@kanso-labs/kanso-ui 0.44.0 → 0.45.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 +59 -7
- package/dist/chip/index.js +24 -4
- package/dist/chip/index.js.map +1 -1
- package/dist/chip/styles.js +13 -5
- package/dist/chip/styles.js.map +1 -1
- package/dist/components/app-bar/index.d.ts +23 -7
- package/dist/components/app-bar/index.js +428 -169
- package/dist/components/app-bar/index.js.map +1 -1
- package/dist/components/autocomplete/index.d.ts +44 -0
- package/dist/components/autocomplete/index.js +44 -0
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/button/index.d.ts +3 -2
- package/dist/components/button/index.js +53 -59
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/card/index.d.ts +11 -3
- package/dist/components/card/index.js +23 -1
- package/dist/components/card/index.js.map +1 -1
- package/dist/components/checkbox/index.js +66 -58
- package/dist/components/checkbox/index.js.map +1 -1
- package/dist/components/chip/index.d.ts +46 -30
- package/dist/components/chip/index.js +38 -17
- package/dist/components/chip/index.js.map +1 -1
- package/dist/components/chip-group/index.d.ts +5 -2
- package/dist/components/chip-group/index.js +8 -2
- package/dist/components/chip-group/index.js.map +1 -1
- package/dist/components/dialog/index.d.ts +27 -0
- package/dist/components/dialog/index.js +107 -69
- package/dist/components/dialog/index.js.map +1 -1
- package/dist/components/fab/index.d.ts +1 -1
- package/dist/components/fab/index.js.map +1 -1
- package/dist/components/form/index.d.ts +14 -4
- package/dist/components/form/index.js +6 -3
- package/dist/components/form/index.js.map +1 -1
- package/dist/components/icon-button/index.d.ts +15 -1
- package/dist/components/icon-button/index.js +15 -1
- package/dist/components/icon-button/index.js.map +1 -1
- package/dist/components/link/index.d.ts +4 -0
- package/dist/components/link/index.js +4 -0
- package/dist/components/link/index.js.map +1 -1
- package/dist/components/list/index.d.ts +34 -0
- package/dist/components/list/index.js +47 -13
- package/dist/components/list/index.js.map +1 -1
- package/dist/components/list-detail/index.d.ts +34 -1
- package/dist/components/list-detail/index.js +34 -1
- package/dist/components/list-detail/index.js.map +1 -1
- package/dist/components/list-item/index.d.ts +21 -2
- package/dist/components/list-item/index.js +6 -0
- package/dist/components/list-item/index.js.map +1 -1
- package/dist/components/menu/index.d.ts +6 -3
- package/dist/components/menu/index.js +3 -1
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/meter/index.d.ts +4 -0
- package/dist/components/meter/index.js +4 -0
- package/dist/components/meter/index.js.map +1 -1
- package/dist/components/navigation-bar/index.d.ts +14 -2
- package/dist/components/navigation-bar/index.js +14 -2
- package/dist/components/navigation-bar/index.js.map +1 -1
- package/dist/components/navigation-tree/index.js +2 -9
- package/dist/components/navigation-tree/index.js.map +1 -1
- package/dist/components/number-field/index.d.ts +7 -1
- package/dist/components/number-field/index.js +7 -1
- package/dist/components/number-field/index.js.map +1 -1
- package/dist/components/popover/index.d.ts +15 -1
- package/dist/components/popover/index.js +15 -1
- package/dist/components/popover/index.js.map +1 -1
- package/dist/components/product-icon/index.d.ts +8 -1
- package/dist/components/product-icon/index.js +8 -1
- package/dist/components/product-icon/index.js.map +1 -1
- package/dist/components/progress-indicator/index.d.ts +12 -6
- package/dist/components/progress-indicator/index.js +57 -46
- package/dist/components/progress-indicator/index.js.map +1 -1
- package/dist/components/radio-group/index.d.ts +7 -0
- package/dist/components/radio-group/index.js +23 -14
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/search-field/index.d.ts +13 -4
- package/dist/components/search-field/index.js +10 -4
- package/dist/components/search-field/index.js.map +1 -1
- package/dist/components/search-view/index.d.ts +2 -0
- package/dist/components/search-view/index.js.map +1 -1
- package/dist/components/segmented-button/index.d.ts +1 -1
- package/dist/components/segmented-button/index.js.map +1 -1
- package/dist/components/separator/index.d.ts +31 -6
- package/dist/components/separator/index.js +30 -6
- package/dist/components/separator/index.js.map +1 -1
- package/dist/components/sheet/index.d.ts +96 -37
- package/dist/components/sheet/index.js +420 -143
- package/dist/components/sheet/index.js.map +1 -1
- package/dist/components/snackbar/index.d.ts +8 -1
- package/dist/components/snackbar/index.js +7 -0
- package/dist/components/snackbar/index.js.map +1 -1
- package/dist/components/stack/index.d.ts +21 -5
- package/dist/components/stack/index.js +10 -0
- package/dist/components/stack/index.js.map +1 -1
- package/dist/components/switch/index.d.ts +12 -0
- package/dist/components/switch/index.js +13 -0
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/text-field/index.d.ts +39 -9
- package/dist/components/text-field/index.js +29 -7
- package/dist/components/text-field/index.js.map +1 -1
- package/dist/components/time-picker/index.js +37 -41
- package/dist/components/time-picker/index.js.map +1 -1
- package/dist/components/tree/index.js +11 -15
- package/dist/components/tree/index.js.map +1 -1
- package/dist/control/index.js +1 -1
- package/dist/control/index.js.map +1 -1
- package/dist/control/styles.js +0 -1
- package/dist/control/styles.js.map +1 -1
- package/dist/field/index.js +148 -139
- package/dist/field/index.js.map +1 -1
- package/dist/field/styles.js +50 -7
- package/dist/field/styles.js.map +1 -1
- package/dist/hooks/useBottomEdge.js +6 -3
- package/dist/hooks/useBottomEdge.js.map +1 -1
- package/dist/hooks/useRipple.js +217 -193
- package/dist/hooks/useRipple.js.map +1 -1
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/index.js.map +1 -1
- package/dist/i18n/messages.js +34 -0
- package/dist/i18n/messages.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/indicator/styles.js +7 -4
- package/dist/indicator/styles.js.map +1 -1
- package/dist/layout.d.ts +4 -1
- package/dist/layout.js +4 -1
- package/dist/layout.js.map +1 -1
- package/dist/mark/styles.js +11 -5
- package/dist/mark/styles.js.map +1 -1
- package/dist/react-aria.d.ts +2 -2
- package/dist/row/index.js +90 -62
- package/dist/row/index.js.map +1 -1
- package/dist/row/styles.js +8 -2
- package/dist/row/styles.js.map +1 -1
- package/dist/styles/focus.js.map +1 -1
- package/dist/styles/overlay.js +8 -5
- package/dist/styles/overlay.js.map +1 -1
- package/dist/styles.css +252 -130
- package/dist/theme-scope.d.ts +14 -2
- package/dist/theme-scope.js +12 -0
- package/dist/theme-scope.js.map +1 -1
- package/package.json +3 -3
- package/dist/overlay/modal.js +0 -7
- package/dist/overlay/modal.js.map +0 -1
package/dist/theme-scope.d.ts
CHANGED
|
@@ -7,8 +7,8 @@ type ThemeScopeProps = RenderComponentProps<'div'> & {
|
|
|
7
7
|
* reader's OS asks for. A pinned scope paints its own surface and text in
|
|
8
8
|
* that scheme and sets `color-scheme` for the native controls inside, so
|
|
9
9
|
* it reads on any page. Left unset, the scope paints nothing and keeps the
|
|
10
|
-
* scheme around it: the one an enclosing scope or
|
|
11
|
-
* pins, or the OS's.
|
|
10
|
+
* scheme around it: the one an enclosing scope or a `colorScheme` class
|
|
11
|
+
* pins, on the `<html>` element or nearer, or else the OS's.
|
|
12
12
|
*/
|
|
13
13
|
scheme?: 'dark' | 'light' | undefined;
|
|
14
14
|
/**
|
|
@@ -52,6 +52,18 @@ type ThemeScopeProps = RenderComponentProps<'div'> & {
|
|
|
52
52
|
* `<div>` added inside the scope's element, so an element whose content is
|
|
53
53
|
* restricted — a list, whose children have to be list items, a paragraph,
|
|
54
54
|
* or a part of a table — is not a scope: put the scope around it instead.
|
|
55
|
+
*
|
|
56
|
+
* That container comes after whatever the scope renders, and it has no box,
|
|
57
|
+
* so layout never sees it, but selectors do. Inside the scope the last
|
|
58
|
+
* element the call site rendered is not `:last-child` and is counted wrong
|
|
59
|
+
* by `:nth-last-child()`, a lone child is not `:only-child`, and a scope
|
|
60
|
+
* with nothing in it is not `:empty`. Key a rule like that on something of
|
|
61
|
+
* the call site's own, such as a class, or put the scope around the element
|
|
62
|
+
* whose children it counts.
|
|
63
|
+
*
|
|
64
|
+
* What reaches a scope from around it is the scheme and the `--kui-*`
|
|
65
|
+
* properties. It resolves every token again from those two, so a theme
|
|
66
|
+
* applied around it in any other way stops at its edge.
|
|
55
67
|
*/
|
|
56
68
|
declare function ThemeScope({ children, render, scheme, theme, ...props }: ThemeScopeProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
57
69
|
//#endregion
|
package/dist/theme-scope.js
CHANGED
|
@@ -50,6 +50,18 @@ const containers = /* @__PURE__ */ new WeakMap();
|
|
|
50
50
|
* `<div>` added inside the scope's element, so an element whose content is
|
|
51
51
|
* restricted — a list, whose children have to be list items, a paragraph,
|
|
52
52
|
* or a part of a table — is not a scope: put the scope around it instead.
|
|
53
|
+
*
|
|
54
|
+
* That container comes after whatever the scope renders, and it has no box,
|
|
55
|
+
* so layout never sees it, but selectors do. Inside the scope the last
|
|
56
|
+
* element the call site rendered is not `:last-child` and is counted wrong
|
|
57
|
+
* by `:nth-last-child()`, a lone child is not `:only-child`, and a scope
|
|
58
|
+
* with nothing in it is not `:empty`. Key a rule like that on something of
|
|
59
|
+
* the call site's own, such as a class, or put the scope around the element
|
|
60
|
+
* whose children it counts.
|
|
61
|
+
*
|
|
62
|
+
* What reaches a scope from around it is the scheme and the `--kui-*`
|
|
63
|
+
* properties. It resolves every token again from those two, so a theme
|
|
64
|
+
* applied around it in any other way stops at its edge.
|
|
53
65
|
*/
|
|
54
66
|
function ThemeScope(t0) {
|
|
55
67
|
const $ = c(29);
|
package/dist/theme-scope.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-scope.js","names":["c","_c","stylex","useCallback","useMemo","useState","UNSAFE_PortalProvider","PortalProvider","RenderComponentProps","KuiTheme","mergeRefs","useRender","mergeStyles","pinnedScheme","colorDefaultsDarkTheme","colorDefaultsLightTheme","tokenScope","styles","root","kB7OPa","$$css","schemes","dark","light","ThemeScopeProps","scheme","theme","containerClassName","className","containers","WeakMap","Element","HTMLDivElement","ThemeScope","t0","$","children","props","render","container","setContainer","t1","getContainer","t2","Symbol","for","scope","made","get","undefined","ownerDocument","createElement","append","set","attach","t3","ref","t4","t5","t6","style","t7","t8","defaultTagName","_c","props","stylex.props","PortalProvider"],"sources":["../src/theme-scope.tsx"],"sourcesContent":["'use client';\n\nimport * as stylex from '@stylexjs/stylex';\nimport { useCallback, useMemo, useState } from 'react';\nimport { UNSAFE_PortalProvider as PortalProvider } from 'react-aria/PortalProvider';\nimport type { RenderComponentProps } from './render/useRender';\nimport type { KuiTheme } from './tokens/theme';\nimport { mergeRefs } from './render/ref';\nimport { useRender } from './render/useRender';\nimport { mergeStyles } from './styles/merge';\nimport { pinnedScheme } from './styles/scheme';\nimport { colorDefaultsDarkTheme, colorDefaultsLightTheme, tokenScope } from './tokens/design.tokens.stylex';\n\n// The component form of `themeScope` and `colorScheme` in ./color-scheme.ts:\n// the same classes, on an element of its own, plus the one thing a class\n// cannot do — take the overlays along. A pinned scheme paints the scope's\n// surface and sets its `color-scheme` too; see src/styles/scheme.ts.\n//\n// React Aria portals every overlay to the end of `<body>` unless a portal\n// provider names another container, so a popover, a sheet, a tooltip or a\n// toast opened inside a themed element renders outside it, and keeps the\n// tokens of the page. The container here is inside the scope's own element,\n// which is what makes the overlays inherit whatever the scope inherits: its\n// scheme, and the `--kui-*` overrides declared on it or on any element around\n// it. A container appended to the body and given the scope's classes would\n// carry the classes alone, losing every override declared above the scope.\n//\n// It is appended to the scope's element once that element is in the document,\n// rather than rendered as one of its children. A rendered `<div>` was a child\n// of whatever the scope rendered as, so a scope rendered as a `<p>` drew\n// React's nesting error and a hydration warning, and the server's markup held\n// a `<div>` inside it. Appended, it is in neither React's tree nor the\n// server's markup, and it is there before anything can open into it.\n//\n// `display: contents` keeps that container out of the layout, so a scope\n// that is a grid or a flex container gains no item and no gap from it. React\n// Aria positions an overlay against the overlay's own containing block rather\n// than the container's box, so a container with no box of its own changes\n// nothing about where a popover lands.\nconst styles = {\n root: {\n kB7OPa: \"x9f619\",\n $$css: true\n }\n};\nconst schemes = {\n dark: colorDefaultsDarkTheme,\n light: colorDefaultsLightTheme\n};\ntype ThemeScopeProps = RenderComponentProps<'div'> & {\n /**\n * Pins the scope to the library's light or dark scheme, whatever the\n * reader's OS asks for. A pinned scope paints its own surface and text in\n * that scheme and sets `color-scheme` for the native controls inside, so\n * it reads on any page. Left unset, the scope paints nothing and keeps the\n * scheme around it: the one an enclosing scope or the `<html>` element\n * pins, or the OS's.\n */\n scheme?: 'dark' | 'light' | undefined;\n /**\n * `--kui-*` overrides for everything inside, as a map of the custom\n * properties `tokens.css` lists to CSS values. The scope declares them on\n * its own element, as an override in `style` would be, with `style` winning\n * where the two set the same property.\n *\n * The values hold for both schemes. To give light and dark a value each,\n * keep two maps and hand the scope the one for the scheme in use.\n */\n theme?: KuiTheme | undefined;\n};\n\n// The container's class, the one thing it carries: it is made with\n// `createElement`, which takes no props.\nconst containerClassName = {\n className: \"x9f619 xjp7ctv\"\n}.className ?? '';\n\n// The container made for each scope's element. A ref attaches again whenever\n// the call site hands a ref of a new identity, and a new container each time\n// would move every open overlay into it, which remounts them. So the one an\n// element already holds is kept as it is — not even appended again, since\n// moving a node blurs whatever inside it has focus — and a new one is made\n// only for a new element, as when `render` changes the tag. React removes an\n// old element with its container in it, and the map lets both go.\nconst containers = new WeakMap<Element, HTMLDivElement>();\n\n/**\n * Themes what is inside it, overlays included.\n *\n * A `--kui-*` override declared on the scope — through `theme`, `className`\n * or `style` — or on any element around it reaches every component inside,\n * where on any element but `<html>` it would otherwise reach none, since the\n * tokens resolve once on `:root`. Popovers, sheets, tooltips and toasts\n * opened inside portal into the scope rather than into the body, so they\n * follow it too. The rest of the page keeps its own tokens.\n *\n * ```tsx\n * const accent: KuiTheme = { '--kui-color-primary': '#7d5260' }\n *\n * <ThemeScope scheme=\"dark\" theme={accent}>\n * <Select label=\"Label\">…</Select>\n * </ThemeScope>\n * ```\n *\n * Because the overlays render inside the scope, an ancestor that confines\n * its descendants confines them too: a `transform` or a `filter` makes a\n * sheet's fixed scrim cover that ancestor rather than the viewport, and\n * `overflow: hidden` with a position clips a popover. Put the scope around\n * such an element rather than inside it.\n *\n * `render` swaps the element, for a scope that should be a `<main>`, a\n * `<section>`, an `<article>`, or the `<body>` itself — any element that\n * takes flow content, as a `<div>` does. The overlays' container is a\n * `<div>` added inside the scope's element, so an element whose content is\n * restricted — a list, whose children have to be list items, a paragraph,\n * or a part of a table — is not a scope: put the scope around it instead.\n */\nfunction ThemeScope({\n children,\n render,\n scheme,\n theme,\n ...props\n}: ThemeScopeProps) {\n // State rather than a ref, so the overlays render again once the container\n // exists. React Aria renders an overlay nowhere while `getContainer` hands\n // back nothing, and one open on the scope's first render would otherwise\n // stay that way.\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const getContainer = useCallback(() => container, [container]);\n const attach = useCallback((scope: HTMLDivElement | null) => {\n if (scope === null) {\n return;\n }\n let made = containers.get(scope);\n if (made === undefined) {\n made = scope.ownerDocument.createElement('div');\n made.className = containerClassName;\n scope.append(made);\n containers.set(scope, made);\n }\n setContainer(made);\n }, []);\n // The call site's ref lands on the same element. Read off `props` rather\n // than destructured, as `useRender` reads it, so the compiler sees a prop\n // holding still rather than a ref read during render.\n const ref = useMemo(() => mergeRefs(attach, props.ref ?? undefined), [attach, props.ref]);\n return useRender({\n defaultTagName: 'div',\n props: {\n ...props,\n ref,\n ...mergeStyles(stylex.props(styles.root, tokenScope, scheme !== undefined && schemes[scheme], scheme !== undefined && pinnedScheme[scheme]), theme === undefined ? props : {\n ...props,\n style: {\n ...theme,\n ...props.style\n }\n }),\n children: <PortalProvider getContainer={getContainer}>{children}</PortalProvider>\n },\n render\n });\n}\nexport type { KuiTheme } from './tokens/theme';\nexport type { ThemeScopeProps };\nexport { ThemeScope };"],"mappings":";;;;;;;;;;;;AAuCA,MAAMiB,SAAS,EACbC,MAAM;CACJC,QAAQ;CACRC,OAAO;AACT,EACF;AACA,MAAMC,UAAU;CACdC,MAAMR;CACNS,OAAOR;AACT;AAyBA,MAAMY,qBAAqB,EACzBC,WAAW,iBACb,EAAEA,aAAa;AASf,MAAMC,6BAAa,IAAIC,QAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCxD,SAAAG,WAAAC,IAAA;CAAA,MAAAC,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,IAAA3B,EAAA,QAAAG,UAAAH,EAAA,QAAA0B,IAAA;EAbcC,KAAA;GAAAC,gBACC;GAAK1B,OACdwB;GAWNvB;EAEH;EAACH,EAAA,MAAAG;EAAAH,EAAA,MAAA0B;EAAA1B,EAAA,MAAA2B;CAAA,OAAAA,KAAA3B,EAAA;CAAA,OAfMxB,UAAUmD,EAehB;AAAC"}
|
|
1
|
+
{"version":3,"file":"theme-scope.js","names":["c","_c","stylex","useCallback","useMemo","useState","UNSAFE_PortalProvider","PortalProvider","RenderComponentProps","KuiTheme","mergeRefs","useRender","mergeStyles","pinnedScheme","colorDefaultsDarkTheme","colorDefaultsLightTheme","tokenScope","styles","root","kB7OPa","$$css","schemes","dark","light","ThemeScopeProps","scheme","theme","containerClassName","className","containers","WeakMap","Element","HTMLDivElement","ThemeScope","t0","$","children","props","render","container","setContainer","t1","getContainer","t2","Symbol","for","scope","made","get","undefined","ownerDocument","createElement","append","set","attach","t3","ref","t4","t5","t6","style","t7","t8","defaultTagName","_c","props","stylex.props","PortalProvider"],"sources":["../src/theme-scope.tsx"],"sourcesContent":["'use client';\n\nimport * as stylex from '@stylexjs/stylex';\nimport { useCallback, useMemo, useState } from 'react';\nimport { UNSAFE_PortalProvider as PortalProvider } from 'react-aria/PortalProvider';\nimport type { RenderComponentProps } from './render/useRender';\nimport type { KuiTheme } from './tokens/theme';\nimport { mergeRefs } from './render/ref';\nimport { useRender } from './render/useRender';\nimport { mergeStyles } from './styles/merge';\nimport { pinnedScheme } from './styles/scheme';\nimport { colorDefaultsDarkTheme, colorDefaultsLightTheme, tokenScope } from './tokens/design.tokens.stylex';\n\n// The component form of `themeScope` and `colorScheme` in ./color-scheme.ts:\n// the same classes, on an element of its own, plus the one thing a class\n// cannot do — take the overlays along. A pinned scheme paints the scope's\n// surface and sets its `color-scheme` too; see src/styles/scheme.ts.\n//\n// React Aria portals every overlay to the end of `<body>` unless a portal\n// provider names another container, so a popover, a sheet, a tooltip or a\n// toast opened inside a themed element renders outside it, and keeps the\n// tokens of the page. The container here is inside the scope's own element,\n// which is what makes the overlays inherit whatever the scope inherits: its\n// scheme, and the `--kui-*` overrides declared on it or on any element around\n// it. A container appended to the body and given the scope's classes would\n// carry the classes alone, losing every override declared above the scope.\n//\n// It is appended to the scope's element once that element is in the document,\n// rather than rendered as one of its children. A rendered `<div>` was a child\n// of whatever the scope rendered as, so a scope rendered as a `<p>` drew\n// React's nesting error and a hydration warning, and the server's markup held\n// a `<div>` inside it. Appended, it is in neither React's tree nor the\n// server's markup, and it is there before anything can open into it.\n//\n// `display: contents` keeps that container out of the layout, so a scope\n// that is a grid or a flex container gains no item and no gap from it. React\n// Aria positions an overlay against the overlay's own containing block rather\n// than the container's box, so a container with no box of its own changes\n// nothing about where a popover lands. It is still an element, so a selector\n// that counts the scope's children counts it; the description below says\n// what that changes for a call site.\nconst styles = {\n root: {\n kB7OPa: \"x9f619\",\n $$css: true\n }\n};\nconst schemes = {\n dark: colorDefaultsDarkTheme,\n light: colorDefaultsLightTheme\n};\ntype ThemeScopeProps = RenderComponentProps<'div'> & {\n /**\n * Pins the scope to the library's light or dark scheme, whatever the\n * reader's OS asks for. A pinned scope paints its own surface and text in\n * that scheme and sets `color-scheme` for the native controls inside, so\n * it reads on any page. Left unset, the scope paints nothing and keeps the\n * scheme around it: the one an enclosing scope or a `colorScheme` class\n * pins, on the `<html>` element or nearer, or else the OS's.\n */\n scheme?: 'dark' | 'light' | undefined;\n /**\n * `--kui-*` overrides for everything inside, as a map of the custom\n * properties `tokens.css` lists to CSS values. The scope declares them on\n * its own element, as an override in `style` would be, with `style` winning\n * where the two set the same property.\n *\n * The values hold for both schemes. To give light and dark a value each,\n * keep two maps and hand the scope the one for the scheme in use.\n */\n theme?: KuiTheme | undefined;\n};\n\n// The container's class, the one thing it carries: it is made with\n// `createElement`, which takes no props.\nconst containerClassName = {\n className: \"x9f619 xjp7ctv\"\n}.className ?? '';\n\n// The container made for each scope's element. A ref attaches again whenever\n// the call site hands a ref of a new identity, and a new container each time\n// would move every open overlay into it, which remounts them. So the one an\n// element already holds is kept as it is — not even appended again, since\n// moving a node blurs whatever inside it has focus — and a new one is made\n// only for a new element, as when `render` changes the tag. React removes an\n// old element with its container in it, and the map lets both go.\nconst containers = new WeakMap<Element, HTMLDivElement>();\n\n/**\n * Themes what is inside it, overlays included.\n *\n * A `--kui-*` override declared on the scope — through `theme`, `className`\n * or `style` — or on any element around it reaches every component inside,\n * where on any element but `<html>` it would otherwise reach none, since the\n * tokens resolve once on `:root`. Popovers, sheets, tooltips and toasts\n * opened inside portal into the scope rather than into the body, so they\n * follow it too. The rest of the page keeps its own tokens.\n *\n * ```tsx\n * const accent: KuiTheme = { '--kui-color-primary': '#7d5260' }\n *\n * <ThemeScope scheme=\"dark\" theme={accent}>\n * <Select label=\"Label\">…</Select>\n * </ThemeScope>\n * ```\n *\n * Because the overlays render inside the scope, an ancestor that confines\n * its descendants confines them too: a `transform` or a `filter` makes a\n * sheet's fixed scrim cover that ancestor rather than the viewport, and\n * `overflow: hidden` with a position clips a popover. Put the scope around\n * such an element rather than inside it.\n *\n * `render` swaps the element, for a scope that should be a `<main>`, a\n * `<section>`, an `<article>`, or the `<body>` itself — any element that\n * takes flow content, as a `<div>` does. The overlays' container is a\n * `<div>` added inside the scope's element, so an element whose content is\n * restricted — a list, whose children have to be list items, a paragraph,\n * or a part of a table — is not a scope: put the scope around it instead.\n *\n * That container comes after whatever the scope renders, and it has no box,\n * so layout never sees it, but selectors do. Inside the scope the last\n * element the call site rendered is not `:last-child` and is counted wrong\n * by `:nth-last-child()`, a lone child is not `:only-child`, and a scope\n * with nothing in it is not `:empty`. Key a rule like that on something of\n * the call site's own, such as a class, or put the scope around the element\n * whose children it counts.\n *\n * What reaches a scope from around it is the scheme and the `--kui-*`\n * properties. It resolves every token again from those two, so a theme\n * applied around it in any other way stops at its edge.\n */\nfunction ThemeScope({\n children,\n render,\n scheme,\n theme,\n ...props\n}: ThemeScopeProps) {\n // State rather than a ref, so the overlays render again once the container\n // exists. React Aria renders an overlay nowhere while `getContainer` hands\n // back nothing, and one open on the scope's first render would otherwise\n // stay that way.\n const [container, setContainer] = useState<HTMLDivElement | null>(null);\n const getContainer = useCallback(() => container, [container]);\n const attach = useCallback((scope: HTMLDivElement | null) => {\n if (scope === null) {\n return;\n }\n let made = containers.get(scope);\n if (made === undefined) {\n made = scope.ownerDocument.createElement('div');\n made.className = containerClassName;\n scope.append(made);\n containers.set(scope, made);\n }\n setContainer(made);\n }, []);\n // The call site's ref lands on the same element. Read off `props` rather\n // than destructured, as `useRender` reads it, so the compiler sees a prop\n // holding still rather than a ref read during render.\n const ref = useMemo(() => mergeRefs(attach, props.ref ?? undefined), [attach, props.ref]);\n return useRender({\n defaultTagName: 'div',\n props: {\n ...props,\n ref,\n ...mergeStyles(stylex.props(styles.root, tokenScope, scheme !== undefined && schemes[scheme], scheme !== undefined && pinnedScheme[scheme]), theme === undefined ? props : {\n ...props,\n style: {\n ...theme,\n ...props.style\n }\n }),\n children: <PortalProvider getContainer={getContainer}>{children}</PortalProvider>\n },\n render\n });\n}\nexport type { KuiTheme } from './tokens/theme';\nexport type { ThemeScopeProps };\nexport { ThemeScope };"],"mappings":";;;;;;;;;;;;AAyCA,MAAMiB,SAAS,EACbC,MAAM;CACJC,QAAQ;CACRC,OAAO;AACT,EACF;AACA,MAAMC,UAAU;CACdC,MAAMR;CACNS,OAAOR;AACT;AAyBA,MAAMY,qBAAqB,EACzBC,WAAW,iBACb,EAAEA,aAAa;AASf,MAAMC,6BAAa,IAAIC,QAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CxD,SAAAG,WAAAC,IAAA;CAAA,MAAAC,IAAAlC,EAAA,EAAA;CAAA,IAAAmC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAb;CAAA,IAAAC;CAAA,IAAAS,EAAA,OAAAD,IAAA;EAAoB,CAAA,CAAAE,UAAAE,QAAAb,QAAAC,OAAA,GAAAW,WAAA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AA,KAAA3B,EAAA;CAAA,OAfMxB,UAAUmD,EAehB;AAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kanso-labs/kanso-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.45.0",
|
|
4
4
|
"description": "A React component library built on React Aria Components primitives and styled with StyleX, with design tokens sourced from a single W3C DTCG file and compiled via Style Dictionary",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"@commitlint/cli": "21.2.4",
|
|
86
86
|
"@commitlint/config-conventional": "21.2.4",
|
|
87
87
|
"@eslint/js": "10.0.1",
|
|
88
|
-
"@kanso-labs/unplugin-style-dictionary": "0.10.
|
|
88
|
+
"@kanso-labs/unplugin-style-dictionary": "0.10.37",
|
|
89
89
|
"@microsoft/api-extractor": "7.59.4",
|
|
90
90
|
"@rolldown/plugin-babel": "0.2.4",
|
|
91
91
|
"@storybook/addon-a11y": "10.6.3",
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
"tsdown": "0.23.1",
|
|
129
129
|
"typescript": "6.0.3",
|
|
130
130
|
"typescript-eslint": "8.72.0",
|
|
131
|
-
"vite": "8.3.
|
|
131
|
+
"vite": "8.3.5",
|
|
132
132
|
"vitest": "5.0.5"
|
|
133
133
|
},
|
|
134
134
|
"peerDependencies": {
|
package/dist/overlay/modal.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","names":["createContext","InsideModalContext"],"sources":["../../src/overlay/modal.ts"],"sourcesContent":["import { createContext } from 'react'\n\n// Whether a modal is open around what reads it. Every modal draws its own\n// scrim across the whole window, so one opened from inside another laid a\n// second over the first: the page darkened twice over, and the first modal's\n// own surface was dimmed with it. A modal set inside another reads this as\n// true and draws its scrim without a fill, leaving the first modal's as the\n// one the page is dimmed by. Its scrim is still there, empty, since it is\n// what React Aria reads a press outside the modal from.\n//\n// Set by a modal around its content rather than by `OverlayScope`, which\n// popovers set too: a modal opened from a popover is over a modal only if the\n// popover is inside one, and the context reaching it through the popover from\n// further out says exactly that. Apart from the components so their modules\n// export components alone, which is what keeps fast refresh working for them.\nconst InsideModalContext = createContext(false)\n\nexport { InsideModalContext }\n"],"mappings":";;AAeA,MAAMC,qBAAqBD,cAAc,KAAK"}
|