@lism-css/ui 0.9.2 → 0.10.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 (189) hide show
  1. package/README.ja.md +137 -0
  2. package/README.md +93 -5
  3. package/dist/components/Accordion/getProps.js +53 -0
  4. package/dist/components/Accordion/react/AccIcon.js +9 -0
  5. package/dist/components/Accordion/react/Accordion.d.ts +5 -6
  6. package/dist/components/Accordion/react/Accordion.js +45 -0
  7. package/dist/components/Accordion/react/index.js +6 -0
  8. package/dist/components/Alert/getProps.js +20 -0
  9. package/dist/components/Alert/presets.js +29 -0
  10. package/dist/components/Alert/react/Alert.js +16 -0
  11. package/dist/components/Avatar/react/Avatar.js +8 -0
  12. package/dist/components/Badge/react/Badge.js +12 -0
  13. package/dist/components/Button/react/Button.js +12 -0
  14. package/dist/components/Callout/getProps.js +22 -0
  15. package/dist/components/Callout/presets.js +29 -0
  16. package/dist/components/Callout/react/Callout.js +20 -0
  17. package/dist/components/Chat/getProps.js +47 -0
  18. package/dist/components/Chat/react/Chat.js +22 -0
  19. package/dist/components/Details/getProps.js +15 -0
  20. package/dist/components/Details/react/Details.js +28 -0
  21. package/dist/components/Details/react/index.js +5 -0
  22. package/dist/components/DummyImage/astro/index.d.ts +1 -0
  23. package/dist/components/DummyImage/react/DummyImage.d.ts +2 -0
  24. package/dist/components/DummyImage/react/DummyImage.js +8 -0
  25. package/dist/components/DummyImage/react/index.d.ts +1 -0
  26. package/dist/components/DummyText/astro/index.d.ts +1 -0
  27. package/dist/components/DummyText/getContent.d.ts +11 -0
  28. package/dist/components/DummyText/getContent.js +9 -0
  29. package/dist/components/DummyText/react/DummyText.d.ts +10 -0
  30. package/dist/components/DummyText/react/DummyText.js +10 -0
  31. package/dist/components/DummyText/react/index.d.ts +1 -0
  32. package/dist/components/DummyText/texts.d.ts +22 -0
  33. package/dist/components/DummyText/texts.js +39 -0
  34. package/dist/components/Modal/getProps.js +25 -0
  35. package/dist/components/Modal/react/Body.js +9 -0
  36. package/dist/components/Modal/react/CloseBtn.js +13 -0
  37. package/dist/components/Modal/react/Inner.js +9 -0
  38. package/dist/components/Modal/react/Modal.d.ts +1 -2
  39. package/dist/components/Modal/react/Modal.js +17 -0
  40. package/dist/components/Modal/react/OpenBtn.js +9 -0
  41. package/dist/components/Modal/react/index.js +9 -0
  42. package/dist/components/Modal/setModal.js +16 -17
  43. package/dist/components/NavMenu/getProps.js +40 -0
  44. package/dist/components/NavMenu/react/NavMenu.js +24 -0
  45. package/dist/components/NavMenu/react/index.js +5 -0
  46. package/dist/components/ShapeDivider/getProps.js +22 -0
  47. package/dist/components/ShapeDivider/react/ShapeDivider.js +26 -0
  48. package/dist/components/Tabs/getProps.js +10 -0
  49. package/dist/components/Tabs/react/Tab.js +9 -0
  50. package/dist/components/Tabs/react/TabItem.js +7 -0
  51. package/dist/components/Tabs/react/TabList.js +8 -0
  52. package/dist/components/Tabs/react/TabPanel.js +9 -0
  53. package/dist/components/Tabs/react/Tabs.d.ts +1 -2
  54. package/dist/components/Tabs/react/Tabs.js +48 -0
  55. package/dist/components/Tabs/react/index.js +9 -0
  56. package/dist/components/Tabs/setTabs.js +10 -11
  57. package/dist/components/astro.d.ts +2 -0
  58. package/dist/components/react.d.ts +2 -0
  59. package/dist/components/react.js +30 -0
  60. package/dist/lism-css/dist/components/Center/index.js +8 -0
  61. package/dist/lism-css/dist/components/Flex/index.js +8 -0
  62. package/dist/lism-css/dist/components/Flow/index.js +8 -0
  63. package/dist/lism-css/dist/components/Frame/index.js +8 -0
  64. package/dist/lism-css/dist/components/Grid/index.js +8 -0
  65. package/dist/lism-css/dist/components/Lism/index.js +8 -0
  66. package/dist/lism-css/dist/components/Stack/index.js +8 -0
  67. package/dist/lism-css/dist/components/atomic/Decorator/getProps.js +15 -0
  68. package/dist/lism-css/dist/components/atomic/Decorator/index.js +9 -0
  69. package/dist/lism-css/dist/components/atomic/Icon/SVG.js +22 -0
  70. package/dist/lism-css/dist/components/atomic/Icon/getProps.js +56 -0
  71. package/dist/lism-css/dist/components/atomic/Icon/index.js +12 -0
  72. package/dist/lism-css/dist/components/atomic/Icon/presets.js +276 -0
  73. package/dist/lism-css/dist/config/default-config.js +11 -0
  74. package/dist/lism-css/dist/config/defaults/props.js +340 -0
  75. package/dist/lism-css/dist/config/defaults/states.js +39 -0
  76. package/dist/lism-css/dist/config/defaults/tokens.js +30 -0
  77. package/dist/lism-css/dist/config/helper/getSvgUrl.js +4 -0
  78. package/dist/lism-css/dist/config/helper.js +27 -0
  79. package/dist/lism-css/dist/config/index.js +17 -0
  80. package/dist/lism-css/dist/lib/getBpData.js +19 -0
  81. package/dist/lism-css/dist/lib/getLayoutProps.js +30 -0
  82. package/dist/lism-css/dist/lib/getLismProps.js +188 -0
  83. package/dist/lism-css/dist/lib/getMaybeCssVar.js +42 -0
  84. package/dist/lism-css/dist/lib/getMaybeTokenValue.js +26 -0
  85. package/dist/lism-css/dist/lib/getUtilKey.js +13 -0
  86. package/dist/lism-css/dist/lib/helper/atts.js +11 -0
  87. package/dist/lism-css/dist/lib/helper/filterEmptyObj.js +10 -0
  88. package/dist/lism-css/dist/lib/helper/hasSomeKeys.js +6 -0
  89. package/dist/lism-css/dist/lib/helper/isEmptyObj.js +6 -0
  90. package/dist/lism-css/dist/lib/helper/isNumStr.js +6 -0
  91. package/dist/lism-css/dist/lib/helper/splitWithComma.js +6 -0
  92. package/dist/lism-css/dist/lib/isPresetValue.js +13 -0
  93. package/dist/lism-css/dist/lib/isTokenValue.js +27 -0
  94. package/dist/style.css +1 -1
  95. package/dist/ui.css +1 -0
  96. package/package.json +9 -7
  97. package/src/components/Accordion/_style.css +69 -69
  98. package/src/components/Accordion/astro/Button.astro +2 -2
  99. package/src/components/Accordion/astro/Heading.astro +1 -1
  100. package/src/components/Accordion/astro/Item.astro +7 -7
  101. package/src/components/Accordion/astro/Panel.astro +3 -3
  102. package/src/components/Accordion/astro/Root.astro +3 -3
  103. package/src/components/Accordion/getProps.js +54 -54
  104. package/src/components/Accordion/react/AccIcon.jsx +1 -1
  105. package/src/components/Accordion/react/Accordion.jsx +37 -36
  106. package/src/components/Accordion/script.js +1 -1
  107. package/src/components/Accordion/setAccordion.js +93 -93
  108. package/src/components/Alert/astro/Alert.astro +6 -6
  109. package/src/components/Alert/getProps.ts +22 -22
  110. package/src/components/Alert/presets.ts +26 -26
  111. package/src/components/Alert/react/Alert.tsx +9 -9
  112. package/src/components/Avatar/astro/Avatar.astro +2 -2
  113. package/src/components/Avatar/react/Avatar.jsx +5 -5
  114. package/src/components/Badge/_style.css +14 -14
  115. package/src/components/Badge/astro/Badge.astro +4 -4
  116. package/src/components/Badge/react/Badge.jsx +6 -6
  117. package/src/components/Button/_style.css +29 -29
  118. package/src/components/Button/astro/Button.astro +4 -4
  119. package/src/components/Button/react/Button.jsx +6 -6
  120. package/src/components/Callout/astro/Callout.astro +13 -13
  121. package/src/components/Callout/getProps.ts +24 -24
  122. package/src/components/Callout/presets.ts +26 -26
  123. package/src/components/Callout/react/Callout.tsx +16 -16
  124. package/src/components/Chat/_style.css +49 -49
  125. package/src/components/Chat/astro/Chat.astro +27 -27
  126. package/src/components/Chat/getProps.js +40 -45
  127. package/src/components/Chat/react/Chat.jsx +17 -17
  128. package/src/components/Details/_style.css +39 -39
  129. package/src/components/Details/astro/Content.astro +3 -3
  130. package/src/components/Details/astro/Details.astro +1 -1
  131. package/src/components/Details/astro/Icon.astro +1 -1
  132. package/src/components/Details/astro/Summary.astro +2 -2
  133. package/src/components/Details/astro/Title.astro +1 -1
  134. package/src/components/Details/getProps.js +7 -7
  135. package/src/components/Details/react/Details.jsx +24 -24
  136. package/src/components/DummyImage/astro/DummyImage.astro +7 -0
  137. package/src/components/DummyImage/astro/index.ts +1 -0
  138. package/src/components/DummyImage/react/DummyImage.tsx +5 -0
  139. package/src/components/DummyImage/react/index.ts +1 -0
  140. package/src/components/DummyText/astro/DummyText.astro +9 -0
  141. package/src/components/DummyText/astro/index.ts +1 -0
  142. package/src/components/DummyText/getContent.ts +39 -0
  143. package/src/components/DummyText/react/DummyText.tsx +15 -0
  144. package/src/components/DummyText/react/index.ts +1 -0
  145. package/src/components/DummyText/texts.ts +39 -0
  146. package/src/components/Modal/_style.css +34 -34
  147. package/src/components/Modal/astro/Body.astro +1 -1
  148. package/src/components/Modal/astro/CloseBtn.astro +10 -10
  149. package/src/components/Modal/astro/Inner.astro +1 -1
  150. package/src/components/Modal/astro/Modal.astro +3 -3
  151. package/src/components/Modal/astro/OpenBtn.astro +1 -1
  152. package/src/components/Modal/getProps.js +19 -19
  153. package/src/components/Modal/react/Body.jsx +5 -5
  154. package/src/components/Modal/react/CloseBtn.jsx +13 -13
  155. package/src/components/Modal/react/Inner.jsx +1 -1
  156. package/src/components/Modal/react/Modal.jsx +12 -11
  157. package/src/components/Modal/react/OpenBtn.jsx +5 -5
  158. package/src/components/Modal/script.js +1 -1
  159. package/src/components/Modal/setModal.ts +92 -92
  160. package/src/components/NavMenu/_style.css +17 -17
  161. package/src/components/NavMenu/astro/Item.astro +1 -1
  162. package/src/components/NavMenu/astro/Link.astro +1 -1
  163. package/src/components/NavMenu/astro/Nest.astro +1 -1
  164. package/src/components/NavMenu/astro/Root.astro +1 -1
  165. package/src/components/NavMenu/getProps.js +28 -28
  166. package/src/components/NavMenu/react/NavMenu.jsx +4 -4
  167. package/src/components/ShapeDivider/_style.css +51 -51
  168. package/src/components/ShapeDivider/astro/ShapeDivider.astro +20 -20
  169. package/src/components/ShapeDivider/getProps.js +23 -23
  170. package/src/components/ShapeDivider/react/ShapeDivider.jsx +24 -24
  171. package/src/components/Tabs/_style.css +29 -29
  172. package/src/components/Tabs/astro/Tab.astro +2 -2
  173. package/src/components/Tabs/astro/TabItem.astro +1 -1
  174. package/src/components/Tabs/astro/TabList.astro +2 -2
  175. package/src/components/Tabs/astro/TabPanel.astro +2 -2
  176. package/src/components/Tabs/astro/Tabs.astro +20 -20
  177. package/src/components/Tabs/astro/transformTabitems.js +30 -30
  178. package/src/components/Tabs/getProps.js +4 -4
  179. package/src/components/Tabs/react/Tab.jsx +4 -12
  180. package/src/components/Tabs/react/TabItem.jsx +1 -1
  181. package/src/components/Tabs/react/TabList.jsx +2 -2
  182. package/src/components/Tabs/react/TabPanel.jsx +2 -2
  183. package/src/components/Tabs/react/Tabs.jsx +46 -47
  184. package/src/components/Tabs/script.js +4 -4
  185. package/src/components/Tabs/setTabs.js +70 -70
  186. package/src/components/astro.ts +2 -0
  187. package/src/components/react.ts +2 -0
  188. package/src/helper/animation.ts +10 -10
  189. package/src/helper/uuid.js +3 -3
@@ -8,24 +8,24 @@ const { viewBox, isAnimation, isEmpty, ...lismProps } = componentProps || {};
8
8
  ---
9
9
 
10
10
  {
11
- componentProps && (
12
- <Lism {...lismProps}>
13
- {isEmpty ? null : (
14
- <div class='c--shapeDivider_inner'>
15
- <svg
16
- xmlns='http://www.w3.org/2000/svg'
17
- class='c--shapeDivider_svg'
18
- viewBox={viewBox}
19
- width='100%'
20
- height='100%'
21
- fill='currentColor'
22
- focusable='false'
23
- preserveAspectRatio='none'
24
- >
25
- <slot />
26
- </svg>
27
- </div>
28
- )}
29
- </Lism>
30
- )
11
+ componentProps && (
12
+ <Lism {...lismProps}>
13
+ {isEmpty ? null : (
14
+ <div class="c--shapeDivider_inner">
15
+ <svg
16
+ xmlns="http://www.w3.org/2000/svg"
17
+ class="c--shapeDivider_svg"
18
+ viewBox={viewBox}
19
+ width="100%"
20
+ height="100%"
21
+ fill="currentColor"
22
+ focusable="false"
23
+ preserveAspectRatio="none"
24
+ >
25
+ <slot />
26
+ </svg>
27
+ </div>
28
+ )}
29
+ </Lism>
30
+ )
31
31
  }
@@ -9,32 +9,32 @@
9
9
  * @param {string} [props.flip] - X/Y/XY で反転方向を指定
10
10
  */
11
11
  export default function getProps({ viewBox, isAnimation, isEmpty, level = 5, stretch, offset, flip, style = {}, ...restProps }) {
12
- // level が 0 の場合は非表示
13
- if (level === 0) return null;
12
+ // level が 0 の場合は非表示
13
+ if (level === 0) return null;
14
14
 
15
- // CSS変数をセット
16
- const computedStyle = { ...style };
17
- computedStyle['--level'] = level || null;
18
- computedStyle['--_inner-offset'] = offset || null;
19
- computedStyle['--_inner-stretch'] = stretch || null;
15
+ // CSS変数をセット
16
+ const computedStyle = { ...style };
17
+ computedStyle['--level'] = level || null;
18
+ computedStyle['--_inner-offset'] = offset || null;
19
+ computedStyle['--_inner-stretch'] = stretch || null;
20
20
 
21
- const _props = {
22
- lismClass: 'c--shapeDivider',
23
- 'max-sz': 'full',
24
- 'aria-hidden': 'true',
25
- };
26
- if (flip) _props['data-flip'] = flip;
27
- if (isAnimation) _props['data-has-animation'] = 'true';
21
+ const _props = {
22
+ lismClass: 'c--shapeDivider',
23
+ 'max-sz': 'full',
24
+ 'aria-hidden': 'true',
25
+ };
26
+ if (flip) _props['data-flip'] = flip;
27
+ if (isAnimation) _props['data-has-animation'] = 'true';
28
28
 
29
- return {
30
- ..._props,
31
- style: computedStyle,
29
+ return {
30
+ ..._props,
31
+ style: computedStyle,
32
32
 
33
- // SVG用のprops
34
- viewBox,
35
- isEmpty,
33
+ // SVG用のprops
34
+ viewBox,
35
+ isEmpty,
36
36
 
37
- // その他のprops
38
- ...restProps,
39
- };
37
+ // その他のprops
38
+ ...restProps,
39
+ };
40
40
  }
@@ -3,31 +3,31 @@ import getProps from '../getProps';
3
3
  import '../_style.css';
4
4
 
5
5
  export default function ShapeDivider({ children, ...props }) {
6
- const componentProps = getProps(props);
6
+ const componentProps = getProps(props);
7
7
 
8
- // level が 0 の場合は非表示
9
- if (!componentProps) return null;
8
+ // level が 0 の場合は非表示
9
+ if (!componentProps) return null;
10
10
 
11
- const { viewBox, isAnimation, isEmpty, ...lismProps } = componentProps;
11
+ const { viewBox, isAnimation, isEmpty, ...lismProps } = componentProps;
12
12
 
13
- return (
14
- <Lism {...lismProps}>
15
- {isEmpty ? null : (
16
- <div className='c--shapeDivider_inner'>
17
- <svg
18
- xmlns='http://www.w3.org/2000/svg'
19
- className='c--shapeDivider_svg'
20
- viewBox={viewBox}
21
- width='100%'
22
- height='100%'
23
- fill='currentColor'
24
- focusable='false'
25
- preserveAspectRatio='none'
26
- >
27
- {children}
28
- </svg>
29
- </div>
30
- )}
31
- </Lism>
32
- );
13
+ return (
14
+ <Lism {...lismProps}>
15
+ {isEmpty ? null : (
16
+ <div className="c--shapeDivider_inner">
17
+ <svg
18
+ xmlns="http://www.w3.org/2000/svg"
19
+ className="c--shapeDivider_svg"
20
+ viewBox={viewBox}
21
+ width="100%"
22
+ height="100%"
23
+ fill="currentColor"
24
+ focusable="false"
25
+ preserveAspectRatio="none"
26
+ >
27
+ {children}
28
+ </svg>
29
+ </div>
30
+ )}
31
+ </Lism>
32
+ );
33
33
  }
@@ -1,32 +1,32 @@
1
- @layer lism.modules {
2
- .c--tabs {
3
- display: grid;
4
- grid: 'list' 'panel' / 100%;
5
- }
6
- .c--tabs_list {
7
- grid-area: list;
8
- display: flex;
9
- overflow-x: auto;
10
- }
11
- .c--tabs_tab {
12
- &[aria-selected='true'] {
13
- --_notSelected: ;
14
- }
15
- &[aria-selected='false'] {
16
- --_isSelected: ;
17
- }
18
- /* 非アクティブの時、薄いカラーに */
19
- :where(&) {
20
- color: var(--_notSelected, var(--text-2));
21
- }
22
- }
1
+ @layer lism-modules {
2
+ .c--tabs {
3
+ display: grid;
4
+ grid: 'list' 'panel' / 100%;
5
+ }
6
+ .c--tabs_list {
7
+ grid-area: list;
8
+ display: flex;
9
+ overflow-x: auto;
10
+ }
11
+ .c--tabs_tab {
12
+ &[aria-selected='true'] {
13
+ --_notSelected: ;
14
+ }
15
+ &[aria-selected='false'] {
16
+ --_isSelected: ;
17
+ }
18
+ /* 非アクティブの時、薄いカラーに */
19
+ :where(&) {
20
+ color: var(--_notSelected, var(--text-2));
21
+ }
22
+ }
23
23
 
24
- .c--tabs_panel {
25
- grid-area: panel;
26
- width: 100%;
24
+ .c--tabs_panel {
25
+ grid-area: panel;
26
+ width: 100%;
27
27
 
28
- &:where([aria-hidden='true']) {
29
- display: none;
30
- }
31
- }
28
+ &:where([aria-hidden='true']) {
29
+ display: none;
30
+ }
31
+ }
32
32
  }
@@ -12,6 +12,6 @@ const { tabId = 'tab', index = 0, isActive, ...props } = Astro.props;
12
12
  const controlId = `${tabId}-${index}`;
13
13
  ---
14
14
 
15
- <Lism as='button' lismClass='c--tabs_tab' setPlain role='tab' aria-controls={controlId} aria-selected={isActive ? 'true' : 'false'} {...props}>
16
- <slot />
15
+ <Lism as="button" lismClass="c--tabs_tab" setPlain role="tab" aria-controls={controlId} aria-selected={isActive ? 'true' : 'false'} {...props}>
16
+ <slot />
17
17
  </Lism>
@@ -4,5 +4,5 @@
4
4
  ---
5
5
 
6
6
  <lism-placeholder-tabitem>
7
- <slot />
7
+ <slot />
8
8
  </lism-placeholder-tabitem>
@@ -3,6 +3,6 @@
3
3
  import { Lism } from 'lism-css/astro';
4
4
  ---
5
5
 
6
- <Lism lismClass='c--tabs_list' role='tablist' {...Astro.props}>
7
- <slot />
6
+ <Lism lismClass="c--tabs_list" role="tablist" {...Astro.props}>
7
+ <slot />
8
8
  </Lism>
@@ -11,6 +11,6 @@ const { tabId = 'tab', index = 0, isActive = false, ...props } = Astro.props;
11
11
  const controlId = `${tabId}-${index}`;
12
12
  ---
13
13
 
14
- <Lism id={controlId} role='tabpanel' aria-hidden={isActive ? 'false' : 'true'} lismClass='c--tabs_panel' {...props}>
15
- <slot />
14
+ <Lism id={controlId} role="tabpanel" aria-hidden={isActive ? 'false' : 'true'} lismClass="c--tabs_panel" {...props}>
15
+ <slot />
16
16
  </Lism>
@@ -32,27 +32,27 @@ const hasItems = btns.length > 0;
32
32
  ---
33
33
 
34
34
  <Lism {...getTabsProps(props)}>
35
- {
36
- btns && (
37
- <TabList {...listProps}>
38
- {btns.map((btn, index) => {
39
- return <Fragment key={index} set:html={btn} />;
40
- })}
41
- </TabList>
42
- )
43
- }
44
- {
45
- panels.map((panel, index) => {
46
- return <Fragment key={index} set:html={panel} />;
47
- })
48
- }
49
- {!hasItems && <slot />}
35
+ {
36
+ btns && (
37
+ <TabList {...listProps}>
38
+ {btns.map((btn, index) => {
39
+ return <Fragment key={index} set:html={btn} />;
40
+ })}
41
+ </TabList>
42
+ )
43
+ }
44
+ {
45
+ panels.map((panel, index) => {
46
+ return <Fragment key={index} set:html={panel} />;
47
+ })
48
+ }
49
+ {!hasItems && <slot />}
50
50
  </Lism>
51
51
 
52
52
  <script>
53
- import setTabs from '../setTabs';
54
- const tabsAll = document.querySelectorAll('.c--tabs');
55
- tabsAll.forEach((tabs) => {
56
- setTabs(tabs);
57
- });
53
+ import setTabs from '../setTabs';
54
+ const tabsAll = document.querySelectorAll('.c--tabs');
55
+ tabsAll.forEach((tabs) => {
56
+ setTabs(tabs);
57
+ });
58
58
  </script>
@@ -1,40 +1,40 @@
1
1
  // <lism-placeholder-tabitem> → div.tabitem へ 変換
2
2
  export default function transformHTML(htmlString, tabID, defaultIndex) {
3
- let index = 1; // 1スタート
4
- let btns = [];
5
- let panels = [];
3
+ let index = 1; // 1スタート
4
+ let btns = [];
5
+ let panels = [];
6
6
 
7
- // <lism-placeholder-tabitem>でコンテンツを囲んでいるので中身を解析する。
8
- const regex = /<lism-placeholder-tabitem(.*?)>(.*?)<\/lism-placeholder-tabitem>/gs;
9
- const matches = [...htmlString.matchAll(regex)];
7
+ // <lism-placeholder-tabitem>でコンテンツを囲んでいるので中身を解析する。
8
+ const regex = /<lism-placeholder-tabitem(.*?)>(.*?)<\/lism-placeholder-tabitem>/gs;
9
+ const matches = [...htmlString.matchAll(regex)];
10
10
 
11
- // console.log(matches);
12
- matches.forEach((match) => {
13
- // const tabItemAttrs = match[1]; // 使わないがdata-astro-source-file属性が自動でついてきたりするので、属性値があっても問題ないようにしている。
14
- const tabItemContent = match[2];
11
+ // console.log(matches);
12
+ matches.forEach((match) => {
13
+ // const tabItemAttrs = match[1]; // 使わないがdata-astro-source-file属性が自動でついてきたりするので、属性値があっても問題ないようにしている。
14
+ const tabItemContent = match[2];
15
15
 
16
- const controlId = `${tabID}-${index}`;
17
- const isActive = index === defaultIndex;
18
- index++;
16
+ const controlId = `${tabID}-${index}`;
17
+ const isActive = index === defaultIndex;
18
+ index++;
19
19
 
20
- // <lism-placeholder-tabtbn>からタブボタンを生成
21
- const btnMatch = tabItemContent.match(/<button(.*?)>(.*?)<\/button>(.*)/s);
22
- if (!btnMatch) return;
23
- let btnAtts = btnMatch[1];
24
- let btnContent = btnMatch[2];
25
- let panel = btnMatch[3];
20
+ // <lism-placeholder-tabtbn>からタブボタンを生成
21
+ const btnMatch = tabItemContent.match(/<button(.*?)>(.*?)<\/button>(.*)/s);
22
+ if (!btnMatch) return;
23
+ let btnAtts = btnMatch[1];
24
+ let btnContent = btnMatch[2];
25
+ let panel = btnMatch[3];
26
26
 
27
- // btnContent = btnContent.replace(` slot="tab"`, '');
28
- btnAtts = btnAtts.replace(`aria-controls="tab-0"`, `aria-controls="${controlId}"`);
29
- panel = panel.replace(`id="tab-0"`, `id="${controlId}"`);
30
- if (isActive) {
31
- btnAtts = btnAtts.replace(/aria-selected="false"/, 'aria-selected="true"');
32
- panel = panel.replace(/aria-hidden="true"/, 'aria-hidden="false"');
33
- }
27
+ // btnContent = btnContent.replace(` slot="tab"`, '');
28
+ btnAtts = btnAtts.replace(`aria-controls="tab-0"`, `aria-controls="${controlId}"`);
29
+ panel = panel.replace(`id="tab-0"`, `id="${controlId}"`);
30
+ if (isActive) {
31
+ btnAtts = btnAtts.replace(/aria-selected="false"/, 'aria-selected="true"');
32
+ panel = panel.replace(/aria-hidden="true"/, 'aria-hidden="false"');
33
+ }
34
34
 
35
- btns.push(`<button${btnAtts}>${btnContent}</button>`);
36
- panels.push(panel);
37
- });
35
+ btns.push(`<button${btnAtts}>${btnContent}</button>`);
36
+ panels.push(panel);
37
+ });
38
38
 
39
- return { btns, panels };
39
+ return { btns, panels };
40
40
  }
@@ -1,8 +1,8 @@
1
1
  import atts from 'lism-css/lib/helper/atts';
2
2
 
3
3
  export default function getTabsProps({ lismClass, ...props }) {
4
- return {
5
- lismClass: atts(lismClass, 'c--tabs'),
6
- ...props,
7
- };
4
+ return {
5
+ lismClass: atts(lismClass, 'c--tabs'),
6
+ ...props,
7
+ };
8
8
  }
@@ -2,17 +2,9 @@
2
2
  import { Lism } from 'lism-css/react';
3
3
 
4
4
  export default function Tab({ tabId = 'tab', index = 0, isActive = false, ...props }) {
5
- const controlId = `${tabId}-${index}`;
5
+ const controlId = `${tabId}-${index}`;
6
6
 
7
- return (
8
- <Lism
9
- as='button'
10
- lismClass='c--tabs_tab'
11
- setPlain
12
- role='tab'
13
- aria-controls={controlId}
14
- aria-selected={isActive ? 'true' : 'false'}
15
- {...props}
16
- />
17
- );
7
+ return (
8
+ <Lism as="button" lismClass="c--tabs_tab" setPlain role="tab" aria-controls={controlId} aria-selected={isActive ? 'true' : 'false'} {...props} />
9
+ );
18
10
  }
@@ -1,5 +1,5 @@
1
1
  // Note: <Tabs>側でループして色々処理される。
2
2
  // 引数でちゃんと処理したいpropを書いておかないとだめ。
3
3
  export default function TabItem({ isTabItem = true, children }) {
4
- return <div>{children}</div>;
4
+ return <div>{children}</div>;
5
5
  }
@@ -1,6 +1,6 @@
1
1
  import { Lism } from 'lism-css/react';
2
2
 
3
3
  export default function TabList(props) {
4
- // jc: 's',
5
- return <Lism lismClass='c--tabs_list' role='tablist' {...props} />;
4
+ // jc: 's',
5
+ return <Lism lismClass="c--tabs_list" role="tablist" {...props} />;
6
6
  }
@@ -2,7 +2,7 @@
2
2
  import { Lism } from 'lism-css/react';
3
3
 
4
4
  export default function TabPanel({ tabId = 'tab', isActive = false, index = 0, ...props }) {
5
- const controlId = `${tabId}-${index}`;
5
+ const controlId = `${tabId}-${index}`;
6
6
 
7
- return <Lism id={controlId} role='tabpanel' aria-hidden={isActive ? 'false' : 'true'} lismClass='c--tabs_panel' {...props} />;
7
+ return <Lism id={controlId} role="tabpanel" aria-hidden={isActive ? 'false' : 'true'} lismClass="c--tabs_panel" {...props} />;
8
8
  }
@@ -1,4 +1,5 @@
1
- import React from 'react';
1
+ 'use client';
2
+ import { useState, useId, Children, isValidElement } from 'react';
2
3
  import { Lism } from 'lism-css/react';
3
4
  import Tab from './Tab';
4
5
  import TabItem from './TabItem';
@@ -10,53 +11,51 @@ import getTabsProps from '../getProps';
10
11
  import '../_style.css';
11
12
 
12
13
  export default function Tabs({ tabId = '', defaultIndex = 1, listProps = {}, children, ...props }) {
13
- const [activeIndex, setActiveIndex] = React.useState(defaultIndex);
14
- const theTabId = tabId || React.useId();
15
- const btns = [];
16
- const panels = [];
14
+ const [activeIndex, setActiveIndex] = useState(defaultIndex);
15
+ const theTabId = tabId || useId();
16
+ const btns = [];
17
+ const panels = [];
17
18
 
18
- // Tabs.Item の処理
19
- React.Children.forEach(children, (child, index) => {
20
- const tabIndex = index + 1; // 1 はじまり
21
- // console.log('child.type', React.isValidElement(child), child.type);
19
+ // Tabs.Item の処理
20
+ Children.forEach(children, (child, index) => {
21
+ const tabIndex = index + 1; // 1 はじまり
22
+ // console.log('child.type', isValidElement(child), child.type);
22
23
 
23
- if (React.isValidElement(child) && child.type === TabItem) {
24
- React.Children.forEach(child.props.children, (nestedChild) => {
25
- if (React.isValidElement(nestedChild)) {
26
- if (nestedChild.type === Tab) {
27
- const tabProps = nestedChild.props;
28
- btns.push(
29
- <Tab
30
- {...tabProps}
31
- tabId={theTabId}
32
- index={tabIndex}
33
- key={tabIndex}
34
- isActive={tabIndex === activeIndex}
35
- onClick={() => setActiveIndex(tabIndex)}
36
- />
37
- );
38
- } else if (nestedChild.type === TabPanel) {
39
- const panelProps = nestedChild.props;
40
- panels.push(
41
- <TabPanel {...panelProps} tabId={theTabId} index={tabIndex} key={tabIndex} isActive={tabIndex === activeIndex} />
42
- );
43
- }
44
- }
45
- });
46
- }
47
- });
24
+ if (isValidElement(child) && child.type === TabItem) {
25
+ Children.forEach(child.props.children, (nestedChild) => {
26
+ if (isValidElement(nestedChild)) {
27
+ if (nestedChild.type === Tab) {
28
+ const tabProps = nestedChild.props;
29
+ btns.push(
30
+ <Tab
31
+ {...tabProps}
32
+ tabId={theTabId}
33
+ index={tabIndex}
34
+ key={tabIndex}
35
+ isActive={tabIndex === activeIndex}
36
+ onClick={() => setActiveIndex(tabIndex)}
37
+ />
38
+ );
39
+ } else if (nestedChild.type === TabPanel) {
40
+ const panelProps = nestedChild.props;
41
+ panels.push(<TabPanel {...panelProps} tabId={theTabId} index={tabIndex} key={tabIndex} isActive={tabIndex === activeIndex} />);
42
+ }
43
+ }
44
+ });
45
+ }
46
+ });
48
47
 
49
- return (
50
- <Lism {...getTabsProps(props)}>
51
- {btns.length === 0 ? (
52
- // TabItemを使わず直接TabListなどを子要素に配置する場合
53
- children
54
- ) : (
55
- <>
56
- <TabList {...listProps}>{btns}</TabList>
57
- {panels}
58
- </>
59
- )}
60
- </Lism>
61
- );
48
+ return (
49
+ <Lism {...getTabsProps(props)}>
50
+ {btns.length === 0 ? (
51
+ // TabItemを使わず直接TabListなどを子要素に配置する場合
52
+ children
53
+ ) : (
54
+ <>
55
+ <TabList {...listProps}>{btns}</TabList>
56
+ {panels}
57
+ </>
58
+ )}
59
+ </Lism>
60
+ );
62
61
  }
@@ -1,8 +1,8 @@
1
1
  import setTabs from './setTabs.js';
2
2
 
3
3
  document.addEventListener('DOMContentLoaded', function () {
4
- const tabsAll = document.querySelectorAll('.c--tabs');
5
- tabsAll.forEach((tabs) => {
6
- setTabs(tabs);
7
- });
4
+ const tabsAll = document.querySelectorAll('.c--tabs');
5
+ tabsAll.forEach((tabs) => {
6
+ setTabs(tabs);
7
+ });
8
8
  });