@hywax/cms 0.0.22 → 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 -182
  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 -6
  107. package/.nuxt/cms/editor-content-light.ts +0 -6
  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 -15
  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 -53
  122. package/dist/runtime/components/EditorContentFull.vue.d.ts +0 -20
  123. package/dist/runtime/components/EditorContentLight.vue +0 -46
  124. package/dist/runtime/components/EditorContentLight.vue.d.ts +0 -20
  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 -136
  130. package/dist/runtime/components/InputUploraImage.vue.d.ts +0 -35
  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,24 @@
1
+ import type { ColumnOrderState, Table, VisibilityState } from '@tanstack/vue-table';
2
+ export interface TableColumnVisibilityProps {
3
+ storageKey?: string;
4
+ table?: Table<any>;
5
+ }
6
+ export type TableColumnVisibilityModel = VisibilityState;
7
+ export type TableColumnVisibilityOrderModel = ColumnOrderState;
8
+ type __VLS_Props = TableColumnVisibilityProps;
9
+ type __VLS_ModelProps = {
10
+ 'visibility'?: TableColumnVisibilityModel;
11
+ 'order'?: TableColumnVisibilityOrderModel;
12
+ };
13
+ type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
14
+ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
15
+ "update:visibility": (value: VisibilityState) => any;
16
+ "update:order": (value: ColumnOrderState) => any;
17
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
18
+ "onUpdate:visibility"?: ((value: VisibilityState) => any) | undefined;
19
+ "onUpdate:order"?: ((value: ColumnOrderState) => any) | undefined;
20
+ }>, {
21
+ storageKey: string;
22
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
23
+ declare const _default: typeof __VLS_export;
24
+ export default _default;
@@ -0,0 +1,90 @@
1
+ import type { FormData, FormFieldProps, FormProps, FormSchema, SelectItem, SelectProps, SelectValue } from '@nuxt/ui';
2
+ import type { MaybeRef, VNode } from 'vue';
3
+ import type { KeysMatching } from '../types';
4
+ import type { Props as DatePickerProps } from './DatePicker.vue';
5
+ type EnumSelectItem = SelectValue | Required<Pick<Extract<SelectItem, object>, 'value' | 'label'>>;
6
+ interface Presets {
7
+ Input: {
8
+ modelValue: string | undefined;
9
+ placeholder?: string;
10
+ };
11
+ InputNumber: {
12
+ modelValue: number | undefined;
13
+ placeholder?: string;
14
+ };
15
+ Date: {
16
+ modelValue: DatePickerProps<false>['modelValue'];
17
+ withTime?: DatePickerProps<false>['withTime'];
18
+ };
19
+ DateRange: {
20
+ modelValue: DatePickerProps<true>['modelValue'];
21
+ withTime?: DatePickerProps<true>['withTime'];
22
+ };
23
+ Select: Pick<SelectProps<EnumSelectItem[]>, 'modelValue' | 'items' | 'placeholder'>;
24
+ MultiSelect: Pick<SelectProps<EnumSelectItem[], 'value', true>, 'modelValue' | 'items' | 'placeholder'>;
25
+ Checkbox: {
26
+ modelValue: boolean | undefined;
27
+ };
28
+ Switch: {
29
+ modelValue: boolean | undefined;
30
+ };
31
+ }
32
+ type GetPresetProps<K extends Presets[keyof Presets]> = {
33
+ [P in keyof Omit<K, 'modelValue'>]: MaybeRef<K[P]>;
34
+ };
35
+ type PresetField<S extends FormSchema = FormSchema> = {
36
+ [P in keyof Presets]: {
37
+ name: KeysMatching<FormData<S>, Presets[P]['modelValue']>;
38
+ render?: P;
39
+ } & GetPresetProps<Presets[P]>;
40
+ }[keyof Presets];
41
+ interface BaseField<S extends FormSchema = FormSchema> {
42
+ name: keyof FormData<S> & string;
43
+ render?: (state: FormData<S>, field: FiltersField<S>) => VNode;
44
+ }
45
+ export type FiltersField<S extends FormSchema = FormSchema> = Omit<FormFieldProps, 'name'> & (BaseField<S> | PresetField<S>);
46
+ export type TableFiltersModel<S extends FormSchema> = FormData<S>;
47
+ export interface TableFiltersProps<S extends FormSchema, F extends FiltersField<S>[] = FiltersField<S>[]> extends Omit<FormProps<S>, 'transform' | 'onSubmit' | 'id' | 'state' | 'nested' | 'name'> {
48
+ source: FormData<S>;
49
+ fields?: F;
50
+ }
51
+ export type TableFiltersSlots<S extends FormSchema> = {
52
+ [K in Extract<keyof FormData<S>, string>]: (props: {
53
+ model: FormData<S>[K];
54
+ state: FormData<S>;
55
+ updateModel: (value: FormData<S>[K]) => any;
56
+ }) => any;
57
+ };
58
+ export interface TableFiltersEmits<S extends FormSchema> {
59
+ submit: [TableFiltersModel<S>];
60
+ reset: [TableFiltersModel<S>];
61
+ }
62
+ declare const _default: typeof __VLS_export;
63
+ export default _default;
64
+ declare const __VLS_export: <S extends FormSchema, F extends FiltersField<S>[] = FiltersField<S>[]>(__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<{
65
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<(TableFiltersProps<S, F> & {
66
+ modelValue?: TableFiltersModel<S>;
67
+ }) & {
68
+ onReset?: ((args_0: import("@nuxt/ui").InferOutput<S>) => any) | undefined;
69
+ onSubmit?: ((args_0: import("@nuxt/ui").InferOutput<S>) => any) | undefined;
70
+ "onUpdate:modelValue"?: ((value: import("@nuxt/ui").InferOutput<S> | undefined) => any) | undefined;
71
+ }> & (typeof globalThis extends {
72
+ __VLS_PROPS_FALLBACK: infer P;
73
+ } ? P : {});
74
+ expose: (exposed: import("vue").ShallowUnwrapRef<{
75
+ appliedFields: import("vue").ComputedRef<FiltersField<S>[]>;
76
+ clearField: (field: FiltersField<S>) => void;
77
+ reset: () => void;
78
+ submit: (data: TableFiltersModel<S>) => void;
79
+ }>) => void;
80
+ attrs: any;
81
+ slots: TableFiltersSlots<S>;
82
+ emit: (((evt: "reset", args_0: import("@nuxt/ui").InferOutput<S>) => void) & ((evt: "submit", args_0: import("@nuxt/ui").InferOutput<S>) => void)) & ((evt: "update:modelValue", value: import("@nuxt/ui").InferOutput<S> | undefined) => void);
83
+ }>) => import("vue").VNode & {
84
+ __ctx?: Awaited<typeof __VLS_setup>;
85
+ };
86
+ type __VLS_PrettifyLocal<T> = (T extends any ? {
87
+ [K in keyof T]: T[K];
88
+ } : {
89
+ [K in keyof T as K]: T[K];
90
+ }) & {};
@@ -0,0 +1,198 @@
1
+ <template>
2
+ <UPopover v-model:open="isOpen">
3
+ <UChip
4
+ :ui="{ base: 'z-1 size-3' }"
5
+ :show="appliedFields.length > 0"
6
+ :text="appliedFields.length"
7
+ size="xl"
8
+ >
9
+ <UButton
10
+ variant="soft"
11
+ color="neutral"
12
+ label="Фильтры"
13
+ :icon="appConfig.ui.icons.filter"
14
+ />
15
+ </UChip>
16
+
17
+ <template #content>
18
+ <UForm
19
+ :id="formId"
20
+ ref="filters-form"
21
+ class="p-4 w-xs max-h-[60vh] overflow-y-auto"
22
+ :state="models"
23
+ :schema="schema"
24
+ @submit="submit($event.data)"
25
+ >
26
+ <UFormField
27
+ v-for="field of fields"
28
+ :key="field.name"
29
+ v-bind="field"
30
+ >
31
+ <slot
32
+ :name="field.name"
33
+ :model="models[field.name]"
34
+ :state="models"
35
+ :update-model="(value) => models[field.name] = value"
36
+ >
37
+ <component
38
+ :is="presets[field.render]?.(models, field)"
39
+ v-if="typeof field.render === 'string'"
40
+ />
41
+
42
+ <component
43
+ :is="field.render(models, field)"
44
+ v-else-if="field.render"
45
+ />
46
+ </slot>
47
+ </UFormField>
48
+ </UForm>
49
+
50
+ <USeparator class="mt-0" orientation="horizontal" />
51
+
52
+ <div class="flex justify-end space-x-2 p-4">
53
+ <UButton
54
+ color="neutral"
55
+ label="Сбросить"
56
+ variant="outline"
57
+ @click="reset"
58
+ />
59
+
60
+ <UButton
61
+ type="submit"
62
+ label="Подтвердить"
63
+ :color="formRef && formRef.errors.length > 0 ? 'error' : 'primary'"
64
+ :form="formId"
65
+ />
66
+ </div>
67
+ </template>
68
+ </UPopover>
69
+ </template>
70
+
71
+ <script>
72
+ import { LazyCDatePicker, LazyUCheckbox, LazyUInput, LazyUSelect, LazyUSwitch, UForm } from "#components";
73
+ import { useAppConfig } from "#imports";
74
+ import { useCloned } from "@vueuse/core";
75
+ import copy from "fast-copy";
76
+ import { deepEqual } from "fast-equals";
77
+ import { computed, h, nextTick, ref, toValue, unref, useId, useTemplateRef, watch } from "vue";
78
+ const presets = {
79
+ Date: (state, field) => h(LazyCDatePicker, {
80
+ "modelValue": state[field.name],
81
+ "withTime": toValue(field.withTime),
82
+ "onUpdate:modelValue": (value) => state[field.name] = value
83
+ }),
84
+ DateRange: (state, field) => h(LazyCDatePicker, {
85
+ "modelValue": state[field.name],
86
+ "range": true,
87
+ "withTime": unref(field.withTime),
88
+ "onUpdate:modelValue": (value) => state[field.name] = value
89
+ }),
90
+ Input: (state, field) => h(LazyUInput, {
91
+ "modelValue": state[field.name],
92
+ "modelModifiers": { trim: true, optional: true },
93
+ "placeholder": unref(field.placeholder) ?? `\u0412\u0432\u0435\u0434\u0438\u0442\u0435 ${field.label?.toLowerCase() ?? "\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"}`,
94
+ "onUpdate:modelValue": (value) => state[field.name] = value
95
+ }, {}),
96
+ InputNumber: (state, field) => h(LazyUInput, {
97
+ "modelValue": state[field.name],
98
+ "modelModifiers": { number: true, optional: true },
99
+ "placeholder": unref(field.placeholder) ?? `\u0412\u0432\u0435\u0434\u0438\u0442\u0435 ${field.label?.toLowerCase() ?? "\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"}`,
100
+ "onUpdate:modelValue": (value) => state[field.name] = value
101
+ }, {}),
102
+ Select: (state, field) => h(LazyUSelect, {
103
+ "modelValue": state[field.name],
104
+ "items": unref(field.items),
105
+ "placeholder": unref(field.placeholder) ?? `\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 ${field.label?.toLowerCase() ?? "\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"}`,
106
+ "onUpdate:modelValue": (value) => state[field.name] = value
107
+ }, {}),
108
+ MultiSelect: (state, field) => h(LazyUSelect, {
109
+ "modelValue": state[field.name],
110
+ "items": unref(field.items),
111
+ "placeholder": unref(field.placeholder) ?? `\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 ${field.label?.toLowerCase() ?? "\u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435"}`,
112
+ "multiple": true,
113
+ "onUpdate:modelValue": (value) => state[field.name] = value
114
+ }, {}),
115
+ Checkbox: (state, field) => h(LazyUCheckbox, {
116
+ "modelValue": state[field.name],
117
+ "label": unref(field.label),
118
+ "onUpdate:modelValue": (value) => state[field.name] = Boolean(value) || void 0
119
+ }),
120
+ Switch: (state, field) => h(LazyUSwitch, {
121
+ "modelValue": state[field.name],
122
+ "label": unref(field.label),
123
+ "onUpdate:modelValue": (value) => state[field.name] = value || void 0
124
+ })
125
+ };
126
+ </script>
127
+
128
+ <script setup>
129
+ const props = defineProps({
130
+ source: { type: null, required: true },
131
+ fields: { type: null, required: false },
132
+ schema: { type: null, required: false },
133
+ validate: { type: Function, required: false },
134
+ validateOn: { type: Array, required: false },
135
+ disabled: { type: Boolean, required: false },
136
+ validateOnInputDelay: { type: Number, required: false },
137
+ loadingAuto: { type: Boolean, required: false },
138
+ class: { type: null, required: false }
139
+ });
140
+ const emit = defineEmits(["submit", "reset"]);
141
+ defineSlots();
142
+ const appConfig = useAppConfig();
143
+ const filters = defineModel({ type: null });
144
+ const formId = `form-${useId()}`;
145
+ const formRef = useTemplateRef("filters-form");
146
+ const { cloned: models, sync: resetModels } = useCloned(() => props.source, {
147
+ clone: copy
148
+ });
149
+ const appliedFields = computed(() => {
150
+ return props.fields?.filter((field) => {
151
+ let value = filters.value?.[field.name];
152
+ let sourceValue = props.source?.[field.name];
153
+ if (value === "" || value === null || value === void 0 || Array.isArray(value) && value.length === 0) {
154
+ value = null;
155
+ }
156
+ if (sourceValue === "" || sourceValue === null || sourceValue === void 0 || Array.isArray(sourceValue) && sourceValue.length === 0) {
157
+ sourceValue = null;
158
+ }
159
+ return value !== sourceValue && !deepEqual(value, sourceValue);
160
+ }) ?? [];
161
+ });
162
+ let _isInternalUpdate = false;
163
+ watch(filters, (value) => {
164
+ if (!value) {
165
+ return;
166
+ }
167
+ if (_isInternalUpdate) {
168
+ return;
169
+ }
170
+ models.value = copy(value);
171
+ }, { immediate: true, deep: true });
172
+ const isOpen = ref(false);
173
+ function submit(data) {
174
+ filters.value = copy(data);
175
+ emit("submit", filters.value);
176
+ isOpen.value = false;
177
+ _isInternalUpdate = true;
178
+ nextTick(() => _isInternalUpdate = false);
179
+ }
180
+ function reset() {
181
+ resetModels();
182
+ filters.value = copy(models.value);
183
+ emit("reset", filters.value);
184
+ isOpen.value = false;
185
+ _isInternalUpdate = true;
186
+ nextTick(() => _isInternalUpdate = false);
187
+ }
188
+ function clearField(field) {
189
+ models.value = copy({ ...models.value, [field.name]: props.source[field.name] });
190
+ submit(models.value);
191
+ }
192
+ defineExpose({
193
+ appliedFields,
194
+ clearField,
195
+ reset,
196
+ submit
197
+ });
198
+ </script>
@@ -0,0 +1,90 @@
1
+ import type { FormData, FormFieldProps, FormProps, FormSchema, SelectItem, SelectProps, SelectValue } from '@nuxt/ui';
2
+ import type { MaybeRef, VNode } from 'vue';
3
+ import type { KeysMatching } from '../types';
4
+ import type { Props as DatePickerProps } from './DatePicker.vue';
5
+ type EnumSelectItem = SelectValue | Required<Pick<Extract<SelectItem, object>, 'value' | 'label'>>;
6
+ interface Presets {
7
+ Input: {
8
+ modelValue: string | undefined;
9
+ placeholder?: string;
10
+ };
11
+ InputNumber: {
12
+ modelValue: number | undefined;
13
+ placeholder?: string;
14
+ };
15
+ Date: {
16
+ modelValue: DatePickerProps<false>['modelValue'];
17
+ withTime?: DatePickerProps<false>['withTime'];
18
+ };
19
+ DateRange: {
20
+ modelValue: DatePickerProps<true>['modelValue'];
21
+ withTime?: DatePickerProps<true>['withTime'];
22
+ };
23
+ Select: Pick<SelectProps<EnumSelectItem[]>, 'modelValue' | 'items' | 'placeholder'>;
24
+ MultiSelect: Pick<SelectProps<EnumSelectItem[], 'value', true>, 'modelValue' | 'items' | 'placeholder'>;
25
+ Checkbox: {
26
+ modelValue: boolean | undefined;
27
+ };
28
+ Switch: {
29
+ modelValue: boolean | undefined;
30
+ };
31
+ }
32
+ type GetPresetProps<K extends Presets[keyof Presets]> = {
33
+ [P in keyof Omit<K, 'modelValue'>]: MaybeRef<K[P]>;
34
+ };
35
+ type PresetField<S extends FormSchema = FormSchema> = {
36
+ [P in keyof Presets]: {
37
+ name: KeysMatching<FormData<S>, Presets[P]['modelValue']>;
38
+ render?: P;
39
+ } & GetPresetProps<Presets[P]>;
40
+ }[keyof Presets];
41
+ interface BaseField<S extends FormSchema = FormSchema> {
42
+ name: keyof FormData<S> & string;
43
+ render?: (state: FormData<S>, field: FiltersField<S>) => VNode;
44
+ }
45
+ export type FiltersField<S extends FormSchema = FormSchema> = Omit<FormFieldProps, 'name'> & (BaseField<S> | PresetField<S>);
46
+ export type TableFiltersModel<S extends FormSchema> = FormData<S>;
47
+ export interface TableFiltersProps<S extends FormSchema, F extends FiltersField<S>[] = FiltersField<S>[]> extends Omit<FormProps<S>, 'transform' | 'onSubmit' | 'id' | 'state' | 'nested' | 'name'> {
48
+ source: FormData<S>;
49
+ fields?: F;
50
+ }
51
+ export type TableFiltersSlots<S extends FormSchema> = {
52
+ [K in Extract<keyof FormData<S>, string>]: (props: {
53
+ model: FormData<S>[K];
54
+ state: FormData<S>;
55
+ updateModel: (value: FormData<S>[K]) => any;
56
+ }) => any;
57
+ };
58
+ export interface TableFiltersEmits<S extends FormSchema> {
59
+ submit: [TableFiltersModel<S>];
60
+ reset: [TableFiltersModel<S>];
61
+ }
62
+ declare const _default: typeof __VLS_export;
63
+ export default _default;
64
+ declare const __VLS_export: <S extends FormSchema, F extends FiltersField<S>[] = FiltersField<S>[]>(__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<{
65
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<(TableFiltersProps<S, F> & {
66
+ modelValue?: TableFiltersModel<S>;
67
+ }) & {
68
+ onReset?: ((args_0: import("@nuxt/ui").InferOutput<S>) => any) | undefined;
69
+ onSubmit?: ((args_0: import("@nuxt/ui").InferOutput<S>) => any) | undefined;
70
+ "onUpdate:modelValue"?: ((value: import("@nuxt/ui").InferOutput<S> | undefined) => any) | undefined;
71
+ }> & (typeof globalThis extends {
72
+ __VLS_PROPS_FALLBACK: infer P;
73
+ } ? P : {});
74
+ expose: (exposed: import("vue").ShallowUnwrapRef<{
75
+ appliedFields: import("vue").ComputedRef<FiltersField<S>[]>;
76
+ clearField: (field: FiltersField<S>) => void;
77
+ reset: () => void;
78
+ submit: (data: TableFiltersModel<S>) => void;
79
+ }>) => void;
80
+ attrs: any;
81
+ slots: TableFiltersSlots<S>;
82
+ emit: (((evt: "reset", args_0: import("@nuxt/ui").InferOutput<S>) => void) & ((evt: "submit", args_0: import("@nuxt/ui").InferOutput<S>) => void)) & ((evt: "update:modelValue", value: import("@nuxt/ui").InferOutput<S> | undefined) => void);
83
+ }>) => import("vue").VNode & {
84
+ __ctx?: Awaited<typeof __VLS_setup>;
85
+ };
86
+ type __VLS_PrettifyLocal<T> = (T extends any ? {
87
+ [K in keyof T]: T[K];
88
+ } : {
89
+ [K in keyof T as K]: T[K];
90
+ }) & {};
@@ -0,0 +1,95 @@
1
+ import type { AsyncDataRequestStatus } from '#app';
2
+ import type { AppConfig } from '@nuxt/schema';
3
+ import type { DropdownMenuItem, FormSchema, PaginationEmits, PaginationProps, TableData, TableProps, TableRow, TableSlots } from '@nuxt/ui';
4
+ import type { ColumnPinningState, GroupingState, RowSelectionState } from '@tanstack/vue-table';
5
+ import type { ComponentConfig, OptionalKeys } from '../types';
6
+ import type { ModalConfirmProps } from './ModalConfirm.vue';
7
+ import type { TableColumnSortingModel } from './TableColumnSorting.vue';
8
+ import type { TableColumnVisibilityProps } from './TableColumnVisibility.vue';
9
+ import type { TableFiltersEmits, TableFiltersModel, TableFiltersProps, TableFiltersSlots } from './TableFilters.vue';
10
+ import theme from '#build/cms/table-panel';
11
+ type TablePanel = ComponentConfig<typeof theme, AppConfig, 'tablePanel'>;
12
+ export interface ActionMenuItem extends DropdownMenuItem {
13
+ confirm?: ModalConfirmProps;
14
+ delete?: OptionalKeys<ModalConfirmProps, 'message'>;
15
+ visibility?: () => boolean;
16
+ }
17
+ export interface TablePanelProps<Data extends TableData, Schema extends FormSchema> {
18
+ title?: string;
19
+ status?: AsyncDataRequestStatus;
20
+ page?: PaginationProps['page'];
21
+ itemsPerPage?: PaginationProps['itemsPerPage'];
22
+ total?: PaginationProps['total'];
23
+ storageKey?: TableColumnVisibilityProps['storageKey'];
24
+ /** @default true */
25
+ columnVisibility?: boolean;
26
+ defaultHiddenColumns?: string[];
27
+ sorting?: TableColumnSortingModel;
28
+ columns?: TableProps<Data>['columns'];
29
+ data?: TableProps<Data>['data'];
30
+ /** @default true */
31
+ sticky?: TableProps<Data>['sticky'];
32
+ columnPinning?: ColumnPinningState;
33
+ getRowId?: TableProps<Data>['getRowId'];
34
+ rowSelection?: RowSelectionState;
35
+ rowSelectionOptions?: TableProps<Data>['rowSelectionOptions'];
36
+ /** @default true */
37
+ resetRowSelection?: boolean;
38
+ grouping?: GroupingState;
39
+ /** @default { getGroupedRowModel: getGroupedRowModel(), groupedColumnMode: false } */
40
+ groupingOptions?: TableProps<Data>['groupingOptions'];
41
+ hideSelectedFilters?: true;
42
+ filters?: TableFiltersModel<Schema>;
43
+ filtersSchema?: Schema;
44
+ filtersSource?: TableFiltersProps<Schema>['source'];
45
+ filtersFields?: TableFiltersProps<Schema>['fields'];
46
+ empty?: TableProps<Data>['empty'];
47
+ actions?: ((row: TableRow<Data>) => ActionMenuItem[] | undefined);
48
+ onSelect?: TableProps<Data>['onSelect'];
49
+ class?: any;
50
+ ui?: TablePanel['slots'];
51
+ }
52
+ export interface TablePanelEmits<Schema extends FormSchema> {
53
+ 'update:page': PaginationEmits['update:page'];
54
+ 'update:items-per-page': [value: number];
55
+ 'update:sorting': [value: TableColumnSortingModel];
56
+ 'update:row-selection': [value?: RowSelectionState];
57
+ 'update:filters': [value: TableFiltersModel<Schema>];
58
+ 'update:grouping': [value?: GroupingState];
59
+ 'filtersReset': TableFiltersEmits<Schema>['reset'];
60
+ 'filtersSubmit': TableFiltersEmits<Schema>['submit'];
61
+ }
62
+ export type TablePanelSlots<Data extends TableData, Schema extends FormSchema> = TableSlots<Data> & {
63
+ 'toolbar-left'?: () => any;
64
+ 'navbar-right'?: () => any;
65
+ 'toolbar-right'?: () => any;
66
+ } & {
67
+ [P in keyof TableFiltersSlots<Schema> as `filter-${P}`]: TableFiltersSlots<Schema>[P];
68
+ };
69
+ declare const _default: typeof __VLS_export;
70
+ export default _default;
71
+ declare const __VLS_export: <Data extends TableData, Schema extends FormSchema>(__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<{
72
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<TablePanelProps<Data, Schema> & {
73
+ "onUpdate:page"?: ((value: number) => any) | undefined;
74
+ "onUpdate:items-per-page"?: ((value: number) => any) | undefined;
75
+ "onUpdate:sorting"?: ((value: import("@tanstack/table-core").SortingState) => any) | undefined;
76
+ "onUpdate:row-selection"?: ((value?: RowSelectionState | undefined) => any) | undefined;
77
+ "onUpdate:filters"?: ((value: import("@nuxt/ui").InferOutput<Schema>) => any) | undefined;
78
+ "onUpdate:grouping"?: ((value?: GroupingState | undefined) => any) | undefined;
79
+ onFiltersReset?: ((args_0: import("@nuxt/ui").InferOutput<Schema>) => any) | undefined;
80
+ onFiltersSubmit?: ((args_0: import("@nuxt/ui").InferOutput<Schema>) => any) | undefined;
81
+ }> & (typeof globalThis extends {
82
+ __VLS_PROPS_FALLBACK: infer P;
83
+ } ? P : {});
84
+ expose: (exposed: {}) => void;
85
+ attrs: any;
86
+ slots: TablePanelSlots<Data, Schema>;
87
+ emit: ((evt: "update:page", value: number) => void) & ((evt: "update:items-per-page", value: number) => void) & ((evt: "update:sorting", value: import("@tanstack/table-core").SortingState) => void) & ((evt: "update:row-selection", value?: RowSelectionState | undefined) => void) & ((evt: "update:filters", value: import("@nuxt/ui").InferOutput<Schema>) => void) & ((evt: "update:grouping", value?: GroupingState | undefined) => void) & ((evt: "filtersReset", args_0: import("@nuxt/ui").InferOutput<Schema>) => void) & ((evt: "filtersSubmit", args_0: import("@nuxt/ui").InferOutput<Schema>) => void);
88
+ }>) => import("vue").VNode & {
89
+ __ctx?: Awaited<typeof __VLS_setup>;
90
+ };
91
+ type __VLS_PrettifyLocal<T> = (T extends any ? {
92
+ [K in keyof T]: T[K];
93
+ } : {
94
+ [K in keyof T as K]: T[K];
95
+ }) & {};