reka-ui 2.3.0 → 2.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Accordion/AccordionItem.cjs +1 -1
- package/dist/Accordion/AccordionItem.cjs.map +1 -1
- package/dist/Accordion/AccordionItem.js +1 -1
- package/dist/Accordion/AccordionItem.js.map +1 -1
- package/dist/AlertDialog/AlertDialogContent.cjs +0 -1
- package/dist/AlertDialog/AlertDialogContent.cjs.map +1 -1
- package/dist/AlertDialog/AlertDialogContent.js +0 -1
- package/dist/AlertDialog/AlertDialogContent.js.map +1 -1
- package/dist/Combobox/ComboboxCancel.cjs +1 -1
- package/dist/Combobox/ComboboxCancel.cjs.map +1 -1
- package/dist/Combobox/ComboboxCancel.js +1 -1
- package/dist/Combobox/ComboboxCancel.js.map +1 -1
- package/dist/Combobox/ComboboxContentImpl.cjs +1 -1
- package/dist/Combobox/ComboboxContentImpl.js +1 -1
- package/dist/Combobox/ComboboxEmpty.cjs +1 -1
- package/dist/Combobox/ComboboxEmpty.cjs.map +1 -1
- package/dist/Combobox/ComboboxEmpty.js +1 -1
- package/dist/Combobox/ComboboxEmpty.js.map +1 -1
- package/dist/Combobox/ComboboxGroup.cjs +1 -1
- package/dist/Combobox/ComboboxGroup.cjs.map +1 -1
- package/dist/Combobox/ComboboxGroup.js +1 -1
- package/dist/Combobox/ComboboxGroup.js.map +1 -1
- package/dist/Combobox/ComboboxInput.cjs +7 -10
- package/dist/Combobox/ComboboxInput.cjs.map +1 -1
- package/dist/Combobox/ComboboxInput.js +7 -10
- package/dist/Combobox/ComboboxInput.js.map +1 -1
- package/dist/Combobox/ComboboxItem.cjs +2 -2
- package/dist/Combobox/ComboboxItem.cjs.map +1 -1
- package/dist/Combobox/ComboboxItem.js +2 -2
- package/dist/Combobox/ComboboxItem.js.map +1 -1
- package/dist/Combobox/ComboboxRoot.cjs +23 -33
- package/dist/Combobox/ComboboxRoot.cjs.map +1 -1
- package/dist/Combobox/ComboboxRoot.js +24 -34
- package/dist/Combobox/ComboboxRoot.js.map +1 -1
- package/dist/DateRangePicker/DateRangePickerCalendar.cjs +2 -1
- package/dist/DateRangePicker/DateRangePickerCalendar.cjs.map +1 -1
- package/dist/DateRangePicker/DateRangePickerCalendar.js +2 -1
- package/dist/DateRangePicker/DateRangePickerCalendar.js.map +1 -1
- package/dist/DateRangePicker/DateRangePickerRoot.cjs +5 -2
- package/dist/DateRangePicker/DateRangePickerRoot.cjs.map +1 -1
- package/dist/DateRangePicker/DateRangePickerRoot.js +5 -2
- package/dist/DateRangePicker/DateRangePickerRoot.js.map +1 -1
- package/dist/Dialog/DialogContent.cjs +0 -1
- package/dist/Dialog/DialogContent.cjs.map +1 -1
- package/dist/Dialog/DialogContent.js +0 -1
- package/dist/Dialog/DialogContent.js.map +1 -1
- package/dist/Dialog/DialogContentImpl.cjs +1 -1
- package/dist/Dialog/DialogContentImpl.js +1 -1
- package/dist/DismissableLayer/utils.cjs +12 -4
- package/dist/DismissableLayer/utils.cjs.map +1 -1
- package/dist/DismissableLayer/utils.js +12 -4
- package/dist/DismissableLayer/utils.js.map +1 -1
- package/dist/Editable/EditableRoot.cjs +2 -2
- package/dist/Editable/EditableRoot.cjs.map +1 -1
- package/dist/Editable/EditableRoot.js +2 -2
- package/dist/Editable/EditableRoot.js.map +1 -1
- package/dist/HoverCard/HoverCardContentImpl.cjs +1 -1
- package/dist/HoverCard/HoverCardContentImpl.js +1 -1
- package/dist/Listbox/ListboxFilter.cjs +1 -1
- package/dist/Listbox/ListboxFilter.cjs.map +1 -1
- package/dist/Listbox/ListboxFilter.js +1 -1
- package/dist/Listbox/ListboxFilter.js.map +1 -1
- package/dist/Listbox/ListboxRoot.cjs.map +1 -1
- package/dist/Listbox/ListboxRoot.js.map +1 -1
- package/dist/Listbox/ListboxVirtualizer.cjs +1 -1
- package/dist/Listbox/ListboxVirtualizer.cjs.map +1 -1
- package/dist/Listbox/ListboxVirtualizer.js +1 -1
- package/dist/Listbox/ListboxVirtualizer.js.map +1 -1
- package/dist/Menu/MenuContentImpl.cjs +1 -1
- package/dist/Menu/MenuContentImpl.js +1 -1
- package/dist/NavigationMenu/NavigationMenuContentImpl.cjs +1 -1
- package/dist/NavigationMenu/NavigationMenuContentImpl.js +1 -1
- package/dist/PinInput/PinInputInput.cjs +14 -6
- package/dist/PinInput/PinInputInput.cjs.map +1 -1
- package/dist/PinInput/PinInputInput.js +14 -6
- package/dist/PinInput/PinInputInput.js.map +1 -1
- package/dist/PinInput/PinInputRoot.cjs +4 -2
- package/dist/PinInput/PinInputRoot.cjs.map +1 -1
- package/dist/PinInput/PinInputRoot.js +4 -2
- package/dist/PinInput/PinInputRoot.js.map +1 -1
- package/dist/Popover/PopoverContentImpl.cjs +1 -1
- package/dist/Popover/PopoverContentImpl.js +1 -1
- package/dist/Primitive/Slot.cjs +7 -7
- package/dist/Primitive/Slot.cjs.map +1 -1
- package/dist/Primitive/Slot.js +7 -7
- package/dist/Primitive/Slot.js.map +1 -1
- package/dist/RadioGroup/Radio.cjs +2 -0
- package/dist/RadioGroup/Radio.cjs.map +1 -1
- package/dist/RadioGroup/Radio.js +2 -0
- package/dist/RadioGroup/Radio.js.map +1 -1
- package/dist/RangeCalendar/useRangeCalendar.cjs +22 -4
- package/dist/RangeCalendar/useRangeCalendar.cjs.map +1 -1
- package/dist/RangeCalendar/useRangeCalendar.js +22 -4
- package/dist/RangeCalendar/useRangeCalendar.js.map +1 -1
- package/dist/Select/SelectContent.cjs +8 -4
- package/dist/Select/SelectContent.cjs.map +1 -1
- package/dist/Select/SelectContent.js +9 -5
- package/dist/Select/SelectContent.js.map +1 -1
- package/dist/Select/SelectContentImpl.cjs +1 -1
- package/dist/Select/SelectContentImpl.js +1 -1
- package/dist/Select/SelectItemText.cjs +1 -1
- package/dist/Select/SelectItemText.cjs.map +1 -1
- package/dist/Select/SelectItemText.js +2 -2
- package/dist/Select/SelectItemText.js.map +1 -1
- package/dist/Stepper/StepperRoot.cjs +1 -1
- package/dist/Stepper/StepperRoot.cjs.map +1 -1
- package/dist/Stepper/StepperRoot.js +1 -1
- package/dist/Stepper/StepperRoot.js.map +1 -1
- package/dist/Toast/ToastViewport.cjs +1 -1
- package/dist/Toast/ToastViewport.js +1 -1
- package/dist/Tooltip/TooltipContentImpl.cjs +1 -1
- package/dist/Tooltip/TooltipContentImpl.js +1 -1
- package/dist/constant/components.cjs.map +1 -1
- package/dist/constant/components.js.map +1 -1
- package/dist/constant.d.ts +60 -0
- package/dist/date/useDateField.cjs +6 -2
- package/dist/date/useDateField.cjs.map +1 -1
- package/dist/date/useDateField.js +6 -2
- package/dist/date/useDateField.js.map +1 -1
- package/dist/index.d.ts +17 -16
- package/dist/nuxt/index.cjs +14 -14
- package/dist/nuxt/index.d.cts +2 -2
- package/dist/nuxt/index.d.mts +2 -2
- package/dist/nuxt/index.mjs +14 -14
- package/dist/resolver/index.cjs +9 -5
- package/dist/resolver/index.mjs +9 -5
- package/dist/shared/useForwardProps.cjs +2 -4
- package/dist/shared/useForwardProps.cjs.map +1 -1
- package/dist/shared/useForwardProps.js +3 -5
- package/dist/shared/useForwardProps.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PinInputRoot.cjs","sources":["../../src/PinInput/PinInputRoot.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { ComputedRef, Ref } from 'vue'\nimport type { PrimitiveProps } from '@/Primitive'\nimport type { Direction, FormFieldProps } from '@/shared/types'\nimport { computed, ref, toRefs, watch } from 'vue'\nimport { createContext, useDirection, useForwardExpose } from '@/shared'\nimport VisuallyHiddenInput from '@/VisuallyHidden/VisuallyHiddenInput.vue'\n\nexport type PinInputType = 'text' | 'number'\n\n// Using this type to avoid mixed arrays (string | number)[].\nexport type PinInputValue<Type extends PinInputType = 'text'> = Type extends 'number' ? number[] : string[]\n\nexport type PinInputRootEmits<Type extends PinInputType = 'text'> = {\n 'update:modelValue': [value: PinInputValue<Type>]\n 'complete': [value: PinInputValue<Type>]\n}\n\nexport interface PinInputRootProps<Type extends PinInputType = 'text'> extends PrimitiveProps, FormFieldProps {\n /** The controlled checked state of the pin input. Can be binded as `v-model`. */\n modelValue?: PinInputValue<Type> | null\n /** The default value of the pin inputs when it is initially rendered. Use when you do not need to control its checked state. */\n defaultValue?: PinInputValue<Type>[]\n /** The placeholder character to use for empty pin-inputs. */\n placeholder?: string\n /** When `true`, pin inputs will be treated as password. */\n mask?: boolean\n /** When `true`, mobile devices will autodetect the OTP from messages or clipboard, and enable the autocomplete field. */\n otp?: boolean\n /** Input type for the inputs. */\n type?: Type\n /** The reading direction of the combobox when applicable. <br> If omitted, inherits globally from `ConfigProvider` or assumes LTR (left-to-right) reading mode. */\n dir?: Direction\n /** When `true`, prevents the user from interacting with the pin input */\n disabled?: boolean\n /** Id of the element */\n id?: string\n}\n\nexport interface PinInputRootContext<Type extends PinInputType = 'text'> {\n modelValue: Ref<PinInputValue<Type>>\n currentModelValue: ComputedRef<PinInputValue<Type>>\n mask: Ref<boolean>\n otp: Ref<boolean>\n placeholder: Ref<string>\n type: Ref<PinInputType>\n dir: Ref<Direction>\n disabled: Ref<boolean>\n isCompleted: ComputedRef<boolean>\n inputElements?: Ref<Set<HTMLInputElement>>\n onInputElementChange: (el: HTMLInputElement) => void\n}\n\nexport const [injectPinInputRootContext, providePinInputRootContext]\n = createContext<PinInputRootContext<PinInputType>>('PinInputRoot')\n</script>\n\n<script setup lang=\"ts\" generic=\"Type extends PinInputType = 'text'\">\nimport { useVModel } from '@vueuse/core'\nimport { Primitive } from '@/Primitive'\n\ndefineOptions({\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<PinInputRootProps<Type>>(), {\n placeholder: '',\n type: 'text' as any,\n})\nconst emits = defineEmits<PinInputRootEmits<Type>>()\n\ndefineSlots<{\n default?: (props: {\n /** Current input values */\n modelValue: typeof modelValue.value\n }) => any\n}>()\n\nconst { mask, otp, placeholder, type, disabled, dir: propDir } = toRefs(props)\nconst { forwardRef } = useForwardExpose()\nconst dir = useDirection(propDir)\n\nconst modelValue = useVModel(props, 'modelValue', emits, {\n defaultValue: props.defaultValue ?? [] as any,\n passive: (props.modelValue === undefined) as false,\n}) as Ref<PinInputValue<Type>>\n\nconst currentModelValue = computed(() => Array.isArray(modelValue.value) ? [...modelValue.value] : [])\n\nconst inputElements = ref<Set<HTMLInputElement>>(new Set())\nfunction onInputElementChange(el: HTMLInputElement) {\n inputElements.value.add(el)\n}\n\nconst isCompleted = computed(() => {\n const modelValues = currentModelValue.value.filter(i => !!i)\n return modelValues.length === inputElements.value.size\n})\n\nwatch(modelValue, () => {\n if (isCompleted.value)\n emits('complete', modelValue.value)\n}, { deep: true })\n\nprovidePinInputRootContext({\n modelValue,\n currentModelValue: currentModelValue as ComputedRef<PinInputValue<Type>>,\n mask,\n otp,\n placeholder,\n type,\n dir,\n disabled,\n isCompleted,\n inputElements,\n onInputElementChange,\n})\n</script>\n\n<template>\n <Primitive\n v-bind=\"$attrs\"\n :ref=\"forwardRef\"\n :dir=\"dir\"\n :data-complete=\"isCompleted ? '' : undefined\"\n :data-disabled=\"disabled ? '' : undefined\"\n >\n <slot :model-value=\"modelValue\" />\n\n <VisuallyHiddenInput\n :id=\"id\"\n as=\"input\"\n feature=\"focusable\"\n tabindex=\"-1\"\n :value=\"currentModelValue.join('')\"\n :name=\"name ?? ''\"\n :disabled=\"disabled\"\n :required=\"required\"\n @focus=\"Array.from(inputElements)?.[0]?.focus()\"\n />\n </Primitive>\n</template>\n"],"names":["createContext","toRefs","useForwardExpose","useDirection","useVModel","computed","ref","watch"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"PinInputRoot.cjs","sources":["../../src/PinInput/PinInputRoot.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { ComputedRef, Ref } from 'vue'\nimport type { PrimitiveProps } from '@/Primitive'\nimport type { Direction, FormFieldProps } from '@/shared/types'\nimport { computed, ref, toRefs, watch } from 'vue'\nimport { createContext, useDirection, useForwardExpose } from '@/shared'\nimport VisuallyHiddenInput from '@/VisuallyHidden/VisuallyHiddenInput.vue'\n\nexport type PinInputType = 'text' | 'number'\n\n// Using this type to avoid mixed arrays (string | number)[].\nexport type PinInputValue<Type extends PinInputType = 'text'> = Type extends 'number' ? number[] : string[]\n\nexport type PinInputRootEmits<Type extends PinInputType = 'text'> = {\n 'update:modelValue': [value: PinInputValue<Type>]\n 'complete': [value: PinInputValue<Type>]\n}\n\nexport interface PinInputRootProps<Type extends PinInputType = 'text'> extends PrimitiveProps, FormFieldProps {\n /** The controlled checked state of the pin input. Can be binded as `v-model`. */\n modelValue?: PinInputValue<Type> | null\n /** The default value of the pin inputs when it is initially rendered. Use when you do not need to control its checked state. */\n defaultValue?: PinInputValue<Type>[]\n /** The placeholder character to use for empty pin-inputs. */\n placeholder?: string\n /** When `true`, pin inputs will be treated as password. */\n mask?: boolean\n /** When `true`, mobile devices will autodetect the OTP from messages or clipboard, and enable the autocomplete field. */\n otp?: boolean\n /** Input type for the inputs. */\n type?: Type\n /** The reading direction of the combobox when applicable. <br> If omitted, inherits globally from `ConfigProvider` or assumes LTR (left-to-right) reading mode. */\n dir?: Direction\n /** When `true`, prevents the user from interacting with the pin input */\n disabled?: boolean\n /** Id of the element */\n id?: string\n}\n\nexport interface PinInputRootContext<Type extends PinInputType = 'text'> {\n modelValue: Ref<PinInputValue<Type>>\n currentModelValue: ComputedRef<PinInputValue<Type>>\n mask: Ref<boolean>\n otp: Ref<boolean>\n placeholder: Ref<string>\n type: Ref<PinInputType>\n dir: Ref<Direction>\n disabled: Ref<boolean>\n isCompleted: ComputedRef<boolean>\n inputElements?: Ref<Set<HTMLInputElement>>\n onInputElementChange: (el: HTMLInputElement) => void\n isNumericMode: ComputedRef<boolean>\n}\n\nexport const [injectPinInputRootContext, providePinInputRootContext]\n = createContext<PinInputRootContext<PinInputType>>('PinInputRoot')\n</script>\n\n<script setup lang=\"ts\" generic=\"Type extends PinInputType = 'text'\">\nimport { useVModel } from '@vueuse/core'\nimport { Primitive } from '@/Primitive'\n\ndefineOptions({\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<PinInputRootProps<Type>>(), {\n placeholder: '',\n type: 'text' as any,\n})\nconst emits = defineEmits<PinInputRootEmits<Type>>()\n\ndefineSlots<{\n default?: (props: {\n /** Current input values */\n modelValue: typeof modelValue.value\n }) => any\n}>()\n\nconst { mask, otp, placeholder, type, disabled, dir: propDir } = toRefs(props)\nconst { forwardRef } = useForwardExpose()\nconst dir = useDirection(propDir)\n\nconst modelValue = useVModel(props, 'modelValue', emits, {\n defaultValue: props.defaultValue ?? [] as any,\n passive: (props.modelValue === undefined) as false,\n}) as Ref<PinInputValue<Type>>\n\nconst currentModelValue = computed(() => Array.isArray(modelValue.value) ? [...modelValue.value] : [])\n\nconst inputElements = ref<Set<HTMLInputElement>>(new Set())\nfunction onInputElementChange(el: HTMLInputElement) {\n inputElements.value.add(el)\n}\n\nconst isNumericMode = computed(() => props.type === 'number')\nconst isCompleted = computed(() => {\n const modelValues = currentModelValue.value.filter(i => !!i || (isNumericMode.value && i === 0))\n return modelValues.length === inputElements.value.size\n})\n\nwatch(modelValue, () => {\n if (isCompleted.value)\n emits('complete', modelValue.value)\n}, { deep: true })\n\nprovidePinInputRootContext({\n modelValue,\n currentModelValue: currentModelValue as ComputedRef<PinInputValue<Type>>,\n mask,\n otp,\n placeholder,\n type,\n dir,\n disabled,\n isCompleted,\n inputElements,\n onInputElementChange,\n isNumericMode,\n})\n</script>\n\n<template>\n <Primitive\n v-bind=\"$attrs\"\n :ref=\"forwardRef\"\n :dir=\"dir\"\n :data-complete=\"isCompleted ? '' : undefined\"\n :data-disabled=\"disabled ? '' : undefined\"\n >\n <slot :model-value=\"modelValue\" />\n\n <VisuallyHiddenInput\n :id=\"id\"\n as=\"input\"\n feature=\"focusable\"\n tabindex=\"-1\"\n :value=\"currentModelValue.join('')\"\n :name=\"name ?? ''\"\n :disabled=\"disabled\"\n :required=\"required\"\n @focus=\"Array.from(inputElements)?.[0]?.focus()\"\n />\n </Primitive>\n</template>\n"],"names":["createContext","toRefs","useForwardExpose","useDirection","useVModel","computed","ref","watch"],"mappings":";;;;;;;;;;AAsDO,MAAM,CAAC,yBAAA,EAA2B,0BAA0B,CAAA,GAC/DA,mCAAiD,cAAc;;;;;;;;;;;;;;;;;;;;;;;AAWnE,IAAA,MAAM,KAAQ,GAAA,OAAA;AAId,IAAA,MAAM,KAAQ,GAAA,MAAA;AASd,IAAM,MAAA,EAAE,IAAM,EAAA,GAAA,EAAK,WAAa,EAAA,IAAA,EAAM,UAAU,GAAK,EAAA,OAAA,EAAY,GAAAC,UAAA,CAAO,KAAK,CAAA;AAC7E,IAAM,MAAA,EAAE,UAAW,EAAA,GAAIC,wCAAiB,EAAA;AACxC,IAAM,MAAA,GAAA,GAAMC,iCAAa,OAAO,CAAA;AAEhC,IAAA,MAAM,UAAa,GAAAC,cAAA,CAAU,KAAO,EAAA,YAAA,EAAc,KAAO,EAAA;AAAA,MACvD,YAAA,EAAc,KAAM,CAAA,YAAA,IAAgB,EAAC;AAAA,MACrC,OAAA,EAAU,MAAM,UAAe,KAAA;AAAA,KAChC,CAAA;AAED,IAAA,MAAM,iBAAoB,GAAAC,YAAA,CAAS,MAAM,KAAA,CAAM,QAAQ,UAAW,CAAA,KAAK,CAAI,GAAA,CAAC,GAAG,UAAA,CAAW,KAAK,CAAA,GAAI,EAAE,CAAA;AAErG,IAAA,MAAM,aAAgB,GAAAC,OAAA,iBAA+B,IAAA,GAAA,EAAK,CAAA;AAC1D,IAAA,SAAS,qBAAqB,EAAsB,EAAA;AAClD,MAAc,aAAA,CAAA,KAAA,CAAM,IAAI,EAAE,CAAA;AAAA;AAG5B,IAAA,MAAM,aAAgB,GAAAD,YAAA,CAAS,MAAM,KAAA,CAAM,SAAS,QAAQ,CAAA;AAC5D,IAAM,MAAA,WAAA,GAAcA,aAAS,MAAM;AACjC,MAAM,MAAA,WAAA,GAAc,iBAAkB,CAAA,KAAA,CAAM,MAAO,CAAA,CAAA,CAAA,KAAK,CAAC,CAAC,CAAM,IAAA,aAAA,CAAc,KAAS,IAAA,CAAA,KAAM,CAAE,CAAA;AAC/F,MAAO,OAAA,WAAA,CAAY,MAAW,KAAA,aAAA,CAAc,KAAM,CAAA,IAAA;AAAA,KACnD,CAAA;AAED,IAAAE,SAAA,CAAM,YAAY,MAAM;AACtB,MAAA,IAAI,WAAY,CAAA,KAAA;AACd,QAAM,KAAA,CAAA,UAAA,EAAY,WAAW,KAAK,CAAA;AAAA,KACnC,EAAA,EAAE,IAAM,EAAA,IAAA,EAAM,CAAA;AAEjB,IAA2B,0BAAA,CAAA;AAAA,MACzB,UAAA;AAAA,MACA,iBAAA;AAAA,MACA,IAAA;AAAA,MACA,GAAA;AAAA,MACA,WAAA;AAAA,MACA,IAAA;AAAA,MACA,GAAA;AAAA,MACA,QAAA;AAAA,MACA,WAAA;AAAA,MACA,aAAA;AAAA,MACA,oBAAA;AAAA,MACA;AAAA,KACD,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -43,8 +43,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
43
43
|
function onInputElementChange(el) {
|
|
44
44
|
inputElements.value.add(el);
|
|
45
45
|
}
|
|
46
|
+
const isNumericMode = computed(() => props.type === "number");
|
|
46
47
|
const isCompleted = computed(() => {
|
|
47
|
-
const modelValues = currentModelValue.value.filter((i) => !!i);
|
|
48
|
+
const modelValues = currentModelValue.value.filter((i) => !!i || isNumericMode.value && i === 0);
|
|
48
49
|
return modelValues.length === inputElements.value.size;
|
|
49
50
|
});
|
|
50
51
|
watch(modelValue, () => {
|
|
@@ -62,7 +63,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
62
63
|
disabled,
|
|
63
64
|
isCompleted,
|
|
64
65
|
inputElements,
|
|
65
|
-
onInputElementChange
|
|
66
|
+
onInputElementChange,
|
|
67
|
+
isNumericMode
|
|
66
68
|
});
|
|
67
69
|
return (_ctx, _cache) => {
|
|
68
70
|
return openBlock(), createBlock(unref(Primitive), mergeProps(_ctx.$attrs, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PinInputRoot.js","sources":["../../src/PinInput/PinInputRoot.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { ComputedRef, Ref } from 'vue'\nimport type { PrimitiveProps } from '@/Primitive'\nimport type { Direction, FormFieldProps } from '@/shared/types'\nimport { computed, ref, toRefs, watch } from 'vue'\nimport { createContext, useDirection, useForwardExpose } from '@/shared'\nimport VisuallyHiddenInput from '@/VisuallyHidden/VisuallyHiddenInput.vue'\n\nexport type PinInputType = 'text' | 'number'\n\n// Using this type to avoid mixed arrays (string | number)[].\nexport type PinInputValue<Type extends PinInputType = 'text'> = Type extends 'number' ? number[] : string[]\n\nexport type PinInputRootEmits<Type extends PinInputType = 'text'> = {\n 'update:modelValue': [value: PinInputValue<Type>]\n 'complete': [value: PinInputValue<Type>]\n}\n\nexport interface PinInputRootProps<Type extends PinInputType = 'text'> extends PrimitiveProps, FormFieldProps {\n /** The controlled checked state of the pin input. Can be binded as `v-model`. */\n modelValue?: PinInputValue<Type> | null\n /** The default value of the pin inputs when it is initially rendered. Use when you do not need to control its checked state. */\n defaultValue?: PinInputValue<Type>[]\n /** The placeholder character to use for empty pin-inputs. */\n placeholder?: string\n /** When `true`, pin inputs will be treated as password. */\n mask?: boolean\n /** When `true`, mobile devices will autodetect the OTP from messages or clipboard, and enable the autocomplete field. */\n otp?: boolean\n /** Input type for the inputs. */\n type?: Type\n /** The reading direction of the combobox when applicable. <br> If omitted, inherits globally from `ConfigProvider` or assumes LTR (left-to-right) reading mode. */\n dir?: Direction\n /** When `true`, prevents the user from interacting with the pin input */\n disabled?: boolean\n /** Id of the element */\n id?: string\n}\n\nexport interface PinInputRootContext<Type extends PinInputType = 'text'> {\n modelValue: Ref<PinInputValue<Type>>\n currentModelValue: ComputedRef<PinInputValue<Type>>\n mask: Ref<boolean>\n otp: Ref<boolean>\n placeholder: Ref<string>\n type: Ref<PinInputType>\n dir: Ref<Direction>\n disabled: Ref<boolean>\n isCompleted: ComputedRef<boolean>\n inputElements?: Ref<Set<HTMLInputElement>>\n onInputElementChange: (el: HTMLInputElement) => void\n}\n\nexport const [injectPinInputRootContext, providePinInputRootContext]\n = createContext<PinInputRootContext<PinInputType>>('PinInputRoot')\n</script>\n\n<script setup lang=\"ts\" generic=\"Type extends PinInputType = 'text'\">\nimport { useVModel } from '@vueuse/core'\nimport { Primitive } from '@/Primitive'\n\ndefineOptions({\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<PinInputRootProps<Type>>(), {\n placeholder: '',\n type: 'text' as any,\n})\nconst emits = defineEmits<PinInputRootEmits<Type>>()\n\ndefineSlots<{\n default?: (props: {\n /** Current input values */\n modelValue: typeof modelValue.value\n }) => any\n}>()\n\nconst { mask, otp, placeholder, type, disabled, dir: propDir } = toRefs(props)\nconst { forwardRef } = useForwardExpose()\nconst dir = useDirection(propDir)\n\nconst modelValue = useVModel(props, 'modelValue', emits, {\n defaultValue: props.defaultValue ?? [] as any,\n passive: (props.modelValue === undefined) as false,\n}) as Ref<PinInputValue<Type>>\n\nconst currentModelValue = computed(() => Array.isArray(modelValue.value) ? [...modelValue.value] : [])\n\nconst inputElements = ref<Set<HTMLInputElement>>(new Set())\nfunction onInputElementChange(el: HTMLInputElement) {\n inputElements.value.add(el)\n}\n\nconst isCompleted = computed(() => {\n const modelValues = currentModelValue.value.filter(i => !!i)\n return modelValues.length === inputElements.value.size\n})\n\nwatch(modelValue, () => {\n if (isCompleted.value)\n emits('complete', modelValue.value)\n}, { deep: true })\n\nprovidePinInputRootContext({\n modelValue,\n currentModelValue: currentModelValue as ComputedRef<PinInputValue<Type>>,\n mask,\n otp,\n placeholder,\n type,\n dir,\n disabled,\n isCompleted,\n inputElements,\n onInputElementChange,\n})\n</script>\n\n<template>\n <Primitive\n v-bind=\"$attrs\"\n :ref=\"forwardRef\"\n :dir=\"dir\"\n :data-complete=\"isCompleted ? '' : undefined\"\n :data-disabled=\"disabled ? '' : undefined\"\n >\n <slot :model-value=\"modelValue\" />\n\n <VisuallyHiddenInput\n :id=\"id\"\n as=\"input\"\n feature=\"focusable\"\n tabindex=\"-1\"\n :value=\"currentModelValue.join('')\"\n :name=\"name ?? ''\"\n :disabled=\"disabled\"\n :required=\"required\"\n @focus=\"Array.from(inputElements)?.[0]?.focus()\"\n />\n </Primitive>\n</template>\n"],"names":[],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"PinInputRoot.js","sources":["../../src/PinInput/PinInputRoot.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { ComputedRef, Ref } from 'vue'\nimport type { PrimitiveProps } from '@/Primitive'\nimport type { Direction, FormFieldProps } from '@/shared/types'\nimport { computed, ref, toRefs, watch } from 'vue'\nimport { createContext, useDirection, useForwardExpose } from '@/shared'\nimport VisuallyHiddenInput from '@/VisuallyHidden/VisuallyHiddenInput.vue'\n\nexport type PinInputType = 'text' | 'number'\n\n// Using this type to avoid mixed arrays (string | number)[].\nexport type PinInputValue<Type extends PinInputType = 'text'> = Type extends 'number' ? number[] : string[]\n\nexport type PinInputRootEmits<Type extends PinInputType = 'text'> = {\n 'update:modelValue': [value: PinInputValue<Type>]\n 'complete': [value: PinInputValue<Type>]\n}\n\nexport interface PinInputRootProps<Type extends PinInputType = 'text'> extends PrimitiveProps, FormFieldProps {\n /** The controlled checked state of the pin input. Can be binded as `v-model`. */\n modelValue?: PinInputValue<Type> | null\n /** The default value of the pin inputs when it is initially rendered. Use when you do not need to control its checked state. */\n defaultValue?: PinInputValue<Type>[]\n /** The placeholder character to use for empty pin-inputs. */\n placeholder?: string\n /** When `true`, pin inputs will be treated as password. */\n mask?: boolean\n /** When `true`, mobile devices will autodetect the OTP from messages or clipboard, and enable the autocomplete field. */\n otp?: boolean\n /** Input type for the inputs. */\n type?: Type\n /** The reading direction of the combobox when applicable. <br> If omitted, inherits globally from `ConfigProvider` or assumes LTR (left-to-right) reading mode. */\n dir?: Direction\n /** When `true`, prevents the user from interacting with the pin input */\n disabled?: boolean\n /** Id of the element */\n id?: string\n}\n\nexport interface PinInputRootContext<Type extends PinInputType = 'text'> {\n modelValue: Ref<PinInputValue<Type>>\n currentModelValue: ComputedRef<PinInputValue<Type>>\n mask: Ref<boolean>\n otp: Ref<boolean>\n placeholder: Ref<string>\n type: Ref<PinInputType>\n dir: Ref<Direction>\n disabled: Ref<boolean>\n isCompleted: ComputedRef<boolean>\n inputElements?: Ref<Set<HTMLInputElement>>\n onInputElementChange: (el: HTMLInputElement) => void\n isNumericMode: ComputedRef<boolean>\n}\n\nexport const [injectPinInputRootContext, providePinInputRootContext]\n = createContext<PinInputRootContext<PinInputType>>('PinInputRoot')\n</script>\n\n<script setup lang=\"ts\" generic=\"Type extends PinInputType = 'text'\">\nimport { useVModel } from '@vueuse/core'\nimport { Primitive } from '@/Primitive'\n\ndefineOptions({\n inheritAttrs: false,\n})\n\nconst props = withDefaults(defineProps<PinInputRootProps<Type>>(), {\n placeholder: '',\n type: 'text' as any,\n})\nconst emits = defineEmits<PinInputRootEmits<Type>>()\n\ndefineSlots<{\n default?: (props: {\n /** Current input values */\n modelValue: typeof modelValue.value\n }) => any\n}>()\n\nconst { mask, otp, placeholder, type, disabled, dir: propDir } = toRefs(props)\nconst { forwardRef } = useForwardExpose()\nconst dir = useDirection(propDir)\n\nconst modelValue = useVModel(props, 'modelValue', emits, {\n defaultValue: props.defaultValue ?? [] as any,\n passive: (props.modelValue === undefined) as false,\n}) as Ref<PinInputValue<Type>>\n\nconst currentModelValue = computed(() => Array.isArray(modelValue.value) ? [...modelValue.value] : [])\n\nconst inputElements = ref<Set<HTMLInputElement>>(new Set())\nfunction onInputElementChange(el: HTMLInputElement) {\n inputElements.value.add(el)\n}\n\nconst isNumericMode = computed(() => props.type === 'number')\nconst isCompleted = computed(() => {\n const modelValues = currentModelValue.value.filter(i => !!i || (isNumericMode.value && i === 0))\n return modelValues.length === inputElements.value.size\n})\n\nwatch(modelValue, () => {\n if (isCompleted.value)\n emits('complete', modelValue.value)\n}, { deep: true })\n\nprovidePinInputRootContext({\n modelValue,\n currentModelValue: currentModelValue as ComputedRef<PinInputValue<Type>>,\n mask,\n otp,\n placeholder,\n type,\n dir,\n disabled,\n isCompleted,\n inputElements,\n onInputElementChange,\n isNumericMode,\n})\n</script>\n\n<template>\n <Primitive\n v-bind=\"$attrs\"\n :ref=\"forwardRef\"\n :dir=\"dir\"\n :data-complete=\"isCompleted ? '' : undefined\"\n :data-disabled=\"disabled ? '' : undefined\"\n >\n <slot :model-value=\"modelValue\" />\n\n <VisuallyHiddenInput\n :id=\"id\"\n as=\"input\"\n feature=\"focusable\"\n tabindex=\"-1\"\n :value=\"currentModelValue.join('')\"\n :name=\"name ?? ''\"\n :disabled=\"disabled\"\n :required=\"required\"\n @focus=\"Array.from(inputElements)?.[0]?.focus()\"\n />\n </Primitive>\n</template>\n"],"names":[],"mappings":";;;;;;;;AAsDO,MAAM,CAAC,yBAAA,EAA2B,0BAA0B,CAAA,GAC/D,cAAiD,cAAc;;;;;;;;;;;;;;;;;;;;;;;AAWnE,IAAA,MAAM,KAAQ,GAAA,OAAA;AAId,IAAA,MAAM,KAAQ,GAAA,MAAA;AASd,IAAM,MAAA,EAAE,IAAM,EAAA,GAAA,EAAK,WAAa,EAAA,IAAA,EAAM,UAAU,GAAK,EAAA,OAAA,EAAY,GAAA,MAAA,CAAO,KAAK,CAAA;AAC7E,IAAM,MAAA,EAAE,UAAW,EAAA,GAAI,gBAAiB,EAAA;AACxC,IAAM,MAAA,GAAA,GAAM,aAAa,OAAO,CAAA;AAEhC,IAAA,MAAM,UAAa,GAAA,SAAA,CAAU,KAAO,EAAA,YAAA,EAAc,KAAO,EAAA;AAAA,MACvD,YAAA,EAAc,KAAM,CAAA,YAAA,IAAgB,EAAC;AAAA,MACrC,OAAA,EAAU,MAAM,UAAe,KAAA;AAAA,KAChC,CAAA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vue = require('vue');
|
|
4
|
-
const DismissableLayer_DismissableLayer = require('../DismissableLayer/DismissableLayer.cjs');
|
|
5
4
|
const Popper_PopperContent = require('../Popper/PopperContent.cjs');
|
|
6
5
|
const shared = require('@vueuse/shared');
|
|
7
6
|
const shared_useForwardProps = require('../shared/useForwardProps.cjs');
|
|
8
7
|
const shared_useForwardExpose = require('../shared/useForwardExpose.cjs');
|
|
9
8
|
const shared_useFocusGuards = require('../shared/useFocusGuards.cjs');
|
|
10
9
|
const FocusScope_FocusScope = require('../FocusScope/FocusScope.cjs');
|
|
10
|
+
const DismissableLayer_DismissableLayer = require('../DismissableLayer/DismissableLayer.cjs');
|
|
11
11
|
const Popover_PopoverRoot = require('./PopoverRoot.cjs');
|
|
12
12
|
|
|
13
13
|
const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { defineComponent, createBlock, openBlock, unref, withCtx, createVNode, mergeProps, renderSlot } from 'vue';
|
|
2
|
-
import { _ as _sfc_main$2 } from '../DismissableLayer/DismissableLayer.js';
|
|
3
2
|
import { _ as _sfc_main$3 } from '../Popper/PopperContent.js';
|
|
4
3
|
import { reactiveOmit } from '@vueuse/shared';
|
|
5
4
|
import { u as useForwardProps } from '../shared/useForwardProps.js';
|
|
6
5
|
import { u as useForwardExpose } from '../shared/useForwardExpose.js';
|
|
7
6
|
import { u as useFocusGuards } from '../shared/useFocusGuards.js';
|
|
8
7
|
import { _ as _sfc_main$1 } from '../FocusScope/FocusScope.js';
|
|
8
|
+
import { _ as _sfc_main$2 } from '../DismissableLayer/DismissableLayer.js';
|
|
9
9
|
import { i as injectPopoverRootContext } from './PopoverRoot.js';
|
|
10
10
|
|
|
11
11
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
package/dist/Primitive/Slot.cjs
CHANGED
|
@@ -10,18 +10,18 @@ const Slot = vue.defineComponent({
|
|
|
10
10
|
return () => {
|
|
11
11
|
if (!slots.default)
|
|
12
12
|
return null;
|
|
13
|
-
const
|
|
14
|
-
const firstNonCommentChildrenIndex =
|
|
13
|
+
const children = shared_renderSlotFragments.renderSlotFragments(slots.default());
|
|
14
|
+
const firstNonCommentChildrenIndex = children.findIndex((child) => child.type !== vue.Comment);
|
|
15
15
|
if (firstNonCommentChildrenIndex === -1)
|
|
16
|
-
return
|
|
17
|
-
const firstNonCommentChildren =
|
|
16
|
+
return children;
|
|
17
|
+
const firstNonCommentChildren = children[firstNonCommentChildrenIndex];
|
|
18
18
|
delete firstNonCommentChildren.props?.ref;
|
|
19
19
|
const mergedProps = firstNonCommentChildren.props ? vue.mergeProps(attrs, firstNonCommentChildren.props) : attrs;
|
|
20
20
|
const cloned = vue.cloneVNode({ ...firstNonCommentChildren, props: {} }, mergedProps);
|
|
21
|
-
if (
|
|
21
|
+
if (children.length === 1)
|
|
22
22
|
return cloned;
|
|
23
|
-
|
|
24
|
-
return
|
|
23
|
+
children[firstNonCommentChildrenIndex] = cloned;
|
|
24
|
+
return children;
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
27
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slot.cjs","sources":["../../src/Primitive/Slot.ts"],"sourcesContent":["import { cloneVNode, Comment, defineComponent, mergeProps } from 'vue'\nimport { renderSlotFragments } from '@/shared'\n\nexport const Slot = defineComponent({\n name: 'PrimitiveSlot',\n inheritAttrs: false,\n setup(_, { attrs, slots }) {\n return () => {\n if (!slots.default)\n return null\n\n const
|
|
1
|
+
{"version":3,"file":"Slot.cjs","sources":["../../src/Primitive/Slot.ts"],"sourcesContent":["import { cloneVNode, Comment, defineComponent, mergeProps } from 'vue'\nimport { renderSlotFragments } from '@/shared'\n\nexport const Slot = defineComponent({\n name: 'PrimitiveSlot',\n inheritAttrs: false,\n setup(_, { attrs, slots }) {\n return () => {\n if (!slots.default)\n return null\n\n const children = renderSlotFragments(slots.default())\n const firstNonCommentChildrenIndex = children.findIndex(child => child.type !== Comment)\n if (firstNonCommentChildrenIndex === -1)\n return children\n\n const firstNonCommentChildren = children[firstNonCommentChildrenIndex]\n\n // Remove props ref from being inferred\n delete firstNonCommentChildren.props?.ref\n\n // Manually merge props to ensure `firstNonCommentChildren.props`\n // has higher priority than `attrs` and can override `attrs`.\n // Otherwise `cloneVNode(firstNonCommentChildren, attrs)` will\n // prioritize `attrs` and override `firstNonCommentChildren.props`.\n const mergedProps = firstNonCommentChildren.props\n ? mergeProps(attrs, firstNonCommentChildren.props)\n : attrs\n const cloned = cloneVNode({ ...firstNonCommentChildren, props: {} }, mergedProps)\n\n if (children.length === 1)\n return cloned\n\n children[firstNonCommentChildrenIndex] = cloned\n return children\n }\n },\n})\n"],"names":["defineComponent","renderSlotFragments","Comment","mergeProps","cloneVNode"],"mappings":";;;;;AAGO,MAAM,OAAOA,mBAAgB,CAAA;AAAA,EAClC,IAAM,EAAA,eAAA;AAAA,EACN,YAAc,EAAA,KAAA;AAAA,EACd,KAAM,CAAA,CAAA,EAAG,EAAE,KAAA,EAAO,OAAS,EAAA;AACzB,IAAA,OAAO,MAAM;AACX,MAAA,IAAI,CAAC,KAAM,CAAA,OAAA;AACT,QAAO,OAAA,IAAA;AAET,MAAA,MAAM,QAAW,GAAAC,8CAAA,CAAoB,KAAM,CAAA,OAAA,EAAS,CAAA;AACpD,MAAA,MAAM,+BAA+B,QAAS,CAAA,SAAA,CAAU,CAAS,KAAA,KAAA,KAAA,CAAM,SAASC,WAAO,CAAA;AACvF,MAAA,IAAI,4BAAiC,KAAA,EAAA;AACnC,QAAO,OAAA,QAAA;AAET,MAAM,MAAA,uBAAA,GAA0B,SAAS,4BAA4B,CAAA;AAGrE,MAAA,OAAO,wBAAwB,KAAO,EAAA,GAAA;AAMtC,MAAA,MAAM,cAAc,uBAAwB,CAAA,KAAA,GACxCC,eAAW,KAAO,EAAA,uBAAA,CAAwB,KAAK,CAC/C,GAAA,KAAA;AACJ,MAAM,MAAA,MAAA,GAASC,eAAW,EAAE,GAAG,yBAAyB,KAAO,EAAA,EAAG,EAAA,EAAG,WAAW,CAAA;AAEhF,MAAA,IAAI,SAAS,MAAW,KAAA,CAAA;AACtB,QAAO,OAAA,MAAA;AAET,MAAA,QAAA,CAAS,4BAA4B,CAAI,GAAA,MAAA;AACzC,MAAO,OAAA,QAAA;AAAA,KACT;AAAA;AAEJ,CAAC;;;;"}
|
package/dist/Primitive/Slot.js
CHANGED
|
@@ -8,18 +8,18 @@ const Slot = defineComponent({
|
|
|
8
8
|
return () => {
|
|
9
9
|
if (!slots.default)
|
|
10
10
|
return null;
|
|
11
|
-
const
|
|
12
|
-
const firstNonCommentChildrenIndex =
|
|
11
|
+
const children = renderSlotFragments(slots.default());
|
|
12
|
+
const firstNonCommentChildrenIndex = children.findIndex((child) => child.type !== Comment);
|
|
13
13
|
if (firstNonCommentChildrenIndex === -1)
|
|
14
|
-
return
|
|
15
|
-
const firstNonCommentChildren =
|
|
14
|
+
return children;
|
|
15
|
+
const firstNonCommentChildren = children[firstNonCommentChildrenIndex];
|
|
16
16
|
delete firstNonCommentChildren.props?.ref;
|
|
17
17
|
const mergedProps = firstNonCommentChildren.props ? mergeProps(attrs, firstNonCommentChildren.props) : attrs;
|
|
18
18
|
const cloned = cloneVNode({ ...firstNonCommentChildren, props: {} }, mergedProps);
|
|
19
|
-
if (
|
|
19
|
+
if (children.length === 1)
|
|
20
20
|
return cloned;
|
|
21
|
-
|
|
22
|
-
return
|
|
21
|
+
children[firstNonCommentChildrenIndex] = cloned;
|
|
22
|
+
return children;
|
|
23
23
|
};
|
|
24
24
|
}
|
|
25
25
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Slot.js","sources":["../../src/Primitive/Slot.ts"],"sourcesContent":["import { cloneVNode, Comment, defineComponent, mergeProps } from 'vue'\nimport { renderSlotFragments } from '@/shared'\n\nexport const Slot = defineComponent({\n name: 'PrimitiveSlot',\n inheritAttrs: false,\n setup(_, { attrs, slots }) {\n return () => {\n if (!slots.default)\n return null\n\n const
|
|
1
|
+
{"version":3,"file":"Slot.js","sources":["../../src/Primitive/Slot.ts"],"sourcesContent":["import { cloneVNode, Comment, defineComponent, mergeProps } from 'vue'\nimport { renderSlotFragments } from '@/shared'\n\nexport const Slot = defineComponent({\n name: 'PrimitiveSlot',\n inheritAttrs: false,\n setup(_, { attrs, slots }) {\n return () => {\n if (!slots.default)\n return null\n\n const children = renderSlotFragments(slots.default())\n const firstNonCommentChildrenIndex = children.findIndex(child => child.type !== Comment)\n if (firstNonCommentChildrenIndex === -1)\n return children\n\n const firstNonCommentChildren = children[firstNonCommentChildrenIndex]\n\n // Remove props ref from being inferred\n delete firstNonCommentChildren.props?.ref\n\n // Manually merge props to ensure `firstNonCommentChildren.props`\n // has higher priority than `attrs` and can override `attrs`.\n // Otherwise `cloneVNode(firstNonCommentChildren, attrs)` will\n // prioritize `attrs` and override `firstNonCommentChildren.props`.\n const mergedProps = firstNonCommentChildren.props\n ? mergeProps(attrs, firstNonCommentChildren.props)\n : attrs\n const cloned = cloneVNode({ ...firstNonCommentChildren, props: {} }, mergedProps)\n\n if (children.length === 1)\n return cloned\n\n children[firstNonCommentChildrenIndex] = cloned\n return children\n }\n },\n})\n"],"names":[],"mappings":";;;AAGO,MAAM,OAAO,eAAgB,CAAA;AAAA,EAClC,IAAM,EAAA,eAAA;AAAA,EACN,YAAc,EAAA,KAAA;AAAA,EACd,KAAM,CAAA,CAAA,EAAG,EAAE,KAAA,EAAO,OAAS,EAAA;AACzB,IAAA,OAAO,MAAM;AACX,MAAA,IAAI,CAAC,KAAM,CAAA,OAAA;AACT,QAAO,OAAA,IAAA;AAET,MAAA,MAAM,QAAW,GAAA,mBAAA,CAAoB,KAAM,CAAA,OAAA,EAAS,CAAA;AACpD,MAAA,MAAM,+BAA+B,QAAS,CAAA,SAAA,CAAU,CAAS,KAAA,KAAA,KAAA,CAAM,SAAS,OAAO,CAAA;AACvF,MAAA,IAAI,4BAAiC,KAAA,EAAA;AACnC,QAAO,OAAA,QAAA;AAET,MAAM,MAAA,uBAAA,GAA0B,SAAS,4BAA4B,CAAA;AAGrE,MAAA,OAAO,wBAAwB,KAAO,EAAA,GAAA;AAMtC,MAAA,MAAM,cAAc,uBAAwB,CAAA,KAAA,GACxC,WAAW,KAAO,EAAA,uBAAA,CAAwB,KAAK,CAC/C,GAAA,KAAA;AACJ,MAAM,MAAA,MAAA,GAAS,WAAW,EAAE,GAAG,yBAAyB,KAAO,EAAA,EAAG,EAAA,EAAG,WAAW,CAAA;AAEhF,MAAA,IAAI,SAAS,MAAW,KAAA,CAAA;AACtB,QAAO,OAAA,MAAA;AAET,MAAA,QAAA,CAAS,4BAA4B,CAAI,GAAA,MAAA;AACzC,MAAO,OAAA,QAAA;AAAA,KACT;AAAA;AAEJ,CAAC;;;;"}
|
|
@@ -32,6 +32,8 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
32
32
|
const isFormControl = shared_useFormControl.useFormControl(triggerElement);
|
|
33
33
|
const ariaLabel = vue.computed(() => props.id && triggerElement.value ? document.querySelector(`[for="${props.id}"]`)?.innerText ?? props.value : void 0);
|
|
34
34
|
function handleClick(event) {
|
|
35
|
+
if (props.disabled)
|
|
36
|
+
return;
|
|
35
37
|
RadioGroup_utils.handleSelect(event, props.value, (ev) => {
|
|
36
38
|
emits("select", ev);
|
|
37
39
|
if (ev?.defaultPrevented)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.cjs","sources":["../../src/RadioGroup/Radio.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { SelectEvent } from './utils'\nimport type { PrimitiveProps } from '@/Primitive'\nimport type { AcceptableValue, FormFieldProps } from '@/shared/types'\n\nexport type RadioEmits = {\n 'update:checked': [value: boolean]\n 'select': [SelectEvent]\n}\n\nexport interface RadioProps extends PrimitiveProps, FormFieldProps {\n id?: string\n /** The value given as data when submitted with a `name`. */\n value?: AcceptableValue\n /** When `true`, prevents the user from interacting with the radio item. */\n disabled?: boolean\n checked?: boolean\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { useVModel } from '@vueuse/core'\nimport { computed, toRefs } from 'vue'\nimport { Primitive } from '@/Primitive'\nimport { useFormControl, useForwardExpose } from '@/shared'\nimport { VisuallyHiddenInput } from '@/VisuallyHidden'\nimport { handleSelect } from './utils'\n\nconst props = withDefaults(defineProps<RadioProps>(), {\n disabled: false,\n checked: undefined,\n as: 'button',\n})\nconst emits = defineEmits<RadioEmits>()\n\ndefineSlots<{\n default?: (props: {\n /** Current checked state */\n checked: typeof checked.value\n }) => any\n}>()\n\nconst checked = useVModel(props, 'checked', emits, {\n passive: (props.checked === undefined) as false,\n})\n\nconst { value } = toRefs(props)\nconst { forwardRef, currentElement: triggerElement } = useForwardExpose()\nconst isFormControl = useFormControl(triggerElement)\n\nconst ariaLabel = computed(() => props.id && triggerElement.value ? (document.querySelector(`[for=\"${props.id}\"]`) as HTMLLabelElement)?.innerText ?? props.value : undefined)\n\nfunction handleClick(event: MouseEvent) {\n handleSelect(event, props.value, (ev) => {\n emits('select', ev)\n if (ev?.defaultPrevented)\n return\n\n checked.value = true\n if (isFormControl.value) {\n // if radio is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect radio updates.\n ev.stopPropagation()\n }\n })\n}\n</script>\n\n<template>\n <Primitive\n v-bind=\"$attrs\"\n :id=\"id\"\n :ref=\"forwardRef\"\n role=\"radio\"\n :type=\"as === 'button' ? 'button' : undefined\"\n :as=\"as\"\n :aria-checked=\"checked\"\n :aria-label=\"ariaLabel\"\n :as-child=\"asChild\"\n :disabled=\"disabled ? '' : undefined\"\n :data-state=\"checked ? 'checked' : 'unchecked'\"\n :data-disabled=\"disabled ? '' : undefined\"\n :value=\"value\"\n :required=\"required\"\n :name=\"name\"\n @click.stop=\"handleClick\"\n >\n <slot :checked=\"checked\" />\n\n <VisuallyHiddenInput\n v-if=\"isFormControl && name\"\n type=\"radio\"\n tabindex=\"-1\"\n :value=\"value\"\n :checked=\"!!checked\"\n :name=\"name\"\n :disabled=\"disabled\"\n :required=\"required\"\n />\n </Primitive>\n</template>\n"],"names":["useVModel","toRefs","useForwardExpose","useFormControl","computed","handleSelect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAA,MAAM,KAAQ,GAAA,OAAA;AAKd,IAAA,MAAM,KAAQ,GAAA,MAAA;AASd,IAAA,MAAM,OAAU,GAAAA,cAAA,CAAU,KAAO,EAAA,SAAA,EAAW,KAAO,EAAA;AAAA,MACjD,OAAA,EAAU,MAAM,OAAY,KAAA;AAAA,KAC7B,CAAA;AAED,IAAA,MAAM,EAAE,KAAA,EAAU,GAAAC,UAAA,CAAO,KAAK,CAAA;AAC9B,IAAA,MAAM,EAAE,UAAA,EAAY,cAAgB,EAAA,cAAA,KAAmBC,wCAAiB,EAAA;AACxE,IAAM,MAAA,aAAA,GAAgBC,qCAAe,cAAc,CAAA;AAEnD,IAAA,MAAM,YAAYC,YAAS,CAAA,MAAM,KAAM,CAAA,EAAA,IAAM,eAAe,KAAS,GAAA,QAAA,CAAS,aAAc,CAAA,CAAA,MAAA,EAAS,MAAM,EAAE,CAAA,EAAA,CAAI,GAAwB,SAAa,IAAA,KAAA,CAAM,QAAQ,MAAS,CAAA;AAE7K,IAAA,SAAS,YAAY,KAAmB,EAAA;AACtC,MAAAC,6BAAA,CAAa,KAAO,EAAA,KAAA,CAAM,KAAO,EAAA,CAAC,EAAO,KAAA;AACvC,QAAA,KAAA,CAAM,UAAU,EAAE,CAAA;AAClB,QAAA,IAAI,EAAI,EAAA,gBAAA;AACN,UAAA;AAEF,QAAA,OAAA,CAAQ,KAAQ,GAAA,IAAA;AAChB,QAAA,IAAI,cAAc,KAAO,EAAA;AAIvB,UAAA,EAAA,CAAG,eAAgB,EAAA;AAAA;AACrB,OACD,CAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Radio.cjs","sources":["../../src/RadioGroup/Radio.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { SelectEvent } from './utils'\nimport type { PrimitiveProps } from '@/Primitive'\nimport type { AcceptableValue, FormFieldProps } from '@/shared/types'\n\nexport type RadioEmits = {\n 'update:checked': [value: boolean]\n 'select': [SelectEvent]\n}\n\nexport interface RadioProps extends PrimitiveProps, FormFieldProps {\n id?: string\n /** The value given as data when submitted with a `name`. */\n value?: AcceptableValue\n /** When `true`, prevents the user from interacting with the radio item. */\n disabled?: boolean\n checked?: boolean\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { useVModel } from '@vueuse/core'\nimport { computed, toRefs } from 'vue'\nimport { Primitive } from '@/Primitive'\nimport { useFormControl, useForwardExpose } from '@/shared'\nimport { VisuallyHiddenInput } from '@/VisuallyHidden'\nimport { handleSelect } from './utils'\n\nconst props = withDefaults(defineProps<RadioProps>(), {\n disabled: false,\n checked: undefined,\n as: 'button',\n})\nconst emits = defineEmits<RadioEmits>()\n\ndefineSlots<{\n default?: (props: {\n /** Current checked state */\n checked: typeof checked.value\n }) => any\n}>()\n\nconst checked = useVModel(props, 'checked', emits, {\n passive: (props.checked === undefined) as false,\n})\n\nconst { value } = toRefs(props)\nconst { forwardRef, currentElement: triggerElement } = useForwardExpose()\nconst isFormControl = useFormControl(triggerElement)\n\nconst ariaLabel = computed(() => props.id && triggerElement.value ? (document.querySelector(`[for=\"${props.id}\"]`) as HTMLLabelElement)?.innerText ?? props.value : undefined)\n\nfunction handleClick(event: MouseEvent) {\n if (props.disabled)\n return\n\n handleSelect(event, props.value, (ev) => {\n emits('select', ev)\n if (ev?.defaultPrevented)\n return\n\n checked.value = true\n if (isFormControl.value) {\n // if radio is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect radio updates.\n ev.stopPropagation()\n }\n })\n}\n</script>\n\n<template>\n <Primitive\n v-bind=\"$attrs\"\n :id=\"id\"\n :ref=\"forwardRef\"\n role=\"radio\"\n :type=\"as === 'button' ? 'button' : undefined\"\n :as=\"as\"\n :aria-checked=\"checked\"\n :aria-label=\"ariaLabel\"\n :as-child=\"asChild\"\n :disabled=\"disabled ? '' : undefined\"\n :data-state=\"checked ? 'checked' : 'unchecked'\"\n :data-disabled=\"disabled ? '' : undefined\"\n :value=\"value\"\n :required=\"required\"\n :name=\"name\"\n @click.stop=\"handleClick\"\n >\n <slot :checked=\"checked\" />\n\n <VisuallyHiddenInput\n v-if=\"isFormControl && name\"\n type=\"radio\"\n tabindex=\"-1\"\n :value=\"value\"\n :checked=\"!!checked\"\n :name=\"name\"\n :disabled=\"disabled\"\n :required=\"required\"\n />\n </Primitive>\n</template>\n"],"names":["useVModel","toRefs","useForwardExpose","useFormControl","computed","handleSelect"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAA,MAAM,KAAQ,GAAA,OAAA;AAKd,IAAA,MAAM,KAAQ,GAAA,MAAA;AASd,IAAA,MAAM,OAAU,GAAAA,cAAA,CAAU,KAAO,EAAA,SAAA,EAAW,KAAO,EAAA;AAAA,MACjD,OAAA,EAAU,MAAM,OAAY,KAAA;AAAA,KAC7B,CAAA;AAED,IAAA,MAAM,EAAE,KAAA,EAAU,GAAAC,UAAA,CAAO,KAAK,CAAA;AAC9B,IAAA,MAAM,EAAE,UAAA,EAAY,cAAgB,EAAA,cAAA,KAAmBC,wCAAiB,EAAA;AACxE,IAAM,MAAA,aAAA,GAAgBC,qCAAe,cAAc,CAAA;AAEnD,IAAA,MAAM,YAAYC,YAAS,CAAA,MAAM,KAAM,CAAA,EAAA,IAAM,eAAe,KAAS,GAAA,QAAA,CAAS,aAAc,CAAA,CAAA,MAAA,EAAS,MAAM,EAAE,CAAA,EAAA,CAAI,GAAwB,SAAa,IAAA,KAAA,CAAM,QAAQ,MAAS,CAAA;AAE7K,IAAA,SAAS,YAAY,KAAmB,EAAA;AACtC,MAAA,IAAI,KAAM,CAAA,QAAA;AACR,QAAA;AAEF,MAAAC,6BAAA,CAAa,KAAO,EAAA,KAAA,CAAM,KAAO,EAAA,CAAC,EAAO,KAAA;AACvC,QAAA,KAAA,CAAM,UAAU,EAAE,CAAA;AAClB,QAAA,IAAI,EAAI,EAAA,gBAAA;AACN,UAAA;AAEF,QAAA,OAAA,CAAQ,KAAQ,GAAA,IAAA;AAChB,QAAA,IAAI,cAAc,KAAO,EAAA;AAIvB,UAAA,EAAA,CAAG,eAAgB,EAAA;AAAA;AACrB,OACD,CAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/RadioGroup/Radio.js
CHANGED
|
@@ -30,6 +30,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
30
30
|
const isFormControl = useFormControl(triggerElement);
|
|
31
31
|
const ariaLabel = computed(() => props.id && triggerElement.value ? document.querySelector(`[for="${props.id}"]`)?.innerText ?? props.value : void 0);
|
|
32
32
|
function handleClick(event) {
|
|
33
|
+
if (props.disabled)
|
|
34
|
+
return;
|
|
33
35
|
handleSelect(event, props.value, (ev) => {
|
|
34
36
|
emits("select", ev);
|
|
35
37
|
if (ev?.defaultPrevented)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Radio.js","sources":["../../src/RadioGroup/Radio.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { SelectEvent } from './utils'\nimport type { PrimitiveProps } from '@/Primitive'\nimport type { AcceptableValue, FormFieldProps } from '@/shared/types'\n\nexport type RadioEmits = {\n 'update:checked': [value: boolean]\n 'select': [SelectEvent]\n}\n\nexport interface RadioProps extends PrimitiveProps, FormFieldProps {\n id?: string\n /** The value given as data when submitted with a `name`. */\n value?: AcceptableValue\n /** When `true`, prevents the user from interacting with the radio item. */\n disabled?: boolean\n checked?: boolean\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { useVModel } from '@vueuse/core'\nimport { computed, toRefs } from 'vue'\nimport { Primitive } from '@/Primitive'\nimport { useFormControl, useForwardExpose } from '@/shared'\nimport { VisuallyHiddenInput } from '@/VisuallyHidden'\nimport { handleSelect } from './utils'\n\nconst props = withDefaults(defineProps<RadioProps>(), {\n disabled: false,\n checked: undefined,\n as: 'button',\n})\nconst emits = defineEmits<RadioEmits>()\n\ndefineSlots<{\n default?: (props: {\n /** Current checked state */\n checked: typeof checked.value\n }) => any\n}>()\n\nconst checked = useVModel(props, 'checked', emits, {\n passive: (props.checked === undefined) as false,\n})\n\nconst { value } = toRefs(props)\nconst { forwardRef, currentElement: triggerElement } = useForwardExpose()\nconst isFormControl = useFormControl(triggerElement)\n\nconst ariaLabel = computed(() => props.id && triggerElement.value ? (document.querySelector(`[for=\"${props.id}\"]`) as HTMLLabelElement)?.innerText ?? props.value : undefined)\n\nfunction handleClick(event: MouseEvent) {\n handleSelect(event, props.value, (ev) => {\n emits('select', ev)\n if (ev?.defaultPrevented)\n return\n\n checked.value = true\n if (isFormControl.value) {\n // if radio is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect radio updates.\n ev.stopPropagation()\n }\n })\n}\n</script>\n\n<template>\n <Primitive\n v-bind=\"$attrs\"\n :id=\"id\"\n :ref=\"forwardRef\"\n role=\"radio\"\n :type=\"as === 'button' ? 'button' : undefined\"\n :as=\"as\"\n :aria-checked=\"checked\"\n :aria-label=\"ariaLabel\"\n :as-child=\"asChild\"\n :disabled=\"disabled ? '' : undefined\"\n :data-state=\"checked ? 'checked' : 'unchecked'\"\n :data-disabled=\"disabled ? '' : undefined\"\n :value=\"value\"\n :required=\"required\"\n :name=\"name\"\n @click.stop=\"handleClick\"\n >\n <slot :checked=\"checked\" />\n\n <VisuallyHiddenInput\n v-if=\"isFormControl && name\"\n type=\"radio\"\n tabindex=\"-1\"\n :value=\"value\"\n :checked=\"!!checked\"\n :name=\"name\"\n :disabled=\"disabled\"\n :required=\"required\"\n />\n </Primitive>\n</template>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAA,MAAM,KAAQ,GAAA,OAAA;AAKd,IAAA,MAAM,KAAQ,GAAA,MAAA;AASd,IAAA,MAAM,OAAU,GAAA,SAAA,CAAU,KAAO,EAAA,SAAA,EAAW,KAAO,EAAA;AAAA,MACjD,OAAA,EAAU,MAAM,OAAY,KAAA;AAAA,KAC7B,CAAA;AAED,IAAA,MAAM,EAAE,KAAA,EAAU,GAAA,MAAA,CAAO,KAAK,CAAA;AAC9B,IAAA,MAAM,EAAE,UAAA,EAAY,cAAgB,EAAA,cAAA,KAAmB,gBAAiB,EAAA;AACxE,IAAM,MAAA,aAAA,GAAgB,eAAe,cAAc,CAAA;AAEnD,IAAA,MAAM,YAAY,QAAS,CAAA,MAAM,KAAM,CAAA,EAAA,IAAM,eAAe,KAAS,GAAA,QAAA,CAAS,aAAc,CAAA,CAAA,MAAA,EAAS,MAAM,EAAE,CAAA,EAAA,CAAI,GAAwB,SAAa,IAAA,KAAA,CAAM,QAAQ,MAAS,CAAA;AAE7K,IAAA,SAAS,YAAY,KAAmB,EAAA;AACtC,MAAA,YAAA,CAAa,KAAO,EAAA,KAAA,CAAM,KAAO,EAAA,CAAC,EAAO,KAAA;AACvC,QAAA,KAAA,CAAM,UAAU,EAAE,CAAA;AAClB,QAAA,IAAI,EAAI,EAAA,gBAAA;AACN,UAAA;AAEF,QAAA,OAAA,CAAQ,KAAQ,GAAA,IAAA;AAChB,QAAA,IAAI,cAAc,KAAO,EAAA;AAIvB,UAAA,EAAA,CAAG,eAAgB,EAAA;AAAA;AACrB,OACD,CAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Radio.js","sources":["../../src/RadioGroup/Radio.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { SelectEvent } from './utils'\nimport type { PrimitiveProps } from '@/Primitive'\nimport type { AcceptableValue, FormFieldProps } from '@/shared/types'\n\nexport type RadioEmits = {\n 'update:checked': [value: boolean]\n 'select': [SelectEvent]\n}\n\nexport interface RadioProps extends PrimitiveProps, FormFieldProps {\n id?: string\n /** The value given as data when submitted with a `name`. */\n value?: AcceptableValue\n /** When `true`, prevents the user from interacting with the radio item. */\n disabled?: boolean\n checked?: boolean\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { useVModel } from '@vueuse/core'\nimport { computed, toRefs } from 'vue'\nimport { Primitive } from '@/Primitive'\nimport { useFormControl, useForwardExpose } from '@/shared'\nimport { VisuallyHiddenInput } from '@/VisuallyHidden'\nimport { handleSelect } from './utils'\n\nconst props = withDefaults(defineProps<RadioProps>(), {\n disabled: false,\n checked: undefined,\n as: 'button',\n})\nconst emits = defineEmits<RadioEmits>()\n\ndefineSlots<{\n default?: (props: {\n /** Current checked state */\n checked: typeof checked.value\n }) => any\n}>()\n\nconst checked = useVModel(props, 'checked', emits, {\n passive: (props.checked === undefined) as false,\n})\n\nconst { value } = toRefs(props)\nconst { forwardRef, currentElement: triggerElement } = useForwardExpose()\nconst isFormControl = useFormControl(triggerElement)\n\nconst ariaLabel = computed(() => props.id && triggerElement.value ? (document.querySelector(`[for=\"${props.id}\"]`) as HTMLLabelElement)?.innerText ?? props.value : undefined)\n\nfunction handleClick(event: MouseEvent) {\n if (props.disabled)\n return\n\n handleSelect(event, props.value, (ev) => {\n emits('select', ev)\n if (ev?.defaultPrevented)\n return\n\n checked.value = true\n if (isFormControl.value) {\n // if radio is in a form, stop propagation from the button so that we only propagate\n // one click event (from the input). We propagate changes from an input so that native\n // form validation works and form events reflect radio updates.\n ev.stopPropagation()\n }\n })\n}\n</script>\n\n<template>\n <Primitive\n v-bind=\"$attrs\"\n :id=\"id\"\n :ref=\"forwardRef\"\n role=\"radio\"\n :type=\"as === 'button' ? 'button' : undefined\"\n :as=\"as\"\n :aria-checked=\"checked\"\n :aria-label=\"ariaLabel\"\n :as-child=\"asChild\"\n :disabled=\"disabled ? '' : undefined\"\n :data-state=\"checked ? 'checked' : 'unchecked'\"\n :data-disabled=\"disabled ? '' : undefined\"\n :value=\"value\"\n :required=\"required\"\n :name=\"name\"\n @click.stop=\"handleClick\"\n >\n <slot :checked=\"checked\" />\n\n <VisuallyHiddenInput\n v-if=\"isFormControl && name\"\n type=\"radio\"\n tabindex=\"-1\"\n :value=\"value\"\n :checked=\"!!checked\"\n :name=\"name\"\n :disabled=\"disabled\"\n :required=\"required\"\n />\n </Primitive>\n</template>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAA,MAAM,KAAQ,GAAA,OAAA;AAKd,IAAA,MAAM,KAAQ,GAAA,MAAA;AASd,IAAA,MAAM,OAAU,GAAA,SAAA,CAAU,KAAO,EAAA,SAAA,EAAW,KAAO,EAAA;AAAA,MACjD,OAAA,EAAU,MAAM,OAAY,KAAA;AAAA,KAC7B,CAAA;AAED,IAAA,MAAM,EAAE,KAAA,EAAU,GAAA,MAAA,CAAO,KAAK,CAAA;AAC9B,IAAA,MAAM,EAAE,UAAA,EAAY,cAAgB,EAAA,cAAA,KAAmB,gBAAiB,EAAA;AACxE,IAAM,MAAA,aAAA,GAAgB,eAAe,cAAc,CAAA;AAEnD,IAAA,MAAM,YAAY,QAAS,CAAA,MAAM,KAAM,CAAA,EAAA,IAAM,eAAe,KAAS,GAAA,QAAA,CAAS,aAAc,CAAA,CAAA,MAAA,EAAS,MAAM,EAAE,CAAA,EAAA,CAAI,GAAwB,SAAa,IAAA,KAAA,CAAM,QAAQ,MAAS,CAAA;AAE7K,IAAA,SAAS,YAAY,KAAmB,EAAA;AACtC,MAAA,IAAI,KAAM,CAAA,QAAA;AACR,QAAA;AAEF,MAAA,YAAA,CAAa,KAAO,EAAA,KAAA,CAAM,KAAO,EAAA,CAAC,EAAO,KAAA;AACvC,QAAA,KAAA,CAAM,UAAU,EAAE,CAAA;AAClB,QAAA,IAAI,EAAI,EAAA,gBAAA;AACN,UAAA;AAEF,QAAA,OAAA,CAAQ,KAAQ,GAAA,IAAA;AAChB,QAAA,IAAI,cAAc,KAAO,EAAA;AAIvB,UAAA,EAAA,CAAG,eAAgB,EAAA;AAAA;AACrB,OACD,CAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const date = require('@internationalized/date');
|
|
4
4
|
const vue = require('vue');
|
|
5
|
+
const date_calendar = require('../date/calendar.cjs');
|
|
5
6
|
const date_comparators = require('../date/comparators.cjs');
|
|
6
7
|
|
|
7
8
|
function useRangeCalendarState(props) {
|
|
@@ -50,10 +51,27 @@ function useRangeCalendarState(props) {
|
|
|
50
51
|
const rangeIsDateDisabled = (date$1) => {
|
|
51
52
|
if (props.isDateDisabled(date$1))
|
|
52
53
|
return true;
|
|
53
|
-
if (
|
|
54
|
+
if (props.maximumDays?.value) {
|
|
55
|
+
if (props.start.value && props.end.value) {
|
|
56
|
+
if (props.fixedDate.value) {
|
|
57
|
+
const diff = date_calendar.getDaysBetween(props.start.value, props.end.value).length;
|
|
58
|
+
if (diff <= props.maximumDays.value) {
|
|
59
|
+
const daysLeft = props.maximumDays.value - diff - 1;
|
|
60
|
+
const startLimit = props.start.value.subtract({ days: daysLeft });
|
|
61
|
+
const endLimit = props.end.value.add({ days: daysLeft });
|
|
62
|
+
return !date_comparators.isBetween(date$1, startLimit, endLimit);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (props.start.value) {
|
|
68
|
+
const maxDate = props.start.value.add({ days: props.maximumDays.value });
|
|
69
|
+
const minDate = props.start.value.subtract({ days: props.maximumDays.value });
|
|
70
|
+
return !date_comparators.isBetween(date$1, minDate, maxDate);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (!props.start.value || props.end.value || date.isSameDay(props.start.value, date$1))
|
|
54
74
|
return false;
|
|
55
|
-
if (Math.abs(date$1.compare(props.start.value)) > props.maximumDays.value)
|
|
56
|
-
return true;
|
|
57
75
|
return false;
|
|
58
76
|
};
|
|
59
77
|
const isDateHighlightable = (date) => {
|
|
@@ -75,7 +93,7 @@ function useRangeCalendarState(props) {
|
|
|
75
93
|
end
|
|
76
94
|
};
|
|
77
95
|
}
|
|
78
|
-
if (props.maximumDays?.value && !props.end.value
|
|
96
|
+
if (props.maximumDays?.value && !props.end.value) {
|
|
79
97
|
const cappedEnd = isStartBeforeFocused ? start.add({ days: props.maximumDays.value }) : start.subtract({ days: props.maximumDays.value });
|
|
80
98
|
return {
|
|
81
99
|
start,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRangeCalendar.cjs","sources":["../../src/RangeCalendar/useRangeCalendar.ts"],"sourcesContent":["/*\n * Adapted from https://github.com/melt-ui/melt-ui/blob/develop/src/lib/builders/range-calendar/create.ts\n*/\n\nimport type { DateValue } from '@internationalized/date'\nimport type { Ref } from 'vue'\nimport type { Matcher } from '@/date'\nimport { isSameDay } from '@internationalized/date'\nimport { computed } from 'vue'\nimport { areAllDaysBetweenValid, isBefore, isBetween } from '@/date'\n\nexport type UseRangeCalendarProps = {\n start: Ref<DateValue | undefined>\n end: Ref<DateValue | undefined>\n isDateDisabled: Matcher\n isDateUnavailable: Matcher\n isDateHighlightable?: Matcher\n focusedValue: Ref<DateValue | undefined>\n allowNonContiguousRanges: Ref<boolean>\n fixedDate: Ref<'start' | 'end' | undefined>\n maximumDays?: Ref<number | undefined>\n}\n\nexport function useRangeCalendarState(props: UseRangeCalendarProps) {\n const isStartInvalid = computed(() => {\n if (!props.start.value)\n return false\n if (props.isDateDisabled(props.start.value))\n return true\n return false\n })\n\n const isEndInvalid = computed(() => {\n if (!props.end.value)\n return false\n if (props.isDateDisabled(props.end.value))\n return true\n return false\n })\n\n const isInvalid = computed(\n () => {\n if (isStartInvalid.value || isEndInvalid.value)\n return false\n if (props.start.value && props.end.value && isBefore(props.end.value, props.start.value))\n return true\n return false\n },\n )\n\n const isSelectionStart = (date: DateValue) => {\n if (!props.start.value)\n return false\n return isSameDay(props.start.value, date)\n }\n\n const isSelectionEnd = (date: DateValue) => {\n if (!props.end.value)\n return false\n return isSameDay(props.end.value, date)\n }\n\n const isSelected = (date: DateValue) => {\n if (props.start.value && isSameDay(props.start.value, date))\n return true\n if (props.end.value && isSameDay(props.end.value, date))\n return true\n if (props.end.value && props.start.value)\n return isBetween(date, props.start.value, props.end.value)\n\n return false\n }\n\n // Check if a date exceeds maximum days limit from the start date\n const rangeIsDateDisabled = (date: DateValue) => {\n if (props.isDateDisabled(date))\n return true\n\n if (!props.maximumDays?.value || !props.start.value || props.end.value || isSameDay(props.start.value, date))\n return false\n\n // Check if exceeds maximum days limit\n if (Math.abs(date.compare(props.start.value)) > props.maximumDays.value)\n return true\n\n return false\n }\n\n const isDateHighlightable = (date: DateValue) => {\n if (props.isDateHighlightable?.(date))\n return true\n return false\n }\n\n const highlightedRange = computed(() => {\n if (props.start.value && props.end.value && !props.fixedDate.value)\n return null\n if (!props.start.value || !props.focusedValue.value)\n return null\n\n const isStartBeforeFocused = isBefore(props.start.value, props.focusedValue.value)\n const start = isStartBeforeFocused ? props.start.value : props.focusedValue.value\n const end = isStartBeforeFocused ? props.focusedValue.value : props.start.value\n\n if (isSameDay(start, end)) {\n return {\n start,\n end,\n }\n }\n\n // If maximum days is set and the range exceeds it, limit the highlight\n // We only apply this when we're in the middle of a selection (no end date yet)\n if (props.maximumDays?.value && !props.end.value && Math.abs(end.compare(start)) > props.maximumDays.value) {\n // Determine the direction of selection and limit to maximum days\n const cappedEnd = isStartBeforeFocused\n ? start.add({ days: props.maximumDays.value })\n : start.subtract({ days: props.maximumDays.value })\n\n return {\n start,\n end: cappedEnd,\n }\n }\n\n const isValid = areAllDaysBetweenValid(start, end, props.allowNonContiguousRanges.value ? () => false : props.isDateUnavailable, rangeIsDateDisabled, props.isDateHighlightable)\n if (isValid) {\n return {\n start,\n end,\n }\n }\n return null\n })\n\n const isHighlightedStart = (date: DateValue) => {\n if (!highlightedRange.value || !highlightedRange.value.start)\n return false\n return isSameDay(highlightedRange.value.start, date)\n }\n\n const isHighlightedEnd = (date: DateValue) => {\n if (!highlightedRange.value || !highlightedRange.value.end)\n return false\n return isSameDay(highlightedRange.value.end, date)\n }\n\n return {\n isInvalid,\n isSelected,\n isDateHighlightable,\n highlightedRange,\n isSelectionStart,\n isSelectionEnd,\n isHighlightedStart,\n isHighlightedEnd,\n isDateDisabled: rangeIsDateDisabled,\n }\n}\n"],"names":["computed","isBefore","date","isSameDay","isBetween","areAllDaysBetweenValid"],"mappings":";;;;;;AAuBO,SAAS,sBAAsB,KAA8B,EAAA;AAClE,EAAM,MAAA,cAAA,GAAiBA,aAAS,MAAM;AACpC,IAAI,IAAA,CAAC,MAAM,KAAM,CAAA,KAAA;AACf,MAAO,OAAA,KAAA;AACT,IAAA,IAAI,KAAM,CAAA,cAAA,CAAe,KAAM,CAAA,KAAA,CAAM,KAAK,CAAA;AACxC,MAAO,OAAA,IAAA;AACT,IAAO,OAAA,KAAA;AAAA,GACR,CAAA;AAED,EAAM,MAAA,YAAA,GAAeA,aAAS,MAAM;AAClC,IAAI,IAAA,CAAC,MAAM,GAAI,CAAA,KAAA;AACb,MAAO,OAAA,KAAA;AACT,IAAA,IAAI,KAAM,CAAA,cAAA,CAAe,KAAM,CAAA,GAAA,CAAI,KAAK,CAAA;AACtC,MAAO,OAAA,IAAA;AACT,IAAO,OAAA,KAAA;AAAA,GACR,CAAA;AAED,EAAA,MAAM,SAAY,GAAAA,YAAA;AAAA,IAChB,MAAM;AACJ,MAAI,IAAA,cAAA,CAAe,SAAS,YAAa,CAAA,KAAA;AACvC,QAAO,OAAA,KAAA;AACT,MAAA,IAAI,KAAM,CAAA,KAAA,CAAM,KAAS,IAAA,KAAA,CAAM,GAAI,CAAA,KAAA,IAASC,yBAAS,CAAA,KAAA,CAAM,GAAI,CAAA,KAAA,EAAO,KAAM,CAAA,KAAA,CAAM,KAAK,CAAA;AACrF,QAAO,OAAA,IAAA;AACT,MAAO,OAAA,KAAA;AAAA;AACT,GACF;AA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A;AAAA,IACA,gBAAA;AAAA,IACA,gBAAA;AAAA,IACA,cAAA;AAAA,IACA,kBAAA;AAAA,IACA,gBAAA;AAAA,IACA,cAAgB,EAAA;AAAA,GAClB;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"useRangeCalendar.cjs","sources":["../../src/RangeCalendar/useRangeCalendar.ts"],"sourcesContent":["/*\n * Adapted from https://github.com/melt-ui/melt-ui/blob/develop/src/lib/builders/range-calendar/create.ts\n*/\n\nimport type { DateValue } from '@internationalized/date'\nimport type { Ref } from 'vue'\nimport type { Matcher } from '@/date'\nimport { isSameDay } from '@internationalized/date'\nimport { computed } from 'vue'\nimport { areAllDaysBetweenValid, getDaysBetween, isBefore, isBetween } from '@/date'\n\nexport type UseRangeCalendarProps = {\n start: Ref<DateValue | undefined>\n end: Ref<DateValue | undefined>\n isDateDisabled: Matcher\n isDateUnavailable: Matcher\n isDateHighlightable?: Matcher\n focusedValue: Ref<DateValue | undefined>\n allowNonContiguousRanges: Ref<boolean>\n fixedDate: Ref<'start' | 'end' | undefined>\n maximumDays?: Ref<number | undefined>\n}\n\nexport function useRangeCalendarState(props: UseRangeCalendarProps) {\n const isStartInvalid = computed(() => {\n if (!props.start.value)\n return false\n if (props.isDateDisabled(props.start.value))\n return true\n return false\n })\n\n const isEndInvalid = computed(() => {\n if (!props.end.value)\n return false\n if (props.isDateDisabled(props.end.value))\n return true\n return false\n })\n\n const isInvalid = computed(\n () => {\n if (isStartInvalid.value || isEndInvalid.value)\n return false\n if (props.start.value && props.end.value && isBefore(props.end.value, props.start.value))\n return true\n return false\n },\n )\n\n const isSelectionStart = (date: DateValue) => {\n if (!props.start.value)\n return false\n return isSameDay(props.start.value, date)\n }\n\n const isSelectionEnd = (date: DateValue) => {\n if (!props.end.value)\n return false\n return isSameDay(props.end.value, date)\n }\n\n const isSelected = (date: DateValue) => {\n if (props.start.value && isSameDay(props.start.value, date))\n return true\n if (props.end.value && isSameDay(props.end.value, date))\n return true\n if (props.end.value && props.start.value)\n return isBetween(date, props.start.value, props.end.value)\n\n return false\n }\n\n // Check if a date exceeds maximum days limit from the start date\n const rangeIsDateDisabled = (date: DateValue) => {\n if (props.isDateDisabled(date))\n return true\n\n // Check if exceeds maximum days limit\n if (props.maximumDays?.value) {\n if (props.start.value && props.end.value) {\n if (props.fixedDate.value) {\n const diff = getDaysBetween(props.start.value, props.end.value).length\n if (diff <= props.maximumDays.value) {\n const daysLeft = props.maximumDays.value - diff - 1\n const startLimit = props.start.value.subtract({ days: daysLeft })\n const endLimit = props.end.value.add({ days: daysLeft })\n return !isBetween(date, startLimit, endLimit)\n }\n }\n return false\n }\n if (props.start.value) {\n const maxDate = props.start.value.add({ days: props.maximumDays.value })\n const minDate = props.start.value.subtract({ days: props.maximumDays.value })\n return !isBetween(date, minDate, maxDate)\n }\n }\n\n if (!props.start.value || props.end.value || isSameDay(props.start.value, date))\n return false\n\n return false\n }\n\n const isDateHighlightable = (date: DateValue) => {\n if (props.isDateHighlightable?.(date))\n return true\n return false\n }\n\n const highlightedRange = computed(() => {\n if (props.start.value && props.end.value && !props.fixedDate.value)\n return null\n if (!props.start.value || !props.focusedValue.value)\n return null\n\n const isStartBeforeFocused = isBefore(props.start.value, props.focusedValue.value)\n const start = isStartBeforeFocused ? props.start.value : props.focusedValue.value\n const end = isStartBeforeFocused ? props.focusedValue.value : props.start.value\n\n if (isSameDay(start, end)) {\n return {\n start,\n end,\n }\n }\n\n // If maximum days is set and the range exceeds it, limit the highlight\n // We only apply this when we're in the middle of a selection (no end date yet)\n if (props.maximumDays?.value && !props.end.value) {\n // Determine the direction of selection and limit to maximum days\n const cappedEnd = isStartBeforeFocused\n ? start.add({ days: props.maximumDays.value })\n : start.subtract({ days: props.maximumDays.value })\n\n return {\n start,\n end: cappedEnd,\n }\n }\n\n const isValid = areAllDaysBetweenValid(start, end, props.allowNonContiguousRanges.value ? () => false : props.isDateUnavailable, rangeIsDateDisabled, props.isDateHighlightable)\n if (isValid) {\n return {\n start,\n end,\n }\n }\n return null\n })\n\n const isHighlightedStart = (date: DateValue) => {\n if (!highlightedRange.value || !highlightedRange.value.start)\n return false\n return isSameDay(highlightedRange.value.start, date)\n }\n\n const isHighlightedEnd = (date: DateValue) => {\n if (!highlightedRange.value || !highlightedRange.value.end)\n return false\n return isSameDay(highlightedRange.value.end, date)\n }\n\n return {\n isInvalid,\n isSelected,\n isDateHighlightable,\n highlightedRange,\n isSelectionStart,\n isSelectionEnd,\n isHighlightedStart,\n isHighlightedEnd,\n isDateDisabled: rangeIsDateDisabled,\n }\n}\n"],"names":["computed","isBefore","date","isSameDay","isBetween","getDaysBetween","areAllDaysBetweenValid"],"mappings":";;;;;;;AAuBO,SAAS,sBAAsB,KAA8B,EAAA;AAClE,EAAM,MAAA,cAAA,GAAiBA,aAAS,MAAM;AACpC,IAAI,IAAA,CAAC,MAAM,KAAM,CAAA,KAAA;AACf,MAAO,OAAA,KAAA;AACT,IAAA,IAAI,KAAM,CAAA,cAAA,CAAe,KAAM,CAAA,KAAA,CAAM,KAAK,CAAA;AACxC,MAAO,OAAA,IAAA;AACT,IAAO,OAAA,KAAA;AAAA,GACR,CAAA;AAED,EAAM,MAAA,YAAA,GAAeA,aAAS,MAAM;AAClC,IAAI,IAAA,CAAC,MAAM,GAAI,CAAA,KAAA;AACb,MAAO,OAAA,KAAA;AACT,IAAA,IAAI,KAAM,CAAA,cAAA,CAAe,KAAM,CAAA,GAAA,CAAI,KAAK,CAAA;AACtC,MAAO,OAAA,IAAA;AACT,IAAO,OAAA,KAAA;AAAA,GACR,CAAA;AAED,EAAA,MAAM,SAAY,GAAAA,YAAA;AAAA,IAChB,MAAM;AACJ,MAAI,IAAA,cAAA,CAAe,SAAS,YAAa,CAAA,KAAA;AACvC,QAAO,OAAA,KAAA;AACT,MAAA,IAAI,KAAM,CAAA,KAAA,CAAM,KAAS,IAAA,KAAA,CAAM,GAAI,CAAA,KAAA,IAASC,yBAAS,CAAA,KAAA,CAAM,GAAI,CAAA,KAAA,EAAO,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DaysBetween } from '../date/calendar.js';
|
|
3
4
|
import { b as isBefore, m as areAllDaysBetweenValid, j as isBetween } from '../date/comparators.js';
|
|
4
5
|
|
|
5
6
|
function useRangeCalendarState(props) {
|
|
@@ -48,10 +49,27 @@ function useRangeCalendarState(props) {
|
|
|
48
49
|
const rangeIsDateDisabled = (date) => {
|
|
49
50
|
if (props.isDateDisabled(date))
|
|
50
51
|
return true;
|
|
51
|
-
if (
|
|
52
|
+
if (props.maximumDays?.value) {
|
|
53
|
+
if (props.start.value && props.end.value) {
|
|
54
|
+
if (props.fixedDate.value) {
|
|
55
|
+
const diff = getDaysBetween(props.start.value, props.end.value).length;
|
|
56
|
+
if (diff <= props.maximumDays.value) {
|
|
57
|
+
const daysLeft = props.maximumDays.value - diff - 1;
|
|
58
|
+
const startLimit = props.start.value.subtract({ days: daysLeft });
|
|
59
|
+
const endLimit = props.end.value.add({ days: daysLeft });
|
|
60
|
+
return !isBetween(date, startLimit, endLimit);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
if (props.start.value) {
|
|
66
|
+
const maxDate = props.start.value.add({ days: props.maximumDays.value });
|
|
67
|
+
const minDate = props.start.value.subtract({ days: props.maximumDays.value });
|
|
68
|
+
return !isBetween(date, minDate, maxDate);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
if (!props.start.value || props.end.value || isSameDay(props.start.value, date))
|
|
52
72
|
return false;
|
|
53
|
-
if (Math.abs(date.compare(props.start.value)) > props.maximumDays.value)
|
|
54
|
-
return true;
|
|
55
73
|
return false;
|
|
56
74
|
};
|
|
57
75
|
const isDateHighlightable = (date) => {
|
|
@@ -73,7 +91,7 @@ function useRangeCalendarState(props) {
|
|
|
73
91
|
end
|
|
74
92
|
};
|
|
75
93
|
}
|
|
76
|
-
if (props.maximumDays?.value && !props.end.value
|
|
94
|
+
if (props.maximumDays?.value && !props.end.value) {
|
|
77
95
|
const cappedEnd = isStartBeforeFocused ? start.add({ days: props.maximumDays.value }) : start.subtract({ days: props.maximumDays.value });
|
|
78
96
|
return {
|
|
79
97
|
start,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRangeCalendar.js","sources":["../../src/RangeCalendar/useRangeCalendar.ts"],"sourcesContent":["/*\n * Adapted from https://github.com/melt-ui/melt-ui/blob/develop/src/lib/builders/range-calendar/create.ts\n*/\n\nimport type { DateValue } from '@internationalized/date'\nimport type { Ref } from 'vue'\nimport type { Matcher } from '@/date'\nimport { isSameDay } from '@internationalized/date'\nimport { computed } from 'vue'\nimport { areAllDaysBetweenValid, isBefore, isBetween } from '@/date'\n\nexport type UseRangeCalendarProps = {\n start: Ref<DateValue | undefined>\n end: Ref<DateValue | undefined>\n isDateDisabled: Matcher\n isDateUnavailable: Matcher\n isDateHighlightable?: Matcher\n focusedValue: Ref<DateValue | undefined>\n allowNonContiguousRanges: Ref<boolean>\n fixedDate: Ref<'start' | 'end' | undefined>\n maximumDays?: Ref<number | undefined>\n}\n\nexport function useRangeCalendarState(props: UseRangeCalendarProps) {\n const isStartInvalid = computed(() => {\n if (!props.start.value)\n return false\n if (props.isDateDisabled(props.start.value))\n return true\n return false\n })\n\n const isEndInvalid = computed(() => {\n if (!props.end.value)\n return false\n if (props.isDateDisabled(props.end.value))\n return true\n return false\n })\n\n const isInvalid = computed(\n () => {\n if (isStartInvalid.value || isEndInvalid.value)\n return false\n if (props.start.value && props.end.value && isBefore(props.end.value, props.start.value))\n return true\n return false\n },\n )\n\n const isSelectionStart = (date: DateValue) => {\n if (!props.start.value)\n return false\n return isSameDay(props.start.value, date)\n }\n\n const isSelectionEnd = (date: DateValue) => {\n if (!props.end.value)\n return false\n return isSameDay(props.end.value, date)\n }\n\n const isSelected = (date: DateValue) => {\n if (props.start.value && isSameDay(props.start.value, date))\n return true\n if (props.end.value && isSameDay(props.end.value, date))\n return true\n if (props.end.value && props.start.value)\n return isBetween(date, props.start.value, props.end.value)\n\n return false\n }\n\n // Check if a date exceeds maximum days limit from the start date\n const rangeIsDateDisabled = (date: DateValue) => {\n if (props.isDateDisabled(date))\n return true\n\n if (!props.maximumDays?.value || !props.start.value || props.end.value || isSameDay(props.start.value, date))\n return false\n\n // Check if exceeds maximum days limit\n if (Math.abs(date.compare(props.start.value)) > props.maximumDays.value)\n return true\n\n return false\n }\n\n const isDateHighlightable = (date: DateValue) => {\n if (props.isDateHighlightable?.(date))\n return true\n return false\n }\n\n const highlightedRange = computed(() => {\n if (props.start.value && props.end.value && !props.fixedDate.value)\n return null\n if (!props.start.value || !props.focusedValue.value)\n return null\n\n const isStartBeforeFocused = isBefore(props.start.value, props.focusedValue.value)\n const start = isStartBeforeFocused ? props.start.value : props.focusedValue.value\n const end = isStartBeforeFocused ? props.focusedValue.value : props.start.value\n\n if (isSameDay(start, end)) {\n return {\n start,\n end,\n }\n }\n\n // If maximum days is set and the range exceeds it, limit the highlight\n // We only apply this when we're in the middle of a selection (no end date yet)\n if (props.maximumDays?.value && !props.end.value && Math.abs(end.compare(start)) > props.maximumDays.value) {\n // Determine the direction of selection and limit to maximum days\n const cappedEnd = isStartBeforeFocused\n ? start.add({ days: props.maximumDays.value })\n : start.subtract({ days: props.maximumDays.value })\n\n return {\n start,\n end: cappedEnd,\n }\n }\n\n const isValid = areAllDaysBetweenValid(start, end, props.allowNonContiguousRanges.value ? () => false : props.isDateUnavailable, rangeIsDateDisabled, props.isDateHighlightable)\n if (isValid) {\n return {\n start,\n end,\n }\n }\n return null\n })\n\n const isHighlightedStart = (date: DateValue) => {\n if (!highlightedRange.value || !highlightedRange.value.start)\n return false\n return isSameDay(highlightedRange.value.start, date)\n }\n\n const isHighlightedEnd = (date: DateValue) => {\n if (!highlightedRange.value || !highlightedRange.value.end)\n return false\n return isSameDay(highlightedRange.value.end, date)\n }\n\n return {\n isInvalid,\n isSelected,\n isDateHighlightable,\n highlightedRange,\n isSelectionStart,\n isSelectionEnd,\n isHighlightedStart,\n isHighlightedEnd,\n isDateDisabled: rang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,QACA,GAAK,EAAA;AAAA,OACP;AAAA;AAGF,IAAA,MAAM,OAAU,GAAA,sBAAA,CAAuB,KAAO,EAAA,GAAA,EAAK,KAAM,CAAA,wBAAA,CAAyB,KAAQ,GAAA,MAAM,KAAQ,GAAA,KAAA,CAAM,iBAAmB,EAAA,mBAAA,EAAqB,MAAM,mBAAmB,CAAA;AAC/K,IAAA,IAAI,OAAS,EAAA;AACX,MAAO,OAAA;AAAA,QACL,KAAA;AAAA,QACA;AAAA,OACF;AAAA;AAEF,IAAO,OAAA,IAAA;AAAA,GACR,CAAA;AAED,EAAM,MAAA,kBAAA,GAAqB,CAAC,IAAoB,KAAA;AAC9C,IAAA,IAAI,CAAC,gBAAA,CAAiB,KAAS,IAAA,CAAC,iBAAiB,KAAM,CAAA,KAAA;AACrD,MAAO,OAAA,KAAA;AACT,IAAA,OAAO,SAAU,CAAA,gBAAA,CAAiB,KAAM,CAAA,KAAA,EAAO,IAAI,CAAA;AAAA,GACrD;AAEA,EAAM,MAAA,gBAAA,GAAmB,CAAC,IAAoB,KAAA;AAC5C,IAAA,IAAI,CAAC,gBAAA,CAAiB,KAAS,IAAA,CAAC,iBAAiB,KAAM,CAAA,GAAA;AACrD,MAAO,OAAA,KAAA;AACT,IAAA,OAAO,SAAU,CAAA,gBAAA,CAAiB,KAAM,CAAA,GAAA,EAAK,IAAI,CAAA;AAAA,GACnD;AAEA,EAAO,OAAA;AAAA,IACL,SAAA;AAAA,IACA,UAAA;AAAA,IACA,mBAAA;AAAA,IACA,gBAAA;AAAA,IACA,gBAAA;AAAA,IACA,cAAA;AAAA,IACA,kBAAA;AAAA,IACA,gBAAA;AAAA,IACA,cAAgB,EAAA;AAAA,GAClB;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"useRangeCalendar.js","sources":["../../src/RangeCalendar/useRangeCalendar.ts"],"sourcesContent":["/*\n * Adapted from https://github.com/melt-ui/melt-ui/blob/develop/src/lib/builders/range-calendar/create.ts\n*/\n\nimport type { DateValue } from '@internationalized/date'\nimport type { Ref } from 'vue'\nimport type { Matcher } from '@/date'\nimport { isSameDay } from '@internationalized/date'\nimport { computed } from 'vue'\nimport { areAllDaysBetweenValid, getDaysBetween, isBefore, isBetween } from '@/date'\n\nexport type UseRangeCalendarProps = {\n start: Ref<DateValue | undefined>\n end: Ref<DateValue | undefined>\n isDateDisabled: Matcher\n isDateUnavailable: Matcher\n isDateHighlightable?: Matcher\n focusedValue: Ref<DateValue | undefined>\n allowNonContiguousRanges: Ref<boolean>\n fixedDate: Ref<'start' | 'end' | undefined>\n maximumDays?: Ref<number | undefined>\n}\n\nexport function useRangeCalendarState(props: UseRangeCalendarProps) {\n const isStartInvalid = computed(() => {\n if (!props.start.value)\n return false\n if (props.isDateDisabled(props.start.value))\n return true\n return false\n })\n\n const isEndInvalid = computed(() => {\n if (!props.end.value)\n return false\n if (props.isDateDisabled(props.end.value))\n return true\n return false\n })\n\n const isInvalid = computed(\n () => {\n if (isStartInvalid.value || isEndInvalid.value)\n return false\n if (props.start.value && props.end.value && isBefore(props.end.value, props.start.value))\n return true\n return false\n },\n )\n\n const isSelectionStart = (date: DateValue) => {\n if (!props.start.value)\n return false\n return isSameDay(props.start.value, date)\n }\n\n const isSelectionEnd = (date: DateValue) => {\n if (!props.end.value)\n return false\n return isSameDay(props.end.value, date)\n }\n\n const isSelected = (date: DateValue) => {\n if (props.start.value && isSameDay(props.start.value, date))\n return true\n if (props.end.value && isSameDay(props.end.value, date))\n return true\n if (props.end.value && props.start.value)\n return isBetween(date, props.start.value, props.end.value)\n\n return false\n }\n\n // Check if a date exceeds maximum days limit from the start date\n const rangeIsDateDisabled = (date: DateValue) => {\n if (props.isDateDisabled(date))\n return true\n\n // Check if exceeds maximum days limit\n if (props.maximumDays?.value) {\n if (props.start.value && props.end.value) {\n if (props.fixedDate.value) {\n const diff = getDaysBetween(props.start.value, props.end.value).length\n if (diff <= props.maximumDays.value) {\n const daysLeft = props.maximumDays.value - diff - 1\n const startLimit = props.start.value.subtract({ days: daysLeft })\n const endLimit = props.end.value.add({ days: daysLeft })\n return !isBetween(date, startLimit, endLimit)\n }\n }\n return false\n }\n if (props.start.value) {\n const maxDate = props.start.value.add({ days: props.maximumDays.value })\n const minDate = props.start.value.subtract({ days: props.maximumDays.value })\n return !isBetween(date, minDate, maxDate)\n }\n }\n\n if (!props.start.value || props.end.value || isSameDay(props.start.value, date))\n return false\n\n return false\n }\n\n const isDateHighlightable = (date: DateValue) => {\n if (props.isDateHighlightable?.(date))\n return true\n return false\n }\n\n const highlightedRange = computed(() => {\n if (props.start.value && props.end.value && !props.fixedDate.value)\n return null\n if (!props.start.value || !props.focusedValue.value)\n return null\n\n const isStartBeforeFocused = isBefore(props.start.value, props.focusedValue.value)\n const start = isStartBeforeFocused ? props.start.value : props.focusedValue.value\n const end = isStartBeforeFocused ? props.focusedValue.value : props.start.value\n\n if (isSameDay(start, end)) {\n return {\n start,\n end,\n }\n }\n\n // If maximum days is set and the range exceeds it, limit the highlight\n // We only apply this when we're in the middle of a selection (no end date yet)\n if (props.maximumDays?.value && !props.end.value) {\n // Determine the direction of selection and limit to maximum days\n const cappedEnd = isStartBeforeFocused\n ? start.add({ days: props.maximumDays.value })\n : start.subtract({ days: props.maximumDays.value })\n\n return {\n start,\n end: cappedEnd,\n }\n }\n\n const isValid = areAllDaysBetweenValid(start, end, props.allowNonContiguousRanges.value ? () => false : props.isDateUnavailable, rangeIsDateDisabled, props.isDateHighlightable)\n if (isValid) {\n return {\n start,\n end,\n }\n }\n return null\n })\n\n const isHighlightedStart = (date: DateValue) => {\n if (!highlightedRange.value || !highlightedRange.value.start)\n return false\n return isSameDay(highlightedRange.value.start, date)\n }\n\n const isHighlightedEnd = (date: DateValue) => {\n if (!highlightedRange.value || !highlightedRange.value.end)\n return false\n return isSameDay(highlightedRange.value.end, date)\n }\n\n return {\n isInvalid,\n isSelected,\n isDateHighlightable,\n highlightedRange,\n isSelectionStart,\n isSelectionEnd,\n isHighlightedStart,\n isHighlightedEnd,\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A;AAAA,GACR,CAAA;AAED,EAAM,MAAA,kBAAA,GAAqB,CAAC,IAAoB,KAAA;AAC9C,IAAA,IAAI,CAAC,gBAAA,CAAiB,KAAS,IAAA,CAAC,iBAAiB,KAAM,CAAA,KAAA;AACrD,MAAO,OAAA,KAAA;AACT,IAAA,OAAO,SAAU,CAAA,gBAAA,CAAiB,KAAM,CAAA,KAAA,EAAO,IAAI,CAAA;AAAA,GACrD;AAEA,EAAM,MAAA,gBAAA,GAAmB,CAAC,IAAoB,KAAA;AAC5C,IAAA,IAAI,CAAC,gBAAA,CAAiB,KAAS,IAAA,CAAC,iBAAiB,KAAM,CAAA,GAAA;AACrD,MAAO,OAAA,KAAA;AACT,IAAA,OAAO,SAAU,CAAA,gBAAA,CAAiB,KAAM,CAAA,GAAA,EAAK,IAAI,CAAA;AAAA,GACnD;AAEA,EAAO,OAAA;AAAA,IACL,SAAA;AAAA,IACA,UAAA;AAAA,IACA,mBAAA;AAAA,IACA,gBAAA;AAAA,IACA,gBAAA;AAAA,IACA,cAAA;AAAA,IACA,kBAAA;AAAA,IACA,gBAAA;AAAA,IACA,cAAgB,EAAA;AAAA,GAClB;AACF;;;;"}
|
|
@@ -46,13 +46,17 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
46
46
|
fragment.value = new DocumentFragment();
|
|
47
47
|
});
|
|
48
48
|
const presenceRef = vue.ref();
|
|
49
|
-
const
|
|
49
|
+
const present = vue.computed(() => props.forceMount || rootContext.open.value);
|
|
50
|
+
const renderPresence = vue.ref(present.value);
|
|
51
|
+
vue.watch(present, () => {
|
|
52
|
+
setTimeout(() => renderPresence.value = present.value);
|
|
53
|
+
});
|
|
50
54
|
return (_ctx, _cache) => {
|
|
51
|
-
return renderPresence.value ? (vue.openBlock(), vue.createBlock(vue.unref(Presence_Presence.Presence), {
|
|
55
|
+
return present.value || renderPresence.value || presenceRef.value?.present ? (vue.openBlock(), vue.createBlock(vue.unref(Presence_Presence.Presence), {
|
|
52
56
|
key: 0,
|
|
53
57
|
ref_key: "presenceRef",
|
|
54
58
|
ref: presenceRef,
|
|
55
|
-
present:
|
|
59
|
+
present: present.value
|
|
56
60
|
}, {
|
|
57
61
|
default: vue.withCtx(() => [
|
|
58
62
|
vue.createVNode(Select_SelectContentImpl._sfc_main, vue.normalizeProps(vue.guardReactiveProps({ ...vue.unref(forwarded), ..._ctx.$attrs })), {
|
|
@@ -63,7 +67,7 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
63
67
|
}, 16)
|
|
64
68
|
]),
|
|
65
69
|
_: 3
|
|
66
|
-
},
|
|
70
|
+
}, 8, ["present"])) : fragment.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [
|
|
67
71
|
(vue.openBlock(), vue.createBlock(vue.Teleport, { to: fragment.value }, [
|
|
68
72
|
vue.createVNode(Select_SelectProvider._sfc_main, { context: vue.unref(rootContext) }, {
|
|
69
73
|
default: vue.withCtx(() => [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectContent.cjs","sources":["../../src/Select/SelectContent.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type {\n SelectContentImplEmits,\n SelectContentImplProps,\n} from './SelectContentImpl.vue'\n\nexport type SelectContentEmits = SelectContentImplEmits\n\nexport interface SelectContentProps extends SelectContentImplProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with Vue animation libraries.\n */\n forceMount?: boolean\n}\n</script>\n\n<script setup lang=\"ts\">\nimport {
|
|
1
|
+
{"version":3,"file":"SelectContent.cjs","sources":["../../src/Select/SelectContent.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type {\n SelectContentImplEmits,\n SelectContentImplProps,\n} from './SelectContentImpl.vue'\nimport { computed, onMounted, ref, watch } from 'vue'\n\nexport type SelectContentEmits = SelectContentImplEmits\n\nexport interface SelectContentProps extends SelectContentImplProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with Vue animation libraries.\n */\n forceMount?: boolean\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { Presence } from '@/Presence'\nimport { useForwardPropsEmits } from '@/shared'\nimport SelectContentImpl from './SelectContentImpl.vue'\nimport SelectProvider from './SelectProvider.vue'\nimport { injectSelectRootContext } from './SelectRoot.vue'\n\ndefineOptions({\n inheritAttrs: false,\n})\n\nconst props = defineProps<SelectContentProps>()\n\nconst emits = defineEmits<SelectContentEmits>()\nconst forwarded = useForwardPropsEmits(props, emits)\n\nconst rootContext = injectSelectRootContext()\n\nconst fragment = ref<DocumentFragment>()\nonMounted(() => {\n fragment.value = new DocumentFragment()\n})\n\nconst presenceRef = ref<InstanceType<typeof Presence>>()\n\nconst present = computed(() => props.forceMount || rootContext.open.value)\nconst renderPresence = ref(present.value)\n\nwatch(present, () => {\n // Toggle render presence after a delay (nextTick is not enough)\n // to allow children to re-render with the latest state.\n // Otherwise, they would remain in the old state during the transition,\n // which would prevent the animation that depend on state (e.g., data-[state=closed])\n // from being applied accurately.\n // @see https://github.com/unovue/reka-ui/issues/1865\n setTimeout(() => renderPresence.value = present.value)\n})\n</script>\n\n<template>\n <Presence\n v-if=\"present || renderPresence || presenceRef?.present\"\n ref=\"presenceRef\"\n :present=\"present\"\n >\n <SelectContentImpl v-bind=\"{ ...forwarded, ...$attrs }\">\n <slot />\n </SelectContentImpl>\n </Presence>\n\n <div v-else-if=\"fragment\">\n <Teleport :to=\"fragment\">\n <SelectProvider :context=\"rootContext\">\n <slot />\n </SelectProvider>\n </Teleport>\n </div>\n</template>\n"],"names":["useForwardPropsEmits","injectSelectRootContext","ref","onMounted","computed","watch"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAA,MAAM,KAAQ,GAAA,OAAA;AAEd,IAAA,MAAM,KAAQ,GAAA,MAAA;AACd,IAAM,MAAA,SAAA,GAAYA,gDAAqB,CAAA,KAAA,EAAO,KAAK,CAAA;AAEnD,IAAA,MAAM,cAAcC,yCAAwB,EAAA;AAE5C,IAAA,MAAM,WAAWC,OAAsB,EAAA;AACvC,IAAAC,aAAA,CAAU,MAAM;AACd,MAAS,QAAA,CAAA,KAAA,GAAQ,IAAI,gBAAiB,EAAA;AAAA,KACvC,CAAA;AAED,IAAA,MAAM,cAAcD,OAAmC,EAAA;AAEvD,IAAA,MAAM,UAAUE,YAAS,CAAA,MAAM,MAAM,UAAc,IAAA,WAAA,CAAY,KAAK,KAAK,CAAA;AACzE,IAAM,MAAA,cAAA,GAAiBF,OAAI,CAAA,OAAA,CAAQ,KAAK,CAAA;AAExC,IAAAG,SAAA,CAAM,SAAS,MAAM;AAOnB,MAAA,UAAA,CAAW,MAAM,cAAA,CAAe,KAAQ,GAAA,OAAA,CAAQ,KAAK,CAAA;AAAA,KACtD,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, ref, onMounted, computed, createBlock, createElementBlock, createCommentVNode, openBlock, unref, withCtx, createVNode, normalizeProps, guardReactiveProps, renderSlot, Teleport } from 'vue';
|
|
1
|
+
import { defineComponent, ref, onMounted, computed, watch, createBlock, createElementBlock, createCommentVNode, openBlock, unref, withCtx, createVNode, normalizeProps, guardReactiveProps, renderSlot, Teleport } from 'vue';
|
|
2
2
|
import { _ as _sfc_main$1 } from './SelectContentImpl.js';
|
|
3
3
|
import { _ as _sfc_main$2 } from './SelectProvider.js';
|
|
4
4
|
import { u as useForwardPropsEmits } from '../shared/useForwardPropsEmits.js';
|
|
@@ -44,13 +44,17 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
44
44
|
fragment.value = new DocumentFragment();
|
|
45
45
|
});
|
|
46
46
|
const presenceRef = ref();
|
|
47
|
-
const
|
|
47
|
+
const present = computed(() => props.forceMount || rootContext.open.value);
|
|
48
|
+
const renderPresence = ref(present.value);
|
|
49
|
+
watch(present, () => {
|
|
50
|
+
setTimeout(() => renderPresence.value = present.value);
|
|
51
|
+
});
|
|
48
52
|
return (_ctx, _cache) => {
|
|
49
|
-
return renderPresence.value ? (openBlock(), createBlock(unref(Presence), {
|
|
53
|
+
return present.value || renderPresence.value || presenceRef.value?.present ? (openBlock(), createBlock(unref(Presence), {
|
|
50
54
|
key: 0,
|
|
51
55
|
ref_key: "presenceRef",
|
|
52
56
|
ref: presenceRef,
|
|
53
|
-
present:
|
|
57
|
+
present: present.value
|
|
54
58
|
}, {
|
|
55
59
|
default: withCtx(() => [
|
|
56
60
|
createVNode(_sfc_main$1, normalizeProps(guardReactiveProps({ ...unref(forwarded), ..._ctx.$attrs })), {
|
|
@@ -61,7 +65,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
61
65
|
}, 16)
|
|
62
66
|
]),
|
|
63
67
|
_: 3
|
|
64
|
-
},
|
|
68
|
+
}, 8, ["present"])) : fragment.value ? (openBlock(), createElementBlock("div", _hoisted_1, [
|
|
65
69
|
(openBlock(), createBlock(Teleport, { to: fragment.value }, [
|
|
66
70
|
createVNode(_sfc_main$2, { context: unref(rootContext) }, {
|
|
67
71
|
default: withCtx(() => [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectContent.js","sources":["../../src/Select/SelectContent.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type {\n SelectContentImplEmits,\n SelectContentImplProps,\n} from './SelectContentImpl.vue'\n\nexport type SelectContentEmits = SelectContentImplEmits\n\nexport interface SelectContentProps extends SelectContentImplProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with Vue animation libraries.\n */\n forceMount?: boolean\n}\n</script>\n\n<script setup lang=\"ts\">\nimport {
|
|
1
|
+
{"version":3,"file":"SelectContent.js","sources":["../../src/Select/SelectContent.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type {\n SelectContentImplEmits,\n SelectContentImplProps,\n} from './SelectContentImpl.vue'\nimport { computed, onMounted, ref, watch } from 'vue'\n\nexport type SelectContentEmits = SelectContentImplEmits\n\nexport interface SelectContentProps extends SelectContentImplProps {\n /**\n * Used to force mounting when more control is needed. Useful when\n * controlling animation with Vue animation libraries.\n */\n forceMount?: boolean\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { Presence } from '@/Presence'\nimport { useForwardPropsEmits } from '@/shared'\nimport SelectContentImpl from './SelectContentImpl.vue'\nimport SelectProvider from './SelectProvider.vue'\nimport { injectSelectRootContext } from './SelectRoot.vue'\n\ndefineOptions({\n inheritAttrs: false,\n})\n\nconst props = defineProps<SelectContentProps>()\n\nconst emits = defineEmits<SelectContentEmits>()\nconst forwarded = useForwardPropsEmits(props, emits)\n\nconst rootContext = injectSelectRootContext()\n\nconst fragment = ref<DocumentFragment>()\nonMounted(() => {\n fragment.value = new DocumentFragment()\n})\n\nconst presenceRef = ref<InstanceType<typeof Presence>>()\n\nconst present = computed(() => props.forceMount || rootContext.open.value)\nconst renderPresence = ref(present.value)\n\nwatch(present, () => {\n // Toggle render presence after a delay (nextTick is not enough)\n // to allow children to re-render with the latest state.\n // Otherwise, they would remain in the old state during the transition,\n // which would prevent the animation that depend on state (e.g., data-[state=closed])\n // from being applied accurately.\n // @see https://github.com/unovue/reka-ui/issues/1865\n setTimeout(() => renderPresence.value = present.value)\n})\n</script>\n\n<template>\n <Presence\n v-if=\"present || renderPresence || presenceRef?.present\"\n ref=\"presenceRef\"\n :present=\"present\"\n >\n <SelectContentImpl v-bind=\"{ ...forwarded, ...$attrs }\">\n <slot />\n </SelectContentImpl>\n </Presence>\n\n <div v-else-if=\"fragment\">\n <Teleport :to=\"fragment\">\n <SelectProvider :context=\"rootContext\">\n <slot />\n </SelectProvider>\n </Teleport>\n </div>\n</template>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAA,MAAM,KAAQ,GAAA,OAAA;AAEd,IAAA,MAAM,KAAQ,GAAA,MAAA;AACd,IAAM,MAAA,SAAA,GAAY,oBAAqB,CAAA,KAAA,EAAO,KAAK,CAAA;AAEnD,IAAA,MAAM,cAAc,uBAAwB,EAAA;AAE5C,IAAA,MAAM,WAAW,GAAsB,EAAA;AACvC,IAAA,SAAA,CAAU,MAAM;AACd,MAAS,QAAA,CAAA,KAAA,GAAQ,IAAI,gBAAiB,EAAA;AAAA,KACvC,CAAA;AAED,IAAA,MAAM,cAAc,GAAmC,EAAA;AAEvD,IAAA,MAAM,UAAU,QAAS,CAAA,MAAM,MAAM,UAAc,IAAA,WAAA,CAAY,KAAK,KAAK,CAAA;AACzE,IAAM,MAAA,cAAA,GAAiB,GAAI,CAAA,OAAA,CAAQ,KAAK,CAAA;AAExC,IAAA,KAAA,CAAM,SAAS,MAAM;AAOnB,MAAA,UAAA,CAAW,MAAM,cAAA,CAAe,KAAQ,GAAA,OAAA,CAAQ,KAAK,CAAA;AAAA,KACtD,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const vue = require('vue');
|
|
4
4
|
const core = require('@vueuse/core');
|
|
5
|
-
const DismissableLayer_DismissableLayer = require('../DismissableLayer/DismissableLayer.cjs');
|
|
6
5
|
const Menu_utils = require('../Menu/utils.cjs');
|
|
7
6
|
const Select_SelectItemAlignedPosition = require('./SelectItemAlignedPosition.cjs');
|
|
8
7
|
const Select_SelectPopperPosition = require('./SelectPopperPosition.cjs');
|
|
@@ -15,6 +14,7 @@ const shared_useHideOthers = require('../shared/useHideOthers.cjs');
|
|
|
15
14
|
const shared_useTypeahead = require('../shared/useTypeahead.cjs');
|
|
16
15
|
const shared_useForwardProps = require('../shared/useForwardProps.cjs');
|
|
17
16
|
const FocusScope_FocusScope = require('../FocusScope/FocusScope.cjs');
|
|
17
|
+
const DismissableLayer_DismissableLayer = require('../DismissableLayer/DismissableLayer.cjs');
|
|
18
18
|
const Select_SelectRoot = require('./SelectRoot.cjs');
|
|
19
19
|
|
|
20
20
|
const SelectContentDefaultContextValue = {
|