@grantbii/design-system 1.0.41 → 1.0.43

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.
@@ -1,7 +1,9 @@
1
1
  import { DetailedHTMLProps, InputHTMLAttributes } from "react";
2
2
  import { Option } from "../foundations";
3
+ export type RadioOption = Option & DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
3
4
  type RadioButtonProps = {
4
- options: Option[];
5
- } & DetailedHTMLProps<InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
6
- declare const RadioButtons: ({ options, name, ...radioButtonProps }: RadioButtonProps) => import("react/jsx-runtime").JSX.Element;
5
+ name: string;
6
+ options: RadioOption[];
7
+ };
8
+ declare const RadioButtons: ({ name, options }: RadioButtonProps) => import("react/jsx-runtime").JSX.Element;
7
9
  export default RadioButtons;
@@ -13,9 +13,11 @@ import { jsx as _jsx } from "react/jsx-runtime";
13
13
  import { createElement as _createElement } from "react";
14
14
  import styled from "styled-components";
15
15
  import { RadioButton } from "../atoms";
16
- const RadioButtons = (_a) => {
17
- var { options, name } = _a, radioButtonProps = __rest(_a, ["options", "name"]);
18
- return (_jsx(RadioGroup, { children: options.map(({ label, value }) => (_createElement(RadioButton, Object.assign({}, radioButtonProps, { key: `${name}-radio-button`, id: `${name}-radio-button`, name: name, label: label, value: value })))) }));
16
+ const RadioButtons = ({ name, options }) => {
17
+ return (_jsx(RadioGroup, { children: options.map((_a) => {
18
+ var { value } = _a, props = __rest(_a, ["value"]);
19
+ return (_createElement(RadioButton, Object.assign({}, props, { key: `${value}-radio-button`, id: `${value}-radio-button`, value: value, name: name })));
20
+ }) }));
19
21
  };
20
22
  export default RadioButtons;
21
23
  const RadioGroup = styled.div `
@@ -1,2 +1,2 @@
1
1
  export { default as Modal, useModal } from "./Modal";
2
- export { default as RadioButtons } from "./RadioButtons";
2
+ export { default as RadioButtons, type RadioOption } from "./RadioButtons";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grantbii/design-system",
3
- "version": "1.0.41",
3
+ "version": "1.0.43",
4
4
  "description": "Grantbii's Design System",
5
5
  "homepage": "https://design.grantbii.com",
6
6
  "repository": {
@@ -3,4 +3,5 @@ import { Meta, StoryObj } from "@storybook/nextjs-vite";
3
3
  declare const meta: Meta<typeof RadioButtons>;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof meta>;
6
- export declare const TextOnly: Story;
6
+ export declare const NoneSelectedByDefault: Story;
7
+ export declare const OneSelectedByDefault: Story;
@@ -8,12 +8,38 @@ const meta = {
8
8
  },
9
9
  };
10
10
  export default meta;
11
- export const TextOnly = {
11
+ export const NoneSelectedByDefault = {
12
12
  args: {
13
13
  name: "location ",
14
14
  options: [
15
- { label: "Singapore", value: "Singapore" },
16
- { label: "Hong Kong", value: "Hong Kong" },
15
+ {
16
+ label: "Singapore",
17
+ value: "Singapore",
18
+ onChange: () => alert("Selected Singapore!"),
19
+ },
20
+ {
21
+ label: "Hong Kong",
22
+ value: "Hong Kong",
23
+ onChange: () => alert("Selected Hong Kong!"),
24
+ },
25
+ ],
26
+ },
27
+ };
28
+ export const OneSelectedByDefault = {
29
+ args: {
30
+ name: "location ",
31
+ options: [
32
+ {
33
+ label: "Singapore",
34
+ value: "Singapore",
35
+ onChange: () => alert("Selected Singapore!"),
36
+ defaultChecked: true,
37
+ },
38
+ {
39
+ label: "Hong Kong",
40
+ value: "Hong Kong",
41
+ onChange: () => alert("Selected Hong Kong!"),
42
+ },
17
43
  ],
18
44
  },
19
45
  };