@lism-css/ui 0.9.3 → 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 (124) hide show
  1. package/README.ja.md +137 -0
  2. package/README.md +93 -5
  3. package/dist/components/Chat/getProps.js +1 -6
  4. package/dist/components/DummyImage/astro/index.d.ts +1 -0
  5. package/dist/components/DummyImage/react/DummyImage.d.ts +2 -0
  6. package/dist/components/DummyImage/react/DummyImage.js +8 -0
  7. package/dist/components/DummyImage/react/index.d.ts +1 -0
  8. package/dist/components/DummyText/astro/index.d.ts +1 -0
  9. package/dist/components/DummyText/getContent.d.ts +11 -0
  10. package/dist/components/DummyText/getContent.js +9 -0
  11. package/dist/components/DummyText/react/DummyText.d.ts +10 -0
  12. package/dist/components/DummyText/react/DummyText.js +10 -0
  13. package/dist/components/DummyText/react/index.d.ts +1 -0
  14. package/dist/components/DummyText/texts.d.ts +22 -0
  15. package/dist/components/DummyText/texts.js +39 -0
  16. package/dist/components/NavMenu/getProps.js +2 -2
  17. package/dist/components/Tabs/react/Tab.js +1 -12
  18. package/dist/components/Tabs/react/Tabs.js +1 -3
  19. package/dist/components/astro.d.ts +2 -0
  20. package/dist/components/react.d.ts +2 -0
  21. package/dist/components/react.js +20 -16
  22. package/dist/lism-css/dist/components/atomic/Decorator/getProps.js +10 -10
  23. package/dist/lism-css/dist/components/atomic/Icon/getProps.js +28 -27
  24. package/dist/lism-css/dist/config/defaults/props.js +6 -1
  25. package/dist/lism-css/dist/config/defaults/tokens.js +1 -1
  26. package/dist/lism-css/dist/lib/getMaybeCssVar.js +26 -21
  27. package/dist/style.css +1 -1
  28. package/dist/ui.css +1 -1
  29. package/package.json +5 -4
  30. package/src/components/Accordion/_style.css +69 -69
  31. package/src/components/Accordion/astro/Button.astro +2 -2
  32. package/src/components/Accordion/astro/Heading.astro +1 -1
  33. package/src/components/Accordion/astro/Item.astro +7 -7
  34. package/src/components/Accordion/astro/Panel.astro +3 -3
  35. package/src/components/Accordion/astro/Root.astro +3 -3
  36. package/src/components/Accordion/getProps.js +54 -54
  37. package/src/components/Accordion/react/AccIcon.jsx +1 -1
  38. package/src/components/Accordion/react/Accordion.jsx +34 -34
  39. package/src/components/Accordion/script.js +1 -1
  40. package/src/components/Accordion/setAccordion.js +93 -93
  41. package/src/components/Alert/astro/Alert.astro +6 -6
  42. package/src/components/Alert/getProps.ts +22 -22
  43. package/src/components/Alert/presets.ts +26 -26
  44. package/src/components/Alert/react/Alert.tsx +9 -9
  45. package/src/components/Avatar/astro/Avatar.astro +2 -2
  46. package/src/components/Avatar/react/Avatar.jsx +5 -5
  47. package/src/components/Badge/_style.css +14 -14
  48. package/src/components/Badge/astro/Badge.astro +4 -4
  49. package/src/components/Badge/react/Badge.jsx +6 -6
  50. package/src/components/Button/_style.css +29 -29
  51. package/src/components/Button/astro/Button.astro +4 -4
  52. package/src/components/Button/react/Button.jsx +6 -6
  53. package/src/components/Callout/astro/Callout.astro +13 -13
  54. package/src/components/Callout/getProps.ts +24 -24
  55. package/src/components/Callout/presets.ts +26 -26
  56. package/src/components/Callout/react/Callout.tsx +16 -16
  57. package/src/components/Chat/_style.css +49 -49
  58. package/src/components/Chat/astro/Chat.astro +27 -27
  59. package/src/components/Chat/getProps.js +40 -45
  60. package/src/components/Chat/react/Chat.jsx +17 -17
  61. package/src/components/Details/_style.css +39 -39
  62. package/src/components/Details/astro/Content.astro +3 -3
  63. package/src/components/Details/astro/Details.astro +1 -1
  64. package/src/components/Details/astro/Icon.astro +1 -1
  65. package/src/components/Details/astro/Summary.astro +2 -2
  66. package/src/components/Details/astro/Title.astro +1 -1
  67. package/src/components/Details/getProps.js +7 -7
  68. package/src/components/Details/react/Details.jsx +24 -24
  69. package/src/components/DummyImage/astro/DummyImage.astro +7 -0
  70. package/src/components/DummyImage/astro/index.ts +1 -0
  71. package/src/components/DummyImage/react/DummyImage.tsx +5 -0
  72. package/src/components/DummyImage/react/index.ts +1 -0
  73. package/src/components/DummyText/astro/DummyText.astro +9 -0
  74. package/src/components/DummyText/astro/index.ts +1 -0
  75. package/src/components/DummyText/getContent.ts +39 -0
  76. package/src/components/DummyText/react/DummyText.tsx +15 -0
  77. package/src/components/DummyText/react/index.ts +1 -0
  78. package/src/components/DummyText/texts.ts +39 -0
  79. package/src/components/Modal/_style.css +34 -34
  80. package/src/components/Modal/astro/Body.astro +1 -1
  81. package/src/components/Modal/astro/CloseBtn.astro +10 -10
  82. package/src/components/Modal/astro/Inner.astro +1 -1
  83. package/src/components/Modal/astro/Modal.astro +3 -3
  84. package/src/components/Modal/astro/OpenBtn.astro +1 -1
  85. package/src/components/Modal/getProps.js +19 -19
  86. package/src/components/Modal/react/Body.jsx +5 -5
  87. package/src/components/Modal/react/CloseBtn.jsx +13 -13
  88. package/src/components/Modal/react/Inner.jsx +1 -1
  89. package/src/components/Modal/react/Modal.jsx +10 -10
  90. package/src/components/Modal/react/OpenBtn.jsx +5 -5
  91. package/src/components/Modal/script.js +1 -1
  92. package/src/components/Modal/setModal.ts +92 -92
  93. package/src/components/NavMenu/_style.css +17 -17
  94. package/src/components/NavMenu/astro/Item.astro +1 -1
  95. package/src/components/NavMenu/astro/Link.astro +1 -1
  96. package/src/components/NavMenu/astro/Nest.astro +1 -1
  97. package/src/components/NavMenu/astro/Root.astro +1 -1
  98. package/src/components/NavMenu/getProps.js +28 -28
  99. package/src/components/NavMenu/react/NavMenu.jsx +4 -4
  100. package/src/components/ShapeDivider/_style.css +51 -51
  101. package/src/components/ShapeDivider/astro/ShapeDivider.astro +20 -20
  102. package/src/components/ShapeDivider/getProps.js +23 -23
  103. package/src/components/ShapeDivider/react/ShapeDivider.jsx +24 -24
  104. package/src/components/Tabs/_style.css +29 -29
  105. package/src/components/Tabs/astro/Tab.astro +2 -2
  106. package/src/components/Tabs/astro/TabItem.astro +1 -1
  107. package/src/components/Tabs/astro/TabList.astro +2 -2
  108. package/src/components/Tabs/astro/TabPanel.astro +2 -2
  109. package/src/components/Tabs/astro/Tabs.astro +20 -20
  110. package/src/components/Tabs/astro/transformTabitems.js +30 -30
  111. package/src/components/Tabs/getProps.js +4 -4
  112. package/src/components/Tabs/react/Tab.jsx +4 -12
  113. package/src/components/Tabs/react/TabItem.jsx +1 -1
  114. package/src/components/Tabs/react/TabList.jsx +2 -2
  115. package/src/components/Tabs/react/TabPanel.jsx +2 -2
  116. package/src/components/Tabs/react/Tabs.jsx +44 -46
  117. package/src/components/Tabs/script.js +4 -4
  118. package/src/components/Tabs/setTabs.js +70 -70
  119. package/src/components/astro.ts +2 -0
  120. package/src/components/react.ts +2 -0
  121. package/src/helper/animation.ts +10 -10
  122. package/src/helper/uuid.js +3 -3
  123. package/dist/lism-css/dist/components/getFilterProps.js +0 -23
  124. package/dist/lism-css/dist/components/setMaybeTransformStyles.js +0 -7
@@ -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';
@@ -14,23 +14,23 @@ export const waitFrame = (): Promise<number> => new Promise((resolve) => request
14
14
  * - 'canceled': pause() 等でキャンセルされたアニメーションがあった
15
15
  */
16
16
  export const waitAnimation = async (el: HTMLElement): Promise<AnimationStatus> => {
17
- const animations = el.getAnimations();
17
+ const animations = el.getAnimations();
18
18
 
19
- // アニメーションがなければ 'none' を返す
20
- if (animations.length === 0) return 'none';
19
+ // アニメーションがなければ 'none' を返す
20
+ if (animations.length === 0) return 'none';
21
21
 
22
- // allSettled を使うことで、キャンセル時も例外にならずに結果を取得できる
23
- const results = await Promise.allSettled(animations.map((a) => a.finished));
22
+ // allSettled を使うことで、キャンセル時も例外にならずに結果を取得できる
23
+ const results = await Promise.allSettled(animations.map((a) => a.finished));
24
24
 
25
- // ( pause()で止めた時用 )rejected があれば 'canceled'
26
- return results.every((r) => r.status === 'fulfilled') ? 'finished' : 'canceled';
25
+ // ( pause()で止めた時用 )rejected があれば 'canceled'
26
+ return results.every((r) => r.status === 'fulfilled') ? 'finished' : 'canceled';
27
27
  };
28
28
 
29
29
  /**
30
30
  * 実行中のアニメーションがあれば一旦停止させる
31
31
  */
32
32
  export const maybePauseAnimation = (el: HTMLElement): void => {
33
- const animations = el.getAnimations();
34
- if (animations.length === 0) return;
35
- animations.forEach((a) => a.pause());
33
+ const animations = el.getAnimations();
34
+ if (animations.length === 0) return;
35
+ animations.forEach((a) => a.pause());
36
36
  };
@@ -1,6 +1,6 @@
1
1
  // https://stackoverflow.com/questions/105034/how-do-i-create-a-guid-uuid
2
2
  export default function uuidv4() {
3
- return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) =>
4
- (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
5
- );
3
+ return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) =>
4
+ (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
5
+ );
6
6
  }
@@ -1,23 +0,0 @@
1
- const l = [
2
- "blur",
3
- "contrast",
4
- "brightness",
5
- "dropShadow",
6
- "grayscale",
7
- "hueRotate",
8
- "invert",
9
- "saturate",
10
- "sepia"
11
- ];
12
- function c(a, o = "filter") {
13
- const r = [], { style: s = {}, ...t } = a;
14
- return l.forEach((e) => {
15
- if (t[e]) {
16
- const n = e.replace(/([A-Z])/g, "-$1").toLowerCase();
17
- r.push(`${n}(${t[e]})`), delete t[e];
18
- }
19
- }), r.length > 0 && (s[o] = r.join(" ")), { ...t, style: s };
20
- }
21
- export {
22
- c as default
23
- };