@flipdish/ui-library 0.37.0 → 0.39.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/README.md +9 -9
- package/dist/components/__internal__/selectionControl/selectionControl.styles.cjs +22 -0
- package/dist/components/__internal__/selectionControl/selectionControl.styles.cjs.map +1 -0
- package/dist/components/__internal__/selectionControl/selectionControl.styles.d.ts +17 -0
- package/dist/components/__internal__/selectionControl/selectionControl.styles.d.ts.map +1 -0
- package/dist/components/__internal__/selectionControl/selectionControl.styles.js +20 -0
- package/dist/components/__internal__/selectionControl/selectionControl.styles.js.map +1 -0
- package/dist/components/__internal__/selectionControl/selectionControl.utils.d.ts +23 -0
- package/dist/components/__internal__/selectionControl/selectionControl.utils.d.ts.map +1 -0
- package/dist/components/atoms/Checkbox/index.cjs +3 -16
- package/dist/components/atoms/Checkbox/index.cjs.map +1 -1
- package/dist/components/atoms/Checkbox/index.d.ts.map +1 -1
- package/dist/components/atoms/Checkbox/index.js +3 -16
- package/dist/components/atoms/Checkbox/index.js.map +1 -1
- package/dist/components/atoms/Toggle/Toggle.styles.cjs +0 -14
- package/dist/components/atoms/Toggle/Toggle.styles.cjs.map +1 -1
- package/dist/components/atoms/Toggle/Toggle.styles.d.ts +0 -14
- package/dist/components/atoms/Toggle/Toggle.styles.d.ts.map +1 -1
- package/dist/components/atoms/Toggle/Toggle.styles.js +0 -14
- package/dist/components/atoms/Toggle/Toggle.styles.js.map +1 -1
- package/dist/components/atoms/Toggle/index.cjs +3 -2
- package/dist/components/atoms/Toggle/index.cjs.map +1 -1
- package/dist/components/atoms/Toggle/index.d.ts.map +1 -1
- package/dist/components/atoms/Toggle/index.js +3 -2
- package/dist/components/atoms/Toggle/index.js.map +1 -1
- package/dist/components/templates/WidgetLayout/index.cjs +36 -0
- package/dist/components/templates/WidgetLayout/index.cjs.map +1 -0
- package/dist/components/templates/WidgetLayout/index.d.ts +54 -0
- package/dist/components/templates/WidgetLayout/index.d.ts.map +1 -0
- package/dist/components/templates/WidgetLayout/index.js +34 -0
- package/dist/components/templates/WidgetLayout/index.js.map +1 -0
- package/dist/native/components/__internal__/selectionControl/SelectionControlText.d.ts +1 -1
- package/dist/native/components/__internal__/selectionControl/SelectionControlText.d.ts.map +1 -1
- package/dist/native/components/__internal__/selectionControl/SelectionControlText.js +2 -1
- package/dist/native/components/__internal__/selectionControl/SelectionControlText.js.map +1 -1
- package/dist/native/components/__internal__/selectionControl/selectionControl.styles.d.ts +17 -0
- package/dist/native/components/__internal__/selectionControl/selectionControl.styles.d.ts.map +1 -0
- package/dist/native/components/__internal__/selectionControl/selectionControl.styles.js +20 -0
- package/dist/native/components/__internal__/selectionControl/selectionControl.styles.js.map +1 -0
- package/dist/native/components/__internal__/selectionControl/selectionControl.utils.d.ts +23 -0
- package/dist/native/components/__internal__/selectionControl/selectionControl.utils.d.ts.map +1 -0
- package/dist/native/components/__internal__/selectionControl/selectionControl.utils.js +20 -0
- package/dist/native/components/__internal__/selectionControl/selectionControl.utils.js.map +1 -0
- package/dist/native/components/atoms/Checkbox/index.d.ts +31 -9
- package/dist/native/components/atoms/Checkbox/index.d.ts.map +1 -0
- package/dist/native/components/atoms/Checkbox/index.js +39 -0
- package/dist/native/components/atoms/Checkbox/index.js.map +1 -0
- package/dist/native/components/atoms/Toggle/Toggle.styles.d.ts +0 -14
- package/dist/native/components/atoms/Toggle/Toggle.styles.d.ts.map +1 -1
- package/dist/native/components/atoms/Toggle/Toggle.styles.js +0 -14
- package/dist/native/components/atoms/Toggle/Toggle.styles.js.map +1 -1
- package/dist/native/components/atoms/Toggle/index.d.ts.map +1 -1
- package/dist/native/components/atoms/Toggle/index.js +3 -1
- package/dist/native/components/atoms/Toggle/index.js.map +1 -1
- package/dist/native/components/templates/WidgetLayout/index.d.ts +12 -0
- package/dist/providers/PortalContainer/index.d.ts +1 -1
- package/dist/providers/ThemeProvider/index.cjs +36 -14
- package/dist/providers/ThemeProvider/index.cjs.map +1 -1
- package/dist/providers/ThemeProvider/index.d.ts +19 -5
- package/dist/providers/ThemeProvider/index.d.ts.map +1 -1
- package/dist/providers/ThemeProvider/index.js +36 -14
- package/dist/providers/ThemeProvider/index.js.map +1 -1
- package/dist/providers/UIProvider/hooks/usePortalAnchor.cjs +137 -0
- package/dist/providers/UIProvider/hooks/usePortalAnchor.cjs.map +1 -0
- package/dist/providers/UIProvider/hooks/usePortalAnchor.d.ts +60 -0
- package/dist/providers/UIProvider/hooks/usePortalAnchor.d.ts.map +1 -0
- package/dist/providers/UIProvider/hooks/usePortalAnchor.js +131 -0
- package/dist/providers/UIProvider/hooks/usePortalAnchor.js.map +1 -0
- package/dist/providers/UIProvider/index.cjs +7 -64
- package/dist/providers/UIProvider/index.cjs.map +1 -1
- package/dist/providers/UIProvider/index.d.ts +16 -11
- package/dist/providers/UIProvider/index.d.ts.map +1 -1
- package/dist/providers/UIProvider/index.js +7 -64
- package/dist/providers/UIProvider/index.js.map +1 -1
- package/dist/utilities/cssScopeUtils/index.cjs +22 -11
- package/dist/utilities/cssScopeUtils/index.cjs.map +1 -1
- package/dist/utilities/cssScopeUtils/index.d.ts +20 -9
- package/dist/utilities/cssScopeUtils/index.d.ts.map +1 -1
- package/dist/utilities/cssScopeUtils/index.js +22 -11
- package/dist/utilities/cssScopeUtils/index.js.map +1 -1
- package/dist/utilities/renderUtils/index.cjs +36 -7
- package/dist/utilities/renderUtils/index.cjs.map +1 -1
- package/dist/utilities/renderUtils/index.d.ts +23 -2
- package/dist/utilities/renderUtils/index.d.ts.map +1 -1
- package/dist/utilities/renderUtils/index.js +35 -8
- package/dist/utilities/renderUtils/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -185,7 +185,7 @@ Unable to resolve module .../dist/native/components/atoms/Button/index.js
|
|
|
185
185
|
|
|
186
186
|
## Scoping Tailwind CSS to a subtree
|
|
187
187
|
|
|
188
|
-
When your app doesn't own the whole page — a widget, an embed, a Storybook preview, a multi-tenant host, or a micro-frontend — its Tailwind v4 output (utilities **and** Preflight resets) can leak into or clash with the surrounding CSS. The fix is to scope every emitted selector under a single
|
|
188
|
+
When your app doesn't own the whole page — a widget, an embed, a Storybook preview, a multi-tenant host, or a micro-frontend — its Tailwind v4 output (utilities **and** Preflight resets) can leak into or clash with the surrounding CSS. The fix is to scope every emitted selector under a single element the app renders itself: `UIProvider`'s `scopeId` stamps `data-mfe-scope` on the themed root for this. Never scope to a host container id (`#flipdish-micro-frontend`) or a union of ids; several apps share those containers, so the rules leak across them.
|
|
189
189
|
|
|
190
190
|
`@flipdish/ui-library/utilities/cssScopeUtils` ships `createScopedPrefixTransform`, a small factory for [`postcss-prefix-selector`](https://www.npmjs.com/package/postcss-prefix-selector) that consolidates the scoping rules (scope `:root`/`html` so `@theme` tokens and base typography cascade only within the subtree, leave `:host` and `@keyframes` steps alone, never double-prefix, etc.) so you write one line instead of copy-pasting a bespoke transform.
|
|
191
191
|
|
|
@@ -202,7 +202,8 @@ Then add it to your PostCSS config:
|
|
|
202
202
|
import prefixSelector from "postcss-prefix-selector";
|
|
203
203
|
import { createScopedPrefixTransform } from "@flipdish/ui-library/utilities/cssScopeUtils";
|
|
204
204
|
|
|
205
|
-
|
|
205
|
+
// Your Portal microFrontendWindowName; must match <UIProvider scopeId="sale-service">.
|
|
206
|
+
const SCOPE = '[data-mfe-scope="sale-service"]';
|
|
206
207
|
|
|
207
208
|
export default {
|
|
208
209
|
plugins: [
|
|
@@ -214,23 +215,22 @@ export default {
|
|
|
214
215
|
};
|
|
215
216
|
```
|
|
216
217
|
|
|
217
|
-
Tailwind's output becomes plain
|
|
218
|
+
Tailwind's output becomes plain `[data-mfe-scope="sale-service"] .px-4 { … }`, which every downstream tool (Vite, lightningcss) understands.
|
|
218
219
|
|
|
219
220
|
### Options
|
|
220
221
|
|
|
221
222
|
`createScopedPrefixTransform(scopeSelector, options?)`:
|
|
222
223
|
|
|
223
|
-
| Option | Type | Default | Description
|
|
224
|
-
| ------------------ | -------------------------------------------- | ------------ |
|
|
225
|
-
| `shouldScope` | `(filePath: string \| undefined) => boolean` | `() => true` | Return `false` to leave a file's selectors untouched (e.g. third-party CSS you don't want prefixed).
|
|
226
|
-
| `scopeBody` | `boolean` | `false` | Scope Preflight `body` resets to the mount selector instead of leaving `body` global. Enable when the host page must not inherit the reset.
|
|
227
|
-
| `matchRootElement` | `boolean` | `
|
|
224
|
+
| Option | Type | Default | Description |
|
|
225
|
+
| ------------------ | -------------------------------------------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
226
|
+
| `shouldScope` | `(filePath: string \| undefined) => boolean` | `() => true` | Return `false` to leave a file's selectors untouched (e.g. third-party CSS you don't want prefixed). |
|
|
227
|
+
| `scopeBody` | `boolean` | `false` | Scope Preflight `body` resets to the mount selector instead of leaving `body` global. Enable when the host page must not inherit the reset. |
|
|
228
|
+
| `matchRootElement` | `boolean` | `true` | Also emit a compound selector so the scope root itself matches class and attribute selectors; `[data-theme="dark"]` on the themed root needs it. |
|
|
228
229
|
|
|
229
230
|
```js
|
|
230
231
|
createScopedPrefixTransform("[data-tailwind]", {
|
|
231
232
|
shouldScope: (file) => !file || !file.includes("node_modules"),
|
|
232
233
|
scopeBody: true,
|
|
233
|
-
matchRootElement: true,
|
|
234
234
|
});
|
|
235
235
|
```
|
|
236
236
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
4
|
+
|
|
5
|
+
/** Root gap and label/hint typography shared by `Toggle`, `Checkbox` and `RadioButton` on web and React Native. */
|
|
6
|
+
const selectionControlSizes = cx.sortCx({
|
|
7
|
+
sm: {
|
|
8
|
+
root: 'gap-2',
|
|
9
|
+
textWrapper: '',
|
|
10
|
+
label: 'text-sm font-medium',
|
|
11
|
+
hint: 'text-sm',
|
|
12
|
+
},
|
|
13
|
+
md: {
|
|
14
|
+
root: 'gap-3',
|
|
15
|
+
textWrapper: 'gap-0.5',
|
|
16
|
+
label: 'text-md font-medium',
|
|
17
|
+
hint: 'text-md',
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
exports.selectionControlSizes = selectionControlSizes;
|
|
22
|
+
//# sourceMappingURL=selectionControl.styles.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectionControl.styles.cjs","sources":["../../../../src/components/__internal__/selectionControl/selectionControl.styles.ts"],"sourcesContent":[null],"names":["sortCx"],"mappings":";;;;AAIA;AACO,MAAM,qBAAqB,GAAGA,SAAM,CAAC;AAC1C,IAAA,EAAE,EAAE;AACF,QAAA,IAAI,EAAE,OAAO;AACb,QAAA,WAAW,EAAE,EAAE;AACf,QAAA,KAAK,EAAE,qBAAqB;AAC5B,QAAA,IAAI,EAAE,SAAS;AAChB,KAAA;AACD,IAAA,EAAE,EAAE;AACF,QAAA,IAAI,EAAE,OAAO;AACb,QAAA,WAAW,EAAE,SAAS;AACtB,QAAA,KAAK,EAAE,qBAAqB;AAC5B,QAAA,IAAI,EAAE,SAAS;AAChB,KAAA;AACgG,CAAA;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type SelectionControlSize = 'sm' | 'md';
|
|
2
|
+
/** Root gap and label/hint typography shared by `Toggle`, `Checkbox` and `RadioButton` on web and React Native. */
|
|
3
|
+
export declare const selectionControlSizes: {
|
|
4
|
+
sm: {
|
|
5
|
+
root: string;
|
|
6
|
+
textWrapper: string;
|
|
7
|
+
label: string;
|
|
8
|
+
hint: string;
|
|
9
|
+
};
|
|
10
|
+
md: {
|
|
11
|
+
root: string;
|
|
12
|
+
textWrapper: string;
|
|
13
|
+
label: string;
|
|
14
|
+
hint: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=selectionControl.styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectionControl.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/__internal__/selectionControl/selectionControl.styles.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,oBAAoB,GAAG,IAAI,GAAG,IAAI,CAAC;AAE/C,mHAAmH;AACnH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;CAakE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { sortCx } from '@flipdish/ui-library/utilities/cx';
|
|
2
|
+
|
|
3
|
+
/** Root gap and label/hint typography shared by `Toggle`, `Checkbox` and `RadioButton` on web and React Native. */
|
|
4
|
+
const selectionControlSizes = sortCx({
|
|
5
|
+
sm: {
|
|
6
|
+
root: 'gap-2',
|
|
7
|
+
textWrapper: '',
|
|
8
|
+
label: 'text-sm font-medium',
|
|
9
|
+
hint: 'text-sm',
|
|
10
|
+
},
|
|
11
|
+
md: {
|
|
12
|
+
root: 'gap-3',
|
|
13
|
+
textWrapper: 'gap-0.5',
|
|
14
|
+
label: 'text-md font-medium',
|
|
15
|
+
hint: 'text-md',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export { selectionControlSizes };
|
|
20
|
+
//# sourceMappingURL=selectionControl.styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectionControl.styles.js","sources":["../../../../src/components/__internal__/selectionControl/selectionControl.styles.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAIA;AACO,MAAM,qBAAqB,GAAG,MAAM,CAAC;AAC1C,IAAA,EAAE,EAAE;AACF,QAAA,IAAI,EAAE,OAAO;AACb,QAAA,WAAW,EAAE,EAAE;AACf,QAAA,KAAK,EAAE,qBAAqB;AAC5B,QAAA,IAAI,EAAE,SAAS;AAChB,KAAA;AACD,IAAA,EAAE,EAAE;AACF,QAAA,IAAI,EAAE,OAAO;AACb,QAAA,WAAW,EAAE,SAAS;AACtB,QAAA,KAAK,EAAE,qBAAqB;AAC5B,QAAA,IAAI,EAAE,SAAS;AAChB,KAAA;AACgG,CAAA;;"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Accessible name for a native selection control, since RN's `accessibilityLabel` takes only a string.
|
|
4
|
+
*
|
|
5
|
+
* @param ariaLabel Explicit name from the web-style `aria-label` prop; always wins when set.
|
|
6
|
+
* @param label The visible label, used only when it is plain text.
|
|
7
|
+
* @returns The name to announce, or `undefined` when neither gives a string.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getAccessibleName: (ariaLabel: string | undefined, label: ReactNode) => string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Screen-reader hint for a native selection control, since RN's `accessibilityHint` takes only a string.
|
|
12
|
+
*
|
|
13
|
+
* @param hint The visible hint, announced after the name only when it is plain text.
|
|
14
|
+
* @returns The hint to announce, or `undefined` for a non-string or missing hint.
|
|
15
|
+
*/
|
|
16
|
+
export declare const getAccessibleHint: (hint: ReactNode) => string | undefined;
|
|
17
|
+
export declare const SELECTION_CONTROL_HIT_SLOP: {
|
|
18
|
+
top: number;
|
|
19
|
+
bottom: number;
|
|
20
|
+
left: number;
|
|
21
|
+
right: number;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=selectionControl.utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectionControl.utils.d.ts","sourceRoot":"","sources":["../../../../src/components/__internal__/selectionControl/selectionControl.utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,WAAW,MAAM,GAAG,SAAS,EAAE,OAAO,SAAS,KAAG,MAAM,GAAG,SAC/B,CAAC;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,SAAS,KAAG,MAAM,GAAG,SAA0D,CAAC;AAGxH,eAAO,MAAM,0BAA0B;;;;;CAA6C,CAAC"}
|
|
@@ -4,6 +4,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
5
5
|
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
6
6
|
var reactAriaComponents = require('react-aria-components');
|
|
7
|
+
var selectionControl_styles = require('../../__internal__/selectionControl/selectionControl.styles.cjs');
|
|
7
8
|
|
|
8
9
|
/** Visual-only checkbox square with no input behaviour, for building custom selectable controls; `Checkbox` renders it inside a react-aria `Checkbox`. */
|
|
9
10
|
const CheckboxBase = ({ className, isSelected, isDisabled, isIndeterminate, size = 'sm', isFocusVisible = false }) => {
|
|
@@ -18,24 +19,10 @@ CheckboxBase.displayName = 'CheckboxBase';
|
|
|
18
19
|
*/
|
|
19
20
|
const Checkbox = ({ label, hint, size = 'sm', className, 'data-testid': dataTestId, ...ariaCheckboxProps }) => {
|
|
20
21
|
const checkboxTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'checkbox', rootName: 'checkbox' });
|
|
21
|
-
|
|
22
|
-
sm: {
|
|
23
|
-
root: 'gap-2',
|
|
24
|
-
textWrapper: '',
|
|
25
|
-
label: 'text-sm font-medium',
|
|
26
|
-
hint: 'text-sm',
|
|
27
|
-
},
|
|
28
|
-
md: {
|
|
29
|
-
root: 'gap-3',
|
|
30
|
-
textWrapper: 'gap-0.5',
|
|
31
|
-
label: 'text-md font-medium',
|
|
32
|
-
hint: 'text-md',
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
return (jsxRuntime.jsx(reactAriaComponents.Checkbox, { ...ariaCheckboxProps, "data-testid": checkboxTestId, className: (state) => cx.cx('relative flex items-start', state.isDisabled && 'cursor-not-allowed', sizes[size].root, typeof className === 'function' ? className(state) : className), children: ({ isSelected, isIndeterminate, isDisabled, isFocusVisible }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(CheckboxBase, { size: size, isSelected: isSelected, isIndeterminate: isIndeterminate, isDisabled: isDisabled, isFocusVisible: isFocusVisible, className: label || hint ? 'mt-0.5' : '' }), (label || hint) && (jsxRuntime.jsxs("div", { className: cx.cx('inline-flex flex-col', sizes[size].textWrapper), children: [label && jsxRuntime.jsx("p", { className: cx.cx('text-secondary select-none', sizes[size].label), children: label }), hint && (
|
|
22
|
+
return (jsxRuntime.jsx(reactAriaComponents.Checkbox, { ...ariaCheckboxProps, "data-testid": checkboxTestId, className: (state) => cx.cx('relative flex items-start', state.isDisabled && 'cursor-not-allowed', selectionControl_styles.selectionControlSizes[size].root, typeof className === 'function' ? className(state) : className), children: ({ isSelected, isIndeterminate, isDisabled, isFocusVisible }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(CheckboxBase, { size: size, isSelected: isSelected, isIndeterminate: isIndeterminate, isDisabled: isDisabled, isFocusVisible: isFocusVisible, className: label || hint ? 'mt-0.5' : '' }), (label || hint) && (jsxRuntime.jsxs("div", { className: cx.cx('inline-flex flex-col', selectionControl_styles.selectionControlSizes[size].textWrapper), children: [label && jsxRuntime.jsx("p", { className: cx.cx('text-secondary select-none', selectionControl_styles.selectionControlSizes[size].label), children: label }), hint && (
|
|
36
23
|
// biome-ignore lint/a11y/noStaticElementInteractions: not independently interactive — only stops the click reaching outer React handlers, see below
|
|
37
24
|
// biome-ignore lint/a11y/useKeyWithClickEvents: same as above, no keyboard equivalent needed
|
|
38
|
-
jsxRuntime.jsx("span", { className: cx.cx('text-tertiary',
|
|
25
|
+
jsxRuntime.jsx("span", { className: cx.cx('text-tertiary', selectionControl_styles.selectionControlSizes[size].hint), onClick: (event) => {
|
|
39
26
|
// Deliberately stopPropagation only, no preventDefault (matches the
|
|
40
27
|
// Untitled UI reference). The native <label>->control click-forwarding
|
|
41
28
|
// that toggles the checkbox happens during the real DOM bubble phase,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"sourcesContent":[null],"names":["_jsxs","cx","_jsx","useResolvedTestId","AriaCheckbox","_Fragment"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"sourcesContent":[null],"names":["_jsxs","cx","_jsx","useResolvedTestId","AriaCheckbox","selectionControlSizes","_Fragment"],"mappings":";;;;;;;;AAuBA;MACa,YAAY,GAAG,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,GAAG,IAAI,EAAE,cAAc,GAAG,KAAK,EAAqB,KAAI;AAC7I,IAAA,QACEA,eAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAEC,KAAE,CACX,4IAA4I,EAC5I,IAAI,KAAK,IAAI,IAAI,mBAAmB,EACpC,CAAC,UAAU,IAAI,eAAe,KAAK,iCAAiC,EACpE,UAAU,IAAI,+BAA+B,EAC7C,UAAU,IAAI,EAAE,UAAU,IAAI,eAAe,CAAC,IAAI,aAAa,EAC/D,cAAc,IAAI,+CAA+C,EACjE,SAAS,CACV,EAAA,QAAA,EAAA,CAEDC,cAAA,CAAA,KAAA,EAAA,EAAA,aAAA,EACc,MAAM,EAClB,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,SAAS,EAAED,KAAE,CACX,uFAAuF,EACvF,IAAI,KAAK,IAAI,IAAI,UAAU,EAC3B,eAAe,IAAI,aAAa,CACjC,EAAA,QAAA,EAEDC,yBAAM,CAAC,EAAC,oBAAoB,EAAC,MAAM,EAAC,cAAc,EAAC,WAAW,EAAC,GAAG,EAAC,aAAa,EAAC,OAAO,EAAC,cAAc,EAAC,OAAO,EAAA,CAAG,EAAA,CAC9G,EAENA,cAAA,CAAA,KAAA,EAAA,EAAA,aAAA,EACc,MAAM,EAClB,OAAO,EAAC,WAAW,EACnB,IAAI,EAAC,MAAM,EACX,SAAS,EAAED,KAAE,CACX,oFAAoF,EACpF,IAAI,KAAK,IAAI,IAAI,UAAU,EAC3B,UAAU,IAAI,CAAC,eAA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AAK,IAAI,IAAI,MACbF,eAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAEC,KAAE,CAAC,sBAAsB,EAAEI,6CAAqB,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,EAAA,QAAA,EAAA,CAChF,KAAK,IAAIH,cAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAED,KAAE,CAAC,4BAA4B,EAAEI,6CAAqB,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,EAAA,QAAA,EAAG,KAAK,EAAA,CAAK,EACvG,IAAI;;;AAGH,wBAAAH,cAAA,CAAA,MAAA,EAAA,EACE,SAAS,EAAED,KAAE,CAAC,eAAe,EAAEI,6CAAqB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAChE,OAAO,EAAE,CAAC,KAAK,KAAI;;;;;;;;;gCASjB,KAAK,CAAC,eAAe,EAAE;4BACzB,CAAC,EAAA,QAAA,EAEA,IAAI,EAAA,CACA,CACR,CAAA,EAAA,CACG,CACP,CAAA,EAAA,CACA,CACJ,EAAA,CACY;AAEnB;AACA,QAAQ,CAAC,WAAW,GAAG,UAAU;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAA4B,KAAK,aAAa,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAA4B,KAAK,aAAa,IAAI,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAG1G,MAAM,WAAW,iBAAiB;IAChC,qDAAqD;IACrD,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,iDAAiD;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oDAAoD;IACpD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,oEAAoE;IACpE,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,mDAAmD;IACnD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,qGAAqG;IACrG,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,0JAA0J;AAC1J,eAAO,MAAM,YAAY;mFAAiG,iBAAiB;;CAwC1I,CAAC;AAGF,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACtD,iDAAiD;IACjD,GAAG,CAAC,EAAE,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC5B,0DAA0D;IAC1D,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACnB,mEAAmE;IACnE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,6CAA6C;IAC7C,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,+DAA+D;IAC/D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,eAAO,MAAM,QAAQ;wFAA8F,aAAa;;CAuD/H,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
3
3
|
import { useResolvedTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
4
4
|
import { Checkbox as Checkbox$1 } from 'react-aria-components';
|
|
5
|
+
import { selectionControlSizes } from '../../__internal__/selectionControl/selectionControl.styles.js';
|
|
5
6
|
|
|
6
7
|
/** Visual-only checkbox square with no input behaviour, for building custom selectable controls; `Checkbox` renders it inside a react-aria `Checkbox`. */
|
|
7
8
|
const CheckboxBase = ({ className, isSelected, isDisabled, isIndeterminate, size = 'sm', isFocusVisible = false }) => {
|
|
@@ -16,24 +17,10 @@ CheckboxBase.displayName = 'CheckboxBase';
|
|
|
16
17
|
*/
|
|
17
18
|
const Checkbox = ({ label, hint, size = 'sm', className, 'data-testid': dataTestId, ...ariaCheckboxProps }) => {
|
|
18
19
|
const checkboxTestId = useResolvedTestId({ testId: dataTestId, segment: 'checkbox', rootName: 'checkbox' });
|
|
19
|
-
|
|
20
|
-
sm: {
|
|
21
|
-
root: 'gap-2',
|
|
22
|
-
textWrapper: '',
|
|
23
|
-
label: 'text-sm font-medium',
|
|
24
|
-
hint: 'text-sm',
|
|
25
|
-
},
|
|
26
|
-
md: {
|
|
27
|
-
root: 'gap-3',
|
|
28
|
-
textWrapper: 'gap-0.5',
|
|
29
|
-
label: 'text-md font-medium',
|
|
30
|
-
hint: 'text-md',
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
return (jsx(Checkbox$1, { ...ariaCheckboxProps, "data-testid": checkboxTestId, className: (state) => cx('relative flex items-start', state.isDisabled && 'cursor-not-allowed', sizes[size].root, typeof className === 'function' ? className(state) : className), children: ({ isSelected, isIndeterminate, isDisabled, isFocusVisible }) => (jsxs(Fragment, { children: [jsx(CheckboxBase, { size: size, isSelected: isSelected, isIndeterminate: isIndeterminate, isDisabled: isDisabled, isFocusVisible: isFocusVisible, className: label || hint ? 'mt-0.5' : '' }), (label || hint) && (jsxs("div", { className: cx('inline-flex flex-col', sizes[size].textWrapper), children: [label && jsx("p", { className: cx('text-secondary select-none', sizes[size].label), children: label }), hint && (
|
|
20
|
+
return (jsx(Checkbox$1, { ...ariaCheckboxProps, "data-testid": checkboxTestId, className: (state) => cx('relative flex items-start', state.isDisabled && 'cursor-not-allowed', selectionControlSizes[size].root, typeof className === 'function' ? className(state) : className), children: ({ isSelected, isIndeterminate, isDisabled, isFocusVisible }) => (jsxs(Fragment, { children: [jsx(CheckboxBase, { size: size, isSelected: isSelected, isIndeterminate: isIndeterminate, isDisabled: isDisabled, isFocusVisible: isFocusVisible, className: label || hint ? 'mt-0.5' : '' }), (label || hint) && (jsxs("div", { className: cx('inline-flex flex-col', selectionControlSizes[size].textWrapper), children: [label && jsx("p", { className: cx('text-secondary select-none', selectionControlSizes[size].label), children: label }), hint && (
|
|
34
21
|
// biome-ignore lint/a11y/noStaticElementInteractions: not independently interactive — only stops the click reaching outer React handlers, see below
|
|
35
22
|
// biome-ignore lint/a11y/useKeyWithClickEvents: same as above, no keyboard equivalent needed
|
|
36
|
-
jsx("span", { className: cx('text-tertiary',
|
|
23
|
+
jsx("span", { className: cx('text-tertiary', selectionControlSizes[size].hint), onClick: (event) => {
|
|
37
24
|
// Deliberately stopPropagation only, no preventDefault (matches the
|
|
38
25
|
// Untitled UI reference). The native <label>->control click-forwarding
|
|
39
26
|
// that toggles the checkbox happens during the real DOM bubble phase,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx","AriaCheckbox","_Fragment"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/Checkbox/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx","AriaCheckbox","_Fragment"],"mappings":";;;;;;AAuBA;MACa,YAAY,GAAG,CAAC,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,GAAG,IAAI,EAAE,cAAc,GAAG,KAAK,EAAqB,KAAI;AAC7I,IAAA,QACEA,IAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAE,EAAE,CACX,4IAA4I,EAC5I,IAAI,KAAK,IAAI,IAAI,mBAAmB,EACpC,CAAC,UAAU,IAAI,eAAe,KAAK,iCAAiC,EACpE,UAAU,IAAI,+BAA+B,EAC7C,UAAU,IAAI,EAAE,UAAU,IAAI,eAAe,CAAC,IAAI,aAAa,EAC/D,cAAc,IAAI,+CAA+C,EACjE,SAAS,CACV,EAAA,QAAA,EAAA,CAEDC,GAAA,CAAA,KAAA,EAAA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
|
|
@@ -21,20 +21,6 @@ const styles = cx.sortCx({
|
|
|
21
21
|
sm: 'translate-x-4',
|
|
22
22
|
md: 'translate-x-5',
|
|
23
23
|
},
|
|
24
|
-
sizes: {
|
|
25
|
-
sm: {
|
|
26
|
-
root: 'gap-2',
|
|
27
|
-
textWrapper: '',
|
|
28
|
-
label: 'text-sm font-medium',
|
|
29
|
-
hint: 'text-sm',
|
|
30
|
-
},
|
|
31
|
-
md: {
|
|
32
|
-
root: 'gap-3',
|
|
33
|
-
textWrapper: 'gap-0.5',
|
|
34
|
-
label: 'text-md font-medium',
|
|
35
|
-
hint: 'text-md',
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
24
|
});
|
|
39
25
|
|
|
40
26
|
exports.styles = styles;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toggle.styles.cjs","sources":["../../../../src/components/atoms/Toggle/Toggle.styles.ts"],"sourcesContent":[null],"names":["sortCx"],"mappings":";;;;AAGO,MAAM,MAAM,GAAGA,SAAM,CAAC;AAC3B,IAAA,KAAK,EAAE;AACL,QAAA,OAAO,EAAE;AACP,YAAA,EAAE,EAAE,eAAe;AACnB,YAAA,EAAE,EAAE,gBAAgB;AACrB,SAAA;AACD,QAAA,IAAI,EAAE;AACJ,YAAA,EAAE,EAAE,SAAS;AACb,YAAA,EAAE,EAAE,UAAU;AACf,SAAA;AAC+D,KAAA;AAClE,IAAA,IAAI,EAAE;AACJ,QAAA,EAAE,EAAE,QAAQ;AACZ,QAAA,EAAE,EAAE,QAAQ;AACwB,KAAA;AACtC,IAAA,YAAY,EAAE;AACZ,QAAA,EAAE,EAAE,eAAe;AACnB,QAAA,EAAE,EAAE,eAAe;AACiB,KAAA;
|
|
1
|
+
{"version":3,"file":"Toggle.styles.cjs","sources":["../../../../src/components/atoms/Toggle/Toggle.styles.ts"],"sourcesContent":[null],"names":["sortCx"],"mappings":";;;;AAGO,MAAM,MAAM,GAAGA,SAAM,CAAC;AAC3B,IAAA,KAAK,EAAE;AACL,QAAA,OAAO,EAAE;AACP,YAAA,EAAE,EAAE,eAAe;AACnB,YAAA,EAAE,EAAE,gBAAgB;AACrB,SAAA;AACD,QAAA,IAAI,EAAE;AACJ,YAAA,EAAE,EAAE,SAAS;AACb,YAAA,EAAE,EAAE,UAAU;AACf,SAAA;AAC+D,KAAA;AAClE,IAAA,IAAI,EAAE;AACJ,QAAA,EAAE,EAAE,QAAQ;AACZ,QAAA,EAAE,EAAE,QAAQ;AACwB,KAAA;AACtC,IAAA,YAAY,EAAE;AACZ,QAAA,EAAE,EAAE,eAAe;AACnB,QAAA,EAAE,EAAE,eAAe;AACiB,KAAA;AACvC,CAAA;;"}
|
|
@@ -17,19 +17,5 @@ export declare const styles: {
|
|
|
17
17
|
sm: string;
|
|
18
18
|
md: string;
|
|
19
19
|
};
|
|
20
|
-
sizes: {
|
|
21
|
-
sm: {
|
|
22
|
-
root: string;
|
|
23
|
-
textWrapper: string;
|
|
24
|
-
label: string;
|
|
25
|
-
hint: string;
|
|
26
|
-
};
|
|
27
|
-
md: {
|
|
28
|
-
root: string;
|
|
29
|
-
textWrapper: string;
|
|
30
|
-
label: string;
|
|
31
|
-
hint: string;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
20
|
};
|
|
35
21
|
//# sourceMappingURL=Toggle.styles.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toggle.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Toggle/Toggle.styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM
|
|
1
|
+
{"version":3,"file":"Toggle.styles.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Toggle/Toggle.styles.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;CAmBjB,CAAC"}
|
|
@@ -19,20 +19,6 @@ const styles = sortCx({
|
|
|
19
19
|
sm: 'translate-x-4',
|
|
20
20
|
md: 'translate-x-5',
|
|
21
21
|
},
|
|
22
|
-
sizes: {
|
|
23
|
-
sm: {
|
|
24
|
-
root: 'gap-2',
|
|
25
|
-
textWrapper: '',
|
|
26
|
-
label: 'text-sm font-medium',
|
|
27
|
-
hint: 'text-sm',
|
|
28
|
-
},
|
|
29
|
-
md: {
|
|
30
|
-
root: 'gap-3',
|
|
31
|
-
textWrapper: 'gap-0.5',
|
|
32
|
-
label: 'text-md font-medium',
|
|
33
|
-
hint: 'text-md',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
22
|
});
|
|
37
23
|
|
|
38
24
|
export { styles };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Toggle.styles.js","sources":["../../../../src/components/atoms/Toggle/Toggle.styles.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAGO,MAAM,MAAM,GAAG,MAAM,CAAC;AAC3B,IAAA,KAAK,EAAE;AACL,QAAA,OAAO,EAAE;AACP,YAAA,EAAE,EAAE,eAAe;AACnB,YAAA,EAAE,EAAE,gBAAgB;AACrB,SAAA;AACD,QAAA,IAAI,EAAE;AACJ,YAAA,EAAE,EAAE,SAAS;AACb,YAAA,EAAE,EAAE,UAAU;AACf,SAAA;AAC+D,KAAA;AAClE,IAAA,IAAI,EAAE;AACJ,QAAA,EAAE,EAAE,QAAQ;AACZ,QAAA,EAAE,EAAE,QAAQ;AACwB,KAAA;AACtC,IAAA,YAAY,EAAE;AACZ,QAAA,EAAE,EAAE,eAAe;AACnB,QAAA,EAAE,EAAE,eAAe;AACiB,KAAA;
|
|
1
|
+
{"version":3,"file":"Toggle.styles.js","sources":["../../../../src/components/atoms/Toggle/Toggle.styles.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAGO,MAAM,MAAM,GAAG,MAAM,CAAC;AAC3B,IAAA,KAAK,EAAE;AACL,QAAA,OAAO,EAAE;AACP,YAAA,EAAE,EAAE,eAAe;AACnB,YAAA,EAAE,EAAE,gBAAgB;AACrB,SAAA;AACD,QAAA,IAAI,EAAE;AACJ,YAAA,EAAE,EAAE,SAAS;AACb,YAAA,EAAE,EAAE,UAAU;AACf,SAAA;AAC+D,KAAA;AAClE,IAAA,IAAI,EAAE;AACJ,QAAA,EAAE,EAAE,QAAQ;AACZ,QAAA,EAAE,EAAE,QAAQ;AACwB,KAAA;AACtC,IAAA,YAAY,EAAE;AACZ,QAAA,EAAE,EAAE,eAAe;AACnB,QAAA,EAAE,EAAE,eAAe;AACiB,KAAA;AACvC,CAAA;;"}
|
|
@@ -4,6 +4,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
5
5
|
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
6
6
|
var reactAriaComponents = require('react-aria-components');
|
|
7
|
+
var selectionControl_styles = require('../../__internal__/selectionControl/selectionControl.styles.cjs');
|
|
7
8
|
var Toggle_styles = require('./Toggle.styles.cjs');
|
|
8
9
|
|
|
9
10
|
/** Visual-only switch track and knob with no input behaviour, for building custom controls; `Toggle` renders it inside a react-aria `Switch`. */
|
|
@@ -19,10 +20,10 @@ const ToggleBase = ({ className, isHovered, isDisabled, isFocusVisible, isSelect
|
|
|
19
20
|
*/
|
|
20
21
|
const Toggle = ({ label, hint, className, size = 'sm', slim, 'data-testid': dataTestId, ...ariaSwitchProps }) => {
|
|
21
22
|
const toggleTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'toggle', rootName: 'toggle' });
|
|
22
|
-
return (jsxRuntime.jsx(reactAriaComponents.Switch, { ...ariaSwitchProps, "data-testid": toggleTestId, className: (state) => cx.cx('relative flex w-max items-start', state.isDisabled && 'cursor-not-allowed',
|
|
23
|
+
return (jsxRuntime.jsx(reactAriaComponents.Switch, { ...ariaSwitchProps, "data-testid": toggleTestId, className: (state) => cx.cx('relative flex w-max items-start', state.isDisabled && 'cursor-not-allowed', selectionControl_styles.selectionControlSizes[size].root, typeof className === 'function' ? className(state) : className), children: ({ isSelected, isDisabled, isFocusVisible, isHovered }) => (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(ToggleBase, { slim: slim, size: size, isHovered: isHovered, isDisabled: isDisabled, isFocusVisible: isFocusVisible, isSelected: isSelected, className: slim ? 'mt-0.5' : '' }), (label || hint) && (jsxRuntime.jsxs("div", { className: cx.cx('flex flex-col', selectionControl_styles.selectionControlSizes[size].textWrapper), children: [label && jsxRuntime.jsx("p", { className: cx.cx('text-secondary select-none', selectionControl_styles.selectionControlSizes[size].label), children: label }), hint && (
|
|
23
24
|
// biome-ignore lint/a11y/noStaticElementInteractions: This is a hint that is not interactive
|
|
24
25
|
// biome-ignore lint/a11y/useKeyWithClickEvents: This is a hint that is not interactive
|
|
25
|
-
jsxRuntime.jsx("span", { className: cx.cx('text-tertiary',
|
|
26
|
+
jsxRuntime.jsx("span", { className: cx.cx('text-tertiary', selectionControl_styles.selectionControlSizes[size].hint), onClick: (event) => event.stopPropagation(), children: hint }))] }))] })) }));
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
exports.Toggle = Toggle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../../../src/components/atoms/Toggle/index.tsx"],"sourcesContent":[null],"names":["_jsx","cx","styles","useResolvedTestId","AriaSwitch","_jsxs","_Fragment"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/atoms/Toggle/index.tsx"],"sourcesContent":[null],"names":["_jsx","cx","styles","useResolvedTestId","AriaSwitch","selectionControlSizes","_jsxs","_Fragment"],"mappings":";;;;;;;;;AAuBA;MACa,UAAU,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,EAAmB,KAAI;IACjI,QACEA,cAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAEC,KAAE,CACX,uIAAuI,EACvI,UAAU,IAAI,gBAAgB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AAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/atoms/Toggle/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,IAAI,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAI5E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,UAAU,eAAe;IACvB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,iJAAiJ;AACjJ,eAAO,MAAM,UAAU,GAAI,8EAAqF,eAAe,gCAkC9H,CAAC;AAEF,MAAM,WAAW,WAAY,SAAQ,eAAe;IAClD,6DAA6D;IAC7D,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,qFAAqF;IACrF,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,eAAO,MAAM,MAAM,GAAI,uFAA8F,WAAW,gCA4C/H,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
3
3
|
import { useResolvedTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
4
4
|
import { Switch } from 'react-aria-components';
|
|
5
|
+
import { selectionControlSizes } from '../../__internal__/selectionControl/selectionControl.styles.js';
|
|
5
6
|
import { styles } from './Toggle.styles.js';
|
|
6
7
|
|
|
7
8
|
/** Visual-only switch track and knob with no input behaviour, for building custom controls; `Toggle` renders it inside a react-aria `Switch`. */
|
|
@@ -17,10 +18,10 @@ const ToggleBase = ({ className, isHovered, isDisabled, isFocusVisible, isSelect
|
|
|
17
18
|
*/
|
|
18
19
|
const Toggle = ({ label, hint, className, size = 'sm', slim, 'data-testid': dataTestId, ...ariaSwitchProps }) => {
|
|
19
20
|
const toggleTestId = useResolvedTestId({ testId: dataTestId, segment: 'toggle', rootName: 'toggle' });
|
|
20
|
-
return (jsx(Switch, { ...ariaSwitchProps, "data-testid": toggleTestId, className: (state) => cx('relative flex w-max items-start', state.isDisabled && 'cursor-not-allowed',
|
|
21
|
+
return (jsx(Switch, { ...ariaSwitchProps, "data-testid": toggleTestId, className: (state) => cx('relative flex w-max items-start', state.isDisabled && 'cursor-not-allowed', selectionControlSizes[size].root, typeof className === 'function' ? className(state) : className), children: ({ isSelected, isDisabled, isFocusVisible, isHovered }) => (jsxs(Fragment, { children: [jsx(ToggleBase, { slim: slim, size: size, isHovered: isHovered, isDisabled: isDisabled, isFocusVisible: isFocusVisible, isSelected: isSelected, className: slim ? 'mt-0.5' : '' }), (label || hint) && (jsxs("div", { className: cx('flex flex-col', selectionControlSizes[size].textWrapper), children: [label && jsx("p", { className: cx('text-secondary select-none', selectionControlSizes[size].label), children: label }), hint && (
|
|
21
22
|
// biome-ignore lint/a11y/noStaticElementInteractions: This is a hint that is not interactive
|
|
22
23
|
// biome-ignore lint/a11y/useKeyWithClickEvents: This is a hint that is not interactive
|
|
23
|
-
jsx("span", { className: cx('text-tertiary',
|
|
24
|
+
jsx("span", { className: cx('text-tertiary', selectionControlSizes[size].hint), onClick: (event) => event.stopPropagation(), children: hint }))] }))] })) }));
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
export { Toggle, ToggleBase };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/Toggle/index.tsx"],"sourcesContent":[null],"names":["_jsx","AriaSwitch","_jsxs","_Fragment"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/atoms/Toggle/index.tsx"],"sourcesContent":[null],"names":["_jsx","AriaSwitch","_jsxs","_Fragment"],"mappings":";;;;;;;AAuBA;MACa,UAAU,GAAG,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,EAAmB,KAAI;IACjI,QACEA,GAAA,CAAA,KAAA,EAAA,EACE,SAAS,EAAE,EAAE,CACX,uIAAuI,EACvI,UAAU,IAAI,gBAAgB,EAC9B,UAAU,IAAI,SAAS,IAAI,sBAAsB,EACjD,UAAU,IAAI,+BAA+B,EAC7C,cAAc,IAAI,4BAA4B,EAE9C,IAAI,IAAI,QAAQ,EAChB,IAAI,IAAI,UAAU,IAAI,kBAAkB,EACxC,MAAM,CAAC,KAAK,CAAC,IAAI,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC,IAAI,CAAC,EAC7C,SAAS,CACV,EAAA,QAAA,EAEDA,GAAA,CAAA,KAAA,EAAA,EACE,KAAK,EAAE;AACL,gBAAA,UAAU,EAAE,kHAAkH;aAC/H,EACD,SAAS,EAAE,EAAE,CACX,oCAAoC,EAEpC,IAAI,IAAI,WAAW,EACnB,IAAI,IAAI,6BAA6B,EACrC,IAAI,IAAI,UAAU,IAAI,mCAAmC,EACzD,IAAI,IAAI,UAAU,IAAI,SAAS,IAAI,yCAAyC,EAE5E,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EACjB,UAAU,IAAI,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,CACxC,EAAA,CACD,EAAA,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qB,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,EAAA,QAAA,EAAG,KAAK,EAAA,CAAK,EACvG,IAAI;;;AAGH,wBAAAA,GAAA,CAAA,MAAA,EAAA,EAAM,SAAS,EAAE,EAAE,CAAC,eAAe,EAAE,qBAAqB,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,eAAe,EAAE,EAAA,QAAA,EAChH,IAAI,EAAA,CACA,CACR,IACG,CACP,CAAA,EAAA,CACA,CACJ,EAAA,CACU;AAEjB;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var ErrorBoundary = require('@flipdish/ui-library/providers/ErrorBoundary');
|
|
5
|
+
var cx = require('@flipdish/ui-library/utilities/cx');
|
|
6
|
+
var testIdUtils = require('@flipdish/ui-library/utilities/testIdUtils');
|
|
7
|
+
|
|
8
|
+
/** English fallback copy — consumers localise via `renderError`. TODO(i18n): source from ui-library's translation layer once one exists. */
|
|
9
|
+
const DefaultWidgetError = ({ testId }) => (jsxRuntime.jsxs("div", { role: "alert", "data-testid": testId, className: "flex w-full flex-col items-center gap-2 py-xl text-center", children: [jsxRuntime.jsx("h2", { className: "font-semibold text-md text-primary", children: "Something went wrong" }), jsxRuntime.jsx("p", { className: "text-sm text-tertiary", children: "An unexpected error occurred in this widget." })] }));
|
|
10
|
+
/**
|
|
11
|
+
* Widget-shaped template for a micro-frontend mounted beside a page: a named `region` that fills
|
|
12
|
+
* the height its host gives it, with pinned `header` and `footer` slots around a content area
|
|
13
|
+
* that scrolls internally, and an error boundary keyed by `widgetName`. Reach for it instead of
|
|
14
|
+
* `PageLayout` whenever the host page already owns `<main>` and the document must not scroll.
|
|
15
|
+
*
|
|
16
|
+
* @summary bounded-height widget template with pinned header and footer
|
|
17
|
+
*/
|
|
18
|
+
const WidgetLayout = ({ widgetName, label, header, footer, children, renderError, onError, scrollAreaProps, className, 'data-testid': dataTestId, }) => {
|
|
19
|
+
const widgetLayoutTestId = testIdUtils.useResolvedTestId({ testId: dataTestId, segment: 'widget-layout', rootName: 'widget-layout' });
|
|
20
|
+
const scrollAreaTestId = scrollAreaProps?.['data-testid'] ?? testIdUtils.joinTestId(widgetLayoutTestId, 'scroll-area');
|
|
21
|
+
// A `<section>` with an accessible name is a `region` landmark; without a name it is a plain `div`, so a
|
|
22
|
+
// host that already provides the landmark does not get a nested, same-named one.
|
|
23
|
+
const Root = label ? 'section' : 'div';
|
|
24
|
+
return (
|
|
25
|
+
// `h-full`, never a viewport unit: the host supplies the bounded height, and WebView viewport units can
|
|
26
|
+
// disagree with the visible area. `min-h-0` lets the scroll region shrink below its content's height.
|
|
27
|
+
jsxRuntime.jsxs(Root, { "aria-label": label, "data-testid": widgetLayoutTestId, className: cx.cx('flex h-full min-h-0 w-full flex-col gap-md p-md pb-[max(var(--spacing-md),env(safe-area-inset-bottom))]', className), children: [header, jsxRuntime.jsx("div", { id: scrollAreaProps?.id, ref: scrollAreaProps?.ref, "data-testid": scrollAreaTestId,
|
|
28
|
+
// Focusable so keyboard users can scroll content that has no focusable element of its own (axe: scrollable-region-focusable).
|
|
29
|
+
// biome-ignore lint/a11y/noNoninteractiveTabindex: a scrollable region must be reachable by keyboard
|
|
30
|
+
tabIndex: 0,
|
|
31
|
+
// `overscroll-contain` keeps a scroll that reaches the end from chaining to the host page.
|
|
32
|
+
className: cx.cx('min-h-0 flex-1 overflow-y-auto overscroll-contain outline-focus-ring focus-visible:outline-2 focus-visible:-outline-offset-2', scrollAreaProps?.className), children: jsxRuntime.jsx(ErrorBoundary.ErrorBoundary, { identifier: widgetName, onError: onError, renderFallback: (error) => renderError?.({ error, widgetName }) ?? jsxRuntime.jsx(DefaultWidgetError, { testId: testIdUtils.joinTestId(widgetLayoutTestId, 'error') }), children: children }) }), footer] }));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.WidgetLayout = WidgetLayout;
|
|
36
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../../../src/components/templates/WidgetLayout/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx","useResolvedTestId","joinTestId","cx","ErrorBoundary"],"mappings":";;;;;;;AAiDA;AACA,MAAM,kBAAkB,GAAG,CAAC,EAAE,MAAM,EAAuB,MACzDA,eAAA,CAAA,KAAA,EAAA,EAAK,IAAI,EAAC,OAAO,iBAAc,MAAM,EAAE,SAAS,EAAC,2DAA2D,EAAA,QAAA,EAAA,CAC1GC,cAAA,CAAA,IAAA,EAAA,EAAI,SAAS,EAAC,oCAAoC,EAAA,QAAA,EAAA,sBAAA,EAAA,CAA0B,EAC5EA,cAAA,CAAA,GAAA,EAAA,EAAG,SAAS,EAAC,uBAAuB,EAAA,QAAA,EAAA,8CAAA,EAAA,CAAiD,CAAA,EAAA,CACjF,CACP;AAED;;;;;;;AAOG;AACI,MAAM,YAAY,GAAG,CAAC,EAC3B,UAAU,EACV,KAAK,EACL,MAAM,EACN,MAAM,EACN,QAAQ,EACR,WAAW,EACX,OAAO,EACP,eAAe,EACf,SAAS,EACT,aAAa,EAAE,UAAU,GACP,KAAe;AACjC,IAAA,MAAM,kBAAkB,GAAGC,6BAAiB,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;AACzH,IAAA,MAAM,gBAAgB,GAAG,eAAe,GAAG,aAAa,CAAC,IAAIC,sBAAU,CAAC,kBAAkB,EAAE,aAAa,CAAC;;;IAG1G,MAAM,IAAI,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK;IAEtC;;;AAGE,IAAAH,eAAA,CAAC,IAAI,EAAA,EAAA,YAAA,EACS,KAAK,EAAA,aAAA,EACJ,kBAAkB,EAC/B,SAAS,EAAEI,KAAE,CAAC,yGAAyG,EAAE,SAAS,CAAC,EAAA,QAAA,EAAA,CAElI,MAAM,EAEPH,cAAA,CAAA,KAAA,EAAA,EACE,EAAE,EAAE,eAAe,EAAE,EAAE,EACvB,GAAG,EAAE,eAAe,EAAE,GAAG,iBACZ,gBAAgB;;;AAG7B,gBAAA,QAAQ,EAAE,CAAC;;gBAEX,SAAS,EAAEG,KAAE,CACX,8HAA8H,EAC9H,eAAe,EAAE,SAAS,CAC3B,EAAA,QAAA,EAEDH,cAAA,CAACI,2BAAa,EAAA,EACZ,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,cAAc,EAAE,CAAC,KAAK,KAAK,WAAW,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,IAAIJ,cAAA,CAAC,kBAAkB,EAAA,EAAC,MAAM,EAAEE,sBAAU,CAAC,kBAAkB,EAAE,OAAO,CAAC,EAAA,CAAI,EAAA,QAAA,EAEzI,QAAQ,EAAA,CACK,EAAA,CACZ,EAEL,MAAM,CAAA,EAAA,CACF;AAEX;;"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ErrorInfo, ReactNode, Ref } from 'react';
|
|
2
|
+
export interface WidgetLayoutScrollAreaProps {
|
|
3
|
+
/** `id` for the scrolling element, e.g. for a scroll-to-bottom helper that looks it up. */
|
|
4
|
+
id?: string;
|
|
5
|
+
/** Ref to the scrolling element, e.g. to keep a chat list pinned to its newest message. */
|
|
6
|
+
ref?: Ref<HTMLDivElement>;
|
|
7
|
+
/** Extra classes merged onto the scrolling element, e.g. a gap between messages. */
|
|
8
|
+
className?: string;
|
|
9
|
+
/** Overrides the scrolling element's `data-testid` (defaults to `<root>--scroll-area`). */
|
|
10
|
+
'data-testid'?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface WidgetLayoutProps {
|
|
13
|
+
/**
|
|
14
|
+
* Stable, human-readable name of the widget (e.g. "ChatWidget"). Tags the widget-scoped error
|
|
15
|
+
* boundary so a thrown error can be attributed in logs/RUM, and is forwarded to `renderError`
|
|
16
|
+
* and `onError`.
|
|
17
|
+
*/
|
|
18
|
+
widgetName: string;
|
|
19
|
+
/**
|
|
20
|
+
* Accessible name that makes the root a `region` landmark. Set it when the widget is the landmark,
|
|
21
|
+
* since the host page already owns `<main>`; omit it when the host already wraps the widget in a named
|
|
22
|
+
* landmark such as `SidePanel`, so the root is a plain `div` and no nested region repeats the name.
|
|
23
|
+
*/
|
|
24
|
+
label?: string;
|
|
25
|
+
/** Pinned above the scroll region and rendered OUTSIDE the error boundary, so a title or close control stays usable when content throws. */
|
|
26
|
+
header?: ReactNode;
|
|
27
|
+
/** Pinned below the scroll region and rendered OUTSIDE the error boundary; the composer slot. Keeps clear of the device's bottom safe area. */
|
|
28
|
+
footer?: ReactNode;
|
|
29
|
+
/** Widget content, rendered INSIDE the error boundary and the scroll region. */
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
/** Replaces the default fallback shown when a child throws. Receives the thrown error and `widgetName` so consumers can render localised copy. */
|
|
32
|
+
renderError?: (props: {
|
|
33
|
+
error: Error;
|
|
34
|
+
widgetName: string;
|
|
35
|
+
}) => ReactNode;
|
|
36
|
+
/** Called when a child throws — wire app-level reporting (e.g. Datadog RUM) here. */
|
|
37
|
+
onError?: (error: Error, info: ErrorInfo) => void;
|
|
38
|
+
/** Hooks for the element that scrolls the content, since the host's bounded height means the widget never scrolls the document. */
|
|
39
|
+
scrollAreaProps?: WidgetLayoutScrollAreaProps;
|
|
40
|
+
/** Extra classes merged onto the root `<section>`. */
|
|
41
|
+
className?: string;
|
|
42
|
+
/** Overrides the `data-testid` (defaults to `fd-widget-layout`). */
|
|
43
|
+
'data-testid'?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Widget-shaped template for a micro-frontend mounted beside a page: a named `region` that fills
|
|
47
|
+
* the height its host gives it, with pinned `header` and `footer` slots around a content area
|
|
48
|
+
* that scrolls internally, and an error boundary keyed by `widgetName`. Reach for it instead of
|
|
49
|
+
* `PageLayout` whenever the host page already owns `<main>` and the document must not scroll.
|
|
50
|
+
*
|
|
51
|
+
* @summary bounded-height widget template with pinned header and footer
|
|
52
|
+
*/
|
|
53
|
+
export declare const WidgetLayout: ({ widgetName, label, header, footer, children, renderError, onError, scrollAreaProps, className, "data-testid": dataTestId, }: WidgetLayoutProps) => ReactNode;
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/templates/WidgetLayout/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEvD,MAAM,WAAW,2BAA2B;IAC1C,2FAA2F;IAC3F,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,2FAA2F;IAC3F,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IAC1B,oFAAoF;IACpF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2FAA2F;IAC3F,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4IAA4I;IAC5I,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,+IAA+I;IAC/I,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,gFAAgF;IAChF,QAAQ,EAAE,SAAS,CAAC;IACpB,kJAAkJ;IAClJ,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,KAAK,SAAS,CAAC;IACzE,qFAAqF;IACrF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,KAAK,IAAI,CAAC;IAClD,mIAAmI;IACnI,eAAe,CAAC,EAAE,2BAA2B,CAAC;IAC9C,sDAAsD;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oEAAoE;IACpE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAUD;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,+HAW1B,iBAAiB,KAAG,SA0CtB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { ErrorBoundary } from '@flipdish/ui-library/providers/ErrorBoundary';
|
|
3
|
+
import { cx } from '@flipdish/ui-library/utilities/cx';
|
|
4
|
+
import { useResolvedTestId, joinTestId } from '@flipdish/ui-library/utilities/testIdUtils';
|
|
5
|
+
|
|
6
|
+
/** English fallback copy — consumers localise via `renderError`. TODO(i18n): source from ui-library's translation layer once one exists. */
|
|
7
|
+
const DefaultWidgetError = ({ testId }) => (jsxs("div", { role: "alert", "data-testid": testId, className: "flex w-full flex-col items-center gap-2 py-xl text-center", children: [jsx("h2", { className: "font-semibold text-md text-primary", children: "Something went wrong" }), jsx("p", { className: "text-sm text-tertiary", children: "An unexpected error occurred in this widget." })] }));
|
|
8
|
+
/**
|
|
9
|
+
* Widget-shaped template for a micro-frontend mounted beside a page: a named `region` that fills
|
|
10
|
+
* the height its host gives it, with pinned `header` and `footer` slots around a content area
|
|
11
|
+
* that scrolls internally, and an error boundary keyed by `widgetName`. Reach for it instead of
|
|
12
|
+
* `PageLayout` whenever the host page already owns `<main>` and the document must not scroll.
|
|
13
|
+
*
|
|
14
|
+
* @summary bounded-height widget template with pinned header and footer
|
|
15
|
+
*/
|
|
16
|
+
const WidgetLayout = ({ widgetName, label, header, footer, children, renderError, onError, scrollAreaProps, className, 'data-testid': dataTestId, }) => {
|
|
17
|
+
const widgetLayoutTestId = useResolvedTestId({ testId: dataTestId, segment: 'widget-layout', rootName: 'widget-layout' });
|
|
18
|
+
const scrollAreaTestId = scrollAreaProps?.['data-testid'] ?? joinTestId(widgetLayoutTestId, 'scroll-area');
|
|
19
|
+
// A `<section>` with an accessible name is a `region` landmark; without a name it is a plain `div`, so a
|
|
20
|
+
// host that already provides the landmark does not get a nested, same-named one.
|
|
21
|
+
const Root = label ? 'section' : 'div';
|
|
22
|
+
return (
|
|
23
|
+
// `h-full`, never a viewport unit: the host supplies the bounded height, and WebView viewport units can
|
|
24
|
+
// disagree with the visible area. `min-h-0` lets the scroll region shrink below its content's height.
|
|
25
|
+
jsxs(Root, { "aria-label": label, "data-testid": widgetLayoutTestId, className: cx('flex h-full min-h-0 w-full flex-col gap-md p-md pb-[max(var(--spacing-md),env(safe-area-inset-bottom))]', className), children: [header, jsx("div", { id: scrollAreaProps?.id, ref: scrollAreaProps?.ref, "data-testid": scrollAreaTestId,
|
|
26
|
+
// Focusable so keyboard users can scroll content that has no focusable element of its own (axe: scrollable-region-focusable).
|
|
27
|
+
// biome-ignore lint/a11y/noNoninteractiveTabindex: a scrollable region must be reachable by keyboard
|
|
28
|
+
tabIndex: 0,
|
|
29
|
+
// `overscroll-contain` keeps a scroll that reaches the end from chaining to the host page.
|
|
30
|
+
className: cx('min-h-0 flex-1 overflow-y-auto overscroll-contain outline-focus-ring focus-visible:outline-2 focus-visible:-outline-offset-2', scrollAreaProps?.className), children: jsx(ErrorBoundary, { identifier: widgetName, onError: onError, renderFallback: (error) => renderError?.({ error, widgetName }) ?? jsx(DefaultWidgetError, { testId: joinTestId(widgetLayoutTestId, 'error') }), children: children }) }), footer] }));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { WidgetLayout };
|
|
34
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/templates/WidgetLayout/index.tsx"],"sourcesContent":[null],"names":["_jsxs","_jsx"],"mappings":";;;;;AAiDA;AACA,MAAM,kBAAkB,GAAG,CAAC,EAAE,MAAM,EAAuB,MACzDA,I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