@svelte-atoms/core 1.0.0-alpha.29 → 1.0.0-alpha.31
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 +3 -2
- package/dist/attachments/clickout.svelte.d.ts +1 -1
- package/dist/attachments/clickout.svelte.js +2 -2
- package/dist/components/accordion/accordion-root.svelte +65 -61
- package/dist/components/accordion/accordion-root.svelte.d.ts +1 -1
- package/dist/components/accordion/accordion.stories.svelte +70 -134
- package/dist/components/accordion/item/accordion-item-body.svelte +44 -42
- package/dist/components/accordion/item/accordion-item-header.svelte +51 -50
- package/dist/components/accordion/item/accordion-item-indicator.svelte +51 -50
- package/dist/components/accordion/item/accordion-item-root.svelte +66 -65
- package/dist/components/accordion/item/bond.svelte.d.ts +2 -0
- package/dist/components/accordion/item/index.d.ts +3 -0
- package/dist/components/accordion/item/index.js +3 -0
- package/dist/components/accordion/item/motion.svelte.d.ts +15 -0
- package/dist/components/accordion/item/motion.svelte.js +30 -0
- package/dist/components/accordion/item/types.d.ts +7 -24
- package/dist/components/alert/alert-close-button.svelte +66 -70
- package/dist/components/alert/alert-description.svelte +42 -42
- package/dist/components/alert/alert-description.svelte.d.ts +3 -6
- package/dist/components/alert/alert-root.svelte +68 -103
- package/dist/components/alert/alert-root.svelte.d.ts +2 -2
- package/dist/components/alert/alert.stories.svelte +10 -11
- package/dist/components/alert/bond.svelte.d.ts +0 -13
- package/dist/components/alert/bond.svelte.js +0 -32
- package/dist/components/alert/types.d.ts +8 -32
- package/dist/components/atom/html-atom.svelte +261 -207
- package/dist/components/avatar/avatar.stories.svelte +8 -13
- package/dist/components/badge/badge.stories.svelte +1 -6
- package/dist/components/badge/badge.svelte +1 -1
- package/dist/components/breadcrumb/breadcrumb.stories.svelte +16 -21
- package/dist/components/button/button.stories.svelte +1 -34
- package/dist/components/calendar/calendar-day.svelte +9 -4
- 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 +26 -31
- package/dist/components/card/card-body.svelte +1 -1
- package/dist/components/card/card-footer.svelte +1 -1
- package/dist/components/card/card-root.svelte +1 -1
- package/dist/components/card/card.stories.svelte +92 -104
- package/dist/components/checkbox/checkbox.stories.svelte +4 -9
- package/dist/components/checkbox/checkbox.svelte +159 -157
- package/dist/components/collapsible/collapsible.stories.svelte +2 -3
- package/dist/components/combobox/atoms.d.ts +1 -1
- package/dist/components/combobox/atoms.js +1 -1
- package/dist/components/combobox/combobox-root.svelte +1 -1
- package/dist/components/combobox/compobox.stories.svelte +19 -22
- package/dist/components/combobox/index.d.ts +1 -0
- package/dist/components/container/container.stories.svelte +8 -11
- package/dist/components/container/container.svelte.d.ts +1 -1
- package/dist/components/datagrid/datagrid-root.svelte +59 -59
- package/dist/components/datagrid/datagrid.css +5 -5
- package/dist/components/datagrid/datagrid.stories.svelte +47 -50
- package/dist/components/datagrid/tr/bond.svelte.d.ts +4 -2
- package/dist/components/datagrid/tr/bond.svelte.js +9 -7
- package/dist/components/datagrid/tr/datagrid-tr.svelte +90 -88
- package/dist/components/date-picker/date-picker-calendar.svelte +2 -2
- 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 +95 -95
- package/dist/components/date-picker/date-picker-years.svelte +205 -205
- package/dist/components/date-picker/date-picker.stories.svelte +35 -42
- package/dist/components/dialog/bond.svelte.d.ts +13 -3
- package/dist/components/dialog/bond.svelte.js +66 -5
- package/dist/components/dialog/dialog-content.svelte +2 -20
- package/dist/components/dialog/dialog-root.svelte +91 -110
- package/dist/components/dialog/dialog.stories.svelte +34 -37
- package/dist/components/dialog/motion.svelte.d.ts +13 -0
- package/dist/components/dialog/motion.svelte.js +44 -0
- package/dist/components/drawer/attachments.svelte.d.ts +1 -1
- package/dist/components/drawer/attachments.svelte.js +7 -10
- package/dist/components/drawer/bond.svelte.d.ts +24 -5
- package/dist/components/drawer/bond.svelte.js +77 -11
- package/dist/components/drawer/drawer-content.svelte +49 -42
- package/dist/components/drawer/drawer.stories.svelte +144 -224
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/drawer/index.js +2 -0
- package/dist/components/drawer/motion.d.ts +15 -0
- package/dist/components/drawer/motion.js +28 -0
- package/dist/components/dropdown/atoms.d.ts +1 -1
- package/dist/components/dropdown/atoms.js +1 -1
- package/dist/components/dropdown/bond.svelte.d.ts +5 -1
- package/dist/components/dropdown/dropdown-root.svelte +1 -1
- package/dist/components/dropdown/dropdown.stories.svelte +38 -41
- package/dist/components/dropdown/index.d.ts +1 -0
- package/dist/components/form/form.stories.svelte +58 -61
- package/dist/components/image/image.stories.svelte +9 -12
- package/dist/components/input/input.stories.svelte +11 -14
- package/dist/components/label/label.stories.svelte +1 -12
- package/dist/components/label/label.stories.svelte.d.ts +24 -4
- package/dist/components/lazy/lazy.stories.svelte +28 -35
- package/dist/components/lazy/lazy.svelte +28 -28
- package/dist/components/link/link.stories.svelte +1 -12
- package/dist/components/link/link.stories.svelte.d.ts +24 -4
- package/dist/components/list/list-item.svelte +20 -20
- package/dist/components/menu/atoms.d.ts +1 -0
- package/dist/components/menu/atoms.js +1 -0
- package/dist/components/menu/index.d.ts +2 -1
- package/dist/components/menu/index.js +1 -1
- package/dist/components/menu/menu-item.svelte +69 -51
- package/dist/components/menu/menu-item.svelte.d.ts +1 -0
- package/dist/components/menu/menu-list.svelte +40 -40
- package/dist/components/menu/menu.stories.svelte +9 -12
- package/dist/components/popover/bond.svelte.d.ts +20 -7
- package/dist/components/popover/bond.svelte.js +104 -45
- package/dist/components/popover/motion.d.ts +6 -0
- package/dist/components/popover/motion.js +56 -0
- package/dist/components/popover/popover-arrow.svelte +4 -4
- package/dist/components/popover/popover-content.svelte +137 -178
- package/dist/components/popover/popover-indicator.svelte +2 -1
- package/dist/components/popover/popover-root.svelte +1 -1
- package/dist/components/popover/popover.stories.svelte +49 -52
- package/dist/components/popover/types.d.ts +9 -7
- package/dist/components/portal/active-portal.svelte +29 -22
- package/dist/components/portal/active-portal.svelte.d.ts +2 -9
- package/dist/components/portal/portal-root.svelte +76 -83
- package/dist/components/portal/portal-root.svelte.d.ts +4 -6
- package/dist/components/portal/teleport.svelte +49 -50
- package/dist/components/portal/teleport.svelte.d.ts +3 -4
- package/dist/components/qr-code/qr-code.stories.svelte +18 -27
- package/dist/components/qr-code/qr-code.svelte +75 -75
- package/dist/components/radio/radio-group.stories.svelte +21 -30
- package/dist/components/radio/radio.stories.svelte +1 -10
- package/dist/components/radio/radio.svelte +109 -109
- package/dist/components/radio/types.d.ts +98 -0
- package/dist/components/radio/types.js +2 -0
- package/dist/components/root/root.svelte +104 -121
- package/dist/components/scrollable/scrollable-root.svelte.d.ts +2 -2
- package/dist/components/scrollable/scrollable.stories.svelte +95 -105
- package/dist/components/sidebar/index.d.ts +2 -0
- package/dist/components/sidebar/index.js +2 -0
- package/dist/components/sidebar/motion.svelte.d.ts +11 -0
- package/dist/components/sidebar/motion.svelte.js +16 -0
- package/dist/components/sidebar/sidebar-content.svelte +3 -2
- package/dist/components/sidebar/sidebar-root.svelte +39 -41
- package/dist/components/sidebar/sidebar.stories.svelte +43 -54
- package/dist/components/sidebar/types.d.ts +3 -12
- 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 +31 -34
- package/dist/components/textarea/atoms.d.ts +1 -0
- package/dist/components/textarea/atoms.js +1 -0
- package/dist/components/textarea/textarea-input.svelte +9 -6
- package/dist/components/textarea/textarea-root.svelte +9 -9
- package/dist/components/textarea/textarea-root.svelte.d.ts +2 -0
- package/dist/components/tooltip/tooltip-trigger.svelte +39 -37
- package/dist/components/tooltip/tooltip-trigger.svelte.d.ts +1 -0
- package/dist/components/tooltip/tooltip.stories.svelte +7 -10
- package/dist/components/tree/tree.stories.svelte +102 -94
- package/dist/context/preset.svelte.d.ts +3 -3
- package/dist/icons/icon-copy.svelte +6 -0
- package/dist/{components/radio/types.svelte.d.ts → icons/icon-copy.svelte.d.ts} +3 -3
- package/dist/utils/function.d.ts +2 -0
- package/dist/utils/function.js +6 -0
- package/dist/utils/markdown-to-llm.d.ts +28 -0
- package/dist/utils/markdown-to-llm.js +76 -0
- package/package.json +6 -10
- 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
- package/dist/components/radio/types.svelte +0 -0
- package/llm/composition.md +0 -395
- package/llm/crafting.md +0 -838
- package/llm/motion.md +0 -970
- package/llm/philosophy.md +0 -23
- package/llm/preset-variant-integration.md +0 -516
- package/llm/preset.md +0 -383
- package/llm/styling.md +0 -216
- package/llm/usage.md +0 -46
- package/llm/variants.md +0 -1259
|
@@ -1,83 +1,76 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
export type { PortalOuterProps } from './types';
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
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
|
-
{bond}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
animate={animate?.bind(bond.state)}
|
|
78
|
-
onmount={onmount?.bind(bond.state)}
|
|
79
|
-
ondestroy={ondestroy?.bind(bond.state)}
|
|
80
|
-
{...rootProps}
|
|
81
|
-
>
|
|
82
|
-
{@render children?.()}
|
|
83
|
-
</HtmlAtom>
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export type { PortalOuterProps } from './types';
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
6
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
7
|
+
import type { PortalOuterProps } from './types';
|
|
8
|
+
import { PortalsBond, PortalBond, PortalState, type PortalStateProps } from '.';
|
|
9
|
+
import { RootBond } from '../root';
|
|
10
|
+
import { HtmlAtom, type ElementType, type Base } from '../atom';
|
|
11
|
+
import { defineProperty, defineState } from '../../utils';
|
|
12
|
+
|
|
13
|
+
type Element = ElementType<E>;
|
|
14
|
+
|
|
15
|
+
let {
|
|
16
|
+
class: klass = '',
|
|
17
|
+
id,
|
|
18
|
+
factory = _factory,
|
|
19
|
+
children = undefined,
|
|
20
|
+
onmount = undefined,
|
|
21
|
+
ondestroy = undefined,
|
|
22
|
+
animate = undefined,
|
|
23
|
+
enter = undefined,
|
|
24
|
+
exit = undefined,
|
|
25
|
+
initial = undefined,
|
|
26
|
+
...restProps
|
|
27
|
+
}: PortalOuterProps<E, B> & HTMLAttributes<Element> = $props();
|
|
28
|
+
|
|
29
|
+
const rootBond = RootBond.get();
|
|
30
|
+
const portalsBond = PortalsBond.get();
|
|
31
|
+
|
|
32
|
+
const bondProps = defineState<PortalStateProps>([defineProperty('id', () => id)]);
|
|
33
|
+
const bond = factory(bondProps).share() as PortalBond;
|
|
34
|
+
|
|
35
|
+
portalsBond?.state.set(id, bond);
|
|
36
|
+
|
|
37
|
+
$effect(() => {
|
|
38
|
+
if (rootBond) {
|
|
39
|
+
rootBond.state.setPortal(id, bond);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return () => {
|
|
43
|
+
portalsBond?.state.delete(id);
|
|
44
|
+
bond.destroy();
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const rootProps = $derived({
|
|
49
|
+
...bond.root(),
|
|
50
|
+
...restProps
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
function _factory(props: typeof bondProps) {
|
|
54
|
+
const portalState = new PortalState(() => props);
|
|
55
|
+
return new PortalBond(portalState);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function getBond() {
|
|
59
|
+
return bond;
|
|
60
|
+
}
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
<HtmlAtom
|
|
64
|
+
{bond}
|
|
65
|
+
preset="portal"
|
|
66
|
+
class={['border-border pointer-events-none', '$preset', klass]}
|
|
67
|
+
enter={enter?.bind(bond.state)}
|
|
68
|
+
exit={exit?.bind(bond.state)}
|
|
69
|
+
initial={initial?.bind(bond.state)}
|
|
70
|
+
animate={animate?.bind(bond.state)}
|
|
71
|
+
onmount={onmount?.bind(bond.state)}
|
|
72
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
73
|
+
{...rootProps}
|
|
74
|
+
>
|
|
75
|
+
{@render children?.()}
|
|
76
|
+
</HtmlAtom>
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
export type { PortalOuterProps } from './types';
|
|
2
|
-
import type { Snippet } from 'svelte';
|
|
3
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
4
3
|
import { PortalBond } from '.';
|
|
5
|
-
import type
|
|
6
|
-
import { type ElementType, type HtmlAtomProps, type Base } from '../atom';
|
|
4
|
+
import { type ElementType, type Base } from '../atom';
|
|
7
5
|
declare function $$render<E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base>(): {
|
|
8
|
-
props: HtmlAtomProps<E, B> & import("./types").PortalOuterExtendProps & {
|
|
9
|
-
id: RootPortals | (string & {});
|
|
10
|
-
children?: Snippet;
|
|
6
|
+
props: import("../atom").HtmlAtomProps<E, B> & import("./types").PortalOuterExtendProps & {
|
|
7
|
+
id: import("../root/root.svelte").RootPortals | (string & {});
|
|
8
|
+
children?: import("svelte").Snippet;
|
|
11
9
|
} & HTMLAttributes<ElementType<E>>;
|
|
12
10
|
exports: {
|
|
13
11
|
getBond: () => PortalBond;
|
|
@@ -1,50 +1,49 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
export type { TeleportProps } from './types';
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<script lang="ts" generics="E extends HtmlElementTagName = 'div', B extends Base = Base">
|
|
6
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
7
|
-
import type { TeleportProps } from './types';
|
|
8
|
-
import { HtmlAtom, type
|
|
9
|
-
import type { HtmlElementTagName, HtmlElementType } from '../element';
|
|
10
|
-
import { PortalsBond } from './portals';
|
|
11
|
-
import { RootBond } from '../root/bond.svelte';
|
|
12
|
-
import { port } from './utils';
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
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
|
-
{/if}
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export type { TeleportProps } from './types';
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script lang="ts" generics="E extends HtmlElementTagName = 'div', B extends Base = Base">
|
|
6
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
7
|
+
import type { TeleportProps } from './types';
|
|
8
|
+
import { HtmlAtom, type Base } from '../atom';
|
|
9
|
+
import type { HtmlElementTagName, HtmlElementType } from '../element';
|
|
10
|
+
import { PortalsBond } from './portals';
|
|
11
|
+
import { RootBond } from '../root/bond.svelte';
|
|
12
|
+
import { port } from './utils';
|
|
13
|
+
|
|
14
|
+
type Element = HtmlElementType<E>;
|
|
15
|
+
|
|
16
|
+
let { portal, as, base, children, ...restProps }: TeleportProps<E, B> & HTMLAttributes<Element> =
|
|
17
|
+
$props();
|
|
18
|
+
|
|
19
|
+
const portalsBond = PortalsBond.get();
|
|
20
|
+
const rootBond = RootBond.get();
|
|
21
|
+
|
|
22
|
+
const portalBond = $derived.by(() => {
|
|
23
|
+
if (typeof portal === 'string') {
|
|
24
|
+
return portalsBond?.state?.get(portal!) ?? rootBond?.state?.getPortal(portal!);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return portal;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const targetElement = $derived(portalBond?.targetElement);
|
|
31
|
+
|
|
32
|
+
function _port(node: HTMLElement) {
|
|
33
|
+
const hidden = node.hidden;
|
|
34
|
+
|
|
35
|
+
node.hidden = true;
|
|
36
|
+
|
|
37
|
+
const unport = port(node, targetElement);
|
|
38
|
+
|
|
39
|
+
node.hidden = hidden;
|
|
40
|
+
|
|
41
|
+
return unport;
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
{#if targetElement && portal}
|
|
46
|
+
<HtmlAtom {@attach _port} as={as as E} {base} {...restProps}>
|
|
47
|
+
{@render children?.({ portal: portalBond })}
|
|
48
|
+
</HtmlAtom>
|
|
49
|
+
{/if}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
export type { TeleportProps } from './types';
|
|
2
2
|
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import { type
|
|
3
|
+
import { type Base } from '../atom';
|
|
4
4
|
import type { HtmlElementTagName, HtmlElementType } from '../element';
|
|
5
|
-
import type { PortalBond } from '.';
|
|
6
5
|
declare function $$render<E extends HtmlElementTagName = 'div', B extends Base = Base>(): {
|
|
7
|
-
props: HtmlAtomProps<E, B> & import("./types").TeleportExtendProps & {
|
|
8
|
-
portal?: string | PortalBond;
|
|
6
|
+
props: import("../atom").HtmlAtomProps<E, B> & import("./types").TeleportExtendProps & {
|
|
7
|
+
portal?: string | import("./bond.svelte").PortalBond;
|
|
9
8
|
} & HTMLAttributes<HtmlElementType<E>>;
|
|
10
9
|
exports: {};
|
|
11
10
|
bindings: "";
|
|
@@ -1,27 +1,18 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import QrCodeComponent from './qr-code.svelte';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
<QrCodeComponent
|
|
20
|
-
class="text-primary-foreground bg-primary size-64 rounded-2xl p-1"
|
|
21
|
-
value="Hello World 123"
|
|
22
|
-
/>
|
|
23
|
-
</div>
|
|
24
|
-
{/snippet}
|
|
25
|
-
</Root>
|
|
26
|
-
{/snippet}
|
|
27
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import QrCodeComponent from './qr-code.svelte';
|
|
4
|
+
|
|
5
|
+
const { Story } = defineMeta({
|
|
6
|
+
title: 'Atoms/QR Code'
|
|
7
|
+
});
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<Story name="QR Code">
|
|
14
|
+
<QrCodeComponent
|
|
15
|
+
class="text-primary-foreground bg-primary size-64 rounded-2xl p-1"
|
|
16
|
+
value="Hello World 123"
|
|
17
|
+
/>
|
|
18
|
+
</Story>
|
|
@@ -1,75 +1,75 @@
|
|
|
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
|
+
<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>
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
3
|
import { default as RadioComponent } from './radio.svelte';
|
|
4
4
|
import { default as RadioGroupComponent } from './radio-group.svelte';
|
|
5
|
-
import { Root } from '../root';
|
|
6
5
|
|
|
7
6
|
const { Story } = defineMeta({
|
|
8
7
|
title: 'ATOMS/Radio'
|
|
@@ -14,37 +13,29 @@
|
|
|
14
13
|
</script>
|
|
15
14
|
|
|
16
15
|
<Story name="Group">
|
|
17
|
-
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<label class="flex items-center gap-2">
|
|
23
|
-
<RadioComponent class="size-8" value="t1" />
|
|
24
|
-
<div>Test 1</div>
|
|
25
|
-
</label>
|
|
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>
|
|
26
21
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
<label class="flex items-center gap-2">
|
|
23
|
+
<RadioComponent class="size-8" value="t2" />
|
|
24
|
+
<div>Test 2</div>
|
|
25
|
+
</label>
|
|
31
26
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
27
|
+
<label class="flex items-center gap-2">
|
|
28
|
+
<RadioComponent class="size-8" value="t3" />
|
|
29
|
+
<div>Test 3</div>
|
|
30
|
+
</label>
|
|
36
31
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
<label class="flex items-center gap-2">
|
|
33
|
+
<RadioComponent class="size-8" value="t4" />
|
|
34
|
+
<div>Test 4</div>
|
|
35
|
+
</label>
|
|
36
|
+
</RadioGroupComponent>
|
|
42
37
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</div>
|
|
47
|
-
{/snippet}
|
|
48
|
-
</Root>
|
|
49
|
-
{/snippet}
|
|
38
|
+
<div class="mt-8">
|
|
39
|
+
Selected value: <strong>{value}</strong>
|
|
40
|
+
</div>
|
|
50
41
|
</Story>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
<script module>
|
|
2
2
|
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
3
|
import { default as RadioModule } from './radio.svelte';
|
|
4
|
-
import { Root } from '../root';
|
|
5
4
|
|
|
6
5
|
const { Story } = defineMeta({
|
|
7
6
|
title: 'ATOMS/Radio'
|
|
@@ -14,13 +13,5 @@
|
|
|
14
13
|
</script>
|
|
15
14
|
|
|
16
15
|
<Story name="Radio">
|
|
17
|
-
|
|
18
|
-
<Root>
|
|
19
|
-
{#snippet children({})}
|
|
20
|
-
<div class="flex h-full w-full items-center justify-center">
|
|
21
|
-
<RadioModule class="size-5" />
|
|
22
|
-
</div>
|
|
23
|
-
{/snippet}
|
|
24
|
-
</Root>
|
|
25
|
-
{/snippet}
|
|
16
|
+
<RadioModule class="size-5" />
|
|
26
17
|
</Story>
|