@hywax/cms 0.0.23 → 1.0.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.
Files changed (182) hide show
  1. package/.nuxt/cms/editor/index.ts +0 -2
  2. package/.nuxt/cms/form-panel-section.ts +2 -2
  3. package/.nuxt/cms/index.ts +8 -21
  4. package/.nuxt/cms/table-search-input.ts +6 -0
  5. package/dist/module.json +3 -3
  6. package/dist/module.mjs +78 -203
  7. package/dist/runtime/components/AutocompleteSelect.d.vue.ts +56 -0
  8. package/dist/runtime/components/AutocompleteSelect.vue +131 -77
  9. package/dist/runtime/components/AutocompleteSelect.vue.d.ts +43 -29
  10. package/dist/runtime/components/{ButtonDelete.vue.d.ts → ButtonDeleteConfirm.d.vue.ts} +4 -3
  11. package/dist/runtime/components/{ButtonDelete.vue → ButtonDeleteConfirm.vue} +1 -1
  12. package/dist/runtime/components/ButtonDeleteConfirm.vue.d.ts +36 -0
  13. package/dist/runtime/components/DatePicker.d.vue.ts +43 -0
  14. package/dist/runtime/components/DatePicker.vue +232 -0
  15. package/dist/runtime/components/DatePicker.vue.d.ts +43 -0
  16. package/dist/runtime/components/EditorFull.d.vue.ts +13 -0
  17. package/dist/runtime/components/EditorFull.vue +127 -0
  18. package/dist/runtime/components/EditorFull.vue.d.ts +13 -0
  19. package/dist/runtime/components/EditorLinkPopover.d.vue.ts +8 -0
  20. package/dist/runtime/components/EditorLinkPopover.vue +137 -0
  21. package/dist/runtime/components/EditorLinkPopover.vue.d.ts +8 -0
  22. package/dist/runtime/components/FormPanel.d.vue.ts +47 -0
  23. package/dist/runtime/components/FormPanel.vue +10 -7
  24. package/dist/runtime/components/FormPanel.vue.d.ts +21 -15
  25. package/dist/runtime/components/FormPanelAsideSection.d.vue.ts +24 -0
  26. package/dist/runtime/components/FormPanelAsideSection.vue.d.ts +2 -1
  27. package/dist/runtime/components/FormPanelSection.d.vue.ts +21 -0
  28. package/dist/runtime/components/FormPanelSection.vue +2 -2
  29. package/dist/runtime/components/FormPanelSection.vue.d.ts +3 -2
  30. package/dist/runtime/components/Layout.d.vue.ts +27 -0
  31. package/dist/runtime/components/Layout.vue +79 -0
  32. package/dist/runtime/components/Layout.vue.d.ts +27 -0
  33. package/dist/runtime/components/ModalConfirm.d.vue.ts +33 -0
  34. package/dist/runtime/components/ModalConfirm.vue.d.ts +3 -2
  35. package/dist/runtime/components/TableColumnSorting.d.vue.ts +17 -0
  36. package/dist/runtime/components/{TablePanelColumnSorting.vue → TableColumnSorting.vue} +27 -18
  37. package/dist/runtime/components/TableColumnSorting.vue.d.ts +17 -0
  38. package/dist/runtime/components/TableColumnVisibility.d.vue.ts +24 -0
  39. package/dist/runtime/components/TableColumnVisibility.vue +111 -0
  40. package/dist/runtime/components/TableColumnVisibility.vue.d.ts +24 -0
  41. package/dist/runtime/components/TableFilters.d.vue.ts +90 -0
  42. package/dist/runtime/components/TableFilters.vue +198 -0
  43. package/dist/runtime/components/TableFilters.vue.d.ts +90 -0
  44. package/dist/runtime/components/TablePanel.d.vue.ts +95 -0
  45. package/dist/runtime/components/TablePanel.vue +207 -66
  46. package/dist/runtime/components/TablePanel.vue.d.ts +76 -31
  47. package/dist/runtime/components/TableSearchInput.d.vue.ts +33 -0
  48. package/dist/runtime/components/TableSearchInput.vue +96 -0
  49. package/dist/runtime/components/TableSearchInput.vue.d.ts +33 -0
  50. package/dist/runtime/components/UploraImage.d.vue.ts +35 -0
  51. package/dist/runtime/components/UploraImage.vue.d.ts +3 -2
  52. package/dist/runtime/components/prose/UploraImage.d.vue.ts +14 -0
  53. package/dist/runtime/components/prose/UploraImage.vue.d.ts +2 -1
  54. package/dist/runtime/composables/useAdmin.d.ts +1 -1
  55. package/dist/runtime/composables/useAdmin.js +2 -1
  56. package/dist/runtime/composables/useApi.d.ts +1 -1
  57. package/dist/runtime/composables/useAsyncHandler.d.ts +1 -1
  58. package/dist/runtime/composables/useAsyncHandler.js +1 -1
  59. package/dist/runtime/composables/useEditorDragHandle.d.ts +16 -0
  60. package/dist/runtime/composables/useEditorDragHandle.js +95 -0
  61. package/dist/runtime/composables/useEditorSuggestions.d.ts +68 -0
  62. package/dist/runtime/composables/useEditorSuggestions.js +24 -0
  63. package/dist/runtime/composables/useEditorToolbar.d.ts +120 -0
  64. package/dist/runtime/composables/useEditorToolbar.js +87 -0
  65. package/dist/runtime/composables/useFormState.d.ts +12 -0
  66. package/dist/runtime/composables/useFormState.js +33 -0
  67. package/dist/runtime/composables/useLogout.d.ts +1 -1
  68. package/dist/runtime/composables/useLogout.js +3 -1
  69. package/dist/runtime/composables/useNotification.d.ts +12 -0
  70. package/dist/runtime/composables/useNotification.js +46 -0
  71. package/dist/runtime/composables/useQueryState.d.ts +28 -0
  72. package/dist/runtime/composables/useQueryState.js +105 -0
  73. package/dist/runtime/composables/useRouteQuery.d.ts +37 -0
  74. package/dist/runtime/composables/useRouteQuery.js +81 -0
  75. package/dist/runtime/composables/useRowSelection.d.ts +8 -0
  76. package/dist/runtime/composables/useRowSelection.js +46 -0
  77. package/dist/runtime/composables/useTable.d.ts +17 -11
  78. package/dist/runtime/composables/useTable.js +47 -53
  79. package/dist/runtime/composables/useUplora.d.ts +1 -1
  80. package/dist/runtime/composables/useUplora.js +2 -1
  81. package/dist/runtime/index.css +1 -1
  82. package/dist/runtime/plugins/zod.d.ts +2 -0
  83. package/dist/runtime/plugins/zod.js +26 -0
  84. package/dist/runtime/server/api/uplora/[id].delete.d.ts +1 -5
  85. package/dist/runtime/tv.d.ts +1 -1
  86. package/dist/runtime/types/date.d.ts +5 -0
  87. package/dist/runtime/types/index.d.ts +3 -21
  88. package/dist/runtime/types/index.js +1 -21
  89. package/dist/runtime/types/utils.d.ts +7 -0
  90. package/dist/runtime/utils/date.d.ts +9 -0
  91. package/dist/runtime/utils/date.js +28 -0
  92. package/dist/runtime/utils/formatters.d.ts +2 -0
  93. package/dist/runtime/utils/formatters.js +8 -0
  94. package/dist/runtime/utils/index.d.ts +5 -2
  95. package/dist/runtime/utils/index.js +5 -2
  96. package/dist/runtime/utils/storage.d.ts +2 -0
  97. package/dist/runtime/utils/storage.js +10 -0
  98. package/dist/runtime/utils/table.d.ts +23 -0
  99. package/dist/runtime/utils/table.js +51 -0
  100. package/package.json +26 -25
  101. package/.nuxt/cms/button-clear.ts +0 -5
  102. package/.nuxt/cms/button-copy.ts +0 -5
  103. package/.nuxt/cms/button-delete.ts +0 -5
  104. package/.nuxt/cms/editor/callout.ts +0 -21
  105. package/.nuxt/cms/editor/uplora-image.ts +0 -5
  106. package/.nuxt/cms/editor-content-full.ts +0 -13
  107. package/.nuxt/cms/editor-content-light.ts +0 -13
  108. package/.nuxt/cms/input-seo.ts +0 -5
  109. package/.nuxt/cms/input-slug.ts +0 -5
  110. package/.nuxt/cms/input-uplora-image.ts +0 -22
  111. package/.nuxt/cms/table-cell-preview.ts +0 -9
  112. package/.nuxt/cms/table-cell-seo.ts +0 -5
  113. package/.nuxt/cms/table-cell-user.ts +0 -9
  114. package/.nuxt/cms/table-panel-column-sorting.ts +0 -5
  115. package/.nuxt/cms/table-panel-column-visibility.ts +0 -5
  116. package/.nuxt/cms/table-panel-filters.ts +0 -5
  117. package/dist/runtime/components/ButtonClear.vue +0 -35
  118. package/dist/runtime/components/ButtonClear.vue.d.ts +0 -35
  119. package/dist/runtime/components/ButtonCopy.vue +0 -40
  120. package/dist/runtime/components/ButtonCopy.vue.d.ts +0 -23
  121. package/dist/runtime/components/EditorContentFull.vue +0 -67
  122. package/dist/runtime/components/EditorContentFull.vue.d.ts +0 -23
  123. package/dist/runtime/components/EditorContentLight.vue +0 -60
  124. package/dist/runtime/components/EditorContentLight.vue.d.ts +0 -23
  125. package/dist/runtime/components/InputSeo.vue +0 -73
  126. package/dist/runtime/components/InputSeo.vue.d.ts +0 -19
  127. package/dist/runtime/components/InputSlug.vue +0 -70
  128. package/dist/runtime/components/InputSlug.vue.d.ts +0 -29
  129. package/dist/runtime/components/InputUploraImage.vue +0 -156
  130. package/dist/runtime/components/InputUploraImage.vue.d.ts +0 -38
  131. package/dist/runtime/components/TableCellPreview.vue +0 -41
  132. package/dist/runtime/components/TableCellPreview.vue.d.ts +0 -18
  133. package/dist/runtime/components/TableCellSeo.vue +0 -34
  134. package/dist/runtime/components/TableCellSeo.vue.d.ts +0 -13
  135. package/dist/runtime/components/TableCellUser.vue +0 -40
  136. package/dist/runtime/components/TableCellUser.vue.d.ts +0 -18
  137. package/dist/runtime/components/TablePanelColumnSorting.vue.d.ts +0 -20
  138. package/dist/runtime/components/TablePanelColumnVisibility.vue +0 -49
  139. package/dist/runtime/components/TablePanelColumnVisibility.vue.d.ts +0 -20
  140. package/dist/runtime/components/TablePanelFilters.vue +0 -79
  141. package/dist/runtime/components/TablePanelFilters.vue.d.ts +0 -34
  142. package/dist/runtime/composables/useDeleteConfirm.d.ts +0 -15
  143. package/dist/runtime/composables/useDeleteConfirm.js +0 -27
  144. package/dist/runtime/composables/useSeoStats.d.ts +0 -12
  145. package/dist/runtime/composables/useSeoStats.js +0 -44
  146. package/dist/runtime/editor/components/BlockMenu.vue +0 -43
  147. package/dist/runtime/editor/components/BlockMenu.vue.d.ts +0 -2
  148. package/dist/runtime/editor/components/SlashCommand.vue +0 -92
  149. package/dist/runtime/editor/components/SlashCommand.vue.d.ts +0 -7
  150. package/dist/runtime/editor/components/TooltipLink.vue +0 -81
  151. package/dist/runtime/editor/components/TooltipLink.vue.d.ts +0 -9
  152. package/dist/runtime/editor/components/TooltipMenu.vue +0 -75
  153. package/dist/runtime/editor/components/TooltipMenu.vue.d.ts +0 -9
  154. package/dist/runtime/editor/extensions/callout/CalloutView.vue +0 -85
  155. package/dist/runtime/editor/extensions/callout/CalloutView.vue.d.ts +0 -7
  156. package/dist/runtime/editor/extensions/callout/extension.d.ts +0 -13
  157. package/dist/runtime/editor/extensions/callout/extension.js +0 -48
  158. package/dist/runtime/editor/extensions/callout/index.d.ts +0 -2
  159. package/dist/runtime/editor/extensions/callout/index.js +0 -2
  160. package/dist/runtime/editor/extensions/callout/types.d.ts +0 -3
  161. package/dist/runtime/editor/extensions/index.d.ts +0 -26
  162. package/dist/runtime/editor/extensions/index.js +0 -85
  163. package/dist/runtime/editor/extensions/uplora-image/UploraImageView.vue +0 -29
  164. package/dist/runtime/editor/extensions/uplora-image/UploraImageView.vue.d.ts +0 -7
  165. package/dist/runtime/editor/extensions/uplora-image/extension.d.ts +0 -13
  166. package/dist/runtime/editor/extensions/uplora-image/extension.js +0 -60
  167. package/dist/runtime/editor/extensions/uplora-image/index.d.ts +0 -2
  168. package/dist/runtime/editor/extensions/uplora-image/index.js +0 -2
  169. package/dist/runtime/editor/extensions/uplora-image/types.d.ts +0 -5
  170. package/dist/runtime/editor/extensions/uplora-image/types.js +0 -0
  171. package/dist/runtime/editor/markdown/index.d.ts +0 -3
  172. package/dist/runtime/editor/markdown/index.js +0 -47
  173. package/dist/runtime/editor/markdown/nodes/callout.d.ts +0 -2
  174. package/dist/runtime/editor/markdown/nodes/callout.js +0 -21
  175. package/dist/runtime/editor/markdown/nodes/uploraImage.d.ts +0 -2
  176. package/dist/runtime/editor/markdown/nodes/uploraImage.js +0 -31
  177. package/dist/runtime/utils/dictionaries.d.ts +0 -4
  178. package/dist/runtime/utils/dictionaries.js +0 -6
  179. /package/.nuxt/cms/{autocomplete-select.ts → button-delete-confirm.ts} +0 -0
  180. /package/dist/runtime/{editor/extensions/callout/types.js → types/date.js} +0 -0
  181. /package/dist/runtime/utils/{image.d.ts → uplora.d.ts} +0 -0
  182. /package/dist/runtime/utils/{image.js → uplora.js} +0 -0
@@ -0,0 +1,28 @@
1
+ import type { MaybeRefOrGetter, Ref } from 'vue';
2
+ import type { LocationQueryValue } from 'vue-router';
3
+ type RouteQueryValueRaw = LocationQueryValue | LocationQueryValue[] | undefined;
4
+ type QueryTransformGetter<Default, Value = Default> = (queryOrDefault: Default | RouteQueryValueRaw) => Value;
5
+ type QueryTransform<Default, Value = Default> = QueryTransformGetter<Default, Value> | ({
6
+ get?: QueryTransformGetter<Default, Value>;
7
+ set?: (value: Value) => RouteQueryValueRaw;
8
+ });
9
+ interface Transforms<Default> {
10
+ number: QueryTransformGetter<number | Default>;
11
+ boolean: QueryTransformGetter<boolean | Default>;
12
+ date: QueryTransformGetter<string | Default>;
13
+ dateRange: QueryTransform<{
14
+ end: string;
15
+ start: string;
16
+ } | Default>;
17
+ arrayString: QueryTransformGetter<any[] extends Default ? Default : string[]>;
18
+ }
19
+ type GetTransform<T> = keyof {
20
+ [P in keyof Transforms<T> as Transforms<T>[P] extends QueryTransform<any, T> ? P : never]: P;
21
+ };
22
+ export type GetQueryTransforms<T> = {
23
+ [P in keyof T as T[P] extends Exclude<RouteQueryValueRaw, any[]> ? never : P]: GetTransform<T[P]> | QueryTransform<T[P], T[P]>;
24
+ } & {
25
+ [P in keyof T as T[P] extends Exclude<RouteQueryValueRaw, any[]> ? P : never]?: GetTransform<T[P]> | QueryTransform<T[P], T[P]>;
26
+ };
27
+ export declare function useQueryState<T extends Record<string, any>>(defaults: MaybeRefOrGetter<T>, stateTransforms: GetQueryTransforms<T>): Ref<T>;
28
+ export {};
@@ -0,0 +1,105 @@
1
+ import { useRoute, useRouter } from "#imports";
2
+ import { computed, customRef, reactive, toValue, watch } from "vue";
3
+ import { formatServerDateTime } from "../utils/date.js";
4
+ import { useRouteQuery } from "./useRouteQuery.js";
5
+ const valuesCache = /* @__PURE__ */ new WeakMap();
6
+ const queryTransforms = {
7
+ number: (val) => val === null || val === void 0 ? val : Number(val),
8
+ boolean: (val) => val === null || val === void 0 ? val : val === "true" ? true : val === "false" ? false : Boolean(val),
9
+ date: (val) => val === null || val === void 0 ? val : formatServerDateTime(val),
10
+ dateRange: {
11
+ get: (val) => {
12
+ if (!Array.isArray(val)) {
13
+ return val;
14
+ }
15
+ if (valuesCache.has(val)) {
16
+ return valuesCache.get(val);
17
+ }
18
+ const date = {
19
+ start: formatServerDateTime(val[0]),
20
+ end: formatServerDateTime(val[1])
21
+ };
22
+ valuesCache.set(val, date);
23
+ return date;
24
+ },
25
+ set: (value) => {
26
+ if (!value || typeof value !== "object") {
27
+ return value;
28
+ }
29
+ return [value.start, value.end];
30
+ }
31
+ },
32
+ arrayString: (val) => {
33
+ if (typeof val === "string") {
34
+ val = [val];
35
+ }
36
+ if (!Array.isArray(val)) {
37
+ return val;
38
+ }
39
+ if (valuesCache.has(val)) {
40
+ return valuesCache.get(val);
41
+ } else {
42
+ valuesCache.set(val, val);
43
+ }
44
+ return val;
45
+ }
46
+ };
47
+ export function useQueryState(defaults, stateTransforms) {
48
+ const route = useRoute();
49
+ const router = useRouter();
50
+ const defaultsValue = computed(() => toValue(defaults));
51
+ const proxy = customRef((track, trigger) => {
52
+ let queryState = { _initial: true };
53
+ return {
54
+ get: () => {
55
+ track();
56
+ return queryState;
57
+ },
58
+ set: (newValue) => {
59
+ if (newValue === queryState) {
60
+ return;
61
+ }
62
+ if (typeof newValue !== "object" || newValue === null) {
63
+ queryState = newValue;
64
+ return trigger();
65
+ }
66
+ const defaultValuesValue = defaultsValue.value;
67
+ const newQueryState = {};
68
+ for (const key in newValue) {
69
+ const query = createQuery(key, defaultValuesValue[key]);
70
+ const newValueField = newValue[key];
71
+ if (query.value !== newValueField && !queryState._initial) {
72
+ query.value = newValueField;
73
+ }
74
+ newQueryState[key] = query;
75
+ }
76
+ queryState = reactive(newQueryState);
77
+ trigger();
78
+ }
79
+ };
80
+ });
81
+ watch(() => toValue(defaults), (value) => {
82
+ proxy.value = value;
83
+ }, { immediate: true });
84
+ function getTransform(key) {
85
+ if (!stateTransforms[key]) {
86
+ return void 0;
87
+ }
88
+ const transform = stateTransforms[key];
89
+ if (typeof transform !== "function" && typeof transform !== "string") {
90
+ return void 0;
91
+ }
92
+ if (typeof transform === "string") {
93
+ return queryTransforms[transform];
94
+ }
95
+ return transform;
96
+ }
97
+ function createQuery(key, value) {
98
+ return useRouteQuery(key, value, {
99
+ transform: getTransform(key),
100
+ route,
101
+ router
102
+ });
103
+ }
104
+ return proxy;
105
+ }
@@ -0,0 +1,37 @@
1
+ import type { MaybeRef, MaybeRefOrGetter, Ref } from 'vue';
2
+ import type { RouteParamValueRaw } from 'vue-router';
3
+ import { useRoute, useRouter } from '#imports';
4
+ /**
5
+ * Скопировано из vueuse, модифицированно для поддержки не примитивов:
6
+ * @see https://github.com/vueuse/vueuse/blob/main/packages/router/useRouteQuery/index.ts
7
+ */
8
+ export type RouteQueryValueRaw = RouteParamValueRaw | string[];
9
+ interface ReactiveRouteOptions {
10
+ /**
11
+ * Mode to update the router query, ref is also acceptable
12
+ *
13
+ * @default 'replace'
14
+ */
15
+ mode?: MaybeRef<'replace' | 'push'>;
16
+ /**
17
+ * Route instance, use `useRoute()` if not given
18
+ */
19
+ route?: ReturnType<typeof useRoute>;
20
+ /**
21
+ * Router instance, use `useRouter()` if not given
22
+ */
23
+ router?: ReturnType<typeof useRouter>;
24
+ }
25
+ interface ReactiveRouteOptionsWithTransform<V, R> extends ReactiveRouteOptions {
26
+ /**
27
+ * Function to transform data before return, or an object with one or both functions:
28
+ * `get` to transform data before returning, and `set` to transform data before setting
29
+ */
30
+ transform?: ((val: V) => R) | ({
31
+ get?: (value: V) => R;
32
+ set?: (value: R) => V;
33
+ });
34
+ }
35
+ export declare function useRouteQuery(name: string): Ref<undefined | null | string | string[]>;
36
+ export declare function useRouteQuery<T extends RouteQueryValueRaw = RouteQueryValueRaw, K = T>(name: string, defaultValue?: MaybeRefOrGetter<T>, options?: ReactiveRouteOptionsWithTransform<T, K>): Ref<K>;
37
+ export {};
@@ -0,0 +1,81 @@
1
+ import { useRoute, useRouter } from "#imports";
2
+ import { tryOnScopeDispose } from "@vueuse/core";
3
+ import { customRef, nextTick, toValue, watch } from "vue";
4
+ const _queue = /* @__PURE__ */ new WeakMap();
5
+ export function useRouteQuery(name, defaultValue, options = {}) {
6
+ const {
7
+ mode = "replace",
8
+ route = useRoute(),
9
+ router = useRouter(),
10
+ transform
11
+ } = options;
12
+ let transformGet = (value) => value;
13
+ let transformSet = (value) => value;
14
+ if (typeof transform === "function") {
15
+ transformGet = transform;
16
+ } else if (transform) {
17
+ if (transform.get) {
18
+ transformGet = transform.get;
19
+ }
20
+ if (transform.set) {
21
+ transformSet = transform.set;
22
+ }
23
+ }
24
+ if (!_queue.has(router)) {
25
+ _queue.set(router, /* @__PURE__ */ new Map());
26
+ }
27
+ const _queriesQueue = _queue.get(router);
28
+ let query = route.query[name];
29
+ tryOnScopeDispose(() => {
30
+ query = void 0;
31
+ });
32
+ let _trigger;
33
+ const proxy = customRef((track, trigger) => {
34
+ _trigger = trigger;
35
+ return {
36
+ get() {
37
+ track();
38
+ return transformGet(query !== void 0 ? query : toValue(defaultValue));
39
+ },
40
+ set(v) {
41
+ v = transformSet(v);
42
+ if (query === v) {
43
+ return;
44
+ }
45
+ query = v === toValue(defaultValue) ? void 0 : v;
46
+ _queriesQueue.set(name, v === toValue(defaultValue) ? void 0 : v);
47
+ trigger();
48
+ nextTick(() => {
49
+ if (_queriesQueue.size === 0) {
50
+ return;
51
+ }
52
+ const newQueries = Object.fromEntries(_queriesQueue.entries());
53
+ _queriesQueue.clear();
54
+ const { params, query: query2, hash } = route;
55
+ router[toValue(mode)]({
56
+ params,
57
+ query: { ...query2, ...newQueries },
58
+ hash
59
+ });
60
+ });
61
+ }
62
+ };
63
+ });
64
+ watch(
65
+ () => route.query[name],
66
+ (v) => {
67
+ const newQueryValue = transformSet(transformGet(v));
68
+ if (query === newQueryValue) {
69
+ return;
70
+ }
71
+ if (JSON.stringify(query) === JSON.stringify(newQueryValue)) {
72
+ query = v;
73
+ return;
74
+ }
75
+ query = v;
76
+ _trigger();
77
+ },
78
+ { flush: "sync" }
79
+ );
80
+ return proxy;
81
+ }
@@ -0,0 +1,8 @@
1
+ import type { RowSelectionState } from '@tanstack/vue-table';
2
+ import type { MaybeRefOrGetter } from 'vue';
3
+ export declare function useRowSelection<T extends Record<any, any>, P extends keyof T>(state: MaybeRefOrGetter<RowSelectionState | undefined>, data: MaybeRefOrGetter<T[] | undefined>, key: P): {
4
+ rowSelection: import("vue").Ref<RowSelectionState | undefined, RowSelectionState | undefined>;
5
+ getRowId: (originalRow: T, index: number, parent?: import("@tanstack/table-core").Row<T> | undefined) => string;
6
+ selectedItems: import("vue").ComputedRef<T[]>;
7
+ selectedIds: import("vue").ComputedRef<T[P][]>;
8
+ };
@@ -0,0 +1,46 @@
1
+ import { useCloned } from "@vueuse/core";
2
+ import clone from "fast-copy";
3
+ import { computed, shallowRef, toValue, triggerRef, watch } from "vue";
4
+ export function useRowSelection(state, data, key) {
5
+ const { cloned: rowSelection } = useCloned(state, { clone });
6
+ const getRowId = (row) => {
7
+ return String(row[key]);
8
+ };
9
+ const dataMap = computed(() => {
10
+ return new Map(
11
+ toValue(data)?.map((item, index) => [getRowId(item, index), item]) ?? []
12
+ );
13
+ });
14
+ const cache = shallowRef(/* @__PURE__ */ new Map());
15
+ watch([rowSelection, dataMap], ([rowSelection2, dataMap2]) => {
16
+ rowSelection2 ??= {};
17
+ cache.value.keys().forEach((id) => {
18
+ if (!rowSelection2[id]) {
19
+ cache.value.delete(id);
20
+ }
21
+ });
22
+ Object.entries(rowSelection2).forEach(([id, selected]) => {
23
+ if (!selected) {
24
+ return;
25
+ }
26
+ const item = dataMap2.get(id) ?? cache.value.get(id);
27
+ if (!item) {
28
+ return console.warn(`Item with id ${id} not found`);
29
+ }
30
+ cache.value.set(id, item);
31
+ });
32
+ triggerRef(cache);
33
+ }, { immediate: true });
34
+ const selectedItems = computed(() => {
35
+ return cache.value.values().toArray();
36
+ });
37
+ const selectedIds = computed(() => {
38
+ return selectedItems.value.map((item) => item[key]);
39
+ });
40
+ return {
41
+ rowSelection,
42
+ getRowId,
43
+ selectedItems,
44
+ selectedIds
45
+ };
46
+ }
@@ -1,19 +1,25 @@
1
1
  import type { SortingState } from '@tanstack/vue-table';
2
2
  import type { ComputedRef, MaybeRefOrGetter, Ref } from 'vue';
3
- import type { PaginationQuery, SortQuery } from '../types';
3
+ import type { PaginationQuery, RequiredOptional, SortQuery } from '../types';
4
+ import type { GetQueryTransforms } from './useQueryState';
5
+ interface UseTableOptions<T> {
6
+ query?: {
7
+ enabled?: true | false;
8
+ transform: GetQueryTransforms<T>;
9
+ };
10
+ }
4
11
  interface UseTableReturn<T> {
5
- models: Ref<T>;
6
- appliedCount: ComputedRef<number>;
7
- applyFilters: () => void;
8
- resetFilters: () => void;
12
+ source: ComputedRef<T>;
13
+ filters: Ref<T>;
14
+ updateFilters: (value: Partial<T>) => void;
9
15
  sorting: Ref<SortingState>;
10
16
  pagination: Ref<PaginationQuery>;
11
- filters: Ref<T>;
12
17
  query: ComputedRef<T & PaginationQuery & SortQuery | object>;
13
18
  }
14
- interface UseTableOptions<T> {
15
- defaultSort?: SortQuery;
16
- countFiltersExcept?: Array<keyof T>;
17
- }
18
- export default function useTable<T extends object>(initialFilters: MaybeRefOrGetter<T>, options?: UseTableOptions<T>): UseTableReturn<T>;
19
+ export declare function useTableFilters<T extends Record<string, any>>(initialFilters: MaybeRefOrGetter<T>, options?: UseTableOptions<T>): {
20
+ initial: ComputedRef<T>;
21
+ filters: Ref<T, T>;
22
+ updateFilters: (value: Partial<T>) => void;
23
+ };
24
+ export default function useTable<T extends Record<string, any>>(initialFilters: MaybeRefOrGetter<RequiredOptional<T>>, options?: UseTableOptions<RequiredOptional<T>>): UseTableReturn<RequiredOptional<T>>;
19
25
  export {};
@@ -1,90 +1,84 @@
1
- import { computed, reactive, ref, toRaw, toValue, watch } from "#imports";
2
- import { deepEqual } from "fast-equals";
3
- function useTableFilters(initialFilters, options) {
1
+ import copy from "fast-copy";
2
+ import { computed, ref, toValue, watch } from "vue";
3
+ import { useQueryState } from "./useQueryState.js";
4
+ export function useTableFilters(initialFilters, options) {
4
5
  const initial = computed(() => toValue(initialFilters));
5
- const filters = ref(structuredClone(initial.value));
6
- const models = ref(structuredClone(initial.value));
7
- const applyFilters = () => {
8
- filters.value = structuredClone(toRaw(models.value));
9
- };
10
- const resetFilters = () => {
11
- models.value = structuredClone(initial.value);
12
- applyFilters();
13
- };
14
- const appliedCountFields = computed(() => {
15
- const fields = Object.keys(initial.value);
16
- if (!options?.countFiltersExcept) {
17
- return fields;
18
- }
19
- return fields.filter((key) => {
20
- return !options.countFiltersExcept.includes(key);
21
- });
22
- });
23
- const appliedCount = computed(() => {
24
- return appliedCountFields.value.reduce((sum, key) => {
25
- return deepEqual(filters.value[key], initial.value[key]) ? sum : sum + 1;
26
- }, 0);
27
- });
6
+ const filters = options?.query?.enabled ? useQueryState(initial, options.query.transform) : ref(initial.value);
28
7
  watch(initial, (initial2) => {
29
- filters.value = structuredClone(initial2);
30
- models.value = structuredClone(initial2);
8
+ filters.value = copy(initial2);
31
9
  });
10
+ const updateFilters = (value) => {
11
+ Object.assign(filters.value, value);
12
+ };
32
13
  return {
14
+ initial,
33
15
  filters,
34
- models,
35
- appliedCount,
36
- applyFilters,
37
- resetFilters
16
+ updateFilters
38
17
  };
39
18
  }
40
- function useTableSort(defaultSort) {
41
- const state = reactive({ "sort.column": defaultSort?.sortColumn ?? null, "sort.type": defaultSort?.sortType ?? "desc" });
19
+ function useTablePagination(options) {
20
+ const initialPagination = { page: 1, perPage: 20 };
21
+ const pagination = options?.query?.enabled ? useQueryState(initialPagination, { page: "number", perPage: "number" }) : ref(initialPagination);
22
+ watch(() => pagination.value.perPage, () => {
23
+ if (pagination.value.page !== 1) {
24
+ pagination.value.page = 1;
25
+ }
26
+ });
27
+ return { pagination };
28
+ }
29
+ function useTableSort(query) {
30
+ const initialSort = { "sort.column": null, "sort.type": "asc" };
31
+ const state = query ? useQueryState(initialSort, {}) : ref(initialSort);
42
32
  const sort = computed(() => {
43
- if (!state["sort.column"]) {
33
+ if (!state.value["sort.column"]) {
44
34
  return null;
45
35
  }
46
- return { sortColumn: state["sort.column"], sortType: state["sort.type"] };
36
+ return { sortColumn: state.value["sort.column"], sortType: state.value["sort.type"] };
47
37
  });
48
38
  const sorting = computed({
49
- get: () => state["sort.column"] ? [{ id: state["sort.column"], desc: state["sort.type"] === "desc" }] : [],
39
+ get: () => {
40
+ if (!state.value["sort.column"]) {
41
+ return [];
42
+ }
43
+ return [{ id: state.value["sort.column"], desc: state.value["sort.type"] === "desc" }];
44
+ },
50
45
  set: (value) => {
51
46
  if (value.length === 0) {
52
- state["sort.column"] = null;
53
- state["sort.type"] = "asc";
47
+ state.value = { "sort.column": null, "sort.type": "asc" };
54
48
  return;
55
49
  }
56
50
  const { id, desc } = value[0];
57
- state["sort.column"] = id;
58
- state["sort.type"] = desc ? "desc" : "asc";
51
+ state.value = { "sort.column": id, "sort.type": desc ? "desc" : "asc" };
59
52
  }
60
53
  });
61
54
  return { sort, sorting };
62
55
  }
63
56
  export default function useTable(initialFilters, options) {
64
- const { filters, models, appliedCount, applyFilters, resetFilters } = useTableFilters(initialFilters, options);
65
- const { sort, sorting } = useTableSort(options?.defaultSort);
66
- const pagination = ref({ page: 1, perPage: 20 });
57
+ const {
58
+ initial,
59
+ filters,
60
+ updateFilters
61
+ } = useTableFilters(initialFilters, options);
62
+ const { sorting } = useTableSort(options?.query?.enabled ?? true);
63
+ const { pagination } = useTablePagination(options);
67
64
  const query = computed(() => {
68
65
  return {
69
66
  ...filters.value,
70
- ...sort.value,
67
+ ...sorting.value,
71
68
  ...pagination.value
72
69
  };
73
70
  });
74
- watch([filters, sort, () => pagination.value.perPage], () => {
75
- if (pagination.value.page === 1) {
76
- return;
71
+ watch(filters, () => {
72
+ if (pagination.value.page !== 1) {
73
+ pagination.value.page = 1;
77
74
  }
78
- pagination.value.page = 1;
79
75
  }, { deep: true });
80
76
  return {
81
- models,
82
- appliedCount,
83
- applyFilters,
84
- resetFilters,
77
+ source: initial,
85
78
  filters,
86
79
  sorting,
87
80
  pagination,
81
+ updateFilters,
88
82
  query
89
83
  };
90
84
  }
@@ -1,6 +1,6 @@
1
1
  import type { AsyncDataRequestStatus } from '#app';
2
- import type { Ref } from '#imports';
3
2
  import type { EventHookOn } from '@vueuse/shared';
3
+ import type { Ref } from 'vue';
4
4
  export interface UseUploraUploadOptions {
5
5
  accept?: string;
6
6
  }
@@ -1,4 +1,5 @@
1
- import { createEventHook, useFileDialog, useNuxtApp } from "#imports";
1
+ import { useNuxtApp } from "#imports";
2
+ import { createEventHook, useFileDialog } from "@vueuse/core";
2
3
  import { useAsyncHandler } from "./useAsyncHandler.js";
3
4
  export function useUploraUpload(options) {
4
5
  const { $api } = useNuxtApp();
@@ -1 +1 @@
1
- @import "@nuxt/ui-pro";@import "#build/cms.css";@source "./components";@source "./editor";
1
+ @import "@nuxt/ui";@import "#build/cms.css";@source "./components";@source "./editor";
@@ -0,0 +1,2 @@
1
+ declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,26 @@
1
+ import { defineNuxtPlugin } from "#imports";
2
+ import { z } from "zod";
3
+ import { ru } from "zod/locales";
4
+ export default defineNuxtPlugin({
5
+ name: "zod",
6
+ parallel: true,
7
+ setup: () => {
8
+ z.config({
9
+ ...ru(),
10
+ customError: (iss) => {
11
+ if (iss.code === "invalid_type" && (iss.input === void 0 || iss.input === null)) {
12
+ return "\u041F\u043E\u043B\u0435 \u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E \u043A \u0437\u0430\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u044E.";
13
+ }
14
+ if (iss.code === "invalid_value" && (iss.input === void 0 || iss.input === null)) {
15
+ return "\u041F\u043E\u043B\u0435 \u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E \u043A \u0437\u0430\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u044E.";
16
+ }
17
+ if (iss.code === "too_small" && iss.minimum === 1) {
18
+ return "\u041F\u043E\u043B\u0435 \u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E \u043A \u0437\u0430\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u044E.";
19
+ }
20
+ if (iss.code === "custom" && iss.path && iss.path.length > 0) {
21
+ return "\u041F\u043E\u043B\u0435 \u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E \u043A \u0437\u0430\u043F\u043E\u043B\u043D\u0435\u043D\u0438\u044E.";
22
+ }
23
+ }
24
+ });
25
+ }
26
+ });
@@ -1,10 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  export declare const filesDeleteRouteParamsSchema: z.ZodObject<{
3
3
  id: z.ZodString;
4
- }, "strip", z.ZodTypeAny, {
5
- id: string;
6
- }, {
7
- id: string;
8
- }>;
4
+ }, z.core.$strip>;
9
5
  declare const _default: import("h3").EventHandler<import("h3").EventHandlerRequest, Promise<void>>;
10
6
  export default _default;
@@ -1 +1 @@
1
- export declare const tv: import("tailwind-variants").CreateTV;
1
+ export declare const tv: import("tailwind-variants").TV;
@@ -0,0 +1,5 @@
1
+ export type DateType = string;
2
+ export interface DateRange {
3
+ start: DateType;
4
+ end: DateType;
5
+ }
@@ -1,24 +1,6 @@
1
- export * from '../components/AutocompleteSelect.vue';
2
- export * from '../components/ButtonClear.vue';
3
- export * from '../components/ButtonCopy.vue';
4
- export * from '../components/ButtonDelete.vue';
5
- export * from '../components/EditorContentFull.vue';
6
- export * from '../components/EditorContentLight.vue';
7
- export * from '../components/FormPanel.vue';
8
- export * from '../components/FormPanelAsideSection.vue';
9
- export * from '../components/FormPanelSection.vue';
10
- export * from '../components/InputSeo.vue';
11
- export * from '../components/InputSlug.vue';
12
- export * from '../components/InputUploraImage.vue';
13
- export * from '../components/ModalConfirm.vue';
14
- export * from '../components/TableCellPreview.vue';
15
- export * from '../components/TableCellSeo.vue';
16
- export * from '../components/TableCellUser.vue';
17
- export * from '../components/TablePanel.vue';
18
- export * from '../components/TablePanelColumnSorting.vue';
19
- export * from '../components/TablePanelColumnVisibility.vue';
20
- export * from '../components/TablePanelFilters.vue';
21
- export * from '../components/UploraImage.vue';
1
+ export type { FiltersField } from '../components/TableFilters.vue';
2
+ export type { ActionMenuItem } from '../components/TablePanel.vue';
3
+ export * from './date';
22
4
  export * from './image';
23
5
  export * from './query';
24
6
  export * from './seo';
@@ -1,24 +1,4 @@
1
- export * from "../components/AutocompleteSelect.vue";
2
- export * from "../components/ButtonClear.vue";
3
- export * from "../components/ButtonCopy.vue";
4
- export * from "../components/ButtonDelete.vue";
5
- export * from "../components/EditorContentFull.vue";
6
- export * from "../components/EditorContentLight.vue";
7
- export * from "../components/FormPanel.vue";
8
- export * from "../components/FormPanelAsideSection.vue";
9
- export * from "../components/FormPanelSection.vue";
10
- export * from "../components/InputSeo.vue";
11
- export * from "../components/InputSlug.vue";
12
- export * from "../components/InputUploraImage.vue";
13
- export * from "../components/ModalConfirm.vue";
14
- export * from "../components/TableCellPreview.vue";
15
- export * from "../components/TableCellSeo.vue";
16
- export * from "../components/TableCellUser.vue";
17
- export * from "../components/TablePanel.vue";
18
- export * from "../components/TablePanelColumnSorting.vue";
19
- export * from "../components/TablePanelColumnVisibility.vue";
20
- export * from "../components/TablePanelFilters.vue";
21
- export * from "../components/UploraImage.vue";
1
+ export * from "./date.js";
22
2
  export * from "./image.js";
23
3
  export * from "./query.js";
24
4
  export * from "./seo.js";
@@ -4,3 +4,10 @@ export type AcceptableValue = Exclude<_AcceptableValue, Record<string, any>>;
4
4
  export type KeysMatching<T, V> = {
5
5
  [K in keyof T]: T[K] extends V ? K : never;
6
6
  }[keyof T];
7
+ export type OptionalKeys<T extends object, P extends keyof T> = Omit<T, P> & Partial<Pick<T, P>>;
8
+ export type PickOptional<T> = {
9
+ [P in keyof T as T extends Record<P, T[P]> ? never : P]: P;
10
+ };
11
+ export type RequiredOptional<T> = T & {
12
+ [P in keyof Required<PickOptional<T>>]: T[P] | undefined;
13
+ };
@@ -0,0 +1,9 @@
1
+ import type { DateLike } from '@vueuse/core';
2
+ import type { DateRange } from '../types/date';
3
+ export declare function getPeriod(beforeDays: number, afterDays?: number, fixTime?: boolean): DateRange;
4
+ export declare function getPeriodFromDaysAgo(days: number, fixTime?: boolean): DateRange;
5
+ export declare function getCurrentDayPeriod(): DateRange;
6
+ export declare function formatDateTime(date: DateLike): string;
7
+ export declare function formatDate(date: DateLike): string;
8
+ export declare function formatTime(date: DateLike): string;
9
+ export declare function formatServerDateTime(date: DateLike): string;