@dbcdk/react-components 0.0.211 → 0.0.213

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 (56) hide show
  1. package/README.md +6 -1
  2. package/dist/components/button/Button.cjs +2 -1
  3. package/dist/components/button/Button.d.ts +6 -1
  4. package/dist/components/button/Button.js +2 -1
  5. package/dist/components/button/Button.module.css +14 -0
  6. package/dist/components/color-scheme-button/ColorSchemeButton.cjs +2 -2
  7. package/dist/components/color-scheme-button/ColorSchemeButton.js +2 -2
  8. package/dist/components/forms/file-upload/FileUpload.cjs +4 -0
  9. package/dist/components/forms/file-upload/FileUpload.js +4 -0
  10. package/dist/components/forms/form-select/FormSelect.cjs +4 -0
  11. package/dist/components/forms/form-select/FormSelect.d.ts +1 -1
  12. package/dist/components/forms/form-select/FormSelect.js +4 -0
  13. package/dist/components/forms/input/Input.cjs +4 -0
  14. package/dist/components/forms/input/Input.js +4 -0
  15. package/dist/components/forms/input-container/InputContainer.cjs +1 -1
  16. package/dist/components/forms/input-container/InputContainer.js +1 -1
  17. package/dist/components/forms/input-container/InputContainer.module.css +12 -1
  18. package/dist/components/forms/radio-buttons/RadioButtonGroup.cjs +6 -5
  19. package/dist/components/forms/radio-buttons/RadioButtonGroup.js +2 -5
  20. package/dist/components/forms/radio-buttons/RadioButtons.module.css +15 -0
  21. package/dist/components/forms/select/Select.cjs +4 -0
  22. package/dist/components/forms/select/Select.d.ts +1 -1
  23. package/dist/components/forms/select/Select.js +4 -0
  24. package/dist/components/forms/text-area/Textarea.cjs +4 -0
  25. package/dist/components/forms/text-area/Textarea.js +4 -0
  26. package/dist/components/forms/typeahead/Typeahead.cjs +109 -42
  27. package/dist/components/forms/typeahead/Typeahead.d.ts +6 -0
  28. package/dist/components/forms/typeahead/Typeahead.js +109 -42
  29. package/dist/components/forms/typeahead/Typeahead.module.css +16 -0
  30. package/dist/components/headline/CollapsibleHeadline.cjs +15 -18
  31. package/dist/components/headline/CollapsibleHeadline.d.ts +2 -2
  32. package/dist/components/headline/CollapsibleHeadline.js +15 -18
  33. package/dist/components/headline/Headline.module.css +22 -0
  34. package/dist/components/sidebar/components/SidebarItem.cjs +2 -0
  35. package/dist/components/sidebar/components/SidebarItem.d.ts +2 -1
  36. package/dist/components/sidebar/components/SidebarItem.js +2 -0
  37. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.cjs +2 -0
  38. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.d.ts +2 -1
  39. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +2 -0
  40. package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.module.css +1 -1
  41. package/dist/components/sidebar/components/sidebar-container/SidebarContainer.module.css +40 -0
  42. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.cjs +2 -0
  43. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.d.ts +2 -1
  44. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.js +2 -0
  45. package/dist/components/sidebar/components/sidebar-item-content/SidebarItemContent.module.css +9 -0
  46. package/dist/components/sidebar/components/sidebar-items/SidebarItems.cjs +6 -4
  47. package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +6 -4
  48. package/dist/components/theme-script/ThemeScript.cjs +1 -1
  49. package/dist/components/theme-script/ThemeScript.d.ts +1 -1
  50. package/dist/components/theme-script/ThemeScript.js +1 -1
  51. package/dist/hooks/useColorScheme.cjs +1 -1
  52. package/dist/hooks/useColorScheme.js +1 -1
  53. package/dist/hooks/useGetActiveTheme.cjs +1 -1
  54. package/dist/hooks/useGetActiveTheme.js +1 -1
  55. package/dist/styles/themes/dbc/colors.css +4 -4
  56. package/package.json +1 -1
package/README.md CHANGED
@@ -100,6 +100,11 @@ export default function Header() {
100
100
  }
101
101
  ```
102
102
 
103
+ Light is the default color scheme, including before hydration. `ThemeScript`,
104
+ `useColorScheme()`, and the color scheme controls preserve saved Dark or System
105
+ preferences. To default to the OS preference explicitly, use
106
+ `<ThemeScript defaultColorScheme="system" />` and `useColorScheme('system')`.
107
+
103
108
  The hook updates `data-product-theme`, applies the selected product theme's
104
109
  token overrides, and persists the selection.
105
110
 
@@ -150,7 +155,7 @@ elsewhere it's the `storageKey` option passed to `useColorScheme`):
150
155
 
151
156
  ```tsx
152
157
  const { theme, switchTheme } = useTheme({ defaultTheme: 'dbc', storageKey: 'my-app-theme' })
153
- const { colorScheme, switchColorScheme } = useColorScheme('system', {
158
+ const { colorScheme, switchColorScheme } = useColorScheme(undefined, {
154
159
  storageKey: 'my-app-color-scheme',
155
160
  })
156
161
  ```
@@ -54,7 +54,8 @@ const Button = React__namespace.forwardRef(function Button2({
54
54
  const computedClassName = cx(
55
55
  styles__default.default.button,
56
56
  styles__default.default[variant],
57
- styles__default.default[size],
57
+ // A class name can't start with a digit.
58
+ size === "2xs" ? styles__default.default.size2xs : styles__default.default[size],
58
59
  fullWidth ? styles__default.default.fullWidth : "",
59
60
  active ? styles__default.default.active : "",
60
61
  loading ? styles__default.default.loading : "",
@@ -7,7 +7,12 @@ export type ButtonSize = Exclude<Size, 'xl'>;
7
7
  export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
8
8
  variant?: ButtonVariant;
9
9
  shape?: 'default' | 'rounded' | 'round';
10
- size?: ButtonSize;
10
+ /**
11
+ * `2xs`: an icon button that fits within a line of text, e.g. next to a form label - no
12
+ * border or padding, so it doesn't make the line taller. Use it with `variant="inline"`
13
+ * and an `aria-label`. Its click target is small, so keep other controls at a distance.
14
+ */
15
+ size?: ButtonSize | '2xs';
11
16
  fullWidth?: boolean;
12
17
  icon?: React.ReactNode;
13
18
  loading?: boolean;
@@ -30,7 +30,8 @@ const Button = React.forwardRef(function Button2({
30
30
  const computedClassName = cx(
31
31
  styles.button,
32
32
  styles[variant],
33
- styles[size],
33
+ // A class name can't start with a digit.
34
+ size === "2xs" ? styles.size2xs : styles[size],
34
35
  fullWidth ? styles.fullWidth : "",
35
36
  active ? styles.active : "",
36
37
  loading ? styles.loading : "",
@@ -292,3 +292,17 @@
292
292
  inline-size: var(--icon-size-sm);
293
293
  block-size: var(--icon-size-sm);
294
294
  }
295
+
296
+ /* Fits within a line of text: no border or padding to make the line taller. */
297
+ .button.size2xs {
298
+ height: auto;
299
+ min-block-size: 0;
300
+ padding: 0;
301
+ border-width: 0;
302
+ line-height: 1;
303
+ }
304
+
305
+ .button.size2xs svg {
306
+ inline-size: var(--icon-size-xs);
307
+ block-size: var(--icon-size-xs);
308
+ }
@@ -16,7 +16,7 @@ const COLOR_SCHEME_OPTIONS = [
16
16
  function ColorSchemeMenuSection({
17
17
  storageKey
18
18
  } = {}) {
19
- const { colorScheme, switchColorScheme } = useColorScheme.useColorScheme("system", { storageKey });
19
+ const { colorScheme, switchColorScheme } = useColorScheme.useColorScheme(void 0, { storageKey });
20
20
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
21
21
  /* @__PURE__ */ jsxRuntime.jsx(Menu.Menu.Header, { children: "Udseende" }),
22
22
  COLOR_SCHEME_OPTIONS.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
@@ -37,7 +37,7 @@ function ColorSchemeButton({
37
37
  variant = "outlined",
38
38
  storageKey
39
39
  }) {
40
- const { colorScheme, switchColorScheme } = useColorScheme.useColorScheme("system", { storageKey });
40
+ const { colorScheme, switchColorScheme } = useColorScheme.useColorScheme(void 0, { storageKey });
41
41
  return /* @__PURE__ */ jsxRuntime.jsx(
42
42
  Popover.Popover,
43
43
  {
@@ -14,7 +14,7 @@ const COLOR_SCHEME_OPTIONS = [
14
14
  function ColorSchemeMenuSection({
15
15
  storageKey
16
16
  } = {}) {
17
- const { colorScheme, switchColorScheme } = useColorScheme("system", { storageKey });
17
+ const { colorScheme, switchColorScheme } = useColorScheme(void 0, { storageKey });
18
18
  return /* @__PURE__ */ jsxs(Fragment, { children: [
19
19
  /* @__PURE__ */ jsx(Menu.Header, { children: "Udseende" }),
20
20
  COLOR_SCHEME_OPTIONS.map((option) => /* @__PURE__ */ jsx(
@@ -35,7 +35,7 @@ function ColorSchemeButton({
35
35
  variant = "outlined",
36
36
  storageKey
37
37
  }) {
38
- const { colorScheme, switchColorScheme } = useColorScheme("system", { storageKey });
38
+ const { colorScheme, switchColorScheme } = useColorScheme(void 0, { storageKey });
39
39
  return /* @__PURE__ */ jsx(
40
40
  Popover,
41
41
  {
@@ -22,6 +22,8 @@ const FileUpload = react.forwardRef(function FileUpload2({
22
22
  fullWidth = false,
23
23
  required,
24
24
  modified,
25
+ modifiedLabel,
26
+ labelAlignment,
25
27
  onChange,
26
28
  children,
27
29
  hint,
@@ -78,6 +80,8 @@ const FileUpload = react.forwardRef(function FileUpload2({
78
80
  fullWidth,
79
81
  required,
80
82
  modified,
83
+ modifiedLabel,
84
+ labelAlignment,
81
85
  children: /* @__PURE__ */ jsxRuntime.jsxs(
82
86
  "label",
83
87
  {
@@ -16,6 +16,8 @@ const FileUpload = forwardRef(function FileUpload2({
16
16
  fullWidth = false,
17
17
  required,
18
18
  modified,
19
+ modifiedLabel,
20
+ labelAlignment,
19
21
  onChange,
20
22
  children,
21
23
  hint,
@@ -72,6 +74,8 @@ const FileUpload = forwardRef(function FileUpload2({
72
74
  fullWidth,
73
75
  required,
74
76
  modified,
77
+ modifiedLabel,
78
+ labelAlignment,
75
79
  children: /* @__PURE__ */ jsxs(
76
80
  "label",
77
81
  {
@@ -67,6 +67,8 @@ function FormSelect({
67
67
  tooltip,
68
68
  tooltipPlacement = "right",
69
69
  modified = false,
70
+ modifiedLabel,
71
+ labelAlignment,
70
72
  // FormSelect props
71
73
  id,
72
74
  name,
@@ -130,6 +132,8 @@ function FormSelect({
130
132
  labelWidth,
131
133
  required,
132
134
  modified,
135
+ modifiedLabel,
136
+ labelAlignment,
133
137
  children: /* @__PURE__ */ jsxRuntime.jsxs(
134
138
  "div",
135
139
  {
@@ -31,5 +31,5 @@ export type FormSelectProps<T> = Omit<InputContainerProps, 'children' | 'htmlFor
31
31
  */
32
32
  allowClearWhenRequired?: boolean;
33
33
  };
34
- export declare function FormSelect<T extends string | number | Record<string, any>>({ label, labelAction, error, helpText, helpTextAddition, orientation, labelWidth, fullWidth, required, tooltip, tooltipPlacement, modified, id, name, options, selectedValue, onChange, placeholder, size, variant, onClear, datakey, dataCy, disabled, includePlaceholderOption, allowClearWhenRequired, }: FormSelectProps<T>): React.ReactNode;
34
+ export declare function FormSelect<T extends string | number | Record<string, any>>({ label, labelAction, error, helpText, helpTextAddition, orientation, labelWidth, fullWidth, required, tooltip, tooltipPlacement, modified, modifiedLabel, labelAlignment, id, name, options, selectedValue, onChange, placeholder, size, variant, onClear, datakey, dataCy, disabled, includePlaceholderOption, allowClearWhenRequired, }: FormSelectProps<T>): React.ReactNode;
35
35
  export {};
@@ -42,6 +42,8 @@ function FormSelect({
42
42
  tooltip,
43
43
  tooltipPlacement = "right",
44
44
  modified = false,
45
+ modifiedLabel,
46
+ labelAlignment,
45
47
  // FormSelect props
46
48
  id,
47
49
  name,
@@ -105,6 +107,8 @@ function FormSelect({
105
107
  labelWidth,
106
108
  required,
107
109
  modified,
110
+ modifiedLabel,
111
+ labelAlignment,
108
112
  children: /* @__PURE__ */ jsxs(
109
113
  "div",
110
114
  {
@@ -36,6 +36,8 @@ const Input = react.forwardRef(function Input2({
36
36
  tooltip,
37
37
  tooltipPlacement = "right",
38
38
  modified = false,
39
+ modifiedLabel,
40
+ labelAlignment,
39
41
  icon,
40
42
  autoFocus,
41
43
  minWidth,
@@ -104,6 +106,8 @@ const Input = react.forwardRef(function Input2({
104
106
  labelWidth,
105
107
  required,
106
108
  modified,
109
+ modifiedLabel,
110
+ labelAlignment,
107
111
  children: /* @__PURE__ */ jsxRuntime.jsxs(
108
112
  "div",
109
113
  {
@@ -30,6 +30,8 @@ const Input = forwardRef(function Input2({
30
30
  tooltip,
31
31
  tooltipPlacement = "right",
32
32
  modified = false,
33
+ modifiedLabel,
34
+ labelAlignment,
33
35
  icon,
34
36
  autoFocus,
35
37
  minWidth,
@@ -98,6 +100,8 @@ const Input = forwardRef(function Input2({
98
100
  labelWidth,
99
101
  required,
100
102
  modified,
103
+ modifiedLabel,
104
+ labelAlignment,
101
105
  children: /* @__PURE__ */ jsxs(
102
106
  "div",
103
107
  {
@@ -34,7 +34,7 @@ function InputContainer({
34
34
  required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.required, children: " *" })
35
35
  ] }),
36
36
  withModifiedTag && modifiedTag,
37
- labelAction && /* @__PURE__ */ jsxRuntime.jsx("span", { "data-input-container-label-action": "true", children: labelAction })
37
+ labelAction && /* @__PURE__ */ jsxRuntime.jsx("span", { className: styles__default.default.labelAction, "data-input-container-label-action": "true", children: labelAction })
38
38
  ] });
39
39
  const renderLabelRow = orientation === "vertical" ? labelRow(true) : modifiedTag ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: styles__default.default.horizontalLabel, children: [
40
40
  labelRow(false),
@@ -28,7 +28,7 @@ function InputContainer({
28
28
  required && /* @__PURE__ */ jsx("span", { className: styles.required, children: " *" })
29
29
  ] }),
30
30
  withModifiedTag && modifiedTag,
31
- labelAction && /* @__PURE__ */ jsx("span", { "data-input-container-label-action": "true", children: labelAction })
31
+ labelAction && /* @__PURE__ */ jsx("span", { className: styles.labelAction, "data-input-container-label-action": "true", children: labelAction })
32
32
  ] });
33
33
  const renderLabelRow = orientation === "vertical" ? labelRow(true) : modifiedTag ? /* @__PURE__ */ jsxs("div", { className: styles.horizontalLabel, children: [
34
34
  labelRow(false),
@@ -16,6 +16,15 @@
16
16
  font-weight: var(--font-weight-medium);
17
17
  }
18
18
 
19
+ /* Fills the rest of the label row like Headline's addition, so the content can
20
+ position itself, e.g. <Stack grow justify="end"> or dbc-ms-auto. */
21
+ .labelAction {
22
+ display: flex;
23
+ flex: 1 1 auto;
24
+ min-width: 0;
25
+ align-items: center;
26
+ }
27
+
19
28
  .horizontal .errorText,
20
29
  .horizontal .helpText {
21
30
  margin-left: calc(var(--label-width) + var(--gap));
@@ -38,7 +47,9 @@
38
47
  white-space: nowrap;
39
48
  }
40
49
 
41
- .horizontal label {
50
+ /* Only the field's own label: a bare `label` selector also sized labels inside
51
+ the control or the label action, e.g. a Switch's text. */
52
+ .horizontal .label {
42
53
  width: var(--label-width);
43
54
  }
44
55
 
@@ -4,8 +4,13 @@
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var react = require('react');
6
6
  var RadioButton = require('./RadioButton');
7
+ var styles = require('./RadioButtons.module.css');
7
8
  var InputContainer = require('../input-container/InputContainer');
8
9
 
10
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
11
+
12
+ var styles__default = /*#__PURE__*/_interopDefault(styles);
13
+
9
14
  function RadioButtonGroup({
10
15
  name,
11
16
  value,
@@ -31,11 +36,7 @@ function RadioButtonGroup({
31
36
  role: "radiogroup",
32
37
  "aria-invalid": Boolean(error) || void 0,
33
38
  "data-cy": dataCy,
34
- style: {
35
- display: "flex",
36
- flexDirection: direction,
37
- gap: "8px"
38
- },
39
+ className: [styles__default.default.group, direction === "row" ? styles__default.default.groupRow : void 0].filter(Boolean).join(" "),
39
40
  children: options.map((opt) => /* @__PURE__ */ jsxRuntime.jsx(
40
41
  RadioButton.RadioButton,
41
42
  {
@@ -2,6 +2,7 @@
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
  import { useId } from 'react';
4
4
  import { RadioButton } from './RadioButton';
5
+ import styles from './RadioButtons.module.css';
5
6
  import { InputContainer } from '../input-container/InputContainer';
6
7
 
7
8
  function RadioButtonGroup({
@@ -29,11 +30,7 @@ function RadioButtonGroup({
29
30
  role: "radiogroup",
30
31
  "aria-invalid": Boolean(error) || void 0,
31
32
  "data-cy": dataCy,
32
- style: {
33
- display: "flex",
34
- flexDirection: direction,
35
- gap: "8px"
36
- },
33
+ className: [styles.group, direction === "row" ? styles.groupRow : void 0].filter(Boolean).join(" "),
37
34
  children: options.map((opt) => /* @__PURE__ */ jsx(
38
35
  RadioButton,
39
36
  {
@@ -129,3 +129,18 @@
129
129
  width: 12px;
130
130
  height: 12px;
131
131
  }
132
+
133
+ .group {
134
+ display: flex;
135
+ flex-direction: column;
136
+ gap: var(--spacing-sm);
137
+ }
138
+
139
+ .groupRow {
140
+ flex-direction: row;
141
+ flex-wrap: wrap;
142
+ }
143
+
144
+ .groupRow > * {
145
+ flex-shrink: 0;
146
+ }
@@ -29,6 +29,8 @@ function Select({
29
29
  tooltip,
30
30
  tooltipPlacement = "right",
31
31
  modified = false,
32
+ modifiedLabel,
33
+ labelAlignment,
32
34
  id,
33
35
  options,
34
36
  selectedValue,
@@ -199,6 +201,8 @@ function Select({
199
201
  labelWidth,
200
202
  required,
201
203
  modified,
204
+ modifiedLabel,
205
+ labelAlignment,
202
206
  children: /* @__PURE__ */ jsxRuntime.jsx(
203
207
  Popover.Popover,
204
208
  {
@@ -20,5 +20,5 @@ export type SelectProps<T> = Omit<InputContainerProps, 'children' | 'htmlFor' |
20
20
  tooltip?: React.ReactNode;
21
21
  tooltipPlacement?: 'top' | 'right' | 'bottom' | 'left';
22
22
  };
23
- export declare function Select<T extends string | number | Record<string, any>>({ label, labelAction, error, helpText, helpTextAddition, 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
+ export declare function Select<T extends string | number | Record<string, any>>({ label, labelAction, error, helpText, helpTextAddition, orientation, labelWidth, fullWidth, required, tooltip, tooltipPlacement, modified, modifiedLabel, labelAlignment, id, options, selectedValue, onChange, placeholder, size, variant, onClear, datakey, dataCy, disabled, minWidth, menuHeader, }: SelectProps<T>): React.ReactNode;
24
24
  export {};
@@ -23,6 +23,8 @@ function Select({
23
23
  tooltip,
24
24
  tooltipPlacement = "right",
25
25
  modified = false,
26
+ modifiedLabel,
27
+ labelAlignment,
26
28
  id,
27
29
  options,
28
30
  selectedValue,
@@ -193,6 +195,8 @@ function Select({
193
195
  labelWidth,
194
196
  required,
195
197
  modified,
198
+ modifiedLabel,
199
+ labelAlignment,
196
200
  children: /* @__PURE__ */ jsx(
197
201
  Popover,
198
202
  {
@@ -26,6 +26,8 @@ const Textarea = function Textarea2({
26
26
  adjustHeight,
27
27
  id,
28
28
  modified = false,
29
+ modifiedLabel,
30
+ labelAlignment,
29
31
  // InputContainer props
30
32
  label,
31
33
  error,
@@ -97,6 +99,8 @@ const Textarea = function Textarea2({
97
99
  InputContainer.InputContainer,
98
100
  {
99
101
  modified,
102
+ modifiedLabel,
103
+ labelAlignment,
100
104
  label,
101
105
  htmlFor: textareaId,
102
106
  error,
@@ -20,6 +20,8 @@ const Textarea = function Textarea2({
20
20
  adjustHeight,
21
21
  id,
22
22
  modified = false,
23
+ modifiedLabel,
24
+ labelAlignment,
23
25
  // InputContainer props
24
26
  label,
25
27
  error,
@@ -91,6 +93,8 @@ const Textarea = function Textarea2({
91
93
  InputContainer,
92
94
  {
93
95
  modified,
96
+ modifiedLabel,
97
+ labelAlignment,
94
98
  label,
95
99
  htmlFor: textareaId,
96
100
  error,