@lism-css/ui 0.0.0-dev.2 → 0.0.0-dev.4

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 (83) hide show
  1. package/dist/components/Accordion/astro/__setEvent.d.ts +1 -0
  2. package/dist/components/Accordion/astro/index.d.ts +9 -0
  3. package/dist/components/Accordion/getProps.d.ts +31 -0
  4. package/dist/components/Accordion/react/AccIcon.d.ts +6 -0
  5. package/dist/components/Accordion/react/Accordion.d.ts +23 -0
  6. package/dist/components/Accordion/react/index.d.ts +11 -0
  7. package/dist/components/Accordion/script.d.ts +1 -0
  8. package/dist/components/Accordion/setAccordion.d.ts +3 -0
  9. package/dist/components/Accordion/setAccordion.js +37 -0
  10. package/dist/components/Modal/astro/index.d.ts +8 -0
  11. package/dist/components/Modal/getProps.d.ts +41 -0
  12. package/dist/components/Modal/react/Body.d.ts +4 -0
  13. package/dist/components/Modal/react/CloseBtn.d.ts +7 -0
  14. package/dist/components/Modal/react/Inner.d.ts +4 -0
  15. package/dist/components/Modal/react/Modal.d.ts +6 -0
  16. package/dist/components/Modal/react/OpenBtn.d.ts +5 -0
  17. package/dist/components/Modal/react/index.d.ts +13 -0
  18. package/dist/components/Modal/script.d.ts +1 -0
  19. package/dist/components/Modal/setModal.d.ts +3 -0
  20. package/dist/components/Modal/setModal.js +42 -0
  21. package/dist/components/Tabs/astro/helper.d.ts +1 -0
  22. package/dist/components/Tabs/astro/index.d.ts +8 -0
  23. package/dist/components/Tabs/astro/transformTabitems.d.ts +4 -0
  24. package/dist/components/Tabs/getProps.d.ts +6 -0
  25. package/dist/components/Tabs/react/Tab.d.ts +6 -0
  26. package/dist/components/Tabs/react/TabItem.d.ts +4 -0
  27. package/dist/components/Tabs/react/TabList.d.ts +1 -0
  28. package/dist/components/Tabs/react/TabPanel.d.ts +6 -0
  29. package/dist/components/Tabs/react/Tabs.d.ts +8 -0
  30. package/dist/components/Tabs/react/index.d.ts +13 -0
  31. package/dist/components/Tabs/script.d.ts +1 -0
  32. package/dist/components/Tabs/setTabs.d.ts +2 -0
  33. package/dist/components/Tabs/setTabs.js +29 -0
  34. package/dist/components/__contexts.d.ts +2 -0
  35. package/dist/components/astro.d.ts +3 -0
  36. package/dist/components/react.d.ts +3 -0
  37. package/dist/scripts/accordion.js +4 -0
  38. package/dist/scripts/modal.js +4 -0
  39. package/dist/scripts/tabs.js +6 -0
  40. package/dist/style.css +1 -0
  41. package/package.json +68 -74
  42. package/src/components/Accordion/_style.css +54 -0
  43. package/src/components/Accordion/astro/Accordion.astro +2 -1
  44. package/src/components/Accordion/{AccIcon.jsx → react/AccIcon.jsx} +1 -1
  45. package/src/components/Accordion/{Accordion.jsx → react/Accordion.jsx} +4 -2
  46. package/src/components/Modal/_style.css +44 -0
  47. package/src/components/Modal/astro/Body.astro +13 -0
  48. package/src/components/Modal/astro/CloseBtn.astro +24 -0
  49. package/src/components/Modal/astro/Inner.astro +13 -0
  50. package/src/components/Modal/astro/Modal.astro +21 -0
  51. package/src/components/Modal/astro/OpenBtn.astro +14 -0
  52. package/src/components/Modal/astro/index.js +7 -0
  53. package/src/components/Modal/getProps.js +1 -1
  54. package/src/components/Modal/{Body.jsx → react/Body.jsx} +2 -2
  55. package/src/components/Modal/{CloseBtn.jsx → react/CloseBtn.jsx} +4 -3
  56. package/src/components/Modal/{Inner.jsx → react/Inner.jsx} +2 -2
  57. package/src/components/Modal/{Modal.jsx → react/Modal.jsx} +5 -3
  58. package/src/components/Modal/{OpenBtn.jsx → react/OpenBtn.jsx} +3 -2
  59. package/src/components/Tabs/_style.css +32 -0
  60. package/src/components/Tabs/astro/Tab.astro +17 -0
  61. package/src/components/Tabs/astro/TabItem.astro +8 -0
  62. package/src/components/Tabs/astro/TabList.astro +8 -0
  63. package/src/components/Tabs/astro/TabPanel.astro +16 -0
  64. package/src/components/Tabs/astro/Tabs.astro +57 -0
  65. package/src/components/Tabs/astro/helper.js +6 -0
  66. package/src/components/Tabs/astro/index.js +7 -0
  67. package/src/components/Tabs/astro/transformTabitems.js +40 -0
  68. package/src/components/Tabs/getProps.js +1 -1
  69. package/src/components/Tabs/{Tab.jsx → react/Tab.jsx} +1 -1
  70. package/src/components/Tabs/{TabList.jsx → react/TabList.jsx} +1 -1
  71. package/src/components/Tabs/{TabPanel.jsx → react/TabPanel.jsx} +1 -1
  72. package/src/components/Tabs/{Tabs.jsx → react/Tabs.jsx} +4 -2
  73. package/src/components/Tabs/script.js +2 -2
  74. package/src/components/Tabs/{setEvent.js → setTabs.js} +2 -2
  75. package/src/components/astro.ts +2 -2
  76. package/src/components/react.ts +3 -3
  77. package/src/style.scss +1 -0
  78. package/LICENSE +0 -21
  79. package/src/components/Accordion/_style.scss +0 -54
  80. /package/src/components/Accordion/{index.js → react/index.js} +0 -0
  81. /package/src/components/Modal/{index.js → react/index.js} +0 -0
  82. /package/src/components/Tabs/{TabItem.jsx → react/TabItem.jsx} +0 -0
  83. /package/src/components/Tabs/{index.js → react/index.js} +0 -0
@@ -3,6 +3,8 @@
3
3
  import getLismProps from 'lism-css/lib/getLismProps';
4
4
  import { getAccProps } from '../getProps';
5
5
 
6
+ import '../_style.css';
7
+
6
8
  // Propsの定義
7
9
  // interface Props extends LismProps {
8
10
  // duration?: string | number;
@@ -15,7 +17,6 @@ const props = Astro.props || {};
15
17
  </details>
16
18
 
17
19
  <script>
18
- // import setEvent from './setEvent';
19
20
  import setAccordion from '../setAccordion';
20
21
  setAccordion();
21
22
  </script>
@@ -1,5 +1,5 @@
1
1
  import { Lism, Icon } from 'lism-css/react';
2
- import { getAccIconProps } from './getProps';
2
+ import { getAccIconProps } from '../getProps';
3
3
 
4
4
  export default function AccIcon({ icon = 'caret-down', viewBox, children = null, ...props }) {
5
5
  return <Lism {...getAccIconProps(props)}>{children || <Icon viewBox={viewBox} icon={icon} />}</Lism>;
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
2
  import getLismProps from 'lism-css/lib/getLismProps';
3
3
  import { Lism } from 'lism-css/react';
4
- import { getAccProps, defaultProps } from './getProps';
5
- import { setEvent } from './setAccordion';
4
+ import { getAccProps, defaultProps } from '../getProps';
5
+ import { setEvent } from '../setAccordion';
6
6
  import AccIcon from './AccIcon';
7
7
 
8
+ import '../_style.css';
9
+
8
10
  // import { AccContext } from './context';
9
11
 
10
12
  // duration: [s]
@@ -0,0 +1,44 @@
1
+ /*
2
+ * dialog で実装.
3
+ * Memo: ::backdrop のアニメーションはFirefoxで動かない
4
+ */
5
+ @layer lism.modules {
6
+ .d--modal {
7
+ --flow: 0; /* flow直下にきても影響しないように */
8
+ --duration: var(--modal-duration, 0.4s);
9
+ width: 100%;
10
+ height: 100%;
11
+ max-width: 100%;
12
+ max-height: 100%;
13
+ overflow: unset;
14
+ background: var(--backdrop-bg, rgb(0 0 0 / 0.6));
15
+ transition-duration: var(--duration);
16
+ transition-property: opacity;
17
+ }
18
+ .d--modal::backdrop {
19
+ background: none;
20
+ }
21
+ .d--modal[open] {
22
+ display: flex;
23
+ flex-direction: column;
24
+ justify-content: center;
25
+ }
26
+
27
+ .d--modal_inner {
28
+ --offset: 0 0; /* アニメーション用 */
29
+ background-color: var(--base);
30
+ transition: translate var(--duration);
31
+ max-height: 100%;
32
+ }
33
+
34
+ /* .d--modal_body {
35
+ overscroll-behavior: contain;
36
+ } */
37
+
38
+ .d--modal:not([data-is-open]) {
39
+ opacity: 0;
40
+ }
41
+ .d--modal:not([data-is-open]) > .d--modal_inner {
42
+ translate: var(--offset);
43
+ }
44
+ }
@@ -0,0 +1,13 @@
1
+ ---
2
+ // import type { LismProps } from 'lism-css/types';
3
+ import { Lism } from 'lism-css/react';
4
+ import { defaultProps } from '../getProps';
5
+
6
+ // Propsの定義
7
+ // interface Props extends LismProps {}
8
+ const props = Astro.props || {};
9
+ ---
10
+
11
+ <Lism {...defaultProps.body} {...props}>
12
+ <slot />
13
+ </Lism>
@@ -0,0 +1,24 @@
1
+ ---
2
+ // import type { LismProps } from 'lism-css/types';
3
+ import { Lism } from 'lism-css/react';
4
+ import { Icon } from 'lism-css/react';
5
+ import { defaultProps } from '../getProps';
6
+
7
+ // Propsの定義
8
+ // interface Props extends LismProps {}
9
+ const { modalId = '', icon, srText = 'Close', ...props } = Astro.props || {};
10
+ const btnProps = { ...defaultProps.closeBtn, ...props };
11
+ ---
12
+
13
+ {
14
+ Astro.slots.has('default') ? (
15
+ <Lism data-modal-close={modalId} {...btnProps}>
16
+ <slot />
17
+ </Lism>
18
+ ) : (
19
+ <Lism data-modal-close={modalId} {...btnProps}>
20
+ <Icon icon={icon || 'x'} />
21
+ <span class='u-hidden'>{srText || 'Close'}</span>
22
+ </Lism>
23
+ )
24
+ }
@@ -0,0 +1,13 @@
1
+ ---
2
+ // import type { LismProps } from 'lism-css/types';
3
+ import { Lism } from 'lism-css/react';
4
+ import { getInnerProps } from '../getProps';
5
+
6
+ // Propsの定義
7
+ // interface Props extends LismProps {}
8
+ const props = Astro.props || {};
9
+ ---
10
+
11
+ <Lism {...getInnerProps(props)}>
12
+ <slot />
13
+ </Lism>
@@ -0,0 +1,21 @@
1
+ ---
2
+ // import type { LismProps } from 'lism-css/types';
3
+ import { Lism } from 'lism-css/react';
4
+ import { getProps } from '../getProps';
5
+ import '../_style.css';
6
+
7
+ // Propsの定義
8
+ // interface Props extends LismProps {
9
+ // duration?: string | number;
10
+ // }
11
+ const props = Astro.props || {};
12
+ ---
13
+
14
+ <Lism {...getProps(props)}>
15
+ <slot />
16
+ </Lism>
17
+
18
+ <script>
19
+ import setModal from '../setModal';
20
+ setModal();
21
+ </script>
@@ -0,0 +1,14 @@
1
+ ---
2
+ // import type { LismProps } from 'lism-css/types';
3
+ import { Lism } from 'lism-css/react';
4
+ import { defaultProps } from '../getProps';
5
+
6
+ // Propsの定義
7
+ // interface Props extends LismProps {}
8
+ const { modalId = '', ...props } = Astro.props || {};
9
+ const btnProps = { ...defaultProps.openBtn, ...props };
10
+ ---
11
+
12
+ <Lism data-modal-open={modalId} {...btnProps}>
13
+ <slot />
14
+ </Lism>
@@ -0,0 +1,7 @@
1
+ import Root from './Modal.astro';
2
+ import Inner from './Inner.astro';
3
+ import Body from './Body.astro';
4
+ import CloseBtn from './CloseBtn.astro';
5
+ import OpenBtn from './OpenBtn.astro';
6
+
7
+ export default { Root, Inner, Body, CloseBtn, OpenBtn };
@@ -1,4 +1,4 @@
1
- import atts from '../../lib/helper/atts';
1
+ import atts from 'lism-css/lib/helper/atts';
2
2
 
3
3
  export function getProps({ lismClass = '', duration, style = {}, ...props }) {
4
4
  const theProps = {
@@ -1,5 +1,5 @@
1
- import { Lism } from '../Lism';
2
- import { defaultProps } from './getProps';
1
+ import { Lism } from '../../Lism';
2
+ import { defaultProps } from '../getProps';
3
3
 
4
4
  export default function ModalBody({ children, ...props }) {
5
5
  return (
@@ -1,6 +1,7 @@
1
- import { Lism } from '../Lism';
2
- import { Icon } from '../atomic/Icon';
3
- import { defaultProps } from './getProps';
1
+ import { Lism } from '../../Lism';
2
+ import { Icon } from '../../atomic/Icon';
3
+ import { defaultProps } from '../getProps';
4
+
4
5
  // duration: [s]
5
6
  export default function CloseBtn({ children, modalId = '', icon, srText = 'Close', ...props }) {
6
7
  // const lismProps = getLismProps(getAccProps(props));
@@ -1,5 +1,5 @@
1
- import { Lism } from '../Lism';
2
- import { getInnerProps } from './getProps';
1
+ import { Lism } from '../../Lism';
2
+ import { getInnerProps } from '../getProps';
3
3
 
4
4
  export default function ModalInner({ children, ...props }) {
5
5
  return <Lism {...getInnerProps(props)}>{children}</Lism>;
@@ -1,7 +1,9 @@
1
1
  import React from 'react';
2
- import { Lism } from '../Lism';
3
- import { setEvent } from './setModal';
4
- import { getProps } from './getProps';
2
+ import { Lism } from '../../Lism';
3
+ import { setEvent } from '../setModal';
4
+ import { getProps } from '../getProps';
5
+
6
+ import '../_style.css';
5
7
 
6
8
  // duration: [s]
7
9
  const Modal = ({ children, ...props }) => {
@@ -1,5 +1,6 @@
1
- import { Lism } from '../Lism';
2
- import { defaultProps } from './getProps';
1
+ import { Lism } from '../../Lism';
2
+ import { defaultProps } from '../getProps';
3
+
3
4
  // duration: [s]
4
5
  export default function OpenBtn({ children, modalId = '', ...props }) {
5
6
  return (
@@ -0,0 +1,32 @@
1
+ @layer lism.modules {
2
+ .d--tabs {
3
+ display: grid;
4
+ grid: 'list' 'panel' / 100%;
5
+ }
6
+ .d--tabs_list {
7
+ grid-area: list;
8
+ display: flex;
9
+ overflow-x: auto;
10
+ }
11
+ .d--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
+
24
+ .d--tabs_panel {
25
+ grid-area: panel;
26
+ width: 100%;
27
+
28
+ &:where([aria-hidden='true']) {
29
+ display: none;
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,17 @@
1
+ ---
2
+ // import type { LismProps } from 'lism-css/types';
3
+ import { Lism } from 'lism-css/react';
4
+
5
+ // export interface Props extends LismProps {
6
+ // // controlId: string;
7
+ // isActive?: boolean;
8
+ // tabId?: string | number;
9
+ // index?: number;
10
+ // }
11
+ const { tabId = 'tab', index = 0, isActive, ...props } = Astro.props;
12
+ const controlId = `${tabId}-${index}`;
13
+ ---
14
+
15
+ <Lism tag='button' lismClass='d--tabs_tab' setPlain role='tab' aria-controls={controlId} aria-selected={isActive ? 'true' : 'false'} {...props}>
16
+ <slot />
17
+ </Lism>
@@ -0,0 +1,8 @@
1
+ ---
2
+ // memo: タブボタンが <button ~ button> で取得できることを前提にして<slot />だけにしている。
3
+ // <slot name='tab' />,<slot name='panel' />に分け、それぞれをカスタムDOMで囲んだ方が確実にそれぞれの内容は取れるが、わざわざslot指定が必要になってしまう。
4
+ ---
5
+
6
+ <lism-placeholder-tabitem>
7
+ <slot />
8
+ </lism-placeholder-tabitem>
@@ -0,0 +1,8 @@
1
+ ---
2
+ // import type { LismProps } from 'lism-css/types';
3
+ import { Lism } from 'lism-css/react';
4
+ ---
5
+
6
+ <Lism lismClass='d--tabs_list' role='tablist' {...Astro.props}>
7
+ <slot />
8
+ </Lism>
@@ -0,0 +1,16 @@
1
+ ---
2
+ // import type { LismProps } from 'lism-css/types';
3
+ import { Lism } from 'lism-css/react';
4
+
5
+ // export interface Props extends LismProps {
6
+ // isActive?: boolean;
7
+ // tabId?: string | number;
8
+ // index?: number;
9
+ // }
10
+ const { tabId = 'tab', index = 0, isActive = false, ...props } = Astro.props;
11
+ const controlId = `${tabId}-${index}`;
12
+ ---
13
+
14
+ <Lism id={controlId} role='tabpanel' aria-hidden={isActive ? 'false' : 'true'} lismClass='d--tabs_panel' {...props}>
15
+ <slot />
16
+ </Lism>
@@ -0,0 +1,57 @@
1
+ ---
2
+ // import type { LismProps } from 'lism-css/types';
3
+ import { Lism } from 'lism-css/react';
4
+ // import Tab from './Tab.astro';
5
+ // import TabPanel from './TabPanel.astro';
6
+ import TabList from './TabList.astro';
7
+ import { uuidv4 } from './helper.js';
8
+ import transformTabitems from './transformTabitems.js';
9
+ import getTabsProps from '../getProps';
10
+
11
+ import '../_style.css';
12
+
13
+ // import TheTab from './TheTab.astro';}
14
+ // slotsについて: https://docs.astro.build/ja/reference/api-reference/#astroslots
15
+
16
+ // Propsの定義
17
+ // interface Props extends LismProps {
18
+ // uid?: string | number;
19
+ // defaultIndex?: string | number;
20
+ // }
21
+ // propsの取得
22
+ const { defaultIndex = 1, tabId = '', listProps = {}, ...props } = Astro.props || {};
23
+
24
+ // tabID生成
25
+ const theTabID = tabId ? tabId : uuidv4();
26
+
27
+ // 子要素の方から順番に処理されていくので、文字列処理でデータを抽出
28
+ const { btns, panels } = transformTabitems(await Astro.slots.render('default'), theTabID, defaultIndex);
29
+
30
+ const hasItems = btns.length > 0;
31
+ ---
32
+
33
+ <Lism {...getTabsProps(props)}>
34
+ {
35
+ btns && (
36
+ <TabList {...listProps}>
37
+ {btns.map((btn, index) => {
38
+ return <Fragment key={index} set:html={btn} />;
39
+ })}
40
+ </TabList>
41
+ )
42
+ }
43
+ {
44
+ panels.map((panel, index) => {
45
+ return <Fragment key={index} set:html={panel} />;
46
+ })
47
+ }
48
+ {!hasItems && <slot />}
49
+ </Lism>
50
+
51
+ <script>
52
+ import setTabs from '../setTabs';
53
+ const tabsAll = document.querySelectorAll('.d--tabs');
54
+ tabsAll.forEach((tabs) => {
55
+ setTabs(tabs);
56
+ });
57
+ </script>
@@ -0,0 +1,6 @@
1
+ // https://stackoverflow.com/questions/105034/how-do-i-create-a-guid-uuid
2
+ export 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
+ );
6
+ }
@@ -0,0 +1,7 @@
1
+ import Root from './Tabs.astro';
2
+ import Item from './TabItem.astro';
3
+ import List from './TabList.astro';
4
+ import Panel from './TabPanel.astro';
5
+ import Tab from './Tab.astro';
6
+
7
+ export default { Root, List, Panel, Item, Tab };
@@ -0,0 +1,40 @@
1
+ // <lism-placeholder-tabitem> → div.tabitem へ 変換
2
+ export default function transformHTML(htmlString, tabID, defaultIndex) {
3
+ let index = 1; // 1スタート
4
+ let btns = [];
5
+ let panels = [];
6
+
7
+ // <lism-placeholder-tabitem>でコンテンツを囲んでいるので中身を解析する。
8
+ const regex = /<lism-placeholder-tabitem(.*?)>(.*?)<\/lism-placeholder-tabitem>/gs;
9
+ const matches = [...htmlString.matchAll(regex)];
10
+
11
+ // console.log(matches);
12
+ matches.forEach((match) => {
13
+ // const tabItemAttrs = match[1]; // 使わないがdata-astro-source-file属性が自動でついてきたりするので、属性値があっても問題ないようにしている。
14
+ const tabItemContent = match[2];
15
+
16
+ const controlId = `${tabID}-${index}`;
17
+ const isActive = index === defaultIndex;
18
+ index++;
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];
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
+ }
34
+
35
+ btns.push(`<button${btnAtts}>${btnContent}</button>`);
36
+ panels.push(panel);
37
+ });
38
+
39
+ return { btns, panels };
40
+ }
@@ -1,4 +1,4 @@
1
- import atts from '../../lib/helper/atts';
1
+ import atts from 'lism-css/lib/helper/atts';
2
2
 
3
3
  export default function getTabsProps({ lismClass, ...props }) {
4
4
  return {
@@ -1,5 +1,5 @@
1
1
  // import React from 'react';
2
- import { Lism } from '../Lism';
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}`;
@@ -1,4 +1,4 @@
1
- import { Lism } from '../Lism';
1
+ import { Lism } from 'lism-css/react';
2
2
 
3
3
  export default function TabList(props) {
4
4
  // jc: 's',
@@ -1,5 +1,5 @@
1
1
  // import React from 'react';
2
- import { Lism } from '../Lism';
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}`;
@@ -1,12 +1,14 @@
1
1
  import React from 'react';
2
- import { Lism } from '../Lism';
2
+ import { Lism } from 'lism-css/react';
3
3
  import Tab from './Tab';
4
4
  import TabItem from './TabItem';
5
5
  import TabList from './TabList';
6
6
  import TabPanel from './TabPanel';
7
- import getTabsProps from './getProps';
7
+ import getTabsProps from '../getProps';
8
8
  // import { TabContext } from './context';
9
9
 
10
+ import '../_style.css';
11
+
10
12
  export default function Tabs({ tabId = '', defaultIndex = 1, listProps = {}, children, ...props }) {
11
13
  const [activeIndex, setActiveIndex] = React.useState(defaultIndex);
12
14
  const theTabId = tabId || React.useId();
@@ -1,8 +1,8 @@
1
- import setEvent from './setEvent.js';
1
+ import setTabs from './setTabs.js';
2
2
 
3
3
  document.addEventListener('DOMContentLoaded', function () {
4
4
  const tabsAll = document.querySelectorAll('.d--tabs');
5
5
  tabsAll.forEach((tabs) => {
6
- setEvent(tabs);
6
+ setTabs(tabs);
7
7
  });
8
8
  });
@@ -46,7 +46,7 @@ const toggleAriaData = (clickedButton) => {
46
46
  targetBody.setAttribute('aria-hidden', 'false');
47
47
  };
48
48
 
49
- function setEvent(tabs) {
49
+ function setTabs(tabs) {
50
50
  const tabBtns = tabs.querySelectorAll('button[role="tab"]');
51
51
  tabBtns.forEach((tabBtn) => {
52
52
  tabBtn.addEventListener('click', function (e) {
@@ -84,4 +84,4 @@ function setEvent(tabs) {
84
84
  }
85
85
  }
86
86
 
87
- export default setEvent;
87
+ export default setTabs;
@@ -1,3 +1,3 @@
1
1
  export { default as Accordion } from './Accordion/astro';
2
- // export { default as Tabs } from './Tabs';
3
- // export { default as Modal } from './Modal';
2
+ export { default as Modal } from './Modal/astro';
3
+ export { default as Tabs } from './Tabs/astro';
@@ -1,3 +1,3 @@
1
- export { default as Accordion } from './Accordion';
2
- // export { default as Tabs } from './Tabs';
3
- // export { default as Modal } from './Modal';
1
+ export { default as Accordion } from './Accordion/react';
2
+ export { default as Modal } from './Modal/react';
3
+ export { default as Tabs } from './Tabs/react';
package/src/style.scss ADDED
@@ -0,0 +1 @@
1
+ @use './components/Accordion/_style.css';
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) Loos, Inc.
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
@@ -1,54 +0,0 @@
1
- .d--accordion {
2
- --duration: var(--acc-duration, 0.4s);
3
- &[data-opened] {
4
- --_notOpen: ;
5
- }
6
- &:not([data-opened]) {
7
- --_isOpen: ;
8
- }
9
- }
10
-
11
- .d--accordion_header {
12
- display: grid;
13
- grid: auto / 1fr auto;
14
- gap: 0.5em;
15
- align-items: center;
16
- outline-offset: -1px; // overflow:clip|hidden; で見えなくなってしまうのを防ぐ
17
-
18
- /* Safariで表示されるデフォルトの三角形アイコンを消す */
19
- &::-webkit-details-marker {
20
- display: none;
21
- }
22
- }
23
-
24
- .d--accordion_body {
25
- display: grid;
26
- grid: 1fr / auto;
27
- transition-property: margin-block, padding-block, opacity, grid-template;
28
- transition-duration: var(--duration);
29
- }
30
-
31
- // ※ 正常な animation には必須
32
- .d--accordion_inner {
33
- overflow: hidden;
34
- }
35
-
36
- // 閉じている時
37
- .d--accordion:not([data-opened]) {
38
- > .d--accordion_body {
39
- grid: 0fr / auto;
40
- padding-block: 0 !important;
41
- margin-block: 0 !important;
42
- }
43
- }
44
-
45
- // アコーディオンブロックのネスト時、別のアイコンタイプにすると表示が崩れるがそこまでは考慮しない。
46
- .d--accordion_icon {
47
- display: grid;
48
-
49
- // __icon 自体にborderつけたりすると回転が見えてしまうので、 icon自体を回転させる。
50
- > .a--icon {
51
- transition-duration: var(--duration);
52
- rotate: var(--_isOpen, -180deg);
53
- }
54
- }