tfy-web-components 0.0.45 → 0.0.47
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/{CompositeItem-GNejxLcK.js → CompositeItem-ClTKQQ4f.js} +2 -2
- package/dist/{CompositeItem-GNejxLcK.js.map → CompositeItem-ClTKQQ4f.js.map} +1 -1
- package/dist/{CompositeRoot-7_u1HqDT.js → CompositeRoot-CR4V84Em.js} +6 -6
- package/dist/{CompositeRoot-7_u1HqDT.js.map → CompositeRoot-CR4V84Em.js.map} +1 -1
- package/dist/{DropdownMenu-Crlf-J4E.js → DropdownMenu-B_tIHJUl.js} +14 -14
- package/dist/{DropdownMenu-Crlf-J4E.js.map → DropdownMenu-B_tIHJUl.js.map} +1 -1
- package/dist/{Modal-DaHG8mjy.js → Modal-CJj8wP0E.js} +7 -7
- package/dist/{Modal-DaHG8mjy.js.map → Modal-CJj8wP0E.js.map} +1 -1
- package/dist/{Popover-A8IyEt2w.js → Popover-DOpJ7QW-.js} +5 -5
- package/dist/{Popover-A8IyEt2w.js.map → Popover-DOpJ7QW-.js.map} +1 -1
- package/dist/{PopoverPopup-teGm7D5T.js → PopoverPopup-Dd6Z5rv7.js} +8 -8
- package/dist/{PopoverPopup-teGm7D5T.js.map → PopoverPopup-Dd6Z5rv7.js.map} +1 -1
- package/dist/{PrehydrationScript-B3u_PP2W.js → PrehydrationScript-BfRb7l5u.js} +2 -2
- package/dist/{PrehydrationScript-B3u_PP2W.js.map → PrehydrationScript-BfRb7l5u.js.map} +1 -1
- package/dist/{Select-BtX40h2K.js → Select-OlnvlAXg.js} +14 -14
- package/dist/{Select-BtX40h2K.js.map → Select-OlnvlAXg.js.map} +1 -1
- package/dist/components/atoms/Accordion.d.ts +11 -4
- package/dist/components/atoms/Accordion.es.js +108 -52
- package/dist/components/atoms/Accordion.es.js.map +1 -1
- package/dist/components/atoms/ButtonGroup.es.js +2 -0
- package/dist/components/atoms/ButtonGroup.es.js.map +1 -1
- package/dist/components/atoms/Combobox.es.js +12 -12
- package/dist/components/atoms/ContextMenu.es.js +6 -6
- package/dist/components/atoms/DropdownMenu.es.js +1 -1
- package/dist/components/atoms/Modal.es.js +1 -1
- package/dist/components/atoms/Popover.es.js +1 -1
- package/dist/components/atoms/Select.es.js +2 -2
- package/dist/components/atoms/Switch.es.js +4 -4
- package/dist/components/atoms/TabButton.d.ts +10 -7
- package/dist/components/atoms/TabButton.es.js +198 -49
- package/dist/components/atoms/TabButton.es.js.map +1 -1
- package/dist/components/atoms/Tooltip.es.js +7 -7
- package/dist/components/molecules/Alert.es.js +1 -1
- package/dist/components/molecules/CustomDrawer.es.js +1 -1
- package/dist/components/molecules/Dialog.es.js +1 -1
- package/dist/components/molecules/ImagesPreview.es.js +1 -1
- package/dist/components/molecules/Pagination.es.js +18 -23
- package/dist/components/molecules/Pagination.es.js.map +1 -1
- package/dist/{composite-IA--dSel.js → composite-CH__oBQH.js} +2 -2
- package/dist/{composite-IA--dSel.js.map → composite-CH__oBQH.js.map} +1 -1
- package/dist/{composite-DnShFmi7.js → composite-Dzn8P1fl.js} +11 -11
- package/dist/{composite-DnShFmi7.js.map → composite-Dzn8P1fl.js.map} +1 -1
- package/dist/{constants-BaUKmVF_.js → constants-BzjgA7aT.js} +2 -2
- package/dist/{constants-BaUKmVF_.js.map → constants-BzjgA7aT.js.map} +1 -1
- package/dist/{element-B1vbc-LG.js → element-BI1c88Lp.js} +3 -3
- package/dist/{element-B1vbc-LG.js.map → element-BI1c88Lp.js.map} +1 -1
- package/dist/index.es.js +3 -3
- package/dist/{isElementDisabled-lq1fKien.js → isElementDisabled-CcmHYLra.js} +2 -2
- package/dist/{isElementDisabled-lq1fKien.js.map → isElementDisabled-CcmHYLra.js.map} +1 -1
- package/dist/new-components/atoms/Checkbox.es.js +4 -4
- package/dist/new-components/atoms/Popover.es.js +2 -2
- package/dist/new-components/atoms/Radio.es.js +8 -8
- package/dist/new-components/atoms/SegmentedControl.es.js +4 -4
- package/dist/new-components/atoms/Slider.es.js +6 -6
- package/dist/new-components/atoms/Toast.d.ts +1 -2
- package/dist/new-components/atoms/Toast.es.js +70 -98
- package/dist/new-components/atoms/Toast.es.js.map +1 -1
- package/dist/new-components/atoms/Toggletip.es.js +2 -2
- package/dist/style.css +1 -1
- package/dist/theme.css +1 -2
- package/dist/tokens.css +5 -5
- package/dist/{useAriaLabelledBy-CP4wKTYs.js → useAriaLabelledBy-C_Zzl94S.js} +2 -2
- package/dist/{useAriaLabelledBy-CP4wKTYs.js.map → useAriaLabelledBy-C_Zzl94S.js.map} +1 -1
- package/dist/{useBaseUiId-CYT1vFMG.js → useBaseUiId-DCE1GVlg.js} +6 -6
- package/dist/{useBaseUiId-CYT1vFMG.js.map → useBaseUiId-DCE1GVlg.js.map} +1 -1
- package/dist/{useButton-BlHadUfM.js → useButton-CtXDdeoI.js} +2 -2
- package/dist/{useButton-BlHadUfM.js.map → useButton-CtXDdeoI.js.map} +1 -1
- package/dist/{useFocus-C__7iwl1.js → useFocus-BGyXJhul.js} +6 -6
- package/dist/{useFocus-C__7iwl1.js.map → useFocus-BGyXJhul.js.map} +1 -1
- package/dist/{usePopupHandleStore-C_Vw7xcw.js → usePopupHandleStore-9hGUXtn5.js} +30 -30
- package/dist/{usePopupHandleStore-C_Vw7xcw.js.map → usePopupHandleStore-9hGUXtn5.js.map} +1 -1
- package/dist/{usePositioner-BmYVsMO_.js → usePositioner-CAWMEP8L.js} +6 -6
- package/dist/{usePositioner-BmYVsMO_.js.map → usePositioner-CAWMEP8L.js.map} +1 -1
- package/dist/{useScrollLock-By-42HSc.js → useScrollLock-QpeWQmdB.js} +6 -6
- package/dist/{useScrollLock-By-42HSc.js.map → useScrollLock-QpeWQmdB.js.map} +1 -1
- package/dist/{useSetFieldFocused-CcdG6FNp.js → useSetFieldFocused-BO2Y66f_.js} +2 -2
- package/dist/{useSetFieldFocused-CcdG6FNp.js.map → useSetFieldFocused-BO2Y66f_.js.map} +1 -1
- package/dist/{useTriggerFocusGuards-CXAhW8P6.js → useTriggerFocusGuards-Ss68N7Fe.js} +5 -5
- package/dist/{useTriggerFocusGuards-CXAhW8P6.js.map → useTriggerFocusGuards-Ss68N7Fe.js.map} +1 -1
- package/dist/utilities.css +38 -0
- package/package.json +2 -1
package/dist/theme.css
CHANGED
package/dist/tokens.css
CHANGED
|
@@ -226,9 +226,9 @@
|
|
|
226
226
|
--button-destructive-text-hover: #ffffff;
|
|
227
227
|
--button-destructive-icon: #f43f5e;
|
|
228
228
|
--button-destructive-icon-hover: #ffffff;
|
|
229
|
-
--tabs-text-selected: #
|
|
230
|
-
--tabs-background-hover: #
|
|
231
|
-
--tabs-background-selected: #
|
|
229
|
+
--tabs-text-selected: #090f17;
|
|
230
|
+
--tabs-background-hover: #fafcff;
|
|
231
|
+
--tabs-background-selected: #f1f5f9;
|
|
232
232
|
--tabs-indicator-background-selected: #4f46e5;
|
|
233
233
|
--tabs-contained-background-selected: #ffffff;
|
|
234
234
|
--segmented-segment-solid-background-selected: #05090e;
|
|
@@ -242,7 +242,7 @@
|
|
|
242
242
|
--segmented-segment-brand-icon-selected: #ffffff;
|
|
243
243
|
--topbar-background: #ffffff;
|
|
244
244
|
--topbar-divider-background: #cee0f8;
|
|
245
|
-
--tabs-contained-background: #
|
|
245
|
+
--tabs-contained-background: #f1f5f9;
|
|
246
246
|
|
|
247
247
|
--space-0: 0;
|
|
248
248
|
--space-2: 0.125rem;
|
|
@@ -581,7 +581,7 @@
|
|
|
581
581
|
--button-destructive-icon-hover: #ffffff;
|
|
582
582
|
--tabs-text-selected: #e4e4e7;
|
|
583
583
|
--tabs-background-hover: #1a1a1d;
|
|
584
|
-
--tabs-background-selected: #
|
|
584
|
+
--tabs-background-selected: #27272a;
|
|
585
585
|
--tabs-indicator-background-selected: #6366f1;
|
|
586
586
|
--tabs-contained-background-selected: #1f1f22;
|
|
587
587
|
--segmented-segment-solid-background-selected: #fdfdfd;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { u as useIsoLayoutEffect } from "./useIsoLayoutEffect-D2lpsB9D.js";
|
|
3
|
-
import { u as useBaseUiId } from "./useBaseUiId-
|
|
3
|
+
import { u as useBaseUiId } from "./useBaseUiId-DCE1GVlg.js";
|
|
4
4
|
function useAriaLabelledBy(explicitAriaLabelledBy, labelId, labelSourceRef, enableFallback = true, labelSourceId, ariaLabel) {
|
|
5
5
|
const [fallbackAriaLabelledBy, setFallbackAriaLabelledBy] = React.useState();
|
|
6
6
|
const generatedLabelId = useBaseUiId(labelSourceId ? `${labelSourceId}-label` : void 0);
|
|
@@ -46,4 +46,4 @@ function findAssociatedLabel(labelSource) {
|
|
|
46
46
|
export {
|
|
47
47
|
useAriaLabelledBy as u
|
|
48
48
|
};
|
|
49
|
-
//# sourceMappingURL=useAriaLabelledBy-
|
|
49
|
+
//# sourceMappingURL=useAriaLabelledBy-C_Zzl94S.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAriaLabelledBy-
|
|
1
|
+
{"version":3,"file":"useAriaLabelledBy-C_Zzl94S.js","sources":["../node_modules/@base-ui/react/internals/labelable-provider/useAriaLabelledBy.mjs"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';\nimport { useBaseUiId } from \"../useBaseUiId.mjs\";\nexport function useAriaLabelledBy(explicitAriaLabelledBy, labelId, labelSourceRef, enableFallback = true, labelSourceId, ariaLabel) {\n const [fallbackAriaLabelledBy, setFallbackAriaLabelledBy] = React.useState();\n const generatedLabelId = useBaseUiId(labelSourceId ? `${labelSourceId}-label` : undefined);\n // A non-blank `aria-label` wins over any associated label, as it does on native inputs.\n const hasAriaLabel = Boolean(ariaLabel?.trim());\n const implicitLabelId = hasAriaLabel ? undefined : labelId;\n const ariaLabelledBy = explicitAriaLabelledBy ?? implicitLabelId ?? fallbackAriaLabelledBy;\n\n // Fallback for <span> controls labelled by wrapping/sibling native <label>.\n // Run after every commit so DOM association changes (e.g. label mount/unmount)\n // are reflected even when props/state deps are unchanged.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n useIsoLayoutEffect(() => {\n const nextAriaLabelledBy = explicitAriaLabelledBy || labelId || hasAriaLabel || !enableFallback ? undefined : getAriaLabelledBy(labelSourceRef.current, generatedLabelId);\n if (fallbackAriaLabelledBy !== nextAriaLabelledBy) {\n setFallbackAriaLabelledBy(nextAriaLabelledBy);\n }\n });\n return ariaLabelledBy;\n}\nfunction getAriaLabelledBy(labelSource, generatedLabelId) {\n const label = findAssociatedLabel(labelSource);\n if (!label) {\n return undefined;\n }\n if (!label.id && generatedLabelId) {\n label.id = generatedLabelId;\n }\n return label.id || undefined;\n}\nfunction findAssociatedLabel(labelSource) {\n if (!labelSource) {\n return undefined;\n }\n\n // Fast path before the expensive `.labels` read.\n const parent = labelSource.parentElement;\n if (parent && parent.tagName === 'LABEL') {\n return parent;\n }\n const controlId = labelSource.id;\n if (controlId) {\n const nextSibling = labelSource.nextElementSibling;\n if (nextSibling && nextSibling.htmlFor === controlId) {\n return nextSibling;\n }\n }\n const labels = labelSource.labels;\n return labels && labels[0];\n}"],"names":[],"mappings":";;;AAKO,SAAS,kBAAkB,wBAAwB,SAAS,gBAAgB,iBAAiB,MAAM,eAAe,WAAW;AAClI,QAAM,CAAC,wBAAwB,yBAAyB,IAAI,MAAM,SAAQ;AAC1E,QAAM,mBAAmB,YAAY,gBAAgB,GAAG,aAAa,WAAW,MAAS;AAEzF,QAAM,eAAe,QAAQ,uCAAW,MAAM;AAC9C,QAAM,kBAAkB,eAAe,SAAY;AACnD,QAAM,iBAAiB,0BAA0B,mBAAmB;AAMpE,qBAAmB,MAAM;AACvB,UAAM,qBAAqB,0BAA0B,WAAW,gBAAgB,CAAC,iBAAiB,SAAY,kBAAkB,eAAe,SAAS,gBAAgB;AACxK,QAAI,2BAA2B,oBAAoB;AACjD,gCAA0B,kBAAkB;AAAA,IAC9C;AAAA,EACF,CAAC;AACD,SAAO;AACT;AACA,SAAS,kBAAkB,aAAa,kBAAkB;AACxD,QAAM,QAAQ,oBAAoB,WAAW;AAC7C,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AACA,MAAI,CAAC,MAAM,MAAM,kBAAkB;AACjC,UAAM,KAAK;AAAA,EACb;AACA,SAAO,MAAM,MAAM;AACrB;AACA,SAAS,oBAAoB,aAAa;AACxC,MAAI,CAAC,aAAa;AAChB,WAAO;AAAA,EACT;AAGA,QAAM,SAAS,YAAY;AAC3B,MAAI,UAAU,OAAO,YAAY,SAAS;AACxC,WAAO;AAAA,EACT;AACA,QAAM,YAAY,YAAY;AAC9B,MAAI,WAAW;AACb,UAAM,cAAc,YAAY;AAChC,QAAI,eAAe,YAAY,YAAY,WAAW;AACpD,aAAO;AAAA,IACT;AAAA,EACF;AACA,QAAM,SAAS,YAAY;AAC3B,SAAO,UAAU,OAAO,CAAC;AAC3B;","x_google_ignoreList":[0]}
|
|
@@ -252,11 +252,11 @@ export {
|
|
|
252
252
|
keyboard as C,
|
|
253
253
|
chipRemovePress as D,
|
|
254
254
|
clearPress as E,
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
255
|
+
pointer as F,
|
|
256
|
+
siblingOpen as G,
|
|
257
|
+
triggerHover as H,
|
|
258
|
+
triggerFocus as I,
|
|
259
|
+
windowResize as J,
|
|
260
260
|
drag as K,
|
|
261
261
|
trackPress as L,
|
|
262
262
|
getNodeName as M,
|
|
@@ -298,4 +298,4 @@ export {
|
|
|
298
298
|
imperativeAction as y,
|
|
299
299
|
closePress as z
|
|
300
300
|
};
|
|
301
|
-
//# sourceMappingURL=useBaseUiId-
|
|
301
|
+
//# sourceMappingURL=useBaseUiId-DCE1GVlg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBaseUiId-CYT1vFMG.js","sources":["../node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs","../node_modules/@base-ui/utils/useForcedRerendering.mjs","../node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs","../node_modules/@base-ui/react/internals/reason-parts.mjs","../node_modules/@base-ui/utils/useId.mjs","../node_modules/@base-ui/react/internals/useBaseUiId.mjs"],"sourcesContent":["function hasWindow() {\n return typeof window !== 'undefined';\n}\nfunction getNodeName(node) {\n if (isNode(node)) {\n return (node.nodeName || '').toLowerCase();\n }\n // Mocked nodes in testing environments may not be instances of Node. By\n // returning `#document` an infinite loop won't occur.\n // https://github.com/floating-ui/floating-ui/issues/2317\n return '#document';\n}\nfunction getWindow(node) {\n var _node$ownerDocument;\n return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;\n}\nfunction getDocumentElement(node) {\n var _ref;\n return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;\n}\nfunction isNode(value) {\n if (!hasWindow()) {\n return false;\n }\n return value instanceof Node || value instanceof getWindow(value).Node;\n}\nfunction isElement(value) {\n if (!hasWindow()) {\n return false;\n }\n return value instanceof Element || value instanceof getWindow(value).Element;\n}\nfunction isHTMLElement(value) {\n if (!hasWindow()) {\n return false;\n }\n return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;\n}\nfunction isShadowRoot(value) {\n if (!hasWindow() || typeof ShadowRoot === 'undefined') {\n return false;\n }\n return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;\n}\nfunction isOverflowElement(element) {\n const {\n overflow,\n overflowX,\n overflowY,\n display\n } = getComputedStyle(element);\n return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== 'inline' && display !== 'contents';\n}\nfunction isTableElement(element) {\n return /^(table|td|th)$/.test(getNodeName(element));\n}\nfunction isTopLayer(element) {\n try {\n if (element.matches(':popover-open')) {\n return true;\n }\n } catch (_e) {\n // no-op\n }\n try {\n return element.matches(':modal');\n } catch (_e) {\n return false;\n }\n}\nconst willChangeRe = /transform|translate|scale|rotate|perspective|filter/;\nconst containRe = /paint|layout|strict|content/;\nconst isNotNone = value => !!value && value !== 'none';\nlet isWebKitValue;\nfunction isContainingBlock(elementOrCss) {\n const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;\n\n // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n // https://drafts.csswg.org/css-transforms-2/#individual-transforms\n return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || '') || containRe.test(css.contain || '');\n}\nfunction getContainingBlock(element) {\n let currentNode = getParentNode(element);\n while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {\n if (isContainingBlock(currentNode)) {\n return currentNode;\n } else if (isTopLayer(currentNode)) {\n return null;\n }\n currentNode = getParentNode(currentNode);\n }\n return null;\n}\nfunction isWebKit() {\n if (isWebKitValue == null) {\n isWebKitValue = typeof CSS !== 'undefined' && CSS.supports && CSS.supports('-webkit-backdrop-filter', 'none');\n }\n return isWebKitValue;\n}\nfunction isLastTraversableNode(node) {\n return /^(html|body|#document)$/.test(getNodeName(node));\n}\nfunction getComputedStyle(element) {\n return getWindow(element).getComputedStyle(element);\n}\nfunction getNodeScroll(element) {\n if (isElement(element)) {\n return {\n scrollLeft: element.scrollLeft,\n scrollTop: element.scrollTop\n };\n }\n return {\n scrollLeft: element.scrollX,\n scrollTop: element.scrollY\n };\n}\nfunction getParentNode(node) {\n if (getNodeName(node) === 'html') {\n return node;\n }\n const result =\n // Step into the shadow DOM of the parent of a slotted node.\n node.assignedSlot ||\n // DOM Element detected.\n node.parentNode ||\n // ShadowRoot detected.\n isShadowRoot(node) && node.host ||\n // Fallback.\n getDocumentElement(node);\n return isShadowRoot(result) ? result.host : result;\n}\nfunction getNearestOverflowAncestor(node) {\n const parentNode = getParentNode(node);\n if (isLastTraversableNode(parentNode)) {\n return (node.ownerDocument || node).body;\n }\n if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {\n return parentNode;\n }\n return getNearestOverflowAncestor(parentNode);\n}\nfunction getOverflowAncestors(node, list, traverseIframes) {\n var _node$ownerDocument2;\n if (list === void 0) {\n list = [];\n }\n if (traverseIframes === void 0) {\n traverseIframes = true;\n }\n const scrollableAncestor = getNearestOverflowAncestor(node);\n const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);\n const win = getWindow(scrollableAncestor);\n if (isBody) {\n const frameElement = getFrameElement(win);\n return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);\n } else {\n return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));\n }\n}\nfunction getFrameElement(win) {\n return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;\n}\n\nexport { getComputedStyle, getContainingBlock, getDocumentElement, getFrameElement, getNearestOverflowAncestor, getNodeName, getNodeScroll, getOverflowAncestors, getParentNode, getWindow, isContainingBlock, isElement, isHTMLElement, isLastTraversableNode, isNode, isOverflowElement, isShadowRoot, isTableElement, isTopLayer, isWebKit };\n","'use client';\n\nimport * as React from 'react';\n\n/**\n * Returns a function that forces a rerender.\n */\nexport function useForcedRerendering() {\n const [, setState] = React.useState({});\n return React.useCallback(() => {\n setState({});\n }, []);\n}","import { EMPTY_OBJECT } from '@base-ui/utils/empty';\n\n/**\n * Maps a change `reason` string to the corresponding native event type.\n */\n\n/**\n * Details of custom change events emitted by Base UI components.\n */\n\n/**\n * Details of custom generic events emitted by Base UI components.\n */\n\n/** Highlight navigation uses mouse events for hover and pointer events for leaving an item. */\n\n/**\n * Creates a Base UI event details object with the given reason and utilities\n * for preventing Base UI's internal event handling.\n */\nexport function createChangeEventDetails(reason, event, trigger, customProperties) {\n let canceled = false;\n let allowPropagation = false;\n const custom = customProperties ?? EMPTY_OBJECT;\n const details = {\n reason,\n event: event ?? new Event('base-ui'),\n cancel() {\n canceled = true;\n },\n allowPropagation() {\n allowPropagation = true;\n },\n get isCanceled() {\n return canceled;\n },\n get isPropagationAllowed() {\n return allowPropagation;\n },\n trigger,\n ...custom\n };\n return details;\n}\nexport function createGenericEventDetails(reason, event, customProperties) {\n const custom = customProperties ?? EMPTY_OBJECT;\n const details = {\n reason,\n event: event ?? new Event('base-ui'),\n ...custom\n };\n return details;\n}","export const none = 'none';\nexport const triggerPress = 'trigger-press';\nexport const triggerHover = 'trigger-hover';\nexport const triggerFocus = 'trigger-focus';\nexport const outsidePress = 'outside-press';\nexport const itemPress = 'item-press';\nexport const closePress = 'close-press';\nexport const linkPress = 'link-press';\nexport const clearPress = 'clear-press';\nexport const chipRemovePress = 'chip-remove-press';\nexport const trackPress = 'track-press';\nexport const incrementPress = 'increment-press';\nexport const decrementPress = 'decrement-press';\nexport const inputChange = 'input-change';\nexport const inputClear = 'input-clear';\nexport const inputBlur = 'input-blur';\nexport const inputPaste = 'input-paste';\nexport const inputPress = 'input-press';\nexport const focusOut = 'focus-out';\nexport const escapeKey = 'escape-key';\nexport const closeWatcher = 'close-watcher';\nexport const listNavigation = 'list-navigation';\nexport const keyboard = 'keyboard';\nexport const pointer = 'pointer';\nexport const drag = 'drag';\nexport const wheel = 'wheel';\nexport const scrub = 'scrub';\nexport const popupClose = 'popup-close';\nexport const cancelOpen = 'cancel-open';\nexport const siblingOpen = 'sibling-open';\nexport const disabled = 'disabled';\nexport const missing = 'missing';\nexport const initial = 'initial';\nexport const imperativeAction = 'imperative-action';\nexport const swipe = 'swipe';\nexport const windowResize = 'window-resize';","'use client';\n\nimport * as React from 'react';\nimport { SafeReact } from \"./safeReact.mjs\";\nimport { useForcedRerendering } from \"./useForcedRerendering.mjs\";\nlet globalId = 0;\n\n// TODO React 17: Remove `useGlobalId` once React 17 support is removed\nfunction useGlobalId(idOverride, prefix = 'mui') {\n const defaultId = React.useRef(undefined);\n const forceRerender = useForcedRerendering();\n const id = idOverride ?? defaultId.current;\n React.useEffect(() => {\n if (defaultId.current == null) {\n // Fallback to this default id when possible.\n // Use the incrementing value for client-side rendering only.\n // We can't use it server-side.\n // If you want to use random values please consider the Birthday Problem: https://en.wikipedia.org/wiki/Birthday_problem\n globalId += 1;\n defaultId.current = `${prefix}-${globalId}`;\n // Generate the fallback even while `idOverride` is set.\n // Removing the override then swaps in the existing id within the same commit.\n // Deferring generation would leave one commit with no id, breaking `htmlFor` and `aria-labelledby` links.\n // Only rerender when the fallback is the value being rendered.\n if (idOverride == null) {\n forceRerender();\n }\n }\n }, [idOverride, prefix, forceRerender]);\n return id;\n}\nconst maybeReactUseId = SafeReact.useId;\n\n/**\n *\n * @example <div id={useId()} />\n * @param {string | undefined} idOverride overrides the generated id when provided\n * @param {string | undefined} prefix prefixes the generated id when provided\n * @returns {string | undefined}\n */\nexport function useId(idOverride, prefix) {\n // React.useId() is only available from React 18.0.0.\n if (maybeReactUseId !== undefined) {\n const reactId = maybeReactUseId();\n return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);\n }\n\n // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler\n // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.\n return useGlobalId(idOverride, prefix);\n}","'use client';\n\nimport { useId } from '@base-ui/utils/useId';\n\n/**\n * Wraps `useId` and prefixes generated `id`s with `base-ui-`\n * @param {string | undefined} idOverride overrides the generated id when provided\n * @returns {string | undefined}\n */\nexport function useBaseUiId(idOverride) {\n return useId(idOverride, 'base-ui');\n}"],"names":[],"mappings":";;AAAA,SAAS,YAAY;AACnB,SAAO,OAAO,WAAW;AAC3B;AACA,SAAS,YAAY,MAAM;AACzB,MAAI,OAAO,IAAI,GAAG;AAChB,YAAQ,KAAK,YAAY,IAAI,YAAW;AAAA,EAC1C;AAIA,SAAO;AACT;AACA,SAAS,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mBAAmB;AAEpB,MAAC,eAAe;AC9B5B,IAAI,WAAW;AAGf,SAAS,YAAY,YAAY,SAAS,OAAO;AAC/C,QAAM,YAAY,MAAM,OAAO,MAAS;AACxC,QAAM,gBAAgB,qBAAoB;AAC1C,QAAM,KAAK,cAAc,UAAU;AACnC,QAAM,UAAU,MAAM;AACpB,QAAI,UAAU,WAAW,MAAM;AAK7B,kBAAY;AACZ,gBAAU,UAAU,GAAG,MAAM,IAAI,QAAQ;AAKzC,UAAI,cAAc,MAAM;AACtB,sBAAa;AAAA,MACf;AAAA,IACF;AAAA,EACF,GAAG,CAAC,YAAY,QAAQ,aAAa,CAAC;AACtC,SAAO;AACT;AACA,MAAM,kBAAkB,UAAU;AAS3B,SAAS,MAAM,YAAY,QAAQ;AAExC,MAAI,oBAAoB,QAAW;AACjC,UAAM,UAAU,gBAAe;AAC/B,WAAO,eAAe,SAAS,GAAG,MAAM,IAAI,OAAO,KAAK;AAAA,EAC1D;AAIA,SAAO,YAAY,YAAY,MAAM;AACvC;ACzCO,SAAS,YAAY,YAAY;AACtC,SAAO,MAAM,YAAY,SAAS;AACpC;","x_google_ignoreList":[0,1,2,3,4,5]}
|
|
1
|
+
{"version":3,"file":"useBaseUiId-DCE1GVlg.js","sources":["../node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs","../node_modules/@base-ui/utils/useForcedRerendering.mjs","../node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs","../node_modules/@base-ui/react/internals/reason-parts.mjs","../node_modules/@base-ui/utils/useId.mjs","../node_modules/@base-ui/react/internals/useBaseUiId.mjs"],"sourcesContent":["function hasWindow() {\n return typeof window !== 'undefined';\n}\nfunction getNodeName(node) {\n if (isNode(node)) {\n return (node.nodeName || '').toLowerCase();\n }\n // Mocked nodes in testing environments may not be instances of Node. By\n // returning `#document` an infinite loop won't occur.\n // https://github.com/floating-ui/floating-ui/issues/2317\n return '#document';\n}\nfunction getWindow(node) {\n var _node$ownerDocument;\n return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;\n}\nfunction getDocumentElement(node) {\n var _ref;\n return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;\n}\nfunction isNode(value) {\n if (!hasWindow()) {\n return false;\n }\n return value instanceof Node || value instanceof getWindow(value).Node;\n}\nfunction isElement(value) {\n if (!hasWindow()) {\n return false;\n }\n return value instanceof Element || value instanceof getWindow(value).Element;\n}\nfunction isHTMLElement(value) {\n if (!hasWindow()) {\n return false;\n }\n return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;\n}\nfunction isShadowRoot(value) {\n if (!hasWindow() || typeof ShadowRoot === 'undefined') {\n return false;\n }\n return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;\n}\nfunction isOverflowElement(element) {\n const {\n overflow,\n overflowX,\n overflowY,\n display\n } = getComputedStyle(element);\n return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== 'inline' && display !== 'contents';\n}\nfunction isTableElement(element) {\n return /^(table|td|th)$/.test(getNodeName(element));\n}\nfunction isTopLayer(element) {\n try {\n if (element.matches(':popover-open')) {\n return true;\n }\n } catch (_e) {\n // no-op\n }\n try {\n return element.matches(':modal');\n } catch (_e) {\n return false;\n }\n}\nconst willChangeRe = /transform|translate|scale|rotate|perspective|filter/;\nconst containRe = /paint|layout|strict|content/;\nconst isNotNone = value => !!value && value !== 'none';\nlet isWebKitValue;\nfunction isContainingBlock(elementOrCss) {\n const css = isElement(elementOrCss) ? getComputedStyle(elementOrCss) : elementOrCss;\n\n // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n // https://drafts.csswg.org/css-transforms-2/#individual-transforms\n return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || '') || containRe.test(css.contain || '');\n}\nfunction getContainingBlock(element) {\n let currentNode = getParentNode(element);\n while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {\n if (isContainingBlock(currentNode)) {\n return currentNode;\n } else if (isTopLayer(currentNode)) {\n return null;\n }\n currentNode = getParentNode(currentNode);\n }\n return null;\n}\nfunction isWebKit() {\n if (isWebKitValue == null) {\n isWebKitValue = typeof CSS !== 'undefined' && CSS.supports && CSS.supports('-webkit-backdrop-filter', 'none');\n }\n return isWebKitValue;\n}\nfunction isLastTraversableNode(node) {\n return /^(html|body|#document)$/.test(getNodeName(node));\n}\nfunction getComputedStyle(element) {\n return getWindow(element).getComputedStyle(element);\n}\nfunction getNodeScroll(element) {\n if (isElement(element)) {\n return {\n scrollLeft: element.scrollLeft,\n scrollTop: element.scrollTop\n };\n }\n return {\n scrollLeft: element.scrollX,\n scrollTop: element.scrollY\n };\n}\nfunction getParentNode(node) {\n if (getNodeName(node) === 'html') {\n return node;\n }\n const result =\n // Step into the shadow DOM of the parent of a slotted node.\n node.assignedSlot ||\n // DOM Element detected.\n node.parentNode ||\n // ShadowRoot detected.\n isShadowRoot(node) && node.host ||\n // Fallback.\n getDocumentElement(node);\n return isShadowRoot(result) ? result.host : result;\n}\nfunction getNearestOverflowAncestor(node) {\n const parentNode = getParentNode(node);\n if (isLastTraversableNode(parentNode)) {\n return (node.ownerDocument || node).body;\n }\n if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {\n return parentNode;\n }\n return getNearestOverflowAncestor(parentNode);\n}\nfunction getOverflowAncestors(node, list, traverseIframes) {\n var _node$ownerDocument2;\n if (list === void 0) {\n list = [];\n }\n if (traverseIframes === void 0) {\n traverseIframes = true;\n }\n const scrollableAncestor = getNearestOverflowAncestor(node);\n const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);\n const win = getWindow(scrollableAncestor);\n if (isBody) {\n const frameElement = getFrameElement(win);\n return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);\n } else {\n return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));\n }\n}\nfunction getFrameElement(win) {\n return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;\n}\n\nexport { getComputedStyle, getContainingBlock, getDocumentElement, getFrameElement, getNearestOverflowAncestor, getNodeName, getNodeScroll, getOverflowAncestors, getParentNode, getWindow, isContainingBlock, isElement, isHTMLElement, isLastTraversableNode, isNode, isOverflowElement, isShadowRoot, isTableElement, isTopLayer, isWebKit };\n","'use client';\n\nimport * as React from 'react';\n\n/**\n * Returns a function that forces a rerender.\n */\nexport function useForcedRerendering() {\n const [, setState] = React.useState({});\n return React.useCallback(() => {\n setState({});\n }, []);\n}","import { EMPTY_OBJECT } from '@base-ui/utils/empty';\n\n/**\n * Maps a change `reason` string to the corresponding native event type.\n */\n\n/**\n * Details of custom change events emitted by Base UI components.\n */\n\n/**\n * Details of custom generic events emitted by Base UI components.\n */\n\n/** Highlight navigation uses mouse events for hover and pointer events for leaving an item. */\n\n/**\n * Creates a Base UI event details object with the given reason and utilities\n * for preventing Base UI's internal event handling.\n */\nexport function createChangeEventDetails(reason, event, trigger, customProperties) {\n let canceled = false;\n let allowPropagation = false;\n const custom = customProperties ?? EMPTY_OBJECT;\n const details = {\n reason,\n event: event ?? new Event('base-ui'),\n cancel() {\n canceled = true;\n },\n allowPropagation() {\n allowPropagation = true;\n },\n get isCanceled() {\n return canceled;\n },\n get isPropagationAllowed() {\n return allowPropagation;\n },\n trigger,\n ...custom\n };\n return details;\n}\nexport function createGenericEventDetails(reason, event, customProperties) {\n const custom = customProperties ?? EMPTY_OBJECT;\n const details = {\n reason,\n event: event ?? new Event('base-ui'),\n ...custom\n };\n return details;\n}","export const none = 'none';\nexport const triggerPress = 'trigger-press';\nexport const triggerHover = 'trigger-hover';\nexport const triggerFocus = 'trigger-focus';\nexport const outsidePress = 'outside-press';\nexport const itemPress = 'item-press';\nexport const closePress = 'close-press';\nexport const linkPress = 'link-press';\nexport const clearPress = 'clear-press';\nexport const chipRemovePress = 'chip-remove-press';\nexport const trackPress = 'track-press';\nexport const incrementPress = 'increment-press';\nexport const decrementPress = 'decrement-press';\nexport const inputChange = 'input-change';\nexport const inputClear = 'input-clear';\nexport const inputBlur = 'input-blur';\nexport const inputPaste = 'input-paste';\nexport const inputPress = 'input-press';\nexport const focusOut = 'focus-out';\nexport const escapeKey = 'escape-key';\nexport const closeWatcher = 'close-watcher';\nexport const listNavigation = 'list-navigation';\nexport const keyboard = 'keyboard';\nexport const pointer = 'pointer';\nexport const drag = 'drag';\nexport const wheel = 'wheel';\nexport const scrub = 'scrub';\nexport const popupClose = 'popup-close';\nexport const cancelOpen = 'cancel-open';\nexport const siblingOpen = 'sibling-open';\nexport const disabled = 'disabled';\nexport const missing = 'missing';\nexport const initial = 'initial';\nexport const imperativeAction = 'imperative-action';\nexport const swipe = 'swipe';\nexport const windowResize = 'window-resize';","'use client';\n\nimport * as React from 'react';\nimport { SafeReact } from \"./safeReact.mjs\";\nimport { useForcedRerendering } from \"./useForcedRerendering.mjs\";\nlet globalId = 0;\n\n// TODO React 17: Remove `useGlobalId` once React 17 support is removed\nfunction useGlobalId(idOverride, prefix = 'mui') {\n const defaultId = React.useRef(undefined);\n const forceRerender = useForcedRerendering();\n const id = idOverride ?? defaultId.current;\n React.useEffect(() => {\n if (defaultId.current == null) {\n // Fallback to this default id when possible.\n // Use the incrementing value for client-side rendering only.\n // We can't use it server-side.\n // If you want to use random values please consider the Birthday Problem: https://en.wikipedia.org/wiki/Birthday_problem\n globalId += 1;\n defaultId.current = `${prefix}-${globalId}`;\n // Generate the fallback even while `idOverride` is set.\n // Removing the override then swaps in the existing id within the same commit.\n // Deferring generation would leave one commit with no id, breaking `htmlFor` and `aria-labelledby` links.\n // Only rerender when the fallback is the value being rendered.\n if (idOverride == null) {\n forceRerender();\n }\n }\n }, [idOverride, prefix, forceRerender]);\n return id;\n}\nconst maybeReactUseId = SafeReact.useId;\n\n/**\n *\n * @example <div id={useId()} />\n * @param {string | undefined} idOverride overrides the generated id when provided\n * @param {string | undefined} prefix prefixes the generated id when provided\n * @returns {string | undefined}\n */\nexport function useId(idOverride, prefix) {\n // React.useId() is only available from React 18.0.0.\n if (maybeReactUseId !== undefined) {\n const reactId = maybeReactUseId();\n return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);\n }\n\n // TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler\n // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.\n return useGlobalId(idOverride, prefix);\n}","'use client';\n\nimport { useId } from '@base-ui/utils/useId';\n\n/**\n * Wraps `useId` and prefixes generated `id`s with `base-ui-`\n * @param {string | undefined} idOverride overrides the generated id when provided\n * @returns {string | undefined}\n */\nexport function useBaseUiId(idOverride) {\n return useId(idOverride, 'base-ui');\n}"],"names":[],"mappings":";;AAAA,SAAS,YAAY;AACnB,SAAO,OAAO,WAAW;AAC3B;AACA,SAAS,YAAY,MAAM;AACzB,MAAI,OAAO,IAAI,GAAG;AAChB,YAAQ,KAAK,YAAY,IAAI,YAAW;AAAA,EAC1C;AAIA,SAAO;AACT;AACA,SAAS,UAAU,MAAM;AACvB,MAAI;AACJ,UAAQ,QAAQ,SAAS,sBAAsB,KAAK,kBAAkB,OAAO,SAAS,oBAAoB,gBAAgB;AAC5H;AACA,SAAS,mBAAmB,MAAM;AAChC,MAAI;AACJ,UAAQ,QAAQ,OAAO,IAAI,IAAI,KAAK,gBAAgB,KAAK,aAAa,OAAO,aAAa,OAAO,SAAS,KAAK;AACjH;AACA,SAAS,OAAO,OAAO;AACrB,MAAI,CAAC,UAAS,GAAI;AAChB,WAAO;AAAA,EACT;AACA,SAAO,iBAAiB,QAAQ,iBAAiB,UAAU,KAAK,EAAE;AACpE;AACA,SAAS,UAAU,OAAO;AAC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,SAAO;AACT;AACA,MAAM,kBAAkB,UAAU;AAS3B,SAAS,MAAM,YAAY,QAAQ;AAExC,MAAI,oBAAoB,QAAW;AACjC,UAAM,UAAU,gBAAe;AAC/B,WAAO,eAAe,SAAS,GAAG,MAAM,IAAI,OAAO,KAAK;AAAA,EAC1D;AAIA,SAAO,YAAY,YAAY,MAAM;AACvC;ACzCO,SAAS,YAAY,YAAY;AACtC,SAAO,MAAM,YAAY,SAAS;AACpC;","x_google_ignoreList":[0,1,2,3,4,5]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { b as getWindow, i as isHTMLElement } from "./useBaseUiId-
|
|
2
|
+
import { b as getWindow, i as isHTMLElement } from "./useBaseUiId-DCE1GVlg.js";
|
|
3
3
|
import { f as formatErrorMessage, S as SafeReact, u as useIsoLayoutEffect, m as mergeProps, h as makeEventPreventable, a as useStableCallback } from "./useIsoLayoutEffect-D2lpsB9D.js";
|
|
4
4
|
import { e as error } from "./error-nCTLdGUr.js";
|
|
5
5
|
const CompositeRootContext = /* @__PURE__ */ React.createContext(void 0);
|
|
@@ -232,4 +232,4 @@ export {
|
|
|
232
232
|
dispatchClickWithModifiers as d,
|
|
233
233
|
useCompositeRootContext as u
|
|
234
234
|
};
|
|
235
|
-
//# sourceMappingURL=useButton-
|
|
235
|
+
//# sourceMappingURL=useButton-CtXDdeoI.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useButton-BlHadUfM.js","sources":["../node_modules/@base-ui/react/internals/composite/root/CompositeRootContext.mjs","../node_modules/@base-ui/react/utils/useFocusableWhenDisabled.mjs","../node_modules/@base-ui/react/utils/dispatchClickWithModifiers.mjs","../node_modules/@base-ui/react/internals/use-button/useButton.mjs"],"sourcesContent":["'use client';\n\nimport _formatErrorMessage from \"@base-ui/utils/formatErrorMessage\";\nimport * as React from 'react';\nexport const CompositeRootContext = /*#__PURE__*/React.createContext(undefined);\nif (process.env.NODE_ENV !== \"production\") CompositeRootContext.displayName = \"CompositeRootContext\";\nexport function useCompositeRootContext(optional = false) {\n const context = React.useContext(CompositeRootContext);\n if (context === undefined && !optional) {\n throw new Error(process.env.NODE_ENV !== \"production\" ? 'Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>.' : _formatErrorMessage(16));\n }\n return context;\n}","'use client';\n\nimport * as React from 'react';\nexport function useFocusableWhenDisabled(parameters) {\n const {\n focusableWhenDisabled,\n disabled,\n composite = false,\n tabIndex: tabIndexProp = 0,\n isNativeButton\n } = parameters;\n const isFocusableComposite = composite && focusableWhenDisabled !== false;\n const isNonFocusableComposite = composite && focusableWhenDisabled === false;\n\n // we can't explicitly assign `undefined` to any of these props because it\n // would otherwise prevent subsequently merged props from setting them\n const props = React.useMemo(() => {\n const additionalProps = {\n // allow Tabbing away from focusableWhenDisabled elements\n onKeyDown(event) {\n if (disabled && focusableWhenDisabled && event.key !== 'Tab') {\n event.preventDefault();\n }\n }\n };\n if (!composite) {\n additionalProps.tabIndex = tabIndexProp;\n if (!isNativeButton && disabled) {\n additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;\n }\n }\n if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled) {\n additionalProps['aria-disabled'] = disabled;\n }\n if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) {\n additionalProps.disabled = disabled;\n }\n return additionalProps;\n }, [composite, disabled, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]);\n return {\n props\n };\n}","import { ownerWindow } from '@base-ui/utils/owner';\n/**\n * Dispatches a constructed click on the target so it carries the source event's\n * modifier state, which `click()` always reports as unpressed. Like `click()`,\n * the untrusted click still runs native activation behavior (form submission,\n * link navigation).\n * `detail` defaults to 0 and `pointerType` to `''` (the native convention for\n * keyboard-generated clicks). When the click represents a mouse gesture, pass\n * `detail: 1` and `pointerType: 'mouse'` so consumers don't classify it as a\n * keyboard activation.\n */\nexport function dispatchClickWithModifiers(target, sourceEvent, {\n detail = 0,\n pointerType = ''\n} = {}) {\n target.dispatchEvent(new (ownerWindow(target).PointerEvent)('click', {\n bubbles: true,\n cancelable: true,\n composed: true,\n detail,\n pointerType,\n shiftKey: sourceEvent.shiftKey,\n ctrlKey: sourceEvent.ctrlKey,\n altKey: sourceEvent.altKey,\n metaKey: sourceEvent.metaKey\n }));\n}","'use client';\n\nimport * as React from 'react';\nimport { isHTMLElement } from '@floating-ui/utils/dom';\nimport { useStableCallback } from '@base-ui/utils/useStableCallback';\nimport { error } from '@base-ui/utils/error';\nimport { SafeReact } from '@base-ui/utils/safeReact';\nimport { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';\nimport { makeEventPreventable, mergeProps } from \"../../merge-props/index.mjs\";\nimport { useCompositeRootContext } from \"../composite/root/CompositeRootContext.mjs\";\nimport { useFocusableWhenDisabled } from \"../../utils/useFocusableWhenDisabled.mjs\";\nimport { dispatchClickWithModifiers } from \"../../utils/dispatchClickWithModifiers.mjs\";\nexport function useButton(parameters = {}) {\n const {\n disabled = false,\n focusableWhenDisabled,\n tabIndex = 0,\n native: isNativeButton = true,\n composite: compositeProp\n } = parameters;\n const elementRef = React.useRef(null);\n const compositeRootContext = useCompositeRootContext(true);\n const isCompositeItem = compositeProp ?? compositeRootContext !== undefined;\n const {\n props: focusableWhenDisabledProps\n } = useFocusableWhenDisabled({\n focusableWhenDisabled,\n disabled,\n composite: isCompositeItem,\n tabIndex,\n isNativeButton\n });\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (!elementRef.current) {\n return;\n }\n const isButtonTag = isButtonElement(elementRef.current);\n if (isNativeButton) {\n if (!isButtonTag) {\n const ownerStackMessage = SafeReact.captureOwnerStack?.() || '';\n const message = 'A component that acts as a button expected a native <button> because the ' + '`nativeButton` prop is true. Rendering a non-<button> removes native button ' + 'semantics, which can impact forms and accessibility. Use a real <button> in the ' + '`render` prop, or set `nativeButton` to `false`.';\n error(`${message}${ownerStackMessage}`);\n }\n } else if (isButtonTag) {\n const ownerStackMessage = SafeReact.captureOwnerStack?.() || '';\n const message = 'A component that acts as a button expected a non-<button> because the `nativeButton` ' + 'prop is false. Rendering a <button> keeps native behavior while Base UI applies ' + 'non-native attributes and handlers, which can add unintended extra attributes (such ' + 'as `role` or `aria-disabled`). Use a non-<button> in the `render` prop, or set ' + '`nativeButton` to `true`.';\n error(`${message}${ownerStackMessage}`);\n }\n }, [isNativeButton]);\n }\n\n // handles a disabled composite button rendering another button, e.g.\n // <Toolbar.Button disabled render={<Menu.Trigger />} />\n // the `disabled` prop needs to pass through 2 `useButton`s then finally\n // delete the `disabled` attribute from DOM\n const updateDisabled = React.useCallback(() => {\n const element = elementRef.current;\n if (!isButtonElement(element)) {\n return;\n }\n if (isCompositeItem && disabled && focusableWhenDisabledProps.disabled === undefined && element.disabled) {\n element.disabled = false;\n }\n }, [disabled, focusableWhenDisabledProps.disabled, isCompositeItem]);\n useIsoLayoutEffect(updateDisabled, [updateDisabled]);\n const getButtonProps = React.useCallback((externalProps = {}) => {\n const {\n onClick: externalOnClick,\n onMouseDown: externalOnMouseDown,\n onKeyUp: externalOnKeyUp,\n onKeyDown: externalOnKeyDown,\n onPointerDown: externalOnPointerDown,\n ...otherExternalProps\n } = externalProps;\n return mergeProps({\n onClick(event) {\n if (disabled) {\n event.preventDefault();\n return;\n }\n externalOnClick?.(event);\n },\n onMouseDown(event) {\n if (!disabled) {\n externalOnMouseDown?.(event);\n }\n },\n onKeyDown(event) {\n if (disabled) {\n return;\n }\n makeEventPreventable(event);\n externalOnKeyDown?.(event);\n if (event.baseUIHandlerPrevented) {\n return;\n }\n const isCurrentTarget = event.target === event.currentTarget;\n const currentTarget = event.currentTarget;\n const isButton = isButtonElement(currentTarget);\n const isLink = !isNativeButton && isValidLinkElement(currentTarget);\n const shouldClick = isCurrentTarget && (isNativeButton ? isButton : !isLink);\n const isEnterKey = event.key === 'Enter';\n const isSpaceKey = event.key === ' ';\n const role = currentTarget.getAttribute('role');\n const isTextNavigationRole = role?.startsWith('menuitem') || role === 'option' || role === 'gridcell';\n if (isCurrentTarget && isCompositeItem && isSpaceKey) {\n if (event.defaultPrevented && isTextNavigationRole) {\n return;\n }\n event.preventDefault();\n\n // Only a native-mode item that isn't a real <button> is excluded.\n if (!isNativeButton || isButton) {\n event.preventBaseUIHandler();\n dispatchClickWithModifiers(currentTarget, event);\n }\n return;\n }\n\n // Keyboard accessibility for native and non-native elements.\n if (!shouldClick || isNativeButton || !isSpaceKey && !isEnterKey) {\n // Space activates links on keyup (`role=\"button\"` semantics, matching the\n // composite path); prevent the page scroll Space would otherwise trigger.\n // Enter is left to the browser's native link activation.\n if (isCurrentTarget && isLink && isSpaceKey) {\n event.preventDefault();\n }\n return;\n }\n\n // Match native buttons: preventing the keydown's default cancels activation.\n if (event.defaultPrevented) {\n return;\n }\n event.preventDefault();\n if (isEnterKey) {\n event.preventBaseUIHandler();\n dispatchClickWithModifiers(currentTarget, event);\n }\n },\n onKeyUp(event) {\n if (disabled) {\n return;\n }\n\n // calling preventDefault in keyUp on a <button> will not dispatch a click event if Space is pressed\n // https://codesandbox.io/p/sandbox/button-keyup-preventdefault-dn7f0\n makeEventPreventable(event);\n externalOnKeyUp?.(event);\n if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === ' ') {\n event.preventDefault();\n return;\n }\n if (event.baseUIHandlerPrevented) {\n return;\n }\n\n // Keyboard accessibility for non interactive elements.\n // Match native buttons: preventing the keyup's default cancels Space activation.\n // Limitation: unlike a native <button>, a prevented *keydown* cannot cancel the\n // activation — no state is kept between keydown and keyup, so we can't tell\n // whether the keydown was prevented or even happened on this element.\n if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && !event.defaultPrevented && event.key === ' ') {\n event.preventBaseUIHandler();\n dispatchClickWithModifiers(event.currentTarget, event);\n }\n },\n onPointerDown(event) {\n if (disabled) {\n event.preventDefault();\n return;\n }\n externalOnPointerDown?.(event);\n }\n }, isNativeButton ? {\n type: 'button'\n } : {\n role: 'button'\n }, focusableWhenDisabledProps, otherExternalProps);\n }, [disabled, focusableWhenDisabledProps, isCompositeItem, isNativeButton]);\n const buttonRef = useStableCallback(element => {\n elementRef.current = element;\n updateDisabled();\n });\n return {\n getButtonProps,\n buttonRef\n };\n}\nfunction isButtonElement(elem) {\n return isHTMLElement(elem) && elem.tagName === 'BUTTON';\n}\nfunction isValidLinkElement(elem) {\n return isHTMLElement(elem) && elem.tagName === 'A' && Boolean(elem.href);\n}"],"names":["_formatErrorMessage","ownerWindow"],"mappings":";;;;AAIY,MAAC,uBAAoC,sBAAM,cAAc,MAAS;AAC9E,IAAI,QAAQ,IAAI,aAAa,aAAc,sBAAqB,cAAc;AACvE,SAAS,wBAAwB,WAAW,OAAO;AACxD,QAAM,UAAU,MAAM,WAAW,oBAAoB;AACrD,MAAI,YAAY,UAAa,CAAC,UAAU;AACtC,UAAM,IAAI,MAAM,QAAQ,IAAI,aAAa,eAAe,sGAAsGA,mBAAoB,EAAE,CAAC;AAAA,EACvL;AACA,SAAO;AACT;ACTO,SAAS,yBAAyB,YAAY;AACnD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,UAAU,eAAe;AAAA,IACzB;AAAA,EACJ,IAAM;AACJ,QAAM,uBAAuB,aAAa,0BAA0B;AACpE,QAAM,0BAA0B,aAAa,0BAA0B;AAIvE,QAAM,QAAQ,MAAM,QAAQ,MAAM;AAChC,UAAM,kBAAkB;AAAA;AAAA,MAEtB,UAAU,OAAO;AACf,YAAI,YAAY,yBAAyB,MAAM,QAAQ,OAAO;AAC5D,gBAAM,eAAc;AAAA,QACtB;AAAA,MACF;AAAA,IACN;AACI,QAAI,CAAC,WAAW;AACd,sBAAgB,WAAW;AAC3B,UAAI,CAAC,kBAAkB,UAAU;AAC/B,wBAAgB,WAAW,wBAAwB,eAAe;AAAA,MAC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AAA,QACvD;AAAA,MACF;AAAA,MACA,cAAc,OAAO;AACnB,YAAI,UAAU;AACZ,gBAAM,eAAc;AACpB;AAAA,QACF;AACA,uEAAwB;AAAA,MAC1B;AAAA,IACN,GAAO,iBAAiB;AAAA,MAClB,MAAM;AAAA,IACZ,IAAQ;AAAA,MACF,MAAM;AAAA,IACZ,GAAO,4BAA4B,kBAAkB;AAAA,EACnD,GAAG,CAAC,UAAU,4BAA4B,iBAAiB,cAAc,CAAC;AAC1E,QAAM,YAAY,kBAAkB,aAAW;AAC7C,eAAW,UAAU;AACrB,mBAAc;AAAA,EAChB,CAAC;AACD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACJ;AACA;AACA,SAAS,gBAAgB,MAAM;AAC7B,SAAO,cAAc,IAAI,KAAK,KAAK,YAAY;AACjD;AACA,SAAS,mBAAmB,MAAM;AAChC,SAAO,cAAc,IAAI,KAAK,KAAK,YAAY,OAAO,QAAQ,KAAK,IAAI;AACzE;","x_google_ignoreList":[0,1,2,3]}
|
|
1
|
+
{"version":3,"file":"useButton-CtXDdeoI.js","sources":["../node_modules/@base-ui/react/internals/composite/root/CompositeRootContext.mjs","../node_modules/@base-ui/react/utils/useFocusableWhenDisabled.mjs","../node_modules/@base-ui/react/utils/dispatchClickWithModifiers.mjs","../node_modules/@base-ui/react/internals/use-button/useButton.mjs"],"sourcesContent":["'use client';\n\nimport _formatErrorMessage from \"@base-ui/utils/formatErrorMessage\";\nimport * as React from 'react';\nexport const CompositeRootContext = /*#__PURE__*/React.createContext(undefined);\nif (process.env.NODE_ENV !== \"production\") CompositeRootContext.displayName = \"CompositeRootContext\";\nexport function useCompositeRootContext(optional = false) {\n const context = React.useContext(CompositeRootContext);\n if (context === undefined && !optional) {\n throw new Error(process.env.NODE_ENV !== \"production\" ? 'Base UI: CompositeRootContext is missing. Composite parts must be placed within <Composite.Root>.' : _formatErrorMessage(16));\n }\n return context;\n}","'use client';\n\nimport * as React from 'react';\nexport function useFocusableWhenDisabled(parameters) {\n const {\n focusableWhenDisabled,\n disabled,\n composite = false,\n tabIndex: tabIndexProp = 0,\n isNativeButton\n } = parameters;\n const isFocusableComposite = composite && focusableWhenDisabled !== false;\n const isNonFocusableComposite = composite && focusableWhenDisabled === false;\n\n // we can't explicitly assign `undefined` to any of these props because it\n // would otherwise prevent subsequently merged props from setting them\n const props = React.useMemo(() => {\n const additionalProps = {\n // allow Tabbing away from focusableWhenDisabled elements\n onKeyDown(event) {\n if (disabled && focusableWhenDisabled && event.key !== 'Tab') {\n event.preventDefault();\n }\n }\n };\n if (!composite) {\n additionalProps.tabIndex = tabIndexProp;\n if (!isNativeButton && disabled) {\n additionalProps.tabIndex = focusableWhenDisabled ? tabIndexProp : -1;\n }\n }\n if (isNativeButton && (focusableWhenDisabled || isFocusableComposite) || !isNativeButton && disabled) {\n additionalProps['aria-disabled'] = disabled;\n }\n if (isNativeButton && (!focusableWhenDisabled || isNonFocusableComposite)) {\n additionalProps.disabled = disabled;\n }\n return additionalProps;\n }, [composite, disabled, focusableWhenDisabled, isFocusableComposite, isNonFocusableComposite, isNativeButton, tabIndexProp]);\n return {\n props\n };\n}","import { ownerWindow } from '@base-ui/utils/owner';\n/**\n * Dispatches a constructed click on the target so it carries the source event's\n * modifier state, which `click()` always reports as unpressed. Like `click()`,\n * the untrusted click still runs native activation behavior (form submission,\n * link navigation).\n * `detail` defaults to 0 and `pointerType` to `''` (the native convention for\n * keyboard-generated clicks). When the click represents a mouse gesture, pass\n * `detail: 1` and `pointerType: 'mouse'` so consumers don't classify it as a\n * keyboard activation.\n */\nexport function dispatchClickWithModifiers(target, sourceEvent, {\n detail = 0,\n pointerType = ''\n} = {}) {\n target.dispatchEvent(new (ownerWindow(target).PointerEvent)('click', {\n bubbles: true,\n cancelable: true,\n composed: true,\n detail,\n pointerType,\n shiftKey: sourceEvent.shiftKey,\n ctrlKey: sourceEvent.ctrlKey,\n altKey: sourceEvent.altKey,\n metaKey: sourceEvent.metaKey\n }));\n}","'use client';\n\nimport * as React from 'react';\nimport { isHTMLElement } from '@floating-ui/utils/dom';\nimport { useStableCallback } from '@base-ui/utils/useStableCallback';\nimport { error } from '@base-ui/utils/error';\nimport { SafeReact } from '@base-ui/utils/safeReact';\nimport { useIsoLayoutEffect } from '@base-ui/utils/useIsoLayoutEffect';\nimport { makeEventPreventable, mergeProps } from \"../../merge-props/index.mjs\";\nimport { useCompositeRootContext } from \"../composite/root/CompositeRootContext.mjs\";\nimport { useFocusableWhenDisabled } from \"../../utils/useFocusableWhenDisabled.mjs\";\nimport { dispatchClickWithModifiers } from \"../../utils/dispatchClickWithModifiers.mjs\";\nexport function useButton(parameters = {}) {\n const {\n disabled = false,\n focusableWhenDisabled,\n tabIndex = 0,\n native: isNativeButton = true,\n composite: compositeProp\n } = parameters;\n const elementRef = React.useRef(null);\n const compositeRootContext = useCompositeRootContext(true);\n const isCompositeItem = compositeProp ?? compositeRootContext !== undefined;\n const {\n props: focusableWhenDisabledProps\n } = useFocusableWhenDisabled({\n focusableWhenDisabled,\n disabled,\n composite: isCompositeItem,\n tabIndex,\n isNativeButton\n });\n if (process.env.NODE_ENV !== 'production') {\n // eslint-disable-next-line react-hooks/rules-of-hooks\n React.useEffect(() => {\n if (!elementRef.current) {\n return;\n }\n const isButtonTag = isButtonElement(elementRef.current);\n if (isNativeButton) {\n if (!isButtonTag) {\n const ownerStackMessage = SafeReact.captureOwnerStack?.() || '';\n const message = 'A component that acts as a button expected a native <button> because the ' + '`nativeButton` prop is true. Rendering a non-<button> removes native button ' + 'semantics, which can impact forms and accessibility. Use a real <button> in the ' + '`render` prop, or set `nativeButton` to `false`.';\n error(`${message}${ownerStackMessage}`);\n }\n } else if (isButtonTag) {\n const ownerStackMessage = SafeReact.captureOwnerStack?.() || '';\n const message = 'A component that acts as a button expected a non-<button> because the `nativeButton` ' + 'prop is false. Rendering a <button> keeps native behavior while Base UI applies ' + 'non-native attributes and handlers, which can add unintended extra attributes (such ' + 'as `role` or `aria-disabled`). Use a non-<button> in the `render` prop, or set ' + '`nativeButton` to `true`.';\n error(`${message}${ownerStackMessage}`);\n }\n }, [isNativeButton]);\n }\n\n // handles a disabled composite button rendering another button, e.g.\n // <Toolbar.Button disabled render={<Menu.Trigger />} />\n // the `disabled` prop needs to pass through 2 `useButton`s then finally\n // delete the `disabled` attribute from DOM\n const updateDisabled = React.useCallback(() => {\n const element = elementRef.current;\n if (!isButtonElement(element)) {\n return;\n }\n if (isCompositeItem && disabled && focusableWhenDisabledProps.disabled === undefined && element.disabled) {\n element.disabled = false;\n }\n }, [disabled, focusableWhenDisabledProps.disabled, isCompositeItem]);\n useIsoLayoutEffect(updateDisabled, [updateDisabled]);\n const getButtonProps = React.useCallback((externalProps = {}) => {\n const {\n onClick: externalOnClick,\n onMouseDown: externalOnMouseDown,\n onKeyUp: externalOnKeyUp,\n onKeyDown: externalOnKeyDown,\n onPointerDown: externalOnPointerDown,\n ...otherExternalProps\n } = externalProps;\n return mergeProps({\n onClick(event) {\n if (disabled) {\n event.preventDefault();\n return;\n }\n externalOnClick?.(event);\n },\n onMouseDown(event) {\n if (!disabled) {\n externalOnMouseDown?.(event);\n }\n },\n onKeyDown(event) {\n if (disabled) {\n return;\n }\n makeEventPreventable(event);\n externalOnKeyDown?.(event);\n if (event.baseUIHandlerPrevented) {\n return;\n }\n const isCurrentTarget = event.target === event.currentTarget;\n const currentTarget = event.currentTarget;\n const isButton = isButtonElement(currentTarget);\n const isLink = !isNativeButton && isValidLinkElement(currentTarget);\n const shouldClick = isCurrentTarget && (isNativeButton ? isButton : !isLink);\n const isEnterKey = event.key === 'Enter';\n const isSpaceKey = event.key === ' ';\n const role = currentTarget.getAttribute('role');\n const isTextNavigationRole = role?.startsWith('menuitem') || role === 'option' || role === 'gridcell';\n if (isCurrentTarget && isCompositeItem && isSpaceKey) {\n if (event.defaultPrevented && isTextNavigationRole) {\n return;\n }\n event.preventDefault();\n\n // Only a native-mode item that isn't a real <button> is excluded.\n if (!isNativeButton || isButton) {\n event.preventBaseUIHandler();\n dispatchClickWithModifiers(currentTarget, event);\n }\n return;\n }\n\n // Keyboard accessibility for native and non-native elements.\n if (!shouldClick || isNativeButton || !isSpaceKey && !isEnterKey) {\n // Space activates links on keyup (`role=\"button\"` semantics, matching the\n // composite path); prevent the page scroll Space would otherwise trigger.\n // Enter is left to the browser's native link activation.\n if (isCurrentTarget && isLink && isSpaceKey) {\n event.preventDefault();\n }\n return;\n }\n\n // Match native buttons: preventing the keydown's default cancels activation.\n if (event.defaultPrevented) {\n return;\n }\n event.preventDefault();\n if (isEnterKey) {\n event.preventBaseUIHandler();\n dispatchClickWithModifiers(currentTarget, event);\n }\n },\n onKeyUp(event) {\n if (disabled) {\n return;\n }\n\n // calling preventDefault in keyUp on a <button> will not dispatch a click event if Space is pressed\n // https://codesandbox.io/p/sandbox/button-keyup-preventdefault-dn7f0\n makeEventPreventable(event);\n externalOnKeyUp?.(event);\n if (event.target === event.currentTarget && isNativeButton && isCompositeItem && isButtonElement(event.currentTarget) && event.key === ' ') {\n event.preventDefault();\n return;\n }\n if (event.baseUIHandlerPrevented) {\n return;\n }\n\n // Keyboard accessibility for non interactive elements.\n // Match native buttons: preventing the keyup's default cancels Space activation.\n // Limitation: unlike a native <button>, a prevented *keydown* cannot cancel the\n // activation — no state is kept between keydown and keyup, so we can't tell\n // whether the keydown was prevented or even happened on this element.\n if (event.target === event.currentTarget && !isNativeButton && !isCompositeItem && !event.defaultPrevented && event.key === ' ') {\n event.preventBaseUIHandler();\n dispatchClickWithModifiers(event.currentTarget, event);\n }\n },\n onPointerDown(event) {\n if (disabled) {\n event.preventDefault();\n return;\n }\n externalOnPointerDown?.(event);\n }\n }, isNativeButton ? {\n type: 'button'\n } : {\n role: 'button'\n }, focusableWhenDisabledProps, otherExternalProps);\n }, [disabled, focusableWhenDisabledProps, isCompositeItem, isNativeButton]);\n const buttonRef = useStableCallback(element => {\n elementRef.current = element;\n updateDisabled();\n });\n return {\n getButtonProps,\n buttonRef\n };\n}\nfunction isButtonElement(elem) {\n return isHTMLElement(elem) && elem.tagName === 'BUTTON';\n}\nfunction isValidLinkElement(elem) {\n return isHTMLElement(elem) && elem.tagName === 'A' && Boolean(elem.href);\n}"],"names":["_formatErrorMessage","ownerWindow"],"mappings":";;;;AAIY,MAAC,uBAAoC,sBAAM,cAAc,MAAS;AAC9E,IAAI,QAAQ,IAAI,aAAa,aAAc,sBAAqB,cAAc;AACvE,SAAS,wBAAwB,WAAW,OAAO;AACxD,QAAM,UAAU,MAAM,WAAW,oBAAoB;AACrD,MAAI,YAAY,UAAa,CAAC,UAAU;AACtC,UAAM,IAAI,MAAM,QAAQ,IAAI,aAAa,eAAe,sGAAsGA,mBAAoB,EAAE,CAAC;AAAA,EACvL;AACA,SAAO;AACT;ACTO,SAAS,yBAAyB,YAAY;AACnD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,UAAU,eAAe;AAAA,IACzB;AAAA,EACJ,IAAM;AACJ,QAAM,uBAAuB,aAAa,0BAA0B;AACpE,QAAM,0BAA0B,aAAa,0BAA0B;AAIvE,QAAM,QAAQ,MAAM,QAAQ,MAAM;AAChC,UAAM,kBAAkB;AAAA;AAAA,MAEtB,UAAU,OAAO;AACf,YAAI,YAAY,yBAAyB,MAAM,QAAQ,OAAO;AAC5D,gBAAM,eAAc;AAAA,QACtB;AAAA,MACF;AAAA,IACN;AACI,QAAI,CAAC,WAAW;AACd,sBAAgB,WAAW;AAC3B,UAAI,CAAC,kBAAkB,UAAU;AAC/B,wBAAgB,WAAW,wBAAwB,eAAe;AAAA,MACpE;AAAA,IACF;AACA,QAAI,mBAAmB,yBAAyB,yBAAyB,CAAC,kBAAkB,UAAU;AACpG,sBAAgB,eAAe,IAAI;AAAA,IACrC;AACA,QAAI,mBAAmB,CAAC,yBAAyB,0BAA0B;AACzE,sBAAgB,WAAW;AAAA,IAC7B;AACA,WAAO;AAAA,EACT,GAAG,CAAC,WAAW,UAAU,uBAAuB,sBAAsB,yBAAyB,gB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AAC,UAAU,4BAA4B,iBAAiB,cAAc,CAAC;AAC1E,QAAM,YAAY,kBAAkB,aAAW;AAC7C,eAAW,UAAU;AACrB,mBAAc;AAAA,EAChB,CAAC;AACD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACJ;AACA;AACA,SAAS,gBAAgB,MAAM;AAC7B,SAAO,cAAc,IAAI,KAAK,KAAK,YAAY;AACjD;AACA,SAAS,mBAAmB,MAAM;AAChC,SAAO,cAAc,IAAI,KAAK,KAAK,YAAY,OAAO,QAAQ,KAAK,IAAI;AACzE;","x_google_ignoreList":[0,1,2,3]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { a as addEventListener } from "./addEventListener-D-i9O6BG.js";
|
|
3
|
-
import { O as mergeCleanups, w as webkit, W as createAttribute } from "./usePopupHandleStore-
|
|
4
|
-
import { o as ownerDocument, e as isTargetInsideEnabledTrigger, b as isTypeableElement, m as matchesFocusVisible } from "./element-
|
|
3
|
+
import { O as mergeCleanups, w as webkit, W as createAttribute } from "./usePopupHandleStore-9hGUXtn5.js";
|
|
4
|
+
import { o as ownerDocument, e as isTargetInsideEnabledTrigger, b as isTypeableElement, m as matchesFocusVisible } from "./element-BI1c88Lp.js";
|
|
5
5
|
import { u as useTimeout } from "./useTimeout-D1vYJgq4.js";
|
|
6
|
-
import { b as getWindow, A as isElement, c as createChangeEventDetails,
|
|
7
|
-
import { a as activeElement, c as contains, g as getTarget } from "./constants-
|
|
8
|
-
import { m as mac } from "./composite-
|
|
6
|
+
import { b as getWindow, A as isElement, c as createChangeEventDetails, I as triggerFocus, i as isHTMLElement, t as triggerPress, r as escapeKey } from "./useBaseUiId-DCE1GVlg.js";
|
|
7
|
+
import { a as activeElement, c as contains, g as getTarget } from "./constants-BzjgA7aT.js";
|
|
8
|
+
import { m as mac } from "./composite-Dzn8P1fl.js";
|
|
9
9
|
const isMacSafari = mac && webkit;
|
|
10
10
|
function useFocus(store, props = {}) {
|
|
11
11
|
const {
|
|
@@ -134,4 +134,4 @@ function useFocus(store, props = {}) {
|
|
|
134
134
|
export {
|
|
135
135
|
useFocus as u
|
|
136
136
|
};
|
|
137
|
-
//# sourceMappingURL=useFocus-
|
|
137
|
+
//# sourceMappingURL=useFocus-BGyXJhul.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useFocus-C__7iwl1.js","sources":["../node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { addEventListener } from '@base-ui/utils/addEventListener';\nimport { platform } from '@base-ui/utils/platform';\nimport { mergeCleanups } from '@base-ui/utils/mergeCleanups';\nimport { ownerDocument } from '@base-ui/utils/owner';\nimport { useTimeout } from '@base-ui/utils/useTimeout';\nimport { getWindow, isElement, isHTMLElement } from '@floating-ui/utils/dom';\nimport { createAttribute } from \"../utils/createAttribute.mjs\";\nimport { activeElement, contains, getTarget, isTargetInsideEnabledTrigger, isTypeableElement, matchesFocusVisible } from \"../utils/element.mjs\";\nimport { createChangeEventDetails } from \"../../internals/createBaseUIEventDetails.mjs\";\nimport { REASONS } from \"../../internals/reasons.mjs\";\nconst isMacSafari = platform.os.mac && platform.engine.webkit;\n/**\n * Opens the floating element while the reference element has focus, like CSS\n * `:focus`.\n * @see https://floating-ui.com/docs/useFocus\n */\nexport function useFocus(store, props = {}) {\n const {\n enabled = true,\n delay\n } = props;\n const {\n events,\n dataRef\n } = store.context;\n const blockFocusRef = React.useRef(false);\n // Track which reference should be blocked from re-opening after Escape/press dismissal.\n const blockedReferenceRef = React.useRef(null);\n const keyboardModalityRef = React.useRef(true);\n const timeout = useTimeout();\n React.useEffect(() => {\n const domReference = store.select('domReferenceElement');\n if (!enabled) {\n return undefined;\n }\n const win = getWindow(domReference);\n\n // If the reference was focused and the user left the tab/window, and the\n // floating element was not open, the focus should be blocked when they\n // return to the tab/window.\n function onBlur() {\n const currentDomReference = store.select('domReferenceElement');\n if (!store.select('open') && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {\n blockFocusRef.current = true;\n blockedReferenceRef.current = currentDomReference;\n }\n }\n function onKeyDown() {\n keyboardModalityRef.current = true;\n }\n function onPointerDown() {\n keyboardModalityRef.current = false;\n }\n return mergeCleanups(addEventListener(win, 'blur', onBlur), isMacSafari && addEventListener(win, 'keydown', onKeyDown, true), isMacSafari && addEventListener(win, 'pointerdown', onPointerDown, true));\n }, [store, enabled]);\n React.useEffect(() => {\n if (!enabled) {\n return undefined;\n }\n function onOpenChangeLocal(details) {\n if (details.reason === REASONS.triggerPress || details.reason === REASONS.escapeKey) {\n const referenceElement = store.select('domReferenceElement');\n if (isElement(referenceElement)) {\n blockedReferenceRef.current = referenceElement;\n blockFocusRef.current = true;\n }\n }\n }\n events.on('openchange', onOpenChangeLocal);\n return () => {\n events.off('openchange', onOpenChangeLocal);\n };\n }, [events, enabled, store]);\n const reference = React.useMemo(() => {\n function resetBlockedFocus() {\n blockFocusRef.current = false;\n blockedReferenceRef.current = null;\n }\n return {\n onMouseLeave() {\n resetBlockedFocus();\n },\n onFocus(event) {\n const focusTarget = event.currentTarget;\n if (blockFocusRef.current) {\n if (blockedReferenceRef.current === focusTarget) {\n return;\n }\n resetBlockedFocus();\n }\n const target = getTarget(event.nativeEvent);\n if (isElement(target)) {\n // Safari fails to match `:focus-visible` if focus was initially\n // outside the document.\n if (isMacSafari && !event.relatedTarget) {\n if (!keyboardModalityRef.current && !isTypeableElement(target)) {\n return;\n }\n } else if (!matchesFocusVisible(target)) {\n return;\n }\n }\n const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);\n const {\n nativeEvent,\n currentTarget\n } = event;\n if (store.select('open') && movedFromOtherEnabledTrigger || !delay) {\n store.setOpen(true, createChangeEventDetails(REASONS.triggerFocus, nativeEvent, currentTarget));\n return;\n }\n timeout.start(delay, () => {\n if (blockFocusRef.current) {\n return;\n }\n store.setOpen(true, createChangeEventDetails(REASONS.triggerFocus, nativeEvent, currentTarget));\n });\n },\n onBlur(event) {\n resetBlockedFocus();\n const relatedTarget = event.relatedTarget;\n const nativeEvent = event.nativeEvent;\n\n // Hit the non-modal focus management portal guard. Focus will be\n // moved into the floating element immediately after.\n const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute('focus-guard')) && relatedTarget.getAttribute('data-type') === 'outside';\n\n // Wait for the window blur listener to fire.\n timeout.start(0, () => {\n const domReference = store.select('domReferenceElement');\n const activeEl = activeElement(ownerDocument(domReference));\n\n // Focus left the page, keep it open.\n if (!relatedTarget && activeEl === domReference) {\n return;\n }\n\n // When focusing the reference element (e.g. regular click), then\n // clicking into the floating element, prevent it from hiding.\n // Note: it must be focusable, e.g. `tabindex=\"-1\"`.\n // We can not rely on relatedTarget to point to the correct element\n // as it will only point to the shadow host of the newly focused element\n // and not the element that actually has received focus if it is located\n // inside a shadow root.\n if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {\n return;\n }\n\n // If the next focused element is one of the triggers, do not close\n // the floating element. The focus handler of that trigger will\n // handle the open state.\n const nextFocusedElement = relatedTarget ?? activeEl;\n if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {\n return;\n }\n store.setOpen(false, createChangeEventDetails(REASONS.triggerFocus, nativeEvent));\n });\n }\n };\n }, [dataRef, delay, store, timeout]);\n return React.useMemo(() => enabled ? {\n reference,\n trigger: reference\n } : {}, [enabled, reference]);\n}"],"names":["platform.os.mac","platform.engine.webkit","REASONS.triggerPress","REASONS.escapeKey","REASONS.triggerFocus"],"mappings":";;;;;;;;AAaA,MAAM,cAAcA,OAAmBC;AAMhC,SAAS,SAAS,OAAO,QAAQ,IAAI;AAC1C,QAAM;AAAA,IACJ,UAAU;AAAA,IACV;AAAA,EACJ,IAAM;AACJ,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,EACJ,IAAM,MAAM;A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AO,qBAAqB;AACvD,gBAAM,WAAW,cAAc,cAAc,YAAY,CAAC;AAG1D,cAAI,CAAC,iBAAiB,aAAa,cAAc;AAC/C;AAAA,UACF;AASA,cAAI,UAAS,aAAQ,QAAQ,oBAAhB,mBAAiC,KAAK,SAAS,SAAS,QAAQ,KAAK,SAAS,cAAc,QAAQ,KAAK,mBAAmB;AACvI;AAAA,UACF;AAKA,gBAAM,qBAAqB,iBAAiB;AAC5C,cAAI,6BAA6B,oBAAoB,MAAM,QAAQ,eAAe,GAAG;AACnF;AAAA,UACF;AACA,gBAAM,QAAQ,OAAO,yBAAyBA,cAAsB,WAAW,CAAC;AAAA,QAClF,CAAC;AAAA,MACH;AAAA,IACN;AAAA,EACE,GAAG,CAAC,SAAS,OAAO,OAAO,OAAO,CAAC;AACnC,SAAO,MAAM,QAAQ,MAAM,UAAU;AAAA,IACnC;AAAA,IACA,SAAS;AAAA,EACb,IAAM,IAAI,CAAC,SAAS,SAAS,CAAC;AAC9B;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"useFocus-BGyXJhul.js","sources":["../node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\nimport { addEventListener } from '@base-ui/utils/addEventListener';\nimport { platform } from '@base-ui/utils/platform';\nimport { mergeCleanups } from '@base-ui/utils/mergeCleanups';\nimport { ownerDocument } from '@base-ui/utils/owner';\nimport { useTimeout } from '@base-ui/utils/useTimeout';\nimport { getWindow, isElement, isHTMLElement } from '@floating-ui/utils/dom';\nimport { createAttribute } from \"../utils/createAttribute.mjs\";\nimport { activeElement, contains, getTarget, isTargetInsideEnabledTrigger, isTypeableElement, matchesFocusVisible } from \"../utils/element.mjs\";\nimport { createChangeEventDetails } from \"../../internals/createBaseUIEventDetails.mjs\";\nimport { REASONS } from \"../../internals/reasons.mjs\";\nconst isMacSafari = platform.os.mac && platform.engine.webkit;\n/**\n * Opens the floating element while the reference element has focus, like CSS\n * `:focus`.\n * @see https://floating-ui.com/docs/useFocus\n */\nexport function useFocus(store, props = {}) {\n const {\n enabled = true,\n delay\n } = props;\n const {\n events,\n dataRef\n } = store.context;\n const blockFocusRef = React.useRef(false);\n // Track which reference should be blocked from re-opening after Escape/press dismissal.\n const blockedReferenceRef = React.useRef(null);\n const keyboardModalityRef = React.useRef(true);\n const timeout = useTimeout();\n React.useEffect(() => {\n const domReference = store.select('domReferenceElement');\n if (!enabled) {\n return undefined;\n }\n const win = getWindow(domReference);\n\n // If the reference was focused and the user left the tab/window, and the\n // floating element was not open, the focus should be blocked when they\n // return to the tab/window.\n function onBlur() {\n const currentDomReference = store.select('domReferenceElement');\n if (!store.select('open') && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {\n blockFocusRef.current = true;\n blockedReferenceRef.current = currentDomReference;\n }\n }\n function onKeyDown() {\n keyboardModalityRef.current = true;\n }\n function onPointerDown() {\n keyboardModalityRef.current = false;\n }\n return mergeCleanups(addEventListener(win, 'blur', onBlur), isMacSafari && addEventListener(win, 'keydown', onKeyDown, true), isMacSafari && addEventListener(win, 'pointerdown', onPointerDown, true));\n }, [store, enabled]);\n React.useEffect(() => {\n if (!enabled) {\n return undefined;\n }\n function onOpenChangeLocal(details) {\n if (details.reason === REASONS.triggerPress || details.reason === REASONS.escapeKey) {\n const referenceElement = store.select('domReferenceElement');\n if (isElement(referenceElement)) {\n blockedReferenceRef.current = referenceElement;\n blockFocusRef.current = true;\n }\n }\n }\n events.on('openchange', onOpenChangeLocal);\n return () => {\n events.off('openchange', onOpenChangeLocal);\n };\n }, [events, enabled, store]);\n const reference = React.useMemo(() => {\n function resetBlockedFocus() {\n blockFocusRef.current = false;\n blockedReferenceRef.current = null;\n }\n return {\n onMouseLeave() {\n resetBlockedFocus();\n },\n onFocus(event) {\n const focusTarget = event.currentTarget;\n if (blockFocusRef.current) {\n if (blockedReferenceRef.current === focusTarget) {\n return;\n }\n resetBlockedFocus();\n }\n const target = getTarget(event.nativeEvent);\n if (isElement(target)) {\n // Safari fails to match `:focus-visible` if focus was initially\n // outside the document.\n if (isMacSafari && !event.relatedTarget) {\n if (!keyboardModalityRef.current && !isTypeableElement(target)) {\n return;\n }\n } else if (!matchesFocusVisible(target)) {\n return;\n }\n }\n const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);\n const {\n nativeEvent,\n currentTarget\n } = event;\n if (store.select('open') && movedFromOtherEnabledTrigger || !delay) {\n store.setOpen(true, createChangeEventDetails(REASONS.triggerFocus, nativeEvent, currentTarget));\n return;\n }\n timeout.start(delay, () => {\n if (blockFocusRef.current) {\n return;\n }\n store.setOpen(true, createChangeEventDetails(REASONS.triggerFocus, nativeEvent, currentTarget));\n });\n },\n onBlur(event) {\n resetBlockedFocus();\n const relatedTarget = event.relatedTarget;\n const nativeEvent = event.nativeEvent;\n\n // Hit the non-modal focus management portal guard. Focus will be\n // moved into the floating element immediately after.\n const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute('focus-guard')) && relatedTarget.getAttribute('data-type') === 'outside';\n\n // Wait for the window blur listener to fire.\n timeout.start(0, () => {\n const domReference = store.select('domReferenceElement');\n const activeEl = activeElement(ownerDocument(domReference));\n\n // Focus left the page, keep it open.\n if (!relatedTarget && activeEl === domReference) {\n return;\n }\n\n // When focusing the reference element (e.g. regular click), then\n // clicking into the floating element, prevent it from hiding.\n // Note: it must be focusable, e.g. `tabindex=\"-1\"`.\n // We can not rely on relatedTarget to point to the correct element\n // as it will only point to the shadow host of the newly focused element\n // and not the element that actually has received focus if it is located\n // inside a shadow root.\n if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {\n return;\n }\n\n // If the next focused element is one of the triggers, do not close\n // the floating element. The focus handler of that trigger will\n // handle the open state.\n const nextFocusedElement = relatedTarget ?? activeEl;\n if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {\n return;\n }\n store.setOpen(false, createChangeEventDetails(REASONS.triggerFocus, nativeEvent));\n });\n }\n };\n }, [dataRef, delay, store, timeout]);\n return React.useMemo(() => enabled ? {\n reference,\n trigger: reference\n } : {}, [enabled, reference]);\n}"],"names":["platform.os.mac","platform.engine.webkit","REASONS.triggerPress","REASONS.escapeKey","REASONS.triggerFocus"],"mappings":";;;;;;;;AAaA,MAAM,cAAcA,OAAmBC;AAMhC,SAAS,SAAS,OAAO,QAAQ,IAAI;AAC1C,QAAM;AAAA,IACJ,UAAU;AAAA,IACV;AAAA,EACJ,IAAM;AACJ,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,EACJ,IAAM,MAAM;AACV,QAAM,gBAAgB,MAAM,OAAO,KAAK;AAExC,QAAM,sBAAsB,MAAM,OAAO,IAAI;AAC7C,QAAM,sBAAsB,MAAM,OAAO,IAAI;AAC7C,QAAM,UAAU,WAAU;AAC1B,QAAM,UAAU,MAAM;AACpB,UAAM,eAAe,MAAM,OAAO,qBAAqB;AACvD,QAAI,CAAC,SAAS;AACZ,aAAO;AAAA,IACT;AACA,UAAM,MAAM,UAAU,YAAY;AAKlC,aAAS,SAAS;AAChB,YAAM,sBAAsB,MAAM,OAAO,qBAAqB;AAC9D,UAAI,CAAC,MAAM,OAAO,MAAM,KAAK,cAAc,mBAAmB,KAAK,wBAAwB,cAAc,cAAc,mBAAmB,CAAC,GAAG;AAC5I,sBAAc,UAAU;AACxB,4BAAoB,UAAU;AAAA,MAChC;AAAA,IACF;AACA,aAAS,YAAY;AACnB,0BAAoB,UAAU;AAAA,IAChC;AACA,aAAS,gBAAgB;AACvB,0BAAoB,UAAU;AAAA,IAChC;AACA,WAAO,cAAc,iBAAiB,KAAK,QAAQ,MAAM,GAAG,eAAe,iBAAiB,KAAK,WAAW,WAAW,IAAI,GAAG,eAAe,iBAAiB,KAAK,eAAe,eAAe,IAAI,CAAC;AAAA,EACxM,GAAG,CAAC,OAAO,OAAO,CAAC;AACnB,QAAM,UAA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AAAA,QACF;AACA,gBAAQ,MAAM,OAAO,MAAM;AACzB,cAAI,cAAc,SAAS;AACzB;AAAA,UACF;AACA,gBAAM,QAAQ,MAAM,yBAAyBA,cAAsB,aAAa,aAAa,CAAC;AAAA,QAChG,CAAC;AAAA,MACH;AAAA,MACA,OAAO,OAAO;AACZ,0BAAiB;AACjB,cAAM,gBAAgB,MAAM;AAC5B,cAAM,cAAc,MAAM;AAI1B,cAAM,oBAAoB,UAAU,aAAa,KAAK,cAAc,aAAa,gBAAgB,aAAa,CAAC,KAAK,cAAc,aAAa,WAAW,MAAM;AAGhK,gBAAQ,MAAM,GAAG,MAAM;;AACrB,gBAAM,eAAe,MAAM,OAAO,qBAAqB;AACvD,gBAAM,WAAW,cAAc,cAAc,YAAY,CAAC;AAG1D,cAAI,CAAC,iBAAiB,aAAa,cAAc;AAC/C;AAAA,UACF;AASA,cAAI,UAAS,aAAQ,QAAQ,oBAAhB,mBAAiC,KAAK,SAAS,SAAS,QAAQ,KAAK,SAAS,cAAc,QAAQ,KAAK,mBAAmB;AACvI;AAAA,UACF;AAKA,gBAAM,qBAAqB,iBAAiB;AAC5C,cAAI,6BAA6B,oBAAoB,MAAM,QAAQ,eAAe,GAAG;AACnF;AAAA,UACF;AACA,gBAAM,QAAQ,OAAO,yBAAyBA,cAAsB,WAAW,CAAC;AAAA,QAClF,CAAC;AAAA,MACH;AAAA,IACN;AAAA,EACE,GAAG,CAAC,SAAS,OAAO,OAAO,OAAO,CAAC;AACnC,SAAO,MAAM,QAAQ,MAAM,UAAU;AAAA,IACnC;AAAA,IACA,SAAS;AAAA,EACb,IAAM,IAAI,CAAC,SAAS,SAAS,CAAC;AAC9B;","x_google_ignoreList":[0]}
|
|
@@ -6,14 +6,14 @@ import { t as transitionStatusMapping, u as useTransitionStatus, a as useOpenCha
|
|
|
6
6
|
import * as React from "react";
|
|
7
7
|
import React__default from "react";
|
|
8
8
|
import * as ReactDOM from "react-dom";
|
|
9
|
-
import { i as isHTMLElement, M as getNodeName, N as isShadowRoot, g as getComputedStyle, j as useId, O as isNode, c as createChangeEventDetails, s as focusOut, t as triggerPress, r as escapeKey, A as isElement, h as isLastTraversableNode, f as getParentNode, v as outsidePress, e as useForcedRerendering, n as none,
|
|
9
|
+
import { i as isHTMLElement, M as getNodeName, N as isShadowRoot, g as getComputedStyle, j as useId, O as isNode, c as createChangeEventDetails, s as focusOut, t as triggerPress, r as escapeKey, A as isElement, h as isLastTraversableNode, f as getParentNode, v as outsidePress, e as useForcedRerendering, n as none, H as triggerHover, I as triggerFocus } from "./useBaseUiId-DCE1GVlg.js";
|
|
10
10
|
import { a as addEventListener } from "./addEventListener-D-i9O6BG.js";
|
|
11
11
|
import { e as useRefWithInit, i as isReactVersionAtLeast, u as useIsoLayoutEffect, a as useStableCallback, N as NOOP, b as useRenderElement, d as EMPTY_OBJECT } from "./useIsoLayoutEffect-D2lpsB9D.js";
|
|
12
12
|
import { a as visuallyHidden } from "./visuallyHidden-B6H2X3_Y.js";
|
|
13
13
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
14
|
-
import { n as apple,
|
|
15
|
-
import { s as shimExports, o as ownerDocument, c as isEventTargetWithin, d as isRootElement } from "./element-
|
|
16
|
-
import { h as lowerUserAgent, c as contains, a as activeElement, g as getTarget, F as FOCUSABLE_ATTRIBUTE } from "./constants-
|
|
14
|
+
import { n as apple, j as isElementVisible, o as isReactEvent, f as isVirtualClick, p as isClickLikeEvent } from "./composite-Dzn8P1fl.js";
|
|
15
|
+
import { s as shimExports, o as ownerDocument, c as isEventTargetWithin, d as isRootElement } from "./element-BI1c88Lp.js";
|
|
16
|
+
import { h as lowerUserAgent, c as contains, a as activeElement, g as getTarget, F as FOCUSABLE_ATTRIBUTE } from "./constants-BzjgA7aT.js";
|
|
17
17
|
import { u as useTimeout, T as Timeout } from "./useTimeout-D1vYJgq4.js";
|
|
18
18
|
var withSelector = { exports: {} };
|
|
19
19
|
var withSelector_production = {};
|
|
@@ -2275,22 +2275,22 @@ function usePopupHandleStore(handle) {
|
|
|
2275
2275
|
}
|
|
2276
2276
|
export {
|
|
2277
2277
|
isTabbable as $,
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2278
|
+
fastComponentRef as A,
|
|
2279
|
+
usePopupHandleStore as B,
|
|
2280
|
+
useTriggerDataForwarding as C,
|
|
2281
2281
|
DROPDOWN_COLLISION_AVOIDANCE as D,
|
|
2282
|
-
|
|
2282
|
+
FocusGuard as E,
|
|
2283
2283
|
FOCUSABLE_POPUP_PROPS as F,
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2284
|
+
PATIENT_CLICK_THRESHOLD as G,
|
|
2285
|
+
useTriggerRegistration as H,
|
|
2286
|
+
voiceOver as I,
|
|
2287
|
+
FloatingRootStore as J,
|
|
2288
2288
|
createDefaultInitialFocus as K,
|
|
2289
2289
|
usePopupRootStore as L,
|
|
2290
2290
|
usePopupRootSync as M,
|
|
2291
2291
|
CLICK_TRIGGER_IDENTIFIER as N,
|
|
2292
2292
|
mergeCleanups as O,
|
|
2293
|
-
|
|
2293
|
+
POPUP_COLLISION_AVOIDANCE as P,
|
|
2294
2294
|
getNodeChildren as Q,
|
|
2295
2295
|
ReactStore as R,
|
|
2296
2296
|
DISABLED_TRANSITIONS_STYLE as S,
|
|
@@ -2311,26 +2311,26 @@ export {
|
|
|
2311
2311
|
FloatingPortal as c,
|
|
2312
2312
|
popupStateMapping as d,
|
|
2313
2313
|
useFloatingParentNodeId as e,
|
|
2314
|
-
|
|
2314
|
+
useFloatingTree as f,
|
|
2315
2315
|
gecko as g,
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2316
|
+
popupTransitionStateMapping as h,
|
|
2317
|
+
FloatingNode as i,
|
|
2318
|
+
popupStoreSelectors as j,
|
|
2319
|
+
FloatingTreeStore as k,
|
|
2320
|
+
createInitialPopupStoreState as l,
|
|
2321
|
+
PopupTriggerMap as m,
|
|
2322
|
+
fastComponent as n,
|
|
2323
|
+
useFloatingNodeId as o,
|
|
2324
2324
|
pressableTriggerOpenStateMapping as p,
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2325
|
+
useImplicitActiveTrigger as q,
|
|
2326
|
+
useOpenStateTransitions as r,
|
|
2327
|
+
createPopupOpenState as s,
|
|
2328
2328
|
triggerOpenStateMapping as t,
|
|
2329
2329
|
useUnmountAfterClose as u,
|
|
2330
|
-
|
|
2330
|
+
useSyncedFloatingRootContext as v,
|
|
2331
2331
|
webkit as w,
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
|
|
2332
|
+
usePopupInteractionProps as x,
|
|
2333
|
+
PopupHandleAttachment as y,
|
|
2334
|
+
FloatingTree as z
|
|
2335
2335
|
};
|
|
2336
|
-
//# sourceMappingURL=usePopupHandleStore-
|
|
2336
|
+
//# sourceMappingURL=usePopupHandleStore-9hGUXtn5.js.map
|