@namroodinc/liquid-editorial 0.11.0 → 0.12.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 +32 -18
- package/UPGRADING.md +252 -0
- package/dist/chunks/{Board-Cnyqrc-R.js → Board-BCS7sDXg.js} +13 -5
- package/dist/chunks/{Board-Cnyqrc-R.js.map → Board-BCS7sDXg.js.map} +1 -1
- package/dist/chunks/{Board-DFuJt2Oh.cjs → Board-CNVy8gHI.cjs} +2 -2
- package/dist/chunks/Board-CNVy8gHI.cjs.map +1 -0
- package/dist/chunks/{CollectionView-Vj84E26b.js → CollectionView-B0ZJxkNK.js} +4 -4
- package/dist/chunks/CollectionView-B0ZJxkNK.js.map +1 -0
- package/dist/chunks/CollectionView-DrszOUOt.cjs +2 -0
- package/dist/chunks/CollectionView-DrszOUOt.cjs.map +1 -0
- package/dist/chunks/ColourField-BdobU76j.cjs +2 -0
- package/dist/chunks/ColourField-BdobU76j.cjs.map +1 -0
- package/dist/chunks/{ColourField-DkO8tjeB.js → ColourField-C39pcjkG.js} +2 -2
- package/dist/chunks/ColourField-C39pcjkG.js.map +1 -0
- package/dist/chunks/{DatePicker-B8tllGYy.js → DatePicker-DDc1nDTb.js} +2 -2
- package/dist/chunks/DatePicker-DDc1nDTb.js.map +1 -0
- package/dist/chunks/DatePicker-Dpvfomrm.cjs +2 -0
- package/dist/chunks/DatePicker-Dpvfomrm.cjs.map +1 -0
- package/dist/chunks/{Drawer-DTtgAZO2.js → Drawer-C3mWT9Kh.js} +2 -2
- package/dist/chunks/Drawer-C3mWT9Kh.js.map +1 -0
- package/dist/chunks/Drawer-DTKZptua.cjs +2 -0
- package/dist/chunks/Drawer-DTKZptua.cjs.map +1 -0
- package/dist/chunks/EntryPicker-CgWbgWnc.cjs +2 -0
- package/dist/chunks/EntryPicker-CgWbgWnc.cjs.map +1 -0
- package/dist/chunks/{EntryPicker-KxHZzZsh.js → EntryPicker-DlEsVCvA.js} +3 -3
- package/dist/chunks/EntryPicker-DlEsVCvA.js.map +1 -0
- package/dist/chunks/{FormEditor-CdLqPaKK.js → FormEditor-CLLOHKiO.js} +6 -6
- package/dist/chunks/{FormEditor-CdLqPaKK.js.map → FormEditor-CLLOHKiO.js.map} +1 -1
- package/dist/chunks/{FormEditor-BJcAIVcL.cjs → FormEditor-iACd0El-.cjs} +2 -2
- package/dist/chunks/{FormEditor-BJcAIVcL.cjs.map → FormEditor-iACd0El-.cjs.map} +1 -1
- package/dist/chunks/{RichTextEditor-DmNM63Wg.js → RichTextEditor-B0P53GFt.js} +9 -9
- package/dist/chunks/RichTextEditor-B0P53GFt.js.map +1 -0
- package/dist/chunks/RichTextEditor-Wu_yjvD7.cjs +2 -0
- package/dist/chunks/RichTextEditor-Wu_yjvD7.cjs.map +1 -0
- package/dist/chunks/{use-picker-session-BDEWL2jK.js → use-picker-session-BnMxbGAZ.js} +3 -3
- package/dist/chunks/use-picker-session-BnMxbGAZ.js.map +1 -0
- package/dist/chunks/use-picker-session-DbfOJstX.cjs +2 -0
- package/dist/chunks/use-picker-session-DbfOJstX.cjs.map +1 -0
- package/dist/components/AppShell/index.cjs +1 -1
- package/dist/components/AppShell/index.js +1 -1
- package/dist/components/AssetCard/index.cjs +1 -1
- package/dist/components/AssetCard/index.cjs.map +1 -1
- package/dist/components/AssetCard/index.d.cts.map +1 -1
- package/dist/components/AssetCard/index.d.ts.map +1 -1
- package/dist/components/AssetCard/index.js +16 -16
- package/dist/components/AssetCard/index.js.map +1 -1
- package/dist/components/AssetCard/style.css +47 -46
- package/dist/components/AssetGrid/index.cjs +1 -1
- package/dist/components/AssetGrid/index.cjs.map +1 -1
- package/dist/components/AssetGrid/index.d.cts +0 -2
- package/dist/components/AssetGrid/index.d.cts.map +1 -1
- package/dist/components/AssetGrid/index.d.ts +0 -2
- package/dist/components/AssetGrid/index.d.ts.map +1 -1
- package/dist/components/AssetGrid/index.js +15 -15
- package/dist/components/AssetGrid/index.js.map +1 -1
- package/dist/components/Avatar/style.css +26 -5
- package/dist/components/Badge/index.cjs +1 -1
- package/dist/components/Badge/index.cjs.map +1 -1
- package/dist/components/Badge/index.d.cts +2 -3
- package/dist/components/Badge/index.d.cts.map +1 -1
- package/dist/components/Badge/index.d.ts +2 -3
- package/dist/components/Badge/index.d.ts.map +1 -1
- package/dist/components/Badge/index.js +1 -1
- package/dist/components/Badge/index.js.map +1 -1
- package/dist/components/Badge/style.css +20 -26
- package/dist/components/Board/index.cjs +1 -1
- package/dist/components/Board/index.js +1 -1
- package/dist/components/Board/style.css +36 -15
- package/dist/components/Button/style.css +19 -10
- package/dist/components/ButtonGroup/index.cjs.map +1 -1
- package/dist/components/ButtonGroup/index.d.cts +1 -1
- package/dist/components/ButtonGroup/index.d.ts +1 -1
- package/dist/components/ButtonGroup/index.js.map +1 -1
- package/dist/components/ButtonGroup/style.css +4 -20
- package/dist/components/Choice/style.css +10 -9
- package/dist/components/CollectionView/index.cjs +1 -1
- package/dist/components/CollectionView/index.js +1 -1
- package/dist/components/CollectionView/style.css +8 -11
- package/dist/components/ColourField/index.cjs +1 -1
- package/dist/components/ColourField/index.js +1 -1
- package/dist/components/ColourField/style.css +28 -17
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/DatePicker/style.css +10 -3
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.js +1 -1
- package/dist/components/Drawer/style.css +11 -22
- package/dist/components/EditLayout/index.cjs +1 -1
- package/dist/components/EditLayout/index.cjs.map +1 -1
- package/dist/components/EditLayout/index.js +2 -2
- package/dist/components/EditLayout/index.js.map +1 -1
- package/dist/components/EditLayout/style.css +10 -5
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.js +1 -1
- package/dist/components/EntryPicker/style.css +43 -19
- package/dist/components/Field/style.css +6 -5
- package/dist/components/FormEditor/README.md +21 -5
- package/dist/components/FormEditor/index.cjs +1 -1
- package/dist/components/FormEditor/index.js +1 -1
- package/dist/components/ImageCropper/style.css +20 -20
- package/dist/components/Menu/style.css +2 -3
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.cjs.map +1 -1
- package/dist/components/Modal/index.js +1 -1
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/Modal/style.css +7 -5
- package/dist/components/Popover/style.css +2 -2
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.js +1 -1
- package/dist/components/RichTextEditor/style.css +59 -42
- package/dist/components/SelectionCard/index.cjs +1 -1
- package/dist/components/SelectionCard/index.cjs.map +1 -1
- package/dist/components/SelectionCard/index.d.cts.map +1 -1
- package/dist/components/SelectionCard/index.d.ts.map +1 -1
- package/dist/components/SelectionCard/index.js +5 -1
- package/dist/components/SelectionCard/index.js.map +1 -1
- package/dist/components/SelectionCard/style.css +39 -12
- package/dist/components/SideNav/index.cjs +1 -1
- package/dist/components/SideNav/index.cjs.map +1 -1
- package/dist/components/SideNav/index.d.cts +3 -3
- package/dist/components/SideNav/index.d.ts +3 -3
- package/dist/components/SideNav/index.js +15 -3
- package/dist/components/SideNav/index.js.map +1 -1
- package/dist/components/SideNav/style.css +19 -13
- package/dist/components/Slider/style.css +12 -14
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.cjs.map +1 -1
- package/dist/components/SortableList/index.js +6 -2
- package/dist/components/SortableList/index.js.map +1 -1
- package/dist/components/SortableList/style.css +20 -5
- package/dist/components/Stepper/style.css +8 -9
- package/dist/components/SubNav/index.cjs.map +1 -1
- package/dist/components/SubNav/index.d.cts +2 -2
- package/dist/components/SubNav/index.d.ts +2 -2
- package/dist/components/SubNav/index.js.map +1 -1
- package/dist/components/SubNav/style.css +3 -8
- package/dist/components/Switch/index.cjs +1 -1
- package/dist/components/Switch/index.cjs.map +1 -1
- package/dist/components/Switch/index.d.cts.map +1 -1
- package/dist/components/Switch/index.d.ts.map +1 -1
- package/dist/components/Switch/index.js +2 -2
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Switch/style.css +14 -6
- package/dist/components/Table/index.cjs +1 -1
- package/dist/components/Table/index.cjs.map +1 -1
- package/dist/components/Table/index.js +2 -2
- package/dist/components/Table/index.js.map +1 -1
- package/dist/components/Table/style.css +34 -22
- package/dist/components/TagsInput/index.cjs +1 -1
- package/dist/components/TagsInput/index.cjs.map +1 -1
- package/dist/components/TagsInput/index.js +1 -1
- package/dist/components/TagsInput/index.js.map +1 -1
- package/dist/components/TagsInput/style.css +31 -6
- package/dist/components/Time/style.css +1 -1
- package/dist/components/Toast/style.css +1 -1
- package/dist/components/TopNav/index.cjs +1 -1
- package/dist/components/TopNav/index.cjs.map +1 -1
- package/dist/components/TopNav/index.d.cts +4 -4
- package/dist/components/TopNav/index.d.ts +4 -4
- package/dist/components/TopNav/index.js +5 -1
- package/dist/components/TopNav/index.js.map +1 -1
- package/dist/components/TopNav/style.css +6 -9
- package/dist/elements.css +0 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +44 -44
- package/dist/message.css +8 -14
- package/dist/tokens.css +101 -43
- package/package.json +1 -1
- package/dist/chunks/Board-DFuJt2Oh.cjs.map +0 -1
- package/dist/chunks/CollectionView-BNYx29b1.cjs +0 -2
- package/dist/chunks/CollectionView-BNYx29b1.cjs.map +0 -1
- package/dist/chunks/CollectionView-Vj84E26b.js.map +0 -1
- package/dist/chunks/ColourField--rS9KDpq.cjs +0 -2
- package/dist/chunks/ColourField--rS9KDpq.cjs.map +0 -1
- package/dist/chunks/ColourField-DkO8tjeB.js.map +0 -1
- package/dist/chunks/DatePicker-B8tllGYy.js.map +0 -1
- package/dist/chunks/DatePicker-OiqjoO-f.cjs +0 -2
- package/dist/chunks/DatePicker-OiqjoO-f.cjs.map +0 -1
- package/dist/chunks/Drawer-BDX9_qHA.cjs +0 -2
- package/dist/chunks/Drawer-BDX9_qHA.cjs.map +0 -1
- package/dist/chunks/Drawer-DTtgAZO2.js.map +0 -1
- package/dist/chunks/EntryPicker-BI_7g2Wg.cjs +0 -2
- package/dist/chunks/EntryPicker-BI_7g2Wg.cjs.map +0 -1
- package/dist/chunks/EntryPicker-KxHZzZsh.js.map +0 -1
- package/dist/chunks/RichTextEditor-BXyhSeJd.cjs +0 -2
- package/dist/chunks/RichTextEditor-BXyhSeJd.cjs.map +0 -1
- package/dist/chunks/RichTextEditor-DmNM63Wg.js.map +0 -1
- package/dist/chunks/use-picker-session-BDEWL2jK.js.map +0 -1
- package/dist/chunks/use-picker-session-C4FGinLN.cjs +0 -2
- package/dist/chunks/use-picker-session-C4FGinLN.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Icon","SubNav","forwardRef","rest","label","className","actions","SubNavItem","isActive","icon","count","Badge","SubNavButton","Button","disabled"],"sources":["../../../src/components/SubNav/index.tsx"],"sourcesContent":["import {\n forwardRef,\n type AnchorHTMLAttributes,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { Icon } from \"../Icon\";\nimport { Button } from \"../Button\";\nimport { Badge } from \"../Badge\";\nimport type { IconName } from \"../Icon/icons\";\nimport \"./style.css\";\n\nexport interface SubNavProps extends HTMLAttributes<HTMLElement> {\n /** Accessible name — say what the set switches, e.g. \"Article sections\". */\n label: string;\n /** Controls parked at the end of the row, e.g. a view switch. */\n actions?: ReactNode;\n children?: ReactNode;\n}\n\n/**\n * The second level: views inside one page — Content, Settings, Revisions.
|
|
1
|
+
{"version":3,"file":"index.js","names":["Icon","SubNav","forwardRef","rest","label","className","actions","SubNavItem","isActive","icon","count","Badge","SubNavButton","Button","disabled"],"sources":["../../../src/components/SubNav/index.tsx"],"sourcesContent":["import {\n forwardRef,\n type AnchorHTMLAttributes,\n type ButtonHTMLAttributes,\n type HTMLAttributes,\n type ReactNode,\n} from \"react\";\nimport { Icon } from \"../Icon\";\nimport { Button } from \"../Button\";\nimport { Badge } from \"../Badge\";\nimport type { IconName } from \"../Icon/icons\";\nimport \"./style.css\";\n\nexport interface SubNavProps extends HTMLAttributes<HTMLElement> {\n /** Accessible name — say what the set switches, e.g. \"Article sections\". */\n label: string;\n /** Controls parked at the end of the row, e.g. a view switch. */\n actions?: ReactNode;\n children?: ReactNode;\n}\n\n/**\n * The second level: views inside one page — Content, Settings, Revisions. The\n * active item uses stronger text without a rule or selection rail.\n */\nexport const SubNav = forwardRef<HTMLElement, SubNavProps>(function SubNav(\n { label, actions, className, children, ...rest },\n ref,\n) {\n return (\n <nav\n ref={ref}\n aria-label={label}\n className={[\"ds-subnav\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n <ul className=\"ds-subnav__list\">{children}</ul>\n {actions && <div className=\"ds-subnav__actions\">{actions}</div>}\n </nav>\n );\n});\n\ninterface SubNavItemBase {\n label: string;\n icon?: IconName;\n isActive?: boolean;\n /** A count beside the label — kept quiet, never a status colour. */\n count?: number;\n}\n\nexport interface SubNavItemProps\n extends SubNavItemBase, Omit<AnchorHTMLAttributes<HTMLAnchorElement>, \"children\"> {}\n\n/** One view, as a link. Use `SubNavButton` when the view is client state. */\nexport const SubNavItem = forwardRef<HTMLAnchorElement, SubNavItemProps>(function SubNavItem(\n { label, icon, isActive, count, className, ...rest },\n ref,\n) {\n return (\n <li className=\"ds-subnav__row\">\n <a\n ref={ref}\n className={[\"ds-subnav__item\", className].filter(Boolean).join(\" \")}\n data-active={isActive || undefined}\n aria-current={isActive ? \"page\" : undefined}\n {...rest}\n >\n {icon && <Icon name={icon} />}\n {label}\n {count !== undefined && (\n <Badge\n className=\"ds-subnav__count\"\n shape=\"count\"\n size=\"sm\"\n appearance=\"soft\"\n isCountExact\n >\n {count}\n </Badge>\n )}\n </a>\n </li>\n );\n});\n\nexport interface SubNavButtonProps\n extends SubNavItemBase, Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"children\" | \"type\"> {}\n\n/** One view, as a control — for panes switched in place rather than routed. */\nexport const SubNavButton = forwardRef<HTMLButtonElement, SubNavButtonProps>(function SubNavButton(\n { label, icon, isActive, count, disabled, className, ...rest },\n ref,\n) {\n return (\n <li className=\"ds-subnav__row\">\n <Button\n ref={ref}\n variant=\"simple\"\n iconStart={icon}\n isDisabled={disabled}\n className={[\"ds-subnav__item\", className].filter(Boolean).join(\" \")}\n data-active={isActive || undefined}\n aria-pressed={isActive}\n {...rest}\n >\n {label}\n {count !== undefined && (\n <Badge\n className=\"ds-subnav__count\"\n shape=\"count\"\n size=\"sm\"\n appearance=\"soft\"\n isCountExact\n >\n {count}\n </Badge>\n )}\n </Button>\n </li>\n );\n});\n"],"mappings":";;;;;;AAyBA,IAAaC,IAASC,EAAqC,SACzD,EAAE,UAAO,YAAS,cAAW,aAAU,GAAGC,KAC1C,GACA;CACA,OACE,kBAAC,OAAD;EACO;EACL,cAAYC;EACZ,WAAW,CAAC,aAAaC,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;EAC5D,GAAIF;EAJN,UAAA,CAME,kBAAC,MAAD;GAAI,WAAU;GAAmB;EAAa,CAAA,GAC7CG,KAAW,kBAAC,OAAD;GAAK,WAAU;GAAsB,UAAAA;EAAa,CAAA,CAC3D;;AAET,CAAC,GAcYC,IAAaL,EAA+C,SACvE,EAAE,UAAO,SAAM,aAAU,UAAO,cAAW,GAAGC,KAC9C,GACA;CACA,OACE,kBAAC,MAAD;EAAI,WAAU;EACZ,UAAA,kBAAC,KAAD;GACO;GACL,WAAW,CAAC,mBAAmBE,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;GAClE,eAAaG,KAAY,KAAA;GACzB,gBAAcA,IAAW,SAAS,KAAA;GAClC,GAAIL;GALN,UAAA;IAOGM,KAAQ,kBAACT,GAAD,EAAM,MAAMS,EAAO,CAAA;IAC3BL;IACAM,MAAU,KAAA,KACT,kBAACC,GAAD;KACE,WAAU;KACV,OAAM;KACN,MAAK;KACL,YAAW;KACX,cAAA;KAEC,UAAAD;IACI,CAAA;GAER;;CACD,CAAA;AAER,CAAC,GAMYE,IAAeV,EAAiD,SAC3E,EAAE,UAAO,SAAM,aAAU,UAAO,aAAU,cAAW,GAAGC,KACxD,GACA;CACA,OACE,kBAAC,MAAD;EAAI,WAAU;EACZ,UAAA,kBAACU,GAAD;GACO;GACL,SAAQ;GACR,WAAWJ;GACX,YAAYK;GACZ,WAAW,CAAC,mBAAmBT,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;GAClE,eAAaG,KAAY,KAAA;GACzB,gBAAcA;GACd,GAAIL;GARN,UAAA,CAUGC,GACAM,MAAU,KAAA,KACT,kBAACC,GAAD;IACE,WAAU;IACV,OAAM;IACN,MAAK;IACL,YAAW;IACX,cAAA;IAEC,UAAAD;GACI,CAAA,CAEH;;CACN,CAAA;AAER,CAAC"}
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
align-items: stretch;
|
|
5
5
|
gap: var(--space-4);
|
|
6
6
|
min-block-size: var(--subnav-height);
|
|
7
|
-
border-block-end: var(--rule-width) solid var(--rule-color);
|
|
8
7
|
}
|
|
9
8
|
|
|
10
9
|
.ds-subnav__list {
|
|
@@ -36,13 +35,10 @@
|
|
|
36
35
|
text-decoration: none;
|
|
37
36
|
white-space: nowrap;
|
|
38
37
|
cursor: pointer;
|
|
39
|
-
|
|
40
|
-
transition:
|
|
41
|
-
color var(--duration-fast) var(--ease-standard),
|
|
42
|
-
box-shadow var(--duration-fast) var(--ease-standard);
|
|
38
|
+
transition: color var(--duration-fast) var(--ease-standard);
|
|
43
39
|
}
|
|
44
40
|
|
|
45
|
-
/* SubNavButton
|
|
41
|
+
/* SubNavButton shares the same navigation layout as links. */
|
|
46
42
|
.ds-subnav__item.ds-button {
|
|
47
43
|
height: auto;
|
|
48
44
|
padding: 0 var(--space-3);
|
|
@@ -60,14 +56,13 @@
|
|
|
60
56
|
}
|
|
61
57
|
|
|
62
58
|
.ds-subnav__item:focus-visible {
|
|
63
|
-
outline: var(--
|
|
59
|
+
outline: var(--focus-width) solid var(--color-focus);
|
|
64
60
|
outline-offset: -2px;
|
|
65
61
|
}
|
|
66
62
|
|
|
67
63
|
.ds-subnav__item[data-active] {
|
|
68
64
|
color: var(--color-text);
|
|
69
65
|
font-weight: var(--font-weight-bold);
|
|
70
|
-
box-shadow: inset 0 calc(-1 * var(--rail-width)) 0 0 var(--rail-color);
|
|
71
66
|
}
|
|
72
67
|
|
|
73
68
|
.ds-subnav__actions {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Button/index.cjs");let t=require("react"),n=require("react/jsx-runtime");function r(...e){return e.filter(Boolean).join(` `)}var i=(0,t.forwardRef)(function({isSelected:i,defaultSelected:a=!1,onSelectedChange:o,isDisabled:s=!1,required:c,className:l,children:u,onClick:d,...f},p){let[m,h]=(0,t.useState)(a),g=i??m
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Button/index.cjs");let t=require("react"),n=require("react/jsx-runtime");function r(...e){return e.filter(Boolean).join(` `)}var i=(0,t.forwardRef)(function({isSelected:i,defaultSelected:a=!1,onSelectedChange:o,isDisabled:s=!1,required:c,className:l,children:u,onClick:d,...f},p){let[m,h]=(0,t.useState)(a),g=i??m,_=f[`aria-invalid`]===!0||f[`aria-invalid`]===`true`;return(0,n.jsxs)(`label`,{className:r(`ds-switch`,l),children:[(0,n.jsx)(e.Button,{ref:p,variant:_?`danger`:g?`primary`:`neutral`,size:`sm`,role:`switch`,"aria-checked":g,"aria-required":c||void 0,isDisabled:s,className:`ds-switch__track`,onClick:e=>{if(d?.(e),e.defaultPrevented)return;let t=!g;i===void 0&&h(t),o?.(t)},...f,children:(0,n.jsx)(`span`,{className:`ds-switch__knob`,"aria-hidden":`true`})}),u&&(0,n.jsx)(`span`,{className:`ds-switch__label`,children:u})]})});exports.Switch=i;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["forwardRef","useState","Button","require_components_Button_index","react","react_jsx_runtime","cx","parts","Switch","rest","internal","setInternal","defaultSelected","current","isSelected","className","required","onClick","event","next","onSelectedChange","children"],"sources":["../../../src/components/Switch/index.tsx"],"sourcesContent":["import { forwardRef, useState, type ButtonHTMLAttributes, type ReactNode } from \"react\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface SwitchProps extends Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n \"onChange\" | \"value\" | \"disabled\"\n> {\n /** Required state when bound to Field. */\n required?: boolean;\n isSelected?: boolean;\n defaultSelected?: boolean;\n onSelectedChange?: (isSelected: boolean) => void;\n isDisabled?: boolean;\n /** Label to the right of the track. Omit it and pass `aria-label`. */\n children?: ReactNode;\n}\n\n/** An immediate on/off — it commits as it is pressed, no Save behind it. */\nexport const Switch = forwardRef<HTMLButtonElement, SwitchProps>(function Switch(\n {\n isSelected,\n defaultSelected = false,\n onSelectedChange,\n isDisabled = false,\n required,\n className,\n children,\n onClick,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState(defaultSelected);\n const current = isSelected ?? internal;\n\n return (\n <label className={cx(\"ds-switch\", className)}>\n <Button\n ref={ref}\n variant={current ? \"primary\" : \"neutral\"}\n size=\"sm\"\n role=\"switch\"\n aria-checked={current}\n aria-required={required || undefined}\n isDisabled={isDisabled}\n className=\"ds-switch__track\"\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) {\n return;\n }\n const next = !current;\n if (isSelected === undefined) {\n setInternal(next);\n }\n onSelectedChange?.(next);\n }}\n {...rest}\n >\n <span\n className=\"ds-switch__knob\"\n aria-hidden=\"true\"\n />\n </Button>\n {children && <span className=\"ds-switch__label\">{children}</span>}\n </label>\n );\n});\n"],"mappings":"A,gKAIA,SAASM,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAiBA,IAAaC,GAAA,EAASR,EAAAA,WAAAA,CAA2C,SAC/D,CACE,aACA,kBAAkB,GAClB,mBACA,aAAa,GACb,WACA,YACA,WACA,UACA,GAAGS,GAEL,EACA,CACA,GAAM,CAACC,EAAUC,IAAA,EAAeV,EAAAA,SAAAA,CAASW,CAAe,EAClDC,EAAUC,GAAcJ,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["forwardRef","useState","Button","require_components_Button_index","react","react_jsx_runtime","cx","parts","Switch","rest","internal","setInternal","defaultSelected","current","isSelected","invalid","className","required","onClick","event","next","onSelectedChange","children"],"sources":["../../../src/components/Switch/index.tsx"],"sourcesContent":["import { forwardRef, useState, type ButtonHTMLAttributes, type ReactNode } from \"react\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface SwitchProps extends Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n \"onChange\" | \"value\" | \"disabled\"\n> {\n /** Required state when bound to Field. */\n required?: boolean;\n isSelected?: boolean;\n defaultSelected?: boolean;\n onSelectedChange?: (isSelected: boolean) => void;\n isDisabled?: boolean;\n /** Label to the right of the track. Omit it and pass `aria-label`. */\n children?: ReactNode;\n}\n\n/** An immediate on/off — it commits as it is pressed, no Save behind it. */\nexport const Switch = forwardRef<HTMLButtonElement, SwitchProps>(function Switch(\n {\n isSelected,\n defaultSelected = false,\n onSelectedChange,\n isDisabled = false,\n required,\n className,\n children,\n onClick,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState(defaultSelected);\n const current = isSelected ?? internal;\n const invalid = rest[\"aria-invalid\"] === true || rest[\"aria-invalid\"] === \"true\";\n\n return (\n <label className={cx(\"ds-switch\", className)}>\n <Button\n ref={ref}\n variant={invalid ? \"danger\" : current ? \"primary\" : \"neutral\"}\n size=\"sm\"\n role=\"switch\"\n aria-checked={current}\n aria-required={required || undefined}\n isDisabled={isDisabled}\n className=\"ds-switch__track\"\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) {\n return;\n }\n const next = !current;\n if (isSelected === undefined) {\n setInternal(next);\n }\n onSelectedChange?.(next);\n }}\n {...rest}\n >\n <span\n className=\"ds-switch__knob\"\n aria-hidden=\"true\"\n />\n </Button>\n {children && <span className=\"ds-switch__label\">{children}</span>}\n </label>\n );\n});\n"],"mappings":"A,gKAIA,SAASM,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAiBA,IAAaC,GAAA,EAASR,EAAAA,WAAAA,CAA2C,SAC/D,CACE,aACA,kBAAkB,GAClB,mBACA,aAAa,GACb,WACA,YACA,WACA,UACA,GAAGS,GAEL,EACA,CACA,GAAM,CAACC,EAAUC,IAAA,EAAeV,EAAAA,SAAAA,CAASW,CAAe,EAClDC,EAAUC,GAAcJ,EACxBK,EAAUN,EAAK,kBAAoB,IAAQA,EAAK,kBAAoB,OAE1E,OACE,EAAAJ,EAAA,KAAA,CAAC,QAAD,CAAO,UAAWC,EAAG,YAAaU,CAAS,EAA3C,SAAA,EACE,EAAAX,EAAA,IAAA,CAACH,EAAAA,OAAD,CACO,MACL,QAASa,EAAU,SAAWF,EAAU,UAAY,UACpD,KAAK,KACL,KAAK,SACL,eAAcA,EACd,gBAAeI,GAAY,IAAA,GACf,aACZ,UAAU,mBACV,QAAU,GAAU,CAElB,GADAC,IAAUC,CAAK,EACXA,EAAM,iBACR,OAEF,IAAMC,EAAO,CAACP,EACVC,IAAe,IAAA,IACjBH,EAAYS,CAAI,EAElBC,IAAmBD,CAAI,CACzB,EACA,GAAIX,EAEJ,UAAA,EAAAJ,EAAA,IAAA,CAAC,OAAD,CACE,UAAU,kBACV,cAAY,MACb,CAAA,CACK,CAAA,EACPiB,IAAY,EAAAjB,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,mBAAoB,UAAe,CAAA,CAC3D,C,EAEX,CAAC,E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Switch/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,oBAAoB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAExF,OAAO,aAAa,CAAC;AAMrB,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,UAAU,GAAG,OAAO,GAAG,UAAU,CAClC;IACC,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,4EAA4E;AAC5E,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/Switch/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,oBAAoB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAExF,OAAO,aAAa,CAAC;AAMrB,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,UAAU,GAAG,OAAO,GAAG,UAAU,CAClC;IACC,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,4EAA4E;AAC5E,eAAO,MAAM,MAAM,2GAkDjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Switch/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,oBAAoB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAExF,OAAO,aAAa,CAAC;AAMrB,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,UAAU,GAAG,OAAO,GAAG,UAAU,CAClC;IACC,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,4EAA4E;AAC5E,eAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Switch/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,oBAAoB,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAExF,OAAO,aAAa,CAAC;AAMrB,MAAM,WAAW,WAAY,SAAQ,IAAI,CACvC,oBAAoB,CAAC,iBAAiB,CAAC,EACvC,UAAU,GAAG,OAAO,GAAG,UAAU,CAClC;IACC,0CAA0C;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,4EAA4E;AAC5E,eAAO,MAAM,MAAM,2GAkDjB,CAAC"}
|
|
@@ -6,12 +6,12 @@ function a(...e) {
|
|
|
6
6
|
return e.filter(Boolean).join(" ");
|
|
7
7
|
}
|
|
8
8
|
var o = t(function({ isSelected: t, defaultSelected: o = !1, onSelectedChange: s, isDisabled: c = !1, required: l, className: u, children: d, onClick: f, ...p }, m) {
|
|
9
|
-
let [h, g] = n(o), _ = t ?? h;
|
|
9
|
+
let [h, g] = n(o), _ = t ?? h, v = p["aria-invalid"] === !0 || p["aria-invalid"] === "true";
|
|
10
10
|
return /* @__PURE__ */ i("label", {
|
|
11
11
|
className: a("ds-switch", u),
|
|
12
12
|
children: [/* @__PURE__ */ r(e, {
|
|
13
13
|
ref: m,
|
|
14
|
-
variant: _ ? "primary" : "neutral",
|
|
14
|
+
variant: v ? "danger" : _ ? "primary" : "neutral",
|
|
15
15
|
size: "sm",
|
|
16
16
|
role: "switch",
|
|
17
17
|
"aria-checked": _,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["cx","parts","Switch","forwardRef","rest","internal","setInternal","useState","defaultSelected","current","isSelected","className","Button","required","onClick","event","next","onSelectedChange","children"],"sources":["../../../src/components/Switch/index.tsx"],"sourcesContent":["import { forwardRef, useState, type ButtonHTMLAttributes, type ReactNode } from \"react\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface SwitchProps extends Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n \"onChange\" | \"value\" | \"disabled\"\n> {\n /** Required state when bound to Field. */\n required?: boolean;\n isSelected?: boolean;\n defaultSelected?: boolean;\n onSelectedChange?: (isSelected: boolean) => void;\n isDisabled?: boolean;\n /** Label to the right of the track. Omit it and pass `aria-label`. */\n children?: ReactNode;\n}\n\n/** An immediate on/off — it commits as it is pressed, no Save behind it. */\nexport const Switch = forwardRef<HTMLButtonElement, SwitchProps>(function Switch(\n {\n isSelected,\n defaultSelected = false,\n onSelectedChange,\n isDisabled = false,\n required,\n className,\n children,\n onClick,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState(defaultSelected);\n const current = isSelected ?? internal;\n\n return (\n <label className={cx(\"ds-switch\", className)}>\n <Button\n ref={ref}\n variant={current ? \"primary\" : \"neutral\"}\n size=\"sm\"\n role=\"switch\"\n aria-checked={current}\n aria-required={required || undefined}\n isDisabled={isDisabled}\n className=\"ds-switch__track\"\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) {\n return;\n }\n const next = !current;\n if (isSelected === undefined) {\n setInternal(next);\n }\n onSelectedChange?.(next);\n }}\n {...rest}\n >\n <span\n className=\"ds-switch__knob\"\n aria-hidden=\"true\"\n />\n </Button>\n {children && <span className=\"ds-switch__label\">{children}</span>}\n </label>\n );\n});\n"],"mappings":";;;;AAIA,SAASA,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAiBA,IAAaC,IAASC,EAA2C,SAC/D,EACE,eACA,qBAAkB,IAClB,qBACA,gBAAa,IACb,aACA,cACA,aACA,YACA,GAAGC,KAEL,GACA;CACA,IAAM,CAACC,GAAUC,KAAeC,EAASC,CAAe,GAClDC,IAAUC,KAAcL;
|
|
1
|
+
{"version":3,"file":"index.js","names":["cx","parts","Switch","forwardRef","rest","internal","setInternal","useState","defaultSelected","current","isSelected","invalid","className","Button","required","onClick","event","next","onSelectedChange","children"],"sources":["../../../src/components/Switch/index.tsx"],"sourcesContent":["import { forwardRef, useState, type ButtonHTMLAttributes, type ReactNode } from \"react\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface SwitchProps extends Omit<\n ButtonHTMLAttributes<HTMLButtonElement>,\n \"onChange\" | \"value\" | \"disabled\"\n> {\n /** Required state when bound to Field. */\n required?: boolean;\n isSelected?: boolean;\n defaultSelected?: boolean;\n onSelectedChange?: (isSelected: boolean) => void;\n isDisabled?: boolean;\n /** Label to the right of the track. Omit it and pass `aria-label`. */\n children?: ReactNode;\n}\n\n/** An immediate on/off — it commits as it is pressed, no Save behind it. */\nexport const Switch = forwardRef<HTMLButtonElement, SwitchProps>(function Switch(\n {\n isSelected,\n defaultSelected = false,\n onSelectedChange,\n isDisabled = false,\n required,\n className,\n children,\n onClick,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState(defaultSelected);\n const current = isSelected ?? internal;\n const invalid = rest[\"aria-invalid\"] === true || rest[\"aria-invalid\"] === \"true\";\n\n return (\n <label className={cx(\"ds-switch\", className)}>\n <Button\n ref={ref}\n variant={invalid ? \"danger\" : current ? \"primary\" : \"neutral\"}\n size=\"sm\"\n role=\"switch\"\n aria-checked={current}\n aria-required={required || undefined}\n isDisabled={isDisabled}\n className=\"ds-switch__track\"\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) {\n return;\n }\n const next = !current;\n if (isSelected === undefined) {\n setInternal(next);\n }\n onSelectedChange?.(next);\n }}\n {...rest}\n >\n <span\n className=\"ds-switch__knob\"\n aria-hidden=\"true\"\n />\n </Button>\n {children && <span className=\"ds-switch__label\">{children}</span>}\n </label>\n );\n});\n"],"mappings":";;;;AAIA,SAASA,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAiBA,IAAaC,IAASC,EAA2C,SAC/D,EACE,eACA,qBAAkB,IAClB,qBACA,gBAAa,IACb,aACA,cACA,aACA,YACA,GAAGC,KAEL,GACA;CACA,IAAM,CAACC,GAAUC,KAAeC,EAASC,CAAe,GAClDC,IAAUC,KAAcL,GACxBM,IAAUP,EAAK,oBAAoB,MAAQA,EAAK,oBAAoB;CAE1E,OACE,kBAAC,SAAD;EAAO,WAAWJ,EAAG,aAAaY,CAAS;EAA3C,UAAA,CACE,kBAACC,GAAD;GACO;GACL,SAASF,IAAU,WAAWF,IAAU,YAAY;GACpD,MAAK;GACL,MAAK;GACL,gBAAcA;GACd,iBAAeK,KAAY,KAAA;GACf;GACZ,WAAU;GACV,UAAU,MAAU;IAElB,IADAC,IAAUC,CAAK,GACXA,EAAM,kBACR;IAEF,IAAMC,IAAO,CAACR;IAId,AAHIC,MAAe,KAAA,KACjBJ,EAAYW,CAAI,GAElBC,IAAmBD,CAAI;GACzB;GACA,GAAIb;GAEJ,UAAA,kBAAC,QAAD;IACE,WAAU;IACV,eAAY;GACb,CAAA;EACK,CAAA,GACPe,KAAY,kBAAC,QAAD;GAAM,WAAU;GAAoB;EAAe,CAAA,CAC3D;;AAEX,CAAC"}
|
|
@@ -15,14 +15,22 @@
|
|
|
15
15
|
border-radius: var(--radius-pill);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
+
/* An off switch is an indicator. Button's neutral variant paints it, read
|
|
19
|
+
* from the indicator ladder instead of the control ladder. */
|
|
20
|
+
.ds-switch__track {
|
|
21
|
+
--fill-control: var(--fill-indicator);
|
|
22
|
+
--fill-control-hover: var(--fill-indicator-hover);
|
|
23
|
+
--fill-control-pressed: var(--fill-indicator-pressed);
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
.ds-switch__knob {
|
|
19
27
|
position: absolute;
|
|
20
28
|
inset-block-start: 50%;
|
|
21
|
-
inset-inline-start:
|
|
29
|
+
inset-inline-start: 4px;
|
|
22
30
|
inline-size: var(--switch-knob-size);
|
|
23
31
|
block-size: var(--switch-knob-size);
|
|
24
32
|
border-radius: var(--radius-pill);
|
|
25
|
-
background: var(--
|
|
33
|
+
background: var(--color-surface);
|
|
26
34
|
translate: 0 -50%;
|
|
27
35
|
transition:
|
|
28
36
|
translate var(--duration-fast) var(--ease-standard),
|
|
@@ -34,11 +42,11 @@
|
|
|
34
42
|
translate: calc(var(--switch-width) - var(--switch-knob-size) - 8px) -50%;
|
|
35
43
|
}
|
|
36
44
|
|
|
37
|
-
.ds-
|
|
38
|
-
|
|
45
|
+
.ds-switch:dir(rtl) .ds-switch__track[aria-checked="true"] .ds-switch__knob {
|
|
46
|
+
translate: calc(-1 * (var(--switch-width) - var(--switch-knob-size) - 8px)) -50%;
|
|
39
47
|
}
|
|
40
48
|
|
|
41
|
-
.ds-
|
|
42
|
-
|
|
49
|
+
.ds-switch__label {
|
|
50
|
+
font-size: var(--font-size-sm);
|
|
43
51
|
}
|
|
44
52
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-CD3oeiNA.cjs");let t=require("react"),n=require("react/jsx-runtime");function r(...e){return e.filter(Boolean).join(` `)}var i=(0,t.forwardRef)(function({className:e,children:t,...i},a){return(0,n.jsx)(`div`,{ref:a,className:r(`ds-table-frame`,`ds-field-surface`,e),...i,children:t})}),a=(0,t.forwardRef)(function({start:e,end:t,className:i,...a},o){return(0,n.jsxs)(`div`,{ref:o,className:r(`ds-table-toolbar`,i),...a,children:[(0,n.jsx)(`div`,{className:`ds-table-toolbar__group`,children:e}),(0,n.jsx)(`div`,{className:`ds-table-toolbar__group`,children:t})]})});function o(e){return t.Children.toArray(e).some(e=>(0,t.isValidElement)(e)&&(e.type!==t.Fragment||o(e.props.children)))}var s=(0,t.createContext)({emptyMessage:`No data found.`}),c=(0,t.forwardRef)(function({emptyMessage:e=`No data found.`,isEmpty:t,className:i,children:a,...o},c){return(0,n.jsx)(s.Provider,{value:{emptyMessage:e,isEmpty:t},children:(0,n.jsx)(`div`,{className:`ds-table-frame__scroll`,children:(0,n.jsx)(`table`,{...o,ref:c,className:r(`ds-table`,i),children:a})})})}),l=(0,t.forwardRef)(function({className:e,...t},r){return(0,n.jsx)(`thead`,{ref:r,className:e,...t})}),u=(0,t.forwardRef)(function({className:e,children:r,...i},a){let{emptyMessage:c,isEmpty:l}=(0,t.useContext)(s);return(0,n.jsx)(`tbody`,{ref:a,className:e,...i,children:l??!o(r)?(0,n.jsx)(d,{children:(0,n.jsx)(p,{colSpan:1e3,className:`ds-table__empty-cell`,children:(0,n.jsx)(m,{title:c,role:`status`})})}):r})}),d=(0,t.forwardRef)(function({isSelected:e=!1,isInteractive:t=!1,className:
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-CD3oeiNA.cjs");let t=require("react"),n=require("react/jsx-runtime");function r(...e){return e.filter(Boolean).join(` `)}var i=(0,t.forwardRef)(function({className:e,children:t,...i},a){return(0,n.jsx)(`div`,{ref:a,className:r(`ds-table-frame`,`ds-field-surface`,e),...i,children:t})}),a=(0,t.forwardRef)(function({start:e,end:t,className:i,...a},o){return(0,n.jsxs)(`div`,{ref:o,className:r(`ds-table-toolbar`,`ds-field-surface`,i),...a,children:[(0,n.jsx)(`div`,{className:`ds-table-toolbar__group`,children:e}),(0,n.jsx)(`div`,{className:`ds-table-toolbar__group`,children:t})]})});function o(e){return t.Children.toArray(e).some(e=>(0,t.isValidElement)(e)&&(e.type!==t.Fragment||o(e.props.children)))}var s=(0,t.createContext)({emptyMessage:`No data found.`}),c=(0,t.forwardRef)(function({emptyMessage:e=`No data found.`,isEmpty:t,className:i,children:a,...o},c){return(0,n.jsx)(s.Provider,{value:{emptyMessage:e,isEmpty:t},children:(0,n.jsx)(`div`,{className:`ds-table-frame__scroll`,children:(0,n.jsx)(`table`,{...o,ref:c,className:r(`ds-table`,i),children:a})})})}),l=(0,t.forwardRef)(function({className:e,...t},r){return(0,n.jsx)(`thead`,{ref:r,className:e,...t})}),u=(0,t.forwardRef)(function({className:e,children:r,...i},a){let{emptyMessage:c,isEmpty:l}=(0,t.useContext)(s);return(0,n.jsx)(`tbody`,{ref:a,className:e,...i,children:l??!o(r)?(0,n.jsx)(d,{children:(0,n.jsx)(p,{colSpan:1e3,className:`ds-table__empty-cell`,children:(0,n.jsx)(m,{title:c,role:`status`})})}):r})}),d=(0,t.forwardRef)(function({isSelected:e=!1,isInteractive:t=!1,className:i,...a},o){return(0,n.jsx)(`tr`,{ref:o,"data-selected":e||void 0,"data-interactive":t||void 0,tabIndex:t?0:void 0,className:r(`ds-field-surface`,i),...a})}),f=(0,t.forwardRef)(function({align:e=`start`,width:t=`auto`,className:r,...i},a){return(0,n.jsx)(`th`,{ref:a,scope:`col`,"data-align":e,"data-width":t,className:r,...i})}),p=(0,t.forwardRef)(function({align:e=`start`,width:t=`auto`,emphasis:r=`default`,className:i,...a},o){return(0,n.jsx)(`td`,{ref:o,"data-align":e,"data-width":t,"data-emphasis":r==="default"?void 0:r,className:i,...a})}),m=(0,t.forwardRef)(function({icon:t=`info`,title:i=`No data found.`,description:a,action:o,className:s,...c},l){return(0,n.jsxs)(`div`,{ref:l,className:r(`ds-table-empty`,s),...c,children:[(0,n.jsx)(e.t,{name:t,size:24}),(0,n.jsx)(`span`,{style:{color:`var(--color-text)`,fontWeight:`var(--font-weight-bold)`},children:i}),a&&(0,n.jsx)(`span`,{children:a}),o]})});exports.Table=c,exports.TableBody=u,exports.TableCell=p,exports.TableEmpty=m,exports.TableFrame=i,exports.TableHead=l,exports.TableHeaderCell=f,exports.TableRow=d,exports.TableToolbar=a;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["forwardRef","Children","isValidElement","Fragment","createContext","useContext","Icon","require_Icon","react","react_jsx_runtime","cx","parts","TableFrame","rest","className","TableToolbar","start","end","hasBodyContent","children","child","TableContext","Table","TableHead","TableBody","isEmpty","TableRow","TableCell","TableEmpty","emptyMessage","isSelected","isInteractive","TableHeaderCell","align","width","emphasis","icon","title","description","action"],"sources":["../../../src/components/Table/index.tsx"],"sourcesContent":["import {\n Children,\n Fragment,\n createContext,\n forwardRef,\n isValidElement,\n useContext,\n type HTMLAttributes,\n type ReactNode,\n type TableHTMLAttributes,\n type TdHTMLAttributes,\n type ThHTMLAttributes,\n} from \"react\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface TableFrameProps extends HTMLAttributes<HTMLDivElement> {\n children?: ReactNode;\n}\n\n/** The 3px collection frame every table, list and board sits inside. */\nexport const TableFrame = forwardRef<HTMLDivElement, TableFrameProps>(function TableFrame(\n { className, children, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n className={cx(\"ds-table-frame\", \"ds-field-surface\", className)}\n {...rest}\n >\n {children}\n </div>\n );\n});\n\nexport interface TableToolbarProps extends HTMLAttributes<HTMLDivElement> {\n /** Left side — usually a select-all checkbox, a title and a count badge. */\n start?: ReactNode;\n /** Right side — filters and the one primary action. */\n end?: ReactNode;\n}\n\n/** The band above the rules: selection, title, count, filters, primary action. */\nexport const TableToolbar = forwardRef<HTMLDivElement, TableToolbarProps>(function TableToolbar(\n { start, end, className, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n className={cx(\"ds-table-toolbar\", className)}\n {...rest}\n >\n <div className=\"ds-table-toolbar__group\">{start}</div>\n <div className=\"ds-table-toolbar__group\">{end}</div>\n </div>\n );\n});\n\nexport interface TableProps extends TableHTMLAttributes<HTMLTableElement> {\n /** Message shown when a body has no rows. */\n emptyMessage?: string;\n /** Override empty-child detection when rows are rendered by custom components. */\n isEmpty?: boolean;\n children?: ReactNode;\n}\n\nfunction hasBodyContent(children: ReactNode): boolean {\n return Children.toArray(children).some(\n (child) =>\n isValidElement<{ children?: ReactNode }>(child) &&\n (child.type !== Fragment || hasBodyContent(child.props.children)),\n );\n}\n\nconst TableContext = createContext<{\n emptyMessage: string;\n isEmpty?: boolean;\n}>({ emptyMessage: \"No data found.\" });\n\n/** The rules layer. Always render it inside a `TableFrame`. */\nexport const Table = forwardRef<HTMLTableElement, TableProps>(function Table(\n { emptyMessage = \"No data found.\", isEmpty, className, children, ...rest },\n ref,\n) {\n return (\n <TableContext.Provider value={{ emptyMessage, isEmpty }}>\n <div className=\"ds-table-frame__scroll\">\n <table\n {...rest}\n ref={ref}\n className={cx(\"ds-table\", className)}\n >\n {children}\n </table>\n </div>\n </TableContext.Provider>\n );\n});\n\nexport const TableHead = forwardRef<\n HTMLTableSectionElement,\n HTMLAttributes<HTMLTableSectionElement>\n>(function TableHead({ className, ...rest }, ref) {\n return (\n <thead\n ref={ref}\n className={className}\n {...rest}\n />\n );\n});\n\nexport const TableBody = forwardRef<\n HTMLTableSectionElement,\n HTMLAttributes<HTMLTableSectionElement>\n>(function TableBody({ className, children, ...rest }, ref) {\n const { emptyMessage, isEmpty } = useContext(TableContext);\n return (\n <tbody\n ref={ref}\n className={className}\n {...rest}\n >\n {(isEmpty ?? !hasBodyContent(children)) ? (\n <TableRow>\n {/* HTML's maximum span covers the row without inspecting columns. */}\n <TableCell\n colSpan={1000}\n className=\"ds-table__empty-cell\"\n >\n <TableEmpty\n title={emptyMessage}\n role=\"status\"\n />\n </TableCell>\n </TableRow>\n ) : (\n children\n )}\n </tbody>\n );\n});\n\nexport interface TableRowProps extends HTMLAttributes<HTMLTableRowElement> {\n /** Paints the soft fill and the solid rail. Never changes the row's size. */\n isSelected?: boolean;\n /** Marks the row clickable: hover fill plus a pointer cursor. */\n isInteractive?: boolean;\n}\n\nexport const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(function TableRow(\n { isSelected = false, isInteractive = false, className, ...rest },\n ref,\n) {\n return (\n <tr\n ref={ref}\n data-selected={isSelected || undefined}\n data-interactive={isInteractive || undefined}\n tabIndex={isInteractive ? 0 : undefined}\n className={className}\n {...rest}\n />\n );\n});\n\nexport type TableAlign = \"start\" | \"end\";\nexport type TableCellWidth = \"auto\" | \"control\";\n\nexport interface TableHeaderCellProps extends Omit<\n ThHTMLAttributes<HTMLTableCellElement>,\n \"align\"\n> {\n align?: TableAlign;\n width?: TableCellWidth;\n}\n\nexport const TableHeaderCell = forwardRef<HTMLTableCellElement, TableHeaderCellProps>(\n function TableHeaderCell({ align = \"start\", width = \"auto\", className, ...rest }, ref) {\n return (\n <th\n ref={ref}\n scope=\"col\"\n data-align={align}\n data-width={width}\n className={className}\n {...rest}\n />\n );\n },\n);\n\nexport type TableCellEmphasis = \"default\" | \"primary\" | \"muted\";\n\nexport interface TableCellProps extends Omit<TdHTMLAttributes<HTMLTableCellElement>, \"align\"> {\n align?: TableAlign;\n width?: TableCellWidth;\n /** `primary` is the row's identity cell — one per row, never two. */\n emphasis?: TableCellEmphasis;\n}\n\nexport const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(function TableCell(\n { align = \"start\", width = \"auto\", emphasis = \"default\", className, ...rest },\n ref,\n) {\n return (\n <td\n ref={ref}\n data-align={align}\n data-width={width}\n data-emphasis={emphasis === \"default\" ? undefined : emphasis}\n className={className}\n {...rest}\n />\n );\n});\n\nexport interface TableEmptyProps extends HTMLAttributes<HTMLDivElement> {\n icon?: IconName;\n title?: string;\n description?: string;\n /** One action at most — the thing that ends the empty state. */\n action?: ReactNode;\n}\n\n/** What the frame shows when the collection has no rows. */\nexport const TableEmpty = forwardRef<HTMLDivElement, TableEmptyProps>(function TableEmpty(\n { icon = \"info\", title = \"No data found.\", description, action, className, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n className={cx(\"ds-table-empty\", className)}\n {...rest}\n >\n <Icon\n name={icon}\n size={24}\n />\n <span style={{ color: \"var(--color-text)\", fontWeight: \"var(--font-weight-bold)\" }}>\n {title}\n </span>\n {description && <span>{description}</span>}\n {action}\n </div>\n );\n});\n"],"mappings":"A,2KAiBA,SAASU,EAAG,GAAGC,EAAuC,CACpD,OAAOA,E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EACD,YACX,GAAIrB,CACL,CAAA,CAEL,CACF,EAWac,GAAA,EAAY3B,EAAAA,WAAAA,CAAiD,SACxE,CAAE,QAAQ,QAAS,QAAQ,OAAQ,WAAW,UAAW,YAAW,GAAGa,GACvE,EACA,CACA,OACE,EAAAJ,EAAA,IAAA,CAAC,KAAD,CACO,MACL,aAAYwB,EACZ,aAAYC,EACZ,gBAAeC,IAAa,UAAY,IAAA,GAAYA,EACzC,YACX,GAAItB,CACL,CAAA,CAEL,CAAC,EAWYe,GAAA,EAAa5B,EAAAA,WAAAA,CAA4C,SACpE,CAAE,OAAO,OAAQ,QAAQ,iBAAkB,cAAa,SAAQ,YAAW,GAAGa,GAC9E,EACA,CACA,OACE,EAAAJ,EAAA,KAAA,CAAC,MAAD,CACO,MACL,UAAWC,EAAG,iBAAkBI,CAAS,EACzC,GAAID,EAHN,SAAA,EAKE,EAAAJ,EAAA,IAAA,CAACH,EAAAA,EAAD,CACE,KAAM8B,EACN,KAAM,EACP,CAAA,GACD,EAAA3B,EAAA,IAAA,CAAC,OAAD,CAAM,MAAO,CAAE,MAAO,oBAAqB,WAAY,yBAA0B,EAC9E,SAAA4B,CACG,CAAA,EACLC,IAAe,EAAA7B,EAAA,IAAA,CAAC,OAAD,CAAA,SAAO6B,CAAkB,CAAA,EACxCC,CACE,C,EAET,CAAC,E"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["forwardRef","Children","isValidElement","Fragment","createContext","useContext","Icon","require_Icon","react","react_jsx_runtime","cx","parts","TableFrame","rest","className","TableToolbar","start","end","hasBodyContent","children","child","TableContext","Table","TableHead","TableBody","isEmpty","TableRow","TableCell","TableEmpty","emptyMessage","isSelected","isInteractive","TableHeaderCell","align","width","emphasis","icon","title","description","action"],"sources":["../../../src/components/Table/index.tsx"],"sourcesContent":["import {\n Children,\n Fragment,\n createContext,\n forwardRef,\n isValidElement,\n useContext,\n type HTMLAttributes,\n type ReactNode,\n type TableHTMLAttributes,\n type TdHTMLAttributes,\n type ThHTMLAttributes,\n} from \"react\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface TableFrameProps extends HTMLAttributes<HTMLDivElement> {\n children?: ReactNode;\n}\n\n/** The 3px collection frame every table, list and board sits inside. */\nexport const TableFrame = forwardRef<HTMLDivElement, TableFrameProps>(function TableFrame(\n { className, children, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n className={cx(\"ds-table-frame\", \"ds-field-surface\", className)}\n {...rest}\n >\n {children}\n </div>\n );\n});\n\nexport interface TableToolbarProps extends HTMLAttributes<HTMLDivElement> {\n /** Left side — usually a select-all checkbox, a title and a count badge. */\n start?: ReactNode;\n /** Right side — filters and the one primary action. */\n end?: ReactNode;\n}\n\n/** The band above the rules: selection, title, count, filters, primary action. */\nexport const TableToolbar = forwardRef<HTMLDivElement, TableToolbarProps>(function TableToolbar(\n { start, end, className, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n className={cx(\"ds-table-toolbar\", \"ds-field-surface\", className)}\n {...rest}\n >\n <div className=\"ds-table-toolbar__group\">{start}</div>\n <div className=\"ds-table-toolbar__group\">{end}</div>\n </div>\n );\n});\n\nexport interface TableProps extends TableHTMLAttributes<HTMLTableElement> {\n /** Message shown when a body has no rows. */\n emptyMessage?: string;\n /** Override empty-child detection when rows are rendered by custom components. */\n isEmpty?: boolean;\n children?: ReactNode;\n}\n\nfunction hasBodyContent(children: ReactNode): boolean {\n return Children.toArray(children).some(\n (child) =>\n isValidElement<{ children?: ReactNode }>(child) &&\n (child.type !== Fragment || hasBodyContent(child.props.children)),\n );\n}\n\nconst TableContext = createContext<{\n emptyMessage: string;\n isEmpty?: boolean;\n}>({ emptyMessage: \"No data found.\" });\n\n/** The rules layer. Always render it inside a `TableFrame`. */\nexport const Table = forwardRef<HTMLTableElement, TableProps>(function Table(\n { emptyMessage = \"No data found.\", isEmpty, className, children, ...rest },\n ref,\n) {\n return (\n <TableContext.Provider value={{ emptyMessage, isEmpty }}>\n <div className=\"ds-table-frame__scroll\">\n <table\n {...rest}\n ref={ref}\n className={cx(\"ds-table\", className)}\n >\n {children}\n </table>\n </div>\n </TableContext.Provider>\n );\n});\n\nexport const TableHead = forwardRef<\n HTMLTableSectionElement,\n HTMLAttributes<HTMLTableSectionElement>\n>(function TableHead({ className, ...rest }, ref) {\n return (\n <thead\n ref={ref}\n className={className}\n {...rest}\n />\n );\n});\n\nexport const TableBody = forwardRef<\n HTMLTableSectionElement,\n HTMLAttributes<HTMLTableSectionElement>\n>(function TableBody({ className, children, ...rest }, ref) {\n const { emptyMessage, isEmpty } = useContext(TableContext);\n return (\n <tbody\n ref={ref}\n className={className}\n {...rest}\n >\n {(isEmpty ?? !hasBodyContent(children)) ? (\n <TableRow>\n {/* HTML's maximum span covers the row without inspecting columns. */}\n <TableCell\n colSpan={1000}\n className=\"ds-table__empty-cell\"\n >\n <TableEmpty\n title={emptyMessage}\n role=\"status\"\n />\n </TableCell>\n </TableRow>\n ) : (\n children\n )}\n </tbody>\n );\n});\n\nexport interface TableRowProps extends HTMLAttributes<HTMLTableRowElement> {\n /** Paints the soft fill and the solid rail. Never changes the row's size. */\n isSelected?: boolean;\n /** Marks the row clickable: hover fill plus a pointer cursor. */\n isInteractive?: boolean;\n}\n\nexport const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(function TableRow(\n { isSelected = false, isInteractive = false, className, ...rest },\n ref,\n) {\n return (\n <tr\n ref={ref}\n data-selected={isSelected || undefined}\n data-interactive={isInteractive || undefined}\n tabIndex={isInteractive ? 0 : undefined}\n className={cx(\"ds-field-surface\", className)}\n {...rest}\n />\n );\n});\n\nexport type TableAlign = \"start\" | \"end\";\nexport type TableCellWidth = \"auto\" | \"control\";\n\nexport interface TableHeaderCellProps extends Omit<\n ThHTMLAttributes<HTMLTableCellElement>,\n \"align\"\n> {\n align?: TableAlign;\n width?: TableCellWidth;\n}\n\nexport const TableHeaderCell = forwardRef<HTMLTableCellElement, TableHeaderCellProps>(\n function TableHeaderCell({ align = \"start\", width = \"auto\", className, ...rest }, ref) {\n return (\n <th\n ref={ref}\n scope=\"col\"\n data-align={align}\n data-width={width}\n className={className}\n {...rest}\n />\n );\n },\n);\n\nexport type TableCellEmphasis = \"default\" | \"primary\" | \"muted\";\n\nexport interface TableCellProps extends Omit<TdHTMLAttributes<HTMLTableCellElement>, \"align\"> {\n align?: TableAlign;\n width?: TableCellWidth;\n /** `primary` is the row's identity cell — one per row, never two. */\n emphasis?: TableCellEmphasis;\n}\n\nexport const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(function TableCell(\n { align = \"start\", width = \"auto\", emphasis = \"default\", className, ...rest },\n ref,\n) {\n return (\n <td\n ref={ref}\n data-align={align}\n data-width={width}\n data-emphasis={emphasis === \"default\" ? undefined : emphasis}\n className={className}\n {...rest}\n />\n );\n});\n\nexport interface TableEmptyProps extends HTMLAttributes<HTMLDivElement> {\n icon?: IconName;\n title?: string;\n description?: string;\n /** One action at most — the thing that ends the empty state. */\n action?: ReactNode;\n}\n\n/** What the frame shows when the collection has no rows. */\nexport const TableEmpty = forwardRef<HTMLDivElement, TableEmptyProps>(function TableEmpty(\n { icon = \"info\", title = \"No data found.\", description, action, className, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n className={cx(\"ds-table-empty\", className)}\n {...rest}\n >\n <Icon\n name={icon}\n size={24}\n />\n <span style={{ color: \"var(--color-text)\", fontWeight: \"var(--font-weight-bold)\" }}>\n {title}\n </span>\n {description && <span>{description}</span>}\n {action}\n </div>\n );\n});\n"],"mappings":"A,2KAiBA,SAASU,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAOA,IAAaC,GAAA,EAAaZ,EAAAA,WAAAA,CAA4C,SACpE,CAAE,YAAW,WAAU,GAAGa,GAC1B,EACA,CACA,OACE,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AQ,OAAQ,WAAW,UAAW,YAAW,GAAGa,GACvE,EACA,CACA,OACE,EAAAJ,EAAA,IAAA,CAAC,KAAD,CACO,MACL,aAAYwB,EACZ,aAAYC,EACZ,gBAAeC,IAAa,UAAY,IAAA,GAAYA,EACzC,YACX,GAAItB,CACL,CAAA,CAEL,CAAC,EAWYe,GAAA,EAAa5B,EAAAA,WAAAA,CAA4C,SACpE,CAAE,OAAO,OAAQ,QAAQ,iBAAkB,cAAa,SAAQ,YAAW,GAAGa,GAC9E,EACA,CACA,OACE,EAAAJ,EAAA,KAAA,CAAC,MAAD,CACO,MACL,UAAWC,EAAG,iBAAkBI,CAAS,EACzC,GAAID,EAHN,SAAA,EAKE,EAAAJ,EAAA,IAAA,CAACH,EAAAA,EAAD,CACE,KAAM8B,EACN,KAAM,EACP,CAAA,GACD,EAAA3B,EAAA,IAAA,CAAC,OAAD,CAAM,MAAO,CAAE,MAAO,oBAAqB,WAAY,yBAA0B,EAC9E,SAAA4B,CACG,CAAA,EACLC,IAAe,EAAA7B,EAAA,IAAA,CAAC,OAAD,CAAA,SAAO6B,CAAkB,CAAA,EACxCC,CACE,C,EAET,CAAC,E"}
|
|
@@ -15,7 +15,7 @@ var u = i(function({ className: e, children: t, ...n }, r) {
|
|
|
15
15
|
}), d = i(function({ start: e, end: t, className: n, ...r }, i) {
|
|
16
16
|
return /* @__PURE__ */ c("div", {
|
|
17
17
|
ref: i,
|
|
18
|
-
className: l("ds-table-toolbar", n),
|
|
18
|
+
className: l("ds-table-toolbar", "ds-field-surface", n),
|
|
19
19
|
...r,
|
|
20
20
|
children: [/* @__PURE__ */ s("div", {
|
|
21
21
|
className: "ds-table-toolbar__group",
|
|
@@ -72,7 +72,7 @@ var p = r({ emptyMessage: "No data found." }), m = i(function({ emptyMessage: e
|
|
|
72
72
|
"data-selected": e || void 0,
|
|
73
73
|
"data-interactive": t || void 0,
|
|
74
74
|
tabIndex: t ? 0 : void 0,
|
|
75
|
-
className: n,
|
|
75
|
+
className: l("ds-field-surface", n),
|
|
76
76
|
...r
|
|
77
77
|
});
|
|
78
78
|
}), v = i(function({ align: e = "start", width: t = "auto", className: n, ...r }, i) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Icon","cx","parts","TableFrame","forwardRef","rest","className","TableToolbar","start","end","hasBodyContent","Children","children","isValidElement","child","Fragment","TableContext","createContext","Table","TableHead","TableBody","useContext","isEmpty","TableRow","TableCell","TableEmpty","emptyMessage","isSelected","isInteractive","TableHeaderCell","align","width","emphasis","icon","title","description","action"],"sources":["../../../src/components/Table/index.tsx"],"sourcesContent":["import {\n Children,\n Fragment,\n createContext,\n forwardRef,\n isValidElement,\n useContext,\n type HTMLAttributes,\n type ReactNode,\n type TableHTMLAttributes,\n type TdHTMLAttributes,\n type ThHTMLAttributes,\n} from \"react\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface TableFrameProps extends HTMLAttributes<HTMLDivElement> {\n children?: ReactNode;\n}\n\n/** The 3px collection frame every table, list and board sits inside. */\nexport const TableFrame = forwardRef<HTMLDivElement, TableFrameProps>(function TableFrame(\n { className, children, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n className={cx(\"ds-table-frame\", \"ds-field-surface\", className)}\n {...rest}\n >\n {children}\n </div>\n );\n});\n\nexport interface TableToolbarProps extends HTMLAttributes<HTMLDivElement> {\n /** Left side — usually a select-all checkbox, a title and a count badge. */\n start?: ReactNode;\n /** Right side — filters and the one primary action. */\n end?: ReactNode;\n}\n\n/** The band above the rules: selection, title, count, filters, primary action. */\nexport const TableToolbar = forwardRef<HTMLDivElement, TableToolbarProps>(function TableToolbar(\n { start, end, className, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n className={cx(\"ds-table-toolbar\", className)}\n {...rest}\n >\n <div className=\"ds-table-toolbar__group\">{start}</div>\n <div className=\"ds-table-toolbar__group\">{end}</div>\n </div>\n );\n});\n\nexport interface TableProps extends TableHTMLAttributes<HTMLTableElement> {\n /** Message shown when a body has no rows. */\n emptyMessage?: string;\n /** Override empty-child detection when rows are rendered by custom components. */\n isEmpty?: boolean;\n children?: ReactNode;\n}\n\nfunction hasBodyContent(children: ReactNode): boolean {\n return Children.toArray(children).some(\n (child) =>\n isValidElement<{ children?: ReactNode }>(child) &&\n (child.type !== Fragment || hasBodyContent(child.props.children)),\n );\n}\n\nconst TableContext = createContext<{\n emptyMessage: string;\n isEmpty?: boolean;\n}>({ emptyMessage: \"No data found.\" });\n\n/** The rules layer. Always render it inside a `TableFrame`. */\nexport const Table = forwardRef<HTMLTableElement, TableProps>(function Table(\n { emptyMessage = \"No data found.\", isEmpty, className, children, ...rest },\n ref,\n) {\n return (\n <TableContext.Provider value={{ emptyMessage, isEmpty }}>\n <div className=\"ds-table-frame__scroll\">\n <table\n {...rest}\n ref={ref}\n className={cx(\"ds-table\", className)}\n >\n {children}\n </table>\n </div>\n </TableContext.Provider>\n );\n});\n\nexport const TableHead = forwardRef<\n HTMLTableSectionElement,\n HTMLAttributes<HTMLTableSectionElement>\n>(function TableHead({ className, ...rest }, ref) {\n return (\n <thead\n ref={ref}\n className={className}\n {...rest}\n />\n );\n});\n\nexport const TableBody = forwardRef<\n HTMLTableSectionElement,\n HTMLAttributes<HTMLTableSectionElement>\n>(function TableBody({ className, children, ...rest }, ref) {\n const { emptyMessage, isEmpty } = useContext(TableContext);\n return (\n <tbody\n ref={ref}\n className={className}\n {...rest}\n >\n {(isEmpty ?? !hasBodyContent(children)) ? (\n <TableRow>\n {/* HTML's maximum span covers the row without inspecting columns. */}\n <TableCell\n colSpan={1000}\n className=\"ds-table__empty-cell\"\n >\n <TableEmpty\n title={emptyMessage}\n role=\"status\"\n />\n </TableCell>\n </TableRow>\n ) : (\n children\n )}\n </tbody>\n );\n});\n\nexport interface TableRowProps extends HTMLAttributes<HTMLTableRowElement> {\n /** Paints the soft fill and the solid rail. Never changes the row's size. */\n isSelected?: boolean;\n /** Marks the row clickable: hover fill plus a pointer cursor. */\n isInteractive?: boolean;\n}\n\nexport const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(function TableRow(\n { isSelected = false, isInteractive = false, className, ...rest },\n ref,\n) {\n return (\n <tr\n ref={ref}\n data-selected={isSelected || undefined}\n data-interactive={isInteractive || undefined}\n tabIndex={isInteractive ? 0 : undefined}\n className={className}\n {...rest}\n />\n );\n});\n\nexport type TableAlign = \"start\" | \"end\";\nexport type TableCellWidth = \"auto\" | \"control\";\n\nexport interface TableHeaderCellProps extends Omit<\n ThHTMLAttributes<HTMLTableCellElement>,\n \"align\"\n> {\n align?: TableAlign;\n width?: TableCellWidth;\n}\n\nexport const TableHeaderCell = forwardRef<HTMLTableCellElement, TableHeaderCellProps>(\n function TableHeaderCell({ align = \"start\", width = \"auto\", className, ...rest }, ref) {\n return (\n <th\n ref={ref}\n scope=\"col\"\n data-align={align}\n data-width={width}\n className={className}\n {...rest}\n />\n );\n },\n);\n\nexport type TableCellEmphasis = \"default\" | \"primary\" | \"muted\";\n\nexport interface TableCellProps extends Omit<TdHTMLAttributes<HTMLTableCellElement>, \"align\"> {\n align?: TableAlign;\n width?: TableCellWidth;\n /** `primary` is the row's identity cell — one per row, never two. */\n emphasis?: TableCellEmphasis;\n}\n\nexport const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(function TableCell(\n { align = \"start\", width = \"auto\", emphasis = \"default\", className, ...rest },\n ref,\n) {\n return (\n <td\n ref={ref}\n data-align={align}\n data-width={width}\n data-emphasis={emphasis === \"default\" ? undefined : emphasis}\n className={className}\n {...rest}\n />\n );\n});\n\nexport interface TableEmptyProps extends HTMLAttributes<HTMLDivElement> {\n icon?: IconName;\n title?: string;\n description?: string;\n /** One action at most — the thing that ends the empty state. */\n action?: ReactNode;\n}\n\n/** What the frame shows when the collection has no rows. */\nexport const TableEmpty = forwardRef<HTMLDivElement, TableEmptyProps>(function TableEmpty(\n { icon = \"info\", title = \"No data found.\", description, action, className, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n className={cx(\"ds-table-empty\", className)}\n {...rest}\n >\n <Icon\n name={icon}\n size={24}\n />\n <span style={{ color: \"var(--color-text)\", fontWeight: \"var(--font-weight-bold)\" }}>\n {title}\n </span>\n {description && <span>{description}</span>}\n {action}\n </div>\n );\n});\n"],"mappings":";;;;AAiBA,SAASC,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAOA,IAAaC,IAAaC,EAA4C,SACpE,EAAE,cAAW,aAAU,GAAGC,KAC1B,GACA;CACA,OACE,kBAAC,OAAD;EACO;EACL,WAAWJ,EAAG,kBAAkB,oBAAoBK,CAAS;EAC7D,GAAID;EAEH;CACE,CAAA;AAET,CAAC,GAUYE,IAAeH,EAA8C,SACxE,EAAE,UAAO,QAAK,cAAW,GAAGC,KAC5B,GACA;CACA,OACE,kBAAC,OAAD;EACO;EACL,WAAWJ,EAAG,oBAAoBK,CAAS;EAC3C,GAAID;EAHN,UAAA,CAKE,kBAAC,OAAD;GAAK,WAAU;GAA2B,UAAAG;EAAW,CAAA,GACrD,kBAAC,OAAD;GAAK,WAAU;GAA2B,UAAAC;EAAS,CAAA,CAChD;;AAET,CAAC;AAUD,SAASC,EAAe,GAA8B;CACpD,OAAOC,EAAS,QAAQC,CAAQ,CAAC,CAAC,MAC/B,MACCC,EAAyCC,CAAK,MAC7CA,EAAM,SAASC,KAAYL,EAAeI,EAAM,MAAM,QAAQ,EACnE;AACF;AAEA,IAAME,IAAeC,EAGlB,EAAE,cAAc,iBAAiB,CAAC,GAGxBC,IAAQd,EAAyC,SAC5D,EAAE,kBAAe,kBAAkB,YAAS,cAAW,aAAU,GAAGC,KACpE,GACA;CACA,OACE,kBAACW,EAAa,UAAd;EAAuB,OAAO;GAAE;GAAc;EAAQ;EACpD,UAAA,kBAAC,OAAD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YyB;EACZ,cAAYC;EACZ,iBAAeC,MAAa,YAAY,KAAA,IAAYA;EACzC;EACX,GAAI3B;CACL,CAAA;AAEL,CAAC,GAWYoB,IAAarB,EAA4C,SACpE,EAAE,UAAO,QAAQ,WAAQ,kBAAkB,gBAAa,WAAQ,cAAW,GAAGC,KAC9E,GACA;CACA,OACE,kBAAC,OAAD;EACO;EACL,WAAWJ,EAAG,kBAAkBK,CAAS;EACzC,GAAID;EAHN,UAAA;GAKE,kBAACL,GAAD;IACE,MAAMiC;IACN,MAAM;GACP,CAAA;GACD,kBAAC,QAAD;IAAM,OAAO;KAAE,OAAO;KAAqB,YAAY;IAA0B;IAC9E,UAAAC;GACG,CAAA;GACLC,KAAe,kBAAC,QAAD,EAAA,UAAOA,EAAkB,CAAA;GACxCC;EACE;;AAET,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["Icon","cx","parts","TableFrame","forwardRef","rest","className","TableToolbar","start","end","hasBodyContent","Children","children","isValidElement","child","Fragment","TableContext","createContext","Table","TableHead","TableBody","useContext","isEmpty","TableRow","TableCell","TableEmpty","emptyMessage","isSelected","isInteractive","TableHeaderCell","align","width","emphasis","icon","title","description","action"],"sources":["../../../src/components/Table/index.tsx"],"sourcesContent":["import {\n Children,\n Fragment,\n createContext,\n forwardRef,\n isValidElement,\n useContext,\n type HTMLAttributes,\n type ReactNode,\n type TableHTMLAttributes,\n type TdHTMLAttributes,\n type ThHTMLAttributes,\n} from \"react\";\nimport { Icon } from \"../Icon\";\nimport type { IconName } from \"../Icon/icons\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface TableFrameProps extends HTMLAttributes<HTMLDivElement> {\n children?: ReactNode;\n}\n\n/** The 3px collection frame every table, list and board sits inside. */\nexport const TableFrame = forwardRef<HTMLDivElement, TableFrameProps>(function TableFrame(\n { className, children, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n className={cx(\"ds-table-frame\", \"ds-field-surface\", className)}\n {...rest}\n >\n {children}\n </div>\n );\n});\n\nexport interface TableToolbarProps extends HTMLAttributes<HTMLDivElement> {\n /** Left side — usually a select-all checkbox, a title and a count badge. */\n start?: ReactNode;\n /** Right side — filters and the one primary action. */\n end?: ReactNode;\n}\n\n/** The band above the rules: selection, title, count, filters, primary action. */\nexport const TableToolbar = forwardRef<HTMLDivElement, TableToolbarProps>(function TableToolbar(\n { start, end, className, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n className={cx(\"ds-table-toolbar\", \"ds-field-surface\", className)}\n {...rest}\n >\n <div className=\"ds-table-toolbar__group\">{start}</div>\n <div className=\"ds-table-toolbar__group\">{end}</div>\n </div>\n );\n});\n\nexport interface TableProps extends TableHTMLAttributes<HTMLTableElement> {\n /** Message shown when a body has no rows. */\n emptyMessage?: string;\n /** Override empty-child detection when rows are rendered by custom components. */\n isEmpty?: boolean;\n children?: ReactNode;\n}\n\nfunction hasBodyContent(children: ReactNode): boolean {\n return Children.toArray(children).some(\n (child) =>\n isValidElement<{ children?: ReactNode }>(child) &&\n (child.type !== Fragment || hasBodyContent(child.props.children)),\n );\n}\n\nconst TableContext = createContext<{\n emptyMessage: string;\n isEmpty?: boolean;\n}>({ emptyMessage: \"No data found.\" });\n\n/** The rules layer. Always render it inside a `TableFrame`. */\nexport const Table = forwardRef<HTMLTableElement, TableProps>(function Table(\n { emptyMessage = \"No data found.\", isEmpty, className, children, ...rest },\n ref,\n) {\n return (\n <TableContext.Provider value={{ emptyMessage, isEmpty }}>\n <div className=\"ds-table-frame__scroll\">\n <table\n {...rest}\n ref={ref}\n className={cx(\"ds-table\", className)}\n >\n {children}\n </table>\n </div>\n </TableContext.Provider>\n );\n});\n\nexport const TableHead = forwardRef<\n HTMLTableSectionElement,\n HTMLAttributes<HTMLTableSectionElement>\n>(function TableHead({ className, ...rest }, ref) {\n return (\n <thead\n ref={ref}\n className={className}\n {...rest}\n />\n );\n});\n\nexport const TableBody = forwardRef<\n HTMLTableSectionElement,\n HTMLAttributes<HTMLTableSectionElement>\n>(function TableBody({ className, children, ...rest }, ref) {\n const { emptyMessage, isEmpty } = useContext(TableContext);\n return (\n <tbody\n ref={ref}\n className={className}\n {...rest}\n >\n {(isEmpty ?? !hasBodyContent(children)) ? (\n <TableRow>\n {/* HTML's maximum span covers the row without inspecting columns. */}\n <TableCell\n colSpan={1000}\n className=\"ds-table__empty-cell\"\n >\n <TableEmpty\n title={emptyMessage}\n role=\"status\"\n />\n </TableCell>\n </TableRow>\n ) : (\n children\n )}\n </tbody>\n );\n});\n\nexport interface TableRowProps extends HTMLAttributes<HTMLTableRowElement> {\n /** Paints the soft fill and the solid rail. Never changes the row's size. */\n isSelected?: boolean;\n /** Marks the row clickable: hover fill plus a pointer cursor. */\n isInteractive?: boolean;\n}\n\nexport const TableRow = forwardRef<HTMLTableRowElement, TableRowProps>(function TableRow(\n { isSelected = false, isInteractive = false, className, ...rest },\n ref,\n) {\n return (\n <tr\n ref={ref}\n data-selected={isSelected || undefined}\n data-interactive={isInteractive || undefined}\n tabIndex={isInteractive ? 0 : undefined}\n className={cx(\"ds-field-surface\", className)}\n {...rest}\n />\n );\n});\n\nexport type TableAlign = \"start\" | \"end\";\nexport type TableCellWidth = \"auto\" | \"control\";\n\nexport interface TableHeaderCellProps extends Omit<\n ThHTMLAttributes<HTMLTableCellElement>,\n \"align\"\n> {\n align?: TableAlign;\n width?: TableCellWidth;\n}\n\nexport const TableHeaderCell = forwardRef<HTMLTableCellElement, TableHeaderCellProps>(\n function TableHeaderCell({ align = \"start\", width = \"auto\", className, ...rest }, ref) {\n return (\n <th\n ref={ref}\n scope=\"col\"\n data-align={align}\n data-width={width}\n className={className}\n {...rest}\n />\n );\n },\n);\n\nexport type TableCellEmphasis = \"default\" | \"primary\" | \"muted\";\n\nexport interface TableCellProps extends Omit<TdHTMLAttributes<HTMLTableCellElement>, \"align\"> {\n align?: TableAlign;\n width?: TableCellWidth;\n /** `primary` is the row's identity cell — one per row, never two. */\n emphasis?: TableCellEmphasis;\n}\n\nexport const TableCell = forwardRef<HTMLTableCellElement, TableCellProps>(function TableCell(\n { align = \"start\", width = \"auto\", emphasis = \"default\", className, ...rest },\n ref,\n) {\n return (\n <td\n ref={ref}\n data-align={align}\n data-width={width}\n data-emphasis={emphasis === \"default\" ? undefined : emphasis}\n className={className}\n {...rest}\n />\n );\n});\n\nexport interface TableEmptyProps extends HTMLAttributes<HTMLDivElement> {\n icon?: IconName;\n title?: string;\n description?: string;\n /** One action at most — the thing that ends the empty state. */\n action?: ReactNode;\n}\n\n/** What the frame shows when the collection has no rows. */\nexport const TableEmpty = forwardRef<HTMLDivElement, TableEmptyProps>(function TableEmpty(\n { icon = \"info\", title = \"No data found.\", description, action, className, ...rest },\n ref,\n) {\n return (\n <div\n ref={ref}\n className={cx(\"ds-table-empty\", className)}\n {...rest}\n >\n <Icon\n name={icon}\n size={24}\n />\n <span style={{ color: \"var(--color-text)\", fontWeight: \"var(--font-weight-bold)\" }}>\n {title}\n </span>\n {description && <span>{description}</span>}\n {action}\n </div>\n );\n});\n"],"mappings":";;;;AAiBA,SAASC,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAOA,IAAaC,IAAaC,EAA4C,SACpE,EAAE,cAAW,aAAU,GAAGC,KAC1B,GACA;CACA,OACE,kBAAC,OAAD;EACO;EACL,WAAWJ,EAAG,kBAAkB,oBAAoBK,CAAS;EAC7D,GAAID;EAEH;CACE,CAAA;AAET,CAAC,GAUYE,IAAeH,EAA8C,SACxE,EAAE,UAAO,QAAK,cAAW,GAAGC,KAC5B,GACA;CACA,OACE,kBAAC,OAAD;EACO;EACL,WAAWJ,EAAG,oBAAoB,oBAAoBK,CAAS;EAC/D,GAAID;EAHN,UAAA,CAKE,kBAAC,OAAD;GAAK,WAAU;GAA2B,UAAAG;EAAW,CAAA,GACrD,kBAAC,OAAD;GAAK,WAAU;GAA2B,UA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BC,KAAiB,KAAA;EACnC,UAAUA,IAAgB,IAAI,KAAA;EAC9B,WAAW3B,EAAG,oBAAoBK,CAAS;EAC3C,GAAID;CACL,CAAA;AAEL,CAAC,GAaYwB,IAAkBzB,EAC7B,SAAyB,EAAE,WAAQ,SAAS,WAAQ,QAAQ,cAAW,GAAGC,KAAQ,GAAK;CACrF,OACE,kBAAC,MAAD;EACO;EACL,OAAM;EACN,cAAYyB;EACZ,cAAYC;EACD;EACX,GAAI1B;CACL,CAAA;AAEL,CACF,GAWamB,IAAYpB,EAAiD,SACxE,EAAE,WAAQ,SAAS,WAAQ,QAAQ,cAAW,WAAW,cAAW,GAAGC,KACvE,GACA;CACA,OACE,kBAAC,MAAD;EACO;EACL,cAAYyB;EACZ,cAAYC;EACZ,iBAAeC,MAAa,YAAY,KAAA,IAAYA;EACzC;EACX,GAAI3B;CACL,CAAA;AAEL,CAAC,GAWYoB,IAAarB,EAA4C,SACpE,EAAE,UAAO,QAAQ,WAAQ,kBAAkB,gBAAa,WAAQ,cAAW,GAAGC,KAC9E,GACA;CACA,OACE,kBAAC,OAAD;EACO;EACL,WAAWJ,EAAG,kBAAkBK,CAAS;EACzC,GAAID;EAHN,UAAA;GAKE,kBAACL,GAAD;IACE,MAAMiC;IACN,MAAM;GACP,CAAA;GACD,kBAAC,QAAD;IAAM,OAAO;KAAE,OAAO;KAAqB,YAAY;IAA0B;IAC9E,UAAAC;GACG,CAAA;GACLC,KAAe,kBAAC,QAAD,EAAA,UAAOA,EAAkB,CAAA;GACxCC;EACE;;AAET,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
@layer components {
|
|
2
|
-
/* The collection frame
|
|
3
|
-
*
|
|
2
|
+
/* The collection frame: a surface on the canvas. Cards inside it, such as
|
|
3
|
+
* an AssetGrid's tiles, rest on the alternate row fill to stand off it. */
|
|
4
4
|
.ds-table-frame {
|
|
5
5
|
--field-bg: var(--color-surface);
|
|
6
|
+
--fill-card: var(--fill-row-alt);
|
|
6
7
|
|
|
7
|
-
border:
|
|
8
|
+
border: 0;
|
|
8
9
|
border-radius: var(--radius-lg);
|
|
9
|
-
background: var(--
|
|
10
|
+
background: var(--field-bg);
|
|
10
11
|
overflow: hidden;
|
|
11
12
|
}
|
|
12
13
|
|
|
@@ -20,8 +21,9 @@
|
|
|
20
21
|
justify-content: space-between;
|
|
21
22
|
gap: var(--space-4);
|
|
22
23
|
padding: var(--space-4) var(--table-row-pad-inline);
|
|
23
|
-
background: var(--
|
|
24
|
-
|
|
24
|
+
background: var(--field-bg);
|
|
25
|
+
|
|
26
|
+
--field-bg: var(--fill-band);
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
.ds-table-toolbar__group {
|
|
@@ -41,6 +43,11 @@
|
|
|
41
43
|
border-collapse: collapse;
|
|
42
44
|
font-size: var(--table-cell-size);
|
|
43
45
|
color: var(--color-text);
|
|
46
|
+
|
|
47
|
+
/* Alternate rows step from the ground the table sits on: the frame's
|
|
48
|
+
* surface, or the canvas or any panel when used on its own. Declared
|
|
49
|
+
* here so each row can take it as its own ground. */
|
|
50
|
+
--table-row-alt: color-mix(in srgb, var(--color-text) 3%, var(--field-bg));
|
|
44
51
|
}
|
|
45
52
|
|
|
46
53
|
.ds-table th {
|
|
@@ -52,6 +59,7 @@
|
|
|
52
59
|
color: var(--color-text-muted);
|
|
53
60
|
padding: var(--space-3) var(--table-row-pad-inline);
|
|
54
61
|
white-space: nowrap;
|
|
62
|
+
padding-block-start: 14px;
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
.ds-table th[data-align="end"],
|
|
@@ -83,40 +91,44 @@
|
|
|
83
91
|
font-size: var(--font-size-sm);
|
|
84
92
|
}
|
|
85
93
|
|
|
86
|
-
.ds-table tbody tr
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
/* The rail exists at every row so selection never shifts the layout. */
|
|
90
|
-
box-shadow: inset var(--rail-width) 0 0 0 transparent;
|
|
91
|
-
transition: background-color var(--duration-fast) var(--ease-standard);
|
|
92
|
-
}
|
|
94
|
+
.ds-table:where(:has(thead)) tbody tr:where(:nth-child(odd)),
|
|
95
|
+
.ds-table:where(:not(:has(thead))) tbody tr:where(:nth-child(even)) {
|
|
96
|
+
--field-bg: var(--table-row-alt);
|
|
93
97
|
|
|
94
|
-
|
|
95
|
-
border-block-end: none;
|
|
98
|
+
background: var(--field-bg);
|
|
96
99
|
}
|
|
97
100
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
.ds-table tbody tr {
|
|
102
|
+
/* The rail exists at every row so selection never shifts the layout. */
|
|
103
|
+
box-shadow: inset calc(var(--rail-width) * var(--rail-direction)) 0 0 0 transparent;
|
|
104
|
+
transition: background-color var(--duration-fast) var(--ease-standard);
|
|
102
105
|
}
|
|
103
106
|
|
|
107
|
+
/* Painted fills other than the ground are named in --field-paint, so
|
|
108
|
+
* neutral badges and controls in the row step from them. */
|
|
104
109
|
.ds-table tbody tr[data-interactive]:hover {
|
|
110
|
+
--field-paint: var(--field-hover);
|
|
111
|
+
|
|
105
112
|
background: var(--field-hover);
|
|
106
113
|
cursor: pointer;
|
|
107
114
|
}
|
|
108
115
|
|
|
109
116
|
.ds-table tbody tr[data-selected] {
|
|
110
|
-
|
|
111
|
-
|
|
117
|
+
--field-bg: var(--color-primary-soft);
|
|
118
|
+
--button-active-bg: var(--color-primary-soft-pressed);
|
|
119
|
+
|
|
120
|
+
background: var(--field-bg);
|
|
121
|
+
box-shadow: inset calc(var(--rail-width) * var(--rail-direction)) 0 0 0 var(--rail-color);
|
|
112
122
|
}
|
|
113
123
|
|
|
114
124
|
.ds-table tbody tr[data-selected]:hover {
|
|
125
|
+
--field-paint: var(--color-primary-soft-hover);
|
|
126
|
+
|
|
115
127
|
background: var(--color-primary-soft-hover);
|
|
116
128
|
}
|
|
117
129
|
|
|
118
130
|
.ds-table tbody tr:focus-visible {
|
|
119
|
-
outline: var(--
|
|
131
|
+
outline: var(--focus-width) solid var(--color-focus);
|
|
120
132
|
outline-offset: -2px;
|
|
121
133
|
}
|
|
122
134
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Button/index.cjs");;/* empty css */const t=require("../../chunks/useLimit-CCv6sAUS.cjs");let n=require("react"),r=require("react/jsx-runtime");function i(...e){return e.filter(Boolean).join(` `)}var a=(0,n.forwardRef)(function({value:a,defaultValue:o=[],onValueChange:s,placeholder:c=`Add a tag`,size:l=`md`,max:u,isDisabled:d=!1,isInvalid:f=!1,required:p,"aria-invalid":m,className:h,...g},_){let[v,y]=(0,n.useState)(o),b=a??v;t.t(g,u===void 0?void 0:{count:b.length,max:u});let[x,S]=(0,n.useState)(``),C=(0,n.useRef)(null),w=e=>{a===void 0&&y(e),s?.(e)},T=e=>{let t=e.trim();t&&!b.includes(t)&&(u!==void 0&&b.length>=u||w([...b,t]))};return(0,r.jsxs)(`div`,{className:i(`ds-field-skin`,`ds-tags`,h),"data-size":l,"data-disabled":d||void 0,"aria-invalid":f||m||void 0,onClick:()=>C.current?.focus(),children:[b.map(t=>(0,r.jsxs)(`span`,{className:`ds-tags__tag`,children:[t,(0,r.jsx)(e.Button,{variant:`simple`,size:`xs`,isIconOnly:!0,iconStart:`x`,"aria-label":`Remove ${t}`,isDisabled:d,onClick:e=>{e.stopPropagation(),w(b.filter(e=>e!==t))}})]},t)),(0,r.jsx)(`input`,{ref:e=>{C.current=e,typeof _==`function`?_(e):_&&(_.current=e)},type:`text`,className:`ds-tags__input`,value:x,placeholder:b.length===0?c:``,disabled:d,"aria-invalid":f||m||void 0,"aria-required":p||void 0,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`||e.key===`,`?(e.preventDefault(),T(x),S(``)):e.key===`Backspace`&&x===``&&b.length>0&&w(b.slice(0,-1))},onBlur:()=>{T(x),S(``)},...g})]})});exports.TagsInput=a;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Button/index.cjs");;/* empty css */const t=require("../../chunks/useLimit-CCv6sAUS.cjs");let n=require("react"),r=require("react/jsx-runtime");function i(...e){return e.filter(Boolean).join(` `)}var a=(0,n.forwardRef)(function({value:a,defaultValue:o=[],onValueChange:s,placeholder:c=`Add a tag`,size:l=`md`,max:u,isDisabled:d=!1,isInvalid:f=!1,required:p,"aria-invalid":m,className:h,...g},_){let[v,y]=(0,n.useState)(o),b=a??v;t.t(g,u===void 0?void 0:{count:b.length,max:u});let[x,S]=(0,n.useState)(``),C=(0,n.useRef)(null),w=e=>{a===void 0&&y(e),s?.(e)},T=e=>{let t=e.trim();t&&!b.includes(t)&&(u!==void 0&&b.length>=u||w([...b,t]))};return(0,r.jsxs)(`div`,{className:i(`ds-field-skin`,`ds-tags`,h),"data-size":l,"data-disabled":d||void 0,"aria-invalid":f||m||void 0,onClick:()=>C.current?.focus(),children:[b.map(t=>(0,r.jsxs)(`span`,{className:`ds-tags__tag ds-field-surface`,children:[t,(0,r.jsx)(e.Button,{variant:`simple`,size:`xs`,isIconOnly:!0,iconStart:`x`,"aria-label":`Remove ${t}`,isDisabled:d,onClick:e=>{e.stopPropagation(),w(b.filter(e=>e!==t))}})]},t)),(0,r.jsx)(`input`,{ref:e=>{C.current=e,typeof _==`function`?_(e):_&&(_.current=e)},type:`text`,className:`ds-tags__input`,value:x,placeholder:b.length===0?c:``,disabled:d,"aria-invalid":f||m||void 0,"aria-required":p||void 0,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`||e.key===`,`?(e.preventDefault(),T(x),S(``)):e.key===`Backspace`&&x===``&&b.length>0&&w(b.slice(0,-1))},onBlur:()=>{T(x),S(``)},...g})]})});exports.TagsInput=a;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["forwardRef","useState","useRef","Button","require_components_Button_index","require_useLimit","react","react_jsx_runtime","cx","parts","TagsInput","ariaInvalid","rest","internal","setInternal","defaultValue","current","value","max","draft","setDraft","inputRef","commit","next","onValueChange","add","tag","raw","className","size","isDisabled","isInvalid","event","item","node","ref","placeholder","required"],"sources":["../../../src/components/TagsInput/index.tsx"],"sourcesContent":["import { forwardRef, useRef, useState, type KeyboardEvent } from \"react\";\nimport { Button } from \"../Button\";\nimport type { FieldBinding, FieldSize } from \"../Field\";\nimport { useReportedLimit } from \"../Field/useLimit\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface TagsInputProps extends FieldBinding {\n value?: string[];\n defaultValue?: string[];\n onValueChange?: (value: string[]) => void;\n placeholder?: string;\n size?: FieldSize;\n /** Stop accepting new tags past this count. */\n max?: number;\n isDisabled?: boolean;\n isInvalid?: boolean;\n className?: string;\n}\n\n/**\n * Free-text keywords. Enter or comma commits a tag, Backspace on an empty\n * input removes the last one. Tags are plain strings — never status tones.\n */\nexport const TagsInput = forwardRef<HTMLInputElement, TagsInputProps>(function TagsInput(\n {\n value,\n defaultValue = [],\n onValueChange,\n placeholder = \"Add a tag\",\n size = \"md\",\n max,\n isDisabled = false,\n isInvalid = false,\n required,\n \"aria-invalid\": ariaInvalid,\n className,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState<string[]>(defaultValue);\n const current = value ?? internal;\n useReportedLimit(rest, max === undefined ? undefined : { count: current.length, max });\n const [draft, setDraft] = useState(\"\");\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const commit = (next: string[]) => {\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n };\n\n const add = (raw: string) => {\n const tag = raw.trim();\n if (!tag || current.includes(tag)) {\n return;\n }\n if (max !== undefined && current.length >= max) {\n return;\n }\n commit([...current, tag]);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Enter\" || event.key === \",\") {\n event.preventDefault();\n add(draft);\n setDraft(\"\");\n } else if (event.key === \"Backspace\" && draft === \"\" && current.length > 0) {\n commit(current.slice(0, -1));\n }\n };\n\n return (\n <div\n className={cx(\"ds-field-skin\", \"ds-tags\", className)}\n data-size={size}\n data-disabled={isDisabled || undefined}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n onClick={() => inputRef.current?.focus()}\n >\n {current.map((tag) => (\n <span\n key={tag}\n className=\"ds-tags__tag\"\n >\n {tag}\n <Button\n variant=\"simple\"\n size=\"xs\"\n isIconOnly\n iconStart=\"x\"\n aria-label={`Remove ${tag}`}\n isDisabled={isDisabled}\n onClick={(event) => {\n event.stopPropagation();\n commit(current.filter((item) => item !== tag));\n }}\n />\n </span>\n ))}\n <input\n ref={(node) => {\n inputRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }}\n type=\"text\"\n className=\"ds-tags__input\"\n value={draft}\n placeholder={current.length === 0 ? placeholder : \"\"}\n disabled={isDisabled}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n aria-required={required || undefined}\n onChange={(event) => setDraft(event.target.value)}\n onKeyDown={onKeyDown}\n onBlur={() => {\n add(draft);\n setDraft(\"\");\n }}\n {...rest}\n />\n </div>\n );\n});\n"],"mappings":"A,iQAOA,SAASQ,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAmBA,IAAaC,GAAA,EAAYV,EAAAA,WAAAA,CAA6C,SACpE,CACE,QACA,eAAe,CAAC,EAChB,gBACA,cAAc,YACd,OAAO,KACP,MACA,aAAa,GACb,YAAY,GACZ,WACA,eAAgBW,EAChB,YACA,GAAGC,GAEL,EACA,CACA,GAAM,CAACC,EAAUC,IAAA,EAAeb,EAAAA,SAAAA,CAAmBc,CAAY,EACzDC,EAAUC,GAASJ,EACzBR,EAAA,EAAiBO,EAAMM,IAAQ,IAAA,GAAY,IAAA,GAAY,CAAE,MAAOF,EAAQ,OAAQ,KAAI,CAAC,EACrF,GAAM,CAACG,EAAOC,IAAA,EAAYnB,EAAAA,SAAAA,CAAS,EAAE,EAC/BoB,GAAA,EAAWnB,EAAAA,OAAAA,CAAgC,IAAI,EAE/CoB,EAAU,GAAmB,CAC7BL,IAAU,IAAA,IACZH,EAAYS,CAAI,EAElBC,IAAgBD,CAAI,CACtB,EAEME,EAAO,GAAgB,CAC3B,IAAMC,EAAMC,EAAI,KAAK,EAChBD,GAAO,GAAQ,SAASA,CAAG,IAG5BR,IAAQ,IAAA,IAAaF,EAAQ,QAAUE,GAG3CI,EAAO,CAAC,GAAGN,EAASU,CAAG,CAAC,EAC1B,EAYA,OACE,EAAAnB,EAAA,KAAA,CAAC,MAAD,CACE,UAAWC,EAAG,gBAAiB,UAAWoB,CAAS,EACnD,YAAWC,EACX,gBAAeC,GAAc,IAAA,GAC7B,eAAcC,GAAapB,GAAe,IAAA,GAC1C,YAAeU,EAAS,SAAS,MAAM,EALzC,SAAA,CAOGL,EAAQ,IAAK,IACZ,EAAAT,EAAA,KAAA,CAAC,OAAD,CAEE,UAAU,
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["forwardRef","useState","useRef","Button","require_components_Button_index","require_useLimit","react","react_jsx_runtime","cx","parts","TagsInput","ariaInvalid","rest","internal","setInternal","defaultValue","current","value","max","draft","setDraft","inputRef","commit","next","onValueChange","add","tag","raw","className","size","isDisabled","isInvalid","event","item","node","ref","placeholder","required"],"sources":["../../../src/components/TagsInput/index.tsx"],"sourcesContent":["import { forwardRef, useRef, useState, type KeyboardEvent } from \"react\";\nimport { Button } from \"../Button\";\nimport type { FieldBinding, FieldSize } from \"../Field\";\nimport { useReportedLimit } from \"../Field/useLimit\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface TagsInputProps extends FieldBinding {\n value?: string[];\n defaultValue?: string[];\n onValueChange?: (value: string[]) => void;\n placeholder?: string;\n size?: FieldSize;\n /** Stop accepting new tags past this count. */\n max?: number;\n isDisabled?: boolean;\n isInvalid?: boolean;\n className?: string;\n}\n\n/**\n * Free-text keywords. Enter or comma commits a tag, Backspace on an empty\n * input removes the last one. Tags are plain strings — never status tones.\n */\nexport const TagsInput = forwardRef<HTMLInputElement, TagsInputProps>(function TagsInput(\n {\n value,\n defaultValue = [],\n onValueChange,\n placeholder = \"Add a tag\",\n size = \"md\",\n max,\n isDisabled = false,\n isInvalid = false,\n required,\n \"aria-invalid\": ariaInvalid,\n className,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState<string[]>(defaultValue);\n const current = value ?? internal;\n useReportedLimit(rest, max === undefined ? undefined : { count: current.length, max });\n const [draft, setDraft] = useState(\"\");\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const commit = (next: string[]) => {\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n };\n\n const add = (raw: string) => {\n const tag = raw.trim();\n if (!tag || current.includes(tag)) {\n return;\n }\n if (max !== undefined && current.length >= max) {\n return;\n }\n commit([...current, tag]);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Enter\" || event.key === \",\") {\n event.preventDefault();\n add(draft);\n setDraft(\"\");\n } else if (event.key === \"Backspace\" && draft === \"\" && current.length > 0) {\n commit(current.slice(0, -1));\n }\n };\n\n return (\n <div\n className={cx(\"ds-field-skin\", \"ds-tags\", className)}\n data-size={size}\n data-disabled={isDisabled || undefined}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n onClick={() => inputRef.current?.focus()}\n >\n {current.map((tag) => (\n <span\n key={tag}\n className=\"ds-tags__tag ds-field-surface\"\n >\n {tag}\n <Button\n variant=\"simple\"\n size=\"xs\"\n isIconOnly\n iconStart=\"x\"\n aria-label={`Remove ${tag}`}\n isDisabled={isDisabled}\n onClick={(event) => {\n event.stopPropagation();\n commit(current.filter((item) => item !== tag));\n }}\n />\n </span>\n ))}\n <input\n ref={(node) => {\n inputRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }}\n type=\"text\"\n className=\"ds-tags__input\"\n value={draft}\n placeholder={current.length === 0 ? placeholder : \"\"}\n disabled={isDisabled}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n aria-required={required || undefined}\n onChange={(event) => setDraft(event.target.value)}\n onKeyDown={onKeyDown}\n onBlur={() => {\n add(draft);\n setDraft(\"\");\n }}\n {...rest}\n />\n </div>\n );\n});\n"],"mappings":"A,iQAOA,SAASQ,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAmBA,IAAaC,GAAA,EAAYV,EAAAA,WAAAA,CAA6C,SACpE,CACE,QACA,eAAe,CAAC,EAChB,gBACA,cAAc,YACd,OAAO,KACP,MACA,aAAa,GACb,YAAY,GACZ,WACA,eAAgBW,EAChB,YACA,GAAGC,GAEL,EACA,CACA,GAAM,CAACC,EAAUC,IAAA,EAAeb,EAAAA,SAAAA,CAAmBc,CAAY,EACzDC,EAAUC,GAASJ,EACzBR,EAAA,EAAiBO,EAAMM,IAAQ,IAAA,GAAY,IAAA,GAAY,CAAE,MAAOF,EAAQ,OAAQ,KAAI,CAAC,EACrF,GAAM,CAACG,EAAOC,IAAA,EAAYnB,EAAAA,SAAAA,CAAS,EAAE,EAC/BoB,GAAA,EAAWnB,EAAAA,OAAAA,CAAgC,IAAI,EAE/CoB,EAAU,GAAmB,CAC7BL,IAAU,IAAA,IACZH,EAAYS,CAAI,EAElBC,IAAgBD,CAAI,CACtB,EAEME,EAAO,GAAgB,CAC3B,IAAMC,EAAMC,EAAI,KAAK,EAChBD,GAAO,GAAQ,SAASA,CAAG,IAG5BR,IAAQ,IAAA,IAAaF,EAAQ,QAAUE,GAG3CI,EAAO,CAAC,GAAGN,EAASU,CAAG,CAAC,EAC1B,EAYA,OACE,EAAAnB,EAAA,KAAA,CAAC,MAAD,CACE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
|
26
26
|
"aria-invalid": m || g || void 0,
|
|
27
27
|
onClick: () => T.current?.focus(),
|
|
28
28
|
children: [S.map((t) => /* @__PURE__ */ o("span", {
|
|
29
|
-
className: "ds-tags__tag",
|
|
29
|
+
className: "ds-tags__tag ds-field-surface",
|
|
30
30
|
children: [t, /* @__PURE__ */ a(e, {
|
|
31
31
|
variant: "simple",
|
|
32
32
|
size: "xs",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["cx","parts","TagsInput","forwardRef","ariaInvalid","rest","internal","setInternal","useState","defaultValue","current","value","max","draft","setDraft","inputRef","useRef","commit","next","onValueChange","add","tag","raw","className","size","isDisabled","isInvalid","Button","event","item","node","ref","placeholder","required"],"sources":["../../../src/components/TagsInput/index.tsx"],"sourcesContent":["import { forwardRef, useRef, useState, type KeyboardEvent } from \"react\";\nimport { Button } from \"../Button\";\nimport type { FieldBinding, FieldSize } from \"../Field\";\nimport { useReportedLimit } from \"../Field/useLimit\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface TagsInputProps extends FieldBinding {\n value?: string[];\n defaultValue?: string[];\n onValueChange?: (value: string[]) => void;\n placeholder?: string;\n size?: FieldSize;\n /** Stop accepting new tags past this count. */\n max?: number;\n isDisabled?: boolean;\n isInvalid?: boolean;\n className?: string;\n}\n\n/**\n * Free-text keywords. Enter or comma commits a tag, Backspace on an empty\n * input removes the last one. Tags are plain strings — never status tones.\n */\nexport const TagsInput = forwardRef<HTMLInputElement, TagsInputProps>(function TagsInput(\n {\n value,\n defaultValue = [],\n onValueChange,\n placeholder = \"Add a tag\",\n size = \"md\",\n max,\n isDisabled = false,\n isInvalid = false,\n required,\n \"aria-invalid\": ariaInvalid,\n className,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState<string[]>(defaultValue);\n const current = value ?? internal;\n useReportedLimit(rest, max === undefined ? undefined : { count: current.length, max });\n const [draft, setDraft] = useState(\"\");\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const commit = (next: string[]) => {\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n };\n\n const add = (raw: string) => {\n const tag = raw.trim();\n if (!tag || current.includes(tag)) {\n return;\n }\n if (max !== undefined && current.length >= max) {\n return;\n }\n commit([...current, tag]);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Enter\" || event.key === \",\") {\n event.preventDefault();\n add(draft);\n setDraft(\"\");\n } else if (event.key === \"Backspace\" && draft === \"\" && current.length > 0) {\n commit(current.slice(0, -1));\n }\n };\n\n return (\n <div\n className={cx(\"ds-field-skin\", \"ds-tags\", className)}\n data-size={size}\n data-disabled={isDisabled || undefined}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n onClick={() => inputRef.current?.focus()}\n >\n {current.map((tag) => (\n <span\n key={tag}\n className=\"ds-tags__tag\"\n >\n {tag}\n <Button\n variant=\"simple\"\n size=\"xs\"\n isIconOnly\n iconStart=\"x\"\n aria-label={`Remove ${tag}`}\n isDisabled={isDisabled}\n onClick={(event) => {\n event.stopPropagation();\n commit(current.filter((item) => item !== tag));\n }}\n />\n </span>\n ))}\n <input\n ref={(node) => {\n inputRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }}\n type=\"text\"\n className=\"ds-tags__input\"\n value={draft}\n placeholder={current.length === 0 ? placeholder : \"\"}\n disabled={isDisabled}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n aria-required={required || undefined}\n onChange={(event) => setDraft(event.target.value)}\n onKeyDown={onKeyDown}\n onBlur={() => {\n add(draft);\n setDraft(\"\");\n }}\n {...rest}\n />\n </div>\n );\n});\n"],"mappings":";;;;;;AAOA,SAASA,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAmBA,IAAa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AQ,aACjBA,EAAID,CAAI,IACCC,MACT,EAAI,UAAUD;GAElB;GACA,MAAK;GACL,WAAU;GACV,OAAOjB;GACP,aAAaH,EAAQ,WAAW,IAAIsB,IAAc;GAClD,UAAUP;GACV,gBAAcC,KAAatB,KAAe,KAAA;GAC1C,iBAAe6B,KAAY,KAAA;GAC3B,WAAW,MAAUnB,EAASc,EAAM,OAAO,KAAK;GACrC,YAvDE,MAA2C;IAC5D,AAAIA,EAAM,QAAQ,WAAWA,EAAM,QAAQ,OACzCA,EAAM,eAAe,GACrBR,EAAIP,CAAK,GACTC,EAAS,EAAE,KACFc,EAAM,QAAQ,eAAef,MAAU,MAAMH,EAAQ,SAAS,KACvEO,EAAOP,EAAQ,MAAM,GAAG,EAAE,CAAC;GAE/B;GAgDM,cAAc;IAEZ,AADAU,EAAIP,CAAK,GACTC,EAAS,EAAE;GACb;GACA,GAAIT;EACL,CAAA,CACE;;AAET,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["cx","parts","TagsInput","forwardRef","ariaInvalid","rest","internal","setInternal","useState","defaultValue","current","value","max","draft","setDraft","inputRef","useRef","commit","next","onValueChange","add","tag","raw","className","size","isDisabled","isInvalid","Button","event","item","node","ref","placeholder","required"],"sources":["../../../src/components/TagsInput/index.tsx"],"sourcesContent":["import { forwardRef, useRef, useState, type KeyboardEvent } from \"react\";\nimport { Button } from \"../Button\";\nimport type { FieldBinding, FieldSize } from \"../Field\";\nimport { useReportedLimit } from \"../Field/useLimit\";\nimport \"../Field/style.css\";\nimport \"./style.css\";\n\nfunction cx(...parts: (string | undefined | false)[]) {\n return parts.filter(Boolean).join(\" \");\n}\n\nexport interface TagsInputProps extends FieldBinding {\n value?: string[];\n defaultValue?: string[];\n onValueChange?: (value: string[]) => void;\n placeholder?: string;\n size?: FieldSize;\n /** Stop accepting new tags past this count. */\n max?: number;\n isDisabled?: boolean;\n isInvalid?: boolean;\n className?: string;\n}\n\n/**\n * Free-text keywords. Enter or comma commits a tag, Backspace on an empty\n * input removes the last one. Tags are plain strings — never status tones.\n */\nexport const TagsInput = forwardRef<HTMLInputElement, TagsInputProps>(function TagsInput(\n {\n value,\n defaultValue = [],\n onValueChange,\n placeholder = \"Add a tag\",\n size = \"md\",\n max,\n isDisabled = false,\n isInvalid = false,\n required,\n \"aria-invalid\": ariaInvalid,\n className,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState<string[]>(defaultValue);\n const current = value ?? internal;\n useReportedLimit(rest, max === undefined ? undefined : { count: current.length, max });\n const [draft, setDraft] = useState(\"\");\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const commit = (next: string[]) => {\n if (value === undefined) {\n setInternal(next);\n }\n onValueChange?.(next);\n };\n\n const add = (raw: string) => {\n const tag = raw.trim();\n if (!tag || current.includes(tag)) {\n return;\n }\n if (max !== undefined && current.length >= max) {\n return;\n }\n commit([...current, tag]);\n };\n\n const onKeyDown = (event: KeyboardEvent<HTMLInputElement>) => {\n if (event.key === \"Enter\" || event.key === \",\") {\n event.preventDefault();\n add(draft);\n setDraft(\"\");\n } else if (event.key === \"Backspace\" && draft === \"\" && current.length > 0) {\n commit(current.slice(0, -1));\n }\n };\n\n return (\n <div\n className={cx(\"ds-field-skin\", \"ds-tags\", className)}\n data-size={size}\n data-disabled={isDisabled || undefined}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n onClick={() => inputRef.current?.focus()}\n >\n {current.map((tag) => (\n <span\n key={tag}\n className=\"ds-tags__tag ds-field-surface\"\n >\n {tag}\n <Button\n variant=\"simple\"\n size=\"xs\"\n isIconOnly\n iconStart=\"x\"\n aria-label={`Remove ${tag}`}\n isDisabled={isDisabled}\n onClick={(event) => {\n event.stopPropagation();\n commit(current.filter((item) => item !== tag));\n }}\n />\n </span>\n ))}\n <input\n ref={(node) => {\n inputRef.current = node;\n if (typeof ref === \"function\") {\n ref(node);\n } else if (ref) {\n ref.current = node;\n }\n }}\n type=\"text\"\n className=\"ds-tags__input\"\n value={draft}\n placeholder={current.length === 0 ? placeholder : \"\"}\n disabled={isDisabled}\n aria-invalid={isInvalid || ariaInvalid || undefined}\n aria-required={required || undefined}\n onChange={(event) => setDraft(event.target.value)}\n onKeyDown={onKeyDown}\n onBlur={() => {\n add(draft);\n setDraft(\"\");\n }}\n {...rest}\n />\n </div>\n );\n});\n"],"mappings":";;;;;;AAOA,SAASA,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAmBA,IAAaC,IAAYC,EAA6C,SACpE,EACE,UACA,kBAAe,CAAC,GAChB,kBACA,iBAAc,aACd,UAAO,MACP,QACA,gBAAa,IACb,eAAY,IACZ,aACA,gBAAgBC,GAChB,cACA,GAAGC,KAEL,GACA;CACA,IAAM,CAACC,GAAUC,KAAeC,EAAmBC,CAAY,GACzDC,IAAUC,KAASL;CACzB,EAAiBD,GAAMO,MAAQ,KAAA,IAAY,KAAA,IAAY;EAAE,OAAOF,EAAQ;EAAQ;CAAI,CAAC;CACrF,IAAM,CAACG,GAAOC,KAAYN,EAAS,EAAE,GAC/BO,IAAWC,EAAgC,IAAI,GAE/CC,KAAU,MAAmB;EAIjC,AAHIN,MAAU,KAAA,KACZJ,EAAYW,CAAI,GAElBC,IAAgBD,CAAI;CACtB,GAEME,KAAO,MAAgB;EAC3B,IAAMC,IAAMC,EAAI,KAAK;EACrB,AAAKD,KAAO,GAAQ,SAASA,CAAG,MAG5BT,MAAQ,KAAA,KAAaF,EAAQ,UAAUE,KAG3CK,EAAO,CAAC,GAAGP,GAASW,CAAG,CAAC;CAC1B;CAYA,OACE,kBAAC,OAAD;EACE,WAAWrB,EAAG,iBAAiB,WAAWuB,CAAS;EACnD,aAAWC;EACX,iBAAeC,KAAc,KAAA;EAC7B,gBAAcC,KAAatB,KAAe,KAAA;EAC1C,eAAeW,EAAS,SAAS,MAAM;EALzC,UAAA,CAOGL,EAAQ,KAAK,MACZ,kBAAC,QAAD;GAEE,WAAU;GAFZ,UAAA,CAIGW,GACD,kBAACM,GAAD;IACE,SAAQ;IACR,MAAK;IACL,YAAA;IACA,WAAU;IACV,cAAY,UAAUN;IACV;IACZ,UAAU,MAAU;KAElB,AADAO,EAAM,gBAAgB,GACtBX,EAAOP,EAAQ,QAAQ,MAASmB,MAASR,CAAG,CAAC;IAC/C;GACD,CAAA,CACG;EAhBC,GAAAA,CAgBD,CACP,GACD,kBAAC,SAAD;GACE,MAAM,MAAS;IAEb,AADA,EAAS,UAAUS,GACf,OAAOC,KAAQ,aACjBA,EAAID,CAAI,IACCC,MACT,EAAI,UAAUD;GAElB;GACA,MAAK;GACL,WAAU;GACV,OAAOjB;GACP,aAAaH,EAAQ,WAAW,IAAIsB,IAAc;GAClD,UAAUP;GACV,gBAAcC,KAAatB,KAAe,KAAA;GAC1C,iBAAe6B,KAAY,KAAA;GAC3B,WAAW,MAAUnB,EAASc,EAAM,OAAO,KAAK;GACrC,YAvDE,MAA2C;IAC5D,AAAIA,EAAM,QAAQ,WAAWA,EAAM,QAAQ,OACzCA,EAAM,eAAe,GACrBR,EAAIP,CAAK,GACTC,EAAS,EAAE,KACFc,EAAM,QAAQ,eAAef,MAAU,MAAMH,EAAQ,SAAS,KACvEO,EAAOP,EAAQ,MAAM,GAAG,EAAE,CAAC;GAE/B;GAgDM,cAAc;IAEZ,AADAU,EAAIP,CAAK,GACTC,EAAS,EAAE;GACb;GACA,GAAIT;EACL,CAAA,CACE;;AAET,CAAC"}
|
|
@@ -7,6 +7,19 @@
|
|
|
7
7
|
min-block-size: var(--field-height-md);
|
|
8
8
|
padding: var(--space-1) var(--space-2);
|
|
9
9
|
cursor: text;
|
|
10
|
+
|
|
11
|
+
/* The fill the field paints in its current state. Chips step from it. */
|
|
12
|
+
--tags-fill: var(--field-rest);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/* Outranks the shared skin's rest and hover fills; its invalid fill paints
|
|
16
|
+
* the same value. */
|
|
17
|
+
.ds-tags.ds-field-skin {
|
|
18
|
+
background: var(--tags-fill);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.ds-tags:hover {
|
|
22
|
+
--tags-fill: var(--field-hover);
|
|
10
23
|
}
|
|
11
24
|
|
|
12
25
|
.ds-tags[data-size="sm"] {
|
|
@@ -18,11 +31,20 @@
|
|
|
18
31
|
}
|
|
19
32
|
|
|
20
33
|
.ds-tags:focus-within {
|
|
21
|
-
|
|
22
|
-
|
|
34
|
+
--tags-fill: var(--field-focus);
|
|
35
|
+
|
|
36
|
+
outline: var(--focus-width) solid var(--color-focus);
|
|
23
37
|
outline-offset: 2px;
|
|
24
38
|
}
|
|
25
39
|
|
|
40
|
+
.ds-tags[aria-invalid="true"] {
|
|
41
|
+
--tags-fill: var(--field-invalid);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.ds-tags[aria-invalid="true"]:focus-within {
|
|
45
|
+
--tags-fill: var(--field-invalid-focus);
|
|
46
|
+
}
|
|
47
|
+
|
|
26
48
|
.ds-tags[data-disabled] {
|
|
27
49
|
opacity: 0.45;
|
|
28
50
|
cursor: not-allowed;
|
|
@@ -34,18 +56,21 @@
|
|
|
34
56
|
gap: var(--space-1);
|
|
35
57
|
|
|
36
58
|
/* The xs remove Button sets the chip height, so the md field never grows. */
|
|
37
|
-
padding:
|
|
38
|
-
border:
|
|
59
|
+
padding: 2px var(--space-1) 2px var(--space-2);
|
|
60
|
+
border: 0;
|
|
39
61
|
border-radius: var(--radius-pill);
|
|
40
|
-
background: var(--
|
|
62
|
+
background: var(--field-bg);
|
|
41
63
|
font-size: var(--font-size-xs);
|
|
42
64
|
font-weight: var(--font-weight-semibold);
|
|
65
|
+
|
|
66
|
+
/* A chip is a surface of its own, so its remove Button steps from it. */
|
|
67
|
+
--field-bg: color-mix(in srgb, var(--color-text) 8%, var(--tags-fill));
|
|
43
68
|
}
|
|
44
69
|
|
|
45
70
|
.ds-tags__input {
|
|
46
71
|
flex: 1;
|
|
47
72
|
min-inline-size: 6rem;
|
|
48
|
-
border:
|
|
73
|
+
border: 0;
|
|
49
74
|
background: transparent;
|
|
50
75
|
color: var(--color-text);
|
|
51
76
|
font-family: var(--font-sans);
|