import { computed, unref } from "vue";
import { propsFactory, convertToUnit, getCurrentInstanceName } from "../../utils/dist/index.mjs";
const POSITIONS = ["static", "relative", "fixed", "absolute", "sticky"];
const makePositionProps = propsFactory({
  absolute: Boolean,
  bottom: [Boolean, Number, String],
  fixed: Boolean,
  left: [Boolean, Number, String],
  position: {
    type: String,
    validator: (v) => POSITIONS.includes(v)
  },
  right: [Boolean, Number, String],
  top: [Boolean, Number, String]
}, "position");
function usePosition(props, name = getCurrentInstanceName()) {
  const targets = ["top", "right", "bottom", "left"];
  const positionClasses = computed(() => {
    const { fixed, absolute, position } = unref(props);
    if (fixed) {
      return `${name}--fixed`;
    } else if (absolute) {
      return `${name}--absolute`;
    } else if (position) {
      return `position-${position}`;
    }
    return null;
  });
  const positionStyles = computed(() => {
    const unrefedProps = unref(props);
    const styles = {};
    for (const target of targets) {
      const prop = unrefedProps[target];
      if (prop == null || prop === false)
        continue;
      styles[target] = convertToUnit(prop === true ? "0" : String(prop));
    }
    return styles;
  });
  return {
    positionClasses,
    positionStyles
  };
}
export {
  POSITIONS,
  makePositionProps,
  usePosition
};
//# sourceMappingURL=index.mjs.map
