@ubie/vitals-ui-consumer 0.0.1

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.
Files changed (170) hide show
  1. package/.storybook/main.ts +14 -0
  2. package/.storybook/preview.tsx +25 -0
  3. package/.storybook/vitest.setup.ts +7 -0
  4. package/dist/chunk-DKo7XVKm.mjs +33 -0
  5. package/dist/index.d.mts +1720 -0
  6. package/dist/index.d.mts.map +1 -0
  7. package/dist/index.mjs +10594 -0
  8. package/dist/index.mjs.map +1 -0
  9. package/dist/style.css +2299 -0
  10. package/package.json +47 -0
  11. package/src/components/Accordion/Accordion.module.css +75 -0
  12. package/src/components/Accordion/Accordion.spec.tsx +18 -0
  13. package/src/components/Accordion/Accordion.stories.tsx +61 -0
  14. package/src/components/Accordion/Accordion.tsx +89 -0
  15. package/src/components/ActionHalfModal/ActionHalfModal.module.css +180 -0
  16. package/src/components/ActionHalfModal/ActionHalfModal.spec.tsx +57 -0
  17. package/src/components/ActionHalfModal/ActionHalfModal.stories.tsx +469 -0
  18. package/src/components/ActionHalfModal/ActionHalfModal.tsx +269 -0
  19. package/src/components/ActionModal/ActionModal.module.css +145 -0
  20. package/src/components/ActionModal/ActionModal.spec.tsx +57 -0
  21. package/src/components/ActionModal/ActionModal.stories.tsx +302 -0
  22. package/src/components/ActionModal/ActionModal.tsx +232 -0
  23. package/src/components/Bold/Bold.module.css +4 -0
  24. package/src/components/Bold/Bold.spec.tsx +24 -0
  25. package/src/components/Bold/Bold.stories.tsx +54 -0
  26. package/src/components/Bold/Bold.tsx +31 -0
  27. package/src/components/Box/Box.module.css +46 -0
  28. package/src/components/Box/Box.spec.tsx +188 -0
  29. package/src/components/Box/Box.tsx +242 -0
  30. package/src/components/Button/Button.module.css +261 -0
  31. package/src/components/Button/Button.spec.tsx +82 -0
  32. package/src/components/Button/Button.tsx +99 -0
  33. package/src/components/Button/ButtonTypes.ts +107 -0
  34. package/src/components/Button/LinkButton.spec.tsx +86 -0
  35. package/src/components/Button/LinkButton.tsx +80 -0
  36. package/src/components/Button/VariantIcon.tsx +20 -0
  37. package/src/components/Button/useIcon.tsx +16 -0
  38. package/src/components/ButtonCard/ButtonCard.module.css +35 -0
  39. package/src/components/ButtonCard/ButtonCard.spec.tsx +18 -0
  40. package/src/components/ButtonCard/ButtonCard.stories.tsx +54 -0
  41. package/src/components/ButtonCard/ButtonCard.tsx +18 -0
  42. package/src/components/Center/Center.module.css +19 -0
  43. package/src/components/Center/Center.spec.tsx +143 -0
  44. package/src/components/Center/Center.tsx +108 -0
  45. package/src/components/Checkbox/Checkbox.module.css +124 -0
  46. package/src/components/Checkbox/Checkbox.spec.tsx +17 -0
  47. package/src/components/Checkbox/Checkbox.stories.tsx +213 -0
  48. package/src/components/Checkbox/Checkbox.tsx +50 -0
  49. package/src/components/CheckboxCard/CheckboxCard.module.css +102 -0
  50. package/src/components/CheckboxCard/CheckboxCard.spec.tsx +16 -0
  51. package/src/components/CheckboxCard/CheckboxCard.stories.tsx +205 -0
  52. package/src/components/CheckboxCard/CheckboxCard.tsx +53 -0
  53. package/src/components/CheckboxGroup/CheckboxGroup.module.css +16 -0
  54. package/src/components/CheckboxGroup/CheckboxGroup.spec.tsx +17 -0
  55. package/src/components/CheckboxGroup/CheckboxGroup.tsx +64 -0
  56. package/src/components/Color/Color.module.css +3 -0
  57. package/src/components/Color/Color.spec.tsx +24 -0
  58. package/src/components/Color/Color.stories.tsx +71 -0
  59. package/src/components/Color/Color.tsx +28 -0
  60. package/src/components/Divider/Divider.module.css +9 -0
  61. package/src/components/Divider/Divider.spec.tsx +42 -0
  62. package/src/components/Divider/Divider.stories.tsx +77 -0
  63. package/src/components/Divider/Divider.tsx +49 -0
  64. package/src/components/ErrorMessage/ErrorMessage.module.css +8 -0
  65. package/src/components/ErrorMessage/ErrorMessage.spec.tsx +12 -0
  66. package/src/components/ErrorMessage/ErrorMessage.tsx +20 -0
  67. package/src/components/Flex/Flex.module.css +24 -0
  68. package/src/components/Flex/Flex.spec.tsx +188 -0
  69. package/src/components/Flex/Flex.tsx +173 -0
  70. package/src/components/FlexItem/FlexItem.module.css +14 -0
  71. package/src/components/FlexItem/FlexItem.spec.tsx +84 -0
  72. package/src/components/FlexItem/FlexItem.tsx +106 -0
  73. package/src/components/Heading/Heading.module.css +131 -0
  74. package/src/components/Heading/Heading.tsx +86 -0
  75. package/src/components/HelperMessage/HelperMessage.module.css +8 -0
  76. package/src/components/HelperMessage/HelperMessage.tsx +15 -0
  77. package/src/components/Icon/Icon.module.css +6 -0
  78. package/src/components/Icon/Icon.spec.tsx +24 -0
  79. package/src/components/Icon/Icon.stories.tsx +100 -0
  80. package/src/components/Icon/Icon.tsx +101 -0
  81. package/src/components/Input/Input.module.css +51 -0
  82. package/src/components/Input/Input.spec.tsx +14 -0
  83. package/src/components/Input/Input.tsx +27 -0
  84. package/src/components/Label/Label.module.css +14 -0
  85. package/src/components/Label/Label.tsx +39 -0
  86. package/src/components/LinkCard/LinkCard.module.css +72 -0
  87. package/src/components/LinkCard/LinkCard.tsx +96 -0
  88. package/src/components/MessageHalfModal/MessageHalfModal.module.css +181 -0
  89. package/src/components/MessageHalfModal/MessageHalfModal.spec.tsx +73 -0
  90. package/src/components/MessageHalfModal/MessageHalfModal.stories.tsx +242 -0
  91. package/src/components/MessageHalfModal/MessageHalfModal.tsx +194 -0
  92. package/src/components/MessageModal/MessageModal.module.css +149 -0
  93. package/src/components/MessageModal/MessageModal.spec.tsx +57 -0
  94. package/src/components/MessageModal/MessageModal.stories.tsx +223 -0
  95. package/src/components/MessageModal/MessageModal.tsx +178 -0
  96. package/src/components/Pre/Pre.module.css +8 -0
  97. package/src/components/Pre/Pre.spec.tsx +11 -0
  98. package/src/components/Pre/Pre.stories.tsx +76 -0
  99. package/src/components/Pre/Pre.tsx +40 -0
  100. package/src/components/RadioButton/RadioButton.module.css +92 -0
  101. package/src/components/RadioButton/RadioButton.spec.tsx +25 -0
  102. package/src/components/RadioButton/RadioButton.tsx +55 -0
  103. package/src/components/RadioCard/RadioCard.module.css +109 -0
  104. package/src/components/RadioCard/RadioCard.tsx +61 -0
  105. package/src/components/RadioGroup/RadioGroup.module.css +16 -0
  106. package/src/components/RadioGroup/RadioGroup.spec.tsx +17 -0
  107. package/src/components/RadioGroup/RadioGroup.tsx +60 -0
  108. package/src/components/Select/Select.module.css +70 -0
  109. package/src/components/Select/Select.spec.tsx +12 -0
  110. package/src/components/Select/Select.tsx +56 -0
  111. package/src/components/Stack/Stack.module.css +10 -0
  112. package/src/components/Stack/Stack.spec.tsx +177 -0
  113. package/src/components/Stack/Stack.tsx +151 -0
  114. package/src/components/Stepper/Stepper.module.css +137 -0
  115. package/src/components/Stepper/Stepper.spec.tsx +198 -0
  116. package/src/components/Stepper/Stepper.stories.tsx +192 -0
  117. package/src/components/Stepper/Stepper.tsx +70 -0
  118. package/src/components/Stepper/StepperItem.tsx +113 -0
  119. package/src/components/Text/Text.module.css +168 -0
  120. package/src/components/Text/Text.tsx +192 -0
  121. package/src/components/TextArea/TextArea.module.css +46 -0
  122. package/src/components/TextArea/TextArea.spec.tsx +13 -0
  123. package/src/components/TextArea/TextArea.tsx +29 -0
  124. package/src/components/Toggle/Toggle.module.css +71 -0
  125. package/src/components/Toggle/Toggle.spec.tsx +21 -0
  126. package/src/components/Toggle/Toggle.tsx +56 -0
  127. package/src/font.ts +2 -0
  128. package/src/hooks/useScrollable.ts +58 -0
  129. package/src/icons/AppleIcon.tsx +14 -0
  130. package/src/icons/GoogleIcon.tsx +27 -0
  131. package/src/icons/LINEIcon.tsx +16 -0
  132. package/src/index.ts +35 -0
  133. package/src/sharedComponents/RequiredLabel/RequiredLabel.module.css +10 -0
  134. package/src/sharedComponents/RequiredLabel/RequiredLabel.tsx +8 -0
  135. package/src/sharedComponents/VisuallyHidden/VisuallyHidden.module.css +15 -0
  136. package/src/sharedComponents/VisuallyHidden/VisuallyHidden.tsx +22 -0
  137. package/src/stories/Accordion.stories.portable.ts +4 -0
  138. package/src/stories/Box.stories.tsx +474 -0
  139. package/src/stories/Button.stories.tsx +262 -0
  140. package/src/stories/Center.stories.tsx +126 -0
  141. package/src/stories/ErrorMessage.stories.tsx +19 -0
  142. package/src/stories/Flex.stories.tsx +345 -0
  143. package/src/stories/Form.stories.tsx +83 -0
  144. package/src/stories/Heading.stories.tsx +263 -0
  145. package/src/stories/HelperMessage.stories.tsx +22 -0
  146. package/src/stories/Input.stories.tsx +145 -0
  147. package/src/stories/Label.stories.tsx +32 -0
  148. package/src/stories/LinkButton.stories.tsx +207 -0
  149. package/src/stories/LinkCard.stories.tsx +90 -0
  150. package/src/stories/RadioButton.stories.tsx +168 -0
  151. package/src/stories/RadioCard.stories.tsx +236 -0
  152. package/src/stories/Select.stories.tsx +97 -0
  153. package/src/stories/Stack.stories.tsx +167 -0
  154. package/src/stories/Text.stories.tsx +396 -0
  155. package/src/stories/TextArea.stories.tsx +49 -0
  156. package/src/stories/Toggle.stories.tsx +30 -0
  157. package/src/test/vitest-jest-dom.d.ts +12 -0
  158. package/src/types/attributes.ts +6 -0
  159. package/src/types/global.d.ts +11 -0
  160. package/src/types/icon.ts +3 -0
  161. package/src/types/style.ts +254 -0
  162. package/src/utils/component.ts +8 -0
  163. package/src/utils/style.spec.ts +57 -0
  164. package/src/utils/style.ts +387 -0
  165. package/src/utils/types.ts +8 -0
  166. package/tsconfig.json +18 -0
  167. package/tsconfig.spec-lint.tsbuildinfo +1 -0
  168. package/tsconfig.tsbuildinfo +1 -0
  169. package/vite.config.ts +50 -0
  170. package/vitest.shims.d.ts +1 -0
@@ -0,0 +1,396 @@
1
+ import { Meta, StoryObj } from "@storybook/react-vite";
2
+ import { Text, Flex, Stack, Box } from "../";
3
+ import type { FC, PropsWithChildren } from "react";
4
+
5
+ export default {
6
+ title: "Typography/Text",
7
+ component: Text,
8
+ } satisfies Meta<typeof Text>;
9
+
10
+ type Story = StoryObj<typeof Text>;
11
+
12
+ const defaultArgs = {};
13
+ export const Default: Story = {
14
+ render: () => (
15
+ <Text as="h1" type="heading" size="xl" color="blue">
16
+ Dummy Text
17
+ </Text>
18
+ ),
19
+ args: defaultArgs,
20
+ };
21
+
22
+ export const Color: Story = {
23
+ render: () => (
24
+ <Stack gap="xs">
25
+ <Text color="main">main</Text>
26
+ <Text color="sub">sub</Text>
27
+ <Text color="link">link</Text>
28
+ <Text color="linkSub">linkSub</Text>
29
+ <Text color="disabled">disabled</Text>
30
+ <Text color="blue">blue</Text>
31
+ <Text color="blueDarken">blueDarken</Text>
32
+ <Text color="pink">pink</Text>
33
+ <Text color="pinkDarken">pinkDarken</Text>
34
+ <Text color="orange">orange</Text>
35
+ <Text color="orangeDarken">orangeDarken</Text>
36
+ <Text color="purple">purple</Text>
37
+ <Text color="purpleDarken">purpleDarken</Text>
38
+ <Text color="green">green</Text>
39
+ <Text color="greenDarken">greenDarken</Text>
40
+ <Text color="red">red</Text>
41
+ <Text color="redDarken">redDarken</Text>
42
+ <Text color="black">black</Text>
43
+ <Text color="blackDarken">blackDarken</Text>
44
+ <span style={{ background: "black", padding: "0 0.5em" }}>
45
+ <Text color="white">white</Text>
46
+ </span>
47
+ </Stack>
48
+ ),
49
+ args: defaultArgs,
50
+ };
51
+
52
+ export const Heading: Story = {
53
+ render: () => {
54
+ const headingText = "近くの医療機関から調べる";
55
+
56
+ return (
57
+ <>
58
+ <p>Default Leading</p>
59
+ <Flex spacing="md" alignItems="center">
60
+ <Text bold type="heading" size="xxs">
61
+ xxs
62
+ <br />
63
+ {`${headingText}`}
64
+ </Text>
65
+ <Text bold type="heading" size="xs">
66
+ xs
67
+ <br />
68
+ {`${headingText}`}
69
+ </Text>
70
+ <Text bold type="heading" size="sm">
71
+ sm
72
+ <br />
73
+ {`${headingText}`}
74
+ </Text>
75
+ <Text bold type="heading" size="md">
76
+ md
77
+ <br />
78
+ {`${headingText}`}
79
+ </Text>
80
+ <Text bold type="heading" size="lg">
81
+ lg
82
+ <br />
83
+ {`${headingText}`}
84
+ </Text>
85
+ <Text bold type="heading" size="xl">
86
+ xl
87
+ <br />
88
+ {`${headingText}`}
89
+ </Text>
90
+ </Flex>
91
+
92
+ <p style={{ marginTop: "16px" }}>Wide Leading</p>
93
+ <Flex spacing="md" alignItems="center">
94
+ <Text bold leading="wide" type="heading" size="xxs">
95
+ xxs
96
+ <br />
97
+ {`${headingText}`}
98
+ </Text>
99
+ <Text bold leading="wide" type="heading" size="xs">
100
+ xs
101
+ <br />
102
+ {`${headingText}`}
103
+ </Text>
104
+ <Text bold leading="wide" type="heading" size="sm">
105
+ sm
106
+ <br />
107
+ {`${headingText}`}
108
+ </Text>
109
+ <Text bold leading="wide" type="heading" size="md">
110
+ md
111
+ <br />
112
+ {`${headingText}`}
113
+ </Text>
114
+ <Text bold leading="wide" type="heading" size="lg">
115
+ lg
116
+ <br />
117
+ {`${headingText}`}
118
+ </Text>
119
+ <Text bold leading="wide" type="heading" size="xl">
120
+ xl
121
+ <br />
122
+ {`${headingText}`}
123
+ </Text>
124
+ </Flex>
125
+ </>
126
+ );
127
+ },
128
+ args: defaultArgs,
129
+ };
130
+
131
+ export const Body: Story = {
132
+ render: () => {
133
+ const bodyText =
134
+ "症状検索エンジン「ユビー」は「適切なタイミングでの適切な医療との出会い」の橋渡しによって、みなさんの健康・安全をサポートし、医療についての不安・悩み・苦痛を和らげます。";
135
+
136
+ return (
137
+ <Stack as="dl" spacing="md">
138
+ <div>
139
+ <dt>Default Leading</dt>
140
+ <dd>
141
+ <Flex spacing="md" alignItems="center">
142
+ <Text type="body" size="xs">
143
+ xs
144
+ <br />
145
+ {`${bodyText}`}
146
+ </Text>
147
+ <Text type="body" size="sm">
148
+ sm
149
+ <br />
150
+ {`${bodyText}`}
151
+ </Text>
152
+ <Text type="body" size="md">
153
+ md
154
+ <br />
155
+ {`${bodyText}`}
156
+ </Text>
157
+ <Text type="body" size="lg">
158
+ lg
159
+ <br />
160
+ {`${bodyText}`}
161
+ </Text>
162
+ </Flex>
163
+ </dd>
164
+ </div>
165
+
166
+ <div>
167
+ <dt>Narrow Leading</dt>
168
+ <dd>
169
+ <Flex spacing="md" alignItems="center">
170
+ <Text leading="narrow" type="body" size="xs">
171
+ xs
172
+ <br />
173
+ {`${bodyText}`}
174
+ </Text>
175
+ <Text leading="narrow" type="body" size="sm">
176
+ sm
177
+ <br />
178
+ {`${bodyText}`}
179
+ </Text>
180
+ <Text leading="narrow" type="body" size="md">
181
+ md
182
+ <br />
183
+ {`${bodyText}`}
184
+ </Text>
185
+ <Text leading="narrow" type="body" size="lg">
186
+ lg
187
+ <br />
188
+ {`${bodyText}`}
189
+ </Text>
190
+ </Flex>
191
+ </dd>
192
+ </div>
193
+
194
+ <div>
195
+ <dt>Wide Leading</dt>
196
+ <dd>
197
+ <Flex spacing="md" alignItems="center">
198
+ <Text leading="wide" type="body" size="xs">
199
+ xs
200
+ <br />
201
+ {`${bodyText}`}
202
+ </Text>
203
+ <Text leading="wide" type="body" size="sm">
204
+ sm
205
+ <br />
206
+ {`${bodyText}`}
207
+ </Text>
208
+ <Text leading="wide" type="body" size="md">
209
+ md
210
+ <br />
211
+ {`${bodyText}`}
212
+ </Text>
213
+ <Text leading="wide" type="body" size="lg">
214
+ lg
215
+ <br />
216
+ {`${bodyText}`}
217
+ </Text>
218
+ </Flex>
219
+ </dd>
220
+ </div>
221
+ </Stack>
222
+ );
223
+ },
224
+ args: defaultArgs,
225
+ };
226
+
227
+ export const Button: Story = {
228
+ render: () => {
229
+ const buttonText = "同意して症状から調べる";
230
+
231
+ return (
232
+ <Flex spacing="md" alignItems="center">
233
+ <Text type="button" size="sm">
234
+ sm
235
+ <br />
236
+ {`${buttonText}`}
237
+ </Text>
238
+ <Text type="button" size="md">
239
+ md
240
+ <br />
241
+ {`${buttonText}`}
242
+ </Text>
243
+ <Text type="button" size="lg">
244
+ lg
245
+ <br />
246
+ {`${buttonText}`}
247
+ </Text>
248
+ </Flex>
249
+ );
250
+ },
251
+ args: defaultArgs,
252
+ };
253
+
254
+ export const Tag: Story = {
255
+ render: () => {
256
+ const tagText = "循環器内科";
257
+
258
+ return (
259
+ <Flex spacing="md" alignItems="center">
260
+ <Text type="tag" size="md">
261
+ md
262
+ <br />
263
+ {`${tagText}`}
264
+ </Text>
265
+ <Text type="tag" size="lg">
266
+ lg
267
+ <br />
268
+ {`${tagText}`}
269
+ </Text>
270
+ </Flex>
271
+ );
272
+ },
273
+ args: defaultArgs,
274
+ };
275
+
276
+ export const WithId: Story = {
277
+ render: () => (
278
+ <Text id="text-id" type="heading" size="xl" as="h2" color="blue" bold>
279
+ Dummy Text
280
+ </Text>
281
+ ),
282
+ };
283
+
284
+ export const TextInText: Story = {
285
+ render: () => (
286
+ <Text type="body" size="lg">
287
+ <Text as="span" type="body" size="lg" color="red" bold>
288
+ Alert:
289
+ </Text>{" "}
290
+ Please fill in all fields
291
+ </Text>
292
+ ),
293
+ };
294
+
295
+ export const TextAlign: Story = {
296
+ render: () => (
297
+ <Stack spacing="md" alignItems="normal">
298
+ <Text textAlign="left">Left</Text>
299
+ <Text textAlign="center">Center</Text>
300
+ <Text textAlign="right">Right</Text>
301
+ <div style={{ textAlign: "center" }}>
302
+ <Text textAlign="center">Inherit(undefined)</Text>
303
+ </div>
304
+ </Stack>
305
+ ),
306
+ };
307
+
308
+ export const CustomDataAttribute: Story = {
309
+ render: () => <Text date-test-id="some-id">Text</Text>,
310
+ };
311
+
312
+ export const Bold: Story = {
313
+ render: () => <Text bold>Bold</Text>,
314
+ };
315
+
316
+ export const Wrap: Story = {
317
+ render: () => (
318
+ <div style={{ width: "300px" }}>
319
+ <Stack spacing="md">
320
+ <Box border="black">
321
+ <Text>
322
+ 私はすべてぼんやりその批評痛というのの中を押しだなけれ。現に十月の仕事方ももしこのお尋ねましたまでをふりまいとならませには刺戟待ったたて、とてもにはなろべきませたです。https://vitals.ubie.life/?hoge=1111111111111111111111111111111111111111111111111111
323
+ </Text>
324
+ </Box>
325
+
326
+ <div lang="en">
327
+ <Box border="black">
328
+ <Text>
329
+ industry. Lorem Ipsum has been the industry&apos;s standard dummy text ever since the
330
+ 1500s, when an unknown printer took a galley of type and scrambled it to make a type
331
+ specimen booooooooooooooooooooooooooooooooooooooooooooook.
332
+ </Text>
333
+ </Box>
334
+ </div>
335
+
336
+ <div>
337
+ <p>
338
+ <code>noWrap</code>
339
+ </p>
340
+
341
+ <Box border="black">
342
+ <Text noWrap>
343
+ 私はすべてぼんやりその批評痛というのの中を押しだなけれ。現に十月の仕事方ももしこのお尋ねましたまでをふりまいとならませには刺戟待ったたて、とてもにはなろべきませたです。https://vitals.ubie.life/?hoge=1111111111111111111111111111111111111111111111111111
344
+ </Text>
345
+ </Box>
346
+ </div>
347
+
348
+ <div>
349
+ <p>
350
+ <code>noWrap</code>
351
+ </p>
352
+
353
+ <Box border="black">
354
+ <Text noWrap>
355
+ industry. Lorem Ipsum has been the industry&apos;s standard dummy text ever since the
356
+ 1500s, when an unknown printer took a galley of type and scrambled it to make a type
357
+ specimen book.
358
+ </Text>
359
+ </Box>
360
+ </div>
361
+ </Stack>
362
+ </div>
363
+ ),
364
+ };
365
+
366
+ const TestLink: FC<PropsWithChildren<{ href: string }>> = ({ href, children, ...rest }) => (
367
+ <a href={href} {...rest}>
368
+ {children}
369
+ </a>
370
+ );
371
+
372
+ export const AsLink: Story = {
373
+ render: () => (
374
+ <>
375
+ <Text as="a" href="https://vitals.ubie.life/">
376
+ Link ggggg(underline確認でgをおいている)
377
+ </Text>
378
+ <br />
379
+ <Text type="heading" size="xl" bold render={<TestLink href="https://vitals.ubie.life/" />}>
380
+ render propを使用したケース
381
+ </Text>
382
+ </>
383
+ ),
384
+ };
385
+
386
+ export const AsButton: Story = {
387
+ render: () => (
388
+ <>
389
+ <p>as propを使うと、type propが重複してしまう。ハッキ―だがrenderで回避</p>
390
+ <p>button要素に対してmarkuplintのrequire-accessible-nameを無効化する必要があります</p>
391
+ <Text type="heading" size="xl" bold render={<button type="button" />}>
392
+ ボタン
393
+ </Text>
394
+ </>
395
+ ),
396
+ };
@@ -0,0 +1,49 @@
1
+ import { Meta, StoryObj } from "@storybook/react-vite";
2
+ import { useState, useCallback, ChangeEventHandler } from "react";
3
+ import { TextArea } from "../";
4
+
5
+ export default {
6
+ title: "Form/TextArea",
7
+ component: TextArea,
8
+ } satisfies Meta<typeof TextArea>;
9
+
10
+ type Story = StoryObj<typeof TextArea>;
11
+
12
+ export const Default: Story = {
13
+ render: () => {
14
+ const [value, setValue] = useState("Lorem\nipsum");
15
+
16
+ const onChange: ChangeEventHandler<HTMLTextAreaElement> = useCallback((event) => {
17
+ setValue(event.target.value);
18
+ }, []);
19
+
20
+ return <TextArea value={value} onChange={onChange} />;
21
+ },
22
+ };
23
+
24
+ export const Disabled: Story = {
25
+ render: () => {
26
+ return <TextArea value={"Lorem\nipsum"} disabled />;
27
+ },
28
+ };
29
+
30
+ export const IsInvalid: Story = {
31
+ render: () => {
32
+ return <TextArea value={"wrong\nvalue"} isInvalid />;
33
+ },
34
+ };
35
+
36
+ export const Placeholder: Story = {
37
+ render: () => {
38
+ return <TextArea placeholder={"place\nholder"} />;
39
+ },
40
+ };
41
+
42
+ export const CustomDataAttribute: Story = {
43
+ args: {
44
+ "data-test-id": "textarea-custom-attribute",
45
+ },
46
+ render: (args) => (
47
+ <TextArea {...args} value="This is a text area with a custom data attribute." />
48
+ ),
49
+ };
@@ -0,0 +1,30 @@
1
+ import { Meta, StoryObj } from "@storybook/react-vite";
2
+ import { Toggle } from "..";
3
+
4
+ export default {
5
+ title: "Form/Toggle",
6
+ component: Toggle,
7
+ } satisfies Meta<typeof Toggle>;
8
+
9
+ type Story = StoryObj<typeof Toggle>;
10
+
11
+ export const Default: Story = {};
12
+
13
+ export const DefaultChecked: Story = {
14
+ args: {
15
+ defaultChecked: true,
16
+ },
17
+ };
18
+
19
+ export const Disabled: Story = {
20
+ args: {
21
+ disabled: true,
22
+ },
23
+ };
24
+
25
+ export const CustomDataAttribute: Story = {
26
+ args: {
27
+ "data-test-id": "toggle-custom-attribute",
28
+ },
29
+ render: (args) => <Toggle {...args} />,
30
+ };
@@ -0,0 +1,12 @@
1
+ export {};
2
+
3
+ declare global {
4
+ namespace jest {
5
+ interface Matchers<R = void, T = {}> {
6
+ toBeInTheDocument(): R;
7
+ toHaveAttribute(attr: string, value?: unknown): R;
8
+ toHaveClass(...classNames: Array<string | RegExp>): R;
9
+ toHaveStyle(css: string | Record<string, unknown>): R;
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,6 @@
1
+ export type CustomDataAttributeProps = {
2
+ /**
3
+ * data-*属性
4
+ */
5
+ [key: `data-${string}`]: unknown;
6
+ };
@@ -0,0 +1,11 @@
1
+ declare module "*.module.css" {
2
+ const classes: { readonly [key: string]: string };
3
+ export default classes;
4
+ }
5
+
6
+ declare module "*.module.scss" {
7
+ const classes: { readonly [key: string]: string };
8
+ export default classes;
9
+ }
10
+
11
+ declare module "@ubie/vitals-token-consumer/css";
@@ -0,0 +1,3 @@
1
+ import * as Icons from "@ubie/vitals-icon";
2
+
3
+ export type IconName = keyof typeof Icons;