@vc-shell/framework 1.0.38 → 1.0.40

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 (256) hide show
  1. package/core/api/index.ts +1 -0
  2. package/core/api/platform.ts +8332 -0
  3. package/core/composables/index.ts +8 -0
  4. package/core/composables/useAutosave/index.ts +57 -0
  5. package/core/composables/useFunctions/debounce.ts +18 -0
  6. package/core/composables/useFunctions/delay.ts +7 -0
  7. package/core/composables/useFunctions/index.ts +21 -0
  8. package/core/composables/useFunctions/once.ts +14 -0
  9. package/core/composables/useFunctions/sleep.ts +4 -0
  10. package/core/composables/useFunctions/throttle.ts +17 -0
  11. package/core/composables/useI18n/index.ts +28 -0
  12. package/core/composables/useLogger/index.ts +24 -0
  13. package/core/composables/useNotifications/index.ts +116 -0
  14. package/core/composables/usePermissions/index.ts +32 -0
  15. package/core/composables/useSettings/index.ts +62 -0
  16. package/core/composables/useUser/index.ts +266 -0
  17. package/core/directives/autofocus/index.ts +9 -0
  18. package/core/directives/click-outside/index.ts +21 -0
  19. package/core/directives/index.ts +4 -0
  20. package/core/directives/loading/index.ts +28 -0
  21. package/core/directives/permissions/index.ts +20 -0
  22. package/core/plugins/index.ts +1 -0
  23. package/core/plugins/validation/index.ts +2 -0
  24. package/core/plugins/validation/rules.ts +196 -0
  25. package/core/types/index.ts +92 -0
  26. package/core/utilities/camelToSnake.ts +7 -0
  27. package/core/utilities/index.ts +1 -0
  28. package/dist/core/composables/useNotifications/index.d.ts +1 -1
  29. package/dist/core/composables/useNotifications/index.d.ts.map +1 -1
  30. package/dist/core/composables/useSettings/index.d.ts +10 -1
  31. package/dist/core/composables/useSettings/index.d.ts.map +1 -1
  32. package/dist/core/composables/useUser/index.d.ts +2 -2
  33. package/dist/core/composables/useUser/index.d.ts.map +1 -1
  34. package/dist/core/plugins/validation/index.d.ts.map +1 -1
  35. package/dist/core/types/index.d.ts +1 -1
  36. package/dist/core/types/index.d.ts.map +1 -1
  37. package/dist/framework.js +72 -99
  38. package/dist/framework.js.map +1 -1
  39. package/dist/index.d.ts +3 -1
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/shared/app-switcher/composables/useAppSwitcher/index.d.ts +1 -1
  42. package/dist/shared/app-switcher/composables/useAppSwitcher/index.d.ts.map +1 -1
  43. package/dist/shared/app-switcher/index.d.ts +2 -2
  44. package/dist/shared/app-switcher/index.d.ts.map +1 -1
  45. package/dist/shared/blade-navigation/composables/useBladeNavigation/index.d.ts +1 -1
  46. package/dist/shared/blade-navigation/composables/useBladeNavigation/index.d.ts.map +1 -1
  47. package/dist/shared/blade-navigation/types/index.d.ts +1 -1
  48. package/dist/shared/blade-navigation/types/index.d.ts.map +1 -1
  49. package/dist/style.css +1 -1
  50. package/dist/tsconfig.tsbuildinfo +1 -0
  51. package/dist/ui/components/atoms/vc-badge/index.d.ts +5 -0
  52. package/dist/ui/components/atoms/vc-badge/index.d.ts.map +1 -0
  53. package/dist/ui/components/atoms/vc-badge/vc-badge-model.d.ts +28 -0
  54. package/dist/ui/components/atoms/vc-badge/vc-badge-model.d.ts.map +1 -0
  55. package/dist/{components → ui/components}/atoms/vc-badge/vc-badge.stories.d.ts +0 -0
  56. package/dist/ui/components/atoms/vc-badge/vc-badge.stories.d.ts.map +1 -0
  57. package/dist/ui/components/atoms/vc-button/index.d.ts +5 -0
  58. package/dist/ui/components/atoms/vc-button/index.d.ts.map +1 -0
  59. package/dist/ui/components/atoms/vc-button/vc-button-model.d.ts +28 -0
  60. package/dist/ui/components/atoms/vc-button/vc-button-model.d.ts.map +1 -0
  61. package/dist/{components → ui/components}/atoms/vc-button/vc-button.stories.d.ts +0 -0
  62. package/dist/ui/components/atoms/vc-button/vc-button.stories.d.ts.map +1 -0
  63. package/dist/{components → ui/components}/atoms/vc-checkbox/vc-checkbox.stories.d.ts +0 -0
  64. package/dist/ui/components/atoms/vc-checkbox/vc-checkbox.stories.d.ts.map +1 -0
  65. package/dist/{components → ui/components}/atoms/vc-container/vc-container.stories.d.ts +0 -0
  66. package/dist/ui/components/atoms/vc-container/vc-container.stories.d.ts.map +1 -0
  67. package/dist/{components → ui/components}/atoms/vc-hint/vc-hint.stories.d.ts +0 -0
  68. package/dist/ui/components/atoms/vc-hint/vc-hint.stories.d.ts.map +1 -0
  69. package/dist/{components → ui/components}/atoms/vc-icon/vc-icon.stories.d.ts +0 -0
  70. package/dist/ui/components/atoms/vc-icon/vc-icon.stories.d.ts.map +1 -0
  71. package/dist/{components → ui/components}/atoms/vc-image/vc-image.stories.d.ts +0 -0
  72. package/dist/ui/components/atoms/vc-image/vc-image.stories.d.ts.map +1 -0
  73. package/dist/{components → ui/components}/atoms/vc-label/vc-label.stories.d.ts +0 -0
  74. package/dist/ui/components/atoms/vc-label/vc-label.stories.d.ts.map +1 -0
  75. package/dist/{components → ui/components}/atoms/vc-link/vc-link.stories.d.ts +0 -0
  76. package/dist/ui/components/atoms/vc-link/vc-link.stories.d.ts.map +1 -0
  77. package/dist/{components → ui/components}/atoms/vc-progress/vc-progress.stories.d.ts +0 -0
  78. package/dist/ui/components/atoms/vc-progress/vc-progress.stories.d.ts.map +1 -0
  79. package/dist/{components → ui/components}/atoms/vc-status/vc-status.stories.d.ts +0 -0
  80. package/dist/ui/components/atoms/vc-status/vc-status.stories.d.ts.map +1 -0
  81. package/dist/{components → ui/components}/atoms/vc-switch/vc-switch.stories.d.ts +0 -0
  82. package/dist/ui/components/atoms/vc-switch/vc-switch.stories.d.ts.map +1 -0
  83. package/dist/{components → ui/components}/index.d.ts +4 -3
  84. package/dist/ui/components/index.d.ts.map +1 -0
  85. package/dist/{components → ui/components}/molecules/vc-breadcrumbs/vc-breadcrumbs.stories.d.ts +0 -0
  86. package/dist/ui/components/molecules/vc-breadcrumbs/vc-breadcrumbs.stories.d.ts.map +1 -0
  87. package/dist/{components → ui/components}/molecules/vc-form/vc-form.stories.d.ts +0 -0
  88. package/dist/ui/components/molecules/vc-form/vc-form.stories.d.ts.map +1 -0
  89. package/dist/ui/components/molecules/vc-input/index.d.ts +5 -0
  90. package/dist/ui/components/molecules/vc-input/index.d.ts.map +1 -0
  91. package/dist/ui/components/molecules/vc-input/vc-input-model.d.ts +140 -0
  92. package/dist/ui/components/molecules/vc-input/vc-input-model.d.ts.map +1 -0
  93. package/dist/ui/components/molecules/vc-input-currency/index.d.ts +5 -0
  94. package/dist/ui/components/molecules/vc-input-currency/index.d.ts.map +1 -0
  95. package/dist/ui/components/molecules/vc-input-currency/vc-input-currency-model.d.ts +124 -0
  96. package/dist/ui/components/molecules/vc-input-currency/vc-input-currency-model.d.ts.map +1 -0
  97. package/dist/{components → ui/components}/molecules/vc-pagination/vc-pagination.stories.d.ts +0 -0
  98. package/dist/ui/components/molecules/vc-pagination/vc-pagination.stories.d.ts.map +1 -0
  99. package/dist/{components → ui/components}/molecules/vc-rating/vc-rating.stories.d.ts +0 -0
  100. package/dist/ui/components/molecules/vc-rating/vc-rating.stories.d.ts.map +1 -0
  101. package/dist/ui/components/molecules/vc-select/index.d.ts +5 -0
  102. package/dist/ui/components/molecules/vc-select/index.d.ts.map +1 -0
  103. package/dist/ui/components/molecules/vc-select/vc-select-model.d.ts +207 -0
  104. package/dist/ui/components/molecules/vc-select/vc-select-model.d.ts.map +1 -0
  105. package/dist/{components → ui/components}/molecules/vc-textarea/vc-textarea.stories.d.ts +0 -0
  106. package/dist/ui/components/molecules/vc-textarea/vc-textarea.stories.d.ts.map +1 -0
  107. package/dist/{components → ui/components}/organisms/vc-app/vc-app.stories.d.ts +0 -0
  108. package/dist/ui/components/organisms/vc-app/vc-app.stories.d.ts.map +1 -0
  109. package/dist/{components → ui/components}/organisms/vc-blade/vc-blade.stories.d.ts +0 -0
  110. package/dist/ui/components/organisms/vc-blade/vc-blade.stories.d.ts.map +1 -0
  111. package/dist/{components → ui/components}/organisms/vc-login-form/vc-login-form.stories.d.ts +0 -0
  112. package/dist/ui/components/organisms/vc-login-form/vc-login-form.stories.d.ts.map +1 -0
  113. package/dist/{components → ui/components}/organisms/vc-popup/vc-popup.stories.d.ts +0 -0
  114. package/dist/ui/components/organisms/vc-popup/vc-popup.stories.d.ts.map +1 -0
  115. package/dist/{components → ui/components}/organisms/vc-table/vc-table.stories.d.ts +0 -0
  116. package/dist/ui/components/organisms/vc-table/vc-table.stories.d.ts.map +1 -0
  117. package/dist/ui/types/index.d.ts +13 -0
  118. package/dist/ui/types/index.d.ts.map +1 -0
  119. package/dist/ui/types/ts-helpers.d.ts +13 -0
  120. package/dist/ui/types/ts-helpers.d.ts.map +1 -0
  121. package/dist/vite.config.d.ts.map +1 -1
  122. package/package.json +30 -10
  123. package/shared/app-switcher/components/index.ts +1 -0
  124. package/shared/app-switcher/components/vc-app-switcher/vc-app-switcher.vue +90 -0
  125. package/shared/app-switcher/composables/index.ts +1 -0
  126. package/shared/app-switcher/composables/useAppSwitcher/index.ts +54 -0
  127. package/shared/app-switcher/index.ts +14 -0
  128. package/shared/assets/components/assets-details/assets-details.vue +138 -0
  129. package/shared/assets/components/index.ts +1 -0
  130. package/shared/assets/index.ts +19 -0
  131. package/shared/assets/locales/en.json +29 -0
  132. package/shared/assets/locales/index.ts +2 -0
  133. package/shared/blade-navigation/components/index.ts +1 -0
  134. package/shared/blade-navigation/components/vc-blade-navigation/vc-blade-navigation.vue +84 -0
  135. package/shared/blade-navigation/composables/index.ts +1 -0
  136. package/shared/blade-navigation/composables/useBladeNavigation/index.ts +216 -0
  137. package/shared/blade-navigation/index.ts +15 -0
  138. package/shared/blade-navigation/types/index.ts +52 -0
  139. package/shared/index.ts +16 -0
  140. package/tailwind.config.js +4 -3
  141. package/ui/components/atoms/vc-badge/index.ts +7 -0
  142. package/ui/components/atoms/vc-badge/vc-badge-model.ts +30 -0
  143. package/ui/components/atoms/vc-badge/vc-badge.stories.ts +27 -0
  144. package/ui/components/atoms/vc-badge/vc-badge.vue +57 -0
  145. package/ui/components/atoms/vc-button/index.ts +7 -0
  146. package/ui/components/atoms/vc-button/vc-button-model.ts +30 -0
  147. package/ui/components/atoms/vc-button/vc-button.stories.ts +34 -0
  148. package/ui/components/atoms/vc-button/vc-button.vue +219 -0
  149. package/ui/components/atoms/vc-card/vc-card.vue +137 -0
  150. package/ui/components/atoms/vc-checkbox/vc-checkbox.stories.ts +25 -0
  151. package/ui/components/atoms/vc-checkbox/vc-checkbox.vue +130 -0
  152. package/ui/components/atoms/vc-col/vc-col.vue +22 -0
  153. package/ui/components/atoms/vc-container/vc-container.stories.ts +31 -0
  154. package/ui/components/atoms/vc-container/vc-container.vue +222 -0
  155. package/ui/components/atoms/vc-hint/vc-hint.stories.ts +23 -0
  156. package/ui/components/atoms/vc-hint/vc-hint.vue +11 -0
  157. package/ui/components/atoms/vc-icon/vc-icon.stories.ts +32 -0
  158. package/ui/components/atoms/vc-icon/vc-icon.vue +36 -0
  159. package/ui/components/atoms/vc-image/vc-image.stories.ts +40 -0
  160. package/ui/components/atoms/vc-image/vc-image.vue +122 -0
  161. package/ui/components/atoms/vc-info-row/vc-info-row.vue +42 -0
  162. package/ui/components/atoms/vc-label/vc-label.stories.ts +23 -0
  163. package/ui/components/atoms/vc-label/vc-label.vue +49 -0
  164. package/ui/components/atoms/vc-link/vc-link.stories.ts +30 -0
  165. package/ui/components/atoms/vc-link/vc-link.vue +46 -0
  166. package/ui/components/atoms/vc-loading/vc-loading.vue +33 -0
  167. package/ui/components/atoms/vc-progress/vc-progress.stories.ts +25 -0
  168. package/ui/components/atoms/vc-progress/vc-progress.vue +65 -0
  169. package/ui/components/atoms/vc-row/vc-row.vue +13 -0
  170. package/ui/components/atoms/vc-status/vc-status.stories.ts +26 -0
  171. package/ui/components/atoms/vc-status/vc-status.vue +78 -0
  172. package/ui/components/atoms/vc-status-icon/vc-status-icon.vue +21 -0
  173. package/ui/components/atoms/vc-switch/vc-switch.stories.ts +27 -0
  174. package/ui/components/atoms/vc-switch/vc-switch.vue +100 -0
  175. package/ui/components/atoms/vc-widget/vc-widget.vue +85 -0
  176. package/ui/components/index.ts +44 -0
  177. package/ui/components/molecules/vc-breadcrumbs/_internal/vc-breadcrumbs-item/vc-breadcrumbs-item.vue +103 -0
  178. package/ui/components/molecules/vc-breadcrumbs/vc-breadcrumbs.stories.ts +39 -0
  179. package/ui/components/molecules/vc-breadcrumbs/vc-breadcrumbs.vue +21 -0
  180. package/ui/components/molecules/vc-currency-input/vc-input.vue +436 -0
  181. package/ui/components/molecules/vc-editor/vc-editor.vue +117 -0
  182. package/ui/components/molecules/vc-file-upload/vc-file-upload.vue +134 -0
  183. package/ui/components/molecules/vc-form/vc-form.stories.ts +23 -0
  184. package/ui/components/molecules/vc-form/vc-form.vue +5 -0
  185. package/ui/components/molecules/vc-input/index.ts +8 -0
  186. package/ui/components/molecules/vc-input/vc-input-model.ts +150 -0
  187. package/ui/components/molecules/vc-input/vc-input.vue +324 -0
  188. package/ui/components/molecules/vc-input-currency/index.ts +8 -0
  189. package/ui/components/molecules/vc-input-currency/vc-input-currency-model.ts +128 -0
  190. package/ui/components/molecules/vc-input-currency/vc-input-currency.vue +86 -0
  191. package/ui/components/molecules/vc-multivalue/vc-multivalue.vue +447 -0
  192. package/ui/components/molecules/vc-notification/vc-notification.vue +101 -0
  193. package/ui/components/molecules/vc-pagination/vc-pagination.stories.ts +23 -0
  194. package/ui/components/molecules/vc-pagination/vc-pagination.vue +169 -0
  195. package/ui/components/molecules/vc-rating/vc-rating.stories.ts +23 -0
  196. package/ui/components/molecules/vc-rating/vc-rating.vue +77 -0
  197. package/ui/components/molecules/vc-select/index.ts +7 -0
  198. package/ui/components/molecules/vc-select/vc-select-model.ts +216 -0
  199. package/ui/components/molecules/vc-select/vc-select.vue +727 -0
  200. package/ui/components/molecules/vc-slider/vc-slider.vue +106 -0
  201. package/ui/components/molecules/vc-textarea/vc-textarea.stories.ts +23 -0
  202. package/ui/components/molecules/vc-textarea/vc-textarea.vue +155 -0
  203. package/ui/components/organisms/vc-app/_internal/vc-app-bar/vc-app-bar.vue +150 -0
  204. package/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/_internal/vc-app-menu-link.vue +148 -0
  205. package/ui/components/organisms/vc-app/_internal/vc-app-menu/_internal/vc-app-menu-item/vc-app-menu-item.vue +157 -0
  206. package/ui/components/organisms/vc-app/_internal/vc-app-menu/vc-app-menu.vue +110 -0
  207. package/ui/components/organisms/vc-app/vc-app.stories.ts +75 -0
  208. package/ui/components/organisms/vc-app/vc-app.vue +169 -0
  209. package/ui/components/organisms/vc-blade/_internal/vc-blade-header/vc-blade-header.vue +126 -0
  210. package/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/_internal/vc-blade-toolbar-button/vc-blade-toolbar-button.vue +223 -0
  211. package/ui/components/organisms/vc-blade/_internal/vc-blade-toolbar/vc-blade-toolbar.vue +67 -0
  212. package/ui/components/organisms/vc-blade/vc-blade.stories.ts +46 -0
  213. package/ui/components/organisms/vc-blade/vc-blade.vue +87 -0
  214. package/ui/components/organisms/vc-dynamic-property/vc-dynamic-property.vue +426 -0
  215. package/ui/components/organisms/vc-gallery/_internal/vc-gallery-item/vc-gallery-item.vue +123 -0
  216. package/ui/components/organisms/vc-gallery/_internal/vc-gallery-preview/vc-gallery-preview.vue +93 -0
  217. package/ui/components/organisms/vc-gallery/vc-gallery.vue +186 -0
  218. package/ui/components/organisms/vc-login-form/vc-login-form.stories.ts +55 -0
  219. package/ui/components/organisms/vc-login-form/vc-login-form.vue +48 -0
  220. package/ui/components/organisms/vc-popup/vc-popup.stories.ts +23 -0
  221. package/ui/components/organisms/vc-popup/vc-popup.vue +97 -0
  222. package/ui/components/organisms/vc-table/_internal/vc-table-cell/vc-table-cell.vue +113 -0
  223. package/ui/components/organisms/vc-table/_internal/vc-table-counter/vc-table-counter.vue +29 -0
  224. package/ui/components/organisms/vc-table/_internal/vc-table-filter/vc-table-filter.vue +152 -0
  225. package/ui/components/organisms/vc-table/_internal/vc-table-mobile-item/vc-table-mobile-item.vue +272 -0
  226. package/ui/components/organisms/vc-table/vc-table.stories.ts +99 -0
  227. package/ui/components/organisms/vc-table/vc-table.vue +638 -0
  228. package/ui/types/index.ts +38 -0
  229. package/ui/types/ts-helpers.ts +46 -0
  230. package/dist/components/atoms/vc-badge/vc-badge.stories.d.ts.map +0 -1
  231. package/dist/components/atoms/vc-button/vc-button.stories.d.ts.map +0 -1
  232. package/dist/components/atoms/vc-checkbox/vc-checkbox.stories.d.ts.map +0 -1
  233. package/dist/components/atoms/vc-container/vc-container.stories.d.ts.map +0 -1
  234. package/dist/components/atoms/vc-hint/vc-hint.stories.d.ts.map +0 -1
  235. package/dist/components/atoms/vc-icon/vc-icon.stories.d.ts.map +0 -1
  236. package/dist/components/atoms/vc-image/vc-image.stories.d.ts.map +0 -1
  237. package/dist/components/atoms/vc-label/vc-label.stories.d.ts.map +0 -1
  238. package/dist/components/atoms/vc-link/vc-link.stories.d.ts.map +0 -1
  239. package/dist/components/atoms/vc-progress/vc-progress.stories.d.ts.map +0 -1
  240. package/dist/components/atoms/vc-status/vc-status.stories.d.ts.map +0 -1
  241. package/dist/components/atoms/vc-switch/vc-switch.stories.d.ts.map +0 -1
  242. package/dist/components/index.d.ts.map +0 -1
  243. package/dist/components/molecules/vc-breadcrumbs/vc-breadcrumbs.stories.d.ts.map +0 -1
  244. package/dist/components/molecules/vc-form/vc-form.stories.d.ts.map +0 -1
  245. package/dist/components/molecules/vc-input/vc-input.stories.d.ts +0 -7
  246. package/dist/components/molecules/vc-input/vc-input.stories.d.ts.map +0 -1
  247. package/dist/components/molecules/vc-pagination/vc-pagination.stories.d.ts.map +0 -1
  248. package/dist/components/molecules/vc-rating/vc-rating.stories.d.ts.map +0 -1
  249. package/dist/components/molecules/vc-select/vc-select.stories.d.ts +0 -7
  250. package/dist/components/molecules/vc-select/vc-select.stories.d.ts.map +0 -1
  251. package/dist/components/molecules/vc-textarea/vc-textarea.stories.d.ts.map +0 -1
  252. package/dist/components/organisms/vc-app/vc-app.stories.d.ts.map +0 -1
  253. package/dist/components/organisms/vc-blade/vc-blade.stories.d.ts.map +0 -1
  254. package/dist/components/organisms/vc-login-form/vc-login-form.stories.d.ts.map +0 -1
  255. package/dist/components/organisms/vc-popup/vc-popup.stories.d.ts.map +0 -1
  256. package/dist/components/organisms/vc-table/vc-table.stories.d.ts.map +0 -1
@@ -0,0 +1,272 @@
1
+ <template>
2
+ <div
3
+ class="tw-relative tw-flex tw-flex-nowrap tw-items-stretch tw-transition tw-duration-200"
4
+ :class="{ ' tw-transition-none': isMoving }"
5
+ :style="`transform: translateX(${offsetX}px)`"
6
+ @click="$emit('click')"
7
+ @touchstart="touchStart"
8
+ @touchmove="touchMove"
9
+ @touchend="touchEnd"
10
+ @touchcancel="touchCancel"
11
+ >
12
+ <!-- Left swipe actions-->
13
+ <div
14
+ class= "tw-flex-shrink-0 tw-w-[80px] tw-flex tw-flex-col [justify-content:stretch] tw-bg-[#a9bfd2]"
15
+ v-if="leftSwipeActions && leftSwipeActions.length"
16
+ >
17
+ <div
18
+ class= "tw-flex tw-grow tw-basis-[1] tw-flex-col tw-justify-center tw-items-center tw-text-white"
19
+ :class="[`vc-table-mobile__item-action_${leftSwipeActions[0].variant}`]"
20
+ @click.stop="leftSwipeActions[0].clickHandler(item)"
21
+ >
22
+ <VcIcon :icon="leftSwipeActions[0].icon"></VcIcon>
23
+ <div class="tw-mt-1 tw-text-lg">
24
+ {{ leftSwipeActions[0].title }}
25
+ </div>
26
+ </div>
27
+ </div>
28
+
29
+ <div class= "tw-flex-shrink-0 tw-w-full">
30
+ <!-- Mobile item slot content -->
31
+ <slot></slot>
32
+ </div>
33
+
34
+ <!-- Item actions -->
35
+ <div
36
+ class= "tw-flex-shrink-0 tw-w-[80px] tw-flex tw-flex-col [justify-content:stretch] tw-bg-[#a9bfd2]"
37
+ v-if="rightSwipeActions && rightSwipeActions.length"
38
+ >
39
+ <!-- First available action -->
40
+ <div
41
+ class= "tw-flex tw-grow tw-basis-[1] tw-flex-col tw-justify-center tw-items-center tw-text-white"
42
+ :class="[
43
+ `vc-table-mobile__item-action_${rightSwipeActions[0].variant}`,
44
+ ]"
45
+ @click.stop="rightSwipeActions[0].clickHandler(item)"
46
+ >
47
+ <VcIcon :icon="rightSwipeActions[0].icon"></VcIcon>
48
+ <div class="vc-table-mobile__item-action-text">
49
+ {{ rightSwipeActions[0].title }}
50
+ </div>
51
+ </div>
52
+
53
+ <!-- Second available action -->
54
+ <div
55
+ v-if="rightSwipeActions.length === 2"
56
+ class= "tw-flex tw-grow tw-basis-[1] tw-flex-col tw-justify-center tw-items-center tw-text-white"
57
+ :class="[
58
+ `vc-table-mobile__item-action_${rightSwipeActions[1].variant}`,
59
+ ]"
60
+ @click.stop="rightSwipeActions[1].clickHandler(item)"
61
+ >
62
+ <VcIcon :icon="rightSwipeActions[1].icon"></VcIcon>
63
+ <div class="tw-mt-1 tw-text-lg">
64
+ {{ rightSwipeActions[1].title }}
65
+ </div>
66
+ </div>
67
+
68
+ <!-- Other available actions -->
69
+ <template v-if="rightSwipeActions.length > 2">
70
+ <div
71
+ class= "tw-flex tw-grow tw-basis-[1] tw-flex-col tw-justify-center tw-items-center tw-text-white"
72
+ @click.stop="isActionsPopupVisible = true"
73
+ >
74
+ <VcIcon icon="fas fa-ellipsis-h"></VcIcon>
75
+ <div class="tw-mt-1 tw-text-lg">More</div>
76
+ </div>
77
+
78
+ <!-- Actions popup -->
79
+ <teleport to="body" v-if="isActionsPopupVisible">
80
+ <div
81
+ class="tw-absolute tw-left-0 tw-top-0 tw-right-0 tw-bottom-0 tw-bg-[rgba(107,121,135,0.15)] tw-flex tw-items-center tw-justify-center tw-z-[99]"
82
+ >
83
+ <div
84
+ class="tw-bg-white tw-rounded-[6px] tw-overflow-hidden tw-p-5 tw-max-w-[80%] tw-w-[350px] tw-border tw-border-solid tw-border-[#eef0f2] tw-box-border tw-shadow-[1px_1px_22px_rgba(126,142,157,0.2)]"
85
+ >
86
+ <div class= "tw-flex tw-w-full tw-items-center">
87
+ <span
88
+ class="tw-grow tw-text-[#2e3d4e] tw-text-[19px] tw-font-semibold tw-tracking-[-0.01em]"
89
+ >
90
+ {{ $t("All actions") }}
91
+ </span>
92
+ <VcIcon
93
+ class="tw-text-[#c2d7e4]"
94
+ icon="fas fa-times-circle"
95
+ size="xl"
96
+ @click="isActionsPopupVisible = false"
97
+ ></VcIcon>
98
+ </div>
99
+
100
+ <div class= "tw-flex tw-flex-wrap tw-my-5 tw-justify-between">
101
+ <div
102
+ v-for="(itemAction, i) in itemActions"
103
+ :key="i"
104
+ class= "tw-flex tw-grow tw-shrink-0 tw-flex-col tw-items-center tw-text-[#319ed4] tw-my-2 tw-box-border tw-p-1 tw-max-w-[80px]"
105
+ @click="itemAction.clickHandler(item)"
106
+ >
107
+ <VcIcon :icon="itemAction.icon" size="xl"></VcIcon>
108
+ <div class="tw-text-base tw-mt-2 tw-text-center">
109
+ {{ itemAction.title }}
110
+ </div>
111
+ </div>
112
+ </div>
113
+ </div>
114
+ </div>
115
+ </teleport>
116
+ </template>
117
+ </div>
118
+ </div>
119
+ </template>
120
+
121
+ <script lang="ts" setup>
122
+ import { computed, ref, watch } from "vue";
123
+ import { IActionBuilderResult } from "@/core/types";
124
+ import { VcIcon } from "@/ui/components";
125
+
126
+ export interface Props {
127
+ item: {
128
+ id: string;
129
+ };
130
+ actionBuilder?: (item: { id: string }) => IActionBuilderResult[];
131
+ swipingItem?: string;
132
+ }
133
+
134
+ export interface Emits {
135
+ (event: "swipeStart", id: string): void;
136
+ }
137
+
138
+ const props = withDefaults(defineProps<Props>(), {
139
+ item: undefined,
140
+ actionBuilder: undefined,
141
+ swipingItem: null,
142
+ });
143
+
144
+ const emit = defineEmits<Emits>();
145
+ const offsetX = ref(0);
146
+ const startX = ref(0);
147
+ const startY = ref(0);
148
+ const startOffsetX = ref(0);
149
+ const isMoving = ref(false);
150
+ const threshold = 10;
151
+ const maxWidth = 80;
152
+ const isActionsPopupVisible = ref(false);
153
+ const itemActions = ref([]);
154
+
155
+ watch(
156
+ () => props.swipingItem,
157
+ (newVal) => {
158
+ if (newVal !== props.item.id) {
159
+ handleOffset();
160
+ }
161
+ }
162
+ );
163
+
164
+ const rightSwipeActions = computed(
165
+ () =>
166
+ itemActions.value &&
167
+ itemActions.value.length &&
168
+ itemActions.value.filter(
169
+ (actions: IActionBuilderResult) => !actions.leftActions
170
+ )
171
+ );
172
+ const leftSwipeActions = computed(
173
+ () =>
174
+ itemActions.value &&
175
+ itemActions.value.length &&
176
+ itemActions.value.filter(
177
+ (actions: IActionBuilderResult) => actions.leftActions
178
+ )
179
+ );
180
+
181
+ function handleOffset() {
182
+ if (
183
+ itemActions.value.some((action: IActionBuilderResult) => action.leftActions)
184
+ ) {
185
+ offsetX.value = -maxWidth;
186
+ startOffsetX.value = offsetX.value;
187
+ } else {
188
+ offsetX.value = 0;
189
+ startOffsetX.value = 0;
190
+ }
191
+ }
192
+
193
+ async function touchStart(e: TouchEvent): Promise<void> {
194
+ startX.value = e.touches[0].clientX;
195
+ startY.value = e.touches[0].clientY;
196
+ startOffsetX.value = offsetX.value;
197
+ isMoving.value = true;
198
+
199
+ if (!itemActions.value.length) {
200
+ if (typeof props.actionBuilder === "function") {
201
+ itemActions.value = props.actionBuilder(props.item);
202
+
203
+ handleOffset();
204
+ }
205
+ }
206
+ }
207
+
208
+ function touchMove(e: TouchEvent): void {
209
+ emit("swipeStart", props.item.id);
210
+ if (itemActions.value && itemActions.value.length) {
211
+ const deltaX = e.touches[0].clientX - startX.value;
212
+ const deltaY = e.touches[0].clientY - startY.value;
213
+
214
+ if (
215
+ Math.abs(deltaX) > threshold &&
216
+ (rightSwipeActions.value && rightSwipeActions.value.length
217
+ ? leftSwipeActions.value && leftSwipeActions.value.length
218
+ ? Math.abs(startOffsetX.value + deltaX) <= maxWidth * 2
219
+ : Math.abs(startOffsetX.value + deltaX) <= maxWidth
220
+ : Math.abs(startOffsetX.value + deltaX) <= maxWidth) &&
221
+ startOffsetX.value + deltaX < 0
222
+ ) {
223
+ if (Math.abs(deltaY) < threshold * 2) {
224
+ e.preventDefault();
225
+ }
226
+ offsetX.value = startOffsetX.value + deltaX;
227
+ }
228
+ }
229
+ }
230
+
231
+ function touchEnd(): void {
232
+ const absoluteOffsetX = Math.abs(offsetX.value);
233
+ if (absoluteOffsetX < maxWidth) {
234
+ offsetX.value = absoluteOffsetX < maxWidth / 2 ? 0 : -maxWidth;
235
+ } else {
236
+ offsetX.value =
237
+ absoluteOffsetX <= maxWidth * 2 - threshold * 2
238
+ ? -maxWidth
239
+ : -maxWidth * 2;
240
+ }
241
+
242
+ isMoving.value = false;
243
+ }
244
+
245
+ function touchCancel(): void {
246
+ const absoluteOffsetX = Math.abs(offsetX.value);
247
+ if (absoluteOffsetX < maxWidth) {
248
+ offsetX.value = absoluteOffsetX < maxWidth / 2 ? 0 : -maxWidth;
249
+ } else {
250
+ offsetX.value =
251
+ absoluteOffsetX <= maxWidth * 2 - threshold * 2
252
+ ? -maxWidth
253
+ : -maxWidth * 2;
254
+ }
255
+
256
+ isMoving.value = false;
257
+ }
258
+ </script>
259
+
260
+ <style lang="scss">
261
+ .vc-table-mobile__item {
262
+ &-action {
263
+ &_success {
264
+ @apply tw-bg-[#87b563];
265
+ }
266
+
267
+ &_danger {
268
+ @apply tw-bg-[#ff4a4a];
269
+ }
270
+ }
271
+ }
272
+ </style>
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Table component.
3
+ * @author Iurii A Taranov <me@flanker72.ru>
4
+ */
5
+ import { Story } from "@storybook/vue3";
6
+ import VcTable from "./vc-table.vue";
7
+ import VcHint from "../../atoms/vc-hint/vc-hint.vue";
8
+ import VcImage from "../../atoms/vc-image/vc-image.vue";
9
+
10
+ export default {
11
+ title: "organisms/vc-table",
12
+ component: VcTable,
13
+ };
14
+
15
+ const Template: Story = (args) => ({
16
+ components: { VcTable, VcHint, VcImage },
17
+ setup() {
18
+ return { args };
19
+ },
20
+ template: `
21
+ <div class= "tw-flex tw-h-[400px] tw-overflow-hidden">
22
+ <vc-table v-bind="args">
23
+ <template v-slot:item_img="itemData">
24
+ <vc-image aspect="1x1" size="auto" :tw-border-ed="true" :src="itemData.item.img"></vc-image>
25
+ </template>
26
+ <template v-slot:item_name="itemData">
27
+ <div class= "tw-flex tw-flex-col">
28
+ <div>{{ itemData.item.name }}</div>
29
+ <vc-hint>{{ itemData.item.description }}</vc-hint>
30
+ </div>
31
+ </template>
32
+ </vc-table>
33
+ </div>
34
+ `,
35
+ });
36
+
37
+ export const Table = Template.bind({});
38
+ Table.storyName = "vc-table";
39
+ Table.args = {
40
+ multiselect: true,
41
+
42
+ columns: [
43
+ {
44
+ id: "img",
45
+ title: "Pic",
46
+ width: 60,
47
+ class: "pr-0",
48
+ },
49
+ {
50
+ id: "name",
51
+ title: "Name",
52
+ sortable: true,
53
+ },
54
+ {
55
+ id: "sku",
56
+ title: "SKU",
57
+ sortable: true,
58
+ width: 100,
59
+ },
60
+ ],
61
+
62
+ items: [
63
+ {
64
+ id: 1,
65
+ img: "/images/1.jpg",
66
+ name: "Lenovo IdeaCentre 310S-08",
67
+ description: "Physical",
68
+ sku: "990555005",
69
+ },
70
+ {
71
+ id: 2,
72
+ img: "/images/2.jpg",
73
+ name: "BLU Win HD LTE X150Q 8GB",
74
+ description: "Physical",
75
+ sku: "003578948",
76
+ },
77
+ {
78
+ id: 3,
79
+ img: "/images/3.jpg",
80
+ name: "Samsung Galaxy S6 SM-G920F 32GB",
81
+ description: "Physical",
82
+ sku: "334590-095",
83
+ },
84
+ {
85
+ id: 4,
86
+ img: "/images/4.jpg",
87
+ name: "DJI Phantom 3 Professional Quadcopter",
88
+ description: "Physical",
89
+ sku: "000545432",
90
+ },
91
+ {
92
+ id: 5,
93
+ img: "/images/5.jpg",
94
+ name: "3DR X8-M Octocopter for Visual-Spectr",
95
+ description: "Physical",
96
+ sku: "435344443",
97
+ },
98
+ ],
99
+ };