@scalar/components 0.36.0 → 0.36.1
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/ScalarCard/ScalarCard.vue.d.ts.map +1 -1
- package/dist/components/ScalarCard/ScalarCard.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarDialog/ScalarDialog.vue.d.ts.map +1 -1
- package/dist/components/ScalarDialog/ScalarDialog.vue_vue_type_script_setup_true_lang.js +19 -2
- package/dist/components/ScalarDialog/ScalarDialog.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarModal/ScalarModal.vue.d.ts +0 -2
- package/dist/components/ScalarModal/ScalarModal.vue.d.ts.map +1 -1
- package/dist/components/ScalarModal/ScalarModal.vue.js +1 -1
- package/dist/components/ScalarModal/ScalarModal.vue_vue_type_script_setup_true_lang.js +53 -34
- package/dist/components/ScalarModal/ScalarModal.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarTeleport/ScalarTeleport.vue.d.ts +2 -1
- package/dist/components/ScalarTeleport/ScalarTeleport.vue.d.ts.map +1 -1
- package/dist/components/ScalarTeleport/ScalarTeleport.vue_vue_type_script_setup_true_lang.js +47 -4
- package/dist/components/ScalarTeleport/ScalarTeleport.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarTooltip/useTooltip.d.ts.map +1 -1
- package/dist/components/ScalarTooltip/useTooltip.js +7 -2
- package/dist/components/ScalarTooltip/useTooltip.js.map +1 -1
- package/dist/style.css +57 -38
- package/dist/vue-styles.css +20 -19
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarCard.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarCard/ScalarCard.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarCard.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarCard/ScalarCard.vue"],"names":[],"mappings":"AAmHA;;;;;;;;;;;;;GAaG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;IAEhB,yCAAyC;YACjC,MAAM;;IADd,yCAAyC;YACjC,MAAM;;cAsDF,CAAC,KAAK,IAAgB,KAAK,GAAG;EASxC,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarCard.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_mergeProps","_unref","_renderSlot"],"sources":["../../../src/components/ScalarCard/ScalarCard.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar card component\n *\n * Creates an aria region using the nearest ScalarCardHeader as the label\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/region_role\n *\n * @example\n * <ScalarCard>\n * <ScalarCardHeader>Header</ScalarCardHeader>\n * <ScalarCardSection>Content</ScalarCardSection>\n * <ScalarCardFooter>Footer</ScalarCardFooter>\n * </ScalarCard>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { computed } from 'vue'\n\nimport { useCardRegion } from './useCardHeading'\n\nconst { label } = defineProps<{\n /** The a11y label for the card region */\n label?: string\n}>()\n\n// Get the id for the nearest ScalarCardHeader if it exists\nconst { id } = useCardRegion()\n\nconst labelAttrs = computed(() => {\n if (label) {\n // If a label is provided, use it\n return { 'aria-label': label }\n }\n if (id.value) {\n // If no label is provided, use the heading id\n return { 'aria-labelledby': id.value }\n }\n // If no label or heading id is provided, don't add any aria attributes\n return {}\n})\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <div\n role=\"group\"\n v-bind=\"{\n ...labelAttrs,\n ...cx('scalar-card bg-b-2 flex flex-col rounded-2xl p-1'),\n }\">\n <slot />\n </div>\n</template>\n<style>\n/**\n * A card is a backdrop with its sections lifted off it as surfaces.\n *\n * The surface color is worked out from the backdrop instead of being read from another theme\n * token, so it stays one step lighter than the card whatever a theme does to the card's colors.\n * That lands on white over the default light backdrop and next to --scalar-background-3 over the\n * default dark one, and it keeps working for a theme that paints its cards dark in light mode,\n * where a token picked by color mode would be the wrong way round.\n *\n * A control that sits on a surface, such as a copy button, is one step further again. That step\n * goes toward the text color, so it is lighter than a dark surface and darker than a light one,\n * and never sinks back to the color of the card behind the surface.\n *\n * The variables are resolved here, on the card, so a section that swaps --scalar-background-2 for\n * its own purposes does not move the surface under the code inside it, and so a theme can set\n * --scalar-card-surface, --scalar-card-surface-raised or --scalar-card-surface-shadow on\n * `.scalar-card` without restating a section selector.\n *\n * Every rule below is a single class, so any theme or `customCss` rule that names the same\n * element still wins.\n */\n.scalar-card {\n /* Browsers without relative colors get the light arrangement in both color modes. */\n --scalar-card-surface: var(--scalar-background-1);\n --scalar-card-surface-raised: var(--scalar-background-2);\n /* The theme's own soft shadow and border color, so a theme steers the outline of a surface */\n --scalar-card-surface-shadow:\n var(--scalar-shadow-1),\n 0 0 0 var(--scalar-border-width) var(--scalar-border-color);\n}\n@supports (color:
|
|
1
|
+
{"version":3,"file":"ScalarCard.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_mergeProps","_unref","_renderSlot"],"sources":["../../../src/components/ScalarCard/ScalarCard.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar card component\n *\n * Creates an aria region using the nearest ScalarCardHeader as the label\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/region_role\n *\n * @example\n * <ScalarCard>\n * <ScalarCardHeader>Header</ScalarCardHeader>\n * <ScalarCardSection>Content</ScalarCardSection>\n * <ScalarCardFooter>Footer</ScalarCardFooter>\n * </ScalarCard>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { computed } from 'vue'\n\nimport { useCardRegion } from './useCardHeading'\n\nconst { label } = defineProps<{\n /** The a11y label for the card region */\n label?: string\n}>()\n\n// Get the id for the nearest ScalarCardHeader if it exists\nconst { id } = useCardRegion()\n\nconst labelAttrs = computed(() => {\n if (label) {\n // If a label is provided, use it\n return { 'aria-label': label }\n }\n if (id.value) {\n // If no label is provided, use the heading id\n return { 'aria-labelledby': id.value }\n }\n // If no label or heading id is provided, don't add any aria attributes\n return {}\n})\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <div\n role=\"group\"\n v-bind=\"{\n ...labelAttrs,\n ...cx('scalar-card bg-b-2 flex flex-col rounded-2xl p-1'),\n }\">\n <slot />\n </div>\n</template>\n<style>\n/**\n * A card is a backdrop with its sections lifted off it as surfaces.\n *\n * The surface color is worked out from the backdrop instead of being read from another theme\n * token, so it stays one step lighter than the card whatever a theme does to the card's colors.\n * That lands on white over the default light backdrop and next to --scalar-background-3 over the\n * default dark one, and it keeps working for a theme that paints its cards dark in light mode,\n * where a token picked by color mode would be the wrong way round.\n *\n * A control that sits on a surface, such as a copy button, is one step further again. That step\n * goes toward the text color, so it is lighter than a dark surface and darker than a light one,\n * and never sinks back to the color of the card behind the surface.\n *\n * The variables are resolved here, on the card, so a section that swaps --scalar-background-2 for\n * its own purposes does not move the surface under the code inside it, and so a theme can set\n * --scalar-card-surface, --scalar-card-surface-raised or --scalar-card-surface-shadow on\n * `.scalar-card` without restating a section selector.\n *\n * Every rule below is a single class, so any theme or `customCss` rule that names the same\n * element still wins.\n */\n.scalar-card {\n /* Browsers without relative colors get the light arrangement in both color modes. */\n --scalar-card-surface: var(--scalar-background-1);\n --scalar-card-surface-raised: var(--scalar-background-2);\n /* The theme's own soft shadow and border color, so a theme steers the outline of a surface */\n --scalar-card-surface-shadow:\n var(--scalar-shadow-1),\n 0 0 0 var(--scalar-border-width) var(--scalar-border-color);\n}\n@supports (color: oklab(from white l a b)) {\n .scalar-card {\n /*\n * The lightness step is taken in oklab, not oklch. Chrome treats the hue of a near-grey color\n * as missing in oklch(from …) but keeps its small chroma, which turned the surfaces of themes\n * with tinted greys pink. Oklab has the same lightness and no hue to lose.\n */\n --scalar-card-surface: oklab(\n from var(--scalar-background-2) calc(l + 0.055) a b\n );\n --scalar-card-surface-raised: color-mix(\n in oklab,\n var(--scalar-card-surface),\n var(--scalar-color-1) 8%\n );\n }\n}\n</style>\n"],"mappings":";;;;;;;;EA6BA,MAAM,EAAE,OAAO,cAAc;EAE7B,MAAM,aAAa,eAAe;GAChC,IAAI,QAAA,OAEF,OAAO,EAAE,cAAc,QAAA,MAAM;GAE/B,IAAI,GAAG,OAEL,OAAO,EAAE,mBAAmB,GAAG,MAAM;GAGvC,OAAO,CAAC;EACV,CAAC;EAGD,MAAM,EAAE,OAAO,UAAU;;GAGvB,OAAAA,UAAA,GAAAC,mBAOM,OAPNC,WAOM,EANJ,MAAK,QAAO,GAAA;IACO,GAAA,WAAA;IAAqB,GAAAC,MAAA,EAAA,CAAE,CAAA,kDAAA;G,KAI1CC,WAAQ,KAAA,QAAA,SAAA,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarDialog.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarDialog/ScalarDialog.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarDialog.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarDialog/ScalarDialog.vue"],"names":[],"mappings":"AAiNA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAKhD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;IAgKlB,uFAAuF;WAC9E,OAAO;;;;;;IADhB,uFAAuF;WAC9E,OAAO;;;;;IArJd,2EAA2E;eAChE,OAAO;EAwNhB,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -23,12 +23,29 @@ var ScalarDialog_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
23
23
|
const open = useModel(__props, "open");
|
|
24
24
|
const dialog = cva({ base: [
|
|
25
25
|
"scalar-dialog m-auto rounded-lg border-0 p-3 shadow-lg",
|
|
26
|
+
"not-open:hidden",
|
|
26
27
|
"bg-b-1 text-c-1",
|
|
27
28
|
"backdrop:bg-backdrop dark:backdrop:bg-backdrop-dark",
|
|
28
29
|
"custom-scroll max-h-[85svh] w-[calc(100dvw-2rem)] max-w-md overflow-auto"
|
|
29
30
|
] });
|
|
30
31
|
const { cx } = useBindCx();
|
|
31
32
|
const dialogRef = ref(null);
|
|
33
|
+
/**
|
|
34
|
+
* Open the dialog as a modal, or just mark it open where the dialog API is missing.
|
|
35
|
+
*
|
|
36
|
+
* jsdom (and so every consumer's component tests) and very old browsers do not implement
|
|
37
|
+
* `showModal()`. Toggling the `open` attribute there keeps the contents rendering and the model
|
|
38
|
+
* working, without the top layer, focus trap or inert background the real API adds.
|
|
39
|
+
*/
|
|
40
|
+
const showModal = (element) => {
|
|
41
|
+
if (typeof element.showModal === "function") element.showModal();
|
|
42
|
+
else element.setAttribute("open", "");
|
|
43
|
+
};
|
|
44
|
+
/** Close the dialog, falling back to removing the `open` attribute like {@link showModal}. */
|
|
45
|
+
const closeDialog = (element) => {
|
|
46
|
+
if (typeof element.close === "function") element.close();
|
|
47
|
+
else element.removeAttribute("open");
|
|
48
|
+
};
|
|
32
49
|
const { lock, unlock } = useScrollLock();
|
|
33
50
|
/** Whether the dialog was open on the last run of the bridge, so `close` fires once per close. */
|
|
34
51
|
let wasOpen = false;
|
|
@@ -44,11 +61,11 @@ var ScalarDialog_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
|
|
|
44
61
|
const element = dialogRef.value;
|
|
45
62
|
if (!element) return;
|
|
46
63
|
if (open.value) {
|
|
47
|
-
if (!element.open)
|
|
64
|
+
if (!element.open) showModal(element);
|
|
48
65
|
lock(element);
|
|
49
66
|
wasOpen = true;
|
|
50
67
|
} else {
|
|
51
|
-
if (element.open) element
|
|
68
|
+
if (element.open) closeDialog(element);
|
|
52
69
|
unlock();
|
|
53
70
|
if (wasOpen) emit("close");
|
|
54
71
|
wasOpen = false;
|
package/dist/components/ScalarDialog/ScalarDialog.vue_vue_type_script_setup_true_lang.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarDialog.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createElementBlock","_mergeProps","_unref","_withKeys","_createBlock","ScalarTeleportRoot","_withCtx","_renderSlot"],"sources":["../../../src/components/ScalarDialog/ScalarDialog.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Dialog\n *\n * A modal dialog built on the native `<dialog>` element. It calls `showModal()`\n * under the hood, so the dialog is promoted to the browser top layer (escaping\n * ancestor stacking, overflow, and transform contexts), traps and restores focus,\n * makes the rest of the page inert, and closes on Escape — all natively, with no\n * teleport. It also locks page scrolling while open, and gives popovers inside it a\n * teleport target within the dialog so they render above it rather than under the\n * top layer.\n *\n * Control it with `v-model:open` and compose the contents with the default slot.\n * Restyle or resize it by passing your own `class`; the defaults are intentionally\n * minimal so consumers compose rather than configure.\n *\n * Give the dialog an accessible name, ideally by pointing `aria-labelledby` at its\n * visible heading so screen readers announce the same title sighted users see.\n *\n * @example\n * <ScalarDialog v-model:open=\"open\">\n * <h2>Title</h2>\n * <p>Some content</p>\n * </ScalarDialog>\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { cva, useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { ref, watchPostEffect } from 'vue'\n\nimport { ScalarTeleportRoot } from '../ScalarTeleport'\nimport type { ScalarDialogProps } from './types'\nimport { useBackdropClick } from './useBackdropClick'\nimport { useScrollLock } from './useScrollLock'\n\nconst { persist = false } = defineProps<ScalarDialogProps>()\n\nconst emit = defineEmits<{\n /** Emitted whenever the dialog closes, whether via Escape, a backdrop click, or `open` being set to false. */\n (e: 'close'): void\n}>()\n\ndefineSlots<{\n /** The dialog contents. Compose your own header, body, and footer here. */\n default(): unknown\n}>()\n\n/** Whether the dialog is open. Drives the native `showModal()` and `close()` calls. */\nconst open = defineModel<boolean>('open', { default: false })\n\nconst dialog = cva({\n base: [\n // Reset the native dialog chrome and center it within the top layer\n 'scalar-dialog m-auto rounded-lg border-0 p-3 shadow-lg',\n // Surface colors\n 'bg-b-1 text-c-1',\n // Theme the native ::backdrop via Tailwind's backdrop variant\n 'backdrop:bg-backdrop dark:backdrop:bg-backdrop-dark',\n // Constrain the size and let long content scroll\n 'custom-scroll max-h-[85svh] w-[calc(100dvw-2rem)] max-w-md overflow-auto',\n ],\n})\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n\nconst dialogRef = ref<HTMLDialogElement | null>(null)\n\nconst { lock, unlock } = useScrollLock()\n\n/** Whether the dialog was open on the last run of the bridge, so `close` fires once per close. */\nlet wasOpen = false\n\n/**\n * Puppet the native dialog from the reactive `open` model.\n *\n * `watchPostEffect` runs after the DOM updates, so the slotted content (and any\n * `autofocus` target) is mounted before `showModal()` moves focus into it. The\n * guards against `dialog.open` avoid the `InvalidStateError` the browser throws\n * when `showModal()` is called on an already-open dialog.\n */\nwatchPostEffect(() => {\n const element = dialogRef.value\n if (!element) {\n return\n }\n\n if (open.value) {\n if (!element.open) {\n
|
|
1
|
+
{"version":3,"file":"ScalarDialog.vue_vue_type_script_setup_true_lang.js","names":["_useModel","_openBlock","_createElementBlock","_mergeProps","_unref","_withKeys","_createBlock","ScalarTeleportRoot","_withCtx","_renderSlot"],"sources":["../../../src/components/ScalarDialog/ScalarDialog.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Dialog\n *\n * A modal dialog built on the native `<dialog>` element. It calls `showModal()`\n * under the hood, so the dialog is promoted to the browser top layer (escaping\n * ancestor stacking, overflow, and transform contexts), traps and restores focus,\n * makes the rest of the page inert, and closes on Escape — all natively, with no\n * teleport. It also locks page scrolling while open, and gives popovers inside it a\n * teleport target within the dialog so they render above it rather than under the\n * top layer.\n *\n * Control it with `v-model:open` and compose the contents with the default slot.\n * Restyle or resize it by passing your own `class`; the defaults are intentionally\n * minimal so consumers compose rather than configure.\n *\n * Give the dialog an accessible name, ideally by pointing `aria-labelledby` at its\n * visible heading so screen readers announce the same title sighted users see.\n *\n * @example\n * <ScalarDialog v-model:open=\"open\">\n * <h2>Title</h2>\n * <p>Some content</p>\n * </ScalarDialog>\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { cva, useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { ref, watchPostEffect } from 'vue'\n\nimport { ScalarTeleportRoot } from '../ScalarTeleport'\nimport type { ScalarDialogProps } from './types'\nimport { useBackdropClick } from './useBackdropClick'\nimport { useScrollLock } from './useScrollLock'\n\nconst { persist = false } = defineProps<ScalarDialogProps>()\n\nconst emit = defineEmits<{\n /** Emitted whenever the dialog closes, whether via Escape, a backdrop click, or `open` being set to false. */\n (e: 'close'): void\n}>()\n\ndefineSlots<{\n /** The dialog contents. Compose your own header, body, and footer here. */\n default(): unknown\n}>()\n\n/** Whether the dialog is open. Drives the native `showModal()` and `close()` calls. */\nconst open = defineModel<boolean>('open', { default: false })\n\nconst dialog = cva({\n base: [\n // Reset the native dialog chrome and center it within the top layer\n 'scalar-dialog m-auto rounded-lg border-0 p-3 shadow-lg',\n // Keep a closed dialog hidden even when a consumer class sets its display, such as `flex`\n 'not-open:hidden',\n // Surface colors\n 'bg-b-1 text-c-1',\n // Theme the native ::backdrop via Tailwind's backdrop variant\n 'backdrop:bg-backdrop dark:backdrop:bg-backdrop-dark',\n // Constrain the size and let long content scroll\n 'custom-scroll max-h-[85svh] w-[calc(100dvw-2rem)] max-w-md overflow-auto',\n ],\n})\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n\nconst dialogRef = ref<HTMLDialogElement | null>(null)\n\n/**\n * Open the dialog as a modal, or just mark it open where the dialog API is missing.\n *\n * jsdom (and so every consumer's component tests) and very old browsers do not implement\n * `showModal()`. Toggling the `open` attribute there keeps the contents rendering and the model\n * working, without the top layer, focus trap or inert background the real API adds.\n */\nconst showModal = (element: HTMLDialogElement): void => {\n if (typeof element.showModal === 'function') {\n element.showModal()\n } else {\n element.setAttribute('open', '')\n }\n}\n\n/** Close the dialog, falling back to removing the `open` attribute like {@link showModal}. */\nconst closeDialog = (element: HTMLDialogElement): void => {\n if (typeof element.close === 'function') {\n element.close()\n } else {\n element.removeAttribute('open')\n }\n}\n\nconst { lock, unlock } = useScrollLock()\n\n/** Whether the dialog was open on the last run of the bridge, so `close` fires once per close. */\nlet wasOpen = false\n\n/**\n * Puppet the native dialog from the reactive `open` model.\n *\n * `watchPostEffect` runs after the DOM updates, so the slotted content (and any\n * `autofocus` target) is mounted before `showModal()` moves focus into it. The\n * guards against `dialog.open` avoid the `InvalidStateError` the browser throws\n * when `showModal()` is called on an already-open dialog.\n */\nwatchPostEffect(() => {\n const element = dialogRef.value\n if (!element) {\n return\n }\n\n if (open.value) {\n if (!element.open) {\n showModal(element)\n }\n lock(element)\n wasOpen = true\n } else {\n if (element.open) {\n closeDialog(element)\n }\n unlock()\n // Emit here rather than from the native `close` event, which is queued and never\n // arrives if the dialog is reopened before it fires\n if (wasOpen) {\n emit('close')\n }\n wasOpen = false\n }\n})\n\n/**\n * Mirror native closes (a form submit, or the browser force-closing the dialog) back into the model.\n *\n * The `close` event is queued rather than fired synchronously, so when the dialog is closed and\n * reopened in quick succession the event lands after it is open again. Ignoring it while the\n * dialog is open keeps that stale event from closing it.\n */\nconst handleClose = (): void => {\n if (dialogRef.value?.open) {\n return\n }\n open.value = false\n}\n\n/**\n * Close on Escape, unless something inside the dialog already handled it.\n *\n * Child widgets such as listboxes and comboboxes use Escape to close themselves and mark the event\n * as handled, so the dialog leaves those alone. The same goes for Escape cancelling an IME\n * composition, which should not also close the dialog. Stopping propagation means only the innermost of\n * several nested dialogs closes. Preventing the default also stops a search input from clearing\n * its value on the same keypress that dismisses the dialog.\n */\nconst handleEscape = (event: KeyboardEvent): void => {\n if (event.defaultPrevented || event.isComposing) {\n return\n }\n event.preventDefault()\n event.stopPropagation()\n open.value = false\n}\n\n/**\n * Route other close requests, such as the Android back gesture, through the model.\n *\n * The browser would otherwise close the dialog itself. Going through `open` keeps every close on\n * the same path, so the scroll lock is released and the contents unmount in step.\n */\nconst handleCancel = (event: Event): void => {\n event.preventDefault()\n open.value = false\n}\n\n/**\n * Close when the backdrop is clicked. The composable ignores text-selection drags\n * and keyboard-activated controls; setting `open` to false lets the puppet bridge\n * run the native `close()` so the flow matches Escape and programmatic closes.\n */\nconst { handlePointerDown, handleClick } = useBackdropClick(dialogRef, () => {\n open.value = false\n})\n</script>\n\n<template>\n <dialog\n ref=\"dialogRef\"\n v-bind=\"cx(dialog())\"\n @cancel=\"handleCancel\"\n @click=\"handleClick\"\n @close=\"handleClose\"\n @keydown.esc=\"handleEscape\"\n @pointerdown=\"handlePointerDown\">\n <ScalarTeleportRoot v-if=\"persist || open\">\n <slot />\n </ScalarTeleportRoot>\n </dialog>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EAuCA,MAAM,OAAO;;EAWb,MAAM,OAAOA,SAAoB,SAAC,MAA0B;EAE5D,MAAM,SAAS,IAAI,EACjB,MAAM;GAEJ;GAEA;GAEA;GAEA;GAEA;EACF,EACF,CAAC;EAGD,MAAM,EAAE,OAAO,UAAU;EAEzB,MAAM,YAAY,IAA8B,IAAI;;;;;;;;EASpD,MAAM,aAAa,YAAqC;GACtD,IAAI,OAAO,QAAQ,cAAc,YAC/B,QAAQ,UAAU;QAElB,QAAQ,aAAa,QAAQ,EAAE;EAEnC;;EAGA,M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,CAAA,CAAA,GAAA,IAAA;G,KACY,QAAA,WAAW,KAAA,SAArCH,UAAA,GAAAK,YAEqBF,MAAAG,0BAAA,GAAA,EAAA,KAAA,EAAA,GAAA;IADnB,SAAAC,cAAQ,CAARC,WAAQ,KAAA,QAAA,SAAA,C"}
|
|
@@ -37,8 +37,6 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
|
37
37
|
onClose?: (() => any) | undefined;
|
|
38
38
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
39
39
|
default?: (props: {}) => any;
|
|
40
|
-
} & {
|
|
41
|
-
default?: (props: {}) => any;
|
|
42
40
|
}>;
|
|
43
41
|
type __VLS_WithSlots<T, S> = T & {
|
|
44
42
|
new (): {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarModal.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarModal/ScalarModal.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarModal.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarModal/ScalarModal.vue"],"names":[],"mappings":"AA6OA;;;;;;;;;;GAUG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAIzC,+CAA+C;AAC/C,wBAAgB,QAAQ;;;;EAUvB;AACD,QAAA,MAAM,YAAY;WAIT,UAAU,CAAC,OAAO,QAAQ,CAAC;YAC1B,MAAM;gBACF,MAAM;eACP,MAAM;;;;;;WAHV,UAAU,CAAC,OAAO,QAAQ,CAAC;YAC1B,MAAM;gBACF,MAAM;eACP,MAAM;;;;;;cAuNL,CAAC,KAAK,IAAiB,KAAK,GAAG;EAUzC,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -2,7 +2,7 @@ import ScalarModal_vue_vue_type_script_setup_true_lang_default, { useModal } fro
|
|
|
2
2
|
/* empty css */
|
|
3
3
|
import _plugin_vue_export_helper_default from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
4
|
// src/components/ScalarModal/ScalarModal.vue
|
|
5
|
-
var ScalarModal_default = /*#__PURE__*/ _plugin_vue_export_helper_default(ScalarModal_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-
|
|
5
|
+
var ScalarModal_default = /*#__PURE__*/ _plugin_vue_export_helper_default(ScalarModal_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-09866bb7"]]);
|
|
6
6
|
export { ScalarModal_default as default, useModal };
|
|
7
7
|
|
|
8
8
|
//# sourceMappingURL=ScalarModal.vue.js.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import ScalarDialog_default from "../ScalarDialog/ScalarDialog.vue.js";
|
|
1
2
|
import ScalarIconButton_default from "../ScalarIconButton/ScalarIconButton.vue.js";
|
|
2
3
|
import { cva, cx } from "@scalar/use-hooks/useBindCx";
|
|
3
|
-
import { createBlock, createCommentVNode, createElementBlock, createElementVNode,
|
|
4
|
+
import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, reactive, renderSlot, toDisplayString, unref, useId, withCtx } from "vue";
|
|
4
5
|
import { ScalarIconX } from "@scalar/icons";
|
|
5
|
-
import { Dialog, DialogPanel, DialogTitle } from "@headlessui/vue";
|
|
6
6
|
// src/components/ScalarModal/ScalarModal.vue?vue&type=script&setup=true&lang.ts
|
|
7
|
-
var _hoisted_1 =
|
|
7
|
+
var _hoisted_1 = ["id"];
|
|
8
|
+
var _hoisted_2 = {
|
|
8
9
|
key: 0,
|
|
9
10
|
class: "close-button fixed top-2 right-2 z-10"
|
|
10
11
|
};
|
|
@@ -46,8 +47,29 @@ var ScalarModal_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
46
47
|
emits: ["close"],
|
|
47
48
|
setup(__props, { emit: __emit }) {
|
|
48
49
|
const emit = __emit;
|
|
50
|
+
const titleId = useId();
|
|
51
|
+
/** Whether the modal is the full-height side panel rather than a centered panel */
|
|
52
|
+
const isFull = computed(() => __props.size === "full");
|
|
53
|
+
/** The full size dialog is an invisible full-viewport layer the side panel sits in */
|
|
54
|
+
const FULL_LAYOUT = "scalar-modal-layout-full m-0 h-dvh max-h-dvh w-dvw max-w-none overflow-visible rounded-none bg-transparent p-0 shadow-none backdrop:bg-transparent dark:backdrop:bg-transparent";
|
|
55
|
+
/**
|
|
56
|
+
* Sync user dismissals from the dialog back into the modal state.
|
|
57
|
+
*
|
|
58
|
+
* Only `false` updates come through here, since the dialog never opens itself. Programmatic
|
|
59
|
+
* closes via `state.hide()` do not emit `close`, which matches how the modal has always behaved.
|
|
60
|
+
*/
|
|
61
|
+
const handleOpenChange = (open) => {
|
|
62
|
+
if (!open) {
|
|
63
|
+
__props.state.hide();
|
|
64
|
+
emit("close");
|
|
65
|
+
}
|
|
66
|
+
};
|
|
49
67
|
const modal = cva({
|
|
50
|
-
base: [
|
|
68
|
+
base: [
|
|
69
|
+
"scalar-modal",
|
|
70
|
+
"flex flex-col mb-0 rounded-lg bg-b-1 p-0 text-left leading-snug text-c-1 opacity-0 w-[calc(100vw-12px)] md:w-[calc(100vw-16px)] lg:w-[calc(100vw-32px)]",
|
|
71
|
+
"overflow-visible"
|
|
72
|
+
].join(" "),
|
|
51
73
|
variants: {
|
|
52
74
|
size: {
|
|
53
75
|
xxs: "mt-[20svh] max-h-[60svh] max-w-[360px]",
|
|
@@ -85,45 +107,42 @@ var ScalarModal_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defi
|
|
|
85
107
|
}
|
|
86
108
|
});
|
|
87
109
|
return (_ctx, _cache) => {
|
|
88
|
-
return openBlock(), createBlock(unref(
|
|
110
|
+
return openBlock(), createBlock(unref(ScalarDialog_default), {
|
|
111
|
+
"aria-labelledby": __props.title ? unref(titleId) : void 0,
|
|
112
|
+
class: normalizeClass(isFull.value ? FULL_LAYOUT : unref(modal)({
|
|
113
|
+
size: __props.size,
|
|
114
|
+
variant: __props.variant
|
|
115
|
+
})),
|
|
89
116
|
open: __props.state.open,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
emit("close");
|
|
93
|
-
})
|
|
117
|
+
style: normalizeStyle(isFull.value ? void 0 : { maxWidth: __props.maxWidth }),
|
|
118
|
+
"onUpdate:open": handleOpenChange
|
|
94
119
|
}, {
|
|
95
|
-
default: withCtx(() => [createElementVNode("div", {
|
|
96
|
-
class: normalizeClass(unref(modal)({
|
|
120
|
+
default: withCtx(() => [createElementVNode("div", {
|
|
121
|
+
class: normalizeClass(isFull.value ? unref(modal)({
|
|
97
122
|
size: __props.size,
|
|
98
123
|
variant: __props.variant
|
|
99
|
-
})),
|
|
100
|
-
style: normalizeStyle({ maxWidth: __props.maxWidth })
|
|
101
|
-
}, {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
key: 1,
|
|
110
|
-
class: normalizeClass(__props.bodyClass)
|
|
111
|
-
}, [renderSlot(_ctx.$slots, "default", {}, void 0, true)], 2)) : (openBlock(), createElementBlock("div", {
|
|
112
|
-
key: 2,
|
|
113
|
-
class: normalizeClass(unref(cx)(unref(body)({
|
|
114
|
-
size: __props.size,
|
|
115
|
-
variant: __props.variant
|
|
116
|
-
}), __props.bodyClass))
|
|
117
|
-
}, [renderSlot(_ctx.$slots, "default", {}, void 0, true)], 2))]),
|
|
118
|
-
_: 3
|
|
119
|
-
}, 8, ["class", "style"]), __props.size === "full" ? (openBlock(), createElementBlock("div", _hoisted_1, [createVNode(unref(ScalarIconButton_default), {
|
|
124
|
+
}) : "contents"),
|
|
125
|
+
style: normalizeStyle(isFull.value ? { maxWidth: __props.maxWidth } : void 0)
|
|
126
|
+
}, [__props.title ? (openBlock(), createElementBlock("h2", {
|
|
127
|
+
key: 0,
|
|
128
|
+
id: unref(titleId),
|
|
129
|
+
class: "scalar-modal-header text-c-1 m-0 -mb-1 rounded-lg px-3 pt-3 text-left text-sm font-medium"
|
|
130
|
+
}, toDisplayString(__props.title), 9, _hoisted_1)) : createCommentVNode("", true), createElementVNode("div", { class: normalizeClass(isFull.value ? __props.bodyClass : unref(cx)(unref(body)({
|
|
131
|
+
size: __props.size,
|
|
132
|
+
variant: __props.variant
|
|
133
|
+
}), __props.bodyClass)) }, [renderSlot(_ctx.$slots, "default", {}, void 0, true)], 2)], 6), isFull.value ? (openBlock(), createElementBlock("div", _hoisted_2, [createVNode(unref(ScalarIconButton_default), {
|
|
120
134
|
class: "hover:bg-b-3 focus:outline-none",
|
|
121
135
|
icon: unref(ScalarIconX),
|
|
122
136
|
label: "Close modal",
|
|
123
137
|
onClick: _cache[0] || (_cache[0] = ($event) => __props.state.hide())
|
|
124
|
-
}, null, 8, ["icon"])])) : createCommentVNode("", true)]
|
|
138
|
+
}, null, 8, ["icon"])])) : createCommentVNode("", true)]),
|
|
125
139
|
_: 3
|
|
126
|
-
}, 8, [
|
|
140
|
+
}, 8, [
|
|
141
|
+
"aria-labelledby",
|
|
142
|
+
"class",
|
|
143
|
+
"open",
|
|
144
|
+
"style"
|
|
145
|
+
]);
|
|
127
146
|
};
|
|
128
147
|
}
|
|
129
148
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarModal.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","
|
|
1
|
+
{"version":3,"file":"ScalarModal.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_unref","ScalarDialog","_normalizeClass","_normalizeStyle","_withCtx","_createElementVNode","_createElementBlock","_toDisplayString","_renderSlot","_createVNode","ScalarIconButton"],"sources":["../../../src/components/ScalarModal/ScalarModal.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIconX } from '@scalar/icons'\nimport { cva, cx } from '@scalar/use-hooks/useBindCx'\nimport type { VariantProps } from 'cva'\nimport { computed, reactive, useId } from 'vue'\n\nimport { ScalarDialog } from '../ScalarDialog'\nimport { ScalarIconButton } from '../ScalarIconButton'\n\ntype ModalVariants = VariantProps<typeof modal>\n\nconst { size = 'md', state } = defineProps<{\n state: ReturnType<typeof useModal>\n title?: string\n bodyClass?: string\n maxWidth?: string\n size?: ModalVariants['size']\n variant?: ModalVariants['variant']\n}>()\n\nconst emit = defineEmits<{\n /** Emitted when the user dismisses the modal with Escape or a backdrop click. */\n (event: 'close'): void\n}>()\n\nconst titleId = useId()\n\n/** Whether the modal is the full-height side panel rather than a centered panel */\nconst isFull = computed(() => size === 'full')\n\n/** The full size dialog is an invisible full-viewport layer the side panel sits in */\nconst FULL_LAYOUT =\n 'scalar-modal-layout-full m-0 h-dvh max-h-dvh w-dvw max-w-none overflow-visible rounded-none bg-transparent p-0 shadow-none backdrop:bg-transparent dark:backdrop:bg-transparent'\n\n/**\n * Sync user dismissals from the dialog back into the modal state.\n *\n * Only `false` updates come through here, since the dialog never opens itself. Programmatic\n * closes via `state.hide()` do not emit `close`, which matches how the modal has always behaved.\n */\nconst handleOpenChange = (open: boolean): void => {\n if (!open) {\n state.hide()\n emit('close')\n }\n}\n\nconst modal = cva({\n base: [\n 'scalar-modal',\n 'flex flex-col mb-0 rounded-lg bg-b-1 p-0 text-left leading-snug text-c-1 opacity-0 w-[calc(100vw-12px)] md:w-[calc(100vw-16px)] lg:w-[calc(100vw-32px)]',\n // Let form popovers overflow the panel rather than scrolling the whole dialog\n 'overflow-visible',\n ].join(' '),\n variants: {\n size: {\n xxs: 'mt-[20svh] max-h-[60svh] max-w-[360px]',\n xs: 'mt-[20svh] max-h-[60svh] max-w-[480px]',\n sm: 'mt-[20svh] max-h-[60svh] max-w-[540px]',\n md: 'mt-[20svh] max-h-[60svh] max-w-[640px]',\n lg: 'm-auto max-h-[80svh] max-w-[800px]',\n xl: 'm-auto max-h-[90svh] max-w-[1000px]',\n full: 'full-size-styles max-h-dvh mt-0 lg:w-full',\n },\n variant: {\n form: 'scalar-modal-form',\n search: 'scalar-modal-search mt-[15svh] max-h-[60svh] max-w-[540px]',\n error: 'scalar-modal-error',\n },\n },\n})\nconst body = cva({\n base: ['scalar-modal-body', 'relative flex-1 min-h-0 p-3'].join(' '),\n variants: {\n variant: {\n form: 'overflow-visible',\n search: 'flex flex-col !m-0 overflow-hidden p-0',\n error: 'overflow-y-scroll',\n },\n size: {\n xxs: '',\n xs: '',\n sm: '',\n md: '',\n lg: '',\n xl: 'm-0 p-0',\n full: ' rounded-none',\n },\n },\n})\n</script>\n<script lang=\"ts\">\n/**\n * Scalar Modal component\n *\n * A dialog overlay with configurable size and variant.\n * Use the {@link useModal} hook to control the open state.\n *\n * @example\n * <ScalarModal :state=\"modal\" title=\"My Modal\">\n * Modal content\n * </ScalarModal>\n */\nexport default {}\n\n/** Hook for creating a reactive modal state */\nexport function useModal() {\n return reactive({\n open: false,\n show() {\n this.open = true\n },\n hide() {\n this.open = false\n },\n })\n}\n</script>\n<template>\n <ScalarDialog\n :aria-labelledby=\"title ? titleId : undefined\"\n :class=\"isFull ? FULL_LAYOUT : modal({ size, variant })\"\n :open=\"state.open\"\n :style=\"isFull ? undefined : { maxWidth }\"\n @update:open=\"handleOpenChange\">\n <!-- The full size is a side panel, so the dialog fills the viewport and the panel sits inside\n it. Every other size is the panel itself, and the wrapper steps out of the layout. -->\n <div\n :class=\"isFull ? modal({ size, variant }) : 'contents'\"\n :style=\"isFull ? { maxWidth } : undefined\">\n <h2\n v-if=\"title\"\n :id=\"titleId\"\n class=\"scalar-modal-header text-c-1 m-0 -mb-1 rounded-lg px-3 pt-3 text-left text-sm font-medium\">\n {{ title }}\n </h2>\n <div :class=\"isFull ? bodyClass : cx(body({ size, variant }), bodyClass)\">\n <slot />\n </div>\n </div>\n <div\n v-if=\"isFull\"\n class=\"close-button fixed top-2 right-2 z-10\">\n <ScalarIconButton\n class=\"hover:bg-b-3 focus:outline-none\"\n :icon=\"ScalarIconX\"\n label=\"Close modal\"\n @click=\"state.hide()\" />\n </div>\n </ScalarDialog>\n</template>\n<style scoped>\n@reference '../../style.css';\n\n.scalar-modal::backdrop {\n animation: fadein-layout ease-in-out 0.3s forwards;\n}\n.scalar-modal {\n animation: fadein-modal ease-in-out 0.3s forwards;\n animation-delay: 0.1s;\n box-shadow: var(--scalar-shadow-2);\n transform: translate3d(0, 10px, 0);\n}\n.modal-content-search .modal-body {\n padding: 0;\n overflow: hidden;\n display: flex;\n flex-direction: column;\n max-height: 440px;\n}\n/*\n * Allow the modal to fill more space on\n * very short (or very zoomed in) screens\n */\n@variant zoomed {\n .scalar-modal:not(.full-size-styles) {\n margin-top: 5svh;\n max-height: 90svh;\n }\n}\n@keyframes fadein-layout {\n 0% {\n opacity: 0;\n }\n 100% {\n opacity: 1;\n }\n}\n@keyframes fadein-modal {\n 0% {\n opacity: 0;\n transform: translate3d(0, 10px, 0);\n }\n 100% {\n opacity: 1;\n transform: translate3d(0, 0, 0);\n }\n}\n.full-size-styles {\n transform: translate3d(0, 0, 0);\n animation: fadein-layout ease-in-out 0.3s forwards;\n max-height: 100% !important;\n top: 0 !important;\n left: 0;\n position: absolute !important;\n margin: initial;\n border-radius: 0 !important;\n background-color: var(--scalar-background-1) !important;\n box-shadow: none !important;\n border-right: var(--scalar-border-width) solid var(--scalar-border-color);\n}\n@variant md {\n .full-size-styles {\n width: 50dvw !important;\n }\n}\n.full-size-styles:after {\n content: '';\n width: 50dvw;\n height: 100dvh;\n position: absolute;\n right: -50dvw;\n top: 0;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuGA,IAAA,cAAe,CAAC;;AAGhB,SAAgB,WAAW;CACzB,OAAO,SAAS;EACd,MAAM;EACN,OAAO;GACL,KAAK,OAAO;EACd;EACA,OAAO;GACL,KAAK,OAAO;EACd;CACF,CAAC;AACH;;;;;;;;;;;;;;EAhGA,MAAM,OAAO;EAKb,MAAM,UAAU,MAAM;;EAGtB,MAAM,SAAS,eAAe,Q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,IAEjC,QAAA,SADRL,UAAA,GAAAQ,mBAKK,MAAA;;KAHF,IAAIN,MAAA,OAAA;KACL,OAAM;IACH,GAAAO,gBAAA,QAAA,KAAK,GAAA,GAAA,UAAA,K,8BAEVF,mBAEM,OAAA,EAFA,OAAKH,eAAE,OAAA,QAAS,QAAA,YAAYF,MAAA,EAAA,CAAE,CAACA,MAAA,IAAA,CAAI,CAAA;KAAA,MAAG,QAAA;KAAI,SAAE,QAAA;IAAO,CAAA,GAAK,QAAA,SAAS,CAAA,E,IACrEQ,WAAQ,KAAA,QAAA,WAAA,CAAA,GAAA,KAAA,GAAA,IAAA,C,YAIJ,OAAA,SADRV,UAAA,GAAAQ,mBAQM,OARN,YAQM,CALJG,YAI0BT,MAAAU,wBAAA,GAAA;KAHxB,OAAM;KACL,MAAMV,MAAA,WAAA;KACP,OAAM;KACL,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,QAAA,MAAM,KAAI"}
|
|
@@ -3,7 +3,8 @@ import { type TeleportProps } from 'vue';
|
|
|
3
3
|
* Scalar teleport component
|
|
4
4
|
*
|
|
5
5
|
* Teleports the contents to the nearest <ScalarTeleportRoot>
|
|
6
|
-
* Falls back to the default teleport target (body) if no root is found
|
|
6
|
+
* Falls back to the default teleport target (body) if no root is found,
|
|
7
|
+
* or to the shadow root when it renders inside one
|
|
7
8
|
*
|
|
8
9
|
* Is a wrapper around the Vue <Teleport> component and takes the same props
|
|
9
10
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarTeleport.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarTeleport/ScalarTeleport.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarTeleport.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarTeleport/ScalarTeleport.vue"],"names":[],"mappings":"AAiLA,OAAO,EACL,KAAK,aAAa,EAWnB,MAAM,KAAK,CAAA;AAKZ;;;;;;;;;;;;;GAaG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;IAEhB;;OAEG;SACE,aAAa,CAAC,IAAI,CAAC;IACxB;;;;OAIG;gBACS,OAAO;IACnB;;OAEG;eACQ,aAAa,CAAC,UAAU,CAAC;;IAbpC;;OAEG;SACE,aAAa,CAAC,IAAI,CAAC;IACxB;;;;OAIG;gBACS,OAAO;IACnB;;OAEG;eACQ,aAAa,CAAC,UAAU,CAAC;;IAMpC,mCAAmC;eACxB,OAAO;EA8JhB,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
package/dist/components/ScalarTeleport/ScalarTeleport.vue_vue_type_script_setup_true_lang.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { useTeleport } from "./useTeleport.js";
|
|
2
|
-
import { Teleport, createBlock, createElementVNode, defineComponent, getCurrentInstance, inject, mergeProps, onMounted, openBlock, ref, renderSlot, ssrContextKey,
|
|
2
|
+
import { Teleport, computed, createBlock, createElementVNode, defineComponent, getCurrentInstance, inject, mergeProps, nextTick, onMounted, openBlock, ref, renderSlot, shallowRef, ssrContextKey, useTemplateRef, watch } from "vue";
|
|
3
|
+
import { getActiveElement } from "@scalar/helpers/dom/get-active-element";
|
|
4
|
+
import { isShadowRoot } from "@scalar/helpers/dom/is-shadow-root";
|
|
5
|
+
import { useDocumentRoot } from "@scalar/use-hooks/useDocumentRoot";
|
|
3
6
|
var ScalarTeleport_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
4
7
|
inheritAttrs: false,
|
|
5
8
|
__name: "ScalarTeleport",
|
|
@@ -10,6 +13,31 @@ var ScalarTeleport_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
|
|
|
10
13
|
},
|
|
11
14
|
setup(__props) {
|
|
12
15
|
const root = useTeleport();
|
|
16
|
+
const documentRoot = useDocumentRoot();
|
|
17
|
+
/**
|
|
18
|
+
* Inside a shadow root we look the target up ourselves and hand Vue the element
|
|
19
|
+
*
|
|
20
|
+
* Vue looks up selectors with `document.querySelector`, which cannot see into a shadow root,
|
|
21
|
+
* so we run the same query on the shadow root instead, and `body` becomes the shadow root
|
|
22
|
+
* itself. Whoever renders into a shadow root is expected to wrap it in a <ScalarTeleportRoot>
|
|
23
|
+
* inside an element that carries the theme classes. Normal pages keep handing Vue the selector.
|
|
24
|
+
*
|
|
25
|
+
* `null` means the target is not there yet.
|
|
26
|
+
*/
|
|
27
|
+
const findTarget = () => {
|
|
28
|
+
const selector = __props.to || root;
|
|
29
|
+
if (typeof selector !== "string" || !isShadowRoot(documentRoot)) return selector;
|
|
30
|
+
return selector === "body" ? documentRoot : documentRoot.querySelector(selector);
|
|
31
|
+
};
|
|
32
|
+
const target = shallowRef(findTarget());
|
|
33
|
+
watch(() => __props.to, () => target.value = findTarget(), { flush: "post" });
|
|
34
|
+
/**
|
|
35
|
+
* Content waiting for its target stays in place and moves once the target is there.
|
|
36
|
+
*
|
|
37
|
+
* Vue moves the content when `disabled` and `to` change in the same update, so it is not
|
|
38
|
+
* mounted again. A Teleport that is enabled without a target would not render it at all.
|
|
39
|
+
*/
|
|
40
|
+
const isWaitingForTarget = computed(() => target.value === null);
|
|
13
41
|
/**
|
|
14
42
|
* Server-rendered teleports stay in place until the component is mounted.
|
|
15
43
|
*
|
|
@@ -35,16 +63,31 @@ var ScalarTeleport_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
|
|
|
35
63
|
* nowhere to move the content to later, so it stays where it was rendered.
|
|
36
64
|
*/
|
|
37
65
|
const isTargetOnPage = (target) => typeof target === "string" ? document.querySelector(target) !== null : !!target;
|
|
38
|
-
const canTeleport = !isHydrating || isTargetOnPage(
|
|
66
|
+
const canTeleport = !isHydrating || isTargetOnPage(target.value);
|
|
67
|
+
const content = useTemplateRef("content");
|
|
68
|
+
/**
|
|
69
|
+
* A <ScalarTeleportRoot> renders its target after its slot, so we look again once mounted.
|
|
70
|
+
*
|
|
71
|
+
* Browsers drop focus from an element that moves, so content that focused itself while it
|
|
72
|
+
* waited in place gets its focus back once it has moved.
|
|
73
|
+
*/
|
|
74
|
+
const findTargetAgain = () => {
|
|
75
|
+
const focused = getActiveElement(documentRoot);
|
|
76
|
+
target.value = findTarget();
|
|
77
|
+
if (focused instanceof HTMLElement && content.value?.contains(focused)) nextTick(() => focused.focus());
|
|
78
|
+
};
|
|
39
79
|
onMounted(() => {
|
|
80
|
+
if (isWaitingForTarget.value) findTargetAgain();
|
|
40
81
|
if (canTeleport) renderInPlace.value = false;
|
|
41
82
|
});
|
|
42
83
|
return (_ctx, _cache) => {
|
|
43
84
|
return openBlock(), createBlock(Teleport, {
|
|
44
85
|
defer: !__props.immediate,
|
|
45
|
-
disabled: __props.disabled || renderInPlace.value,
|
|
46
|
-
to:
|
|
86
|
+
disabled: __props.disabled || renderInPlace.value || isWaitingForTarget.value,
|
|
87
|
+
to: target.value
|
|
47
88
|
}, [createElementVNode("div", mergeProps({
|
|
89
|
+
ref_key: "content",
|
|
90
|
+
ref: content,
|
|
48
91
|
class: "scalar-app",
|
|
49
92
|
style: { "display": "contents" }
|
|
50
93
|
}, _ctx.$attrs), [renderSlot(_ctx.$slots, "default")], 16)], 8, [
|
package/dist/components/ScalarTeleport/ScalarTeleport.vue_vue_type_script_setup_true_lang.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarTeleport.vue_vue_type_script_setup_true_lang.js","names":["$attrs","_openBlock","_createBlock","_Teleport","
|
|
1
|
+
{"version":3,"file":"ScalarTeleport.vue_vue_type_script_setup_true_lang.js","names":["$attrs","_openBlock","_createBlock","_Teleport","_createElementVNode","_mergeProps","_renderSlot"],"sources":["../../../src/components/ScalarTeleport/ScalarTeleport.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar teleport component\n *\n * Teleports the contents to the nearest <ScalarTeleportRoot>\n * Falls back to the default teleport target (body) if no root is found,\n * or to the shadow root when it renders inside one\n *\n * Is a wrapper around the Vue <Teleport> component and takes the same props\n *\n * @example\n * <ScalarTeleport>\n * <div>Teleported Content</div>\n * </ScalarTeleport>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { getActiveElement } from '@scalar/helpers/dom/get-active-element'\nimport { isShadowRoot } from '@scalar/helpers/dom/is-shadow-root'\nimport { useDocumentRoot } from '@scalar/use-hooks/useDocumentRoot'\nimport {\n type TeleportProps,\n computed,\n getCurrentInstance,\n inject,\n nextTick,\n onMounted,\n ref,\n shallowRef,\n ssrContextKey,\n useTemplateRef,\n watch,\n} from 'vue'\n\nimport { useTeleport } from './useTeleport'\n\nconst { to } = defineProps<{\n /**\n * Override the default teleport target\n */\n to?: TeleportProps['to']\n /**\n * Whether to teleport immediately, disables the default defer behavior\n *\n * @see https://vuejs.org/guide/built-ins/teleport#deferred-teleport\n */\n immediate?: boolean\n /**\n * Whether to disable teleportation\n */\n disabled?: TeleportProps['disabled']\n}>()\n\ndefineSlots<{\n /** The element to be teleported */\n default(): unknown\n}>()\n\ndefineOptions({ inheritAttrs: false })\n\nconst root = useTeleport()\nconst documentRoot = useDocumentRoot()\n\n/**\n * Inside a shadow root we look the target up ourselves and hand Vue the element\n *\n * Vue looks up selectors with `document.querySelector`, which cannot see into a shadow root,\n * so we run the same query on the shadow root instead, and `body` becomes the shadow root\n * itself. Whoever renders into a shadow root is expected to wrap it in a <ScalarTeleportRoot>\n * inside an element that carries the theme classes. Normal pages keep handing Vue the selector.\n *\n * `null` means the target is not there yet.\n */\nconst findTarget = (): TeleportProps['to'] | null => {\n const selector = to || root\n if (typeof selector !== 'string' || !isShadowRoot(documentRoot)) {\n return selector\n }\n return selector === 'body'\n ? documentRoot\n : documentRoot.querySelector(selector)\n}\n\nconst target = shallowRef<TeleportProps['to'] | null>(findTarget())\n// After the DOM update, so a new target rendered in the same update is there to find\nwatch(\n () => to,\n () => (target.value = findTarget()),\n { flush: 'post' },\n)\n\n/**\n * Content waiting for its target stays in place and moves once the target is there.\n *\n * Vue moves the content when `disabled` and `to` change in the same update, so it is not\n * mounted again. A Teleport that is enabled without a target would not render it at all.\n */\nconst isWaitingForTarget = computed(() => target.value === null)\n\n/**\n * Server-rendered teleports stay in place until the component is mounted.\n *\n * Vue's server renderer does not put teleported content into the page. It\n * hands the content back separately and expects the host to place it in the\n * target. A host that embeds the server-rendered markup never receives it, so\n * during hydration Vue looks for the content in the target and hydrates over\n * whatever the host page has there.\n *\n * Rendering in place asks nothing of the host. The content is part of the\n * markup where the component is used, it is hydrated there, and it moves to\n * the target once the component is mounted. A component that is mounted\n * without server-rendered markup still teleports right away.\n *\n * @see https://vuejs.org/guide/scaling-up/ssr.html#teleports\n */\nconst isServerRendering = inject<unknown>(ssrContextKey, null) !== null\nconst isHydrating = getCurrentInstance()?.vnode.el != null\nconst renderInPlace = ref<boolean>(isServerRendering || isHydrating)\n\n/**\n * Vue looks up the target once, while it hydrates the teleport, and keeps\n * what it found. If the target is not on the page at that moment there is\n * nowhere to move the content to later, so it stays where it was rendered.\n */\nconst isTargetOnPage = (target: TeleportProps['to'] | null): boolean =>\n typeof target === 'string'\n ? document.querySelector(target) !== null\n : !!target\nconst canTeleport = !isHydrating || isTargetOnPage(target.value)\n\nconst content = useTemplateRef<HTMLElement>('content')\n\n/**\n * A <ScalarTeleportRoot> renders its target after its slot, so we look again once mounted.\n *\n * Browsers drop focus from an element that moves, so content that focused itself while it\n * waited in place gets its focus back once it has moved.\n */\nconst findTargetAgain = (): void => {\n const focused = getActiveElement(documentRoot)\n target.value = findTarget()\n\n if (focused instanceof HTMLElement && content.value?.contains(focused)) {\n void nextTick(() => focused.focus())\n }\n}\n\nonMounted(() => {\n if (isWaitingForTarget.value) {\n findTargetAgain()\n }\n if (canTeleport) {\n renderInPlace.value = false\n }\n})\n</script>\n<template>\n <Teleport\n :defer=\"!immediate\"\n :disabled=\"disabled || renderInPlace || isWaitingForTarget\"\n :to=\"target\">\n <div\n ref=\"content\"\n class=\"scalar-app\"\n style=\"display: contents\"\n v-bind=\"$attrs\">\n <slot />\n </div>\n </Teleport>\n</template>\n"],"mappings":";;;;;;;;;;;;;;EA6DA,MAAM,OAAO,YAAY;EACzB,MAAM,eAAe,gBAAgB;;;;;;;;;;;EAYrC,MAAM,mBAA+C;GACnD,MAAM,WAAW,QAAA,MAAM;GACvB,IAAI,OAAO,aAAa,YAAY,CAAC,aAAa,YAAY,GAC5D,OAAO;GAET,OAAO,aAAa,SAChB,eACA,aAAa,cAAc,QAAQ;EACzC;EAEA,MAAM,SAAS,WAAuC,WAAW,CAAC;EAElE,YACQ,QAAA,UACC,OAAO,QAAQ,WAAW,GACjC,EAAE,OAAO,OAAO,CAClB;;;;;;;EAQA,MAAM,qBAAqB,eAAe,OAAO,UAAU,IAAI;;;;;;;;;;;;;;;;;EAkB/D,MAAM,oBAAoB,OAAgB,eAAe,IAAI,MAAM;EACnE,MAAM,cAAc,mBAAmB,CAAC,EAAE,MAAM,MAAM;EACtD,MAAM,gBAAgB,IAAa,qBAAqB,WAAW;;;;;;EAOnE,MAAM,kBAAkB,WACtB,OAAO,WAAW,WACd,SAAS,cAAc,MAAM,MAAM,OACnC,CAAC,CAAC;EACR,MAAM,cAAc,CAAC,eAAe,eAAe,OAAO,KAAK;EAE/D,MAAM,UAAU,eAA4B,SAAS;;;;;;;EAQrD,MAAM,wBAA8B;GAClC,MAAM,UAAU,iBAAiB,YAAY;GAC7C,OAAO,QAAQ,WAAW;GAE1B,IAAI,mBAAmB,eAAe,QAAQ,OAAO,SAAS,OAAO,GACnE,eAAoB,QAAQ,MAAM,CAAC;EAEvC;EAEA,gBAAgB;GACd,IAAI,mBAAmB,OACrB,gBAAgB;GAElB,IAAI,aACF,cAAc,QAAQ;EAE1B,CAAC;;GAGC,OAAAC,UAAA,GAAAC,YAWWC,UAAA;IAVR,OAAK,CAAG,QAAA;IACR,UAAU,QAAA,YAAY,cAAA,SAAiB,mBAAA;IACvC,IAAI,OAAA;G,IACLC,mBAMM,OANNC,WAMM;IALA,SAAA;IAAJ,KAAI;IACJ,OAAM;IACN,OAAA,EAAA,WAAA,WAAA;GACQL,GAAAA,KAAAA,MAAM,GAAA,CACdM,WAAQ,KAAA,QAAA,SAAA,C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTooltip.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarTooltip/useTooltip.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAS,oBAAoB,EAAE,MAAM,SAAS,CAAA;AA4J1D;;GAEG;AACH,wBAAgB,qBAAqB,SAGpC;
|
|
1
|
+
{"version":3,"file":"useTooltip.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarTooltip/useTooltip.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAS,oBAAoB,EAAE,MAAM,SAAS,CAAA;AA4J1D;;GAEG;AACH,wBAAgB,qBAAqB,SAGpC;AA0ID;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,oBAAoB,QA8EpD"}
|
|
@@ -88,12 +88,17 @@ function hideTooltip(_e) {
|
|
|
88
88
|
/**
|
|
89
89
|
* Handle the escape key
|
|
90
90
|
*
|
|
91
|
-
* If the escape key is pressed we need to hide
|
|
91
|
+
* If the escape key is pressed while the tooltip is showing we need to hide it, and only it.
|
|
92
|
+
* Preventing the default stops the browser from also turning the key into a `cancel` request
|
|
93
|
+
* for a surrounding modal `<dialog>`, which stopping propagation alone does not do. The listener
|
|
94
|
+
* outlives a tooltip hidden by blur or mouseleave, so an Escape with no tooltip showing is left
|
|
95
|
+
* alone for whatever else wants it.
|
|
92
96
|
*
|
|
93
97
|
* @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tooltip_role#keyboard_interactions
|
|
94
98
|
*/
|
|
95
99
|
function handleEscape(e) {
|
|
96
|
-
if (e.key === "Escape") {
|
|
100
|
+
if (e.key === "Escape" && config.value) {
|
|
101
|
+
e.preventDefault();
|
|
97
102
|
e.stopPropagation();
|
|
98
103
|
hideTooltip(e);
|
|
99
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTooltip.js","names":[],"sources":["../../../src/components/ScalarTooltip/useTooltip.ts"],"sourcesContent":["import { autoUpdate, flip, shift, useFloating } from '@floating-ui/vue'\nimport { computed, onScopeDispose, ref, unref, watch } from 'vue'\n\nimport { DEFAULT_DELAY, DEFAULT_OFFSET, ELEMENT_CLASS, ELEMENT_ID } from './constants'\nimport type { Timer, TooltipConfiguration } from './types'\n\n// ---------------------------------------------------------------------------\n// State\n// ---------------------------------------------------------------------------\n\n/**\n * The delay timer for the tooltip\n *\n * If there's not a timer running it should be undefined\n */\nconst timer = ref<Timer>()\n\n/**\n * A reference to the tooltip element\n *\n * If the hook hasn't been initialized it should be undefined\n */\nconst el = ref<HTMLElement>()\n\n/**\n * The configuration for the active tooltip\n *\n * If no tooltip is active it should be undefined\n */\nconst config = ref<TooltipConfiguration>()\n\n// ---------------------------------------------------------------------------\n// Core watcher and floating UI setup\n// ---------------------------------------------------------------------------\n\n// Set up floating UI\nconst { floatingStyles, placement, update } = useFloating(\n computed(() => unref(config.value?.targetRef)),\n el,\n {\n placement: computed(() => unref(config.value?.placement)),\n whileElementsMounted: autoUpdate,\n middleware: computed(() => [flip(), shift()]),\n },\n)\n\n// Expose the resolved placement side (post-flip) so the CSS can apply the offset\n// gap only on the side facing the target. We key off the side (the part before\n// the '-') because that is where the tooltip sits relative to the target. The\n// initial side is set synchronously when the tooltip is shown (see the config\n// watcher below); this watcher keeps it in sync once Floating UI flips it.\nwatch(placement, (value) => {\n if (!el.value || !value) {\n return\n }\n el.value.dataset.side = value.split('-')[0]\n})\n\n// Update the tooltip element's positioning when Floating UI updates the styles\nwatch(floatingStyles, () => {\n if (!el.value) {\n return\n }\n\n el.value.style.position = floatingStyles.value.position\n el.value.style.top = floatingStyles.value.top\n el.value.style.left = floatingStyles.value.left\n el.value.style.transform = floatingStyles.value.transform ?? ''\n el.value.style.willChange = floatingStyles.value.willChange ?? ''\n})\n\n// Show or hide the tooltip when the config changes\nwatch(\n config,\n (opts) => {\n if (!el.value) {\n return\n }\n\n if (opts) {\n // Keep the element in the right host if the target moved into or out of a modal\n // dialog while the tooltip was already showing. Opening a tooltip is handled in\n // `showTooltip` before the config is assigned, so this only fires when `targetRef`\n // changes underneath an open tooltip, and it has to ask Floating UI for a fresh\n // position because a reparent is neither a scroll nor a resize.\n if (moveTooltipToHost(unref(opts.targetRef))) {\n update()\n }\n\n const contentTarget = unref(opts?.contentTarget) ?? 'textContent'\n\n // Update the tooltip content\n el.value[contentTarget] = unref(opts?.content) ?? ''\n\n // Show the tooltip\n const offset = unref(opts?.offset) ?? DEFAULT_OFFSET\n el.value.style.setProperty('--scalar-tooltip-offset', `${offset}px`)\n\n // Set the side the tooltip sits on so the offset gap is only applied to\n // the target-facing side. Floating UI defaults to 'bottom' when no\n // placement is provided; the placement watcher above refines this after\n // any flip.\n el.value.dataset.side = (unref(opts?.placement) ?? 'bottom').split('-')[0]\n\n el.value.style.setProperty('display', 'block')\n } else {\n // Clear the tooltip content\n el.value.innerHTML = ''\n\n // Hide the tooltip\n el.value.style.removeProperty('--scalar-tooltip-offset')\n el.value.style.setProperty('display', 'none')\n\n // Park the element back on the body. Left inside a dialog it would be removed from\n // the document when that dialog unmounts, taking the shared tooltip with it.\n moveTooltipToHost(undefined)\n }\n },\n { deep: true },\n)\n\n// ---------------------------------------------------------------------------\n// Lifecycle Functions\n// ---------------------------------------------------------------------------\n\n/**\n * Initialize the tooltip element\n *\n * If the tooltip is already initialized it will be ignored\n */\nfunction initializeTooltipElement(): void {\n if (typeof document === 'undefined' || typeof window === 'undefined') {\n // Skip tooltip initialization during SSR\n return\n }\n\n if (el.value) {\n // Tooltip already initialized\n return\n }\n\n // See if the tooltip element already exists\n // (Sometimes this happens with HMR)\n const existingTooltipElement = document.getElementById(ELEMENT_ID)\n\n if (existingTooltipElement) {\n el.value = existingTooltipElement\n } else {\n // Create the tooltip element\n el.value = document.createElement('div')\n el.value.role = 'tooltip'\n el.value.id = ELEMENT_ID\n el.value.classList.add(ELEMENT_CLASS)\n el.value.classList.add('scalar-app')\n el.value.style.setProperty('display', 'none')\n el.value.addEventListener('mouseleave', hideTooltip)\n document.body.appendChild(el.value)\n }\n}\n\n/**\n * Cleanup and reset the tooltip element\n */\nexport function cleanupTooltipElement() {\n document.getElementById(ELEMENT_ID)?.remove()\n el.value = undefined\n}\n\n// ---------------------------------------------------------------------------\n// Helper Functions\n// ---------------------------------------------------------------------------\n\n/**\n * Hide the tooltip\n *\n * If the mouse is moving between the tooltip and the target we don't hide the tooltip\n */\nfunction hideTooltip(_e: Event) {\n if (!isMovingOffElements(_e)) {\n // Don't hide the tooltip if the mouse is moving between the tooltip and the target\n return\n }\n\n // Clear any existing timer\n clearTimer()\n\n // Hide the tooltip\n config.value = undefined\n}\n\n/**\n * Handle the escape key\n *\n * If the escape key is pressed we need to hide the tooltip\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tooltip_role#keyboard_interactions\n */\nfunction handleEscape(e: KeyboardEvent) {\n if (e.key === 'Escape') {\n e.stopPropagation()\n hideTooltip(e)\n }\n}\n\n/**\n * Find the modal dialog containing an element, if there is one\n *\n * Only a dialog opened with `showModal()` is promoted to the browser's top layer, and\n * `:modal` matches exactly those. The `open` property is not a substitute: it is also\n * true for `dialog.show()`, which leaves the dialog in the normal flow where the\n * tooltip already paints correctly.\n */\nfunction getModalDialog(target: Element | undefined | null): HTMLDialogElement | undefined {\n const dialog = target?.closest('dialog')\n\n if (!dialog) {\n return undefined\n }\n\n try {\n return dialog.matches(':modal') ? dialog : undefined\n } catch {\n // `:modal` reached Safari a couple of releases after `showModal()` did, and an\n // unknown pseudo-class throws. Treating it as \"not modal\" degrades to the old\n // behaviour for that one case instead of breaking every tooltip on the page.\n return undefined\n }\n}\n\n/**\n * Move the tooltip element into the host it needs to paint above\n *\n * Top layer content paints above the rest of the document whatever `z-index` anything\n * else carries, so the only way to sit above a modal dialog is to live inside it.\n * Everywhere else the tooltip belongs on the body.\n *\n * This doubles as a repair step: appending an element that is no longer in the document\n * puts it back, which covers a dialog being unmounted while the tooltip sat inside it.\n *\n * Returns whether the element actually moved.\n */\nfunction moveTooltipToHost(target: Element | undefined | null): boolean {\n if (!el.value) {\n return false\n }\n\n const host = getModalDialog(target) ?? document.body\n\n if (el.value.parentElement === host) {\n return false\n }\n\n host.appendChild(el.value)\n\n return true\n}\n\n/** Clears the current timer */\nfunction clearTimer() {\n if (timer.value) {\n clearTimeout(timer.value)\n timer.value = undefined\n }\n}\n\n/** Get all the parents of an element */\nfunction getAllParents(el: Element): Element[] {\n const parents: Element[] = []\n let parent = el.parentElement\n while (parent) {\n parents.push(parent)\n parent = parent.parentElement\n }\n return parents\n}\n\n/**\n * Check if the mouse moved off the target and the tooltip altogether\n *\n * Moving between the two keeps the tooltip open. Landing on a child of the target (an icon\n * inside a button, say) counts as landing on the target: the pointer never left it.\n */\nfunction isMovingOffElements(e: Event): boolean {\n const target = unref(config.value?.targetRef)\n if (e instanceof MouseEvent && e.relatedTarget instanceof Element && target) {\n const relatedTargetParents = getAllParents(e.relatedTarget)\n return (\n e.relatedTarget.id !== ELEMENT_ID &&\n !relatedTargetParents.some((parent) => parent.id === ELEMENT_ID) &&\n !target.contains(e.relatedTarget)\n )\n }\n return true\n}\n\n// ---------------------------------------------------------------------------\n// Tooltip Hook\n// ---------------------------------------------------------------------------\n\n/**\n * Create a tooltip\n *\n * If there isn't a tooltip element it will be created\n */\nexport function useTooltip(opts: TooltipConfiguration) {\n initializeTooltipElement()\n\n /**\n * Show the tooltip after the delay if configured\n */\n function showTooltipAfterDelay(_e: Event) {\n const delay = unref(opts.delay) ?? DEFAULT_DELAY\n clearTimer()\n\n // Show the tooltip after the delay\n if (delay > 0) {\n timer.value = setTimeout(() => showTooltip(_e), delay)\n } else {\n showTooltip(_e)\n }\n }\n\n /**\n * Show the tooltip\n */\n function showTooltip(_e: Event) {\n clearTimer()\n\n // Handle the escape key\n document.addEventListener('keydown', handleEscape, { once: true, capture: true })\n\n // Move the element before the config is assigned, not after. Floating UI watches the\n // target with `flush: 'sync'`, so it measures the position the instant the config\n // lands, and that measurement has to happen with the tooltip already in its final\n // parent or the first frame is positioned against the wrong offset parent.\n moveTooltipToHost(unref(opts.targetRef))\n\n // Show the tooltip\n config.value = opts\n }\n\n watch(\n () => unref(opts.targetRef),\n (newRef, oldRef) => {\n if (oldRef) {\n oldRef.removeEventListener('mouseenter', showTooltipAfterDelay)\n oldRef.removeEventListener('mouseleave', hideTooltip)\n oldRef.removeEventListener('focus', showTooltip)\n oldRef.removeEventListener('blur', hideTooltip)\n\n oldRef.removeAttribute('aria-describedby')\n }\n if (newRef) {\n newRef.addEventListener('mouseenter', showTooltipAfterDelay)\n newRef.addEventListener('mouseleave', hideTooltip)\n newRef.addEventListener('focus', showTooltip)\n newRef.addEventListener('blur', hideTooltip)\n\n newRef.setAttribute('aria-describedby', ELEMENT_ID)\n }\n },\n { immediate: true },\n )\n\n // Cleanup the tooltip when the component is unmounted\n onScopeDispose(() => {\n clearTimer()\n\n const target = unref(opts.targetRef)\n if (target) {\n target.removeEventListener('mouseenter', showTooltipAfterDelay)\n target.removeEventListener('mouseleave', hideTooltip)\n target.removeEventListener('focus', showTooltip)\n target.removeEventListener('blur', hideTooltip)\n target.removeAttribute('aria-describedby')\n }\n\n // If the tooltip is showing on this target hide it\n if (unref(config.value?.targetRef) === unref(opts.targetRef)) {\n config.value = undefined\n }\n })\n}\n"],"mappings":";;;;;;;;;AAeA,IAAM,QAAQ,IAAW;;;;;;AAOzB,IAAM,KAAK,IAAiB;;;;;;AAO5B,IAAM,SAAS,IAA0B;AAOzC,IAAM,EAAE,gBAAgB,WAAW,WAAW,YAC5C,eAAe,MAAM,OAAO,OAAO,SAAS,CAAC,GAC7C,IACA;CACE,WAAW,eAA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CACF,GACA,EAAE,WAAW,KAAK,CACpB;CAGA,qBAAqB;EACnB,WAAW;EAEX,MAAM,SAAS,MAAM,KAAK,SAAS;EACnC,IAAI,QAAQ;GACV,OAAO,oBAAoB,cAAc,qBAAqB;GAC9D,OAAO,oBAAoB,cAAc,WAAW;GACpD,OAAO,oBAAoB,SAAS,WAAW;GAC/C,OAAO,oBAAoB,QAAQ,WAAW;GAC9C,OAAO,gBAAgB,kBAAkB;EAC3C;EAGA,IAAI,MAAM,OAAO,OAAO,SAAS,MAAM,MAAM,KAAK,SAAS,GACzD,OAAO,QAAQ,KAAA;CAEnB,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"useTooltip.js","names":[],"sources":["../../../src/components/ScalarTooltip/useTooltip.ts"],"sourcesContent":["import { autoUpdate, flip, shift, useFloating } from '@floating-ui/vue'\nimport { computed, onScopeDispose, ref, unref, watch } from 'vue'\n\nimport { DEFAULT_DELAY, DEFAULT_OFFSET, ELEMENT_CLASS, ELEMENT_ID } from './constants'\nimport type { Timer, TooltipConfiguration } from './types'\n\n// ---------------------------------------------------------------------------\n// State\n// ---------------------------------------------------------------------------\n\n/**\n * The delay timer for the tooltip\n *\n * If there's not a timer running it should be undefined\n */\nconst timer = ref<Timer>()\n\n/**\n * A reference to the tooltip element\n *\n * If the hook hasn't been initialized it should be undefined\n */\nconst el = ref<HTMLElement>()\n\n/**\n * The configuration for the active tooltip\n *\n * If no tooltip is active it should be undefined\n */\nconst config = ref<TooltipConfiguration>()\n\n// ---------------------------------------------------------------------------\n// Core watcher and floating UI setup\n// ---------------------------------------------------------------------------\n\n// Set up floating UI\nconst { floatingStyles, placement, update } = useFloating(\n computed(() => unref(config.value?.targetRef)),\n el,\n {\n placement: computed(() => unref(config.value?.placement)),\n whileElementsMounted: autoUpdate,\n middleware: computed(() => [flip(), shift()]),\n },\n)\n\n// Expose the resolved placement side (post-flip) so the CSS can apply the offset\n// gap only on the side facing the target. We key off the side (the part before\n// the '-') because that is where the tooltip sits relative to the target. The\n// initial side is set synchronously when the tooltip is shown (see the config\n// watcher below); this watcher keeps it in sync once Floating UI flips it.\nwatch(placement, (value) => {\n if (!el.value || !value) {\n return\n }\n el.value.dataset.side = value.split('-')[0]\n})\n\n// Update the tooltip element's positioning when Floating UI updates the styles\nwatch(floatingStyles, () => {\n if (!el.value) {\n return\n }\n\n el.value.style.position = floatingStyles.value.position\n el.value.style.top = floatingStyles.value.top\n el.value.style.left = floatingStyles.value.left\n el.value.style.transform = floatingStyles.value.transform ?? ''\n el.value.style.willChange = floatingStyles.value.willChange ?? ''\n})\n\n// Show or hide the tooltip when the config changes\nwatch(\n config,\n (opts) => {\n if (!el.value) {\n return\n }\n\n if (opts) {\n // Keep the element in the right host if the target moved into or out of a modal\n // dialog while the tooltip was already showing. Opening a tooltip is handled in\n // `showTooltip` before the config is assigned, so this only fires when `targetRef`\n // changes underneath an open tooltip, and it has to ask Floating UI for a fresh\n // position because a reparent is neither a scroll nor a resize.\n if (moveTooltipToHost(unref(opts.targetRef))) {\n update()\n }\n\n const contentTarget = unref(opts?.contentTarget) ?? 'textContent'\n\n // Update the tooltip content\n el.value[contentTarget] = unref(opts?.content) ?? ''\n\n // Show the tooltip\n const offset = unref(opts?.offset) ?? DEFAULT_OFFSET\n el.value.style.setProperty('--scalar-tooltip-offset', `${offset}px`)\n\n // Set the side the tooltip sits on so the offset gap is only applied to\n // the target-facing side. Floating UI defaults to 'bottom' when no\n // placement is provided; the placement watcher above refines this after\n // any flip.\n el.value.dataset.side = (unref(opts?.placement) ?? 'bottom').split('-')[0]\n\n el.value.style.setProperty('display', 'block')\n } else {\n // Clear the tooltip content\n el.value.innerHTML = ''\n\n // Hide the tooltip\n el.value.style.removeProperty('--scalar-tooltip-offset')\n el.value.style.setProperty('display', 'none')\n\n // Park the element back on the body. Left inside a dialog it would be removed from\n // the document when that dialog unmounts, taking the shared tooltip with it.\n moveTooltipToHost(undefined)\n }\n },\n { deep: true },\n)\n\n// ---------------------------------------------------------------------------\n// Lifecycle Functions\n// ---------------------------------------------------------------------------\n\n/**\n * Initialize the tooltip element\n *\n * If the tooltip is already initialized it will be ignored\n */\nfunction initializeTooltipElement(): void {\n if (typeof document === 'undefined' || typeof window === 'undefined') {\n // Skip tooltip initialization during SSR\n return\n }\n\n if (el.value) {\n // Tooltip already initialized\n return\n }\n\n // See if the tooltip element already exists\n // (Sometimes this happens with HMR)\n const existingTooltipElement = document.getElementById(ELEMENT_ID)\n\n if (existingTooltipElement) {\n el.value = existingTooltipElement\n } else {\n // Create the tooltip element\n el.value = document.createElement('div')\n el.value.role = 'tooltip'\n el.value.id = ELEMENT_ID\n el.value.classList.add(ELEMENT_CLASS)\n el.value.classList.add('scalar-app')\n el.value.style.setProperty('display', 'none')\n el.value.addEventListener('mouseleave', hideTooltip)\n document.body.appendChild(el.value)\n }\n}\n\n/**\n * Cleanup and reset the tooltip element\n */\nexport function cleanupTooltipElement() {\n document.getElementById(ELEMENT_ID)?.remove()\n el.value = undefined\n}\n\n// ---------------------------------------------------------------------------\n// Helper Functions\n// ---------------------------------------------------------------------------\n\n/**\n * Hide the tooltip\n *\n * If the mouse is moving between the tooltip and the target we don't hide the tooltip\n */\nfunction hideTooltip(_e: Event) {\n if (!isMovingOffElements(_e)) {\n // Don't hide the tooltip if the mouse is moving between the tooltip and the target\n return\n }\n\n // Clear any existing timer\n clearTimer()\n\n // Hide the tooltip\n config.value = undefined\n}\n\n/**\n * Handle the escape key\n *\n * If the escape key is pressed while the tooltip is showing we need to hide it, and only it.\n * Preventing the default stops the browser from also turning the key into a `cancel` request\n * for a surrounding modal `<dialog>`, which stopping propagation alone does not do. The listener\n * outlives a tooltip hidden by blur or mouseleave, so an Escape with no tooltip showing is left\n * alone for whatever else wants it.\n *\n * @see https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Reference/Roles/tooltip_role#keyboard_interactions\n */\nfunction handleEscape(e: KeyboardEvent) {\n if (e.key === 'Escape' && config.value) {\n e.preventDefault()\n e.stopPropagation()\n hideTooltip(e)\n }\n}\n\n/**\n * Find the modal dialog containing an element, if there is one\n *\n * Only a dialog opened with `showModal()` is promoted to the browser's top layer, and\n * `:modal` matches exactly those. The `open` property is not a substitute: it is also\n * true for `dialog.show()`, which leaves the dialog in the normal flow where the\n * tooltip already paints correctly.\n */\nfunction getModalDialog(target: Element | undefined | null): HTMLDialogElement | undefined {\n const dialog = target?.closest('dialog')\n\n if (!dialog) {\n return undefined\n }\n\n try {\n return dialog.matches(':modal') ? dialog : undefined\n } catch {\n // `:modal` reached Safari a couple of releases after `showModal()` did, and an\n // unknown pseudo-class throws. Treating it as \"not modal\" degrades to the old\n // behaviour for that one case instead of breaking every tooltip on the page.\n return undefined\n }\n}\n\n/**\n * Move the tooltip element into the host it needs to paint above\n *\n * Top layer content paints above the rest of the document whatever `z-index` anything\n * else carries, so the only way to sit above a modal dialog is to live inside it.\n * Everywhere else the tooltip belongs on the body.\n *\n * This doubles as a repair step: appending an element that is no longer in the document\n * puts it back, which covers a dialog being unmounted while the tooltip sat inside it.\n *\n * Returns whether the element actually moved.\n */\nfunction moveTooltipToHost(target: Element | undefined | null): boolean {\n if (!el.value) {\n return false\n }\n\n const host = getModalDialog(target) ?? document.body\n\n if (el.value.parentElement === host) {\n return false\n }\n\n host.appendChild(el.value)\n\n return true\n}\n\n/** Clears the current timer */\nfunction clearTimer() {\n if (timer.value) {\n clearTimeout(timer.value)\n timer.value = undefined\n }\n}\n\n/** Get all the parents of an element */\nfunction getAllParents(el: Element): Element[] {\n const parents: Element[] = []\n let parent = el.parentElement\n while (parent) {\n parents.push(parent)\n parent = parent.parentElement\n }\n return parents\n}\n\n/**\n * Check if the mouse moved off the target and the tooltip altogether\n *\n * Moving between the two keeps the tooltip open. Landing on a child of the target (an icon\n * inside a button, say) counts as landing on the target: the pointer never left it.\n */\nfunction isMovingOffElements(e: Event): boolean {\n const target = unref(config.value?.targetRef)\n if (e instanceof MouseEvent && e.relatedTarget instanceof Element && target) {\n const relatedTargetParents = getAllParents(e.relatedTarget)\n return (\n e.relatedTarget.id !== ELEMENT_ID &&\n !relatedTargetParents.some((parent) => parent.id === ELEMENT_ID) &&\n !target.contains(e.relatedTarget)\n )\n }\n return true\n}\n\n// ---------------------------------------------------------------------------\n// Tooltip Hook\n// ---------------------------------------------------------------------------\n\n/**\n * Create a tooltip\n *\n * If there isn't a tooltip element it will be created\n */\nexport function useTooltip(opts: TooltipConfiguration) {\n initializeTooltipElement()\n\n /**\n * Show the tooltip after the delay if configured\n */\n function showTooltipAfterDelay(_e: Event) {\n const delay = unref(opts.delay) ?? DEFAULT_DELAY\n clearTimer()\n\n // Show the tooltip after the delay\n if (delay > 0) {\n timer.value = setTimeout(() => showTooltip(_e), delay)\n } else {\n showTooltip(_e)\n }\n }\n\n /**\n * Show the tooltip\n */\n function showTooltip(_e: Event) {\n clearTimer()\n\n // Handle the escape key\n document.addEventListener('keydown', handleEscape, { once: true, capture: true })\n\n // Move the element before the config is assigned, not after. Floating UI watches the\n // target with `flush: 'sync'`, so it measures the position the instant the config\n // lands, and that measurement has to happen with the tooltip already in its final\n // parent or the first frame is positioned against the wrong offset parent.\n moveTooltipToHost(unref(opts.targetRef))\n\n // Show the tooltip\n config.value = opts\n }\n\n watch(\n () => unref(opts.targetRef),\n (newRef, oldRef) => {\n if (oldRef) {\n oldRef.removeEventListener('mouseenter', showTooltipAfterDelay)\n oldRef.removeEventListener('mouseleave', hideTooltip)\n oldRef.removeEventListener('focus', showTooltip)\n oldRef.removeEventListener('blur', hideTooltip)\n\n oldRef.removeAttribute('aria-describedby')\n }\n if (newRef) {\n newRef.addEventListener('mouseenter', showTooltipAfterDelay)\n newRef.addEventListener('mouseleave', hideTooltip)\n newRef.addEventListener('focus', showTooltip)\n newRef.addEventListener('blur', hideTooltip)\n\n newRef.setAttribute('aria-describedby', ELEMENT_ID)\n }\n },\n { immediate: true },\n )\n\n // Cleanup the tooltip when the component is unmounted\n onScopeDispose(() => {\n clearTimer()\n\n const target = unref(opts.targetRef)\n if (target) {\n target.removeEventListener('mouseenter', showTooltipAfterDelay)\n target.removeEventListener('mouseleave', hideTooltip)\n target.removeEventListener('focus', showTooltip)\n target.removeEventListener('blur', hideTooltip)\n target.removeAttribute('aria-describedby')\n }\n\n // If the tooltip is showing on this target hide it\n if (unref(config.value?.targetRef) === unref(opts.targetRef)) {\n config.value = undefined\n }\n })\n}\n"],"mappings":";;;;;;;;;AAeA,IAAM,QAAQ,IAAW;;;;;;AAOzB,IAAM,KAAK,IAAiB;;;;;;AAO5B,IAAM,SAAS,IAA0B;AAOzC,IAAM,EAAE,gBAAgB,WAAW,WAAW,YAC5C,eAAe,MAAM,OAAO,OAAO,SAAS,CAAC,GAC7C,IACA;CACE,WAAW,eAAe,MAAM,OAAO,OAAO,SAAS,CAAC;CACxD,sBAAsB;CACtB,YAAY,eAAe,CAAC,KAAK,GAAG,MAAM,CAAC,CAAC;AAC9C,CACF;AAOA,MAAM,YAAY,UAAU;CAC1B,IAAI,CAAC,GAAG,SAAS,CAAC,OAChB;CAEF,GAAG,MAAM,QAAQ,OAAO,MAAM,MAAM,GAAG,CAAC,CAAC;AAC3C,CAAC;AAGD,MAAM,sBAAsB;CAC1B,IAAI,CAAC,GAAG,OACN;CAGF,GAAG,MAAM,MAAM,WAAW,eAAe,MAAM;CAC/C,GAAG,MAAM,MAAM,MAAM,eAAe,MAAM;CAC1C,GAAG,MAAM,MAAM,OAAO,eAAe,MAAM;CAC3C,GAAG,MAAM,MAAM,YAAY,eAAe,MAAM,aAAa;CAC7D,GAAG,MAAM,MAAM,aAAa,eAAe,MAAM,cAAc;AACjE,CAAC;AAGD,MACE,SACC,SAAS;CACR,IAAI,CAAC,GAAG,OACN;CAGF,IAAI,MAAM;EAMR,IAAI,kBAAkB,MAAM,KAAK,SAAS,CAAC,GACzC,OAAO;EAGT,MAAM,gBAAgB,MAAM,MAAM,aAAa,KAAK;EAGpD,GAAG,MAAM,iBAAiB,MAAM,MAAM,OAAO,KAAK;EAGlD,MAAM,SAAS,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MAAM,KAAK,SAAS,CAAC;EAGvC,OAAO,QAAQ;CACjB;CAEA,YACQ,MAAM,KAAK,SAAS,IACzB,QAAQ,WAAW;EAClB,IAAI,QAAQ;GACV,OAAO,oBAAoB,cAAc,qBAAqB;GAC9D,OAAO,oBAAoB,cAAc,WAAW;GACpD,OAAO,oBAAoB,SAAS,WAAW;GAC/C,OAAO,oBAAoB,QAAQ,WAAW;GAE9C,OAAO,gBAAgB,kBAAkB;EAC3C;EACA,IAAI,QAAQ;GACV,OAAO,iBAAiB,cAAc,qBAAqB;GAC3D,OAAO,iBAAiB,cAAc,WAAW;GACjD,OAAO,iBAAiB,SAAS,WAAW;GAC5C,OAAO,iBAAiB,QAAQ,WAAW;GAE3C,OAAO,aAAa,oBAAoB,UAAU;EACpD;CACF,GACA,EAAE,WAAW,KAAK,CACpB;CAGA,qBAAqB;EACnB,WAAW;EAEX,MAAM,SAAS,MAAM,KAAK,SAAS;EACnC,IAAI,QAAQ;GACV,OAAO,oBAAoB,cAAc,qBAAqB;GAC9D,OAAO,oBAAoB,cAAc,WAAW;GACpD,OAAO,oBAAoB,SAAS,WAAW;GAC/C,OAAO,oBAAoB,QAAQ,WAAW;GAC9C,OAAO,gBAAgB,kBAAkB;EAC3C;EAGA,IAAI,MAAM,OAAO,OAAO,SAAS,MAAM,MAAM,KAAK,SAAS,GACzD,OAAO,QAAQ,KAAA;CAEnB,CAAC;AACH"}
|
package/dist/style.css
CHANGED
|
@@ -106,9 +106,9 @@
|
|
|
106
106
|
--scalar-radius-2xl: min(calc(var(--scalar-radius) * 4), var(--scalar-radius-max));
|
|
107
107
|
--scalar-radius-3xl: min(calc(var(--scalar-radius) * 16 / 3), var(--scalar-radius-max));
|
|
108
108
|
--scalar-radius-full: calc(var(--scalar-radius) * 9999);
|
|
109
|
-
--scalar-font:
|
|
110
|
-
"
|
|
111
|
-
--scalar-font-code:
|
|
109
|
+
--scalar-font: -apple-system-body, ui-sans-serif, -apple-system, system-ui, "Segoe UI", "Helvetica", "Apple Color Emoji", "Arial",
|
|
110
|
+
sans-serif, "Segoe UI Emoji", "Segoe UI Symbol";
|
|
111
|
+
--scalar-font-code: ui-monospace, "SFMono-Regular", "SF Mono", menlo, consolas, "Liberation Mono", monospace;
|
|
112
112
|
--scalar-heading-1: 24px;
|
|
113
113
|
--scalar-page-description: 16px;
|
|
114
114
|
--scalar-heading-2: 20px;
|
|
@@ -146,7 +146,6 @@
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
.dark-mode {
|
|
149
|
-
color-scheme: dark;
|
|
150
149
|
--scalar-scrollbar-color: #ffffff2e;
|
|
151
150
|
--scalar-scrollbar-color-active: #ffffff5c;
|
|
152
151
|
--scalar-button-1: #fff;
|
|
@@ -161,7 +160,6 @@
|
|
|
161
160
|
}
|
|
162
161
|
|
|
163
162
|
.light-mode {
|
|
164
|
-
color-scheme: light;
|
|
165
163
|
--scalar-scrollbar-color-active: #0000005c;
|
|
166
164
|
--scalar-scrollbar-color: #0000002e;
|
|
167
165
|
--scalar-button-1: #000;
|
|
@@ -175,8 +173,24 @@
|
|
|
175
173
|
--scalar-text-decoration-color-hover: currentColor;
|
|
176
174
|
}
|
|
177
175
|
|
|
178
|
-
.
|
|
179
|
-
color-scheme: dark
|
|
176
|
+
.dark-mode .scalar-app {
|
|
177
|
+
color-scheme: dark;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.light-mode .scalar-app {
|
|
181
|
+
color-scheme: light;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.scalar-app .scalar-app {
|
|
185
|
+
color-scheme: inherit;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
.scalar-app.dark-mode, .scalar-app .dark-mode {
|
|
189
|
+
color-scheme: dark;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.scalar-app.light-mode, .scalar-app .light-mode {
|
|
193
|
+
color-scheme: light;
|
|
180
194
|
}
|
|
181
195
|
|
|
182
196
|
@media (max-width: 460px) {
|
|
@@ -886,10 +900,6 @@
|
|
|
886
900
|
z-index: 1001;
|
|
887
901
|
}
|
|
888
902
|
|
|
889
|
-
.scalar-app .z-overlay {
|
|
890
|
-
z-index: 10000;
|
|
891
|
-
}
|
|
892
|
-
|
|
893
903
|
.scalar-app .z-tooltip {
|
|
894
904
|
z-index: 99999;
|
|
895
905
|
}
|
|
@@ -1525,6 +1535,10 @@
|
|
|
1525
1535
|
max-width: 448px;
|
|
1526
1536
|
}
|
|
1527
1537
|
|
|
1538
|
+
.scalar-app .max-w-none {
|
|
1539
|
+
max-width: none;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1528
1542
|
.scalar-app .max-w-screen-padded-4 {
|
|
1529
1543
|
max-width: calc(100vw - 32px);
|
|
1530
1544
|
}
|
|
@@ -2043,10 +2057,6 @@
|
|
|
2043
2057
|
background-color: var(--scalar-tooltip-background);
|
|
2044
2058
|
}
|
|
2045
2059
|
|
|
2046
|
-
.scalar-app .bg-backdrop {
|
|
2047
|
-
background-color: #00000038;
|
|
2048
|
-
}
|
|
2049
|
-
|
|
2050
2060
|
.scalar-app .bg-border {
|
|
2051
2061
|
background-color: var(--scalar-border-color);
|
|
2052
2062
|
}
|
|
@@ -2840,6 +2850,10 @@
|
|
|
2840
2850
|
font-size: var(--scalar-font-size-5);
|
|
2841
2851
|
}
|
|
2842
2852
|
|
|
2853
|
+
.scalar-app .not-open\:hidden:not(:is([open], :popover-open, :open)) {
|
|
2854
|
+
display: none;
|
|
2855
|
+
}
|
|
2856
|
+
|
|
2843
2857
|
@media (hover: hover) {
|
|
2844
2858
|
:is(:where(.group):hover :is(.scalar-app .group-hover\:text-c-1)) {
|
|
2845
2859
|
color: var(--scalar-color-1);
|
|
@@ -2916,6 +2930,10 @@
|
|
|
2916
2930
|
background-color: #00000038;
|
|
2917
2931
|
}
|
|
2918
2932
|
|
|
2933
|
+
.scalar-app .backdrop\:bg-transparent::backdrop {
|
|
2934
|
+
background-color: #0000;
|
|
2935
|
+
}
|
|
2936
|
+
|
|
2919
2937
|
.scalar-app .first\:rounded-t-\[inherit\]:first-child {
|
|
2920
2938
|
border-top-left-radius: inherit;
|
|
2921
2939
|
border-top-right-radius: inherit;
|
|
@@ -3114,10 +3132,6 @@
|
|
|
3114
3132
|
background-color: var(--scalar-background-3);
|
|
3115
3133
|
}
|
|
3116
3134
|
|
|
3117
|
-
.scalar-app .dark\:bg-backdrop-dark:where(.dark-mode, .dark-mode *) {
|
|
3118
|
-
background-color: #00000073;
|
|
3119
|
-
}
|
|
3120
|
-
|
|
3121
3135
|
.scalar-app .dark\:bg-linear-to-t:where(.dark-mode, .dark-mode *) {
|
|
3122
3136
|
--tw-gradient-position: to top;
|
|
3123
3137
|
}
|
|
@@ -3148,6 +3162,10 @@
|
|
|
3148
3162
|
background-color: #00000073;
|
|
3149
3163
|
}
|
|
3150
3164
|
|
|
3165
|
+
.scalar-app .dark\:backdrop\:bg-transparent:where(.dark-mode, .dark-mode *)::backdrop {
|
|
3166
|
+
background-color: #0000;
|
|
3167
|
+
}
|
|
3168
|
+
|
|
3151
3169
|
@media (hover: hover) {
|
|
3152
3170
|
.scalar-app .dark\:hover\:bg-b-2:where(.dark-mode, .dark-mode *):hover {
|
|
3153
3171
|
background-color: var(--scalar-background-2);
|
|
@@ -3778,10 +3796,15 @@ to {
|
|
|
3778
3796
|
var(--scalar-shadow-1),
|
|
3779
3797
|
0 0 0 var(--scalar-border-width) var(--scalar-border-color);
|
|
3780
3798
|
}
|
|
3781
|
-
@supports (color:
|
|
3799
|
+
@supports (color: oklab(from white l a b)) {
|
|
3782
3800
|
.scalar-card {
|
|
3783
|
-
|
|
3784
|
-
|
|
3801
|
+
/*
|
|
3802
|
+
* The lightness step is taken in oklab, not oklch. Chrome treats the hue of a near-grey color
|
|
3803
|
+
* as missing in oklch(from …) but keeps its small chroma, which turned the surfaces of themes
|
|
3804
|
+
* with tinted greys pink. Oklab has the same lightness and no hue to lose.
|
|
3805
|
+
*/
|
|
3806
|
+
--scalar-card-surface: oklab(
|
|
3807
|
+
from var(--scalar-background-2) calc(l + 0.055) a b
|
|
3785
3808
|
);
|
|
3786
3809
|
--scalar-card-surface-raised: color-mix(
|
|
3787
3810
|
in oklab,
|
|
@@ -4766,19 +4789,15 @@ ol > li::marker,
|
|
|
4766
4789
|
}
|
|
4767
4790
|
}
|
|
4768
4791
|
/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
|
|
4769
|
-
.scalar-modal
|
|
4770
|
-
animation: .3s ease-in-out forwards fadein-layout-
|
|
4792
|
+
.scalar-modal[data-v-09866bb7]::backdrop {
|
|
4793
|
+
animation: .3s ease-in-out forwards fadein-layout-09866bb7;
|
|
4771
4794
|
}
|
|
4772
|
-
.scalar-modal[data-v-
|
|
4795
|
+
.scalar-modal[data-v-09866bb7] {
|
|
4773
4796
|
box-shadow: var(--scalar-shadow-2);
|
|
4774
|
-
animation: .3s ease-in-out .1s forwards fadein-modal-
|
|
4797
|
+
animation: .3s ease-in-out .1s forwards fadein-modal-09866bb7;
|
|
4775
4798
|
transform: translate3d(0, 10px, 0);
|
|
4776
4799
|
}
|
|
4777
|
-
.
|
|
4778
|
-
opacity: 1 !important;
|
|
4779
|
-
background: none !important;
|
|
4780
|
-
}
|
|
4781
|
-
.modal-content-search .modal-body[data-v-b002945c] {
|
|
4800
|
+
.modal-content-search .modal-body[data-v-09866bb7] {
|
|
4782
4801
|
flex-direction: column;
|
|
4783
4802
|
max-height: 440px;
|
|
4784
4803
|
padding: 0;
|
|
@@ -4786,12 +4805,12 @@ ol > li::marker,
|
|
|
4786
4805
|
overflow: hidden;
|
|
4787
4806
|
}
|
|
4788
4807
|
@media (max-width: 720px) and (max-height: 480px) {
|
|
4789
|
-
.scalar-modal
|
|
4808
|
+
.scalar-modal[data-v-09866bb7]:not(.full-size-styles) {
|
|
4790
4809
|
max-height: 90svh;
|
|
4791
4810
|
margin-top: 5svh;
|
|
4792
4811
|
}
|
|
4793
4812
|
}
|
|
4794
|
-
@keyframes fadein-layout-
|
|
4813
|
+
@keyframes fadein-layout-09866bb7 {
|
|
4795
4814
|
0% {
|
|
4796
4815
|
opacity: 0;
|
|
4797
4816
|
}
|
|
@@ -4799,7 +4818,7 @@ ol > li::marker,
|
|
|
4799
4818
|
opacity: 1;
|
|
4800
4819
|
}
|
|
4801
4820
|
}
|
|
4802
|
-
@keyframes fadein-modal-
|
|
4821
|
+
@keyframes fadein-modal-09866bb7 {
|
|
4803
4822
|
0% {
|
|
4804
4823
|
opacity: 0;
|
|
4805
4824
|
transform: translate3d(0, 10px, 0);
|
|
@@ -4809,10 +4828,10 @@ ol > li::marker,
|
|
|
4809
4828
|
transform: translate3d(0, 0, 0);
|
|
4810
4829
|
}
|
|
4811
4830
|
}
|
|
4812
|
-
.full-size-styles[data-v-
|
|
4831
|
+
.full-size-styles[data-v-09866bb7] {
|
|
4813
4832
|
margin: initial;
|
|
4814
4833
|
border-right: var(--scalar-border-width) solid var(--scalar-border-color);
|
|
4815
|
-
animation: .3s ease-in-out forwards fadein-layout-
|
|
4834
|
+
animation: .3s ease-in-out forwards fadein-layout-09866bb7;
|
|
4816
4835
|
left: 0;
|
|
4817
4836
|
transform: translate3d(0, 0, 0);
|
|
4818
4837
|
background-color: var(--scalar-background-1) !important;
|
|
@@ -4823,11 +4842,11 @@ ol > li::marker,
|
|
|
4823
4842
|
top: 0 !important;
|
|
4824
4843
|
}
|
|
4825
4844
|
@media (min-width: 800px) {
|
|
4826
|
-
.full-size-styles[data-v-
|
|
4845
|
+
.full-size-styles[data-v-09866bb7] {
|
|
4827
4846
|
width: 50dvw !important;
|
|
4828
4847
|
}
|
|
4829
4848
|
}
|
|
4830
|
-
.full-size-styles[data-v-
|
|
4849
|
+
.full-size-styles[data-v-09866bb7]:after {
|
|
4831
4850
|
content: "";
|
|
4832
4851
|
width: 50dvw;
|
|
4833
4852
|
height: 100dvh;
|
package/dist/vue-styles.css
CHANGED
|
@@ -114,10 +114,15 @@ to {
|
|
|
114
114
|
var(--scalar-shadow-1),
|
|
115
115
|
0 0 0 var(--scalar-border-width) var(--scalar-border-color);
|
|
116
116
|
}
|
|
117
|
-
@supports (color:
|
|
117
|
+
@supports (color: oklab(from white l a b)) {
|
|
118
118
|
.scalar-card {
|
|
119
|
-
|
|
120
|
-
|
|
119
|
+
/*
|
|
120
|
+
* The lightness step is taken in oklab, not oklch. Chrome treats the hue of a near-grey color
|
|
121
|
+
* as missing in oklch(from …) but keeps its small chroma, which turned the surfaces of themes
|
|
122
|
+
* with tinted greys pink. Oklab has the same lightness and no hue to lose.
|
|
123
|
+
*/
|
|
124
|
+
--scalar-card-surface: oklab(
|
|
125
|
+
from var(--scalar-background-2) calc(l + 0.055) a b
|
|
121
126
|
);
|
|
122
127
|
--scalar-card-surface-raised: color-mix(
|
|
123
128
|
in oklab,
|
|
@@ -1102,19 +1107,15 @@ ol > li::marker,
|
|
|
1102
1107
|
}
|
|
1103
1108
|
}
|
|
1104
1109
|
/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
|
|
1105
|
-
.scalar-modal
|
|
1106
|
-
animation: .3s ease-in-out forwards fadein-layout-
|
|
1110
|
+
.scalar-modal[data-v-09866bb7]::backdrop {
|
|
1111
|
+
animation: .3s ease-in-out forwards fadein-layout-09866bb7;
|
|
1107
1112
|
}
|
|
1108
|
-
.scalar-modal[data-v-
|
|
1113
|
+
.scalar-modal[data-v-09866bb7] {
|
|
1109
1114
|
box-shadow: var(--scalar-shadow-2);
|
|
1110
|
-
animation: .3s ease-in-out .1s forwards fadein-modal-
|
|
1115
|
+
animation: .3s ease-in-out .1s forwards fadein-modal-09866bb7;
|
|
1111
1116
|
transform: translate3d(0, 10px, 0);
|
|
1112
1117
|
}
|
|
1113
|
-
.
|
|
1114
|
-
opacity: 1 !important;
|
|
1115
|
-
background: none !important;
|
|
1116
|
-
}
|
|
1117
|
-
.modal-content-search .modal-body[data-v-b002945c] {
|
|
1118
|
+
.modal-content-search .modal-body[data-v-09866bb7] {
|
|
1118
1119
|
flex-direction: column;
|
|
1119
1120
|
max-height: 440px;
|
|
1120
1121
|
padding: 0;
|
|
@@ -1122,12 +1123,12 @@ ol > li::marker,
|
|
|
1122
1123
|
overflow: hidden;
|
|
1123
1124
|
}
|
|
1124
1125
|
@media (max-width: 720px) and (max-height: 480px) {
|
|
1125
|
-
.scalar-modal
|
|
1126
|
+
.scalar-modal[data-v-09866bb7]:not(.full-size-styles) {
|
|
1126
1127
|
max-height: 90svh;
|
|
1127
1128
|
margin-top: 5svh;
|
|
1128
1129
|
}
|
|
1129
1130
|
}
|
|
1130
|
-
@keyframes fadein-layout-
|
|
1131
|
+
@keyframes fadein-layout-09866bb7 {
|
|
1131
1132
|
0% {
|
|
1132
1133
|
opacity: 0;
|
|
1133
1134
|
}
|
|
@@ -1135,7 +1136,7 @@ ol > li::marker,
|
|
|
1135
1136
|
opacity: 1;
|
|
1136
1137
|
}
|
|
1137
1138
|
}
|
|
1138
|
-
@keyframes fadein-modal-
|
|
1139
|
+
@keyframes fadein-modal-09866bb7 {
|
|
1139
1140
|
0% {
|
|
1140
1141
|
opacity: 0;
|
|
1141
1142
|
transform: translate3d(0, 10px, 0);
|
|
@@ -1145,10 +1146,10 @@ ol > li::marker,
|
|
|
1145
1146
|
transform: translate3d(0, 0, 0);
|
|
1146
1147
|
}
|
|
1147
1148
|
}
|
|
1148
|
-
.full-size-styles[data-v-
|
|
1149
|
+
.full-size-styles[data-v-09866bb7] {
|
|
1149
1150
|
margin: initial;
|
|
1150
1151
|
border-right: var(--scalar-border-width) solid var(--scalar-border-color);
|
|
1151
|
-
animation: .3s ease-in-out forwards fadein-layout-
|
|
1152
|
+
animation: .3s ease-in-out forwards fadein-layout-09866bb7;
|
|
1152
1153
|
left: 0;
|
|
1153
1154
|
transform: translate3d(0, 0, 0);
|
|
1154
1155
|
background-color: var(--scalar-background-1) !important;
|
|
@@ -1159,11 +1160,11 @@ ol > li::marker,
|
|
|
1159
1160
|
top: 0 !important;
|
|
1160
1161
|
}
|
|
1161
1162
|
@media (min-width: 800px) {
|
|
1162
|
-
.full-size-styles[data-v-
|
|
1163
|
+
.full-size-styles[data-v-09866bb7] {
|
|
1163
1164
|
width: 50dvw !important;
|
|
1164
1165
|
}
|
|
1165
1166
|
}
|
|
1166
|
-
.full-size-styles[data-v-
|
|
1167
|
+
.full-size-styles[data-v-09866bb7]:after {
|
|
1167
1168
|
content: "";
|
|
1168
1169
|
width: 50dvw;
|
|
1169
1170
|
height: 100dvh;
|
package/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"url": "git+https://github.com/scalar/scalar.git",
|
|
11
11
|
"directory": "packages/components"
|
|
12
12
|
},
|
|
13
|
-
"version": "0.36.
|
|
13
|
+
"version": "0.36.1",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">=22"
|
|
16
16
|
},
|
|
@@ -221,12 +221,12 @@
|
|
|
221
221
|
"@floating-ui/vue": "2.0.1",
|
|
222
222
|
"@headlessui/tailwindcss": "^0.2.2",
|
|
223
223
|
"@headlessui/vue": "1.7.23",
|
|
224
|
-
"@scalar/helpers": "0.20.
|
|
224
|
+
"@scalar/helpers": "0.20.1",
|
|
225
225
|
"@scalar/highlight": "0.9.0",
|
|
226
226
|
"@scalar/icons": "0.7.12",
|
|
227
227
|
"@scalar/markdown": "0.1.3",
|
|
228
|
-
"@scalar/themes": "0.
|
|
229
|
-
"@scalar/use-hooks": "0.5.
|
|
228
|
+
"@scalar/themes": "0.22.0",
|
|
229
|
+
"@scalar/use-hooks": "0.5.1",
|
|
230
230
|
"@vueuse/core": "15.0.0",
|
|
231
231
|
"cva": "1.0.0-beta.4",
|
|
232
232
|
"radix-vue": "^1.9.17",
|
|
@@ -235,6 +235,7 @@
|
|
|
235
235
|
},
|
|
236
236
|
"devDependencies": {
|
|
237
237
|
"@playwright/test": "1.65.1",
|
|
238
|
+
"@scalar/use-toasts": "0.10.11",
|
|
238
239
|
"@storybook/addon-docs": "10.6.8",
|
|
239
240
|
"@storybook/addon-links": "10.6.8",
|
|
240
241
|
"@storybook/vue3-vite": "10.6.8",
|