@lism-css/ui 0.9.3 → 0.11.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 (127) hide show
  1. package/README.ja.md +137 -0
  2. package/README.md +93 -5
  3. package/dist/components/Callout/getProps.d.ts +0 -1
  4. package/dist/components/Callout/getProps.js +11 -12
  5. package/dist/components/Chat/getProps.js +1 -6
  6. package/dist/components/DummyImage/astro/index.d.ts +1 -0
  7. package/dist/components/DummyImage/react/DummyImage.d.ts +2 -0
  8. package/dist/components/DummyImage/react/DummyImage.js +8 -0
  9. package/dist/components/DummyImage/react/index.d.ts +1 -0
  10. package/dist/components/DummyText/astro/index.d.ts +1 -0
  11. package/dist/components/DummyText/getContent.d.ts +11 -0
  12. package/dist/components/DummyText/getContent.js +9 -0
  13. package/dist/components/DummyText/react/DummyText.d.ts +10 -0
  14. package/dist/components/DummyText/react/DummyText.js +10 -0
  15. package/dist/components/DummyText/react/index.d.ts +1 -0
  16. package/dist/components/DummyText/texts.d.ts +22 -0
  17. package/dist/components/DummyText/texts.js +39 -0
  18. package/dist/components/NavMenu/getProps.js +2 -2
  19. package/dist/components/Tabs/react/Tab.js +1 -12
  20. package/dist/components/Tabs/react/Tabs.js +1 -3
  21. package/dist/components/astro.d.ts +2 -0
  22. package/dist/components/react.d.ts +2 -0
  23. package/dist/components/react.js +20 -16
  24. package/dist/lism-css/dist/components/atomic/Decorator/getProps.js +10 -10
  25. package/dist/lism-css/dist/components/atomic/Icon/getProps.js +28 -27
  26. package/dist/lism-css/dist/config/defaults/props.js +6 -1
  27. package/dist/lism-css/dist/config/defaults/states.js +1 -2
  28. package/dist/lism-css/dist/config/defaults/tokens.js +3 -3
  29. package/dist/lism-css/dist/lib/getMaybeCssVar.js +26 -21
  30. package/dist/style.css +1 -1
  31. package/dist/ui.css +1 -1
  32. package/package.json +5 -4
  33. package/src/components/Accordion/_style.css +69 -69
  34. package/src/components/Accordion/astro/Button.astro +2 -2
  35. package/src/components/Accordion/astro/Heading.astro +1 -1
  36. package/src/components/Accordion/astro/Item.astro +7 -7
  37. package/src/components/Accordion/astro/Panel.astro +3 -3
  38. package/src/components/Accordion/astro/Root.astro +3 -3
  39. package/src/components/Accordion/getProps.js +54 -54
  40. package/src/components/Accordion/react/AccIcon.jsx +1 -1
  41. package/src/components/Accordion/react/Accordion.jsx +34 -34
  42. package/src/components/Accordion/script.js +1 -1
  43. package/src/components/Accordion/setAccordion.js +93 -93
  44. package/src/components/Alert/astro/Alert.astro +6 -6
  45. package/src/components/Alert/getProps.ts +22 -22
  46. package/src/components/Alert/presets.ts +26 -26
  47. package/src/components/Alert/react/Alert.tsx +9 -9
  48. package/src/components/Avatar/astro/Avatar.astro +2 -2
  49. package/src/components/Avatar/react/Avatar.jsx +5 -5
  50. package/src/components/Badge/_style.css +14 -14
  51. package/src/components/Badge/astro/Badge.astro +4 -4
  52. package/src/components/Badge/react/Badge.jsx +6 -6
  53. package/src/components/Button/_style.css +29 -29
  54. package/src/components/Button/astro/Button.astro +4 -4
  55. package/src/components/Button/react/Button.jsx +6 -6
  56. package/src/components/Callout/astro/Callout.astro +13 -13
  57. package/src/components/Callout/getProps.ts +23 -24
  58. package/src/components/Callout/presets.ts +26 -26
  59. package/src/components/Callout/react/Callout.tsx +16 -16
  60. package/src/components/Chat/_style.css +49 -49
  61. package/src/components/Chat/astro/Chat.astro +27 -27
  62. package/src/components/Chat/getProps.js +40 -45
  63. package/src/components/Chat/react/Chat.jsx +17 -17
  64. package/src/components/Details/_style.css +39 -39
  65. package/src/components/Details/astro/Content.astro +3 -3
  66. package/src/components/Details/astro/Details.astro +1 -1
  67. package/src/components/Details/astro/Icon.astro +1 -1
  68. package/src/components/Details/astro/Summary.astro +2 -2
  69. package/src/components/Details/astro/Title.astro +1 -1
  70. package/src/components/Details/getProps.js +7 -7
  71. package/src/components/Details/react/Details.jsx +24 -24
  72. package/src/components/DummyImage/astro/DummyImage.astro +7 -0
  73. package/src/components/DummyImage/astro/index.ts +1 -0
  74. package/src/components/DummyImage/react/DummyImage.tsx +5 -0
  75. package/src/components/DummyImage/react/index.ts +1 -0
  76. package/src/components/DummyText/astro/DummyText.astro +9 -0
  77. package/src/components/DummyText/astro/index.ts +1 -0
  78. package/src/components/DummyText/getContent.ts +39 -0
  79. package/src/components/DummyText/react/DummyText.tsx +15 -0
  80. package/src/components/DummyText/react/index.ts +1 -0
  81. package/src/components/DummyText/texts.ts +39 -0
  82. package/src/components/Modal/_style.css +34 -34
  83. package/src/components/Modal/astro/Body.astro +1 -1
  84. package/src/components/Modal/astro/CloseBtn.astro +10 -10
  85. package/src/components/Modal/astro/Inner.astro +1 -1
  86. package/src/components/Modal/astro/Modal.astro +3 -3
  87. package/src/components/Modal/astro/OpenBtn.astro +1 -1
  88. package/src/components/Modal/getProps.js +19 -19
  89. package/src/components/Modal/react/Body.jsx +5 -5
  90. package/src/components/Modal/react/CloseBtn.jsx +13 -13
  91. package/src/components/Modal/react/Inner.jsx +1 -1
  92. package/src/components/Modal/react/Modal.jsx +10 -10
  93. package/src/components/Modal/react/OpenBtn.jsx +5 -5
  94. package/src/components/Modal/script.js +1 -1
  95. package/src/components/Modal/setModal.ts +92 -92
  96. package/src/components/NavMenu/_style.css +17 -17
  97. package/src/components/NavMenu/astro/Item.astro +1 -1
  98. package/src/components/NavMenu/astro/Link.astro +1 -1
  99. package/src/components/NavMenu/astro/Nest.astro +1 -1
  100. package/src/components/NavMenu/astro/Root.astro +1 -1
  101. package/src/components/NavMenu/getProps.js +28 -28
  102. package/src/components/NavMenu/react/NavMenu.jsx +4 -4
  103. package/src/components/ShapeDivider/_style.css +51 -51
  104. package/src/components/ShapeDivider/astro/ShapeDivider.astro +20 -20
  105. package/src/components/ShapeDivider/getProps.js +23 -23
  106. package/src/components/ShapeDivider/react/ShapeDivider.jsx +24 -24
  107. package/src/components/Tabs/_style.css +29 -29
  108. package/src/components/Tabs/astro/Tab.astro +2 -2
  109. package/src/components/Tabs/astro/TabItem.astro +1 -1
  110. package/src/components/Tabs/astro/TabList.astro +2 -2
  111. package/src/components/Tabs/astro/TabPanel.astro +2 -2
  112. package/src/components/Tabs/astro/Tabs.astro +20 -20
  113. package/src/components/Tabs/astro/transformTabitems.js +30 -30
  114. package/src/components/Tabs/getProps.js +4 -4
  115. package/src/components/Tabs/react/Tab.jsx +4 -12
  116. package/src/components/Tabs/react/TabItem.jsx +1 -1
  117. package/src/components/Tabs/react/TabList.jsx +2 -2
  118. package/src/components/Tabs/react/TabPanel.jsx +2 -2
  119. package/src/components/Tabs/react/Tabs.jsx +44 -46
  120. package/src/components/Tabs/script.js +4 -4
  121. package/src/components/Tabs/setTabs.js +70 -70
  122. package/src/components/astro.ts +2 -0
  123. package/src/components/react.ts +2 -0
  124. package/src/helper/animation.ts +10 -10
  125. package/src/helper/uuid.js +3 -3
  126. package/dist/lism-css/dist/components/getFilterProps.js +0 -23
  127. package/dist/lism-css/dist/components/setMaybeTransformStyles.js +0 -7
@@ -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
  }
@@ -11,53 +11,51 @@ import getTabsProps from '../getProps';
11
11
  import '../_style.css';
12
12
 
13
13
  export default function Tabs({ tabId = '', defaultIndex = 1, listProps = {}, children, ...props }) {
14
- const [activeIndex, setActiveIndex] = useState(defaultIndex);
15
- const theTabId = tabId || useId();
16
- const btns = [];
17
- const panels = [];
14
+ const [activeIndex, setActiveIndex] = useState(defaultIndex);
15
+ const theTabId = tabId || useId();
16
+ const btns = [];
17
+ const panels = [];
18
18
 
19
- // Tabs.Item の処理
20
- Children.forEach(children, (child, index) => {
21
- const tabIndex = index + 1; // 1 はじまり
22
- // console.log('child.type', 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);
23
23
 
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(
42
- <TabPanel {...panelProps} tabId={theTabId} index={tabIndex} key={tabIndex} isActive={tabIndex === activeIndex} />
43
- );
44
- }
45
- }
46
- });
47
- }
48
- });
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
+ });
49
47
 
50
- return (
51
- <Lism {...getTabsProps(props)}>
52
- {btns.length === 0 ? (
53
- // TabItemを使わず直接TabListなどを子要素に配置する場合
54
- children
55
- ) : (
56
- <>
57
- <TabList {...listProps}>{btns}</TabList>
58
- {panels}
59
- </>
60
- )}
61
- </Lism>
62
- );
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
+ );
63
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
  });
@@ -2,86 +2,86 @@
2
2
  * タブ
3
3
  */
4
4
  function tabControl(e) {
5
- e.preventDefault();
5
+ e.preventDefault();
6
6
 
7
- // クリックされたボタン要素
8
- const clickedButton = e.currentTarget;
7
+ // クリックされたボタン要素
8
+ const clickedButton = e.currentTarget;
9
9
 
10
- // クリックイベントがキー(Enter / space)によって呼び出されたかどうか
11
- // const iskeyClick = 0 === e.clientX;
10
+ // クリックイベントがキー(Enter / space)によって呼び出されたかどうか
11
+ // const iskeyClick = 0 === e.clientX;
12
12
 
13
- // マウスクリック時はフォーカスを外す
14
- // if (!iskeyClick) {
15
- // clickedButton.blur();
16
- // }
13
+ // マウスクリック時はフォーカスを外す
14
+ // if (!iskeyClick) {
15
+ // clickedButton.blur();
16
+ // }
17
17
 
18
- // 属性の切り替え
19
- toggleAriaData(clickedButton);
18
+ // 属性の切り替え
19
+ toggleAriaData(clickedButton);
20
20
  }
21
21
 
22
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');
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
47
  };
48
48
 
49
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
- }
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
85
  }
86
86
 
87
87
  export default setTabs;
@@ -10,3 +10,5 @@ export { default as Modal } from './Modal/astro';
10
10
  export { default as NavMenu } from './NavMenu/astro';
11
11
  export { default as ShapeDivider } from './ShapeDivider/astro';
12
12
  export { default as Tabs } from './Tabs/astro';
13
+ export { default as DummyText } from './DummyText/astro';
14
+ export { default as DummyImage } from './DummyImage/astro';
@@ -10,3 +10,5 @@ export { default as Modal } from './Modal/react';
10
10
  export { default as NavMenu } from './NavMenu/react';
11
11
  export { default as ShapeDivider } from './ShapeDivider/react';
12
12
  export { default as Tabs } from './Tabs/react';
13
+ export { default as DummyText } from './DummyText/react';
14
+ export { default as DummyImage } from './DummyImage/react';