@yamada-ui/react 2.3.0-next-20261009073533 → 2.3.1-dev-20261030022105
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 +4 -3
- package/dist/cjs/components/accordion/accordion.cjs.map +1 -1
- package/dist/cjs/components/aspect-ratio/aspect-ratio.cjs +2 -2
- package/dist/cjs/components/aspect-ratio/aspect-ratio.cjs.map +1 -1
- package/dist/cjs/components/blockquote/blockquote.style.cjs +1 -1
- package/dist/cjs/components/blockquote/blockquote.style.cjs.map +1 -1
- package/dist/cjs/components/breadcrumb/use-breadcrumb.cjs +2 -1
- package/dist/cjs/components/breadcrumb/use-breadcrumb.cjs.map +1 -1
- package/dist/cjs/components/bubble/bubble.cjs +163 -0
- package/dist/cjs/components/bubble/bubble.cjs.map +1 -0
- package/dist/cjs/components/bubble/bubble.style.cjs +143 -0
- package/dist/cjs/components/bubble/bubble.style.cjs.map +1 -0
- package/dist/cjs/components/bubble/index.cjs +18 -0
- package/dist/cjs/components/bubble/namespace.cjs +28 -0
- package/dist/cjs/components/bubble/namespace.cjs.map +1 -0
- package/dist/cjs/components/button/button.cjs +11 -8
- package/dist/cjs/components/button/button.cjs.map +1 -1
- package/dist/cjs/components/calendar/calendar.cjs +3 -1
- package/dist/cjs/components/calendar/calendar.cjs.map +1 -1
- package/dist/cjs/components/calendar/use-calendar.cjs +11 -6
- package/dist/cjs/components/calendar/use-calendar.cjs.map +1 -1
- package/dist/cjs/components/code/code.style.cjs +2 -1
- package/dist/cjs/components/code/code.style.cjs.map +1 -1
- package/dist/cjs/components/date-picker/use-date-picker.cjs +10 -10
- package/dist/cjs/components/date-picker/use-date-picker.cjs.map +1 -1
- package/dist/cjs/components/drawer/drawer.cjs +13 -1
- package/dist/cjs/components/drawer/drawer.cjs.map +1 -1
- package/dist/cjs/components/drawer/index.cjs +1 -0
- package/dist/cjs/components/drawer/namespace.cjs +2 -0
- package/dist/cjs/components/drawer/namespace.cjs.map +1 -1
- package/dist/cjs/components/drawer/use-drawer.cjs +139 -11
- package/dist/cjs/components/drawer/use-drawer.cjs.map +1 -1
- package/dist/cjs/components/field/field.cjs +4 -3
- package/dist/cjs/components/field/field.cjs.map +1 -1
- package/dist/cjs/components/file-input/use-file-input.cjs.map +1 -1
- package/dist/cjs/components/icon/icons/armenian-dram-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/armenian-dram-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/bangladeshi-taka-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/bangladeshi-taka-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/belarusian-ruble-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/belarusian-ruble-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/calendar-chevrons-left-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/calendar-chevrons-left-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/certificate-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/certificate-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/circle-fading-play-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/circle-fading-play-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/cpu-ai-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/cpu-ai-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/door-closed-cog-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/door-closed-cog-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/eighth-note-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/eighth-note-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/eighth-notes-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/eighth-notes-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/folder-user-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/folder-user-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/folder-users-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/folder-users-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/graph-star-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/graph-star-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/groceries-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/groceries-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/guitar-electric-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/guitar-electric-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/half-note-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/half-note-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/handle-bottom-right-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/handle-bottom-right-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/hiking-stick-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/hiking-stick-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/index.cjs +123 -12
- package/dist/cjs/components/icon/icons/index.cjs.map +1 -1
- package/dist/cjs/components/icon/icons/kazakh-tenge-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/kazakh-tenge-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/layout-grid-circles-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/layout-grid-circles-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/lens-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/lens-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/letters-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/letters-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/mail-dot-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/mail-dot-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/message-circle-text-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/message-circle-text-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/perfume-bottle-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/perfume-bottle-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/phone-log-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/phone-log-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/printer3d-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/printer3d-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/rugby-ball-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/rugby-ball-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/scratch-blocks-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/scratch-blocks-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/screw-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/screw-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/server-nas-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/server-nas-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/shield-house-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/shield-house-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/sixteenth-notes-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/sixteenth-notes-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/text-align-justify-center-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/text-align-justify-center-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/text-align-justify-end-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/text-align-justify-end-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/text-align-justify-start-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/text-align-justify-start-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/user-round-star-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/user-round-star-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/users-collaboration-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/users-collaboration-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/users-round-collaboration-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/users-round-collaboration-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/wifi-lock-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/wifi-lock-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/icons/wind-arrow-up-icon.cjs +14 -0
- package/dist/cjs/components/icon/icons/wind-arrow-up-icon.cjs.map +1 -0
- package/dist/cjs/components/icon/index.cjs +82 -8
- package/dist/cjs/components/kbd/kbd.style.cjs +2 -1
- package/dist/cjs/components/kbd/kbd.style.cjs.map +1 -1
- package/dist/cjs/components/list/list.cjs +5 -3
- package/dist/cjs/components/list/list.cjs.map +1 -1
- package/dist/cjs/components/marquee/index.cjs +21 -0
- package/dist/cjs/components/marquee/marquee.cjs +74 -0
- package/dist/cjs/components/marquee/marquee.cjs.map +1 -0
- package/dist/cjs/components/marquee/marquee.style.cjs +121 -0
- package/dist/cjs/components/marquee/marquee.style.cjs.map +1 -0
- package/dist/cjs/components/marquee/namespace.cjs +26 -0
- package/dist/cjs/components/marquee/namespace.cjs.map +1 -0
- package/dist/cjs/components/marquee/use-marquee.cjs +183 -0
- package/dist/cjs/components/marquee/use-marquee.cjs.map +1 -0
- package/dist/cjs/components/native-accordion/native-accordion.cjs +4 -3
- package/dist/cjs/components/native-accordion/native-accordion.cjs.map +1 -1
- package/dist/cjs/components/prose/index.cjs +7 -0
- package/dist/cjs/components/prose/prose.cjs +17 -0
- package/dist/cjs/components/prose/prose.cjs.map +1 -0
- package/dist/cjs/components/prose/prose.style.cjs +205 -0
- package/dist/cjs/components/prose/prose.style.cjs.map +1 -0
- package/dist/cjs/components/reorder/use-reorder.cjs +2 -1
- package/dist/cjs/components/reorder/use-reorder.cjs.map +1 -1
- package/dist/cjs/components/resizable/index.cjs +6 -1
- package/dist/cjs/components/resizable/namespace.cjs +6 -1
- package/dist/cjs/components/resizable/use-resizable.cjs +6 -1
- package/dist/cjs/components/select/use-select.cjs.map +1 -1
- package/dist/cjs/components/sidebar/sidebar.cjs +4 -3
- package/dist/cjs/components/sidebar/sidebar.cjs.map +1 -1
- package/dist/cjs/components/slot/slot.cjs +10 -9
- package/dist/cjs/components/slot/slot.cjs.map +1 -1
- package/dist/cjs/components/stack/stack.cjs +2 -1
- package/dist/cjs/components/stack/stack.cjs.map +1 -1
- package/dist/cjs/components/table/index.cjs +6 -1
- package/dist/cjs/components/toggle/toggle.style.cjs +2 -0
- package/dist/cjs/components/toggle/toggle.style.cjs.map +1 -1
- package/dist/cjs/components/tree/tree.cjs +5 -3
- package/dist/cjs/components/tree/tree.cjs.map +1 -1
- package/dist/cjs/core/components/create-component.cjs +1 -1
- package/dist/cjs/core/components/create-component.cjs.map +1 -1
- package/dist/cjs/core/css/conditions.cjs +4 -4
- package/dist/cjs/core/css/conditions.cjs.map +1 -1
- package/dist/cjs/core/css/styles.cjs.map +1 -1
- package/dist/cjs/hooks/use-focus/index.cjs +7 -14
- package/dist/cjs/hooks/use-focus/index.cjs.map +1 -1
- package/dist/cjs/index.cjs +306 -112
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/utils/children.cjs +22 -9
- package/dist/cjs/utils/children.cjs.map +1 -1
- package/dist/cjs/utils/index.cjs +4 -0
- package/dist/esm/components/accordion/accordion.js +5 -4
- package/dist/esm/components/accordion/accordion.js.map +1 -1
- package/dist/esm/components/aspect-ratio/aspect-ratio.js +2 -2
- package/dist/esm/components/aspect-ratio/aspect-ratio.js.map +1 -1
- package/dist/esm/components/blockquote/blockquote.style.js +1 -1
- package/dist/esm/components/blockquote/blockquote.style.js.map +1 -1
- package/dist/esm/components/box/index.js +1 -2
- package/dist/esm/components/breadcrumb/use-breadcrumb.js +2 -1
- package/dist/esm/components/breadcrumb/use-breadcrumb.js.map +1 -1
- package/dist/esm/components/bubble/bubble.js +157 -0
- package/dist/esm/components/bubble/bubble.js.map +1 -0
- package/dist/esm/components/bubble/bubble.style.js +144 -0
- package/dist/esm/components/bubble/bubble.style.js.map +1 -0
- package/dist/esm/components/bubble/index.js +4 -0
- package/dist/esm/components/bubble/namespace.js +16 -0
- package/dist/esm/components/bubble/namespace.js.map +1 -0
- package/dist/esm/components/button/button.js +11 -8
- package/dist/esm/components/button/button.js.map +1 -1
- package/dist/esm/components/calendar/calendar.js +3 -1
- package/dist/esm/components/calendar/calendar.js.map +1 -1
- package/dist/esm/components/calendar/use-calendar.js +12 -7
- package/dist/esm/components/calendar/use-calendar.js.map +1 -1
- package/dist/esm/components/client-only/index.js +1 -2
- package/dist/esm/components/code/code.style.js +2 -1
- package/dist/esm/components/code/code.style.js.map +1 -1
- package/dist/esm/components/date-picker/use-date-picker.js +10 -10
- package/dist/esm/components/date-picker/use-date-picker.js.map +1 -1
- package/dist/esm/components/drawer/drawer.js +13 -2
- package/dist/esm/components/drawer/drawer.js.map +1 -1
- package/dist/esm/components/drawer/index.js +2 -2
- package/dist/esm/components/drawer/namespace.js +3 -2
- package/dist/esm/components/drawer/namespace.js.map +1 -1
- package/dist/esm/components/drawer/use-drawer.js +140 -12
- package/dist/esm/components/drawer/use-drawer.js.map +1 -1
- package/dist/esm/components/field/field.js +5 -4
- package/dist/esm/components/field/field.js.map +1 -1
- package/dist/esm/components/file-input/use-file-input.js.map +1 -1
- package/dist/esm/components/focus-lock/index.js +1 -2
- package/dist/esm/components/for/index.js +1 -2
- package/dist/esm/components/icon/icons/armenian-dram-icon.js +14 -0
- package/dist/esm/components/icon/icons/armenian-dram-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/bangladeshi-taka-icon.js +14 -0
- package/dist/esm/components/icon/icons/bangladeshi-taka-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/belarusian-ruble-icon.js +14 -0
- package/dist/esm/components/icon/icons/belarusian-ruble-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/calendar-chevrons-left-icon.js +14 -0
- package/dist/esm/components/icon/icons/calendar-chevrons-left-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/certificate-icon.js +14 -0
- package/dist/esm/components/icon/icons/certificate-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/circle-fading-play-icon.js +14 -0
- package/dist/esm/components/icon/icons/circle-fading-play-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/cpu-ai-icon.js +14 -0
- package/dist/esm/components/icon/icons/cpu-ai-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/door-closed-cog-icon.js +14 -0
- package/dist/esm/components/icon/icons/door-closed-cog-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/eighth-note-icon.js +14 -0
- package/dist/esm/components/icon/icons/eighth-note-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/eighth-notes-icon.js +14 -0
- package/dist/esm/components/icon/icons/eighth-notes-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/folder-user-icon.js +14 -0
- package/dist/esm/components/icon/icons/folder-user-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/folder-users-icon.js +14 -0
- package/dist/esm/components/icon/icons/folder-users-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/graph-star-icon.js +14 -0
- package/dist/esm/components/icon/icons/graph-star-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/groceries-icon.js +14 -0
- package/dist/esm/components/icon/icons/groceries-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/guitar-electric-icon.js +14 -0
- package/dist/esm/components/icon/icons/guitar-electric-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/half-note-icon.js +14 -0
- package/dist/esm/components/icon/icons/half-note-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/handle-bottom-right-icon.js +14 -0
- package/dist/esm/components/icon/icons/handle-bottom-right-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/hiking-stick-icon.js +14 -0
- package/dist/esm/components/icon/icons/hiking-stick-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/index.js +83 -9
- package/dist/esm/components/icon/icons/index.js.map +1 -1
- package/dist/esm/components/icon/icons/kazakh-tenge-icon.js +14 -0
- package/dist/esm/components/icon/icons/kazakh-tenge-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/layout-grid-circles-icon.js +14 -0
- package/dist/esm/components/icon/icons/layout-grid-circles-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/lens-icon.js +14 -0
- package/dist/esm/components/icon/icons/lens-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/letters-icon.js +14 -0
- package/dist/esm/components/icon/icons/letters-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/mail-dot-icon.js +14 -0
- package/dist/esm/components/icon/icons/mail-dot-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/message-circle-text-icon.js +14 -0
- package/dist/esm/components/icon/icons/message-circle-text-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/perfume-bottle-icon.js +14 -0
- package/dist/esm/components/icon/icons/perfume-bottle-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/phone-log-icon.js +14 -0
- package/dist/esm/components/icon/icons/phone-log-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/printer3d-icon.js +14 -0
- package/dist/esm/components/icon/icons/printer3d-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/rugby-ball-icon.js +14 -0
- package/dist/esm/components/icon/icons/rugby-ball-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/scratch-blocks-icon.js +14 -0
- package/dist/esm/components/icon/icons/scratch-blocks-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/screw-icon.js +14 -0
- package/dist/esm/components/icon/icons/screw-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/server-nas-icon.js +14 -0
- package/dist/esm/components/icon/icons/server-nas-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/shield-house-icon.js +14 -0
- package/dist/esm/components/icon/icons/shield-house-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/sixteenth-notes-icon.js +14 -0
- package/dist/esm/components/icon/icons/sixteenth-notes-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/text-align-justify-center-icon.js +14 -0
- package/dist/esm/components/icon/icons/text-align-justify-center-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/text-align-justify-end-icon.js +14 -0
- package/dist/esm/components/icon/icons/text-align-justify-end-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/text-align-justify-start-icon.js +14 -0
- package/dist/esm/components/icon/icons/text-align-justify-start-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/user-round-star-icon.js +14 -0
- package/dist/esm/components/icon/icons/user-round-star-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/users-collaboration-icon.js +14 -0
- package/dist/esm/components/icon/icons/users-collaboration-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/users-round-collaboration-icon.js +14 -0
- package/dist/esm/components/icon/icons/users-round-collaboration-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/wifi-lock-icon.js +14 -0
- package/dist/esm/components/icon/icons/wifi-lock-icon.js.map +1 -0
- package/dist/esm/components/icon/icons/wind-arrow-up-icon.js +14 -0
- package/dist/esm/components/icon/icons/wind-arrow-up-icon.js.map +1 -0
- package/dist/esm/components/icon/index.js +42 -5
- package/dist/esm/components/kbd/kbd.style.js +2 -1
- package/dist/esm/components/kbd/kbd.style.js.map +1 -1
- package/dist/esm/components/list/list.js +5 -3
- package/dist/esm/components/list/list.js.map +1 -1
- package/dist/esm/components/marquee/index.js +5 -0
- package/dist/esm/components/marquee/marquee.js +69 -0
- package/dist/esm/components/marquee/marquee.js.map +1 -0
- package/dist/esm/components/marquee/marquee.style.js +122 -0
- package/dist/esm/components/marquee/marquee.style.js.map +1 -0
- package/dist/esm/components/marquee/namespace.js +15 -0
- package/dist/esm/components/marquee/namespace.js.map +1 -0
- package/dist/esm/components/marquee/use-marquee.js +181 -0
- package/dist/esm/components/marquee/use-marquee.js.map +1 -0
- package/dist/esm/components/native-accordion/native-accordion.js +5 -4
- package/dist/esm/components/native-accordion/native-accordion.js.map +1 -1
- package/dist/esm/components/picture/index.js +1 -2
- package/dist/esm/components/portal/index.js +1 -2
- package/dist/esm/components/prose/index.js +3 -0
- package/dist/esm/components/prose/prose.js +15 -0
- package/dist/esm/components/prose/prose.js.map +1 -0
- package/dist/esm/components/prose/prose.style.js +205 -0
- package/dist/esm/components/prose/prose.style.js.map +1 -0
- package/dist/esm/components/reorder/use-reorder.js +2 -1
- package/dist/esm/components/reorder/use-reorder.js.map +1 -1
- package/dist/esm/components/select/use-select.js.map +1 -1
- package/dist/esm/components/show/index.js +1 -2
- package/dist/esm/components/sidebar/sidebar.js +5 -4
- package/dist/esm/components/sidebar/sidebar.js.map +1 -1
- package/dist/esm/components/slot/index.js +1 -2
- package/dist/esm/components/slot/slot.js +11 -10
- package/dist/esm/components/slot/slot.js.map +1 -1
- package/dist/esm/components/stack/stack.js +2 -1
- package/dist/esm/components/stack/stack.js.map +1 -1
- package/dist/esm/components/table/index.js +1 -2
- package/dist/esm/components/tip/index.js +1 -2
- package/dist/esm/components/toggle/toggle.style.js +2 -0
- package/dist/esm/components/toggle/toggle.style.js.map +1 -1
- package/dist/esm/components/tree/tree.js +5 -3
- package/dist/esm/components/tree/tree.js.map +1 -1
- package/dist/esm/core/components/create-component.js +1 -1
- package/dist/esm/core/components/create-component.js.map +1 -1
- package/dist/esm/core/css/conditions.js +4 -4
- package/dist/esm/core/css/conditions.js.map +1 -1
- package/dist/esm/core/css/styles.js.map +1 -1
- package/dist/esm/hooks/use-focus/index.js +8 -15
- package/dist/esm/hooks/use-focus/index.js.map +1 -1
- package/dist/esm/index.js +215 -105
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/providers/ui-provider/index.js +1 -2
- package/dist/esm/utils/children.js +22 -11
- package/dist/esm/utils/children.js.map +1 -1
- package/dist/esm/utils/index.js +4 -2
- package/dist/types/components/alert/alert.d.ts +0 -1
- package/dist/types/components/alpha-slider/alpha-slider.d.ts +0 -1
- package/dist/types/components/autocomplete/autocomplete.d.ts +0 -1
- package/dist/types/components/breadcrumb/use-breadcrumb.d.ts +1 -1
- package/dist/types/components/bubble/bubble.d.ts +89 -0
- package/dist/types/components/bubble/bubble.style.d.ts +79 -0
- package/dist/types/components/bubble/index.d.ts +4 -0
- package/dist/types/components/bubble/namespace.d.ts +7 -0
- package/dist/types/components/button/button.d.ts +0 -1
- package/dist/types/components/calendar/calendar.d.ts +0 -1
- package/dist/types/components/calendar/use-calendar.d.ts +4 -3
- package/dist/types/components/color-picker/color-picker.d.ts +0 -3
- package/dist/types/components/color-selector/color-selector.d.ts +0 -1
- package/dist/types/components/color-selector/use-color-selector.d.ts +1 -0
- package/dist/types/components/date-picker/date-picker.d.ts +0 -3
- package/dist/types/components/date-picker/use-date-picker.d.ts +1 -0
- package/dist/types/components/drawer/drawer.d.ts +2 -0
- package/dist/types/components/drawer/index.d.ts +2 -2
- package/dist/types/components/drawer/namespace.d.ts +3 -3
- package/dist/types/components/drawer/use-drawer.d.ts +9 -2
- package/dist/types/components/dropzone/dropzone.d.ts +0 -1
- package/dist/types/components/field/use-field-props.d.ts +1 -1
- package/dist/types/components/hue-slider/hue-slider.d.ts +0 -1
- package/dist/types/components/icon/icons/armenian-dram-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/bangladeshi-taka-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/belarusian-ruble-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/calendar-chevrons-left-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/certificate-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/circle-fading-play-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/cpu-ai-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/door-closed-cog-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/eighth-note-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/eighth-notes-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/folder-user-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/folder-users-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/graph-star-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/groceries-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/guitar-electric-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/half-note-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/handle-bottom-right-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/hiking-stick-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/index.d.ts +43 -6
- package/dist/types/components/icon/icons/index.type.d.ts +1 -1
- package/dist/types/components/icon/icons/kazakh-tenge-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/layout-grid-circles-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/lens-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/letters-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/mail-dot-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/message-circle-text-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/perfume-bottle-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/phone-log-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/printer3d-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/rugby-ball-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/scratch-blocks-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/{music-icon.d.ts → screw-icon.d.ts} +4 -4
- package/dist/types/components/icon/icons/server-nas-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/shield-house-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/sixteenth-notes-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/text-align-justify-center-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/text-align-justify-end-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/text-align-justify-start-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/user-round-star-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/users-collaboration-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/users-round-collaboration-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/wifi-lock-icon.d.ts +12 -0
- package/dist/types/components/icon/icons/wind-arrow-up-icon.d.ts +12 -0
- package/dist/types/components/icon/index.d.ts +42 -5
- package/dist/types/components/loading/loading-provider.d.ts +1 -0
- package/dist/types/components/loading/use-loading-component.d.ts +0 -1
- package/dist/types/components/marquee/index.d.ts +5 -0
- package/dist/types/components/marquee/marquee.d.ts +50 -0
- package/dist/types/components/marquee/marquee.style.d.ts +8 -0
- package/dist/types/components/marquee/namespace.d.ts +8 -0
- package/dist/types/components/marquee/use-marquee.d.ts +127 -0
- package/dist/types/components/menu/menu.d.ts +0 -1
- package/dist/types/components/motion/factory.d.ts +1 -0
- package/dist/types/components/motion/index.type.d.ts +4 -3
- package/dist/types/components/native-select/native-select.d.ts +0 -1
- package/dist/types/components/native-select/use-native-select.d.ts +1 -0
- package/dist/types/components/notice/use-notice.d.ts +0 -1
- package/dist/types/components/number-input/number-input.d.ts +0 -1
- package/dist/types/components/pagination/pagination.d.ts +0 -1
- package/dist/types/components/password-input/password-input.d.ts +0 -1
- package/dist/types/components/prose/index.d.ts +3 -0
- package/dist/types/components/prose/prose.d.ts +17 -0
- package/dist/types/components/prose/prose.style.d.ts +121 -0
- package/dist/types/components/rating/rating.d.ts +1 -0
- package/dist/types/components/reorder/use-reorder.d.ts +1 -1
- package/dist/types/components/select/select.d.ts +0 -1
- package/dist/types/components/sidebar/sidebar.d.ts +0 -2
- package/dist/types/components/sidebar/sidebar.style.d.ts +1 -0
- package/dist/types/components/snacks/use-snacks.d.ts +1 -1
- package/dist/types/components/table/table.d.ts +0 -1
- package/dist/types/components/toggle/toggle.d.ts +6 -0
- package/dist/types/components/toggle/toggle.style.d.ts +2 -0
- package/dist/types/components/tree/tree.d.ts +0 -1
- package/dist/types/core/components/create-component.d.ts +1 -0
- package/dist/types/core/components/index.type.d.ts +4 -2
- package/dist/types/core/components/props.d.ts +1 -0
- package/dist/types/core/components/use-component-style.d.ts +1 -0
- package/dist/types/core/css/conditions.d.ts +10 -10
- package/dist/types/core/css/styles.d.ts +36 -16
- package/dist/types/core/system/breakpoint.d.ts +1 -0
- package/dist/types/core/system/config.d.ts +1 -0
- package/dist/types/core/system/create-system.d.ts +1 -0
- package/dist/types/core/system/factory.d.ts +1 -0
- package/dist/types/core/system/index.type.d.ts +1 -0
- package/dist/types/core/system/system-provider.d.ts +1 -0
- package/dist/types/hooks/use-async/index.d.ts +1 -0
- package/dist/types/hooks/use-async-callback/index.d.ts +1 -1
- package/dist/types/hooks/use-controllable-state/index.d.ts +1 -0
- package/dist/types/hooks/use-descendants/index.d.ts +1 -0
- package/dist/types/hooks/use-eye-dropper/index.d.ts +1 -0
- package/dist/types/hooks/use-popper/index.d.ts +1 -0
- package/dist/types/hooks/use-window-event/index.d.ts +1 -0
- package/dist/types/index.d.ts +103 -54
- package/dist/types/providers/i18n-provider/i18n-cache.d.ts +1 -0
- package/dist/types/providers/i18n-provider/icu.type.d.ts +1 -0
- package/dist/types/utils/children.d.ts +11 -2
- package/dist/types/utils/context.d.ts +1 -0
- package/dist/types/utils/dom.d.ts +1 -0
- package/dist/types/utils/index.d.ts +3 -3
- package/dist/types/utils/store.d.ts +1 -0
- package/package.json +21 -18
- package/dist/cjs/components/icon/icons/music-icon.cjs +0 -14
- package/dist/cjs/components/icon/icons/music-icon.cjs.map +0 -1
- package/dist/cjs/components/icon/icons/music2-icon.cjs +0 -14
- package/dist/cjs/components/icon/icons/music2-icon.cjs.map +0 -1
- package/dist/cjs/components/icon/icons/music3-icon.cjs +0 -14
- package/dist/cjs/components/icon/icons/music3-icon.cjs.map +0 -1
- package/dist/cjs/components/icon/icons/music4-icon.cjs +0 -14
- package/dist/cjs/components/icon/icons/music4-icon.cjs.map +0 -1
- package/dist/esm/components/icon/icons/music-icon.js +0 -14
- package/dist/esm/components/icon/icons/music-icon.js.map +0 -1
- package/dist/esm/components/icon/icons/music2-icon.js +0 -14
- package/dist/esm/components/icon/icons/music2-icon.js.map +0 -1
- package/dist/esm/components/icon/icons/music3-icon.js +0 -14
- package/dist/esm/components/icon/icons/music3-icon.js.map +0 -1
- package/dist/esm/components/icon/icons/music4-icon.js +0 -14
- package/dist/esm/components/icon/icons/music4-icon.js.map +0 -1
- package/dist/types/components/icon/icons/music2-icon.d.ts +0 -12
- package/dist/types/components/icon/icons/music3-icon.d.ts +0 -12
- package/dist/types/components/icon/icons/music4-icon.d.ts +0 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-date-picker.cjs","names":["DEFAULT_MAX_DATE","DEFAULT_MIN_DATE","useEnvironment","useI18n","useFieldProps","useDateTimeFormat","useMemo","useCalendarProps","useRef","useState","useControllableState","getAdjustedMonth","useCallback","isBeforeDate","isAfterDate","useCombobox","updateMaybeDateValue","isValidElement","cloneElement","isComposing","isIncludeDates","mergeRefs","visuallyHiddenAttributes","runKeyAction"],"sources":["../../../../src/components/date-picker/use-date-picker.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type { UseComboboxProps } from \"../../hooks/use-combobox\"\nimport type { Dict } from \"../../utils\"\nimport type {\n CalendarFormat,\n MaybeDateValue,\n UseCalendarProps,\n} from \"../calendar\"\nimport type { FieldProps } from \"../field\"\nimport dayjs from \"dayjs\"\nimport {\n cloneElement,\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { useEnvironment } from \"../../core\"\nimport { useCombobox } from \"../../hooks/use-combobox\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n ariaAttr,\n cast,\n contains,\n dataAttr,\n focusTransfer,\n handlerAll,\n isActiveElement,\n isArray,\n isComposing,\n isDate,\n isNumber,\n isObject,\n mergeRefs,\n runIfFn,\n runKeyAction,\n useUpdateEffect,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport {\n DEFAULT_MAX_DATE,\n DEFAULT_MIN_DATE,\n getAdjustedMonth,\n isAfterDate,\n isBeforeDate,\n isIncludeDates,\n updateMaybeDateValue,\n useCalendarProps,\n} from \"../calendar\"\nimport { useFieldProps } from \"../field\"\nimport { useDateTimeFormat } from \"../format\"\n\nexport interface DatePickerFormat extends CalendarFormat {\n input?: Intl.DateTimeFormatOptions | null\n}\n\ntype InputAlign = \"end\" | \"start\"\ntype MaybeInputValue<Range extends boolean = false> = Range extends true\n ? { end?: string; start?: string }\n : string | undefined\n\ninterface DatePickerRenderProps {\n count: number\n date: Date\n focused: boolean\n index: number\n separator: string\n value: string\n onClear: () => void\n max?: number\n}\n\nexport interface DatePickerRender {\n (props: DatePickerRenderProps): ReactNode\n}\n\nconst defaultRender: DatePickerRender = ({\n count,\n focused,\n index,\n max,\n separator,\n value,\n}) => {\n const last = count - 1 === index\n\n return (\n <span style={{ marginInlineEnd: \"var(--gap)\" }}>\n {value}\n {((!isNumber(max) || count < max) && focused) || !last ? separator : null}\n </span>\n )\n}\n\nexport interface UseDatePickerProps<\n Multiple extends boolean = false,\n Range extends boolean = false,\n>\n extends\n Omit<UseCalendarProps<Multiple, Range>, \"format\" | \"ref\">,\n Omit<\n UseComboboxProps,\n \"defaultValue\" | \"initialFocusValue\" | \"onChange\" | \"ref\" | \"value\"\n >,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * If `true`, allows input.\n *\n * @default true\n */\n allowInput?: boolean\n /**\n * If `true`, allows input of dates beyond the `minDate` and `maxDate` restrictions.\n *\n * @default true\n */\n allowInputBeyond?: boolean\n /**\n * If `true`, the date picker will be closed when the input value changes.\n *\n * @default false\n */\n closeOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * The initial value of the input.\n */\n defaultInputValue?: MaybeInputValue<Range>\n /**\n * If `true`, the input will be focused when the clear icon is clicked.\n *\n * @default true\n */\n focusOnClear?: boolean\n /**\n * The format used for conversion.\n * Check the docs to see the format of possible modifiers you can pass.\n *\n * @see https://day.js.org/docs/en/display/format#list-of-localized-formats\n */\n format?: DatePickerFormat\n /**\n * The `id` attribute of the input element.\n */\n id?: string\n /**\n * The value of the input.\n */\n inputValue?: MaybeInputValue<Range>\n /**\n * The `name` attribute of the input element.\n */\n name?: string\n /**\n * If `true`, the date picker will be opened when the input value changes.\n *\n * @default true\n */\n openOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * If `true`, the date picker will be opened when the input is focused.\n *\n * @default true\n */\n openOnFocus?: boolean\n /**\n * The pattern used to check the input element.\n */\n pattern?: RegExp\n /**\n * The placeholder for date picker.\n */\n placeholder?: string\n /**\n * The visual separator between each value.\n *\n * @default ','\n */\n separator?: string\n /**\n * The callback invoked when input value state changes.\n */\n onInputChange?: (value: MaybeInputValue<Range>) => void\n /**\n * Function that converts the input value to Date type.\n */\n parseDate?: (value: string) => Date | undefined\n /**\n * The function to render the selected date.\n */\n render?: (props: DatePickerRenderProps) => ReactNode\n}\n\nexport const useDatePicker = <\n Multiple extends boolean = false,\n Range extends boolean = false,\n>({\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n ...props\n}: UseDatePickerProps<Multiple, Range> = {}) => {\n if (dayjs(minDate).isAfter(dayjs(maxDate))) maxDate = minDate\n\n const { getDocument } = useEnvironment()\n const { locale: defaultLocale, t } = useI18n(\"datePicker\")\n const {\n props: {\n id,\n ref,\n name,\n allowInput = true,\n allowInputBeyond = false,\n closeOnChange = false,\n multiple = false,\n closeOnSelect = !multiple,\n defaultInputValue,\n defaultMonth = new Date(),\n range = false,\n defaultValue = (range\n ? { end: undefined, start: undefined }\n : multiple\n ? []\n : undefined) as MaybeDateValue<Multiple, Range>,\n disabled,\n focusOnClear = true,\n format,\n inputValue: inputValueProp,\n locale = defaultLocale,\n max,\n month: monthProp,\n openOnChange = true,\n openOnClick = true,\n openOnFocus = true,\n parseDate,\n pattern,\n placeholder: placeholderProp,\n placement = \"end-start\",\n readOnly,\n render = defaultRender,\n required,\n separator = range ? \"-\" : \",\",\n value: valueProp,\n onChange: onChangeProp,\n onChangeMonth: onChangeMonthProp,\n onInputChange: onInputChangeProp,\n ...computedProps\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const dateTimeFormat = useDateTimeFormat({ locale })\n const { calendarFormat, inputFormat } = useMemo(() => {\n const { input: inputFormat, ...calendarFormat } = format ?? {}\n const defaultInputFormat: Intl.DateTimeFormatOptions = {\n day: \"numeric\",\n month: \"long\",\n year: \"numeric\",\n }\n\n return {\n calendarFormat,\n inputFormat:\n inputFormat !== null ? (inputFormat ?? defaultInputFormat) : undefined,\n }\n }, [format])\n const [calendarProps, rest] = useCalendarProps<Multiple, Range>(computedProps)\n const { excludeDate } = calendarProps\n const fieldRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const startInputRef = useRef<HTMLInputElement>(null)\n const endInputRef = useRef<HTMLInputElement>(null)\n const focusByClickRef = useRef<boolean>(false)\n const [focused, setFocused] = useState(false)\n const [value, setValue] = useControllableState({\n defaultValue: defaultValue as MaybeDateValue<Multiple, Range>,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [month, setMonth] = useControllableState({\n defaultValue: () => {\n let value = defaultMonth\n\n if (dayjs(minDate).isAfter(dayjs(defaultMonth)))\n value = dayjs(minDate).set(\"date\", 1).toDate()\n\n if (valueProp) value = getAdjustedMonth(valueProp, value)\n else if (defaultValue) value = getAdjustedMonth(defaultValue, value)\n\n return value\n },\n value: monthProp,\n onChange: onChangeMonthProp,\n })\n const stringToDate = useCallback(\n (value: string, start: Date = minDate, end: Date = maxDate) => {\n let date = parseDate?.(value)\n\n if (!date && dayjs(value).isValid())\n date = dayjs(value).locale(locale).toDate()\n\n if (date == null) return undefined\n if (excludeDate?.(date)) return undefined\n\n if (!allowInputBeyond) {\n if (isBeforeDate(date, start)) date = start\n if (isAfterDate(date, end)) date = end\n }\n\n return date\n },\n [allowInputBeyond, excludeDate, locale, maxDate, minDate, parseDate],\n )\n const dateToString = useCallback(\n (date?: Date) => {\n if (date == null) return \"\"\n\n return dateTimeFormat(date, inputFormat)\n },\n [dateTimeFormat, inputFormat],\n )\n const [inputValue, setInputValue] = useControllableState({\n defaultValue: () => {\n if (defaultInputValue)\n if (isObject(defaultInputValue)) {\n if (dayjs(defaultInputValue.start).isValid())\n defaultInputValue.start = dateTimeFormat(\n dayjs(defaultInputValue.start).toDate(),\n inputFormat,\n )\n\n if (dayjs(defaultInputValue.end).isValid())\n defaultInputValue.end = dateTimeFormat(\n dayjs(defaultInputValue.end).toDate(),\n inputFormat,\n )\n\n return defaultInputValue\n } else {\n if (dayjs(defaultInputValue).isValid())\n return dateTimeFormat(\n dayjs(defaultInputValue).toDate(),\n inputFormat,\n ) as MaybeInputValue<Range>\n else return defaultInputValue\n }\n else if (isDate(value))\n return dateToString(value) as MaybeInputValue<Range>\n else if (isObject(value) && !isArray(value))\n return {\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>\n else return \"\" as MaybeInputValue<Range>\n },\n value: inputValueProp,\n onChange: onInputChangeProp,\n })\n const {\n interactive,\n open,\n getContentProps: getComboboxContentProps,\n getTriggerProps,\n popoverProps,\n onClose,\n onOpen,\n } = useCombobox({\n disabled,\n matchWidth: false,\n openOnClick: false,\n openOnEnter: !allowInput,\n openOnSpace: !allowInput,\n placement,\n readOnly,\n transferFocus: false,\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n ...rest,\n })\n const children = useMemo<ReactNode>(() => {\n if (!isArray(value)) return null\n\n const count = value.length\n\n return value.map((date, index) => {\n const value = dateToString(date)\n\n const onClear = (ev?: MouseEvent<HTMLElement>) => {\n ev?.preventDefault()\n ev?.stopPropagation()\n\n setValue(\n (prev) =>\n updateMaybeDateValue(date, max)(prev) as MaybeDateValue<\n Multiple,\n Range\n >,\n )\n }\n\n const component = render({\n count,\n date,\n focused,\n index,\n max,\n separator,\n value,\n onClear,\n })\n\n if (isValidElement<Dict>(component))\n return cloneElement(component, { ...component.props, key: index })\n else return component\n })\n }, [dateToString, focused, max, render, separator, setValue, value])\n const { endPlaceholder, startPlaceholder } = useMemo(() => {\n if (range) {\n const startPlaceholder =\n placeholderProp ?? dateTimeFormat(new Date(), inputFormat)\n const endPlaceholder =\n placeholderProp ??\n dateTimeFormat(dayjs().add(1, \"day\").toDate(), inputFormat)\n\n return { endPlaceholder, startPlaceholder }\n } else {\n const placeholder =\n placeholderProp ?? dateTimeFormat(new Date(), inputFormat)\n\n return { endPlaceholder: placeholder, startPlaceholder: placeholder }\n }\n }, [dateTimeFormat, inputFormat, placeholderProp, range])\n\n const onChange = useCallback(\n (value: MaybeDateValue<Multiple, Range>) => {\n setValue(value)\n\n if (isArray(value)) setInputValue(\"\" as MaybeInputValue<Range>)\n else if (isObject(value) && !isDate(value))\n setInputValue({\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>)\n else setInputValue(dateToString(value) as MaybeInputValue<Range>)\n\n if (!closeOnSelect) return\n\n if (isObject(value) && !isArray(value) && !isDate(value)) {\n if (value.end && value.start) onClose()\n } else {\n onClose()\n }\n },\n [setValue, closeOnSelect, setInputValue, dateToString, onClose],\n )\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (!allowInput) return\n if (isArray(value) && value.length === max) return\n\n if (runIfFn(closeOnChange, ev)) onClose()\n else if (runIfFn(openOnChange, ev)) onOpen()\n\n let inputValue = ev.target.value\n\n if (pattern) inputValue = inputValue.replace(pattern, \"\")\n\n if (isArray(value)) {\n const date = stringToDate(inputValue)\n\n setInputValue(inputValue as MaybeInputValue<Range>)\n\n if (date) setMonth(dayjs(date).set(\"date\", 1).toDate())\n } else if (isObject(value) && !isDate(value)) {\n const align = contains(endInputRef.current, ev.target) ? \"end\" : \"start\"\n const minDate =\n value.start && align === \"end\"\n ? dayjs(value.start).add(1, \"day\").toDate()\n : undefined\n const maxDate =\n value.end && align === \"start\"\n ? dayjs(value.end).subtract(1, \"day\").toDate()\n : undefined\n const date = stringToDate(inputValue, minDate, maxDate)\n\n setInputValue((prev) =>\n isObject(prev)\n ? Object.assign({}, prev, { [align]: inputValue })\n : prev,\n )\n setValue((prev) =>\n isObject(prev) && !isDate(prev) ? { ...prev, [align]: date } : prev,\n )\n } else {\n const date = stringToDate(inputValue)\n\n setInputValue(inputValue as MaybeInputValue<Range>)\n setValue(date as MaybeDateValue<Multiple, Range>)\n }\n },\n [\n allowInput,\n closeOnChange,\n max,\n onClose,\n onOpen,\n openOnChange,\n pattern,\n setInputValue,\n setMonth,\n setValue,\n stringToDate,\n value,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLInputElement>) => {\n if (disabled || isComposing(ev)) return\n\n const inputValue = cast<HTMLInputElement>(ev.target).value\n\n runKeyAction(\n ev,\n {\n Backspace: (ev) => {\n if (isArray(value)) {\n if (inputValue.length) return\n\n ev.preventDefault()\n\n setValue((prev) =>\n isArray(prev)\n ? (prev.slice(0, -1) as MaybeDateValue<Multiple, Range>)\n : prev,\n )\n } else if (isObject(value) && !isDate(value)) {\n if (inputValue.length) return\n if (!contains(endInputRef.current, ev.target)) return\n\n ev.preventDefault()\n\n setInputValue({ end: \"\", start: \"\" } as MaybeInputValue<Range>)\n setValue({ end: undefined, start: undefined } as MaybeDateValue<\n Multiple,\n Range\n >)\n\n startInputRef.current?.focus()\n }\n },\n Enter: (ev) => {\n if (!open || !inputValue.length) return\n\n if (isObject(value) && !isArray(value) && !isDate(value)) {\n const align = contains(endInputRef.current, ev.target)\n ? \"end\"\n : \"start\"\n const minDate =\n value.start && align === \"end\"\n ? dayjs(value.start).add(1, \"day\").toDate()\n : undefined\n const maxDate =\n value.end && align === \"start\"\n ? dayjs(value.end).subtract(1, \"day\").toDate()\n : undefined\n const date = stringToDate(inputValue, minDate, maxDate)\n\n if (!date) return\n\n ev.preventDefault()\n\n setInputValue((prev) =>\n isObject(prev)\n ? Object.assign({}, prev, { [align]: dateToString(date) })\n : prev,\n )\n setValue((prev) =>\n isObject(prev) && !isDate(prev)\n ? { ...prev, [align]: date }\n : prev,\n )\n\n if (align === \"start\") endInputRef.current?.focus()\n } else {\n const date = stringToDate(inputValue)\n\n if (!date) return\n\n ev.preventDefault()\n\n if (isArray(value)) {\n setInputValue(\"\" as MaybeInputValue<Range>)\n\n setValue((prev) =>\n isArray(prev) &&\n !isIncludeDates(date, prev) &&\n (!isNumber(max) || prev.length < max)\n ? ([...prev, date] as MaybeDateValue<Multiple, Range>)\n : prev,\n )\n } else {\n setInputValue(dateToString(date) as MaybeInputValue<Range>)\n setValue(date as MaybeDateValue<Multiple, Range>)\n }\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n dateToString,\n disabled,\n max,\n open,\n setInputValue,\n setValue,\n stringToDate,\n value,\n ],\n )\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (!interactive) return\n\n focusByClickRef.current = true\n\n if (allowInput)\n if (isObject(value) && !isArray(value) && !isDate(value))\n if (\n startInputRef.current &&\n contains(startInputRef.current, ev.target)\n ) {\n if (!isActiveElement(startInputRef.current, getDocument()!))\n ev.defaultPrevented = true\n\n startInputRef.current.focus()\n } else if (\n endInputRef.current &&\n contains(endInputRef.current, ev.target)\n ) {\n if (!isActiveElement(endInputRef.current, getDocument()!))\n ev.defaultPrevented = true\n\n endInputRef.current.focus()\n } else {\n startInputRef.current?.focus()\n }\n else startInputRef.current?.focus()\n\n if (openOnClick) onOpen()\n },\n [allowInput, interactive, onOpen, openOnClick, value, getDocument],\n )\n\n const onMouseDown = useCallback(\n (ev: MouseEvent<HTMLDivElement | HTMLInputElement>) => {\n if (!openOnFocus) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [openOnFocus],\n )\n\n const onFieldFocus = useCallback(() => {\n if (allowInput) return\n\n if (openOnFocus) onOpen()\n\n focusByClickRef.current = false\n }, [allowInput, onOpen, openOnFocus])\n\n const onInputFocus = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n setFocused(true)\n\n if (openOnFocus && !focusByClickRef.current) onOpen()\n\n focusByClickRef.current = false\n },\n [onOpen, openOnFocus],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n setFocused(false)\n\n if (\n contains(fieldRef.current, ev.relatedTarget) ||\n contains(contentRef.current, ev.relatedTarget)\n )\n ev.preventDefault()\n else if (isArray(value)) setInputValue(\"\" as MaybeInputValue<Range>)\n else if (isObject(value) && !isDate(value))\n setInputValue((prev) =>\n isObject(prev)\n ? ({\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>)\n : prev,\n )\n else setInputValue(dateToString(value) as MaybeInputValue<Range>)\n },\n [dateToString, setInputValue, value],\n )\n\n const onClear = useCallback(() => {\n if (!interactive) return\n\n setValue((prev) => {\n if (isDate(prev)) return undefined as MaybeDateValue<Multiple, Range>\n else if (isArray(prev))\n return [] as unknown as MaybeDateValue<Multiple, Range>\n else if (isObject(prev))\n return { end: undefined, start: undefined } as MaybeDateValue<\n Multiple,\n Range\n >\n else return prev\n })\n\n setInputValue(\n (range ? { end: \"\", start: \"\" } : \"\") as MaybeInputValue<Range>,\n )\n\n if (focusOnClear)\n if (allowInput) startInputRef.current?.focus()\n else fieldRef.current?.focus()\n }, [allowInput, focusOnClear, interactive, range, setInputValue, setValue])\n\n useEffect(() => {\n if (!open) return\n\n return focusTransfer(\n contentRef.current,\n allowInput ? startInputRef.current : fieldRef.current,\n )\n }, [allowInput, open])\n\n useUpdateEffect(() => {\n setMonth((prev) => getAdjustedMonth(value, prev))\n }, [value, range])\n\n useUpdateEffect(() => {\n if (isArray(valueProp)) return\n\n if (isObject(valueProp) && !isDate(valueProp))\n setInputValue({\n end: dateToString(valueProp.end),\n start: dateToString(valueProp.start),\n } as MaybeInputValue<Range>)\n else setInputValue(dateToString(valueProp) as MaybeInputValue<Range>)\n }, [valueProp])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n \"data-range\": dataAttr(range),\n ...dataProps,\n ...props,\n }),\n [dataProps, range],\n )\n\n const getFieldProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getTriggerProps({\n ref: mergeRefs(ref, fieldRef),\n \"aria-haspopup\": \"dialog\",\n tabIndex: !allowInput ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n onFocus: handlerAll(props.onFocus, onFieldFocus),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n\n [allowInput, getTriggerProps, onClick, onFieldFocus, onMouseDown],\n )\n\n const getInputProps: PropGetter<\"input\", { align?: InputAlign }> =\n useCallback(\n ({ align = \"start\", ...props } = {}) => {\n const inputProps: HTMLProps<\"input\"> = {\n style: {\n ...(!allowInput ? { pointerEvents: \"none\" } : {}),\n ...props.style,\n },\n autoComplete: \"off\",\n disabled,\n readOnly,\n required,\n tabIndex: allowInput ? 0 : -1,\n ...dataProps,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onInputChange),\n onFocus: handlerAll(props.onFocus, onInputFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }\n\n if (isObject(inputValue)) {\n if (align === \"start\") {\n inputProps.ref = mergeRefs(props.ref, ref, startInputRef)\n inputProps.value = inputValue.start\n inputProps.placeholder = startPlaceholder\n } else {\n inputProps.ref = mergeRefs(props.ref, ref, endInputRef)\n inputProps.value = inputValue.end\n inputProps.placeholder = endPlaceholder\n }\n\n if (!inputValue.start && align === \"start\") {\n inputProps.id = id\n inputProps.name = name\n }\n\n if (!!inputValue.start && align === \"end\") {\n inputProps.id = id\n inputProps.name = name\n }\n } else {\n inputProps.ref = mergeRefs(props.ref, ref, startInputRef)\n inputProps.value = inputValue\n inputProps.id = id\n inputProps.name = name\n\n if (isArray(value)) {\n inputProps.style = {\n ...(!focused && !!value.length\n ? visuallyHiddenAttributes.style\n : {}),\n ...inputProps.style,\n }\n inputProps.placeholder = !value.length\n ? startPlaceholder\n : undefined\n inputProps[\"data-max\"] = dataAttr(\n isNumber(max) && value.length >= max,\n )\n } else {\n inputProps.placeholder = startPlaceholder\n }\n }\n\n return inputProps\n },\n [\n allowInput,\n dataProps,\n disabled,\n endPlaceholder,\n focused,\n id,\n inputValue,\n max,\n name,\n onBlur,\n onInputFocus,\n onInputChange,\n onKeyDown,\n onMouseDown,\n readOnly,\n ref,\n required,\n startPlaceholder,\n value,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getComboboxContentProps({\n ref: mergeRefs(ref, contentRef),\n role: \"dialog\",\n ...props,\n }),\n [getComboboxContentProps],\n )\n\n const getCalendarProps: PropGetter<UseCalendarProps<Multiple, Range>> =\n useCallback(\n (props) =>\n ({\n disabled: !interactive,\n format: calendarFormat,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n value,\n onChange,\n onChangeMonth: setMonth,\n ...calendarProps,\n ...props,\n }) as UseCalendarProps<Multiple, Range>,\n [\n interactive,\n calendarFormat,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n value,\n onChange,\n setMonth,\n calendarProps,\n ],\n )\n\n const getIconProps: PropGetter = useCallback(\n (props) => ({ ...dataProps, ...props }),\n [dataProps],\n )\n\n const getClearIconProps: PropGetter = useCallback(\n (props = {}) =>\n getIconProps({\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-label\": t(\"Clear value\"),\n role: \"button\",\n tabIndex: interactive ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClear),\n onKeyDown: handlerAll(props.onKeyDown, (ev) =>\n runKeyAction(ev, { Enter: onClear, Space: onClear }),\n ),\n }),\n [getIconProps, interactive, onClear, t],\n )\n\n return {\n children,\n dateToString,\n inputValue,\n interactive,\n month,\n open,\n range,\n separator,\n setInputValue,\n setMonth,\n setValue,\n stringToDate,\n value,\n getCalendarProps,\n getClearIconProps,\n getContentProps,\n getFieldProps,\n getIconProps,\n getInputProps,\n getRootProps,\n popoverProps,\n onChange,\n onClose,\n onInputChange,\n onOpen,\n }\n}\n\nexport type UseDatePickerReturn = ReturnType<typeof useDatePicker>\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwFA,MAAM,iBAAmC,EACvC,OACA,SACA,OACA,KACA,WACA,YACI;CACJ,MAAM,OAAO,QAAQ,MAAM;CAE3B,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,QAAD;EAAM,OAAO,EAAE,iBAAiB,aAAa;EAA7C,UAAA,CACG,QACE,EAAA,GAAA,oBAAA,cAAC,SAAA,CAAS,GAAG,KAAK,QAAQ,QAAQ,WAAY,CAAC,OAAO,YAAY,IACjE;;AAEV;AAqGA,MAAa,iBAGX,EACA,UAAUA,qBAAAA,kBACV,UAAUC,qBAAAA,kBACV,GAAG,UACoC,CAAC,MAAM;CAC9C,KAAA,GAAI,MAAA,QAAA,CAAM,OAAO,CAAC,CAAC,SAAA,GAAQ,MAAA,QAAA,CAAM,OAAO,CAAC,GAAG,UAAU;CAEtD,MAAM,EAAE,gBAAgBC,6BAAAA,eAAe;CACvC,MAAM,EAAE,QAAQ,eAAe,MAAMC,sBAAAA,QAAQ,YAAY;CACzD,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,aAAa,MACb,mBAAmB,OACnB,gBAAgB,OAChB,WAAW,OACX,gBAAgB,CAAC,UACjB,mBACA,+BAAe,IAAI,KAAK,GACxB,QAAQ,OACR,eAAgB,QACZ;EAAE,KAAK,KAAA;EAAW,OAAO,KAAA;CAAU,IACnC,WACE,CAAC,IACD,KAAA,GACN,UACA,eAAe,MACf,QACA,YAAY,gBACZ,SAAS,eACT,KACA,OAAO,WACP,eAAe,MACf,cAAc,MACd,cAAc,MACd,WACA,SACA,aAAa,iBACb,YAAY,aACZ,UACA,SAAS,eACT,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A;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,oBAAA,GA/BoCA,MAAAA,YAAAA,EACnC,QAAQ,CAAC,MACR,aAAa;GACX,kBAAA,GAAA,oBAAA,cAAiB,SAAA,CAAS,CAAC,WAAW;GACtC,cAAc,EAAE,aAAa;GAC7B,MAAM;GACN,UAAU,cAAc,IAAI;GAC5B,GAAG;GACH,UAAA,GAAA,oBAAA,cAAS,WAAA,CAAW,MAAM,SAAS,OAAO;GAC1C,YAAA,GAAA,oBAAA,cAAW,WAAA,CAAW,MAAM,YAAY,OACtCW,YAAAA,aAAa,IAAI;IAAE,OAAO;IAAS,OAAO;GAAQ,CAAC,CACrD;EACF,CAAC,GACH;GAAC;GAAc;GAAa;GAAS;EAAC,CAkBtB;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"use-date-picker.cjs","names":["DEFAULT_MAX_DATE","DEFAULT_MIN_DATE","useEnvironment","useI18n","useFieldProps","useDateTimeFormat","useMemo","useCalendarProps","useRef","useState","useControllableState","getAdjustedMonth","useCallback","isBeforeDate","isAfterDate","useCombobox","updateMaybeDateValue","isValidElement","cloneElement","isComposing","isIncludeDates","mergeRefs","visuallyHiddenAttributes","runKeyAction"],"sources":["../../../../src/components/date-picker/use-date-picker.tsx"],"sourcesContent":["\"use client\"\n\nimport type {\n ChangeEvent,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n ReactNode,\n} from \"react\"\nimport type { HTMLProps, HTMLRefAttributes, PropGetter } from \"../../core\"\nimport type { UseComboboxProps } from \"../../hooks/use-combobox\"\nimport type { Dict } from \"../../utils\"\nimport type {\n CalendarFormat,\n MaybeDateValue,\n UseCalendarProps,\n} from \"../calendar\"\nimport type { FieldProps } from \"../field\"\nimport dayjs from \"dayjs\"\nimport {\n cloneElement,\n isValidElement,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\"\nimport { useEnvironment } from \"../../core\"\nimport { useCombobox } from \"../../hooks/use-combobox\"\nimport { useControllableState } from \"../../hooks/use-controllable-state\"\nimport { useI18n } from \"../../providers/i18n-provider\"\nimport {\n ariaAttr,\n cast,\n contains,\n dataAttr,\n focusTransfer,\n handlerAll,\n isActiveElement,\n isArray,\n isComposing,\n isDate,\n isNumber,\n isObject,\n mergeRefs,\n runIfFn,\n runKeyAction,\n useUpdateEffect,\n visuallyHiddenAttributes,\n} from \"../../utils\"\nimport {\n DEFAULT_MAX_DATE,\n DEFAULT_MIN_DATE,\n getAdjustedMonth,\n isAfterDate,\n isBeforeDate,\n isIncludeDates,\n updateMaybeDateValue,\n useCalendarProps,\n} from \"../calendar\"\nimport { useFieldProps } from \"../field\"\nimport { useDateTimeFormat } from \"../format\"\n\nexport interface DatePickerFormat extends CalendarFormat {\n input?: Intl.DateTimeFormatOptions | null\n}\n\ntype InputAlign = \"end\" | \"start\"\ntype MaybeInputValue<Range extends boolean = false> = Range extends true\n ? { end?: string; start?: string }\n : string | undefined\n\ninterface DatePickerRenderProps {\n count: number\n date: Date\n focused: boolean\n index: number\n separator: string\n value: string\n onClear: () => void\n max?: number\n}\n\nexport interface DatePickerRender {\n (props: DatePickerRenderProps): ReactNode\n}\n\nconst defaultRender: DatePickerRender = ({\n count,\n focused,\n index,\n max,\n separator,\n value,\n}) => {\n const last = count - 1 === index\n\n return (\n <span style={{ marginInlineEnd: \"var(--gap)\" }}>\n {value}\n {((!isNumber(max) || count < max) && focused) || !last ? separator : null}\n </span>\n )\n}\n\nexport interface UseDatePickerProps<\n Multiple extends boolean = false,\n Range extends boolean = false,\n>\n extends\n Omit<UseCalendarProps<Multiple, Range>, \"format\" | \"ref\">,\n Omit<\n UseComboboxProps,\n \"defaultValue\" | \"initialFocusValue\" | \"onChange\" | \"ref\" | \"value\"\n >,\n HTMLRefAttributes<\"input\">,\n FieldProps {\n /**\n * If `true`, allows input.\n *\n * @default true\n */\n allowInput?: boolean\n /**\n * If `true`, allows input of dates beyond the `minDate` and `maxDate` restrictions.\n *\n * @default true\n */\n allowInputBeyond?: boolean\n /**\n * If `true`, the date picker will be closed when the input value changes.\n *\n * @default false\n */\n closeOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * The initial value of the input.\n */\n defaultInputValue?: MaybeInputValue<Range>\n /**\n * If `true`, the input will be focused when the clear icon is clicked.\n *\n * @default true\n */\n focusOnClear?: boolean\n /**\n * The format used for conversion.\n * Check the docs to see the format of possible modifiers you can pass.\n *\n * @see https://day.js.org/docs/en/display/format#list-of-localized-formats\n */\n format?: DatePickerFormat\n /**\n * The `id` attribute of the input element.\n */\n id?: string\n /**\n * The value of the input.\n */\n inputValue?: MaybeInputValue<Range>\n /**\n * The `name` attribute of the input element.\n */\n name?: string\n /**\n * If `true`, the date picker will be opened when the input value changes.\n *\n * @default true\n */\n openOnChange?: ((ev: ChangeEvent<HTMLInputElement>) => boolean) | boolean\n /**\n * If `true`, the date picker will be opened when the input is focused.\n *\n * @default true\n */\n openOnFocus?: boolean\n /**\n * The pattern used to check the input element.\n */\n pattern?: RegExp\n /**\n * The placeholder for date picker.\n */\n placeholder?: string\n /**\n * The visual separator between each value.\n *\n * @default ','\n */\n separator?: string\n /**\n * The callback invoked when input value state changes.\n */\n onInputChange?: (value: MaybeInputValue<Range>) => void\n /**\n * Function that converts the input value to Date type.\n */\n parseDate?: (value: string) => Date | undefined\n /**\n * The function to render the selected date.\n */\n render?: (props: DatePickerRenderProps) => ReactNode\n}\n\nexport const useDatePicker = <\n Multiple extends boolean = false,\n Range extends boolean = false,\n>({\n maxDate = DEFAULT_MAX_DATE,\n minDate = DEFAULT_MIN_DATE,\n ...props\n}: UseDatePickerProps<Multiple, Range> = {}) => {\n if (dayjs(minDate).isAfter(dayjs(maxDate))) maxDate = minDate\n\n const { getDocument } = useEnvironment()\n const { locale: defaultLocale, t } = useI18n(\"datePicker\")\n const {\n props: {\n id,\n ref,\n name,\n allowInput = true,\n allowInputBeyond = false,\n closeOnChange = false,\n multiple = false,\n closeOnSelect = !multiple,\n defaultInputValue,\n defaultMonth = () => new Date(),\n range = false,\n defaultValue = (range\n ? { end: undefined, start: undefined }\n : multiple\n ? []\n : undefined) as MaybeDateValue<Multiple, Range>,\n disabled,\n focusOnClear = true,\n format,\n inputValue: inputValueProp,\n locale = defaultLocale,\n max,\n month: monthProp,\n openOnChange = true,\n openOnClick = true,\n openOnFocus = true,\n parseDate,\n pattern,\n placeholder: placeholderProp,\n placement = \"end-start\",\n readOnly,\n render = defaultRender,\n required,\n separator = range ? \"-\" : \",\",\n value: valueProp,\n onChange: onChangeProp,\n onChangeMonth: onChangeMonthProp,\n onInputChange: onInputChangeProp,\n ...computedProps\n },\n ariaProps,\n dataProps,\n eventProps,\n } = useFieldProps(props)\n const dateTimeFormat = useDateTimeFormat({ locale })\n const { calendarFormat, inputFormat } = useMemo(() => {\n const { input: inputFormat, ...calendarFormat } = format ?? {}\n const defaultInputFormat: Intl.DateTimeFormatOptions = {\n day: \"numeric\",\n month: \"long\",\n year: \"numeric\",\n }\n\n return {\n calendarFormat,\n inputFormat:\n inputFormat !== null ? (inputFormat ?? defaultInputFormat) : undefined,\n }\n }, [format])\n const [calendarProps, rest] = useCalendarProps<Multiple, Range>(computedProps)\n const { excludeDate } = calendarProps\n const fieldRef = useRef<HTMLDivElement>(null)\n const contentRef = useRef<HTMLDivElement>(null)\n const startInputRef = useRef<HTMLInputElement>(null)\n const endInputRef = useRef<HTMLInputElement>(null)\n const focusByClickRef = useRef<boolean>(false)\n const [currentDate] = useState<Date>(() => new Date())\n const [focused, setFocused] = useState(false)\n const [value, setValue] = useControllableState({\n defaultValue: defaultValue as MaybeDateValue<Multiple, Range>,\n value: valueProp,\n onChange: onChangeProp,\n })\n const [month, setMonth] = useControllableState({\n defaultValue: () => {\n let defaultValue = runIfFn(defaultMonth)\n\n if (dayjs(minDate).isAfter(dayjs(defaultValue)))\n defaultValue = dayjs(minDate).set(\"date\", 1).toDate()\n\n return getAdjustedMonth(value, defaultValue)\n },\n value: monthProp,\n onChange: onChangeMonthProp,\n })\n const stringToDate = useCallback(\n (value: string, start: Date = minDate, end: Date = maxDate) => {\n let date = parseDate?.(value)\n\n if (!date && dayjs(value).isValid())\n date = dayjs(value).locale(locale).toDate()\n\n if (date == null) return undefined\n if (excludeDate?.(date)) return undefined\n\n if (!allowInputBeyond) {\n if (isBeforeDate(date, start)) date = start\n if (isAfterDate(date, end)) date = end\n }\n\n return date\n },\n [allowInputBeyond, excludeDate, locale, maxDate, minDate, parseDate],\n )\n const dateToString = useCallback(\n (date?: Date) => {\n if (date == null) return \"\"\n\n return dateTimeFormat(date, inputFormat)\n },\n [dateTimeFormat, inputFormat],\n )\n const [inputValue, setInputValue] = useControllableState({\n defaultValue: () => {\n if (defaultInputValue)\n if (isObject(defaultInputValue)) {\n if (dayjs(defaultInputValue.start).isValid())\n defaultInputValue.start = dateTimeFormat(\n dayjs(defaultInputValue.start).toDate(),\n inputFormat,\n )\n\n if (dayjs(defaultInputValue.end).isValid())\n defaultInputValue.end = dateTimeFormat(\n dayjs(defaultInputValue.end).toDate(),\n inputFormat,\n )\n\n return defaultInputValue\n } else {\n if (dayjs(defaultInputValue).isValid())\n return dateTimeFormat(\n dayjs(defaultInputValue).toDate(),\n inputFormat,\n ) as MaybeInputValue<Range>\n else return defaultInputValue\n }\n else if (isDate(value))\n return dateToString(value) as MaybeInputValue<Range>\n else if (isObject(value) && !isArray(value))\n return {\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>\n else return \"\" as MaybeInputValue<Range>\n },\n value: inputValueProp,\n onChange: onInputChangeProp,\n })\n const {\n interactive,\n open,\n getContentProps: getComboboxContentProps,\n getTriggerProps,\n popoverProps,\n onClose,\n onOpen,\n } = useCombobox({\n disabled,\n matchWidth: false,\n openOnClick: false,\n openOnEnter: !allowInput,\n openOnSpace: !allowInput,\n placement,\n readOnly,\n transferFocus: false,\n ...ariaProps,\n ...dataProps,\n ...eventProps,\n ...rest,\n })\n const children = useMemo<ReactNode>(() => {\n if (!isArray(value)) return null\n\n const count = value.length\n\n return value.map((date, index) => {\n const value = dateToString(date)\n\n const onClear = (ev?: MouseEvent<HTMLElement>) => {\n ev?.preventDefault()\n ev?.stopPropagation()\n\n setValue(\n (prev) =>\n updateMaybeDateValue(date, max)(prev) as MaybeDateValue<\n Multiple,\n Range\n >,\n )\n }\n\n const component = render({\n count,\n date,\n focused,\n index,\n max,\n separator,\n value,\n onClear,\n })\n\n if (isValidElement<Dict>(component))\n return cloneElement(component, { ...component.props, key: index })\n else return component\n })\n }, [dateToString, focused, max, render, separator, setValue, value])\n const { endPlaceholder, startPlaceholder } = useMemo(() => {\n if (range) {\n const startPlaceholder =\n placeholderProp ?? dateTimeFormat(currentDate, inputFormat)\n const endPlaceholder =\n placeholderProp ??\n dateTimeFormat(dayjs(currentDate).add(1, \"day\").toDate(), inputFormat)\n\n return { endPlaceholder, startPlaceholder }\n } else {\n const placeholder =\n placeholderProp ?? dateTimeFormat(currentDate, inputFormat)\n\n return { endPlaceholder: placeholder, startPlaceholder: placeholder }\n }\n }, [dateTimeFormat, inputFormat, placeholderProp, range, currentDate])\n\n const onChange = useCallback(\n (value: MaybeDateValue<Multiple, Range>) => {\n setValue(value)\n\n if (isArray(value)) setInputValue(\"\" as MaybeInputValue<Range>)\n else if (isObject(value) && !isDate(value))\n setInputValue({\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>)\n else setInputValue(dateToString(value) as MaybeInputValue<Range>)\n\n if (!closeOnSelect) return\n\n if (isObject(value) && !isArray(value) && !isDate(value)) {\n if (value.end && value.start) onClose()\n } else {\n onClose()\n }\n },\n [setValue, closeOnSelect, setInputValue, dateToString, onClose],\n )\n\n const onInputChange = useCallback(\n (ev: ChangeEvent<HTMLInputElement>) => {\n if (!allowInput) return\n if (isArray(value) && value.length === max) return\n\n if (runIfFn(closeOnChange, ev)) onClose()\n else if (runIfFn(openOnChange, ev)) onOpen()\n\n let inputValue = ev.target.value\n\n if (pattern) inputValue = inputValue.replace(pattern, \"\")\n\n if (isArray(value)) {\n const date = stringToDate(inputValue)\n\n setInputValue(inputValue as MaybeInputValue<Range>)\n\n if (date) setMonth(dayjs(date).set(\"date\", 1).toDate())\n } else if (isObject(value) && !isDate(value)) {\n const align = contains(endInputRef.current, ev.target) ? \"end\" : \"start\"\n const minDate =\n value.start && align === \"end\"\n ? dayjs(value.start).add(1, \"day\").toDate()\n : undefined\n const maxDate =\n value.end && align === \"start\"\n ? dayjs(value.end).subtract(1, \"day\").toDate()\n : undefined\n const date = stringToDate(inputValue, minDate, maxDate)\n\n setInputValue((prev) =>\n isObject(prev)\n ? Object.assign({}, prev, { [align]: inputValue })\n : prev,\n )\n setValue((prev) =>\n isObject(prev) && !isDate(prev) ? { ...prev, [align]: date } : prev,\n )\n } else {\n const date = stringToDate(inputValue)\n\n setInputValue(inputValue as MaybeInputValue<Range>)\n setValue(date as MaybeDateValue<Multiple, Range>)\n }\n },\n [\n allowInput,\n closeOnChange,\n max,\n onClose,\n onOpen,\n openOnChange,\n pattern,\n setInputValue,\n setMonth,\n setValue,\n stringToDate,\n value,\n ],\n )\n\n const onKeyDown = useCallback(\n (ev: KeyboardEvent<HTMLInputElement>) => {\n if (disabled || isComposing(ev)) return\n\n const inputValue = cast<HTMLInputElement>(ev.target).value\n\n runKeyAction(\n ev,\n {\n Backspace: (ev) => {\n if (isArray(value)) {\n if (inputValue.length) return\n\n ev.preventDefault()\n\n setValue((prev) =>\n isArray(prev)\n ? (prev.slice(0, -1) as MaybeDateValue<Multiple, Range>)\n : prev,\n )\n } else if (isObject(value) && !isDate(value)) {\n if (inputValue.length) return\n if (!contains(endInputRef.current, ev.target)) return\n\n ev.preventDefault()\n\n setInputValue({ end: \"\", start: \"\" } as MaybeInputValue<Range>)\n setValue({ end: undefined, start: undefined } as MaybeDateValue<\n Multiple,\n Range\n >)\n\n startInputRef.current?.focus()\n }\n },\n Enter: (ev) => {\n if (!open || !inputValue.length) return\n\n if (isObject(value) && !isArray(value) && !isDate(value)) {\n const align = contains(endInputRef.current, ev.target)\n ? \"end\"\n : \"start\"\n const minDate =\n value.start && align === \"end\"\n ? dayjs(value.start).add(1, \"day\").toDate()\n : undefined\n const maxDate =\n value.end && align === \"start\"\n ? dayjs(value.end).subtract(1, \"day\").toDate()\n : undefined\n const date = stringToDate(inputValue, minDate, maxDate)\n\n if (!date) return\n\n ev.preventDefault()\n\n setInputValue((prev) =>\n isObject(prev)\n ? Object.assign({}, prev, { [align]: dateToString(date) })\n : prev,\n )\n setValue((prev) =>\n isObject(prev) && !isDate(prev)\n ? { ...prev, [align]: date }\n : prev,\n )\n\n if (align === \"start\") endInputRef.current?.focus()\n } else {\n const date = stringToDate(inputValue)\n\n if (!date) return\n\n ev.preventDefault()\n\n if (isArray(value)) {\n setInputValue(\"\" as MaybeInputValue<Range>)\n\n setValue((prev) =>\n isArray(prev) &&\n !isIncludeDates(date, prev) &&\n (!isNumber(max) || prev.length < max)\n ? ([...prev, date] as MaybeDateValue<Multiple, Range>)\n : prev,\n )\n } else {\n setInputValue(dateToString(date) as MaybeInputValue<Range>)\n setValue(date as MaybeDateValue<Multiple, Range>)\n }\n }\n },\n },\n { preventDefault: false },\n )\n },\n [\n dateToString,\n disabled,\n max,\n open,\n setInputValue,\n setValue,\n stringToDate,\n value,\n ],\n )\n\n const onClick = useCallback(\n (ev: MouseEvent<HTMLDivElement>) => {\n if (!interactive) return\n\n focusByClickRef.current = true\n\n if (allowInput)\n if (isObject(value) && !isArray(value) && !isDate(value))\n if (\n startInputRef.current &&\n contains(startInputRef.current, ev.target)\n ) {\n if (!isActiveElement(startInputRef.current, getDocument()!))\n ev.defaultPrevented = true\n\n startInputRef.current.focus()\n } else if (\n endInputRef.current &&\n contains(endInputRef.current, ev.target)\n ) {\n if (!isActiveElement(endInputRef.current, getDocument()!))\n ev.defaultPrevented = true\n\n endInputRef.current.focus()\n } else {\n startInputRef.current?.focus()\n }\n else startInputRef.current?.focus()\n\n if (openOnClick) onOpen()\n },\n [allowInput, interactive, onOpen, openOnClick, value, getDocument],\n )\n\n const onMouseDown = useCallback(\n (ev: MouseEvent<HTMLDivElement | HTMLInputElement>) => {\n if (!openOnFocus) return\n\n ev.preventDefault()\n ev.stopPropagation()\n },\n [openOnFocus],\n )\n\n const onFieldFocus = useCallback(() => {\n if (allowInput) return\n\n if (openOnFocus) onOpen()\n\n focusByClickRef.current = false\n }, [allowInput, onOpen, openOnFocus])\n\n const onInputFocus = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n ev.preventDefault()\n ev.stopPropagation()\n\n setFocused(true)\n\n if (openOnFocus && !focusByClickRef.current) onOpen()\n\n focusByClickRef.current = false\n },\n [onOpen, openOnFocus],\n )\n\n const onBlur = useCallback(\n (ev: FocusEvent<HTMLInputElement>) => {\n setFocused(false)\n\n if (\n contains(fieldRef.current, ev.relatedTarget) ||\n contains(contentRef.current, ev.relatedTarget)\n )\n ev.preventDefault()\n else if (isArray(value)) setInputValue(\"\" as MaybeInputValue<Range>)\n else if (isObject(value) && !isDate(value))\n setInputValue((prev) =>\n isObject(prev)\n ? ({\n end: dateToString(value.end),\n start: dateToString(value.start),\n } as MaybeInputValue<Range>)\n : prev,\n )\n else setInputValue(dateToString(value) as MaybeInputValue<Range>)\n },\n [dateToString, setInputValue, value],\n )\n\n const onClear = useCallback(() => {\n if (!interactive) return\n\n setValue((prev) => {\n if (isDate(prev)) return undefined as MaybeDateValue<Multiple, Range>\n else if (isArray(prev))\n return [] as unknown as MaybeDateValue<Multiple, Range>\n else if (isObject(prev))\n return { end: undefined, start: undefined } as MaybeDateValue<\n Multiple,\n Range\n >\n else return prev\n })\n\n setInputValue(\n (range ? { end: \"\", start: \"\" } : \"\") as MaybeInputValue<Range>,\n )\n\n if (focusOnClear)\n if (allowInput) startInputRef.current?.focus()\n else fieldRef.current?.focus()\n }, [allowInput, focusOnClear, interactive, range, setInputValue, setValue])\n\n useEffect(() => {\n if (!open) return\n\n return focusTransfer(\n contentRef.current,\n allowInput ? startInputRef.current : fieldRef.current,\n )\n }, [allowInput, open])\n\n useUpdateEffect(() => {\n setMonth((prev) => getAdjustedMonth(value, prev))\n }, [value, range])\n\n useUpdateEffect(() => {\n if (isArray(valueProp)) return\n\n if (isObject(valueProp) && !isDate(valueProp))\n setInputValue({\n end: dateToString(valueProp.end),\n start: dateToString(valueProp.start),\n } as MaybeInputValue<Range>)\n else setInputValue(dateToString(valueProp) as MaybeInputValue<Range>)\n }, [valueProp])\n\n const getRootProps: PropGetter = useCallback(\n (props) => ({\n \"data-range\": dataAttr(range),\n ...dataProps,\n ...props,\n }),\n [dataProps, range],\n )\n\n const getFieldProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getTriggerProps({\n ref: mergeRefs(ref, fieldRef),\n \"aria-haspopup\": \"dialog\",\n tabIndex: !allowInput ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClick),\n onFocus: handlerAll(props.onFocus, onFieldFocus),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }),\n\n [allowInput, getTriggerProps, onClick, onFieldFocus, onMouseDown],\n )\n\n const getInputProps: PropGetter<\"input\", { align?: InputAlign }> =\n useCallback(\n ({ align = \"start\", ...props } = {}) => {\n const inputProps: HTMLProps<\"input\"> = {\n style: {\n ...(!allowInput ? { pointerEvents: \"none\" } : {}),\n ...props.style,\n },\n autoComplete: \"off\",\n disabled,\n readOnly,\n required,\n tabIndex: allowInput ? 0 : -1,\n ...dataProps,\n ...props,\n onBlur: handlerAll(props.onBlur, onBlur),\n onChange: handlerAll(props.onChange, onInputChange),\n onFocus: handlerAll(props.onFocus, onInputFocus),\n onKeyDown: handlerAll(props.onKeyDown, onKeyDown),\n onMouseDown: handlerAll(props.onMouseDown, onMouseDown),\n }\n\n if (isObject(inputValue)) {\n if (align === \"start\") {\n inputProps.ref = mergeRefs(props.ref, ref, startInputRef)\n inputProps.value = inputValue.start\n inputProps.placeholder = startPlaceholder\n } else {\n inputProps.ref = mergeRefs(props.ref, ref, endInputRef)\n inputProps.value = inputValue.end\n inputProps.placeholder = endPlaceholder\n }\n\n if (!inputValue.start && align === \"start\") {\n inputProps.id = id\n inputProps.name = name\n }\n\n if (!!inputValue.start && align === \"end\") {\n inputProps.id = id\n inputProps.name = name\n }\n } else {\n inputProps.ref = mergeRefs(props.ref, ref, startInputRef)\n inputProps.value = inputValue\n inputProps.id = id\n inputProps.name = name\n\n if (isArray(value)) {\n inputProps.style = {\n ...(!focused && !!value.length\n ? visuallyHiddenAttributes.style\n : {}),\n ...inputProps.style,\n }\n inputProps.placeholder = !value.length\n ? startPlaceholder\n : undefined\n inputProps[\"data-max\"] = dataAttr(\n isNumber(max) && value.length >= max,\n )\n } else {\n inputProps.placeholder = startPlaceholder\n }\n }\n\n return inputProps\n },\n [\n allowInput,\n dataProps,\n disabled,\n endPlaceholder,\n focused,\n id,\n inputValue,\n max,\n name,\n onBlur,\n onInputFocus,\n onInputChange,\n onKeyDown,\n onMouseDown,\n readOnly,\n ref,\n required,\n startPlaceholder,\n value,\n ],\n )\n\n const getContentProps: PropGetter = useCallback(\n ({ ref, ...props } = {}) =>\n getComboboxContentProps({\n ref: mergeRefs(ref, contentRef),\n role: \"dialog\",\n ...props,\n }),\n [getComboboxContentProps],\n )\n\n const getCalendarProps: PropGetter<UseCalendarProps<Multiple, Range>> =\n useCallback(\n (props) =>\n ({\n disabled: !interactive,\n format: calendarFormat,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n value,\n onChange,\n onChangeMonth: setMonth,\n ...calendarProps,\n ...props,\n }) as UseCalendarProps<Multiple, Range>,\n [\n interactive,\n calendarFormat,\n locale,\n max,\n maxDate,\n minDate,\n month,\n multiple,\n range,\n value,\n onChange,\n setMonth,\n calendarProps,\n ],\n )\n\n const getIconProps: PropGetter = useCallback(\n (props) => ({ ...dataProps, ...props }),\n [dataProps],\n )\n\n const getClearIconProps: PropGetter = useCallback(\n (props = {}) =>\n getIconProps({\n \"aria-disabled\": ariaAttr(!interactive),\n \"aria-label\": t(\"Clear value\"),\n role: \"button\",\n tabIndex: interactive ? 0 : -1,\n ...props,\n onClick: handlerAll(props.onClick, onClear),\n onKeyDown: handlerAll(props.onKeyDown, (ev) =>\n runKeyAction(ev, { Enter: onClear, Space: onClear }),\n ),\n }),\n [getIconProps, interactive, onClear, t],\n )\n\n return {\n children,\n dateToString,\n inputValue,\n interactive,\n month,\n open,\n range,\n separator,\n setInputValue,\n setMonth,\n setValue,\n stringToDate,\n value,\n getCalendarProps,\n getClearIconProps,\n getContentProps,\n getFieldProps,\n getIconProps,\n getInputProps,\n getRootProps,\n popoverProps,\n onChange,\n onClose,\n onInputChange,\n onOpen,\n }\n}\n\nexport type UseDatePickerReturn = ReturnType<typeof useDatePicker>\n"],"mappings":";;;;;;;;;;;;;;;;;;AAwFA,MAAM,iBAAmC,EACvC,OACA,SACA,OACA,KACA,WACA,YACI;CACJ,MAAM,OAAO,QAAQ,MAAM;CAE3B,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,QAAD;EAAM,OAAO,EAAE,iBAAiB,aAAa;EAA7C,UAAA,CACG,QACE,EAAA,GAAA,oBAAA,cAAC,SAAA,CAAS,GAAG,KAAK,QAAQ,QAAQ,WAAY,CAAC,OAAO,YAAY,IACjE;;AAEV;AAqGA,MAAa,iBAGX,EACA,UAAUA,qBAAAA,kBACV,UAAUC,qBAAAA,kBACV,GAAG,UACoC,CAAC,MAAM;CAC9C,KAAA,GAAI,MAAA,QAAA,CAAM,OAAO,CAAC,CAAC,SAAA,GAAQ,MAAA,QAAA,CAAM,OAAO,CAAC,GAAG,UAAU;CAEtD,MAAM,EAAE,gBAAgBC,6BAAAA,eAAe;CACvC,MAAM,EAAE,QAAQ,eAAe,MAAMC,sBAAAA,QAAQ,YAAY;CACzD,MAAM,EACJ,OAAO,EACL,IACA,KACA,MACA,aAAa,MACb,mBAAmB,OACnB,gBAAgB,OAChB,WAAW,OACX,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C;EACX,QAAQ;EACR;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,eAAe;EACf,GAAG;EACH,GAAG;CACL,IACF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF,CACF;CAEF,MAAM,gBAAA,GAA2BA,MAAAA,YAAAA,EAC9B,WAAW;EAAE,GAAG;EAAW,GAAG;CAAM,IACrC,CAAC,SAAS,CACZ;CAkBA,OAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,oBAAA,GA/BoCA,MAAAA,YAAAA,EACnC,QAAQ,CAAC,MACR,aAAa;GACX,kBAAA,GAAA,oBAAA,cAAiB,SAAA,CAAS,CAAC,WAAW;GACtC,cAAc,EAAE,aAAa;GAC7B,MAAM;GACN,UAAU,cAAc,IAAI;GAC5B,GAAG;GACH,UAAA,GAAA,oBAAA,cAAS,WAAA,CAAW,MAAM,SAAS,OAAO;GAC1C,YAAA,GAAA,oBAAA,cAAW,WAAA,CAAW,MAAM,YAAY,OACtCW,YAAAA,aAAa,IAAI;IAAE,OAAO;IAAS,OAAO;GAAQ,CAAC,CACrD;EACF,CAAC,GACH;GAAC;GAAc;GAAa;GAAS;EAAC,CAkBtB;EAChB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;AACF"}
|
|
@@ -24,7 +24,7 @@ const { ComponentContext, PropsContext: DrawerPropsContext, useComponentContext,
|
|
|
24
24
|
*
|
|
25
25
|
* @see https://yamada-ui.com/docs/components/drawer
|
|
26
26
|
*/
|
|
27
|
-
const DrawerRoot = withProvider(({ allowPinchZoom = false, autoFocus, blockScrollOnMount = true, body, cancel, children, closeOnDrag, dragConstraints, dragElastic, dragOffset, dragVelocity, duration = {
|
|
27
|
+
const DrawerRoot = withProvider(({ allowPinchZoom = false, autoFocus, blockScrollOnMount = true, body, cancel, children, closeOnDrag, dragConstraints, dragElastic, dragHandleOnly, dragOffset, dragVelocity, duration = {
|
|
28
28
|
enter: .4,
|
|
29
29
|
exit: .3
|
|
30
30
|
}, finalFocusRef, footer, header, initialFocusRef, lockFocusAcrossFrames = true, middle, placement: placementProp, restoreFocus, success, title, trigger, withCloseButton = !closeOnDrag, withDragBar = true, withOverlay = true, portalProps, onCancel, onCloseComplete, onMiddle, onSuccess, ...props }) => {
|
|
@@ -35,6 +35,7 @@ const DrawerRoot = withProvider(({ allowPinchZoom = false, autoFocus, blockScrol
|
|
|
35
35
|
closeOnDrag,
|
|
36
36
|
dragConstraints,
|
|
37
37
|
dragElastic,
|
|
38
|
+
dragHandleOnly,
|
|
38
39
|
dragOffset,
|
|
39
40
|
dragVelocity,
|
|
40
41
|
placement,
|
|
@@ -177,6 +178,16 @@ const DrawerDragBar = withContext("div", "dragBar")(void 0, (props) => {
|
|
|
177
178
|
const { getDragBarProps } = useComponentContext();
|
|
178
179
|
return { ...getDragBarProps(props) };
|
|
179
180
|
});
|
|
181
|
+
const DrawerDragTrigger = withContext("div", {
|
|
182
|
+
name: "DragTrigger",
|
|
183
|
+
slot: ["trigger", "drag"]
|
|
184
|
+
})(void 0, (props) => {
|
|
185
|
+
const { getDragTriggerProps } = useComponentContext();
|
|
186
|
+
return {
|
|
187
|
+
asChild: true,
|
|
188
|
+
...getDragTriggerProps(props)
|
|
189
|
+
};
|
|
190
|
+
});
|
|
180
191
|
const DrawerHeader = withContext("header", "header")(void 0, (props) => {
|
|
181
192
|
const { getHeaderProps } = useComponentContext();
|
|
182
193
|
return { ...getHeaderProps(props) };
|
|
@@ -199,6 +210,7 @@ exports.DrawerCloseButton = DrawerCloseButton;
|
|
|
199
210
|
exports.DrawerCloseTrigger = DrawerCloseTrigger;
|
|
200
211
|
exports.DrawerContent = DrawerContent;
|
|
201
212
|
exports.DrawerDragBar = DrawerDragBar;
|
|
213
|
+
exports.DrawerDragTrigger = DrawerDragTrigger;
|
|
202
214
|
exports.DrawerFooter = DrawerFooter;
|
|
203
215
|
exports.DrawerHeader = DrawerHeader;
|
|
204
216
|
exports.DrawerOpenTrigger = DrawerOpenTrigger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drawer.cjs","names":["createSlotComponent","drawerStyle","useValue","useSplitChildren","useDrawer","useMemo","AnimatePresence","Portal","FocusLock","RemoveScroll","styled","CloseButton","motion","fadeVariants","Slide","wrapOrPassProps","Button"],"sources":["../../../../src/components/drawer/drawer.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren, ReactNode } from \"react\"\nimport type { HTMLProps, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { ButtonProps } from \"../button\"\nimport type { CloseButtonProps } from \"../close-button\"\nimport type { FocusLockProps } from \"../focus-lock\"\nimport type { HTMLMotionProps, MotionTransitionProps } from \"../motion\"\nimport type { PortalProps } from \"../portal\"\nimport type { SlideProps } from \"../slide\"\nimport type { DrawerStyle } from \"./drawer.style\"\nimport type { UseDrawerProps, UseDrawerReturn } from \"./use-drawer\"\nimport { AnimatePresence } from \"motion/react\"\nimport { useMemo } from \"react\"\nimport { RemoveScroll } from \"react-remove-scroll\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { useValue } from \"../../hooks/use-value\"\nimport { cast, isArray, useSplitChildren, wrapOrPassProps } from \"../../utils\"\nimport { Button } from \"../button\"\nimport { CloseButton } from \"../close-button\"\nimport { fadeVariants } from \"../fade\"\nimport { FocusLock } from \"../focus-lock\"\nimport { motion } from \"../motion\"\nimport { Portal } from \"../portal\"\nimport { Slide } from \"../slide\"\nimport { drawerStyle } from \"./drawer.style\"\nimport { useDrawer } from \"./use-drawer\"\n\ninterface ComponentContext\n extends\n Omit<UseDrawerReturn, \"getRootProps\">,\n Pick<\n DrawerRootProps,\n \"duration\" | \"placement\" | \"withCloseButton\" | \"withDragBar\"\n > {}\n\nexport interface DrawerRootProps\n extends\n ThemeProps<DrawerStyle>,\n Omit<UseDrawerProps, \"placement\" | \"title\">,\n Pick<\n FocusLockProps,\n | \"autoFocus\"\n | \"finalFocusRef\"\n | \"initialFocusRef\"\n | \"lockFocusAcrossFrames\"\n | \"restoreFocus\"\n >,\n ShorthandDrawerContentProps {\n /**\n * Handle zoom or pinch gestures on iOS devices when scroll locking is enabled.\n *\n * @default false.\n */\n allowPinchZoom?: boolean\n /**\n * If `true`, scrolling will be disabled on the `body` when the drawer opens.\n *\n * @default true\n */\n blockScrollOnMount?: boolean\n /**\n * The animation duration.\n */\n duration?: MotionTransitionProps[\"duration\"]\n /**\n * The modal trigger to use.\n */\n trigger?: ReactNode\n /**\n * If `true`, display the drawer close button.\n *\n * @default true\n */\n withCloseButton?: boolean\n /**\n * If `true`, display the drag bar when `closeOnDrag` is `true`.\n *\n * @default true\n */\n withDragBar?: boolean\n /**\n * If `true`, display the drawer overlay.\n *\n * @default true\n */\n withOverlay?: boolean\n /**\n * Props to be forwarded to the portal component.\n */\n portalProps?: Omit<PortalProps, \"children\">\n /**\n * Callback function to run side effects after the drawer has closed.\n */\n onCloseComplete?: () => void\n}\n\nconst {\n ComponentContext,\n PropsContext: DrawerPropsContext,\n useComponentContext,\n usePropsContext: useDrawerPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<DrawerRootProps, DrawerStyle, ComponentContext>(\n \"drawer\",\n drawerStyle,\n)\n\nexport { DrawerPropsContext, useDrawerPropsContext }\n\n/**\n * `Drawer` is a component for a panel that appears from the edge of the screen.\n *\n * @see https://yamada-ui.com/docs/components/drawer\n */\nexport const DrawerRoot = withProvider<\"div\", DrawerRootProps, \"placement\">(\n ({\n allowPinchZoom = false,\n autoFocus,\n blockScrollOnMount = true,\n body,\n cancel,\n children,\n closeOnDrag,\n dragConstraints,\n dragElastic,\n dragOffset,\n dragVelocity,\n duration = { enter: 0.4, exit: 0.3 },\n finalFocusRef,\n footer,\n header,\n initialFocusRef,\n lockFocusAcrossFrames = true,\n middle,\n placement: placementProp,\n restoreFocus,\n success,\n title,\n trigger,\n withCloseButton = !closeOnDrag,\n withDragBar = true,\n withOverlay = true,\n portalProps,\n onCancel,\n onCloseComplete,\n onMiddle,\n onSuccess,\n ...props\n }) => {\n const placement = useValue(placementProp)\n const [omittedChildren, openTrigger, customOverlay] = useSplitChildren(\n children,\n DrawerOpenTrigger,\n DrawerOverlay,\n )\n const hasChildren = isArray(omittedChildren) && !!omittedChildren.length\n const { open, getRootProps, ...rest } = useDrawer({\n closeOnDrag,\n dragConstraints,\n dragElastic,\n dragOffset,\n dragVelocity,\n placement,\n ...props,\n })\n const customOpenTrigger = trigger ? (\n <DrawerOpenTrigger>{trigger}</DrawerOpenTrigger>\n ) : null\n\n const context = useMemo(\n () => ({\n duration,\n open,\n placement,\n withCloseButton,\n withDragBar,\n ...rest,\n }),\n [duration, open, withDragBar, placement, withCloseButton, rest],\n )\n\n return (\n <ComponentContext value={context}>\n {openTrigger ?? customOpenTrigger}\n\n <AnimatePresence onExitComplete={onCloseComplete}>\n {open ? (\n <Portal {...portalProps}>\n <FocusLock\n autoFocus={autoFocus}\n finalFocusRef={finalFocusRef}\n initialFocusRef={initialFocusRef}\n lockFocusAcrossFrames={lockFocusAcrossFrames}\n restoreFocus={restoreFocus}\n >\n <RemoveScroll\n allowPinchZoom={allowPinchZoom}\n enabled={blockScrollOnMount}\n forwardProps\n >\n <styled.div {...getRootProps()}>\n {customOverlay ?? (withOverlay ? <DrawerOverlay /> : null)}\n\n {hasChildren ? (\n omittedChildren\n ) : (\n <ShorthandDrawerContent\n body={body}\n cancel={cancel}\n footer={footer}\n header={header}\n middle={middle}\n success={success}\n title={title}\n onCancel={onCancel}\n onMiddle={onMiddle}\n onSuccess={onSuccess}\n />\n )}\n </styled.div>\n </RemoveScroll>\n </FocusLock>\n </Portal>\n ) : null}\n </AnimatePresence>\n </ComponentContext>\n )\n },\n \"root\",\n { transferProps: [\"placement\"] },\n)()\n\nexport interface DrawerOpenTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const DrawerOpenTrigger = withContext<\"button\", DrawerOpenTriggerProps>(\n \"button\",\n { name: \"OpenTrigger\", slot: [\"trigger\", \"open\"] },\n)(undefined, (props) => {\n const { getOpenTriggerProps } = useComponentContext()\n\n return { asChild: true, ...getOpenTriggerProps(props) }\n})\n\nexport interface DrawerCloseTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const DrawerCloseTrigger = withContext<\n \"button\",\n DrawerCloseTriggerProps\n>(\"button\", { name: \"CloseTrigger\", slot: [\"trigger\", \"close\"] })(\n undefined,\n (props) => {\n const { getCloseTriggerProps } = useComponentContext()\n\n return { asChild: true, ...getCloseTriggerProps(props) }\n },\n)\n\nexport interface DrawerCloseButtonProps extends CloseButtonProps {}\n\nexport const DrawerCloseButton = withContext<\"button\", DrawerCloseButtonProps>(\n CloseButton,\n \"closeButton\",\n)(undefined, (props) => {\n const { getCloseButtonProps } = useComponentContext()\n\n return { ...getCloseButtonProps(props) }\n})\n\nexport interface DrawerOverlayProps extends HTMLMotionProps {}\n\nexport const DrawerOverlay = withContext<\"div\", DrawerOverlayProps>((props) => {\n const { duration, getOverlayProps } = useComponentContext()\n\n return (\n <motion.div\n animate=\"enter\"\n custom={{ duration }}\n exit=\"exit\"\n initial=\"exit\"\n variants={fadeVariants}\n {...cast<HTMLMotionProps>(getOverlayProps(cast<HTMLProps>(props)))}\n />\n )\n}, \"overlay\")()\n\nexport interface DrawerContentProps\n extends Omit<HTMLMotionProps<\"section\">, \"children\">, PropsWithChildren {}\n\nexport const DrawerContent = withContext<\"div\", DrawerContentProps>(\n ({ children, ...rest }) => {\n const {\n closeOnDrag,\n duration,\n open,\n placement,\n withCloseButton,\n withDragBar,\n getContentProps,\n } = useComponentContext()\n const [omittedChildren, customCloseButton, customDragBar] =\n useSplitChildren(children, DrawerCloseButton, DrawerDragBar)\n\n return (\n <Slide\n as=\"section\"\n duration={duration}\n open={open}\n placement={placement}\n {...(getContentProps(rest) as SlideProps)}\n >\n {customCloseButton ?? (withCloseButton ? <DrawerCloseButton /> : null)}\n {customDragBar ??\n (withDragBar && closeOnDrag ? <DrawerDragBar /> : null)}\n\n {omittedChildren}\n </Slide>\n )\n },\n \"content\",\n)()\n\ninterface ShorthandDrawerContentProps {\n /**\n * The drawer body to use.\n */\n body?: DrawerBodyProps | ReactNode\n /**\n * The drawer cancel button to use.\n */\n cancel?: ButtonProps | ReactNode\n /**\n * The drawer footer to use.\n */\n footer?: DrawerFooterProps | ReactNode\n /**\n * The drawer header to use.\n */\n header?: DrawerHeaderProps | ReactNode\n /**\n * The drawer middle button to use.\n */\n middle?: ButtonProps | ReactNode\n /**\n * The drawer success button to use.\n */\n success?: ButtonProps | ReactNode\n /**\n * The drawer title to use.\n */\n title?: DrawerTitleProps | ReactNode\n /**\n * The callback invoked when cancel button clicked.\n */\n onCancel?: (onClose: () => void) => void\n /**\n * The callback invoked when middle button clicked.\n */\n onMiddle?: (onClose: () => void) => void\n /**\n * The callback invoked when success button clicked.\n */\n onSuccess?: (onClose: () => void) => void\n}\n\nexport const ShorthandDrawerContent: FC<ShorthandDrawerContentProps> = ({\n body,\n cancel,\n footer,\n header,\n middle,\n success,\n title,\n onCancel,\n onMiddle,\n onSuccess,\n}) => {\n const { onClose } = useComponentContext()\n const customHeader = wrapOrPassProps(DrawerHeader, header)\n const customTitle = wrapOrPassProps(DrawerTitle, title)\n const customBody = wrapOrPassProps(DrawerBody, body)\n const customFooter = wrapOrPassProps(DrawerFooter, footer)\n const customCancel = wrapOrPassProps(Button, cancel, {\n colorScheme: \"mono\",\n variant: \"ghost\",\n onClick: () => (onCancel ? onCancel(onClose) : onClose()),\n })\n const customMiddle = wrapOrPassProps(Button, middle, {\n colorScheme: \"secondary\",\n onClick: () => (onMiddle ? onMiddle(onClose) : onClose()),\n })\n const customSuccess = wrapOrPassProps(Button, success, {\n colorScheme: \"primary\",\n onClick: () => (onSuccess ? onSuccess(onClose) : onClose()),\n })\n\n return (\n <DrawerContent>\n {customHeader ??\n (customTitle ? <DrawerHeader>{customTitle}</DrawerHeader> : null)}\n {customBody}\n {customFooter ??\n (customCancel || customMiddle || customSuccess ? (\n <DrawerFooter>\n {customCancel}\n {customMiddle}\n {customSuccess}\n </DrawerFooter>\n ) : null)}\n </DrawerContent>\n )\n}\n\nexport interface DrawerDragBarProps extends HTMLStyledProps {}\n\nexport const DrawerDragBar = withContext<\"div\", DrawerDragBarProps>(\n \"div\",\n \"dragBar\",\n)(undefined, (props) => {\n const { getDragBarProps } = useComponentContext()\n\n return { ...getDragBarProps(props) }\n})\n\nexport interface DrawerHeaderProps extends HTMLStyledProps<\"header\"> {}\n\nexport const DrawerHeader = withContext<\"header\", DrawerHeaderProps>(\n \"header\",\n \"header\",\n)(undefined, (props) => {\n const { getHeaderProps } = useComponentContext()\n\n return { ...getHeaderProps(props) }\n})\n\nexport interface DrawerTitleProps extends HTMLStyledProps<\"h2\"> {}\n\nexport const DrawerTitle = withContext<\"h2\", DrawerTitleProps>(\"h2\", \"title\")(\n undefined,\n (props) => {\n const { getTitleProps } = useComponentContext()\n\n return { ...getTitleProps(props) }\n },\n)\n\nexport interface DrawerBodyProps extends HTMLStyledProps {}\n\nexport const DrawerBody = withContext<\"div\", DrawerBodyProps>(\"div\", \"body\")(\n undefined,\n (props) => {\n const { getBodyProps } = useComponentContext()\n\n return { ...getBodyProps(props) }\n },\n)\n\nexport interface DrawerFooterProps extends HTMLStyledProps<\"footer\"> {}\n\nexport const DrawerFooter = withContext<\"footer\", DrawerFooterProps>(\n \"footer\",\n \"footer\",\n)(undefined, (props) => {\n const { getFooterProps } = useComponentContext()\n\n return { ...getFooterProps(props) }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiGA,MAAM,EACJ,kBACA,cAAc,oBACd,qBACA,iBAAiB,uBACjB,aACA,iBACEA,yBAAAA,oBACF,UACAC,qBAAAA,WACF;;;;;;AASA,MAAa,aAAa,cACvB,EACC,iBAAiB,OACjB,WACA,qBAAqB,MACrB,MACA,QACA,UACA,aACA,iBACA,aACA,YACA,cACA,WAAW;CAAE,OAAO;CAAK,MAAM;A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Q;CAC3D,CAAC;CAED,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,eAAD,EAAA,UAAA;EACG,iBACE,cAAc,iBAAA,GAAA,kBAAA,IAAA,CAAC,cAAD,EAAA,UAAe,YAA0B,CAAA,IAAI;EAC7D;EACA,iBACE,gBAAgB,gBAAgB,gBAC/B,iBAAA,GAAA,kBAAA,KAAA,CAAC,cAAD,EAAA,UAAA;GACG;GACA;GACA;EACW,EAAA,CAAA,IACZ;CACO,EAAA,CAAA;AAEnB;AAIA,MAAa,gBAAgB,YAC3B,OACA,SACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,oBAAoB,oBAAoB;CAEhD,OAAO,EAAE,GAAG,gBAAgB,KAAK,EAAE;AACrC,CAAC;AAID,MAAa,eAAe,YAC1B,UACA,QACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,mBAAmB,oBAAoB;CAE/C,OAAO,EAAE,GAAG,eAAe,KAAK,EAAE;AACpC,CAAC;AAID,MAAa,cAAc,YAAoC,MAAM,OAAO,CAAC,CAC3E,KAAA,IACC,UAAU;CACT,MAAM,EAAE,kBAAkB,oBAAoB;CAE9C,OAAO,EAAE,GAAG,cAAc,KAAK,EAAE;AACnC,CACF;AAIA,MAAa,aAAa,YAAoC,OAAO,MAAM,CAAC,CAC1E,KAAA,IACC,UAAU;CACT,MAAM,EAAE,iBAAiB,oBAAoB;CAE7C,OAAO,EAAE,GAAG,aAAa,KAAK,EAAE;AAClC,CACF;AAIA,MAAa,eAAe,YAC1B,UACA,QACF,CAAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,mBAAmB,oBAAoB;CAE/C,OAAO,EAAE,GAAG,eAAe,KAAK,EAAE;AACpC,CAAC"}
|
|
1
|
+
{"version":3,"file":"drawer.cjs","names":["createSlotComponent","drawerStyle","useValue","useSplitChildren","useDrawer","useMemo","AnimatePresence","Portal","FocusLock","RemoveScroll","styled","CloseButton","motion","fadeVariants","Slide","wrapOrPassProps","Button"],"sources":["../../../../src/components/drawer/drawer.tsx"],"sourcesContent":["\"use client\"\n\nimport type { FC, PropsWithChildren, ReactNode } from \"react\"\nimport type { HTMLProps, HTMLStyledProps, ThemeProps } from \"../../core\"\nimport type { ButtonProps } from \"../button\"\nimport type { CloseButtonProps } from \"../close-button\"\nimport type { FocusLockProps } from \"../focus-lock\"\nimport type { HTMLMotionProps, MotionTransitionProps } from \"../motion\"\nimport type { PortalProps } from \"../portal\"\nimport type { SlideProps } from \"../slide\"\nimport type { DrawerStyle } from \"./drawer.style\"\nimport type { UseDrawerProps, UseDrawerReturn } from \"./use-drawer\"\nimport { AnimatePresence } from \"motion/react\"\nimport { useMemo } from \"react\"\nimport { RemoveScroll } from \"react-remove-scroll\"\nimport { createSlotComponent, styled } from \"../../core\"\nimport { useValue } from \"../../hooks/use-value\"\nimport { cast, isArray, useSplitChildren, wrapOrPassProps } from \"../../utils\"\nimport { Button } from \"../button\"\nimport { CloseButton } from \"../close-button\"\nimport { fadeVariants } from \"../fade\"\nimport { FocusLock } from \"../focus-lock\"\nimport { motion } from \"../motion\"\nimport { Portal } from \"../portal\"\nimport { Slide } from \"../slide\"\nimport { drawerStyle } from \"./drawer.style\"\nimport { useDrawer } from \"./use-drawer\"\n\ninterface ComponentContext\n extends\n Omit<UseDrawerReturn, \"getRootProps\">,\n Pick<\n DrawerRootProps,\n \"duration\" | \"placement\" | \"withCloseButton\" | \"withDragBar\"\n > {}\n\nexport interface DrawerRootProps\n extends\n ThemeProps<DrawerStyle>,\n Omit<UseDrawerProps, \"placement\" | \"title\">,\n Pick<\n FocusLockProps,\n | \"autoFocus\"\n | \"finalFocusRef\"\n | \"initialFocusRef\"\n | \"lockFocusAcrossFrames\"\n | \"restoreFocus\"\n >,\n ShorthandDrawerContentProps {\n /**\n * Handle zoom or pinch gestures on iOS devices when scroll locking is enabled.\n *\n * @default false.\n */\n allowPinchZoom?: boolean\n /**\n * If `true`, scrolling will be disabled on the `body` when the drawer opens.\n *\n * @default true\n */\n blockScrollOnMount?: boolean\n /**\n * The animation duration.\n */\n duration?: MotionTransitionProps[\"duration\"]\n /**\n * The modal trigger to use.\n */\n trigger?: ReactNode\n /**\n * If `true`, display the drawer close button.\n *\n * @default true\n */\n withCloseButton?: boolean\n /**\n * If `true`, display the drag bar when `closeOnDrag` is `true`.\n *\n * @default true\n */\n withDragBar?: boolean\n /**\n * If `true`, display the drawer overlay.\n *\n * @default true\n */\n withOverlay?: boolean\n /**\n * Props to be forwarded to the portal component.\n */\n portalProps?: Omit<PortalProps, \"children\">\n /**\n * Callback function to run side effects after the drawer has closed.\n */\n onCloseComplete?: () => void\n}\n\nconst {\n ComponentContext,\n PropsContext: DrawerPropsContext,\n useComponentContext,\n usePropsContext: useDrawerPropsContext,\n withContext,\n withProvider,\n} = createSlotComponent<DrawerRootProps, DrawerStyle, ComponentContext>(\n \"drawer\",\n drawerStyle,\n)\n\nexport { DrawerPropsContext, useDrawerPropsContext }\n\n/**\n * `Drawer` is a component for a panel that appears from the edge of the screen.\n *\n * @see https://yamada-ui.com/docs/components/drawer\n */\nexport const DrawerRoot = withProvider<\"div\", DrawerRootProps, \"placement\">(\n ({\n allowPinchZoom = false,\n autoFocus,\n blockScrollOnMount = true,\n body,\n cancel,\n children,\n closeOnDrag,\n dragConstraints,\n dragElastic,\n dragHandleOnly,\n dragOffset,\n dragVelocity,\n duration = { enter: 0.4, exit: 0.3 },\n finalFocusRef,\n footer,\n header,\n initialFocusRef,\n lockFocusAcrossFrames = true,\n middle,\n placement: placementProp,\n restoreFocus,\n success,\n title,\n trigger,\n withCloseButton = !closeOnDrag,\n withDragBar = true,\n withOverlay = true,\n portalProps,\n onCancel,\n onCloseComplete,\n onMiddle,\n onSuccess,\n ...props\n }) => {\n const placement = useValue(placementProp)\n const [omittedChildren, openTrigger, customOverlay] = useSplitChildren(\n children,\n DrawerOpenTrigger,\n DrawerOverlay,\n )\n const hasChildren = isArray(omittedChildren) && !!omittedChildren.length\n const { open, getRootProps, ...rest } = useDrawer({\n closeOnDrag,\n dragConstraints,\n dragElastic,\n dragHandleOnly,\n dragOffset,\n dragVelocity,\n placement,\n ...props,\n })\n const customOpenTrigger = trigger ? (\n <DrawerOpenTrigger>{trigger}</DrawerOpenTrigger>\n ) : null\n\n const context = useMemo(\n () => ({\n duration,\n open,\n placement,\n withCloseButton,\n withDragBar,\n ...rest,\n }),\n [duration, open, withDragBar, placement, withCloseButton, rest],\n )\n\n return (\n <ComponentContext value={context}>\n {openTrigger ?? customOpenTrigger}\n\n <AnimatePresence onExitComplete={onCloseComplete}>\n {open ? (\n <Portal {...portalProps}>\n <FocusLock\n autoFocus={autoFocus}\n finalFocusRef={finalFocusRef}\n initialFocusRef={initialFocusRef}\n lockFocusAcrossFrames={lockFocusAcrossFrames}\n restoreFocus={restoreFocus}\n >\n <RemoveScroll\n allowPinchZoom={allowPinchZoom}\n enabled={blockScrollOnMount}\n forwardProps\n >\n <styled.div {...getRootProps()}>\n {customOverlay ?? (withOverlay ? <DrawerOverlay /> : null)}\n\n {hasChildren ? (\n omittedChildren\n ) : (\n <ShorthandDrawerContent\n body={body}\n cancel={cancel}\n footer={footer}\n header={header}\n middle={middle}\n success={success}\n title={title}\n onCancel={onCancel}\n onMiddle={onMiddle}\n onSuccess={onSuccess}\n />\n )}\n </styled.div>\n </RemoveScroll>\n </FocusLock>\n </Portal>\n ) : null}\n </AnimatePresence>\n </ComponentContext>\n )\n },\n \"root\",\n { transferProps: [\"placement\"] },\n)()\n\nexport interface DrawerOpenTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const DrawerOpenTrigger = withContext<\"button\", DrawerOpenTriggerProps>(\n \"button\",\n { name: \"OpenTrigger\", slot: [\"trigger\", \"open\"] },\n)(undefined, (props) => {\n const { getOpenTriggerProps } = useComponentContext()\n\n return { asChild: true, ...getOpenTriggerProps(props) }\n})\n\nexport interface DrawerCloseTriggerProps extends HTMLStyledProps<\"button\"> {}\n\nexport const DrawerCloseTrigger = withContext<\n \"button\",\n DrawerCloseTriggerProps\n>(\"button\", { name: \"CloseTrigger\", slot: [\"trigger\", \"close\"] })(\n undefined,\n (props) => {\n const { getCloseTriggerProps } = useComponentContext()\n\n return { asChild: true, ...getCloseTriggerProps(props) }\n },\n)\n\nexport interface DrawerCloseButtonProps extends CloseButtonProps {}\n\nexport const DrawerCloseButton = withContext<\"button\", DrawerCloseButtonProps>(\n CloseButton,\n \"closeButton\",\n)(undefined, (props) => {\n const { getCloseButtonProps } = useComponentContext()\n\n return { ...getCloseButtonProps(props) }\n})\n\nexport interface DrawerOverlayProps extends HTMLMotionProps {}\n\nexport const DrawerOverlay = withContext<\"div\", DrawerOverlayProps>((props) => {\n const { duration, getOverlayProps } = useComponentContext()\n\n return (\n <motion.div\n animate=\"enter\"\n custom={{ duration }}\n exit=\"exit\"\n initial=\"exit\"\n variants={fadeVariants}\n {...cast<HTMLMotionProps>(getOverlayProps(cast<HTMLProps>(props)))}\n />\n )\n}, \"overlay\")()\n\nexport interface DrawerContentProps\n extends Omit<HTMLMotionProps<\"section\">, \"children\">, PropsWithChildren {}\n\nexport const DrawerContent = withContext<\"div\", DrawerContentProps>(\n ({ children, ...rest }) => {\n const {\n closeOnDrag,\n duration,\n open,\n placement,\n withCloseButton,\n withDragBar,\n getContentProps,\n } = useComponentContext()\n const [omittedChildren, customCloseButton, customDragBar] =\n useSplitChildren(children, DrawerCloseButton, DrawerDragBar)\n\n return (\n <Slide\n as=\"section\"\n duration={duration}\n open={open}\n placement={placement}\n {...(getContentProps(rest) as SlideProps)}\n >\n {customCloseButton ?? (withCloseButton ? <DrawerCloseButton /> : null)}\n {customDragBar ??\n (withDragBar && closeOnDrag ? <DrawerDragBar /> : null)}\n\n {omittedChildren}\n </Slide>\n )\n },\n \"content\",\n)()\n\ninterface ShorthandDrawerContentProps {\n /**\n * The drawer body to use.\n */\n body?: DrawerBodyProps | ReactNode\n /**\n * The drawer cancel button to use.\n */\n cancel?: ButtonProps | ReactNode\n /**\n * The drawer footer to use.\n */\n footer?: DrawerFooterProps | ReactNode\n /**\n * The drawer header to use.\n */\n header?: DrawerHeaderProps | ReactNode\n /**\n * The drawer middle button to use.\n */\n middle?: ButtonProps | ReactNode\n /**\n * The drawer success button to use.\n */\n success?: ButtonProps | ReactNode\n /**\n * The drawer title to use.\n */\n title?: DrawerTitleProps | ReactNode\n /**\n * The callback invoked when cancel button clicked.\n */\n onCancel?: (onClose: () => void) => void\n /**\n * The callback invoked when middle button clicked.\n */\n onMiddle?: (onClose: () => void) => void\n /**\n * The callback invoked when success button clicked.\n */\n onSuccess?: (onClose: () => void) => void\n}\n\nexport const ShorthandDrawerContent: FC<ShorthandDrawerContentProps> = ({\n body,\n cancel,\n footer,\n header,\n middle,\n success,\n title,\n onCancel,\n onMiddle,\n onSuccess,\n}) => {\n const { onClose } = useComponentContext()\n const customHeader = wrapOrPassProps(DrawerHeader, header)\n const customTitle = wrapOrPassProps(DrawerTitle, title)\n const customBody = wrapOrPassProps(DrawerBody, body)\n const customFooter = wrapOrPassProps(DrawerFooter, footer)\n const customCancel = wrapOrPassProps(Button, cancel, {\n colorScheme: \"mono\",\n variant: \"ghost\",\n onClick: () => (onCancel ? onCancel(onClose) : onClose()),\n })\n const customMiddle = wrapOrPassProps(Button, middle, {\n colorScheme: \"secondary\",\n onClick: () => (onMiddle ? onMiddle(onClose) : onClose()),\n })\n const customSuccess = wrapOrPassProps(Button, success, {\n colorScheme: \"primary\",\n onClick: () => (onSuccess ? onSuccess(onClose) : onClose()),\n })\n\n return (\n <DrawerContent>\n {customHeader ??\n (customTitle ? <DrawerHeader>{customTitle}</DrawerHeader> : null)}\n {customBody}\n {customFooter ??\n (customCancel || customMiddle || customSuccess ? (\n <DrawerFooter>\n {customCancel}\n {customMiddle}\n {customSuccess}\n </DrawerFooter>\n ) : null)}\n </DrawerContent>\n )\n}\n\nexport interface DrawerDragBarProps extends HTMLStyledProps {}\n\nexport const DrawerDragBar = withContext<\"div\", DrawerDragBarProps>(\n \"div\",\n \"dragBar\",\n)(undefined, (props) => {\n const { getDragBarProps } = useComponentContext()\n\n return { ...getDragBarProps(props) }\n})\n\nexport interface DrawerDragTriggerProps extends HTMLStyledProps {}\n\nexport const DrawerDragTrigger = withContext<\"div\", DrawerDragTriggerProps>(\n \"div\",\n { name: \"DragTrigger\", slot: [\"trigger\", \"drag\"] },\n)(undefined, (props) => {\n const { getDragTriggerProps } = useComponentContext()\n\n return { asChild: true, ...getDragTriggerProps(props) }\n})\n\nexport interface DrawerHeaderProps extends HTMLStyledProps<\"header\"> {}\n\nexport const DrawerHeader = withContext<\"header\", DrawerHeaderProps>(\n \"header\",\n \"header\",\n)(undefined, (props) => {\n const { getHeaderProps } = useComponentContext()\n\n return { ...getHeaderProps(props) }\n})\n\nexport interface DrawerTitleProps extends HTMLStyledProps<\"h2\"> {}\n\nexport const DrawerTitle = withContext<\"h2\", DrawerTitleProps>(\"h2\", \"title\")(\n undefined,\n (props) => {\n const { getTitleProps } = useComponentContext()\n\n return { ...getTitleProps(props) }\n },\n)\n\nexport interface DrawerBodyProps extends HTMLStyledProps {}\n\nexport const DrawerBody = withContext<\"div\", DrawerBodyProps>(\"div\", \"body\")(\n undefined,\n (props) => {\n const { getBodyProps } = useComponentContext()\n\n return { ...getBodyProps(props) }\n },\n)\n\nexport interface DrawerFooterProps extends HTMLStyledProps<\"footer\"> {}\n\nexport const DrawerFooter = withContext<\"footer\", DrawerFooterProps>(\n \"footer\",\n \"footer\",\n)(undefined, (props) => {\n const { getFooterProps } = useComponentContext()\n\n return { ...getFooterProps(props) }\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAiGA,MAAM,EACJ,kBACA,cAAc,oBACd,qBACA,iBAAiB,uBACjB,aACA,iBACEA,yBAAAA,oBACF,UACAC,qBAAAA,WACF;;;;;;AASA,MAAa,aAAa,cACvB,EACC,iBAAiB,OACjB,WACA,qBAAqB,MACrB,MACA,QACA,UACA,aACA,iBACA,aACA,gBACA,YACA,cACA,WA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AAC,CAAC,KAAA,IAAY,UAAU;CACtB,MAAM,EAAE,mBAAmB,oBAAoB;CAE/C,OAAO,EAAE,GAAG,eAAe,KAAK,EAAE;AACpC,CAAC"}
|
|
@@ -14,6 +14,7 @@ exports.DrawerCloseButton = require_drawer.DrawerCloseButton;
|
|
|
14
14
|
exports.DrawerCloseTrigger = require_drawer.DrawerCloseTrigger;
|
|
15
15
|
exports.DrawerContent = require_drawer.DrawerContent;
|
|
16
16
|
exports.DrawerDragBar = require_drawer.DrawerDragBar;
|
|
17
|
+
exports.DrawerDragTrigger = require_drawer.DrawerDragTrigger;
|
|
17
18
|
exports.DrawerFooter = require_drawer.DrawerFooter;
|
|
18
19
|
exports.DrawerHeader = require_drawer.DrawerHeader;
|
|
19
20
|
exports.DrawerOpenTrigger = require_drawer.DrawerOpenTrigger;
|
|
@@ -7,6 +7,7 @@ var namespace_exports = /* @__PURE__ */ require_runtime.__exportAll({
|
|
|
7
7
|
CloseTrigger: () => require_drawer.DrawerCloseTrigger,
|
|
8
8
|
Content: () => require_drawer.DrawerContent,
|
|
9
9
|
DragBar: () => require_drawer.DrawerDragBar,
|
|
10
|
+
DragTrigger: () => require_drawer.DrawerDragTrigger,
|
|
10
11
|
Footer: () => require_drawer.DrawerFooter,
|
|
11
12
|
Header: () => require_drawer.DrawerHeader,
|
|
12
13
|
OpenTrigger: () => require_drawer.DrawerOpenTrigger,
|
|
@@ -22,6 +23,7 @@ exports.CloseButton = require_drawer.DrawerCloseButton;
|
|
|
22
23
|
exports.CloseTrigger = require_drawer.DrawerCloseTrigger;
|
|
23
24
|
exports.Content = require_drawer.DrawerContent;
|
|
24
25
|
exports.DragBar = require_drawer.DrawerDragBar;
|
|
26
|
+
exports.DragTrigger = require_drawer.DrawerDragTrigger;
|
|
25
27
|
exports.Footer = require_drawer.DrawerFooter;
|
|
26
28
|
exports.Header = require_drawer.DrawerHeader;
|
|
27
29
|
exports.OpenTrigger = require_drawer.DrawerOpenTrigger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"namespace.cjs","names":[],"sources":["../../../../src/components/drawer/namespace.ts"],"sourcesContent":["export {\n DrawerBody as Body,\n DrawerCloseButton as CloseButton,\n DrawerCloseTrigger as CloseTrigger,\n DrawerContent as Content,\n DrawerDragBar as DragBar,\n DrawerFooter as Footer,\n DrawerHeader as Header,\n DrawerOpenTrigger as OpenTrigger,\n DrawerOverlay as Overlay,\n DrawerPropsContext as PropsContext,\n DrawerRoot as Root,\n DrawerTitle as Title,\n useDrawerPropsContext as usePropsContext,\n} from \"./drawer\"\nexport type {\n DrawerCloseButtonProps as CloseButtonProps,\n DrawerCloseTriggerProps as CloseTriggerProps,\n DrawerContentProps as ContentProps,\n DrawerDragBarProps as DragBarProps,\n DrawerFooterProps as FooterProps,\n DrawerHeaderProps as HeaderProps,\n DrawerOpenTriggerProps as OpenTriggerProps,\n DrawerOverlayProps as OverlayProps,\n DrawerRootProps as RootProps,\n DrawerTitleProps as TitleProps,\n} from \"./drawer\"\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"namespace.cjs","names":[],"sources":["../../../../src/components/drawer/namespace.ts"],"sourcesContent":["export {\n DrawerBody as Body,\n DrawerCloseButton as CloseButton,\n DrawerCloseTrigger as CloseTrigger,\n DrawerContent as Content,\n DrawerDragBar as DragBar,\n DrawerDragTrigger as DragTrigger,\n DrawerFooter as Footer,\n DrawerHeader as Header,\n DrawerOpenTrigger as OpenTrigger,\n DrawerOverlay as Overlay,\n DrawerPropsContext as PropsContext,\n DrawerRoot as Root,\n DrawerTitle as Title,\n useDrawerPropsContext as usePropsContext,\n} from \"./drawer\"\nexport type {\n DrawerCloseButtonProps as CloseButtonProps,\n DrawerCloseTriggerProps as CloseTriggerProps,\n DrawerContentProps as ContentProps,\n DrawerDragBarProps as DragBarProps,\n DrawerDragTriggerProps as DragTriggerProps,\n DrawerFooterProps as FooterProps,\n DrawerHeaderProps as HeaderProps,\n DrawerOpenTriggerProps as OpenTriggerProps,\n DrawerOverlayProps as OverlayProps,\n DrawerRootProps as RootProps,\n DrawerTitleProps as TitleProps,\n} from \"./drawer\"\n"],"mappings":""}
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
const require_utils_index = require("../../utils/index.cjs");
|
|
3
|
+
const require_environment_provider = require("../../core/system/environment-provider.cjs");
|
|
4
|
+
const require_props = require("../../core/components/props.cjs");
|
|
3
5
|
const require_use_modal = require("../modal/use-modal.cjs");
|
|
4
6
|
let react = require("react");
|
|
7
|
+
let motion_react = require("motion/react");
|
|
5
8
|
//#region src/components/drawer/use-drawer.ts
|
|
6
|
-
const useDrawer = ({ closeOnDrag = false, closeOnEsc, closeOnOverlay, dragConstraints = 0, dragElastic = .1, dragOffset = 80, dragVelocity = 100, placement = "inline-end", onEsc, ...rest } = {}) => {
|
|
7
|
-
const {
|
|
9
|
+
const useDrawer = ({ closeOnDrag = false, closeOnEsc, closeOnOverlay, dragConstraints = 0, dragElastic = .1, dragHandleOnly = false, dragOffset = 80, dragVelocity = 100, placement = "inline-end", onEsc, ...rest } = {}) => {
|
|
10
|
+
const { getWindow } = require_environment_provider.useEnvironment();
|
|
11
|
+
const { open, getContentProps: getModalContentProps, onClose, ...modalProps } = require_use_modal.useModal({
|
|
8
12
|
closeOnEsc,
|
|
9
13
|
closeOnOverlay,
|
|
10
14
|
onEsc,
|
|
11
15
|
...rest
|
|
12
16
|
});
|
|
17
|
+
const dragControls = (0, motion_react.useDragControls)();
|
|
18
|
+
const gesture = (0, react.useRef)(void 0);
|
|
19
|
+
const controller = (0, react.useRef)(void 0);
|
|
20
|
+
const axis = placement.startsWith("block") ? "y" : "x";
|
|
21
|
+
const direction = placement.endsWith("end") ? 1 : -1;
|
|
13
22
|
const drag = (0, react.useMemo)(() => {
|
|
14
23
|
if (!closeOnDrag) return false;
|
|
15
24
|
switch (placement) {
|
|
@@ -19,6 +28,98 @@ const useDrawer = ({ closeOnDrag = false, closeOnEsc, closeOnOverlay, dragConstr
|
|
|
19
28
|
case "inline-end": return "x";
|
|
20
29
|
}
|
|
21
30
|
}, [placement, closeOnDrag]);
|
|
31
|
+
const resetGesture = (0, react.useCallback)(() => {
|
|
32
|
+
controller.current?.abort();
|
|
33
|
+
controller.current = void 0;
|
|
34
|
+
gesture.current = void 0;
|
|
35
|
+
}, []);
|
|
36
|
+
const canScroll = (0, react.useCallback)((path, axis, delta) => {
|
|
37
|
+
const win = getWindow();
|
|
38
|
+
if (!win) return false;
|
|
39
|
+
return path.some((el) => {
|
|
40
|
+
const style = win.getComputedStyle(el);
|
|
41
|
+
const overflow = axis === "x" ? style.overflowX : style.overflowY;
|
|
42
|
+
if (!/auto|scroll|overlay/.test(overflow)) return false;
|
|
43
|
+
const size = axis === "x" ? el.scrollWidth : el.scrollHeight;
|
|
44
|
+
const clientSize = axis === "x" ? el.clientWidth : el.clientHeight;
|
|
45
|
+
const offset = axis === "x" ? el.scrollLeft : el.scrollTop;
|
|
46
|
+
const reversed = axis === "x" ? style.direction === "rtl" : style.flexDirection === "column-reverse";
|
|
47
|
+
const min = reversed ? clientSize - size : 0;
|
|
48
|
+
const max = reversed ? 0 : size - clientSize;
|
|
49
|
+
if (size <= clientSize) return false;
|
|
50
|
+
return delta > 0 ? offset > min + 1 : offset < max - 1;
|
|
51
|
+
});
|
|
52
|
+
}, [getWindow]);
|
|
53
|
+
const updateGesture = (0, react.useCallback)((x, y) => {
|
|
54
|
+
const current = gesture.current;
|
|
55
|
+
if (current?.owner !== "pending") return;
|
|
56
|
+
const dx = x - current.ev.clientX;
|
|
57
|
+
const dy = y - current.ev.clientY;
|
|
58
|
+
const delta = axis === "x" ? dx : dy;
|
|
59
|
+
const crossDelta = axis === "x" ? dy : dx;
|
|
60
|
+
if (Math.max(Math.abs(delta), Math.abs(crossDelta)) < 3) return;
|
|
61
|
+
if (Math.abs(crossDelta) > Math.abs(delta) || delta * direction <= 0 || canScroll(current.path, axis, delta)) current.owner = "scroll";
|
|
62
|
+
else {
|
|
63
|
+
current.owner = "drag";
|
|
64
|
+
dragControls.start(current.ev);
|
|
65
|
+
}
|
|
66
|
+
}, [
|
|
67
|
+
axis,
|
|
68
|
+
canScroll,
|
|
69
|
+
direction,
|
|
70
|
+
dragControls
|
|
71
|
+
]);
|
|
72
|
+
const onPointerDown = (0, react.useCallback)((ev) => {
|
|
73
|
+
if (ev.defaultPrevented) return;
|
|
74
|
+
resetGesture();
|
|
75
|
+
if (!open || !closeOnDrag || dragHandleOnly) return;
|
|
76
|
+
if (ev.button !== 0 || !ev.isPrimary) return;
|
|
77
|
+
if (ev.pointerType === "mouse") dragControls.start(ev);
|
|
78
|
+
else {
|
|
79
|
+
const win = getWindow();
|
|
80
|
+
if (!win) return;
|
|
81
|
+
const targets = ev.nativeEvent.composedPath();
|
|
82
|
+
const path = targets.slice(0, targets.indexOf(ev.currentTarget) + 1).filter(require_utils_index.utils_exports.isHTMLElement);
|
|
83
|
+
gesture.current = {
|
|
84
|
+
ev: ev.nativeEvent,
|
|
85
|
+
owner: "pending",
|
|
86
|
+
path
|
|
87
|
+
};
|
|
88
|
+
controller.current = new AbortController();
|
|
89
|
+
(0, require_utils_index.utils_exports.addDomEvent)(ev.currentTarget, "touchmove", (ev) => {
|
|
90
|
+
if (ev.touches.length !== 1) resetGesture();
|
|
91
|
+
else {
|
|
92
|
+
if (!ev.touches[0]) return;
|
|
93
|
+
updateGesture(ev.touches[0].clientX, ev.touches[0].clientY);
|
|
94
|
+
if (gesture.current?.owner === "drag" && ev.cancelable) ev.preventDefault();
|
|
95
|
+
}
|
|
96
|
+
}, {
|
|
97
|
+
passive: false,
|
|
98
|
+
signal: controller.current.signal
|
|
99
|
+
});
|
|
100
|
+
win.addEventListener("pointerup", resetGesture, {
|
|
101
|
+
signal: controller.current.signal,
|
|
102
|
+
once: true
|
|
103
|
+
});
|
|
104
|
+
win.addEventListener("pointercancel", resetGesture, {
|
|
105
|
+
signal: controller.current.signal,
|
|
106
|
+
once: true
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}, [
|
|
110
|
+
closeOnDrag,
|
|
111
|
+
dragControls,
|
|
112
|
+
dragHandleOnly,
|
|
113
|
+
getWindow,
|
|
114
|
+
open,
|
|
115
|
+
resetGesture,
|
|
116
|
+
updateGesture
|
|
117
|
+
]);
|
|
118
|
+
const onPointerMove = (0, react.useCallback)((ev) => {
|
|
119
|
+
if (ev.defaultPrevented) return;
|
|
120
|
+
if (ev.pointerId !== gesture.current?.ev.pointerId) return;
|
|
121
|
+
updateGesture(ev.clientX, ev.clientY);
|
|
122
|
+
}, [updateGesture]);
|
|
22
123
|
const getDragRestriction = (0, react.useCallback)((value) => {
|
|
23
124
|
switch (placement) {
|
|
24
125
|
case "block-start": return { bottom: value };
|
|
@@ -27,7 +128,9 @@ const useDrawer = ({ closeOnDrag = false, closeOnEsc, closeOnOverlay, dragConstr
|
|
|
27
128
|
case "inline-end": return { left: value };
|
|
28
129
|
}
|
|
29
130
|
}, [placement]);
|
|
30
|
-
const onDragEnd = (0, react.useCallback)((
|
|
131
|
+
const onDragEnd = (0, react.useCallback)((ev, info) => {
|
|
132
|
+
if (ev.defaultPrevented) return;
|
|
133
|
+
if (ev.type === "pointercancel" || ev.type === "touchcancel") return;
|
|
31
134
|
switch (placement) {
|
|
32
135
|
case "block-start":
|
|
33
136
|
if (info.velocity.y <= dragVelocity * -1 || info.offset.y <= dragOffset * -1) onClose();
|
|
@@ -46,28 +149,53 @@ const useDrawer = ({ closeOnDrag = false, closeOnEsc, closeOnOverlay, dragConstr
|
|
|
46
149
|
dragOffset,
|
|
47
150
|
onClose
|
|
48
151
|
]);
|
|
49
|
-
|
|
152
|
+
(0, react.useEffect)(() => {
|
|
153
|
+
resetGesture();
|
|
154
|
+
return resetGesture;
|
|
155
|
+
}, [
|
|
156
|
+
closeOnDrag,
|
|
157
|
+
dragHandleOnly,
|
|
158
|
+
open,
|
|
159
|
+
placement,
|
|
160
|
+
resetGesture
|
|
161
|
+
]);
|
|
162
|
+
const getContentProps = (0, react.useCallback)((props = {}) => require_props.mergeProps({
|
|
50
163
|
drag,
|
|
51
164
|
dragConstraints: getDragRestriction(dragConstraints),
|
|
165
|
+
dragControls,
|
|
52
166
|
dragElastic: getDragRestriction(dragElastic),
|
|
167
|
+
dragListener: false,
|
|
53
168
|
dragMomentum: false,
|
|
54
|
-
dragSnapToOrigin: true
|
|
55
|
-
|
|
56
|
-
onDragEnd
|
|
57
|
-
|
|
169
|
+
dragSnapToOrigin: true
|
|
170
|
+
}, (0, require_utils_index.utils_exports.cast)(getModalContentProps((0, require_utils_index.utils_exports.cast)(props))), {
|
|
171
|
+
onDragEnd,
|
|
172
|
+
onPointerDown,
|
|
173
|
+
onPointerMove
|
|
174
|
+
})(), [
|
|
58
175
|
drag,
|
|
176
|
+
dragControls,
|
|
59
177
|
getDragRestriction,
|
|
60
178
|
dragConstraints,
|
|
61
179
|
dragElastic,
|
|
62
180
|
onDragEnd,
|
|
63
|
-
getModalContentProps
|
|
181
|
+
getModalContentProps,
|
|
182
|
+
onPointerDown,
|
|
183
|
+
onPointerMove
|
|
184
|
+
]);
|
|
185
|
+
const getDragTriggerProps = (0, react.useCallback)((props = {}) => require_props.mergeProps({ style: { touchAction: closeOnDrag && dragHandleOnly ? "none" : void 0 } }, props, { onPointerDown: (ev) => {
|
|
186
|
+
if (closeOnDrag && dragHandleOnly) dragControls.start(ev);
|
|
187
|
+
} })(), [
|
|
188
|
+
closeOnDrag,
|
|
189
|
+
dragHandleOnly,
|
|
190
|
+
dragControls
|
|
64
191
|
]);
|
|
65
|
-
const getDragBarProps = (0, react.useCallback)((props) => ({ ...props }), []);
|
|
66
192
|
return {
|
|
67
193
|
...modalProps,
|
|
68
194
|
closeOnDrag,
|
|
195
|
+
open,
|
|
69
196
|
getContentProps,
|
|
70
|
-
getDragBarProps,
|
|
197
|
+
getDragBarProps: getDragTriggerProps,
|
|
198
|
+
getDragTriggerProps,
|
|
71
199
|
onClose
|
|
72
200
|
};
|
|
73
201
|
};
|