@allxsmith/bestax-bulma 5.62.0 → 5.64.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/dist/bestax.css +1 -1
  2. package/dist/bestax.css.map +1 -1
  3. package/dist/esm/components/EmptyState.js +2 -6
  4. package/dist/esm/components/EmptyState.js.map +1 -1
  5. package/dist/esm/components/ScrollArea.js +7 -7
  6. package/dist/esm/components/ScrollArea.js.map +1 -1
  7. package/dist/esm/components/TableOfContents.js +85 -0
  8. package/dist/esm/components/TableOfContents.js.map +1 -0
  9. package/dist/esm/components/Timeline.js +5 -9
  10. package/dist/esm/components/Timeline.js.map +1 -1
  11. package/dist/esm/components/TreeView.js +3 -7
  12. package/dist/esm/components/TreeView.js.map +1 -1
  13. package/dist/esm/elements/Buttons.js +2 -0
  14. package/dist/esm/elements/Buttons.js.map +1 -1
  15. package/dist/esm/elements/CopyButton.js +132 -0
  16. package/dist/esm/elements/CopyButton.js.map +1 -0
  17. package/dist/esm/elements/DescriptionList.js +1 -5
  18. package/dist/esm/elements/DescriptionList.js.map +1 -1
  19. package/dist/esm/elements/Stat.js +196 -0
  20. package/dist/esm/elements/Stat.js.map +1 -0
  21. package/dist/esm/elements/Stats.js +48 -0
  22. package/dist/esm/elements/Stats.js.map +1 -0
  23. package/dist/esm/elements/statContext.js +10 -0
  24. package/dist/esm/elements/statContext.js.map +1 -0
  25. package/dist/esm/form/Combobox.js +2 -1
  26. package/dist/esm/form/Combobox.js.map +1 -1
  27. package/dist/esm/form/PasswordInput.js +105 -0
  28. package/dist/esm/form/PasswordInput.js.map +1 -0
  29. package/dist/esm/form/PasswordInputBase.js +177 -0
  30. package/dist/esm/form/PasswordInputBase.js.map +1 -0
  31. package/dist/esm/helpers/checkIcon.js +20 -0
  32. package/dist/esm/helpers/checkIcon.js.map +1 -0
  33. package/dist/esm/helpers/isGiven.js +13 -0
  34. package/dist/esm/helpers/isGiven.js.map +1 -0
  35. package/dist/esm/helpers/statusRegion.js +3 -3
  36. package/dist/esm/helpers/useClipboard.js +176 -0
  37. package/dist/esm/helpers/useClipboard.js.map +1 -0
  38. package/dist/esm/helpers/useScrollSpy.js +286 -0
  39. package/dist/esm/helpers/useScrollSpy.js.map +1 -0
  40. package/dist/extras.css +1 -1
  41. package/dist/extras.css.map +1 -1
  42. package/dist/index.cjs +2671 -1544
  43. package/dist/index.cjs.map +1 -1
  44. package/dist/index.esm.js +8 -0
  45. package/dist/index.esm.js.map +1 -1
  46. package/dist/types/components/TableOfContents.d.ts +87 -0
  47. package/dist/types/elements/Buttons.d.ts +1 -0
  48. package/dist/types/elements/CopyButton.d.ts +105 -0
  49. package/dist/types/elements/Stat.d.ts +242 -0
  50. package/dist/types/elements/Stats.d.ts +40 -0
  51. package/dist/types/elements/statContext.d.ts +18 -0
  52. package/dist/types/form/PasswordInput.d.ts +98 -0
  53. package/dist/types/form/PasswordInputBase.d.ts +91 -0
  54. package/dist/types/helpers/checkIcon.d.ts +10 -0
  55. package/dist/types/helpers/isGiven.d.ts +7 -0
  56. package/dist/types/helpers/useClipboard.d.ts +65 -0
  57. package/dist/types/helpers/useScrollSpy.d.ts +61 -0
  58. package/dist/types/index.d.ts +10 -0
  59. package/dist/types-cjs/components/TableOfContents.d.ts +87 -0
  60. package/dist/types-cjs/elements/Buttons.d.ts +1 -0
  61. package/dist/types-cjs/elements/CopyButton.d.ts +105 -0
  62. package/dist/types-cjs/elements/Stat.d.ts +242 -0
  63. package/dist/types-cjs/elements/Stats.d.ts +40 -0
  64. package/dist/types-cjs/elements/statContext.d.ts +18 -0
  65. package/dist/types-cjs/form/PasswordInput.d.ts +98 -0
  66. package/dist/types-cjs/form/PasswordInputBase.d.ts +91 -0
  67. package/dist/types-cjs/helpers/checkIcon.d.ts +10 -0
  68. package/dist/types-cjs/helpers/isGiven.d.ts +7 -0
  69. package/dist/types-cjs/helpers/useClipboard.d.ts +65 -0
  70. package/dist/types-cjs/helpers/useScrollSpy.d.ts +61 -0
  71. package/dist/types-cjs/index.d.ts +10 -0
  72. package/dist/versions/bestax-no-dark-mode.css +1 -1
  73. package/dist/versions/bestax-no-dark-mode.css.map +1 -1
  74. package/dist/versions/bestax-no-helpers-prefixed.css +1 -1
  75. package/dist/versions/bestax-no-helpers-prefixed.css.map +1 -1
  76. package/dist/versions/bestax-no-helpers.css +1 -1
  77. package/dist/versions/bestax-no-helpers.css.map +1 -1
  78. package/dist/versions/bestax-prefixed.css +1 -1
  79. package/dist/versions/bestax-prefixed.css.map +1 -1
  80. package/package.json +1 -1
  81. package/src/scss/CLAUDE.md +3 -0
  82. package/src/scss/_input-trigger.scss +76 -0
  83. package/src/scss/components/_index.scss +1 -0
  84. package/src/scss/components/_tableofcontents.scss +42 -0
  85. package/src/scss/elements/_index.scss +1 -0
  86. package/src/scss/elements/_stat.scss +153 -0
  87. package/src/scss/form/_index.scss +1 -0
  88. package/src/scss/form/_passwordinput.scss +112 -0
  89. package/src/scss/form/_picker-popover.scss +24 -63
@@ -0,0 +1,196 @@
1
+ /* @allxsmith/bestax-bulma — AI agents: see AGENTS.md in the package root, or https://bestax.io/llms.txt */
2
+ 'use client';
3
+ import { jsx, jsxs } from 'react/jsx-runtime';
4
+ import React, { forwardRef, useContext, useEffect, useMemo } from 'react';
5
+ import { usePrefixedClassNames, classNames } from '../helpers/classNames.js';
6
+ import { useBulmaClasses } from '../helpers/useBulmaClasses.js';
7
+ import { withSubComponents } from '../helpers/withSubComponents.js';
8
+ import { isGiven } from '../helpers/isGiven.js';
9
+ import { flattenChildren } from '../helpers/flattenChildren.js';
10
+ import { useNumberFormat } from '../helpers/localeFormat.js';
11
+ import { warnOnce } from '../helpers/devWarnings.js';
12
+ import { NumberFormatter } from './NumberFormatter.js';
13
+ import { Skeleton } from './Skeleton.js';
14
+ import { StatScopeContext } from './statContext.js';
15
+
16
+ /** How a change is written when no format is given: a signed percentage. */
17
+ const DEFAULT_CHANGE_FORMAT = {
18
+ style: 'percent',
19
+ signDisplay: 'exceptZero',
20
+ maximumFractionDigits: 1,
21
+ };
22
+ /**
23
+ * What the figure is: a `<dt>`, small and in the weaker text color.
24
+ *
25
+ * @function
26
+ * @param {StatLabelProps} props - Props for Stat.Label.
27
+ * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the `<dt>`.
28
+ * @returns {JSX.Element} The rendered label.
29
+ *
30
+ * @example
31
+ * <Stat.Label>Revenue</Stat.Label>
32
+ */
33
+ const StatLabel = forwardRef(({ className, textColor, bgColor, children, ...props }, ref) => {
34
+ const { bulmaHelperClasses, rest } = useBulmaClasses({
35
+ color: textColor,
36
+ backgroundColor: bgColor,
37
+ ...props,
38
+ });
39
+ const labelClass = usePrefixedClassNames('stat-label');
40
+ return (jsx("dt", { ref: ref, className: classNames(labelClass, bulmaHelperClasses, className), ...rest, children: children }));
41
+ });
42
+ StatLabel.displayName = 'Stat.Label';
43
+ /**
44
+ * The figure: a `<dd>`, large, in the Stat's color, with digits of one width so a figure that updates doesn't shift.
45
+ *
46
+ * @function
47
+ * @param {StatValueProps} props - Props for Stat.Value.
48
+ * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the `<dd>`.
49
+ * @returns {JSX.Element} The rendered figure.
50
+ *
51
+ * @example
52
+ * <Stat.Value>
53
+ * <NumberFormatter value={182} format={{ style: 'unit', unit: 'millisecond' }} />
54
+ * </Stat.Value>
55
+ */
56
+ const StatValue = forwardRef(({ className, textColor, bgColor, children, ...props }, ref) => {
57
+ const { bulmaHelperClasses, rest } = useBulmaClasses({
58
+ color: textColor,
59
+ backgroundColor: bgColor,
60
+ ...props,
61
+ });
62
+ const valueClass = usePrefixedClassNames('stat-value');
63
+ return (jsx("dd", { ref: ref, className: classNames(valueClass, bulmaHelperClasses, className), ...rest, children: children }));
64
+ });
65
+ StatValue.displayName = 'Stat.Value';
66
+ /**
67
+ * A note under the figure: a `<dd>`, small and in the weaker text color.
68
+ *
69
+ * @function
70
+ * @param {StatDescriptionProps} props - Props for Stat.Description.
71
+ * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the `<dd>`.
72
+ * @returns {JSX.Element} The rendered note.
73
+ *
74
+ * @example
75
+ * <Stat.Description>since last month</Stat.Description>
76
+ */
77
+ const StatDescription = forwardRef(({ className, textColor, bgColor, children, ...props }, ref) => {
78
+ const { bulmaHelperClasses, rest } = useBulmaClasses({
79
+ color: textColor,
80
+ backgroundColor: bgColor,
81
+ ...props,
82
+ });
83
+ const descriptionClass = usePrefixedClassNames('stat-description');
84
+ return (jsx("dd", { ref: ref, className: classNames(descriptionClass, bulmaHelperClasses, className), ...rest, children: children }));
85
+ });
86
+ StatDescription.displayName = 'Stat.Description';
87
+ /**
88
+ * A change written with its sign, such as "+12%", after an arrow that repeats the direction: a `<dd>`, green when it's up and red when it's down unless `color` says otherwise.
89
+ *
90
+ * The sign is in the text, written by `Intl` for the locale, so a screen
91
+ * reader hears the direction; the arrow is hidden from assistive tech, and
92
+ * the color repeats the direction for sighted readers rather than carry it.
93
+ *
94
+ * @function
95
+ * @param {StatChangeProps} props - Props for Stat.Change.
96
+ * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the `<dd>`.
97
+ * @returns {JSX.Element} The rendered change.
98
+ *
99
+ * @example
100
+ * <Stat.Change value={-0.08} color="success" />
101
+ */
102
+ const StatChange = forwardRef(({ className, value, format, locale, color, ...props }, ref) => {
103
+ const { bulmaHelperClasses, rest } = useBulmaClasses(props);
104
+ const scope = useContext(StatScopeContext);
105
+ const ownLocale = locale || scope.locale;
106
+ const options = format
107
+ ? { ...format, signDisplay: format.signDisplay || 'exceptZero' }
108
+ : DEFAULT_CHANGE_FORMAT;
109
+ // A change that rounds to zero gets no arrow and no tone, which would
110
+ // contradict a figure of zero. `Intl` writes no sign with 'exceptZero'
111
+ // only when the value rounds to zero, by whatever rounding the options
112
+ // ask for, so the change written that way is zero's text exactly then.
113
+ const formatNumber = useNumberFormat(ownLocale);
114
+ const signed = { ...options, signDisplay: 'exceptZero' };
115
+ const direction = formatNumber(value, signed) === formatNumber(0, signed)
116
+ ? 0
117
+ : Math.sign(value);
118
+ const tone = color ||
119
+ (direction > 0 ? 'success' : direction < 0 ? 'danger' : undefined);
120
+ const changeClass = usePrefixedClassNames('stat-change', {
121
+ [`is-${tone}`]: !!tone,
122
+ });
123
+ return (jsxs("dd", { ref: ref, className: classNames(changeClass, bulmaHelperClasses, className), ...rest, children: [(direction > 0 || direction < 0) && (jsx("svg", { viewBox: "0 0 16 16", width: "1em", height: "1em", "aria-hidden": "true", children: jsx("path", { d: direction > 0
124
+ ? 'M8 13V3M3.5 7.5 8 3l4.5 4.5'
125
+ : 'M8 3v10M3.5 8.5 8 13l4.5-4.5', fill: "none", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", strokeLinejoin: "round" }) })), jsx(NumberFormatter, { value: value, format: options, locale: ownLocale })] }));
126
+ });
127
+ StatChange.displayName = 'Stat.Change';
128
+ /**
129
+ * The `Stat` component shows a figure with its name, and often a change and a note, such as a dashboard's revenue or an account's storage used.
130
+ *
131
+ * It's a label and its values in a description list: a `<dt>` for the
132
+ * label, and a `<dd>` each for the figure, the change and the note. On its
133
+ * own it renders its own `<dl>`; inside `Stats` it's a `<div>` in the row's.
134
+ * A number `value` is written by `NumberFormatter`, so it follows a
135
+ * `LocaleProvider`. A change is written with its sign ("+12%"), so the
136
+ * direction is in the text, beside a decorative arrow and a color.
137
+ *
138
+ * @function
139
+ * @param {StatProps} props - Props for the Stat component.
140
+ * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the root.
141
+ * @returns {JSX.Element} The rendered stat.
142
+ *
143
+ * @example
144
+ * <Stat
145
+ * label="Revenue"
146
+ * value={8456.4}
147
+ * format={{ style: 'currency', currency: 'USD' }}
148
+ * change={0.12}
149
+ * description="since last month"
150
+ * />
151
+ */
152
+ const StatRoot = forwardRef(({ className, label, value, format, locale, change, changeFormat, changeColor, description, size, loading, textColor, bgColor, children, ...props }, ref) => {
153
+ const scope = useContext(StatScopeContext);
154
+ const { bulmaHelperClasses, rest } = useBulmaClasses({
155
+ color: textColor || scope.textColor,
156
+ backgroundColor: bgColor,
157
+ ...props,
158
+ });
159
+ const statClass = usePrefixedClassNames('stat', {
160
+ [`is-${size}`]: !!size,
161
+ });
162
+ // The parts given as children, by type, so the figure's `<dd>` and the
163
+ // warning below know what's there. A part rendered from inside another
164
+ // component isn't seen.
165
+ const parts = flattenChildren(children);
166
+ const hasPart = (type) => parts.some(part => React.isValidElement(part) && part.type === type);
167
+ const hasValuePart = hasPart(StatValue);
168
+ const labelled = isGiven(label) || hasPart(StatLabel);
169
+ // Without a label, the figure has no name and the values no term.
170
+ useEffect(() => {
171
+ if (!labelled) {
172
+ warnOnce('Stat:unlabelled', '[bestax-bulma] <Stat> has no label. Pass label, or a Stat.Label ' +
173
+ 'child, so the figure has a name for assistive tech and its ' +
174
+ 'values have a term in the list.');
175
+ }
176
+ }, [labelled]);
177
+ // Its parts take its locale and leave the row, so a Stat inside one of
178
+ // them, in a `<dd>`, renders a `<dl>` of its own.
179
+ const inner = useMemo(() => ({ row: false, locale }), [locale]);
180
+ const Root = scope.row ? 'div' : 'dl';
181
+ const figure = loading ? (jsx(Skeleton, {})) : typeof value === 'number' ? (jsx(NumberFormatter, { value: value, format: format, locale: locale })) : isGiven(value) ? (value) : null;
182
+ // A `Stat.Value` child is the figure. Without one, the figure's `<dd>`
183
+ // renders for a figure, or for a label, empty while the figure is
184
+ // missing, so the label keeps its definition.
185
+ const showsFigure = !hasValuePart && (figure !== null || labelled);
186
+ return (jsx(Root, { ref: ref, className: classNames(statClass, bulmaHelperClasses, className), ...rest, "aria-busy": loading || rest['aria-busy'], children: jsxs(StatScopeContext.Provider, { value: inner, children: [isGiven(label) && jsx(StatLabel, { children: label }), children, showsFigure && jsx(StatValue, { children: figure }), typeof change === 'number' && (jsx(StatChange, { value: change, format: changeFormat, color: changeColor })), isGiven(description) && (jsx(StatDescription, { children: description }))] }) }));
187
+ });
188
+ const Stat = withSubComponents(StatRoot, {
189
+ Label: StatLabel,
190
+ Value: StatValue,
191
+ Change: StatChange,
192
+ Description: StatDescription,
193
+ }, 'Stat');
194
+
195
+ export { Stat, StatChange, StatDescription, StatLabel, StatValue };
196
+ //# sourceMappingURL=Stat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Stat.js","sources":["../../../src/elements/Stat.tsx"],"sourcesContent":["import React, { forwardRef, useContext, useEffect, useMemo } from 'react';\nimport { classNames, usePrefixedClassNames } from '../helpers/classNames';\nimport {\n useBulmaClasses,\n BulmaClassesProps,\n validColors,\n} from '../helpers/useBulmaClasses';\nimport { withSubComponents } from '../helpers/withSubComponents';\nimport { isGiven } from '../helpers/isGiven';\nimport { flattenChildren } from '../helpers/flattenChildren';\nimport { useNumberFormat } from '../helpers/localeFormat';\nimport { warnOnce } from '../helpers/devWarnings';\nimport { NumberFormatter } from './NumberFormatter';\nimport { Skeleton } from './Skeleton';\nimport { StatScopeContext } from './statContext';\n\n/** The colors a Stat's change can take, the union `messageColor` takes. */\nexport type StatChangeColor =\n 'primary' | 'link' | 'info' | 'success' | 'warning' | 'danger';\n\n/** How a change is written when no format is given: a signed percentage. */\nconst DEFAULT_CHANGE_FORMAT: Intl.NumberFormatOptions = {\n style: 'percent',\n signDisplay: 'exceptZero',\n maximumFractionDigits: 1,\n};\n\n/**\n * Props for the Stat component. The helper props, the other attributes and\n * the `ref` land on its root: a `<div>` inside `Stats`, or its own `<dl>` on\n * its own.\n *\n * @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the root, a `<div>` inside `Stats` or a `<dl>` on its own.\n */\nexport interface StatProps\n extends\n Omit<React.HTMLAttributes<HTMLElement>, 'color'>,\n Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {\n /** Additional CSS classes to apply. */\n className?: string;\n /**\n * What the figure is (\"Revenue\"), as a `Stat.Label` before the children.\n * A Stat needs one, here or as a `Stat.Label` child: it's the figure's\n * name for assistive tech, and a definition list's values belong to a\n * term. A Stat with neither a `label` nor a `Stat.Label` child warns in\n * development.\n */\n label?: React.ReactNode;\n /**\n * The figure, as a `Stat.Value` after the children. A number is written by\n * `NumberFormatter` with `format` and `locale`; anything else, such as\n * \"N/A\", renders as given, and `0` renders. `undefined`, `null`, a boolean\n * and `''` leave it empty, and its `<dd>` still renders, one line of the\n * figure tall, while the Stat has a label, so the label keeps its\n * definition while the figure is missing. A `Stat.Value` child takes its\n * place: with one, `value` and its `<dd>` are left out.\n */\n value?: React.ReactNode;\n /**\n * `Intl.NumberFormat` options for a number `value`, as NumberFormatter's\n * `format`. A `value` that isn't a number ignores it.\n */\n format?: Intl.NumberFormatOptions;\n /**\n * The locale for `value` and `change`, as NumberFormatter's `locale`.\n * Unset, it's the `LocaleProvider`'s around it, and with neither, the\n * runtime's own, so give one, here or through a `LocaleProvider`, on a\n * page rendered on the server.\n */\n locale?: string;\n /**\n * The change, as a `Stat.Change` after the value. With the default format\n * it's a fraction (`0.12` for 12%); with your own `changeFormat`, it's in\n * that format's terms. It's written with its sign, so the direction is in\n * the text.\n */\n change?: number;\n /**\n * `Intl.NumberFormat` options for `change`. Yours replace the default, and\n * `signDisplay: 'exceptZero'` is added unless you set a `signDisplay`. With\n * `signDisplay: 'never'`, or `'negative'` on a rise, the text carries no\n * direction: the arrow is hidden from assistive tech and the tone is color\n * alone, so keep a sign, or say the direction in `description`.\n * @defaultValue { style: 'percent', signDisplay: 'exceptZero', maximumFractionDigits: 1 }\n */\n changeFormat?: Intl.NumberFormatOptions;\n /**\n * The change's color. Unset, it's the sign's: `success` up, `danger` down,\n * and none at zero. Set it where up is bad news, such as a cost or an\n * error rate.\n */\n changeColor?: StatChangeColor;\n /** A note under the figure (\"since last month\"), as a `Stat.Description` last. */\n description?: React.ReactNode;\n /**\n * The figure's size, a step of Bulma's size scale. The label, the change\n * and the note stay small.\n */\n size?: 'small' | 'medium' | 'large';\n /**\n * Shows a `Skeleton` in place of `value`, one line of the figure tall,\n * and sets `aria-busy` on the Stat. The label, the change and the note\n * render as given. With a `Stat.Value` child, it only sets `aria-busy`:\n * the child renders as given, so put a `Skeleton` in it yourself.\n */\n loading?: boolean;\n /**\n * `Stat.Label`, `Stat.Value`, `Stat.Change` and `Stat.Description`, for\n * anything the props don't cover, such as a unit or an info tip. They\n * render between `label` and `value`. They're this Stat's own parts, so\n * not another Stat: that would be a list inside this one's. The Stat finds\n * a `Stat.Label` or `Stat.Value` among them by type, so one rendered from\n * inside a component of your own isn't seen.\n */\n children?: React.ReactNode;\n /**\n * Text color helper. It colors the figure; the label, the change and the\n * note keep their own colors. Inside `Stats`, a Stat without one takes the\n * row's.\n */\n textColor?: (typeof validColors)[number] | 'inherit' | 'current';\n /** Background color helper. */\n bgColor?: (typeof validColors)[number] | 'inherit' | 'current';\n}\n\n/**\n * Props for Stat.Label, what the figure is. The helper props, the other\n * attributes and the `ref` land on its `<dt>`.\n *\n * @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the `<dt>`.\n */\nexport interface StatLabelProps\n extends\n Omit<React.HTMLAttributes<HTMLElement>, 'color'>,\n Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {\n /** Additional CSS classes to apply. */\n className?: string;\n /**\n * The label. A button may sit in it, such as one that opens a `Popover`\n * about the figure, but not a heading, which HTML doesn't allow here.\n */\n children?: React.ReactNode;\n /** Text color helper. */\n textColor?: (typeof validColors)[number] | 'inherit' | 'current';\n /** Background color helper. */\n bgColor?: (typeof validColors)[number] | 'inherit' | 'current';\n}\n\n/**\n * Props for Stat.Value, the figure. The helper props, the other attributes\n * and the `ref` land on its `<dd>`.\n *\n * @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the `<dd>`.\n */\nexport interface StatValueProps\n extends\n Omit<React.HTMLAttributes<HTMLElement>, 'color'>,\n Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {\n /** Additional CSS classes to apply. */\n className?: string;\n /**\n * The figure, written as you give it, so write a number with\n * `NumberFormatter`.\n */\n children?: React.ReactNode;\n /** Text color helper. */\n textColor?: (typeof validColors)[number] | 'inherit' | 'current';\n /** Background color helper. */\n bgColor?: (typeof validColors)[number] | 'inherit' | 'current';\n}\n\n/**\n * Props for Stat.Description, a note under the figure. The helper props, the\n * other attributes and the `ref` land on its `<dd>`.\n *\n * @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the `<dd>`.\n */\nexport interface StatDescriptionProps\n extends\n Omit<React.HTMLAttributes<HTMLElement>, 'color'>,\n Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {\n /** Additional CSS classes to apply. */\n className?: string;\n /** The note, such as \"since last month\". */\n children?: React.ReactNode;\n /** Text color helper. */\n textColor?: (typeof validColors)[number] | 'inherit' | 'current';\n /** Background color helper. */\n bgColor?: (typeof validColors)[number] | 'inherit' | 'current';\n}\n\n/**\n * Props for Stat.Change, a change written with its sign. The helper props,\n * the other attributes and the `ref` land on its `<dd>`.\n *\n * @extraProp {React.Ref<HTMLElement>} [ref] - Ref forwarded to the `<dd>`.\n */\nexport interface StatChangeProps\n extends\n Omit<React.HTMLAttributes<HTMLElement>, 'color' | 'children'>,\n Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {\n /** Additional CSS classes to apply. */\n className?: string;\n /**\n * The change, as Stat's `change`. One that rounds to zero in its format,\n * such as `0.0004` at one decimal place of a percentage, reads as zero, so\n * it gets no arrow and no color of its own.\n */\n value: number;\n /**\n * As Stat's `changeFormat`: yours replace the default, and\n * `signDisplay: 'exceptZero'` is added unless you set a `signDisplay`.\n * @defaultValue { style: 'percent', signDisplay: 'exceptZero', maximumFractionDigits: 1 }\n */\n format?: Intl.NumberFormatOptions;\n /** As Stat's `locale`. Unset, the Stat's. */\n locale?: string;\n /**\n * As Stat's `changeColor`. Unset, it's the sign's: `success` up, `danger`\n * down, and none at zero. Set, it applies at zero too.\n */\n color?: StatChangeColor;\n}\n\n/**\n * What the figure is: a `<dt>`, small and in the weaker text color.\n *\n * @function\n * @param {StatLabelProps} props - Props for Stat.Label.\n * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the `<dt>`.\n * @returns {JSX.Element} The rendered label.\n *\n * @example\n * <Stat.Label>Revenue</Stat.Label>\n */\nexport const StatLabel = forwardRef<HTMLElement, StatLabelProps>(\n ({ className, textColor, bgColor, children, ...props }, ref) => {\n const { bulmaHelperClasses, rest } = useBulmaClasses({\n color: textColor,\n backgroundColor: bgColor,\n ...props,\n });\n const labelClass = usePrefixedClassNames('stat-label');\n return (\n <dt\n ref={ref}\n className={classNames(labelClass, bulmaHelperClasses, className)}\n {...rest}\n >\n {children}\n </dt>\n );\n }\n);\n\nStatLabel.displayName = 'Stat.Label';\n\n/**\n * The figure: a `<dd>`, large, in the Stat's color, with digits of one width so a figure that updates doesn't shift.\n *\n * @function\n * @param {StatValueProps} props - Props for Stat.Value.\n * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the `<dd>`.\n * @returns {JSX.Element} The rendered figure.\n *\n * @example\n * <Stat.Value>\n * <NumberFormatter value={182} format={{ style: 'unit', unit: 'millisecond' }} />\n * </Stat.Value>\n */\nexport const StatValue = forwardRef<HTMLElement, StatValueProps>(\n ({ className, textColor, bgColor, children, ...props }, ref) => {\n const { bulmaHelperClasses, rest } = useBulmaClasses({\n color: textColor,\n backgroundColor: bgColor,\n ...props,\n });\n const valueClass = usePrefixedClassNames('stat-value');\n return (\n <dd\n ref={ref}\n className={classNames(valueClass, bulmaHelperClasses, className)}\n {...rest}\n >\n {children}\n </dd>\n );\n }\n);\n\nStatValue.displayName = 'Stat.Value';\n\n/**\n * A note under the figure: a `<dd>`, small and in the weaker text color.\n *\n * @function\n * @param {StatDescriptionProps} props - Props for Stat.Description.\n * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the `<dd>`.\n * @returns {JSX.Element} The rendered note.\n *\n * @example\n * <Stat.Description>since last month</Stat.Description>\n */\nexport const StatDescription = forwardRef<HTMLElement, StatDescriptionProps>(\n ({ className, textColor, bgColor, children, ...props }, ref) => {\n const { bulmaHelperClasses, rest } = useBulmaClasses({\n color: textColor,\n backgroundColor: bgColor,\n ...props,\n });\n const descriptionClass = usePrefixedClassNames('stat-description');\n return (\n <dd\n ref={ref}\n className={classNames(descriptionClass, bulmaHelperClasses, className)}\n {...rest}\n >\n {children}\n </dd>\n );\n }\n);\n\nStatDescription.displayName = 'Stat.Description';\n\n/**\n * A change written with its sign, such as \"+12%\", after an arrow that repeats the direction: a `<dd>`, green when it's up and red when it's down unless `color` says otherwise.\n *\n * The sign is in the text, written by `Intl` for the locale, so a screen\n * reader hears the direction; the arrow is hidden from assistive tech, and\n * the color repeats the direction for sighted readers rather than carry it.\n *\n * @function\n * @param {StatChangeProps} props - Props for Stat.Change.\n * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the `<dd>`.\n * @returns {JSX.Element} The rendered change.\n *\n * @example\n * <Stat.Change value={-0.08} color=\"success\" />\n */\nexport const StatChange = forwardRef<HTMLElement, StatChangeProps>(\n ({ className, value, format, locale, color, ...props }, ref) => {\n const { bulmaHelperClasses, rest } = useBulmaClasses(props);\n const scope = useContext(StatScopeContext);\n const ownLocale = locale || scope.locale;\n const options = format\n ? { ...format, signDisplay: format.signDisplay || 'exceptZero' }\n : DEFAULT_CHANGE_FORMAT;\n // A change that rounds to zero gets no arrow and no tone, which would\n // contradict a figure of zero. `Intl` writes no sign with 'exceptZero'\n // only when the value rounds to zero, by whatever rounding the options\n // ask for, so the change written that way is zero's text exactly then.\n const formatNumber = useNumberFormat(ownLocale);\n const signed = { ...options, signDisplay: 'exceptZero' as const };\n const direction =\n formatNumber(value, signed) === formatNumber(0, signed)\n ? 0\n : Math.sign(value);\n const tone =\n color ||\n (direction > 0 ? 'success' : direction < 0 ? 'danger' : undefined);\n const changeClass = usePrefixedClassNames('stat-change', {\n [`is-${tone}`]: !!tone,\n });\n return (\n <dd\n ref={ref}\n className={classNames(changeClass, bulmaHelperClasses, className)}\n {...rest}\n >\n {(direction > 0 || direction < 0) && (\n <svg viewBox=\"0 0 16 16\" width=\"1em\" height=\"1em\" aria-hidden=\"true\">\n <path\n d={\n direction > 0\n ? 'M8 13V3M3.5 7.5 8 3l4.5 4.5'\n : 'M8 3v10M3.5 8.5 8 13l4.5-4.5'\n }\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"1.75\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n )}\n <NumberFormatter value={value} format={options} locale={ownLocale} />\n </dd>\n );\n }\n);\n\nStatChange.displayName = 'Stat.Change';\n\n/**\n * The `Stat` component shows a figure with its name, and often a change and a note, such as a dashboard's revenue or an account's storage used.\n *\n * It's a label and its values in a description list: a `<dt>` for the\n * label, and a `<dd>` each for the figure, the change and the note. On its\n * own it renders its own `<dl>`; inside `Stats` it's a `<div>` in the row's.\n * A number `value` is written by `NumberFormatter`, so it follows a\n * `LocaleProvider`. A change is written with its sign (\"+12%\"), so the\n * direction is in the text, beside a decorative arrow and a color.\n *\n * @function\n * @param {StatProps} props - Props for the Stat component.\n * @param {React.Ref<HTMLElement>} ref - Forwarded ref to the root.\n * @returns {JSX.Element} The rendered stat.\n *\n * @example\n * <Stat\n * label=\"Revenue\"\n * value={8456.4}\n * format={{ style: 'currency', currency: 'USD' }}\n * change={0.12}\n * description=\"since last month\"\n * />\n */\nconst StatRoot = forwardRef<HTMLElement, StatProps>(\n (\n {\n className,\n label,\n value,\n format,\n locale,\n change,\n changeFormat,\n changeColor,\n description,\n size,\n loading,\n textColor,\n bgColor,\n children,\n ...props\n },\n ref\n ) => {\n const scope = useContext(StatScopeContext);\n const { bulmaHelperClasses, rest } = useBulmaClasses({\n color: textColor || scope.textColor,\n backgroundColor: bgColor,\n ...props,\n });\n const statClass = usePrefixedClassNames('stat', {\n [`is-${size}`]: !!size,\n });\n // The parts given as children, by type, so the figure's `<dd>` and the\n // warning below know what's there. A part rendered from inside another\n // component isn't seen.\n const parts = flattenChildren(children);\n const hasPart = (type: unknown) =>\n parts.some(part => React.isValidElement(part) && part.type === type);\n const hasValuePart = hasPart(StatValue);\n const labelled = isGiven(label) || hasPart(StatLabel);\n // Without a label, the figure has no name and the values no term.\n useEffect(() => {\n if (!labelled) {\n warnOnce(\n 'Stat:unlabelled',\n '[bestax-bulma] <Stat> has no label. Pass label, or a Stat.Label ' +\n 'child, so the figure has a name for assistive tech and its ' +\n 'values have a term in the list.'\n );\n }\n }, [labelled]);\n // Its parts take its locale and leave the row, so a Stat inside one of\n // them, in a `<dd>`, renders a `<dl>` of its own.\n const inner = useMemo(() => ({ row: false, locale }), [locale]);\n const Root = scope.row ? 'div' : 'dl';\n const figure = loading ? (\n <Skeleton />\n ) : typeof value === 'number' ? (\n <NumberFormatter value={value} format={format} locale={locale} />\n ) : isGiven(value) ? (\n value\n ) : null;\n // A `Stat.Value` child is the figure. Without one, the figure's `<dd>`\n // renders for a figure, or for a label, empty while the figure is\n // missing, so the label keeps its definition.\n const showsFigure = !hasValuePart && (figure !== null || labelled);\n return (\n <Root\n ref={ref as React.Ref<HTMLDivElement & HTMLDListElement>}\n className={classNames(statClass, bulmaHelperClasses, className)}\n {...rest}\n aria-busy={loading || rest['aria-busy']}\n >\n <StatScopeContext.Provider value={inner}>\n {isGiven(label) && <StatLabel>{label}</StatLabel>}\n {children}\n {showsFigure && <StatValue>{figure}</StatValue>}\n {typeof change === 'number' && (\n <StatChange\n value={change}\n format={changeFormat}\n color={changeColor}\n />\n )}\n {isGiven(description) && (\n <StatDescription>{description}</StatDescription>\n )}\n </StatScopeContext.Provider>\n </Root>\n );\n }\n);\n\nexport const Stat = withSubComponents(\n StatRoot,\n {\n Label: StatLabel,\n Value: StatValue,\n Change: StatChange,\n Description: StatDescription,\n },\n 'Stat'\n);\n\nexport default Stat;\n"],"names":["_jsx","_jsxs"],"mappings":";;;;;;;;;;;;;;;AAoBA;AACA,MAAM,qBAAqB,GAA6B;AACtD,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,WAAW,EAAE,YAAY;AACzB,IAAA,qBAAqB,EAAE,CAAC;CACzB;AAuMD;;;;;;;;;;A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WAAW,EAAE,eAAe;CAC7B,EACD,MAAM;;"}
@@ -0,0 +1,48 @@
1
+ /* @allxsmith/bestax-bulma — AI agents: see AGENTS.md in the package root, or https://bestax.io/llms.txt */
2
+ 'use client';
3
+ import { jsx } from 'react/jsx-runtime';
4
+ import { forwardRef, useMemo } from 'react';
5
+ import { usePrefixedClassNames, classNames } from '../helpers/classNames.js';
6
+ import { useBulmaClasses } from '../helpers/useBulmaClasses.js';
7
+ import { withSubComponents } from '../helpers/withSubComponents.js';
8
+ import { Stat } from './Stat.js';
9
+ import { StatScopeContext } from './statContext.js';
10
+
11
+ /**
12
+ * The `Stats` component lays out a row of `Stat`s, such as the key figures at the top of a dashboard, as one description list on Bulma's smart grid.
13
+ *
14
+ * It's a `<dl>` with a `<div>` for each Stat, so a screen reader announces
15
+ * the row once, then each label with its values. The tiles fill the grid's
16
+ * columns, each at least `minCol` wide, and wrap without media queries;
17
+ * the `gap` helper prop sets the space between them. Name the row with
18
+ * `aria-labelledby` pointing at the heading above it. `Stat` is also
19
+ * `Stats.Stat`.
20
+ *
21
+ * @function
22
+ * @param {StatsProps} props - Props for the Stats component.
23
+ * @param {React.Ref<HTMLDListElement>} ref - Forwarded ref to the `<dl>`.
24
+ * @returns {JSX.Element} The rendered row.
25
+ *
26
+ * @example
27
+ * <Stats aria-labelledby="kpis" minCol={8} gap="4">
28
+ * <Stat label="Revenue" value={8456.4} format={{ style: 'currency', currency: 'USD' }} />
29
+ * <Stat label="New customers" value={1234} change={-0.019} />
30
+ * </Stats>
31
+ */
32
+ const StatsRoot = forwardRef(({ className, minCol, textColor, bgColor, children, ...props }, ref) => {
33
+ const { bulmaHelperClasses, rest } = useBulmaClasses({
34
+ color: textColor,
35
+ backgroundColor: bgColor,
36
+ ...props,
37
+ });
38
+ const statsClass = usePrefixedClassNames('stats grid', {
39
+ [`is-col-min-${minCol}`]: minCol !== undefined && minCol !== null,
40
+ });
41
+ const scope = useMemo(() => ({ row: true, textColor }), [textColor]);
42
+ return (jsx("dl", { ref: ref, className: classNames(statsClass, bulmaHelperClasses, className), ...rest, children: jsx(StatScopeContext.Provider, { value: scope, children: children }) }));
43
+ });
44
+ StatsRoot.displayName = 'Stats';
45
+ const Stats = withSubComponents(StatsRoot, { Stat }, 'Stats');
46
+
47
+ export { Stats };
48
+ //# sourceMappingURL=Stats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Stats.js","sources":["../../../src/elements/Stats.tsx"],"sourcesContent":["import React, { forwardRef, useMemo } from 'react';\nimport { classNames, usePrefixedClassNames } from '../helpers/classNames';\nimport {\n useBulmaClasses,\n BulmaClassesProps,\n validColors,\n} from '../helpers/useBulmaClasses';\nimport { withSubComponents } from '../helpers/withSubComponents';\nimport type { BulmaMinColValue } from '../grid/Grid';\nimport { Stat } from './Stat';\nimport { StatScopeContext } from './statContext';\n\n/**\n * Props for the Stats component, a row of Stats on Bulma's smart grid. The\n * helper props, the other attributes and the `ref` land on its `<dl>`.\n *\n * @extraProp {React.Ref<HTMLDListElement>} [ref] - Ref forwarded to the `<dl>`.\n * @extraProp {BulmaGapStep} [gap] - The space between tiles (`is-gap-*`), the helper prop with the values Grid's `gap` takes.\n * @extraProp {string} [aria-labelledby] - The id of the heading above the row, which names it.\n */\nexport interface StatsProps\n extends\n Omit<React.HTMLAttributes<HTMLDListElement>, 'color'>,\n Omit<BulmaClassesProps, 'color' | 'backgroundColor'> {\n /** Additional CSS classes to apply. */\n className?: string;\n /** `Stat`s, one per figure, and nothing else: they're the groups of its `<dl>`. */\n children?: React.ReactNode;\n /**\n * The narrowest a tile gets before the row wraps (`is-col-min-*`), as\n * Grid's `minCol`: 1.5rem a step. Unset, it's Bulma's 9rem.\n */\n minCol?: BulmaMinColValue;\n /**\n * Text color helper: `has-text-*` on the `<dl>`, as on Buttons. Each Stat\n * in the row without a `textColor` of its own takes it too, which colors\n * its figure, since a Stat sets its own color. The labels, the changes and\n * the notes keep theirs.\n */\n textColor?: (typeof validColors)[number] | 'inherit' | 'current';\n /** Background color helper. */\n bgColor?: (typeof validColors)[number] | 'inherit' | 'current';\n}\n\n/**\n * The `Stats` component lays out a row of `Stat`s, such as the key figures at the top of a dashboard, as one description list on Bulma's smart grid.\n *\n * It's a `<dl>` with a `<div>` for each Stat, so a screen reader announces\n * the row once, then each label with its values. The tiles fill the grid's\n * columns, each at least `minCol` wide, and wrap without media queries;\n * the `gap` helper prop sets the space between them. Name the row with\n * `aria-labelledby` pointing at the heading above it. `Stat` is also\n * `Stats.Stat`.\n *\n * @function\n * @param {StatsProps} props - Props for the Stats component.\n * @param {React.Ref<HTMLDListElement>} ref - Forwarded ref to the `<dl>`.\n * @returns {JSX.Element} The rendered row.\n *\n * @example\n * <Stats aria-labelledby=\"kpis\" minCol={8} gap=\"4\">\n * <Stat label=\"Revenue\" value={8456.4} format={{ style: 'currency', currency: 'USD' }} />\n * <Stat label=\"New customers\" value={1234} change={-0.019} />\n * </Stats>\n */\nconst StatsRoot = forwardRef<HTMLDListElement, StatsProps>(\n ({ className, minCol, textColor, bgColor, children, ...props }, ref) => {\n const { bulmaHelperClasses, rest } = useBulmaClasses({\n color: textColor,\n backgroundColor: bgColor,\n ...props,\n });\n const statsClass = usePrefixedClassNames('stats grid', {\n [`is-col-min-${minCol}`]: minCol !== undefined && minCol !== null,\n });\n const scope = useMemo(() => ({ row: true, textColor }), [textColor]);\n return (\n <dl\n ref={ref}\n className={classNames(statsClass, bulmaHelperClasses, className)}\n {...rest}\n >\n <StatScopeContext.Provider value={scope}>\n {children}\n </StatScopeContext.Provider>\n </dl>\n );\n }\n);\n\nStatsRoot.displayName = 'Stats';\n\nexport const Stats = withSubComponents(StatsRoot, { Stat }, 'Stats');\n\nexport default Stats;\n"],"names":["_jsx"],"mappings":";;;;;;;;;;AA4CA;;;;;;;;;;;;;;;;;;;;AAoBG;AACH,MAAM,SAAS,GAAG,UAAU,CAC1B,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KAAI;AACrE,IAAA,MAAM,EAAE,kBAAkB,EAAE,IAAI,EAAE,GAAG,eAAe,CAAC;AACnD,QAAA,KAAK,EAAE,SAAS;AAChB,QAAA,eAAe,EAAE,OAAO;AACxB,QAAA,GAAG,KAAK;AACT,KAAA,CAAC;AACF,IAAA,MAAM,UAAU,GAAG,qBAAqB,CAAC,YAAY,EAAE;QACrD,CAAC,CAAA,WAAA,EAAc,MAAM,CAAA,CAAE,GAAG,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,IAAI;AAClE,KAAA,CAAC;IACF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;AACpE,IAAA,QACEA,GAAA,CAAA,IAAA,EAAA,EACE,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,UAAU,CAAC,UAAU,EAAE,kBAAkB,EAAE,SAAS,CAAC,EAAA,GAC5D,IAAI,EAAA,QAAA,EAERA,GAAA,CAAC,gBAAgB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,QAAA,EACpC,QAAQ,EAAA,CACiB,EAAA,CACzB;AAET,CAAC,CACF;AAED,SAAS,CAAC,WAAW,GAAG,OAAO;AAExB,MAAM,KAAK,GAAG,iBAAiB,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,EAAE,OAAO;;"}
@@ -0,0 +1,10 @@
1
+ /* @allxsmith/bestax-bulma — AI agents: see AGENTS.md in the package root, or https://bestax.io/llms.txt */
2
+ 'use client';
3
+ import { createContext } from 'react';
4
+
5
+ // INTERNAL, deliberately not exported from src/index.ts: what a Stat and its
6
+ // parts read from around them.
7
+ const StatScopeContext = createContext({ row: false });
8
+
9
+ export { StatScopeContext };
10
+ //# sourceMappingURL=statContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statContext.js","sources":["../../../src/elements/statContext.ts"],"sourcesContent":["// INTERNAL, deliberately not exported from src/index.ts: what a Stat and its\n// parts read from around them.\n\nimport { createContext } from 'react';\nimport type { validColors } from '../helpers/useBulmaClasses';\n\nexport interface StatScope {\n /**\n * Whether this is inside a `Stats` row, where a Stat is a `<div>` in the\n * row's `<dl>` rather than a `<dl>` of its own. A Stat sets it back to\n * `false` for its children. Those are meant to be its parts, so a Stat\n * inside a part sits in a `<dd>`, where a `<dl>` of its own is valid. A\n * Stat written straight among another's children isn't handled: it renders\n * a `<dl>` inside the other's list, which HTML doesn't allow, and Stat's\n * `children` TSDoc says not to.\n */\n row: boolean;\n /** The row's `textColor`, which each Stat in it takes unless it has its own. */\n textColor?: (typeof validColors)[number] | 'inherit' | 'current';\n /** The Stat's `locale`, which a `Stat.Change` in it takes unless it has its own. */\n locale?: string;\n}\n\nexport const StatScopeContext = createContext<StatScope>({ row: false });\n"],"names":[],"mappings":";;;;AAAA;AACA;AAsBO,MAAM,gBAAgB,GAAG,aAAa,CAAY,EAAE,GAAG,EAAE,KAAK,EAAE;;"}
@@ -13,6 +13,7 @@ import { warnOnce } from '../helpers/devWarnings.js';
13
13
  import { useLocaleMatcher } from '../helpers/localeFormat.js';
14
14
  import { useAnchoredPosition, marginGap } from '../helpers/useAnchoredPosition.js';
15
15
  import { spokenText, StatusRegion } from '../helpers/statusRegion.js';
16
+ import { CheckIcon } from '../helpers/checkIcon.js';
16
17
  import { useComboboxEngine } from '../helpers/useComboboxEngine.js';
17
18
  import { Field } from './Field.js';
18
19
  import { Input } from './Input.js';
@@ -372,7 +373,7 @@ const ComboboxItem = ({ value, disabled = false, checked = false, children, clas
372
373
  onPointerMove?.(event);
373
374
  if (!disabled && !highlighted)
374
375
  engine.hover(value);
375
- }, children: [checked && (jsx("span", { className: checkClass, "aria-hidden": "true", children: jsx("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", width: "1em", height: "1em", focusable: "false", children: jsx("polyline", { points: "3 8.5 6.5 12 13 4.5" }) }) })), children] }));
376
+ }, children: [checked && (jsx("span", { className: checkClass, "aria-hidden": "true", children: jsx(CheckIcon, {}) })), children] }));
376
377
  };
377
378
  ComboboxItem.displayName = 'ComboboxItem';
378
379
  /**