@uva-glass/component-library 1.0.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.
- package/README.md +3 -0
- package/dist/SelectListbox.module-wZfvJXBJ.js +22 -0
- package/dist/SelectListbox.module-wZfvJXBJ.js.map +1 -0
- package/dist/assets/Button.css +1 -0
- package/dist/assets/Card.css +1 -0
- package/dist/assets/ClipboardButton.css +1 -0
- package/dist/assets/Icon.css +1 -0
- package/dist/assets/IconButton.css +1 -0
- package/dist/assets/InfoMessage.css +1 -0
- package/dist/assets/SectionNotification.css +1 -0
- package/dist/assets/SelectListbox.css +1 -0
- package/dist/clsx-DB4S2d7J.js +23 -0
- package/dist/clsx-DB4S2d7J.js.map +1 -0
- package/dist/components/Button/Button.d.ts +8 -0
- package/dist/components/Button/Button.js +28 -0
- package/dist/components/Button/Button.js.map +1 -0
- package/dist/components/Button/Button.stories.d.ts +5 -0
- package/dist/components/Button/Button.stories.js +25 -0
- package/dist/components/Button/Button.stories.js.map +1 -0
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/Button/index.js +5 -0
- package/dist/components/Button/index.js.map +1 -0
- package/dist/components/Card/Card.d.ts +10 -0
- package/dist/components/Card/Card.js +41 -0
- package/dist/components/Card/Card.js.map +1 -0
- package/dist/components/Card/Card.stories.d.ts +8 -0
- package/dist/components/Card/Card.stories.js +49 -0
- package/dist/components/Card/Card.stories.js.map +1 -0
- package/dist/components/Card/index.d.ts +1 -0
- package/dist/components/Card/index.js +5 -0
- package/dist/components/Card/index.js.map +1 -0
- package/dist/components/Icon/Icon.d.ts +11 -0
- package/dist/components/Icon/Icon.js +10 -0
- package/dist/components/Icon/Icon.js.map +1 -0
- package/dist/components/Icon/Icon.stories.d.ts +6 -0
- package/dist/components/Icon/Icon.stories.js +41 -0
- package/dist/components/Icon/Icon.stories.js.map +1 -0
- package/dist/components/Icon/icons/index.d.ts +152 -0
- package/dist/components/Icon/icons/index.js +57 -0
- package/dist/components/Icon/icons/index.js.map +1 -0
- package/dist/components/Icon/index.d.ts +1 -0
- package/dist/components/Icon/index.js +5 -0
- package/dist/components/Icon/index.js.map +1 -0
- package/dist/components/IconButton/IconButton.d.ts +9 -0
- package/dist/components/IconButton/IconButton.js +30 -0
- package/dist/components/IconButton/IconButton.js.map +1 -0
- package/dist/components/IconButton/IconButton.stories.d.ts +5 -0
- package/dist/components/IconButton/IconButton.stories.js +48 -0
- package/dist/components/IconButton/IconButton.stories.js.map +1 -0
- package/dist/components/IconButton/index.d.ts +1 -0
- package/dist/components/IconButton/index.js +5 -0
- package/dist/components/IconButton/index.js.map +1 -0
- package/dist/components/InfoMessage/InfoMassage.stories.d.ts +5 -0
- package/dist/components/InfoMessage/InfoMassage.stories.js +23 -0
- package/dist/components/InfoMessage/InfoMassage.stories.js.map +1 -0
- package/dist/components/InfoMessage/InfoMessage.d.ts +7 -0
- package/dist/components/InfoMessage/InfoMessage.js +25 -0
- package/dist/components/InfoMessage/InfoMessage.js.map +1 -0
- package/dist/components/InfoMessage/index.d.ts +1 -0
- package/dist/components/InfoMessage/index.js +5 -0
- package/dist/components/InfoMessage/index.js.map +1 -0
- package/dist/components/SectionNotification/SectionNotification.d.ts +6 -0
- package/dist/components/SectionNotification/SectionNotification.js +20 -0
- package/dist/components/SectionNotification/SectionNotification.js.map +1 -0
- package/dist/components/SectionNotification/SectionNotification.stories.d.ts +6 -0
- package/dist/components/SectionNotification/SectionNotification.stories.js +21 -0
- package/dist/components/SectionNotification/SectionNotification.stories.js.map +1 -0
- package/dist/components/SectionNotification/index.d.ts +1 -0
- package/dist/components/SectionNotification/index.js +5 -0
- package/dist/components/SectionNotification/index.js.map +1 -0
- package/dist/components/SelectListbox/SelectListBox.stories.d.ts +9 -0
- package/dist/components/SelectListbox/SelectListBox.stories.js +117 -0
- package/dist/components/SelectListbox/SelectListBox.stories.js.map +1 -0
- package/dist/components/SelectListbox/SelectListbox.d.ts +45 -0
- package/dist/components/SelectListbox/SelectListbox.js +38 -0
- package/dist/components/SelectListbox/SelectListbox.js.map +1 -0
- package/dist/components/SelectListbox/SelectProvider.d.ts +28 -0
- package/dist/components/SelectListbox/SelectProvider.js +42 -0
- package/dist/components/SelectListbox/SelectProvider.js.map +1 -0
- package/dist/components/SelectListbox/components/SelectButton.d.ts +10 -0
- package/dist/components/SelectListbox/components/SelectButton.js +69 -0
- package/dist/components/SelectListbox/components/SelectButton.js.map +1 -0
- package/dist/components/SelectListbox/components/SelectContainer.d.ts +3 -0
- package/dist/components/SelectListbox/components/SelectContainer.js +22 -0
- package/dist/components/SelectListbox/components/SelectContainer.js.map +1 -0
- package/dist/components/SelectListbox/components/SelectOption.d.ts +10 -0
- package/dist/components/SelectListbox/components/SelectOption.js +55 -0
- package/dist/components/SelectListbox/components/SelectOption.js.map +1 -0
- package/dist/components/SelectListbox/components/SelectOptionBox.d.ts +8 -0
- package/dist/components/SelectListbox/components/SelectOptionBox.js +33 -0
- package/dist/components/SelectListbox/components/SelectOptionBox.js.map +1 -0
- package/dist/components/SelectListbox/index.d.ts +1 -0
- package/dist/components/SelectListbox/index.js +5 -0
- package/dist/components/SelectListbox/index.js.map +1 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.js +17 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/storyComponents/ClipboardButton/ClipboardButton.d.ts +5 -0
- package/dist/components/storyComponents/ClipboardButton/ClipboardButton.js +46 -0
- package/dist/components/storyComponents/ClipboardButton/ClipboardButton.js.map +1 -0
- package/dist/components/storyComponents/ClipboardButton/index.d.ts +1 -0
- package/dist/components/storyComponents/ClipboardButton/index.js +5 -0
- package/dist/components/storyComponents/ClipboardButton/index.js.map +1 -0
- package/dist/index-CZx-Vhwf.js +17360 -0
- package/dist/index-CZx-Vhwf.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/vite-env.d.js +2 -0
- package/dist/vite-env.d.js.map +1 -0
- package/package.json +90 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconButton.stories.js","sources":["../../../src/components/IconButton/IconButton.stories.tsx"],"sourcesContent":["import { fn } from '@storybook/test';\n\nimport type { Meta, StoryFn } from '@storybook/react';\nimport type { IconButtonProps } from 'components/IconButton';\n\nimport { IconButton } from 'components/IconButton';\nimport { Icon } from 'components/Icon';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n title: 'Atoms/IconButton',\n component: IconButton,\n argTypes: {\n variant: {\n options: ['destructive'],\n control: { type: 'check' },\n },\n noBorder: {\n control: 'boolean',\n default: false,\n },\n wide: {\n control: 'boolean',\n default: false,\n },\n 'aria-label': {\n table: {\n disable: true,\n },\n },\n type: {\n options: ['button', 'submit', 'reset'],\n control: { type: 'select' },\n },\n children: {\n table: {\n disable: true,\n },\n },\n },\n} as Meta<IconButtonProps>;\n\nconst Template: StoryFn<IconButtonProps> = (args) => <IconButton {...args} />;\n\nexport const IconButtonExample = Template.bind({});\nIconButtonExample.args = {\n variant: 'destructive',\n noBorder: false,\n wide: false,\n children: <Icon name=\"Trash\" />,\n onClick: fn(),\n};\n"],"names":["IconButton_stories","IconButton","Template","args","jsx","IconButtonExample","Icon","fn"],"mappings":";;;;AASA,MAAeA,IAAA;AAAA,EACb,OAAO;AAAA,EACP,WAAWC;AAAA,EACX,UAAU;AAAA,IACR,SAAS;AAAA,MACP,SAAS,CAAC,aAAa;AAAA,MACvB,SAAS,EAAE,MAAM,QAAQ;AAAA,IAC3B;AAAA,IACA,UAAU;AAAA,MACR,SAAS;AAAA,MACT,SAAS;AAAA,IACX;AAAA,IACA,MAAM;AAAA,MACJ,SAAS;AAAA,MACT,SAAS;AAAA,IACX;AAAA,IACA,cAAc;AAAA,MACZ,OAAO;AAAA,QACL,SAAS;AAAA,MACX;AAAA,IACF;AAAA,IACA,MAAM;AAAA,MACJ,SAAS,CAAC,UAAU,UAAU,OAAO;AAAA,MACrC,SAAS,EAAE,MAAM,SAAS;AAAA,IAC5B;AAAA,IACA,UAAU;AAAA,MACR,OAAO;AAAA,QACL,SAAS;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF,GAEMC,IAAqC,CAACC,MAAU,gBAAAC,EAAAH,GAAA,EAAY,GAAGE,EAAM,CAAA,GAE9DE,IAAoBH,EAAS,KAAK,EAAE;AACjDG,EAAkB,OAAO;AAAA,EACvB,SAAS;AAAA,EACT,UAAU;AAAA,EACV,MAAM;AAAA,EACN,UAAU,gBAAAD,EAACE,GAAK,EAAA,MAAK,QAAQ,CAAA;AAAA,EAC7B,SAASC,EAAG;AACd;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './IconButton';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { InfoMessageProps } from './InfoMessage';
|
|
2
|
+
|
|
3
|
+
declare const _default: import('@storybook/types').ComponentAnnotations<import('@storybook/react').ReactRenderer, InfoMessageProps>;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const InfoMessageExample: import('@storybook/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, InfoMessageProps>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { InfoMessage as e } from "./InfoMessage.js";
|
|
3
|
+
const r = {
|
|
4
|
+
title: "Atoms/InfoMessage",
|
|
5
|
+
component: e,
|
|
6
|
+
argTypes: {
|
|
7
|
+
message: {
|
|
8
|
+
control: "text"
|
|
9
|
+
},
|
|
10
|
+
hasOwnContainer: {
|
|
11
|
+
control: "boolean"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}, a = (s) => /* @__PURE__ */ o(e, { ...s }), n = a.bind({});
|
|
15
|
+
n.args = {
|
|
16
|
+
message: "This is an example info message",
|
|
17
|
+
hasOwnContainer: !1
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
n as InfoMessageExample,
|
|
21
|
+
r as default
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=InfoMassage.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InfoMassage.stories.js","sources":["../../../src/components/InfoMessage/InfoMassage.stories.tsx"],"sourcesContent":["import type { Meta, StoryFn } from '@storybook/react';\nimport type { InfoMessageProps } from './InfoMessage';\n\nimport { InfoMessage } from './InfoMessage';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n title: 'Atoms/InfoMessage',\n component: InfoMessage,\n argTypes: {\n message: {\n control: 'text',\n },\n hasOwnContainer: {\n control: 'boolean',\n },\n },\n} as Meta<InfoMessageProps>;\n\nconst Template: StoryFn<InfoMessageProps> = (args) => <InfoMessage {...args} />;\n\nexport const InfoMessageExample = Template.bind({});\nInfoMessageExample.args = {\n message: 'This is an example info message',\n hasOwnContainer: false,\n};\n"],"names":["InfoMassage_stories","InfoMessage","Template","args","jsx","InfoMessageExample"],"mappings":";;AAMA,MAAeA,IAAA;AAAA,EACb,OAAO;AAAA,EACP,WAAWC;AAAA,EACX,UAAU;AAAA,IACR,SAAS;AAAA,MACP,SAAS;AAAA,IACX;AAAA,IACA,iBAAiB;AAAA,MACf,SAAS;AAAA,IACX;AAAA,EACF;AACF,GAEMC,IAAsC,CAACC,MAAU,gBAAAC,EAAAH,GAAA,EAAa,GAAGE,EAAM,CAAA,GAEhEE,IAAqBH,EAAS,KAAK,EAAE;AAClDG,EAAmB,OAAO;AAAA,EACxB,SAAS;AAAA,EACT,iBAAiB;AACnB;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface InfoMessageProps {
|
|
4
|
+
message: string;
|
|
5
|
+
hasOwnContainer?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const InfoMessage: ({ message, hasOwnContainer }: PropsWithChildren<InfoMessageProps>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import '../../assets/InfoMessage.css';
|
|
2
|
+
import { jsxs as n, jsx as o } from "react/jsx-runtime";
|
|
3
|
+
import { c as _ } from "../../clsx-DB4S2d7J.js";
|
|
4
|
+
import { Icon as a } from "../Icon/Icon.js";
|
|
5
|
+
const e = {
|
|
6
|
+
"visually-hidden": "_visually-hidden_elg9f_1",
|
|
7
|
+
"info-message": "_info-message_elg9f_3",
|
|
8
|
+
"info-message__container": "_info-message__container_elg9f_8",
|
|
9
|
+
"info-message__icon": "_info-message__icon_elg9f_13"
|
|
10
|
+
}, c = ({ message: s, hasOwnContainer: i = !1 }) => /* @__PURE__ */ n(
|
|
11
|
+
"div",
|
|
12
|
+
{
|
|
13
|
+
className: _(e["info-message"], {
|
|
14
|
+
[e["info-message__container"]]: i
|
|
15
|
+
}),
|
|
16
|
+
children: [
|
|
17
|
+
/* @__PURE__ */ o(a, { name: "InformationCircleFillMini", className: e["info-message__icon"] }),
|
|
18
|
+
s
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
export {
|
|
23
|
+
c as InfoMessage
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=InfoMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InfoMessage.js","sources":["../../../src/components/InfoMessage/InfoMessage.tsx"],"sourcesContent":["import { clsx } from 'clsx';\n\nimport type { PropsWithChildren } from 'react';\n\nimport styles from './InfoMessage.module.css';\n\nimport { Icon } from 'components/Icon';\n\nexport interface InfoMessageProps {\n message: string;\n hasOwnContainer?: boolean;\n}\n\nexport const InfoMessage = ({ message, hasOwnContainer = false }: PropsWithChildren<InfoMessageProps>) => (\n <div\n className={clsx(styles['info-message'], {\n [styles['info-message__container']]: hasOwnContainer,\n })}\n >\n <Icon name=\"InformationCircleFillMini\" className={styles['info-message__icon']} />\n {message}\n </div>\n);\n"],"names":["InfoMessage","message","hasOwnContainer","jsxs","clsx","styles","jsx","Icon"],"mappings":";;;;;;;;GAaaA,IAAc,CAAC,EAAE,SAAAC,GAAS,iBAAAC,IAAkB,GACvD,MAAA,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAWC,EAAKC,EAAO,cAAc,GAAG;AAAA,MACtC,CAACA,EAAO,yBAAyB,CAAC,GAAGH;AAAA,IAAA,CACtC;AAAA,IAED,UAAA;AAAA,MAAA,gBAAAI,EAACC,KAAK,MAAK,6BAA4B,WAAWF,EAAO,oBAAoB,GAAG;AAAA,MAC/EJ;AAAA,IAAA;AAAA,EAAA;AACH;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './InfoMessage';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface SectionNotificationProps {
|
|
4
|
+
fullWidth?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export declare const SectionNotification: ({ fullWidth, children }: PropsWithChildren<SectionNotificationProps>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import '../../assets/SectionNotification.css';
|
|
2
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
3
|
+
import { c as s } from "../../clsx-DB4S2d7J.js";
|
|
4
|
+
const i = {
|
|
5
|
+
"visually-hidden": "_visually-hidden_xsb8x_1",
|
|
6
|
+
"section-notification": "_section-notification_xsb8x_3",
|
|
7
|
+
"section-notification--fullwidth": "_section-notification--fullwidth_xsb8x_12"
|
|
8
|
+
}, a = ({ fullWidth: t = !1, children: o }) => /* @__PURE__ */ n(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
className: s(i["section-notification"], {
|
|
12
|
+
[i["section-notification--fullwidth"]]: t
|
|
13
|
+
}),
|
|
14
|
+
children: o
|
|
15
|
+
}
|
|
16
|
+
);
|
|
17
|
+
export {
|
|
18
|
+
a as SectionNotification
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=SectionNotification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionNotification.js","sources":["../../../src/components/SectionNotification/SectionNotification.tsx"],"sourcesContent":["import classNames from 'clsx';\n\nimport type { PropsWithChildren } from 'react';\n\nimport styles from './SectionNotification.module.css';\n\nexport interface SectionNotificationProps {\n fullWidth?: boolean;\n}\n\nexport const SectionNotification = ({ fullWidth = false, children }: PropsWithChildren<SectionNotificationProps>) => (\n <div\n className={classNames(styles['section-notification'], {\n [styles['section-notification--fullwidth']]: fullWidth,\n })}\n >\n {children}\n </div>\n);\n"],"names":["SectionNotification","fullWidth","children","jsx","classNames","styles"],"mappings":";;;;;;GAUaA,IAAsB,CAAC,EAAE,WAAAC,IAAY,IAAO,UAAAC,EACvD,MAAA,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAWC,EAAWC,EAAO,sBAAsB,GAAG;AAAA,MACpD,CAACA,EAAO,iCAAiC,CAAC,GAAGJ;AAAA,IAAA,CAC9C;AAAA,IAEA,UAAAC;AAAA,EAAA;AACH;"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SectionNotificationProps } from 'components/SectionNotification';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
|
|
4
|
+
declare const _default: import('@storybook/types').ComponentAnnotations<import('@storybook/react').ReactRenderer, PropsWithChildren<SectionNotificationProps>>;
|
|
5
|
+
export default _default;
|
|
6
|
+
export declare const SectionNotificationExample: import('@storybook/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, PropsWithChildren<SectionNotificationProps>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import { SectionNotification as t } from "./SectionNotification.js";
|
|
3
|
+
const l = {
|
|
4
|
+
title: "Atoms/SectionNotification",
|
|
5
|
+
component: t,
|
|
6
|
+
argTypes: {
|
|
7
|
+
fullWidth: {
|
|
8
|
+
control: "boolean",
|
|
9
|
+
default: !1
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}, e = (o) => /* @__PURE__ */ i(t, { ...o }), n = e.bind({});
|
|
13
|
+
n.args = {
|
|
14
|
+
fullWidth: !0,
|
|
15
|
+
children: "This is an example notification"
|
|
16
|
+
};
|
|
17
|
+
export {
|
|
18
|
+
n as SectionNotificationExample,
|
|
19
|
+
l as default
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=SectionNotification.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionNotification.stories.js","sources":["../../../src/components/SectionNotification/SectionNotification.stories.tsx"],"sourcesContent":["import type { PropsWithChildren } from 'react';\nimport type { Meta, StoryFn } from '@storybook/react';\nimport type { SectionNotificationProps } from 'components/SectionNotification';\n\nimport { SectionNotification } from 'components/SectionNotification';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n title: 'Atoms/SectionNotification',\n component: SectionNotification,\n argTypes: {\n fullWidth: {\n control: 'boolean',\n default: false,\n },\n },\n} as Meta<PropsWithChildren<SectionNotificationProps>>;\n\nconst Template: StoryFn<PropsWithChildren<SectionNotificationProps>> = (args) => <SectionNotification {...args} />;\n\nexport const SectionNotificationExample = Template.bind({});\nSectionNotificationExample.args = {\n fullWidth: true,\n children: 'This is an example notification',\n};\n"],"names":["SectionNotification_stories","SectionNotification","Template","args","jsx","SectionNotificationExample"],"mappings":";;AAOA,MAAeA,IAAA;AAAA,EACb,OAAO;AAAA,EACP,WAAWC;AAAA,EACX,UAAU;AAAA,IACR,WAAW;AAAA,MACT,SAAS;AAAA,MACT,SAAS;AAAA,IACX;AAAA,EACF;AACF,GAEMC,IAAiE,CAACC,MAAU,gBAAAC,EAAAH,GAAA,EAAqB,GAAGE,EAAM,CAAA,GAEnGE,IAA6BH,EAAS,KAAK,EAAE;AAC1DG,EAA2B,OAAO;AAAA,EAChC,WAAW;AAAA,EACX,UAAU;AACZ;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SectionNotification';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SelectListboxProps } from './SelectListbox';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
|
|
4
|
+
declare const _default: import('@storybook/types').ComponentAnnotations<import('@storybook/react').ReactRenderer, SelectListboxProps & {
|
|
5
|
+
children?: import('react').ReactNode;
|
|
6
|
+
}>;
|
|
7
|
+
export default _default;
|
|
8
|
+
export declare const SelectListboxExample: import('@storybook/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, PropsWithChildren<SelectListboxProps>>;
|
|
9
|
+
export declare const WithComponentOption: import('@storybook/types').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, PropsWithChildren<SelectListboxProps>>;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { jsx as l, jsxs as h } from "react/jsx-runtime";
|
|
2
|
+
import { f as c } from "../../index-CZx-Vhwf.js";
|
|
3
|
+
import { SelectListbox as a } from "./SelectListbox.js";
|
|
4
|
+
import * as e from "react";
|
|
5
|
+
const d = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 9 6", ...t }, /* @__PURE__ */ e.createElement("rect", { fill: "#21468B", width: 9, height: 6 }), /* @__PURE__ */ e.createElement("rect", { fill: "#FFF", width: 9, height: 4 }), /* @__PURE__ */ e.createElement("rect", { fill: "#AE1C28", width: 9, height: 2 })), p = d, g = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 60 30", ...t }, /* @__PURE__ */ e.createElement("clipPath", { id: "t" }, /* @__PURE__ */ e.createElement("path", { d: "M30,15 h30 v15 z v15 h-30 z h-30 v-15 z v-15 h30 z" })), /* @__PURE__ */ e.createElement("path", { d: "M0,0 v30 h60 v-30 z", fill: "#00247d" }), /* @__PURE__ */ e.createElement("path", { d: "M0,0 L60,30 M60,0 L0,30", stroke: "#fff", strokeWidth: 6 }), /* @__PURE__ */ e.createElement("path", { d: "M0,0 L60,30 M60,0 L0,30", clipPath: "url(#t)", stroke: "#cf142b", strokeWidth: 4 }), /* @__PURE__ */ e.createElement("path", { d: "M30,0 v30 M0,15 h60", stroke: "#fff", strokeWidth: 10 }), /* @__PURE__ */ e.createElement("path", { d: "M30,0 v30 M0,15 h60", stroke: "#cf142b", strokeWidth: 6 })), m = g, f = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 5 3", ...t }, /* @__PURE__ */ e.createElement("desc", null, "Flag of Germany"), /* @__PURE__ */ e.createElement("rect", { id: "black_stripe", width: 5, height: 3, y: 0, x: 0, fill: "#000" }), /* @__PURE__ */ e.createElement("rect", { id: "red_stripe", width: 5, height: 2, y: 1, x: 0, fill: "#D00" }), /* @__PURE__ */ e.createElement("rect", { id: "gold_stripe", width: 5, height: 1, y: 2, x: 0, fill: "#FFCE00" })), b = f, w = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 3 2", ...t }, /* @__PURE__ */ e.createElement("rect", { width: 3, height: 2, fill: "#ED2939" }), /* @__PURE__ */ e.createElement("rect", { width: 2, height: 2, fill: "#fff" }), /* @__PURE__ */ e.createElement("rect", { width: 1, height: 2, fill: "#002395" })), x = w, r = [
|
|
6
|
+
{
|
|
7
|
+
label: "Nerderlands",
|
|
8
|
+
value: "NL"
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
label: "English",
|
|
12
|
+
value: "EN"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
label: "Deutsch",
|
|
16
|
+
value: "DU"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label: "Français",
|
|
20
|
+
value: "FR"
|
|
21
|
+
}
|
|
22
|
+
], M = {
|
|
23
|
+
title: "Organisms/SelectListbox",
|
|
24
|
+
component: a,
|
|
25
|
+
argTypes: {
|
|
26
|
+
options: {
|
|
27
|
+
table: {
|
|
28
|
+
disable: !0
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
defaultValue: {
|
|
32
|
+
table: {
|
|
33
|
+
disable: !0
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
onChange: {
|
|
37
|
+
table: {
|
|
38
|
+
disable: !0
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
disabled: {
|
|
42
|
+
control: "boolean",
|
|
43
|
+
default: !1
|
|
44
|
+
},
|
|
45
|
+
buttonLabelBold: {
|
|
46
|
+
control: "boolean",
|
|
47
|
+
default: !1
|
|
48
|
+
},
|
|
49
|
+
variant: {
|
|
50
|
+
options: ["default", "noborder", "pill", "pillLeft", "pillRight"],
|
|
51
|
+
control: { type: "select" }
|
|
52
|
+
},
|
|
53
|
+
optionPositionRight: {
|
|
54
|
+
control: "boolean",
|
|
55
|
+
default: !1
|
|
56
|
+
},
|
|
57
|
+
buttonLabelProp: {
|
|
58
|
+
table: {
|
|
59
|
+
disable: !0
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
children: {
|
|
63
|
+
table: {
|
|
64
|
+
disable: !0
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
SelectOption: {
|
|
68
|
+
table: {
|
|
69
|
+
disable: !0
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
SelectOptionBox: {
|
|
73
|
+
table: {
|
|
74
|
+
disable: !0
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
SelectButton: {
|
|
78
|
+
table: {
|
|
79
|
+
disable: !0
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
SelectContainer: {
|
|
83
|
+
table: {
|
|
84
|
+
disable: !0
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, s = {
|
|
89
|
+
options: r,
|
|
90
|
+
defaultValue: "EN",
|
|
91
|
+
disabled: !1,
|
|
92
|
+
buttonLabelBold: !1,
|
|
93
|
+
maxOptionHeight: "200px",
|
|
94
|
+
optionPositionRight: !1,
|
|
95
|
+
onChange: c()
|
|
96
|
+
}, E = (t) => /* @__PURE__ */ l("div", { style: { width: "10rem" }, children: /* @__PURE__ */ l(a, { ...t, children: r.map(({ label: i, value: o }, n) => /* @__PURE__ */ l(a.SelectOption, { option: { label: i, value: o }, index: n, children: i }, `${o}`)) }) }), u = E.bind({});
|
|
97
|
+
u.args = {
|
|
98
|
+
...s
|
|
99
|
+
};
|
|
100
|
+
const v = ({ label: t, value: i }) => /* @__PURE__ */ h("div", { style: { display: "flex" }, children: [
|
|
101
|
+
{
|
|
102
|
+
NL: /* @__PURE__ */ l(p, { style: { width: "24px", height: "24px", marginRight: "10px" } }),
|
|
103
|
+
EN: /* @__PURE__ */ l(m, { style: { width: "24px", height: "24px", marginRight: "10px" } }),
|
|
104
|
+
DU: /* @__PURE__ */ l(b, { style: { width: "24px", height: "24px", marginRight: "10px" } }),
|
|
105
|
+
FR: /* @__PURE__ */ l(x, { style: { width: "24px", height: "24px", marginRight: "10px" } })
|
|
106
|
+
}[i],
|
|
107
|
+
t
|
|
108
|
+
] }), F = (t) => /* @__PURE__ */ l("div", { style: { width: "10rem" }, children: /* @__PURE__ */ l(a, { ...t, children: t.options.map(({ label: i, value: o }, n) => /* @__PURE__ */ l(a.SelectOption, { option: { label: i, value: o }, index: n, children: /* @__PURE__ */ l(v, { label: i, value: o }) }, `${o}`)) }) }), y = F.bind({});
|
|
109
|
+
y.args = {
|
|
110
|
+
...s
|
|
111
|
+
};
|
|
112
|
+
export {
|
|
113
|
+
u as SelectListboxExample,
|
|
114
|
+
y as WithComponentOption,
|
|
115
|
+
M as default
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=SelectListBox.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectListBox.stories.js","sources":["../../../src/components/SelectListbox/stories-images/nl.svg?react","../../../src/components/SelectListbox/stories-images/gb.svg?react","../../../src/components/SelectListbox/stories-images/de.svg?react","../../../src/components/SelectListbox/stories-images/fr.svg?react","../../../src/components/SelectListbox/SelectListBox.stories.tsx"],"sourcesContent":["import * as React from \"react\";\nconst SvgNl = (props) => /* @__PURE__ */ React.createElement(\"svg\", { xmlns: \"http://www.w3.org/2000/svg\", viewBox: \"0 0 9 6\", ...props }, /* @__PURE__ */ React.createElement(\"rect\", { fill: \"#21468B\", width: 9, height: 6 }), /* @__PURE__ */ React.createElement(\"rect\", { fill: \"#FFF\", width: 9, height: 4 }), /* @__PURE__ */ React.createElement(\"rect\", { fill: \"#AE1C28\", width: 9, height: 2 }));\nexport default SvgNl;\n","import * as React from \"react\";\nconst SvgGb = (props) => /* @__PURE__ */ React.createElement(\"svg\", { xmlns: \"http://www.w3.org/2000/svg\", viewBox: \"0 0 60 30\", ...props }, /* @__PURE__ */ React.createElement(\"clipPath\", { id: \"t\" }, /* @__PURE__ */ React.createElement(\"path\", { d: \"M30,15 h30 v15 z v15 h-30 z h-30 v-15 z v-15 h30 z\" })), /* @__PURE__ */ React.createElement(\"path\", { d: \"M0,0 v30 h60 v-30 z\", fill: \"#00247d\" }), /* @__PURE__ */ React.createElement(\"path\", { d: \"M0,0 L60,30 M60,0 L0,30\", stroke: \"#fff\", strokeWidth: 6 }), /* @__PURE__ */ React.createElement(\"path\", { d: \"M0,0 L60,30 M60,0 L0,30\", clipPath: \"url(#t)\", stroke: \"#cf142b\", strokeWidth: 4 }), /* @__PURE__ */ React.createElement(\"path\", { d: \"M30,0 v30 M0,15 h60\", stroke: \"#fff\", strokeWidth: 10 }), /* @__PURE__ */ React.createElement(\"path\", { d: \"M30,0 v30 M0,15 h60\", stroke: \"#cf142b\", strokeWidth: 6 }));\nexport default SvgGb;\n","import * as React from \"react\";\nconst SvgDe = (props) => /* @__PURE__ */ React.createElement(\"svg\", { xmlns: \"http://www.w3.org/2000/svg\", viewBox: \"0 0 5 3\", ...props }, /* @__PURE__ */ React.createElement(\"desc\", null, \"Flag of Germany\"), /* @__PURE__ */ React.createElement(\"rect\", { id: \"black_stripe\", width: 5, height: 3, y: 0, x: 0, fill: \"#000\" }), /* @__PURE__ */ React.createElement(\"rect\", { id: \"red_stripe\", width: 5, height: 2, y: 1, x: 0, fill: \"#D00\" }), /* @__PURE__ */ React.createElement(\"rect\", { id: \"gold_stripe\", width: 5, height: 1, y: 2, x: 0, fill: \"#FFCE00\" }));\nexport default SvgDe;\n","import * as React from \"react\";\nconst SvgFr = (props) => /* @__PURE__ */ React.createElement(\"svg\", { xmlns: \"http://www.w3.org/2000/svg\", viewBox: \"0 0 3 2\", ...props }, /* @__PURE__ */ React.createElement(\"rect\", { width: 3, height: 2, fill: \"#ED2939\" }), /* @__PURE__ */ React.createElement(\"rect\", { width: 2, height: 2, fill: \"#fff\" }), /* @__PURE__ */ React.createElement(\"rect\", { width: 1, height: 2, fill: \"#002395\" }));\nexport default SvgFr;\n","import { fn } from '@storybook/test';\n\nimport type { Meta, StoryFn } from '@storybook/react';\nimport type { FC, PropsWithChildren } from 'react';\nimport type { SelectListboxProps } from './SelectListbox';\n\nimport { SelectListbox } from './SelectListbox';\nimport FlagNl from './stories-images/nl.svg?react';\nimport FlagEn from './stories-images/gb.svg?react';\nimport FlagDu from './stories-images/de.svg?react';\nimport FlagFr from './stories-images/fr.svg?react';\n\nconst DATA = [\n {\n label: 'Nerderlands',\n value: 'NL',\n },\n {\n label: 'English',\n value: 'EN',\n },\n {\n label: 'Deutsch',\n value: 'DU',\n },\n {\n label: 'Français',\n value: 'FR',\n },\n];\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n title: 'Organisms/SelectListbox',\n component: SelectListbox,\n argTypes: {\n options: {\n table: {\n disable: true,\n },\n },\n defaultValue: {\n table: {\n disable: true,\n },\n },\n onChange: {\n table: {\n disable: true,\n },\n },\n disabled: {\n control: 'boolean',\n default: false,\n },\n buttonLabelBold: {\n control: 'boolean',\n default: false,\n },\n variant: {\n options: ['default', 'noborder', 'pill', 'pillLeft', 'pillRight'],\n control: { type: 'select' },\n },\n optionPositionRight: {\n control: 'boolean',\n default: false,\n },\n buttonLabelProp: {\n table: {\n disable: true,\n },\n },\n children: {\n table: {\n disable: true,\n },\n },\n SelectOption: {\n table: {\n disable: true,\n },\n },\n SelectOptionBox: {\n table: {\n disable: true,\n },\n },\n SelectButton: {\n table: {\n disable: true,\n },\n },\n SelectContainer: {\n table: {\n disable: true,\n },\n },\n },\n} as Meta<typeof SelectListbox>;\n\nconst defaultArgs: Partial<PropsWithChildren<SelectListboxProps>> = {\n options: DATA,\n defaultValue: 'EN',\n disabled: false,\n buttonLabelBold: false,\n maxOptionHeight: '200px',\n optionPositionRight: false,\n onChange: fn(),\n};\n\nconst Template: StoryFn<PropsWithChildren<SelectListboxProps>> = (args) => (\n <div style={{ width: '10rem' }}>\n <SelectListbox {...args}>\n {DATA.map(({ label, value }, index) => (\n <SelectListbox.SelectOption option={{ label, value }} index={index} key={`${value}`}>\n {label}\n </SelectListbox.SelectOption>\n ))}\n </SelectListbox>\n </div>\n);\n\nexport const SelectListboxExample = Template.bind({});\nSelectListboxExample.args = {\n ...defaultArgs,\n};\n\nconst ComponentOption: FC<{ label: string; value: string }> = ({ label, value }) => {\n const flags = {\n NL: <FlagNl style={{ width: '24px', height: '24px', marginRight: '10px' }} />,\n EN: <FlagEn style={{ width: '24px', height: '24px', marginRight: '10px' }} />,\n DU: <FlagDu style={{ width: '24px', height: '24px', marginRight: '10px' }} />,\n FR: <FlagFr style={{ width: '24px', height: '24px', marginRight: '10px' }} />,\n };\n\n return (\n <div style={{ display: 'flex' }}>\n {flags[value as keyof typeof flags]}\n {label}\n </div>\n );\n};\n\nconst TemplateWithComponent: StoryFn<PropsWithChildren<SelectListboxProps>> = (args) => (\n <div style={{ width: '10rem' }}>\n <SelectListbox {...args}>\n {args.options.map(({ label, value }, index) => (\n <SelectListbox.SelectOption option={{ label, value }} index={index} key={`${value}`}>\n <ComponentOption label={label} value={value as string} />\n </SelectListbox.SelectOption>\n ))}\n </SelectListbox>\n </div>\n);\n\nexport const WithComponentOption = TemplateWithComponent.bind({});\nWithComponentOption.args = {\n ...defaultArgs,\n};\n"],"names":["SvgNl","props","React","FlagNl","SvgGb","FlagEn","SvgDe","FlagDu","SvgFr","FlagFr","DATA","SelectListBox_stories","SelectListbox","defaultArgs","fn","Template","args","jsx","label","value","index","SelectListboxExample","ComponentOption","TemplateWithComponent","WithComponentOption"],"mappings":";;;;AACA,MAAMA,IAAQ,CAACC,MAA0B,gBAAAC,EAAM,cAAc,OAAO,EAAE,OAAO,8BAA8B,SAAS,WAAW,GAAGD,KAAyB,gBAAAC,EAAM,cAAc,QAAQ,EAAE,MAAM,WAAW,OAAO,GAAG,QAAQ,EAAC,CAAE,GAAmB,gBAAAA,EAAM,cAAc,QAAQ,EAAE,MAAM,QAAQ,OAAO,GAAG,QAAQ,GAAG,GAAmB,gBAAAA,EAAM,cAAc,QAAQ,EAAE,MAAM,WAAW,OAAO,GAAG,QAAQ,EAAG,CAAA,CAAC,GAC3YC,IAAeH,GCDTI,IAAQ,CAACH,MAA0B,gBAAAC,EAAM,cAAc,OAAO,EAAE,OAAO,8BAA8B,SAAS,aAAa,GAAGD,EAAO,GAAkB,gBAAAC,EAAM,cAAc,YAAY,EAAE,IAAI,OAAuB,gBAAAA,EAAM,cAAc,QAAQ,EAAE,GAAG,qDAAoD,CAAE,CAAC,GAAmB,gBAAAA,EAAM,cAAc,QAAQ,EAAE,GAAG,uBAAuB,MAAM,WAAW,GAAmB,gBAAAA,EAAM,cAAc,QAAQ,EAAE,GAAG,2BAA2B,QAAQ,QAAQ,aAAa,EAAG,CAAA,GAAmB,gBAAAA,EAAM,cAAc,QAAQ,E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EAAE,OAAO,QAAA,GACnB,UAAC,gBAAAC,EAAAL,GAAA,EAAe,GAAGI,GAChB,UAAAA,EAAK,QAAQ,IAAI,CAAC,EAAE,OAAAE,GAAO,OAAAC,KAASC,MACnC,gBAAAH,EAACL,EAAc,cAAd,EAA2B,QAAQ,EAAE,OAAAM,GAAO,OAAAC,EAAS,GAAA,OAAAC,GACpD,4BAACE,GAAgB,EAAA,OAAAJ,GAAc,OAAAC,EAAwB,CAAA,KADgB,GAAGA,CAAK,EAEjF,CACD,GACH,EACF,CAAA,GAGWK,IAAsBD,EAAsB,KAAK,EAAE;AAChEC,EAAoB,OAAO;AAAA,EACzB,GAAGX;AACL;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { SelectOption } from './components/SelectOption';
|
|
2
|
+
import { SelectOptionBox } from './components/SelectOptionBox';
|
|
3
|
+
import { SelectContainer } from './components/SelectContainer';
|
|
4
|
+
import { SelectButton } from './components/SelectButton';
|
|
5
|
+
import { OptionValue, SelectValue } from './SelectProvider';
|
|
6
|
+
import { ReactNode, PropsWithChildren } from 'react';
|
|
7
|
+
|
|
8
|
+
interface ISelect {
|
|
9
|
+
options: OptionValue[];
|
|
10
|
+
defaultValue?: SelectValue;
|
|
11
|
+
maxOptionHeight?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
buttonLabelProp?: string;
|
|
14
|
+
buttonLabelBold?: boolean;
|
|
15
|
+
variant?: 'noborder' | 'pill' | 'pillLeft' | 'pillRight';
|
|
16
|
+
optionPositionRight?: boolean;
|
|
17
|
+
onChange?: (option: OptionValue) => void;
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
export interface SelectListboxProps extends ISelect {
|
|
21
|
+
SelectOption?: typeof SelectOption;
|
|
22
|
+
SelectOptionBox?: typeof SelectOptionBox;
|
|
23
|
+
SelectButton: typeof SelectButton;
|
|
24
|
+
SelectContainer: typeof SelectContainer;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* SelectListbox component
|
|
28
|
+
* Options can be a component or just a label, it should be wrapped in SelectListbox.SelectOption
|
|
29
|
+
* NOTE: If you want to use a custom component, you should add [aria-hidden="true"]
|
|
30
|
+
* on the root element so the screen reader will ignore it
|
|
31
|
+
*
|
|
32
|
+
* TODO: Add dynamic positioning/sizing of the optionbox based on the availible space
|
|
33
|
+
* Fixed positioned so it will not be affected by the parent container and will always be on top
|
|
34
|
+
* TODO: Buttonlabel should take a component aswell zo the bold prop can be removed
|
|
35
|
+
*/
|
|
36
|
+
export declare const SelectListbox: {
|
|
37
|
+
({ options, variant, optionPositionRight, defaultValue, maxOptionHeight, disabled, buttonLabelProp, buttonLabelBold, onChange, children, }: PropsWithChildren<SelectListboxProps>): import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
SelectOption: ({ option, index, children }: import('./components/SelectOption').SelectOptionProps) => import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
SelectButton: ({ variant, onChange, buttonLabelProp, buttonLabelBold, disabled, }: import('./components/SelectButton').SelectButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
SelectContainer: ({ children }: {
|
|
41
|
+
children?: ReactNode;
|
|
42
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
SelectOptionBox: ({ optionPositionRight, maxOptionHeight, children }: import('./components/SelectOptionBox').SelectOptionBoxProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
44
|
+
};
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx as e, jsxs as O } from "react/jsx-runtime";
|
|
2
|
+
import { SelectButton as o } from "./components/SelectButton.js";
|
|
3
|
+
import { SelectContainer as r } from "./components/SelectContainer.js";
|
|
4
|
+
import { SelectOptionBox as i } from "./components/SelectOptionBox.js";
|
|
5
|
+
import { SelectOption as a } from "./components/SelectOption.js";
|
|
6
|
+
import { SelectProvider as d } from "./SelectProvider.js";
|
|
7
|
+
const t = ({
|
|
8
|
+
options: l,
|
|
9
|
+
variant: n,
|
|
10
|
+
optionPositionRight: c,
|
|
11
|
+
defaultValue: m = -1,
|
|
12
|
+
maxOptionHeight: p,
|
|
13
|
+
disabled: S,
|
|
14
|
+
buttonLabelProp: f = "label",
|
|
15
|
+
buttonLabelBold: x,
|
|
16
|
+
onChange: s,
|
|
17
|
+
children: B
|
|
18
|
+
}) => /* @__PURE__ */ e(d, { options: l, defaultValue: m, children: /* @__PURE__ */ O(r, { children: [
|
|
19
|
+
/* @__PURE__ */ e(
|
|
20
|
+
o,
|
|
21
|
+
{
|
|
22
|
+
disabled: S,
|
|
23
|
+
buttonLabelProp: f,
|
|
24
|
+
buttonLabelBold: x,
|
|
25
|
+
variant: n,
|
|
26
|
+
onChange: s
|
|
27
|
+
}
|
|
28
|
+
),
|
|
29
|
+
/* @__PURE__ */ e(i, { maxOptionHeight: p, optionPositionRight: c, children: B })
|
|
30
|
+
] }) });
|
|
31
|
+
t.SelectOption = a;
|
|
32
|
+
t.SelectButton = o;
|
|
33
|
+
t.SelectContainer = r;
|
|
34
|
+
t.SelectOptionBox = i;
|
|
35
|
+
export {
|
|
36
|
+
t as SelectListbox
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=SelectListbox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectListbox.js","sources":["../../../src/components/SelectListbox/SelectListbox.tsx"],"sourcesContent":["import type { ReactNode, PropsWithChildren } from 'react';\nimport type { OptionValue, SelectValue } from './SelectProvider';\n\nimport { SelectButton } from './components/SelectButton';\nimport { SelectContainer } from './components/SelectContainer';\nimport { SelectOptionBox } from './components/SelectOptionBox';\nimport { SelectOption } from './components/SelectOption';\nimport { SelectProvider } from './SelectProvider';\n\ninterface ISelect {\n options: OptionValue[];\n defaultValue?: SelectValue;\n maxOptionHeight?: string;\n disabled?: boolean;\n buttonLabelProp?: string;\n buttonLabelBold?: boolean;\n variant?: 'noborder' | 'pill' | 'pillLeft' | 'pillRight';\n optionPositionRight?: boolean;\n onChange?: (option: OptionValue) => void;\n children?: ReactNode;\n}\n\nexport interface SelectListboxProps extends ISelect {\n SelectOption?: typeof SelectOption;\n SelectOptionBox?: typeof SelectOptionBox;\n SelectButton: typeof SelectButton;\n SelectContainer: typeof SelectContainer;\n}\n\n/**\n * SelectListbox component\n * Options can be a component or just a label, it should be wrapped in SelectListbox.SelectOption\n * NOTE: If you want to use a custom component, you should add [aria-hidden=\"true\"]\n * on the root element so the screen reader will ignore it\n *\n * TODO: Add dynamic positioning/sizing of the optionbox based on the availible space\n * Fixed positioned so it will not be affected by the parent container and will always be on top\n * TODO: Buttonlabel should take a component aswell zo the bold prop can be removed\n */\n\nexport const SelectListbox = ({\n options,\n variant,\n optionPositionRight,\n defaultValue = -1,\n maxOptionHeight,\n disabled,\n buttonLabelProp = 'label',\n buttonLabelBold,\n onChange,\n children,\n}: PropsWithChildren<SelectListboxProps>) => {\n return (\n <SelectProvider options={options} defaultValue={defaultValue}>\n <SelectContainer>\n <SelectButton\n disabled={disabled}\n buttonLabelProp={buttonLabelProp}\n buttonLabelBold={buttonLabelBold}\n variant={variant}\n onChange={onChange}\n />\n <SelectOptionBox maxOptionHeight={maxOptionHeight} optionPositionRight={optionPositionRight}>\n {children}\n </SelectOptionBox>\n </SelectContainer>\n </SelectProvider>\n );\n};\n\nSelectListbox.SelectOption = SelectOption;\nSelectListbox.SelectButton = SelectButton;\nSelectListbox.SelectContainer = SelectContainer;\nSelectListbox.SelectOptionBox = SelectOptionBox;\n"],"names":["SelectListbox","options","variant","optionPositionRight","defaultValue","maxOptionHeight","disabled","buttonLabelProp","buttonLabelBold","onChange","children","jsx","SelectProvider","SelectContainer","SelectButton","SelectOptionBox","SelectOption"],"mappings":";;;;;;AAwCO,MAAMA,IAAgB,CAAC;AAAA,EAC5B,SAAAC;AAAA,EACA,SAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,cAAAC,IAAe;AAAA,EACf,iBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,iBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AACF,MAEK,gBAAAC,EAAAC,GAAA,EAAe,SAAAX,GAAkB,cAAAG,GAChC,4BAACS,GACC,EAAA,UAAA;AAAA,EAAA,gBAAAF;AAAA,IAACG;AAAA,IAAA;AAAA,MACC,UAAAR;AAAA,MACA,iBAAAC;AAAA,MACA,iBAAAC;AAAA,MACA,SAAAN;AAAA,MACA,UAAAO;AAAA,IAAA;AAAA,EACF;AAAA,EACC,gBAAAE,EAAAI,GAAA,EAAgB,iBAAAV,GAAkC,qBAAAF,GAChD,UAAAO,EACH,CAAA;AAAA,EACF,CAAA,EACF,CAAA;AAIJV,EAAc,eAAegB;AAC7BhB,EAAc,eAAec;AAC7Bd,EAAc,kBAAkBa;AAChCb,EAAc,kBAAkBe;"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
export type SelectValue = string | number | null;
|
|
4
|
+
export type OptionValue = {
|
|
5
|
+
value: SelectValue;
|
|
6
|
+
label: string;
|
|
7
|
+
selectedLabel?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export interface SelectListboxContext {
|
|
11
|
+
options: OptionValue[];
|
|
12
|
+
selectedValue: OptionValue;
|
|
13
|
+
setSelectedValue: (v: OptionValue) => void;
|
|
14
|
+
isOpen: boolean;
|
|
15
|
+
setIsOpen: (v: boolean) => void;
|
|
16
|
+
toggleListbox: () => void;
|
|
17
|
+
getValue: (value: SelectValue) => OptionValue;
|
|
18
|
+
activeIndex: number;
|
|
19
|
+
setActiveIndex: (v: number) => void;
|
|
20
|
+
listboxId: string;
|
|
21
|
+
}
|
|
22
|
+
interface Props {
|
|
23
|
+
options: OptionValue[];
|
|
24
|
+
defaultValue: SelectValue;
|
|
25
|
+
}
|
|
26
|
+
export declare const SelectProvider: ({ options, defaultValue, children }: PropsWithChildren<Props>) => import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export declare const useSelect: () => SelectListboxContext;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as g, useState as l, useRef as p, useId as C, useContext as P } from "react";
|
|
3
|
+
const d = g({}), L = ({ options: e, defaultValue: o, children: i }) => {
|
|
4
|
+
const [c, v] = l({ value: "", label: "" }), [x, s] = l(!1), [f, r] = l(-1), I = p(C()), b = () => {
|
|
5
|
+
s((t) => !t);
|
|
6
|
+
}, u = (t) => e.find((n) => n.value === t) || {
|
|
7
|
+
value: -1,
|
|
8
|
+
label: "",
|
|
9
|
+
selectedLabel: "-"
|
|
10
|
+
}, a = (t) => {
|
|
11
|
+
const n = e.findIndex((S) => S.value === t.value);
|
|
12
|
+
r(n), v(t), s(!1);
|
|
13
|
+
};
|
|
14
|
+
return o !== -1 && !c.value && a(u(o)), /* @__PURE__ */ m(
|
|
15
|
+
d.Provider,
|
|
16
|
+
{
|
|
17
|
+
value: {
|
|
18
|
+
options: e,
|
|
19
|
+
selectedValue: c,
|
|
20
|
+
setSelectedValue: a,
|
|
21
|
+
isOpen: x,
|
|
22
|
+
setIsOpen: s,
|
|
23
|
+
toggleListbox: b,
|
|
24
|
+
getValue: u,
|
|
25
|
+
activeIndex: f,
|
|
26
|
+
setActiveIndex: r,
|
|
27
|
+
listboxId: I.current
|
|
28
|
+
},
|
|
29
|
+
children: i
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
}, O = () => {
|
|
33
|
+
const e = P(d);
|
|
34
|
+
if (e === void 0)
|
|
35
|
+
throw new Error("useSelect can only be used in an SelectProvider");
|
|
36
|
+
return e;
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
L as SelectProvider,
|
|
40
|
+
O as useSelect
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=SelectProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectProvider.js","sources":["../../../src/components/SelectListbox/SelectProvider.tsx"],"sourcesContent":["import { createContext, useContext, useState, useId, useRef } from 'react';\n\nimport type { PropsWithChildren } from 'react';\n\nexport type SelectValue = string | number | null;\n\nexport type OptionValue = {\n value: SelectValue;\n label: string;\n selectedLabel?: string;\n disabled?: boolean;\n};\nexport interface SelectListboxContext {\n options: OptionValue[];\n selectedValue: OptionValue;\n setSelectedValue: (v: OptionValue) => void;\n isOpen: boolean;\n setIsOpen: (v: boolean) => void;\n toggleListbox: () => void;\n getValue: (value: SelectValue) => OptionValue;\n activeIndex: number;\n setActiveIndex: (v: number) => void;\n listboxId: string;\n}\n\nconst SelectContext = createContext<SelectListboxContext>({} as SelectListboxContext);\n\ninterface Props {\n options: OptionValue[];\n defaultValue: SelectValue;\n}\n\nexport const SelectProvider = ({ options, defaultValue, children }: PropsWithChildren<Props>) => {\n const [value, setValue] = useState<OptionValue>({ value: '', label: '' });\n const [isOpen, setIsOpen] = useState(false);\n const [activeIndex, setActiveIndex] = useState(-1);\n const listboxId = useRef<string>(useId());\n\n const toggleListbox = () => {\n setIsOpen((status) => !status);\n };\n\n const getValue = (value: SelectValue) => {\n return (\n options.find((option) => option.value === value) || {\n value: -1,\n label: '',\n selectedLabel: '-',\n }\n );\n };\n\n const setSelectedValue = (value: OptionValue) => {\n const selectedIndex = options.findIndex((option) => option.value === value.value);\n setActiveIndex(selectedIndex);\n setValue(value);\n setIsOpen(false);\n };\n\n if (defaultValue !== -1 && !value.value) {\n setSelectedValue(getValue(defaultValue));\n }\n\n return (\n <SelectContext.Provider\n value={{\n options,\n selectedValue: value,\n setSelectedValue,\n isOpen,\n setIsOpen,\n toggleListbox,\n getValue,\n activeIndex,\n setActiveIndex,\n listboxId: listboxId.current,\n }}\n >\n {children}\n </SelectContext.Provider>\n );\n};\n\nexport const useSelect = () => {\n const context = useContext(SelectContext);\n\n if (context === undefined) throw new Error('useSelect can only be used in an SelectProvider');\n\n return context;\n};\n"],"names":["SelectContext","createContext","SelectProvider","options","defaultValue","children","value","setValue","useState","isOpen","setIsOpen","activeIndex","setActiveIndex","listboxId","useRef","useId","toggleListbox","status","getValue","option","setSelectedValue","selectedIndex","jsx","useSelect","context","useContext"],"mappings":";;AAyBA,MAAMA,IAAgBC,EAAoC,CAAA,CAA0B,GAOvEC,IAAiB,CAAC,EAAE,SAAAC,GAAS,cAAAC,GAAc,UAAAC,QAAyC;AACzF,QAAA,CAACC,GAAOC,CAAQ,IAAIC,EAAsB,EAAE,OAAO,IAAI,OAAO,GAAA,CAAI,GAClE,CAACC,GAAQC,CAAS,IAAIF,EAAS,EAAK,GACpC,CAACG,GAAaC,CAAc,IAAIJ,EAAS,EAAE,GAC3CK,IAAYC,EAAeC,EAAA,CAAO,GAElCC,IAAgB,MAAM;AAChB,IAAAN,EAAA,CAACO,MAAW,CAACA,CAAM;AAAA,EAAA,GAGzBC,IAAW,CAACZ,MAEdH,EAAQ,KAAK,CAACgB,MAAWA,EAAO,UAAUb,CAAK,KAAK;AAAA,IAClD,OAAO;AAAA,IACP,OAAO;AAAA,IACP,eAAe;AAAA,EAAA,GAKfc,IAAmB,CAACd,MAAuB;AACzC,UAAAe,IAAgBlB,EAAQ,UAAU,CAACgB,MAAWA,EAAO,UAAUb,EAAM,KAAK;AAChF,IAAAM,EAAeS,CAAa,GAC5Bd,EAASD,CAAK,GACdI,EAAU,EAAK;AAAA,EAAA;AAGjB,SAAIN,MAAiB,MAAM,CAACE,EAAM,SACfc,EAAAF,EAASd,CAAY,CAAC,GAIvC,gBAAAkB;AAAA,IAACtB,EAAc;AAAA,IAAd;AAAA,MACC,OAAO;AAAA,QACL,SAAAG;AAAA,QACA,eAAeG;AAAA,QACf,kBAAAc;AAAA,QACA,QAAAX;AAAA,QACA,WAAAC;AAAA,QACA,eAAAM;AAAA,QACA,UAAAE;AAAA,QACA,aAAAP;AAAA,QACA,gBAAAC;AAAA,QACA,WAAWC,EAAU;AAAA,MACvB;AAAA,MAEC,UAAAR;AAAA,IAAA;AAAA,EAAA;AAGP,GAEakB,IAAY,MAAM;AACvB,QAAAC,IAAUC,EAAWzB,CAAa;AAExC,MAAIwB,MAAY;AAAiB,UAAA,IAAI,MAAM,iDAAiD;AAErF,SAAAA;AACT;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { OptionValue } from 'components/SelectListbox/SelectProvider';
|
|
2
|
+
|
|
3
|
+
export interface SelectButtonProps {
|
|
4
|
+
variant?: 'noborder' | 'pill' | 'pillLeft' | 'pillRight';
|
|
5
|
+
onChange?: (option: OptionValue) => void;
|
|
6
|
+
buttonLabelProp?: string;
|
|
7
|
+
buttonLabelBold?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const SelectButton: ({ variant, onChange, buttonLabelProp, buttonLabelBold, disabled, }: SelectButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { jsxs as w, jsx as D } from "react/jsx-runtime";
|
|
2
|
+
import { c as f } from "../../../clsx-DB4S2d7J.js";
|
|
3
|
+
import { useRef as p, useEffect as c } from "react";
|
|
4
|
+
import { s } from "../../../SelectListbox.module-wZfvJXBJ.js";
|
|
5
|
+
import { Icon as E } from "../../Icon/Icon.js";
|
|
6
|
+
import { useSelect as R } from "../SelectProvider.js";
|
|
7
|
+
const O = ({
|
|
8
|
+
variant: a,
|
|
9
|
+
onChange: i,
|
|
10
|
+
buttonLabelProp: b = "label",
|
|
11
|
+
buttonLabelBold: m,
|
|
12
|
+
disabled: x = !1
|
|
13
|
+
}) => {
|
|
14
|
+
const l = p(null), n = p(!0), { listboxId: g, isOpen: t, selectedValue: e, toggleListbox: d, setIsOpen: u, setActiveIndex: y, options: I } = R() || {}, k = (r) => {
|
|
15
|
+
switch (r.key) {
|
|
16
|
+
case "Enter":
|
|
17
|
+
if (r.preventDefault(), !t) {
|
|
18
|
+
u(!0);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
break;
|
|
22
|
+
case "Escape":
|
|
23
|
+
t && (r.stopPropagation(), y(I.findIndex((o) => o.value === (e == null ? void 0 : e.value))), u(!1));
|
|
24
|
+
break;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
return c(() => {
|
|
28
|
+
var r, o;
|
|
29
|
+
t ? (r = l.current) == null || r.blur() : !n.current && ((o = l.current) == null || o.focus());
|
|
30
|
+
}, [t]), c(() => {
|
|
31
|
+
i && i(e);
|
|
32
|
+
}, [i, e]), c(() => (n.current = !1, () => {
|
|
33
|
+
n.current = !0;
|
|
34
|
+
}), []), /* @__PURE__ */ w(
|
|
35
|
+
"button",
|
|
36
|
+
{
|
|
37
|
+
className: f(s["select-listbox-trigger"], {
|
|
38
|
+
[s[`select-listbox-trigger--${a}`]]: a,
|
|
39
|
+
[s["select-listbox-trigger--bold"]]: m
|
|
40
|
+
}),
|
|
41
|
+
type: "button",
|
|
42
|
+
onClick: d,
|
|
43
|
+
onKeyDown: k,
|
|
44
|
+
"aria-expanded": t,
|
|
45
|
+
"aria-haspopup": "listbox",
|
|
46
|
+
"aria-label": `${e.label}`,
|
|
47
|
+
disabled: x,
|
|
48
|
+
"aria-controls": g,
|
|
49
|
+
ref: l,
|
|
50
|
+
children: [
|
|
51
|
+
e[b],
|
|
52
|
+
/* @__PURE__ */ D(
|
|
53
|
+
E,
|
|
54
|
+
{
|
|
55
|
+
className: f(s["select-listbox-trigger-icon"], {
|
|
56
|
+
[s["select-listbox-trigger-icon--open"]]: t
|
|
57
|
+
}),
|
|
58
|
+
name: "CheveronDown",
|
|
59
|
+
size: 16
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
O as SelectButton
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=SelectButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectButton.js","sources":["../../../../src/components/SelectListbox/components/SelectButton.tsx"],"sourcesContent":["import { clsx } from 'clsx';\nimport { useEffect, useRef } from 'react';\n\nimport type {KeyboardEvent} from 'react';\nimport type { OptionValue, SelectValue } from 'components/SelectListbox/SelectProvider';\n\nimport styles from 'components/SelectListbox/SelectListbox.module.css';\nimport { Icon } from 'components/Icon';\nimport { useSelect } from 'components/SelectListbox/SelectProvider';\n\nexport interface SelectButtonProps {\n variant?: 'noborder' | 'pill' | 'pillLeft' | 'pillRight';\n onChange?: (option: OptionValue) => void;\n buttonLabelProp?: string;\n buttonLabelBold?: boolean;\n disabled?: boolean;\n}\n\nexport const SelectButton = ({\n variant,\n onChange,\n buttonLabelProp = 'label',\n buttonLabelBold,\n disabled = false,\n}: SelectButtonProps) => {\n const selectButtonRef = useRef<HTMLButtonElement>(null);\n const isFirstRender = useRef(true);\n const { listboxId, isOpen, selectedValue, toggleListbox, setIsOpen, setActiveIndex, options } = useSelect() || {};\n\n const onTriggerKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n switch (event.key) {\n case 'Enter':\n event.preventDefault();\n if (!isOpen) {\n setIsOpen(true);\n return;\n }\n break;\n case 'Escape':\n if (isOpen) {\n event.stopPropagation();\n setActiveIndex(options.findIndex((option) => option.value === selectedValue?.value));\n setIsOpen(false);\n }\n break;\n }\n };\n\n useEffect(() => {\n isOpen ? selectButtonRef.current?.blur() : !isFirstRender.current && selectButtonRef.current?.focus();\n }, [isOpen]);\n\n useEffect(() => {\n if (onChange) onChange(selectedValue);\n }, [onChange, selectedValue]);\n\n useEffect(() => {\n isFirstRender.current = false;\n\n return () => {\n isFirstRender.current = true;\n };\n }, []);\n\n return (\n <button\n className={clsx(styles['select-listbox-trigger'], {\n [styles[`select-listbox-trigger--${variant}`]]: variant,\n [styles['select-listbox-trigger--bold']]: buttonLabelBold,\n })}\n type=\"button\"\n onClick={toggleListbox}\n onKeyDown={onTriggerKeyDown}\n aria-expanded={isOpen}\n aria-haspopup=\"listbox\"\n aria-label={`${selectedValue.label}`}\n disabled={disabled}\n aria-controls={listboxId}\n ref={selectButtonRef}\n >\n {selectedValue[buttonLabelProp as keyof SelectValue]}\n\n <Icon\n className={clsx(styles['select-listbox-trigger-icon'], {\n [styles['select-listbox-trigger-icon--open']]: isOpen,\n })}\n name=\"CheveronDown\"\n size={16}\n />\n </button>\n );\n};\n"],"names":["SelectButton","variant","onChange","buttonLabelProp","buttonLabelBold","disabled","selectButtonRef","useRef","isFirstRender","listboxId","isOpen","selectedValue","toggleListbox","setIsOpen","setActiveIndex","options","useSelect","onTriggerKeyDown","event","option","useEffect","_a","_b","jsxs","clsx","styles","jsx","Icon"],"mappings":";;;;;;AAkBO,MAAMA,IAAe,CAAC;AAAA,EAC3B,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,iBAAAC;AAAA,EACA,UAAAC,IAAW;AACb,MAAyB;AACjB,QAAAC,IAAkBC,EAA0B,IAAI,GAChDC,IAAgBD,EAAO,EAAI,GAC3B,EAAE,WAAAE,GAAW,QAAAC,GAAQ,eAAAC,GAAe,eAAAC,GAAe,WAAAC,GAAW,gBAAAC,GAAgB,SAAAC,EAAQ,IAAIC,EAAU,KAAK,CAAA,GAEzGC,IAAmB,CAACC,MAA4C;AACpE,YAAQA,EAAM,KAAK;AAAA,MACjB,KAAK;AAEH,YADAA,EAAM,eAAe,GACjB,CAACR,GAAQ;AACX,UAAAG,EAAU,EAAI;AACd;AAAA,QACF;AACA;AAAA,MACF,KAAK;AACH,QAAIH,MACFQ,EAAM,gBAAgB,GACPJ,EAAAC,EAAQ,UAAU,CAACI,MAAWA,EAAO,WAAUR,KAAA,gBAAAA,EAAe,MAAK,CAAC,GACnFE,EAAU,EAAK;AAEjB;AAAA,IACJ;AAAA,EAAA;AAGF,SAAAO,EAAU,MAAM;;AACL,IAAAV,KAAAW,IAAAf,EAAgB,YAAhB,QAAAe,EAAyB,SAAS,CAACb,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