@gunkin/uiify 0.0.9-alpha → 0.0.10-alpha
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/components/behavior.css +4 -0
- package/dist/components/behavior.css.map +1 -1
- package/dist/components/drawer/Drawer.d.ts.map +1 -1
- package/dist/components/drawer/Drawer.js +0 -2
- package/dist/components/drawer/Drawer.js.map +1 -1
- package/dist/components/enhance/dialog-dismiss.d.ts +22 -0
- package/dist/components/enhance/dialog-dismiss.d.ts.map +1 -0
- package/dist/components/enhance/dialog-dismiss.js +49 -0
- package/dist/components/enhance/dialog-dismiss.js.map +1 -0
- package/dist/components/enhance/internal/read-box.d.ts +3 -0
- package/dist/components/enhance/internal/read-box.d.ts.map +1 -0
- package/dist/components/enhance/internal/read-box.js +7 -0
- package/dist/components/enhance/internal/read-box.js.map +1 -0
- package/dist/components/enhance/invoker-fallback.d.ts +0 -7
- package/dist/components/enhance/invoker-fallback.d.ts.map +1 -1
- package/dist/components/enhance/invoker-fallback.js +3 -6
- package/dist/components/enhance/invoker-fallback.js.map +1 -1
- package/dist/components/enhance/listeners.d.ts +2 -0
- package/dist/components/enhance/listeners.d.ts.map +1 -1
- package/dist/components/enhance/listeners.js +6 -0
- package/dist/components/enhance/listeners.js.map +1 -1
- package/dist/components/enhance/sheet-swipe.d.ts +9 -0
- package/dist/components/enhance/sheet-swipe.d.ts.map +1 -0
- package/dist/components/enhance/sheet-swipe.js +112 -0
- package/dist/components/enhance/sheet-swipe.js.map +1 -0
- package/dist/components/modal/Modal.d.ts +5 -4
- package/dist/components/modal/Modal.d.ts.map +1 -1
- package/dist/components/modal/Modal.js +48 -7
- package/dist/components/modal/Modal.js.map +1 -1
- package/dist/components/modal/ModalAnatomy.d.ts +33 -0
- package/dist/components/modal/ModalAnatomy.d.ts.map +1 -0
- package/dist/components/modal/ModalAnatomy.js +34 -0
- package/dist/components/modal/ModalAnatomy.js.map +1 -0
- package/dist/components/modal/ModalParts.d.ts +1 -0
- package/dist/components/modal/ModalParts.d.ts.map +1 -1
- package/dist/components/modal/ModalParts.js +26 -2
- package/dist/components/modal/ModalParts.js.map +1 -1
- package/dist/components/modal/attributes.d.ts +13 -0
- package/dist/components/modal/attributes.d.ts.map +1 -0
- package/dist/components/modal/attributes.js +17 -0
- package/dist/components/modal/attributes.js.map +1 -0
- package/dist/components/modal/client/ModalClientContent.d.ts.map +1 -1
- package/dist/components/modal/client/ModalClientContent.js +36 -14
- package/dist/components/modal/client/ModalClientContent.js.map +1 -1
- package/dist/components/modal/index.d.ts +2 -2
- package/dist/components/modal/index.d.ts.map +1 -1
- package/dist/components/modal/index.js +17 -1
- package/dist/components/modal/index.js.map +1 -1
- package/dist/components/modal/types.d.ts +43 -11
- package/dist/components/modal/types.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +0 -2
- package/dist/hooks/index.js.map +1 -1
- package/dist/styles/index.css +1 -1
- package/package.json +1 -1
- package/dist/hooks/use-lock-body-scroll.d.ts +0 -3
- package/dist/hooks/use-lock-body-scroll.d.ts.map +0 -1
- package/dist/hooks/use-lock-body-scroll.js +0 -15
- package/dist/hooks/use-lock-body-scroll.js.map +0 -1
- package/dist/hooks/utils/scroll-lock.d.ts +0 -5
- package/dist/hooks/utils/scroll-lock.d.ts.map +0 -1
- package/dist/hooks/utils/scroll-lock.js +0 -29
- package/dist/hooks/utils/scroll-lock.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/behavior.css"],"sourcesContent":["/* Behavioral rules for @gunkin/uiify/components — zero visual opinion.\n * Import is required: @import \"@gunkin/uiify/components/behavior.css\";\n * Cascade order: consumer app layer wins without specificity fights. */\n@layer ui.reset, ui.behavior, ui.tokens, ui.theme, app;\n\n@layer ui.behavior {\n [popover]:not(:popover-open) {\n display: none;\n }\n\n /* Native modal dialogs: wheel/touch scrolling inside the dialog must not chain to the page behind it. */\n dialog:modal {\n overscroll-behavior: contain;\n }\n\n /* Closed dialogs stay hidden even when author CSS sets display. */\n dialog:not([open]) {\n display: none;\n }\n\n [data-anchor]:not([data-positioning]) {\n anchor-name: var(--uiify-anchor, attr(data-anchor type(<custom-ident>)));\n }\n\n [data-positioning=\"native\"] {\n position: fixed;\n inset: auto;\n margin: 0;\n position-try-fallbacks: flip-block, flip-inline;\n }\n\n [data-positioning=\"native\"][data-anchor] {\n position-anchor: var(--uiify-anchor, attr(data-anchor type(<custom-ident>)));\n }\n\n [data-positioning=\"native\"][data-side=\"top\"] {\n position-area: top;\n margin-block-end: var(--uiify-anchor-offset, 0);\n }\n\n [data-positioning=\"native\"][data-side=\"right\"] {\n position-area: right;\n margin-inline-start: var(--uiify-anchor-offset, 0);\n }\n\n [data-positioning=\"native\"][data-side=\"bottom\"] {\n position-area: bottom;\n margin-block-start: var(--uiify-anchor-offset, 0);\n }\n\n [data-positioning=\"native\"][data-side=\"left\"] {\n position-area: left;\n margin-inline-end: var(--uiify-anchor-offset, 0);\n }\n\n [data-positioning=\"native\"][data-side=\"top\"][data-align=\"start\"] {\n position-area: top span-right;\n justify-self: start;\n }\n\n [data-positioning=\"native\"][data-side=\"top\"][data-align=\"end\"] {\n position-area: top span-left;\n justify-self: end;\n }\n\n [data-positioning=\"native\"][data-side=\"bottom\"][data-align=\"start\"] {\n position-area: bottom span-right;\n justify-self: start;\n }\n\n [data-positioning=\"native\"][data-side=\"bottom\"][data-align=\"end\"] {\n position-area: bottom span-left;\n justify-self: end;\n }\n\n [data-positioning=\"native\"][data-side=\"right\"][data-align=\"start\"] {\n align-self: start;\n position-area: right span-bottom;\n }\n\n [data-positioning=\"native\"][data-side=\"right\"][data-align=\"end\"] {\n align-self: end;\n position-area: right span-top;\n }\n\n [data-positioning=\"native\"][data-side=\"left\"][data-align=\"start\"] {\n align-self: start;\n position-area: left span-bottom;\n }\n\n [data-positioning=\"native\"][data-side=\"left\"][data-align=\"end\"] {\n align-self: end;\n position-area: left span-top;\n }\n\n /*\n * Local open-state hooks. Top layer does not change DOM ancestry, so a scope\n * that directly contains its surface can read the native state. Consumers\n * style with the selector or with the variable; neither is a second source of truth.\n *\n * Compound roots and their public trigger parts share one component identity plus\n * `data-part`, so native state stays readable without a second scope convention.\n */\n [data-uiify-modal][data-part=\"root\"]:has(> [data-uiify-modal][data-part=\"content\"][open])\n > [data-uiify-modal][data-part=\"trigger\"],\n [data-uiify-alert-modal][data-part=\"root\"]:has(\n > [data-uiify-alert-modal][data-part=\"content\"][open]\n )\n > [data-uiify-alert-modal][data-part=\"trigger\"],\n [data-uiify-popup][data-part=\"root\"]:has(> [data-uiify-popup][data-part=\"content\"]:popover-open)\n > [data-uiify-popup][data-part=\"trigger\"] {\n --uiify-trigger-open: 1;\n }\n\n [data-uiify-accordion] > [data-part=\"item\"][data-disabled] > summary,\n [data-uiify-collapsible][data-disabled] > summary {\n cursor: not-allowed;\n pointer-events: none;\n }\n\n /* Customizable select: opts the control and its picker into the browser's\n base styles so the picker becomes a styleable, top-layer popover with\n implicit anchor positioning. Behavior only — no visual opinion. Engines\n without support ignore this and keep the classic OS picker, which stays\n fully functional. */\n [data-uiify-select],\n [data-uiify-select]::picker(select) {\n appearance: base-select;\n }\n\n [data-uiify-tabs] > [data-part=\"item\"] > [data-part=\"control\"] {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n /* stylelint-disable-next-line property-no-deprecated -- kept for older browser support alongside clip-path */\n clip: rect(0, 0, 0, 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n }\n\n [data-uiify-tabs] > [data-part=\"item\"] > [data-part=\"panel\"] {\n display: none;\n }\n\n [data-uiify-tabs] > [data-part=\"item\"] > [data-part=\"control\"]:checked ~ [data-part=\"panel\"] {\n display: block;\n }\n\n [data-uiify-stepper] > [data-part=\"step\"] > [data-part=\"panel\"] {\n display: none;\n }\n\n [data-uiify-stepper] > [data-part=\"step\"] > [data-part=\"control\"]:checked ~ [data-part=\"panel\"] {\n display: block;\n }\n\n [data-uiify-tabs] [data-part=\"trigger\"][data-disabled] {\n cursor: not-allowed;\n pointer-events: none;\n }\n\n [data-uiify-spinner][data-state=\"delayed\"] {\n animation-name: uiify-spinner-show;\n animation-duration: 0s;\n animation-delay: attr(data-delay type(<time>), 0s);\n animation-fill-mode: forwards;\n visibility: hidden;\n }\n\n @keyframes uiify-spinner-show {\n to {\n visibility: visible;\n }\n }\n\n [data-uiify-breadcrumb] [data-part=\"ellipsis\"] > ol {\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n [data-uiify-carousel] > [data-part=\"viewport\"] {\n display: grid;\n min-inline-size: 0;\n min-block-size: 0;\n gap: var(--uiify-carousel-gap, 0);\n scroll-behavior: auto;\n }\n\n [data-uiify-carousel][data-axis=\"inline\"] > [data-part=\"viewport\"] {\n grid-auto-flow: column;\n grid-auto-columns: var(--uiify-carousel-slide-size, 100%);\n overflow-inline: auto;\n overflow-block: hidden;\n scroll-snap-type: inline mandatory;\n }\n\n [data-uiify-carousel][data-axis=\"block\"] > [data-part=\"viewport\"] {\n grid-auto-flow: row;\n grid-auto-rows: var(--uiify-carousel-slide-size, 100%);\n overflow-block: auto;\n overflow-inline: hidden;\n scroll-snap-type: block mandatory;\n }\n\n [data-uiify-carousel] > [data-part=\"viewport\"] > [data-part=\"slide\"] {\n min-inline-size: 0;\n min-block-size: 0;\n scroll-snap-align: start;\n }\n\n [data-uiify-carousel] > [data-part=\"viewport\"]:focus-visible,\n [data-uiify-carousel] > button[data-part=\"controls\"]:focus-visible,\n [data-uiify-carousel] > [data-part=\"dots\"] > a:focus-visible {\n outline: auto;\n }\n\n @media (prefers-reduced-motion: no-preference) {\n [data-uiify-carousel] > [data-part=\"viewport\"] {\n scroll-behavior: smooth;\n }\n }\n\n [data-uiify-carousel] > [data-part=\"viewport\"][data-dragging] {\n scroll-behavior: auto;\n scroll-snap-type: none;\n }\n\n [data-uiify-carousel][data-mode=\"fade\"][data-enhanced] > [data-part=\"viewport\"] {\n grid-auto-flow: row;\n grid-template-columns: 100%;\n grid-auto-columns: auto;\n overflow: hidden;\n scroll-snap-type: none;\n touch-action: pan-y pinch-zoom;\n }\n\n [data-uiify-carousel][data-mode=\"fade\"][data-enhanced]\n > [data-part=\"viewport\"]\n > [data-part=\"slide\"] {\n grid-area: 1 / 1;\n opacity: 0;\n pointer-events: none;\n }\n\n [data-uiify-carousel][data-mode=\"fade\"][data-enhanced]\n > [data-part=\"viewport\"]\n > [data-part=\"slide\"][data-state=\"active\"] {\n opacity: 1;\n pointer-events: auto;\n }\n\n @media (prefers-reduced-motion: no-preference) {\n [data-uiify-carousel][data-mode=\"fade\"][data-enhanced]\n > [data-part=\"viewport\"]\n > [data-part=\"slide\"] {\n transition: opacity var(--uiify-carousel-fade-duration, 300ms) ease;\n }\n }\n\n [data-uiify-virtual-scroll] {\n --uiify-virtual-scroll-row-height: 64px;\n\n overflow-y: auto;\n }\n\n [data-uiify-virtual-scroll] > [data-part=\"spacer\"] {\n position: relative;\n block-size: var(\n --uiify-virtual-scroll-total-size,\n calc(var(--uiify-virtual-scroll-count, 0) * var(--uiify-virtual-scroll-row-height))\n );\n }\n\n [data-uiify-virtual-scroll] [data-part=\"row\"] {\n --uiify-row-position: var(\n --uiify-row-offset,\n calc(\n (var(--uiify-range-start, 0) + var(--uiify-slot-index, 0)) *\n var(--uiify-virtual-scroll-row-height)\n )\n );\n\n position: absolute;\n inset-inline: 0;\n block-size: var(--uiify-row-height, var(--uiify-virtual-scroll-row-height));\n translate: 0 var(--uiify-row-position);\n }\n\n /* Horizontal: the row size runs along the inline axis. Rows sit at a logical\n inline offset so RTL needs no direction selector; child combinators keep a\n vertical list nested inside a horizontal row on the vertical rules. */\n [data-uiify-virtual-scroll][data-orientation=\"horizontal\"] {\n overflow: auto hidden;\n }\n\n [data-uiify-virtual-scroll][data-orientation=\"horizontal\"] > [data-part=\"spacer\"] {\n block-size: 100%;\n inline-size: var(\n --uiify-virtual-scroll-total-size,\n calc(var(--uiify-virtual-scroll-count, 0) * var(--uiify-virtual-scroll-row-height))\n );\n }\n\n [data-uiify-virtual-scroll][data-orientation=\"horizontal\"]\n > [data-part=\"spacer\"]\n > [data-part=\"row\"] {\n inset-block: 0;\n inset-inline: var(--uiify-row-position) auto;\n block-size: auto;\n inline-size: var(--uiify-row-height, var(--uiify-virtual-scroll-row-height));\n translate: none;\n }\n\n /*\n * Toast list changes commit as React view transitions typed \"uiify-toast\".\n * Only the toast cards are captured: the page root is not snapshotted and\n * stays clickable while they move.\n */\n :root:active-view-transition-type(uiify-toast) {\n view-transition-name: none;\n }\n\n :root:active-view-transition-type(uiify-toast)::view-transition {\n pointer-events: none;\n }\n\n @media (prefers-reduced-motion: reduce) {\n ::view-transition-group(.uiify-toast),\n ::view-transition-old(.uiify-toast),\n ::view-transition-new(.uiify-toast) {\n animation: none;\n }\n }\n}\n"],"mappings":"AAGA;AAEA;AACE,GAAC,QAAQ,KAAK;AACZ,aAAS;AACX;AAGA,QAAM;AACJ,yBAAqB;AACvB;AAGA,QAAM,KAAK,CAAC;AACV,aAAS;AACX;AAEA,GAAC,YAAY,KAAK,CAAC;AACjB,iBAAa,IAAI,cAAc,EAAE,KAAK,YAAY,KAAK,CAAC,YAAY;AACtE;AAEA,GAAC;AACC,cAAU;AACV,WAAO;AACP,YAAQ;AACR,4BAAwB,UAAU,EAAE;AACtC;AAEA,GAAC,wBAA0B,CAAC;AAC1B,qBAAiB,IAAI,cAAc,EAAE,KAAK,YAAY,KAAK,CAAC,YAAY;AAC1E;AAEA,GAAC,wBAA0B,CAAC;AAC1B,mBAAe;AACf,sBAAkB,IAAI,qBAAqB,EAAE;AAC/C;AAEA,GAAC,wBAA0B,CAAC;AAC1B,mBAAe;AACf,yBAAqB,IAAI,qBAAqB,EAAE;AAClD;AAEA,GAAC,wBAA0B,CAAC;AAC1B,mBAAe;AACf,wBAAoB,IAAI,qBAAqB,EAAE;AACjD;AAEA,GAAC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AACV,gBAAY,KACV,iCAAiC,EACjC,KAAK,IAAI,4BAA4B,EAAE,GAAG,EAAE,IAAI;AAEpD;AAEA,GAAC,2BAA2B,CAAC;AAC3B,0BAAsB,KACpB,kBAAkB,EAClB,MACE,CAAC,IAAI,mBAAmB,EAAE,GAAG,EAAE,IAAI,kBAAkB,EAAE,IAAI,EACzD,IAAI;AAIV,cAAU;AACV,kBAAc;AACd,gBAAY,IAAI,kBAAkB,EAAE,IAAI;AACxC,eAAW,EAAE,IAAI;AACnB;AAKA,GAAC,0BAA0B,CAAC;AAC1B,cAAU,KAAK;AACjB;AAEA,GAAC,0BAA0B,CAAC,6BAA+B,EAAE,CAAC;AAC5D,gBAAY;AACZ,iBAAa,KACX,iCAAiC,EACjC,KAAK,IAAI,4BAA4B,EAAE,GAAG,EAAE,IAAI;AAEpD;AAEA,GAAC,0BAA0B,CAAC,6BAC1B,EAAE,CAAC,kBACH,EAAE,CAAC;AACH,iBAAa;AACb,kBAAc,IAAI,sBAAsB;AACxC,gBAAY;AACZ,iBAAa,IAAI,kBAAkB,EAAE,IAAI;AACzC,eAAW;AACb;AAOA,OAAK,6BAA6B;AAChC,0BAAsB;AACxB;AAEA,OAAK,6BAA6B,YAAY;AAC5C,oBAAgB;AAClB;AAEA,UAAO,wBAAyB;AAC9B,4BAAwB,CAAC;AAAA,IACzB,sBAAsB,CAAC;AAAA,IACvB,sBAAsB,CAAC;AACrB,iBAAW;AACb;AACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/components/behavior.css"],"sourcesContent":["/* Behavioral rules for @gunkin/uiify/components — zero visual opinion.\n * Import is required: @import \"@gunkin/uiify/components/behavior.css\";\n * Cascade order: consumer app layer wins without specificity fights. */\n@layer ui.reset, ui.behavior, ui.tokens, ui.theme, app;\n\n@layer ui.behavior {\n [popover]:not(:popover-open) {\n display: none;\n }\n\n /* Native modal dialogs: wheel/touch scrolling inside the dialog must not chain to the page behind it. */\n dialog:modal {\n overscroll-behavior: contain;\n }\n\n /* Open modal dialogs lock the page scroll, iOS Safari included (checked on iOS 27: a swipe on\n the backdrop or the dialog leaves scrollY unchanged). The stable gutter keeps a classic\n scrollbar's width, so the page does not shift when the dialog opens. */\n :root:has(dialog:modal) {\n overflow: hidden;\n scrollbar-gutter: stable;\n }\n\n /* Closed dialogs stay hidden even when author CSS sets display. */\n dialog:not([open]) {\n display: none;\n }\n\n [data-anchor]:not([data-positioning]) {\n anchor-name: var(--uiify-anchor, attr(data-anchor type(<custom-ident>)));\n }\n\n [data-positioning=\"native\"] {\n position: fixed;\n inset: auto;\n margin: 0;\n position-try-fallbacks: flip-block, flip-inline;\n }\n\n [data-positioning=\"native\"][data-anchor] {\n position-anchor: var(--uiify-anchor, attr(data-anchor type(<custom-ident>)));\n }\n\n [data-positioning=\"native\"][data-side=\"top\"] {\n position-area: top;\n margin-block-end: var(--uiify-anchor-offset, 0);\n }\n\n [data-positioning=\"native\"][data-side=\"right\"] {\n position-area: right;\n margin-inline-start: var(--uiify-anchor-offset, 0);\n }\n\n [data-positioning=\"native\"][data-side=\"bottom\"] {\n position-area: bottom;\n margin-block-start: var(--uiify-anchor-offset, 0);\n }\n\n [data-positioning=\"native\"][data-side=\"left\"] {\n position-area: left;\n margin-inline-end: var(--uiify-anchor-offset, 0);\n }\n\n [data-positioning=\"native\"][data-side=\"top\"][data-align=\"start\"] {\n position-area: top span-right;\n justify-self: start;\n }\n\n [data-positioning=\"native\"][data-side=\"top\"][data-align=\"end\"] {\n position-area: top span-left;\n justify-self: end;\n }\n\n [data-positioning=\"native\"][data-side=\"bottom\"][data-align=\"start\"] {\n position-area: bottom span-right;\n justify-self: start;\n }\n\n [data-positioning=\"native\"][data-side=\"bottom\"][data-align=\"end\"] {\n position-area: bottom span-left;\n justify-self: end;\n }\n\n [data-positioning=\"native\"][data-side=\"right\"][data-align=\"start\"] {\n align-self: start;\n position-area: right span-bottom;\n }\n\n [data-positioning=\"native\"][data-side=\"right\"][data-align=\"end\"] {\n align-self: end;\n position-area: right span-top;\n }\n\n [data-positioning=\"native\"][data-side=\"left\"][data-align=\"start\"] {\n align-self: start;\n position-area: left span-bottom;\n }\n\n [data-positioning=\"native\"][data-side=\"left\"][data-align=\"end\"] {\n align-self: end;\n position-area: left span-top;\n }\n\n /*\n * Local open-state hooks. Top layer does not change DOM ancestry, so a scope\n * that directly contains its surface can read the native state. Consumers\n * style with the selector or with the variable; neither is a second source of truth.\n *\n * Compound roots and their public trigger parts share one component identity plus\n * `data-part`, so native state stays readable without a second scope convention.\n */\n [data-uiify-modal][data-part=\"root\"]:has(> [data-uiify-modal][data-part=\"content\"][open])\n > [data-uiify-modal][data-part=\"trigger\"],\n [data-uiify-alert-modal][data-part=\"root\"]:has(\n > [data-uiify-alert-modal][data-part=\"content\"][open]\n )\n > [data-uiify-alert-modal][data-part=\"trigger\"],\n [data-uiify-popup][data-part=\"root\"]:has(> [data-uiify-popup][data-part=\"content\"]:popover-open)\n > [data-uiify-popup][data-part=\"trigger\"] {\n --uiify-trigger-open: 1;\n }\n\n [data-uiify-accordion] > [data-part=\"item\"][data-disabled] > summary,\n [data-uiify-collapsible][data-disabled] > summary {\n cursor: not-allowed;\n pointer-events: none;\n }\n\n /* Customizable select: opts the control and its picker into the browser's\n base styles so the picker becomes a styleable, top-layer popover with\n implicit anchor positioning. Behavior only — no visual opinion. Engines\n without support ignore this and keep the classic OS picker, which stays\n fully functional. */\n [data-uiify-select],\n [data-uiify-select]::picker(select) {\n appearance: base-select;\n }\n\n [data-uiify-tabs] > [data-part=\"item\"] > [data-part=\"control\"] {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n /* stylelint-disable-next-line property-no-deprecated -- kept for older browser support alongside clip-path */\n clip: rect(0, 0, 0, 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n }\n\n [data-uiify-tabs] > [data-part=\"item\"] > [data-part=\"panel\"] {\n display: none;\n }\n\n [data-uiify-tabs] > [data-part=\"item\"] > [data-part=\"control\"]:checked ~ [data-part=\"panel\"] {\n display: block;\n }\n\n [data-uiify-stepper] > [data-part=\"step\"] > [data-part=\"panel\"] {\n display: none;\n }\n\n [data-uiify-stepper] > [data-part=\"step\"] > [data-part=\"control\"]:checked ~ [data-part=\"panel\"] {\n display: block;\n }\n\n [data-uiify-tabs] [data-part=\"trigger\"][data-disabled] {\n cursor: not-allowed;\n pointer-events: none;\n }\n\n [data-uiify-spinner][data-state=\"delayed\"] {\n animation-name: uiify-spinner-show;\n animation-duration: 0s;\n animation-delay: attr(data-delay type(<time>), 0s);\n animation-fill-mode: forwards;\n visibility: hidden;\n }\n\n @keyframes uiify-spinner-show {\n to {\n visibility: visible;\n }\n }\n\n [data-uiify-breadcrumb] [data-part=\"ellipsis\"] > ol {\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n [data-uiify-carousel] > [data-part=\"viewport\"] {\n display: grid;\n min-inline-size: 0;\n min-block-size: 0;\n gap: var(--uiify-carousel-gap, 0);\n scroll-behavior: auto;\n }\n\n [data-uiify-carousel][data-axis=\"inline\"] > [data-part=\"viewport\"] {\n grid-auto-flow: column;\n grid-auto-columns: var(--uiify-carousel-slide-size, 100%);\n overflow-inline: auto;\n overflow-block: hidden;\n scroll-snap-type: inline mandatory;\n }\n\n [data-uiify-carousel][data-axis=\"block\"] > [data-part=\"viewport\"] {\n grid-auto-flow: row;\n grid-auto-rows: var(--uiify-carousel-slide-size, 100%);\n overflow-block: auto;\n overflow-inline: hidden;\n scroll-snap-type: block mandatory;\n }\n\n [data-uiify-carousel] > [data-part=\"viewport\"] > [data-part=\"slide\"] {\n min-inline-size: 0;\n min-block-size: 0;\n scroll-snap-align: start;\n }\n\n [data-uiify-carousel] > [data-part=\"viewport\"]:focus-visible,\n [data-uiify-carousel] > button[data-part=\"controls\"]:focus-visible,\n [data-uiify-carousel] > [data-part=\"dots\"] > a:focus-visible {\n outline: auto;\n }\n\n @media (prefers-reduced-motion: no-preference) {\n [data-uiify-carousel] > [data-part=\"viewport\"] {\n scroll-behavior: smooth;\n }\n }\n\n [data-uiify-carousel] > [data-part=\"viewport\"][data-dragging] {\n scroll-behavior: auto;\n scroll-snap-type: none;\n }\n\n [data-uiify-carousel][data-mode=\"fade\"][data-enhanced] > [data-part=\"viewport\"] {\n grid-auto-flow: row;\n grid-template-columns: 100%;\n grid-auto-columns: auto;\n overflow: hidden;\n scroll-snap-type: none;\n touch-action: pan-y pinch-zoom;\n }\n\n [data-uiify-carousel][data-mode=\"fade\"][data-enhanced]\n > [data-part=\"viewport\"]\n > [data-part=\"slide\"] {\n grid-area: 1 / 1;\n opacity: 0;\n pointer-events: none;\n }\n\n [data-uiify-carousel][data-mode=\"fade\"][data-enhanced]\n > [data-part=\"viewport\"]\n > [data-part=\"slide\"][data-state=\"active\"] {\n opacity: 1;\n pointer-events: auto;\n }\n\n @media (prefers-reduced-motion: no-preference) {\n [data-uiify-carousel][data-mode=\"fade\"][data-enhanced]\n > [data-part=\"viewport\"]\n > [data-part=\"slide\"] {\n transition: opacity var(--uiify-carousel-fade-duration, 300ms) ease;\n }\n }\n\n [data-uiify-virtual-scroll] {\n --uiify-virtual-scroll-row-height: 64px;\n\n overflow-y: auto;\n }\n\n [data-uiify-virtual-scroll] > [data-part=\"spacer\"] {\n position: relative;\n block-size: var(\n --uiify-virtual-scroll-total-size,\n calc(var(--uiify-virtual-scroll-count, 0) * var(--uiify-virtual-scroll-row-height))\n );\n }\n\n [data-uiify-virtual-scroll] [data-part=\"row\"] {\n --uiify-row-position: var(\n --uiify-row-offset,\n calc(\n (var(--uiify-range-start, 0) + var(--uiify-slot-index, 0)) *\n var(--uiify-virtual-scroll-row-height)\n )\n );\n\n position: absolute;\n inset-inline: 0;\n block-size: var(--uiify-row-height, var(--uiify-virtual-scroll-row-height));\n translate: 0 var(--uiify-row-position);\n }\n\n /* Horizontal: the row size runs along the inline axis. Rows sit at a logical\n inline offset so RTL needs no direction selector; child combinators keep a\n vertical list nested inside a horizontal row on the vertical rules. */\n [data-uiify-virtual-scroll][data-orientation=\"horizontal\"] {\n overflow: auto hidden;\n }\n\n [data-uiify-virtual-scroll][data-orientation=\"horizontal\"] > [data-part=\"spacer\"] {\n block-size: 100%;\n inline-size: var(\n --uiify-virtual-scroll-total-size,\n calc(var(--uiify-virtual-scroll-count, 0) * var(--uiify-virtual-scroll-row-height))\n );\n }\n\n [data-uiify-virtual-scroll][data-orientation=\"horizontal\"]\n > [data-part=\"spacer\"]\n > [data-part=\"row\"] {\n inset-block: 0;\n inset-inline: var(--uiify-row-position) auto;\n block-size: auto;\n inline-size: var(--uiify-row-height, var(--uiify-virtual-scroll-row-height));\n translate: none;\n }\n\n /*\n * Toast list changes commit as React view transitions typed \"uiify-toast\".\n * Only the toast cards are captured: the page root is not snapshotted and\n * stays clickable while they move.\n */\n :root:active-view-transition-type(uiify-toast) {\n view-transition-name: none;\n }\n\n :root:active-view-transition-type(uiify-toast)::view-transition {\n pointer-events: none;\n }\n\n @media (prefers-reduced-motion: reduce) {\n ::view-transition-group(.uiify-toast),\n ::view-transition-old(.uiify-toast),\n ::view-transition-new(.uiify-toast) {\n animation: none;\n }\n }\n}\n"],"mappings":"AAGA;AAEA;AACE,GAAC,QAAQ,KAAK;AACZ,aAAS;AACX;AAGA,QAAM;AACJ,yBAAqB;AACvB;AAKA,OAAK,KAAK,MAAM;AACd,cAAU;AACV,sBAAkB;AACpB;AAGA,QAAM,KAAK,CAAC;AACV,aAAS;AACX;AAEA,GAAC,YAAY,KAAK,CAAC;AACjB,iBAAa,IAAI,cAAc,EAAE,KAAK,YAAY,KAAK,CAAC,YAAY;AACtE;AAEA,GAAC;AACC,cAAU;AACV,WAAO;AACP,YAAQ;AACR,4BAAwB,UAAU,EAAE;AACtC;AAEA,GAAC,wBAA0B,CAAC;AAC1B,qBAAiB,IAAI,cAAc,EAAE,KAAK,YAAY,KAAK,CAAC,YAAY;AAC1E;AAEA,GAAC,wBAA0B,CAAC;AAC1B,mBAAe;AACf,sBAAkB,IAAI,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AiB,CAAC,eACtC,EAAE,CAAC,oBACH,EAAE,CAAC;AACH,kBAAY,QAAQ,IAAI,8BAA8B,EAAE,OAAO;AACjE;AACF;AAEA,GAAC;AACC,uCAAmC;AAEnC,gBAAY;AACd;AAEA,GAAC,2BAA2B,EAAE,CAAC;AAC7B,cAAU;AACV,gBAAY,KACV,iCAAiC,EACjC,KAAK,IAAI,4BAA4B,EAAE,GAAG,EAAE,IAAI;AAEpD;AAEA,GAAC,2BAA2B,CAAC;AAC3B,0BAAsB,KACpB,kBAAkB,EAClB,MACE,CAAC,IAAI,mBAAmB,EAAE,GAAG,EAAE,IAAI,kBAAkB,EAAE,IAAI,EACzD,IAAI;AAIV,cAAU;AACV,kBAAc;AACd,gBAAY,IAAI,kBAAkB,EAAE,IAAI;AACxC,eAAW,EAAE,IAAI;AACnB;AAKA,GAAC,0BAA0B,CAAC;AAC1B,cAAU,KAAK;AACjB;AAEA,GAAC,0BAA0B,CAAC,6BAA+B,EAAE,CAAC;AAC5D,gBAAY;AACZ,iBAAa,KACX,iCAAiC,EACjC,KAAK,IAAI,4BAA4B,EAAE,GAAG,EAAE,IAAI;AAEpD;AAEA,GAAC,0BAA0B,CAAC,6BAC1B,EAAE,CAAC,kBACH,EAAE,CAAC;AACH,iBAAa;AACb,kBAAc,IAAI,sBAAsB;AACxC,gBAAY;AACZ,iBAAa,IAAI,kBAAkB,EAAE,IAAI;AACzC,eAAW;AACb;AAOA,OAAK,6BAA6B;AAChC,0BAAsB;AACxB;AAEA,OAAK,6BAA6B,YAAY;AAC5C,oBAAgB;AAClB;AAEA,UAAO,wBAAyB;AAC9B,4BAAwB,CAAC;AAAA,IACzB,sBAAsB,CAAC;AAAA,IACvB,sBAAsB,CAAC;AACrB,iBAAW;AACb;AACF;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../src/components/drawer/Drawer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,YAAY,EAAkB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Drawer.d.ts","sourceRoot":"","sources":["../../../src/components/drawer/Drawer.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,YAAY,EAAkB,MAAM,OAAO,CAAC;AAYxE,OAAO,KAAK,EAGV,eAAe,EACf,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,EAChB,oBAAoB,EACrB,MAAM,mBAAmB,CAAC;AAI3B,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,GAAG,YAAY,GAAG,IAAI,CAuFtE;yBAvFe,UAAU;;;AA0F1B,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,GAAG,IAAI,CAuB5E;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,YAAY,GAAG,IAAI,CA4E5E;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,mBAAmB,GAAG,YAAY,GAAG,IAAI,CAqB3E;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,yBAAyB,GAAG,YAAY,GAAG,IAAI,CAqBvF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,YAAY,GAAG,IAAI,CAqBxE;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,oBAAoB,GAAG,YAAY,GAAG,IAAI,CAsD7E;AAED,eAAO,MAAM,MAAM;;;;;;;;CAQlB,CAAC"}
|
|
@@ -4,7 +4,6 @@ import { useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
|
4
4
|
import {
|
|
5
5
|
useId,
|
|
6
6
|
useIsomorphicLayoutEffect,
|
|
7
|
-
useLockBodyScroll,
|
|
8
7
|
useMergedRefs,
|
|
9
8
|
useResizeObserver
|
|
10
9
|
} from "@gunkin/uiify/hooks";
|
|
@@ -50,7 +49,6 @@ function DrawerRoot(props) {
|
|
|
50
49
|
...onSnapChange ? { onSnapChange } : {}
|
|
51
50
|
});
|
|
52
51
|
const store = storeRef.current;
|
|
53
|
-
useLockBodyScroll(modal && dialog.open);
|
|
54
52
|
useIsomorphicLayoutEffect(() => {
|
|
55
53
|
if (activeSnapPoint !== void 0) store.syncActiveSnapPoint(activeSnapPoint);
|
|
56
54
|
}, [activeSnapPoint, store]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/drawer/Drawer.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMemo, useRef, useState, useSyncExternalStore } from \"react\";\nimport type { PointerEvent, ReactElement, SyntheticEvent } from \"react\";\nimport {\n useId,\n useIsomorphicLayoutEffect,\n useLockBodyScroll,\n useMergedRefs,\n useResizeObserver,\n} from \"@gunkin/uiify/hooks\";\nimport { createPartContext } from \"@gunkin/uiify/core\";\nimport { composeEventHandlers } from \"@gunkin/uiify/core/compose-event-handlers\";\nimport { useRenderElement } from \"@gunkin/uiify/core/render\";\nimport { useDialog } from \"@gunkin/uiify/core/dialog\";\nimport { createDrawerStore } from \"./drawer-store.js\";\nimport type {\n DrawerStore,\n DrawerContextValue,\n DrawerRootProps,\n DrawerTriggerProps,\n DrawerContentProps,\n DrawerTitleOwnProps,\n DrawerDescriptionOwnProps,\n DrawerCloseProps,\n DrawerHandleOwnProps,\n} from \"./client-types.js\";\n\nconst [DrawerProvider, useDrawerContext] = createPartContext<DrawerContextValue>(\"Drawer\");\n\nexport function DrawerRoot(props: DrawerRootProps): ReactElement | null {\n const {\n activeSnapPoint,\n children,\n defaultActiveSnapPoint,\n defaultOpen,\n dismissible = true,\n modal = true,\n onOpenChange,\n onSnapChange,\n open,\n side = \"bottom\",\n snapPoints,\n } = props;\n const contentId = useId();\n const dialog = useDialog({\n modal,\n ...(defaultOpen !== undefined ? { defaultOpen } : {}),\n ...(open !== undefined ? { open } : {}),\n ...(onOpenChange ? { onOpenChange } : {}),\n });\n const [labelId, setLabelId] = useState<string | undefined>();\n const [descriptionId, setDescriptionId] = useState<string | undefined>();\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const wasOpenRef = useRef(dialog.open);\n const storeRef = useRef<DrawerStore | null>(null);\n storeRef.current ??= createDrawerStore({\n side,\n dismissible,\n onDismiss: () => dialog.close(),\n ...(snapPoints ? { snapPoints } : {}),\n ...(activeSnapPoint !== undefined ? { activeSnapPoint } : {}),\n ...(defaultActiveSnapPoint !== undefined ? { defaultActiveSnapPoint } : {}),\n ...(onSnapChange ? { onSnapChange } : {}),\n });\n const store = storeRef.current;\n\n useLockBodyScroll(modal && dialog.open);\n\n useIsomorphicLayoutEffect(() => {\n if (activeSnapPoint !== undefined) store.syncActiveSnapPoint(activeSnapPoint);\n }, [activeSnapPoint, store]);\n\n useIsomorphicLayoutEffect(() => {\n if (wasOpenRef.current && !dialog.open) {\n queueMicrotask(() => triggerRef.current?.focus({ preventScroll: true }));\n }\n wasOpenRef.current = dialog.open;\n }, [dialog.open]);\n\n const snapEnabled = Boolean(snapPoints && snapPoints.length > 0);\n\n const contextValue = useMemo<DrawerContextValue>(\n () => ({\n close: dialog.close,\n contentId,\n descriptionId,\n dialogProps: dialog.dialogProps,\n dialogRef: dialog.dialogRef,\n dismissible,\n labelId,\n modal,\n open: dialog.open,\n openDialog: dialog.openDialog,\n setDescriptionId,\n setLabelId,\n side,\n snapEnabled,\n store,\n triggerRef,\n }),\n [\n contentId,\n descriptionId,\n dialog.close,\n dialog.dialogProps,\n dialog.dialogRef,\n dialog.open,\n dialog.openDialog,\n dismissible,\n labelId,\n modal,\n side,\n snapEnabled,\n store,\n ],\n );\n\n return <DrawerProvider value={contextValue}>{children}</DrawerProvider>;\n}\nDrawerRoot.displayName = \"DrawerRoot\";\n\nexport function DrawerTrigger(props: DrawerTriggerProps): ReactElement | null {\n const { children, className, ref, ...consumerProps } = props;\n const { contentId, open, openDialog, triggerRef } = useDrawerContext(\"Trigger\");\n const mergedRef = useMergedRefs(triggerRef, ref);\n\n return useRenderElement({\n defaultTag: \"button\",\n props: {\n ...consumerProps,\n ref: mergedRef,\n type: \"button\",\n \"data-uiify-button\": \"\",\n \"data-part\": \"trigger\",\n \"data-uiify-drawer\": \"\",\n \"aria-controls\": contentId,\n \"aria-expanded\": open,\n \"aria-haspopup\": \"dialog\",\n onClick: composeEventHandlers(consumerProps.onClick, openDialog),\n ...(className ? { className } : {}),\n children,\n },\n state: {},\n });\n}\n\nexport function DrawerContent(props: DrawerContentProps): ReactElement | null {\n const { children, className, ref, style: consumerStyle, ...consumerProps } = props;\n const {\n contentId,\n descriptionId,\n dialogProps,\n dialogRef,\n labelId,\n modal,\n open,\n side,\n snapEnabled,\n store,\n } = useDrawerContext(\"Content\");\n const containerRef = useRef<HTMLDialogElement | null>(null);\n const mergedRef = useMergedRefs(dialogRef, containerRef, ref);\n const size = useResizeObserver(containerRef);\n const transform = useSyncExternalStore(\n (listener) => store.subscribe(listener),\n () => store.getTransform(),\n () => \"\",\n );\n const activeSnap = useSyncExternalStore(\n (listener) => store.subscribe(listener),\n () => store.getActiveSnapPoint(),\n () => 1,\n );\n\n useIsomorphicLayoutEffect(() => {\n if (!size) return;\n const vertical = side === \"top\" || side === \"bottom\";\n store.setContainerSize(vertical ? size.height : size.width);\n }, [side, size, store]);\n\n const styleVars =\n snapEnabled && transform\n ? ({\n \"--uiify-drawer-transform\": transform,\n \"--uiify-drawer-snap\": String(activeSnap),\n } as React.CSSProperties)\n : undefined;\n\n const content = useRenderElement({\n defaultTag: \"dialog\",\n props: {\n ...consumerProps,\n ref: mergedRef,\n id: contentId,\n \"aria-describedby\": descriptionId,\n \"aria-labelledby\": labelId,\n \"aria-modal\": modal ? true : undefined,\n \"data-part\": \"content\",\n \"data-side\": side,\n \"data-state\": open ? \"open\" : \"closed\",\n \"data-uiify-drawer\": \"\",\n \"data-snap-enabled\": snapEnabled ? \"\" : undefined,\n ...(className ? { className } : {}),\n ...(consumerStyle || styleVars ? { style: { ...consumerStyle, ...styleVars } } : {}),\n onCancel: composeEventHandlers(\n consumerProps.onCancel,\n (event: SyntheticEvent<HTMLDialogElement>) => {\n dialogProps.onCancel?.(event);\n },\n ),\n onClose: composeEventHandlers(\n consumerProps.onClose,\n (event: SyntheticEvent<HTMLDialogElement>) => {\n dialogProps.onClose?.(event);\n },\n ),\n children,\n },\n state: { open, side },\n });\n\n return content;\n}\n\nexport function DrawerTitle(props: DrawerTitleOwnProps): ReactElement | null {\n const { children, className } = props;\n const id = useId();\n const { setLabelId } = useDrawerContext(\"Title\");\n\n useIsomorphicLayoutEffect(() => {\n setLabelId(id);\n return () => setLabelId(undefined);\n }, [id, setLabelId]);\n\n return useRenderElement({\n defaultTag: \"h2\",\n props: {\n id,\n \"data-part\": \"title\",\n \"data-uiify-drawer\": \"\",\n ...(className ? { className } : {}),\n children,\n },\n state: {},\n });\n}\n\nexport function DrawerDescription(props: DrawerDescriptionOwnProps): ReactElement | null {\n const { children, className } = props;\n const id = useId();\n const { setDescriptionId } = useDrawerContext(\"Description\");\n\n useIsomorphicLayoutEffect(() => {\n setDescriptionId(id);\n return () => setDescriptionId(undefined);\n }, [id, setDescriptionId]);\n\n return useRenderElement({\n defaultTag: \"p\",\n props: {\n id,\n \"data-part\": \"description\",\n \"data-uiify-drawer\": \"\",\n ...(className ? { className } : {}),\n children,\n },\n state: {},\n });\n}\n\nexport function DrawerClose(props: DrawerCloseProps): ReactElement | null {\n const { children, className, ...consumerProps } = props;\n const { close } = useDrawerContext(\"Close\");\n\n return useRenderElement({\n defaultTag: \"button\",\n props: {\n ...consumerProps,\n type: \"button\",\n \"data-uiify-button\": \"\",\n \"data-part\": \"close\",\n \"data-uiify-drawer\": \"\",\n \"data-variant\": \"ghost\",\n onClick: composeEventHandlers(consumerProps.onClick, () => {\n close();\n }),\n ...(className ? { className } : {}),\n children,\n },\n state: {},\n });\n}\n\nexport function DrawerHandle(props: DrawerHandleOwnProps): ReactElement | null {\n const { className, onPointerCancel, onPointerDown, onPointerMove, onPointerUp } = props;\n const { side, snapEnabled, store } = useDrawerContext(\"Handle\");\n const dragging = useSyncExternalStore(\n (listener) => store.subscribe(listener),\n () => store.isDragging(),\n () => false,\n );\n\n const axis = side === \"top\" || side === \"bottom\" ? \"clientY\" : \"clientX\";\n\n return useRenderElement({\n defaultTag: \"div\",\n props: snapEnabled\n ? {\n \"aria-hidden\": true,\n \"data-part\": \"handle\",\n \"data-uiify-drawer\": \"\",\n \"data-dragging\": dragging ? \"\" : undefined,\n \"data-side\": side,\n ...(className ? { className } : {}),\n onPointerDown: composeEventHandlers(\n onPointerDown,\n (event: PointerEvent<HTMLDivElement>) => {\n event.currentTarget.setPointerCapture(event.pointerId);\n store.startDrag(event[axis]);\n },\n ),\n onPointerMove: composeEventHandlers(\n onPointerMove,\n (event: PointerEvent<HTMLDivElement>) => {\n if (!store.isDragging()) return;\n store.moveDrag(event[axis]);\n },\n ),\n onPointerUp: composeEventHandlers(onPointerUp, (event: PointerEvent<HTMLDivElement>) => {\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n store.endDrag();\n }),\n onPointerCancel: composeEventHandlers(\n onPointerCancel,\n (event: PointerEvent<HTMLDivElement>) => {\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n store.endDrag();\n },\n ),\n }\n : { \"aria-hidden\": true, hidden: true },\n state: { dragging },\n });\n}\n\nexport const Drawer = {\n Close: DrawerClose,\n Content: DrawerContent,\n Description: DrawerDescription,\n Handle: DrawerHandle,\n Root: DrawerRoot,\n Title: DrawerTitle,\n Trigger: DrawerTrigger,\n};\n"],"mappings":";AAsHS;AApHT,SAAS,SAAS,QAAQ,UAAU,4BAA4B;AAEhE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;AAC1B,SAAS,yBAA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,QACA,CAAC,UAAwC;AACvC,gBAAM,cAAc,kBAAkB,MAAM,SAAS;AACrD,gBAAM,UAAU,MAAM,IAAI,CAAC;AAAA,QAC7B;AAAA,MACF;AAAA,MACA,eAAe;AAAA,QACb;AAAA,QACA,CAAC,UAAwC;AACvC,cAAI,CAAC,MAAM,WAAW,EAAG;AACzB,gBAAM,SAAS,MAAM,IAAI,CAAC;AAAA,QAC5B;AAAA,MACF;AAAA,MACA,aAAa,qBAAqB,aAAa,CAAC,UAAwC;AACtF,YAAI,MAAM,cAAc,kBAAkB,MAAM,SAAS,GAAG;AAC1D,gBAAM,cAAc,sBAAsB,MAAM,SAAS;AAAA,QAC3D;AACA,cAAM,QAAQ;AAAA,MAChB,CAAC;AAAA,MACD,iBAAiB;AAAA,QACf;AAAA,QACA,CAAC,UAAwC;AACvC,cAAI,MAAM,cAAc,kBAAkB,MAAM,SAAS,GAAG;AAC1D,kBAAM,cAAc,sBAAsB,MAAM,SAAS;AAAA,UAC3D;AACA,gBAAM,QAAQ;AAAA,QAChB;AAAA,MACF;AAAA,IACF,IACA,EAAE,eAAe,MAAM,QAAQ,KAAK;AAAA,IACxC,OAAO,EAAE,SAAS;AAAA,EACpB,CAAC;AACH;AAEO,MAAM,SAAS;AAAA,EACpB,OAAO;AAAA,EACP,SAAS;AAAA,EACT,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AACX;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../../src/components/drawer/Drawer.tsx"],"sourcesContent":["\"use client\";\n\nimport { useMemo, useRef, useState, useSyncExternalStore } from \"react\";\nimport type { PointerEvent, ReactElement, SyntheticEvent } from \"react\";\nimport {\n useId,\n useIsomorphicLayoutEffect,\n useMergedRefs,\n useResizeObserver,\n} from \"@gunkin/uiify/hooks\";\nimport { createPartContext } from \"@gunkin/uiify/core\";\nimport { composeEventHandlers } from \"@gunkin/uiify/core/compose-event-handlers\";\nimport { useRenderElement } from \"@gunkin/uiify/core/render\";\nimport { useDialog } from \"@gunkin/uiify/core/dialog\";\nimport { createDrawerStore } from \"./drawer-store.js\";\nimport type {\n DrawerStore,\n DrawerContextValue,\n DrawerRootProps,\n DrawerTriggerProps,\n DrawerContentProps,\n DrawerTitleOwnProps,\n DrawerDescriptionOwnProps,\n DrawerCloseProps,\n DrawerHandleOwnProps,\n} from \"./client-types.js\";\n\nconst [DrawerProvider, useDrawerContext] = createPartContext<DrawerContextValue>(\"Drawer\");\n\nexport function DrawerRoot(props: DrawerRootProps): ReactElement | null {\n const {\n activeSnapPoint,\n children,\n defaultActiveSnapPoint,\n defaultOpen,\n dismissible = true,\n modal = true,\n onOpenChange,\n onSnapChange,\n open,\n side = \"bottom\",\n snapPoints,\n } = props;\n const contentId = useId();\n const dialog = useDialog({\n modal,\n ...(defaultOpen !== undefined ? { defaultOpen } : {}),\n ...(open !== undefined ? { open } : {}),\n ...(onOpenChange ? { onOpenChange } : {}),\n });\n const [labelId, setLabelId] = useState<string | undefined>();\n const [descriptionId, setDescriptionId] = useState<string | undefined>();\n const triggerRef = useRef<HTMLButtonElement | null>(null);\n const wasOpenRef = useRef(dialog.open);\n const storeRef = useRef<DrawerStore | null>(null);\n storeRef.current ??= createDrawerStore({\n side,\n dismissible,\n onDismiss: () => dialog.close(),\n ...(snapPoints ? { snapPoints } : {}),\n ...(activeSnapPoint !== undefined ? { activeSnapPoint } : {}),\n ...(defaultActiveSnapPoint !== undefined ? { defaultActiveSnapPoint } : {}),\n ...(onSnapChange ? { onSnapChange } : {}),\n });\n const store = storeRef.current;\n\n useIsomorphicLayoutEffect(() => {\n if (activeSnapPoint !== undefined) store.syncActiveSnapPoint(activeSnapPoint);\n }, [activeSnapPoint, store]);\n\n useIsomorphicLayoutEffect(() => {\n if (wasOpenRef.current && !dialog.open) {\n queueMicrotask(() => triggerRef.current?.focus({ preventScroll: true }));\n }\n wasOpenRef.current = dialog.open;\n }, [dialog.open]);\n\n const snapEnabled = Boolean(snapPoints && snapPoints.length > 0);\n\n const contextValue = useMemo<DrawerContextValue>(\n () => ({\n close: dialog.close,\n contentId,\n descriptionId,\n dialogProps: dialog.dialogProps,\n dialogRef: dialog.dialogRef,\n dismissible,\n labelId,\n modal,\n open: dialog.open,\n openDialog: dialog.openDialog,\n setDescriptionId,\n setLabelId,\n side,\n snapEnabled,\n store,\n triggerRef,\n }),\n [\n contentId,\n descriptionId,\n dialog.close,\n dialog.dialogProps,\n dialog.dialogRef,\n dialog.open,\n dialog.openDialog,\n dismissible,\n labelId,\n modal,\n side,\n snapEnabled,\n store,\n ],\n );\n\n return <DrawerProvider value={contextValue}>{children}</DrawerProvider>;\n}\nDrawerRoot.displayName = \"DrawerRoot\";\n\nexport function DrawerTrigger(props: DrawerTriggerProps): ReactElement | null {\n const { children, className, ref, ...consumerProps } = props;\n const { contentId, open, openDialog, triggerRef } = useDrawerContext(\"Trigger\");\n const mergedRef = useMergedRefs(triggerRef, ref);\n\n return useRenderElement({\n defaultTag: \"button\",\n props: {\n ...consumerProps,\n ref: mergedRef,\n type: \"button\",\n \"data-uiify-button\": \"\",\n \"data-part\": \"trigger\",\n \"data-uiify-drawer\": \"\",\n \"aria-controls\": contentId,\n \"aria-expanded\": open,\n \"aria-haspopup\": \"dialog\",\n onClick: composeEventHandlers(consumerProps.onClick, openDialog),\n ...(className ? { className } : {}),\n children,\n },\n state: {},\n });\n}\n\nexport function DrawerContent(props: DrawerContentProps): ReactElement | null {\n const { children, className, ref, style: consumerStyle, ...consumerProps } = props;\n const {\n contentId,\n descriptionId,\n dialogProps,\n dialogRef,\n labelId,\n modal,\n open,\n side,\n snapEnabled,\n store,\n } = useDrawerContext(\"Content\");\n const containerRef = useRef<HTMLDialogElement | null>(null);\n const mergedRef = useMergedRefs(dialogRef, containerRef, ref);\n const size = useResizeObserver(containerRef);\n const transform = useSyncExternalStore(\n (listener) => store.subscribe(listener),\n () => store.getTransform(),\n () => \"\",\n );\n const activeSnap = useSyncExternalStore(\n (listener) => store.subscribe(listener),\n () => store.getActiveSnapPoint(),\n () => 1,\n );\n\n useIsomorphicLayoutEffect(() => {\n if (!size) return;\n const vertical = side === \"top\" || side === \"bottom\";\n store.setContainerSize(vertical ? size.height : size.width);\n }, [side, size, store]);\n\n const styleVars =\n snapEnabled && transform\n ? ({\n \"--uiify-drawer-transform\": transform,\n \"--uiify-drawer-snap\": String(activeSnap),\n } as React.CSSProperties)\n : undefined;\n\n const content = useRenderElement({\n defaultTag: \"dialog\",\n props: {\n ...consumerProps,\n ref: mergedRef,\n id: contentId,\n \"aria-describedby\": descriptionId,\n \"aria-labelledby\": labelId,\n \"aria-modal\": modal ? true : undefined,\n \"data-part\": \"content\",\n \"data-side\": side,\n \"data-state\": open ? \"open\" : \"closed\",\n \"data-uiify-drawer\": \"\",\n \"data-snap-enabled\": snapEnabled ? \"\" : undefined,\n ...(className ? { className } : {}),\n ...(consumerStyle || styleVars ? { style: { ...consumerStyle, ...styleVars } } : {}),\n onCancel: composeEventHandlers(\n consumerProps.onCancel,\n (event: SyntheticEvent<HTMLDialogElement>) => {\n dialogProps.onCancel?.(event);\n },\n ),\n onClose: composeEventHandlers(\n consumerProps.onClose,\n (event: SyntheticEvent<HTMLDialogElement>) => {\n dialogProps.onClose?.(event);\n },\n ),\n children,\n },\n state: { open, side },\n });\n\n return content;\n}\n\nexport function DrawerTitle(props: DrawerTitleOwnProps): ReactElement | null {\n const { children, className } = props;\n const id = useId();\n const { setLabelId } = useDrawerContext(\"Title\");\n\n useIsomorphicLayoutEffect(() => {\n setLabelId(id);\n return () => setLabelId(undefined);\n }, [id, setLabelId]);\n\n return useRenderElement({\n defaultTag: \"h2\",\n props: {\n id,\n \"data-part\": \"title\",\n \"data-uiify-drawer\": \"\",\n ...(className ? { className } : {}),\n children,\n },\n state: {},\n });\n}\n\nexport function DrawerDescription(props: DrawerDescriptionOwnProps): ReactElement | null {\n const { children, className } = props;\n const id = useId();\n const { setDescriptionId } = useDrawerContext(\"Description\");\n\n useIsomorphicLayoutEffect(() => {\n setDescriptionId(id);\n return () => setDescriptionId(undefined);\n }, [id, setDescriptionId]);\n\n return useRenderElement({\n defaultTag: \"p\",\n props: {\n id,\n \"data-part\": \"description\",\n \"data-uiify-drawer\": \"\",\n ...(className ? { className } : {}),\n children,\n },\n state: {},\n });\n}\n\nexport function DrawerClose(props: DrawerCloseProps): ReactElement | null {\n const { children, className, ...consumerProps } = props;\n const { close } = useDrawerContext(\"Close\");\n\n return useRenderElement({\n defaultTag: \"button\",\n props: {\n ...consumerProps,\n type: \"button\",\n \"data-uiify-button\": \"\",\n \"data-part\": \"close\",\n \"data-uiify-drawer\": \"\",\n \"data-variant\": \"ghost\",\n onClick: composeEventHandlers(consumerProps.onClick, () => {\n close();\n }),\n ...(className ? { className } : {}),\n children,\n },\n state: {},\n });\n}\n\nexport function DrawerHandle(props: DrawerHandleOwnProps): ReactElement | null {\n const { className, onPointerCancel, onPointerDown, onPointerMove, onPointerUp } = props;\n const { side, snapEnabled, store } = useDrawerContext(\"Handle\");\n const dragging = useSyncExternalStore(\n (listener) => store.subscribe(listener),\n () => store.isDragging(),\n () => false,\n );\n\n const axis = side === \"top\" || side === \"bottom\" ? \"clientY\" : \"clientX\";\n\n return useRenderElement({\n defaultTag: \"div\",\n props: snapEnabled\n ? {\n \"aria-hidden\": true,\n \"data-part\": \"handle\",\n \"data-uiify-drawer\": \"\",\n \"data-dragging\": dragging ? \"\" : undefined,\n \"data-side\": side,\n ...(className ? { className } : {}),\n onPointerDown: composeEventHandlers(\n onPointerDown,\n (event: PointerEvent<HTMLDivElement>) => {\n event.currentTarget.setPointerCapture(event.pointerId);\n store.startDrag(event[axis]);\n },\n ),\n onPointerMove: composeEventHandlers(\n onPointerMove,\n (event: PointerEvent<HTMLDivElement>) => {\n if (!store.isDragging()) return;\n store.moveDrag(event[axis]);\n },\n ),\n onPointerUp: composeEventHandlers(onPointerUp, (event: PointerEvent<HTMLDivElement>) => {\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n store.endDrag();\n }),\n onPointerCancel: composeEventHandlers(\n onPointerCancel,\n (event: PointerEvent<HTMLDivElement>) => {\n if (event.currentTarget.hasPointerCapture(event.pointerId)) {\n event.currentTarget.releasePointerCapture(event.pointerId);\n }\n store.endDrag();\n },\n ),\n }\n : { \"aria-hidden\": true, hidden: true },\n state: { dragging },\n });\n}\n\nexport const Drawer = {\n Close: DrawerClose,\n Content: DrawerContent,\n Description: DrawerDescription,\n Handle: DrawerHandle,\n Root: DrawerRoot,\n Title: DrawerTitle,\n Trigger: DrawerTrigger,\n};\n"],"mappings":";AAmHS;AAjHT,SAAS,SAAS,QAAQ,UAAU,4BAA4B;AAEhE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yBAAyB;AAClC,SAAS,4BAA4B;AACrC,SAAS,wBAAwB;AACjC,SAAS,iBAAiB;AAC1B,SAAS,yBAAyB;AAalC,MAAM,CAAC,gBAAgB,gBAAgB,IAAI,kBAAsC,QAAQ;AAElF,SAAS,WAAW,OAA6C;AACtE,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,IACd,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA,OAAO;AAAA,IACP;AAAA,EACF,IAAI;AACJ,QAAM,YAAY,MAAM;AACxB,QAAM,SAAS,UAAU;AAAA,IACvB;AAAA,IACA,GAAI,gBAAgB,SAAY,EAAE,YAAY,IAAI,CAAC;AAAA,IACnD,GAAI,SAAS,SAAY,EAAE,KAAK,IAAI,CAAC;AAAA,IACrC,GAAI,eAAe,EAAE,aAAa,IAAI,CAAC;AAAA,EACzC,CAAC;AACD,QAAM,CAAC,SAAS,UAAU,IAAI,SAA6B;AAC3D,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAA6B;AACvE,QAAM,aAAa,OAAiC,IAAI;AACxD,QAAM,aAA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A,IACF,IACA,EAAE,eAAe,MAAM,QAAQ,KAAK;AAAA,IACxC,OAAO,EAAE,SAAS;AAAA,EACpB,CAAC;AACH;AAEO,MAAM,SAAS;AAAA,EACpB,OAAO;AAAA,EACP,SAAS;AAAA,EACT,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,OAAO;AAAA,EACP,SAAS;AACX;","names":[]}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** The modal dialog surface `ModalContent` renders. */
|
|
2
|
+
export declare const MODAL_DIALOG = "dialog[data-uiify-modal][data-part=\"content\"]";
|
|
3
|
+
interface Box {
|
|
4
|
+
readonly left: number;
|
|
5
|
+
readonly right: number;
|
|
6
|
+
readonly top: number;
|
|
7
|
+
readonly bottom: number;
|
|
8
|
+
}
|
|
9
|
+
/** True when the point lies outside the border box, that is on the dialog's `::backdrop`. */
|
|
10
|
+
export declare function isOutside(box: Box, x: number, y: number): boolean;
|
|
11
|
+
/** `requestClose()` lets a `cancel` handler veto; engines without it get a plain `close()`. */
|
|
12
|
+
export declare function requestCloseDialog(dialog: HTMLDialogElement, returnValue?: string): void;
|
|
13
|
+
/** Chrome 134+ and Firefox 141+ implement `closedby`; Safari does not (iOS 27). */
|
|
14
|
+
export declare function supportsClosedBy(view?: Window): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Backdrop-tap dismissal for engines without `closedby`. The markup already says
|
|
17
|
+
* `closedby="any"`; where the browser cannot act on it, this closes the dialog when a press
|
|
18
|
+
* and its click both land on the backdrop. Attaches nothing where `closedBy` exists.
|
|
19
|
+
*/
|
|
20
|
+
export declare function attachBackdropClose(doc?: Document): () => void;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=dialog-dismiss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dialog-dismiss.d.ts","sourceRoot":"","sources":["../../../src/components/enhance/dialog-dismiss.ts"],"names":[],"mappings":"AAEA,uDAAuD;AACvD,eAAO,MAAM,YAAY,oDAAkD,CAAC;AAE5E,UAAU,GAAG;IACX,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,6FAA6F;AAC7F,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAEjE;AAED,+FAA+F;AAC/F,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,iBAAiB,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAMxF;AAED,mFAAmF;AACnF,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,MAAe,GAAG,OAAO,CAG/D;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,QAAmB,GAAG,MAAM,IAAI,CA8BxE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { readBox } from "./internal/read-box.js";
|
|
2
|
+
const MODAL_DIALOG = 'dialog[data-uiify-modal][data-part="content"]';
|
|
3
|
+
function isOutside(box, x, y) {
|
|
4
|
+
return x < box.left || x > box.right || y < box.top || y > box.bottom;
|
|
5
|
+
}
|
|
6
|
+
function requestCloseDialog(dialog, returnValue) {
|
|
7
|
+
const { requestClose } = dialog;
|
|
8
|
+
if (typeof requestClose === "function") requestClose.call(dialog, returnValue);
|
|
9
|
+
else dialog.close(returnValue);
|
|
10
|
+
}
|
|
11
|
+
function supportsClosedBy(view = window) {
|
|
12
|
+
const { HTMLDialogElement: DialogCtor } = view;
|
|
13
|
+
return "closedBy" in DialogCtor.prototype;
|
|
14
|
+
}
|
|
15
|
+
function attachBackdropClose(doc = document) {
|
|
16
|
+
if (supportsClosedBy(doc.defaultView ?? window)) return () => {
|
|
17
|
+
};
|
|
18
|
+
let pressed = null;
|
|
19
|
+
const backdropTarget = (event) => {
|
|
20
|
+
const dialog = event.target;
|
|
21
|
+
if (!(dialog instanceof HTMLDialogElement) || !dialog.matches(MODAL_DIALOG)) return null;
|
|
22
|
+
if (dialog.getAttribute("closedby") !== "any") return null;
|
|
23
|
+
const box = readBox(dialog);
|
|
24
|
+
return isOutside(box, event.clientX, event.clientY) ? dialog : null;
|
|
25
|
+
};
|
|
26
|
+
const onPointerDown = (event) => {
|
|
27
|
+
pressed = backdropTarget(event);
|
|
28
|
+
};
|
|
29
|
+
const onClick = (event) => {
|
|
30
|
+
const start = pressed;
|
|
31
|
+
pressed = null;
|
|
32
|
+
if (event.defaultPrevented || !start || backdropTarget(event) !== start) return;
|
|
33
|
+
requestCloseDialog(start);
|
|
34
|
+
};
|
|
35
|
+
doc.addEventListener("pointerdown", onPointerDown);
|
|
36
|
+
doc.addEventListener("click", onClick);
|
|
37
|
+
return () => {
|
|
38
|
+
doc.removeEventListener("pointerdown", onPointerDown);
|
|
39
|
+
doc.removeEventListener("click", onClick);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
MODAL_DIALOG,
|
|
44
|
+
attachBackdropClose,
|
|
45
|
+
isOutside,
|
|
46
|
+
requestCloseDialog,
|
|
47
|
+
supportsClosedBy
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=dialog-dismiss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/enhance/dialog-dismiss.ts"],"sourcesContent":["import { readBox } from \"./internal/read-box.js\";\n\n/** The modal dialog surface `ModalContent` renders. */\nexport const MODAL_DIALOG = 'dialog[data-uiify-modal][data-part=\"content\"]';\n\ninterface Box {\n readonly left: number;\n readonly right: number;\n readonly top: number;\n readonly bottom: number;\n}\n\n/** True when the point lies outside the border box, that is on the dialog's `::backdrop`. */\nexport function isOutside(box: Box, x: number, y: number): boolean {\n return x < box.left || x > box.right || y < box.top || y > box.bottom;\n}\n\n/** `requestClose()` lets a `cancel` handler veto; engines without it get a plain `close()`. */\nexport function requestCloseDialog(dialog: HTMLDialogElement, returnValue?: string): void {\n const { requestClose } = dialog as HTMLDialogElement & {\n requestClose?: (value?: string) => void;\n };\n if (typeof requestClose === \"function\") requestClose.call(dialog, returnValue);\n else dialog.close(returnValue);\n}\n\n/** Chrome 134+ and Firefox 141+ implement `closedby`; Safari does not (iOS 27). */\nexport function supportsClosedBy(view: Window = window): boolean {\n const { HTMLDialogElement: DialogCtor } = view as unknown as typeof globalThis;\n return \"closedBy\" in DialogCtor.prototype;\n}\n\n/**\n * Backdrop-tap dismissal for engines without `closedby`. The markup already says\n * `closedby=\"any\"`; where the browser cannot act on it, this closes the dialog when a press\n * and its click both land on the backdrop. Attaches nothing where `closedBy` exists.\n */\nexport function attachBackdropClose(doc: Document = document): () => void {\n if (supportsClosedBy(doc.defaultView ?? window)) return () => {};\n\n let pressed: HTMLDialogElement | null = null;\n\n const backdropTarget = (event: MouseEvent): HTMLDialogElement | null => {\n const dialog = event.target;\n if (!(dialog instanceof HTMLDialogElement) || !dialog.matches(MODAL_DIALOG)) return null;\n if (dialog.getAttribute(\"closedby\") !== \"any\") return null;\n const box = readBox(dialog);\n return isOutside(box, event.clientX, event.clientY) ? dialog : null;\n };\n\n const onPointerDown = (event: PointerEvent): void => {\n pressed = backdropTarget(event);\n };\n\n const onClick = (event: MouseEvent): void => {\n const start = pressed;\n pressed = null;\n if (event.defaultPrevented || !start || backdropTarget(event) !== start) return;\n requestCloseDialog(start);\n };\n\n doc.addEventListener(\"pointerdown\", onPointerDown);\n doc.addEventListener(\"click\", onClick);\n return () => {\n doc.removeEventListener(\"pointerdown\", onPointerDown);\n doc.removeEventListener(\"click\", onClick);\n };\n}\n"],"mappings":"AAAA,SAAS,eAAe;AAGjB,MAAM,eAAe;AAUrB,SAAS,UAAU,KAAU,GAAW,GAAoB;AACjE,SAAO,IAAI,IAAI,QAAQ,IAAI,IAAI,SAAS,IAAI,IAAI,OAAO,IAAI,IAAI;AACjE;AAGO,SAAS,mBAAmB,QAA2B,aAA4B;AACxF,QAAM,EAAE,aAAa,IAAI;AAGzB,MAAI,OAAO,iBAAiB,WAAY,cAAa,KAAK,QAAQ,WAAW;AAAA,MACxE,QAAO,MAAM,WAAW;AAC/B;AAGO,SAAS,iBAAiB,OAAe,QAAiB;AAC/D,QAAM,EAAE,mBAAmB,WAAW,IAAI;AAC1C,SAAO,cAAc,WAAW;AAClC;AAOO,SAAS,oBAAoB,MAAgB,UAAsB;AACxE,MAAI,iBAAiB,IAAI,eAAe,MAAM,EAAG,QAAO,MAAM;AAAA,EAAC;AAE/D,MAAI,UAAoC;AAExC,QAAM,iBAAiB,CAAC,UAAgD;AACtE,UAAM,SAAS,MAAM;AACrB,QAAI,EAAE,kBAAkB,sBAAsB,CAAC,OAAO,QAAQ,YAAY,EAAG,QAAO;AACpF,QAAI,OAAO,aAAa,UAAU,MAAM,MAAO,QAAO;AACtD,UAAM,MAAM,QAAQ,MAAM;AAC1B,WAAO,UAAU,KAAK,MAAM,SAAS,MAAM,OAAO,IAAI,SAAS;AAAA,EACjE;AAEA,QAAM,gBAAgB,CAAC,UAA8B;AACnD,cAAU,eAAe,KAAK;AAAA,EAChC;AAEA,QAAM,UAAU,CAAC,UAA4B;AAC3C,UAAM,QAAQ;AACd,cAAU;AACV,QAAI,MAAM,oBAAoB,CAAC,SAAS,eAAe,KAAK,MAAM,MAAO;AACzE,uBAAmB,KAAK;AAAA,EAC1B;AAEA,MAAI,iBAAiB,eAAe,aAAa;AACjD,MAAI,iBAAiB,SAAS,OAAO;AACrC,SAAO,MAAM;AACX,QAAI,oBAAoB,eAAe,aAAa;AACpD,QAAI,oBAAoB,SAAS,OAAO;AAAA,EAC1C;AACF;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-box.d.ts","sourceRoot":"","sources":["../../../../src/components/enhance/internal/read-box.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,wBAAgB,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAEjD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/enhance/internal/read-box.ts"],"sourcesContent":["/** One synchronous geometry read, taken once per user press and never per frame. */\nexport function readBox(element: Element): DOMRect {\n return element.getBoundingClientRect(); // banned-read-ok: one read per user press, never per frame\n}\n"],"mappings":"AACO,SAAS,QAAQ,SAA2B;AACjD,SAAO,QAAQ,sBAAsB;AACvC;","names":[]}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Delegated fallback for `command`/`commandfor` on engines below the library
|
|
3
|
-
* baseline (Chrome < 135, Firefox < 144, Safari < 26.2), e.g. Firefox ESR 140
|
|
4
|
-
* and iOS 26.0/26.1. Feature-detected: engines that implement invoker commands
|
|
5
|
-
* get nothing attached. Clicks that happen before hydration on those engines
|
|
6
|
-
* are still lost — see docs/guides/native-composition.md.
|
|
7
|
-
*/
|
|
8
1
|
export declare function supportsInvokerCommands(view?: Window): boolean;
|
|
9
2
|
/** Execute the button's declared command against its target. Returns true when a command ran. */
|
|
10
3
|
export declare function runInvokerCommand(button: HTMLButtonElement): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoker-fallback.d.ts","sourceRoot":"","sources":["../../../src/components/enhance/invoker-fallback.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"invoker-fallback.d.ts","sourceRoot":"","sources":["../../../src/components/enhance/invoker-fallback.ts"],"names":[],"mappings":"AAYA,wBAAgB,uBAAuB,CAAC,IAAI,GAAE,MAAe,GAAG,OAAO,CAOtE;AAkCD,iGAAiG;AACjG,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAQpE;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,GAAE,QAAmB,GAAG,MAAM,IAAI,CAa1E"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { requestCloseDialog } from "./dialog-dismiss.js";
|
|
1
2
|
const INVOKER_SELECTOR = "button[command][commandfor]";
|
|
2
3
|
function supportsInvokerCommands(view = window) {
|
|
3
4
|
const { HTMLButtonElement: ButtonCtor } = view;
|
|
@@ -11,13 +12,9 @@ function runDialogCommand(dialog, command, value) {
|
|
|
11
12
|
case "close":
|
|
12
13
|
if (dialog.open) dialog.close(value);
|
|
13
14
|
return true;
|
|
14
|
-
case "request-close":
|
|
15
|
-
if (
|
|
16
|
-
const requestClose = dialog.requestClose;
|
|
17
|
-
if (typeof requestClose === "function") requestClose.call(dialog, value);
|
|
18
|
-
else dialog.close(value);
|
|
15
|
+
case "request-close":
|
|
16
|
+
if (dialog.open) requestCloseDialog(dialog, value);
|
|
19
17
|
return true;
|
|
20
|
-
}
|
|
21
18
|
default:
|
|
22
19
|
return false;
|
|
23
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/enhance/invoker-fallback.ts"],"sourcesContent":["/**\n * Delegated fallback for `command`/`commandfor` on engines below the library\n * baseline (Chrome < 135, Firefox < 144, Safari < 26.2), e.g. Firefox ESR 140\n * and iOS 26.0/26.1. Feature-detected: engines that implement invoker commands\n * get nothing attached. Clicks that happen before hydration on those engines\n * are still lost — see docs/guides/native-composition.md.\n */\n\nconst INVOKER_SELECTOR = \"button[command][commandfor]\";\n\nexport function supportsInvokerCommands(view: Window = window): boolean {\n // `HTMLButtonElement` is a global constructor, not a member of the `Window`\n // interface itself, so TypeScript's DOM lib does not expose it on a plain\n // `Window`-typed value. `view` is always the global `window` (or another\n // document's `defaultView`, which carries the same globals) at runtime.\n const { HTMLButtonElement: ButtonCtor } = view as unknown as typeof globalThis;\n return \"commandForElement\" in ButtonCtor.prototype;\n}\n\nfunction runDialogCommand(dialog: HTMLDialogElement, command: string, value: string): boolean {\n switch (command) {\n case \"show-modal\":\n if (!dialog.open) dialog.showModal();\n return true;\n case \"close\":\n if (dialog.open) dialog.close(value);\n return true;\n case \"request-close\"
|
|
1
|
+
{"version":3,"sources":["../../../src/components/enhance/invoker-fallback.ts"],"sourcesContent":["import { requestCloseDialog } from \"./dialog-dismiss.js\";\n\n/**\n * Delegated fallback for `command`/`commandfor` on engines below the library\n * baseline (Chrome < 135, Firefox < 144, Safari < 26.2), e.g. Firefox ESR 140\n * and iOS 26.0/26.1. Feature-detected: engines that implement invoker commands\n * get nothing attached. Clicks that happen before hydration on those engines\n * are still lost — see docs/guides/native-composition.md.\n */\n\nconst INVOKER_SELECTOR = \"button[command][commandfor]\";\n\nexport function supportsInvokerCommands(view: Window = window): boolean {\n // `HTMLButtonElement` is a global constructor, not a member of the `Window`\n // interface itself, so TypeScript's DOM lib does not expose it on a plain\n // `Window`-typed value. `view` is always the global `window` (or another\n // document's `defaultView`, which carries the same globals) at runtime.\n const { HTMLButtonElement: ButtonCtor } = view as unknown as typeof globalThis;\n return \"commandForElement\" in ButtonCtor.prototype;\n}\n\nfunction runDialogCommand(dialog: HTMLDialogElement, command: string, value: string): boolean {\n switch (command) {\n case \"show-modal\":\n if (!dialog.open) dialog.showModal();\n return true;\n case \"close\":\n if (dialog.open) dialog.close(value);\n return true;\n case \"request-close\":\n if (dialog.open) requestCloseDialog(dialog, value);\n return true;\n default:\n return false;\n }\n}\n\nfunction runPopoverCommand(target: HTMLElement, command: string): boolean {\n switch (command) {\n case \"toggle-popover\":\n target.togglePopover();\n return true;\n case \"show-popover\":\n target.showPopover();\n return true;\n case \"hide-popover\":\n target.hidePopover();\n return true;\n default:\n return false;\n }\n}\n\n/** Execute the button's declared command against its target. Returns true when a command ran. */\nexport function runInvokerCommand(button: HTMLButtonElement): boolean {\n const command = button.getAttribute(\"command\");\n const targetId = button.getAttribute(\"commandfor\");\n if (!command || !targetId) return false;\n const target = button.ownerDocument.getElementById(targetId);\n if (!target) return false;\n if (target instanceof HTMLDialogElement) return runDialogCommand(target, command, button.value);\n return target.hasAttribute(\"popover\") && runPopoverCommand(target, command);\n}\n\n/**\n * Attach the delegated click listener when the engine lacks invoker commands.\n * Returns a teardown; a no-op teardown when nothing was attached.\n */\nexport function attachInvokerFallback(doc: Document = document): () => void {\n if (supportsInvokerCommands(doc.defaultView ?? window)) return () => {};\n\n const onClick = (event: Event): void => {\n if (event.defaultPrevented) return;\n const origin = event.target instanceof Element ? event.target : null;\n const button = origin?.closest(INVOKER_SELECTOR);\n if (!(button instanceof HTMLButtonElement) || button.disabled) return;\n if (runInvokerCommand(button)) event.preventDefault();\n };\n\n doc.addEventListener(\"click\", onClick);\n return () => doc.removeEventListener(\"click\", onClick);\n}\n"],"mappings":"AAAA,SAAS,0BAA0B;AAUnC,MAAM,mBAAmB;AAElB,SAAS,wBAAwB,OAAe,QAAiB;AAKtE,QAAM,EAAE,mBAAmB,WAAW,IAAI;AAC1C,SAAO,uBAAuB,WAAW;AAC3C;AAEA,SAAS,iBAAiB,QAA2B,SAAiB,OAAwB;AAC5F,UAAQ,SAAS;AAAA,IACf,KAAK;AACH,UAAI,CAAC,OAAO,KAAM,QAAO,UAAU;AACnC,aAAO;AAAA,IACT,KAAK;AACH,UAAI,OAAO,KAAM,QAAO,MAAM,KAAK;AACnC,aAAO;AAAA,IACT,KAAK;AACH,UAAI,OAAO,KAAM,oBAAmB,QAAQ,KAAK;AACjD,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEA,SAAS,kBAAkB,QAAqB,SAA0B;AACxE,UAAQ,SAAS;AAAA,IACf,KAAK;AACH,aAAO,cAAc;AACrB,aAAO;AAAA,IACT,KAAK;AACH,aAAO,YAAY;AACnB,aAAO;AAAA,IACT,KAAK;AACH,aAAO,YAAY;AACnB,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAGO,SAAS,kBAAkB,QAAoC;AACpE,QAAM,UAAU,OAAO,aAAa,SAAS;AAC7C,QAAM,WAAW,OAAO,aAAa,YAAY;AACjD,MAAI,CAAC,WAAW,CAAC,SAAU,QAAO;AAClC,QAAM,SAAS,OAAO,cAAc,eAAe,QAAQ;AAC3D,MAAI,CAAC,OAAQ,QAAO;AACpB,MAAI,kBAAkB,kBAAmB,QAAO,iBAAiB,QAAQ,SAAS,OAAO,KAAK;AAC9F,SAAO,OAAO,aAAa,SAAS,KAAK,kBAAkB,QAAQ,OAAO;AAC5E;AAMO,SAAS,sBAAsB,MAAgB,UAAsB;AAC1E,MAAI,wBAAwB,IAAI,eAAe,MAAM,EAAG,QAAO,MAAM;AAAA,EAAC;AAEtE,QAAM,UAAU,CAAC,UAAuB;AACtC,QAAI,MAAM,iBAAkB;AAC5B,UAAM,SAAS,MAAM,kBAAkB,UAAU,MAAM,SAAS;AAChE,UAAM,SAAS,QAAQ,QAAQ,gBAAgB;AAC/C,QAAI,EAAE,kBAAkB,sBAAsB,OAAO,SAAU;AAC/D,QAAI,kBAAkB,MAAM,EAAG,OAAM,eAAe;AAAA,EACtD;AAEA,MAAI,iBAAiB,SAAS,OAAO;AACrC,SAAO,MAAM,IAAI,oBAAoB,SAAS,OAAO;AACvD;","names":[]}
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
*
|
|
11
11
|
* The invoker fallback attaches only on engines without `command`/`commandfor`
|
|
12
12
|
* (see invoker-fallback.ts); on the baseline it is a no-op.
|
|
13
|
+
* The backdrop-tap fallback attaches only on engines without `closedBy`.
|
|
14
|
+
* The sheet swipe is delegated pointer handling for the mobile modal sheet.
|
|
13
15
|
*/
|
|
14
16
|
export declare function attachEnhancers(doc?: Document): () => void;
|
|
15
17
|
//# sourceMappingURL=listeners.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"listeners.d.ts","sourceRoot":"","sources":["../../../src/components/enhance/listeners.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"listeners.d.ts","sourceRoot":"","sources":["../../../src/components/enhance/listeners.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,GAAG,GAAE,QAAmB,GAAG,MAAM,IAAI,CAgCpE"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { attachBackdropClose } from "./dialog-dismiss.js";
|
|
1
2
|
import { attachInvokerFallback } from "./invoker-fallback.js";
|
|
3
|
+
import { attachSheetSwipe } from "./sheet-swipe.js";
|
|
2
4
|
import { syncPopoverTriggers, syncTabs } from "./sync.js";
|
|
3
5
|
function attachEnhancers(doc = document) {
|
|
4
6
|
const onToggle = (event) => {
|
|
@@ -16,10 +18,14 @@ function attachEnhancers(doc = document) {
|
|
|
16
18
|
doc.addEventListener("toggle", onToggle, true);
|
|
17
19
|
doc.addEventListener("change", onChange);
|
|
18
20
|
const detachInvokerFallback = attachInvokerFallback(doc);
|
|
21
|
+
const detachBackdropClose = attachBackdropClose(doc);
|
|
22
|
+
const detachSheetSwipe = attachSheetSwipe(doc);
|
|
19
23
|
return () => {
|
|
20
24
|
doc.removeEventListener("toggle", onToggle, true);
|
|
21
25
|
doc.removeEventListener("change", onChange);
|
|
22
26
|
detachInvokerFallback();
|
|
27
|
+
detachBackdropClose();
|
|
28
|
+
detachSheetSwipe();
|
|
23
29
|
};
|
|
24
30
|
}
|
|
25
31
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/enhance/listeners.ts"],"sourcesContent":["import { attachInvokerFallback } from \"./invoker-fallback.js\";\nimport { syncPopoverTriggers, syncTabs } from \"./sync.js\";\n\n/**\n * Attach the document-level enhancement listeners. Returns a teardown.\n *\n * `toggle` is captured rather than bubbled: the event has `bubbles: false`, but\n * the capture phase runs from the root down to the target for every dispatched\n * event regardless of bubbling, so a single capture-phase listener on the\n * document sees every popover on the page — including ones rendered later.\n *\n * `change` bubbles, so tabs are handled in the ordinary bubble phase.\n *\n * The invoker fallback attaches only on engines without `command`/`commandfor`\n * (see invoker-fallback.ts); on the baseline it is a no-op.\n */\nexport function attachEnhancers(doc: Document = document): () => void {\n const onToggle = (event: Event): void => {\n const target = event.target as HTMLElement | null;\n if (!target?.hasAttribute(\"popover\") || !target.id) return;\n const { newState } = event as ToggleEvent;\n syncPopoverTriggers(target.id, newState === \"open\");\n };\n\n const onChange = (event: Event): void => {\n const target = event.target as HTMLElement | null;\n if (!target?.matches('[data-uiify-tabs] > [data-part=\"item\"] > [data-part=\"control\"]')) return;\n // The root Tabs marker is `data-uiify-tabs`:\n // the latter never existed outside this selector, so syncTabs was never\n // reached in production. Pinned by listeners.test.ts, which now builds its\n // fixture with renderToStaticMarkup instead of hand-written HTML.\n const root = target.closest<HTMLElement>(\"[data-uiify-tabs]\");\n if (root?.id) syncTabs(root.id);\n };\n\n doc.addEventListener(\"toggle\", onToggle, true);\n doc.addEventListener(\"change\", onChange);\n const detachInvokerFallback = attachInvokerFallback(doc);\n\n return () => {\n doc.removeEventListener(\"toggle\", onToggle, true);\n doc.removeEventListener(\"change\", onChange);\n detachInvokerFallback();\n };\n}\n"],"mappings":"AAAA,SAAS,6BAA6B;AACtC,SAAS,qBAAqB,gBAAgB;
|
|
1
|
+
{"version":3,"sources":["../../../src/components/enhance/listeners.ts"],"sourcesContent":["import { attachBackdropClose } from \"./dialog-dismiss.js\";\nimport { attachInvokerFallback } from \"./invoker-fallback.js\";\nimport { attachSheetSwipe } from \"./sheet-swipe.js\";\nimport { syncPopoverTriggers, syncTabs } from \"./sync.js\";\n\n/**\n * Attach the document-level enhancement listeners. Returns a teardown.\n *\n * `toggle` is captured rather than bubbled: the event has `bubbles: false`, but\n * the capture phase runs from the root down to the target for every dispatched\n * event regardless of bubbling, so a single capture-phase listener on the\n * document sees every popover on the page — including ones rendered later.\n *\n * `change` bubbles, so tabs are handled in the ordinary bubble phase.\n *\n * The invoker fallback attaches only on engines without `command`/`commandfor`\n * (see invoker-fallback.ts); on the baseline it is a no-op.\n * The backdrop-tap fallback attaches only on engines without `closedBy`.\n * The sheet swipe is delegated pointer handling for the mobile modal sheet.\n */\nexport function attachEnhancers(doc: Document = document): () => void {\n const onToggle = (event: Event): void => {\n const target = event.target as HTMLElement | null;\n if (!target?.hasAttribute(\"popover\") || !target.id) return;\n const { newState } = event as ToggleEvent;\n syncPopoverTriggers(target.id, newState === \"open\");\n };\n\n const onChange = (event: Event): void => {\n const target = event.target as HTMLElement | null;\n if (!target?.matches('[data-uiify-tabs] > [data-part=\"item\"] > [data-part=\"control\"]')) return;\n // The root Tabs marker is `data-uiify-tabs`:\n // the latter never existed outside this selector, so syncTabs was never\n // reached in production. Pinned by listeners.test.ts, which now builds its\n // fixture with renderToStaticMarkup instead of hand-written HTML.\n const root = target.closest<HTMLElement>(\"[data-uiify-tabs]\");\n if (root?.id) syncTabs(root.id);\n };\n\n doc.addEventListener(\"toggle\", onToggle, true);\n doc.addEventListener(\"change\", onChange);\n const detachInvokerFallback = attachInvokerFallback(doc);\n const detachBackdropClose = attachBackdropClose(doc);\n const detachSheetSwipe = attachSheetSwipe(doc);\n\n return () => {\n doc.removeEventListener(\"toggle\", onToggle, true);\n doc.removeEventListener(\"change\", onChange);\n detachInvokerFallback();\n detachBackdropClose();\n detachSheetSwipe();\n };\n}\n"],"mappings":"AAAA,SAAS,2BAA2B;AACpC,SAAS,6BAA6B;AACtC,SAAS,wBAAwB;AACjC,SAAS,qBAAqB,gBAAgB;AAiBvC,SAAS,gBAAgB,MAAgB,UAAsB;AACpE,QAAM,WAAW,CAAC,UAAuB;AACvC,UAAM,SAAS,MAAM;AACrB,QAAI,CAAC,QAAQ,aAAa,SAAS,KAAK,CAAC,OAAO,GAAI;AACpD,UAAM,EAAE,SAAS,IAAI;AACrB,wBAAoB,OAAO,IAAI,aAAa,MAAM;AAAA,EACpD;AAEA,QAAM,WAAW,CAAC,UAAuB;AACvC,UAAM,SAAS,MAAM;AACrB,QAAI,CAAC,QAAQ,QAAQ,gEAAgE,EAAG;AAKxF,UAAM,OAAO,OAAO,QAAqB,mBAAmB;AAC5D,QAAI,MAAM,GAAI,UAAS,KAAK,EAAE;AAAA,EAChC;AAEA,MAAI,iBAAiB,UAAU,UAAU,IAAI;AAC7C,MAAI,iBAAiB,UAAU,QAAQ;AACvC,QAAM,wBAAwB,sBAAsB,GAAG;AACvD,QAAM,sBAAsB,oBAAoB,GAAG;AACnD,QAAM,mBAAmB,iBAAiB,GAAG;AAE7C,SAAO,MAAM;AACX,QAAI,oBAAoB,UAAU,UAAU,IAAI;AAChD,QAAI,oBAAoB,UAAU,QAAQ;AAC1C,0BAAsB;AACtB,wBAAoB;AACpB,qBAAiB;AAAA,EACnB;AACF;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Below this width the modal is a bottom sheet. Keep in sync with the `@media` in modal.css. */
|
|
2
|
+
export declare const SHEET_QUERY = "(width < 40rem)";
|
|
3
|
+
/**
|
|
4
|
+
* Swipe-down-to-close for the mobile sheet, driven by pointer events. It only moves the sheet
|
|
5
|
+
* with `data-dragging` and `--uiify-sheet-offset`; the transition back or out is the CSS in
|
|
6
|
+
* modal.css. Optional: without it the sheet still closes by icon, Escape and backdrop tap.
|
|
7
|
+
*/
|
|
8
|
+
export declare function attachSheetSwipe(doc?: Document): () => void;
|
|
9
|
+
//# sourceMappingURL=sheet-swipe.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sheet-swipe.d.ts","sourceRoot":"","sources":["../../../src/components/enhance/sheet-swipe.ts"],"names":[],"mappings":"AAGA,iGAAiG;AACjG,eAAO,MAAM,WAAW,oBAAoB,CAAC;AAyC7C;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,GAAE,QAAmB,GAAG,MAAM,IAAI,CAgGrE"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { MODAL_DIALOG, isOutside, requestCloseDialog } from "./dialog-dismiss.js";
|
|
2
|
+
import { readBox } from "./internal/read-box.js";
|
|
3
|
+
const SHEET_QUERY = "(width < 40rem)";
|
|
4
|
+
const HANDLE = '[data-uiify-modal][data-part="header"], [data-uiify-modal][data-part="grabber"]';
|
|
5
|
+
const INTERACTIVE = "a, button, input, select, textarea, [contenteditable], [data-no-swipe]";
|
|
6
|
+
const SLOP = 6;
|
|
7
|
+
const DISMISS_RATIO = 0.25;
|
|
8
|
+
const DISMISS_VELOCITY = 0.5;
|
|
9
|
+
const FLING_WINDOW_MS = 80;
|
|
10
|
+
const SWALLOW_MS = 300;
|
|
11
|
+
function swallowNextClick(doc) {
|
|
12
|
+
const swallow = (event) => {
|
|
13
|
+
event.stopPropagation();
|
|
14
|
+
event.preventDefault();
|
|
15
|
+
};
|
|
16
|
+
doc.addEventListener("click", swallow, { capture: true, once: true });
|
|
17
|
+
const timer = setTimeout(() => doc.removeEventListener("click", swallow, true), SWALLOW_MS);
|
|
18
|
+
return () => {
|
|
19
|
+
clearTimeout(timer);
|
|
20
|
+
doc.removeEventListener("click", swallow, true);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function attachSheetSwipe(doc = document) {
|
|
24
|
+
const view = doc.defaultView ?? window;
|
|
25
|
+
let press = null;
|
|
26
|
+
let cancelSwallow = null;
|
|
27
|
+
const startOf = (event) => {
|
|
28
|
+
const origin = event.target instanceof Element ? event.target : null;
|
|
29
|
+
const dialog = origin?.closest(MODAL_DIALOG);
|
|
30
|
+
if (!origin || !dialog || !dialog.open) return null;
|
|
31
|
+
if (dialog.getAttribute("closedby") === "none" || dialog.getAttribute("data-size") === "full") {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
const handle = origin === dialog ? null : origin.closest(HANDLE);
|
|
35
|
+
const onHandle = handle !== null && handle.closest(MODAL_DIALOG) === dialog && !origin.closest(INTERACTIVE);
|
|
36
|
+
if (origin !== dialog && !onHandle) return null;
|
|
37
|
+
if (!view.matchMedia(SHEET_QUERY).matches) return null;
|
|
38
|
+
const box = readBox(dialog);
|
|
39
|
+
const onBackdrop = origin === dialog && isOutside(box, event.clientX, event.clientY);
|
|
40
|
+
return onBackdrop || onHandle ? { dialog, height: box.height } : null;
|
|
41
|
+
};
|
|
42
|
+
const onDown = (event) => {
|
|
43
|
+
if (press || !event.isPrimary) return;
|
|
44
|
+
if (event.pointerType === "mouse" && event.button !== 0) return;
|
|
45
|
+
const start = startOf(event);
|
|
46
|
+
if (!start) return;
|
|
47
|
+
press = {
|
|
48
|
+
...start,
|
|
49
|
+
dragging: false,
|
|
50
|
+
lastTime: event.timeStamp,
|
|
51
|
+
lastY: event.clientY,
|
|
52
|
+
pointerId: event.pointerId,
|
|
53
|
+
startY: event.clientY,
|
|
54
|
+
velocity: 0
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
const onMove = (event) => {
|
|
58
|
+
if (!press || event.pointerId !== press.pointerId) return;
|
|
59
|
+
const dy = event.clientY - press.startY;
|
|
60
|
+
if (!press.dragging) {
|
|
61
|
+
if (dy < SLOP) return;
|
|
62
|
+
press.dragging = true;
|
|
63
|
+
press.dialog.setPointerCapture(event.pointerId);
|
|
64
|
+
press.dialog.setAttribute("data-dragging", "");
|
|
65
|
+
}
|
|
66
|
+
const elapsed = event.timeStamp - press.lastTime;
|
|
67
|
+
if (elapsed > 0) press.velocity = (event.clientY - press.lastY) / elapsed;
|
|
68
|
+
press.lastY = event.clientY;
|
|
69
|
+
press.lastTime = event.timeStamp;
|
|
70
|
+
press.dialog.style.setProperty("--uiify-sheet-offset", `${Math.max(0, dy)}px`);
|
|
71
|
+
};
|
|
72
|
+
const onEnd = (event) => {
|
|
73
|
+
if (!press || event.pointerId !== press.pointerId) return;
|
|
74
|
+
const { dialog, dragging, height, lastTime, startY, velocity: lastVelocity } = press;
|
|
75
|
+
press = null;
|
|
76
|
+
if (!dragging) return;
|
|
77
|
+
cancelSwallow?.();
|
|
78
|
+
cancelSwallow = swallowNextClick(doc);
|
|
79
|
+
if (!dialog.open) {
|
|
80
|
+
dialog.removeAttribute("data-dragging");
|
|
81
|
+
dialog.style.removeProperty("--uiify-sheet-offset");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const velocity = event.timeStamp - lastTime > FLING_WINDOW_MS ? 0 : lastVelocity;
|
|
85
|
+
const distance = event.clientY - startY;
|
|
86
|
+
const dismiss = event.type === "pointerup" && (distance > height * DISMISS_RATIO || velocity > DISMISS_VELOCITY);
|
|
87
|
+
dialog.removeAttribute("data-dragging");
|
|
88
|
+
dialog.style.removeProperty("--uiify-sheet-offset");
|
|
89
|
+
if (dismiss) requestCloseDialog(dialog);
|
|
90
|
+
};
|
|
91
|
+
doc.addEventListener("pointerdown", onDown);
|
|
92
|
+
doc.addEventListener("pointermove", onMove);
|
|
93
|
+
doc.addEventListener("pointerup", onEnd);
|
|
94
|
+
doc.addEventListener("pointercancel", onEnd);
|
|
95
|
+
return () => {
|
|
96
|
+
doc.removeEventListener("pointerdown", onDown);
|
|
97
|
+
doc.removeEventListener("pointermove", onMove);
|
|
98
|
+
doc.removeEventListener("pointerup", onEnd);
|
|
99
|
+
doc.removeEventListener("pointercancel", onEnd);
|
|
100
|
+
cancelSwallow?.();
|
|
101
|
+
if (press) {
|
|
102
|
+
press.dialog.removeAttribute("data-dragging");
|
|
103
|
+
press.dialog.style.removeProperty("--uiify-sheet-offset");
|
|
104
|
+
press = null;
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export {
|
|
109
|
+
SHEET_QUERY,
|
|
110
|
+
attachSheetSwipe
|
|
111
|
+
};
|
|
112
|
+
//# sourceMappingURL=sheet-swipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/enhance/sheet-swipe.ts"],"sourcesContent":["import { MODAL_DIALOG, isOutside, requestCloseDialog } from \"./dialog-dismiss.js\";\nimport { readBox } from \"./internal/read-box.js\";\n\n/** Below this width the modal is a bottom sheet. Keep in sync with the `@media` in modal.css. */\nexport const SHEET_QUERY = \"(width < 40rem)\";\n/** Where a press may start a swipe, besides the backdrop: the modal's own parts only. */\nconst HANDLE = '[data-uiify-modal][data-part=\"header\"], [data-uiify-modal][data-part=\"grabber\"]';\n/** Never start a swipe from these: the press is meant for them. */\nconst INTERACTIVE = \"a, button, input, select, textarea, [contenteditable], [data-no-swipe]\";\n/** Pixels a press must travel down before it becomes a drag; below it the tap reaches `click`. */\nconst SLOP = 6;\n/** Fraction of the sheet height that dismisses on release. */\nconst DISMISS_RATIO = 0.25;\n/** Downward release speed (px per ms) that dismisses regardless of distance. */\nconst DISMISS_VELOCITY = 0.5;\n/** A release this long after the last move is a pause, not a fling: its speed counts as zero. */\nconst FLING_WINDOW_MS = 80;\n/** How long the click that follows a drag is swallowed if it never arrives. */\nconst SWALLOW_MS = 300;\n\ninterface Press {\n readonly dialog: HTMLDialogElement;\n readonly height: number;\n readonly pointerId: number;\n readonly startY: number;\n dragging: boolean;\n lastY: number;\n lastTime: number;\n velocity: number;\n}\n\n/** Swallows the click that ends a drag; returns a function that removes the trap. */\nfunction swallowNextClick(doc: Document): () => void {\n const swallow = (event: Event): void => {\n event.stopPropagation();\n event.preventDefault();\n };\n doc.addEventListener(\"click\", swallow, { capture: true, once: true });\n const timer = setTimeout(() => doc.removeEventListener(\"click\", swallow, true), SWALLOW_MS);\n return () => {\n clearTimeout(timer);\n doc.removeEventListener(\"click\", swallow, true);\n };\n}\n\n/**\n * Swipe-down-to-close for the mobile sheet, driven by pointer events. It only moves the sheet\n * with `data-dragging` and `--uiify-sheet-offset`; the transition back or out is the CSS in\n * modal.css. Optional: without it the sheet still closes by icon, Escape and backdrop tap.\n */\nexport function attachSheetSwipe(doc: Document = document): () => void {\n const view = doc.defaultView ?? window;\n let press: Press | null = null;\n let cancelSwallow: (() => void) | null = null;\n\n const startOf = (event: PointerEvent): { dialog: HTMLDialogElement; height: number } | null => {\n const origin = event.target instanceof Element ? event.target : null;\n const dialog = origin?.closest<HTMLDialogElement>(MODAL_DIALOG);\n if (!origin || !dialog || !dialog.open) return null;\n if (dialog.getAttribute(\"closedby\") === \"none\" || dialog.getAttribute(\"data-size\") === \"full\") {\n return null;\n }\n const handle = origin === dialog ? null : origin.closest(HANDLE);\n const onHandle =\n handle !== null && handle.closest(MODAL_DIALOG) === dialog && !origin.closest(INTERACTIVE);\n // A press in the body or on a control never starts a swipe: skip the layout read for it.\n if (origin !== dialog && !onHandle) return null;\n if (!view.matchMedia(SHEET_QUERY).matches) return null;\n const box = readBox(dialog);\n const onBackdrop = origin === dialog && isOutside(box, event.clientX, event.clientY);\n return onBackdrop || onHandle ? { dialog, height: box.height } : null;\n };\n\n const onDown = (event: PointerEvent): void => {\n if (press || !event.isPrimary) return;\n if (event.pointerType === \"mouse\" && event.button !== 0) return;\n const start = startOf(event);\n if (!start) return;\n press = {\n ...start,\n dragging: false,\n lastTime: event.timeStamp,\n lastY: event.clientY,\n pointerId: event.pointerId,\n startY: event.clientY,\n velocity: 0,\n };\n };\n\n const onMove = (event: PointerEvent): void => {\n if (!press || event.pointerId !== press.pointerId) return;\n const dy = event.clientY - press.startY;\n if (!press.dragging) {\n if (dy < SLOP) return;\n press.dragging = true;\n press.dialog.setPointerCapture(event.pointerId);\n press.dialog.setAttribute(\"data-dragging\", \"\");\n }\n const elapsed = event.timeStamp - press.lastTime;\n if (elapsed > 0) press.velocity = (event.clientY - press.lastY) / elapsed;\n press.lastY = event.clientY;\n press.lastTime = event.timeStamp;\n press.dialog.style.setProperty(\"--uiify-sheet-offset\", `${Math.max(0, dy)}px`);\n };\n\n const onEnd = (event: PointerEvent): void => {\n if (!press || event.pointerId !== press.pointerId) return;\n const { dialog, dragging, height, lastTime, startY, velocity: lastVelocity } = press;\n press = null;\n if (!dragging) return;\n cancelSwallow?.();\n cancelSwallow = swallowNextClick(doc);\n if (!dialog.open) {\n // Closed by other means mid-drag (Escape, a programmatic close): just reset the drag state.\n dialog.removeAttribute(\"data-dragging\");\n dialog.style.removeProperty(\"--uiify-sheet-offset\");\n return;\n }\n const velocity = event.timeStamp - lastTime > FLING_WINDOW_MS ? 0 : lastVelocity;\n const distance = event.clientY - startY;\n const dismiss =\n event.type === \"pointerup\" &&\n (distance > height * DISMISS_RATIO || velocity > DISMISS_VELOCITY);\n // Hand the position back to CSS first: if the dialog closes it slides out from where the\n // finger left it, if a cancel handler vetoes it springs back to the resting position.\n dialog.removeAttribute(\"data-dragging\");\n dialog.style.removeProperty(\"--uiify-sheet-offset\");\n if (dismiss) requestCloseDialog(dialog);\n };\n\n doc.addEventListener(\"pointerdown\", onDown);\n doc.addEventListener(\"pointermove\", onMove);\n doc.addEventListener(\"pointerup\", onEnd);\n doc.addEventListener(\"pointercancel\", onEnd);\n return () => {\n doc.removeEventListener(\"pointerdown\", onDown);\n doc.removeEventListener(\"pointermove\", onMove);\n doc.removeEventListener(\"pointerup\", onEnd);\n doc.removeEventListener(\"pointercancel\", onEnd);\n cancelSwallow?.();\n if (press) {\n press.dialog.removeAttribute(\"data-dragging\");\n press.dialog.style.removeProperty(\"--uiify-sheet-offset\");\n press = null;\n }\n };\n}\n"],"mappings":"AAAA,SAAS,cAAc,WAAW,0BAA0B;AAC5D,SAAS,eAAe;AAGjB,MAAM,cAAc;AAE3B,MAAM,SAAS;AAEf,MAAM,cAAc;AAEpB,MAAM,OAAO;AAEb,MAAM,gBAAgB;AAEtB,MAAM,mBAAmB;AAEzB,MAAM,kBAAkB;AAExB,MAAM,aAAa;AAcnB,SAAS,iBAAiB,KAA2B;AACnD,QAAM,UAAU,CAAC,UAAuB;AACtC,UAAM,gBAAgB;AACtB,UAAM,eAAe;AAAA,EACvB;AACA,MAAI,iBAAiB,SAAS,SAAS,EAAE,SAAS,MAAM,MAAM,KAAK,CAAC;AACpE,QAAM,QAAQ,WAAW,MAAM,IAAI,oBAAoB,SAAS,SAAS,IAAI,GAAG,UAAU;AAC1F,SAAO,MAAM;AACX,iBAAa,KAAK;AAClB,QAAI,oBAAoB,SAAS,SAAS,IAAI;AAAA,EAChD;AACF;AAOO,SAAS,iBAAiB,MAAgB,UAAsB;AACrE,QAAM,OAAO,IAAI,eAAe;AAChC,MAAI,QAAsB;AAC1B,MAAI,gBAAqC;AAEzC,QAAM,U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AO;AACT,YAAM,OAAO,gBAAgB,eAAe;AAC5C,YAAM,OAAO,MAAM,eAAe,sBAAsB;AACxD,cAAQ;AAAA,IACV;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { ReactElement } from "react";
|
|
2
2
|
import type { ModalProps } from "./types.js";
|
|
3
3
|
/**
|
|
4
|
-
* Convenience shell over the native parts: one trigger
|
|
5
|
-
* with title
|
|
6
|
-
* dialogs use `ModalClientContent` from
|
|
4
|
+
* Convenience shell over the native parts: one trigger and one modal `<dialog>`
|
|
5
|
+
* with a header (title, description, close icon), a body and an optional footer.
|
|
6
|
+
* Controlled or initially open dialogs use `ModalClientContent` from
|
|
7
|
+
* `@gunkin/uiify/components/modal/client`.
|
|
7
8
|
*/
|
|
8
|
-
export declare function Modal({ id, trigger, title, description, children, closeLabel, className, }: ModalProps): ReactElement;
|
|
9
|
+
export declare function Modal({ id, trigger, title, description, children, closeLabel, footer, className, align, backdrop, dismiss, size, }: ModalProps): ReactElement;
|
|
9
10
|
export declare namespace Modal {
|
|
10
11
|
var displayName: string;
|
|
11
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAa,MAAM,OAAO,CAAC;AAYrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAuB7C;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,EACpB,EAAE,EACF,OAAO,EACP,KAAK,EACL,WAAW,EACX,QAAQ,EACR,UAAoB,EACpB,MAAM,EACN,SAAS,EACT,KAAK,EACL,QAAQ,EACR,OAAO,EACP,IAAI,GACL,EAAE,UAAU,GAAG,YAAY,CAgC3B;yBA7Ce,KAAK"}
|