@lism-css/ui 0.11.0 → 0.12.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 (207) 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 +16 -6
  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 +36 -36
  43. package/dist/components/Modal/getProps.js +36 -17
  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 +14 -4
  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/defaults/props.js +16 -26
  83. package/dist/lism-css/dist/config/defaults/states.js +3 -23
  84. package/dist/lism-css/dist/lib/getLayoutProps.js +6 -9
  85. package/dist/lism-css/dist/lib/getLismProps.js +94 -92
  86. package/dist/lism-css/dist/lib/helper/mergeSet.js +14 -0
  87. package/dist/style.css +1 -1
  88. package/dist/ui.css +1 -1
  89. package/package.json +14 -7
  90. package/src/components/Accordion/Accordion.stories.tsx +105 -0
  91. package/src/components/Accordion/astro/Button.astro +2 -2
  92. package/src/components/Accordion/getProps.ts +91 -0
  93. package/src/components/Accordion/react/{AccIcon.jsx → AccIcon.tsx} +2 -2
  94. package/src/components/Accordion/react/{Accordion.jsx → Accordion.tsx} +33 -11
  95. package/src/components/Accordion/setAccordion.ts +120 -0
  96. package/src/components/Alert/Alert.stories.tsx +64 -0
  97. package/src/components/Alert/getProps.ts +5 -3
  98. package/src/components/Alert/react/Alert.tsx +3 -3
  99. package/src/components/Avatar/Avatar.stories.tsx +42 -0
  100. package/src/components/Avatar/react/Avatar.tsx +17 -0
  101. package/src/components/Badge/Badge.stories.tsx +40 -0
  102. package/src/components/Badge/astro/Badge.astro +1 -7
  103. package/src/components/Badge/react/Badge.tsx +7 -0
  104. package/src/components/Button/Button.stories.tsx +44 -0
  105. package/src/components/Button/astro/Button.astro +1 -7
  106. package/src/components/Button/react/Button.tsx +7 -0
  107. package/src/components/Callout/Callout.stories.tsx +55 -0
  108. package/src/components/Callout/getProps.ts +3 -2
  109. package/src/components/Callout/react/Callout.tsx +3 -3
  110. package/src/components/Chat/Chat.stories.tsx +58 -0
  111. package/src/components/Chat/_style.css +5 -5
  112. package/src/components/Chat/{getProps.js → getProps.ts} +10 -4
  113. package/src/components/Chat/react/{Chat.jsx → Chat.tsx} +13 -3
  114. package/src/components/Details/Details.stories.tsx +61 -0
  115. package/src/components/Details/astro/Title.astro +2 -2
  116. package/src/components/Details/{getProps.js → getProps.ts} +19 -6
  117. package/src/components/Details/react/Details.tsx +69 -0
  118. package/src/components/DummyImage/DummyImage.stories.tsx +23 -0
  119. package/src/components/DummyText/DummyText.stories.tsx +48 -0
  120. package/src/components/Modal/Modal.stories.tsx +67 -0
  121. package/src/components/Modal/astro/CloseBtn.astro +2 -2
  122. package/src/components/Modal/astro/OpenBtn.astro +2 -3
  123. package/src/components/Modal/getProps.ts +65 -0
  124. package/src/components/Modal/react/Body.tsx +10 -0
  125. package/src/components/Modal/react/CloseBtn.tsx +24 -0
  126. package/src/components/Modal/react/Inner.tsx +6 -0
  127. package/src/components/Modal/react/Modal.tsx +24 -0
  128. package/src/components/Modal/react/OpenBtn.tsx +15 -0
  129. package/src/components/Modal/{script.js → script.ts} +1 -1
  130. package/src/components/NavMenu/NavMenu.stories.tsx +68 -0
  131. package/src/components/NavMenu/getProps.ts +60 -0
  132. package/src/components/NavMenu/react/NavMenu.tsx +40 -0
  133. package/src/components/ShapeDivider/ShapeDivider.stories.tsx +87 -0
  134. package/src/components/ShapeDivider/getProps.ts +36 -0
  135. package/src/components/ShapeDivider/react/{ShapeDivider.jsx → ShapeDivider.tsx} +4 -4
  136. package/src/components/Tabs/Tabs.stories.tsx +79 -0
  137. package/src/components/Tabs/astro/Tab.astro +2 -1
  138. package/src/components/Tabs/astro/{transformTabitems.js → transformTabitems.ts} +9 -9
  139. package/src/components/Tabs/getProps.ts +23 -0
  140. package/src/components/Tabs/react/Tab.tsx +21 -0
  141. package/src/components/Tabs/react/TabItem.tsx +13 -0
  142. package/src/components/Tabs/react/TabList.tsx +5 -0
  143. package/src/components/Tabs/react/{TabPanel.jsx → TabPanel.tsx} +8 -3
  144. package/src/components/Tabs/react/{Tabs.jsx → Tabs.tsx} +27 -12
  145. package/src/components/Tabs/{script.js → script.ts} +2 -2
  146. package/src/components/Tabs/setTabs.ts +65 -0
  147. package/src/helper/{uuid.js → uuid.ts} +2 -2
  148. package/src/vite-env.d.ts +1 -0
  149. package/dist/components/Accordion/astro/__setEvent.d.ts +0 -1
  150. package/dist/components/Accordion/astro/index.d.ts +0 -15
  151. package/dist/components/Alert/astro/index.d.ts +0 -1
  152. package/dist/components/Callout/astro/index.d.ts +0 -1
  153. package/dist/components/Details/astro/index.d.ts +0 -13
  154. package/dist/components/DummyImage/astro/index.d.ts +0 -1
  155. package/dist/components/DummyText/astro/index.d.ts +0 -1
  156. package/dist/components/Modal/astro/index.d.ts +0 -13
  157. package/dist/components/NavMenu/astro/index.d.ts +0 -11
  158. package/dist/components/Tabs/astro/index.d.ts +0 -13
  159. package/dist/components/Tabs/astro/transformTabitems.d.ts +0 -4
  160. package/dist/components/astro.d.ts +0 -14
  161. package/dist/lism-css/dist/config/helper/getSvgUrl.js +0 -4
  162. package/src/components/Accordion/getProps.js +0 -77
  163. package/src/components/Accordion/setAccordion.js +0 -146
  164. package/src/components/Avatar/astro/index.js +0 -1
  165. package/src/components/Avatar/react/Avatar.jsx +0 -9
  166. package/src/components/Badge/astro/index.js +0 -1
  167. package/src/components/Badge/react/Badge.jsx +0 -12
  168. package/src/components/Button/astro/index.js +0 -1
  169. package/src/components/Button/react/Button.jsx +0 -12
  170. package/src/components/Chat/astro/index.js +0 -1
  171. package/src/components/Details/react/Details.jsx +0 -66
  172. package/src/components/Modal/getProps.js +0 -30
  173. package/src/components/Modal/react/Body.jsx +0 -10
  174. package/src/components/Modal/react/CloseBtn.jsx +0 -20
  175. package/src/components/Modal/react/Inner.jsx +0 -6
  176. package/src/components/Modal/react/Modal.jsx +0 -23
  177. package/src/components/Modal/react/OpenBtn.jsx +0 -11
  178. package/src/components/NavMenu/getProps.js +0 -65
  179. package/src/components/NavMenu/react/NavMenu.jsx +0 -19
  180. package/src/components/ShapeDivider/astro/index.js +0 -1
  181. package/src/components/ShapeDivider/getProps.js +0 -40
  182. package/src/components/Tabs/getProps.js +0 -8
  183. package/src/components/Tabs/react/Tab.jsx +0 -10
  184. package/src/components/Tabs/react/TabItem.jsx +0 -5
  185. package/src/components/Tabs/react/TabList.jsx +0 -6
  186. package/src/components/Tabs/setTabs.js +0 -87
  187. /package/src/components/Accordion/astro/{index.js → index.ts} +0 -0
  188. /package/src/components/Accordion/react/{index.js → index.ts} +0 -0
  189. /package/src/components/Accordion/{script.js → script.ts} +0 -0
  190. /package/{dist/components/Avatar/astro/index.d.ts → src/components/Avatar/astro/index.ts} +0 -0
  191. /package/src/components/Avatar/react/{index.js → index.ts} +0 -0
  192. /package/{dist/components/Badge/astro/index.d.ts → src/components/Badge/astro/index.ts} +0 -0
  193. /package/src/components/Badge/react/{index.js → index.ts} +0 -0
  194. /package/{dist/components/Button/astro/index.d.ts → src/components/Button/astro/index.ts} +0 -0
  195. /package/src/components/Button/react/{index.js → index.ts} +0 -0
  196. /package/{dist/components/Chat/astro/index.d.ts → src/components/Chat/astro/index.ts} +0 -0
  197. /package/src/components/Chat/react/{index.js → index.ts} +0 -0
  198. /package/src/components/Details/astro/{index.js → index.ts} +0 -0
  199. /package/src/components/Details/react/{index.js → index.ts} +0 -0
  200. /package/src/components/Modal/astro/{index.js → index.ts} +0 -0
  201. /package/src/components/Modal/react/{index.js → index.ts} +0 -0
  202. /package/src/components/NavMenu/astro/{index.js → index.ts} +0 -0
  203. /package/src/components/NavMenu/react/{index.js → index.ts} +0 -0
  204. /package/{dist/components/ShapeDivider/astro/index.d.ts → src/components/ShapeDivider/astro/index.ts} +0 -0
  205. /package/src/components/ShapeDivider/react/{index.js → index.ts} +0 -0
  206. /package/src/components/Tabs/astro/{index.js → index.ts} +0 -0
  207. /package/src/components/Tabs/react/{index.js → index.ts} +0 -0
@@ -1,12 +0,0 @@
1
- import { Flex } from 'lism-css/react';
2
- import '../_style.css';
3
-
4
- export default function Button(props) {
5
- // c--button では c, bgc は 変数で受け取る
6
- const _propConfig = {
7
- c: { isVar: 1 },
8
- bgc: { isVar: 1 },
9
- };
10
-
11
- return <Flex lismClass="c--button" as="a" lh="s" py="10" px="20" hov="o" _propConfig={_propConfig} {...props} />;
12
- }
@@ -1 +0,0 @@
1
- export { default } from './Chat.astro';
@@ -1,66 +0,0 @@
1
- /**
2
- * React版 Detailsコンポーネント
3
- */
4
- import getLismProps from 'lism-css/lib/getLismProps';
5
- import { Lism } from 'lism-css/react';
6
- import { getDetailsProps, defaultProps } from '../getProps';
7
-
8
- // スタイルのインポート
9
- import '../_style.css';
10
-
11
- /**
12
- * Details - ルートコンポーネント
13
- * details要素をレンダリング
14
- */
15
- export function Details({ children, ...props }) {
16
- const lismProps = getLismProps(getDetailsProps(props));
17
-
18
- return <details {...lismProps}>{children}</details>;
19
- }
20
-
21
- /**
22
- * Summary - サマリーコンポーネント
23
- * details要素のsummary部分
24
- */
25
- export function Summary({ children, ...props }) {
26
- return (
27
- <Lism as="summary" {...defaultProps.summary} {...props}>
28
- {children}
29
- </Lism>
30
- );
31
- }
32
-
33
- /**
34
- * Title - タイトルコンポーネント
35
- */
36
- export function Title({ children, ...props }) {
37
- return (
38
- <Lism {...defaultProps.title} {...props}>
39
- {children}
40
- </Lism>
41
- );
42
- }
43
-
44
- /**
45
- * Icon - アイコンコンポーネント
46
- */
47
- export function Icon({ children, ...props }) {
48
- return (
49
- <Lism {...defaultProps.icon} {...props}>
50
- {children}
51
- </Lism>
52
- );
53
- }
54
-
55
- /**
56
- * Content - コンテンツコンポーネント
57
- */
58
- export function Content({ children, ...props }) {
59
- return (
60
- <Lism {...defaultProps.body}>
61
- <Lism {...defaultProps.content} {...props}>
62
- {children}
63
- </Lism>
64
- </Lism>
65
- );
66
- }
@@ -1,30 +0,0 @@
1
- import atts from 'lism-css/lib/helper/atts';
2
-
3
- export function getProps({ lismClass = '', duration, style = {}, ...props }) {
4
- const theProps = {
5
- lismClass: atts(lismClass, 'c--modal'),
6
- setPlain: true,
7
- };
8
- if (duration) {
9
- style['--duration'] = duration;
10
- }
11
-
12
- return { as: 'dialog', ...theProps, style, ...props };
13
- }
14
-
15
- export function getInnerProps({ lismClass = '', offset, style = {}, ...props }) {
16
- if (offset) {
17
- style['--offset'] = offset;
18
- }
19
- return {
20
- lismClass: atts(lismClass, 'c--modal_inner'),
21
- style,
22
- ...props,
23
- };
24
- }
25
-
26
- export const defaultProps = {
27
- body: { lismClass: 'c--modal_body' },
28
- closeBtn: { as: 'button', setPlain: true, hov: 'o', d: 'in-flex' },
29
- openBtn: { as: 'button', setPlain: true, hov: 'o', d: 'in-flex' },
30
- };
@@ -1,10 +0,0 @@
1
- import { Lism } from 'lism-css/react';
2
- import { defaultProps } from '../getProps';
3
-
4
- export default function ModalBody({ children, ...props }) {
5
- return (
6
- <Lism {...defaultProps.body} {...props}>
7
- {children}
8
- </Lism>
9
- );
10
- }
@@ -1,20 +0,0 @@
1
- import { Lism, Icon } from 'lism-css/react';
2
- import { defaultProps } from '../getProps';
3
-
4
- // duration: [s]
5
- export default function CloseBtn({ children, modalId = '', icon, srText = 'Close', ...props }) {
6
- // const lismProps = getLismProps(getAccProps(props));
7
-
8
- return (
9
- <Lism data-modal-close={modalId} {...defaultProps.closeBtn} {...props}>
10
- {children ? (
11
- children
12
- ) : (
13
- <>
14
- <Icon icon={icon || 'x'} />
15
- <span className="u--srOnly">{srText || 'Close'}</span>
16
- </>
17
- )}
18
- </Lism>
19
- );
20
- }
@@ -1,6 +0,0 @@
1
- import { Lism } from 'lism-css/react';
2
- import { getInnerProps } from '../getProps';
3
-
4
- export default function ModalInner({ children, ...props }) {
5
- return <Lism {...getInnerProps(props)}>{children}</Lism>;
6
- }
@@ -1,23 +0,0 @@
1
- 'use client';
2
- import { useRef, useEffect } from 'react';
3
- import { Lism } from 'lism-css/react';
4
- import { setEvent } from '../setModal';
5
- import { getProps } from '../getProps';
6
-
7
- import '../_style.css';
8
-
9
- // duration: [s]
10
- const Modal = ({ children, ...props }) => {
11
- const ref = useRef(null);
12
- useEffect(() => {
13
- if (!ref?.current) return;
14
- return setEvent(ref?.current);
15
- }, [ref]);
16
-
17
- return (
18
- <Lism forwardedRef={ref} {...getProps(props)}>
19
- {children}
20
- </Lism>
21
- );
22
- };
23
- export default Modal;
@@ -1,11 +0,0 @@
1
- import { Lism } from 'lism-css/react';
2
- import { defaultProps } from '../getProps';
3
-
4
- // duration: [s]
5
- export default function OpenBtn({ children, modalId = '', ...props }) {
6
- return (
7
- <Lism data-modal-open={modalId} {...defaultProps.openBtn} {...props}>
8
- {children}
9
- </Lism>
10
- );
11
- }
@@ -1,65 +0,0 @@
1
- /**
2
- * NavMenu コンポーネントの共通プロパティ処理
3
- */
4
- import getMaybeCssVar from 'lism-css/lib/getMaybeCssVar';
5
-
6
- /**
7
- * NavMenu.Root のプロパティを処理
8
- * @param {object} props - コンポーネントのプロパティ
9
- * @param {string} [props.hovC] - ホバー時のテキストカラー(--hov-c として出力)
10
- * @param {string} [props.hovBgc] - ホバー時の背景カラー(--hov-bgc として出力)
11
- * @param {string} [props.itemP] - 各アイテムのパディング(--_item-p として出力)
12
- * @param {object} [props.style] - スタイルオブジェクト
13
- */
14
- export function getRootProps({ hovC, hovBgc, itemP, style = {}, ...props }) {
15
- const computedStyle = { ...style };
16
-
17
- if (hovBgc) computedStyle['--hov-bgc'] = getMaybeCssVar(hovBgc, 'color');
18
- if (hovC) computedStyle['--hov-c'] = getMaybeCssVar(hovC, 'color');
19
- if (itemP) computedStyle['--_item-p'] = getMaybeCssVar(itemP, 'space');
20
-
21
- return {
22
- lismClass: 'c--navMenu',
23
- as: 'ul',
24
- style: computedStyle,
25
- ...props,
26
- };
27
- }
28
-
29
- /**
30
- * NavMenu.Nest のプロパティを処理
31
- */
32
- export function getNestProps(props) {
33
- return {
34
- lismClass: 'c--navMenu_nest',
35
- as: 'ul',
36
- 'px-s': '20',
37
- ...props,
38
- };
39
- }
40
-
41
- /**
42
- * NavMenu.Item のプロパティを処理
43
- */
44
- export function getItemProps(props) {
45
- return {
46
- lismClass: 'c--navMenu_item',
47
- as: 'li',
48
- ...props,
49
- };
50
- }
51
-
52
- /**
53
- * NavMenu.Link のプロパティを処理
54
- * @param {string} [props.href] - リンク先URL。指定時は a タグになる
55
- * @param {string} [props.as='span'] - HTML タグ
56
- */
57
- export function getLinkProps({ href, as = 'span', ...props }) {
58
- return {
59
- lismClass: 'c--navMenu_link',
60
- as: href ? 'a' : as,
61
- href,
62
- c: 'inherit',
63
- ...props,
64
- };
65
- }
@@ -1,19 +0,0 @@
1
- import { Lism, Stack, Flex } from 'lism-css/react';
2
- import { getRootProps, getNestProps, getItemProps, getLinkProps } from '../getProps';
3
- import '../_style.css';
4
-
5
- export function Root({ children, ...props }) {
6
- return <Stack {...getRootProps(props)}>{children}</Stack>;
7
- }
8
-
9
- export function Nest({ children, ...props }) {
10
- return <Stack {...getNestProps(props)}>{children}</Stack>;
11
- }
12
-
13
- export function Item({ children, ...props }) {
14
- return <Lism {...getItemProps(props)}>{children}</Lism>;
15
- }
16
-
17
- export function Link({ children, ...props }) {
18
- return <Flex {...getLinkProps(props)}>{children}</Flex>;
19
- }
@@ -1 +0,0 @@
1
- export { default } from './ShapeDivider.astro';
@@ -1,40 +0,0 @@
1
- /**
2
- * ShapeDivider コンポーネントの共通プロパティ処理
3
- * @param {string} [props.viewBox] - SVG の viewBox
4
- * @param {boolean} [props.isAnimation] - アニメーションを有効にするか
5
- * @param {boolean} [props.isEmpty] - シェイプを非表示にしてスペーサーとして使用
6
- * @param {number} [props.level=5] - シェイプの高さレベル
7
- * @param {string} [props.stretch] - 水平方向の引き伸ばし量
8
- * @param {string} [props.offset] - 水平方向のオフセット
9
- * @param {string} [props.flip] - X/Y/XY で反転方向を指定
10
- */
11
- export default function getProps({ viewBox, isAnimation, isEmpty, level = 5, stretch, offset, flip, style = {}, ...restProps }) {
12
- // level が 0 の場合は非表示
13
- if (level === 0) return null;
14
-
15
- // CSS変数をセット
16
- const computedStyle = { ...style };
17
- computedStyle['--level'] = level || null;
18
- computedStyle['--_inner-offset'] = offset || null;
19
- computedStyle['--_inner-stretch'] = stretch || null;
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';
28
-
29
- return {
30
- ..._props,
31
- style: computedStyle,
32
-
33
- // SVG用のprops
34
- viewBox,
35
- isEmpty,
36
-
37
- // その他のprops
38
- ...restProps,
39
- };
40
- }
@@ -1,8 +0,0 @@
1
- import atts from 'lism-css/lib/helper/atts';
2
-
3
- export default function getTabsProps({ lismClass, ...props }) {
4
- return {
5
- lismClass: atts(lismClass, 'c--tabs'),
6
- ...props,
7
- };
8
- }
@@ -1,10 +0,0 @@
1
- // import React from 'react';
2
- import { Lism } from 'lism-css/react';
3
-
4
- export default function Tab({ tabId = 'tab', index = 0, isActive = false, ...props }) {
5
- const controlId = `${tabId}-${index}`;
6
-
7
- return (
8
- <Lism as="button" lismClass="c--tabs_tab" setPlain role="tab" aria-controls={controlId} aria-selected={isActive ? 'true' : 'false'} {...props} />
9
- );
10
- }
@@ -1,5 +0,0 @@
1
- // Note: <Tabs>側でループして色々処理される。
2
- // 引数でちゃんと処理したいpropを書いておかないとだめ。
3
- export default function TabItem({ isTabItem = true, children }) {
4
- return <div>{children}</div>;
5
- }
@@ -1,6 +0,0 @@
1
- import { Lism } from 'lism-css/react';
2
-
3
- export default function TabList(props) {
4
- // jc: 's',
5
- return <Lism lismClass="c--tabs_list" role="tablist" {...props} />;
6
- }
@@ -1,87 +0,0 @@
1
- /**
2
- * タブ
3
- */
4
- function tabControl(e) {
5
- e.preventDefault();
6
-
7
- // クリックされたボタン要素
8
- const clickedButton = e.currentTarget;
9
-
10
- // クリックイベントがキー(Enter / space)によって呼び出されたかどうか
11
- // const iskeyClick = 0 === e.clientX;
12
-
13
- // マウスクリック時はフォーカスを外す
14
- // if (!iskeyClick) {
15
- // clickedButton.blur();
16
- // }
17
-
18
- // 属性の切り替え
19
- toggleAriaData(clickedButton);
20
- }
21
-
22
- const toggleAriaData = (clickedButton) => {
23
- // すでにオープンされているタブの場合はなにもしない
24
- const isOpend = 'true' === clickedButton.getAttribute('aria-selected');
25
- if (isOpend) return;
26
-
27
- // 新しく表示するBodyを取得
28
- const targetID = clickedButton.getAttribute('aria-controls');
29
- const targetBody = document.getElementById(targetID);
30
- if (null === targetBody) return;
31
-
32
- // 親のタブリスト(ul)を取得
33
- const parentTabList = clickedButton.parentNode.parentNode;
34
-
35
- // 現在選択中のタブボタンを取得
36
- const selectedButton = parentTabList.querySelector('[aria-selected="true"]');
37
-
38
- // 展開中のBodyを取得
39
- const displayedID = selectedButton.getAttribute('aria-controls');
40
- const displayedBody = document.getElementById(displayedID);
41
-
42
- // ariaの処理
43
- clickedButton.setAttribute('aria-selected', 'true');
44
- selectedButton.setAttribute('aria-selected', 'false');
45
- displayedBody.setAttribute('aria-hidden', 'true');
46
- targetBody.setAttribute('aria-hidden', 'false');
47
- };
48
-
49
- function setTabs(tabs) {
50
- const tabBtns = tabs.querySelectorAll('button[role="tab"]');
51
- tabBtns.forEach((tabBtn) => {
52
- tabBtn.addEventListener('click', function (e) {
53
- tabControl(e);
54
- });
55
- });
56
-
57
- // タブへのリンクがあるかどうか
58
- const nowUrl = window?.location?.href;
59
- if (!nowUrl) return;
60
-
61
- const hasTabLink = -1 !== nowUrl.indexOf('?lism-tab=');
62
- if (!hasTabLink) return;
63
-
64
- // URLでタブを切り替える機能がONかどうか
65
-
66
- // URLSearchParamsオブジェクトを取得
67
- const url = new URL(nowUrl);
68
- const params = url.searchParams;
69
-
70
- // getメソッド
71
- const targetTabId = params.get('lism-tab');
72
- const target = tabs.querySelector(`[aria-controls="${targetTabId}"]`);
73
- if (target) {
74
- // transitionをオフにするための属性
75
- tabs.dataset.hasTabLink = '1';
76
-
77
- // タブ切り替え
78
- toggleAriaData(target);
79
-
80
- // 少し後で属性削除
81
- setTimeout(() => {
82
- delete tabs.dataset.hasTabLink;
83
- }, 10);
84
- }
85
- }
86
-
87
- export default setTabs;