@vc-shell/framework 1.0.188 → 1.0.190

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 (181) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/core/plugins/moment/humanize.ts +6 -7
  3. package/core/types/index.ts +12 -1
  4. package/dist/core/plugins/moment/humanize.d.ts.map +1 -1
  5. package/dist/core/types/index.d.ts +1 -1
  6. package/dist/core/types/index.d.ts.map +1 -1
  7. package/dist/framework.js +30782 -20187
  8. package/dist/index.css +1 -1
  9. package/dist/shared/components/error-interceptor/interceptor.d.ts.map +1 -1
  10. package/dist/shared/modules/dynamic/components/fields/Button.d.ts.map +1 -1
  11. package/dist/shared/modules/dynamic/components/fields/ContentField.d.ts.map +1 -1
  12. package/dist/shared/modules/dynamic/components/fields/DynamicProperty.d.ts.map +1 -1
  13. package/dist/shared/modules/dynamic/components/fields/EditorField.d.ts +4 -1
  14. package/dist/shared/modules/dynamic/components/fields/EditorField.d.ts.map +1 -1
  15. package/dist/shared/modules/dynamic/components/fields/GalleryField.d.ts.map +1 -1
  16. package/dist/shared/modules/dynamic/components/fields/ImageField.d.ts.map +1 -1
  17. package/dist/shared/modules/dynamic/components/fields/InputField.d.ts.map +1 -1
  18. package/dist/shared/modules/dynamic/components/fields/MultivalueField.d.ts.map +1 -1
  19. package/dist/shared/modules/dynamic/components/fields/SelectField.d.ts.map +1 -1
  20. package/dist/shared/modules/dynamic/components/fields/StatusField.d.ts.map +1 -1
  21. package/dist/shared/modules/dynamic/components/fields/TextareaField.d.ts.map +1 -1
  22. package/dist/shared/modules/dynamic/components/fields/VideoField.d.ts.map +1 -1
  23. package/dist/shared/modules/dynamic/components/fields/storybook/Button.stories.d.ts +417 -0
  24. package/dist/shared/modules/dynamic/components/fields/storybook/Button.stories.d.ts.map +1 -0
  25. package/dist/shared/modules/dynamic/components/fields/storybook/Card.stories.d.ts +357 -0
  26. package/dist/shared/modules/dynamic/components/fields/storybook/Card.stories.d.ts.map +1 -0
  27. package/dist/shared/modules/dynamic/components/fields/storybook/Checkbox.stories.d.ts +398 -0
  28. package/dist/shared/modules/dynamic/components/fields/storybook/Checkbox.stories.d.ts.map +1 -0
  29. package/dist/shared/modules/dynamic/components/fields/storybook/ContentField.stories.d.ts +392 -0
  30. package/dist/shared/modules/dynamic/components/fields/storybook/ContentField.stories.d.ts.map +1 -0
  31. package/dist/shared/modules/dynamic/components/fields/storybook/EditorField.stories.d.ts +407 -0
  32. package/dist/shared/modules/dynamic/components/fields/storybook/EditorField.stories.d.ts.map +1 -0
  33. package/dist/shared/modules/dynamic/components/fields/storybook/Fieldset.stories.d.ts +372 -0
  34. package/dist/shared/modules/dynamic/components/fields/storybook/Fieldset.stories.d.ts.map +1 -0
  35. package/dist/shared/modules/dynamic/components/fields/storybook/GalleryField.stories.d.ts +391 -0
  36. package/dist/shared/modules/dynamic/components/fields/storybook/GalleryField.stories.d.ts.map +1 -0
  37. package/dist/shared/modules/dynamic/components/fields/storybook/ImageField.stories.d.ts +372 -0
  38. package/dist/shared/modules/dynamic/components/fields/storybook/ImageField.stories.d.ts.map +1 -0
  39. package/dist/shared/modules/dynamic/components/fields/storybook/InputCurrency.stories.d.ts +439 -0
  40. package/dist/shared/modules/dynamic/components/fields/storybook/InputCurrency.stories.d.ts.map +1 -0
  41. package/dist/shared/modules/dynamic/components/fields/storybook/InputField.stories.d.ts +460 -0
  42. package/dist/shared/modules/dynamic/components/fields/storybook/InputField.stories.d.ts.map +1 -0
  43. package/dist/shared/modules/dynamic/components/fields/storybook/MultivalueField.stories.d.ts +459 -0
  44. package/dist/shared/modules/dynamic/components/fields/storybook/MultivalueField.stories.d.ts.map +1 -0
  45. package/dist/shared/modules/dynamic/components/fields/storybook/RatingField.stories.d.ts +359 -0
  46. package/dist/shared/modules/dynamic/components/fields/storybook/RatingField.stories.d.ts.map +1 -0
  47. package/dist/shared/modules/dynamic/components/fields/storybook/SelectField.stories.d.ts +507 -0
  48. package/dist/shared/modules/dynamic/components/fields/storybook/SelectField.stories.d.ts.map +1 -0
  49. package/dist/shared/modules/dynamic/components/fields/storybook/StatusField.stories.d.ts +392 -0
  50. package/dist/shared/modules/dynamic/components/fields/storybook/StatusField.stories.d.ts.map +1 -0
  51. package/dist/shared/modules/dynamic/components/fields/storybook/SwitchField.stories.d.ts +14 -0
  52. package/dist/shared/modules/dynamic/components/fields/storybook/SwitchField.stories.d.ts.map +1 -0
  53. package/dist/shared/modules/dynamic/components/fields/storybook/TextareaField.stories.d.ts +407 -0
  54. package/dist/shared/modules/dynamic/components/fields/storybook/TextareaField.stories.d.ts.map +1 -0
  55. package/dist/shared/modules/dynamic/components/fields/storybook/VideoField.stories.d.ts +322 -0
  56. package/dist/shared/modules/dynamic/components/fields/storybook/VideoField.stories.d.ts.map +1 -0
  57. package/dist/shared/modules/dynamic/components/fields/storybook/common/args.d.ts +113 -0
  58. package/dist/shared/modules/dynamic/components/fields/storybook/common/args.d.ts.map +1 -0
  59. package/dist/shared/modules/dynamic/components/fields/storybook/common/templates.d.ts +3 -0
  60. package/dist/shared/modules/dynamic/components/fields/storybook/common/templates.d.ts.map +1 -0
  61. package/dist/shared/modules/dynamic/components/fields/storybook/pages/DynamicRender.d.ts +235 -0
  62. package/dist/shared/modules/dynamic/components/fields/storybook/pages/DynamicRender.d.ts.map +1 -0
  63. package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceHighlighter.d.ts +4 -0
  64. package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceHighlighter.d.ts.map +1 -0
  65. package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceTransform.d.ts +3 -0
  66. package/dist/shared/modules/dynamic/components/fields/storybook/utils/sourceTransform.d.ts.map +1 -0
  67. package/dist/shared/modules/dynamic/factories/base/useDetailsFactory.d.ts.map +1 -1
  68. package/dist/shared/modules/dynamic/factories/types/index.d.ts +1 -0
  69. package/dist/shared/modules/dynamic/factories/types/index.d.ts.map +1 -1
  70. package/dist/shared/modules/dynamic/helpers/getters.d.ts.map +1 -1
  71. package/dist/shared/modules/dynamic/types/index.d.ts +88 -38
  72. package/dist/shared/modules/dynamic/types/index.d.ts.map +1 -1
  73. package/dist/shared/modules/dynamic/types/models.d.ts.map +1 -1
  74. package/dist/tsconfig.tsbuildinfo +1 -1
  75. package/dist/ui/components/atoms/vc-card/vc-card.stories.d.ts +16 -16
  76. package/dist/ui/components/atoms/vc-card/vc-card.vue.d.ts.map +1 -1
  77. package/dist/ui/components/atoms/vc-switch/index.d.ts +1 -39
  78. package/dist/ui/components/atoms/vc-switch/index.d.ts.map +1 -1
  79. package/dist/ui/components/atoms/vc-switch/vc-switch.stories.d.ts +30 -11
  80. package/dist/ui/components/atoms/vc-switch/vc-switch.stories.d.ts.map +1 -1
  81. package/dist/ui/components/atoms/vc-switch/vc-switch.vue.d.ts +22 -3
  82. package/dist/ui/components/atoms/vc-switch/vc-switch.vue.d.ts.map +1 -1
  83. package/dist/ui/components/atoms/vc-video/index.d.ts +1 -35
  84. package/dist/ui/components/atoms/vc-video/index.d.ts.map +1 -1
  85. package/dist/ui/components/atoms/vc-video/vc-video.stories.d.ts +5 -27
  86. package/dist/ui/components/atoms/vc-video/vc-video.stories.d.ts.map +1 -1
  87. package/dist/ui/components/atoms/vc-video/vc-video.vue.d.ts +3 -18
  88. package/dist/ui/components/atoms/vc-video/vc-video.vue.d.ts.map +1 -1
  89. package/dist/ui/components/molecules/vc-editor/vc-editor.stories.d.ts +16 -4
  90. package/dist/ui/components/molecules/vc-editor/vc-editor.stories.d.ts.map +1 -1
  91. package/dist/ui/components/molecules/vc-editor/vc-editor.vue.d.ts +2 -1
  92. package/dist/ui/components/molecules/vc-editor/vc-editor.vue.d.ts.map +1 -1
  93. package/dist/ui/components/molecules/vc-input/vc-input.stories.d.ts +30 -16
  94. package/dist/ui/components/molecules/vc-input/vc-input.stories.d.ts.map +1 -1
  95. package/dist/ui/components/molecules/vc-input-currency/vc-input-currency.stories.d.ts +12 -12
  96. package/dist/ui/components/molecules/vc-input-currency/vc-input-currency.vue.d.ts.map +1 -1
  97. package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.stories.d.ts +252 -42
  98. package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.stories.d.ts.map +1 -1
  99. package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.vue.d.ts +36 -6
  100. package/dist/ui/components/molecules/vc-multivalue/vc-multivalue.vue.d.ts.map +1 -1
  101. package/dist/ui/components/molecules/vc-select/vc-select.stories.d.ts +96 -32
  102. package/dist/ui/components/molecules/vc-select/vc-select.stories.d.ts.map +1 -1
  103. package/dist/ui/components/molecules/vc-select/vc-select.vue.d.ts +3 -3
  104. package/dist/ui/components/molecules/vc-select/vc-select.vue.d.ts.map +1 -1
  105. package/dist/ui/components/molecules/vc-textarea/vc-textarea.stories.d.ts +63 -63
  106. package/dist/ui/components/molecules/vc-textarea/vc-textarea.vue.d.ts +6 -6
  107. package/dist/ui/components/molecules/vc-textarea/vc-textarea.vue.d.ts.map +1 -1
  108. package/dist/ui/components/organisms/vc-table/_internal/vc-table-cell/vc-table-cell.vue.d.ts +1 -0
  109. package/dist/ui/components/organisms/vc-table/_internal/vc-table-cell/vc-table-cell.vue.d.ts.map +1 -1
  110. package/dist/ui/components/organisms/vc-table/_internal/vc-table-column-switcher/vc-table-column-switcher.vue.d.ts.map +1 -1
  111. package/dist/ui/components/organisms/vc-table/vc-table.stories.d.ts +8 -2
  112. package/dist/ui/components/organisms/vc-table/vc-table.stories.d.ts.map +1 -1
  113. package/dist/ui/components/organisms/vc-table/vc-table.vue.d.ts +3 -1
  114. package/dist/ui/components/organisms/vc-table/vc-table.vue.d.ts.map +1 -1
  115. package/package.json +8 -4
  116. package/shared/components/error-interceptor/interceptor.ts +1 -1
  117. package/shared/modules/dynamic/components/fields/Button.ts +5 -2
  118. package/shared/modules/dynamic/components/fields/Card.ts +4 -4
  119. package/shared/modules/dynamic/components/fields/ContentField.ts +1 -0
  120. package/shared/modules/dynamic/components/fields/DynamicProperty.ts +5 -6
  121. package/shared/modules/dynamic/components/fields/EditorField.ts +5 -3
  122. package/shared/modules/dynamic/components/fields/Fieldset.ts +1 -1
  123. package/shared/modules/dynamic/components/fields/GalleryField.ts +6 -3
  124. package/shared/modules/dynamic/components/fields/ImageField.ts +0 -1
  125. package/shared/modules/dynamic/components/fields/InputCurrency.ts +1 -1
  126. package/shared/modules/dynamic/components/fields/InputField.ts +1 -0
  127. package/shared/modules/dynamic/components/fields/MultivalueField.ts +3 -2
  128. package/shared/modules/dynamic/components/fields/SelectField.ts +1 -0
  129. package/shared/modules/dynamic/components/fields/StatusField.ts +20 -10
  130. package/shared/modules/dynamic/components/fields/TextareaField.ts +1 -0
  131. package/shared/modules/dynamic/components/fields/VideoField.ts +0 -1
  132. package/shared/modules/dynamic/components/fields/storybook/Button.stories.ts +247 -0
  133. package/shared/modules/dynamic/components/fields/storybook/Card.stories.ts +166 -0
  134. package/shared/modules/dynamic/components/fields/storybook/Checkbox.stories.ts +185 -0
  135. package/shared/modules/dynamic/components/fields/storybook/ContentField.stories.ts +245 -0
  136. package/shared/modules/dynamic/components/fields/storybook/EditorField.stories.ts +192 -0
  137. package/shared/modules/dynamic/components/fields/storybook/Fieldset.stories.ts +409 -0
  138. package/shared/modules/dynamic/components/fields/storybook/GalleryField.stories.ts +239 -0
  139. package/shared/modules/dynamic/components/fields/storybook/ImageField.stories.ts +186 -0
  140. package/shared/modules/dynamic/components/fields/storybook/InputCurrency.stories.ts +267 -0
  141. package/shared/modules/dynamic/components/fields/storybook/InputField.stories.ts +298 -0
  142. package/shared/modules/dynamic/components/fields/storybook/MultivalueField.stories.ts +347 -0
  143. package/shared/modules/dynamic/components/fields/storybook/RatingField.stories.ts +131 -0
  144. package/shared/modules/dynamic/components/fields/storybook/SelectField.stories.ts +653 -0
  145. package/shared/modules/dynamic/components/fields/storybook/StatusField.stories.ts +202 -0
  146. package/shared/modules/dynamic/components/fields/storybook/SwitchField.stories.ts +178 -0
  147. package/shared/modules/dynamic/components/fields/storybook/TextareaField.stories.ts +203 -0
  148. package/shared/modules/dynamic/components/fields/storybook/VideoField.stories.ts +92 -0
  149. package/shared/modules/dynamic/components/fields/storybook/common/args.ts +130 -0
  150. package/shared/modules/dynamic/components/fields/storybook/common/templates.ts +8 -0
  151. package/shared/modules/dynamic/components/fields/storybook/pages/DynamicRender.ts +54 -0
  152. package/shared/modules/dynamic/components/fields/storybook/utils/sourceHighlighter.ts +16 -0
  153. package/shared/modules/dynamic/components/fields/storybook/utils/sourceTransform.ts +41 -0
  154. package/shared/modules/dynamic/factories/base/useDetailsFactory.ts +1 -0
  155. package/shared/modules/dynamic/factories/types/index.ts +2 -0
  156. package/shared/modules/dynamic/helpers/getters.ts +3 -0
  157. package/shared/modules/dynamic/helpers/nodeBuilder.ts +1 -1
  158. package/shared/modules/dynamic/helpers/setters.ts +1 -1
  159. package/shared/modules/dynamic/types/index.ts +93 -40
  160. package/shared/modules/dynamic/types/models.ts +8 -7
  161. package/shared/pages/LoginPage/components/login/Login.vue +1 -1
  162. package/ui/components/atoms/vc-card/vc-card.vue +12 -2
  163. package/ui/components/atoms/vc-switch/index.ts +1 -3
  164. package/ui/components/atoms/vc-switch/vc-switch.vue +10 -3
  165. package/ui/components/atoms/vc-video/index.ts +1 -3
  166. package/ui/components/atoms/vc-video/vc-video.stories.ts +1 -15
  167. package/ui/components/atoms/vc-video/vc-video.vue +4 -37
  168. package/ui/components/molecules/vc-editor/vc-editor.vue +47 -33
  169. package/ui/components/molecules/vc-field/_internal/vc-field-type/vc-field-type.vue +2 -2
  170. package/ui/components/molecules/vc-input/vc-input.stories.ts +14 -0
  171. package/ui/components/molecules/vc-input-currency/vc-input-currency.vue +8 -0
  172. package/ui/components/molecules/vc-multivalue/vc-multivalue.vue +21 -9
  173. package/ui/components/molecules/vc-select/vc-select.stories.ts +74 -3
  174. package/ui/components/molecules/vc-select/vc-select.vue +35 -38
  175. package/ui/components/molecules/vc-textarea/vc-textarea.stories.ts +1 -1
  176. package/ui/components/molecules/vc-textarea/vc-textarea.vue +5 -15
  177. package/ui/components/organisms/vc-blade/_internal/vc-blade-header/vc-blade-header.vue +1 -1
  178. package/ui/components/organisms/vc-table/_internal/vc-table-cell/vc-table-cell.vue +140 -108
  179. package/ui/components/organisms/vc-table/_internal/vc-table-column-switcher/vc-table-column-switcher.vue +20 -6
  180. package/ui/components/organisms/vc-table/vc-table.stories.ts +6 -2
  181. package/ui/components/organisms/vc-table/vc-table.vue +176 -124
@@ -1,10 +1,13 @@
1
1
  <template>
2
- <div class="tw-relative tw-overflow-hidden tw-flex tw-flex-col tw-grow">
2
+ <div
3
+ v-loading="unref(loading) || columnsInit"
4
+ class="tw-relative tw-overflow-hidden tw-flex tw-flex-col tw-grow"
5
+ >
3
6
  <!-- Header slot with filter and searchbar -->
4
7
  <slot
5
8
  v-if="
6
9
  ($slots['header'] || header) &&
7
- ((items && items.length) || searchValue || searchValue === '' || activeFilterCount)
10
+ ((items && items.length && !columnsInit) || searchValue || searchValue === '' || activeFilterCount)
8
11
  "
9
12
  name="header"
10
13
  >
@@ -55,13 +58,10 @@
55
58
  </div>
56
59
  </slot>
57
60
 
58
- <div
59
- v-loading="unref(loading)"
60
- class="tw-flex tw-relative tw-overflow-hidden tw-grow"
61
- >
61
+ <div class="tw-flex tw-relative tw-overflow-hidden tw-grow">
62
62
  <!-- Table scroll container -->
63
63
  <VcContainer
64
- v-if="items && items.length"
64
+ v-if="items && items.length && !columnsInit"
65
65
  ref="scrollContainer"
66
66
  :no-padding="true"
67
67
  class="tw-grow tw-basis-0 tw-relative"
@@ -69,7 +69,7 @@
69
69
  @scroll:ptr="$emit('scroll:ptr')"
70
70
  >
71
71
  <!-- Mobile table view -->
72
- <template v-if="$isMobile.value && $slots['mobile-item']">
72
+ <template v-if="$isMobile.value">
73
73
  <div>
74
74
  <VcTableMobileItem
75
75
  v-for="(item, i) in items"
@@ -85,7 +85,9 @@
85
85
  <slot
86
86
  name="mobile-item"
87
87
  :item="item"
88
- ></slot>
88
+ >
89
+ <mobileTemplateRenderer :item="item as TableItem" />
90
+ </slot>
89
91
  </VcTableMobileItem>
90
92
  </div>
91
93
  </template>
@@ -107,7 +109,8 @@
107
109
  <tr class="vc-table__header-row">
108
110
  <th
109
111
  v-if="multiselect"
110
- class="tw-h-[42px] tw-w-[50px] tw-max-w-[28px] tw-min-w-[28px] tw-bg-[#f9f9f9] !tw-border-0 tw-shadow-[inset_0px_1px_0px_#eaedf3,_inset_0px_-1px_0px_#eaedf3] tw-box-border tw-sticky tw-top-0 tw-select-none tw-overflow-hidden tw-z-[1]"
112
+ width="28px"
113
+ class="tw-h-[42px] tw-w-[28px] tw-max-w-[28px] tw-min-w-[28px] tw-bg-[#f9f9f9] !tw-border-0 tw-shadow-[inset_0px_1px_0px_#eaedf3,_inset_0px_-1px_0px_#eaedf3] tw-box-border tw-sticky tw-top-0 tw-select-none tw-overflow-hidden tw-z-[1]"
111
114
  >
112
115
  <div class="tw-flex tw-justify-center tw-items-center">
113
116
  <VcCheckbox
@@ -121,6 +124,7 @@
121
124
  </th>
122
125
  <th
123
126
  v-if="enableItemActions && itemActionBuilder"
127
+ width="21px"
124
128
  class="tw-h-[42px] tw-w-[21px] tw-max-w-[21px] tw-min-w-[21px] tw-bg-[#f9f9f9] tw-m-w-[70px] !tw-border-0 tw-shadow-[inset_0px_1px_0px_#eaedf3,_inset_0px_-1px_0px_#eaedf3] tw-box-border tw-sticky tw-top-0 tw-select-none tw-z-[1]"
125
129
  >
126
130
  <div class="tw-w-3 tw-top-0 tw-bottom-0 tw-absolute tw-right-0 tw-flex tw-justify-end">
@@ -128,12 +132,13 @@
128
132
  </div>
129
133
  </th>
130
134
  <th
131
- v-for="item in filteredCols"
135
+ v-for="(item, index) in filteredCols"
132
136
  :id="item.id"
133
137
  :key="item.id"
134
138
  class="tw-h-[42px] tw-bg-[#f9f9f9] !tw-border-0 tw-shadow-[inset_0px_1px_0px_#eaedf3,_inset_0px_-1px_0px_#eaedf3] tw-box-border tw-sticky tw-top-0 tw-select-none tw-overflow-hidden tw-z-[1]"
135
139
  :class="{
136
140
  'tw-cursor-pointer tw-group': item.sortable,
141
+ 'tw-p-r-[35px]': index === filteredCols.length - 1,
137
142
  }"
138
143
  :style="{ maxWidth: item.width, width: item.width }"
139
144
  @mousedown="onColumnHeaderMouseDown"
@@ -174,6 +179,7 @@
174
179
  </div>
175
180
  </div>
176
181
  <div
182
+ v-if="index !== filteredCols.length - 1"
177
183
  class="tw-w-3 tw-top-0 tw-bottom-0 tw-absolute tw-right-0 tw-flex tw-justify-end"
178
184
  :class="{
179
185
  'tw-cursor-col-resize': props.resizableColumns,
@@ -183,16 +189,12 @@
183
189
  <div class="tw-w-px tw-bg-[#e5e7eb] tw-h-full"></div>
184
190
  </div>
185
191
  </th>
186
-
187
- <th
188
- class="tw-w-auto tw-h-[42px] tw-bg-[#f9f9f9] !tw-border-0 tw-shadow-[inset_0px_1px_0px_#eaedf3,_inset_0px_-1px_0px_#eaedf3] tw-box-border tw-sticky tw-top-0 tw-select-none tw-overflow-hidden tw-z-[1]"
189
- ></th>
190
192
  <div
191
193
  v-if="props.expanded"
192
194
  class="tw-sticky tw-h-[42px] tw-z-[1] tw-right-0 tw-top-0 tw-table-cell tw-align-middle tw-w-0"
193
195
  >
194
196
  <VcTableColumnSwitcher
195
- :items="toggleCols.filter((col): col is ITableColumns => col !== undefined)"
197
+ :items="internalColumnsSorted"
196
198
  @change="toggleColumn"
197
199
  ></VcTableColumnSwitcher>
198
200
  </div>
@@ -255,7 +257,8 @@
255
257
  >
256
258
  <td
257
259
  v-if="multiselect && typeof item === 'object'"
258
- class="tw-w-[50px] tw-max-w-[28px] tw-min-w-[28px] tw-relative"
260
+ class="tw-w-[28px] tw-max-w-[28px] tw-min-w-[28px] tw-relative"
261
+ width="28px"
259
262
  @click.stop
260
263
  >
261
264
  <div class="tw-flex tw-justify-center tw-items-center">
@@ -269,6 +272,7 @@
269
272
  <td
270
273
  v-if="enableItemActions && itemActionBuilder && typeof item === 'object'"
271
274
  class="tw-box-border tw-overflow-visible tw-w-[21px] tw-max-w-[21px] tw-min-w-[21px] tw-relative"
275
+ width="21px"
272
276
  @click.stop
273
277
  >
274
278
  <div
@@ -329,9 +333,15 @@
329
333
  </td>
330
334
  <td
331
335
  v-for="cell in filteredCols"
336
+ :id="`${(typeof item === 'object' && 'id' in item && item.id) || itemIndex}_${cell.id}`"
332
337
  :key="`${(typeof item === 'object' && 'id' in item && item.id) || itemIndex}_${cell.id}`"
333
338
  class="tw-box-border tw-overflow-hidden tw-px-3"
334
- :class="cell.class"
339
+ :class="[
340
+ cell.class,
341
+ {
342
+ 'last:tw-w-full': cell.id === filteredCols[filteredCols.length - 1].id,
343
+ },
344
+ ]"
335
345
  :style="{ maxWidth: cell.width, width: cell.width }"
336
346
  >
337
347
  <slot
@@ -343,10 +353,14 @@
343
353
  v-if="typeof item === 'object'"
344
354
  :cell="cell"
345
355
  :item="item"
356
+ :width="
357
+ calculateElWidth(
358
+ `${(typeof item === 'object' && 'id' in item && item.id) || itemIndex}_${cell.id}`,
359
+ )
360
+ "
346
361
  ></VcTableCell>
347
362
  </slot>
348
363
  </td>
349
- <td></td>
350
364
  </tr>
351
365
  </tbody>
352
366
  </table>
@@ -358,19 +372,16 @@
358
372
  v-if="searchValue || searchValue === '' || activeFilterCount"
359
373
  name="notfound"
360
374
  >
361
- <div
362
- v-if="notfound"
363
- class="tw-w-full tw-h-full tw-box-border tw-flex tw-flex-col tw-items-center tw-justify-center"
364
- >
375
+ <div class="tw-w-full tw-h-full tw-box-border tw-flex tw-flex-col tw-items-center tw-justify-center">
365
376
  <img
366
- v-if="notfound.image"
377
+ v-if="notfound?.image"
367
378
  :src="notfound.image"
368
379
  />
369
380
  <div class="tw-m-4 vc-table__empty-text">
370
- {{ notfound.text || t("COMPONENTS.ORGANISMS.VC_TABLE.NOT_FOUND") }}
381
+ {{ notfound?.text || t("COMPONENTS.ORGANISMS.VC_TABLE.NOT_FOUND") }}
371
382
  </div>
372
383
  <VcButton
373
- v-if="notfound.action"
384
+ v-if="notfound?.action"
374
385
  @click="notfound.clickHandler"
375
386
  >
376
387
  {{ notfound.action }}
@@ -381,19 +392,16 @@
381
392
  v-else
382
393
  name="empty"
383
394
  >
384
- <div
385
- v-if="empty"
386
- class="tw-w-full tw-h-full tw-box-border tw-flex tw-flex-col tw-items-center tw-justify-center"
387
- >
395
+ <div class="tw-w-full tw-h-full tw-box-border tw-flex tw-flex-col tw-items-center tw-justify-center">
388
396
  <img
389
- v-if="empty.image"
397
+ v-if="empty?.image"
390
398
  :src="empty.image"
391
399
  />
392
400
  <div class="tw-m-4 tw-text-xl tw-font-medium">
393
- {{ empty.text || t("COMPONENTS.ORGANISMS.VC_TABLE.EMPTY") }}
401
+ {{ empty?.text || t("COMPONENTS.ORGANISMS.VC_TABLE.EMPTY") }}
394
402
  </div>
395
403
  <VcButton
396
- v-if="empty.action"
404
+ v-if="empty?.action"
397
405
  @click="empty.clickHandler"
398
406
  >
399
407
  {{ empty.action }}
@@ -405,7 +413,7 @@
405
413
 
406
414
  <!-- Table footer -->
407
415
  <slot
408
- v-if="($slots['footer'] || footer) && items && items.length"
416
+ v-if="($slots['footer'] || footer) && items && items.length && !columnsInit"
409
417
  name="footer"
410
418
  >
411
419
  <div
@@ -430,30 +438,33 @@
430
438
  </template>
431
439
  <!-- eslint-disable @typescript-eslint/no-explicit-any -->
432
440
  <script lang="ts" setup generic="T extends TableItem | string">
441
+ import { ComputePositionReturn, ReferenceElement, arrow, computePosition, flip, offset } from "@floating-ui/vue";
442
+ import { reactiveComputed, useCurrentElement, useLocalStorage } from "@vueuse/core";
433
443
  import {
434
- unref,
444
+ ComponentPublicInstance,
445
+ MaybeRef,
446
+ Ref,
435
447
  computed,
448
+ h,
449
+ nextTick,
450
+ onBeforeUnmount,
451
+ onBeforeUpdate,
436
452
  ref,
453
+ toValue,
454
+ unref,
437
455
  watch,
438
- onBeforeUpdate,
439
- onBeforeUnmount,
440
- Ref,
441
- onUpdated,
442
- onBeforeMount,
443
- nextTick,
444
- MaybeRef,
445
- ComponentPublicInstance,
446
456
  } from "vue";
457
+ import { useI18n } from "vue-i18n";
458
+ import { VcButton, VcCheckbox, VcContainer, VcIcon, VcInput, VcPagination, VcHint } from "./../../";
459
+ import { IActionBuilderResult, ITableColumns } from "./../../../../core/types";
460
+ import VcTableCell from "./_internal/vc-table-cell/vc-table-cell.vue";
461
+ import VcTableColumnSwitcher from "./_internal/vc-table-column-switcher/vc-table-column-switcher.vue";
447
462
  import VcTableCounter from "./_internal/vc-table-counter/vc-table-counter.vue";
448
463
  import VcTableFilter from "./_internal/vc-table-filter/vc-table-filter.vue";
449
464
  import VcTableMobileItem from "./_internal/vc-table-mobile-item/vc-table-mobile-item.vue";
450
- import VcTableCell from "./_internal/vc-table-cell/vc-table-cell.vue";
451
- import VcTableColumnSwitcher from "./_internal/vc-table-column-switcher/vc-table-column-switcher.vue";
452
- import { offset, flip, arrow, computePosition, ComputePositionReturn, ReferenceElement } from "@floating-ui/vue";
453
- import { IActionBuilderResult, ITableColumns } from "./../../../../core/types";
454
- import { useLocalStorage, useCurrentElement } from "@vueuse/core";
455
- import { VcContainer, VcInput, VcCheckbox, VcIcon, VcPagination, VcButton } from "./../../";
456
- import { useI18n } from "vue-i18n";
465
+ import * as _ from "lodash-es";
466
+ import "core-js/actual/array/to-spliced";
467
+ import "core-js/actual/array/to-sorted";
457
468
 
458
469
  export interface StatusImage {
459
470
  image?: string;
@@ -565,11 +576,15 @@ const nextColumn = ref<ITableColumns>();
565
576
  const lastResize = ref<number>();
566
577
  const table = useCurrentElement();
567
578
  const resizer = ref();
568
- const state = useLocalStorage<ITableColumns[]>("VC_TABLE_STATE_" + props.stateKey.toUpperCase(), []);
569
- const defaultColumns: Ref<ITableColumns[]> = ref([]);
579
+ const state = useLocalStorage<Partial<ITableColumns & { predefined: boolean }>[]>(
580
+ "VC_TABLE_STATE_" + props.stateKey.toUpperCase(),
581
+ [],
582
+ );
583
+ const internalColumns: Ref<ITableColumns[]> = ref([]);
570
584
  const draggedColumn = ref();
571
585
  const draggedElement = ref<HTMLElement>();
572
586
  const dropPosition = ref();
587
+ const columnsInit = ref(true);
573
588
 
574
589
  // row reordering variables
575
590
  const draggedRow = ref<T>();
@@ -577,12 +592,6 @@ const rowDragged = ref(false);
577
592
  const droppedRowIndex = ref<number>();
578
593
  const draggedRowIndex = ref<number>();
579
594
 
580
- onBeforeMount(() => {
581
- if (isStateful()) {
582
- restoreState();
583
- }
584
- });
585
-
586
595
  onBeforeUnmount(() => {
587
596
  unbindColumnResizeEvents();
588
597
  });
@@ -592,12 +601,6 @@ onBeforeUpdate(() => {
592
601
  tooltipRefs.value = [];
593
602
  });
594
603
 
595
- onUpdated(() => {
596
- if (isStateful()) {
597
- saveState();
598
- }
599
- });
600
-
601
604
  const sortDirection = computed(() => {
602
605
  const entry = props.sort?.split(":");
603
606
  return entry && entry.length === 2 && entry[1];
@@ -608,10 +611,65 @@ const sortField = computed(() => {
608
611
  return entry && entry.length === 2 && entry[0];
609
612
  });
610
613
 
611
- const toggleCols = computed(() => {
612
- return props.columns.map((item) => {
613
- return defaultColumns.value.find((mutatedItem) => item.id === mutatedItem.id);
614
- });
614
+ const calculateElWidth = (id: string) => {
615
+ const el = document.getElementById(id);
616
+ return el ? el.offsetWidth : 0;
617
+ };
618
+
619
+ const allColumns = ref([]) as Ref<ITableColumns[]>;
620
+
621
+ const mobileTemplateRenderer = ({ item }: { item: TableItem }) => {
622
+ return reactiveComputed(() =>
623
+ h(
624
+ "div",
625
+ { class: "tw-border-b tw-border-solid tw-border-b-[#e3e7ec] tw-p-3 tw-gap-2 tw-flex tw-flex-wrap" },
626
+ props.columns.map((x) => {
627
+ return h("div", { class: "tw-grow tw-w-[33%] tw-ml-3 tw-truncate" }, [
628
+ h(VcHint, { class: "tw-mb-1 tw-truncate" }, toValue(x.title)),
629
+ h(VcTableCell, { cell: { ...x, class: "!tw-justify-start" }, item, class: "" }),
630
+ ]);
631
+ }),
632
+ ),
633
+ );
634
+ };
635
+
636
+ watch(
637
+ () => props.items,
638
+ (newVal) => {
639
+ if (newVal && newVal.length) {
640
+ const cols = Object.keys(newVal[0]).map((key) => {
641
+ return {
642
+ id: key,
643
+ // From camelCase to human readable with first letter capitalized
644
+ title: key.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase()),
645
+ visible: false,
646
+ predefined: false,
647
+ };
648
+ });
649
+
650
+ const predefined = props.columns.map((item) => ({
651
+ ...item,
652
+ predefined: true,
653
+ visible: typeof item.visible !== "undefined" ? item.visible : true,
654
+ }));
655
+ allColumns.value = _.unionBy(predefined, cols, "id");
656
+
657
+ restoreState();
658
+ }
659
+ columnsInit.value = false;
660
+ },
661
+ { deep: true },
662
+ );
663
+
664
+ const internalColumnsSorted = computed(() => {
665
+ // alphabetical order
666
+ return internalColumns.value /* @ts-expect-error - toSorted is not parsed correctly by ts */
667
+ .toSorted((a, b) => {
668
+ if (a && b && a.title && b.title) {
669
+ return toValue(a.title).localeCompare(toValue(b.title));
670
+ }
671
+ return 0;
672
+ });
615
673
  });
616
674
 
617
675
  const tableAlignment = {
@@ -640,7 +698,7 @@ const headerCheckbox = computed({
640
698
  });
641
699
 
642
700
  const filteredCols = computed(() => {
643
- return defaultColumns.value.filter((x) => {
701
+ return internalColumns.value.filter((x) => {
644
702
  if (x.visible === false) {
645
703
  return false;
646
704
  }
@@ -673,19 +731,6 @@ watch(
673
731
  { deep: true },
674
732
  );
675
733
 
676
- watch(
677
- () => props.columns,
678
- (newVal) => {
679
- restoreState();
680
-
681
- if (newVal.length !== state.value.length) {
682
- defaultColumns.value = newVal.map((col) => ({ ...col, visible: col.visible ?? true }));
683
- saveState();
684
- }
685
- },
686
- { deep: true, immediate: true },
687
- );
688
-
689
734
  watch(
690
735
  () => allSelected.value,
691
736
  (newVal) => {
@@ -825,7 +870,7 @@ function handleMouseDown(e: MouseEvent, item: ITableColumns) {
825
870
  const containerLeft = getOffset(table.value as HTMLElement).left;
826
871
  resizeColumnElement.value = item;
827
872
  columnResizing.value = true;
828
- lastResize.value = e.pageX - containerLeft + table.value.scrollLeft;
873
+ lastResize.value = e.pageX - containerLeft + (table.value as HTMLDivElement).scrollLeft;
829
874
 
830
875
  bindColumnResizeEvents();
831
876
  }
@@ -861,11 +906,15 @@ function unbindColumnResizeEvents() {
861
906
  }
862
907
 
863
908
  function onColumnResize(event: MouseEvent) {
864
- const containerLeft = getOffset(table.value as HTMLElement).left;
909
+ if (columnResizing.value) {
910
+ const containerLeft = getOffset(table.value as HTMLElement).left;
865
911
 
866
- resizer.value.style.top = 0 + "px";
867
- resizer.value.style.left = event.pageX - containerLeft + table.value.scrollLeft + "px";
868
- resizer.value.style.display = "block";
912
+ resizer.value.style.top = 0 + "px";
913
+ const leftOffset = event.pageX - containerLeft + (table.value as HTMLDivElement).scrollLeft;
914
+ resizer.value.style.left =
915
+ Math.min(leftOffset, (table.value as HTMLDivElement).offsetWidth - resizer.value.offsetWidth - 70) + "px";
916
+ resizer.value.style.display = "block";
917
+ }
869
918
  }
870
919
 
871
920
  function getOffset(element: HTMLElement) {
@@ -884,7 +933,9 @@ function getOffset(element: HTMLElement) {
884
933
  function onColumnResizeEnd() {
885
934
  const delta = resizer.value.offsetLeft - (lastResize.value ?? 0);
886
935
 
887
- const columnElement: HTMLElement | null = table.value.querySelector(`#${resizeColumnElement.value?.id}`);
936
+ const columnElement: HTMLElement | null = (table.value as HTMLDivElement).querySelector(
937
+ `#${resizeColumnElement.value?.id}`,
938
+ );
888
939
 
889
940
  if (columnElement) {
890
941
  const columnWidth = columnElement.offsetWidth;
@@ -896,7 +947,7 @@ function onColumnResizeEnd() {
896
947
  nextColumn.value = filteredCols.value[filteredCols.value.indexOf(resizeColumnElement.value) + 1];
897
948
 
898
949
  if (nextColumn.value) {
899
- const nextColElement = table.value.querySelector(`#${nextColumn.value.id}`);
950
+ const nextColElement = (table.value as HTMLDivElement).querySelector(`#${nextColumn.value.id}`);
900
951
 
901
952
  const nextColumnWidth = (nextColElement as HTMLElement).offsetWidth - delta;
902
953
  if (newColumnWidth > 15 && nextColumnWidth > 15) {
@@ -980,8 +1031,6 @@ function onColumnHeaderDragOver(event: DragEvent) {
980
1031
  }
981
1032
  }
982
1033
  }
983
- // TODO column width fix
984
- // TODO tootip on date date ago full time on hover
985
1034
  function onColumnHeaderDragLeave(event: DragEvent) {
986
1035
  if (props.reorderableColumns && draggedColumn.value) {
987
1036
  event.preventDefault();
@@ -996,8 +1045,8 @@ function onColumnHeaderDrop(event: DragEvent, item: ITableColumns) {
996
1045
  event.preventDefault();
997
1046
 
998
1047
  if (draggedColumn.value) {
999
- const dragIndex = defaultColumns.value.indexOf(draggedColumn.value);
1000
- const dropIndex = defaultColumns.value.indexOf(item);
1048
+ const dragIndex = internalColumns.value.indexOf(draggedColumn.value);
1049
+ const dropIndex = internalColumns.value.indexOf(item);
1001
1050
 
1002
1051
  let allowDrop = dragIndex !== dropIndex;
1003
1052
 
@@ -1010,11 +1059,9 @@ function onColumnHeaderDrop(event: DragEvent, item: ITableColumns) {
1010
1059
  }
1011
1060
 
1012
1061
  if (allowDrop) {
1013
- reorderArray(defaultColumns.value, dragIndex, dropIndex);
1062
+ reorderArray(internalColumns.value, dragIndex, dropIndex);
1014
1063
 
1015
- if (isStateful()) {
1016
- saveState();
1017
- }
1064
+ saveState();
1018
1065
  }
1019
1066
 
1020
1067
  if (reorderRef.value) {
@@ -1028,34 +1075,35 @@ function onColumnHeaderDrop(event: DragEvent, item: ITableColumns) {
1028
1075
  }
1029
1076
  }
1030
1077
 
1031
- function isStateful() {
1032
- return props.stateKey != null;
1033
- }
1034
-
1035
1078
  function saveState() {
1036
- console.debug("[@vc-shell/framewok#vc-table.vue] - Save state");
1079
+ console.debug("[@vc-shell/framework#vc-table.vue] - Save state");
1037
1080
 
1038
- state.value = defaultColumns.value;
1081
+ state.value = internalColumns.value.map((col) => _.pick(col, "id", "visible", "width", "predefined"));
1039
1082
  }
1040
1083
 
1041
1084
  function restoreState() {
1042
- console.debug("[@vc-shell/framewok#vc-table.vue] - Restore state");
1043
- if (Object.keys(state.value).length) {
1044
- defaultColumns.value = state.value.map((item) => {
1045
- const column = props.columns.find((x) => x.id === item.id);
1046
- if (column) {
1047
- return {
1048
- ...item,
1049
- title: column.title,
1050
- // visible: column.visible,
1051
- sortable: column.sortable,
1052
- alwaysVisible: column.alwaysVisible,
1053
- width: column.width,
1054
- type: column.type,
1055
- };
1085
+ console.debug("[@vc-shell/framework#vc-table.vue] - Restore state");
1086
+
1087
+ if (state.value && state.value.length) {
1088
+ // Iterate over the state value and update corresponding columns in allColumns
1089
+ for (const item of state.value) {
1090
+ const matchingColumn = allColumns.value.find((col) => col.id === item.id);
1091
+ if (matchingColumn) {
1092
+ matchingColumn.width = item.width || matchingColumn.width;
1093
+ matchingColumn.visible = item.visible;
1094
+ // Remove the matched column from internalColumns
1095
+ internalColumns.value = internalColumns.value.filter((col) => col.id !== matchingColumn.id);
1056
1096
  }
1057
- return item;
1058
- });
1097
+ if (item.predefined && !props.columns.some((col) => col.id === item.id)) {
1098
+ _.remove(state.value, item);
1099
+ }
1100
+ }
1101
+ // Merge the updated columns with the remaining state columns
1102
+ internalColumns.value = _.values(
1103
+ _.merge(_.keyBy(props.columns, "id"), _.keyBy(allColumns.value, "id"), _.keyBy(state.value, "id")),
1104
+ );
1105
+ } else {
1106
+ internalColumns.value = allColumns.value;
1059
1107
  }
1060
1108
  }
1061
1109
 
@@ -1077,18 +1125,22 @@ function onColumnHeaderMouseDown(event: MouseEvent) {
1077
1125
  }
1078
1126
 
1079
1127
  function toggleColumn(item: ITableColumns) {
1128
+ // if item is not in internalColumns, add it
1129
+ if (!internalColumns.value.find((x) => x.id === item.id)) {
1130
+ internalColumns.value.push(item);
1131
+ } else {
1132
+ // internalColumns.value = internalColumns.value.filter((x) => x.id !== item.id);
1133
+ }
1080
1134
  if (item) {
1081
- defaultColumns.value = defaultColumns.value.map((x) => {
1082
- if (x === item) {
1135
+ internalColumns.value = internalColumns.value.map((x) => {
1136
+ if (x.id === item.id) {
1083
1137
  x = item;
1084
1138
  }
1085
1139
  return x;
1086
1140
  });
1087
1141
  }
1088
1142
 
1089
- if (isStateful()) {
1090
- saveState();
1091
- }
1143
+ saveState();
1092
1144
  }
1093
1145
 
1094
1146
  function onRowMouseDown(event: MouseEvent) {