@svelte-atoms/core 1.0.0-alpha.23 → 1.0.0-alpha.24
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/dist/components/atom/html-atom.svelte +70 -70
- package/dist/components/input/input-root.svelte +79 -79
- package/dist/components/input/input.stories.svelte +38 -38
- package/dist/components/root/root.svelte +121 -103
- package/dist/components/root/root.svelte.d.ts +1 -0
- package/dist/runes/index.d.ts +3 -0
- package/dist/runes/index.js +3 -0
- package/dist/runes/reduced-motion.svelte.d.ts +23 -0
- package/dist/runes/reduced-motion.svelte.js +41 -0
- package/package.json +436 -436
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import type { Base, ComponentBase, HtmlAtomProps, SnippetBase } from './types';
|
|
4
|
-
import { RootBond } from '../root';
|
|
5
|
-
import { HtmlElement } from '../element';
|
|
6
|
-
import { cn, toClassValue, type ClassValue } from '../../utils';
|
|
7
|
-
import { getPreset } from '../../context';
|
|
8
|
-
import type { PresetModuleName } from '../../context/preset.svelte';
|
|
9
|
-
|
|
10
|
-
type Element = HTMLElementTagNameMap[E];
|
|
11
|
-
|
|
12
|
-
const rootBond = RootBond.get();
|
|
13
|
-
|
|
14
|
-
let {
|
|
15
|
-
class: klass = '',
|
|
16
|
-
as = 'div',
|
|
17
|
-
base = undefined,
|
|
18
|
-
preset: presetKey = undefined,
|
|
19
|
-
bond = undefined,
|
|
20
|
-
children = undefined,
|
|
21
|
-
...restProps
|
|
22
|
-
}: HtmlAtomProps<E, B> & HTMLAttributes<Element> = $props();
|
|
23
|
-
|
|
24
|
-
const preset = $derived(
|
|
25
|
-
presetKey ? getPreset(presetKey as PresetModuleName)?.apply?.(bond, [bond]) : undefined
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
const _klass = $derived(compilePresetPlaceholder(klass));
|
|
29
|
-
|
|
30
|
-
const _base = $derived(base ?? preset?.base);
|
|
31
|
-
const _as = $derived(as ?? preset?.as);
|
|
32
|
-
const _restProps = $derived.by(() => {
|
|
33
|
-
const { class: klass, base, as, ...restPresetProps } = preset ?? {};
|
|
34
|
-
return { ...restPresetProps, ...restProps };
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
const isSnippet = $derived(typeof _base === 'function' && _base.length === 1 && !_base.prototype);
|
|
38
|
-
|
|
39
|
-
const snippet = $derived(_base as SnippetBase);
|
|
40
|
-
|
|
41
|
-
const atom = rootBond?.state?.props?.renderers?.html ?? HtmlElement;
|
|
42
|
-
|
|
43
|
-
const Component = $derived(base ?? atom) as ComponentBase;
|
|
44
|
-
|
|
45
|
-
function compilePresetPlaceholder(klass: ClassValue): ReturnType<typeof toClassValue> {
|
|
46
|
-
if (Array.isArray(klass)) {
|
|
47
|
-
return klass.map((k) => compilePresetPlaceholder(k));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const compiled = toClassValue.apply(bond, [klass, bond]);
|
|
51
|
-
|
|
52
|
-
if (Array.isArray(compiled)) {
|
|
53
|
-
return compiled.map((c) => compilePresetPlaceholder(c));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (typeof compiled === 'string') {
|
|
57
|
-
return compiled.replace('$preset', cn(preset?.class));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return compiled;
|
|
61
|
-
}
|
|
62
|
-
</script>
|
|
63
|
-
|
|
64
|
-
{#if isSnippet}
|
|
65
|
-
{@render snippet({ class: _klass, as: _as, base: _base, children, ..._restProps })}
|
|
66
|
-
{:else}
|
|
67
|
-
<Component class={_klass} as={_as} {..._restProps}>
|
|
68
|
-
{@render children?.()}
|
|
69
|
-
</Component>
|
|
70
|
-
{/if}
|
|
1
|
+
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import type { Base, ComponentBase, HtmlAtomProps, SnippetBase } from './types';
|
|
4
|
+
import { RootBond } from '../root';
|
|
5
|
+
import { HtmlElement } from '../element';
|
|
6
|
+
import { cn, toClassValue, type ClassValue } from '../../utils';
|
|
7
|
+
import { getPreset } from '../../context';
|
|
8
|
+
import type { PresetModuleName } from '../../context/preset.svelte';
|
|
9
|
+
|
|
10
|
+
type Element = HTMLElementTagNameMap[E];
|
|
11
|
+
|
|
12
|
+
const rootBond = RootBond.get();
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
class: klass = '',
|
|
16
|
+
as = 'div',
|
|
17
|
+
base = undefined,
|
|
18
|
+
preset: presetKey = undefined,
|
|
19
|
+
bond = undefined,
|
|
20
|
+
children = undefined,
|
|
21
|
+
...restProps
|
|
22
|
+
}: HtmlAtomProps<E, B> & HTMLAttributes<Element> = $props();
|
|
23
|
+
|
|
24
|
+
const preset = $derived(
|
|
25
|
+
presetKey ? getPreset(presetKey as PresetModuleName)?.apply?.(bond, [bond]) : undefined
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const _klass = $derived(compilePresetPlaceholder(klass));
|
|
29
|
+
|
|
30
|
+
const _base = $derived(base ?? preset?.base);
|
|
31
|
+
const _as = $derived(as ?? preset?.as);
|
|
32
|
+
const _restProps = $derived.by(() => {
|
|
33
|
+
const { class: klass, base, as, ...restPresetProps } = preset ?? {};
|
|
34
|
+
return { ...restPresetProps, ...restProps };
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const isSnippet = $derived(typeof _base === 'function' && _base.length === 1 && !_base.prototype);
|
|
38
|
+
|
|
39
|
+
const snippet = $derived(_base as SnippetBase);
|
|
40
|
+
|
|
41
|
+
const atom = rootBond?.state?.props?.renderers?.html ?? HtmlElement;
|
|
42
|
+
|
|
43
|
+
const Component = $derived(base ?? atom) as ComponentBase;
|
|
44
|
+
|
|
45
|
+
function compilePresetPlaceholder(klass: ClassValue): ReturnType<typeof toClassValue> {
|
|
46
|
+
if (Array.isArray(klass)) {
|
|
47
|
+
return klass.map((k) => compilePresetPlaceholder(k));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const compiled = toClassValue.apply(bond, [klass, bond]);
|
|
51
|
+
|
|
52
|
+
if (Array.isArray(compiled)) {
|
|
53
|
+
return compiled.map((c) => compilePresetPlaceholder(c));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (typeof compiled === 'string') {
|
|
57
|
+
return compiled.replace('$preset', cn(preset?.class));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return compiled;
|
|
61
|
+
}
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
{#if isSnippet}
|
|
65
|
+
{@render snippet({ class: _klass, as: _as, base: _base, children, ..._restProps })}
|
|
66
|
+
{:else}
|
|
67
|
+
<Component class={_klass} as={_as} {..._restProps}>
|
|
68
|
+
{@render children?.()}
|
|
69
|
+
</Component>
|
|
70
|
+
{/if}
|
|
@@ -1,79 +1,79 @@
|
|
|
1
|
-
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
-
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
-
import { InputBond, InputState, type InputStateProps } from './bond.svelte';
|
|
4
|
-
import { defineProperty, defineState, toClassValue } from '../../utils';
|
|
5
|
-
import {
|
|
6
|
-
HtmlAtom,
|
|
7
|
-
type ElementType,
|
|
8
|
-
type HtmlAtomProps,
|
|
9
|
-
type Base
|
|
10
|
-
} from '../atom';
|
|
11
|
-
|
|
12
|
-
type Element = ElementType<E>;
|
|
13
|
-
|
|
14
|
-
let {
|
|
15
|
-
class: klass = '',
|
|
16
|
-
value,
|
|
17
|
-
checked = undefined,
|
|
18
|
-
files = [],
|
|
19
|
-
preset = 'input',
|
|
20
|
-
children = undefined,
|
|
21
|
-
factory = _factory,
|
|
22
|
-
...restProps
|
|
23
|
-
}: HtmlAtomProps<E, B> & HTMLAttributes<Element> = $props();
|
|
24
|
-
|
|
25
|
-
const bondProps = defineState<InputStateProps>([
|
|
26
|
-
defineProperty(
|
|
27
|
-
'value',
|
|
28
|
-
() => value,
|
|
29
|
-
(v) => {
|
|
30
|
-
value = v;
|
|
31
|
-
}
|
|
32
|
-
),
|
|
33
|
-
|
|
34
|
-
defineProperty(
|
|
35
|
-
'checked',
|
|
36
|
-
() => checked,
|
|
37
|
-
(v) => {
|
|
38
|
-
checked = v;
|
|
39
|
-
}
|
|
40
|
-
),
|
|
41
|
-
|
|
42
|
-
defineProperty(
|
|
43
|
-
'files',
|
|
44
|
-
() => files,
|
|
45
|
-
(v) => {
|
|
46
|
-
files = [...v];
|
|
47
|
-
}
|
|
48
|
-
)
|
|
49
|
-
]);
|
|
50
|
-
const bond = _factory(bondProps).share();
|
|
51
|
-
|
|
52
|
-
const rootProps = $derived({
|
|
53
|
-
...bond.root(),
|
|
54
|
-
...restProps
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
function _factory(props: typeof bondProps) {
|
|
58
|
-
const bondState = new InputState(() => props);
|
|
59
|
-
|
|
60
|
-
return new InputBond(bondState);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export function getBond() {
|
|
64
|
-
return bond;
|
|
65
|
-
}
|
|
66
|
-
</script>
|
|
67
|
-
|
|
68
|
-
<HtmlAtom
|
|
69
|
-
{preset}
|
|
70
|
-
class={[
|
|
71
|
-
'border-border text-foreground bg-input relative flex h-10 items-center overflow-hidden rounded-md border',
|
|
72
|
-
'$preset',
|
|
73
|
-
klass
|
|
74
|
-
]}
|
|
75
|
-
{bond}
|
|
76
|
-
{...rootProps}
|
|
77
|
-
>
|
|
78
|
-
{@render children?.({ input: bond })}
|
|
79
|
-
</HtmlAtom>
|
|
1
|
+
<script lang="ts" generics="E extends keyof HTMLElementTagNameMap = 'div', B extends Base = Base">
|
|
2
|
+
import type { HTMLAttributes } from 'svelte/elements';
|
|
3
|
+
import { InputBond, InputState, type InputStateProps } from './bond.svelte';
|
|
4
|
+
import { defineProperty, defineState, toClassValue } from '../../utils';
|
|
5
|
+
import {
|
|
6
|
+
HtmlAtom,
|
|
7
|
+
type ElementType,
|
|
8
|
+
type HtmlAtomProps,
|
|
9
|
+
type Base
|
|
10
|
+
} from '../atom';
|
|
11
|
+
|
|
12
|
+
type Element = ElementType<E>;
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
class: klass = '',
|
|
16
|
+
value,
|
|
17
|
+
checked = undefined,
|
|
18
|
+
files = [],
|
|
19
|
+
preset = 'input',
|
|
20
|
+
children = undefined,
|
|
21
|
+
factory = _factory,
|
|
22
|
+
...restProps
|
|
23
|
+
}: HtmlAtomProps<E, B> & HTMLAttributes<Element> = $props();
|
|
24
|
+
|
|
25
|
+
const bondProps = defineState<InputStateProps>([
|
|
26
|
+
defineProperty(
|
|
27
|
+
'value',
|
|
28
|
+
() => value,
|
|
29
|
+
(v) => {
|
|
30
|
+
value = v;
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
|
|
34
|
+
defineProperty(
|
|
35
|
+
'checked',
|
|
36
|
+
() => checked,
|
|
37
|
+
(v) => {
|
|
38
|
+
checked = v;
|
|
39
|
+
}
|
|
40
|
+
),
|
|
41
|
+
|
|
42
|
+
defineProperty(
|
|
43
|
+
'files',
|
|
44
|
+
() => files,
|
|
45
|
+
(v) => {
|
|
46
|
+
files = [...v];
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
]);
|
|
50
|
+
const bond = _factory(bondProps).share();
|
|
51
|
+
|
|
52
|
+
const rootProps = $derived({
|
|
53
|
+
...bond.root(),
|
|
54
|
+
...restProps
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
function _factory(props: typeof bondProps) {
|
|
58
|
+
const bondState = new InputState(() => props);
|
|
59
|
+
|
|
60
|
+
return new InputBond(bondState);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getBond() {
|
|
64
|
+
return bond;
|
|
65
|
+
}
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<HtmlAtom
|
|
69
|
+
{preset}
|
|
70
|
+
class={[
|
|
71
|
+
'border-border text-foreground bg-input relative flex h-10 items-center overflow-hidden rounded-md border',
|
|
72
|
+
'$preset',
|
|
73
|
+
klass
|
|
74
|
+
]}
|
|
75
|
+
{bond}
|
|
76
|
+
{...rootProps}
|
|
77
|
+
>
|
|
78
|
+
{@render children?.({ input: bond })}
|
|
79
|
+
</HtmlAtom>
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
<script module>
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import { Input as AInput } from '.';
|
|
4
|
-
import Root from '../root/root.svelte';
|
|
5
|
-
import { Label } from '../label';
|
|
6
|
-
|
|
7
|
-
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
|
-
const { Story } = defineMeta({
|
|
9
|
-
title: 'Atoms/Input',
|
|
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="Input" args={{}}>
|
|
24
|
-
<Root class="p-4">
|
|
25
|
-
<div class="flex flex-col">
|
|
26
|
-
<Label for="price-input">Price</Label>
|
|
27
|
-
<AInput.Root>
|
|
28
|
-
<AInput.Icon class="text-foreground box-content px-0">$</AInput.Icon>
|
|
29
|
-
<AInput.Value id="price-input" class="border-border box-content border-x px-2 py-2">
|
|
30
|
-
<!-- -->
|
|
31
|
-
</AInput.Value>
|
|
32
|
-
<AInput.Icon class="text-foreground box-content px-2">.00</AInput.Icon>
|
|
33
|
-
|
|
34
|
-
<AInput.Placeholder class="text-foreground/20 pl-2">Hello World</AInput.Placeholder>
|
|
35
|
-
</AInput.Root>
|
|
36
|
-
</div>
|
|
37
|
-
</Root>
|
|
38
|
-
</Story>
|
|
1
|
+
<script module>
|
|
2
|
+
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
+
import { Input as AInput } from '.';
|
|
4
|
+
import Root from '../root/root.svelte';
|
|
5
|
+
import { Label } from '../label';
|
|
6
|
+
|
|
7
|
+
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories
|
|
8
|
+
const { Story } = defineMeta({
|
|
9
|
+
title: 'Atoms/Input',
|
|
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="Input" args={{}}>
|
|
24
|
+
<Root class="p-4">
|
|
25
|
+
<div class="flex flex-col">
|
|
26
|
+
<Label for="price-input">Price</Label>
|
|
27
|
+
<AInput.Root>
|
|
28
|
+
<AInput.Icon class="text-foreground box-content px-0">$</AInput.Icon>
|
|
29
|
+
<AInput.Value id="price-input" class="border-border box-content border-x px-2 py-2">
|
|
30
|
+
<!-- -->
|
|
31
|
+
</AInput.Value>
|
|
32
|
+
<AInput.Icon class="text-foreground box-content px-2">.00</AInput.Icon>
|
|
33
|
+
|
|
34
|
+
<AInput.Placeholder class="text-foreground/20 pl-2">Hello World</AInput.Placeholder>
|
|
35
|
+
</AInput.Root>
|
|
36
|
+
</div>
|
|
37
|
+
</Root>
|
|
38
|
+
</Story>
|
|
@@ -1,103 +1,121 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
export type RootPortals = 'root.l0' | 'root.l1' | 'root.l2' | 'root.l3';
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<script lang="ts">
|
|
6
|
-
import { cn, defineState, defineProperty } from '../../utils';
|
|
7
|
-
import { RootBond, RootBondState, type RootStateProps } from './bond.svelte';
|
|
8
|
-
import { Portal, ActivePortal, Portals } from '../portal';
|
|
9
|
-
import { Stack } from '../stack';
|
|
10
|
-
import { HtmlAtom } from '../atom';
|
|
11
|
-
import { HtmlElement, MathmlElement, SvgElement } from '../element';
|
|
12
|
-
|
|
13
|
-
let {
|
|
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
|
-
<Portal.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export type RootPortals = 'root.l0' | 'root.l1' | 'root.l2' | 'root.l3';
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script lang="ts">
|
|
6
|
+
import { cn, defineState, defineProperty } from '../../utils';
|
|
7
|
+
import { RootBond, RootBondState, type RootStateProps } from './bond.svelte';
|
|
8
|
+
import { Portal, ActivePortal, Portals } from '../portal';
|
|
9
|
+
import { Stack } from '../stack';
|
|
10
|
+
import { HtmlAtom } from '../atom';
|
|
11
|
+
import { HtmlElement, MathmlElement, SvgElement } from '../element';
|
|
12
|
+
|
|
13
|
+
let {
|
|
14
|
+
class: klass = '',
|
|
15
|
+
base = undefined,
|
|
16
|
+
children = undefined,
|
|
17
|
+
portals = undefined,
|
|
18
|
+
...restProps
|
|
19
|
+
} = $props();
|
|
20
|
+
|
|
21
|
+
let html: typeof HtmlElement | undefined = HtmlElement;
|
|
22
|
+
let svg: typeof SvgElement | undefined = undefined;
|
|
23
|
+
let mathml: typeof MathmlElement | undefined = undefined;
|
|
24
|
+
|
|
25
|
+
type Renderers = {
|
|
26
|
+
html?: typeof HtmlElement;
|
|
27
|
+
svg?: typeof SvgElement;
|
|
28
|
+
mathml?: typeof MathmlElement;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const renderers = defineState<Renderers>([
|
|
32
|
+
defineProperty('html', () => {
|
|
33
|
+
if (!html) {
|
|
34
|
+
import('../element/html-element.svelte').then((mod) => {
|
|
35
|
+
html = mod.default;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return html;
|
|
40
|
+
}),
|
|
41
|
+
defineProperty('svg', () => {
|
|
42
|
+
if (!svg) {
|
|
43
|
+
import('../element/svg-element.svelte').then((mod) => {
|
|
44
|
+
svg = mod.default;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return svg;
|
|
49
|
+
}),
|
|
50
|
+
defineProperty('mathml', () => {
|
|
51
|
+
if (!mathml) {
|
|
52
|
+
import('../element/mathml-element.svelte').then((mod) => {
|
|
53
|
+
mathml = mod.default;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return mathml;
|
|
58
|
+
})
|
|
59
|
+
]);
|
|
60
|
+
|
|
61
|
+
const bondProps = defineState<RootStateProps>([defineProperty('renderers', () => renderers)]);
|
|
62
|
+
|
|
63
|
+
const bondState = new RootBondState(() => bondProps);
|
|
64
|
+
const bond = new RootBond(bondState).share();
|
|
65
|
+
</script>
|
|
66
|
+
|
|
67
|
+
<Portals id="root">
|
|
68
|
+
<HtmlAtom
|
|
69
|
+
{@attach (node) => {
|
|
70
|
+
bond.rootElement = node;
|
|
71
|
+
}}
|
|
72
|
+
{base}
|
|
73
|
+
preset="root"
|
|
74
|
+
class={cn(
|
|
75
|
+
'atom-root bg-background text-foreground relative flex w-full flex-1 flex-col items-start font-sans',
|
|
76
|
+
'$preset',
|
|
77
|
+
klass
|
|
78
|
+
)}
|
|
79
|
+
{...restProps}
|
|
80
|
+
>
|
|
81
|
+
{#if portals}
|
|
82
|
+
{@render portals?.()}
|
|
83
|
+
{:else}
|
|
84
|
+
<Portal.Outer
|
|
85
|
+
base={Stack.Item}
|
|
86
|
+
id="root.l0"
|
|
87
|
+
class="pointer-events-none absolute inset-0 z-10 overflow-hidden"
|
|
88
|
+
>
|
|
89
|
+
<Portal.Inner />
|
|
90
|
+
</Portal.Outer>
|
|
91
|
+
|
|
92
|
+
<Portal.Outer
|
|
93
|
+
base={Stack.Item}
|
|
94
|
+
id="root.l1"
|
|
95
|
+
class="pointer-events-none absolute inset-0 z-10 overflow-hidden"
|
|
96
|
+
>
|
|
97
|
+
<Portal.Inner />
|
|
98
|
+
</Portal.Outer>
|
|
99
|
+
|
|
100
|
+
<Portal.Outer
|
|
101
|
+
base={Stack.Item}
|
|
102
|
+
id="root.l2"
|
|
103
|
+
class="pointer-events-none absolute inset-0 z-10 overflow-hidden"
|
|
104
|
+
>
|
|
105
|
+
<Portal.Inner />
|
|
106
|
+
</Portal.Outer>
|
|
107
|
+
|
|
108
|
+
<Portal.Outer
|
|
109
|
+
base={Stack.Item}
|
|
110
|
+
id="root.l3"
|
|
111
|
+
class="pointer-events-none absolute inset-0 z-10 overflow-hidden"
|
|
112
|
+
>
|
|
113
|
+
<Portal.Inner />
|
|
114
|
+
</Portal.Outer>
|
|
115
|
+
{/if}
|
|
116
|
+
|
|
117
|
+
<ActivePortal id="root.l0">
|
|
118
|
+
{@render children?.()}
|
|
119
|
+
</ActivePortal>
|
|
120
|
+
</HtmlAtom>
|
|
121
|
+
</Portals>
|
package/dist/runes/index.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export { colorScheme, type ColorScheme } from './color-scheme.svelte';
|
|
2
|
+
export { reducedMotion } from './reduced-motion.svelte';
|
|
3
|
+
export { container } from './container.svelte';
|
|
4
|
+
export { type Viewport, viewport } from './viewport.svelte';
|
|
2
5
|
export { mounted } from './lifecycles.svelte';
|
package/dist/runes/index.js
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A rune that tracks the user's motion preferences via the `prefers-reduced-motion` media query.
|
|
3
|
+
*
|
|
4
|
+
* @returns An object with a `current` getter that returns `true` if the user prefers reduced motion, `false` otherwise.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```svelte
|
|
8
|
+
* <script>
|
|
9
|
+
* import { reducedMotion } from '@svelte-atoms/core';
|
|
10
|
+
*
|
|
11
|
+
* const motion = reducedMotion();
|
|
12
|
+
* </script>
|
|
13
|
+
*
|
|
14
|
+
* {#if motion.current}
|
|
15
|
+
* <div>Animations disabled</div>
|
|
16
|
+
* {:else}
|
|
17
|
+
* <div class="animated">Animations enabled</div>
|
|
18
|
+
* {/if}
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function reducedMotion(): {
|
|
22
|
+
readonly current: boolean;
|
|
23
|
+
};
|