@k8o/arte-odyssey 0.0.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.
Files changed (276) hide show
  1. package/LICENSE +21 -0
  2. package/dist/components/accordion/accordion-button.d.ts +2 -0
  3. package/dist/components/accordion/accordion-button.js +40 -0
  4. package/dist/components/accordion/accordion-item.d.ts +4 -0
  5. package/dist/components/accordion/accordion-item.js +11 -0
  6. package/dist/components/accordion/accordion-panel.d.ts +2 -0
  7. package/dist/components/accordion/accordion-panel.js +21 -0
  8. package/dist/components/accordion/accordion.d.ts +2 -0
  9. package/dist/components/accordion/accordion.js +17 -0
  10. package/dist/components/accordion/accordion.stories.js +89 -0
  11. package/dist/components/accordion/context.d.ts +10 -0
  12. package/dist/components/accordion/context.js +38 -0
  13. package/dist/components/accordion/index.d.ts +4 -0
  14. package/dist/components/accordion/index.js +4 -0
  15. package/dist/components/alert/alert.d.ts +8 -0
  16. package/dist/components/alert/alert.js +46 -0
  17. package/dist/components/alert/alert.stories.js +51 -0
  18. package/dist/components/alert/index.d.ts +1 -0
  19. package/dist/components/alert/index.js +1 -0
  20. package/dist/components/anchor/anchor.d.ts +14 -0
  21. package/dist/components/anchor/anchor.js +31 -0
  22. package/dist/components/anchor/anchor.stories.js +23 -0
  23. package/dist/components/anchor/index.d.ts +1 -0
  24. package/dist/components/anchor/index.js +1 -0
  25. package/dist/components/baseline-status/baseline-status.d.ts +16 -0
  26. package/dist/components/baseline-status/baseline-status.js +39 -0
  27. package/dist/components/baseline-status/baseline-status.stories.js +15 -0
  28. package/dist/components/baseline-status/index.d.ts +1 -0
  29. package/dist/components/baseline-status/index.js +1 -0
  30. package/dist/components/breadcrumb/breadcrumb.d.ts +18 -0
  31. package/dist/components/breadcrumb/breadcrumb.js +36 -0
  32. package/dist/components/breadcrumb/breadcrumb.stories.js +40 -0
  33. package/dist/components/breadcrumb/index.d.ts +1 -0
  34. package/dist/components/breadcrumb/index.js +1 -0
  35. package/dist/components/button/button.d.ts +10 -0
  36. package/dist/components/button/button.js +55 -0
  37. package/dist/components/button/button.stories.js +96 -0
  38. package/dist/components/button/index.d.ts +1 -0
  39. package/dist/components/button/index.js +1 -0
  40. package/dist/components/card/card.d.ts +3 -0
  41. package/dist/components/card/card.js +26 -0
  42. package/dist/components/card/card.stories.js +38 -0
  43. package/dist/components/card/index.d.ts +2 -0
  44. package/dist/components/card/index.js +2 -0
  45. package/dist/components/card/interactive-card.d.ts +3 -0
  46. package/dist/components/card/interactive-card.js +34 -0
  47. package/dist/components/card/type.d.ts +6 -0
  48. package/dist/components/card/type.js +0 -0
  49. package/dist/components/code/code.d.ts +4 -0
  50. package/dist/components/code/code.js +38 -0
  51. package/dist/components/code/code.stories.js +60 -0
  52. package/dist/components/code/index.d.ts +1 -0
  53. package/dist/components/code/index.js +4 -0
  54. package/dist/components/dialog/dialog.d.ts +17 -0
  55. package/dist/components/dialog/dialog.js +85 -0
  56. package/dist/components/dialog/dialog.stories.js +98 -0
  57. package/dist/components/dialog/index.d.ts +1 -0
  58. package/dist/components/dialog/index.js +1 -0
  59. package/dist/components/drawer/drawer.d.ts +6 -0
  60. package/dist/components/drawer/drawer.js +56 -0
  61. package/dist/components/drawer/drawer.stories.js +25 -0
  62. package/dist/components/drawer/index.d.ts +1 -0
  63. package/dist/components/drawer/index.js +1 -0
  64. package/dist/components/dropdown-menu/dropdown-menu.d.ts +24 -0
  65. package/dist/components/dropdown-menu/dropdown-menu.js +130 -0
  66. package/dist/components/dropdown-menu/dropdown-menu.stories.js +111 -0
  67. package/dist/components/dropdown-menu/hooks.d.ts +23 -0
  68. package/dist/components/dropdown-menu/hooks.js +56 -0
  69. package/dist/components/dropdown-menu/index.d.ts +1 -0
  70. package/dist/components/dropdown-menu/index.js +1 -0
  71. package/dist/components/error-boundary/index.d.ts +1 -0
  72. package/dist/components/error-boundary/index.js +4 -0
  73. package/dist/components/form/autocomplete/autocomplete.d.ts +14 -0
  74. package/dist/components/form/autocomplete/autocomplete.js +225 -0
  75. package/dist/components/form/autocomplete/autocomplete.stories.js +59 -0
  76. package/dist/components/form/autocomplete/index.d.ts +1 -0
  77. package/dist/components/form/autocomplete/index.js +1 -0
  78. package/dist/components/form/checkbox/checkbox.d.ts +8 -0
  79. package/dist/components/form/checkbox/checkbox.js +40 -0
  80. package/dist/components/form/checkbox/checkbox.stories.js +27 -0
  81. package/dist/components/form/checkbox/index.d.ts +1 -0
  82. package/dist/components/form/checkbox/index.js +1 -0
  83. package/dist/components/form/form-control/form-control.d.ts +20 -0
  84. package/dist/components/form/form-control/form-control.js +53 -0
  85. package/dist/components/form/form-control/form-control.stories.js +94 -0
  86. package/dist/components/form/form-control/index.d.ts +1 -0
  87. package/dist/components/form/form-control/index.js +1 -0
  88. package/dist/components/form/number-field/index.d.ts +1 -0
  89. package/dist/components/form/number-field/index.js +1 -0
  90. package/dist/components/form/number-field/number-field.d.ts +17 -0
  91. package/dist/components/form/number-field/number-field.js +150 -0
  92. package/dist/components/form/number-field/number-field.stories.js +106 -0
  93. package/dist/components/form/radio/index.d.ts +1 -0
  94. package/dist/components/form/radio/index.js +1 -0
  95. package/dist/components/form/radio/radio.d.ts +11 -0
  96. package/dist/components/form/radio/radio.js +51 -0
  97. package/dist/components/form/radio/radio.stories.js +55 -0
  98. package/dist/components/form/range-field/index.d.ts +1 -0
  99. package/dist/components/form/range-field/index.js +4 -0
  100. package/dist/components/form/range-field/range-field.d.ts +17 -0
  101. package/dist/components/form/range-field/range-field.js +54 -0
  102. package/dist/components/form/range-field/range-field.stories.js +162 -0
  103. package/dist/components/form/select/index.d.ts +1 -0
  104. package/dist/components/form/select/index.js +1 -0
  105. package/dist/components/form/select/select.d.ts +14 -0
  106. package/dist/components/form/select/select.js +39 -0
  107. package/dist/components/form/select/select.stories.js +58 -0
  108. package/dist/components/form/text-field/index.d.ts +1 -0
  109. package/dist/components/form/text-field/index.js +1 -0
  110. package/dist/components/form/text-field/text-field.d.ts +15 -0
  111. package/dist/components/form/text-field/text-field.js +40 -0
  112. package/dist/components/form/text-field/text-field.stories.js +61 -0
  113. package/dist/components/form/textarea/index.d.ts +1 -0
  114. package/dist/components/form/textarea/index.js +1 -0
  115. package/dist/components/form/textarea/textarea.d.ts +18 -0
  116. package/dist/components/form/textarea/textarea.js +56 -0
  117. package/dist/components/form/textarea/textarea.stories.js +92 -0
  118. package/dist/components/heading/heading.d.ts +8 -0
  119. package/dist/components/heading/heading.js +77 -0
  120. package/dist/components/heading/heading.stories.js +52 -0
  121. package/dist/components/heading/index.d.ts +1 -0
  122. package/dist/components/heading/index.js +1 -0
  123. package/dist/components/icon-button/icon-button.d.ts +8 -0
  124. package/dist/components/icon-button/icon-button.js +38 -0
  125. package/dist/components/icon-button/icon-button.stories.js +54 -0
  126. package/dist/components/icon-button/index.d.ts +1 -0
  127. package/dist/components/icon-button/index.js +1 -0
  128. package/dist/components/icon-link/icon-link.d.ts +17 -0
  129. package/dist/components/icon-link/icon-link.js +37 -0
  130. package/dist/components/icon-link/icon-link.stories.js +40 -0
  131. package/dist/components/icon-link/index.d.ts +1 -0
  132. package/dist/components/icon-link/index.js +1 -0
  133. package/dist/components/icons/arte-odyssey.d.ts +3 -0
  134. package/dist/components/icons/arte-odyssey.js +463 -0
  135. package/dist/components/icons/base.d.ts +9 -0
  136. package/dist/components/icons/base.js +13 -0
  137. package/dist/components/icons/github-mark.d.ts +3 -0
  138. package/dist/components/icons/github-mark.js +33 -0
  139. package/dist/components/icons/icons.stories.js +276 -0
  140. package/dist/components/icons/index.d.ts +7 -0
  141. package/dist/components/icons/index.js +7 -0
  142. package/dist/components/icons/logo.d.ts +6 -0
  143. package/dist/components/icons/logo.js +50 -0
  144. package/dist/components/icons/lucide.d.ts +50 -0
  145. package/dist/components/icons/lucide.js +569 -0
  146. package/dist/components/icons/qiita.d.ts +3 -0
  147. package/dist/components/icons/qiita.js +48 -0
  148. package/dist/components/icons/twitter.d.ts +3 -0
  149. package/dist/components/icons/twitter.js +34 -0
  150. package/dist/components/icons/zenn.d.ts +6 -0
  151. package/dist/components/icons/zenn.js +41 -0
  152. package/dist/components/index.d.ts +37 -0
  153. package/dist/components/index.js +37 -0
  154. package/dist/components/link-button/index.d.ts +1 -0
  155. package/dist/components/link-button/index.js +1 -0
  156. package/dist/components/link-button/link-button.d.ts +19 -0
  157. package/dist/components/link-button/link-button.js +46 -0
  158. package/dist/components/link-button/link-button.stories.js +51 -0
  159. package/dist/components/list-box/hooks.d.ts +37 -0
  160. package/dist/components/list-box/hooks.js +70 -0
  161. package/dist/components/list-box/index.d.ts +1 -0
  162. package/dist/components/list-box/index.js +1 -0
  163. package/dist/components/list-box/list-box.d.ts +22 -0
  164. package/dist/components/list-box/list-box.js +145 -0
  165. package/dist/components/list-box/list-box.stories.js +69 -0
  166. package/dist/components/modal/index.d.ts +1 -0
  167. package/dist/components/modal/index.js +1 -0
  168. package/dist/components/modal/modal.d.ts +8 -0
  169. package/dist/components/modal/modal.js +118 -0
  170. package/dist/components/modal/modal.stories.js +22 -0
  171. package/dist/components/popover/hooks.d.ts +65 -0
  172. package/dist/components/popover/hooks.js +187 -0
  173. package/dist/components/popover/index.d.ts +1 -0
  174. package/dist/components/popover/index.js +1 -0
  175. package/dist/components/popover/popover.d.ts +18 -0
  176. package/dist/components/popover/popover.js +141 -0
  177. package/dist/components/popover/popover.stories.js +45 -0
  178. package/dist/components/progress/index.d.ts +1 -0
  179. package/dist/components/progress/index.js +1 -0
  180. package/dist/components/progress/progress.d.ts +7 -0
  181. package/dist/components/progress/progress.js +21 -0
  182. package/dist/components/progress/progress.stories.js +16 -0
  183. package/dist/components/providers/component-provider.d.ts +2 -0
  184. package/dist/components/providers/component-provider.js +9 -0
  185. package/dist/components/providers/index.d.ts +2 -0
  186. package/dist/components/providers/index.js +2 -0
  187. package/dist/components/providers/portal-root.d.ts +5 -0
  188. package/dist/components/providers/portal-root.js +17 -0
  189. package/dist/components/scroll-linked/index.d.ts +1 -0
  190. package/dist/components/scroll-linked/index.js +1 -0
  191. package/dist/components/scroll-linked/scroll-linked.d.ts +2 -0
  192. package/dist/components/scroll-linked/scroll-linked.js +21 -0
  193. package/dist/components/scroll-linked/scroll-linked.stories.js +18 -0
  194. package/dist/components/separator/index.d.ts +1 -0
  195. package/dist/components/separator/index.js +1 -0
  196. package/dist/components/separator/separator.d.ts +4 -0
  197. package/dist/components/separator/separator.js +20 -0
  198. package/dist/components/separator/separator.stories.js +27 -0
  199. package/dist/components/tabs/index.d.ts +1 -0
  200. package/dist/components/tabs/index.js +1 -0
  201. package/dist/components/tabs/tabs.d.ts +16 -0
  202. package/dist/components/tabs/tabs.js +145 -0
  203. package/dist/components/tabs/tabs.stories.js +49 -0
  204. package/dist/components/text-tag/index.d.ts +1 -0
  205. package/dist/components/text-tag/index.js +1 -0
  206. package/dist/components/text-tag/text-tag.d.ts +5 -0
  207. package/dist/components/text-tag/text-tag.js +23 -0
  208. package/dist/components/text-tag/text-tag.stories.js +30 -0
  209. package/dist/components/toast/index.d.ts +1 -0
  210. package/dist/components/toast/index.js +5 -0
  211. package/dist/components/toast/provider.d.ts +11 -0
  212. package/dist/components/toast/provider.js +125 -0
  213. package/dist/components/toast/toast.d.ts +9 -0
  214. package/dist/components/toast/toast.js +19 -0
  215. package/dist/components/toast/toast.stories.js +45 -0
  216. package/dist/components/tooltip/index.d.ts +1 -0
  217. package/dist/components/tooltip/index.js +1 -0
  218. package/dist/components/tooltip/tooltip.d.ts +13 -0
  219. package/dist/components/tooltip/tooltip.js +60 -0
  220. package/dist/components/tooltip/tooltip.stories.js +40 -0
  221. package/dist/helpers/cn.d.ts +2 -0
  222. package/dist/helpers/cn.js +8 -0
  223. package/dist/helpers/color/find-all-colors.d.ts +12 -0
  224. package/dist/helpers/color/find-all-colors.js +210 -0
  225. package/dist/helpers/is-internal-route.d.ts +1 -0
  226. package/dist/helpers/is-internal-route.js +12 -0
  227. package/dist/helpers/number/between.d.ts +1 -0
  228. package/dist/helpers/number/between.js +19 -0
  229. package/dist/helpers/number/cast.d.ts +1 -0
  230. package/dist/helpers/number/cast.js +41 -0
  231. package/dist/helpers/number/commalize.d.ts +1 -0
  232. package/dist/helpers/number/commalize.js +22 -0
  233. package/dist/helpers/number/index.d.ts +4 -0
  234. package/dist/helpers/number/index.js +10 -0
  235. package/dist/helpers/number/to-precision.d.ts +1 -0
  236. package/dist/helpers/number/to-precision.js +17 -0
  237. package/dist/helpers/uuid-v4.d.ts +1 -0
  238. package/dist/helpers/uuid-v4.js +32 -0
  239. package/dist/hooks/click-away/index.d.ts +2 -0
  240. package/dist/hooks/click-away/index.js +24 -0
  241. package/dist/hooks/click-away/index.test.js +31 -0
  242. package/dist/hooks/client/index.d.ts +1 -0
  243. package/dist/hooks/client/index.js +12 -0
  244. package/dist/hooks/clipboard/index.d.ts +4 -0
  245. package/dist/hooks/clipboard/index.js +17 -0
  246. package/dist/hooks/clipboard/index.test.js +35 -0
  247. package/dist/hooks/hash/index.d.ts +1 -0
  248. package/dist/hooks/hash/index.js +28 -0
  249. package/dist/hooks/hash/index.test.js +46 -0
  250. package/dist/hooks/index.d.ts +10 -0
  251. package/dist/hooks/index.js +10 -0
  252. package/dist/hooks/interval/index.d.ts +1 -0
  253. package/dist/hooks/interval/index.js +17 -0
  254. package/dist/hooks/interval/index.test.js +32 -0
  255. package/dist/hooks/local-storage/index.d.ts +1 -0
  256. package/dist/hooks/local-storage/index.js +48 -0
  257. package/dist/hooks/local-storage/index.test.js +82 -0
  258. package/dist/hooks/scroll-direction/index.d.ts +6 -0
  259. package/dist/hooks/scroll-direction/index.js +40 -0
  260. package/dist/hooks/scroll-direction/index.test.js +174 -0
  261. package/dist/hooks/step/index.d.ts +13 -0
  262. package/dist/hooks/step/index.js +39 -0
  263. package/dist/hooks/step/index.test.js +85 -0
  264. package/dist/hooks/timeout/index.d.ts +1 -0
  265. package/dist/hooks/timeout/index.js +17 -0
  266. package/dist/hooks/timeout/index.test.js +31 -0
  267. package/dist/hooks/window-size/index.d.ts +6 -0
  268. package/dist/hooks/window-size/index.js +22 -0
  269. package/dist/hooks/window-size/index.test.js +18 -0
  270. package/dist/index.d.ts +2 -0
  271. package/dist/index.js +2 -0
  272. package/dist/package.json +6 -0
  273. package/dist/styles/index.css +394 -0
  274. package/dist/types/variables.d.ts +6 -0
  275. package/dist/types/variables.js +0 -0
  276. package/package.json +110 -0
@@ -0,0 +1,59 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Autocomplete } from "./autocomplete";
4
+ const meta = {
5
+ title: "components/form/autocomplete",
6
+ component: Autocomplete,
7
+ render: (props) => {
8
+ const options = [
9
+ { value: "2", label: "2\u9032\u6570" },
10
+ { value: "8", label: "8\u9032\u6570" },
11
+ { value: "10", label: "10\u9032\u6570" },
12
+ { value: "16", label: "16\u9032\u6570" }
13
+ ];
14
+ const [value, setValue] = useState([]);
15
+ return /* @__PURE__ */ jsx(
16
+ Autocomplete,
17
+ {
18
+ ...props,
19
+ onChange: setValue,
20
+ options,
21
+ value
22
+ }
23
+ );
24
+ }
25
+ };
26
+ var autocomplete_stories_default = meta;
27
+ const Default = {
28
+ args: {
29
+ id: "autocomplete",
30
+ describedbyId: void 0,
31
+ isInvalid: false,
32
+ isDisabled: false,
33
+ isRequired: false
34
+ }
35
+ };
36
+ const Invalid = {
37
+ args: {
38
+ id: "autocomplete",
39
+ describedbyId: void 0,
40
+ isInvalid: true,
41
+ isDisabled: false,
42
+ isRequired: true
43
+ }
44
+ };
45
+ const Disabled = {
46
+ args: {
47
+ id: "autocomplete",
48
+ describedbyId: void 0,
49
+ isInvalid: false,
50
+ isDisabled: true,
51
+ isRequired: true
52
+ }
53
+ };
54
+ export {
55
+ Default,
56
+ Disabled,
57
+ Invalid,
58
+ autocomplete_stories_default as default
59
+ };
@@ -0,0 +1 @@
1
+ export * from './autocomplete';
@@ -0,0 +1 @@
1
+ export * from "./autocomplete";
@@ -0,0 +1,8 @@
1
+ import { type ChangeEventHandler, type FC } from 'react';
2
+ type Props = {
3
+ label: string;
4
+ value: boolean;
5
+ onChange: ChangeEventHandler<HTMLInputElement>;
6
+ };
7
+ export declare const Checkbox: FC<Props>;
8
+ export {};
@@ -0,0 +1,40 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { cn } from "./../../../helpers/cn";
4
+ import { CheckIcon } from "../../icons";
5
+ const Checkbox = ({ label, value, onChange }) => {
6
+ const [isFocus, setIsFocus] = useState(false);
7
+ return /* @__PURE__ */ jsxs("label", { className: "inline-flex cursor-pointer items-center gap-2", children: [
8
+ /* @__PURE__ */ jsx(
9
+ "input",
10
+ {
11
+ checked: value,
12
+ className: "sr-only",
13
+ onBlur: () => {
14
+ setIsFocus(false);
15
+ },
16
+ onChange,
17
+ onFocus: () => {
18
+ setIsFocus(true);
19
+ },
20
+ type: "checkbox"
21
+ }
22
+ ),
23
+ /* @__PURE__ */ jsx(
24
+ "span",
25
+ {
26
+ "aria-hidden": true,
27
+ className: cn(
28
+ "inline-flex size-5 items-center justify-center rounded-md border-2",
29
+ isFocus && "bordertransparent outline-hidden ring-2 ring-border-info",
30
+ value ? "border-border-base bg-primary-bg text-fg-base" : "border-border-mute bg-bg-base"
31
+ ),
32
+ children: value ? /* @__PURE__ */ jsx(CheckIcon, { size: "sm" }) : null
33
+ }
34
+ ),
35
+ /* @__PURE__ */ jsx("span", { className: "text-lg", children: label })
36
+ ] });
37
+ };
38
+ export {
39
+ Checkbox
40
+ };
@@ -0,0 +1,27 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Checkbox } from "./checkbox";
4
+ const meta = {
5
+ title: "components/form/checkbox",
6
+ component: Checkbox
7
+ };
8
+ var checkbox_stories_default = meta;
9
+ const Default = {
10
+ render: () => {
11
+ const [value, setValue] = useState(false);
12
+ return /* @__PURE__ */ jsx(
13
+ Checkbox,
14
+ {
15
+ label: "checkbox",
16
+ onChange: (e) => {
17
+ setValue(e.target.checked);
18
+ },
19
+ value
20
+ }
21
+ );
22
+ }
23
+ };
24
+ export {
25
+ Default,
26
+ checkbox_stories_default as default
27
+ };
@@ -0,0 +1 @@
1
+ export * from './checkbox';
@@ -0,0 +1 @@
1
+ export * from "./checkbox";
@@ -0,0 +1,20 @@
1
+ import { type FC, type ReactElement } from 'react';
2
+ type FormControlProps = {
3
+ isDisabled?: boolean;
4
+ isInvalid?: boolean;
5
+ isRequired?: boolean;
6
+ label: string;
7
+ labelAs?: 'label' | 'legend';
8
+ helpText?: string;
9
+ errorText?: string | undefined;
10
+ renderInput: (props: {
11
+ id: string;
12
+ describedbyId: string | undefined;
13
+ labelId: string;
14
+ isDisabled: boolean;
15
+ isInvalid: boolean;
16
+ isRequired: boolean;
17
+ }) => ReactElement;
18
+ };
19
+ export declare const FormControl: FC<FormControlProps>;
20
+ export {};
@@ -0,0 +1,53 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useId } from "react";
3
+ const FormControl = ({
4
+ isDisabled = false,
5
+ isInvalid = false,
6
+ isRequired = false,
7
+ label,
8
+ labelAs = "label",
9
+ helpText,
10
+ errorText,
11
+ renderInput
12
+ }) => {
13
+ const id = useId();
14
+ const describedbyId = isInvalid && errorText ? `${id}-feedback` : helpText ? `${id}-helptext` : void 0;
15
+ const labelId = `${id}-label`;
16
+ return /* @__PURE__ */ jsxs("fieldset", { className: "flex w-full flex-col", children: [
17
+ labelAs === "label" ? /* @__PURE__ */ jsxs(
18
+ "label",
19
+ {
20
+ className: "mb-1 flex gap-2 font-bold text-fg-base text-md",
21
+ htmlFor: id,
22
+ id: labelId,
23
+ children: [
24
+ label,
25
+ isRequired && /* @__PURE__ */ jsx("span", { className: "font-medium text-fg-error", children: "\u5FC5\u9808" })
26
+ ]
27
+ }
28
+ ) : /* @__PURE__ */ jsxs("legend", { className: "mb-1 flex gap-2 font-bold text-fg-base text-md", children: [
29
+ label,
30
+ isRequired && /* @__PURE__ */ jsx("span", { className: "font-medium text-fg-error", children: "\u5FC5\u9808" })
31
+ ] }),
32
+ renderInput({
33
+ id,
34
+ describedbyId,
35
+ labelId,
36
+ isDisabled,
37
+ isInvalid,
38
+ isRequired
39
+ }),
40
+ isInvalid && errorText ? /* @__PURE__ */ jsx(
41
+ "p",
42
+ {
43
+ "aria-live": "polite",
44
+ className: "text-fg-error text-sm",
45
+ id: `${id}-feedback`,
46
+ children: errorText
47
+ }
48
+ ) : helpText && /* @__PURE__ */ jsx("p", { className: "text-fg-mute text-sm", id: `${id}-helptext`, children: helpText })
49
+ ] });
50
+ };
51
+ export {
52
+ FormControl
53
+ };
@@ -0,0 +1,94 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { TextField } from "../text-field";
4
+ import { FormControl } from "./form-control";
5
+ const meta = {
6
+ title: "components/form/form-control",
7
+ component: FormControl,
8
+ args: {
9
+ renderInput: (props) => {
10
+ const [state, setState] = useState("");
11
+ return /* @__PURE__ */ jsx(
12
+ TextField,
13
+ {
14
+ ...props,
15
+ onChange: (e) => {
16
+ setState(e.target.value);
17
+ },
18
+ value: state
19
+ }
20
+ );
21
+ }
22
+ }
23
+ };
24
+ var form_control_stories_default = meta;
25
+ const Default = {
26
+ args: {
27
+ label: "\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9"
28
+ }
29
+ };
30
+ const HelpText = {
31
+ args: {
32
+ label: "\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",
33
+ helpText: "RFC\u306B\u6E96\u62E0\u3057\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002"
34
+ }
35
+ };
36
+ const Required = {
37
+ args: {
38
+ label: "\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",
39
+ helpText: "RFC\u306B\u6E96\u62E0\u3057\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
40
+ isRequired: true
41
+ }
42
+ };
43
+ const Error = {
44
+ args: {
45
+ label: "\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",
46
+ helpText: "RFC\u306B\u6E96\u62E0\u3057\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
47
+ isInvalid: true,
48
+ errorText: "\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u304C\u6B63\u3057\u304F\u3042\u308A\u307E\u305B\u3093\u3002",
49
+ isRequired: true
50
+ }
51
+ };
52
+ const ErrorWithoutText = {
53
+ args: {
54
+ label: "\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",
55
+ helpText: "RFC\u306B\u6E96\u62E0\u3057\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
56
+ isInvalid: true,
57
+ isRequired: true
58
+ }
59
+ };
60
+ const Disabled = {
61
+ args: {
62
+ label: "\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",
63
+ helpText: "RFC\u306B\u6E96\u62E0\u3057\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
64
+ isDisabled: true
65
+ }
66
+ };
67
+ const Legend = {
68
+ args: {
69
+ label: "\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9",
70
+ helpText: "RFC\u306B\u6E96\u62E0\u3057\u305F\u30E1\u30FC\u30EB\u30A2\u30C9\u30EC\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044\u3002",
71
+ labelAs: "legend"
72
+ },
73
+ parameters: {
74
+ a11y: {
75
+ options: {
76
+ rules: {
77
+ // labelが不要なケースに使うのでoffにする
78
+ label: { enabled: false },
79
+ "label-title-only": { enabled: false }
80
+ }
81
+ }
82
+ }
83
+ }
84
+ };
85
+ export {
86
+ Default,
87
+ Disabled,
88
+ Error,
89
+ ErrorWithoutText,
90
+ HelpText,
91
+ Legend,
92
+ Required,
93
+ form_control_stories_default as default
94
+ };
@@ -0,0 +1 @@
1
+ export * from './form-control';
@@ -0,0 +1 @@
1
+ export * from "./form-control";
@@ -0,0 +1 @@
1
+ export * from './number-field';
@@ -0,0 +1 @@
1
+ export * from "./number-field";
@@ -0,0 +1,17 @@
1
+ import { type FC } from 'react';
2
+ type Props = {
3
+ id?: string;
4
+ describedbyId?: string | undefined;
5
+ isInvalid: boolean;
6
+ isDisabled: boolean;
7
+ isRequired: boolean;
8
+ value: number;
9
+ onChange: (value: number) => void;
10
+ step?: number;
11
+ precision?: number;
12
+ max?: number;
13
+ min?: number;
14
+ placeholder?: string;
15
+ };
16
+ export declare const NumberField: FC<Props>;
17
+ export {};
@@ -0,0 +1,150 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { cn } from "./../../../helpers/cn";
4
+ import { between, cast, toPrecision } from "./../../../helpers/number";
5
+ import { MinusIcon, PlusIcon } from "../../icons";
6
+ const NumberField = ({
7
+ id,
8
+ describedbyId,
9
+ isInvalid,
10
+ isDisabled,
11
+ isRequired,
12
+ value,
13
+ onChange,
14
+ step = 1,
15
+ precision = 0,
16
+ max = 9007199254740991,
17
+ min = -9007199254740991,
18
+ placeholder
19
+ }) => {
20
+ const [displayValue, setDisplayValue] = useState(value.toFixed(precision));
21
+ const [prevValue, setPrevValue] = useState(value);
22
+ if (value !== prevValue) {
23
+ setDisplayValue(value.toFixed(precision));
24
+ setPrevValue(value);
25
+ }
26
+ return /* @__PURE__ */ jsxs(
27
+ "div",
28
+ {
29
+ className: cn(
30
+ "relative flex h-12 w-full items-center justify-between gap-2 rounded-md border border-border-base bg-bg-base shadow-xs",
31
+ "focus-within:bordertransparent focus-within:outline-hidden focus-within:ring-2 focus-within:ring-border-info",
32
+ "has-aria-invalid:border-border-error",
33
+ "has-disabled:cursor-not-allowed has-disabled:border-border-mute has-disabled:bg-bg-mute has-disabled:has-hover:hover:bg-bg-mute"
34
+ ),
35
+ children: [
36
+ /* @__PURE__ */ jsx(
37
+ "input",
38
+ {
39
+ "aria-describedby": describedbyId,
40
+ "aria-invalid": isInvalid,
41
+ "aria-required": isRequired,
42
+ "aria-valuemax": max,
43
+ "aria-valuemin": min,
44
+ "aria-valuenow": value,
45
+ autoComplete: "off",
46
+ autoCorrect: "off",
47
+ className: cn(
48
+ "h-full w-full grow bg-transparent pr-8 pl-3 focus-visible:outline-hidden",
49
+ "disabled:cursor-not-allowed"
50
+ ),
51
+ disabled: isDisabled,
52
+ id,
53
+ inputMode: "decimal",
54
+ onBlur: () => {
55
+ const newValue = between(cast(displayValue, precision), min, max);
56
+ onChange(newValue);
57
+ setDisplayValue(newValue.toFixed(precision));
58
+ },
59
+ onChange: (e) => {
60
+ if (e.nativeEvent.isComposing) {
61
+ return;
62
+ }
63
+ setDisplayValue(e.target.value);
64
+ },
65
+ onKeyDown: (e) => {
66
+ if (e.key === "ArrowUp") {
67
+ const newValue = between(
68
+ toPrecision(cast(displayValue, precision) + step, precision),
69
+ min,
70
+ max
71
+ );
72
+ onChange(newValue);
73
+ setDisplayValue(newValue.toFixed(precision));
74
+ }
75
+ if (e.key === "ArrowDown") {
76
+ const newValue = between(
77
+ toPrecision(cast(displayValue, precision) - step, precision),
78
+ min,
79
+ max
80
+ );
81
+ onChange(newValue);
82
+ setDisplayValue(newValue.toFixed(precision));
83
+ }
84
+ },
85
+ pattern: "[0-9]*(.[0-9]+)?",
86
+ placeholder,
87
+ role: "spinbutton",
88
+ type: "text",
89
+ value: displayValue
90
+ }
91
+ ),
92
+ /* @__PURE__ */ jsxs("div", { "aria-hidden": "true", className: "absolute right-0 flex h-full flex-col", children: [
93
+ /* @__PURE__ */ jsxs(
94
+ "button",
95
+ {
96
+ className: cn(
97
+ "flex w-6 grow items-center justify-center rounded-tr-sm border-border-base border-b border-l bg-bg-mute",
98
+ "disabled:cursor-not-allowed"
99
+ ),
100
+ disabled: isDisabled,
101
+ onClick: () => {
102
+ const newValue = between(
103
+ toPrecision(cast(displayValue, precision) + step, precision),
104
+ min,
105
+ max
106
+ );
107
+ onChange(newValue);
108
+ setDisplayValue(newValue.toFixed(precision));
109
+ },
110
+ tabIndex: -1,
111
+ type: "button",
112
+ children: [
113
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "\u5897\u3084\u3059" }),
114
+ /* @__PURE__ */ jsx(PlusIcon, { size: "sm" })
115
+ ]
116
+ }
117
+ ),
118
+ /* @__PURE__ */ jsxs(
119
+ "button",
120
+ {
121
+ className: cn(
122
+ "flex w-6 grow items-center justify-center rounded-br-sm border-border-base border-l bg-bg-mute",
123
+ "disabled:cursor-not-allowed"
124
+ ),
125
+ disabled: isDisabled,
126
+ onClick: () => {
127
+ const newValue = between(
128
+ toPrecision(cast(displayValue, precision) - step, precision),
129
+ min,
130
+ max
131
+ );
132
+ onChange(newValue);
133
+ setDisplayValue(newValue.toFixed(precision));
134
+ },
135
+ tabIndex: -1,
136
+ type: "button",
137
+ children: [
138
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "\u6E1B\u3089\u3059" }),
139
+ /* @__PURE__ */ jsx(MinusIcon, { size: "sm" })
140
+ ]
141
+ }
142
+ )
143
+ ] })
144
+ ]
145
+ }
146
+ );
147
+ };
148
+ export {
149
+ NumberField
150
+ };
@@ -0,0 +1,106 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { expect } from "storybook/test";
4
+ import { NumberField } from "./number-field";
5
+ const meta = {
6
+ title: "components/form/number-field",
7
+ component: NumberField,
8
+ args: {
9
+ id: "textfield",
10
+ describedbyId: "numberfield-feedback"
11
+ },
12
+ render: (args) => {
13
+ const [value, setValue] = useState(0);
14
+ return /* @__PURE__ */ jsx(NumberField, { ...args, onChange: setValue, value });
15
+ },
16
+ parameters: {
17
+ a11y: {
18
+ options: {
19
+ rules: {
20
+ // NumberField単体ではラベルを付随しない
21
+ "label-title-only": { enabled: false },
22
+ label: { enabled: false }
23
+ }
24
+ }
25
+ }
26
+ }
27
+ };
28
+ var number_field_stories_default = meta;
29
+ const Default = {
30
+ args: {
31
+ isDisabled: false,
32
+ isInvalid: false,
33
+ isRequired: false
34
+ },
35
+ play: async ({ canvas, userEvent }) => {
36
+ const input = canvas.getByRole("spinbutton");
37
+ await userEvent.type(input, "2.0[Tab]");
38
+ await expect(input).toHaveValue("2");
39
+ await userEvent.click(input);
40
+ await userEvent.keyboard("{ArrowUp}");
41
+ await userEvent.keyboard("{ArrowDown}");
42
+ await userEvent.keyboard("{ArrowDown}");
43
+ await userEvent.keyboard("{ArrowDown}");
44
+ await expect(input).toHaveValue("0");
45
+ }
46
+ };
47
+ const Min0Max100 = {
48
+ args: {
49
+ isDisabled: false,
50
+ isInvalid: false,
51
+ isRequired: false,
52
+ min: 0,
53
+ max: 100
54
+ },
55
+ play: async ({ canvas, userEvent }) => {
56
+ const input = canvas.getByRole("spinbutton");
57
+ await userEvent.type(input, "-10[Tab]");
58
+ await expect(input).toHaveValue("0");
59
+ await userEvent.keyboard("{ArrowDown}");
60
+ await expect(input).toHaveValue("0");
61
+ await userEvent.type(input, "111[Tab]");
62
+ await expect(input).toHaveValue("100");
63
+ await userEvent.keyboard("{ArrowUp}");
64
+ await expect(input).toHaveValue("100");
65
+ }
66
+ };
67
+ const Precision = {
68
+ args: {
69
+ isDisabled: false,
70
+ isInvalid: false,
71
+ isRequired: false,
72
+ precision: 2,
73
+ step: 0.01
74
+ }
75
+ };
76
+ const Placeholder = {
77
+ args: {
78
+ isDisabled: false,
79
+ isInvalid: false,
80
+ isRequired: false,
81
+ placeholder: "10.2"
82
+ }
83
+ };
84
+ const Invalid = {
85
+ args: {
86
+ isDisabled: false,
87
+ isInvalid: true,
88
+ isRequired: false
89
+ }
90
+ };
91
+ const Disabled = {
92
+ args: {
93
+ isDisabled: true,
94
+ isInvalid: false,
95
+ isRequired: false
96
+ }
97
+ };
98
+ export {
99
+ Default,
100
+ Disabled,
101
+ Invalid,
102
+ Min0Max100,
103
+ Placeholder,
104
+ Precision,
105
+ number_field_stories_default as default
106
+ };
@@ -0,0 +1 @@
1
+ export * from './radio';
@@ -0,0 +1 @@
1
+ export * from "./radio";
@@ -0,0 +1,11 @@
1
+ import type { ChangeEventHandler, FC } from 'react';
2
+ import type { Option } from '../../../types/variables';
3
+ type Props = {
4
+ labelId: string;
5
+ isDisabled: boolean;
6
+ value: string;
7
+ onChange: ChangeEventHandler<HTMLInputElement>;
8
+ options: readonly Option[];
9
+ };
10
+ export declare const Radio: FC<Props>;
11
+ export {};
@@ -0,0 +1,51 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { cn } from "./../../../helpers/cn";
3
+ const Radio = ({
4
+ labelId,
5
+ isDisabled,
6
+ value,
7
+ onChange,
8
+ options
9
+ }) => {
10
+ return /* @__PURE__ */ jsx(
11
+ "div",
12
+ {
13
+ "aria-labelledby": labelId,
14
+ className: cn(
15
+ "flex cursor-pointer flex-col gap-2",
16
+ isDisabled && "cursor-not-allowed"
17
+ ),
18
+ role: "radiogroup",
19
+ children: options.map((option) => /* @__PURE__ */ jsxs(
20
+ "label",
21
+ {
22
+ className: cn(
23
+ "flex cursor-pointer items-center gap-2",
24
+ "has-disabled:cursor-not-allowed"
25
+ ),
26
+ children: [
27
+ /* @__PURE__ */ jsx(
28
+ "input",
29
+ {
30
+ checked: value === option.value,
31
+ className: cn(
32
+ "cursor-pointer",
33
+ "disabled:cursor-not-allowed disabled:bg-bg-mute"
34
+ ),
35
+ disabled: isDisabled,
36
+ onChange,
37
+ type: "radio",
38
+ value: option.value
39
+ }
40
+ ),
41
+ /* @__PURE__ */ jsx("span", { children: option.label })
42
+ ]
43
+ },
44
+ option.value
45
+ ))
46
+ }
47
+ );
48
+ };
49
+ export {
50
+ Radio
51
+ };