@hywax/cms 1.1.3 → 1.2.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/.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 +22 -1
- 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/{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
|
@@ -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.
|
|
9
|
+
const version = "1.2.0";
|
|
10
10
|
|
|
11
11
|
function createContext(options, nuxt) {
|
|
12
12
|
const { resolve } = createResolver(import.meta.url);
|
|
@@ -239,6 +239,26 @@ function prepareServerRoutes({ resolve }) {
|
|
|
239
239
|
});
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
+
const buttonCopyText = {
|
|
243
|
+
slots: {
|
|
244
|
+
root: "wrap-anywhere",
|
|
245
|
+
text: "pe-5",
|
|
246
|
+
button: "p-0 -ms-4 align-middle"
|
|
247
|
+
},
|
|
248
|
+
variants: {
|
|
249
|
+
buttonInvisible: {
|
|
250
|
+
true: {
|
|
251
|
+
button: "invisible"
|
|
252
|
+
}
|
|
253
|
+
},
|
|
254
|
+
to: {
|
|
255
|
+
true: {
|
|
256
|
+
text: "ps-0"
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
|
|
242
262
|
const buttonDeleteConfirm = {
|
|
243
263
|
slots: {
|
|
244
264
|
root: ""
|
|
@@ -313,6 +333,7 @@ const uploraImage$1 = {
|
|
|
313
333
|
|
|
314
334
|
const theme = {
|
|
315
335
|
__proto__: null,
|
|
336
|
+
ButtonCopyText: buttonCopyText,
|
|
316
337
|
ButtonDeleteConfirm: buttonDeleteConfirm,
|
|
317
338
|
FormPanel: formPanel,
|
|
318
339
|
FormPanelAsideSection: formPanelAsideSection,
|
|
@@ -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 {};
|
|
@@ -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
|
}
|