@yamada-ui/react 2.1.3-dev-20260315020004 → 2.1.3-dev-20260315080238
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/cjs/components/airy/airy.cjs.map +1 -1
- package/dist/cjs/components/autocomplete/use-autocomplete.cjs +1 -1
- package/dist/cjs/components/autocomplete/use-autocomplete.cjs.map +1 -1
- package/dist/cjs/components/chart/chart.cjs +1 -1
- package/dist/cjs/components/chart/chart.cjs.map +1 -1
- package/dist/cjs/components/date-picker/use-date-picker.cjs +1 -1
- package/dist/cjs/components/date-picker/use-date-picker.cjs.map +1 -1
- package/dist/cjs/components/dropzone/dropzone.cjs.map +1 -1
- package/dist/cjs/components/flip/flip.cjs.map +1 -1
- package/dist/cjs/components/native-popover/use-native-popover.cjs +1 -1
- package/dist/cjs/components/native-popover/use-native-popover.cjs.map +1 -1
- package/dist/cjs/components/popover/use-popover.cjs +1 -1
- package/dist/cjs/components/popover/use-popover.cjs.map +1 -1
- package/dist/cjs/components/rotate/rotate.cjs.map +1 -1
- package/dist/cjs/components/snacks/snacks.cjs +1 -1
- package/dist/cjs/components/snacks/snacks.cjs.map +1 -1
- package/dist/cjs/components/snacks/use-snacks.cjs.map +1 -1
- package/dist/cjs/components/stack/stack.cjs +1 -1
- package/dist/cjs/components/stack/stack.cjs.map +1 -1
- package/dist/cjs/core/components/use-component-style.cjs +1 -1
- package/dist/cjs/core/components/use-component-style.cjs.map +1 -1
- package/dist/cjs/core/system/color-mode-provider.cjs +1 -1
- package/dist/cjs/core/system/color-mode-provider.cjs.map +1 -1
- package/dist/cjs/core/system/styled.cjs +1 -1
- package/dist/cjs/core/system/styled.cjs.map +1 -1
- package/dist/cjs/core/system/theme-provider.cjs +1 -1
- package/dist/cjs/core/system/theme-provider.cjs.map +1 -1
- package/dist/cjs/core/system/var.cjs +2 -2
- package/dist/cjs/core/system/var.cjs.map +1 -1
- package/dist/cjs/utils/effect.cjs +1 -1
- package/dist/cjs/utils/effect.cjs.map +1 -1
- package/dist/esm/components/airy/airy.js.map +1 -1
- package/dist/esm/components/autocomplete/use-autocomplete.js +1 -1
- package/dist/esm/components/autocomplete/use-autocomplete.js.map +1 -1
- package/dist/esm/components/chart/chart.js +1 -1
- package/dist/esm/components/chart/chart.js.map +1 -1
- package/dist/esm/components/date-picker/use-date-picker.js +1 -1
- package/dist/esm/components/date-picker/use-date-picker.js.map +1 -1
- package/dist/esm/components/dropzone/dropzone.js.map +1 -1
- package/dist/esm/components/flip/flip.js.map +1 -1
- package/dist/esm/components/native-popover/use-native-popover.js +1 -1
- package/dist/esm/components/native-popover/use-native-popover.js.map +1 -1
- package/dist/esm/components/popover/use-popover.js +1 -1
- package/dist/esm/components/popover/use-popover.js.map +1 -1
- package/dist/esm/components/rotate/rotate.js.map +1 -1
- package/dist/esm/components/snacks/snacks.js +1 -1
- package/dist/esm/components/snacks/snacks.js.map +1 -1
- package/dist/esm/components/snacks/use-snacks.js.map +1 -1
- package/dist/esm/components/stack/stack.js +1 -1
- package/dist/esm/components/stack/stack.js.map +1 -1
- package/dist/esm/core/components/use-component-style.js +1 -1
- package/dist/esm/core/components/use-component-style.js.map +1 -1
- package/dist/esm/core/system/color-mode-provider.js +1 -1
- package/dist/esm/core/system/color-mode-provider.js.map +1 -1
- package/dist/esm/core/system/styled.js +1 -1
- package/dist/esm/core/system/styled.js.map +1 -1
- package/dist/esm/core/system/theme-provider.js +1 -1
- package/dist/esm/core/system/theme-provider.js.map +1 -1
- package/dist/esm/core/system/var.js +2 -2
- package/dist/esm/core/system/var.js.map +1 -1
- package/dist/esm/utils/effect.js +1 -1
- package/dist/esm/utils/effect.js.map +1 -1
- package/dist/types/components/accordion/accordion.d.ts +2 -2
- package/dist/types/components/accordion/accordion.style.d.ts +1 -1
- package/dist/types/components/accordion/use-accordion.d.ts +11 -11
- package/dist/types/components/airy/airy.d.ts +3 -3
- package/dist/types/components/alert/alert.d.ts +2 -2
- package/dist/types/components/alpha-slider/alpha-slider.d.ts +2 -2
- package/dist/types/components/aspect-ratio/aspect-ratio.d.ts +2 -2
- package/dist/types/components/autocomplete/autocomplete.d.ts +2 -2
- package/dist/types/components/autocomplete/autocomplete.style.d.ts +1 -1
- package/dist/types/components/autocomplete/use-autocomplete.d.ts +5 -5
- package/dist/types/components/avatar/avatar.d.ts +5 -5
- package/dist/types/components/avatar/avatar.style.d.ts +1 -1
- package/dist/types/components/avatar/use-avatar-group.d.ts +2 -2
- package/dist/types/components/badge/badge.d.ts +2 -2
- package/dist/types/components/bleed/bleed.d.ts +2 -2
- package/dist/types/components/blockquote/blockquote.d.ts +2 -2
- package/dist/types/components/breadcrumb/breadcrumb.d.ts +2 -2
- package/dist/types/components/breadcrumb/breadcrumb.style.d.ts +1 -1
- package/dist/types/components/breadcrumb/use-breadcrumb.d.ts +2 -2
- package/dist/types/components/button/button.d.ts +2 -2
- package/dist/types/components/button/icon-button.d.ts +2 -2
- package/dist/types/components/calendar/calendar.d.ts +2 -2
- package/dist/types/components/calendar/calendar.style.d.ts +2 -2
- package/dist/types/components/calendar/use-calendar.d.ts +8 -8
- package/dist/types/components/card/card.d.ts +2 -2
- package/dist/types/components/carousel/carousel.d.ts +2 -2
- package/dist/types/components/carousel/carousel.style.d.ts +2 -2
- package/dist/types/components/carousel/use-carousel.d.ts +3 -3
- package/dist/types/components/center/center.d.ts +2 -2
- package/dist/types/components/chart/area-chart.d.ts +2 -2
- package/dist/types/components/chart/bar-chart.d.ts +2 -2
- package/dist/types/components/chart/chart.d.ts +5 -5
- package/dist/types/components/chart/composed-chart.d.ts +2 -2
- package/dist/types/components/chart/donut-chart.d.ts +2 -2
- package/dist/types/components/chart/pie-chart.d.ts +2 -2
- package/dist/types/components/chart/radar-chart.d.ts +2 -2
- package/dist/types/components/chart/use-chart.d.ts +2 -2
- package/dist/types/components/checkbox/checkbox.d.ts +5 -5
- package/dist/types/components/checkbox/checkbox.style.d.ts +1 -1
- package/dist/types/components/checkbox/use-checkbox-group.d.ts +2 -2
- package/dist/types/components/checkbox-card/checkbox-card.d.ts +5 -5
- package/dist/types/components/checkbox-card/checkbox-card.style.d.ts +1 -1
- package/dist/types/components/circle-progress/circle-progress.d.ts +2 -2
- package/dist/types/components/close-button/close-button.d.ts +2 -2
- package/dist/types/components/code/code.d.ts +2 -2
- package/dist/types/components/collapse/collapse.d.ts +2 -2
- package/dist/types/components/color-picker/color-picker.d.ts +2 -2
- package/dist/types/components/color-picker/color-picker.style.d.ts +1 -1
- package/dist/types/components/color-picker/use-color-picker.d.ts +2 -2
- package/dist/types/components/color-selector/color-selector.d.ts +2 -2
- package/dist/types/components/color-selector/color-selector.style.d.ts +2 -2
- package/dist/types/components/color-selector/use-color-selector.d.ts +3 -3
- package/dist/types/components/color-swatch/color-swatch.d.ts +2 -2
- package/dist/types/components/container/container.d.ts +2 -2
- package/dist/types/components/data-list/data-list.d.ts +2 -2
- package/dist/types/components/data-list/data-list.style.d.ts +1 -1
- package/dist/types/components/date-picker/date-picker.d.ts +2 -2
- package/dist/types/components/date-picker/date-picker.style.d.ts +1 -1
- package/dist/types/components/date-picker/use-date-picker.d.ts +4 -4
- package/dist/types/components/drawer/drawer.d.ts +2 -2
- package/dist/types/components/dropzone/dropzone.d.ts +4 -5
- package/dist/types/components/editable/editable.d.ts +4 -4
- package/dist/types/components/editable/use-editable.d.ts +2 -2
- package/dist/types/components/em/em.d.ts +2 -2
- package/dist/types/components/empty-state/empty-state.d.ts +2 -2
- package/dist/types/components/empty-state/empty-state.style.d.ts +2 -2
- package/dist/types/components/fade/fade.d.ts +2 -2
- package/dist/types/components/field/field.d.ts +3 -3
- package/dist/types/components/field/use-field-props.d.ts +4 -4
- package/dist/types/components/fieldset/fieldset.d.ts +3 -3
- package/dist/types/components/file-button/file-button.d.ts +2 -2
- package/dist/types/components/file-button/use-file-button.d.ts +17 -17
- package/dist/types/components/file-input/file-input.d.ts +2 -2
- package/dist/types/components/file-input/use-file-input.d.ts +17 -17
- package/dist/types/components/flex/flex.d.ts +2 -2
- package/dist/types/components/flip/flip.d.ts +5 -5
- package/dist/types/components/flip/flip.style.d.ts +1 -1
- package/dist/types/components/float/float.d.ts +2 -2
- package/dist/types/components/form/form.d.ts +3 -3
- package/dist/types/components/format/format-byte.d.ts +4 -4
- package/dist/types/components/format/format-date-time.d.ts +4 -4
- package/dist/types/components/format/format-number.d.ts +2 -2
- package/dist/types/components/grid/grid-item.d.ts +2 -2
- package/dist/types/components/grid/grid.d.ts +2 -2
- package/dist/types/components/group/group.d.ts +2 -2
- package/dist/types/components/group/use-group.d.ts +2 -2
- package/dist/types/components/heading/heading.d.ts +2 -2
- package/dist/types/components/hue-slider/hue-slider.d.ts +3 -3
- package/dist/types/components/icon/icon.d.ts +5 -5
- package/dist/types/components/image/image.d.ts +2 -2
- package/dist/types/components/indicator/indicator.d.ts +4 -4
- package/dist/types/components/infinite-scroll-area/infinite-scroll-area.d.ts +2 -2
- package/dist/types/components/input/input-addon.d.ts +2 -2
- package/dist/types/components/input/input-element.d.ts +2 -2
- package/dist/types/components/input/input.d.ts +2 -2
- package/dist/types/components/kbd/kbd.d.ts +2 -2
- package/dist/types/components/link/link.d.ts +2 -2
- package/dist/types/components/link-box/link-box.d.ts +2 -2
- package/dist/types/components/list/list.d.ts +2 -2
- package/dist/types/components/list/list.style.d.ts +2 -2
- package/dist/types/components/loading/loading-provider.d.ts +2 -2
- package/dist/types/components/loading/loading.d.ts +3 -3
- package/dist/types/components/mark/mark.d.ts +2 -2
- package/dist/types/components/menu/menu.d.ts +2 -2
- package/dist/types/components/menu/menu.style.d.ts +2 -2
- package/dist/types/components/menu/use-menu.d.ts +11 -11
- package/dist/types/components/modal/modal.d.ts +2 -2
- package/dist/types/components/native-accordion/native-accordion.d.ts +2 -2
- package/dist/types/components/native-accordion/native-accordion.style.d.ts +2 -2
- package/dist/types/components/native-accordion/use-native-accordion.d.ts +2 -2
- package/dist/types/components/native-popover/native-popover.d.ts +2 -2
- package/dist/types/components/native-select/native-select.d.ts +2 -2
- package/dist/types/components/native-table/native-table.d.ts +4 -4
- package/dist/types/components/notice/notice.style.d.ts +1 -1
- package/dist/types/components/number-input/number-input.d.ts +2 -2
- package/dist/types/components/number-input/number-input.style.d.ts +1 -1
- package/dist/types/components/pagination/pagination.d.ts +2 -2
- package/dist/types/components/pagination/pagination.style.d.ts +1 -1
- package/dist/types/components/pagination/use-pagination.d.ts +2 -2
- package/dist/types/components/password-input/password-input.d.ts +2 -2
- package/dist/types/components/password-input/strength-meter.d.ts +2 -2
- package/dist/types/components/password-input/strength-meter.style.d.ts +1 -1
- package/dist/types/components/password-input/use-password-input.d.ts +2 -2
- package/dist/types/components/pin-input/pin-input.d.ts +2 -2
- package/dist/types/components/pin-input/use-pin-input.d.ts +7 -7
- package/dist/types/components/popover/popover.d.ts +2 -2
- package/dist/types/components/progress/progress.d.ts +4 -4
- package/dist/types/components/progress/use-progress.d.ts +706 -706
- package/dist/types/components/qr-code/qr-code.d.ts +2 -2
- package/dist/types/components/radio/radio.d.ts +5 -5
- package/dist/types/components/radio/radio.style.d.ts +1 -1
- package/dist/types/components/radio/use-radio-group.d.ts +2 -2
- package/dist/types/components/radio-card/radio-card.d.ts +5 -5
- package/dist/types/components/radio-card/radio-card.style.d.ts +1 -1
- package/dist/types/components/rating/rating.style.d.ts +2 -2
- package/dist/types/components/rating/use-rating.d.ts +7 -7
- package/dist/types/components/reorder/reorder.d.ts +2 -2
- package/dist/types/components/reorder/reorder.style.d.ts +1 -1
- package/dist/types/components/reorder/use-reorder.d.ts +4 -4
- package/dist/types/components/resizable/resizable.d.ts +2 -2
- package/dist/types/components/resizable/resizable.style.d.ts +2 -2
- package/dist/types/components/resizable/use-resizable.d.ts +2 -2
- package/dist/types/components/ripple/ripple.d.ts +2 -2
- package/dist/types/components/ripple/use-ripple.d.ts +2 -2
- package/dist/types/components/rotate/rotate.d.ts +3 -3
- package/dist/types/components/saturation-slider/saturation-slider.d.ts +2 -2
- package/dist/types/components/saturation-slider/use-saturation-slider.d.ts +2 -2
- package/dist/types/components/scroll-area/scroll-area.d.ts +2 -2
- package/dist/types/components/segmented-control/segmented-control.d.ts +2 -2
- package/dist/types/components/segmented-control/segmented-control.style.d.ts +2 -2
- package/dist/types/components/segmented-control/use-segmented-control.d.ts +9 -9
- package/dist/types/components/select/select.d.ts +2 -2
- package/dist/types/components/select/select.style.d.ts +1 -1
- package/dist/types/components/select/use-select.d.ts +4 -4
- package/dist/types/components/separator/separator.d.ts +2 -2
- package/dist/types/components/simple-grid/simple-grid.d.ts +2 -2
- package/dist/types/components/skeleton/skeleton.d.ts +2 -2
- package/dist/types/components/slide/slide.d.ts +2 -2
- package/dist/types/components/slide-fade/slide-fade.d.ts +2 -2
- package/dist/types/components/slider/slider.d.ts +2 -2
- package/dist/types/components/slider/use-slider.d.ts +2 -2
- package/dist/types/components/stack/h-stack.d.ts +2 -2
- package/dist/types/components/stack/stack.d.ts +2 -2
- package/dist/types/components/stack/v-stack.d.ts +2 -2
- package/dist/types/components/stack/z-stack.d.ts +2 -2
- package/dist/types/components/stat/stat.d.ts +2 -2
- package/dist/types/components/stat/stat.style.d.ts +2 -2
- package/dist/types/components/status/status.d.ts +2 -2
- package/dist/types/components/status/status.style.d.ts +2 -2
- package/dist/types/components/steps/steps.d.ts +2 -2
- package/dist/types/components/steps/steps.style.d.ts +1 -1
- package/dist/types/components/steps/use-steps.d.ts +10 -10
- package/dist/types/components/switch/switch.d.ts +2 -2
- package/dist/types/components/table/table.d.ts +2 -2
- package/dist/types/components/tabs/tabs.d.ts +2 -2
- package/dist/types/components/tabs/tabs.style.d.ts +1 -1
- package/dist/types/components/tabs/use-tabs.d.ts +16 -16
- package/dist/types/components/tag/tag.d.ts +2 -2
- package/dist/types/components/text/text.d.ts +2 -2
- package/dist/types/components/textarea/textarea.d.ts +2 -2
- package/dist/types/components/textarea/use-autosize.d.ts +2 -2
- package/dist/types/components/timeline/timeline.d.ts +4 -4
- package/dist/types/components/timeline/timeline.style.d.ts +2 -2
- package/dist/types/components/toggle/toggle.d.ts +5 -5
- package/dist/types/components/toggle/use-toggle-group.d.ts +2 -2
- package/dist/types/components/toggle/use-toggle.d.ts +2 -2
- package/dist/types/components/tooltip/tooltip.d.ts +2 -2
- package/dist/types/components/visually-hidden/visually-hidden.d.ts +2 -2
- package/dist/types/components/wrap/wrap.d.ts +2 -2
- package/dist/types/core/components/create-component.d.ts +7 -7
- package/dist/types/core/system/color-mode-provider.d.ts +2 -2
- package/dist/types/core/system/storage-script.d.ts +3 -3
- package/dist/types/core/system/styled.d.ts +2 -2
- package/dist/types/core/system/system-provider.d.ts +2 -2
- package/dist/types/hooks/use-breakpoint/use-breakpoint-state.d.ts +2 -2
- package/dist/types/hooks/use-clickable/index.d.ts +9 -9
- package/dist/types/hooks/use-clipboard/index.d.ts +2 -2
- package/dist/types/hooks/use-combobox/index.d.ts +12 -12
- package/dist/types/hooks/use-counter/index.d.ts +2 -2
- package/dist/types/hooks/use-descendants/index.d.ts +2 -2
- package/dist/types/hooks/use-field-sizing/index.d.ts +2 -2
- package/dist/types/hooks/use-hover/index.d.ts +2 -2
- package/dist/types/hooks/use-popper/index.d.ts +2 -2
- package/dist/types/hooks/use-resize-observer/index.d.ts +3 -3
- package/dist/types/providers/i18n-provider/i18n-provider.d.ts +3 -3
- package/dist/types/providers/ui-provider/ui-provider.d.ts +2 -2
- package/dist/types/utils/children.d.ts +2 -2
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-date-picker.js","names":["defaultRender: DatePickerRender","inputFormat","calendarFormat","value","onClear","startPlaceholder","inputValue","minDate","maxDate","ev","getRootProps: PropGetter","props","getFieldProps: PropGetter","ref","getInputProps: PropGetter<\"input\", { align?: InputAlign }>","inputProps: HTMLProps<\"input\">","getContentProps: PropGetter","getCalendarProps: PropGetter<UseCalendarProps<Multiple, Range>>","getIconProps: PropGetter"],"sources":["../../../../src/components/date-picker/use-date-picker.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type { UseComboboxProps } from \"../../hooks/use-combobox\"\nimport type { Dict } from \"../../utils\"\nimport type {\n CalendarFormat,\n MaybeDateValue,\n UseCalendarProps,\n} from \"../calendar\"\nimport type { FieldProps } from \"../field\"\nimport dayjs from \"dayjs\"\nimport {\n cloneElement,\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { useCombobox } from \"../../hooks/use-combobox\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n ariaAttr,\n cast,\n contains,\n dataAttr,\n focusTransfer,\n handlerAll,\n isArray,\n isComposing,\n isDate,\n isNumber,\n isObject,\n mergeRefs,\n runIfFn,\n runKeyAction,\n useUpdateEffect,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport {\n DEFAULT_MAX_DATE,\n DEFAULT_MIN_DATE,\n getAdjustedMonth,\n isAfterDate,\n isBeforeDate,\n updateMaybeDateValue,\n useCalendarProps,\n} from \"../calendar\"\nimport { useFieldProps } from \"../field\"\nimport { useDateTimeFormat } from \"../format\"\n\nexport interface DatePickerFormat extends CalendarFormat {\n input?: Intl.DateTimeFormatOptions | null\n}\n\ntype InputAlign = \"end\" | \"start\"\ntype MaybeInputValue<Range extends boolean = false> = Range extends true\n ? { end?: string; start?: string }\n : string | undefined\n\ninterface DatePickerRenderProps {\n count: number\n date: Date\n focused: boolean\n index: number\n separator: string\n value: string\n onClear: () => void\n max?: number\n}\n\nexport interface DatePickerRender {\n (props: DatePickerRenderProps): ReactNode\n}\n\nconst defaultRender: DatePickerRender = ({\n count,\n focused,\n index,\n max,\n separator,\n value,\n}) => {\n const last = count - 1 === index\n\n return (\n <span style={{ marginInlineEnd: \"var(--gap)\" }}>\n {value}\n {((!isNumber(max) || count < max) && focused) || !last ? separator : null}\n </span>\n )\n}\n\nexport interface UseDatePickerProps<\n Multiple extends boolean = false,\n Range extends boolean = false,\n>\n extends\n Omit<UseCalendarProps<Multiple, Range>, \"format\" | \"ref\">,\n Omit<\n UseComboboxProps,\n \"defaultValue\" | \"initialFocusValue\" | \"onChange\" | \"ref\" | \"value\"\n >,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * If `true`, allows input.\n *\n * @default true\n */\n allowInput?: boolean\n /**\n * If `true`, allows input of dates beyond the `minDate` and `maxDate` restrictions.\n *\n * @default true\n */\n allowInputBeyond?: boolean\n /**\n * If `true`, the date picker will be closed when the input value changes.\n *\n * @default false\n */\n closeOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * The initial value of the input.\n */\n defaultInputValue?: MaybeInputValue<Range>\n /**\n * If `true`, the input will be focused when the clear icon is clicked.\n *\n * @default true\n */\n focusOnClear?: boolean\n /**\n * The format used for conversion.\n * Check the docs to see the format of possible modifiers you can pass.\n *\n * @see https://day.js.org/docs/en/display/format#list-of-localized-formats\n */\n format?: DatePickerFormat\n /**\n * The `id` attribute of the input element.\n */\n id?: string\n /**\n * The value of the input.\n */\n inputValue?: MaybeInputValue<Range>\n /**\n * The `name` attribute of the input element.\n */\n name?: string\n /**\n * If `true`, the date picker will be opened when the input value changes.\n *\n * @default true\n */\n openOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * If `true`, the date picker will be opened when the input is focused.\n *\n * @default true\n */\n openOnFocus?: boolean\n /**\n * The pattern used to check the input element.\n */\n pattern?: RegExp\n /**\n * The placeholder for date picker.\n */\n placeholder?: string\n /**\n * The visual separator between each value.\n *\n * @default ','\n */\n separator?: string\n /**\n * The callback invoked when input value state changes.\n */\n onInputChange?: (value: MaybeInputValue<Range>) => void\n /**\n * Function that converts the input value to Date type.\n */\n parseDate?: (value: string) => Date | undefined\n /**\n * The function to render the selected date.\n */\n render?: (props: DatePickerRenderProps) => ReactNode\n}\n\nexport const useDatePicker = <\n Multiple extends boolean = false,\n Range extends boolean = false,\n>({\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n ...props\n}: UseDatePickerProps<Multiple, Range> = {}) => {\n if (dayjs(minDate).isAfter(dayjs(maxDate))) maxDate = minDate\n\n const { locale: defaultLocale, t } = useI18n(\"datePicker\")\n const {\n props: {\n id,\n ref,\n name,\n allowInput = true,\n allowInputBeyond = false,\n closeOnChange = false,\n multiple = false,\n closeOnSelect = !multiple,\n defaultInputValue,\n defaultMonth = new Date(),\n range = false,\n defaultValue = (range\n ? { end: undefined, start: undefined }\n : multiple\n ? []\n : undefined) as MaybeDateValue<Multiple, Range>,\n disabled,\n focusOnClear = true,\n format,\n inputValue: inputValueProp,\n locale = defaultLocale,\n max,\n month: monthProp,\n openOnChange = true,\n openOnClick = true,\n openOnFocus = true,\n parseDate,\n pattern,\n placeholder: placeholderProp,\n readOnly,\n render = defaultRender,\n required,\n separator = range ? \"-\" : \",\",\n value: valueProp,\n onChange: onChangeProp,\n onChangeMonth: onChangeMonthProp,\n onInputChange: onInputChangeProp,\n ...computedProps\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const dateTimeFormat = useDateTimeFormat({ locale })\n const { calendarFormat, inputFormat } = useMemo(() => {\n const { input: inputFormat, ...calendarFormat } = format ?? {}\n const defaultInputFormat: Intl.DateTimeFormatOptions = {\n day: \"numeric\",\n month: \"long\",\n year: \"numeric\",\n }\n\n return {\n calendarFormat,\n inputFormat:\n inputFormat !== null ? (inputFormat ?? defaultInputFormat) : undefined,\n }\n }, [format])\n const [calendarProps, rest] = useCalendarProps<Multiple, Range>(computedProps)\n const { excludeDate } = calendarProps\n const fieldRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const startInputRef = useRef<HTMLInputElement>(null)\n const endInputRef = useRef<HTMLInputElement>(null)\n const focusByClickRef = useRef<boolean>(false)\n const [focused, setFocused] = useState(false)\n const [value, setValue] = useControllableState({\n defaultValue: defaultValue as MaybeDateValue<Multiple, Range>,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [month, setMonth] = useControllableState({\n defaultValue: () => {\n let value = defaultMonth\n\n if (dayjs(minDate).isAfter(dayjs(defaultMonth)))\n value = dayjs(minDate).set(\"date\", 1).toDate()\n\n if (valueProp) {\n value = getAdjustedMonth(valueProp, value)\n } else if (defaultValue) {\n value = getAdjustedMonth(defaultValue, value)\n }\n\n return value\n },\n value: monthProp,\n onChange: onChangeMonthProp,\n })\n const stringToDate = useCallback(\n (value: string, start: Date = minDate, end: Date = maxDate) => {\n let date = parseDate?.(value)\n\n if (!date && dayjs(value).isValid()) date = dayjs(value, locale).toDate()\n\n if (date == null) return undefined\n if (excludeDate?.(date)) return undefined\n\n if (!allowInputBeyond) {\n if (isBeforeDate(date, start)) date = start\n if (isAfterDate(date, end)) date = end\n }\n\n return date\n },\n [allowInputBeyond, excludeDate, locale, maxDate, minDate, parseDate],\n )\n const dateToString = useCallback(\n (date?: Date) => {\n if (date == null) return \"\"\n\n return dateTimeFormat(date, inputFormat)\n },\n [dateTimeFormat, inputFormat],\n )\n const [inputValue, setInputValue] = useControllableState({\n defaultValue: () => {\n if (defaultInputValue) {\n if (isObject(defaultInputValue)) {\n if (dayjs(defaultInputValue.start).isValid())\n defaultInputValue.start = dateTimeFormat(\n dayjs(defaultInputValue.start).toDate(),\n inputFormat,\n )\n\n if (dayjs(defaultInputValue.end).isValid())\n defaultInputValue.end = dateTimeFormat(\n dayjs(defaultInputValue.end).toDate(),\n inputFormat,\n )\n\n return defaultInputValue\n } else {\n if (dayjs(defaultInputValue).isValid()) {\n return dateTimeFormat(\n dayjs(defaultInputValue).toDate(),\n inputFormat,\n ) as MaybeInputValue<Range>\n } else {\n return defaultInputValue as MaybeInputValue<Range>\n }\n }\n } else if (isDate(value)) {\n return dateToString(value) as MaybeInputValue<Range>\n } else if (isObject(value) && !isArray(value)) {\n return {\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>\n } else {\n return \"\" as MaybeInputValue<Range>\n }\n },\n value: inputValueProp,\n onChange: onInputChangeProp,\n })\n const {\n interactive,\n open,\n getContentProps: getComboboxContentProps,\n getTriggerProps,\n popoverProps,\n onClose,\n onOpen,\n } = useCombobox({\n disabled,\n matchWidth: false,\n openOnClick: false,\n openOnEnter: !allowInput,\n openOnSpace: !allowInput,\n placement: \"end-start\",\n readOnly,\n transferFocus: false,\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n ...rest,\n })\n const children = useMemo<ReactNode>(() => {\n if (!isArray(value)) return null\n\n const count = value.length\n\n return value.map((date, index) => {\n const value = dateToString(date)\n\n const onClear = (ev?: MouseEvent<HTMLElement>) => {\n ev?.preventDefault()\n ev?.stopPropagation()\n\n setValue(\n (prev) =>\n updateMaybeDateValue(date, max)(prev) as MaybeDateValue<\n Multiple,\n Range\n >,\n )\n }\n\n const component = render({\n count,\n date,\n focused,\n index,\n max,\n separator,\n value,\n onClear,\n })\n\n if (isValidElement<Dict>(component)) {\n return cloneElement(component, { ...component.props, key: index })\n } else {\n return component\n }\n })\n }, [dateToString, focused, max, render, separator, setValue, value])\n const { endPlaceholder, startPlaceholder } = useMemo(() => {\n if (range) {\n const startPlaceholder =\n placeholderProp ?? dateTimeFormat(new Date(), inputFormat)\n const endPlaceholder =\n placeholderProp ??\n dateTimeFormat(dayjs().add(1, \"day\").toDate(), inputFormat)\n\n return { endPlaceholder, startPlaceholder }\n } else {\n const placeholder =\n placeholderProp ?? dateTimeFormat(new Date(), inputFormat)\n\n return { endPlaceholder: placeholder, startPlaceholder: placeholder }\n }\n }, [dateTimeFormat, inputFormat, placeholderProp, range])\n\n const onChange = useCallback(\n (value: MaybeDateValue<Multiple, Range>) => {\n setValue(value)\n\n if (isArray(value)) {\n setInputValue(\"\" as MaybeInputValue<Range>)\n } else if (isObject(value) && !isDate(value)) {\n setInputValue({\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>)\n } else {\n setInputValue(dateToString(value) as MaybeInputValue<Range>)\n }\n\n if (!closeOnSelect) return\n\n if (isObject(value) && !isArray(value) && !isDate(value)) {\n if (value.end && value.start) onClose()\n } else {\n onClose()\n }\n },\n [setValue, closeOnSelect, setInputValue, dateToString, onClose],\n )\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (!allowInput) return\n if (isArray(value) && value.length === max) return\n\n if (runIfFn(closeOnChange, ev)) {\n onClose()\n } else if (runIfFn(openOnChange, ev)) {\n onOpen()\n }\n\n let inputValue = ev.target.value\n\n if (pattern) inputValue = inputValue.replace(pattern, \"\")\n\n if (isArray(value)) {\n const date = stringToDate(inputValue)\n\n setInputValue(inputValue as MaybeInputValue<Range>)\n\n if (date) setMonth(dayjs(date).set(\"date\", 1).toDate())\n } else if (isObject(value) && !isDate(value)) {\n const align = contains(endInputRef.current, ev.target) ? \"end\" : \"start\"\n const minDate =\n value.start && align === \"end\"\n ? dayjs(value.start).add(1, \"day\").toDate()\n : undefined\n const maxDate =\n value.end && align === \"start\"\n ? dayjs(value.end).subtract(1, \"day\").toDate()\n : undefined\n const date = stringToDate(inputValue, minDate, maxDate)\n\n setInputValue((prev) =>\n isObject(prev)\n ? ({\n ...(prev as MaybeInputValue<true>),\n [align]: inputValue,\n } as MaybeInputValue<Range>)\n : prev,\n )\n setValue((prev) =>\n isObject(prev) && !isDate(prev)\n ? ({ ...prev, [align]: date } as MaybeDateValue<Multiple, Range>)\n : prev,\n )\n } else {\n const date = stringToDate(inputValue)\n\n setInputValue(inputValue as MaybeInputValue<Range>)\n setValue(date as MaybeDateValue<Multiple, Range>)\n }\n },\n [\n allowInput,\n closeOnChange,\n max,\n onClose,\n onOpen,\n openOnChange,\n pattern,\n setInputValue,\n setMonth,\n setValue,\n stringToDate,\n value,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLInputElement>) => {\n if (disabled || isComposing(ev)) return\n\n const inputValue = cast<HTMLInputElement>(ev.target).value\n\n runKeyAction(\n ev,\n {\n Backspace: (ev) => {\n if (!value || isDate(value)) return\n if (!!inputValue.length) return\n\n if (isArray(value)) {\n ev.preventDefault()\n\n setValue((prev) =>\n isArray(prev)\n ? (prev.slice(0, -1) as MaybeDateValue<Multiple, Range>)\n : prev,\n )\n } else if (contains(endInputRef.current, ev.target)) {\n ev.preventDefault()\n\n setInputValue({ end: \"\", start: \"\" } as MaybeInputValue<Range>)\n setValue({ end: undefined, start: undefined } as MaybeDateValue<\n Multiple,\n Range\n >)\n\n startInputRef.current?.focus()\n }\n },\n Enter: (ev) => {\n if (!open || !inputValue.length) return\n\n if (isDate(value) || isArray(value)) {\n const date = stringToDate(inputValue)\n\n if (!date) return\n\n ev.preventDefault()\n\n if (isArray(value)) {\n setInputValue(\"\" as MaybeInputValue<Range>)\n } else {\n setInputValue(dateToString(date) as MaybeInputValue<Range>)\n }\n\n setValue(\n (prev) =>\n updateMaybeDateValue(date, max)(prev) as MaybeDateValue<\n Multiple,\n Range\n >,\n )\n } else if (isObject(value)) {\n const align = contains(endInputRef.current, ev.target)\n ? \"end\"\n : \"start\"\n const minDate =\n value.start && align === \"end\"\n ? dayjs(value.start).add(1, \"day\").toDate()\n : undefined\n const maxDate =\n value.end && align === \"start\"\n ? dayjs(value.end).subtract(1, \"day\").toDate()\n : undefined\n const date = stringToDate(inputValue, minDate, maxDate)\n\n if (!date) return\n\n ev.preventDefault()\n\n setInputValue((prev) =>\n isObject(prev)\n ? ({\n ...(prev as MaybeInputValue<true>),\n [align]: dateToString(date),\n } as MaybeInputValue<Range>)\n : prev,\n )\n setValue((prev) =>\n isObject(prev) && !isDate(prev)\n ? ({ ...prev, [align]: date } as MaybeDateValue<\n Multiple,\n Range\n >)\n : prev,\n )\n\n if (align === \"start\") endInputRef.current?.focus()\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n dateToString,\n disabled,\n max,\n open,\n setInputValue,\n setValue,\n stringToDate,\n value,\n ],\n )\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (!interactive) return\n\n focusByClickRef.current = true\n\n if (allowInput) {\n if (isObject(value) && !isArray(value) && !isDate(value)) {\n if (contains(startInputRef.current, ev.target)) return\n if (contains(endInputRef.current, ev.target)) return\n\n const { end, start } = value\n\n if ((!start && !end) || !!end) {\n startInputRef.current?.focus()\n } else {\n endInputRef.current?.focus()\n }\n } else {\n startInputRef.current?.focus()\n }\n }\n\n if (openOnClick) onOpen()\n },\n [allowInput, interactive, onOpen, openOnClick, value],\n )\n\n const onMouseDown = useCallback(\n (ev: MouseEvent<HTMLDivElement | HTMLInputElement>) => {\n if (!openOnFocus) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [openOnFocus],\n )\n\n const onFieldFocus = useCallback(() => {\n if (allowInput) return\n\n if (openOnFocus) onOpen()\n\n focusByClickRef.current = false\n }, [allowInput, onOpen, openOnFocus])\n\n const onInputFocus = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n setFocused(true)\n\n if (openOnFocus && !focusByClickRef.current) onOpen()\n\n focusByClickRef.current = false\n },\n [onOpen, openOnFocus],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n setFocused(false)\n\n if (\n contains(fieldRef.current, ev.relatedTarget) ||\n contains(contentRef.current, ev.relatedTarget)\n ) {\n ev.preventDefault()\n } else {\n if (isArray(value)) {\n setInputValue(\"\" as MaybeInputValue<Range>)\n } else if (isObject(value) && !isDate(value)) {\n setInputValue((prev) =>\n isObject(prev)\n ? ({\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>)\n : prev,\n )\n } else {\n setInputValue(dateToString(value) as MaybeInputValue<Range>)\n }\n }\n },\n [dateToString, setInputValue, value],\n )\n\n const onClear = useCallback(() => {\n if (!interactive) return\n\n setValue((prev) => {\n if (isDate(prev)) {\n return undefined as MaybeDateValue<Multiple, Range>\n } else if (isArray(prev)) {\n return [] as unknown as MaybeDateValue<Multiple, Range>\n } else if (isObject(prev)) {\n return { end: undefined, start: undefined } as MaybeDateValue<\n Multiple,\n Range\n >\n } else {\n return prev\n }\n })\n\n setInputValue(\n (range ? { end: \"\", start: \"\" } : \"\") as MaybeInputValue<Range>,\n )\n\n if (focusOnClear) {\n if (allowInput) {\n startInputRef.current?.focus()\n } else {\n fieldRef.current?.focus()\n }\n }\n }, [allowInput, focusOnClear, interactive, range, setInputValue, setValue])\n\n useEffect(() => {\n if (!open) return\n\n return focusTransfer(\n contentRef.current,\n allowInput ? startInputRef.current : fieldRef.current,\n )\n }, [allowInput, open])\n\n useUpdateEffect(() => {\n setMonth((prev) => getAdjustedMonth(value, prev))\n }, [value, range])\n\n useUpdateEffect(() => {\n if (isArray(valueProp)) return\n\n if (isObject(valueProp) && !isDate(valueProp)) {\n setInputValue({\n end: dateToString(valueProp.end),\n start: dateToString(valueProp.start),\n } as MaybeInputValue<Range>)\n } else {\n setInputValue(dateToString(valueProp) as MaybeInputValue<Range>)\n }\n }, [valueProp])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n \"data-range\": dataAttr(range),\n ...dataProps,\n ...props,\n }),\n [dataProps, range],\n )\n\n const getFieldProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getTriggerProps({\n ref: mergeRefs(ref, fieldRef),\n \"aria-haspopup\": \"dialog\",\n tabIndex: !allowInput ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n onFocus: handlerAll(props.onFocus, onFieldFocus),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n\n [allowInput, getTriggerProps, onClick, onFieldFocus, onMouseDown],\n )\n\n const getInputProps: PropGetter<\"input\", { align?: InputAlign }> =\n useCallback(\n ({ align = \"start\", ...props } = {}) => {\n const inputProps: HTMLProps<\"input\"> = {\n style: {\n ...(!allowInput ? { pointerEvents: \"none\" } : {}),\n ...props.style,\n },\n autoComplete: \"off\",\n disabled,\n readOnly,\n required,\n tabIndex: allowInput ? 0 : -1,\n ...dataProps,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onInputChange),\n onFocus: handlerAll(props.onFocus, onInputFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }\n\n if (isObject(inputValue)) {\n if (align === \"start\") {\n inputProps.ref = mergeRefs(props.ref, ref, startInputRef)\n inputProps.value = inputValue.start\n inputProps.placeholder = startPlaceholder\n } else {\n inputProps.ref = mergeRefs(props.ref, ref, endInputRef)\n inputProps.value = inputValue.end\n inputProps.placeholder = endPlaceholder\n }\n\n if (!inputValue.start && align === \"start\") {\n inputProps.id = id\n inputProps.name = name\n }\n\n if (!!inputValue.start && align === \"end\") {\n inputProps.id = id\n inputProps.name = name\n }\n } else {\n inputProps.ref = mergeRefs(props.ref, ref, startInputRef)\n inputProps.value = inputValue\n inputProps.id = id\n inputProps.name = name\n\n if (isArray(value)) {\n inputProps.style = {\n ...(!focused && !!value.length\n ? visuallyHiddenAttributes.style\n : {}),\n ...inputProps.style,\n }\n inputProps.placeholder = !value.length\n ? startPlaceholder\n : undefined\n inputProps[\"data-max\"] = dataAttr(\n isNumber(max) && value.length >= max,\n )\n } else {\n inputProps.placeholder = startPlaceholder\n }\n }\n\n return inputProps\n },\n [\n allowInput,\n dataProps,\n disabled,\n endPlaceholder,\n focused,\n id,\n inputValue,\n max,\n name,\n onBlur,\n onInputFocus,\n onInputChange,\n onKeyDown,\n onMouseDown,\n readOnly,\n ref,\n required,\n startPlaceholder,\n value,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getComboboxContentProps({\n ref: mergeRefs(ref, contentRef),\n role: \"dialog\",\n ...props,\n }),\n [getComboboxContentProps],\n )\n\n const getCalendarProps: PropGetter<UseCalendarProps<Multiple, Range>> =\n useCallback(\n (props) =>\n ({\n disabled: !interactive,\n format: calendarFormat,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n value,\n onChange,\n onChangeMonth: setMonth,\n ...calendarProps,\n ...props,\n }) as UseCalendarProps<Multiple, Range>,\n [\n interactive,\n calendarFormat,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n value,\n onChange,\n setMonth,\n calendarProps,\n ],\n )\n\n const getIconProps: PropGetter = useCallback(\n (props) => ({ ...dataProps, ...props }),\n [dataProps],\n )\n\n const getClearIconProps: PropGetter = useCallback(\n (props = {}) =>\n getIconProps({\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-label\": t(\"Clear value\"),\n role: \"button\",\n tabIndex: interactive ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClear),\n onKeyDown: handlerAll(props.onKeyDown, (ev) =>\n runKeyAction(ev, { Enter: onClear, Space: onClear }),\n ),\n }),\n [getIconProps, interactive, onClear, t],\n )\n\n return {\n children,\n dateToString,\n inputValue,\n interactive,\n month,\n open,\n range,\n separator,\n setInputValue,\n setMonth,\n setValue,\n stringToDate,\n value,\n getCalendarProps,\n getClearIconProps,\n getContentProps,\n getFieldProps,\n getIconProps,\n getInputProps,\n getRootProps,\n popoverProps,\n onChange,\n onClose,\n onInputChange,\n onOpen,\n }\n}\n\nexport type UseDatePickerReturn = ReturnType<typeof useDatePicker>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqFA,MAAMA,iBAAmC,EACvC,OACA,SACA,OACA,KACA,WACA,YACI;CACJ,MAAM,OAAO,QAAQ,MAAM;AAE3B,QACE,qBAAC;EAAK,OAAO,EAAE,iBAAiB,cAAc;aAC3C,QACE,6BAAU,IAAI,IAAI,QAAQ,QAAQ,WAAY,CAAC,OAAO,YAAY;GAChE;;AAuGX,MAAa,iBAGX,EACA,UAAU,kBACV,UAAU,kBACV,GAAG,UACoC,EAAE,KAAK;AAC9C,KAAI,MAAM,QAAQ,CAAC,QAAQ,MA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EH,MAAMO,eAA2B,aAC9B,aAAW;EAAE,GAAG;EAAW,GAAGP;EAAO,GACtC,CAAC,UAAU,CACZ;AAkBD,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,mBA/BoC,aACnC,UAAQ,EAAE,KACT,aAAa;GACX,6CAA0B,CAAC,YAAY;GACvC,cAAc,EAAE,cAAc;GAC9B,MAAM;GACN,UAAU,cAAc,IAAI;GAC5B,GAAGA;GACH,uCAAoBA,QAAM,SAAS,QAAQ;GAC3C,yCAAsBA,QAAM,YAAY,OACtC,aAAa,IAAI;IAAE,OAAO;IAAS,OAAO;IAAS,CAAC,CACrD;GACF,CAAC,EACJ;GAAC;GAAc;GAAa;GAAS;GAAE,CACxC;EAkBC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
|
|
1
|
+
{"version":3,"file":"use-date-picker.js","names":["defaultRender: DatePickerRender","inputFormat","calendarFormat","value","onClear","startPlaceholder","inputValue","minDate","maxDate","ev","getRootProps: PropGetter","props","getFieldProps: PropGetter","ref","getInputProps: PropGetter<\"input\", { align?: InputAlign }>","inputProps: HTMLProps<\"input\">","getContentProps: PropGetter","getCalendarProps: PropGetter<UseCalendarProps<Multiple, Range>>","getIconProps: PropGetter"],"sources":["../../../../src/components/date-picker/use-date-picker.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type { UseComboboxProps } from \"../../hooks/use-combobox\"\nimport type { Dict } from \"../../utils\"\nimport type {\n CalendarFormat,\n MaybeDateValue,\n UseCalendarProps,\n} from \"../calendar\"\nimport type { FieldProps } from \"../field\"\nimport dayjs from \"dayjs\"\nimport {\n cloneElement,\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { useCombobox } from \"../../hooks/use-combobox\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n ariaAttr,\n cast,\n contains,\n dataAttr,\n focusTransfer,\n handlerAll,\n isArray,\n isComposing,\n isDate,\n isNumber,\n isObject,\n mergeRefs,\n runIfFn,\n runKeyAction,\n useUpdateEffect,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport {\n DEFAULT_MAX_DATE,\n DEFAULT_MIN_DATE,\n getAdjustedMonth,\n isAfterDate,\n isBeforeDate,\n updateMaybeDateValue,\n useCalendarProps,\n} from \"../calendar\"\nimport { useFieldProps } from \"../field\"\nimport { useDateTimeFormat } from \"../format\"\n\nexport interface DatePickerFormat extends CalendarFormat {\n input?: Intl.DateTimeFormatOptions | null\n}\n\ntype InputAlign = \"end\" | \"start\"\ntype MaybeInputValue<Range extends boolean = false> = Range extends true\n ? { end?: string; start?: string }\n : string | undefined\n\ninterface DatePickerRenderProps {\n count: number\n date: Date\n focused: boolean\n index: number\n separator: string\n value: string\n onClear: () => void\n max?: number\n}\n\nexport interface DatePickerRender {\n (props: DatePickerRenderProps): ReactNode\n}\n\nconst defaultRender: DatePickerRender = ({\n count,\n focused,\n index,\n max,\n separator,\n value,\n}) => {\n const last = count - 1 === index\n\n return (\n <span style={{ marginInlineEnd: \"var(--gap)\" }}>\n {value}\n {((!isNumber(max) || count < max) && focused) || !last ? separator : null}\n </span>\n )\n}\n\nexport interface UseDatePickerProps<\n Multiple extends boolean = false,\n Range extends boolean = false,\n>\n extends\n Omit<UseCalendarProps<Multiple, Range>, \"format\" | \"ref\">,\n Omit<\n UseComboboxProps,\n \"defaultValue\" | \"initialFocusValue\" | \"onChange\" | \"ref\" | \"value\"\n >,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * If `true`, allows input.\n *\n * @default true\n */\n allowInput?: boolean\n /**\n * If `true`, allows input of dates beyond the `minDate` and `maxDate` restrictions.\n *\n * @default true\n */\n allowInputBeyond?: boolean\n /**\n * If `true`, the date picker will be closed when the input value changes.\n *\n * @default false\n */\n closeOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * The initial value of the input.\n */\n defaultInputValue?: MaybeInputValue<Range>\n /**\n * If `true`, the input will be focused when the clear icon is clicked.\n *\n * @default true\n */\n focusOnClear?: boolean\n /**\n * The format used for conversion.\n * Check the docs to see the format of possible modifiers you can pass.\n *\n * @see https://day.js.org/docs/en/display/format#list-of-localized-formats\n */\n format?: DatePickerFormat\n /**\n * The `id` attribute of the input element.\n */\n id?: string\n /**\n * The value of the input.\n */\n inputValue?: MaybeInputValue<Range>\n /**\n * The `name` attribute of the input element.\n */\n name?: string\n /**\n * If `true`, the date picker will be opened when the input value changes.\n *\n * @default true\n */\n openOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * If `true`, the date picker will be opened when the input is focused.\n *\n * @default true\n */\n openOnFocus?: boolean\n /**\n * The pattern used to check the input element.\n */\n pattern?: RegExp\n /**\n * The placeholder for date picker.\n */\n placeholder?: string\n /**\n * The visual separator between each value.\n *\n * @default ','\n */\n separator?: string\n /**\n * The callback invoked when input value state changes.\n */\n onInputChange?: (value: MaybeInputValue<Range>) => void\n /**\n * Function that converts the input value to Date type.\n */\n parseDate?: (value: string) => Date | undefined\n /**\n * The function to render the selected date.\n */\n render?: (props: DatePickerRenderProps) => ReactNode\n}\n\nexport const useDatePicker = <\n Multiple extends boolean = false,\n Range extends boolean = false,\n>({\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n ...props\n}: UseDatePickerProps<Multiple, Range> = {}) => {\n if (dayjs(minDate).isAfter(dayjs(maxDate))) maxDate = minDate\n\n const { locale: defaultLocale, t } = useI18n(\"datePicker\")\n const {\n props: {\n id,\n ref,\n name,\n allowInput = true,\n allowInputBeyond = false,\n closeOnChange = false,\n multiple = false,\n closeOnSelect = !multiple,\n defaultInputValue,\n defaultMonth = new Date(),\n range = false,\n defaultValue = (range\n ? { end: undefined, start: undefined }\n : multiple\n ? []\n : undefined) as MaybeDateValue<Multiple, Range>,\n disabled,\n focusOnClear = true,\n format,\n inputValue: inputValueProp,\n locale = defaultLocale,\n max,\n month: monthProp,\n openOnChange = true,\n openOnClick = true,\n openOnFocus = true,\n parseDate,\n pattern,\n placeholder: placeholderProp,\n readOnly,\n render = defaultRender,\n required,\n separator = range ? \"-\" : \",\",\n value: valueProp,\n onChange: onChangeProp,\n onChangeMonth: onChangeMonthProp,\n onInputChange: onInputChangeProp,\n ...computedProps\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const dateTimeFormat = useDateTimeFormat({ locale })\n const { calendarFormat, inputFormat } = useMemo(() => {\n const { input: inputFormat, ...calendarFormat } = format ?? {}\n const defaultInputFormat: Intl.DateTimeFormatOptions = {\n day: \"numeric\",\n month: \"long\",\n year: \"numeric\",\n }\n\n return {\n calendarFormat,\n inputFormat:\n inputFormat !== null ? (inputFormat ?? defaultInputFormat) : undefined,\n }\n }, [format])\n const [calendarProps, rest] = useCalendarProps<Multiple, Range>(computedProps)\n const { excludeDate } = calendarProps\n const fieldRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const startInputRef = useRef<HTMLInputElement>(null)\n const endInputRef = useRef<HTMLInputElement>(null)\n const focusByClickRef = useRef<boolean>(false)\n const [focused, setFocused] = useState(false)\n const [value, setValue] = useControllableState({\n defaultValue: defaultValue as MaybeDateValue<Multiple, Range>,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [month, setMonth] = useControllableState({\n defaultValue: () => {\n let value = defaultMonth\n\n if (dayjs(minDate).isAfter(dayjs(defaultMonth)))\n value = dayjs(minDate).set(\"date\", 1).toDate()\n\n if (valueProp) {\n value = getAdjustedMonth(valueProp, value)\n } else if (defaultValue) {\n value = getAdjustedMonth(defaultValue, value)\n }\n\n return value\n },\n value: monthProp,\n onChange: onChangeMonthProp,\n })\n const stringToDate = useCallback(\n (value: string, start: Date = minDate, end: Date = maxDate) => {\n let date = parseDate?.(value)\n\n if (!date && dayjs(value).isValid()) date = dayjs(value, locale).toDate()\n\n if (date == null) return undefined\n if (excludeDate?.(date)) return undefined\n\n if (!allowInputBeyond) {\n if (isBeforeDate(date, start)) date = start\n if (isAfterDate(date, end)) date = end\n }\n\n return date\n },\n [allowInputBeyond, excludeDate, locale, maxDate, minDate, parseDate],\n )\n const dateToString = useCallback(\n (date?: Date) => {\n if (date == null) return \"\"\n\n return dateTimeFormat(date, inputFormat)\n },\n [dateTimeFormat, inputFormat],\n )\n const [inputValue, setInputValue] = useControllableState({\n defaultValue: () => {\n if (defaultInputValue) {\n if (isObject(defaultInputValue)) {\n if (dayjs(defaultInputValue.start).isValid())\n defaultInputValue.start = dateTimeFormat(\n dayjs(defaultInputValue.start).toDate(),\n inputFormat,\n )\n\n if (dayjs(defaultInputValue.end).isValid())\n defaultInputValue.end = dateTimeFormat(\n dayjs(defaultInputValue.end).toDate(),\n inputFormat,\n )\n\n return defaultInputValue\n } else {\n if (dayjs(defaultInputValue).isValid()) {\n return dateTimeFormat(\n dayjs(defaultInputValue).toDate(),\n inputFormat,\n ) as MaybeInputValue<Range>\n } else {\n return defaultInputValue as MaybeInputValue<Range>\n }\n }\n } else if (isDate(value)) {\n return dateToString(value) as MaybeInputValue<Range>\n } else if (isObject(value) && !isArray(value)) {\n return {\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>\n } else {\n return \"\" as MaybeInputValue<Range>\n }\n },\n value: inputValueProp,\n onChange: onInputChangeProp,\n })\n const {\n interactive,\n open,\n getContentProps: getComboboxContentProps,\n getTriggerProps,\n popoverProps,\n onClose,\n onOpen,\n } = useCombobox({\n disabled,\n matchWidth: false,\n openOnClick: false,\n openOnEnter: !allowInput,\n openOnSpace: !allowInput,\n placement: \"end-start\",\n readOnly,\n transferFocus: false,\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n ...rest,\n })\n const children = useMemo<ReactNode>(() => {\n if (!isArray(value)) return null\n\n const count = value.length\n\n return value.map((date, index) => {\n const value = dateToString(date)\n\n const onClear = (ev?: MouseEvent<HTMLElement>) => {\n ev?.preventDefault()\n ev?.stopPropagation()\n\n setValue(\n (prev) =>\n updateMaybeDateValue(date, max)(prev) as MaybeDateValue<\n Multiple,\n Range\n >,\n )\n }\n\n const component = render({\n count,\n date,\n focused,\n index,\n max,\n separator,\n value,\n onClear,\n })\n\n if (isValidElement<Dict>(component)) {\n return cloneElement(component, { ...component.props, key: index })\n } else {\n return component\n }\n })\n }, [dateToString, focused, max, render, separator, setValue, value])\n const { endPlaceholder, startPlaceholder } = useMemo(() => {\n if (range) {\n const startPlaceholder =\n placeholderProp ?? dateTimeFormat(new Date(), inputFormat)\n const endPlaceholder =\n placeholderProp ??\n dateTimeFormat(dayjs().add(1, \"day\").toDate(), inputFormat)\n\n return { endPlaceholder, startPlaceholder }\n } else {\n const placeholder =\n placeholderProp ?? dateTimeFormat(new Date(), inputFormat)\n\n return { endPlaceholder: placeholder, startPlaceholder: placeholder }\n }\n }, [dateTimeFormat, inputFormat, placeholderProp, range])\n\n const onChange = useCallback(\n (value: MaybeDateValue<Multiple, Range>) => {\n setValue(value)\n\n if (isArray(value)) {\n setInputValue(\"\" as MaybeInputValue<Range>)\n } else if (isObject(value) && !isDate(value)) {\n setInputValue({\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>)\n } else {\n setInputValue(dateToString(value) as MaybeInputValue<Range>)\n }\n\n if (!closeOnSelect) return\n\n if (isObject(value) && !isArray(value) && !isDate(value)) {\n if (value.end && value.start) onClose()\n } else {\n onClose()\n }\n },\n [setValue, closeOnSelect, setInputValue, dateToString, onClose],\n )\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (!allowInput) return\n if (isArray(value) && value.length === max) return\n\n if (runIfFn(closeOnChange, ev)) {\n onClose()\n } else if (runIfFn(openOnChange, ev)) {\n onOpen()\n }\n\n let inputValue = ev.target.value\n\n if (pattern) inputValue = inputValue.replace(pattern, \"\")\n\n if (isArray(value)) {\n const date = stringToDate(inputValue)\n\n setInputValue(inputValue as MaybeInputValue<Range>)\n\n if (date) setMonth(dayjs(date).set(\"date\", 1).toDate())\n } else if (isObject(value) && !isDate(value)) {\n const align = contains(endInputRef.current, ev.target) ? \"end\" : \"start\"\n const minDate =\n value.start && align === \"end\"\n ? dayjs(value.start).add(1, \"day\").toDate()\n : undefined\n const maxDate =\n value.end && align === \"start\"\n ? dayjs(value.end).subtract(1, \"day\").toDate()\n : undefined\n const date = stringToDate(inputValue, minDate, maxDate)\n\n setInputValue((prev) =>\n isObject(prev)\n ? ({\n ...(prev as MaybeInputValue<true>),\n [align]: inputValue,\n } as MaybeInputValue<Range>)\n : prev,\n )\n setValue((prev) =>\n isObject(prev) && !isDate(prev)\n ? ({ ...prev, [align]: date } as MaybeDateValue<Multiple, Range>)\n : prev,\n )\n } else {\n const date = stringToDate(inputValue)\n\n setInputValue(inputValue as MaybeInputValue<Range>)\n setValue(date as MaybeDateValue<Multiple, Range>)\n }\n },\n [\n allowInput,\n closeOnChange,\n max,\n onClose,\n onOpen,\n openOnChange,\n pattern,\n setInputValue,\n setMonth,\n setValue,\n stringToDate,\n value,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLInputElement>) => {\n if (disabled || isComposing(ev)) return\n\n const inputValue = cast<HTMLInputElement>(ev.target).value\n\n runKeyAction(\n ev,\n {\n Backspace: (ev) => {\n if (!value || isDate(value)) return\n if (inputValue.length) return\n\n if (isArray(value)) {\n ev.preventDefault()\n\n setValue((prev) =>\n isArray(prev)\n ? (prev.slice(0, -1) as MaybeDateValue<Multiple, Range>)\n : prev,\n )\n } else if (contains(endInputRef.current, ev.target)) {\n ev.preventDefault()\n\n setInputValue({ end: \"\", start: \"\" } as MaybeInputValue<Range>)\n setValue({ end: undefined, start: undefined } as MaybeDateValue<\n Multiple,\n Range\n >)\n\n startInputRef.current?.focus()\n }\n },\n Enter: (ev) => {\n if (!open || !inputValue.length) return\n\n if (isDate(value) || isArray(value)) {\n const date = stringToDate(inputValue)\n\n if (!date) return\n\n ev.preventDefault()\n\n if (isArray(value)) {\n setInputValue(\"\" as MaybeInputValue<Range>)\n } else {\n setInputValue(dateToString(date) as MaybeInputValue<Range>)\n }\n\n setValue(\n (prev) =>\n updateMaybeDateValue(date, max)(prev) as MaybeDateValue<\n Multiple,\n Range\n >,\n )\n } else if (isObject(value)) {\n const align = contains(endInputRef.current, ev.target)\n ? \"end\"\n : \"start\"\n const minDate =\n value.start && align === \"end\"\n ? dayjs(value.start).add(1, \"day\").toDate()\n : undefined\n const maxDate =\n value.end && align === \"start\"\n ? dayjs(value.end).subtract(1, \"day\").toDate()\n : undefined\n const date = stringToDate(inputValue, minDate, maxDate)\n\n if (!date) return\n\n ev.preventDefault()\n\n setInputValue((prev) =>\n isObject(prev)\n ? ({\n ...(prev as MaybeInputValue<true>),\n [align]: dateToString(date),\n } as MaybeInputValue<Range>)\n : prev,\n )\n setValue((prev) =>\n isObject(prev) && !isDate(prev)\n ? ({ ...prev, [align]: date } as MaybeDateValue<\n Multiple,\n Range\n >)\n : prev,\n )\n\n if (align === \"start\") endInputRef.current?.focus()\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n dateToString,\n disabled,\n max,\n open,\n setInputValue,\n setValue,\n stringToDate,\n value,\n ],\n )\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (!interactive) return\n\n focusByClickRef.current = true\n\n if (allowInput) {\n if (isObject(value) && !isArray(value) && !isDate(value)) {\n if (contains(startInputRef.current, ev.target)) return\n if (contains(endInputRef.current, ev.target)) return\n\n const { end, start } = value\n\n if ((!start && !end) || !!end) {\n startInputRef.current?.focus()\n } else {\n endInputRef.current?.focus()\n }\n } else {\n startInputRef.current?.focus()\n }\n }\n\n if (openOnClick) onOpen()\n },\n [allowInput, interactive, onOpen, openOnClick, value],\n )\n\n const onMouseDown = useCallback(\n (ev: MouseEvent<HTMLDivElement | HTMLInputElement>) => {\n if (!openOnFocus) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [openOnFocus],\n )\n\n const onFieldFocus = useCallback(() => {\n if (allowInput) return\n\n if (openOnFocus) onOpen()\n\n focusByClickRef.current = false\n }, [allowInput, onOpen, openOnFocus])\n\n const onInputFocus = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n setFocused(true)\n\n if (openOnFocus && !focusByClickRef.current) onOpen()\n\n focusByClickRef.current = false\n },\n [onOpen, openOnFocus],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n setFocused(false)\n\n if (\n contains(fieldRef.current, ev.relatedTarget) ||\n contains(contentRef.current, ev.relatedTarget)\n ) {\n ev.preventDefault()\n } else {\n if (isArray(value)) {\n setInputValue(\"\" as MaybeInputValue<Range>)\n } else if (isObject(value) && !isDate(value)) {\n setInputValue((prev) =>\n isObject(prev)\n ? ({\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>)\n : prev,\n )\n } else {\n setInputValue(dateToString(value) as MaybeInputValue<Range>)\n }\n }\n },\n [dateToString, setInputValue, value],\n )\n\n const onClear = useCallback(() => {\n if (!interactive) return\n\n setValue((prev) => {\n if (isDate(prev)) {\n return undefined as MaybeDateValue<Multiple, Range>\n } else if (isArray(prev)) {\n return [] as unknown as MaybeDateValue<Multiple, Range>\n } else if (isObject(prev)) {\n return { end: undefined, start: undefined } as MaybeDateValue<\n Multiple,\n Range\n >\n } else {\n return prev\n }\n })\n\n setInputValue(\n (range ? { end: \"\", start: \"\" } : \"\") as MaybeInputValue<Range>,\n )\n\n if (focusOnClear) {\n if (allowInput) {\n startInputRef.current?.focus()\n } else {\n fieldRef.current?.focus()\n }\n }\n }, [allowInput, focusOnClear, interactive, range, setInputValue, setValue])\n\n useEffect(() => {\n if (!open) return\n\n return focusTransfer(\n contentRef.current,\n allowInput ? startInputRef.current : fieldRef.current,\n )\n }, [allowInput, open])\n\n useUpdateEffect(() => {\n setMonth((prev) => getAdjustedMonth(value, prev))\n }, [value, range])\n\n useUpdateEffect(() => {\n if (isArray(valueProp)) return\n\n if (isObject(valueProp) && !isDate(valueProp)) {\n setInputValue({\n end: dateToString(valueProp.end),\n start: dateToString(valueProp.start),\n } as MaybeInputValue<Range>)\n } else {\n setInputValue(dateToString(valueProp) as MaybeInputValue<Range>)\n }\n }, [valueProp])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n \"data-range\": dataAttr(range),\n ...dataProps,\n ...props,\n }),\n [dataProps, range],\n )\n\n const getFieldProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getTriggerProps({\n ref: mergeRefs(ref, fieldRef),\n \"aria-haspopup\": \"dialog\",\n tabIndex: !allowInput ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n onFocus: handlerAll(props.onFocus, onFieldFocus),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n\n [allowInput, getTriggerProps, onClick, onFieldFocus, onMouseDown],\n )\n\n const getInputProps: PropGetter<\"input\", { align?: InputAlign }> =\n useCallback(\n ({ align = \"start\", ...props } = {}) => {\n const inputProps: HTMLProps<\"input\"> = {\n style: {\n ...(!allowInput ? { pointerEvents: \"none\" } : {}),\n ...props.style,\n },\n autoComplete: \"off\",\n disabled,\n readOnly,\n required,\n tabIndex: allowInput ? 0 : -1,\n ...dataProps,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onInputChange),\n onFocus: handlerAll(props.onFocus, onInputFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }\n\n if (isObject(inputValue)) {\n if (align === \"start\") {\n inputProps.ref = mergeRefs(props.ref, ref, startInputRef)\n inputProps.value = inputValue.start\n inputProps.placeholder = startPlaceholder\n } else {\n inputProps.ref = mergeRefs(props.ref, ref, endInputRef)\n inputProps.value = inputValue.end\n inputProps.placeholder = endPlaceholder\n }\n\n if (!inputValue.start && align === \"start\") {\n inputProps.id = id\n inputProps.name = name\n }\n\n if (!!inputValue.start && align === \"end\") {\n inputProps.id = id\n inputProps.name = name\n }\n } else {\n inputProps.ref = mergeRefs(props.ref, ref, startInputRef)\n inputProps.value = inputValue\n inputProps.id = id\n inputProps.name = name\n\n if (isArray(value)) {\n inputProps.style = {\n ...(!focused && !!value.length\n ? visuallyHiddenAttributes.style\n : {}),\n ...inputProps.style,\n }\n inputProps.placeholder = !value.length\n ? startPlaceholder\n : undefined\n inputProps[\"data-max\"] = dataAttr(\n isNumber(max) && value.length >= max,\n )\n } else {\n inputProps.placeholder = startPlaceholder\n }\n }\n\n return inputProps\n },\n [\n allowInput,\n dataProps,\n disabled,\n endPlaceholder,\n focused,\n id,\n inputValue,\n max,\n name,\n onBlur,\n onInputFocus,\n onInputChange,\n onKeyDown,\n onMouseDown,\n readOnly,\n ref,\n required,\n startPlaceholder,\n value,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getComboboxContentProps({\n ref: mergeRefs(ref, contentRef),\n role: \"dialog\",\n ...props,\n }),\n [getComboboxContentProps],\n )\n\n const getCalendarProps: PropGetter<UseCalendarProps<Multiple, Range>> =\n useCallback(\n (props) =>\n ({\n disabled: !interactive,\n format: calendarFormat,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n value,\n onChange,\n onChangeMonth: setMonth,\n ...calendarProps,\n ...props,\n }) as UseCalendarProps<Multiple, Range>,\n [\n interactive,\n calendarFormat,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n value,\n onChange,\n setMonth,\n calendarProps,\n ],\n )\n\n const getIconProps: PropGetter = useCallback(\n (props) => ({ ...dataProps, ...props }),\n [dataProps],\n )\n\n const getClearIconProps: PropGetter = useCallback(\n (props = {}) =>\n getIconProps({\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-label\": t(\"Clear value\"),\n role: \"button\",\n tabIndex: interactive ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClear),\n onKeyDown: handlerAll(props.onKeyDown, (ev) =>\n runKeyAction(ev, { Enter: onClear, Space: onClear }),\n ),\n }),\n [getIconProps, interactive, onClear, t],\n )\n\n return {\n children,\n dateToString,\n inputValue,\n interactive,\n month,\n open,\n range,\n separator,\n setInputValue,\n setMonth,\n setValue,\n stringToDate,\n value,\n getCalendarProps,\n getClearIconProps,\n getContentProps,\n getFieldProps,\n getIconProps,\n getInputProps,\n getRootProps,\n popoverProps,\n onChange,\n onClose,\n onInputChange,\n onOpen,\n }\n}\n\nexport type UseDatePickerReturn = ReturnType<typeof useDatePicker>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAqFA,MAAMA,iBAAmC,EACvC,OACA,SACA,OACA,KACA,WACA,YACI;CACJ,MAAM,OAAO,QAAQ,MAAM;AAE3B,QACE,qBAAC;EAAK,OAAO,EAAE,iBAAiB,cAAc;aAC3C,QACE,6BAAU,IAAI,IAAI,QAAQ,QAAQ,WAAY,CAAC,OAAO,YAAY;GAChE;;AAuGX,MAAa,iBAGX,EACA,UAAU,kBACV,UAAU,kBACV,GAAG,UACoC,EAAE,KAAK;AAC9C,KAAI,MAAM,QAAQ,CAAC,QAAQ,MAAM,QAAQ,CAAC,CAAE,WAAU;CAEtD,MAAM,EAAE,QAAQ,eAAe,MAAM,QAAQ,aAAa;CAC1D,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,aAAa,MACb,mBAAmB,OACnB,gBAAgB,OAChB,WAAW,OACX,gBAAgB,CAAC,UACjB,mBACA,+BAAe,IAAI,MAAM,EACzB,QAAQ,OACR,eAAgB,QACZ;EAAE,KAAK;EAAW,OAAO;EAAW,GACpC,WACE,EAAE,GACF,QACN,UACA,eAAe,MACf,QACA,YAAY,gBACZ,SAA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sBA,QAAM,YAAY,OACtC,aAAa,IAAI;IAAE,OAAO;IAAS,OAAO;IAAS,CAAC,CACrD;GACF,CAAC,EACJ;GAAC;GAAc;GAAa;GAAS;GAAE,CACxC;EAkBC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropzone.js","names":["DropzoneAccept: FC<DropzoneAcceptProps>","DropzoneReject: FC<DropzoneRejectProps>","DropzoneIdle: FC<DropzoneIdleProps>"],"sources":["../../../../src/components/dropzone/dropzone.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren } from \"react\"\nimport type { HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { Merge } from \"../../utils\"\nimport type { FadeProps } from \"../fade\"\nimport type { UseInputBorderProps } from \"../input\"\nimport type { Loading } from \"../loading\"\nimport type { DropzoneStyle } from \"./dropzone.style\"\nimport type { UseDropzoneProps, UseDropzoneReturn } from \"./use-dropzone\"\nimport { useMemo } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { Fade } from \"../fade\"\nimport { useInputBorder } from \"../input\"\nimport { useLoadingComponent } from \"../loading\"\nimport { Portal } from \"../portal\"\nimport { dropzoneStyle } from \"./dropzone.style\"\nimport { useDropzone } from \"./use-dropzone\"\n\ninterface ComponentContext extends Pick<\n UseDropzoneReturn,\n \"dragAccept\" | \"dragIdle\" | \"dragReject\" | \"loading\"\n> {}\n\nexport interface DropzoneRootProps\n extends\n Merge<HTMLStyledProps, UseDropzoneProps>,\n UseInputBorderProps,\n ThemeProps<DropzoneStyle>,\n Pick<DropzoneLoadingProps, \"loadingScheme\"> {\n /**\n * Props for dropzone input element.\n */\n inputProps?: HTMLStyledProps<\"input\">\n /**\n * Props for dropzone loading icon element.\n */\n loadingProps?: DropzoneLoadingProps\n /**\n * Props for dropzone overlay element.\n */\n overlayProps?: DropzoneOverlayProps\n}\n\nconst {\n ComponentContext,\n PropsContext: DropzonePropsContext,\n useComponentContext,\n usePropsContext: useDropzonePropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<DropzoneRootProps, DropzoneStyle>(\n \"dropzone\",\n dropzoneStyle,\n)\n\nexport { DropzonePropsContext, useDropzonePropsContext }\n\n/**\n * `Dropzone` is a component used for uploading files via drag and drop.\n *\n * @see https://yamada-ui.com/docs/components/dropzone\n */\nexport const DropzoneRoot = withProvider(\n ({\n children,\n errorBorderColor,\n focusBorderColor,\n loadingScheme,\n inputProps,\n loadingProps,\n overlayProps,\n ...rest\n }) => {\n const varProps = useInputBorder({ errorBorderColor, focusBorderColor })\n const {\n dragAccept,\n dragIdle,\n dragReject,\n loading,\n getInputProps,\n getRootProps,\n } = useDropzone(rest)\n const context = useMemo(\n () => ({\n dragAccept,\n dragIdle,\n dragReject,\n loading,\n }),\n [dragAccept, dragIdle, dragReject, loading],\n )\n\n return (\n <ComponentContext value={context}>\n <Portal>\n <styled.input {...getInputProps(inputProps)} />\n </Portal>\n\n <styled.div data-group {...varProps} {...getRootProps()}>\n <DropzoneOverlay {...overlayProps}>\n <DropzoneLoading loadingScheme={loadingScheme} {...loadingProps} />\n </DropzoneOverlay>\n\n {children}\n </styled.div>\n </ComponentContext>\n )\n },\n \"root\",\n)()\n\nexport interface DropzoneIconProps extends HTMLStyledProps<\"svg\"> {}\n\nexport const DropzoneIcon = withContext<\"svg\", DropzoneIconProps>(\n \"svg\",\n \"icon\",\n)()\n\nexport interface DropzoneTitleProps extends HTMLStyledProps<\"p\"> {}\n\nexport const DropzoneTitle = withContext<\"p\", DropzoneTitleProps>(\n \"p\",\n \"title\",\n)()\n\nexport interface DropzoneDescriptionProps extends HTMLStyledProps<\"p\"> {}\n\nexport const DropzoneDescription = withContext<\"p\", DropzoneDescriptionProps>(\n \"p\",\n \"description\",\n)()\n\
|
|
1
|
+
{"version":3,"file":"dropzone.js","names":["DropzoneAccept: FC<DropzoneAcceptProps>","DropzoneReject: FC<DropzoneRejectProps>","DropzoneIdle: FC<DropzoneIdleProps>"],"sources":["../../../../src/components/dropzone/dropzone.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren } from \"react\"\nimport type { HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { Merge } from \"../../utils\"\nimport type { FadeProps } from \"../fade\"\nimport type { UseInputBorderProps } from \"../input\"\nimport type { Loading } from \"../loading\"\nimport type { DropzoneStyle } from \"./dropzone.style\"\nimport type { UseDropzoneProps, UseDropzoneReturn } from \"./use-dropzone\"\nimport { useMemo } from \"react\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { Fade } from \"../fade\"\nimport { useInputBorder } from \"../input\"\nimport { useLoadingComponent } from \"../loading\"\nimport { Portal } from \"../portal\"\nimport { dropzoneStyle } from \"./dropzone.style\"\nimport { useDropzone } from \"./use-dropzone\"\n\ninterface ComponentContext extends Pick<\n UseDropzoneReturn,\n \"dragAccept\" | \"dragIdle\" | \"dragReject\" | \"loading\"\n> {}\n\nexport interface DropzoneRootProps\n extends\n Merge<HTMLStyledProps, UseDropzoneProps>,\n UseInputBorderProps,\n ThemeProps<DropzoneStyle>,\n Pick<DropzoneLoadingProps, \"loadingScheme\"> {\n /**\n * Props for dropzone input element.\n */\n inputProps?: HTMLStyledProps<\"input\">\n /**\n * Props for dropzone loading icon element.\n */\n loadingProps?: DropzoneLoadingProps\n /**\n * Props for dropzone overlay element.\n */\n overlayProps?: DropzoneOverlayProps\n}\n\nconst {\n ComponentContext,\n PropsContext: DropzonePropsContext,\n useComponentContext,\n usePropsContext: useDropzonePropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<DropzoneRootProps, DropzoneStyle>(\n \"dropzone\",\n dropzoneStyle,\n)\n\nexport { DropzonePropsContext, useDropzonePropsContext }\n\n/**\n * `Dropzone` is a component used for uploading files via drag and drop.\n *\n * @see https://yamada-ui.com/docs/components/dropzone\n */\nexport const DropzoneRoot = withProvider(\n ({\n children,\n errorBorderColor,\n focusBorderColor,\n loadingScheme,\n inputProps,\n loadingProps,\n overlayProps,\n ...rest\n }) => {\n const varProps = useInputBorder({ errorBorderColor, focusBorderColor })\n const {\n dragAccept,\n dragIdle,\n dragReject,\n loading,\n getInputProps,\n getRootProps,\n } = useDropzone(rest)\n const context = useMemo(\n () => ({\n dragAccept,\n dragIdle,\n dragReject,\n loading,\n }),\n [dragAccept, dragIdle, dragReject, loading],\n )\n\n return (\n <ComponentContext value={context}>\n <Portal>\n <styled.input {...getInputProps(inputProps)} />\n </Portal>\n\n <styled.div data-group {...varProps} {...getRootProps()}>\n <DropzoneOverlay {...overlayProps}>\n <DropzoneLoading loadingScheme={loadingScheme} {...loadingProps} />\n </DropzoneOverlay>\n\n {children}\n </styled.div>\n </ComponentContext>\n )\n },\n \"root\",\n)()\n\nexport interface DropzoneIconProps extends HTMLStyledProps<\"svg\"> {}\n\nexport const DropzoneIcon = withContext<\"svg\", DropzoneIconProps>(\n \"svg\",\n \"icon\",\n)()\n\nexport interface DropzoneTitleProps extends HTMLStyledProps<\"p\"> {}\n\nexport const DropzoneTitle = withContext<\"p\", DropzoneTitleProps>(\n \"p\",\n \"title\",\n)()\n\nexport interface DropzoneDescriptionProps extends HTMLStyledProps<\"p\"> {}\n\nexport const DropzoneDescription = withContext<\"p\", DropzoneDescriptionProps>(\n \"p\",\n \"description\",\n)()\n\ninterface DropzoneOverlayProps extends FadeProps {\n loadingProps?: DropzoneLoadingProps\n}\n\nconst DropzoneOverlay = withContext<\"div\", DropzoneOverlayProps>(\n Fade,\n \"overlay\",\n)(undefined, (props) => {\n const { loading } = useComponentContext()\n\n return { open: loading, unmountOnExit: true, ...props }\n})\n\ninterface DropzoneLoadingProps extends Loading.Props {\n /**\n * The loading scheme.\n *\n * @default 'oval'\n */\n loadingScheme?: Loading.Scheme\n}\n\nconst DropzoneLoading = withContext<\"svg\", DropzoneLoadingProps>(\n ({ loadingScheme = \"oval\", ...rest }) => {\n const Component = useLoadingComponent(loadingScheme)\n\n return <Component {...rest} />\n },\n \"loading\",\n)()\n\nexport interface DropzoneAcceptProps extends PropsWithChildren {}\n\nexport const DropzoneAccept: FC<DropzoneAcceptProps> = ({ children }) => {\n const { dragAccept } = useComponentContext()\n\n return dragAccept ? children : null\n}\n\nexport interface DropzoneRejectProps extends PropsWithChildren {}\n\nexport const DropzoneReject: FC<DropzoneRejectProps> = ({ children }) => {\n const { dragReject } = useComponentContext()\n\n return dragReject ? children : null\n}\n\nexport interface DropzoneIdleProps extends PropsWithChildren {}\n\nexport const DropzoneIdle: FC<DropzoneIdleProps> = ({ children }) => {\n const { dragIdle } = useComponentContext()\n\n return dragIdle ? children : null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA4CA,MAAM,EACJ,kBACA,cAAc,sBACd,qBACA,iBAAiB,yBACjB,aACA,iBACE,oBACF,YACA,cACD;;;;;;AASD,MAAa,eAAe,cACzB,EACC,UACA,kBACA,kBACA,eACA,YACA,cACA,cACA,GAAG,WACC;CACJ,MAAM,WAAW,eAAe;EAAE;EAAkB;EAAkB,CAAC;CACvE,MAAM,EACJ,YACA,UACA,YACA,SACA,eACA,iBACE,YAAY,KAAK;AAWrB,QACE,qBAAC;EAAiB,OAXJ,eACP;GACL;GACA;GACA;GACA;GACD,GACD;GAAC;GAAY;GAAU;GAAY;GAAQ,CAC5C;aAIG,oBAAC,oBACC,oBAAC,OAAO,SAAM,GAAI,cAAc,WAAW,GAAI,GACxC,EAET,qBAAC,OAAO;GAAI;GAAW,GAAI;GAAU,GAAI,cAAc;cACrD,oBAAC;IAAgB,GAAI;cACnB,oBAAC;KAA+B;KAAe,GAAI;MAAgB;KACnD,EAEjB;IACU;GACI;GAGvB,OACD,EAAE;AAIH,MAAa,eAAe,YAC1B,OACA,OACD,EAAE;AAIH,MAAa,gBAAgB,YAC3B,KACA,QACD,EAAE;AAIH,MAAa,sBAAsB,YACjC,KACA,cACD,EAAE;AAMH,MAAM,kBAAkB,YACtB,MACA,UACD,CAAC,SAAY,UAAU;CACtB,MAAM,EAAE,YAAY,qBAAqB;AAEzC,QAAO;EAAE,MAAM;EAAS,eAAe;EAAM,GAAG;EAAO;EACvD;AAWF,MAAM,kBAAkB,aACrB,EAAE,gBAAgB,QAAQ,GAAG,WAAW;AAGvC,QAAO,oBAFW,oBAAoB,cAAc,IAElC,GAAI,OAAQ;GAEhC,UACD,EAAE;AAIH,MAAaA,kBAA2C,EAAE,eAAe;CACvE,MAAM,EAAE,eAAe,qBAAqB;AAE5C,QAAO,aAAa,WAAW;;AAKjC,MAAaC,kBAA2C,EAAE,eAAe;CACvE,MAAM,EAAE,eAAe,qBAAqB;AAE5C,QAAO,aAAa,WAAW;;AAKjC,MAAaC,gBAAuC,EAAE,eAAe;CACnE,MAAM,EAAE,aAAa,qBAAqB;AAE1C,QAAO,WAAW,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flip.js","names":["flipVariants: Variants","from","to"],"sources":["../../../../src/components/flip/flip.tsx"],"sourcesContent":["\"use client\"\n\nimport type { Variants } from \"motion/react\"\nimport type { ReactNode } from \"react\"\nimport type { KeyframeIdent, Orientation, ThemeProps } from \"../../core\"\nimport type { HTMLMotionProps } from \"../motion\"\nimport type { FlipStyle } from \"./flip.style\"\nimport { useMemo, useRef, useState } from \"react\"\nimport { createSlotComponent } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { dataAttr, handlerAll, useSafeLayoutEffect } from \"../../utils\"\nimport { motion } from \"../motion\"\nimport { flipStyle } from \"./flip.style\"\n\nconst flipVariants: Variants = {\n enter: ({ ident, orientation, visible }) => ({\n [orientation === \"horizontal\" ? \"rotateY\" : \"rotateX\"]:\n ident === \"from\" ? (visible ? 180 : 0) : visible ? 0 : 180,\n }),\n exit: ({ ident, orientation }) => ({\n [orientation === \"horizontal\" ? \"rotateY\" : \"rotateX\"]:\n ident === \"from\" ? 0 : 180,\n }),\n}\n\ninterface Rect {\n height?: number\n width?: number\n}\n\nexport interface FlipProps\n extends Omit<HTMLMotionProps<\"button\">, \"onChange\">, ThemeProps<FlipStyle> {\n /**\n * Passing React elements to \"from\" is required.\n */\n from: ReactNode\n /**\n * Passing React elements to \"to\" is required.\n */\n to: ReactNode\n /**\n * You can set the initial state.\n *\n * @default 'from'\n */\n defaultValue?: KeyframeIdent\n /**\n *
|
|
1
|
+
{"version":3,"file":"flip.js","names":["flipVariants: Variants","from","to"],"sources":["../../../../src/components/flip/flip.tsx"],"sourcesContent":["\"use client\"\n\nimport type { Variants } from \"motion/react\"\nimport type { ReactNode } from \"react\"\nimport type { KeyframeIdent, Orientation, ThemeProps } from \"../../core\"\nimport type { HTMLMotionProps } from \"../motion\"\nimport type { FlipStyle } from \"./flip.style\"\nimport { useMemo, useRef, useState } from \"react\"\nimport { createSlotComponent } from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { dataAttr, handlerAll, useSafeLayoutEffect } from \"../../utils\"\nimport { motion } from \"../motion\"\nimport { flipStyle } from \"./flip.style\"\n\nconst flipVariants: Variants = {\n enter: ({ ident, orientation, visible }) => ({\n [orientation === \"horizontal\" ? \"rotateY\" : \"rotateX\"]:\n ident === \"from\" ? (visible ? 180 : 0) : visible ? 0 : 180,\n }),\n exit: ({ ident, orientation }) => ({\n [orientation === \"horizontal\" ? \"rotateY\" : \"rotateX\"]:\n ident === \"from\" ? 0 : 180,\n }),\n}\n\ninterface Rect {\n height?: number\n width?: number\n}\n\nexport interface FlipProps\n extends Omit<HTMLMotionProps<\"button\">, \"onChange\">, ThemeProps<FlipStyle> {\n /**\n * Passing React elements to \"from\" is required.\n */\n from: ReactNode\n /**\n * Passing React elements to \"to\" is required.\n */\n to: ReactNode\n /**\n * You can set the initial state.\n *\n * @default 'from'\n */\n defaultValue?: KeyframeIdent\n /**\n * The animation delay.\n *\n * @default 0\n */\n delay?: number\n /**\n * If `true`, the component is disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The animation duration.\n *\n * @default 0.4\n */\n duration?: number\n /**\n * The orientation of the flip effect. Determines whether the flip occurs horizontally or vertically.\n *\n * @default 'horizontal'\n */\n orientation?: Orientation\n /**\n * If `true`, the component is readonly.\n *\n * @default false\n */\n readOnly?: boolean\n /**\n * Use this when you want to control the animation from outside the component.\n */\n value?: KeyframeIdent\n /**\n * This is a callback function that is called when the animation state changes.\n */\n onChange?: (value: KeyframeIdent) => void\n}\n\nconst {\n PropsContext: FlipPropsContext,\n usePropsContext: useFlipPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<FlipProps, FlipStyle>(\"flip\", flipStyle)\n\nexport { FlipPropsContext, useFlipPropsContext }\n\n/**\n * `Flip` is an animation component that alternates between flipping two elements.\n *\n * @see https://yamada-ui.com/docs/components/flip\n */\nexport const Flip = withProvider(\n ({\n defaultValue = \"from\",\n delay = 0,\n disabled,\n duration = 0.4,\n from,\n orientation = \"horizontal\",\n readOnly,\n to,\n transition = {},\n value: valueProp,\n onChange,\n onClick: onClickProp,\n ...rest\n }) => {\n const [{ height, width }, setRect] = useState<Rect>({})\n const fromRef = useRef<HTMLDivElement | null>(null)\n const toRef = useRef<HTMLDivElement | null>(null)\n const [value, setValue] = useControllableState({\n defaultValue,\n value: valueProp,\n onChange,\n })\n const visible = value === \"to\"\n\n const style = useMemo(\n () => ({\n height: height ? `${height}px` : \"auto\",\n width: width ? `${width}px` : \"auto\",\n }),\n [width, height],\n )\n\n const onClick = () => {\n if (readOnly) return\n\n setValue((prev) => (prev === \"from\" ? \"to\" : \"from\"))\n }\n\n useSafeLayoutEffect(() => {\n const from = fromRef.current\n const to = toRef.current\n\n if (!from || !to) return\n\n if (\n from.offsetWidth !== to.offsetWidth ||\n from.offsetHeight !== to.offsetHeight\n ) {\n console.warn(\n `Flip: \"from\" element (width: ${from.offsetWidth}px, height: ${from.offsetHeight}px) does not match \"to\" element (width: ${to.offsetWidth}px, height: ${to.offsetHeight}px). Please ensure both elements have the same dimensions.`,\n )\n }\n\n setRect({ height: from.offsetHeight, width: from.offsetWidth })\n }, [fromRef, toRef])\n\n return (\n <motion.button\n type=\"button\"\n style={style}\n data-disabled={dataAttr(disabled)}\n data-orientation={orientation}\n data-readonly={dataAttr(readOnly)}\n data-value={value}\n disabled={disabled}\n onClick={handlerAll(onClickProp, onClick)}\n {...rest}\n >\n <FlipFrom\n ref={fromRef}\n custom={{ orientation, visible }}\n transition={{ delay, duration, ...transition }}\n >\n {from}\n </FlipFrom>\n\n <FlipTo\n ref={toRef}\n custom={{ orientation, visible }}\n transition={{ delay, duration, ...transition }}\n >\n {to}\n </FlipTo>\n </motion.button>\n )\n },\n \"root\",\n)()\n\ninterface FlipFromProps extends HTMLMotionProps<\"span\"> {}\n\nconst FlipFrom = withContext<\"span\", FlipFromProps>(\n ({ custom, ...rest }) => {\n return (\n <motion.span\n animate=\"enter\"\n custom={{ ident: \"from\", ...custom }}\n initial=\"exit\"\n variants={flipVariants}\n {...rest}\n />\n )\n },\n [\"item\", \"from\"],\n)()\n\ninterface FlipToProps extends HTMLMotionProps<\"span\"> {}\n\nconst FlipTo = withContext<\"span\", FlipToProps>(\n ({ custom, ...rest }) => {\n return (\n <motion.span\n animate=\"enter\"\n custom={{ ident: \"to\", ...custom }}\n initial=\"exit\"\n variants={flipVariants}\n {...rest}\n />\n )\n },\n [\"item\", \"to\"],\n)()\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAMA,eAAyB;CAC7B,QAAQ,EAAE,OAAO,aAAa,eAAe,GAC1C,gBAAgB,eAAe,YAAY,YAC1C,UAAU,SAAU,UAAU,MAAM,IAAK,UAAU,IAAI,KAC1D;CACD,OAAO,EAAE,OAAO,mBAAmB,GAChC,gBAAgB,eAAe,YAAY,YAC1C,UAAU,SAAS,IAAI,KAC1B;CACF;AA+DD,MAAM,EACJ,cAAc,kBACd,iBAAiB,qBACjB,aACA,iBACE,oBAA0C,QAAQ,UAAU;;;;;;AAShE,MAAa,OAAO,cACjB,EACC,eAAe,QACf,QAAQ,GACR,UACA,WAAW,IACX,MACA,cAAc,cACd,UACA,IACA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GACK;GAGpB,OACD,EAAE;AAIH,MAAM,WAAW,aACd,EAAE,QAAQ,GAAG,WAAW;AACvB,QACE,oBAAC,OAAO;EACN,SAAQ;EACR,QAAQ;GAAE,OAAO;GAAQ,GAAG;GAAQ;EACpC,SAAQ;EACR,UAAU;EACV,GAAI;GACJ;GAGN,CAAC,QAAQ,OAAO,CACjB,EAAE;AAIH,MAAM,SAAS,aACZ,EAAE,QAAQ,GAAG,WAAW;AACvB,QACE,oBAAC,OAAO;EACN,SAAQ;EACR,QAAQ;GAAE,OAAO;GAAM,GAAG;GAAQ;EAClC,SAAQ;EACR,UAAU;EACV,GAAI;GACJ;GAGN,CAAC,QAAQ,KAAK,CACf,EAAE"}
|
|
@@ -64,7 +64,7 @@ const useNativePopover = ({ autoUpdate, disabled = false, elements, flip, gutter
|
|
|
64
64
|
...props,
|
|
65
65
|
ref: mergeRefs(ref, anchorRef, refs.setReference)
|
|
66
66
|
}), [refs.setReference]);
|
|
67
|
-
const getPositionerProps = useCallback(getPopperProps, [getPopperProps]);
|
|
67
|
+
const getPositionerProps = useCallback((props) => getPopperProps(props), [getPopperProps]);
|
|
68
68
|
const getContentProps = useCallback(({ ref, "aria-describedby": ariaDescribedby, "aria-labelledby": ariaLabelledby, ...props } = {}) => {
|
|
69
69
|
const hasHeader = !!getDocument()?.getElementById(headerId);
|
|
70
70
|
const hasBody = !!getDocument()?.getElementById(bodyId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-native-popover.js","names":["getTriggerProps: PropGetter<\"button\">","getAnchorProps: PropGetter","getPositionerProps: PropGetter","getContentProps: PropGetter","getHeaderProps: PropGetter","getBodyProps: PropGetter","getFooterProps: PropGetter"],"sources":["../../../../src/components/native-popover/use-native-popover.tsx"],"sourcesContent":["\"use client\"\n\nimport type { MouseEvent, RefObject } from \"react\"\nimport type { Direction, PropGetter } from \"../../core\"\nimport type { UsePopperProps } from \"../../hooks/use-popper\"\nimport { useCallback, useId, useRef } from \"react\"\nimport { useEnvironment } from \"../../core\"\nimport { usePopper } from \"../../hooks/use-popper\"\nimport {\n ariaAttr,\n assignRef,\n cx,\n dataAttr,\n handlerAll,\n mergeRefs,\n} from \"../../utils\"\n\nexport interface UseNativePopoverProps extends UsePopperProps<\"button\"> {\n /**\n * If `true`, the popover will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The placement of the popper relative to its reference.\n *\n * @default 'end'\n */\n placement?: Direction\n /**\n * The mode of the popover.\n *\n * @default 'auto'\n */\n popover?: \"\" | \"auto\" | \"hint\" | \"manual\" | true\n /**\n * The target element ID for the popover trigger.\n * If not provided, a generated ID will be used.\n */\n popoverTarget?: string\n /**\n * The action for the popover target.\n *\n * @default 'toggle'\n */\n popoverTargetAction?: \"hide\" | \"show\" | \"toggle\"\n /**\n * Update the position of the floating element, re-rendering the component if required.\n */\n updateRef?: RefObject<() => void>\n}\n\nexport const useNativePopover = ({\n autoUpdate,\n disabled = false,\n elements,\n flip,\n gutter,\n matchWidth,\n middleware,\n offset,\n placement = \"end\",\n platform,\n popover = \"auto\",\n popoverTarget,\n popoverTargetAction = \"toggle\",\n preventOverflow,\n strategy,\n transform,\n updateRef,\n whileElementsMounted,\n}: UseNativePopoverProps = {}) => {\n const { getDocument } = useEnvironment()\n const headerId = useId()\n const bodyId = useId()\n const generatedContentId = useId()\n const contentId = popoverTarget ?? generatedContentId\n const anchorRef = useRef<HTMLElement>(null)\n const triggerRef = useRef<HTMLButtonElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const { refs, update, getPopperProps } = usePopper<\"button\">({\n autoUpdate,\n elements,\n flip,\n gutter,\n matchWidth,\n middleware,\n offset,\n placement,\n platform,\n preventOverflow,\n strategy,\n transform,\n whileElementsMounted,\n })\n\n assignRef(updateRef, update)\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLButtonElement>) => {\n if (!disabled) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [disabled],\n )\n\n const getTriggerProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => {\n return {\n type: \"button\",\n \"aria-controls\": contentId,\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-haspopup\": \"dialog\",\n popoverTarget: contentId,\n popoverTargetAction,\n role: \"button\",\n ...props,\n ref: mergeRefs(ref, triggerRef, (node) => {\n if (anchorRef.current == null) refs.setReference(node)\n }),\n onClick: handlerAll(props.onClick, onClick),\n }\n },\n [contentId, disabled, onClick, popoverTargetAction, refs],\n )\n\n const getAnchorProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n ...props,\n ref: mergeRefs(ref, anchorRef, refs.setReference),\n }),\n [refs.setReference],\n )\n\n const getPositionerProps: PropGetter = useCallback(
|
|
1
|
+
{"version":3,"file":"use-native-popover.js","names":["getTriggerProps: PropGetter<\"button\">","getAnchorProps: PropGetter","getPositionerProps: PropGetter","getContentProps: PropGetter","getHeaderProps: PropGetter","getBodyProps: PropGetter","getFooterProps: PropGetter"],"sources":["../../../../src/components/native-popover/use-native-popover.tsx"],"sourcesContent":["\"use client\"\n\nimport type { MouseEvent, RefObject } from \"react\"\nimport type { Direction, PropGetter } from \"../../core\"\nimport type { UsePopperProps } from \"../../hooks/use-popper\"\nimport { useCallback, useId, useRef } from \"react\"\nimport { useEnvironment } from \"../../core\"\nimport { usePopper } from \"../../hooks/use-popper\"\nimport {\n ariaAttr,\n assignRef,\n cx,\n dataAttr,\n handlerAll,\n mergeRefs,\n} from \"../../utils\"\n\nexport interface UseNativePopoverProps extends UsePopperProps<\"button\"> {\n /**\n * If `true`, the popover will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The placement of the popper relative to its reference.\n *\n * @default 'end'\n */\n placement?: Direction\n /**\n * The mode of the popover.\n *\n * @default 'auto'\n */\n popover?: \"\" | \"auto\" | \"hint\" | \"manual\" | true\n /**\n * The target element ID for the popover trigger.\n * If not provided, a generated ID will be used.\n */\n popoverTarget?: string\n /**\n * The action for the popover target.\n *\n * @default 'toggle'\n */\n popoverTargetAction?: \"hide\" | \"show\" | \"toggle\"\n /**\n * Update the position of the floating element, re-rendering the component if required.\n */\n updateRef?: RefObject<() => void>\n}\n\nexport const useNativePopover = ({\n autoUpdate,\n disabled = false,\n elements,\n flip,\n gutter,\n matchWidth,\n middleware,\n offset,\n placement = \"end\",\n platform,\n popover = \"auto\",\n popoverTarget,\n popoverTargetAction = \"toggle\",\n preventOverflow,\n strategy,\n transform,\n updateRef,\n whileElementsMounted,\n}: UseNativePopoverProps = {}) => {\n const { getDocument } = useEnvironment()\n const headerId = useId()\n const bodyId = useId()\n const generatedContentId = useId()\n const contentId = popoverTarget ?? generatedContentId\n const anchorRef = useRef<HTMLElement>(null)\n const triggerRef = useRef<HTMLButtonElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const { refs, update, getPopperProps } = usePopper<\"button\">({\n autoUpdate,\n elements,\n flip,\n gutter,\n matchWidth,\n middleware,\n offset,\n placement,\n platform,\n preventOverflow,\n strategy,\n transform,\n whileElementsMounted,\n })\n\n assignRef(updateRef, update)\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLButtonElement>) => {\n if (!disabled) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [disabled],\n )\n\n const getTriggerProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => {\n return {\n type: \"button\",\n \"aria-controls\": contentId,\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-haspopup\": \"dialog\",\n popoverTarget: contentId,\n popoverTargetAction,\n role: \"button\",\n ...props,\n ref: mergeRefs(ref, triggerRef, (node) => {\n if (anchorRef.current == null) refs.setReference(node)\n }),\n onClick: handlerAll(props.onClick, onClick),\n }\n },\n [contentId, disabled, onClick, popoverTargetAction, refs],\n )\n\n const getAnchorProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n ...props,\n ref: mergeRefs(ref, anchorRef, refs.setReference),\n }),\n [refs.setReference],\n )\n\n const getPositionerProps: PropGetter = useCallback(\n (props) => getPopperProps(props),\n [getPopperProps],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({\n ref,\n \"aria-describedby\": ariaDescribedby,\n \"aria-labelledby\": ariaLabelledby,\n ...props\n } = {}) => {\n const hasHeader = !!getDocument()?.getElementById(headerId)\n const hasBody = !!getDocument()?.getElementById(bodyId)\n\n return {\n id: contentId,\n \"aria-describedby\": cx(ariaDescribedby, hasBody ? bodyId : undefined),\n \"aria-labelledby\": cx(ariaLabelledby, hasHeader ? headerId : undefined),\n \"data-popup\": dataAttr(true),\n popover: popover === true ? \"\" : popover,\n role: \"dialog\",\n tabIndex: -1,\n ...props,\n ref: mergeRefs(ref, contentRef),\n }\n },\n [getDocument, headerId, bodyId, contentId, popover],\n )\n\n const getHeaderProps: PropGetter = useCallback(\n (props) => ({ id: headerId, ...props }),\n [headerId],\n )\n\n const getBodyProps: PropGetter = useCallback(\n (props) => ({ id: bodyId, ...props }),\n [bodyId],\n )\n\n const getFooterProps: PropGetter = useCallback((props) => ({ ...props }), [])\n\n const getCloseTriggerProps: PropGetter<\"button\"> = useCallback(\n (props = {}) => {\n return {\n popoverTarget: contentId,\n popoverTargetAction: \"hide\",\n ...props,\n }\n },\n [contentId],\n )\n\n return {\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n }\n}\n\nexport type UseNativePopoverReturn = ReturnType<typeof useNativePopover>\n"],"mappings":";;;;;;;;;;AAqDA,MAAa,oBAAoB,EAC/B,YACA,WAAW,OACX,UACA,MACA,QACA,YACA,YACA,QACA,YAAY,OACZ,UACA,UAAU,QACV,eACA,sBAAsB,UACtB,iBACA,UACA,WACA,WACA,yBACyB,EAAE,KAAK;CAChC,MAAM,EAAE,gBAAgB,gBAAgB;CACxC,MAAM,WAAW,OAAO;CACxB,MAAM,SAAS,OAAO;CACtB,MAAM,qBAAqB,OAAO;CAClC,MAAM,YAAY,iBAAiB;CACnC,MAAM,YAA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0CAAuB,KAAK;GAC5B,SAAS,YAAY,OAAO,KAAK;GACjC,MAAM;GACN,UAAU;GACV,GAAG;GACH,KAAK,UAAU,KAAK,WAAW;GAChC;IAEH;EAAC;EAAa;EAAU;EAAQ;EAAW;EAAQ,CACpD;CAED,MAAMC,iBAA6B,aAChC,WAAW;EAAE,IAAI;EAAU,GAAG;EAAO,GACtC,CAAC,SAAS,CACX;CAED,MAAMC,eAA2B,aAC9B,WAAW;EAAE,IAAI;EAAQ,GAAG;EAAO,GACpC,CAAC,OAAO,CACT;CAED,MAAMC,iBAA6B,aAAa,WAAW,EAAE,GAAG,OAAO,GAAG,EAAE,CAAC;AAa7E,QAAO;EACL;EACA;EACA,sBAdiD,aAChD,QAAQ,EAAE,KAAK;AACd,UAAO;IACL,eAAe;IACf,qBAAqB;IACrB,GAAG;IACJ;KAEH,CAAC,UAAU,CACZ;EAMC;EACA;EACA;EACA;EACA;EACD"}
|
|
@@ -140,7 +140,7 @@ const usePopover = ({ autoFocus = true, autoUpdate, modal = false, blockScrollOn
|
|
|
140
140
|
...props,
|
|
141
141
|
ref: mergeRefs(ref, anchorRef, refs.setReference)
|
|
142
142
|
}), [refs.setReference]);
|
|
143
|
-
const getPositionerProps = useCallback(getPopperProps, [getPopperProps]);
|
|
143
|
+
const getPositionerProps = useCallback((props) => getPopperProps(props), [getPopperProps]);
|
|
144
144
|
const getContentProps = useCallback(({ ref, ...props } = {}) => ({
|
|
145
145
|
id: contentId,
|
|
146
146
|
"aria-hidden": !open,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-popover.js","names":["getTriggerProps: PropGetter<\"button\">","getAnchorProps: PropGetter","getPositionerProps: PropGetter","getContentProps: PropGetter","getHeaderProps: PropGetter","getBodyProps: PropGetter","getFooterProps: PropGetter","popoverProps: (\n | keyof PopupAnimationProps\n | keyof UsePopoverProps\n)[]"],"sources":["../../../../src/components/popover/use-popover.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FocusEvent, KeyboardEvent, RefObject } from \"react\"\nimport type { Direction, PropGetter } from \"../../core\"\nimport type { UseDisclosureProps } from \"../../hooks/use-disclosure\"\nimport type { UsePopperProps } from \"../../hooks/use-popper\"\nimport type { Dict } from \"../../utils\"\nimport type { PopupAnimationProps } from \"./popover\"\nimport { useCallback, useEffect, useId, useRef } from \"react\"\nimport { useEnvironment, useSplitProps } from \"../../core\"\nimport { useDisclosure } from \"../../hooks/use-disclosure\"\nimport { useEventListener } from \"../../hooks/use-event-listener\"\nimport { useFocusOnShow } from \"../../hooks/use-focus\"\nimport { useOutsideClick } from \"../../hooks/use-outside-click\"\nimport { popperProps, usePopper } from \"../../hooks/use-popper\"\nimport {\n ariaAttr,\n assignRef,\n contains,\n dataAttr,\n focusTransfer,\n focusTrap,\n getEventRelatedTarget,\n handlerAll,\n mergeRefs,\n runKeyAction,\n scrollLock,\n setAttribute,\n useSafeLayoutEffect,\n useUnmountEffect,\n} from \"../../utils\"\n\nexport interface UsePopoverProps\n extends Omit<UseDisclosureProps, \"timing\">, UsePopperProps<\"button\"> {\n /**\n * If `true`, focus will be transferred to the first interactive element when the popover opens.\n *\n * @default true\n */\n autoFocus?: boolean\n /**\n * If `true`, scrolling will be disabled on the `body` when the modal opens.\n *\n * @default false\n */\n blockScrollOnMount?: boolean\n /**\n * If `true`, the popover will close when you blur out it by clicking outside or tabbing out.\n *\n * @default true\n */\n closeOnBlur?: boolean\n /**\n * If `true`, the popover will hide on pressing Esc key.\n *\n * @default true\n */\n closeOnEsc?: boolean\n /**\n * If `true`, the popover will hide on scroll.\n *\n * @default false\n */\n closeOnScroll?: boolean\n /**\n * If `true`, the popover will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The `ref` of the element that should receive focus when the popover opens.\n */\n initialFocusRef?: RefObject<HTMLElement | null>\n /**\n * If `true`, the popover will be modal.\n *\n * - scrolling is blocked.\n * - focus is trapped within the popover.\n *\n * @default false\n */\n modal?: boolean\n /**\n * If `true`, the popover will be opened when click on the field.\n *\n * @default true\n */\n openOnClick?: boolean\n /**\n * The placement of the popper relative to its reference.\n *\n * @default 'end'\n */\n placement?: Direction\n /**\n * If `true`, the focus will be transferred to the popover content when the tab key is pressed.\n *\n * @default true\n */\n transferFocus?: boolean\n /**\n * Update the position of the floating element, re-rendering the component if required.\n */\n updateRef?: RefObject<() => void>\n}\n\nexport const usePopover = ({\n autoFocus = true,\n autoUpdate,\n modal = false,\n blockScrollOnMount = modal,\n closeOnBlur = true,\n closeOnEsc = true,\n closeOnScroll,\n defaultOpen,\n disabled,\n elements,\n flip,\n gutter,\n initialFocusRef,\n matchWidth,\n middleware,\n offset,\n open: openProp,\n openOnClick = true,\n placement = \"end\",\n platform,\n preventOverflow,\n strategy,\n transferFocus = true,\n transform,\n updateRef,\n whileElementsMounted,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n}: UsePopoverProps = {}) => {\n const { getDocument } = useEnvironment()\n const headerId = useId()\n const bodyId = useId()\n const contentId = useId()\n const anchorRef = useRef<HTMLElement>(null)\n const triggerRef = useRef<HTMLButtonElement>(null)\n const contentRef = useRef<HTMLElement>(null)\n const openTimeout = useRef<NodeJS.Timeout>(undefined)\n const closeTimeout = useRef<NodeJS.Timeout>(undefined)\n const { open, onClose, onOpen } = useDisclosure({\n defaultOpen,\n open: openProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n })\n const { refs, update, getPopperProps } = usePopper<\"button\">({\n autoUpdate,\n elements,\n flip,\n gutter,\n matchWidth,\n middleware,\n offset,\n open,\n placement,\n platform,\n preventOverflow,\n strategy,\n transform,\n whileElementsMounted,\n })\n\n assignRef(updateRef, update)\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLElement>) => {\n runKeyAction(ev, {\n Escape: () => {\n if (!closeOnEsc) return\n\n onClose()\n\n triggerRef.current?.focus()\n },\n })\n },\n [closeOnEsc, onClose],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLDivElement>) => {\n const relatedTarget = getEventRelatedTarget(ev)\n const popup = relatedTarget?.hasAttribute(\"data-popup\")\n\n if (contains(triggerRef.current, relatedTarget)) return\n if (contains(contentRef.current, relatedTarget)) return\n if (contains(contentRef.current, ev.target) && popup) return\n\n if (closeOnBlur) onClose()\n },\n [closeOnBlur, onClose],\n )\n\n useEventListener(getDocument(), \"scroll\", () => {\n if (open && closeOnScroll) onClose()\n })\n\n useFocusOnShow(contentRef, {\n focusTarget: initialFocusRef,\n shouldFocus: autoFocus,\n visible: open,\n })\n\n useOutsideClick({\n ref: [contentRef, triggerRef],\n enabled: open && closeOnBlur,\n handler: onClose,\n })\n\n useSafeLayoutEffect(() => {\n const el = contentRef.current\n const hasHeader = !!getDocument()?.getElementById(headerId)\n const hasBody = !!getDocument()?.getElementById(bodyId)\n\n if (el && hasHeader) setAttribute(el, \"aria-labelledby\", headerId)\n if (el && hasBody) setAttribute(el, \"aria-describedby\", bodyId)\n }, [open, headerId, bodyId])\n\n useEffect(() => {\n if (!open || !modal) return\n\n return focusTrap(contentRef.current)\n }, [open, modal])\n\n useEffect(() => {\n if (!open || !blockScrollOnMount) return\n\n return scrollLock(contentRef.current)\n }, [open, modal, blockScrollOnMount])\n\n useEffect(() => {\n if (!open || modal || !transferFocus) return\n\n return focusTransfer(contentRef.current, triggerRef.current)\n }, [open, modal, transferFocus])\n\n useUnmountEffect(() => {\n clearTimeout(openTimeout.current)\n clearTimeout(closeTimeout.current)\n })\n\n const getTriggerProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n \"aria-controls\": open ? contentId : undefined,\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-expanded\": open,\n \"aria-haspopup\": \"dialog\",\n role: \"button\",\n ...props,\n ref: mergeRefs(ref, triggerRef, (node) => {\n if (anchorRef.current == null) refs.setReference(node)\n }),\n onBlur: handlerAll(props.onBlur, (ev) =>\n !contains(contentRef.current, getEventRelatedTarget(ev)) && closeOnBlur\n ? onClose()\n : void 0,\n ),\n onClick: handlerAll(\n props.onClick,\n !open ? (!disabled && openOnClick ? onOpen : undefined) : onClose,\n ),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [\n closeOnBlur,\n contentId,\n disabled,\n onClose,\n onKeyDown,\n onOpen,\n open,\n openOnClick,\n refs,\n ],\n )\n\n const getAnchorProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n ...props,\n ref: mergeRefs(ref, anchorRef, refs.setReference),\n }),\n [refs.setReference],\n )\n\n const getPositionerProps: PropGetter = useCallback(getPopperProps, [\n getPopperProps,\n ])\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n id: contentId,\n \"aria-hidden\": !open,\n \"aria-modal\": modal ? \"true\" : undefined,\n \"data-close\": dataAttr(!open),\n \"data-open\": dataAttr(open),\n \"data-popup\": dataAttr(true),\n role: \"dialog\",\n tabIndex: -1,\n ...props,\n ref: mergeRefs(ref, contentRef),\n onBlur: handlerAll(props.onBlur, onBlur),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [contentId, open, modal, onBlur, onKeyDown],\n )\n\n const getHeaderProps: PropGetter = useCallback(\n (props) => ({ id: headerId, ...props }),\n [headerId],\n )\n\n const getBodyProps: PropGetter = useCallback(\n (props) => ({ id: bodyId, ...props }),\n [bodyId],\n )\n\n const getFooterProps: PropGetter = useCallback((props) => ({ ...props }), [])\n\n const getCloseTriggerProps: PropGetter<\"button\"> = useCallback(\n (props = {}) => ({\n ...props,\n onClick: handlerAll(props.onClick, () => {\n onClose()\n\n triggerRef.current?.focus()\n }),\n }),\n [onClose],\n )\n\n return {\n open,\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n onClose,\n onOpen,\n }\n}\n\nexport type UsePopoverReturn = ReturnType<typeof usePopover>\n\nexport const popoverProps: (\n | keyof PopupAnimationProps\n | keyof UsePopoverProps\n)[] = [\n ...popperProps,\n \"autoFocus\",\n \"transferFocus\",\n \"blockScrollOnMount\",\n \"closeOnBlur\",\n \"closeOnEsc\",\n \"closeOnScroll\",\n \"openOnClick\",\n \"disabled\",\n \"initialFocusRef\",\n \"modal\",\n \"updateRef\",\n \"defaultOpen\",\n \"onOpen\",\n \"onClose\",\n \"animationScheme\",\n \"duration\",\n]\n\nexport const usePopoverProps = <\n Y extends Dict = Dict,\n M extends keyof PopupAnimationProps | keyof UsePopoverProps =\n | keyof PopupAnimationProps\n | keyof UsePopoverProps,\n>(\n props: Y,\n omitKeys?: M[],\n) => {\n return useSplitProps(\n props,\n popoverProps.filter((key) => !omitKeys?.includes(key as M)),\n ) as unknown as [\n keyof PopupAnimationProps | keyof UsePopoverProps extends M\n ? PopupAnimationProps & UsePopoverProps\n : Omit<PopupAnimationProps & UsePopoverProps, M>,\n Omit<\n Y,\n keyof PopupAnimationProps | keyof UsePopoverProps extends M\n ? keyof PopupAnimationProps | keyof UsePopoverProps\n : Exclude<keyof PopupAnimationProps | keyof UsePopoverProps, M>\n >,\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA2GA,MAAa,cAAc,EACzB,YAAY,MACZ,YACA,QAAQ,OACR,qBAAqB,OACrB,cAAc,MACd,aAAa,MACb,eACA,aACA,UACA,UACA,MACA,QACA,iBACA,YACA,YACA,QACA,MAAM,UACN,cAAc,MACd,YAAY,OACZ,UACA,iBACA,UACA,gBAAgB,MAChB,WACA,WACA,sBACA,SAAS,aACT,QAAQ,eACW,EAAE,KAAK;CAC1B,MAAM,EAAE,gBAAgB,gBAAgB;CACxC,MAAM,WAAW,OAAO;CACxB,MAAM,SAAS,OAAO;CACtB,MAAM,YAAY,OAAO;CACzB,MAAM,YAAY,OAAoB,KAAK;CAC3C,MAAM,aAAa,OAA0B,KAAK;CAClD,MAAM,aAAa,OAAoB,KAAK;CAC5C,MAAM,cAAc,OAAuB,OAAU;CACrD,MAAM,eAAe,OAAuB,OAAU;CACtD,MAAM,EAAE,MAAM,SA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AS;EAC/B,0CAAuB,CAAC,KAAK;EAC7B,yCAAsB,KAAK;EAC3B,0CAAuB,KAAK;EAC5B,MAAM;EACN,UAAU;EACV,GAAG;EACH,KAAK,UAAU,KAAK,WAAW;EAC/B,sCAAmB,MAAM,QAAQ,OAAO;EACxC,yCAAsB,MAAM,WAAW,UAAU;EAClD,GACD;EAAC;EAAW;EAAM;EAAO;EAAQ;EAAU,CAC5C;CAED,MAAMC,iBAA6B,aAChC,WAAW;EAAE,IAAI;EAAU,GAAG;EAAO,GACtC,CAAC,SAAS,CACX;CAED,MAAMC,eAA2B,aAC9B,WAAW;EAAE,IAAI;EAAQ,GAAG;EAAO,GACpC,CAAC,OAAO,CACT;CAED,MAAMC,iBAA6B,aAAa,WAAW,EAAE,GAAG,OAAO,GAAG,EAAE,CAAC;AAc7E,QAAO;EACL;EACA;EACA;EACA,sBAhBiD,aAChD,QAAQ,EAAE,MAAM;GACf,GAAG;GACH,uCAAoB,MAAM,eAAe;AACvC,aAAS;AAET,eAAW,SAAS,OAAO;KAC3B;GACH,GACD,CAAC,QAAQ,CACV;EAOC;EACA;EACA;EACA;EACA;EACA;EACA;EACD;;AAKH,MAAaC,eAGP;CACJ,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,mBAMX,OACA,aACG;AACH,QAAO,cACL,OACA,aAAa,QAAQ,QAAQ,CAAC,UAAU,SAAS,IAAS,CAAC,CAC5D"}
|
|
1
|
+
{"version":3,"file":"use-popover.js","names":["getTriggerProps: PropGetter<\"button\">","getAnchorProps: PropGetter","getPositionerProps: PropGetter","getContentProps: PropGetter","getHeaderProps: PropGetter","getBodyProps: PropGetter","getFooterProps: PropGetter","popoverProps: (\n | keyof PopupAnimationProps\n | keyof UsePopoverProps\n)[]"],"sources":["../../../../src/components/popover/use-popover.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FocusEvent, KeyboardEvent, RefObject } from \"react\"\nimport type { Direction, PropGetter } from \"../../core\"\nimport type { UseDisclosureProps } from \"../../hooks/use-disclosure\"\nimport type { UsePopperProps } from \"../../hooks/use-popper\"\nimport type { Dict } from \"../../utils\"\nimport type { PopupAnimationProps } from \"./popover\"\nimport { useCallback, useEffect, useId, useRef } from \"react\"\nimport { useEnvironment, useSplitProps } from \"../../core\"\nimport { useDisclosure } from \"../../hooks/use-disclosure\"\nimport { useEventListener } from \"../../hooks/use-event-listener\"\nimport { useFocusOnShow } from \"../../hooks/use-focus\"\nimport { useOutsideClick } from \"../../hooks/use-outside-click\"\nimport { popperProps, usePopper } from \"../../hooks/use-popper\"\nimport {\n ariaAttr,\n assignRef,\n contains,\n dataAttr,\n focusTransfer,\n focusTrap,\n getEventRelatedTarget,\n handlerAll,\n mergeRefs,\n runKeyAction,\n scrollLock,\n setAttribute,\n useSafeLayoutEffect,\n useUnmountEffect,\n} from \"../../utils\"\n\nexport interface UsePopoverProps\n extends Omit<UseDisclosureProps, \"timing\">, UsePopperProps<\"button\"> {\n /**\n * If `true`, focus will be transferred to the first interactive element when the popover opens.\n *\n * @default true\n */\n autoFocus?: boolean\n /**\n * If `true`, scrolling will be disabled on the `body` when the modal opens.\n *\n * @default false\n */\n blockScrollOnMount?: boolean\n /**\n * If `true`, the popover will close when you blur out it by clicking outside or tabbing out.\n *\n * @default true\n */\n closeOnBlur?: boolean\n /**\n * If `true`, the popover will hide on pressing Esc key.\n *\n * @default true\n */\n closeOnEsc?: boolean\n /**\n * If `true`, the popover will hide on scroll.\n *\n * @default false\n */\n closeOnScroll?: boolean\n /**\n * If `true`, the popover will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The `ref` of the element that should receive focus when the popover opens.\n */\n initialFocusRef?: RefObject<HTMLElement | null>\n /**\n * If `true`, the popover will be modal.\n *\n * - scrolling is blocked.\n * - focus is trapped within the popover.\n *\n * @default false\n */\n modal?: boolean\n /**\n * If `true`, the popover will be opened when click on the field.\n *\n * @default true\n */\n openOnClick?: boolean\n /**\n * The placement of the popper relative to its reference.\n *\n * @default 'end'\n */\n placement?: Direction\n /**\n * If `true`, the focus will be transferred to the popover content when the tab key is pressed.\n *\n * @default true\n */\n transferFocus?: boolean\n /**\n * Update the position of the floating element, re-rendering the component if required.\n */\n updateRef?: RefObject<() => void>\n}\n\nexport const usePopover = ({\n autoFocus = true,\n autoUpdate,\n modal = false,\n blockScrollOnMount = modal,\n closeOnBlur = true,\n closeOnEsc = true,\n closeOnScroll,\n defaultOpen,\n disabled,\n elements,\n flip,\n gutter,\n initialFocusRef,\n matchWidth,\n middleware,\n offset,\n open: openProp,\n openOnClick = true,\n placement = \"end\",\n platform,\n preventOverflow,\n strategy,\n transferFocus = true,\n transform,\n updateRef,\n whileElementsMounted,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n}: UsePopoverProps = {}) => {\n const { getDocument } = useEnvironment()\n const headerId = useId()\n const bodyId = useId()\n const contentId = useId()\n const anchorRef = useRef<HTMLElement>(null)\n const triggerRef = useRef<HTMLButtonElement>(null)\n const contentRef = useRef<HTMLElement>(null)\n const openTimeout = useRef<NodeJS.Timeout>(undefined)\n const closeTimeout = useRef<NodeJS.Timeout>(undefined)\n const { open, onClose, onOpen } = useDisclosure({\n defaultOpen,\n open: openProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n })\n const { refs, update, getPopperProps } = usePopper<\"button\">({\n autoUpdate,\n elements,\n flip,\n gutter,\n matchWidth,\n middleware,\n offset,\n open,\n placement,\n platform,\n preventOverflow,\n strategy,\n transform,\n whileElementsMounted,\n })\n\n assignRef(updateRef, update)\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLElement>) => {\n runKeyAction(ev, {\n Escape: () => {\n if (!closeOnEsc) return\n\n onClose()\n\n triggerRef.current?.focus()\n },\n })\n },\n [closeOnEsc, onClose],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLDivElement>) => {\n const relatedTarget = getEventRelatedTarget(ev)\n const popup = relatedTarget?.hasAttribute(\"data-popup\")\n\n if (contains(triggerRef.current, relatedTarget)) return\n if (contains(contentRef.current, relatedTarget)) return\n if (contains(contentRef.current, ev.target) && popup) return\n\n if (closeOnBlur) onClose()\n },\n [closeOnBlur, onClose],\n )\n\n useEventListener(getDocument(), \"scroll\", () => {\n if (open && closeOnScroll) onClose()\n })\n\n useFocusOnShow(contentRef, {\n focusTarget: initialFocusRef,\n shouldFocus: autoFocus,\n visible: open,\n })\n\n useOutsideClick({\n ref: [contentRef, triggerRef],\n enabled: open && closeOnBlur,\n handler: onClose,\n })\n\n useSafeLayoutEffect(() => {\n const el = contentRef.current\n const hasHeader = !!getDocument()?.getElementById(headerId)\n const hasBody = !!getDocument()?.getElementById(bodyId)\n\n if (el && hasHeader) setAttribute(el, \"aria-labelledby\", headerId)\n if (el && hasBody) setAttribute(el, \"aria-describedby\", bodyId)\n }, [open, headerId, bodyId])\n\n useEffect(() => {\n if (!open || !modal) return\n\n return focusTrap(contentRef.current)\n }, [open, modal])\n\n useEffect(() => {\n if (!open || !blockScrollOnMount) return\n\n return scrollLock(contentRef.current)\n }, [open, modal, blockScrollOnMount])\n\n useEffect(() => {\n if (!open || modal || !transferFocus) return\n\n return focusTransfer(contentRef.current, triggerRef.current)\n }, [open, modal, transferFocus])\n\n useUnmountEffect(() => {\n clearTimeout(openTimeout.current)\n clearTimeout(closeTimeout.current)\n })\n\n const getTriggerProps: PropGetter<\"button\"> = useCallback(\n ({ ref, ...props } = {}) => ({\n \"aria-controls\": open ? contentId : undefined,\n \"aria-disabled\": ariaAttr(disabled),\n \"aria-expanded\": open,\n \"aria-haspopup\": \"dialog\",\n role: \"button\",\n ...props,\n ref: mergeRefs(ref, triggerRef, (node) => {\n if (anchorRef.current == null) refs.setReference(node)\n }),\n onBlur: handlerAll(props.onBlur, (ev) =>\n !contains(contentRef.current, getEventRelatedTarget(ev)) && closeOnBlur\n ? onClose()\n : void 0,\n ),\n onClick: handlerAll(\n props.onClick,\n !open ? (!disabled && openOnClick ? onOpen : undefined) : onClose,\n ),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [\n closeOnBlur,\n contentId,\n disabled,\n onClose,\n onKeyDown,\n onOpen,\n open,\n openOnClick,\n refs,\n ],\n )\n\n const getAnchorProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n ...props,\n ref: mergeRefs(ref, anchorRef, refs.setReference),\n }),\n [refs.setReference],\n )\n\n const getPositionerProps: PropGetter = useCallback(\n (props) => getPopperProps(props),\n [getPopperProps],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n id: contentId,\n \"aria-hidden\": !open,\n \"aria-modal\": modal ? \"true\" : undefined,\n \"data-close\": dataAttr(!open),\n \"data-open\": dataAttr(open),\n \"data-popup\": dataAttr(true),\n role: \"dialog\",\n tabIndex: -1,\n ...props,\n ref: mergeRefs(ref, contentRef),\n onBlur: handlerAll(props.onBlur, onBlur),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n }),\n [contentId, open, modal, onBlur, onKeyDown],\n )\n\n const getHeaderProps: PropGetter = useCallback(\n (props) => ({ id: headerId, ...props }),\n [headerId],\n )\n\n const getBodyProps: PropGetter = useCallback(\n (props) => ({ id: bodyId, ...props }),\n [bodyId],\n )\n\n const getFooterProps: PropGetter = useCallback((props) => ({ ...props }), [])\n\n const getCloseTriggerProps: PropGetter<\"button\"> = useCallback(\n (props = {}) => ({\n ...props,\n onClick: handlerAll(props.onClick, () => {\n onClose()\n\n triggerRef.current?.focus()\n }),\n }),\n [onClose],\n )\n\n return {\n open,\n getAnchorProps,\n getBodyProps,\n getCloseTriggerProps,\n getContentProps,\n getFooterProps,\n getHeaderProps,\n getPositionerProps,\n getTriggerProps,\n onClose,\n onOpen,\n }\n}\n\nexport type UsePopoverReturn = ReturnType<typeof usePopover>\n\nexport const popoverProps: (\n | keyof PopupAnimationProps\n | keyof UsePopoverProps\n)[] = [\n ...popperProps,\n \"autoFocus\",\n \"transferFocus\",\n \"blockScrollOnMount\",\n \"closeOnBlur\",\n \"closeOnEsc\",\n \"closeOnScroll\",\n \"openOnClick\",\n \"disabled\",\n \"initialFocusRef\",\n \"modal\",\n \"updateRef\",\n \"defaultOpen\",\n \"onOpen\",\n \"onClose\",\n \"animationScheme\",\n \"duration\",\n]\n\nexport const usePopoverProps = <\n Y extends Dict = Dict,\n M extends keyof PopupAnimationProps | keyof UsePopoverProps =\n | keyof PopupAnimationProps\n | keyof UsePopoverProps,\n>(\n props: Y,\n omitKeys?: M[],\n) => {\n return useSplitProps(\n props,\n popoverProps.filter((key) => !omitKeys?.includes(key as M)),\n ) as unknown as [\n keyof PopupAnimationProps | keyof UsePopoverProps extends M\n ? PopupAnimationProps & UsePopoverProps\n : Omit<PopupAnimationProps & UsePopoverProps, M>,\n Omit<\n Y,\n keyof PopupAnimationProps | keyof UsePopoverProps extends M\n ? keyof PopupAnimationProps | keyof UsePopoverProps\n : Exclude<keyof PopupAnimationProps | keyof UsePopoverProps, M>\n >,\n ]\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA2GA,MAAa,cAAc,EACzB,YAAY,MACZ,YACA,QAAQ,OACR,qBAAqB,OACrB,cAAc,MACd,aAAa,MACb,eACA,aACA,UACA,UACA,MACA,QACA,iBACA,YACA,YACA,QACA,MAAM,UACN,cAAc,MACd,YAAY,OACZ,UACA,iBACA,UACA,gBAAgB,MAChB,WACA,WACA,sBACA,SAAS,aACT,QAAQ,eACW,EAAE,KAAK;CAC1B,MAAM,EAAE,gBAAgB,gBAAgB;CACxC,MAAM,WAAW,OAAO;CACxB,MAAM,SAAS,OAAO;CACtB,MAAM,YAAY,OAAO;CACzB,MAAM,YAAY,OAAoB,KAAK;CAC3C,MAAM,aAAa,OAA0B,KAAK;CAClD,MAAM,aAAa,OAAoB,KAAK;CAC5C,MAAM,cAAc,OAAuB,OAAU;CACrD,MAAM,eAAe,OAAuB,OAAU;CACtD,MAAM,EAAE,MAAM,SAAS,WAAW,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Q,SAAS;EAC/B,0CAAuB,CAAC,KAAK;EAC7B,yCAAsB,KAAK;EAC3B,0CAAuB,KAAK;EAC5B,MAAM;EACN,UAAU;EACV,GAAG;EACH,KAAK,UAAU,KAAK,WAAW;EAC/B,sCAAmB,MAAM,QAAQ,OAAO;EACxC,yCAAsB,MAAM,WAAW,UAAU;EAClD,GACD;EAAC;EAAW;EAAM;EAAO;EAAQ;EAAU,CAC5C;CAED,MAAMC,iBAA6B,aAChC,WAAW;EAAE,IAAI;EAAU,GAAG;EAAO,GACtC,CAAC,SAAS,CACX;CAED,MAAMC,eAA2B,aAC9B,WAAW;EAAE,IAAI;EAAQ,GAAG;EAAO,GACpC,CAAC,OAAO,CACT;CAED,MAAMC,iBAA6B,aAAa,WAAW,EAAE,GAAG,OAAO,GAAG,EAAE,CAAC;AAc7E,QAAO;EACL;EACA;EACA;EACA,sBAhBiD,aAChD,QAAQ,EAAE,MAAM;GACf,GAAG;GACH,uCAAoB,MAAM,eAAe;AACvC,aAAS;AAET,eAAW,SAAS,OAAO;KAC3B;GACH,GACD,CAAC,QAAQ,CACV;EAOC;EACA;EACA;EACA;EACA;EACA;EACA;EACD;;AAKH,MAAaC,eAGP;CACJ,GAAG;CACH;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,MAAa,mBAMX,OACA,aACG;AACH,QAAO,cACL,OACA,aAAa,QAAQ,QAAQ,CAAC,UAAU,SAAS,IAAS,CAAC,CAC5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rotate.js","names":["motion"],"sources":["../../../../src/components/rotate/rotate.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type { KeyframeIdent, ThemeProps } from \"../../core\"\nimport type { HTMLMotionProps } from \"../motion\"\nimport type { RotateStyle } from \"./rotate.style\"\nimport { useAnimation } from \"motion/react\"\nimport { useCallback } from \"react\"\nimport {\n createComponent,\n useInjectVarsIntoCss,\n useInjectVarsIntoProps,\n} from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { dataAttr, handlerAll } from \"../../utils\"\nimport { motion } from \"../motion\"\nimport { rotateStyle } from \"./rotate.style\"\n\nexport interface RotateProps\n extends\n Omit<HTMLMotionProps<\"button\">, \"onChange\" | \"rotate\">,\n ThemeProps<RotateStyle> {\n /**\n * Passing React elements to \"from\" is required.\n */\n from: ReactNode\n /**\n * Passing React elements to \"to\" is required.\n */\n to: ReactNode\n /**\n * You can set the initial state.\n *\n * @default 'from'\n */\n defaultValue?: KeyframeIdent\n /**\n *
|
|
1
|
+
{"version":3,"file":"rotate.js","names":["motion"],"sources":["../../../../src/components/rotate/rotate.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type { KeyframeIdent, ThemeProps } from \"../../core\"\nimport type { HTMLMotionProps } from \"../motion\"\nimport type { RotateStyle } from \"./rotate.style\"\nimport { useAnimation } from \"motion/react\"\nimport { useCallback } from \"react\"\nimport {\n createComponent,\n useInjectVarsIntoCss,\n useInjectVarsIntoProps,\n} from \"../../core\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { dataAttr, handlerAll } from \"../../utils\"\nimport { motion } from \"../motion\"\nimport { rotateStyle } from \"./rotate.style\"\n\nexport interface RotateProps\n extends\n Omit<HTMLMotionProps<\"button\">, \"onChange\" | \"rotate\">,\n ThemeProps<RotateStyle> {\n /**\n * Passing React elements to \"from\" is required.\n */\n from: ReactNode\n /**\n * Passing React elements to \"to\" is required.\n */\n to: ReactNode\n /**\n * You can set the initial state.\n *\n * @default 'from'\n */\n defaultValue?: KeyframeIdent\n /**\n * The animation delay.\n *\n * @default 0\n */\n delay?: number\n /**\n * If `true`, the component is disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The animation duration.\n *\n * @default 0.4\n */\n duration?: number\n /**\n * If `true`, the component is readonly.\n *\n * @default false\n */\n readOnly?: boolean\n /**\n * The animation rotation.\n *\n * @default 45\n */\n rotate?: number\n /**\n * Use this when you want to control the animation from outside the component.\n */\n value?: KeyframeIdent\n /**\n * This is a callback function that is called when the animation state changes.\n */\n onChange?: (value: KeyframeIdent) => void\n}\n\nconst {\n PropsContext: RotatePropsContext,\n usePropsContext: useRotatePropsContext,\n withContext,\n} = createComponent<RotateProps, RotateStyle>(\"rotate\", rotateStyle)\n\nexport { RotatePropsContext, useRotatePropsContext }\n\n/**\n * `Rotate` is an animation component that alternately rotates two elements as they switch.\n *\n * @see https://yamada-ui.com/docs/components/rotate\n */\nexport const Rotate = withContext<\"button\", RotateProps>(\n ({\n defaultValue = \"from\",\n delay = 0,\n disabled,\n duration = 0.4,\n from,\n readOnly,\n rotate = 45,\n to,\n value: valueProp,\n onChange,\n onClick: onClickProp,\n ...rest\n }) => {\n const opacity = \"var(--opacity)\"\n const animate = useAnimation()\n const [value, setValue] = useControllableState<KeyframeIdent>({\n defaultValue,\n value: valueProp,\n onChange,\n })\n\n const onClick = useCallback(async () => {\n if (readOnly) return\n\n await animate.start({\n opacity: 0,\n rotate: `${rotate}deg`,\n transition: { delay, duration },\n })\n\n setValue((prev) => (prev === \"from\" ? \"to\" : \"from\"))\n\n await animate.start({\n opacity: \"var(--opacity)\",\n rotate: \"0deg\",\n transition: { duration },\n })\n }, [readOnly, animate, rotate, duration, delay, setValue])\n\n return (\n <motion.button\n type=\"button\"\n data-disabled={dataAttr(disabled)}\n data-readonly={dataAttr(readOnly)}\n data-value={value}\n animate={animate}\n custom={{ rotate }}\n disabled={disabled}\n initial={{ opacity, rotate: \"0deg\" }}\n onClick={handlerAll(onClickProp, onClick)}\n {...rest}\n >\n {value === \"from\" ? from : to}\n </motion.button>\n )\n },\n)(undefined, (props) => {\n const css = useInjectVarsIntoCss(props.css, { opacity: \"opacity\" })\n const rest = useInjectVarsIntoProps(props, { opacity: \"opacity\" })\n\n return { ...rest, css, opacity: \"{opacity}\" }\n})\n"],"mappings":";;;;;;;;;;;;;;;AA4EA,MAAM,EACJ,cAAc,oBACd,iBAAiB,uBACjB,gBACE,gBAA0C,UAAU,YAAY;;;;;;AASpE,MAAa,SAAS,aACnB,EACC,eAAe,QACf,QAAQ,GACR,UACA,WAAW,IACX,MACA,UACA,SAAS,IACT,IACA,OAAO,WACP,UACA,SAAS,aACT,GAAG,WACC;CACJ,MAAM,UAAU;CAChB,MAAM,UAAU,cAAc;CAC9B,MAAM,CAAC,OAAO,YAAY,qBAAoC;EAC5D;EACA,OAAO;EACP;EACD,CAAC;CAEF,MAAM,UAAU,YAAY,YAAY;AACtC,MAAI,SAAU;AAEd,QAAM,QAAQ,MAAM;GAClB,SAAS;GACT,QAAQ,GAAG,OAAO;GAClB,YAAY;IAAE;IAAO;IAAU;GAChC,CAAC;AAEF,YAAU,SAAU,SAAS,SAAS,OAAO,OAAQ;AAErD,QAAM,QAAQ,MAAM;GAClB,SAAS;GACT,QAAQ;GACR,YAAY,EAAE,UAAU;GACzB,CAAC;IACD;EAAC;EAAU;EAAS;EAAQ;EAAU;EAAO;EAAS,CAAC;AAE1D,QACE,oBAACA,SAAO;EACN,MAAK;EACL,6CAAwB,SAAS;EACjC,6CAAwB,SAAS;EACjC,cAAY;EACH;EACT,QAAQ,EAAE,QAAQ;EACR;EACV,SAAS;GAAE;GAAS,QAAQ;GAAQ;EACpC,uCAAoB,aAAa,QAAQ;EACzC,GAAI;YAEH,UAAU,SAAS,OAAO;GACb;EAGrB,CAAC,SAAY,UAAU;CACtB,MAAM,MAAM,qBAAqB,MAAM,KAAK,EAAE,SAAS,WAAW,CAAC;AAGnE,QAAO;EAAE,GAFI,uBAAuB,OAAO,EAAE,SAAS,WAAW,CAAC;EAEhD;EAAK,SAAS;EAAa;EAC7C"}
|
|
@@ -48,7 +48,7 @@ const Snacks = withProvider(({ snacks: { direction = "start", items, startIndex
|
|
|
48
48
|
setHeight(height$1);
|
|
49
49
|
}, [count, direction]);
|
|
50
50
|
useUpdateEffect(() => {
|
|
51
|
-
if (
|
|
51
|
+
if (count) setExist(true);
|
|
52
52
|
}, [count]);
|
|
53
53
|
return /* @__PURE__ */ jsx(ComponentContext, {
|
|
54
54
|
value: context,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snacks.js","names":["height","motion","noop","Alert.Root","Alert.Loading","Alert.Icon","Alert.Title","Alert.Description"],"sources":["../../../../src/components/snacks/snacks.tsx"],"sourcesContent":["\"use client\"\n\nimport type { Dispatch, RefObject, SetStateAction } from \"react\"\nimport type { CSSProps, HTMLStyledProps, SimpleDirection } from \"../../core\"\nimport type { Merge } from \"../../utils\"\nimport type { CloseButtonProps } from \"../close-button\"\nimport type { HTMLMotionProps } from \"../motion\"\nimport type { SnacksStyle } from \"./snacks.style\"\nimport type { Snack, UseSnacksReturn } from \"./use-snacks\"\nimport { AnimatePresence, useIsPresent } from \"motion/react\"\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\"\nimport { createSlotComponent, varAttr } from \"../../core\"\nimport { useTimeout } from \"../../hooks/use-timeout\"\nimport { dataAttr, handlerAll, noop, useUpdateEffect } from \"../../utils\"\nimport { Alert } from \"../alert\"\nimport { CloseButton } from \"../close-button\"\nimport { createTransition, motion } from \"../motion\"\nimport { snacksStyle } from \"./snacks.style\"\n\ninterface ComponentContext {\n direction: SimpleDirection\n elMapRef: RefObject<Map<number, HTMLDivElement | null>>\n setExist: Dispatch<SetStateAction<boolean>>\n startIndex: number\n}\n\nexport interface SnacksProps extends HTMLMotionProps {\n /**\n * The snacks created by `useSnacks`.\n */\n snacks: UseSnacksReturn[\"snacks\"]\n /**\n * The CSS `gap` property.\n *\n * @default 'md'\n */\n gap?: CSSProps[\"gap\"]\n /**\n * A property that provides spacing between the top and bottom.\n *\n * @default [0, \"lg\"]\n */\n gutter?: [CSSProps[\"paddingTop\"], CSSProps[\"paddingBottom\"]]\n /**\n * If `true`, apply gutter value to negative margins\n *\n * @default true\n */\n negativeMargins?: boolean\n /**\n * Props for the snacks list element.\n */\n listProps?: HTMLMotionProps\n}\n\nconst {\n ComponentContext,\n PropsContext: SnacksPropsContext,\n useComponentContext,\n usePropsContext: useSnacksPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<SnacksProps, SnacksStyle, ComponentContext>(\n \"snacks\",\n snacksStyle,\n)\n\nexport { SnacksPropsContext, useSnacksPropsContext }\n\nexport const Snacks = withProvider<\"div\", SnacksProps>(\n ({\n snacks: { direction = \"start\", items, startIndex = 0 },\n listProps,\n ...rest\n }) => {\n const count = items.length\n const elMapRef = useRef<Map<number, HTMLDivElement | null>>(new Map())\n const [height, setHeight] = useState(0)\n const [exist, setExist] = useState(!!count)\n const show = !!count || exist\n const context = useMemo(\n () => ({ direction, elMapRef, setExist, startIndex }),\n [direction, startIndex],\n )\n\n const onExitComplete = useCallback(() => {\n if (!count) setExist(false)\n }, [count])\n\n useEffect(() => {\n let height = 0\n\n if (!count) return\n\n const els = [...elMapRef.current.values()].slice(0, count)\n\n for (const el of els) {\n if (!el) continue\n\n let { offsetHeight, offsetTop } = el\n\n offsetHeight += offsetTop\n\n if (offsetHeight > height) height = offsetHeight\n }\n\n setHeight(height)\n }, [count, direction])\n\n useUpdateEffect(() => {\n if (!!count) setExist(true)\n }, [count])\n\n return (\n <ComponentContext value={context}>\n <AnimatePresence initial={false}>\n {show ? (\n <motion.div {...rest}>\n <SnackList custom={{ height }} {...listProps}>\n <AnimatePresence onExitComplete={onExitComplete}>\n {items.map((props, index) => {\n return (\n <Snack\n key={props.id}\n index={index}\n lastIndex={count - index - 1}\n {...props}\n />\n )\n })}\n </AnimatePresence>\n </SnackList>\n </motion.div>\n ) : null}\n </AnimatePresence>\n </ComponentContext>\n )\n },\n \"root\",\n)(\n {\n animate: \"animate\",\n exit: \"exit\",\n initial: \"initial\",\n variants: {\n animate: {\n padding: \"var(--top) 0 var(--bottom)\",\n transition: { duration: 0.4 },\n },\n exit: { padding: 0 },\n initial: { padding: 0 },\n },\n },\n ({ gap, gutter = [0, \"lg\"], negativeMargins = true, ...rest }) => ({\n \"data-negative\": dataAttr(negativeMargins),\n \"--bottom\": varAttr(gutter[1], \"spaces\", \"0px\"),\n \"--gap\": varAttr(gap, \"spaces\"),\n \"--top\": varAttr(gutter[0], \"spaces\", \"0px\"),\n ...rest,\n }),\n)\n\ninterface SnackListProps extends HTMLMotionProps {}\n\nconst SnackList = withContext<\"div\", SnackListProps>(\n motion.div,\n \"list\",\n)({\n animate: \"animate\",\n exit: \"exit\",\n initial: \"initial\",\n role: \"list\",\n variants: {\n animate: ({ height }) => ({\n height,\n opacity: 1,\n transition: { duration: 0.4 },\n }),\n exit: { height: 0, opacity: 0 },\n initial: { height: 0, opacity: 1 },\n },\n})\n\ninterface SnackProps extends Merge<\n HTMLMotionProps,\n Merge<Alert.RootProps, Snack>\n> {\n index: number\n lastIndex: number\n}\n\nconst Snack = withContext<\"div\", SnackProps>(\n ({\n variant = \"plain\",\n closable = true,\n description,\n duration: durationProp = null,\n loadingScheme,\n status,\n title,\n withIcon = true,\n closeButtonProps,\n contentProps,\n descriptionProps,\n iconProps,\n loadingProps,\n titleProps,\n onClose: onCloseProp,\n onCloseComplete,\n ...rest\n }) => {\n const [duration, setDuration] = useState(durationProp)\n const present = useIsPresent()\n const onClose = present ? onCloseProp : noop\n\n const onMouseEnter = useCallback(() => {\n setDuration(null)\n }, [])\n\n const onMouseLeave = useCallback(() => {\n setDuration(durationProp)\n }, [durationProp])\n\n useUpdateEffect(() => {\n if (!present) onCloseComplete?.()\n }, [present])\n\n useUpdateEffect(() => {\n setDuration(durationProp)\n }, [durationProp])\n\n useTimeout(onClose, duration)\n\n return (\n <Alert.Root\n as={motion.div}\n variant={variant}\n status={status}\n {...rest}\n onMouseEnter={handlerAll(rest.onMouseEnter, onMouseEnter)}\n onMouseLeave={handlerAll(rest.onMouseLeave, onMouseLeave)}\n >\n {withIcon ? (\n loadingScheme ? (\n <Alert.Loading loadingScheme={loadingScheme} {...loadingProps} />\n ) : (\n <Alert.Icon {...iconProps} />\n )\n ) : null}\n\n <SnackContent data-close-button={dataAttr(closable)} {...contentProps}>\n {title ? (\n <Alert.Title me=\"0\" {...titleProps}>\n {title}\n </Alert.Title>\n ) : null}\n\n {description ? (\n <Alert.Description {...descriptionProps}>\n {description}\n </Alert.Description>\n ) : null}\n </SnackContent>\n\n {closable ? (\n <SnackCloseButton\n data-variant={variant}\n {...closeButtonProps}\n onClick={handlerAll(closeButtonProps?.onClick, onClose)}\n />\n ) : null}\n </Alert.Root>\n )\n },\n \"item\",\n)(\n {\n animate: \"animate\",\n exit: \"exit\",\n initial: \"initial\",\n layout: true,\n role: \"listitem\",\n variants: {\n animate: ({ index }) => ({\n opacity: 1,\n transition: createTransition.enter()(!index ? 0.2 : 0, 0.4),\n y: 0,\n }),\n exit: {\n opacity: 0,\n transition: createTransition.exit()(undefined, 0.2),\n },\n initial: ({ direction, index }) => ({\n opacity: 0,\n ...(index ? { y: (direction === \"start\" ? -1 : 1) * 16 } : {}),\n }),\n },\n },\n ({ index, lastIndex, ...rest }) => {\n const ref = useRef<HTMLDivElement>(null)\n const { direction, elMapRef, startIndex } = useComponentContext()\n\n useEffect(() => {\n const elMap = elMapRef.current\n\n elMap.set(index, ref.current)\n\n return () => {\n elMap.delete(index)\n }\n }, [elMapRef, index])\n\n return {\n ref,\n \"--index\": direction === \"start\" ? lastIndex : index,\n \"--z-index\": startIndex + index,\n custom: { direction, index },\n ...rest,\n }\n },\n)\n\nexport interface SnackContentProps extends HTMLStyledProps {}\n\nconst SnackContent = withContext<\"div\", SnackContentProps>(\"div\", \"content\")()\n\nexport interface SnackCloseButtonProps extends CloseButtonProps {}\n\nconst SnackCloseButton = withContext<\"button\", SnackCloseButtonProps>(\n CloseButton,\n \"closeButton\",\n)()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuDA,MAAM,EACJ,kBACA,cAAc,oBACd,qBACA,iBAAiB,uBACjB,aACA,iBACE,oBACF,UACA,YACD;AAID,MAAa,SAAS,cACnB,EACC,QAAQ,EAAE,Y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M,mBAAmB,YACvB,aACA,cACD,EAAE"}
|
|
1
|
+
{"version":3,"file":"snacks.js","names":["height","motion","noop","Alert.Root","Alert.Loading","Alert.Icon","Alert.Title","Alert.Description"],"sources":["../../../../src/components/snacks/snacks.tsx"],"sourcesContent":["\"use client\"\n\nimport type { Dispatch, RefObject, SetStateAction } from \"react\"\nimport type { CSSProps, HTMLStyledProps, SimpleDirection } from \"../../core\"\nimport type { Merge } from \"../../utils\"\nimport type { CloseButtonProps } from \"../close-button\"\nimport type { HTMLMotionProps } from \"../motion\"\nimport type { SnacksStyle } from \"./snacks.style\"\nimport type { Snack, UseSnacksReturn } from \"./use-snacks\"\nimport { AnimatePresence, useIsPresent } from \"motion/react\"\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\"\nimport { createSlotComponent, varAttr } from \"../../core\"\nimport { useTimeout } from \"../../hooks/use-timeout\"\nimport { dataAttr, handlerAll, noop, useUpdateEffect } from \"../../utils\"\nimport { Alert } from \"../alert\"\nimport { CloseButton } from \"../close-button\"\nimport { createTransition, motion } from \"../motion\"\nimport { snacksStyle } from \"./snacks.style\"\n\ninterface ComponentContext {\n direction: SimpleDirection\n elMapRef: RefObject<Map<number, HTMLDivElement | null>>\n setExist: Dispatch<SetStateAction<boolean>>\n startIndex: number\n}\n\nexport interface SnacksProps extends HTMLMotionProps {\n /**\n * The snacks created by `useSnacks`.\n */\n snacks: UseSnacksReturn[\"snacks\"]\n /**\n * The CSS `gap` property.\n *\n * @default 'md'\n */\n gap?: CSSProps[\"gap\"]\n /**\n * A property that provides spacing between the top and bottom.\n *\n * @default [0, \"lg\"]\n */\n gutter?: [CSSProps[\"paddingTop\"], CSSProps[\"paddingBottom\"]]\n /**\n * If `true`, apply gutter value to negative margins\n *\n * @default true\n */\n negativeMargins?: boolean\n /**\n * Props for the snacks list element.\n */\n listProps?: HTMLMotionProps\n}\n\nconst {\n ComponentContext,\n PropsContext: SnacksPropsContext,\n useComponentContext,\n usePropsContext: useSnacksPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<SnacksProps, SnacksStyle, ComponentContext>(\n \"snacks\",\n snacksStyle,\n)\n\nexport { SnacksPropsContext, useSnacksPropsContext }\n\nexport const Snacks = withProvider<\"div\", SnacksProps>(\n ({\n snacks: { direction = \"start\", items, startIndex = 0 },\n listProps,\n ...rest\n }) => {\n const count = items.length\n const elMapRef = useRef<Map<number, HTMLDivElement | null>>(new Map())\n const [height, setHeight] = useState(0)\n const [exist, setExist] = useState(!!count)\n const show = !!count || exist\n const context = useMemo(\n () => ({ direction, elMapRef, setExist, startIndex }),\n [direction, startIndex],\n )\n\n const onExitComplete = useCallback(() => {\n if (!count) setExist(false)\n }, [count])\n\n useEffect(() => {\n let height = 0\n\n if (!count) return\n\n const els = [...elMapRef.current.values()].slice(0, count)\n\n for (const el of els) {\n if (!el) continue\n\n let { offsetHeight, offsetTop } = el\n\n offsetHeight += offsetTop\n\n if (offsetHeight > height) height = offsetHeight\n }\n\n setHeight(height)\n }, [count, direction])\n\n useUpdateEffect(() => {\n if (count) setExist(true)\n }, [count])\n\n return (\n <ComponentContext value={context}>\n <AnimatePresence initial={false}>\n {show ? (\n <motion.div {...rest}>\n <SnackList custom={{ height }} {...listProps}>\n <AnimatePresence onExitComplete={onExitComplete}>\n {items.map((props, index) => {\n return (\n <Snack\n key={props.id}\n index={index}\n lastIndex={count - index - 1}\n {...props}\n />\n )\n })}\n </AnimatePresence>\n </SnackList>\n </motion.div>\n ) : null}\n </AnimatePresence>\n </ComponentContext>\n )\n },\n \"root\",\n)(\n {\n animate: \"animate\",\n exit: \"exit\",\n initial: \"initial\",\n variants: {\n animate: {\n padding: \"var(--top) 0 var(--bottom)\",\n transition: { duration: 0.4 },\n },\n exit: { padding: 0 },\n initial: { padding: 0 },\n },\n },\n ({ gap, gutter = [0, \"lg\"], negativeMargins = true, ...rest }) => ({\n \"data-negative\": dataAttr(negativeMargins),\n \"--bottom\": varAttr(gutter[1], \"spaces\", \"0px\"),\n \"--gap\": varAttr(gap, \"spaces\"),\n \"--top\": varAttr(gutter[0], \"spaces\", \"0px\"),\n ...rest,\n }),\n)\n\ninterface SnackListProps extends HTMLMotionProps {}\n\nconst SnackList = withContext<\"div\", SnackListProps>(\n motion.div,\n \"list\",\n)({\n animate: \"animate\",\n exit: \"exit\",\n initial: \"initial\",\n role: \"list\",\n variants: {\n animate: ({ height }) => ({\n height,\n opacity: 1,\n transition: { duration: 0.4 },\n }),\n exit: { height: 0, opacity: 0 },\n initial: { height: 0, opacity: 1 },\n },\n})\n\ninterface SnackProps extends Merge<\n HTMLMotionProps,\n Merge<Alert.RootProps, Snack>\n> {\n index: number\n lastIndex: number\n}\n\nconst Snack = withContext<\"div\", SnackProps>(\n ({\n variant = \"plain\",\n closable = true,\n description,\n duration: durationProp = null,\n loadingScheme,\n status,\n title,\n withIcon = true,\n closeButtonProps,\n contentProps,\n descriptionProps,\n iconProps,\n loadingProps,\n titleProps,\n onClose: onCloseProp,\n onCloseComplete,\n ...rest\n }) => {\n const [duration, setDuration] = useState(durationProp)\n const present = useIsPresent()\n const onClose = present ? onCloseProp : noop\n\n const onMouseEnter = useCallback(() => {\n setDuration(null)\n }, [])\n\n const onMouseLeave = useCallback(() => {\n setDuration(durationProp)\n }, [durationProp])\n\n useUpdateEffect(() => {\n if (!present) onCloseComplete?.()\n }, [present])\n\n useUpdateEffect(() => {\n setDuration(durationProp)\n }, [durationProp])\n\n useTimeout(onClose, duration)\n\n return (\n <Alert.Root\n as={motion.div}\n variant={variant}\n status={status}\n {...rest}\n onMouseEnter={handlerAll(rest.onMouseEnter, onMouseEnter)}\n onMouseLeave={handlerAll(rest.onMouseLeave, onMouseLeave)}\n >\n {withIcon ? (\n loadingScheme ? (\n <Alert.Loading loadingScheme={loadingScheme} {...loadingProps} />\n ) : (\n <Alert.Icon {...iconProps} />\n )\n ) : null}\n\n <SnackContent data-close-button={dataAttr(closable)} {...contentProps}>\n {title ? (\n <Alert.Title me=\"0\" {...titleProps}>\n {title}\n </Alert.Title>\n ) : null}\n\n {description ? (\n <Alert.Description {...descriptionProps}>\n {description}\n </Alert.Description>\n ) : null}\n </SnackContent>\n\n {closable ? (\n <SnackCloseButton\n data-variant={variant}\n {...closeButtonProps}\n onClick={handlerAll(closeButtonProps?.onClick, onClose)}\n />\n ) : null}\n </Alert.Root>\n )\n },\n \"item\",\n)(\n {\n animate: \"animate\",\n exit: \"exit\",\n initial: \"initial\",\n layout: true,\n role: \"listitem\",\n variants: {\n animate: ({ index }) => ({\n opacity: 1,\n transition: createTransition.enter()(!index ? 0.2 : 0, 0.4),\n y: 0,\n }),\n exit: {\n opacity: 0,\n transition: createTransition.exit()(undefined, 0.2),\n },\n initial: ({ direction, index }) => ({\n opacity: 0,\n ...(index ? { y: (direction === \"start\" ? -1 : 1) * 16 } : {}),\n }),\n },\n },\n ({ index, lastIndex, ...rest }) => {\n const ref = useRef<HTMLDivElement>(null)\n const { direction, elMapRef, startIndex } = useComponentContext()\n\n useEffect(() => {\n const elMap = elMapRef.current\n\n elMap.set(index, ref.current)\n\n return () => {\n elMap.delete(index)\n }\n }, [elMapRef, index])\n\n return {\n ref,\n \"--index\": direction === \"start\" ? lastIndex : index,\n \"--z-index\": startIndex + index,\n custom: { direction, index },\n ...rest,\n }\n },\n)\n\nexport interface SnackContentProps extends HTMLStyledProps {}\n\nconst SnackContent = withContext<\"div\", SnackContentProps>(\"div\", \"content\")()\n\nexport interface SnackCloseButtonProps extends CloseButtonProps {}\n\nconst SnackCloseButton = withContext<\"button\", SnackCloseButtonProps>(\n CloseButton,\n \"closeButton\",\n)()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuDA,MAAM,EACJ,kBACA,cAAc,oBACd,qBACA,iBAAiB,uBACjB,aACA,iBACE,oBACF,UACA,YACD;AAID,MAAa,SAAS,cACnB,EACC,QAAQ,EAAE,YAAY,SAAS,OAAO,aAAa,KACnD,WACA,GAAG,WACC;CACJ,MAAM,QAAQ,MAAM;CACpB,MAAM,WAAW,uBAA2C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ources":["../../../../src/components/snacks/use-snacks.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type { SnacksConfig } from \"../../core\"\nimport type { Alert } from \"../alert\"\nimport type { SnackCloseButtonProps, SnackContentProps } from \"./snacks\"\nimport { useCallback, useMemo, useState } from \"react\"\nimport { useSystem } from \"../../core\"\n\nexport interface Snack extends Omit<\n UseSnacksOptions,\n \"direction\" | \"limit\" | \"startIndex\"\n> {\n id: string\n onClose: () => void\n onCloseComplete?: () => void\n}\n\nlet counter = 0\n\ninterface SnackMethodsOptions extends Partial<Omit<Snack, \"onClose\">> {}\n\nexport interface UseSnacksOptions\n extends\n Omit<Alert.RootProps, \"direction\" | \"title\">,\n Pick<Alert.LoadingProps, \"loadingScheme\">,\n SnacksConfig {\n /**\n * The description of the snack.\n */\n description?: ReactNode\n /**\n * The title of the snack.\n */\n title?: ReactNode\n /**\n * If `true`, the snack will have an icon.\n *\n * @default true\n */\n withIcon?: boolean\n /**\n * Props for the snack close button.\n */\n closeButtonProps?: SnackCloseButtonProps\n /**\n * Props for the snack content component.\n */\n contentProps?: SnackContentProps\n /**\n * Props for the alert description component.\n */\n descriptionProps?: Alert.DescriptionProps\n /**\n * Props for the alert icon component.\n */\n iconProps?: Alert.IconProps\n /**\n * Props for the alert loading component.\n */\n loadingProps?: Alert.LoadingProps\n /**\n * Props for the alert title component.\n */\n titleProps?: Alert.TitleProps\n}\n\n/**\n * `useSnacks` is a custom hook for controlling notifications used in forms and the like.\n *\n * @see https://yamada-ui.com/docs/hooks/use-snacks\n */\nexport const useSnacks = (options: UseSnacksOptions = {}) => {\n const [items, setItems] = useState<Snack[]>([])\n const { config } = useSystem()\n\n const systemOptions = useMemo(() => config.snacks ?? {}, [config])\n const defaultOptions = useMemo(\n () => ({ ...systemOptions, ...options }),\n [options, systemOptions],\n )\n const { direction, limit = 3, startIndex } = defaultOptions\n\n const getOptions = useCallback(\n (options: SnackMethodsOptions) => ({ ...defaultOptions, ...options }),\n [defaultOptions],\n )\n\n const snack = useMemo(() => {\n const methods = (options: SnackMethodsOptions = {}) => {\n options = getOptions(options)\n counter += 1\n\n const { id = counter.toString(), ...rest } = options\n const onClose = () =>\n setItems((prev) => prev.filter((prevOptions) => prevOptions.id !== id))\n\n const snack: Snack = { id, onClose, ...rest }\n\n setItems((prev) => [\n ...prev.splice(-1 * ((limit ?? Infinity) - 1)),\n snack,\n ])\n\n return id\n }\n\n methods.update = (\n id: number | string,\n options: Omit<SnackMethodsOptions, \"id\">,\n ) => {\n options = getOptions(options)\n\n setItems((prev) =>\n prev.map((prevOptions) =>\n prevOptions.id === id ? { ...prevOptions, ...options } : prevOptions,\n ),\n )\n }\n\n methods.closeAll = () => {\n setItems([])\n }\n\n methods.close = (id: number | string) => {\n setItems((prev) => prev.filter((prevOptions) => prevOptions.id !== id))\n }\n\n methods.isActive = (id: number | string) =>\n !!items.find((prevOptions) => prevOptions.id === id)\n\n return methods\n }, [items, limit, getOptions])\n\n const snacks = useMemo(\n () => ({ direction, items, startIndex }),\n [direction, startIndex, items],\n )\n\n return { snack, snacks }\n}\n\nexport type UseSnacksReturn = ReturnType<typeof useSnacks>\n"],"mappings":";;;;;;;AAkBA,IAAI,UAAU;;;;;;AAsDd,MAAa,aAAa,UAA4B,EAAE,KAAK;CAC3D,MAAM,CAAC,OAAO,YAAY,SAAkB,EAAE,CAAC;CAC/C,MAAM,EAAE,WAAW,WAAW;CAE9B,MAAM,gBAAgB,cAAc,OAAO,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC;CAClE,MAAM,iBAAiB,eACd;EAAE,GAAG;EAAe,GAAG;EAAS,GACvC,CAAC,SAAS,cAAc,CACzB;CACD,MAAM,EAAE,WAAW,QAAQ,GAAG,eAAe;CAE7C,MAAM,aAAa,aAChB,eAAkC;EAAE,GAAG;EAAgB,GAAGA;EAAS,GACpE,CAAC,eAAe,CACjB;
|
|
1
|
+
{"version":3,"file":"use-snacks.js","names":["options","snack: Snack"],"sources":["../../../../src/components/snacks/use-snacks.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactNode } from \"react\"\nimport type { SnacksConfig } from \"../../core\"\nimport type { Alert } from \"../alert\"\nimport type { SnackCloseButtonProps, SnackContentProps } from \"./snacks\"\nimport { useCallback, useMemo, useState } from \"react\"\nimport { useSystem } from \"../../core\"\n\nexport interface Snack extends Omit<\n UseSnacksOptions,\n \"direction\" | \"limit\" | \"startIndex\"\n> {\n id: string\n onClose: () => void\n onCloseComplete?: () => void\n}\n\nlet counter = 0\n\ninterface SnackMethodsOptions extends Partial<Omit<Snack, \"onClose\">> {}\n\nexport interface UseSnacksOptions\n extends\n Omit<Alert.RootProps, \"direction\" | \"title\">,\n Pick<Alert.LoadingProps, \"loadingScheme\">,\n SnacksConfig {\n /**\n * The description of the snack.\n */\n description?: ReactNode\n /**\n * The title of the snack.\n */\n title?: ReactNode\n /**\n * If `true`, the snack will have an icon.\n *\n * @default true\n */\n withIcon?: boolean\n /**\n * Props for the snack close button.\n */\n closeButtonProps?: SnackCloseButtonProps\n /**\n * Props for the snack content component.\n */\n contentProps?: SnackContentProps\n /**\n * Props for the alert description component.\n */\n descriptionProps?: Alert.DescriptionProps\n /**\n * Props for the alert icon component.\n */\n iconProps?: Alert.IconProps\n /**\n * Props for the alert loading component.\n */\n loadingProps?: Alert.LoadingProps\n /**\n * Props for the alert title component.\n */\n titleProps?: Alert.TitleProps\n}\n\n/**\n * `useSnacks` is a custom hook for controlling notifications used in forms and the like.\n *\n * @see https://yamada-ui.com/docs/hooks/use-snacks\n */\nexport const useSnacks = (options: UseSnacksOptions = {}) => {\n const [items, setItems] = useState<Snack[]>([])\n const { config } = useSystem()\n\n const systemOptions = useMemo(() => config.snacks ?? {}, [config])\n const defaultOptions = useMemo(\n () => ({ ...systemOptions, ...options }),\n [options, systemOptions],\n )\n const { direction, limit = 3, startIndex } = defaultOptions\n\n const getOptions = useCallback(\n (options: SnackMethodsOptions) => ({ ...defaultOptions, ...options }),\n [defaultOptions],\n )\n\n const snack = useMemo(() => {\n const methods = (options: SnackMethodsOptions = {}) => {\n options = getOptions(options)\n // eslint-disable-next-line react-hooks/globals\n counter += 1\n\n const { id = counter.toString(), ...rest } = options\n const onClose = () =>\n setItems((prev) => prev.filter((prevOptions) => prevOptions.id !== id))\n\n const snack: Snack = { id, onClose, ...rest }\n\n setItems((prev) => [\n ...prev.splice(-1 * ((limit ?? Infinity) - 1)),\n snack,\n ])\n\n return id\n }\n\n methods.update = (\n id: number | string,\n options: Omit<SnackMethodsOptions, \"id\">,\n ) => {\n options = getOptions(options)\n\n setItems((prev) =>\n prev.map((prevOptions) =>\n prevOptions.id === id ? { ...prevOptions, ...options } : prevOptions,\n ),\n )\n }\n\n methods.closeAll = () => {\n setItems([])\n }\n\n methods.close = (id: number | string) => {\n setItems((prev) => prev.filter((prevOptions) => prevOptions.id !== id))\n }\n\n methods.isActive = (id: number | string) =>\n !!items.find((prevOptions) => prevOptions.id === id)\n\n return methods\n }, [items, limit, getOptions])\n\n const snacks = useMemo(\n () => ({ direction, items, startIndex }),\n [direction, startIndex, items],\n )\n\n return { snack, snacks }\n}\n\nexport type UseSnacksReturn = ReturnType<typeof useSnacks>\n"],"mappings":";;;;;;;AAkBA,IAAI,UAAU;;;;;;AAsDd,MAAa,aAAa,UAA4B,EAAE,KAAK;CAC3D,MAAM,CAAC,OAAO,YAAY,SAAkB,EAAE,CAAC;CAC/C,MAAM,EAAE,WAAW,WAAW;CAE9B,MAAM,gBAAgB,cAAc,OAAO,UAAU,EAAE,EAAE,CAAC,OAAO,CAAC;CAClE,MAAM,iBAAiB,eACd;EAAE,GAAG;EAAe,GAAG;EAAS,GACvC,CAAC,SAAS,cAAc,CACzB;CACD,MAAM,EAAE,WAAW,QAAQ,GAAG,eAAe;CAE7C,MAAM,aAAa,aAChB,eAAkC;EAAE,GAAG;EAAgB,GAAGA;EAAS,GACpE,CAAC,eAAe,CACjB;AAsDD,QAAO;EAAE,OApDK,cAAc;GAC1B,MAAM,WAAW,YAA+B,EAAE,KAAK;AACrD,gBAAU,WAAWA,UAAQ;AAE7B,eAAW;IAEX,MAAM,EAAE,KAAK,QAAQ,UAAU,EAAE,GAAG,SAASA;IAC7C,MAAM,gBACJ,UAAU,SAAS,KAAK,QAAQ,gBAAgB,YAAY,OAAO,GAAG,CAAC;IAEzE,MAAMC,QAAe;KAAE;KAAI;KAAS,GAAG;KAAM;AAE7C,cAAU,SAAS,CACjB,GAAG,KAAK,OAAO,OAAO,SAAS,YAAY,GAAG,EAC9C,MACD,CAAC;AAEF,WAAO;;AAGT,WAAQ,UACN,IACA,cACG;AACH,gBAAU,WAAWD,UAAQ;AAE7B,cAAU,SACR,KAAK,KAAK,gBACR,YAAY,OAAO,KAAK;KAAE,GAAG;KAAa,GAAGA;KAAS,GAAG,YAC1D,CACF;;AAGH,WAAQ,iBAAiB;AACvB,aAAS,EAAE,CAAC;;AAGd,WAAQ,SAAS,OAAwB;AACvC,cAAU,SAAS,KAAK,QAAQ,gBAAgB,YAAY,OAAO,GAAG,CAAC;;AAGzE,WAAQ,YAAY,OAClB,CAAC,CAAC,MAAM,MAAM,gBAAgB,YAAY,OAAO,GAAG;AAEtD,UAAO;KACN;GAAC;GAAO;GAAO;GAAW,CAAC;EAOd,QALD,eACN;GAAE;GAAW;GAAO;GAAY,GACvC;GAAC;GAAW;GAAY;GAAM,CAC/B;EAEuB"}
|
|
@@ -26,7 +26,7 @@ const Stack = withContext(({ align: alignItems, children, direction: flexDirecti
|
|
|
26
26
|
h: (0, utils_exports.replaceObject)(flexDirection, (value) => isColumn(value) ? "fit-content" : "100%"),
|
|
27
27
|
w: (0, utils_exports.replaceObject)(flexDirection, (value) => isColumn(value) ? "100%" : "fit-content")
|
|
28
28
|
});
|
|
29
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
29
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [index ? cloneSeparator : null, child] }, key);
|
|
30
30
|
}) : validChildren, [
|
|
31
31
|
separator,
|
|
32
32
|
flexDirection,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.js","names":[],"sources":["../../../../src/components/stack/stack.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactElement } from \"react\"\nimport type { CSSProps, HTMLStyledProps } from \"../../core\"\nimport type { StackStyle } from \"./stack.style\"\nimport { cloneElement, Fragment, useMemo } from \"react\"\nimport { createComponent, styled } from \"../../core\"\nimport { replaceObject, useValidChildren } from \"../../utils\"\nimport { stackStyle } from \"./stack.style\"\n\nexport interface StackProps extends Omit<HTMLStyledProps, \"direction\"> {\n /**\n * The CSS `align-items` property.\n */\n align?: CSSProps[\"alignItems\"]\n /**\n * The CSS `flex-direction` property.\n */\n direction?: CSSProps[\"flexDirection\"]\n /**\n * The CSS `justify-content` property.\n */\n justify?: CSSProps[\"justifyContent\"]\n /**\n * If `true`, each stack item will show a separator.\n */\n separator?: ReactElement\n /**\n * The CSS `flex-wrap` property.\n */\n wrap?: CSSProps[\"flexWrap\"]\n}\n\nconst {\n PropsContext: StackPropsContext,\n usePropsContext: useStackPropsContext,\n withContext,\n} = createComponent<StackProps, StackStyle>(\"stack\", stackStyle)\n\nexport { StackPropsContext, useStackPropsContext }\n\n/**\n * `Stack` is a component that groups elements and provides space between child elements.\n *\n * @see https://yamada-ui.com/docs/components/stack\n */\nexport const Stack = withContext<\"div\", StackProps>(\n ({\n align: alignItems,\n children,\n direction: flexDirection = \"column\",\n justify: justifyContent,\n separator,\n wrap: flexWrap,\n ...rest\n }) => {\n const isColumn = (value: any) =>\n value === \"column\" || value === \"column-reverse\"\n\n const validChildren = useValidChildren(children)\n const cloneChildren = useMemo(\n () =>\n separator\n ? validChildren.map((child, index) => {\n const key = typeof child.key !== \"undefined\" ? child.key : index\n\n const cloneSeparator = cloneElement<any>(separator, {\n borderWidth: replaceObject(flexDirection, (value) =>\n isColumn(value) ? \"0 0 1px 0\" : \"0 0 0 1px\",\n ),\n h: replaceObject(flexDirection, (value) =>\n isColumn(value) ? \"fit-content\" : \"100%\",\n ),\n w: replaceObject(flexDirection, (value) =>\n isColumn(value) ? \"100%\" : \"fit-content\",\n ),\n })\n\n return (\n <Fragment key={key}>\n {
|
|
1
|
+
{"version":3,"file":"stack.js","names":[],"sources":["../../../../src/components/stack/stack.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ReactElement } from \"react\"\nimport type { CSSProps, HTMLStyledProps } from \"../../core\"\nimport type { StackStyle } from \"./stack.style\"\nimport { cloneElement, Fragment, useMemo } from \"react\"\nimport { createComponent, styled } from \"../../core\"\nimport { replaceObject, useValidChildren } from \"../../utils\"\nimport { stackStyle } from \"./stack.style\"\n\nexport interface StackProps extends Omit<HTMLStyledProps, \"direction\"> {\n /**\n * The CSS `align-items` property.\n */\n align?: CSSProps[\"alignItems\"]\n /**\n * The CSS `flex-direction` property.\n */\n direction?: CSSProps[\"flexDirection\"]\n /**\n * The CSS `justify-content` property.\n */\n justify?: CSSProps[\"justifyContent\"]\n /**\n * If `true`, each stack item will show a separator.\n */\n separator?: ReactElement\n /**\n * The CSS `flex-wrap` property.\n */\n wrap?: CSSProps[\"flexWrap\"]\n}\n\nconst {\n PropsContext: StackPropsContext,\n usePropsContext: useStackPropsContext,\n withContext,\n} = createComponent<StackProps, StackStyle>(\"stack\", stackStyle)\n\nexport { StackPropsContext, useStackPropsContext }\n\n/**\n * `Stack` is a component that groups elements and provides space between child elements.\n *\n * @see https://yamada-ui.com/docs/components/stack\n */\nexport const Stack = withContext<\"div\", StackProps>(\n ({\n align: alignItems,\n children,\n direction: flexDirection = \"column\",\n justify: justifyContent,\n separator,\n wrap: flexWrap,\n ...rest\n }) => {\n const isColumn = (value: any) =>\n value === \"column\" || value === \"column-reverse\"\n\n const validChildren = useValidChildren(children)\n const cloneChildren = useMemo(\n () =>\n separator\n ? validChildren.map((child, index) => {\n const key = typeof child.key !== \"undefined\" ? child.key : index\n\n const cloneSeparator = cloneElement<any>(separator, {\n borderWidth: replaceObject(flexDirection, (value) =>\n isColumn(value) ? \"0 0 1px 0\" : \"0 0 0 1px\",\n ),\n h: replaceObject(flexDirection, (value) =>\n isColumn(value) ? \"fit-content\" : \"100%\",\n ),\n w: replaceObject(flexDirection, (value) =>\n isColumn(value) ? \"100%\" : \"fit-content\",\n ),\n })\n\n return (\n <Fragment key={key}>\n {index ? cloneSeparator : null}\n {child}\n </Fragment>\n )\n })\n : validChildren,\n [separator, flexDirection, validChildren],\n )\n\n return (\n <styled.div\n alignItems={alignItems}\n flexDirection={flexDirection}\n flexWrap={flexWrap}\n justifyContent={justifyContent}\n {...rest}\n >\n {cloneChildren}\n </styled.div>\n )\n },\n)()\n"],"mappings":";;;;;;;;;;;;AAiCA,MAAM,EACJ,cAAc,mBACd,iBAAiB,sBACjB,gBACE,gBAAwC,SAAS,WAAW;;;;;;AAShE,MAAa,QAAQ,aAClB,EACC,OAAO,YACP,UACA,WAAW,gBAAgB,UAC3B,SAAS,gBACT,WACA,MAAM,UACN,GAAG,WACC;CACJ,MAAM,YAAY,UAChB,UAAU,YAAY,UAAU;CAElC,MAAM,gBAAgB,iBAAiB,SAAS;CAChD,MAAM,gBAAgB,cAElB,YACI,cAAc,KAAK,OAAO,UAAU;EAClC,MAAM,MAAM,OAAO,MAAM,QAAQ,cAAc,MAAM,MAAM;EAE3D,MAAM,iBAAiB,aAAkB,WAAW;GAClD,8CAA2B,gBAAgB,UACzC,SAAS,MAAM,GAAG,cAAc,YACjC;GACD,oCAAiB,gBAAgB,UAC/B,SAAS,MAAM,GAAG,gBAAgB,OACnC;GACD,oCAAiB,gBAAgB,UAC/B,SAAS,MAAM,GAAG,SAAS,cAC5B;GACF,CAAC;AAEF,SACE,qBAAC,uBACE,QAAQ,iBAAiB,MACzB,UAFY,IAGJ;GAEb,GACF,eACN;EAAC;EAAW;EAAe;EAAc,CAC1C;AAED,QACE,oBAAC,OAAO;EACM;EACG;EACL;EACM;EAChB,GAAI;YAEH;GACU;EAGlB,EAAE"}
|
|
@@ -147,7 +147,7 @@ function mergeSlotCSS(slot, style, css) {
|
|
|
147
147
|
else temp.push(style[slot]);
|
|
148
148
|
if (css) temp.push(...(0, utils_exports.toArray)(css));
|
|
149
149
|
const result = (0, utils_exports.filterEmpty)(temp);
|
|
150
|
-
return
|
|
150
|
+
return result.length ? result : void 0;
|
|
151
151
|
}
|
|
152
152
|
function omitThemeProps(props, omitKeys = [], transferProps) {
|
|
153
153
|
if (transferProps) omitKeys = omitKeys.filter((key) => !transferProps.includes(key));
|