@grantbii/design-system 1.0.47 → 1.0.49
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/Checkbox.d.ts +7 -0
- package/core/atoms/Checkbox.js +18 -0
- package/core/atoms/RadioButton.d.ts +1 -1
- package/core/atoms/RadioButton.js +3 -7
- package/core/atoms/index.d.ts +1 -0
- package/core/atoms/index.js +1 -0
- package/core/atoms/shared.d.ts +1 -0
- package/core/atoms/shared.js +5 -0
- package/core/molecules/RadioButtons.js +2 -1
- package/core/organisms/YesNoOptions.d.ts +9 -0
- package/core/organisms/YesNoOptions.js +10 -0
- package/core/organisms/index.d.ts +1 -0
- package/core/organisms/index.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +2 -1
- package/stories/atoms/Checkbox.stories.d.ts +7 -0
- package/stories/atoms/Checkbox.stories.js +23 -0
- package/stories/molecules/RadioButtons.stories.js +15 -16
- package/stories/organisms/YesNoOptions.stories.d.ts +7 -0
- package/stories/organisms/YesNoOptions.stories.js +21 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DetailedHTMLProps, InputHTMLAttributes } from "react";
|
|
2
|
+
type CheckboxProps = {
|
|
3
|
+
label: string;
|
|
4
|
+
labelBefore?: boolean;
|
|
5
|
+
} & DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
6
|
+
declare const Checkbox: ({ id, label, labelBefore, ...checkboxProps }: CheckboxProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export default Checkbox;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { LabelInput } from "./shared";
|
|
14
|
+
const Checkbox = (_a) => {
|
|
15
|
+
var { id, label, labelBefore = false } = _a, checkboxProps = __rest(_a, ["id", "label", "labelBefore"]);
|
|
16
|
+
return (_jsxs(LabelInput, { children: [labelBefore ? _jsx("label", { htmlFor: `${id}-checkbox`, children: label }) : _jsx(_Fragment, {}), _jsx("input", Object.assign({}, checkboxProps, { id: `${id}-checkbox`, type: "checkbox" })), labelBefore ? _jsx(_Fragment, {}) : _jsx("label", { htmlFor: `${id}-checkbox`, children: label })] }));
|
|
17
|
+
};
|
|
18
|
+
export default Checkbox;
|
|
@@ -2,5 +2,5 @@ import { DetailedHTMLProps, InputHTMLAttributes } from "react";
|
|
|
2
2
|
type RadioButtonProps = {
|
|
3
3
|
label: string;
|
|
4
4
|
} & DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
5
|
-
declare const RadioButton: ({
|
|
5
|
+
declare const RadioButton: ({ id, label, ...radioButtonProps }: RadioButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
export default RadioButton;
|
|
@@ -10,13 +10,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import
|
|
13
|
+
import { LabelInput } from "./shared";
|
|
14
14
|
const RadioButton = (_a) => {
|
|
15
|
-
var {
|
|
16
|
-
return (_jsxs(
|
|
15
|
+
var { id, label } = _a, radioButtonProps = __rest(_a, ["id", "label"]);
|
|
16
|
+
return (_jsxs(LabelInput, { children: [_jsx("input", Object.assign({}, radioButtonProps, { id: `${id}-radio-button`, type: "radio" })), _jsx("label", { htmlFor: `${id}-radio-button`, children: label })] }));
|
|
17
17
|
};
|
|
18
18
|
export default RadioButton;
|
|
19
|
-
const BaseRadioButton = styled.div `
|
|
20
|
-
display: flex;
|
|
21
|
-
gap: 8px;
|
|
22
|
-
`;
|
package/core/atoms/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as Badge } from "./Badge";
|
|
2
2
|
export { default as BrandLogo } from "./BrandLogo";
|
|
3
3
|
export { default as Button } from "./Button";
|
|
4
|
+
export { default as Checkbox } from "./Checkbox";
|
|
4
5
|
export { default as LinkButton } from "./LinkButton";
|
|
5
6
|
export { default as RadioButton } from "./RadioButton";
|
|
6
7
|
export { default as Textarea } from "./Textarea";
|
package/core/atoms/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { default as Badge } from "./Badge";
|
|
2
2
|
export { default as BrandLogo } from "./BrandLogo";
|
|
3
3
|
export { default as Button } from "./Button";
|
|
4
|
+
export { default as Checkbox } from "./Checkbox";
|
|
4
5
|
export { default as LinkButton } from "./LinkButton";
|
|
5
6
|
export { default as RadioButton } from "./RadioButton";
|
|
6
7
|
export { default as Textarea } from "./Textarea";
|
package/core/atoms/shared.d.ts
CHANGED
|
@@ -3,3 +3,4 @@ export declare const BaseButton: import("styled-components/dist/types").IStyledC
|
|
|
3
3
|
$backgroundColor?: string;
|
|
4
4
|
$color?: string;
|
|
5
5
|
}>> & string;
|
|
6
|
+
export declare const LabelInput: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
package/core/atoms/shared.js
CHANGED
|
@@ -17,3 +17,8 @@ export const BaseButton = styled.div `
|
|
|
17
17
|
color: ${({ $color = Colors.typography.whiteHigh }) => $color};
|
|
18
18
|
background-color: ${({ $underline = false, $backgroundColor = Colors.main.grantbiiBlue, }) => ($underline ? "transparent" : $backgroundColor)};
|
|
19
19
|
`;
|
|
20
|
+
export const LabelInput = styled.div `
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
gap: 8px;
|
|
24
|
+
`;
|
|
@@ -16,11 +16,12 @@ import { RadioButton } from "../atoms";
|
|
|
16
16
|
const RadioButtons = ({ name, options }) => {
|
|
17
17
|
return (_jsx(RadioGroup, { children: options.map((_a) => {
|
|
18
18
|
var { value } = _a, props = __rest(_a, ["value"]);
|
|
19
|
-
return (_createElement(RadioButton, Object.assign({}, props, { key: `${value}
|
|
19
|
+
return (_createElement(RadioButton, Object.assign({}, props, { key: `${name}-${value}`, id: `${name}-${value}`, value: value, name: name })));
|
|
20
20
|
}) }));
|
|
21
21
|
};
|
|
22
22
|
export default RadioButtons;
|
|
23
23
|
const RadioGroup = styled.div `
|
|
24
24
|
display: flex;
|
|
25
|
+
align-items: center;
|
|
25
26
|
gap: 12px;
|
|
26
27
|
`;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DetailedHTMLProps, InputHTMLAttributes } from "react";
|
|
2
|
+
type YesNoOptionsProps = {
|
|
3
|
+
name: string;
|
|
4
|
+
yesProps: DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
5
|
+
noProps: DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
6
|
+
unsureProps?: DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
7
|
+
};
|
|
8
|
+
declare const YesNoOptions: ({ name, yesProps, noProps, unsureProps, }: YesNoOptionsProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export default YesNoOptions;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import { RadioButton } from "../atoms";
|
|
4
|
+
import { LogicOption } from "@grantbii/ui-base/enums";
|
|
5
|
+
const YesNoOptions = ({ name, yesProps, noProps, unsureProps, }) => (_jsxs(RadioGroup, { children: [_jsx(RadioButton, Object.assign({}, yesProps, { id: `${name}-yes`, label: LogicOption.YES, value: LogicOption.YES, name: name })), _jsx(RadioButton, Object.assign({}, noProps, { id: `${name}-no`, label: LogicOption.NO, value: LogicOption.NO, name: name })), unsureProps ? (_jsx(RadioButton, Object.assign({}, unsureProps, { id: `${name}-unsure`, label: LogicOption.UNSURE, value: LogicOption.UNSURE, name: name }))) : (_jsx(_Fragment, {}))] }));
|
|
6
|
+
export default YesNoOptions;
|
|
7
|
+
const RadioGroup = styled.div `
|
|
8
|
+
display: flex;
|
|
9
|
+
gap: 12px;
|
|
10
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as YesNoOptions } from "./YesNoOptions";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as YesNoOptions } from "./YesNoOptions";
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grantbii/design-system",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.49",
|
|
4
4
|
"description": "Grantbii's Design System",
|
|
5
5
|
"homepage": "https://design.grantbii.com",
|
|
6
6
|
"repository": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"build-storybook": "storybook build"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
+
"@grantbii/ui-base": "1.0.13",
|
|
21
22
|
"@phosphor-icons/react": "^2.1.10",
|
|
22
23
|
"country-flag-icons": "^1.5.19",
|
|
23
24
|
"next": "^15.3.5",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Checkbox } from "@/.";
|
|
2
|
+
import { Meta, StoryObj } from "@storybook/nextjs-vite";
|
|
3
|
+
declare const meta: Meta<typeof Checkbox>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const LabelBefore: Story;
|
|
7
|
+
export declare const LabelAfter: Story;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Checkbox } from "@/.";
|
|
2
|
+
const meta = {
|
|
3
|
+
title: "Atoms/Checkbox",
|
|
4
|
+
component: Checkbox,
|
|
5
|
+
tags: ["autodocs"],
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: "centered",
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
const label = "Grantbii is the best";
|
|
12
|
+
export const LabelBefore = {
|
|
13
|
+
args: {
|
|
14
|
+
label,
|
|
15
|
+
labelBefore: true,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
export const LabelAfter = {
|
|
19
|
+
args: {
|
|
20
|
+
label,
|
|
21
|
+
labelBefore: false,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { RadioButtons } from "@/.";
|
|
3
|
+
import { Location } from "@grantbii/ui-base/enums";
|
|
3
4
|
import { useState } from "react";
|
|
4
|
-
const SINGAPORE = "Singapore";
|
|
5
|
-
const HONG_KONG = "Hong Kong";
|
|
6
5
|
const RadioButtonsExample = ({ controlled }) => {
|
|
7
6
|
const [location, setLocation] = useState("");
|
|
8
7
|
const controlledProps = {
|
|
9
8
|
options: [
|
|
10
9
|
{
|
|
11
|
-
label: SINGAPORE,
|
|
12
|
-
value: SINGAPORE,
|
|
13
|
-
checked: location === SINGAPORE,
|
|
14
|
-
onClick: () => setLocation(SINGAPORE),
|
|
10
|
+
label: Location.SINGAPORE,
|
|
11
|
+
value: Location.SINGAPORE,
|
|
12
|
+
checked: location === Location.SINGAPORE,
|
|
13
|
+
onClick: () => setLocation(Location.SINGAPORE),
|
|
15
14
|
},
|
|
16
15
|
{
|
|
17
|
-
label: HONG_KONG,
|
|
18
|
-
value: HONG_KONG,
|
|
19
|
-
checked: location === HONG_KONG,
|
|
20
|
-
onClick: () => setLocation(HONG_KONG),
|
|
16
|
+
label: Location.HONG_KONG,
|
|
17
|
+
value: Location.HONG_KONG,
|
|
18
|
+
checked: location === Location.HONG_KONG,
|
|
19
|
+
onClick: () => setLocation(Location.HONG_KONG),
|
|
21
20
|
},
|
|
22
21
|
],
|
|
23
22
|
};
|
|
@@ -27,14 +26,14 @@ const uncontrolledProps = {
|
|
|
27
26
|
name: "location",
|
|
28
27
|
options: [
|
|
29
28
|
{
|
|
30
|
-
label: SINGAPORE,
|
|
31
|
-
value: SINGAPORE,
|
|
32
|
-
onChange: () => alert(`Selected ${SINGAPORE}!`),
|
|
29
|
+
label: Location.SINGAPORE,
|
|
30
|
+
value: Location.SINGAPORE,
|
|
31
|
+
onChange: () => alert(`Selected ${Location.SINGAPORE}!`),
|
|
33
32
|
},
|
|
34
33
|
{
|
|
35
|
-
label: HONG_KONG,
|
|
36
|
-
value: HONG_KONG,
|
|
37
|
-
onChange: () => alert(`Selected ${HONG_KONG}!`),
|
|
34
|
+
label: Location.HONG_KONG,
|
|
35
|
+
value: Location.HONG_KONG,
|
|
36
|
+
onChange: () => alert(`Selected ${Location.HONG_KONG}!`),
|
|
38
37
|
},
|
|
39
38
|
],
|
|
40
39
|
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { YesNoOptions } from "@/.";
|
|
2
|
+
import { Meta, StoryObj } from "@storybook/nextjs-vite";
|
|
3
|
+
declare const meta: Meta<typeof YesNoOptions>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const YesOrNo: Story;
|
|
7
|
+
export declare const YesOrNoOrUnsure: Story;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { YesNoOptions } from "@/.";
|
|
2
|
+
const meta = {
|
|
3
|
+
title: "Organisms/Yes-No Options",
|
|
4
|
+
component: YesNoOptions,
|
|
5
|
+
tags: ["autodocs"],
|
|
6
|
+
parameters: {
|
|
7
|
+
layout: "centered",
|
|
8
|
+
},
|
|
9
|
+
};
|
|
10
|
+
export default meta;
|
|
11
|
+
const baseArgs = {
|
|
12
|
+
name: "question",
|
|
13
|
+
yesProps: {},
|
|
14
|
+
noProps: {},
|
|
15
|
+
};
|
|
16
|
+
export const YesOrNo = {
|
|
17
|
+
args: baseArgs,
|
|
18
|
+
};
|
|
19
|
+
export const YesOrNoOrUnsure = {
|
|
20
|
+
args: Object.assign(Object.assign({}, baseArgs), { unsureProps: {} }),
|
|
21
|
+
};
|