@grantbii/design-system 1.0.81 → 1.0.82
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/core/molecules/Dropdown.d.ts +2 -2
- package/core/molecules/Dropdown.js +1 -1
- package/core/molecules/Dropdown.js.map +1 -1
- package/core/molecules/index.d.ts +1 -1
- package/core/molecules/index.js.map +1 -1
- package/package.json +1 -1
- package/stories/molecules/Dropdown.stories.d.ts +7 -5
- package/stories/molecules/Dropdown.stories.js +27 -18
- package/stories/molecules/Dropdown.stories.js.map +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DetailedHTMLProps, SelectHTMLAttributes } from "react";
|
|
2
2
|
import type { Option } from "../foundations";
|
|
3
|
-
type DropdownProps = {
|
|
3
|
+
export type DropdownProps = {
|
|
4
4
|
options: Option[];
|
|
5
5
|
defaultLabel?: string;
|
|
6
6
|
} & DetailedHTMLProps<SelectHTMLAttributes<HTMLSelectElement>, HTMLSelectElement>;
|
|
7
|
-
declare const Dropdown: ({ options, defaultLabel,
|
|
7
|
+
declare const Dropdown: ({ options, defaultLabel, ...selectProps }: DropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export default Dropdown;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Select } from "../atoms";
|
|
3
|
-
const Dropdown = ({ options, defaultLabel,
|
|
3
|
+
const Dropdown = ({ options, defaultLabel, ...selectProps }) => (_jsxs(Select, { ...selectProps, children: [_jsx("option", { hidden: true, disabled: true, value: "", children: defaultLabel ? defaultLabel : "-" }), options.map((option) => (_jsx("option", { value: option.value, children: option.label }, option.value)))] }));
|
|
4
4
|
export default Dropdown;
|
|
5
5
|
//# sourceMappingURL=Dropdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.js","sourceRoot":"","sources":["../../../core/molecules/Dropdown.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAWlC,MAAM,QAAQ,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"Dropdown.js","sourceRoot":"","sources":["../../../core/molecules/Dropdown.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAWlC,MAAM,QAAQ,GAAG,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,WAAW,EAAiB,EAAE,EAAE,CAAC,CAC7E,MAAC,MAAM,OAAK,WAAW,aACrB,iBAAQ,MAAM,QAAC,QAAQ,QAAC,KAAK,EAAC,EAAE,YAC7B,YAAY,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,GAC3B,EAER,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CACvB,iBAA2B,KAAK,EAAE,MAAM,CAAC,KAAK,YAC3C,MAAM,CAAC,KAAK,IADF,MAAM,CAAC,KAAK,CAEhB,CACV,CAAC,IACK,CACV,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import type { DetailedHTMLProps, SelectHTMLAttributes } from \"react\";\nimport { Select } from \"../atoms\";\nimport type { Option } from \"../foundations\";\n\nexport type DropdownProps = {\n options: Option[];\n defaultLabel?: string;\n} & DetailedHTMLProps<\n SelectHTMLAttributes<HTMLSelectElement>,\n HTMLSelectElement\n>;\n\nconst Dropdown = ({ options, defaultLabel, ...selectProps }: DropdownProps) => (\n <Select {...selectProps}>\n <option hidden disabled value=\"\">\n {defaultLabel ? defaultLabel : \"-\"}\n </option>\n\n {options.map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </Select>\n);\n\nexport default Dropdown;\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as Dropdown } from "./Dropdown";
|
|
1
|
+
export { default as Dropdown, type DropdownProps } from "./Dropdown";
|
|
2
2
|
export { default as FileDrop, useFileDrop } from "./FileDrop";
|
|
3
3
|
export { default as Modal, useModal } from "./Modal";
|
|
4
4
|
export { default as RadioButtons, type RadioOption } from "./RadioButtons";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../core/molecules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../core/molecules/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAsB,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAoB,MAAM,gBAAgB,CAAC","sourcesContent":["export { default as Dropdown, type DropdownProps } from \"./Dropdown\";\nexport { default as FileDrop, useFileDrop } from \"./FileDrop\";\nexport { default as Modal, useModal } from \"./Modal\";\nexport { default as RadioButtons, type RadioOption } from \"./RadioButtons\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Dropdown } from "@/.";
|
|
2
1
|
import type { Meta, StoryObj } from "@storybook/nextjs-vite";
|
|
3
|
-
|
|
2
|
+
type ExampleProps = {
|
|
3
|
+
controlled: boolean;
|
|
4
|
+
};
|
|
5
|
+
declare const DropdownExample: ({ controlled }: ExampleProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
declare const meta: Meta<typeof DropdownExample>;
|
|
4
7
|
export default meta;
|
|
5
8
|
type Story = StoryObj<typeof meta>;
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
8
|
-
export declare const WithValidation: Story;
|
|
9
|
+
export declare const Controlled: Story;
|
|
10
|
+
export declare const Uncontrolled: Story;
|
|
@@ -1,34 +1,43 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
import { Dropdown } from "@/.";
|
|
2
|
-
import { Need } from "@grantbii/ui-base/filter/enums";
|
|
3
|
+
import { Need, parseNeed } from "@grantbii/ui-base/filter/enums";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
const DropdownExample = ({ controlled }) => {
|
|
6
|
+
const [selectedNeed, setSelectedNeed] = useState(Need.UNKNOWN);
|
|
7
|
+
const controlledProps = {
|
|
8
|
+
options,
|
|
9
|
+
defaultLabel,
|
|
10
|
+
value: selectedNeed === Need.UNKNOWN ? "" : selectedNeed,
|
|
11
|
+
onChange: (event) => setSelectedNeed(parseNeed(event.target.value)),
|
|
12
|
+
};
|
|
13
|
+
return _jsx(Dropdown, { ...(controlled ? controlledProps : uncontrolledProps) });
|
|
14
|
+
};
|
|
15
|
+
const defaultLabel = "Select your grant need";
|
|
16
|
+
const options = Object.values(Need)
|
|
17
|
+
.filter((need) => need !== Need.UNKNOWN)
|
|
18
|
+
.map((need) => ({ label: need, value: need }));
|
|
19
|
+
const uncontrolledProps = {
|
|
20
|
+
options,
|
|
21
|
+
defaultLabel,
|
|
22
|
+
defaultValue: "",
|
|
23
|
+
};
|
|
3
24
|
const meta = {
|
|
4
25
|
title: "Molecules/Dropdown",
|
|
5
|
-
component:
|
|
26
|
+
component: DropdownExample,
|
|
6
27
|
tags: ["autodocs"],
|
|
7
28
|
parameters: {
|
|
8
29
|
layout: "centered",
|
|
9
30
|
},
|
|
10
31
|
};
|
|
11
32
|
export default meta;
|
|
12
|
-
const
|
|
13
|
-
.filter((need) => need !== Need.UNKNOWN)
|
|
14
|
-
.map((need) => ({ label: need, value: need }));
|
|
15
|
-
export const BasicExample = {
|
|
33
|
+
export const Controlled = {
|
|
16
34
|
args: {
|
|
17
|
-
|
|
35
|
+
controlled: true,
|
|
18
36
|
},
|
|
19
37
|
};
|
|
20
|
-
export const
|
|
38
|
+
export const Uncontrolled = {
|
|
21
39
|
args: {
|
|
22
|
-
|
|
23
|
-
defaultValue: "-",
|
|
24
|
-
defaultLabel: "Select your grant need",
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
export const WithValidation = {
|
|
28
|
-
args: {
|
|
29
|
-
options,
|
|
30
|
-
required: true,
|
|
31
|
-
defaultLabel: "Select your grant need",
|
|
40
|
+
controlled: false,
|
|
32
41
|
},
|
|
33
42
|
};
|
|
34
43
|
//# sourceMappingURL=Dropdown.stories.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown.stories.js","sourceRoot":"","sources":["../../../stories/molecules/Dropdown.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"Dropdown.stories.js","sourceRoot":"","sources":["../../../stories/molecules/Dropdown.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAsB,MAAM,KAAK,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAMjC,MAAM,eAAe,GAAG,CAAC,EAAE,UAAU,EAAgB,EAAE,EAAE;IACvD,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAE/D,MAAM,eAAe,GAAkB;QACrC,OAAO;QACP,YAAY;QACZ,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY;QACxD,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;KACpE,CAAC;IAEF,OAAO,KAAC,QAAQ,OAAK,CAAC,UAAU,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAI,CAAC;AAC9E,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,wBAAwB,CAAC;AAE9C,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;KAChC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,IAAI,CAAC,OAAO,CAAC;KACvC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAEjD,MAAM,iBAAiB,GAAkB;IACvC,OAAO;IACP,YAAY;IACZ,YAAY,EAAE,EAAE;CACjB,CAAC;AAEF,MAAM,IAAI,GAAiC;IACzC,KAAK,EAAE,oBAAoB;IAC3B,SAAS,EAAE,eAAe;IAC1B,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,UAAU,EAAE;QACV,MAAM,EAAE,UAAU;KACnB;CACF,CAAC;AAEF,eAAe,IAAI,CAAC;AAIpB,MAAM,CAAC,MAAM,UAAU,GAAU;IAC/B,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI;KACjB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAU;IACjC,IAAI,EAAE;QACJ,UAAU,EAAE,KAAK;KAClB;CACF,CAAC","sourcesContent":["import { Dropdown, type DropdownProps } from \"@/.\";\nimport { Need, parseNeed } from \"@grantbii/ui-base/filter/enums\";\nimport type { Meta, StoryObj } from \"@storybook/nextjs-vite\";\nimport { useState } from \"react\";\n\ntype ExampleProps = {\n controlled: boolean;\n};\n\nconst DropdownExample = ({ controlled }: ExampleProps) => {\n const [selectedNeed, setSelectedNeed] = useState(Need.UNKNOWN);\n\n const controlledProps: DropdownProps = {\n options,\n defaultLabel,\n value: selectedNeed === Need.UNKNOWN ? \"\" : selectedNeed,\n onChange: (event) => setSelectedNeed(parseNeed(event.target.value)),\n };\n\n return <Dropdown {...(controlled ? controlledProps : uncontrolledProps)} />;\n};\n\nconst defaultLabel = \"Select your grant need\";\n\nconst options = Object.values(Need)\n .filter((need) => need !== Need.UNKNOWN)\n .map((need) => ({ label: need, value: need }));\n\nconst uncontrolledProps: DropdownProps = {\n options,\n defaultLabel,\n defaultValue: \"\",\n};\n\nconst meta: Meta<typeof DropdownExample> = {\n title: \"Molecules/Dropdown\",\n component: DropdownExample,\n tags: [\"autodocs\"],\n parameters: {\n layout: \"centered\",\n },\n};\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\n\nexport const Controlled: Story = {\n args: {\n controlled: true,\n },\n};\n\nexport const Uncontrolled: Story = {\n args: {\n controlled: false,\n },\n};\n"]}
|