{"version":3,"file":"VCol.mjs","names":["makeComponentProps","breakpoints","makeTagProps","capitalize","computed","h","genericComponent","propsFactory","breakpointProps","reduce","props","val","type","Boolean","String","Number","default","offsetProps","offsetKey","orderProps","orderKey","propMap","col","Object","keys","offset","order","breakpointClass","prop","className","undefined","breakpoint","replace","toLowerCase","ALIGN_SELF_VALUES","makeVColProps","cols","alignSelf","validator","str","includes","VCol","name","setup","_ref","slots","classes","classList","forEach","value","push","hasColClasses","some","startsWith","tag","class","style"],"sources":["../../../src/components/VGrid/VCol.ts"],"sourcesContent":["// Styles\nimport './VGrid.sass'\n\n// Composables\nimport { makeComponentProps } from '@/composables/component'\nimport { breakpoints } from '@/composables/display'\nimport { makeTagProps } from '@/composables/tag'\n\n// Utilities\nimport { capitalize, computed, h } from 'vue'\nimport { genericComponent, propsFactory } from '@/util'\n\n// Types\nimport type { Prop, PropType } from 'vue'\nimport type { Breakpoint } from '@/composables/display'\n\ntype BreakpointOffset = `offset${Capitalize<Breakpoint>}`\ntype BreakpointOrder = `order${Capitalize<Breakpoint>}`\n\nconst breakpointProps = (() => {\n  return breakpoints.reduce((props, val) => {\n    props[val] = {\n      type: [Boolean, String, Number],\n      default: false,\n    }\n    return props\n  }, {} as Record<Breakpoint, Prop<boolean | string | number, false>>)\n})()\n\nconst offsetProps = (() => {\n  return breakpoints.reduce((props, val) => {\n    const offsetKey = ('offset' + capitalize(val)) as BreakpointOffset\n    props[offsetKey] = {\n      type: [String, Number],\n      default: null,\n    }\n    return props\n  }, {} as Record<BreakpointOffset, Prop<string | number, null>>)\n})()\n\nconst orderProps = (() => {\n  return breakpoints.reduce((props, val) => {\n    const orderKey = ('order' + capitalize(val)) as BreakpointOrder\n    props[orderKey] = {\n      type: [String, Number],\n      default: null,\n    }\n    return props\n  }, {} as Record<BreakpointOrder, Prop<string | number, null>>)\n})()\n\nconst propMap = {\n  col: Object.keys(breakpointProps),\n  offset: Object.keys(offsetProps),\n  order: Object.keys(orderProps),\n}\n\nfunction breakpointClass (type: keyof typeof propMap, prop: string, val: boolean | string | number) {\n  let className: string = type\n  if (val == null || val === false) {\n    return undefined\n  }\n  if (prop) {\n    const breakpoint = prop.replace(type, '')\n    className += `-${breakpoint}`\n  }\n  if (type === 'col') {\n    className = 'v-' + className\n  }\n  // Handling the boolean style prop when accepting [Boolean, String, Number]\n  // means Vue will not convert <v-col sm></v-col> to sm: true for us.\n  // Since the default is false, an empty string indicates the prop's presence.\n  if (type === 'col' && (val === '' || val === true)) {\n    // .v-col-md\n    return className.toLowerCase()\n  }\n  // .order-md-6\n  className += `-${val}`\n  return className.toLowerCase()\n}\n\nconst ALIGN_SELF_VALUES = ['auto', 'start', 'end', 'center', 'baseline', 'stretch'] as const\n\nexport const makeVColProps = propsFactory({\n  cols: {\n    type: [Boolean, String, Number],\n    default: false,\n  },\n  ...breakpointProps,\n  offset: {\n    type: [String, Number],\n    default: null,\n  },\n  ...offsetProps,\n  order: {\n    type: [String, Number],\n    default: null,\n  },\n  ...orderProps,\n  alignSelf: {\n    type: String as PropType<typeof ALIGN_SELF_VALUES[number]>,\n    default: null,\n    validator: (str: any) => ALIGN_SELF_VALUES.includes(str),\n  },\n\n  ...makeComponentProps(),\n  ...makeTagProps(),\n}, 'VCol')\n\nexport const VCol = genericComponent()({\n  name: 'VCol',\n\n  props: makeVColProps(),\n\n  setup (props, { slots }) {\n    const classes = computed(() => {\n      const classList: any[] = []\n\n      // Loop through `col`, `offset`, `order` breakpoint props\n      let type: keyof typeof propMap\n      for (type in propMap) {\n        propMap[type].forEach(prop => {\n          const value: string | number | boolean = (props as any)[prop]\n          const className = breakpointClass(type, prop, value)\n          if (className) classList!.push(className)\n        })\n      }\n\n      const hasColClasses = classList.some(className => className.startsWith('v-col-'))\n\n      classList.push({\n        // Default to .v-col if no other col-{bp}-* classes generated nor `cols` specified.\n        'v-col': !hasColClasses || !props.cols,\n        [`v-col-${props.cols}`]: props.cols,\n        [`offset-${props.offset}`]: props.offset,\n        [`order-${props.order}`]: props.order,\n        [`align-self-${props.alignSelf}`]: props.alignSelf,\n      })\n\n      return classList\n    })\n\n    return () => h(props.tag, {\n      class: [\n        classes.value,\n        props.class,\n      ],\n      style: props.style,\n    }, slots.default?.())\n  },\n})\n\nexport type VCol = InstanceType<typeof VCol>\n"],"mappings":"AAAA;AACA;;AAEA;AAAA,SACSA,kBAAkB;AAAA,SAClBC,WAAW;AAAA,SACXC,YAAY,qCAErB;AACA,SAASC,UAAU,EAAEC,QAAQ,EAAEC,CAAC,QAAQ,KAAK;AAAA,SACpCC,gBAAgB,EAAEC,YAAY,gCAEvC;AAOA,MAAMC,eAAe,GAAG,CAAC,MAAM;EAC7B,OAAOP,WAAW,CAACQ,MAAM,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;IACxCD,KAAK,CAACC,GAAG,CAAC,GAAG;MACXC,IAAI,EAAE,CAACC,OAAO,EAAEC,MAAM,EAAEC,MAAM,CAAC;MAC/BC,OAAO,EAAE;IACX,CAAC;IACD,OAAON,KAAK;EACd,CAAC,EAAE,CAAC,CAA+D,CAAC;AACtE,CAAC,EAAE,CAAC;AAEJ,MAAMO,WAAW,GAAG,CAAC,MAAM;EACzB,OAAOhB,WAAW,CAACQ,MAAM,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;IACxC,MAAMO,SAAS,GAAI,QAAQ,GAAGf,UAAU,CAACQ,GAAG,CAAsB;IAClED,KAAK,CAACQ,SAAS,CAAC,GAAG;MACjBN,IAAI,EAAE,CAACE,MAAM,EAAEC,MAAM,CAAC;MACtBC,OAAO,EAAE;IACX,CAAC;IACD,OAAON,KAAK;EACd,CAAC,EAAE,CAAC,CAA0D,CAAC;AACjE,CAAC,EAAE,CAAC;AAEJ,MAAMS,UAAU,GAAG,CAAC,MAAM;EACxB,OAAOlB,WAAW,CAACQ,MAAM,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;IACxC,MAAMS,QAAQ,GAAI,OAAO,GAAGjB,UAAU,CAACQ,GAAG,CAAqB;IAC/D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