@cambly/syntax-core 10.29.0 → 10.30.0
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/Modal/FocusTrap.cjs +3 -2
- package/dist/Modal/FocusTrap.js +2 -1
- package/dist/Modal/Modal.cjs +3 -3
- package/dist/Modal/Modal.css +11 -13
- package/dist/Modal/Modal.css.map +1 -1
- package/dist/Modal/Modal.d.ts +3 -7
- package/dist/Modal/Modal.js +2 -2
- package/dist/RichSelect/RichSelectList.cjs +3 -3
- package/dist/RichSelect/RichSelectList.js +2 -2
- package/dist/SelectList/SelectList.cjs +3 -3
- package/dist/SelectList/SelectList.js +2 -2
- package/dist/__chunks/{JHLUJYBX.cjs → 2HNPYS3S.cjs} +3 -3
- package/dist/__chunks/{3Q5UNXKC.js → 3OWAOKRW.js} +2 -2
- package/dist/__chunks/{2BEN3VH2.cjs → 6OCOGTM5.cjs} +3 -3
- package/dist/__chunks/{OFALBLGM.cjs → 7SCBZPIF.cjs} +1 -1
- package/dist/__chunks/{OFALBLGM.cjs.map → 7SCBZPIF.cjs.map} +1 -1
- package/dist/__chunks/AKKJTW7U.js +148 -0
- package/dist/__chunks/AKKJTW7U.js.map +1 -0
- package/dist/__chunks/CPIFXRXD.cjs +148 -0
- package/dist/__chunks/CPIFXRXD.cjs.map +1 -0
- package/dist/__chunks/{J7FCX3U6.js → HVA7R2EL.js} +7 -3
- package/dist/__chunks/HVA7R2EL.js.map +1 -0
- package/dist/__chunks/{VQF4J5CC.js → ICDRMDXD.js} +1 -1
- package/dist/__chunks/{VQF4J5CC.js.map → ICDRMDXD.js.map} +1 -1
- package/dist/__chunks/{AXHY5J3K.js → TDR3JRXZ.js} +2 -2
- package/dist/__chunks/{ZDQ6WQM3.cjs → THM3NAFO.cjs} +7 -3
- package/dist/__chunks/THM3NAFO.cjs.map +1 -0
- package/dist/index.cjs +6 -6
- package/dist/index.css +11 -13
- package/dist/index.css.map +1 -1
- package/dist/index.js +5 -5
- package/package.json +1 -1
- package/dist/__chunks/DDUKESGS.cjs +0 -177
- package/dist/__chunks/DDUKESGS.cjs.map +0 -1
- package/dist/__chunks/J7FCX3U6.js.map +0 -1
- package/dist/__chunks/TNHXXDCA.js +0 -177
- package/dist/__chunks/TNHXXDCA.js.map +0 -1
- package/dist/__chunks/ZDQ6WQM3.cjs.map +0 -1
- /package/dist/__chunks/{JHLUJYBX.cjs.map → 2HNPYS3S.cjs.map} +0 -0
- /package/dist/__chunks/{3Q5UNXKC.js.map → 3OWAOKRW.js.map} +0 -0
- /package/dist/__chunks/{2BEN3VH2.cjs.map → 6OCOGTM5.cjs.map} +0 -0
- /package/dist/__chunks/{AXHY5J3K.js.map → TDR3JRXZ.js.map} +0 -0
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }"use client"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _THYSYYWScjs = require('./THYSYYWS.cjs');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var _HUIHS6RNcjs = require('./HUIHS6RN.cjs');
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _6P6ARVEAcjs = require('./6P6ARVEA.cjs');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _ZDQ6WQM3cjs = require('./ZDQ6WQM3.cjs');
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var _OAZD7W2Wcjs = require('./OAZD7W2W.cjs');
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var _GANR5JVVcjs = require('./GANR5JVV.cjs');
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var _JXOKXBDZcjs = require('./JXOKXBDZ.cjs');
|
|
23
|
-
|
|
24
|
-
// src/Modal/Modal.tsx
|
|
25
|
-
var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames);
|
|
26
|
-
|
|
27
|
-
// css-module:./Modal.module.css#css-module
|
|
28
|
-
var Modal_module_default = { "backdrop": "_backdrop_1w5vm_1", "backdropClassic": "_backdropClassic_1w5vm_11", "backdropCambio": "_backdropCambio_1w5vm_15", "closeButton": "_closeButton_1w5vm_19", "closeButtonClassic": "_closeButtonClassic_1w5vm_34", "closeButtonWithImage": "_closeButtonWithImage_1w5vm_46", "closeButtonWithImageCambio": "_closeButtonWithImageCambio_1w5vm_50" };
|
|
29
|
-
|
|
30
|
-
// src/Modal/Modal.tsx
|
|
31
|
-
var _jsxruntime = require('react/jsx-runtime');
|
|
32
|
-
function XIcon({ color = "#000" }) {
|
|
33
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", fill: color, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
34
|
-
"path",
|
|
35
|
-
{
|
|
36
|
-
fill: "inherit",
|
|
37
|
-
d: "M11.25.758a.83.83 0 0 0-1.175 0L6 4.825 1.925.75A.83.83 0 1 0 .75 1.925L4.825 6 .75 10.075a.83.83 0 1 0 1.175 1.175L6 7.175l4.075 4.075a.83.83 0 1 0 1.175-1.175L7.175 6l4.075-4.075a.835.835 0 0 0 0-1.167Z"
|
|
38
|
-
}
|
|
39
|
-
) });
|
|
40
|
-
}
|
|
41
|
-
function XIconCambio({ className }) {
|
|
42
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
43
|
-
"svg",
|
|
44
|
-
{
|
|
45
|
-
className,
|
|
46
|
-
fill: "currentColor",
|
|
47
|
-
focusable: "false",
|
|
48
|
-
"aria-hidden": "true",
|
|
49
|
-
viewBox: "0 0 24 24",
|
|
50
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" })
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
var sizeWidth = {
|
|
55
|
-
sm: 400,
|
|
56
|
-
lg: 600
|
|
57
|
-
};
|
|
58
|
-
function Modal({
|
|
59
|
-
header,
|
|
60
|
-
children,
|
|
61
|
-
image,
|
|
62
|
-
onDismiss,
|
|
63
|
-
footer,
|
|
64
|
-
accessibilityCloseLabel = "close modal",
|
|
65
|
-
size = "sm",
|
|
66
|
-
zIndex = 1,
|
|
67
|
-
"data-testid": dataTestId
|
|
68
|
-
}) {
|
|
69
|
-
const { themeName } = _JXOKXBDZcjs.useTheme.call(void 0, );
|
|
70
|
-
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _6P6ARVEAcjs.Layer, { zIndex, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _HUIHS6RNcjs.StopScroll, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ZDQ6WQM3cjs.FocusTrap, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
71
|
-
"div",
|
|
72
|
-
{
|
|
73
|
-
className: _classnames2.default.call(void 0,
|
|
74
|
-
Modal_module_default.backdrop,
|
|
75
|
-
themeName === "classic" ? Modal_module_default.backdropClassic : Modal_module_default.backdropCambio
|
|
76
|
-
),
|
|
77
|
-
role: "presentation",
|
|
78
|
-
onClick: (e) => e.target === e.currentTarget && onDismiss(),
|
|
79
|
-
onKeyDown: (e) => e.key === "Escape" && onDismiss(),
|
|
80
|
-
children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
81
|
-
_GANR5JVVcjs.Box_default,
|
|
82
|
-
{
|
|
83
|
-
"data-testid": dataTestId,
|
|
84
|
-
backgroundColor: "white",
|
|
85
|
-
rounding: themeName === "classic" ? "xl" : "md",
|
|
86
|
-
display: "flex",
|
|
87
|
-
direction: "column",
|
|
88
|
-
marginStart: 4,
|
|
89
|
-
marginEnd: 4,
|
|
90
|
-
minWidth: 240,
|
|
91
|
-
maxWidth: sizeWidth[themeName === "classic" ? size : "lg"],
|
|
92
|
-
width: "100%",
|
|
93
|
-
dangerouslySetInlineStyle: { __style: { overflow: "hidden" } },
|
|
94
|
-
children: [
|
|
95
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _GANR5JVVcjs.Box_default, { position: "relative", children: themeName === "classic" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
96
|
-
"button",
|
|
97
|
-
{
|
|
98
|
-
"aria-label": accessibilityCloseLabel,
|
|
99
|
-
type: "button",
|
|
100
|
-
className: _classnames2.default.call(void 0,
|
|
101
|
-
Modal_module_default.closeButton,
|
|
102
|
-
Modal_module_default.closeButtonClassic,
|
|
103
|
-
{
|
|
104
|
-
[Modal_module_default.closeButtonWithImage]: !!image
|
|
105
|
-
}
|
|
106
|
-
),
|
|
107
|
-
onClick: onDismiss,
|
|
108
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, XIcon, { color: image ? "#fff" : "#000" })
|
|
109
|
-
}
|
|
110
|
-
) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
111
|
-
_GANR5JVVcjs.Box_default,
|
|
112
|
-
{
|
|
113
|
-
position: "absolute",
|
|
114
|
-
dangerouslySetInlineStyle: {
|
|
115
|
-
__style: { top: 4, right: 4 }
|
|
116
|
-
},
|
|
117
|
-
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
118
|
-
_OAZD7W2Wcjs.IconButton_default,
|
|
119
|
-
{
|
|
120
|
-
accessibilityLabel: accessibilityCloseLabel,
|
|
121
|
-
color: image ? "primary" : "tertiary",
|
|
122
|
-
on: image ? "darkBackground" : "lightBackground",
|
|
123
|
-
onClick: onDismiss,
|
|
124
|
-
size: "sm",
|
|
125
|
-
icon: XIconCambio
|
|
126
|
-
}
|
|
127
|
-
)
|
|
128
|
-
}
|
|
129
|
-
) }),
|
|
130
|
-
image && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _GANR5JVVcjs.Box_default, { children: image }),
|
|
131
|
-
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
132
|
-
_GANR5JVVcjs.Box_default,
|
|
133
|
-
{
|
|
134
|
-
display: "flex",
|
|
135
|
-
gap: themeName === "classic" ? 3 : 4,
|
|
136
|
-
direction: "column",
|
|
137
|
-
padding: themeName === "classic" ? 9 : 6,
|
|
138
|
-
children: [
|
|
139
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
140
|
-
_THYSYYWScjs.Heading_default,
|
|
141
|
-
{
|
|
142
|
-
as: "h1",
|
|
143
|
-
size: themeName === "classic" ? 500 : 600,
|
|
144
|
-
fontStyle: themeName === "classic" ? "sans-serif" : "serif",
|
|
145
|
-
children: header
|
|
146
|
-
}
|
|
147
|
-
),
|
|
148
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _GANR5JVVcjs.Box_default, { marginBottom: themeName === "classic" ? 4 : 0, children }),
|
|
149
|
-
footer && /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
150
|
-
_GANR5JVVcjs.Box_default,
|
|
151
|
-
{
|
|
152
|
-
display: "flex",
|
|
153
|
-
direction: "column",
|
|
154
|
-
gap: 3,
|
|
155
|
-
marginTop: themeName === "classic" ? 0 : 2,
|
|
156
|
-
smDirection: "row",
|
|
157
|
-
smJustifyContent: "end",
|
|
158
|
-
lgDirection: "row",
|
|
159
|
-
lgJustifyContent: "end",
|
|
160
|
-
children: footer
|
|
161
|
-
}
|
|
162
|
-
)
|
|
163
|
-
]
|
|
164
|
-
}
|
|
165
|
-
)
|
|
166
|
-
]
|
|
167
|
-
}
|
|
168
|
-
)
|
|
169
|
-
}
|
|
170
|
-
) }) }) });
|
|
171
|
-
}
|
|
172
|
-
Modal.displayName = "Modal";
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
exports.Modal = Modal;
|
|
177
|
-
//# sourceMappingURL=DDUKESGS.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src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AAG;AAAA,sBACH,MAAM,cAAc,YAAY,MAAM;AAAA,sBACtC,WAAW,cAAc,YAAY,eAAe;AAAA,sBAEnD;AAAA;AAAA,kBACH;AAAA,kBACA,oBAAC,eAAI,cAAc,cAAc,YAAY,IAAI,GAC9C,UACH;AAAA,kBACC,UACC;AAAA,oBAAC;AAAA;AAAA,sBACC,SAAQ;AAAA,sBACR,WAAU;AAAA,sBACV,KAAK;AAAA,sBACL,WAAW,cAAc,YAAY,IAAI;AAAA,sBACzC,aAAY;AAAA,sBACZ,kBAAiB;AAAA,sBACjB,aAAY;AAAA,sBACZ,kBAAiB;AAAA,sBAEhB;AAAA;AAAA,kBACH;AAAA;AAAA;AAAA,YAEJ;AAAA;AAAA;AAAA,MACF;AAAA;AAAA,EACF,GACF,GACF,GACF;AAEJ;AAEA,MAAM,cAAc","sourcesContent":["import { type ReactElement } from \"react\";\nimport classnames from \"classnames\";\n\nimport Heading from \"../Heading/Heading\";\nimport Box from \"../Box/Box\";\n\nimport FocusTrap from \"./FocusTrap\";\nimport StopScroll from \"./StopScroll\";\nimport Layer from \"./Layer\";\nimport styles from \"./Modal.module.css\";\nimport { useTheme } from \"../ThemeProvider/ThemeProvider\";\nimport IconButton from \"../IconButton/IconButton\";\n\nfunction XIcon({ color = \"#000\" }: { color?: string }) {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"12\" height=\"12\" fill={color}>\n <path\n fill=\"inherit\"\n d=\"M11.25.758a.83.83 0 0 0-1.175 0L6 4.825 1.925.75A.83.83 0 1 0 .75 1.925L4.825 6 .75 10.075a.83.83 0 1 0 1.175 1.175L6 7.175l4.075 4.075a.83.83 0 1 0 1.175-1.175L7.175 6l4.075-4.075a.835.835 0 0 0 0-1.167Z\"\n />\n </svg>\n );\n}\n\nfunction XIconCambio({ className }: { className?: string }) {\n return (\n <svg\n className={className}\n fill=\"currentColor\"\n focusable=\"false\"\n aria-hidden=\"true\"\n viewBox=\"0 0 24 24\"\n >\n <path d=\"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\"></path>\n </svg>\n );\n}\n\n// Note: Only sm + lg size currently. design thinks there should only be two sizes.\n// If there IS a md size at some point, we should use the \"size\" const.\nconst sizeWidth = {\n sm: 400,\n lg: 600,\n} as const;\n\n/**\n * [Modal](https://cambly-syntax.vercel.app/?path=/docs/components-modal--docs) is a dialog that appears on top of the main content and locks user interaction within the modal.\n *\n ```\n const [showModal, setShowModal] = useState(false)\n\n return (\n <>\n {showModal && <Modal\n header=\"header text\"\n onDismiss={() => setShowModal(false)}\n footer={\n <>\n <Button\n text=\"Cancel\"\n color=\"secondary\"\n onClick={() => {}}\n />\n <Button\n text=\"Confirm\"\n onClick={() => {}}\n />\n </>\n }\n >\n <Typography>\n Body text goes here!\n </Typography>\n </Modal> }\n </>\n )\n ```\n */\nexport default function Modal({\n header,\n children,\n image,\n onDismiss,\n footer,\n accessibilityCloseLabel = \"close modal\",\n size = \"sm\",\n zIndex = 1,\n \"data-testid\": dataTestId,\n}: {\n /**\n * The modal's main content. Should typically take in `Typography`'d text.\n */\n children: JSX.Element;\n /**\n * The header inside a modal as a string.\n */\n header: string;\n /**\n * What the X button (or clicking out of the modal area) does.\n * Typically used for closing the Modal\n */\n onDismiss: () => void;\n /**\n * The optional image rendered above the Modal.\n * Image\n * * Size should be 600w x 200h\n * * Be sure to set width=\"100%\" on the image\n * If images aren't that sized, should ask design to give another image.\n */\n image?: JSX.Element;\n /**\n * The footer for the bottom area of the Modal. Typically used for rendering buttons.\n * * Use Syntax `Button` and pass it into footer.\n * * If one button, just pass it in. If two, wrap in a React fragment (`<> </>`)\n * * If two(2) buttons, put primary button _second_.\n *\n <>\n <Button\n text=\"Cancel\"\n color=\"secondary\"\n onClick={() => {}}\n />\n <Button\n text=\"Confirm\"\n onClick={() => {}}\n />\n </>\n */\n footer?: JSX.Element;\n /**\n * The accessibilty text on the close button.\n * (Sets the aria-label of the button)\n *\n *\n * @defaultValue close modal\n */\n accessibilityCloseLabel?: string;\n /**\n * The size of the card\n *\n * Classic:\n * * `sm`: 400px (Classic only)\n * * `lg`: 600px\n *\n * Cambio:\n * * `lg`: 600px\n *\n *\n * @defaultValue sm\n */\n size?: keyof typeof sizeWidth;\n /**\n * The z-index for the modal.\n * Typically used if there are other things on the page with higher z-index and you need this overlayed on top.\n *\n * @defaultValue 0\n */\n zIndex?: number;\n /**\n * Test id for the modal\n */\n \"data-testid\"?: string;\n}): ReactElement {\n const { themeName } = useTheme();\n return (\n <Layer zIndex={zIndex}>\n <StopScroll>\n <FocusTrap>\n <div\n className={classnames(\n styles.backdrop,\n themeName === \"classic\"\n ? styles.backdropClassic\n : styles.backdropCambio,\n )}\n role=\"presentation\"\n onClick={(e) => e.target === e.currentTarget && onDismiss()}\n onKeyDown={(e) => e.key === \"Escape\" && onDismiss()}\n >\n <Box\n data-testid={dataTestId}\n backgroundColor=\"white\"\n rounding={themeName === \"classic\" ? \"xl\" : \"md\"}\n display=\"flex\"\n direction=\"column\"\n marginStart={4}\n marginEnd={4}\n minWidth={240}\n maxWidth={sizeWidth[themeName === \"classic\" ? size : \"lg\"]}\n width=\"100%\"\n dangerouslySetInlineStyle={{ __style: { overflow: \"hidden\" } }}\n >\n <Box position=\"relative\">\n {themeName === \"classic\" ? (\n <button\n aria-label={accessibilityCloseLabel}\n type=\"button\"\n className={classnames(\n styles.closeButton,\n styles.closeButtonClassic,\n {\n [styles.closeButtonWithImage]: !!image,\n },\n )}\n onClick={onDismiss}\n >\n <XIcon color={image ? \"#fff\" : \"#000\"} />\n </button>\n ) : (\n <Box\n position=\"absolute\"\n dangerouslySetInlineStyle={{\n __style: { top: 4, right: 4 },\n }}\n >\n <IconButton\n accessibilityLabel={accessibilityCloseLabel}\n color={image ? \"primary\" : \"tertiary\"}\n on={image ? \"darkBackground\" : \"lightBackground\"}\n onClick={onDismiss}\n size=\"sm\"\n icon={XIconCambio}\n />\n </Box>\n )}\n </Box>\n {image && <Box>{image}</Box>}\n <Box\n display=\"flex\"\n gap={themeName === \"classic\" ? 3 : 4}\n direction=\"column\"\n padding={themeName === \"classic\" ? 9 : 6}\n >\n <Heading\n as=\"h1\"\n size={themeName === \"classic\" ? 500 : 600}\n fontStyle={themeName === \"classic\" ? \"sans-serif\" : \"serif\"}\n >\n {header}\n </Heading>\n <Box marginBottom={themeName === \"classic\" ? 4 : 0}>\n {children}\n </Box>\n {footer && (\n <Box\n display=\"flex\"\n direction=\"column\"\n gap={3}\n marginTop={themeName === \"classic\" ? 0 : 2}\n smDirection=\"row\"\n smJustifyContent=\"end\"\n lgDirection=\"row\"\n lgJustifyContent=\"end\"\n >\n {footer}\n </Box>\n )}\n </Box>\n </Box>\n </div>\n </FocusTrap>\n </StopScroll>\n </Layer>\n );\n}\n\nModal.displayName = \"Modal\";\n","import \"/home/runner/work/syntax/syntax/packages/syntax-core/src/Modal/Modal.module.css\"; export default {\"backdrop\":\"_backdrop_1w5vm_1\",\"backdropClassic\":\"_backdropClassic_1w5vm_11\",\"backdropCambio\":\"_backdropCambio_1w5vm_15\",\"closeButton\":\"_closeButton_1w5vm_19\",\"closeButtonClassic\":\"_closeButtonClassic_1w5vm_34\",\"closeButtonWithImage\":\"_closeButtonWithImage_1w5vm_46\",\"closeButtonWithImageCambio\":\"_closeButtonWithImageCambio_1w5vm_50\"}"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Modal/FocusTrap.tsx"],"sourcesContent":["import React, { useEffect, useRef, type ReactElement } from \"react\";\n\nfunction queryFocusableAll(el: HTMLDivElement): NodeListOf<HTMLElement> {\n // Focusable, interactive elements that could possibly be in children\n const selector = [\n \"a[href]\",\n \"area[href]\",\n \"input:not([disabled])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n \"button:not([disabled])\",\n \"iframe\",\n \"object\",\n \"embed\",\n '[tabindex=\"-1\"]',\n '[tabindex=\"0\"]',\n \"[contenteditable]\",\n \"audio[controls]\",\n \"video[controls]\",\n \"summary\",\n ].join(\",\");\n return el.querySelectorAll(selector);\n}\n\nconst focusElement = (el?: HTMLElement) => {\n if (el && typeof el.focus === \"function\") {\n el.focus();\n }\n};\n\n/**\n * FocusTrap is used by components like Modal to ensure that only elements within children components can be focused.\n */\nexport default function FocusTrap({\n children,\n}: {\n children?: ReactElement | null;\n}): ReactElement {\n const elRef = useRef<HTMLDivElement | null>(null);\n const previouslyFocusedElRef = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n const { current: element } = elRef;\n\n // Focus the first child element among all the focusable, interactive elements within `children`\n const focusFirstChild = () => {\n const withinIframe = window !== window.parent;\n if (element && !withinIframe) {\n focusElement(queryFocusableAll(element)[0]);\n }\n };\n\n const handleFocus: (event: FocusEvent) => void = (event: FocusEvent) => {\n if (\n !element ||\n (event.target instanceof Node && element.contains(event.target))\n ) {\n return;\n }\n\n // This prevents stack overflow when multiple FocusTraps are rendered\n if (\n event.target instanceof Element &&\n event.target.closest('[data-testid=\"syntax-focus-trap\"]') !== null\n ) {\n return;\n }\n\n event.stopPropagation();\n event.preventDefault();\n focusFirstChild();\n };\n\n // If an element has focus currently, keep a reference to that element\n previouslyFocusedElRef.current = document.activeElement as HTMLElement;\n focusFirstChild();\n document.addEventListener(\"focus\", handleFocus, true);\n\n return function cleanup() {\n const { current: previouslyFocusedEl } = previouslyFocusedElRef;\n document.removeEventListener(\"focus\", handleFocus, true);\n // If we previously stored a reference to a focused element, return focus to that element\n if (previouslyFocusedEl) {\n focusElement(previouslyFocusedEl);\n }\n };\n }, [elRef, previouslyFocusedElRef]);\n\n return (\n <div data-testid=\"syntax-focus-trap\" ref={elRef}>\n {children}\n </div>\n );\n}\n"],"mappings":";;;AAAA,SAAgB,WAAW,cAAiC;AAyFxD;AAvFJ,SAAS,kBAAkB,IAA6C;AAEtE,QAAM,WAAW;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,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|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
import {
|
|
3
|
-
Heading_default
|
|
4
|
-
} from "./AYTJYJHI.js";
|
|
5
|
-
import {
|
|
6
|
-
StopScroll
|
|
7
|
-
} from "./QQT35OLE.js";
|
|
8
|
-
import {
|
|
9
|
-
Layer
|
|
10
|
-
} from "./GJBW4BG7.js";
|
|
11
|
-
import {
|
|
12
|
-
FocusTrap
|
|
13
|
-
} from "./J7FCX3U6.js";
|
|
14
|
-
import {
|
|
15
|
-
IconButton_default
|
|
16
|
-
} from "./VR4ZFZ4Z.js";
|
|
17
|
-
import {
|
|
18
|
-
Box_default
|
|
19
|
-
} from "./HCHFPFNX.js";
|
|
20
|
-
import {
|
|
21
|
-
useTheme
|
|
22
|
-
} from "./4GTNQPPD.js";
|
|
23
|
-
|
|
24
|
-
// src/Modal/Modal.tsx
|
|
25
|
-
import classnames from "classnames";
|
|
26
|
-
|
|
27
|
-
// css-module:./Modal.module.css#css-module
|
|
28
|
-
var Modal_module_default = { "backdrop": "_backdrop_1w5vm_1", "backdropClassic": "_backdropClassic_1w5vm_11", "backdropCambio": "_backdropCambio_1w5vm_15", "closeButton": "_closeButton_1w5vm_19", "closeButtonClassic": "_closeButtonClassic_1w5vm_34", "closeButtonWithImage": "_closeButtonWithImage_1w5vm_46", "closeButtonWithImageCambio": "_closeButtonWithImageCambio_1w5vm_50" };
|
|
29
|
-
|
|
30
|
-
// src/Modal/Modal.tsx
|
|
31
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
32
|
-
function XIcon({ color = "#000" }) {
|
|
33
|
-
return /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "12", height: "12", fill: color, children: /* @__PURE__ */ jsx(
|
|
34
|
-
"path",
|
|
35
|
-
{
|
|
36
|
-
fill: "inherit",
|
|
37
|
-
d: "M11.25.758a.83.83 0 0 0-1.175 0L6 4.825 1.925.75A.83.83 0 1 0 .75 1.925L4.825 6 .75 10.075a.83.83 0 1 0 1.175 1.175L6 7.175l4.075 4.075a.83.83 0 1 0 1.175-1.175L7.175 6l4.075-4.075a.835.835 0 0 0 0-1.167Z"
|
|
38
|
-
}
|
|
39
|
-
) });
|
|
40
|
-
}
|
|
41
|
-
function XIconCambio({ className }) {
|
|
42
|
-
return /* @__PURE__ */ jsx(
|
|
43
|
-
"svg",
|
|
44
|
-
{
|
|
45
|
-
className,
|
|
46
|
-
fill: "currentColor",
|
|
47
|
-
focusable: "false",
|
|
48
|
-
"aria-hidden": "true",
|
|
49
|
-
viewBox: "0 0 24 24",
|
|
50
|
-
children: /* @__PURE__ */ jsx("path", { d: "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" })
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
var sizeWidth = {
|
|
55
|
-
sm: 400,
|
|
56
|
-
lg: 600
|
|
57
|
-
};
|
|
58
|
-
function Modal({
|
|
59
|
-
header,
|
|
60
|
-
children,
|
|
61
|
-
image,
|
|
62
|
-
onDismiss,
|
|
63
|
-
footer,
|
|
64
|
-
accessibilityCloseLabel = "close modal",
|
|
65
|
-
size = "sm",
|
|
66
|
-
zIndex = 1,
|
|
67
|
-
"data-testid": dataTestId
|
|
68
|
-
}) {
|
|
69
|
-
const { themeName } = useTheme();
|
|
70
|
-
return /* @__PURE__ */ jsx(Layer, { zIndex, children: /* @__PURE__ */ jsx(StopScroll, { children: /* @__PURE__ */ jsx(FocusTrap, { children: /* @__PURE__ */ jsx(
|
|
71
|
-
"div",
|
|
72
|
-
{
|
|
73
|
-
className: classnames(
|
|
74
|
-
Modal_module_default.backdrop,
|
|
75
|
-
themeName === "classic" ? Modal_module_default.backdropClassic : Modal_module_default.backdropCambio
|
|
76
|
-
),
|
|
77
|
-
role: "presentation",
|
|
78
|
-
onClick: (e) => e.target === e.currentTarget && onDismiss(),
|
|
79
|
-
onKeyDown: (e) => e.key === "Escape" && onDismiss(),
|
|
80
|
-
children: /* @__PURE__ */ jsxs(
|
|
81
|
-
Box_default,
|
|
82
|
-
{
|
|
83
|
-
"data-testid": dataTestId,
|
|
84
|
-
backgroundColor: "white",
|
|
85
|
-
rounding: themeName === "classic" ? "xl" : "md",
|
|
86
|
-
display: "flex",
|
|
87
|
-
direction: "column",
|
|
88
|
-
marginStart: 4,
|
|
89
|
-
marginEnd: 4,
|
|
90
|
-
minWidth: 240,
|
|
91
|
-
maxWidth: sizeWidth[themeName === "classic" ? size : "lg"],
|
|
92
|
-
width: "100%",
|
|
93
|
-
dangerouslySetInlineStyle: { __style: { overflow: "hidden" } },
|
|
94
|
-
children: [
|
|
95
|
-
/* @__PURE__ */ jsx(Box_default, { position: "relative", children: themeName === "classic" ? /* @__PURE__ */ jsx(
|
|
96
|
-
"button",
|
|
97
|
-
{
|
|
98
|
-
"aria-label": accessibilityCloseLabel,
|
|
99
|
-
type: "button",
|
|
100
|
-
className: classnames(
|
|
101
|
-
Modal_module_default.closeButton,
|
|
102
|
-
Modal_module_default.closeButtonClassic,
|
|
103
|
-
{
|
|
104
|
-
[Modal_module_default.closeButtonWithImage]: !!image
|
|
105
|
-
}
|
|
106
|
-
),
|
|
107
|
-
onClick: onDismiss,
|
|
108
|
-
children: /* @__PURE__ */ jsx(XIcon, { color: image ? "#fff" : "#000" })
|
|
109
|
-
}
|
|
110
|
-
) : /* @__PURE__ */ jsx(
|
|
111
|
-
Box_default,
|
|
112
|
-
{
|
|
113
|
-
position: "absolute",
|
|
114
|
-
dangerouslySetInlineStyle: {
|
|
115
|
-
__style: { top: 4, right: 4 }
|
|
116
|
-
},
|
|
117
|
-
children: /* @__PURE__ */ jsx(
|
|
118
|
-
IconButton_default,
|
|
119
|
-
{
|
|
120
|
-
accessibilityLabel: accessibilityCloseLabel,
|
|
121
|
-
color: image ? "primary" : "tertiary",
|
|
122
|
-
on: image ? "darkBackground" : "lightBackground",
|
|
123
|
-
onClick: onDismiss,
|
|
124
|
-
size: "sm",
|
|
125
|
-
icon: XIconCambio
|
|
126
|
-
}
|
|
127
|
-
)
|
|
128
|
-
}
|
|
129
|
-
) }),
|
|
130
|
-
image && /* @__PURE__ */ jsx(Box_default, { children: image }),
|
|
131
|
-
/* @__PURE__ */ jsxs(
|
|
132
|
-
Box_default,
|
|
133
|
-
{
|
|
134
|
-
display: "flex",
|
|
135
|
-
gap: themeName === "classic" ? 3 : 4,
|
|
136
|
-
direction: "column",
|
|
137
|
-
padding: themeName === "classic" ? 9 : 6,
|
|
138
|
-
children: [
|
|
139
|
-
/* @__PURE__ */ jsx(
|
|
140
|
-
Heading_default,
|
|
141
|
-
{
|
|
142
|
-
as: "h1",
|
|
143
|
-
size: themeName === "classic" ? 500 : 600,
|
|
144
|
-
fontStyle: themeName === "classic" ? "sans-serif" : "serif",
|
|
145
|
-
children: header
|
|
146
|
-
}
|
|
147
|
-
),
|
|
148
|
-
/* @__PURE__ */ jsx(Box_default, { marginBottom: themeName === "classic" ? 4 : 0, children }),
|
|
149
|
-
footer && /* @__PURE__ */ jsx(
|
|
150
|
-
Box_default,
|
|
151
|
-
{
|
|
152
|
-
display: "flex",
|
|
153
|
-
direction: "column",
|
|
154
|
-
gap: 3,
|
|
155
|
-
marginTop: themeName === "classic" ? 0 : 2,
|
|
156
|
-
smDirection: "row",
|
|
157
|
-
smJustifyContent: "end",
|
|
158
|
-
lgDirection: "row",
|
|
159
|
-
lgJustifyContent: "end",
|
|
160
|
-
children: footer
|
|
161
|
-
}
|
|
162
|
-
)
|
|
163
|
-
]
|
|
164
|
-
}
|
|
165
|
-
)
|
|
166
|
-
]
|
|
167
|
-
}
|
|
168
|
-
)
|
|
169
|
-
}
|
|
170
|
-
) }) }) });
|
|
171
|
-
}
|
|
172
|
-
Modal.displayName = "Modal";
|
|
173
|
-
|
|
174
|
-
export {
|
|
175
|
-
Modal
|
|
176
|
-
};
|
|
177
|
-
//# sourceMappingURL=TNHXXDCA.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/Modal/Modal.tsx","css-module:./Modal.module.css#css-module"],"sourcesContent":["import { type ReactElement } from \"react\";\nimport classnames from \"classnames\";\n\nimport Heading from \"../Heading/Heading\";\nimport Box from \"../Box/Box\";\n\nimport FocusTrap from \"./FocusTrap\";\nimport StopScroll from \"./StopScroll\";\nimport Layer from \"./Layer\";\nimport styles from \"./Modal.module.css\";\nimport { useTheme } from \"../ThemeProvider/ThemeProvider\";\nimport IconButton from \"../IconButton/IconButton\";\n\nfunction XIcon({ color = \"#000\" }: { color?: string }) {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"12\" height=\"12\" fill={color}>\n <path\n fill=\"inherit\"\n d=\"M11.25.758a.83.83 0 0 0-1.175 0L6 4.825 1.925.75A.83.83 0 1 0 .75 1.925L4.825 6 .75 10.075a.83.83 0 1 0 1.175 1.175L6 7.175l4.075 4.075a.83.83 0 1 0 1.175-1.175L7.175 6l4.075-4.075a.835.835 0 0 0 0-1.167Z\"\n />\n </svg>\n );\n}\n\nfunction XIconCambio({ className }: { className?: string }) {\n return (\n <svg\n className={className}\n fill=\"currentColor\"\n focusable=\"false\"\n aria-hidden=\"true\"\n viewBox=\"0 0 24 24\"\n >\n <path d=\"M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z\"></path>\n </svg>\n );\n}\n\n// Note: Only sm + lg size currently. design thinks there should only be two sizes.\n// If there IS a md size at some point, we should use the \"size\" const.\nconst sizeWidth = {\n sm: 400,\n lg: 600,\n} as const;\n\n/**\n * [Modal](https://cambly-syntax.vercel.app/?path=/docs/components-modal--docs) is a dialog that appears on top of the main content and locks user interaction within the modal.\n *\n ```\n const [showModal, setShowModal] = useState(false)\n\n return (\n <>\n {showModal && <Modal\n header=\"header text\"\n onDismiss={() => setShowModal(false)}\n footer={\n <>\n <Button\n text=\"Cancel\"\n color=\"secondary\"\n onClick={() => {}}\n />\n <Button\n text=\"Confirm\"\n onClick={() => {}}\n />\n </>\n }\n >\n <Typography>\n Body text goes here!\n </Typography>\n </Modal> }\n </>\n )\n ```\n */\nexport default function Modal({\n header,\n children,\n image,\n onDismiss,\n footer,\n accessibilityCloseLabel = \"close modal\",\n size = \"sm\",\n zIndex = 1,\n \"data-testid\": dataTestId,\n}: {\n /**\n * The modal's main content. Should typically take in `Typography`'d text.\n */\n children: JSX.Element;\n /**\n * The header inside a modal as a string.\n */\n header: string;\n /**\n * What the X button (or clicking out of the modal area) does.\n * Typically used for closing the Modal\n */\n onDismiss: () => void;\n /**\n * The optional image rendered above the Modal.\n * Image\n * * Size should be 600w x 200h\n * * Be sure to set width=\"100%\" on the image\n * If images aren't that sized, should ask design to give another image.\n */\n image?: JSX.Element;\n /**\n * The footer for the bottom area of the Modal. Typically used for rendering buttons.\n * * Use Syntax `Button` and pass it into footer.\n * * If one button, just pass it in. If two, wrap in a React fragment (`<> </>`)\n * * If two(2) buttons, put primary button _second_.\n *\n <>\n <Button\n text=\"Cancel\"\n color=\"secondary\"\n onClick={() => {}}\n />\n <Button\n text=\"Confirm\"\n onClick={() => {}}\n />\n </>\n */\n footer?: JSX.Element;\n /**\n * The accessibilty text on the close button.\n * (Sets the aria-label of the button)\n *\n *\n * @defaultValue close modal\n */\n accessibilityCloseLabel?: string;\n /**\n * The size of the card\n *\n * Classic:\n * * `sm`: 400px (Classic only)\n * * `lg`: 600px\n *\n * Cambio:\n * * `lg`: 600px\n *\n *\n * @defaultValue sm\n */\n size?: keyof typeof sizeWidth;\n /**\n * The z-index for the modal.\n * Typically used if there are other things on the page with higher z-index and you need this overlayed on top.\n *\n * @defaultValue 0\n */\n zIndex?: number;\n /**\n * Test id for the modal\n */\n \"data-testid\"?: string;\n}): ReactElement {\n const { themeName } = useTheme();\n return (\n <Layer zIndex={zIndex}>\n <StopScroll>\n <FocusTrap>\n <div\n className={classnames(\n styles.backdrop,\n themeName === \"classic\"\n ? styles.backdropClassic\n : styles.backdropCambio,\n )}\n role=\"presentation\"\n onClick={(e) => e.target === e.currentTarget && onDismiss()}\n onKeyDown={(e) => e.key === \"Escape\" && onDismiss()}\n >\n <Box\n data-testid={dataTestId}\n backgroundColor=\"white\"\n rounding={themeName === \"classic\" ? \"xl\" : \"md\"}\n display=\"flex\"\n direction=\"column\"\n marginStart={4}\n marginEnd={4}\n minWidth={240}\n maxWidth={sizeWidth[themeName === \"classic\" ? size : \"lg\"]}\n width=\"100%\"\n dangerouslySetInlineStyle={{ __style: { overflow: \"hidden\" } }}\n >\n <Box position=\"relative\">\n {themeName === \"classic\" ? (\n <button\n aria-label={accessibilityCloseLabel}\n type=\"button\"\n className={classnames(\n styles.closeButton,\n styles.closeButtonClassic,\n {\n [styles.closeButtonWithImage]: !!image,\n },\n )}\n onClick={onDismiss}\n >\n <XIcon color={image ? \"#fff\" : \"#000\"} />\n </button>\n ) : (\n <Box\n position=\"absolute\"\n dangerouslySetInlineStyle={{\n __style: { top: 4, right: 4 },\n }}\n >\n <IconButton\n accessibilityLabel={accessibilityCloseLabel}\n color={image ? \"primary\" : \"tertiary\"}\n on={image ? \"darkBackground\" : \"lightBackground\"}\n onClick={onDismiss}\n size=\"sm\"\n icon={XIconCambio}\n />\n </Box>\n )}\n </Box>\n {image && <Box>{image}</Box>}\n <Box\n display=\"flex\"\n gap={themeName === \"classic\" ? 3 : 4}\n direction=\"column\"\n padding={themeName === \"classic\" ? 9 : 6}\n >\n <Heading\n as=\"h1\"\n size={themeName === \"classic\" ? 500 : 600}\n fontStyle={themeName === \"classic\" ? \"sans-serif\" : \"serif\"}\n >\n {header}\n </Heading>\n <Box marginBottom={themeName === \"classic\" ? 4 : 0}>\n {children}\n </Box>\n {footer && (\n <Box\n display=\"flex\"\n direction=\"column\"\n gap={3}\n marginTop={themeName === \"classic\" ? 0 : 2}\n smDirection=\"row\"\n smJustifyContent=\"end\"\n lgDirection=\"row\"\n lgJustifyContent=\"end\"\n >\n {footer}\n </Box>\n )}\n </Box>\n </Box>\n </div>\n </FocusTrap>\n </StopScroll>\n </Layer>\n );\n}\n\nModal.displayName = \"Modal\";\n","import \"/home/runner/work/syntax/syntax/packages/syntax-core/src/Modal/Modal.module.css\"; export default {\"backdrop\":\"_backdrop_1w5vm_1\",\"backdropClassic\":\"_backdropClassic_1w5vm_11\",\"backdropCambio\":\"_backdropCambio_1w5vm_15\",\"closeButton\":\"_closeButton_1w5vm_19\",\"closeButtonClassic\":\"_closeButtonClassic_1w5vm_34\",\"closeButtonWithImage\":\"_closeButtonWithImage_1w5vm_46\",\"closeButtonWithImageCambio\":\"_closeButtonWithImageCambio_1w5vm_50\"}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,gBAAgB;;;ACDmE,IAAO,uBAAQ,EAAC,YAAW,qBAAoB,mBAAkB,6BAA4B,kBAAiB,4BAA2B,eAAc,yBAAwB,sBAAqB,gCAA+B,wBAAuB,kCAAiC,8BAA6B,uCAAsC;;;ADgBlb,cAmNQ,YAnNR;AAHN,SAAS,MAAM,EAAE,QAAQ,OAAO,GAAuB;AACrD,SACE,oBAAC,SAAI,OAAM,8BAA6B,OAAM,MAAK,QAAO,MAAK,MAAM,OACnE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,GAAE;AAAA;AAAA,EACJ,GACF;AAEJ;AAEA,SAAS,YAAY,EAAE,UAAU,GAA2B;AAC1D,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,MAAK;AAAA,MACL,WAAU;AAAA,MACV,eAAY;AAAA,MACZ,SAAQ;AAAA,MAER,8BAAC,UAAK,GAAE,yGAAwG;AAAA;AAAA,EAClH;AAEJ;AAIA,IAAM,YAAY;AAAA,EAChB,IAAI;AAAA,EACJ,IAAI;AACN;AAmCe,SAAR,MAAuB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,0BAA0B;AAAA,EAC1B,OAAO;AA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,IACA;AAAA,EACF,EAAE,KAAK,GAAG;AACV,SAAO,GAAG,iBAAiB,QAAQ;AACrC;AAEA,IAAM,eAAe,CAAC,OAAqB;AACzC,MAAI,MAAM,OAAO,GAAG,UAAU,YAAY;AACxC,OAAG,MAAM;AAAA,EACX;AACF;AAKe,SAAR,UAA2B;AAAA,EAChC;AACF,GAEiB;AACf,QAAM,QAAQ,OAA8B,IAAI;AAChD,QAAM,yBAAyB,OAA2B,IAAI;AAE9D,YAAU,MAAM;AACd,UAAM,EAAE,SAAS,QAAQ,IAAI;AAG7B,UAAM,kBAAkB,MAAM;AAC5B,YAAM,eAAe,WAAW,OAAO;AACvC,UAAI,WAAW,CAAC,cAAc;AAC5B,qBAAa,kBAAkB,OAAO,EAAE,CAAC,CAAC;AAAA,MAC5C;AAAA,IACF;AAEA,UAAM,cAA2C,CAAC,UAAsB;AACtE,UACE,CAAC,WACA,MAAM,kBAAkB,QAAQ,QAAQ,SAAS,MAAM,MAAM,GAC9D;AACA;AAAA,MACF;AAGA,UACE,MAAM,kBAAkB,WACxB,MAAM,OAAO,QAAQ,mCAAmC,MAAM,MAC9D;AACA;AAAA,MACF;AAEA,YAAM,gBAAgB;AACtB,YAAM,eAAe;AACrB,sBAAgB;AAAA,IAClB;AAGA,2BAAuB,UAAU,SAAS;AAC1C,oBAAgB;AAChB,aAAS,iBAAiB,SAAS,aAAa,IAAI;AAEpD,WAAO,SAAS,UAAU;AACxB,YAAM,EAAE,SAAS,oBAAoB,IAAI;AACzC,eAAS,oBAAoB,SAAS,aAAa,IAAI;AAEvD,UAAI,qBAAqB;AACvB,qBAAa,mBAAmB;AAAA,MAClC;AAAA,IACF;AAAA,EACF,GAAG,CAAC,OAAO,sBAAsB,CAAC;AAElC,SACE,oBAAC,SAAI,eAAY,qBAAoB,KAAK,OACvC,UACH;AAEJ","sourcesContent":["import React, { useEffect, useRef, type ReactElement } from \"react\";\n\nfunction queryFocusableAll(el: HTMLDivElement): NodeListOf<HTMLElement> {\n // Focusable, interactive elements that could possibly be in children\n const selector = [\n \"a[href]\",\n \"area[href]\",\n \"input:not([disabled])\",\n \"select:not([disabled])\",\n \"textarea:not([disabled])\",\n \"button:not([disabled])\",\n \"iframe\",\n \"object\",\n \"embed\",\n '[tabindex=\"-1\"]',\n '[tabindex=\"0\"]',\n \"[contenteditable]\",\n \"audio[controls]\",\n \"video[controls]\",\n \"summary\",\n ].join(\",\");\n return el.querySelectorAll(selector);\n}\n\nconst focusElement = (el?: HTMLElement) => {\n if (el && typeof el.focus === \"function\") {\n el.focus();\n }\n};\n\n/**\n * FocusTrap is used by components like Modal to ensure that only elements within children components can be focused.\n */\nexport default function FocusTrap({\n children,\n}: {\n children?: ReactElement | null;\n}): ReactElement {\n const elRef = useRef<HTMLDivElement | null>(null);\n const previouslyFocusedElRef = useRef<HTMLElement | null>(null);\n\n useEffect(() => {\n const { current: element } = elRef;\n\n // Focus the first child element among all the focusable, interactive elements within `children`\n const focusFirstChild = () => {\n const withinIframe = window !== window.parent;\n if (element && !withinIframe) {\n focusElement(queryFocusableAll(element)[0]);\n }\n };\n\n const handleFocus: (event: FocusEvent) => void = (event: FocusEvent) => {\n if (\n !element ||\n (event.target instanceof Node && element.contains(event.target))\n ) {\n return;\n }\n\n // This prevents stack overflow when multiple FocusTraps are rendered\n if (\n event.target instanceof Element &&\n event.target.closest('[data-testid=\"syntax-focus-trap\"]') !== null\n ) {\n return;\n }\n\n event.stopPropagation();\n event.preventDefault();\n focusFirstChild();\n };\n\n // If an element has focus currently, keep a reference to that element\n previouslyFocusedElRef.current = document.activeElement as HTMLElement;\n focusFirstChild();\n document.addEventListener(\"focus\", handleFocus, true);\n\n return function cleanup() {\n const { current: previouslyFocusedEl } = previouslyFocusedElRef;\n document.removeEventListener(\"focus\", handleFocus, true);\n // If we previously stored a reference to a focused element, return focus to that element\n if (previouslyFocusedEl) {\n focusElement(previouslyFocusedEl);\n }\n };\n }, [elRef, previouslyFocusedElRef]);\n\n return (\n <div data-testid=\"syntax-focus-trap\" ref={elRef}>\n {children}\n </div>\n );\n}\n"]}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|