@scalar/components 0.35.5 → 0.36.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/dist/components/ScalarButton/ScalarButton.vue_vue_type_script_setup_true_lang.js +8 -1
  2. package/dist/components/ScalarButton/ScalarButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  3. package/dist/components/ScalarCard/ScalarCard.vue.d.ts.map +1 -1
  4. package/dist/components/ScalarCard/ScalarCard.vue_vue_type_script_setup_true_lang.js.map +1 -1
  5. package/dist/components/ScalarCard/ScalarCardHeader.vue.d.ts.map +1 -1
  6. package/dist/components/ScalarCard/ScalarCardHeader.vue_vue_type_script_setup_true_lang.js +1 -1
  7. package/dist/components/ScalarCard/ScalarCardHeader.vue_vue_type_script_setup_true_lang.js.map +1 -1
  8. package/dist/components/ScalarCodeBlock/ScalarCodeBlock.vue.d.ts +8 -0
  9. package/dist/components/ScalarCodeBlock/ScalarCodeBlock.vue.d.ts.map +1 -1
  10. package/dist/components/ScalarCodeBlock/ScalarCodeBlock.vue_vue_type_script_setup_true_lang.js +5 -1
  11. package/dist/components/ScalarCodeBlock/ScalarCodeBlock.vue_vue_type_script_setup_true_lang.js.map +1 -1
  12. package/dist/components/ScalarCodeBlock/ScalarCodeBlockCopy.vue.d.ts.map +1 -1
  13. package/dist/components/ScalarCodeBlock/ScalarCodeBlockCopy.vue_vue_type_script_setup_true_lang.js +3 -4
  14. package/dist/components/ScalarCodeBlock/ScalarCodeBlockCopy.vue_vue_type_script_setup_true_lang.js.map +1 -1
  15. package/dist/components/ScalarCodeBlock/constants.d.ts +2 -1
  16. package/dist/components/ScalarCodeBlock/constants.d.ts.map +1 -1
  17. package/dist/components/ScalarCodeBlock/constants.js +2 -1
  18. package/dist/components/ScalarCodeBlock/constants.js.map +1 -1
  19. package/dist/components/ScalarColorModeToggle/ScalarColorModeToggleIcon.vue_vue_type_script_setup_true_lang.js +8 -1
  20. package/dist/components/ScalarColorModeToggle/ScalarColorModeToggleIcon.vue_vue_type_script_setup_true_lang.js.map +1 -1
  21. package/dist/components/ScalarCombobox/ScalarCombobox.vue_vue_type_script_setup_true_lang.js +5 -1
  22. package/dist/components/ScalarCombobox/ScalarCombobox.vue_vue_type_script_setup_true_lang.js.map +1 -1
  23. package/dist/components/ScalarCombobox/ScalarComboboxMultiselect.vue_vue_type_script_setup_true_lang.js +5 -1
  24. package/dist/components/ScalarCombobox/ScalarComboboxMultiselect.vue_vue_type_script_setup_true_lang.js.map +1 -1
  25. package/dist/components/ScalarCombobox/ScalarComboboxPopover.vue_vue_type_script_setup_true_lang.js +5 -1
  26. package/dist/components/ScalarCombobox/ScalarComboboxPopover.vue_vue_type_script_setup_true_lang.js.map +1 -1
  27. package/dist/components/ScalarDialog/ScalarDialog.vue.d.ts +50 -0
  28. package/dist/components/ScalarDialog/ScalarDialog.vue.d.ts.map +1 -0
  29. package/dist/components/ScalarDialog/ScalarDialog.vue.js +6 -0
  30. package/dist/components/ScalarDialog/ScalarDialog.vue.js.map +1 -0
  31. package/dist/components/ScalarDialog/ScalarDialog.vue_vue_type_script_setup_true_lang.js +137 -0
  32. package/dist/components/ScalarDialog/ScalarDialog.vue_vue_type_script_setup_true_lang.js.map +1 -0
  33. package/dist/components/ScalarDialog/index.d.ts +4 -0
  34. package/dist/components/ScalarDialog/index.d.ts.map +1 -0
  35. package/dist/components/ScalarDialog/index.js +1 -0
  36. package/dist/components/ScalarDialog/types.d.ts +15 -0
  37. package/dist/components/ScalarDialog/types.d.ts.map +1 -0
  38. package/dist/components/ScalarDialog/useBackdropClick.d.ts +46 -0
  39. package/dist/components/ScalarDialog/useBackdropClick.d.ts.map +1 -0
  40. package/dist/components/ScalarDialog/useBackdropClick.js +60 -0
  41. package/dist/components/ScalarDialog/useBackdropClick.js.map +1 -0
  42. package/dist/components/ScalarDialog/useScrollLock.d.ts +16 -0
  43. package/dist/components/ScalarDialog/useScrollLock.d.ts.map +1 -0
  44. package/dist/components/ScalarDialog/useScrollLock.js +70 -0
  45. package/dist/components/ScalarDialog/useScrollLock.js.map +1 -0
  46. package/dist/components/ScalarDropdown/ScalarDropdown.vue_vue_type_script_setup_true_lang.js +5 -1
  47. package/dist/components/ScalarDropdown/ScalarDropdown.vue_vue_type_script_setup_true_lang.js.map +1 -1
  48. package/dist/components/ScalarDropdown/ScalarDropdownButton.vue_vue_type_script_setup_true_lang.js +8 -1
  49. package/dist/components/ScalarDropdown/ScalarDropdownButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  50. package/dist/components/ScalarDropdown/ScalarDropdownMenu.vue_vue_type_script_setup_true_lang.js +5 -1
  51. package/dist/components/ScalarDropdown/ScalarDropdownMenu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  52. package/dist/components/ScalarFloating/ScalarFloating.vue_vue_type_script_setup_true_lang.js +5 -1
  53. package/dist/components/ScalarFloating/ScalarFloating.vue_vue_type_script_setup_true_lang.js.map +1 -1
  54. package/dist/components/ScalarFloating/types.d.ts +3 -2
  55. package/dist/components/ScalarFloating/types.d.ts.map +1 -1
  56. package/dist/components/ScalarForm/ScalarFormError.vue_vue_type_script_setup_true_lang.js +1 -1
  57. package/dist/components/ScalarForm/ScalarFormField.vue_vue_type_script_setup_true_lang.js +8 -1
  58. package/dist/components/ScalarForm/ScalarFormField.vue_vue_type_script_setup_true_lang.js.map +1 -1
  59. package/dist/components/ScalarForm/ScalarFormInput.vue_vue_type_script_setup_true_lang.js +8 -1
  60. package/dist/components/ScalarForm/ScalarFormInput.vue_vue_type_script_setup_true_lang.js.map +1 -1
  61. package/dist/components/ScalarForm/ScalarFormInputGroup.vue_vue_type_script_setup_true_lang.js +8 -1
  62. package/dist/components/ScalarForm/ScalarFormInputGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
  63. package/dist/components/ScalarHeader/ScalarHeader.vue_vue_type_script_setup_true_lang.js +8 -1
  64. package/dist/components/ScalarHeader/ScalarHeader.vue_vue_type_script_setup_true_lang.js.map +1 -1
  65. package/dist/components/ScalarHeader/ScalarHeaderButton.vue_vue_type_script_setup_true_lang.js +8 -1
  66. package/dist/components/ScalarHeader/ScalarHeaderButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  67. package/dist/components/ScalarListbox/ScalarListbox.vue_vue_type_script_setup_true_lang.js +5 -1
  68. package/dist/components/ScalarListbox/ScalarListbox.vue_vue_type_script_setup_true_lang.js.map +1 -1
  69. package/dist/components/ScalarMenu/ScalarMenuLink.vue_vue_type_script_setup_true_lang.js +8 -1
  70. package/dist/components/ScalarMenu/ScalarMenuLink.vue_vue_type_script_setup_true_lang.js.map +1 -1
  71. package/dist/components/ScalarMenu/ScalarMenuProduct.vue_vue_type_script_setup_true_lang.js +8 -1
  72. package/dist/components/ScalarMenu/ScalarMenuProduct.vue_vue_type_script_setup_true_lang.js.map +1 -1
  73. package/dist/components/ScalarModal/ScalarModal.vue.d.ts +0 -2
  74. package/dist/components/ScalarModal/ScalarModal.vue.d.ts.map +1 -1
  75. package/dist/components/ScalarModal/ScalarModal.vue.js +1 -1
  76. package/dist/components/ScalarModal/ScalarModal.vue_vue_type_script_setup_true_lang.js +53 -34
  77. package/dist/components/ScalarModal/ScalarModal.vue_vue_type_script_setup_true_lang.js.map +1 -1
  78. package/dist/components/ScalarPopover/ScalarPopover.vue_vue_type_script_setup_true_lang.js +5 -1
  79. package/dist/components/ScalarPopover/ScalarPopover.vue_vue_type_script_setup_true_lang.js.map +1 -1
  80. package/dist/components/ScalarSidebar/ScalarSidebarButton.vue_vue_type_script_setup_true_lang.js +8 -1
  81. package/dist/components/ScalarSidebar/ScalarSidebarButton.vue_vue_type_script_setup_true_lang.js.map +1 -1
  82. package/dist/components/ScalarSidebar/ScalarSidebarGroup.vue_vue_type_script_setup_true_lang.js +8 -1
  83. package/dist/components/ScalarSidebar/ScalarSidebarGroup.vue_vue_type_script_setup_true_lang.js.map +1 -1
  84. package/dist/components/ScalarSidebar/ScalarSidebarGroupToggle.vue_vue_type_script_setup_true_lang.js +8 -1
  85. package/dist/components/ScalarSidebar/ScalarSidebarGroupToggle.vue_vue_type_script_setup_true_lang.js.map +1 -1
  86. package/dist/components/ScalarSidebar/ScalarSidebarItem.vue_vue_type_script_setup_true_lang.js +5 -1
  87. package/dist/components/ScalarSidebar/ScalarSidebarItem.vue_vue_type_script_setup_true_lang.js.map +1 -1
  88. package/dist/components/ScalarSidebar/ScalarSidebarItems.vue_vue_type_script_setup_true_lang.js +8 -1
  89. package/dist/components/ScalarSidebar/ScalarSidebarItems.vue_vue_type_script_setup_true_lang.js.map +1 -1
  90. package/dist/components/ScalarSidebar/ScalarSidebarNestedItems.vue_vue_type_script_setup_true_lang.js +5 -1
  91. package/dist/components/ScalarSidebar/ScalarSidebarNestedItems.vue_vue_type_script_setup_true_lang.js.map +1 -1
  92. package/dist/components/ScalarSidebar/ScalarSidebarSection.vue_vue_type_script_setup_true_lang.js +8 -1
  93. package/dist/components/ScalarSidebar/ScalarSidebarSection.vue_vue_type_script_setup_true_lang.js.map +1 -1
  94. package/dist/components/ScalarTeleport/ScalarTeleport.vue.d.ts +2 -1
  95. package/dist/components/ScalarTeleport/ScalarTeleport.vue.d.ts.map +1 -1
  96. package/dist/components/ScalarTeleport/ScalarTeleport.vue_vue_type_script_setup_true_lang.js +47 -4
  97. package/dist/components/ScalarTeleport/ScalarTeleport.vue_vue_type_script_setup_true_lang.js.map +1 -1
  98. package/dist/components/ScalarTooltip/useTooltip.d.ts.map +1 -1
  99. package/dist/components/ScalarTooltip/useTooltip.js +7 -2
  100. package/dist/components/ScalarTooltip/useTooltip.js.map +1 -1
  101. package/dist/components/ScalarVirtualCodeBlock/ScalarVirtualCodeBlock.vue.d.ts +4 -0
  102. package/dist/components/ScalarVirtualCodeBlock/ScalarVirtualCodeBlock.vue.d.ts.map +1 -1
  103. package/dist/components/ScalarVirtualCodeBlock/ScalarVirtualCodeBlock.vue_vue_type_script_setup_true_lang.js +6 -2
  104. package/dist/components/ScalarVirtualCodeBlock/ScalarVirtualCodeBlock.vue_vue_type_script_setup_true_lang.js.map +1 -1
  105. package/dist/index.d.ts +2 -0
  106. package/dist/index.d.ts.map +1 -1
  107. package/dist/index.js +2 -1
  108. package/dist/style.css +87 -38
  109. package/dist/vue-styles.css +20 -19
  110. package/package.json +19 -13
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarSidebarGroup.vue_vue_type_script_setup_true_lang.js","names":["$slots","_useModel","_openBlock","_createBlock","_resolveDynamicComponent","_normalizeProps","_guardReactiveProps","_unref","_withCtx","_createElementVNode","_renderSlot","_createVNode","ScalarSidebarButton","ScalarSidebarIndent","ScalarSidebarGroupToggleSpacer","ScalarSidebarGroupToggle","ScalarSidebarGroupToggleButton","_createTextVNode","_toDisplayString","_createElementBlock","ScalarSidebarLoading"],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarGroup.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Group component\n *\n * A collapsible ScalarSidebarItem that can contain subitems.\n *\n * Classes applied to the component are passed to the inner list element.\n * Other attributes (like click event) are passed to the toggle button.\n *\n * @example\n * <ScalarSidebarGroup>\n * <!-- Group toggle text -->\n * <template #items>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * </template>\n * </ScalarSidebarGroup>\n *\n *\n * By default the component has it's own internal open state, but this can be\n * controlled by passing the `controlled` prop and using binding the :open prop.\n *\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\n\nimport ScalarSidebarButton from './ScalarSidebarButton.vue'\nimport ScalarSidebarGroupToggle from './ScalarSidebarGroupToggle.vue'\nimport ScalarSidebarGroupToggleButton from './ScalarSidebarGroupToggleButton.vue'\nimport ScalarSidebarGroupToggleSpacer from './ScalarSidebarGroupToggleSpacer.vue'\nimport ScalarSidebarIndent from './ScalarSidebarIndent.vue'\nimport ScalarSidebarLoading from './ScalarSidebarLoading.vue'\nimport type { ScalarSidebarGroupProps, ScalarSidebarGroupSlots } from './types'\nimport { useSidebarGroups } from './useSidebarGroups'\n\nconst {\n controlled,\n discrete,\n is = 'li',\n} = defineProps<ScalarSidebarGroupProps>()\n\nconst emit = defineEmits<{\n /** Emitted when the group label is clicked */\n (e: 'click', event: MouseEvent): void\n /**\n * Emitted when _only_ the group toggle button (caret) is clicked\n *\n * Note: This is only emitted if the group is discrete\n */\n (e: 'toggle', event: MouseEvent): void\n}>()\n\nconst open = defineModel<boolean>('open', { default: false })\n\ndefineSlots<ScalarSidebarGroupSlots>()\n\nconst { level } = useSidebarGroups({ increment: true })\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n\n/** Handle the click event for the group toggle */\nconst handleClick = (event: MouseEvent) => {\n // Bubble up the click event\n emit('click', event)\n if (!controlled && !discrete) {\n // Only toggle the open state if the group is uncontrolled and not discrete\n open.value = !open.value\n }\n}\n\n/** Handle the click event for the group toggle */\nconst handleToggle = (event: MouseEvent) => {\n // Bubble up the toggle event\n emit('toggle', event)\n if (!controlled && discrete) {\n // Only toggle the open state if the group is uncontrolled and not discrete\n open.value = !open.value\n }\n}\n</script>\n<template>\n <component\n v-bind=\"cx('group/item flex flex-col gap-px')\"\n :is=\"is\">\n <div class=\"group/group-button relative flex flex-col text-base\">\n <slot\n name=\"before\"\n :open />\n <slot\n :level=\"level\"\n name=\"button\"\n :open>\n <ScalarSidebarButton\n is=\"button\"\n :active\n :aria-expanded=\"discrete ? undefined : open\"\n :disabled\n :icon\n :indent=\"level\"\n :selected\n @click=\"handleClick\">\n <template #indent>\n <ScalarSidebarIndent\n class=\"-my-2 mr-0\"\n :indent=\"level\"\n :selected />\n </template>\n <template\n v-if=\"$slots.icon\"\n #icon>\n <slot\n name=\"icon\"\n :open />\n </template>\n <template #aside>\n <slot\n name=\"aside\"\n :open />\n <ScalarSidebarGroupToggleSpacer v-if=\"discrete\" />\n <slot\n v-else\n name=\"toggle\"\n :open>\n <ScalarSidebarGroupToggle\n class=\"text-sidebar-c-2\"\n :open />\n </slot>\n </template>\n <slot :open />\n </ScalarSidebarButton>\n <ScalarSidebarGroupToggleButton\n v-if=\"discrete\"\n :open\n :selected\n @click=\"handleToggle\">\n <slot\n name=\"toggle\"\n :open>\n <ScalarSidebarGroupToggle :open>\n <template #label>\n {{ open ? 'Close' : 'Open' }} <slot :open=\"open\" />\n </template>\n </ScalarSidebarGroupToggle>\n </slot>\n </ScalarSidebarGroupToggleButton>\n </slot>\n <slot\n name=\"after\"\n :open />\n </div>\n <ul\n v-if=\"open\"\n class=\"group/items flex flex-col gap-px\">\n <ScalarSidebarLoading v-if=\"loading\" />\n <slot\n v-else\n name=\"items\"\n :open />\n </ul>\n </component>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4CA,MAAM,OAAO;EAWb,MAAM,OAAOC,SAAoB,SAAC,MAA0B;EAI5D,MAAM,EAAE,UAAU,iBAAiB,EAAE,WAAW,KAAK,CAAC;EAGtD,MAAM,EAAE,OAAO,UAAU;;EAGzB,MAAM,eAAe,UAAsB;GAEzC,KAAK,SAAS,KAAK;GACnB,IAAI,CAAC,QAAA,cAAc,CAAC,QAAA,UAElB,KAAK,QAAQ,CAAC,KAAK;EAEvB;;EAGA,MAAM,gBAAgB,UAAsB;GAE1C,KAAK,UAAU,KAAK;GACpB,IAAI,CAAC,QAAA,cAAc,QAAA,UAEjB,KAAK,QAAQ,CAAC,KAAK;EAEvB;;GAGE,OAAAC,UAAA,GAAAC,YA8EYC,wBA5EL,QAAA,EAAE,GAAAC,eAAAC,mBADCC,MAAA,EAAA,CAAE,CAAA,iCAAA,CAAA,CAAA,GAAA;IAEV,SAAAC,cAiEM,CAjENC,mBAiEM,OAjEN,YAiEM;KAhEJC,WAEU,KAAA,QAAA,UAAA,EAAP,MAAA,KAAA,MAAI,CAAA;KACPA,WAyDO,KAAA,QAAA,UAAA;MAxDJ,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AP,MAAA,KAAA,MAAI,CAAA;I,IAGD,KAAA,SADRR,UAAA,GAAAiB,mBAQK,MARL,YAQK,CALyB,QAAA,WAA5BjB,UAAA,GAAAC,YAAuCiB,8BAAA,EAAA,KAAA,EAAA,CAAA,KACvCV,WAGU,KAAA,QAAA,SAAA,EAAP,MAAA,KAAA,MAAI,GAAA,KAAA,GAAA,KAAA,GAAA,CAAA,C"}
1
+ {"version":3,"file":"ScalarSidebarGroup.vue_vue_type_script_setup_true_lang.js","names":["$slots","_useModel","_openBlock","_createBlock","_resolveDynamicComponent","_normalizeProps","_guardReactiveProps","_unref","_withCtx","_createElementVNode","_renderSlot","_createVNode","ScalarSidebarButton","ScalarSidebarIndent","ScalarSidebarGroupToggleSpacer","ScalarSidebarGroupToggle","ScalarSidebarGroupToggleButton","_createTextVNode","_toDisplayString","_createElementBlock","ScalarSidebarLoading"],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarGroup.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Group component\n *\n * A collapsible ScalarSidebarItem that can contain subitems.\n *\n * Classes applied to the component are passed to the inner list element.\n * Other attributes (like click event) are passed to the toggle button.\n *\n * @example\n * <ScalarSidebarGroup>\n * <!-- Group toggle text -->\n * <template #items>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * </template>\n * </ScalarSidebarGroup>\n *\n *\n * By default the component has it's own internal open state, but this can be\n * controlled by passing the `controlled` prop and using binding the :open prop.\n *\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\n\nimport ScalarSidebarButton from './ScalarSidebarButton.vue'\nimport ScalarSidebarGroupToggle from './ScalarSidebarGroupToggle.vue'\nimport ScalarSidebarGroupToggleButton from './ScalarSidebarGroupToggleButton.vue'\nimport ScalarSidebarGroupToggleSpacer from './ScalarSidebarGroupToggleSpacer.vue'\nimport ScalarSidebarIndent from './ScalarSidebarIndent.vue'\nimport ScalarSidebarLoading from './ScalarSidebarLoading.vue'\nimport type { ScalarSidebarGroupProps, ScalarSidebarGroupSlots } from './types'\nimport { useSidebarGroups } from './useSidebarGroups'\n\nconst {\n controlled,\n discrete,\n is = 'li',\n} = defineProps<ScalarSidebarGroupProps>()\n\nconst emit = defineEmits<{\n /** Emitted when the group label is clicked */\n (e: 'click', event: MouseEvent): void\n /**\n * Emitted when _only_ the group toggle button (caret) is clicked\n *\n * Note: This is only emitted if the group is discrete\n */\n (e: 'toggle', event: MouseEvent): void\n}>()\n\nconst open = defineModel<boolean>('open', { default: false })\n\ndefineSlots<ScalarSidebarGroupSlots>()\n\nconst { level } = useSidebarGroups({ increment: true })\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n\n/** Handle the click event for the group toggle */\nconst handleClick = (event: MouseEvent) => {\n // Bubble up the click event\n emit('click', event)\n if (!controlled && !discrete) {\n // Only toggle the open state if the group is uncontrolled and not discrete\n open.value = !open.value\n }\n}\n\n/** Handle the click event for the group toggle */\nconst handleToggle = (event: MouseEvent) => {\n // Bubble up the toggle event\n emit('toggle', event)\n if (!controlled && discrete) {\n // Only toggle the open state if the group is uncontrolled and not discrete\n open.value = !open.value\n }\n}\n</script>\n<template>\n <component\n v-bind=\"cx('group/item flex flex-col gap-px')\"\n :is=\"is\">\n <div class=\"group/group-button relative flex flex-col text-base\">\n <slot\n name=\"before\"\n :open />\n <slot\n :level=\"level\"\n name=\"button\"\n :open>\n <ScalarSidebarButton\n is=\"button\"\n :active\n :aria-expanded=\"discrete ? undefined : open\"\n :disabled\n :icon\n :indent=\"level\"\n :selected\n @click=\"handleClick\">\n <template #indent>\n <ScalarSidebarIndent\n class=\"-my-2 mr-0\"\n :indent=\"level\"\n :selected />\n </template>\n <template\n v-if=\"$slots.icon\"\n #icon>\n <slot\n name=\"icon\"\n :open />\n </template>\n <template #aside>\n <slot\n name=\"aside\"\n :open />\n <ScalarSidebarGroupToggleSpacer v-if=\"discrete\" />\n <slot\n v-else\n name=\"toggle\"\n :open>\n <ScalarSidebarGroupToggle\n class=\"text-sidebar-c-2\"\n :open />\n </slot>\n </template>\n <slot :open />\n </ScalarSidebarButton>\n <ScalarSidebarGroupToggleButton\n v-if=\"discrete\"\n :open\n :selected\n @click=\"handleToggle\">\n <slot\n name=\"toggle\"\n :open>\n <ScalarSidebarGroupToggle :open>\n <template #label>\n {{ open ? 'Close' : 'Open' }} <slot :open=\"open\" />\n </template>\n </ScalarSidebarGroupToggle>\n </slot>\n </ScalarSidebarGroupToggleButton>\n </slot>\n <slot\n name=\"after\"\n :open />\n </div>\n <ul\n v-if=\"open\"\n class=\"group/items flex flex-col gap-px\">\n <ScalarSidebarLoading v-if=\"loading\" />\n <slot\n v-else\n name=\"items\"\n :open />\n </ul>\n </component>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4CA,MAAM,OAAO;EAWb,MAAM,OAAOC,SAAoB,SAAC,MAA0B;EAI5D,MAAM,EAAE,UAAU,iBAAiB,EAAE,WAAW,KAAK,CAAC;EAGtD,MAAM,EAAE,OAAO,UAAU;;EAGzB,MAAM,eAAe,UAAsB;GAEzC,KAAK,SAAS,KAAK;GACnB,IAAI,CAAC,QAAA,cAAc,CAAC,QAAA,UAElB,KAAK,QAAQ,CAAC,KAAK;EAEvB;;EAGA,MAAM,gBAAgB,UAAsB;GAE1C,KAAK,UAAU,KAAK;GACpB,IAAI,CAAC,QAAA,cAAc,QAAA,UAEjB,KAAK,QAAQ,CAAC,KAAK;EAEvB;;GAGE,OAAAC,UAAA,GAAAC,YA8EYC,wBA5EL,QAAA,EAAE,GAAAC,eAAAC,mBADCC,MAAA,EAAA,CAAE,CAAA,iCAAA,CAAA,CAAA,GAAA;IAEV,SAAAC,cAiEM,CAjENC,mBAiEM,OAjEN,YAiEM;KAhEJC,WAEU,KAAA,QAAA,UAAA,EA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,MAAM,KAAA,MAAI,CAAA,C;;;;;KAMzDA,WAEU,KAAA,QAAA,SAAA,EAAP,MAAA,KAAA,MAAI,CAAA;I,IAGD,KAAA,SADRR,UAAA,GAAAiB,mBAQK,MARL,YAQK,CALyB,QAAA,WAA5BjB,UAAA,GAAAC,YAAuCiB,8BAAA,EAAA,KAAA,EAAA,CAAA,KACvCV,WAGU,KAAA,QAAA,SAAA,EAAP,MAAA,KAAA,MAAI,GAAA,KAAA,GAAA,KAAA,GAAA,CAAA,C"}
@@ -8,7 +8,14 @@ var ScalarSidebarGroupToggle_vue_vue_type_script_setup_true_lang_default = /*@__
8
8
  inheritAttrs: false,
9
9
  __name: "ScalarSidebarGroupToggle",
10
10
  props: {
11
- is: { default: "div" },
11
+ is: {
12
+ type: [
13
+ Object,
14
+ Function,
15
+ String
16
+ ],
17
+ default: "div"
18
+ },
12
19
  open: {
13
20
  type: Boolean,
14
21
  default: false
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarSidebarGroupToggle.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_resolveDynamicComponent","_mergeProps","_unref","_withCtx","_renderSlot","ScalarIconLegacyAdapter","_createElementVNode","_createTextVNode","_toDisplayString"],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarGroupToggle.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Group toggle component\n *\n * Provides the toggle icon for a ScalarSidebarGroup\n *\n * @example\n * <ScalarSidebarGroupToggle :open=\"...\" />\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { ScalarIconCaretRight } from '@scalar/icons'\nimport type { ScalarIconComponent } from '@scalar/icons/types'\nimport { cva, useBindCx } from '@scalar/use-hooks/useBindCx'\nimport type { Component } from 'vue'\n\nimport { ScalarIconLegacyAdapter, type Icon } from '../ScalarIcon'\n\nconst { is = 'div', open = false } = defineProps<{\n /** Override the element tag */\n is?: Component | string\n /** Whether or not the toggle is open */\n open?: boolean\n /** Overrides the icon */\n icon?: Icon | ScalarIconComponent\n}>()\n\ndefineSlots<{\n /** Override the toggle icon */\n default?(props: { open: boolean }): unknown\n /** Override the screen reader label */\n label?(props: { open: boolean }): unknown\n}>()\n\nconst variants = cva({\n base: 'size-4 flex items-center justify-center transition-transform duration-100',\n variants: { open: { true: 'rotate-90' } },\n defaultVariants: { open: false },\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({ open }))\">\n <slot :open=\"open\">\n <ScalarIconLegacyAdapter\n v-if=\"icon\"\n :icon=\"icon\" />\n <ScalarIconCaretRight\n v-else\n class=\"size-3\"\n weight=\"bold\" />\n </slot>\n <span class=\"sr-only\">\n <slot\n name=\"label\"\n :open=\"open\">\n {{ open ? 'Close' : 'Open' }} Group\n </slot>\n </span>\n </component>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;EAmCA,MAAM,WAAW,IAAI;GACnB,MAAM;GACN,UAAU,EAAE,MAAM,EAAE,MAAM,YAAY,EAAE;GACxC,iBAAiB,EAAE,MAAM,MAAM;EACjC,CAAC;EAED,MAAM,EAAE,OAAO,UAAU;;GAGvB,OAAAA,UAAA,GAAAC,YAoBYC,wBAnBL,QAAA,EAAE,GADTC,WAoBY,EAlBT,MAAM,QAAA,OAAE,WAAA,WAA2B,KAAA,EAC5B,GAAAC,MAAA,EAAA,CAAE,CAACA,MAAA,QAAA,CAAQ,CAAA,EAAA,MAAG,QAAA,KAAI,CAAA,CAAA,CAAA,GAAA;IAC1B,SAAAC,cAQO,CARPC,WAQO,KAAA,QAAA,WAAA,EARA,MAAM,QAAA,KAAI,SAQV,CANG,QAAA,QADRN,UAAA,GAAAC,YAEiBG,MAAAG,+BAAA,GAAA;;KAAd,MAAM,QAAA;I,0BACTP,UAAA,GAAAC,YAGkBG,MAAA,oBAAA,GAAA;;KADhB,OAAM;KACN,QAAO;I,OAEXI,mBAMO,QANP,YAMO,CALLF,WAIO,KAAA,QAAA,SAAA,EAFJ,MAAM,QAAA,KAAI,SAEN,CADFG,gBAAAC,gBAAA,QAAA,OAAI,UAAA,MAAA,IAAsB,WAC/B,CAAA,C"}
1
+ {"version":3,"file":"ScalarSidebarGroupToggle.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_resolveDynamicComponent","_mergeProps","_unref","_withCtx","_renderSlot","ScalarIconLegacyAdapter","_createElementVNode","_createTextVNode","_toDisplayString"],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarGroupToggle.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Group toggle component\n *\n * Provides the toggle icon for a ScalarSidebarGroup\n *\n * @example\n * <ScalarSidebarGroupToggle :open=\"...\" />\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { ScalarIconCaretRight } from '@scalar/icons'\nimport type { ScalarIconComponent } from '@scalar/icons/types'\nimport { cva, useBindCx } from '@scalar/use-hooks/useBindCx'\nimport type { Component } from 'vue'\n\nimport { ScalarIconLegacyAdapter, type Icon } from '../ScalarIcon'\n\nconst { is = 'div', open = false } = defineProps<{\n /** Override the element tag */\n is?: Component | string\n /** Whether or not the toggle is open */\n open?: boolean\n /** Overrides the icon */\n icon?: Icon | ScalarIconComponent\n}>()\n\ndefineSlots<{\n /** Override the toggle icon */\n default?(props: { open: boolean }): unknown\n /** Override the screen reader label */\n label?(props: { open: boolean }): unknown\n}>()\n\nconst variants = cva({\n base: 'size-4 flex items-center justify-center transition-transform duration-100',\n variants: { open: { true: 'rotate-90' } },\n defaultVariants: { open: false },\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({ open }))\">\n <slot :open=\"open\">\n <ScalarIconLegacyAdapter\n v-if=\"icon\"\n :icon=\"icon\" />\n <ScalarIconCaretRight\n v-else\n class=\"size-3\"\n weight=\"bold\" />\n </slot>\n <span class=\"sr-only\">\n <slot\n name=\"label\"\n :open=\"open\">\n {{ open ? 'Close' : 'Open' }} Group\n </slot>\n </span>\n </component>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EAmCA,MAAM,WAAW,IAAI;GACnB,MAAM;GACN,UAAU,EAAE,MAAM,EAAE,MAAM,YAAY,EAAE;GACxC,iBAAiB,EAAE,MAAM,MAAM;EACjC,CAAC;EAED,MAAM,EAAE,OAAO,UAAU;;GAGvB,OAAAA,UAAA,GAAAC,YAoBYC,wBAnBL,QAAA,EAAE,GADTC,WAoBY,EAlBT,MAAM,QAAA,OAAE,WAAA,WAA2B,KAAA,EAC5B,GAAAC,MAAA,EAAA,CAAE,CAACA,MAAA,QAAA,CAAQ,CAAA,EAAA,MAAG,QAAA,KAAI,CAAA,CAAA,CAAA,GAAA;IAC1B,SAAAC,cAQO,CARPC,WAQO,KAAA,QAAA,WAAA,EARA,MAAM,QAAA,KAAI,SAQV,CANG,QAAA,QADRN,UAAA,GAAAC,YAEiBG,MAAAG,+BAAA,GAAA;;KAAd,MAAM,QAAA;I,0BACTP,UAAA,GAAAC,YAGkBG,MAAA,oBAAA,GAAA;;KADhB,OAAM;KACN,QAAO;I,OAEXI,mBAMO,QANP,YAMO,CALLF,WAIO,KAAA,QAAA,SAAA,EAFJ,MAAM,QAAA,KAAI,SAEN,CADFG,gBAAAC,gBAAA,QAAA,OAAI,UAAA,MAAA,IAAsB,WAC/B,CAAA,C"}
@@ -6,7 +6,11 @@ var ScalarSidebarItem_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*
6
6
  inheritAttrs: false,
7
7
  __name: "ScalarSidebarItem",
8
8
  props: {
9
- is: {},
9
+ is: { type: [
10
+ Object,
11
+ Function,
12
+ String
13
+ ] },
10
14
  icon: { type: [Object, Function] },
11
15
  active: { type: Boolean },
12
16
  selected: { type: Boolean },
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarSidebarItem.vue_vue_type_script_setup_true_lang.js","names":["$slots","_openBlock","_createElementBlock","_normalizeProps","_guardReactiveProps","_unref","_renderSlot","_createVNode","ScalarSidebarButton","_mergeProps","_withCtx"],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarItem.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Item component\n *\n * Provides a ScalarSidebarButton wrapped in an `<li>` to\n * meet accessibility requirements and automatically indents\n * the button based on the level of the sidebar group\n *\n * @example\n * <ScalarSidebarItem>\n * <template #icon>\n * <!-- Overrides the icon slot -->\n * </template>\n * <!-- Button text -->\n * <template #aside>\n * <!-- After the button text -->\n * </template>\n * <!-- Content to display before the button but inside the list item -->\n * <template #before>\n * <!-- Before the button -->\n * </template>\n * <!-- Content to display after the button but inside the list item -->\n * <template #after>\n * <!-- After the button -->\n * </template>\n * </ScalarSidebarItem>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\n\nimport ScalarSidebarButton from './ScalarSidebarButton.vue'\nimport type { ScalarSidebarItemProps, ScalarSidebarItemSlots } from './types'\nimport { useSidebarGroups } from './useSidebarGroups'\n\nconst props = defineProps<ScalarSidebarItemProps>()\n\ndefineSlots<ScalarSidebarItemSlots>()\n\nconst { level } = useSidebarGroups()\n\nconst { cx } = useBindCx()\ndefineOptions({ inheritAttrs: false })\n</script>\n<template>\n <li v-bind=\"cx('group/item flex flex-col text-base')\">\n <slot name=\"before\" />\n <slot\n :level=\"level\"\n name=\"button\">\n <ScalarSidebarButton\n v-bind=\"props\"\n :indent=\"indent ?? level\">\n <!-- Pass through all the slots -->\n <template\n v-if=\"$slots.default\"\n #default>\n <slot />\n </template>\n <template\n v-if=\"$slots.icon\"\n #icon>\n <slot name=\"icon\" />\n </template>\n <template\n v-if=\"$slots.aside\"\n #aside>\n <slot name=\"aside\" />\n </template>\n </ScalarSidebarButton>\n </slot>\n <slot name=\"after\" />\n </li>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;EAoCA,MAAM,QAAQ;EAId,MAAM,EAAE,UAAU,iBAAiB;EAEnC,MAAM,EAAE,OAAO,UAAU;;GAIvB,OAAAC,UAAA,GAAAC,mBA2BK,MAAAC,eAAAC,mBA3BOC,MAAA,EAAA,CAAE,CAAA,oCAAA,CAAA,CAAA,GAAA;IACZC,WAAsB,KAAA,QAAA,QAAA;IACtBA,WAuBO,KAAA,QAAA,UAAA,EAtBJ,OAAOD,MAAA,KAAA,EAAK,SAsBR,CApBLE,YAmBsBC,6BAnBtBC,WACU,OAAK,EACZ,QAAQ,QAAA,UAAUJ,MAAA,KAAA,E;KAGXL,KAAAA,OAAO,U;MACZ,MAAA;MACD,IAAAU,cAAQ,CAARJ,WAAQ,KAAA,QAAA,SAAA,C;;;KAGFN,KAAAA,OAAO,O;MACZ,MAAA;MACD,IAAAU,cAAoB,CAApBJ,WAAoB,KAAA,QAAA,MAAA,C;;;KAGdN,KAAAA,OAAO,Q;MACZ,MAAA;MACD,IAAAU,cAAqB,CAArBJ,WAAqB,KAAA,QAAA,OAAA,C;;;;IAI3BA,WAAqB,KAAA,QAAA,OAAA"}
1
+ {"version":3,"file":"ScalarSidebarItem.vue_vue_type_script_setup_true_lang.js","names":["$slots","_openBlock","_createElementBlock","_normalizeProps","_guardReactiveProps","_unref","_renderSlot","_createVNode","ScalarSidebarButton","_mergeProps","_withCtx"],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarItem.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Item component\n *\n * Provides a ScalarSidebarButton wrapped in an `<li>` to\n * meet accessibility requirements and automatically indents\n * the button based on the level of the sidebar group\n *\n * @example\n * <ScalarSidebarItem>\n * <template #icon>\n * <!-- Overrides the icon slot -->\n * </template>\n * <!-- Button text -->\n * <template #aside>\n * <!-- After the button text -->\n * </template>\n * <!-- Content to display before the button but inside the list item -->\n * <template #before>\n * <!-- Before the button -->\n * </template>\n * <!-- Content to display after the button but inside the list item -->\n * <template #after>\n * <!-- After the button -->\n * </template>\n * </ScalarSidebarItem>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\n\nimport ScalarSidebarButton from './ScalarSidebarButton.vue'\nimport type { ScalarSidebarItemProps, ScalarSidebarItemSlots } from './types'\nimport { useSidebarGroups } from './useSidebarGroups'\n\nconst props = defineProps<ScalarSidebarItemProps>()\n\ndefineSlots<ScalarSidebarItemSlots>()\n\nconst { level } = useSidebarGroups()\n\nconst { cx } = useBindCx()\ndefineOptions({ inheritAttrs: false })\n</script>\n<template>\n <li v-bind=\"cx('group/item flex flex-col text-base')\">\n <slot name=\"before\" />\n <slot\n :level=\"level\"\n name=\"button\">\n <ScalarSidebarButton\n v-bind=\"props\"\n :indent=\"indent ?? level\">\n <!-- Pass through all the slots -->\n <template\n v-if=\"$slots.default\"\n #default>\n <slot />\n </template>\n <template\n v-if=\"$slots.icon\"\n #icon>\n <slot name=\"icon\" />\n </template>\n <template\n v-if=\"$slots.aside\"\n #aside>\n <slot name=\"aside\" />\n </template>\n </ScalarSidebarButton>\n </slot>\n <slot name=\"after\" />\n </li>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EAoCA,MAAM,QAAQ;EAId,MAAM,EAAE,UAAU,iBAAiB;EAEnC,MAAM,EAAE,OAAO,UAAU;;GAIvB,OAAAC,UAAA,GAAAC,mBA2BK,MAAAC,eAAAC,mBA3BOC,MAAA,EAAA,CAAE,CAAA,oCAAA,CAAA,CAAA,GAAA;IACZC,WAAsB,KAAA,QAAA,QAAA;IACtBA,WAuBO,KAAA,QAAA,UAAA,EAtBJ,OAAOD,MAAA,KAAA,EAAK,SAsBR,CApBLE,YAmBsBC,6BAnBtBC,WACU,OAAK,EACZ,QAAQ,QAAA,UAAUJ,MAAA,KAAA,E;KAGXL,KAAAA,OAAO,U;MACZ,MAAA;MACD,IAAAU,cAAQ,CAARJ,WAAQ,KAAA,QAAA,SAAA,C;;;KAGFN,KAAAA,OAAO,O;MACZ,MAAA;MACD,IAAAU,cAAoB,CAApBJ,WAAoB,KAAA,QAAA,MAAA,C;;;KAGdN,KAAAA,OAAO,Q;MACZ,MAAA;MACD,IAAAU,cAAqB,CAArBJ,WAAqB,KAAA,QAAA,OAAA,C;;;;IAI3BA,WAAqB,KAAA,QAAA,OAAA"}
@@ -4,7 +4,14 @@ import { createBlock, defineComponent, guardReactiveProps, normalizeProps, openB
4
4
  var ScalarSidebarItems_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
5
5
  inheritAttrs: false,
6
6
  __name: "ScalarSidebarItems",
7
- props: { is: { default: "ul" } },
7
+ props: { is: {
8
+ type: [
9
+ Object,
10
+ Function,
11
+ String
12
+ ],
13
+ default: "ul"
14
+ } },
8
15
  setup(__props) {
9
16
  const { open } = useSidebarNestedItems();
10
17
  const { cx } = useBindCx();
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarSidebarItems.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_resolveDynamicComponent","_normalizeProps","_guardReactiveProps","_unref","_withCtx","_renderSlot"],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarItems.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Items component\n *\n * A base container for ScalarSidebarItem(s), renders as\n * a `<ul>` by default to meet accessibility requirements\n *\n * @example\n * <ScalarSidebarItems>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * </ScalarSidebarItems>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport type { Component } from 'vue'\n\nimport { useSidebarNestedItems } from './useSidebarNestedItems'\n\nconst { is = 'ul' } = defineProps<{\n is?: Component | string\n}>()\n\nconst { open } = useSidebarNestedItems()\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <component\n :is=\"is\"\n v-bind=\"\n cx(\n 'group/items relative flex flex-col p-(--scalar-sidebar-padding) gap-px transition-transform duration-300',\n open ? '-translate-x-full' : 'translate-x-0',\n )\n \">\n <slot />\n </component>\n</template>\n<style>\n@reference \"../../style.css\";\n\n/* Hide the buttons from the keyboard when a nested item is open */\n.group\\/items.-translate-x-full .group\\/button {\n /* Required to prevent the button from being focused */\n display: none;\n /* Required to prevent the button from taking up scroll space */\n max-height: 0;\n\n transition-property: display, max-height;\n transition-behavior: allow-discrete;\n transition-duration: 0s;\n transition-delay: 300ms;\n}\n\n/* Show the buttons within a nested item when it is open */\n.group\\/item.group\\/nested-items-open\n > *\n > .group\\/items.translate-x-0\n .group\\/button {\n max-height: calc(infinity * 1px);\n display: flex;\n}\n</style>\n"],"mappings":";;;;;;;;EA0BA,MAAM,EAAE,SAAS,sBAAsB;EAGvC,MAAM,EAAE,OAAO,UAAU;;GAGvB,OAAAA,UAAA,GAAAC,YASYC,wBARL,QAAA,EAAE,GAAAC,eAAAC,mBACQC,MAAA,EAAA,CAAE,C,4GAA8HA,MAAA,IAAA,IAAI,sBAAA,e;IAMnJ,SAAAC,cAAQ,CAARC,WAAQ,KAAA,QAAA,SAAA,C"}
1
+ {"version":3,"file":"ScalarSidebarItems.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createBlock","_resolveDynamicComponent","_normalizeProps","_guardReactiveProps","_unref","_withCtx","_renderSlot"],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarItems.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Items component\n *\n * A base container for ScalarSidebarItem(s), renders as\n * a `<ul>` by default to meet accessibility requirements\n *\n * @example\n * <ScalarSidebarItems>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * </ScalarSidebarItems>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport type { Component } from 'vue'\n\nimport { useSidebarNestedItems } from './useSidebarNestedItems'\n\nconst { is = 'ul' } = defineProps<{\n is?: Component | string\n}>()\n\nconst { open } = useSidebarNestedItems()\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <component\n :is=\"is\"\n v-bind=\"\n cx(\n 'group/items relative flex flex-col p-(--scalar-sidebar-padding) gap-px transition-transform duration-300',\n open ? '-translate-x-full' : 'translate-x-0',\n )\n \">\n <slot />\n </component>\n</template>\n<style>\n@reference \"../../style.css\";\n\n/* Hide the buttons from the keyboard when a nested item is open */\n.group\\/items.-translate-x-full .group\\/button {\n /* Required to prevent the button from being focused */\n display: none;\n /* Required to prevent the button from taking up scroll space */\n max-height: 0;\n\n transition-property: display, max-height;\n transition-behavior: allow-discrete;\n transition-duration: 0s;\n transition-delay: 300ms;\n}\n\n/* Show the buttons within a nested item when it is open */\n.group\\/item.group\\/nested-items-open\n > *\n > .group\\/items.translate-x-0\n .group\\/button {\n max-height: calc(infinity * 1px);\n display: flex;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;EA0BA,MAAM,EAAE,SAAS,sBAAsB;EAGvC,MAAM,EAAE,OAAO,UAAU;;GAGvB,OAAAA,UAAA,GAAAC,YASYC,wBARL,QAAA,EAAE,GAAAC,eAAAC,mBACQC,MAAA,EAAA,CAAE,C,4GAA8HA,MAAA,IAAA,IAAI,sBAAA,e;IAMnJ,SAAAC,cAAQ,CAARC,WAAQ,KAAA,QAAA,SAAA,C"}
@@ -17,7 +17,11 @@ var ScalarSidebarNestedItems_vue_vue_type_script_setup_true_lang_default = /*@__
17
17
  inheritAttrs: false,
18
18
  __name: "ScalarSidebarNestedItems",
19
19
  props: /*@__PURE__*/ mergeModels({
20
- is: {},
20
+ is: { type: [
21
+ Object,
22
+ Function,
23
+ String
24
+ ] },
21
25
  icon: { type: [Object, Function] },
22
26
  active: { type: Boolean },
23
27
  selected: { type: Boolean },
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarSidebarNestedItems.vue_vue_type_script_setup_true_lang.js","names":["$attrs","$slots","_useModel","_openBlock","_createElementBlock","_normalizeClass","_normalizeStyle","_renderSlot","_createVNode","ScalarSidebarButton","_mergeProps","_unref","_createSlots","_withCtx","_Transition","ScalarSidebarItems","_normalizeProps","_guardReactiveProps","_createElementVNode","_createTextVNode","ScalarSidebarSpacer","_createBlock","ScalarSidebarLoading"],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarNestedItems.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Nested Items component\n *\n * A provides list of items thats presented over the parent list\n * Needs to be nested inside a ScalarSidebarItems component\n *\n * @example\n * <ScalarSidebarNestedItems v-model=\"open\">\n * <!-- Item text -->\n * <template #items>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * </template>\n * </ScalarSidebarNestedItems>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { ScalarIconArrowRight, ScalarIconCaretLeft } from '@scalar/icons'\nimport { nextTick, ref, useTemplateRef } from 'vue'\n\nimport { findScrollContainer } from './findScrollContainer'\nimport ScalarSidebarButton from './ScalarSidebarButton.vue'\nimport ScalarSidebarItems from './ScalarSidebarItems.vue'\nimport ScalarSidebarLoading from './ScalarSidebarLoading.vue'\nimport ScalarSidebarSpacer from './ScalarSidebarSpacer.vue'\nimport type { ScalarSidebarGroupProps } from './types'\nimport { useSidebarGroups } from './useSidebarGroups'\nimport { useSidebarNestedItem } from './useSidebarNestedItems'\n\nconst { controlled } = defineProps<ScalarSidebarGroupProps>()\n\nconst emit = defineEmits<{\n /** Emitted when the nested item button is clicked */\n (e: 'click', event: MouseEvent): void\n /** Emitted when the back button is clicked */\n (e: 'back', event: MouseEvent): void\n}>()\n\nconst open = defineModel<boolean>('open', { default: false })\nuseSidebarNestedItem(() => open.value)\n\ndefineSlots<{\n /** The text content of the button */\n 'default'?: () => unknown\n /** Override the entire button */\n 'button'?: () => unknown\n /** Override the icon */\n 'icon'?: () => unknown\n /** Override the aside slot */\n 'aside'?: () => unknown\n /** Override the back button */\n 'back'?: () => unknown\n /** Override the back button label */\n 'back-label'?: () => unknown\n /** The list of sidebar subitems */\n 'items'?: () => unknown\n}>()\n\nconst { level } = useSidebarGroups({ reset: true })\n\n/** The root element ref */\nconst el = useTemplateRef('el')\n\n/** How far down to offset the nested items by when animating them in */\nconst offset = ref(0)\n\n// Transition hooks\n\nfunction onOpen() {\n // Calculate how far down the nearest scroll container is scrolled\n // We offset the nested items by this amount when animating them\n // in so they appear in line with the parent items list.\n offset.value = findScrollContainer(el.value).scrollTop ?? 0\n\n // Focus the first button in the nested items\n nextTick(() =>\n el.value\n ?.querySelector<HTMLButtonElement>('button:not([aria-expanded=\"true\"])')\n ?.focus({ preventScroll: true }),\n )\n}\nfunction onOpened() {\n /** Reset the scroll position of the scroll container after opening */\n findScrollContainer(el.value).scrollTop = 0\n}\nfunction onClose() {\n nextTick(() => {\n el.value?.querySelector('button')?.focus({ preventScroll: true })\n findScrollContainer(el.value).scrollTop = offset.value\n })\n}\n\ndefineOptions({ inheritAttrs: false })\n\n/** Handle the click event for the nested items button */\nconst handleClick = (event: MouseEvent) => {\n // Bubble up the click event\n emit('click', event)\n if (!controlled) {\n // Only toggle the open state if the group is uncontrolled\n open.value = true\n }\n}\n\n/** Handle the back button click event */\nconst handleBack = (event: MouseEvent) => {\n // Bubble up the back event\n emit('back', event)\n if (!controlled) {\n // Only toggle the open state if the group is uncontrolled\n open.value = false\n }\n}\n</script>\n<template>\n <li\n ref=\"el\"\n class=\"group/item group/nested-items contents\"\n :class=\"{ 'group/nested-items-open': open }\"\n :style=\"{ '--nested-items-offset': `${offset}px` }\">\n <slot name=\"button\">\n <ScalarSidebarButton\n is=\"button\"\n :aria-expanded=\"open\"\n :disabled\n :icon\n :indent=\"level\"\n :selected\n v-bind=\"$attrs\"\n @click=\"handleClick\">\n <template\n v-if=\"$slots.icon\"\n #icon>\n <slot name=\"icon\" />\n </template>\n <slot />\n <template #aside>\n <slot name=\"aside\">\n <ScalarIconArrowRight class=\"text-sidebar-c-2 size-4\" />\n </slot>\n </template>\n </ScalarSidebarButton>\n </slot>\n <!-- Make sure the div is around for the entire transition -->\n <Transition\n :duration=\"300\"\n enterActiveClass=\"top-(--nested-items-offset)!\"\n leaveActiveClass=\"top-(--nested-items-offset)!\"\n @afterEnter=\"onOpened\"\n @enter=\"onOpen\"\n @leave=\"onClose\">\n <div\n v-if=\"open\"\n class=\"absolute inset-0 translate-x-full\">\n <ScalarSidebarItems v-bind=\"$attrs\">\n <div\n class=\"bg-sidebar-b-1 animate-sidebar-border-bottom border-b-sidebar-border sticky top-(--scalar-sidebar-sticky-offset,0) z-1 -mx-(--scalar-sidebar-padding) -mt-(--scalar-sidebar-padding) flex flex-col gap-px px-(--scalar-sidebar-padding) pt-(--scalar-sidebar-padding)\">\n <slot name=\"back\">\n <ScalarSidebarButton\n is=\"button\"\n class=\"text-sidebar-c-1 font-sidebar-active hover:text-sidebar-c-1\"\n @click=\"handleBack\">\n <template #icon>\n <ScalarIconCaretLeft class=\"text-sidebar-c-2 -m-px size-4\" />\n </template>\n <slot name=\"back-label\">Back</slot>\n </ScalarSidebarButton>\n </slot>\n <ScalarSidebarSpacer class=\"h-3\" />\n </div>\n <ScalarSidebarLoading v-if=\"loading\" />\n <slot\n v-else\n name=\"items\" />\n </ScalarSidebarItems>\n </div>\n </Transition>\n </li>\n</template>\n\n<style>\n@reference \"../../style.css\";\n\n.animate-sidebar-border-bottom {\n animation: border-bottom forwards;\n animation-timeline: scroll();\n animation-range-end: 1px;\n}\n\n@keyframes border-bottom {\n from {\n border-bottom-width: 0;\n }\n to {\n border-bottom-width: var(--scalar-border-width);\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;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","_createElementBlock","_normalizeClass","_normalizeStyle","_renderSlot","_createVNode","ScalarSidebarButton","_mergeProps","_unref","_createSlots","_withCtx","_Transition","ScalarSidebarItems","_normalizeProps","_guardReactiveProps","_createElementVNode","_createTextVNode","ScalarSidebarSpacer","_createBlock","ScalarSidebarLoading"],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarNestedItems.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Nested Items component\n *\n * A provides list of items thats presented over the parent list\n * Needs to be nested inside a ScalarSidebarItems component\n *\n * @example\n * <ScalarSidebarNestedItems v-model=\"open\">\n * <!-- Item text -->\n * <template #items>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * </template>\n * </ScalarSidebarNestedItems>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { ScalarIconArrowRight, ScalarIconCaretLeft } from '@scalar/icons'\nimport { nextTick, ref, useTemplateRef } from 'vue'\n\nimport { findScrollContainer } from './findScrollContainer'\nimport ScalarSidebarButton from './ScalarSidebarButton.vue'\nimport ScalarSidebarItems from './ScalarSidebarItems.vue'\nimport ScalarSidebarLoading from './ScalarSidebarLoading.vue'\nimport ScalarSidebarSpacer from './ScalarSidebarSpacer.vue'\nimport type { ScalarSidebarGroupProps } from './types'\nimport { useSidebarGroups } from './useSidebarGroups'\nimport { useSidebarNestedItem } from './useSidebarNestedItems'\n\nconst { controlled } = defineProps<ScalarSidebarGroupProps>()\n\nconst emit = defineEmits<{\n /** Emitted when the nested item button is clicked */\n (e: 'click', event: MouseEvent): void\n /** Emitted when the back button is clicked */\n (e: 'back', event: MouseEvent): void\n}>()\n\nconst open = defineModel<boolean>('open', { default: false })\nuseSidebarNestedItem(() => open.value)\n\ndefineSlots<{\n /** The text content of the button */\n 'default'?: () => unknown\n /** Override the entire button */\n 'button'?: () => unknown\n /** Override the icon */\n 'icon'?: () => unknown\n /** Override the aside slot */\n 'aside'?: () => unknown\n /** Override the back button */\n 'back'?: () => unknown\n /** Override the back button label */\n 'back-label'?: () => unknown\n /** The list of sidebar subitems */\n 'items'?: () => unknown\n}>()\n\nconst { level } = useSidebarGroups({ reset: true })\n\n/** The root element ref */\nconst el = useTemplateRef('el')\n\n/** How far down to offset the nested items by when animating them in */\nconst offset = ref(0)\n\n// Transition hooks\n\nfunction onOpen() {\n // Calculate how far down the nearest scroll container is scrolled\n // We offset the nested items by this amount when animating them\n // in so they appear in line with the parent items list.\n offset.value = findScrollContainer(el.value).scrollTop ?? 0\n\n // Focus the first button in the nested items\n nextTick(() =>\n el.value\n ?.querySelector<HTMLButtonElement>('button:not([aria-expanded=\"true\"])')\n ?.focus({ preventScroll: true }),\n )\n}\nfunction onOpened() {\n /** Reset the scroll position of the scroll container after opening */\n findScrollContainer(el.value).scrollTop = 0\n}\nfunction onClose() {\n nextTick(() => {\n el.value?.querySelector('button')?.focus({ preventScroll: true })\n findScrollContainer(el.value).scrollTop = offset.value\n })\n}\n\ndefineOptions({ inheritAttrs: false })\n\n/** Handle the click event for the nested items button */\nconst handleClick = (event: MouseEvent) => {\n // Bubble up the click event\n emit('click', event)\n if (!controlled) {\n // Only toggle the open state if the group is uncontrolled\n open.value = true\n }\n}\n\n/** Handle the back button click event */\nconst handleBack = (event: MouseEvent) => {\n // Bubble up the back event\n emit('back', event)\n if (!controlled) {\n // Only toggle the open state if the group is uncontrolled\n open.value = false\n }\n}\n</script>\n<template>\n <li\n ref=\"el\"\n class=\"group/item group/nested-items contents\"\n :class=\"{ 'group/nested-items-open': open }\"\n :style=\"{ '--nested-items-offset': `${offset}px` }\">\n <slot name=\"button\">\n <ScalarSidebarButton\n is=\"button\"\n :aria-expanded=\"open\"\n :disabled\n :icon\n :indent=\"level\"\n :selected\n v-bind=\"$attrs\"\n @click=\"handleClick\">\n <template\n v-if=\"$slots.icon\"\n #icon>\n <slot name=\"icon\" />\n </template>\n <slot />\n <template #aside>\n <slot name=\"aside\">\n <ScalarIconArrowRight class=\"text-sidebar-c-2 size-4\" />\n </slot>\n </template>\n </ScalarSidebarButton>\n </slot>\n <!-- Make sure the div is around for the entire transition -->\n <Transition\n :duration=\"300\"\n enterActiveClass=\"top-(--nested-items-offset)!\"\n leaveActiveClass=\"top-(--nested-items-offset)!\"\n @afterEnter=\"onOpened\"\n @enter=\"onOpen\"\n @leave=\"onClose\">\n <div\n v-if=\"open\"\n class=\"absolute inset-0 translate-x-full\">\n <ScalarSidebarItems v-bind=\"$attrs\">\n <div\n class=\"bg-sidebar-b-1 animate-sidebar-border-bottom border-b-sidebar-border sticky top-(--scalar-sidebar-sticky-offset,0) z-1 -mx-(--scalar-sidebar-padding) -mt-(--scalar-sidebar-padding) flex flex-col gap-px px-(--scalar-sidebar-padding) pt-(--scalar-sidebar-padding)\">\n <slot name=\"back\">\n <ScalarSidebarButton\n is=\"button\"\n class=\"text-sidebar-c-1 font-sidebar-active hover:text-sidebar-c-1\"\n @click=\"handleBack\">\n <template #icon>\n <ScalarIconCaretLeft class=\"text-sidebar-c-2 -m-px size-4\" />\n </template>\n <slot name=\"back-label\">Back</slot>\n </ScalarSidebarButton>\n </slot>\n <ScalarSidebarSpacer class=\"h-3\" />\n </div>\n <ScalarSidebarLoading v-if=\"loading\" />\n <slot\n v-else\n name=\"items\" />\n </ScalarSidebarItems>\n </div>\n </Transition>\n </li>\n</template>\n\n<style>\n@reference \"../../style.css\";\n\n.animate-sidebar-border-bottom {\n animation: border-bottom forwards;\n animation-timeline: scroll();\n animation-range-end: 1px;\n}\n\n@keyframes border-bottom {\n from {\n border-bottom-width: 0;\n }\n to {\n border-bottom-width: var(--scalar-border-width);\n }\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCA,MAAM,OAAO;EAOb,MAAM,OAAOE,SAAoB,SAAC,MAA0B;EAC5D,2BAA2B,KAAK,KAAK;EAmBrC,MAAM,EAAE,UAAU,i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YAAwDG,MAAA,oBAAA,GAAA,EAAlC,OAAM,0BAAyB,CAAA,C;IAHzD,SAAAE,cAAQ,CAARN,WAAQ,KAAA,QAAA,SAAA,C;;G,IAJAN,KAAAA,OAAO,O;IACZ,MAAA;IACD,IAAAY,cAAoB,CAApBN,WAAoB,KAAA,QAAA,MAAA,C;;;;;;;;G,MAW1BC,YAgCaM,YAAA;IA/BV,UAAU;IACX,kBAAiB;IACjB,kBAAiB;IAChB,cAAY;IACZ,SAAO;IACP,SAAO;;IACR,SAAAD,cAwBM,CAvBE,KAAA,SADRV,UAAA,GAAAC,mBAwBM,OAxBN,YAwBM,CArBJI,YAoBqBO,4BAAAC,eAAAC,mBApBOjB,KAAAA,MAAM,CAAA,GAAA;KAChC,SAAAa,cAcM,CAdNK,mBAcM,OAdN,YAcM,CAZJX,WAUO,KAAA,QAAA,QAAA,CAAA,SAAA,CATLC,YAQsBC,6BAAA;MAPpB,IAAG;MACH,OAAM;MACL,SAAO;;MACG,MAAII,cACgD,CAA7DL,YAA6DG,MAAA,mBAAA,GAAA,EAAxC,OAAM,gCAA+B,CAAA,C;MAE5D,SAAAE,cAAmC,CAAnCN,WAAmC,KAAA,QAAA,cAAA,CAAA,SAAA,CAAX,OAAA,OAAA,OAAA,KAAAY,gBAAA,QAAI,EAAA,E;;K,MAGhCX,YAAmCY,6BAAA,EAAd,OAAM,MAAK,CAAA,C,IAEN,QAAA,WAA5BjB,UAAA,GAAAkB,YAAuCC,8BAAA,EAAA,KAAA,EAAA,CAAA,KACvCf,WAEiB,KAAA,QAAA,SAAA,CAAA,GAAA,KAAA,GAAA,KAAA,GAAA,CAAA,C"}
@@ -10,7 +10,14 @@ var ScalarSidebarSection_vue_vue_type_script_setup_true_lang_default = /*@__PURE
10
10
  inheritAttrs: false,
11
11
  __name: "ScalarSidebarSection",
12
12
  props: {
13
- is: { default: "li" },
13
+ is: {
14
+ type: [
15
+ Object,
16
+ Function,
17
+ String
18
+ ],
19
+ default: "li"
20
+ },
14
21
  icon: { type: [Object, Function] },
15
22
  active: { type: Boolean },
16
23
  selected: { type: Boolean },
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarSidebarSection.vue_vue_type_script_setup_true_lang.js","names":["$slots","_openBlock","_createBlock","_resolveDynamicComponent","_normalizeProps","_guardReactiveProps","_unref","_withCtx","_createVNode","ScalarSidebarSpacer","ScalarSidebarButton","_renderSlot","_createElementVNode","ScalarSidebarLoading"],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarSection.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Section component\n *\n * A section of the sidebar that can contain subitems\n *\n * @example\n * <ScalarSidebarSection>\n * <!-- Section title -->\n * <template #title>\n * My Section\n * </template>\n * <!-- Section items -->\n * <template #items>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * </template>\n * </ScalarSidebarSection>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\n\nimport ScalarSidebarButton from './ScalarSidebarButton.vue'\nimport ScalarSidebarLoading from './ScalarSidebarLoading.vue'\nimport ScalarSidebarSpacer from './ScalarSidebarSpacer.vue'\nimport type { ScalarSidebarGroupProps, ScalarSidebarItemProps } from './types'\nimport { useSidebarGroups } from './useSidebarGroups'\n\nconst { is = 'li' } = defineProps<\n ScalarSidebarItemProps & Pick<ScalarSidebarGroupProps, 'loading'>\n>()\n\ndefineSlots<{\n /** The text content of the toggle */\n default?(): unknown\n /** The list of sidebar subitems */\n items?(): unknown\n}>()\n\nconst { level } = useSidebarGroups({ increment: false })\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <component\n :is=\"is\"\n v-bind=\"cx('group/item group/sidebar-section contents')\">\n <ScalarSidebarSpacer\n class=\"group/spacer-before h-3\"\n :indent=\"level\" />\n <ScalarSidebarButton\n is=\"div\"\n v-if=\"$slots.default\"\n class=\"py-1.75 text-sm/4 font-bold\"\n disabled\n :icon=\"icon\"\n :indent=\"level\">\n <slot />\n </ScalarSidebarButton>\n <ul class=\"flex flex-col gap-px\">\n <ScalarSidebarLoading v-if=\"loading\" />\n <slot\n v-else\n name=\"items\" />\n </ul>\n <ScalarSidebarSpacer\n class=\"group/spacer-after h-3\"\n :indent=\"level\" />\n </component>\n</template>\n<style>\n@reference \"../../style.css\";\n\n/* Don't add a spacer before the first section */\n.group\\/sidebar-section:first-of-type > .group\\/spacer-before {\n @apply h-0;\n}\n\n/* Don't add a spacer after the last section */\n.group\\/sidebar-section:last-of-type > .group\\/spacer-after {\n @apply h-0;\n}\n\n/* Only one spacer between sections */\n.group\\/sidebar-section:has(+ .group\\/sidebar-section) > .group\\/spacer-after {\n @apply -mb-px h-0;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAyCA,MAAM,EAAE,UAAU,iBAAiB,EAAE,WAAW,MAAM,CAAC;EAGvD,MAAM,EAAE,OAAO,UAAU;;GAGvB,OAAAC,UAAA,GAAAC,YAwBYC,wBAvBL,QAAA,EAAE,GAAAC,eAAAC,mBACCC,MAAA,EAAA,CAAE,CAAA,2CAAA,CAAA,CAAA,GAAA;IACV,SAAAC,cAEoB;KAFpBC,YAEoBC,6BAAA;MADlB,OAAM;MACL,QAAQH,MAAA,KAAA;;KAGHN,KAAAA,OAAO,WAFfC,UAAA,GAAAC,YAQsBQ,6BAAA;;MAPpB,IAAG;MAEH,OAAM;MACN,UAAA;MACC,MAAM,QAAA;MACN,QAAQJ,MAAA,KAAA;;MACT,SAAAC,cAAQ,CAARI,WAAQ,KAAA,QAAA,SAAA,C;;;KAEVC,mBAKK,MALL,YAKK,CAJyB,QAAA,WAA5BX,UAAA,GAAAC,YAAuCW,8BAAA,EAAA,KAAA,EAAA,CAAA,KACvCF,WAEiB,KAAA,QAAA,SAAA,CAAA,GAAA,KAAA,GAAA,KAAA,GAAA,CAAA,C;KAEnBH,YAEoBC,6BAAA;MADlB,OAAM;MACL,QAAQH,MAAA,KAAA"}
1
+ {"version":3,"file":"ScalarSidebarSection.vue_vue_type_script_setup_true_lang.js","names":["$slots","_openBlock","_createBlock","_resolveDynamicComponent","_normalizeProps","_guardReactiveProps","_unref","_withCtx","_createVNode","ScalarSidebarSpacer","ScalarSidebarButton","_renderSlot","_createElementVNode","ScalarSidebarLoading"],"sources":["../../../src/components/ScalarSidebar/ScalarSidebarSection.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Sidebar Section component\n *\n * A section of the sidebar that can contain subitems\n *\n * @example\n * <ScalarSidebarSection>\n * <!-- Section title -->\n * <template #title>\n * My Section\n * </template>\n * <!-- Section items -->\n * <template #items>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * <ScalarSidebarItem>...</ScalarSidebarItem>\n * </template>\n * </ScalarSidebarSection>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\n\nimport ScalarSidebarButton from './ScalarSidebarButton.vue'\nimport ScalarSidebarLoading from './ScalarSidebarLoading.vue'\nimport ScalarSidebarSpacer from './ScalarSidebarSpacer.vue'\nimport type { ScalarSidebarGroupProps, ScalarSidebarItemProps } from './types'\nimport { useSidebarGroups } from './useSidebarGroups'\n\nconst { is = 'li' } = defineProps<\n ScalarSidebarItemProps & Pick<ScalarSidebarGroupProps, 'loading'>\n>()\n\ndefineSlots<{\n /** The text content of the toggle */\n default?(): unknown\n /** The list of sidebar subitems */\n items?(): unknown\n}>()\n\nconst { level } = useSidebarGroups({ increment: false })\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <component\n :is=\"is\"\n v-bind=\"cx('group/item group/sidebar-section contents')\">\n <ScalarSidebarSpacer\n class=\"group/spacer-before h-3\"\n :indent=\"level\" />\n <ScalarSidebarButton\n is=\"div\"\n v-if=\"$slots.default\"\n class=\"py-1.75 text-sm/4 font-bold\"\n disabled\n :icon=\"icon\"\n :indent=\"level\">\n <slot />\n </ScalarSidebarButton>\n <ul class=\"flex flex-col gap-px\">\n <ScalarSidebarLoading v-if=\"loading\" />\n <slot\n v-else\n name=\"items\" />\n </ul>\n <ScalarSidebarSpacer\n class=\"group/spacer-after h-3\"\n :indent=\"level\" />\n </component>\n</template>\n<style>\n@reference \"../../style.css\";\n\n/* Don't add a spacer before the first section */\n.group\\/sidebar-section:first-of-type > .group\\/spacer-before {\n @apply h-0;\n}\n\n/* Don't add a spacer after the last section */\n.group\\/sidebar-section:last-of-type > .group\\/spacer-after {\n @apply h-0;\n}\n\n/* Only one spacer between sections */\n.group\\/sidebar-section:has(+ .group\\/sidebar-section) > .group\\/spacer-after {\n @apply -mb-px h-0;\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyCA,MAAM,EAAE,UAAU,iBAAiB,EAAE,WAAW,MAAM,CAAC;EAGvD,MAAM,EAAE,OAAO,UAAU;;GAGvB,OAAAC,UAAA,GAAAC,YAwBYC,wBAvBL,QAAA,EAAE,GAAAC,eAAAC,mBACCC,MAAA,EAAA,CAAE,CAAA,2CAAA,CAAA,CAAA,GAAA;IACV,SAAAC,cAEoB;KAFpBC,YAEoBC,6BAAA;MADlB,OAAM;MACL,QAAQH,MAAA,KAAA;;KAGHN,KAAAA,OAAO,WAFfC,UAAA,GAAAC,YAQsBQ,6BAAA;;MAPpB,IAAG;MAEH,OAAM;MACN,UAAA;MACC,MAAM,QAAA;MACN,QAAQJ,MAAA,KAAA;;MACT,SAAAC,cAAQ,CAARI,WAAQ,KAAA,QAAA,SAAA,C;;;KAEVC,mBAKK,MALL,YAKK,CAJyB,QAAA,WAA5BX,UAAA,GAAAC,YAAuCW,8BAAA,EAAA,KAAA,EAAA,CAAA,KACvCF,WAEiB,KAAA,QAAA,SAAA,CAAA,GAAA,KAAA,GAAA,KAAA,GAAA,CAAA,C;KAEnBH,YAEoBC,6BAAA;MADlB,OAAM;MACL,QAAQH,MAAA,KAAA"}
@@ -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":"AA2GA,OAAO,EACL,KAAK,aAAa,EAMnB,MAAM,KAAK,CAAA;AAKZ;;;;;;;;;;;;GAYG;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;EAiGhB,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":"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"}
@@ -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, unref } from "vue";
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(__props.to || root);
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: __props.to || unref(root)
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, [
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarTeleport.vue_vue_type_script_setup_true_lang.js","names":["$attrs","_openBlock","_createBlock","_Teleport","_unref","_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 *\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 {\n type TeleportProps,\n getCurrentInstance,\n inject,\n onMounted,\n ref,\n ssrContextKey,\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()\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']): boolean =>\n typeof target === 'string'\n ? document.querySelector(target) !== null\n : !!target\nconst canTeleport = !isHydrating || isTargetOnPage(to || root)\n\nonMounted(() => {\n if (canTeleport) {\n renderInPlace.value = false\n }\n})\n</script>\n<template>\n <Teleport\n :defer=\"!immediate\"\n :disabled=\"disabled || renderInPlace\"\n :to=\"to || root\">\n <div\n class=\"scalar-app\"\n style=\"display: contents\"\n v-bind=\"$attrs\">\n <slot />\n </div>\n </Teleport>\n</template>\n"],"mappings":";;;;;;;;;;;EAoDA,MAAM,OAAO,YAAY;;;;;;;;;;;;;;;;;EAkBzB,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,QAAA,MAAM,IAAI;EAE7D,gBAAgB;GACd,IAAI,aACF,cAAc,QAAQ;EAE1B,CAAC;;GAGC,OAAAC,UAAA,GAAAC,YAUWC,UAAA;IATR,OAAK,CAAG,QAAA;IACR,UAAU,QAAA,YAAY,cAAA;IACtB,IAAI,QAAA,MAAMC,MAAA,IAAA;G,IACXC,mBAKM,OALNC,WAKM;IAJJ,OAAM;IACN,OAAA,EAAA,WAAA,WAAA;GACQN,GAAAA,KAAAA,MAAM,GAAA,CACdO,WAAQ,KAAA,QAAA,SAAA,C"}
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;AAqID;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,oBAAoB,QA8EpD"}
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 the tooltip
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,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,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,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,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C9B,WAAW;EAGX,SAAS,iBAAiB,WAAW,cAAc;GAAE,MAAM;GAAM,SAAS;EAAK,CAAC;EAMhF,kBAAkB,MAAM,KAAK,SAAS,CAAC;EAGvC,OAAO,QAAQ;CACjB;CAEA,YACQ,MAAM,KAAK,SAAS,IACzB,QAAQ,WAAW;EAClB,IAAI,QAAQ;GACV,OAAO,oBAAoB,cAAc,qBAAqB;GAC9D,OAAO,oBAAoB,cAAc,WAAW;GACpD,OAAO,oBAAoB,SAAS,WAAW;GAC/C,OAAO,oBAAoB,QAAQ,WAAW;GAE9C,OAAO,gBAAgB,kBAAkB;EAC3C;EACA,IAAI,QAAQ;GACV,OAAO,iBAAiB,cAAc,qBAAqB;GAC3D,OAAO,iBAAiB,cAAc,WAAW;GACjD,OAAO,iBAAiB,SAAS,WAAW;GAC5C,OAAO,iBAAiB,QAAQ,WAAW;GAE3C,OAAO,aAAa,oBAAoB,UAAU;EACpD;CACF,GACA,EAAE,WAAW,KAAK,CACpB;CAGA,qBAAqB;EACnB,WAAW;EAEX,MAAM,SAAS,MAAM,KAAK,SAAS;EACnC,IAAI,QAAQ;GACV,OAAO,oBAAoB,cAAc,qBAAqB;GAC9D,OAAO,oBAAoB,cAAc,WAAW;GACpD,OAAO,oBAAoB,SAAS,WAAW;GAC/C,OAAO,oBAAoB,QAAQ,WAAW;GAC9C,OAAO,gBAAgB,kBAAkB;EAC3C;EAGA,IAAI,MAAM,OAAO,OAAO,SAAS,MAAM,MAAM,KAAK,SAAS,GACzD,OAAO,QAAQ,KAAA;CAEnB,CAAC;AACH"}
@@ -20,6 +20,8 @@ declare const __VLS_export: import("vue").DefineComponent<{
20
20
  lang?: StandardLanguageKey | string;
21
21
  /** Copy button visibility: 'always', 'hover', or false */
22
22
  copy?: "always" | "hover" | false;
23
+ /** Accessible name for the copy button. Uses the visible “Copy” label when provided. */
24
+ copyLabel?: string;
23
25
  /** Height of each line in pixels */
24
26
  lineHeight?: number;
25
27
  }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
@@ -31,6 +33,8 @@ declare const __VLS_export: import("vue").DefineComponent<{
31
33
  lang?: StandardLanguageKey | string;
32
34
  /** Copy button visibility: 'always', 'hover', or false */
33
35
  copy?: "always" | "hover" | false;
36
+ /** Accessible name for the copy button. Uses the visible “Copy” label when provided. */
37
+ copyLabel?: string;
34
38
  /** Height of each line in pixels */
35
39
  lineHeight?: number;
36
40
  }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarVirtualCodeBlock.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarVirtualCodeBlock/ScalarVirtualCodeBlock.vue"],"names":[],"mappings":"AA8EA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAKnE;;;;;;;;;GASG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;IAEhB,8BAA8B;aACrB,MAAM;IACf,8DAA8D;YACtD,MAAM;IACd,yCAAyC;WAClC,mBAAmB,GAAG,MAAM;IACnC,0DAA0D;WACnD,QAAQ,GAAG,OAAO,GAAG,KAAK;IACjC,oCAAoC;iBACvB,MAAM;;IATnB,8BAA8B;aACrB,MAAM;IACf,8DAA8D;YACtD,MAAM;IACd,yCAAyC;WAClC,mBAAmB,GAAG,MAAM;IACnC,0DAA0D;WACnD,QAAQ,GAAG,OAAO,GAAG,KAAK;IACjC,oCAAoC;iBACvB,MAAM;iGA2GjB,CAAC"}
1
+ {"version":3,"file":"ScalarVirtualCodeBlock.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarVirtualCodeBlock/ScalarVirtualCodeBlock.vue"],"names":[],"mappings":"AAkFA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAKnE;;;;;;;;;GASG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;IAEhB,8BAA8B;aACrB,MAAM;IACf,8DAA8D;YACtD,MAAM;IACd,yCAAyC;WAClC,mBAAmB,GAAG,MAAM;IACnC,0DAA0D;WACnD,QAAQ,GAAG,OAAO,GAAG,KAAK;IACjC,wFAAwF;gBAC5E,MAAM;IAClB,oCAAoC;iBACvB,MAAM;;IAXnB,8BAA8B;aACrB,MAAM;IACf,8DAA8D;YACtD,MAAM;IACd,yCAAyC;WAClC,mBAAmB,GAAG,MAAM;IACnC,0DAA0D;WACnD,QAAQ,GAAG,OAAO,GAAG,KAAK;IACjC,wFAAwF;gBAC5E,MAAM;IAClB,oCAAoC;iBACvB,MAAM;iGA8GjB,CAAC"}
@@ -14,6 +14,7 @@ var ScalarVirtualCodeBlock_vue_vue_type_script_setup_true_lang_default = /*@__PU
14
14
  type: [String, Boolean],
15
15
  default: "hover"
16
16
  },
17
+ copyLabel: {},
17
18
  lineHeight: { default: 20 }
18
19
  },
19
20
  setup(__props) {
@@ -34,15 +35,18 @@ var ScalarVirtualCodeBlock_vue_vue_type_script_setup_true_lang_default = /*@__PU
34
35
  key: 0,
35
36
  class: normalizeClass(["scalar-code-copy absolute top-2.5 right-2.5", [{ "opacity-100": __props.copy === "always" }]]),
36
37
  content: __props.content,
38
+ copyLabel: __props.copyLabel,
37
39
  lang: __props.lang,
38
- showLang: true
40
+ showLang: !__props.copyLabel
39
41
  }, {
40
42
  backdrop: withCtx(() => [createVNode(ScalarCopyBackdrop_default, { class: "scalar-code-copy-backdrop -top-1 -right-1.5" })]),
41
43
  _: 1
42
44
  }, 8, [
43
45
  "class",
44
46
  "content",
45
- "lang"
47
+ "copyLabel",
48
+ "lang",
49
+ "showLang"
46
50
  ])) : createCommentVNode("", true)], 16);
47
51
  };
48
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"ScalarVirtualCodeBlock.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_normalizeProps","_guardReactiveProps","_unref","_createVNode","ScalarVirtualText","_createBlock","ScalarCodeBlockCopy","_normalizeClass","_withCtx","ScalarCopyBackdrop"],"sources":["../../../src/components/ScalarVirtualCodeBlock/ScalarVirtualCodeBlock.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Virtual Code Block component\n *\n * Renders large blocks of code using virtualized scrolling with a copy button.\n * Used as a fallback for ScalarCodeBlock when content exceeds the performance\n * threshold for syntax highlighting.\n *\n * @example\n * <ScalarVirtualCodeBlock content=\"large json string\" lang=\"json\" />\n */\nexport default {}\n</script>\n<script lang=\"ts\" setup>\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\n\nimport ScalarCodeBlockCopy from '../ScalarCodeBlock/ScalarCodeBlockCopy.vue'\nimport type { StandardLanguageKey } from '../ScalarCodeBlock/types'\nimport ScalarCopyBackdrop from '../ScalarCopy/ScalarCopyBackdrop.vue'\nimport ScalarVirtualText from '../ScalarVirtualText/ScalarVirtualText.vue'\n\nconst {\n content,\n label = 'Code sample',\n lang = 'plaintext',\n copy = 'hover',\n lineHeight = 20,\n} = defineProps<{\n /** Text content to display */\n content: string\n /** Accessible name of the keyboard-scrollable code region. */\n label?: string\n /** Language label for the copy button */\n lang?: StandardLanguageKey | string\n /** Copy button visibility: 'always', 'hover', or false */\n copy?: 'always' | 'hover' | false\n /** Height of each line in pixels */\n lineHeight?: number\n}>()\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <div\n v-bind=\"\n cx(\n 'scalar-code-block group/code-block flex flex-col',\n 'relative bg-b-1 min-h-0 min-w-0',\n )\n \">\n <ScalarVirtualText\n :aria-label=\"label\"\n containerClass=\"custom-scroll overflow-auto flex flex-1 max-h-screen\"\n contentClass=\"language-plaintext whitespace-pre font-code text-base p-2\"\n :lineHeight=\"lineHeight\"\n role=\"region\"\n :text=\"content\" />\n <ScalarCodeBlockCopy\n v-if=\"copy\"\n class=\"scalar-code-copy absolute top-2.5 right-2.5\"\n :class=\"[{ 'opacity-100': copy === 'always' }]\"\n :content=\"content\"\n :lang=\"lang\"\n :showLang=\"true\">\n <template #backdrop>\n <ScalarCopyBackdrop\n class=\"scalar-code-copy-backdrop -top-1 -right-1.5\" />\n </template>\n </ScalarCodeBlockCopy>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;EAyCA,MAAM,EAAE,OAAO,UAAU;;GAGvB,OAAAA,UAAA,GAAAC,mBA0BM,OAAAC,eAAAC,mBAzBWC,MAAA,EAAA,CAAE,C,2FAMjBC,YAMoBC,2BAAA;IALjB,cAAY,QAAA;IACb,gBAAe;IACf,cAAa;IACZ,YAAY,QAAA;IACb,MAAK;IACJ,MAAM,QAAA;;;;;G,IAED,QAAA,QADRN,UAAA,GAAAO,YAWsBC,6BAAA;;IATpB,OAAKC,eAAA,CAAC,+CAA6C,CAAA,EAAA,eACzB,QAAA,SAAI,SAAA,CAAA,CAAA,CAAA;IAC7B,SAAS,QAAA;IACT,MAAM,QAAA;IACN,UAAU;;IACA,UAAQC,cAEuC,CADxDL,YACwDM,4BAAA,EAAtD,OAAM,8CAA6C,CAAA,C"}
1
+ {"version":3,"file":"ScalarVirtualCodeBlock.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_normalizeProps","_guardReactiveProps","_unref","_createVNode","ScalarVirtualText","_createBlock","ScalarCodeBlockCopy","_normalizeClass","_withCtx","ScalarCopyBackdrop"],"sources":["../../../src/components/ScalarVirtualCodeBlock/ScalarVirtualCodeBlock.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Virtual Code Block component\n *\n * Renders large blocks of code using virtualized scrolling with a copy button.\n * Used as a fallback for ScalarCodeBlock when content exceeds the performance\n * threshold for syntax highlighting.\n *\n * @example\n * <ScalarVirtualCodeBlock content=\"large json string\" lang=\"json\" />\n */\nexport default {}\n</script>\n<script lang=\"ts\" setup>\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\n\nimport ScalarCodeBlockCopy from '../ScalarCodeBlock/ScalarCodeBlockCopy.vue'\nimport type { StandardLanguageKey } from '../ScalarCodeBlock/types'\nimport ScalarCopyBackdrop from '../ScalarCopy/ScalarCopyBackdrop.vue'\nimport ScalarVirtualText from '../ScalarVirtualText/ScalarVirtualText.vue'\n\nconst {\n content,\n label = 'Code sample',\n lang = 'plaintext',\n copy = 'hover',\n copyLabel,\n lineHeight = 20,\n} = defineProps<{\n /** Text content to display */\n content: string\n /** Accessible name of the keyboard-scrollable code region. */\n label?: string\n /** Language label for the copy button */\n lang?: StandardLanguageKey | string\n /** Copy button visibility: 'always', 'hover', or false */\n copy?: 'always' | 'hover' | false\n /** Accessible name for the copy button. Uses the visible “Copy” label when provided. */\n copyLabel?: string\n /** Height of each line in pixels */\n lineHeight?: number\n}>()\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <div\n v-bind=\"\n cx(\n 'scalar-code-block group/code-block flex flex-col',\n 'relative bg-b-1 min-h-0 min-w-0',\n )\n \">\n <ScalarVirtualText\n :aria-label=\"label\"\n containerClass=\"custom-scroll overflow-auto flex flex-1 max-h-screen\"\n contentClass=\"language-plaintext whitespace-pre font-code text-base p-2\"\n :lineHeight=\"lineHeight\"\n role=\"region\"\n :text=\"content\" />\n <ScalarCodeBlockCopy\n v-if=\"copy\"\n class=\"scalar-code-copy absolute top-2.5 right-2.5\"\n :class=\"[{ 'opacity-100': copy === 'always' }]\"\n :content=\"content\"\n :copyLabel=\"copyLabel\"\n :lang=\"lang\"\n :showLang=\"!copyLabel\">\n <template #backdrop>\n <ScalarCopyBackdrop\n class=\"scalar-code-copy-backdrop -top-1 -right-1.5\" />\n </template>\n </ScalarCodeBlockCopy>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EA4CA,MAAM,EAAE,OAAO,UAAU;;GAGvB,OAAAA,UAAA,GAAAC,mBA2BM,OAAAC,eAAAC,mBA1BWC,MAAA,EAAA,CAAE,C,2FAMjBC,YAMoBC,2BAAA;IALjB,cAAY,QAAA;IACb,gBAAe;IACf,cAAa;IACZ,YAAY,QAAA;IACb,MAAK;IACJ,MAAM,QAAA;;;;;G,IAED,QAAA,QADRN,UAAA,GAAAO,YAYsBC,6BAAA;;IAVpB,OAAKC,eAAA,CAAC,+CAA6C,CAAA,EAAA,eACzB,QAAA,SAAI,SAAA,CAAA,CAAA,CAAA;IAC7B,SAAS,QAAA;IACT,WAAW,QAAA;IACX,MAAM,QAAA;IACN,UAAQ,CAAG,QAAA;;IACD,UAAQC,cAEuC,CADxDL,YACwDM,4BAAA,EAAtD,OAAM,8CAA6C,CAAA,C"}
package/dist/index.d.ts CHANGED
@@ -9,6 +9,8 @@ export { ScalarColorModeToggle, ScalarColorModeToggleButton, ScalarColorModeTogg
9
9
  export type { ScalarComboboxFilterFunction, ScalarComboboxOption, ScalarComboboxOptionGroup, ScalarComboboxOptionsOrGroups, } from './components/ScalarCombobox/index.js';
10
10
  export { ScalarCombobox, ScalarComboboxMultiselect, isScalarComboboxGroups } from './components/ScalarCombobox/index.js';
11
11
  export { ScalarCopy, ScalarCopyBackdrop, ScalarCopyButton } from './components/ScalarCopy/index.js';
12
+ export type { ScalarDialogProps } from './components/ScalarDialog/index.js';
13
+ export { ScalarDialog } from './components/ScalarDialog/index.js';
12
14
  export { ScalarDropdown, ScalarDropdownButton, ScalarDropdownDivider, ScalarDropdownItem, ScalarDropdownMenu, } from './components/ScalarDropdown/index.js';
13
15
  export { ScalarErrorBoundary } from './components/ScalarErrorBoundary/index.js';
14
16
  export { ScalarFileUpload, ScalarFileUploadDropTarget, ScalarFileUploadError, ScalarFileUploadFileList, ScalarFileUploadInput, ScalarFileUploadInputCompact, ScalarFileUploadLoading, } from './components/ScalarFileUpload/index.js';