@lism-css/ui 0.10.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 (209) 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 -3
  26. package/dist/components/Callout/getProps.js +11 -12
  27. package/dist/components/Callout/react/Callout.d.ts +3 -4
  28. package/dist/components/Callout/react/Callout.js +4 -4
  29. package/dist/components/Chat/Chat.stories.d.ts +9 -0
  30. package/dist/components/Chat/getProps.d.ts +43 -44
  31. package/dist/components/Chat/getProps.js +2 -2
  32. package/dist/components/Chat/react/Chat.d.ts +11 -7
  33. package/dist/components/Chat/react/Chat.js +10 -10
  34. package/dist/components/Details/Details.stories.d.ts +6 -0
  35. package/dist/components/Details/getProps.d.ts +34 -35
  36. package/dist/components/Details/getProps.js +16 -6
  37. package/dist/components/Details/react/Details.d.ts +11 -20
  38. package/dist/components/Details/react/Details.js +15 -15
  39. package/dist/components/Details/react/index.d.ts +7 -7
  40. package/dist/components/DummyImage/DummyImage.stories.d.ts +7 -0
  41. package/dist/components/DummyText/DummyText.stories.d.ts +9 -0
  42. package/dist/components/Modal/Modal.stories.d.ts +6 -0
  43. package/dist/components/Modal/getProps.d.ts +36 -36
  44. package/dist/components/Modal/getProps.js +36 -17
  45. package/dist/components/Modal/react/Body.d.ts +2 -4
  46. package/dist/components/Modal/react/CloseBtn.d.ts +9 -7
  47. package/dist/components/Modal/react/CloseBtn.js +5 -5
  48. package/dist/components/Modal/react/Inner.d.ts +3 -4
  49. package/dist/components/Modal/react/Modal.d.ts +4 -4
  50. package/dist/components/Modal/react/Modal.js +11 -9
  51. package/dist/components/Modal/react/OpenBtn.d.ts +7 -5
  52. package/dist/components/Modal/react/OpenBtn.js +4 -4
  53. package/dist/components/Modal/react/index.d.ts +7 -8
  54. package/dist/components/NavMenu/NavMenu.stories.d.ts +7 -0
  55. package/dist/components/NavMenu/getProps.d.ts +31 -29
  56. package/dist/components/NavMenu/react/NavMenu.d.ts +6 -16
  57. package/dist/components/NavMenu/react/NavMenu.js +21 -17
  58. package/dist/components/NavMenu/react/index.d.ts +6 -6
  59. package/dist/components/ShapeDivider/ShapeDivider.stories.d.ts +10 -0
  60. package/dist/components/ShapeDivider/getProps.d.ts +16 -11
  61. package/dist/components/ShapeDivider/getProps.js +10 -12
  62. package/dist/components/ShapeDivider/react/ShapeDivider.d.ts +3 -4
  63. package/dist/components/ShapeDivider/react/ShapeDivider.js +3 -3
  64. package/dist/components/Tabs/Tabs.stories.d.ts +6 -0
  65. package/dist/components/Tabs/getProps.d.ts +11 -4
  66. package/dist/components/Tabs/getProps.js +14 -4
  67. package/dist/components/Tabs/react/Tab.d.ts +8 -6
  68. package/dist/components/Tabs/react/Tab.js +15 -6
  69. package/dist/components/Tabs/react/TabItem.d.ts +7 -4
  70. package/dist/components/Tabs/react/TabList.d.ts +2 -1
  71. package/dist/components/Tabs/react/TabPanel.d.ts +8 -6
  72. package/dist/components/Tabs/react/Tabs.d.ts +9 -7
  73. package/dist/components/Tabs/react/Tabs.js +50 -36
  74. package/dist/components/Tabs/react/index.d.ts +8 -8
  75. package/dist/components/Tabs/setTabs.d.ts +1 -1
  76. package/dist/components/Tabs/setTabs.js +25 -15
  77. package/dist/lism-css/dist/components/{Center → layout/Center}/index.js +1 -1
  78. package/dist/lism-css/dist/components/{Flex → layout/Flex}/index.js +1 -1
  79. package/dist/lism-css/dist/components/{Flow → layout/Flow}/index.js +1 -1
  80. package/dist/lism-css/dist/components/{Frame → layout/Frame}/index.js +1 -1
  81. package/dist/lism-css/dist/components/{Grid → layout/Grid}/index.js +1 -1
  82. package/dist/lism-css/dist/components/{Stack → layout/Stack}/index.js +1 -1
  83. package/dist/lism-css/dist/config/defaults/props.js +16 -26
  84. package/dist/lism-css/dist/config/defaults/states.js +3 -24
  85. package/dist/lism-css/dist/config/defaults/tokens.js +2 -2
  86. package/dist/lism-css/dist/lib/getLayoutProps.js +6 -9
  87. package/dist/lism-css/dist/lib/getLismProps.js +94 -92
  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/astro/Button.astro +2 -2
  94. package/src/components/Accordion/getProps.ts +91 -0
  95. package/src/components/Accordion/react/{AccIcon.jsx → AccIcon.tsx} +2 -2
  96. package/src/components/Accordion/react/{Accordion.jsx → Accordion.tsx} +33 -11
  97. package/src/components/Accordion/setAccordion.ts +120 -0
  98. package/src/components/Alert/Alert.stories.tsx +64 -0
  99. package/src/components/Alert/getProps.ts +5 -3
  100. package/src/components/Alert/react/Alert.tsx +3 -3
  101. package/src/components/Avatar/Avatar.stories.tsx +42 -0
  102. package/src/components/Avatar/react/Avatar.tsx +17 -0
  103. package/src/components/Badge/Badge.stories.tsx +40 -0
  104. package/src/components/Badge/astro/Badge.astro +1 -7
  105. package/src/components/Badge/react/Badge.tsx +7 -0
  106. package/src/components/Button/Button.stories.tsx +44 -0
  107. package/src/components/Button/astro/Button.astro +1 -7
  108. package/src/components/Button/react/Button.tsx +7 -0
  109. package/src/components/Callout/Callout.stories.tsx +55 -0
  110. package/src/components/Callout/getProps.ts +5 -5
  111. package/src/components/Callout/react/Callout.tsx +3 -3
  112. package/src/components/Chat/Chat.stories.tsx +58 -0
  113. package/src/components/Chat/_style.css +5 -5
  114. package/src/components/Chat/{getProps.js → getProps.ts} +10 -4
  115. package/src/components/Chat/react/{Chat.jsx → Chat.tsx} +13 -3
  116. package/src/components/Details/Details.stories.tsx +61 -0
  117. package/src/components/Details/astro/Title.astro +2 -2
  118. package/src/components/Details/{getProps.js → getProps.ts} +19 -6
  119. package/src/components/Details/react/Details.tsx +69 -0
  120. package/src/components/DummyImage/DummyImage.stories.tsx +23 -0
  121. package/src/components/DummyText/DummyText.stories.tsx +48 -0
  122. package/src/components/Modal/Modal.stories.tsx +67 -0
  123. package/src/components/Modal/astro/CloseBtn.astro +2 -2
  124. package/src/components/Modal/astro/OpenBtn.astro +2 -3
  125. package/src/components/Modal/getProps.ts +65 -0
  126. package/src/components/Modal/react/Body.tsx +10 -0
  127. package/src/components/Modal/react/CloseBtn.tsx +24 -0
  128. package/src/components/Modal/react/Inner.tsx +6 -0
  129. package/src/components/Modal/react/Modal.tsx +24 -0
  130. package/src/components/Modal/react/OpenBtn.tsx +15 -0
  131. package/src/components/Modal/{script.js → script.ts} +1 -1
  132. package/src/components/NavMenu/NavMenu.stories.tsx +68 -0
  133. package/src/components/NavMenu/getProps.ts +60 -0
  134. package/src/components/NavMenu/react/NavMenu.tsx +40 -0
  135. package/src/components/ShapeDivider/ShapeDivider.stories.tsx +87 -0
  136. package/src/components/ShapeDivider/getProps.ts +36 -0
  137. package/src/components/ShapeDivider/react/{ShapeDivider.jsx → ShapeDivider.tsx} +4 -4
  138. package/src/components/Tabs/Tabs.stories.tsx +79 -0
  139. package/src/components/Tabs/astro/Tab.astro +2 -1
  140. package/src/components/Tabs/astro/{transformTabitems.js → transformTabitems.ts} +9 -9
  141. package/src/components/Tabs/getProps.ts +23 -0
  142. package/src/components/Tabs/react/Tab.tsx +21 -0
  143. package/src/components/Tabs/react/TabItem.tsx +13 -0
  144. package/src/components/Tabs/react/TabList.tsx +5 -0
  145. package/src/components/Tabs/react/{TabPanel.jsx → TabPanel.tsx} +8 -3
  146. package/src/components/Tabs/react/{Tabs.jsx → Tabs.tsx} +27 -12
  147. package/src/components/Tabs/{script.js → script.ts} +2 -2
  148. package/src/components/Tabs/setTabs.ts +65 -0
  149. package/src/helper/{uuid.js → uuid.ts} +2 -2
  150. package/src/vite-env.d.ts +1 -0
  151. package/dist/components/Accordion/astro/__setEvent.d.ts +0 -1
  152. package/dist/components/Accordion/astro/index.d.ts +0 -15
  153. package/dist/components/Alert/astro/index.d.ts +0 -1
  154. package/dist/components/Callout/astro/index.d.ts +0 -1
  155. package/dist/components/Details/astro/index.d.ts +0 -13
  156. package/dist/components/DummyImage/astro/index.d.ts +0 -1
  157. package/dist/components/DummyText/astro/index.d.ts +0 -1
  158. package/dist/components/Modal/astro/index.d.ts +0 -13
  159. package/dist/components/NavMenu/astro/index.d.ts +0 -11
  160. package/dist/components/Tabs/astro/index.d.ts +0 -13
  161. package/dist/components/Tabs/astro/transformTabitems.d.ts +0 -4
  162. package/dist/components/astro.d.ts +0 -14
  163. package/dist/lism-css/dist/config/helper/getSvgUrl.js +0 -4
  164. package/src/components/Accordion/getProps.js +0 -77
  165. package/src/components/Accordion/setAccordion.js +0 -146
  166. package/src/components/Avatar/astro/index.js +0 -1
  167. package/src/components/Avatar/react/Avatar.jsx +0 -9
  168. package/src/components/Badge/astro/index.js +0 -1
  169. package/src/components/Badge/react/Badge.jsx +0 -12
  170. package/src/components/Button/astro/index.js +0 -1
  171. package/src/components/Button/react/Button.jsx +0 -12
  172. package/src/components/Chat/astro/index.js +0 -1
  173. package/src/components/Details/react/Details.jsx +0 -66
  174. package/src/components/Modal/getProps.js +0 -30
  175. package/src/components/Modal/react/Body.jsx +0 -10
  176. package/src/components/Modal/react/CloseBtn.jsx +0 -20
  177. package/src/components/Modal/react/Inner.jsx +0 -6
  178. package/src/components/Modal/react/Modal.jsx +0 -23
  179. package/src/components/Modal/react/OpenBtn.jsx +0 -11
  180. package/src/components/NavMenu/getProps.js +0 -65
  181. package/src/components/NavMenu/react/NavMenu.jsx +0 -19
  182. package/src/components/ShapeDivider/astro/index.js +0 -1
  183. package/src/components/ShapeDivider/getProps.js +0 -40
  184. package/src/components/Tabs/getProps.js +0 -8
  185. package/src/components/Tabs/react/Tab.jsx +0 -10
  186. package/src/components/Tabs/react/TabItem.jsx +0 -5
  187. package/src/components/Tabs/react/TabList.jsx +0 -6
  188. package/src/components/Tabs/setTabs.js +0 -87
  189. /package/src/components/Accordion/astro/{index.js → index.ts} +0 -0
  190. /package/src/components/Accordion/react/{index.js → index.ts} +0 -0
  191. /package/src/components/Accordion/{script.js → script.ts} +0 -0
  192. /package/{dist/components/Avatar/astro/index.d.ts → src/components/Avatar/astro/index.ts} +0 -0
  193. /package/src/components/Avatar/react/{index.js → index.ts} +0 -0
  194. /package/{dist/components/Badge/astro/index.d.ts → src/components/Badge/astro/index.ts} +0 -0
  195. /package/src/components/Badge/react/{index.js → index.ts} +0 -0
  196. /package/{dist/components/Button/astro/index.d.ts → src/components/Button/astro/index.ts} +0 -0
  197. /package/src/components/Button/react/{index.js → index.ts} +0 -0
  198. /package/{dist/components/Chat/astro/index.d.ts → src/components/Chat/astro/index.ts} +0 -0
  199. /package/src/components/Chat/react/{index.js → index.ts} +0 -0
  200. /package/src/components/Details/astro/{index.js → index.ts} +0 -0
  201. /package/src/components/Details/react/{index.js → index.ts} +0 -0
  202. /package/src/components/Modal/astro/{index.js → index.ts} +0 -0
  203. /package/src/components/Modal/react/{index.js → index.ts} +0 -0
  204. /package/src/components/NavMenu/astro/{index.js → index.ts} +0 -0
  205. /package/src/components/NavMenu/react/{index.js → index.ts} +0 -0
  206. /package/{dist/components/ShapeDivider/astro/index.d.ts → src/components/ShapeDivider/astro/index.ts} +0 -0
  207. /package/src/components/ShapeDivider/react/{index.js → index.ts} +0 -0
  208. /package/src/components/Tabs/astro/{index.js → index.ts} +0 -0
  209. /package/src/components/Tabs/react/{index.js → index.ts} +0 -0
@@ -0,0 +1,65 @@
1
+ /**
2
+ * タブ
3
+ */
4
+ function tabControl(e: MouseEvent): void {
5
+ e.preventDefault();
6
+ const clickedButton = e.currentTarget as HTMLButtonElement;
7
+ toggleAriaData(clickedButton);
8
+ }
9
+
10
+ const toggleAriaData = (clickedButton: HTMLButtonElement): void => {
11
+ const isOpend = 'true' === clickedButton.getAttribute('aria-selected');
12
+ if (isOpend) return;
13
+
14
+ const targetID = clickedButton.getAttribute('aria-controls');
15
+ if (!targetID) return;
16
+ const targetBody = document.getElementById(targetID);
17
+ if (null === targetBody) return;
18
+
19
+ const parentTabList = clickedButton.parentNode?.parentNode as HTMLElement | null;
20
+ if (!parentTabList) return;
21
+
22
+ const selectedButton = parentTabList.querySelector<HTMLButtonElement>('[aria-selected="true"]');
23
+ if (!selectedButton) return;
24
+
25
+ const displayedID = selectedButton.getAttribute('aria-controls');
26
+ if (!displayedID) return;
27
+ const displayedBody = document.getElementById(displayedID);
28
+
29
+ clickedButton.setAttribute('aria-selected', 'true');
30
+ selectedButton.setAttribute('aria-selected', 'false');
31
+ displayedBody?.setAttribute('aria-hidden', 'true');
32
+ targetBody.setAttribute('aria-hidden', 'false');
33
+ };
34
+
35
+ function setTabs(tabs: HTMLElement): void {
36
+ const tabBtns = tabs.querySelectorAll<HTMLButtonElement>('button[role="tab"]');
37
+ tabBtns.forEach((tabBtn) => {
38
+ tabBtn.addEventListener('click', function (e) {
39
+ tabControl(e);
40
+ });
41
+ });
42
+
43
+ const nowUrl = window?.location?.href;
44
+ if (!nowUrl) return;
45
+
46
+ const hasTabLink = -1 !== nowUrl.indexOf('?lism-tab=');
47
+ if (!hasTabLink) return;
48
+
49
+ const url = new URL(nowUrl);
50
+ const params = url.searchParams;
51
+
52
+ const targetTabId = params.get('lism-tab');
53
+ if (!targetTabId) return;
54
+
55
+ const target = tabs.querySelector<HTMLButtonElement>(`[aria-controls="${targetTabId}"]`);
56
+ if (target) {
57
+ tabs.dataset.hasTabLink = '1';
58
+ toggleAriaData(target);
59
+ setTimeout(() => {
60
+ delete tabs.dataset.hasTabLink;
61
+ }, 10);
62
+ }
63
+ }
64
+
65
+ export default setTabs;
@@ -1,6 +1,6 @@
1
1
  // https://stackoverflow.com/questions/105034/how-do-i-create-a-guid-uuid
2
- export default function uuidv4() {
2
+ export default function uuidv4(): string {
3
3
  return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) =>
4
- (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
4
+ (parseInt(c) ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (parseInt(c) / 4)))).toString(16)
5
5
  );
6
6
  }
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -1 +0,0 @@
1
- export default setEvent;
@@ -1,15 +0,0 @@
1
- import { default as Root } from './Root.astro';
2
- import { default as Item } from './Item.astro';
3
- import { default as Heading } from './Heading.astro';
4
- import { default as Panel } from './Panel.astro';
5
- import { default as Icon } from './Icon.astro';
6
- import { default as Button } from './Button.astro';
7
- declare namespace _default {
8
- export { Root };
9
- export { Item };
10
- export { Heading };
11
- export { Panel };
12
- export { Icon };
13
- export { Button };
14
- }
15
- export default _default;
@@ -1 +0,0 @@
1
- export { default } from './Alert.astro';
@@ -1 +0,0 @@
1
- export { default } from './Callout.astro';
@@ -1,13 +0,0 @@
1
- import { default as Root } from './Details.astro';
2
- import { default as Summary } from './Summary.astro';
3
- import { default as Title } from './Title.astro';
4
- import { default as Content } from './Content.astro';
5
- import { default as Icon } from './Icon.astro';
6
- declare namespace _default {
7
- export { Root };
8
- export { Summary };
9
- export { Title };
10
- export { Content };
11
- export { Icon };
12
- }
13
- export default _default;
@@ -1 +0,0 @@
1
- export { default } from './DummyImage.astro';
@@ -1 +0,0 @@
1
- export { default } from './DummyText.astro';
@@ -1,13 +0,0 @@
1
- import { default as Root } from './Modal.astro';
2
- import { default as Inner } from './Inner.astro';
3
- import { default as Body } from './Body.astro';
4
- import { default as CloseBtn } from './CloseBtn.astro';
5
- import { default as OpenBtn } from './OpenBtn.astro';
6
- declare namespace _default {
7
- export { Root };
8
- export { Inner };
9
- export { Body };
10
- export { CloseBtn };
11
- export { OpenBtn };
12
- }
13
- export default _default;
@@ -1,11 +0,0 @@
1
- import { default as Root } from './Root.astro';
2
- import { default as Nest } from './Nest.astro';
3
- import { default as Item } from './Item.astro';
4
- import { default as Link } from './Link.astro';
5
- declare namespace _default {
6
- export { Root };
7
- export { Nest };
8
- export { Item };
9
- export { Link };
10
- }
11
- export default _default;
@@ -1,13 +0,0 @@
1
- import { default as Root } from './Tabs.astro';
2
- import { default as List } from './TabList.astro';
3
- import { default as Panel } from './TabPanel.astro';
4
- import { default as Item } from './TabItem.astro';
5
- import { default as Tab } from './Tab.astro';
6
- declare namespace _default {
7
- export { Root };
8
- export { List };
9
- export { Panel };
10
- export { Item };
11
- export { Tab };
12
- }
13
- export default _default;
@@ -1,4 +0,0 @@
1
- export default function transformHTML(htmlString: any, tabID: any, defaultIndex: any): {
2
- btns: any[];
3
- panels: any[];
4
- };
@@ -1,14 +0,0 @@
1
- export { default as Accordion } from './Accordion/astro';
2
- export { default as Alert } from './Alert/astro';
3
- export { default as Avatar } from './Avatar/astro';
4
- export { default as Badge } from './Badge/astro';
5
- export { default as Button } from './Button/astro';
6
- export { default as Callout } from './Callout/astro';
7
- export { default as Chat } from './Chat/astro';
8
- export { default as Details } from './Details/astro';
9
- export { default as Modal } from './Modal/astro';
10
- export { default as NavMenu } from './NavMenu/astro';
11
- export { default as ShapeDivider } from './ShapeDivider/astro';
12
- export { default as Tabs } from './Tabs/astro';
13
- export { default as DummyText } from './DummyText/astro';
14
- export { default as DummyImage } from './DummyImage/astro';
@@ -1,4 +0,0 @@
1
- const g = (a, r = "") => a ? r === "base64" ? (a = Buffer.from(a).toString("base64"), `url(data:image/svg+xml;base64,${a})`) : (a = a.replace(/'/g, '"'), a = a.replace(/="#/g, '="%23'), `url('data:image/svg+xml,${a}')`) : "";
2
- export {
3
- g as default
4
- };
@@ -1,77 +0,0 @@
1
- import atts from 'lism-css/lib/helper/atts';
2
-
3
- export function getRootProps({ lismClass, allowMultiple, ...props }) {
4
- props.lismClass = atts(lismClass, 'c--accordion');
5
- if (allowMultiple) props['data-allow-multiple'] = '';
6
- return props;
7
- }
8
-
9
- // duration: [s]
10
- export function getItemProps({ lismClass, ...props }) {
11
- props.lismClass = atts(lismClass, 'c--accordion_item');
12
- return props;
13
- }
14
-
15
- export function getHeadingProps(props) {
16
- const defaultProps = {
17
- lismClass: 'c--accordion_heading',
18
- as: 'div',
19
- setPlain: 1,
20
- };
21
-
22
- const returnProps = { ...defaultProps, ...props };
23
-
24
- // div の時は role 付与
25
- if (returnProps.as === 'div') {
26
- returnProps.role = 'heading';
27
- }
28
- return returnProps;
29
- }
30
-
31
- // id: Context から取得できればそれを優先(React用)
32
- export function getPanelProps({ lismClass, _contextID, accID = '__LISM_ACC_ID__', isOpen = false, ...props }) {
33
- // panel側は必要最低限のプロパティのみ。
34
- const panelProps = {
35
- lismClass: atts(lismClass, 'c--accordion_panel'),
36
- id: _contextID || accID,
37
- hidden: isOpen ? undefined : 'until-found',
38
- pos: 'relative',
39
- ov: 'hidden',
40
- };
41
-
42
- // 余白などその他の指定は全て _content 側へ渡す
43
- const contentProps = { lismClass: 'c--accordion_content', layout: 'flow', ...props };
44
-
45
- // content側へ移すprops
46
- // ['p', 'px', 'py', 'pl', 'pr', 'pt', 'pb', 'px-s', 'px-e', 'py-s', 'py-e'].forEach((prop) => {
47
- // if (props[prop]) {
48
- // contentProps[prop] = props[prop];
49
- // delete props[prop];
50
- // }
51
- // });
52
-
53
- // 2つ返す
54
- return { panelProps, contentProps };
55
- }
56
-
57
- export const defaultProps = {
58
- // header: { lismClass: 'c--accordion_header' },
59
- button: {
60
- lismClass: 'c--accordion_button',
61
- as: 'button',
62
- layout: 'flex',
63
- setPlain: 1,
64
- g: '10',
65
- w: '100%',
66
- ai: 'center',
67
- jc: 'between',
68
- },
69
- icon: {
70
- lismClass: 'c--accordion_icon a--icon',
71
- as: 'span',
72
- // d: 'grid',
73
- pi: 'center',
74
- fxsh: '0',
75
- 'aria-hidden': 'true',
76
- },
77
- };
@@ -1,146 +0,0 @@
1
- import { waitFrame, waitAnimation, maybePauseAnimation } from '../../helper/animation';
2
-
3
- // hidden を付け外しする時の値
4
- let ACCORDION_HIDDEN_VALUE = 'until-found';
5
-
6
- // アコーディオン要素から必要な要素を取得
7
- const getAccordionElements = (accordionItem) => {
8
- const heading = accordionItem.querySelector('.c--accordion_heading');
9
- const panel = accordionItem.querySelector('.c--accordion_panel');
10
- return {
11
- heading,
12
- button: heading.querySelector('button'),
13
- panel,
14
- content: panel.querySelector('.c--accordion_content'),
15
- };
16
- };
17
-
18
- // 親に data-allow-multiple がついていなければ、展開中のアコーディオンを閉じる
19
- // Memo: 自身の除外処理はしていない( 開く動作の前に呼び出す & もし自分が含まれていても連打可能なため )
20
- const maybeCloseOpenedItems = (accordionItem) => {
21
- const parent = accordionItem.parentNode;
22
- if (!parent) return;
23
-
24
- // 親の data-allow-multiple 属性の有無をチェック
25
- if (parent.hasAttribute('data-allow-multiple')) return;
26
-
27
- // 開いているアコーディオンを取得して閉じる
28
- parent.querySelectorAll(':scope > [data-opened]').forEach((_a) => closeAccordion(_a));
29
- };
30
-
31
- async function openAccordion(accordionItem) {
32
- const { panel, content, button } = getAccordionElements(accordionItem);
33
-
34
- // アニメーションがあれば一時停止
35
- maybePauseAnimation(panel);
36
-
37
- // hidden を削除
38
- panel.removeAttribute('hidden');
39
-
40
- // 1フレーム待機
41
- await waitFrame();
42
-
43
- // 次フレームで高さセット( 目標の高さ = content の高さ )
44
- accordionItem.style.setProperty('--_panel-h', `${content.offsetHeight}px`);
45
-
46
- // さらに1フレーム待機
47
- await waitFrame();
48
-
49
- // アニメーション開始
50
- accordionItem.setAttribute('data-opened', '');
51
- button.setAttribute('aria-expanded', 'true');
52
-
53
- // アニメーションを待つ
54
- const status = await waitAnimation(panel);
55
-
56
- // アニメーションが最後まで完了した時、--_panel-h削除(高さセットしたままだとリサイズできない)
57
- if ('canceled' !== status) {
58
- accordionItem.style.removeProperty('--_panel-h');
59
- }
60
- }
61
-
62
- async function closeAccordion(accordionItem) {
63
- const { panel, button } = getAccordionElements(accordionItem);
64
-
65
- // アニメーションがあれば一時停止
66
- maybePauseAnimation(panel);
67
-
68
- // 現在の高さを一旦セットする
69
- accordionItem.style.setProperty('--_panel-h', `${panel.offsetHeight}px`);
70
-
71
- // 1フレーム待機
72
- await waitFrame();
73
-
74
- // 次フレームで属性を削除
75
- accordionItem.removeAttribute('data-opened');
76
- button.setAttribute('aria-expanded', 'false');
77
-
78
- // 変数削除して 0px へ向けてアニメーション開始
79
- accordionItem.style.removeProperty('--_panel-h');
80
-
81
- // アニメーションを待つ
82
- const status = await waitAnimation(panel);
83
-
84
- // アニメーションが最後まで完了したら、hidden付与
85
- if ('canceled' !== status) {
86
- panel.setAttribute('hidden', ACCORDION_HIDDEN_VALUE);
87
- }
88
- }
89
-
90
- // アコーディオンのトグル処理
91
- function toggleAccordion(accordionItem) {
92
- if (accordionItem.hasAttribute('data-opened')) {
93
- // 自身を閉じる
94
- closeAccordion(accordionItem);
95
- } else {
96
- // 親に data-allow-multiple がついていなければ、他のアコーディオンを閉じる
97
- maybeCloseOpenedItems(accordionItem);
98
-
99
- // 自身を開く
100
- openAccordion(accordionItem);
101
- }
102
- }
103
-
104
- /**
105
- * 個別のアコーディオンにイベントをセット(React用にクリーンアップ関数を返す)
106
- */
107
- export const setEvent = (accordionItem) => {
108
- const { button, panel } = getAccordionElements(accordionItem);
109
-
110
- // until-found のオン・オフが使い分けれるように、最初に初期値を取得
111
- if (panel.hasAttribute('hidden')) {
112
- ACCORDION_HIDDEN_VALUE = panel.getAttribute('hidden');
113
- }
114
-
115
- // clickイベント登録
116
- const _clickEvent = (e) => {
117
- e.preventDefault(); // hidden="until-found" の自動付け外しを無効化
118
- toggleAccordion(accordionItem);
119
- };
120
-
121
- // beforematchイベント登録 (ページ検索時などはこっちが発火する)
122
- const _beforematchEvent = (e) => {
123
- e.preventDefault(); // hidden="until-found" の自動付け外しを無効化
124
- toggleAccordion(accordionItem);
125
- };
126
-
127
- button.addEventListener('click', _clickEvent);
128
- panel.addEventListener('beforematch', _beforematchEvent);
129
-
130
- // react用: useEffect でアンマウントされた時にremoveEventListenerしないと2重でイベントが登録してしまう
131
- return () => {
132
- button.removeEventListener('click', _clickEvent);
133
- panel.removeEventListener('beforematch', _beforematchEvent);
134
- };
135
- };
136
-
137
- /**
138
- * ページ内の全アコーディオンにイベントをセット(Astro用)
139
- */
140
- const setAccordion = () => {
141
- const accordionAll = document.querySelectorAll('.c--accordion_item');
142
- accordionAll.forEach((accordionItem) => {
143
- setEvent(accordionItem);
144
- });
145
- };
146
- export default setAccordion;
@@ -1 +0,0 @@
1
- export { default } from './Avatar.astro';
@@ -1,9 +0,0 @@
1
- import { Frame } from 'lism-css/react';
2
-
3
- export default function Avatar({ size = '1.5em', src = '', alt = '', ...props }) {
4
- return (
5
- <Frame lismClass="c--avatar" ar="1/1" w={size} bdrs="99" {...props}>
6
- <img src={src} alt={alt} width="100%" height="100%" decoding="async" />
7
- </Frame>
8
- );
9
- }
@@ -1 +0,0 @@
1
- export { default } from './Badge.astro';
@@ -1,12 +0,0 @@
1
- import { Lism } from 'lism-css/react';
2
- import '../_style.css';
3
-
4
- export default function Badge(props) {
5
- // c--badge では c, bgc は 変数で受け取る
6
- const _propConfig = {
7
- c: { isVar: 1 },
8
- bgc: { isVar: 1 },
9
- };
10
-
11
- return <Lism lismClass="c--badge" as="span" d="inline-flex" fz="xs" lh="xs" py="5" px="10" bdrs="10" _propConfig={_propConfig} {...props} />;
12
- }
@@ -1 +0,0 @@
1
- export { default } from './Button.astro';
@@ -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
- }