@bildvitta/quasar-ui-asteroid 3.0.0-beta.2 → 3.0.0-beta.20

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 (173) hide show
  1. package/dist/api/QasActionsMenu.json +15 -15
  2. package/dist/api/QasAppBar.json +4 -8
  3. package/dist/api/QasAppMenu.json +11 -7
  4. package/dist/api/QasBtn.json +8 -4
  5. package/dist/api/QasCard.json +17 -13
  6. package/dist/api/QasCheckboxGroup.json +8 -8
  7. package/dist/api/QasCopy.json +4 -4
  8. package/dist/api/QasDateTimeInput.json +16 -16
  9. package/dist/api/QasDelete.json +17 -17
  10. package/dist/api/QasDialog.json +24 -20
  11. package/dist/api/QasFilters.json +14 -14
  12. package/dist/api/QasFormGenerator.json +57 -26
  13. package/dist/api/QasFormView.json +115 -87
  14. package/dist/api/QasGallery.json +4 -4
  15. package/dist/api/QasGridGenerator.json +40 -39
  16. package/dist/api/QasInput.json +13 -13
  17. package/dist/api/QasListItems.json +18 -17
  18. package/dist/api/QasListView.json +67 -53
  19. package/dist/api/QasNestedFields.json +45 -35
  20. package/dist/api/QasNumericInput.json +31 -12
  21. package/dist/api/QasPageHeader.json +7 -7
  22. package/dist/api/QasPasswordInput.json +13 -13
  23. package/dist/api/QasPasswordStrengthChecker.json +12 -12
  24. package/dist/api/QasProfile.json +5 -5
  25. package/dist/api/QasResizer.json +11 -11
  26. package/dist/api/QasSearchBox.json +90 -8
  27. package/dist/api/QasSelect.json +92 -25
  28. package/dist/api/QasSelectList.json +16 -14
  29. package/dist/api/QasSignaturePad.json +1 -1
  30. package/dist/api/QasSignatureUploader.json +9 -9
  31. package/dist/api/QasSingleView.json +52 -43
  32. package/dist/api/QasSortable.json +20 -20
  33. package/dist/api/QasTableGenerator.json +5 -5
  34. package/dist/api/QasTabsGenerator.json +5 -2
  35. package/dist/api/QasTransfer.json +9 -9
  36. package/dist/api/QasUploader.json +22 -17
  37. package/dist/asteroid.cjs.css +1 -1
  38. package/dist/asteroid.cjs.js +3904 -3102
  39. package/dist/asteroid.cjs.min.js +2 -2
  40. package/dist/asteroid.esm.css +1 -1
  41. package/dist/asteroid.esm.js +3908 -3106
  42. package/dist/asteroid.esm.min.js +2 -2
  43. package/dist/asteroid.umd.css +1 -1
  44. package/dist/asteroid.umd.js +3907 -3106
  45. package/dist/asteroid.umd.min.js +2 -2
  46. package/dist/vetur/asteroid-attributes.json +387 -303
  47. package/dist/vetur/asteroid-tags.json +129 -108
  48. package/package.json +1 -1
  49. package/src/assets/gear.svg +27 -0
  50. package/src/components/actions/QasActions.vue +1 -5
  51. package/src/components/actions-menu/QasActionsMenu.vue +4 -10
  52. package/src/components/actions-menu/QasActionsMenu.yml +15 -15
  53. package/src/components/app-bar/QasAppBar.vue +18 -14
  54. package/src/components/app-bar/QasAppBar.yml +4 -8
  55. package/src/components/app-menu/QasAppMenu.vue +8 -7
  56. package/src/components/app-menu/QasAppMenu.yml +11 -7
  57. package/src/components/avatar/QasAvatar.vue +0 -4
  58. package/src/components/box/QasBox.vue +1 -1
  59. package/src/components/btn/QasBtn.vue +11 -15
  60. package/src/components/btn/QasBtn.yml +7 -3
  61. package/src/components/card/QasCard.vue +18 -9
  62. package/src/components/card/QasCard.yml +17 -13
  63. package/src/components/checkbox-group/QasCheckboxGroup.yml +9 -8
  64. package/src/components/copy/QasCopy.vue +1 -1
  65. package/src/components/copy/QasCopy.yml +4 -3
  66. package/src/components/date-time-input/QasDateTimeInput.vue +39 -41
  67. package/src/components/date-time-input/QasDateTimeInput.yml +16 -16
  68. package/src/components/delete/QasDelete.vue +15 -1
  69. package/src/components/delete/QasDelete.yml +15 -15
  70. package/src/components/dialog/QasDialog.vue +28 -9
  71. package/src/components/dialog/QasDialog.yml +22 -18
  72. package/src/components/dialog-router/QasDialogRouter.vue +1 -1
  73. package/src/components/field/QasField.vue +15 -14
  74. package/src/components/filters/QasFilters.vue +30 -13
  75. package/src/components/filters/QasFilters.yml +14 -14
  76. package/src/components/form-generator/QasFormGenerator.vue +87 -12
  77. package/src/components/form-generator/QasFormGenerator.yml +32 -18
  78. package/src/components/form-view/QasFormView.vue +142 -60
  79. package/src/components/form-view/QasFormView.yml +91 -67
  80. package/src/components/gallery/QasGallery.vue +4 -8
  81. package/src/components/gallery/QasGallery.yml +4 -4
  82. package/src/components/grid-generator/QasGridGenerator.vue +23 -7
  83. package/src/components/grid-generator/QasGridGenerator.yml +29 -27
  84. package/src/components/input/QasInput.vue +37 -21
  85. package/src/components/input/QasInput.yml +13 -13
  86. package/src/components/layout/QasLayout.vue +4 -0
  87. package/src/components/list-items/QasListItems.vue +16 -24
  88. package/src/components/list-items/QasListItems.yml +14 -15
  89. package/src/components/list-view/QasListView.vue +48 -20
  90. package/src/components/list-view/QasListView.yml +58 -46
  91. package/src/components/map/QasMap.vue +5 -5
  92. package/src/components/nested-fields/QasNestedFields.vue +29 -21
  93. package/src/components/nested-fields/QasNestedFields.yml +35 -28
  94. package/src/components/numeric-input/QasNumericInput.vue +45 -27
  95. package/src/components/numeric-input/QasNumericInput.yml +26 -12
  96. package/src/components/page-header/QasPageHeader.vue +14 -11
  97. package/src/components/page-header/QasPageHeader.yml +4 -4
  98. package/src/components/password-input/QasPasswordInput.vue +17 -16
  99. package/src/components/password-input/QasPasswordInput.yml +11 -11
  100. package/src/components/password-strength-checker/QasPasswordStrengthChecker.yml +10 -10
  101. package/src/components/profile/QasProfile.vue +3 -6
  102. package/src/components/profile/QasProfile.yml +5 -5
  103. package/src/components/resizer/QasResizer.vue +1 -1
  104. package/src/components/resizer/QasResizer.yml +6 -5
  105. package/src/components/search-box/QasSearchBox.vue +138 -42
  106. package/src/components/search-box/QasSearchBox.yml +74 -7
  107. package/src/components/select/QasSelect.vue +63 -53
  108. package/src/components/select/QasSelect.yml +68 -17
  109. package/src/components/select-list/QasSelectList.vue +13 -32
  110. package/src/components/select-list/QasSelectList.yml +13 -14
  111. package/src/components/signature-pad/QasSignaturePad.vue +1 -1
  112. package/src/components/signature-pad/QasSignaturePad.yml +1 -1
  113. package/src/components/signature-uploader/QasSignatureUploader.vue +13 -14
  114. package/src/components/signature-uploader/QasSignatureUploader.yml +9 -9
  115. package/src/components/single-view/QasSingleView.vue +24 -8
  116. package/src/components/single-view/QasSingleView.yml +45 -38
  117. package/src/components/sortable/QasSortable.yml +17 -17
  118. package/src/components/table-generator/QasTableGenerator.vue +14 -6
  119. package/src/components/table-generator/QasTableGenerator.yml +5 -5
  120. package/src/components/tabs-generator/QasTabsGenerator.vue +2 -2
  121. package/src/components/tabs-generator/QasTabsGenerator.yml +2 -2
  122. package/src/components/text-truncate/QasTextTruncate.vue +2 -5
  123. package/src/components/transfer/QasTransfer.vue +5 -7
  124. package/src/components/transfer/QasTransfer.yml +9 -9
  125. package/src/components/uploader/QasUploader.vue +63 -16
  126. package/src/components/uploader/QasUploader.yml +17 -12
  127. package/src/composables/index.js +1 -1
  128. package/src/composables/{useHistory.js → use-history.js} +0 -0
  129. package/src/css/components/base.scss +3 -0
  130. package/src/css/components/field.scss +4 -0
  131. package/src/css/components/index.scss +4 -0
  132. package/src/css/components/radio.scss +3 -0
  133. package/src/css/components/tabs.scss +3 -0
  134. package/src/css/mixins/index.scss +1 -0
  135. package/src/css/{set-brand.scss → mixins/set-brand.scss} +0 -0
  136. package/src/css/{background.scss → utils/background.scss} +0 -0
  137. package/src/css/{border-radius.scss → utils/border-radius.scss} +0 -0
  138. package/src/css/{border.scss → utils/border.scss} +0 -0
  139. package/src/css/{container.scss → utils/container.scss} +0 -0
  140. package/src/css/{fonts.scss → utils/fonts.scss} +0 -0
  141. package/src/css/utils/index.scss +9 -0
  142. package/src/css/{line-height.scss → utils/line-height.scss} +0 -0
  143. package/src/css/{opacity.scss → utils/opacity.scss} +0 -0
  144. package/src/css/{text.scss → utils/text.scss} +0 -0
  145. package/src/css/{unset.scss → utils/unset.scss} +0 -0
  146. package/src/css/variables/button.scss +3 -0
  147. package/src/css/variables/index.scss +3 -0
  148. package/src/css/variables/shadow.scss +33 -0
  149. package/src/css/variables/typography.scss +139 -0
  150. package/src/helpers/camelize-fields-name.js +15 -0
  151. package/src/helpers/filters.js +2 -0
  152. package/src/helpers/get-normalized-options.js +20 -0
  153. package/src/helpers/handle-process.js +13 -0
  154. package/src/helpers/index.js +3 -0
  155. package/src/index.scss +11 -12
  156. package/src/mixins/generator.js +10 -2
  157. package/src/mixins/index.js +3 -3
  158. package/src/mixins/search-filter.js +227 -0
  159. package/src/mixins/view.js +35 -13
  160. package/src/pages/ErrorComponent.vue +56 -0
  161. package/src/pages/Forbidden.vue +21 -5
  162. package/src/pages/NotFound.vue +21 -5
  163. package/src/pages/ServerError.vue +25 -0
  164. package/src/pages/Unauthorized.vue +28 -0
  165. package/src/plugins/index.js +4 -2
  166. package/src/plugins/logger/Logger.js +44 -0
  167. package/src/plugins/logger/Logger.yml +9 -0
  168. package/src/plugins/screen/Screen.js +5 -0
  169. package/src/vue-plugin.js +6 -3
  170. package/src/assets/logo-modular.svg +0 -1
  171. package/src/css/design-system.scss +0 -18
  172. package/src/css/shadow.scss +0 -7
  173. package/src/mixins/screen.js +0 -34
@@ -39,6 +39,13 @@ props:
39
39
  default: undefined
40
40
  type: Number
41
41
 
42
+ model-value:
43
+ desc: Model do componente, caso seja múltiplo, retorna um array de string, senão somente uma string.
44
+ default: true
45
+ type: [Array, String]
46
+ examples: [v-model="value"]
47
+ model: true
48
+
42
49
  pica-resize-options:
43
50
  desc: Opções para a biblioteca "pica" que é responsável por fazer o redimensionamento antes do upload (https://github.com/nodeca/pica).
44
51
  type: Object
@@ -48,6 +55,11 @@ props:
48
55
  unsharpRadius: 0.6
49
56
  unsharpThreshold: 1
50
57
 
58
+ readonly:
59
+ desc: O componente não faz mais upload, apenas exibe.
60
+ default: true
61
+ type: Number
62
+
51
63
  size-limit:
52
64
  desc: Se o tamanho da imagem for menor ou igual ao passado nesta prop, não será feito um redimensionamento.
53
65
  default: 1280
@@ -58,24 +70,17 @@ props:
58
70
  default: true
59
71
  type: Number
60
72
 
61
- readonly:
62
- desc: O componente não faz mais upload, apenas exibe.
63
- default: true
64
- type: Number
65
-
66
- model-value:
67
- desc: Model do componente, caso seja múltiplo, retorna um array de string, senão somente uma string.
68
- default: true
69
- type: [Array, String]
70
- examples: [v-model="value"]
71
- model: true
72
-
73
73
  uploading:
74
74
  desc: Model que retorna se o componente está fazendo algum upload.
75
75
  type: Boolean
76
76
  examples: [v-model:uploading="isUploading"]
77
77
  model: true
78
78
 
79
+ useObjectModel:
80
+ desc: Controla se a model retornará um array de objetos.
81
+ type: Boolean
82
+ model: true
83
+
79
84
  slots:
80
85
  header:
81
86
  desc: Acesso ao header do <q-uploader />.
@@ -1 +1 @@
1
- export { default as useHistory } from './useHistory.js'
1
+ export { default as useHistory } from './use-history.js'
@@ -0,0 +1,3 @@
1
+ body {
2
+ background-color: $background-color;
3
+ }
@@ -0,0 +1,4 @@
1
+ .q-field--outlined .q-field__inner {
2
+ background-color: white;
3
+ border-radius: $generic-border-radius;
4
+ }
@@ -0,0 +1,4 @@
1
+ @import './base';
2
+ @import './field';
3
+ @import './radio';
4
+ @import './tabs';
@@ -0,0 +1,3 @@
1
+ .q-radio__inner::before {
2
+ color: $primary;
3
+ }
@@ -0,0 +1,3 @@
1
+ .q-tabs__arrow {
2
+ color: $primary;
3
+ }
@@ -0,0 +1 @@
1
+ @import './set-brand';
File without changes
File without changes
File without changes
@@ -0,0 +1,9 @@
1
+ @import './background';
2
+ @import './border';
3
+ @import './border-radius';
4
+ @import './container';
5
+ @import './fonts';
6
+ @import './line-height';
7
+ @import './opacity';
8
+ @import './text';
9
+ @import './unset';
File without changes
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ $button-font-size: 0.875rem;
2
+ $button-line-height: 1.5rem;
3
+ $button-font-weight: 500;
@@ -0,0 +1,3 @@
1
+ @import './button';
2
+ @import './shadow';
3
+ @import './typography';
@@ -0,0 +1,33 @@
1
+ $shadow-color: $accent;
2
+
3
+ $elevation-umbra: $shadow-color;
4
+ $elevation-penumbra: $shadow-color;
5
+ $elevation-ambient: $shadow-color;
6
+
7
+ // Embossed
8
+ $shadow-2: (
9
+ 0 1px 5px $elevation-umbra,
10
+ 0 2px 2px $elevation-penumbra,
11
+ 0 3px 1px -2px $elevation-ambient
12
+ );
13
+
14
+ // Shallow
15
+ $shadow-6: (
16
+ 0 3px 5px -1px $elevation-umbra,
17
+ 0 6px 10px $elevation-penumbra,
18
+ 0 1px 18px $elevation-ambient
19
+ );
20
+
21
+ // Overhead
22
+ $shadow-14: (
23
+ 0 7px 9px -4px $elevation-umbra,
24
+ 0 14px 21px 2px $elevation-penumbra,
25
+ 0 5px 26px 4px $elevation-ambient
26
+ );
27
+
28
+ // levite
29
+ $shadow-20: (
30
+ 0 10px 13px -6px $elevation-umbra,
31
+ 0 20px 31px 3px $elevation-penumbra,
32
+ 0 8px 38px 7px $elevation-ambient
33
+ );
@@ -0,0 +1,139 @@
1
+ // Definições seguindo:
2
+ // https://www.figma.com/file/JfDthOZoULYMlRJM2IQ8Oi/Design-System?node-id=665%3A163
3
+
4
+ // Quasar:
5
+ // https://github.com/quasarframework/quasar/blob/dev/ui/src/css/variables.sass
6
+ // https://github.com/quasarframework/quasar/blob/dev/ui/src/css/core/typography.sass
7
+
8
+ @use 'sass:map';
9
+
10
+ // headings
11
+ $h1: (
12
+ size: 6rem,
13
+ line-height: 6rem,
14
+ letter-spacing: 0,
15
+ weight: 800,
16
+ margin: 0
17
+ );
18
+
19
+ $h2: (
20
+ size: 3.75rem,
21
+ line-height: 3.75rem,
22
+ letter-spacing: 0,
23
+ weight: 700,
24
+ margin: 0
25
+ );
26
+
27
+ $h3: (
28
+ size: 3rem,
29
+ line-height: 2.5rem,
30
+ letter-spacing: 0,
31
+ weight: 600,
32
+ margin: 0
33
+ );
34
+
35
+ $h4: (
36
+ size: 2.125rem,
37
+ line-height: 2.5rem,
38
+ letter-spacing: 0,
39
+ weight: 800,
40
+ margin: 0
41
+ );
42
+
43
+ $h5: (
44
+ size: 1.5rem,
45
+ line-height: 2rem,
46
+ letter-spacing: 0,
47
+ weight: 700,
48
+ margin: 0
49
+ );
50
+
51
+ $h6: (
52
+ size: 1.25rem,
53
+ line-height: 2rem,
54
+ letter-spacing: 0,
55
+ weight: 600,
56
+ margin: 0
57
+ );
58
+
59
+ // subtitles
60
+ $subtitle1: (
61
+ size: 1rem,
62
+ line-height: 1.75rem,
63
+ letter-spacing: 0,
64
+ weight: 700
65
+ );
66
+
67
+ $subtitle2: (
68
+ size: 0.875rem,
69
+ line-height: 1.375rem,
70
+ letter-spacing: 0,
71
+ weight: 600
72
+ );
73
+
74
+ // body
75
+ $body1: (
76
+ size: 1rem,
77
+ line-height: 1.5rem,
78
+ letter-spacing: 0,
79
+ weight: 500
80
+ );
81
+
82
+ $body2: (
83
+ size: 0.875rem,
84
+ line-height: 1.25rem,
85
+ letter-spacing: 0,
86
+ weight: 400
87
+ );
88
+
89
+ // overline
90
+ $overline: (
91
+ size: 0.75rem,
92
+ line-height: 2rem,
93
+ letter-spacing: 0.25rem,
94
+ weight: 600
95
+ );
96
+
97
+ // caption
98
+ $caption: (
99
+ size: 0.75rem,
100
+ line-height: 1.25rem,
101
+ letter-spacing: 0,
102
+ weight: 700
103
+ );
104
+
105
+ $headings: (
106
+ 'h1': $h1,
107
+ 'h2': $h2,
108
+ 'h3': $h3,
109
+ 'h4': $h4,
110
+ 'h5': $h5,
111
+ 'h6': $h6,
112
+ 'subtitle1': $subtitle1,
113
+ 'subtitle2': $subtitle2,
114
+ 'body1': $body1,
115
+ 'body2': $body2,
116
+ 'overline': $overline,
117
+ 'caption': $caption
118
+ );
119
+
120
+ // adiciona tags com mesmo estilo do css
121
+ $h-tags: (
122
+ h1: map.get($headings, 'h1'),
123
+ h2: map.get($headings, 'h2'),
124
+ h3: map.get($headings, 'h3'),
125
+ h4: map.get($headings, 'h4'),
126
+ h5: map.get($headings, 'h5'),
127
+ h6: map.get($headings, 'h6')
128
+ );
129
+
130
+ // sobrescreve as tags do html para adicionar "margin"
131
+ @each $heading, $value in $h-tags {
132
+ #{$heading} {
133
+ font-size: map.get($value, 'size');
134
+ font-weight: map.get($value, 'weight');
135
+ letter-spacing: map.get($value, 'letter-spacing');
136
+ line-height: map.get($value, 'line-height');
137
+ margin: map.get($value, 'margin');
138
+ }
139
+ }
@@ -0,0 +1,15 @@
1
+ import { camelize } from 'humps'
2
+
3
+ export default function camelizeFieldsName (fields) {
4
+ for (const field in fields) {
5
+ const currentField = fields[field]
6
+
7
+ currentField.name = camelize(currentField.name)
8
+
9
+ if (Object.keys(currentField.children || {}).length) {
10
+ camelizeFieldsName(currentField.children)
11
+ }
12
+ }
13
+
14
+ return fields
15
+ }
@@ -114,6 +114,8 @@ function humanize (field = {}, value) {
114
114
  case 'time': return time(value)
115
115
  case 'radio': return selectLabel(field.options, value)
116
116
  case 'percent': return formatPercent(value)
117
+ case 'money': return money(value)
118
+ case 'decimal': return decimal(value)
117
119
  default: return value
118
120
  }
119
121
  }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * param {options: object[], label: string, value: string} object
3
+ *
4
+ * @example getNormalizedOptions({
5
+ * options: [{ name: 'Test 1', uuid: '1' }, { name: 'Test 2', uuid: '2' }],
6
+ * label: 'name'
7
+ * value: 'uuid'
8
+ * }) // retorna [{ label: 'Test 1', value: '1' }, { label: 'Test 2', value: '2' }]
9
+ */
10
+ export default ({ options = [], label, value }) => {
11
+ return options.map(option => {
12
+ const { [label]: labelKey, [value]: valueKey, ...payload } = option
13
+
14
+ return {
15
+ label: option[label],
16
+ value: option[value],
17
+ ...payload
18
+ }
19
+ })
20
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @param {function} processEnv função que retorna o process.env.
3
+ * @param {string} defaultValue valor default caso não exista a process.env
4
+ *
5
+ * @example handleProcess(() => process.env.MY_ENV, 'meu-valor-default')
6
+ */
7
+ export default (processEnv = () => {}, defaultValue) => {
8
+ try {
9
+ return processEnv() || defaultValue
10
+ } catch {
11
+ return defaultValue
12
+ }
13
+ }
@@ -8,6 +8,9 @@ export { default as filterObject } from './filter-object.js'
8
8
  export { default as getGreatestCommonDivisor } from './get-greatest-common-divisor.js'
9
9
  export { default as filterObjectToArray } from './filter-object-to-array.js'
10
10
  export { default as filterListByHandle } from './filter-list-by-handle.js'
11
+ export { default as camelizeFieldsName } from './camelize-fields-name.js'
12
+ export { default as getNormalizedOptions } from './get-normalized-options.js'
13
+ export { default as handleProcess } from './handle-process.js'
11
14
 
12
15
  export * from './filters.js'
13
16
  export * from './images.js'
package/src/index.scss CHANGED
@@ -5,6 +5,7 @@ $primary: var(--q-primary);
5
5
  $primary-contrast: var(--q-primary-contrast);
6
6
  $secondary: var(--q-secondary);
7
7
  $secondary-contrast: var(--q-secondary-contrast);
8
+ $accent: var(--q-accent);
8
9
 
9
10
  // Asteroid variables
10
11
  :root {
@@ -15,16 +16,14 @@ $secondary-contrast: var(--q-secondary-contrast);
15
16
  $background-color: var(--qas-background-color);
16
17
  $generic-border-radius: var(--qas-generic-border-radius);
17
18
 
18
- @import './css/background';
19
- @import './css/border';
20
- @import './css/border-radius';
21
- @import './css/container';
22
- @import './css/fonts';
23
- @import './css/line-height';
24
- @import './css/opacity';
25
- @import './css/shadow';
26
- @import './css/text';
27
- @import './css/unset';
19
+ // variables
20
+ @import './css/variables/index';
28
21
 
29
- // Design System
30
- @import './css/design-system';
22
+ // components
23
+ @import './css/components/index';
24
+
25
+ // utils
26
+ @import './css/utils/index';
27
+
28
+ // mixins
29
+ @import './css/mixins/index'
@@ -15,7 +15,9 @@ export default {
15
15
  gutter: {
16
16
  default: 'md',
17
17
  type: [String, Boolean],
18
- validator: value => ['xs', 'sm', 'md', 'lg', 'xl'].includes(value)
18
+ validator: value => {
19
+ return typeof value === 'boolean' || ['xs', 'sm', 'md', 'lg', 'xl'].includes(value)
20
+ }
19
21
  }
20
22
  },
21
23
 
@@ -64,7 +66,13 @@ export default {
64
66
  },
65
67
 
66
68
  mx_handleColumnsByIndex (index, isGridGenerator) {
67
- const fields = isGridGenerator ? this.fields : this.groupedFields.visible
69
+ const fields = isGridGenerator ? this.fields : {}
70
+
71
+ if (!isGridGenerator) {
72
+ for (const key in this.normalizedFields) {
73
+ Object.assign(fields, this.normalizedFields[key].fields.visible)
74
+ }
75
+ }
68
76
 
69
77
  if (!Array.isArray(fields)) {
70
78
  index = Object.keys(fields).findIndex(field => field === index)
@@ -1,15 +1,15 @@
1
1
  import contextMixin from './context.js'
2
2
  import formMixin from './form.js'
3
3
  import generatorMixin from './generator.js'
4
+ import searchFilterMixin from './search-filter.js'
4
5
  import passwordMixin from './password.js'
5
- import screenMixin from './screen.js'
6
6
  import viewMixin from './view.js'
7
7
 
8
8
  export {
9
9
  contextMixin,
10
10
  formMixin,
11
11
  generatorMixin,
12
+ searchFilterMixin,
12
13
  passwordMixin,
13
- viewMixin,
14
- screenMixin
14
+ viewMixin
15
15
  }
@@ -0,0 +1,227 @@
1
+ import { decamelize } from 'humps'
2
+ import { isEqual } from 'lodash'
3
+ import { getNormalizedOptions } from '../helpers'
4
+
5
+ export default {
6
+ props: {
7
+ entity: {
8
+ default: '',
9
+ type: String
10
+ },
11
+
12
+ lazyLoadingProps: {
13
+ default: () => ({}),
14
+ type: Object
15
+ },
16
+
17
+ name: {
18
+ default: '',
19
+ type: String
20
+ },
21
+
22
+ useLazyLoading: {
23
+ type: Boolean
24
+ },
25
+
26
+ fetching: {
27
+ type: Boolean
28
+ }
29
+ },
30
+
31
+ emits: [
32
+ 'update:modelValue',
33
+ 'update:fetching',
34
+ 'fetch-options-success',
35
+ 'fetch-options-error'
36
+ ],
37
+
38
+ data () {
39
+ return {
40
+ mx_filteredOptions: [],
41
+ mx_hasFetchError: false,
42
+ mx_isFetching: false,
43
+ mx_isScrolling: false,
44
+ mx_search: '',
45
+ mx_fetchCount: 0,
46
+ mx_pagination: {
47
+ page: 1,
48
+ lastPage: null,
49
+ hasCount: true,
50
+ hasNextPage: false
51
+ }
52
+ }
53
+ },
54
+
55
+ computed: {
56
+ mx_defaultLazyLoadingProps () {
57
+ const {
58
+ url,
59
+ params,
60
+ decamelizeFieldName
61
+ } = this.lazyLoadingProps
62
+
63
+ const defaultParams = { limit: 48 }
64
+
65
+ return {
66
+ url: url || '',
67
+ params: {
68
+ ...defaultParams,
69
+ ...params
70
+ },
71
+ decamelizeFieldName: decamelizeFieldName === undefined ? true : decamelizeFieldName
72
+ }
73
+ },
74
+
75
+ mx_hasFilteredOptions () {
76
+ return !!this.mx_filteredOptions.length
77
+ },
78
+
79
+ mx_isFilterByFuse () {
80
+ return !this.useLazyLoading
81
+ }
82
+ },
83
+
84
+ watch: {
85
+ lazyLoadingProps: {
86
+ handler (value, oldValue) {
87
+ if (isEqual(value, oldValue)) return
88
+
89
+ this.mx_filterOptionsByStore('')
90
+ this.$emit('update:modelValue', '')
91
+ }
92
+ }
93
+ },
94
+
95
+ methods: {
96
+ async mx_filterOptionsByStore (search) {
97
+ this.mx_resetFilter(search)
98
+ await this.mx_setFetchOptions()
99
+ },
100
+
101
+ mx_resetFilter (search) {
102
+ this.mx_filteredOptions = []
103
+ this.mx_search = search
104
+ this.mx_pagination = {
105
+ page: 1,
106
+ lastPage: null,
107
+ hasCount: true,
108
+ hasNextPage: false
109
+ }
110
+ },
111
+
112
+ async mx_onVirtualScroll ({ index, ref }) {
113
+ const lastIndex = this.mx_filteredOptions.length - 1
114
+
115
+ if (index === lastIndex && this.mx_canFetchOptions()) {
116
+ await this.mx_loadMoreOptions()
117
+
118
+ this.$nextTick(() => {
119
+ ref.reset()
120
+ ref.refresh(lastIndex)
121
+ })
122
+ }
123
+ },
124
+
125
+ async mx_loadMoreOptions () {
126
+ this.mx_isScrolling = true
127
+
128
+ const options = await this.mx_fetchOptions()
129
+ this.mx_filteredOptions.push(...options)
130
+
131
+ // this is to prevent the virtual-scroll event to be fired again
132
+ this.$nextTick(() => {
133
+ this.mx_isScrolling = false
134
+ })
135
+ },
136
+
137
+ async mx_fetchOptions () {
138
+ this.mx_fetchCount++
139
+
140
+ try {
141
+ if (!this.entity) this.mx_setMissingPropsMessage('entity')
142
+ if (!this.name) this.mx_setMissingPropsMessage('name')
143
+
144
+ this.mx_hasFetchError = false
145
+ this.mx_isFetching = true
146
+
147
+ this.$emit('update:fetching', true)
148
+
149
+ const { url, params, decamelizeFieldName } = this.mx_defaultLazyLoadingProps
150
+
151
+ const { data } = await this.$store.dispatch(`${this.entity}/fetchFieldOptions`, {
152
+ url,
153
+ field: decamelizeFieldName ? decamelize(this.name, { separator: '-' }) : this.name,
154
+ params: {
155
+ ...params,
156
+ search: this.mx_search,
157
+ offset: (this.mx_pagination.page - 1) * params.limit
158
+ }
159
+ })
160
+
161
+ const { results, count, hasNextPage } = data
162
+ const hasCount = count !== undefined
163
+
164
+ this.mx_pagination = {
165
+ page: this.mx_pagination.page + 1,
166
+ lastPage: hasCount ? Math.ceil(count / params.limit) : null,
167
+ hasCount,
168
+ hasNextPage
169
+ }
170
+
171
+ this.$emit('fetch-options-success', data)
172
+
173
+ return this.mx_handleOptions(results)
174
+ } catch (error) {
175
+ this.$qas.logger.group(
176
+ `Mixin: searchFilterMixin - mx_fetchOptions -> exceção da action ${this.entity}/fetchFieldOptions`,
177
+ [error],
178
+ { error: true }
179
+ )
180
+
181
+ this.mx_hasFetchError = true
182
+ this.$emit('fetch-options-error', error)
183
+
184
+ return []
185
+ } finally {
186
+ this.mx_isFetching = false
187
+ this.$emit('update:fetching', false)
188
+ }
189
+ },
190
+
191
+ async mx_setFetchOptions () {
192
+ this.mx_filteredOptions = await this.mx_fetchOptions()
193
+ },
194
+
195
+ mx_canFetchOptions () {
196
+ const { lastPage, page, hasCount, hasNextPage } = this.mx_pagination
197
+
198
+ const hasMorePages = hasCount ? lastPage && page <= lastPage : hasNextPage
199
+
200
+ return hasMorePages && !this.mx_isFetching && !this.mx_isScrolling && this.useLazyLoading
201
+ },
202
+
203
+ mx_handleOptions (options) {
204
+ if (this.labelKey && this.valueKey) {
205
+ return getNormalizedOptions({
206
+ options,
207
+ label: this.labelKey,
208
+ value: this.valueKey
209
+ })
210
+ }
211
+
212
+ return options
213
+ },
214
+
215
+ mx_getMissingPropsMessage (prop) {
216
+ return `A propriedade "${prop}" é obrigatória quando a propriedade "useLazyLoading" está ativa.`
217
+ },
218
+
219
+ mx_setMissingPropsMessage (prop) {
220
+ throw new Error(this.mx_getMissingPropsMessage(prop))
221
+ },
222
+
223
+ mx_getNormalizedFuseResults (results = []) {
224
+ return results.map(({ item }) => item)
225
+ }
226
+ }
227
+ }