@scalar/components 0.36.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/ScalarSidebar/ScalarSidebarButton.vue.d.ts +3 -0
- package/dist/components/ScalarSidebar/ScalarSidebarButton.vue.d.ts.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarButton.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarItems.vue.d.ts +5 -0
- package/dist/components/ScalarSidebar/ScalarSidebarItems.vue.d.ts.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarItems.vue_vue_type_script_setup_true_lang.js +3 -3
- package/dist/components/ScalarSidebar/ScalarSidebarItems.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarNestedItems.vue.d.ts +5 -0
- package/dist/components/ScalarSidebar/ScalarSidebarNestedItems.vue.d.ts.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarNestedItems.vue_vue_type_script_setup_true_lang.js +9 -7
- package/dist/components/ScalarSidebar/ScalarSidebarNestedItems.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarSearchButton.vue.d.ts +3 -0
- package/dist/components/ScalarSidebar/ScalarSidebarSearchButton.vue.d.ts.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarSearchButton.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarSearchButton.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 +59 -40
- package/dist/vue-styles.css +22 -21
- package/package.json +5 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarSidebarSearchButton.vue_vue_type_script_setup_true_lang.js","names":["$slots","_openBlock","_createElementBlock","_mergeProps","_unref","_createVNode","_createElementVNode","_renderSlot","_createTextVNode","_toDisplayString"],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarSearchButton.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Search Button component\n *\n * A styled button that serves as a search trigger in the sidebar.\n * Displays a magnifying glass icon and an optional keyboard shortcut.\n *\n * @example\n * <ScalarSidebarSearchButton>\n * <template #shortcut>⌘K</template>\n * </ScalarSidebarSearchButton>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { ScalarIconMagnifyingGlass } from '@scalar/icons'\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\n\nconst { shortcutLabel = 'Keyboard Shortcut:' } = defineProps<{\n shortcutLabel?: string\n}>()\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <!-- role=\"search\" is a landmark for a search region, not a button control -->\n <button\n type=\"button\"\n v-bind=\"\n cx(\n 'flex items-center rounded border text-base h-8 gap-1 pl-2 pr-1',\n 'bg-sidebar-b-search border-sidebar-border-search text-sidebar-c-search',\n )\n \">\n <ScalarIconMagnifyingGlass\n aria-hidden=\"true\"\n class=\"size-4\" />\n <span class=\"flex-1 text-start leading-none\">\n <slot>Search...</slot>\n </span>\n <span\n v-if=\"$slots.shortcut\"\n class=\"text-sidebar-c-2 rounded border px-1.25 py-1 text-xs leading-none font-medium uppercase\">\n <span class=\"sr-only\">{{ shortcutLabel }}</span>\n <kbd dir=\"ltr\">\n <slot name=\"shortcut\" />\n </kbd>\n </span>\n </button>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ScalarSidebarSearchButton.vue_vue_type_script_setup_true_lang.js","names":["$slots","_openBlock","_createElementBlock","_mergeProps","_unref","_createVNode","_createElementVNode","_renderSlot","_createTextVNode","_toDisplayString"],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarSearchButton.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Search Button component\n *\n * A styled button that serves as a search trigger in the sidebar.\n * Displays a magnifying glass icon and an optional keyboard shortcut.\n *\n * @example\n * <ScalarSidebarSearchButton>\n * <template #shortcut>⌘K</template>\n * </ScalarSidebarSearchButton>\n *\n * Stable hooks for styling from outside the component:\n * - `.scalar-sidebar-search-shortcut` targets the keyboard shortcut hint\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { ScalarIconMagnifyingGlass } from '@scalar/icons'\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\n\nconst { shortcutLabel = 'Keyboard Shortcut:' } = defineProps<{\n shortcutLabel?: string\n}>()\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <!-- role=\"search\" is a landmark for a search region, not a button control -->\n <button\n type=\"button\"\n v-bind=\"\n cx(\n 'flex items-center rounded border text-base h-8 gap-1 pl-2 pr-1',\n 'bg-sidebar-b-search border-sidebar-border-search text-sidebar-c-search',\n )\n \">\n <ScalarIconMagnifyingGlass\n aria-hidden=\"true\"\n class=\"size-4\" />\n <span class=\"flex-1 text-start leading-none\">\n <slot>Search...</slot>\n </span>\n <span\n v-if=\"$slots.shortcut\"\n class=\"scalar-sidebar-search-shortcut text-sidebar-c-2 rounded border px-1.25 py-1 text-xs leading-none font-medium uppercase\">\n <span class=\"sr-only\">{{ shortcutLabel }}</span>\n <kbd dir=\"ltr\">\n <slot name=\"shortcut\" />\n </kbd>\n </span>\n </button>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;EA0BA,MAAM,EAAE,OAAO,UAAU;;GAIvB,OAAAC,UAAA,GAAAC,mBAsBS,UAtBTC,WAsBS,EArBP,MAAK,SAAQ,GACEC,MAAA,EAAA,CAAE,C;IAMjBC,YAEmBD,MAAA,yBAAA,GAAA;KADjB,eAAY;KACZ,OAAM;;IACRE,mBAEO,QAFP,YAEO,CADLC,WAAsB,KAAA,QAAA,WAAA,CAAA,SAAA,CAAhB,OAAA,OAAA,OAAA,KAAAC,gBAAA,aAAS,EAAA,E;IAGTR,KAAAA,OAAO,YADfC,UAAA,GAAAC,mBAOO,QAPP,YAOO,CAJLI,mBAAgD,QAAhD,YAAgDG,gBAAvB,QAAA,aAAa,GAAA,CAAA,GACtCH,mBAEM,OAFN,YAEM,CADJC,WAAwB,KAAA,QAAA,UAAA,C"}
|
|
@@ -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,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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K,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"}
|
|
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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AAkB;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;
|
|
@@ -4850,7 +4869,7 @@ ol > li::marker,
|
|
|
4850
4869
|
width: 66.6667%;
|
|
4851
4870
|
}
|
|
4852
4871
|
/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
|
|
4853
|
-
.
|
|
4872
|
+
.scalar-sidebar-items[data-nested-open] :is(.scalar-sidebar-button, .group\/button) {
|
|
4854
4873
|
transition-behavior: allow-discrete;
|
|
4855
4874
|
max-height: 0;
|
|
4856
4875
|
transition-property: display, max-height;
|
|
@@ -4858,7 +4877,7 @@ ol > li::marker,
|
|
|
4858
4877
|
transition-delay: .3s;
|
|
4859
4878
|
display: none;
|
|
4860
4879
|
}
|
|
4861
|
-
.
|
|
4880
|
+
.scalar-sidebar-nested-items[data-open] > * > .scalar-sidebar-items:not([data-nested-open]) :is(.scalar-sidebar-button, .group\/button) {
|
|
4862
4881
|
max-height: 2147483647px;
|
|
4863
4882
|
display: flex;
|
|
4864
4883
|
}
|
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;
|
|
@@ -1186,7 +1187,7 @@ ol > li::marker,
|
|
|
1186
1187
|
width: 66.6667%;
|
|
1187
1188
|
}
|
|
1188
1189
|
/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */
|
|
1189
|
-
.
|
|
1190
|
+
.scalar-sidebar-items[data-nested-open] :is(.scalar-sidebar-button, .group\/button) {
|
|
1190
1191
|
transition-behavior: allow-discrete;
|
|
1191
1192
|
max-height: 0;
|
|
1192
1193
|
transition-property: display, max-height;
|
|
@@ -1194,7 +1195,7 @@ ol > li::marker,
|
|
|
1194
1195
|
transition-delay: .3s;
|
|
1195
1196
|
display: none;
|
|
1196
1197
|
}
|
|
1197
|
-
.
|
|
1198
|
+
.scalar-sidebar-nested-items[data-open] > * > .scalar-sidebar-items:not([data-nested-open]) :is(.scalar-sidebar-button, .group\/button) {
|
|
1198
1199
|
max-height: 2147483647px;
|
|
1199
1200
|
display: flex;
|
|
1200
1201
|
}
|
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.
|
|
13
|
+
"version": "0.37.0",
|
|
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.
|
|
224
|
+
"@scalar/helpers": "0.21.0",
|
|
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.2",
|
|
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.12",
|
|
238
239
|
"@storybook/addon-docs": "10.6.8",
|
|
239
240
|
"@storybook/addon-links": "10.6.8",
|
|
240
241
|
"@storybook/vue3-vite": "10.6.8",
|