@lism-css/ui 0.9.2 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +137 -0
- package/README.md +93 -5
- package/dist/components/Accordion/getProps.js +53 -0
- package/dist/components/Accordion/react/AccIcon.js +9 -0
- package/dist/components/Accordion/react/Accordion.d.ts +5 -6
- package/dist/components/Accordion/react/Accordion.js +45 -0
- package/dist/components/Accordion/react/index.js +6 -0
- package/dist/components/Alert/getProps.js +20 -0
- package/dist/components/Alert/presets.js +29 -0
- package/dist/components/Alert/react/Alert.js +16 -0
- package/dist/components/Avatar/react/Avatar.js +8 -0
- package/dist/components/Badge/react/Badge.js +12 -0
- package/dist/components/Button/react/Button.js +12 -0
- package/dist/components/Callout/getProps.js +22 -0
- package/dist/components/Callout/presets.js +29 -0
- package/dist/components/Callout/react/Callout.js +20 -0
- package/dist/components/Chat/getProps.js +47 -0
- package/dist/components/Chat/react/Chat.js +22 -0
- package/dist/components/Details/getProps.js +15 -0
- package/dist/components/Details/react/Details.js +28 -0
- package/dist/components/Details/react/index.js +5 -0
- package/dist/components/DummyImage/astro/index.d.ts +1 -0
- package/dist/components/DummyImage/react/DummyImage.d.ts +2 -0
- package/dist/components/DummyImage/react/DummyImage.js +8 -0
- package/dist/components/DummyImage/react/index.d.ts +1 -0
- package/dist/components/DummyText/astro/index.d.ts +1 -0
- package/dist/components/DummyText/getContent.d.ts +11 -0
- package/dist/components/DummyText/getContent.js +9 -0
- package/dist/components/DummyText/react/DummyText.d.ts +10 -0
- package/dist/components/DummyText/react/DummyText.js +10 -0
- package/dist/components/DummyText/react/index.d.ts +1 -0
- package/dist/components/DummyText/texts.d.ts +22 -0
- package/dist/components/DummyText/texts.js +39 -0
- package/dist/components/Modal/getProps.js +25 -0
- package/dist/components/Modal/react/Body.js +9 -0
- package/dist/components/Modal/react/CloseBtn.js +13 -0
- package/dist/components/Modal/react/Inner.js +9 -0
- package/dist/components/Modal/react/Modal.d.ts +1 -2
- package/dist/components/Modal/react/Modal.js +17 -0
- package/dist/components/Modal/react/OpenBtn.js +9 -0
- package/dist/components/Modal/react/index.js +9 -0
- package/dist/components/Modal/setModal.js +16 -17
- package/dist/components/NavMenu/getProps.js +40 -0
- package/dist/components/NavMenu/react/NavMenu.js +24 -0
- package/dist/components/NavMenu/react/index.js +5 -0
- package/dist/components/ShapeDivider/getProps.js +22 -0
- package/dist/components/ShapeDivider/react/ShapeDivider.js +26 -0
- package/dist/components/Tabs/getProps.js +10 -0
- package/dist/components/Tabs/react/Tab.js +9 -0
- package/dist/components/Tabs/react/TabItem.js +7 -0
- package/dist/components/Tabs/react/TabList.js +8 -0
- package/dist/components/Tabs/react/TabPanel.js +9 -0
- package/dist/components/Tabs/react/Tabs.d.ts +1 -2
- package/dist/components/Tabs/react/Tabs.js +48 -0
- package/dist/components/Tabs/react/index.js +9 -0
- package/dist/components/Tabs/setTabs.js +10 -11
- package/dist/components/astro.d.ts +2 -0
- package/dist/components/react.d.ts +2 -0
- package/dist/components/react.js +30 -0
- package/dist/lism-css/dist/components/Center/index.js +8 -0
- package/dist/lism-css/dist/components/Flex/index.js +8 -0
- package/dist/lism-css/dist/components/Flow/index.js +8 -0
- package/dist/lism-css/dist/components/Frame/index.js +8 -0
- package/dist/lism-css/dist/components/Grid/index.js +8 -0
- package/dist/lism-css/dist/components/Lism/index.js +8 -0
- package/dist/lism-css/dist/components/Stack/index.js +8 -0
- package/dist/lism-css/dist/components/atomic/Decorator/getProps.js +15 -0
- package/dist/lism-css/dist/components/atomic/Decorator/index.js +9 -0
- package/dist/lism-css/dist/components/atomic/Icon/SVG.js +22 -0
- package/dist/lism-css/dist/components/atomic/Icon/getProps.js +56 -0
- package/dist/lism-css/dist/components/atomic/Icon/index.js +12 -0
- package/dist/lism-css/dist/components/atomic/Icon/presets.js +276 -0
- package/dist/lism-css/dist/config/default-config.js +11 -0
- package/dist/lism-css/dist/config/defaults/props.js +340 -0
- package/dist/lism-css/dist/config/defaults/states.js +39 -0
- package/dist/lism-css/dist/config/defaults/tokens.js +30 -0
- package/dist/lism-css/dist/config/helper/getSvgUrl.js +4 -0
- package/dist/lism-css/dist/config/helper.js +27 -0
- package/dist/lism-css/dist/config/index.js +17 -0
- package/dist/lism-css/dist/lib/getBpData.js +19 -0
- package/dist/lism-css/dist/lib/getLayoutProps.js +30 -0
- package/dist/lism-css/dist/lib/getLismProps.js +188 -0
- package/dist/lism-css/dist/lib/getMaybeCssVar.js +42 -0
- package/dist/lism-css/dist/lib/getMaybeTokenValue.js +26 -0
- package/dist/lism-css/dist/lib/getUtilKey.js +13 -0
- package/dist/lism-css/dist/lib/helper/atts.js +11 -0
- package/dist/lism-css/dist/lib/helper/filterEmptyObj.js +10 -0
- package/dist/lism-css/dist/lib/helper/hasSomeKeys.js +6 -0
- package/dist/lism-css/dist/lib/helper/isEmptyObj.js +6 -0
- package/dist/lism-css/dist/lib/helper/isNumStr.js +6 -0
- package/dist/lism-css/dist/lib/helper/splitWithComma.js +6 -0
- package/dist/lism-css/dist/lib/isPresetValue.js +13 -0
- package/dist/lism-css/dist/lib/isTokenValue.js +27 -0
- package/dist/style.css +1 -1
- package/dist/ui.css +1 -0
- package/package.json +9 -7
- package/src/components/Accordion/_style.css +69 -69
- package/src/components/Accordion/astro/Button.astro +2 -2
- package/src/components/Accordion/astro/Heading.astro +1 -1
- package/src/components/Accordion/astro/Item.astro +7 -7
- package/src/components/Accordion/astro/Panel.astro +3 -3
- package/src/components/Accordion/astro/Root.astro +3 -3
- package/src/components/Accordion/getProps.js +54 -54
- package/src/components/Accordion/react/AccIcon.jsx +1 -1
- package/src/components/Accordion/react/Accordion.jsx +37 -36
- package/src/components/Accordion/script.js +1 -1
- package/src/components/Accordion/setAccordion.js +93 -93
- package/src/components/Alert/astro/Alert.astro +6 -6
- package/src/components/Alert/getProps.ts +22 -22
- package/src/components/Alert/presets.ts +26 -26
- package/src/components/Alert/react/Alert.tsx +9 -9
- package/src/components/Avatar/astro/Avatar.astro +2 -2
- package/src/components/Avatar/react/Avatar.jsx +5 -5
- package/src/components/Badge/_style.css +14 -14
- package/src/components/Badge/astro/Badge.astro +4 -4
- package/src/components/Badge/react/Badge.jsx +6 -6
- package/src/components/Button/_style.css +29 -29
- package/src/components/Button/astro/Button.astro +4 -4
- package/src/components/Button/react/Button.jsx +6 -6
- package/src/components/Callout/astro/Callout.astro +13 -13
- package/src/components/Callout/getProps.ts +24 -24
- package/src/components/Callout/presets.ts +26 -26
- package/src/components/Callout/react/Callout.tsx +16 -16
- package/src/components/Chat/_style.css +49 -49
- package/src/components/Chat/astro/Chat.astro +27 -27
- package/src/components/Chat/getProps.js +40 -45
- package/src/components/Chat/react/Chat.jsx +17 -17
- package/src/components/Details/_style.css +39 -39
- package/src/components/Details/astro/Content.astro +3 -3
- package/src/components/Details/astro/Details.astro +1 -1
- package/src/components/Details/astro/Icon.astro +1 -1
- package/src/components/Details/astro/Summary.astro +2 -2
- package/src/components/Details/astro/Title.astro +1 -1
- package/src/components/Details/getProps.js +7 -7
- package/src/components/Details/react/Details.jsx +24 -24
- package/src/components/DummyImage/astro/DummyImage.astro +7 -0
- package/src/components/DummyImage/astro/index.ts +1 -0
- package/src/components/DummyImage/react/DummyImage.tsx +5 -0
- package/src/components/DummyImage/react/index.ts +1 -0
- package/src/components/DummyText/astro/DummyText.astro +9 -0
- package/src/components/DummyText/astro/index.ts +1 -0
- package/src/components/DummyText/getContent.ts +39 -0
- package/src/components/DummyText/react/DummyText.tsx +15 -0
- package/src/components/DummyText/react/index.ts +1 -0
- package/src/components/DummyText/texts.ts +39 -0
- package/src/components/Modal/_style.css +34 -34
- package/src/components/Modal/astro/Body.astro +1 -1
- package/src/components/Modal/astro/CloseBtn.astro +10 -10
- package/src/components/Modal/astro/Inner.astro +1 -1
- package/src/components/Modal/astro/Modal.astro +3 -3
- package/src/components/Modal/astro/OpenBtn.astro +1 -1
- package/src/components/Modal/getProps.js +19 -19
- package/src/components/Modal/react/Body.jsx +5 -5
- package/src/components/Modal/react/CloseBtn.jsx +13 -13
- package/src/components/Modal/react/Inner.jsx +1 -1
- package/src/components/Modal/react/Modal.jsx +12 -11
- package/src/components/Modal/react/OpenBtn.jsx +5 -5
- package/src/components/Modal/script.js +1 -1
- package/src/components/Modal/setModal.ts +92 -92
- package/src/components/NavMenu/_style.css +17 -17
- package/src/components/NavMenu/astro/Item.astro +1 -1
- package/src/components/NavMenu/astro/Link.astro +1 -1
- package/src/components/NavMenu/astro/Nest.astro +1 -1
- package/src/components/NavMenu/astro/Root.astro +1 -1
- package/src/components/NavMenu/getProps.js +28 -28
- package/src/components/NavMenu/react/NavMenu.jsx +4 -4
- package/src/components/ShapeDivider/_style.css +51 -51
- package/src/components/ShapeDivider/astro/ShapeDivider.astro +20 -20
- package/src/components/ShapeDivider/getProps.js +23 -23
- package/src/components/ShapeDivider/react/ShapeDivider.jsx +24 -24
- package/src/components/Tabs/_style.css +29 -29
- package/src/components/Tabs/astro/Tab.astro +2 -2
- package/src/components/Tabs/astro/TabItem.astro +1 -1
- package/src/components/Tabs/astro/TabList.astro +2 -2
- package/src/components/Tabs/astro/TabPanel.astro +2 -2
- package/src/components/Tabs/astro/Tabs.astro +20 -20
- package/src/components/Tabs/astro/transformTabitems.js +30 -30
- package/src/components/Tabs/getProps.js +4 -4
- package/src/components/Tabs/react/Tab.jsx +4 -12
- package/src/components/Tabs/react/TabItem.jsx +1 -1
- package/src/components/Tabs/react/TabList.jsx +2 -2
- package/src/components/Tabs/react/TabPanel.jsx +2 -2
- package/src/components/Tabs/react/Tabs.jsx +46 -47
- package/src/components/Tabs/script.js +4 -4
- package/src/components/Tabs/setTabs.js +70 -70
- package/src/components/astro.ts +2 -0
- package/src/components/react.ts +2 -0
- package/src/helper/animation.ts +10 -10
- package/src/helper/uuid.js +3 -3
|
@@ -8,24 +8,24 @@ const { viewBox, isAnimation, isEmpty, ...lismProps } = componentProps || {};
|
|
|
8
8
|
---
|
|
9
9
|
|
|
10
10
|
{
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
11
|
+
componentProps && (
|
|
12
|
+
<Lism {...lismProps}>
|
|
13
|
+
{isEmpty ? null : (
|
|
14
|
+
<div class="c--shapeDivider_inner">
|
|
15
|
+
<svg
|
|
16
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
17
|
+
class="c--shapeDivider_svg"
|
|
18
|
+
viewBox={viewBox}
|
|
19
|
+
width="100%"
|
|
20
|
+
height="100%"
|
|
21
|
+
fill="currentColor"
|
|
22
|
+
focusable="false"
|
|
23
|
+
preserveAspectRatio="none"
|
|
24
|
+
>
|
|
25
|
+
<slot />
|
|
26
|
+
</svg>
|
|
27
|
+
</div>
|
|
28
|
+
)}
|
|
29
|
+
</Lism>
|
|
30
|
+
)
|
|
31
31
|
}
|
|
@@ -9,32 +9,32 @@
|
|
|
9
9
|
* @param {string} [props.flip] - X/Y/XY で反転方向を指定
|
|
10
10
|
*/
|
|
11
11
|
export default function getProps({ viewBox, isAnimation, isEmpty, level = 5, stretch, offset, flip, style = {}, ...restProps }) {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
// level が 0 の場合は非表示
|
|
13
|
+
if (level === 0) return null;
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
// CSS変数をセット
|
|
16
|
+
const computedStyle = { ...style };
|
|
17
|
+
computedStyle['--level'] = level || null;
|
|
18
|
+
computedStyle['--_inner-offset'] = offset || null;
|
|
19
|
+
computedStyle['--_inner-stretch'] = stretch || null;
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
const _props = {
|
|
22
|
+
lismClass: 'c--shapeDivider',
|
|
23
|
+
'max-sz': 'full',
|
|
24
|
+
'aria-hidden': 'true',
|
|
25
|
+
};
|
|
26
|
+
if (flip) _props['data-flip'] = flip;
|
|
27
|
+
if (isAnimation) _props['data-has-animation'] = 'true';
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
return {
|
|
30
|
+
..._props,
|
|
31
|
+
style: computedStyle,
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
// SVG用のprops
|
|
34
|
+
viewBox,
|
|
35
|
+
isEmpty,
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
// その他のprops
|
|
38
|
+
...restProps,
|
|
39
|
+
};
|
|
40
40
|
}
|
|
@@ -3,31 +3,31 @@ import getProps from '../getProps';
|
|
|
3
3
|
import '../_style.css';
|
|
4
4
|
|
|
5
5
|
export default function ShapeDivider({ children, ...props }) {
|
|
6
|
-
|
|
6
|
+
const componentProps = getProps(props);
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
// level が 0 の場合は非表示
|
|
9
|
+
if (!componentProps) return null;
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const { viewBox, isAnimation, isEmpty, ...lismProps } = componentProps;
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
.c--tabs_panel {
|
|
25
|
+
grid-area: panel;
|
|
26
|
+
width: 100%;
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
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=
|
|
16
|
-
|
|
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>
|
|
@@ -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=
|
|
15
|
-
|
|
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
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
let index = 1; // 1スタート
|
|
4
|
+
let btns = [];
|
|
5
|
+
let panels = [];
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
// <lism-placeholder-tabitem>でコンテンツを囲んでいるので中身を解析する。
|
|
8
|
+
const regex = /<lism-placeholder-tabitem(.*?)>(.*?)<\/lism-placeholder-tabitem>/gs;
|
|
9
|
+
const matches = [...htmlString.matchAll(regex)];
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const controlId = `${tabID}-${index}`;
|
|
17
|
+
const isActive = index === defaultIndex;
|
|
18
|
+
index++;
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
btns.push(`<button${btnAtts}>${btnContent}</button>`);
|
|
36
|
+
panels.push(panel);
|
|
37
|
+
});
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
return { btns, panels };
|
|
40
40
|
}
|
|
@@ -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
|
-
|
|
5
|
+
const controlId = `${tabId}-${index}`;
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
}
|
|
@@ -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
|
-
|
|
5
|
+
const controlId = `${tabId}-${index}`;
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
return <Lism id={controlId} role="tabpanel" aria-hidden={isActive ? 'false' : 'true'} lismClass="c--tabs_panel" {...props} />;
|
|
8
8
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState, useId, Children, isValidElement } from 'react';
|
|
2
3
|
import { Lism } from 'lism-css/react';
|
|
3
4
|
import Tab from './Tab';
|
|
4
5
|
import TabItem from './TabItem';
|
|
@@ -10,53 +11,51 @@ import getTabsProps from '../getProps';
|
|
|
10
11
|
import '../_style.css';
|
|
11
12
|
|
|
12
13
|
export default function Tabs({ tabId = '', defaultIndex = 1, listProps = {}, children, ...props }) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const [activeIndex, setActiveIndex] = useState(defaultIndex);
|
|
15
|
+
const theTabId = tabId || useId();
|
|
16
|
+
const btns = [];
|
|
17
|
+
const panels = [];
|
|
17
18
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
// Tabs.Item の処理
|
|
20
|
+
Children.forEach(children, (child, index) => {
|
|
21
|
+
const tabIndex = index + 1; // 1 はじまり
|
|
22
|
+
// console.log('child.type', isValidElement(child), child.type);
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
});
|
|
24
|
+
if (isValidElement(child) && child.type === TabItem) {
|
|
25
|
+
Children.forEach(child.props.children, (nestedChild) => {
|
|
26
|
+
if (isValidElement(nestedChild)) {
|
|
27
|
+
if (nestedChild.type === Tab) {
|
|
28
|
+
const tabProps = nestedChild.props;
|
|
29
|
+
btns.push(
|
|
30
|
+
<Tab
|
|
31
|
+
{...tabProps}
|
|
32
|
+
tabId={theTabId}
|
|
33
|
+
index={tabIndex}
|
|
34
|
+
key={tabIndex}
|
|
35
|
+
isActive={tabIndex === activeIndex}
|
|
36
|
+
onClick={() => setActiveIndex(tabIndex)}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
} else if (nestedChild.type === TabPanel) {
|
|
40
|
+
const panelProps = nestedChild.props;
|
|
41
|
+
panels.push(<TabPanel {...panelProps} tabId={theTabId} index={tabIndex} key={tabIndex} isActive={tabIndex === activeIndex} />);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
return (
|
|
49
|
+
<Lism {...getTabsProps(props)}>
|
|
50
|
+
{btns.length === 0 ? (
|
|
51
|
+
// TabItemを使わず直接TabListなどを子要素に配置する場合
|
|
52
|
+
children
|
|
53
|
+
) : (
|
|
54
|
+
<>
|
|
55
|
+
<TabList {...listProps}>{btns}</TabList>
|
|
56
|
+
{panels}
|
|
57
|
+
</>
|
|
58
|
+
)}
|
|
59
|
+
</Lism>
|
|
60
|
+
);
|
|
62
61
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import setTabs from './setTabs.js';
|
|
2
2
|
|
|
3
3
|
document.addEventListener('DOMContentLoaded', function () {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const tabsAll = document.querySelectorAll('.c--tabs');
|
|
5
|
+
tabsAll.forEach((tabs) => {
|
|
6
|
+
setTabs(tabs);
|
|
7
|
+
});
|
|
8
8
|
});
|