@digdir/designsystemet-react 1.1.1 → 1.1.2

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.
@@ -30,6 +30,8 @@ const nextItems = (data, prev, multiple) => {
30
30
  const defaultFilter = ({ label, input }) => label.toLowerCase().includes(input.value.trim().toLowerCase());
31
31
  const Suggestion = react.forwardRef(function Suggestion({ children, className, creatable = false, defaultValue, filter = true, multiple = false, name, onValueChange, value, ...rest }, ref) {
32
32
  const uComboboxRef = react.useRef(null);
33
+ const generatedSelectId = react.useId();
34
+ const selectId = rest.id ? `${rest.id}-select` : generatedSelectId;
33
35
  const isContolled = value !== undefined;
34
36
  const mergedRefs = useMergeRefs.useMergeRefs([ref, uComboboxRef]);
35
37
  const [isEmpty, setIsEmpty] = react.useState(false);
@@ -78,7 +80,7 @@ const Suggestion = react.forwardRef(function Suggestion({ children, className, c
78
80
  }
79
81
  setIsEmpty(index === disabled);
80
82
  }, [filter]);
81
- return (jsxRuntime.jsx(SuggestionContext.Provider, { value: { isEmpty, selectedItems, handleFilter }, children: jsxRuntime.jsxs("u-combobox", { "data-multiple": multiple || undefined, "data-creatable": creatable || undefined, class: cl('ds-suggestion', className), ref: mergedRefs, ...rest, children: [children, !!name && jsxRuntime.jsx("select", { name: name, multiple: true, hidden: true })] }) }));
83
+ return (jsxRuntime.jsx(SuggestionContext.Provider, { value: { isEmpty, selectedItems, handleFilter }, children: jsxRuntime.jsxs("u-combobox", { "data-multiple": multiple || undefined, "data-creatable": creatable || undefined, class: cl('ds-suggestion', className), ref: mergedRefs, ...rest, children: [children, !!name && (jsxRuntime.jsx("select", { name: name, multiple: true, hidden: true, id: selectId }))] }) }));
82
84
  });
83
85
 
84
86
  exports.Suggestion = Suggestion;
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { forwardRef, createContext, useRef, useState, useEffect, useCallback } from 'react';
3
+ import { forwardRef, createContext, useRef, useId, useState, useEffect, useCallback } from 'react';
4
4
  import '@u-elements/u-combobox';
5
5
  import cl from 'clsx/lite';
6
6
  import { useMergeRefs } from '../../utilities/hooks/useMergeRefs/useMergeRefs.js';
@@ -28,6 +28,8 @@ const nextItems = (data, prev, multiple) => {
28
28
  const defaultFilter = ({ label, input }) => label.toLowerCase().includes(input.value.trim().toLowerCase());
29
29
  const Suggestion = forwardRef(function Suggestion({ children, className, creatable = false, defaultValue, filter = true, multiple = false, name, onValueChange, value, ...rest }, ref) {
30
30
  const uComboboxRef = useRef(null);
31
+ const generatedSelectId = useId();
32
+ const selectId = rest.id ? `${rest.id}-select` : generatedSelectId;
31
33
  const isContolled = value !== undefined;
32
34
  const mergedRefs = useMergeRefs([ref, uComboboxRef]);
33
35
  const [isEmpty, setIsEmpty] = useState(false);
@@ -76,7 +78,7 @@ const Suggestion = forwardRef(function Suggestion({ children, className, creatab
76
78
  }
77
79
  setIsEmpty(index === disabled);
78
80
  }, [filter]);
79
- return (jsx(SuggestionContext.Provider, { value: { isEmpty, selectedItems, handleFilter }, children: jsxs("u-combobox", { "data-multiple": multiple || undefined, "data-creatable": creatable || undefined, class: cl('ds-suggestion', className), ref: mergedRefs, ...rest, children: [children, !!name && jsx("select", { name: name, multiple: true, hidden: true })] }) }));
81
+ return (jsx(SuggestionContext.Provider, { value: { isEmpty, selectedItems, handleFilter }, children: jsxs("u-combobox", { "data-multiple": multiple || undefined, "data-creatable": creatable || undefined, class: cl('ds-suggestion', className), ref: mergedRefs, ...rest, children: [children, !!name && (jsx("select", { name: name, multiple: true, hidden: true, id: selectId }))] }) }));
80
82
  });
81
83
 
82
84
  export { Suggestion, SuggestionContext };
@@ -1 +1 @@
1
- {"version":3,"file":"Suggestion.d.ts","sourceRoot":"","sources":["../../../src/components/Suggestion/Suggestion.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,cAAc,EAKpB,MAAM,OAAO,CAAC;AACf,OAAO,wBAAwB,CAAC;AAChC,OAAO,K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CAAC,EAAE,gBAAgB,GAAG,IAAI,KAAK,IAAI,CAAC;CACzD,CAAC;AAEF,eAAO,MAAM,iBAAiB,sCAE5B,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;AA+BzC,eAAO,MAAM,UAAU;IAxErB;;;;;;;;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;qFAiId,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@digdir/designsystemet-react",
3
3
  "type": "module",
4
- "version": "1.1.1",
4
+ "version": "1.1.2",
5
5
  "description": "React components for Designsystemet",
6
6
  "author": "Designsystemet team",
7
7
  "repository": {
@@ -67,7 +67,7 @@
67
67
  "storybook": "^9.0.12",
68
68
  "tsx": "4.20.3",
69
69
  "typescript": "^5.8.3",
70
- "@digdir/designsystemet-css": "^1.1.1"
70
+ "@digdir/designsystemet-css": "^1.1.2"
71
71
  },
72
72
  "scripts": {
73
73
  "build": "pnpm run clean && tsc -b tsconfig.lib.json --emitDeclarationOnly false && rollup -c --bundleConfigAsCjs",