@grantbii/design-system 1.9.7 → 1.10.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/core/atoms/LocationIcon.d.ts +8 -0
- package/core/atoms/LocationIcon.js +26 -0
- package/core/atoms/LocationIcon.js.map +1 -0
- package/core/atoms/index.d.ts +1 -0
- package/core/atoms/index.js +1 -0
- package/core/atoms/index.js.map +1 -1
- package/core/foundations/icons.js.map +1 -1
- package/core/integrations/mappings.d.ts +1 -5
- package/core/integrations/mappings.js +0 -14
- package/core/integrations/mappings.js.map +1 -1
- package/package.json +18 -17
- package/stories/atoms/LocationIcon.stories.d.ts +7 -0
- package/stories/atoms/LocationIcon.stories.js +21 -0
- package/stories/atoms/LocationIcon.stories.js.map +1 -0
- package/stories/molecules/RadioButtons.stories.js +2 -5
- package/stories/molecules/RadioButtons.stories.js.map +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Location } from "@grantbii/ui-core/location/enums";
|
|
2
|
+
import type { JSX } from "react";
|
|
3
|
+
type LocationIconProps = {
|
|
4
|
+
location: Location;
|
|
5
|
+
width?: string | number;
|
|
6
|
+
};
|
|
7
|
+
declare const LocationIcon: ({ location, width }: LocationIconProps) => JSX.Element;
|
|
8
|
+
export default LocationIcon;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Location } from "@grantbii/ui-core/location/enums";
|
|
3
|
+
import { Flags, Icons } from "../foundations";
|
|
4
|
+
const LocationIcon = ({ location, width }) => {
|
|
5
|
+
if (location === Location.OTHERS || location === Location.UNKNOWN) {
|
|
6
|
+
return _jsx(Icons.GlobeIcon, { size: width });
|
|
7
|
+
}
|
|
8
|
+
else {
|
|
9
|
+
const Flag = LOCATION_FLAG_MAP[location] ?? Flags.EU;
|
|
10
|
+
return _jsx(Flag, { width: width });
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export default LocationIcon;
|
|
14
|
+
const LOCATION_FLAG_MAP = {
|
|
15
|
+
[Location.SINGAPORE]: Flags.SG,
|
|
16
|
+
[Location.HONG_KONG]: Flags.HK,
|
|
17
|
+
[Location.MALAYSIA]: Flags.MY,
|
|
18
|
+
[Location.SOUTH_KOREA]: Flags.KR,
|
|
19
|
+
[Location.JAPAN]: Flags.JP,
|
|
20
|
+
[Location.CHINA]: Flags.CN,
|
|
21
|
+
[Location.UNITED_KINGDOM]: Flags.GB,
|
|
22
|
+
[Location.UNITED_STATES]: Flags.US,
|
|
23
|
+
[Location.OTHERS]: Flags.EU,
|
|
24
|
+
[Location.UNKNOWN]: Flags.EU,
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=LocationIcon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocationIcon.js","sourceRoot":"","sources":["../../../core/atoms/LocationIcon.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAE5D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAO9C,MAAM,YAAY,GAAG,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAqB,EAAe,EAAE;IAC3E,IAAI,QAAQ,KAAK,QAAQ,CAAC,MAAM,IAAI,QAAQ,KAAK,QAAQ,CAAC,OAAO,EAAE,CAAC;QAClE,OAAO,KAAC,KAAK,CAAC,SAAS,IAAC,IAAI,EAAE,KAAK,GAAI,CAAC;IAC1C,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,GAAG,iBAAiB,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;QACrD,OAAO,KAAC,IAAI,IAAC,KAAK,EAAE,KAAK,GAAI,CAAC;IAChC,CAAC;AACH,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC;AAE5B,MAAM,iBAAiB,GAEnB;IACF,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,EAAE;IAC9B,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,KAAK,CAAC,EAAE;IAC9B,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,EAAE;IAC7B,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,EAAE;IAChC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE;IAC1B,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,EAAE;IAC1B,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,KAAK,CAAC,EAAE;IACnC,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,KAAK,CAAC,EAAE;IAClC,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,EAAE;IAC3B,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,EAAE;CAC7B,CAAC","sourcesContent":["import { Location } from \"@grantbii/ui-core/location/enums\";\nimport type { JSX } from \"react\";\nimport { Flags, Icons } from \"../foundations\";\n\ntype LocationIconProps = {\n location: Location;\n width?: string | number;\n};\n\nconst LocationIcon = ({ location, width }: LocationIconProps): JSX.Element => {\n if (location === Location.OTHERS || location === Location.UNKNOWN) {\n return <Icons.GlobeIcon size={width} />;\n } else {\n const Flag = LOCATION_FLAG_MAP[location] ?? Flags.EU;\n return <Flag width={width} />;\n }\n};\n\nexport default LocationIcon;\n\nconst LOCATION_FLAG_MAP: {\n [location in Location]: Flags.FlagComponent;\n} = {\n [Location.SINGAPORE]: Flags.SG,\n [Location.HONG_KONG]: Flags.HK,\n [Location.MALAYSIA]: Flags.MY,\n [Location.SOUTH_KOREA]: Flags.KR,\n [Location.JAPAN]: Flags.JP,\n [Location.CHINA]: Flags.CN,\n [Location.UNITED_KINGDOM]: Flags.GB,\n [Location.UNITED_STATES]: Flags.US,\n [Location.OTHERS]: Flags.EU,\n [Location.UNKNOWN]: Flags.EU,\n};\n"]}
|
package/core/atoms/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export { default as Checkbox } from "./Checkbox";
|
|
|
5
5
|
export { default as Dropdown, type DropdownProps } from "./Dropdown";
|
|
6
6
|
export { default as Input } from "./Input";
|
|
7
7
|
export { default as LinkButton } from "./LinkButton";
|
|
8
|
+
export { default as LocationIcon } from "./LocationIcon";
|
|
8
9
|
export { default as Overlay } from "./Overlay";
|
|
9
10
|
export { default as RadioButton } from "./RadioButton";
|
|
10
11
|
export { default as Textarea } from "./Textarea";
|
package/core/atoms/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { default as Checkbox } from "./Checkbox";
|
|
|
5
5
|
export { default as Dropdown } from "./Dropdown";
|
|
6
6
|
export { default as Input } from "./Input";
|
|
7
7
|
export { default as LinkButton } from "./LinkButton";
|
|
8
|
+
export { default as LocationIcon } from "./LocationIcon";
|
|
8
9
|
export { default as Overlay } from "./Overlay";
|
|
9
10
|
export { default as RadioButton } from "./RadioButton";
|
|
10
11
|
export { default as Textarea } from "./Textarea";
|
package/core/atoms/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../core/atoms/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAmB,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAsB,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export { default as Badge, type BadgeProps } from \"./Badge\";\nexport { default as BrandLogo } from \"./BrandLogo\";\nexport { default as Button } from \"./Button\";\nexport { default as Checkbox } from \"./Checkbox\";\nexport { default as Dropdown, type DropdownProps } from \"./Dropdown\";\nexport { default as Input } from \"./Input\";\nexport { default as LinkButton } from \"./LinkButton\";\nexport { default as Overlay } from \"./Overlay\";\nexport { default as RadioButton } from \"./RadioButton\";\nexport { default as Textarea } from \"./Textarea\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../core/atoms/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,KAAK,EAAmB,MAAM,SAAS,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAsB,MAAM,YAAY,CAAC;AACrE,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC","sourcesContent":["export { default as Badge, type BadgeProps } from \"./Badge\";\nexport { default as BrandLogo } from \"./BrandLogo\";\nexport { default as Button } from \"./Button\";\nexport { default as Checkbox } from \"./Checkbox\";\nexport { default as Dropdown, type DropdownProps } from \"./Dropdown\";\nexport { default as Input } from \"./Input\";\nexport { default as LinkButton } from \"./LinkButton\";\nexport { default as LocationIcon } from \"./LocationIcon\";\nexport { default as Overlay } from \"./Overlay\";\nexport { default as RadioButton } from \"./RadioButton\";\nexport { default as Textarea } from \"./Textarea\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../../../core/foundations/icons.
|
|
1
|
+
{"version":3,"file":"icons.js","sourceRoot":"","sources":["../../../core/foundations/icons.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC","sourcesContent":["export * from \"@phosphor-icons/react\";\n"]}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
import type { BaseEnumType } from "@grantbii/ui-core/enums";
|
|
2
|
-
import {
|
|
3
|
-
import { Flags, type Option } from "../foundations";
|
|
2
|
+
import type { Option } from "../foundations";
|
|
4
3
|
export declare const mapEnumToOptions: <EnumType extends BaseEnumType>(enumType: EnumType) => Option[];
|
|
5
|
-
export declare const LOCATION_FLAG_MAP: {
|
|
6
|
-
[location in Location]: Flags.FlagComponent;
|
|
7
|
-
};
|
|
@@ -1,18 +1,4 @@
|
|
|
1
|
-
import { Location } from "@grantbii/ui-core/location/enums";
|
|
2
|
-
import { Flags } from "../foundations";
|
|
3
1
|
export const mapEnumToOptions = (enumType) => Object.values(enumType)
|
|
4
2
|
.filter((value) => value !== enumType.UNKNOWN)
|
|
5
3
|
.map((value) => ({ label: value, value }));
|
|
6
|
-
export const LOCATION_FLAG_MAP = {
|
|
7
|
-
[Location.SINGAPORE]: Flags.SG,
|
|
8
|
-
[Location.HONG_KONG]: Flags.HK,
|
|
9
|
-
[Location.MALAYSIA]: Flags.MY,
|
|
10
|
-
[Location.SOUTH_KOREA]: Flags.KR,
|
|
11
|
-
[Location.JAPAN]: Flags.JP,
|
|
12
|
-
[Location.CHINA]: Flags.CN,
|
|
13
|
-
[Location.UNITED_KINGDOM]: Flags.GB,
|
|
14
|
-
[Location.UNITED_STATES]: Flags.US,
|
|
15
|
-
[Location.OTHERS]: Flags.SG,
|
|
16
|
-
[Location.UNKNOWN]: Flags.SG,
|
|
17
|
-
};
|
|
18
4
|
//# sourceMappingURL=mappings.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mappings.js","sourceRoot":"","sources":["../../../core/integrations/mappings.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mappings.js","sourceRoot":"","sources":["../../../core/integrations/mappings.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,QAAkB,EACR,EAAE,CACZ,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;KACpB,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,QAAQ,CAAC,OAAO,CAAC;KAC7C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC","sourcesContent":["import type { BaseEnumType } from \"@grantbii/ui-core/enums\";\nimport type { Option } from \"../foundations\";\n\nexport const mapEnumToOptions = <EnumType extends BaseEnumType>(\n enumType: EnumType,\n): Option[] =>\n Object.values(enumType)\n .filter((value) => value !== enumType.UNKNOWN)\n .map((value) => ({ label: value, value }));\n"]}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@grantbii/design-system",
|
|
3
3
|
"author": "Grantbii",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.10.0",
|
|
6
6
|
"description": "Grantbii's Design System",
|
|
7
7
|
"homepage": "https://design.grantbii.com",
|
|
8
8
|
"repository": {
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"build-storybook": "storybook build"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@grantbii/ui-core": "1.
|
|
23
|
+
"@grantbii/ui-core": "1.6.1",
|
|
24
24
|
"@phosphor-icons/react": "2.1.10",
|
|
25
25
|
"country-flag-icons": "1.6.4",
|
|
26
|
-
"next": "16.
|
|
26
|
+
"next": "16.1.1",
|
|
27
27
|
"react": "19.2.3",
|
|
28
28
|
"react-dom": "19.2.3",
|
|
29
29
|
"react-dropzone": "14.3.8",
|
|
@@ -33,34 +33,35 @@
|
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@chromatic-com/storybook": "4.1.3",
|
|
35
35
|
"@eslint/js": "9.39.2",
|
|
36
|
-
"@next/eslint-plugin-next": "16.
|
|
37
|
-
"@storybook/addon-a11y": "10.1.
|
|
38
|
-
"@storybook/addon-docs": "10.1.
|
|
39
|
-
"@storybook/addon-onboarding": "10.1.
|
|
40
|
-
"@storybook/addon-vitest": "10.1.
|
|
41
|
-
"@storybook/nextjs-vite": "10.1.
|
|
36
|
+
"@next/eslint-plugin-next": "16.1.1",
|
|
37
|
+
"@storybook/addon-a11y": "10.1.10",
|
|
38
|
+
"@storybook/addon-docs": "10.1.10",
|
|
39
|
+
"@storybook/addon-onboarding": "10.1.10",
|
|
40
|
+
"@storybook/addon-vitest": "10.1.10",
|
|
41
|
+
"@storybook/nextjs-vite": "10.1.10",
|
|
42
42
|
"@types/node": "22.18.0",
|
|
43
43
|
"@types/react": "19.2.7",
|
|
44
44
|
"@types/react-dom": "19.2.3",
|
|
45
|
-
"@vitest/browser": "4.0.
|
|
46
|
-
"@vitest/browser-playwright": "4.0.
|
|
47
|
-
"@vitest/coverage-v8": "4.0.
|
|
45
|
+
"@vitest/browser": "4.0.16",
|
|
46
|
+
"@vitest/browser-playwright": "4.0.16",
|
|
47
|
+
"@vitest/coverage-v8": "4.0.16",
|
|
48
|
+
"baseline-browser-mapping": "^2.9.11",
|
|
48
49
|
"eslint": "9.39.2",
|
|
49
|
-
"eslint-config-next": "16.
|
|
50
|
-
"eslint-plugin-storybook": "10.1.
|
|
50
|
+
"eslint-config-next": "16.1.1",
|
|
51
|
+
"eslint-plugin-storybook": "10.1.10",
|
|
51
52
|
"husky": "9.1.7",
|
|
52
53
|
"lint-staged": "16.2.7",
|
|
53
54
|
"playwright": "1.57.0",
|
|
54
55
|
"prettier": "3.7.4",
|
|
55
|
-
"storybook": "10.1.
|
|
56
|
+
"storybook": "10.1.10",
|
|
56
57
|
"typescript": "5.9.3",
|
|
57
|
-
"vitest": "4.0.
|
|
58
|
+
"vitest": "4.0.16"
|
|
58
59
|
},
|
|
59
60
|
"lint-staged": {
|
|
60
61
|
"**/*.{html,css,json,md,yaml}": [
|
|
61
62
|
"prettier --write"
|
|
62
63
|
],
|
|
63
|
-
"**/*.{ts,tsx}": [
|
|
64
|
+
"**/*.{mjs,ts,tsx}": [
|
|
64
65
|
"eslint --fix",
|
|
65
66
|
"prettier --write"
|
|
66
67
|
]
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { LocationIcon } from "@/.";
|
|
2
|
+
import type { Meta, StoryObj } from "@storybook/nextjs-vite";
|
|
3
|
+
declare const meta: Meta<typeof LocationIcon>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const SingaporeIcon: Story;
|
|
7
|
+
export declare const OthersIcon: Story;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { LocationIcon } from "@/.";
|
|
2
|
+
import { Location } from "@grantbii/ui-core/location/enums";
|
|
3
|
+
const meta = {
|
|
4
|
+
title: "Atoms/Location Icon",
|
|
5
|
+
component: LocationIcon,
|
|
6
|
+
tags: ["autodocs"],
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: "centered",
|
|
9
|
+
docs: {
|
|
10
|
+
codePanel: true,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
export default meta;
|
|
15
|
+
export const SingaporeIcon = {
|
|
16
|
+
args: { location: Location.SINGAPORE, width: 24 },
|
|
17
|
+
};
|
|
18
|
+
export const OthersIcon = {
|
|
19
|
+
args: { location: Location.OTHERS, width: 24 },
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=LocationIcon.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LocationIcon.stories.js","sourceRoot":"","sources":["../../../stories/atoms/LocationIcon.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAG5D,MAAM,IAAI,GAA8B;IACtC,KAAK,EAAE,qBAAqB;IAC5B,SAAS,EAAE,YAAY;IACvB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,UAAU,EAAE;QACV,MAAM,EAAE,UAAU;QAClB,IAAI,EAAE;YACJ,SAAS,EAAE,IAAI;SAChB;KACF;CACF,CAAC;AAEF,eAAe,IAAI,CAAC;AAIpB,MAAM,CAAC,MAAM,aAAa,GAAU;IAClC,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE;CAClD,CAAC;AACF,MAAM,CAAC,MAAM,UAAU,GAAU;IAC/B,IAAI,EAAE,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE;CAC/C,CAAC","sourcesContent":["import { LocationIcon } from \"@/.\";\nimport { Location } from \"@grantbii/ui-core/location/enums\";\nimport type { Meta, StoryObj } from \"@storybook/nextjs-vite\";\n\nconst meta: Meta<typeof LocationIcon> = {\n title: \"Atoms/Location Icon\",\n component: LocationIcon,\n tags: [\"autodocs\"],\n parameters: {\n layout: \"centered\",\n docs: {\n codePanel: true,\n },\n },\n};\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\n\nexport const SingaporeIcon: Story = {\n args: { location: Location.SINGAPORE, width: 24 },\n};\nexport const OthersIcon: Story = {\n args: { location: Location.OTHERS, width: 24 },\n};\n"]}
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { LocationIcon, RadioButtons } from "@/.";
|
|
3
3
|
import { Location } from "@grantbii/ui-core/location/enums";
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import styled from "styled-components";
|
|
6
|
-
const Label = ({ location }) => {
|
|
7
|
-
const Flag = LOCATION_FLAG_MAP[location];
|
|
8
|
-
return (_jsxs(BaseLabel, { children: [_jsx(Flag, { width: 20 }), _jsx("p", { children: location })] }));
|
|
9
|
-
};
|
|
6
|
+
const Label = ({ location }) => (_jsxs(BaseLabel, { children: [_jsx(LocationIcon, { location: location, width: 20 }), _jsx("p", { children: location })] }));
|
|
10
7
|
const BaseLabel = styled.div `
|
|
11
8
|
display: flex;
|
|
12
9
|
align-items: center;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadioButtons.stories.js","sourceRoot":"","sources":["../../../stories/molecules/RadioButtons.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"RadioButtons.stories.js","sourceRoot":"","sources":["../../../stories/molecules/RadioButtons.stories.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAE5D,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AAMvC,MAAM,KAAK,GAAG,CAAC,EAAE,QAAQ,EAAc,EAAE,EAAE,CAAC,CAC1C,MAAC,SAAS,eACR,KAAC,YAAY,IAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,EAAE,GAAI,EAC/C,sBAAI,QAAQ,GAAK,IACP,CACb,CAAC;AAEF,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAA;;;;CAI3B,CAAC;AAMF,MAAM,mBAAmB,GAAG,CAAC,EAAE,UAAU,EAAgB,EAAE,EAAE;IAC3D,MAAM,CAAC,gBAAgB,EAAE,mBAAmB,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAE7D,MAAM,eAAe,GAAG;QACtB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;aAC7B,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,QAAQ,CAAC,OAAO,CAAC;aACnD,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YAClB,KAAK,EAAE,QAAQ;YACf,KAAK,EAAE,KAAC,KAAK,IAAC,QAAQ,EAAE,QAAQ,GAAI;YACpC,OAAO,EAAE,gBAAgB,KAAK,QAAQ;YACtC,OAAO,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,QAAQ,CAAC;SAC7C,CAAC,CAAC;KACN,CAAC;IAEF,OAAO,CACL,KAAC,YAAY,OAAK,CAAC,UAAU,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAI,CACzE,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG;IACxB,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;SAC7B,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,QAAQ,CAAC,OAAO,CAAC;SACnD,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAClB,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,KAAC,KAAK,IAAC,QAAQ,EAAE,QAAQ,GAAI;QACpC,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,YAAY,QAAQ,GAAG,CAAC;KAC/C,CAAC,CAAC;CACN,CAAC;AAEF,MAAM,IAAI,GAAqC;IAC7C,KAAK,EAAE,yBAAyB;IAChC,SAAS,EAAE,mBAAmB;IAC9B,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,UAAU,EAAE;QACV,MAAM,EAAE,UAAU;KACnB;CACF,CAAC;AAEF,eAAe,IAAI,CAAC;AAIpB,MAAM,CAAC,MAAM,YAAY,GAAU;IACjC,IAAI,EAAE;QACJ,UAAU,EAAE,KAAK;KAClB;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAU;IAC/B,IAAI,EAAE;QACJ,UAAU,EAAE,IAAI;KACjB;CACF,CAAC","sourcesContent":["import { LocationIcon, RadioButtons } from \"@/.\";\nimport { Location } from \"@grantbii/ui-core/location/enums\";\nimport type { Meta, StoryObj } from \"@storybook/nextjs-vite\";\nimport { useState } from \"react\";\nimport styled from \"styled-components\";\n\ntype LabelProps = {\n location: Location;\n};\n\nconst Label = ({ location }: LabelProps) => (\n <BaseLabel>\n <LocationIcon location={location} width={20} />\n <p>{location}</p>\n </BaseLabel>\n);\n\nconst BaseLabel = styled.div`\n display: flex;\n align-items: center;\n gap: 4px;\n`;\n\ntype ExampleProps = {\n controlled: boolean;\n};\n\nconst RadioButtonsExample = ({ controlled }: ExampleProps) => {\n const [selectedLocation, setSelectedLocation] = useState(\"\");\n\n const controlledProps = {\n options: Object.values(Location)\n .filter((location) => location !== Location.UNKNOWN)\n .map((location) => ({\n value: location,\n label: <Label location={location} />,\n checked: selectedLocation === location,\n onClick: () => setSelectedLocation(location),\n })),\n };\n\n return (\n <RadioButtons {...(controlled ? controlledProps : uncontrolledProps)} />\n );\n};\n\nconst uncontrolledProps = {\n name: \"location\",\n options: Object.values(Location)\n .filter((location) => location !== Location.UNKNOWN)\n .map((location) => ({\n value: location,\n label: <Label location={location} />,\n onChange: () => alert(`Selected ${location}!`),\n })),\n};\n\nconst meta: Meta<typeof RadioButtonsExample> = {\n title: \"Molecules/Radio Buttons\",\n component: RadioButtonsExample,\n tags: [\"autodocs\"],\n parameters: {\n layout: \"centered\",\n },\n};\n\nexport default meta;\n\ntype Story = StoryObj<typeof meta>;\n\nexport const Uncontrolled: Story = {\n args: {\n controlled: false,\n },\n};\n\nexport const Controlled: Story = {\n args: {\n controlled: true,\n },\n};\n"]}
|