@stackone/malachite 2.100.1 → 2.101.1
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/COMPONENTS.md +2 -1
- package/dist/ShadowRootWrapper.js +15 -14
- package/dist/ShadowRootWrapper.js.map +1 -1
- package/dist/components/KeyValueList.js +30 -32
- package/dist/components/KeyValueList.js.map +1 -1
- package/dist/components/KeyValueStrip.js +66 -0
- package/dist/components/KeyValueStrip.js.map +1 -0
- package/dist/components/Tooltip.js +42 -42
- package/dist/components/Tooltip.js.map +1 -1
- package/dist/components/Typography/EllipsisText.js +33 -29
- package/dist/components/Typography/EllipsisText.js.map +1 -1
- package/dist/components/childrenText.js +9 -0
- package/dist/components/childrenText.js.map +1 -0
- package/dist/components/droppedFocus.js +35 -0
- package/dist/components/droppedFocus.js.map +1 -0
- package/dist/components/overlayBehaviour.js +77 -76
- package/dist/components/overlayBehaviour.js.map +1 -1
- package/dist/index.d.ts +40 -2
- package/dist/index.js +390 -388
- package/dist/index.js.map +1 -1
- package/dist/tailwind.css.js +1 -1
- package/package.json +1 -1
|
@@ -1,48 +1,52 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import
|
|
4
|
-
import { getFontWeight as
|
|
5
|
-
const
|
|
6
|
-
children:
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as S } from "react";
|
|
3
|
+
import w from "../Tooltip.js";
|
|
4
|
+
import { getFontWeight as y, getFontSize as v, getTextColor as b } from "./textStyles.js";
|
|
5
|
+
const R = ({
|
|
6
|
+
children: f,
|
|
7
7
|
tooltip: t,
|
|
8
|
-
maxWidth:
|
|
9
|
-
color:
|
|
10
|
-
size:
|
|
11
|
-
fontWeight:
|
|
12
|
-
tooltipWhenTruncated:
|
|
8
|
+
maxWidth: c = "100%",
|
|
9
|
+
color: p = "primary",
|
|
10
|
+
size: l,
|
|
11
|
+
fontWeight: o,
|
|
12
|
+
tooltipWhenTruncated: r = !1,
|
|
13
13
|
tooltipPlacement: a,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
tooltipDelay: m,
|
|
15
|
+
focusableTrigger: d,
|
|
16
|
+
inline: u = !1,
|
|
17
|
+
className: h = "",
|
|
18
|
+
style: x = {}
|
|
17
19
|
}) => {
|
|
18
|
-
const
|
|
19
|
-
color:
|
|
20
|
-
...
|
|
21
|
-
...
|
|
22
|
-
maxWidth:
|
|
20
|
+
const g = {
|
|
21
|
+
color: b(p),
|
|
22
|
+
...l ? { fontSize: v(l) } : {},
|
|
23
|
+
...o ? { fontWeight: y(o) } : {},
|
|
24
|
+
maxWidth: c,
|
|
23
25
|
overflow: "hidden",
|
|
24
26
|
whiteSpace: "nowrap",
|
|
25
27
|
textOverflow: "ellipsis",
|
|
26
28
|
display: "inline-block",
|
|
27
29
|
verticalAlign: "top",
|
|
28
|
-
...
|
|
29
|
-
},
|
|
30
|
-
return t ? /* @__PURE__ */
|
|
31
|
-
|
|
30
|
+
...x
|
|
31
|
+
}, i = S(null), n = /* @__PURE__ */ s("span", { ref: i, className: h, style: g, children: f });
|
|
32
|
+
return t ? /* @__PURE__ */ s(
|
|
33
|
+
w,
|
|
32
34
|
{
|
|
33
35
|
text: t,
|
|
34
36
|
placement: a,
|
|
35
|
-
|
|
37
|
+
delay: m,
|
|
38
|
+
focusableTrigger: d && !r,
|
|
39
|
+
inline: u,
|
|
36
40
|
isShrinkable: !0,
|
|
37
|
-
shouldShow:
|
|
38
|
-
const e =
|
|
41
|
+
shouldShow: r ? () => {
|
|
42
|
+
const e = i.current;
|
|
39
43
|
return !!e && e.scrollWidth > e.clientWidth;
|
|
40
44
|
} : void 0,
|
|
41
|
-
children:
|
|
45
|
+
children: n
|
|
42
46
|
}
|
|
43
|
-
) :
|
|
47
|
+
) : n;
|
|
44
48
|
};
|
|
45
49
|
export {
|
|
46
|
-
|
|
50
|
+
R as default
|
|
47
51
|
};
|
|
48
52
|
//# sourceMappingURL=EllipsisText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EllipsisText.js","sources":["../../../src/components/Typography/EllipsisText.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport Tooltip from '../Tooltip';\nimport type { TextColor } from './Text';\nimport type { FontSize, FontWeight } from './textStyles';\nimport { getFontSize, getFontWeight, getTextColor } from './textStyles';\n\nexport interface EllipsisTextProps {\n children: React.ReactNode;\n tooltip?: React.ReactNode | string;\n /**\n * Defaults to filling the container. Pass a fixed width only when the text should\n * truncate before its container runs out of room (e.g. a column with a hard cap).\n */\n maxWidth?: string;\n color?: TextColor;\n size?: FontSize;\n fontWeight?: FontWeight;\n /**\n * Show `tooltip` only when the text is actually cut off. Opt-in, because `tooltip` is any\n * node: a caller repeating the label wants this, and one supplying something the label does\n * not say — a full path, a timestamp — would lose it.\n */\n tooltipWhenTruncated?: boolean;\n tooltipPlacement?: 'top' | 'bottom' | 'left' | 'right';\n /** A span around the text, for a place a div may not go, such as inside a clickable `Surface.Row`. */\n inline?: boolean;\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst EllipsisText: React.FC<EllipsisTextProps> = ({\n children,\n tooltip,\n maxWidth = '100%',\n color = 'primary',\n size,\n fontWeight,\n tooltipWhenTruncated = false,\n tooltipPlacement,\n inline = false,\n className = '',\n style = {},\n}) => {\n const ellipsisStyles: React.CSSProperties = {\n color: getTextColor(color),\n ...(size ? { fontSize: getFontSize(size) } : {}),\n ...(fontWeight ? { fontWeight: getFontWeight(fontWeight) } : {}),\n maxWidth,\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n display: 'inline-block',\n verticalAlign: 'top',\n ...style,\n };\n\n const textRef = useRef<HTMLSpanElement>(null);\n\n const textElement = (\n <span ref={textRef} className={className} style={ellipsisStyles}>\n {children}\n </span>\n );\n\n if (tooltip) {\n // Measured on hover, not at mount: what fits depends on the container and on webfonts\n // that land after `DOMContentLoaded`, so a value read once is wrong for the rest of the\n // page's life.\n // Without `isShrinkable` the tooltip wrapper is floored at min-content and a percentage `maxWidth` never truncates.\n return (\n <Tooltip\n text={tooltip}\n placement={tooltipPlacement}\n inline={inline}\n isShrinkable\n shouldShow={\n tooltipWhenTruncated\n ? () => {\n const node = textRef.current;\n return !!node && node.scrollWidth > node.clientWidth;\n }\n : undefined\n }\n >\n {textElement}\n </Tooltip>\n );\n }\n\n return textElement;\n};\n\nexport default EllipsisText;\n"],"names":["EllipsisText","children","tooltip","maxWidth","color","size","fontWeight","tooltipWhenTruncated","tooltipPlacement","inline","className","style","ellipsisStyles","getTextColor","getFontSize","getFontWeight","textRef","useRef","textElement","jsx","Tooltip","node"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"EllipsisText.js","sources":["../../../src/components/Typography/EllipsisText.tsx"],"sourcesContent":["import React, { useRef } from 'react';\nimport Tooltip from '../Tooltip';\nimport type { TextColor } from './Text';\nimport type { FontSize, FontWeight } from './textStyles';\nimport { getFontSize, getFontWeight, getTextColor } from './textStyles';\n\nexport interface EllipsisTextProps {\n children: React.ReactNode;\n tooltip?: React.ReactNode | string;\n /**\n * Defaults to filling the container. Pass a fixed width only when the text should\n * truncate before its container runs out of room (e.g. a column with a hard cap).\n */\n maxWidth?: string;\n color?: TextColor;\n size?: FontSize;\n fontWeight?: FontWeight;\n /**\n * Show `tooltip` only when the text is actually cut off. Opt-in, because `tooltip` is any\n * node: a caller repeating the label wants this, and one supplying something the label does\n * not say — a full path, a timestamp — would lose it.\n */\n tooltipWhenTruncated?: boolean;\n tooltipPlacement?: 'top' | 'bottom' | 'left' | 'right';\n /** Seconds before the tooltip opens. */\n tooltipDelay?: number;\n /** Makes the text a tab stop that opens the tooltip. Ignored with `tooltipWhenTruncated`. */\n focusableTrigger?: boolean;\n /** A span around the text, for a place a div may not go, such as inside a clickable `Surface.Row`. */\n inline?: boolean;\n className?: string;\n style?: React.CSSProperties;\n}\n\nconst EllipsisText: React.FC<EllipsisTextProps> = ({\n children,\n tooltip,\n maxWidth = '100%',\n color = 'primary',\n size,\n fontWeight,\n tooltipWhenTruncated = false,\n tooltipPlacement,\n tooltipDelay,\n focusableTrigger,\n inline = false,\n className = '',\n style = {},\n}) => {\n const ellipsisStyles: React.CSSProperties = {\n color: getTextColor(color),\n ...(size ? { fontSize: getFontSize(size) } : {}),\n ...(fontWeight ? { fontWeight: getFontWeight(fontWeight) } : {}),\n maxWidth,\n overflow: 'hidden',\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n display: 'inline-block',\n verticalAlign: 'top',\n ...style,\n };\n\n const textRef = useRef<HTMLSpanElement>(null);\n\n const textElement = (\n <span ref={textRef} className={className} style={ellipsisStyles}>\n {children}\n </span>\n );\n\n if (tooltip) {\n // Measured on hover, not at mount: what fits depends on the container and on webfonts\n // that land after `DOMContentLoaded`, so a value read once is wrong for the rest of the\n // page's life.\n // Without `isShrinkable` the tooltip wrapper is floored at min-content and a percentage `maxWidth` never truncates.\n return (\n <Tooltip\n text={tooltip}\n placement={tooltipPlacement}\n delay={tooltipDelay}\n focusableTrigger={focusableTrigger && !tooltipWhenTruncated}\n inline={inline}\n isShrinkable\n shouldShow={\n tooltipWhenTruncated\n ? () => {\n const node = textRef.current;\n return !!node && node.scrollWidth > node.clientWidth;\n }\n : undefined\n }\n >\n {textElement}\n </Tooltip>\n );\n }\n\n return textElement;\n};\n\nexport default EllipsisText;\n"],"names":["EllipsisText","children","tooltip","maxWidth","color","size","fontWeight","tooltipWhenTruncated","tooltipPlacement","tooltipDelay","focusableTrigger","inline","className","style","ellipsisStyles","getTextColor","getFontSize","getFontWeight","textRef","useRef","textElement","jsx","Tooltip","node"],"mappings":";;;;AAkCA,MAAMA,IAA4C,CAAC;AAAA,EAC/C,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,OAAAC,IAAQ;AAAA,EACR,MAAAC;AAAA,EACA,YAAAC;AAAA,EACA,sBAAAC,IAAuB;AAAA,EACvB,kBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,kBAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,WAAAC,IAAY;AAAA,EACZ,OAAAC,IAAQ,CAAA;AACZ,MAAM;AACF,QAAMC,IAAsC;AAAA,IACxC,OAAOC,EAAaX,CAAK;AAAA,IACzB,GAAIC,IAAO,EAAE,UAAUW,EAAYX,CAAI,EAAA,IAAM,CAAA;AAAA,IAC7C,GAAIC,IAAa,EAAE,YAAYW,EAAcX,CAAU,EAAA,IAAM,CAAA;AAAA,IAC7D,UAAAH;AAAA,IACA,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,cAAc;AAAA,IACd,SAAS;AAAA,IACT,eAAe;AAAA,IACf,GAAGU;AAAA,EAAA,GAGDK,IAAUC,EAAwB,IAAI,GAEtCC,sBACD,QAAA,EAAK,KAAKF,GAAS,WAAAN,GAAsB,OAAOE,GAC5C,UAAAb,GACL;AAGJ,SAAIC,IAMI,gBAAAmB;AAAA,IAACC;AAAA,IAAA;AAAA,MACG,MAAMpB;AAAA,MACN,WAAWM;AAAA,MACX,OAAOC;AAAA,MACP,kBAAkBC,KAAoB,CAACH;AAAA,MACvC,QAAAI;AAAA,MACA,cAAY;AAAA,MACZ,YACIJ,IACM,MAAM;AACF,cAAMgB,IAAOL,EAAQ;AACrB,eAAO,CAAC,CAACK,KAAQA,EAAK,cAAcA,EAAK;AAAA,MAC7C,IACA;AAAA,MAGT,UAAAH;AAAA,IAAA;AAAA,EAAA,IAKNA;AACX;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Children as e } from "react";
|
|
2
|
+
const o = (t) => typeof t == "string" || typeof t == "number", i = (t) => {
|
|
3
|
+
const r = e.toArray(t);
|
|
4
|
+
return r.length > 0 && r.every(o) ? r.join("") : void 0;
|
|
5
|
+
};
|
|
6
|
+
export {
|
|
7
|
+
i as textOf
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=childrenText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"childrenText.js","sources":["../../src/components/childrenText.ts"],"sourcesContent":["import { Children } from 'react';\nimport type React from 'react';\n\nconst isText = (node: React.ReactNode): node is string | number =>\n typeof node === 'string' || typeof node === 'number';\n\n/** The children as one string when every child is text. */\nexport const textOf = (children: React.ReactNode): string | undefined => {\n const parts = Children.toArray(children);\n return parts.length > 0 && parts.every(isText) ? parts.join('') : undefined;\n};\n"],"names":["isText","node","textOf","children","parts","Children"],"mappings":";AAGA,MAAMA,IAAS,CAACC,MACZ,OAAOA,KAAS,YAAY,OAAOA,KAAS,UAGnCC,IAAS,CAACC,MAAkD;AACrE,QAAMC,IAAQC,EAAS,QAAQF,CAAQ;AACvC,SAAOC,EAAM,SAAS,KAAKA,EAAM,MAAMJ,CAAM,IAAII,EAAM,KAAK,EAAE,IAAI;AACtE;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getDeepActiveNode as i, getDeepActiveElement as c } from "./activeElement.js";
|
|
2
|
+
let n = null;
|
|
3
|
+
const s = /* @__PURE__ */ new Set(["Alt", "Control", "Meta", "Shift"]), r = () => {
|
|
4
|
+
n = null, document.removeEventListener("pointerdown", d, !0), document.removeEventListener("keydown", u, !0);
|
|
5
|
+
}, l = (e, t) => {
|
|
6
|
+
const o = t.getBoundingClientRect();
|
|
7
|
+
return e.composedPath().includes(t) || e.clientX >= o.left && e.clientX <= o.right && e.clientY >= o.top && e.clientY <= o.bottom;
|
|
8
|
+
};
|
|
9
|
+
function d(e) {
|
|
10
|
+
(n === null || !l(e, n)) && r();
|
|
11
|
+
}
|
|
12
|
+
function u(e) {
|
|
13
|
+
!e.repeat && !s.has(e.key) && r();
|
|
14
|
+
}
|
|
15
|
+
const a = (e) => {
|
|
16
|
+
const [t] = e.relatedTarget === null ? e.composedPath() : [];
|
|
17
|
+
if (!(t instanceof HTMLElement && t.matches(":disabled"))) {
|
|
18
|
+
r();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
n = t, document.addEventListener("pointerdown", d, !0), document.addEventListener("keydown", u, !0);
|
|
22
|
+
}, f = () => {
|
|
23
|
+
typeof document < "u" && document.addEventListener("focusout", a, !0);
|
|
24
|
+
}, p = () => {
|
|
25
|
+
const e = i();
|
|
26
|
+
if (e !== null && e !== document.body)
|
|
27
|
+
return c();
|
|
28
|
+
const t = n;
|
|
29
|
+
return r(), t ?? c();
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
f as ensureDroppedFocusTracking,
|
|
33
|
+
p as focusReturnTarget
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=droppedFocus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"droppedFocus.js","sources":["../../src/components/droppedFocus.ts"],"sourcesContent":["import { getDeepActiveElement, getDeepActiveNode } from './activeElement';\n\n// A control disabled while focused (a Button that starts loading) drops focus to <body>\n// before the overlay it opens can record it, so the overlay would hand focus back to <body>.\nlet dropped: HTMLElement | null = null;\n\nconst MODIFIER_KEYS = new Set(['Alt', 'Control', 'Meta', 'Shift']);\n\nconst forget = (): void => {\n dropped = null;\n document.removeEventListener('pointerdown', handlePointerDown, true);\n document.removeEventListener('keydown', handleKeyDown, true);\n};\n\n// A press on the control again (a double-click, an impatient re-click) still belongs to the press\n// that disabled it, even where a browser sends it to an ancestor of the disabled control.\nconst pressesControl = (event: PointerEvent, control: HTMLElement): boolean => {\n const box = control.getBoundingClientRect();\n return (\n event.composedPath().includes(control) ||\n (event.clientX >= box.left &&\n event.clientX <= box.right &&\n event.clientY >= box.top &&\n event.clientY <= box.bottom)\n );\n};\n\n// The user acting again ends the interaction that disabled the control, so an overlay opened\n// later (a shortcut, a toast action) does not send focus back to it.\nfunction handlePointerDown(event: PointerEvent): void {\n if (dropped === null || !pressesControl(event, dropped)) {\n forget();\n }\n}\n\n// A held key repeating, or a lone modifier (a screen reader's Ctrl to stop speech), is not a new action.\nfunction handleKeyDown(event: KeyboardEvent): void {\n if (!event.repeat && !MODIFIER_KEYS.has(event.key)) {\n forget();\n }\n}\n\nconst handleFocusOut = (event: FocusEvent): void => {\n const [target] = event.relatedTarget === null ? event.composedPath() : [];\n if (!(target instanceof HTMLElement && target.matches(':disabled'))) {\n forget();\n return;\n }\n dropped = target;\n document.addEventListener('pointerdown', handlePointerDown, true);\n document.addEventListener('keydown', handleKeyDown, true);\n};\n\n/** Starts remembering a control that loses focus by turning disabled. Adding it again is a no-op. */\nexport const ensureDroppedFocusTracking = (): void => {\n if (typeof document !== 'undefined') {\n document.addEventListener('focusout', handleFocusOut, true);\n }\n};\n\n/**\n * The element an overlay opening now should hand focus back to: the focused one, or, when\n * focus sits on <body> because the control that opened it turned disabled, that control.\n */\nexport const focusReturnTarget = (): HTMLElement | null => {\n const node = getDeepActiveNode();\n if (node !== null && node !== document.body) {\n return getDeepActiveElement();\n }\n const control = dropped;\n // One overlay takes it: a later one opened in code must not reach back to it.\n forget();\n return control ?? getDeepActiveElement();\n};\n"],"names":["dropped","MODIFIER_KEYS","forget","handlePointerDown","handleKeyDown","pressesControl","event","control","box","handleFocusOut","target","ensureDroppedFocusTracking","focusReturnTarget","node","getDeepActiveNode","getDeepActiveElement"],"mappings":";AAIA,IAAIA,IAA8B;AAElC,MAAMC,wBAAoB,IAAI,CAAC,OAAO,WAAW,QAAQ,OAAO,CAAC,GAE3DC,IAAS,MAAY;AACvB,EAAAF,IAAU,MACV,SAAS,oBAAoB,eAAeG,GAAmB,EAAI,GACnE,SAAS,oBAAoB,WAAWC,GAAe,EAAI;AAC/D,GAIMC,IAAiB,CAACC,GAAqBC,MAAkC;AAC3E,QAAMC,IAAMD,EAAQ,sBAAA;AACpB,SACID,EAAM,eAAe,SAASC,CAAO,KACpCD,EAAM,WAAWE,EAAI,QAClBF,EAAM,WAAWE,EAAI,SACrBF,EAAM,WAAWE,EAAI,OACrBF,EAAM,WAAWE,EAAI;AAEjC;AAIA,SAASL,EAAkBG,GAA2B;AAClD,GAAIN,MAAY,QAAQ,CAACK,EAAeC,GAAON,CAAO,MAClDE,EAAA;AAER;AAGA,SAASE,EAAcE,GAA4B;AAC/C,EAAI,CAACA,EAAM,UAAU,CAACL,EAAc,IAAIK,EAAM,GAAG,KAC7CJ,EAAA;AAER;AAEA,MAAMO,IAAiB,CAACH,MAA4B;AAChD,QAAM,CAACI,CAAM,IAAIJ,EAAM,kBAAkB,OAAOA,EAAM,aAAA,IAAiB,CAAA;AACvE,MAAI,EAAEI,aAAkB,eAAeA,EAAO,QAAQ,WAAW,IAAI;AACjE,IAAAR,EAAA;AACA;AAAA,EACJ;AACA,EAAAF,IAAUU,GACV,SAAS,iBAAiB,eAAeP,GAAmB,EAAI,GAChE,SAAS,iBAAiB,WAAWC,GAAe,EAAI;AAC5D,GAGaO,IAA6B,MAAY;AAClD,EAAI,OAAO,WAAa,OACpB,SAAS,iBAAiB,YAAYF,GAAgB,EAAI;AAElE,GAMaG,IAAoB,MAA0B;AACvD,QAAMC,IAAOC,EAAA;AACb,MAAID,MAAS,QAAQA,MAAS,SAAS;AACnC,WAAOE,EAAA;AAEX,QAAMR,IAAUP;AAEhB,SAAAE,EAAA,GACOK,KAAWQ,EAAA;AACtB;"}
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { useSyncExternalStore as O, useRef as p, useCallback as L, useEffect as C, useLayoutEffect as g } from "react";
|
|
2
|
-
import { getDeepActiveElement as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
2
|
+
import { getDeepActiveElement as K, containsComposed as W } from "./activeElement.js";
|
|
3
|
+
import { ensureDroppedFocusTracking as $, focusReturnTarget as q } from "./droppedFocus.js";
|
|
4
|
+
import { pushEscapeLayer as J } from "./escapeLayers.js";
|
|
5
|
+
import { FOCUS_RING as Q } from "./focusRing.js";
|
|
6
|
+
import { nextLayerTicket as X, popupLayerHolding as tt } from "./overlayLayers.js";
|
|
7
|
+
import { useOwnedByPopover as et } from "./popoverTree.js";
|
|
8
|
+
import { OVERLAY_Z_BASE as U, ensureElevatedOverlayStyles as nt } from "./portalOverlay.js";
|
|
9
|
+
import { lockBodyScroll as rt } from "./scrollLock.js";
|
|
10
|
+
import { leaveTopLayer as V, raiseToTopLayer as B } from "./topLayer.js";
|
|
11
|
+
const kt = `flex shrink-0 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent p-[4px] text-[var(--malachite-text-secondary)] hover:text-[var(--malachite-text-primary)] transition-colors ${Q}`, ot = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])', st = (t) => t.assignedSlot ?? t.parentElement ?? (t.parentNode instanceof ShadowRoot ? t.parentNode.host : null), ct = (t) => Array.from(t.children).find((r) => r.tagName === "SUMMARY"), at = () => {
|
|
11
12
|
const t = /* @__PURE__ */ new Map(), r = (e) => {
|
|
12
13
|
const n = t.get(e);
|
|
13
14
|
if (n)
|
|
14
15
|
return n;
|
|
15
|
-
const { display: a, visibility: o, contentVisibility: s } = getComputedStyle(e), c =
|
|
16
|
+
const { display: a, visibility: o, contentVisibility: s } = getComputedStyle(e), c = st(e), d = c ? r(c) : null, f = c instanceof HTMLDetailsElement && !c.open && ct(c) !== e, h = {
|
|
16
17
|
hidden: e.hasAttribute("inert") || a === "none" || f || !!(d && (d.hidden || d.hidesContent)),
|
|
17
18
|
invisible: o === "hidden" || o === "collapse",
|
|
18
19
|
hidesContent: s === "hidden"
|
|
@@ -20,43 +21,43 @@ const Lt = `flex shrink-0 cursor-pointer items-center justify-center rounded-md
|
|
|
20
21
|
return t.set(e, h), h;
|
|
21
22
|
};
|
|
22
23
|
return r;
|
|
23
|
-
},
|
|
24
|
+
}, it = (t, r) => {
|
|
24
25
|
if (t.tabIndex < 0 || t.matches(":disabled"))
|
|
25
26
|
return !1;
|
|
26
27
|
const { hidden: e, invisible: n } = r(t);
|
|
27
28
|
return !e && !n;
|
|
28
|
-
},
|
|
29
|
-
if (!
|
|
29
|
+
}, G = (t) => t instanceof HTMLInputElement && t.type === "radio" && t.name !== "", ut = (t, r) => {
|
|
30
|
+
if (!G(t))
|
|
30
31
|
return !1;
|
|
31
32
|
const e = r.filter(
|
|
32
|
-
(n) =>
|
|
33
|
+
(n) => G(n) && n.name === t.name && n.form === t.form
|
|
33
34
|
);
|
|
34
35
|
return (e.find((n) => n.checked) ?? e[0]) !== t;
|
|
35
|
-
},
|
|
36
|
+
}, dt = (t, r) => t.map((e, n) => ({ element: e, index: n, tabIndex: r(e) })).sort((e, n) => e.tabIndex !== n.tabIndex ? e.tabIndex === 0 ? 1 : n.tabIndex === 0 ? -1 : e.tabIndex - n.tabIndex : e.index - n.index).map(({ element: e }) => e), w = (t) => t instanceof HTMLSlotElement && t.getRootNode() instanceof ShadowRoot, T = (t, r = []) => {
|
|
36
37
|
for (const e of t)
|
|
37
|
-
r.push(e), !e.shadowRoot && !
|
|
38
|
+
r.push(e), !e.shadowRoot && !w(e) && T(e.children, r);
|
|
38
39
|
return r;
|
|
39
40
|
}, R = (t, r) => {
|
|
40
41
|
const e = t.filter(
|
|
41
|
-
(o) => o instanceof HTMLElement && o.matches(
|
|
42
|
+
(o) => o instanceof HTMLElement && o.matches(ot) && it(o, r)
|
|
42
43
|
), n = new Set(
|
|
43
|
-
e.filter((o) => !
|
|
44
|
+
e.filter((o) => !ut(o, e))
|
|
44
45
|
), a = t.filter(
|
|
45
|
-
(o) => n.has(o) || o.shadowRoot ||
|
|
46
|
+
(o) => n.has(o) || o.shadowRoot || w(o)
|
|
46
47
|
);
|
|
47
|
-
return
|
|
48
|
+
return dt(
|
|
48
49
|
a,
|
|
49
50
|
(o) => n.has(o) ? o.tabIndex : 0
|
|
50
51
|
).flatMap((o) => {
|
|
51
|
-
if (
|
|
52
|
-
return R(
|
|
52
|
+
if (w(o))
|
|
53
|
+
return R(T(o.assignedElements({ flatten: !0 })), r);
|
|
53
54
|
const s = o.shadowRoot;
|
|
54
55
|
if (s && Number.parseInt(o.getAttribute("tabindex") ?? "", 10) < 0)
|
|
55
56
|
return [];
|
|
56
57
|
const c = n.has(o) && !(s != null && s.delegatesFocus) ? [o] : [];
|
|
57
|
-
return s ? [...c, ...R(
|
|
58
|
+
return s ? [...c, ...R(T(s.children), r)] : c;
|
|
58
59
|
});
|
|
59
|
-
}, D = (t) => R(
|
|
60
|
+
}, D = (t) => R(T(t.children), at()), ft = (t, r) => {
|
|
60
61
|
const e = (o) => {
|
|
61
62
|
const s = [o];
|
|
62
63
|
for (let c = o.getRootNode(); c instanceof ShadowRoot; c = c.host.getRootNode())
|
|
@@ -69,10 +70,10 @@ const Lt = `flex shrink-0 cursor-pointer items-center justify-center rounded-md
|
|
|
69
70
|
return o !== s ? o.compareDocumentPosition(s) : o === t ? Node.DOCUMENT_POSITION_FOLLOWING : Node.DOCUMENT_POSITION_PRECEDING;
|
|
70
71
|
}
|
|
71
72
|
return Node.DOCUMENT_POSITION_DISCONNECTED;
|
|
72
|
-
},
|
|
73
|
+
}, lt = (t) => D(t)[0] ?? null, i = [], S = /* @__PURE__ */ new Set(), M = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Set(), pt = () => {
|
|
73
74
|
};
|
|
74
75
|
let b = [];
|
|
75
|
-
const A = /* @__PURE__ */ new Set(),
|
|
76
|
+
const A = /* @__PURE__ */ new Set(), ht = () => {
|
|
76
77
|
const t = S.size ? i.map((e) => {
|
|
77
78
|
var n;
|
|
78
79
|
return (n = M.get(e)) == null ? void 0 : n();
|
|
@@ -83,26 +84,26 @@ const A = /* @__PURE__ */ new Set(), lt = () => {
|
|
|
83
84
|
for (const e of b)
|
|
84
85
|
r.has(e) || V(e);
|
|
85
86
|
for (const e of t)
|
|
86
|
-
|
|
87
|
+
B(e);
|
|
87
88
|
b = t;
|
|
88
89
|
for (const e of A)
|
|
89
|
-
|
|
90
|
-
},
|
|
90
|
+
B(e);
|
|
91
|
+
}, wt = (t) => (A.add(t), () => {
|
|
91
92
|
A.delete(t);
|
|
92
|
-
}),
|
|
93
|
+
}), I = () => {
|
|
93
94
|
for (const t of v)
|
|
94
95
|
t();
|
|
95
96
|
}, Y = (t) => (v.add(t), () => {
|
|
96
97
|
v.delete(t);
|
|
97
|
-
}),
|
|
98
|
+
}), P = (t, r, e, n) => {
|
|
98
99
|
const a = n[0], o = n[n.length - 1], s = W(e, r);
|
|
99
100
|
if (r && s && r !== e && !n.includes(r)) {
|
|
100
101
|
const c = t.shiftKey ? Node.DOCUMENT_POSITION_PRECEDING : Node.DOCUMENT_POSITION_FOLLOWING;
|
|
101
|
-
n.some((d) =>
|
|
102
|
+
n.some((d) => ft(r, d) & c) || (t.preventDefault(), (t.shiftKey ? o : a).focus());
|
|
102
103
|
return;
|
|
103
104
|
}
|
|
104
105
|
t.shiftKey ? (!s || r === a || r === e) && (t.preventDefault(), o.focus()) : (!s || r === o || r === e) && (t.preventDefault(), a.focus());
|
|
105
|
-
},
|
|
106
|
+
}, H = (t) => {
|
|
106
107
|
if (t.key !== "Tab" || t.defaultPrevented)
|
|
107
108
|
return;
|
|
108
109
|
let r = null, e = 0;
|
|
@@ -110,14 +111,14 @@ const A = /* @__PURE__ */ new Set(), lt = () => {
|
|
|
110
111
|
r = i[s](), r && (e = _.get(i[s]) ?? 0);
|
|
111
112
|
if (!r)
|
|
112
113
|
return;
|
|
113
|
-
const n =
|
|
114
|
+
const n = K(), a = n ? tt(n) : null;
|
|
114
115
|
if (n && a && a.ticket > e) {
|
|
115
116
|
const s = a.popup.shadowRoot ?? a.popup, c = D(s);
|
|
116
117
|
if (c.length === 0) {
|
|
117
118
|
t.preventDefault();
|
|
118
119
|
return;
|
|
119
120
|
}
|
|
120
|
-
|
|
121
|
+
P(t, n, s, c);
|
|
121
122
|
return;
|
|
122
123
|
}
|
|
123
124
|
const o = D(r);
|
|
@@ -125,32 +126,32 @@ const A = /* @__PURE__ */ new Set(), lt = () => {
|
|
|
125
126
|
t.preventDefault(), r.focus();
|
|
126
127
|
return;
|
|
127
128
|
}
|
|
128
|
-
|
|
129
|
-
},
|
|
129
|
+
P(t, n, r, o);
|
|
130
|
+
}, St = (t, r) => (i.length === 0 && document.addEventListener("keydown", H), i.push(t), M.set(t, r), _.set(t, X()), I(), () => {
|
|
130
131
|
const e = i.lastIndexOf(t);
|
|
131
132
|
e !== -1 && i.splice(e, 1), S.delete(t), M.delete(t), _.delete(t);
|
|
132
133
|
const n = r();
|
|
133
|
-
n && V(n), i.length === 0 && document.removeEventListener("keydown",
|
|
134
|
-
}),
|
|
134
|
+
n && V(n), i.length === 0 && document.removeEventListener("keydown", H), I();
|
|
135
|
+
}), yt = (t) => {
|
|
135
136
|
const r = i.lastIndexOf(t);
|
|
136
137
|
return r === -1 ? void 0 : i.slice(r + 1).find((e) => {
|
|
137
138
|
var n;
|
|
138
139
|
return ((n = e()) == null ? void 0 : n.isConnected) === !0;
|
|
139
140
|
});
|
|
140
|
-
},
|
|
141
|
+
}, k = /* @__PURE__ */ new Map(), Rt = () => O(
|
|
141
142
|
Y,
|
|
142
143
|
() => i.length > 0,
|
|
143
144
|
() => !1
|
|
144
|
-
),
|
|
145
|
+
), z = (t, r) => {
|
|
145
146
|
if (r === "content") {
|
|
146
|
-
const e =
|
|
147
|
+
const e = K();
|
|
147
148
|
if (W(t, e))
|
|
148
149
|
return;
|
|
149
|
-
(
|
|
150
|
+
(lt(t) ?? t).focus();
|
|
150
151
|
return;
|
|
151
152
|
}
|
|
152
153
|
t.focus();
|
|
153
|
-
},
|
|
154
|
+
}, Dt = ({
|
|
154
155
|
open: t,
|
|
155
156
|
onClose: r,
|
|
156
157
|
elevated: e = !1,
|
|
@@ -159,77 +160,77 @@ const A = /* @__PURE__ */ new Set(), lt = () => {
|
|
|
159
160
|
onYield: o
|
|
160
161
|
}) => {
|
|
161
162
|
const s = p(null), c = p(() => s.current).current;
|
|
162
|
-
|
|
163
|
+
et(
|
|
163
164
|
L(() => (n == null ? void 0 : n.current) ?? s.current, [n]),
|
|
164
165
|
t
|
|
165
166
|
);
|
|
166
|
-
const d = p(null), f = p(null), h = p(a),
|
|
167
|
+
const d = p(null), f = p(null), h = p(a), F = p(r), m = p(o);
|
|
167
168
|
C(() => {
|
|
168
|
-
|
|
169
|
+
F.current = r, m.current = o;
|
|
169
170
|
}, [r, o]), C(() => {
|
|
170
|
-
if (t)
|
|
171
|
-
return d.current =
|
|
171
|
+
if ($(), !!t)
|
|
172
|
+
return d.current = q(), () => {
|
|
172
173
|
const u = d.current;
|
|
173
174
|
d.current = null;
|
|
174
|
-
const
|
|
175
|
-
if (
|
|
175
|
+
const E = k.get(c);
|
|
176
|
+
if (k.delete(c), f.current === null)
|
|
176
177
|
return;
|
|
177
|
-
const l = u != null && u.isConnected ? u :
|
|
178
|
-
x && l &&
|
|
178
|
+
const l = u != null && u.isConnected ? u : E, x = yt(c);
|
|
179
|
+
x && l && k.set(x, l), !x && (l != null && l.isConnected) && l.focus();
|
|
179
180
|
};
|
|
180
181
|
}, [t, c]), C(() => {
|
|
181
182
|
if (!t)
|
|
182
183
|
return;
|
|
183
|
-
if (
|
|
184
|
-
|
|
184
|
+
if (m.current && i.length > 0) {
|
|
185
|
+
m.current();
|
|
185
186
|
return;
|
|
186
187
|
}
|
|
187
188
|
f.current = c;
|
|
188
|
-
const u =
|
|
189
|
-
return s.current &&
|
|
190
|
-
f.current = null, l(), u(),
|
|
189
|
+
const u = J(() => F.current()), E = rt(), l = St(c, () => (n == null ? void 0 : n.current) ?? null);
|
|
190
|
+
return s.current && z(s.current, h.current), () => {
|
|
191
|
+
f.current = null, l(), u(), E();
|
|
191
192
|
};
|
|
192
193
|
}, [t, n, c]), g(() => {
|
|
193
194
|
if (!(!t || !e))
|
|
194
|
-
return S.add(c),
|
|
195
|
-
S.delete(c),
|
|
195
|
+
return S.add(c), I(), () => {
|
|
196
|
+
S.delete(c), I();
|
|
196
197
|
};
|
|
197
198
|
}, [t, e, c]);
|
|
198
|
-
const
|
|
199
|
-
(u) => t ? Y(u) :
|
|
199
|
+
const N = L(
|
|
200
|
+
(u) => t ? Y(u) : pt,
|
|
200
201
|
[t]
|
|
201
202
|
), j = O(
|
|
202
|
-
|
|
203
|
+
N,
|
|
203
204
|
// Gated on `open` so an overlay fading out stops claiming modal. Before it registers
|
|
204
205
|
// it is the one about to go on top, or aria-modal would drop for a frame on open.
|
|
205
206
|
() => t && (f.current === null || i[i.length - 1] === f.current),
|
|
206
207
|
() => !0
|
|
207
208
|
), y = O(
|
|
208
|
-
|
|
209
|
+
N,
|
|
209
210
|
() => t && (e || S.size > 0),
|
|
210
211
|
() => !1
|
|
211
212
|
), Z = O(
|
|
212
|
-
|
|
213
|
+
N,
|
|
213
214
|
() => {
|
|
214
215
|
const u = f.current;
|
|
215
|
-
return
|
|
216
|
+
return U + (t && u ? Math.max(0, i.indexOf(u)) : 0);
|
|
216
217
|
},
|
|
217
|
-
() =>
|
|
218
|
+
() => U
|
|
218
219
|
);
|
|
219
220
|
return g(() => {
|
|
220
|
-
y &&
|
|
221
|
+
y && nt();
|
|
221
222
|
}, [y]), g(() => {
|
|
222
|
-
|
|
223
|
+
ht();
|
|
223
224
|
}), { ref: L((u) => {
|
|
224
|
-
s.current = u, u && f.current !== null &&
|
|
225
|
+
s.current = u, u && f.current !== null && z(u, h.current);
|
|
225
226
|
}, []), isTopmost: j, zIndex: y ? void 0 : Z, elevated: y };
|
|
226
227
|
};
|
|
227
228
|
export {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
229
|
+
ot as FOCUSABLE_SELECTOR,
|
|
230
|
+
kt as OVERLAY_ICON_BUTTON_CLASSES,
|
|
231
|
+
lt as firstTabStopIn,
|
|
232
|
+
wt as keepAboveOverlayStack,
|
|
233
|
+
Rt as useHasOpenOverlay,
|
|
234
|
+
Dt as useOverlayBehaviour
|
|
234
235
|
};
|
|
235
236
|
//# sourceMappingURL=overlayBehaviour.js.map
|