@lism-css/ui 0.11.0 → 0.13.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 (218) hide show
  1. package/README.md +1 -1
  2. package/dist/components/Accordion/Accordion.stories.d.ts +7 -0
  3. package/dist/components/Accordion/getProps.d.ts +55 -42
  4. package/dist/components/Accordion/getProps.js +36 -32
  5. package/dist/components/Accordion/react/AccIcon.d.ts +2 -1
  6. package/dist/components/Accordion/react/Accordion.d.ts +12 -21
  7. package/dist/components/Accordion/react/Accordion.js +30 -29
  8. package/dist/components/Accordion/react/index.d.ts +10 -11
  9. package/dist/components/Accordion/setAccordion.d.ts +6 -3
  10. package/dist/components/Accordion/setAccordion.js +12 -10
  11. package/dist/components/Alert/Alert.stories.d.ts +13 -0
  12. package/dist/components/Alert/getProps.d.ts +6 -4
  13. package/dist/components/Alert/react/Alert.d.ts +3 -4
  14. package/dist/components/Alert/react/Alert.js +2 -2
  15. package/dist/components/Avatar/Avatar.stories.d.ts +8 -0
  16. package/dist/components/Avatar/react/Avatar.d.ts +10 -6
  17. package/dist/components/Avatar/react/Avatar.js +1 -1
  18. package/dist/components/Badge/Badge.stories.d.ts +8 -0
  19. package/dist/components/Badge/react/Badge.d.ts +3 -1
  20. package/dist/components/Badge/react/Badge.js +5 -8
  21. package/dist/components/Button/Button.stories.d.ts +8 -0
  22. package/dist/components/Button/react/Button.d.ts +3 -1
  23. package/dist/components/Button/react/Button.js +3 -6
  24. package/dist/components/Callout/Callout.stories.d.ts +12 -0
  25. package/dist/components/Callout/getProps.d.ts +3 -2
  26. package/dist/components/Callout/react/Callout.d.ts +3 -4
  27. package/dist/components/Callout/react/Callout.js +4 -4
  28. package/dist/components/Chat/Chat.stories.d.ts +9 -0
  29. package/dist/components/Chat/getProps.d.ts +43 -44
  30. package/dist/components/Chat/getProps.js +2 -2
  31. package/dist/components/Chat/react/Chat.d.ts +11 -7
  32. package/dist/components/Chat/react/Chat.js +10 -10
  33. package/dist/components/Details/Details.stories.d.ts +6 -0
  34. package/dist/components/Details/getProps.d.ts +34 -35
  35. package/dist/components/Details/getProps.js +17 -7
  36. package/dist/components/Details/react/Details.d.ts +11 -20
  37. package/dist/components/Details/react/Details.js +15 -15
  38. package/dist/components/Details/react/index.d.ts +7 -7
  39. package/dist/components/DummyImage/DummyImage.stories.d.ts +7 -0
  40. package/dist/components/DummyText/DummyText.stories.d.ts +9 -0
  41. package/dist/components/Modal/Modal.stories.d.ts +6 -0
  42. package/dist/components/Modal/getProps.d.ts +35 -36
  43. package/dist/components/Modal/getProps.js +34 -15
  44. package/dist/components/Modal/react/Body.d.ts +2 -4
  45. package/dist/components/Modal/react/CloseBtn.d.ts +9 -7
  46. package/dist/components/Modal/react/CloseBtn.js +5 -5
  47. package/dist/components/Modal/react/Inner.d.ts +3 -4
  48. package/dist/components/Modal/react/Modal.d.ts +4 -4
  49. package/dist/components/Modal/react/Modal.js +11 -9
  50. package/dist/components/Modal/react/OpenBtn.d.ts +7 -5
  51. package/dist/components/Modal/react/OpenBtn.js +4 -4
  52. package/dist/components/Modal/react/index.d.ts +7 -8
  53. package/dist/components/NavMenu/NavMenu.stories.d.ts +7 -0
  54. package/dist/components/NavMenu/getProps.d.ts +31 -29
  55. package/dist/components/NavMenu/react/NavMenu.d.ts +6 -16
  56. package/dist/components/NavMenu/react/NavMenu.js +21 -17
  57. package/dist/components/NavMenu/react/index.d.ts +6 -6
  58. package/dist/components/ShapeDivider/ShapeDivider.stories.d.ts +10 -0
  59. package/dist/components/ShapeDivider/getProps.d.ts +16 -11
  60. package/dist/components/ShapeDivider/getProps.js +10 -12
  61. package/dist/components/ShapeDivider/react/ShapeDivider.d.ts +3 -4
  62. package/dist/components/ShapeDivider/react/ShapeDivider.js +3 -3
  63. package/dist/components/Tabs/Tabs.stories.d.ts +6 -0
  64. package/dist/components/Tabs/getProps.d.ts +11 -4
  65. package/dist/components/Tabs/getProps.js +15 -5
  66. package/dist/components/Tabs/react/Tab.d.ts +8 -6
  67. package/dist/components/Tabs/react/Tab.js +15 -6
  68. package/dist/components/Tabs/react/TabItem.d.ts +7 -4
  69. package/dist/components/Tabs/react/TabList.d.ts +2 -1
  70. package/dist/components/Tabs/react/TabPanel.d.ts +8 -6
  71. package/dist/components/Tabs/react/Tabs.d.ts +9 -7
  72. package/dist/components/Tabs/react/Tabs.js +50 -36
  73. package/dist/components/Tabs/react/index.d.ts +8 -8
  74. package/dist/components/Tabs/setTabs.d.ts +1 -1
  75. package/dist/components/Tabs/setTabs.js +25 -15
  76. package/dist/lism-css/dist/components/{Center → layout/Center}/index.js +1 -1
  77. package/dist/lism-css/dist/components/{Flex → layout/Flex}/index.js +1 -1
  78. package/dist/lism-css/dist/components/{Flow → layout/Flow}/index.js +1 -1
  79. package/dist/lism-css/dist/components/{Frame → layout/Frame}/index.js +1 -1
  80. package/dist/lism-css/dist/components/{Grid → layout/Grid}/index.js +1 -1
  81. package/dist/lism-css/dist/components/{Stack → layout/Stack}/index.js +1 -1
  82. package/dist/lism-css/dist/config/default-config.js +6 -6
  83. package/dist/lism-css/dist/config/defaults/props.js +16 -26
  84. package/dist/lism-css/dist/config/defaults/traits.js +19 -0
  85. package/dist/lism-css/dist/config/index.js +9 -9
  86. package/dist/lism-css/dist/lib/getLayoutProps.js +6 -9
  87. package/dist/lism-css/dist/lib/getLismProps.js +116 -104
  88. package/dist/lism-css/dist/lib/helper/mergeSet.js +14 -0
  89. package/dist/style.css +1 -1
  90. package/dist/ui.css +1 -1
  91. package/package.json +14 -7
  92. package/src/components/Accordion/Accordion.stories.tsx +105 -0
  93. package/src/components/Accordion/_style.css +1 -1
  94. package/src/components/Accordion/astro/Button.astro +2 -2
  95. package/src/components/Accordion/getProps.ts +91 -0
  96. package/src/components/Accordion/react/{AccIcon.jsx → AccIcon.tsx} +2 -2
  97. package/src/components/Accordion/react/{Accordion.jsx → Accordion.tsx} +33 -11
  98. package/src/components/Accordion/setAccordion.ts +120 -0
  99. package/src/components/Alert/Alert.stories.tsx +64 -0
  100. package/src/components/Alert/getProps.ts +5 -3
  101. package/src/components/Alert/react/Alert.tsx +3 -3
  102. package/src/components/Avatar/Avatar.stories.tsx +42 -0
  103. package/src/components/Avatar/react/Avatar.tsx +17 -0
  104. package/src/components/Badge/Badge.stories.tsx +40 -0
  105. package/src/components/Badge/_style.css +1 -1
  106. package/src/components/Badge/astro/Badge.astro +1 -7
  107. package/src/components/Badge/react/Badge.tsx +7 -0
  108. package/src/components/Button/Button.stories.tsx +44 -0
  109. package/src/components/Button/_style.css +1 -1
  110. package/src/components/Button/astro/Button.astro +1 -7
  111. package/src/components/Button/react/Button.tsx +7 -0
  112. package/src/components/Callout/Callout.stories.tsx +55 -0
  113. package/src/components/Callout/getProps.ts +3 -2
  114. package/src/components/Callout/react/Callout.tsx +3 -3
  115. package/src/components/Chat/Chat.stories.tsx +58 -0
  116. package/src/components/Chat/_style.css +6 -6
  117. package/src/components/Chat/{getProps.js → getProps.ts} +10 -4
  118. package/src/components/Chat/react/{Chat.jsx → Chat.tsx} +13 -3
  119. package/src/components/Details/Details.stories.tsx +61 -0
  120. package/src/components/Details/_style.css +1 -1
  121. package/src/components/Details/astro/Title.astro +2 -2
  122. package/src/components/Details/{getProps.js → getProps.ts} +19 -6
  123. package/src/components/Details/react/Details.tsx +69 -0
  124. package/src/components/DummyImage/DummyImage.stories.tsx +23 -0
  125. package/src/components/DummyText/DummyText.stories.tsx +48 -0
  126. package/src/components/Modal/Modal.stories.tsx +67 -0
  127. package/src/components/Modal/_style.css +1 -1
  128. package/src/components/Modal/astro/CloseBtn.astro +2 -2
  129. package/src/components/Modal/astro/OpenBtn.astro +2 -3
  130. package/src/components/Modal/getProps.ts +64 -0
  131. package/src/components/Modal/react/Body.tsx +10 -0
  132. package/src/components/Modal/react/CloseBtn.tsx +24 -0
  133. package/src/components/Modal/react/Inner.tsx +6 -0
  134. package/src/components/Modal/react/Modal.tsx +24 -0
  135. package/src/components/Modal/react/OpenBtn.tsx +15 -0
  136. package/src/components/Modal/{script.js → script.ts} +1 -1
  137. package/src/components/NavMenu/NavMenu.stories.tsx +68 -0
  138. package/src/components/NavMenu/_style.css +1 -1
  139. package/src/components/NavMenu/getProps.ts +60 -0
  140. package/src/components/NavMenu/react/NavMenu.tsx +40 -0
  141. package/src/components/ShapeDivider/ShapeDivider.stories.tsx +87 -0
  142. package/src/components/ShapeDivider/_style.css +1 -1
  143. package/src/components/ShapeDivider/getProps.ts +36 -0
  144. package/src/components/ShapeDivider/react/{ShapeDivider.jsx → ShapeDivider.tsx} +4 -4
  145. package/src/components/Tabs/Tabs.stories.tsx +79 -0
  146. package/src/components/Tabs/_style.css +1 -1
  147. package/src/components/Tabs/astro/Tab.astro +2 -1
  148. package/src/components/Tabs/astro/{transformTabitems.js → transformTabitems.ts} +9 -9
  149. package/src/components/Tabs/getProps.ts +23 -0
  150. package/src/components/Tabs/react/Tab.tsx +21 -0
  151. package/src/components/Tabs/react/TabItem.tsx +13 -0
  152. package/src/components/Tabs/react/TabList.tsx +5 -0
  153. package/src/components/Tabs/react/{TabPanel.jsx → TabPanel.tsx} +8 -3
  154. package/src/components/Tabs/react/{Tabs.jsx → Tabs.tsx} +27 -12
  155. package/src/components/Tabs/{script.js → script.ts} +2 -2
  156. package/src/components/Tabs/setTabs.ts +65 -0
  157. package/src/helper/{uuid.js → uuid.ts} +2 -2
  158. package/src/vite-env.d.ts +1 -0
  159. package/dist/components/Accordion/astro/__setEvent.d.ts +0 -1
  160. package/dist/components/Accordion/astro/index.d.ts +0 -15
  161. package/dist/components/Alert/astro/index.d.ts +0 -1
  162. package/dist/components/Callout/astro/index.d.ts +0 -1
  163. package/dist/components/Details/astro/index.d.ts +0 -13
  164. package/dist/components/DummyImage/astro/index.d.ts +0 -1
  165. package/dist/components/DummyText/astro/index.d.ts +0 -1
  166. package/dist/components/Modal/astro/index.d.ts +0 -13
  167. package/dist/components/NavMenu/astro/index.d.ts +0 -11
  168. package/dist/components/Tabs/astro/index.d.ts +0 -13
  169. package/dist/components/Tabs/astro/transformTabitems.d.ts +0 -4
  170. package/dist/components/astro.d.ts +0 -14
  171. package/dist/lism-css/dist/config/defaults/states.js +0 -38
  172. package/dist/lism-css/dist/config/helper/getSvgUrl.js +0 -4
  173. package/src/components/Accordion/getProps.js +0 -77
  174. package/src/components/Accordion/setAccordion.js +0 -146
  175. package/src/components/Avatar/astro/index.js +0 -1
  176. package/src/components/Avatar/react/Avatar.jsx +0 -9
  177. package/src/components/Badge/astro/index.js +0 -1
  178. package/src/components/Badge/react/Badge.jsx +0 -12
  179. package/src/components/Button/astro/index.js +0 -1
  180. package/src/components/Button/react/Button.jsx +0 -12
  181. package/src/components/Chat/astro/index.js +0 -1
  182. package/src/components/Details/react/Details.jsx +0 -66
  183. package/src/components/Modal/getProps.js +0 -30
  184. package/src/components/Modal/react/Body.jsx +0 -10
  185. package/src/components/Modal/react/CloseBtn.jsx +0 -20
  186. package/src/components/Modal/react/Inner.jsx +0 -6
  187. package/src/components/Modal/react/Modal.jsx +0 -23
  188. package/src/components/Modal/react/OpenBtn.jsx +0 -11
  189. package/src/components/NavMenu/getProps.js +0 -65
  190. package/src/components/NavMenu/react/NavMenu.jsx +0 -19
  191. package/src/components/ShapeDivider/astro/index.js +0 -1
  192. package/src/components/ShapeDivider/getProps.js +0 -40
  193. package/src/components/Tabs/getProps.js +0 -8
  194. package/src/components/Tabs/react/Tab.jsx +0 -10
  195. package/src/components/Tabs/react/TabItem.jsx +0 -5
  196. package/src/components/Tabs/react/TabList.jsx +0 -6
  197. package/src/components/Tabs/setTabs.js +0 -87
  198. /package/src/components/Accordion/astro/{index.js → index.ts} +0 -0
  199. /package/src/components/Accordion/react/{index.js → index.ts} +0 -0
  200. /package/src/components/Accordion/{script.js → script.ts} +0 -0
  201. /package/{dist/components/Avatar/astro/index.d.ts → src/components/Avatar/astro/index.ts} +0 -0
  202. /package/src/components/Avatar/react/{index.js → index.ts} +0 -0
  203. /package/{dist/components/Badge/astro/index.d.ts → src/components/Badge/astro/index.ts} +0 -0
  204. /package/src/components/Badge/react/{index.js → index.ts} +0 -0
  205. /package/{dist/components/Button/astro/index.d.ts → src/components/Button/astro/index.ts} +0 -0
  206. /package/src/components/Button/react/{index.js → index.ts} +0 -0
  207. /package/{dist/components/Chat/astro/index.d.ts → src/components/Chat/astro/index.ts} +0 -0
  208. /package/src/components/Chat/react/{index.js → index.ts} +0 -0
  209. /package/src/components/Details/astro/{index.js → index.ts} +0 -0
  210. /package/src/components/Details/react/{index.js → index.ts} +0 -0
  211. /package/src/components/Modal/astro/{index.js → index.ts} +0 -0
  212. /package/src/components/Modal/react/{index.js → index.ts} +0 -0
  213. /package/src/components/NavMenu/astro/{index.js → index.ts} +0 -0
  214. /package/src/components/NavMenu/react/{index.js → index.ts} +0 -0
  215. /package/{dist/components/ShapeDivider/astro/index.d.ts → src/components/ShapeDivider/astro/index.ts} +0 -0
  216. /package/src/components/ShapeDivider/react/{index.js → index.ts} +0 -0
  217. /package/src/components/Tabs/astro/{index.js → index.ts} +0 -0
  218. /package/src/components/Tabs/react/{index.js → index.ts} +0 -0
@@ -0,0 +1,42 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import Avatar from './react/Avatar';
3
+
4
+ const meta: Meta<typeof Avatar> = {
5
+ title: 'UI/Avatar',
6
+ component: Avatar,
7
+ tags: ['autodocs'],
8
+ argTypes: {
9
+ src: { control: 'text' },
10
+ alt: { control: 'text' },
11
+ size: { control: 'text' },
12
+ },
13
+ };
14
+
15
+ export default meta;
16
+ type Story = StoryObj<typeof Avatar>;
17
+
18
+ export const Default: Story = {
19
+ args: {
20
+ src: 'https://cdn.lism-css.com/dummy-image.jpg',
21
+ alt: 'ユーザーアバター',
22
+ size: '4rem',
23
+ },
24
+ };
25
+
26
+ export const Small: Story = {
27
+ name: '小サイズ',
28
+ args: {
29
+ src: 'https://cdn.lism-css.com/dummy-image.jpg',
30
+ alt: '',
31
+ size: '2rem',
32
+ },
33
+ };
34
+
35
+ export const Large: Story = {
36
+ name: '大サイズ',
37
+ args: {
38
+ src: 'https://cdn.lism-css.com/dummy-image.jpg',
39
+ alt: '',
40
+ size: '8rem',
41
+ },
42
+ };
@@ -0,0 +1,17 @@
1
+ import type { ElementType } from 'react';
2
+ import { Frame, type LayoutComponentProps } from 'lism-css/react';
3
+ import type { FrameProps } from 'lism-css/lib/types/LayoutProps';
4
+
5
+ type AvatarProps<T extends ElementType = 'div'> = LayoutComponentProps<T, FrameProps> & {
6
+ size?: string;
7
+ src?: string;
8
+ alt?: string;
9
+ };
10
+
11
+ export default function Avatar<T extends ElementType = 'div'>({ size = '1.5em', src = '', alt = '', ...props }: AvatarProps<T>) {
12
+ return (
13
+ <Frame lismClass="c--avatar" ar="1/1" w={size} bdrs="99" {...(props as LayoutComponentProps<T, FrameProps>)}>
14
+ <img src={src} alt={alt} width="100%" height="100%" decoding="async" />
15
+ </Frame>
16
+ );
17
+ }
@@ -0,0 +1,40 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import Badge from './react/Badge';
3
+
4
+ const meta: Meta<typeof Badge> = {
5
+ title: 'UI/Badge',
6
+ component: Badge,
7
+ tags: ['autodocs'],
8
+ argTypes: {
9
+ children: { control: 'text' },
10
+ c: { control: 'text', description: 'テキストカラー(CSS変数キー)' },
11
+ bgc: { control: 'text', description: '背景カラー(CSS変数キー)' },
12
+ },
13
+ };
14
+
15
+ export default meta;
16
+ type Story = StoryObj<typeof Badge>;
17
+
18
+ export const Default: Story = {
19
+ args: {
20
+ children: 'Badge',
21
+ },
22
+ };
23
+
24
+ export const WithColor: Story = {
25
+ name: 'カラー指定',
26
+ args: {
27
+ children: 'New',
28
+ c: 'white',
29
+ bgc: 'red',
30
+ },
31
+ };
32
+
33
+ export const Secondary: Story = {
34
+ name: 'セカンダリカラー',
35
+ args: {
36
+ children: 'Info',
37
+ c: 'white',
38
+ bgc: 'blue',
39
+ },
40
+ };
@@ -1,4 +1,4 @@
1
- @layer lism-modules {
1
+ @layer lism-component {
2
2
  .c--badge {
3
3
  --c: var(--base);
4
4
  --bgc: var(--text);
@@ -3,14 +3,8 @@ import { Lism } from 'lism-css/astro';
3
3
  import '../_style.css';
4
4
 
5
5
  const props = Astro.props;
6
-
7
- // c--badge では c, bgc は 変数で受け取る
8
- const _propConfig = {
9
- c: { isVar: 1 },
10
- bgc: { isVar: 1 },
11
- };
12
6
  ---
13
7
 
14
- <Lism lismClass="c--badge" as="span" d="inline-flex" fz="xs" lh="xs" py="5" px="10" bdrs="10" _propConfig={_propConfig} {...props}>
8
+ <Lism lismClass="c--badge" as="span" d="inline-flex" fz="xs" lh="xs" py="5" px="10" bdrs="10" {...props}>
15
9
  <slot />
16
10
  </Lism>
@@ -0,0 +1,7 @@
1
+ import type { ElementType } from 'react';
2
+ import { Lism, type LismComponentProps } from 'lism-css/react';
3
+ import '../_style.css';
4
+
5
+ export default function Badge<T extends ElementType = 'span'>(props: LismComponentProps<T>) {
6
+ return <Lism lismClass="c--badge" as="span" d="inline-flex" fz="xs" lh="xs" py="5" px="10" bdrs="10" {...props} />;
7
+ }
@@ -0,0 +1,44 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import Button from './react/Button';
3
+
4
+ const meta: Meta<typeof Button> = {
5
+ title: 'UI/Button',
6
+ component: Button,
7
+ tags: ['autodocs'],
8
+ argTypes: {
9
+ children: { control: 'text' },
10
+ c: { control: 'text', description: 'テキストカラー(CSS変数キー)' },
11
+ bgc: { control: 'text', description: '背景カラー(CSS変数キー)' },
12
+ href: { control: 'text' },
13
+ as: { control: 'text' },
14
+ },
15
+ };
16
+
17
+ export default meta;
18
+ type Story = StoryObj<typeof Button>;
19
+
20
+ export const Default: Story = {
21
+ args: {
22
+ children: 'ボタン',
23
+ href: '#',
24
+ },
25
+ };
26
+
27
+ export const AsButton: Story = {
28
+ name: 'as="button"',
29
+ args: {
30
+ children: 'ボタン要素',
31
+ as: 'button',
32
+ },
33
+ };
34
+
35
+ export const WithColor: Story = {
36
+ name: 'カラー指定',
37
+ args: {
38
+ children: '送信する',
39
+ as: 'button',
40
+ c: 'white',
41
+ bgc: 'blue',
42
+ bdrs: '99',
43
+ },
44
+ };
@@ -1,4 +1,4 @@
1
- @layer lism-modules {
1
+ @layer lism-component {
2
2
  .c--button {
3
3
  --c: var(--base);
4
4
  --bgc: var(--text);
@@ -3,14 +3,8 @@ import { Flex } from 'lism-css/astro';
3
3
  import '../_style.css';
4
4
 
5
5
  const props = Astro.props;
6
-
7
- // c--button では c, bgc は 変数で受け取る
8
- const _propConfig = {
9
- c: { isVar: 1 },
10
- bgc: { isVar: 1 },
11
- };
12
6
  ---
13
7
 
14
- <Flex lismClass="c--button" as="a" lh="s" py="10" px="20" hov="o" _propConfig={_propConfig} {...props}>
8
+ <Flex lismClass="c--button" as="a" lh="s" py="10" px="20" hov="o" {...props}>
15
9
  <slot />
16
10
  </Flex>
@@ -0,0 +1,7 @@
1
+ import type { ElementType } from 'react';
2
+ import { Flex, type LismComponentProps } from 'lism-css/react';
3
+ import '../_style.css';
4
+
5
+ export default function Button<T extends ElementType = 'a'>(props: LismComponentProps<T>) {
6
+ return <Flex lismClass="c--button" as="a" lh="s" py="10" px="20" hov="o" {...props} />;
7
+ }
@@ -0,0 +1,55 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import Callout from './react/Callout';
3
+ import PRESETS from './presets';
4
+
5
+ const presetTypes = Object.keys(PRESETS);
6
+
7
+ const meta: Meta<typeof Callout> = {
8
+ title: 'UI/Callout',
9
+ component: Callout,
10
+ tags: ['autodocs'],
11
+ argTypes: {
12
+ children: { control: false },
13
+ type: { control: 'select', options: presetTypes },
14
+ title: { control: 'text' },
15
+ },
16
+ };
17
+
18
+ export default meta;
19
+ type Story = StoryObj<typeof Callout>;
20
+
21
+ export const Default: Story = {
22
+ args: {
23
+ type: 'note',
24
+ children: 'コールアウトのメッセージです。',
25
+ },
26
+ };
27
+
28
+ export const WithTitle: Story = {
29
+ name: 'タイトルあり',
30
+ args: {
31
+ type: 'note',
32
+ title: 'メモ',
33
+ children: 'タイトル付きのコールアウトです。',
34
+ },
35
+ };
36
+
37
+ export const Alert: Story = {
38
+ args: { type: 'alert', title: '警告', children: '警告のメッセージです。' },
39
+ };
40
+
41
+ export const Point: Story = {
42
+ args: { type: 'point', title: 'ポイント', children: 'ポイントのメッセージです。' },
43
+ };
44
+
45
+ export const Warning: Story = {
46
+ args: { type: 'warning', title: '注意', children: '注意のメッセージです。' },
47
+ };
48
+
49
+ export const Check: Story = {
50
+ args: { type: 'check', title: 'OK', children: 'チェックのメッセージです。' },
51
+ };
52
+
53
+ export const Help: Story = {
54
+ args: { type: 'help', title: 'ヘルプ', children: 'ヘルプのメッセージです。' },
55
+ };
@@ -1,9 +1,10 @@
1
1
  import PRESETS from './presets';
2
+ import type { IconProps } from 'lism-css/react';
2
3
 
3
4
  export type CalloutProps = {
4
5
  type?: string;
5
6
  keycolor?: string;
6
- icon?: string;
7
+ icon?: IconProps['icon'];
7
8
  title?: string;
8
9
  flow?: string;
9
10
  [key: string]: unknown;
@@ -11,7 +12,7 @@ export type CalloutProps = {
11
12
 
12
13
  export default function getCalloutProps({ type = 'note', keycolor, icon, title, flow = 's', ...props }: CalloutProps) {
13
14
  const presetData = type ? PRESETS[type] : null;
14
- const _icon = icon || presetData?.icon || 'note';
15
+ const _icon = (icon || presetData?.icon || 'note') as IconProps['icon'];
15
16
  const _keycolor = keycolor || presetData?.color || null;
16
17
 
17
18
  return {
@@ -1,8 +1,8 @@
1
- import type { ReactNode } from 'react';
2
- import { Flow, Flex, Stack, Icon, Center } from 'lism-css/react';
1
+ import type { ElementType } from 'react';
2
+ import { Flow, Flex, Stack, Icon, Center, type LismComponentProps } from 'lism-css/react';
3
3
  import getCalloutProps, { type CalloutProps } from '../getProps';
4
4
 
5
- export default function Callout({ children, ...inputProps }: CalloutProps & { children?: ReactNode }) {
5
+ export default function Callout<T extends ElementType = 'div'>({ children, ...inputProps }: CalloutProps & LismComponentProps<T>) {
6
6
  const { icon, title, flow, ...calloutProps } = getCalloutProps(inputProps);
7
7
 
8
8
  return (
@@ -0,0 +1,58 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import Chat from './react/Chat';
3
+
4
+ const meta: Meta<typeof Chat> = {
5
+ title: 'UI/Chat',
6
+ component: Chat,
7
+ tags: ['autodocs'],
8
+ argTypes: {
9
+ children: { control: false },
10
+ name: { control: 'text' },
11
+ avatar: { control: 'text' },
12
+ direction: { control: 'select', options: ['start', 'end'] },
13
+ variant: { control: 'select', options: ['speak', 'think'] },
14
+ keycolor: { control: 'text' },
15
+ },
16
+ };
17
+
18
+ export default meta;
19
+ type Story = StoryObj<typeof Chat>;
20
+
21
+ const AVATAR_SRC = 'https://cdn.lism-css.com/dummy-image.jpg';
22
+
23
+ export const Default: Story = {
24
+ args: {
25
+ name: 'ユーザー',
26
+ avatar: AVATAR_SRC,
27
+ children: 'こんにちは!チャットコンポーネントのデモです。',
28
+ },
29
+ };
30
+
31
+ export const End: Story = {
32
+ name: 'direction: end(右寄せ)',
33
+ args: {
34
+ name: '自分',
35
+ avatar: AVATAR_SRC,
36
+ direction: 'end',
37
+ keycolor: 'blue',
38
+ children: '右寄せのチャットメッセージです。',
39
+ },
40
+ };
41
+
42
+ export const NoAvatar: Story = {
43
+ name: 'アバターなし',
44
+ args: {
45
+ name: 'ゲスト',
46
+ children: 'アバターなしのチャットです。',
47
+ },
48
+ };
49
+
50
+ export const Think: Story = {
51
+ name: 'variant: think',
52
+ args: {
53
+ name: 'キャラ',
54
+ avatar: AVATAR_SRC,
55
+ variant: 'think',
56
+ children: '考え中のバリアントです。',
57
+ },
58
+ };
@@ -1,9 +1,9 @@
1
- @layer lism-modules {
1
+ @layer lism-component {
2
2
  .c--chat {
3
3
  --cbox-bgPct: 8%;
4
- --gta: 'avatar name' 'avatar body';
5
- --gtc: auto 1fr;
6
- --gtr: minmax(1.5rem, auto) auto;
4
+ grid-template-areas: 'avatar name' 'avatar body';
5
+ grid-template-columns: auto 1fr;
6
+ grid-template-rows: minmax(1.5rem, auto) auto;
7
7
  --_avator-size: clamp(48px, 32px + 5cqw, 64px); /* @320px:40px ~ @640:64px */
8
8
  --_deco-size: calc(min(var(--_avator-size), 80px) / 4 + 0.25rem);
9
9
  --_deco-mask: none;
@@ -46,8 +46,8 @@
46
46
  [data-chat-dir='end'] {
47
47
  --_deco-scale: -1 1;
48
48
  --_deco-inset-x: calc(100% - 1px) auto;
49
- --gta: 'name avatar' 'body avatar';
50
- --gtc: 1fr auto;
49
+ grid-template-areas: 'name avatar' 'body avatar';
50
+ grid-template-columns: 1fr auto;
51
51
  }
52
52
  }
53
53
 
@@ -2,7 +2,6 @@
2
2
  * Chat コンポーネントの共通プロパティ処理
3
3
  */
4
4
 
5
- // 各サブ要素のデフォルトプロパティ
6
5
  export const defaultProps = {
7
6
  avatar: {
8
7
  lismClass: 'c--chat_avatar',
@@ -23,11 +22,11 @@ export const defaultProps = {
23
22
  },
24
23
  body: {
25
24
  lismClass: 'c--chat_body',
26
- pos: 'rel',
25
+ pos: 'relative',
27
26
  },
28
27
  deco: {
29
28
  lismClass: 'c--chat_deco',
30
- pos: 'abs',
29
+ pos: 'absolute',
31
30
  },
32
31
  content: {
33
32
  lismClass: 'c--chat_content',
@@ -35,12 +34,19 @@ export const defaultProps = {
35
34
  p: '20',
36
35
  lh: 's',
37
36
  },
37
+ } as const;
38
+
39
+ export type ChatProps = {
40
+ variant?: string;
41
+ direction?: string;
42
+ keycolor?: string;
43
+ [key: string]: unknown;
38
44
  };
39
45
 
40
46
  /**
41
47
  * Chat コンポーネントのルートプロパティを生成
42
48
  */
43
- export default function getChatProps({ variant = 'speak', direction = 'start', keycolor = 'gray', ...props }) {
49
+ export default function getChatProps({ variant = 'speak', direction = 'start', keycolor = 'gray', ...props }: ChatProps) {
44
50
  return {
45
51
  lismClass: 'c--chat',
46
52
  variant,
@@ -1,14 +1,24 @@
1
- import { Lism, Flow, Grid, Frame, Decorator } from 'lism-css/react';
1
+ import type { ElementType } from 'react';
2
+ import { Lism, Flow, Grid, Frame, Decorator, type LayoutComponentProps } from 'lism-css/react';
3
+ import type { GridLayoutProps } from 'lism-css/lib/types/LayoutProps';
2
4
  import getChatProps, { defaultProps } from '../getProps';
5
+ import type { ChatProps } from '../getProps';
3
6
  import '../_style.css';
4
7
 
5
- export default function Chat({ name, avatar, flow = 's', children, ...props }) {
8
+ type Props<T extends ElementType = 'div'> = ChatProps &
9
+ LayoutComponentProps<T, GridLayoutProps> & {
10
+ name?: string;
11
+ avatar?: string;
12
+ flow?: string;
13
+ };
14
+
15
+ export default function Chat<T extends ElementType = 'div'>({ name, avatar, flow = 's', children, ...props }: Props<T>) {
6
16
  const { 'data-chat-dir': direction, ...chatProps } = getChatProps(props);
7
17
 
8
18
  return (
9
19
  <Grid data-chat-dir={direction} {...chatProps}>
10
20
  {avatar && (
11
- <Frame {...defaultProps.avatar} src={avatar} alt="">
21
+ <Frame {...defaultProps.avatar}>
12
22
  <img src={avatar} alt="" width="60" height="60" decoding="async" />
13
23
  </Frame>
14
24
  )}
@@ -0,0 +1,61 @@
1
+ import type { Meta, StoryObj } from '@storybook/react-vite';
2
+ import { expect, userEvent, within } from 'storybook/test';
3
+ import Details from './react';
4
+
5
+ const meta: Meta = {
6
+ title: 'UI/Details',
7
+ tags: ['autodocs'],
8
+ };
9
+
10
+ export default meta;
11
+ type Story = StoryObj;
12
+
13
+ export const Default: Story = {
14
+ render: () => (
15
+ <Details.Root>
16
+ <Details.Summary>
17
+ <Details.Icon>▶</Details.Icon>
18
+ <Details.Title>詳細を見る</Details.Title>
19
+ </Details.Summary>
20
+ <Details.Content>
21
+ <p>詳細コンテンツです。クリックで開閉できます。</p>
22
+ </Details.Content>
23
+ </Details.Root>
24
+ ),
25
+ play: async ({ canvasElement }) => {
26
+ const details = within(canvasElement).getByRole('group'); // <details>
27
+ const summary = details.querySelector('summary') as HTMLElement;
28
+
29
+ // 初期状態: 閉じている
30
+ await expect(details).not.toHaveAttribute('open');
31
+
32
+ // クリックで開く
33
+ await userEvent.click(summary);
34
+ await expect(details).toHaveAttribute('open');
35
+
36
+ // 再クリックで閉じる
37
+ await userEvent.click(summary);
38
+ await expect(details).not.toHaveAttribute('open');
39
+ },
40
+ };
41
+
42
+ export const OpenByDefault: Story = {
43
+ name: '初期展開状態',
44
+ render: () => (
45
+ <Details.Root open>
46
+ <Details.Summary>
47
+ <Details.Icon>▼</Details.Icon>
48
+ <Details.Title>最初から開いている詳細</Details.Title>
49
+ </Details.Summary>
50
+ <Details.Content>
51
+ <p>open 属性を付けると初期状態で展開されます。</p>
52
+ </Details.Content>
53
+ </Details.Root>
54
+ ),
55
+ play: async ({ canvasElement }) => {
56
+ const details = within(canvasElement).getByRole('group'); // <details>
57
+
58
+ // 初期状態: 開いている(open 属性あり)
59
+ await expect(details).toHaveAttribute('open');
60
+ },
61
+ };
@@ -1,6 +1,6 @@
1
1
  /* Details コンポーネント用スタイル */
2
2
  /* ::details-content と grid-template-rows: 0fr → 1fr のトランジションでアニメーション */
3
- @layer lism-modules {
3
+ @layer lism-component {
4
4
  .c--details {
5
5
  --duration: var(--acc-duration, 0.25s); /* transition時間 */
6
6
  --_icon-scale: 1.1;
@@ -1,10 +1,10 @@
1
1
  ---
2
2
  import { Lism } from 'lism-css/astro';
3
- import { defaultProps } from '../getProps';
3
+ import { getTitleProps } from '../getProps';
4
4
 
5
5
  const props = Astro.props || {};
6
6
  ---
7
7
 
8
- <Lism {...defaultProps.title} {...props}>
8
+ <Lism {...getTitleProps(props)}>
9
9
  <slot />
10
10
  </Lism>
@@ -1,23 +1,36 @@
1
1
  import atts from 'lism-css/lib/helper/atts';
2
+ import mergeSet from 'lism-css/lib/helper/mergeSet';
3
+ import type { LismProps } from 'lism-css/lib/getLismProps';
4
+
5
+ export type DetailsProps = {
6
+ lismClass?: string;
7
+ [key: string]: unknown;
8
+ };
2
9
 
3
10
  /**
4
11
  * Detailsコンポーネントのルート要素用プロパティを生成
5
- * @param {Object} props - コンポーネントのプロパティ
6
- * @param {string} props.lismClass - 追加のLismクラス
7
- * @returns {Object} 処理済みプロパティ
8
12
  */
9
- export function getDetailsProps({ lismClass, ...props }) {
13
+ export function getDetailsProps({ lismClass, ...props }: DetailsProps): LismProps {
10
14
  props.lismClass = atts(lismClass, 'c--details');
11
15
  return props;
12
16
  }
13
17
 
18
+ export function getTitleProps({ set, ...props }: Record<string, unknown>) {
19
+ return {
20
+ lismClass: 'c--details_title',
21
+ as: 'span',
22
+ fx: '1',
23
+ set: mergeSet('plain', set),
24
+ ...props,
25
+ };
26
+ }
27
+
14
28
  /**
15
29
  * 各サブコンポーネント用のデフォルトプロパティ
16
30
  */
17
31
  export const defaultProps = {
18
32
  summary: { lismClass: 'c--details_summary', layout: 'flex', g: '10', ai: 'center' },
19
- title: { lismClass: 'c--details_title', as: 'span', fx: '1', setPlain: 1 },
20
33
  icon: { lismClass: 'c--details_icon a--icon', as: 'span', 'aria-hidden': 'true' },
21
34
  body: { lismClass: 'c--details_body' },
22
35
  content: { lismClass: 'c--details_content', layout: 'flow', flow: 's' },
23
- };
36
+ } as const;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * React版 Detailsコンポーネント
3
+ */
4
+ import type { ElementType } from 'react';
5
+ import getLismProps from 'lism-css/lib/getLismProps';
6
+ import { Lism, type LismComponentProps } from 'lism-css/react';
7
+ import { getDetailsProps, getTitleProps, defaultProps } from '../getProps';
8
+
9
+ // スタイルのインポート
10
+ import '../_style.css';
11
+
12
+ type DetailsRootProps = LismComponentProps<'details'> & { open?: boolean };
13
+
14
+ /**
15
+ * Details - ルートコンポーネント
16
+ * details要素をレンダリング
17
+ */
18
+ export function Details({ children, open, ...props }: DetailsRootProps) {
19
+ const lismProps = getLismProps(getDetailsProps(props));
20
+
21
+ return (
22
+ <details open={open} {...lismProps}>
23
+ {children}
24
+ </details>
25
+ );
26
+ }
27
+
28
+ /**
29
+ * Summary - サマリーコンポーネント
30
+ * details要素のsummary部分
31
+ */
32
+ export function Summary<T extends ElementType = 'summary'>({ children, ...props }: LismComponentProps<T>) {
33
+ return (
34
+ <Lism as="summary" {...(defaultProps.summary as object)} {...(props as object)}>
35
+ {children}
36
+ </Lism>
37
+ );
38
+ }
39
+
40
+ /**
41
+ * Title - タイトルコンポーネント
42
+ */
43
+ export function Title<T extends ElementType = 'span'>({ children, ...props }: LismComponentProps<T>) {
44
+ return <Lism {...(getTitleProps(props as Record<string, unknown>) as object)}>{children}</Lism>;
45
+ }
46
+
47
+ /**
48
+ * Icon - アイコンコンポーネント
49
+ */
50
+ export function Icon<T extends ElementType = 'span'>({ children, ...props }: LismComponentProps<T>) {
51
+ return (
52
+ <Lism {...(defaultProps.icon as object)} {...(props as object)}>
53
+ {children}
54
+ </Lism>
55
+ );
56
+ }
57
+
58
+ /**
59
+ * Content - コンテンツコンポーネント
60
+ */
61
+ export function Content<T extends ElementType = 'div'>({ children, ...props }: LismComponentProps<T>) {
62
+ return (
63
+ <Lism {...defaultProps.body}>
64
+ <Lism {...(defaultProps.content as object)} {...(props as object)}>
65
+ {children}
66
+ </Lism>
67
+ </Lism>
68
+ );
69
+ }