@namroodinc/liquid-editorial 0.1.6 → 0.1.7
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/AGENTS.md +2 -0
- package/README.md +42 -0
- package/UPGRADING.md +68 -11
- package/dist/components/AppShell/index.cjs +2 -0
- package/dist/components/AppShell/index.cjs.map +1 -0
- package/dist/components/AppShell/index.d.cts +15 -0
- package/dist/components/AppShell/index.d.cts.map +1 -0
- package/dist/components/AppShell/index.d.ts +15 -0
- package/dist/components/AppShell/index.d.ts.map +1 -0
- package/dist/components/AppShell/index.js +93 -0
- package/dist/components/AppShell/index.js.map +1 -0
- package/dist/components/AppShell/style.css +79 -0
- package/dist/components/AssetGrid/index.cjs +1 -1
- package/dist/components/AssetGrid/index.cjs.map +1 -1
- package/dist/components/AssetGrid/index.d.cts.map +1 -1
- package/dist/components/AssetGrid/index.d.ts.map +1 -1
- package/dist/components/AssetGrid/index.js +57 -59
- package/dist/components/AssetGrid/index.js.map +1 -1
- package/dist/components/AssetGrid/style.css +8 -16
- package/dist/components/Board/index.cjs +1 -1
- package/dist/components/Board/index.cjs.map +1 -1
- package/dist/components/Board/index.d.cts.map +1 -1
- package/dist/components/Board/index.d.ts.map +1 -1
- package/dist/components/Board/index.js +88 -84
- package/dist/components/Board/index.js.map +1 -1
- package/dist/components/Board/style.css +17 -28
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.cjs.map +1 -1
- package/dist/components/Button/index.d.cts +3 -2
- package/dist/components/Button/index.d.cts.map +1 -1
- package/dist/components/Button/index.d.ts +3 -2
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/Button/index.js.map +1 -1
- package/dist/components/Button/style.css +21 -15
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.cjs.map +1 -1
- package/dist/components/DatePicker/index.d.cts.map +1 -1
- package/dist/components/DatePicker/index.d.ts.map +1 -1
- package/dist/components/DatePicker/index.js +46 -45
- package/dist/components/DatePicker/index.js.map +1 -1
- package/dist/components/DatePicker/style.css +4 -61
- package/dist/components/Drawer/index.cjs +1 -1
- package/dist/components/Drawer/index.cjs.map +1 -1
- package/dist/components/Drawer/index.d.cts +10 -1
- package/dist/components/Drawer/index.d.cts.map +1 -1
- package/dist/components/Drawer/index.d.ts +10 -1
- package/dist/components/Drawer/index.d.ts.map +1 -1
- package/dist/components/Drawer/index.js +69 -47
- package/dist/components/Drawer/index.js.map +1 -1
- package/dist/components/Drawer/style.css +106 -0
- package/dist/components/EntryPicker/index.cjs +1 -1
- package/dist/components/EntryPicker/index.cjs.map +1 -1
- package/dist/components/EntryPicker/index.d.cts.map +1 -1
- package/dist/components/EntryPicker/index.d.ts.map +1 -1
- package/dist/components/EntryPicker/index.js +12 -11
- package/dist/components/EntryPicker/index.js.map +1 -1
- package/dist/components/EntryPicker/style.css +3 -30
- package/dist/components/Field/style.css +11 -3
- package/dist/components/Menu/index.cjs +1 -1
- package/dist/components/Menu/index.cjs.map +1 -1
- package/dist/components/Menu/index.d.cts.map +1 -1
- package/dist/components/Menu/index.d.ts.map +1 -1
- package/dist/components/Menu/index.js +11 -16
- package/dist/components/Menu/index.js.map +1 -1
- package/dist/components/Menu/style.css +7 -41
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.cjs.map +1 -1
- package/dist/components/Modal/index.d.cts.map +1 -1
- package/dist/components/Modal/index.d.ts.map +1 -1
- package/dist/components/Modal/index.js +12 -12
- package/dist/components/Modal/index.js.map +1 -1
- package/dist/components/NumberField/index.cjs +1 -1
- package/dist/components/NumberField/index.cjs.map +1 -1
- package/dist/components/NumberField/index.js +13 -17
- package/dist/components/NumberField/index.js.map +1 -1
- package/dist/components/NumberField/style.css +1 -41
- package/dist/components/Popover/index.cjs +1 -1
- package/dist/components/Popover/index.cjs.map +1 -1
- package/dist/components/Popover/index.js +4 -4
- package/dist/components/SearchField/index.cjs +1 -1
- package/dist/components/SearchField/index.cjs.map +1 -1
- package/dist/components/SearchField/index.d.cts.map +1 -1
- package/dist/components/SearchField/index.d.ts.map +1 -1
- package/dist/components/SearchField/index.js +26 -27
- package/dist/components/SearchField/index.js.map +1 -1
- package/dist/components/SearchField/style.css +0 -21
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.cjs.map +1 -1
- package/dist/components/Select/index.d.cts.map +1 -1
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +82 -75
- package/dist/components/Select/index.js.map +1 -1
- package/dist/components/Select/style.css +5 -38
- package/dist/components/SideNav/index.cjs +1 -1
- package/dist/components/SideNav/index.cjs.map +1 -1
- package/dist/components/SideNav/index.d.cts.map +1 -1
- package/dist/components/SideNav/index.d.ts.map +1 -1
- package/dist/components/SideNav/index.js +52 -49
- package/dist/components/SideNav/index.js.map +1 -1
- package/dist/components/SideNav/style.css +2 -27
- package/dist/components/SortableList/index.cjs +1 -1
- package/dist/components/SortableList/index.cjs.map +1 -1
- package/dist/components/SortableList/index.d.cts.map +1 -1
- package/dist/components/SortableList/index.d.ts.map +1 -1
- package/dist/components/SortableList/index.js +42 -39
- package/dist/components/SortableList/index.js.map +1 -1
- package/dist/components/SortableList/style.css +9 -15
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.cjs.map +1 -1
- package/dist/components/Stepper/index.d.cts.map +1 -1
- package/dist/components/Stepper/index.d.ts.map +1 -1
- package/dist/components/Stepper/index.js +48 -39
- package/dist/components/Stepper/index.js.map +1 -1
- package/dist/components/Stepper/style.css +24 -18
- package/dist/components/SubNav/index.cjs +1 -1
- package/dist/components/SubNav/index.cjs.map +1 -1
- package/dist/components/SubNav/index.d.cts.map +1 -1
- package/dist/components/SubNav/index.d.ts.map +1 -1
- package/dist/components/SubNav/index.js +27 -28
- package/dist/components/SubNav/index.js.map +1 -1
- package/dist/components/SubNav/style.css +13 -0
- 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 +23 -21
- package/dist/components/Switch/index.js.map +1 -1
- package/dist/components/Switch/style.css +2 -28
- package/dist/components/TagsInput/index.cjs +1 -1
- package/dist/components/TagsInput/index.cjs.map +1 -1
- package/dist/components/TagsInput/index.js +8 -10
- package/dist/components/TagsInput/index.js.map +1 -1
- package/dist/components/TagsInput/style.css +2 -24
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +39 -38
- package/dist/styles.css +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Icon","statusOf","index","activeStep","Stepper","forwardRef","rest","label","size","className","steps","status","interactive","onStepChange","step"],"sources":["../../../src/components/Stepper/index.tsx"],"sourcesContent":["import { forwardRef, type HTMLAttributes, type ReactNode } from \"react\";\nimport { Icon } from \"../Icon\";\nimport \"./style.css\";\n\nexport type StepperSize = \"sm\" | \"md\";\nexport type StepStatus = \"complete\" | \"current\" | \"upcoming\";\n\nexport interface Step {\n /** Stable key, and the value reported by `onStepChange`. */\n id: string;\n /** The step in the user's words — sentence case. */\n label: ReactNode;\n /** One line on what happens here. */\n description?: ReactNode;\n}\n\nexport interface StepperProps\n extends Omit<HTMLAttributes<HTMLElement>, \"onChange\" | \"children\"> {\n /** The ordered steps. Three or more spread evenly across the full width. */\n steps: Step[];\n /** Index of the step being worked on. Everything before it reads as complete. */\n activeStep: number;\n /** Marker scale. `sm` for a toolbar band, `md` for a page header. */\n size?: StepperSize;\n /** Accessible name for the progress bar. */\n label?: string;\n /**\n * Makes completed steps (and the current one) navigable. Omit for a\n * read-only progress indicator.\n */\n onStepChange?: (index: number, id: string) => void;\n}\n\nfunction statusOf(index: number, activeStep: number): StepStatus {\n if (index < activeStep) return \"complete\";\n if (index === activeStep) return \"current\";\n return \"upcoming\";\n}\n\n/**\n * A linear progress rail: 1 - 2 - 3. Steps share the row equally however many\n * there are, so the last marker always lands on the trailing edge.\n */\nexport const Stepper = forwardRef<HTMLElement, StepperProps>(function Stepper(\n { steps, activeStep, size = \"md\", label = \"Progress\", onStepChange, className, ...rest },\n ref,\n) {\n return (\n <nav\n ref={ref}\n aria-label={label}\n data-size={size}\n className={[\"ds-stepper\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n <ol className=\"ds-stepper__list\">\n {steps.map((step, index) => {\n const status = statusOf(index, activeStep);\n const interactive = Boolean(onStepChange) && status !== \"upcoming\";\n const
|
|
1
|
+
{"version":3,"file":"index.js","names":["_Fragment","Icon","Fragment$1","statusOf","index","activeStep","Stepper","forwardRef","rest","id","useId","label","size","className","steps","status","interactive","onStepChange","marker","Button","step"],"sources":["../../../src/components/Stepper/index.tsx"],"sourcesContent":["import { forwardRef, useId, type HTMLAttributes, type ReactNode } from \"react\";\nimport { Icon } from \"../Icon\";\nimport { Button } from \"../Button\";\nimport \"./style.css\";\n\nexport type StepperSize = \"sm\" | \"md\";\nexport type StepStatus = \"complete\" | \"current\" | \"upcoming\";\n\nexport interface Step {\n /** Stable key, and the value reported by `onStepChange`. */\n id: string;\n /** The step in the user's words — sentence case. */\n label: ReactNode;\n /** One line on what happens here. */\n description?: ReactNode;\n}\n\nexport interface StepperProps\n extends Omit<HTMLAttributes<HTMLElement>, \"onChange\" | \"children\"> {\n /** The ordered steps. Three or more spread evenly across the full width. */\n steps: Step[];\n /** Index of the step being worked on. Everything before it reads as complete. */\n activeStep: number;\n /** Marker scale. `sm` for a toolbar band, `md` for a page header. */\n size?: StepperSize;\n /** Accessible name for the progress bar. */\n label?: string;\n /**\n * Makes completed steps (and the current one) navigable. Omit for a\n * read-only progress indicator.\n */\n onStepChange?: (index: number, id: string) => void;\n}\n\nfunction statusOf(index: number, activeStep: number): StepStatus {\n if (index < activeStep) return \"complete\";\n if (index === activeStep) return \"current\";\n return \"upcoming\";\n}\n\n/**\n * A linear progress rail: 1 - 2 - 3. Steps share the row equally however many\n * there are, so the last marker always lands on the trailing edge.\n */\nexport const Stepper = forwardRef<HTMLElement, StepperProps>(function Stepper(\n { steps, activeStep, size = \"md\", label = \"Progress\", onStepChange, className, ...rest },\n ref,\n) {\n const id = useId();\n return (\n <nav\n ref={ref}\n aria-label={label}\n data-size={size}\n className={[\"ds-stepper\", className].filter(Boolean).join(\" \")}\n {...rest}\n >\n <ol className=\"ds-stepper__list\">\n {steps.map((step, index) => {\n const status = statusOf(index, activeStep);\n const interactive = Boolean(onStepChange) && status !== \"upcoming\";\n const marker = <>\n {status === \"complete\" ? <Icon name=\"check\" size={16} aria-hidden=\"true\" /> : index + 1}\n <span id={`${id}-${index}-status`} className=\"ds-stepper__sr\">{status}</span>\n </>;\n return (\n <li\n key={step.id}\n className=\"ds-stepper__step\"\n data-status={status}\n aria-current={status === \"current\" ? \"step\" : undefined}\n >\n <span className=\"ds-stepper__track\" aria-hidden=\"true\">\n <span className=\"ds-stepper__connector\" data-side=\"start\" />\n <span className=\"ds-stepper__connector\" data-side=\"end\" />\n </span>\n {interactive ? <Button\n className=\"ds-stepper__marker\"\n variant={status === \"complete\" ? \"primary\" : \"active\"}\n size=\"sm\"\n isIconOnly\n aria-labelledby={`${id}-${index}-label`}\n aria-describedby={`${id}-${index}-status`}\n onClick={() => onStepChange?.(index, step.id)}\n >{marker}</Button> : <span className=\"ds-stepper__marker\">{marker}</span>}\n <span className=\"ds-stepper__text\">\n <span id={`${id}-${index}-label`} className=\"ds-stepper__label\">{step.label}</span>\n {step.description && (\n <span className=\"ds-stepper__description\">{step.description}</span>\n )}\n </span>\n </li>\n );\n })}\n </ol>\n </nav>\n );\n});\n"],"mappings":";;;;;AAkCA,SAASG,EAAS,GAAe,GAAgC;CAG/D,OAFIC,IAAQC,IAAmB,aAC3BD,MAAUC,IAAmB,YAC1B;AACT;AAMA,IAAaC,IAAUC,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;MACxE,kBAAC,QAAD;OAAM,WAAU;OAAhB,UAAA,CACE,kBAAC,QAAD;QAAM,IAAI,GAAGT,EAAG,GAAGL,EAAM;QAAS,WAAU;QAAqB,UAAAgB,EAAK;OAAY,CAAA,GACjFA,EAAK,eACJ,kBAAC,QAAD;QAAM,WAAU;QAA2B,UAAAA,EAAK;OAAkB,CAAA,CAEhE;;KACJ;IAxBG,GAAAA,EAAK,EAwBR;GAER,CAAC;EACC,CAAA;CACD,CAAA;AAET,CAAC"}
|
|
@@ -58,6 +58,25 @@
|
|
|
58
58
|
position: relative;
|
|
59
59
|
z-index: 1;
|
|
60
60
|
flex: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* Navigable markers are Buttons held to the rail's marker size, so the
|
|
64
|
+
* connector and labels line up with read-only steps. */
|
|
65
|
+
.ds-stepper .ds-stepper__marker.ds-button {
|
|
66
|
+
inline-size: var(--stepper-marker-size);
|
|
67
|
+
height: var(--stepper-marker-size);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.ds-stepper[data-size="sm"] .ds-stepper__marker.ds-button {
|
|
71
|
+
inline-size: var(--stepper-marker-size-sm);
|
|
72
|
+
height: var(--stepper-marker-size-sm);
|
|
73
|
+
font-size: var(--font-size-xs);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.ds-stepper__marker:not(.ds-button) {
|
|
77
|
+
position: relative;
|
|
78
|
+
z-index: 1;
|
|
79
|
+
flex: none;
|
|
61
80
|
inline-size: var(--stepper-marker-size);
|
|
62
81
|
block-size: var(--stepper-marker-size);
|
|
63
82
|
display: grid;
|
|
@@ -74,38 +93,25 @@
|
|
|
74
93
|
transition: background-color var(--duration-fast) var(--ease-standard);
|
|
75
94
|
}
|
|
76
95
|
|
|
77
|
-
.ds-stepper[data-size="sm"] .ds-stepper__marker {
|
|
96
|
+
.ds-stepper[data-size="sm"] .ds-stepper__marker:not(.ds-button) {
|
|
78
97
|
inline-size: var(--stepper-marker-size-sm);
|
|
79
98
|
block-size: var(--stepper-marker-size-sm);
|
|
80
99
|
font-size: var(--font-size-xs);
|
|
81
100
|
}
|
|
82
101
|
|
|
83
|
-
|
|
84
|
-
cursor: pointer;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
button.ds-stepper__marker:hover {
|
|
88
|
-
background: var(--field-hover);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
button.ds-stepper__marker:focus-visible {
|
|
92
|
-
outline: var(--control-border-width) solid var(--color-focus);
|
|
93
|
-
outline-offset: 2px;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.ds-stepper__step[data-status="complete"] .ds-stepper__marker {
|
|
102
|
+
.ds-stepper__step[data-status="complete"] .ds-stepper__marker:not(.ds-button) {
|
|
97
103
|
background: var(--color-primary);
|
|
98
104
|
border-color: var(--color-primary);
|
|
99
105
|
color: var(--color-text-on-solid);
|
|
100
106
|
}
|
|
101
107
|
|
|
102
|
-
.ds-stepper__step[data-status="current"] .ds-stepper__marker {
|
|
108
|
+
.ds-stepper__step[data-status="current"] .ds-stepper__marker:not(.ds-button) {
|
|
103
109
|
background: var(--color-primary-soft);
|
|
104
110
|
border-color: var(--color-primary);
|
|
105
111
|
color: var(--color-primary-text);
|
|
106
112
|
}
|
|
107
113
|
|
|
108
|
-
.ds-stepper__step[data-status="upcoming"] .ds-stepper__marker {
|
|
114
|
+
.ds-stepper__step[data-status="upcoming"] .ds-stepper__marker:not(.ds-button) {
|
|
109
115
|
color: var(--color-text-muted);
|
|
110
116
|
border-color: var(--color-border-muted);
|
|
111
117
|
}
|
|
@@ -147,7 +153,7 @@
|
|
|
147
153
|
}
|
|
148
154
|
|
|
149
155
|
@media (prefers-reduced-motion: reduce) {
|
|
150
|
-
.ds-stepper__marker {
|
|
156
|
+
.ds-stepper__marker:not(.ds-button) {
|
|
151
157
|
transition: none;
|
|
152
158
|
}
|
|
153
159
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-CWsA1W83.cjs");let
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../../chunks/Icon-CWsA1W83.cjs"),t=require("../Button/index.cjs");let n=require("react"),r=require("react/jsx-runtime");var i=(0,n.forwardRef)(function({label:e,actions:t,className:n,children:i,...a},o){return(0,r.jsxs)(`nav`,{ref:o,"aria-label":e,className:[`ds-subnav`,n].filter(Boolean).join(` `),...a,children:[(0,r.jsx)(`ul`,{className:`ds-subnav__list`,children:i}),t&&(0,r.jsx)(`div`,{className:`ds-subnav__actions`,children:t})]})}),a=(0,n.forwardRef)(function({label:t,icon:n,isActive:i,count:a,className:o,...s},c){return(0,r.jsx)(`li`,{className:`ds-subnav__row`,children:(0,r.jsxs)(`a`,{ref:c,className:[`ds-subnav__item`,o].filter(Boolean).join(` `),"data-active":i||void 0,"aria-current":i?`page`:void 0,...s,children:[n&&(0,r.jsx)(e.t,{name:n}),t,a!==void 0&&(0,r.jsx)(`span`,{className:`ds-subnav__count`,children:a})]})})}),o=(0,n.forwardRef)(function({label:e,icon:n,isActive:i,count:a,disabled:o,className:s,...c},l){return(0,r.jsx)(`li`,{className:`ds-subnav__row`,children:(0,r.jsxs)(t.Button,{ref:l,variant:`simple`,iconStart:n,isDisabled:o,className:[`ds-subnav__item`,s].filter(Boolean).join(` `),"data-active":i||void 0,"aria-pressed":i,...c,children:[e,a!==void 0&&(0,r.jsx)(`span`,{className:`ds-subnav__count`,children:a})]})})});exports.SubNav=i,exports.SubNavButton=o,exports.SubNavItem=a;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["forwardRef","Icon","require_Icon","react","react_jsx_runtime","SubNav","rest","label","className","actions","SubNavItem","isActive","icon","count","SubNavButton"],"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 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. A\n * hairline rule runs the full width; the active item sits on the 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,\n 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>(\n function SubNavItem({ label, icon, isActive, count, className, ...rest }, ref) {\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 && <span className=\"ds-subnav__count\">{count}</span>}\n </a>\n </li>\n );\n },\n);\n\nexport interface SubNavButtonProps\n extends SubNavItemBase,\n 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>(\n function SubNavButton({ label, icon, isActive, count, className, ...rest }, ref) {\n return (\n <li className=\"ds-subnav__row\">\n <
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["forwardRef","Icon","Button","require_Icon","require_components_Button_index","react","react_jsx_runtime","SubNav","rest","label","className","actions","SubNavItem","isActive","icon","count","SubNavButton","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 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. A\n * hairline rule runs the full width; the active item sits on the 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,\n 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>(\n function SubNavItem({ label, icon, isActive, count, className, ...rest }, ref) {\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 && <span className=\"ds-subnav__count\">{count}</span>}\n </a>\n </li>\n );\n },\n);\n\nexport interface SubNavButtonProps\n extends SubNavItemBase,\n 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>(\n function SubNavButton({ label, icon, isActive, count, disabled, className, ...rest }, ref) {\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 && <span className=\"ds-subnav__count\">{count}</span>}\n </Button>\n </li>\n );\n },\n);\n"],"mappings":"A,4MAwBA,IAAaO,GAAA,EAASP,EAAAA,WAAAA,CAAqC,SACzD,CAAE,QAAO,UAAS,YAAW,WAAU,GAAGQ,GAC1C,EACA,CACA,OACE,EAAAF,EAAA,KAAA,CAAC,MAAD,CACO,MACL,aAAYG,EACZ,UAAW,CAAC,YAAaC,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,EAC5D,GAAIF,EAJN,SAAA,EAME,EAAAF,EAAA,IAAA,CAAC,KAAD,CAAI,UAAU,kBAAmB,UAAa,CAAA,EAC7CK,IAAW,EAAAL,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,qBAAsB,SAAAK,CAAa,CAAA,CAC3D,C,EAET,CAAC,EAeYC,GAAA,EAAaZ,EAAAA,WAAAA,CACxB,SAAoB,CAAE,QAAO,OAAM,WAAU,QAAO,YAAW,GAAGQ,GAAQ,EAAK,CAC7E,OACE,E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+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/components/SubNav/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,aAAa,CAAC;AAErB,MAAM,WAAW,WAAY,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC9D,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM,qGAejB,CAAC;AAEH,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eACf,SAAQ,cAAc,EACpB,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC;CAAG;AAEhE,6EAA6E;AAC7E,eAAO,MAAM,UAAU,+GAkBtB,CAAC;AAEF,MAAM,WAAW,iBACf,SAAQ,cAAc,EACpB,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CAAG;AAEzE,+EAA+E;AAC/E,eAAO,MAAM,YAAY,iHAoBxB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SubNav/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/SubNav/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,oBAAoB,EACzB,KAAK,cAAc,EACnB,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,aAAa,CAAC;AAErB,MAAM,WAAW,WAAY,SAAQ,cAAc,CAAC,WAAW,CAAC;IAC9D,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM,qGAejB,CAAC;AAEH,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,eACf,SAAQ,cAAc,EACpB,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC;CAAG;AAEhE,6EAA6E;AAC7E,eAAO,MAAM,UAAU,+GAkBtB,CAAC;AAEF,MAAM,WAAW,iBACf,SAAQ,cAAc,EACpB,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CAAG;AAEzE,+EAA+E;AAC/E,eAAO,MAAM,YAAY,iHAoBxB,CAAC"}
|
|
@@ -1,62 +1,61 @@
|
|
|
1
1
|
import { t as e } from "../../chunks/Icon-CGY1FNXT.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { Button as t } from "../Button/index.js";
|
|
3
|
+
import { forwardRef as n } from "react";
|
|
4
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
4
5
|
//#region src/components/SubNav/index.tsx
|
|
5
|
-
var
|
|
6
|
-
return /* @__PURE__ */
|
|
6
|
+
var a = n(function({ label: e, actions: t, className: n, children: a, ...o }, s) {
|
|
7
|
+
return /* @__PURE__ */ i("nav", {
|
|
7
8
|
ref: s,
|
|
8
9
|
"aria-label": e,
|
|
9
|
-
className: ["ds-subnav",
|
|
10
|
+
className: ["ds-subnav", n].filter(Boolean).join(" "),
|
|
10
11
|
...o,
|
|
11
|
-
children: [/* @__PURE__ */
|
|
12
|
+
children: [/* @__PURE__ */ r("ul", {
|
|
12
13
|
className: "ds-subnav__list",
|
|
13
14
|
children: a
|
|
14
|
-
}), t && /* @__PURE__ */
|
|
15
|
+
}), t && /* @__PURE__ */ r("div", {
|
|
15
16
|
className: "ds-subnav__actions",
|
|
16
17
|
children: t
|
|
17
18
|
})]
|
|
18
19
|
});
|
|
19
|
-
}),
|
|
20
|
-
return /* @__PURE__ */
|
|
20
|
+
}), o = n(function({ label: t, icon: n, isActive: a, count: o, className: s, ...c }, l) {
|
|
21
|
+
return /* @__PURE__ */ r("li", {
|
|
21
22
|
className: "ds-subnav__row",
|
|
22
|
-
children: /* @__PURE__ */
|
|
23
|
+
children: /* @__PURE__ */ i("a", {
|
|
23
24
|
ref: l,
|
|
24
25
|
className: ["ds-subnav__item", s].filter(Boolean).join(" "),
|
|
25
26
|
"data-active": a || void 0,
|
|
26
27
|
"aria-current": a ? "page" : void 0,
|
|
27
28
|
...c,
|
|
28
29
|
children: [
|
|
29
|
-
|
|
30
|
+
n && /* @__PURE__ */ r(e, { name: n }),
|
|
30
31
|
t,
|
|
31
|
-
o !== void 0 && /* @__PURE__ */
|
|
32
|
+
o !== void 0 && /* @__PURE__ */ r("span", {
|
|
32
33
|
className: "ds-subnav__count",
|
|
33
34
|
children: o
|
|
34
35
|
})
|
|
35
36
|
]
|
|
36
37
|
})
|
|
37
38
|
});
|
|
38
|
-
}),
|
|
39
|
-
return /* @__PURE__ */
|
|
39
|
+
}), s = n(function({ label: e, icon: n, isActive: a, count: o, disabled: s, className: c, ...l }, u) {
|
|
40
|
+
return /* @__PURE__ */ r("li", {
|
|
40
41
|
className: "ds-subnav__row",
|
|
41
|
-
children: /* @__PURE__ */
|
|
42
|
-
ref:
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
children: /* @__PURE__ */ i(t, {
|
|
43
|
+
ref: u,
|
|
44
|
+
variant: "simple",
|
|
45
|
+
iconStart: n,
|
|
46
|
+
isDisabled: s,
|
|
47
|
+
className: ["ds-subnav__item", c].filter(Boolean).join(" "),
|
|
45
48
|
"data-active": a || void 0,
|
|
46
49
|
"aria-pressed": a,
|
|
47
|
-
...
|
|
48
|
-
children: [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
className: "ds-subnav__count",
|
|
53
|
-
children: o
|
|
54
|
-
})
|
|
55
|
-
]
|
|
50
|
+
...l,
|
|
51
|
+
children: [e, o !== void 0 && /* @__PURE__ */ r("span", {
|
|
52
|
+
className: "ds-subnav__count",
|
|
53
|
+
children: o
|
|
54
|
+
})]
|
|
56
55
|
})
|
|
57
56
|
});
|
|
58
57
|
});
|
|
59
58
|
//#endregion
|
|
60
|
-
export {
|
|
59
|
+
export { a as SubNav, s as SubNavButton, o as SubNavItem };
|
|
61
60
|
|
|
62
61
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Icon","SubNav","forwardRef","rest","label","className","actions","SubNavItem","isActive","icon","count","SubNavButton"],"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 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. A\n * hairline rule runs the full width; the active item sits on the 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,\n 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>(\n function SubNavItem({ label, icon, isActive, count, className, ...rest }, ref) {\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 && <span className=\"ds-subnav__count\">{count}</span>}\n </a>\n </li>\n );\n },\n);\n\nexport interface SubNavButtonProps\n extends SubNavItemBase,\n 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>(\n function SubNavButton({ label, icon, isActive, count, className, ...rest }, ref) {\n return (\n <li className=\"ds-subnav__row\">\n <
|
|
1
|
+
{"version":3,"file":"index.js","names":["Icon","SubNav","forwardRef","rest","label","className","actions","SubNavItem","isActive","icon","count","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 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. A\n * hairline rule runs the full width; the active item sits on the 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,\n 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>(\n function SubNavItem({ label, icon, isActive, count, className, ...rest }, ref) {\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 && <span className=\"ds-subnav__count\">{count}</span>}\n </a>\n </li>\n );\n },\n);\n\nexport interface SubNavButtonProps\n extends SubNavItemBase,\n 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>(\n function SubNavButton({ label, icon, isActive, count, disabled, className, ...rest }, ref) {\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 && <span className=\"ds-subnav__count\">{count}</span>}\n </Button>\n </li>\n );\n },\n);\n"],"mappings":";;;;;AAwBA,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,GAeYC,IAAaL,EACxB,SAAoB,EAAE,UAAO,SAAM,aAAU,UAAO,cAAW,GAAGC,KAAQ,GAAK;CAC7E,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,KAAa,kBAAC,QAAD;KAAM,WAAU;KAAoB,UAAAA;IAAY,CAAA;GACvE;;CACD,CAAA;AAER,CACF,GAOaC,IAAeT,EAC1B,SAAsB,EAAE,UAAO,SAAM,aAAU,UAAO,aAAU,cAAW,GAAGC,KAAQ,GAAK;CACzF,OACE,kBAAC,MAAD;EAAI,WAAU;EACZ,UAAA,kBAACS,GAAD;GACO;GACL,SAAQ;GACR,WAAWH;GACX,YAAYI;GACZ,WAAW,CAAC,mBAAmBR,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;GAClE,eAAaG,KAAY,KAAA;GACzB,gBAAcA;GACd,GAAIL;GARN,UAAA,CAUGC,GACAM,MAAU,KAAA,KAAa,kBAAC,QAAD;IAAM,WAAU;IAAoB,UAAAA;GAAY,CAAA,CAClE;;CACN,CAAA;AAER,CACF"}
|
|
@@ -42,6 +42,19 @@
|
|
|
42
42
|
box-shadow var(--duration-fast) var(--ease-standard);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/* SubNavButton composes Button but sits on the rail exactly like a link. */
|
|
46
|
+
.ds-subnav__item.ds-button {
|
|
47
|
+
height: auto;
|
|
48
|
+
padding: 0 var(--space-3);
|
|
49
|
+
border: 0;
|
|
50
|
+
border-radius: 0;
|
|
51
|
+
font-weight: var(--font-weight-medium);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.ds-subnav__item.ds-button:is(:hover, :active):not(:disabled) {
|
|
55
|
+
background: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
45
58
|
.ds-subnav__item:hover {
|
|
46
59
|
color: var(--color-text);
|
|
47
60
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});
|
|
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,className:c,children:l,onClick:u,...d},f){let[p,m]=(0,t.useState)(a),h=i??p;return(0,n.jsxs)(`label`,{className:r(`ds-switch`,c),children:[(0,n.jsx)(e.Button,{ref:f,variant:h?`primary`:`neutral`,size:`sm`,role:`switch`,"aria-checked":h,isDisabled:s,className:`ds-switch__track`,onClick:e=>{if(u?.(e),e.defaultPrevented)return;let t=!h;i===void 0&&m(t),o?.(t)},...d,children:(0,n.jsx)(`span`,{className:`ds-switch__knob`,"aria-hidden":`true`})}),l&&(0,n.jsx)(`span`,{className:`ds-switch__label`,children:l})]})});exports.Switch=i;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["forwardRef","useState","react","react_jsx_runtime","cx","parts","Switch","rest","internal","setInternal","defaultSelected","current","isSelected","className","
|
|
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","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\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"onChange\" | \"value\" | \"disabled\"> {\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 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 isDisabled={isDisabled}\n className=\"ds-switch__track\"\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) return;\n const next = !current;\n if (isSelected === undefined) setInternal(next);\n onSelectedChange?.(next);\n }}\n {...rest}\n >\n <span className=\"ds-switch__knob\" aria-hidden=\"true\" />\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,CAaA,IAAaC,GAAA,EAASR,EAAAA,WAAAA,CAA2C,SAC/D,CACE,aACA,kBAAkB,GAClB,mBACA,aAAa,GACb,YACA,WACA,UACA,GAAGS,GAEL,EACA,CACA,GAAM,CAACC,EAAUC,IAAA,EAAeV,EAAAA,SAAAA,CAASW,CAAe,EAClDC,EAAUC,GAAcJ,EAE9B,OACE,EAAAL,EAAA,KAAA,CAAC,QAAD,CAAO,UAAWC,EAAG,YAAaS,CAAS,EAA3C,SAAA,EACE,EAAAV,EAAA,IAAA,CAACH,EAAAA,OAAD,CACO,MACL,QAASW,EAAU,UAAY,UAC/B,KAAK,KACL,KAAK,SACL,eAAcA,EACF,aACZ,UAAU,mBACV,QAAU,GAAU,CAElB,GADAG,IAAUC,CAAK,EACXA,EAAM,iBAAkB,OAC5B,IAAMC,EAAO,CAACL,EACVC,IAAe,IAAA,IAAWH,EAAYO,CAAI,EAC9CC,IAAmBD,CAAI,CACzB,EACA,GAAIT,EAEJ,UAAA,EAAAJ,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,kBAAkB,cAAY,MAAQ,CAAA,CAChD,CAAA,EACPe,IAAY,EAAAf,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;
|
|
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,WACf,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;IACxF,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,2GAwCjB,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;
|
|
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,WACf,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,GAAG,OAAO,GAAG,UAAU,CAAC;IACxF,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,2GAwCjB,CAAC"}
|
|
@@ -1,37 +1,39 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { Button as e } from "../Button/index.js";
|
|
2
|
+
import { forwardRef as t, useState as n } from "react";
|
|
3
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
3
4
|
//#region src/components/Switch/index.tsx
|
|
4
|
-
function
|
|
5
|
+
function a(...e) {
|
|
5
6
|
return e.filter(Boolean).join(" ");
|
|
6
7
|
}
|
|
7
|
-
var
|
|
8
|
-
let [
|
|
9
|
-
return /* @__PURE__ */
|
|
10
|
-
className:
|
|
11
|
-
children: [/* @__PURE__ */
|
|
12
|
-
ref:
|
|
13
|
-
|
|
8
|
+
var o = t(function({ isSelected: t, defaultSelected: o = !1, onSelectedChange: s, isDisabled: c = !1, className: l, children: u, onClick: d, ...f }, p) {
|
|
9
|
+
let [m, h] = n(o), g = t ?? m;
|
|
10
|
+
return /* @__PURE__ */ i("label", {
|
|
11
|
+
className: a("ds-switch", l),
|
|
12
|
+
children: [/* @__PURE__ */ r(e, {
|
|
13
|
+
ref: p,
|
|
14
|
+
variant: g ? "primary" : "neutral",
|
|
15
|
+
size: "sm",
|
|
14
16
|
role: "switch",
|
|
15
|
-
"aria-checked":
|
|
16
|
-
|
|
17
|
+
"aria-checked": g,
|
|
18
|
+
isDisabled: c,
|
|
17
19
|
className: "ds-switch__track",
|
|
18
|
-
onClick: (
|
|
19
|
-
if (
|
|
20
|
-
let n = !
|
|
21
|
-
|
|
20
|
+
onClick: (e) => {
|
|
21
|
+
if (d?.(e), e.defaultPrevented) return;
|
|
22
|
+
let n = !g;
|
|
23
|
+
t === void 0 && h(n), s?.(n);
|
|
22
24
|
},
|
|
23
|
-
...
|
|
24
|
-
children: /* @__PURE__ */
|
|
25
|
+
...f,
|
|
26
|
+
children: /* @__PURE__ */ r("span", {
|
|
25
27
|
className: "ds-switch__knob",
|
|
26
28
|
"aria-hidden": "true"
|
|
27
29
|
})
|
|
28
|
-
}),
|
|
30
|
+
}), u && /* @__PURE__ */ r("span", {
|
|
29
31
|
className: "ds-switch__label",
|
|
30
|
-
children:
|
|
32
|
+
children: u
|
|
31
33
|
})]
|
|
32
34
|
});
|
|
33
35
|
});
|
|
34
36
|
//#endregion
|
|
35
|
-
export {
|
|
37
|
+
export { o as Switch };
|
|
36
38
|
|
|
37
39
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["cx","parts","Switch","forwardRef","rest","internal","setInternal","useState","defaultSelected","current","isSelected","className","
|
|
1
|
+
{"version":3,"file":"index.js","names":["cx","parts","Switch","forwardRef","rest","internal","setInternal","useState","defaultSelected","current","isSelected","className","Button","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\n extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, \"onChange\" | \"value\" | \"disabled\"> {\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 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 isDisabled={isDisabled}\n className=\"ds-switch__track\"\n onClick={(event) => {\n onClick?.(event);\n if (event.defaultPrevented) return;\n const next = !current;\n if (isSelected === undefined) setInternal(next);\n onSelectedChange?.(next);\n }}\n {...rest}\n >\n <span className=\"ds-switch__knob\" aria-hidden=\"true\" />\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;AAaA,IAAaC,IAASC,EAA2C,SAC/D,EACE,eACA,qBAAkB,IAClB,qBACA,gBAAa,IACb,cACA,aACA,YACA,GAAGC,KAEL,GACA;CACA,IAAM,CAACC,GAAUC,KAAeC,EAASC,CAAe,GAClDC,IAAUC,KAAcL;CAE9B,OACE,kBAAC,SAAD;EAAO,WAAWL,EAAG,aAAaW,CAAS;EAA3C,UAAA,CACE,kBAACC,GAAD;GACO;GACL,SAASH,IAAU,YAAY;GAC/B,MAAK;GACL,MAAK;GACL,gBAAcA;GACF;GACZ,WAAU;GACV,UAAU,MAAU;IAElB,IADAI,IAAUC,CAAK,GACXA,EAAM,kBAAkB;IAC5B,IAAMC,IAAO,CAACN;IAEd,AADIC,MAAe,KAAA,KAAWJ,EAAYS,CAAI,GAC9CC,IAAmBD,CAAI;GACzB;GACA,GAAIX;GAEJ,UAAA,kBAAC,QAAD;IAAM,WAAU;IAAkB,eAAY;GAAQ,CAAA;EAChD,CAAA,GACPa,KAAY,kBAAC,QAAD;GAAM,WAAU;GAAoB;EAAe,CAAA,CAC3D;;AAEX,CAAC"}
|
|
@@ -6,39 +6,13 @@
|
|
|
6
6
|
cursor: pointer;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
.ds-switch__track {
|
|
9
|
+
.ds-switch__track.ds-button {
|
|
10
10
|
position: relative;
|
|
11
11
|
flex: none;
|
|
12
12
|
inline-size: var(--switch-width);
|
|
13
|
-
|
|
13
|
+
height: var(--switch-height);
|
|
14
14
|
padding: 0;
|
|
15
|
-
border: var(--control-border-width) solid var(--control-border-color);
|
|
16
15
|
border-radius: var(--radius-pill);
|
|
17
|
-
background: var(--field-rest);
|
|
18
|
-
cursor: pointer;
|
|
19
|
-
transition: background-color var(--duration-fast) var(--ease-standard);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
.ds-switch__track:hover:not(:disabled) {
|
|
23
|
-
background: var(--field-hover);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.ds-switch__track[aria-checked="true"] {
|
|
27
|
-
background: var(--color-primary);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.ds-switch__track[aria-checked="true"]:hover:not(:disabled) {
|
|
31
|
-
background: var(--color-primary-hover);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
.ds-switch__track:focus-visible {
|
|
35
|
-
outline: var(--control-border-width) solid var(--color-focus);
|
|
36
|
-
outline-offset: 2px;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.ds-switch__track:disabled {
|
|
40
|
-
opacity: 45%;
|
|
41
|
-
cursor: not-allowed;
|
|
42
16
|
}
|
|
43
17
|
|
|
44
18
|
.ds-switch__knob {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../Button/index.cjs");;/* empty css */let t=require("react"),n=require("react/jsx-runtime");function r(...e){return e.filter(Boolean).join(` `)}var i=(0,t.forwardRef)(function({value:i,defaultValue:a=[],onValueChange:o,placeholder:s=`Add a tag`,size:c=`md`,max:l,isDisabled:u=!1,isInvalid:d=!1,className:f,...p},m){let[h,g]=(0,t.useState)(a),_=i??h,[v,y]=(0,t.useState)(``),b=(0,t.useRef)(null),x=e=>{i===void 0&&g(e),o?.(e)},S=e=>{let t=e.trim();t&&!_.includes(t)&&(l!==void 0&&_.length>=l||x([..._,t]))};return(0,n.jsxs)(`div`,{className:r(`ds-field-skin`,`ds-tags`,f),"data-size":c,"data-disabled":u||void 0,"aria-invalid":d||void 0,onClick:()=>b.current?.focus(),children:[_.map(t=>(0,n.jsxs)(`span`,{className:`ds-tags__tag`,children:[t,(0,n.jsx)(e.Button,{variant:`simple`,size:`xs`,isIconOnly:!0,iconStart:`x`,"aria-label":`Remove ${t}`,isDisabled:u,onClick:e=>{e.stopPropagation(),x(_.filter(e=>e!==t))}})]},t)),(0,n.jsx)(`input`,{ref:e=>{b.current=e,typeof m==`function`?m(e):m&&(m.current=e)},type:`text`,className:`ds-tags__input`,value:v,placeholder:_.length===0?s:``,disabled:u,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Enter`||e.key===`,`?(e.preventDefault(),S(v),y(``)):e.key===`Backspace`&&v===``&&_.length>0&&x(_.slice(0,-1))},onBlur:()=>{S(v),y(``)},...p})]})});exports.TagsInput=i;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["forwardRef","useState","useRef","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["forwardRef","useState","useRef","Button","require_components_Button_index","react","react_jsx_runtime","cx","parts","TagsInput","rest","internal","setInternal","defaultValue","current","value","draft","setDraft","inputRef","commit","next","onValueChange","add","tag","raw","max","className","size","isDisabled","isInvalid","event","item","node","ref","placeholder"],"sources":["../../../src/components/TagsInput/index.tsx"],"sourcesContent":["import { forwardRef, useRef, useState, type KeyboardEvent } from \"react\";\nimport { Button } from \"../Button\";\nimport type { FieldSize } from \"../Field\";\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 {\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 id?: string;\n className?: string;\n \"aria-label\"?: string;\n \"aria-describedby\"?: 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 className,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState<string[]>(defaultValue);\n const current = value ?? internal;\n const [draft, setDraft] = useState(\"\");\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const commit = (next: string[]) => {\n if (value === undefined) setInternal(next);\n onValueChange?.(next);\n };\n\n const add = (raw: string) => {\n const tag = raw.trim();\n if (!tag || current.includes(tag)) return;\n if (max !== undefined && current.length >= max) return;\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 || undefined}\n onClick={() => inputRef.current?.focus()}\n >\n {current.map((tag) => (\n <span key={tag} className=\"ds-tags__tag\">\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\") ref(node);\n else if (ref) ref.current = node;\n }}\n type=\"text\"\n className=\"ds-tags__input\"\n value={draft}\n placeholder={current.length === 0 ? placeholder : \"\"}\n disabled={isDisabled}\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,2MAMA,SAASO,EAAG,GAAGC,EAAuC,CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,CACvC,CAsBA,IAAaC,GAAA,EAAYT,EAAAA,WAAAA,CAA6C,SACpE,CACE,QACA,eAAe,CAAC,EAChB,gBACA,cAAc,YACd,OAAO,KACP,MACA,aAAa,GACb,YAAY,GACZ,YACA,GAAGU,GAEL,EACA,CACA,GAAM,CAACC,EAAUC,IAAA,EAAeX,EAAAA,SAAAA,CAAmBY,CAAY,EACzDC,EAAUC,GAASJ,EACnB,CAACK,EAAOC,IAAA,EAAYhB,EAAAA,SAAAA,CAAS,EAAE,EAC/BiB,GAAA,EAAWhB,EAAAA,OAAAA,CAAgC,IAAI,EAE/CiB,EAAU,GAAmB,CAC7BJ,IAAU,IAAA,IAAWH,EAAYQ,CAAI,EACzCC,IAAgBD,CAAI,CACtB,EAEME,EAAO,GAAgB,CAC3B,IAAMC,EAAMC,EAAI,KAAK,EAChBD,GAAO,GAAQ,SAASA,CAAG,IAC5BE,IAAQ,IAAA,IAAaX,EAAQ,QAAUW,GAC3CN,EAA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1
|
+
import { Button as e } from "../Button/index.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import { forwardRef as t, useRef as n, useState as r } from "react";
|
|
4
4
|
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
@@ -21,18 +21,16 @@ var s = t(function({ value: t, defaultValue: s = [], onValueChange: c, placehold
|
|
|
21
21
|
onClick: () => S.current?.focus(),
|
|
22
22
|
children: [y.map((t) => /* @__PURE__ */ a("span", {
|
|
23
23
|
className: "ds-tags__tag",
|
|
24
|
-
children: [t, /* @__PURE__ */ i(
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
children: [t, /* @__PURE__ */ i(e, {
|
|
25
|
+
variant: "simple",
|
|
26
|
+
size: "xs",
|
|
27
|
+
isIconOnly: !0,
|
|
28
|
+
iconStart: "x",
|
|
27
29
|
"aria-label": `Remove ${t}`,
|
|
28
|
-
|
|
30
|
+
isDisabled: f,
|
|
29
31
|
onClick: (e) => {
|
|
30
32
|
e.stopPropagation(), C(y.filter((e) => e !== t));
|
|
31
|
-
}
|
|
32
|
-
children: /* @__PURE__ */ i(e, {
|
|
33
|
-
name: "x",
|
|
34
|
-
size: 16
|
|
35
|
-
})
|
|
33
|
+
}
|
|
36
34
|
})]
|
|
37
35
|
}, t)), /* @__PURE__ */ i("input", {
|
|
38
36
|
ref: (e) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["
|
|
1
|
+
{"version":3,"file":"index.js","names":["cx","parts","TagsInput","forwardRef","rest","internal","setInternal","useState","defaultValue","current","value","draft","setDraft","inputRef","useRef","commit","next","onValueChange","add","tag","raw","max","className","size","isDisabled","isInvalid","Button","event","item","node","ref","placeholder"],"sources":["../../../src/components/TagsInput/index.tsx"],"sourcesContent":["import { forwardRef, useRef, useState, type KeyboardEvent } from \"react\";\nimport { Button } from \"../Button\";\nimport type { FieldSize } from \"../Field\";\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 {\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 id?: string;\n className?: string;\n \"aria-label\"?: string;\n \"aria-describedby\"?: 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 className,\n ...rest\n },\n ref,\n) {\n const [internal, setInternal] = useState<string[]>(defaultValue);\n const current = value ?? internal;\n const [draft, setDraft] = useState(\"\");\n const inputRef = useRef<HTMLInputElement | null>(null);\n\n const commit = (next: string[]) => {\n if (value === undefined) setInternal(next);\n onValueChange?.(next);\n };\n\n const add = (raw: string) => {\n const tag = raw.trim();\n if (!tag || current.includes(tag)) return;\n if (max !== undefined && current.length >= max) return;\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 || undefined}\n onClick={() => inputRef.current?.focus()}\n >\n {current.map((tag) => (\n <span key={tag} className=\"ds-tags__tag\">\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\") ref(node);\n else if (ref) ref.current = node;\n }}\n type=\"text\"\n className=\"ds-tags__input\"\n value={draft}\n placeholder={current.length === 0 ? placeholder : \"\"}\n disabled={isDisabled}\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":";;;;;AAMA,SAASA,EAAG,GAAGC,GAAuC;CACpD,OAAOA,EAAM,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;AACvC;AAsBA,IAAaC,IAAYC,EAA6C,SACpE,EACE,UACA,kBAAe,CAAC,GAChB,kBACA,iBAAc,aACd,UAAO,MACP,QACA,gBAAa,IACb,eAAY,IACZ,cACA,GAAGC,KAEL,GACA;CACA,IAAM,CAACC,GAAUC,KAAeC,EAAmBC,CAAY,GACzDC,IAAUC,KAASL,GACnB,CAACM,GAAOC,KAAYL,EAAS,EAAE,GAC/BM,IAAWC,EAAgC,IAAI,GAE/CC,KAAU,MAAmB;EAEjC,AADIL,MAAU,KAAA,KAAWJ,EAAYU,CAAI,GACzCC,IAAgBD,CAAI;CACtB,GAEME,KAAO,MAAgB;EAC3B,IAAMC,IAAMC,EAAI,KAAK;EACrB,AAAKD,KAAO,GAAQ,SAASA,CAAG,MAC5BE,MAAQ,KAAA,KAAaZ,EAAQ,UAAUY,KAC3CN,EAAO,CAAC,GAAGN,GAASU,CAAG,CAAC;CAC1B;CAYA,OACE,kBAAC,OAAD;EACE,WAAWnB,EAAG,iBAAiB,WAAWsB,CAAS;EACnD,aAAWC;EACX,iBAAeC,KAAc,KAAA;EAC7B,gBAAcC,KAAa,KAAA;EAC3B,eAAeZ,EAAS,SAAS,MAAM;EALzC,UAAA,CAOGJ,EAAQ,KAAK,MACZ,kBAAC,QAAD;GAAgB,WAAU;GAA1B,UAAA,CACGU,GACD,kBAAC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