@dynamic-framework/ui-react 2.10.0 → 2.11.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/DPortalStack-6zJm6JoD.js +14 -0
- package/dist/DPortalStack-6zJm6JoD.js.map +1 -0
- package/dist/DPortalStack-D1-GGU4C.js +12 -0
- package/dist/DPortalStack-D1-GGU4C.js.map +1 -0
- package/dist/api.json +7429 -0
- package/dist/css/dynamic-ui.css +95 -26
- package/dist/css/dynamic-ui.min.css +2 -2
- package/dist/esm/components/DAlert/DAlert.js +2 -2
- package/dist/esm/components/DAlert/DAlert.js.map +1 -1
- package/dist/esm/components/DButtonIcon/DButtonIcon.js +6 -3
- package/dist/esm/components/DButtonIcon/DButtonIcon.js.map +1 -1
- package/dist/esm/components/DDataStateWrapper/DDataStateWrapper.js +10 -3
- package/dist/esm/components/DDataStateWrapper/DDataStateWrapper.js.map +1 -1
- package/dist/esm/components/DErrorBoundary/DErrorBoundary.js +3 -3
- package/dist/esm/components/DErrorBoundary/DErrorBoundary.js.map +1 -1
- package/dist/esm/components/DErrorBoundary/components/DefaultErrorBoundary.js +2 -2
- package/dist/esm/components/DErrorBoundary/components/DefaultErrorBoundary.js.map +1 -1
- package/dist/esm/components/DInput/DInput.js +15 -3
- package/dist/esm/components/DInput/DInput.js.map +1 -1
- package/dist/esm/components/DInputCheck/DInputCheck.js +45 -8
- package/dist/esm/components/DInputCheck/DInputCheck.js.map +1 -1
- package/dist/esm/components/DInputCounter/DInputCounter.js +78 -20
- package/dist/esm/components/DInputCounter/DInputCounter.js.map +1 -1
- package/dist/esm/components/DInputCurrency/DInputCurrency.js +8 -3
- package/dist/esm/components/DInputCurrency/DInputCurrency.js.map +1 -1
- package/dist/esm/components/DInputPhone/DInputPhone.js +14 -2
- package/dist/esm/components/DInputPhone/DInputPhone.js.map +1 -1
- package/dist/esm/components/DInputPin/DInputPin.js +3 -1
- package/dist/esm/components/DInputPin/DInputPin.js.map +1 -1
- package/dist/esm/components/DInputRange/DInputRange.js +16 -2
- package/dist/esm/components/DInputRange/DInputRange.js.map +1 -1
- package/dist/esm/components/DInputSelect/DInputSelect.js +18 -4
- package/dist/esm/components/DInputSelect/DInputSelect.js.map +1 -1
- package/dist/esm/components/DInputSwitch/DInputSwitch.js +20 -9
- package/dist/esm/components/DInputSwitch/DInputSwitch.js.map +1 -1
- package/dist/esm/components/DListGroup/DListGroup.js +10 -2
- package/dist/esm/components/DListGroup/DListGroup.js.map +1 -1
- package/dist/esm/components/DListGroup/ListGroupContext.js +11 -0
- package/dist/esm/components/DListGroup/ListGroupContext.js.map +1 -0
- package/dist/esm/components/DListGroup/components/DListGroupItem.js +34 -16
- package/dist/esm/components/DListGroup/components/DListGroupItem.js.map +1 -1
- package/dist/esm/components/DListGroup/components/warnInvalidListMarkup.js +30 -0
- package/dist/esm/components/DListGroup/components/warnInvalidListMarkup.js.map +1 -0
- package/dist/esm/components/DPasswordStrengthMeter/DPasswordStrengthMeter.js +2 -2
- package/dist/esm/components/DPasswordStrengthMeter/DPasswordStrengthMeter.js.map +1 -1
- package/dist/esm/components/DProgress/DProgress.js +9 -3
- package/dist/esm/components/DProgress/DProgress.js.map +1 -1
- package/dist/esm/components/DSelect/DSelect.js +31 -3
- package/dist/esm/components/DSelect/DSelect.js.map +1 -1
- package/dist/esm/components/DSelect/createAriaGuidance.js +57 -0
- package/dist/esm/components/DSelect/createAriaGuidance.js.map +1 -0
- package/dist/esm/components/DTabs/DTabs.js +29 -40
- package/dist/esm/components/DTabs/DTabs.js.map +1 -1
- package/dist/esm/components/DTabs/TabContext.js +3 -2
- package/dist/esm/components/DTabs/TabContext.js.map +1 -1
- package/dist/esm/components/DTabs/components/DTabContent.js +2 -2
- package/dist/esm/components/DTabs/components/DTabContent.js.map +1 -1
- package/dist/esm/components/DTabs/components/DTabsProvider.js +22 -0
- package/dist/esm/components/DTabs/components/DTabsProvider.js.map +1 -0
- package/dist/esm/components/DTabs/index.js +1 -0
- package/dist/esm/components/DTabs/index.js.map +1 -1
- package/dist/esm/components/DToast/DToast.js +7 -2
- package/dist/esm/components/DToast/DToast.js.map +1 -1
- package/dist/esm/components/DToastContainer/useDToast.js +5 -5
- package/dist/esm/components/DToastContainer/useDToast.js.map +1 -1
- package/dist/esm/components/internal/DFormLabel.js +46 -0
- package/dist/esm/components/internal/DFormLabel.js.map +1 -0
- package/dist/esm/contexts/DPortalContext.js +43 -8
- package/dist/esm/contexts/DPortalContext.js.map +1 -1
- package/dist/esm/contexts/portal/DPortalStack.js +12 -0
- package/dist/esm/contexts/portal/DPortalStack.js.map +1 -0
- package/dist/esm/hooks/useControlledState.js +51 -0
- package/dist/esm/hooks/useControlledState.js.map +1 -0
- package/dist/esm/hooks/useInputCurrency.js +73 -19
- package/dist/esm/hooks/useInputCurrency.js.map +1 -1
- package/dist/esm/hooks/useMediaBreakpointUp.js +42 -3
- package/dist/esm/hooks/useMediaBreakpointUp.js.map +1 -1
- package/dist/esm/hooks/useResponsiveProp.js +13 -2
- package/dist/esm/hooks/useResponsiveProp.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/utils/hasLabelContent.js +48 -0
- package/dist/esm/utils/hasLabelContent.js.map +1 -0
- package/dist/esm/utils/isTextLabel.js +23 -0
- package/dist/esm/utils/isTextLabel.js.map +1 -0
- package/dist/esm/utils/labelClickGuard.js +61 -0
- package/dist/esm/utils/labelClickGuard.js.map +1 -0
- package/dist/esm/utils/warnLabelUsage.js +57 -0
- package/dist/esm/utils/warnLabelUsage.js.map +1 -0
- package/dist/icons-core.json +1 -1
- package/dist/index.esm.js +865 -163
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +864 -161
- package/dist/index.js.map +1 -1
- package/dist/types/components/DAlert/DAlert.d.ts +16 -2
- package/dist/types/components/DButtonIcon/DButtonIcon.d.ts +9 -1
- package/dist/types/components/DDataStateWrapper/DDataStateWrapper.d.ts +29 -4
- package/dist/types/components/DDataStateWrapper/index.d.ts +1 -1
- package/dist/types/components/DErrorBoundary/DErrorBoundary.d.ts +6 -1
- package/dist/types/components/DErrorBoundary/components/DefaultErrorBoundary.d.ts +3 -1
- package/dist/types/components/DInput/DInput.d.ts +11 -2
- package/dist/types/components/DInputCheck/DInputCheck.d.ts +28 -3
- package/dist/types/components/DInputCounter/DInputCounter.d.ts +15 -3
- package/dist/types/components/DInputCurrency/DInputCurrency.d.ts +10 -3
- package/dist/types/components/DInputPhone/DInputPhone.d.ts +11 -2
- package/dist/types/components/DInputPin/DInputPin.d.ts +12 -2
- package/dist/types/components/DInputRange/DInputRange.d.ts +15 -2
- package/dist/types/components/DInputSelect/DInputSelect.d.ts +18 -3
- package/dist/types/components/DInputSwitch/DInputSwitch.d.ts +28 -3
- package/dist/types/components/DListGroup/DListGroup.d.ts +12 -1
- package/dist/types/components/DListGroup/ListGroupContext.d.ts +8 -0
- package/dist/types/components/DListGroup/components/DListGroupItem.d.ts +6 -1
- package/dist/types/components/DListGroup/components/warnInvalidListMarkup.d.ts +13 -0
- package/dist/types/components/DPasswordStrengthMeter/DPasswordStrengthMeter.d.ts +18 -3
- package/dist/types/components/DProgress/DProgress.d.ts +13 -1
- package/dist/types/components/DSelect/DSelect.d.ts +23 -3
- package/dist/types/components/DSelect/createAriaGuidance.d.ts +21 -0
- package/dist/types/components/DTabs/DTabs.d.ts +13 -2
- package/dist/types/components/DTabs/TabContext.d.ts +5 -0
- package/dist/types/components/DTabs/components/DTabsProvider.d.ts +11 -0
- package/dist/types/components/DTabs/index.d.ts +1 -0
- package/dist/types/components/DToast/DToast.d.ts +10 -3
- package/dist/types/components/DToastContainer/useDToast.d.ts +8 -1
- package/dist/types/components/index.d.ts +2 -2
- package/dist/types/components/interface.d.ts +7 -0
- package/dist/types/components/internal/DFormLabel.d.ts +30 -0
- package/dist/types/contexts/portal/DPortalStack.d.ts +13 -0
- package/dist/types/hooks/useControlledState.d.ts +17 -0
- package/dist/types/hooks/useInputCurrency.d.ts +26 -1
- package/dist/types/hooks/useMediaBreakpointUp.d.ts +10 -0
- package/dist/types/utils/hasLabelContent.d.ts +30 -0
- package/dist/types/utils/isTextLabel.d.ts +17 -0
- package/dist/types/utils/labelClickGuard.d.ts +20 -0
- package/dist/types/utils/warnLabelUsage.d.ts +43 -0
- package/package.json +8 -3
- package/src/style/abstracts/variables/_body.scss +2 -2
- package/src/style/abstracts/variables/_chips.scss +2 -0
- package/src/style/abstracts/variables/_colors.scss +2 -2
- package/src/style/base/_buttons.scss +4 -1
- package/src/style/base/_input-group.scss +5 -2
- package/src/style/base/_list-group.scss +55 -0
- package/src/style/components/_d-chip.scss +7 -2
- package/src/style/components/_d-tabs.scss +3 -0
- package/src/style/helpers/_color-bg.scss +5 -0
- package/src/style/root/_root.scss +9 -0
|
@@ -1,33 +1,29 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { useState, useCallback, useEffect, useMemo, useRef,
|
|
2
|
+
import { useContext, useState, useCallback, useEffect, useMemo, useRef, Children } from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import TabContext from './TabContext.js';
|
|
4
|
+
import TabContext, { TabsStateContext } from './TabContext.js';
|
|
5
5
|
import DTabContent from './components/DTabContent.js';
|
|
6
|
+
import DTabsProvider from './components/DTabsProvider.js';
|
|
6
7
|
|
|
7
|
-
function DTabs({ children, defaultSelected, onChange, options, className, classNameTab, style, vertical, variant = 'underline', dataAttributes, ariaLabel, ariaLabelledBy, }) {
|
|
8
|
-
|
|
8
|
+
function DTabs({ children, defaultSelected, onChange, options, className, classNameTab, classNameContent, style, vertical, variant = 'underline', dataAttributes, ariaLabel, ariaLabelledBy, }) {
|
|
9
|
+
var _a;
|
|
10
|
+
const shared = useContext(TabsStateContext);
|
|
11
|
+
const [ownSelected, setOwnSelected] = useState(defaultSelected);
|
|
12
|
+
const selected = shared
|
|
13
|
+
? shared.selected
|
|
14
|
+
: ownSelected !== null && ownSelected !== void 0 ? ownSelected : (_a = options.find((opt) => !opt.disabled)) === null || _a === void 0 ? void 0 : _a.tab;
|
|
15
|
+
const setSelected = shared ? shared.setSelected : setOwnSelected;
|
|
9
16
|
const onSelect = useCallback((option) => {
|
|
10
17
|
if (option.tab) {
|
|
11
18
|
setSelected(option.tab);
|
|
12
19
|
}
|
|
13
20
|
onChange === null || onChange === void 0 ? void 0 : onChange(option);
|
|
14
|
-
}, [onChange]);
|
|
21
|
+
}, [onChange, setSelected]);
|
|
15
22
|
useEffect(() => {
|
|
16
|
-
|
|
23
|
+
setOwnSelected(defaultSelected);
|
|
17
24
|
}, [defaultSelected]);
|
|
18
25
|
const generateClasses = useMemo(() => (Object.assign({ nav: true, 'd-tabs-nav-vertical': vertical && variant !== 'tabs', [`nav-${variant}`]: true }, className && { [className]: true })), [vertical, variant, className]);
|
|
19
26
|
const tabRefs = useRef([]);
|
|
20
|
-
// Always holds the latest `options` without needing to be a dependency:
|
|
21
|
-
// `options` is commonly passed as an inline array literal (e.g.
|
|
22
|
-
// `options={[{ label: 'SMS', tab: 'sms' }, ...]}`), so it's a new array
|
|
23
|
-
// reference on every parent render even when its content hasn't changed.
|
|
24
|
-
// Reading it from this ref (updated synchronously on every render) lets
|
|
25
|
-
// the focus effect below react only to `selected` changing.
|
|
26
|
-
const optionsRef = useRef(options);
|
|
27
|
-
optionsRef.current = options;
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
tabRefs.current = options.map((_, i) => tabRefs.current[i] || createRef());
|
|
30
|
-
}, [options]);
|
|
31
27
|
// Ensure selected is never disabled
|
|
32
28
|
useEffect(() => {
|
|
33
29
|
if (options.length === 0)
|
|
@@ -38,29 +34,16 @@ function DTabs({ children, defaultSelected, onChange, options, className, classN
|
|
|
38
34
|
if (firstEnabled)
|
|
39
35
|
setSelected(firstEnabled.tab);
|
|
40
36
|
}
|
|
41
|
-
}, [options, selected]);
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
//
|
|
45
|
-
//
|
|
37
|
+
}, [options, selected, setSelected]);
|
|
38
|
+
// Focus only moves in response to the user: arrow keys and clicks call
|
|
39
|
+
// this directly. Changes to `selected` that don't come from an interaction
|
|
40
|
+
// (mount, a new `defaultSelected`, the disabled-tab fallback above) leave
|
|
41
|
+
// focus where it is, so the page doesn't scroll to the tablist and no other
|
|
42
|
+
// element (a search field, an OTP input) loses focus.
|
|
46
43
|
const focusTab = useCallback((idx) => {
|
|
47
44
|
var _a;
|
|
48
|
-
|
|
49
|
-
tabRefs.current[idx].current.focus();
|
|
50
|
-
}
|
|
45
|
+
(_a = tabRefs.current[idx]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
51
46
|
}, []);
|
|
52
|
-
// Focus selected tab when selected changes.
|
|
53
|
-
// Reads `options` from `optionsRef` (see comment above) instead of
|
|
54
|
-
// depending on `options` directly, so a parent re-render that merely
|
|
55
|
-
// creates a new `options` reference with identical content doesn't call
|
|
56
|
-
// `focusTab` again and steal focus away from unrelated elements on the
|
|
57
|
-
// page (e.g. an OTP input).
|
|
58
|
-
useEffect(() => {
|
|
59
|
-
const idx = optionsRef.current.findIndex((opt) => opt.tab === selected && !opt.disabled);
|
|
60
|
-
if (idx !== -1) {
|
|
61
|
-
focusTab(idx);
|
|
62
|
-
}
|
|
63
|
-
}, [selected, focusTab]);
|
|
64
47
|
const handleKeyDown = useCallback((idx, e) => {
|
|
65
48
|
const count = options.length;
|
|
66
49
|
if (count === 0)
|
|
@@ -89,7 +72,7 @@ function DTabs({ children, defaultSelected, onChange, options, className, classN
|
|
|
89
72
|
}
|
|
90
73
|
}
|
|
91
74
|
}
|
|
92
|
-
}, [options, vertical, focusTab]);
|
|
75
|
+
}, [options, vertical, focusTab, setSelected]);
|
|
93
76
|
let tablistProps = {};
|
|
94
77
|
if (ariaLabelledBy) {
|
|
95
78
|
tablistProps = { 'aria-labelledby': ariaLabelledBy };
|
|
@@ -106,11 +89,17 @@ function DTabs({ children, defaultSelected, onChange, options, className, classN
|
|
|
106
89
|
'd-tabs-column': !vertical || variant === 'tabs',
|
|
107
90
|
}), style: style }, dataAttributes, { children: [jsx("ul", Object.assign({ className: classNames(generateClasses), role: "tablist", "aria-orientation": vertical ? 'vertical' : undefined }, tablistProps, { children: options.map((option, idx) => {
|
|
108
91
|
const isTabSelected = !!option.tab && option.tab === selected;
|
|
109
|
-
return (jsx("li", { role: "presentation", className: "nav-item", children: jsx("button", { ref:
|
|
110
|
-
|
|
92
|
+
return (jsx("li", { role: "presentation", className: "nav-item", children: jsx("button", { ref: (element) => {
|
|
93
|
+
tabRefs.current[idx] = element;
|
|
94
|
+
}, id: `${option.tab}Tab`, className: classNames('nav-link', { active: isTabSelected }, classNameTab), type: "button", role: "tab", "aria-controls": `${option.tab}Pane`, "aria-selected": isTabSelected, tabIndex: isTabSelected ? 0 : -1, disabled: option.disabled, onClick: () => {
|
|
95
|
+
focusTab(idx);
|
|
96
|
+
onSelect(option);
|
|
97
|
+
}, onKeyDown: (e) => handleKeyDown(idx, e), children: option.label }) }, option.tab));
|
|
98
|
+
}) })), Children.toArray(children).length > 0 && (jsx("div", { className: classNames('d-tabs-content tab-content', classNameContent), children: children }))] })) }));
|
|
111
99
|
}
|
|
112
100
|
var DTabs$1 = Object.assign(DTabs, {
|
|
113
101
|
Tab: DTabContent,
|
|
102
|
+
Provider: DTabsProvider,
|
|
114
103
|
});
|
|
115
104
|
|
|
116
105
|
export { DTabs$1 as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DTabs.js","sources":["../../../../dist-transpiled/components/DTabs/DTabs.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { useState, useCallback, useEffect, useRef, createRef, useMemo, } from 'react';\nimport classNames from 'classnames';\nimport TabContext from './TabContext';\nimport DTabContent from './components/DTabContent';\nfunction DTabs({ children, defaultSelected, onChange, options, className, classNameTab, style, vertical, variant = 'underline', dataAttributes, ariaLabel, ariaLabelledBy, }) {\n const [selected, setSelected] = useState(defaultSelected);\n const onSelect = useCallback((option) => {\n if (option.tab) {\n setSelected(option.tab);\n }\n onChange === null || onChange === void 0 ? void 0 : onChange(option);\n }, [onChange]);\n useEffect(() => {\n setSelected(defaultSelected);\n }, [defaultSelected]);\n const generateClasses = useMemo(() => (Object.assign({ nav: true, 'd-tabs-nav-vertical': vertical && variant !== 'tabs', [`nav-${variant}`]: true }, className && { [className]: true })), [vertical, variant, className]);\n const tabRefs = useRef([]);\n // Always holds the latest `options` without needing to be a dependency:\n // `options` is commonly passed as an inline array literal (e.g.\n // `options={[{ label: 'SMS', tab: 'sms' }, ...]}`), so it's a new array\n // reference on every parent render even when its content hasn't changed.\n // Reading it from this ref (updated synchronously on every render) lets\n // the focus effect below react only to `selected` changing.\n const optionsRef = useRef(options);\n optionsRef.current = options;\n useEffect(() => {\n tabRefs.current = options.map((_, i) => tabRefs.current[i] || createRef());\n }, [options]);\n // Ensure selected is never disabled\n useEffect(() => {\n if (options.length === 0)\n return;\n const selectedOption = options.find((opt) => opt.tab === selected);\n if (selectedOption && selectedOption.disabled) {\n const firstEnabled = options.find((opt) => !opt.disabled);\n if (firstEnabled)\n setSelected(firstEnabled.tab);\n }\n }, [options, selected]);\n // Declarative focus management. Wrapped in `useCallback` with an empty\n // dependency array since it only reads from the `tabRefs` ref, so its\n // identity stays stable across renders and it can safely be used as an\n // effect dependency below.\n const focusTab = useCallback((idx) => {\n var _a;\n if ((_a = tabRefs.current[idx]) === null || _a === void 0 ? void 0 : _a.current) {\n tabRefs.current[idx].current.focus();\n }\n }, []);\n // Focus selected tab when selected changes.\n // Reads `options` from `optionsRef` (see comment above) instead of\n // depending on `options` directly, so a parent re-render that merely\n // creates a new `options` reference with identical content doesn't call\n // `focusTab` again and steal focus away from unrelated elements on the\n // page (e.g. an OTP input).\n useEffect(() => {\n const idx = optionsRef.current.findIndex((opt) => opt.tab === selected && !opt.disabled);\n if (idx !== -1) {\n focusTab(idx);\n }\n }, [selected, focusTab]);\n const handleKeyDown = useCallback((idx, e) => {\n const count = options.length;\n if (count === 0)\n return;\n let next = idx;\n let prev = idx;\n if (e.key === 'ArrowRight' || (vertical && e.key === 'ArrowDown')) {\n e.preventDefault();\n for (let i = 0; i < count; i += 1) {\n next = (next + 1) % count;\n if (!options[next].disabled) {\n focusTab(next);\n setSelected(options[next].tab);\n break;\n }\n }\n }\n if (e.key === 'ArrowLeft' || (vertical && e.key === 'ArrowUp')) {\n e.preventDefault();\n for (let i = 0; i < count; i += 1) {\n prev = (prev - 1 + count) % count;\n if (!options[prev].disabled) {\n focusTab(prev);\n setSelected(options[prev].tab);\n break;\n }\n }\n }\n }, [options, vertical, focusTab]);\n let tablistProps = {};\n if (ariaLabelledBy) {\n tablistProps = { 'aria-labelledby': ariaLabelledBy };\n }\n else if (ariaLabel) {\n tablistProps = { 'aria-label': ariaLabel };\n }\n const isSelected = useCallback((tab) => (selected === tab), [selected]);\n const value = useMemo(() => ({\n isSelected,\n }), [isSelected]);\n return (_jsx(TabContext.Provider, { value: value, children: _jsxs(\"div\", Object.assign({ className: classNames({\n 'd-tabs': true,\n 'd-tabs-column': !vertical || variant === 'tabs',\n }), style: style }, dataAttributes, { children: [_jsx(\"ul\", Object.assign({ className: classNames(generateClasses), role: \"tablist\", \"aria-orientation\": vertical ? 'vertical' : undefined }, tablistProps, { children: options.map((option, idx) => {\n const isTabSelected = !!option.tab && option.tab === selected;\n return (_jsx(\"li\", { role: \"presentation\", className: \"nav-item\", children: _jsx(\"button\", { ref: tabRefs.current[idx], id: `${option.tab}Tab`, className: classNames('nav-link', { active: isTabSelected }, classNameTab), type: \"button\", role: \"tab\", \"aria-controls\": `${option.tab}Pane`, \"aria-selected\": isTabSelected, tabIndex: isTabSelected ? 0 : -1, disabled: option.disabled, onClick: () => onSelect(option), onKeyDown: (e) => handleKeyDown(idx, e), children: option.label }) }, option.tab));\n }) })), _jsx(\"div\", { className: \"d-tabs-content tab-content\", children: children })] })) }));\n}\nexport default Object.assign(DTabs, {\n Tab: DTabContent,\n});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,EAAE,MAAM,CAAC,GAAG,CAAC;AACtgB,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAEA,GAAI,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,4BAA4B,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAChH;AACA,cAAe,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;AACpC,IAAI,GAAG,EAAE,WAAW;AACpB,CAAC,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"DTabs.js","sources":["../../../../dist-transpiled/components/DTabs/DTabs.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { Children, useState, useCallback, useContext, useEffect, useRef, useMemo, } from 'react';\nimport classNames from 'classnames';\nimport TabContext, { TabsStateContext } from './TabContext';\nimport DTabContent from './components/DTabContent';\nimport DTabsProvider from './components/DTabsProvider';\nfunction DTabs({ children, defaultSelected, onChange, options, className, classNameTab, classNameContent, style, vertical, variant = 'underline', dataAttributes, ariaLabel, ariaLabelledBy, }) {\n var _a;\n const shared = useContext(TabsStateContext);\n const [ownSelected, setOwnSelected] = useState(defaultSelected);\n const selected = shared\n ? shared.selected\n : ownSelected !== null && ownSelected !== void 0 ? ownSelected : (_a = options.find((opt) => !opt.disabled)) === null || _a === void 0 ? void 0 : _a.tab;\n const setSelected = shared ? shared.setSelected : setOwnSelected;\n const onSelect = useCallback((option) => {\n if (option.tab) {\n setSelected(option.tab);\n }\n onChange === null || onChange === void 0 ? void 0 : onChange(option);\n }, [onChange, setSelected]);\n useEffect(() => {\n setOwnSelected(defaultSelected);\n }, [defaultSelected]);\n const generateClasses = useMemo(() => (Object.assign({ nav: true, 'd-tabs-nav-vertical': vertical && variant !== 'tabs', [`nav-${variant}`]: true }, className && { [className]: true })), [vertical, variant, className]);\n const tabRefs = useRef([]);\n // Ensure selected is never disabled\n useEffect(() => {\n if (options.length === 0)\n return;\n const selectedOption = options.find((opt) => opt.tab === selected);\n if (selectedOption && selectedOption.disabled) {\n const firstEnabled = options.find((opt) => !opt.disabled);\n if (firstEnabled)\n setSelected(firstEnabled.tab);\n }\n }, [options, selected, setSelected]);\n // Focus only moves in response to the user: arrow keys and clicks call\n // this directly. Changes to `selected` that don't come from an interaction\n // (mount, a new `defaultSelected`, the disabled-tab fallback above) leave\n // focus where it is, so the page doesn't scroll to the tablist and no other\n // element (a search field, an OTP input) loses focus.\n const focusTab = useCallback((idx) => {\n var _a;\n (_a = tabRefs.current[idx]) === null || _a === void 0 ? void 0 : _a.focus();\n }, []);\n const handleKeyDown = useCallback((idx, e) => {\n const count = options.length;\n if (count === 0)\n return;\n let next = idx;\n let prev = idx;\n if (e.key === 'ArrowRight' || (vertical && e.key === 'ArrowDown')) {\n e.preventDefault();\n for (let i = 0; i < count; i += 1) {\n next = (next + 1) % count;\n if (!options[next].disabled) {\n focusTab(next);\n setSelected(options[next].tab);\n break;\n }\n }\n }\n if (e.key === 'ArrowLeft' || (vertical && e.key === 'ArrowUp')) {\n e.preventDefault();\n for (let i = 0; i < count; i += 1) {\n prev = (prev - 1 + count) % count;\n if (!options[prev].disabled) {\n focusTab(prev);\n setSelected(options[prev].tab);\n break;\n }\n }\n }\n }, [options, vertical, focusTab, setSelected]);\n let tablistProps = {};\n if (ariaLabelledBy) {\n tablistProps = { 'aria-labelledby': ariaLabelledBy };\n }\n else if (ariaLabel) {\n tablistProps = { 'aria-label': ariaLabel };\n }\n const isSelected = useCallback((tab) => (selected === tab), [selected]);\n const value = useMemo(() => ({\n isSelected,\n }), [isSelected]);\n return (_jsx(TabContext.Provider, { value: value, children: _jsxs(\"div\", Object.assign({ className: classNames({\n 'd-tabs': true,\n 'd-tabs-column': !vertical || variant === 'tabs',\n }), style: style }, dataAttributes, { children: [_jsx(\"ul\", Object.assign({ className: classNames(generateClasses), role: \"tablist\", \"aria-orientation\": vertical ? 'vertical' : undefined }, tablistProps, { children: options.map((option, idx) => {\n const isTabSelected = !!option.tab && option.tab === selected;\n return (_jsx(\"li\", { role: \"presentation\", className: \"nav-item\", children: _jsx(\"button\", { ref: (element) => {\n tabRefs.current[idx] = element;\n }, id: `${option.tab}Tab`, className: classNames('nav-link', { active: isTabSelected }, classNameTab), type: \"button\", role: \"tab\", \"aria-controls\": `${option.tab}Pane`, \"aria-selected\": isTabSelected, tabIndex: isTabSelected ? 0 : -1, disabled: option.disabled, onClick: () => {\n focusTab(idx);\n onSelect(option);\n }, onKeyDown: (e) => handleKeyDown(idx, e), children: option.label }) }, option.tab));\n }) })), Children.toArray(children).length > 0 && (_jsx(\"div\", { className: classNames('d-tabs-content tab-content', classNameContent), children: children }))] })) }));\n}\nexport default Object.assign(DTabs, {\n Tab: DTabContent,\n Provider: DTabsProvider,\n});\n//# sourceMappingURL=DTabs.js.map"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;AAMA,SAAS,KAAK,CAAC,EAAE,QAAQ,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,gBAAgB,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,GAAG,WAAW,EAAE,cAAc,EAAE,SAAS,EAAE,cAAc,GAAG,EAAE;AAChM,IAAI,IAAI,EAAE;AACV,IAAI,MAAM,MAAM,GAAG,UAAU,CAAC,gBAAgB,CAAC;AAC/C,IAAI,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC;AACnE,IAAI,MAAM,QAAQ,GAAG;AACrB,UAAU,MAAM,CAAC;AACjB,UAAU,WAAW,KAAK,IAAI,IAAI,WAAW,KAAK,MAAM,GAAG,WAAW,GAAG,CAAC,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,IAAI,IAAI,EAAE,KAAK,MAAM,GAAG,MAAM,GAAG,EAAE,CAAC,GAAG;AAChK,IAAI,MAAM,WAAW,G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AAG,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,OAAO,EAAE,MAAM;AACtT,oCAAoC,QAAQ,CAAC,GAAG,CAAC;AACjD,oCAAoC,QAAQ,CAAC,MAAM,CAAC;AACpD,gCAAgC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,KAAK,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC;AACpH,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC,KAAKA,GAAI,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,4BAA4B,EAAE,gBAAgB,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AACzL;AACA,cAAe,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE;AACpC,IAAI,GAAG,EAAE,WAAW;AACpB,IAAI,QAAQ,EAAE,aAAa;AAC3B,CAAC,CAAC;;;;"}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { useContext, createContext } from 'react';
|
|
2
2
|
|
|
3
3
|
const TabContext = createContext(undefined);
|
|
4
|
+
const TabsStateContext = createContext(undefined);
|
|
4
5
|
function useTabContext() {
|
|
5
6
|
const context = useContext(TabContext);
|
|
6
7
|
if (context === undefined) {
|
|
7
|
-
throw new Error('useTabContext was used outside of
|
|
8
|
+
throw new Error('useTabContext was used outside of DTabs');
|
|
8
9
|
}
|
|
9
10
|
return context;
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
export { TabContext as default, useTabContext };
|
|
13
|
+
export { TabsStateContext, TabContext as default, useTabContext };
|
|
13
14
|
//# sourceMappingURL=TabContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TabContext.js","sources":["../../../../dist-transpiled/components/DTabs/TabContext.js"],"sourcesContent":["import { createContext, useContext } from 'react';\nconst TabContext = createContext(undefined);\nexport function useTabContext() {\n const context = useContext(TabContext);\n if (context === undefined) {\n throw new Error('useTabContext was used outside of
|
|
1
|
+
{"version":3,"file":"TabContext.js","sources":["../../../../dist-transpiled/components/DTabs/TabContext.js"],"sourcesContent":["import { createContext, useContext } from 'react';\nconst TabContext = createContext(undefined);\nexport const TabsStateContext = createContext(undefined);\nexport function useTabContext() {\n const context = useContext(TabContext);\n if (context === undefined) {\n throw new Error('useTabContext was used outside of DTabs');\n }\n return context;\n}\nexport default TabContext;\n//# sourceMappingURL=TabContext.js.map"],"names":[],"mappings":";;AACK,MAAC,UAAU,GAAG,aAAa,CAAC,SAAS;AAC9B,MAAC,gBAAgB,GAAG,aAAa,CAAC,SAAS;AAChD,SAAS,aAAa,GAAG;AAChC,IAAI,MAAM,OAAO,GAAG,UAAU,CAAC,UAAU,CAAC;AAC1C,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE;AAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC;AAClE,IAAI;AACJ,IAAI,OAAO,OAAO;AAClB;;;;"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
|
-
import { useTabContext } from '../TabContext.js';
|
|
3
|
+
import { useTabContext, TabsStateContext } from '../TabContext.js';
|
|
4
4
|
|
|
5
5
|
function DTabContent({ tab, children, className, style, }) {
|
|
6
6
|
const { isSelected } = useTabContext();
|
|
7
7
|
if (!isSelected(tab)) {
|
|
8
8
|
return null;
|
|
9
9
|
}
|
|
10
|
-
return (jsx("div", { className: classNames('tab-pane fade show active', className), id: `${tab}Pane`, role: "tabpanel", tabIndex: 0, "aria-labelledby": `${tab}Tab`, style: style, children: children }));
|
|
10
|
+
return (jsx("div", { className: classNames('tab-pane fade show active', className), id: `${tab}Pane`, role: "tabpanel", tabIndex: 0, "aria-labelledby": `${tab}Tab`, style: style, children: jsx(TabsStateContext.Provider, { value: undefined, children: children }) }));
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export { DTabContent as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DTabContent.js","sources":["../../../../../dist-transpiled/components/DTabs/components/DTabContent.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport classNames from 'classnames';\nimport { useTabContext } from '../TabContext';\nexport default function DTabContent({ tab, children, className, style, }) {\n const { isSelected } = useTabContext();\n if (!isSelected(tab)) {\n return null;\n }\n return (_jsx(\"div\", { className: classNames('tab-pane fade show active', className), id: `${tab}Pane`, role: \"tabpanel\", tabIndex: 0, \"aria-labelledby\": `${tab}Tab`, style: style, children: children }));\n}\n//# sourceMappingURL=DTabContent.js.map"],"names":["_jsx"],"mappings":";;;;AAGe,SAAS,WAAW,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,GAAG,EAAE;AAC1E,IAAI,MAAM,EAAE,UAAU,EAAE,GAAG,aAAa,EAAE;AAC1C,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;AAC1B,QAAQ,OAAO,IAAI;AACnB,IAAI;AACJ,IAAI,QAAQA,GAAI,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,2BAA2B,EAAE,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"DTabContent.js","sources":["../../../../../dist-transpiled/components/DTabs/components/DTabContent.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport classNames from 'classnames';\nimport { TabsStateContext, useTabContext } from '../TabContext';\nexport default function DTabContent({ tab, children, className, style, }) {\n const { isSelected } = useTabContext();\n if (!isSelected(tab)) {\n return null;\n }\n return (_jsx(\"div\", { className: classNames('tab-pane fade show active', className), id: `${tab}Pane`, role: \"tabpanel\", tabIndex: 0, \"aria-labelledby\": `${tab}Tab`, style: style, children: _jsx(TabsStateContext.Provider, { value: undefined, children: children }) }));\n}\n//# sourceMappingURL=DTabContent.js.map"],"names":["_jsx"],"mappings":";;;;AAGe,SAAS,WAAW,CAAC,EAAE,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,GAAG,EAAE;AAC1E,IAAI,MAAM,EAAE,UAAU,EAAE,GAAG,aAAa,EAAE;AAC1C,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE;AAC1B,QAAQ,OAAO,IAAI;AACnB,IAAI;AACJ,IAAI,QAAQA,GAAI,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,UAAU,CAAC,2BAA2B,EAAE,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,EAAE,iBAAiB,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAEA,GAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;AAC9Q;;;;"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useEffect, useCallback, useMemo } from 'react';
|
|
3
|
+
import TabContext, { TabsStateContext } from '../TabContext.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Owns the selected tab so the tab bar (`DTabs`) and its panels (`DTabs.Tab`)
|
|
7
|
+
* can live anywhere inside it, e.g. the bar in a header and the panels in
|
|
8
|
+
* another column.
|
|
9
|
+
*/
|
|
10
|
+
function DTabsProvider({ defaultSelected, children, }) {
|
|
11
|
+
const [selected, setSelected] = useState(defaultSelected);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
setSelected(defaultSelected);
|
|
14
|
+
}, [defaultSelected]);
|
|
15
|
+
const isSelected = useCallback((tab) => (selected === tab), [selected]);
|
|
16
|
+
const state = useMemo(() => ({ selected, setSelected }), [selected]);
|
|
17
|
+
const value = useMemo(() => ({ isSelected }), [isSelected]);
|
|
18
|
+
return (jsx(TabsStateContext.Provider, { value: state, children: jsx(TabContext.Provider, { value: value, children: children }) }));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { DTabsProvider as default };
|
|
22
|
+
//# sourceMappingURL=DTabsProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DTabsProvider.js","sources":["../../../../../dist-transpiled/components/DTabs/components/DTabsProvider.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport { useCallback, useEffect, useMemo, useState, } from 'react';\nimport TabContext, { TabsStateContext } from '../TabContext';\n/**\n * Owns the selected tab so the tab bar (`DTabs`) and its panels (`DTabs.Tab`)\n * can live anywhere inside it, e.g. the bar in a header and the panels in\n * another column.\n */\nexport default function DTabsProvider({ defaultSelected, children, }) {\n const [selected, setSelected] = useState(defaultSelected);\n useEffect(() => {\n setSelected(defaultSelected);\n }, [defaultSelected]);\n const isSelected = useCallback((tab) => (selected === tab), [selected]);\n const state = useMemo(() => ({ selected, setSelected }), [selected]);\n const value = useMemo(() => ({ isSelected }), [isSelected]);\n return (_jsx(TabsStateContext.Provider, { value: state, children: _jsx(TabContext.Provider, { value: value, children: children }) }));\n}\n//# sourceMappingURL=DTabsProvider.js.map"],"names":["_jsx"],"mappings":";;;;AAGA;AACA;AACA;AACA;AACA;AACe,SAAS,aAAa,CAAC,EAAE,eAAe,EAAE,QAAQ,GAAG,EAAE;AACtE,IAAI,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,eAAe,CAAC;AAC7D,IAAI,SAAS,CAAC,MAAM;AACpB,QAAQ,WAAW,CAAC,eAAe,CAAC;AACpC,IAAI,CAAC,EAAE,CAAC,eAAe,CAAC,CAAC;AACzB,IAAI,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,GAAG,MAAM,QAAQ,KAAK,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;AAC3E,IAAI,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;AACxE,IAAI,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;AAC/D,IAAI,QAAQA,GAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAEA,GAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC;AACxI;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
|
|
@@ -3,8 +3,13 @@ import classNames from 'classnames';
|
|
|
3
3
|
import DToastHeader from './components/DToastHeader.js';
|
|
4
4
|
import DToastBody from './components/DToastBody.js';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const LIVE_REGION_ATTRIBUTES = {
|
|
7
|
+
alert: { role: 'alert', 'aria-live': 'assertive', 'aria-atomic': 'true' },
|
|
8
|
+
status: { role: 'status', 'aria-live': 'polite', 'aria-atomic': 'true' },
|
|
9
|
+
none: {},
|
|
10
|
+
};
|
|
11
|
+
function DToast({ children, role = 'alert', className, style, dataAttributes, }) {
|
|
12
|
+
return (jsx("div", Object.assign({ className: classNames('toast', className) }, LIVE_REGION_ATTRIBUTES[role], { style: style }, dataAttributes, { children: children })));
|
|
8
13
|
}
|
|
9
14
|
var DToast$1 = Object.assign(DToast, {
|
|
10
15
|
Header: DToastHeader,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DToast.js","sources":["../../../../dist-transpiled/components/DToast/DToast.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport classNames from 'classnames';\nimport DToastHeader from './components/DToastHeader';\nimport DToastBody from './components/DToastBody';\nfunction DToast({ children, className, style, dataAttributes, }) {\n return (_jsx(\"div\", Object.assign({ className: classNames('toast', className), role
|
|
1
|
+
{"version":3,"file":"DToast.js","sources":["../../../../dist-transpiled/components/DToast/DToast.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport classNames from 'classnames';\nimport DToastHeader from './components/DToastHeader';\nimport DToastBody from './components/DToastBody';\nconst LIVE_REGION_ATTRIBUTES = {\n alert: { role: 'alert', 'aria-live': 'assertive', 'aria-atomic': 'true' },\n status: { role: 'status', 'aria-live': 'polite', 'aria-atomic': 'true' },\n none: {},\n};\nfunction DToast({ children, role = 'alert', className, style, dataAttributes, }) {\n return (_jsx(\"div\", Object.assign({ className: classNames('toast', className) }, LIVE_REGION_ATTRIBUTES[role], { style: style }, dataAttributes, { children: children })));\n}\nexport default Object.assign(DToast, {\n Header: DToastHeader,\n Body: DToastBody,\n});\n//# sourceMappingURL=DToast.js.map"],"names":["_jsx"],"mappings":";;;;;AAIA,MAAM,sBAAsB,GAAG;AAC/B,IAAI,KAAK,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,EAAE;AAC7E,IAAI,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,EAAE;AAC5E,IAAI,IAAI,EAAE,EAAE;AACZ,CAAC;AACD,SAAS,MAAM,CAAC,EAAE,QAAQ,EAAE,IAAI,GAAG,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,cAAc,GAAG,EAAE;AACjF,IAAI,QAAQA,GAAI,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE,EAAE,sBAAsB,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,cAAc,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;AAC7K;AACA,eAAe,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE;AACrC,IAAI,MAAM,EAAE,YAAY;AACxB,IAAI,IAAI,EAAE,UAAU;AACpB,CAAC,CAAC;;;;"}
|
|
@@ -34,19 +34,19 @@ function useDToast() {
|
|
|
34
34
|
if (typeof data === 'function') {
|
|
35
35
|
return toast.custom(data, toastProps);
|
|
36
36
|
}
|
|
37
|
-
const { title, description, icon, closeIcon, timestamp, color, } = data;
|
|
37
|
+
const { title, description, icon, closeIcon, timestamp, color, role, closeAriaLabel = 'Close', } = data;
|
|
38
38
|
return toast.custom(({ id, visible }) => {
|
|
39
39
|
if (!visible) {
|
|
40
40
|
return null;
|
|
41
41
|
}
|
|
42
42
|
if (!description) {
|
|
43
|
-
return (jsx(DToast, { className: classNames({
|
|
43
|
+
return (jsx(DToast, { role: role, className: classNames({
|
|
44
44
|
[`toast-${color}`]: !!color,
|
|
45
|
-
}, 'show'), children: jsxs(DToast.Body, { children: [icon && (jsx(DIcon, { className: "toast-icon", icon: icon })), jsx("p", { className: "toast-title", children: title }), jsx("button", { type: "button", className: "d-close", "aria-label":
|
|
45
|
+
}, 'show'), children: jsxs(DToast.Body, { children: [icon && (jsx(DIcon, { className: "toast-icon", icon: icon })), jsx("p", { className: "toast-title", children: title }), jsx("button", { type: "button", className: "d-close", "aria-label": closeAriaLabel, onClick: () => toast.dismiss(id), children: jsx(DIcon, { icon: closeIcon || xLg }) })] }) }));
|
|
46
46
|
}
|
|
47
|
-
return (jsxs(DToast, { className: classNames({
|
|
47
|
+
return (jsxs(DToast, { role: role, className: classNames({
|
|
48
48
|
[`toast-${color}`]: !!color,
|
|
49
|
-
}, 'show'), children: [jsxs(DToast.Header, { children: [icon && (jsx(DIcon, { className: "toast-icon", icon: icon })), jsx("p", { className: "toast-title", children: title }), timestamp && (jsx("small", { className: "toast-timestamp", children: timestamp })), jsx("button", { type: "button", className: "d-close", "aria-label":
|
|
49
|
+
}, 'show'), children: [jsxs(DToast.Header, { children: [icon && (jsx(DIcon, { className: "toast-icon", icon: icon })), jsx("p", { className: "toast-title", children: title }), timestamp && (jsx("small", { className: "toast-timestamp", children: timestamp })), jsx("button", { type: "button", className: "d-close", "aria-label": closeAriaLabel, onClick: () => toast.dismiss(id), children: jsx(DIcon, { icon: closeIcon || xLg }) })] }), jsx(DToast.Body, { children: jsx("span", { children: description }) })] }));
|
|
50
50
|
}, toastProps);
|
|
51
51
|
}, [xLg]);
|
|
52
52
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDToast.js","sources":["../../../../dist-transpiled/components/DToastContainer/useDToast.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { useCallback, } from 'react';\nimport { toast as reactHotToast, } from 'react-hot-toast';\nimport classNames from 'classnames';\nimport DToast from '../DToast/DToast';\nimport DIcon from '../DIcon';\nimport { useDContext } from '../../contexts';\n/**\n * Hook that provides a `toast` function to dispatch DToast notifications.\n *\n * Prerequisites:\n * - The calling component must be inside `DContextProvider` (provides icon context).\n * - `DToastContainer` must be present somewhere in the component tree as a render target.\n *\n * @returns {{ toast }} Object containing a `toast` dispatcher function.\n * @requires DContextProvider\n * @requires DToastContainer\n * @example\n * const { toast } = useDToast();\n * toast({ title: 'Saved', color: 'success' });\n */\nexport default function useDToast() {\n const { iconMap: { xLg, }, } = useDContext();\n /**\n * Dispatches a toast notification rendered as a `DToast` component.\n * When `data` is a `ToastData` object, the default DToast layout is used.\n * When `data` is a render function, full custom content is rendered instead.\n * Returns the toast ID, which can be passed to `reactHotToast.dismiss(id)`.\n * @param data - Toast content as `ToastData` or a render function for custom layouts.\n * @param toastProps - Optional per-toast overrides: id, duration, position.\n */\n const toast = useCallback((data, toastProps) => {\n if (typeof data === 'function') {\n return reactHotToast.custom(data, toastProps);\n }\n const { title, description, icon, closeIcon, timestamp, color, } = data;\n return reactHotToast.custom(({ id, visible }) => {\n if (!visible) {\n return null;\n }\n if (!description) {\n return (_jsx(DToast, { className: classNames({\n [`toast-${color}`]: !!color,\n }, 'show'), children: _jsxs(DToast.Body, { children: [icon && (_jsx(DIcon, { className: \"toast-icon\", icon: icon })), _jsx(\"p\", { className: \"toast-title\", children: title }), _jsx(\"button\", { type: \"button\", className: \"d-close\", \"aria-label\":
|
|
1
|
+
{"version":3,"file":"useDToast.js","sources":["../../../../dist-transpiled/components/DToastContainer/useDToast.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\nimport { useCallback, } from 'react';\nimport { toast as reactHotToast, } from 'react-hot-toast';\nimport classNames from 'classnames';\nimport DToast from '../DToast/DToast';\nimport DIcon from '../DIcon';\nimport { useDContext } from '../../contexts';\n/**\n * Hook that provides a `toast` function to dispatch DToast notifications.\n *\n * Prerequisites:\n * - The calling component must be inside `DContextProvider` (provides icon context).\n * - `DToastContainer` must be present somewhere in the component tree as a render target.\n *\n * @returns {{ toast }} Object containing a `toast` dispatcher function.\n * @requires DContextProvider\n * @requires DToastContainer\n * @example\n * const { toast } = useDToast();\n * toast({ title: 'Saved', color: 'success' });\n */\nexport default function useDToast() {\n const { iconMap: { xLg, }, } = useDContext();\n /**\n * Dispatches a toast notification rendered as a `DToast` component.\n * When `data` is a `ToastData` object, the default DToast layout is used.\n * When `data` is a render function, full custom content is rendered instead.\n * Returns the toast ID, which can be passed to `reactHotToast.dismiss(id)`.\n * @param data - Toast content as `ToastData` or a render function for custom layouts.\n * @param toastProps - Optional per-toast overrides: id, duration, position.\n */\n const toast = useCallback((data, toastProps) => {\n if (typeof data === 'function') {\n return reactHotToast.custom(data, toastProps);\n }\n const { title, description, icon, closeIcon, timestamp, color, role, closeAriaLabel = 'Close', } = data;\n return reactHotToast.custom(({ id, visible }) => {\n if (!visible) {\n return null;\n }\n if (!description) {\n return (_jsx(DToast, { role: role, className: classNames({\n [`toast-${color}`]: !!color,\n }, 'show'), children: _jsxs(DToast.Body, { children: [icon && (_jsx(DIcon, { className: \"toast-icon\", icon: icon })), _jsx(\"p\", { className: \"toast-title\", children: title }), _jsx(\"button\", { type: \"button\", className: \"d-close\", \"aria-label\": closeAriaLabel, onClick: () => reactHotToast.dismiss(id), children: _jsx(DIcon, { icon: closeIcon || xLg }) })] }) }));\n }\n return (_jsxs(DToast, { role: role, className: classNames({\n [`toast-${color}`]: !!color,\n }, 'show'), children: [_jsxs(DToast.Header, { children: [icon && (_jsx(DIcon, { className: \"toast-icon\", icon: icon })), _jsx(\"p\", { className: \"toast-title\", children: title }), timestamp && (_jsx(\"small\", { className: \"toast-timestamp\", children: timestamp })), _jsx(\"button\", { type: \"button\", className: \"d-close\", \"aria-label\": closeAriaLabel, onClick: () => reactHotToast.dismiss(id), children: _jsx(DIcon, { icon: closeIcon || xLg }) })] }), _jsx(DToast.Body, { children: _jsx(\"span\", { children: description }) })] }));\n }, toastProps);\n }, [xLg]);\n return {\n toast,\n };\n}\n//# sourceMappingURL=useDToast.js.map"],"names":["toast","reactHotToast","_jsx","_jsxs"],"mappings":";;;;;;;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,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MAAM,EAAE,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC;AAC7hB,QAAQ,CAAC,EAAE,UAAU,CAAC;AACtB,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;AACb,IAAI,OAAO;AACX,eAAQF,OAAK;AACb,KAAK;AACL;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import labelClickGuard from '../../utils/labelClickGuard.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The `<label>` every form control renders, with the click guard already wired.
|
|
6
|
+
*
|
|
7
|
+
* Internal: it exists so the guard — and the lint exception it needs — lives in
|
|
8
|
+
* one place instead of being repeated across every input component.
|
|
9
|
+
*
|
|
10
|
+
* The guard runs in the capture phase, not on bubble: a tooltip or modal
|
|
11
|
+
* trigger that calls `stopPropagation()` in its own handler — a common pattern —
|
|
12
|
+
* would otherwise keep the guard from ever running, and the browser would go on
|
|
13
|
+
* to activate the labelled control. Confirmed in Chromium, where the same
|
|
14
|
+
* trigger toggles the control with a bubble-phase guard and does not with this
|
|
15
|
+
* one. Capturing changes nothing else: `preventDefault` applies to the default
|
|
16
|
+
* action, which is evaluated after propagation either way.
|
|
17
|
+
*
|
|
18
|
+
* The `jsx-a11y` rules below assume a click handler is being used to make a
|
|
19
|
+
* non-interactive element interactive, which then owes the keyboard an
|
|
20
|
+
* equivalent. This handler does the opposite: it suppresses a pointer-only
|
|
21
|
+
* behaviour, the click a label forwards to its control, and adds no way to
|
|
22
|
+
* activate anything. Keyboard support for a nested trigger is the consumer's:
|
|
23
|
+
* `<a href>` carries its own, while a `span` with a role and a tabindex is
|
|
24
|
+
* focusable but inert until they handle Enter and Space themselves.
|
|
25
|
+
*/
|
|
26
|
+
function DFormLabel({ htmlFor, className, children }) {
|
|
27
|
+
/**
|
|
28
|
+
* React 19 renders a bigint child; React 18 throws on one, and this package
|
|
29
|
+
* supports both (`react: >=18 <20`). The label helpers count bigint as text
|
|
30
|
+
* because that is what it draws as, so it is turned into its string form here
|
|
31
|
+
* — the one place every control's label passes through — rather than pushing
|
|
32
|
+
* a version check onto consumers.
|
|
33
|
+
*
|
|
34
|
+
* Only a bigint at the top level: one buried inside an array or a fragment is
|
|
35
|
+
* the consumer's own React child, and normalising it would mean walking and
|
|
36
|
+
* rebuilding the whole subtree.
|
|
37
|
+
*/
|
|
38
|
+
const content = typeof children === 'bigint' ? String(children) : children;
|
|
39
|
+
return (
|
|
40
|
+
/* eslint-disable-next-line jsx-a11y/click-events-have-key-events,
|
|
41
|
+
jsx-a11y/no-noninteractive-element-interactions */
|
|
42
|
+
jsx("label", { htmlFor: htmlFor, className: className, onClickCapture: labelClickGuard, children: content }));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { DFormLabel as default };
|
|
46
|
+
//# sourceMappingURL=DFormLabel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DFormLabel.js","sources":["../../../../dist-transpiled/components/internal/DFormLabel.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\nimport labelClickGuard from '../../utils/labelClickGuard';\n/**\n * The `<label>` every form control renders, with the click guard already wired.\n *\n * Internal: it exists so the guard — and the lint exception it needs — lives in\n * one place instead of being repeated across every input component.\n *\n * The guard runs in the capture phase, not on bubble: a tooltip or modal\n * trigger that calls `stopPropagation()` in its own handler — a common pattern —\n * would otherwise keep the guard from ever running, and the browser would go on\n * to activate the labelled control. Confirmed in Chromium, where the same\n * trigger toggles the control with a bubble-phase guard and does not with this\n * one. Capturing changes nothing else: `preventDefault` applies to the default\n * action, which is evaluated after propagation either way.\n *\n * The `jsx-a11y` rules below assume a click handler is being used to make a\n * non-interactive element interactive, which then owes the keyboard an\n * equivalent. This handler does the opposite: it suppresses a pointer-only\n * behaviour, the click a label forwards to its control, and adds no way to\n * activate anything. Keyboard support for a nested trigger is the consumer's:\n * `<a href>` carries its own, while a `span` with a role and a tabindex is\n * focusable but inert until they handle Enter and Space themselves.\n */\nexport default function DFormLabel({ htmlFor, className, children }) {\n /**\n * React 19 renders a bigint child; React 18 throws on one, and this package\n * supports both (`react: >=18 <20`). The label helpers count bigint as text\n * because that is what it draws as, so it is turned into its string form here\n * — the one place every control's label passes through — rather than pushing\n * a version check onto consumers.\n *\n * Only a bigint at the top level: one buried inside an array or a fragment is\n * the consumer's own React child, and normalising it would mean walking and\n * rebuilding the whole subtree.\n */\n const content = typeof children === 'bigint' ? String(children) : children;\n return (\n /* eslint-disable-next-line jsx-a11y/click-events-have-key-events,\n jsx-a11y/no-noninteractive-element-interactions */\n _jsx(\"label\", { htmlFor: htmlFor, className: className, onClickCapture: labelClickGuard, children: content }));\n}\n//# sourceMappingURL=DFormLabel.js.map"],"names":["_jsx"],"mappings":";;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAAS,UAAU,CAAC,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE;AACrE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAI,MAAM,OAAO,GAAG,OAAO,QAAQ,KAAK,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,QAAQ;AAC9E,IAAI;AACJ;AACA;AACA,IAAIA,GAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,cAAc,EAAE,eAAe,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC;AACjH;;;;"}
|
|
@@ -1,17 +1,35 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { createContext,
|
|
2
|
+
import { createContext, useState, useRef, useEffect, useCallback, useMemo, useContext } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
|
-
import { AnimatePresence, motion } from 'framer-motion';
|
|
5
4
|
import useDisableBodyScrollEffect from '../hooks/useDisableBodyScrollEffect.js';
|
|
6
5
|
import usePortal from '../hooks/usePortal.js';
|
|
7
6
|
import useStackState from '../hooks/useStackState.js';
|
|
8
7
|
import getKeyboardFocusableElements from '../utils/getKeyboardFocusableElements.js';
|
|
9
8
|
|
|
9
|
+
const loadPortalStack = () => import('./portal/DPortalStack.js').then((module) => module.default);
|
|
10
10
|
const DPortalContext = createContext(undefined);
|
|
11
11
|
function DPortalContextProvider({ portalName, children, availablePortals, }) {
|
|
12
12
|
const { created } = usePortal(portalName);
|
|
13
13
|
const [stack, { push, pop }] = useStackState([]);
|
|
14
|
+
const [PortalStack, setPortalStack] = useState(null);
|
|
15
|
+
const pending = useRef([]);
|
|
16
|
+
const ready = useRef(false);
|
|
14
17
|
useDisableBodyScrollEffect(Boolean(stack.length));
|
|
18
|
+
// Loads framer-motion off the critical path only when portals are configured,
|
|
19
|
+
// so the first openPortal does not wait for it.
|
|
20
|
+
const hasPortals = Object.keys(availablePortals !== null && availablePortals !== void 0 ? availablePortals : {}).length > 0;
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (!hasPortals)
|
|
23
|
+
return;
|
|
24
|
+
loadPortalStack()
|
|
25
|
+
.then((Stack) => {
|
|
26
|
+
ready.current = true;
|
|
27
|
+
setPortalStack(() => Stack);
|
|
28
|
+
})
|
|
29
|
+
.catch(() => {
|
|
30
|
+
// openPortal retries the import and reports the failure.
|
|
31
|
+
});
|
|
32
|
+
}, [hasPortals]);
|
|
15
33
|
const openPortal = useCallback(
|
|
16
34
|
// eslint-disable-next-line prefer-arrow-callback
|
|
17
35
|
function openPortalImpl(name, payload) {
|
|
@@ -27,10 +45,30 @@ function DPortalContextProvider({ portalName, children, availablePortals, }) {
|
|
|
27
45
|
}
|
|
28
46
|
// K is a specific member of keyof T & string so the object satisfies
|
|
29
47
|
// InternalStackItem<T>, but TS can't verify generic-over-union assignability.
|
|
30
|
-
|
|
48
|
+
const item = { name, Component, payload };
|
|
49
|
+
if (ready.current) {
|
|
50
|
+
push(item);
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
// Not loaded yet: the portal enters the stack together with its renderer.
|
|
54
|
+
pending.current.push(item);
|
|
55
|
+
loadPortalStack().then((Stack) => {
|
|
56
|
+
ready.current = true;
|
|
57
|
+
setPortalStack(() => Stack);
|
|
58
|
+
pending.current.splice(0).forEach(push);
|
|
59
|
+
}).catch((error) => {
|
|
60
|
+
pending.current = [];
|
|
61
|
+
// eslint-disable-next-line no-console
|
|
62
|
+
console.error('[DPortalContext] Could not load the portal stack', error);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
31
65
|
(_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.blur();
|
|
32
66
|
}, [availablePortals, push]);
|
|
33
67
|
const closePortal = useCallback(() => {
|
|
68
|
+
if (pending.current.length > 0) {
|
|
69
|
+
pending.current.pop();
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
34
72
|
// pop() is safe on empty stacks, so close remains idempotent.
|
|
35
73
|
pop();
|
|
36
74
|
}, [pop]);
|
|
@@ -87,13 +125,10 @@ function DPortalContextProvider({ portalName, children, availablePortals, }) {
|
|
|
87
125
|
window.removeEventListener('keydown', keyEvent);
|
|
88
126
|
};
|
|
89
127
|
}, [handleClose, portalName, stack.length]);
|
|
90
|
-
return (jsxs(DPortalContext.Provider, { value: value, children: [children, created && createPortal(
|
|
128
|
+
return (jsxs(DPortalContext.Provider, { value: value, children: [children, created && PortalStack && createPortal(
|
|
91
129
|
// eslint-disable-next-line max-len
|
|
92
130
|
// eslint-disable-next-line jsx-a11y/no-static-element-interactions
|
|
93
|
-
jsx("div", { onClick: ({ target }) => handleClose(target), onKeyDown: () => { }, children: jsx(
|
|
94
|
-
jsx(motion.div, { className: "backdrop", initial: { opacity: 0 }, animate: { opacity: 0.5 }, exit: { opacity: 0, transition: { delay: 0.3 } }, transition: { duration: 0.15, ease: 'linear' } }, `${name}-backdrop`),
|
|
95
|
-
jsx(Component, { name: name, payload: payload }, name),
|
|
96
|
-
]) }) }), document.getElementById(portalName))] }));
|
|
131
|
+
jsx("div", { onClick: ({ target }) => handleClose(target), onKeyDown: () => { }, children: jsx(PortalStack, { stack: stack }) }), document.getElementById(portalName))] }));
|
|
97
132
|
}
|
|
98
133
|
/**
|
|
99
134
|
* Hook to open/close registered portals (modals, offcanvas, etc.).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DPortalContext.js","sources":["../../../dist-transpiled/contexts/DPortalContext.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { createContext, useCallback, useContext, useEffect, useMemo, } from 'react';\nimport { createPortal } from 'react-dom';\nimport { AnimatePresence, motion } from 'framer-motion';\nimport useDisableBodyScrollEffect from '../hooks/useDisableBodyScrollEffect';\nimport usePortal from '../hooks/usePortal';\nimport useStackState from '../hooks/useStackState';\nimport getKeyboardFocusableElements from '../utils/getKeyboardFocusableElements';\nexport const DPortalContext = createContext(undefined);\nexport function DPortalContextProvider({ portalName, children, availablePortals, }) {\n const { created } = usePortal(portalName);\n const [stack, { push, pop }] = useStackState([]);\n useDisableBodyScrollEffect(Boolean(stack.length));\n const openPortal = useCallback(\n // eslint-disable-next-line prefer-arrow-callback\n function openPortalImpl(name, payload) {\n var _a;\n if (!availablePortals) {\n throw new Error('openPortal was called but DContextProvider has no availablePortals configured. '\n + 'Pass an availablePortals map to DContextProvider.');\n }\n const Component = availablePortals[name];\n if (!Component) {\n throw new Error(`No component registered for portal \"${String(name)}\". `\n + `Ensure \"${String(name)}\" has an entry in the availablePortals map on DContextProvider.`);\n }\n // K is a specific member of keyof T & string so the object satisfies\n // InternalStackItem<T>, but TS can't verify generic-over-union assignability.\n push({ name, Component, payload });\n (_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.blur();\n }, [availablePortals, push]);\n const closePortal = useCallback(() => {\n // pop() is safe on empty stacks, so close remains idempotent.\n pop();\n }, [pop]);\n const publicStack = useMemo(() => stack.map(({ name, payload }) => ({ name, payload })), [stack]);\n const value = useMemo(() => ({\n stack: publicStack,\n openPortal,\n closePortal,\n }), [publicStack, openPortal, closePortal]);\n const handleClose = useCallback((target) => {\n if (!(target instanceof HTMLDivElement)) {\n return;\n }\n if (target.classList.contains('portal') && !('bsBackdrop' in target.dataset)) {\n closePortal();\n return;\n }\n if (target.classList.contains('backdrop')) {\n const lastPortal = target.nextElementSibling;\n if (lastPortal && lastPortal.classList.contains('portal') && !('bsBackdrop' in lastPortal.dataset)) {\n closePortal();\n }\n }\n }, [closePortal]);\n useEffect(() => {\n const keyEvent = (event) => {\n const lastPortal = document.querySelector(`#${portalName} > div > div:last-child`);\n if (event.key === 'Escape') {\n if (lastPortal) {\n handleClose(lastPortal);\n return;\n }\n }\n if (event.key === 'Tab') {\n const focusableElements = getKeyboardFocusableElements(lastPortal);\n if (focusableElements.length === 0)\n return;\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n if (event.shiftKey && document.activeElement === firstElement) {\n event.preventDefault();\n lastElement.focus();\n }\n else if (!event.shiftKey && document.activeElement === lastElement) {\n event.preventDefault();\n firstElement.focus();\n }\n }\n };\n if (stack.length !== 0) {\n window.addEventListener('keydown', keyEvent);\n }\n return () => {\n window.removeEventListener('keydown', keyEvent);\n };\n }, [handleClose, portalName, stack.length]);\n return (_jsxs(DPortalContext.Provider, { value: value, children: [children, created && createPortal(\n // eslint-disable-next-line max-len\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n _jsx(\"div\", { onClick: ({ target }) => handleClose(target), onKeyDown: () => { }, children: _jsx(AnimatePresence, { children: stack.flatMap(({ Component, name, payload, }) => [\n _jsx(motion.div, { className: \"backdrop\", initial: { opacity: 0 }, animate: { opacity: 0.5 }, exit: { opacity: 0, transition: { delay: 0.3 } }, transition: { duration: 0.15, ease: 'linear' } }, `${name}-backdrop`),\n _jsx(Component, { name: name, payload: payload }, name),\n ]) }) }), document.getElementById(portalName))] }));\n}\n/**\n * Hook to open/close registered portals (modals, offcanvas, etc.).\n *\n * **Prerequisite**: must be called inside a `DContextProvider` configured with\n * `portalName` and `availablePortals`. `DContextProvider` mounts\n * `DPortalContextProvider` internally — consumers never use\n * `DPortalContextProvider` directly.\n *\n * @template T - Map of portal name → payload shape (e.g. `ModalPayloads`).\n * Typing this generic gives you autocomplete on `openPortal` arguments.\n * @returns `{ openPortal, closePortal, stack }` from the nearest portal context.\n * @throws If called outside of `DContextProvider` / `DPortalContextProvider`.\n *\n * @requires DContextProvider\n *\n * @example\n * ```tsx\n * const { openPortal, closePortal } = useDPortalContext<ModalPayloads>();\n * openPortal('confirm', { message: 'Are you sure?' });\n * ```\n */\nexport function useDPortalContext() {\n const context = useContext(DPortalContext);\n if (context === undefined) {\n throw new Error('useDPortalContext was used outside of DPortalContextProvider');\n }\n return context;\n}\n//# sourceMappingURL=DPortalContext.js.map"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;;AASY,MAAC,cAAc,GAAG,aAAa,CAAC,SAAS;AAC9C,SAAS,sBAAsB,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,GAAG,EAAE;AACpF,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC,UAAU,CAAC;AAC7C,IAAI,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,aAAa,CAAC,EAAE,CAAC;AACpD,IAAI,0BAA0B,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACrD,IAAI,MAAM,UAAU,GAAG,WAAW;AAClC;AACA,IAAI,SAAS,cAAc,CAAC,IAAI,EAAE,OAAO,EAAE;AAC3C,QAAQ,IAAI,EAAE;AACd,QAAQ,IAAI,CAAC,gBAAgB,EAAE;AAC/B,YAAY,MAAM,IAAI,KAAK,CAAC;AAC5B,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,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;AAC7O,wBAAwBA,GAAI,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,CAAC;AAC/E,qBAAqB,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;AACtE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,GAAG;AACpC,IAAI,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC;AAC9C,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE;AAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC;AACvF,IAAI;AACJ,IAAI,OAAO,OAAO;AAClB;;;;"}
|
|
1
|
+
{"version":3,"file":"DPortalContext.js","sources":["../../../dist-transpiled/contexts/DPortalContext.js"],"sourcesContent":["import { jsx as _jsx, jsxs as _jsxs } from \"react/jsx-runtime\";\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from 'react';\nimport { createPortal } from 'react-dom';\nimport useDisableBodyScrollEffect from '../hooks/useDisableBodyScrollEffect';\nimport usePortal from '../hooks/usePortal';\nimport useStackState from '../hooks/useStackState';\nimport getKeyboardFocusableElements from '../utils/getKeyboardFocusableElements';\nconst loadPortalStack = () => import('./portal/DPortalStack').then((module) => module.default);\nexport const DPortalContext = createContext(undefined);\nexport function DPortalContextProvider({ portalName, children, availablePortals, }) {\n const { created } = usePortal(portalName);\n const [stack, { push, pop }] = useStackState([]);\n const [PortalStack, setPortalStack] = useState(null);\n const pending = useRef([]);\n const ready = useRef(false);\n useDisableBodyScrollEffect(Boolean(stack.length));\n // Loads framer-motion off the critical path only when portals are configured,\n // so the first openPortal does not wait for it.\n const hasPortals = Object.keys(availablePortals !== null && availablePortals !== void 0 ? availablePortals : {}).length > 0;\n useEffect(() => {\n if (!hasPortals)\n return;\n loadPortalStack()\n .then((Stack) => {\n ready.current = true;\n setPortalStack(() => Stack);\n })\n .catch(() => {\n // openPortal retries the import and reports the failure.\n });\n }, [hasPortals]);\n const openPortal = useCallback(\n // eslint-disable-next-line prefer-arrow-callback\n function openPortalImpl(name, payload) {\n var _a;\n if (!availablePortals) {\n throw new Error('openPortal was called but DContextProvider has no availablePortals configured. '\n + 'Pass an availablePortals map to DContextProvider.');\n }\n const Component = availablePortals[name];\n if (!Component) {\n throw new Error(`No component registered for portal \"${String(name)}\". `\n + `Ensure \"${String(name)}\" has an entry in the availablePortals map on DContextProvider.`);\n }\n // K is a specific member of keyof T & string so the object satisfies\n // InternalStackItem<T>, but TS can't verify generic-over-union assignability.\n const item = { name, Component, payload };\n if (ready.current) {\n push(item);\n }\n else {\n // Not loaded yet: the portal enters the stack together with its renderer.\n pending.current.push(item);\n loadPortalStack().then((Stack) => {\n ready.current = true;\n setPortalStack(() => Stack);\n pending.current.splice(0).forEach(push);\n }).catch((error) => {\n pending.current = [];\n // eslint-disable-next-line no-console\n console.error('[DPortalContext] Could not load the portal stack', error);\n });\n }\n (_a = document.activeElement) === null || _a === void 0 ? void 0 : _a.blur();\n }, [availablePortals, push]);\n const closePortal = useCallback(() => {\n if (pending.current.length > 0) {\n pending.current.pop();\n return;\n }\n // pop() is safe on empty stacks, so close remains idempotent.\n pop();\n }, [pop]);\n const publicStack = useMemo(() => stack.map(({ name, payload }) => ({ name, payload })), [stack]);\n const value = useMemo(() => ({\n stack: publicStack,\n openPortal,\n closePortal,\n }), [publicStack, openPortal, closePortal]);\n const handleClose = useCallback((target) => {\n if (!(target instanceof HTMLDivElement)) {\n return;\n }\n if (target.classList.contains('portal') && !('bsBackdrop' in target.dataset)) {\n closePortal();\n return;\n }\n if (target.classList.contains('backdrop')) {\n const lastPortal = target.nextElementSibling;\n if (lastPortal && lastPortal.classList.contains('portal') && !('bsBackdrop' in lastPortal.dataset)) {\n closePortal();\n }\n }\n }, [closePortal]);\n useEffect(() => {\n const keyEvent = (event) => {\n const lastPortal = document.querySelector(`#${portalName} > div > div:last-child`);\n if (event.key === 'Escape') {\n if (lastPortal) {\n handleClose(lastPortal);\n return;\n }\n }\n if (event.key === 'Tab') {\n const focusableElements = getKeyboardFocusableElements(lastPortal);\n if (focusableElements.length === 0)\n return;\n const firstElement = focusableElements[0];\n const lastElement = focusableElements[focusableElements.length - 1];\n if (event.shiftKey && document.activeElement === firstElement) {\n event.preventDefault();\n lastElement.focus();\n }\n else if (!event.shiftKey && document.activeElement === lastElement) {\n event.preventDefault();\n firstElement.focus();\n }\n }\n };\n if (stack.length !== 0) {\n window.addEventListener('keydown', keyEvent);\n }\n return () => {\n window.removeEventListener('keydown', keyEvent);\n };\n }, [handleClose, portalName, stack.length]);\n return (_jsxs(DPortalContext.Provider, { value: value, children: [children, created && PortalStack && createPortal(\n // eslint-disable-next-line max-len\n // eslint-disable-next-line jsx-a11y/no-static-element-interactions\n _jsx(\"div\", { onClick: ({ target }) => handleClose(target), onKeyDown: () => { }, children: _jsx(PortalStack, { stack: stack }) }), document.getElementById(portalName))] }));\n}\n/**\n * Hook to open/close registered portals (modals, offcanvas, etc.).\n *\n * **Prerequisite**: must be called inside a `DContextProvider` configured with\n * `portalName` and `availablePortals`. `DContextProvider` mounts\n * `DPortalContextProvider` internally — consumers never use\n * `DPortalContextProvider` directly.\n *\n * @template T - Map of portal name → payload shape (e.g. `ModalPayloads`).\n * Typing this generic gives you autocomplete on `openPortal` arguments.\n * @returns `{ openPortal, closePortal, stack }` from the nearest portal context.\n * @throws If called outside of `DContextProvider` / `DPortalContextProvider`.\n *\n * @requires DContextProvider\n *\n * @example\n * ```tsx\n * const { openPortal, closePortal } = useDPortalContext<ModalPayloads>();\n * openPortal('confirm', { message: 'Are you sure?' });\n * ```\n */\nexport function useDPortalContext() {\n const context = useContext(DPortalContext);\n if (context === undefined) {\n throw new Error('useDPortalContext was used outside of DPortalContextProvider');\n }\n return context;\n}\n//# sourceMappingURL=DPortalContext.js.map"],"names":["_jsxs","_jsx"],"mappings":";;;;;;;;AAQA,MAAM,eAAe,GAAG,MAAM,OAAO,0BAAuB,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,OAAO,CAAC;AAClF,MAAC,cAAc,GAAG,aAAa,CAAC,SAAS;AAC9C,SAAS,sBAAsB,CAAC,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,GAAG,EAAE;AACpF,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC,UAAU,CAAC;AAC7C,IAAI,MAAM,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,GAAG,aAAa,CAAC,EAAE,CAAC;AACpD,IAAI,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC;AACxD,IAAI,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,CAAC;AAC9B,IAAI,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;AAC/B,IAAI,0BAA0B,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AACrD;AACA;AACA,IAAI,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,gBAAgB,KAAK,IAAI,IAAI,gBAAgB,KAAK,MAAM,GAAG,gBAAgB,GAAG,EAAE,CAAC,CAAC,MAAM,GAAG,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AC,CAAC,EAAE,CAAC;AACxL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,iBAAiB,GAAG;AACpC,IAAI,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC;AAC9C,IAAI,IAAI,OAAO,KAAK,SAAS,EAAE;AAC/B,QAAQ,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC;AACvF,IAAI;AACJ,IAAI,OAAO,OAAO;AAClB;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
3
|
+
|
|
4
|
+
function DPortalStack({ stack }) {
|
|
5
|
+
return (jsx(AnimatePresence, { children: stack.flatMap(({ Component, name, payload, }) => [
|
|
6
|
+
jsx(motion.div, { className: "backdrop", initial: { opacity: 0 }, animate: { opacity: 0.5 }, exit: { opacity: 0, transition: { delay: 0.3 } }, transition: { duration: 0.15, ease: 'linear' } }, `${name}-backdrop`),
|
|
7
|
+
jsx(Component, { name: name, payload: payload }, name),
|
|
8
|
+
]) }));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { DPortalStack as default };
|
|
12
|
+
//# sourceMappingURL=DPortalStack.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DPortalStack.js","sources":["../../../../dist-transpiled/contexts/portal/DPortalStack.js"],"sourcesContent":["import { jsx as _jsx } from \"react/jsx-runtime\";\n/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { AnimatePresence, motion } from 'framer-motion';\nexport default function DPortalStack({ stack }) {\n return (_jsx(AnimatePresence, { children: stack.flatMap(({ Component, name, payload, }) => [\n _jsx(motion.div, { className: \"backdrop\", initial: { opacity: 0 }, animate: { opacity: 0.5 }, exit: { opacity: 0, transition: { delay: 0.3 } }, transition: { duration: 0.15, ease: 'linear' } }, `${name}-backdrop`),\n _jsx(Component, { name: name, payload: payload }, name),\n ]) }));\n}\n//# sourceMappingURL=DPortalStack.js.map"],"names":["_jsx"],"mappings":";;;AAGe,SAAS,YAAY,CAAC,EAAE,KAAK,EAAE,EAAE;AAChD,IAAI,QAAQA,GAAI,CAAC,eAAe,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,GAAG,KAAK;AAC/F,YAAYA,GAAI,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;AACjO,YAAYA,GAAI,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,CAAC;AACnE,SAAS,CAAC,EAAE,CAAC;AACb;;;;"}
|