@svelte-atoms/core 1.0.0-alpha.28 → 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 -856
- 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-actions.svelte +43 -43
- package/dist/components/alert/alert-close-button.svelte +70 -70
- package/dist/components/alert/alert-content.svelte +43 -43
- package/dist/components/alert/alert-description.svelte +42 -42
- package/dist/components/alert/alert-icon.svelte +47 -47
- package/dist/components/alert/alert-root.svelte +103 -103
- package/dist/components/alert/alert-title.svelte +42 -42
- package/dist/components/alert/alert.stories.svelte +10 -11
- package/dist/components/atom/html-atom.svelte +75 -19
- package/dist/components/atom/html-atom.svelte.d.ts +1 -1
- package/dist/components/atom/snippet-renderer.svelte +5 -5
- 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 +1 -34
- package/dist/components/calendar/calendar-body.svelte +107 -107
- package/dist/components/calendar/calendar-day.svelte +96 -97
- package/dist/components/calendar/calendar-header.svelte +29 -33
- package/dist/components/calendar/calendar-header.svelte.d.ts +0 -1
- package/dist/components/calendar/calendar-root.svelte +206 -208
- package/dist/components/calendar/calendar-week-day.svelte +34 -34
- package/dist/components/calendar/calendar.css +26 -26
- package/dist/components/calendar/calendar.stories.svelte +10 -20
- package/dist/components/calendar/calendar.stories.svelte.d.ts +24 -4
- 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 +2 -2
- package/dist/components/datagrid/datagrid.css +0 -42
- package/dist/components/datagrid/datagrid.stories.svelte +72 -75
- package/dist/components/datagrid/types.d.ts +1 -1
- package/dist/components/date-picker/atoms.d.ts +0 -4
- package/dist/components/date-picker/atoms.js +0 -4
- package/dist/components/date-picker/date-picker-calendar.svelte +67 -42
- package/dist/components/date-picker/date-picker-calendar.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker-header.svelte +100 -105
- package/dist/components/date-picker/date-picker-header.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker-months.svelte +142 -150
- package/dist/components/date-picker/date-picker-months.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker-root.svelte +4 -3
- package/dist/components/date-picker/date-picker-root.svelte.d.ts +2 -15
- package/dist/components/date-picker/date-picker-years.svelte +205 -214
- package/dist/components/date-picker/date-picker-years.svelte.d.ts +2 -5
- package/dist/components/date-picker/date-picker.stories.svelte +15 -31
- package/dist/components/date-picker/types.d.ts +53 -1
- package/dist/components/dialog/dialog-content.svelte +1 -1
- 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/element/html-element.svelte +85 -85
- package/dist/components/element/types.d.ts +1 -1
- package/dist/components/form/form.stories.svelte +96 -99
- package/dist/components/image/image.stories.svelte +20 -23
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- 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/index.d.ts +1 -0
- package/dist/components/lazy/index.js +1 -0
- package/dist/components/lazy/lazy.stories.svelte +28 -0
- package/dist/components/lazy/lazy.stories.svelte.d.ts +19 -0
- package/dist/components/lazy/lazy.svelte +28 -0
- package/dist/components/lazy/lazy.svelte.d.ts +5 -0
- package/dist/components/lazy/types.d.ts +10 -0
- package/dist/components/lazy/types.js +1 -0
- 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 +2 -1
- package/dist/components/menu/menu-list.svelte.d.ts +1 -0
- 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 +2 -5
- package/dist/components/popover/popover-indicator.svelte +44 -43
- package/dist/components/popover/popover-root.svelte +1 -1
- package/dist/components/popover/popover.stories.svelte +18 -21
- package/dist/components/qr-code/index.d.ts +1 -0
- package/dist/components/qr-code/index.js +1 -0
- package/dist/components/qr-code/qr-code.stories.svelte +4 -10
- package/dist/components/qr-code/qr-code.svelte +75 -25
- package/dist/components/qr-code/qr-code.svelte.d.ts +2 -4
- package/dist/components/qr-code/types.d.ts +14 -0
- package/dist/components/qr-code/types.js +1 -0
- 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/bond.svelte.d.ts +0 -5
- package/dist/components/sidebar/bond.svelte.js +1 -12
- package/dist/components/sidebar/sidebar-content.svelte +50 -39
- package/dist/components/sidebar/sidebar-content.svelte.d.ts +2 -2
- package/dist/components/sidebar/sidebar-root.svelte +39 -68
- package/dist/components/sidebar/sidebar-root.svelte.d.ts +2 -2
- package/dist/components/sidebar/sidebar.stories.svelte +43 -52
- package/dist/components/sidebar/types.d.ts +7 -6
- 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/llm/variants.md +1259 -1261
- package/package.json +7 -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,111 +1,111 @@
|
|
|
1
|
-
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import { animate as motion } from 'motion';
|
|
4
|
-
import { HtmlAtom, type Base } from '../atom';
|
|
5
|
-
import { PopoverBond } from './bond.svelte';
|
|
6
|
-
import type { PopoverArrowProps } from './types';
|
|
7
|
-
|
|
8
|
-
type Element = HTMLElementTagNameMap[E];
|
|
9
|
-
|
|
10
|
-
const bond = PopoverBond.get();
|
|
11
|
-
|
|
12
|
-
if (!bond) {
|
|
13
|
-
throw new Error('');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
let {
|
|
17
|
-
class: klass = '',
|
|
18
|
-
children = undefined,
|
|
19
|
-
onmount = undefined,
|
|
20
|
-
ondestroy = undefined,
|
|
21
|
-
animate = _animate,
|
|
22
|
-
enter = undefined,
|
|
23
|
-
exit = undefined,
|
|
24
|
-
initial = undefined,
|
|
25
|
-
...restProps
|
|
26
|
-
}: PopoverArrowProps<E, B> & HTMLAttributes<Element> = $props();
|
|
27
|
-
|
|
28
|
-
const position = $derived(bond.position);
|
|
29
|
-
const middlewareArrowData = $derived(position?.middlewareData?.arrow);
|
|
30
|
-
const isReady = $derived(!!middlewareArrowData);
|
|
31
|
-
const side = $derived(position?.placement?.split('-')[0] ?? 'top');
|
|
32
|
-
|
|
33
|
-
const arrowProps = $derived({
|
|
34
|
-
...bond.arrow(),
|
|
35
|
-
...restProps
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Rotation based on placement side
|
|
39
|
-
const rotation = $derived.by(() => {
|
|
40
|
-
switch (side) {
|
|
41
|
-
case 'top':
|
|
42
|
-
return 180;
|
|
43
|
-
case 'bottom':
|
|
44
|
-
return 0;
|
|
45
|
-
case 'left':
|
|
46
|
-
return 90;
|
|
47
|
-
case 'right':
|
|
48
|
-
return -90;
|
|
49
|
-
default:
|
|
50
|
-
return 0;
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
function _animate(node: HTMLElement) {
|
|
55
|
-
if (!middlewareArrowData) {
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const { x, y } = middlewareArrowData;
|
|
60
|
-
|
|
61
|
-
const isMainAxis = side === 'top' || side === 'bottom';
|
|
62
|
-
|
|
63
|
-
const crossAxisStyle = isMainAxis
|
|
64
|
-
? {
|
|
65
|
-
left: 0
|
|
66
|
-
}
|
|
67
|
-
: {
|
|
68
|
-
top: 0
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
motion(
|
|
72
|
-
node,
|
|
73
|
-
{
|
|
74
|
-
x: x ?? 0,
|
|
75
|
-
y: y ?? 0,
|
|
76
|
-
opacity: 1,
|
|
77
|
-
...crossAxisStyle
|
|
78
|
-
},
|
|
79
|
-
{ duration: 0 }
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
</script>
|
|
83
|
-
|
|
84
|
-
<HtmlAtom
|
|
85
|
-
{bond}
|
|
86
|
-
preset="popover.arrow"
|
|
87
|
-
class={['text-border border-border pointer-events-none absolute opacity-0', '$preset', klass]}
|
|
88
|
-
onmount={onmount?.bind(bond.state)}
|
|
89
|
-
ondestroy={ondestroy?.bind(bond.state)}
|
|
90
|
-
animate={animate?.bind(bond.state)}
|
|
91
|
-
enter={enter?.bind(bond.state)}
|
|
92
|
-
exit={exit?.bind(bond.state)}
|
|
93
|
-
initial={initial?.bind(bond.state)}
|
|
94
|
-
style="{side}: 100%;"
|
|
95
|
-
{...arrowProps}
|
|
96
|
-
>
|
|
97
|
-
{#if children}
|
|
98
|
-
{@render children({ popover: bond })}
|
|
99
|
-
{:else}
|
|
100
|
-
<svg
|
|
101
|
-
width="
|
|
102
|
-
height="
|
|
103
|
-
viewBox="0 0
|
|
104
|
-
fill="none"
|
|
105
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
106
|
-
style="transform: rotate({rotation}deg);"
|
|
107
|
-
>
|
|
108
|
-
<path d="M0
|
|
109
|
-
</svg>
|
|
110
|
-
{/if}
|
|
111
|
-
</HtmlAtom>
|
|
1
|
+
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import { animate as motion } from 'motion';
|
|
4
|
+
import { HtmlAtom, type Base } from '../atom';
|
|
5
|
+
import { PopoverBond } from './bond.svelte';
|
|
6
|
+
import type { PopoverArrowProps } from './types';
|
|
7
|
+
|
|
8
|
+
type Element = HTMLElementTagNameMap[E];
|
|
9
|
+
|
|
10
|
+
const bond = PopoverBond.get();
|
|
11
|
+
|
|
12
|
+
if (!bond) {
|
|
13
|
+
throw new Error('');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let {
|
|
17
|
+
class: klass = '',
|
|
18
|
+
children = undefined,
|
|
19
|
+
onmount = undefined,
|
|
20
|
+
ondestroy = undefined,
|
|
21
|
+
animate = _animate,
|
|
22
|
+
enter = undefined,
|
|
23
|
+
exit = undefined,
|
|
24
|
+
initial = undefined,
|
|
25
|
+
...restProps
|
|
26
|
+
}: PopoverArrowProps<E, B> & HTMLAttributes<Element> = $props();
|
|
27
|
+
|
|
28
|
+
const position = $derived(bond.position);
|
|
29
|
+
const middlewareArrowData = $derived(position?.middlewareData?.arrow);
|
|
30
|
+
const isReady = $derived(!!middlewareArrowData);
|
|
31
|
+
const side = $derived(position?.placement?.split('-')[0] ?? 'top');
|
|
32
|
+
|
|
33
|
+
const arrowProps = $derived({
|
|
34
|
+
...bond.arrow(),
|
|
35
|
+
...restProps
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// Rotation based on placement side
|
|
39
|
+
const rotation = $derived.by(() => {
|
|
40
|
+
switch (side) {
|
|
41
|
+
case 'top':
|
|
42
|
+
return 180;
|
|
43
|
+
case 'bottom':
|
|
44
|
+
return 0;
|
|
45
|
+
case 'left':
|
|
46
|
+
return 90;
|
|
47
|
+
case 'right':
|
|
48
|
+
return -90;
|
|
49
|
+
default:
|
|
50
|
+
return 0;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
function _animate(node: HTMLElement) {
|
|
55
|
+
if (!middlewareArrowData) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const { x, y } = middlewareArrowData;
|
|
60
|
+
|
|
61
|
+
const isMainAxis = side === 'top' || side === 'bottom';
|
|
62
|
+
|
|
63
|
+
const crossAxisStyle = isMainAxis
|
|
64
|
+
? {
|
|
65
|
+
left: 0
|
|
66
|
+
}
|
|
67
|
+
: {
|
|
68
|
+
top: 0
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
motion(
|
|
72
|
+
node,
|
|
73
|
+
{
|
|
74
|
+
x: x ?? 0,
|
|
75
|
+
y: y ?? 0,
|
|
76
|
+
opacity: 1,
|
|
77
|
+
...crossAxisStyle
|
|
78
|
+
},
|
|
79
|
+
{ duration: 0 }
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<HtmlAtom
|
|
85
|
+
{bond}
|
|
86
|
+
preset="popover.arrow"
|
|
87
|
+
class={['text-border border-border pointer-events-none absolute opacity-0', '$preset', klass]}
|
|
88
|
+
onmount={onmount?.bind(bond.state)}
|
|
89
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
90
|
+
animate={animate?.bind(bond.state)}
|
|
91
|
+
enter={enter?.bind(bond.state)}
|
|
92
|
+
exit={exit?.bind(bond.state)}
|
|
93
|
+
initial={initial?.bind(bond.state)}
|
|
94
|
+
style="{side}: 100%;"
|
|
95
|
+
{...arrowProps}
|
|
96
|
+
>
|
|
97
|
+
{#if children}
|
|
98
|
+
{@render children({ popover: bond })}
|
|
99
|
+
{:else}
|
|
100
|
+
<svg
|
|
101
|
+
width="16"
|
|
102
|
+
height="8"
|
|
103
|
+
viewBox="0 0 16 8"
|
|
104
|
+
fill="none"
|
|
105
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
106
|
+
style="transform: rotate({rotation}deg);"
|
|
107
|
+
>
|
|
108
|
+
<path d="M0 8C2 8 6 4 8 0C10 4 14 8 16 8H0Z" fill="currentColor" />
|
|
109
|
+
</svg>
|
|
110
|
+
{/if}
|
|
111
|
+
</HtmlAtom>
|
|
@@ -99,9 +99,6 @@
|
|
|
99
99
|
const arrowClientWidth = bond?.elements.arrow?.clientWidth ?? 0;
|
|
100
100
|
const arrowClientHeight = bond?.elements.arrow?.clientHeight ?? 0;
|
|
101
101
|
|
|
102
|
-
const _x = openAsNumber * dx;
|
|
103
|
-
const _y = openAsNumber * dy;
|
|
104
|
-
|
|
105
102
|
const getTransformOrigin = () => {
|
|
106
103
|
switch (placement) {
|
|
107
104
|
case 'top':
|
|
@@ -133,8 +130,8 @@
|
|
|
133
130
|
node,
|
|
134
131
|
{
|
|
135
132
|
opacity: openAsNumber,
|
|
136
|
-
y:
|
|
137
|
-
x:
|
|
133
|
+
y: dy * (!isOpen ? -1 : 0) * (arrowClientHeight + yOffset),
|
|
134
|
+
x: dx * (!isOpen ? -1 : 0) * (arrowClientWidth + xOffset),
|
|
138
135
|
scaleY: dy ? (isOpen ? [from, 1] : [1, 0.8]) : undefined,
|
|
139
136
|
scaleX: dx ? (isOpen ? [from, 1] : [1, 0.8]) : undefined,
|
|
140
137
|
transformOrigin
|
|
@@ -1,43 +1,44 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { animate as motion } from 'motion';
|
|
3
|
-
import { Icon } from '../icon';
|
|
4
|
-
import IconArrowDown from '../../icons/icon-arrow-down.svelte';
|
|
5
|
-
import { HtmlAtom } from '../atom';
|
|
6
|
-
import { PopoverBond } from './bond.svelte';
|
|
7
|
-
|
|
8
|
-
const bond = PopoverBond.get();
|
|
9
|
-
|
|
10
|
-
let {
|
|
11
|
-
class: klass = '',
|
|
12
|
-
children = undefined,
|
|
13
|
-
onmount = undefined,
|
|
14
|
-
ondestroy = undefined,
|
|
15
|
-
animate = undefined,
|
|
16
|
-
enter = undefined,
|
|
17
|
-
exit = undefined,
|
|
18
|
-
initial = undefined
|
|
19
|
-
} = $props();
|
|
20
|
-
|
|
21
|
-
const isOpen = $derived(bond?.state.props.open ?? false);
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<HtmlAtom
|
|
25
|
-
{bond}
|
|
26
|
-
preset="popover.indicator"
|
|
27
|
-
class={['border-border flex items-center justify-center', '$preset', klass]}
|
|
28
|
-
onmount={onmount?.bind(bond.state)}
|
|
29
|
-
ondestroy={ondestroy?.bind(bond.state)}
|
|
30
|
-
animate={animate?.bind(bond.state)}
|
|
31
|
-
enter={enter?.bind(bond.state)}
|
|
32
|
-
exit={exit?.bind(bond.state)}
|
|
33
|
-
initial={initial?.bind(bond.state)}
|
|
34
|
-
>
|
|
35
|
-
{#if children}
|
|
36
|
-
{@render children?.({ popover: bond })}
|
|
37
|
-
{:else}
|
|
38
|
-
<Icon
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { animate as motion } from 'motion';
|
|
3
|
+
import { Icon } from '../icon';
|
|
4
|
+
import IconArrowDown from '../../icons/icon-arrow-down.svelte';
|
|
5
|
+
import { HtmlAtom } from '../atom';
|
|
6
|
+
import { PopoverBond } from './bond.svelte';
|
|
7
|
+
|
|
8
|
+
const bond = PopoverBond.get();
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
class: klass = '',
|
|
12
|
+
children = undefined,
|
|
13
|
+
onmount = undefined,
|
|
14
|
+
ondestroy = undefined,
|
|
15
|
+
animate = undefined,
|
|
16
|
+
enter = undefined,
|
|
17
|
+
exit = undefined,
|
|
18
|
+
initial = undefined
|
|
19
|
+
} = $props();
|
|
20
|
+
|
|
21
|
+
const isOpen = $derived(bond?.state.props.open ?? false);
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<HtmlAtom
|
|
25
|
+
{bond}
|
|
26
|
+
preset="popover.indicator"
|
|
27
|
+
class={['border-border flex h-5 items-center justify-center', '$preset', klass]}
|
|
28
|
+
onmount={onmount?.bind(bond.state)}
|
|
29
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
30
|
+
animate={animate?.bind(bond.state)}
|
|
31
|
+
enter={enter?.bind(bond.state)}
|
|
32
|
+
exit={exit?.bind(bond.state)}
|
|
33
|
+
initial={initial?.bind(bond.state)}
|
|
34
|
+
>
|
|
35
|
+
{#if children}
|
|
36
|
+
{@render children?.({ popover: bond })}
|
|
37
|
+
{:else}
|
|
38
|
+
<Icon
|
|
39
|
+
class="h-full"
|
|
40
|
+
src={IconArrowDown}
|
|
41
|
+
animate={(node) => motion(node, { rotate: 180 * +isOpen }, { duration: 0.2 })}
|
|
42
|
+
/>
|
|
43
|
+
{/if}
|
|
44
|
+
</HtmlAtom>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script module>
|
|
2
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
3
|
import { Popover as Popover_ } from '.';
|
|
4
|
-
import Root from '../root/root.svelte';
|
|
5
4
|
import { clickoutPopover } from './attachments.svelte';
|
|
6
5
|
import { Button } from '../button';
|
|
7
6
|
|
|
@@ -24,29 +23,27 @@
|
|
|
24
23
|
|
|
25
24
|
<Story name="Popover" args={{}}>
|
|
26
25
|
{#snippet children(args)}
|
|
27
|
-
<Root
|
|
28
|
-
|
|
29
|
-
{#
|
|
30
|
-
<!-- {#if dev}
|
|
26
|
+
<Popover_.Root bind:open offset={0} {...args}>
|
|
27
|
+
{#snippet children({ popover })}
|
|
28
|
+
<!-- {#if dev}
|
|
31
29
|
<RenderScan duration={400} />
|
|
32
30
|
{/if} -->
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
<Popover_.Trigger base={Button} class="items-center gap-4">
|
|
33
|
+
<div>Open Popover</div>
|
|
34
|
+
<Popover_.Indicator />
|
|
35
|
+
</Popover_.Trigger>
|
|
38
36
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
</Root>
|
|
37
|
+
<Popover_.Content
|
|
38
|
+
{@attach clickoutPopover((ev, atom) => {
|
|
39
|
+
atom.state.close();
|
|
40
|
+
})}
|
|
41
|
+
class="bg-card"
|
|
42
|
+
>
|
|
43
|
+
<div>Hello World !</div>
|
|
44
|
+
<Popover_.Arrow />
|
|
45
|
+
</Popover_.Content>
|
|
46
|
+
{/snippet}
|
|
47
|
+
</Popover_.Root>
|
|
51
48
|
{/snippet}
|
|
52
49
|
</Story>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script module>
|
|
2
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
3
|
import QrCodeComponent from './qr-code.svelte';
|
|
4
|
-
import { Root } from '../root';
|
|
5
4
|
|
|
6
5
|
const { Story } = defineMeta({
|
|
7
6
|
title: 'Atoms/QR Code'
|
|
@@ -12,13 +11,8 @@
|
|
|
12
11
|
</script>
|
|
13
12
|
|
|
14
13
|
<Story name="QR Code">
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<QrCodeComponent value="Hello World" />
|
|
20
|
-
</div>
|
|
21
|
-
{/snippet}
|
|
22
|
-
</Root>
|
|
23
|
-
{/snippet}
|
|
14
|
+
<QrCodeComponent
|
|
15
|
+
class="text-primary-foreground bg-primary size-64 rounded-2xl p-1"
|
|
16
|
+
value="Hello World 123"
|
|
17
|
+
/>
|
|
24
18
|
</Story>
|
|
@@ -1,25 +1,75 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { QRCodeBrowser } from '@qrcode-js/browser';
|
|
3
|
+
import { HtmlAtom } from '../atom';
|
|
4
|
+
import type { QRCodeProps } from './types';
|
|
5
|
+
|
|
6
|
+
type Render = typeof QRCodeBrowser;
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
class: klass = '',
|
|
10
|
+
value = '',
|
|
11
|
+
finder = {
|
|
12
|
+
round: 0.5
|
|
13
|
+
},
|
|
14
|
+
dots = {
|
|
15
|
+
scale: 0.75,
|
|
16
|
+
round: 1
|
|
17
|
+
},
|
|
18
|
+
drawFunction = 'telegram',
|
|
19
|
+
gradient = undefined,
|
|
20
|
+
logo = undefined,
|
|
21
|
+
margin = undefined,
|
|
22
|
+
qr = undefined,
|
|
23
|
+
...restProps
|
|
24
|
+
}: QRCodeProps = $props();
|
|
25
|
+
|
|
26
|
+
let canvasElement: HTMLCanvasElement | undefined = $state();
|
|
27
|
+
|
|
28
|
+
let clientWidth = $state(0);
|
|
29
|
+
let isReady = $state(false);
|
|
30
|
+
let render: Render | undefined = $state();
|
|
31
|
+
let computedColor = $state('black');
|
|
32
|
+
|
|
33
|
+
import('@qrcode-js/browser').then((result) => {
|
|
34
|
+
render = result.QRCodeBrowser;
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
$effect(() => {
|
|
38
|
+
if (!canvasElement) return;
|
|
39
|
+
if (!render) return;
|
|
40
|
+
if (!isReady) render;
|
|
41
|
+
|
|
42
|
+
// Get the computed color from the canvas element
|
|
43
|
+
computedColor = getComputedStyle(canvasElement).color;
|
|
44
|
+
|
|
45
|
+
const qrcode = render(canvasElement);
|
|
46
|
+
|
|
47
|
+
qrcode.setOptions({
|
|
48
|
+
text: value,
|
|
49
|
+
size: clientWidth,
|
|
50
|
+
color: computedColor,
|
|
51
|
+
dots,
|
|
52
|
+
finder,
|
|
53
|
+
drawFunction,
|
|
54
|
+
...(gradient && { gradient }),
|
|
55
|
+
...(margin && { margin }),
|
|
56
|
+
...(logo && { logo }),
|
|
57
|
+
...(qr && { qr })
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
qrcode.draw();
|
|
61
|
+
});
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<HtmlAtom class={[klass]} {...restProps}>
|
|
65
|
+
<div bind:clientWidth class="size-full">
|
|
66
|
+
<canvas
|
|
67
|
+
{@attach (node) => {
|
|
68
|
+
canvasElement = node;
|
|
69
|
+
isReady = true;
|
|
70
|
+
}}
|
|
71
|
+
width={clientWidth}
|
|
72
|
+
height={clientWidth}
|
|
73
|
+
></canvas>
|
|
74
|
+
</div>
|
|
75
|
+
</HtmlAtom>
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
value?: string;
|
|
4
|
-
}, {}, "">;
|
|
1
|
+
import type { QRCodeProps } from './types';
|
|
2
|
+
declare const QrCode: import("svelte").Component<QRCodeProps, {}, "">;
|
|
5
3
|
type QrCode = ReturnType<typeof QrCode>;
|
|
6
4
|
export default QrCode;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { QRCodeBrowser } from '@qrcode-js/browser';
|
|
2
|
+
type QRCodeOptions = Parameters<ReturnType<typeof QRCodeBrowser>['setOptions']>[0];
|
|
3
|
+
export type QRCodeProps = {
|
|
4
|
+
class?: string;
|
|
5
|
+
value: string;
|
|
6
|
+
finder?: QRCodeOptions['finder'];
|
|
7
|
+
dots?: QRCodeOptions['dots'];
|
|
8
|
+
drawFunction?: QRCodeOptions['drawFunction'];
|
|
9
|
+
gradient?: QRCodeOptions['gradient'];
|
|
10
|
+
logo?: QRCodeOptions['logo'];
|
|
11
|
+
margin?: QRCodeOptions['margin'];
|
|
12
|
+
qr?: QRCodeOptions['qr'];
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,50 +1,41 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { default as RadioComponent } from './radio.svelte';
|
|
4
|
-
import { default as RadioGroupComponent } from './radio-group.svelte';
|
|
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
|
-
<div class="mt-8">
|
|
44
|
-
Selected value: <strong>{value}</strong>
|
|
45
|
-
</div>
|
|
46
|
-
</div>
|
|
47
|
-
{/snippet}
|
|
48
|
-
</Root>
|
|
49
|
-
{/snippet}
|
|
50
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { default as RadioComponent } from './radio.svelte';
|
|
4
|
+
import { default as RadioGroupComponent } from './radio-group.svelte';
|
|
5
|
+
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
title: 'ATOMS/Radio'
|
|
8
|
+
});
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<script>
|
|
12
|
+
let value = $state('t1');
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<Story name="Group">
|
|
16
|
+
<RadioGroupComponent class="gap-4" name="choice" bind:value>
|
|
17
|
+
<label class="flex items-center gap-2">
|
|
18
|
+
<RadioComponent class="size-8" value="t1" />
|
|
19
|
+
<div>Test 1</div>
|
|
20
|
+
</label>
|
|
21
|
+
|
|
22
|
+
<label class="flex items-center gap-2">
|
|
23
|
+
<RadioComponent class="size-8" value="t2" />
|
|
24
|
+
<div>Test 2</div>
|
|
25
|
+
</label>
|
|
26
|
+
|
|
27
|
+
<label class="flex items-center gap-2">
|
|
28
|
+
<RadioComponent class="size-8" value="t3" />
|
|
29
|
+
<div>Test 3</div>
|
|
30
|
+
</label>
|
|
31
|
+
|
|
32
|
+
<label class="flex items-center gap-2">
|
|
33
|
+
<RadioComponent class="size-8" value="t4" />
|
|
34
|
+
<div>Test 4</div>
|
|
35
|
+
</label>
|
|
36
|
+
</RadioGroupComponent>
|
|
37
|
+
|
|
38
|
+
<div class="mt-8">
|
|
39
|
+
Selected value: <strong>{value}</strong>
|
|
40
|
+
</div>
|
|
41
|
+
</Story>
|