@scalar/components 0.21.0 → 0.21.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ScalarCodeBlock/ScalarCodeBlock.vue.d.ts +38 -9
- package/dist/components/ScalarCodeBlock/ScalarCodeBlock.vue.d.ts.map +1 -1
- package/dist/components/ScalarCodeBlock/ScalarCodeBlock.vue.js.map +1 -1
- package/dist/components/ScalarCodeBlock/ScalarCodeBlock.vue.script.js +0 -5
- package/dist/components/ScalarCodeBlock/ScalarCodeBlock.vue.script.js.map +1 -1
- package/dist/components/ScalarCodeBlock/ScalarCodeBlockCopy.vue.d.ts +28 -16
- package/dist/components/ScalarCodeBlock/ScalarCodeBlockCopy.vue.d.ts.map +1 -1
- package/dist/components/ScalarCodeBlock/ScalarCodeBlockCopy.vue.js.map +1 -1
- package/dist/components/ScalarCodeBlock/ScalarCodeBlockCopy.vue.script.js.map +1 -1
- package/dist/components/ScalarCombobox/ScalarCombobox.vue.d.ts +13 -2
- package/dist/components/ScalarCombobox/ScalarCombobox.vue.d.ts.map +1 -1
- package/dist/components/ScalarCombobox/ScalarCombobox.vue.js.map +1 -1
- package/dist/components/ScalarCombobox/ScalarCombobox.vue.script.js +0 -1
- package/dist/components/ScalarCombobox/ScalarCombobox.vue.script.js.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxMultiselect.vue.d.ts +12 -2
- package/dist/components/ScalarCombobox/ScalarComboboxMultiselect.vue.d.ts.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxMultiselect.vue.js.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxMultiselect.vue.script.js +0 -1
- package/dist/components/ScalarCombobox/ScalarComboboxMultiselect.vue.script.js.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxOption.vue.d.ts +23 -13
- package/dist/components/ScalarCombobox/ScalarComboboxOption.vue.d.ts.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxOption.vue.js.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxOption.vue.script.js.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxOptionGroup.vue.d.ts +21 -11
- package/dist/components/ScalarCombobox/ScalarComboboxOptionGroup.vue.d.ts.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxOptionGroup.vue.js.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxOptionGroup.vue.script.js.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxOptions.vue.d.ts +11 -2
- package/dist/components/ScalarCombobox/ScalarComboboxOptions.vue.d.ts.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxOptions.vue.js.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxOptions.vue.script.js.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxPopover.vue.d.ts +16 -6
- package/dist/components/ScalarCombobox/ScalarComboboxPopover.vue.d.ts.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxPopover.vue.js.map +1 -1
- package/dist/components/ScalarCombobox/ScalarComboboxPopover.vue.script.js +0 -1
- package/dist/components/ScalarCombobox/ScalarComboboxPopover.vue.script.js.map +1 -1
- package/dist/components/ScalarErrorBoundary/ScalarErrorBoundary.vue.d.ts +14 -6
- package/dist/components/ScalarErrorBoundary/ScalarErrorBoundary.vue.d.ts.map +1 -1
- package/dist/components/ScalarErrorBoundary/ScalarErrorBoundary.vue.js.map +1 -1
- package/dist/components/ScalarErrorBoundary/ScalarErrorBoundary.vue.script.js.map +1 -1
- package/dist/components/ScalarFloating/ScalarFloating.vue.d.ts +19 -9
- package/dist/components/ScalarFloating/ScalarFloating.vue.d.ts.map +1 -1
- package/dist/components/ScalarFloating/ScalarFloating.vue.js.map +1 -1
- package/dist/components/ScalarFloating/ScalarFloating.vue.script.js +0 -1
- package/dist/components/ScalarFloating/ScalarFloating.vue.script.js.map +1 -1
- package/dist/components/ScalarForm/ScalarFormError.vue.d.ts +20 -11
- package/dist/components/ScalarForm/ScalarFormError.vue.d.ts.map +1 -1
- package/dist/components/ScalarForm/ScalarFormError.vue.js.map +1 -1
- package/dist/components/ScalarForm/ScalarFormError.vue.script.js +0 -1
- package/dist/components/ScalarForm/ScalarFormError.vue.script.js.map +1 -1
- package/dist/components/ScalarHotkey/ScalarHotkey.vue.d.ts +15 -5
- package/dist/components/ScalarHotkey/ScalarHotkey.vue.d.ts.map +1 -1
- package/dist/components/ScalarHotkey/ScalarHotkey.vue.js.map +1 -1
- package/dist/components/ScalarHotkey/ScalarHotkey.vue.script.js.map +1 -1
- package/dist/components/ScalarIcon/IconList.vue.d.ts +15 -4
- package/dist/components/ScalarIcon/IconList.vue.d.ts.map +1 -1
- package/dist/components/ScalarListbox/ScalarListbox.vue.d.ts +37 -24
- package/dist/components/ScalarListbox/ScalarListbox.vue.d.ts.map +1 -1
- package/dist/components/ScalarListbox/ScalarListbox.vue.js.map +1 -1
- package/dist/components/ScalarListbox/ScalarListbox.vue.script.js.map +1 -1
- package/dist/components/ScalarListbox/ScalarListboxCheckbox.vue.d.ts +17 -5
- package/dist/components/ScalarListbox/ScalarListboxCheckbox.vue.d.ts.map +1 -1
- package/dist/components/ScalarListbox/ScalarListboxCheckbox.vue.js.map +1 -1
- package/dist/components/ScalarListbox/ScalarListboxCheckbox.vue.script.js +0 -1
- package/dist/components/ScalarListbox/ScalarListboxCheckbox.vue.script.js.map +1 -1
- package/dist/components/ScalarListbox/ScalarListboxItem.vue.d.ts +16 -5
- package/dist/components/ScalarListbox/ScalarListboxItem.vue.d.ts.map +1 -1
- package/dist/components/ScalarListbox/ScalarListboxItem.vue.js.map +1 -1
- package/dist/components/ScalarListbox/ScalarListboxItem.vue.script.js +0 -1
- package/dist/components/ScalarListbox/ScalarListboxItem.vue.script.js.map +1 -1
- package/dist/components/ScalarMarkdown/ScalarMarkdown.vue.d.ts +11 -2
- package/dist/components/ScalarMarkdown/ScalarMarkdown.vue.d.ts.map +1 -1
- package/dist/components/ScalarMarkdown/ScalarMarkdown.vue.js.map +1 -1
- package/dist/components/ScalarMarkdown/ScalarMarkdown.vue.script.js.map +1 -1
- package/dist/components/ScalarMarkdown/ScalarMarkdownSummary.vue.d.ts +26 -17
- package/dist/components/ScalarMarkdown/ScalarMarkdownSummary.vue.d.ts.map +1 -1
- package/dist/components/ScalarMarkdown/ScalarMarkdownSummary.vue.js.map +1 -1
- package/dist/components/ScalarMarkdown/ScalarMarkdownSummary.vue.script.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenu.vue.d.ts +15 -6
- package/dist/components/ScalarMenu/ScalarMenu.vue.d.ts.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenu.vue.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenu.vue.script.js +0 -1
- package/dist/components/ScalarMenu/ScalarMenu.vue.script.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuButton.vue.d.ts +10 -3
- package/dist/components/ScalarMenu/ScalarMenuButton.vue.d.ts.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuButton.vue.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuButton.vue.script.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuLink.vue.d.ts +21 -10
- package/dist/components/ScalarMenu/ScalarMenuLink.vue.d.ts.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuLink.vue.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuLink.vue.script.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuProduct.vue.d.ts +21 -10
- package/dist/components/ScalarMenu/ScalarMenuProduct.vue.d.ts.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuProduct.vue.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuProduct.vue.script.js +0 -1
- package/dist/components/ScalarMenu/ScalarMenuProduct.vue.script.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuProducts.vue.d.ts +22 -11
- package/dist/components/ScalarMenu/ScalarMenuProducts.vue.d.ts.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuProducts.vue.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuProducts.vue.script.js +0 -1
- package/dist/components/ScalarMenu/ScalarMenuProducts.vue.script.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuResources.vue.d.ts +9 -1
- package/dist/components/ScalarMenu/ScalarMenuResources.vue.d.ts.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuResources.vue.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuResources.vue.script.js +0 -1
- package/dist/components/ScalarMenu/ScalarMenuResources.vue.script.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuSection.vue.d.ts +14 -6
- package/dist/components/ScalarMenu/ScalarMenuSection.vue.d.ts.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuSection.vue.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuSection.vue.script.js +0 -1
- package/dist/components/ScalarMenu/ScalarMenuSection.vue.script.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuSupport.vue.d.ts +9 -1
- package/dist/components/ScalarMenu/ScalarMenuSupport.vue.d.ts.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuSupport.vue.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuSupport.vue.script.js +0 -1
- package/dist/components/ScalarMenu/ScalarMenuSupport.vue.script.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuTeamPicker.vue.d.ts +19 -6
- package/dist/components/ScalarMenu/ScalarMenuTeamPicker.vue.d.ts.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuTeamPicker.vue.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuTeamPicker.vue.script.js +0 -1
- package/dist/components/ScalarMenu/ScalarMenuTeamPicker.vue.script.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuTeamProfile.vue.d.ts +16 -5
- package/dist/components/ScalarMenu/ScalarMenuTeamProfile.vue.d.ts.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuTeamProfile.vue.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuTeamProfile.vue.script.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuWorkspacePicker.vue.d.ts +20 -9
- package/dist/components/ScalarMenu/ScalarMenuWorkspacePicker.vue.d.ts.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuWorkspacePicker.vue.js.map +1 -1
- package/dist/components/ScalarMenu/ScalarMenuWorkspacePicker.vue.script.js.map +1 -1
- package/dist/components/ScalarModal/ScalarModal.vue.d.ts +13 -2
- package/dist/components/ScalarModal/ScalarModal.vue.d.ts.map +1 -1
- package/dist/components/ScalarModal/ScalarModal.vue.js +1 -1
- package/dist/components/ScalarModal/ScalarModal.vue.js.map +1 -1
- package/dist/components/ScalarModal/ScalarModal.vue.script.js +13 -0
- package/dist/components/ScalarModal/ScalarModal.vue.script.js.map +1 -1
- package/dist/components/ScalarPopover/ScalarPopover.vue.d.ts +19 -7
- package/dist/components/ScalarPopover/ScalarPopover.vue.d.ts.map +1 -1
- package/dist/components/ScalarPopover/ScalarPopover.vue.js.map +1 -1
- package/dist/components/ScalarPopover/ScalarPopover.vue.script.js +0 -1
- package/dist/components/ScalarPopover/ScalarPopover.vue.script.js.map +1 -1
- package/dist/components/ScalarSearchResults/ScalarSearchResultItem.vue.d.ts +23 -13
- package/dist/components/ScalarSearchResults/ScalarSearchResultItem.vue.d.ts.map +1 -1
- package/dist/components/ScalarSearchResults/ScalarSearchResultItem.vue.js.map +1 -1
- package/dist/components/ScalarSearchResults/ScalarSearchResultItem.vue.script.js.map +1 -1
- package/dist/components/ScalarSearchResults/ScalarSearchResultList.vue.d.ts +21 -11
- package/dist/components/ScalarSearchResults/ScalarSearchResultList.vue.d.ts.map +1 -1
- package/dist/components/ScalarSearchResults/ScalarSearchResultList.vue.js.map +1 -1
- package/dist/components/ScalarSearchResults/ScalarSearchResultList.vue.script.js +0 -1
- package/dist/components/ScalarSearchResults/ScalarSearchResultList.vue.script.js.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarSearchButton.vue.d.ts +16 -8
- package/dist/components/ScalarSidebar/ScalarSidebarSearchButton.vue.d.ts.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarSearchButton.vue.js.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarSearchButton.vue.script.js.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarSearchInput.vue.d.ts +21 -9
- package/dist/components/ScalarSidebar/ScalarSidebarSearchInput.vue.d.ts.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarSearchInput.vue.js.map +1 -1
- package/dist/components/ScalarSidebar/ScalarSidebarSearchInput.vue.script.js.map +1 -1
- package/dist/components/ScalarToggle/ScalarToggle.vue.d.ts +20 -9
- package/dist/components/ScalarToggle/ScalarToggle.vue.d.ts.map +1 -1
- package/dist/components/ScalarToggle/ScalarToggle.vue.js.map +1 -1
- package/dist/components/ScalarToggle/ScalarToggle.vue.script.js.map +1 -1
- package/dist/components/ScalarVirtualText/ScalarVirtualText.vue.d.ts +24 -5
- package/dist/components/ScalarVirtualText/ScalarVirtualText.vue.d.ts.map +1 -1
- package/dist/components/ScalarVirtualText/ScalarVirtualText.vue.js.map +1 -1
- package/dist/components/ScalarVirtualText/ScalarVirtualText.vue.script.js +0 -1
- package/dist/components/ScalarVirtualText/ScalarVirtualText.vue.script.js.map +1 -1
- package/dist/style.css +13 -13
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarComboboxOptions.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarCombobox/ScalarComboboxOptions.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarComboboxOptions.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarCombobox/ScalarComboboxOptions.vue"],"names":[],"mappings":"AAgTA,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,MAAM,EAC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AAC,CAAC;CAAG,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,CAAC,GAAG,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarComboboxOptions.vue.js","names":[],"sources":["../../../src/components/ScalarCombobox/ScalarComboboxOptions.vue"],"sourcesContent":["<!-- prettier-ignore-attribute generic -->\n<script\n setup\n lang=\"ts\"\n generic=\"O extends Option = Option, G extends OptionGroup<O> = OptionGroup<O>\">\nimport { filterByOptionLabel } from '@/components/ScalarCombobox/filter-by-option-label'\nimport { ScalarIconMagnifyingGlass, ScalarIconPlus } from '@scalar/icons'\nimport { computed, onMounted, ref, useId, watch } from 'vue'\n\nimport { ScalarListboxCheckbox } from '../ScalarListbox'\nimport ComboboxOption from './ScalarComboboxOption.vue'\nimport ComboboxOptionGroup from './ScalarComboboxOptionGroup.vue'\nimport {\n type ComboboxEmits,\n type ComboboxSlots,\n type FilterFunction,\n type Option,\n type OptionGroup,\n type OptionsOrGroups,\n isGroups,\n} from './types'\n\nconst {\n options: optionsOrGroups,\n placeholder,\n filterFn = filterByOptionLabel,\n multiselect,\n} = defineProps<{\n /** The options to display in the combobox */\n options: OptionsOrGroups<O, G>\n /** The placeholder text to display in the combobox */\n placeholder?: string\n /**\n * A function to filter the options based on a query,\n * if not provided, the options will be filtered by option label\n *\n * @see {@link FilterFunction} for more information\n */\n filterFn?: FilterFunction<O, G>\n /** Whether the combobox is in multiselect mode, defaults to false */\n multiselect?: boolean\n}>()\n\nconst emit = defineEmits<ComboboxEmits>()\n\nconst model = defineModel<O[]>({ default: [] })\n\nconst slots = defineSlots<Omit<ComboboxSlots<O, G>, 'default'>>()\n\ndefineOptions({ inheritAttrs: false })\n\n/** A unique ID for the combobox */\nconst id = `scalar-combobox-items-${useId()}`\n\n/** A static option entry for the \"Add a new option\" option */\nconst addOption: Option = { id: `${useId()}-add`, label: 'Add a new option' }\n\n/** Generate a unique ID for an option */\nfunction getOptionId(option: Option) {\n return `${id}-${option.id}`\n}\n\n/** A flat list of all options */\nconst options = computed<O[]>(() =>\n isGroups(optionsOrGroups)\n ? optionsOrGroups.flatMap((group) => group.options)\n : optionsOrGroups,\n)\n\n/** An list of all groups */\nconst groups = computed<G[]>(\n () =>\n isGroups(optionsOrGroups)\n ? optionsOrGroups // G extends OptionGroup<O>\n : /*\n We know G is an unextended OptionGroup<O> here because of the\n structure of the component props so we can cast it to G\n */\n [{ label: '', options: optionsOrGroups } as G], // G is OptionGroup<O>\n)\n\nconst query = ref<string>('')\nconst activeRef = ref<Option | undefined>(model.value?.[0] ?? options.value[0])\n\n// Clear the query on open and close\nonMounted(() => {\n // Clear the query\n query.value = ''\n\n // Set the active option to the selected option or the first option\n activeRef.value = model.value?.[0] ?? options.value[0]\n\n // Scroll to the selected option\n const selected = model.value[0]\n if (selected) {\n setTimeout(() => {\n const value = model.value[0]\n if (!value) {\n return\n }\n\n document\n ?.getElementById(getOptionId(value))\n ?.scrollIntoView({ block: 'nearest' })\n }, 10)\n }\n})\n\n// Set the top option as active when searching\nwatch(\n () => query.value,\n () => (activeRef.value = withAdd.value[0]),\n)\n\n/** The filtered list of options */\nconst filtered = computed<O[]>(() =>\n filterFn(query.value, options.value, groups.value),\n)\n\n/** The list of filtered options with the \"Add a new option\" option */\nconst withAdd = computed<Option[]>(() =>\n slots.add ? [...filtered.value, addOption] : filtered.value,\n)\n\nfunction toggleSelected(option: Option | undefined) {\n if (!option) {\n return\n }\n\n if (option.id === addOption.id) {\n addNew()\n return\n }\n\n if (multiselect) {\n // Remove from selection list\n if (model.value.some((o) => o.id === option.id)) {\n model.value = model.value.filter((o) => o.id !== option.id)\n }\n // Add to selection list\n else {\n model.value = [\n ...model.value,\n options.value.find((o) => o.id === option.id)!,\n ]\n }\n } else {\n // Set selection for single select mode\n model.value = [options.value.find((o) => o.id === option.id)!]\n }\n}\n\nfunction moveActive(dir: 1 | -1) {\n const list = withAdd.value\n\n // Find active index\n const activeIdx = list.findIndex(\n (option) => option.id === activeRef.value?.id,\n )\n\n // Calculate next index and exit if it's out of bounds\n const nextIdx = activeIdx + dir\n\n if (nextIdx < 0 || nextIdx > list.length - 1) {\n return\n }\n\n activeRef.value = list[nextIdx]! // We know it's in bounds from the check above\n\n if (!activeRef.value) {\n return\n }\n\n // Scroll to the active option\n document?.getElementById(getOptionId(activeRef.value))?.scrollIntoView({\n behavior: 'smooth',\n block: 'nearest',\n })\n}\n\nfunction addNew() {\n emit('add')\n query.value = ''\n}\n\n// Manual autofocus for the input\nconst input = ref<HTMLInputElement | null>(null)\n\n// This must be a setTimeout to ensure there is no scroll jump. nextTick does not work here.\nonMounted(() => setTimeout(() => input.value?.focus(), 0))\n</script>\n<template>\n <div class=\"relative flex\">\n <ScalarIconMagnifyingGlass\n class=\"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-c-3 size-4\" />\n <input\n ref=\"input\"\n v-model=\"query\"\n :aria-activedescendant=\"activeRef ? getOptionId(activeRef) : undefined\"\n aria-autocomplete=\"list\"\n :aria-controls=\"id\"\n class=\"min-w-0 flex-1 rounded border-0 py-2.5 pl-8 pr-3 leading-none text-c-1 -outline-offset-1\"\n data-1p-ignore\n :placeholder\n role=\"combobox\"\n tabindex=\"0\"\n type=\"text\"\n @keydown.down.prevent=\"moveActive(1)\"\n @keydown.enter.prevent=\"activeRef && toggleSelected(activeRef)\"\n @keydown.up.prevent=\"moveActive(-1)\" />\n </div>\n <ul\n v-show=\"filtered.length || slots.add\"\n :id=\"id\"\n :aria-multiselectable=\"multiselect\"\n class=\"border-t p-0.75 custom-scroll overscroll-contain flex-1 min-h-0\"\n role=\"listbox\"\n tabindex=\"-1\">\n <ComboboxOptionGroup\n v-for=\"(group, i) in groups\"\n :id=\"`${id}-group-${i}`\"\n :key=\"i\"\n :hidden=\"\n // Only show the group label if there are some results\n !group.options.some((o) => filtered.some((f) => f.id === o.id)) ||\n // And it has a label\n !group.label\n \">\n <template #label>\n <slot\n v-if=\"$slots.group\"\n :group\n name=\"group\" />\n <template v-else>\n {{ group.label }}\n </template>\n </template>\n <template\n v-for=\"option in filtered\"\n :key=\"option.id\">\n <ComboboxOption\n v-if=\"group.options.some((o) => o.id === option.id)\"\n :id=\"getOptionId(option)\"\n v-slot=\"{ active, selected }\"\n :active=\"activeRef?.id === option.id\"\n :selected=\"model.some((o) => o.id === option.id)\"\n @click=\"toggleSelected(option)\"\n @mousedown.prevent\n @mouseenter=\"activeRef = option\">\n <slot\n v-if=\"$slots.option\"\n :active\n name=\"option\"\n :option\n :selected />\n <template v-else>\n <ScalarListboxCheckbox\n :multiselect\n :selected=\"model.some((o) => o.id === option.id)\" />\n <span class=\"inline-block min-w-0 flex-1 truncate text-c-1\">\n {{ option.label }}\n </span>\n </template>\n </ComboboxOption>\n </template>\n </ComboboxOptionGroup>\n <ComboboxOption\n v-if=\"slots.add\"\n :id=\"getOptionId(addOption)\"\n v-slot=\"{ active }\"\n :active=\"activeRef?.id === addOption.id\"\n @click=\"addNew\"\n @mousedown.prevent\n @mouseenter=\"activeRef = addOption\">\n <ScalarIconPlus class=\"size-4 p-px\" />\n <slot\n :active\n name=\"add\" />\n </ComboboxOption>\n </ul>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ScalarComboboxOptions.vue.js","names":[],"sources":["../../../src/components/ScalarCombobox/ScalarComboboxOptions.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Combobox Options component\n *\n * Renders the searchable option list for a combobox, including\n * filtering, keyboard navigation, and an optional \"add new\" action.\n *\n * @example\n * <ScalarComboboxOptions v-model=\"selected\" :options=\"options\" />\n */\nexport default {}\n</script>\n\n<!-- prettier-ignore-attribute generic -->\n<script\n setup\n lang=\"ts\"\n generic=\"O extends Option = Option, G extends OptionGroup<O> = OptionGroup<O>\">\nimport { filterByOptionLabel } from '@/components/ScalarCombobox/filter-by-option-label'\nimport { ScalarIconMagnifyingGlass, ScalarIconPlus } from '@scalar/icons'\nimport { computed, onMounted, ref, useId, watch } from 'vue'\n\nimport { ScalarListboxCheckbox } from '../ScalarListbox'\nimport ComboboxOption from './ScalarComboboxOption.vue'\nimport ComboboxOptionGroup from './ScalarComboboxOptionGroup.vue'\nimport {\n type ComboboxEmits,\n type ComboboxSlots,\n type FilterFunction,\n type Option,\n type OptionGroup,\n type OptionsOrGroups,\n isGroups,\n} from './types'\n\nconst {\n options: optionsOrGroups,\n placeholder,\n filterFn = filterByOptionLabel,\n multiselect,\n} = defineProps<{\n /** The options to display in the combobox */\n options: OptionsOrGroups<O, G>\n /** The placeholder text to display in the combobox */\n placeholder?: string\n /**\n * A function to filter the options based on a query,\n * if not provided, the options will be filtered by option label\n *\n * @see {@link FilterFunction} for more information\n */\n filterFn?: FilterFunction<O, G>\n /** Whether the combobox is in multiselect mode, defaults to false */\n multiselect?: boolean\n}>()\n\nconst emit = defineEmits<ComboboxEmits>()\n\nconst model = defineModel<O[]>({ default: [] })\n\nconst slots = defineSlots<Omit<ComboboxSlots<O, G>, 'default'>>()\n\ndefineOptions({ inheritAttrs: false })\n\n/** A unique ID for the combobox */\nconst id = `scalar-combobox-items-${useId()}`\n\n/** A static option entry for the \"Add a new option\" option */\nconst addOption: Option = { id: `${useId()}-add`, label: 'Add a new option' }\n\n/** Generate a unique ID for an option */\nfunction getOptionId(option: Option) {\n return `${id}-${option.id}`\n}\n\n/** A flat list of all options */\nconst options = computed<O[]>(() =>\n isGroups(optionsOrGroups)\n ? optionsOrGroups.flatMap((group) => group.options)\n : optionsOrGroups,\n)\n\n/** An list of all groups */\nconst groups = computed<G[]>(\n () =>\n isGroups(optionsOrGroups)\n ? optionsOrGroups // G extends OptionGroup<O>\n : /*\n We know G is an unextended OptionGroup<O> here because of the\n structure of the component props so we can cast it to G\n */\n [{ label: '', options: optionsOrGroups } as G], // G is OptionGroup<O>\n)\n\nconst query = ref<string>('')\nconst activeRef = ref<Option | undefined>(model.value?.[0] ?? options.value[0])\n\n// Clear the query on open and close\nonMounted(() => {\n // Clear the query\n query.value = ''\n\n // Set the active option to the selected option or the first option\n activeRef.value = model.value?.[0] ?? options.value[0]\n\n // Scroll to the selected option\n const selected = model.value[0]\n if (selected) {\n setTimeout(() => {\n const value = model.value[0]\n if (!value) {\n return\n }\n\n document\n ?.getElementById(getOptionId(value))\n ?.scrollIntoView({ block: 'nearest' })\n }, 10)\n }\n})\n\n// Set the top option as active when searching\nwatch(\n () => query.value,\n () => (activeRef.value = withAdd.value[0]),\n)\n\n/** The filtered list of options */\nconst filtered = computed<O[]>(() =>\n filterFn(query.value, options.value, groups.value),\n)\n\n/** The list of filtered options with the \"Add a new option\" option */\nconst withAdd = computed<Option[]>(() =>\n slots.add ? [...filtered.value, addOption] : filtered.value,\n)\n\nfunction toggleSelected(option: Option | undefined) {\n if (!option) {\n return\n }\n\n if (option.id === addOption.id) {\n addNew()\n return\n }\n\n if (multiselect) {\n // Remove from selection list\n if (model.value.some((o) => o.id === option.id)) {\n model.value = model.value.filter((o) => o.id !== option.id)\n }\n // Add to selection list\n else {\n model.value = [\n ...model.value,\n options.value.find((o) => o.id === option.id)!,\n ]\n }\n } else {\n // Set selection for single select mode\n model.value = [options.value.find((o) => o.id === option.id)!]\n }\n}\n\nfunction moveActive(dir: 1 | -1) {\n const list = withAdd.value\n\n // Find active index\n const activeIdx = list.findIndex(\n (option) => option.id === activeRef.value?.id,\n )\n\n // Calculate next index and exit if it's out of bounds\n const nextIdx = activeIdx + dir\n\n if (nextIdx < 0 || nextIdx > list.length - 1) {\n return\n }\n\n activeRef.value = list[nextIdx]! // We know it's in bounds from the check above\n\n if (!activeRef.value) {\n return\n }\n\n // Scroll to the active option\n document?.getElementById(getOptionId(activeRef.value))?.scrollIntoView({\n behavior: 'smooth',\n block: 'nearest',\n })\n}\n\nfunction addNew() {\n emit('add')\n query.value = ''\n}\n\n// Manual autofocus for the input\nconst input = ref<HTMLInputElement | null>(null)\n\n// This must be a setTimeout to ensure there is no scroll jump. nextTick does not work here.\nonMounted(() => setTimeout(() => input.value?.focus(), 0))\n</script>\n<template>\n <div class=\"relative flex\">\n <ScalarIconMagnifyingGlass\n class=\"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-c-3 size-4\" />\n <input\n ref=\"input\"\n v-model=\"query\"\n :aria-activedescendant=\"activeRef ? getOptionId(activeRef) : undefined\"\n aria-autocomplete=\"list\"\n :aria-controls=\"id\"\n class=\"min-w-0 flex-1 rounded border-0 py-2.5 pl-8 pr-3 leading-none text-c-1 -outline-offset-1\"\n data-1p-ignore\n :placeholder\n role=\"combobox\"\n tabindex=\"0\"\n type=\"text\"\n @keydown.down.prevent=\"moveActive(1)\"\n @keydown.enter.prevent=\"activeRef && toggleSelected(activeRef)\"\n @keydown.up.prevent=\"moveActive(-1)\" />\n </div>\n <ul\n v-show=\"filtered.length || slots.add\"\n :id=\"id\"\n :aria-multiselectable=\"multiselect\"\n class=\"border-t p-0.75 custom-scroll overscroll-contain flex-1 min-h-0\"\n role=\"listbox\"\n tabindex=\"-1\">\n <ComboboxOptionGroup\n v-for=\"(group, i) in groups\"\n :id=\"`${id}-group-${i}`\"\n :key=\"i\"\n :hidden=\"\n // Only show the group label if there are some results\n !group.options.some((o) => filtered.some((f) => f.id === o.id)) ||\n // And it has a label\n !group.label\n \">\n <template #label>\n <slot\n v-if=\"$slots.group\"\n :group\n name=\"group\" />\n <template v-else>\n {{ group.label }}\n </template>\n </template>\n <template\n v-for=\"option in filtered\"\n :key=\"option.id\">\n <ComboboxOption\n v-if=\"group.options.some((o) => o.id === option.id)\"\n :id=\"getOptionId(option)\"\n v-slot=\"{ active, selected }\"\n :active=\"activeRef?.id === option.id\"\n :selected=\"model.some((o) => o.id === option.id)\"\n @click=\"toggleSelected(option)\"\n @mousedown.prevent\n @mouseenter=\"activeRef = option\">\n <slot\n v-if=\"$slots.option\"\n :active\n name=\"option\"\n :option\n :selected />\n <template v-else>\n <ScalarListboxCheckbox\n :multiselect\n :selected=\"model.some((o) => o.id === option.id)\" />\n <span class=\"inline-block min-w-0 flex-1 truncate text-c-1\">\n {{ option.label }}\n </span>\n </template>\n </ComboboxOption>\n </template>\n </ComboboxOptionGroup>\n <ComboboxOption\n v-if=\"slots.add\"\n :id=\"getOptionId(addOption)\"\n v-slot=\"{ active }\"\n :active=\"activeRef?.id === addOption.id\"\n @click=\"addNew\"\n @mousedown.prevent\n @mouseenter=\"activeRef = addOption\">\n <ScalarIconPlus class=\"size-4 p-px\" />\n <slot\n :active\n name=\"add\" />\n </ComboboxOption>\n </ul>\n</template>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarComboboxOptions.vue.script.js","names":["$slots"],"sources":["../../../src/components/ScalarCombobox/ScalarComboboxOptions.vue"],"sourcesContent":["<!-- prettier-ignore-attribute generic -->\n<script\n setup\n lang=\"ts\"\n generic=\"O extends Option = Option, G extends OptionGroup<O> = OptionGroup<O>\">\nimport { filterByOptionLabel } from '@/components/ScalarCombobox/filter-by-option-label'\nimport { ScalarIconMagnifyingGlass, ScalarIconPlus } from '@scalar/icons'\nimport { computed, onMounted, ref, useId, watch } from 'vue'\n\nimport { ScalarListboxCheckbox } from '../ScalarListbox'\nimport ComboboxOption from './ScalarComboboxOption.vue'\nimport ComboboxOptionGroup from './ScalarComboboxOptionGroup.vue'\nimport {\n type ComboboxEmits,\n type ComboboxSlots,\n type FilterFunction,\n type Option,\n type OptionGroup,\n type OptionsOrGroups,\n isGroups,\n} from './types'\n\nconst {\n options: optionsOrGroups,\n placeholder,\n filterFn = filterByOptionLabel,\n multiselect,\n} = defineProps<{\n /** The options to display in the combobox */\n options: OptionsOrGroups<O, G>\n /** The placeholder text to display in the combobox */\n placeholder?: string\n /**\n * A function to filter the options based on a query,\n * if not provided, the options will be filtered by option label\n *\n * @see {@link FilterFunction} for more information\n */\n filterFn?: FilterFunction<O, G>\n /** Whether the combobox is in multiselect mode, defaults to false */\n multiselect?: boolean\n}>()\n\nconst emit = defineEmits<ComboboxEmits>()\n\nconst model = defineModel<O[]>({ default: [] })\n\nconst slots = defineSlots<Omit<ComboboxSlots<O, G>, 'default'>>()\n\ndefineOptions({ inheritAttrs: false })\n\n/** A unique ID for the combobox */\nconst id = `scalar-combobox-items-${useId()}`\n\n/** A static option entry for the \"Add a new option\" option */\nconst addOption: Option = { id: `${useId()}-add`, label: 'Add a new option' }\n\n/** Generate a unique ID for an option */\nfunction getOptionId(option: Option) {\n return `${id}-${option.id}`\n}\n\n/** A flat list of all options */\nconst options = computed<O[]>(() =>\n isGroups(optionsOrGroups)\n ? optionsOrGroups.flatMap((group) => group.options)\n : optionsOrGroups,\n)\n\n/** An list of all groups */\nconst groups = computed<G[]>(\n () =>\n isGroups(optionsOrGroups)\n ? optionsOrGroups // G extends OptionGroup<O>\n : /*\n We know G is an unextended OptionGroup<O> here because of the\n structure of the component props so we can cast it to G\n */\n [{ label: '', options: optionsOrGroups } as G], // G is OptionGroup<O>\n)\n\nconst query = ref<string>('')\nconst activeRef = ref<Option | undefined>(model.value?.[0] ?? options.value[0])\n\n// Clear the query on open and close\nonMounted(() => {\n // Clear the query\n query.value = ''\n\n // Set the active option to the selected option or the first option\n activeRef.value = model.value?.[0] ?? options.value[0]\n\n // Scroll to the selected option\n const selected = model.value[0]\n if (selected) {\n setTimeout(() => {\n const value = model.value[0]\n if (!value) {\n return\n }\n\n document\n ?.getElementById(getOptionId(value))\n ?.scrollIntoView({ block: 'nearest' })\n }, 10)\n }\n})\n\n// Set the top option as active when searching\nwatch(\n () => query.value,\n () => (activeRef.value = withAdd.value[0]),\n)\n\n/** The filtered list of options */\nconst filtered = computed<O[]>(() =>\n filterFn(query.value, options.value, groups.value),\n)\n\n/** The list of filtered options with the \"Add a new option\" option */\nconst withAdd = computed<Option[]>(() =>\n slots.add ? [...filtered.value, addOption] : filtered.value,\n)\n\nfunction toggleSelected(option: Option | undefined) {\n if (!option) {\n return\n }\n\n if (option.id === addOption.id) {\n addNew()\n return\n }\n\n if (multiselect) {\n // Remove from selection list\n if (model.value.some((o) => o.id === option.id)) {\n model.value = model.value.filter((o) => o.id !== option.id)\n }\n // Add to selection list\n else {\n model.value = [\n ...model.value,\n options.value.find((o) => o.id === option.id)!,\n ]\n }\n } else {\n // Set selection for single select mode\n model.value = [options.value.find((o) => o.id === option.id)!]\n }\n}\n\nfunction moveActive(dir: 1 | -1) {\n const list = withAdd.value\n\n // Find active index\n const activeIdx = list.findIndex(\n (option) => option.id === activeRef.value?.id,\n )\n\n // Calculate next index and exit if it's out of bounds\n const nextIdx = activeIdx + dir\n\n if (nextIdx < 0 || nextIdx > list.length - 1) {\n return\n }\n\n activeRef.value = list[nextIdx]! // We know it's in bounds from the check above\n\n if (!activeRef.value) {\n return\n }\n\n // Scroll to the active option\n document?.getElementById(getOptionId(activeRef.value))?.scrollIntoView({\n behavior: 'smooth',\n block: 'nearest',\n })\n}\n\nfunction addNew() {\n emit('add')\n query.value = ''\n}\n\n// Manual autofocus for the input\nconst input = ref<HTMLInputElement | null>(null)\n\n// This must be a setTimeout to ensure there is no scroll jump. nextTick does not work here.\nonMounted(() => setTimeout(() => input.value?.focus(), 0))\n</script>\n<template>\n <div class=\"relative flex\">\n <ScalarIconMagnifyingGlass\n class=\"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-c-3 size-4\" />\n <input\n ref=\"input\"\n v-model=\"query\"\n :aria-activedescendant=\"activeRef ? getOptionId(activeRef) : undefined\"\n aria-autocomplete=\"list\"\n :aria-controls=\"id\"\n class=\"min-w-0 flex-1 rounded border-0 py-2.5 pl-8 pr-3 leading-none text-c-1 -outline-offset-1\"\n data-1p-ignore\n :placeholder\n role=\"combobox\"\n tabindex=\"0\"\n type=\"text\"\n @keydown.down.prevent=\"moveActive(1)\"\n @keydown.enter.prevent=\"activeRef && toggleSelected(activeRef)\"\n @keydown.up.prevent=\"moveActive(-1)\" />\n </div>\n <ul\n v-show=\"filtered.length || slots.add\"\n :id=\"id\"\n :aria-multiselectable=\"multiselect\"\n class=\"border-t p-0.75 custom-scroll overscroll-contain flex-1 min-h-0\"\n role=\"listbox\"\n tabindex=\"-1\">\n <ComboboxOptionGroup\n v-for=\"(group, i) in groups\"\n :id=\"`${id}-group-${i}`\"\n :key=\"i\"\n :hidden=\"\n // Only show the group label if there are some results\n !group.options.some((o) => filtered.some((f) => f.id === o.id)) ||\n // And it has a label\n !group.label\n \">\n <template #label>\n <slot\n v-if=\"$slots.group\"\n :group\n name=\"group\" />\n <template v-else>\n {{ group.label }}\n </template>\n </template>\n <template\n v-for=\"option in filtered\"\n :key=\"option.id\">\n <ComboboxOption\n v-if=\"group.options.some((o) => o.id === option.id)\"\n :id=\"getOptionId(option)\"\n v-slot=\"{ active, selected }\"\n :active=\"activeRef?.id === option.id\"\n :selected=\"model.some((o) => o.id === option.id)\"\n @click=\"toggleSelected(option)\"\n @mousedown.prevent\n @mouseenter=\"activeRef = option\">\n <slot\n v-if=\"$slots.option\"\n :active\n name=\"option\"\n :option\n :selected />\n <template v-else>\n <ScalarListboxCheckbox\n :multiselect\n :selected=\"model.some((o) => o.id === option.id)\" />\n <span class=\"inline-block min-w-0 flex-1 truncate text-c-1\">\n {{ option.label }}\n </span>\n </template>\n </ComboboxOption>\n </template>\n </ComboboxOptionGroup>\n <ComboboxOption\n v-if=\"slots.add\"\n :id=\"getOptionId(addOption)\"\n v-slot=\"{ active }\"\n :active=\"activeRef?.id === addOption.id\"\n @click=\"addNew\"\n @mousedown.prevent\n @mouseenter=\"activeRef = addOption\">\n <ScalarIconPlus class=\"size-4 p-px\" />\n <slot\n :active\n name=\"add\" />\n </ComboboxOption>\n </ul>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA2CA,MAAM,OAAO;EAEb,MAAM,QAAQ,SAAgB,SAAA,aAAgB;EAE9C,MAAM,QAAQ,UAAA;;EAKd,MAAM,KAAK,yBAAyB,OAAO;;EAG3C,MAAM,YAAoB;GAAE,IAAI,GAAG,OAAO,CAAC;GAA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;;;cAOjB,MAAM,OAAA,WAAA,EADd,YAYiB,8BAAA;;IAVd,IAAI,YAAY,UAAS;IAEzB,QAAQ,UAAA,OAAW,OAAO,UAAU;IACpC,SAAO;IACP,aAAS,OAAA,OAAA,OAAA,KAAA,oBAAV,IAAkB,CAAA,UAAA,CAAA;IACjB,cAAU,OAAA,OAAA,OAAA,MAAA,WAAE,UAAA,QAAY;;sBACa,EAL5B,aAAM,CAKhB,YAAsC,MAAA,eAAA,EAAA,EAAtB,OAAM,eAAa,CAAA,EACnC,WAEe,KAAA,QAAA,OAAA,EADZ,QAAM,CAAA,CAAA,CAAA;;sFAhEH,SAAA,MAAS,UAAU,MAAM,IAAG,CAAA,CAAA,CAAA,EAAA,GAAA"}
|
|
1
|
+
{"version":3,"file":"ScalarComboboxOptions.vue.script.js","names":["$slots"],"sources":["../../../src/components/ScalarCombobox/ScalarComboboxOptions.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Combobox Options component\n *\n * Renders the searchable option list for a combobox, including\n * filtering, keyboard navigation, and an optional \"add new\" action.\n *\n * @example\n * <ScalarComboboxOptions v-model=\"selected\" :options=\"options\" />\n */\nexport default {}\n</script>\n\n<!-- prettier-ignore-attribute generic -->\n<script\n setup\n lang=\"ts\"\n generic=\"O extends Option = Option, G extends OptionGroup<O> = OptionGroup<O>\">\nimport { filterByOptionLabel } from '@/components/ScalarCombobox/filter-by-option-label'\nimport { ScalarIconMagnifyingGlass, ScalarIconPlus } from '@scalar/icons'\nimport { computed, onMounted, ref, useId, watch } from 'vue'\n\nimport { ScalarListboxCheckbox } from '../ScalarListbox'\nimport ComboboxOption from './ScalarComboboxOption.vue'\nimport ComboboxOptionGroup from './ScalarComboboxOptionGroup.vue'\nimport {\n type ComboboxEmits,\n type ComboboxSlots,\n type FilterFunction,\n type Option,\n type OptionGroup,\n type OptionsOrGroups,\n isGroups,\n} from './types'\n\nconst {\n options: optionsOrGroups,\n placeholder,\n filterFn = filterByOptionLabel,\n multiselect,\n} = defineProps<{\n /** The options to display in the combobox */\n options: OptionsOrGroups<O, G>\n /** The placeholder text to display in the combobox */\n placeholder?: string\n /**\n * A function to filter the options based on a query,\n * if not provided, the options will be filtered by option label\n *\n * @see {@link FilterFunction} for more information\n */\n filterFn?: FilterFunction<O, G>\n /** Whether the combobox is in multiselect mode, defaults to false */\n multiselect?: boolean\n}>()\n\nconst emit = defineEmits<ComboboxEmits>()\n\nconst model = defineModel<O[]>({ default: [] })\n\nconst slots = defineSlots<Omit<ComboboxSlots<O, G>, 'default'>>()\n\ndefineOptions({ inheritAttrs: false })\n\n/** A unique ID for the combobox */\nconst id = `scalar-combobox-items-${useId()}`\n\n/** A static option entry for the \"Add a new option\" option */\nconst addOption: Option = { id: `${useId()}-add`, label: 'Add a new option' }\n\n/** Generate a unique ID for an option */\nfunction getOptionId(option: Option) {\n return `${id}-${option.id}`\n}\n\n/** A flat list of all options */\nconst options = computed<O[]>(() =>\n isGroups(optionsOrGroups)\n ? optionsOrGroups.flatMap((group) => group.options)\n : optionsOrGroups,\n)\n\n/** An list of all groups */\nconst groups = computed<G[]>(\n () =>\n isGroups(optionsOrGroups)\n ? optionsOrGroups // G extends OptionGroup<O>\n : /*\n We know G is an unextended OptionGroup<O> here because of the\n structure of the component props so we can cast it to G\n */\n [{ label: '', options: optionsOrGroups } as G], // G is OptionGroup<O>\n)\n\nconst query = ref<string>('')\nconst activeRef = ref<Option | undefined>(model.value?.[0] ?? options.value[0])\n\n// Clear the query on open and close\nonMounted(() => {\n // Clear the query\n query.value = ''\n\n // Set the active option to the selected option or the first option\n activeRef.value = model.value?.[0] ?? options.value[0]\n\n // Scroll to the selected option\n const selected = model.value[0]\n if (selected) {\n setTimeout(() => {\n const value = model.value[0]\n if (!value) {\n return\n }\n\n document\n ?.getElementById(getOptionId(value))\n ?.scrollIntoView({ block: 'nearest' })\n }, 10)\n }\n})\n\n// Set the top option as active when searching\nwatch(\n () => query.value,\n () => (activeRef.value = withAdd.value[0]),\n)\n\n/** The filtered list of options */\nconst filtered = computed<O[]>(() =>\n filterFn(query.value, options.value, groups.value),\n)\n\n/** The list of filtered options with the \"Add a new option\" option */\nconst withAdd = computed<Option[]>(() =>\n slots.add ? [...filtered.value, addOption] : filtered.value,\n)\n\nfunction toggleSelected(option: Option | undefined) {\n if (!option) {\n return\n }\n\n if (option.id === addOption.id) {\n addNew()\n return\n }\n\n if (multiselect) {\n // Remove from selection list\n if (model.value.some((o) => o.id === option.id)) {\n model.value = model.value.filter((o) => o.id !== option.id)\n }\n // Add to selection list\n else {\n model.value = [\n ...model.value,\n options.value.find((o) => o.id === option.id)!,\n ]\n }\n } else {\n // Set selection for single select mode\n model.value = [options.value.find((o) => o.id === option.id)!]\n }\n}\n\nfunction moveActive(dir: 1 | -1) {\n const list = withAdd.value\n\n // Find active index\n const activeIdx = list.findIndex(\n (option) => option.id === activeRef.value?.id,\n )\n\n // Calculate next index and exit if it's out of bounds\n const nextIdx = activeIdx + dir\n\n if (nextIdx < 0 || nextIdx > list.length - 1) {\n return\n }\n\n activeRef.value = list[nextIdx]! // We know it's in bounds from the check above\n\n if (!activeRef.value) {\n return\n }\n\n // Scroll to the active option\n document?.getElementById(getOptionId(activeRef.value))?.scrollIntoView({\n behavior: 'smooth',\n block: 'nearest',\n })\n}\n\nfunction addNew() {\n emit('add')\n query.value = ''\n}\n\n// Manual autofocus for the input\nconst input = ref<HTMLInputElement | null>(null)\n\n// This must be a setTimeout to ensure there is no scroll jump. nextTick does not work here.\nonMounted(() => setTimeout(() => input.value?.focus(), 0))\n</script>\n<template>\n <div class=\"relative flex\">\n <ScalarIconMagnifyingGlass\n class=\"pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-c-3 size-4\" />\n <input\n ref=\"input\"\n v-model=\"query\"\n :aria-activedescendant=\"activeRef ? getOptionId(activeRef) : undefined\"\n aria-autocomplete=\"list\"\n :aria-controls=\"id\"\n class=\"min-w-0 flex-1 rounded border-0 py-2.5 pl-8 pr-3 leading-none text-c-1 -outline-offset-1\"\n data-1p-ignore\n :placeholder\n role=\"combobox\"\n tabindex=\"0\"\n type=\"text\"\n @keydown.down.prevent=\"moveActive(1)\"\n @keydown.enter.prevent=\"activeRef && toggleSelected(activeRef)\"\n @keydown.up.prevent=\"moveActive(-1)\" />\n </div>\n <ul\n v-show=\"filtered.length || slots.add\"\n :id=\"id\"\n :aria-multiselectable=\"multiselect\"\n class=\"border-t p-0.75 custom-scroll overscroll-contain flex-1 min-h-0\"\n role=\"listbox\"\n tabindex=\"-1\">\n <ComboboxOptionGroup\n v-for=\"(group, i) in groups\"\n :id=\"`${id}-group-${i}`\"\n :key=\"i\"\n :hidden=\"\n // Only show the group label if there are some results\n !group.options.some((o) => filtered.some((f) => f.id === o.id)) ||\n // And it has a label\n !group.label\n \">\n <template #label>\n <slot\n v-if=\"$slots.group\"\n :group\n name=\"group\" />\n <template v-else>\n {{ group.label }}\n </template>\n </template>\n <template\n v-for=\"option in filtered\"\n :key=\"option.id\">\n <ComboboxOption\n v-if=\"group.options.some((o) => o.id === option.id)\"\n :id=\"getOptionId(option)\"\n v-slot=\"{ active, selected }\"\n :active=\"activeRef?.id === option.id\"\n :selected=\"model.some((o) => o.id === option.id)\"\n @click=\"toggleSelected(option)\"\n @mousedown.prevent\n @mouseenter=\"activeRef = option\">\n <slot\n v-if=\"$slots.option\"\n :active\n name=\"option\"\n :option\n :selected />\n <template v-else>\n <ScalarListboxCheckbox\n :multiselect\n :selected=\"model.some((o) => o.id === option.id)\" />\n <span class=\"inline-block min-w-0 flex-1 truncate text-c-1\">\n {{ option.label }}\n </span>\n </template>\n </ComboboxOption>\n </template>\n </ComboboxOptionGroup>\n <ComboboxOption\n v-if=\"slots.add\"\n :id=\"getOptionId(addOption)\"\n v-slot=\"{ active }\"\n :active=\"activeRef?.id === addOption.id\"\n @click=\"addNew\"\n @mousedown.prevent\n @mouseenter=\"activeRef = addOption\">\n <ScalarIconPlus class=\"size-4 p-px\" />\n <slot\n :active\n name=\"add\" />\n </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mBAOW,UAAA,EAAA,KAAA,GAAA,EAAA,CANT,YAEsD,MAAA,8BAAA,EAAA;QADnD,aAAA,QAAA;QACA,UAAU,MAAA,MAAM,MAAM,MAAM,EAAE,OAAO,OAAO,GAAE;iDACjD,mBAEO,QAFP,YAEO,gBADF,OAAO,MAAK,EAAA,EAAA,CAAA,EAAA,GAAA,EAAA,CAAA;;;;;;;;;;;;cAOjB,MAAM,OAAA,WAAA,EADd,YAYiB,8BAAA;;IAVd,IAAI,YAAY,UAAS;IAEzB,QAAQ,UAAA,OAAW,OAAO,UAAU;IACpC,SAAO;IACP,aAAS,OAAA,OAAA,OAAA,KAAA,oBAAV,IAAkB,CAAA,UAAA,CAAA;IACjB,cAAU,OAAA,OAAA,OAAA,MAAA,WAAE,UAAA,QAAY;;sBACa,EAL5B,aAAM,CAKhB,YAAsC,MAAA,eAAA,EAAA,EAAtB,OAAM,eAAa,CAAA,EACnC,WAEe,KAAA,QAAA,OAAA,EADZ,QAAM,CAAA,CAAA,CAAA;;sFAhEH,SAAA,MAAS,UAAU,MAAM,IAAG,CAAA,CAAA,CAAA,EAAA,GAAA"}
|
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
import { type ScalarFloatingOptions } from '../ScalarFloating';
|
|
2
2
|
import type { ScalarPopoverSlots } from '../ScalarPopover';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Scalar Combobox Popover component
|
|
5
|
+
*
|
|
6
|
+
* Wraps combobox content in a floating popover panel.
|
|
7
|
+
* Handles open/close behavior and keyboard interactions.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* <ScalarComboboxPopover>
|
|
11
|
+
* <button>Toggle</button>
|
|
12
|
+
* <template #popover="{ close }">Content</template>
|
|
13
|
+
* </ScalarComboboxPopover>
|
|
14
|
+
*/
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
17
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<ScalarFloatingOptions, {
|
|
5
18
|
popoverButtonRef: import("vue").Ref<import("vue").DefineComponent<{
|
|
6
19
|
as: {
|
|
7
20
|
type: (ObjectConstructor | StringConstructor)[];
|
|
@@ -67,10 +80,7 @@ declare const __VLS_base: import("vue").DefineComponent<ScalarFloatingOptions, {
|
|
|
67
80
|
as: string | Record<string, any>;
|
|
68
81
|
disabled: boolean;
|
|
69
82
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any> | null>;
|
|
70
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ScalarFloatingOptions> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
71
|
-
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
72
|
-
declare const _default: typeof __VLS_export;
|
|
73
|
-
export default _default;
|
|
83
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ScalarFloatingOptions> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ScalarPopoverSlots>;
|
|
74
84
|
type __VLS_WithSlots<T, S> = T & {
|
|
75
85
|
new (): {
|
|
76
86
|
$slots: S;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarComboboxPopover.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarCombobox/ScalarComboboxPopover.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarComboboxPopover.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarCombobox/ScalarComboboxPopover.vue"],"names":[],"mappings":"AAsFA,OAAO,EAGL,KAAK,qBAAqB,EAC3B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAG1D;;;;;;;;;;;GAWG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mRAqKd,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarComboboxPopover.vue.js","names":[],"sources":["../../../src/components/ScalarCombobox/ScalarComboboxPopover.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Popover, PopoverButton, PopoverPanel } from '@headlessui/vue'\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { ref } from 'vue'\n\nimport {\n ScalarFloating,\n ScalarFloatingBackdrop,\n type ScalarFloatingOptions,\n} from '../ScalarFloating'\nimport type { ScalarPopoverSlots } from '../ScalarPopover'\n\ndefineProps<ScalarFloatingOptions>()\n\ndefineSlots<ScalarPopoverSlots>()\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n\n/** Expose the popover button so we can close the popup */\nconst popoverButtonRef = ref<typeof PopoverButton | null>(null)\n\n/** Open the popover of the up or down arrows are pressed */\nconst handleKeydown = (e: KeyboardEvent) => {\n if (!['ArrowUp', 'ArrowDown'].includes(e.key)) {\n return\n }\n e.preventDefault()\n e.target?.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }))\n}\n\ndefineExpose({ popoverButtonRef })\n</script>\n<template>\n <Popover\n v-slot=\"{ open }\"\n as=\"template\">\n <ScalarFloating v-bind=\"$props\">\n <PopoverButton\n ref=\"popoverButtonRef\"\n as=\"template\"\n @keydown=\"handleKeydown\">\n <slot :open />\n </PopoverButton>\n <template\n v-if=\"open\"\n #floating=\"{ width }\">\n <PopoverPanel\n v-slot=\"{ close }\"\n :style=\"{ width }\"\n v-bind=\"\n cx('relative flex flex-col max-h-[inherit] w-40 rounded text-sm')\n \">\n <slot\n :close\n name=\"popover\"\n :open />\n <ScalarFloatingBackdrop />\n </PopoverPanel>\n </template>\n </ScalarFloating>\n </Popover>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ScalarComboboxPopover.vue.js","names":[],"sources":["../../../src/components/ScalarCombobox/ScalarComboboxPopover.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Combobox Popover component\n *\n * Wraps combobox content in a floating popover panel.\n * Handles open/close behavior and keyboard interactions.\n *\n * @example\n * <ScalarComboboxPopover>\n * <button>Toggle</button>\n * <template #popover=\"{ close }\">Content</template>\n * </ScalarComboboxPopover>\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { Popover, PopoverButton, PopoverPanel } from '@headlessui/vue'\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { ref } from 'vue'\n\nimport {\n ScalarFloating,\n ScalarFloatingBackdrop,\n type ScalarFloatingOptions,\n} from '../ScalarFloating'\nimport type { ScalarPopoverSlots } from '../ScalarPopover'\n\ndefineProps<ScalarFloatingOptions>()\n\ndefineSlots<ScalarPopoverSlots>()\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n\n/** Expose the popover button so we can close the popup */\nconst popoverButtonRef = ref<typeof PopoverButton | null>(null)\n\n/** Open the popover of the up or down arrows are pressed */\nconst handleKeydown = (e: KeyboardEvent) => {\n if (!['ArrowUp', 'ArrowDown'].includes(e.key)) {\n return\n }\n e.preventDefault()\n e.target?.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }))\n}\n\ndefineExpose({ popoverButtonRef })\n</script>\n<template>\n <Popover\n v-slot=\"{ open }\"\n as=\"template\">\n <ScalarFloating v-bind=\"$props\">\n <PopoverButton\n ref=\"popoverButtonRef\"\n as=\"template\"\n @keydown=\"handleKeydown\">\n <slot :open />\n </PopoverButton>\n <template\n v-if=\"open\"\n #floating=\"{ width }\">\n <PopoverPanel\n v-slot=\"{ close }\"\n :style=\"{ width }\"\n v-bind=\"\n cx('relative flex flex-col max-h-[inherit] w-40 rounded text-sm')\n \">\n <slot\n :close\n name=\"popover\"\n :open />\n <ScalarFloatingBackdrop />\n </PopoverPanel>\n </template>\n </ScalarFloating>\n </Popover>\n</template>\n"],"mappings":""}
|
|
@@ -3,7 +3,6 @@ import ScalarFloatingBackdrop_default from "../ScalarFloating/ScalarFloatingBack
|
|
|
3
3
|
import { useBindCx } from "@scalar/use-hooks/useBindCx";
|
|
4
4
|
import { createBlock, createSlots, createVNode, defineComponent, guardReactiveProps, mergeProps, normalizeProps, openBlock, ref, renderSlot, unref, withCtx } from "vue";
|
|
5
5
|
import { Popover, PopoverButton, PopoverPanel } from "@headlessui/vue";
|
|
6
|
-
//#region src/components/ScalarCombobox/ScalarComboboxPopover.vue?vue&type=script&setup=true&lang.ts
|
|
7
6
|
var ScalarComboboxPopover_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
8
7
|
inheritAttrs: false,
|
|
9
8
|
__name: "ScalarComboboxPopover",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarComboboxPopover.vue.script.js","names":["$props"],"sources":["../../../src/components/ScalarCombobox/ScalarComboboxPopover.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Popover, PopoverButton, PopoverPanel } from '@headlessui/vue'\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { ref } from 'vue'\n\nimport {\n ScalarFloating,\n ScalarFloatingBackdrop,\n type ScalarFloatingOptions,\n} from '../ScalarFloating'\nimport type { ScalarPopoverSlots } from '../ScalarPopover'\n\ndefineProps<ScalarFloatingOptions>()\n\ndefineSlots<ScalarPopoverSlots>()\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n\n/** Expose the popover button so we can close the popup */\nconst popoverButtonRef = ref<typeof PopoverButton | null>(null)\n\n/** Open the popover of the up or down arrows are pressed */\nconst handleKeydown = (e: KeyboardEvent) => {\n if (!['ArrowUp', 'ArrowDown'].includes(e.key)) {\n return\n }\n e.preventDefault()\n e.target?.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }))\n}\n\ndefineExpose({ popoverButtonRef })\n</script>\n<template>\n <Popover\n v-slot=\"{ open }\"\n as=\"template\">\n <ScalarFloating v-bind=\"$props\">\n <PopoverButton\n ref=\"popoverButtonRef\"\n as=\"template\"\n @keydown=\"handleKeydown\">\n <slot :open />\n </PopoverButton>\n <template\n v-if=\"open\"\n #floating=\"{ width }\">\n <PopoverPanel\n v-slot=\"{ close }\"\n :style=\"{ width }\"\n v-bind=\"\n cx('relative flex flex-col max-h-[inherit] w-40 rounded text-sm')\n \">\n <slot\n :close\n name=\"popover\"\n :open />\n <ScalarFloatingBackdrop />\n </PopoverPanel>\n </template>\n </ScalarFloating>\n </Popover>\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarComboboxPopover.vue.script.js","names":["$props"],"sources":["../../../src/components/ScalarCombobox/ScalarComboboxPopover.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Combobox Popover component\n *\n * Wraps combobox content in a floating popover panel.\n * Handles open/close behavior and keyboard interactions.\n *\n * @example\n * <ScalarComboboxPopover>\n * <button>Toggle</button>\n * <template #popover=\"{ close }\">Content</template>\n * </ScalarComboboxPopover>\n */\nexport default {}\n</script>\n\n<script setup lang=\"ts\">\nimport { Popover, PopoverButton, PopoverPanel } from '@headlessui/vue'\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { ref } from 'vue'\n\nimport {\n ScalarFloating,\n ScalarFloatingBackdrop,\n type ScalarFloatingOptions,\n} from '../ScalarFloating'\nimport type { ScalarPopoverSlots } from '../ScalarPopover'\n\ndefineProps<ScalarFloatingOptions>()\n\ndefineSlots<ScalarPopoverSlots>()\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n\n/** Expose the popover button so we can close the popup */\nconst popoverButtonRef = ref<typeof PopoverButton | null>(null)\n\n/** Open the popover of the up or down arrows are pressed */\nconst handleKeydown = (e: KeyboardEvent) => {\n if (!['ArrowUp', 'ArrowDown'].includes(e.key)) {\n return\n }\n e.preventDefault()\n e.target?.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter' }))\n}\n\ndefineExpose({ popoverButtonRef })\n</script>\n<template>\n <Popover\n v-slot=\"{ open }\"\n as=\"template\">\n <ScalarFloating v-bind=\"$props\">\n <PopoverButton\n ref=\"popoverButtonRef\"\n as=\"template\"\n @keydown=\"handleKeydown\">\n <slot :open />\n </PopoverButton>\n <template\n v-if=\"open\"\n #floating=\"{ width }\">\n <PopoverPanel\n v-slot=\"{ close }\"\n :style=\"{ width }\"\n v-bind=\"\n cx('relative flex flex-col max-h-[inherit] w-40 rounded text-sm')\n \">\n <slot\n :close\n name=\"popover\"\n :open />\n <ScalarFloatingBackdrop />\n </PopoverPanel>\n </template>\n </ScalarFloating>\n </Popover>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;EAiCA,MAAM,EAAE,OAAO,WAAU;;EAGzB,MAAM,mBAAmB,IAAiC,KAAI;;EAG9D,MAAM,iBAAiB,MAAqB;AAC1C,OAAI,CAAC,CAAC,WAAW,YAAY,CAAC,SAAS,EAAE,IAAI,CAC3C;AAEF,KAAE,gBAAe;AACjB,KAAE,QAAQ,cAAc,IAAI,cAAc,WAAW,EAAE,KAAK,SAAS,CAAC,CAAA;;AAGxE,WAAa,EAAE,kBAAkB,CAAA;;uBAG/B,YA2BU,MAAA,QAAA,EAAA,EAzBR,IAAG,YAAU,EAAA;sBAwBI,EAzBP,WAAI,CAEd,YAuBiB,MAAA,uBAAA,EAAA,eAAA,mBAvBOA,KAAAA,OAAM,CAAA,EAAA,YAAA;4BAMZ,CALhB,YAKgB,MAAA,cAAA,EAAA;eAJV;MAAJ,KAAI;MACJ,IAAG;MACF,WAAS;;6BACI,CAAd,WAAc,KAAA,QAAA,WAAA,EAAP,MAAI,CAAA,CAAA,CAAA;;;;QAGL,OAAA;WACL;kBAYc,EAZF,YAAK,CAClB,YAWe,MAAA,aAAA,EAXf,WAWe,EATZ,OAAK,EAAI,OAAK,EAAA,EACM,MAAA,GAAE,CAAA,8DAAA,CAAA,EAAA;wBAMb,EARA,YAAK,CAKf,WAGU,KAAA,QAAA,WAAA;OAFP;OAEA;UACH,YAA0B,MAAA,+BAAA,CAAA,CAAA,CAAA"}
|
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Scalar Error Boundary component
|
|
3
|
+
*
|
|
4
|
+
* Catches errors thrown by child components and displays
|
|
5
|
+
* a fallback error message instead of crashing the entire app.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <ScalarErrorBoundary>
|
|
9
|
+
* <SomeComponent />
|
|
10
|
+
* </ScalarErrorBoundary>
|
|
11
|
+
*/
|
|
7
12
|
declare const _default: typeof __VLS_export;
|
|
8
13
|
export default _default;
|
|
14
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, {
|
|
15
|
+
default?: (props: {}) => any;
|
|
16
|
+
}>;
|
|
9
17
|
type __VLS_WithSlots<T, S> = T & {
|
|
10
18
|
new (): {
|
|
11
19
|
$slots: S;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarErrorBoundary.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarErrorBoundary/ScalarErrorBoundary.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarErrorBoundary.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarErrorBoundary/ScalarErrorBoundary.vue"],"names":[],"mappings":"AAkDA;;;;;;;;;;GAUG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;cAgEJ,CAAC,KAAK,IAAgB,KAAK,GAAG;EAQxC,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarErrorBoundary.vue.js","names":[],"sources":["../../../src/components/ScalarErrorBoundary/ScalarErrorBoundary.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { onErrorCaptured, ref } from 'vue'\n\nconst hasError = ref<boolean>(false)\nconst error = ref<Error>()\n\nonErrorCaptured((err, _, info) => {\n console.error('[ERROR]', err, info)\n\n hasError.value = true\n error.value = err\n\n // Prevent the error from propagating further up\n return false\n})\n</script>\n\n<template>\n <slot v-if=\"!hasError\" />\n <div\n v-else\n class=\"rounded border bg-b-2 p-3 text-sm\">\n <div class=\"p-2\">Oops, something went wrong here.</div>\n <div\n v-if=\"error\"\n class=\"mt-2 rounded border bg-b-1 p-2 font-code text-c-2\">\n {{ error?.name }}: {{ error?.message }}\n </div>\n </div>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ScalarErrorBoundary.vue.js","names":[],"sources":["../../../src/components/ScalarErrorBoundary/ScalarErrorBoundary.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Error Boundary component\n *\n * Catches errors thrown by child components and displays\n * a fallback error message instead of crashing the entire app.\n *\n * @example\n * <ScalarErrorBoundary>\n * <SomeComponent />\n * </ScalarErrorBoundary>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { onErrorCaptured, ref } from 'vue'\n\nconst hasError = ref<boolean>(false)\nconst error = ref<Error>()\n\nonErrorCaptured((err, _, info) => {\n console.error('[ERROR]', err, info)\n\n hasError.value = true\n error.value = err\n\n // Prevent the error from propagating further up\n return false\n})\n</script>\n\n<template>\n <slot v-if=\"!hasError\" />\n <div\n v-else\n class=\"rounded border bg-b-2 p-3 text-sm\">\n <div class=\"p-2\">Oops, something went wrong here.</div>\n <div\n v-if=\"error\"\n class=\"mt-2 rounded border bg-b-1 p-2 font-code text-c-2\">\n {{ error?.name }}: {{ error?.message }}\n </div>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarErrorBoundary.vue.script.js","names":[],"sources":["../../../src/components/ScalarErrorBoundary/ScalarErrorBoundary.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { onErrorCaptured, ref } from 'vue'\n\nconst hasError = ref<boolean>(false)\nconst error = ref<Error>()\n\nonErrorCaptured((err, _, info) => {\n console.error('[ERROR]', err, info)\n\n hasError.value = true\n error.value = err\n\n // Prevent the error from propagating further up\n return false\n})\n</script>\n\n<template>\n <slot v-if=\"!hasError\" />\n <div\n v-else\n class=\"rounded border bg-b-2 p-3 text-sm\">\n <div class=\"p-2\">Oops, something went wrong here.</div>\n <div\n v-if=\"error\"\n class=\"mt-2 rounded border bg-b-1 p-2 font-code text-c-2\">\n {{ error?.name }}: {{ error?.message }}\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ScalarErrorBoundary.vue.script.js","names":[],"sources":["../../../src/components/ScalarErrorBoundary/ScalarErrorBoundary.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Error Boundary component\n *\n * Catches errors thrown by child components and displays\n * a fallback error message instead of crashing the entire app.\n *\n * @example\n * <ScalarErrorBoundary>\n * <SomeComponent />\n * </ScalarErrorBoundary>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { onErrorCaptured, ref } from 'vue'\n\nconst hasError = ref<boolean>(false)\nconst error = ref<Error>()\n\nonErrorCaptured((err, _, info) => {\n console.error('[ERROR]', err, info)\n\n hasError.value = true\n error.value = err\n\n // Prevent the error from propagating further up\n return false\n})\n</script>\n\n<template>\n <slot v-if=\"!hasError\" />\n <div\n v-else\n class=\"rounded border bg-b-2 p-3 text-sm\">\n <div class=\"p-2\">Oops, something went wrong here.</div>\n <div\n v-if=\"error\"\n class=\"mt-2 rounded border bg-b-1 p-2 font-code text-c-2\">\n {{ error?.name }}: {{ error?.message }}\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;EAiBA,MAAM,WAAW,IAAa,MAAK;EACnC,MAAM,QAAQ,KAAW;AAEzB,mBAAiB,KAAK,GAAG,SAAS;AAChC,WAAQ,MAAM,WAAW,KAAK,KAAI;AAElC,YAAS,QAAQ;AACjB,SAAM,QAAQ;AAGd,UAAO;IACR;;WAIc,SAAA,QAAb,WAAyB,KAAA,QAAA,WAAA,EAAA,KAAA,GAAA,CAAA,IAAA,WAAA,EACzB,mBASM,OATN,YASM,CAAA,OAAA,OAAA,OAAA,KANJ,mBAAuD,OAAA,EAAlD,OAAM,OAAK,EAAC,oCAAgC,GAAA,GAEzC,MAAA,SAAA,WAAA,EADR,mBAIM,OAJN,YAIM,gBADD,MAAA,OAAO,KAAI,GAAG,OAAE,gBAAG,MAAA,OAAO,QAAO,EAAA,EAAA,IAAA,mBAAA,IAAA,KAAA,CAAA,CAAA"}
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import { type MiddlewareData } from '@floating-ui/vue';
|
|
2
2
|
import type { FloatingOptions } from './types';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Scalar Floating component
|
|
5
|
+
*
|
|
6
|
+
* Positions a floating element relative to a reference element
|
|
7
|
+
* using Floating UI. Handles placement, offset, flipping, and resizing.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* <ScalarFloating placement="bottom">
|
|
11
|
+
* <button>Reference</button>
|
|
12
|
+
* <template #floating>Floating content</template>
|
|
13
|
+
* </ScalarFloating>
|
|
14
|
+
*/
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
17
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<FloatingOptions, {
|
|
18
|
+
/** The resolved target element */
|
|
19
|
+
targetRef: import("vue").ComputedRef<HTMLElement | undefined>;
|
|
20
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FloatingOptions> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
4
21
|
/** The reference element for the element in the #floating slot */
|
|
5
22
|
default(): unknown;
|
|
6
23
|
/** The floating element */
|
|
@@ -12,14 +29,7 @@ type __VLS_Slots = {
|
|
|
12
29
|
/** The middleware data return by Floating UI */
|
|
13
30
|
data?: MiddlewareData;
|
|
14
31
|
}): unknown;
|
|
15
|
-
}
|
|
16
|
-
declare const __VLS_base: import("vue").DefineComponent<FloatingOptions, {
|
|
17
|
-
/** The resolved target element */
|
|
18
|
-
targetRef: import("vue").ComputedRef<HTMLElement | undefined>;
|
|
19
|
-
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<FloatingOptions> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
20
|
-
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
21
|
-
declare const _default: typeof __VLS_export;
|
|
22
|
-
export default _default;
|
|
32
|
+
}>;
|
|
23
33
|
type __VLS_WithSlots<T, S> = T & {
|
|
24
34
|
new (): {
|
|
25
35
|
$slots: S;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarFloating.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarFloating/ScalarFloating.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarFloating.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarFloating/ScalarFloating.vue"],"names":[],"mappings":"AAwJA,OAAO,EACL,KAAK,cAAc,EAOpB,MAAM,kBAAkB,CAAA;AAIzB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAI9C;;;;;;;;;;;GAWG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;IA8FhB,kCAAkC;;;IAjFlC,kEAAkE;eACvD,OAAO;IAClB,2BAA2B;qBACV;QACf,4FAA4F;QAC5F,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,6FAA6F;QAC7F,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,gDAAgD;QAChD,IAAI,CAAC,EAAE,cAAc,CAAA;KACtB,GAAG,OAAO;EAgJT,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarFloating.vue.js","names":[],"sources":["../../../src/components/ScalarFloating/ScalarFloating.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { getSideAxis } from '@floating-ui/utils'\nimport {\n type MiddlewareData,\n autoUpdate,\n flip,\n offset as offsetMiddleware,\n shift,\n size,\n useFloating,\n} from '@floating-ui/vue'\nimport { type Ref, computed, ref } from 'vue'\n\nimport { ScalarTeleport } from '../ScalarTeleport'\nimport type { FloatingOptions } from './types'\nimport { useResizeWithTarget } from './useResizeWithTarget'\n\nconst {\n placement,\n offset = 5,\n resize = false,\n middleware = [],\n target,\n teleport,\n} = defineProps<FloatingOptions>()\n\ndefineSlots<{\n /** The reference element for the element in the #floating slot */\n default(): unknown\n /** The floating element */\n floating?(props: {\n /** The width of the reference element if `resize` is true and placement is on the y axis */\n width?: string\n /** The height of the reference element if `resize` is true and placement is on the x axis */\n height?: string\n /** The middleware data return by Floating UI */\n data?: MiddlewareData\n }): unknown\n}>()\n\ndefineOptions({ inheritAttrs: false })\n\nconst floatingRef: Ref<HTMLElement | null> = ref(null)\nconst wrapperRef: Ref<HTMLElement | null> = ref(null)\n\nconst targetRef = computed<HTMLElement | undefined>(() => {\n if (typeof window !== 'undefined' && wrapperRef.value) {\n // If target is a string (id), try to find it in the document\n if (typeof target === 'string') {\n const t = document.getElementById(target)\n if (t) {\n return t\n }\n console.warn(`ScalarFloating: Target with id=\"${target}\" not found`)\n }\n // If target is an HTMLElement, return it\n else if (target instanceof HTMLElement) {\n return target\n }\n // Fallback to div wrapper if no child element is provided\n const firstChild = wrapperRef.value.children?.[0]\n if (firstChild instanceof HTMLElement) {\n return firstChild\n }\n return wrapperRef.value\n }\n // Return undefined if nothing is found\n return undefined\n})\n\nconst targetSize = useResizeWithTarget(targetRef, {\n enabled: computed(() => resize),\n})\n\nconst targetWidth = computed(() =>\n getSideAxis(placement ?? 'bottom') === 'y'\n ? targetSize.width.value\n : undefined,\n)\n\nconst targetHeight = computed(() =>\n getSideAxis(placement ?? 'bottom') === 'x'\n ? targetSize.height.value\n : undefined,\n)\nconst { floatingStyles, middlewareData } = useFloating(targetRef, floatingRef, {\n placement: computed(() => placement ?? 'bottom'),\n whileElementsMounted: autoUpdate,\n middleware: computed(() => [\n offsetMiddleware(offset),\n flip(),\n shift({ padding: 10 }),\n size({\n apply({ availableWidth, availableHeight, elements }) {\n // Assign the max width and height to the floating element\n // @see https://floating-ui.com/docs/size\n Object.assign(elements.floating.style, {\n maxWidth: `${Math.max(0, availableWidth) - 20}px`,\n maxHeight: `${Math.max(0, availableHeight) - 20}px`,\n })\n },\n }),\n ...middleware,\n ]),\n})\n\ndefineExpose({\n /** The resolved target element */\n targetRef,\n})\n</script>\n<template>\n <div\n ref=\"wrapperRef\"\n :class=\"{ contents: !!$slots.default }\">\n <slot />\n </div>\n <ScalarTeleport\n v-if=\"$slots.floating\"\n :disabled=\"!teleport\"\n :to=\"typeof teleport === 'string' ? teleport : undefined\">\n <div\n ref=\"floatingRef\"\n class=\"relative z-context\"\n :style=\"floatingStyles\">\n <slot\n :data=\"middlewareData\"\n :height=\"targetHeight\"\n name=\"floating\"\n :width=\"targetWidth\" />\n </div>\n </ScalarTeleport>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ScalarFloating.vue.js","names":[],"sources":["../../../src/components/ScalarFloating/ScalarFloating.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Floating component\n *\n * Positions a floating element relative to a reference element\n * using Floating UI. Handles placement, offset, flipping, and resizing.\n *\n * @example\n * <ScalarFloating placement=\"bottom\">\n * <button>Reference</button>\n * <template #floating>Floating content</template>\n * </ScalarFloating>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { getSideAxis } from '@floating-ui/utils'\nimport {\n type MiddlewareData,\n autoUpdate,\n flip,\n offset as offsetMiddleware,\n shift,\n size,\n useFloating,\n} from '@floating-ui/vue'\nimport { type Ref, computed, ref } from 'vue'\n\nimport { ScalarTeleport } from '../ScalarTeleport'\nimport type { FloatingOptions } from './types'\nimport { useResizeWithTarget } from './useResizeWithTarget'\n\nconst {\n placement,\n offset = 5,\n resize = false,\n middleware = [],\n target,\n teleport,\n} = defineProps<FloatingOptions>()\n\ndefineSlots<{\n /** The reference element for the element in the #floating slot */\n default(): unknown\n /** The floating element */\n floating?(props: {\n /** The width of the reference element if `resize` is true and placement is on the y axis */\n width?: string\n /** The height of the reference element if `resize` is true and placement is on the x axis */\n height?: string\n /** The middleware data return by Floating UI */\n data?: MiddlewareData\n }): unknown\n}>()\n\ndefineOptions({ inheritAttrs: false })\n\nconst floatingRef: Ref<HTMLElement | null> = ref(null)\nconst wrapperRef: Ref<HTMLElement | null> = ref(null)\n\nconst targetRef = computed<HTMLElement | undefined>(() => {\n if (typeof window !== 'undefined' && wrapperRef.value) {\n // If target is a string (id), try to find it in the document\n if (typeof target === 'string') {\n const t = document.getElementById(target)\n if (t) {\n return t\n }\n console.warn(`ScalarFloating: Target with id=\"${target}\" not found`)\n }\n // If target is an HTMLElement, return it\n else if (target instanceof HTMLElement) {\n return target\n }\n // Fallback to div wrapper if no child element is provided\n const firstChild = wrapperRef.value.children?.[0]\n if (firstChild instanceof HTMLElement) {\n return firstChild\n }\n return wrapperRef.value\n }\n // Return undefined if nothing is found\n return undefined\n})\n\nconst targetSize = useResizeWithTarget(targetRef, {\n enabled: computed(() => resize),\n})\n\nconst targetWidth = computed(() =>\n getSideAxis(placement ?? 'bottom') === 'y'\n ? targetSize.width.value\n : undefined,\n)\n\nconst targetHeight = computed(() =>\n getSideAxis(placement ?? 'bottom') === 'x'\n ? targetSize.height.value\n : undefined,\n)\nconst { floatingStyles, middlewareData } = useFloating(targetRef, floatingRef, {\n placement: computed(() => placement ?? 'bottom'),\n whileElementsMounted: autoUpdate,\n middleware: computed(() => [\n offsetMiddleware(offset),\n flip(),\n shift({ padding: 10 }),\n size({\n apply({ availableWidth, availableHeight, elements }) {\n // Assign the max width and height to the floating element\n // @see https://floating-ui.com/docs/size\n Object.assign(elements.floating.style, {\n maxWidth: `${Math.max(0, availableWidth) - 20}px`,\n maxHeight: `${Math.max(0, availableHeight) - 20}px`,\n })\n },\n }),\n ...middleware,\n ]),\n})\n\ndefineExpose({\n /** The resolved target element */\n targetRef,\n})\n</script>\n<template>\n <div\n ref=\"wrapperRef\"\n :class=\"{ contents: !!$slots.default }\">\n <slot />\n </div>\n <ScalarTeleport\n v-if=\"$slots.floating\"\n :disabled=\"!teleport\"\n :to=\"typeof teleport === 'string' ? teleport : undefined\">\n <div\n ref=\"floatingRef\"\n class=\"relative z-context\"\n :style=\"floatingStyles\">\n <slot\n :data=\"middlewareData\"\n :height=\"targetHeight\"\n name=\"floating\"\n :width=\"targetWidth\" />\n </div>\n </ScalarTeleport>\n</template>\n"],"mappings":""}
|
|
@@ -3,7 +3,6 @@ import { useResizeWithTarget } from "./useResizeWithTarget.js";
|
|
|
3
3
|
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, ref, renderSlot, unref, withCtx } from "vue";
|
|
4
4
|
import { getSideAxis } from "@floating-ui/utils";
|
|
5
5
|
import { autoUpdate, flip, offset, shift, size, useFloating } from "@floating-ui/vue";
|
|
6
|
-
//#region src/components/ScalarFloating/ScalarFloating.vue?vue&type=script&setup=true&lang.ts
|
|
7
6
|
var ScalarFloating_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
8
7
|
inheritAttrs: false,
|
|
9
8
|
__name: "ScalarFloating",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarFloating.vue.script.js","names":["$slots"],"sources":["../../../src/components/ScalarFloating/ScalarFloating.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { getSideAxis } from '@floating-ui/utils'\nimport {\n type MiddlewareData,\n autoUpdate,\n flip,\n offset as offsetMiddleware,\n shift,\n size,\n useFloating,\n} from '@floating-ui/vue'\nimport { type Ref, computed, ref } from 'vue'\n\nimport { ScalarTeleport } from '../ScalarTeleport'\nimport type { FloatingOptions } from './types'\nimport { useResizeWithTarget } from './useResizeWithTarget'\n\nconst {\n placement,\n offset = 5,\n resize = false,\n middleware = [],\n target,\n teleport,\n} = defineProps<FloatingOptions>()\n\ndefineSlots<{\n /** The reference element for the element in the #floating slot */\n default(): unknown\n /** The floating element */\n floating?(props: {\n /** The width of the reference element if `resize` is true and placement is on the y axis */\n width?: string\n /** The height of the reference element if `resize` is true and placement is on the x axis */\n height?: string\n /** The middleware data return by Floating UI */\n data?: MiddlewareData\n }): unknown\n}>()\n\ndefineOptions({ inheritAttrs: false })\n\nconst floatingRef: Ref<HTMLElement | null> = ref(null)\nconst wrapperRef: Ref<HTMLElement | null> = ref(null)\n\nconst targetRef = computed<HTMLElement | undefined>(() => {\n if (typeof window !== 'undefined' && wrapperRef.value) {\n // If target is a string (id), try to find it in the document\n if (typeof target === 'string') {\n const t = document.getElementById(target)\n if (t) {\n return t\n }\n console.warn(`ScalarFloating: Target with id=\"${target}\" not found`)\n }\n // If target is an HTMLElement, return it\n else if (target instanceof HTMLElement) {\n return target\n }\n // Fallback to div wrapper if no child element is provided\n const firstChild = wrapperRef.value.children?.[0]\n if (firstChild instanceof HTMLElement) {\n return firstChild\n }\n return wrapperRef.value\n }\n // Return undefined if nothing is found\n return undefined\n})\n\nconst targetSize = useResizeWithTarget(targetRef, {\n enabled: computed(() => resize),\n})\n\nconst targetWidth = computed(() =>\n getSideAxis(placement ?? 'bottom') === 'y'\n ? targetSize.width.value\n : undefined,\n)\n\nconst targetHeight = computed(() =>\n getSideAxis(placement ?? 'bottom') === 'x'\n ? targetSize.height.value\n : undefined,\n)\nconst { floatingStyles, middlewareData } = useFloating(targetRef, floatingRef, {\n placement: computed(() => placement ?? 'bottom'),\n whileElementsMounted: autoUpdate,\n middleware: computed(() => [\n offsetMiddleware(offset),\n flip(),\n shift({ padding: 10 }),\n size({\n apply({ availableWidth, availableHeight, elements }) {\n // Assign the max width and height to the floating element\n // @see https://floating-ui.com/docs/size\n Object.assign(elements.floating.style, {\n maxWidth: `${Math.max(0, availableWidth) - 20}px`,\n maxHeight: `${Math.max(0, availableHeight) - 20}px`,\n })\n },\n }),\n ...middleware,\n ]),\n})\n\ndefineExpose({\n /** The resolved target element */\n targetRef,\n})\n</script>\n<template>\n <div\n ref=\"wrapperRef\"\n :class=\"{ contents: !!$slots.default }\">\n <slot />\n </div>\n <ScalarTeleport\n v-if=\"$slots.floating\"\n :disabled=\"!teleport\"\n :to=\"typeof teleport === 'string' ? teleport : undefined\">\n <div\n ref=\"floatingRef\"\n class=\"relative z-context\"\n :style=\"floatingStyles\">\n <slot\n :data=\"middlewareData\"\n :height=\"targetHeight\"\n name=\"floating\"\n :width=\"targetWidth\" />\n </div>\n </ScalarTeleport>\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarFloating.vue.script.js","names":["$slots"],"sources":["../../../src/components/ScalarFloating/ScalarFloating.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Floating component\n *\n * Positions a floating element relative to a reference element\n * using Floating UI. Handles placement, offset, flipping, and resizing.\n *\n * @example\n * <ScalarFloating placement=\"bottom\">\n * <button>Reference</button>\n * <template #floating>Floating content</template>\n * </ScalarFloating>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { getSideAxis } from '@floating-ui/utils'\nimport {\n type MiddlewareData,\n autoUpdate,\n flip,\n offset as offsetMiddleware,\n shift,\n size,\n useFloating,\n} from '@floating-ui/vue'\nimport { type Ref, computed, ref } from 'vue'\n\nimport { ScalarTeleport } from '../ScalarTeleport'\nimport type { FloatingOptions } from './types'\nimport { useResizeWithTarget } from './useResizeWithTarget'\n\nconst {\n placement,\n offset = 5,\n resize = false,\n middleware = [],\n target,\n teleport,\n} = defineProps<FloatingOptions>()\n\ndefineSlots<{\n /** The reference element for the element in the #floating slot */\n default(): unknown\n /** The floating element */\n floating?(props: {\n /** The width of the reference element if `resize` is true and placement is on the y axis */\n width?: string\n /** The height of the reference element if `resize` is true and placement is on the x axis */\n height?: string\n /** The middleware data return by Floating UI */\n data?: MiddlewareData\n }): unknown\n}>()\n\ndefineOptions({ inheritAttrs: false })\n\nconst floatingRef: Ref<HTMLElement | null> = ref(null)\nconst wrapperRef: Ref<HTMLElement | null> = ref(null)\n\nconst targetRef = computed<HTMLElement | undefined>(() => {\n if (typeof window !== 'undefined' && wrapperRef.value) {\n // If target is a string (id), try to find it in the document\n if (typeof target === 'string') {\n const t = document.getElementById(target)\n if (t) {\n return t\n }\n console.warn(`ScalarFloating: Target with id=\"${target}\" not found`)\n }\n // If target is an HTMLElement, return it\n else if (target instanceof HTMLElement) {\n return target\n }\n // Fallback to div wrapper if no child element is provided\n const firstChild = wrapperRef.value.children?.[0]\n if (firstChild instanceof HTMLElement) {\n return firstChild\n }\n return wrapperRef.value\n }\n // Return undefined if nothing is found\n return undefined\n})\n\nconst targetSize = useResizeWithTarget(targetRef, {\n enabled: computed(() => resize),\n})\n\nconst targetWidth = computed(() =>\n getSideAxis(placement ?? 'bottom') === 'y'\n ? targetSize.width.value\n : undefined,\n)\n\nconst targetHeight = computed(() =>\n getSideAxis(placement ?? 'bottom') === 'x'\n ? targetSize.height.value\n : undefined,\n)\nconst { floatingStyles, middlewareData } = useFloating(targetRef, floatingRef, {\n placement: computed(() => placement ?? 'bottom'),\n whileElementsMounted: autoUpdate,\n middleware: computed(() => [\n offsetMiddleware(offset),\n flip(),\n shift({ padding: 10 }),\n size({\n apply({ availableWidth, availableHeight, elements }) {\n // Assign the max width and height to the floating element\n // @see https://floating-ui.com/docs/size\n Object.assign(elements.floating.style, {\n maxWidth: `${Math.max(0, availableWidth) - 20}px`,\n maxHeight: `${Math.max(0, availableHeight) - 20}px`,\n })\n },\n }),\n ...middleware,\n ]),\n})\n\ndefineExpose({\n /** The resolved target element */\n targetRef,\n})\n</script>\n<template>\n <div\n ref=\"wrapperRef\"\n :class=\"{ contents: !!$slots.default }\">\n <slot />\n </div>\n <ScalarTeleport\n v-if=\"$slots.floating\"\n :disabled=\"!teleport\"\n :to=\"typeof teleport === 'string' ? teleport : undefined\">\n <div\n ref=\"floatingRef\"\n class=\"relative z-context\"\n :style=\"floatingStyles\">\n <slot\n :data=\"middlewareData\"\n :height=\"targetHeight\"\n name=\"floating\"\n :width=\"targetWidth\" />\n </div>\n </ScalarTeleport>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;EAyDA,MAAM,cAAuC,IAAI,KAAI;EACrD,MAAM,aAAsC,IAAI,KAAI;EAEpD,MAAM,YAAY,eAAwC;AACxD,OAAI,OAAO,WAAW,eAAe,WAAW,OAAO;AAErD,QAAI,OAAO,QAAA,WAAW,UAAU;KAC9B,MAAM,IAAI,SAAS,eAAe,QAAA,OAAM;AACxC,SAAI,EACF,QAAO;AAET,aAAQ,KAAK,mCAAmC,QAAA,OAAO,aAAY;e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ACL,OAAK,eAAE,MAAA,eAAc,CAAA;QACtB,WAIyB,KAAA,QAAA,YAAA;KAHtB,MAAM,MAAA,eAAc;KACpB,QAAQ,aAAA;KAER,OAAO,YAAA"}
|
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
import { type Component } from 'vue';
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Scalar Form Error component
|
|
4
|
+
*
|
|
5
|
+
* Displays an error or warning message with an icon.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <ScalarFormError variant="error">Something went wrong</ScalarFormError>
|
|
9
|
+
*/
|
|
10
|
+
declare const _default: typeof __VLS_export;
|
|
11
|
+
export default _default;
|
|
12
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
|
|
3
13
|
/** The variant of the error */
|
|
4
|
-
variant?:
|
|
14
|
+
variant?: "error" | "warning";
|
|
5
15
|
/** Whether to show the icon */
|
|
6
16
|
icon?: Component | undefined;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export default _default;
|
|
17
|
+
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
|
|
18
|
+
/** The variant of the error */
|
|
19
|
+
variant?: "error" | "warning";
|
|
20
|
+
/** Whether to show the icon */
|
|
21
|
+
icon?: Component | undefined;
|
|
22
|
+
}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
23
|
+
default?: (props: {}) => any;
|
|
24
|
+
}>;
|
|
16
25
|
type __VLS_WithSlots<T, S> = T & {
|
|
17
26
|
new (): {
|
|
18
27
|
$slots: S;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarFormError.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarForm/ScalarFormError.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarFormError.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarForm/ScalarFormError.vue"],"names":[],"mappings":"AA2DA,OAAO,EAAE,KAAK,SAAS,EAAY,MAAM,KAAK,CAAA;AAG9C;;;;;;;GAOG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;IAEhB,+BAA+B;cACrB,OAAO,GAAG,SAAS;IAC7B,+BAA+B;WACxB,SAAS,GAAG,SAAS;;IAH5B,+BAA+B;cACrB,OAAO,GAAG,SAAS;IAC7B,+BAA+B;WACxB,SAAS,GAAG,SAAS;;cAkEhB,CAAC,KAAK,IAAgB,KAAK,GAAG;EASxC,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarFormError.vue.js","names":[],"sources":["../../../src/components/ScalarForm/ScalarFormError.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIconWarning, ScalarIconWarningCircle } from '@scalar/icons'\nimport { cva, useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { type Component, computed } from 'vue'\n\nconst { variant = 'error', icon } = defineProps<{\n /** The variant of the error */\n variant?: 'error' | 'warning'\n /** Whether to show the icon */\n icon?: Component | undefined\n}>()\n\nconst iconIs = computed(() => {\n if (icon) {\n return icon\n }\n return variant === 'error' ? ScalarIconWarningCircle : ScalarIconWarning\n})\n\nconst variants = cva({\n base: 'flex items-baseline gap-1.5 rounded border p-2',\n variants: {\n variant: {\n error: 'border-c-danger bg-b-danger text-c-danger',\n warning: 'border-c-alert bg-b-alert text-c-alert',\n },\n },\n})\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <div\n role=\"alert\"\n v-bind=\"cx(variants({ variant }))\">\n <component\n :is=\"iconIs\"\n class=\"relative top-0.5 shrink-0\"\n weight=\"bold\" />\n <slot />\n </div>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ScalarFormError.vue.js","names":[],"sources":["../../../src/components/ScalarForm/ScalarFormError.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Form Error component\n *\n * Displays an error or warning message with an icon.\n *\n * @example\n * <ScalarFormError variant=\"error\">Something went wrong</ScalarFormError>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { ScalarIconWarning, ScalarIconWarningCircle } from '@scalar/icons'\nimport { cva, useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { type Component, computed } from 'vue'\n\nconst { variant = 'error', icon } = defineProps<{\n /** The variant of the error */\n variant?: 'error' | 'warning'\n /** Whether to show the icon */\n icon?: Component | undefined\n}>()\n\nconst iconIs = computed(() => {\n if (icon) {\n return icon\n }\n return variant === 'error' ? ScalarIconWarningCircle : ScalarIconWarning\n})\n\nconst variants = cva({\n base: 'flex items-baseline gap-1.5 rounded border p-2',\n variants: {\n variant: {\n error: 'border-c-danger bg-b-danger text-c-danger',\n warning: 'border-c-alert bg-b-alert text-c-alert',\n },\n },\n})\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <div\n role=\"alert\"\n v-bind=\"cx(variants({ variant }))\">\n <component\n :is=\"iconIs\"\n class=\"relative top-0.5 shrink-0\"\n weight=\"bold\" />\n <slot />\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { cva, useBindCx } from "@scalar/use-hooks/useBindCx";
|
|
2
2
|
import { computed, createBlock, createElementBlock, defineComponent, mergeProps, openBlock, renderSlot, resolveDynamicComponent, unref } from "vue";
|
|
3
3
|
import { ScalarIconWarning, ScalarIconWarningCircle } from "@scalar/icons";
|
|
4
|
-
//#region src/components/ScalarForm/ScalarFormError.vue?vue&type=script&setup=true&lang.ts
|
|
5
4
|
var ScalarFormError_vue_vue_type_script_setup_true_lang_default = /* @__PURE__ */ defineComponent({
|
|
6
5
|
inheritAttrs: false,
|
|
7
6
|
__name: "ScalarFormError",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarFormError.vue.script.js","names":[],"sources":["../../../src/components/ScalarForm/ScalarFormError.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ScalarIconWarning, ScalarIconWarningCircle } from '@scalar/icons'\nimport { cva, useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { type Component, computed } from 'vue'\n\nconst { variant = 'error', icon } = defineProps<{\n /** The variant of the error */\n variant?: 'error' | 'warning'\n /** Whether to show the icon */\n icon?: Component | undefined\n}>()\n\nconst iconIs = computed(() => {\n if (icon) {\n return icon\n }\n return variant === 'error' ? ScalarIconWarningCircle : ScalarIconWarning\n})\n\nconst variants = cva({\n base: 'flex items-baseline gap-1.5 rounded border p-2',\n variants: {\n variant: {\n error: 'border-c-danger bg-b-danger text-c-danger',\n warning: 'border-c-alert bg-b-alert text-c-alert',\n },\n },\n})\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <div\n role=\"alert\"\n v-bind=\"cx(variants({ variant }))\">\n <component\n :is=\"iconIs\"\n class=\"relative top-0.5 shrink-0\"\n weight=\"bold\" />\n <slot />\n </div>\n</template>\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarFormError.vue.script.js","names":[],"sources":["../../../src/components/ScalarForm/ScalarFormError.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Form Error component\n *\n * Displays an error or warning message with an icon.\n *\n * @example\n * <ScalarFormError variant=\"error\">Something went wrong</ScalarFormError>\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { ScalarIconWarning, ScalarIconWarningCircle } from '@scalar/icons'\nimport { cva, useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { type Component, computed } from 'vue'\n\nconst { variant = 'error', icon } = defineProps<{\n /** The variant of the error */\n variant?: 'error' | 'warning'\n /** Whether to show the icon */\n icon?: Component | undefined\n}>()\n\nconst iconIs = computed(() => {\n if (icon) {\n return icon\n }\n return variant === 'error' ? ScalarIconWarningCircle : ScalarIconWarning\n})\n\nconst variants = cva({\n base: 'flex items-baseline gap-1.5 rounded border p-2',\n variants: {\n variant: {\n error: 'border-c-danger bg-b-danger text-c-danger',\n warning: 'border-c-alert bg-b-alert text-c-alert',\n },\n },\n})\n\ndefineOptions({ inheritAttrs: false })\nconst { cx } = useBindCx()\n</script>\n<template>\n <div\n role=\"alert\"\n v-bind=\"cx(variants({ variant }))\">\n <component\n :is=\"iconIs\"\n class=\"relative top-0.5 shrink-0\"\n weight=\"bold\" />\n <slot />\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;EAuBA,MAAM,SAAS,eAAe;AAC5B,OAAI,QAAA,KACF,QAAO,QAAA;AAET,UAAO,QAAA,YAAY,UAAU,0BAA0B;IACxD;EAED,MAAM,WAAW,IAAI;GACnB,MAAM;GACN,UAAU,EACR,SAAS;IACP,OAAO;IACP,SAAS;IACV,EACF;GACF,CAAA;EAGD,MAAM,EAAE,OAAO,WAAU;;uBAGvB,mBAQM,OARN,WAQM,EAPJ,MAAK,SAAO,EACJ,MAAA,GAAE,CAAC,MAAA,SAAQ,CAAA,EAAA,SAAG,QAAA,SAAO,CAAA,CAAA,CAAA,EAAA,EAAA,WAAA,EAC7B,YAGkB,wBAFX,OAAA,MAAM,EAAA;IACX,OAAM;IACN,QAAO;QACT,WAAQ,KAAA,QAAA,UAAA,CAAA,EAAA,GAAA"}
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import type { HotKeyModifier } from './types';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Scalar Hotkey component
|
|
4
|
+
*
|
|
5
|
+
* Displays a keyboard shortcut as styled key caps.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <ScalarHotkey hotkey="k" :modifier="['Meta']" />
|
|
9
|
+
*/
|
|
7
10
|
declare const _default: typeof __VLS_export;
|
|
8
11
|
export default _default;
|
|
12
|
+
declare const __VLS_export: import("vue").DefineComponent<{
|
|
13
|
+
hotkey: string;
|
|
14
|
+
modifier?: HotKeyModifier[];
|
|
15
|
+
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
|
|
16
|
+
hotkey: string;
|
|
17
|
+
modifier?: HotKeyModifier[];
|
|
18
|
+
}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
9
19
|
//# sourceMappingURL=ScalarHotkey.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarHotkey.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarHotkey/ScalarHotkey.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ScalarHotkey.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarHotkey/ScalarHotkey.vue"],"names":[],"mappings":"AAwDA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAG7C;;;;;;;GAOG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;YAER,MAAM;eACH,cAAc,EAAE;;YADnB,MAAM;eACH,cAAc,EAAE;iGA6DzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarHotkey.vue.js","names":[],"sources":["../../../src/components/ScalarHotkey/ScalarHotkey.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { computed } from 'vue'\n\nimport { formatHotkeySymbols, getKeyLabel } from './formatHotkey'\nimport type { HotKeyModifier } from './types'\n\nconst { modifier = ['Meta'], hotkey } = defineProps<{\n hotkey: string\n modifier?: HotKeyModifier[]\n}>()\n\nconst { cx } = useBindCx()\ndefineOptions({ inheritAttrs: false })\n\nconst hotkeyChars = computed(() => formatHotkeySymbols(hotkey, modifier))\n</script>\n<template>\n <div\n v-bind=\"\n cx(\n 'border-(--scalar-background-3) inline-flex gap-0.5 overflow-hidden rounded border text-xxs rounded-b p-1 font-medium uppercase leading-none',\n )\n \">\n <div\n v-for=\"(char, i) in hotkeyChars\"\n :key=\"i\">\n <span\n aria-hidden=\"true\"\n class=\"contents\">\n {{ char }}\n </span>\n <span class=\"sr-only\">\n {{ getKeyLabel(char) }}\n </span>\n </div>\n </div>\n</template>\n"],"mappings":""}
|
|
1
|
+
{"version":3,"file":"ScalarHotkey.vue.js","names":[],"sources":["../../../src/components/ScalarHotkey/ScalarHotkey.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Hotkey component\n *\n * Displays a keyboard shortcut as styled key caps.\n *\n * @example\n * <ScalarHotkey hotkey=\"k\" :modifier=\"['Meta']\" />\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { computed } from 'vue'\n\nimport { formatHotkeySymbols, getKeyLabel } from './formatHotkey'\nimport type { HotKeyModifier } from './types'\n\nconst { modifier = ['Meta'], hotkey } = defineProps<{\n hotkey: string\n modifier?: HotKeyModifier[]\n}>()\n\nconst { cx } = useBindCx()\ndefineOptions({ inheritAttrs: false })\n\nconst hotkeyChars = computed(() => formatHotkeySymbols(hotkey, modifier))\n</script>\n<template>\n <div\n v-bind=\"\n cx(\n 'border-(--scalar-background-3) inline-flex gap-0.5 overflow-hidden rounded border text-xxs rounded-b p-1 font-medium uppercase leading-none',\n )\n \">\n <div\n v-for=\"(char, i) in hotkeyChars\"\n :key=\"i\">\n <span\n aria-hidden=\"true\"\n class=\"contents\">\n {{ char }}\n </span>\n <span class=\"sr-only\">\n {{ getKeyLabel(char) }}\n </span>\n </div>\n </div>\n</template>\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScalarHotkey.vue.script.js","names":[],"sources":["../../../src/components/ScalarHotkey/ScalarHotkey.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { computed } from 'vue'\n\nimport { formatHotkeySymbols, getKeyLabel } from './formatHotkey'\nimport type { HotKeyModifier } from './types'\n\nconst { modifier = ['Meta'], hotkey } = defineProps<{\n hotkey: string\n modifier?: HotKeyModifier[]\n}>()\n\nconst { cx } = useBindCx()\ndefineOptions({ inheritAttrs: false })\n\nconst hotkeyChars = computed(() => formatHotkeySymbols(hotkey, modifier))\n</script>\n<template>\n <div\n v-bind=\"\n cx(\n 'border-(--scalar-background-3) inline-flex gap-0.5 overflow-hidden rounded border text-xxs rounded-b p-1 font-medium uppercase leading-none',\n )\n \">\n <div\n v-for=\"(char, i) in hotkeyChars\"\n :key=\"i\">\n <span\n aria-hidden=\"true\"\n class=\"contents\">\n {{ char }}\n </span>\n <span class=\"sr-only\">\n {{ getKeyLabel(char) }}\n </span>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"ScalarHotkey.vue.script.js","names":[],"sources":["../../../src/components/ScalarHotkey/ScalarHotkey.vue"],"sourcesContent":["<script lang=\"ts\">\n/**\n * Scalar Hotkey component\n *\n * Displays a keyboard shortcut as styled key caps.\n *\n * @example\n * <ScalarHotkey hotkey=\"k\" :modifier=\"['Meta']\" />\n */\nexport default {}\n</script>\n<script setup lang=\"ts\">\nimport { useBindCx } from '@scalar/use-hooks/useBindCx'\nimport { computed } from 'vue'\n\nimport { formatHotkeySymbols, getKeyLabel } from './formatHotkey'\nimport type { HotKeyModifier } from './types'\n\nconst { modifier = ['Meta'], hotkey } = defineProps<{\n hotkey: string\n modifier?: HotKeyModifier[]\n}>()\n\nconst { cx } = useBindCx()\ndefineOptions({ inheritAttrs: false })\n\nconst hotkeyChars = computed(() => formatHotkeySymbols(hotkey, modifier))\n</script>\n<template>\n <div\n v-bind=\"\n cx(\n 'border-(--scalar-background-3) inline-flex gap-0.5 overflow-hidden rounded border text-xxs rounded-b p-1 font-medium uppercase leading-none',\n )\n \">\n <div\n v-for=\"(char, i) in hotkeyChars\"\n :key=\"i\">\n <span\n aria-hidden=\"true\"\n class=\"contents\">\n {{ char }}\n </span>\n <span class=\"sr-only\">\n {{ getKeyLabel(char) }}\n </span>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;EAuBA,MAAM,EAAE,OAAO,WAAU;EAGzB,MAAM,cAAc,eAAe,oBAAoB,QAAA,QAAQ,QAAA,SAAS,CAAA;;uBAGtE,mBAkBM,OAAA,eAAA,mBAjBW,MAAA,GAAE,CAAA,8IAAA,CAAA,CAAA,EAAA,EAAA,UAAA,KAAA,EAKjB,mBAWM,UAAA,MAAA,WAVgB,YAAA,QAAZ,MAAM,MAAC;wBADjB,mBAWM,OAAA,EATH,KAAK,GAAC,EAAA,CACP,mBAIO,QAJP,YAIO,gBADF,KAAI,EAAA,EAAA,EAET,mBAEO,QAFP,YAEO,gBADF,MAAA,YAAW,CAAC,KAAI,CAAA,EAAA,EAAA,CAAA,CAAA"}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Icon List component
|
|
3
|
+
*
|
|
4
|
+
* Displays all available icons in a grid for browsing and selection.
|
|
5
|
+
* Clicking an icon copies its name to the clipboard.
|
|
6
|
+
* Used internally in Storybook for icon discovery.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* <IconList />
|
|
10
|
+
*/
|
|
5
11
|
declare const _default: typeof __VLS_export;
|
|
6
12
|
export default _default;
|
|
13
|
+
declare const __VLS_export: import("vue").DefineComponent<{
|
|
14
|
+
thickness?: string;
|
|
15
|
+
}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
|
|
16
|
+
thickness?: string;
|
|
17
|
+
}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
7
18
|
//# sourceMappingURL=IconList.vue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconList.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarIcon/IconList.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IconList.vue.d.ts","sourceRoot":"","sources":["../../../src/components/ScalarIcon/IconList.vue"],"names":[],"mappings":"AAkEA;;;;;;;;;GASG;wBACkB,OAAO,YAAY;AAAxC,wBAAyC;AAGzC,QAAA,MAAM,YAAY;gBAEJ,MAAM;;gBAAN,MAAM;iGA6HhB,CAAC"}
|