@anker-in/headless-ui 0.0.11 → 0.0.13
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/CONTRIBUTING.md +20 -1
- package/README.md +1 -1
- package/dist/cjs/components/checkbox.d.ts +8 -1
- package/dist/cjs/components/checkbox.js +1 -1
- package/dist/cjs/components/checkbox.js.map +3 -3
- package/dist/cjs/components/dialog.js +1 -1
- package/dist/cjs/components/dialog.js.map +2 -2
- package/dist/cjs/components/heading.d.ts +10 -2
- package/dist/cjs/components/heading.js +1 -1
- package/dist/cjs/components/heading.js.map +3 -3
- package/dist/cjs/components/index.d.ts +1 -0
- package/dist/cjs/components/index.js +1 -1
- package/dist/cjs/components/index.js.map +2 -2
- package/dist/cjs/components/input.d.ts +1 -1
- package/dist/cjs/components/input.js.map +1 -1
- package/dist/cjs/components/radio.d.ts +13 -2
- package/dist/cjs/components/radio.js +1 -1
- package/dist/cjs/components/radio.js.map +3 -3
- package/dist/cjs/components/skeleton.d.ts +6 -3
- package/dist/cjs/components/skeleton.js +4 -1
- package/dist/cjs/components/skeleton.js.map +3 -3
- package/dist/cjs/components/text.d.ts +17 -3
- package/dist/cjs/components/text.js +1 -1
- package/dist/cjs/components/text.js.map +3 -3
- package/dist/cjs/stories/checkbox.stories.d.ts +44 -3
- package/dist/cjs/stories/checkbox.stories.js +1 -1
- package/dist/cjs/stories/checkbox.stories.js.map +3 -3
- package/dist/cjs/stories/dialog.stories.d.ts +18 -3
- package/dist/cjs/stories/dialog.stories.js +1 -1
- package/dist/cjs/stories/dialog.stories.js.map +3 -3
- package/dist/cjs/stories/heading.stories.d.ts +70 -0
- package/dist/cjs/stories/heading.stories.js +2 -0
- package/dist/cjs/stories/heading.stories.js.map +7 -0
- package/dist/cjs/stories/input.stories.d.ts +5 -0
- package/dist/cjs/stories/input.stories.js +1 -1
- package/dist/cjs/stories/input.stories.js.map +2 -2
- package/dist/cjs/stories/radio.stories.d.ts +37 -3
- package/dist/cjs/stories/radio.stories.js +1 -1
- package/dist/cjs/stories/radio.stories.js.map +3 -3
- package/dist/cjs/stories/skeleton.stories.d.ts +9 -3
- package/dist/cjs/stories/skeleton.stories.js +1 -1
- package/dist/cjs/stories/skeleton.stories.js.map +3 -3
- package/dist/cjs/stories/text.stories.d.ts +38 -3
- package/dist/cjs/stories/text.stories.js +9 -1
- package/dist/cjs/stories/text.stories.js.map +3 -3
- package/dist/esm/components/checkbox.d.ts +8 -1
- package/dist/esm/components/checkbox.js +1 -1
- package/dist/esm/components/checkbox.js.map +3 -3
- package/dist/esm/components/dialog.js +1 -1
- package/dist/esm/components/dialog.js.map +2 -2
- package/dist/esm/components/heading.d.ts +10 -2
- package/dist/esm/components/heading.js +1 -1
- package/dist/esm/components/heading.js.map +3 -3
- package/dist/esm/components/index.d.ts +1 -0
- package/dist/esm/components/index.js +1 -1
- package/dist/esm/components/index.js.map +2 -2
- package/dist/esm/components/input.d.ts +1 -1
- package/dist/esm/components/input.js.map +1 -1
- package/dist/esm/components/radio.d.ts +13 -2
- package/dist/esm/components/radio.js +1 -1
- package/dist/esm/components/radio.js.map +3 -3
- package/dist/esm/components/skeleton.d.ts +6 -3
- package/dist/esm/components/skeleton.js +4 -1
- package/dist/esm/components/skeleton.js.map +3 -3
- package/dist/esm/components/text.d.ts +17 -3
- package/dist/esm/components/text.js +1 -1
- package/dist/esm/components/text.js.map +3 -3
- package/dist/esm/stories/checkbox.stories.d.ts +44 -3
- package/dist/esm/stories/checkbox.stories.js +1 -1
- package/dist/esm/stories/checkbox.stories.js.map +3 -3
- package/dist/esm/stories/dialog.stories.d.ts +18 -3
- package/dist/esm/stories/dialog.stories.js +1 -1
- package/dist/esm/stories/dialog.stories.js.map +3 -3
- package/dist/esm/stories/heading.stories.d.ts +70 -0
- package/dist/esm/stories/heading.stories.js +2 -0
- package/dist/esm/stories/heading.stories.js.map +7 -0
- package/dist/esm/stories/input.stories.d.ts +5 -0
- package/dist/esm/stories/input.stories.js +1 -1
- package/dist/esm/stories/input.stories.js.map +2 -2
- package/dist/esm/stories/radio.stories.d.ts +37 -3
- package/dist/esm/stories/radio.stories.js +1 -1
- package/dist/esm/stories/radio.stories.js.map +3 -3
- package/dist/esm/stories/skeleton.stories.d.ts +9 -3
- package/dist/esm/stories/skeleton.stories.js +1 -1
- package/dist/esm/stories/skeleton.stories.js.map +3 -3
- package/dist/esm/stories/text.stories.d.ts +38 -3
- package/dist/esm/stories/text.stories.js +9 -1
- package/dist/esm/stories/text.stories.js.map +3 -3
- package/package.json +1 -1
- package/src/components/checkbox.tsx +34 -18
- package/src/components/dialog.tsx +1 -0
- package/src/components/heading.tsx +61 -5
- package/src/components/index.ts +1 -0
- package/src/components/input.tsx +1 -1
- package/src/components/radio.tsx +63 -28
- package/src/components/skeleton.tsx +33 -2
- package/src/components/text.tsx +25 -7
- package/src/stories/checkbox.stories.tsx +80 -3
- package/src/stories/dialog.stories.tsx +60 -31
- package/src/stories/heading.stories.tsx +90 -0
- package/src/stories/input.stories.tsx +5 -0
- package/src/stories/radio.stories.tsx +52 -16
- package/src/stories/skeleton.stories.tsx +36 -2
- package/src/stories/text.stories.tsx +74 -13
- package/src/styles/global.css +5 -5
- package/style.css +70 -19
- package/dist/cjs/tsconfig.tsbuildinfo +0 -1
- package/dist/esm/tsconfig.tsbuildinfo +0 -1
|
@@ -1,5 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
import type { StoryObj } from '@storybook/react/*';
|
|
2
|
+
import { RadioGroup } from '../components/index';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
declare const meta: {
|
|
2
5
|
title: string;
|
|
6
|
+
component: React.ForwardRefExoticComponent<import("../components/radio").RadioGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
subcomponents: {
|
|
8
|
+
RadioGroupItem: React.ComponentType<unknown>;
|
|
9
|
+
};
|
|
10
|
+
parameters: {
|
|
11
|
+
layout: string;
|
|
12
|
+
docs: {
|
|
13
|
+
description: {
|
|
14
|
+
component: string;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
tags: string[];
|
|
19
|
+
argTypes: {
|
|
20
|
+
size: {
|
|
21
|
+
control: {
|
|
22
|
+
type: "select";
|
|
23
|
+
};
|
|
24
|
+
options: string[];
|
|
25
|
+
description: string;
|
|
26
|
+
table: {
|
|
27
|
+
defaultValue: {
|
|
28
|
+
summary: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
args: {
|
|
34
|
+
size: "base";
|
|
35
|
+
};
|
|
3
36
|
};
|
|
4
|
-
export default
|
|
5
|
-
|
|
37
|
+
export default meta;
|
|
38
|
+
type Story = StoryObj<typeof RadioGroup>;
|
|
39
|
+
export declare const Default: Story;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as o,jsxs as
|
|
1
|
+
import{Fragment as p,jsx as o,jsxs as t}from"react/jsx-runtime";import{RadioGroup as a,RadioGroupItem as e}from"../components/index";import"react";const i={title:"Components/RadioGroup",component:a,subcomponents:{RadioGroupItem:e},parameters:{layout:"centered",docs:{description:{component:"\u5355\u9009\u6846, \u57FA\u4E8E@radix-ui/react-radio-group https://www.radix-ui.com/primitives/docs/components/radio-group"}}},tags:["autodocs"],argTypes:{size:{control:{type:"select"},options:["sm","base","lg"],description:"\u5C3A\u5BF8",table:{defaultValue:{summary:"base"}}}},args:{size:"base"}};var l=i;const m={args:{size:"base",children:t(p,{children:[t("div",{className:"ai-flex ai-items-center ai-space-x-2",children:[o(e,{value:"option-one",id:"option-one"}),o("label",{htmlFor:"option-one",children:"Option One"})]}),t("div",{className:"ai-flex ai-items-center ai-space-x-2",children:[o(e,{value:"option-two",id:"option-two"}),o("label",{htmlFor:"option-two",children:"Option Two"})]})]})}};export{m as Default,l as default};
|
|
2
2
|
//# sourceMappingURL=radio.stories.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/stories/radio.stories.tsx"],
|
|
4
|
-
"sourcesContent": ["import { RadioGroup, RadioGroupItem } from '../components/index'\nimport React from 'react'\n\
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jsx", "jsxs", "RadioGroup", "RadioGroupItem", "radio_stories_default", "Default"]
|
|
4
|
+
"sourcesContent": ["import type { Meta, StoryObj } from '@storybook/react/*'\nimport { RadioGroup, RadioGroupItem } from '../components/index'\nimport React, { type ComponentType } from 'react'\n\nconst meta = {\n title: 'Components/RadioGroup',\n component: RadioGroup,\n subcomponents: { RadioGroupItem: RadioGroupItem as ComponentType<unknown> },\n parameters: {\n layout: 'centered',\n docs: {\n description: {\n component:\n '\u5355\u9009\u6846, \u57FA\u4E8E@radix-ui/react-radio-group https://www.radix-ui.com/primitives/docs/components/radio-group',\n },\n },\n },\n tags: ['autodocs'],\n argTypes: {\n size: {\n control: {\n type: 'select',\n },\n options: ['sm', 'base', 'lg'],\n description: '\u5C3A\u5BF8',\n table: {\n defaultValue: { summary: 'base' },\n },\n },\n },\n args: {\n size: 'base',\n },\n} satisfies Meta<typeof RadioGroup>\n\nexport default meta\n\ntype Story = StoryObj<typeof RadioGroup>\nexport const Default: Story = {\n args: {\n size: 'base',\n children: (\n <>\n <div className=\"ai-flex ai-items-center ai-space-x-2\">\n <RadioGroupItem value=\"option-one\" id=\"option-one\" />\n <label htmlFor=\"option-one\">Option One</label>\n </div>\n <div className=\"ai-flex ai-items-center ai-space-x-2\">\n <RadioGroupItem value=\"option-two\" id=\"option-two\" />\n <label htmlFor=\"option-two\">Option Two</label>\n </div>\n </>\n ),\n },\n}\n"],
|
|
5
|
+
"mappings": "AA0CM,mBAAAA,EAEI,OAAAC,EADF,QAAAC,MADF,oBAzCN,OAAS,cAAAC,EAAY,kBAAAC,MAAsB,sBAC3C,MAA0C,QAE1C,MAAMC,EAAO,CACX,MAAO,wBACP,UAAWF,EACX,cAAe,CAAE,eAAgBC,CAAyC,EAC1E,WAAY,CACV,OAAQ,WACR,KAAM,CACJ,YAAa,CACX,UACE,6HACJ,CACF,CACF,EACA,KAAM,CAAC,UAAU,EACjB,SAAU,CACR,KAAM,CACJ,QAAS,CACP,KAAM,QACR,EACA,QAAS,CAAC,KAAM,OAAQ,IAAI,EAC5B,YAAa,eACb,MAAO,CACL,aAAc,CAAE,QAAS,MAAO,CAClC,CACF,CACF,EACA,KAAM,CACJ,KAAM,MACR,CACF,EAEA,IAAOE,EAAQD,EAGR,MAAME,EAAiB,CAC5B,KAAM,CACJ,KAAM,OACN,SACEL,EAAAF,EAAA,CACE,UAAAE,EAAC,OAAI,UAAU,uCACb,UAAAD,EAACG,EAAA,CAAe,MAAM,aAAa,GAAG,aAAa,EACnDH,EAAC,SAAM,QAAQ,aAAa,sBAAU,GACxC,EACAC,EAAC,OAAI,UAAU,uCACb,UAAAD,EAACG,EAAA,CAAe,MAAM,aAAa,GAAG,aAAa,EACnDH,EAAC,SAAM,QAAQ,aAAa,sBAAU,GACxC,GACF,CAEJ,CACF",
|
|
6
|
+
"names": ["Fragment", "jsx", "jsxs", "RadioGroup", "RadioGroupItem", "meta", "radio_stories_default", "Default"]
|
|
7
7
|
}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
import type { StoryObj } from '@storybook/react';
|
|
2
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component:
|
|
5
|
+
component: React.ForwardRefExoticComponent<import("../components/skeleton").SkeletonProps & React.RefAttributes<HTMLSpanElement>>;
|
|
6
6
|
parameters: {
|
|
7
7
|
layout: string;
|
|
8
|
+
docs: {
|
|
9
|
+
description: {
|
|
10
|
+
component: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
8
13
|
};
|
|
9
14
|
tags: string[];
|
|
10
15
|
};
|
|
11
16
|
export default meta;
|
|
12
17
|
type Story = StoryObj<typeof meta>;
|
|
13
18
|
export declare const Default: Story;
|
|
14
|
-
export declare const
|
|
19
|
+
export declare const Multiple: Story;
|
|
20
|
+
export declare const WithText: Story;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{Fragment as i,jsx as e,jsxs as o}from"react/jsx-runtime";import{Skeleton as a}from"../components/index";import"react";const t={title:"Components/Skeleton",component:a,parameters:{layout:"centered",docs:{description:{component:"\u9AA8\u67B6\u5C4F\u7EC4\u4EF6,\u7528\u6765\u5728\u6570\u636E\u52A0\u8F7D\u65F6\u5C55\u793A\u4E00\u4E2A\u5360\u4F4D\u56FE, \u53EF\u4EE5\u5305\u5728dom \u5916\u4F7F\u7528\uFF0C\u901A\u8FC7loading \u63A7\u5236\u663E\u793A\u9690\u85CF, \u4E5F\u53EF\u4EE5\u5355\u72EC\u4F7F\u7528\uFF0C\u901A\u8FC7\u81EA\u5B9A\u4E49class\u63A7\u5236\u6837\u5F0F, \u7EC4\u5408\u6210\u60F3\u8981\u7684\u5F62\u72B6"}}},tags:["autodocs"]};var n=t;const c={args:{loading:!0,children:e("div",{className:"ai-h-14 ai-rounded-3xl ai-overflow-hidden ai-px-4 ai-py-4 w-full",children:"Fog creeps across moors, hills, and rivers. It adds an eerie charm to the landscape, but also complicates driving."})}},d={render(){return o("div",{className:"ai-flex ai-flex-col ai-items-center ai-justify-center",children:[o("div",{className:"ai-flex ai-w-full ai-justify-between",children:[e(a,{className:"ai-size-12 ai-rounded-full"}),e(a,{className:"ai-h-12 ai-w-[70%] "})]}),e(a,{className:"ai-mt-2 ai-h-40 ai-w-[200px]"})]})}},p={render(){return o(i,{children:[e(a,{loading:!0,children:"Rainfall is a constant companion. Umbrellas are practically a national accessory. Expect drizzles, showers, and downpours, often accompanied by gray skies."}),e("hr",{}),e(a,{loading:!1,children:"Rainfall is a constant companion. Umbrellas are practically a national accessory. Expect drizzles, showers, and downpours, often accompanied by gray skies."})]})}};export{c as Default,d as Multiple,p as WithText,n as default};
|
|
2
2
|
//# sourceMappingURL=skeleton.stories.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/stories/skeleton.stories.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { Meta, StoryObj } from '@storybook/react'\n\nimport { Skeleton } from '../components/index'\nimport React from 'react'\n\nconst meta = {\n title: 'Components/Skeleton',\n component: Skeleton,\n parameters: {\n layout: 'centered',\n },\n tags: ['autodocs'],\n} satisfies Meta<typeof Skeleton>\n\nexport default meta\n\ntype Story = StoryObj<typeof meta>\n\nexport const Default: Story = {}\n\nexport const
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["jsx", "jsxs", "Skeleton", "meta", "skeleton_stories_default", "Default", "
|
|
4
|
+
"sourcesContent": ["import type { Meta, StoryObj } from '@storybook/react'\n\nimport { Skeleton } from '../components/index'\nimport React from 'react'\n\nconst meta = {\n title: 'Components/Skeleton',\n component: Skeleton,\n parameters: {\n layout: 'centered',\n docs: {\n description: {\n component:\n '\u9AA8\u67B6\u5C4F\u7EC4\u4EF6,\u7528\u6765\u5728\u6570\u636E\u52A0\u8F7D\u65F6\u5C55\u793A\u4E00\u4E2A\u5360\u4F4D\u56FE, \u53EF\u4EE5\u5305\u5728dom \u5916\u4F7F\u7528\uFF0C\u901A\u8FC7loading \u63A7\u5236\u663E\u793A\u9690\u85CF, \u4E5F\u53EF\u4EE5\u5355\u72EC\u4F7F\u7528\uFF0C\u901A\u8FC7\u81EA\u5B9A\u4E49class\u63A7\u5236\u6837\u5F0F, \u7EC4\u5408\u6210\u60F3\u8981\u7684\u5F62\u72B6',\n },\n },\n },\n tags: ['autodocs'],\n} satisfies Meta<typeof Skeleton>\n\nexport default meta\n\ntype Story = StoryObj<typeof meta>\n\nexport const Default: Story = {\n args: {\n loading: true,\n children: (\n <div className=\"ai-h-14 ai-rounded-3xl ai-overflow-hidden ai-px-4 ai-py-4 w-full\">\n Fog creeps across moors, hills, and rivers. It adds an eerie charm to the landscape, but also complicates\n driving.\n </div>\n ),\n },\n}\n\nexport const Multiple: Story = {\n render() {\n return (\n <div className=\"ai-flex ai-flex-col ai-items-center ai-justify-center\">\n <div className=\"ai-flex ai-w-full ai-justify-between\">\n <Skeleton className=\"ai-size-12 ai-rounded-full\" />\n <Skeleton className=\"ai-h-12 ai-w-[70%] \" />\n </div>\n <Skeleton className=\"ai-mt-2 ai-h-40 ai-w-[200px]\" />\n </div>\n )\n },\n}\n\nexport const WithText: Story = {\n render() {\n return (\n <>\n <Skeleton loading={true}>\n Rainfall is a constant companion. Umbrellas are practically a national accessory. Expect drizzles, showers,\n and downpours, often accompanied by gray skies.\n </Skeleton>\n <hr />\n <Skeleton loading={false}>\n Rainfall is a constant companion. Umbrellas are practically a national accessory. Expect drizzles, showers,\n and downpours, often accompanied by gray skies.\n </Skeleton>\n </>\n )\n },\n}\n"],
|
|
5
|
+
"mappings": "AA4BM,OAyBA,YAAAA,EAzBA,OAAAC,EAYE,QAAAC,MAZF,oBA1BN,OAAS,YAAAC,MAAgB,sBACzB,MAAkB,QAElB,MAAMC,EAAO,CACX,MAAO,sBACP,UAAWD,EACX,WAAY,CACV,OAAQ,WACR,KAAM,CACJ,YAAa,CACX,UACE,wYACJ,CACF,CACF,EACA,KAAM,CAAC,UAAU,CACnB,EAEA,IAAOE,EAAQD,EAIR,MAAME,EAAiB,CAC5B,KAAM,CACJ,QAAS,GACT,SACEL,EAAC,OAAI,UAAU,mEAAmE,8HAGlF,CAEJ,CACF,EAEaM,EAAkB,CAC7B,QAAS,CACP,OACEL,EAAC,OAAI,UAAU,wDACb,UAAAA,EAAC,OAAI,UAAU,uCACb,UAAAD,EAACE,EAAA,CAAS,UAAU,6BAA6B,EACjDF,EAACE,EAAA,CAAS,UAAU,sBAAsB,GAC5C,EACAF,EAACE,EAAA,CAAS,UAAU,+BAA+B,GACrD,CAEJ,CACF,EAEaK,EAAkB,CAC7B,QAAS,CACP,OACEN,EAAAF,EAAA,CACE,UAAAC,EAACE,EAAA,CAAS,QAAS,GAAM,uKAGzB,EACAF,EAAC,OAAG,EACJA,EAACE,EAAA,CAAS,QAAS,GAAO,uKAG1B,GACF,CAEJ,CACF",
|
|
6
|
+
"names": ["Fragment", "jsx", "jsxs", "Skeleton", "meta", "skeleton_stories_default", "Default", "Multiple", "WithText"]
|
|
7
7
|
}
|
|
@@ -5,6 +5,11 @@ declare const meta: {
|
|
|
5
5
|
component: React.ForwardRefExoticComponent<import("../components/text").TextProps & React.RefAttributes<HTMLSpanElement>>;
|
|
6
6
|
parameters: {
|
|
7
7
|
layout: string;
|
|
8
|
+
docs: {
|
|
9
|
+
description: {
|
|
10
|
+
component: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
8
13
|
};
|
|
9
14
|
tags: string[];
|
|
10
15
|
argTypes: {
|
|
@@ -12,13 +17,41 @@ declare const meta: {
|
|
|
12
17
|
control: {
|
|
13
18
|
type: "select";
|
|
14
19
|
};
|
|
15
|
-
|
|
20
|
+
description: string;
|
|
21
|
+
options: (string | number)[];
|
|
22
|
+
table: {
|
|
23
|
+
defaultValue: {
|
|
24
|
+
summary: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
16
27
|
};
|
|
17
28
|
weights: {
|
|
18
29
|
control: {
|
|
19
30
|
type: "select";
|
|
20
31
|
};
|
|
21
32
|
options: string[];
|
|
33
|
+
table: {
|
|
34
|
+
defaultValue: {
|
|
35
|
+
summary: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
color: {
|
|
40
|
+
control: {
|
|
41
|
+
type: "color";
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
as: {
|
|
45
|
+
control: {
|
|
46
|
+
type: "select";
|
|
47
|
+
};
|
|
48
|
+
description: string;
|
|
49
|
+
options: string[];
|
|
50
|
+
table: {
|
|
51
|
+
defaultValue: {
|
|
52
|
+
summary: string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
22
55
|
};
|
|
23
56
|
html: {
|
|
24
57
|
type: "string";
|
|
@@ -26,7 +59,7 @@ declare const meta: {
|
|
|
26
59
|
};
|
|
27
60
|
};
|
|
28
61
|
args: {
|
|
29
|
-
size:
|
|
62
|
+
size: "none";
|
|
30
63
|
weights: "normal";
|
|
31
64
|
html: string;
|
|
32
65
|
};
|
|
@@ -34,4 +67,6 @@ declare const meta: {
|
|
|
34
67
|
export default meta;
|
|
35
68
|
type Story = StoryObj<typeof meta>;
|
|
36
69
|
export declare const Default: Story;
|
|
37
|
-
export declare const
|
|
70
|
+
export declare const Sizes: Story;
|
|
71
|
+
export declare const Weights: Story;
|
|
72
|
+
export declare const Html: Story;
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jsx as o,jsxs as t}from"react/jsx-runtime";import{Text as e}from"../components/index";import"react";const r={title:"Typography/Text",component:e,parameters:{layout:"centered",docs:{description:{component:"\u6587\u672C\u7EC4\u4EF6, \u7B80\u5355\u5C01\u88C5\u4E86\u5E38\u7528\u7684\u6837\u5F0F\u5B57\u6BB5\uFF0C\u7528\u4E8E\u5C55\u793A\u6587\u672C\u5185\u5BB9."}}},tags:["autodocs"],argTypes:{size:{control:{type:"select"},description:"\u6587\u672C\u5C3A\u5BF8\uFF0C\u9ED8\u8BA4\u4E3Anone\uFF0C\u6D4F\u89C8\u5668\u9ED8\u8BA4\u5927\u5C0F\u548C\u884C\u9AD8\uFF0C1\uFF5E9\u9884\u8BBE\u5B57\u4F53\u5927\u5C0F\u548C\u884C\u9AD8",options:["none",1,2,3,4,5,6,7,8,9],table:{defaultValue:{summary:"none"}}},weights:{control:{type:"select"},options:["light","normal","medium","bold"],table:{defaultValue:{summary:"normal"}}},color:{control:{type:"color"}},as:{control:{type:"select"},description:"html \u6807\u7B7E\u7C7B\u578B",options:["div","label","p","span"],table:{defaultValue:{summary:"span"}}},html:{type:"string",description:"\u76F8\u5F53\u4E8E dangerouslySetInnerHTML"}},args:{size:"none",weights:"normal",html:""}};var a=r;const l={args:{children:" The quick brown fox jumps over the lazy dog.",size:"none",weights:"normal"}},p={render(){return t("div",{className:"ai-flex ai-flex-col",children:[o(e,{size:1,children:"The quick brown fox jumps over the lazy dog."}),o(e,{size:2,children:"The quick brown fox jumps over the lazy dog."}),o(e,{size:3,children:"The quick brown fox jumps over the lazy dog."}),o(e,{size:4,children:"The quick brown fox jumps over the lazy dog."}),o(e,{size:5,children:"The quick brown fox jumps over the lazy dog."}),o(e,{size:6,children:"The quick brown fox jumps over the lazy dog."}),o(e,{size:7,children:"The quick brown fox jumps over the lazy dog."}),o(e,{size:8,children:"The quick brown fox jumps over the lazy dog."}),o(e,{size:9,children:"The quick brown fox jumps over the lazy dog."})]})}},u={render(){return t("div",{className:"ai-flex ai-flex-col",children:[o(e,{weights:"light",children:"The quick brown fox jumps over the lazy dog."}),o(e,{weights:"normal",children:"The quick brown fox jumps over the lazy dog."}),o(e,{weights:"medium",children:"The quick brown fox jumps over the lazy dog."}),o(e,{weights:"bold",children:"The quick brown fox jumps over the lazy dog."})]})}},c={render(){return o(e,{html:`The <span style='font-size:20px;font:bold; -webkit-background-clip: text; background: linear-gradient(
|
|
2
|
+
to right,
|
|
3
|
+
#00ff00, /* \u7EFF\u8272 */
|
|
4
|
+
#00ff99, /* \u6D45\u7EFF\u8272 */
|
|
5
|
+
#00ffff, /* \u9752\u8272 */
|
|
6
|
+
#0099ff, /* \u6D45\u84DD\u8272 */
|
|
7
|
+
#8000ff, /* \u7D2B\u8272 */
|
|
8
|
+
#ff00ff /* \u7C89\u8272 */
|
|
9
|
+
);color: transparent;background-clip: text;'>quick brown fox</span> <br/> jumps over the lazy dog.`})}};export{l as Default,c as Html,p as Sizes,u as Weights,a as default};
|
|
2
10
|
//# sourceMappingURL=text.stories.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/stories/text.stories.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { Meta, StoryObj } from '@storybook/react'\n\nimport { Text } from '../components/index'\nimport React from 'react'\n\nconst meta = {\n title: '
|
|
5
|
-
"mappings": "
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["import type { Meta, StoryObj } from '@storybook/react'\n\nimport { Text } from '../components/index'\nimport React from 'react'\n\nconst meta = {\n title: 'Typography/Text',\n component: Text,\n parameters: {\n layout: 'centered',\n docs: {\n description: {\n component: '\u6587\u672C\u7EC4\u4EF6, \u7B80\u5355\u5C01\u88C5\u4E86\u5E38\u7528\u7684\u6837\u5F0F\u5B57\u6BB5\uFF0C\u7528\u4E8E\u5C55\u793A\u6587\u672C\u5185\u5BB9.',\n },\n },\n },\n tags: ['autodocs'],\n argTypes: {\n size: {\n control: {\n type: 'select',\n },\n description: '\u6587\u672C\u5C3A\u5BF8\uFF0C\u9ED8\u8BA4\u4E3Anone\uFF0C\u6D4F\u89C8\u5668\u9ED8\u8BA4\u5927\u5C0F\u548C\u884C\u9AD8\uFF0C1\uFF5E9\u9884\u8BBE\u5B57\u4F53\u5927\u5C0F\u548C\u884C\u9AD8',\n options: ['none', 1, 2, 3, 4, 5, 6, 7, 8, 9],\n table: {\n defaultValue: { summary: 'none' },\n },\n },\n weights: {\n control: {\n type: 'select',\n },\n options: ['light', 'normal', 'medium', 'bold'],\n table: {\n defaultValue: { summary: 'normal' },\n },\n },\n color: {\n control: {\n type: 'color',\n },\n },\n as: {\n control: {\n type: 'select',\n },\n description: 'html \u6807\u7B7E\u7C7B\u578B',\n options: ['div', 'label', 'p', 'span'],\n table: {\n defaultValue: { summary: 'span' },\n },\n },\n html: {\n type: 'string',\n description: '\u76F8\u5F53\u4E8E dangerouslySetInnerHTML',\n },\n },\n args: {\n size: 'none',\n weights: 'normal',\n html: '',\n },\n} satisfies Meta<typeof Text>\n\nexport default meta\ntype Story = StoryObj<typeof meta>\n\nexport const Default: Story = {\n args: {\n children: ' The quick brown fox jumps over the lazy dog.',\n size: 'none',\n weights: 'normal',\n },\n}\n\nexport const Sizes: Story = {\n render() {\n return (\n <div className=\"ai-flex ai-flex-col\">\n <Text size={1}>The quick brown fox jumps over the lazy dog.</Text>\n <Text size={2}>The quick brown fox jumps over the lazy dog.</Text>\n <Text size={3}>The quick brown fox jumps over the lazy dog.</Text>\n <Text size={4}>The quick brown fox jumps over the lazy dog.</Text>\n <Text size={5}>The quick brown fox jumps over the lazy dog.</Text>\n <Text size={6}>The quick brown fox jumps over the lazy dog.</Text>\n <Text size={7}>The quick brown fox jumps over the lazy dog.</Text>\n <Text size={8}>The quick brown fox jumps over the lazy dog.</Text>\n <Text size={9}>The quick brown fox jumps over the lazy dog.</Text>\n </div>\n )\n },\n}\n\nexport const Weights: Story = {\n render() {\n return (\n <div className=\"ai-flex ai-flex-col\">\n <Text weights=\"light\">The quick brown fox jumps over the lazy dog.</Text>\n <Text weights=\"normal\">The quick brown fox jumps over the lazy dog.</Text>\n <Text weights=\"medium\">The quick brown fox jumps over the lazy dog.</Text>\n <Text weights=\"bold\">The quick brown fox jumps over the lazy dog.</Text>\n </div>\n )\n },\n}\n\nexport const Html: Story = {\n render() {\n return (\n <Text\n html={`The <span style='font-size:20px;font:bold; -webkit-background-clip: text; background: linear-gradient(\n to right, \n #00ff00, /* \u7EFF\u8272 */\n #00ff99, /* \u6D45\u7EFF\u8272 */\n #00ffff, /* \u9752\u8272 */\n #0099ff, /* \u6D45\u84DD\u8272 */\n #8000ff, /* \u7D2B\u8272 */\n #ff00ff /* \u7C89\u8272 */\n );color: transparent;background-clip: text;'>quick brown fox</span> <br/> jumps over the lazy dog.`}\n />\n )\n },\n}\n"],
|
|
5
|
+
"mappings": "AA8EM,OACE,OAAAA,EADF,QAAAC,MAAA,oBA5EN,OAAS,QAAAC,MAAY,sBACrB,MAAkB,QAElB,MAAMC,EAAO,CACX,MAAO,kBACP,UAAWD,EACX,WAAY,CACV,OAAQ,WACR,KAAM,CACJ,YAAa,CACX,UAAW,2JACb,CACF,CACF,EACA,KAAM,CAAC,UAAU,EACjB,SAAU,CACR,KAAM,CACJ,QAAS,CACP,KAAM,QACR,EACA,YAAa,6LACb,QAAS,CAAC,OAAQ,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,EAAG,CAAC,EAC3C,MAAO,CACL,aAAc,CAAE,QAAS,MAAO,CAClC,CACF,EACA,QAAS,CACP,QAAS,CACP,KAAM,QACR,EACA,QAAS,CAAC,QAAS,SAAU,SAAU,MAAM,EAC7C,MAAO,CACL,aAAc,CAAE,QAAS,QAAS,CACpC,CACF,EACA,MAAO,CACL,QAAS,CACP,KAAM,OACR,CACF,EACA,GAAI,CACF,QAAS,CACP,KAAM,QACR,EACA,YAAa,gCACb,QAAS,CAAC,MAAO,QAAS,IAAK,MAAM,EACrC,MAAO,CACL,aAAc,CAAE,QAAS,MAAO,CAClC,CACF,EACA,KAAM,CACJ,KAAM,SACN,YAAa,4CACf,CACF,EACA,KAAM,CACJ,KAAM,OACN,QAAS,SACT,KAAM,EACR,CACF,EAEA,IAAOE,EAAQD,EAGR,MAAME,EAAiB,CAC5B,KAAM,CACJ,SAAU,gDACV,KAAM,OACN,QAAS,QACX,CACF,EAEaC,EAAe,CAC1B,QAAS,CACP,OACEL,EAAC,OAAI,UAAU,sBACb,UAAAD,EAACE,EAAA,CAAK,KAAM,EAAG,wDAA4C,EAC3DF,EAACE,EAAA,CAAK,KAAM,EAAG,wDAA4C,EAC3DF,EAACE,EAAA,CAAK,KAAM,EAAG,wDAA4C,EAC3DF,EAACE,EAAA,CAAK,KAAM,EAAG,wDAA4C,EAC3DF,EAACE,EAAA,CAAK,KAAM,EAAG,wDAA4C,EAC3DF,EAACE,EAAA,CAAK,KAAM,EAAG,wDAA4C,EAC3DF,EAACE,EAAA,CAAK,KAAM,EAAG,wDAA4C,EAC3DF,EAACE,EAAA,CAAK,KAAM,EAAG,wDAA4C,EAC3DF,EAACE,EAAA,CAAK,KAAM,EAAG,wDAA4C,GAC7D,CAEJ,CACF,EAEaK,EAAiB,CAC5B,QAAS,CACP,OACEN,EAAC,OAAI,UAAU,sBACb,UAAAD,EAACE,EAAA,CAAK,QAAQ,QAAQ,wDAA4C,EAClEF,EAACE,EAAA,CAAK,QAAQ,SAAS,wDAA4C,EACnEF,EAACE,EAAA,CAAK,QAAQ,SAAS,wDAA4C,EACnEF,EAACE,EAAA,CAAK,QAAQ,OAAO,wDAA4C,GACnE,CAEJ,CACF,EAEaM,EAAc,CACzB,QAAS,CACP,OACER,EAACE,EAAA,CACC,KAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,wGASR,CAEJ,CACF",
|
|
6
|
+
"names": ["jsx", "jsxs", "Text", "meta", "text_stories_default", "Default", "Sizes", "Weights", "Html"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -5,24 +5,40 @@ import * as CheckboxPrimitive from '@radix-ui/react-checkbox'
|
|
|
5
5
|
import { CheckIcon } from '@radix-ui/react-icons'
|
|
6
6
|
|
|
7
7
|
import { cn } from '../helpers/index.js'
|
|
8
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
8
9
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
{
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
10
|
+
const checkboxVariants = cva(
|
|
11
|
+
'ai-border-primary ai-ring-offset-background focus-visible:ai-ring-ring data-[state=checked]:ai-bg-primary data-[state=checked]:ai-text-primary-foreground ai-peer ai-shrink-0 ai-rounded-sm ai-border focus-visible:ai-outline-none focus-visible:ai-ring-2 focus-visible:ai-ring-offset-2 disabled:ai-cursor-not-allowed disabled:ai-opacity-50 disabled:ai-bg-btn-primary-disabled',
|
|
12
|
+
{
|
|
13
|
+
variants: {
|
|
14
|
+
size: {
|
|
15
|
+
sm: 'ai-size-[14px]',
|
|
16
|
+
base: 'ai-size-4',
|
|
17
|
+
lg: 'ai-size-5',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
defaultVariants: {
|
|
21
|
+
size: 'base',
|
|
22
|
+
},
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
interface CheckboxProps
|
|
27
|
+
extends React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>,
|
|
28
|
+
VariantProps<typeof checkboxVariants> {}
|
|
29
|
+
|
|
30
|
+
const Checkbox = React.forwardRef<React.ElementRef<typeof CheckboxPrimitive.Root>, CheckboxProps>(
|
|
31
|
+
({ className, size, ...props }, ref) => (
|
|
32
|
+
<CheckboxPrimitive.Root ref={ref} className={cn(checkboxVariants({ size }), className)} {...props}>
|
|
33
|
+
<CheckboxPrimitive.Indicator
|
|
34
|
+
className={cn('ai-flex ai-items-center ai-justify-center ai-text-current ai-w-full ai-h-full')}
|
|
35
|
+
>
|
|
36
|
+
<CheckIcon />
|
|
37
|
+
</CheckboxPrimitive.Indicator>
|
|
38
|
+
</CheckboxPrimitive.Root>
|
|
39
|
+
)
|
|
40
|
+
)
|
|
41
|
+
Checkbox.displayName = 'Checkbox'
|
|
27
42
|
|
|
28
43
|
export default Checkbox
|
|
44
|
+
export type { CheckboxProps }
|
|
@@ -1,19 +1,74 @@
|
|
|
1
1
|
import { cn } from '../helpers/index.js'
|
|
2
2
|
import { Slot } from '@radix-ui/react-slot'
|
|
3
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
3
4
|
import React from 'react'
|
|
4
5
|
|
|
6
|
+
const headingVariants = cva('', {
|
|
7
|
+
variants: {
|
|
8
|
+
size: {
|
|
9
|
+
none: '',
|
|
10
|
+
1: 'ai-text-xs',
|
|
11
|
+
2: 'ai-text-sm',
|
|
12
|
+
3: 'ai-text-base',
|
|
13
|
+
4: 'ai-text-lg',
|
|
14
|
+
5: 'ai-text-xl',
|
|
15
|
+
6: 'ai-text-2xl',
|
|
16
|
+
7: 'ai-text-3xl',
|
|
17
|
+
8: 'ai-text-4xl',
|
|
18
|
+
9: 'ai-text-5xl',
|
|
19
|
+
},
|
|
20
|
+
weights: {
|
|
21
|
+
light: 'ai-font-light',
|
|
22
|
+
normal: 'ai-font-normal',
|
|
23
|
+
medium: 'ai-font-medium',
|
|
24
|
+
bold: 'ai-font-bold',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
defaultVariants: {
|
|
28
|
+
size: 'none',
|
|
29
|
+
weights: 'normal',
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
|
|
5
33
|
type HeadingElement = React.ElementRef<'h1'>
|
|
6
34
|
|
|
7
|
-
interface HeadingProps extends React.ComponentPropsWithoutRef<'h1'> {
|
|
8
|
-
as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
|
|
35
|
+
interface HeadingProps extends React.ComponentPropsWithoutRef<'h1'>, VariantProps<typeof headingVariants> {
|
|
36
|
+
as?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
|
|
9
37
|
asChild?: boolean
|
|
38
|
+
color?: string
|
|
39
|
+
html?: string
|
|
10
40
|
}
|
|
11
41
|
|
|
12
42
|
const Heading = React.forwardRef<HeadingElement, HeadingProps>((props, forwardedRef) => {
|
|
13
|
-
const { children, className, asChild, as: Tag = 'h1', color, ...headingProps } = props
|
|
43
|
+
const { children, className, size, weights, asChild, as: Tag = 'h1', color, html, ...headingProps } = props
|
|
44
|
+
const htmlContentProps = html
|
|
45
|
+
? {
|
|
46
|
+
dangerouslySetInnerHTML: { __html: html },
|
|
47
|
+
}
|
|
48
|
+
: null
|
|
49
|
+
|
|
50
|
+
const styleProps = color
|
|
51
|
+
? {
|
|
52
|
+
style: {
|
|
53
|
+
color,
|
|
54
|
+
},
|
|
55
|
+
}
|
|
56
|
+
: null
|
|
14
57
|
return (
|
|
15
|
-
<Slot
|
|
16
|
-
{
|
|
58
|
+
<Slot
|
|
59
|
+
{...headingProps}
|
|
60
|
+
ref={forwardedRef}
|
|
61
|
+
className={cn(
|
|
62
|
+
headingVariants({
|
|
63
|
+
size,
|
|
64
|
+
weights,
|
|
65
|
+
}),
|
|
66
|
+
className
|
|
67
|
+
)}
|
|
68
|
+
{...htmlContentProps}
|
|
69
|
+
{...styleProps}
|
|
70
|
+
>
|
|
71
|
+
{asChild ? children : <Tag>{htmlContentProps ? null : children}</Tag>}
|
|
17
72
|
</Slot>
|
|
18
73
|
)
|
|
19
74
|
})
|
|
@@ -21,3 +76,4 @@ const Heading = React.forwardRef<HeadingElement, HeadingProps>((props, forwarded
|
|
|
21
76
|
Heading.displayName = 'Heading'
|
|
22
77
|
|
|
23
78
|
export { Heading }
|
|
79
|
+
export type { HeadingProps }
|
package/src/components/index.ts
CHANGED
package/src/components/input.tsx
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import { cn } from '../helpers/index.js'
|
|
5
|
-
import type { ComponentPropsWithout, RemovedProps } from '
|
|
5
|
+
import type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js'
|
|
6
6
|
import { cva, type VariantProps } from 'class-variance-authority'
|
|
7
7
|
|
|
8
8
|
const inputVariants = cva(
|
package/src/components/radio.tsx
CHANGED
|
@@ -3,36 +3,71 @@
|
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group'
|
|
5
5
|
import { CheckIcon } from '@radix-ui/react-icons'
|
|
6
|
-
|
|
6
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
7
7
|
import { cn } from '../helpers/index.js'
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
|
|
12
|
-
>(({ className, ...props }, ref) => {
|
|
13
|
-
return <RadioGroupPrimitive.Root className={cn('grid gap-2', className)} {...props} ref={ref} />
|
|
14
|
-
})
|
|
15
|
-
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
|
|
16
|
-
|
|
17
|
-
const RadioGroupItem = React.forwardRef<
|
|
18
|
-
React.ElementRef<typeof RadioGroupPrimitive.Item>,
|
|
19
|
-
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
|
|
20
|
-
>(({ className, ...props }, ref) => {
|
|
21
|
-
return (
|
|
22
|
-
<RadioGroupPrimitive.Item
|
|
23
|
-
ref={ref}
|
|
24
|
-
className={cn(
|
|
25
|
-
'ai-border-primary ai-text-primary ai-ring-offset-background focus-visible:ai-ring-ring ai-aspect-square ai-size-4 ai-rounded-full ai-border focus:ai-outline-none focus-visible:ai-ring-2 focus-visible:ai-ring-offset-2 disabled:ai-cursor-not-allowed disabled:ai-opacity-50',
|
|
26
|
-
className
|
|
27
|
-
)}
|
|
28
|
-
{...props}
|
|
29
|
-
>
|
|
30
|
-
<RadioGroupPrimitive.Indicator className="ai-flex ai-items-center ai-justify-center">
|
|
31
|
-
<CheckIcon className="ai-text-primary ai-size-2.5 ai-fill-current" />
|
|
32
|
-
</RadioGroupPrimitive.Indicator>
|
|
33
|
-
</RadioGroupPrimitive.Item>
|
|
34
|
-
)
|
|
9
|
+
const RadioContext = React.createContext<{ size?: 'sm' | 'base' | 'lg' }>({
|
|
10
|
+
size: 'base',
|
|
35
11
|
})
|
|
36
|
-
|
|
12
|
+
|
|
13
|
+
const radioGroupVariants = cva(
|
|
14
|
+
'ai-border-primary ai-text-primary ai-ring-offset-background focus-visible:ai-ring-ring ai-aspect-square ai-rounded-full ai-border focus:ai-outline-none focus-visible:ai-ring-2 focus-visible:ai-ring-offset-2 disabled:ai-cursor-not-allowed disabled:ai-opacity-50 data-[state=checked]:ai-bg-primary data-[state=checked]:ai-text-primary-foreground',
|
|
15
|
+
{
|
|
16
|
+
variants: {
|
|
17
|
+
size: {
|
|
18
|
+
sm: 'ai-size-[14px]',
|
|
19
|
+
base: 'ai-size-4',
|
|
20
|
+
lg: 'ai-size-5',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
defaultVariants: {
|
|
24
|
+
size: 'base',
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
interface RadioGroupProps extends React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root> {
|
|
30
|
+
/** 尺寸 */
|
|
31
|
+
size?: 'sm' | 'base' | 'lg'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const RadioGroup = React.forwardRef<React.ElementRef<typeof RadioGroupPrimitive.Root>, RadioGroupProps>(
|
|
35
|
+
({ className, children, size, ...props }, ref) => {
|
|
36
|
+
return (
|
|
37
|
+
<RadioGroupPrimitive.Root className={cn('grid gap-2', className)} {...props} ref={ref}>
|
|
38
|
+
<RadioContext.Provider value={{ size }}>{children}</RadioContext.Provider>
|
|
39
|
+
</RadioGroupPrimitive.Root>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
)
|
|
43
|
+
RadioGroup.displayName = 'RadioGroup'
|
|
44
|
+
|
|
45
|
+
interface RadioGroupItemProps
|
|
46
|
+
extends React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>,
|
|
47
|
+
VariantProps<typeof radioGroupVariants> {}
|
|
48
|
+
|
|
49
|
+
const RadioGroupItem = React.forwardRef<React.ElementRef<typeof RadioGroupPrimitive.Item>, RadioGroupItemProps>(
|
|
50
|
+
({ className, size, ...props }, ref) => {
|
|
51
|
+
const { size: sizeFromParent } = React.useContext(RadioContext)
|
|
52
|
+
return (
|
|
53
|
+
<RadioGroupPrimitive.Item
|
|
54
|
+
ref={ref}
|
|
55
|
+
className={cn(
|
|
56
|
+
radioGroupVariants({
|
|
57
|
+
size: size ?? sizeFromParent,
|
|
58
|
+
}),
|
|
59
|
+
className
|
|
60
|
+
)}
|
|
61
|
+
{...props}
|
|
62
|
+
>
|
|
63
|
+
<RadioGroupPrimitive.Indicator className="ai-flex ai-items-center ai-justify-center ai-text-current ai-w-full ai-h-full">
|
|
64
|
+
<CheckIcon />
|
|
65
|
+
</RadioGroupPrimitive.Indicator>
|
|
66
|
+
</RadioGroupPrimitive.Item>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
RadioGroupItem.displayName = 'RadioGroupItem'
|
|
37
71
|
|
|
38
72
|
export { RadioGroup, RadioGroupItem }
|
|
73
|
+
export type { RadioGroupProps, RadioGroupItemProps }
|
|
@@ -1,10 +1,41 @@
|
|
|
1
1
|
import * as React from 'react'
|
|
2
2
|
import { cn } from '../helpers/index.js'
|
|
3
|
+
import { Slot } from '@radix-ui/react-slot'
|
|
4
|
+
import type { ComponentPropsWithout, RemovedProps } from '../helpers/component-props.js'
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
type SkeletonElement = React.ElementRef<'span'>
|
|
7
|
+
|
|
8
|
+
interface SkeletonProps extends ComponentPropsWithout<'span', RemovedProps> {
|
|
9
|
+
/** 是否正在加载 , 默认是true*/
|
|
10
|
+
loading?: boolean
|
|
6
11
|
}
|
|
7
12
|
|
|
13
|
+
const Skeleton = React.forwardRef<SkeletonElement, SkeletonProps>((props, forwardedRef) => {
|
|
14
|
+
const { children, className, loading = true, ...skeletonProps } = props
|
|
15
|
+
|
|
16
|
+
if (!loading) return children
|
|
17
|
+
const Tag = React.isValidElement(children) ? Slot : 'span'
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<Tag
|
|
21
|
+
ref={forwardedRef}
|
|
22
|
+
className={cn(
|
|
23
|
+
`ai-bg-skeleton ai-animate-pulse empty:ai-block data-[inline-skeleton=true]:ai-leading-[0] !ai-bg-none !ai-bg-clip-border !ai-border-none !ai-shadow-none
|
|
24
|
+
!ai-text-transparent !ai-outline-none !ai-select-none !ai-cursor-default !ai-pointer-events-none !ai-decoration-clone
|
|
25
|
+
after:!ai-invisible before:!ai-invisible [&>*]:!ai-invisible
|
|
26
|
+
`,
|
|
27
|
+
className
|
|
28
|
+
)}
|
|
29
|
+
data-inline-skeleton={React.isValidElement(children) ? undefined : true}
|
|
30
|
+
tabIndex={-1}
|
|
31
|
+
{...skeletonProps}
|
|
32
|
+
>
|
|
33
|
+
{children}
|
|
34
|
+
</Tag>
|
|
35
|
+
)
|
|
36
|
+
})
|
|
37
|
+
|
|
8
38
|
Skeleton.displayName = 'Skeleton'
|
|
9
39
|
|
|
10
40
|
export default Skeleton
|
|
41
|
+
export type { SkeletonProps }
|