@sikt/sds-combobox 2.2.1 → 3.0.1
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/CHANGELOG.md +18 -0
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [3.0.1](https://gitlab.sikt.no/designsystem/sds-komponentbibliotek/compare/@sikt/sds-combobox@3.0.0...@sikt/sds-combobox@3.0.1) (2025-07-09)
|
|
6
|
+
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
|
|
9
|
+
- **combobox:** fix broken version 3.0.0: replace outdated deps with internal code ([bb9827e](https://gitlab.sikt.no/designsystem/sds-komponentbibliotek/commit/bb9827ef59cbe6c6e398c97f561cd62b9a58b16f))
|
|
10
|
+
|
|
11
|
+
## [3.0.0](https://gitlab.sikt.no/designsystem/sds-komponentbibliotek/compare/@sikt/sds-combobox@2.2.1...@sikt/sds-combobox@3.0.0) (2025-06-25)
|
|
12
|
+
|
|
13
|
+
### ⚠ BREAKING CHANGES
|
|
14
|
+
|
|
15
|
+
- **combobox:** change label to NonNullable<ReactNode>
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
- **combobox:** change label to NonNullable<ReactNode> ([49ccc24](https://gitlab.sikt.no/designsystem/sds-komponentbibliotek/commit/49ccc2465ff16ec849630bc80be34670e373784e))
|
|
20
|
+
- **combobox:** change to ReactNode for helpText & errorText ([89039ed](https://gitlab.sikt.no/designsystem/sds-komponentbibliotek/commit/89039ed38d0d2f042f6b367ea75ce7cbd732c545))
|
|
21
|
+
- **deps:** update dependency react-aria-components to ^1.10.1 ([3410e9a](https://gitlab.sikt.no/designsystem/sds-komponentbibliotek/commit/3410e9a732fd077586885c4ad63d289d26d37276))
|
|
22
|
+
|
|
5
23
|
## [2.2.1](https://gitlab.sikt.no/designsystem/sds-komponentbibliotek/compare/@sikt/sds-combobox@2.2.0...@sikt/sds-combobox@2.2.1) (2025-06-10)
|
|
6
24
|
|
|
7
25
|
### Bug Fixes
|
package/dist/index.d.mts
CHANGED
|
@@ -3,15 +3,15 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
import { ComboBoxProps, PopoverProps, ListBoxItemProps } from 'react-aria-components';
|
|
4
4
|
|
|
5
5
|
interface ComboboxBaseProps<T extends object> extends Omit<ComboBoxProps<T>, "children" | "menuTrigger" | "aria-label" | "aria-labelledby"> {
|
|
6
|
-
children:
|
|
6
|
+
children: ReactNode | ((item: T) => ReactNode);
|
|
7
7
|
className?: string;
|
|
8
|
-
errorText?:
|
|
9
|
-
helpText?:
|
|
8
|
+
errorText?: ReactNode;
|
|
9
|
+
helpText?: ReactNode;
|
|
10
10
|
menuTrigger?: "focus" | "manual" | "input";
|
|
11
11
|
popoverProps?: PopoverProps;
|
|
12
12
|
}
|
|
13
13
|
type ComboboxProps<T extends object> = ComboboxBaseProps<T> & ({
|
|
14
|
-
label:
|
|
14
|
+
label: NonNullable<ReactNode>;
|
|
15
15
|
"aria-labelledby"?: never;
|
|
16
16
|
} | {
|
|
17
17
|
label?: never;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,15 +3,15 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
import { ComboBoxProps, PopoverProps, ListBoxItemProps } from 'react-aria-components';
|
|
4
4
|
|
|
5
5
|
interface ComboboxBaseProps<T extends object> extends Omit<ComboBoxProps<T>, "children" | "menuTrigger" | "aria-label" | "aria-labelledby"> {
|
|
6
|
-
children:
|
|
6
|
+
children: ReactNode | ((item: T) => ReactNode);
|
|
7
7
|
className?: string;
|
|
8
|
-
errorText?:
|
|
9
|
-
helpText?:
|
|
8
|
+
errorText?: ReactNode;
|
|
9
|
+
helpText?: ReactNode;
|
|
10
10
|
menuTrigger?: "focus" | "manual" | "input";
|
|
11
11
|
popoverProps?: PopoverProps;
|
|
12
12
|
}
|
|
13
13
|
type ComboboxProps<T extends object> = ComboboxBaseProps<T> & ({
|
|
14
|
-
label:
|
|
14
|
+
label: NonNullable<ReactNode>;
|
|
15
15
|
"aria-labelledby"?: never;
|
|
16
16
|
} | {
|
|
17
17
|
label?: never;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@sikt/sds-form"),r=require("@sikt/sds-icons"),o=require("clsx/lite"),s=require("react"),
|
|
1
|
+
"use strict";var e=require("@sikt/sds-form"),r=require("@sikt/sds-icons"),o=require("clsx/lite"),s=require("react"),t=require("react-aria-components"),a=require("react/jsx-runtime"),l=Object.defineProperty,i=Object.defineProperties,c=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,b=Object.prototype.hasOwnProperty,x=Object.prototype.propertyIsEnumerable,d=(e,r,o)=>r in e?l(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o,m=(e,r)=>{for(var o in r||(r={}))b.call(r,o)&&d(e,o,r[o]);if(n)for(var o of n(r))x.call(r,o)&&d(e,o,r[o]);return e},p=(e,r)=>i(e,c(r)),u=(e,r)=>{var o={};for(var s in e)b.call(e,s)&&r.indexOf(s)<0&&(o[s]=e[s]);if(null!=e&&n)for(var s of n(e))r.indexOf(s)<0&&x.call(e,s)&&(o[s]=e[s]);return o},f=e=>{let r="";return"string"==typeof e?r=e:"number"==typeof e?r=e.toString():e instanceof Array?e.forEach(e=>{r+=f(e)}):s.isValidElement(e)&&(r+=f(e.props.children)),r};exports.Combobox=function(l){var i=l,{children:c,className:n,errorText:b,helpText:x,label:d,"aria-labelledby":h,menuTrigger:j="focus",popoverProps:v}=i,y=u(i,["children","className","errorText","helpText","label","aria-labelledby","menuTrigger","popoverProps"]);const _=s.useId(),g="".concat(_,"-error-text"),N="".concat(_,"-help-text"),O=f(d),T=[b&&g,x&&N].filter(Boolean).join(" ")||void 0;return a.jsx(e.FormField,{className:o.clsx("sds-combobox",b&&"sds-combobox--invalid",n),label:d,errorText:b,errorTextId:g,helpText:x,helpTextId:N,htmlFor:_,children:a.jsxs(t.ComboBox,p(m({menuTrigger:j,id:_,"aria-label":O,"aria-labelledby":h},y),{children:[a.jsxs("div",{className:"sds-combobox__combobox",children:[a.jsx(t.Input,{className:"sds-combobox__combobox-input","aria-describedby":T,"aria-invalid":Boolean(b),"aria-errormessage":b?g:void 0}),a.jsx(t.Button,{className:"sds-combobox__combobox-button",children:a.jsx(r.ExpandShowAltIcon,{})})]}),a.jsx(t.Popover,p(m({className:"sds-combobox__popover"},v),{children:a.jsx(t.ListBox,{className:"sds-combobox__listbox",children:c})}))]}))})},exports.ComboboxHeader=function({children:e}){return a.jsx(t.Header,{className:"sds-combobox__header",children:e})},exports.ComboboxItem=function(e){var r=e,{className:s}=r,l=u(r,["className"]);return a.jsx(t.ListBoxItem,m({className:o.clsx("sds-combobox__item",s)},l))},exports.ComboboxSection=function({children:e}){return a.jsx(t.ListBoxSection,{children:e})};//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Combobox.tsx"],"names":["useId","jsx","FormField","clsx","jsxs","AriaCombobox","Input","Button","ExpandShowAltIcon","Popover","ListBox","ListBoxItem","Header","ListBoxSection"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../src/reactNodeToString.ts","../src/Combobox.tsx"],"names":["isValidElement","useId","jsx","FormField","clsx","jsxs","AriaCombobox","Input","Button","ExpandShowAltIcon","Popover","ListBox","ListBoxItem","Header","ListBoxSection"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAM,iB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C,EACC,QAAA,kBAAAR,cAAA,CAACS,2BAAQ,EAAA,EAAA,SAAA,EAAU,uBAAyB,EAAA,QAAA,EAAS,CACvD,EAAA,CAAA;AAAA;AAAA,SAAA;AAAA;AACF;AAAA,GACF;AAEJ;AAEO,SAAS,aAAa,EAGiB,EAAA;AAHjB,EAC3B,IAAA,EAAA,GAAA,EAAA,EAAA;AAAA,IAAA;AAAA,GA3GF,GA0G6B,EAExB,EAAA,KAAA,GAAA,SAAA,CAFwB,EAExB,EAAA;AAAA,IADH;AAAA,GAAA,CAAA;AAGA,EAAA,sCACGC,+BAAY,EAAA,cAAA,CAAA,EAAA,SAAA,EAAWR,UAAK,oBAAsB,EAAA,SAAS,KAAO,KAAO,CAAA,CAAA;AAE9E;AAEO,SAAS,cAAA,CAAe,EAAE,QAAA,EAAqC,EAAA;AACpE,EAAA,uBAAQF,cAAA,CAAAW,0BAAA,EAAA,EAAO,SAAU,EAAA,sBAAA,EAAwB,QAAS,EAAA,CAAA;AAC5D;AAEO,SAAS,eAAA,CAAgB,EAAE,QAAA,EAAqC,EAAA;AACrE,EAAO,uBAAAX,cAAA,CAACY,sCAAgB,QAAS,EAAA,CAAA;AACnC","file":"index.js","sourcesContent":["import { isValidElement, ReactNode } from \"react\";\n\nexport const reactNodeToString = (reactNode: ReactNode): string => {\n let string = \"\";\n if (typeof reactNode === \"string\") {\n string = reactNode;\n } else if (typeof reactNode === \"number\") {\n string = reactNode.toString();\n } else if (reactNode instanceof Array) {\n reactNode.forEach((child) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n string += reactNodeToString(child);\n });\n } else if (isValidElement(reactNode)) {\n // @ts-expect-error is of type unknown\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n string += reactNodeToString(reactNode.props.children);\n }\n return string;\n};\n","import { FormField } from \"@sikt/sds-form\";\nimport { ExpandShowAltIcon } from \"@sikt/sds-icons\";\nimport { clsx } from \"clsx/lite\";\nimport { ReactNode, useId } from \"react\";\nimport {\n ComboBox as AriaCombobox,\n ComboBoxProps as AriaComboboxProps,\n Button,\n Header,\n Input,\n ListBox,\n ListBoxItem,\n ListBoxItemProps,\n ListBoxSection,\n Popover,\n PopoverProps,\n} from \"react-aria-components\";\nimport \"./combobox.pcss\";\nimport { reactNodeToString } from \"./reactNodeToString\";\n\ninterface ComboboxBaseProps<T extends object>\n extends Omit<\n AriaComboboxProps<T>,\n \"children\" | \"menuTrigger\" | \"aria-label\" | \"aria-labelledby\"\n > {\n children: ReactNode | ((item: T) => ReactNode);\n className?: string;\n errorText?: ReactNode;\n helpText?: ReactNode;\n menuTrigger?: \"focus\" | \"manual\" | \"input\";\n popoverProps?: PopoverProps;\n}\n\nexport type ComboboxProps<T extends object> = ComboboxBaseProps<T> &\n (\n | {\n label: NonNullable<ReactNode>;\n \"aria-labelledby\"?: never;\n }\n | {\n label?: never;\n \"aria-labelledby\": string;\n }\n );\n\nexport function Combobox<T extends object>({\n children,\n className,\n errorText,\n helpText,\n label,\n \"aria-labelledby\": ariaLabelledBy,\n menuTrigger = \"focus\",\n popoverProps,\n ...props\n}: ComboboxProps<T>) {\n const id = useId();\n const errorTextId = `${id}-error-text`;\n const helpTextId = `${id}-help-text`;\n\n const ariaLabel = reactNodeToString(label);\n const ariaDescribedBy =\n [errorText && errorTextId, helpText && helpTextId]\n .filter(Boolean)\n .join(\" \") || undefined;\n\n return (\n <FormField\n className={clsx(\n \"sds-combobox\",\n errorText && \"sds-combobox--invalid\",\n className,\n )}\n label={label}\n errorText={errorText}\n errorTextId={errorTextId}\n helpText={helpText}\n helpTextId={helpTextId}\n htmlFor={id}\n >\n <AriaCombobox\n menuTrigger={menuTrigger}\n id={id}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n {...props}\n >\n <div className=\"sds-combobox__combobox\">\n <Input\n className=\"sds-combobox__combobox-input\"\n aria-describedby={ariaDescribedBy}\n aria-invalid={Boolean(errorText)}\n aria-errormessage={errorText ? errorTextId : undefined}\n />\n <Button className=\"sds-combobox__combobox-button\">\n <ExpandShowAltIcon />\n </Button>\n </div>\n <Popover className=\"sds-combobox__popover\" {...popoverProps}>\n <ListBox className=\"sds-combobox__listbox\">{children}</ListBox>\n </Popover>\n </AriaCombobox>\n </FormField>\n );\n}\n\nexport function ComboboxItem({\n className,\n ...props\n}: ListBoxItemProps & { className?: string }) {\n return (\n <ListBoxItem className={clsx(\"sds-combobox__item\", className)} {...props} />\n );\n}\n\nexport function ComboboxHeader({ children }: { children: ReactNode }) {\n return <Header className=\"sds-combobox__header\">{children}</Header>;\n}\n\nexport function ComboboxSection({ children }: { children: ReactNode }) {\n return <ListBoxSection>{children}</ListBoxSection>;\n}\n"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{FormField as e}from"@sikt/sds-form";import{ExpandShowAltIcon as r}from"@sikt/sds-icons";import{clsx as o}from"clsx/lite";import{useId as a}from"react";import{ComboBox as l,Input as
|
|
1
|
+
import{FormField as e}from"@sikt/sds-form";import{ExpandShowAltIcon as r}from"@sikt/sds-icons";import{clsx as o}from"clsx/lite";import{useId as a,isValidElement as t}from"react";import{ComboBox as l,Input as i,Button as s,Popover as c,ListBox as n,ListBoxItem as b,Header as m,ListBoxSection as d}from"react-aria-components";import{jsx as p,jsxs as f}from"react/jsx-runtime";var x=Object.defineProperty,u=Object.defineProperties,h=Object.getOwnPropertyDescriptors,v=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable,g=(e,r,o)=>r in e?x(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o,N=(e,r)=>{for(var o in r||(r={}))y.call(r,o)&&g(e,o,r[o]);if(v)for(var o of v(r))_.call(r,o)&&g(e,o,r[o]);return e},O=(e,r)=>u(e,h(r)),T=(e,r)=>{var o={};for(var a in e)y.call(e,a)&&r.indexOf(a)<0&&(o[a]=e[a]);if(null!=e&&v)for(var a of v(e))r.indexOf(a)<0&&_.call(e,a)&&(o[a]=e[a]);return o},j=e=>{let r="";return"string"==typeof e?r=e:"number"==typeof e?r=e.toString():e instanceof Array?e.forEach(e=>{r+=j(e)}):t(e)&&(r+=j(e.props.children)),r};function P(t){var b=t,{children:m,className:d,errorText:x,helpText:u,label:h,"aria-labelledby":v,menuTrigger:y="focus",popoverProps:_}=b,g=T(b,["children","className","errorText","helpText","label","aria-labelledby","menuTrigger","popoverProps"]);const P=a(),w="".concat(P,"-error-text"),I="".concat(P,"-help-text"),k=j(h),B=[x&&w,u&&I].filter(Boolean).join(" ")||void 0;return p(e,{className:o("sds-combobox",x&&"sds-combobox--invalid",d),label:h,errorText:x,errorTextId:w,helpText:u,helpTextId:I,htmlFor:P,children:f(l,O(N({menuTrigger:y,id:P,"aria-label":k,"aria-labelledby":v},g),{children:[f("div",{className:"sds-combobox__combobox",children:[p(i,{className:"sds-combobox__combobox-input","aria-describedby":B,"aria-invalid":Boolean(x),"aria-errormessage":x?w:void 0}),p(s,{className:"sds-combobox__combobox-button",children:p(r,{})})]}),p(c,O(N({className:"sds-combobox__popover"},_),{children:p(n,{className:"sds-combobox__listbox",children:m})}))]}))})}function w(e){var r=e,{className:a}=r,t=T(r,["className"]);return p(b,N({className:o("sds-combobox__item",a)},t))}function I({children:e}){return p(m,{className:"sds-combobox__header",children:e})}function k({children:e}){return p(d,{children:e})}export{P as Combobox,I as ComboboxHeader,w as ComboboxItem,k as ComboboxSection};//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/Combobox.tsx"],"names":["AriaCombobox"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["../src/reactNodeToString.ts","../src/Combobox.tsx"],"names":["AriaCombobox"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEO,IAAM,iBAAA,GAAoB,CAAC,SAAiC,KAAA;AACjE,EAAA,IAAI,MA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,EAAA,QAAA,EAAS,CACvD,EAAA,CAAA;AAAA;AAAA,SAAA;AAAA;AACF;AAAA,GACF;AAEJ;AAEO,SAAS,aAAa,EAGiB,EAAA;AAHjB,EAC3B,IAAA,EAAA,GAAA,EAAA,EAAA;AAAA,IAAA;AAAA,GA3GF,GA0G6B,EAExB,EAAA,KAAA,GAAA,SAAA,CAFwB,EAExB,EAAA;AAAA,IADH;AAAA,GAAA,CAAA;AAGA,EAAA,2BACG,WAAY,EAAA,cAAA,CAAA,EAAA,SAAA,EAAW,KAAK,oBAAsB,EAAA,SAAS,KAAO,KAAO,CAAA,CAAA;AAE9E;AAEO,SAAS,cAAA,CAAe,EAAE,QAAA,EAAqC,EAAA;AACpE,EAAA,uBAAQ,GAAA,CAAA,MAAA,EAAA,EAAO,SAAU,EAAA,sBAAA,EAAwB,QAAS,EAAA,CAAA;AAC5D;AAEO,SAAS,eAAA,CAAgB,EAAE,QAAA,EAAqC,EAAA;AACrE,EAAO,uBAAA,GAAA,CAAC,kBAAgB,QAAS,EAAA,CAAA;AACnC","file":"index.mjs","sourcesContent":["import { isValidElement, ReactNode } from \"react\";\n\nexport const reactNodeToString = (reactNode: ReactNode): string => {\n let string = \"\";\n if (typeof reactNode === \"string\") {\n string = reactNode;\n } else if (typeof reactNode === \"number\") {\n string = reactNode.toString();\n } else if (reactNode instanceof Array) {\n reactNode.forEach((child) => {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n string += reactNodeToString(child);\n });\n } else if (isValidElement(reactNode)) {\n // @ts-expect-error is of type unknown\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n string += reactNodeToString(reactNode.props.children);\n }\n return string;\n};\n","import { FormField } from \"@sikt/sds-form\";\nimport { ExpandShowAltIcon } from \"@sikt/sds-icons\";\nimport { clsx } from \"clsx/lite\";\nimport { ReactNode, useId } from \"react\";\nimport {\n ComboBox as AriaCombobox,\n ComboBoxProps as AriaComboboxProps,\n Button,\n Header,\n Input,\n ListBox,\n ListBoxItem,\n ListBoxItemProps,\n ListBoxSection,\n Popover,\n PopoverProps,\n} from \"react-aria-components\";\nimport \"./combobox.pcss\";\nimport { reactNodeToString } from \"./reactNodeToString\";\n\ninterface ComboboxBaseProps<T extends object>\n extends Omit<\n AriaComboboxProps<T>,\n \"children\" | \"menuTrigger\" | \"aria-label\" | \"aria-labelledby\"\n > {\n children: ReactNode | ((item: T) => ReactNode);\n className?: string;\n errorText?: ReactNode;\n helpText?: ReactNode;\n menuTrigger?: \"focus\" | \"manual\" | \"input\";\n popoverProps?: PopoverProps;\n}\n\nexport type ComboboxProps<T extends object> = ComboboxBaseProps<T> &\n (\n | {\n label: NonNullable<ReactNode>;\n \"aria-labelledby\"?: never;\n }\n | {\n label?: never;\n \"aria-labelledby\": string;\n }\n );\n\nexport function Combobox<T extends object>({\n children,\n className,\n errorText,\n helpText,\n label,\n \"aria-labelledby\": ariaLabelledBy,\n menuTrigger = \"focus\",\n popoverProps,\n ...props\n}: ComboboxProps<T>) {\n const id = useId();\n const errorTextId = `${id}-error-text`;\n const helpTextId = `${id}-help-text`;\n\n const ariaLabel = reactNodeToString(label);\n const ariaDescribedBy =\n [errorText && errorTextId, helpText && helpTextId]\n .filter(Boolean)\n .join(\" \") || undefined;\n\n return (\n <FormField\n className={clsx(\n \"sds-combobox\",\n errorText && \"sds-combobox--invalid\",\n className,\n )}\n label={label}\n errorText={errorText}\n errorTextId={errorTextId}\n helpText={helpText}\n helpTextId={helpTextId}\n htmlFor={id}\n >\n <AriaCombobox\n menuTrigger={menuTrigger}\n id={id}\n aria-label={ariaLabel}\n aria-labelledby={ariaLabelledBy}\n {...props}\n >\n <div className=\"sds-combobox__combobox\">\n <Input\n className=\"sds-combobox__combobox-input\"\n aria-describedby={ariaDescribedBy}\n aria-invalid={Boolean(errorText)}\n aria-errormessage={errorText ? errorTextId : undefined}\n />\n <Button className=\"sds-combobox__combobox-button\">\n <ExpandShowAltIcon />\n </Button>\n </div>\n <Popover className=\"sds-combobox__popover\" {...popoverProps}>\n <ListBox className=\"sds-combobox__listbox\">{children}</ListBox>\n </Popover>\n </AriaCombobox>\n </FormField>\n );\n}\n\nexport function ComboboxItem({\n className,\n ...props\n}: ListBoxItemProps & { className?: string }) {\n return (\n <ListBoxItem className={clsx(\"sds-combobox__item\", className)} {...props} />\n );\n}\n\nexport function ComboboxHeader({ children }: { children: ReactNode }) {\n return <Header className=\"sds-combobox__header\">{children}</Header>;\n}\n\nexport function ComboboxSection({ children }: { children: ReactNode }) {\n return <ListBoxSection>{children}</ListBoxSection>;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sikt/sds-combobox",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"homepage": "https://designsystem.sikt.no/",
|
|
6
6
|
"repository": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@sikt/sds-core": "^4.6.0",
|
|
38
38
|
"@sikt/sds-form": "^4.0.1",
|
|
39
39
|
"@sikt/sds-icons": "^3.0.0",
|
|
40
|
-
"react-aria-components": "^1.10.
|
|
40
|
+
"react-aria-components": "^1.10.1"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@types/react": "^18.0.0 || ^19.0.0",
|