@eslamdevui/ui 3.2.0-beta.1 → 3.2.0-beta.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/.nuxt/ui/alert.ts +5 -0
- package/.nuxt/ui/badge.ts +5 -0
- package/.nuxt/ui/button-group.ts +13 -0
- package/.nuxt/ui/button.ts +5 -0
- package/.nuxt/ui/carousel.ts +5 -0
- package/.nuxt/ui/content/content-navigation.ts +339 -0
- package/.nuxt/ui/content/content-search-button.ts +6 -0
- package/.nuxt/ui/content/content-search.ts +6 -0
- package/.nuxt/ui/content/content-surround.ts +39 -0
- package/.nuxt/ui/content/content-toc.ts +150 -0
- package/.nuxt/ui/content/index.ts +5 -0
- package/.nuxt/ui/content-surround.ts +5 -0
- package/.nuxt/ui/content-toc.ts +6 -6
- package/.nuxt/ui/dashboard-navbar.ts +5 -0
- package/.nuxt/ui/dashboard-sidebar-collapse.ts +5 -0
- package/.nuxt/ui/dashboard-sidebar-toggle.ts +5 -0
- package/.nuxt/ui/dashboard-sidebar.ts +10 -0
- package/.nuxt/ui/error.ts +9 -0
- package/.nuxt/ui/index.ts +48 -1
- package/.nuxt/ui/input-menu.ts +9 -0
- package/.nuxt/ui/input-number.ts +5 -0
- package/.nuxt/ui/input-tags.ts +9 -0
- package/.nuxt/ui/input.ts +9 -0
- package/.nuxt/ui/prose/a.ts +6 -0
- package/.nuxt/ui/prose/accordion-item.ts +3 -0
- package/.nuxt/ui/prose/accordion.ts +6 -0
- package/.nuxt/ui/prose/badge.ts +3 -0
- package/.nuxt/ui/prose/blockquote.ts +3 -0
- package/.nuxt/ui/prose/callout.ts +129 -0
- package/.nuxt/ui/prose/card-group.ts +3 -0
- package/.nuxt/ui/prose/card.ts +119 -0
- package/.nuxt/ui/prose/code-collapse.ts +19 -0
- package/.nuxt/ui/prose/code-group.ts +13 -0
- package/.nuxt/ui/prose/code-icon.ts +66 -0
- package/.nuxt/ui/prose/code-preview.ts +14 -0
- package/.nuxt/ui/prose/code-tree.ts +28 -0
- package/.nuxt/ui/prose/code.ts +27 -0
- package/.nuxt/ui/prose/collapsible.ts +12 -0
- package/.nuxt/ui/prose/em.ts +3 -0
- package/.nuxt/ui/prose/field-group.ts +3 -0
- package/.nuxt/ui/prose/field.ts +11 -0
- package/.nuxt/ui/prose/h1.ts +6 -0
- package/.nuxt/ui/prose/h2.ts +14 -0
- package/.nuxt/ui/prose/h3.ts +14 -0
- package/.nuxt/ui/prose/h4.ts +6 -0
- package/.nuxt/ui/prose/hr.ts +3 -0
- package/.nuxt/ui/prose/icon.ts +3 -0
- package/.nuxt/ui/prose/img.ts +3 -0
- package/.nuxt/ui/prose/index.ts +41 -0
- package/.nuxt/ui/prose/kbd.ts +3 -0
- package/.nuxt/ui/prose/li.ts +3 -0
- package/.nuxt/ui/prose/ol.ts +3 -0
- package/.nuxt/ui/prose/p.ts +3 -0
- package/.nuxt/ui/prose/pre.ts +17 -0
- package/.nuxt/ui/prose/steps.ts +19 -0
- package/.nuxt/ui/prose/strong.ts +3 -0
- package/.nuxt/ui/prose/table.ts +6 -0
- package/.nuxt/ui/prose/tabs-item.ts +3 -0
- package/.nuxt/ui/prose/tabs.ts +5 -0
- package/.nuxt/ui/prose/tbody.ts +3 -0
- package/.nuxt/ui/prose/td.ts +3 -0
- package/.nuxt/ui/prose/th.ts +3 -0
- package/.nuxt/ui/prose/thead.ts +3 -0
- package/.nuxt/ui/prose/tr.ts +3 -0
- package/.nuxt/ui/prose/ul.ts +3 -0
- package/.nuxt/ui/select-menu.ts +9 -0
- package/.nuxt/ui/select.ts +9 -0
- package/.nuxt/ui/textarea.ts +9 -0
- package/.nuxt/ui/toast.ts +5 -0
- package/LICENSE.md +9 -9
- package/README.md +147 -147
- package/cli/commands/make/component.mjs +95 -95
- package/cli/commands/make/index.mjs +14 -14
- package/cli/commands/make/locale.mjs +64 -64
- package/cli/index.mjs +15 -15
- package/cli/package.json +13 -13
- package/cli/templates.mjs +236 -228
- package/cli/utils.mjs +31 -31
- package/dist/module.json +1 -1
- package/dist/module.mjs +18 -13
- package/dist/runtime/components/Accordion.vue +36 -36
- package/dist/runtime/components/Alert.vue +46 -46
- package/dist/runtime/components/App.vue +10 -10
- package/dist/runtime/components/Avatar.vue +27 -27
- package/dist/runtime/components/AvatarGroup.vue +4 -4
- package/dist/runtime/components/Badge.vue +16 -16
- package/dist/runtime/components/Breadcrumb.vue +32 -32
- package/dist/runtime/components/Button.vue +28 -28
- package/dist/runtime/components/ButtonGroup.vue +3 -3
- package/dist/runtime/components/Calendar.vue +74 -74
- package/dist/runtime/components/Card.vue +13 -13
- package/dist/runtime/components/Carousel.vue +58 -58
- package/dist/runtime/components/ChatMessage.vue +35 -35
- package/dist/runtime/components/ChatMessages.vue +71 -71
- package/dist/runtime/components/ChatMessages.vue.d.ts +1 -2
- package/dist/runtime/components/ChatPrompt.vue +30 -31
- package/dist/runtime/components/ChatPrompt.vue.d.ts +4 -4
- package/dist/runtime/components/ChatPromptSubmit.vue +10 -10
- package/dist/runtime/components/Checkbox.vue +33 -33
- package/dist/runtime/components/CheckboxGroup.vue +32 -32
- package/dist/runtime/components/Chip.vue +11 -11
- package/dist/runtime/components/Collapsible.vue +9 -9
- package/dist/runtime/components/ColorPicker.vue +30 -30
- package/dist/runtime/components/CommandPalette.vue +117 -117
- package/dist/runtime/components/Container.vue +3 -3
- package/dist/runtime/components/ContextMenu.vue +22 -22
- package/dist/runtime/components/ContextMenuContent.vue +105 -105
- package/dist/runtime/components/DashboardGroup.vue +3 -3
- package/dist/runtime/components/DashboardNavbar.vue +41 -41
- package/dist/runtime/components/DashboardNavbar.vue.d.ts +1 -1
- package/dist/runtime/components/DashboardPanel.vue +29 -29
- package/dist/runtime/components/DashboardPanel.vue.d.ts +1 -1
- package/dist/runtime/components/DashboardResizeHandle.vue +7 -7
- package/dist/runtime/components/DashboardSearch.vue +24 -25
- package/dist/runtime/components/DashboardSearch.vue.d.ts +3 -3
- package/dist/runtime/components/DashboardSearchButton.vue +63 -41
- package/dist/runtime/components/DashboardSearchButton.vue.d.ts +7 -1
- package/dist/runtime/components/DashboardSidebar.vue +77 -77
- package/dist/runtime/components/DashboardSidebarCollapse.vue +7 -7
- package/dist/runtime/components/DashboardSidebarCollapse.vue.d.ts +1 -1
- package/dist/runtime/components/DashboardSidebarToggle.vue +14 -17
- package/dist/runtime/components/DashboardSidebarToggle.vue.d.ts +4 -6
- package/dist/runtime/components/Drawer.vue +55 -55
- package/dist/runtime/components/DropdownMenu.vue +24 -24
- package/dist/runtime/components/DropdownMenuContent.vue +107 -107
- package/dist/runtime/components/Error.vue +57 -0
- package/dist/runtime/components/Error.vue.d.ts +52 -0
- package/dist/runtime/components/Form.vue +8 -8
- package/dist/runtime/components/Form.vue.d.ts +1 -1
- package/dist/runtime/components/FormField.vue +37 -37
- package/dist/runtime/components/Icon.vue +1 -1
- package/dist/runtime/components/Input.vue +34 -34
- package/dist/runtime/components/InputMenu.vue +163 -163
- package/dist/runtime/components/InputNumber.vue +49 -49
- package/dist/runtime/components/InputTags.vue +55 -55
- package/dist/runtime/components/Kbd.vue +5 -5
- package/dist/runtime/components/Link.vue +14 -14
- package/dist/runtime/components/LinkBase.vue +8 -8
- package/dist/runtime/components/Modal.vue +69 -69
- package/dist/runtime/components/NavigationMenu.vue +166 -166
- package/dist/runtime/components/OverlayProvider.vue +9 -9
- package/dist/runtime/components/Pagination.vue +47 -47
- package/dist/runtime/components/PinInput.vue +20 -20
- package/dist/runtime/components/Popover.vue +17 -17
- package/dist/runtime/components/Progress.vue +19 -19
- package/dist/runtime/components/RadioGroup.vue +43 -43
- package/dist/runtime/components/Select.vue +96 -96
- package/dist/runtime/components/SelectMenu.vue +130 -130
- package/dist/runtime/components/Separator.vue +15 -15
- package/dist/runtime/components/Skeleton.vue +10 -10
- package/dist/runtime/components/Slideover.vue +76 -76
- package/dist/runtime/components/Slider.vue +27 -27
- package/dist/runtime/components/Stepper.vue +51 -51
- package/dist/runtime/components/Switch.vue +33 -33
- package/dist/runtime/components/Table.vue +77 -77
- package/dist/runtime/components/Tabs.vue +37 -37
- package/dist/runtime/components/Textarea.vue +33 -33
- package/dist/runtime/components/Timeline.vue +38 -38
- package/dist/runtime/components/Toast.vue +69 -69
- package/dist/runtime/components/Toaster.vue +28 -28
- package/dist/runtime/components/Tooltip.vue +19 -19
- package/dist/runtime/components/Tree.vue +60 -60
- package/dist/runtime/components/color-mode/ColorModeAvatar.vue +2 -2
- package/dist/runtime/components/color-mode/ColorModeAvatar.vue.d.ts +2 -2
- package/dist/runtime/components/color-mode/ColorModeButton.vue +16 -16
- package/dist/runtime/components/color-mode/ColorModeButton.vue.d.ts +3 -3
- package/dist/runtime/components/color-mode/ColorModeImage.vue +2 -2
- package/dist/runtime/components/color-mode/ColorModeSelect.vue +19 -19
- package/dist/runtime/components/color-mode/ColorModeSelect.vue.d.ts +1 -1
- package/dist/runtime/components/color-mode/ColorModeSwitch.vue +19 -19
- package/dist/runtime/components/color-mode/ColorModeSwitch.vue.d.ts +1 -1
- package/dist/runtime/components/content/ContentNavigation.vue +175 -0
- package/dist/runtime/components/content/ContentNavigation.vue.d.ts +53 -0
- package/dist/runtime/components/content/ContentSearch.vue +184 -0
- package/dist/runtime/components/content/ContentSearch.vue.d.ts +111 -0
- package/dist/runtime/components/content/ContentSearchButton.vue +95 -0
- package/dist/runtime/components/content/ContentSearchButton.vue.d.ts +12 -0
- package/dist/runtime/components/content/ContentSurround.vue +61 -0
- package/dist/runtime/components/content/ContentSurround.vue.d.ts +59 -0
- package/dist/runtime/components/content/ContentToc.vue +146 -0
- package/dist/runtime/components/content/ContentToc.vue.d.ts +88 -0
- package/dist/runtime/components/locale/LocaleSelect.vue +20 -20
- package/dist/runtime/components/locale/LocaleSelect.vue.d.ts +1 -1
- package/dist/runtime/components/prose/A.vue +24 -0
- package/dist/runtime/components/prose/A.vue.d.ts +15 -0
- package/dist/runtime/components/prose/Accordion.vue +43 -0
- package/dist/runtime/components/prose/Accordion.vue.d.ts +16 -0
- package/dist/runtime/components/prose/AccordionItem.vue +25 -0
- package/dist/runtime/components/prose/AccordionItem.vue.d.ts +15 -0
- package/dist/runtime/components/prose/Badge.vue +21 -0
- package/dist/runtime/components/prose/Badge.vue.d.ts +13 -0
- package/dist/runtime/components/prose/Blockquote.vue +21 -0
- package/dist/runtime/components/prose/Blockquote.vue.d.ts +13 -0
- package/dist/runtime/components/prose/Callout.vue +60 -0
- package/dist/runtime/components/prose/Callout.vue.d.ts +26 -0
- package/dist/runtime/components/prose/Card.vue +83 -0
- package/dist/runtime/components/prose/Card.vue.d.ts +30 -0
- package/dist/runtime/components/prose/CardGroup.vue +21 -0
- package/dist/runtime/components/prose/CardGroup.vue.d.ts +13 -0
- package/dist/runtime/components/prose/Code.vue +23 -0
- package/dist/runtime/components/prose/Code.vue.d.ts +22 -0
- package/dist/runtime/components/prose/CodeCollapse.vue +44 -0
- package/dist/runtime/components/prose/CodeCollapse.vue.d.ts +46 -0
- package/dist/runtime/components/prose/CodeGroup.vue +70 -0
- package/dist/runtime/components/prose/CodeGroup.vue.d.ts +37 -0
- package/dist/runtime/components/prose/CodeIcon.vue +28 -0
- package/dist/runtime/components/prose/CodeIcon.vue.d.ts +24 -0
- package/dist/runtime/components/prose/CodePreview.vue +28 -0
- package/dist/runtime/components/prose/CodePreview.vue.d.ts +19 -0
- package/dist/runtime/components/prose/CodeTree.vue +160 -0
- package/dist/runtime/components/prose/CodeTree.vue.d.ts +30 -0
- package/dist/runtime/components/prose/Collapsible.vue +41 -0
- package/dist/runtime/components/prose/Collapsible.vue.d.ts +38 -0
- package/dist/runtime/components/prose/Em.vue +19 -0
- package/dist/runtime/components/prose/Em.vue.d.ts +13 -0
- package/dist/runtime/components/prose/Field.vue +48 -0
- package/dist/runtime/components/prose/Field.vue.d.ts +39 -0
- package/dist/runtime/components/prose/FieldGroup.vue +23 -0
- package/dist/runtime/components/prose/FieldGroup.vue.d.ts +18 -0
- package/dist/runtime/components/prose/H1.vue +28 -0
- package/dist/runtime/components/prose/H1.vue.d.ts +19 -0
- package/dist/runtime/components/prose/H2.vue +32 -0
- package/dist/runtime/components/prose/H2.vue.d.ts +19 -0
- package/dist/runtime/components/prose/H3.vue +32 -0
- package/dist/runtime/components/prose/H3.vue.d.ts +19 -0
- package/dist/runtime/components/prose/H4.vue +28 -0
- package/dist/runtime/components/prose/H4.vue.d.ts +19 -0
- package/dist/runtime/components/prose/Hr.vue +18 -0
- package/dist/runtime/components/prose/Hr.vue.d.ts +5 -0
- package/dist/runtime/components/prose/Icon.vue +19 -0
- package/dist/runtime/components/prose/Icon.vue.d.ts +6 -0
- package/dist/runtime/components/prose/Img.vue +40 -0
- package/dist/runtime/components/prose/Img.vue.d.ts +9 -0
- package/dist/runtime/components/prose/Kbd.vue +19 -0
- package/dist/runtime/components/prose/Kbd.vue.d.ts +6 -0
- package/dist/runtime/components/prose/Li.vue +21 -0
- package/dist/runtime/components/prose/Li.vue.d.ts +13 -0
- package/dist/runtime/components/prose/Ol.vue +21 -0
- package/dist/runtime/components/prose/Ol.vue.d.ts +13 -0
- package/dist/runtime/components/prose/P.vue +21 -0
- package/dist/runtime/components/prose/P.vue.d.ts +13 -0
- package/dist/runtime/components/prose/Pre.vue +63 -0
- package/dist/runtime/components/prose/Pre.vue.d.ts +25 -0
- package/dist/runtime/components/prose/Script.vue +12 -0
- package/dist/runtime/components/prose/Script.vue.d.ts +12 -0
- package/dist/runtime/components/prose/Steps.vue +22 -0
- package/dist/runtime/components/prose/Steps.vue.d.ts +22 -0
- package/dist/runtime/components/prose/Strong.vue +21 -0
- package/dist/runtime/components/prose/Strong.vue.d.ts +13 -0
- package/dist/runtime/components/prose/Table.vue +24 -0
- package/dist/runtime/components/prose/Table.vue.d.ts +18 -0
- package/dist/runtime/components/prose/Tabs.vue +78 -0
- package/dist/runtime/components/prose/Tabs.vue.d.ts +36 -0
- package/dist/runtime/components/prose/TabsItem.vue +25 -0
- package/dist/runtime/components/prose/TabsItem.vue.d.ts +15 -0
- package/dist/runtime/components/prose/Tbody.vue +21 -0
- package/dist/runtime/components/prose/Tbody.vue.d.ts +13 -0
- package/dist/runtime/components/prose/Td.vue +21 -0
- package/dist/runtime/components/prose/Td.vue.d.ts +13 -0
- package/dist/runtime/components/prose/Th.vue +21 -0
- package/dist/runtime/components/prose/Th.vue.d.ts +13 -0
- package/dist/runtime/components/prose/Thead.vue +21 -0
- package/dist/runtime/components/prose/Thead.vue.d.ts +13 -0
- package/dist/runtime/components/prose/Tr.vue +21 -0
- package/dist/runtime/components/prose/Tr.vue.d.ts +13 -0
- package/dist/runtime/components/prose/Ul.vue +21 -0
- package/dist/runtime/components/prose/Ul.vue.d.ts +13 -0
- package/dist/runtime/components/prose/callout/Caution.vue +11 -0
- package/dist/runtime/components/prose/callout/Caution.vue.d.ts +14 -0
- package/dist/runtime/components/prose/callout/Note.vue +11 -0
- package/dist/runtime/components/prose/callout/Note.vue.d.ts +14 -0
- package/dist/runtime/components/prose/callout/Tip.vue +11 -0
- package/dist/runtime/components/prose/callout/Tip.vue.d.ts +14 -0
- package/dist/runtime/components/prose/callout/Warning.vue +11 -0
- package/dist/runtime/components/prose/callout/Warning.vue.d.ts +14 -0
- package/dist/runtime/composables/useAvatarGroup.d.ts +1 -1
- package/dist/runtime/composables/useComponentIcons.d.ts +1 -1
- package/dist/runtime/composables/useFormField.d.ts +2 -2
- package/dist/runtime/composables/usePortal.d.ts +1 -1
- package/dist/runtime/composables/useResizable.d.ts +1 -1
- package/dist/runtime/inertia/components/Link.vue +12 -12
- package/dist/runtime/inertia/components/LinkBase.vue +15 -15
- package/dist/runtime/types/app.config.d.ts +6 -6
- package/dist/runtime/types/content.d.ts +4 -1
- package/dist/runtime/types/content.js +4 -0
- package/dist/runtime/types/index.d.ts +1 -0
- package/dist/runtime/types/index.js +1 -0
- package/dist/runtime/types/prose.d.ts +42 -1
- package/dist/runtime/types/prose.js +42 -0
- package/dist/runtime/types/tv.d.ts +2 -2
- package/dist/runtime/utils/index.d.ts +1 -1
- package/dist/runtime/utils/index.js +13 -4
- package/dist/runtime/vue/components/Icon.vue +1 -1
- package/dist/runtime/vue/components/Link.vue +31 -31
- package/dist/runtime/vue/components/color-mode/ColorModeButton.vue +7 -7
- package/dist/runtime/vue/components/color-mode/ColorModeSelect.vue +7 -7
- package/dist/runtime/vue/components/color-mode/ColorModeSwitch.vue +7 -7
- package/dist/shared/{ui.BcVNrqyb.mjs → ui.DQZ75GCP.mjs} +183 -180
- package/dist/unplugin.mjs +9 -9
- package/dist/vite.mjs +1 -1
- package/package.json +8 -9
- package/vue-plugin.d.ts +5 -5
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import theme from "#build/ui/content-navigation";
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script setup>
|
|
6
|
+
import { computed } from "vue";
|
|
7
|
+
import { useRoute, useAppConfig } from "#imports";
|
|
8
|
+
import { Primitive, AccordionRoot, AccordionItem, AccordionTrigger, AccordionContent, useForwardPropsEmits } from "reka-ui";
|
|
9
|
+
import { reactivePick, createReusableTemplate } from "@vueuse/core";
|
|
10
|
+
import { pickLinkProps } from "../../utils/link";
|
|
11
|
+
import { tv } from "../../utils/tv";
|
|
12
|
+
import { mapContentNavigationItem } from "../../utils/content";
|
|
13
|
+
import UBadge from "../Badge.vue";
|
|
14
|
+
import UIcon from "../Icon.vue";
|
|
15
|
+
import ULink from "../Link.vue";
|
|
16
|
+
import ULinkBase from "../LinkBase.vue";
|
|
17
|
+
const props = defineProps({
|
|
18
|
+
as: { type: null, required: false, default: "nav" },
|
|
19
|
+
defaultOpen: { type: Boolean, required: false, default: void 0 },
|
|
20
|
+
trailingIcon: { type: String, required: false },
|
|
21
|
+
color: { type: null, required: false },
|
|
22
|
+
variant: { type: null, required: false },
|
|
23
|
+
highlight: { type: Boolean, required: false, default: false },
|
|
24
|
+
highlightColor: { type: null, required: false },
|
|
25
|
+
collapsible: { type: Boolean, required: false, default: true },
|
|
26
|
+
level: { type: Number, required: false, default: 0 },
|
|
27
|
+
navigation: { type: Array, required: false },
|
|
28
|
+
class: { type: null, required: false },
|
|
29
|
+
ui: { type: Object, required: false },
|
|
30
|
+
disabled: { type: Boolean, required: false },
|
|
31
|
+
type: { type: String, required: false, default: "multiple" },
|
|
32
|
+
unmountOnHide: { type: Boolean, required: false, default: true }
|
|
33
|
+
});
|
|
34
|
+
const emits = defineEmits(["update:modelValue"]);
|
|
35
|
+
const slots = defineSlots();
|
|
36
|
+
const rootProps = useForwardPropsEmits(reactivePick(props, "collapsible", "disabled", "type", "unmountOnHide"), emits);
|
|
37
|
+
const route = useRoute();
|
|
38
|
+
const appConfig = useAppConfig();
|
|
39
|
+
const [DefineLinkTemplate, ReuseLinkTemplate] = createReusableTemplate();
|
|
40
|
+
const ui = computed(
|
|
41
|
+
() => tv({ extend: tv(theme), ...appConfig.ui?.contentNavigation || {} })({
|
|
42
|
+
color: props.color,
|
|
43
|
+
variant: props.variant,
|
|
44
|
+
highlight: props.highlight,
|
|
45
|
+
highlightColor: props.highlightColor || props.color
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
const defaultValue = computed(() => {
|
|
49
|
+
if (props.defaultOpen === false) return void 0;
|
|
50
|
+
if (props.defaultOpen === void 0) {
|
|
51
|
+
if (props.type === "single") {
|
|
52
|
+
return "0";
|
|
53
|
+
} else {
|
|
54
|
+
return props.navigation?.map((link, idx) => link.defaultOpen !== false ? String(idx) : void 0).filter((v) => typeof v === "string");
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const index = props.navigation?.findIndex((link) => route.path.startsWith(link.path || ""));
|
|
58
|
+
return props.type === "multiple" ? [String(index === -1 ? 0 : index)] : String(index === -1 ? 0 : index);
|
|
59
|
+
});
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<template>
|
|
63
|
+
<DefineLinkTemplate v-slot="{ link, active }">
|
|
64
|
+
<slot name="link" :link="link" :active="active">
|
|
65
|
+
<slot name="link-leading" :link="link" :active="active">
|
|
66
|
+
<UIcon
|
|
67
|
+
v-if="link.icon"
|
|
68
|
+
:name="link.icon"
|
|
69
|
+
:class="ui.linkLeadingIcon({ class: [props.ui?.linkLeadingIcon, link.ui?.linkLeadingIcon], active })"
|
|
70
|
+
/>
|
|
71
|
+
</slot>
|
|
72
|
+
|
|
73
|
+
<span
|
|
74
|
+
v-if="link.title || !!slots['link-title']"
|
|
75
|
+
:class="ui.linkTitle({ class: [props.ui?.linkTitle, link.ui?.linkTitle], active })"
|
|
76
|
+
>
|
|
77
|
+
<slot name="link-title" :link="link" :active="active">
|
|
78
|
+
{{ link.title }}
|
|
79
|
+
</slot>
|
|
80
|
+
|
|
81
|
+
<UIcon
|
|
82
|
+
v-if="link.target === '_blank'"
|
|
83
|
+
:name="appConfig.ui.icons.external"
|
|
84
|
+
:class="ui.linkTitleExternalIcon({ class: [props.ui?.linkTitleExternalIcon, link.ui?.linkTitleExternalIcon], active })"
|
|
85
|
+
/>
|
|
86
|
+
</span>
|
|
87
|
+
|
|
88
|
+
<span
|
|
89
|
+
v-if="link.badge || link.children?.length && !props.disabled || link.trailingIcon || !!slots['link-trailing']"
|
|
90
|
+
:class="ui.linkTrailing({ class: [props.ui?.linkTrailing, link.ui?.linkTrailing] })"
|
|
91
|
+
>
|
|
92
|
+
<slot name="link-trailing" :link="link" :active="active">
|
|
93
|
+
<UBadge
|
|
94
|
+
v-if="link.badge"
|
|
95
|
+
color="neutral"
|
|
96
|
+
variant="outline"
|
|
97
|
+
:size="props.ui?.linkTrailingBadgeSize || ui.linkTrailingBadgeSize()"
|
|
98
|
+
v-bind="typeof link.badge === 'string' || typeof link.badge === 'number' ? { label: link.badge } : link.badge"
|
|
99
|
+
:class="ui.linkTrailingBadge({ class: props.ui?.linkTrailingBadge })"
|
|
100
|
+
/>
|
|
101
|
+
|
|
102
|
+
<UIcon
|
|
103
|
+
v-if="link.children?.length && !props.disabled"
|
|
104
|
+
:name="link.trailingIcon || props.trailingIcon || appConfig.ui.icons.chevronDown"
|
|
105
|
+
:class="ui.linkTrailingIcon({ class: [props.ui?.linkTrailingIcon, link.ui?.linkTrailingIcon] })"
|
|
106
|
+
/>
|
|
107
|
+
|
|
108
|
+
<UIcon
|
|
109
|
+
v-else-if="link.trailingIcon"
|
|
110
|
+
:name="link.trailingIcon"
|
|
111
|
+
:class="ui.linkTrailingIcon({ class: [props.ui?.linkTrailingIcon, link.ui?.linkTrailingIcon] })"
|
|
112
|
+
/>
|
|
113
|
+
</slot>
|
|
114
|
+
</span>
|
|
115
|
+
</slot>
|
|
116
|
+
</DefineLinkTemplate>
|
|
117
|
+
|
|
118
|
+
<Primitive :as="props.as" :as-child="props.level > 0" :class="ui.root({ class: [props.ui?.root, props.class] })">
|
|
119
|
+
<AccordionRoot
|
|
120
|
+
as="ul"
|
|
121
|
+
v-bind="rootProps"
|
|
122
|
+
:default-value="defaultValue"
|
|
123
|
+
:class="props.level > 0 ? ui.listWithChildren({ class: props.ui?.listWithChildren }) : ui.list({ class: props.ui?.list })"
|
|
124
|
+
>
|
|
125
|
+
<template v-for="(link, index) in props.navigation" :key="index">
|
|
126
|
+
<AccordionItem
|
|
127
|
+
v-if="link.children?.length"
|
|
128
|
+
as="li"
|
|
129
|
+
:value="String(index)"
|
|
130
|
+
:class="ui.itemWithChildren({ class: [props.ui?.itemWithChildren, link.ui?.itemWithChildren], level: props.level > 0 })"
|
|
131
|
+
>
|
|
132
|
+
<AccordionTrigger
|
|
133
|
+
as="button"
|
|
134
|
+
:class="[
|
|
135
|
+
ui.link({ class: [props.ui?.link, link.ui?.link, link.class], active: link.active, disabled: !!link.disabled }),
|
|
136
|
+
ui.trigger({ class: [props.ui?.trigger, link.ui?.trigger] })
|
|
137
|
+
]"
|
|
138
|
+
>
|
|
139
|
+
<ReuseLinkTemplate :link="link" :active="link.active" />
|
|
140
|
+
</AccordionTrigger>
|
|
141
|
+
|
|
142
|
+
<AccordionContent :class="ui.content({ class: [props.ui?.content, link.ui?.content] })">
|
|
143
|
+
<UContentNavigation
|
|
144
|
+
v-bind="rootProps"
|
|
145
|
+
:navigation="link.children"
|
|
146
|
+
:default-open="props.defaultOpen"
|
|
147
|
+
:level="props.level + 1"
|
|
148
|
+
:trailing-icon="props.trailingIcon"
|
|
149
|
+
:color="props.color"
|
|
150
|
+
:variant="props.variant"
|
|
151
|
+
:highlight="props.highlight"
|
|
152
|
+
:highlight-color="props.highlightColor"
|
|
153
|
+
:ui="props.ui"
|
|
154
|
+
>
|
|
155
|
+
<template v-for="(_, name) in slots" #[name]="slotData">
|
|
156
|
+
<slot :name="name" :link="slotData.link" :active="slotData.active" />
|
|
157
|
+
</template>
|
|
158
|
+
</UContentNavigation>
|
|
159
|
+
</AccordionContent>
|
|
160
|
+
</AccordionItem>
|
|
161
|
+
|
|
162
|
+
<li v-else :class="ui.item({ class: [props.ui?.item, link.ui?.item], level: props.level > 0 })">
|
|
163
|
+
<ULink v-slot="{ active, ...slotProps }" v-bind="pickLinkProps(mapContentNavigationItem(link))" custom>
|
|
164
|
+
<ULinkBase
|
|
165
|
+
v-bind="slotProps"
|
|
166
|
+
:class="ui.link({ class: [props.ui?.link, link.ui?.link, link.class], active, disabled: !!link.disabled, level: props.level > 0 })"
|
|
167
|
+
>
|
|
168
|
+
<ReuseLinkTemplate :link="link" :active="active" />
|
|
169
|
+
</ULinkBase>
|
|
170
|
+
</ULink>
|
|
171
|
+
</li>
|
|
172
|
+
</template>
|
|
173
|
+
</AccordionRoot>
|
|
174
|
+
</Primitive>
|
|
175
|
+
</template>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { AppConfig } from '@nuxt/schema';
|
|
2
|
+
import type { AccordionRootProps, AccordionRootEmits } from 'reka-ui';
|
|
3
|
+
import type { BadgeProps, LinkProps, ComponentConfig } from '../../types';
|
|
4
|
+
import type { ContentNavigationItem } from '@nuxt/content';
|
|
5
|
+
import theme from '#build/ui/content-navigation';
|
|
6
|
+
export type ContentNavigation = ComponentConfig<typeof theme, AppConfig, 'contentNavigation'>;
|
|
7
|
+
export interface ContentNavigationLink extends ContentNavigationItem {
|
|
8
|
+
icon?: string;
|
|
9
|
+
badge?: string | number | BadgeProps;
|
|
10
|
+
target?: LinkProps['target'];
|
|
11
|
+
trailingIcon?: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
children?: ContentNavigationLink[];
|
|
14
|
+
defaultOpen?: boolean;
|
|
15
|
+
active?: boolean;
|
|
16
|
+
class?: any;
|
|
17
|
+
ui?: Partial<ContentNavigation['slots']>;
|
|
18
|
+
}
|
|
19
|
+
export interface ContentNavigationProps<T extends ContentNavigationLink = ContentNavigationLink> extends Pick<AccordionRootProps, 'disabled' | 'type' | 'unmountOnHide'> {
|
|
20
|
+
as?: any;
|
|
21
|
+
defaultOpen?: boolean;
|
|
22
|
+
trailingIcon?: string;
|
|
23
|
+
color?: ContentNavigation['variants']['color'];
|
|
24
|
+
variant?: ContentNavigation['variants']['variant'];
|
|
25
|
+
highlight?: boolean;
|
|
26
|
+
highlightColor?: ContentNavigation['variants']['highlightColor'];
|
|
27
|
+
collapsible?: boolean;
|
|
28
|
+
level?: number;
|
|
29
|
+
navigation?: T[];
|
|
30
|
+
class?: any;
|
|
31
|
+
ui?: Partial<ContentNavigation['slots']>;
|
|
32
|
+
}
|
|
33
|
+
export interface ContentNavigationEmits extends AccordionRootEmits {
|
|
34
|
+
}
|
|
35
|
+
declare const _default: __VLS_WithSlots<import("vue").DefineComponent<ContentNavigationProps<ContentNavigationLink>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
36
|
+
"update:modelValue": (value: string | string[] | undefined) => any;
|
|
37
|
+
}, string, import("vue").PublicProps, Readonly<ContentNavigationProps<ContentNavigationLink>> & Readonly<{
|
|
38
|
+
"onUpdate:modelValue"?: ((value: string | string[] | undefined) => any) | undefined;
|
|
39
|
+
}>, {
|
|
40
|
+
type: "multiple" | "single";
|
|
41
|
+
collapsible: boolean;
|
|
42
|
+
as: any;
|
|
43
|
+
defaultOpen: boolean;
|
|
44
|
+
highlight: boolean;
|
|
45
|
+
unmountOnHide: boolean;
|
|
46
|
+
level: number;
|
|
47
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, __VLS_Slots>;
|
|
48
|
+
export default _default;
|
|
49
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
50
|
+
new (): {
|
|
51
|
+
$slots: S;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import theme from "#build/ui/content/content-search";
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script setup>
|
|
6
|
+
import {
|
|
7
|
+
computed,
|
|
8
|
+
useTemplateRef
|
|
9
|
+
} from "vue";
|
|
10
|
+
import {
|
|
11
|
+
useForwardProps,
|
|
12
|
+
useAppConfig,
|
|
13
|
+
useColorMode,
|
|
14
|
+
defineShortcuts
|
|
15
|
+
} from "#imports";
|
|
16
|
+
import {
|
|
17
|
+
reactivePick,
|
|
18
|
+
defu
|
|
19
|
+
} from "@vueuse/core";
|
|
20
|
+
import {
|
|
21
|
+
useContentSearch
|
|
22
|
+
} from "../../composables/useContentSearch";
|
|
23
|
+
import {
|
|
24
|
+
useLocalePro
|
|
25
|
+
} from "../../composables/useLocalePro";
|
|
26
|
+
import {
|
|
27
|
+
transformUI,
|
|
28
|
+
omit
|
|
29
|
+
} from "../../utils";
|
|
30
|
+
import { tv } from "../../utils/tv";
|
|
31
|
+
import UModal from "../Modal.vue";
|
|
32
|
+
import UCommandPalette from "../CommandPalette.vue";
|
|
33
|
+
const props = defineProps({
|
|
34
|
+
icon: { type: String, required: false },
|
|
35
|
+
placeholder: { type: String, required: false },
|
|
36
|
+
autofocus: { type: Boolean, required: false },
|
|
37
|
+
loading: { type: Boolean, required: false },
|
|
38
|
+
loadingIcon: { type: String, required: false },
|
|
39
|
+
close: { type: [Boolean, Object], required: false },
|
|
40
|
+
closeIcon: { type: String, required: false },
|
|
41
|
+
shortcut: { type: String, required: false },
|
|
42
|
+
links: { type: Array, required: false },
|
|
43
|
+
navigation: { type: Array, required: false },
|
|
44
|
+
groups: { type: Array, required: false },
|
|
45
|
+
files: { type: Array, required: false },
|
|
46
|
+
fuse: { type: Object, required: false },
|
|
47
|
+
colorMode: { type: Boolean, required: false },
|
|
48
|
+
class: { type: null, required: false },
|
|
49
|
+
ui: { type: void 0, required: false }
|
|
50
|
+
});
|
|
51
|
+
const slots = defineSlots();
|
|
52
|
+
const searchTerm = defineModel("searchTerm", { type: String, default: "" });
|
|
53
|
+
const { t } = useLocalePro();
|
|
54
|
+
const { open } = useContentSearch();
|
|
55
|
+
const colorMode = useColorMode();
|
|
56
|
+
const appConfig = useAppConfig();
|
|
57
|
+
const commandPaletteProps = useForwardProps(reactivePick(
|
|
58
|
+
props,
|
|
59
|
+
"icon",
|
|
60
|
+
"placeholder",
|
|
61
|
+
"autofocus",
|
|
62
|
+
"loading",
|
|
63
|
+
"loadingIcon",
|
|
64
|
+
"close",
|
|
65
|
+
"closeIcon"
|
|
66
|
+
));
|
|
67
|
+
const proxySlots = omit(slots, ["content"]);
|
|
68
|
+
const fuse = computed(() => defu({
|
|
69
|
+
fuseOptions: { includeMatches: true }
|
|
70
|
+
}, props.fuse));
|
|
71
|
+
const ui = computed(
|
|
72
|
+
() => tv({ extend: tv(theme), ...appConfig.ui?.contentSearch || {} })()
|
|
73
|
+
);
|
|
74
|
+
function mapLinksItems(links) {
|
|
75
|
+
return links.flatMap((link) => [
|
|
76
|
+
{
|
|
77
|
+
...link,
|
|
78
|
+
suffix: link.description,
|
|
79
|
+
icon: link.icon || appConfig.ui.icons.file
|
|
80
|
+
},
|
|
81
|
+
...link.children?.map((child) => ({
|
|
82
|
+
...child,
|
|
83
|
+
prefix: `${link.label} >`,
|
|
84
|
+
suffix: child.description,
|
|
85
|
+
icon: child.icon || link.icon || appConfig.ui.icons.file
|
|
86
|
+
})) || []
|
|
87
|
+
]);
|
|
88
|
+
}
|
|
89
|
+
function mapNavigationItems(children, parent) {
|
|
90
|
+
return children.flatMap(
|
|
91
|
+
(link) => link.children?.length ? mapNavigationItems(link.children, link) : props.files?.filter((file) => file.id === link.path || file.id.startsWith(`${link.path}#`))?.map((file) => mapFile(file, link, parent)) || []
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
function mapFile(file, link, parent) {
|
|
95
|
+
const prefix = [...new Set([parent?.title, ...file.titles].filter(Boolean))].join(" > ");
|
|
96
|
+
return {
|
|
97
|
+
prefix: prefix ? `${prefix} >` : void 0,
|
|
98
|
+
label: file.id === link.path ? link.title : file.title,
|
|
99
|
+
suffix: file.content.replaceAll("<", "<").replaceAll(">", ">"),
|
|
100
|
+
to: file.id,
|
|
101
|
+
icon: link.icon || parent?.icon || (file.level > 1 ? appConfig.ui.icons.hash : appConfig.ui.icons.file),
|
|
102
|
+
level: file.level
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function postFilter(query, items) {
|
|
106
|
+
return query ? items : items?.filter((item) => item.level === 1);
|
|
107
|
+
}
|
|
108
|
+
function onSelect(item) {
|
|
109
|
+
if (!item.disabled) {
|
|
110
|
+
open.value = false;
|
|
111
|
+
searchTerm.value = "";
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
defineShortcuts({
|
|
115
|
+
[props.shortcut || "meta_k"]: {
|
|
116
|
+
usingInput: true,
|
|
117
|
+
handler: () => open.value = !open.value
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const groups = computed(() => {
|
|
121
|
+
const result = [];
|
|
122
|
+
if (props.links?.length) {
|
|
123
|
+
result.push({ id: "links", label: t("contentSearch.links"), items: mapLinksItems(props.links) });
|
|
124
|
+
}
|
|
125
|
+
if (props.navigation?.length) {
|
|
126
|
+
if (props.navigation.some((link) => link.children?.length)) {
|
|
127
|
+
result.push(...props.navigation.map((group) => ({
|
|
128
|
+
id: group.path,
|
|
129
|
+
label: group.title,
|
|
130
|
+
items: mapNavigationItems(group.children || []),
|
|
131
|
+
postFilter
|
|
132
|
+
})));
|
|
133
|
+
} else {
|
|
134
|
+
result.push({ id: "docs", items: mapNavigationItems(props.navigation), postFilter });
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
if (props.groups?.length) result.push(...props.groups);
|
|
138
|
+
if (props.colorMode && !colorMode?.forced) {
|
|
139
|
+
result.push({
|
|
140
|
+
id: "theme",
|
|
141
|
+
label: t("contentSearch.theme"),
|
|
142
|
+
items: ["system", "light", "dark"].map((mode) => ({
|
|
143
|
+
label: t(`colorMode.${mode}`),
|
|
144
|
+
icon: appConfig.ui.icons[mode],
|
|
145
|
+
active: colorMode.preference === mode,
|
|
146
|
+
onSelect: () => {
|
|
147
|
+
colorMode.preference = mode;
|
|
148
|
+
}
|
|
149
|
+
}))
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
return result;
|
|
153
|
+
});
|
|
154
|
+
const commandPaletteRef = useTemplateRef("commandPaletteRef");
|
|
155
|
+
defineExpose({ commandPaletteRef });
|
|
156
|
+
</script>
|
|
157
|
+
|
|
158
|
+
<template>
|
|
159
|
+
<UModal
|
|
160
|
+
v-model:open="open"
|
|
161
|
+
:title="t('contentSearch.title')"
|
|
162
|
+
:description="t('contentSearch.description')"
|
|
163
|
+
:class="ui.modal({ class: props.class })"
|
|
164
|
+
>
|
|
165
|
+
<template #content>
|
|
166
|
+
<slot name="content">
|
|
167
|
+
<UCommandPalette
|
|
168
|
+
ref="commandPaletteRef"
|
|
169
|
+
v-model:search-term="searchTerm"
|
|
170
|
+
v-bind="commandPaletteProps"
|
|
171
|
+
:groups="groups"
|
|
172
|
+
:fuse="fuse"
|
|
173
|
+
:ui="transformUI(omit(ui, ['modal']), props.ui)"
|
|
174
|
+
@update:model-value="onSelect"
|
|
175
|
+
@update:open="open = $event"
|
|
176
|
+
>
|
|
177
|
+
<template v-for="(_, name) in proxySlots" #[name]="slotData">
|
|
178
|
+
<slot :name="name" v-bind="slotData" />
|
|
179
|
+
</template>
|
|
180
|
+
</UCommandPalette>
|
|
181
|
+
</slot>
|
|
182
|
+
</template>
|
|
183
|
+
</UModal>
|
|
184
|
+
</template>
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import theme from '#build/ui/content/content-search';
|
|
2
|
+
import type { ContentNavigationItem } from '@nuxt/content';
|
|
3
|
+
import type { AppConfig } from '@nuxt/schema';
|
|
4
|
+
import type { ButtonProps, InputProps, LinkProps, ModalProps, CommandPaletteProps, CommandPaletteSlots, CommandPaletteGroup, CommandPaletteItem, ComponentConfig } from '../../types';
|
|
5
|
+
import type { UseFuseOptions } from '@vueuse/integrations/useFuse';
|
|
6
|
+
type ContentSearch = ComponentConfig<typeof theme, AppConfig, 'contentSearch'>;
|
|
7
|
+
export interface ContentSearchLink extends Omit<LinkProps, 'custom'> {
|
|
8
|
+
label?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
/**
|
|
11
|
+
* @IconifyIcon
|
|
12
|
+
*/
|
|
13
|
+
icon?: string;
|
|
14
|
+
children?: ContentSearchLink[];
|
|
15
|
+
}
|
|
16
|
+
export interface ContentSearchFile {
|
|
17
|
+
id: string;
|
|
18
|
+
title: string;
|
|
19
|
+
titles: string[];
|
|
20
|
+
level: number;
|
|
21
|
+
content: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ContentSearchItem extends Omit<LinkProps, 'custom'>, CommandPaletteItem {
|
|
24
|
+
level?: number;
|
|
25
|
+
/**
|
|
26
|
+
* @IconifyIcon
|
|
27
|
+
*/
|
|
28
|
+
icon?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ContentSearchProps<T extends ContentSearchLink = ContentSearchLink> extends /* @vue-ignore */ Pick<ModalProps, 'title' | 'description' | 'overlay' | 'transition' | 'content' | 'dismissible' | 'fullscreen' | 'modal' | 'portal'> {
|
|
31
|
+
/**
|
|
32
|
+
* The icon displayed in the input.
|
|
33
|
+
* @defaultValue appConfig.ui.icons.search
|
|
34
|
+
* @IconifyIcon
|
|
35
|
+
*/
|
|
36
|
+
icon?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The placeholder text for the input.
|
|
39
|
+
* @defaultValue t('commandPalette.placeholder')
|
|
40
|
+
*/
|
|
41
|
+
placeholder?: InputProps['placeholder'];
|
|
42
|
+
/**
|
|
43
|
+
* Automatically focus the input when component is mounted.
|
|
44
|
+
* @defaultValue true
|
|
45
|
+
*/
|
|
46
|
+
autofocus?: boolean;
|
|
47
|
+
/** When `true`, the loading icon will be displayed. */
|
|
48
|
+
loading?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The icon when the `loading` prop is `true`.
|
|
51
|
+
* @defaultValue appConfig.ui.icons.loading
|
|
52
|
+
* @IconifyIcon
|
|
53
|
+
*/
|
|
54
|
+
loadingIcon?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Display a close button in the input (useful when inside a Modal for example).
|
|
57
|
+
* `{ size: 'md', color: 'neutral', variant: 'ghost' }`{lang="ts-type"}
|
|
58
|
+
* @emits 'update:open'
|
|
59
|
+
* @defaultValue true
|
|
60
|
+
*/
|
|
61
|
+
close?: boolean | Partial<ButtonProps>;
|
|
62
|
+
/**
|
|
63
|
+
* The icon displayed in the close button.
|
|
64
|
+
* @defaultValue appConfig.ui.icons.close
|
|
65
|
+
* @IconifyIcon
|
|
66
|
+
*/
|
|
67
|
+
closeIcon?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Keyboard shortcut to open the search (used by [`defineShortcuts`](https://ui.nuxt.com/composables/define-shortcuts))
|
|
70
|
+
* @defaultValue 'meta_k'
|
|
71
|
+
*/
|
|
72
|
+
shortcut?: string;
|
|
73
|
+
/** Links group displayed as the first group in the command palette. */
|
|
74
|
+
links?: T[];
|
|
75
|
+
navigation?: ContentNavigationItem[];
|
|
76
|
+
/** Custom groups displayed between navigation and color mode group. */
|
|
77
|
+
groups?: CommandPaletteGroup<ContentSearchItem>[];
|
|
78
|
+
files?: ContentSearchFile[];
|
|
79
|
+
/**
|
|
80
|
+
* Options for [useFuse](https://vueuse.org/integrations/useFuse) passed to the [CommandPalette](https://ui.nuxt.com/components/command-palette).
|
|
81
|
+
* @defaultValue { fuseOptions: { includeMatches: true } }
|
|
82
|
+
*/
|
|
83
|
+
fuse?: UseFuseOptions<T>;
|
|
84
|
+
/**
|
|
85
|
+
* When `true`, the theme command will be added to the groups.
|
|
86
|
+
* @defaultValue true
|
|
87
|
+
*/
|
|
88
|
+
colorMode?: boolean;
|
|
89
|
+
class?: any;
|
|
90
|
+
ui?: ContentSearch['slots'] & CommandPaletteProps<CommandPaletteGroup<ContentSearchItem>, ContentSearchItem>['ui'];
|
|
91
|
+
}
|
|
92
|
+
export type ContentSearchSlots = CommandPaletteSlots<CommandPaletteGroup<ContentSearchItem>, ContentSearchItem> & {
|
|
93
|
+
content(props?: {}): any;
|
|
94
|
+
};
|
|
95
|
+
declare const _default: __VLS_WithSlots<import("vue").DefineComponent<ContentSearchProps<ContentSearchLink> & {
|
|
96
|
+
searchTerm?: string;
|
|
97
|
+
}, {
|
|
98
|
+
commandPaletteRef: Readonly<import("vue").ShallowRef<any>>;
|
|
99
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
100
|
+
"update:searchTerm": (value: string) => any;
|
|
101
|
+
}, string, import("vue").PublicProps, Readonly<ContentSearchProps<ContentSearchLink> & {
|
|
102
|
+
searchTerm?: string;
|
|
103
|
+
}> & Readonly<{
|
|
104
|
+
"onUpdate:searchTerm"?: ((value: string) => any) | undefined;
|
|
105
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, ContentSearchSlots>;
|
|
106
|
+
export default _default;
|
|
107
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
108
|
+
new (): {
|
|
109
|
+
$slots: S;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import theme from "#build/ui/content/content-search-button";
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<script setup>
|
|
6
|
+
import { computed } from "vue";
|
|
7
|
+
import { defu } from "defu";
|
|
8
|
+
import { useForwardProps } from "reka-ui";
|
|
9
|
+
import { reactivePick, createReusableTemplate } from "@vueuse/core";
|
|
10
|
+
import { useAppConfig } from "#imports";
|
|
11
|
+
import { useContentSearch } from "../../composables/useContentSearch";
|
|
12
|
+
import { useLocalePro } from "../../composables/useLocalePro";
|
|
13
|
+
import { transformUI, omit } from "../../utils";
|
|
14
|
+
import { tv } from "../../utils/tv";
|
|
15
|
+
import UTooltip from "../Tooltip.vue";
|
|
16
|
+
const props = defineProps({
|
|
17
|
+
icon: { type: String, required: false },
|
|
18
|
+
label: { type: String, required: false },
|
|
19
|
+
color: { type: null, required: false, default: "neutral" },
|
|
20
|
+
variant: { type: null, required: false },
|
|
21
|
+
size: { type: null, required: false },
|
|
22
|
+
collapsed: { type: Boolean, required: false, default: true },
|
|
23
|
+
tooltip: { type: [Boolean, Object], required: false, default: false },
|
|
24
|
+
kbds: { type: Array, required: false, default: () => ["meta", "k"] },
|
|
25
|
+
ui: { type: void 0, required: false },
|
|
26
|
+
class: { type: null, required: false }
|
|
27
|
+
});
|
|
28
|
+
const slots = defineSlots();
|
|
29
|
+
const [DefineButtonTemplate, ReuseButtonTemplate] = createReusableTemplate();
|
|
30
|
+
const { open } = useContentSearch();
|
|
31
|
+
const { t } = useLocalePro();
|
|
32
|
+
const appConfig = useAppConfig();
|
|
33
|
+
const rootProps = useForwardProps(reactivePick(props, "color", "size"));
|
|
34
|
+
const ui = computed(
|
|
35
|
+
() => tv({
|
|
36
|
+
extend: tv(theme),
|
|
37
|
+
...appConfig.ui?.contentSearchButton
|
|
38
|
+
})()
|
|
39
|
+
);
|
|
40
|
+
const proxySlots = omit(slots, ["trailing"]);
|
|
41
|
+
const tooltipProps = computed(
|
|
42
|
+
() => defu(typeof props.tooltip === "boolean" ? {} : props.tooltip, {
|
|
43
|
+
delayDuration: 0,
|
|
44
|
+
content: { side: "right" }
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
|
+
</script>
|
|
48
|
+
|
|
49
|
+
<template>
|
|
50
|
+
<DefineButtonTemplate>
|
|
51
|
+
<UButton
|
|
52
|
+
:icon="icon || appConfig.ui.icons.search"
|
|
53
|
+
:label="label || t('contentSearchButton.label')"
|
|
54
|
+
:variant="variant || (collapsed ? 'ghost' : 'outline')"
|
|
55
|
+
v-bind="{
|
|
56
|
+
...rootProps,
|
|
57
|
+
...collapsed ? {
|
|
58
|
+
'square': true,
|
|
59
|
+
'label': void 0,
|
|
60
|
+
'aria-label': label || t('contentSearchButton.label')
|
|
61
|
+
} : {}
|
|
62
|
+
}"
|
|
63
|
+
:class="ui.base({ class: [props.ui?.base, props.class] })"
|
|
64
|
+
:ui="transformUI(ui, props.ui)"
|
|
65
|
+
@click="open = true"
|
|
66
|
+
>
|
|
67
|
+
<template v-for="(_, name) in proxySlots" #[name]="slotData">
|
|
68
|
+
<slot :name="name" v-bind="slotData" />
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<template v-if="!props.collapsed" #trailing>
|
|
72
|
+
<div :class="ui.trailing({ class: props.ui?.trailing })">
|
|
73
|
+
<slot name="trailing">
|
|
74
|
+
<UKbd
|
|
75
|
+
v-for="(kbd, index) in props.kbds"
|
|
76
|
+
:key="index"
|
|
77
|
+
variant="subtle"
|
|
78
|
+
v-bind="typeof kbd === 'string' ? { value: kbd } : kbd"
|
|
79
|
+
/>
|
|
80
|
+
</slot>
|
|
81
|
+
</div>
|
|
82
|
+
</template>
|
|
83
|
+
</UButton>
|
|
84
|
+
</DefineButtonTemplate>
|
|
85
|
+
|
|
86
|
+
<UTooltip
|
|
87
|
+
v-if="props.collapsed && props.tooltip"
|
|
88
|
+
:text="props.label || t('contentSearchButton.label')"
|
|
89
|
+
v-bind="tooltipProps"
|
|
90
|
+
>
|
|
91
|
+
<ReuseButtonTemplate />
|
|
92
|
+
</UTooltip>
|
|
93
|
+
|
|
94
|
+
<ReuseButtonTemplate v-else />
|
|
95
|
+
</template>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const _default: __VLS_WithSlots<import('vue').DefineComponent<ContentSearchButtonProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<ContentSearchButtonProps> & Readonly<{}>, {
|
|
2
|
+
color: 'error' | 'info' | 'primary' | 'secondary' | 'success' | 'warning' | 'neutral'
|
|
3
|
+
collapsed: boolean
|
|
4
|
+
tooltip: boolean | TooltipProps
|
|
5
|
+
kbds: KbdProps['value'][] | KbdProps[]
|
|
6
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>, ButtonSlots>
|
|
7
|
+
export default _default
|
|
8
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
9
|
+
new (): {
|
|
10
|
+
$slots: S
|
|
11
|
+
}
|
|
12
|
+
}
|