@scalar/components 0.24.2 → 0.24.4

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.
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarDropdownButton.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarDropdown/ScalarDropdownButton.vue"],"names":[],"mappings":"AA+DA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAGpC;;;;;;;;;;;;;;GAcG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;SAEX,MAAM,GAAG,SAAS;aACd,OAAO;eACL,OAAO;;SAFb,MAAM,GAAG,SAAS;aACd,OAAO;eACL,OAAO;;cAmEN,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
+ {"version":3,"file":"ScalarDropdownButton.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarDropdown/ScalarDropdownButton.vue"],"names":[],"mappings":"AAiEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAGpC;;;;;;;;;;;;;;GAcG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;SAEX,MAAM,GAAG,SAAS;aACd,OAAO;eACL,OAAO;;SAFb,MAAM,GAAG,SAAS;aACd,OAAO;eACL,OAAO;;cAsEN,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"}
@@ -2,7 +2,7 @@ import _plugin_vue_export_helper_default from "../../_virtual/_plugin-vue_export
2
2
  import ScalarDropdownButton_vue_vue_type_script_setup_true_lang_default from "./ScalarDropdownButton.vue.script.js";
3
3
  /* empty css */
4
4
  //#region src/components/ScalarDropdown/ScalarDropdownButton.vue
5
- var ScalarDropdownButton_default = /* @__PURE__ */ _plugin_vue_export_helper_default(ScalarDropdownButton_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-6660bbc5"]]);
5
+ var ScalarDropdownButton_default = /* @__PURE__ */ _plugin_vue_export_helper_default(ScalarDropdownButton_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-f5e0d3d8"]]);
6
6
  //#endregion
7
7
  export { ScalarDropdownButton_default as default };
8
8
 
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarDropdownButton.vue.js","names":[],"sources":["../../../src/components/ScalarDropdown/ScalarDropdownButton.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar dropdown button base component\n *\n * Provide a styled button for the ScalarDropdown or similar\n *\n * This is used internally by the ScalarDropdownItem component\n *\n * If you're looking to add items to a dropdown menu you\n * probably want the ScalarDropdownItem component\n *\n * @example\n * <ScalarDropdownButton @click=\"handleClick\">\n * Label\n * </ScalarDropdownButton>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { cva, cx } from '@scalar/use-hooks/useBindCx'\nimport type { Component } from 'vue'\n\nconst { is = 'button' } = defineProps<{\n is?: string | Component\n active?: boolean\n disabled?: boolean\n}>()\n\nconst variants = cva({\n base: [\n // Layout\n 'block h-8 min-w-0 gap-1.5 rounded px-2.5 py-1.5 text-left',\n // Text / background style\n 'truncate no-underline text-sm text-c-1',\n // Interaction\n 'cursor-pointer hover:bg-b-2',\n ],\n variants: {\n disabled: { true: 'pointer-events-none text-c-3' },\n active: { true: '' },\n },\n compoundVariants: [{ disabled: false, active: true, class: 'bg-b-2' }],\n})\n</script>\n<template>\n <component\n :is=\"is\"\n :aria-disabled=\"disabled\"\n class=\"item\"\n :class=\"cx('scalar-dropdown-item', variants({ active, disabled }))\"\n :type=\"is === 'button' ? 'button' : undefined\">\n <slot />\n </component>\n</template>\n<style scoped>\n.dark-mode .scalar-dropdown-item:hover {\n filter: brightness(1.1);\n}\n</style>\n"],"mappings":""}
1
+ {"version":3,"file":"ScalarDropdownButton.vue.js","names":[],"sources":["../../../src/components/ScalarDropdown/ScalarDropdownButton.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar dropdown button base component\n *\n * Provide a styled button for the ScalarDropdown or similar\n *\n * This is used internally by the ScalarDropdownItem component\n *\n * If you're looking to add items to a dropdown menu you\n * probably want the ScalarDropdownItem component\n *\n * @example\n * <ScalarDropdownButton @click=\"handleClick\">\n * Label\n * </ScalarDropdownButton>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { cva, cx } from '@scalar/use-hooks/useBindCx'\nimport type { Component } from 'vue'\n\nconst { is = 'button' } = defineProps<{\n is?: string | Component\n active?: boolean\n disabled?: boolean\n}>()\n\nconst variants = cva({\n base: [\n // Layout\n 'block h-8 min-w-0 gap-1.5 rounded px-2.5 py-1.5 text-left',\n // Text / background style\n 'truncate no-underline text-sm text-c-1',\n // Interaction — hover:bg-b-2 handles mouse, highlighted:bg-b-2 handles\n // Radix keyboard navigation and mouse-hover within Radix menu items\n 'cursor-pointer hover:bg-b-2 highlighted:bg-b-2',\n ],\n variants: {\n disabled: { true: 'pointer-events-none text-c-3' },\n active: { true: '' },\n },\n compoundVariants: [{ disabled: false, active: true, class: 'bg-b-2' }],\n})\n</script>\n<template>\n <component\n :is=\"is\"\n :aria-disabled=\"disabled\"\n class=\"item\"\n :class=\"cx('scalar-dropdown-item', variants({ active, disabled }))\"\n :type=\"is === 'button' ? 'button' : undefined\">\n <slot />\n </component>\n</template>\n<style scoped>\n.dark-mode .scalar-dropdown-item:hover,\n.dark-mode .scalar-dropdown-item[data-highlighted] {\n filter: brightness(1.1);\n}\n</style>\n"],"mappings":""}
@@ -12,7 +12,7 @@ var ScalarDropdownButton_vue_vue_type_script_setup_true_lang_default = /* @__PUR
12
12
  base: [
13
13
  "block h-8 min-w-0 gap-1.5 rounded px-2.5 py-1.5 text-left",
14
14
  "truncate no-underline text-sm text-c-1",
15
- "cursor-pointer hover:bg-b-2"
15
+ "cursor-pointer hover:bg-b-2 highlighted:bg-b-2"
16
16
  ],
17
17
  variants: {
18
18
  disabled: { true: "pointer-events-none text-c-3" },
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarDropdownButton.vue.script.js","names":[],"sources":["../../../src/components/ScalarDropdown/ScalarDropdownButton.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar dropdown button base component\n *\n * Provide a styled button for the ScalarDropdown or similar\n *\n * This is used internally by the ScalarDropdownItem component\n *\n * If you're looking to add items to a dropdown menu you\n * probably want the ScalarDropdownItem component\n *\n * @example\n * <ScalarDropdownButton @click=\"handleClick\">\n * Label\n * </ScalarDropdownButton>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { cva, cx } from '@scalar/use-hooks/useBindCx'\nimport type { Component } from 'vue'\n\nconst { is = 'button' } = defineProps<{\n is?: string | Component\n active?: boolean\n disabled?: boolean\n}>()\n\nconst variants = cva({\n base: [\n // Layout\n 'block h-8 min-w-0 gap-1.5 rounded px-2.5 py-1.5 text-left',\n // Text / background style\n 'truncate no-underline text-sm text-c-1',\n // Interaction\n 'cursor-pointer hover:bg-b-2',\n ],\n variants: {\n disabled: { true: 'pointer-events-none text-c-3' },\n active: { true: '' },\n },\n compoundVariants: [{ disabled: false, active: true, class: 'bg-b-2' }],\n})\n</script>\n<template>\n <component\n :is=\"is\"\n :aria-disabled=\"disabled\"\n class=\"item\"\n :class=\"cx('scalar-dropdown-item', variants({ active, disabled }))\"\n :type=\"is === 'button' ? 'button' : undefined\">\n <slot />\n </component>\n</template>\n<style scoped>\n.dark-mode .scalar-dropdown-item:hover {\n filter: brightness(1.1);\n}\n</style>\n"],"mappings":";;;;;;;;;;EA4BA,MAAM,WAAW,IAAI;GACnB,MAAM;IAEJ;IAEA;IAEA;IACD;GACD,UAAU;IACR,UAAU,EAAE,MAAM,gCAAgC;IAClD,QAAQ,EAAE,MAAM,IAAI;IACrB;GACD,kBAAkB,CAAC;IAAE,UAAU;IAAO,QAAQ;IAAM,OAAO;IAAU,CAAC;GACvE,CAAA;;uBAGC,YAOY,wBANL,QAAA,GAAE,EAAA;IACN,iBAAe,QAAA;IAChB,OAAK,eAAA,CAAC,QACE,MAAA,GAAE,CAAA,wBAAyB,MAAA,SAAQ,CAAA;KAAA,QAAG,QAAA;KAAM,UAAE,QAAA;KAAQ,CAAA,CAAA,CAAA,CAAA;IAC7D,MAAM,QAAA,OAAE,WAAA,WAA2B,KAAA;;2BAC5B,CAAR,WAAQ,KAAA,QAAA,WAAA,EAAA,EAAA,KAAA,GAAA,KAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"ScalarDropdownButton.vue.script.js","names":[],"sources":["../../../src/components/ScalarDropdown/ScalarDropdownButton.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar dropdown button base component\n *\n * Provide a styled button for the ScalarDropdown or similar\n *\n * This is used internally by the ScalarDropdownItem component\n *\n * If you're looking to add items to a dropdown menu you\n * probably want the ScalarDropdownItem component\n *\n * @example\n * <ScalarDropdownButton @click=\"handleClick\">\n * Label\n * </ScalarDropdownButton>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { cva, cx } from '@scalar/use-hooks/useBindCx'\nimport type { Component } from 'vue'\n\nconst { is = 'button' } = defineProps<{\n is?: string | Component\n active?: boolean\n disabled?: boolean\n}>()\n\nconst variants = cva({\n base: [\n // Layout\n 'block h-8 min-w-0 gap-1.5 rounded px-2.5 py-1.5 text-left',\n // Text / background style\n 'truncate no-underline text-sm text-c-1',\n // Interaction — hover:bg-b-2 handles mouse, highlighted:bg-b-2 handles\n // Radix keyboard navigation and mouse-hover within Radix menu items\n 'cursor-pointer hover:bg-b-2 highlighted:bg-b-2',\n ],\n variants: {\n disabled: { true: 'pointer-events-none text-c-3' },\n active: { true: '' },\n },\n compoundVariants: [{ disabled: false, active: true, class: 'bg-b-2' }],\n})\n</script>\n<template>\n <component\n :is=\"is\"\n :aria-disabled=\"disabled\"\n class=\"item\"\n :class=\"cx('scalar-dropdown-item', variants({ active, disabled }))\"\n :type=\"is === 'button' ? 'button' : undefined\">\n <slot />\n </component>\n</template>\n<style scoped>\n.dark-mode .scalar-dropdown-item:hover,\n.dark-mode .scalar-dropdown-item[data-highlighted] {\n filter: brightness(1.1);\n}\n</style>\n"],"mappings":";;;;;;;;;;EA4BA,MAAM,WAAW,IAAI;GACnB,MAAM;IAEJ;IAEA;IAGA;IACD;GACD,UAAU;IACR,UAAU,EAAE,MAAM,gCAAgC;IAClD,QAAQ,EAAE,MAAM,IAAI;IACrB;GACD,kBAAkB,CAAC;IAAE,UAAU;IAAO,QAAQ;IAAM,OAAO;IAAU,CAAC;GACvE,CAAA;;uBAGC,YAOY,wBANL,QAAA,GAAE,EAAA;IACN,iBAAe,QAAA;IAChB,OAAK,eAAA,CAAC,QACE,MAAA,GAAE,CAAA,wBAAyB,MAAA,SAAQ,CAAA;KAAA,QAAG,QAAA;KAAM,UAAE,QAAA;KAAQ,CAAA,CAAA,CAAA,CAAA;IAC7D,MAAM,QAAA,OAAE,WAAA,WAA2B,KAAA;;2BAC5B,CAAR,WAAQ,KAAA,QAAA,WAAA,EAAA,EAAA,KAAA,GAAA,KAAA,CAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarHeaderButton.vue.js","names":[],"sources":["../../../src/components/ScalarHeader/ScalarHeaderButton.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar header button component\n *\n * Used within the ScalarHeader component\n *\n * @example\n * ```html\n * <ScalarHeaderButton>\n * Login\n * </ScalarHeaderButton>\n * ```\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { cva, useBindCx } from '@scalar/use-hooks/useBindCx'\nimport type { Component } from 'vue'\n\nconst { is = 'button' } = defineProps<{\n is?: string | Component\n cta?: boolean\n}>()\n\ndefineSlots<{\n /** The contents of the button */\n default?(): unknown\n}>()\n\nconst variants = cva({\n base: 'group/button flex items-center rounded px-3 py-2 text-base/4 no-underline',\n variants: {\n cta: {\n true: 'font-bold bg-b-header-cta text-sm/4 text-c-header-cta hover:bg-h-header-cta',\n false: 'text-c-header-2 hover:text-c-header-1',\n },\n },\n})\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <component\n :is=\"is\"\n :type=\"is === 'button' ? 'button' : undefined\"\n v-bind=\"cx(variants({ cta }))\">\n <slot />\n </component>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"ScalarHeaderButton.vue.js","names":[],"sources":["../../../src/components/ScalarHeader/ScalarHeaderButton.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar header button component\n *\n * Used within the ScalarHeader component\n *\n * @example\n * ```html\n * <ScalarHeaderButton>\n * Login\n * </ScalarHeaderButton>\n * ```\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { cva, useBindCx } from '@scalar/use-hooks/useBindCx'\nimport type { Component } from 'vue'\n\nconst { is = 'button' } = defineProps<{\n is?: string | Component\n cta?: boolean\n}>()\n\ndefineSlots<{\n /** The contents of the button */\n default?(): unknown\n}>()\n\nconst variants = cva({\n base: 'group/button flex items-center rounded px-3 py-2 text-base/4 no-underline',\n variants: {\n cta: {\n true: 'font-bold bg-b-header-cta text-sm/4 text-c-header-cta hover:bg-h-header-cta',\n false: 'text-c-header-2 hover:text-c-header-1',\n },\n },\n})\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <component\n :is=\"is\"\n :type=\"is === 'button' ? 'button' : undefined\"\n v-bind=\"cx(variants({ cta }))\">\n <slot />\n </component>\n</template>\n"],"mappings":""}
@@ -9,7 +9,7 @@ var ScalarHeaderButton_vue_vue_type_script_setup_true_lang_default = /* @__PURE_
9
9
  },
10
10
  setup(__props) {
11
11
  const variants = cva({
12
- base: "group/button flex items-center rounded px-3 py-2 text-base/4 no-underline",
12
+ base: "group/button flex items-center rounded px-3 py-2 text-base/4 no-underline",
13
13
  variants: { cta: {
14
14
  true: "font-bold bg-b-header-cta text-sm/4 text-c-header-cta hover:bg-h-header-cta",
15
15
  false: "text-c-header-2 hover:text-c-header-1"
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarHeaderButton.vue.script.js","names":[],"sources":["../../../src/components/ScalarHeader/ScalarHeaderButton.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar header button component\n *\n * Used within the ScalarHeader component\n *\n * @example\n * ```html\n * <ScalarHeaderButton>\n * Login\n * </ScalarHeaderButton>\n * ```\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { cva, useBindCx } from '@scalar/use-hooks/useBindCx'\nimport type { Component } from 'vue'\n\nconst { is = 'button' } = defineProps<{\n is?: string | Component\n cta?: boolean\n}>()\n\ndefineSlots<{\n /** The contents of the button */\n default?(): unknown\n}>()\n\nconst variants = cva({\n base: 'group/button flex items-center rounded px-3 py-2 text-base/4 no-underline',\n variants: {\n cta: {\n true: 'font-bold bg-b-header-cta text-sm/4 text-c-header-cta hover:bg-h-header-cta',\n false: 'text-c-header-2 hover:text-c-header-1',\n },\n },\n})\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <component\n :is=\"is\"\n :type=\"is === 'button' ? 'button' : undefined\"\n v-bind=\"cx(variants({ cta }))\">\n <slot />\n </component>\n</template>\n"],"mappings":";;;;;;;;;;EA6BA,MAAM,WAAW,IAAI;GACnB,MAAM;GACN,UAAU,EACR,KAAK;IACH,MAAM;IACN,OAAO;IACR,EACF;GACF,CAAA;EAGD,MAAM,EAAE,OAAO,WAAU;;uBAGvB,YAKY,wBAJL,QAAA,GAAE,EADT,WAKY,EAHT,MAAM,QAAA,OAAE,WAAA,WAA2B,KAAA,GAAA,EAC5B,MAAA,GAAE,CAAC,MAAA,SAAQ,CAAA,EAAA,KAAG,QAAA,KAAG,CAAA,CAAA,CAAA,EAAA;2BACjB,CAAR,WAAQ,KAAA,QAAA,UAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"ScalarHeaderButton.vue.script.js","names":[],"sources":["../../../src/components/ScalarHeader/ScalarHeaderButton.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar header button component\n *\n * Used within the ScalarHeader component\n *\n * @example\n * ```html\n * <ScalarHeaderButton>\n * Login\n * </ScalarHeaderButton>\n * ```\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { cva, useBindCx } from '@scalar/use-hooks/useBindCx'\nimport type { Component } from 'vue'\n\nconst { is = 'button' } = defineProps<{\n is?: string | Component\n cta?: boolean\n}>()\n\ndefineSlots<{\n /** The contents of the button */\n default?(): unknown\n}>()\n\nconst variants = cva({\n base: 'group/button flex items-center rounded px-3 py-2 text-base/4 no-underline',\n variants: {\n cta: {\n true: 'font-bold bg-b-header-cta text-sm/4 text-c-header-cta hover:bg-h-header-cta',\n false: 'text-c-header-2 hover:text-c-header-1',\n },\n },\n})\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <component\n :is=\"is\"\n :type=\"is === 'button' ? 'button' : undefined\"\n v-bind=\"cx(variants({ cta }))\">\n <slot />\n </component>\n</template>\n"],"mappings":";;;;;;;;;;EA6BA,MAAM,WAAW,IAAI;GACnB,MAAM;GACN,UAAU,EACR,KAAK;IACH,MAAM;IACN,OAAO;IACR,EACF;GACF,CAAA;EAGD,MAAM,EAAE,OAAO,WAAU;;uBAGvB,YAKY,wBAJL,QAAA,GAAE,EADT,WAKY,EAHT,MAAM,QAAA,OAAE,WAAA,WAA2B,KAAA,GAAA,EAC5B,MAAA,GAAE,CAAC,MAAA,SAAQ,CAAA,EAAA,KAAG,QAAA,KAAG,CAAA,CAAA,CAAA,EAAA;2BACjB,CAAR,WAAQ,KAAA,QAAA,UAAA,CAAA,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"formatHotkey.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarHotkey/formatHotkey.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAa7C,iDAAiD;AACjD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAGrE;AAED,6CAA6C;AAC7C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,MAAM,EAAE,CAGxF;AAKD,wCAAwC;AACxC,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C"}
1
+ {"version":3,"file":"formatHotkey.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarHotkey/formatHotkey.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAkC7C,iDAAiD;AACjD,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAGrE;AAED,6CAA6C;AAC7C,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,MAAM,EAAE,CAGxF;AAKD,wCAAwC;AACxC,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE/C"}
@@ -1,6 +1,16 @@
1
1
  import { HOTKEY_LABELS, MODIFIER_KEY_SYMBOLS, MODIFIER_KEY_SYMBOLS_MACOS } from "./constants.js";
2
2
  import { isMacOS } from "@scalar/helpers/general/is-mac-os";
3
3
  //#region src/components/ScalarHotkey/formatHotkey.ts
4
+ var forcedHotkeySymbolSet = () => {
5
+ const raw = void 0;
6
+ if (raw === "mac" || raw === "non-mac") return raw;
7
+ };
8
+ var useMacHotkeySymbols = () => {
9
+ const forced = forcedHotkeySymbolSet();
10
+ if (forced === "mac") return true;
11
+ if (forced === "non-mac") return false;
12
+ return isMacOS();
13
+ };
4
14
  /** Typescript helper to check if a modifier is the default modifier */
5
15
  function isDefault(modifier) {
6
16
  return modifier === "default";
@@ -8,7 +18,7 @@ function isDefault(modifier) {
8
18
  /** Get the modifier key symbol for a modifier */
9
19
  function getModifierKeySymbol(modifier) {
10
20
  const hotkey = isDefault(modifier) ? "Meta" : modifier;
11
- return isMacOS() ? MODIFIER_KEY_SYMBOLS_MACOS[hotkey] : MODIFIER_KEY_SYMBOLS[hotkey];
21
+ return useMacHotkeySymbols() ? MODIFIER_KEY_SYMBOLS_MACOS[hotkey] : MODIFIER_KEY_SYMBOLS[hotkey];
12
22
  }
13
23
  /** Format the hotkey symbols for a hotkey */
14
24
  function formatHotkeySymbols(hotkey, modifier) {
@@ -1 +1 @@
1
- {"version":3,"file":"formatHotkey.js","names":[],"sources":["../../../src/components/ScalarHotkey/formatHotkey.ts"],"sourcesContent":["import { isMacOS } from '@scalar/helpers/general/is-mac-os'\n\nimport { HOTKEY_LABELS, MODIFIER_KEY_SYMBOLS, MODIFIER_KEY_SYMBOLS_MACOS } from './constants'\nimport type { HotKeyModifier } from './types'\n\n// Type guards\n// ------------------------------------------------------------\n\n/** Typescript helper to check if a modifier is the default modifier */\nfunction isDefault(modifier: HotKeyModifier): modifier is 'default' {\n return modifier === 'default'\n}\n\n// Symbol Formatting\n// ------------------------------------------------------------\n\n/** Get the modifier key symbol for a modifier */\nexport function getModifierKeySymbol(modifier: HotKeyModifier): string {\n const hotkey = isDefault(modifier) ? 'Meta' : modifier\n return isMacOS() ? MODIFIER_KEY_SYMBOLS_MACOS[hotkey] : MODIFIER_KEY_SYMBOLS[hotkey]\n}\n\n/** Format the hotkey symbols for a hotkey */\nexport function formatHotkeySymbols(hotkey: string, modifier: HotKeyModifier[]): string[] {\n const modifierKeys = modifier.map((mod) => getModifierKeySymbol(mod))\n return [...modifierKeys, hotkey]\n}\n\n// Screen Reader Label Formatting\n// ------------------------------------------------------------\n\n/** Get the hotkey label for a hotkey */\nexport function getKeyLabel(key: string): string {\n return key in HOTKEY_LABELS ? HOTKEY_LABELS[key as keyof typeof HOTKEY_LABELS] : key\n}\n"],"mappings":";;;;AASA,SAAS,UAAU,UAAiD;AAClE,QAAO,aAAa;;;AAOtB,SAAgB,qBAAqB,UAAkC;CACrE,MAAM,SAAS,UAAU,SAAS,GAAG,SAAS;AAC9C,QAAO,SAAS,GAAG,2BAA2B,UAAU,qBAAqB;;;AAI/E,SAAgB,oBAAoB,QAAgB,UAAsC;AAExF,QAAO,CAAC,GADa,SAAS,KAAK,QAAQ,qBAAqB,IAAI,CAAC,EAC5C,OAAO;;;AAOlC,SAAgB,YAAY,KAAqB;AAC/C,QAAO,OAAO,gBAAgB,cAAc,OAAqC"}
1
+ {"version":3,"file":"formatHotkey.js","names":[],"sources":["../../../src/components/ScalarHotkey/formatHotkey.ts"],"sourcesContent":["import { isMacOS } from '@scalar/helpers/general/is-mac-os'\n\nimport { HOTKEY_LABELS, MODIFIER_KEY_SYMBOLS, MODIFIER_KEY_SYMBOLS_MACOS } from './constants'\nimport type { HotKeyModifier } from './types'\n\ntype HotkeySymbolSet = 'mac' | 'non-mac'\n\nconst forcedHotkeySymbolSet = (): HotkeySymbolSet | undefined => {\n const raw = import.meta.env.VITE_SCALAR_HOTKEY_SYMBOL_SET\n if (raw === 'mac' || raw === 'non-mac') {\n return raw\n }\n return undefined\n}\n\nconst useMacHotkeySymbols = (): boolean => {\n const forced = forcedHotkeySymbolSet()\n if (forced === 'mac') {\n return true\n }\n if (forced === 'non-mac') {\n return false\n }\n return isMacOS()\n}\n\n// Type guards\n// ------------------------------------------------------------\n\n/** Typescript helper to check if a modifier is the default modifier */\nfunction isDefault(modifier: HotKeyModifier): modifier is 'default' {\n return modifier === 'default'\n}\n\n// Symbol Formatting\n// ------------------------------------------------------------\n\n/** Get the modifier key symbol for a modifier */\nexport function getModifierKeySymbol(modifier: HotKeyModifier): string {\n const hotkey = isDefault(modifier) ? 'Meta' : modifier\n return useMacHotkeySymbols() ? MODIFIER_KEY_SYMBOLS_MACOS[hotkey] : MODIFIER_KEY_SYMBOLS[hotkey]\n}\n\n/** Format the hotkey symbols for a hotkey */\nexport function formatHotkeySymbols(hotkey: string, modifier: HotKeyModifier[]): string[] {\n const modifierKeys = modifier.map((mod) => getModifierKeySymbol(mod))\n return [...modifierKeys, hotkey]\n}\n\n// Screen Reader Label Formatting\n// ------------------------------------------------------------\n\n/** Get the hotkey label for a hotkey */\nexport function getKeyLabel(key: string): string {\n return key in HOTKEY_LABELS ? HOTKEY_LABELS[key as keyof typeof HOTKEY_LABELS] : key\n}\n"],"mappings":";;;AAOA,IAAM,8BAA2D;CAC/D,MAAM,MAAA,KAAA;AACN,KAAI,QAAQ,SAAS,QAAQ,UAC3B,QAAO;;AAKX,IAAM,4BAAqC;CACzC,MAAM,SAAS,uBAAuB;AACtC,KAAI,WAAW,MACb,QAAO;AAET,KAAI,WAAW,UACb,QAAO;AAET,QAAO,SAAS;;;AAOlB,SAAS,UAAU,UAAiD;AAClE,QAAO,aAAa;;;AAOtB,SAAgB,qBAAqB,UAAkC;CACrE,MAAM,SAAS,UAAU,SAAS,GAAG,SAAS;AAC9C,QAAO,qBAAqB,GAAG,2BAA2B,UAAU,qBAAqB;;;AAI3F,SAAgB,oBAAoB,QAAgB,UAAsC;AAExF,QAAO,CAAC,GADa,SAAS,KAAK,QAAQ,qBAAqB,IAAI,CAAC,EAC5C,OAAO;;;AAOlC,SAAgB,YAAY,KAAqB;AAC/C,QAAO,OAAO,gBAAgB,cAAc,OAAqC"}
@@ -15,6 +15,8 @@ declare const __VLS_export: import("vue").DefineComponent<{
15
15
  team?: ScalarMenuTeamOption | undefined;
16
16
  /** The list of teams to choose from */
17
17
  teams: ScalarMenuTeamOption[];
18
+ /** Whether to disable the "Add team" button */
19
+ allowAddTeam?: boolean;
18
20
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
19
21
  add: () => any;
20
22
  "update:team": (value: ScalarMenuTeamOption | undefined) => any;
@@ -23,6 +25,8 @@ declare const __VLS_export: import("vue").DefineComponent<{
23
25
  team?: ScalarMenuTeamOption | undefined;
24
26
  /** The list of teams to choose from */
25
27
  teams: ScalarMenuTeamOption[];
28
+ /** Whether to disable the "Add team" button */
29
+ allowAddTeam?: boolean;
26
30
  }> & Readonly<{
27
31
  onAdd?: (() => any) | undefined;
28
32
  "onUpdate:team"?: ((value: ScalarMenuTeamOption | undefined) => any) | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarMenuTeamPicker.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarMenu/ScalarMenuTeamPicker.vue"],"names":[],"mappings":"AAsHA,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,IAAI,CAAA;AAI9D;;;;;;;;GAQG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;IAEhB,kCAAkC;WAC3B,oBAAoB,GAAG,SAAS;IACvC,uCAAuC;WAChC,oBAAoB,EAAE;;;;;IAH7B,kCAAkC;WAC3B,oBAAoB,GAAG,SAAS;IACvC,uCAAuC;WAChC,oBAAoB,EAAE;;;;kFAuP3B,CAAC"}
1
+ {"version":3,"file":"ScalarMenuTeamPicker.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarMenu/ScalarMenuTeamPicker.vue"],"names":[],"mappings":"AA6HA,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,IAAI,CAAA;AAI9D;;;;;;;;GAQG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;IAEhB,kCAAkC;WAC3B,oBAAoB,GAAG,SAAS;IACvC,uCAAuC;WAChC,oBAAoB,EAAE;IAC7B,+CAA+C;mBAChC,OAAO;;;;;IALtB,kCAAkC;WAC3B,oBAAoB,GAAG,SAAS;IACvC,uCAAuC;WAChC,oBAAoB,EAAE;IAC7B,+CAA+C;mBAChC,OAAO;;;;kFA+PpB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarMenuTeamPicker.vue.js","names":[],"sources":["../../../src/components/ScalarMenu/ScalarMenuTeamPicker.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Menu Team Picker component\n *\n * A sub-menu within ScalarMenu that lets users switch between teams\n * or create a new team.\n *\n * @example\n * <ScalarMenuTeamPicker :teams=\"teams\" :team=\"currentTeam\" @update:team=\"setTeam\" />\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport {\n ScalarIconCaretRight,\n ScalarIconPlus,\n ScalarIconUserSwitch,\n} from '@scalar/icons'\nimport { DropdownMenu } from 'radix-vue/namespaced'\nimport { computed } from 'vue'\n\nimport {\n ScalarDropdownButton,\n ScalarDropdownMenu,\n ScalarListboxCheckbox,\n} from '../..'\nimport { ScalarMenuLink, type ScalarMenuTeamOption } from './'\nimport ScalarMenuTeamProfile from './ScalarMenuTeamProfile.vue'\n\nconst props = defineProps<{\n /** The currently selected team */\n team?: ScalarMenuTeamOption | undefined\n /** The list of teams to choose from */\n teams: ScalarMenuTeamOption[]\n}>()\n\nconst emit = defineEmits<{\n /** Emitted when the selected team changes */\n (e: 'update:team', value: ScalarMenuTeamOption | undefined): void\n /** Emitted when the user clicks the \"Create new team\" button */\n (e: 'add'): void\n}>()\n\n/** A model that tracks the team id */\nconst model = computed<string | undefined>({\n get: () => props.team?.id,\n set: (v) =>\n emit(\n 'update:team',\n props.teams.find((t) => t.id === v),\n ),\n})\n\ndefineOptions({ inheritAttrs: false })\n</script>\n<template>\n <DropdownMenu.Sub>\n <ScalarMenuLink\n :icon=\"ScalarIconUserSwitch\"\n submenu\n v-bind=\"$attrs\">\n <div>Change team</div>\n <ScalarIconCaretRight\n class=\"ml-auto text-c-2 -mr-px size-3\"\n weight=\"bold\" />\n </ScalarMenuLink>\n <DropdownMenu.Portal>\n <DropdownMenu.SubContent\n :as=\"ScalarDropdownMenu\"\n class=\"max-h-radix-popper z-context-plus\"\n :sideOffset=\"3\">\n <DropdownMenu.RadioGroup\n v-model=\"model\"\n class=\"contents\">\n <DropdownMenu.RadioItem\n v-for=\"t in teams\"\n :key=\"t.id\"\n :as=\"ScalarDropdownButton\"\n class=\"group/item flex items-center\"\n :value=\"t.id\">\n <ScalarMenuTeamProfile\n class=\"-ml-0.75 flex-1 min-w-0\"\n :label=\"t.label\"\n :src=\"t.src\" />\n <ScalarListboxCheckbox\n class=\"ml-auto\"\n :selected=\"t.id === model\" />\n </DropdownMenu.RadioItem>\n </DropdownMenu.RadioGroup>\n <DropdownMenu.Item\n :as=\"ScalarDropdownButton\"\n class=\"flex items-center\"\n @click=\"emit('add')\">\n <ScalarIconPlus\n class=\"bg-b-3 -ml-0.75 rounded p-1 size-5 text-c-3\"\n weight=\"bold\" />\n Create new team\n </DropdownMenu.Item>\n </DropdownMenu.SubContent>\n </DropdownMenu.Portal>\n </DropdownMenu.Sub>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"ScalarMenuTeamPicker.vue.js","names":[],"sources":["../../../src/components/ScalarMenu/ScalarMenuTeamPicker.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Menu Team Picker component\n *\n * A sub-menu within ScalarMenu that lets users switch between teams\n * or create a new team.\n *\n * @example\n * <ScalarMenuTeamPicker :teams=\"teams\" :team=\"currentTeam\" @update:team=\"setTeam\" />\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport {\n ScalarIconCaretRight,\n ScalarIconPlus,\n ScalarIconUserSwitch,\n} from '@scalar/icons'\nimport { DropdownMenu } from 'radix-vue/namespaced'\nimport { computed } from 'vue'\n\nimport {\n ScalarDropdownButton,\n ScalarDropdownMenu,\n ScalarListboxCheckbox,\n} from '../..'\nimport { ScalarMenuLink, type ScalarMenuTeamOption } from './'\nimport ScalarMenuTeamProfile from './ScalarMenuTeamProfile.vue'\n\nconst {\n team,\n teams,\n allowAddTeam = true,\n} = defineProps<{\n /** The currently selected team */\n team?: ScalarMenuTeamOption | undefined\n /** The list of teams to choose from */\n teams: ScalarMenuTeamOption[]\n /** Whether to disable the \"Add team\" button */\n allowAddTeam?: boolean\n}>()\n\nconst emit = defineEmits<{\n /** Emitted when the selected team changes */\n (e: 'update:team', value: ScalarMenuTeamOption | undefined): void\n /** Emitted when the user clicks the \"Create new team\" button */\n (e: 'add'): void\n}>()\n\n/** A model that tracks the team id */\nconst model = computed<string | undefined>({\n get: () => team?.id,\n set: (v) =>\n emit(\n 'update:team',\n teams.find((t) => t.id === v),\n ),\n})\n\ndefineOptions({ inheritAttrs: false })\n</script>\n<template>\n <DropdownMenu.Sub>\n <ScalarMenuLink\n :icon=\"ScalarIconUserSwitch\"\n submenu\n v-bind=\"$attrs\">\n <div>Change team</div>\n <ScalarIconCaretRight\n class=\"ml-auto text-c-2 -mr-px size-3\"\n weight=\"bold\" />\n </ScalarMenuLink>\n <DropdownMenu.Portal>\n <DropdownMenu.SubContent\n :as=\"ScalarDropdownMenu\"\n class=\"max-h-radix-popper z-context-plus\"\n :sideOffset=\"3\">\n <DropdownMenu.RadioGroup\n v-model=\"model\"\n class=\"contents\">\n <DropdownMenu.RadioItem\n v-for=\"t in teams\"\n :key=\"t.id\"\n :as=\"ScalarDropdownButton\"\n class=\"group/item flex items-center\"\n :value=\"t.id\">\n <ScalarMenuTeamProfile\n class=\"-ml-0.75 flex-1 min-w-0\"\n :label=\"t.label\"\n :src=\"t.src\" />\n <ScalarListboxCheckbox\n class=\"ml-auto\"\n :selected=\"t.id === model\" />\n </DropdownMenu.RadioItem>\n </DropdownMenu.RadioGroup>\n <DropdownMenu.Item\n v-if=\"allowAddTeam\"\n :as=\"ScalarDropdownButton\"\n class=\"flex items-center\"\n @click=\"emit('add')\">\n <ScalarIconPlus\n class=\"bg-b-3 -ml-0.75 rounded p-1 size-5 text-c-3\"\n weight=\"bold\" />\n Create new team\n </DropdownMenu.Item>\n </DropdownMenu.SubContent>\n </DropdownMenu.Portal>\n </DropdownMenu.Sub>\n</template>\n"],"mappings":""}
@@ -3,7 +3,7 @@ import ScalarDropdownMenu_default from "../ScalarDropdown/ScalarDropdownMenu.vue
3
3
  import ScalarDropdownButton_default from "../ScalarDropdown/ScalarDropdownButton.vue.js";
4
4
  import ScalarMenuLink_default from "./ScalarMenuLink.vue.js";
5
5
  import ScalarMenuTeamProfile_default from "./ScalarMenuTeamProfile.vue.js";
6
- import { Fragment, computed, createBlock, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeProps, openBlock, renderList, unref, withCtx } from "vue";
6
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, mergeProps, openBlock, renderList, unref, withCtx } from "vue";
7
7
  import { ScalarIconCaretRight, ScalarIconPlus, ScalarIconUserSwitch } from "@scalar/icons";
8
8
  import { DropdownMenu } from "radix-vue/namespaced";
9
9
  var ScalarMenuTeamPicker_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
@@ -11,16 +11,19 @@ var ScalarMenuTeamPicker_vue_vue_type_script_setup_true_lang_default = /* @__PUR
11
11
  __name: "ScalarMenuTeamPicker",
12
12
  props: {
13
13
  team: {},
14
- teams: {}
14
+ teams: {},
15
+ allowAddTeam: {
16
+ type: Boolean,
17
+ default: true
18
+ }
15
19
  },
16
20
  emits: ["update:team", "add"],
17
21
  setup(__props, { emit: __emit }) {
18
- const props = __props;
19
22
  const emit = __emit;
20
23
  /** A model that tracks the team id */
21
24
  const model = computed({
22
- get: () => props.team?.id,
23
- set: (v) => emit("update:team", props.teams.find((t) => t.id === v))
25
+ get: () => __props.team?.id,
26
+ set: (v) => emit("update:team", __props.teams.find((t) => t.id === v))
24
27
  });
25
28
  return (_ctx, _cache) => {
26
29
  return openBlock(), createBlock(unref(DropdownMenu).Sub, null, {
@@ -63,7 +66,8 @@ var ScalarMenuTeamPicker_vue_vue_type_script_setup_true_lang_default = /* @__PUR
63
66
  }, 1032, ["as", "value"]);
64
67
  }), 128))]),
65
68
  _: 1
66
- }, 8, ["modelValue"]), createVNode(unref(DropdownMenu).Item, {
69
+ }, 8, ["modelValue"]), __props.allowAddTeam ? (openBlock(), createBlock(unref(DropdownMenu).Item, {
70
+ key: 0,
67
71
  as: unref(ScalarDropdownButton_default),
68
72
  class: "flex items-center",
69
73
  onClick: _cache[1] || (_cache[1] = ($event) => emit("add"))
@@ -73,7 +77,7 @@ var ScalarMenuTeamPicker_vue_vue_type_script_setup_true_lang_default = /* @__PUR
73
77
  weight: "bold"
74
78
  }), _cache[3] || (_cache[3] = createTextVNode(" Create new team ", -1))]),
75
79
  _: 1
76
- }, 8, ["as"])]),
80
+ }, 8, ["as"])) : createCommentVNode("", true)]),
77
81
  _: 1
78
82
  }, 8, ["as"])]),
79
83
  _: 1
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarMenuTeamPicker.vue.script.js","names":["$attrs"],"sources":["../../../src/components/ScalarMenu/ScalarMenuTeamPicker.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Menu Team Picker component\n *\n * A sub-menu within ScalarMenu that lets users switch between teams\n * or create a new team.\n *\n * @example\n * <ScalarMenuTeamPicker :teams=\"teams\" :team=\"currentTeam\" @update:team=\"setTeam\" />\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport {\n ScalarIconCaretRight,\n ScalarIconPlus,\n ScalarIconUserSwitch,\n} from '@scalar/icons'\nimport { DropdownMenu } from 'radix-vue/namespaced'\nimport { computed } from 'vue'\n\nimport {\n ScalarDropdownButton,\n ScalarDropdownMenu,\n ScalarListboxCheckbox,\n} from '../..'\nimport { ScalarMenuLink, type ScalarMenuTeamOption } from './'\nimport ScalarMenuTeamProfile from './ScalarMenuTeamProfile.vue'\n\nconst props = defineProps<{\n /** The currently selected team */\n team?: ScalarMenuTeamOption | undefined\n /** The list of teams to choose from */\n teams: ScalarMenuTeamOption[]\n}>()\n\nconst emit = defineEmits<{\n /** Emitted when the selected team changes */\n (e: 'update:team', value: ScalarMenuTeamOption | undefined): void\n /** Emitted when the user clicks the \"Create new team\" button */\n (e: 'add'): void\n}>()\n\n/** A model that tracks the team id */\nconst model = computed<string | undefined>({\n get: () => props.team?.id,\n set: (v) =>\n emit(\n 'update:team',\n props.teams.find((t) => t.id === v),\n ),\n})\n\ndefineOptions({ inheritAttrs: false })\n</script>\n<template>\n <DropdownMenu.Sub>\n <ScalarMenuLink\n :icon=\"ScalarIconUserSwitch\"\n submenu\n v-bind=\"$attrs\">\n <div>Change team</div>\n <ScalarIconCaretRight\n class=\"ml-auto text-c-2 -mr-px size-3\"\n weight=\"bold\" />\n </ScalarMenuLink>\n <DropdownMenu.Portal>\n <DropdownMenu.SubContent\n :as=\"ScalarDropdownMenu\"\n class=\"max-h-radix-popper z-context-plus\"\n :sideOffset=\"3\">\n <DropdownMenu.RadioGroup\n v-model=\"model\"\n class=\"contents\">\n <DropdownMenu.RadioItem\n v-for=\"t in teams\"\n :key=\"t.id\"\n :as=\"ScalarDropdownButton\"\n class=\"group/item flex items-center\"\n :value=\"t.id\">\n <ScalarMenuTeamProfile\n class=\"-ml-0.75 flex-1 min-w-0\"\n :label=\"t.label\"\n :src=\"t.src\" />\n <ScalarListboxCheckbox\n class=\"ml-auto\"\n :selected=\"t.id === model\" />\n </DropdownMenu.RadioItem>\n </DropdownMenu.RadioGroup>\n <DropdownMenu.Item\n :as=\"ScalarDropdownButton\"\n class=\"flex items-center\"\n @click=\"emit('add')\">\n <ScalarIconPlus\n class=\"bg-b-3 -ml-0.75 rounded p-1 size-5 text-c-3\"\n weight=\"bold\" />\n Create new team\n </DropdownMenu.Item>\n </DropdownMenu.SubContent>\n </DropdownMenu.Portal>\n </DropdownMenu.Sub>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;EA6BA,MAAM,QAAQ;EAOd,MAAM,OAAO;;EAQb,MAAM,QAAQ,SAA6B;GACzC,WAAW,MAAM,MAAM;GACvB,MAAM,MACJ,KACE,eACA,MAAM,MAAM,MAAM,MAAM,EAAE,OAAO,EAAE,CACpC;GACJ,CAAA;;uBAKC,YA4CmB,MAAA,aAAA,CAAA,KAAA,MAAA;2BAnCA,CARjB,YAQiB,MAAA,uBAAA,EARjB,WAQiB;KAPd,MAAM,MAAA,qBAAoB;KAC3B,SAAA;OACQA,KAAAA,OAAM,EAAA;4BACQ,CAAA,OAAA,OAAA,OAAA,KAAtB,mBAAsB,OAAA,MAAjB,eAAW,GAAA,GAChB,YAEkB,MAAA,qBAAA,EAAA;MADhB,OAAM;MACN,QAAO;;;sBAEX,YAiCsB,MAAA,aAAA,CAAA,QAAA,MAAA;4BADM,CA/B1B,YA+B0B,MAAA,aAAA,CAAA,YAAA;MA9BvB,IAAI,MAAA,2BAAkB;MACvB,OAAM;MACL,YAAY;;6BAkBa,CAjB1B,YAiB0B,MAAA,aAAA,CAAA,YAAA;mBAhBf,MAAA;0EAAK,QAAA;OACd,OAAM;;8BAEc,EAAA,UAAA,KAAA,EADpB,mBAayB,UAAA,MAAA,WAZX,QAAA,QAAL,MAAC;4BADV,YAayB,MAAA,aAAA,CAAA,WAAA;SAXtB,KAAK,EAAE;SACP,IAAI,MAAA,6BAAoB;SACzB,OAAM;SACL,OAAO,EAAE;;gCAIO,CAHjB,YAGiB,+BAAA;UAFf,OAAM;UACL,OAAO,EAAE;UACT,KAAK,EAAE;wCACV,YAE+B,MAAA,8BAAA,EAAA;UAD7B,OAAM;UACL,UAAU,EAAE,OAAO,MAAA;;;;;;6BAG1B,YAQoB,MAAA,aAAA,CAAA,MAAA;OAPjB,IAAI,MAAA,6BAAoB;OACzB,OAAM;OACL,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,MAAA;;8BAGM,CAFlB,YAEkB,MAAA,eAAA,EAAA;QADhB,OAAM;QACN,QAAO;qDAAS,qBAEpB,GAAA,EAAA,CAAA"}
1
+ {"version":3,"file":"ScalarMenuTeamPicker.vue.script.js","names":["$attrs"],"sources":["../../../src/components/ScalarMenu/ScalarMenuTeamPicker.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Menu Team Picker component\n *\n * A sub-menu within ScalarMenu that lets users switch between teams\n * or create a new team.\n *\n * @example\n * <ScalarMenuTeamPicker :teams=\"teams\" :team=\"currentTeam\" @update:team=\"setTeam\" />\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport {\n ScalarIconCaretRight,\n ScalarIconPlus,\n ScalarIconUserSwitch,\n} from '@scalar/icons'\nimport { DropdownMenu } from 'radix-vue/namespaced'\nimport { computed } from 'vue'\n\nimport {\n ScalarDropdownButton,\n ScalarDropdownMenu,\n ScalarListboxCheckbox,\n} from '../..'\nimport { ScalarMenuLink, type ScalarMenuTeamOption } from './'\nimport ScalarMenuTeamProfile from './ScalarMenuTeamProfile.vue'\n\nconst {\n team,\n teams,\n allowAddTeam = true,\n} = defineProps<{\n /** The currently selected team */\n team?: ScalarMenuTeamOption | undefined\n /** The list of teams to choose from */\n teams: ScalarMenuTeamOption[]\n /** Whether to disable the \"Add team\" button */\n allowAddTeam?: boolean\n}>()\n\nconst emit = defineEmits<{\n /** Emitted when the selected team changes */\n (e: 'update:team', value: ScalarMenuTeamOption | undefined): void\n /** Emitted when the user clicks the \"Create new team\" button */\n (e: 'add'): void\n}>()\n\n/** A model that tracks the team id */\nconst model = computed<string | undefined>({\n get: () => team?.id,\n set: (v) =>\n emit(\n 'update:team',\n teams.find((t) => t.id === v),\n ),\n})\n\ndefineOptions({ inheritAttrs: false })\n</script>\n<template>\n <DropdownMenu.Sub>\n <ScalarMenuLink\n :icon=\"ScalarIconUserSwitch\"\n submenu\n v-bind=\"$attrs\">\n <div>Change team</div>\n <ScalarIconCaretRight\n class=\"ml-auto text-c-2 -mr-px size-3\"\n weight=\"bold\" />\n </ScalarMenuLink>\n <DropdownMenu.Portal>\n <DropdownMenu.SubContent\n :as=\"ScalarDropdownMenu\"\n class=\"max-h-radix-popper z-context-plus\"\n :sideOffset=\"3\">\n <DropdownMenu.RadioGroup\n v-model=\"model\"\n class=\"contents\">\n <DropdownMenu.RadioItem\n v-for=\"t in teams\"\n :key=\"t.id\"\n :as=\"ScalarDropdownButton\"\n class=\"group/item flex items-center\"\n :value=\"t.id\">\n <ScalarMenuTeamProfile\n class=\"-ml-0.75 flex-1 min-w-0\"\n :label=\"t.label\"\n :src=\"t.src\" />\n <ScalarListboxCheckbox\n class=\"ml-auto\"\n :selected=\"t.id === model\" />\n </DropdownMenu.RadioItem>\n </DropdownMenu.RadioGroup>\n <DropdownMenu.Item\n v-if=\"allowAddTeam\"\n :as=\"ScalarDropdownButton\"\n class=\"flex items-center\"\n @click=\"emit('add')\">\n <ScalarIconPlus\n class=\"bg-b-3 -ml-0.75 rounded p-1 size-5 text-c-3\"\n weight=\"bold\" />\n Create new team\n </DropdownMenu.Item>\n </DropdownMenu.SubContent>\n </DropdownMenu.Portal>\n </DropdownMenu.Sub>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EA0CA,MAAM,OAAO;;EAQb,MAAM,QAAQ,SAA6B;GACzC,WAAW,QAAA,MAAM;GACjB,MAAM,MACJ,KACE,eACA,QAAA,MAAM,MAAM,MAAM,EAAE,OAAO,EAAE,CAC9B;GACJ,CAAA;;uBAKC,YA6CmB,MAAA,aAAA,CAAA,KAAA,MAAA;2BApCA,CARjB,YAQiB,MAAA,uBAAA,EARjB,WAQiB;KAPd,MAAM,MAAA,qBAAoB;KAC3B,SAAA;OACQA,KAAAA,OAAM,EAAA;4BACQ,CAAA,OAAA,OAAA,OAAA,KAAtB,mBAAsB,OAAA,MAAjB,eAAW,GAAA,GAChB,YAEkB,MAAA,qBAAA,EAAA;MADhB,OAAM;MACN,QAAO;;;sBAEX,YAkCsB,MAAA,aAAA,CAAA,QAAA,MAAA;4BADM,CAhC1B,YAgC0B,MAAA,aAAA,CAAA,YAAA;MA/BvB,IAAI,MAAA,2BAAkB;MACvB,OAAM;MACL,YAAY;;6BAkBa,CAjB1B,YAiB0B,MAAA,aAAA,CAAA,YAAA;mBAhBf,MAAA;0EAAK,QAAA;OACd,OAAM;;8BAEc,EAAA,UAAA,KAAA,EADpB,mBAayB,UAAA,MAAA,WAZX,QAAA,QAAL,MAAC;4BADV,YAayB,MAAA,aAAA,CAAA,WAAA;SAXtB,KAAK,EAAE;SACP,IAAI,MAAA,6BAAoB;SACzB,OAAM;SACL,OAAO,EAAE;;gCAIO,CAHjB,YAGiB,+BAAA;UAFf,OAAM;UACL,OAAO,EAAE;UACT,KAAK,EAAE;wCACV,YAE+B,MAAA,8BAAA,EAAA;UAD7B,OAAM;UACL,UAAU,EAAE,OAAO,MAAA;;;;;;6BAIlB,QAAA,gBAAA,WAAA,EADR,YASoB,MAAA,aAAA,CAAA,MAAA;;OAPjB,IAAI,MAAA,6BAAoB;OACzB,OAAM;OACL,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,MAAA;;8BAGM,CAFlB,YAEkB,MAAA,eAAA,EAAA;QADhB,OAAM;QACN,QAAO;qDAAS,qBAEpB,GAAA,EAAA,CAAA"}
@@ -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;AA4H1D;;GAEG;AACH,wBAAgB,qBAAqB,SAGpC;AA2ED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,oBAAoB,QAqDpD"}
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;AA4H1D;;GAEG;AACH,wBAAgB,qBAAqB,SAGpC;AA2ED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,oBAAoB,QAwEpD"}
@@ -1,5 +1,5 @@
1
1
  import { ELEMENT_CLASS, ELEMENT_ID } from "./constants.js";
2
- import { computed, ref, unref, watch } from "vue";
2
+ import { computed, onScopeDispose, ref, unref, watch } from "vue";
3
3
  import { autoUpdate, flip, shift, useFloating } from "@floating-ui/vue";
4
4
  //#region src/components/ScalarTooltip/useTooltip.ts
5
5
  /**
@@ -160,6 +160,18 @@ function useTooltip(opts) {
160
160
  newRef.setAttribute("aria-describedby", ELEMENT_ID);
161
161
  }
162
162
  }, { immediate: true });
163
+ onScopeDispose(() => {
164
+ clearTimer();
165
+ const target = unref(opts.targetRef);
166
+ if (target) {
167
+ target.removeEventListener("mouseenter", showTooltipAfterDelay);
168
+ target.removeEventListener("mouseleave", hideTooltip);
169
+ target.removeEventListener("focus", showTooltip);
170
+ target.removeEventListener("blur", hideTooltip);
171
+ target.removeAttribute("aria-describedby");
172
+ }
173
+ if (unref(config.value?.targetRef) === unref(opts.targetRef)) config.value = void 0;
174
+ });
163
175
  }
164
176
  //#endregion
165
177
  export { useTooltip };
@@ -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, 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 } = 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// 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 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 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 },\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/** 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/** Check if mouse moved off the target but onto the tooltip */\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 e.relatedTarget !== target\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 // 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"],"mappings":";;;;;;;;;AAeA,IAAM,QAAQ,KAAY;;;;;;AAO1B,IAAM,KAAK,KAAkB;;;;;;AAO7B,IAAM,SAAS,KAA2B;AAO1C,IAAM,EAAE,mBAAmB,YACzB,eAAe,MAAM,OAAO,OAAO,UAAU,CAAC,EAC9C,IACA;CACE,WAAW,eAAe,MAAM,OAAO,OAAO,UAAU,CAAC;CACzD,sBAAsB;CACtB,YAAY,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9C,CACF;AAGD,MAAM,sBAAsB;AAC1B,KAAI,CAAC,GAAG,MACN;AAGF,IAAG,MAAM,MAAM,WAAW,eAAe,MAAM;AAC/C,IAAG,MAAM,MAAM,MAAM,eAAe,MAAM;AAC1C,IAAG,MAAM,MAAM,OAAO,eAAe,MAAM;AAC3C,IAAG,MAAM,MAAM,YAAY,eAAe,MAAM,aAAa;AAC7D,IAAG,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aAAa,oBAAoB,WAAW;;IAGvD,EAAE,WAAW,MAAM,CACpB"}
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 } = 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// 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 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 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 },\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/** 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/** Check if mouse moved off the target but onto the tooltip */\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 e.relatedTarget !== target\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 // 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,KAAY;;;;;;AAO1B,IAAM,KAAK,KAAkB;;;;;;AAO7B,IAAM,SAAS,KAA2B;AAO1C,IAAM,EAAE,mBAAmB,YACzB,eAAe,MAAM,OAAO,OAAO,UAAU,CAAC,EAC9C,IACA;CACE,WAAW,eAAe,MAAM,OAAO,OAAO,UAAU,CAAC;CACzD,sBAAsB;CACtB,YAAY,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9C,CACF;AAGD,MAAM,sBAAsB;AAC1B,KAAI,CAAC,GAAG,MACN;AAGF,IAAG,MAAM,MAAM,WAAW,eAAe,MAAM;AAC/C,IAAG,MAAM,MAAM,MAAM,eAAe,MAAM;AAC1C,IAAG,MAAM,MAAM,OAAO,eAAe,MAAM;AAC3C,IAAG,MAAM,MAAM,YAAY,eAAe,MAAM,aAAa;AAC7D,IAAG,MAAM,MAAM,aAAa,eAAe,MAAM,cAAc;EAC/D;AAGF,MACE,SACC,SAAS;AACR,KAAI,CAAC,GAAG,MACN;AAGF,KAAI,MAAM;EACR,MAAM,gBAAgB,MAAM,MAAM,cAAc,IAAI;AAGpD,KAAG,MAAM,iBAAiB,MAAM,MAAM,QAA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YAAY;AACrD,UAAO,oBAAoB,SAAS,YAAY;AAChD,UAAO,oBAAoB,QAAQ,YAAY;AAC/C,UAAO,gBAAgB,mBAAmB;;AAI5C,MAAI,MAAM,OAAO,OAAO,UAAU,KAAK,MAAM,KAAK,UAAU,CAC1D,QAAO,QAAQ,KAAA;GAEjB"}
package/dist/style.css CHANGED
@@ -2926,6 +2926,10 @@
2926
2926
  }
2927
2927
  }
2928
2928
 
2929
+ .scalar-app .highlighted\:bg-b-2[data-highlighted] {
2930
+ background-color: var(--scalar-background-2);
2931
+ }
2932
+
2929
2933
  @property --tw-translate-x {
2930
2934
  syntax: "*";
2931
2935
  inherits: false;
@@ -3661,7 +3665,8 @@ to {
3661
3665
  transform: translate3d(0, 0, 0);
3662
3666
  }
3663
3667
 
3664
- .dark-mode .scalar-dropdown-item[data-v-6660bbc5]:hover {
3668
+ .dark-mode .scalar-dropdown-item[data-v-f5e0d3d8]:hover,
3669
+ .dark-mode .scalar-dropdown-item[data-highlighted][data-v-f5e0d3d8] {
3665
3670
  filter: brightness(1.1);
3666
3671
  }
3667
3672
 
@@ -267,7 +267,8 @@ to {
267
267
  transform: translate3d(0, 0, 0);
268
268
  }
269
269
 
270
- .dark-mode .scalar-dropdown-item[data-v-6660bbc5]:hover {
270
+ .dark-mode .scalar-dropdown-item[data-v-f5e0d3d8]:hover,
271
+ .dark-mode .scalar-dropdown-item[data-highlighted][data-v-f5e0d3d8] {
271
272
  filter: brightness(1.1);
272
273
  }
273
274
 
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.24.2",
13
+ "version": "0.24.4",
14
14
  "engines": {
15
15
  "node": ">=22"
16
16
  },
@@ -43,10 +43,10 @@
43
43
  "vue": "^3.5.30",
44
44
  "vue-component-type-helpers": "^3.2.6",
45
45
  "@scalar/code-highlight": "0.3.4",
46
- "@scalar/themes": "0.15.3",
46
+ "@scalar/helpers": "0.8.0",
47
47
  "@scalar/icons": "0.7.2",
48
- "@scalar/helpers": "0.6.0",
49
- "@scalar/use-hooks": "0.4.3"
48
+ "@scalar/themes": "0.15.5",
49
+ "@scalar/use-hooks": "0.4.5"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@playwright/test": "1.59.1",