se-design 1.0.91 → 1.0.93
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/assets/icons/share.svg +6 -0
- package/dist/assets/style.css +1 -1
- package/dist/components/OnboardingTour/index.d.ts +3 -0
- package/dist/components/SidebarOverlay/index.d.ts +41 -0
- package/dist/index12.js +2 -2
- package/dist/index13.js +2 -2
- package/dist/index16.js +1 -1
- package/dist/index183.js +1 -1
- package/dist/index183.js.map +1 -1
- package/dist/index184.js +1 -1
- package/dist/index184.js.map +1 -1
- package/dist/index185.js +1 -1
- package/dist/index185.js.map +1 -1
- package/dist/index186.js +1 -1
- package/dist/index186.js.map +1 -1
- package/dist/index187.js +1 -1
- package/dist/index187.js.map +1 -1
- package/dist/index188.js +1 -1
- package/dist/index188.js.map +1 -1
- package/dist/index189.js +1 -1
- package/dist/index189.js.map +1 -1
- package/dist/index19.js +1 -1
- package/dist/index190.js +1 -1
- package/dist/index190.js.map +1 -1
- package/dist/index191.js +2 -2
- package/dist/index191.js.map +1 -1
- package/dist/index192.js +2 -2
- package/dist/index192.js.map +1 -1
- package/dist/index193.js +1 -1
- package/dist/index193.js.map +1 -1
- package/dist/index194.js +1 -1
- package/dist/index194.js.map +1 -1
- package/dist/index195.js +2 -2
- package/dist/index195.js.map +1 -1
- package/dist/index196.js +2 -2
- package/dist/index196.js.map +1 -1
- package/dist/index197.js +1 -1
- package/dist/index197.js.map +1 -1
- package/dist/index198.js +1 -1
- package/dist/index198.js.map +1 -1
- package/dist/index199.js +1 -1
- package/dist/index199.js.map +1 -1
- package/dist/index200.js +1 -1
- package/dist/index200.js.map +1 -1
- package/dist/index201.js +1 -1
- package/dist/index201.js.map +1 -1
- package/dist/index202.js +1 -1
- package/dist/index202.js.map +1 -1
- package/dist/index203.js +1 -1
- package/dist/index203.js.map +1 -1
- package/dist/index204.js +1 -1
- package/dist/index204.js.map +1 -1
- package/dist/index205.js +1 -1
- package/dist/index205.js.map +1 -1
- package/dist/index206.js +2 -2
- package/dist/index206.js.map +1 -1
- package/dist/index207.js +2 -2
- package/dist/index207.js.map +1 -1
- package/dist/index208.js +2 -2
- package/dist/index208.js.map +1 -1
- package/dist/index209.js +2 -149
- package/dist/index209.js.map +1 -1
- package/dist/index210.js +149 -9
- package/dist/index210.js.map +1 -1
- package/dist/index211.js +8 -5
- package/dist/index211.js.map +1 -1
- package/dist/index212.js +5 -42
- package/dist/index212.js.map +1 -1
- package/dist/index213.js +40 -18
- package/dist/index213.js.map +1 -1
- package/dist/index214.js +24 -0
- package/dist/index214.js.map +1 -0
- package/dist/index221.js +24 -68
- package/dist/index221.js.map +1 -1
- package/dist/index222.js +75 -0
- package/dist/index222.js.map +1 -0
- package/dist/{index228.js → index229.js} +1 -1
- package/dist/{index228.js.map → index229.js.map} +1 -1
- package/dist/{index230.js → index231.js} +1 -1
- package/dist/{index230.js.map → index231.js.map} +1 -1
- package/dist/{index238.js → index239.js} +1 -1
- package/dist/{index238.js.map → index239.js.map} +1 -1
- package/dist/index24.js +1 -1
- package/dist/{index241.js → index242.js} +1 -1
- package/dist/{index241.js.map → index242.js.map} +1 -1
- package/dist/index251.js +169 -3
- package/dist/index251.js.map +1 -1
- package/dist/index252.js +7 -0
- package/dist/index252.js.map +1 -0
- package/dist/index254.js +18 -9
- package/dist/index254.js.map +1 -1
- package/dist/index255.js +9 -9
- package/dist/index255.js.map +1 -1
- package/dist/index256.js +9 -4
- package/dist/index256.js.map +1 -1
- package/dist/index257.js +5 -170
- package/dist/index257.js.map +1 -1
- package/dist/index258.js +170 -11
- package/dist/index258.js.map +1 -1
- package/dist/index259.js +11 -6
- package/dist/index259.js.map +1 -1
- package/dist/index26.js +1 -1
- package/dist/index260.js +5 -5
- package/dist/index260.js.map +1 -1
- package/dist/index261.js +5 -37
- package/dist/index261.js.map +1 -1
- package/dist/index262.js +38 -2
- package/dist/index262.js.map +1 -1
- package/dist/index263.js +2 -8
- package/dist/index263.js.map +1 -1
- package/dist/index264.js +7 -326
- package/dist/index264.js.map +1 -1
- package/dist/index265.js +324 -47
- package/dist/index265.js.map +1 -1
- package/dist/index266.js +50 -2
- package/dist/index266.js.map +1 -1
- package/dist/index267.js +2 -76
- package/dist/index267.js.map +1 -1
- package/dist/index268.js +65 -82
- package/dist/index268.js.map +1 -1
- package/dist/index269.js +89 -48
- package/dist/index269.js.map +1 -1
- package/dist/index270.js +51 -7
- package/dist/index270.js.map +1 -1
- package/dist/index271.js +7 -4
- package/dist/index271.js.map +1 -1
- package/dist/index272.js +4 -51
- package/dist/index272.js.map +1 -1
- package/dist/index273.js +52 -2
- package/dist/index273.js.map +1 -1
- package/dist/index274.js +2 -2
- package/dist/index275.js +5 -0
- package/dist/index275.js.map +1 -0
- package/dist/index29.js +149 -88
- package/dist/index29.js.map +1 -1
- package/dist/index30.js +1 -1
- package/dist/index31.js +1 -1
- package/dist/index34.js +1 -1
- package/dist/index36.js +1 -1
- package/dist/index37.js +1 -1
- package/dist/index38.js +1 -1
- package/dist/index39.js +1 -1
- package/dist/index40.js +2 -2
- package/dist/index41.js +1 -1
- package/dist/index44.js +1 -1
- package/dist/index46.js +1 -1
- package/dist/index51.js +2 -2
- package/dist/index54.js +1 -1
- package/dist/index56.js +1 -1
- package/dist/index57.js +1 -1
- package/dist/index58.js +1 -1
- package/dist/index6.js +39 -37
- package/dist/index6.js.map +1 -1
- package/dist/index62.js +1 -1
- package/dist/index66.js +1 -1
- package/dist/index67.js +32 -31
- package/dist/index67.js.map +1 -1
- package/dist/index68.js +1 -1
- package/dist/index7.js +1 -1
- package/dist/index70.js +1 -1
- package/dist/index84.js +1 -1
- package/dist/index86.js +1 -1
- package/dist/index9.js +1 -1
- package/package.json +1 -1
- package/dist/index220.js +0 -31
- package/dist/index220.js.map +0 -1
- package/dist/index250.js +0 -173
- package/dist/index250.js.map +0 -1
- package/dist/index253.js +0 -22
- package/dist/index253.js.map +0 -1
package/dist/index6.js
CHANGED
|
@@ -119,10 +119,11 @@ import Jo from "./index205.js";
|
|
|
119
119
|
import Ko from "./index206.js";
|
|
120
120
|
import Qo from "./index207.js";
|
|
121
121
|
import Uo from "./index208.js";
|
|
122
|
+
import Wo from "./index209.js";
|
|
122
123
|
import a from "react";
|
|
123
|
-
import { ReactSVG as
|
|
124
|
-
import { getA11yNameAttributes as
|
|
125
|
-
import { useAccessiblePress as
|
|
124
|
+
import { ReactSVG as Xo } from "./index210.js";
|
|
125
|
+
import { getA11yNameAttributes as Yo } from "./index86.js";
|
|
126
|
+
import { useAccessiblePress as Zo } from "./index72.js";
|
|
126
127
|
import "./index77.js";
|
|
127
128
|
function m() {
|
|
128
129
|
return m = Object.assign ? Object.assign.bind() : function(s) {
|
|
@@ -133,7 +134,7 @@ function m() {
|
|
|
133
134
|
return s;
|
|
134
135
|
}, m.apply(null, arguments);
|
|
135
136
|
}
|
|
136
|
-
const
|
|
137
|
+
const zo = /* @__PURE__ */ Object.assign({
|
|
137
138
|
"/src/assets/icons/ai-off.svg": L,
|
|
138
139
|
"/src/assets/icons/ai-re-run.svg": R,
|
|
139
140
|
"/src/assets/icons/ai-search.svg": F,
|
|
@@ -229,37 +230,38 @@ const Zo = /* @__PURE__ */ Object.assign({
|
|
|
229
230
|
"/src/assets/icons/rounded-plus.svg": ko,
|
|
230
231
|
"/src/assets/icons/search.svg": xo,
|
|
231
232
|
"/src/assets/icons/select-files.svg": Ao,
|
|
232
|
-
"/src/assets/icons/
|
|
233
|
-
"/src/assets/icons/shield.svg": wo,
|
|
234
|
-
"/src/assets/icons/
|
|
235
|
-
"/src/assets/icons/shipment.svg": Po,
|
|
236
|
-
"/src/assets/icons/
|
|
237
|
-
"/src/assets/icons/
|
|
238
|
-
"/src/assets/icons/
|
|
239
|
-
"/src/assets/icons/
|
|
240
|
-
"/src/assets/icons/
|
|
241
|
-
"/src/assets/icons/
|
|
242
|
-
"/src/assets/icons/sort-
|
|
243
|
-
"/src/assets/icons/sort.svg": jo,
|
|
244
|
-
"/src/assets/icons/
|
|
245
|
-
"/src/assets/icons/
|
|
246
|
-
"/src/assets/icons/
|
|
247
|
-
"/src/assets/icons/
|
|
248
|
-
"/src/assets/icons/
|
|
249
|
-
"/src/assets/icons/
|
|
250
|
-
"/src/assets/icons/
|
|
251
|
-
"/src/assets/icons/
|
|
252
|
-
"/src/assets/icons/
|
|
253
|
-
"/src/assets/icons/
|
|
254
|
-
"/src/assets/icons/
|
|
255
|
-
"/src/assets/icons/
|
|
256
|
-
"/src/assets/icons/
|
|
257
|
-
"/src/assets/icons/
|
|
233
|
+
"/src/assets/icons/share.svg": Io,
|
|
234
|
+
"/src/assets/icons/shield-with-tick.svg": wo,
|
|
235
|
+
"/src/assets/icons/shield.svg": yo,
|
|
236
|
+
"/src/assets/icons/shipment-private.svg": Po,
|
|
237
|
+
"/src/assets/icons/shipment.svg": No,
|
|
238
|
+
"/src/assets/icons/sidebar.svg": Co,
|
|
239
|
+
"/src/assets/icons/signature-field.svg": Oo,
|
|
240
|
+
"/src/assets/icons/signer.svg": $o,
|
|
241
|
+
"/src/assets/icons/slideout.svg": Eo,
|
|
242
|
+
"/src/assets/icons/sms.svg": So,
|
|
243
|
+
"/src/assets/icons/sort-asc.svg": To,
|
|
244
|
+
"/src/assets/icons/sort-desc.svg": jo,
|
|
245
|
+
"/src/assets/icons/sort.svg": Lo,
|
|
246
|
+
"/src/assets/icons/space.svg": Ro,
|
|
247
|
+
"/src/assets/icons/stamp-field.svg": Fo,
|
|
248
|
+
"/src/assets/icons/stop.svg": Bo,
|
|
249
|
+
"/src/assets/icons/success-check.svg": Do,
|
|
250
|
+
"/src/assets/icons/tag.svg": Mo,
|
|
251
|
+
"/src/assets/icons/text-field.svg": qo,
|
|
252
|
+
"/src/assets/icons/tick.svg": Go,
|
|
253
|
+
"/src/assets/icons/title-field.svg": Vo,
|
|
254
|
+
"/src/assets/icons/upload-csv.svg": Ho,
|
|
255
|
+
"/src/assets/icons/views.svg": Jo,
|
|
256
|
+
"/src/assets/icons/warning.svg": Ko,
|
|
257
|
+
"/src/assets/icons/webinar-widget.svg": Qo,
|
|
258
|
+
"/src/assets/icons/white-close.svg": Uo,
|
|
259
|
+
"/src/assets/icons/widget-demo-image.svg": Wo
|
|
258
260
|
}), l = (s, t, o, _) => {
|
|
259
261
|
t && s.hasAttribute("fill") && s.getAttribute("fill") !== "none" && s.setAttribute("fill", t), o && s.hasAttribute("stroke") && s.setAttribute("stroke", o), _ && s.hasAttribute("width") && s.setAttribute("width", _.toString()), _ && s.hasAttribute("height") && s.setAttribute("height", _.toString()), Array.from(s.children).forEach((e) => {
|
|
260
262
|
l(e, t, o);
|
|
261
263
|
});
|
|
262
|
-
},
|
|
264
|
+
}, s_ = /* @__PURE__ */ a.forwardRef((s, t) => {
|
|
263
265
|
const {
|
|
264
266
|
name: o = "",
|
|
265
267
|
id: _,
|
|
@@ -287,7 +289,7 @@ const Zo = /* @__PURE__ */ Object.assign({
|
|
|
287
289
|
225: "rotate-[225deg]",
|
|
288
290
|
270: "-rotate-90",
|
|
289
291
|
315: "-rotate-45"
|
|
290
|
-
}, v =
|
|
292
|
+
}, v = zo[`/src/assets/icons/${o}.svg`];
|
|
291
293
|
if (!v)
|
|
292
294
|
return console.error(`Icon "${o}" not found in ICON_MAP.`), null;
|
|
293
295
|
const i = typeof g == "function", C = f || o, c = s.tabIndex !== void 0, {
|
|
@@ -295,13 +297,13 @@ const Zo = /* @__PURE__ */ Object.assign({
|
|
|
295
297
|
role: $,
|
|
296
298
|
tabIndex: E,
|
|
297
299
|
isDisabled: S
|
|
298
|
-
} =
|
|
300
|
+
} = Zo({
|
|
299
301
|
isNative: !1,
|
|
300
302
|
onClick: i ? (r) => g?.(r) : void 0,
|
|
301
303
|
disabled: i ? y : !1,
|
|
302
304
|
tabIndex: s.tabIndex ?? 0,
|
|
303
305
|
stopPropagation: w
|
|
304
|
-
}), n =
|
|
306
|
+
}), n = Yo({
|
|
305
307
|
ariaLabel: C,
|
|
306
308
|
ariaLabelledBy: b,
|
|
307
309
|
ariaDescribedBy: p
|
|
@@ -325,7 +327,7 @@ const Zo = /* @__PURE__ */ Object.assign({
|
|
|
325
327
|
...n
|
|
326
328
|
}, {
|
|
327
329
|
"data-automation-id": s?.automationId
|
|
328
|
-
}), /* @__PURE__ */ a.createElement(
|
|
330
|
+
}), /* @__PURE__ */ a.createElement(Xo, {
|
|
329
331
|
src: v,
|
|
330
332
|
wrapper: "span",
|
|
331
333
|
beforeInjection: (r) => {
|
|
@@ -333,8 +335,8 @@ const Zo = /* @__PURE__ */ Object.assign({
|
|
|
333
335
|
}
|
|
334
336
|
}));
|
|
335
337
|
});
|
|
336
|
-
|
|
338
|
+
s_.displayName = "Icon";
|
|
337
339
|
export {
|
|
338
|
-
|
|
340
|
+
s_ as Icon
|
|
339
341
|
};
|
|
340
342
|
//# sourceMappingURL=index6.js.map
|
package/dist/index6.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index6.js","sources":["../src/components/Icon/index.tsx"],"sourcesContent":["// TODO: `applyAttributesToElement` recursion drops `size` for nested elements (pre-existing).\nimport React from 'react';\nimport { ReactSVG } from 'react-svg';\nimport { getA11yNameAttributes, useAccessiblePress } from '../../utils/a11y';\n\n// Dynamically import icons using Vite's asset handling\nconst ICON_MAP: Record<string, string> = (import.meta as any).glob('/src/assets/icons/*.svg', {\n eager: true,\n query: '?url',\n import: 'default'\n});\n\nexport type RotationTypes = '0' | '45' | '90' | '135' | '180' | '225' | '270' | '315';\n\nexport type IconProps = {\n name: string;\n id?: string;\n className?: string;\n onClick?: (e?: React.MouseEvent<HTMLElement>) => void;\n /**\n * Accessible name when Icon is interactive (onClick is provided).\n * If omitted, we fall back to `name` and warn in development.\n */\n ariaLabel?: string;\n /**\n * ID(s) of visible element(s) that label this Icon when interactive.\n * Preferred over ariaLabel when a visible label exists (keeps SR and visual text in sync).\n */\n ariaLabelledBy?: string;\n /**\n * ID(s) of element(s) that describe this Icon when interactive (additional context).\n */\n ariaDescribedBy?: string;\n /**\n * Toggle state when Icon is used as a button (e.g., show/hide sidebar).\n * Only applies when `onClick` is provided (interactive icon).\n */\n ariaPressed?: boolean;\n /**\n * Expansion state when Icon controls a collapsible region/panel.\n * Only applies when `onClick` is provided (interactive icon).\n */\n ariaExpanded?: boolean;\n /**\n * ID of the element controlled by this Icon (for aria-controls).\n * Only applies when `onClick` is provided (interactive icon).\n */\n ariaControls?: string;\n fill?: string;\n stroke?: string;\n rotation?: RotationTypes;\n size?: number;\n shouldStopPropagation?: boolean;\n automationId?: string;\n /**\n * Disables the icon interaction while keeping it visible to AT with aria-disabled=\"true\".\n * Only applies when `onClick` is provided (interactive icon).\n */\n disabled?: boolean;\n /**\n * Native HTML title attribute — renders as a browser tooltip on hover.\n * For mouse users only; does not replace ariaLabel for screen readers.\n */\n htmlTitle?: string;\n /**\n * Override tab order. Pass tabIndex={0} to make a non-interactive or disabled icon\n * focusable (e.g. for tooltip access). Overrides the hook's default when provided.\n */\n tabIndex?: number;\n};\n\nconst applyAttributesToElement = (element: Element, fill?: string, stroke?: string, size?: number) => {\n // Only modify existing attributes\n if (fill && element.hasAttribute('fill')) {\n const currentFill = element.getAttribute('fill');\n // Only update if the current fill is not \"none\"\n if (currentFill !== 'none') {\n element.setAttribute('fill', fill);\n }\n }\n\n if (stroke && element.hasAttribute('stroke')) {\n element.setAttribute('stroke', stroke);\n }\n\n if (size && element.hasAttribute('width')) {\n element.setAttribute('width', size.toString());\n }\n\n if (size && element.hasAttribute('height')) {\n element.setAttribute('height', size.toString());\n }\n\n // Recursively apply to all child elements\n Array.from(element.children).forEach((child) => {\n applyAttributesToElement(child, fill, stroke);\n });\n};\n\nexport const Icon = React.forwardRef<HTMLDivElement, IconProps>((props, ref) => {\n const {\n name = '',\n id,\n className = '',\n onClick,\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy,\n ariaPressed,\n ariaExpanded,\n ariaControls,\n fill,\n stroke,\n rotation = '0',\n size,\n shouldStopPropagation = false,\n disabled = false,\n htmlTitle\n } = props;\n const iconRotationClasses = {\n '0': 'rotate-0',\n '45': 'rotate-45',\n '90': 'rotate-90',\n '135': 'rotate-[135deg]',\n '180': 'rotate-180',\n '225': 'rotate-[225deg]',\n '270': '-rotate-90',\n '315': '-rotate-45'\n };\n const src = ICON_MAP[`/src/assets/icons/${name}.svg`];\n\n if (!src) {\n console.error(`Icon \"${name}\" not found in ICON_MAP.`);\n return null;\n }\n\n const isInteractive = typeof onClick === 'function';\n const computedAriaLabel = ariaLabel || name;\n\n if (isInteractive && !ariaLabel && (import.meta as { env?: { DEV?: boolean } }).env?.DEV) {\n // eslint-disable-next-line no-console\n console.warn(\n `[se-design/Icon] Missing ariaLabel for clickable icon \"${name}\". ` +\n `Falling back to aria-label=\"${computedAriaLabel}\".`\n );\n }\n\n const hasTabIndex = props.tabIndex !== undefined;\n const { pressProps, role, tabIndex: hookTabIndex, isDisabled } = useAccessiblePress({\n isNative: false,\n onClick: isInteractive ? (e: React.MouseEvent<HTMLElement>) => onClick?.(e) : undefined,\n disabled: isInteractive ? disabled : false,\n tabIndex: props.tabIndex ?? 0,\n stopPropagation: shouldStopPropagation\n });\n\n // Compute accessible name/description props with correct precedence (aligns with Button/Link).\n const accessibleNameProps = getA11yNameAttributes({\n ariaLabel: computedAriaLabel,\n ariaLabelledBy,\n ariaDescribedBy\n });\n\n const finalTabIndex = hasTabIndex ? props.tabIndex : hookTabIndex;\n const interactiveProps = isInteractive\n ? {\n ...pressProps,\n role,\n tabIndex: finalTabIndex,\n ...accessibleNameProps,\n 'aria-pressed': ariaPressed,\n 'aria-expanded': ariaExpanded,\n 'aria-controls': ariaControls || undefined\n }\n : undefined;\n\n return (\n <div\n ref={ref}\n id={id}\n className={`se-design-svg-wrapper transition-transform duration-250 ease-linear rounded-[3px] ${\n isInteractive ? `${isDisabled ? 'opacity-50 cursor-default' : 'cursor-pointer focus-outline'}` : ''\n } ${className} ${iconRotationClasses[rotation]}`}\n aria-hidden={!isInteractive && !hasTabIndex ? 'true' : undefined}\n title={htmlTitle}\n {...interactiveProps}\n {...(!isInteractive && hasTabIndex && { tabIndex: props.tabIndex, ...accessibleNameProps })}\n data-automation-id={props?.automationId}\n >\n <ReactSVG\n src={src}\n wrapper=\"span\"\n beforeInjection={(svg) => {\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('role', 'none');\n applyAttributesToElement(svg, fill, stroke, size);\n }}\n />\n </div>\n );\n});\n\nIcon.displayName = 'Icon';\n"],"names":["ICON_MAP","import","applyAttributesToElement","element","fill","stroke","size","hasAttribute","getAttribute","setAttribute","toString","Array","from","children","forEach","child","Icon","React","forwardRef","props","ref","name","id","className","onClick","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaPressed","ariaExpanded","ariaControls","rotation","shouldStopPropagation","disabled","htmlTitle","iconRotationClasses","src","console","error","isInteractive","computedAriaLabel","hasTabIndex","tabIndex","undefined","pressProps","role","hookTabIndex","isDisabled","useAccessiblePress","isNative","e","stopPropagation","accessibleNameProps","getA11yNameAttributes","finalTabIndex","interactiveProps","createElement","_extends","title","automationId","ReactSVG","wrapper","beforeInjection","svg","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAMA,KAAoCC,uBAAAA,OAAAA;AAAAA,EAAAA,gCAAAA;AAAAA,EAAAA,mCAAAA;AAAAA,EAAAA,mCAAAA;AAAAA,EAAAA,kCAAAA;AAAAA,EAAAA,4BAAAA;AAAAA,EAAAA,mCAAAA;AAAAA,EAAAA,oCAAAA;AAAAA,EAAAA,oCAAAA;AAAAA,EAAAA,8BAAAA;AAAAA,EAAAA,yCAAAA;AAAAA,EAAAA,2CAAAA;AAAAA,EAAAA,8BAAAA;AAAAA,EAAAA,sCAAAA;AAAAA,EAAAA,8BAAAA;AAAAA,EAAAA,iDAAAA;A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;AAAAA,EAAAA,CAAa,GAExC1C,gBAAAA,EAAAuC,cAACI,IAAQ;AAAA,IACPxB,KAAAA;AAAAA,IACAyB,SAAQ;AAAA,IACRC,iBAAkBC,CAAAA,MAAQ;AACxBA,MAAAA,EAAItD,aAAa,eAAe,MAAM,GACtCsD,EAAItD,aAAa,QAAQ,MAAM,GAC/BP,EAAyB6D,GAAK3D,GAAMC,GAAQC,CAAI;AAAA,IAClD;AAAA,EAAA,CACD,CACE;AAET,CAAC;AAEDU,GAAKgD,cAAc;"}
|
|
1
|
+
{"version":3,"file":"index6.js","sources":["../src/components/Icon/index.tsx"],"sourcesContent":["// TODO: `applyAttributesToElement` recursion drops `size` for nested elements (pre-existing).\nimport React from 'react';\nimport { ReactSVG } from 'react-svg';\nimport { getA11yNameAttributes, useAccessiblePress } from '../../utils/a11y';\n\n// Dynamically import icons using Vite's asset handling\nconst ICON_MAP: Record<string, string> = (import.meta as any).glob('/src/assets/icons/*.svg', {\n eager: true,\n query: '?url',\n import: 'default'\n});\n\nexport type RotationTypes = '0' | '45' | '90' | '135' | '180' | '225' | '270' | '315';\n\nexport type IconProps = {\n name: string;\n id?: string;\n className?: string;\n onClick?: (e?: React.MouseEvent<HTMLElement>) => void;\n /**\n * Accessible name when Icon is interactive (onClick is provided).\n * If omitted, we fall back to `name` and warn in development.\n */\n ariaLabel?: string;\n /**\n * ID(s) of visible element(s) that label this Icon when interactive.\n * Preferred over ariaLabel when a visible label exists (keeps SR and visual text in sync).\n */\n ariaLabelledBy?: string;\n /**\n * ID(s) of element(s) that describe this Icon when interactive (additional context).\n */\n ariaDescribedBy?: string;\n /**\n * Toggle state when Icon is used as a button (e.g., show/hide sidebar).\n * Only applies when `onClick` is provided (interactive icon).\n */\n ariaPressed?: boolean;\n /**\n * Expansion state when Icon controls a collapsible region/panel.\n * Only applies when `onClick` is provided (interactive icon).\n */\n ariaExpanded?: boolean;\n /**\n * ID of the element controlled by this Icon (for aria-controls).\n * Only applies when `onClick` is provided (interactive icon).\n */\n ariaControls?: string;\n fill?: string;\n stroke?: string;\n rotation?: RotationTypes;\n size?: number;\n shouldStopPropagation?: boolean;\n automationId?: string;\n /**\n * Disables the icon interaction while keeping it visible to AT with aria-disabled=\"true\".\n * Only applies when `onClick` is provided (interactive icon).\n */\n disabled?: boolean;\n /**\n * Native HTML title attribute — renders as a browser tooltip on hover.\n * For mouse users only; does not replace ariaLabel for screen readers.\n */\n htmlTitle?: string;\n /**\n * Override tab order. Pass tabIndex={0} to make a non-interactive or disabled icon\n * focusable (e.g. for tooltip access). Overrides the hook's default when provided.\n */\n tabIndex?: number;\n};\n\nconst applyAttributesToElement = (element: Element, fill?: string, stroke?: string, size?: number) => {\n // Only modify existing attributes\n if (fill && element.hasAttribute('fill')) {\n const currentFill = element.getAttribute('fill');\n // Only update if the current fill is not \"none\"\n if (currentFill !== 'none') {\n element.setAttribute('fill', fill);\n }\n }\n\n if (stroke && element.hasAttribute('stroke')) {\n element.setAttribute('stroke', stroke);\n }\n\n if (size && element.hasAttribute('width')) {\n element.setAttribute('width', size.toString());\n }\n\n if (size && element.hasAttribute('height')) {\n element.setAttribute('height', size.toString());\n }\n\n // Recursively apply to all child elements\n Array.from(element.children).forEach((child) => {\n applyAttributesToElement(child, fill, stroke);\n });\n};\n\nexport const Icon = React.forwardRef<HTMLDivElement, IconProps>((props, ref) => {\n const {\n name = '',\n id,\n className = '',\n onClick,\n ariaLabel,\n ariaLabelledBy,\n ariaDescribedBy,\n ariaPressed,\n ariaExpanded,\n ariaControls,\n fill,\n stroke,\n rotation = '0',\n size,\n shouldStopPropagation = false,\n disabled = false,\n htmlTitle\n } = props;\n const iconRotationClasses = {\n '0': 'rotate-0',\n '45': 'rotate-45',\n '90': 'rotate-90',\n '135': 'rotate-[135deg]',\n '180': 'rotate-180',\n '225': 'rotate-[225deg]',\n '270': '-rotate-90',\n '315': '-rotate-45'\n };\n const src = ICON_MAP[`/src/assets/icons/${name}.svg`];\n\n if (!src) {\n console.error(`Icon \"${name}\" not found in ICON_MAP.`);\n return null;\n }\n\n const isInteractive = typeof onClick === 'function';\n const computedAriaLabel = ariaLabel || name;\n\n if (isInteractive && !ariaLabel && (import.meta as { env?: { DEV?: boolean } }).env?.DEV) {\n // eslint-disable-next-line no-console\n console.warn(\n `[se-design/Icon] Missing ariaLabel for clickable icon \"${name}\". ` +\n `Falling back to aria-label=\"${computedAriaLabel}\".`\n );\n }\n\n const hasTabIndex = props.tabIndex !== undefined;\n const { pressProps, role, tabIndex: hookTabIndex, isDisabled } = useAccessiblePress({\n isNative: false,\n onClick: isInteractive ? (e: React.MouseEvent<HTMLElement>) => onClick?.(e) : undefined,\n disabled: isInteractive ? disabled : false,\n tabIndex: props.tabIndex ?? 0,\n stopPropagation: shouldStopPropagation\n });\n\n // Compute accessible name/description props with correct precedence (aligns with Button/Link).\n const accessibleNameProps = getA11yNameAttributes({\n ariaLabel: computedAriaLabel,\n ariaLabelledBy,\n ariaDescribedBy\n });\n\n const finalTabIndex = hasTabIndex ? props.tabIndex : hookTabIndex;\n const interactiveProps = isInteractive\n ? {\n ...pressProps,\n role,\n tabIndex: finalTabIndex,\n ...accessibleNameProps,\n 'aria-pressed': ariaPressed,\n 'aria-expanded': ariaExpanded,\n 'aria-controls': ariaControls || undefined\n }\n : undefined;\n\n return (\n <div\n ref={ref}\n id={id}\n className={`se-design-svg-wrapper transition-transform duration-250 ease-linear rounded-[3px] ${\n isInteractive ? `${isDisabled ? 'opacity-50 cursor-default' : 'cursor-pointer focus-outline'}` : ''\n } ${className} ${iconRotationClasses[rotation]}`}\n aria-hidden={!isInteractive && !hasTabIndex ? 'true' : undefined}\n title={htmlTitle}\n {...interactiveProps}\n {...(!isInteractive && hasTabIndex && { tabIndex: props.tabIndex, ...accessibleNameProps })}\n data-automation-id={props?.automationId}\n >\n <ReactSVG\n src={src}\n wrapper=\"span\"\n beforeInjection={(svg) => {\n svg.setAttribute('aria-hidden', 'true');\n svg.setAttribute('role', 'none');\n applyAttributesToElement(svg, fill, stroke, size);\n }}\n />\n </div>\n );\n});\n\nIcon.displayName = 'Icon';\n"],"names":["ICON_MAP","import","applyAttributesToElement","element","fill","stroke","size","hasAttribute","getAttribute","setAttribute","toString","Array","from","children","forEach","child","Icon","React","forwardRef","props","ref","name","id","className","onClick","ariaLabel","ariaLabelledBy","ariaDescribedBy","ariaPressed","ariaExpanded","ariaControls","rotation","shouldStopPropagation","disabled","htmlTitle","iconRotationClasses","src","console","error","isInteractive","computedAriaLabel","hasTabIndex","tabIndex","undefined","pressProps","role","hookTabIndex","isDisabled","useAccessiblePress","isNative","e","stopPropagation","accessibleNameProps","getA11yNameAttributes","finalTabIndex","interactiveProps","createElement","_extends","title","automationId","ReactSVG","wrapper","beforeInjection","svg","displayName"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAMA,KAAoCC,uBAAAA,OAAAA;AAAAA,EAAAA,gCAAAA;AAAAA,EAAAA,mCAAAA;AAAAA,EAAAA,mCAAAA;AAAAA,EAAAA,kCAAAA;AAAAA,EAAAA,4BAAAA;AAAAA,EAAAA,mCAAAA;AAAAA,EAAAA,oCAAAA;AAAAA,EAAAA,oCAAAA;AAAAA,EAAAA,8BAAAA;AAAAA,EAAAA,yCAAAA;AAAAA,EAAAA,2CAAAA;AAAAA,EAAAA,8BAAAA;AAAAA,EAAAA,sCAAAA;AAAAA,EAAAA,8BAAAA;AAAAA,EAAAA,iDAAAA;AAAAA,EAAAA,gDAAAA;AAAAA,EAAAA,2CAAAA;AAAAA,EAAAA,wCAAAA;AAAAA,EAAAA,uCAAAA;AAAAA,EAAAA,6CAAAA;AAAAA,EAAAA,8CAAAA;AAAAA,EAAAA,6CAAAA;AAAAA,EAAAA,wCAAAA;AAAAA,EAAAA,uCAAAA;AAAAA,EAAAA,w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a,QAAQ,MAAM,GAC/BP,EAAyB6D,GAAK3D,GAAMC,GAAQC,CAAI;AAAA,IAClD;AAAA,EAAA,CACD,CACE;AAET,CAAC;AAEDU,GAAKgD,cAAc;"}
|
package/dist/index62.js
CHANGED
package/dist/index66.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import n, { useState as u, useCallback as y, useEffect as P } from "react";
|
|
2
2
|
import { Popover as I } from "./index19.js";
|
|
3
|
-
import { useStableId as k } from "./
|
|
3
|
+
import { useStableId as k } from "./index212.js";
|
|
4
4
|
/* empty css */
|
|
5
5
|
function p() {
|
|
6
6
|
return p = Object.assign ? Object.assign.bind() : function(r) {
|
package/dist/index67.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
import o, { useState as
|
|
1
|
+
import o, { useState as D, useRef as _, useCallback as m, useEffect as p } from "react";
|
|
2
2
|
import { Button as L } from "./index4.js";
|
|
3
|
-
import { Tooltip as
|
|
3
|
+
import { Tooltip as U } from "./index16.js";
|
|
4
4
|
/* empty css */
|
|
5
5
|
const u = {
|
|
6
6
|
gotIt: "got_it",
|
|
7
7
|
finish: "finish",
|
|
8
8
|
next: "next",
|
|
9
9
|
back: "back"
|
|
10
|
-
},
|
|
10
|
+
}, X = ({
|
|
11
11
|
steps: e = [],
|
|
12
12
|
screenBaseElementSelector: T = "",
|
|
13
13
|
handleCloseProductTour: d,
|
|
14
14
|
tourType: g = "",
|
|
15
15
|
automationId: f = "onboarding-tour",
|
|
16
16
|
highlightBorderRadius: E = 6,
|
|
17
|
-
|
|
17
|
+
customClassName: A = "",
|
|
18
|
+
labels: H
|
|
18
19
|
}) => {
|
|
19
|
-
const [t, k] =
|
|
20
|
-
next:
|
|
21
|
-
gotIt:
|
|
22
|
-
finish:
|
|
23
|
-
skip:
|
|
24
|
-
stepInfo:
|
|
25
|
-
} =
|
|
20
|
+
const [t, k] = D(0), c = _(null), l = _(null), {
|
|
21
|
+
next: P = "Next",
|
|
22
|
+
gotIt: M = "Got It",
|
|
23
|
+
finish: W = "Finish",
|
|
24
|
+
skip: O = "Skip tour",
|
|
25
|
+
stepInfo: V = "Step {step} of {total}"
|
|
26
|
+
} = H || {}, s = document.querySelector(T), y = m(() => {
|
|
26
27
|
let n;
|
|
27
28
|
if (t >= e.length)
|
|
28
29
|
return n;
|
|
@@ -40,24 +41,24 @@ const u = {
|
|
|
40
41
|
const x = document.querySelector(e[t]?.targetElementSelector);
|
|
41
42
|
if (!x || !c.current || !l.current)
|
|
42
43
|
return;
|
|
43
|
-
const a = x.getBoundingClientRect(),
|
|
44
|
-
c.current.style.height = `${
|
|
44
|
+
const a = x.getBoundingClientRect(), w = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);
|
|
45
|
+
c.current.style.height = `${w}px`;
|
|
45
46
|
const h = e[t]?.targetElementGap || {
|
|
46
47
|
horizontal: 0,
|
|
47
48
|
vertical: 0
|
|
48
|
-
}, S = E * 2,
|
|
49
|
-
<svg width="${
|
|
49
|
+
}, S = E * 2, N = a.left - h.horizontal, I = a.top + window.scrollY - h.vertical, F = a.right + h.horizontal, G = a.bottom + window.scrollY + h.vertical, q = F - N, B = G - I, C = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth), R = encodeURIComponent(`
|
|
50
|
+
<svg width="${C}" height="${w}" xmlns="http://www.w3.org/2000/svg">
|
|
50
51
|
<defs>
|
|
51
52
|
<mask id="highlight-mask-${t}">
|
|
52
|
-
<rect x="0" y="0" width="${
|
|
53
|
-
<rect x="${
|
|
53
|
+
<rect x="0" y="0" width="${C}" height="${w}" fill="white"/>
|
|
54
|
+
<rect x="${N}" y="${I}" width="${q}" height="${B}" rx="${S}" ry="${S}" fill="black"/>
|
|
54
55
|
</mask>
|
|
55
56
|
</defs>
|
|
56
57
|
</svg>
|
|
57
58
|
`);
|
|
58
|
-
c.current.style.maskImage = `url("data:image/svg+xml,${
|
|
59
|
+
c.current.style.maskImage = `url("data:image/svg+xml,${R}#highlight-mask-${t}")`, c.current.style.webkitMaskImage = `url("data:image/svg+xml,${R}#highlight-mask-${t}")`, l.current.style.top = `${a.top}px`, l.current.style.left = `${a.left}px`, l.current.style.width = `${a.width}px`, l.current.style.height = `${a.height}px`, l.current.style.borderRadius = `${E}px`;
|
|
59
60
|
}, 50), n;
|
|
60
|
-
}, [t, e]),
|
|
61
|
+
}, [t, e]), z = m(() => {
|
|
61
62
|
d(), s && s.scrollTo({
|
|
62
63
|
top: 0,
|
|
63
64
|
behavior: "smooth"
|
|
@@ -78,14 +79,14 @@ const u = {
|
|
|
78
79
|
}, [t, e, g]), b = m((n) => {
|
|
79
80
|
(n.keyCode === 37 || n.key === "ArrowLeft") && t > 0 && $(), (n.keyCode === 39 || n.key === "ArrowRight") && v();
|
|
80
81
|
}, [t, v, $]);
|
|
81
|
-
return
|
|
82
|
+
return p(() => (window.addEventListener("keydown", b), () => {
|
|
82
83
|
window.removeEventListener("keydown", b);
|
|
83
|
-
}), [b]),
|
|
84
|
+
}), [b]), p(() => {
|
|
84
85
|
let n;
|
|
85
86
|
return t < e.length && (n = y()), () => {
|
|
86
87
|
n && clearTimeout(n);
|
|
87
88
|
};
|
|
88
|
-
}, [t, e, y]),
|
|
89
|
+
}, [t, e, y]), p(() => {
|
|
89
90
|
if (t < e.length && c.current) {
|
|
90
91
|
const n = c.current, i = (r) => {
|
|
91
92
|
r.preventDefault(), r.stopPropagation();
|
|
@@ -104,9 +105,9 @@ const u = {
|
|
|
104
105
|
className: "se-design-onboarding-tour-overlay",
|
|
105
106
|
ref: c,
|
|
106
107
|
"data-automation-id": `${f}-overlay`
|
|
107
|
-
}), /* @__PURE__ */ o.createElement(
|
|
108
|
+
}), /* @__PURE__ */ o.createElement(U, {
|
|
108
109
|
content: /* @__PURE__ */ o.createElement("div", {
|
|
109
|
-
className:
|
|
110
|
+
className: `se-design-onboarding-tour-tooltip-content ${A}`
|
|
110
111
|
}, e[t]?.content?.illustration && /* @__PURE__ */ o.createElement("img", {
|
|
111
112
|
src: e[t].content.illustration,
|
|
112
113
|
className: "se-design-onboarding-tour-illustration",
|
|
@@ -114,26 +115,26 @@ const u = {
|
|
|
114
115
|
}), /* @__PURE__ */ o.createElement("div", {
|
|
115
116
|
className: "se-design-onboarding-tour-content"
|
|
116
117
|
}, e[t]?.content?.title && /* @__PURE__ */ o.createElement("p", {
|
|
117
|
-
className:
|
|
118
|
+
className: `se-design-onboarding-tour-title ${e[t].content.titleClassName || ""}`
|
|
118
119
|
}, e[t].content.title), e[t]?.content?.description && /* @__PURE__ */ o.createElement("p", {
|
|
119
|
-
className:
|
|
120
|
+
className: `se-design-onboarding-tour-description ${e[t].content.descriptionClassName || ""}`
|
|
120
121
|
}, e[t].content.description)), /* @__PURE__ */ o.createElement("div", {
|
|
121
122
|
className: "se-design-onboarding-tour-actions"
|
|
122
123
|
}, e.length > 1 && /* @__PURE__ */ o.createElement("span", {
|
|
123
124
|
className: "steps"
|
|
124
|
-
},
|
|
125
|
+
}, V.replace("{step}", `${t + 1}`).replace("{total}", `${e.length}`)), /* @__PURE__ */ o.createElement("div", {
|
|
125
126
|
className: "btns-container"
|
|
126
127
|
}, t !== e.length - 1 && /* @__PURE__ */ o.createElement(L, {
|
|
127
128
|
theme: "white",
|
|
128
129
|
type: "link",
|
|
129
|
-
label:
|
|
130
|
+
label: O,
|
|
130
131
|
automationId: `${f}-skip-button`,
|
|
131
|
-
onClick:
|
|
132
|
+
onClick: z
|
|
132
133
|
}), /* @__PURE__ */ o.createElement(L, {
|
|
133
134
|
theme: "white",
|
|
134
135
|
type: "primary",
|
|
135
136
|
size: "sm",
|
|
136
|
-
label: t === e.length - 1 ? e.length === 1 ?
|
|
137
|
+
label: t === e.length - 1 ? e.length === 1 ? M : W : P,
|
|
137
138
|
automationId: `${f}-next-button`,
|
|
138
139
|
onClick: v
|
|
139
140
|
})))),
|
|
@@ -150,6 +151,6 @@ const u = {
|
|
|
150
151
|
}));
|
|
151
152
|
};
|
|
152
153
|
export {
|
|
153
|
-
|
|
154
|
+
X as OnboardingTour
|
|
154
155
|
};
|
|
155
156
|
//# sourceMappingURL=index67.js.map
|
package/dist/index67.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index67.js","sources":["../src/components/OnboardingTour/index.tsx"],"sourcesContent":["import React, { FC, useEffect, useRef, useState, useCallback } from 'react';\n\nimport { Button } from 'components/Button';\nimport { Tooltip } from 'components/Tooltip';\n\nimport './style.scss';\n\nconst TOUR_NAVIGATION_STEPS = {\n gotIt: 'got_it',\n finish: 'finish',\n next: 'next',\n back: 'back'\n};\n\nexport interface TourStep {\n targetElementSelector: string;\n targetElementContainerSelector?: string;\n targetElementGap?: {\n horizontal: number;\n vertical: number;\n };\n tooltipPosition?:\n | 'top-left'\n | 'top-center'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-center'\n | 'bottom-right'\n | 'left-top'\n | 'left-center'\n | 'left-bottom'\n | 'right-top'\n | 'right-center'\n | 'right-bottom';\n content: {\n title?: string;\n description?: string;\n illustration?: any;\n };\n tourMixPanelHandler?: (data: { user_path: string; action_type: string }) => void;\n}\n\nexport interface OnboardingTourProps {\n steps: TourStep[];\n screenBaseElementSelector: string;\n handleCloseProductTour: (e?: React.MouseEvent<HTMLButtonElement>) => void;\n tourType?: string;\n highlightBorderRadius?: number;\n automationId?: string;\n labels?: {\n next: string;\n gotIt: string;\n finish: string;\n skip: string;\n stepInfo: string;\n };\n}\n\nexport const OnboardingTour: FC<OnboardingTourProps> = ({\n steps = [],\n screenBaseElementSelector = '',\n handleCloseProductTour,\n tourType = '',\n automationId = 'onboarding-tour',\n highlightBorderRadius = 6,\n labels\n}) => {\n const [currentStep, setCurrentStep] = useState(0);\n const overlayRef = useRef<HTMLDivElement>(null);\n const blockerRef = useRef<HTMLDivElement>(null);\n\n const {\n next = 'Next',\n gotIt = 'Got It',\n finish = 'Finish',\n skip = 'Skip tour',\n stepInfo = 'Step {step} of {total}'\n } = labels || {};\n\n const parentScreenElement = document.querySelector(screenBaseElementSelector) as HTMLElement | null;\n\n const clipTargetElementAndPositionTooltip = useCallback(() => {\n let timerId: any;\n\n if (currentStep >= steps.length) {\n return timerId;\n }\n\n // get the target element\n const initialTargetElement = document.querySelector(\n steps[currentStep]?.targetElementContainerSelector\n ? steps[currentStep].targetElementContainerSelector\n : steps[currentStep]?.targetElementSelector\n ) as HTMLElement | null;\n\n if (!initialTargetElement) {\n return timerId;\n }\n\n const initialTargetArea = initialTargetElement.getBoundingClientRect();\n\n // check whether target element is fully visible in viewport\n const isFullyVisible =\n initialTargetArea.top >= 0 &&\n initialTargetArea.left >= 0 &&\n initialTargetArea.bottom <= window.innerHeight &&\n initialTargetArea.right <= window.innerWidth;\n\n if (!isFullyVisible) {\n if (initialTargetArea.top < 0) {\n initialTargetElement.scrollIntoView({ behavior: 'auto', block: 'start' });\n } else if (initialTargetArea.bottom > window.innerHeight) {\n initialTargetElement.scrollIntoView({ behavior: 'auto', block: 'end' });\n }\n }\n\n // if the target element is visible, then clip the target element and position the tooltip\n timerId = setTimeout(() => {\n const targetElement = document.querySelector(steps[currentStep]?.targetElementSelector) as HTMLElement | null;\n\n if (!targetElement || !overlayRef.current || !blockerRef.current) {\n return;\n }\n\n const targetArea = targetElement.getBoundingClientRect();\n\n const documentHeight = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);\n\n // Update overlay dimensions and calculate target element area to focus\n overlayRef.current.style.height = `${documentHeight}px`;\n\n // Providing gap around target element\n const targetElementGap = steps[currentStep]?.targetElementGap || { horizontal: 0, vertical: 0 };\n\n // clip the target element with rounded corners\n const borderRadius = highlightBorderRadius * 2;\n const left = targetArea.left - targetElementGap.horizontal;\n const top = targetArea.top + window.scrollY - targetElementGap.vertical;\n const right = targetArea.right + targetElementGap.horizontal;\n const bottom = targetArea.bottom + window.scrollY + targetElementGap.vertical;\n const width = right - left;\n const height = bottom - top;\n const documentWidth = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth);\n\n // Create SVG mask with rounded rectangle hole\n const svgMask = encodeURIComponent(`\n <svg width=\"${documentWidth}\" height=\"${documentHeight}\" xmlns=\"http://www.w3.org/2000/svg\">\n <defs>\n <mask id=\"highlight-mask-${currentStep}\">\n <rect x=\"0\" y=\"0\" width=\"${documentWidth}\" height=\"${documentHeight}\" fill=\"white\"/>\n <rect x=\"${left}\" y=\"${top}\" width=\"${width}\" height=\"${height}\" rx=\"${borderRadius}\" ry=\"${borderRadius}\" fill=\"black\"/>\n </mask>\n </defs>\n </svg>\n `);\n\n // Apply created mask to the overlay\n overlayRef.current.style.maskImage = `url(\"data:image/svg+xml,${svgMask}#highlight-mask-${currentStep}\")`;\n overlayRef.current.style.webkitMaskImage = `url(\"data:image/svg+xml,${svgMask}#highlight-mask-${currentStep}\")`;\n\n // Position blocker over clipped area to avoid clicks on the target element\n blockerRef.current.style.top = `${targetArea.top}px`;\n blockerRef.current.style.left = `${targetArea.left}px`;\n blockerRef.current.style.width = `${targetArea.width}px`;\n blockerRef.current.style.height = `${targetArea.height}px`;\n blockerRef.current.style.borderRadius = `${highlightBorderRadius}px`;\n }, 50);\n\n return timerId;\n }, [currentStep, steps]);\n\n const handleSkipTour = useCallback(() => {\n handleCloseProductTour();\n if (parentScreenElement) {\n parentScreenElement.scrollTo({ top: 0, behavior: 'smooth' });\n }\n }, [handleCloseProductTour, parentScreenElement]);\n\n const handleNextClick = useCallback(\n (e?: React.MouseEvent<HTMLButtonElement>) => {\n e?.preventDefault();\n e?.stopPropagation();\n\n if (currentStep < steps.length - 1) {\n setCurrentStep((prev) => prev + 1);\n } else {\n handleCloseProductTour(e);\n if (parentScreenElement) {\n parentScreenElement.scrollTo({ top: 0, behavior: 'smooth' });\n }\n }\n steps[currentStep]?.tourMixPanelHandler?.({\n user_path: tourType,\n action_type: `clicked_${\n currentStep === steps.length - 1\n ? steps.length === 1\n ? TOUR_NAVIGATION_STEPS.gotIt\n : TOUR_NAVIGATION_STEPS.finish\n : TOUR_NAVIGATION_STEPS.next\n }`\n });\n },\n [currentStep, steps, handleCloseProductTour, tourType, parentScreenElement]\n );\n\n const handlePrevClick = useCallback(() => {\n if (currentStep > 0) {\n setCurrentStep((prev) => prev - 1);\n }\n steps[currentStep]?.tourMixPanelHandler?.({\n user_path: tourType,\n action_type: `clicked_${TOUR_NAVIGATION_STEPS.back}`\n });\n }, [currentStep, steps, tourType]);\n\n const handleKeyPress = useCallback(\n (e: KeyboardEvent) => {\n if (e.keyCode === 37 || e.key === 'ArrowLeft') {\n // for previous navigation\n if (currentStep > 0) {\n handlePrevClick();\n }\n }\n if (e.keyCode === 39 || e.key === 'ArrowRight') {\n // for next navigation\n handleNextClick();\n }\n },\n [currentStep, handleNextClick, handlePrevClick]\n );\n\n useEffect(() => {\n // Adding event listener for keydown\n window.addEventListener('keydown', handleKeyPress);\n\n return () => {\n window.removeEventListener('keydown', handleKeyPress);\n };\n }, [handleKeyPress]);\n\n useEffect(() => {\n let timerId: any;\n if (currentStep < steps.length) {\n timerId = clipTargetElementAndPositionTooltip();\n }\n\n return () => {\n if (timerId) {\n clearTimeout(timerId);\n }\n };\n }, [currentStep, steps, clipTargetElementAndPositionTooltip]);\n\n // To prevent scroll when tour is active\n useEffect(() => {\n if (currentStep < steps.length && overlayRef.current) {\n const overlay = overlayRef.current;\n\n const preventScroll = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n };\n\n overlay.addEventListener('wheel', preventScroll, { passive: false });\n overlay.addEventListener('touchmove', preventScroll, { passive: false });\n overlay.addEventListener('scroll', preventScroll, { passive: false });\n\n return () => {\n overlay.removeEventListener('wheel', preventScroll);\n overlay.removeEventListener('touchmove', preventScroll);\n overlay.removeEventListener('scroll', preventScroll);\n };\n }\n }, [currentStep]);\n\n if (!steps || steps.length === 0) {\n return null;\n }\n\n return (\n <>\n <div\n className=\"se-design-onboarding-tour-overlay\"\n ref={overlayRef}\n data-automation-id={`${automationId}-overlay`}\n />\n\n <Tooltip\n content={\n <div className=\"se-design-onboarding-tour-tooltip-content\">\n {steps[currentStep]?.content?.illustration && (\n <img\n src={steps[currentStep].content.illustration}\n className=\"se-design-onboarding-tour-illustration\"\n alt=\"illustration\"\n />\n )}\n <div className=\"se-design-onboarding-tour-content\">\n {steps[currentStep]?.content?.title && (\n <p className=\"se-design-onboarding-tour-title\">{steps[currentStep].content.title}</p>\n )}\n {steps[currentStep]?.content?.description && (\n <p className=\"se-design-onboarding-tour-description\">{steps[currentStep].content.description}</p>\n )}\n </div>\n\n <div className=\"se-design-onboarding-tour-actions\">\n {steps.length > 1 && (\n <span className=\"steps\">\n {stepInfo.replace('{step}', `${currentStep + 1}`).replace('{total}', `${steps.length}`)}\n </span>\n )}\n <div className=\"btns-container\">\n {currentStep !== steps.length - 1 && (\n <Button\n theme=\"white\"\n type=\"link\"\n label={skip}\n automationId={`${automationId}-skip-button`}\n onClick={handleSkipTour}\n />\n )}\n <Button\n theme=\"white\"\n type=\"primary\"\n size=\"sm\"\n label={currentStep === steps.length - 1 ? (steps.length === 1 ? gotIt : finish) : next}\n automationId={`${automationId}-next-button`}\n onClick={handleNextClick}\n />\n </div>\n </div>\n </div>\n }\n tooltipSrc={<div className=\"blocker\" ref={blockerRef} />}\n tooltipSrcRef={blockerRef as React.RefObject<HTMLDivElement>}\n position={steps[currentStep]?.tooltipPosition || 'bottom-center'}\n tooltipOffset={16}\n displayOn=\"always-on\"\n isWithPortal={true}\n maxWidth={384}\n />\n </>\n );\n};\n"],"names":["React__default","useState","useRef","useCallback","useEffect","Button","Tooltip","TOUR_NAVIGATION_STEPS","gotIt","finish","next","back","OnboardingTour","steps","screenBaseElementSelector","handleCloseProductTour","tourType","automationId","highlightBorderRadius","labels","currentStep","setCurrentStep","overlayRef","blockerRef","skip","stepInfo","parentScreenElement","document","querySelector","clipTargetElementAndPositionTooltip","timerId","length","initialTargetElement","targetElementContainerSelector","targetElementSelector","initialTargetArea","getBoundingClientRect","top","left","bottom","window","innerHeight","right","innerWidth","scrollIntoView","behavior","block","setTimeout","targetElement","current","targetArea","documentHeight","Math","max","documentElement","scrollHeight","body","style","height","targetElementGap","horizontal","vertical","borderRadius","scrollY","width","documentWidth","scrollWidth","svgMask","encodeURIComponent","maskImage","webkitMaskImage","handleSkipTour","scrollTo","handleNextClick","e","preventDefault","stopPropagation","prev","tourMixPanelHandler","user_path","action_type","handlePrevClick","handleKeyPress","keyCode","key","addEventListener","removeEventListener","clearTimeout","overlay","preventScroll","passive","createElement","React","Fragment","className","ref","content","illustration","src","alt","title","description","replace","theme","type","label","onClick","size","tooltipSrc","tooltipSrcRef","position","tooltipPosition","tooltipOffset","displayOn","isWithPortal","maxWidth"],"mappings":"AAOA,OAAAA,KAAA,YAAAC,GAAA,UAAAC,GAAA,eAAAC,GAAA,aAAAC,SAAA;AAAA,SAAA,UAAAC,SAAA;AAAA,SAAA,WAAAC,SAAA;AAAA,OAAA;AAAA,MAAMC,IAAwB;AAAA,EAC5BC,OAAO;AAAA,EACPC,QAAQ;AAAA,EACRC,MAAM;AAAA,EACNC,MAAM;AACR,GA8CaC,IAA0CA,CAAC;AAAA,EACtDC,OAAAA,IAAQ,CAAA;AAAA,EACRC,2BAAAA,IAA4B;AAAA,EAC5BC,wBAAAA;AAAAA,EACAC,UAAAA,IAAW;AAAA,EACXC,cAAAA,IAAe;AAAA,EACfC,uBAAAA,IAAwB;AAAA,EACxBC,QAAAA;AACF,MAAM;AACJ,QAAM,CAACC,GAAaC,CAAc,IAAIpB,EAAS,CAAC,GAC1CqB,IAAapB,EAAuB,IAAI,GACxCqB,IAAarB,EAAuB,IAAI,GAExC;AAAA,IACJQ,MAAAA,IAAO;AAAA,IACPF,OAAAA,IAAQ;AAAA,IACRC,QAAAA,IAAS;AAAA,IACTe,MAAAA,IAAO;AAAA,IACPC,UAAAA,IAAW;AAAA,EAAA,IACTN,KAAU,CAAA,GAERO,IAAsBC,SAASC,cAAcd,CAAyB,GAEtEe,IAAsC1B,EAAY,MAAM;AAC5D,QAAI2B;AAEJ,QAAIV,KAAeP,EAAMkB;AACvB,aAAOD;AAIT,UAAME,IA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A,CACX,CACD;AAEN;"}
|
|
1
|
+
{"version":3,"file":"index67.js","sources":["../src/components/OnboardingTour/index.tsx"],"sourcesContent":["import React, { FC, useEffect, useRef, useState, useCallback } from 'react';\n\nimport { Button } from 'components/Button';\nimport { Tooltip } from 'components/Tooltip';\n\nimport './style.scss';\n\nconst TOUR_NAVIGATION_STEPS = {\n gotIt: 'got_it',\n finish: 'finish',\n next: 'next',\n back: 'back'\n};\n\nexport interface TourStep {\n targetElementSelector: string;\n targetElementContainerSelector?: string;\n targetElementGap?: {\n horizontal: number;\n vertical: number;\n };\n tooltipPosition?:\n | 'top-left'\n | 'top-center'\n | 'top-right'\n | 'bottom-left'\n | 'bottom-center'\n | 'bottom-right'\n | 'left-top'\n | 'left-center'\n | 'left-bottom'\n | 'right-top'\n | 'right-center'\n | 'right-bottom';\n content: {\n title?: string;\n description?: string;\n illustration?: any;\n titleClassName?: string;\n descriptionClassName?: string;\n };\n tourMixPanelHandler?: (data: { user_path: string; action_type: string }) => void;\n}\n\nexport interface OnboardingTourProps {\n steps: TourStep[];\n screenBaseElementSelector: string;\n handleCloseProductTour: (e?: React.MouseEvent<HTMLButtonElement>) => void;\n tourType?: string;\n highlightBorderRadius?: number;\n automationId?: string;\n customClassName?: string;\n labels?: {\n next: string;\n gotIt: string;\n finish: string;\n skip: string;\n stepInfo: string;\n };\n}\n\nexport const OnboardingTour: FC<OnboardingTourProps> = ({\n steps = [],\n screenBaseElementSelector = '',\n handleCloseProductTour,\n tourType = '',\n automationId = 'onboarding-tour',\n highlightBorderRadius = 6,\n customClassName = '',\n labels\n}) => {\n const [currentStep, setCurrentStep] = useState(0);\n const overlayRef = useRef<HTMLDivElement>(null);\n const blockerRef = useRef<HTMLDivElement>(null);\n\n const {\n next = 'Next',\n gotIt = 'Got It',\n finish = 'Finish',\n skip = 'Skip tour',\n stepInfo = 'Step {step} of {total}'\n } = labels || {};\n\n const parentScreenElement = document.querySelector(screenBaseElementSelector) as HTMLElement | null;\n\n const clipTargetElementAndPositionTooltip = useCallback(() => {\n let timerId: any;\n\n if (currentStep >= steps.length) {\n return timerId;\n }\n\n // get the target element\n const initialTargetElement = document.querySelector(\n steps[currentStep]?.targetElementContainerSelector\n ? steps[currentStep].targetElementContainerSelector\n : steps[currentStep]?.targetElementSelector\n ) as HTMLElement | null;\n\n if (!initialTargetElement) {\n return timerId;\n }\n\n const initialTargetArea = initialTargetElement.getBoundingClientRect();\n\n // check whether target element is fully visible in viewport\n const isFullyVisible =\n initialTargetArea.top >= 0 &&\n initialTargetArea.left >= 0 &&\n initialTargetArea.bottom <= window.innerHeight &&\n initialTargetArea.right <= window.innerWidth;\n\n if (!isFullyVisible) {\n if (initialTargetArea.top < 0) {\n initialTargetElement.scrollIntoView({ behavior: 'auto', block: 'start' });\n } else if (initialTargetArea.bottom > window.innerHeight) {\n initialTargetElement.scrollIntoView({ behavior: 'auto', block: 'end' });\n }\n }\n\n // if the target element is visible, then clip the target element and position the tooltip\n timerId = setTimeout(() => {\n const targetElement = document.querySelector(steps[currentStep]?.targetElementSelector) as HTMLElement | null;\n\n if (!targetElement || !overlayRef.current || !blockerRef.current) {\n return;\n }\n\n const targetArea = targetElement.getBoundingClientRect();\n\n const documentHeight = Math.max(document.documentElement.scrollHeight, document.body.scrollHeight);\n\n // Update overlay dimensions and calculate target element area to focus\n overlayRef.current.style.height = `${documentHeight}px`;\n\n // Providing gap around target element\n const targetElementGap = steps[currentStep]?.targetElementGap || { horizontal: 0, vertical: 0 };\n\n // clip the target element with rounded corners\n const borderRadius = highlightBorderRadius * 2;\n const left = targetArea.left - targetElementGap.horizontal;\n const top = targetArea.top + window.scrollY - targetElementGap.vertical;\n const right = targetArea.right + targetElementGap.horizontal;\n const bottom = targetArea.bottom + window.scrollY + targetElementGap.vertical;\n const width = right - left;\n const height = bottom - top;\n const documentWidth = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth);\n\n // Create SVG mask with rounded rectangle hole\n const svgMask = encodeURIComponent(`\n <svg width=\"${documentWidth}\" height=\"${documentHeight}\" xmlns=\"http://www.w3.org/2000/svg\">\n <defs>\n <mask id=\"highlight-mask-${currentStep}\">\n <rect x=\"0\" y=\"0\" width=\"${documentWidth}\" height=\"${documentHeight}\" fill=\"white\"/>\n <rect x=\"${left}\" y=\"${top}\" width=\"${width}\" height=\"${height}\" rx=\"${borderRadius}\" ry=\"${borderRadius}\" fill=\"black\"/>\n </mask>\n </defs>\n </svg>\n `);\n\n // Apply created mask to the overlay\n overlayRef.current.style.maskImage = `url(\"data:image/svg+xml,${svgMask}#highlight-mask-${currentStep}\")`;\n overlayRef.current.style.webkitMaskImage = `url(\"data:image/svg+xml,${svgMask}#highlight-mask-${currentStep}\")`;\n\n // Position blocker over clipped area to avoid clicks on the target element\n blockerRef.current.style.top = `${targetArea.top}px`;\n blockerRef.current.style.left = `${targetArea.left}px`;\n blockerRef.current.style.width = `${targetArea.width}px`;\n blockerRef.current.style.height = `${targetArea.height}px`;\n blockerRef.current.style.borderRadius = `${highlightBorderRadius}px`;\n }, 50);\n\n return timerId;\n }, [currentStep, steps]);\n\n const handleSkipTour = useCallback(() => {\n handleCloseProductTour();\n if (parentScreenElement) {\n parentScreenElement.scrollTo({ top: 0, behavior: 'smooth' });\n }\n }, [handleCloseProductTour, parentScreenElement]);\n\n const handleNextClick = useCallback(\n (e?: React.MouseEvent<HTMLButtonElement>) => {\n e?.preventDefault();\n e?.stopPropagation();\n\n if (currentStep < steps.length - 1) {\n setCurrentStep((prev) => prev + 1);\n } else {\n handleCloseProductTour(e);\n if (parentScreenElement) {\n parentScreenElement.scrollTo({ top: 0, behavior: 'smooth' });\n }\n }\n steps[currentStep]?.tourMixPanelHandler?.({\n user_path: tourType,\n action_type: `clicked_${\n currentStep === steps.length - 1\n ? steps.length === 1\n ? TOUR_NAVIGATION_STEPS.gotIt\n : TOUR_NAVIGATION_STEPS.finish\n : TOUR_NAVIGATION_STEPS.next\n }`\n });\n },\n [currentStep, steps, handleCloseProductTour, tourType, parentScreenElement]\n );\n\n const handlePrevClick = useCallback(() => {\n if (currentStep > 0) {\n setCurrentStep((prev) => prev - 1);\n }\n steps[currentStep]?.tourMixPanelHandler?.({\n user_path: tourType,\n action_type: `clicked_${TOUR_NAVIGATION_STEPS.back}`\n });\n }, [currentStep, steps, tourType]);\n\n const handleKeyPress = useCallback(\n (e: KeyboardEvent) => {\n if (e.keyCode === 37 || e.key === 'ArrowLeft') {\n // for previous navigation\n if (currentStep > 0) {\n handlePrevClick();\n }\n }\n if (e.keyCode === 39 || e.key === 'ArrowRight') {\n // for next navigation\n handleNextClick();\n }\n },\n [currentStep, handleNextClick, handlePrevClick]\n );\n\n useEffect(() => {\n // Adding event listener for keydown\n window.addEventListener('keydown', handleKeyPress);\n\n return () => {\n window.removeEventListener('keydown', handleKeyPress);\n };\n }, [handleKeyPress]);\n\n useEffect(() => {\n let timerId: any;\n if (currentStep < steps.length) {\n timerId = clipTargetElementAndPositionTooltip();\n }\n\n return () => {\n if (timerId) {\n clearTimeout(timerId);\n }\n };\n }, [currentStep, steps, clipTargetElementAndPositionTooltip]);\n\n // To prevent scroll when tour is active\n useEffect(() => {\n if (currentStep < steps.length && overlayRef.current) {\n const overlay = overlayRef.current;\n\n const preventScroll = (e: Event) => {\n e.preventDefault();\n e.stopPropagation();\n };\n\n overlay.addEventListener('wheel', preventScroll, { passive: false });\n overlay.addEventListener('touchmove', preventScroll, { passive: false });\n overlay.addEventListener('scroll', preventScroll, { passive: false });\n\n return () => {\n overlay.removeEventListener('wheel', preventScroll);\n overlay.removeEventListener('touchmove', preventScroll);\n overlay.removeEventListener('scroll', preventScroll);\n };\n }\n }, [currentStep]);\n\n if (!steps || steps.length === 0) {\n return null;\n }\n\n return (\n <>\n <div\n className=\"se-design-onboarding-tour-overlay\"\n ref={overlayRef}\n data-automation-id={`${automationId}-overlay`}\n />\n\n <Tooltip\n content={\n <div className={`se-design-onboarding-tour-tooltip-content ${customClassName}`}>\n {steps[currentStep]?.content?.illustration && (\n <img\n src={steps[currentStep].content.illustration}\n className=\"se-design-onboarding-tour-illustration\"\n alt=\"illustration\"\n />\n )}\n <div className=\"se-design-onboarding-tour-content\">\n {steps[currentStep]?.content?.title && (\n <p\n className={`se-design-onboarding-tour-title ${steps[currentStep].content.titleClassName || ''}`}\n >\n {steps[currentStep].content.title}\n </p>\n )}\n {steps[currentStep]?.content?.description && (\n <p\n className={`se-design-onboarding-tour-description ${\n steps[currentStep].content.descriptionClassName || ''\n }`}\n >\n {steps[currentStep].content.description}\n </p>\n )}\n </div>\n\n <div className=\"se-design-onboarding-tour-actions\">\n {steps.length > 1 && (\n <span className=\"steps\">\n {stepInfo.replace('{step}', `${currentStep + 1}`).replace('{total}', `${steps.length}`)}\n </span>\n )}\n <div className=\"btns-container\">\n {currentStep !== steps.length - 1 && (\n <Button\n theme=\"white\"\n type=\"link\"\n label={skip}\n automationId={`${automationId}-skip-button`}\n onClick={handleSkipTour}\n />\n )}\n <Button\n theme=\"white\"\n type=\"primary\"\n size=\"sm\"\n label={currentStep === steps.length - 1 ? (steps.length === 1 ? gotIt : finish) : next}\n automationId={`${automationId}-next-button`}\n onClick={handleNextClick}\n />\n </div>\n </div>\n </div>\n }\n tooltipSrc={<div className=\"blocker\" ref={blockerRef} />}\n tooltipSrcRef={blockerRef as React.RefObject<HTMLDivElement>}\n position={steps[currentStep]?.tooltipPosition || 'bottom-center'}\n tooltipOffset={16}\n displayOn=\"always-on\"\n isWithPortal={true}\n maxWidth={384}\n />\n </>\n );\n};\n"],"names":["React__default","useState","useRef","useCallback","useEffect","Button","Tooltip","TOUR_NAVIGATION_STEPS","gotIt","finish","next","back","OnboardingTour","steps","screenBaseElementSelector","handleCloseProductTour","tourType","automationId","highlightBorderRadius","customClassName","labels","currentStep","setCurrentStep","overlayRef","blockerRef","skip","stepInfo","parentScreenElement","document","querySelector","clipTargetElementAndPositionTooltip","timerId","length","initialTargetElement","targetElementContainerSelector","targetElementSelector","initialTargetArea","getBoundingClientRect","top","left","bottom","window","innerHeight","right","innerWidth","scrollIntoView","behavior","block","setTimeout","targetElement","current","targetArea","documentHeight","Math","max","documentElement","scrollHeight","body","style","height","targetElementGap","horizontal","vertical","borderRadius","scrollY","width","documentWidth","scrollWidth","svgMask","encodeURIComponent","maskImage","webkitMaskImage","handleSkipTour","scrollTo","handleNextClick","e","preventDefault","stopPropagation","prev","tourMixPanelHandler","user_path","action_type","handlePrevClick","handleKeyPress","keyCode","key","addEventListener","removeEventListener","clearTimeout","overlay","preventScroll","passive","createElement","React","Fragment","className","ref","content","illustration","src","alt","title","titleClassName","description","descriptionClassName","replace","theme","type","label","onClick","size","tooltipSrc","tooltipSrcRef","position","tooltipPosition","tooltipOffset","displayOn","isWithPortal","maxWidth"],"mappings":"AAOA,OAAAA,KAAA,YAAAC,GAAA,UAAAC,GAAA,eAAAC,GAAA,aAAAC,SAAA;AAAA,SAAA,UAAAC,SAAA;AAAA,SAAA,WAAAC,SAAA;AAAA,OAAA;AAAA,MAAMC,IAAwB;AAAA,EAC5BC,OAAO;AAAA,EACPC,QAAQ;AAAA,EACRC,MAAM;AAAA,EACNC,MAAM;AACR,GAiDaC,IAA0CA,CAAC;AAAA,EACtDC,OAAAA,IAAQ,CAAA;AAAA,EACRC,2BAAAA,IAA4B;AAAA,EAC5BC,wBAAAA;AAAAA,EACAC,UAAAA,IAAW;AAAA,EACXC,cAAAA,IAAe;AAAA,EACfC,uBAAAA,IAAwB;AAAA,EACxBC,iBAAAA,IAAkB;AAAA,EAClBC,QAAAA;AACF,MAAM;AACJ,QAAM,CAACC,GAAaC,CAAc,IAAIrB,EAAS,CAAC,GAC1CsB,IAAarB,EAAuB,IAAI,GACxCsB,IAAatB,EAAuB,IAAI,GAExC;AAAA,IACJQ,MAAAA,IAAO;AAAA,IACPF,OAAAA,IAAQ;AAAA,IACRC,QAAAA,IAAS;AAAA,IACTgB,MAAAA,IAAO;AAAA,IACPC,UAAAA,IAAW;AAAA,EAAA,IACTN,KAAU,CAAA,GAERO,IAAsBC,SAASC,cAAcf,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YlB,gBAAAA,EAAAD,cAAA,OAAA;AAAA,MAAKG,WAAU;AAAA,MAAUC,KAAKxE;AAAAA,IAAAA,CAAa;AAAA,IACvDwF,eAAexF;AAAAA,IACfyF,UAAUpG,EAAMQ,CAAW,GAAG6F,mBAAmB;AAAA,IACjDC,eAAe;AAAA,IACfC,WAAU;AAAA,IACVC,cAAc;AAAA,IACdC,UAAU;AAAA,EAAA,CACX,CACD;AAEN;"}
|
package/dist/index68.js
CHANGED
|
@@ -2,7 +2,7 @@ import F, { useState as ot, useRef as X, useEffect as $ } from "react";
|
|
|
2
2
|
import { createPortal as nt } from "react-dom";
|
|
3
3
|
import { Icon as it } from "./index6.js";
|
|
4
4
|
import { Button as rt } from "./index4.js";
|
|
5
|
-
import { debounce as lt } from "./
|
|
5
|
+
import { debounce as lt } from "./index231.js";
|
|
6
6
|
const q = 500, S = 50, U = 150, st = {
|
|
7
7
|
"top-left": {
|
|
8
8
|
rotate: "315",
|
package/dist/index7.js
CHANGED
package/dist/index70.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Badge as j } from "./index10.js";
|
|
|
4
4
|
import { Icon as q } from "./index6.js";
|
|
5
5
|
import { Link as N } from "./index69.js";
|
|
6
6
|
import { CustomModal as G } from "./index13.js";
|
|
7
|
-
import { useStableId as J } from "./
|
|
7
|
+
import { useStableId as J } from "./index212.js";
|
|
8
8
|
/* empty css */
|
|
9
9
|
const K = {
|
|
10
10
|
lg: {
|
package/dist/index84.js
CHANGED
package/dist/index86.js
CHANGED
package/dist/index9.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import o from "react";
|
|
2
|
-
import { useStableId as A } from "./
|
|
2
|
+
import { useStableId as A } from "./index212.js";
|
|
3
3
|
import { getA11yNameAttributes as O } from "./index86.js";
|
|
4
4
|
import { useAccessiblePress as C } from "./index72.js";
|
|
5
5
|
import "./index77.js";
|
package/package.json
CHANGED
package/dist/index220.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useCallback as y, useEffect as d } from "react";
|
|
2
|
-
function p({
|
|
3
|
-
containerRef: E,
|
|
4
|
-
onDismiss: e,
|
|
5
|
-
enabled: t = !0,
|
|
6
|
-
useDocumentListener: u = !1,
|
|
7
|
-
preventDefault: c = !0,
|
|
8
|
-
stopPropagation: n = !0
|
|
9
|
-
}) {
|
|
10
|
-
const f = y((r) => {
|
|
11
|
-
!t || !e || r.key !== "Escape" || (c && r.preventDefault(), n && r.stopPropagation(), e());
|
|
12
|
-
}, [t, e, c, n]);
|
|
13
|
-
return d(() => {
|
|
14
|
-
if (!u || !t || !e) return;
|
|
15
|
-
const r = E?.current, a = (o) => {
|
|
16
|
-
o.key === "Escape" && (r && !r.contains(document.activeElement) || (c && o.preventDefault(), n && o.stopPropagation(), e()));
|
|
17
|
-
};
|
|
18
|
-
return document.addEventListener("keydown", a, {
|
|
19
|
-
capture: !0
|
|
20
|
-
}), () => document.removeEventListener("keydown", a, {
|
|
21
|
-
capture: !0
|
|
22
|
-
});
|
|
23
|
-
}, [u, t, e, E, c, n]), {
|
|
24
|
-
onKeyDown: u ? () => {
|
|
25
|
-
} : f
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export {
|
|
29
|
-
p as useDismissOnEscape
|
|
30
|
-
};
|
|
31
|
-
//# sourceMappingURL=index220.js.map
|
package/dist/index220.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index220.js","sources":["../src/utils/a11y/useDismissOnEscape.ts"],"sourcesContent":["import { useCallback, useEffect } from 'react';\nimport type { RefObject } from 'react';\n\nexport interface UseDismissOnEscapeOptions<T extends HTMLElement = HTMLElement> {\n /**\n * Container element ref — used for focus-check in document-level mode,\n * and for the returned onKeyDown in React-event mode.\n */\n containerRef?: RefObject<T | null>;\n /**\n * Callback when Escape key is pressed.\n */\n onDismiss?: () => void;\n /**\n * Whether the Escape handler is active.\n * Default: true\n */\n enabled?: boolean;\n /**\n * Use a native document-level capture listener instead of React's event system.\n * Only use this when React events can't reach the container (e.g. portals outside\n * the container's DOM tree). Prefer the default (false) for layered dismiss support.\n * Default: false\n */\n useDocumentListener?: boolean;\n /**\n * Whether to call e.preventDefault() on Escape.\n * Default: true\n */\n preventDefault?: boolean;\n /**\n * Whether to call e.stopPropagation() on Escape.\n * In React-event mode this is the layered-dismiss mechanism — set false only if\n * you want the event to continue bubbling to a parent dismiss handler.\n * Default: true\n */\n stopPropagation?: boolean;\n}\n\nexport interface UseDismissOnEscapeReturn {\n /**\n * Spread on the container element. In document-listener mode this is a no-op object.\n */\n onKeyDown: (e: React.KeyboardEvent) => void;\n}\n\n/**\n * Hook to handle Escape key dismissal.\n *\n * Default mode: returns an onKeyDown handler for the container element.\n * Uses React's synthetic events so child stopPropagation() is respected,\n * enabling layered dismiss (e.g. dropdown closes before sidebar).\n *\n * Document-listener mode (useDocumentListener: true): registers a native\n * capture listener on document. Use only when focus may be in a portal\n * outside the container's DOM tree.\n */\nexport function useDismissOnEscape<T extends HTMLElement = HTMLElement>({\n containerRef,\n onDismiss,\n enabled = true,\n useDocumentListener = false,\n preventDefault = true,\n stopPropagation = true,\n}: UseDismissOnEscapeOptions<T>): UseDismissOnEscapeReturn {\n // React-event mode: return handler to spread on container\n const onKeyDown = useCallback(\n (e: React.KeyboardEvent) => {\n if (!enabled || !onDismiss || e.key !== 'Escape') return;\n preventDefault && e.preventDefault();\n stopPropagation && e.stopPropagation();\n onDismiss();\n },\n [enabled, onDismiss, preventDefault, stopPropagation]\n );\n\n // Document-listener mode: native capture handler\n useEffect(() => {\n if (!useDocumentListener || !enabled || !onDismiss) return;\n\n const container = containerRef?.current;\n\n const handleEscape = (e: KeyboardEvent) => {\n if (e.key !== 'Escape') return;\n // Only fire if focus is within the container (if provided)\n if (container && !container.contains(document.activeElement)) return;\n preventDefault && e.preventDefault();\n stopPropagation && e.stopPropagation();\n onDismiss();\n };\n\n document.addEventListener('keydown', handleEscape, { capture: true });\n return () => document.removeEventListener('keydown', handleEscape, { capture: true });\n }, [useDocumentListener, enabled, onDismiss, containerRef, preventDefault, stopPropagation]);\n\n return { onKeyDown: useDocumentListener ? (() => {}) : onKeyDown };\n}\n"],"names":["useCallback","useEffect","useDismissOnEscape","containerRef","onDismiss","enabled","useDocumentListener","preventDefault","stopPropagation","onKeyDown","e","key","container","current","handleEscape","contains","document","activeElement","addEventListener","capture","removeEventListener"],"mappings":"AAyDO,SAAA,eAAAA,GAAA,aAAAC,SAAA;AAAA,SAASC,EAAwD;AAAA,EACtEC,cAAAA;AAAAA,EACAC,WAAAA;AAAAA,EACAC,SAAAA,IAAU;AAAA,EACVC,qBAAAA,IAAsB;AAAA,EACtBC,gBAAAA,IAAiB;AAAA,EACjBC,iBAAAA,IAAkB;AACU,GAA6B;AAEzD,QAAMC,IAAYT,EAChB,CAACU,MAA2B;AAC1B,IAAI,CAACL,KAAW,CAACD,KAAaM,EAAEC,QAAQ,aACxCJ,KAAkBG,EAAEH,eAAAA,GACpBC,KAAmBE,EAAEF,gBAAAA,GACrBJ,EAAAA;AAAAA,EACF,GACA,CAACC,GAASD,GAAWG,GAAgBC,CAAe,CACtD;AAGAP,SAAAA,EAAU,MAAM;AACd,QAAI,CAACK,KAAuB,CAACD,KAAW,CAACD,EAAW;AAEpD,UAAMQ,IAAYT,GAAcU,SAE1BC,IAAeA,CAACJ,MAAqB;AACzC,MAAIA,EAAEC,QAAQ,aAEVC,KAAa,CAACA,EAAUG,SAASC,SAASC,aAAa,MAC3DV,KAAkBG,EAAEH,eAAAA,GACpBC,KAAmBE,EAAEF,gBAAAA,GACrBJ,EAAAA;AAAAA,IACF;AAEAY,oBAASE,iBAAiB,WAAWJ,GAAc;AAAA,MAAEK,SAAS;AAAA,IAAA,CAAM,GAC7D,MAAMH,SAASI,oBAAoB,WAAWN,GAAc;AAAA,MAAEK,SAAS;AAAA,IAAA,CAAM;AAAA,EACtF,GAAG,CAACb,GAAqBD,GAASD,GAAWD,GAAcI,GAAgBC,CAAe,CAAC,GAEpF;AAAA,IAAEC,WAAWH,IAAuB,MAAM;AAAA,IAAC,IAAKG;AAAAA,EAAAA;AACzD;"}
|