@widgetic/design-system 0.5.27 → 0.5.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/dist/components/CopyableHeader.svelte +29 -10
- package/dist/components/CopyableHeader.svelte.d.ts +3 -0
- package/dist/components/EmptyState.svelte +13 -3
- package/dist/components/modals/BaseModal.svelte +133 -11
- package/dist/components/modals/BaseModal.svelte.d.ts +1 -0
- package/dist/components/modals/NewItemDialog.svelte +2 -0
- package/dist/components/shad-editor/custom/Extentions/SearchAndReplace.js +0 -1
- package/dist/components/shad-editor/custom/utils.d.ts +1 -1
- package/dist/components/shad-editor/custom/utils.js +0 -1
- package/dist/components/shell/NavRow.svelte +5 -4
- package/dist/components/shell/NavRow.svelte.d.ts +3 -3
- package/dist/components/ui/accordion/accordion-content.svelte +5 -1
- package/dist/components/ui/accordion/accordion-item.svelte +2 -1
- package/dist/components/ui/accordion/accordion-trigger.svelte +38 -0
- package/dist/components/ui/button/button.svelte +1 -1
- package/dist/components/ui/button/button.svelte.d.ts +3 -3
- package/dist/components/ui/calendar/calendar.svelte.d.ts +1 -1
- package/dist/components/ui/checkbox/checkbox.svelte +1 -1
- package/dist/components/ui/dialog/dialog-overlay.svelte +8 -1
- package/dist/components/ui/icon-button/icon-button.svelte +1 -1
- package/dist/components/ui/icon-button/icon-button.svelte.d.ts +2 -2
- package/dist/components/ui/input-otp/input-otp-slot.svelte.d.ts +1 -1
- package/dist/components/ui/radio-group/radio-group-item.svelte +1 -1
- package/dist/components/ui/range-calendar/range-calendar.svelte.d.ts +1 -1
- package/dist/components/ui/select/select-content.svelte +2 -2
- package/dist/components/ui/select/select-scroll-down-button.svelte +1 -1
- package/dist/components/ui/select/select-scroll-up-button.svelte +1 -1
- package/dist/components/ui/select/select-trigger.svelte +1 -1
- package/dist/components/ui/stepper-button/stepper-button.svelte +1 -1
- package/dist/components/ui/tooltip/tooltip-content.svelte +1 -1
- package/dist/components/widget-system/Moveable.svelte +24 -21
- package/dist/utils/isEditableEventTarget.d.ts +5 -0
- package/dist/utils/isEditableEventTarget.js +25 -0
- package/dist/utils/modalFocusTrap.d.ts +28 -0
- package/dist/utils/modalFocusTrap.js +135 -0
- package/dist/utils/overlayMotion.d.ts +6 -0
- package/dist/utils/overlayMotion.js +7 -0
- package/dist/utils/overlayStacking.d.ts +47 -0
- package/dist/utils/overlayStacking.js +63 -0
- package/package.json +1 -1
|
@@ -23,11 +23,11 @@ export declare const buttonVariants: import("tailwind-variants").TVReturnType<{
|
|
|
23
23
|
true: string;
|
|
24
24
|
false: string;
|
|
25
25
|
};
|
|
26
|
-
}, undefined, "inline-flex items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", {
|
|
26
|
+
}, undefined, "inline-flex cursor-pointer items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", {
|
|
27
27
|
responsiveVariants?: boolean | (string | number | symbol)[] | {
|
|
28
28
|
size?: boolean | (string | number | symbol)[] | undefined;
|
|
29
|
-
variant?: boolean | (string | number | symbol)[] | undefined;
|
|
30
29
|
iconPadding?: boolean | (string | number | symbol)[] | undefined;
|
|
30
|
+
variant?: boolean | (string | number | symbol)[] | undefined;
|
|
31
31
|
} | undefined;
|
|
32
32
|
} & import("tailwind-variants/dist/config.js").TWMConfig & {
|
|
33
33
|
twMergeConfig: {
|
|
@@ -81,7 +81,7 @@ export declare const buttonVariants: import("tailwind-variants").TVReturnType<{
|
|
|
81
81
|
true: string;
|
|
82
82
|
false: string;
|
|
83
83
|
};
|
|
84
|
-
}, undefined, "inline-flex items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
84
|
+
}, undefined, "inline-flex cursor-pointer items-center justify-center gap-1 whitespace-nowrap rounded-lg text-label press-feedback focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
85
85
|
variant: {
|
|
86
86
|
default: string;
|
|
87
87
|
destructive: string;
|
|
@@ -6,6 +6,6 @@ export type CalendarProps = WithoutChildrenOrChild<CalendarPrimitive.RootProps>
|
|
|
6
6
|
nextLabel?: string;
|
|
7
7
|
};
|
|
8
8
|
import * as Calendar from "./index.js";
|
|
9
|
-
declare const Calendar: import("svelte").Component<CalendarProps, {}, "
|
|
9
|
+
declare const Calendar: import("svelte").Component<CalendarProps, {}, "ref" | "value" | "placeholder">;
|
|
10
10
|
type Calendar = ReturnType<typeof Calendar>;
|
|
11
11
|
export default Calendar;
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
<CheckboxPrimitive.Root
|
|
22
22
|
bind:ref
|
|
23
23
|
class={cn(
|
|
24
|
-
"peer flex size-4 shrink-0 items-center justify-center rounded-sm border border-input bg-background text-primary-foreground hover:bg-muted focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary active:border-input active:data-[state=checked]:border-primary active:data-[state=indeterminate]:border-primary press-feedback",
|
|
24
|
+
"peer flex size-4 shrink-0 cursor-pointer items-center justify-center rounded-sm border border-input bg-background text-primary-foreground hover:bg-muted focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background active:ring-2 active:ring-ring active:ring-offset-2 active:ring-offset-background disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[state=checked]:border-primary data-[state=checked]:bg-primary data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary active:border-input active:data-[state=checked]:border-primary active:data-[state=indeterminate]:border-primary press-feedback",
|
|
25
25
|
className
|
|
26
26
|
)}
|
|
27
27
|
bind:checked
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
overlayDialogOverlayClasses,
|
|
10
10
|
overlayReducedMotionClasses
|
|
11
11
|
} from "../../../utils/overlayMotion.js";
|
|
12
|
+
// A scrim drawn over another scrim only dims (the page is blurred once): see overlayStacking.ts.
|
|
13
|
+
import { stackedScrimMark } from "../../../utils/overlayStacking.js";
|
|
12
14
|
|
|
13
15
|
let {
|
|
14
16
|
ref = $bindable(null),
|
|
@@ -27,4 +29,9 @@
|
|
|
27
29
|
className
|
|
28
30
|
)}
|
|
29
31
|
{...restProps}
|
|
30
|
-
|
|
32
|
+
>
|
|
33
|
+
{#snippet child({ props })}
|
|
34
|
+
<!-- The element is created here, only while the dialog is shown: it is marked as it is created, so a scrim over another one never has the blur to lose. -->
|
|
35
|
+
<div {...props} data-stacked={stackedScrimMark()}></div>
|
|
36
|
+
{/snippet}
|
|
37
|
+
</DialogPrimitive.Overlay>
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import type { VariantProps } from "tailwind-variants";
|
|
9
9
|
|
|
10
10
|
export const iconButtonVariants = tv({
|
|
11
|
-
base: "inline-flex shrink-0 items-center justify-center press-feedback focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2",
|
|
11
|
+
base: "inline-flex shrink-0 cursor-pointer items-center justify-center press-feedback focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2",
|
|
12
12
|
variants: {
|
|
13
13
|
variant: {
|
|
14
14
|
ghost:
|
|
@@ -13,7 +13,7 @@ export declare const iconButtonVariants: import("tailwind-variants").TVReturnTyp
|
|
|
13
13
|
default: string;
|
|
14
14
|
sm: string;
|
|
15
15
|
};
|
|
16
|
-
}, undefined, "inline-flex shrink-0 items-center justify-center press-feedback focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", {
|
|
16
|
+
}, undefined, "inline-flex shrink-0 cursor-pointer items-center justify-center press-feedback focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", {
|
|
17
17
|
responsiveVariants?: boolean | (string | number | symbol)[] | {
|
|
18
18
|
size?: boolean | (string | number | symbol)[] | undefined;
|
|
19
19
|
variant?: boolean | (string | number | symbol)[] | undefined;
|
|
@@ -50,7 +50,7 @@ export declare const iconButtonVariants: import("tailwind-variants").TVReturnTyp
|
|
|
50
50
|
default: string;
|
|
51
51
|
sm: string;
|
|
52
52
|
};
|
|
53
|
-
}, undefined, "inline-flex shrink-0 items-center justify-center press-feedback focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
53
|
+
}, undefined, "inline-flex shrink-0 cursor-pointer items-center justify-center press-feedback focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 [&_svg]:stroke-2", import("tailwind-variants/dist/config.js").TVConfig<{
|
|
54
54
|
variant: {
|
|
55
55
|
ghost: string;
|
|
56
56
|
secondary: string;
|
|
@@ -3,7 +3,7 @@ export type InputOtpSlotProps = ComponentProps<typeof InputOTPPrimitive.Cell>;
|
|
|
3
3
|
import type { ComponentProps } from "svelte";
|
|
4
4
|
declare const InputOtpSlot: import("svelte").Component<Omit<{
|
|
5
5
|
cell: import("bits-ui").PinInputCell;
|
|
6
|
-
}, "
|
|
6
|
+
}, "children" | "child"> & {
|
|
7
7
|
child?: import("svelte").Snippet<[{
|
|
8
8
|
props: Record<string, unknown>;
|
|
9
9
|
}]> | undefined;
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
<RadioGroupPrimitive.Item
|
|
18
18
|
bind:ref
|
|
19
19
|
class={cn(
|
|
20
|
-
"aspect-square size-4 shrink-0 rounded-full border border-input bg-background text-primary hover:bg-muted focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 data-[state=checked]:border-primary active:border-input active:data-[state=checked]:border-primary press-feedback",
|
|
20
|
+
"aspect-square size-4 shrink-0 cursor-pointer rounded-full border border-input bg-background text-primary hover:bg-muted focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background active:ring-2 active:ring-ring active:ring-offset-2 active:ring-offset-background disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary active:border-input active:data-[state=checked]:border-primary press-feedback",
|
|
21
21
|
className
|
|
22
22
|
)}
|
|
23
23
|
{...restProps}
|
|
@@ -6,6 +6,6 @@ export type RangeCalendarProps = WithoutChildrenOrChild<RangeCalendarPrimitive.R
|
|
|
6
6
|
nextLabel?: string;
|
|
7
7
|
};
|
|
8
8
|
import * as RangeCalendar from "./index.js";
|
|
9
|
-
declare const RangeCalendar: import("svelte").Component<RangeCalendarProps, {}, "
|
|
9
|
+
declare const RangeCalendar: import("svelte").Component<RangeCalendarProps, {}, "ref" | "value" | "placeholder">;
|
|
10
10
|
type RangeCalendar = ReturnType<typeof RangeCalendar>;
|
|
11
11
|
export default RangeCalendar;
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
type="button"
|
|
138
138
|
tabindex={-1}
|
|
139
139
|
aria-hidden="true"
|
|
140
|
-
class="select-scroll-step select-scroll-step-up flex w-full cursor-
|
|
140
|
+
class="select-scroll-step select-scroll-step-up flex w-full cursor-pointer items-center justify-center py-1 [&_svg]:cursor-pointer"
|
|
141
141
|
onpointerdown={(event) => handleScrollButtonPointerDown(event, -1)}
|
|
142
142
|
onpointerup={handleScrollButtonPointerUp}
|
|
143
143
|
onpointerleave={handleScrollButtonPointerUp}
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
type="button"
|
|
161
161
|
tabindex={-1}
|
|
162
162
|
aria-hidden="true"
|
|
163
|
-
class="select-scroll-step select-scroll-step-down flex w-full cursor-
|
|
163
|
+
class="select-scroll-step select-scroll-step-down flex w-full cursor-pointer items-center justify-center py-1 [&_svg]:cursor-pointer"
|
|
164
164
|
onpointerdown={(event) => handleScrollButtonPointerDown(event, 1)}
|
|
165
165
|
onpointerup={handleScrollButtonPointerUp}
|
|
166
166
|
onpointerleave={handleScrollButtonPointerUp}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
<SelectPrimitive.ScrollDownButton
|
|
18
18
|
bind:ref
|
|
19
|
-
class={cn("flex cursor-
|
|
19
|
+
class={cn("flex cursor-pointer items-center justify-center py-1 [&_svg]:cursor-pointer", className)}
|
|
20
20
|
{...restProps}
|
|
21
21
|
>
|
|
22
22
|
<IconChevronDown class="size-4 stroke-2" aria-hidden="true" />
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
<SelectPrimitive.ScrollUpButton
|
|
18
18
|
bind:ref
|
|
19
|
-
class={cn("flex cursor-
|
|
19
|
+
class={cn("flex cursor-pointer items-center justify-center py-1 [&_svg]:cursor-pointer", className)}
|
|
20
20
|
{...restProps}
|
|
21
21
|
>
|
|
22
22
|
<IconChevronUp class="size-4 stroke-2" aria-hidden="true" />
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
<SelectPrimitive.Trigger
|
|
20
20
|
bind:ref
|
|
21
21
|
class={cn(
|
|
22
|
-
"flex h-9 w-full items-center justify-between gap-2 rounded-lg border border-input bg-background px-3 py-2 text-start text-body transition-colors duration-fast hover:bg-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 data-[placeholder]:text-muted-foreground aria-invalid:border-destructive [&>span]:line-clamp-1 [&[data-state=open]>svg:last-child]:rotate-180",
|
|
22
|
+
"flex h-9 w-full cursor-pointer items-center justify-between gap-2 rounded-lg border border-input bg-background px-3 py-2 text-start text-body transition-colors duration-fast hover:bg-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 data-[placeholder]:text-muted-foreground aria-invalid:border-destructive [&>span]:line-clamp-1 [&[data-state=open]>svg:last-child]:rotate-180",
|
|
23
23
|
className
|
|
24
24
|
)}
|
|
25
25
|
{...restProps}
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
{disabled}
|
|
30
30
|
data-pressed={dataPressed}
|
|
31
31
|
class={cn(
|
|
32
|
-
"inline-flex size-6 shrink-0 items-center justify-center rounded-lg bg-transparent text-foreground hover:bg-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-50 press-feedback [&_svg]:pointer-events-none",
|
|
32
|
+
"inline-flex size-6 shrink-0 cursor-pointer items-center justify-center rounded-lg bg-transparent text-foreground hover:bg-accent focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 press-feedback [&_svg]:pointer-events-none",
|
|
33
33
|
className
|
|
34
34
|
)}
|
|
35
35
|
{...restProps}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
{sideOffset}
|
|
25
25
|
dir={$textDirection}
|
|
26
26
|
class={cn(
|
|
27
|
-
"bg-popover text-popover-foreground border-border text-caption animate-in fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 overflow-hidden rounded-lg border px-3 py-1.5",
|
|
27
|
+
"bg-popover text-popover-foreground border-border text-caption animate-in fade-in-0 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 max-w-[min(18rem,calc(100vw-2rem))] overflow-hidden rounded-lg border px-3 py-1.5 text-balance whitespace-normal",
|
|
28
28
|
className
|
|
29
29
|
)}
|
|
30
30
|
{...restProps}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount, createEventDispatcher } from 'svelte';
|
|
3
|
+
import { isEditableEventTarget } from '../../utils/isEditableEventTarget';
|
|
3
4
|
|
|
4
5
|
// COMPONENT PROPS
|
|
5
6
|
// Class & Style
|
|
@@ -52,8 +53,16 @@
|
|
|
52
53
|
// console.log(`${prefix} - Position: (${currentLeft.toFixed(1)}, ${currentTop.toFixed(1)}), Size: ${Math.round(currentWidth)}x${Math.round(currentHeight)}`);
|
|
53
54
|
}
|
|
54
55
|
|
|
56
|
+
/** Modifier keys apply visually only while the pointer is over the widget or a drag/resize is active. */
|
|
57
|
+
$: pointerInteractionActive = isHovering || isDragging || isResizing;
|
|
58
|
+
$: showDragMode = pointerInteractionActive && (isCmdCtrlKeyDown || isSpaceKeyDown);
|
|
59
|
+
$: showProportionalMode = pointerInteractionActive && isShiftKeyDown && !isAltOptKeyDown;
|
|
60
|
+
$: showSymmetricalMode = pointerInteractionActive && isAltOptKeyDown && !isShiftKeyDown;
|
|
61
|
+
$: showCombinedMode = pointerInteractionActive && isShiftKeyDown && isAltOptKeyDown;
|
|
62
|
+
|
|
55
63
|
// Track key states
|
|
56
64
|
function handleKeyDown(e: KeyboardEvent) {
|
|
65
|
+
if (isEditableEventTarget(e)) return;
|
|
57
66
|
if ((isMac && e.key === 'Meta') || (!isMac && e.key === 'Control')) {
|
|
58
67
|
isCmdCtrlKeyDown = true;
|
|
59
68
|
updateContainerClasses();
|
|
@@ -95,25 +104,19 @@
|
|
|
95
104
|
|
|
96
105
|
function updateContainerClasses() {
|
|
97
106
|
if (!container) return;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
container.classList.
|
|
101
|
-
container.classList.
|
|
102
|
-
container.classList.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
container.classList.add('combined-mode');
|
|
112
|
-
} else if (isShiftKeyDown) {
|
|
113
|
-
container.classList.add('proportional-mode');
|
|
114
|
-
} else if (isAltOptKeyDown) {
|
|
115
|
-
container.classList.add('symmetrical-mode');
|
|
116
|
-
}
|
|
107
|
+
container.classList.remove('drag-mode', 'proportional-mode', 'symmetrical-mode', 'combined-mode');
|
|
108
|
+
if (showDragMode) container.classList.add('drag-mode');
|
|
109
|
+
if (showCombinedMode) container.classList.add('combined-mode');
|
|
110
|
+
else if (showProportionalMode) container.classList.add('proportional-mode');
|
|
111
|
+
else if (showSymmetricalMode) container.classList.add('symmetrical-mode');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
$: if (container) {
|
|
115
|
+
showDragMode;
|
|
116
|
+
showProportionalMode;
|
|
117
|
+
showSymmetricalMode;
|
|
118
|
+
showCombinedMode;
|
|
119
|
+
updateContainerClasses();
|
|
117
120
|
}
|
|
118
121
|
|
|
119
122
|
// Reclaim focus from iframes so Cmd/Ctrl keydown reaches document listeners
|
|
@@ -497,7 +500,7 @@
|
|
|
497
500
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
498
501
|
<div
|
|
499
502
|
bind:this={container}
|
|
500
|
-
class="moveable-content-ct moveable-container {
|
|
503
|
+
class="moveable-content-ct moveable-container {showDragMode ? 'drag-mode' : ''} {showProportionalMode ? 'proportional-mode' : ''} {showSymmetricalMode ? 'symmetrical-mode' : ''} {showCombinedMode ? 'combined-mode' : ''} {isResizing ? 'resizing-mode' : ''}"
|
|
501
504
|
class:hovering={isHovering || alwaysShowControls}
|
|
502
505
|
style="position: absolute; left: 8px; top: 8px; width: {currentWidth}px; height: {currentHeight}px;"
|
|
503
506
|
on:mousedown={handleMouseDown}
|
|
@@ -505,7 +508,7 @@
|
|
|
505
508
|
<slot></slot>
|
|
506
509
|
|
|
507
510
|
<!-- Drag overlay: real DOM element that sits above iframes to capture mouse events in drag mode -->
|
|
508
|
-
{#if
|
|
511
|
+
{#if showDragMode}
|
|
509
512
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
510
513
|
<div class="drag-overlay" on:mousedown={handleMouseDown}></div>
|
|
511
514
|
{/if}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* True when a keyboard event originated from (or should be treated as) typing in an editable control,
|
|
3
|
+
* including fields inside shadow roots and portaled popovers (composedPath).
|
|
4
|
+
*/
|
|
5
|
+
export declare function isEditableEventTarget(event: Pick<KeyboardEvent, 'composedPath' | 'target'>): boolean;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const EDITABLE_SELECTOR = 'input, textarea, select, option, [contenteditable]:not([contenteditable="false"]), [role="textbox"], [role="combobox"], [role="searchbox"]';
|
|
2
|
+
function elementIsEditable(element) {
|
|
3
|
+
if (!element || typeof element !== 'object')
|
|
4
|
+
return false;
|
|
5
|
+
const htmlElement = element;
|
|
6
|
+
if (htmlElement.isContentEditable)
|
|
7
|
+
return true;
|
|
8
|
+
const contentEditable = htmlElement.getAttribute?.('contenteditable');
|
|
9
|
+
if (contentEditable !== null && contentEditable !== undefined && contentEditable !== 'false')
|
|
10
|
+
return true;
|
|
11
|
+
return typeof htmlElement.matches === 'function' && htmlElement.matches(EDITABLE_SELECTOR);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* True when a keyboard event originated from (or should be treated as) typing in an editable control,
|
|
15
|
+
* including fields inside shadow roots and portaled popovers (composedPath).
|
|
16
|
+
*/
|
|
17
|
+
export function isEditableEventTarget(event) {
|
|
18
|
+
for (const node of event.composedPath()) {
|
|
19
|
+
if (elementIsEditable(node))
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (elementIsEditable(event.target))
|
|
23
|
+
return true;
|
|
24
|
+
return elementIsEditable(typeof document !== 'undefined' ? document.activeElement : null);
|
|
25
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for BaseModal focus trapping (tab order, visibility, portaled bits-ui layers).
|
|
3
|
+
*/
|
|
4
|
+
/** A new id for the title of one modal, so two modals open at once never share the id their `aria-labelledby` points at. */
|
|
5
|
+
export declare function nextModalTitleId(): string;
|
|
6
|
+
export declare function isElementVisible(element: HTMLElement): boolean;
|
|
7
|
+
export declare function isFocusable(element: HTMLElement): boolean;
|
|
8
|
+
export declare function getTabbableElements(root: HTMLElement): HTMLElement[];
|
|
9
|
+
/**
|
|
10
|
+
* The element that really has focus, looking inside open shadow roots too (`document.activeElement` alone stops at the host of a
|
|
11
|
+
* shadow root, and the file browser lives in one when an app embeds it).
|
|
12
|
+
*/
|
|
13
|
+
export declare function deepActiveElement(root?: Document | ShadowRoot): HTMLElement | null;
|
|
14
|
+
/**
|
|
15
|
+
* Where focus must wrap to when Tab (or Shift+Tab) would otherwise leave the modal. `null` means the browser's own Tab is fine:
|
|
16
|
+
* the trap steps in only at the two ends of the modal (and when focus is not in the modal at all), so the tab order everywhere
|
|
17
|
+
* else stays the browser's own (radio groups, shadow DOM, anything the list of tabbable elements does not know).
|
|
18
|
+
*/
|
|
19
|
+
export declare function tabWrapTarget(options: {
|
|
20
|
+
elements: HTMLElement[];
|
|
21
|
+
active: Element | null;
|
|
22
|
+
shiftKey: boolean;
|
|
23
|
+
modalRoot: HTMLElement;
|
|
24
|
+
}): HTMLElement | null;
|
|
25
|
+
/**
|
|
26
|
+
* Focus may sit on a bits-ui layer portaled outside the dialog if a control inside the modal opened it.
|
|
27
|
+
*/
|
|
28
|
+
export declare function isFocusAllowed(modalRoot: HTMLElement, target: HTMLElement): boolean;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pure helpers for BaseModal focus trapping (tab order, visibility, portaled bits-ui layers).
|
|
3
|
+
*/
|
|
4
|
+
const TABBABLE_SELECTOR = [
|
|
5
|
+
'a[href]',
|
|
6
|
+
'button:not([disabled])',
|
|
7
|
+
'input:not([disabled])',
|
|
8
|
+
'select:not([disabled])',
|
|
9
|
+
'textarea:not([disabled])',
|
|
10
|
+
'[tabindex]:not([tabindex="-1"])',
|
|
11
|
+
'audio[controls]',
|
|
12
|
+
'video[controls]',
|
|
13
|
+
'[contenteditable]:not([contenteditable="false"])'
|
|
14
|
+
].join(',');
|
|
15
|
+
const FLOATING_LAYER_ROLES = new Set(['menu', 'listbox', 'dialog', 'tooltip', 'grid']);
|
|
16
|
+
let modalTitleIdCounter = 0;
|
|
17
|
+
/** A new id for the title of one modal, so two modals open at once never share the id their `aria-labelledby` points at. */
|
|
18
|
+
export function nextModalTitleId() {
|
|
19
|
+
modalTitleIdCounter += 1;
|
|
20
|
+
return `base-modal-title-${modalTitleIdCounter}`;
|
|
21
|
+
}
|
|
22
|
+
export function isElementVisible(element) {
|
|
23
|
+
if (element.hidden)
|
|
24
|
+
return false;
|
|
25
|
+
const style = element.ownerDocument?.defaultView?.getComputedStyle(element);
|
|
26
|
+
if (!style)
|
|
27
|
+
return true;
|
|
28
|
+
if (style.visibility === 'hidden' || style.display === 'none')
|
|
29
|
+
return false;
|
|
30
|
+
if (parseFloat(style.opacity) === 0)
|
|
31
|
+
return false;
|
|
32
|
+
return element.getClientRects().length > 0;
|
|
33
|
+
}
|
|
34
|
+
function isNaturallyTabbable(element) {
|
|
35
|
+
const tag = element.tagName;
|
|
36
|
+
if (tag === 'INPUT' || tag === 'SELECT' || tag === 'TEXTAREA' || tag === 'BUTTON') {
|
|
37
|
+
return !element.disabled;
|
|
38
|
+
}
|
|
39
|
+
if (tag === 'A')
|
|
40
|
+
return element.hasAttribute('href');
|
|
41
|
+
const tabIndex = element.tabIndex;
|
|
42
|
+
return tabIndex >= 0;
|
|
43
|
+
}
|
|
44
|
+
export function isFocusable(element) {
|
|
45
|
+
if (!isElementVisible(element))
|
|
46
|
+
return false;
|
|
47
|
+
if (element.tabIndex < 0 && !isNaturallyTabbable(element))
|
|
48
|
+
return false;
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
export function getTabbableElements(root) {
|
|
52
|
+
const doc = root.ownerDocument;
|
|
53
|
+
const nodes = root.querySelectorAll(TABBABLE_SELECTOR);
|
|
54
|
+
const result = [];
|
|
55
|
+
for (const node of nodes) {
|
|
56
|
+
if (!root.contains(node))
|
|
57
|
+
continue;
|
|
58
|
+
if (!isFocusable(node))
|
|
59
|
+
continue;
|
|
60
|
+
result.push(node);
|
|
61
|
+
}
|
|
62
|
+
const withTabIndex = root.querySelectorAll('[tabindex]');
|
|
63
|
+
for (const node of withTabIndex) {
|
|
64
|
+
if (result.includes(node))
|
|
65
|
+
continue;
|
|
66
|
+
if (node.tabIndex < 0)
|
|
67
|
+
continue;
|
|
68
|
+
if (!isFocusable(node))
|
|
69
|
+
continue;
|
|
70
|
+
result.push(node);
|
|
71
|
+
}
|
|
72
|
+
result.sort((a, b) => {
|
|
73
|
+
const ai = a.tabIndex > 0 ? a.tabIndex : 0;
|
|
74
|
+
const bi = b.tabIndex > 0 ? b.tabIndex : 0;
|
|
75
|
+
if (ai !== bi)
|
|
76
|
+
return ai - bi;
|
|
77
|
+
return a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
78
|
+
});
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The element that really has focus, looking inside open shadow roots too (`document.activeElement` alone stops at the host of a
|
|
83
|
+
* shadow root, and the file browser lives in one when an app embeds it).
|
|
84
|
+
*/
|
|
85
|
+
export function deepActiveElement(root = document) {
|
|
86
|
+
let active = root.activeElement;
|
|
87
|
+
while (active && active.shadowRoot && active.shadowRoot.activeElement) {
|
|
88
|
+
active = active.shadowRoot.activeElement;
|
|
89
|
+
}
|
|
90
|
+
return active instanceof HTMLElement ? active : null;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Where focus must wrap to when Tab (or Shift+Tab) would otherwise leave the modal. `null` means the browser's own Tab is fine:
|
|
94
|
+
* the trap steps in only at the two ends of the modal (and when focus is not in the modal at all), so the tab order everywhere
|
|
95
|
+
* else stays the browser's own (radio groups, shadow DOM, anything the list of tabbable elements does not know).
|
|
96
|
+
*/
|
|
97
|
+
export function tabWrapTarget(options) {
|
|
98
|
+
const { elements, active, shiftKey, modalRoot } = options;
|
|
99
|
+
const first = elements[0];
|
|
100
|
+
const last = elements[elements.length - 1];
|
|
101
|
+
if (!first || !last)
|
|
102
|
+
return null;
|
|
103
|
+
// Focus is not in the modal (something moved it out): bring it back at the end the person is heading for
|
|
104
|
+
if (!active || !modalRoot.contains(active))
|
|
105
|
+
return shiftKey ? last : first;
|
|
106
|
+
// Focus is on the card itself: forward goes into the card by itself, backward would leave it
|
|
107
|
+
if (active === modalRoot)
|
|
108
|
+
return shiftKey ? last : null;
|
|
109
|
+
if (shiftKey)
|
|
110
|
+
return active === first ? last : null;
|
|
111
|
+
return active === last ? first : null;
|
|
112
|
+
}
|
|
113
|
+
function findOpenFloatingAncestor(target) {
|
|
114
|
+
let node = target;
|
|
115
|
+
while (node && node !== node.ownerDocument.body) {
|
|
116
|
+
const role = node.getAttribute('role');
|
|
117
|
+
const state = node.getAttribute('data-state');
|
|
118
|
+
if (state === 'open' && role && FLOATING_LAYER_ROLES.has(role)) {
|
|
119
|
+
return node;
|
|
120
|
+
}
|
|
121
|
+
node = node.parentElement;
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Focus may sit on a bits-ui layer portaled outside the dialog if a control inside the modal opened it.
|
|
127
|
+
*/
|
|
128
|
+
export function isFocusAllowed(modalRoot, target) {
|
|
129
|
+
if (modalRoot.contains(target))
|
|
130
|
+
return true;
|
|
131
|
+
const floating = findOpenFloatingAncestor(target);
|
|
132
|
+
if (!floating)
|
|
133
|
+
return false;
|
|
134
|
+
return modalRoot.querySelector('[aria-expanded="true"]') !== null;
|
|
135
|
+
}
|
|
@@ -42,6 +42,12 @@ export declare const overlayBackdropBlurClass = "backdrop-blur-[3px]";
|
|
|
42
42
|
export declare const overlayScrimClasses = "bg-muted-foreground/80 backdrop-blur-[3px]";
|
|
43
43
|
/** Tailwind arbitrary easing approximating Svelte `cubicOut` (ease-out cubic, 1 − (1 − t)³). */
|
|
44
44
|
export declare const overlayEasingClass = "ease-[cubic-bezier(0.33,1,0.68,1)]";
|
|
45
|
+
/**
|
|
46
|
+
* A scrim drawn over another scrim only dims: the one below blurs the page already, and two backdrop blurs that fade
|
|
47
|
+
* in together flicker. `markStackedScrim` (`overlayStacking.ts`) puts `data-stacked` on such a scrim, and this takes its
|
|
48
|
+
* blur off. Literal so Tailwind's scanner emits it.
|
|
49
|
+
*/
|
|
50
|
+
export declare const overlayStackedScrimClass = "data-[stacked]:backdrop-blur-none";
|
|
45
51
|
/** Overlay + panel classes for bits-ui Dialog (aligned with BaseModal motion: fade, 200ms, cubic-out-like, zoom from 0.95). */
|
|
46
52
|
export declare const overlayDialogOverlayClasses: string;
|
|
47
53
|
export declare const overlayDialogContentClasses: string;
|
|
@@ -45,9 +45,16 @@ export const overlayBackdropBlurClass = 'backdrop-blur-[3px]';
|
|
|
45
45
|
export const overlayScrimClasses = 'bg-muted-foreground/80 backdrop-blur-[3px]';
|
|
46
46
|
/** Tailwind arbitrary easing approximating Svelte `cubicOut` (ease-out cubic, 1 − (1 − t)³). */
|
|
47
47
|
export const overlayEasingClass = 'ease-[cubic-bezier(0.33,1,0.68,1)]';
|
|
48
|
+
/**
|
|
49
|
+
* A scrim drawn over another scrim only dims: the one below blurs the page already, and two backdrop blurs that fade
|
|
50
|
+
* in together flicker. `markStackedScrim` (`overlayStacking.ts`) puts `data-stacked` on such a scrim, and this takes its
|
|
51
|
+
* blur off. Literal so Tailwind's scanner emits it.
|
|
52
|
+
*/
|
|
53
|
+
export const overlayStackedScrimClass = 'data-[stacked]:backdrop-blur-none';
|
|
48
54
|
/** Overlay + panel classes for bits-ui Dialog (aligned with BaseModal motion: fade, 200ms, cubic-out-like, zoom from 0.95). */
|
|
49
55
|
export const overlayDialogOverlayClasses = [
|
|
50
56
|
overlayScrimClasses,
|
|
57
|
+
overlayStackedScrimClass,
|
|
51
58
|
overlayDurationClass,
|
|
52
59
|
overlayEasingClass,
|
|
53
60
|
...overlayDialogOpenClosedAnimationDurationClasses,
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stacked overlays blur the page once.
|
|
3
|
+
*
|
|
4
|
+
* Every dialog and modal draws a scrim: the muted foreground at 80% with a 3px backdrop blur (`overlayScrimClasses`). A
|
|
5
|
+
* dialog opened over another one (the settings dialog, then "Edit domain" on top of it) draws a second scrim over the
|
|
6
|
+
* first. Blurring a page that is already blurred adds nothing the eye can see, but the second scrim fades in, and a
|
|
7
|
+
* backdrop blur that fades is redrawn on every frame of the fade, over the first scrim's redrawn blur: two of them
|
|
8
|
+
* stacked are what made the background flicker when a second dialog opened.
|
|
9
|
+
*
|
|
10
|
+
* So a scrim drawn over another one only dims: it carries `data-stacked`, and the surface that draws it takes the blur
|
|
11
|
+
* off (the dialog overlay with `overlayStackedScrimClass`, the base modal with a rule of its own). The first scrim keeps
|
|
12
|
+
* the blur, so the page is blurred once, however many layers are above it.
|
|
13
|
+
*
|
|
14
|
+
* The mark is part of the scrim as it is created (`data-stacked={stackedScrimMark()}` in the template), not added a
|
|
15
|
+
* moment later: a scrim created with the blur and stripped of it after would first resolve its style with the blur, and
|
|
16
|
+
* the dialog overlay, which transitions every property over 200ms, would then animate the blur away.
|
|
17
|
+
*
|
|
18
|
+
* The decision is made from the page, not from the component tree: bits-ui knows a dialog is nested only when it is
|
|
19
|
+
* rendered inside the other dialog, and a dialog can be mounted somewhere else (the plan chooser, over the settings
|
|
20
|
+
* dialog) and still be drawn above it.
|
|
21
|
+
*/
|
|
22
|
+
/** What marks a scrim that is drawn over another scrim. */
|
|
23
|
+
export declare const stackedScrimAttribute = "data-stacked";
|
|
24
|
+
/** The scrims that blur the page: the backdrop of a dialog (bits-ui) and the backdrop of a base modal. */
|
|
25
|
+
export declare const blurringScrimSelector = "[data-widgetic-overlay=\"dialog-backdrop\"], [data-widgetic-overlay=\"base-modal-backdrop\"]";
|
|
26
|
+
/** What the lookup needs of the page: the real `document`, or a stand-in in a test. */
|
|
27
|
+
type ScrimLookupRoot = Pick<ParentNode, 'querySelectorAll'>;
|
|
28
|
+
/**
|
|
29
|
+
* Whether a scrim that still blurs the page is drawn.
|
|
30
|
+
*
|
|
31
|
+
* A scrim that is closing (`data-state="closed"`: the fade out of a dialog that was just closed) does not count. When
|
|
32
|
+
* a dialog closes and another opens in the same moment, the new one is the first, and keeps the blur the old one
|
|
33
|
+
* takes away with it.
|
|
34
|
+
*
|
|
35
|
+
* @param root - Where to look; the page by default.
|
|
36
|
+
* @returns "A scrim is drawn": `true` when the scrim about to be created has to dim only.
|
|
37
|
+
*/
|
|
38
|
+
export declare function isAnotherScrimDrawn(root?: ScrimLookupRoot): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The value of `data-stacked` for a scrim that is being created: an empty string (the attribute is set) when another
|
|
41
|
+
* scrim is drawn, `undefined` (no attribute) when this one is the first. Called from the template, so it runs once, as
|
|
42
|
+
* the scrim is created, before its first frame.
|
|
43
|
+
*
|
|
44
|
+
* @param root - Where to look; the page by default.
|
|
45
|
+
*/
|
|
46
|
+
export declare function stackedScrimMark(root?: ScrimLookupRoot): '' | undefined;
|
|
47
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stacked overlays blur the page once.
|
|
3
|
+
*
|
|
4
|
+
* Every dialog and modal draws a scrim: the muted foreground at 80% with a 3px backdrop blur (`overlayScrimClasses`). A
|
|
5
|
+
* dialog opened over another one (the settings dialog, then "Edit domain" on top of it) draws a second scrim over the
|
|
6
|
+
* first. Blurring a page that is already blurred adds nothing the eye can see, but the second scrim fades in, and a
|
|
7
|
+
* backdrop blur that fades is redrawn on every frame of the fade, over the first scrim's redrawn blur: two of them
|
|
8
|
+
* stacked are what made the background flicker when a second dialog opened.
|
|
9
|
+
*
|
|
10
|
+
* So a scrim drawn over another one only dims: it carries `data-stacked`, and the surface that draws it takes the blur
|
|
11
|
+
* off (the dialog overlay with `overlayStackedScrimClass`, the base modal with a rule of its own). The first scrim keeps
|
|
12
|
+
* the blur, so the page is blurred once, however many layers are above it.
|
|
13
|
+
*
|
|
14
|
+
* The mark is part of the scrim as it is created (`data-stacked={stackedScrimMark()}` in the template), not added a
|
|
15
|
+
* moment later: a scrim created with the blur and stripped of it after would first resolve its style with the blur, and
|
|
16
|
+
* the dialog overlay, which transitions every property over 200ms, would then animate the blur away.
|
|
17
|
+
*
|
|
18
|
+
* The decision is made from the page, not from the component tree: bits-ui knows a dialog is nested only when it is
|
|
19
|
+
* rendered inside the other dialog, and a dialog can be mounted somewhere else (the plan chooser, over the settings
|
|
20
|
+
* dialog) and still be drawn above it.
|
|
21
|
+
*/
|
|
22
|
+
/** What marks a scrim that is drawn over another scrim. */
|
|
23
|
+
export const stackedScrimAttribute = 'data-stacked';
|
|
24
|
+
/** The scrims that blur the page: the backdrop of a dialog (bits-ui) and the backdrop of a base modal. */
|
|
25
|
+
export const blurringScrimSelector = '[data-widgetic-overlay="dialog-backdrop"], [data-widgetic-overlay="base-modal-backdrop"]';
|
|
26
|
+
/**
|
|
27
|
+
* Whether a scrim that still blurs the page is drawn.
|
|
28
|
+
*
|
|
29
|
+
* A scrim that is closing (`data-state="closed"`: the fade out of a dialog that was just closed) does not count. When
|
|
30
|
+
* a dialog closes and another opens in the same moment, the new one is the first, and keeps the blur the old one
|
|
31
|
+
* takes away with it.
|
|
32
|
+
*
|
|
33
|
+
* @param root - Where to look; the page by default.
|
|
34
|
+
* @returns "A scrim is drawn": `true` when the scrim about to be created has to dim only.
|
|
35
|
+
*/
|
|
36
|
+
export function isAnotherScrimDrawn(root = document) {
|
|
37
|
+
for (const drawnScrim of root.querySelectorAll(blurringScrimSelector)) {
|
|
38
|
+
if (drawnScrim.getAttribute('data-state') === 'closed')
|
|
39
|
+
continue;
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The value of `data-stacked` for a scrim that is being created: an empty string (the attribute is set) when another
|
|
46
|
+
* scrim is drawn, `undefined` (no attribute) when this one is the first. Called from the template, so it runs once, as
|
|
47
|
+
* the scrim is created, before its first frame.
|
|
48
|
+
*
|
|
49
|
+
* @param root - Where to look; the page by default.
|
|
50
|
+
*/
|
|
51
|
+
export function stackedScrimMark(root) {
|
|
52
|
+
try {
|
|
53
|
+
// On the server there is no page, and no dialog is open.
|
|
54
|
+
if (root === undefined && typeof document === 'undefined')
|
|
55
|
+
return undefined;
|
|
56
|
+
return isAnotherScrimDrawn(root ?? document) ? '' : undefined;
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
// The scrim keeps its blur: a double blur is only a flicker, not a broken dialog.
|
|
60
|
+
console.warn('[overlayStacking] Could not tell whether another scrim is drawn', error);
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|