@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
@@ -1,59 +1,80 @@
1
1
  <template>
2
- <USelectMenu
3
- v-model:search-term="searchTerm"
4
- v-model:open="isOpen"
5
- :model-value="modelValue"
6
- :items="items"
7
- :loading="isLoading"
8
- ignore-filter
9
- :value-key="valueKey"
10
- :label-key="labelKey"
11
- :placeholder="placeholder"
12
- :content="{ 'data-autocomplete-select-content': autocompleteSelectId }"
13
- :multiple="multiple"
14
- :class="ui.root({ class: [props.ui?.root, props.class] })"
15
- @update:model-value="emit('update:modelValue', $event)"
16
- >
17
- <template v-if="modelValue && !props.multiple">
18
- <span class="truncate pointer-events-none">
19
- {{ getCachedLabel(modelValue) }}
20
- </span>
21
- </template>
2
+ <ClientOnly>
3
+ <USelectMenu
4
+ v-model:search-term="searchTerm"
5
+ v-model:open="isOpen"
6
+ :model-value="modelValue"
7
+ :items="items"
8
+ ignore-filter
9
+ :value-key="valueKey"
10
+ :label-key="labelKey"
11
+ :placeholder="placeholder"
12
+ :multiple="multiple"
13
+ :ui="{ viewport: viewportId }"
14
+ @update:model-value="$emit('update:modelValue', $event)"
15
+ >
16
+ <template v-if="props.multiple ? modelValue?.length : modelValue">
17
+ <span class="truncate pointer-events-none">
18
+ {{ cachedLabel }}
19
+ </span>
20
+ </template>
21
+
22
+ <template v-if="slots['item-label']" #item-label="{ item }">
23
+ <slot name="item-label" :item="item" />
24
+ </template>
22
25
 
23
- <template v-if="!multiple" #trailing>
24
- <ButtonClear
25
- :model-value="modelValue"
26
- :reset-value="resetValue"
27
- @update:model-value="$emit('update:modelValue', $event)"
28
- />
26
+ <template #trailing>
27
+ <UIcon v-if="isLoading" :name="appConfig.ui.icons.loading" class="shrink-0 text-dimmed size-5 animate-spin" />
28
+ <template v-else>
29
+ <UButton
30
+ v-if="props.multiple ? modelValue?.length : modelValue"
31
+ :icon="appConfig.ui.icons.close"
32
+ variant="link"
33
+ size="sm"
34
+ color="neutral"
35
+ class="px-0"
36
+ @click="$emit('update:modelValue', void 0)"
37
+ />
38
+ </template>
39
+ </template>
40
+ </USelectMenu>
41
+
42
+ <template #placeholder>
43
+ <USkeleton class="w-full h-8" />
29
44
  </template>
30
- </USelectMenu>
45
+ </ClientOnly>
31
46
  </template>
32
47
 
33
48
  <script>
34
- import theme from "#build/cms/autocomplete-select";
35
- import { computed, ref, refDebounced, shallowRef, toRaw, triggerRef, useAppConfig, useAsyncData, useId, useInfiniteScroll, useNuxtData, useOffsetPagination, watch } from "#imports";
36
- import { tv } from "../tv";
37
- import ButtonClear from "./ButtonClear.vue";
49
+ import { useAppConfig, useAsyncData, useNuxtData } from "#imports";
50
+ import { refDebounced, useInfiniteScroll, useOffsetPagination } from "@vueuse/core";
51
+ import { computed, ref, shallowRef, toRaw, triggerRef, useId, watch } from "vue";
38
52
  </script>
39
53
 
40
54
  <script setup>
41
55
  const props = defineProps({
42
- modelValue: { type: null, required: true },
56
+ modelValue: { type: null, required: false },
43
57
  cacheKey: { type: String, required: true },
44
58
  handler: { type: Function, required: true },
45
- valueKey: { type: null, required: false },
46
- labelKey: { type: null, required: false },
47
- multiple: { type: null, required: false },
59
+ valueKey: { type: null, required: false, default: "id" },
60
+ labelKey: { type: null, required: false, default: "name" },
61
+ multiple: { type: Boolean, required: false },
48
62
  placeholder: { type: String, required: false },
49
- resetValue: { type: [String, Number, Boolean, null], required: false, skipCheck: true },
50
- class: { type: null, required: false },
51
- ui: { type: null, required: false }
63
+ initSelected: { type: Boolean, required: false }
52
64
  });
53
- const emit = defineEmits(["update:modelValue"]);
65
+ defineEmits(["update:modelValue"]);
66
+ const slots = defineSlots();
54
67
  const appConfig = useAppConfig();
55
- const autocompleteSelectId = `autocomplete-select-${useId()}`;
56
- const { initialPagination, initialData, initialStatus } = useInitialData();
68
+ const autocompleteSelectKey = `autocomplete-select:${props.cacheKey}`;
69
+ const autocompleteSelectId = `${autocompleteSelectKey}:${useId()}`;
70
+ const viewportId = `autocomplete-select-viewport-${useId()}`;
71
+ const {
72
+ initialPagination,
73
+ initialData,
74
+ initialStatus,
75
+ initSelected,
76
+ initSelectedStatus
77
+ } = useInitialData();
57
78
  const { fetchPage, nextPage, isLastPage, pageDataStatus, allPagesData } = usePageData({
58
79
  pagination: initialPagination,
59
80
  total: () => initialData.value?.pagination.total ?? 0
@@ -63,7 +84,8 @@ const { isOpen } = useInfiniteScrollData({ nextPage, isLastPage, fetchPage, sear
63
84
  const isLoading = computed(() => [
64
85
  initialStatus.value,
65
86
  pageDataStatus.value,
66
- searchStatus.value
87
+ searchStatus.value,
88
+ initSelectedStatus.value
67
89
  ].includes("pending"));
68
90
  const items = computed(() => {
69
91
  if (searchTerm.value) {
@@ -74,22 +96,40 @@ const items = computed(() => {
74
96
  ...allPagesData.value
75
97
  ];
76
98
  });
77
- const { getCachedLabel } = useAutocompleteCache({ items });
99
+ const { cachedLabel } = useAutocompleteCache({ items, initSelected });
78
100
  function useInitialData() {
79
101
  const initialPagination2 = { page: "1", perPage: "25" };
80
102
  const { data: initialData2, status: initialStatus2 } = useAsyncData(
81
- `autocomplete-select:${props.cacheKey}`,
103
+ autocompleteSelectKey,
82
104
  () => props.handler({ ...initialPagination2, search: "" }),
83
105
  {
84
106
  lazy: true,
85
- getCachedData: (key) => useNuxtData(key).data.value ?? void 0,
107
+ getCachedData: (key) => useNuxtData(key).data.value,
86
108
  dedupe: "defer"
87
109
  }
88
110
  );
111
+ const { data: initSelected2, status: initSelectedStatus2 } = useAsyncData(
112
+ `${autocompleteSelectId}:initial-value`,
113
+ async () => {
114
+ const result = await props.handler({
115
+ ...initialPagination2,
116
+ search: "",
117
+ ids: Array.isArray(props.modelValue) ? props.modelValue : [props.modelValue]
118
+ });
119
+ return result.items;
120
+ },
121
+ {
122
+ lazy: true,
123
+ immediate: props.initSelected && (Array.isArray(props.modelValue) ? props.modelValue.length > 0 : !!props.modelValue),
124
+ default: () => []
125
+ }
126
+ );
89
127
  return {
90
128
  initialPagination: initialPagination2,
91
129
  initialData: initialData2,
92
- initialStatus: initialStatus2
130
+ initialStatus: initialStatus2,
131
+ initSelected: initSelected2,
132
+ initSelectedStatus: initSelectedStatus2
93
133
  };
94
134
  }
95
135
  function usePageData(options) {
@@ -98,13 +138,17 @@ function usePageData(options) {
98
138
  pageSize: Number(options.pagination.perPage),
99
139
  page: Number(options.pagination.page)
100
140
  });
101
- const { execute: fetchPage2, data: pageData, status: pageDataStatus2 } = useAsyncData(() => {
102
- return props.handler({
103
- page: String(currentPage.value),
104
- perPage: String(currentPageSize.value),
105
- search: ""
106
- });
107
- }, { immediate: false });
141
+ const { execute: fetchPage2, data: pageData, status: pageDataStatus2 } = useAsyncData(
142
+ `${autocompleteSelectId}:page-data`,
143
+ () => {
144
+ return props.handler({
145
+ page: currentPage.value.toString(),
146
+ perPage: currentPageSize.value.toString(),
147
+ search: ""
148
+ });
149
+ },
150
+ { immediate: false }
151
+ );
108
152
  const allPagesData2 = shallowRef([]);
109
153
  watch(pageData, (value) => {
110
154
  if (value?.items) {
@@ -116,12 +160,10 @@ function usePageData(options) {
116
160
  }
117
161
  function useInfiniteScrollData(options) {
118
162
  const isOpen2 = ref(false);
119
- const contentDiv = ref(null);
163
+ const contentDiv = shallowRef(null);
120
164
  watch(isOpen2, (value) => {
121
165
  if (value) {
122
- contentDiv.value = document.querySelector(`
123
- [data-autocomplete-select-content="${autocompleteSelectId}"] [data-reka-combobox-viewport]
124
- `) ?? null;
166
+ contentDiv.value = document.querySelector(`.${viewportId}`) ?? null;
125
167
  }
126
168
  }, { flush: "post" });
127
169
  useInfiniteScroll(contentDiv, () => {
@@ -131,16 +173,14 @@ function useInfiniteScrollData(options) {
131
173
  return { isOpen: isOpen2 };
132
174
  }
133
175
  function useSearch(options) {
176
+ const searchKey = `${autocompleteSelectId}:search`;
134
177
  const searchTerm2 = ref("");
135
178
  const searchTermDebounced = refDebounced(searchTerm2, 500);
136
- let controller;
137
- const { data: searchData2, status: searchStatus2, execute: search } = useAsyncData(() => {
138
- controller?.abort();
139
- controller = new AbortController();
179
+ const { data: searchData2, status: searchStatus2, execute: search } = useAsyncData(searchKey, (_, { signal }) => {
140
180
  return props.handler({
141
181
  ...options.pagination,
142
182
  search: searchTermDebounced.value
143
- }, controller.signal);
183
+ }, signal);
144
184
  }, { lazy: true, immediate: false });
145
185
  watch(searchTermDebounced, (value) => {
146
186
  value && search();
@@ -149,23 +189,37 @@ function useSearch(options) {
149
189
  }
150
190
  function useAutocompleteCache(options) {
151
191
  const selectedItemCache = shallowRef(/* @__PURE__ */ new Map());
152
- watch(() => [props.modelValue, options.items.value], ([value]) => {
153
- const cacheSize = selectedItemCache.value.size;
154
- (Array.isArray(value) ? value : [value]).forEach((code) => {
155
- if (!code || selectedItemCache.value.has(code)) {
156
- return;
157
- }
158
- const item = options.items.value.find((item2) => item2[props.valueKey] === code);
159
- if (item) {
160
- selectedItemCache.value.set(code, structuredClone(toRaw(item)));
192
+ const updateCache = (value) => {
193
+ if (!value || selectedItemCache.value.has(value)) {
194
+ return;
195
+ }
196
+ const item = options.initSelected.value.find((item2) => item2[props.valueKey] === value) || options.items.value.find((item2) => item2[props.valueKey] === value);
197
+ if (item) {
198
+ selectedItemCache.value.set(value, structuredClone(toRaw(item)));
199
+ }
200
+ };
201
+ watch(
202
+ () => [props.modelValue, options.items.value, options.initSelected.value],
203
+ ([value]) => {
204
+ const cacheSize = selectedItemCache.value.size;
205
+ if (Array.isArray(value)) {
206
+ value.forEach(updateCache);
207
+ } else {
208
+ updateCache(value);
161
209
  }
162
- });
163
- cacheSize !== selectedItemCache.value.size && triggerRef(selectedItemCache);
164
- }, { immediate: true });
165
- const getCachedLabel2 = (value) => {
210
+ cacheSize !== selectedItemCache.value.size && triggerRef(selectedItemCache);
211
+ },
212
+ { immediate: true }
213
+ );
214
+ const getCachedLabel = (value) => {
215
+ if (Array.isArray(value)) {
216
+ return value.map(getCachedLabel).join(", ");
217
+ }
166
218
  return selectedItemCache.value.get(value)?.[props.labelKey] ?? value;
167
219
  };
168
- return { selectedItemCache, getCachedLabel: getCachedLabel2 };
220
+ const cachedLabel2 = computed(() => {
221
+ return props.modelValue && getCachedLabel(props.modelValue);
222
+ });
223
+ return { selectedItemCache, getCachedLabel, cachedLabel: cachedLabel2 };
169
224
  }
170
- const ui = computed(() => tv({ extend: tv(theme), ...appConfig.cms?.autocompleteSelect || {} })());
171
225
  </script>
@@ -1,42 +1,56 @@
1
- import type { AppConfig } from '@nuxt/schema';
2
- import type { ComponentConfig, Pagination, PaginationQueryRaw } from '../types';
3
- import type { ResetValue } from './ButtonClear.vue';
4
- import theme from '#build/cms/autocomplete-select';
5
- type AutocompleteSelect = ComponentConfig<typeof theme, AppConfig, 'autocompleteSelect'>;
1
+ import type { InputMenuItem } from '@nuxt/ui';
2
+ import type { Pagination, PaginationQueryRaw } from '../types';
6
3
  type PaginationQuery = Required<PaginationQueryRaw>;
7
- type HandlerQuery = PaginationQuery & {
4
+ export type AutocompleteSelectItem = Extract<InputMenuItem, object> & {
5
+ id?: string | number;
6
+ name?: string;
7
+ };
8
+ type GetModelValue<T extends AutocompleteSelectItem, VK extends keyof T, M extends boolean> = M extends true ? (T[VK][] | undefined) : (T[VK] | undefined);
9
+ export type HandlerParams = PaginationQuery & {
8
10
  search: string;
11
+ ids?: string[] | number[];
9
12
  };
10
- export interface AutocompleteSelectProps<T extends object, M extends boolean = true> {
11
- modelValue: M extends true ? (string | number)[] : (string | number | null | undefined);
13
+ export type Handler<T extends AutocompleteSelectItem = AutocompleteSelectItem> = (params: HandlerParams, signal?: AbortSignal) => Promise<{
14
+ items: T[];
15
+ pagination: Pagination;
16
+ }>;
17
+ export interface Props<T extends AutocompleteSelectItem = AutocompleteSelectItem, VK extends keyof T = 'id', M extends boolean = false> {
18
+ modelValue?: GetModelValue<T, VK, M>;
12
19
  cacheKey: string;
13
- handler: (query: HandlerQuery, signal?: AbortSignal) => Promise<{
14
- items: T[];
15
- pagination: Pagination;
16
- }>;
17
- valueKey?: keyof T;
20
+ handler: Handler<T>;
21
+ /** @defaultValue 'id' */
22
+ valueKey?: VK;
23
+ /** @defaultValue 'name' */
18
24
  labelKey?: keyof T;
19
- multiple?: M;
25
+ multiple?: M & boolean;
20
26
  placeholder?: string;
21
- resetValue?: ResetValue;
22
- class?: any;
23
- ui?: AutocompleteSelect['slots'];
27
+ initSelected?: boolean;
28
+ }
29
+ export interface Emits<T extends AutocompleteSelectItem = AutocompleteSelectItem, VK extends keyof T = 'id', M extends boolean = false> {
30
+ 'update:modelValue': [payload: GetModelValue<T, VK, M>];
24
31
  }
25
- export interface AutocompleteSelectEmits {
26
- 'update:modelValue': [string[]];
32
+ export interface Slots<T extends AutocompleteSelectItem = AutocompleteSelectItem> {
33
+ 'item-label': (props: {
34
+ item: T;
35
+ }) => any;
27
36
  }
28
- declare const _default: <T extends object, M extends boolean = true>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
29
- props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
30
- readonly "onUpdate:modelValue"?: ((args_0: string[]) => any) | undefined;
31
- } & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, never>, "onUpdate:modelValue"> & AutocompleteSelectProps<T, M> & Partial<{}>> & import("vue").PublicProps;
32
- expose(exposed: import("vue").ShallowUnwrapRef<{}>): void;
37
+ declare const _default: typeof __VLS_export;
38
+ export default _default;
39
+ declare const __VLS_export: <T extends AutocompleteSelectItem, VK extends keyof T = "id", M 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<{
40
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<Props<T, VK, M> & {
41
+ "onUpdate:modelValue"?: ((payload: GetModelValue<T, VK, M>) => any) | undefined;
42
+ }> & (typeof globalThis extends {
43
+ __VLS_PROPS_FALLBACK: infer P;
44
+ } ? P : {});
45
+ expose: (exposed: {}) => void;
33
46
  attrs: any;
34
- slots: {};
35
- emit: (evt: "update:modelValue", args_0: string[]) => void;
47
+ slots: Slots<T>;
48
+ emit: (evt: "update:modelValue", payload: GetModelValue<T, VK, M>) => void;
36
49
  }>) => import("vue").VNode & {
37
50
  __ctx?: Awaited<typeof __VLS_setup>;
38
51
  };
39
- export default _default;
40
- type __VLS_PrettifyLocal<T> = {
52
+ type __VLS_PrettifyLocal<T> = (T extends any ? {
41
53
  [K in keyof T]: T[K];
42
- } & {};
54
+ } : {
55
+ [K in keyof T as K]: T[K];
56
+ }) & {};
@@ -3,7 +3,7 @@ import type { ButtonProps, ModalProps } from '@nuxt/ui';
3
3
  import type { ComponentProps } from 'vue-component-type-helpers';
4
4
  import type { ComponentConfig } from '../types';
5
5
  import type { ModalConfirmEmits, ModalConfirmProps } from './ModalConfirm.vue';
6
- import theme from '#build/cms/button-delete';
6
+ import theme from '#build/cms/button-delete-confirm';
7
7
  import ModalConfirm from './ModalConfirm.vue';
8
8
  type ButtonDelete = ComponentConfig<typeof theme, AppConfig, 'buttonDelete'>;
9
9
  export interface ButtonDeleteProps extends Pick<ModalConfirmProps, 'onConfirm'> {
@@ -22,7 +22,9 @@ export interface ButtonDeleteProps extends Pick<ModalConfirmProps, 'onConfirm'>
22
22
  }
23
23
  export interface ButtonDeleteEmits extends ModalConfirmEmits {
24
24
  }
25
- declare const _default: import("vue").DefineComponent<ButtonDeleteProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
25
+ declare const _default: typeof __VLS_export;
26
+ export default _default;
27
+ declare const __VLS_export: import("vue").DefineComponent<ButtonDeleteProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
26
28
  close: () => any;
27
29
  confirm: () => any;
28
30
  }, string, import("vue").PublicProps, Readonly<ButtonDeleteProps> & Readonly<{
@@ -32,4 +34,3 @@ declare const _default: import("vue").DefineComponent<ButtonDeleteProps, {}, {},
32
34
  color: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral";
33
35
  confirmLabel: string;
34
36
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
35
- export default _default;
@@ -19,7 +19,7 @@
19
19
  </template>
20
20
 
21
21
  <script>
22
- import theme from "#build/cms/button-delete";
22
+ import theme from "#build/cms/button-delete-confirm";
23
23
  import { computed, useAppConfig, useOverlay } from "#imports";
24
24
  import { tv } from "../tv";
25
25
  import ModalConfirm from "./ModalConfirm.vue";
@@ -0,0 +1,36 @@
1
+ import type { AppConfig } from '@nuxt/schema';
2
+ import type { ButtonProps, ModalProps } from '@nuxt/ui';
3
+ import type { ComponentProps } from 'vue-component-type-helpers';
4
+ import type { ComponentConfig } from '../types';
5
+ import type { ModalConfirmEmits, ModalConfirmProps } from './ModalConfirm.vue';
6
+ import theme from '#build/cms/button-delete-confirm';
7
+ import ModalConfirm from './ModalConfirm.vue';
8
+ type ButtonDelete = ComponentConfig<typeof theme, AppConfig, 'buttonDelete'>;
9
+ export interface ButtonDeleteProps extends Pick<ModalConfirmProps, 'onConfirm'> {
10
+ modalProps?: Omit<ModalProps & ComponentProps<typeof ModalConfirm>, 'title' | 'message' | 'onConfirm' | 'confirmButton'>;
11
+ confirmText?: string;
12
+ confirmLabel?: string;
13
+ title?: string;
14
+ message?: string;
15
+ tooltipText?: string;
16
+ color?: ButtonProps['color'];
17
+ variant?: ButtonProps['variant'];
18
+ icon?: ButtonProps['icon'];
19
+ size?: ButtonProps['size'];
20
+ class?: any;
21
+ ui?: ButtonDelete['slots'];
22
+ }
23
+ export interface ButtonDeleteEmits extends ModalConfirmEmits {
24
+ }
25
+ declare const _default: typeof __VLS_export;
26
+ export default _default;
27
+ declare const __VLS_export: import("vue").DefineComponent<ButtonDeleteProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
28
+ close: () => any;
29
+ confirm: () => any;
30
+ }, string, import("vue").PublicProps, Readonly<ButtonDeleteProps> & Readonly<{
31
+ onClose?: (() => any) | undefined;
32
+ onConfirm?: (() => any) | undefined;
33
+ }>, {
34
+ color: "primary" | "secondary" | "success" | "info" | "warning" | "error" | "neutral";
35
+ confirmLabel: string;
36
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
@@ -0,0 +1,43 @@
1
+ import type { DateValue } from '@internationalized/date';
2
+ import type { CalendarProps } from '@nuxt/ui';
3
+ import type { DateRange as CalendarDateRange } from 'reka-ui';
4
+ import type { DateRange, DateType } from '../types';
5
+ export type CalendarValue = DateValue | CalendarDateRange;
6
+ export type ModelValue<R extends boolean> = (R extends true ? DateRange : DateType) | undefined;
7
+ export interface Props<R extends boolean> extends Omit<CalendarProps<R, false>, 'modelValue' | 'multiple' | 'minValue' | 'maxValue'> {
8
+ modelValue: ModelValue<R>;
9
+ id?: string;
10
+ name?: string;
11
+ withTime?: boolean;
12
+ minValue?: DateType;
13
+ maxValue?: DateType;
14
+ }
15
+ export interface Emits<R extends boolean> {
16
+ 'update:modelValue': [value: ModelValue<R>];
17
+ 'change': [event: Event];
18
+ 'blur': [event: FocusEvent];
19
+ 'focus': [event: FocusEvent];
20
+ }
21
+ declare const _default: typeof __VLS_export;
22
+ export default _default;
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
+ props: import("vue").PublicProps & __VLS_PrettifyLocal<Props<R> & {
25
+ onBlur?: ((event: FocusEvent) => any) | undefined;
26
+ onChange?: ((event: Event) => any) | undefined;
27
+ onFocus?: ((event: FocusEvent) => any) | undefined;
28
+ "onUpdate:modelValue"?: ((value: ModelValue<R>) => any) | undefined;
29
+ }> & (typeof globalThis extends {
30
+ __VLS_PROPS_FALLBACK: infer P;
31
+ } ? P : {});
32
+ expose: (exposed: {}) => void;
33
+ attrs: any;
34
+ slots: {};
35
+ emit: ((evt: "blur", event: FocusEvent) => void) & ((evt: "change", event: Event) => void) & ((evt: "focus", event: FocusEvent) => void) & ((evt: "update:modelValue", value: ModelValue<R>) => void);
36
+ }>) => import("vue").VNode & {
37
+ __ctx?: Awaited<typeof __VLS_setup>;
38
+ };
39
+ type __VLS_PrettifyLocal<T> = (T extends any ? {
40
+ [K in keyof T]: T[K];
41
+ } : {
42
+ [K in keyof T as K]: T[K];
43
+ }) & {};