@hywax/cms 1.1.3 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.nuxt/cms/button-copy-text.ts +19 -0
- package/.nuxt/cms/index.ts +1 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +29 -18
- package/dist/runtime/components/ButtonCopyText.d.vue.ts +26 -0
- package/dist/runtime/components/ButtonCopyText.vue +70 -0
- package/dist/runtime/components/ButtonCopyText.vue.d.ts +26 -0
- package/dist/runtime/components/DatePicker.d.vue.ts +2 -2
- package/dist/runtime/components/DatePicker.vue.d.ts +2 -2
- package/dist/runtime/composables/useApi.d.ts +1 -2
- package/dist/runtime/composables/useTable.js +2 -2
- package/dist/runtime/{utils/table.d.ts → composables/useTableColumns.d.ts} +8 -4
- package/dist/runtime/{utils/table.js → composables/useTableColumns.js} +6 -6
- package/dist/runtime/utils/index.d.ts +0 -1
- package/dist/runtime/utils/index.js +0 -1
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"slots": {
|
|
3
|
+
"root": "wrap-anywhere",
|
|
4
|
+
"text": "pe-5",
|
|
5
|
+
"button": "p-0 -ms-4 align-middle"
|
|
6
|
+
},
|
|
7
|
+
"variants": {
|
|
8
|
+
"buttonInvisible": {
|
|
9
|
+
"true": {
|
|
10
|
+
"button": "invisible"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"to": {
|
|
14
|
+
"true": {
|
|
15
|
+
"text": "ps-0"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
package/.nuxt/cms/index.ts
CHANGED
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createResolver, addComponentsDir, addPlugin, addImports, addImportsDir, addServerImports, addServerImportsDir,
|
|
1
|
+
import { createResolver, addComponentsDir, addPlugin, addImports, addImportsDir, addServerImports, addServerImportsDir, addServerHandler, addTypeTemplate, addTemplate, addServerTemplate, defineNuxtModule } from '@nuxt/kit';
|
|
2
2
|
import { fileURLToPath } from 'node:url';
|
|
3
3
|
import { dirname, join } from 'pathe';
|
|
4
4
|
import { defu } from 'defu';
|
|
@@ -6,7 +6,7 @@ import { snakeCase, kebabCase } from 'scule';
|
|
|
6
6
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
7
7
|
|
|
8
8
|
const name = "@hywax/cms";
|
|
9
|
-
const version = "1.1
|
|
9
|
+
const version = "1.2.1";
|
|
10
10
|
|
|
11
11
|
function createContext(options, nuxt) {
|
|
12
12
|
const { resolve } = createResolver(import.meta.url);
|
|
@@ -110,21 +110,6 @@ async function prepareGenerateEnv({ nuxt }) {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
async function prepareInstallModules(_context) {
|
|
114
|
-
if (!hasNuxtModule("@nuxt/ui")) {
|
|
115
|
-
await installModule("@nuxt/ui");
|
|
116
|
-
}
|
|
117
|
-
if (!hasNuxtModule("@nuxtjs/mdc")) {
|
|
118
|
-
await installModule("@nuxtjs/mdc");
|
|
119
|
-
}
|
|
120
|
-
if (!hasNuxtModule("@vueuse/nuxt")) {
|
|
121
|
-
await installModule("@vueuse/nuxt");
|
|
122
|
-
}
|
|
123
|
-
if (!hasNuxtModule("nuxt-auth-utils")) {
|
|
124
|
-
await installModule("nuxt-auth-utils");
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
113
|
const icons = {
|
|
129
114
|
calendar: "lucide:calendar",
|
|
130
115
|
sort: "lucide:arrow-down-up",
|
|
@@ -239,6 +224,26 @@ function prepareServerRoutes({ resolve }) {
|
|
|
239
224
|
});
|
|
240
225
|
}
|
|
241
226
|
|
|
227
|
+
const buttonCopyText = {
|
|
228
|
+
slots: {
|
|
229
|
+
root: "wrap-anywhere",
|
|
230
|
+
text: "pe-5",
|
|
231
|
+
button: "p-0 -ms-4 align-middle"
|
|
232
|
+
},
|
|
233
|
+
variants: {
|
|
234
|
+
buttonInvisible: {
|
|
235
|
+
true: {
|
|
236
|
+
button: "invisible"
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
to: {
|
|
240
|
+
true: {
|
|
241
|
+
text: "ps-0"
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
|
|
242
247
|
const buttonDeleteConfirm = {
|
|
243
248
|
slots: {
|
|
244
249
|
root: ""
|
|
@@ -313,6 +318,7 @@ const uploraImage$1 = {
|
|
|
313
318
|
|
|
314
319
|
const theme = {
|
|
315
320
|
__proto__: null,
|
|
321
|
+
ButtonCopyText: buttonCopyText,
|
|
316
322
|
ButtonDeleteConfirm: buttonDeleteConfirm,
|
|
317
323
|
FormPanel: formPanel,
|
|
318
324
|
FormPanelAsideSection: formPanelAsideSection,
|
|
@@ -462,11 +468,16 @@ const module$1 = defineNuxtModule({
|
|
|
462
468
|
version,
|
|
463
469
|
configKey: "cms"
|
|
464
470
|
},
|
|
471
|
+
moduleDependencies: {
|
|
472
|
+
"@nuxt/ui": {},
|
|
473
|
+
"@nuxtjs/mdc": {},
|
|
474
|
+
"@vueuse/nuxt": {},
|
|
475
|
+
"nuxt-auth-utils": {}
|
|
476
|
+
},
|
|
465
477
|
defaults: defaultModuleOptions,
|
|
466
478
|
async setup(options, nuxt) {
|
|
467
479
|
const context = createContext(options, nuxt);
|
|
468
480
|
prepareMergeConfigs(context);
|
|
469
|
-
await prepareInstallModules();
|
|
470
481
|
prepareTemplates(context);
|
|
471
482
|
prepareAutoImports(context);
|
|
472
483
|
prepareServerRoutes(context);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AppConfig } from '@nuxt/schema';
|
|
2
|
+
import type { ButtonProps } from '@nuxt/ui';
|
|
3
|
+
import type { RouteLocationRaw } from 'vue-router';
|
|
4
|
+
import type { ComponentConfig } from '../types';
|
|
5
|
+
import theme from '#build/cms/button-copy-text';
|
|
6
|
+
type ButtonCopyText = ComponentConfig<typeof theme, AppConfig, 'buttonCopyText'>;
|
|
7
|
+
export interface Props extends Pick<ButtonProps, 'target' | 'external' | 'label'> {
|
|
8
|
+
text?: string | number | null;
|
|
9
|
+
showAction?: boolean;
|
|
10
|
+
alwaysShowTooltip?: boolean;
|
|
11
|
+
to?: RouteLocationRaw;
|
|
12
|
+
class?: any;
|
|
13
|
+
ui?: ButtonCopyText['slots'];
|
|
14
|
+
}
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
17
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
18
|
+
default?: (props: {}) => any;
|
|
19
|
+
} & {
|
|
20
|
+
default?: (props: {}) => any;
|
|
21
|
+
}>;
|
|
22
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
23
|
+
new (): {
|
|
24
|
+
$slots: S;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="textValue" ref="button-copy-text" :class="ui.root({ class: [props.class, props.ui?.root] })">
|
|
3
|
+
<UButton
|
|
4
|
+
v-if="to"
|
|
5
|
+
:to="to"
|
|
6
|
+
:class="ui.text({ class: props.ui?.text })"
|
|
7
|
+
:external="external"
|
|
8
|
+
:target="target"
|
|
9
|
+
variant="link"
|
|
10
|
+
color="info"
|
|
11
|
+
>
|
|
12
|
+
<slot>{{ textValue }}</slot>
|
|
13
|
+
</UButton>
|
|
14
|
+
<span v-else :class="ui.text({ class: props.ui?.text })">
|
|
15
|
+
<slot>{{ textValue }}</slot>
|
|
16
|
+
</span>
|
|
17
|
+
|
|
18
|
+
<UTooltip
|
|
19
|
+
v-if="showAction"
|
|
20
|
+
:text="tooltipText"
|
|
21
|
+
:content="{ side: 'top' }"
|
|
22
|
+
disable-hoverable-content
|
|
23
|
+
disable-closing-trigger
|
|
24
|
+
>
|
|
25
|
+
<UButton
|
|
26
|
+
:class="ui.button({ class: props.ui?.button })"
|
|
27
|
+
:icon="copied ? 'check' : 'copy'"
|
|
28
|
+
variant="link"
|
|
29
|
+
size="sm"
|
|
30
|
+
:color="copied ? 'success' : 'neutral'"
|
|
31
|
+
@click="copy(textValue)"
|
|
32
|
+
/>
|
|
33
|
+
</UTooltip>
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script>
|
|
38
|
+
import theme from "#build/cms/button-copy-text";
|
|
39
|
+
import { useAppConfig } from "#imports";
|
|
40
|
+
import { useClipboard, useElementHover } from "@vueuse/core";
|
|
41
|
+
import { computed, useTemplateRef } from "vue";
|
|
42
|
+
import { tv } from "../tv";
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<script setup>
|
|
46
|
+
const props = defineProps({
|
|
47
|
+
text: { type: [String, Number, null], required: false },
|
|
48
|
+
showAction: { type: Boolean, required: false },
|
|
49
|
+
alwaysShowTooltip: { type: Boolean, required: false },
|
|
50
|
+
to: { type: null, required: false },
|
|
51
|
+
class: { type: null, required: false },
|
|
52
|
+
ui: { type: null, required: false },
|
|
53
|
+
target: { type: [String, Object, null], required: false },
|
|
54
|
+
external: { type: Boolean, required: false },
|
|
55
|
+
label: { type: String, required: false }
|
|
56
|
+
});
|
|
57
|
+
const appConfig = useAppConfig();
|
|
58
|
+
const { copy, copied } = useClipboard();
|
|
59
|
+
const tooltipText = computed(() => copied.value ? "\u0421\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u043D\u043E" : "\u0421\u043A\u043E\u043F\u0438\u0440\u043E\u0432\u0430\u0442\u044C");
|
|
60
|
+
const copyTextRef = useTemplateRef("button-copy-text");
|
|
61
|
+
const isHovered = useElementHover(copyTextRef);
|
|
62
|
+
const textValue = computed(() => {
|
|
63
|
+
const text = props.label ?? props.text;
|
|
64
|
+
return typeof text === "number" ? text.toString() : text;
|
|
65
|
+
});
|
|
66
|
+
const ui = computed(() => tv({ extend: tv(theme), ...appConfig.cms?.buttonCopyText || {} })({
|
|
67
|
+
buttonInvisible: !isHovered.value && !props.alwaysShowTooltip,
|
|
68
|
+
to: !!props.to
|
|
69
|
+
}));
|
|
70
|
+
</script>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { AppConfig } from '@nuxt/schema';
|
|
2
|
+
import type { ButtonProps } from '@nuxt/ui';
|
|
3
|
+
import type { RouteLocationRaw } from 'vue-router';
|
|
4
|
+
import type { ComponentConfig } from '../types';
|
|
5
|
+
import theme from '#build/cms/button-copy-text';
|
|
6
|
+
type ButtonCopyText = ComponentConfig<typeof theme, AppConfig, 'buttonCopyText'>;
|
|
7
|
+
export interface Props extends Pick<ButtonProps, 'target' | 'external' | 'label'> {
|
|
8
|
+
text?: string | number | null;
|
|
9
|
+
showAction?: boolean;
|
|
10
|
+
alwaysShowTooltip?: boolean;
|
|
11
|
+
to?: RouteLocationRaw;
|
|
12
|
+
class?: any;
|
|
13
|
+
ui?: ButtonCopyText['slots'];
|
|
14
|
+
}
|
|
15
|
+
declare const _default: typeof __VLS_export;
|
|
16
|
+
export default _default;
|
|
17
|
+
declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
|
|
18
|
+
default?: (props: {}) => any;
|
|
19
|
+
} & {
|
|
20
|
+
default?: (props: {}) => any;
|
|
21
|
+
}>;
|
|
22
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
23
|
+
new (): {
|
|
24
|
+
$slots: S;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -23,8 +23,8 @@ export default _default;
|
|
|
23
23
|
declare const __VLS_export: <R extends boolean = false>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
24
24
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<Props<R> & {
|
|
25
25
|
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
26
|
-
onChange?: ((event: Event) => any) | undefined;
|
|
27
26
|
onFocus?: ((event: FocusEvent) => any) | undefined;
|
|
27
|
+
onChange?: ((event: Event) => any) | undefined;
|
|
28
28
|
"onUpdate:modelValue"?: ((value: ModelValue<R>) => any) | undefined;
|
|
29
29
|
}> & (typeof globalThis extends {
|
|
30
30
|
__VLS_PROPS_FALLBACK: infer P;
|
|
@@ -32,7 +32,7 @@ declare const __VLS_export: <R extends boolean = false>(__VLS_props: NonNullable
|
|
|
32
32
|
expose: (exposed: {}) => void;
|
|
33
33
|
attrs: any;
|
|
34
34
|
slots: {};
|
|
35
|
-
emit: ((evt: "blur", event: FocusEvent) => void) & ((evt: "
|
|
35
|
+
emit: ((evt: "blur", event: FocusEvent) => void) & ((evt: "focus", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: ModelValue<R>) => void);
|
|
36
36
|
}>) => import("vue").VNode & {
|
|
37
37
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
38
38
|
};
|
|
@@ -23,8 +23,8 @@ export default _default;
|
|
|
23
23
|
declare const __VLS_export: <R extends boolean = false>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_exposed?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
24
24
|
props: import("vue").PublicProps & __VLS_PrettifyLocal<Props<R> & {
|
|
25
25
|
onBlur?: ((event: FocusEvent) => any) | undefined;
|
|
26
|
-
onChange?: ((event: Event) => any) | undefined;
|
|
27
26
|
onFocus?: ((event: FocusEvent) => any) | undefined;
|
|
27
|
+
onChange?: ((event: Event) => any) | undefined;
|
|
28
28
|
"onUpdate:modelValue"?: ((value: ModelValue<R>) => any) | undefined;
|
|
29
29
|
}> & (typeof globalThis extends {
|
|
30
30
|
__VLS_PROPS_FALLBACK: infer P;
|
|
@@ -32,7 +32,7 @@ declare const __VLS_export: <R extends boolean = false>(__VLS_props: NonNullable
|
|
|
32
32
|
expose: (exposed: {}) => void;
|
|
33
33
|
attrs: any;
|
|
34
34
|
slots: {};
|
|
35
|
-
emit: ((evt: "blur", event: FocusEvent) => void) & ((evt: "
|
|
35
|
+
emit: ((evt: "blur", event: FocusEvent) => void) & ((evt: "focus", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "update:modelValue", value: ModelValue<R>) => void);
|
|
36
36
|
}>) => import("vue").VNode & {
|
|
37
37
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
38
38
|
};
|
|
@@ -4,11 +4,10 @@ import type { FetchError } from 'ofetch';
|
|
|
4
4
|
import type { Ref } from 'vue';
|
|
5
5
|
type PickFrom<T, K extends Array<string>> = T extends Array<any> ? T : T extends Record<string, any> ? keyof T extends K[number] ? T : K[number] extends never ? T : Pick<T, K[number]> : T;
|
|
6
6
|
type KeysOf<T> = Array<T extends T ? (keyof T extends string ? keyof T : never) : never>;
|
|
7
|
-
type DefaultAsyncDataValue = undefined;
|
|
8
7
|
/**
|
|
9
8
|
* На данный момент нет возможности использовать `useFetch` со своим $fetch,
|
|
10
9
|
* поэтому приходится использовать костыль.
|
|
11
10
|
* https://github.com/nuxt/nuxt/issues/14736
|
|
12
11
|
*/
|
|
13
|
-
export declare function useApi<ResT = void, ErrorT = FetchError, ReqT extends NitroFetchRequest = NitroFetchRequest, Method extends AvailableRouterMethod<ReqT> = ResT extends void ? 'get' extends AvailableRouterMethod<ReqT> ? 'get' : AvailableRouterMethod<ReqT> : AvailableRouterMethod<ReqT>, _ResT = ResT extends void ? FetchResult<ReqT, Method> : ResT, DataT = _ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT =
|
|
12
|
+
export declare function useApi<ResT = void, ErrorT = FetchError, ReqT extends NitroFetchRequest = NitroFetchRequest, Method extends AvailableRouterMethod<ReqT> = ResT extends void ? 'get' extends AvailableRouterMethod<ReqT> ? 'get' : AvailableRouterMethod<ReqT> : AvailableRouterMethod<ReqT>, _ResT = ResT extends void ? FetchResult<ReqT, Method> : ResT, DataT = _ResT, PickKeys extends KeysOf<DataT> = KeysOf<DataT>, DefaultT = undefined>(request: Ref<ReqT> | ReqT | (() => ReqT), opts?: UseFetchOptions<_ResT, DataT, PickKeys, DefaultT, ReqT, Method>): AsyncData<PickFrom<DataT, PickKeys> | DefaultT, ErrorT | undefined>;
|
|
14
13
|
export {};
|
|
@@ -59,12 +59,12 @@ export default function useTable(initialFilters, options) {
|
|
|
59
59
|
filters,
|
|
60
60
|
updateFilters
|
|
61
61
|
} = useTableFilters(initialFilters, options);
|
|
62
|
-
const { sorting } = useTableSort(
|
|
62
|
+
const { sort, sorting } = useTableSort();
|
|
63
63
|
const { pagination } = useTablePagination(options);
|
|
64
64
|
const query = computed(() => {
|
|
65
65
|
return {
|
|
66
66
|
...filters.value,
|
|
67
|
-
...
|
|
67
|
+
...sort.value,
|
|
68
68
|
...pagination.value
|
|
69
69
|
};
|
|
70
70
|
});
|
|
@@ -7,8 +7,10 @@ declare module '@tanstack/table-core' {
|
|
|
7
7
|
headerLabel?: string;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
export declare function
|
|
11
|
-
|
|
10
|
+
export declare function useTableFiltersFields<S extends FormSchema, F extends readonly FiltersField<S>[]>(_schema: S, fields: F): {
|
|
11
|
+
filtersFields: {
|
|
12
|
+
-readonly [P in keyof F]: F[P];
|
|
13
|
+
};
|
|
12
14
|
};
|
|
13
15
|
export type TableColumnFormat = 'number' | 'date' | 'date-time';
|
|
14
16
|
export type TableColumnCustom<T extends TableData, D = unknown> = TableColumn<T, D> & {
|
|
@@ -18,6 +20,8 @@ export type TableColumnCustom<T extends TableData, D = unknown> = TableColumn<T,
|
|
|
18
20
|
external?: boolean;
|
|
19
21
|
emptyValue?: string;
|
|
20
22
|
};
|
|
21
|
-
export declare function
|
|
22
|
-
|
|
23
|
+
export declare function useTableColumns<I extends Record<string, any>, T extends readonly TableColumnCustom<I>[] = readonly TableColumnCustom<I>[]>(columns: T): {
|
|
24
|
+
columns: {
|
|
25
|
+
-readonly [P in keyof T]: T[P];
|
|
26
|
+
};
|
|
23
27
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { UButton } from "#components";
|
|
2
2
|
import { h } from "vue";
|
|
3
|
-
import { formatDate, formatDateTime } from "
|
|
4
|
-
import { formatNumber } from "
|
|
5
|
-
export function
|
|
6
|
-
return fields;
|
|
3
|
+
import { formatDate, formatDateTime } from "../utils/date.js";
|
|
4
|
+
import { formatNumber } from "../utils/formatters.js";
|
|
5
|
+
export function useTableFiltersFields(_schema, fields) {
|
|
6
|
+
return { filtersFields: fields };
|
|
7
7
|
}
|
|
8
8
|
function applyFormat(value, column) {
|
|
9
9
|
if (value === void 0 || value === null || !column.format) {
|
|
@@ -46,6 +46,6 @@ function transformColumn(column) {
|
|
|
46
46
|
}
|
|
47
47
|
return col;
|
|
48
48
|
}
|
|
49
|
-
export function
|
|
50
|
-
return columns.map((c) => transformColumn(c));
|
|
49
|
+
export function useTableColumns(columns) {
|
|
50
|
+
return { columns: columns.map((c) => transformColumn(c)) };
|
|
51
51
|
}
|