@lism-css/ui 0.2.3 → 0.8.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 (60) hide show
  1. package/dist/components/Accordion/astro/index.d.ts +10 -10
  2. package/dist/components/Accordion/getProps.d.ts +40 -19
  3. package/dist/components/Accordion/react/AccIcon.d.ts +1 -6
  4. package/dist/components/Accordion/react/Accordion.d.ts +23 -7
  5. package/dist/components/Accordion/react/index.d.ts +6 -4
  6. package/dist/components/Accordion/setAccordion.d.ts +4 -1
  7. package/dist/components/Accordion/setAccordion.js +39 -42
  8. package/dist/components/Callout/getProps.d.ts +1 -1
  9. package/dist/components/Details/astro/index.d.ts +13 -0
  10. package/dist/components/Details/getProps.d.ts +40 -0
  11. package/dist/components/Details/react/Details.d.ts +37 -0
  12. package/dist/components/Details/react/index.d.ts +9 -0
  13. package/dist/components/Modal/getProps.d.ts +2 -2
  14. package/dist/components/Modal/setModal.d.ts +3 -0
  15. package/dist/components/Modal/setModal.js +24 -29
  16. package/dist/components/Tabs/getProps.d.ts +1 -1
  17. package/dist/components/astro.d.ts +1 -0
  18. package/dist/components/react.d.ts +1 -0
  19. package/dist/helper/animation.d.ts +18 -0
  20. package/dist/helper/animation.js +12 -0
  21. package/dist/helper/uuid.d.ts +1 -0
  22. package/dist/style.css +1 -1
  23. package/package.json +2 -2
  24. package/src/components/Accordion/_style.css +60 -35
  25. package/src/components/Accordion/astro/Button.astro +13 -0
  26. package/src/components/Accordion/astro/Heading.astro +10 -0
  27. package/src/components/Accordion/astro/Icon.astro +15 -0
  28. package/src/components/Accordion/astro/Item.astro +31 -0
  29. package/src/components/Accordion/astro/Panel.astro +14 -0
  30. package/src/components/Accordion/astro/Root.astro +17 -0
  31. package/src/components/Accordion/astro/index.js +10 -7
  32. package/src/components/Accordion/getProps.js +61 -16
  33. package/src/components/Accordion/react/AccIcon.jsx +5 -4
  34. package/src/components/Accordion/react/Accordion.jsx +56 -28
  35. package/src/components/Accordion/react/index.js +6 -3
  36. package/src/components/Accordion/setAccordion.js +114 -88
  37. package/src/components/Callout/getProps.ts +1 -1
  38. package/src/components/Details/_style.css +48 -0
  39. package/src/components/Details/astro/Content.astro +17 -0
  40. package/src/components/Details/astro/Details.astro +18 -0
  41. package/src/components/Details/astro/Icon.astro +14 -0
  42. package/src/components/{Accordion/astro/AccLabel.astro → Details/astro/Summary.astro} +1 -2
  43. package/src/components/Details/astro/Title.astro +10 -0
  44. package/src/components/Details/astro/index.js +10 -0
  45. package/src/components/Details/getProps.js +23 -0
  46. package/src/components/Details/react/Details.jsx +66 -0
  47. package/src/components/Details/react/index.js +6 -0
  48. package/src/components/Modal/script.js +1 -0
  49. package/src/components/Modal/setModal.ts +64 -68
  50. package/src/components/Tabs/astro/Tabs.astro +3 -2
  51. package/src/components/astro.ts +1 -0
  52. package/src/components/react.ts +1 -0
  53. package/src/helper/animation.ts +36 -0
  54. package/src/{components/Tabs/astro/helper.js → helper/uuid.js} +1 -1
  55. package/dist/components/Tabs/astro/helper.d.ts +0 -1
  56. package/src/components/Accordion/astro/AccBody.astro +0 -13
  57. package/src/components/Accordion/astro/AccHeader.astro +0 -13
  58. package/src/components/Accordion/astro/AccHeaderLabel.astro +0 -12
  59. package/src/components/Accordion/astro/AccIcon.astro +0 -17
  60. package/src/components/Accordion/astro/Accordion.astro +0 -22
@@ -4,7 +4,8 @@ import { Lism } from 'lism-css/astro';
4
4
  // import Tab from './Tab.astro';
5
5
  // import TabPanel from './TabPanel.astro';
6
6
  import TabList from './TabList.astro';
7
- import { uuidv4 } from './helper.js';
7
+ import uuid from '../../../helper/uuid.js';
8
+
8
9
  import transformTabitems from './transformTabitems.js';
9
10
  import getTabsProps from '../getProps';
10
11
 
@@ -22,7 +23,7 @@ import '../_style.css';
22
23
  const { defaultIndex = 1, tabId = '', listProps = {}, ...props } = Astro.props || {};
23
24
 
24
25
  // tabID生成
25
- const theTabID = tabId ? tabId : uuidv4();
26
+ const theTabID = tabId ? tabId : uuid();
26
27
 
27
28
  // 子要素の方から順番に処理されていくので、文字列処理でデータを抽出
28
29
  const { btns, panels } = transformTabitems(await Astro.slots.render('default'), theTabID, defaultIndex);
@@ -5,6 +5,7 @@ export { default as Badge } from './Badge/astro';
5
5
  export { default as Button } from './Button/astro';
6
6
  export { default as Callout } from './Callout/astro';
7
7
  export { default as Chat } from './Chat/astro';
8
+ export { default as Details } from './Details/astro';
8
9
  export { default as Modal } from './Modal/astro';
9
10
  export { default as NavMenu } from './NavMenu/astro';
10
11
  export { default as ShapeDivider } from './ShapeDivider/astro';
@@ -5,6 +5,7 @@ export { default as Badge } from './Badge/react';
5
5
  export { default as Button } from './Button/react';
6
6
  export { default as Callout } from './Callout/react';
7
7
  export { default as Chat } from './Chat/react';
8
+ export { default as Details } from './Details/react';
8
9
  export { default as Modal } from './Modal/react';
9
10
  export { default as NavMenu } from './NavMenu/react';
10
11
  export { default as ShapeDivider } from './ShapeDivider/react';
@@ -0,0 +1,36 @@
1
+ // アニメーション完了時のステータス
2
+ type AnimationStatus = 'none' | 'finished' | 'canceled';
3
+
4
+ /**
5
+ * 1フレーム待機する(requestAnimationFrame のPromiseラッパー)
6
+ */
7
+ export const waitFrame = (): Promise<number> => new Promise((resolve) => requestAnimationFrame(resolve));
8
+
9
+ /**
10
+ * 要素のアニメーションが完了するのを待つ
11
+ * @returns アニメーションの結果ステータス
12
+ * - 'none': アニメーションが実行されていなかった
13
+ * - 'finished': すべてのアニメーションが正常に完了
14
+ * - 'canceled': pause() 等でキャンセルされたアニメーションがあった
15
+ */
16
+ export const waitAnimation = async (el: HTMLElement): Promise<AnimationStatus> => {
17
+ const animations = el.getAnimations();
18
+
19
+ // アニメーションがなければ 'none' を返す
20
+ if (animations.length === 0) return 'none';
21
+
22
+ // allSettled を使うことで、キャンセル時も例外にならずに結果を取得できる
23
+ const results = await Promise.allSettled(animations.map((a) => a.finished));
24
+
25
+ // ( pause()で止めた時用 )rejected があれば 'canceled'
26
+ return results.every((r) => r.status === 'fulfilled') ? 'finished' : 'canceled';
27
+ };
28
+
29
+ /**
30
+ * 実行中のアニメーションがあれば一旦停止させる
31
+ */
32
+ export const maybePauseAnimation = (el: HTMLElement): void => {
33
+ const animations = el.getAnimations();
34
+ if (animations.length === 0) return;
35
+ animations.forEach((a) => a.pause());
36
+ };
@@ -1,5 +1,5 @@
1
1
  // https://stackoverflow.com/questions/105034/how-do-i-create-a-guid-uuid
2
- export function uuidv4() {
2
+ export default function uuidv4() {
3
3
  return '10000000-1000-4000-8000-100000000000'.replace(/[018]/g, (c) =>
4
4
  (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
5
5
  );
@@ -1 +0,0 @@
1
- export function uuidv4(): string;
@@ -1,13 +0,0 @@
1
- ---
2
- // import type { LismProps } from 'lism-css/types';
3
- import { Lism } from 'lism-css/astro';
4
- import { defaultProps } from '../getProps';
5
-
6
- const { flow, innerProps, ...props } = Astro.props || {};
7
- ---
8
-
9
- <Lism {...defaultProps.body} {...props}>
10
- <Lism layout='flow' flow={flow} {...defaultProps.inner} {...innerProps}>
11
- <slot />
12
- </Lism>
13
- </Lism>
@@ -1,13 +0,0 @@
1
- ---
2
- // import type { LismProps } from 'lism-css/types';
3
- import { Lism } from 'lism-css/astro';
4
- import { defaultProps } from '../getProps';
5
-
6
- // interface Props extends LismProps {}
7
-
8
- const props = Astro.props || {};
9
- ---
10
-
11
- <Lism tag='summary' {...defaultProps.header} {...props}>
12
- <slot />
13
- </Lism>
@@ -1,12 +0,0 @@
1
- ---
2
- import AccHeader from './AccHeader.astro';
3
- import AccLabel from './AccLabel.astro';
4
- import AccIcon from './AccIcon.astro';
5
- ---
6
-
7
- <AccHeader {...Astro.props || {}}>
8
- <AccLabel>
9
- <slot />
10
- </AccLabel>
11
- <AccIcon />
12
- </AccHeader>
@@ -1,17 +0,0 @@
1
- ---
2
- import { Lism, Icon } from 'lism-css/astro';
3
- import { getAccIconProps } from '../getProps';
4
-
5
- // Propsの定義
6
- // interface Props extends LismProps {
7
- // icon?: string;
8
- // size?: string;
9
- // iconProps?: Object;
10
- // }
11
-
12
- const { viewBox, icon = 'caret-down', ...props } = Astro.props || {};
13
- ---
14
-
15
- <Lism {...getAccIconProps(props)}>
16
- {Astro.slots.has('default') ? <slot /> : <Icon viewBox={viewBox} icon={icon} />}
17
- </Lism>
@@ -1,22 +0,0 @@
1
- ---
2
- // import type { LismProps } from 'lism-css/types';
3
- import getLismProps from 'lism-css/lib/getLismProps';
4
- import { getAccProps } from '../getProps';
5
-
6
- import '../_style.css';
7
-
8
- // Propsの定義
9
- // interface Props extends LismProps {
10
- // duration?: string | number;
11
- // }
12
- const props = Astro.props || {};
13
- ---
14
-
15
- <details {...getLismProps(getAccProps(props))}>
16
- <slot />
17
- </details>
18
-
19
- <script>
20
- import setAccordion from '../setAccordion';
21
- setAccordion();
22
- </script>