@svelte-atoms/core 1.0.0-alpha.27 → 1.0.0-alpha.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +856 -645
- package/dist/components/accordion/accordion-root.svelte +61 -61
- package/dist/components/accordion/item/accordion-item-body.svelte +42 -42
- package/dist/components/accordion/item/accordion-item-header.svelte +50 -50
- package/dist/components/accordion/item/accordion-item-indicator.svelte +50 -50
- package/dist/components/accordion/item/accordion-item-root.svelte +65 -65
- package/dist/components/alert/alert-actions.svelte +2 -1
- package/dist/components/alert/alert-close-button.svelte +18 -20
- package/dist/components/alert/alert-content.svelte +2 -1
- package/dist/components/alert/alert-description.svelte +2 -1
- package/dist/components/alert/alert-icon.svelte +2 -1
- package/dist/components/alert/alert-root.svelte +3 -2
- package/dist/components/alert/alert-title.svelte +2 -1
- package/dist/components/alert/alert.stories.svelte +401 -40
- package/dist/components/alert/alert.stories.svelte.d.ts +2 -5
- package/dist/components/atom/html-atom.svelte +205 -201
- package/dist/components/atom/snippet-renderer.svelte +5 -0
- package/dist/components/atom/snippet-renderer.svelte.d.ts +5 -0
- package/dist/components/avatar/avatar.stories.svelte.d.ts +1 -1
- package/dist/components/badge/badge.stories.svelte.d.ts +1 -1
- package/dist/components/breadcrumb/breadcrumb.stories.svelte.d.ts +1 -1
- package/dist/components/button/button.stories.svelte +60 -57
- package/dist/components/calendar/atoms.d.ts +5 -0
- package/dist/components/calendar/atoms.js +5 -0
- package/dist/components/calendar/bond.svelte.d.ts +72 -0
- package/dist/components/calendar/bond.svelte.js +132 -0
- package/dist/components/calendar/calendar-body.svelte +107 -0
- package/dist/components/calendar/calendar-body.svelte.d.ts +8 -0
- package/dist/components/calendar/calendar-day.svelte +97 -0
- package/dist/components/calendar/calendar-day.svelte.d.ts +4 -0
- package/dist/components/calendar/calendar-header.svelte +33 -0
- package/dist/components/calendar/calendar-header.svelte.d.ts +7 -0
- package/dist/components/calendar/calendar-root.svelte +208 -0
- package/dist/components/calendar/calendar-root.svelte.d.ts +8 -0
- package/dist/components/calendar/calendar-week-day.svelte +34 -0
- package/dist/components/calendar/calendar-week-day.svelte.d.ts +9 -0
- package/dist/components/calendar/calendar.css +26 -0
- package/dist/components/calendar/calendar.stories.svelte +36 -0
- package/dist/components/calendar/calendar.stories.svelte.d.ts +6 -0
- package/dist/components/calendar/index.d.ts +4 -0
- package/dist/components/calendar/index.js +4 -0
- package/dist/components/calendar/runes.svelte.d.ts +3 -0
- package/dist/components/calendar/runes.svelte.js +25 -0
- package/dist/components/calendar/types.d.ts +62 -0
- package/dist/components/calendar/types.js +1 -0
- package/dist/components/card/card-body.svelte +39 -39
- package/dist/components/card/card-description.svelte +41 -41
- package/dist/components/card/card-footer.svelte +41 -41
- package/dist/components/card/card-header.svelte +41 -41
- package/dist/components/card/card-media.svelte +41 -41
- package/dist/components/card/card-root.svelte +91 -91
- package/dist/components/card/card-subtitle.svelte +41 -41
- package/dist/components/card/card-title.svelte +45 -45
- package/dist/components/collapsible/collapsible-body.svelte +39 -39
- package/dist/components/collapsible/collapsible-header.svelte +39 -39
- package/dist/components/collapsible/collapsible-indicator.svelte +50 -50
- package/dist/components/collapsible/collapsible-root.svelte +66 -66
- package/dist/components/combobox/combobox-root.svelte +65 -65
- package/dist/components/container/container.stories.svelte.d.ts +1 -1
- package/dist/components/contextmenu/contextmenu-trigger.svelte.d.ts +1 -1
- package/dist/components/datagrid/bond.svelte.d.ts +2 -2
- package/dist/components/datagrid/datagrid-body.svelte +37 -37
- package/dist/components/datagrid/datagrid-checkbox.svelte +101 -101
- package/dist/components/datagrid/datagrid-footer.svelte +34 -34
- package/dist/components/datagrid/datagrid-header.svelte +49 -49
- package/dist/components/datagrid/datagrid-root.svelte +59 -59
- package/dist/components/datagrid/td/datagrid-td.svelte +66 -66
- package/dist/components/datagrid/th/datagrid-th.svelte +106 -106
- package/dist/components/datagrid/tr/datagrid-tr.svelte +88 -88
- package/dist/components/date-picker/atoms.d.ts +7 -0
- package/dist/components/date-picker/atoms.js +7 -0
- package/dist/components/date-picker/bond.svelte.d.ts +67 -0
- package/dist/components/date-picker/bond.svelte.js +174 -0
- package/dist/components/date-picker/date-picker-calendar.svelte +42 -0
- package/dist/components/date-picker/date-picker-calendar.svelte.d.ts +7 -0
- package/dist/components/date-picker/date-picker-header.svelte +105 -0
- package/dist/components/date-picker/date-picker-header.svelte.d.ts +7 -0
- package/dist/components/date-picker/date-picker-months.svelte +150 -0
- package/dist/components/date-picker/date-picker-months.svelte.d.ts +7 -0
- package/dist/components/date-picker/date-picker-root.svelte +94 -0
- package/dist/components/date-picker/date-picker-root.svelte.d.ts +17 -0
- package/dist/components/date-picker/date-picker-years.svelte +214 -0
- package/dist/components/date-picker/date-picker-years.svelte.d.ts +7 -0
- package/dist/components/date-picker/date-picker.stories.svelte +51 -0
- package/dist/components/date-picker/date-picker.stories.svelte.d.ts +3 -0
- package/dist/components/date-picker/index.d.ts +3 -0
- package/dist/components/date-picker/index.js +3 -0
- package/dist/components/date-picker/types.d.ts +1 -0
- package/dist/components/date-picker/types.js +1 -0
- package/dist/components/dialog/dialog-body.svelte +39 -39
- package/dist/components/dialog/dialog-close-button.svelte +58 -58
- package/dist/components/dialog/dialog-content.svelte +62 -62
- package/dist/components/dialog/dialog-description.svelte +40 -40
- package/dist/components/dialog/dialog-footer.svelte +39 -39
- package/dist/components/dialog/dialog-header.svelte +39 -39
- package/dist/components/dialog/dialog-root.svelte +110 -110
- package/dist/components/dialog/dialog-title.svelte +41 -41
- package/dist/components/drawer/drawer-backdrop.svelte +38 -38
- package/dist/components/drawer/drawer-body.svelte +42 -42
- package/dist/components/drawer/drawer-content.svelte +42 -42
- package/dist/components/drawer/drawer-description.svelte +44 -44
- package/dist/components/drawer/drawer-footer.svelte +41 -41
- package/dist/components/drawer/drawer-header.svelte +43 -43
- package/dist/components/drawer/drawer-root.svelte +93 -93
- package/dist/components/drawer/drawer-title.svelte +44 -44
- package/dist/components/dropdown/dropdown-query.svelte +54 -54
- package/dist/components/dropdown/dropdown-root.svelte +59 -59
- package/dist/components/dropdown/dropdown-trigger.svelte +41 -41
- package/dist/components/dropdown/dropdown-value.svelte +60 -60
- package/dist/components/element/html-element.svelte +85 -85
- package/dist/components/form/bond.svelte.d.ts +1 -1
- package/dist/components/form/field/field-control.svelte +48 -48
- package/dist/components/form/field/field-label.svelte +24 -24
- package/dist/components/form/field/field-root.svelte +59 -59
- package/dist/components/icon/icon.svelte +44 -44
- package/dist/components/image/image.stories.svelte.d.ts +1 -1
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +3 -0
- package/dist/components/input/input-control.svelte +103 -103
- package/dist/components/label/label.svelte +25 -25
- package/dist/components/popover/popover-arrow.svelte +111 -111
- package/dist/components/popover/popover-content.svelte +46 -7
- package/dist/components/popover/popover-root.svelte +48 -49
- package/dist/components/popover/popover.stories.svelte +52 -67
- package/dist/components/portal/portal-root.svelte +83 -83
- package/dist/components/portal/teleport.svelte +50 -50
- 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 +24 -0
- package/dist/components/qr-code/qr-code.stories.svelte.d.ts +26 -0
- package/dist/components/qr-code/qr-code.svelte +25 -0
- package/dist/components/qr-code/qr-code.svelte.d.ts +6 -0
- package/dist/components/radio/radio.svelte +109 -109
- package/dist/components/radio/types.svelte.d.ts +1 -1
- package/dist/components/scrollable/scrollable-container.svelte +82 -82
- package/dist/components/scrollable/scrollable-content.svelte +41 -41
- package/dist/components/scrollable/scrollable-root.svelte +100 -100
- package/dist/components/scrollable/scrollable-thumb.svelte +75 -75
- package/dist/components/scrollable/scrollable-track.svelte +59 -59
- package/dist/components/scrollable/scrollable.stories.svelte.d.ts +1 -1
- package/dist/components/tabs/tab/tab-body.svelte +52 -52
- package/dist/components/tabs/tab/tab-description.svelte +41 -41
- package/dist/components/tabs/tab/tab-header.svelte +71 -71
- package/dist/components/tabs/tab/tab-root.svelte +86 -86
- package/dist/components/toast/toast-description.svelte +38 -38
- package/dist/components/toast/toast-root.svelte +61 -61
- package/dist/components/toast/toast-title.svelte +35 -35
- package/dist/components/tree/tree-body.svelte +39 -39
- package/dist/components/tree/tree-header.svelte +54 -54
- package/dist/components/tree/tree-indicator.svelte +40 -40
- package/dist/components/tree/tree-root.svelte +65 -65
- package/dist/components/virtual/virtual-root.svelte +239 -239
- package/dist/context/preset.svelte.d.ts +1 -1
- package/dist/icons/icon-arrow-down.svelte.d.ts +1 -1
- package/dist/icons/icon-checkmark.svelte.d.ts +1 -1
- package/dist/icons/icon-close.svelte.d.ts +1 -1
- package/dist/icons/icon-more-vert.svelte.d.ts +1 -1
- package/dist/runes/container.svelte.d.ts +2 -2
- package/dist/shared/bond.svelte.d.ts +1 -1
- package/dist/utils/state.d.ts +1 -1
- package/dist/utils/state.js +2 -1
- package/llm/variants.md +1261 -712
- package/package.json +464 -437
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { getRadioGroupContext } from './context';
|
|
3
|
-
import { Stack } from '../stack';
|
|
4
|
-
import { toClassValue } from '../../utils';
|
|
5
|
-
import { HtmlAtom, type Base } from '../atom';
|
|
6
|
-
|
|
7
|
-
const radioGroupContext = getRadioGroupContext();
|
|
8
|
-
|
|
9
|
-
let {
|
|
10
|
-
class: klass = '',
|
|
11
|
-
value = $bindable(undefined),
|
|
12
|
-
group = $bindable(),
|
|
13
|
-
id = undefined,
|
|
14
|
-
name = undefined,
|
|
15
|
-
disabled = false,
|
|
16
|
-
required = false,
|
|
17
|
-
readonly = false,
|
|
18
|
-
onchange = undefined,
|
|
19
|
-
oninput = undefined,
|
|
20
|
-
checkedContent = undefined,
|
|
21
|
-
...restProps
|
|
22
|
-
} = $props();
|
|
23
|
-
|
|
24
|
-
const _disabled = $derived(radioGroupContext?.disabled);
|
|
25
|
-
const _required = $derived(radioGroupContext?.required);
|
|
26
|
-
const _readonly = $derived(radioGroupContext?.readonly);
|
|
27
|
-
const _name = $derived(radioGroupContext?.name);
|
|
28
|
-
|
|
29
|
-
const proxy = {
|
|
30
|
-
get current() {
|
|
31
|
-
return radioGroupContext?.value ?? group;
|
|
32
|
-
},
|
|
33
|
-
set current(v) {
|
|
34
|
-
group = v;
|
|
35
|
-
if (radioGroupContext) {
|
|
36
|
-
radioGroupContext.value = v;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const isDisabled = $derived(_disabled || disabled);
|
|
42
|
-
const isRequired = $derived(_required || required);
|
|
43
|
-
const isReadonly = $derived(_readonly || readonly);
|
|
44
|
-
const isChecked = $derived(proxy.current === value);
|
|
45
|
-
|
|
46
|
-
function handleChange(ev: Event) {
|
|
47
|
-
const checked = (ev.currentTarget as HTMLInputElement)?.checked ?? false;
|
|
48
|
-
|
|
49
|
-
onchange?.(ev, {
|
|
50
|
-
checked,
|
|
51
|
-
value: checked,
|
|
52
|
-
type: 'boolean'
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function handleInput(ev: Event) {
|
|
57
|
-
const currentTarget = ev.currentTarget as HTMLInputElement;
|
|
58
|
-
const _checked = currentTarget?.checked ?? false;
|
|
59
|
-
|
|
60
|
-
oninput?.(ev, {
|
|
61
|
-
checked: _checked,
|
|
62
|
-
value: _checked,
|
|
63
|
-
type: 'boolean'
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
if (ev.defaultPrevented) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
</script>
|
|
71
|
-
|
|
72
|
-
<Stack.Root
|
|
73
|
-
preset="radio"
|
|
74
|
-
class={[
|
|
75
|
-
'text-foreground bg-input box-border inline-flex aspect-square size-4 max-w-fit cursor-pointer place-items-center rounded-full border p-0',
|
|
76
|
-
isDisabled && 'pointer-events-none opacity-50',
|
|
77
|
-
'$preset',
|
|
78
|
-
toClassValue.apply(null, [klass, {}])
|
|
79
|
-
]}
|
|
80
|
-
as="label"
|
|
81
|
-
{...restProps}
|
|
82
|
-
>
|
|
83
|
-
<Stack.Item class="pointer-events-none flex size-full">
|
|
84
|
-
<input
|
|
85
|
-
bind:group={proxy.current}
|
|
86
|
-
{id}
|
|
87
|
-
{value}
|
|
88
|
-
class="pointer-events-auto size-0 opacity-0"
|
|
89
|
-
type="radio"
|
|
90
|
-
name={_name ?? name}
|
|
91
|
-
disabled={isDisabled}
|
|
92
|
-
required={isRequired}
|
|
93
|
-
readonly={isReadonly}
|
|
94
|
-
onchange={handleChange}
|
|
95
|
-
oninput={handleInput}
|
|
96
|
-
/>
|
|
97
|
-
</Stack.Item>
|
|
98
|
-
|
|
99
|
-
{#if isChecked}
|
|
100
|
-
{#if checkedContent}
|
|
101
|
-
<HtmlAtom
|
|
102
|
-
class="rounded-inherit pointer-events-none size-1/2 bg-current"
|
|
103
|
-
base={checkedContent}
|
|
104
|
-
/>
|
|
105
|
-
{:else}
|
|
106
|
-
<Stack.Item class="rounded-inherit pointer-events-none size-1/2 bg-current"></Stack.Item>
|
|
107
|
-
{/if}
|
|
108
|
-
{/if}
|
|
109
|
-
</Stack.Root>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getRadioGroupContext } from './context';
|
|
3
|
+
import { Stack } from '../stack';
|
|
4
|
+
import { toClassValue } from '../../utils';
|
|
5
|
+
import { HtmlAtom, type Base } from '../atom';
|
|
6
|
+
|
|
7
|
+
const radioGroupContext = getRadioGroupContext();
|
|
8
|
+
|
|
9
|
+
let {
|
|
10
|
+
class: klass = '',
|
|
11
|
+
value = $bindable(undefined),
|
|
12
|
+
group = $bindable(),
|
|
13
|
+
id = undefined,
|
|
14
|
+
name = undefined,
|
|
15
|
+
disabled = false,
|
|
16
|
+
required = false,
|
|
17
|
+
readonly = false,
|
|
18
|
+
onchange = undefined,
|
|
19
|
+
oninput = undefined,
|
|
20
|
+
checkedContent = undefined,
|
|
21
|
+
...restProps
|
|
22
|
+
} = $props();
|
|
23
|
+
|
|
24
|
+
const _disabled = $derived(radioGroupContext?.disabled);
|
|
25
|
+
const _required = $derived(radioGroupContext?.required);
|
|
26
|
+
const _readonly = $derived(radioGroupContext?.readonly);
|
|
27
|
+
const _name = $derived(radioGroupContext?.name);
|
|
28
|
+
|
|
29
|
+
const proxy = {
|
|
30
|
+
get current() {
|
|
31
|
+
return radioGroupContext?.value ?? group;
|
|
32
|
+
},
|
|
33
|
+
set current(v) {
|
|
34
|
+
group = v;
|
|
35
|
+
if (radioGroupContext) {
|
|
36
|
+
radioGroupContext.value = v;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const isDisabled = $derived(_disabled || disabled);
|
|
42
|
+
const isRequired = $derived(_required || required);
|
|
43
|
+
const isReadonly = $derived(_readonly || readonly);
|
|
44
|
+
const isChecked = $derived(proxy.current === value);
|
|
45
|
+
|
|
46
|
+
function handleChange(ev: Event) {
|
|
47
|
+
const checked = (ev.currentTarget as HTMLInputElement)?.checked ?? false;
|
|
48
|
+
|
|
49
|
+
onchange?.(ev, {
|
|
50
|
+
checked,
|
|
51
|
+
value: checked,
|
|
52
|
+
type: 'boolean'
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function handleInput(ev: Event) {
|
|
57
|
+
const currentTarget = ev.currentTarget as HTMLInputElement;
|
|
58
|
+
const _checked = currentTarget?.checked ?? false;
|
|
59
|
+
|
|
60
|
+
oninput?.(ev, {
|
|
61
|
+
checked: _checked,
|
|
62
|
+
value: _checked,
|
|
63
|
+
type: 'boolean'
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
if (ev.defaultPrevented) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<Stack.Root
|
|
73
|
+
preset="radio"
|
|
74
|
+
class={[
|
|
75
|
+
'text-foreground bg-input box-border inline-flex aspect-square size-4 max-w-fit cursor-pointer place-items-center rounded-full border p-0',
|
|
76
|
+
isDisabled && 'pointer-events-none opacity-50',
|
|
77
|
+
'$preset',
|
|
78
|
+
toClassValue.apply(null, [klass, {}])
|
|
79
|
+
]}
|
|
80
|
+
as="label"
|
|
81
|
+
{...restProps}
|
|
82
|
+
>
|
|
83
|
+
<Stack.Item class="pointer-events-none flex size-full">
|
|
84
|
+
<input
|
|
85
|
+
bind:group={proxy.current}
|
|
86
|
+
{id}
|
|
87
|
+
{value}
|
|
88
|
+
class="pointer-events-auto size-0 opacity-0"
|
|
89
|
+
type="radio"
|
|
90
|
+
name={_name ?? name}
|
|
91
|
+
disabled={isDisabled}
|
|
92
|
+
required={isRequired}
|
|
93
|
+
readonly={isReadonly}
|
|
94
|
+
onchange={handleChange}
|
|
95
|
+
oninput={handleInput}
|
|
96
|
+
/>
|
|
97
|
+
</Stack.Item>
|
|
98
|
+
|
|
99
|
+
{#if isChecked}
|
|
100
|
+
{#if checkedContent}
|
|
101
|
+
<HtmlAtom
|
|
102
|
+
class="rounded-inherit pointer-events-none size-1/2 bg-current"
|
|
103
|
+
base={checkedContent}
|
|
104
|
+
/>
|
|
105
|
+
{:else}
|
|
106
|
+
<Stack.Item class="rounded-inherit pointer-events-none size-1/2 bg-current"></Stack.Item>
|
|
107
|
+
{/if}
|
|
108
|
+
{/if}
|
|
109
|
+
</Stack.Root>
|
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
export type { ScrollableContainerProps } from './types';
|
|
3
|
-
</script>
|
|
4
|
-
|
|
5
|
-
<script lang="ts" generics="T extends keyof HTMLElementTagNameMap">
|
|
6
|
-
import type { ScrollableContainerProps } from './types';
|
|
7
|
-
import { ScrollableBond } from './bond.svelte';
|
|
8
|
-
import { resizeObserver } from '../../attachments/resize-observer.svelte';
|
|
9
|
-
import { HtmlAtom } from '../atom';
|
|
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
|
-
...restProps
|
|
20
|
-
}: ScrollableContainerProps<T> = $props();
|
|
21
|
-
|
|
22
|
-
const bond = ScrollableBond.get();
|
|
23
|
-
|
|
24
|
-
if (!bond) {
|
|
25
|
-
throw new Error('ScrollableContainer must be used within a ScrollableRoot');
|
|
26
|
-
}
|
|
27
|
-
</script>
|
|
28
|
-
|
|
29
|
-
<HtmlAtom
|
|
30
|
-
{@attach (node) => {
|
|
31
|
-
if (!bond) return;
|
|
32
|
-
|
|
33
|
-
return resizeObserver(() => {
|
|
34
|
-
bond.state.props.clientWidth = node.clientWidth;
|
|
35
|
-
bond.state.props.clientHeight = node.clientHeight;
|
|
36
|
-
bond.state.props.scrollWidth = node.scrollWidth;
|
|
37
|
-
bond.state.props.scrollHeight = node.scrollHeight;
|
|
38
|
-
})(node);
|
|
39
|
-
}}
|
|
40
|
-
{bond}
|
|
41
|
-
preset="scrollable.container"
|
|
42
|
-
class={[
|
|
43
|
-
'scrollable-container border-border h-full max-h-full w-full overflow-auto',
|
|
44
|
-
'$preset',
|
|
45
|
-
klass
|
|
46
|
-
]}
|
|
47
|
-
enter={enter?.bind(bond.state)}
|
|
48
|
-
exit={exit?.bind(bond.state)}
|
|
49
|
-
initial={initial?.bind(bond.state)}
|
|
50
|
-
animate={animate?.bind(bond.state)}
|
|
51
|
-
onmount={onmount?.bind(bond.state)}
|
|
52
|
-
ondestroy={ondestroy?.bind(bond.state)}
|
|
53
|
-
{...bond.container()}
|
|
54
|
-
{...restProps}
|
|
55
|
-
>
|
|
56
|
-
{#if children}
|
|
57
|
-
{@render children()}
|
|
58
|
-
{/if}
|
|
59
|
-
</HtmlAtom>
|
|
60
|
-
|
|
61
|
-
<style>
|
|
62
|
-
:global(.scrollable-container) {
|
|
63
|
-
scrollbar-width: none; /* Firefox */
|
|
64
|
-
-ms-overflow-style: none; /* Internet Explorer 10+ */
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
:global(.scrollable-container::-webkit-scrollbar) {
|
|
68
|
-
display: none; /* WebKit */
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
:global(.scrollable-container[data-hide-scrollbar='true']) {
|
|
72
|
-
--scrollbar-width: 0px;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
:global(.scrollable-container[data-hide-scrollbar='false']) {
|
|
76
|
-
--scrollbar-width: 16px;
|
|
77
|
-
/* margin-right: calc(-1 * var(--scrollbar-width, 16px));
|
|
78
|
-
margin-bottom: calc(-1 * var(--scrollbar-width, 16px));
|
|
79
|
-
padding-right: var(--scrollbar-width, 16px);
|
|
80
|
-
padding-bottom: var(--scrollbar-width, 16px); */
|
|
81
|
-
}
|
|
82
|
-
</style>
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
export type { ScrollableContainerProps } from './types';
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script lang="ts" generics="T extends keyof HTMLElementTagNameMap">
|
|
6
|
+
import type { ScrollableContainerProps } from './types';
|
|
7
|
+
import { ScrollableBond } from './bond.svelte';
|
|
8
|
+
import { resizeObserver } from '../../attachments/resize-observer.svelte';
|
|
9
|
+
import { HtmlAtom } from '../atom';
|
|
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
|
+
...restProps
|
|
20
|
+
}: ScrollableContainerProps<T> = $props();
|
|
21
|
+
|
|
22
|
+
const bond = ScrollableBond.get();
|
|
23
|
+
|
|
24
|
+
if (!bond) {
|
|
25
|
+
throw new Error('ScrollableContainer must be used within a ScrollableRoot');
|
|
26
|
+
}
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<HtmlAtom
|
|
30
|
+
{@attach (node) => {
|
|
31
|
+
if (!bond) return;
|
|
32
|
+
|
|
33
|
+
return resizeObserver(() => {
|
|
34
|
+
bond.state.props.clientWidth = node.clientWidth;
|
|
35
|
+
bond.state.props.clientHeight = node.clientHeight;
|
|
36
|
+
bond.state.props.scrollWidth = node.scrollWidth;
|
|
37
|
+
bond.state.props.scrollHeight = node.scrollHeight;
|
|
38
|
+
})(node);
|
|
39
|
+
}}
|
|
40
|
+
{bond}
|
|
41
|
+
preset="scrollable.container"
|
|
42
|
+
class={[
|
|
43
|
+
'scrollable-container border-border h-full max-h-full w-full overflow-auto',
|
|
44
|
+
'$preset',
|
|
45
|
+
klass
|
|
46
|
+
]}
|
|
47
|
+
enter={enter?.bind(bond.state)}
|
|
48
|
+
exit={exit?.bind(bond.state)}
|
|
49
|
+
initial={initial?.bind(bond.state)}
|
|
50
|
+
animate={animate?.bind(bond.state)}
|
|
51
|
+
onmount={onmount?.bind(bond.state)}
|
|
52
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
53
|
+
{...bond.container()}
|
|
54
|
+
{...restProps}
|
|
55
|
+
>
|
|
56
|
+
{#if children}
|
|
57
|
+
{@render children()}
|
|
58
|
+
{/if}
|
|
59
|
+
</HtmlAtom>
|
|
60
|
+
|
|
61
|
+
<style>
|
|
62
|
+
:global(.scrollable-container) {
|
|
63
|
+
scrollbar-width: none; /* Firefox */
|
|
64
|
+
-ms-overflow-style: none; /* Internet Explorer 10+ */
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
:global(.scrollable-container::-webkit-scrollbar) {
|
|
68
|
+
display: none; /* WebKit */
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
:global(.scrollable-container[data-hide-scrollbar='true']) {
|
|
72
|
+
--scrollbar-width: 0px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
:global(.scrollable-container[data-hide-scrollbar='false']) {
|
|
76
|
+
--scrollbar-width: 16px;
|
|
77
|
+
/* margin-right: calc(-1 * var(--scrollbar-width, 16px));
|
|
78
|
+
margin-bottom: calc(-1 * var(--scrollbar-width, 16px));
|
|
79
|
+
padding-right: var(--scrollbar-width, 16px);
|
|
80
|
+
padding-bottom: var(--scrollbar-width, 16px); */
|
|
81
|
+
}
|
|
82
|
+
</style>
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
<script lang="ts" generics="T extends keyof HTMLElementTagNameMap">
|
|
2
|
-
import type { ScrollableContentProps } from './types';
|
|
3
|
-
import { ScrollableBond } from './bond.svelte';
|
|
4
|
-
import { HtmlAtom } from '../atom';
|
|
5
|
-
|
|
6
|
-
const bond = ScrollableBond.get();
|
|
7
|
-
|
|
8
|
-
let {
|
|
9
|
-
class: klass = '',
|
|
10
|
-
children = undefined,
|
|
11
|
-
onmount = undefined,
|
|
12
|
-
ondestroy = undefined,
|
|
13
|
-
animate = undefined,
|
|
14
|
-
enter = undefined,
|
|
15
|
-
exit = undefined,
|
|
16
|
-
initial = undefined,
|
|
17
|
-
...restProps
|
|
18
|
-
}: ScrollableContentProps<T> = $props();
|
|
19
|
-
|
|
20
|
-
if (!bond) {
|
|
21
|
-
throw new Error('ScrollableContent must be used within a ScrollableRoot');
|
|
22
|
-
}
|
|
23
|
-
</script>
|
|
24
|
-
|
|
25
|
-
<HtmlAtom
|
|
26
|
-
{bond}
|
|
27
|
-
preset="scrollable.content"
|
|
28
|
-
class={['scrollable-content border-border h-full max-h-full', '$preset', klass]}
|
|
29
|
-
enter={enter?.bind(bond.state)}
|
|
30
|
-
exit={exit?.bind(bond.state)}
|
|
31
|
-
initial={initial?.bind(bond.state)}
|
|
32
|
-
animate={animate?.bind(bond.state)}
|
|
33
|
-
onmount={onmount?.bind(bond.state)}
|
|
34
|
-
ondestroy={ondestroy?.bind(bond.state)}
|
|
35
|
-
{...bond.content()}
|
|
36
|
-
{...restProps}
|
|
37
|
-
>
|
|
38
|
-
{#if children}
|
|
39
|
-
{@render children()}
|
|
40
|
-
{/if}
|
|
41
|
-
</HtmlAtom>
|
|
1
|
+
<script lang="ts" generics="T extends keyof HTMLElementTagNameMap">
|
|
2
|
+
import type { ScrollableContentProps } from './types';
|
|
3
|
+
import { ScrollableBond } from './bond.svelte';
|
|
4
|
+
import { HtmlAtom } from '../atom';
|
|
5
|
+
|
|
6
|
+
const bond = ScrollableBond.get();
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
class: klass = '',
|
|
10
|
+
children = undefined,
|
|
11
|
+
onmount = undefined,
|
|
12
|
+
ondestroy = undefined,
|
|
13
|
+
animate = undefined,
|
|
14
|
+
enter = undefined,
|
|
15
|
+
exit = undefined,
|
|
16
|
+
initial = undefined,
|
|
17
|
+
...restProps
|
|
18
|
+
}: ScrollableContentProps<T> = $props();
|
|
19
|
+
|
|
20
|
+
if (!bond) {
|
|
21
|
+
throw new Error('ScrollableContent must be used within a ScrollableRoot');
|
|
22
|
+
}
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<HtmlAtom
|
|
26
|
+
{bond}
|
|
27
|
+
preset="scrollable.content"
|
|
28
|
+
class={['scrollable-content border-border h-full max-h-full', '$preset', klass]}
|
|
29
|
+
enter={enter?.bind(bond.state)}
|
|
30
|
+
exit={exit?.bind(bond.state)}
|
|
31
|
+
initial={initial?.bind(bond.state)}
|
|
32
|
+
animate={animate?.bind(bond.state)}
|
|
33
|
+
onmount={onmount?.bind(bond.state)}
|
|
34
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
35
|
+
{...bond.content()}
|
|
36
|
+
{...restProps}
|
|
37
|
+
>
|
|
38
|
+
{#if children}
|
|
39
|
+
{@render children()}
|
|
40
|
+
{/if}
|
|
41
|
+
</HtmlAtom>
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
<script lang="ts" generics="T extends keyof HTMLElementTagNameMap">
|
|
2
|
-
import { defineProperty, defineState } from '../../utils';
|
|
3
|
-
import { HtmlAtom } from '../atom';
|
|
4
|
-
import { ScrollableBond, ScrollableState, type ScrollableStateProps } from './bond.svelte';
|
|
5
|
-
import type { ScrollableRootProps } from './types';
|
|
6
|
-
let {
|
|
7
|
-
scrollX = $bindable(0),
|
|
8
|
-
scrollY = $bindable(0),
|
|
9
|
-
scrollWidth = $bindable(0),
|
|
10
|
-
scrollHeight = $bindable(0),
|
|
11
|
-
clientWidth = $bindable(0),
|
|
12
|
-
clientHeight = $bindable(0),
|
|
13
|
-
class: klass = '',
|
|
14
|
-
disabled = false,
|
|
15
|
-
open = true,
|
|
16
|
-
factory = _factory,
|
|
17
|
-
children = undefined,
|
|
18
|
-
onmount = undefined,
|
|
19
|
-
ondestroy = undefined,
|
|
20
|
-
animate = undefined,
|
|
21
|
-
enter = undefined,
|
|
22
|
-
exit = undefined,
|
|
23
|
-
initial = undefined,
|
|
24
|
-
...restProps
|
|
25
|
-
}: ScrollableRootProps<T> = $props();
|
|
26
|
-
|
|
27
|
-
let isScrolling = $state(false);
|
|
28
|
-
|
|
29
|
-
const bondProps = defineState<ScrollableStateProps>([
|
|
30
|
-
defineProperty(
|
|
31
|
-
'scrollX',
|
|
32
|
-
() => scrollX,
|
|
33
|
-
(v) => (scrollX = v)
|
|
34
|
-
),
|
|
35
|
-
defineProperty(
|
|
36
|
-
'scrollY',
|
|
37
|
-
() => scrollY,
|
|
38
|
-
(v) => (scrollY = v)
|
|
39
|
-
),
|
|
40
|
-
defineProperty(
|
|
41
|
-
'scrollWidth',
|
|
42
|
-
() => scrollWidth,
|
|
43
|
-
(v) => (scrollWidth = v)
|
|
44
|
-
),
|
|
45
|
-
defineProperty(
|
|
46
|
-
'scrollHeight',
|
|
47
|
-
() => scrollHeight,
|
|
48
|
-
(v) => (scrollHeight = v)
|
|
49
|
-
),
|
|
50
|
-
defineProperty(
|
|
51
|
-
'clientWidth',
|
|
52
|
-
() => clientWidth,
|
|
53
|
-
(v) => (clientWidth = v)
|
|
54
|
-
),
|
|
55
|
-
defineProperty(
|
|
56
|
-
'clientHeight',
|
|
57
|
-
() => clientHeight,
|
|
58
|
-
(v) => (clientHeight = v)
|
|
59
|
-
),
|
|
60
|
-
defineProperty('disabled', () => disabled),
|
|
61
|
-
defineProperty(
|
|
62
|
-
'open',
|
|
63
|
-
() => open,
|
|
64
|
-
(v) => (open = v)
|
|
65
|
-
),
|
|
66
|
-
defineProperty(
|
|
67
|
-
'isScrolling',
|
|
68
|
-
() => isScrolling,
|
|
69
|
-
(v) => (isScrolling = v)
|
|
70
|
-
)
|
|
71
|
-
]);
|
|
72
|
-
|
|
73
|
-
const bond = factory(bondProps).share();
|
|
74
|
-
|
|
75
|
-
const rootProps = $derived({ ...bond.root(), ...restProps });
|
|
76
|
-
|
|
77
|
-
function _factory(props: typeof bondProps) {
|
|
78
|
-
const scrollableState = new ScrollableState(() => props);
|
|
79
|
-
return new ScrollableBond(scrollableState).share();
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export function getBond() {
|
|
83
|
-
return bond;
|
|
84
|
-
}
|
|
85
|
-
</script>
|
|
86
|
-
|
|
87
|
-
<HtmlAtom
|
|
88
|
-
{bond}
|
|
89
|
-
preset="scrollable"
|
|
90
|
-
class={['scrollable-root border-border relative box-content overflow-hidden', '$preset', klass]}
|
|
91
|
-
enter={enter?.bind(bond.state)}
|
|
92
|
-
exit={exit?.bind(bond.state)}
|
|
93
|
-
initial={initial?.bind(bond.state)}
|
|
94
|
-
animate={animate?.bind(bond.state)}
|
|
95
|
-
onmount={onmount?.bind(bond.state)}
|
|
96
|
-
ondestroy={ondestroy?.bind(bond.state)}
|
|
97
|
-
{...rootProps}
|
|
98
|
-
>
|
|
99
|
-
{@render children?.({ scrollable: bond })}
|
|
100
|
-
</HtmlAtom>
|
|
1
|
+
<script lang="ts" generics="T extends keyof HTMLElementTagNameMap">
|
|
2
|
+
import { defineProperty, defineState } from '../../utils';
|
|
3
|
+
import { HtmlAtom } from '../atom';
|
|
4
|
+
import { ScrollableBond, ScrollableState, type ScrollableStateProps } from './bond.svelte';
|
|
5
|
+
import type { ScrollableRootProps } from './types';
|
|
6
|
+
let {
|
|
7
|
+
scrollX = $bindable(0),
|
|
8
|
+
scrollY = $bindable(0),
|
|
9
|
+
scrollWidth = $bindable(0),
|
|
10
|
+
scrollHeight = $bindable(0),
|
|
11
|
+
clientWidth = $bindable(0),
|
|
12
|
+
clientHeight = $bindable(0),
|
|
13
|
+
class: klass = '',
|
|
14
|
+
disabled = false,
|
|
15
|
+
open = true,
|
|
16
|
+
factory = _factory,
|
|
17
|
+
children = undefined,
|
|
18
|
+
onmount = undefined,
|
|
19
|
+
ondestroy = undefined,
|
|
20
|
+
animate = undefined,
|
|
21
|
+
enter = undefined,
|
|
22
|
+
exit = undefined,
|
|
23
|
+
initial = undefined,
|
|
24
|
+
...restProps
|
|
25
|
+
}: ScrollableRootProps<T> = $props();
|
|
26
|
+
|
|
27
|
+
let isScrolling = $state(false);
|
|
28
|
+
|
|
29
|
+
const bondProps = defineState<ScrollableStateProps>([
|
|
30
|
+
defineProperty(
|
|
31
|
+
'scrollX',
|
|
32
|
+
() => scrollX,
|
|
33
|
+
(v) => (scrollX = v)
|
|
34
|
+
),
|
|
35
|
+
defineProperty(
|
|
36
|
+
'scrollY',
|
|
37
|
+
() => scrollY,
|
|
38
|
+
(v) => (scrollY = v)
|
|
39
|
+
),
|
|
40
|
+
defineProperty(
|
|
41
|
+
'scrollWidth',
|
|
42
|
+
() => scrollWidth,
|
|
43
|
+
(v) => (scrollWidth = v)
|
|
44
|
+
),
|
|
45
|
+
defineProperty(
|
|
46
|
+
'scrollHeight',
|
|
47
|
+
() => scrollHeight,
|
|
48
|
+
(v) => (scrollHeight = v)
|
|
49
|
+
),
|
|
50
|
+
defineProperty(
|
|
51
|
+
'clientWidth',
|
|
52
|
+
() => clientWidth,
|
|
53
|
+
(v) => (clientWidth = v)
|
|
54
|
+
),
|
|
55
|
+
defineProperty(
|
|
56
|
+
'clientHeight',
|
|
57
|
+
() => clientHeight,
|
|
58
|
+
(v) => (clientHeight = v)
|
|
59
|
+
),
|
|
60
|
+
defineProperty('disabled', () => disabled),
|
|
61
|
+
defineProperty(
|
|
62
|
+
'open',
|
|
63
|
+
() => open,
|
|
64
|
+
(v) => (open = v)
|
|
65
|
+
),
|
|
66
|
+
defineProperty(
|
|
67
|
+
'isScrolling',
|
|
68
|
+
() => isScrolling,
|
|
69
|
+
(v) => (isScrolling = v)
|
|
70
|
+
)
|
|
71
|
+
]);
|
|
72
|
+
|
|
73
|
+
const bond = factory(bondProps).share();
|
|
74
|
+
|
|
75
|
+
const rootProps = $derived({ ...bond.root(), ...restProps });
|
|
76
|
+
|
|
77
|
+
function _factory(props: typeof bondProps) {
|
|
78
|
+
const scrollableState = new ScrollableState(() => props);
|
|
79
|
+
return new ScrollableBond(scrollableState).share();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export function getBond() {
|
|
83
|
+
return bond;
|
|
84
|
+
}
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<HtmlAtom
|
|
88
|
+
{bond}
|
|
89
|
+
preset="scrollable"
|
|
90
|
+
class={['scrollable-root border-border relative box-content overflow-hidden', '$preset', klass]}
|
|
91
|
+
enter={enter?.bind(bond.state)}
|
|
92
|
+
exit={exit?.bind(bond.state)}
|
|
93
|
+
initial={initial?.bind(bond.state)}
|
|
94
|
+
animate={animate?.bind(bond.state)}
|
|
95
|
+
onmount={onmount?.bind(bond.state)}
|
|
96
|
+
ondestroy={ondestroy?.bind(bond.state)}
|
|
97
|
+
{...rootProps}
|
|
98
|
+
>
|
|
99
|
+
{@render children?.({ scrollable: bond })}
|
|
100
|
+
</HtmlAtom>
|