sheer-ui 0.4.0 → 0.4.3
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/package.json +1 -1
- package/src/lib/components/accordion/components/accordion-item.svelte +3 -3
- package/src/lib/components/accordion/components/accordion.svelte +29 -13
- package/src/lib/components/accordion/types.ts +3 -3
- package/src/lib/components/avatar/avatar.svelte.ts +34 -37
- package/src/lib/components/avatar/components/avatar-fallback.svelte +9 -6
- package/src/lib/components/avatar/components/avatar-image.svelte +18 -9
- package/src/lib/components/avatar/components/avatar.svelte +20 -16
- package/src/lib/components/checkbox/checkbox.svelte.ts +45 -55
- package/src/lib/components/checkbox/components/checkbox-group-label.svelte +9 -6
- package/src/lib/components/checkbox/components/checkbox-group.svelte +25 -14
- package/src/lib/components/checkbox/components/checkbox.svelte +39 -21
- package/src/lib/components/combobox/components/combobox.svelte +2 -2
- package/src/lib/components/combobox/select/components/select.svelte +2 -2
- package/src/lib/components/context-menu/components/context-menu-trigger.svelte +1 -1
- package/src/lib/components/date-field/date-field.svelte.ts +2 -3
- package/src/lib/components/dialog/components/dialog-close.svelte +13 -8
- package/src/lib/components/dialog/components/dialog-content-headless.svelte +14 -11
- package/src/lib/components/dialog/components/dialog-description.svelte +9 -6
- package/src/lib/components/dialog/components/dialog-overlay.svelte +10 -7
- package/src/lib/components/dialog/components/dialog-title.svelte +12 -7
- package/src/lib/components/dialog/components/dialog-trigger.svelte +12 -7
- package/src/lib/components/dialog/components/dialog.svelte +10 -4
- package/src/lib/components/dialog/components/modal-surface.svelte +11 -8
- package/src/lib/components/dialog/dialog.svelte.ts +73 -61
- package/src/lib/components/drawer/drawer.svelte +8 -3
- package/src/lib/components/link-preview/components/link-preview-content.svelte +15 -8
- package/src/lib/components/link-preview/components/link-preview-trigger.svelte +9 -6
- package/src/lib/components/link-preview/components/link-preview.svelte +19 -11
- package/src/lib/components/link-preview/link-preview.svelte.ts +42 -43
- package/src/lib/components/menu/components/menu-checkbox-group.svelte +6 -4
- package/src/lib/components/menu/components/menu-checkbox-item.svelte +11 -7
- package/src/lib/components/menu/menu.svelte.ts +29 -19
- package/src/lib/components/menubar/menubar.svelte.ts +7 -6
- package/src/lib/components/meter/components/meter.svelte +18 -9
- package/src/lib/components/meter/meter.svelte.ts +15 -18
- package/src/lib/components/navigation-menu/components/navigation-menu-content.svelte +1 -1
- package/src/lib/components/navigation-menu/components/navigation-menu-indicator.svelte +2 -2
- package/src/lib/components/navigation-menu/components/navigation-menu-trigger.svelte +1 -1
- package/src/lib/components/navigation-menu/navigation-menu.svelte.ts +57 -60
- package/src/lib/components/pagination/components/pagination-next-button.svelte +12 -7
- package/src/lib/components/pagination/components/pagination-page.svelte +15 -8
- package/src/lib/components/pagination/components/pagination-prev-button.svelte +12 -7
- package/src/lib/components/pagination/components/pagination.svelte +31 -18
- package/src/lib/components/pagination/pagination.svelte.ts +48 -64
- package/src/lib/components/pin-input/pin-input.svelte.ts +7 -8
- package/src/lib/components/pin-input/usePasswordManager.svelte.ts +2 -2
- package/src/lib/components/popover/components/popover-close.svelte +9 -6
- package/src/lib/components/popover/components/popover-content.svelte +12 -7
- package/src/lib/components/popover/components/popover-trigger.svelte +21 -10
- package/src/lib/components/popover/components/popover.svelte +9 -8
- package/src/lib/components/popover/popover.svelte.ts +68 -74
- package/src/lib/components/progress/components/progress.svelte +18 -9
- package/src/lib/components/progress/progress.svelte.ts +14 -17
- package/src/lib/components/scroll-area/scroll-area.svelte.ts +9 -10
- package/src/lib/components/separator/components/separator.svelte +15 -8
- package/src/lib/components/separator/separator.svelte.ts +12 -15
- package/src/lib/components/sidebar/sidebar-mobile-surface.svelte +8 -4
- package/src/lib/components/slider/components/slider.svelte +2 -1
- package/src/lib/components/tabs/components/tabs-content.svelte +12 -7
- package/src/lib/components/tabs/components/tabs-list.svelte +9 -6
- package/src/lib/components/tabs/components/tabs-trigger.svelte +15 -8
- package/src/lib/components/tabs/components/tabs.svelte +28 -17
- package/src/lib/components/tabs/tabs.svelte.ts +51 -67
- package/src/lib/components/time-field/time-field.svelte.ts +2 -2
- package/src/lib/components/toggle/components/toggle.svelte +19 -14
- package/src/lib/components/toggle/toggle.svelte.ts +15 -20
- package/src/lib/components/toggle-group/components/toggle-group-item.svelte +15 -8
- package/src/lib/components/toggle-group/components/toggle-group.svelte +28 -16
- package/src/lib/components/toggle-group/toggle-group.svelte.ts +33 -35
- package/src/lib/components/toolbar/components/toolbar-group-item.svelte +15 -8
- package/src/lib/components/toolbar/components/toolbar-group.svelte +19 -14
- package/src/lib/components/toolbar/toolbar.svelte.ts +28 -30
- package/src/lib/components/tooltip/components/tooltip-content.svelte +15 -8
- package/src/lib/components/tooltip/components/tooltip-provider.svelte +18 -7
- package/src/lib/components/tooltip/components/tooltip-trigger.svelte +21 -10
- package/src/lib/components/tooltip/components/tooltip.svelte +34 -21
- package/src/lib/components/tooltip/tooltip.svelte.ts +101 -125
- package/src/lib/internal/dismissible-layer/use-dismissable-layer.svelte.ts +3 -4
- package/src/lib/internal/escape-layer/use-escape-layer.svelte.ts +13 -29
- package/src/lib/internal/floating-layer/use-floating-layer.svelte.ts +26 -30
- package/src/lib/internal/group-value.svelte.ts +11 -10
- package/src/lib/internal/native-popover.svelte.ts +6 -6
- package/src/lib/internal/{roving-focus-group.ts → roving-focus-group.svelte.ts} +17 -19
- package/src/lib/internal/roving-focus-item.svelte.ts +12 -17
- package/src/lib/internal/selection.svelte.ts +55 -41
- package/src/lib/internal/{state-machine.ts → state-machine.svelte.ts} +6 -8
- package/src/lib/internal/timeout-fn.svelte.ts +6 -4
- package/src/lib/internal/tools/box.svelte.ts +5 -114
- package/src/lib/internal/tools/index.ts +1 -11
- package/src/lib/internal/tools/types.ts +0 -3
- package/src/lib/internal/typeahead.svelte.ts +9 -13
- package/src/lib/internal/types.ts +6 -0
- package/src/lib/internal/vaul/use-drawer-content.svelte.ts +2 -2
- package/src/lib/internal/vaul/use-drawer-root.svelte.ts +12 -7
- package/src/lib/components/accordion/accordion.svelte.ts +0 -43
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Checkbox (button): controlled / headless. A <button role=checkbox> for table
|
|
3
3
|
// select-all, JS-owned state, and Checkbox.Group. It does NOT submit in a form;
|
|
4
4
|
// use `CheckboxNative` (name/value) for form fields.
|
|
5
|
-
import {
|
|
5
|
+
import { repairBindable } from '../../../internal/tools/index.js';
|
|
6
6
|
import { mergeProps } from '../../../internal/merge-props.js';
|
|
7
7
|
import type { CheckboxRootProps } from '../types.js';
|
|
8
8
|
import { CheckboxRootState } from '../checkbox.svelte.js';
|
|
@@ -30,26 +30,44 @@
|
|
|
30
30
|
}: CheckboxRootProps = $props();
|
|
31
31
|
|
|
32
32
|
const rootState = CheckboxRootState.create({
|
|
33
|
-
checked
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
)
|
|
51
|
-
|
|
52
|
-
|
|
33
|
+
get checked() {
|
|
34
|
+
return checked;
|
|
35
|
+
},
|
|
36
|
+
set checked(v) {
|
|
37
|
+
checked = v;
|
|
38
|
+
onCheckedChange?.(v);
|
|
39
|
+
},
|
|
40
|
+
get indeterminate() {
|
|
41
|
+
return indeterminate;
|
|
42
|
+
},
|
|
43
|
+
set indeterminate(v) {
|
|
44
|
+
indeterminate = v;
|
|
45
|
+
onIndeterminateChange?.(v);
|
|
46
|
+
},
|
|
47
|
+
get disabled() {
|
|
48
|
+
return disabled ?? false;
|
|
49
|
+
},
|
|
50
|
+
get required() {
|
|
51
|
+
return required;
|
|
52
|
+
},
|
|
53
|
+
get readonly() {
|
|
54
|
+
return Boolean(readonly);
|
|
55
|
+
},
|
|
56
|
+
get value() {
|
|
57
|
+
return value;
|
|
58
|
+
},
|
|
59
|
+
get type() {
|
|
60
|
+
return type;
|
|
61
|
+
},
|
|
62
|
+
get id() {
|
|
63
|
+
return id;
|
|
64
|
+
},
|
|
65
|
+
get ref() {
|
|
66
|
+
return ref;
|
|
67
|
+
},
|
|
68
|
+
set ref(v) {
|
|
69
|
+
ref = v;
|
|
70
|
+
},
|
|
53
71
|
});
|
|
54
72
|
|
|
55
73
|
repairBindable(rootState.groupChecked, () => (checked = rootState.groupChecked() ?? checked));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { untrack } from 'svelte';
|
|
3
2
|
import { type WritableBox, boxWith, repairBindable } from '../../../internal/tools/index.js';
|
|
4
3
|
import { OpenCell } from '../../../internal/open-cell.svelte.js';
|
|
5
4
|
import type { ComboboxRootProps } from '../types.js';
|
|
@@ -41,7 +40,8 @@
|
|
|
41
40
|
const cell = givenCell ?? new OpenCell(() => open);
|
|
42
41
|
|
|
43
42
|
const rootState = SelectRootState.create({
|
|
44
|
-
|
|
43
|
+
// svelte-ignore state_referenced_locally
|
|
44
|
+
type,
|
|
45
45
|
value: boxWith(
|
|
46
46
|
() => value!,
|
|
47
47
|
(v) => {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { untrack } from 'svelte';
|
|
3
2
|
import FloatingLayer from '../../../../internal/floating-layer/components/floating-layer.svelte';
|
|
4
3
|
import { type WritableBox, boxWith, repairBindable } from '../../../../internal/tools/index.js';
|
|
5
4
|
import { OpenCell } from '../../../../internal/open-cell.svelte.js';
|
|
@@ -46,7 +45,8 @@
|
|
|
46
45
|
const select = givenCell ?? new OpenCell(() => open);
|
|
47
46
|
|
|
48
47
|
const rootState = SelectRootState.create({
|
|
49
|
-
|
|
48
|
+
// svelte-ignore state_referenced_locally
|
|
49
|
+
type,
|
|
50
50
|
value: boxWith(
|
|
51
51
|
() => value!,
|
|
52
52
|
(v) => {
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
DOMContext,
|
|
9
9
|
type ReadableBoxedValues,
|
|
10
10
|
type WritableBoxedValues,
|
|
11
|
-
simpleBox,
|
|
12
11
|
} from '../../internal/tools/index.js';
|
|
13
12
|
import { createContext, onMount, untrack } from 'svelte';
|
|
14
13
|
import type { DateRangeFieldRootState } from '../date-range-field/date-range-field.svelte.js';
|
|
@@ -193,7 +192,7 @@ export class DateFieldRootState {
|
|
|
193
192
|
states = initSegmentStates();
|
|
194
193
|
dayPeriodNode = $state<HTMLElement | null>(null);
|
|
195
194
|
rangeRoot: DateRangeFieldRootState | undefined = undefined;
|
|
196
|
-
#nameSource: ReadableBox<string> =
|
|
195
|
+
#nameSource: ReadableBox<string> = boxWith(() => '');
|
|
197
196
|
get name() {
|
|
198
197
|
return this.#nameSource.current;
|
|
199
198
|
}
|
|
@@ -209,7 +208,7 @@ export class DateFieldRootState {
|
|
|
209
208
|
*/
|
|
210
209
|
this.value = props.value;
|
|
211
210
|
this.placeholder = rangeRoot ? rangeRoot.opts.placeholder : props.placeholder;
|
|
212
|
-
this.validate = rangeRoot ?
|
|
211
|
+
this.validate = rangeRoot ? boxWith(() => undefined) : props.validate;
|
|
213
212
|
this.minValue = rangeRoot ? rangeRoot.opts.minValue : props.minValue;
|
|
214
213
|
this.maxValue = rangeRoot ? rangeRoot.opts.maxValue : props.maxValue;
|
|
215
214
|
this.disabled = rangeRoot ? rangeRoot.opts.disabled : props.disabled;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { boxWith } from '../../../internal/tools/index.js';
|
|
3
2
|
import { mergeProps } from '../../../internal/merge-props.js';
|
|
4
3
|
import { DialogCloseState } from '../dialog.svelte.js';
|
|
5
4
|
import type { DialogCloseProps } from '../types.js';
|
|
@@ -10,13 +9,19 @@
|
|
|
10
9
|
let { children, child, id = createId(uid), ref = $bindable(null), disabled = false, ...restProps }: DialogCloseProps = $props();
|
|
11
10
|
|
|
12
11
|
const closeState = DialogCloseState.create({
|
|
13
|
-
variant:
|
|
14
|
-
id
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
variant: 'close',
|
|
13
|
+
get id() {
|
|
14
|
+
return id;
|
|
15
|
+
},
|
|
16
|
+
get ref() {
|
|
17
|
+
return ref;
|
|
18
|
+
},
|
|
19
|
+
set ref(v) {
|
|
20
|
+
ref = v;
|
|
21
|
+
},
|
|
22
|
+
get disabled() {
|
|
23
|
+
return Boolean(disabled);
|
|
24
|
+
},
|
|
20
25
|
});
|
|
21
26
|
|
|
22
27
|
const mergedProps = $derived(mergeProps({ 'data-slot': 'dialog-close' }, restProps, closeState.props));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { boxWith } from '../../../internal/tools/index.js';
|
|
3
2
|
import { mergeProps } from '../../../internal/merge-props.js';
|
|
4
3
|
import { DialogContentState } from '../dialog.svelte.js';
|
|
5
4
|
import type { DialogContentProps } from '../types.js';
|
|
@@ -35,17 +34,21 @@
|
|
|
35
34
|
}: DialogContentProps = $props();
|
|
36
35
|
|
|
37
36
|
const contentState = DialogContentState.create({
|
|
38
|
-
id
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
get id() {
|
|
38
|
+
return id;
|
|
39
|
+
},
|
|
40
|
+
get ref() {
|
|
41
|
+
return ref;
|
|
42
|
+
},
|
|
43
|
+
set ref(v) {
|
|
44
|
+
ref = v;
|
|
45
|
+
},
|
|
43
46
|
});
|
|
44
47
|
|
|
45
48
|
// Closed state, on this element only (DialogContentState.props is shared with the native
|
|
46
49
|
// modal surface). The scroll lock's body styles land a tick after opening, after vaul's
|
|
47
50
|
// open effect has snapshotted them, as they did when the mount gate flipped a flush later.
|
|
48
|
-
const mergedProps = $derived(mergeProps(restProps, contentState.props, { style: contentState.root.
|
|
51
|
+
const mergedProps = $derived(mergeProps(restProps, contentState.props, { style: contentState.root.opts.open ? {} : { visibility: 'hidden' } }));
|
|
49
52
|
|
|
50
53
|
const escapeAttachment = escapeKeydownAttachment({
|
|
51
54
|
escapeKeydownBehavior: () => restProps.escapeKeydownBehavior ?? 'close',
|
|
@@ -54,7 +57,7 @@
|
|
|
54
57
|
if (e.defaultPrevented) return;
|
|
55
58
|
contentState.root.handleClose();
|
|
56
59
|
},
|
|
57
|
-
enabled: () => contentState.root.
|
|
60
|
+
enabled: () => contentState.root.opts.open,
|
|
58
61
|
});
|
|
59
62
|
|
|
60
63
|
// Dialog content historically dropped the dismissible focus-capture props (its default-slot
|
|
@@ -68,12 +71,12 @@
|
|
|
68
71
|
contentState.root.handleClose();
|
|
69
72
|
},
|
|
70
73
|
onFocusOutside: () => restProps.onFocusOutside,
|
|
71
|
-
enabled: () => contentState.root.
|
|
74
|
+
enabled: () => contentState.root.opts.open,
|
|
72
75
|
});
|
|
73
76
|
|
|
74
77
|
// Flags the open surface for the CSS text-selection guard in ui.css.
|
|
75
78
|
const textSelectionGuard = $derived(
|
|
76
|
-
contentState.root.
|
|
79
|
+
contentState.root.opts.open && (restProps.preventOverflowTextSelection ?? true) ? { 'data-text-selection-guard': '' } : {},
|
|
77
80
|
);
|
|
78
81
|
|
|
79
82
|
// Spans `present` (open through the settled exit), the window element lifecycle used to
|
|
@@ -84,7 +87,7 @@
|
|
|
84
87
|
});
|
|
85
88
|
|
|
86
89
|
const focusScope = createFocusScopeProps({
|
|
87
|
-
enabled: () => contentState.root.
|
|
90
|
+
enabled: () => contentState.root.opts.open,
|
|
88
91
|
trap: () => trapFocus,
|
|
89
92
|
loop: () => true,
|
|
90
93
|
onCloseAutoFocus: () => onCloseAutoFocus,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { boxWith } from '../../../internal/tools/index.js';
|
|
3
2
|
import { mergeProps } from '../../../internal/merge-props.js';
|
|
4
3
|
import { DialogDescriptionState } from '../dialog.svelte.js';
|
|
5
4
|
import type { DialogDescriptionProps } from '../types.js';
|
|
@@ -10,11 +9,15 @@
|
|
|
10
9
|
let { id = createId(uid), children, child, ref = $bindable(null), ...restProps }: DialogDescriptionProps = $props();
|
|
11
10
|
|
|
12
11
|
const descriptionState = DialogDescriptionState.create({
|
|
13
|
-
id
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
get id() {
|
|
13
|
+
return id;
|
|
14
|
+
},
|
|
15
|
+
get ref() {
|
|
16
|
+
return ref;
|
|
17
|
+
},
|
|
18
|
+
set ref(v) {
|
|
19
|
+
ref = v;
|
|
20
|
+
},
|
|
18
21
|
});
|
|
19
22
|
|
|
20
23
|
const mergedProps = $derived(mergeProps(restProps, descriptionState.props));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { boxWith } from '../../../internal/tools/index.js';
|
|
3
2
|
import { mergeProps } from '../../../internal/merge-props.js';
|
|
4
3
|
import { DialogOverlayState } from '../dialog.svelte.js';
|
|
5
4
|
import type { DialogOverlayProps } from '../types.js';
|
|
@@ -10,16 +9,20 @@
|
|
|
10
9
|
let { id = createId(uid), child, children, ref = $bindable(null), ...restProps }: DialogOverlayProps = $props();
|
|
11
10
|
|
|
12
11
|
const overlayState = DialogOverlayState.create({
|
|
13
|
-
id
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
get id() {
|
|
13
|
+
return id;
|
|
14
|
+
},
|
|
15
|
+
get ref() {
|
|
16
|
+
return ref;
|
|
17
|
+
},
|
|
18
|
+
set ref(v) {
|
|
19
|
+
ref = v;
|
|
20
|
+
},
|
|
18
21
|
});
|
|
19
22
|
|
|
20
23
|
// Always mounted; closed is visibility:hidden here, and the adapter's exit (the drawer's fadeOut
|
|
21
24
|
// keyframe, the sheet's overlay-surface transition) holds it visible while it plays.
|
|
22
|
-
const mergedProps = $derived(mergeProps(restProps, overlayState.props, { style: overlayState.root.
|
|
25
|
+
const mergedProps = $derived(mergeProps(restProps, overlayState.props, { style: overlayState.root.opts.open ? {} : { visibility: 'hidden' } }));
|
|
23
26
|
</script>
|
|
24
27
|
|
|
25
28
|
{#if child}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { boxWith } from '../../../internal/tools/index.js';
|
|
3
2
|
import { mergeProps } from '../../../internal/merge-props.js';
|
|
4
3
|
import { DialogTitleState } from '../dialog.svelte.js';
|
|
5
4
|
import type { DialogTitleProps } from '../types.js';
|
|
@@ -10,12 +9,18 @@
|
|
|
10
9
|
let { id = createId(uid), ref = $bindable(null), child, children, level = 2, ...restProps }: DialogTitleProps = $props();
|
|
11
10
|
|
|
12
11
|
const titleState = DialogTitleState.create({
|
|
13
|
-
id
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
get id() {
|
|
13
|
+
return id;
|
|
14
|
+
},
|
|
15
|
+
get level() {
|
|
16
|
+
return level;
|
|
17
|
+
},
|
|
18
|
+
get ref() {
|
|
19
|
+
return ref;
|
|
20
|
+
},
|
|
21
|
+
set ref(v) {
|
|
22
|
+
ref = v;
|
|
23
|
+
},
|
|
19
24
|
});
|
|
20
25
|
|
|
21
26
|
const mergedProps = $derived(mergeProps(restProps, titleState.props));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { boxWith } from '../../../internal/tools/index.js';
|
|
3
2
|
import { mergeProps } from '../../../internal/merge-props.js';
|
|
4
3
|
import { DialogTriggerState } from '../dialog.svelte.js';
|
|
5
4
|
import type { DialogTriggerProps } from '../types.js';
|
|
@@ -10,12 +9,18 @@
|
|
|
10
9
|
let { id = createId(uid), ref = $bindable(null), children, child, disabled = false, ...restProps }: DialogTriggerProps = $props();
|
|
11
10
|
|
|
12
11
|
const triggerState = DialogTriggerState.create({
|
|
13
|
-
id
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
get id() {
|
|
13
|
+
return id;
|
|
14
|
+
},
|
|
15
|
+
get ref() {
|
|
16
|
+
return ref;
|
|
17
|
+
},
|
|
18
|
+
set ref(v) {
|
|
19
|
+
ref = v;
|
|
20
|
+
},
|
|
21
|
+
get disabled() {
|
|
22
|
+
return Boolean(disabled);
|
|
23
|
+
},
|
|
19
24
|
});
|
|
20
25
|
|
|
21
26
|
const mergedProps = $derived(mergeProps(restProps, triggerState.props));
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { boxWith } from '../../../internal/tools/index.js';
|
|
3
2
|
import { DialogRootState, DialogState } from '../dialog.svelte.js';
|
|
4
3
|
import type { DialogRootProps } from '../types.js';
|
|
5
4
|
|
|
@@ -12,9 +11,16 @@
|
|
|
12
11
|
// svelte-ignore state_referenced_locally
|
|
13
12
|
const dialog = state ?? new DialogState(() => open);
|
|
14
13
|
DialogRootState.create({
|
|
15
|
-
variant:
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
variant: 'dialog',
|
|
15
|
+
get open() {
|
|
16
|
+
return dialog.open;
|
|
17
|
+
},
|
|
18
|
+
set open(v) {
|
|
19
|
+
dialog.open = v;
|
|
20
|
+
},
|
|
21
|
+
get onOpenChangeComplete() {
|
|
22
|
+
return onOpenChangeComplete;
|
|
23
|
+
},
|
|
18
24
|
});
|
|
19
25
|
</script>
|
|
20
26
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { HTMLDialogAttributes } from 'svelte/elements';
|
|
3
|
-
import { boxWith } from '../../../internal/tools/index.js';
|
|
4
3
|
import { mergeProps } from '../../../internal/merge-props.js';
|
|
5
4
|
import { DialogContentState } from '../dialog.svelte.js';
|
|
6
5
|
import type { DialogContentProps, DialogPortalProps } from '../types.js';
|
|
@@ -84,11 +83,15 @@
|
|
|
84
83
|
} = $props();
|
|
85
84
|
|
|
86
85
|
const contentState = DialogContentState.create({
|
|
87
|
-
id
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
get id() {
|
|
87
|
+
return id;
|
|
88
|
+
},
|
|
89
|
+
get ref() {
|
|
90
|
+
return ref;
|
|
91
|
+
},
|
|
92
|
+
set ref(v) {
|
|
93
|
+
ref = v;
|
|
94
|
+
},
|
|
92
95
|
});
|
|
93
96
|
|
|
94
97
|
// Bridge the shared root `open` to the native top-layer API and mirror native dismissal back
|
|
@@ -99,7 +102,7 @@
|
|
|
99
102
|
// `contentNode` (set by DialogContentState) and fires it once the <dialog>'s animations
|
|
100
103
|
// settle (useOpenChangeComplete) — a listener here would double-fire it.
|
|
101
104
|
const controllerAttachment = nativeDialogControllerAttachment({
|
|
102
|
-
open: () => contentState.root.
|
|
105
|
+
open: () => contentState.root.opts.open,
|
|
103
106
|
onClose: () => contentState.root.handleClose(),
|
|
104
107
|
// the controller takes this as a plain, non-reactive value — fixed per adapter at mount
|
|
105
108
|
// svelte-ignore state_referenced_locally
|
|
@@ -113,7 +116,7 @@
|
|
|
113
116
|
|
|
114
117
|
// The <dialog> persists across open/close, so the lock gates on the cell's open, not element lifecycle.
|
|
115
118
|
const scrollLock = scrollLockAttachment({
|
|
116
|
-
enabled: () => contentState.root.
|
|
119
|
+
enabled: () => contentState.root.opts.open && preventScroll,
|
|
117
120
|
restoreScrollDelay: () => restoreScrollDelay,
|
|
118
121
|
});
|
|
119
122
|
|