@yamada-ui/react 2.3.0-dev-20260724085908 → 2.3.0-dev-20260730080927
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/accordion/accordion.cjs.map +1 -1
- package/dist/cjs/components/action-bar/action-bar.cjs.map +1 -1
- package/dist/cjs/components/airy/airy.cjs.map +1 -1
- package/dist/cjs/components/alert/alert.cjs.map +1 -1
- package/dist/cjs/components/alpha-slider/alpha-slider.cjs.map +1 -1
- package/dist/cjs/components/autocomplete/autocomplete.cjs.map +1 -1
- package/dist/cjs/components/autocomplete/use-autocomplete.cjs.map +1 -1
- package/dist/cjs/components/avatar/avatar-group.cjs.map +1 -1
- package/dist/cjs/components/avatar/avatar.cjs.map +1 -1
- package/dist/cjs/components/blockquote/blockquote.cjs.map +1 -1
- package/dist/cjs/components/breadcrumb/breadcrumb.cjs.map +1 -1
- package/dist/cjs/components/button/button-group.cjs.map +1 -1
- package/dist/cjs/components/button/button.cjs.map +1 -1
- package/dist/cjs/components/calendar/calendar.cjs.map +1 -1
- package/dist/cjs/components/calendar/use-calendar.cjs.map +1 -1
- package/dist/cjs/components/carousel/carousel.cjs.map +1 -1
- package/dist/cjs/components/chart/cartesian-chart.cjs.map +1 -1
- package/dist/cjs/components/chart/chart.cjs.map +1 -1
- package/dist/cjs/components/chart/polar-chart.cjs.map +1 -1
- package/dist/cjs/components/checkbox/checkbox-group.cjs.map +1 -1
- package/dist/cjs/components/checkbox/checkbox.cjs.map +1 -1
- package/dist/cjs/components/checkbox-card/checkbox-card-group.cjs.map +1 -1
- package/dist/cjs/components/checkbox-card/checkbox-card.cjs.map +1 -1
- package/dist/cjs/components/circle-progress/circle-progress.cjs.map +1 -1
- package/dist/cjs/components/collapse/collapse.cjs.map +1 -1
- package/dist/cjs/components/color-picker/color-picker.cjs.map +1 -1
- package/dist/cjs/components/color-selector/color-selector.cjs.map +1 -1
- package/dist/cjs/components/color-swatch/color-swatch-group.cjs.map +1 -1
- package/dist/cjs/components/color-swatch/color-swatch.cjs.map +1 -1
- package/dist/cjs/components/data-list/data-list.cjs.map +1 -1
- package/dist/cjs/components/date-picker/date-picker.cjs.map +1 -1
- package/dist/cjs/components/date-picker/use-date-picker.cjs.map +1 -1
- package/dist/cjs/components/drawer/drawer.cjs +1 -1
- package/dist/cjs/components/drawer/drawer.cjs.map +1 -1
- package/dist/cjs/components/dropzone/dropzone.cjs.map +1 -1
- package/dist/cjs/components/editable/editable.cjs.map +1 -1
- package/dist/cjs/components/editable/use-editable.cjs +4 -5
- package/dist/cjs/components/editable/use-editable.cjs.map +1 -1
- package/dist/cjs/components/empty-state/empty-state.cjs.map +1 -1
- package/dist/cjs/components/fade/fade.cjs.map +1 -1
- package/dist/cjs/components/fade-scale/fade-scale.cjs.map +1 -1
- package/dist/cjs/components/field/field.cjs.map +1 -1
- package/dist/cjs/components/fieldset/fieldset.cjs.map +1 -1
- package/dist/cjs/components/file-input/file-input.cjs.map +1 -1
- package/dist/cjs/components/flip/flip.cjs.map +1 -1
- package/dist/cjs/components/focus-lock/focus-lock.cjs +26 -9
- package/dist/cjs/components/focus-lock/focus-lock.cjs.map +1 -1
- package/dist/cjs/components/focus-lock/index.cjs +1 -0
- package/dist/cjs/components/form/form.cjs.map +1 -1
- package/dist/cjs/components/format/format-byte.cjs.map +1 -1
- package/dist/cjs/components/format/format-date-time.cjs.map +1 -1
- package/dist/cjs/components/format/format-number.cjs.map +1 -1
- package/dist/cjs/components/highlight/highlight.cjs.map +1 -1
- package/dist/cjs/components/hue-slider/hue-slider.cjs.map +1 -1
- package/dist/cjs/components/icon/icons/circle-euro-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/circle-euro-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/index.cjs +9 -3
- package/dist/cjs/components/icon/icons/index.cjs.map +1 -1
- package/dist/cjs/components/icon/icons/scan-box-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/scan-box-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/server-plus-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/server-plus-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/index.cjs +6 -2
- package/dist/cjs/components/indicator/indicator.cjs.map +1 -1
- package/dist/cjs/components/infinite-scroll-area/infinite-scroll-area.cjs.map +1 -1
- package/dist/cjs/components/input/input-group.cjs.map +1 -1
- package/dist/cjs/components/link-box/link-box.cjs.map +1 -1
- package/dist/cjs/components/list/list.cjs.map +1 -1
- package/dist/cjs/components/loading/audio.cjs.map +1 -1
- package/dist/cjs/components/loading/background.cjs.map +1 -1
- package/dist/cjs/components/loading/circles.cjs.map +1 -1
- package/dist/cjs/components/loading/dots.cjs.map +1 -1
- package/dist/cjs/components/loading/grid.cjs.map +1 -1
- package/dist/cjs/components/loading/loading-provider.cjs.map +1 -1
- package/dist/cjs/components/loading/oval.cjs.map +1 -1
- package/dist/cjs/components/loading/page.cjs.map +1 -1
- package/dist/cjs/components/loading/puff.cjs.map +1 -1
- package/dist/cjs/components/loading/rings.cjs.map +1 -1
- package/dist/cjs/components/loading/screen.cjs.map +1 -1
- package/dist/cjs/components/loading/suspense.cjs.map +1 -1
- package/dist/cjs/components/menu/menu.cjs.map +1 -1
- package/dist/cjs/components/menu/use-menu.cjs.map +1 -1
- package/dist/cjs/components/modal/modal.cjs +39 -21
- package/dist/cjs/components/modal/modal.cjs.map +1 -1
- package/dist/cjs/components/native-accordion/native-accordion.cjs.map +1 -1
- package/dist/cjs/components/native-popover/native-popover.cjs.map +1 -1
- package/dist/cjs/components/native-select/native-select.cjs.map +1 -1
- package/dist/cjs/components/native-select/use-native-select.cjs.map +1 -1
- package/dist/cjs/components/native-table/native-table.cjs.map +1 -1
- package/dist/cjs/components/notice/notice-provider.cjs.map +1 -1
- package/dist/cjs/components/notice/notice.cjs.map +1 -1
- package/dist/cjs/components/notice/use-notice.cjs.map +1 -1
- package/dist/cjs/components/number-input/number-input.cjs.map +1 -1
- package/dist/cjs/components/number-input/use-number-input.cjs +2 -1
- package/dist/cjs/components/number-input/use-number-input.cjs.map +1 -1
- package/dist/cjs/components/pagination/pagination.cjs.map +1 -1
- package/dist/cjs/components/password-input/password-input.cjs.map +1 -1
- package/dist/cjs/components/password-input/strength-meter.cjs.map +1 -1
- package/dist/cjs/components/picture/picture.cjs.map +1 -1
- package/dist/cjs/components/pin-input/pin-input.cjs.map +1 -1
- package/dist/cjs/components/popover/popover.cjs +66 -24
- package/dist/cjs/components/popover/popover.cjs.map +1 -1
- package/dist/cjs/components/portal/portal.cjs +16 -0
- package/dist/cjs/components/portal/portal.cjs.map +1 -1
- package/dist/cjs/components/progress/progress.cjs.map +1 -1
- package/dist/cjs/components/qr-code/qr-code.cjs.map +1 -1
- package/dist/cjs/components/radio/radio-group.cjs.map +1 -1
- package/dist/cjs/components/radio/radio.cjs.map +1 -1
- package/dist/cjs/components/radio-card/radio-card-group.cjs.map +1 -1
- package/dist/cjs/components/radio-card/radio-card.cjs.map +1 -1
- package/dist/cjs/components/rating/rating.cjs.map +1 -1
- package/dist/cjs/components/reorder/reorder.cjs.map +1 -1
- package/dist/cjs/components/resizable/resizable.cjs.map +1 -1
- package/dist/cjs/components/ripple/ripple.cjs.map +1 -1
- package/dist/cjs/components/rotate/rotate.cjs.map +1 -1
- package/dist/cjs/components/saturation-slider/saturation-slider.cjs.map +1 -1
- package/dist/cjs/components/saturation-slider/use-saturation-slider.cjs.map +1 -1
- package/dist/cjs/components/segmented-control/segmented-control.cjs.map +1 -1
- package/dist/cjs/components/select/select.cjs.map +1 -1
- package/dist/cjs/components/select/use-select.cjs.map +1 -1
- package/dist/cjs/components/sidebar/sidebar.cjs.map +1 -1
- package/dist/cjs/components/skeleton/skeleton-text.cjs.map +1 -1
- package/dist/cjs/components/slide/slide.cjs.map +1 -1
- package/dist/cjs/components/slide-fade/slide-fade.cjs.map +1 -1
- package/dist/cjs/components/slider/slider.cjs.map +1 -1
- package/dist/cjs/components/slot/slot.cjs.map +1 -1
- package/dist/cjs/components/snacks/snacks.cjs.map +1 -1
- package/dist/cjs/components/stack/stack.cjs.map +1 -1
- package/dist/cjs/components/stack/z-stack.cjs.map +1 -1
- package/dist/cjs/components/stat/stat.cjs.map +1 -1
- package/dist/cjs/components/status/status.cjs.map +1 -1
- package/dist/cjs/components/steps/steps.cjs.map +1 -1
- package/dist/cjs/components/switch/switch.cjs.map +1 -1
- package/dist/cjs/components/table/table.cjs.map +1 -1
- package/dist/cjs/components/tabs/tabs.cjs.map +1 -1
- package/dist/cjs/components/tag/tag.cjs.map +1 -1
- package/dist/cjs/components/timeline/timeline.cjs.map +1 -1
- package/dist/cjs/components/tip/tip.cjs.map +1 -1
- package/dist/cjs/components/toggle/toggle-group.cjs.map +1 -1
- package/dist/cjs/components/tooltip/tooltip.cjs +2 -2
- package/dist/cjs/components/tooltip/tooltip.cjs.map +1 -1
- package/dist/cjs/components/tree/tree.cjs.map +1 -1
- package/dist/cjs/components/tree/use-tree.cjs.map +1 -1
- package/dist/cjs/core/components/create-component.cjs.map +1 -1
- package/dist/cjs/core/css/focus-ring.cjs +4 -1
- package/dist/cjs/core/css/focus-ring.cjs.map +1 -1
- package/dist/cjs/core/system/breakpoint.cjs.map +1 -1
- package/dist/cjs/core/system/environment-provider.cjs.map +1 -1
- package/dist/cjs/core/system/styled.cjs.map +1 -1
- package/dist/cjs/core/system/theme-provider.cjs.map +1 -1
- package/dist/cjs/hooks/use-async-callback/index.cjs.map +1 -1
- package/dist/cjs/hooks/use-breakpoint/use-breakpoint.cjs.map +1 -1
- package/dist/cjs/hooks/use-combobox/index.cjs.map +1 -1
- package/dist/cjs/hooks/use-field-sizing/index.cjs.map +1 -1
- package/dist/cjs/hooks/use-focus/index.cjs +8 -4
- package/dist/cjs/hooks/use-focus/index.cjs.map +1 -1
- package/dist/cjs/hooks/use-outside-click/index.cjs +4 -2
- package/dist/cjs/hooks/use-outside-click/index.cjs.map +1 -1
- package/dist/cjs/index.cjs +12 -4
- package/dist/cjs/providers/ui-provider/ui-provider.cjs.map +1 -1
- package/dist/cjs/utils/dom.cjs +4 -1
- package/dist/cjs/utils/dom.cjs.map +1 -1
- package/dist/cjs/utils/store.cjs.map +1 -1
- package/dist/esm/components/accordion/accordion.js.map +1 -1
- package/dist/esm/components/action-bar/action-bar.js.map +1 -1
- package/dist/esm/components/airy/airy.js.map +1 -1
- package/dist/esm/components/alert/alert.js.map +1 -1
- package/dist/esm/components/alpha-slider/alpha-slider.js.map +1 -1
- package/dist/esm/components/autocomplete/autocomplete.js.map +1 -1
- package/dist/esm/components/autocomplete/use-autocomplete.js.map +1 -1
- package/dist/esm/components/avatar/avatar-group.js.map +1 -1
- package/dist/esm/components/avatar/avatar.js.map +1 -1
- package/dist/esm/components/blockquote/blockquote.js.map +1 -1
- package/dist/esm/components/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/esm/components/button/button-group.js.map +1 -1
- package/dist/esm/components/button/button.js.map +1 -1
- package/dist/esm/components/calendar/calendar.js.map +1 -1
- package/dist/esm/components/calendar/use-calendar.js.map +1 -1
- package/dist/esm/components/carousel/carousel.js.map +1 -1
- package/dist/esm/components/chart/cartesian-chart.js.map +1 -1
- package/dist/esm/components/chart/chart.js.map +1 -1
- package/dist/esm/components/chart/polar-chart.js.map +1 -1
- package/dist/esm/components/checkbox/checkbox-group.js.map +1 -1
- package/dist/esm/components/checkbox/checkbox.js.map +1 -1
- package/dist/esm/components/checkbox-card/checkbox-card-group.js.map +1 -1
- package/dist/esm/components/checkbox-card/checkbox-card.js.map +1 -1
- package/dist/esm/components/circle-progress/circle-progress.js.map +1 -1
- package/dist/esm/components/collapse/collapse.js.map +1 -1
- package/dist/esm/components/color-picker/color-picker.js.map +1 -1
- package/dist/esm/components/color-selector/color-selector.js.map +1 -1
- package/dist/esm/components/color-swatch/color-swatch-group.js.map +1 -1
- package/dist/esm/components/color-swatch/color-swatch.js.map +1 -1
- package/dist/esm/components/data-list/data-list.js.map +1 -1
- package/dist/esm/components/date-picker/date-picker.js.map +1 -1
- package/dist/esm/components/date-picker/use-date-picker.js.map +1 -1
- package/dist/esm/components/drawer/drawer.js +1 -1
- package/dist/esm/components/drawer/drawer.js.map +1 -1
- package/dist/esm/components/dropzone/dropzone.js.map +1 -1
- package/dist/esm/components/editable/editable.js.map +1 -1
- package/dist/esm/components/editable/use-editable.js +4 -5
- package/dist/esm/components/editable/use-editable.js.map +1 -1
- package/dist/esm/components/empty-state/empty-state.js.map +1 -1
- package/dist/esm/components/fade/fade.js.map +1 -1
- package/dist/esm/components/fade-scale/fade-scale.js.map +1 -1
- package/dist/esm/components/field/field.js.map +1 -1
- package/dist/esm/components/fieldset/fieldset.js.map +1 -1
- package/dist/esm/components/file-input/file-input.js.map +1 -1
- package/dist/esm/components/flip/flip.js.map +1 -1
- package/dist/esm/components/focus-lock/focus-lock.js +27 -11
- package/dist/esm/components/focus-lock/focus-lock.js.map +1 -1
- package/dist/esm/components/focus-lock/index.js +2 -2
- package/dist/esm/components/form/form.js.map +1 -1
- package/dist/esm/components/format/format-byte.js.map +1 -1
- package/dist/esm/components/format/format-date-time.js.map +1 -1
- package/dist/esm/components/format/format-number.js.map +1 -1
- package/dist/esm/components/highlight/highlight.js.map +1 -1
- package/dist/esm/components/hue-slider/hue-slider.js.map +1 -1
- package/dist/esm/components/icon/icons/circle-euro-icon.js +14 -0
- package/dist/esm/components/icon/icons/circle-euro-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/index.js +7 -3
- package/dist/esm/components/icon/icons/index.js.map +1 -1
- package/dist/esm/components/icon/icons/scan-box-icon.js +14 -0
- package/dist/esm/components/icon/icons/scan-box-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/server-plus-icon.js +14 -0
- package/dist/esm/components/icon/icons/server-plus-icon.js.map +1 -0
- package/dist/esm/components/icon/index.js +4 -2
- package/dist/esm/components/indicator/indicator.js.map +1 -1
- package/dist/esm/components/infinite-scroll-area/infinite-scroll-area.js.map +1 -1
- package/dist/esm/components/input/input-group.js.map +1 -1
- package/dist/esm/components/link-box/link-box.js.map +1 -1
- package/dist/esm/components/list/list.js.map +1 -1
- package/dist/esm/components/loading/audio.js.map +1 -1
- package/dist/esm/components/loading/background.js.map +1 -1
- package/dist/esm/components/loading/circles.js.map +1 -1
- package/dist/esm/components/loading/dots.js.map +1 -1
- package/dist/esm/components/loading/grid.js.map +1 -1
- package/dist/esm/components/loading/loading-provider.js.map +1 -1
- package/dist/esm/components/loading/oval.js.map +1 -1
- package/dist/esm/components/loading/page.js.map +1 -1
- package/dist/esm/components/loading/puff.js.map +1 -1
- package/dist/esm/components/loading/rings.js.map +1 -1
- package/dist/esm/components/loading/screen.js.map +1 -1
- package/dist/esm/components/loading/suspense.js.map +1 -1
- package/dist/esm/components/menu/menu.js.map +1 -1
- package/dist/esm/components/menu/use-menu.js.map +1 -1
- package/dist/esm/components/modal/modal.js +40 -21
- package/dist/esm/components/modal/modal.js.map +1 -1
- package/dist/esm/components/native-accordion/native-accordion.js.map +1 -1
- package/dist/esm/components/native-popover/native-popover.js.map +1 -1
- package/dist/esm/components/native-select/native-select.js.map +1 -1
- package/dist/esm/components/native-select/use-native-select.js.map +1 -1
- package/dist/esm/components/native-table/native-table.js.map +1 -1
- package/dist/esm/components/notice/notice-provider.js.map +1 -1
- package/dist/esm/components/notice/notice.js.map +1 -1
- package/dist/esm/components/notice/use-notice.js.map +1 -1
- package/dist/esm/components/number-input/number-input.js.map +1 -1
- package/dist/esm/components/number-input/use-number-input.js +2 -1
- package/dist/esm/components/number-input/use-number-input.js.map +1 -1
- package/dist/esm/components/pagination/pagination.js.map +1 -1
- package/dist/esm/components/password-input/password-input.js.map +1 -1
- package/dist/esm/components/password-input/strength-meter.js.map +1 -1
- package/dist/esm/components/picture/picture.js.map +1 -1
- package/dist/esm/components/pin-input/pin-input.js.map +1 -1
- package/dist/esm/components/popover/popover.js +67 -25
- package/dist/esm/components/popover/popover.js.map +1 -1
- package/dist/esm/components/portal/portal.js +17 -1
- package/dist/esm/components/portal/portal.js.map +1 -1
- package/dist/esm/components/progress/progress.js.map +1 -1
- package/dist/esm/components/qr-code/qr-code.js.map +1 -1
- package/dist/esm/components/radio/radio-group.js.map +1 -1
- package/dist/esm/components/radio/radio.js.map +1 -1
- package/dist/esm/components/radio-card/radio-card-group.js.map +1 -1
- package/dist/esm/components/radio-card/radio-card.js.map +1 -1
- package/dist/esm/components/rating/rating.js.map +1 -1
- package/dist/esm/components/reorder/reorder.js.map +1 -1
- package/dist/esm/components/resizable/resizable.js.map +1 -1
- package/dist/esm/components/ripple/ripple.js.map +1 -1
- package/dist/esm/components/rotate/rotate.js.map +1 -1
- package/dist/esm/components/saturation-slider/saturation-slider.js.map +1 -1
- package/dist/esm/components/saturation-slider/use-saturation-slider.js.map +1 -1
- package/dist/esm/components/segmented-control/segmented-control.js.map +1 -1
- package/dist/esm/components/select/select.js.map +1 -1
- package/dist/esm/components/select/use-select.js.map +1 -1
- package/dist/esm/components/sidebar/sidebar.js.map +1 -1
- package/dist/esm/components/skeleton/skeleton-text.js.map +1 -1
- package/dist/esm/components/slide/slide.js.map +1 -1
- package/dist/esm/components/slide-fade/slide-fade.js.map +1 -1
- package/dist/esm/components/slider/slider.js.map +1 -1
- package/dist/esm/components/slot/slot.js.map +1 -1
- package/dist/esm/components/snacks/snacks.js.map +1 -1
- package/dist/esm/components/stack/stack.js.map +1 -1
- package/dist/esm/components/stack/z-stack.js.map +1 -1
- package/dist/esm/components/stat/stat.js.map +1 -1
- package/dist/esm/components/status/status.js.map +1 -1
- package/dist/esm/components/steps/steps.js.map +1 -1
- package/dist/esm/components/switch/switch.js.map +1 -1
- package/dist/esm/components/table/table.js.map +1 -1
- package/dist/esm/components/tabs/tabs.js.map +1 -1
- package/dist/esm/components/tag/tag.js.map +1 -1
- package/dist/esm/components/timeline/timeline.js.map +1 -1
- package/dist/esm/components/tip/tip.js.map +1 -1
- package/dist/esm/components/toggle/toggle-group.js.map +1 -1
- package/dist/esm/components/tooltip/tooltip.js +2 -2
- package/dist/esm/components/tooltip/tooltip.js.map +1 -1
- package/dist/esm/components/tree/tree.js.map +1 -1
- package/dist/esm/components/tree/use-tree.js.map +1 -1
- package/dist/esm/core/components/create-component.js.map +1 -1
- package/dist/esm/core/css/focus-ring.js +4 -1
- package/dist/esm/core/css/focus-ring.js.map +1 -1
- package/dist/esm/core/system/breakpoint.js.map +1 -1
- package/dist/esm/core/system/environment-provider.js.map +1 -1
- package/dist/esm/core/system/styled.js.map +1 -1
- package/dist/esm/core/system/theme-provider.js.map +1 -1
- package/dist/esm/hooks/use-breakpoint/use-breakpoint.js.map +1 -1
- package/dist/esm/hooks/use-combobox/index.js.map +1 -1
- package/dist/esm/hooks/use-field-sizing/index.js.map +1 -1
- package/dist/esm/hooks/use-focus/index.js +8 -4
- package/dist/esm/hooks/use-focus/index.js.map +1 -1
- package/dist/esm/hooks/use-outside-click/index.js +4 -2
- package/dist/esm/hooks/use-outside-click/index.js.map +1 -1
- package/dist/esm/index.js +9 -4
- package/dist/esm/providers/ui-provider/ui-provider.js.map +1 -1
- package/dist/esm/utils/dom.js +4 -1
- package/dist/esm/utils/dom.js.map +1 -1
- package/dist/esm/utils/store.js.map +1 -1
- package/dist/types/components/avatar/avatar.d.ts +3 -3
- package/dist/types/components/avatar/avatar.style.d.ts +1 -1
- package/dist/types/components/chart/cartesian-chart.style.d.ts +1 -1
- package/dist/types/components/chart/polar-chart.style.d.ts +1 -1
- package/dist/types/components/focus-lock/focus-lock.d.ts +2 -1
- package/dist/types/components/focus-lock/index.d.ts +2 -2
- package/dist/types/components/icon/icons/circle-euro-icon.d.ts +13 -0
- package/dist/types/components/icon/icons/index.d.ts +5 -3
- package/dist/types/components/icon/icons/index.types.d.ts +1 -1
- package/dist/types/components/icon/icons/scan-box-icon.d.ts +13 -0
- package/dist/types/components/icon/icons/server-plus-icon.d.ts +13 -0
- package/dist/types/components/icon/index.d.ts +4 -2
- package/dist/types/components/menu/use-menu.d.ts +1 -1
- package/dist/types/components/modal/modal.d.ts +37 -1
- package/dist/types/components/popover/popover.d.ts +57 -2
- package/dist/types/components/tooltip/tooltip.d.ts +8 -1
- package/dist/types/core/css/focus-ring.d.ts +1 -0
- package/dist/types/index.d.ts +6 -4
- package/dist/types/providers/i18n-provider/i18n-provider.d.ts +1 -1
- package/package.json +6 -6
- package/dist/cjs/components/icon/icons/circle-euro-sign-icon.cjs +0 -14
- package/dist/cjs/components/icon/icons/circle-euro-sign-icon.cjs.map +0 -1
- package/dist/esm/components/icon/icons/circle-euro-sign-icon.js +0 -14
- package/dist/esm/components/icon/icons/circle-euro-sign-icon.js.map +0 -1
- package/dist/types/components/icon/icons/circle-euro-sign-icon.d.ts +0 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.cjs","names":["createContext","getDisplayName","createShouldForwardProp","useSystem","useTheme","useComponentStyle","css","Slot"],"sources":["../../../../src/core/system/styled.tsx"],"sourcesContent":["\"use client\"\n\nimport type { EmotionCache, SerializedStyles } from \"@emotion/utils\"\nimport type { FC } from \"react\"\nimport type { Dict } from \"../../utils\"\nimport type { As, ShouldForwardProp, StyledComponent } from \"../components\"\nimport type { CSSModifierObject, CSSPropObject } from \"../css\"\nimport type {\n ColorScheme,\n ComponentStyle,\n System,\n UsageTheme,\n} from \"./index.types\"\nimport { withEmotionCache } from \"@emotion/react\"\nimport { serializeStyles } from \"@emotion/serialize\"\nimport { useInsertionEffectAlwaysWithSyncFallback } from \"@emotion/use-insertion-effect-with-fallbacks\"\nimport {\n getRegisteredStyles,\n insertStyles,\n registerStyles,\n} from \"@emotion/utils\"\nimport { useMemo, useRef } from \"react\"\nimport isEqual from \"react-fast-compare\"\nimport { Slot } from \"../../components/slot\"\nimport {\n createContext,\n createdDom,\n cx,\n filterEmpty,\n filterUndefined,\n isString,\n isUndefined,\n runIfFn,\n splitObject,\n toArray,\n toKebabCase,\n} from \"../../utils\"\nimport {\n createShouldForwardProp,\n getDisplayName,\n useComponentStyle,\n} from \"../components\"\nimport { css } from \"../css\"\nimport { useSystem } from \"./system-provider\"\nimport { useTheme } from \"./theme-provider\"\n\ninterface InsertionProps {\n cache: EmotionCache\n htmlTag: boolean\n serialized: SerializedStyles\n}\n\nconst Insertion: FC<InsertionProps> = ({ cache, htmlTag, serialized }) => {\n registerStyles(cache, serialized, htmlTag)\n\n const style = useInsertionEffectAlwaysWithSyncFallback(() =>\n insertStyles(cache, serialized, htmlTag),\n )\n\n if (!createdDom() && !isUndefined(style)) {\n let className = serialized.name\n let next = serialized.next\n\n while (next !== undefined) {\n className = cx(className, next.name) ?? \"\"\n next = next.next\n }\n\n return (\n <style\n data-emotion={cx(cache.key, className)}\n dangerouslySetInnerHTML={{ __html: style }}\n nonce={cache.sheet.nonce}\n />\n )\n } else {\n return null\n }\n}\n\nconst useSplitProps = <Y extends Dict, M extends Dict>(\n props: Dict,\n shouldForwardProp?: ShouldForwardProp,\n) => {\n const propsRef = useRef(props)\n\n if (!isEqual(propsRef.current, props)) propsRef.current = props\n\n const computedProps = propsRef.current\n\n return useMemo(\n () => splitObject<Y, M>(computedProps, shouldForwardProp),\n [computedProps, shouldForwardProp],\n )\n}\n\nexport const [ColorSchemeContext, useColorSchemeContext] =\n createContext<ColorScheme>({\n name: \"ColorSchemeContext\",\n strict: false,\n })\n\nexport interface StyledOptions<\n Y extends CSSPropObject = CSSPropObject,\n M extends CSSModifierObject = CSSModifierObject,\n D extends CSSModifierObject = CSSModifierObject,\n H extends number | string | symbol = string,\n> extends Omit<ComponentStyle<Y, M, D>, \"className\"> {\n className?: ((system: System) => string) | string\n displayName?: string\n forwardAsChild?: boolean\n name?: string\n shouldForwardProp?: boolean | ShouldForwardProp\n target?: string\n forwardProps?: string[]\n transferProps?: H[]\n}\n\nexport function createStyled<\n Y extends As,\n M extends object = {},\n D extends CSSPropObject = CSSPropObject,\n H extends CSSModifierObject = CSSModifierObject,\n R extends CSSModifierObject = CSSModifierObject,\n>(\n el: Y,\n {\n name,\n base,\n compounds,\n props,\n sizes,\n variants,\n defaultProps,\n transferProps,\n ...options\n }: StyledOptions<D, H, R, keyof M> = {},\n) {\n const displayName = options.displayName ?? getDisplayName(name, \"\")\n const shouldForwardProp = !options.shouldForwardProp\n ? createShouldForwardProp(options.forwardProps)\n : undefined\n const style = filterUndefined({\n base,\n compounds,\n props,\n sizes,\n variants,\n defaultProps,\n })\n\n const StyledComponent = withEmotionCache<Dict>(function (\n { as: Component = el, asChild, children, ...props },\n cache,\n ref,\n ) {\n let className: string | undefined = \"\"\n\n const system = useSystem()\n const { theme } = useTheme<UsageTheme>()\n const componentStyleOptions = {\n name,\n className: system.utils.getClassName(\n runIfFn(options.className, system) ?? toKebabCase(name ?? \"\"),\n ),\n style,\n transferProps,\n }\n const registered = useRef<string[]>([])\n const htmlTag = isString(Component)\n const forwardAsChild =\n options.forwardAsChild || options.forwardProps?.includes(\"asChild\")\n const [omittedProps, styleProps] = useSplitProps(props, shouldForwardProp)\n const [, rest] = useComponentStyle<any, {}>(\n omittedProps,\n componentStyleOptions,\n )\n const [cssArray, colorScheme, forwardProps] = useMemo(() => {\n const { css, colorScheme, ...forwardProps } = rest\n\n return [toArray(css), colorScheme, forwardProps]\n }, [rest])\n\n styleProps.colorScheme ??= colorScheme\n\n if (forwardProps.className)\n className = getRegisteredStyles(\n cache.registered,\n registered.current,\n forwardProps.className,\n ).trim()\n\n const interpolations = useMemo(\n () => [\n ...registered.current,\n ...filterEmpty([...cssArray, styleProps].map(css(system, theme))),\n ],\n [cssArray, system, styleProps, theme],\n )\n\n const serialized = useMemo(\n () => serializeStyles(interpolations, cache.registered),\n [interpolations, cache.registered],\n )\n\n className = cx(\n className,\n serialized.styles ? `${cache.key}-${serialized.name}` : undefined,\n )\n className = cx(className, options.target)\n\n if (!className) className = undefined\n\n const mergedProps = { ...forwardProps, className, children }\n\n return (\n <ColorSchemeContext value={styleProps.colorScheme}>\n <Insertion cache={cache} htmlTag={htmlTag} serialized={serialized} />\n\n {asChild && !forwardAsChild ? (\n <Slot ref={ref} {...mergedProps} />\n ) : (\n <Component ref={ref} {...mergedProps} />\n )}\n </ColorSchemeContext>\n )\n }) as StyledComponent<Y, M>\n\n StyledComponent.displayName = displayName || \"StyledComponent\"\n\n return StyledComponent\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoDA,MAAM,aAAiC,EAAE,OAAO,SAAS,iBAAiB;CACxE,CAAA,GAAA,eAAA,eAAA,CAAe,OAAO,YAAY,OAAO;CAEzC,MAAM,SAAA,GAAA,6CAAA,yCAAA,QAAA,GAAA,eAAA,aAAA,CACS,OAAO,YAAY,OAAO,CACzC;CAEA,IAAI,EAAA,GAAA,oBAAA,cAAA,WAAA,CAAY,KAAK,EAAA,GAAA,oBAAA,cAAA,YAAA,CAAa,KAAK,GAAG;EACxC,IAAI,YAAY,WAAW;EAC3B,IAAI,OAAO,WAAW;EAEtB,OAAO,SAAS,KAAA,GAAW;GACzB,aAAA,GAAA,oBAAA,cAAA,GAAA,CAAe,WAAW,KAAK,IAAI,KAAK;GACxC,OAAO,KAAK;EACd;EAEA,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,SAAD;GACE,iBAAA,GAAA,oBAAA,cAAA,GAAA,CAAiB,MAAM,KAAK,SAAS;GACrC,yBAAyB,EAAE,QAAQ,MAAM;GACzC,OAAO,MAAM,MAAM;EACpB,CAAA;CAEL,OACE,OAAO;AAEX;AAEA,MAAM,iBACJ,OACA,sBACG;CACH,MAAM,YAAA,GAAA,MAAA,OAAA,CAAkB,KAAK;CAE7B,IAAI,EAAA,GAAA,mBAAA,QAAA,CAAS,SAAS,SAAS,KAAK,GAAG,SAAS,UAAU;CAE1D,MAAM,gBAAgB,SAAS;CAE/B,QAAA,GAAA,MAAA,QAAA,QAAA,GAAA,oBAAA,cAAA,YAAA,CAC0B,eAAe,iBAAiB,GACxD,CAAC,eAAe,iBAAiB,CACnC;AACF;AAEA,MAAa,CAAC,oBAAoB,yBAChCA,gBAAAA,cAA2B;CACzB,MAAM;CACN,QAAQ;AACV,CAAC;AAkBH,SAAgB,aAOd,IACA,EACE,MACA,MACA,WACA,OACA,OACA,UACA,cACA,eACA,GAAG,YACgC,CAAC,GACtC;CACA,MAAM,cAAc,QAAQ,eAAeC,cAAAA,eAAe,MAAM,EAAE;CAClE,MAAM,oBAAoB,CAAC,QAAQ,oBAC/BC,cAAAA,wBAAwB,QAAQ,YAAY,IAC5C,KAAA;CACJ,MAAM,SAAA,GAAA,oBAAA,cAAA,gBAAA,CAAwB;EAC5B;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;CAED,MAAM,mBAAA,GAAA,eAAA,iBAAA,CAAyC,SAC7C,EAAE,IAAI,YAAY,IAAI,SAAS,UAAU,GAAG,SAC5C,OACA,KACA;EACA,IAAI,YAAgC;EAEpC,MAAM,SAASC,wBAAAA,UAAU;EACzB,MAAM,EAAE,UAAUC,uBAAAA,SAAqB;EACvC,MAAM,wBAAwB;GAC5B;GACA,WAAW,OAAO,MAAM,cAAA,GAAA,oBAAA,cAAA,QAAA,CACd,QAAQ,WAAW,MAAM,MAAA,GAAA,oBAAA,cAAA,YAAA,CAAiB,QAAQ,EAAE,CAC9D;GACA;GACA;EACF;EACA,MAAM,cAAA,GAAA,MAAA,OAAA,CAA8B,CAAC,CAAC;EACtC,MAAM,WAAA,GAAA,oBAAA,cAAA,SAAA,CAAmB,SAAS;EAClC,MAAM,iBACJ,QAAQ,kBAAkB,QAAQ,cAAc,SAAS,SAAS;EACpE,MAAM,CAAC,cAAc,cAAc,cAAc,OAAO,iBAAiB;EACzE,MAAM,GAAG,QAAQC,4BAAAA,kBACf,cACA,qBACF;EACA,MAAM,CAAC,UAAU,aAAa,iBAAA,GAAA,MAAA,QAAA,OAA8B;GAC1D,MAAM,EAAE,KAAK,aAAa,GAAG,iBAAiB;GAE9C,OAAO;
|
|
1
|
+
{"version":3,"file":"styled.cjs","names":["createContext","getDisplayName","createShouldForwardProp","useSystem","useTheme","useComponentStyle","css","Slot"],"sources":["../../../../src/core/system/styled.tsx"],"sourcesContent":["\"use client\"\n\nimport type { EmotionCache, SerializedStyles } from \"@emotion/utils\"\nimport type { FC } from \"react\"\nimport type { Dict } from \"../../utils\"\nimport type { As, ShouldForwardProp, StyledComponent } from \"../components\"\nimport type { CSSModifierObject, CSSPropObject } from \"../css\"\nimport type {\n ColorScheme,\n ComponentStyle,\n System,\n UsageTheme,\n} from \"./index.types\"\nimport { withEmotionCache } from \"@emotion/react\"\nimport { serializeStyles } from \"@emotion/serialize\"\nimport { useInsertionEffectAlwaysWithSyncFallback } from \"@emotion/use-insertion-effect-with-fallbacks\"\nimport {\n getRegisteredStyles,\n insertStyles,\n registerStyles,\n} from \"@emotion/utils\"\nimport { useMemo, useRef } from \"react\"\nimport isEqual from \"react-fast-compare\"\nimport { Slot } from \"../../components/slot\"\nimport {\n createContext,\n createdDom,\n cx,\n filterEmpty,\n filterUndefined,\n isString,\n isUndefined,\n runIfFn,\n splitObject,\n toArray,\n toKebabCase,\n} from \"../../utils\"\nimport {\n createShouldForwardProp,\n getDisplayName,\n useComponentStyle,\n} from \"../components\"\nimport { css } from \"../css\"\nimport { useSystem } from \"./system-provider\"\nimport { useTheme } from \"./theme-provider\"\n\ninterface InsertionProps {\n cache: EmotionCache\n htmlTag: boolean\n serialized: SerializedStyles\n}\n\nconst Insertion: FC<InsertionProps> = ({ cache, htmlTag, serialized }) => {\n registerStyles(cache, serialized, htmlTag)\n\n const style = useInsertionEffectAlwaysWithSyncFallback(() =>\n insertStyles(cache, serialized, htmlTag),\n )\n\n if (!createdDom() && !isUndefined(style)) {\n let className = serialized.name\n let next = serialized.next\n\n while (next !== undefined) {\n className = cx(className, next.name) ?? \"\"\n next = next.next\n }\n\n return (\n <style\n data-emotion={cx(cache.key, className)}\n dangerouslySetInnerHTML={{ __html: style }}\n nonce={cache.sheet.nonce}\n />\n )\n } else {\n return null\n }\n}\n\nconst useSplitProps = <Y extends Dict, M extends Dict>(\n props: Dict,\n shouldForwardProp?: ShouldForwardProp,\n) => {\n const propsRef = useRef(props)\n\n if (!isEqual(propsRef.current, props)) propsRef.current = props\n\n const computedProps = propsRef.current\n\n return useMemo(\n () => splitObject<Y, M>(computedProps, shouldForwardProp),\n [computedProps, shouldForwardProp],\n )\n}\n\nexport const [ColorSchemeContext, useColorSchemeContext] =\n createContext<ColorScheme>({\n name: \"ColorSchemeContext\",\n strict: false,\n })\n\nexport interface StyledOptions<\n Y extends CSSPropObject = CSSPropObject,\n M extends CSSModifierObject = CSSModifierObject,\n D extends CSSModifierObject = CSSModifierObject,\n H extends number | string | symbol = string,\n> extends Omit<ComponentStyle<Y, M, D>, \"className\"> {\n className?: ((system: System) => string) | string\n displayName?: string\n forwardAsChild?: boolean\n name?: string\n shouldForwardProp?: boolean | ShouldForwardProp\n target?: string\n forwardProps?: string[]\n transferProps?: H[]\n}\n\nexport function createStyled<\n Y extends As,\n M extends object = {},\n D extends CSSPropObject = CSSPropObject,\n H extends CSSModifierObject = CSSModifierObject,\n R extends CSSModifierObject = CSSModifierObject,\n>(\n el: Y,\n {\n name,\n base,\n compounds,\n props,\n sizes,\n variants,\n defaultProps,\n transferProps,\n ...options\n }: StyledOptions<D, H, R, keyof M> = {},\n) {\n const displayName = options.displayName ?? getDisplayName(name, \"\")\n const shouldForwardProp = !options.shouldForwardProp\n ? createShouldForwardProp(options.forwardProps)\n : undefined\n const style = filterUndefined({\n base,\n compounds,\n props,\n sizes,\n variants,\n defaultProps,\n })\n\n const StyledComponent = withEmotionCache<Dict>(function (\n { as: Component = el, asChild, children, ...props },\n cache,\n ref,\n ) {\n let className: string | undefined = \"\"\n\n const system = useSystem()\n const { theme } = useTheme<UsageTheme>()\n const componentStyleOptions = {\n name,\n className: system.utils.getClassName(\n runIfFn(options.className, system) ?? toKebabCase(name ?? \"\"),\n ),\n style,\n transferProps,\n }\n const registered = useRef<string[]>([])\n const htmlTag = isString(Component)\n const forwardAsChild =\n options.forwardAsChild || options.forwardProps?.includes(\"asChild\")\n const [omittedProps, styleProps] = useSplitProps(props, shouldForwardProp)\n const [, rest] = useComponentStyle<any, {}>(\n omittedProps,\n componentStyleOptions,\n )\n const [cssArray, colorScheme, forwardProps] = useMemo(() => {\n const { css, colorScheme, ...forwardProps } = rest\n\n return [toArray(css), colorScheme, forwardProps]\n }, [rest])\n\n styleProps.colorScheme ??= colorScheme\n\n if (forwardProps.className)\n className = getRegisteredStyles(\n cache.registered,\n registered.current,\n forwardProps.className,\n ).trim()\n\n const interpolations = useMemo(\n () => [\n ...registered.current,\n ...filterEmpty([...cssArray, styleProps].map(css(system, theme))),\n ],\n [cssArray, system, styleProps, theme],\n )\n\n const serialized = useMemo(\n () => serializeStyles(interpolations, cache.registered),\n [interpolations, cache.registered],\n )\n\n className = cx(\n className,\n serialized.styles ? `${cache.key}-${serialized.name}` : undefined,\n )\n className = cx(className, options.target)\n\n if (!className) className = undefined\n\n const mergedProps = { ...forwardProps, className, children }\n\n return (\n <ColorSchemeContext value={styleProps.colorScheme}>\n <Insertion cache={cache} htmlTag={htmlTag} serialized={serialized} />\n\n {asChild && !forwardAsChild ? (\n <Slot ref={ref} {...mergedProps} />\n ) : (\n <Component ref={ref} {...mergedProps} />\n )}\n </ColorSchemeContext>\n )\n }) as StyledComponent<Y, M>\n\n StyledComponent.displayName = displayName || \"StyledComponent\"\n\n return StyledComponent\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoDA,MAAM,aAAiC,EAAE,OAAO,SAAS,iBAAiB;CACxE,CAAA,GAAA,eAAA,eAAA,CAAe,OAAO,YAAY,OAAO;CAEzC,MAAM,SAAA,GAAA,6CAAA,yCAAA,QAAA,GAAA,eAAA,aAAA,CACS,OAAO,YAAY,OAAO,CACzC;CAEA,IAAI,EAAA,GAAA,oBAAA,cAAA,WAAA,CAAY,KAAK,EAAA,GAAA,oBAAA,cAAA,YAAA,CAAa,KAAK,GAAG;EACxC,IAAI,YAAY,WAAW;EAC3B,IAAI,OAAO,WAAW;EAEtB,OAAO,SAAS,KAAA,GAAW;GACzB,aAAA,GAAA,oBAAA,cAAA,GA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cAAA,GAAA,CAAe,WAAW,QAAQ,MAAM;EAExC,IAAI,CAAC,WAAW,YAAY,KAAA;EAE5B,MAAM,cAAc;GAAE,GAAG;GAAc;GAAW;EAAS;EAE3D,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,oBAAD;GAAoB,OAAO,WAAW;GAAtC,UAAA,CACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;IAAkB;IAAgB;IAAqB;GAAa,CAAA,GAEnE,WAAW,CAAC,iBACX,iBAAA,GAAA,kBAAA,IAAA,CAACC,aAAAA,MAAD;IAAW;IAAK,GAAI;GAAc,CAAA,IAElC,iBAAA,GAAA,kBAAA,IAAA,CAAC,WAAD;IAAgB;IAAK,GAAI;GAAc,CAAA,CAEvB;;CAExB,CAAC;CAED,gBAAgB,cAAc,eAAe;CAE7C,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-provider.cjs","names":["THEME_SCHEME_STORAGE_KEY","createStorageManager","useEnvironment","EmotionThemeProvider","useSystem","css","Global","createVarRules","ThemeContext"],"sources":["../../../../src/core/system/theme-provider.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ThemeProviderProps as EmotionThemeProviderProps } from \"@emotion/react\"\nimport type { FC, PropsWithChildren } from \"react\"\nimport type { Environment } from \"./environment-provider\"\nimport type {\n ChangeThemeScheme,\n StyledTheme,\n Theme,\n ThemeConfig,\n ThemeScheme,\n UsageTheme,\n} from \"./index.types\"\nimport type { Storage } from \"./storage-manager\"\nimport {\n ThemeProvider as EmotionThemeProvider,\n Global,\n ThemeContext,\n} from \"@emotion/react\"\nimport { use, useCallback, useEffect, useMemo, useState } from \"react\"\nimport {\n isEmptyObject,\n isObject,\n isShadowRoot,\n isUndefined,\n merge,\n} from \"../../utils\"\nimport { THEME_SCHEME_STORAGE_KEY } from \"../constant\"\nimport { css } from \"../css\"\nimport { useEnvironment } from \"./environment-provider\"\nimport { createStorageManager } from \"./storage-manager\"\nimport { useSystem } from \"./system-provider\"\nimport { createVarRules } from \"./var\"\n\nexport const getPreventTransition = (environment: Environment) => {\n const win = environment.getWindow()\n const doc = environment.getDocument()\n const root = environment.getRootElement()\n const rootNode = environment.getRootNode()\n\n if (!win || !doc || !root) return\n\n const css = doc.createElement(\"style\")\n const shadowRoot = isShadowRoot(rootNode)\n const selector = shadowRoot ? \":host, *\" : \"*\"\n const container = shadowRoot ? rootNode : doc.head\n\n const node = doc.createTextNode(\n `${selector}{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`,\n )\n\n css.appendChild(node)\n\n container.appendChild(css)\n\n return () => {\n const forceReflow = () => win.getComputedStyle(root)\n\n forceReflow()\n\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n container.removeChild(css)\n })\n })\n }\n}\n\nexport interface ThemeProviderProps\n extends\n PropsWithChildren,\n Omit<EmotionThemeProviderProps, \"children\" | \"theme\"> {\n /**\n * The config of the yamada ui.\n */\n config?: ThemeConfig\n /**\n * If `storage` is `cookie`, the cookie to use.\n * If not provided, the cookie will be set to `document.cookie`.\n */\n cookie?: string\n /**\n * The storage to use.\n * If you are using a server-side rendering library, you should use `cookie`.\n *\n * @default 'localStorage'\n */\n storage?: Storage\n /**\n * Key of value saved in storage.\n * By default, it is saved to `local storage`.\n */\n storageKey?: string\n /**\n * The theme of the yamada ui.\n */\n theme?: UsageTheme\n}\n\nexport const ThemeProvider: FC<ThemeProviderProps> = ({\n children,\n config,\n cookie,\n storage = cookie ? \"cookie\" : \"localStorage\",\n storageKey = THEME_SCHEME_STORAGE_KEY,\n theme = {},\n}) => {\n const { defaultThemeScheme = \"base\", disableTransitionOnChange } =\n config ?? {}\n const storageManager = useMemo(\n () => createStorageManager(storage, storageKey, defaultThemeScheme, cookie),\n [cookie, defaultThemeScheme, storage, storageKey],\n )\n const environment = useEnvironment()\n const [themeScheme, setThemeScheme] = useState<ThemeScheme>(\n storageManager.get(),\n )\n\n const changeThemeScheme: ChangeThemeScheme = useCallback(\n (themeScheme) => {\n const root = environment.getRootElement()\n\n const cleanup = disableTransitionOnChange\n ? getPreventTransition(environment)\n : undefined\n\n if (root) root.dataset.theme = themeScheme\n\n cleanup?.()\n\n setThemeScheme(themeScheme)\n\n storageManager.set(themeScheme)\n },\n [disableTransitionOnChange, environment, storageManager],\n )\n\n useEffect(() => {\n const themeScheme = storageManager.get()\n\n changeThemeScheme(themeScheme)\n }, [changeThemeScheme, storageManager])\n\n return (\n <EmotionThemeProvider theme={{ changeThemeScheme, themeScheme, ...theme }}>\n <GlobalStyles />\n\n {children}\n </EmotionThemeProvider>\n )\n}\n\nexport const GlobalStyles: FC = () => {\n const system = useSystem()\n const { theme } = useTheme<UsageTheme>()\n const { atRule, wrap } = system.layers\n\n const resetStyle = useMemo(() => {\n const style = theme.styles?.resetStyle\n\n if (!style || isEmptyObject(style)) return undefined\n\n return css(system, theme)(style)\n }, [system, theme])\n\n const globalStyle = useMemo(() => {\n const style = theme.styles?.globalStyle\n\n if (!style || isEmptyObject(style)) return undefined\n\n return css(system, theme)(style)\n }, [system, theme])\n\n const varRules = useMemo(() => {\n return createVarRules(\n system.config.css?.varRoot ?? \":host, :root\",\n system.cssVars,\n )\n }, [system])\n\n return (\n <Global\n styles={[\n atRule,\n wrap(\"tokens\", varRules),\n wrap(\"reset\", resetStyle),\n wrap(\"global\", globalStyle),\n ]}\n />\n )\n}\n\n/**\n * `useTheme` is a custom hook that returns a function for retrieving and switching themes.\n *\n * @see https://yamada-ui.com/docs/hooks/use-theme\n */\nexport const useTheme = <Y extends UsageTheme = Theme>() => {\n const internalTheme = use(ThemeContext) as StyledTheme<Y>\n\n const theme = useMemo(() => {\n const { themeScheme } = internalTheme\n\n if (isUndefined(themeScheme) || themeScheme === \"base\") return internalTheme\n\n const nestedTheme =\n \"themeSchemes\" in internalTheme && isObject(internalTheme.themeSchemes)\n ? internalTheme.themeSchemes[themeScheme as string]\n : undefined\n\n if (!nestedTheme) return internalTheme\n\n return merge<StyledTheme<Y>>(internalTheme, nestedTheme)\n }, [internalTheme])\n\n const value = useMemo(() => {\n const { changeThemeScheme, themeScheme } = internalTheme\n\n return {\n changeThemeScheme,\n internalTheme,\n theme,\n themeScheme,\n }\n }, [theme, internalTheme])\n\n return value\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,MAAa,wBAAwB,gBAA6B;CAChE,MAAM,MAAM,YAAY,UAAU;CAClC,MAAM,MAAM,YAAY,YAAY;CACpC,MAAM,OAAO,YAAY,eAAe;CACxC,MAAM,WAAW,YAAY,YAAY;CAEzC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM;CAE3B,MAAM,MAAM,IAAI,cAAc,OAAO;CACrC,MAAM,cAAA,GAAA,oBAAA,cAAA,aAAA,CAA0B,QAAQ;CACxC,MAAM,WAAW,aAAa,aAAa;CAC3C,MAAM,YAAY,aAAa,WAAW,IAAI;CAE9C,MAAM,OAAO,IAAI,eACf,GAAG,SAAS,wJACd;CAEA,IAAI,YAAY,IAAI;CAEpB,UAAU,YAAY,GAAG;CAEzB,aAAa;EACX,MAAM,oBAAoB,IAAI,iBAAiB,IAAI;EAEnD,YAAY;EAEZ,4BAA4B;GAC1B,4BAA4B;IAC1B,UAAU,YAAY,GAAG;GAC3B,CAAC;EACH,CAAC;CACH;AACF;AAiCA,MAAa,iBAAyC,EACpD,UACA,QACA,QACA,UAAU,SAAS,WAAW,gBAC9B,aAAaA,iBAAAA,0BACb,QAAQ,CAAC,QACL;CACJ,MAAM,EAAE,qBAAqB,QAAQ,8BACnC,UAAU,CAAC;CACb,MAAM,kBAAA,GAAA,MAAA,QAAA,OACEC,wBAAAA,qBAAqB,SAAS,YAAY,oBAAoB,MAAM,GAC1E;EAAC;EAAQ;EAAoB;EAAS;CAAU,CAClD;CACA,MAAM,cAAcC,6BAAAA,eAAe;CACnC,MAAM,CAAC,aAAa,mBAAA,GAAA,MAAA,SAAA,CAClB,eAAe,IAAI,CACrB;CAEA,MAAM,qBAAA,GAAA,MAAA,YAAA,EACH,gBAAgB;EACf,MAAM,OAAO,YAAY,eAAe;EAExC,MAAM,UAAU,4BACZ,qBAAqB,WAAW,IAChC,KAAA;EAEJ,IAAI,MAAM,KAAK,QAAQ,QAAQ;EAE/B,UAAU;EAEV,eAAe,WAAW;EAE1B,eAAe,IAAI,WAAW;CAChC,GACA;EAAC;EAA2B;EAAa;CAAc,CACzD;CAEA,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,MAAM,cAAc,eAAe,IAAI;EAEvC,kBAAkB,WAAW;CAC/B,GAAG,CAAC,mBAAmB,cAAc,CAAC;CAEtC,OACE,iBAAA,GAAA,kBAAA,KAAA,CAACC,eAAAA,eAAD;EAAsB,OAAO;GAAE;GAAmB;GAAa,GAAG;EAAM;
|
|
1
|
+
{"version":3,"file":"theme-provider.cjs","names":["THEME_SCHEME_STORAGE_KEY","createStorageManager","useEnvironment","EmotionThemeProvider","useSystem","css","Global","createVarRules","ThemeContext"],"sources":["../../../../src/core/system/theme-provider.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ThemeProviderProps as EmotionThemeProviderProps } from \"@emotion/react\"\nimport type { FC, PropsWithChildren } from \"react\"\nimport type { Environment } from \"./environment-provider\"\nimport type {\n ChangeThemeScheme,\n StyledTheme,\n Theme,\n ThemeConfig,\n ThemeScheme,\n UsageTheme,\n} from \"./index.types\"\nimport type { Storage } from \"./storage-manager\"\nimport {\n ThemeProvider as EmotionThemeProvider,\n Global,\n ThemeContext,\n} from \"@emotion/react\"\nimport { use, useCallback, useEffect, useMemo, useState } from \"react\"\nimport {\n isEmptyObject,\n isObject,\n isShadowRoot,\n isUndefined,\n merge,\n} from \"../../utils\"\nimport { THEME_SCHEME_STORAGE_KEY } from \"../constant\"\nimport { css } from \"../css\"\nimport { useEnvironment } from \"./environment-provider\"\nimport { createStorageManager } from \"./storage-manager\"\nimport { useSystem } from \"./system-provider\"\nimport { createVarRules } from \"./var\"\n\nexport const getPreventTransition = (environment: Environment) => {\n const win = environment.getWindow()\n const doc = environment.getDocument()\n const root = environment.getRootElement()\n const rootNode = environment.getRootNode()\n\n if (!win || !doc || !root) return\n\n const css = doc.createElement(\"style\")\n const shadowRoot = isShadowRoot(rootNode)\n const selector = shadowRoot ? \":host, *\" : \"*\"\n const container = shadowRoot ? rootNode : doc.head\n\n const node = doc.createTextNode(\n `${selector}{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}`,\n )\n\n css.appendChild(node)\n\n container.appendChild(css)\n\n return () => {\n const forceReflow = () => win.getComputedStyle(root)\n\n forceReflow()\n\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n container.removeChild(css)\n })\n })\n }\n}\n\nexport interface ThemeProviderProps\n extends\n PropsWithChildren,\n Omit<EmotionThemeProviderProps, \"children\" | \"theme\"> {\n /**\n * The config of the yamada ui.\n */\n config?: ThemeConfig\n /**\n * If `storage` is `cookie`, the cookie to use.\n * If not provided, the cookie will be set to `document.cookie`.\n */\n cookie?: string\n /**\n * The storage to use.\n * If you are using a server-side rendering library, you should use `cookie`.\n *\n * @default 'localStorage'\n */\n storage?: Storage\n /**\n * Key of value saved in storage.\n * By default, it is saved to `local storage`.\n */\n storageKey?: string\n /**\n * The theme of the yamada ui.\n */\n theme?: UsageTheme\n}\n\nexport const ThemeProvider: FC<ThemeProviderProps> = ({\n children,\n config,\n cookie,\n storage = cookie ? \"cookie\" : \"localStorage\",\n storageKey = THEME_SCHEME_STORAGE_KEY,\n theme = {},\n}) => {\n const { defaultThemeScheme = \"base\", disableTransitionOnChange } =\n config ?? {}\n const storageManager = useMemo(\n () => createStorageManager(storage, storageKey, defaultThemeScheme, cookie),\n [cookie, defaultThemeScheme, storage, storageKey],\n )\n const environment = useEnvironment()\n const [themeScheme, setThemeScheme] = useState<ThemeScheme>(\n storageManager.get(),\n )\n\n const changeThemeScheme: ChangeThemeScheme = useCallback(\n (themeScheme) => {\n const root = environment.getRootElement()\n\n const cleanup = disableTransitionOnChange\n ? getPreventTransition(environment)\n : undefined\n\n if (root) root.dataset.theme = themeScheme\n\n cleanup?.()\n\n setThemeScheme(themeScheme)\n\n storageManager.set(themeScheme)\n },\n [disableTransitionOnChange, environment, storageManager],\n )\n\n useEffect(() => {\n const themeScheme = storageManager.get()\n\n changeThemeScheme(themeScheme)\n }, [changeThemeScheme, storageManager])\n\n return (\n <EmotionThemeProvider theme={{ changeThemeScheme, themeScheme, ...theme }}>\n <GlobalStyles />\n\n {children}\n </EmotionThemeProvider>\n )\n}\n\nexport const GlobalStyles: FC = () => {\n const system = useSystem()\n const { theme } = useTheme<UsageTheme>()\n const { atRule, wrap } = system.layers\n\n const resetStyle = useMemo(() => {\n const style = theme.styles?.resetStyle\n\n if (!style || isEmptyObject(style)) return undefined\n\n return css(system, theme)(style)\n }, [system, theme])\n\n const globalStyle = useMemo(() => {\n const style = theme.styles?.globalStyle\n\n if (!style || isEmptyObject(style)) return undefined\n\n return css(system, theme)(style)\n }, [system, theme])\n\n const varRules = useMemo(() => {\n return createVarRules(\n system.config.css?.varRoot ?? \":host, :root\",\n system.cssVars,\n )\n }, [system])\n\n return (\n <Global\n styles={[\n atRule,\n wrap(\"tokens\", varRules),\n wrap(\"reset\", resetStyle),\n wrap(\"global\", globalStyle),\n ]}\n />\n )\n}\n\n/**\n * `useTheme` is a custom hook that returns a function for retrieving and switching themes.\n *\n * @see https://yamada-ui.com/docs/hooks/use-theme\n */\nexport const useTheme = <Y extends UsageTheme = Theme>() => {\n const internalTheme = use(ThemeContext) as StyledTheme<Y>\n\n const theme = useMemo(() => {\n const { themeScheme } = internalTheme\n\n if (isUndefined(themeScheme) || themeScheme === \"base\") return internalTheme\n\n const nestedTheme =\n \"themeSchemes\" in internalTheme && isObject(internalTheme.themeSchemes)\n ? internalTheme.themeSchemes[themeScheme as string]\n : undefined\n\n if (!nestedTheme) return internalTheme\n\n return merge<StyledTheme<Y>>(internalTheme, nestedTheme)\n }, [internalTheme])\n\n const value = useMemo(() => {\n const { changeThemeScheme, themeScheme } = internalTheme\n\n return {\n changeThemeScheme,\n internalTheme,\n theme,\n themeScheme,\n }\n }, [theme, internalTheme])\n\n return value\n}\n"],"mappings":";;;;;;;;;;;;AAkCA,MAAa,wBAAwB,gBAA6B;CAChE,MAAM,MAAM,YAAY,UAAU;CAClC,MAAM,MAAM,YAAY,YAAY;CACpC,MAAM,OAAO,YAAY,eAAe;CACxC,MAAM,WAAW,YAAY,YAAY;CAEzC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM;CAE3B,MAAM,MAAM,IAAI,cAAc,OAAO;CACrC,MAAM,cAAA,GAAA,oBAAA,cAAA,aAAA,CAA0B,QAAQ;CACxC,MAAM,WAAW,aAAa,aAAa;CAC3C,MAAM,YAAY,aAAa,WAAW,IAAI;CAE9C,MAAM,OAAO,IAAI,eACf,GAAG,SAAS,wJACd;CAEA,IAAI,YAAY,IAAI;CAEpB,UAAU,YAAY,GAAG;CAEzB,aAAa;EACX,MAAM,oBAAoB,IAAI,iBAAiB,IAAI;EAEnD,YAAY;EAEZ,4BAA4B;GAC1B,4BAA4B;IAC1B,UAAU,YAAY,GAAG;GAC3B,CAAC;EACH,CAAC;CACH;AACF;AAiCA,MAAa,iBAAyC,EACpD,UACA,QACA,QACA,UAAU,SAAS,WAAW,gBAC9B,aAAaA,iBAAAA,0BACb,QAAQ,CAAC,QACL;CACJ,MAAM,EAAE,qBAAqB,QAAQ,8BACnC,UAAU,CAAC;CACb,MAAM,kBAAA,GAAA,MAAA,QAAA,OACEC,wBAAAA,qBAAqB,SAAS,YAAY,oBAAoB,MAAM,GAC1E;EAAC;EAAQ;EAAoB;EAAS;CAAU,CAClD;CACA,MAAM,cAAcC,6BAAAA,eAAe;CACnC,MAAM,CAAC,aAAa,mBAAA,GAAA,MAAA,SAAA,CAClB,eAAe,IAAI,CACrB;CAEA,MAAM,qBAAA,GAAA,MAAA,YAAA,EACH,gBAAgB;EACf,MAAM,OAAO,YAAY,eAAe;EAExC,MAA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,QAAA,OAXoB;GAC7B,OAAOC,YAAAA,eACL,OAAO,OAAO,KAAK,WAAW,gBAC9B,OAAO,OACT;EACF,GAAG,CAAC,MAAM,CAMkB,CAAC;EACvB,KAAK,SAAS,UAAU;EACxB,KAAK,UAAU,WAAW;CAC5B,EACD,CAAA;AAEL;;;;;;AAOA,MAAa,iBAA+C;CAC1D,MAAM,iBAAA,GAAA,MAAA,IAAA,CAAoBC,eAAAA,YAAY;CAEtC,MAAM,SAAA,GAAA,MAAA,QAAA,OAAsB;EAC1B,MAAM,EAAE,gBAAgB;EAExB,KAAA,GAAA,oBAAA,cAAA,YAAA,CAAgB,WAAW,KAAK,gBAAgB,QAAQ,OAAO;EAE/D,MAAM,cACJ,kBAAkB,kBAAA,GAAA,oBAAA,cAAA,SAAA,CAA0B,cAAc,YAAY,IAClE,cAAc,aAAa,eAC3B,KAAA;EAEN,IAAI,CAAC,aAAa,OAAO;EAEzB,QAAA,GAAA,oBAAA,cAAA,MAAA,CAA6B,eAAe,WAAW;CACzD,GAAG,CAAC,aAAa,CAAC;CAalB,QAAA,GAAA,MAAA,QAAA,OAX4B;EAC1B,MAAM,EAAE,mBAAmB,gBAAgB;EAE3C,OAAO;GACL;GACA;GACA;GACA;EACF;CACF,GAAG,CAAC,OAAO,aAAa,CAEb;AACb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useLoading","useProcessing","useCallbackRef"],"sources":["../../../../src/hooks/use-async-callback/index.ts"],"sourcesContent":["import type { DependencyList } from \"react\"\nimport type { Loading } from \"../../components/loading\"\nimport { useCallback, useMemo } from \"react\"\nimport { useLoading } from \"../../components/loading\"\nimport { useCallbackRef } from \"../../utils/ref\"\nimport { useProcessing } from \"../use-processing\"\n\ntype Callback = (...args: any[]) => any\n\nexport interface UseAsyncCallbackOptions {\n /**\n * The method to use for loading.\n * If `false`, the loading will not be shown.\n */\n loading?: false | Loading.Method\n /**\n * The options to pass to the loading component.\n */\n loadingOptions?: Loading.Options\n /**\n * If `false`, the processing will not change.\n *\n * @default true\n */\n processing?: boolean\n}\n\n/**\n * `useAsyncCallback` is a custom hook used to manage async callbacks.\n *\n * @see https://yamada-ui.com/docs/hooks/use-async-callback\n */\nexport const useAsyncCallback = <Y extends Callback>(\n callback: Y,\n deps: DependencyList,\n {\n loading: method = false,\n loadingOptions,\n processing: shouldProcessing = true,\n }: UseAsyncCallbackOptions = {},\n): UseAsyncCallbackReturn<Y> => {\n const context = useLoading()\n const { finish, loading, start } = useProcessing()\n const shouldLoading = !!method\n const callbackRef = useCallbackRef(callback, deps)\n\n const asyncCallback = useCallback(\n async (...args: Parameters<Y>) => {\n try {\n if (shouldProcessing) start()\n if (shouldLoading) context[method].start(loadingOptions)\n\n return await callbackRef(...args)\n } finally {\n if (shouldProcessing) finish()\n if (shouldLoading) context[method].finish()\n }\n },\n [\n callbackRef,\n shouldProcessing,\n shouldLoading,\n context,\n method,\n loadingOptions,\n start,\n finish,\n ],\n )\n\n const control = useMemo(() => ({ finish, start }), [finish, start])\n\n return [loading, asyncCallback, control]\n}\n\nexport type UseAsyncCallbackReturn<Y extends Callback> = [\n loading: boolean,\n callback: (...args: Parameters<Y>) => Promise<Awaited<ReturnType<Y>>>,\n control: { finish: () => void; start: () => void },\n]\n"],"mappings":";;;;;;;;;;;AAgCA,MAAa,oBACX,UACA,MACA,EACE,SAAS,SAAS,OAClB,gBACA,YAAY,mBAAmB,SACJ,CAAC,MACA;CAC9B,MAAM,UAAUA,yBAAAA,WAAW;CAC3B,MAAM,EAAE,QAAQ,SAAS,UAAUC,mCAAAA,cAAc;CACjD,MAAM,gBAAgB,CAAC,CAAC;CACxB,MAAM,cAAcC,YAAAA,eAAe,UAAU,IAAI;CA4BjD,OAAO;EAAC;
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useLoading","useProcessing","useCallbackRef"],"sources":["../../../../src/hooks/use-async-callback/index.ts"],"sourcesContent":["import type { DependencyList } from \"react\"\nimport type { Loading } from \"../../components/loading\"\nimport { useCallback, useMemo } from \"react\"\nimport { useLoading } from \"../../components/loading\"\nimport { useCallbackRef } from \"../../utils/ref\"\nimport { useProcessing } from \"../use-processing\"\n\ntype Callback = (...args: any[]) => any\n\nexport interface UseAsyncCallbackOptions {\n /**\n * The method to use for loading.\n * If `false`, the loading will not be shown.\n */\n loading?: false | Loading.Method\n /**\n * The options to pass to the loading component.\n */\n loadingOptions?: Loading.Options\n /**\n * If `false`, the processing will not change.\n *\n * @default true\n */\n processing?: boolean\n}\n\n/**\n * `useAsyncCallback` is a custom hook used to manage async callbacks.\n *\n * @see https://yamada-ui.com/docs/hooks/use-async-callback\n */\nexport const useAsyncCallback = <Y extends Callback>(\n callback: Y,\n deps: DependencyList,\n {\n loading: method = false,\n loadingOptions,\n processing: shouldProcessing = true,\n }: UseAsyncCallbackOptions = {},\n): UseAsyncCallbackReturn<Y> => {\n const context = useLoading()\n const { finish, loading, start } = useProcessing()\n const shouldLoading = !!method\n const callbackRef = useCallbackRef(callback, deps)\n\n const asyncCallback = useCallback(\n async (...args: Parameters<Y>) => {\n try {\n if (shouldProcessing) start()\n if (shouldLoading) context[method].start(loadingOptions)\n\n return await callbackRef(...args)\n } finally {\n if (shouldProcessing) finish()\n if (shouldLoading) context[method].finish()\n }\n },\n [\n callbackRef,\n shouldProcessing,\n shouldLoading,\n context,\n method,\n loadingOptions,\n start,\n finish,\n ],\n )\n\n const control = useMemo(() => ({ finish, start }), [finish, start])\n\n return [loading, asyncCallback, control]\n}\n\nexport type UseAsyncCallbackReturn<Y extends Callback> = [\n loading: boolean,\n callback: (...args: Parameters<Y>) => Promise<Awaited<ReturnType<Y>>>,\n control: { finish: () => void; start: () => void },\n]\n"],"mappings":";;;;;;;;;;;AAgCA,MAAa,oBACX,UACA,MACA,EACE,SAAS,SAAS,OAClB,gBACA,YAAY,mBAAmB,SACJ,CAAC,MACA;CAC9B,MAAM,UAAUA,yBAAAA,WAAW;CAC3B,MAAM,EAAE,QAAQ,SAAS,UAAUC,mCAAAA,cAAc;CACjD,MAAM,gBAAgB,CAAC,CAAC;CACxB,MAAM,cAAcC,YAAAA,eAAe,UAAU,IAAI;CA4BjD,OAAO;EAAC;GAzBN,GAAA,MAAA,YAAA,CAAA,OAAO,GAAG,SAAwB;GAChC,IAAI;IACF,IAAI,kBAAkB,MAAM;IAC5B,IAAI,eAAe,QAAQ,OAAO,CAAC,MAAM,cAAc;IAEvD,OAAO,MAAM,YAAY,GAAG,IAAI;GAClC,UAAU;IACR,IAAI,kBAAkB,OAAO;IAC7B,IAAI,eAAe,QAAQ,OAAO,CAAC,OAAO;GAC5C;EACF,GACA;GACE;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAK2B;GAFE,GAAA,MAAA,QAAA,QAAA;GAAE;GAAQ;EAAM,IAAI,CAAC,QAAQ,KAAK,CAE3B;CAAC;AACzC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-breakpoint.cjs","names":["useSystem","useEnvironment"],"sources":["../../../../src/hooks/use-breakpoint/use-breakpoint.ts"],"sourcesContent":["\"use client\"\n\nimport type { Breakpoint } from \"../../core\"\nimport { useCallback, useMemo, useRef, useSyncExternalStore } from \"react\"\nimport { useEnvironment, useSystem } from \"../../core\"\nimport { createdDom, isUndefined, noop } from \"../../utils\"\n\n/**\n * `useBreakpoint` is a custom hook that returns the current breakpoint.\n * This hook monitors changes in the window size and returns the appropriate value.\n *\n * @see https://yamada-ui.com/docs/hooks/use-breakpoint\n */\nexport const useBreakpoint = () => {\n const animationFrameId = useRef(0)\n const { breakpoints, config } = useSystem()\n const { getWindow } = useEnvironment()\n const {\n containerRef,\n direction = \"down\",\n identifier = \"@media screen\",\n } = config.breakpoint ?? {}\n const hasContainer = !!containerRef\n\n const queries = useMemo(() => {\n return breakpoints.queries.map(\n ({ breakpoint, maxW, minMaxQuery, minW }) => {\n const searchValue =\n identifier === \"@media screen\"\n ? \"@media screen and \"\n : `${identifier} `\n const query = minMaxQuery?.replace(searchValue, \"\") ?? \"\"\n\n return {\n breakpoint,\n maxW,\n minW,\n query,\n }\n },\n )\n }, [breakpoints, identifier])\n\n const hasQueries = !!queries.length\n\n const getBreakpoint = useCallback(\n (width?: number) => {\n if (isUndefined(width)) {\n const win = getWindow()\n\n if (hasContainer || !hasQueries) return \"base\"\n\n for (const { breakpoint, query } of queries) {\n const mql = win?.matchMedia(query)\n\n if (mql?.matches) return breakpoint\n }\n } else {\n for (const { breakpoint, maxW, minW } of queries)\n if (direction !== \"up\") {\n if ((minW ?? 0) <= width) return breakpoint\n } else {\n if (width <= (maxW ?? Infinity)) return breakpoint\n }\n }\n\n return \"base\"\n },\n [direction, getWindow, hasContainer, hasQueries, queries],\n )\n\n const breakpointRef = useRef<Breakpoint>(getBreakpoint())\n\n const subscribe = useCallback(\n (listener: () => void) => {\n if (!hasContainer || !hasQueries) {\n const observer = queries.map(({ breakpoint, query }): (() => void) => {\n const mql = getWindow()?.matchMedia(query)\n\n const onChange = (e: MediaQueryListEvent) => {\n if (e.matches) breakpointRef.current = breakpoint\n\n listener()\n }\n\n mql?.addEventListener(\"change\", onChange)\n\n return () => {\n mql?.removeEventListener(\"change\", onChange)\n }\n })\n\n return () => {\n observer.forEach((unobserve) => unobserve())\n }\n } else if (createdDom()) {\n const observer = new ResizeObserver(([entry]) => {\n if (!entry) return\n\n cancelAnimationFrame(animationFrameId.current)\n\n const { width } = entry.contentRect\n\n breakpointRef.current = getBreakpoint(width)\n\n animationFrameId.current = requestAnimationFrame(listener)\n })\n\n if (containerRef.current) observer.observe(containerRef.current)\n\n return () => {\n observer.disconnect()\n\n if (process.env.NODE_ENV !== \"test\")\n cancelAnimationFrame(animationFrameId.current)\n }\n } else {\n return noop\n }\n },\n [containerRef, getBreakpoint, getWindow, hasContainer, hasQueries, queries],\n )\n\n const getSnapshot = useCallback(() => {\n return breakpointRef.current\n }, [])\n\n const breakpoint = useSyncExternalStore(subscribe, getSnapshot, getSnapshot)\n\n return breakpoint\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,sBAAsB;CACjC,MAAM,oBAAA,GAAA,MAAA,OAAA,CAA0B,CAAC;CACjC,MAAM,EAAE,aAAa,WAAWA,wBAAAA,UAAU;CAC1C,MAAM,EAAE,cAAcC,6BAAAA,eAAe;CACrC,MAAM,EACJ,cACA,YAAY,QACZ,aAAa,oBACX,OAAO,cAAc,CAAC;CAC1B,MAAM,eAAe,CAAC,CAAC;CAEvB,MAAM,WAAA,GAAA,MAAA,QAAA,OAAwB;EAC5B,OAAO,YAAY,QAAQ,KACxB,EAAE,YAAY,MAAM,aAAa,WAAW;GAC3C,MAAM,cACJ,eAAe,kBACX,uBACA,GAAG,WAAW;GAGpB,OAAO;IACL;IACA;IACA;IACA,OANY,aAAa,QAAQ,aAAa,EAAE,KAAK;GAOvD;EACF,CACF;CACF,GAAG,CAAC,aAAa,UAAU,CAAC;CAE5B,MAAM,aAAa,CAAC,CAAC,QAAQ;CAE7B,MAAM,iBAAA,GAAA,MAAA,YAAA,EACH,UAAmB;EAClB,KAAA,GAAA,oBAAA,cAAA,YAAA,CAAgB,KAAK,GAAG;GACtB,MAAM,MAAM,UAAU;GAEtB,IAAI,gBAAgB,CAAC,YAAY,OAAO;GAExC,KAAK,MAAM,EAAE,YAAY,WAAW,SAGlC,KAFY,KAAK,WAAW,KAAK,EAAA,EAExB,SAAS,OAAO;EAE7B,OACE,KAAK,MAAM,EAAE,YAAY,MAAM,UAAU,SACvC,IAAI,cAAc;
|
|
1
|
+
{"version":3,"file":"use-breakpoint.cjs","names":["useSystem","useEnvironment"],"sources":["../../../../src/hooks/use-breakpoint/use-breakpoint.ts"],"sourcesContent":["\"use client\"\n\nimport type { Breakpoint } from \"../../core\"\nimport { useCallback, useMemo, useRef, useSyncExternalStore } from \"react\"\nimport { useEnvironment, useSystem } from \"../../core\"\nimport { createdDom, isUndefined, noop } from \"../../utils\"\n\n/**\n * `useBreakpoint` is a custom hook that returns the current breakpoint.\n * This hook monitors changes in the window size and returns the appropriate value.\n *\n * @see https://yamada-ui.com/docs/hooks/use-breakpoint\n */\nexport const useBreakpoint = () => {\n const animationFrameId = useRef(0)\n const { breakpoints, config } = useSystem()\n const { getWindow } = useEnvironment()\n const {\n containerRef,\n direction = \"down\",\n identifier = \"@media screen\",\n } = config.breakpoint ?? {}\n const hasContainer = !!containerRef\n\n const queries = useMemo(() => {\n return breakpoints.queries.map(\n ({ breakpoint, maxW, minMaxQuery, minW }) => {\n const searchValue =\n identifier === \"@media screen\"\n ? \"@media screen and \"\n : `${identifier} `\n const query = minMaxQuery?.replace(searchValue, \"\") ?? \"\"\n\n return {\n breakpoint,\n maxW,\n minW,\n query,\n }\n },\n )\n }, [breakpoints, identifier])\n\n const hasQueries = !!queries.length\n\n const getBreakpoint = useCallback(\n (width?: number) => {\n if (isUndefined(width)) {\n const win = getWindow()\n\n if (hasContainer || !hasQueries) return \"base\"\n\n for (const { breakpoint, query } of queries) {\n const mql = win?.matchMedia(query)\n\n if (mql?.matches) return breakpoint\n }\n } else {\n for (const { breakpoint, maxW, minW } of queries)\n if (direction !== \"up\") {\n if ((minW ?? 0) <= width) return breakpoint\n } else {\n if (width <= (maxW ?? Infinity)) return breakpoint\n }\n }\n\n return \"base\"\n },\n [direction, getWindow, hasContainer, hasQueries, queries],\n )\n\n const breakpointRef = useRef<Breakpoint>(getBreakpoint())\n\n const subscribe = useCallback(\n (listener: () => void) => {\n if (!hasContainer || !hasQueries) {\n const observer = queries.map(({ breakpoint, query }): (() => void) => {\n const mql = getWindow()?.matchMedia(query)\n\n const onChange = (e: MediaQueryListEvent) => {\n if (e.matches) breakpointRef.current = breakpoint\n\n listener()\n }\n\n mql?.addEventListener(\"change\", onChange)\n\n return () => {\n mql?.removeEventListener(\"change\", onChange)\n }\n })\n\n return () => {\n observer.forEach((unobserve) => unobserve())\n }\n } else if (createdDom()) {\n const observer = new ResizeObserver(([entry]) => {\n if (!entry) return\n\n cancelAnimationFrame(animationFrameId.current)\n\n const { width } = entry.contentRect\n\n breakpointRef.current = getBreakpoint(width)\n\n animationFrameId.current = requestAnimationFrame(listener)\n })\n\n if (containerRef.current) observer.observe(containerRef.current)\n\n return () => {\n observer.disconnect()\n\n if (process.env.NODE_ENV !== \"test\")\n cancelAnimationFrame(animationFrameId.current)\n }\n } else {\n return noop\n }\n },\n [containerRef, getBreakpoint, getWindow, hasContainer, hasQueries, queries],\n )\n\n const getSnapshot = useCallback(() => {\n return breakpointRef.current\n }, [])\n\n const breakpoint = useSyncExternalStore(subscribe, getSnapshot, getSnapshot)\n\n return breakpoint\n}\n"],"mappings":";;;;;;;;;;;;AAaA,MAAa,sBAAsB;CACjC,MAAM,oBAAA,GAAA,MAAA,OAAA,CAA0B,CAAC;CACjC,MAAM,EAAE,aAAa,WAAWA,wBAAAA,UAAU;CAC1C,MAAM,EAAE,cAAcC,6BAAAA,eAAe;CACrC,MAAM,EACJ,cACA,YAAY,QACZ,aAAa,oBACX,OAAO,cAAc,CAAC;CAC1B,MAAM,eAAe,CAAC,CAAC;CAEvB,MAAM,WAAA,GAAA,MAAA,QAAA,OAAwB;EAC5B,OAAO,YAAY,QAAQ,KACxB,EAAE,YAAY,MAAM,aAAa,WAAW;GAC3C,MAAM,cACJ,eAAe,kBACX,uBACA,GAAG,WAAW;GAGpB,OAAO;IACL;IACA;IACA;IACA,OANY,aAAa,QAAQ,aAAa,EAAE,KAAK;GAOvD;EACF,CACF;CACF,GAAG,CAAC,aAAa,UAAU,CAAC;CAE5B,MAAM,aAAa,CAAC,CAAC,QAAQ;CAE7B,MAAM,iBAAA,GAAA,MAAA,YAAA,EACH,UAAmB;EAClB,KAAA,GAAA,oBAAA,cAAA,YAAA,CAAgB,KAAK,GAAG;GACtB,MAAM,MAAM,UAAU;GAEtB,IAAI,gBAAgB,CAAC,YAAY,OAAO;GAExC,KAAK,MAAM,EAAE,YAAY,WAAW,SAGlC,KAFY,KAAK,WAAW,KAAK,EAAA,EAExB,SAAS,OAAO;EAE7B,OACE,KAAK,MAAM,EAAE,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AAC,CAAC;CAIL,QAAA,GAAA,MAAA,qBAAA,CAFwC,WAAW,aAAa,WAEhD;AAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["getValidChildren","isSomeElement","findChild","createDescendants","createContext","usePopoverProps","useEnvironment","useDisclosure","isComposing","mergeProps","mergeRefs"],"sources":["../../../../src/hooks/use-combobox/index.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n JSXElementConstructor,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n RefObject,\n} from \"react\"\nimport type { UsePopoverProps } from \"../../components/popover\"\nimport type { HTMLProps, PropGetter, SimpleDirection } from \"../../core\"\nimport type { Descendant } from \"../use-descendants\"\nimport type { UseDisclosureProps } from \"../use-disclosure\"\nimport { useCallback, useId, useMemo, useRef } from \"react\"\nimport scrollIntoView from \"scroll-into-view-if-needed\"\nimport { usePopoverProps } from \"../../components/popover\"\nimport { mergeProps, useEnvironment } from \"../../core\"\nimport {\n ariaAttr,\n createContext,\n cx,\n dataAttr,\n findChild,\n getValidChildren,\n handlerAll,\n isComposing,\n isSomeElement,\n isUndefined,\n mergeRefs,\n runKeyAction,\n useUpdateEffect,\n} from \"../../utils\"\nimport { createDescendants } from \"../use-descendants\"\nimport { useDisclosure } from \"../use-disclosure\"\n\ninterface ComboboxSharedItem extends Omit<HTMLProps, \"children\" | \"value\"> {\n label: ReactNode\n}\n\nexport interface ComboboxItemWithValue extends ComboboxSharedItem {\n query?: string\n value?: string\n}\n\nexport interface ComboboxItemWithItems extends ComboboxSharedItem {\n items: ComboboxItemWithValue[]\n}\n\nexport type ComboboxItem = ComboboxItemWithItems | ComboboxItemWithValue\n\nexport interface CreateComboboxItemOptions {\n Group: JSXElementConstructor<any>\n Label: JSXElementConstructor<any>\n Option: JSXElementConstructor<any>\n}\n\nexport const createComboboxItem = (\n children: ReactNode,\n { Group, Label, Option }: CreateComboboxItemOptions,\n) => {\n const validChildren = getValidChildren(children)\n\n return validChildren\n .filter(\n ({ type }) => isSomeElement(type, Option) || isSomeElement(type, Group),\n )\n .map(({ type, props }) => {\n if (isSomeElement(type, Option)) {\n return { ...props, label: props.children }\n } else {\n const validChildren = getValidChildren(props.children)\n const label = findChild(validChildren, Label)\n\n return {\n ...props,\n items: validChildren\n .filter(({ type }) => isSomeElement(type, Option))\n .map(({ props }) => ({ ...props, label: props.children })),\n label: label?.props.children ?? props.label,\n }\n }\n })\n}\n\nexport interface CreateComboboxChildrenOptions {\n Group: JSXElementConstructor<any>\n Option: JSXElementConstructor<any>\n Empty?: JSXElementConstructor<any>\n}\n\nexport const createComboboxChildren = (\n items: ComboboxItem[],\n { Empty, Group, Option }: CreateComboboxChildrenOptions,\n) => {\n return items.map((item, index) => {\n if (\"data-empty\" in item && Empty) {\n const { label, ...rest } = item\n\n return (\n <Empty key={index} {...rest}>\n {label}\n </Empty>\n )\n } else if (\"items\" in item) {\n const { items, label, ...rest } = item\n\n return (\n <Group key={index} label={label} {...rest}>\n {items.map(({ label, ...rest }, index) => (\n <Option key={index} {...rest}>\n {label}\n </Option>\n ))}\n </Group>\n )\n } else {\n const { label, ...rest } = item\n\n return (\n <Option key={index} {...rest}>\n {label}\n </Option>\n )\n }\n })\n}\n\nexport interface ComboboxDescendantProps {\n id: string\n closeOnSelect?: boolean\n value?: string\n}\nexport type ComboboxDescendant = Descendant<\n HTMLDivElement,\n ComboboxDescendantProps\n>\n\nconst {\n DescendantsContext: ComboboxDescendantsContext,\n useDescendant: useComboboxDescendant,\n useDescendantRegister: useComboboxDescendantRegister,\n useDescendants: useComboboxDescendants,\n} = createDescendants<HTMLDivElement, ComboboxDescendantProps>()\n\nexport {\n ComboboxDescendantsContext,\n useComboboxDescendant,\n useComboboxDescendantRegister,\n useComboboxDescendants,\n}\n\ninterface ComboboxContext extends Pick<\n UseComboboxReturn,\n \"onActiveDescendant\" | \"onClose\" | \"onSelect\"\n> {}\n\nconst [ComboboxContext, useComboboxContext] = createContext<ComboboxContext>({\n name: \"ComboboxContext\",\n})\n\ninterface ComboboxGroupContext extends Pick<\n UseComboboxGroupReturn,\n \"getLabelProps\"\n> {}\n\nconst [ComboboxGroupContext, useComboboxGroupContext] =\n createContext<ComboboxGroupContext>({\n name: \"ComboboxGroupContext\",\n })\n\nexport {\n ComboboxContext,\n ComboboxGroupContext,\n useComboboxContext,\n useComboboxGroupContext,\n}\n\nexport interface UseComboboxProps\n extends\n Omit<HTMLProps, \"onChange\">,\n Omit<UseDisclosureProps, \"timing\">,\n Omit<\n UsePopoverProps,\n \"autoFocus\" | \"initialFocusRef\" | \"modal\" | \"transform\" | \"updateRef\"\n > {\n /**\n * If `true`, the list element will be closed when value is selected.\n *\n * @default true\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the combobox will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The value to focus on when the combobox is opened.\n */\n initialFocusValue?: string\n /**\n * If `true`, the combobox will be opened when click on the field.\n *\n * @default true\n */\n openOnClick?: boolean\n /**\n * If `true`, the combobox will be opened when enter is pressed.\n *\n * @default true\n */\n openOnEnter?: boolean\n /**\n * If `true`, the combobox will be opened when space is pressed.\n *\n * @default true\n */\n openOnSpace?: boolean\n /**\n * If `true`, the combobox will be readonly.\n *\n * @default false\n */\n readOnly?: boolean\n /**\n * The `ref` of the element that should receive focus when selected.\n */\n selectFocusRef?: RefObject<HTMLElement | null>\n /**\n * If `true`, the item will be selected when space is pressed.\n *\n * @default true\n */\n selectOnSpace?: boolean\n /**\n * The callback invoked when value is selected.\n */\n onChange?: (value: string) => void\n}\n\nexport const useCombobox = (props: UseComboboxProps = {}) => {\n const [\n { matchWidth = true, ...popoverProps },\n {\n \"aria-label\": ariaLabelProp,\n \"aria-labelledby\": ariaLabelledbyProp,\n closeOnSelect: closeOnSelectProp = true,\n defaultOpen,\n disabled,\n initialFocusValue,\n open: openProp,\n openOnClick = true,\n openOnEnter = true,\n openOnSpace = true,\n readOnly,\n selectFocusRef,\n selectOnSpace = true,\n onChange: onChangeProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n ...rest\n },\n ] = usePopoverProps(props, [\n \"disabled\",\n \"open\",\n \"defaultOpen\",\n \"onOpen\",\n \"onClose\",\n \"openOnClick\",\n ])\n const { getWindow } = useEnvironment()\n const interactive = !(readOnly || disabled)\n const triggerRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const contentId = useId()\n const descendants = useComboboxDescendants()\n const { open, onClose, onOpen } = useDisclosure({\n defaultOpen,\n open: openProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n })\n const activeDescendant = useRef<ComboboxDescendant | null>(null)\n const mergedPopoverProps = useMemo<UsePopoverProps>(\n () => ({\n autoFocus: false,\n matchWidth,\n openOnClick: false,\n ...popoverProps,\n disabled: !interactive,\n open,\n onClose,\n onOpen,\n }),\n [interactive, matchWidth, onClose, onOpen, open, popoverProps],\n )\n\n const onSelect = useCallback(\n (value?: string, closeOnSelect = closeOnSelectProp) => {\n const ref = selectFocusRef ?? triggerRef\n\n ref.current?.focus()\n\n if (!interactive || isUndefined(value)) return\n\n onChangeProp?.(value)\n\n if (!closeOnSelect) return\n\n onClose()\n },\n [closeOnSelectProp, interactive, onChangeProp, onClose, selectFocusRef],\n )\n\n const onScrollIntoView = useCallback(\n (descendant?: ComboboxDescendant, block: SimpleDirection = \"start\") => {\n if (!contentRef.current || !descendant) return\n\n const style = getWindow()?.getComputedStyle(contentRef.current)\n const padding =\n block === \"start\" ? style?.paddingBlockStart : style?.paddingBlockEnd\n const value = parseInt(padding ?? \"0px\")\n\n scrollIntoView(descendant.node, {\n behavior: (actions) =>\n actions.forEach(({ el, top }) => {\n el.scrollTop = block === \"start\" ? top - value : top + value\n }),\n block,\n boundary: contentRef.current,\n inline: \"nearest\",\n scrollMode: \"if-needed\",\n })\n },\n [getWindow],\n )\n\n const onActiveDescendant = useCallback(\n (descendant?: ComboboxDescendant) => {\n if (!triggerRef.current || !descendant || disabled) return\n\n triggerRef.current.setAttribute(\"aria-activedescendant\", descendant.id)\n\n activeDescendant.current = descendant\n\n descendants.active(descendant)\n },\n [descendants, disabled],\n )\n\n const onOpenWithActiveDescendant = useCallback(\n (\n getFallbackDescendant: () => ComboboxDescendant | undefined,\n block: SimpleDirection = \"start\",\n ) => {\n onOpen()\n\n setTimeout(() => {\n if (!initialFocusValue) {\n const descendant = getFallbackDescendant()\n\n onActiveDescendant(descendant)\n onScrollIntoView(descendant, block)\n } else {\n const values = descendants.values()\n const descendant =\n values.find(({ value }) => initialFocusValue === value) ??\n getFallbackDescendant()\n\n onActiveDescendant(descendant)\n onScrollIntoView(descendant, block)\n }\n })\n },\n [\n descendants,\n initialFocusValue,\n onActiveDescendant,\n onOpen,\n onScrollIntoView,\n ],\n )\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (disabled) return\n\n ev.preventDefault()\n\n if (!open) {\n if (openOnClick)\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n onClose()\n }\n },\n [\n descendants,\n disabled,\n onClose,\n onOpenWithActiveDescendant,\n open,\n openOnClick,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n if (disabled || isComposing(ev)) return\n\n runKeyAction(\n ev,\n {\n ArrowDown: (ev) => {\n ev.preventDefault()\n\n if (!open) {\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else if (activeDescendant.current) {\n const descendant = descendants.enabledNextValue(\n activeDescendant.current,\n )\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(\n descendant,\n descendant?.recurred ? \"start\" : \"end\",\n )\n } else {\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant)\n }\n },\n ArrowUp: (ev) => {\n ev.preventDefault()\n\n if (!open) {\n onOpenWithActiveDescendant(descendants.enabledLastValue, \"end\")\n } else if (activeDescendant.current) {\n const descendant = descendants.enabledPrevValue(\n activeDescendant.current,\n )\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(\n descendant,\n descendant?.recurred ? \"end\" : \"start\",\n )\n } else {\n const descendant = descendants.enabledLastValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant, \"end\")\n }\n },\n End: (ev) => {\n ev.preventDefault()\n\n if (!open) return\n\n const descendant = descendants.enabledLastValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant, \"end\")\n },\n Enter: (ev) => {\n if (!open) {\n if (!openOnEnter) return\n\n ev.preventDefault()\n\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n if (!activeDescendant.current) return\n\n ev.preventDefault()\n\n const { closeOnSelect, value } = activeDescendant.current\n\n onSelect(value, closeOnSelect)\n }\n },\n Home: (ev) => {\n if (!open) return\n\n ev.preventDefault()\n\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant)\n },\n Space: (ev) => {\n if (!open) {\n if (!openOnSpace) return\n\n ev.preventDefault()\n\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n if (!activeDescendant.current || !selectOnSpace) return\n\n ev.preventDefault()\n\n const { closeOnSelect, value } = activeDescendant.current\n\n onSelect(value, closeOnSelect)\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n disabled,\n open,\n onOpenWithActiveDescendant,\n descendants,\n onActiveDescendant,\n onScrollIntoView,\n openOnEnter,\n onSelect,\n openOnSpace,\n selectOnSpace,\n ],\n )\n\n useUpdateEffect(() => {\n if (open) return\n\n activeDescendant.current = null\n }, [open])\n\n const getTriggerProps: PropGetter = useCallback(\n ({\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n ...props\n } = {}) => ({\n ...mergeProps(\n {\n ref: triggerRef,\n \"aria-controls\": open ? contentId : undefined,\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-expanded\": open,\n \"aria-haspopup\": \"listbox\",\n \"aria-label\": ariaLabel || ariaLabelProp,\n \"aria-labelledby\": cx(ariaLabelledby, ariaLabelledbyProp),\n \"data-disabled\": dataAttr(disabled),\n \"data-readonly\": dataAttr(readOnly),\n role: \"combobox\",\n tabIndex: interactive ? 0 : -1,\n },\n rest,\n props,\n )({ mergeEvent: false }),\n onClick: handlerAll(props.onClick, rest.onClick, onClick),\n onKeyDown: handlerAll(props.onKeyDown, rest.onKeyDown, onKeyDown),\n }),\n [\n open,\n contentId,\n interactive,\n ariaLabelledbyProp,\n disabled,\n readOnly,\n ariaLabelProp,\n rest,\n onClick,\n onKeyDown,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n id: contentId,\n role: \"listbox\",\n ...props,\n ref: mergeRefs(ref, contentRef),\n onKeyDown: handlerAll(props.onKeyDown),\n }),\n [contentId],\n )\n\n const getSeparatorProps: PropGetter = useCallback(\n (props) => ({ role: \"separator\", ...props }),\n [],\n )\n\n return {\n activeDescendant,\n descendants,\n interactive,\n open,\n getContentProps,\n getSeparatorProps,\n getTriggerProps,\n popoverProps: mergedPopoverProps,\n onActiveDescendant,\n onClose,\n onOpen,\n onOpenWithActiveDescendant,\n onScrollIntoView,\n onSelect,\n }\n}\n\nexport type UseComboboxReturn = ReturnType<typeof useCombobox>\n\nexport interface UseComboboxGroupProps extends HTMLProps {}\n\nexport const useComboboxGroup = ({\n \"aria-labelledby\": ariaLabelledbyProp,\n ...rest\n}: UseComboboxGroupProps = {}) => {\n const labelId = useId()\n\n const getGroupProps: PropGetter = useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, ...props } = {}) =>\n mergeProps(\n {\n \"aria-labelledby\": cx(ariaLabelledbyProp, ariaLabelledby, labelId),\n role: \"group\",\n },\n rest,\n props,\n )(),\n [ariaLabelledbyProp, labelId, rest],\n )\n\n const getLabelProps: PropGetter<\"span\"> = useCallback(\n (props) => ({ id: labelId, role: \"presentation\", ...props }),\n [labelId],\n )\n\n return { getGroupProps, getLabelProps }\n}\n\nexport type UseComboboxGroupReturn = ReturnType<typeof useComboboxGroup>\n\nexport interface UseComboboxItemProps extends HTMLProps {\n /**\n * If `true`, the item will be closed when selected.\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * If `true`, the item will be selected.\n */\n selected?: boolean\n /**\n * The value of the item.\n */\n value?: string\n}\n\nexport const useComboboxItem = ({\n id,\n \"aria-disabled\": ariaDisabled,\n \"data-disabled\": dataDisabled,\n closeOnSelect,\n disabled = false,\n selected = false,\n value,\n ...rest\n}: UseComboboxItemProps = {}) => {\n const uuid = useId()\n const itemRef = useRef<HTMLDivElement>(null)\n const { onActiveDescendant, onClose, onSelect } = useComboboxContext()\n\n id ??= uuid\n\n const { descendants, register } = useComboboxDescendant({\n id,\n closeOnSelect,\n disabled,\n value,\n })\n\n const onActive = useCallback(() => {\n if (disabled) return\n\n const current = descendants.value(itemRef.current)\n\n onActiveDescendant(current)\n }, [descendants, disabled, onActiveDescendant])\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n ev.preventDefault()\n\n if (disabled) return\n\n onSelect(value, closeOnSelect)\n },\n [closeOnSelect, disabled, onSelect, value],\n )\n\n const getItemProps: PropGetter = useCallback(\n (props = {}) => ({\n ...mergeProps(\n {\n id,\n ref: itemRef,\n \"aria-disabled\": ariaDisabled ?? ariaAttr(disabled),\n \"aria-selected\": selected,\n \"data-disabled\": dataDisabled ?? dataAttr(disabled),\n \"data-selected\": dataAttr(selected),\n \"data-value\": value,\n role: \"option\",\n tabIndex: -1,\n },\n rest,\n props,\n { ref: register },\n )({ mergeEvent: false }),\n onClick: handlerAll(props.onClick, rest.onClick, onClick),\n onMouseMove: handlerAll(props.onMouseMove, rest.onMouseMove, onActive),\n }),\n [\n id,\n ariaDisabled,\n disabled,\n selected,\n dataDisabled,\n value,\n rest,\n register,\n onClick,\n onActive,\n ],\n )\n\n const getIndicatorProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps({ style: { opacity: selected ? 1 : 0 } }, props)(),\n [selected],\n )\n\n return {\n descendants,\n disabled,\n selected,\n getIndicatorProps,\n getItemProps,\n onActiveDescendant,\n onClose,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwDA,MAAa,sBACX,UACA,EAAE,OAAO,OAAO,aACb;CAGH,OAFsBA,iBAAAA,iBAAiB,QAEpB,CAAC,CACjB,QACE,EAAE,WAAWC,iBAAAA,cAAc,MAAM,MAAM,KAAKA,iBAAAA,cAAc,MAAM,KAAK,CACxE,CAAC,CACA,KAAK,EAAE,MAAM,YAAY;EACxB,IAAIA,iBAAAA,cAAc,MAAM,MAAM,GAC5B,OAAO;GAAE,GAAG;GAAO,OAAO,MAAM;EAAS;OACpC;GACL,MAAM,gBAAgBD,iBAAAA,iBAAiB,MAAM,QAAQ;GACrD,MAAM,QAAQE,iBAAAA,UAAU,eAAe,KAAK;GAE5C,OAAO;IACL,GAAG;IACH,OAAO,cACJ,QAAQ,EAAE,WAAWD,iBAAAA,cAAc,MAAM,MAAM,CAAC,CAAC,CACjD,KAAK,EAAE,aAAa;KAAE,GAAG;KAAO,OAAO,MAAM;IAAS,EAAE;IAC3D,OAAO,OAAO,MAAM,YAAY,MAAM;GACxC;EACF;CACF,CAAC;AACL;AAQA,MAAa,0BACX,OACA,EAAE,OAAO,OAAO,aACb;CACH,OAAO,MAAM,KAAK,MAAM,UAAU;EAChC,IAAI,gBAAgB,QAAQ,OAAO;GACjC,MAAM,EAAE,OAAO,GAAG,SAAS;GAE3B,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAmB,GAAI;cACpB;GACI,GAFK,KAEL;EAEX,OAAO,IAAI,WAAW,MAAM;GAC1B,MAAM,EAAE,OAAO,OAAO,GAAG,SAAS;GAElC,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAA0B;IAAO,GAAI;cAClC,MAAM,KAAK,EAAE,OAAO,GAAG,QAAQ,UAC9B,iBAAA,GAAA,kBAAA,IAAA,CAAC,QA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,MACA,OACA,EAAE,KAAK,SAAS,CAClB,CAAC,CAAC,EAAE,YAAY,MAAM,CAAC;EACvB,UAAA,GAAA,oBAAA,cAAA,WAAA,CAAoB,MAAM,SAAS,KAAK,SAAS,OAAO;EACxD,cAAA,GAAA,oBAAA,cAAA,WAAA,CAAwB,MAAM,aAAa,KAAK,aAAa,QAAQ;CACvE,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAQA,OAAO;EACL;EACA;EACA;EACA,oBAAA,GAAA,MAAA,YAAA,EATC,QAAQ,CAAC,MACRA,cAAAA,WAAW,EAAE,OAAO,EAAE,SAAS,WAAW,IAAI,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,GAC9D,CAAC,QAAQ,CAOO;EAChB;EACA;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["getValidChildren","isSomeElement","findChild","createDescendants","createContext","usePopoverProps","useEnvironment","useDisclosure","isComposing","mergeProps","mergeRefs"],"sources":["../../../../src/hooks/use-combobox/index.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n JSXElementConstructor,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n RefObject,\n} from \"react\"\nimport type { UsePopoverProps } from \"../../components/popover\"\nimport type { HTMLProps, PropGetter, SimpleDirection } from \"../../core\"\nimport type { Descendant } from \"../use-descendants\"\nimport type { UseDisclosureProps } from \"../use-disclosure\"\nimport { useCallback, useId, useMemo, useRef } from \"react\"\nimport scrollIntoView from \"scroll-into-view-if-needed\"\nimport { usePopoverProps } from \"../../components/popover\"\nimport { mergeProps, useEnvironment } from \"../../core\"\nimport {\n ariaAttr,\n createContext,\n cx,\n dataAttr,\n findChild,\n getValidChildren,\n handlerAll,\n isComposing,\n isSomeElement,\n isUndefined,\n mergeRefs,\n runKeyAction,\n useUpdateEffect,\n} from \"../../utils\"\nimport { createDescendants } from \"../use-descendants\"\nimport { useDisclosure } from \"../use-disclosure\"\n\ninterface ComboboxSharedItem extends Omit<HTMLProps, \"children\" | \"value\"> {\n label: ReactNode\n}\n\nexport interface ComboboxItemWithValue extends ComboboxSharedItem {\n query?: string\n value?: string\n}\n\nexport interface ComboboxItemWithItems extends ComboboxSharedItem {\n items: ComboboxItemWithValue[]\n}\n\nexport type ComboboxItem = ComboboxItemWithItems | ComboboxItemWithValue\n\nexport interface CreateComboboxItemOptions {\n Group: JSXElementConstructor<any>\n Label: JSXElementConstructor<any>\n Option: JSXElementConstructor<any>\n}\n\nexport const createComboboxItem = (\n children: ReactNode,\n { Group, Label, Option }: CreateComboboxItemOptions,\n) => {\n const validChildren = getValidChildren(children)\n\n return validChildren\n .filter(\n ({ type }) => isSomeElement(type, Option) || isSomeElement(type, Group),\n )\n .map(({ type, props }) => {\n if (isSomeElement(type, Option)) {\n return { ...props, label: props.children }\n } else {\n const validChildren = getValidChildren(props.children)\n const label = findChild(validChildren, Label)\n\n return {\n ...props,\n items: validChildren\n .filter(({ type }) => isSomeElement(type, Option))\n .map(({ props }) => ({ ...props, label: props.children })),\n label: label?.props.children ?? props.label,\n }\n }\n })\n}\n\nexport interface CreateComboboxChildrenOptions {\n Group: JSXElementConstructor<any>\n Option: JSXElementConstructor<any>\n Empty?: JSXElementConstructor<any>\n}\n\nexport const createComboboxChildren = (\n items: ComboboxItem[],\n { Empty, Group, Option }: CreateComboboxChildrenOptions,\n) => {\n return items.map((item, index) => {\n if (\"data-empty\" in item && Empty) {\n const { label, ...rest } = item\n\n return (\n <Empty key={index} {...rest}>\n {label}\n </Empty>\n )\n } else if (\"items\" in item) {\n const { items, label, ...rest } = item\n\n return (\n <Group key={index} label={label} {...rest}>\n {items.map(({ label, ...rest }, index) => (\n <Option key={index} {...rest}>\n {label}\n </Option>\n ))}\n </Group>\n )\n } else {\n const { label, ...rest } = item\n\n return (\n <Option key={index} {...rest}>\n {label}\n </Option>\n )\n }\n })\n}\n\nexport interface ComboboxDescendantProps {\n id: string\n closeOnSelect?: boolean\n value?: string\n}\nexport type ComboboxDescendant = Descendant<\n HTMLDivElement,\n ComboboxDescendantProps\n>\n\nconst {\n DescendantsContext: ComboboxDescendantsContext,\n useDescendant: useComboboxDescendant,\n useDescendantRegister: useComboboxDescendantRegister,\n useDescendants: useComboboxDescendants,\n} = createDescendants<HTMLDivElement, ComboboxDescendantProps>()\n\nexport {\n ComboboxDescendantsContext,\n useComboboxDescendant,\n useComboboxDescendantRegister,\n useComboboxDescendants,\n}\n\ninterface ComboboxContext extends Pick<\n UseComboboxReturn,\n \"onActiveDescendant\" | \"onClose\" | \"onSelect\"\n> {}\n\nconst [ComboboxContext, useComboboxContext] = createContext<ComboboxContext>({\n name: \"ComboboxContext\",\n})\n\ninterface ComboboxGroupContext extends Pick<\n UseComboboxGroupReturn,\n \"getLabelProps\"\n> {}\n\nconst [ComboboxGroupContext, useComboboxGroupContext] =\n createContext<ComboboxGroupContext>({\n name: \"ComboboxGroupContext\",\n })\n\nexport {\n ComboboxContext,\n ComboboxGroupContext,\n useComboboxContext,\n useComboboxGroupContext,\n}\n\nexport interface UseComboboxProps\n extends\n Omit<HTMLProps, \"onChange\">,\n Omit<UseDisclosureProps, \"timing\">,\n Omit<\n UsePopoverProps,\n \"autoFocus\" | \"initialFocusRef\" | \"modal\" | \"transform\" | \"updateRef\"\n > {\n /**\n * If `true`, the list element will be closed when value is selected.\n *\n * @default true\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the combobox will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * The value to focus on when the combobox is opened.\n */\n initialFocusValue?: string\n /**\n * If `true`, the combobox will be opened when click on the field.\n *\n * @default true\n */\n openOnClick?: boolean\n /**\n * If `true`, the combobox will be opened when enter is pressed.\n *\n * @default true\n */\n openOnEnter?: boolean\n /**\n * If `true`, the combobox will be opened when space is pressed.\n *\n * @default true\n */\n openOnSpace?: boolean\n /**\n * If `true`, the combobox will be readonly.\n *\n * @default false\n */\n readOnly?: boolean\n /**\n * The `ref` of the element that should receive focus when selected.\n */\n selectFocusRef?: RefObject<HTMLElement | null>\n /**\n * If `true`, the item will be selected when space is pressed.\n *\n * @default true\n */\n selectOnSpace?: boolean\n /**\n * The callback invoked when value is selected.\n */\n onChange?: (value: string) => void\n}\n\nexport const useCombobox = (props: UseComboboxProps = {}) => {\n const [\n { matchWidth = true, ...popoverProps },\n {\n \"aria-label\": ariaLabelProp,\n \"aria-labelledby\": ariaLabelledbyProp,\n closeOnSelect: closeOnSelectProp = true,\n defaultOpen,\n disabled,\n initialFocusValue,\n open: openProp,\n openOnClick = true,\n openOnEnter = true,\n openOnSpace = true,\n readOnly,\n selectFocusRef,\n selectOnSpace = true,\n onChange: onChangeProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n ...rest\n },\n ] = usePopoverProps(props, [\n \"disabled\",\n \"open\",\n \"defaultOpen\",\n \"onOpen\",\n \"onClose\",\n \"openOnClick\",\n ])\n const { getWindow } = useEnvironment()\n const interactive = !(readOnly || disabled)\n const triggerRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const contentId = useId()\n const descendants = useComboboxDescendants()\n const { open, onClose, onOpen } = useDisclosure({\n defaultOpen,\n open: openProp,\n onClose: onCloseProp,\n onOpen: onOpenProp,\n })\n const activeDescendant = useRef<ComboboxDescendant | null>(null)\n const mergedPopoverProps = useMemo<UsePopoverProps>(\n () => ({\n autoFocus: false,\n matchWidth,\n openOnClick: false,\n ...popoverProps,\n disabled: !interactive,\n open,\n onClose,\n onOpen,\n }),\n [interactive, matchWidth, onClose, onOpen, open, popoverProps],\n )\n\n const onSelect = useCallback(\n (value?: string, closeOnSelect = closeOnSelectProp) => {\n const ref = selectFocusRef ?? triggerRef\n\n ref.current?.focus()\n\n if (!interactive || isUndefined(value)) return\n\n onChangeProp?.(value)\n\n if (!closeOnSelect) return\n\n onClose()\n },\n [closeOnSelectProp, interactive, onChangeProp, onClose, selectFocusRef],\n )\n\n const onScrollIntoView = useCallback(\n (descendant?: ComboboxDescendant, block: SimpleDirection = \"start\") => {\n if (!contentRef.current || !descendant) return\n\n const style = getWindow()?.getComputedStyle(contentRef.current)\n const padding =\n block === \"start\" ? style?.paddingBlockStart : style?.paddingBlockEnd\n const value = parseInt(padding ?? \"0px\")\n\n scrollIntoView(descendant.node, {\n behavior: (actions) =>\n actions.forEach(({ el, top }) => {\n el.scrollTop = block === \"start\" ? top - value : top + value\n }),\n block,\n boundary: contentRef.current,\n inline: \"nearest\",\n scrollMode: \"if-needed\",\n })\n },\n [getWindow],\n )\n\n const onActiveDescendant = useCallback(\n (descendant?: ComboboxDescendant) => {\n if (!triggerRef.current || !descendant || disabled) return\n\n triggerRef.current.setAttribute(\"aria-activedescendant\", descendant.id)\n\n activeDescendant.current = descendant\n\n descendants.active(descendant)\n },\n [descendants, disabled],\n )\n\n const onOpenWithActiveDescendant = useCallback(\n (\n getFallbackDescendant: () => ComboboxDescendant | undefined,\n block: SimpleDirection = \"start\",\n ) => {\n onOpen()\n\n setTimeout(() => {\n if (!initialFocusValue) {\n const descendant = getFallbackDescendant()\n\n onActiveDescendant(descendant)\n onScrollIntoView(descendant, block)\n } else {\n const values = descendants.values()\n const descendant =\n values.find(({ value }) => initialFocusValue === value) ??\n getFallbackDescendant()\n\n onActiveDescendant(descendant)\n onScrollIntoView(descendant, block)\n }\n })\n },\n [\n descendants,\n initialFocusValue,\n onActiveDescendant,\n onOpen,\n onScrollIntoView,\n ],\n )\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (disabled) return\n\n ev.preventDefault()\n\n if (!open) {\n if (openOnClick)\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n onClose()\n }\n },\n [\n descendants,\n disabled,\n onClose,\n onOpenWithActiveDescendant,\n open,\n openOnClick,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLDivElement>) => {\n if (disabled || isComposing(ev)) return\n\n runKeyAction(\n ev,\n {\n ArrowDown: (ev) => {\n ev.preventDefault()\n\n if (!open) {\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else if (activeDescendant.current) {\n const descendant = descendants.enabledNextValue(\n activeDescendant.current,\n )\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(\n descendant,\n descendant?.recurred ? \"start\" : \"end\",\n )\n } else {\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant)\n }\n },\n ArrowUp: (ev) => {\n ev.preventDefault()\n\n if (!open) {\n onOpenWithActiveDescendant(descendants.enabledLastValue, \"end\")\n } else if (activeDescendant.current) {\n const descendant = descendants.enabledPrevValue(\n activeDescendant.current,\n )\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(\n descendant,\n descendant?.recurred ? \"end\" : \"start\",\n )\n } else {\n const descendant = descendants.enabledLastValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant, \"end\")\n }\n },\n End: (ev) => {\n ev.preventDefault()\n\n if (!open) return\n\n const descendant = descendants.enabledLastValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant, \"end\")\n },\n Enter: (ev) => {\n if (!open) {\n if (!openOnEnter) return\n\n ev.preventDefault()\n\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n if (!activeDescendant.current) return\n\n ev.preventDefault()\n\n const { closeOnSelect, value } = activeDescendant.current\n\n onSelect(value, closeOnSelect)\n }\n },\n Home: (ev) => {\n if (!open) return\n\n ev.preventDefault()\n\n const descendant = descendants.enabledFirstValue()\n\n onActiveDescendant(descendant)\n\n onScrollIntoView(descendant)\n },\n Space: (ev) => {\n if (!open) {\n if (!openOnSpace) return\n\n ev.preventDefault()\n\n onOpenWithActiveDescendant(descendants.enabledFirstValue)\n } else {\n if (!activeDescendant.current || !selectOnSpace) return\n\n ev.preventDefault()\n\n const { closeOnSelect, value } = activeDescendant.current\n\n onSelect(value, closeOnSelect)\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n disabled,\n open,\n onOpenWithActiveDescendant,\n descendants,\n onActiveDescendant,\n onScrollIntoView,\n openOnEnter,\n onSelect,\n openOnSpace,\n selectOnSpace,\n ],\n )\n\n useUpdateEffect(() => {\n if (open) return\n\n activeDescendant.current = null\n }, [open])\n\n const getTriggerProps: PropGetter = useCallback(\n ({\n \"aria-label\": ariaLabel,\n \"aria-labelledby\": ariaLabelledby,\n ...props\n } = {}) => ({\n ...mergeProps(\n {\n ref: triggerRef,\n \"aria-controls\": open ? contentId : undefined,\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-expanded\": open,\n \"aria-haspopup\": \"listbox\",\n \"aria-label\": ariaLabel || ariaLabelProp,\n \"aria-labelledby\": cx(ariaLabelledby, ariaLabelledbyProp),\n \"data-disabled\": dataAttr(disabled),\n \"data-readonly\": dataAttr(readOnly),\n role: \"combobox\",\n tabIndex: interactive ? 0 : -1,\n },\n rest,\n props,\n )({ mergeEvent: false }),\n onClick: handlerAll(props.onClick, rest.onClick, onClick),\n onKeyDown: handlerAll(props.onKeyDown, rest.onKeyDown, onKeyDown),\n }),\n [\n open,\n contentId,\n interactive,\n ariaLabelledbyProp,\n disabled,\n readOnly,\n ariaLabelProp,\n rest,\n onClick,\n onKeyDown,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) => ({\n id: contentId,\n role: \"listbox\",\n ...props,\n ref: mergeRefs(ref, contentRef),\n onKeyDown: handlerAll(props.onKeyDown),\n }),\n [contentId],\n )\n\n const getSeparatorProps: PropGetter = useCallback(\n (props) => ({ role: \"separator\", ...props }),\n [],\n )\n\n return {\n activeDescendant,\n descendants,\n interactive,\n open,\n getContentProps,\n getSeparatorProps,\n getTriggerProps,\n popoverProps: mergedPopoverProps,\n onActiveDescendant,\n onClose,\n onOpen,\n onOpenWithActiveDescendant,\n onScrollIntoView,\n onSelect,\n }\n}\n\nexport type UseComboboxReturn = ReturnType<typeof useCombobox>\n\nexport interface UseComboboxGroupProps extends HTMLProps {}\n\nexport const useComboboxGroup = ({\n \"aria-labelledby\": ariaLabelledbyProp,\n ...rest\n}: UseComboboxGroupProps = {}) => {\n const labelId = useId()\n\n const getGroupProps: PropGetter = useCallback(\n ({ \"aria-labelledby\": ariaLabelledby, ...props } = {}) =>\n mergeProps(\n {\n \"aria-labelledby\": cx(ariaLabelledbyProp, ariaLabelledby, labelId),\n role: \"group\",\n },\n rest,\n props,\n )(),\n [ariaLabelledbyProp, labelId, rest],\n )\n\n const getLabelProps: PropGetter<\"span\"> = useCallback(\n (props) => ({ id: labelId, role: \"presentation\", ...props }),\n [labelId],\n )\n\n return { getGroupProps, getLabelProps }\n}\n\nexport type UseComboboxGroupReturn = ReturnType<typeof useComboboxGroup>\n\nexport interface UseComboboxItemProps extends HTMLProps {\n /**\n * If `true`, the item will be closed when selected.\n */\n closeOnSelect?: boolean\n /**\n * If `true`, the item will be disabled.\n *\n * @default false\n */\n disabled?: boolean\n /**\n * If `true`, the item will be selected.\n */\n selected?: boolean\n /**\n * The value of the item.\n */\n value?: string\n}\n\nexport const useComboboxItem = ({\n id,\n \"aria-disabled\": ariaDisabled,\n \"data-disabled\": dataDisabled,\n closeOnSelect,\n disabled = false,\n selected = false,\n value,\n ...rest\n}: UseComboboxItemProps = {}) => {\n const uuid = useId()\n const itemRef = useRef<HTMLDivElement>(null)\n const { onActiveDescendant, onClose, onSelect } = useComboboxContext()\n\n id ??= uuid\n\n const { descendants, register } = useComboboxDescendant({\n id,\n closeOnSelect,\n disabled,\n value,\n })\n\n const onActive = useCallback(() => {\n if (disabled) return\n\n const current = descendants.value(itemRef.current)\n\n onActiveDescendant(current)\n }, [descendants, disabled, onActiveDescendant])\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n ev.preventDefault()\n\n if (disabled) return\n\n onSelect(value, closeOnSelect)\n },\n [closeOnSelect, disabled, onSelect, value],\n )\n\n const getItemProps: PropGetter = useCallback(\n (props = {}) => ({\n ...mergeProps(\n {\n id,\n ref: itemRef,\n \"aria-disabled\": ariaDisabled ?? ariaAttr(disabled),\n \"aria-selected\": selected,\n \"data-disabled\": dataDisabled ?? dataAttr(disabled),\n \"data-selected\": dataAttr(selected),\n \"data-value\": value,\n role: \"option\",\n tabIndex: -1,\n },\n rest,\n props,\n { ref: register },\n )({ mergeEvent: false }),\n onClick: handlerAll(props.onClick, rest.onClick, onClick),\n onMouseMove: handlerAll(props.onMouseMove, rest.onMouseMove, onActive),\n }),\n [\n id,\n ariaDisabled,\n disabled,\n selected,\n dataDisabled,\n value,\n rest,\n register,\n onClick,\n onActive,\n ],\n )\n\n const getIndicatorProps: PropGetter = useCallback(\n (props = {}) =>\n mergeProps({ style: { opacity: selected ? 1 : 0 } }, props)(),\n [selected],\n )\n\n return {\n descendants,\n disabled,\n selected,\n getIndicatorProps,\n getItemProps,\n onActiveDescendant,\n onClose,\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwDA,MAAa,sBACX,UACA,EAAE,OAAO,OAAO,aACb;CAGH,OAFsBA,iBAAAA,iBAAiB,QAEpB,CAAC,CACjB,QACE,EAAE,WAAWC,iBAAAA,cAAc,MAAM,MAAM,KAAKA,iBAAAA,cAAc,MAAM,KAAK,CACxE,CAAC,CACA,KAAK,EAAE,MAAM,YAAY;EACxB,IAAIA,iBAAAA,cAAc,MAAM,MAAM,GAC5B,OAAO;GAAE,GAAG;GAAO,OAAO,MAAM;EAAS;OACpC;GACL,MAAM,gBAAgBD,iBAAAA,iBAAiB,MAAM,QAAQ;GACrD,MAAM,QAAQE,iBAAAA,UAAU,eAAe,KAAK;GAE5C,OAAO;IACL,GAAG;IACH,OAAO,cACJ,QAAQ,EAAE,WAAWD,iBAAAA,cAAc,MAAM,MAAM,CAAC,CAAC,CACjD,KAAK,EAAE,aAAa;KAAE,GAAG;KAAO,OAAO,MAAM;IAAS,EAAE;IAC3D,OAAO,OAAO,MAAM,YAAY,MAAM;GACxC;EACF;CACF,CAAC;AACL;AAQA,MAAa,0BACX,OACA,EAAE,OAAO,OAAO,aACb;CACH,OA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AClC,GAAG,eAAe;EAElB,IAAI,UAAU;EAEd,SAAS,OAAO,aAAa;CAC/B,GACA;EAAC;EAAe;EAAU;EAAU;CAAK,CAC3C;CAEA,MAAM,gBAAA,GAAA,MAAA,YAAA,EACH,QAAQ,CAAC,OAAO;EACf,GAAGA,cAAAA,WACD;GACE;GACA,KAAK;GACL,iBAAiB,iBAAA,GAAA,oBAAA,cAAA,SAAA,CAAyB,QAAQ;GAClD,iBAAiB;GACjB,iBAAiB,iBAAA,GAAA,oBAAA,cAAA,SAAA,CAAyB,QAAQ;GAClD,kBAAA,GAAA,oBAAA,cAAA,SAAA,CAA0B,QAAQ;GAClC,cAAc;GACd,MAAM;GACN,UAAU;EACZ,GACA,MACA,OACA,EAAE,KAAK,SAAS,CAClB,CAAC,CAAC,EAAE,YAAY,MAAM,CAAC;EACvB,UAAA,GAAA,oBAAA,cAAA,WAAA,CAAoB,MAAM,SAAS,KAAK,SAAS,OAAO;EACxD,cAAA,GAAA,oBAAA,cAAA,WAAA,CAAwB,MAAM,aAAa,KAAK,aAAa,QAAQ;CACvE,IACA;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAQA,OAAO;EACL;EACA;EACA;EACA,oBAAA,GAAA,MAAA,YAAA,EATC,QAAQ,CAAC,MACRA,cAAAA,WAAW,EAAE,OAAO,EAAE,SAAS,WAAW,IAAI,EAAE,EAAE,GAAG,KAAK,CAAC,CAAC,GAC9D,CAAC,QAAQ,CAOO;EAChB;EACA;EACA;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../../../src/hooks/use-field-sizing/index.tsx"],"sourcesContent":["\"use client\"\n\nimport { useEffect, useMemo, useRef } from \"react\"\n\nexport interface UseFieldSizingProps {\n value?: string\n}\n\nexport const useFieldSizing = <Y extends HTMLElement>({\n value = \"\",\n}: UseFieldSizingProps) => {\n const ref = useRef<Y>(null)\n const textRef = useRef<HTMLSpanElement>(null)\n const text = useMemo(\n () => (\n <span\n ref={textRef}\n style={{\n opacity: 0,\n overflow: \"hidden\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n zIndex: -1,\n }}\n aria-hidden\n >\n {value}\n </span>\n ),\n [value],\n )\n\n useEffect(() => {\n if (!textRef.current) return\n\n const { width } = textRef.current.getBoundingClientRect()\n\n if (ref.current) ref.current.style.width = `${width}px`\n }, [value])\n\n return { ref, text }\n}\n\nexport type UseFieldSizingReturn = ReturnType<typeof useFieldSizing>\n"],"mappings":";;;;;AAQA,MAAa,kBAAyC,EACpD,QAAQ,SACiB;CACzB,MAAM,OAAA,GAAA,MAAA,OAAA,CAAgB,IAAI;CAC1B,MAAM,WAAA,GAAA,MAAA,OAAA,CAAkC,IAAI;CAC5C,MAAM,QAAA,GAAA,MAAA,QAAA,OAEF,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EACE,KAAK;EACL,OAAO;GACL,SAAS;GACT,UAAU;GACV,UAAU;GACV,YAAY;GACZ,QAAQ;EACV;EACA,eAAA;
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../../../src/hooks/use-field-sizing/index.tsx"],"sourcesContent":["\"use client\"\n\nimport { useEffect, useMemo, useRef } from \"react\"\n\nexport interface UseFieldSizingProps {\n value?: string\n}\n\nexport const useFieldSizing = <Y extends HTMLElement>({\n value = \"\",\n}: UseFieldSizingProps) => {\n const ref = useRef<Y>(null)\n const textRef = useRef<HTMLSpanElement>(null)\n const text = useMemo(\n () => (\n <span\n ref={textRef}\n style={{\n opacity: 0,\n overflow: \"hidden\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n zIndex: -1,\n }}\n aria-hidden\n >\n {value}\n </span>\n ),\n [value],\n )\n\n useEffect(() => {\n if (!textRef.current) return\n\n const { width } = textRef.current.getBoundingClientRect()\n\n if (ref.current) ref.current.style.width = `${width}px`\n }, [value])\n\n return { ref, text }\n}\n\nexport type UseFieldSizingReturn = ReturnType<typeof useFieldSizing>\n"],"mappings":";;;;;AAQA,MAAa,kBAAyC,EACpD,QAAQ,SACiB;CACzB,MAAM,OAAA,GAAA,MAAA,OAAA,CAAgB,IAAI;CAC1B,MAAM,WAAA,GAAA,MAAA,OAAA,CAAkC,IAAI;CAC5C,MAAM,QAAA,GAAA,MAAA,QAAA,OAEF,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EACE,KAAK;EACL,OAAO;GACL,SAAS;GACT,UAAU;GACV,UAAU;GACV,YAAY;GACZ,QAAQ;EACV;EACA,eAAA;EAEC,UAAA;CACG,CAAA,GAER,CAAC,KAAK,CACR;CAEA,CAAA,GAAA,MAAA,UAAA,OAAgB;EACd,IAAI,CAAC,QAAQ,SAAS;EAEtB,MAAM,EAAE,UAAU,QAAQ,QAAQ,sBAAsB;EAExD,IAAI,IAAI,SAAS,IAAI,QAAQ,MAAM,QAAQ,GAAG,MAAM;CACtD,GAAG,CAAC,KAAK,CAAC;CAEV,OAAO;EAAE;EAAK;CAAK;AACrB"}
|
|
@@ -26,7 +26,8 @@ const useFocusOnShow = (refOrEl, { focusTarget: focusRefOrEl, preventScroll, sho
|
|
|
26
26
|
const onFocus = (0, react.useCallback)(() => {
|
|
27
27
|
const target = getTarget();
|
|
28
28
|
if (!target || !trulyShouldFocus || focused.current) return;
|
|
29
|
-
|
|
29
|
+
const rootNode = target.getRootNode();
|
|
30
|
+
if ((0, require_utils_index.utils_exports.contains)(target, (0, require_utils_index.utils_exports.getActiveElement)((0, require_utils_index.utils_exports.isShadowRoot)(rootNode) ? rootNode : (0, require_utils_index.utils_exports.getDocument)(target)))) return;
|
|
30
31
|
const focusTarget = getFocusTarget();
|
|
31
32
|
if (focusTarget) requestAnimationFrame(() => {
|
|
32
33
|
focusTarget.focus({ preventScroll });
|
|
@@ -63,14 +64,17 @@ const useFocusOnShow = (refOrEl, { focusTarget: focusRefOrEl, preventScroll, sho
|
|
|
63
64
|
* @see https://yamada-ui.com/docs/hooks/use-focus-on-pointer-down
|
|
64
65
|
*/
|
|
65
66
|
const useFocusOnPointerDown = ({ ref, elements, enabled }) => {
|
|
66
|
-
require_hooks_use_event_listener_index.useEventListener(() => (0, require_utils_index.utils_exports.getDocument)(ref.current), "pointerdown", (ev) => {
|
|
67
|
+
require_hooks_use_event_listener_index.useEventListener(() => ref.current?.getRootNode() ?? (0, require_utils_index.utils_exports.getDocument)(ref.current), "pointerdown", (ev) => {
|
|
67
68
|
if (!(0, require_utils_index.utils_exports.isSafari)() || !enabled) return;
|
|
68
69
|
const target = ev.target;
|
|
69
|
-
const
|
|
70
|
+
const els = elements ?? [ref];
|
|
71
|
+
const rootNode = ref.current?.getRootNode();
|
|
72
|
+
const root = (0, require_utils_index.utils_exports.isShadowRoot)(rootNode) ? rootNode : (0, require_utils_index.utils_exports.getDocument)(ref.current);
|
|
73
|
+
const validTarget = els.some((elOrRef) => {
|
|
70
74
|
const el = require_ref.isRefObject(elOrRef) ? elOrRef.current : elOrRef;
|
|
71
75
|
return el?.contains(target) || el === target;
|
|
72
76
|
});
|
|
73
|
-
if ((0, require_utils_index.utils_exports.getActiveElement)(
|
|
77
|
+
if ((0, require_utils_index.utils_exports.getActiveElement)(root) !== target && validTarget) {
|
|
74
78
|
ev.preventDefault();
|
|
75
79
|
target.focus();
|
|
76
80
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["isRefObject"],"sources":["../../../../src/hooks/use-focus/index.ts"],"sourcesContent":["\"use client\"\n\nimport type { RefObject } from \"react\"\nimport { useCallback, useRef } from \"react\"\nimport {\n getActiveElement,\n getDocument,\n getFirstFocusableElement,\n isRefObject,\n isSafari,\n useUpdateEffect,\n} from \"../../utils\"\nimport { useEventListener } from \"../use-event-listener\"\n\nexport interface UseFocusOnShowProps {\n focusTarget?: HTMLElement | null | RefObject<HTMLElement | null>\n preventScroll?: boolean\n shouldFocus?: boolean\n visible?: boolean\n}\n\n/**\n * `useFocusOnShow` is a custom hook that focuses on the target element when it is shown.\n *\n * @see https://yamada-ui.com/docs/hooks/use-focus-on-show\n */\nexport const useFocusOnShow = <Y extends HTMLElement>(\n refOrEl: RefObject<null | Y> | Y,\n {\n focusTarget: focusRefOrEl,\n preventScroll,\n shouldFocus,\n visible,\n }: UseFocusOnShowProps = {\n preventScroll: true,\n shouldFocus: false,\n },\n) => {\n const trulyShouldFocus = shouldFocus && visible\n const focused = useRef(false)\n\n const getTarget = useCallback(() => {\n return isRefObject(refOrEl) ? refOrEl.current : refOrEl\n }, [refOrEl])\n\n const getFocusTarget = useCallback(() => {\n return isRefObject(focusRefOrEl) ? focusRefOrEl.current : focusRefOrEl\n }, [focusRefOrEl])\n\n const onFocus = useCallback(() => {\n const target = getTarget()\n\n if (!target || !trulyShouldFocus || focused.current) return\n if (
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["isRefObject"],"sources":["../../../../src/hooks/use-focus/index.ts"],"sourcesContent":["\"use client\"\n\nimport type { RefObject } from \"react\"\nimport { useCallback, useRef } from \"react\"\nimport {\n contains,\n getActiveElement,\n getDocument,\n getFirstFocusableElement,\n isRefObject,\n isSafari,\n isShadowRoot,\n useUpdateEffect,\n} from \"../../utils\"\nimport { useEventListener } from \"../use-event-listener\"\n\nexport interface UseFocusOnShowProps {\n focusTarget?: HTMLElement | null | RefObject<HTMLElement | null>\n preventScroll?: boolean\n shouldFocus?: boolean\n visible?: boolean\n}\n\n/**\n * `useFocusOnShow` is a custom hook that focuses on the target element when it is shown.\n *\n * @see https://yamada-ui.com/docs/hooks/use-focus-on-show\n */\nexport const useFocusOnShow = <Y extends HTMLElement>(\n refOrEl: RefObject<null | Y> | Y,\n {\n focusTarget: focusRefOrEl,\n preventScroll,\n shouldFocus,\n visible,\n }: UseFocusOnShowProps = {\n preventScroll: true,\n shouldFocus: false,\n },\n) => {\n const trulyShouldFocus = shouldFocus && visible\n const focused = useRef(false)\n\n const getTarget = useCallback(() => {\n return isRefObject(refOrEl) ? refOrEl.current : refOrEl\n }, [refOrEl])\n\n const getFocusTarget = useCallback(() => {\n return isRefObject(focusRefOrEl) ? focusRefOrEl.current : focusRefOrEl\n }, [focusRefOrEl])\n\n const onFocus = useCallback(() => {\n const target = getTarget()\n\n if (!target || !trulyShouldFocus || focused.current) return\n const rootNode = target.getRootNode()\n const root = isShadowRoot(rootNode) ? rootNode : getDocument(target)\n if (contains(target, getActiveElement(root))) return\n\n const focusTarget = getFocusTarget()\n\n if (focusTarget) {\n requestAnimationFrame(() => {\n focusTarget.focus({ preventScroll })\n\n focused.current = true\n })\n } else {\n const firstFocusable = getFirstFocusableElement(target)\n\n if (firstFocusable)\n requestAnimationFrame(() => {\n firstFocusable.focus({ preventScroll })\n\n focused.current = true\n })\n else\n requestAnimationFrame(() => {\n target.focus({ preventScroll })\n\n focused.current = true\n })\n }\n }, [getTarget, trulyShouldFocus, getFocusTarget, preventScroll])\n\n useUpdateEffect(() => {\n focused.current = !trulyShouldFocus\n }, [trulyShouldFocus])\n\n useUpdateEffect(() => {\n requestAnimationFrame(onFocus)\n }, [onFocus])\n\n useEventListener(getTarget, \"transitionend\", onFocus)\n}\n\nexport interface UseFocusOnMouseDownProps {\n ref: RefObject<HTMLElement | null>\n elements?: (HTMLElement | null | RefObject<HTMLElement | null>)[]\n enabled?: boolean\n}\n\n/**\n * `useFocusOnPointerDown` is a custom hook that focuses on the target element when it is clicked.\n *\n * @see https://yamada-ui.com/docs/hooks/use-focus-on-pointer-down\n */\nexport const useFocusOnPointerDown = ({\n ref,\n elements,\n enabled,\n}: UseFocusOnMouseDownProps) => {\n useEventListener(\n () => ref.current?.getRootNode() ?? getDocument(ref.current),\n \"pointerdown\",\n (ev) => {\n if (!isSafari() || !enabled) return\n\n const target = ev.target as HTMLElement\n const els = elements ?? [ref]\n const rootNode = ref.current?.getRootNode()\n const root = isShadowRoot(rootNode) ? rootNode : getDocument(ref.current)\n const validTarget = els.some((elOrRef) => {\n const el = isRefObject(elOrRef) ? elOrRef.current : elOrRef\n\n return el?.contains(target) || el === target\n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;EAAC;EAAW;EAAkB;EAAgB;CAAa,CAAC;CAE/D,eAAA,sBAAsB;EACpB,QAAQ,UAAU,CAAC;CACrB,GAAG,CAAC,gBAAgB,CAAC;CAErB,eAAA,sBAAsB;EACpB,sBAAsB,OAAO;CAC/B,GAAG,CAAC,OAAO,CAAC;CAEZ,uCAAA,iBAAiB,WAAW,iBAAiB,OAAO;AACtD;;;;;;AAaA,MAAa,yBAAyB,EACpC,KACA,UACA,cAC8B;CAC9B,uCAAA,uBACQ,IAAI,SAAS,YAAY,MAAA,GAAA,oBAAA,cAAA,YAAA,CAAiB,IAAI,OAAO,GAC3D,gBACC,OAAO;EACN,IAAI,EAAA,GAAA,oBAAA,cAAA,SAAA,CAAU,KAAK,CAAC,SAAS;EAE7B,MAAM,SAAS,GAAG;EAClB,MAAM,MAAM,YAAY,CAAC,GAAG;EAC5B,MAAM,WAAW,IAAI,SAAS,YAAY;EAC1C,MAAM,QAAA,GAAA,oBAAA,cAAA,aAAA,CAAoB,QAAQ,IAAI,YAAA,GAAA,oBAAA,cAAA,YAAA,CAAuB,IAAI,OAAO;EACxE,MAAM,cAAc,IAAI,MAAM,YAAY;GACxC,MAAM,KAAKA,YAAAA,YAAY,OAAO,IAAI,QAAQ,UAAU;GAEpD,OAAO,IAAI,SAAS,MAAM,KAAK,OAAO;EACxC,CAAC;EAED,KAAA,GAAA,oBAAA,cAAA,iBAAA,CAAqB,IAAI,MAAM,UAAU,aAAa;GACpD,GAAG,eAAe;GAElB,OAAO,MAAM;EACf;CACF,CACF;AACF"}
|
|
@@ -69,12 +69,14 @@ const useOutsideClick = ({ ref, enabled = true, handler }) => {
|
|
|
69
69
|
};
|
|
70
70
|
const isValidEvent = (ev, ref) => {
|
|
71
71
|
const target = ev.target;
|
|
72
|
+
const path = ev.composedPath();
|
|
72
73
|
if ("button" in ev && ev.button > 0) return false;
|
|
73
74
|
if (target) {
|
|
74
75
|
if (!(0, require_utils_index.utils_exports.getDocument)(target).contains(target)) return false;
|
|
75
76
|
}
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
const contains = (el) => !!el && (path.includes(el) || el.contains(target));
|
|
78
|
+
if ((0, require_utils_index.utils_exports.isArray)(ref)) return !ref.some(({ current }) => contains(current));
|
|
79
|
+
else return !contains(ref.current);
|
|
78
80
|
};
|
|
79
81
|
//#endregion
|
|
80
82
|
exports.useOutsideClick = useOutsideClick;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useCallbackRef"],"sources":["../../../../src/hooks/use-outside-click/index.ts"],"sourcesContent":["\"use client\"\n\nimport type { RefObject } from \"react\"\nimport { useCallback, useEffect, useRef } from \"react\"\nimport { getDocument, isArray, useCallbackRef } from \"../../utils\"\n\nexport interface UseOutsideClickProps {\n ref: RefObject<HTMLElement | null> | RefObject<HTMLElement | null>[]\n enabled?: boolean\n handler?: (ev: Event) => void\n}\n\n/**\n * `useOutsideClick` is a custom hook that detects click events outside of an element.\n *\n * @see https://yamada-ui.com/docs/hooks/use-outside-click\n */\nexport const useOutsideClick = ({\n ref,\n enabled = true,\n handler,\n}: UseOutsideClickProps) => {\n const handlerRef = useCallbackRef(handler)\n\n const state = useRef({\n ignoreEmulatedMouseEvents: false,\n isPointerDown: false,\n })\n\n const onPointerDown = useCallback(\n (ev: MouseEvent | TouchEvent) => {\n if (isValidEvent(ev, ref)) state.current.isPointerDown = true\n },\n [ref],\n )\n\n const onMouseUp = useCallback(\n (ev: MouseEvent) => {\n if (state.current.ignoreEmulatedMouseEvents) {\n state.current.ignoreEmulatedMouseEvents = false\n\n return\n }\n\n if (state.current.isPointerDown && handler && isValidEvent(ev, ref)) {\n state.current.isPointerDown = false\n\n handlerRef(ev)\n }\n },\n [handler, handlerRef, ref],\n )\n\n const onTouchEnd = useCallback(\n (ev: TouchEvent) => {\n state.current.ignoreEmulatedMouseEvents = true\n\n if (state.current.isPointerDown && handler && isValidEvent(ev, ref)) {\n state.current.isPointerDown = false\n\n handlerRef(ev)\n }\n },\n [handler, handlerRef, ref],\n )\n\n useEffect(() => {\n if (!enabled) return\n\n const doc = getDocument(isArray(ref) ? ref[0]?.current : ref.current)\n\n doc.addEventListener(\"mousedown\", onPointerDown, true)\n doc.addEventListener(\"mouseup\", onMouseUp, true)\n doc.addEventListener(\"touchstart\", onPointerDown, true)\n doc.addEventListener(\"touchend\", onTouchEnd, true)\n\n return () => {\n doc.removeEventListener(\"mousedown\", onPointerDown, true)\n doc.removeEventListener(\"mouseup\", onMouseUp, true)\n doc.removeEventListener(\"touchstart\", onPointerDown, true)\n doc.removeEventListener(\"touchend\", onTouchEnd, true)\n }\n }, [\n handler,\n ref,\n handlerRef,\n state,\n enabled,\n onPointerDown,\n onMouseUp,\n onTouchEnd,\n ])\n}\n\nconst isValidEvent = (\n ev: MouseEvent | TouchEvent,\n ref: RefObject<HTMLElement | null> | RefObject<HTMLElement | null>[],\n) => {\n const target = ev.target as HTMLElement | null\n\n if (\"button\" in ev && ev.button > 0) return false\n\n if (target) if (!getDocument(target).contains(target)) return false\n\n if (isArray(ref)) return !ref.some((
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useCallbackRef"],"sources":["../../../../src/hooks/use-outside-click/index.ts"],"sourcesContent":["\"use client\"\n\nimport type { RefObject } from \"react\"\nimport { useCallback, useEffect, useRef } from \"react\"\nimport { getDocument, isArray, useCallbackRef } from \"../../utils\"\n\nexport interface UseOutsideClickProps {\n ref: RefObject<HTMLElement | null> | RefObject<HTMLElement | null>[]\n enabled?: boolean\n handler?: (ev: Event) => void\n}\n\n/**\n * `useOutsideClick` is a custom hook that detects click events outside of an element.\n *\n * @see https://yamada-ui.com/docs/hooks/use-outside-click\n */\nexport const useOutsideClick = ({\n ref,\n enabled = true,\n handler,\n}: UseOutsideClickProps) => {\n const handlerRef = useCallbackRef(handler)\n\n const state = useRef({\n ignoreEmulatedMouseEvents: false,\n isPointerDown: false,\n })\n\n const onPointerDown = useCallback(\n (ev: MouseEvent | TouchEvent) => {\n if (isValidEvent(ev, ref)) state.current.isPointerDown = true\n },\n [ref],\n )\n\n const onMouseUp = useCallback(\n (ev: MouseEvent) => {\n if (state.current.ignoreEmulatedMouseEvents) {\n state.current.ignoreEmulatedMouseEvents = false\n\n return\n }\n\n if (state.current.isPointerDown && handler && isValidEvent(ev, ref)) {\n state.current.isPointerDown = false\n\n handlerRef(ev)\n }\n },\n [handler, handlerRef, ref],\n )\n\n const onTouchEnd = useCallback(\n (ev: TouchEvent) => {\n state.current.ignoreEmulatedMouseEvents = true\n\n if (state.current.isPointerDown && handler && isValidEvent(ev, ref)) {\n state.current.isPointerDown = false\n\n handlerRef(ev)\n }\n },\n [handler, handlerRef, ref],\n )\n\n useEffect(() => {\n if (!enabled) return\n\n const doc = getDocument(isArray(ref) ? ref[0]?.current : ref.current)\n\n doc.addEventListener(\"mousedown\", onPointerDown, true)\n doc.addEventListener(\"mouseup\", onMouseUp, true)\n doc.addEventListener(\"touchstart\", onPointerDown, true)\n doc.addEventListener(\"touchend\", onTouchEnd, true)\n\n return () => {\n doc.removeEventListener(\"mousedown\", onPointerDown, true)\n doc.removeEventListener(\"mouseup\", onMouseUp, true)\n doc.removeEventListener(\"touchstart\", onPointerDown, true)\n doc.removeEventListener(\"touchend\", onTouchEnd, true)\n }\n }, [\n handler,\n ref,\n handlerRef,\n state,\n enabled,\n onPointerDown,\n onMouseUp,\n onTouchEnd,\n ])\n}\n\nconst isValidEvent = (\n ev: MouseEvent | TouchEvent,\n ref: RefObject<HTMLElement | null> | RefObject<HTMLElement | null>[],\n) => {\n const target = ev.target as HTMLElement | null\n const path = ev.composedPath()\n\n if (\"button\" in ev && ev.button > 0) return false\n\n if (target) if (!getDocument(target).contains(target)) return false\n\n const contains = (el: HTMLElement | null) =>\n !!el && (path.includes(el) || el.contains(target))\n\n if (isArray(ref)) return !ref.some(({ current }) => contains(current))\n else return !contains(ref.current)\n}\n"],"mappings":";;;;;;;;;;;AAiBA,MAAa,mBAAmB,EAC9B,KACA,UAAU,MACV,cAC0B;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,eAAe,IAAI;GACzD,IAAI,oBAAoB,YAAY,YAAY,IAAI;EACtD;CACF,GAAG;EACD;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACH;AAEA,MAAM,gBACJ,IACA,QACG;CACH,MAAM,SAAS,GAAG;CAClB,MAAM,OAAO,GAAG,aAAa;CAE7B,IAAI,YAAY,MAAM,GAAG,SAAS,GAAG,OAAO;CAE5C,IAAI,QAAY;MAAA,EAAA,GAAA,oBAAA,cAAA,YAAA,CAAa,MAAM,CAAC,CAAC,SAAS,MAAM,GAAG,OAAO;CAAA;CAE9D,MAAM,YAAY,OAChB,CAAC,CAAC,OAAO,KAAK,SAAS,EAAE,KAAK,GAAG,SAAS,MAAM;CAElD,KAAA,GAAA,oBAAA,cAAA,QAAA,CAAY,GAAG,GAAG,OAAO,CAAC,IAAI,MAAM,EAAE,cAAc,SAAS,OAAO,CAAC;MAChE,OAAO,CAAC,SAAS,IAAI,OAAO;AACnC"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -426,7 +426,7 @@ const require_circle_dot_dashed_icon = require("./components/icon/icons/circle-d
|
|
|
426
426
|
const require_circle_dot_icon = require("./components/icon/icons/circle-dot-icon.cjs");
|
|
427
427
|
const require_circle_ellipsis_icon = require("./components/icon/icons/circle-ellipsis-icon.cjs");
|
|
428
428
|
const require_circle_equal_icon = require("./components/icon/icons/circle-equal-icon.cjs");
|
|
429
|
-
const
|
|
429
|
+
const require_circle_euro_icon = require("./components/icon/icons/circle-euro-icon.cjs");
|
|
430
430
|
const require_circle_fading_arrow_up_icon = require("./components/icon/icons/circle-fading-arrow-up-icon.cjs");
|
|
431
431
|
const require_circle_fading_plus_icon = require("./components/icon/icons/circle-fading-plus-icon.cjs");
|
|
432
432
|
const require_circle_gauge_icon = require("./components/icon/icons/circle-gauge-icon.cjs");
|
|
@@ -1342,6 +1342,7 @@ const require_scale3d_icon = require("./components/icon/icons/scale3d-icon.cjs")
|
|
|
1342
1342
|
const require_scale_icon = require("./components/icon/icons/scale-icon.cjs");
|
|
1343
1343
|
const require_scaling_icon = require("./components/icon/icons/scaling-icon.cjs");
|
|
1344
1344
|
const require_scan_barcode_icon = require("./components/icon/icons/scan-barcode-icon.cjs");
|
|
1345
|
+
const require_scan_box_icon = require("./components/icon/icons/scan-box-icon.cjs");
|
|
1345
1346
|
const require_scan_eye_icon = require("./components/icon/icons/scan-eye-icon.cjs");
|
|
1346
1347
|
const require_scan_face_icon = require("./components/icon/icons/scan-face-icon.cjs");
|
|
1347
1348
|
const require_scan_heart_icon = require("./components/icon/icons/scan-heart-icon.cjs");
|
|
@@ -1374,6 +1375,7 @@ const require_server_cog_icon = require("./components/icon/icons/server-cog-icon
|
|
|
1374
1375
|
const require_server_crash_icon = require("./components/icon/icons/server-crash-icon.cjs");
|
|
1375
1376
|
const require_server_icon = require("./components/icon/icons/server-icon.cjs");
|
|
1376
1377
|
const require_server_off_icon = require("./components/icon/icons/server-off-icon.cjs");
|
|
1378
|
+
const require_server_plus_icon = require("./components/icon/icons/server-plus-icon.cjs");
|
|
1377
1379
|
const require_settings2_icon = require("./components/icon/icons/settings2-icon.cjs");
|
|
1378
1380
|
const require_settings_icon = require("./components/icon/icons/settings-icon.cjs");
|
|
1379
1381
|
const require_shapes_icon = require("./components/icon/icons/shapes-icon.cjs");
|
|
@@ -1824,6 +1826,7 @@ const require_namespace$2 = require("./components/native-popover/namespace.cjs")
|
|
|
1824
1826
|
const require_popover_style = require("./components/popover/popover.style.cjs");
|
|
1825
1827
|
const require_fade_scale_style = require("./components/fade-scale/fade-scale.style.cjs");
|
|
1826
1828
|
const require_fade_scale = require("./components/fade-scale/fade-scale.cjs");
|
|
1829
|
+
const require_focus_lock = require("./components/focus-lock/focus-lock.cjs");
|
|
1827
1830
|
const require_portal = require("./components/portal/portal.cjs");
|
|
1828
1831
|
const require_slide_fade_style = require("./components/slide-fade/slide-fade.style.cjs");
|
|
1829
1832
|
const require_slide_fade = require("./components/slide-fade/slide-fade.cjs");
|
|
@@ -2041,7 +2044,6 @@ const require_namespace$31 = require("./components/data-list/namespace.cjs");
|
|
|
2041
2044
|
const require_modal_style = require("./components/modal/modal.style.cjs");
|
|
2042
2045
|
const require_fade_style = require("./components/fade/fade.style.cjs");
|
|
2043
2046
|
const require_fade = require("./components/fade/fade.cjs");
|
|
2044
|
-
const require_focus_lock = require("./components/focus-lock/focus-lock.cjs");
|
|
2045
2047
|
const require_use_modal = require("./components/modal/use-modal.cjs");
|
|
2046
2048
|
const require_modal = require("./components/modal/modal.cjs");
|
|
2047
2049
|
const require_namespace$32 = require("./components/modal/namespace.cjs");
|
|
@@ -2757,7 +2759,7 @@ var src_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
2757
2759
|
CircleDotIcon: () => require_circle_dot_icon.CircleDotIcon,
|
|
2758
2760
|
CircleEllipsisIcon: () => require_circle_ellipsis_icon.CircleEllipsisIcon,
|
|
2759
2761
|
CircleEqualIcon: () => require_circle_equal_icon.CircleEqualIcon,
|
|
2760
|
-
|
|
2762
|
+
CircleEuroIcon: () => require_circle_euro_icon.CircleEuroIcon,
|
|
2761
2763
|
CircleFadingArrowUpIcon: () => require_circle_fading_arrow_up_icon.CircleFadingArrowUpIcon,
|
|
2762
2764
|
CircleFadingPlusIcon: () => require_circle_fading_plus_icon.CircleFadingPlusIcon,
|
|
2763
2765
|
CircleGaugeIcon: () => require_circle_gauge_icon.CircleGaugeIcon,
|
|
@@ -4031,6 +4033,7 @@ var src_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
4031
4033
|
ScaleIcon: () => require_scale_icon.ScaleIcon,
|
|
4032
4034
|
ScalingIcon: () => require_scaling_icon.ScalingIcon,
|
|
4033
4035
|
ScanBarcodeIcon: () => require_scan_barcode_icon.ScanBarcodeIcon,
|
|
4036
|
+
ScanBoxIcon: () => require_scan_box_icon.ScanBoxIcon,
|
|
4034
4037
|
ScanEyeIcon: () => require_scan_eye_icon.ScanEyeIcon,
|
|
4035
4038
|
ScanFaceIcon: () => require_scan_face_icon.ScanFaceIcon,
|
|
4036
4039
|
ScanHeartIcon: () => require_scan_heart_icon.ScanHeartIcon,
|
|
@@ -4081,6 +4084,7 @@ var src_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
4081
4084
|
ServerCrashIcon: () => require_server_crash_icon.ServerCrashIcon,
|
|
4082
4085
|
ServerIcon: () => require_server_icon.ServerIcon,
|
|
4083
4086
|
ServerOffIcon: () => require_server_off_icon.ServerOffIcon,
|
|
4087
|
+
ServerPlusIcon: () => require_server_plus_icon.ServerPlusIcon,
|
|
4084
4088
|
Settings2Icon: () => require_settings2_icon.Settings2Icon,
|
|
4085
4089
|
SettingsIcon: () => require_settings_icon.SettingsIcon,
|
|
4086
4090
|
ShapesIcon: () => require_shapes_icon.ShapesIcon,
|
|
@@ -5082,6 +5086,7 @@ var src_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
5082
5086
|
useFlexPropsContext: () => require_flex.useFlexPropsContext,
|
|
5083
5087
|
useFlipPropsContext: () => require_flip.useFlipPropsContext,
|
|
5084
5088
|
useFloatPropsContext: () => require_float.useFloatPropsContext,
|
|
5089
|
+
useFocusLockShard: () => require_focus_lock.useFocusLockShard,
|
|
5085
5090
|
useFocusOnPointerDown: () => require_hooks_use_focus_index.useFocusOnPointerDown,
|
|
5086
5091
|
useFocusOnShow: () => require_hooks_use_focus_index.useFocusOnShow,
|
|
5087
5092
|
useFormContext: () => require_form.useFormContext,
|
|
@@ -5921,7 +5926,7 @@ exports.CircleDotDashedIcon = require_circle_dot_dashed_icon.CircleDotDashedIcon
|
|
|
5921
5926
|
exports.CircleDotIcon = require_circle_dot_icon.CircleDotIcon;
|
|
5922
5927
|
exports.CircleEllipsisIcon = require_circle_ellipsis_icon.CircleEllipsisIcon;
|
|
5923
5928
|
exports.CircleEqualIcon = require_circle_equal_icon.CircleEqualIcon;
|
|
5924
|
-
exports.
|
|
5929
|
+
exports.CircleEuroIcon = require_circle_euro_icon.CircleEuroIcon;
|
|
5925
5930
|
exports.CircleFadingArrowUpIcon = require_circle_fading_arrow_up_icon.CircleFadingArrowUpIcon;
|
|
5926
5931
|
exports.CircleFadingPlusIcon = require_circle_fading_plus_icon.CircleFadingPlusIcon;
|
|
5927
5932
|
exports.CircleGaugeIcon = require_circle_gauge_icon.CircleGaugeIcon;
|
|
@@ -7390,6 +7395,7 @@ exports.Scale3dIcon = require_scale3d_icon.Scale3dIcon;
|
|
|
7390
7395
|
exports.ScaleIcon = require_scale_icon.ScaleIcon;
|
|
7391
7396
|
exports.ScalingIcon = require_scaling_icon.ScalingIcon;
|
|
7392
7397
|
exports.ScanBarcodeIcon = require_scan_barcode_icon.ScanBarcodeIcon;
|
|
7398
|
+
exports.ScanBoxIcon = require_scan_box_icon.ScanBoxIcon;
|
|
7393
7399
|
exports.ScanEyeIcon = require_scan_eye_icon.ScanEyeIcon;
|
|
7394
7400
|
exports.ScanFaceIcon = require_scan_face_icon.ScanFaceIcon;
|
|
7395
7401
|
exports.ScanHeartIcon = require_scan_heart_icon.ScanHeartIcon;
|
|
@@ -7450,6 +7456,7 @@ exports.ServerCogIcon = require_server_cog_icon.ServerCogIcon;
|
|
|
7450
7456
|
exports.ServerCrashIcon = require_server_crash_icon.ServerCrashIcon;
|
|
7451
7457
|
exports.ServerIcon = require_server_icon.ServerIcon;
|
|
7452
7458
|
exports.ServerOffIcon = require_server_off_icon.ServerOffIcon;
|
|
7459
|
+
exports.ServerPlusIcon = require_server_plus_icon.ServerPlusIcon;
|
|
7453
7460
|
exports.Settings2Icon = require_settings2_icon.Settings2Icon;
|
|
7454
7461
|
exports.SettingsIcon = require_settings_icon.SettingsIcon;
|
|
7455
7462
|
exports.ShapesIcon = require_shapes_icon.ShapesIcon;
|
|
@@ -8496,6 +8503,7 @@ exports.useFindChildren = require_children.useFindChildren;
|
|
|
8496
8503
|
exports.useFlexPropsContext = require_flex.useFlexPropsContext;
|
|
8497
8504
|
exports.useFlipPropsContext = require_flip.useFlipPropsContext;
|
|
8498
8505
|
exports.useFloatPropsContext = require_float.useFloatPropsContext;
|
|
8506
|
+
exports.useFocusLockShard = require_focus_lock.useFocusLockShard;
|
|
8499
8507
|
exports.useFocusOnPointerDown = require_hooks_use_focus_index.useFocusOnPointerDown;
|
|
8500
8508
|
exports.useFocusOnShow = require_hooks_use_focus_index.useFocusOnShow;
|
|
8501
8509
|
exports.useFormContext = require_form.useFormContext;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ui-provider.cjs","names":["defaultConfig","defaultTheme","EnvironmentProvider","I18nProvider","SystemProvider","config","theme","ThemeProvider","ColorModeProvider","LoadingProvider","NoticeProvider"],"sources":["../../../../src/providers/ui-provider/ui-provider.tsx"],"sourcesContent":["import type { FC } from \"react\"\nimport type {\n ColorModeProviderProps,\n EnvironmentProviderProps,\n ThemeConfig,\n ThemeProviderProps,\n UsageTheme,\n} from \"../../core\"\nimport type { DeepMerge } from \"../../utils\"\nimport type { I18nProviderProps } from \"../i18n-provider\"\nimport { LoadingProvider } from \"../../components/loading\"\nimport { NoticeProvider } from \"../../components/notice\"\nimport {\n ColorModeProvider,\n EnvironmentProvider,\n SystemProvider,\n ThemeProvider,\n} from \"../../core\"\nimport { config as defaultConfig, theme as defaultTheme } from \"../../theme\"\nimport { merge } from \"../../utils\"\nimport { I18nProvider } from \"../i18n-provider\"\n\nexport interface UIProviderProps\n extends\n Omit<ThemeProviderProps, \"storageKey\">,\n Pick<ColorModeProviderProps, \"colorMode\">,\n I18nProviderProps {\n /**\n * Key of value saved in storage.\n * By default, it is saved to `local storage`.\n */\n colorModeStorageKey?: string\n /**\n * The root node to use.\n */\n rootNode?: EnvironmentProviderProps[\"value\"]\n /**\n * Key of value saved in storage.\n * By default, it is saved to `local storage`.\n */\n themeSchemeStorageKey?: string\n}\n\n/**\n * The global provider that must be added to make all Yamada UI components work correctly.\n */\nexport const UIProvider: FC<UIProviderProps> = ({\n children,\n colorMode,\n colorModeStorageKey,\n config = defaultConfig,\n cookie,\n dir,\n intl,\n locale,\n rootNode,\n storage,\n theme = defaultTheme,\n themeSchemeStorageKey,\n}) => {\n return (\n <EnvironmentProvider value={rootNode}>\n <I18nProvider dir={dir} intl={intl} locale={locale}>\n <SystemProvider config={config} theme={theme}>\n <ThemeProvider\n config={config}\n cookie={cookie}\n storage={storage}\n storageKey={themeSchemeStorageKey}\n theme={theme}\n >\n <ColorModeProvider\n colorMode={colorMode}\n config={config}\n cookie={cookie}\n storage={storage}\n storageKey={colorModeStorageKey}\n >\n <LoadingProvider {...config.loading}>\n <NoticeProvider {...config.notice}>{children}</NoticeProvider>\n </LoadingProvider>\n </ColorModeProvider>\n </ThemeProvider>\n </SystemProvider>\n </I18nProvider>\n </EnvironmentProvider>\n )\n}\n\ntype DefaultTheme = typeof defaultTheme\n\nexport const extendTheme = <Y extends UsageTheme>(theme: Y) => {\n return merge<DeepMerge<DefaultTheme, Y>>(defaultTheme, theme)\n}\n\nexport const extendConfig = (config: ThemeConfig) => {\n return merge(defaultConfig, config)\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8CA,MAAa,cAAmC,EAC9C,UACA,WACA,qBACA,QAAA,WAASA,eAAAA,QACT,QACA,KACA,MACA,QACA,UACA,SACA,OAAA,UAAQC,oBAAAA,OACR,4BACI;CACJ,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,6BAAAA,qBAAD;EAAqB,OAAO;
|
|
1
|
+
{"version":3,"file":"ui-provider.cjs","names":["defaultConfig","defaultTheme","EnvironmentProvider","I18nProvider","SystemProvider","config","theme","ThemeProvider","ColorModeProvider","LoadingProvider","NoticeProvider"],"sources":["../../../../src/providers/ui-provider/ui-provider.tsx"],"sourcesContent":["import type { FC } from \"react\"\nimport type {\n ColorModeProviderProps,\n EnvironmentProviderProps,\n ThemeConfig,\n ThemeProviderProps,\n UsageTheme,\n} from \"../../core\"\nimport type { DeepMerge } from \"../../utils\"\nimport type { I18nProviderProps } from \"../i18n-provider\"\nimport { LoadingProvider } from \"../../components/loading\"\nimport { NoticeProvider } from \"../../components/notice\"\nimport {\n ColorModeProvider,\n EnvironmentProvider,\n SystemProvider,\n ThemeProvider,\n} from \"../../core\"\nimport { config as defaultConfig, theme as defaultTheme } from \"../../theme\"\nimport { merge } from \"../../utils\"\nimport { I18nProvider } from \"../i18n-provider\"\n\nexport interface UIProviderProps\n extends\n Omit<ThemeProviderProps, \"storageKey\">,\n Pick<ColorModeProviderProps, \"colorMode\">,\n I18nProviderProps {\n /**\n * Key of value saved in storage.\n * By default, it is saved to `local storage`.\n */\n colorModeStorageKey?: string\n /**\n * The root node to use.\n */\n rootNode?: EnvironmentProviderProps[\"value\"]\n /**\n * Key of value saved in storage.\n * By default, it is saved to `local storage`.\n */\n themeSchemeStorageKey?: string\n}\n\n/**\n * The global provider that must be added to make all Yamada UI components work correctly.\n */\nexport const UIProvider: FC<UIProviderProps> = ({\n children,\n colorMode,\n colorModeStorageKey,\n config = defaultConfig,\n cookie,\n dir,\n intl,\n locale,\n rootNode,\n storage,\n theme = defaultTheme,\n themeSchemeStorageKey,\n}) => {\n return (\n <EnvironmentProvider value={rootNode}>\n <I18nProvider dir={dir} intl={intl} locale={locale}>\n <SystemProvider config={config} theme={theme}>\n <ThemeProvider\n config={config}\n cookie={cookie}\n storage={storage}\n storageKey={themeSchemeStorageKey}\n theme={theme}\n >\n <ColorModeProvider\n colorMode={colorMode}\n config={config}\n cookie={cookie}\n storage={storage}\n storageKey={colorModeStorageKey}\n >\n <LoadingProvider {...config.loading}>\n <NoticeProvider {...config.notice}>{children}</NoticeProvider>\n </LoadingProvider>\n </ColorModeProvider>\n </ThemeProvider>\n </SystemProvider>\n </I18nProvider>\n </EnvironmentProvider>\n )\n}\n\ntype DefaultTheme = typeof defaultTheme\n\nexport const extendTheme = <Y extends UsageTheme>(theme: Y) => {\n return merge<DeepMerge<DefaultTheme, Y>>(defaultTheme, theme)\n}\n\nexport const extendConfig = (config: ThemeConfig) => {\n return merge(defaultConfig, config)\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8CA,MAAa,cAAmC,EAC9C,UACA,WACA,qBACA,QAAA,WAASA,eAAAA,QACT,QACA,KACA,MACA,QACA,UACA,SACA,OAAA,UAAQC,oBAAAA,OACR,4BACI;CACJ,OACE,iBAAA,GAAA,kBAAA,IAAA,CAACC,6BAAAA,qBAAD;EAAqB,OAAO;EAC1B,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,sBAAAA,cAAD;GAAmB;GAAW;GAAc;GAC1C,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,wBAAAA,gBAAD;IAAgB,QAAQC;IAAQ,OAAOC;IACrC,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,uBAAAA,eAAD;KACE,QAAQF;KACA;KACC;KACT,YAAY;KACZ,OAAOC;KAEP,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACE,4BAAAA,mBAAD;MACa;MACX,QAAQH;MACA;MACC;MACT,YAAY;MAEZ,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACI,yBAAAA,iBAAD;OAAiB,GAAIJ,SAAO;OAC1B,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACK,wBAAAA,gBAAD;QAAgB,GAAIL,SAAO;QAAS;OAAyB,CAAA;MAC9C,CAAA;KACA,CAAA;IACN,CAAA;GACD,CAAA;EACJ,CAAA;CACK,CAAA;AAEzB;AAIA,MAAa,eAAqC,YAAa;CAC7D,QAAA,GAAA,oBAAA,cAAA,MAAA,CAAyCJ,oBAAAA,OAAcK,OAAK;AAC9D;AAEA,MAAa,gBAAgB,aAAwB;CACnD,QAAA,GAAA,oBAAA,cAAA,MAAA,CAAaN,eAAAA,QAAeK,QAAM;AACpC"}
|
package/dist/cjs/utils/dom.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
2
2
|
let react = require("react");
|
|
3
3
|
react = require_runtime.__toESM(react, 1);
|
|
4
|
+
let _yamada_ui_utils = require("@yamada-ui/utils");
|
|
4
5
|
//#region src/utils/dom.ts
|
|
5
6
|
function runKeyAction(ev, actions, { preventDefault = true } = {}) {
|
|
6
7
|
if (ev.key === " ") ev.key = ev.code;
|
|
@@ -32,7 +33,9 @@ function useAttributeObserver(ref, attributeFilter, enabled, func) {
|
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
function getEventRelatedTarget(ev) {
|
|
35
|
-
|
|
36
|
+
if (ev.relatedTarget) return ev.relatedTarget;
|
|
37
|
+
const root = ev.currentTarget.getRootNode?.call(ev.currentTarget);
|
|
38
|
+
return (root && (0, _yamada_ui_utils.getActiveElement)(root)) ?? ev.currentTarget.ownerDocument.activeElement;
|
|
36
39
|
}
|
|
37
40
|
const visuallyHiddenAttributes = {
|
|
38
41
|
style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dom.cjs","names":["React"],"sources":["../../../src/utils/dom.ts"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"file":"dom.cjs","names":["React"],"sources":["../../../src/utils/dom.ts"],"sourcesContent":["import { type AnyString, getActiveElement } from \"@yamada-ui/utils\"\nimport * as React from \"react\"\n\ntype KeyboardNavigationKey =\n | \"ArrowDown\"\n | \"ArrowLeft\"\n | \"ArrowRight\"\n | \"ArrowUp\"\n | \"End\"\n | \"Home\"\n | \"PageDown\"\n | \"PageUp\"\n\ntype KeyboardControlKey =\n | \"Alt\"\n | \"Backspace\"\n | \"CapsLock\"\n | \"Control\"\n | \"Delete\"\n | \"Enter\"\n | \"Escape\"\n | \"Insert\"\n | \"Meta\"\n | \"NumLock\"\n | \"Pause\"\n | \"PrintScreen\"\n | \"ScrollLock\"\n | \"Shift\"\n | \"Space\"\n | \"Tab\"\n\ntype KeyboardFunctionKey = \"Fn\" | \"FnLock\" | `F${number}`\n\ntype KeyboardKey =\n | AnyString\n | KeyboardControlKey\n | KeyboardFunctionKey\n | KeyboardNavigationKey\n\nexport function runKeyAction<Y>(\n ev: React.KeyboardEvent<Y>,\n actions: { [key in KeyboardKey]?: React.KeyboardEventHandler<Y> },\n { preventDefault = true }: { preventDefault?: boolean } = {},\n) {\n if (ev.key === \" \") ev.key = ev.code\n const action = actions[ev.key]\n\n if (!action) return\n\n if (preventDefault) ev.preventDefault()\n\n action(ev)\n}\n\nexport function isComposing(\n ev: React.ChangeEvent<HTMLElement> | React.KeyboardEvent<HTMLElement>,\n): boolean {\n if (\"keyCode\" in ev) return ev.nativeEvent.isComposing || ev.keyCode === 229\n else if (ev.nativeEvent instanceof InputEvent)\n return ev.nativeEvent.isComposing\n else return false\n}\n\nexport function useAttributeObserver(\n ref: React.RefObject<HTMLElement | null>,\n attributeFilter: string[],\n enabled: boolean,\n func: () => void,\n) {\n React.useEffect(() => {\n if (!ref.current || !enabled) return\n\n const ownerDocument = ref.current.ownerDocument.defaultView ?? window\n\n const observer = new ownerDocument.MutationObserver((changes) => {\n for (const { type, attributeName } of changes) {\n if (type !== \"attributes\") continue\n if (!attributeName) continue\n\n if (attributeFilter.includes(attributeName)) func()\n }\n })\n\n observer.observe(ref.current, { attributeFilter, attributes: true })\n\n return () => observer.disconnect()\n })\n}\n\nexport function getEventRelatedTarget(ev: React.FocusEvent | React.MouseEvent) {\n if (ev.relatedTarget) return ev.relatedTarget as HTMLElement\n\n const getRootNode = (\n ev.currentTarget as unknown as {\n getRootNode?: () => Document | ShadowRoot\n }\n ).getRootNode\n const root = getRootNode?.call(ev.currentTarget)\n\n return ((root && getActiveElement(root)) ??\n ev.currentTarget.ownerDocument.activeElement) as HTMLElement | null\n}\n\nconst visuallyHiddenStyle = {\n border: \"0px\",\n clipPath: \"rect(0px 0px 0px 0px)\",\n height: \"1px\",\n margin: \"-1px\",\n overflow: \"hidden\",\n padding: \"0px\",\n position: \"absolute\",\n whiteSpace: \"nowrap\",\n width: \"1px\",\n} satisfies React.CSSProperties\n\nexport const visuallyHiddenAttributes = {\n style: visuallyHiddenStyle,\n \"aria-hidden\": true,\n tabIndex: -1,\n} satisfies React.HTMLAttributes<HTMLElement>\n\nexport function* useIds() {\n const id = React.useId()\n\n for (let i = 0; ; i++) yield `${id}-${i}`\n}\n"],"mappings":";;;;;AAuCA,SAAgB,aACd,IACA,SACA,EAAE,iBAAiB,SAAuC,CAAC,GAC3D;CACA,IAAI,GAAG,QAAQ,KAAK,GAAG,MAAM,GAAG;CAChC,MAAM,SAAS,QAAQ,GAAG;CAE1B,IAAI,CAAC,QAAQ;CAEb,IAAI,gBAAgB,GAAG,eAAe;CAEtC,OAAO,EAAE;AACX;AAEA,SAAgB,YACd,IACS;CACT,IAAI,aAAa,IAAI,OAAO,GAAG,YAAY,eAAe,GAAG,YAAY;MACpE,IAAI,GAAG,uBAAuB,YACjC,OAAO,GAAG,YAAY;MACnB,OAAO;AACd;AAEA,SAAgB,qBACd,KACA,iBACA,SACA,MACA;CACA,MAAM,gBAAgB;EACpB,IAAI,CAAC,IAAI,WAAW,CAAC,SAAS;EAI9B,MAAM,WAAW,KAFK,IAAI,QAAQ,cAAc,eAAe,OAAA,CAE5B,kBAAkB,YAAY;GAC/D,KAAK,MAAM,EAAE,MAAM,mBAAmB,SAAS;IAC7C,IAAI,SAAS,cAAc;IAC3B,IAAI,CAAC,eAAe;IAEpB,IAAI,gBAAgB,SAAS,aAAa,GAAG,KAAK;GACpD;EACF,CAAC;EAED,SAAS,QAAQ,IAAI,SAAS;GAAE;GAAiB,YAAY;EAAK,CAAC;EAEnE,aAAa,SAAS,WAAW;CACnC,CAAC;AACH;AAEA,SAAgB,sBAAsB,IAAyC;CAC7E,IAAI,GAAG,eAAe,OAAO,GAAG;CAOhC,MAAM,OAJJ,GAAG,cAGH,aACwB,KAAK,GAAG,aAAa;CAE/C,QAAS,SAAA,GAAA,iBAAA,iBAAA,CAAyB,IAAI,MACpC,GAAG,cAAc,cAAc;AACnC;AAcA,MAAa,2BAA2B;CACtC,OAAO;EAZP,QAAQ;EACR,UAAU;EACV,QAAQ;EACR,QAAQ;EACR,UAAU;EACV,S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