@bildvitta/quasar-ui-asteroid 2.16.0 → 3.0.0-alpha.2

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 (280) hide show
  1. package/dist/api/QasActions.json +40 -0
  2. package/dist/api/QasActionsMenu.json +64 -0
  3. package/dist/api/QasAlert.json +40 -0
  4. package/dist/api/QasAppBar.json +52 -0
  5. package/dist/api/QasAppMenu.json +38 -0
  6. package/dist/api/QasAvatar.json +44 -0
  7. package/dist/api/QasBox.json +16 -0
  8. package/dist/api/QasBreakline.json +32 -0
  9. package/dist/api/QasBtn.json +16 -0
  10. package/dist/api/QasCard.json +52 -0
  11. package/dist/api/QasCheckboxGroup.json +38 -0
  12. package/dist/api/QasCopy.json +29 -0
  13. package/dist/api/QasDateTimeInput.json +60 -0
  14. package/dist/api/QasDebugger.json +13 -0
  15. package/dist/api/QasDelete.json +64 -0
  16. package/dist/api/QasDialog.json +109 -0
  17. package/dist/api/QasDialogRouter.json +31 -0
  18. package/dist/api/QasField.json +56 -0
  19. package/dist/api/QasFilters.json +111 -0
  20. package/dist/api/QasFormGenerator.json +92 -0
  21. package/dist/api/QasFormView.json +228 -0
  22. package/dist/api/QasGallery.json +54 -0
  23. package/dist/api/QasGridGenerator.json +108 -0
  24. package/dist/api/QasInput.json +40 -0
  25. package/dist/api/QasLabel.json +40 -0
  26. package/dist/api/QasLayout.json +47 -0
  27. package/dist/api/QasListItems.json +72 -0
  28. package/dist/api/QasListView.json +161 -0
  29. package/dist/api/QasMap.json +41 -0
  30. package/dist/api/QasNestedFields.json +223 -0
  31. package/dist/api/QasNumericInput.json +68 -0
  32. package/dist/api/QasPageHeader.json +36 -0
  33. package/dist/api/QasPasswordInput.json +121 -0
  34. package/dist/api/QasPasswordStrengthChecker.json +126 -0
  35. package/dist/api/QasProfile.json +74 -0
  36. package/dist/api/QasResizer.json +34 -0
  37. package/dist/api/QasSearchBox.json +91 -0
  38. package/dist/api/QasSelect.json +88 -0
  39. package/dist/api/QasSelectList.json +134 -0
  40. package/dist/api/QasSignaturePad.json +63 -0
  41. package/dist/api/QasSignatureUploader.json +41 -0
  42. package/dist/api/QasSingleView.json +147 -0
  43. package/dist/api/QasSortable.json +80 -0
  44. package/dist/api/QasTableGenerator.json +56 -0
  45. package/dist/api/QasTabsGenerator.json +90 -0
  46. package/dist/api/QasTextTruncate.json +38 -0
  47. package/dist/api/QasTransfer.json +70 -0
  48. package/dist/api/QasUploader.json +143 -0
  49. package/dist/asteroid.cjs.css +1 -0
  50. package/dist/asteroid.cjs.js +9307 -0
  51. package/dist/asteroid.cjs.min.js +6 -0
  52. package/dist/asteroid.esm.css +1 -0
  53. package/dist/asteroid.esm.js +9298 -0
  54. package/dist/asteroid.esm.min.js +6 -0
  55. package/dist/asteroid.umd.css +1 -0
  56. package/dist/asteroid.umd.js +9301 -0
  57. package/dist/asteroid.umd.min.js +6 -0
  58. package/dist/vetur/asteroid-attributes.json +1178 -0
  59. package/dist/vetur/asteroid-tags.json +535 -0
  60. package/package.json +41 -56
  61. package/src/assets/logo-modular.svg +1 -1
  62. package/src/asteroid.js +1 -0
  63. package/src/components/actions/QasActions.vue +45 -0
  64. package/src/components/actions/QasActions.yml +24 -0
  65. package/src/components/actions-menu/QasActionsMenu.vue +41 -14
  66. package/src/components/actions-menu/QasActionsMenu.yml +63 -0
  67. package/src/components/alert/QasAlert.vue +90 -0
  68. package/src/components/alert/QasAlert.yml +33 -0
  69. package/src/components/app-bar/QasAppBar.vue +16 -13
  70. package/src/components/app-bar/QasAppBar.yml +51 -0
  71. package/src/components/app-menu/QasAppMenu.vue +10 -12
  72. package/src/components/app-menu/QasAppMenu.yml +32 -0
  73. package/src/components/avatar/QasAvatar.vue +17 -9
  74. package/src/components/avatar/QasAvatar.yml +38 -0
  75. package/src/components/box/QasBox.vue +12 -4
  76. package/src/components/box/QasBox.yml +13 -0
  77. package/src/components/breakline/QasBreakline.vue +37 -0
  78. package/src/components/breakline/QasBreakline.yml +25 -0
  79. package/src/components/btn/QasBtn.vue +27 -24
  80. package/src/components/btn/QasBtn.yml +13 -0
  81. package/src/components/card/QasCard.vue +32 -33
  82. package/src/components/card/QasCard.yml +42 -0
  83. package/src/components/checkbox-group/QasCheckboxGroup.vue +50 -17
  84. package/src/components/checkbox-group/QasCheckboxGroup.yml +30 -0
  85. package/src/components/copy/QasCopy.vue +22 -11
  86. package/src/components/copy/QasCopy.yml +20 -0
  87. package/src/components/date-time-input/QasDateTimeInput.vue +18 -26
  88. package/src/components/date-time-input/QasDateTimeInput.yml +54 -0
  89. package/src/components/debugger/QasDebugger.vue +2 -0
  90. package/src/components/debugger/QasDebugger.yml +10 -0
  91. package/src/components/delete/QasDelete.vue +43 -16
  92. package/src/components/delete/QasDelete.yml +52 -0
  93. package/src/components/dialog/QasDialog.vue +63 -67
  94. package/src/components/dialog/QasDialog.yml +86 -0
  95. package/src/components/dialog-router/QasDialogRouter.vue +14 -4
  96. package/src/components/dialog-router/QasDialogRouter.yml +23 -0
  97. package/src/components/field/QasField.vue +21 -24
  98. package/src/components/field/QasField.yml +31 -0
  99. package/src/components/filters/QasFilters.vue +33 -26
  100. package/src/components/filters/QasFilters.yml +91 -0
  101. package/src/components/form-generator/QasFormGenerator.vue +13 -15
  102. package/src/components/form-generator/QasFormGenerator.yml +64 -0
  103. package/src/components/form-view/QasFormView.vue +129 -69
  104. package/src/components/form-view/QasFormView.yml +179 -0
  105. package/src/components/gallery/QasGallery.vue +47 -30
  106. package/src/components/gallery/QasGallery.yml +51 -0
  107. package/src/components/grid-generator/QasGridGenerator.vue +15 -7
  108. package/src/components/grid-generator/QasGridGenerator.yml +73 -0
  109. package/src/components/index.js +0 -0
  110. package/src/components/input/QasInput.vue +43 -36
  111. package/src/components/input/QasInput.yml +32 -0
  112. package/src/components/label/QasLabel.vue +14 -15
  113. package/src/components/label/QasLabel.yml +28 -0
  114. package/src/components/layout/QasLayout.vue +13 -21
  115. package/src/components/layout/QasLayout.yml +38 -0
  116. package/src/components/list-items/QasListItems.vue +15 -12
  117. package/src/components/list-items/QasListItems.yml +57 -0
  118. package/src/components/list-view/QasListView.vue +57 -31
  119. package/src/components/list-view/QasListView.yml +132 -0
  120. package/src/components/map/QasMap.vue +15 -31
  121. package/src/components/map/QasMap.yml +33 -0
  122. package/src/components/nested-fields/QasNestedFields.vue +57 -47
  123. package/src/components/nested-fields/QasNestedFields.yml +180 -0
  124. package/src/components/numeric-input/QasNumericInput.vue +31 -22
  125. package/src/components/numeric-input/QasNumericInput.yml +51 -0
  126. package/src/components/page-header/QasPageHeader.vue +20 -11
  127. package/src/components/page-header/QasPageHeader.yml +24 -0
  128. package/src/components/password-input/QasPasswordInput.vue +24 -21
  129. package/src/components/password-input/QasPasswordInput.yml +103 -0
  130. package/src/components/password-strength-checker/QasPasswordStrengthChecker.vue +51 -34
  131. package/src/components/password-strength-checker/QasPasswordStrengthChecker.yml +103 -0
  132. package/src/components/profile/QasProfile.vue +15 -13
  133. package/src/components/profile/QasProfile.yml +60 -0
  134. package/src/components/resizer/QasResizer.vue +3 -3
  135. package/src/components/resizer/QasResizer.yml +23 -0
  136. package/src/components/search-box/QasSearchBox.vue +50 -21
  137. package/src/components/search-box/QasSearchBox.yml +76 -0
  138. package/src/components/select/QasSelect.vue +51 -50
  139. package/src/components/select/QasSelect.yml +62 -0
  140. package/src/components/select-list/QasSelectList.vue +72 -53
  141. package/src/components/select-list/QasSelectList.yml +116 -0
  142. package/src/components/signature-pad/QasSignaturePad.vue +60 -40
  143. package/src/components/signature-pad/QasSignaturePad.yml +53 -0
  144. package/src/components/signature-uploader/QasSignatureUploader.vue +19 -17
  145. package/src/components/signature-uploader/QasSignatureUploader.yml +36 -0
  146. package/src/components/single-view/QasSingleView.vue +41 -22
  147. package/src/components/single-view/QasSingleView.yml +116 -0
  148. package/src/components/sortable/QasSortable.vue +51 -30
  149. package/src/components/sortable/QasSortable.yml +65 -0
  150. package/src/components/table-generator/QasTableGenerator.vue +112 -21
  151. package/src/components/table-generator/QasTableGenerator.yml +46 -0
  152. package/src/components/tabs-generator/QasTabsGenerator.vue +37 -25
  153. package/src/components/tabs-generator/QasTabsGenerator.yml +67 -0
  154. package/src/components/text-truncate/QasTextTruncate.vue +25 -17
  155. package/src/components/text-truncate/QasTextTruncate.yml +32 -0
  156. package/src/components/transfer/QasTransfer.vue +48 -49
  157. package/src/components/transfer/QasTransfer.yml +59 -0
  158. package/src/components/uploader/QasUploader.vue +169 -48
  159. package/src/components/uploader/QasUploader.yml +117 -0
  160. package/src/css/background.scss +1 -1
  161. package/src/css/border.scss +7 -6
  162. package/src/css/design-system.scss +0 -43
  163. package/src/css/fonts.scss +2 -28
  164. package/src/css/opacity.scss +0 -4
  165. package/src/css/set-brand.scss +15 -0
  166. package/src/css/transitions.scss +1 -1
  167. package/src/helpers/add-counter-suffix.js +3 -0
  168. package/src/helpers/{base64ToBlob.js → base-64-to-blob.js} +0 -0
  169. package/src/helpers/{constructObject.js → construct-object.js} +0 -0
  170. package/src/helpers/filter-object.js +8 -6
  171. package/src/helpers/filters.js +8 -4
  172. package/src/helpers/{greatestCommonDivisor.js → get-greatest-common-divisor.js} +0 -0
  173. package/src/helpers/get-slot-children-text.js +15 -0
  174. package/src/helpers/images.js +28 -0
  175. package/src/helpers/index.js +11 -59
  176. package/src/helpers/{isLocalDevelopment.js → is-local-development.js} +0 -0
  177. package/src/helpers/set-scroll-on-grab.js +61 -0
  178. package/src/index.cjs.js +1 -0
  179. package/src/index.esm.js +4 -0
  180. package/src/index.scss +19 -21
  181. package/src/index.umd.js +2 -0
  182. package/src/mixins/context.js +1 -1
  183. package/src/mixins/dialog-router.js +17 -0
  184. package/src/mixins/form.js +4 -12
  185. package/src/mixins/generator.js +14 -14
  186. package/src/mixins/index.js +2 -8
  187. package/src/mixins/password.js +73 -11
  188. package/src/mixins/screen.js +8 -6
  189. package/src/mixins/view.js +62 -22
  190. package/src/plugins/dialog/Dialog.js +14 -0
  191. package/src/plugins/dialog/Dialog.yml +10 -0
  192. package/src/plugins/index.js +4 -2
  193. package/src/plugins/{NotifyError.js → notify-error/NotifyError.js} +0 -0
  194. package/src/plugins/notify-error/NotifyError.yml +11 -0
  195. package/src/plugins/{NotifySuccess.js → notify-success/NotifySuccess.js} +3 -3
  196. package/src/plugins/notify-success/NotifySuccess.yml +11 -0
  197. package/src/store/history.js +43 -0
  198. package/src/store/index.js +1 -0
  199. package/src/vue-plugin.js +185 -0
  200. package/.babelrc +0 -12
  201. package/.storybook/main.js +0 -35
  202. package/.storybook/preview.js +0 -26
  203. package/debug.log +0 -1
  204. package/index.js +0 -4
  205. package/jest-setup.js +0 -1
  206. package/jest.config.json +0 -22
  207. package/postcss.config.js +0 -5
  208. package/src/components/Introduction.stories.mdx +0 -12
  209. package/src/components/actions-menu/QasActionsMenu.stories.js +0 -73
  210. package/src/components/app-bar/QasAppBar.stories.js +0 -84
  211. package/src/components/app-menu/QasAppMenu.stories.js +0 -66
  212. package/src/components/apps-menu/QasAppsMenu.spec.js +0 -58
  213. package/src/components/apps-menu/QasAppsMenu.stories.js +0 -54
  214. package/src/components/apps-menu/QasAppsMenu.vue +0 -48
  215. package/src/components/avatar/QasAvatar.spec.js +0 -14
  216. package/src/components/avatar/QasAvatar.stories.js +0 -52
  217. package/src/components/box/QasBox.spec.js +0 -18
  218. package/src/components/box/QasBox.stories.js +0 -35
  219. package/src/components/break-line/QasBreakLine.stories.js +0 -57
  220. package/src/components/break-line/QasBreakLine.vue +0 -52
  221. package/src/components/btn/QasBtn.stories.js +0 -45
  222. package/src/components/btn-actions/QasBtnActions.stories.js +0 -77
  223. package/src/components/btn-actions/QasBtnActions.vue +0 -54
  224. package/src/components/card/QasCard.stories.js +0 -126
  225. package/src/components/checkbox-group/QasCheckboxGroup.stories.js +0 -59
  226. package/src/components/copy/QasCopy.stories.js +0 -41
  227. package/src/components/date-time-input/QasDateTimeInput.stories.js +0 -67
  228. package/src/components/debugger/QasDebugger.stories.js +0 -33
  229. package/src/components/delete/QasDelete.stories.js +0 -80
  230. package/src/components/dialog/QasDialog.stories.js +0 -139
  231. package/src/components/dialog-router/QasDialogRouter.stories.js +0 -38
  232. package/src/components/field/QasField.stories.js +0 -181
  233. package/src/components/filters/QasFilters.stories.js +0 -121
  234. package/src/components/form-generator/QasFormGenerator.stories.js +0 -115
  235. package/src/components/form-view/QasFormView.stories.js +0 -236
  236. package/src/components/gallery/QasGallery.stories.js +0 -91
  237. package/src/components/grid-generator/QasGridGenerator.stories.js +0 -142
  238. package/src/components/input/QasInput.stories.js +0 -78
  239. package/src/components/label/QasLabel.stories.js +0 -60
  240. package/src/components/layout/QasLayout.stories.js +0 -104
  241. package/src/components/list-items/QasListItems.stories.js +0 -135
  242. package/src/components/list-view/QasListView.stories.js +0 -168
  243. package/src/components/map/QasMap.stories.js +0 -75
  244. package/src/components/nested-fields/QasNestedFields.stories.js +0 -255
  245. package/src/components/numeric-input/QasNumericInput.stories.js +0 -92
  246. package/src/components/page-header/QasPageHeader.stories.js +0 -61
  247. package/src/components/password-input/QasPasswordInput.stories.js +0 -76
  248. package/src/components/password-strength-checker/QasPasswordStrengthChecker.stories.js +0 -54
  249. package/src/components/profile/QasProfile.stories.js +0 -131
  250. package/src/components/resizer/QasResizer.stories.js +0 -43
  251. package/src/components/search-box/QasSearchBox.stories.js +0 -111
  252. package/src/components/select/QasSelect.stories.js +0 -113
  253. package/src/components/select-list/QasSelectList.stories.js +0 -153
  254. package/src/components/signature-pad/QasSignaturePad.stories.js +0 -51
  255. package/src/components/signature-uploader/QasSignatureUploader.stories.js +0 -69
  256. package/src/components/single-view/QasSingleView.stories.js +0 -130
  257. package/src/components/sortable/QasSortable.stories.js +0 -80
  258. package/src/components/table-generator/QasTableGenerator.stories.js +0 -120
  259. package/src/components/tabs-generator/QasTabsGenerator.stories.js +0 -145
  260. package/src/components/text-truncate/QasTextTruncate.stories.js +0 -55
  261. package/src/components/tip/QasTip.stories.js +0 -57
  262. package/src/components/tip/QasTip.vue +0 -68
  263. package/src/components/tooltip/QasTooltip.stories.js +0 -63
  264. package/src/components/tooltip/QasTooltip.vue +0 -81
  265. package/src/components/transfer/QasTransfer.stories.js +0 -118
  266. package/src/components/uploader/QasCustomUploader.vue +0 -120
  267. package/src/components/uploader/QasUploader.stories.js +0 -139
  268. package/src/directives/Test.js +0 -13
  269. package/src/helpers/historyHandler.js +0 -52
  270. package/src/helpers/label.js +0 -3
  271. package/src/index.js +0 -249
  272. package/src/mixins/map-markers.js +0 -26
  273. package/src/mixins/unsaved-changes.js +0 -24
  274. package/src/mixins/uploader.js +0 -30
  275. package/src/mocks/json/user.json +0 -27
  276. package/src/mocks/json/users-new.json +0 -23
  277. package/src/mocks/json/users.json +0 -97
  278. package/src/mocks/storeModule.js +0 -71
  279. package/src/pages/Forbidden.vue +0 -6
  280. package/src/pages/NotFound.vue +0 -6
@@ -0,0 +1,116 @@
1
+ type: component
2
+
3
+ meta:
4
+ desc: Componente para C.R.U.D. responsável pela visualização (Read) ou conhecido também como "show".
5
+
6
+ props:
7
+ entity:
8
+ desc: Entidade da store, por exemplo se tiver que trabalhar com modulo de usuários, teremos o model "users" na store, que vai ser nossa "entity".
9
+ required: true
10
+ type: String
11
+
12
+ custom-id:
13
+ desc: Por padrão, o componente vai pegar o "id" que vem como parâmetro na url, caso queira que o id seja diferente da url, use esta prop.
14
+ type: String
15
+ examples: ['my-custom-id']
16
+
17
+ dialog:
18
+ desc: Este componente pode ser utilizado dentro de um dialog, neste caso o componente pai não pode ser um "QPage" e sim uma "div", esta prop cuida disto.
19
+ type: Boolean
20
+
21
+ url:
22
+ desc: Envia como parâmetro para a action "fetchSingle" do modulo correspondente a "entity".
23
+ type: String
24
+
25
+ result:
26
+ model: true
27
+ desc: Model de result, utilizado para recuperar o resultado retornado pelo componente.
28
+ type: Object
29
+ examples: [v-model:result="result"]
30
+
31
+ fields:
32
+ model: true
33
+ desc: Model de fields, utilizado para recuperar os fields fora do template.
34
+ default: {}
35
+ type: Object
36
+ examples: [v-model:fields="fields"]
37
+
38
+ errors:
39
+ model: true
40
+ desc: Model de errors, utilizado para recuperar os errors fora do template.
41
+ default: {}
42
+ type: Object
43
+ examples: [v-model:errors="errors"]
44
+
45
+ metadata:
46
+ model: true
47
+ desc: Model de metadata, utilizado para recuperar os metadata fora do template.
48
+ default: {}
49
+ type: Object
50
+ examples: [v-model:metadata="metadata"]
51
+
52
+ fetching:
53
+ model: true
54
+ desc: Model de fetching, utilizado para saber se o componente está fazendo fetching de dados.
55
+ type: Boolean
56
+ examples: [v-model:fetching="isFetching"]
57
+
58
+ slots:
59
+ header:
60
+ desc: 'Slot para acessar o header.'
61
+
62
+ default:
63
+ desc: 'Slot para ter o conteúdo principal (dentro do main).'
64
+
65
+ footer:
66
+ desc: 'Slot para acessar o footer.'
67
+
68
+ events:
69
+ '@update:result -> function(value)':
70
+ desc: Dispara quando a action "fetchSingle" é executada com sucesso, é chamado antes do evento "fetch-success".
71
+ params:
72
+ value:
73
+ desc: lista retornada no "fetchSingle".
74
+ type: Array
75
+
76
+ '@update:fields -> function(value)':
77
+ desc: Dispara quando a action "fetchSingle" é executada com sucesso, é chamado antes do evento "fetch-success".
78
+ params:
79
+ value:
80
+ desc: fields.
81
+ type: Object
82
+
83
+ '@update:errors -> function(value)':
84
+ desc: Dispara quando a action "fetchSingle" é chamada.
85
+ params:
86
+ value:
87
+ desc: Errors durante o fetch.
88
+ type: Object
89
+
90
+ '@update:metadata -> function(value)':
91
+ desc: Dispara quando a action "fetchSingle" acontece com sucesso, é chamado antes do evento "fetch-success".
92
+ params:
93
+ value:
94
+ desc: metadata.
95
+ type: Object
96
+
97
+ '@update:fetching -> function(value)':
98
+ desc: Dispara logo antes da action "fetchSingle" e ao cair no bloco "finally", ou seja, quando começar o fetching e após terminar.
99
+ params:
100
+ value:
101
+ desc: Retorna se está ou não fazendo fetching de dados.
102
+ type: Boolean
103
+
104
+ '@fetch-success -> function(value)':
105
+ desc: Dispara quando a action "fetchSingle" é executada com sucesso.
106
+ params:
107
+ value:
108
+ desc: Retorna todos os dados "cru" respondido pelo fetch.
109
+ type: Object
110
+
111
+ '@fetch-error -> function(value)':
112
+ desc: Dispara quando a action "fetchSingle" cai em uma exceção.
113
+ params:
114
+ value:
115
+ desc: Retorna todos os dados "cru" respondido na exceção do fetch.
116
+ type: Object
@@ -1,30 +1,31 @@
1
1
  <template>
2
- <component :is="tag" ref="items" v-bind="$attrs" v-on="$listeners">
3
- <slot :sorted="sorted" />
2
+ <component :is="tag" ref="sortableItems">
3
+ <slot />
4
4
  </component>
5
5
  </template>
6
6
 
7
7
  <script>
8
- import { cloneDeep, get } from 'lodash'
9
- import { Loading } from 'quasar'
10
- import { NotifyError } from '../../plugins'
8
+ import { Loading, extend } from 'quasar'
11
9
  import Sortable from 'sortablejs'
12
10
 
13
- let sortable = null
11
+ import { NotifyError } from '../../plugins'
14
12
 
15
13
  export default {
14
+ name: 'QasSortable',
15
+
16
16
  props: {
17
17
  entity: {
18
18
  default: '',
19
+ required: true,
19
20
  type: String
20
21
  },
21
22
 
22
- options: {
23
+ sortableOptions: {
23
24
  default: () => ({ animation: 500 }),
24
25
  type: Object
25
26
  },
26
27
 
27
- results: {
28
+ list: {
28
29
  default: () => [],
29
30
  type: Array
30
31
  },
@@ -37,39 +38,52 @@ export default {
37
38
  url: {
38
39
  default: '',
39
40
  type: String
41
+ },
42
+
43
+ sorted: {
44
+ default: () => [],
45
+ type: Array
40
46
  }
41
47
  },
42
48
 
49
+ emits: [
50
+ 'update:sorted',
51
+ 'sort',
52
+ 'success',
53
+ 'error'
54
+ ],
55
+
43
56
  data () {
44
57
  return {
45
- sorted: null
58
+ sortable: null,
59
+ sortedList: null
46
60
  }
47
61
  },
48
62
 
49
63
  computed: {
50
64
  identifiers () {
51
- return this.sorted.map(({ id }) => id)
65
+ return this.sortedList.map(({ id }) => id)
52
66
  }
53
67
  },
54
68
 
55
69
  watch: {
56
- options (value) {
57
- sortable.options = { ...sortable.options, ...value }
70
+ sortableOptions (value) {
71
+ this.sortable.options = { ...this.sortable.options, ...value }
58
72
  },
59
73
 
60
- results (value) {
61
- this.updateValue(value)
62
- sortable.sort(sortable.toArray())
74
+ list (value) {
75
+ this.setSortedValue(value)
76
+ this.sortable.sort(this.sortable.toArray())
63
77
  }
64
78
  },
65
79
 
66
80
  created () {
67
- this.updateValue()
81
+ this.setSortedValue()
68
82
  },
69
83
 
70
- mounted () {
71
- sortable = new Sortable(this.$refs.items, {
72
- ...this.options,
84
+ async mounted () {
85
+ this.sortable = new Sortable(this.$refs.sortableItems, {
86
+ ...this.sortableOptions,
73
87
 
74
88
  onUpdate: event => {
75
89
  this.updateOrder(event)
@@ -78,18 +92,19 @@ export default {
78
92
  })
79
93
  },
80
94
 
81
- beforeDestroy () {
82
- sortable.destroy()
95
+ unmounted () {
96
+ this.sortable.destroy()
83
97
  },
84
98
 
85
99
  methods: {
86
- handleError (error) {
100
+ setError (error) {
87
101
  const { response } = error
88
- const exception = get(response, 'data.exception') || error.message
102
+ const exception = response?.data?.exception || error.message
89
103
 
90
- NotifyError('Ops! Erro ao ordernar itens.', exception)
104
+ NotifyError('Ops! Erro ao salvar ordenação.', exception)
91
105
  },
92
106
 
107
+ // TODO precisa testar este método quando tivermos uma API para teste.
93
108
  async replace () {
94
109
  Loading.show()
95
110
 
@@ -101,21 +116,27 @@ export default {
101
116
 
102
117
  this.$emit('success', response)
103
118
  } catch (error) {
104
- this.handleError(error)
119
+ this.setError(error)
120
+ this.$emit('error', error)
105
121
  } finally {
106
122
  Loading.hide()
107
123
  }
108
124
  },
109
125
 
110
- updateOrder ({ oldIndex, newIndex }) {
111
- const deleted = this.sorted.splice(oldIndex, 1)
112
- this.sorted.splice(newIndex, 0, deleted[0])
126
+ updateOrder ({ newIndex, oldIndex }) {
127
+ const deleted = this.sortedList.splice(oldIndex, 1)
128
+ this.sortedList.splice(newIndex, 0, deleted[0])
113
129
 
114
130
  this.replace()
115
131
  },
116
132
 
117
- updateValue (value) {
118
- this.sorted = cloneDeep(value || this.results)
133
+ setSortedValue (value) {
134
+ this.sortedList = extend(true, [], value || this.list)
135
+ this.updateSortedModel()
136
+ },
137
+
138
+ updateSortedModel () {
139
+ return this.$emit('update:sorted', this.sortedList)
119
140
  }
120
141
  }
121
142
  }
@@ -0,0 +1,65 @@
1
+ type: component
2
+
3
+ meta:
4
+ desc: Componente para reordenar items em uma lista e salvar após isto.
5
+
6
+ props:
7
+ entity:
8
+ desc: Entidade da store que para salvar os items após reordenar a lista.
9
+ required: true
10
+ type: String
11
+
12
+ sortable-options:
13
+ desc: Opções do "sortablejs" (https://github.com/SortableJS/Sortable#options).
14
+ default: { animation: 500 }
15
+ type: Object
16
+
17
+ list:
18
+ desc: Lista que vai ser reordenada.
19
+ default: []
20
+ type: Array
21
+
22
+ tag:
23
+ desc: Tag do componente pai.
24
+ default: div
25
+ type: String
26
+
27
+ url:
28
+ desc: Parâmetro enviado para a action "replace".
29
+ type: String
30
+
31
+ sorted:
32
+ desc: Model da lista reordenada
33
+ default: []
34
+ type: Array
35
+ examples: [v-model:sorted="fields"]
36
+ model: true
37
+
38
+ slots:
39
+ default:
40
+ desc: Slot para adicionar os items que serão reordenados.
41
+
42
+ events:
43
+ '@update:sorted -> function(value)':
44
+ desc: Dispara no created e toda vez que a prop "list" muda, usado para o v-model:sorted.
45
+ params:
46
+ value:
47
+ desc: Lista contendo nova ordenação.
48
+ type: Array
49
+
50
+ '@sort -> function(value)':
51
+ desc: Dispara toda vez que acontece uma nova ordenação.
52
+
53
+ '@success -> function(value)':
54
+ desc: Dispara toda vez que salva com sucesso a nova ordenação.
55
+ params:
56
+ value:
57
+ desc: fields.
58
+ type: Object
59
+
60
+ '@error -> function(value)':
61
+ desc: Dispara toda vez que acontece algum erro ao salvar a nova ordenação.
62
+ params:
63
+ value:
64
+ desc: fields.
65
+ type: Object
@@ -1,22 +1,27 @@
1
1
  <template>
2
- <q-table class="bg-transparent qas-table" :class="tableClasses" v-bind="attributes">
3
- <template v-for="(slot, key) in $scopedSlots" #[key]="context">
4
- <slot v-if="hasBodySlot" name="body" :props="context" />
5
-
6
- <q-td v-else :key="key">
7
- <slot :name="key" v-bind="context" />
8
- </q-td>
9
- </template>
10
- </q-table>
2
+ <qas-box class="q-mb-xl q-px-lg q-py-md">
3
+ <q-table ref="table" class="bg-transparent qas-table-generator" :class="tableClass" v-bind="attributes">
4
+ <template v-for="(_, name) in $slots" #[name]="context">
5
+ <slot v-if="hasBodySlot" name="body" :props="context" />
6
+
7
+ <q-td v-else :key="name">
8
+ <slot :name="name" v-bind="context || {}" />
9
+ </q-td>
10
+ </template>
11
+ </q-table>
12
+ </qas-box>
11
13
  </template>
12
14
 
13
15
  <script>
14
16
  import { extend } from 'quasar'
15
17
  import { humanize } from '../../helpers/filters'
16
- import screen from '../../mixins/screen'
18
+ import { setScrollOnGrab } from '../../helpers'
19
+ import screenMixin from '../../mixins/screen'
17
20
 
18
21
  export default {
19
- mixins: [screen],
22
+ name: 'QasTableGenerator',
23
+
24
+ mixins: [screenMixin],
20
25
 
21
26
  props: {
22
27
  columns: {
@@ -29,11 +34,6 @@ export default {
29
34
  type: [Array, Object]
30
35
  },
31
36
 
32
- order: {
33
- default: () => [],
34
- type: Array
35
- },
36
-
37
37
  results: {
38
38
  default: () => [],
39
39
  required: true,
@@ -48,6 +48,20 @@ export default {
48
48
  emptyResultText: {
49
49
  default: '-',
50
50
  type: String
51
+ },
52
+
53
+ useScrollOnGrab: {
54
+ type: Boolean,
55
+ default: true
56
+ }
57
+ },
58
+
59
+ data () {
60
+ return {
61
+ scrollableElement: null,
62
+ scrollOnGrab: {},
63
+ elementToObserve: null,
64
+ resizeObserver: null
51
65
  }
52
66
  },
53
67
 
@@ -55,7 +69,7 @@ export default {
55
69
  attributes () {
56
70
  const attributes = {
57
71
  columns: this.columnsByFields,
58
- data: this.resultsByFields,
72
+ rows: this.resultsByFields,
59
73
  flat: true,
60
74
  hideBottom: true,
61
75
  pagination: { rowsPerPage: 0 },
@@ -106,7 +120,11 @@ export default {
106
120
  },
107
121
 
108
122
  hasBodySlot () {
109
- return !!(this.$slots.body || this.$scopedSlots.body)
123
+ return !!this.$slots.body
124
+ },
125
+
126
+ hasTbodySlot () {
127
+ return !!this.$slots.tbody
110
128
  },
111
129
 
112
130
  hasFields () {
@@ -130,15 +148,88 @@ export default {
130
148
  return this.results.length
131
149
  },
132
150
 
133
- tableClasses () {
134
- return this.$_isSmall && 'qas-table--mobile'
151
+ tableClass () {
152
+ return this.mx_isSmall && 'qas-table-generator--mobile'
153
+ },
154
+
155
+ hasScrollOnGrab () {
156
+ return !!Object.keys(this.scrollOnGrab).length
157
+ }
158
+ },
159
+
160
+ mounted () {
161
+ if (!this.useScrollOnGrab) return
162
+
163
+ this.setObserver()
164
+ window.addEventListener('resize', this.handleScrollOnGrab)
165
+ },
166
+
167
+ onUnmounted () {
168
+ if (!this.hasScrollOnGrab) return
169
+
170
+ this.destroyObserver()
171
+ this.scrollOnGrab.destroyEvents()
172
+ window.removeEventListener('resize', this.handleScrollOnGrab)
173
+ },
174
+
175
+ methods: {
176
+ initializeScrollOnGrab () {
177
+ if (this.hasScrollOnGrab) return
178
+
179
+ const element = this.getTableElementComponent().querySelector('.q-table__middle.scroll')
180
+
181
+ this.scrollOnGrab = setScrollOnGrab(element)
182
+ },
183
+
184
+ getTableElementComponent () {
185
+ return this.$refs?.table?.$el
186
+ },
187
+
188
+ getTableElement () {
189
+ return this.getTableElementComponent()?.querySelector('table')
190
+ },
191
+
192
+ getFullTableWidth () {
193
+ const tableElemet = this.getTableElement()
194
+ return tableElemet?.getBoundingClientRect?.()?.width
195
+ },
196
+
197
+ getContainerTableWidth () {
198
+ const containerElement = this.getTableElementComponent()?.querySelector('.q-table__middle')
199
+ return containerElement?.getBoundingClientRect?.()?.width
200
+ },
201
+
202
+ handleScrollOnGrab () {
203
+ const fullTableWidth = this.getFullTableWidth()
204
+ const containerTableWidth = this.getContainerTableWidth()
205
+
206
+ if (fullTableWidth > containerTableWidth) {
207
+ this.initializeScrollOnGrab()
208
+ } else if (this.hasScrollOnGrab) {
209
+ this.scrollOnGrab.destroyEvents()
210
+ this.scrollOnGrab.element.style.cursor = 'auto'
211
+ this.scrollOnGrab = {}
212
+ }
213
+ },
214
+
215
+ setObserver () {
216
+ this.elementToObserve = this.getTableElement()
217
+ this.resizeObserver = new ResizeObserver(entries => {
218
+ entries.forEach(() => this.handleScrollOnGrab())
219
+ })
220
+
221
+ this.resizeObserver.observe(this.elementToObserve)
222
+ },
223
+
224
+ destroyObserver () {
225
+ this.resizeObserver.unobserve(this.elementToObserve)
135
226
  }
136
227
  }
137
228
  }
138
229
  </script>
139
230
 
140
231
  <style lang="scss">
141
- .qas-table {
232
+ .qas-table-generator {
142
233
  .q-table th {
143
234
  font-weight: bold;
144
235
  }
@@ -0,0 +1,46 @@
1
+ type: component
2
+
3
+ meta:
4
+ desc: Componente para criação de tabela dinâmica usando o `QTable` do quasar.
5
+
6
+ props:
7
+ columns:
8
+ desc: Colunas que vão ter na tabela.
9
+ default: []
10
+ type: Array
11
+
12
+ fields:
13
+ desc: Lista de field contendo informações necessárias para a criação da tabela.
14
+ default: {}
15
+ type: Object
16
+ examples: ["{ email: { name: 'email', type: 'email', label: 'E-mail' } }"]
17
+
18
+ results:
19
+ desc: Lista com resultados para serem mostrados na tabela.
20
+ default: {}
21
+ type: Object
22
+ examples: ["{ name: { dense: true, onClick: () => alert('Estou sendo clicado') } }"]
23
+
24
+ row-key:
25
+ desc: Propriedade de cada linha que define a chave única de cada linha.
26
+ default: name
27
+ type: String
28
+
29
+ empty-result-text:
30
+ desc: Quando uma célula da tabela está vazia, esta prop define qual será o valor padrão.
31
+ default: '-'
32
+ type: String
33
+
34
+ use-scroll-on-grab:
35
+ desc: Adiciona scroll pelo mouse ao arrastar tabela em todas as telas (Celular, Desktop).
36
+ default: true
37
+ type: Boolean
38
+
39
+ slots:
40
+ body:
41
+ desc: Acesso direto dentro do `tbody`.
42
+ scope:
43
+ row:
44
+ desc: Payload da linha da tabela.
45
+ default: {}
46
+ type: Object
@@ -1,9 +1,9 @@
1
1
  <template>
2
- <q-tabs v-model="currentTab" v-bind="$attrs" :active-color="activeColor" :class="bgColorClass" :indicator-color="indicatorColor" outside-arrows v-on="$listeners">
2
+ <q-tabs v-model="model" :active-color="activeColor" :indicator-color="indicatorColor" outside-arrows>
3
3
  <slot v-for="(tab, key) in formattedTabs" :item="tab" :name="`tab-${tab.value}`">
4
- <q-tab :key="key" v-bind="tab" :class="colorClass" :label="tab.label" :name="key">
4
+ <q-tab :key="key" v-bind="tab" :class="tabClass" :label="tab.label" :name="key">
5
5
  <slot :item="tab" :name="`tab-after-${tab.value}`">
6
- <q-badge v-if="counters[key]" color="negative" floating :label="counters[key]" />
6
+ <q-badge v-if="counters[key]" :label="counters[key]" v-bind="defaultCounterProps" />
7
7
  </slot>
8
8
  </q-tab>
9
9
  </slot>
@@ -14,20 +14,17 @@
14
14
  import { extend } from 'quasar'
15
15
 
16
16
  export default {
17
+ name: 'QasTabsGenerator',
18
+
17
19
  props: {
18
20
  activeColor: {
19
21
  default: 'primary',
20
22
  type: String
21
23
  },
22
24
 
23
- bgColorClass: {
24
- default: 'transparent',
25
- type: String
26
- },
27
-
28
- colorClass: {
29
- default: 'text-primary',
30
- type: String
25
+ counterProps: {
26
+ default: () => ({}),
27
+ type: Object
31
28
  },
32
29
 
33
30
  counters: {
@@ -40,26 +37,31 @@ export default {
40
37
  type: String
41
38
  },
42
39
 
43
- tabs: {
44
- default: () => ({}),
45
- type: Object,
46
- required: true
40
+ modelValue: {
41
+ default: '',
42
+ type: String
47
43
  },
48
44
 
49
- value: {
50
- default: '',
45
+ tabClass: {
46
+ default: 'text-primary',
51
47
  type: String
48
+ },
49
+
50
+ tabs: {
51
+ default: () => ({}),
52
+ required: true,
53
+ type: Object
52
54
  }
53
55
  },
54
56
 
55
- computed: {
56
- currentTab: {
57
- get () {
58
- return this.value
59
- },
57
+ emits: ['update:modelValue'],
60
58
 
61
- set (value) {
62
- this.$emit('input', value)
59
+ computed: {
60
+ defaultCounterProps () {
61
+ return {
62
+ color: 'negative',
63
+ floating: true,
64
+ ...this.counterProps
63
65
  }
64
66
  },
65
67
 
@@ -68,11 +70,21 @@ export default {
68
70
 
69
71
  for (const key in tabs) {
70
72
  if (typeof tabs[key] === 'string') {
71
- tabs[key] = { label: tabs[key] }
73
+ tabs[key] = { label: tabs[key], value: key }
72
74
  }
73
75
  }
74
76
 
75
77
  return tabs
78
+ },
79
+
80
+ model: {
81
+ get () {
82
+ return this.modelValue
83
+ },
84
+
85
+ set (value) {
86
+ this.$emit('update:modelValue', value)
87
+ }
76
88
  }
77
89
  }
78
90
  }