1 |
- {"version":3,"file":"VStepperItem.mjs","names":["VAvatar","VIcon","makeGroupItemProps","useGroupItem","Ripple","computed","VStepperSymbol","genericComponent","propsFactory","useRender","makeVStepperItemProps","color","String","title","subtitle","complete","Boolean","completeIcon","type","default","editable","editIcon","error","errorIcon","icon","ripple","Object","rules","Array","VStepperItem","name","directives","props","emits","val","setup","_ref","slots","group","step","value","isValid","every","handler","canEdit","disabled","hasError","hasCompleted","length","slotProps","hasColor","isSelected","hasTitle","hasSubtitle","onClick","toggle","_withDirectives","_createVNode","selectedClass","undefined","_resolveDirective"],"sources":["../../../src/labs/VStepper/VStepperItem.tsx"],"sourcesContent":["// Styles\nimport './VStepperItem.sass'\n\n// Components\nimport { VAvatar } from '@/components/VAvatar/VAvatar'\nimport { VIcon } from '@/components/VIcon/VIcon'\n\n// Composables\nimport { makeGroupItemProps, useGroupItem } from '@/composables/group'\n\n// Directives\nimport { Ripple } from '@/directives/ripple'\n\n// Utilities\nimport { computed } from 'vue'\nimport { VStepperSymbol } from './VStepper'\nimport { genericComponent, propsFactory, useRender } from '@/util'\n\n// Types\nimport type { PropType } from 'vue'\nimport type { RippleDirectiveBinding } from '@/directives/ripple'\n\nexport type StepperItemSlot = {\n canEdit: boolean\n hasError: boolean\n hasCompleted: boolean\n title?: string\n subtitle?: string\n step: any\n}\n\nexport type VStepperItemSlots = {\n default: StepperItemSlot\n icon: StepperItemSlot\n title: StepperItemSlot\n subtitle: StepperItemSlot\n}\n\nexport type ValidationRule = () => string | boolean\n\nexport const makeVStepperItemProps = propsFactory({\n color: String,\n title: String,\n subtitle: String,\n complete: Boolean,\n completeIcon: {\n type: String,\n default: '$complete',\n },\n editable: Boolean,\n editIcon: {\n type: String,\n default: '$edit',\n },\n error: Boolean,\n errorIcon: {\n type: String,\n default: '$error',\n },\n icon: String,\n ripple: {\n type: [Boolean, Object] as PropType<RippleDirectiveBinding['value']>,\n default: true,\n },\n rules: {\n type: Array as PropType<readonly ValidationRule[]>,\n default: () => ([]),\n },\n\n ...makeGroupItemProps(),\n}, 'VStepperItem')\n\nexport const VStepperItem = genericComponent<VStepperItemSlots>()({\n name: 'VStepperItem',\n\n directives: { Ripple },\n\n props: makeVStepperItemProps(),\n\n emits: {\n 'group:selected': (val: { value: boolean }) => true,\n },\n\n setup (props, { slots }) {\n const group = useGroupItem(props, VStepperSymbol, true)\n const step = computed(() => group?.value.value ?? props.value)\n const isValid = computed(() => props.rules.every(handler => handler() === true))\n const canEdit = computed(() => !props.disabled && props.editable)\n const hasError = computed(() => props.error || !isValid.value)\n const hasCompleted = computed(() => props.complete || (props.rules.length > 0 && isValid.value))\n const icon = computed(() => {\n if (hasError.value) return props.errorIcon\n if (hasCompleted.value) return props.completeIcon\n if (props.editable) return props.editIcon\n\n return props.icon\n })\n const slotProps = computed(() => ({\n canEdit: canEdit.value,\n hasError: hasError.value,\n hasCompleted: hasCompleted.value,\n title: props.title,\n subtitle: props.subtitle,\n step: step.value,\n value: props.value,\n }))\n\n useRender(() => {\n const hasColor = (\n !group ||\n group.isSelected.value ||\n hasCompleted.value ||\n canEdit.value\n ) && (\n !hasError.value &&\n !props.disabled\n )\n const hasTitle = !!(props.title || slots.title)\n const hasSubtitle = !!(props.subtitle || slots.subtitle)\n\n function onClick () {\n group?.toggle()\n }\n\n return (\n <button\n class={[\n 'v-stepper-item',\n {\n 'v-stepper-item--complete': hasCompleted.value,\n 'v-stepper-item--disabled': props.disabled,\n 'v-stepper-item--error': hasError.value,\n },\n group?.selectedClass.value,\n ]}\n disabled={ !props.editable }\n v-ripple={[\n props.ripple && props.editable,\n null,\n null,\n ]}\n onClick={ onClick }\n >\n <VAvatar\n key=\"stepper-avatar\"\n class=\"v-stepper-item__avatar\"\n color={ hasColor ? props.color : undefined }\n size={ 24 }\n >\n { slots.icon?.(slotProps.value) ?? (\n icon.value ? (\n <VIcon icon={ icon.value }></VIcon>\n ) : step.value\n )}\n </VAvatar>\n\n <div class=\"v-stepper-item__content\">\n { hasTitle && (\n <div\n key=\"title\"\n class=\"v-stepper-item__title\"\n >\n { slots.title?.(slotProps.value) ?? props.title }\n </div>\n )}\n\n { hasSubtitle && (\n <div\n key=\"subtitle\"\n class=\"v-stepper-item__subtitle\"\n >\n { slots.subtitle?.(slotProps.value) ?? props.subtitle }\n </div>\n )}\n\n { slots.default?.(slotProps.value) }\n </div>\n </button>\n )\n })\n return {}\n },\n})\n"],"mappings":";AAAA;AACA;;AAEA;AAAA,SACSA,OAAO;AAAA,SACPC,KAAK,4CAEd;AAAA,SACSC,kBAAkB,EAAEC,YAAY,uCAEzC;AAAA,SACSC,MAAM,6CAEf;AACA,SAASC,QAAQ,QAAQ,KAAK;AAAA,SACrBC,cAAc;AAAA,SACdC,gBAAgB,EAAEC,YAAY,EAAEC,SAAS,gCAElD;AAsBA,OAAO,MAAMC,qBAAqB,GAAGF,YAAY,CAAC;EAChDG,KAAK,EAAEC,MAAM;EACbC,KAAK,EAAED,MAAM;EACbE,QAAQ,EAAEF,MAAM;EAChBG,QAAQ,EAAEC,OAAO;EACjBC,YAAY,EAAE;IACZC,IAAI,EAAEN,MAAM;IACZO,OAAO,EAAE;EACX,CAAC;EACDC,QAAQ,EAAEJ,OAAO;EACjBK,QAAQ,EAAE;IACRH,IAAI,EAAEN,MAAM;IACZO,OAAO,EAAE;EACX,CAAC;EACDG,KAAK,EAAEN,OAAO;EACdO,SAAS,EAAE;IACTL,IAAI,EAAEN,MAAM;IACZO,OAAO,EAAE;EACX,CAAC;EACDK,IAAI,EAAEZ,MAAM;EACZa,MAAM,EAAE;IACNP,IAAI,EAAE,CAACF,OAAO,EAAEU,MAAM,CAA8C;IACpEP,OAAO,EAAE;EACX,CAAC;EACDQ,KAAK,EAAE;IACLT,IAAI,EAAEU,KAA4C;IAClDT,OAAO,EAAEA,CAAA,KAAO;EAClB,CAAC;EAED,GAAGjB,kBAAkB;AACvB,CAAC,EAAE,cAAc,CAAC;AAElB,OAAO,MAAM2B,YAAY,GAAGtB,gBAAgB,EAAqB,CAAC;EACh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