@svelte-atoms/core 1.0.0-alpha.27 → 1.0.0-alpha.28

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 (163) hide show
  1. package/README.md +856 -645
  2. package/dist/components/accordion/accordion-root.svelte +61 -61
  3. package/dist/components/accordion/item/accordion-item-body.svelte +42 -42
  4. package/dist/components/accordion/item/accordion-item-header.svelte +50 -50
  5. package/dist/components/accordion/item/accordion-item-indicator.svelte +50 -50
  6. package/dist/components/accordion/item/accordion-item-root.svelte +65 -65
  7. package/dist/components/alert/alert-actions.svelte +2 -1
  8. package/dist/components/alert/alert-close-button.svelte +18 -20
  9. package/dist/components/alert/alert-content.svelte +2 -1
  10. package/dist/components/alert/alert-description.svelte +2 -1
  11. package/dist/components/alert/alert-icon.svelte +2 -1
  12. package/dist/components/alert/alert-root.svelte +3 -2
  13. package/dist/components/alert/alert-title.svelte +2 -1
  14. package/dist/components/alert/alert.stories.svelte +401 -40
  15. package/dist/components/alert/alert.stories.svelte.d.ts +2 -5
  16. package/dist/components/atom/html-atom.svelte +205 -201
  17. package/dist/components/atom/snippet-renderer.svelte +5 -0
  18. package/dist/components/atom/snippet-renderer.svelte.d.ts +5 -0
  19. package/dist/components/avatar/avatar.stories.svelte.d.ts +1 -1
  20. package/dist/components/badge/badge.stories.svelte.d.ts +1 -1
  21. package/dist/components/breadcrumb/breadcrumb.stories.svelte.d.ts +1 -1
  22. package/dist/components/button/button.stories.svelte +60 -57
  23. package/dist/components/calendar/atoms.d.ts +5 -0
  24. package/dist/components/calendar/atoms.js +5 -0
  25. package/dist/components/calendar/bond.svelte.d.ts +72 -0
  26. package/dist/components/calendar/bond.svelte.js +132 -0
  27. package/dist/components/calendar/calendar-body.svelte +107 -0
  28. package/dist/components/calendar/calendar-body.svelte.d.ts +8 -0
  29. package/dist/components/calendar/calendar-day.svelte +97 -0
  30. package/dist/components/calendar/calendar-day.svelte.d.ts +4 -0
  31. package/dist/components/calendar/calendar-header.svelte +33 -0
  32. package/dist/components/calendar/calendar-header.svelte.d.ts +7 -0
  33. package/dist/components/calendar/calendar-root.svelte +208 -0
  34. package/dist/components/calendar/calendar-root.svelte.d.ts +8 -0
  35. package/dist/components/calendar/calendar-week-day.svelte +34 -0
  36. package/dist/components/calendar/calendar-week-day.svelte.d.ts +9 -0
  37. package/dist/components/calendar/calendar.css +26 -0
  38. package/dist/components/calendar/calendar.stories.svelte +36 -0
  39. package/dist/components/calendar/calendar.stories.svelte.d.ts +6 -0
  40. package/dist/components/calendar/index.d.ts +4 -0
  41. package/dist/components/calendar/index.js +4 -0
  42. package/dist/components/calendar/runes.svelte.d.ts +3 -0
  43. package/dist/components/calendar/runes.svelte.js +25 -0
  44. package/dist/components/calendar/types.d.ts +62 -0
  45. package/dist/components/calendar/types.js +1 -0
  46. package/dist/components/card/card-body.svelte +39 -39
  47. package/dist/components/card/card-description.svelte +41 -41
  48. package/dist/components/card/card-footer.svelte +41 -41
  49. package/dist/components/card/card-header.svelte +41 -41
  50. package/dist/components/card/card-media.svelte +41 -41
  51. package/dist/components/card/card-root.svelte +91 -91
  52. package/dist/components/card/card-subtitle.svelte +41 -41
  53. package/dist/components/card/card-title.svelte +45 -45
  54. package/dist/components/collapsible/collapsible-body.svelte +39 -39
  55. package/dist/components/collapsible/collapsible-header.svelte +39 -39
  56. package/dist/components/collapsible/collapsible-indicator.svelte +50 -50
  57. package/dist/components/collapsible/collapsible-root.svelte +66 -66
  58. package/dist/components/combobox/combobox-root.svelte +65 -65
  59. package/dist/components/container/container.stories.svelte.d.ts +1 -1
  60. package/dist/components/contextmenu/contextmenu-trigger.svelte.d.ts +1 -1
  61. package/dist/components/datagrid/bond.svelte.d.ts +2 -2
  62. package/dist/components/datagrid/datagrid-body.svelte +37 -37
  63. package/dist/components/datagrid/datagrid-checkbox.svelte +101 -101
  64. package/dist/components/datagrid/datagrid-footer.svelte +34 -34
  65. package/dist/components/datagrid/datagrid-header.svelte +49 -49
  66. package/dist/components/datagrid/datagrid-root.svelte +59 -59
  67. package/dist/components/datagrid/td/datagrid-td.svelte +66 -66
  68. package/dist/components/datagrid/th/datagrid-th.svelte +106 -106
  69. package/dist/components/datagrid/tr/datagrid-tr.svelte +88 -88
  70. package/dist/components/date-picker/atoms.d.ts +7 -0
  71. package/dist/components/date-picker/atoms.js +7 -0
  72. package/dist/components/date-picker/bond.svelte.d.ts +67 -0
  73. package/dist/components/date-picker/bond.svelte.js +174 -0
  74. package/dist/components/date-picker/date-picker-calendar.svelte +42 -0
  75. package/dist/components/date-picker/date-picker-calendar.svelte.d.ts +7 -0
  76. package/dist/components/date-picker/date-picker-header.svelte +105 -0
  77. package/dist/components/date-picker/date-picker-header.svelte.d.ts +7 -0
  78. package/dist/components/date-picker/date-picker-months.svelte +150 -0
  79. package/dist/components/date-picker/date-picker-months.svelte.d.ts +7 -0
  80. package/dist/components/date-picker/date-picker-root.svelte +94 -0
  81. package/dist/components/date-picker/date-picker-root.svelte.d.ts +17 -0
  82. package/dist/components/date-picker/date-picker-years.svelte +214 -0
  83. package/dist/components/date-picker/date-picker-years.svelte.d.ts +7 -0
  84. package/dist/components/date-picker/date-picker.stories.svelte +51 -0
  85. package/dist/components/date-picker/date-picker.stories.svelte.d.ts +3 -0
  86. package/dist/components/date-picker/index.d.ts +3 -0
  87. package/dist/components/date-picker/index.js +3 -0
  88. package/dist/components/date-picker/types.d.ts +1 -0
  89. package/dist/components/date-picker/types.js +1 -0
  90. package/dist/components/dialog/dialog-body.svelte +39 -39
  91. package/dist/components/dialog/dialog-close-button.svelte +58 -58
  92. package/dist/components/dialog/dialog-content.svelte +62 -62
  93. package/dist/components/dialog/dialog-description.svelte +40 -40
  94. package/dist/components/dialog/dialog-footer.svelte +39 -39
  95. package/dist/components/dialog/dialog-header.svelte +39 -39
  96. package/dist/components/dialog/dialog-root.svelte +110 -110
  97. package/dist/components/dialog/dialog-title.svelte +41 -41
  98. package/dist/components/drawer/drawer-backdrop.svelte +38 -38
  99. package/dist/components/drawer/drawer-body.svelte +42 -42
  100. package/dist/components/drawer/drawer-content.svelte +42 -42
  101. package/dist/components/drawer/drawer-description.svelte +44 -44
  102. package/dist/components/drawer/drawer-footer.svelte +41 -41
  103. package/dist/components/drawer/drawer-header.svelte +43 -43
  104. package/dist/components/drawer/drawer-root.svelte +93 -93
  105. package/dist/components/drawer/drawer-title.svelte +44 -44
  106. package/dist/components/dropdown/dropdown-query.svelte +54 -54
  107. package/dist/components/dropdown/dropdown-root.svelte +59 -59
  108. package/dist/components/dropdown/dropdown-trigger.svelte +41 -41
  109. package/dist/components/dropdown/dropdown-value.svelte +60 -60
  110. package/dist/components/element/html-element.svelte +85 -85
  111. package/dist/components/form/bond.svelte.d.ts +1 -1
  112. package/dist/components/form/field/field-control.svelte +48 -48
  113. package/dist/components/form/field/field-label.svelte +24 -24
  114. package/dist/components/form/field/field-root.svelte +59 -59
  115. package/dist/components/icon/icon.svelte +44 -44
  116. package/dist/components/image/image.stories.svelte.d.ts +1 -1
  117. package/dist/components/index.d.ts +3 -0
  118. package/dist/components/index.js +3 -0
  119. package/dist/components/input/input-control.svelte +103 -103
  120. package/dist/components/label/label.svelte +25 -25
  121. package/dist/components/popover/popover-arrow.svelte +111 -111
  122. package/dist/components/popover/popover-content.svelte +46 -7
  123. package/dist/components/popover/popover-root.svelte +48 -49
  124. package/dist/components/popover/popover.stories.svelte +52 -67
  125. package/dist/components/portal/portal-root.svelte +83 -83
  126. package/dist/components/portal/teleport.svelte +50 -50
  127. package/dist/components/qr-code/index.d.ts +1 -0
  128. package/dist/components/qr-code/index.js +1 -0
  129. package/dist/components/qr-code/qr-code.stories.svelte +24 -0
  130. package/dist/components/qr-code/qr-code.stories.svelte.d.ts +26 -0
  131. package/dist/components/qr-code/qr-code.svelte +25 -0
  132. package/dist/components/qr-code/qr-code.svelte.d.ts +6 -0
  133. package/dist/components/radio/radio.svelte +109 -109
  134. package/dist/components/radio/types.svelte.d.ts +1 -1
  135. package/dist/components/scrollable/scrollable-container.svelte +82 -82
  136. package/dist/components/scrollable/scrollable-content.svelte +41 -41
  137. package/dist/components/scrollable/scrollable-root.svelte +100 -100
  138. package/dist/components/scrollable/scrollable-thumb.svelte +75 -75
  139. package/dist/components/scrollable/scrollable-track.svelte +59 -59
  140. package/dist/components/scrollable/scrollable.stories.svelte.d.ts +1 -1
  141. package/dist/components/tabs/tab/tab-body.svelte +52 -52
  142. package/dist/components/tabs/tab/tab-description.svelte +41 -41
  143. package/dist/components/tabs/tab/tab-header.svelte +71 -71
  144. package/dist/components/tabs/tab/tab-root.svelte +86 -86
  145. package/dist/components/toast/toast-description.svelte +38 -38
  146. package/dist/components/toast/toast-root.svelte +61 -61
  147. package/dist/components/toast/toast-title.svelte +35 -35
  148. package/dist/components/tree/tree-body.svelte +39 -39
  149. package/dist/components/tree/tree-header.svelte +54 -54
  150. package/dist/components/tree/tree-indicator.svelte +40 -40
  151. package/dist/components/tree/tree-root.svelte +65 -65
  152. package/dist/components/virtual/virtual-root.svelte +239 -239
  153. package/dist/context/preset.svelte.d.ts +1 -1
  154. package/dist/icons/icon-arrow-down.svelte.d.ts +1 -1
  155. package/dist/icons/icon-checkmark.svelte.d.ts +1 -1
  156. package/dist/icons/icon-close.svelte.d.ts +1 -1
  157. package/dist/icons/icon-more-vert.svelte.d.ts +1 -1
  158. package/dist/runes/container.svelte.d.ts +2 -2
  159. package/dist/shared/bond.svelte.d.ts +1 -1
  160. package/dist/utils/state.d.ts +1 -1
  161. package/dist/utils/state.js +2 -1
  162. package/llm/variants.md +1261 -712
  163. package/package.json +464 -437
@@ -1,75 +1,75 @@
1
- <script lang="ts" generics="T extends keyof HTMLElementTagNameMap">
2
- import { HtmlAtom } from '../atom';
3
- import { ScrollableBond } from './bond.svelte';
4
- import type { ScrollableThumbProps } from './types';
5
-
6
- let {
7
- class: klass = '',
8
- children = undefined,
9
- orientation,
10
- onmount = undefined,
11
- ondestroy = undefined,
12
- animate = _animate,
13
- enter = undefined,
14
- exit = undefined,
15
- initial = undefined,
16
- ...restProps
17
- }: ScrollableThumbProps<T> = $props();
18
-
19
- const bond = ScrollableBond.get();
20
-
21
- if (!bond) {
22
- throw new Error('ScrollableThumb must be used within a ScrollableRoot');
23
- }
24
-
25
- const scrollX = $derived(bond.state.props.scrollX);
26
- const scrollY = $derived(bond.state.props.scrollY);
27
-
28
- const clientWidth = $derived(bond.state.props.clientWidth);
29
- const clientHeight = $derived(bond.state.props.clientHeight);
30
-
31
- const scrollWidth = $derived(bond.state.props.scrollWidth);
32
- const scrollHeight = $derived(bond.state.props.scrollHeight);
33
-
34
- const thumbX = $derived((scrollX / scrollWidth) * 100);
35
- const thumbY = $derived((scrollY / scrollHeight) * 100);
36
-
37
- const thumbWidth = $derived((clientWidth / scrollWidth) * 100);
38
- const thumbHeight = $derived((clientHeight / scrollHeight) * 100);
39
-
40
- const thumbProps = $derived(bond.thumb(orientation));
41
-
42
- function _animate(node: HTMLElement) {
43
- if (orientation === 'horizontal') {
44
- node.style.left = thumbX + '%';
45
- node.style.transform = `translateZ(1px)`;
46
- node.style.width = thumbWidth + '%';
47
- } else {
48
- node.style.top = thumbY + '%';
49
- node.style.transform = `translateZ(1px)`;
50
- node.style.height = thumbHeight + '%';
51
- }
52
- }
53
- </script>
54
-
55
- <HtmlAtom
56
- {bond}
57
- preset="scrollable.thumb"
58
- class={[
59
- 'scrollable-thumb border-border bg-foreground/10 hover:bg-foreground/20 absolute cursor-grab rounded-md active:cursor-grabbing',
60
- orientation === 'horizontal' ? 'scrollable-thumb-x' : 'scrollable-thumb-y',
61
- { horizontal: 'h-full', vertical: 'w-full' }[orientation],
62
- '$preset',
63
- klass
64
- ]}
65
- enter={enter?.bind(bond.state)}
66
- exit={exit?.bind(bond.state)}
67
- initial={initial?.bind(bond.state)}
68
- animate={animate?.bind(bond.state)}
69
- onmount={onmount?.bind(bond.state)}
70
- ondestroy={ondestroy?.bind(bond.state)}
71
- {...thumbProps}
72
- {...restProps}
73
- >
74
- {@render children?.()}
75
- </HtmlAtom>
1
+ <script lang="ts" generics="T extends keyof HTMLElementTagNameMap">
2
+ import { HtmlAtom } from '../atom';
3
+ import { ScrollableBond } from './bond.svelte';
4
+ import type { ScrollableThumbProps } from './types';
5
+
6
+ let {
7
+ class: klass = '',
8
+ children = undefined,
9
+ orientation,
10
+ onmount = undefined,
11
+ ondestroy = undefined,
12
+ animate = _animate,
13
+ enter = undefined,
14
+ exit = undefined,
15
+ initial = undefined,
16
+ ...restProps
17
+ }: ScrollableThumbProps<T> = $props();
18
+
19
+ const bond = ScrollableBond.get();
20
+
21
+ if (!bond) {
22
+ throw new Error('ScrollableThumb must be used within a ScrollableRoot');
23
+ }
24
+
25
+ const scrollX = $derived(bond.state.props.scrollX);
26
+ const scrollY = $derived(bond.state.props.scrollY);
27
+
28
+ const clientWidth = $derived(bond.state.props.clientWidth);
29
+ const clientHeight = $derived(bond.state.props.clientHeight);
30
+
31
+ const scrollWidth = $derived(bond.state.props.scrollWidth);
32
+ const scrollHeight = $derived(bond.state.props.scrollHeight);
33
+
34
+ const thumbX = $derived((scrollX / scrollWidth) * 100);
35
+ const thumbY = $derived((scrollY / scrollHeight) * 100);
36
+
37
+ const thumbWidth = $derived((clientWidth / scrollWidth) * 100);
38
+ const thumbHeight = $derived((clientHeight / scrollHeight) * 100);
39
+
40
+ const thumbProps = $derived(bond.thumb(orientation));
41
+
42
+ function _animate(node: HTMLElement) {
43
+ if (orientation === 'horizontal') {
44
+ node.style.left = thumbX + '%';
45
+ node.style.transform = `translateZ(1px)`;
46
+ node.style.width = thumbWidth + '%';
47
+ } else {
48
+ node.style.top = thumbY + '%';
49
+ node.style.transform = `translateZ(1px)`;
50
+ node.style.height = thumbHeight + '%';
51
+ }
52
+ }
53
+ </script>
54
+
55
+ <HtmlAtom
56
+ {bond}
57
+ preset="scrollable.thumb"
58
+ class={[
59
+ 'scrollable-thumb border-border bg-foreground/10 hover:bg-foreground/20 absolute cursor-grab rounded-md active:cursor-grabbing',
60
+ orientation === 'horizontal' ? 'scrollable-thumb-x' : 'scrollable-thumb-y',
61
+ { horizontal: 'h-full', vertical: 'w-full' }[orientation],
62
+ '$preset',
63
+ klass
64
+ ]}
65
+ enter={enter?.bind(bond.state)}
66
+ exit={exit?.bind(bond.state)}
67
+ initial={initial?.bind(bond.state)}
68
+ animate={animate?.bind(bond.state)}
69
+ onmount={onmount?.bind(bond.state)}
70
+ ondestroy={ondestroy?.bind(bond.state)}
71
+ {...thumbProps}
72
+ {...restProps}
73
+ >
74
+ {@render children?.()}
75
+ </HtmlAtom>
@@ -1,59 +1,59 @@
1
- <script lang="ts" generics="T extends keyof HTMLElementTagNameMap">
2
- import type { ScrollableTrackProps } from './types';
3
- import { ScrollableBond } from './bond.svelte';
4
- import { HtmlAtom } from '../atom';
5
-
6
- let {
7
- class: klass = '',
8
-
9
- orientation = undefined,
10
- children = undefined,
11
- onmount = undefined,
12
- ondestroy = undefined,
13
- animate = undefined,
14
- enter = undefined,
15
- exit = undefined,
16
- initial = undefined,
17
- ...restProps
18
- }: ScrollableTrackProps<T> = $props();
19
-
20
- const bond = ScrollableBond.get();
21
-
22
- if (!bond) {
23
- throw new Error('ScrollableTrack must be used within a ScrollableRoot');
24
- }
25
-
26
- const hasYScroll = $derived(bond.state.props.scrollHeight > bond.state.props.clientHeight);
27
- const hasXScroll = $derived(bond.state.props.scrollWidth > bond.state.props.clientWidth);
28
-
29
- const hasScroll = $derived(hasXScroll || hasYScroll);
30
-
31
- const isOpen = $derived(bond?.state?.props?.open ?? true);
32
-
33
- const isScrolling = $derived(bond?.state?.props?.isScrolling ?? false);
34
-
35
- const trackProps = $derived(bond.track(orientation));
36
- </script>
37
-
38
- {#if (isOpen || isScrolling) && hasScroll}
39
- <HtmlAtom
40
- {bond}
41
- preset="scrollable.track"
42
- class={[
43
- 'scrollable-track bg-foreground/10 hover:bg-foreground/15 border-border absolute z-10 rounded transition-opacity',
44
- { vertical: 'inset-y-0 right-0 w-2', horizontal: 'inset-x-0 bottom-0 h-2' }[orientation],
45
- '$preset',
46
- klass
47
- ]}
48
- enter={enter?.bind(bond.state)}
49
- exit={exit?.bind(bond.state)}
50
- initial={initial?.bind(bond.state)}
51
- animate={animate?.bind(bond.state)}
52
- onmount={onmount?.bind(bond.state)}
53
- ondestroy={ondestroy?.bind(bond.state)}
54
- {...trackProps}
55
- {...restProps}
56
- >
57
- {@render children?.()}
58
- </HtmlAtom>
59
- {/if}
1
+ <script lang="ts" generics="T extends keyof HTMLElementTagNameMap">
2
+ import type { ScrollableTrackProps } from './types';
3
+ import { ScrollableBond } from './bond.svelte';
4
+ import { HtmlAtom } from '../atom';
5
+
6
+ let {
7
+ class: klass = '',
8
+
9
+ orientation = undefined,
10
+ children = undefined,
11
+ onmount = undefined,
12
+ ondestroy = undefined,
13
+ animate = undefined,
14
+ enter = undefined,
15
+ exit = undefined,
16
+ initial = undefined,
17
+ ...restProps
18
+ }: ScrollableTrackProps<T> = $props();
19
+
20
+ const bond = ScrollableBond.get();
21
+
22
+ if (!bond) {
23
+ throw new Error('ScrollableTrack must be used within a ScrollableRoot');
24
+ }
25
+
26
+ const hasYScroll = $derived(bond.state.props.scrollHeight > bond.state.props.clientHeight);
27
+ const hasXScroll = $derived(bond.state.props.scrollWidth > bond.state.props.clientWidth);
28
+
29
+ const hasScroll = $derived(hasXScroll || hasYScroll);
30
+
31
+ const isOpen = $derived(bond?.state?.props?.open ?? true);
32
+
33
+ const isScrolling = $derived(bond?.state?.props?.isScrolling ?? false);
34
+
35
+ const trackProps = $derived(bond.track(orientation));
36
+ </script>
37
+
38
+ {#if (isOpen || isScrolling) && hasScroll}
39
+ <HtmlAtom
40
+ {bond}
41
+ preset="scrollable.track"
42
+ class={[
43
+ 'scrollable-track bg-foreground/10 hover:bg-foreground/15 border-border absolute z-10 rounded transition-opacity',
44
+ { vertical: 'inset-y-0 right-0 w-2', horizontal: 'inset-x-0 bottom-0 h-2' }[orientation],
45
+ '$preset',
46
+ klass
47
+ ]}
48
+ enter={enter?.bind(bond.state)}
49
+ exit={exit?.bind(bond.state)}
50
+ initial={initial?.bind(bond.state)}
51
+ animate={animate?.bind(bond.state)}
52
+ onmount={onmount?.bind(bond.state)}
53
+ ondestroy={ondestroy?.bind(bond.state)}
54
+ {...trackProps}
55
+ {...restProps}
56
+ >
57
+ {@render children?.()}
58
+ </HtmlAtom>
59
+ {/if}
@@ -4,7 +4,7 @@ type Scrollable = SvelteComponent<{
4
4
  }, {
5
5
  [evt: string]: CustomEvent<any>;
6
6
  }, {}> & {
7
- $$bindings?: string | undefined;
7
+ $$bindings?: string;
8
8
  };
9
9
  declare const Scrollable: $$__sveltets_2_IsomorphicComponent<{
10
10
  [x: string]: never;
@@ -1,52 +1,52 @@
1
- <script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
2
- import { HtmlAtom, type Base } from '../../atom';
3
- import type { TabBodyProps } from '../types';
4
- import { TabBond } from './bond.svelte';
5
-
6
- const bond = TabBond.get();
7
-
8
- if (!bond) {
9
- throw new Error('TabBody must be used within a Tab');
10
- }
11
-
12
- let {
13
- class: klass = '',
14
- children,
15
- onmount = undefined,
16
- ondestroy = undefined,
17
- animate = undefined,
18
- enter = undefined,
19
- exit = undefined,
20
- initial = undefined,
21
- ...restProps
22
- }: TabBodyProps<E, B> = $props();
23
-
24
- let mounted = $state(false);
25
-
26
- const bodyProps = $derived({
27
- ...bond?.body(),
28
- ...restProps
29
- });
30
-
31
- $effect(() => {
32
- mounted = true;
33
- });
34
- </script>
35
-
36
- <HtmlAtom
37
- preset="tab.body"
38
- class={[
39
- 'tab-body border-border pointer-events-auto flex h-auto w-full min-w-full flex-1 flex-col',
40
- '$preset',
41
- klass
42
- ]}
43
- onmount={onmount?.bind(bond.state)}
44
- ondestroy={ondestroy?.bind(bond.state)}
45
- enter={enter?.bind(bond.state)}
46
- exit={exit?.bind(bond.state)}
47
- initial={initial?.bind(bond.state)}
48
- animate={animate?.bind(bond.state)}
49
- {...bodyProps}
50
- >
51
- {@render children?.({ tab: bond })}
52
- </HtmlAtom>
1
+ <script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
2
+ import { HtmlAtom, type Base } from '../../atom';
3
+ import type { TabBodyProps } from '../types';
4
+ import { TabBond } from './bond.svelte';
5
+
6
+ const bond = TabBond.get();
7
+
8
+ if (!bond) {
9
+ throw new Error('TabBody must be used within a Tab');
10
+ }
11
+
12
+ let {
13
+ class: klass = '',
14
+ children,
15
+ onmount = undefined,
16
+ ondestroy = undefined,
17
+ animate = undefined,
18
+ enter = undefined,
19
+ exit = undefined,
20
+ initial = undefined,
21
+ ...restProps
22
+ }: TabBodyProps<E, B> = $props();
23
+
24
+ let mounted = $state(false);
25
+
26
+ const bodyProps = $derived({
27
+ ...bond?.body(),
28
+ ...restProps
29
+ });
30
+
31
+ $effect(() => {
32
+ mounted = true;
33
+ });
34
+ </script>
35
+
36
+ <HtmlAtom
37
+ preset="tab.body"
38
+ class={[
39
+ 'tab-body border-border pointer-events-auto flex h-auto w-full min-w-full flex-1 flex-col',
40
+ '$preset',
41
+ klass
42
+ ]}
43
+ onmount={onmount?.bind(bond.state)}
44
+ ondestroy={ondestroy?.bind(bond.state)}
45
+ enter={enter?.bind(bond.state)}
46
+ exit={exit?.bind(bond.state)}
47
+ initial={initial?.bind(bond.state)}
48
+ animate={animate?.bind(bond.state)}
49
+ {...bodyProps}
50
+ >
51
+ {@render children?.({ tab: bond })}
52
+ </HtmlAtom>
@@ -1,41 +1,41 @@
1
- <script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'p', B extends Base = Base">
2
- import type { TabDescriptionProps } from '../types';
3
- import { HtmlAtom, type Base } from '../../atom';
4
- import { TabBond } from './bond.svelte';
5
-
6
- const bond = TabBond.get();
7
-
8
- let {
9
- class: klass = '',
10
- as = 'p' as E,
11
- children,
12
- onmount = undefined,
13
- ondestroy = undefined,
14
- animate = undefined,
15
- enter = undefined,
16
- exit = undefined,
17
- initial = undefined,
18
- ...restProps
19
- }: TabDescriptionProps<E, B> = $props();
20
-
21
- const descriptionProps = $derived({
22
- ...bond?.description(),
23
- ...restProps
24
- });
25
- </script>
26
-
27
- <HtmlAtom
28
- {bond}
29
- preset="tab.description"
30
- class={['border-border', '$preset', klass]}
31
- onmount={onmount?.bind(bond.state)}
32
- ondestroy={ondestroy?.bind(bond.state)}
33
- enter={enter?.bind(bond.state)}
34
- exit={exit?.bind(bond.state)}
35
- initial={initial?.bind(bond.state)}
36
- animate={animate?.bind(bond.state)}
37
- {as}
38
- {...descriptionProps}
39
- >
40
- {@render children?.({ tab: bond })}
41
- </HtmlAtom>
1
+ <script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'p', B extends Base = Base">
2
+ import type { TabDescriptionProps } from '../types';
3
+ import { HtmlAtom, type Base } from '../../atom';
4
+ import { TabBond } from './bond.svelte';
5
+
6
+ const bond = TabBond.get();
7
+
8
+ let {
9
+ class: klass = '',
10
+ as = 'p' as E,
11
+ children,
12
+ onmount = undefined,
13
+ ondestroy = undefined,
14
+ animate = undefined,
15
+ enter = undefined,
16
+ exit = undefined,
17
+ initial = undefined,
18
+ ...restProps
19
+ }: TabDescriptionProps<E, B> = $props();
20
+
21
+ const descriptionProps = $derived({
22
+ ...bond?.description(),
23
+ ...restProps
24
+ });
25
+ </script>
26
+
27
+ <HtmlAtom
28
+ {bond}
29
+ preset="tab.description"
30
+ class={['border-border', '$preset', klass]}
31
+ onmount={onmount?.bind(bond.state)}
32
+ ondestroy={ondestroy?.bind(bond.state)}
33
+ enter={enter?.bind(bond.state)}
34
+ exit={exit?.bind(bond.state)}
35
+ initial={initial?.bind(bond.state)}
36
+ animate={animate?.bind(bond.state)}
37
+ {as}
38
+ {...descriptionProps}
39
+ >
40
+ {@render children?.({ tab: bond })}
41
+ </HtmlAtom>
@@ -1,71 +1,71 @@
1
- <script
2
- lang="ts"
3
- generics="E extends keyof HTMLElementTagNameMap = 'button', B extends Base = Base"
4
- >
5
- import type { TabHeaderProps } from '../types';
6
- import { TabBond } from './bond.svelte';
7
- import { HtmlAtom, type Base } from '../../atom';
8
-
9
- const bond = TabBond.get();
10
-
11
- const isActive = $derived(bond?.state.isActive);
12
- const isDisabled = $derived(bond?.state.props.disabled);
13
-
14
- let {
15
- class: klass = '',
16
- as = 'button' as E,
17
- children,
18
- onpointerdown,
19
- onmount = undefined,
20
- ondestroy = undefined,
21
- animate = undefined,
22
- enter = undefined,
23
- exit = undefined,
24
- initial = undefined,
25
- ...restProps
26
- }: TabHeaderProps = $props();
27
-
28
- const headerProps = $derived({
29
- ...bond?.header(),
30
- ...restProps
31
- });
32
-
33
- function handlePointerDown(ev: PointerEvent) {
34
- if (isDisabled) return;
35
-
36
- onpointerdown?.(ev, { tab: bond });
37
-
38
- if (ev.defaultPrevented) {
39
- return;
40
- }
41
-
42
- bond?.state.select();
43
- }
44
- </script>
45
-
46
- <HtmlAtom
47
- {bond}
48
- preset="tab.header"
49
- as="button"
50
- class={[
51
- 'border-border text-foreground/60 hover:text-foreground/80 active:text-foreground/100 bg-foreground/0 hover:bg-foreground/5 active:bg-foreground/10 flex cursor-pointer items-center px-2 py-2 text-sm font-medium transition-colors duration-100',
52
- isActive && 'text-primary bg-accent/10 hover:bg-accent/15 active:bg-accent/20',
53
- isDisabled && 'opacity-50',
54
- '$preset',
55
- klass
56
- ]}
57
- onmount={onmount?.bind(bond.state)}
58
- ondestroy={ondestroy?.bind(bond.state)}
59
- enter={enter?.bind(bond.state)}
60
- exit={exit?.bind(bond.state)}
61
- initial={initial?.bind(bond.state)}
62
- animate={animate?.bind(bond.state)}
63
- type="button"
64
- disabled={isDisabled}
65
- onpointerdown={handlePointerDown}
66
- {...headerProps}
67
- >
68
- {@render children?.({
69
- tab: bond
70
- })}
71
- </HtmlAtom>
1
+ <script
2
+ lang="ts"
3
+ generics="E extends keyof HTMLElementTagNameMap = 'button', B extends Base = Base"
4
+ >
5
+ import type { TabHeaderProps } from '../types';
6
+ import { TabBond } from './bond.svelte';
7
+ import { HtmlAtom, type Base } from '../../atom';
8
+
9
+ const bond = TabBond.get();
10
+
11
+ const isActive = $derived(bond?.state.isActive);
12
+ const isDisabled = $derived(bond?.state.props.disabled);
13
+
14
+ let {
15
+ class: klass = '',
16
+ as = 'button' as E,
17
+ children,
18
+ onpointerdown,
19
+ onmount = undefined,
20
+ ondestroy = undefined,
21
+ animate = undefined,
22
+ enter = undefined,
23
+ exit = undefined,
24
+ initial = undefined,
25
+ ...restProps
26
+ }: TabHeaderProps = $props();
27
+
28
+ const headerProps = $derived({
29
+ ...bond?.header(),
30
+ ...restProps
31
+ });
32
+
33
+ function handlePointerDown(ev: PointerEvent) {
34
+ if (isDisabled) return;
35
+
36
+ onpointerdown?.(ev, { tab: bond });
37
+
38
+ if (ev.defaultPrevented) {
39
+ return;
40
+ }
41
+
42
+ bond?.state.select();
43
+ }
44
+ </script>
45
+
46
+ <HtmlAtom
47
+ {bond}
48
+ preset="tab.header"
49
+ as="button"
50
+ class={[
51
+ 'border-border text-foreground/60 hover:text-foreground/80 active:text-foreground/100 bg-foreground/0 hover:bg-foreground/5 active:bg-foreground/10 flex cursor-pointer items-center px-2 py-2 text-sm font-medium transition-colors duration-100',
52
+ isActive && 'text-primary bg-accent/10 hover:bg-accent/15 active:bg-accent/20',
53
+ isDisabled && 'opacity-50',
54
+ '$preset',
55
+ klass
56
+ ]}
57
+ onmount={onmount?.bind(bond.state)}
58
+ ondestroy={ondestroy?.bind(bond.state)}
59
+ enter={enter?.bind(bond.state)}
60
+ exit={exit?.bind(bond.state)}
61
+ initial={initial?.bind(bond.state)}
62
+ animate={animate?.bind(bond.state)}
63
+ type="button"
64
+ disabled={isDisabled}
65
+ onpointerdown={handlePointerDown}
66
+ {...headerProps}
67
+ >
68
+ {@render children?.({
69
+ tab: bond
70
+ })}
71
+ </HtmlAtom>