<template>
  <view :class="classNames(bem.e('item'), rootClass)" :style="itemStyle">
    <view :class="bem.e('wrapper')">
      <view :class="bem.e('content')" @click="onClick">
        <slot>
          <view :class="bem.e('icon')">
            <slot name="icon">
              <sar-icon
                :name="icon"
                :color="iconColor"
                :size="iconSize"
                :family="iconFamily"
              />
            </slot>
          </view>
          <view :class="bem.e('text')">
            <slot name="text">{{ text }}</slot>
          </view>
        </slot>
      </view>
    </view>
  </view>
</template>

<script lang="ts">
import { defineComponent as _defineComponent } from "vue";
import { computed, inject } from "vue";
import { stringifyStyle, createBem, classNames } from "../utils";
import { gridSymbol, gridItemProps } from "../grid/common";
import SarIcon from "../icon/icon.vue";
const __default__ = {
  options: {
    virtualHost: true,
    styleIsolation: "shared"
  }
};
export default /* @__PURE__ */ _defineComponent({
  ...__default__,
  __name: "grid-item",
  props: gridItemProps,
  emits: ["click"],
  setup(__props, { expose: __expose, emit: __emit }) {
    __expose();
    const props = __props;
    const emit = __emit;
    const bem = createBem("grid");
    const context = inject(gridSymbol);
    if (!context) {
      throw new Error("GridItem must be included in Grid.");
    }
    const onClick = (event) => {
      emit("click", event);
    };
    const itemStyle = computed(() => {
      const width = 1 / context.columns * 100 + "%";
      const gutter = context.gutter;
      return stringifyStyle(
        context.gap ? {
          paddingLeft: gutter[0] + gutter[1],
          paddingRight: gutter[0] + gutter[1]
        } : null,
        {
          width,
          flexBasis: width
        },
        props.rootStyle
      );
    });
    const __returned__ = { props, emit, bem, context, onClick, itemStyle, get classNames() {
      return classNames;
    }, SarIcon };
    return __returned__;
  }
});
</script>

<style lang="scss">
@use './index.scss';
</style>