@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,27 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Separator } from "./separator";
3
+ const meta = {
4
+ title: "components/separator",
5
+ component: Separator,
6
+ decorators: [
7
+ (Story) => {
8
+ return /* @__PURE__ */ jsx("div", { className: "size-40", children: /* @__PURE__ */ jsx(Story, {}) });
9
+ }
10
+ ]
11
+ };
12
+ var separator_stories_default = meta;
13
+ const Horizontal = {
14
+ args: {
15
+ orientation: "horizontal"
16
+ }
17
+ };
18
+ const Vertical = {
19
+ args: {
20
+ orientation: "vertical"
21
+ }
22
+ };
23
+ export {
24
+ Horizontal,
25
+ Vertical,
26
+ separator_stories_default as default
27
+ };
@@ -0,0 +1 @@
1
+ export * from './tabs';
@@ -0,0 +1 @@
1
+ export * from "./tabs";
@@ -0,0 +1,16 @@
1
+ import { type FC, type PropsWithChildren } from 'react';
2
+ export declare const Tabs: {
3
+ Root: FC<PropsWithChildren<{
4
+ defaultSelectedId?: string | null;
5
+ ids: [string, ...string[]];
6
+ }>>;
7
+ List: FC<PropsWithChildren<{
8
+ label: string;
9
+ }>>;
10
+ Tab: FC<PropsWithChildren<{
11
+ id: string;
12
+ }>>;
13
+ Panel: FC<PropsWithChildren<{
14
+ id: string;
15
+ }>>;
16
+ };
@@ -0,0 +1,145 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import * as motion from "motion/react-client";
4
+ import {
5
+ createContext,
6
+ use,
7
+ useEffect,
8
+ useId,
9
+ useRef,
10
+ useState
11
+ } from "react";
12
+ import { cn } from "./../../helpers/cn";
13
+ const TabsProvider = createContext(void 0);
14
+ const useTabsState = () => {
15
+ const context = use(TabsProvider);
16
+ if (!context) {
17
+ throw new Error("useTabsState must be used within a TabsProvider");
18
+ }
19
+ return context;
20
+ };
21
+ const Root = ({ defaultSelectedId = null, ids, children }) => {
22
+ const defaultIndex = defaultSelectedId ? ids.indexOf(defaultSelectedId) : 0;
23
+ const [selectedId, setSelectedId] = useState(
24
+ defaultSelectedId ?? ids[defaultIndex] ?? ids[0]
25
+ );
26
+ const rootId = useId();
27
+ return /* @__PURE__ */ jsx(
28
+ TabsProvider,
29
+ {
30
+ value: {
31
+ rootId,
32
+ ids,
33
+ selectedId,
34
+ setSelectedId
35
+ },
36
+ children: /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1 overflow-x-auto p-0.5", children })
37
+ }
38
+ );
39
+ };
40
+ const TabsListProvider = createContext(void 0);
41
+ const useTabsListState = () => {
42
+ const context = use(TabsListProvider);
43
+ if (!context) {
44
+ throw new Error("useTabListState must be used within a TabListProvider");
45
+ }
46
+ return context;
47
+ };
48
+ const List = ({ label, children }) => {
49
+ const { rootId } = useTabsState();
50
+ const setFocusRef = useRef(false);
51
+ return /* @__PURE__ */ jsx(
52
+ "div",
53
+ {
54
+ "aria-label": label,
55
+ "aria-orientation": "horizontal",
56
+ className: "wrap-normal flex overflow-x-auto overflow-y-hidden border-border-base border-b p-0.5",
57
+ id: `${rootId}-tablist`,
58
+ role: "tablist",
59
+ children: /* @__PURE__ */ jsx(TabsListProvider, { value: { setFocusRef }, children })
60
+ }
61
+ );
62
+ };
63
+ const Tab = ({ id, children }) => {
64
+ const { rootId, ids, selectedId, setSelectedId } = useTabsState();
65
+ const { setFocusRef } = useTabsListState();
66
+ const ref = useRef(null);
67
+ const activeIndex = ids.indexOf(selectedId);
68
+ const index = ids.indexOf(id);
69
+ useEffect(() => {
70
+ if (activeIndex === index && setFocusRef.current) {
71
+ ref.current?.focus();
72
+ setFocusRef.current = false;
73
+ }
74
+ }, [activeIndex, index, setFocusRef]);
75
+ return /* @__PURE__ */ jsxs(
76
+ "div",
77
+ {
78
+ "aria-controls": selectedId === id ? `${rootId}-panel-${id}` : void 0,
79
+ "aria-selected": selectedId === id,
80
+ className: cn(
81
+ "relative cursor-pointer rounded-md p-2",
82
+ "focus-visible:border-transparent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-border-info"
83
+ ),
84
+ id: `${rootId}-tab-${id}`,
85
+ onClick: () => {
86
+ setSelectedId(id);
87
+ },
88
+ onKeyDown: (e) => {
89
+ if (e.key === "ArrowLeft") {
90
+ const nextActiveIndex = index === 0 ? ids.length - 1 : index - 1;
91
+ setSelectedId(ids[nextActiveIndex] ?? ids[0]);
92
+ setFocusRef.current = true;
93
+ return;
94
+ }
95
+ if (e.key === "ArrowRight") {
96
+ const nextActiveIndex = index === ids.length - 1 ? 0 : index + 1;
97
+ setSelectedId(ids[nextActiveIndex] ?? ids[0]);
98
+ setFocusRef.current = true;
99
+ return;
100
+ }
101
+ },
102
+ ref,
103
+ role: "tab",
104
+ tabIndex: activeIndex === index ? 0 : -1,
105
+ children: [
106
+ selectedId === id && /* @__PURE__ */ jsx(
107
+ motion.div,
108
+ {
109
+ className: "-bottom-0.5 absolute right-0 left-0 h-1 bg-primary-border",
110
+ layoutId: "underline"
111
+ }
112
+ ),
113
+ children
114
+ ]
115
+ }
116
+ );
117
+ };
118
+ const Panel = ({ id, children }) => {
119
+ const { rootId, selectedId } = useTabsState();
120
+ if (selectedId !== id) {
121
+ return null;
122
+ }
123
+ return /* @__PURE__ */ jsx(
124
+ "div",
125
+ {
126
+ "aria-labelledby": `${rootId}-tab-${id}`,
127
+ className: cn(
128
+ "flex-grow rounded-md p-2",
129
+ "focus-visible:border-transparent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-border-info"
130
+ ),
131
+ id: `${rootId}-panel-${id}`,
132
+ role: "tabpanel",
133
+ children
134
+ }
135
+ );
136
+ };
137
+ const Tabs = {
138
+ Root,
139
+ List,
140
+ Tab,
141
+ Panel
142
+ };
143
+ export {
144
+ Tabs
145
+ };
@@ -0,0 +1,49 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { expect } from "storybook/test";
3
+ import { Tabs } from "./tabs";
4
+ const meta = {
5
+ title: "components/tabs",
6
+ component: Tabs.Root
7
+ };
8
+ var tabs_stories_default = meta;
9
+ const Primary = {
10
+ render: () => /* @__PURE__ */ jsxs(Tabs.Root, { ids: ["tab1", "tab2", "tab3"], children: [
11
+ /* @__PURE__ */ jsxs(Tabs.List, { label: "Tabs Example", children: [
12
+ /* @__PURE__ */ jsx(Tabs.Tab, { id: "tab1", children: "Tab1" }),
13
+ /* @__PURE__ */ jsx(Tabs.Tab, { id: "tab2", children: "Tab2" }),
14
+ /* @__PURE__ */ jsx(Tabs.Tab, { id: "tab3", children: "Tab3" })
15
+ ] }),
16
+ /* @__PURE__ */ jsx(Tabs.Panel, { id: "tab1", children: "Panel1" }),
17
+ /* @__PURE__ */ jsx(Tabs.Panel, { id: "tab2", children: "Panel2" }),
18
+ /* @__PURE__ */ jsx(Tabs.Panel, { id: "tab3", children: "Panel3" })
19
+ ] }),
20
+ play: async ({ canvas, userEvent }) => {
21
+ const tab2 = canvas.getByRole("tab", { name: "Tab2" });
22
+ const tab3 = canvas.getByRole("tab", { name: "Tab3" });
23
+ await expect(canvas.getByRole("tabpanel")).toHaveTextContent("Panel1");
24
+ await userEvent.click(tab2);
25
+ await expect(canvas.getByRole("tabpanel")).toHaveTextContent("Panel2");
26
+ await userEvent.click(tab3);
27
+ await expect(canvas.getByRole("tabpanel")).toHaveTextContent("Panel3");
28
+ }
29
+ };
30
+ const DefaultSelected = {
31
+ render: () => /* @__PURE__ */ jsxs(Tabs.Root, { defaultSelectedId: "tab2", ids: ["tab1", "tab2", "tab3"], children: [
32
+ /* @__PURE__ */ jsxs(Tabs.List, { label: "Tabs Example", children: [
33
+ /* @__PURE__ */ jsx(Tabs.Tab, { id: "tab1", children: "Tab1" }),
34
+ /* @__PURE__ */ jsx(Tabs.Tab, { id: "tab2", children: "Tab2" }),
35
+ /* @__PURE__ */ jsx(Tabs.Tab, { id: "tab3", children: "Tab3" })
36
+ ] }),
37
+ /* @__PURE__ */ jsx(Tabs.Panel, { id: "tab1", children: "Panel1" }),
38
+ /* @__PURE__ */ jsx(Tabs.Panel, { id: "tab2", children: "Panel2" }),
39
+ /* @__PURE__ */ jsx(Tabs.Panel, { id: "tab3", children: "Panel3" })
40
+ ] }),
41
+ play: async ({ canvas }) => {
42
+ await expect(canvas.getByRole("tabpanel")).toHaveTextContent("Panel2");
43
+ }
44
+ };
45
+ export {
46
+ DefaultSelected,
47
+ Primary,
48
+ tabs_stories_default as default
49
+ };
@@ -0,0 +1 @@
1
+ export * from './text-tag';
@@ -0,0 +1 @@
1
+ export * from "./text-tag";
@@ -0,0 +1,5 @@
1
+ export declare const TextTag: ({ text, size, clickable, }: {
2
+ text: string;
3
+ size?: "sm" | "md";
4
+ clickable?: boolean;
5
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,23 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { cn } from "./../../helpers/cn";
3
+ const TextTag = ({
4
+ text,
5
+ size = "md",
6
+ clickable = false
7
+ }) => {
8
+ return /* @__PURE__ */ jsx(
9
+ "span",
10
+ {
11
+ className: cn(
12
+ "inline-block rounded-full bg-bg-mute font-medium",
13
+ clickable && "cursor-pointer hover:bg-bg-emphasize",
14
+ size === "sm" && "px-2 py-0.5 text-xs",
15
+ size === "md" && "px-3 py-1 text-sm"
16
+ ),
17
+ children: text
18
+ }
19
+ );
20
+ };
21
+ export {
22
+ TextTag
23
+ };
@@ -0,0 +1,30 @@
1
+ import { TextTag } from "./text-tag";
2
+ const meta = {
3
+ title: "components/text-tag",
4
+ component: TextTag
5
+ };
6
+ var text_tag_stories_default = meta;
7
+ const Medium = {
8
+ args: {
9
+ text: "TypeScript",
10
+ size: "md"
11
+ }
12
+ };
13
+ const Clickable = {
14
+ args: {
15
+ text: "TypeScript",
16
+ clickable: true
17
+ }
18
+ };
19
+ const Small = {
20
+ args: {
21
+ text: "TypeScript",
22
+ size: "sm"
23
+ }
24
+ };
25
+ export {
26
+ Clickable,
27
+ Medium,
28
+ Small,
29
+ text_tag_stories_default as default
30
+ };
@@ -0,0 +1 @@
1
+ export { ToastProvider, useToast } from './provider';
@@ -0,0 +1,5 @@
1
+ import { ToastProvider, useToast } from "./provider";
2
+ export {
3
+ ToastProvider,
4
+ useToast
5
+ };
@@ -0,0 +1,11 @@
1
+ import { type FC, type PropsWithChildren, type RefObject } from 'react';
2
+ import type { Status } from './../../types/variables';
3
+ export declare const useToast: () => {
4
+ onOpen: (status: Status, message: string) => void;
5
+ onClose: (id: string) => void;
6
+ onCloseAll: () => void;
7
+ };
8
+ export declare const ToastProvider: FC<PropsWithChildren<{
9
+ portalRef?: RefObject<HTMLElement | null>;
10
+ position?: 'fixed' | 'absolute';
11
+ }>>;
@@ -0,0 +1,125 @@
1
+ "use client";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { AnimatePresence } from "motion/react";
4
+ import * as motion from "motion/react-client";
5
+ import {
6
+ createContext,
7
+ use,
8
+ useCallback,
9
+ useEffect,
10
+ useRef,
11
+ useState
12
+ } from "react";
13
+ import { createPortal } from "react-dom";
14
+ import { cn } from "./../../helpers/cn";
15
+ import { uuidV4 } from "./../../helpers/uuid-v4";
16
+ import { Toast } from "./toast";
17
+ const SetToastContext = createContext(void 0);
18
+ const useToast = () => {
19
+ const setToasts = use(SetToastContext);
20
+ if (!setToasts) {
21
+ throw new Error("useToast must be used within a ToastProvider");
22
+ }
23
+ const onOpen = useCallback(
24
+ (status, message) => {
25
+ setToasts((prev) => [
26
+ ...prev,
27
+ {
28
+ id: uuidV4(),
29
+ status,
30
+ message
31
+ }
32
+ ]);
33
+ },
34
+ [setToasts]
35
+ );
36
+ const onClose = useCallback(
37
+ (id) => {
38
+ setToasts((prev) => prev.filter((toast) => toast.id !== id));
39
+ },
40
+ [setToasts]
41
+ );
42
+ const onCloseAll = useCallback(() => {
43
+ setToasts([]);
44
+ }, [setToasts]);
45
+ return {
46
+ onOpen,
47
+ onClose,
48
+ onCloseAll
49
+ };
50
+ };
51
+ const toastMotionVariants = {
52
+ initial: {
53
+ opacity: 0,
54
+ y: 24
55
+ },
56
+ animate: {
57
+ opacity: 1,
58
+ y: 0,
59
+ x: 0,
60
+ scale: 1,
61
+ transition: {
62
+ duration: 0.4,
63
+ ease: [0.4, 0, 0.2, 1]
64
+ }
65
+ },
66
+ exit: {
67
+ opacity: 0,
68
+ scale: 0.85,
69
+ transition: {
70
+ duration: 0.2,
71
+ ease: [0.4, 0, 1, 1]
72
+ }
73
+ }
74
+ };
75
+ const ToastProvider = ({ children, portalRef = null, position = "fixed" }) => {
76
+ const [toasts, setToasts] = useState([]);
77
+ const ref = useRef(null);
78
+ useEffect(() => {
79
+ ref.current = document.body;
80
+ }, []);
81
+ const container = portalRef?.current ?? ref.current;
82
+ return /* @__PURE__ */ jsxs(SetToastContext, { value: setToasts, children: [
83
+ children,
84
+ container ? createPortal(
85
+ /* @__PURE__ */ jsx(
86
+ "section",
87
+ {
88
+ "aria-label": "\u901A\u77E5",
89
+ "aria-live": "polite",
90
+ className: cn(
91
+ "absolute bottom-3 z-50 flex w-full flex-col items-center justify-center gap-4",
92
+ position === "fixed" && "fixed",
93
+ position === "absolute" && "absolute"
94
+ ),
95
+ children: /* @__PURE__ */ jsx(AnimatePresence, { initial: false, children: toasts.map((toast) => /* @__PURE__ */ jsx(
96
+ motion.div,
97
+ {
98
+ animate: "animate",
99
+ custom: { position: "bottom" },
100
+ exit: "exit",
101
+ initial: "initial",
102
+ layout: true,
103
+ variants: toastMotionVariants,
104
+ children: /* @__PURE__ */ jsx(
105
+ "div",
106
+ {
107
+ "aria-atomic": true,
108
+ className: "shadow-lg",
109
+ role: toast.status === "error" || toast.status === "warning" ? "alert" : "status",
110
+ children: /* @__PURE__ */ jsx(Toast, { ...toast })
111
+ }
112
+ )
113
+ },
114
+ toast.id
115
+ )) })
116
+ }
117
+ ),
118
+ container
119
+ ) : null
120
+ ] });
121
+ };
122
+ export {
123
+ ToastProvider,
124
+ useToast
125
+ };
@@ -0,0 +1,9 @@
1
+ import { type FC } from 'react';
2
+ import type { Status } from './../../types/variables';
3
+ type ToastProps = {
4
+ id: string;
5
+ status: Status;
6
+ message: string;
7
+ };
8
+ export declare const Toast: FC<ToastProps>;
9
+ export {};
@@ -0,0 +1,19 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { useCallback } from "react";
3
+ import { useTimeout } from "./../../hooks/timeout";
4
+ import { Alert } from "../alert";
5
+ import { useToast } from "./provider";
6
+ const DELAY_MS = 5e3;
7
+ const Toast = ({ id, status, message }) => {
8
+ const { onClose } = useToast();
9
+ useTimeout(
10
+ useCallback(() => {
11
+ onClose(id);
12
+ }, [id, onClose]),
13
+ DELAY_MS
14
+ );
15
+ return /* @__PURE__ */ jsx(Alert, { message, status });
16
+ };
17
+ export {
18
+ Toast
19
+ };
@@ -0,0 +1,45 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Button } from "../button";
3
+ import { ToastProvider, useToast } from "./provider";
4
+ import { Toast } from "./toast";
5
+ const meta = {
6
+ title: "components/toast",
7
+ component: ToastProvider,
8
+ decorators: [
9
+ (Story) => /* @__PURE__ */ jsx(ToastProvider, { children: /* @__PURE__ */ jsx(Story, {}) })
10
+ ],
11
+ render: () => {
12
+ const { onOpen } = useToast();
13
+ return /* @__PURE__ */ jsx(
14
+ Button,
15
+ {
16
+ onClick: () => {
17
+ onOpen("success", "\u30C8\u30FC\u30B9\u30C8\u3092\u547C\u3073\u307E\u3057\u305F");
18
+ },
19
+ children: "\u30C8\u30FC\u30B9\u30C8\u3092\u547C\u3076"
20
+ }
21
+ );
22
+ }
23
+ };
24
+ var toast_stories_default = meta;
25
+ const Primary = {};
26
+ const ToastSuccess = {
27
+ render: () => /* @__PURE__ */ jsx(Toast, { id: "1", message: "\u6210\u529F\u3057\u307E\u3057\u305F", status: "success" })
28
+ };
29
+ const ToasInfo = {
30
+ render: () => /* @__PURE__ */ jsx(Toast, { id: "1", message: "\u60C5\u5831\u3067\u3059", status: "info" })
31
+ };
32
+ const ToastError = {
33
+ render: () => /* @__PURE__ */ jsx(Toast, { id: "1", message: "\u5931\u6557\u3057\u307E\u3057\u305F", status: "error" })
34
+ };
35
+ const ToastWarning = {
36
+ render: () => /* @__PURE__ */ jsx(Toast, { id: "1", message: "\u8B66\u544A\u3067\u3059", status: "warning" })
37
+ };
38
+ export {
39
+ Primary,
40
+ ToasInfo,
41
+ ToastError,
42
+ ToastSuccess,
43
+ ToastWarning,
44
+ toast_stories_default as default
45
+ };
@@ -0,0 +1 @@
1
+ export * from './tooltip';
@@ -0,0 +1 @@
1
+ export * from "./tooltip";
@@ -0,0 +1,13 @@
1
+ import type { Placement } from '@floating-ui/react';
2
+ import type { FC, PropsWithChildren, ReactElement } from 'react';
3
+ export declare const Tooltip: {
4
+ Root: FC<PropsWithChildren<{
5
+ placement?: Placement;
6
+ }>>;
7
+ Trigger: FC<{
8
+ renderItem: (props: Record<string, unknown>) => ReactElement;
9
+ }>;
10
+ Content: FC<{
11
+ children?: React.ReactNode | undefined;
12
+ }>;
13
+ };
@@ -0,0 +1,60 @@
1
+ "use client";
2
+ import { jsx } from "react/jsx-runtime";
3
+ import { Popover } from "../popover";
4
+ import { usePlacement } from "../popover/hooks";
5
+ const Root = ({
6
+ children,
7
+ placement = "bottom-start"
8
+ }) => {
9
+ return /* @__PURE__ */ jsx(Popover.Root, { placement, type: "tooltip", children });
10
+ };
11
+ const Trigger = ({ renderItem }) => {
12
+ return /* @__PURE__ */ jsx(Popover.Trigger, { renderItem: (props) => renderItem({ ...props }) });
13
+ };
14
+ const Content = ({ children }) => {
15
+ const placement = usePlacement();
16
+ const translate = {
17
+ top: { translateY: 5 },
18
+ bottom: { translateY: -5 },
19
+ left: { translateX: 5 },
20
+ right: { translateX: -5 }
21
+ }[placement.includes("-") ? placement.split("-")[0] ?? "bottom" : placement];
22
+ return /* @__PURE__ */ jsx(
23
+ Popover.Content,
24
+ {
25
+ motionVariants: {
26
+ closed: {
27
+ ...translate,
28
+ opacity: 0,
29
+ transition: {
30
+ duration: 0.3
31
+ }
32
+ },
33
+ open: {
34
+ translate: 0,
35
+ opacity: 1,
36
+ transition: {
37
+ duration: 0.4,
38
+ ease: "easeOut"
39
+ }
40
+ }
41
+ },
42
+ renderItem: (props) => /* @__PURE__ */ jsx(
43
+ "div",
44
+ {
45
+ ...props,
46
+ className: "rounded-lg border border-border-mute bg-bg-base px-4 py-2 shadow-xl",
47
+ children
48
+ }
49
+ )
50
+ }
51
+ );
52
+ };
53
+ const Tooltip = {
54
+ Root,
55
+ Trigger,
56
+ Content
57
+ };
58
+ export {
59
+ Tooltip
60
+ };
@@ -0,0 +1,40 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Button } from "../button";
3
+ import { Tooltip } from "./tooltip";
4
+ const meta = {
5
+ title: "components/tooltip",
6
+ component: Tooltip.Root,
7
+ parameters: {
8
+ a11y: {
9
+ options: {
10
+ rules: {
11
+ // https://github.com/floating-ui/floating-ui/pull/2298#issuecomment-1518101512
12
+ "aria-hidden-focus": { enabled: false }
13
+ }
14
+ }
15
+ }
16
+ }
17
+ };
18
+ var tooltip_stories_default = meta;
19
+ const Default = {
20
+ render: () => /* @__PURE__ */ jsxs(Tooltip.Root, { placement: "bottom-start", children: [
21
+ /* @__PURE__ */ jsx(
22
+ Tooltip.Trigger,
23
+ {
24
+ renderItem: (props) => /* @__PURE__ */ jsx(Button, { type: "button", ...props, children: "Tooltip" })
25
+ }
26
+ ),
27
+ /* @__PURE__ */ jsx(Tooltip.Content, { children: /* @__PURE__ */ jsx("p", { children: "Tooltip content" }) })
28
+ ] }),
29
+ play: async ({ canvas, userEvent }) => {
30
+ const trigger = canvas.getByRole("button", {
31
+ name: "Tooltip"
32
+ });
33
+ trigger.focus();
34
+ await userEvent.keyboard("{Enter}");
35
+ }
36
+ };
37
+ export {
38
+ Default,
39
+ tooltip_stories_default as default
40
+ };
@@ -0,0 +1,2 @@
1
+ import { type ClassValue } from 'clsx';
2
+ export declare const cn: (...inputs: ClassValue[]) => string;
@@ -0,0 +1,8 @@
1
+ import { clsx } from "clsx";
2
+ import { twMerge } from "tailwind-merge";
3
+ const cn = (...inputs) => {
4
+ return twMerge(clsx(inputs));
5
+ };
6
+ export {
7
+ cn
8
+ };