@navikt/ds-react 4.6.0 → 4.7.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 (133) hide show
  1. package/_docs.json +1711 -169
  2. package/cjs/chips/Chips.js +1 -2
  3. package/cjs/date/DateInput.js +1 -0
  4. package/cjs/form/Select.js +1 -0
  5. package/cjs/form/TextField.js +1 -0
  6. package/cjs/form/Textarea.js +1 -0
  7. package/cjs/form/checkbox/Checkbox.js +1 -1
  8. package/cjs/form/combobox/ClearButton.js +27 -0
  9. package/cjs/form/combobox/Combobox.js +78 -0
  10. package/cjs/form/combobox/ComboboxProvider.js +99 -0
  11. package/cjs/form/combobox/ComboboxWrapper.js +51 -0
  12. package/cjs/form/combobox/FilteredOptions/CheckIcon.js +11 -0
  13. package/cjs/form/combobox/FilteredOptions/FilteredOptions.js +46 -0
  14. package/cjs/form/combobox/FilteredOptions/filteredOptionsContext.js +208 -0
  15. package/cjs/form/combobox/Input/Input.js +143 -0
  16. package/cjs/form/combobox/Input/inputContext.js +86 -0
  17. package/cjs/form/combobox/SelectedOptions/SelectedOptions.js +27 -0
  18. package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js +107 -0
  19. package/cjs/form/combobox/ToggleListButton.js +36 -0
  20. package/cjs/form/combobox/customOptionsContext.js +56 -0
  21. package/cjs/form/combobox/index.js +8 -0
  22. package/cjs/form/combobox/package.json +6 -0
  23. package/cjs/form/combobox/types.js +2 -0
  24. package/cjs/form/index.js +3 -1
  25. package/cjs/timeline/AxisLabels.js +12 -12
  26. package/cjs/timeline/Timeline.js +2 -2
  27. package/cjs/util/usePrevious.js +18 -0
  28. package/esm/chips/Chips.js +1 -2
  29. package/esm/chips/Chips.js.map +1 -1
  30. package/esm/date/DateInput.js +1 -0
  31. package/esm/date/DateInput.js.map +1 -1
  32. package/esm/date/datepicker/TableHead.d.ts +1 -0
  33. package/esm/form/Fieldset/useFieldset.d.ts +1 -1
  34. package/esm/form/Select.js +1 -0
  35. package/esm/form/Select.js.map +1 -1
  36. package/esm/form/TextField.js +1 -0
  37. package/esm/form/TextField.js.map +1 -1
  38. package/esm/form/Textarea.js +1 -0
  39. package/esm/form/Textarea.js.map +1 -1
  40. package/esm/form/checkbox/Checkbox.js +1 -1
  41. package/esm/form/checkbox/Checkbox.js.map +1 -1
  42. package/esm/form/checkbox/useCheckbox.d.ts +4 -4
  43. package/esm/form/combobox/ClearButton.d.ts +7 -0
  44. package/esm/form/combobox/ClearButton.js +21 -0
  45. package/esm/form/combobox/ClearButton.js.map +1 -0
  46. package/esm/form/combobox/Combobox.d.ts +4 -0
  47. package/esm/form/combobox/Combobox.js +50 -0
  48. package/esm/form/combobox/Combobox.js.map +1 -0
  49. package/esm/form/combobox/ComboboxProvider.d.ts +26 -0
  50. package/esm/form/combobox/ComboboxProvider.js +72 -0
  51. package/esm/form/combobox/ComboboxProvider.js.map +1 -0
  52. package/esm/form/combobox/ComboboxWrapper.d.ts +14 -0
  53. package/esm/form/combobox/ComboboxWrapper.js +24 -0
  54. package/esm/form/combobox/ComboboxWrapper.js.map +1 -0
  55. package/esm/form/combobox/FilteredOptions/CheckIcon.d.ts +3 -0
  56. package/esm/form/combobox/FilteredOptions/CheckIcon.js +7 -0
  57. package/esm/form/combobox/FilteredOptions/CheckIcon.js.map +1 -0
  58. package/esm/form/combobox/FilteredOptions/FilteredOptions.d.ts +3 -0
  59. package/esm/form/combobox/FilteredOptions/FilteredOptions.js +42 -0
  60. package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -0
  61. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.d.ts +27 -0
  62. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js +178 -0
  63. package/esm/form/combobox/FilteredOptions/filteredOptionsContext.js.map +1 -0
  64. package/esm/form/combobox/Input/Input.d.ts +10 -0
  65. package/esm/form/combobox/Input/Input.js +116 -0
  66. package/esm/form/combobox/Input/Input.js.map +1 -0
  67. package/esm/form/combobox/Input/inputContext.d.ts +19 -0
  68. package/esm/form/combobox/Input/inputContext.js +59 -0
  69. package/esm/form/combobox/Input/inputContext.js.map +1 -0
  70. package/esm/form/combobox/SelectedOptions/SelectedOptions.d.ts +8 -0
  71. package/esm/form/combobox/SelectedOptions/SelectedOptions.js +23 -0
  72. package/esm/form/combobox/SelectedOptions/SelectedOptions.js.map +1 -0
  73. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.d.ts +17 -0
  74. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js +77 -0
  75. package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -0
  76. package/esm/form/combobox/ToggleListButton.d.ts +6 -0
  77. package/esm/form/combobox/ToggleListButton.js +11 -0
  78. package/esm/form/combobox/ToggleListButton.js.map +1 -0
  79. package/esm/form/combobox/customOptionsContext.d.ts +11 -0
  80. package/esm/form/combobox/customOptionsContext.js +29 -0
  81. package/esm/form/combobox/customOptionsContext.js.map +1 -0
  82. package/esm/form/combobox/index.d.ts +2 -0
  83. package/esm/form/combobox/index.js +2 -0
  84. package/esm/form/combobox/index.js.map +1 -0
  85. package/esm/form/combobox/types.d.ts +119 -0
  86. package/esm/form/combobox/types.js +2 -0
  87. package/esm/form/combobox/types.js.map +1 -0
  88. package/esm/form/index.d.ts +1 -0
  89. package/esm/form/index.js +1 -0
  90. package/esm/form/index.js.map +1 -1
  91. package/esm/form/radio/useRadio.d.ts +4 -4
  92. package/esm/form/useFormField.d.ts +11 -10
  93. package/esm/form/useFormField.js.map +1 -1
  94. package/esm/timeline/AxisLabels.d.ts +7 -5
  95. package/esm/timeline/AxisLabels.js +12 -12
  96. package/esm/timeline/AxisLabels.js.map +1 -1
  97. package/esm/timeline/Timeline.d.ts +6 -0
  98. package/esm/timeline/Timeline.js +2 -2
  99. package/esm/timeline/Timeline.js.map +1 -1
  100. package/esm/timeline/utils/types.external.d.ts +5 -0
  101. package/esm/util/usePrevious.d.ts +2 -0
  102. package/esm/util/usePrevious.js +17 -0
  103. package/esm/util/usePrevious.js.map +1 -0
  104. package/package.json +2 -2
  105. package/src/chips/Chips.tsx +1 -1
  106. package/src/date/DateInput.tsx +1 -0
  107. package/src/form/Select.tsx +1 -0
  108. package/src/form/TextField.tsx +2 -0
  109. package/src/form/Textarea.tsx +1 -0
  110. package/src/form/checkbox/Checkbox.tsx +5 -1
  111. package/src/form/combobox/ClearButton.tsx +29 -0
  112. package/src/form/combobox/Combobox.tsx +136 -0
  113. package/src/form/combobox/ComboboxProvider.tsx +99 -0
  114. package/src/form/combobox/ComboboxWrapper.tsx +63 -0
  115. package/src/form/combobox/FilteredOptions/CheckIcon.tsx +23 -0
  116. package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +106 -0
  117. package/src/form/combobox/FilteredOptions/filteredOptionsContext.tsx +266 -0
  118. package/src/form/combobox/Input/Input.tsx +170 -0
  119. package/src/form/combobox/Input/inputContext.tsx +127 -0
  120. package/src/form/combobox/SelectedOptions/SelectedOptions.tsx +45 -0
  121. package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +147 -0
  122. package/src/form/combobox/ToggleListButton.tsx +37 -0
  123. package/src/form/combobox/combobox.stories.tsx +413 -0
  124. package/src/form/combobox/combobox.test.tsx +123 -0
  125. package/src/form/combobox/customOptionsContext.tsx +57 -0
  126. package/src/form/combobox/index.ts +2 -0
  127. package/src/form/combobox/types.ts +122 -0
  128. package/src/form/index.ts +1 -0
  129. package/src/form/useFormField.ts +19 -1
  130. package/src/timeline/AxisLabels.tsx +23 -13
  131. package/src/timeline/Timeline.tsx +18 -2
  132. package/src/timeline/utils/types.external.ts +6 -0
  133. package/src/util/usePrevious.ts +19 -0
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __rest = (this && this.__rest) || function (s, e) {
26
+ var t = {};
27
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
+ t[p] = s[p];
29
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
+ t[p[i]] = s[p[i]];
33
+ }
34
+ return t;
35
+ };
36
+ var __importDefault = (this && this.__importDefault) || function (mod) {
37
+ return (mod && mod.__esModule) ? mod : { "default": mod };
38
+ };
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ const __1 = require("../../..");
41
+ const react_1 = __importStar(require("react"));
42
+ const clsx_1 = __importDefault(require("clsx"));
43
+ const selectedOptionsContext_1 = require("../SelectedOptions/selectedOptionsContext");
44
+ const filteredOptionsContext_1 = require("../FilteredOptions/filteredOptionsContext");
45
+ const inputContext_1 = require("./inputContext");
46
+ const Input = (0, react_1.forwardRef)((_a, ref) => {
47
+ var { inputClassName, error, errorId } = _a, rest = __rest(_a, ["inputClassName", "error", "errorId"]);
48
+ const { clearInput, inputProps, onChange, size, value } = (0, inputContext_1.useInputContext)();
49
+ const { selectedOptions, removeSelectedOption, toggleOption } = (0, selectedOptionsContext_1.useSelectedOptionsContext)();
50
+ const { activeDecendantId, allowNewValues, currentOption, filteredOptions, toggleIsListOpen, isListOpen, filteredOptionsIndex, moveFocusUp, moveFocusDown, ariaDescribedBy, moveFocusToInput, moveFocusToEnd, shouldAutocomplete, } = (0, filteredOptionsContext_1.useFilteredOptionsContext)();
51
+ const onEnter = (0, react_1.useCallback)((event) => {
52
+ if (currentOption) {
53
+ event.preventDefault();
54
+ // Selecting a value from the dropdown / FilteredOptions
55
+ toggleOption(currentOption, event);
56
+ clearInput(event);
57
+ }
58
+ else if (shouldAutocomplete && selectedOptions.includes(value)) {
59
+ event.preventDefault();
60
+ // Trying to set the same value that is already set, so just clearing the input
61
+ clearInput(event);
62
+ }
63
+ else if ((allowNewValues || shouldAutocomplete) && value !== "") {
64
+ event.preventDefault();
65
+ // Autocompleting or adding a new value
66
+ toggleOption(value, event);
67
+ clearInput(event);
68
+ }
69
+ }, [
70
+ allowNewValues,
71
+ clearInput,
72
+ currentOption,
73
+ selectedOptions,
74
+ shouldAutocomplete,
75
+ toggleOption,
76
+ value,
77
+ ]);
78
+ const handleKeyUp = (e) => {
79
+ e.preventDefault();
80
+ switch (e.key) {
81
+ case "Escape":
82
+ clearInput(e);
83
+ toggleIsListOpen(false);
84
+ break;
85
+ case "Enter":
86
+ case "Accept":
87
+ onEnter(e);
88
+ break;
89
+ case "Home":
90
+ moveFocusToInput();
91
+ break;
92
+ case "End":
93
+ moveFocusToEnd();
94
+ break;
95
+ default:
96
+ break;
97
+ }
98
+ };
99
+ const handleKeyDown = (0, react_1.useCallback)((e) => {
100
+ if (e.key === "Backspace") {
101
+ if (value === "") {
102
+ const lastSelectedOption = selectedOptions[selectedOptions.length - 1];
103
+ removeSelectedOption(lastSelectedOption);
104
+ }
105
+ }
106
+ else if (e.key === "ArrowDown") {
107
+ // Check that cursor position is at the end of the input field,
108
+ // so we don't interfere with text editing
109
+ if (e.target.selectionStart === (value === null || value === void 0 ? void 0 : value.length)) {
110
+ e.preventDefault();
111
+ moveFocusDown();
112
+ }
113
+ }
114
+ else if (e.key === "ArrowUp") {
115
+ // Check that the FilteredOptions list is open and has virtual focus.
116
+ // Otherwise ignore keystrokes, so it doesn't interfere with text editing
117
+ if (isListOpen && filteredOptionsIndex !== null) {
118
+ e.preventDefault();
119
+ moveFocusUp();
120
+ }
121
+ }
122
+ }, [
123
+ value,
124
+ selectedOptions,
125
+ removeSelectedOption,
126
+ moveFocusDown,
127
+ isListOpen,
128
+ filteredOptionsIndex,
129
+ moveFocusUp,
130
+ ]);
131
+ const onChangeHandler = (0, react_1.useCallback)((event) => {
132
+ const newValue = event.target.value;
133
+ if (newValue && newValue !== "") {
134
+ toggleIsListOpen(true);
135
+ }
136
+ else if (filteredOptions.length === 0) {
137
+ toggleIsListOpen(false);
138
+ }
139
+ onChange(event);
140
+ }, [filteredOptions.length, onChange, toggleIsListOpen]);
141
+ return (react_1.default.createElement("input", Object.assign({}, rest, (0, __1.omit)(inputProps, ["aria-invalid"]), { ref: ref, value: value, onChange: onChangeHandler, type: "text", role: "combobox", onKeyUp: handleKeyUp, onKeyDown: handleKeyDown, "aria-controls": `${inputProps.id}-filtered-options`, "aria-expanded": !!isListOpen, autoComplete: "off", "aria-autocomplete": shouldAutocomplete ? "both" : "list", "aria-activedescendant": activeDecendantId, "aria-describedby": ariaDescribedBy, className: (0, clsx_1.default)(inputClassName, "navds-combobox__input", "navds-body-short", `navds-body-${size}`) })));
142
+ });
143
+ exports.default = Input;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.useInputContext = exports.InputContextProvider = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const useFormField_1 = require("../../useFormField");
29
+ const InputContext = (0, react_1.createContext)({});
30
+ const InputContextProvider = ({ children, value: props }) => {
31
+ const { defaultValue = "", description, disabled, error, errorId, id: externalId, value: externalValue, onChange: externalOnChange, onClear, shouldAutocomplete, size, } = props;
32
+ const formFieldProps = (0, useFormField_1.useFormField)({
33
+ description,
34
+ disabled,
35
+ error,
36
+ errorId,
37
+ id: externalId,
38
+ size,
39
+ }, "comboboxfield");
40
+ const inputRef = (0, react_1.useRef)(null);
41
+ const [internalValue, setInternalValue] = (0, react_1.useState)(defaultValue);
42
+ const value = (0, react_1.useMemo)(() => String(externalValue !== null && externalValue !== void 0 ? externalValue : internalValue), [externalValue, internalValue]);
43
+ const [searchTerm, setSearchTerm] = (0, react_1.useState)(value);
44
+ const onChange = (0, react_1.useCallback)((event) => {
45
+ const value = event.currentTarget.value;
46
+ externalValue !== null && externalValue !== void 0 ? externalValue : setInternalValue(value);
47
+ externalOnChange === null || externalOnChange === void 0 ? void 0 : externalOnChange(event);
48
+ setSearchTerm(value);
49
+ }, [externalValue, externalOnChange]);
50
+ const setValue = (0, react_1.useCallback)((text) => {
51
+ setInternalValue(text);
52
+ }, [setInternalValue]);
53
+ const clearInput = (0, react_1.useCallback)((event) => {
54
+ onClear === null || onClear === void 0 ? void 0 : onClear(event);
55
+ setValue("");
56
+ setSearchTerm("");
57
+ }, [onClear, setSearchTerm, setValue]);
58
+ const focusInput = (0, react_1.useCallback)(() => {
59
+ var _a, _b;
60
+ (_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.focus) === null || _b === void 0 ? void 0 : _b.call(_a);
61
+ }, []);
62
+ (0, react_1.useLayoutEffect)(() => {
63
+ var _a, _b;
64
+ if (shouldAutocomplete && inputRef && value !== searchTerm) {
65
+ (_b = (_a = inputRef.current) === null || _a === void 0 ? void 0 : _a.setSelectionRange) === null || _b === void 0 ? void 0 : _b.call(_a, searchTerm.length, value.length);
66
+ }
67
+ }, [value, searchTerm, shouldAutocomplete]);
68
+ return (react_1.default.createElement(InputContext.Provider, { value: Object.assign(Object.assign({}, formFieldProps), { clearInput,
69
+ focusInput,
70
+ inputRef,
71
+ value,
72
+ setValue,
73
+ onChange,
74
+ searchTerm,
75
+ setSearchTerm,
76
+ shouldAutocomplete }) }, children));
77
+ };
78
+ exports.InputContextProvider = InputContextProvider;
79
+ const useInputContext = () => {
80
+ const context = (0, react_1.useContext)(InputContext);
81
+ if (!context) {
82
+ throw new Error("useInputContext must be used within an InputContextProvider");
83
+ }
84
+ return context;
85
+ };
86
+ exports.useInputContext = useInputContext;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const __1 = require("../../..");
8
+ const selectedOptionsContext_1 = require("./selectedOptionsContext");
9
+ const Option = ({ option }) => {
10
+ const { isMultiSelect, removeSelectedOption } = (0, selectedOptionsContext_1.useSelectedOptionsContext)();
11
+ const onClick = (e) => {
12
+ e.stopPropagation();
13
+ removeSelectedOption(option);
14
+ };
15
+ if (!isMultiSelect) {
16
+ return (react_1.default.createElement("div", { className: "navds-combobox__selected-options--no-bg" }, option));
17
+ }
18
+ return react_1.default.createElement(__1.Chips.Removable, { onClick: onClick }, option);
19
+ };
20
+ const SelectedOptions = ({ selectedOptions = [], size, children, }) => {
21
+ return (react_1.default.createElement(__1.Chips, { className: "navds-combobox__selected-options", size: size },
22
+ selectedOptions.length
23
+ ? selectedOptions.map((option, i) => (react_1.default.createElement(Option, { key: option + i, option: option })))
24
+ : [],
25
+ children));
26
+ };
27
+ exports.default = SelectedOptions;
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.useSelectedOptionsContext = exports.SelectedOptionsProvider = void 0;
30
+ const react_1 = __importStar(require("react"));
31
+ const usePrevious_1 = __importDefault(require("../../../util/usePrevious"));
32
+ const inputContext_1 = require("../Input/inputContext");
33
+ const customOptionsContext_1 = require("../customOptionsContext");
34
+ const SelectedOptionsContext = (0, react_1.createContext)({});
35
+ const SelectedOptionsProvider = ({ children, value, }) => {
36
+ const { clearInput, focusInput } = (0, inputContext_1.useInputContext)();
37
+ const { customOptions, removeCustomOption, addCustomOption } = (0, customOptionsContext_1.useCustomOptionsContext)();
38
+ const { allowNewValues, isMultiSelect, selectedOptions: externalSelectedOptions, onToggleSelected, options, } = value;
39
+ const [internalSelectedOptions, setSelectedOptions] = (0, react_1.useState)([]);
40
+ const selectedOptions = (0, react_1.useMemo)(() => externalSelectedOptions !== null && externalSelectedOptions !== void 0 ? externalSelectedOptions : [...customOptions, ...internalSelectedOptions], [customOptions, externalSelectedOptions, internalSelectedOptions]);
41
+ const addSelectedOption = (0, react_1.useCallback)((option) => {
42
+ var _a;
43
+ if (!options
44
+ .map((opt) => opt.toLowerCase())
45
+ .includes((_a = option === null || option === void 0 ? void 0 : option.toLowerCase) === null || _a === void 0 ? void 0 : _a.call(option))) {
46
+ allowNewValues && addCustomOption(option);
47
+ }
48
+ else if (isMultiSelect) {
49
+ setSelectedOptions((prevSelectedOptions) => [
50
+ ...prevSelectedOptions,
51
+ option,
52
+ ]);
53
+ }
54
+ else {
55
+ setSelectedOptions([option]);
56
+ }
57
+ onToggleSelected === null || onToggleSelected === void 0 ? void 0 : onToggleSelected(option, true);
58
+ }, [addCustomOption, allowNewValues, isMultiSelect, onToggleSelected, options]);
59
+ const removeSelectedOption = (0, react_1.useCallback)((option) => {
60
+ if (customOptions.includes(option)) {
61
+ removeCustomOption(option);
62
+ }
63
+ else {
64
+ setSelectedOptions((prevSelectedOptions) => prevSelectedOptions.filter((selectedOption) => selectedOption !== option));
65
+ }
66
+ onToggleSelected === null || onToggleSelected === void 0 ? void 0 : onToggleSelected(option, false);
67
+ }, [customOptions, onToggleSelected, removeCustomOption]);
68
+ const toggleOption = (0, react_1.useCallback)((option, event) => {
69
+ if (selectedOptions.includes(option)) {
70
+ removeSelectedOption(option);
71
+ }
72
+ else {
73
+ addSelectedOption(option);
74
+ }
75
+ if (!isMultiSelect) {
76
+ clearInput(event);
77
+ }
78
+ focusInput();
79
+ }, [
80
+ addSelectedOption,
81
+ clearInput,
82
+ focusInput,
83
+ isMultiSelect,
84
+ removeSelectedOption,
85
+ selectedOptions,
86
+ ]);
87
+ const prevSelectedOptions = (0, usePrevious_1.default)(selectedOptions);
88
+ const selectedOptionsState = {
89
+ addSelectedOption,
90
+ isMultiSelect,
91
+ removeSelectedOption,
92
+ prevSelectedOptions,
93
+ selectedOptions,
94
+ setSelectedOptions,
95
+ toggleOption,
96
+ };
97
+ return (react_1.default.createElement(SelectedOptionsContext.Provider, { value: selectedOptionsState }, children));
98
+ };
99
+ exports.SelectedOptionsProvider = SelectedOptionsProvider;
100
+ const useSelectedOptionsContext = () => {
101
+ const context = (0, react_1.useContext)(SelectedOptionsContext);
102
+ if (!context) {
103
+ throw new Error("useSelectedOptionsContext must be used within a SelectedOptionsProvider");
104
+ }
105
+ return context;
106
+ };
107
+ exports.useSelectedOptionsContext = useSelectedOptionsContext;
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ToggleListButton = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const aksel_icons_1 = require("@navikt/aksel-icons");
29
+ const filteredOptionsContext_1 = require("./FilteredOptions/filteredOptionsContext");
30
+ exports.ToggleListButton = (0, react_1.forwardRef)(({ toggleListButtonLabel }, ref) => {
31
+ const { isListOpen, toggleIsListOpen } = (0, filteredOptionsContext_1.useFilteredOptionsContext)();
32
+ return (react_1.default.createElement("button", { type: "button", onPointerUp: () => toggleIsListOpen(), onKeyDown: ({ key }) => key === "Enter" && toggleIsListOpen(), className: "navds-combobox__button-toggle-list", "aria-expanded": isListOpen, tabIndex: -1, ref: ref },
33
+ react_1.default.createElement("span", { className: "navds-sr-only" }, toggleListButtonLabel !== null && toggleListButtonLabel !== void 0 ? toggleListButtonLabel : "Alternativer"),
34
+ isListOpen ? (react_1.default.createElement(aksel_icons_1.ChevronUpIcon, { "aria-hidden": true })) : (react_1.default.createElement(aksel_icons_1.ChevronDownIcon, { "aria-hidden": true }))));
35
+ });
36
+ exports.default = exports.ToggleListButton;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.useCustomOptionsContext = exports.CustomOptionsProvider = void 0;
27
+ const react_1 = __importStar(require("react"));
28
+ const inputContext_1 = require("./Input/inputContext");
29
+ const CustomOptionsContext = (0, react_1.createContext)({});
30
+ const CustomOptionsProvider = ({ children }) => {
31
+ const [customOptions, setCustomOptions] = (0, react_1.useState)([]);
32
+ const { focusInput } = (0, inputContext_1.useInputContext)();
33
+ const removeCustomOption = (0, react_1.useCallback)((option) => {
34
+ setCustomOptions((prevCustomOptions) => prevCustomOptions.filter((o) => o !== option));
35
+ focusInput();
36
+ }, [focusInput, setCustomOptions]);
37
+ const addCustomOption = (0, react_1.useCallback)((option) => {
38
+ setCustomOptions((prevOptions) => [...prevOptions, option]);
39
+ focusInput();
40
+ }, [focusInput, setCustomOptions]);
41
+ const customOptionsState = {
42
+ customOptions,
43
+ removeCustomOption,
44
+ addCustomOption,
45
+ };
46
+ return (react_1.default.createElement(CustomOptionsContext.Provider, { value: customOptionsState }, children));
47
+ };
48
+ exports.CustomOptionsProvider = CustomOptionsProvider;
49
+ const useCustomOptionsContext = () => {
50
+ const context = (0, react_1.useContext)(CustomOptionsContext);
51
+ if (!context) {
52
+ throw new Error("useCustomOptionsContext must be used within a CustomOptionsProvider");
53
+ }
54
+ return context;
55
+ };
56
+ exports.useCustomOptionsContext = useCustomOptionsContext;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Combobox = void 0;
7
+ var ComboboxProvider_1 = require("./ComboboxProvider");
8
+ Object.defineProperty(exports, "Combobox", { enumerable: true, get: function () { return __importDefault(ComboboxProvider_1).default; } });
@@ -0,0 +1,6 @@
1
+ {
2
+ "sideEffects": false,
3
+ "main": "./index.js",
4
+ "module": "../../../esm/form/combobox/index.js",
5
+ "types": "../../../esm/form/combobox/index.d.ts"
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/cjs/form/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.TextField = exports.Textarea = exports.Counter = exports.Switch = exports.Select = exports.Search = exports.RadioGroup = exports.Radio = exports.FieldsetContext = exports.Fieldset = exports.ErrorSummary = exports.ConfirmationPanel = exports.CheckboxGroup = exports.Checkbox = void 0;
6
+ exports.TextField = exports.Textarea = exports.Counter = exports.Switch = exports.Select = exports.UNSAFE_Combobox = exports.Search = exports.RadioGroup = exports.Radio = exports.FieldsetContext = exports.Fieldset = exports.ErrorSummary = exports.ConfirmationPanel = exports.CheckboxGroup = exports.Checkbox = void 0;
7
7
  var checkbox_1 = require("./checkbox");
8
8
  Object.defineProperty(exports, "Checkbox", { enumerable: true, get: function () { return checkbox_1.Checkbox; } });
9
9
  Object.defineProperty(exports, "CheckboxGroup", { enumerable: true, get: function () { return checkbox_1.CheckboxGroup; } });
@@ -19,6 +19,8 @@ Object.defineProperty(exports, "Radio", { enumerable: true, get: function () { r
19
19
  Object.defineProperty(exports, "RadioGroup", { enumerable: true, get: function () { return radio_1.RadioGroup; } });
20
20
  var search_1 = require("./search");
21
21
  Object.defineProperty(exports, "Search", { enumerable: true, get: function () { return search_1.Search; } });
22
+ var combobox_1 = require("./combobox");
23
+ Object.defineProperty(exports, "UNSAFE_Combobox", { enumerable: true, get: function () { return combobox_1.Combobox; } });
22
24
  var Select_1 = require("./Select");
23
25
  Object.defineProperty(exports, "Select", { enumerable: true, get: function () { return __importDefault(Select_1).default; } });
24
26
  var Switch_1 = require("./Switch");
@@ -11,7 +11,7 @@ const react_1 = __importDefault(require("react"));
11
11
  const useTimelineContext_1 = require("./hooks/useTimelineContext");
12
12
  const utils_1 = require("./utils");
13
13
  const calc_1 = require("./utils/calc");
14
- const dayLabels = (start, end, totalDays, direction) => {
14
+ const dayLabels = (start, end, totalDays, direction, template = "dd.MM") => {
15
15
  const increment = Math.ceil(totalDays / 10);
16
16
  const lastDay = (0, date_fns_1.startOfDay)(end);
17
17
  return new Array(totalDays)
@@ -24,7 +24,7 @@ const dayLabels = (start, end, totalDays, direction) => {
24
24
  return {
25
25
  direction: direction,
26
26
  horizontalPosition: horizontalPosition,
27
- label: (0, date_fns_1.format)(day, "dd.MM", { locale: nb_1.default }),
27
+ label: (0, date_fns_1.format)(day, template, { locale: nb_1.default }),
28
28
  date: day,
29
29
  width: width,
30
30
  };
@@ -32,7 +32,7 @@ const dayLabels = (start, end, totalDays, direction) => {
32
32
  .filter((label) => label !== null);
33
33
  };
34
34
  exports.dayLabels = dayLabels;
35
- const monthLabels = (start, end, direction) => {
35
+ const monthLabels = (start, end, direction, template = "MMM yy") => {
36
36
  const startMonth = (0, date_fns_1.startOfMonth)(start);
37
37
  const endMonth = (0, date_fns_1.endOfMonth)(end);
38
38
  const numberOfMonths = (0, date_fns_1.differenceInMonths)(endMonth, startMonth) + 1;
@@ -42,14 +42,14 @@ const monthLabels = (start, end, direction) => {
42
42
  return {
43
43
  direction: direction,
44
44
  horizontalPosition: horizontalPosition,
45
- label: (0, date_fns_1.format)(month, "MMM yy", { locale: nb_1.default }),
45
+ label: (0, date_fns_1.format)(month, template, { locale: nb_1.default }),
46
46
  date: month,
47
47
  width: width,
48
48
  };
49
49
  });
50
50
  };
51
51
  exports.monthLabels = monthLabels;
52
- const yearLabels = (start, end, direction) => {
52
+ const yearLabels = (start, end, direction, template = "yyyy") => {
53
53
  const firstYear = (0, date_fns_1.startOfYear)(start);
54
54
  const lastYear = (0, date_fns_1.endOfYear)(end);
55
55
  const yearCount = (0, date_fns_1.differenceInYears)(lastYear, start) + 1;
@@ -59,28 +59,28 @@ const yearLabels = (start, end, direction) => {
59
59
  return {
60
60
  direction: direction,
61
61
  horizontalPosition: horizontalPosition,
62
- label: year.getFullYear().toString(),
62
+ label: (0, date_fns_1.format)(year, template, { locale: nb_1.default }),
63
63
  date: year,
64
64
  width: width,
65
65
  };
66
66
  });
67
67
  };
68
68
  exports.yearLabels = yearLabels;
69
- const axisLabels = (start, end, direction) => {
69
+ const axisLabels = (start, end, direction, templates) => {
70
70
  const totalDays = (0, date_fns_1.differenceInDays)(end, start);
71
71
  if (totalDays < 40) {
72
- return (0, exports.dayLabels)(start, end, totalDays, direction);
72
+ return (0, exports.dayLabels)(start, end, totalDays, direction, templates === null || templates === void 0 ? void 0 : templates.day);
73
73
  }
74
74
  else if (totalDays < 370) {
75
- return (0, exports.monthLabels)(start, end, direction);
75
+ return (0, exports.monthLabels)(start, end, direction, templates === null || templates === void 0 ? void 0 : templates.month);
76
76
  }
77
77
  else {
78
- return (0, exports.yearLabels)(start, end, direction);
78
+ return (0, exports.yearLabels)(start, end, direction, templates === null || templates === void 0 ? void 0 : templates.year);
79
79
  }
80
80
  };
81
- const AxisLabels = () => {
81
+ const AxisLabels = ({ templates, }) => {
82
82
  const { endDate, startDate, direction } = (0, useTimelineContext_1.useTimelineContext)();
83
- const labels = axisLabels(startDate, endDate, direction).filter(utils_1.isVisible);
83
+ const labels = axisLabels(startDate, endDate, direction, templates).filter(utils_1.isVisible);
84
84
  return (react_1.default.createElement("div", { className: "navds-timeline__axislabels", "aria-hidden": "true" }, labels.map((etikett) => (react_1.default.createElement(Detail_1.Detail, { className: "navds-timeline__axislabels-label", as: "div", key: etikett.label, style: {
85
85
  justifyContent: direction === "left" ? "flex-start" : "flex-end",
86
86
  [direction]: `${etikett.horizontalPosition}%`,
@@ -68,7 +68,7 @@ const zoom_1 = __importDefault(require("./zoom"));
68
68
  * ```
69
69
  */
70
70
  exports.Timeline = (0, react_1.forwardRef)((_a, ref) => {
71
- var { children, startDate, endDate, direction = "left" } = _a, rest = __rest(_a, ["children", "startDate", "endDate", "direction"]);
71
+ var { children, startDate, endDate, direction = "left", axisLabelTemplates } = _a, rest = __rest(_a, ["children", "startDate", "endDate", "direction", "axisLabelTemplates"]);
72
72
  const isMultipleRows = Array.isArray(children);
73
73
  const firstFocusabled = (0, react_1.useRef)([]);
74
74
  if (!isMultipleRows) {
@@ -158,7 +158,7 @@ exports.Timeline = (0, react_1.forwardRef)((_a, ref) => {
158
158
  } },
159
159
  react_1.default.createElement("div", Object.assign({}, rest, { ref: ref }),
160
160
  react_1.default.createElement("div", { className: "navds-timeline" },
161
- react_1.default.createElement(AxisLabels_1.AxisLabels, null),
161
+ react_1.default.createElement(AxisLabels_1.AxisLabels, { templates: axisLabelTemplates }),
162
162
  pins.map((pin) => {
163
163
  return pin;
164
164
  }),
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("react");
4
+ /*
5
+ * usePrevious hook
6
+ * The ref object's "current" property is mutable and when changed wont re-render the component
7
+ * meaning it can be used to stay "one render behind" the current state
8
+ * https://usehooks.com/usePrevious/
9
+ * https://blog.logrocket.com/accessing-previous-props-state-react-hooks/
10
+ */
11
+ const usePrevious = (value) => {
12
+ const ref = (0, react_1.useRef)(value);
13
+ (0, react_1.useEffect)(() => {
14
+ ref.current = value;
15
+ }, [value]);
16
+ return ref.current;
17
+ };
18
+ exports.default = usePrevious;
@@ -46,8 +46,7 @@ export const Chips = forwardRef((_a, ref) => {
46
46
  "navds-body-short navds-body-short--small": size === "medium",
47
47
  "navds-detail navds-detail--small": size === "small",
48
48
  }) }), React.Children.map(children, (chip, index) => {
49
- var _a;
50
- return React.createElement("li", { key: index + ((_a = chip === null || chip === void 0 ? void 0 : chip.toString()) !== null && _a !== void 0 ? _a : "") }, chip);
49
+ return React.createElement("li", { key: (chip === null || chip === void 0 ? void 0 : chip.toString()) || index }, chip);
51
50
  })));
52
51
  });
53
52
  Chips.Toggle = ToggleChips;
@@ -1 +1 @@
1
- {"version":3,"file":"Chips.js","sourceRoot":"","sources":["../../src/chips/Chips.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAC1D,OAAO,WAAiC,MAAM,UAAU,CAAC;AACzD,OAAO,cAAuC,MAAM,aAAa,CAAC;AA8BlE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,KAAK,GAAmB,UAAU,CAC7C,CAAC,EAAiD,EAAE,GAAG,EAAE,EAAE;QAA1D,EAAE,SAAS,EAAE,IAAI,GAAG,QAAQ,EAAE,QAAQ,OAAW,EAAN,IAAI,cAA/C,iCAAiD,CAAF;IAC9C,OAAO,CACL,4CACM,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,gBAAgB,IAAI,EAAE,EAAE;YAC9D,0CAA0C,EAAE,IAAI,KAAK,QAAQ;YAC7D,kCAAkC,EAAE,IAAI,KAAK,OAAO;SACrD,CAAC,KAED,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;;QAC5C,OAAO,4BAAI,GAAG,EAAE,KAAK,GAAG,CAAC,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,EAAE,mCAAI,EAAE,CAAC,IAAG,IAAI,CAAM,CAAC;IAChE,CAAC,CAAC,CACC,CACN,CAAC;AACJ,CAAC,CACgB,CAAC;AAEpB,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC;AAC3B,KAAK,CAAC,SAAS,GAAG,cAAc,CAAC;AAEjC,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"Chips.js","sourceRoot":"","sources":["../../src/chips/Chips.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAC1D,OAAO,WAAiC,MAAM,UAAU,CAAC;AACzD,OAAO,cAAuC,MAAM,aAAa,CAAC;AA8BlE;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,KAAK,GAAmB,UAAU,CAC7C,CAAC,EAAiD,EAAE,GAAG,EAAE,EAAE;QAA1D,EAAE,SAAS,EAAE,IAAI,GAAG,QAAQ,EAAE,QAAQ,OAAW,EAAN,IAAI,cAA/C,iCAAiD,CAAF;IAC9C,OAAO,CACL,4CACM,IAAI,IACR,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,EAAE,CAAC,aAAa,EAAE,SAAS,EAAE,gBAAgB,IAAI,EAAE,EAAE;YAC9D,0CAA0C,EAAE,IAAI,KAAK,QAAQ;YAC7D,kCAAkC,EAAE,IAAI,KAAK,OAAO;SACrD,CAAC,KAED,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC5C,OAAO,4BAAI,GAAG,EAAE,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,EAAE,KAAI,KAAK,IAAG,IAAI,CAAM,CAAC;IACzD,CAAC,CAAC,CACC,CACN,CAAC;AACJ,CAAC,CACgB,CAAC;AAEpB,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC;AAC3B,KAAK,CAAC,SAAS,GAAG,cAAc,CAAC;AAEjC,eAAe,KAAK,CAAC"}
@@ -33,6 +33,7 @@ const DateInput = forwardRef((props, ref) => {
33
33
  "navds-date__field--error": hasError,
34
34
  "navds-form-field--disabled": !!inputProps.disabled,
35
35
  "navds-text-field--disabled": !!inputProps.disabled,
36
+ "navds-form-field--readonly": readOnly,
36
37
  "navds-text-field--readonly": readOnly,
37
38
  "navds-date__field--readonly": readOnly,
38
39
  }) },