@plexui/vue 0.9.0 → 0.11.0
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/es/components/Alert/Alert.js +6 -2
- package/dist/es/components/Alert/Alert.js.map +1 -1
- package/dist/es/components/Avatar/Avatar.js +3 -1
- package/dist/es/components/Avatar/Avatar.js.map +1 -1
- package/dist/es/components/ButtonGroup/ButtonGroup.js +7 -0
- package/dist/es/components/ButtonGroup/ButtonGroup.js.map +1 -1
- package/dist/es/components/ButtonGroup/index.js.map +1 -1
- package/dist/es/components/Checkbox/Checkbox.js +5 -6
- package/dist/es/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/es/components/ColorPicker/ColorPicker.js +476 -0
- package/dist/es/components/ColorPicker/ColorPicker.js.map +1 -0
- package/dist/es/components/ColorPicker/ColorWell.js +186 -0
- package/dist/es/components/ColorPicker/ColorWell.js.map +1 -0
- package/dist/es/components/ColorPicker/index.js +3 -0
- package/dist/es/components/ColorPicker/index.js.map +1 -0
- package/dist/es/components/ColorPicker/shared.js +132 -0
- package/dist/es/components/ColorPicker/shared.js.map +1 -0
- package/dist/es/components/ContextMenu/ContextMenu.js +223 -0
- package/dist/es/components/ContextMenu/ContextMenu.js.map +1 -0
- package/dist/es/components/ContextMenu/index.js +2 -0
- package/dist/es/components/ContextMenu/index.js.map +1 -0
- package/dist/es/components/ContextMenu/shared.js +58 -0
- package/dist/es/components/ContextMenu/shared.js.map +1 -0
- package/dist/es/components/DatePicker/DatePicker.js +19 -3
- package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/es/components/DateRangePicker/DateRangePicker.js +1 -1
- package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/es/components/Dialog/Dialog.js +245 -25
- package/dist/es/components/Dialog/Dialog.js.map +1 -1
- package/dist/es/components/Dialog/dialogSteps.js +85 -0
- package/dist/es/components/Dialog/dialogSteps.js.map +1 -0
- package/dist/es/components/Dialog/dialogViewport.js +74 -0
- package/dist/es/components/Dialog/dialogViewport.js.map +1 -0
- package/dist/es/components/Dialog/index.js +1 -1
- package/dist/es/components/Dialog/index.js.map +1 -1
- package/dist/es/components/Dialog/sheetDrag.js +2 -1
- package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
- package/dist/es/components/Field/Field.js +11 -3
- package/dist/es/components/Field/Field.js.map +1 -1
- package/dist/es/components/FieldGroup/FieldGroup.js +12 -1
- package/dist/es/components/FieldGroup/FieldGroup.js.map +1 -1
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +2 -2
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js.map +1 -1
- package/dist/es/components/Icon/index.js +1 -0
- package/dist/es/components/Icon/index.js.map +1 -1
- package/dist/es/components/Icon/svg/Eyedropper.js +10 -0
- package/dist/es/components/Icon/svg/Eyedropper.js.map +1 -0
- package/dist/es/components/IndexBar/IndexBar.js +215 -0
- package/dist/es/components/IndexBar/IndexBar.js.map +1 -0
- package/dist/es/components/IndexBar/index.js +2 -0
- package/dist/es/components/IndexBar/index.js.map +1 -0
- package/dist/es/components/Indicator/LoadingIndicator.js +1 -1
- package/dist/es/components/Indicator/LoadingIndicator.js.map +1 -1
- package/dist/es/components/Input/Input.js +3 -2
- package/dist/es/components/Input/Input.js.map +1 -1
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js +149 -1
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
- package/dist/es/components/Menu/Menu.js +206 -33
- package/dist/es/components/Menu/Menu.js.map +1 -1
- package/dist/es/components/Menu/index.js +1 -1
- package/dist/es/components/Menu/index.js.map +1 -1
- package/dist/es/components/Page/Page.js +43 -11
- package/dist/es/components/Page/Page.js.map +1 -1
- package/dist/es/components/PageControl/PageControl.js +210 -0
- package/dist/es/components/PageControl/PageControl.js.map +1 -0
- package/dist/es/components/PageControl/index.js +2 -0
- package/dist/es/components/PageControl/index.js.map +1 -0
- package/dist/es/components/PhoneLayout/PhoneLayout.js +50 -0
- package/dist/es/components/PhoneLayout/PhoneLayout.js.map +1 -0
- package/dist/es/components/PhoneLayout/index.js +2 -0
- package/dist/es/components/PhoneLayout/index.js.map +1 -0
- package/dist/es/components/Popover/Popover.js +5 -1
- package/dist/es/components/Popover/Popover.js.map +1 -1
- package/dist/es/components/Popover/deferredPointerDownOutside.js +59 -4
- package/dist/es/components/Popover/deferredPointerDownOutside.js.map +1 -1
- package/dist/es/components/Select/Select.js +18 -11
- package/dist/es/components/Select/Select.js.map +1 -1
- package/dist/es/components/SelectControl/SelectControl.js +1 -0
- package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
- package/dist/es/components/Sidebar/Sidebar.js +21 -6
- package/dist/es/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/es/components/Slider/Slider.js +44 -9
- package/dist/es/components/Slider/Slider.js.map +1 -1
- package/dist/es/components/Stepper/Stepper.js +195 -0
- package/dist/es/components/Stepper/Stepper.js.map +1 -0
- package/dist/es/components/Stepper/index.js +2 -0
- package/dist/es/components/Stepper/index.js.map +1 -0
- package/dist/es/components/SwipeActions/SwipeActions.js +374 -0
- package/dist/es/components/SwipeActions/SwipeActions.js.map +1 -0
- package/dist/es/components/SwipeActions/index.js +2 -0
- package/dist/es/components/SwipeActions/index.js.map +1 -0
- package/dist/es/components/Switch/Switch.js +3 -1
- package/dist/es/components/Switch/Switch.js.map +1 -1
- package/dist/es/components/TabBar/TabBar.js +205 -0
- package/dist/es/components/TabBar/TabBar.js.map +1 -0
- package/dist/es/components/TabBar/index.js +2 -0
- package/dist/es/components/TabBar/index.js.map +1 -0
- package/dist/es/components/Tabs/Tabs.js +10 -2
- package/dist/es/components/Tabs/Tabs.js.map +1 -1
- package/dist/es/components/TagInput/TagInput.js +3 -46
- package/dist/es/components/TagInput/TagInput.js.map +1 -1
- package/dist/es/components/Textarea/Textarea.js +2 -0
- package/dist/es/components/Textarea/Textarea.js.map +1 -1
- package/dist/es/components/Tip/Tip.js +276 -0
- package/dist/es/components/Tip/Tip.js.map +1 -0
- package/dist/es/components/Tip/index.js +2 -0
- package/dist/es/components/Tip/index.js.map +1 -0
- package/dist/es/components/Toast/ToastRenderer.js +30 -13
- package/dist/es/components/Toast/ToastRenderer.js.map +1 -1
- package/dist/es/components/Toast/Toaster.js +17 -6
- package/dist/es/components/Toast/Toaster.js.map +1 -1
- package/dist/es/components/Toast/toastLifecycle.js +113 -1
- package/dist/es/components/Toast/toastLifecycle.js.map +1 -1
- package/dist/es/components/Toolbar/Toolbar.js +37 -6
- package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/es/components/Toolbar/index.js.map +1 -1
- package/dist/es/components/Tooltip/slot.js +3 -3
- package/dist/es/components/Tooltip/slot.js.map +1 -1
- package/dist/es/composables/useEscCloseStack.js +8 -4
- package/dist/es/composables/useEscCloseStack.js.map +1 -1
- package/dist/es/lib/fieldRow.js +15 -2
- package/dist/es/lib/fieldRow.js.map +1 -1
- package/dist/es/lib/floatingBoundary.js +3 -1
- package/dist/es/lib/floatingBoundary.js.map +1 -1
- package/dist/es/lib/helpers.js +21 -0
- package/dist/es/lib/helpers.js.map +1 -1
- package/dist/es/lib/menuSubmenuPlacement.js +51 -6
- package/dist/es/lib/menuSubmenuPlacement.js.map +1 -1
- package/dist/es/lib/menuTriggerCover.js +70 -0
- package/dist/es/lib/menuTriggerCover.js.map +1 -0
- package/dist/es/lib/phoneLayout.js +16 -0
- package/dist/es/lib/phoneLayout.js.map +1 -0
- package/dist/es/lib/scrollEdges.js +34 -0
- package/dist/es/lib/scrollEdges.js.map +1 -0
- package/dist/es/lib/toastRegion.js +6 -0
- package/dist/es/lib/toastRegion.js.map +1 -0
- package/dist/types/components/ButtonGroup/ButtonGroup.d.ts +13 -0
- package/dist/types/components/ButtonGroup/index.d.ts +1 -1
- package/dist/types/components/ColorPicker/ColorPicker.d.ts +244 -0
- package/dist/types/components/ColorPicker/ColorWell.d.ts +334 -0
- package/dist/types/components/ColorPicker/index.d.ts +3 -0
- package/dist/types/components/ColorPicker/shared.d.ts +69 -0
- package/dist/types/components/ContextMenu/ContextMenu.d.ts +128 -0
- package/dist/types/components/ContextMenu/index.d.ts +1 -0
- package/dist/types/components/ContextMenu/shared.d.ts +51 -0
- package/dist/types/components/DatePicker/DatePicker.d.ts +24 -4
- package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +4 -4
- package/dist/types/components/Dialog/Dialog.d.ts +100 -4
- package/dist/types/components/Dialog/dialogSteps.d.ts +10 -0
- package/dist/types/components/Dialog/dialogViewport.d.ts +1 -0
- package/dist/types/components/Dialog/index.d.ts +1 -1
- package/dist/types/components/Field/Field.d.ts +21 -2
- package/dist/types/components/FieldGroup/FieldGroup.d.ts +18 -1
- package/dist/types/components/Icon/index.d.ts +1 -0
- package/dist/types/components/Icon/svg/Eyedropper.d.ts +3 -0
- package/dist/types/components/IndexBar/IndexBar.d.ts +112 -0
- package/dist/types/components/IndexBar/index.d.ts +1 -0
- package/dist/types/components/Indicator/LoadingIndicator.d.ts +2 -2
- package/dist/types/components/Menu/Menu.d.ts +153 -40
- package/dist/types/components/Menu/index.d.ts +1 -1
- package/dist/types/components/Page/Page.d.ts +13 -5
- package/dist/types/components/PageControl/PageControl.d.ts +216 -0
- package/dist/types/components/PageControl/index.d.ts +1 -0
- package/dist/types/components/PhoneLayout/PhoneLayout.d.ts +21 -0
- package/dist/types/components/PhoneLayout/index.d.ts +1 -0
- package/dist/types/components/Popover/deferredPointerDownOutside.d.ts +1 -1
- package/dist/types/components/Select/Select.d.ts +6 -6
- package/dist/types/components/Stepper/Stepper.d.ts +338 -0
- package/dist/types/components/Stepper/index.d.ts +1 -0
- package/dist/types/components/SwipeActions/SwipeActions.d.ts +135 -0
- package/dist/types/components/SwipeActions/index.d.ts +1 -0
- package/dist/types/components/TabBar/TabBar.d.ts +405 -0
- package/dist/types/components/TabBar/index.d.ts +1 -0
- package/dist/types/components/Tip/Tip.d.ts +146 -0
- package/dist/types/components/Tip/index.d.ts +1 -0
- package/dist/types/components/Toast/toastLifecycle.d.ts +34 -0
- package/dist/types/components/Toolbar/Toolbar.d.ts +26 -9
- package/dist/types/components/Toolbar/index.d.ts +1 -1
- package/dist/types/components/Tooltip/CopyTooltip.d.ts +1 -1
- package/dist/types/composables/useEscCloseStack.d.ts +2 -2
- package/dist/types/lib/fieldRow.d.ts +5 -0
- package/dist/types/lib/helpers.d.ts +6 -0
- package/dist/types/lib/menuSubmenuPlacement.d.ts +14 -1
- package/dist/types/lib/menuTriggerCover.d.ts +23 -0
- package/dist/types/lib/phoneLayout.d.ts +11 -0
- package/dist/types/lib/scrollEdges.d.ts +16 -0
- package/dist/types/lib/toastRegion.d.ts +5 -0
- package/package.json +2 -2
|
@@ -1,17 +1,52 @@
|
|
|
1
|
-
import { cloneVNode, computed, createCommentVNode, defineComponent, h, inject, onBeforeUnmount, onMounted, onUnmounted, provide, ref, watch, } from "vue";
|
|
1
|
+
import { cloneVNode, computed, createCommentVNode, defineComponent, Fragment as FragmentVNode, h, inject, onBeforeUnmount, onMounted, onUnmounted, provide, ref, shallowRef, watch, isVNode, } from "vue";
|
|
2
2
|
import { DialogContent as RekaDialogContent, DialogDescription as RekaDialogDescription, DialogOverlay as RekaDialogOverlay, DialogPortal as RekaDialogPortal, DialogRoot as RekaDialogRoot, DialogTitle as RekaDialogTitle, FocusScope as RekaFocusScope, injectDialogRootContext, useForwardExpose, useId, } from "reka-ui";
|
|
3
3
|
import { useEscCloseStack } from "../../composables/useEscCloseStack.js";
|
|
4
|
-
import {
|
|
4
|
+
import { inToastRegion } from "../../lib/toastRegion.js";
|
|
5
|
+
import { cancelableKeyCopy, dataAttributes, keepMovedFocus, preventDefaultHandler, toCssVariables } from "../../lib/helpers.js";
|
|
5
6
|
import { dismissableSurfaces, useDeferredPointerDownOutside } from "../Popover/deferredPointerDownOutside.js";
|
|
6
7
|
import { firstElementChild } from "../Tooltip/slot.js";
|
|
7
8
|
import { TransitionGroup } from "../Transition/index.js";
|
|
8
9
|
import { attachSheetDrag } from "./sheetDrag.js";
|
|
10
|
+
import { watchDialogViewport } from "./dialogViewport.js";
|
|
11
|
+
import { enterStep, leaveStep, releaseStepHeight, settleStepHeight, STEP_TIMING } from "./dialogSteps.js";
|
|
12
|
+
import { PHONE_LAYOUT as PHONE_LAYOUT_SCOPE } from "../PhoneLayout/PhoneLayout.js";
|
|
9
13
|
import { overlayTiming, overlayTimingLarge } from "../Transition/shared.js";
|
|
10
14
|
import { provideFloatingBoundaryScope, useFloatingBoundaryRegistration } from "../../composables/useFloatingBoundary.js";
|
|
11
15
|
import { NavigationButton } from "../Button/NavigationButton.js";
|
|
12
|
-
import { TOOLBAR_HOST } from "../Toolbar/Toolbar.js";
|
|
16
|
+
import { TOOLBAR_HOST, Toolbar, ToolbarLeading, ToolbarTrailing } from "../Toolbar/Toolbar.js";
|
|
17
|
+
import { observeScrollEdges } from "../../lib/scrollEdges.js";
|
|
13
18
|
import s from "@plexui/styles/components/Dialog/Dialog.module.css";
|
|
19
|
+
import t from "@plexui/styles/components/Toolbar/Toolbar.module.css";
|
|
14
20
|
const DOUBLE_CLICK = 300;
|
|
21
|
+
const DIALOG_SCROLL = Symbol("DialogScroll");
|
|
22
|
+
const DIALOG_SHEET = Symbol("DialogSheet");
|
|
23
|
+
// Inside that bar: the title, the description and the header actions take the Toolbar's parts
|
|
24
|
+
const DIALOG_BAR = Symbol("DialogBar");
|
|
25
|
+
// The phone layout of the Dialog style sheet (its rules for the Sheet's bar use the same query). A dialog's content
|
|
26
|
+
// mounts on the client only (its portal waits for the document), so it reads the layout as it mounts, with nothing to
|
|
27
|
+
// swap after it.
|
|
28
|
+
const PHONE_LAYOUT = "(width <= 767px)";
|
|
29
|
+
const phoneLayout = () => (typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia(PHONE_LAYOUT) : null);
|
|
30
|
+
const usePhoneLayout = () => {
|
|
31
|
+
// Inside a PhoneLayout, or a dialog with `layout="phone"`, at any window width
|
|
32
|
+
const scope = inject(PHONE_LAYOUT_SCOPE, null);
|
|
33
|
+
const query = phoneLayout();
|
|
34
|
+
const narrow = ref(query?.matches ?? false);
|
|
35
|
+
const phone = computed(() => !!scope?.phone.value || narrow.value);
|
|
36
|
+
const update = () => { narrow.value = !!query?.matches; };
|
|
37
|
+
if (!query)
|
|
38
|
+
return phone;
|
|
39
|
+
// Safari before 14 has only the older listener methods
|
|
40
|
+
if (typeof query.addEventListener !== "function") {
|
|
41
|
+
query.addListener(update);
|
|
42
|
+
onBeforeUnmount(() => query.removeListener(update));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
query.addEventListener("change", update);
|
|
46
|
+
onBeforeUnmount(() => query.removeEventListener("change", update));
|
|
47
|
+
}
|
|
48
|
+
return phone;
|
|
49
|
+
};
|
|
15
50
|
const DialogContextKey = Symbol("PlexUIDialog");
|
|
16
51
|
const useDialogContext = () => {
|
|
17
52
|
const context = inject(DialogContextKey, null);
|
|
@@ -128,10 +163,39 @@ export const DialogContent = defineComponent({
|
|
|
128
163
|
onOpenAutoFocus: Function,
|
|
129
164
|
/** Called when focus returns on close; `event.preventDefault()` keeps it elsewhere. */
|
|
130
165
|
onCloseAutoFocus: Function,
|
|
166
|
+
/**
|
|
167
|
+
* Called on Escape before the dialog closes; `event.preventDefault()` keeps it open, such as for a form with
|
|
168
|
+
* unsaved changes.
|
|
169
|
+
*/
|
|
170
|
+
onEscapeKeyDown: Function,
|
|
171
|
+
/**
|
|
172
|
+
* Called on a press or a focus outside the dialog before it closes; `event.preventDefault()` keeps it open, such
|
|
173
|
+
* as for a press on a developer panel over the page.
|
|
174
|
+
*/
|
|
175
|
+
onInteractOutside: Function,
|
|
176
|
+
/** Stack order of the overlay and the dialog. @default 50 */
|
|
177
|
+
zIndex: Number,
|
|
178
|
+
/** Class, style and data attributes for the fixed layer that holds the panel. Data attributes of DialogContent land here too. */
|
|
179
|
+
rootProps: Object,
|
|
180
|
+
/** Class, style and data attributes for the overlay. */
|
|
181
|
+
overlayProps: Object,
|
|
182
|
+
/** `phone` lays the dialog out as on a phone at any window width. Inside a PhoneLayout it always is. @default "auto" */
|
|
183
|
+
layout: { type: String, default: "auto" },
|
|
131
184
|
},
|
|
132
185
|
setup(props, { slots, attrs }) {
|
|
133
186
|
const { open, setOpen, titleCount, descriptionCount } = useDialogContext();
|
|
134
|
-
|
|
187
|
+
const outerPhoneLayout = inject(PHONE_LAYOUT_SCOPE, null);
|
|
188
|
+
// A dialog laid out as on a phone by its own prop, outside a PhoneLayout, keeps the window: what it holds and
|
|
189
|
+
// the dialogs it opens are phone ones too, for as long as the prop says so.
|
|
190
|
+
const phoneLayout = computed(() => !!outerPhoneLayout?.phone.value || props.layout === "phone");
|
|
191
|
+
const portalTarget = computed(() => outerPhoneLayout?.container.value ?? null);
|
|
192
|
+
provide(PHONE_LAYOUT_SCOPE, { container: outerPhoneLayout?.container ?? shallowRef(null), phone: phoneLayout });
|
|
193
|
+
const scroll = { scrolled: ref(false), contentBelow: ref(false) };
|
|
194
|
+
provide(DIALOG_SCROLL, scroll);
|
|
195
|
+
provide(TOOLBAR_HOST, { kind: "dialog", scrolled: scroll.scrolled, contentBelow: scroll.contentBelow });
|
|
196
|
+
provide(DIALOG_SHEET, computed(() => (props.mobileVariant === "sheet" ? { showClose: props.showClose } : null)));
|
|
197
|
+
// A dialog opened from a header action is not inside that header's bar
|
|
198
|
+
provide(DIALOG_BAR, computed(() => false));
|
|
135
199
|
const mobilePlacement = computed(() => props.mobileVariant === "alert"
|
|
136
200
|
? "center"
|
|
137
201
|
: props.mobilePlacement ?? (props.mobileVariant === "sheet" ? "bottom" : undefined));
|
|
@@ -139,6 +203,15 @@ export const DialogContent = defineComponent({
|
|
|
139
203
|
// Radix's root makes the content id; Reka's trigger does, so a dialog
|
|
140
204
|
// without one would render `id=""`
|
|
141
205
|
rootContext.contentId ||= useId(undefined, "reka-dialog-content");
|
|
206
|
+
// Reka replaces the root's content ref as it mounts, so the layer is found from the panel once it is in place
|
|
207
|
+
const panelNode = shallowRef(null);
|
|
208
|
+
let stopViewport;
|
|
209
|
+
watch([panelNode, portalTarget], ([panel, box]) => {
|
|
210
|
+
stopViewport?.();
|
|
211
|
+
const content = panel?.closest("[data-plex-dialog]");
|
|
212
|
+
stopViewport = content ? watchDialogViewport(content, box) : undefined;
|
|
213
|
+
}, { flush: "post", immediate: true });
|
|
214
|
+
onBeforeUnmount(() => stopViewport?.());
|
|
142
215
|
const handleCloseAutoFocus = (rekaEvent) => {
|
|
143
216
|
// Reka announces unmount before descendant scopes release their traps.
|
|
144
217
|
// Match Radix (and our Menu adapter): dispatch the cancellable callback
|
|
@@ -163,24 +236,55 @@ export const DialogContent = defineComponent({
|
|
|
163
236
|
};
|
|
164
237
|
// Escape goes through the shared stack, as in React, so the dialog
|
|
165
238
|
// closes before overlays opened earlier (a forced-open Tooltip)
|
|
166
|
-
useEscCloseStack(open, () => {
|
|
239
|
+
useEscCloseStack(open, (event) => {
|
|
240
|
+
if (props.onEscapeKeyDown) {
|
|
241
|
+
const request = cancelableKeyCopy(event);
|
|
242
|
+
props.onEscapeKeyDown(request);
|
|
243
|
+
if (request.defaultPrevented)
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
167
246
|
setOpen(false);
|
|
168
247
|
});
|
|
169
248
|
// The second click of a double click lands on the overlay: it must not undo the first
|
|
170
249
|
let openedAt = 0;
|
|
171
|
-
//
|
|
250
|
+
// The owner's handler comes first; a prevented interaction keeps the dialog open
|
|
251
|
+
const ownerKeepsOpen = (event) => {
|
|
252
|
+
props.onInteractOutside?.(event);
|
|
253
|
+
return event.defaultPrevented;
|
|
254
|
+
};
|
|
255
|
+
// Radix's modal content: a Ctrl+click (macOS right click) does not dismiss. A deferred press asks the owner when
|
|
256
|
+
// the click completes it, as Radix does, so a form that changed meanwhile can still forbid closing.
|
|
172
257
|
const outsidePress = useDeferredPointerDownOutside((originalEvent) => {
|
|
258
|
+
const request = new CustomEvent("dismissableLayer.pointerDownOutside", { cancelable: true, detail: { originalEvent } });
|
|
259
|
+
if (ownerKeepsOpen(request))
|
|
260
|
+
return;
|
|
173
261
|
if (!originalEvent.ctrlKey && performance.now() - openedAt >= DOUBLE_CLICK)
|
|
174
262
|
setOpen(false);
|
|
175
|
-
});
|
|
263
|
+
}, () => rootContext.contentElement.value);
|
|
176
264
|
const handlePointerDownOutside = (event) => {
|
|
177
265
|
// The native modal owner outlives logical open. An exiting layer must not
|
|
178
266
|
// start a deferred dismissal that closes a trigger-driven reopen.
|
|
179
267
|
if (!open.value)
|
|
180
|
-
event.preventDefault();
|
|
181
|
-
|
|
268
|
+
return event.preventDefault();
|
|
269
|
+
// A press in a toast is not outside: the toast region is a layer above the dialog. The Toaster stops it
|
|
270
|
+
// before Reka sees it; this holds when the Toaster mounted after the dialog.
|
|
271
|
+
if (inToastRegion(event.detail.originalEvent.target))
|
|
272
|
+
return event.preventDefault();
|
|
273
|
+
// A primary mouse or pen press waits for its click; a touch or another button dismisses now, as Reka does
|
|
274
|
+
const { originalEvent } = event.detail;
|
|
275
|
+
if (originalEvent.button === 0 && originalEvent.pointerType !== "touch")
|
|
276
|
+
return outsidePress.onPointerDownOutside(event);
|
|
277
|
+
if (!ownerKeepsOpen(event))
|
|
182
278
|
outsidePress.onPointerDownOutside(event);
|
|
183
279
|
};
|
|
280
|
+
// Focus moving out while a press waits for its click is that press, as on Radix: the owner hears of it once
|
|
281
|
+
const handleFocusOutside = (event) => {
|
|
282
|
+
if (inToastRegion(event.detail?.originalEvent.target))
|
|
283
|
+
return event.preventDefault();
|
|
284
|
+
outsidePress.onFocusOutside(event);
|
|
285
|
+
if (!event.defaultPrevented)
|
|
286
|
+
props.onInteractOutside?.(event);
|
|
287
|
+
};
|
|
184
288
|
const handleInteractOutside = (event) => {
|
|
185
289
|
if (!open.value)
|
|
186
290
|
event.preventDefault();
|
|
@@ -205,11 +309,16 @@ export const DialogContent = defineComponent({
|
|
|
205
309
|
barChildren?.disconnect();
|
|
206
310
|
detachDrag = undefined;
|
|
207
311
|
panelElement = element;
|
|
312
|
+
panelNode.value = element ?? null;
|
|
208
313
|
boundary.setRoot(element);
|
|
209
314
|
if (element) {
|
|
210
315
|
const update = () => {
|
|
211
316
|
// A phone Toolbar takes the place of the header or footer bar on its side.
|
|
212
|
-
|
|
317
|
+
// A phone Toolbar takes the place of the header or footer bar on its side: one the dialog places itself
|
|
318
|
+
// before the bar its header becomes.
|
|
319
|
+
const header = element.querySelector(`:scope > ${TOP_TOOLBAR}:not([data-dialog-bar])`)
|
|
320
|
+
?? element.querySelector(`:scope > ${TOP_TOOLBAR}`)
|
|
321
|
+
?? element.querySelector(`:scope > .${s.Header}`);
|
|
213
322
|
const footer = element.querySelector(`:scope > ${BOTTOM_TOOLBAR}`) ?? element.querySelector(`:scope > .${s.Footer}`);
|
|
214
323
|
element.style.setProperty("--dialog-header-height", `${header?.offsetHeight ?? 0}px`);
|
|
215
324
|
element.style.setProperty("--dialog-footer-height", `${footer?.offsetHeight ?? 0}px`);
|
|
@@ -249,12 +358,21 @@ export const DialogContent = defineComponent({
|
|
|
249
358
|
dismissableSurfaces.add(element);
|
|
250
359
|
};
|
|
251
360
|
const renderDialog = () => h(DialogSurface, { key: "dialog" }, () => [
|
|
252
|
-
h(RekaDialogOverlay, {
|
|
361
|
+
h(RekaDialogOverlay, {
|
|
362
|
+
...props.overlayProps,
|
|
363
|
+
class: [s.Overlay, props.overlayProps?.class],
|
|
364
|
+
style: [layerStyle(), props.overlayProps?.style],
|
|
365
|
+
forceMount: true,
|
|
366
|
+
ref: setOverlayRef,
|
|
367
|
+
"data-state": open.value ? "open" : "closed",
|
|
368
|
+
}),
|
|
253
369
|
h(RekaDialogContent, {
|
|
370
|
+
...dataAttributes(attrs),
|
|
371
|
+
...props.rootProps,
|
|
254
372
|
"forceMount": true,
|
|
255
|
-
"class": s.Content,
|
|
373
|
+
"class": [s.Content, props.rootProps?.class],
|
|
256
374
|
"data-plex-dialog": "",
|
|
257
|
-
"style": toCssVariables({ "dialog-width": props.width }),
|
|
375
|
+
"style": [toCssVariables({ "dialog-width": props.width }), layerStyle(), props.rootProps?.style],
|
|
258
376
|
"data-placement": props.placement === "center" ? undefined : props.placement,
|
|
259
377
|
"data-mobile-placement": mobilePlacement.value,
|
|
260
378
|
"data-mobile-variant": props.mobileVariant,
|
|
@@ -268,7 +386,7 @@ export const DialogContent = defineComponent({
|
|
|
268
386
|
...(descriptionCount.value > 0 ? {} : { "aria-describedby": undefined }),
|
|
269
387
|
"onEscapeKeyDown": preventDefaultHandler,
|
|
270
388
|
"onPointerDownOutside": handlePointerDownOutside,
|
|
271
|
-
"onFocusOutside":
|
|
389
|
+
"onFocusOutside": handleFocusOutside,
|
|
272
390
|
"onInteractOutside": handleInteractOutside,
|
|
273
391
|
}, {
|
|
274
392
|
default: () => [
|
|
@@ -297,12 +415,16 @@ export const DialogContent = defineComponent({
|
|
|
297
415
|
],
|
|
298
416
|
}),
|
|
299
417
|
]);
|
|
418
|
+
const layerStyle = () => toCssVariables({ "dialog-z-index": props.zIndex === undefined ? undefined : String(props.zIndex) });
|
|
300
419
|
return () => {
|
|
301
420
|
const { placement } = props;
|
|
302
421
|
const crossesScreen = placement === "bottom" || placement === "start" || placement === "end" || placement === "fullscreen" || mobilePlacement.value === "bottom" || mobilePlacement.value === "fullscreen";
|
|
303
|
-
|
|
422
|
+
// Portaled out of any phone layout, a phone dialog carries its own scope, above its transition: the phone rules
|
|
423
|
+
// of the style sheet start there.
|
|
424
|
+
const scoped = (group) => phoneLayout.value && !portalTarget.value ? h("div", { class: s.PhoneScope, "data-plex-layout": "phone" }, [group]) : group;
|
|
425
|
+
return h(RekaDialogPortal, { to: portalTarget.value ?? undefined }, {
|
|
304
426
|
default: () => [
|
|
305
|
-
h(TransitionGroup,
|
|
427
|
+
scoped(h(TransitionGroup,
|
|
306
428
|
// A dialog mounted open enters too, as `v-if` and `open` together do
|
|
307
429
|
{
|
|
308
430
|
class: s.Transition,
|
|
@@ -311,23 +433,51 @@ export const DialogContent = defineComponent({
|
|
|
311
433
|
preventInitialTransition: false,
|
|
312
434
|
},
|
|
313
435
|
// `open && <div>` in React: closed still renders the empty wrapper
|
|
314
|
-
{ default: () => [open.value ? renderDialog() : createCommentVNode()] }),
|
|
436
|
+
{ default: () => [open.value ? renderDialog() : createCommentVNode()] })),
|
|
315
437
|
],
|
|
316
438
|
});
|
|
317
439
|
};
|
|
318
440
|
},
|
|
319
441
|
});
|
|
442
|
+
// The header's own parts, fragments opened up, so its actions can stand at the end of the bar
|
|
443
|
+
const headerParts = (children) => (children ?? []).flatMap((part) => isVNode(part) && part.type === FragmentVNode ? headerParts(part.children) : Array.isArray(part) ? headerParts(part) : [part]);
|
|
444
|
+
const isHeaderAction = (part) => isVNode(part) && part.type === DialogHeaderAction;
|
|
320
445
|
export const DialogHeader = defineComponent({
|
|
321
446
|
name: "DialogHeader",
|
|
322
|
-
props: {
|
|
447
|
+
props: {
|
|
448
|
+
/** How the bar meets the content scrolled under it in a phone Sheet. @default "glass" */
|
|
449
|
+
background: { type: String, default: "glass" },
|
|
450
|
+
},
|
|
323
451
|
setup(props, { slots }) {
|
|
324
|
-
|
|
452
|
+
const scroll = inject(DIALOG_SCROLL, null);
|
|
453
|
+
const sheet = inject(DIALOG_SHEET, null);
|
|
454
|
+
const phone = usePhoneLayout();
|
|
455
|
+
const bar = computed(() => !!sheet?.value && phone.value);
|
|
456
|
+
provide(DIALOG_BAR, bar);
|
|
457
|
+
return () => {
|
|
458
|
+
if (!bar.value)
|
|
459
|
+
return h("div", { class: s.Header, "data-background": props.background, "data-scrolled": scroll?.scrolled.value ? "" : undefined }, slots.default?.());
|
|
460
|
+
const parts = headerParts(slots.default?.());
|
|
461
|
+
// On a phone the header of a Sheet is its Toolbar (iOS 27 kit Sheets 507-24684, Toolbar - Top - iPhone
|
|
462
|
+
// 1-54520): Close at the leading edge, the title centered on the row of controls, the header actions at the
|
|
463
|
+
// trailing edge, all on one 44px row under the grabber.
|
|
464
|
+
return h(Toolbar, { "background": props.background, "data-dialog-bar": "" }, () => [
|
|
465
|
+
sheet?.value?.showClose
|
|
466
|
+
? h(ToolbarLeading, { class: s.BarClose }, () => [
|
|
467
|
+
h(DialogClose, null, { default: () => [h(NavigationButton, { "action": "close", "variant": "ghost", "aria-label": "Close dialog" })] }),
|
|
468
|
+
])
|
|
469
|
+
: null,
|
|
470
|
+
h("div", { class: [t.Heading, s.BarHeading] }, parts.filter((part) => !isHeaderAction(part))),
|
|
471
|
+
...parts.filter(isHeaderAction),
|
|
472
|
+
]);
|
|
473
|
+
};
|
|
325
474
|
},
|
|
326
475
|
});
|
|
327
476
|
export const DialogHeaderAction = defineComponent({
|
|
328
477
|
name: "DialogHeaderAction",
|
|
329
478
|
setup(_props, { slots }) {
|
|
330
|
-
|
|
479
|
+
const bar = inject(DIALOG_BAR, null);
|
|
480
|
+
return () => (bar?.value ? h(ToolbarTrailing, null, () => slots.default?.()) : h("div", { class: s.HeaderAction }, slots.default?.()));
|
|
331
481
|
},
|
|
332
482
|
});
|
|
333
483
|
/** The scrolling part between DialogHeader and DialogFooter: with it, only the body scrolls. */
|
|
@@ -335,7 +485,25 @@ export const DialogBody = defineComponent({
|
|
|
335
485
|
name: "DialogBody",
|
|
336
486
|
inheritAttrs: false,
|
|
337
487
|
setup(_props, { slots, attrs }) {
|
|
338
|
-
|
|
488
|
+
const scroll = inject(DIALOG_SCROLL, null);
|
|
489
|
+
const element = ref(null);
|
|
490
|
+
let stop;
|
|
491
|
+
onMounted(() => {
|
|
492
|
+
if (!element.value || !scroll)
|
|
493
|
+
return;
|
|
494
|
+
stop = observeScrollEdges(element.value, (edges) => {
|
|
495
|
+
scroll.scrolled.value = edges.scrolled;
|
|
496
|
+
scroll.contentBelow.value = edges.contentBelow;
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
onBeforeUnmount(() => {
|
|
500
|
+
stop?.();
|
|
501
|
+
if (scroll) {
|
|
502
|
+
scroll.scrolled.value = false;
|
|
503
|
+
scroll.contentBelow.value = false;
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
return () => h("div", { ref: element, class: [s.Body, attrs.class] }, slots.default?.());
|
|
339
507
|
},
|
|
340
508
|
});
|
|
341
509
|
export const DialogFooter = defineComponent({
|
|
@@ -343,11 +511,19 @@ export const DialogFooter = defineComponent({
|
|
|
343
511
|
props: {
|
|
344
512
|
/** Override the mobile action layout. Alerts default to inline; sheets to stacked. */
|
|
345
513
|
mobileLayout: String,
|
|
346
|
-
|
|
514
|
+
/** How the bar meets the content scrolled under it in a phone Sheet. @default "soft" */
|
|
515
|
+
background: { type: String, default: "soft" },
|
|
347
516
|
},
|
|
348
517
|
setup(props, { slots }) {
|
|
349
518
|
const boundary = useFloatingBoundaryRegistration();
|
|
350
|
-
|
|
519
|
+
const scroll = inject(DIALOG_SCROLL, null);
|
|
520
|
+
return () => h("div", {
|
|
521
|
+
"ref": boundary?.setFooter,
|
|
522
|
+
"class": s.Footer,
|
|
523
|
+
"data-mobile-layout": props.mobileLayout,
|
|
524
|
+
"data-background": props.background,
|
|
525
|
+
"data-content-below": scroll?.contentBelow.value ? "" : undefined,
|
|
526
|
+
}, slots.default?.());
|
|
351
527
|
},
|
|
352
528
|
});
|
|
353
529
|
/** Counts a mounted part, as Radix's title and description counts do. */
|
|
@@ -363,14 +539,26 @@ export const DialogTitle = defineComponent({
|
|
|
363
539
|
name: "DialogTitle",
|
|
364
540
|
setup(_props, { slots }) {
|
|
365
541
|
useMountedCount(useDialogContext().titleCount);
|
|
366
|
-
|
|
542
|
+
const bar = inject(DIALOG_BAR, null);
|
|
543
|
+
return () => h(RekaDialogTitle, { class: bar?.value ? t.Title : s.Title }, { default: () => slots.default?.() });
|
|
367
544
|
},
|
|
368
545
|
});
|
|
369
546
|
export const DialogDescription = defineComponent({
|
|
370
547
|
name: "DialogDescription",
|
|
371
548
|
setup(_props, { slots }) {
|
|
372
549
|
useMountedCount(useDialogContext().descriptionCount);
|
|
373
|
-
|
|
550
|
+
const bar = inject(DIALOG_BAR, null);
|
|
551
|
+
const element = ref(null);
|
|
552
|
+
const shown = ref(false);
|
|
553
|
+
// In the bar a description the reader sees is the title's second line (Toolbar's subtitle); one that is only
|
|
554
|
+
// read out, visually hidden, leaves the title on its one line.
|
|
555
|
+
const measure = () => {
|
|
556
|
+
const node = element.value instanceof Element ? element.value : element.value?.$el;
|
|
557
|
+
shown.value = !!bar?.value && node instanceof HTMLElement && node.offsetHeight > 1 && node.offsetWidth > 1;
|
|
558
|
+
};
|
|
559
|
+
onMounted(measure);
|
|
560
|
+
watch(() => bar?.value, () => queueMicrotask(measure));
|
|
561
|
+
return () => h(RekaDialogDescription, { ref: element, class: bar?.value && shown.value ? t.Subtitle : s.Description }, { default: () => slots.default?.() });
|
|
374
562
|
},
|
|
375
563
|
});
|
|
376
564
|
export const DialogClose = defineComponent({
|
|
@@ -384,4 +572,36 @@ export const DialogClose = defineComponent({
|
|
|
384
572
|
return () => withDialogProps(firstElementChild(slots.default?.()), { type: "button" }, onClick);
|
|
385
573
|
},
|
|
386
574
|
});
|
|
575
|
+
/** The steps of a flow inside a dialog, such as a sign-in that asks for an email and then a code. */
|
|
576
|
+
export const DialogSteps = defineComponent({
|
|
577
|
+
name: "DialogSteps",
|
|
578
|
+
props: {
|
|
579
|
+
/** The step on screen. A new value brings its content in. */
|
|
580
|
+
step: { type: [String, Number], required: true },
|
|
581
|
+
/**
|
|
582
|
+
* `forward` brings the new step in from the trailing edge over the one before, as a push on iOS; `back` returns
|
|
583
|
+
* to a step before it.
|
|
584
|
+
* @default "forward"
|
|
585
|
+
*/
|
|
586
|
+
direction: { type: String, default: "forward" },
|
|
587
|
+
},
|
|
588
|
+
setup(props, { slots }) {
|
|
589
|
+
return () => {
|
|
590
|
+
// Resolve this step now, so a step that leaves cannot read the next one
|
|
591
|
+
const entry = h("div", { "key": props.step, "data-dialog-step": "", "tabindex": -1 }, slots.default?.());
|
|
592
|
+
return h("div", { "class": s.Steps, "data-direction": props.direction }, [
|
|
593
|
+
h(TransitionGroup, {
|
|
594
|
+
...STEP_TIMING,
|
|
595
|
+
as: "div",
|
|
596
|
+
overlay: true,
|
|
597
|
+
class: s.Step,
|
|
598
|
+
onEnter: enterStep,
|
|
599
|
+
onExit: leaveStep,
|
|
600
|
+
onExitActive: settleStepHeight,
|
|
601
|
+
onExitComplete: releaseStepHeight,
|
|
602
|
+
}, () => [entry]),
|
|
603
|
+
]);
|
|
604
|
+
};
|
|
605
|
+
},
|
|
606
|
+
});
|
|
387
607
|
//# sourceMappingURL=Dialog.js.map
|