@kanso-labs/kanso-ui 0.40.9 → 0.41.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.
Files changed (39) hide show
  1. package/dist/color-scheme.d.ts +6 -0
  2. package/dist/color-scheme.js +9 -2
  3. package/dist/color-scheme.js.map +1 -1
  4. package/dist/components/app-bar/index.d.ts +11 -2
  5. package/dist/components/app-bar/index.js +53 -46
  6. package/dist/components/app-bar/index.js.map +1 -1
  7. package/dist/components/card/index.d.ts +12 -1
  8. package/dist/components/card/index.js +136 -66
  9. package/dist/components/card/index.js.map +1 -1
  10. package/dist/components/dialog/index.js +3 -2
  11. package/dist/components/dialog/index.js.map +1 -1
  12. package/dist/components/popover/index.js +3 -2
  13. package/dist/components/popover/index.js.map +1 -1
  14. package/dist/components/segmented-button/index.d.ts +3 -0
  15. package/dist/components/segmented-button/index.js +131 -65
  16. package/dist/components/segmented-button/index.js.map +1 -1
  17. package/dist/components/separator/index.js +2 -2
  18. package/dist/components/separator/index.js.map +1 -1
  19. package/dist/components/sheet/index.js +17 -16
  20. package/dist/components/sheet/index.js.map +1 -1
  21. package/dist/components/snackbar/index.d.ts +10 -3
  22. package/dist/components/snackbar/index.js +32 -12
  23. package/dist/components/snackbar/index.js.map +1 -1
  24. package/dist/components/switch/index.js +12 -3
  25. package/dist/components/switch/index.js.map +1 -1
  26. package/dist/components/toolbar/index.d.ts +3 -2
  27. package/dist/components/toolbar/index.js +3 -2
  28. package/dist/components/toolbar/index.js.map +1 -1
  29. package/dist/field/index.js +75 -48
  30. package/dist/field/index.js.map +1 -1
  31. package/dist/overlay/index.js +24 -0
  32. package/dist/overlay/index.js.map +1 -0
  33. package/dist/styles/scheme.js +19 -0
  34. package/dist/styles/scheme.js.map +1 -0
  35. package/dist/styles.css +86 -26
  36. package/dist/theme-scope.d.ts +5 -2
  37. package/dist/theme-scope.js +2 -1
  38. package/dist/theme-scope.js.map +1 -1
  39. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
1
  "use client";
2
2
  import { props } from "./node_modules/@stylexjs/stylex/lib/es/stylex.js";
3
3
  import { colorDefaultsDarkTheme, colorDefaultsLightTheme, tokenScope } from "./tokens/design.tokens.stylex.js";
4
+ import { pinnedScheme } from "./styles/scheme.js";
4
5
  import { useRender } from "./render/useRender.js";
5
6
  import { mergeStyles } from "./styles/merge.js";
6
7
  import { c } from "react/compiler-runtime";
@@ -54,7 +55,7 @@ function ThemeScope(t0) {
54
55
  } else t1 = $[1];
55
56
  const getContainer = t1;
56
57
  const t2 = "div";
57
- const t3 = mergeStyles(props(styles.root, tokenScope, scheme !== void 0 && schemes[scheme]), props$1);
58
+ const t3 = mergeStyles(props(styles.root, tokenScope, scheme !== void 0 && schemes[scheme], scheme !== void 0 && pinnedScheme[scheme]), props$1);
58
59
  let t4;
59
60
  if ($[2] !== children || $[3] !== getContainer) {
60
61
  t4 = /* @__PURE__ */ jsx(UNSAFE_PortalProvider, {
@@ -1 +1 @@
1
- {"version":3,"file":"theme-scope.js","names":["c","_c","stylex","useCallback","useState","UNSAFE_PortalProvider","PortalProvider","RenderComponentProps","useRender","mergeStyles","colorDefaultsDarkTheme","colorDefaultsLightTheme","tokenScope","styles","root","kB7OPa","$$css","schemes","dark","light","ThemeScopeProps","scheme","ThemeScope","t0","$","children","render","props","container","setContainer","t1","getContainer","t2","t3","undefined","t4","t5","t6","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, useState } from 'react';\nimport { UNSAFE_PortalProvider as PortalProvider } from 'react-aria/PortalProvider';\nimport type { RenderComponentProps } from './render/useRender';\nimport { useRender } from './render/useRender';\nimport { mergeStyles } from './styles/merge';\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.\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 the scope's own last child,\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// `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. Left unset, the scope keeps the scheme around it:\n * the one an enclosing scope or the `<html>` element pins, or the OS's.\n */\n scheme?: 'dark' | 'light' | undefined;\n};\n\n/**\n * Themes what is inside it, overlays included.\n *\n * A `--kui-*` override declared on the scope — through `className` or\n * `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 * // .accent { --kui-color-primary: #7d5260; }\n * <ThemeScope className=\"accent\" scheme=\"dark\">\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>`, or the `<body>` itself.\n */\nfunction ThemeScope({\n children,\n render,\n scheme,\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 return useRender({\n defaultTagName: 'div',\n props: {\n ...props,\n ...mergeStyles(stylex.props(styles.root, tokenScope, scheme !== undefined && schemes[scheme]), props),\n children: <>\n <PortalProvider getContainer={getContainer}>\n {children}\n </PortalProvider>\n <div className=\"x9f619 xjp7ctv\" ref={setContainer} />\n </>\n },\n render\n });\n}\nexport type { ThemeScopeProps };\nexport { ThemeScope };"],"mappings":";;;;;;;;;;AA4BA,MAAMa,SAAS,EACbC,MAAM;CACJC,QAAQ;CACRC,OAAO;AACT,EACF;AACA,MAAMC,UAAU;CACdC,MAAMR;CACNS,OAAOR;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAAW,WAAAC,IAAA;CAAA,MAAAC,IAAAvB,EAAA,EAAA;CAAoB,MAAA,EAAAwB,UAAAC,QAAAL,QAAA,GAAAM,YAAAJ;CAUlB,MAAA,CAAAK,WAAAC,gBAAkCzB,SAAgC,IAAI;CAAE,IAAA0B;CAAA,IAAAN,EAAA,OAAAI,WAAA;EACvCE,WAAMF;EAASJ,EAAA,KAAAI;EAAAJ,EAAA,KAAAM;CAAA,OAAAA,KAAAN,EAAA;CAAhD,MAAAO,eAAqBD;CAEH,MAAAE,KAAA;CAGX,MAAAC,KAAAxB,YAAYP,MAAaW,OAAMC,MAAOF,YAAYS,WAAWa,KAAAA,KAAajB,QAAQI,OAAO,GAAGM,OAAK;CAAC,IAAAQ;CAAA,IAAAX,EAAA,OAAAC,YAAAD,EAAA,OAAAO,cAAA;EAEjGI,KAAA,oBAACS,uBAAD;GAA8Bb;GAC3BN;EADY,CAAA;EAEED,EAAA,KAAAC;EAAAD,EAAA,KAAAO;EAAAP,EAAA,KAAAW;CAAA,OAAAA,KAAAX,EAAA;CAAA,IAAAY;CAAA,IAAAZ,EAAA,OAAAK,cAAA;EACjBO,KAAA,oBAAA,OAAA;GAAe,WAAA;GAAsBP,KAAAA;EAAY,CAAA;EAAIL,EAAA,KAAAK;EAAAL,EAAA,KAAAY;CAAA,OAAAA,KAAAZ,EAAA;CAAA,IAAAa;CAAA,IAAAb,EAAA,OAAAW,MAAAX,EAAA,OAAAY,IAAA;EAJ/CC,KAAA,qBAAA,YAAA,EAAA,UAAA,CACNF,IAGAC,EAAqD,EAAA,CAAA;EACpDZ,EAAA,KAAAW;EAAAX,EAAA,KAAAY;EAAAZ,EAAA,KAAAa;CAAA,OAAAA,KAAAb,EAAA;CAAA,IAAAc;CAAA,IAAAd,EAAA,QAAAG,WAAAH,EAAA,QAAAS,MAAAT,EAAA,QAAAa,IAAA;EARAC,KAAA;GAAA,GACFX;GAAK,GACLM;GAAkGR,UAC3FY;EAMZ;EAACb,EAAA,MAAAG;EAAAH,EAAA,MAAAS;EAAAT,EAAA,MAAAa;EAAAb,EAAA,MAAAc;CAAA,OAAAA,KAAAd,EAAA;CAAA,IAAAe;CAAA,IAAAf,EAAA,QAAAE,UAAAF,EAAA,QAAAc,IAAA;EAXcC,KAAA;GAAAC,gBACCR;GAAKL,OACdW;GASNZ;EAEH;EAACF,EAAA,MAAAE;EAAAF,EAAA,MAAAc;EAAAd,EAAA,MAAAe;CAAA,OAAAA,KAAAf,EAAA;CAAA,OAbMhB,UAAU+B,EAahB;AAAC"}
1
+ {"version":3,"file":"theme-scope.js","names":["c","_c","stylex","useCallback","useState","UNSAFE_PortalProvider","PortalProvider","RenderComponentProps","useRender","mergeStyles","pinnedScheme","colorDefaultsDarkTheme","colorDefaultsLightTheme","tokenScope","styles","root","kB7OPa","$$css","schemes","dark","light","ThemeScopeProps","scheme","ThemeScope","t0","$","children","render","props","container","setContainer","t1","getContainer","t2","t3","undefined","t4","t5","t6","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, useState } from 'react';\nimport { UNSAFE_PortalProvider as PortalProvider } from 'react-aria/PortalProvider';\nimport type { RenderComponentProps } from './render/useRender';\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 the scope's own last child,\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// `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\n/**\n * Themes what is inside it, overlays included.\n *\n * A `--kui-*` override declared on the scope — through `className` or\n * `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 * // .accent { --kui-color-primary: #7d5260; }\n * <ThemeScope className=\"accent\" scheme=\"dark\">\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>`, or the `<body>` itself.\n */\nfunction ThemeScope({\n children,\n render,\n scheme,\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 return useRender({\n defaultTagName: 'div',\n props: {\n ...props,\n ...mergeStyles(stylex.props(styles.root, tokenScope, scheme !== undefined && schemes[scheme], scheme !== undefined && pinnedScheme[scheme]), props),\n children: <>\n <PortalProvider getContainer={getContainer}>\n {children}\n </PortalProvider>\n <div className=\"x9f619 xjp7ctv\" ref={setContainer} />\n </>\n },\n render\n });\n}\nexport type { ThemeScopeProps };\nexport { ThemeScope };"],"mappings":";;;;;;;;;;;AA8BA,MAAMc,SAAS,EACbC,MAAM;CACJC,QAAQ;CACRC,OAAO;AACT,EACF;AACA,MAAMC,UAAU;CACdC,MAAMR;CACNS,OAAOR;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAAW,WAAAC,IAAA;CAAA,MAAAC,IAAAxB,EAAA,EAAA;CAAoB,MAAA,EAAAyB,UAAAC,QAAAL,QAAA,G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,OAAAA,KAAAd,EAAA;CAAA,IAAAe;CAAA,IAAAf,EAAA,QAAAE,UAAAF,EAAA,QAAAc,IAAA;EAXcC,KAAA;GAAAC,gBACCR;GAAKL,OACdW;GASNZ;EAEH;EAACF,EAAA,MAAAE;EAAAF,EAAA,MAAAc;EAAAd,EAAA,MAAAe;CAAA,OAAAA,KAAAf,EAAA;CAAA,OAbMjB,UAAUgC,EAahB;AAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanso-labs/kanso-ui",
3
- "version": "0.40.9",
3
+ "version": "0.41.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",