@svelte-atoms/core 1.0.0-alpha.29 → 1.0.0-alpha.30
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.md +852 -852
- package/dist/attachments/clickout.svelte.d.ts +1 -1
- package/dist/attachments/clickout.svelte.js +2 -2
- package/dist/components/accordion/accordion-root.svelte +61 -61
- package/dist/components/accordion/accordion-root.svelte.d.ts +1 -1
- package/dist/components/accordion/accordion.stories.svelte +145 -134
- package/dist/components/alert/alert.stories.svelte +400 -401
- package/dist/components/atom/html-atom.svelte +71 -17
- package/dist/components/avatar/avatar.stories.svelte +22 -27
- package/dist/components/badge/badge.stories.svelte +12 -17
- package/dist/components/badge/badge.svelte +19 -19
- package/dist/components/breadcrumb/breadcrumb.stories.svelte +16 -21
- package/dist/components/button/button.stories.svelte +27 -60
- package/dist/components/calendar/calendar-day.svelte +96 -96
- package/dist/components/calendar/calendar-header.svelte +29 -29
- package/dist/components/calendar/calendar-root.svelte +206 -206
- package/dist/components/calendar/calendar.stories.svelte +10 -15
- package/dist/components/card/card-body.svelte +39 -39
- package/dist/components/card/card-footer.svelte +41 -41
- package/dist/components/card/card-root.svelte +91 -91
- package/dist/components/card/card.stories.svelte +133 -145
- package/dist/components/checkbox/checkbox.stories.svelte +22 -27
- package/dist/components/checkbox/checkbox.svelte +155 -157
- package/dist/components/collapsible/collapsible.stories.svelte +172 -173
- package/dist/components/combobox/combobox-root.svelte +65 -65
- package/dist/components/combobox/compobox.stories.svelte +51 -54
- package/dist/components/container/container.stories.svelte +20 -23
- package/dist/components/datagrid/datagrid-root.svelte +59 -59
- package/dist/components/datagrid/datagrid.css +5 -5
- package/dist/components/datagrid/datagrid.stories.svelte +72 -75
- package/dist/components/date-picker/date-picker-calendar.svelte +67 -67
- package/dist/components/date-picker/date-picker-header.svelte +100 -100
- package/dist/components/date-picker/date-picker-months.svelte +142 -142
- package/dist/components/date-picker/date-picker-root.svelte +1 -1
- package/dist/components/date-picker/date-picker-years.svelte +205 -205
- package/dist/components/date-picker/date-picker.stories.svelte +11 -18
- package/dist/components/dialog/dialog-content.svelte +62 -62
- package/dist/components/dialog/dialog.stories.svelte +64 -67
- package/dist/components/drawer/attachments.svelte.js +8 -9
- package/dist/components/drawer/drawer-content.svelte +57 -42
- package/dist/components/drawer/drawer.stories.svelte +212 -224
- package/dist/components/dropdown/dropdown-root.svelte +59 -59
- package/dist/components/dropdown/dropdown.stories.svelte +80 -83
- package/dist/components/form/form.stories.svelte +96 -99
- package/dist/components/image/image.stories.svelte +20 -23
- package/dist/components/input/input.stories.svelte +35 -38
- package/dist/components/label/label.stories.svelte +15 -26
- package/dist/components/label/label.stories.svelte.d.ts +24 -4
- package/dist/components/lazy/lazy.stories.svelte +9 -16
- package/dist/components/lazy/lazy.svelte +28 -28
- package/dist/components/link/link.stories.svelte +15 -26
- package/dist/components/link/link.stories.svelte.d.ts +24 -4
- package/dist/components/menu/menu-list.svelte +40 -40
- package/dist/components/menu/menu.stories.svelte +33 -36
- package/dist/components/popover/bond.svelte.js +31 -25
- package/dist/components/popover/popover-arrow.svelte +111 -111
- package/dist/components/popover/popover-content.svelte +175 -178
- package/dist/components/popover/popover-indicator.svelte +44 -43
- package/dist/components/popover/popover-root.svelte +48 -48
- package/dist/components/popover/popover.stories.svelte +49 -52
- package/dist/components/qr-code/qr-code.stories.svelte +4 -13
- package/dist/components/qr-code/qr-code.svelte +75 -75
- package/dist/components/radio/radio-group.stories.svelte +41 -50
- package/dist/components/radio/radio.stories.svelte +17 -26
- package/dist/components/radio/radio.svelte +109 -109
- package/dist/components/root/root.svelte +121 -121
- package/dist/components/root/root.svelte.d.ts +1 -1
- package/dist/components/scrollable/scrollable.stories.svelte +116 -126
- package/dist/components/sidebar/sidebar-content.svelte +13 -2
- package/dist/components/sidebar/sidebar-root.svelte +10 -12
- package/dist/components/sidebar/sidebar.stories.svelte +8 -19
- package/dist/components/sidebar/types.d.ts +1 -0
- package/dist/components/tabs/tab/bond.svelte.d.ts +4 -1
- package/dist/components/tabs/tab/bond.svelte.js +4 -1
- package/dist/components/tabs/tabs.stories.svelte +56 -59
- package/dist/components/tooltip/tooltip-trigger.svelte +39 -37
- package/dist/components/tooltip/tooltip.stories.svelte +32 -35
- package/dist/components/tree/tree.stories.svelte +142 -134
- package/dist/context/preset.svelte.d.ts +3 -3
- package/dist/utils/function.d.ts +2 -0
- package/dist/utils/function.js +6 -0
- package/package.json +6 -9
- package/dist/actions/animation.svelte.d.ts +0 -6
- package/dist/actions/animation.svelte.js +0 -14
- package/dist/actions/clickout.svelte.d.ts +0 -2
- package/dist/actions/clickout.svelte.js +0 -15
- package/dist/actions/popover.svelte.d.ts +0 -19
- package/dist/actions/popover.svelte.js +0 -81
- package/dist/actions/portal.svelte.d.ts +0 -8
- package/dist/actions/portal.svelte.js +0 -32
- package/dist/attachments/gsap.svelte.d.ts +0 -2
- package/dist/attachments/gsap.svelte.js +0 -26
|
@@ -1,157 +1,155 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { circOut } from 'svelte/easing';
|
|
3
|
-
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
4
|
-
import { scale } from 'svelte/transition';
|
|
5
|
-
import { Icon } from '../icon';
|
|
6
|
-
import { HtmlAtom } from '../atom';
|
|
7
|
-
import CheckmarkRegularIcon from '../../icons/icon-checkmark.svelte';
|
|
8
|
-
import { DURATION } from '../../shared';
|
|
9
|
-
import type { CheckboxProps } from './types';
|
|
10
|
-
import './checkbox.css';
|
|
11
|
-
|
|
12
|
-
let {
|
|
13
|
-
class: klass = '',
|
|
14
|
-
checked = $bindable(false),
|
|
15
|
-
indeterminate = $bindable(false),
|
|
16
|
-
value = $bindable(undefined),
|
|
17
|
-
group = $bindable([]),
|
|
18
|
-
id,
|
|
19
|
-
name,
|
|
20
|
-
checkedContent,
|
|
21
|
-
indeterminateContent,
|
|
22
|
-
enter,
|
|
23
|
-
exit,
|
|
24
|
-
initial,
|
|
25
|
-
onchange,
|
|
26
|
-
oninput,
|
|
27
|
-
onblur,
|
|
28
|
-
onfocus,
|
|
29
|
-
onclick = undefined,
|
|
30
|
-
...restProps
|
|
31
|
-
}: CheckboxProps & Exclude<HTMLInputAttributes, 'type'> = $props();
|
|
32
|
-
|
|
33
|
-
let checkboxElement: HTMLInputElement | undefined = $state();
|
|
34
|
-
|
|
35
|
-
// Computed state for visual representation
|
|
36
|
-
const isChecked = $derived(checked === true);
|
|
37
|
-
const isIndeterminate = $derived(indeterminate === true);
|
|
38
|
-
const showCheckmark = $derived(isChecked && !isIndeterminate);
|
|
39
|
-
|
|
40
|
-
function handleChange(ev: Event) {
|
|
41
|
-
onchange?.(ev, {
|
|
42
|
-
checked: checked,
|
|
43
|
-
value: checked,
|
|
44
|
-
type: 'boolean'
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function handleInput(ev: Event) {
|
|
49
|
-
oninput?.(ev, {
|
|
50
|
-
checked: checked,
|
|
51
|
-
value: checked,
|
|
52
|
-
type: 'boolean'
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function handleClick(ev: MouseEvent) {
|
|
57
|
-
onclick?.(ev);
|
|
58
|
-
|
|
59
|
-
if (ev.defaultPrevented) {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Handle indeterminate → checked → unchecked cycle
|
|
64
|
-
if (indeterminate) {
|
|
65
|
-
// Indeterminate → checked
|
|
66
|
-
indeterminate = false;
|
|
67
|
-
checked = true;
|
|
68
|
-
} else {
|
|
69
|
-
// Toggle checked state
|
|
70
|
-
checked = !checked;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// Trigger input event manually if needed
|
|
74
|
-
handleInput(ev);
|
|
75
|
-
}
|
|
76
|
-
</script>
|
|
77
|
-
|
|
78
|
-
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
79
|
-
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
80
|
-
<HtmlAtom
|
|
81
|
-
preset="checkbox"
|
|
82
|
-
as="div"
|
|
83
|
-
class={[
|
|
84
|
-
'checkbox-root border-border outline-primary bg-input text-foreground aspect-square h-5 w-fit cursor-pointer rounded-sm border outline-0 outline-offset-2 transition-colors duration-100',
|
|
85
|
-
isChecked && 'bg-foreground',
|
|
86
|
-
'$preset',
|
|
87
|
-
klass,
|
|
88
|
-
'relative'
|
|
89
|
-
]}
|
|
90
|
-
role="checkbox"
|
|
91
|
-
aria-checked={isIndeterminate ? 'mixed' : isChecked}
|
|
92
|
-
{enter}
|
|
93
|
-
{exit}
|
|
94
|
-
{initial}
|
|
95
|
-
onclick={handleClick}
|
|
96
|
-
{...restProps}
|
|
97
|
-
>
|
|
98
|
-
<input
|
|
99
|
-
bind:this={checkboxElement}
|
|
100
|
-
bind:checked
|
|
101
|
-
bind:group
|
|
102
|
-
bind:indeterminate
|
|
103
|
-
type="checkbox"
|
|
104
|
-
class="checkbox-input pointer-events-none"
|
|
105
|
-
{value}
|
|
106
|
-
{id}
|
|
107
|
-
{name}
|
|
108
|
-
onchange={handleChange}
|
|
109
|
-
oninput={handleInput}
|
|
110
|
-
{onblur}
|
|
111
|
-
{onfocus}
|
|
112
|
-
hidden
|
|
113
|
-
tabindex="-1"
|
|
114
|
-
/>
|
|
115
|
-
|
|
116
|
-
{#if isIndeterminate}
|
|
117
|
-
{#if indeterminateContent}
|
|
118
|
-
<HtmlAtom
|
|
119
|
-
preset="checkbox.indeterminate"
|
|
120
|
-
class={[
|
|
121
|
-
'checkbox-indeterminate pointer-events-none flex size-full items-center justify-center
|
|
122
|
-
]}
|
|
123
|
-
base={indeterminateContent}
|
|
124
|
-
/>
|
|
125
|
-
{:else}
|
|
126
|
-
<HtmlAtom
|
|
127
|
-
preset="checkbox.indeterminate"
|
|
128
|
-
class={[
|
|
129
|
-
'checkbox-indeterminate
|
|
130
|
-
]}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
{
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
>
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
{/if}
|
|
157
|
-
</HtmlAtom>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { circOut } from 'svelte/easing';
|
|
3
|
+
import type { HTMLInputAttributes } from 'svelte/elements';
|
|
4
|
+
import { scale } from 'svelte/transition';
|
|
5
|
+
import { Icon } from '../icon';
|
|
6
|
+
import { HtmlAtom } from '../atom';
|
|
7
|
+
import CheckmarkRegularIcon from '../../icons/icon-checkmark.svelte';
|
|
8
|
+
import { DURATION } from '../../shared';
|
|
9
|
+
import type { CheckboxProps } from './types';
|
|
10
|
+
import './checkbox.css';
|
|
11
|
+
|
|
12
|
+
let {
|
|
13
|
+
class: klass = '',
|
|
14
|
+
checked = $bindable(false),
|
|
15
|
+
indeterminate = $bindable(false),
|
|
16
|
+
value = $bindable(undefined),
|
|
17
|
+
group = $bindable([]),
|
|
18
|
+
id,
|
|
19
|
+
name,
|
|
20
|
+
checkedContent,
|
|
21
|
+
indeterminateContent,
|
|
22
|
+
enter,
|
|
23
|
+
exit,
|
|
24
|
+
initial,
|
|
25
|
+
onchange,
|
|
26
|
+
oninput,
|
|
27
|
+
onblur,
|
|
28
|
+
onfocus,
|
|
29
|
+
onclick = undefined,
|
|
30
|
+
...restProps
|
|
31
|
+
}: CheckboxProps & Exclude<HTMLInputAttributes, 'type'> = $props();
|
|
32
|
+
|
|
33
|
+
let checkboxElement: HTMLInputElement | undefined = $state();
|
|
34
|
+
|
|
35
|
+
// Computed state for visual representation
|
|
36
|
+
const isChecked = $derived(checked === true);
|
|
37
|
+
const isIndeterminate = $derived(indeterminate === true);
|
|
38
|
+
const showCheckmark = $derived(isChecked && !isIndeterminate);
|
|
39
|
+
|
|
40
|
+
function handleChange(ev: Event) {
|
|
41
|
+
onchange?.(ev, {
|
|
42
|
+
checked: checked,
|
|
43
|
+
value: checked,
|
|
44
|
+
type: 'boolean'
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function handleInput(ev: Event) {
|
|
49
|
+
oninput?.(ev, {
|
|
50
|
+
checked: checked,
|
|
51
|
+
value: checked,
|
|
52
|
+
type: 'boolean'
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function handleClick(ev: MouseEvent) {
|
|
57
|
+
onclick?.(ev);
|
|
58
|
+
|
|
59
|
+
if (ev.defaultPrevented) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Handle indeterminate → checked → unchecked cycle
|
|
64
|
+
if (indeterminate) {
|
|
65
|
+
// Indeterminate → checked
|
|
66
|
+
indeterminate = false;
|
|
67
|
+
checked = true;
|
|
68
|
+
} else {
|
|
69
|
+
// Toggle checked state
|
|
70
|
+
checked = !checked;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Trigger input event manually if needed
|
|
74
|
+
handleInput(ev);
|
|
75
|
+
}
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<!-- svelte-ignore a11y_click_events_have_key_events -->
|
|
79
|
+
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
80
|
+
<HtmlAtom
|
|
81
|
+
preset="checkbox"
|
|
82
|
+
as="div"
|
|
83
|
+
class={[
|
|
84
|
+
'checkbox-root border-border outline-primary bg-input text-foreground aspect-square h-5 w-fit cursor-pointer rounded-sm border outline-0 outline-offset-2 transition-colors duration-100',
|
|
85
|
+
isChecked && 'bg-foreground',
|
|
86
|
+
'$preset',
|
|
87
|
+
klass,
|
|
88
|
+
'relative'
|
|
89
|
+
]}
|
|
90
|
+
role="checkbox"
|
|
91
|
+
aria-checked={isIndeterminate ? 'mixed' : isChecked}
|
|
92
|
+
{enter}
|
|
93
|
+
{exit}
|
|
94
|
+
{initial}
|
|
95
|
+
onclick={handleClick}
|
|
96
|
+
{...restProps}
|
|
97
|
+
>
|
|
98
|
+
<input
|
|
99
|
+
bind:this={checkboxElement}
|
|
100
|
+
bind:checked
|
|
101
|
+
bind:group
|
|
102
|
+
bind:indeterminate
|
|
103
|
+
type="checkbox"
|
|
104
|
+
class="checkbox-input pointer-events-none"
|
|
105
|
+
{value}
|
|
106
|
+
{id}
|
|
107
|
+
{name}
|
|
108
|
+
onchange={handleChange}
|
|
109
|
+
oninput={handleInput}
|
|
110
|
+
{onblur}
|
|
111
|
+
{onfocus}
|
|
112
|
+
hidden
|
|
113
|
+
tabindex="-1"
|
|
114
|
+
/>
|
|
115
|
+
|
|
116
|
+
{#if isIndeterminate}
|
|
117
|
+
{#if indeterminateContent}
|
|
118
|
+
<HtmlAtom
|
|
119
|
+
preset="checkbox.indeterminate"
|
|
120
|
+
class={[
|
|
121
|
+
'checkbox-indeterminate pointer-events-none flex size-full scale-50 items-center justify-center rounded-[inherit] bg-current'
|
|
122
|
+
]}
|
|
123
|
+
base={indeterminateContent}
|
|
124
|
+
/>
|
|
125
|
+
{:else}
|
|
126
|
+
<HtmlAtom
|
|
127
|
+
preset="checkbox.indeterminate"
|
|
128
|
+
class={[
|
|
129
|
+
'checkbox-indeterminate pointer-events-none flex size-full scale-50 items-center justify-center rounded-[inherit] bg-current'
|
|
130
|
+
]}
|
|
131
|
+
/>
|
|
132
|
+
{/if}
|
|
133
|
+
{:else if showCheckmark}
|
|
134
|
+
{#if checkedContent}
|
|
135
|
+
<HtmlAtom
|
|
136
|
+
preset="checkbox.checkmark"
|
|
137
|
+
class={[
|
|
138
|
+
'checkbox-indicator text-accent pointer-events-none flex h-full content-center items-center justify-center overflow-hidden p-0.5'
|
|
139
|
+
]}
|
|
140
|
+
base={checkedContent}
|
|
141
|
+
/>
|
|
142
|
+
{:else}
|
|
143
|
+
<HtmlAtom
|
|
144
|
+
preset="checkbox.checkmark"
|
|
145
|
+
class={[
|
|
146
|
+
'checkbox-indicator text-accent pointer-events-none flex h-full content-center items-center justify-center overflow-hidden p-0.5'
|
|
147
|
+
]}
|
|
148
|
+
enter={(node) => scale(node, { duration: DURATION.fast, easing: circOut, start: 0.6 })}
|
|
149
|
+
exit={(node) => scale(node, { duration: DURATION.fast, easing: circOut, start: 0.6 })}
|
|
150
|
+
>
|
|
151
|
+
<Icon class="h-full p-0" src={CheckmarkRegularIcon} />
|
|
152
|
+
</HtmlAtom>
|
|
153
|
+
{/if}
|
|
154
|
+
{/if}
|
|
155
|
+
</HtmlAtom>
|
|
@@ -1,173 +1,172 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { Collapsible as ACollapsible } from '.';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { Collapsible as ACollapsible } from '.';
|
|
4
|
+
|
|
5
|
+
import { animate as motion } from 'motion';
|
|
6
|
+
|
|
7
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
|
+
const { Story } = defineMeta({
|
|
9
|
+
title: 'Atoms/Collapsible',
|
|
10
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
11
|
+
|
|
12
|
+
parameters: {
|
|
13
|
+
// More on how to position stories at: https://storybook.js.org/docs/configure/story-layout
|
|
14
|
+
layout: 'fullscreen'
|
|
15
|
+
},
|
|
16
|
+
args: {}
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<script lang="ts">
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<Story name="Collapsible" args={{}}>
|
|
24
|
+
<div class="flex w-full flex-col gap-2">
|
|
25
|
+
<ACollapsible.Root>
|
|
26
|
+
{#snippet children({ collapsible })}
|
|
27
|
+
{@const isOpen = collapsible.state.props.open}
|
|
28
|
+
|
|
29
|
+
<ACollapsible.Header class="">
|
|
30
|
+
<div>Hello Atoms UI 1</div>
|
|
31
|
+
<ACollapsible.Indicator />
|
|
32
|
+
</ACollapsible.Header>
|
|
33
|
+
|
|
34
|
+
<ACollapsible.Body
|
|
35
|
+
class={['pointer-events-none h-0 opacity-0', isOpen && 'pointer-events-auto']}
|
|
36
|
+
enter={(node) => {
|
|
37
|
+
motion(
|
|
38
|
+
node,
|
|
39
|
+
{
|
|
40
|
+
opacity: +isOpen,
|
|
41
|
+
height: isOpen ? 'auto' : 0
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
duration: 0.2,
|
|
45
|
+
ease: 'linear'
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
return { duration: 0.2 };
|
|
49
|
+
}}
|
|
50
|
+
exit={(node) => {
|
|
51
|
+
motion(node, { opacity: 0, height: 0 }, { duration: 0.2, ease: 'linear' });
|
|
52
|
+
return { duration: 0.2 };
|
|
53
|
+
}}
|
|
54
|
+
animate={(node) => {
|
|
55
|
+
motion(
|
|
56
|
+
node,
|
|
57
|
+
{
|
|
58
|
+
opacity: +isOpen,
|
|
59
|
+
height: isOpen ? 'auto' : 0
|
|
60
|
+
},
|
|
61
|
+
{ duration: 0.2, ease: 'linear' }
|
|
62
|
+
);
|
|
63
|
+
}}
|
|
64
|
+
>
|
|
65
|
+
<div class="py-2">
|
|
66
|
+
Mauris et habitasse cubilia potenti at condimentum iaculis nam. Ante fusce litora
|
|
67
|
+
tristique letius libero. Curabitur vitae cursus consectetur feugiat aenean viverra vel
|
|
68
|
+
dolor diam nascetur.
|
|
69
|
+
</div>
|
|
70
|
+
</ACollapsible.Body>
|
|
71
|
+
{/snippet}
|
|
72
|
+
</ACollapsible.Root>
|
|
73
|
+
|
|
74
|
+
<ACollapsible.Root>
|
|
75
|
+
{#snippet children({ collapsible })}
|
|
76
|
+
{@const isOpen = collapsible.state.isOpen}
|
|
77
|
+
|
|
78
|
+
<ACollapsible.Header class="">
|
|
79
|
+
<div>Hello Atoms UI 2</div>
|
|
80
|
+
<ACollapsible.Indicator />
|
|
81
|
+
</ACollapsible.Header>
|
|
82
|
+
|
|
83
|
+
<ACollapsible.Body
|
|
84
|
+
class={['pointer-events-none h-0 opacity-0', isOpen && 'pointer-events-auto']}
|
|
85
|
+
enter={(node) => {
|
|
86
|
+
motion(
|
|
87
|
+
node,
|
|
88
|
+
{
|
|
89
|
+
opacity: +isOpen,
|
|
90
|
+
height: isOpen ? 'auto' : 0
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
duration: 0.2,
|
|
94
|
+
ease: 'linear'
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
return { duration: 0.2 };
|
|
98
|
+
}}
|
|
99
|
+
exit={(node) => {
|
|
100
|
+
motion(node, { opacity: 0, height: 0 }, { duration: 0.2, ease: 'linear' });
|
|
101
|
+
return { duration: 0.2 };
|
|
102
|
+
}}
|
|
103
|
+
animate={(node) => {
|
|
104
|
+
motion(
|
|
105
|
+
node,
|
|
106
|
+
{
|
|
107
|
+
opacity: +isOpen,
|
|
108
|
+
height: isOpen ? 'auto' : 0
|
|
109
|
+
},
|
|
110
|
+
{ duration: 0.1, ease: 'linear' }
|
|
111
|
+
);
|
|
112
|
+
}}
|
|
113
|
+
>
|
|
114
|
+
<div class="py-2">
|
|
115
|
+
Mauris et habitasse cubilia potenti at condimentum iaculis nam. Ante fusce litora
|
|
116
|
+
tristique letius libero. Curabitur vitae cursus consectetur feugiat aenean viverra vel
|
|
117
|
+
dolor diam nascetur.
|
|
118
|
+
</div>
|
|
119
|
+
</ACollapsible.Body>
|
|
120
|
+
{/snippet}
|
|
121
|
+
</ACollapsible.Root>
|
|
122
|
+
|
|
123
|
+
<ACollapsible.Root>
|
|
124
|
+
{#snippet children({ collapsible })}
|
|
125
|
+
{@const isOpen = collapsible.state.isOpen}
|
|
126
|
+
|
|
127
|
+
<ACollapsible.Header class="">
|
|
128
|
+
<div>Hello Atoms UI 3</div>
|
|
129
|
+
<ACollapsible.Indicator />
|
|
130
|
+
</ACollapsible.Header>
|
|
131
|
+
|
|
132
|
+
<ACollapsible.Body
|
|
133
|
+
class={['pointer-events-none h-0 opacity-0', isOpen && 'pointer-events-auto']}
|
|
134
|
+
enter={(node) => {
|
|
135
|
+
motion(
|
|
136
|
+
node,
|
|
137
|
+
{
|
|
138
|
+
opacity: +isOpen,
|
|
139
|
+
height: isOpen ? 'auto' : 0
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
duration: 0.2,
|
|
143
|
+
ease: 'linear'
|
|
144
|
+
}
|
|
145
|
+
);
|
|
146
|
+
return { duration: 0.2 };
|
|
147
|
+
}}
|
|
148
|
+
exit={(node) => {
|
|
149
|
+
motion(node, { opacity: 0, height: 0 }, { duration: 0.2, ease: 'linear' });
|
|
150
|
+
return { duration: 0.2 };
|
|
151
|
+
}}
|
|
152
|
+
animate={(node) => {
|
|
153
|
+
motion(
|
|
154
|
+
node,
|
|
155
|
+
{
|
|
156
|
+
opacity: +isOpen,
|
|
157
|
+
height: isOpen ? 'auto' : 0
|
|
158
|
+
},
|
|
159
|
+
{ duration: 0.1, ease: 'linear' }
|
|
160
|
+
);
|
|
161
|
+
}}
|
|
162
|
+
>
|
|
163
|
+
<div class="py-2">
|
|
164
|
+
Mauris et habitasse cubilia potenti at condimentum iaculis nam. Ante fusce litora
|
|
165
|
+
tristique letius libero. Curabitur vitae cursus consectetur feugiat aenean viverra vel
|
|
166
|
+
dolor diam nascetur.
|
|
167
|
+
</div>
|
|
168
|
+
</ACollapsible.Body>
|
|
169
|
+
{/snippet}
|
|
170
|
+
</ACollapsible.Root>
|
|
171
|
+
</div>
|
|
172
|
+
</Story>
|