@dbcdk/react-components 0.0.146 → 0.0.148
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/dist/components/attribute-chip/AttributeChip.cjs +4 -2
- package/dist/components/attribute-chip/AttributeChip.d.ts +3 -1
- package/dist/components/attribute-chip/AttributeChip.js +4 -2
- package/dist/components/attribute-chip/AttributeChip.module.css +59 -6
- package/dist/components/forms/checkbox/Checkbox.cjs +4 -1
- package/dist/components/forms/checkbox/Checkbox.d.ts +11 -1
- package/dist/components/forms/checkbox/Checkbox.js +4 -1
- package/dist/components/forms/checkbox/Checkbox.module.css +6 -0
- package/dist/components/forms/radio-buttons/RadioButton.cjs +4 -1
- package/dist/components/forms/radio-buttons/RadioButton.d.ts +11 -1
- package/dist/components/forms/radio-buttons/RadioButton.js +4 -1
- package/dist/components/forms/radio-buttons/RadioButtons.module.css +6 -0
- package/dist/components/forms/select/Select.cjs +40 -39
- package/dist/components/forms/select/Select.d.ts +2 -1
- package/dist/components/forms/select/Select.js +40 -39
- package/dist/components/forms/select/Select.module.css +9 -0
- package/dist/components/menu/Menu.cjs +8 -0
- package/dist/components/menu/Menu.d.ts +14 -0
- package/dist/components/menu/Menu.js +8 -0
- package/dist/components/page-layout/PageLayout.module.css +1 -1
- package/package.json +1 -1
|
@@ -11,14 +11,16 @@ function AttributeChip({
|
|
|
11
11
|
label,
|
|
12
12
|
value,
|
|
13
13
|
size = "md",
|
|
14
|
-
loading
|
|
14
|
+
loading,
|
|
15
|
+
severity = "neutral"
|
|
15
16
|
}) {
|
|
17
|
+
const valueClassName = [styles__default.default.value, styles__default.default[severity], !label && styles__default.default.valueStandalone].filter(Boolean).join(" ");
|
|
16
18
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${styles__default.default.container} ${styles__default.default[size]}`, "aria-busy": loading, children: [
|
|
17
19
|
label ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
18
20
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.label, children: label }),
|
|
19
21
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.separator, "aria-hidden": "true", children: "|" })
|
|
20
22
|
] }) : null,
|
|
21
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className:
|
|
23
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: valueClassName, children: loading ? "\u2014" : value == null ? void 0 : value.toString() })
|
|
22
24
|
] });
|
|
23
25
|
}
|
|
24
26
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { JSX } from 'react';
|
|
2
|
+
import { Severity } from '../../constants/severity.types';
|
|
2
3
|
interface AttributeChipProps {
|
|
3
4
|
label?: string;
|
|
4
5
|
value: string | number | boolean;
|
|
5
6
|
loading?: boolean;
|
|
6
7
|
size?: 'sm' | 'md' | 'lg';
|
|
8
|
+
severity?: Severity;
|
|
7
9
|
}
|
|
8
|
-
export declare function AttributeChip({ label, value, size, loading, }: AttributeChipProps): JSX.Element;
|
|
10
|
+
export declare function AttributeChip({ label, value, size, loading, severity, }: AttributeChipProps): JSX.Element;
|
|
9
11
|
export {};
|
|
@@ -5,14 +5,16 @@ function AttributeChip({
|
|
|
5
5
|
label,
|
|
6
6
|
value,
|
|
7
7
|
size = "md",
|
|
8
|
-
loading
|
|
8
|
+
loading,
|
|
9
|
+
severity = "neutral"
|
|
9
10
|
}) {
|
|
11
|
+
const valueClassName = [styles.value, styles[severity], !label && styles.valueStandalone].filter(Boolean).join(" ");
|
|
10
12
|
return /* @__PURE__ */ jsxs("div", { className: `${styles.container} ${styles[size]}`, "aria-busy": loading, children: [
|
|
11
13
|
label ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
12
14
|
/* @__PURE__ */ jsx("span", { className: styles.label, children: label }),
|
|
13
15
|
/* @__PURE__ */ jsx("span", { className: styles.separator, "aria-hidden": "true", children: "|" })
|
|
14
16
|
] }) : null,
|
|
15
|
-
/* @__PURE__ */ jsx("span", { className:
|
|
17
|
+
/* @__PURE__ */ jsx("span", { className: valueClassName, children: loading ? "\u2014" : value == null ? void 0 : value.toString() })
|
|
16
18
|
] });
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -8,14 +8,22 @@
|
|
|
8
8
|
color: var(--color-fg-default);
|
|
9
9
|
font-family: var(--font-family);
|
|
10
10
|
font-weight: var(--font-weight-default);
|
|
11
|
-
line
|
|
12
|
-
|
|
11
|
+
/* All text here is single-line and vertically centered via flex, so use a
|
|
12
|
+
tight line-height instead of the paragraph-oriented default — that
|
|
13
|
+
avoids uneven leading around the glyphs at different font-sizes. */
|
|
14
|
+
line-height: 1;
|
|
15
|
+
--attribute-chip-padding-inline: var(--spacing-xxs);
|
|
16
|
+
--attribute-chip-value-bleed: calc(
|
|
17
|
+
(var(--attribute-chip-padding-inline) - var(--spacing-2xs)) * -1
|
|
18
|
+
);
|
|
19
|
+
padding-inline: var(--attribute-chip-padding-inline);
|
|
13
20
|
}
|
|
14
21
|
|
|
15
22
|
.label,
|
|
16
23
|
.value {
|
|
17
24
|
display: inline-flex;
|
|
18
25
|
align-items: center;
|
|
26
|
+
height: 100%;
|
|
19
27
|
}
|
|
20
28
|
|
|
21
29
|
.label {
|
|
@@ -24,29 +32,74 @@
|
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
.value {
|
|
35
|
+
height: calc(100% - 2 * var(--spacing-2xs));
|
|
36
|
+
margin-block: var(--spacing-2xs);
|
|
27
37
|
font-weight: var(--font-weight-medium);
|
|
38
|
+
padding-inline: var(--attribute-chip-padding-inline);
|
|
39
|
+
margin-inline-end: var(--attribute-chip-value-bleed);
|
|
40
|
+
border-radius: 0 var(--border-radius-default) var(--border-radius-default) 0;
|
|
41
|
+
background: var(--value-bg, transparent);
|
|
42
|
+
color: var(--value-fg, inherit);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* When there's no label/separator before it, the value is the only content,
|
|
46
|
+
so it bleeds into the left padding too and becomes a full pill. A thin
|
|
47
|
+
sliver of the container's own background stays visible around it. */
|
|
48
|
+
.valueStandalone {
|
|
49
|
+
margin-inline-start: var(--attribute-chip-value-bleed);
|
|
50
|
+
border-radius: var(--border-radius-default);
|
|
28
51
|
}
|
|
29
52
|
|
|
30
53
|
.separator {
|
|
31
54
|
color: var(--color-border-default);
|
|
32
|
-
margin-inline: var(--spacing-xxs);
|
|
55
|
+
margin-inline-start: var(--spacing-xxs);
|
|
56
|
+
margin-inline-end: var(--spacing-2xs);
|
|
33
57
|
}
|
|
34
58
|
|
|
35
59
|
/* Sizes */
|
|
36
60
|
.sm {
|
|
37
61
|
height: var(--component-size-xs);
|
|
38
62
|
font-size: var(--font-size-xs);
|
|
39
|
-
padding-inline: var(--spacing-xs);
|
|
40
63
|
}
|
|
41
64
|
|
|
42
65
|
.md {
|
|
43
66
|
height: var(--component-size-sm);
|
|
44
67
|
font-size: var(--font-size-sm);
|
|
45
|
-
padding-inline: var(--spacing-sm);
|
|
46
68
|
}
|
|
47
69
|
|
|
48
70
|
.lg {
|
|
49
71
|
height: var(--component-size-md);
|
|
50
72
|
font-size: var(--font-size-md);
|
|
51
|
-
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Severity colors for the value */
|
|
76
|
+
|
|
77
|
+
.neutral {
|
|
78
|
+
--value-bg: transparent;
|
|
79
|
+
--value-fg: inherit;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.success {
|
|
83
|
+
--value-bg: var(--color-status-success-bg);
|
|
84
|
+
--value-fg: var(--color-status-success-fg);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.warning {
|
|
88
|
+
--value-bg: var(--color-status-warning-bg);
|
|
89
|
+
--value-fg: var(--color-status-warning-fg);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.error {
|
|
93
|
+
--value-bg: var(--color-status-error-bg);
|
|
94
|
+
--value-fg: var(--color-status-error-fg);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.info {
|
|
98
|
+
--value-bg: var(--color-status-info-bg);
|
|
99
|
+
--value-fg: var(--color-status-info-fg);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.brand {
|
|
103
|
+
--value-bg: var(--color-brand);
|
|
104
|
+
--value-fg: var(--color-fg-on-brand);
|
|
52
105
|
}
|
|
@@ -19,6 +19,8 @@ function Checkbox({
|
|
|
19
19
|
disabled,
|
|
20
20
|
label,
|
|
21
21
|
labelAs = "label",
|
|
22
|
+
endAdornment,
|
|
23
|
+
endAdornmentAriaHidden = true,
|
|
22
24
|
size = "md",
|
|
23
25
|
modified,
|
|
24
26
|
containerLabel,
|
|
@@ -70,7 +72,8 @@ function Checkbox({
|
|
|
70
72
|
children: isChecked && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: styles__default.default.icon })
|
|
71
73
|
}
|
|
72
74
|
) }),
|
|
73
|
-
label && (labelAs === "label" ? /* @__PURE__ */ jsxRuntime.jsx("label", { className: styles__default.default.label, htmlFor: controlId, children: label }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.label, children: label }))
|
|
75
|
+
label && (labelAs === "label" ? /* @__PURE__ */ jsxRuntime.jsx("label", { className: styles__default.default.label, htmlFor: controlId, children: label }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.label, children: label })),
|
|
76
|
+
endAdornment && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.endAdornment, "aria-hidden": endAdornmentAriaHidden, children: endAdornment })
|
|
74
77
|
]
|
|
75
78
|
}
|
|
76
79
|
);
|
|
@@ -11,6 +11,16 @@ interface CheckboxProps {
|
|
|
11
11
|
modified?: boolean;
|
|
12
12
|
label?: ReactNode;
|
|
13
13
|
labelAs?: 'label' | 'span';
|
|
14
|
+
/**
|
|
15
|
+
* Extra content rendered after the label (e.g. a status dot or badge).
|
|
16
|
+
* The component owns the layout/spacing for this slot.
|
|
17
|
+
*/
|
|
18
|
+
endAdornment?: ReactNode;
|
|
19
|
+
/**
|
|
20
|
+
* Whether the endAdornment wrapper is hidden from assistive tech.
|
|
21
|
+
* Defaults to true since endAdornment is typically decorative.
|
|
22
|
+
*/
|
|
23
|
+
endAdornmentAriaHidden?: boolean;
|
|
14
24
|
size?: Size;
|
|
15
25
|
containerLabel?: string;
|
|
16
26
|
error?: string;
|
|
@@ -25,5 +35,5 @@ interface CheckboxProps {
|
|
|
25
35
|
tooltip?: ReactNode;
|
|
26
36
|
tooltipPlacement?: TooltipPlacement;
|
|
27
37
|
}
|
|
28
|
-
export declare function Checkbox({ checked: controlled, onChange, variant, disabled, label, labelAs, size, modified, containerLabel, error, helpText, orientation, labelWidth, fullWidth, required, noContainer, id, 'data-cy': dataCy, tooltip, tooltipPlacement, }: CheckboxProps): JSX.Element;
|
|
38
|
+
export declare function Checkbox({ checked: controlled, onChange, variant, disabled, label, labelAs, endAdornment, endAdornmentAriaHidden, size, modified, containerLabel, error, helpText, orientation, labelWidth, fullWidth, required, noContainer, id, 'data-cy': dataCy, tooltip, tooltipPlacement, }: CheckboxProps): JSX.Element;
|
|
29
39
|
export {};
|
|
@@ -13,6 +13,8 @@ function Checkbox({
|
|
|
13
13
|
disabled,
|
|
14
14
|
label,
|
|
15
15
|
labelAs = "label",
|
|
16
|
+
endAdornment,
|
|
17
|
+
endAdornmentAriaHidden = true,
|
|
16
18
|
size = "md",
|
|
17
19
|
modified,
|
|
18
20
|
containerLabel,
|
|
@@ -64,7 +66,8 @@ function Checkbox({
|
|
|
64
66
|
children: isChecked && /* @__PURE__ */ jsx(Check, { className: styles.icon })
|
|
65
67
|
}
|
|
66
68
|
) }),
|
|
67
|
-
label && (labelAs === "label" ? /* @__PURE__ */ jsx("label", { className: styles.label, htmlFor: controlId, children: label }) : /* @__PURE__ */ jsx("span", { className: styles.label, children: label }))
|
|
69
|
+
label && (labelAs === "label" ? /* @__PURE__ */ jsx("label", { className: styles.label, htmlFor: controlId, children: label }) : /* @__PURE__ */ jsx("span", { className: styles.label, children: label })),
|
|
70
|
+
endAdornment && /* @__PURE__ */ jsx("span", { className: styles.endAdornment, "aria-hidden": endAdornmentAriaHidden, children: endAdornment })
|
|
68
71
|
]
|
|
69
72
|
}
|
|
70
73
|
);
|
|
@@ -18,6 +18,8 @@ function RadioButton({
|
|
|
18
18
|
onChange,
|
|
19
19
|
disabled,
|
|
20
20
|
label,
|
|
21
|
+
endAdornment,
|
|
22
|
+
endAdornmentAriaHidden = true,
|
|
21
23
|
variant = "outlined",
|
|
22
24
|
size = "md",
|
|
23
25
|
containerLabel,
|
|
@@ -69,7 +71,8 @@ function RadioButton({
|
|
|
69
71
|
}
|
|
70
72
|
)
|
|
71
73
|
] }),
|
|
72
|
-
label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: styles__default.default.label, htmlFor: controlId, children: label })
|
|
74
|
+
label && /* @__PURE__ */ jsxRuntime.jsx("label", { className: styles__default.default.label, htmlFor: controlId, children: label }),
|
|
75
|
+
endAdornment && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.endAdornment, "aria-hidden": endAdornmentAriaHidden, children: endAdornment })
|
|
73
76
|
] });
|
|
74
77
|
if (noContainer || !containerLabel && !error) return content;
|
|
75
78
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -15,6 +15,16 @@ export interface RadioButtonProps {
|
|
|
15
15
|
onChange?: (value: string, event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
16
16
|
disabled?: boolean;
|
|
17
17
|
label?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Extra content rendered after the label (e.g. a status dot or badge).
|
|
20
|
+
* The component owns the layout/spacing for this slot.
|
|
21
|
+
*/
|
|
22
|
+
endAdornment?: React.ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* Whether the endAdornment wrapper is hidden from assistive tech.
|
|
25
|
+
* Defaults to true since endAdornment is typically decorative.
|
|
26
|
+
*/
|
|
27
|
+
endAdornmentAriaHidden?: boolean;
|
|
18
28
|
variant?: Variant;
|
|
19
29
|
size?: Size;
|
|
20
30
|
containerLabel?: string;
|
|
@@ -32,5 +42,5 @@ export interface RadioButtonProps {
|
|
|
32
42
|
id?: string;
|
|
33
43
|
'data-cy'?: string;
|
|
34
44
|
}
|
|
35
|
-
export declare function RadioButton({ name, value, selectedValue, checked, onChange, disabled, label, variant, size, containerLabel, error, helpText, orientation, labelWidth, fullWidth, required, noContainer, id, 'data-cy': dataCy, }: RadioButtonProps): JSX.Element;
|
|
45
|
+
export declare function RadioButton({ name, value, selectedValue, checked, onChange, disabled, label, endAdornment, endAdornmentAriaHidden, variant, size, containerLabel, error, helpText, orientation, labelWidth, fullWidth, required, noContainer, id, 'data-cy': dataCy, }: RadioButtonProps): JSX.Element;
|
|
36
46
|
export {};
|
|
@@ -12,6 +12,8 @@ function RadioButton({
|
|
|
12
12
|
onChange,
|
|
13
13
|
disabled,
|
|
14
14
|
label,
|
|
15
|
+
endAdornment,
|
|
16
|
+
endAdornmentAriaHidden = true,
|
|
15
17
|
variant = "outlined",
|
|
16
18
|
size = "md",
|
|
17
19
|
containerLabel,
|
|
@@ -63,7 +65,8 @@ function RadioButton({
|
|
|
63
65
|
}
|
|
64
66
|
)
|
|
65
67
|
] }),
|
|
66
|
-
label && /* @__PURE__ */ jsx("label", { className: styles.label, htmlFor: controlId, children: label })
|
|
68
|
+
label && /* @__PURE__ */ jsx("label", { className: styles.label, htmlFor: controlId, children: label }),
|
|
69
|
+
endAdornment && /* @__PURE__ */ jsx("span", { className: styles.endAdornment, "aria-hidden": endAdornmentAriaHidden, children: endAdornment })
|
|
67
70
|
] });
|
|
68
71
|
if (noContainer || !containerLabel && !error) return content;
|
|
69
72
|
return /* @__PURE__ */ jsx(
|
|
@@ -38,7 +38,8 @@ function Select({
|
|
|
38
38
|
datakey,
|
|
39
39
|
dataCy,
|
|
40
40
|
disabled,
|
|
41
|
-
minWidth
|
|
41
|
+
minWidth,
|
|
42
|
+
menuHeader
|
|
42
43
|
}) {
|
|
43
44
|
const generatedId = react.useId();
|
|
44
45
|
const controlId = id != null ? id : `select-${generatedId}`;
|
|
@@ -109,18 +110,14 @@ function Select({
|
|
|
109
110
|
e.preventDefault();
|
|
110
111
|
if (!open) {
|
|
111
112
|
setOpen(true);
|
|
112
|
-
return;
|
|
113
113
|
}
|
|
114
|
-
setActiveIndex((i) => Math.min(i + 1, options.length - 1));
|
|
115
114
|
break;
|
|
116
115
|
}
|
|
117
116
|
case "ArrowUp": {
|
|
118
117
|
e.preventDefault();
|
|
119
118
|
if (!open) {
|
|
120
119
|
setOpen(true);
|
|
121
|
-
return;
|
|
122
120
|
}
|
|
123
|
-
setActiveIndex((i) => Math.max(i - 1, 0));
|
|
124
121
|
break;
|
|
125
122
|
}
|
|
126
123
|
case "Enter":
|
|
@@ -241,40 +238,44 @@ function Select({
|
|
|
241
238
|
)
|
|
242
239
|
}
|
|
243
240
|
),
|
|
244
|
-
children: /* @__PURE__ */ jsxRuntime.
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
"
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
(
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
241
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(Menu.Menu, { onKeyDown: handleKeyDown, role: "listbox", className: styles__default.default.menu, children: [
|
|
242
|
+
menuHeader ? /* @__PURE__ */ jsxRuntime.jsx(Menu.Menu.Header, { children: menuHeader }) : null,
|
|
243
|
+
options.map((opt, index) => {
|
|
244
|
+
const isSelected = typeof opt.value === "object" && typeof selectedValue === "object" && datakey ? (selectedValue == null ? void 0 : selectedValue[datakey]) === opt.value[datakey] : opt.value === selectedValue;
|
|
245
|
+
const isActive = index === activeIndex;
|
|
246
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
247
|
+
Menu.Menu.Item,
|
|
248
|
+
{
|
|
249
|
+
active: isActive,
|
|
250
|
+
selected: isSelected,
|
|
251
|
+
itemRole: "option",
|
|
252
|
+
className: isSelected ? styles__default.default.selectedOption : void 0,
|
|
253
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
254
|
+
"button",
|
|
255
|
+
{
|
|
256
|
+
ref: (el) => {
|
|
257
|
+
optionRefs.current[index] = el;
|
|
258
|
+
},
|
|
259
|
+
type: "button",
|
|
260
|
+
tabIndex: isActive ? 0 : -1,
|
|
261
|
+
onClick: () => {
|
|
262
|
+
var _a;
|
|
263
|
+
onChange(opt.value);
|
|
264
|
+
(_a = popoverRef.current) == null ? void 0 : _a.close();
|
|
265
|
+
},
|
|
266
|
+
onFocus: () => setActiveIndex(index),
|
|
267
|
+
style: { display: "flex", alignItems: "center", width: "100%" },
|
|
268
|
+
children: [
|
|
269
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { width: 16, display: "inline-flex", justifyContent: "center" }, children: isSelected ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, {}) : null }),
|
|
270
|
+
opt.label
|
|
271
|
+
]
|
|
272
|
+
}
|
|
273
|
+
)
|
|
274
|
+
},
|
|
275
|
+
String(opt.value)
|
|
276
|
+
);
|
|
277
|
+
})
|
|
278
|
+
] })
|
|
278
279
|
}
|
|
279
280
|
),
|
|
280
281
|
(error || helpText) && /* @__PURE__ */ jsxRuntime.jsx("span", { id: describedById, style: { display: "none" }, children: error != null ? error : helpText })
|
|
@@ -16,8 +16,9 @@ export type SelectProps<T> = Omit<InputContainerProps, 'children' | 'htmlFor' |
|
|
|
16
16
|
dataCy?: string;
|
|
17
17
|
disabled?: boolean;
|
|
18
18
|
minWidth?: string | number;
|
|
19
|
+
menuHeader?: React.ReactNode;
|
|
19
20
|
tooltip?: React.ReactNode;
|
|
20
21
|
tooltipPlacement?: 'top' | 'right' | 'bottom' | 'left';
|
|
21
22
|
};
|
|
22
|
-
export declare function Select<T extends string | number | Record<string, any>>({ label, error, helpText, orientation, labelWidth, fullWidth, required, tooltip, tooltipPlacement, modified, id, options, selectedValue, onChange, placeholder, size, variant, onClear, datakey, dataCy, disabled, minWidth, }: SelectProps<T>): React.ReactNode;
|
|
23
|
+
export declare function Select<T extends string | number | Record<string, any>>({ label, error, helpText, orientation, labelWidth, fullWidth, required, tooltip, tooltipPlacement, modified, id, options, selectedValue, onChange, placeholder, size, variant, onClear, datakey, dataCy, disabled, minWidth, menuHeader, }: SelectProps<T>): React.ReactNode;
|
|
23
24
|
export {};
|
|
@@ -32,7 +32,8 @@ function Select({
|
|
|
32
32
|
datakey,
|
|
33
33
|
dataCy,
|
|
34
34
|
disabled,
|
|
35
|
-
minWidth
|
|
35
|
+
minWidth,
|
|
36
|
+
menuHeader
|
|
36
37
|
}) {
|
|
37
38
|
const generatedId = useId();
|
|
38
39
|
const controlId = id != null ? id : `select-${generatedId}`;
|
|
@@ -103,18 +104,14 @@ function Select({
|
|
|
103
104
|
e.preventDefault();
|
|
104
105
|
if (!open) {
|
|
105
106
|
setOpen(true);
|
|
106
|
-
return;
|
|
107
107
|
}
|
|
108
|
-
setActiveIndex((i) => Math.min(i + 1, options.length - 1));
|
|
109
108
|
break;
|
|
110
109
|
}
|
|
111
110
|
case "ArrowUp": {
|
|
112
111
|
e.preventDefault();
|
|
113
112
|
if (!open) {
|
|
114
113
|
setOpen(true);
|
|
115
|
-
return;
|
|
116
114
|
}
|
|
117
|
-
setActiveIndex((i) => Math.max(i - 1, 0));
|
|
118
115
|
break;
|
|
119
116
|
}
|
|
120
117
|
case "Enter":
|
|
@@ -235,40 +232,44 @@ function Select({
|
|
|
235
232
|
)
|
|
236
233
|
}
|
|
237
234
|
),
|
|
238
|
-
children: /* @__PURE__ */
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
"
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
235
|
+
children: /* @__PURE__ */ jsxs(Menu, { onKeyDown: handleKeyDown, role: "listbox", className: styles.menu, children: [
|
|
236
|
+
menuHeader ? /* @__PURE__ */ jsx(Menu.Header, { children: menuHeader }) : null,
|
|
237
|
+
options.map((opt, index) => {
|
|
238
|
+
const isSelected = typeof opt.value === "object" && typeof selectedValue === "object" && datakey ? (selectedValue == null ? void 0 : selectedValue[datakey]) === opt.value[datakey] : opt.value === selectedValue;
|
|
239
|
+
const isActive = index === activeIndex;
|
|
240
|
+
return /* @__PURE__ */ jsx(
|
|
241
|
+
Menu.Item,
|
|
242
|
+
{
|
|
243
|
+
active: isActive,
|
|
244
|
+
selected: isSelected,
|
|
245
|
+
itemRole: "option",
|
|
246
|
+
className: isSelected ? styles.selectedOption : void 0,
|
|
247
|
+
children: /* @__PURE__ */ jsxs(
|
|
248
|
+
"button",
|
|
249
|
+
{
|
|
250
|
+
ref: (el) => {
|
|
251
|
+
optionRefs.current[index] = el;
|
|
252
|
+
},
|
|
253
|
+
type: "button",
|
|
254
|
+
tabIndex: isActive ? 0 : -1,
|
|
255
|
+
onClick: () => {
|
|
256
|
+
var _a;
|
|
257
|
+
onChange(opt.value);
|
|
258
|
+
(_a = popoverRef.current) == null ? void 0 : _a.close();
|
|
259
|
+
},
|
|
260
|
+
onFocus: () => setActiveIndex(index),
|
|
261
|
+
style: { display: "flex", alignItems: "center", width: "100%" },
|
|
262
|
+
children: [
|
|
263
|
+
/* @__PURE__ */ jsx("span", { style: { width: 16, display: "inline-flex", justifyContent: "center" }, children: isSelected ? /* @__PURE__ */ jsx(Check, {}) : null }),
|
|
264
|
+
opt.label
|
|
265
|
+
]
|
|
266
|
+
}
|
|
267
|
+
)
|
|
268
|
+
},
|
|
269
|
+
String(opt.value)
|
|
270
|
+
);
|
|
271
|
+
})
|
|
272
|
+
] })
|
|
272
273
|
}
|
|
273
274
|
),
|
|
274
275
|
(error || helpText) && /* @__PURE__ */ jsx("span", { id: describedById, style: { display: "none" }, children: error != null ? error : helpText })
|
|
@@ -30,3 +30,12 @@
|
|
|
30
30
|
box-shadow: inset 0 0 0 1px
|
|
31
31
|
color-mix(in srgb, var(--color-status-warning-border) 55%, var(--color-border-default));
|
|
32
32
|
}
|
|
33
|
+
|
|
34
|
+
.selectedOption > button {
|
|
35
|
+
background-color: var(--color-bg-toolbar-hover);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.selectedOption > button:hover,
|
|
39
|
+
.selectedOption > button:focus-visible {
|
|
40
|
+
background-color: var(--color-bg-toolbar-hover);
|
|
41
|
+
}
|
|
@@ -153,6 +153,8 @@ const MenuCheckItem = React__namespace.forwardRef(
|
|
|
153
153
|
interactiveRef,
|
|
154
154
|
interactiveProps,
|
|
155
155
|
onCheckedChange,
|
|
156
|
+
endAdornment,
|
|
157
|
+
endAdornmentAriaHidden,
|
|
156
158
|
className,
|
|
157
159
|
...liProps
|
|
158
160
|
}, ref) => {
|
|
@@ -200,6 +202,8 @@ const MenuCheckItem = React__namespace.forwardRef(
|
|
|
200
202
|
disabled,
|
|
201
203
|
labelAs: "span",
|
|
202
204
|
label,
|
|
205
|
+
endAdornment,
|
|
206
|
+
endAdornmentAriaHidden,
|
|
203
207
|
onChange: (next, _e) => onCheckedChange == null ? void 0 : onCheckedChange(next)
|
|
204
208
|
}
|
|
205
209
|
)
|
|
@@ -221,6 +225,8 @@ const MenuRadioItem = React__namespace.forwardRef(
|
|
|
221
225
|
interactiveRef,
|
|
222
226
|
interactiveProps,
|
|
223
227
|
onValueChange,
|
|
228
|
+
endAdornment,
|
|
229
|
+
endAdornmentAriaHidden,
|
|
224
230
|
className,
|
|
225
231
|
...liProps
|
|
226
232
|
}, ref) => {
|
|
@@ -277,6 +283,8 @@ const MenuRadioItem = React__namespace.forwardRef(
|
|
|
277
283
|
checked,
|
|
278
284
|
disabled,
|
|
279
285
|
label,
|
|
286
|
+
endAdornment,
|
|
287
|
+
endAdornmentAriaHidden,
|
|
280
288
|
onChange: (v, _e) => onValueChange == null ? void 0 : onValueChange(v)
|
|
281
289
|
}
|
|
282
290
|
)
|
|
@@ -35,6 +35,13 @@ export interface MenuCheckItemProps extends Omit<React.LiHTMLAttributes<HTMLLIEl
|
|
|
35
35
|
interactiveRef?: React.Ref<HTMLDivElement>;
|
|
36
36
|
interactiveProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
37
37
|
onCheckedChange?: (checked: boolean) => void;
|
|
38
|
+
/**
|
|
39
|
+
* Extra content rendered after the label (e.g. a status dot or badge).
|
|
40
|
+
* Forwarded to the underlying Checkbox, which owns the layout/spacing.
|
|
41
|
+
*/
|
|
42
|
+
endAdornment?: React.ReactNode;
|
|
43
|
+
/** Forwarded to the underlying Checkbox. Defaults to true. */
|
|
44
|
+
endAdornmentAriaHidden?: boolean;
|
|
38
45
|
}
|
|
39
46
|
export interface MenuRadioItemProps extends Omit<React.LiHTMLAttributes<HTMLLIElement>, 'onChange'> {
|
|
40
47
|
name: string;
|
|
@@ -46,6 +53,13 @@ export interface MenuRadioItemProps extends Omit<React.LiHTMLAttributes<HTMLLIEl
|
|
|
46
53
|
interactiveRef?: React.Ref<HTMLDivElement>;
|
|
47
54
|
interactiveProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
48
55
|
onValueChange?: (value: string) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Extra content rendered after the label (e.g. a status dot or badge).
|
|
58
|
+
* Forwarded to the underlying RadioButton, which owns the layout/spacing.
|
|
59
|
+
*/
|
|
60
|
+
endAdornment?: React.ReactNode;
|
|
61
|
+
/** Forwarded to the underlying RadioButton. Defaults to true. */
|
|
62
|
+
endAdornmentAriaHidden?: boolean;
|
|
49
63
|
}
|
|
50
64
|
export declare const Menu: React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<HTMLUListElement>> & {
|
|
51
65
|
Item: React.ForwardRefExoticComponent<MenuItemProps & React.RefAttributes<HTMLLIElement>>;
|
|
@@ -128,6 +128,8 @@ const MenuCheckItem = React.forwardRef(
|
|
|
128
128
|
interactiveRef,
|
|
129
129
|
interactiveProps,
|
|
130
130
|
onCheckedChange,
|
|
131
|
+
endAdornment,
|
|
132
|
+
endAdornmentAriaHidden,
|
|
131
133
|
className,
|
|
132
134
|
...liProps
|
|
133
135
|
}, ref) => {
|
|
@@ -175,6 +177,8 @@ const MenuCheckItem = React.forwardRef(
|
|
|
175
177
|
disabled,
|
|
176
178
|
labelAs: "span",
|
|
177
179
|
label,
|
|
180
|
+
endAdornment,
|
|
181
|
+
endAdornmentAriaHidden,
|
|
178
182
|
onChange: (next, _e) => onCheckedChange == null ? void 0 : onCheckedChange(next)
|
|
179
183
|
}
|
|
180
184
|
)
|
|
@@ -196,6 +200,8 @@ const MenuRadioItem = React.forwardRef(
|
|
|
196
200
|
interactiveRef,
|
|
197
201
|
interactiveProps,
|
|
198
202
|
onValueChange,
|
|
203
|
+
endAdornment,
|
|
204
|
+
endAdornmentAriaHidden,
|
|
199
205
|
className,
|
|
200
206
|
...liProps
|
|
201
207
|
}, ref) => {
|
|
@@ -252,6 +258,8 @@ const MenuRadioItem = React.forwardRef(
|
|
|
252
258
|
checked,
|
|
253
259
|
disabled,
|
|
254
260
|
label,
|
|
261
|
+
endAdornment,
|
|
262
|
+
endAdornmentAriaHidden,
|
|
255
263
|
onChange: (v, _e) => onValueChange == null ? void 0 : onValueChange(v)
|
|
256
264
|
}
|
|
257
265
|
)
|