@digdir/designsystemet-react 0.0.0-test-20250714130823 → 0.0.0-test-20250715062533
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/cjs/components/field/field-observer.js +1 -1
- package/dist/cjs/components/suggestion/suggestion.js +8 -13
- package/dist/esm/components/field/field-observer.js +1 -1
- package/dist/esm/components/suggestion/suggestion.js +8 -13
- package/dist/types/components/suggestion/suggestion.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -44,7 +44,7 @@ function fieldObserver(fieldElement) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
// Connect elements
|
|
47
|
-
const describedbyIds = [
|
|
47
|
+
const describedbyIds = describedby ? describedby.split(' ') : []; // Keep original aria-describedby
|
|
48
48
|
const inputId = input?.id || uuid;
|
|
49
49
|
// Reset type counters since we reprocess all elements
|
|
50
50
|
typeCounter.clear();
|
|
@@ -33,17 +33,12 @@ const Suggestion = react.forwardRef(function Suggestion({ children, className, c
|
|
|
33
33
|
const uComboboxRef = react.useRef(null);
|
|
34
34
|
const genId = react.useId();
|
|
35
35
|
const selectId = rest.id ? `${rest.id}-select` : genId;
|
|
36
|
-
const
|
|
36
|
+
const isControlled = value !== undefined;
|
|
37
37
|
const mergedRefs = useMergeRefs.useMergeRefs([ref, uComboboxRef]);
|
|
38
|
+
const [listId, setListId] = react.useState(`${rest.id || genId}-list`);
|
|
38
39
|
const [isEmpty, setIsEmpty] = react.useState(false);
|
|
39
|
-
const [
|
|
40
|
-
const
|
|
41
|
-
// Update if controlled values
|
|
42
|
-
const prevControlled = react.useRef(value);
|
|
43
|
-
if (value !== prevControlled.current) {
|
|
44
|
-
prevControlled.current = value;
|
|
45
|
-
setSelectedItems(sanitizeItems(prevControlled.current));
|
|
46
|
-
}
|
|
40
|
+
const [defaultItems, setDefaultItems] = react.useState(sanitizeItems(defaultValue));
|
|
41
|
+
const selectedItems = value ? sanitizeItems(value) : defaultItems;
|
|
47
42
|
/**
|
|
48
43
|
* Listerners and handling of adding/removing
|
|
49
44
|
*/
|
|
@@ -53,14 +48,14 @@ const Suggestion = react.forwardRef(function Suggestion({ children, className, c
|
|
|
53
48
|
event.preventDefault();
|
|
54
49
|
const multiple = combobox?.multiple;
|
|
55
50
|
const data = event.detail;
|
|
56
|
-
if (
|
|
57
|
-
onValueChange?.(nextItems(data,
|
|
51
|
+
if (isControlled)
|
|
52
|
+
onValueChange?.(nextItems(data, selectedItems, multiple));
|
|
58
53
|
else
|
|
59
|
-
|
|
54
|
+
setDefaultItems(nextItems(data, selectedItems, multiple));
|
|
60
55
|
};
|
|
61
56
|
combobox?.addEventListener('beforechange', beforeChange);
|
|
62
57
|
return () => combobox?.removeEventListener('beforechange', beforeChange);
|
|
63
|
-
}, [
|
|
58
|
+
}, [selectedItems, isControlled]);
|
|
64
59
|
const handleFilter = react.useCallback(() => {
|
|
65
60
|
const { control: input, options = [] } = uComboboxRef?.current || {};
|
|
66
61
|
const filterFn = filter === true ? defaultFilter : filter;
|
|
@@ -42,7 +42,7 @@ function fieldObserver(fieldElement) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
// Connect elements
|
|
45
|
-
const describedbyIds = [
|
|
45
|
+
const describedbyIds = describedby ? describedby.split(' ') : []; // Keep original aria-describedby
|
|
46
46
|
const inputId = input?.id || uuid;
|
|
47
47
|
// Reset type counters since we reprocess all elements
|
|
48
48
|
typeCounter.clear();
|
|
@@ -31,17 +31,12 @@ const Suggestion = forwardRef(function Suggestion({ children, className, creatab
|
|
|
31
31
|
const uComboboxRef = useRef(null);
|
|
32
32
|
const genId = useId();
|
|
33
33
|
const selectId = rest.id ? `${rest.id}-select` : genId;
|
|
34
|
-
const
|
|
34
|
+
const isControlled = value !== undefined;
|
|
35
35
|
const mergedRefs = useMergeRefs([ref, uComboboxRef]);
|
|
36
|
+
const [listId, setListId] = useState(`${rest.id || genId}-list`);
|
|
36
37
|
const [isEmpty, setIsEmpty] = useState(false);
|
|
37
|
-
const [
|
|
38
|
-
const
|
|
39
|
-
// Update if controlled values
|
|
40
|
-
const prevControlled = useRef(value);
|
|
41
|
-
if (value !== prevControlled.current) {
|
|
42
|
-
prevControlled.current = value;
|
|
43
|
-
setSelectedItems(sanitizeItems(prevControlled.current));
|
|
44
|
-
}
|
|
38
|
+
const [defaultItems, setDefaultItems] = useState(sanitizeItems(defaultValue));
|
|
39
|
+
const selectedItems = value ? sanitizeItems(value) : defaultItems;
|
|
45
40
|
/**
|
|
46
41
|
* Listerners and handling of adding/removing
|
|
47
42
|
*/
|
|
@@ -51,14 +46,14 @@ const Suggestion = forwardRef(function Suggestion({ children, className, creatab
|
|
|
51
46
|
event.preventDefault();
|
|
52
47
|
const multiple = combobox?.multiple;
|
|
53
48
|
const data = event.detail;
|
|
54
|
-
if (
|
|
55
|
-
onValueChange?.(nextItems(data,
|
|
49
|
+
if (isControlled)
|
|
50
|
+
onValueChange?.(nextItems(data, selectedItems, multiple));
|
|
56
51
|
else
|
|
57
|
-
|
|
52
|
+
setDefaultItems(nextItems(data, selectedItems, multiple));
|
|
58
53
|
};
|
|
59
54
|
combobox?.addEventListener('beforechange', beforeChange);
|
|
60
55
|
return () => combobox?.removeEventListener('beforechange', beforeChange);
|
|
61
|
-
}, [
|
|
56
|
+
}, [selectedItems, isControlled]);
|
|
62
57
|
const handleFilter = useCallback(() => {
|
|
63
58
|
const { control: input, options = [] } = uComboboxRef?.current || {};
|
|
64
59
|
const filterFn = filter === true ? defaultFilter : filter;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggestion.d.ts","sourceRoot":"","sources":["../../../src/components/suggestion/suggestion.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EAMpB,MAAM,OAAO,CAAC;AACf,OAAO,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAInE,MAAM,MAAM,gBAAgB,GAAG,KAAK,CA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CAAC,EAAE,MAAM,CAAC;CACf,GAAG,cAAc,CAAC,oBAAoB,CAAC,CAAC;AAgCzC,eAAO,MAAM,UAAU;IAzErB;;;;;;;;OAQG;aACM,OAAO,GAAG,MAAM;IACzB;;;;OAIG;gBACS,OAAO;IACnB;;;;OAIG;eACQ,OAAO;IAClB;;;OAGG;YACK,gBAAgB;IACxB;;OAEG;mBACY,gBAAgB;IAC/B;;OAEG;oBACa,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI;IACvC;;;;OAIG;WACI,MAAM;
|
|
1
|
+
{"version":3,"file":"suggestion.d.ts","sourceRoot":"","sources":["../../../src/components/suggestion/suggestion.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EAMpB,MAAM,OAAO,CAAC;AACf,OAAO,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAInE,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC;AAEtE,KAAK,IAAI,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAC7C,KAAK,MAAM,GAAG,CAAC,IAAI,EAAE;IACnB;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,aAAa,EAAE,iBAAiB,CAAC;IACjC;;OAEG;IACH,KAAK,EAAE,gBAAgB,CAAC;CACzB,KAAK,OAAO,CAAC;AAEd,KAAK,qBAAqB,GAAG;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,IAAI,EAAE,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,YAAY,EAAE,CAAC,KAAK,CAAC,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,CAAC;CACzD,CAAC;AAEF,eAAO,MAAM,iBAAiB,sCAG5B,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG;IAC5B;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC1B;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB;;OAEG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACxC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,cAAc,CAAC,oBAAoB,CAAC,CAAC;AAgCzC,eAAO,MAAM,UAAU;IAzErB;;;;;;;;OAQG;aACM,OAAO,GAAG,MAAM;IACzB;;;;OAIG;gBACS,OAAO;IACnB;;;;OAIG;eACQ,OAAO;IAClB;;;OAGG;YACK,gBAAgB;IACxB;;OAEG;mBACY,gBAAgB;IAC/B;;OAEG;oBACa,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI;IACvC;;;;OAIG;WACI,MAAM;qFA4Hd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digdir/designsystemet-react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.0-test-
|
|
4
|
+
"version": "0.0.0-test-20250715062533",
|
|
5
5
|
"description": "React components for Designsystemet",
|
|
6
6
|
"author": "Designsystemet team",
|
|
7
7
|
"repository": {
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"storybook": "^9.0.15",
|
|
68
68
|
"tsx": "4.20.3",
|
|
69
69
|
"typescript": "^5.8.3",
|
|
70
|
-
"@digdir/designsystemet-css": "^0.0.0-test-
|
|
70
|
+
"@digdir/designsystemet-css": "^0.0.0-test-20250715062533"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"build": "pnpm run clean && tsc -b tsconfig.lib.json --emitDeclarationOnly false && rollup -c --bundleConfigAsCjs",
|