@bildvitta/quasar-ui-asteroid 3.5.0-beta.0 → 3.5.0-beta.10

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 (51) hide show
  1. package/package.json +2 -2
  2. package/src/components/actions-menu/QasActionsMenu.vue +86 -37
  3. package/src/components/actions-menu/QasActionsMenu.yml +6 -6
  4. package/src/components/alert/QasAlert.vue +2 -5
  5. package/src/components/app-bar/QasAppBar.vue +31 -115
  6. package/src/components/app-bar/QasAppBar.yml +11 -9
  7. package/src/components/app-menu/QasAppMenu.vue +138 -59
  8. package/src/components/app-menu/QasAppMenu.yml +35 -0
  9. package/src/components/app-user/QasAppUser.vue +141 -0
  10. package/src/components/app-user/QasAppUser.yml +29 -0
  11. package/src/components/avatar/QasAvatar.vue +25 -30
  12. package/src/components/avatar/QasAvatar.yml +4 -4
  13. package/src/components/box/QasBox.vue +1 -1
  14. package/src/components/card/QasCard.vue +1 -1
  15. package/src/components/copy/QasCopy.vue +1 -1
  16. package/src/components/delete/QasDelete.vue +12 -5
  17. package/src/components/field/QasField.vue +18 -1
  18. package/src/components/filters/QasFilters.vue +93 -33
  19. package/src/components/filters/QasFilters.yml +0 -7
  20. package/src/components/form-generator/QasFormGenerator.yml +1 -1
  21. package/src/components/form-view/QasFormView.vue +15 -10
  22. package/src/components/form-view/QasFormView.yml +2 -2
  23. package/src/components/grid-generator/QasGridGenerator.yml +1 -1
  24. package/src/components/layout/QasLayout.vue +25 -24
  25. package/src/components/layout/QasLayout.yml +3 -0
  26. package/src/components/list-view/QasListView.vue +67 -8
  27. package/src/components/list-view/QasListView.yml +4 -0
  28. package/src/components/nested-fields/QasNestedFields.vue +101 -41
  29. package/src/components/nested-fields/QasNestedFields.yml +30 -10
  30. package/src/components/page-header/QasPageHeader.vue +2 -11
  31. package/src/components/pagination/QasPagination.vue +27 -0
  32. package/src/components/pagination/QasPagination.yml +4 -0
  33. package/src/components/select/QasSelect.vue +10 -4
  34. package/src/components/select/QasSelect.yml +5 -0
  35. package/src/components/table-generator/QasTableGenerator.vue +10 -2
  36. package/src/components/table-generator/QasTableGenerator.yml +14 -0
  37. package/src/components/text-truncate/QasTextTruncate.vue +1 -1
  38. package/src/components/transfer/QasTransfer.vue +1 -1
  39. package/src/css/components/item.scss +4 -0
  40. package/src/css/plugins/index.scss +1 -0
  41. package/src/css/plugins/notify.scss +41 -0
  42. package/src/css/utils/border.scss +1 -0
  43. package/src/css/variables/spacing.scss +5 -5
  44. package/src/helpers/set-scroll-on-grab.js +13 -4
  45. package/src/index.scss +8 -2
  46. package/src/mixins/generator.js +1 -1
  47. package/src/mixins/view.js +5 -2
  48. package/src/plugins/notify-error/NotifyError.js +7 -5
  49. package/src/plugins/notify-success/NotifySuccess.js +7 -5
  50. package/src/shared/notify-config.js +7 -0
  51. package/src/vue-plugin.js +6 -0
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bildvitta/quasar-ui-asteroid",
3
3
  "description": "Asteroid",
4
- "version": "3.5.0-beta.0",
4
+ "version": "3.5.0-beta.10",
5
5
  "author": "Bild & Vitta <systemteam@bild.com.br>",
6
6
  "license": "MIT",
7
7
  "main": "dist/asteroid.cjs.min.js",
@@ -64,4 +64,4 @@
64
64
  "tags": "dist/vetur/asteroid-tags.json",
65
65
  "attributes": "dist/vetur/asteroid-attributes.json"
66
66
  }
67
- }
67
+ }
@@ -1,49 +1,45 @@
1
1
  <template>
2
- <qas-btn class="qas-actions-menu" color="primary" :icon="icon" :label="label" outline padding="md" :use-label-on-small-screen="false">
3
- <q-menu class="qas-actions-menu__menu">
4
- <q-list class="qas-actions-menu__list" separator>
5
- <slot v-for="(item, key) in list" :item="item" :name="key">
6
- <q-item :key="key" class="text-primary" clickable v-bind="item.props" @click="onClick(item)">
7
- <q-item-section>
8
- <div class="flex items-center justify-center q-gutter-x-md">
9
- <q-icon :name="item.icon" size="sm" />
2
+ <div v-if="hasActions">
3
+ <component :is="component.is" flat v-bind="component.props" :use-label-on-small-screen="useLabelOnSmallScreen" @click="onClick()">
4
+ <q-menu v-if="hasMoreThanOneAction" auto-close class="q-py-xs">
5
+ <q-list>
6
+ <slot v-for="(item, key) in actions" :item="item" :name="key">
7
+ <component :is="getComponent(key)" v-bind="item.props" :key="key" clickable @click="onClick(item)">
8
+ <q-item-section avatar>
9
+ <q-icon :name="item.icon" />
10
+ </q-item-section>
11
+
12
+ <q-item-section>
10
13
  <div>{{ item.label }}</div>
11
- </div>
12
- </q-item-section>
13
- </q-item>
14
- </slot>
15
-
16
- <qas-delete v-if="hasDelete" v-bind="deleteProps" class="text-negative" clickable tag="q-item">
17
- <q-item-section>
18
- <div class="flex items-center justify-center q-gutter-x-sm">
19
- <q-icon :name="deleteIcon" size="sm" />
20
- <div>{{ deleteLabel }}</div>
21
- </div>
22
- </q-item-section>
23
- </qas-delete>
24
- </q-list>
25
- </q-menu>
26
- </qas-btn>
14
+ </q-item-section>
15
+ </component>
16
+ </slot>
17
+ </q-list>
18
+ </q-menu>
19
+ </component>
20
+ </div>
27
21
  </template>
28
22
 
29
23
  <script>
30
24
  import QasBtn from '../btn/QasBtn.vue'
25
+ import QasDelete from '../delete/QasDelete.vue'
31
26
 
32
27
  export default {
33
28
  name: 'QasActionsMenu',
34
29
 
35
30
  components: {
36
- QasBtn
31
+ QasBtn,
32
+ QasDelete
37
33
  },
38
34
 
39
35
  props: {
40
36
  icon: {
41
- default: 'o_settings',
37
+ default: 'o_more_vert',
42
38
  type: String
43
39
  },
44
40
 
45
41
  label: {
46
- default: 'Configurações',
42
+ default: 'Opções',
47
43
  type: String
48
44
  },
49
45
 
@@ -65,17 +61,79 @@ export default {
65
61
  deleteProps: {
66
62
  default: () => ({}),
67
63
  type: Object
64
+ },
65
+
66
+ useLabelOnSmallScreen: {
67
+ default: true,
68
+ type: Boolean
68
69
  }
69
70
  },
70
71
 
71
72
  computed: {
73
+ actions () {
74
+ return {
75
+ ...this.list,
76
+ ...(this.hasDelete && {
77
+ delete: {
78
+ icon: this.deleteIcon,
79
+ label: this.deleteLabel,
80
+ props: {
81
+ ...this.deleteProps,
82
+ tag: this.hasMoreThanOneAction ? 'q-item' : 'qas-btn'
83
+ }
84
+ }
85
+ })
86
+ }
87
+ },
88
+
89
+ component () {
90
+ const props = {}
91
+
92
+ if (this.hasMoreThanOneAction) {
93
+ props.label = 'Opções'
94
+ props.iconRight = this.icon
95
+ props.textColor = 'dark'
96
+ } else {
97
+ props.icon = this.actions[this.firstItemKey]?.icon
98
+ props.label = this.actions[this.firstItemKey]?.label
99
+ props.color = 'primary'
100
+ }
101
+
102
+ this.hasDelete && Object.assign(props, this.deleteProps)
103
+
104
+ return {
105
+ is: this.hasMoreThanOneAction || !this.hasDelete ? 'qas-btn' : 'qas-delete',
106
+ props
107
+ }
108
+ },
109
+
110
+ firstItemKey () {
111
+ return Object.keys(this.actions)?.[0]
112
+ },
113
+
114
+ hasActions () {
115
+ return !!Object.keys(this.actions).length
116
+ },
117
+
72
118
  hasDelete () {
73
119
  return !!Object.keys(this.deleteProps).length
120
+ },
121
+
122
+ hasMoreThanOneAction () {
123
+ return Object.keys(this.list || {}).length + Number(this.hasDelete) > 1
74
124
  }
75
125
  },
76
126
 
77
127
  methods: {
78
- onClick (item) {
128
+ getComponent (key) {
129
+ return key === 'delete' ? 'qas-delete' : 'q-item'
130
+ },
131
+
132
+ onClick (item = {}) {
133
+ if (!this.hasMoreThanOneAction) {
134
+ item = this.actions[this.firstItemKey]
135
+ }
136
+
79
137
  if (typeof item.handler === 'function') {
80
138
  const { handler, ...filtered } = item
81
139
  item.handler(filtered)
@@ -84,12 +142,3 @@ export default {
84
142
  }
85
143
  }
86
144
  </script>
87
-
88
- <style lang="scss">
89
- .qas-actions-menu {
90
- &__list {
91
- width: 265px;
92
- z-index: 1;
93
- }
94
- }
95
- </style>
@@ -21,15 +21,10 @@ props:
21
21
 
22
22
  icon:
23
23
  desc: Ícone do botão.
24
- default: o_settings
24
+ default: o_more_vert
25
25
  type: String
26
26
  examples: [start, end, between, around, center]
27
27
 
28
- label:
29
- desc: Rotulo do botão.
30
- default: Configurações
31
- type: String
32
-
33
28
  list:
34
29
  desc: Lista de items que vão ser criados dentro do menu de ações.
35
30
  default: '{}'
@@ -44,6 +39,11 @@ props:
44
39
  }"
45
40
  ]
46
41
 
42
+ use-label-on-small-screen:
43
+ desc: Esconde o rótulo (label) do botão quando o tamanho da tela for pequeno (esta propriedade só funciona se o "rotulo") for passado via propriedade "label".
44
+ default: true
45
+ type: Boolean
46
+
47
47
  slots:
48
48
  '[nome-da-chave]':
49
49
  desc: 'Slot dinâmico gerado a partir das chaves dentro do objeto da prop "list"'
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div v-if="model" class="q-pa-lg qas-alert relative-position rounded-borders" :class="classes">
2
+ <div v-if="model" class="bg-white q-pa-lg qas-alert relative-position rounded-borders" :class="classes">
3
3
  <qas-btn class="absolute-top-right q-mr-md q-mt-sm" :color="color" dense flat icon="o_close" rounded @click="close" />
4
4
 
5
5
  <div class="q-gutter-md q-mr-lg">
@@ -58,10 +58,7 @@ export default {
58
58
 
59
59
  computed: {
60
60
  classes () {
61
- return {
62
- [`text-${this.color}`]: true,
63
- [`bg-${this.color}-contrast`]: ['primary', 'secondary'].includes(this.color)
64
- }
61
+ return `text-${this.color}`
65
62
  }
66
63
  },
67
64
 
@@ -1,72 +1,32 @@
1
1
  <template>
2
- <q-header class="bg-white qas-app-bar shadow-2" height-hint="70">
3
- <q-toolbar class="q-px-md qas-app-bar__toolbar" color="bg-white">
4
- <q-ajax-bar color="white" position="top" size="2px" />
5
-
6
- <qas-btn v-if="$qas.screen.untilLarge" color="grey-7" dense flat icon="o_menu" round @click="toggleMenuDrawer" />
7
-
8
- <q-toolbar-title class="flex" :class="toolbarTitleClass">
9
- <div class="cursor-pointer" @click="goToRoot">
10
- <img v-if="brand" :alt="title" class="q-mr-sm qas-app-bar__brand" :src="brand">
11
- <span v-if="showTitle" class="text-bold text-grey-9 text-subtitle1 text-uppercase">{{ title }}</span>
12
- <q-badge v-if="hasDevelopmentBadge" align="middle" class="q-ml-sm" color="negative" :label="developmentBadgeLabel" />
13
- </div>
2
+ <q-header class="qas-app-bar shadow-2" height-hint="56">
3
+ <q-toolbar class="bg-white qas-app-bar__toolbar text-grey-9">
4
+ <qas-btn color="grey-7" dense flat icon="o_menu" round @click="toggleMenuDrawer" />
5
+
6
+ <q-toolbar-title>
7
+ <router-link class="flex items-center no-wrap text-no-decoration" :to="rootRoute">
8
+ <img v-if="brand" :alt="title" class="qas-app-bar__brand" :src="brand">
9
+ <span v-else class="ellipsis text-bold text-primary">{{ title }}</span>
10
+ <q-badge v-if="hasDevelopmentBadge" class="q-ml-sm" color="red" :label="developmentBadgeLabel" />
11
+ </router-link>
14
12
  </q-toolbar-title>
15
13
 
16
- <div v-if="hasNotifications" class="q-mr-md">
17
- <qas-btn class="q-mr-md" dense icon="o_notifications" round unelevated>
18
- <q-badge v-if="notifications" color="red" floating>{{ notifications.count }}</q-badge>
19
- </qas-btn>
20
- </div>
21
-
22
- <div class="items-center no-wrap q-gutter-md row">
23
- <slot name="tools" />
24
-
25
- <div v-if="hasUser" class="cursor-pointer items-center no-wrap qas-app-bar__user-content rounded-borders row text-grey-9" :title="userName">
26
- <qas-avatar color="white" dark :image="user.photo" rounded size="42px" text-color="primary" :title="userName" />
27
-
28
- <div class="q-ml-md q-pr-sm qas-app-bar__user-data qs-lh-lg">
29
- <div class="ellipsis q-mb-xs qas-app-bar__user-name">{{ userName }}</div>
30
- <div class="ellipsis qas-app-bar__user-email">{{ user.email }}</div>
31
- </div>
32
-
33
- <q-menu anchor="bottom end" class="shadow-2 text-grey-9" max-height="400px" :offset="[0, 5]" self="top end">
34
- <div class="qas-app-bar__user-menu">
35
- <div class="q-pa-lg text-center">
36
- <button class="unset" @click="goToProfile">
37
- <qas-avatar :image="user.photo" size="145px" :title="userName" />
38
- </button>
39
-
40
- <div class="ellipsis q-mt-lg qas-app-bar__user-name qs-lh-sm">{{ userName }}</div>
41
- <div class="ellipsis q-mt-xs">{{ user.email }}</div>
42
-
43
- <div class="q-mt-sm">
44
- <qas-btn flat icon="o_edit" label="Editar" :to="user.to" />
45
- </div>
46
-
47
- <div class="q-mt-sm">
48
- <qas-btn v-close-popup class="q-px-lg q-py-xs" dense icon="o_exit_to_app" label="Sair" outline @click="signOut" />
49
- </div>
50
-
51
- <slot name="user" :user="user" />
52
- </div>
53
- </div>
54
- </q-menu>
55
- </div>
56
- </div>
14
+ <slot v-if="hasUser" name="user" :user="user">
15
+ <qas-app-user :menu-props="appUserMenuProps" :user="user" @sign-out="signOut" />
16
+ </slot>
57
17
  </q-toolbar>
58
18
  </q-header>
59
19
  </template>
60
20
 
61
21
  <script>
62
- import QasAvatar from '../avatar/QasAvatar.vue'
22
+ import QasAppUser from '../app-user/QasAppUser.vue'
63
23
  import QasBtn from '../btn/QasBtn.vue'
64
24
 
65
25
  export default {
66
26
  name: 'QasAppBar',
67
27
 
68
28
  components: {
69
- QasAvatar,
29
+ QasAppUser,
70
30
  QasBtn
71
31
  },
72
32
 
@@ -76,16 +36,16 @@ export default {
76
36
  type: String
77
37
  },
78
38
 
79
- title: {
80
- type: String,
81
- default: ''
82
- },
83
-
84
39
  notifications: {
85
40
  default: () => ({}),
86
41
  type: Object
87
42
  },
88
43
 
44
+ title: {
45
+ required: true,
46
+ type: String
47
+ },
48
+
89
49
  user: {
90
50
  default: () => ({}),
91
51
  require: true,
@@ -102,6 +62,14 @@ export default {
102
62
  },
103
63
 
104
64
  computed: {
65
+ appUserMenuProps () {
66
+ return {
67
+ anchor: 'bottom end',
68
+ offset: [0, 5],
69
+ self: 'top end'
70
+ }
71
+ },
72
+
105
73
  developmentBadgeLabel () {
106
74
  const hosts = {
107
75
  localhost: 'Local',
@@ -123,40 +91,16 @@ export default {
123
91
  return !!this.developmentBadgeLabel
124
92
  },
125
93
 
126
- hasNotifications () {
127
- return !!Object.keys(this.notifications).length
128
- },
129
-
130
- showTitle () {
131
- return this.title && !this.brand
132
- },
133
-
134
94
  hasUser () {
135
95
  return !!Object.keys(this.user).length
136
96
  },
137
97
 
138
- userName () {
139
- return this.user.name || this.user.givenName
140
- },
141
-
142
- toolbarTitleClass () {
143
- return !this.$qas.screen.untilLarge && 'q-pl-none'
98
+ rootRoute () {
99
+ return this.$router.hasRoute('Root') ? { name: 'Root' } : { path: '/' }
144
100
  }
145
101
  },
146
102
 
147
103
  methods: {
148
- goToProfile () {
149
- return this.$router.push(this.user.to)
150
- },
151
-
152
- goToRoot () {
153
- const hasRoot = this.$router.hasRoute('Root')
154
-
155
- this.$router.push({
156
- ...(hasRoot ? { name: 'Root' } : { path: '/' })
157
- })
158
- },
159
-
160
104
  signOut () {
161
105
  this.$emit('sign-out')
162
106
  },
@@ -171,39 +115,11 @@ export default {
171
115
  <style lang="scss">
172
116
  .qas-app-bar {
173
117
  &__toolbar {
174
- height: 70px;
118
+ height: 56px;
175
119
  }
176
120
 
177
121
  &__brand {
178
122
  height: 24px;
179
- position: relative;
180
- top: 4px;
181
- }
182
-
183
- &__user-content {
184
- width: 230px;
185
- }
186
-
187
- &__user-data {
188
- max-width: 180px;
189
- }
190
-
191
- &__user-name {
192
- font-weight: 600;
193
- }
194
-
195
- &__user-menu {
196
- width: 260px;
197
- }
198
-
199
- @media (max-width: $breakpoint-xs) {
200
- &__user-content {
201
- width: auto;
202
- }
203
-
204
- &__user-data {
205
- display: none;
206
- }
207
123
  }
208
124
  }
209
125
  </style>
@@ -1,20 +1,25 @@
1
1
  type: component
2
2
 
3
3
  meta:
4
- desc: Cria um seção para alertar sobre um conteúdo.
4
+ desc: Gerencia a barra superior da aplicação
5
5
 
6
6
  props:
7
+ brand:
8
+ desc: Path do logotipo.
9
+ type: String
10
+
7
11
  notifications:
8
- desc: Ícone de notificação que fica ao lado do menu de usuário.
12
+ desc: Lista com as notificações do usuário.
9
13
  type: Object
10
14
  default: {}
11
15
 
12
16
  title:
13
- desc: Título do header, normalmente usado como título da aplicação.
17
+ desc: Título da aplicação.
18
+ required: true
14
19
  type: String
15
20
 
16
21
  user:
17
- desc: Informações de usuário para ser usado no menu.
22
+ desc: Informações do usuário.
18
23
  type: Object
19
24
  default: {}
20
25
  examples: [
@@ -29,16 +34,13 @@ props:
29
34
 
30
35
  slots:
31
36
  user:
32
- desc: Slot para acessar o menu de usuário
37
+ desc: Slot para acessar o menu de usuário.
33
38
  scope:
34
39
  user:
35
- desc: Informações de usuário para ser usado no menu, valor vai depender da prop "user".
40
+ desc: Informações do usuário, recebe o objeto "user".
36
41
  type: Object
37
42
  default: {}
38
43
 
39
- tools:
40
- desc: Slot para acessar o header após o elemento de notificações.
41
-
42
44
  events:
43
45
  '@sign-out -> function()':
44
46
  desc: Dispara quando o botão de "sair" é clicado.