@nuxt/ui 2.8.0 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/module.d.mts +1147 -1096
- package/dist/module.d.ts +1147 -1096
- package/dist/module.json +1 -1
- package/dist/module.mjs +35 -10
- package/dist/runtime/components/data/Table.vue +42 -29
- package/dist/runtime/components/data/Table.vue.d.ts +20 -13
- package/dist/runtime/components/elements/Accordion.vue +25 -22
- package/dist/runtime/components/elements/Accordion.vue.d.ts +21 -17
- package/dist/runtime/components/elements/Alert.vue +22 -18
- package/dist/runtime/components/elements/Alert.vue.d.ts +26 -19
- package/dist/runtime/components/elements/Avatar.vue +22 -16
- package/dist/runtime/components/elements/Avatar.vue.d.ts +28 -19
- package/dist/runtime/components/elements/AvatarGroup.d.ts +17 -8
- package/dist/runtime/components/elements/AvatarGroup.mjs +18 -13
- package/dist/runtime/components/elements/Badge.vue +21 -17
- package/dist/runtime/components/elements/Badge.vue.d.ts +28 -19
- package/dist/runtime/components/elements/Button.vue +22 -18
- package/dist/runtime/components/elements/Button.vue.d.ts +26 -17
- package/dist/runtime/components/elements/ButtonGroup.d.ts +17 -8
- package/dist/runtime/components/elements/ButtonGroup.mjs +22 -15
- package/dist/runtime/components/elements/Dropdown.vue +15 -13
- package/dist/runtime/components/elements/Dropdown.vue.d.ts +20 -17
- package/dist/runtime/components/elements/Kbd.vue +16 -12
- package/dist/runtime/components/elements/Kbd.vue.d.ts +20 -12
- package/dist/runtime/components/elements/Link.vue +18 -5
- package/dist/runtime/components/forms/Checkbox.vue +27 -17
- package/dist/runtime/components/forms/Checkbox.vue.d.ts +33 -15
- package/dist/runtime/components/forms/Form.vue +4 -5
- package/dist/runtime/components/forms/Form.vue.d.ts +1 -1
- package/dist/runtime/components/forms/FormGroup.vue +51 -27
- package/dist/runtime/components/forms/FormGroup.vue.d.ts +23 -15
- package/dist/runtime/components/forms/Input.vue +36 -28
- package/dist/runtime/components/forms/Input.vue.d.ts +41 -23
- package/dist/runtime/components/forms/Radio.vue +27 -17
- package/dist/runtime/components/forms/Radio.vue.d.ts +35 -17
- package/dist/runtime/components/forms/Range.vue +26 -16
- package/dist/runtime/components/forms/Range.vue.d.ts +36 -17
- package/dist/runtime/components/forms/Select.vue +34 -26
- package/dist/runtime/components/forms/Select.vue.d.ts +42 -24
- package/dist/runtime/components/forms/SelectMenu.vue +43 -33
- package/dist/runtime/components/forms/SelectMenu.vue.d.ts +49 -30
- package/dist/runtime/components/forms/Textarea.vue +38 -30
- package/dist/runtime/components/forms/Textarea.vue.d.ts +41 -23
- package/dist/runtime/components/forms/Toggle.vue +26 -15
- package/dist/runtime/components/forms/Toggle.vue.d.ts +31 -12
- package/dist/runtime/components/layout/Card.vue +15 -10
- package/dist/runtime/components/layout/Card.vue.d.ts +17 -9
- package/dist/runtime/components/layout/Container.vue +15 -10
- package/dist/runtime/components/layout/Container.vue.d.ts +17 -9
- package/dist/runtime/components/layout/Skeleton.vue +15 -10
- package/dist/runtime/components/layout/Skeleton.vue.d.ts +17 -9
- package/dist/runtime/components/navigation/CommandPalette.vue +50 -38
- package/dist/runtime/components/navigation/CommandPalette.vue.d.ts +23 -22
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue +1 -1
- package/dist/runtime/components/navigation/CommandPaletteGroup.vue.d.ts +3 -4
- package/dist/runtime/components/navigation/Pagination.vue +65 -56
- package/dist/runtime/components/navigation/Pagination.vue.d.ts +29 -22
- package/dist/runtime/components/navigation/Tabs.vue +16 -13
- package/dist/runtime/components/navigation/Tabs.vue.d.ts +18 -11
- package/dist/runtime/components/navigation/VerticalNavigation.vue +15 -13
- package/dist/runtime/components/navigation/VerticalNavigation.vue.d.ts +20 -16
- package/dist/runtime/components/overlays/ContextMenu.vue +14 -9
- package/dist/runtime/components/overlays/ContextMenu.vue.d.ts +18 -10
- package/dist/runtime/components/overlays/Modal.vue +15 -13
- package/dist/runtime/components/overlays/Modal.vue.d.ts +17 -10
- package/dist/runtime/components/overlays/Notification.vue +18 -14
- package/dist/runtime/components/overlays/Notification.vue.d.ts +25 -19
- package/dist/runtime/components/overlays/Notifications.vue +18 -12
- package/dist/runtime/components/overlays/Notifications.vue.d.ts +22 -14
- package/dist/runtime/components/overlays/Popover.vue +18 -16
- package/dist/runtime/components/overlays/Popover.vue.d.ts +18 -11
- package/dist/runtime/components/overlays/Slideover.vue +15 -13
- package/dist/runtime/components/overlays/Slideover.vue.d.ts +17 -10
- package/dist/runtime/components/overlays/Tooltip.vue +15 -13
- package/dist/runtime/components/overlays/Tooltip.vue.d.ts +18 -11
- package/dist/runtime/composables/useFormGroup.d.ts +12 -2
- package/dist/runtime/composables/useFormGroup.mjs +10 -4
- package/dist/runtime/composables/usePopper.mjs +40 -30
- package/dist/runtime/composables/useToast.d.ts +3 -3
- package/dist/runtime/composables/useUI.d.ts +10 -0
- package/dist/runtime/composables/useUI.mjs +24 -0
- package/dist/runtime/types/avatar.d.ts +10 -4
- package/dist/runtime/types/badge.d.ts +14 -0
- package/dist/runtime/types/button.d.ts +10 -3
- package/dist/runtime/types/command-palette.d.ts +2 -1
- package/dist/runtime/types/form.d.ts +8 -1
- package/dist/runtime/types/index.d.ts +2 -0
- package/dist/runtime/types/link.d.ts +1 -0
- package/dist/runtime/types/notification.d.ts +5 -3
- package/dist/runtime/types/tabs.d.ts +1 -0
- package/dist/runtime/types/utils.d.ts +11 -0
- package/dist/runtime/ui.config.d.ts +1207 -0
- package/dist/runtime/{app.config.mjs → ui.config.mjs} +52 -80
- package/dist/runtime/utils/index.d.ts +5 -11
- package/dist/runtime/utils/index.mjs +21 -9
- package/dist/runtime/utils/lodash.d.ts +2 -0
- package/dist/runtime/utils/lodash.mjs +23 -0
- package/dist/runtime/utils/uid.d.ts +1 -0
- package/dist/runtime/utils/uid.mjs +4 -0
- package/dist/types.d.mts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +19 -21
- package/dist/runtime/app.config.d.ts +0 -1203
|
@@ -17,11 +17,13 @@
|
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
19
|
<script>
|
|
20
|
-
import { computed, defineComponent } from "vue";
|
|
21
|
-
import { omit } from "lodash-es";
|
|
20
|
+
import { computed, toRef, defineComponent } from "vue";
|
|
22
21
|
import { twMerge, twJoin } from "tailwind-merge";
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
22
|
+
import { useUI } from "../../composables/useUI";
|
|
23
|
+
import { mergeConfig } from "../../utils";
|
|
24
|
+
import appConfig from "#build/app.config";
|
|
25
|
+
import { card } from "#ui/ui.config";
|
|
26
|
+
const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.card, card);
|
|
25
27
|
export default defineComponent({
|
|
26
28
|
inheritAttrs: false,
|
|
27
29
|
props: {
|
|
@@ -29,14 +31,17 @@ export default defineComponent({
|
|
|
29
31
|
type: String,
|
|
30
32
|
default: "div"
|
|
31
33
|
},
|
|
34
|
+
class: {
|
|
35
|
+
type: [String, Object, Array],
|
|
36
|
+
default: void 0
|
|
37
|
+
},
|
|
32
38
|
ui: {
|
|
33
39
|
type: Object,
|
|
34
|
-
default:
|
|
40
|
+
default: void 0
|
|
35
41
|
}
|
|
36
42
|
},
|
|
37
|
-
setup(props
|
|
38
|
-
const
|
|
39
|
-
const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.card));
|
|
43
|
+
setup(props) {
|
|
44
|
+
const { ui, attrs } = useUI("card", toRef(props, "ui"), config);
|
|
40
45
|
const cardClass = computed(() => {
|
|
41
46
|
return twMerge(twJoin(
|
|
42
47
|
ui.value.base,
|
|
@@ -45,12 +50,12 @@ export default defineComponent({
|
|
|
45
50
|
ui.value.ring,
|
|
46
51
|
ui.value.shadow,
|
|
47
52
|
ui.value.background
|
|
48
|
-
),
|
|
53
|
+
), props.class);
|
|
49
54
|
});
|
|
50
55
|
return {
|
|
51
|
-
attrs: omit(attrs, ["class"]),
|
|
52
56
|
// eslint-disable-next-line vue/no-dupe-keys
|
|
53
57
|
ui,
|
|
58
|
+
attrs,
|
|
54
59
|
cardClass
|
|
55
60
|
};
|
|
56
61
|
}
|
|
@@ -1,31 +1,39 @@
|
|
|
1
|
-
/// <reference types="lodash" />
|
|
2
1
|
import type { PropType } from 'vue';
|
|
3
2
|
declare const _default: import("vue").DefineComponent<{
|
|
4
3
|
as: {
|
|
5
4
|
type: StringConstructor;
|
|
6
5
|
default: string;
|
|
7
6
|
};
|
|
8
|
-
|
|
7
|
+
class: {
|
|
9
8
|
type: PropType<any>;
|
|
10
|
-
default:
|
|
9
|
+
default: undefined;
|
|
10
|
+
};
|
|
11
|
+
ui: {
|
|
12
|
+
type: PropType<Partial<any>>;
|
|
13
|
+
default: undefined;
|
|
11
14
|
};
|
|
12
15
|
}, {
|
|
13
|
-
attrs: import("lodash").Omit<{
|
|
14
|
-
[x: string]: unknown;
|
|
15
|
-
}, "class">;
|
|
16
16
|
ui: import("vue").ComputedRef<any>;
|
|
17
|
+
attrs: import("vue").ComputedRef<Pick<{
|
|
18
|
+
[x: string]: unknown;
|
|
19
|
+
}, string>>;
|
|
17
20
|
cardClass: import("vue").ComputedRef<string>;
|
|
18
21
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
19
22
|
as: {
|
|
20
23
|
type: StringConstructor;
|
|
21
24
|
default: string;
|
|
22
25
|
};
|
|
23
|
-
|
|
26
|
+
class: {
|
|
24
27
|
type: PropType<any>;
|
|
25
|
-
default:
|
|
28
|
+
default: undefined;
|
|
29
|
+
};
|
|
30
|
+
ui: {
|
|
31
|
+
type: PropType<Partial<any>>;
|
|
32
|
+
default: undefined;
|
|
26
33
|
};
|
|
27
34
|
}>>, {
|
|
28
|
-
ui: any
|
|
35
|
+
ui: Partial<any>;
|
|
36
|
+
class: any;
|
|
29
37
|
as: string;
|
|
30
38
|
}, {}>;
|
|
31
39
|
export default _default;
|
|
@@ -5,11 +5,13 @@
|
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script>
|
|
8
|
-
import { computed, defineComponent } from "vue";
|
|
9
|
-
import { omit } from "lodash-es";
|
|
8
|
+
import { computed, toRef, defineComponent } from "vue";
|
|
10
9
|
import { twMerge, twJoin } from "tailwind-merge";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { useUI } from "../../composables/useUI";
|
|
11
|
+
import { mergeConfig } from "../../utils";
|
|
12
|
+
import appConfig from "#build/app.config";
|
|
13
|
+
import { container } from "#ui/ui.config";
|
|
14
|
+
const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.container, container);
|
|
13
15
|
export default defineComponent({
|
|
14
16
|
inheritAttrs: false,
|
|
15
17
|
props: {
|
|
@@ -17,25 +19,28 @@ export default defineComponent({
|
|
|
17
19
|
type: String,
|
|
18
20
|
default: "div"
|
|
19
21
|
},
|
|
22
|
+
class: {
|
|
23
|
+
type: [String, Object, Array],
|
|
24
|
+
default: void 0
|
|
25
|
+
},
|
|
20
26
|
ui: {
|
|
21
27
|
type: Object,
|
|
22
|
-
default:
|
|
28
|
+
default: void 0
|
|
23
29
|
}
|
|
24
30
|
},
|
|
25
|
-
setup(props
|
|
26
|
-
const
|
|
27
|
-
const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.container));
|
|
31
|
+
setup(props) {
|
|
32
|
+
const { ui, attrs } = useUI("container", toRef(props, "ui"), config);
|
|
28
33
|
const containerClass = computed(() => {
|
|
29
34
|
return twMerge(twJoin(
|
|
30
35
|
ui.value.base,
|
|
31
36
|
ui.value.padding,
|
|
32
37
|
ui.value.constrained
|
|
33
|
-
),
|
|
38
|
+
), props.class);
|
|
34
39
|
});
|
|
35
40
|
return {
|
|
36
|
-
attrs: omit(attrs, ["class"]),
|
|
37
41
|
// eslint-disable-next-line vue/no-dupe-keys
|
|
38
42
|
ui,
|
|
43
|
+
attrs,
|
|
39
44
|
containerClass
|
|
40
45
|
};
|
|
41
46
|
}
|
|
@@ -1,31 +1,39 @@
|
|
|
1
|
-
/// <reference types="lodash" />
|
|
2
1
|
import type { PropType } from 'vue';
|
|
3
2
|
declare const _default: import("vue").DefineComponent<{
|
|
4
3
|
as: {
|
|
5
4
|
type: StringConstructor;
|
|
6
5
|
default: string;
|
|
7
6
|
};
|
|
8
|
-
|
|
7
|
+
class: {
|
|
9
8
|
type: PropType<any>;
|
|
10
|
-
default:
|
|
9
|
+
default: undefined;
|
|
10
|
+
};
|
|
11
|
+
ui: {
|
|
12
|
+
type: PropType<Partial<any>>;
|
|
13
|
+
default: undefined;
|
|
11
14
|
};
|
|
12
15
|
}, {
|
|
13
|
-
attrs: import("lodash").Omit<{
|
|
14
|
-
[x: string]: unknown;
|
|
15
|
-
}, "class">;
|
|
16
16
|
ui: import("vue").ComputedRef<any>;
|
|
17
|
+
attrs: import("vue").ComputedRef<Pick<{
|
|
18
|
+
[x: string]: unknown;
|
|
19
|
+
}, string>>;
|
|
17
20
|
containerClass: import("vue").ComputedRef<string>;
|
|
18
21
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
19
22
|
as: {
|
|
20
23
|
type: StringConstructor;
|
|
21
24
|
default: string;
|
|
22
25
|
};
|
|
23
|
-
|
|
26
|
+
class: {
|
|
24
27
|
type: PropType<any>;
|
|
25
|
-
default:
|
|
28
|
+
default: undefined;
|
|
29
|
+
};
|
|
30
|
+
ui: {
|
|
31
|
+
type: PropType<Partial<any>>;
|
|
32
|
+
default: undefined;
|
|
26
33
|
};
|
|
27
34
|
}>>, {
|
|
28
|
-
ui: any
|
|
35
|
+
ui: Partial<any>;
|
|
36
|
+
class: any;
|
|
29
37
|
as: string;
|
|
30
38
|
}, {}>;
|
|
31
39
|
export default _default;
|
|
@@ -3,33 +3,38 @@
|
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script>
|
|
6
|
-
import { computed, defineComponent } from "vue";
|
|
7
|
-
import { omit } from "lodash-es";
|
|
6
|
+
import { computed, toRef, defineComponent } from "vue";
|
|
8
7
|
import { twMerge, twJoin } from "tailwind-merge";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { useUI } from "../../composables/useUI";
|
|
9
|
+
import { mergeConfig } from "../../utils";
|
|
10
|
+
import appConfig from "#build/app.config";
|
|
11
|
+
import { skeleton } from "#ui/ui.config";
|
|
12
|
+
const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.skeleton, skeleton);
|
|
11
13
|
export default defineComponent({
|
|
12
14
|
inheritAttrs: false,
|
|
13
15
|
props: {
|
|
16
|
+
class: {
|
|
17
|
+
type: [String, Object, Array],
|
|
18
|
+
default: void 0
|
|
19
|
+
},
|
|
14
20
|
ui: {
|
|
15
21
|
type: Object,
|
|
16
|
-
default:
|
|
22
|
+
default: void 0
|
|
17
23
|
}
|
|
18
24
|
},
|
|
19
|
-
setup(props
|
|
20
|
-
const
|
|
21
|
-
const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.skeleton));
|
|
25
|
+
setup(props) {
|
|
26
|
+
const { ui, attrs } = useUI("skeleton", toRef(props, "ui"), config);
|
|
22
27
|
const skeletonClass = computed(() => {
|
|
23
28
|
return twMerge(twJoin(
|
|
24
29
|
ui.value.base,
|
|
25
30
|
ui.value.background,
|
|
26
31
|
ui.value.rounded
|
|
27
|
-
),
|
|
32
|
+
), props.class);
|
|
28
33
|
});
|
|
29
34
|
return {
|
|
30
|
-
attrs: omit(attrs, ["class"]),
|
|
31
35
|
// eslint-disable-next-line vue/no-dupe-keys
|
|
32
36
|
ui,
|
|
37
|
+
attrs,
|
|
33
38
|
skeletonClass
|
|
34
39
|
};
|
|
35
40
|
}
|
|
@@ -1,22 +1,30 @@
|
|
|
1
|
-
/// <reference types="lodash" />
|
|
2
1
|
import type { PropType } from 'vue';
|
|
3
2
|
declare const _default: import("vue").DefineComponent<{
|
|
4
|
-
|
|
3
|
+
class: {
|
|
5
4
|
type: PropType<any>;
|
|
6
|
-
default:
|
|
5
|
+
default: undefined;
|
|
6
|
+
};
|
|
7
|
+
ui: {
|
|
8
|
+
type: PropType<Partial<any>>;
|
|
9
|
+
default: undefined;
|
|
7
10
|
};
|
|
8
11
|
}, {
|
|
9
|
-
attrs: import("lodash").Omit<{
|
|
10
|
-
[x: string]: unknown;
|
|
11
|
-
}, "class">;
|
|
12
12
|
ui: import("vue").ComputedRef<any>;
|
|
13
|
+
attrs: import("vue").ComputedRef<Pick<{
|
|
14
|
+
[x: string]: unknown;
|
|
15
|
+
}, string>>;
|
|
13
16
|
skeletonClass: import("vue").ComputedRef<string>;
|
|
14
17
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
15
|
-
|
|
18
|
+
class: {
|
|
16
19
|
type: PropType<any>;
|
|
17
|
-
default:
|
|
20
|
+
default: undefined;
|
|
21
|
+
};
|
|
22
|
+
ui: {
|
|
23
|
+
type: PropType<Partial<any>>;
|
|
24
|
+
default: undefined;
|
|
18
25
|
};
|
|
19
26
|
}>>, {
|
|
20
|
-
ui: any
|
|
27
|
+
ui: Partial<any>;
|
|
28
|
+
class: any;
|
|
21
29
|
}, {}>;
|
|
22
30
|
export default _default;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
:model-value="modelValue"
|
|
5
5
|
:multiple="multiple"
|
|
6
6
|
:nullable="nullable"
|
|
7
|
-
:class="
|
|
7
|
+
:class="ui.wrapper"
|
|
8
8
|
v-bind="attrs"
|
|
9
9
|
as="div"
|
|
10
10
|
@update:model-value="onSelect"
|
|
@@ -16,17 +16,12 @@
|
|
|
16
16
|
:value="query"
|
|
17
17
|
:class="[ui.input.base, ui.input.size, ui.input.height, ui.input.padding, icon && ui.input.icon.padding]"
|
|
18
18
|
:placeholder="placeholder"
|
|
19
|
+
:aria-label="placeholder"
|
|
19
20
|
autocomplete="off"
|
|
20
21
|
@change="query = $event.target.value"
|
|
21
22
|
/>
|
|
22
23
|
|
|
23
|
-
<UButton
|
|
24
|
-
v-if="closeButton"
|
|
25
|
-
v-bind="{ ...ui.default.closeButton, ...closeButton }"
|
|
26
|
-
:class="ui.input.closeButton"
|
|
27
|
-
aria-label="Close"
|
|
28
|
-
@click="onClear"
|
|
29
|
-
/>
|
|
24
|
+
<UButton v-if="closeButton" aria-label="Close" v-bind="{ ...ui.default.closeButton, ...closeButton }" :class="ui.input.closeButton" @click="onClear" />
|
|
30
25
|
</div>
|
|
31
26
|
|
|
32
27
|
<HComboboxOptions
|
|
@@ -67,19 +62,20 @@
|
|
|
67
62
|
</template>
|
|
68
63
|
|
|
69
64
|
<script>
|
|
70
|
-
import { ref, computed, watch, onMounted, defineComponent } from "vue";
|
|
65
|
+
import { ref, computed, watch, toRef, onMounted, defineComponent } from "vue";
|
|
71
66
|
import { Combobox as HCombobox, ComboboxInput as HComboboxInput, ComboboxOptions as HComboboxOptions } from "@headlessui/vue";
|
|
72
67
|
import { useDebounceFn } from "@vueuse/core";
|
|
73
68
|
import { useFuse } from "@vueuse/integrations/useFuse";
|
|
74
|
-
import {
|
|
75
|
-
import { groupBy, map, omit } from "lodash-es";
|
|
69
|
+
import { twJoin } from "tailwind-merge";
|
|
76
70
|
import { defu } from "defu";
|
|
77
71
|
import UIcon from "../elements/Icon.vue";
|
|
78
72
|
import UButton from "../elements/Button.vue";
|
|
79
73
|
import CommandPaletteGroup from "./CommandPaletteGroup.vue";
|
|
80
|
-
import {
|
|
81
|
-
import {
|
|
74
|
+
import { useUI } from "../../composables/useUI";
|
|
75
|
+
import { mergeConfig } from "../../utils";
|
|
82
76
|
import appConfig from "#build/app.config";
|
|
77
|
+
import { commandPalette } from "#ui/ui.config";
|
|
78
|
+
const config = mergeConfig(appConfig.ui.strategy, appConfig.ui.commandPalette, commandPalette);
|
|
83
79
|
export default defineComponent({
|
|
84
80
|
components: {
|
|
85
81
|
HCombobox,
|
|
@@ -121,23 +117,23 @@ export default defineComponent({
|
|
|
121
117
|
},
|
|
122
118
|
icon: {
|
|
123
119
|
type: String,
|
|
124
|
-
default: () =>
|
|
120
|
+
default: () => config.default.icon
|
|
125
121
|
},
|
|
126
122
|
loadingIcon: {
|
|
127
123
|
type: String,
|
|
128
|
-
default: () =>
|
|
124
|
+
default: () => config.default.loadingIcon
|
|
129
125
|
},
|
|
130
126
|
selectedIcon: {
|
|
131
127
|
type: String,
|
|
132
|
-
default: () =>
|
|
128
|
+
default: () => config.default.selectedIcon
|
|
133
129
|
},
|
|
134
130
|
closeButton: {
|
|
135
131
|
type: Object,
|
|
136
|
-
default: () =>
|
|
132
|
+
default: () => config.default.closeButton
|
|
137
133
|
},
|
|
138
134
|
emptyState: {
|
|
139
135
|
type: Object,
|
|
140
|
-
default: () =>
|
|
136
|
+
default: () => config.default.emptyState
|
|
141
137
|
},
|
|
142
138
|
placeholder: {
|
|
143
139
|
type: String,
|
|
@@ -167,15 +163,18 @@ export default defineComponent({
|
|
|
167
163
|
type: Object,
|
|
168
164
|
default: () => ({})
|
|
169
165
|
},
|
|
166
|
+
class: {
|
|
167
|
+
type: [String, Object, Array],
|
|
168
|
+
default: void 0
|
|
169
|
+
},
|
|
170
170
|
ui: {
|
|
171
171
|
type: Object,
|
|
172
|
-
default:
|
|
172
|
+
default: void 0
|
|
173
173
|
}
|
|
174
174
|
},
|
|
175
175
|
emits: ["update:modelValue", "close"],
|
|
176
|
-
setup(props, { emit,
|
|
177
|
-
const
|
|
178
|
-
const ui = computed(() => defuTwMerge({}, props.ui, appConfig2.ui.commandPalette));
|
|
176
|
+
setup(props, { emit, expose }) {
|
|
177
|
+
const { ui, attrs } = useUI("commandPalette", toRef(props, "ui"), config, toRef(props, "class"));
|
|
179
178
|
const query = ref("");
|
|
180
179
|
const comboboxInput = ref();
|
|
181
180
|
const comboboxApi = ref(null);
|
|
@@ -202,27 +201,42 @@ export default defineComponent({
|
|
|
202
201
|
resultLimit: 12,
|
|
203
202
|
matchAllWhenSearchEmpty: true
|
|
204
203
|
}));
|
|
205
|
-
const commands = computed(() =>
|
|
206
|
-
|
|
207
|
-
|
|
204
|
+
const commands = computed(() => {
|
|
205
|
+
const commands2 = [];
|
|
206
|
+
for (const group of props.groups) {
|
|
207
|
+
if (!group.search) {
|
|
208
|
+
commands2.push(...group.commands.map((command) => ({ ...command, group: group.key })));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return commands2;
|
|
212
|
+
});
|
|
208
213
|
const searchResults = ref({});
|
|
209
214
|
const { results } = useFuse(query, commands, options);
|
|
210
|
-
const groups = computed(() =>
|
|
211
|
-
|
|
212
|
-
|
|
215
|
+
const groups = computed(() => {
|
|
216
|
+
const groups2 = [];
|
|
217
|
+
const groupedCommands = {};
|
|
218
|
+
for (const command of results.value) {
|
|
219
|
+
groupedCommands[command.item.group] ||= [];
|
|
220
|
+
groupedCommands[command.item.group].push(command);
|
|
221
|
+
}
|
|
222
|
+
for (const key in groupedCommands) {
|
|
223
|
+
const group = props.groups.find((group2) => group2.key === key);
|
|
224
|
+
const commands2 = groupedCommands[key].slice(0, options.value.resultLimit).map((result) => {
|
|
213
225
|
const { item, ...data } = result;
|
|
214
226
|
return {
|
|
215
227
|
...item,
|
|
216
228
|
...data
|
|
217
229
|
};
|
|
218
230
|
});
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
231
|
+
groups2.push({ ...group, commands: commands2 });
|
|
232
|
+
}
|
|
233
|
+
for (const group of props.groups) {
|
|
234
|
+
if (group.search && searchResults.value[group.key]?.length) {
|
|
235
|
+
groups2.push({ ...group, commands: (searchResults.value[group.key] || []).slice(0, options.value.resultLimit) });
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
return groups2;
|
|
239
|
+
});
|
|
226
240
|
const debouncedSearch = useDebounceFn(async () => {
|
|
227
241
|
const searchableGroups = props.groups.filter((group) => !!group.search);
|
|
228
242
|
if (!searchableGroups.length) {
|
|
@@ -240,7 +254,6 @@ export default defineComponent({
|
|
|
240
254
|
comboboxInput.value?.$el.dispatchEvent(new KeyboardEvent("keydown", { key: "PageUp" }));
|
|
241
255
|
}, 0);
|
|
242
256
|
});
|
|
243
|
-
const wrapperClass = computed(() => twMerge(ui.value.wrapper, attrs.class));
|
|
244
257
|
const iconName = computed(() => {
|
|
245
258
|
if ((props.loading || isLoading.value) && props.loadingIcon) {
|
|
246
259
|
return props.loadingIcon;
|
|
@@ -284,14 +297,13 @@ export default defineComponent({
|
|
|
284
297
|
results
|
|
285
298
|
});
|
|
286
299
|
return {
|
|
287
|
-
attrs: omit(attrs, ["class"]),
|
|
288
300
|
// eslint-disable-next-line vue/no-dupe-keys
|
|
289
301
|
ui,
|
|
302
|
+
attrs,
|
|
290
303
|
// eslint-disable-next-line vue/no-dupe-keys
|
|
291
304
|
groups,
|
|
292
305
|
comboboxInput,
|
|
293
306
|
query,
|
|
294
|
-
wrapperClass,
|
|
295
307
|
iconName,
|
|
296
308
|
iconClass,
|
|
297
309
|
// eslint-disable-next-line vue/no-dupe-keys
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
/// <reference types="lodash" />
|
|
2
1
|
import type { ComputedRef, PropType, ComponentPublicInstance } from 'vue';
|
|
3
2
|
import type { UseFuseOptions } from '@vueuse/integrations/useFuse';
|
|
4
|
-
import type { Group, Command } from '../../types
|
|
5
|
-
import type { Button } from '../../types/button';
|
|
3
|
+
import type { Group, Command, Button } from '../../types';
|
|
6
4
|
declare const _default: import("vue").DefineComponent<{
|
|
7
5
|
modelValue: {
|
|
8
|
-
type: (ObjectConstructor |
|
|
6
|
+
type: (ObjectConstructor | NumberConstructor | ArrayConstructor | StringConstructor)[];
|
|
9
7
|
default: null;
|
|
10
8
|
};
|
|
11
9
|
by: {
|
|
@@ -46,7 +44,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
46
44
|
};
|
|
47
45
|
closeButton: {
|
|
48
46
|
type: PropType<Button>;
|
|
49
|
-
default: () =>
|
|
47
|
+
default: () => Button;
|
|
50
48
|
};
|
|
51
49
|
emptyState: {
|
|
52
50
|
type: PropType<{
|
|
@@ -84,24 +82,22 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
84
82
|
type: PropType<UseFuseOptions<Command>>;
|
|
85
83
|
default: () => {};
|
|
86
84
|
};
|
|
87
|
-
|
|
85
|
+
class: {
|
|
88
86
|
type: PropType<any>;
|
|
89
|
-
default:
|
|
87
|
+
default: undefined;
|
|
88
|
+
};
|
|
89
|
+
ui: {
|
|
90
|
+
type: PropType<Partial<any>>;
|
|
91
|
+
default: undefined;
|
|
90
92
|
};
|
|
91
93
|
}, {
|
|
92
|
-
attrs: import("lodash").Omit<{
|
|
93
|
-
[x: string]: unknown;
|
|
94
|
-
}, "class">;
|
|
95
94
|
ui: ComputedRef<any>;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
inactive?: string | undefined;
|
|
101
|
-
}[]>;
|
|
95
|
+
attrs: ComputedRef<Pick<{
|
|
96
|
+
[x: string]: unknown;
|
|
97
|
+
}, string>>;
|
|
98
|
+
groups: ComputedRef<Group[]>;
|
|
102
99
|
comboboxInput: import("vue").Ref<ComponentPublicInstance<HTMLInputElement> | undefined>;
|
|
103
100
|
query: import("vue").Ref<string>;
|
|
104
|
-
wrapperClass: ComputedRef<string>;
|
|
105
101
|
iconName: ComputedRef<string | undefined>;
|
|
106
102
|
iconClass: ComputedRef<string>;
|
|
107
103
|
emptyState: ComputedRef<any>;
|
|
@@ -109,7 +105,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
109
105
|
onClear: () => void;
|
|
110
106
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("close" | "update:modelValue")[], "close" | "update:modelValue", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
111
107
|
modelValue: {
|
|
112
|
-
type: (ObjectConstructor |
|
|
108
|
+
type: (ObjectConstructor | NumberConstructor | ArrayConstructor | StringConstructor)[];
|
|
113
109
|
default: null;
|
|
114
110
|
};
|
|
115
111
|
by: {
|
|
@@ -150,7 +146,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
150
146
|
};
|
|
151
147
|
closeButton: {
|
|
152
148
|
type: PropType<Button>;
|
|
153
|
-
default: () =>
|
|
149
|
+
default: () => Button;
|
|
154
150
|
};
|
|
155
151
|
emptyState: {
|
|
156
152
|
type: PropType<{
|
|
@@ -188,9 +184,13 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
188
184
|
type: PropType<UseFuseOptions<Command>>;
|
|
189
185
|
default: () => {};
|
|
190
186
|
};
|
|
191
|
-
|
|
187
|
+
class: {
|
|
192
188
|
type: PropType<any>;
|
|
193
|
-
default:
|
|
189
|
+
default: undefined;
|
|
190
|
+
};
|
|
191
|
+
ui: {
|
|
192
|
+
type: PropType<Partial<any>>;
|
|
193
|
+
default: undefined;
|
|
194
194
|
};
|
|
195
195
|
}>> & {
|
|
196
196
|
onClose?: ((...args: any[]) => any) | undefined;
|
|
@@ -198,7 +198,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
198
198
|
}, {
|
|
199
199
|
icon: string;
|
|
200
200
|
closeButton: Button;
|
|
201
|
-
ui: any
|
|
201
|
+
ui: Partial<any>;
|
|
202
|
+
class: any;
|
|
202
203
|
modelValue: string | number | unknown[] | Record<string, any>;
|
|
203
204
|
by: string;
|
|
204
205
|
loading: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PropType } from 'vue';
|
|
2
|
-
import type { Group } from '../../types
|
|
2
|
+
import type { Group } from '../../types';
|
|
3
3
|
declare const _default: import("vue").DefineComponent<{
|
|
4
4
|
group: {
|
|
5
5
|
type: PropType<Group>;
|
|
@@ -23,7 +23,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
23
23
|
};
|
|
24
24
|
ui: {
|
|
25
25
|
type: PropType<any>;
|
|
26
|
-
|
|
26
|
+
required: true;
|
|
27
27
|
};
|
|
28
28
|
}, {
|
|
29
29
|
label: import("vue").ComputedRef<any>;
|
|
@@ -54,10 +54,9 @@ declare const _default: import("vue").DefineComponent<{
|
|
|
54
54
|
};
|
|
55
55
|
ui: {
|
|
56
56
|
type: PropType<any>;
|
|
57
|
-
|
|
57
|
+
required: true;
|
|
58
58
|
};
|
|
59
59
|
}>>, {
|
|
60
|
-
ui: any;
|
|
61
60
|
query: string;
|
|
62
61
|
}, {}>;
|
|
63
62
|
export default _default;
|