@bildvitta/quasar-ui-asteroid 2.12.2 → 2.14.0

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.
@@ -12,8 +12,8 @@
12
12
  <script>
13
13
  import QasCheckboxGroup from '../checkbox-group/QasCheckboxGroup.vue'
14
14
  import QasDateTimeInput from '../date-time-input/QasDateTimeInput.vue'
15
- import QasDecimalInput from '../decimal-input/QasDecimalInput.vue'
16
15
  import QasInput from '../input/QasInput.vue'
16
+ import QasNumericInput from '../numeric-input/QasNumericInput.vue'
17
17
  import QasPasswordInput from '../password-input/QasPasswordInput.vue'
18
18
  import QasUploader from '../uploader/QasUploader.vue'
19
19
  import QasSignatureUploader from '../signature-uploader/QasSignatureUploader.vue'
@@ -30,8 +30,8 @@ export default {
30
30
  components: {
31
31
  QasCheckboxGroup,
32
32
  QasDateTimeInput,
33
- QasDecimalInput,
34
33
  QasInput,
34
+ QasNumericInput,
35
35
  QasPasswordInput,
36
36
  QasUploader,
37
37
  QasSignatureUploader
@@ -96,8 +96,8 @@ export default {
96
96
  gmt
97
97
  }
98
98
 
99
+ const numericInput = { is: 'qas-numeric-input', ...input }
99
100
  const datetimeInput = { is: 'qas-date-time-input', gmt, ...input }
100
- const decimalInput = { is: 'qas-decimal-input', comma: true, fillMask: '0', reverseFillMask: true, ...input }
101
101
 
102
102
  // It'll generate a list of acceptable files extensions.
103
103
  const accept = extensions && extensions.length ? extensions.map(extension => `.${extension}`).join(',') : ''
@@ -121,9 +121,9 @@ export default {
121
121
  email: { is: 'q-input', type, ...input },
122
122
  password: { is: 'qas-password-input', type, pattern, hideStrengthChecker: !pattern, ...input },
123
123
 
124
- decimal: { ...decimalInput },
125
- money: { ...decimalInput, prefix: 'R$' },
126
- percent: { ...decimalInput, suffix: '%' },
124
+ decimal: { ...numericInput, mode: 'decimal' },
125
+ money: { ...numericInput, mode: 'money' },
126
+ percent: { ...numericInput, mode: 'percent' },
127
127
 
128
128
  date: { ...datetimeInput, dateOnly: true },
129
129
  datetime: { ...datetimeInput },
@@ -41,7 +41,7 @@
41
41
  </div>
42
42
 
43
43
  <div v-if="badges && hasActiveFilters" class="q-mt-md">
44
- <q-chip v-for="(filterItem, key) in activeFilters" :key="key" color="grey-4" dense removable size="md" text-color="grey-8" @remove="removeFilter(filterItem)">{{ filterItem.label }} = "{{ handleChipValue(filterItem.value) }}"</q-chip>
44
+ <q-chip v-for="(filterItem, key) in activeFilters" :key="key" color="grey-4" dense removable size="md" text-color="grey-8" @remove="removeFilter(filterItem)">{{ filterItem.label }} = "{{ getChipValue(filterItem.value) }}"</q-chip>
45
45
  </div>
46
46
 
47
47
  <slot :context="context" :filter="filter" :filters="activeFilters" :removeFilter="removeFilter" />
@@ -122,7 +122,7 @@ export default {
122
122
  const hasField = fields.includes(key)
123
123
 
124
124
  if (hasField) {
125
- const value = humanize(this.fields[key], filters[key])
125
+ const value = humanize(this.fields[key], this.normalizeValues(filters[key], this.fields[key]?.multiple))
126
126
  const { label, name } = this.fields[key]
127
127
 
128
128
  activeFilters[key] = { label, name, value }
@@ -0,0 +1,104 @@
1
+ import QasLayout from './QasLayout.vue'
2
+
3
+ export default {
4
+ component: QasLayout,
5
+ title: 'Components/Layout',
6
+
7
+ parameters: {
8
+ docs: {
9
+ description: {
10
+ component: 'Implementation of [QLayout](https://quasar.dev/layout/layout#introduction) with [QasAppMenu](http://localhost:6006/?path=/docs/components-appmenu--default) and [QasAppBar](http://localhost:6006/?path=/docs/components-appbar--default).'
11
+ }
12
+ }
13
+ },
14
+
15
+ argTypes: {
16
+ // Props
17
+ appMenuProps: {
18
+ description: '[QasAppMenu props](http://localhost:6006/?path=/docs/components-appmenu--default).'
19
+ },
20
+
21
+ appBarProps: {
22
+ description: '[QasAppBar props](http://localhost:6006/?path=/docs/components-appbar--default).'
23
+ },
24
+
25
+ appMenuEvents: {
26
+ description: '[QasAppMenu events](http://localhost:6006/?path=/docs/components-appmenu--default).'
27
+ },
28
+
29
+ appBarEvents: {
30
+ description: '[QasAppBar events](http://localhost:6006/?path=/docs/components-appbar--default).'
31
+ },
32
+
33
+ value: {
34
+ description: 'Model value for toggle drawer.'
35
+ },
36
+
37
+ // Slots
38
+ 'app-bar': {
39
+ description: 'header slot.'
40
+ },
41
+
42
+ 'app-menu': {
43
+ description: 'left side menu.'
44
+ },
45
+
46
+ default: {
47
+ description: 'page container with router-view.'
48
+ },
49
+
50
+ // events
51
+ input: {
52
+ description: 'input model event for toggle drawer.'
53
+ }
54
+ }
55
+ }
56
+
57
+ const Template = (args, { argTypes }) => ({
58
+ components: { QasLayout },
59
+ props: Object.keys(argTypes),
60
+
61
+ template: '<qas-layout v-bind="$props" />'
62
+ })
63
+
64
+ export const Default = Template.bind({})
65
+
66
+ Default.args = {
67
+ appMenuProps: {
68
+ items: [
69
+ {
70
+ label: 'Dialog',
71
+ icon: 'o_home',
72
+ to: { path: '/dialog-form' }
73
+ },
74
+
75
+ {
76
+ label: 'Teste expansivo',
77
+ icon: 'o_edit'
78
+ }
79
+ ],
80
+
81
+ modules: [
82
+ {
83
+ label: 'Modulo de teste',
84
+ value: 'test',
85
+ path: 'http://localhost:8080'
86
+ },
87
+ {
88
+ label: 'Segundo modulo de teste',
89
+ value: 'test-2',
90
+ path: 'https://google.com'
91
+ }
92
+ ]
93
+ },
94
+
95
+ appBarProps: {
96
+ isAuth: true,
97
+ title: 'Some title',
98
+ user: {
99
+ photo: 'https://www.abc.net.au/cm/lb/6367016/data/alan2c-see-the-person-data.jpg',
100
+ name: 'Eduardo Lima',
101
+ email: 'eduardolima@gmail.com'
102
+ }
103
+ }
104
+ }
@@ -0,0 +1,89 @@
1
+ <template>
2
+ <q-layout view="hHh Lpr lFf">
3
+ <slot name="app-bar">
4
+ <qas-app-bar v-bind="appBarProps" v-on="appBarEvents" @toggle-menu="toggleMenuDrawer" />
5
+ </slot>
6
+
7
+ <slot name="app-menu">
8
+ <qas-app-menu v-model="menuDrawer" v-bind="defaultAppMenuProps" v-on="appMenuEvents" />
9
+ </slot>
10
+
11
+ <slot>
12
+ <q-page-container>
13
+ <router-view />
14
+ </q-page-container>
15
+ </slot>
16
+ </q-layout>
17
+ </template>
18
+
19
+ <script>
20
+ import QasAppMenu from '../app-menu/QasAppMenu'
21
+ import QasAppBar from '../app-bar/QasAppBar'
22
+
23
+ export default {
24
+ name: 'QasLayout',
25
+
26
+ components: {
27
+ QasAppMenu,
28
+ QasAppBar
29
+ },
30
+
31
+ props: {
32
+ value: {
33
+ default: true,
34
+ type: Boolean
35
+ },
36
+
37
+ appBarEvents: {
38
+ default: () => ({}),
39
+ type: Object
40
+ },
41
+
42
+ appBarProps: {
43
+ default: () => ({}),
44
+ type: Object
45
+ },
46
+
47
+ appMenuProps: {
48
+ default: () => ({}),
49
+ type: Object
50
+ },
51
+
52
+ appMenuEvents: {
53
+ default: () => ({}),
54
+ type: Object
55
+ }
56
+ },
57
+
58
+ data () {
59
+ return {
60
+ menuDrawer: true
61
+ }
62
+ },
63
+
64
+ computed: {
65
+ defaultAppMenuProps () {
66
+ return {
67
+ ...this.appMenuProps,
68
+ title: this.appBarProps?.title
69
+ }
70
+ }
71
+ },
72
+
73
+ watch: {
74
+ value: {
75
+ handler (value) {
76
+ this.menuDrawer = value
77
+ },
78
+ immediate: true
79
+ }
80
+ },
81
+
82
+ methods: {
83
+ toggleMenuDrawer () {
84
+ this.menuDrawer = !this.menuDrawer
85
+ this.$emit('input', this.menuDrawer)
86
+ }
87
+ }
88
+ }
89
+ </script>
@@ -1,25 +1,41 @@
1
- import QasDecimalInput from './QasDecimalInput.vue'
1
+ import QasNumericInput from './QasNumericInput.vue'
2
2
 
3
3
  export default {
4
- component: QasDecimalInput,
5
- title: 'Components/DecimalInput',
4
+ component: QasNumericInput,
5
+ title: 'Components/NumericInput',
6
6
 
7
7
  parameters: {
8
8
  docs: {
9
9
  description: {
10
- component: 'Extends [QInput](https://quasar.dev/vue-components/input), but with decimal mask.'
10
+ component: 'Extends [QInput](https://quasar.dev/vue-components/input) with [AutoNumeric](http://autonumeric.org/) plugin.'
11
11
  }
12
12
  }
13
13
  },
14
14
 
15
15
  argTypes: {
16
16
  // Props
17
- comma: {
18
- description: 'Use comma instead of period as decimal separator.'
17
+ allowNegative: {
18
+ description: 'Allow negative values.'
19
19
  },
20
20
 
21
- places: {
22
- description: 'Number of decimal places.'
21
+ allowPositive: {
22
+ description: 'Allow positive values.'
23
+ },
24
+
25
+ autonumericProps: {
26
+ description: '(Autonumeric)[http://autonumeric.org/guide] options.'
27
+ },
28
+
29
+ decimalPlaces: {
30
+ description: 'Decimal places.'
31
+ },
32
+
33
+ mode: {
34
+ description: 'Component mode like integer, decimal, percent, and money.'
35
+ },
36
+
37
+ preset: {
38
+ description: 'Property to configure default nationality of currency.'
23
39
  },
24
40
 
25
41
  value: {
@@ -35,16 +51,12 @@ export default {
35
51
  summary: '{}'
36
52
  }
37
53
  }
38
- },
39
-
40
- mount: {
41
- table: { disable: true }
42
54
  }
43
55
  }
44
56
  }
45
57
 
46
58
  const Template = (args, { argTypes }) => ({
47
- components: { QasDecimalInput },
59
+ components: { QasNumericInput },
48
60
  props: Object.keys(argTypes),
49
61
 
50
62
  data () {
@@ -55,7 +67,7 @@ const Template = (args, { argTypes }) => ({
55
67
 
56
68
  template:
57
69
  `<div>
58
- <qas-decimal-input v-bind="$props" v-model="model" />
70
+ <qas-numeric-input v-bind="$props" v-model="model" />
59
71
  <pre>{{ model }}</pre>
60
72
  </div>`
61
73
  })
@@ -64,19 +76,17 @@ export const Default = Template.bind({})
64
76
 
65
77
  Default.parameters = {
66
78
  docs: {
67
- source: { code: '<qas-decimal-input v-model="model" />' }
79
+ source: { code: '<qas-numeric-input v-model="model" />' }
68
80
  }
69
81
  }
70
82
 
71
83
  export const BrazilianReal = Template.bind({})
72
84
 
73
85
  BrazilianReal.args = {
74
- comma: true,
75
- prefix: 'R$'
76
86
  }
77
87
 
78
88
  BrazilianReal.parameters = {
79
89
  docs: {
80
- source: { code: '<qas-decimal-input v-model="model" comma prefix="R$" />' }
90
+ source: { code: '<qas-numeric-input v-model="model" />' }
81
91
  }
82
92
  }
@@ -0,0 +1,122 @@
1
+ <template>
2
+ <div>
3
+ <q-field v-model="model" v-bind="$attrs">
4
+ <template #control="{ emitValue, floatingLabel, id, value: modelValue }">
5
+ <input v-show="floatingLabel" :id="id" ref="input" class="q-field__input" :model-value="modelValue" @input="emitValue($event.target.value)">
6
+ </template>
7
+ </q-field>
8
+ </div>
9
+ </template>
10
+
11
+ <script>
12
+ const defaultModes = {
13
+ integer: ['commaDecimalCharDotSeparator', 'integer'],
14
+ decimal: 'commaDecimalCharDotSeparator',
15
+ percent: 'percentageEU2dec',
16
+ money: 'Brazilian'
17
+ }
18
+
19
+ export default {
20
+ props: {
21
+ allowNegative: {
22
+ default: true,
23
+ type: Boolean
24
+ },
25
+
26
+ allowPositive: {
27
+ default: true,
28
+ type: Boolean
29
+ },
30
+
31
+ autonumericProps: {
32
+ default: () => ({}),
33
+ type: Object
34
+ },
35
+
36
+ decimalPlaces: {
37
+ default: 2,
38
+ type: Number
39
+ },
40
+
41
+ mode: {
42
+ default: 'integer',
43
+ type: String,
44
+ validator: value => ['integer', 'decimal', 'percent', 'money'].includes(value)
45
+ },
46
+
47
+ preset: {
48
+ default: false,
49
+ type: [Boolean, String]
50
+ },
51
+
52
+ value: {
53
+ default: '',
54
+ validator (value) {
55
+ return typeof value === 'number' || typeof value === 'string' || value === '' || value === null
56
+ }
57
+ }
58
+ },
59
+
60
+ data () {
61
+ return {
62
+ autoNumeric: null
63
+ }
64
+ },
65
+
66
+ computed: {
67
+ defaultMode () {
68
+ return defaultModes[this.mode]
69
+ },
70
+
71
+ model: {
72
+ get () {
73
+ return this.value
74
+ },
75
+
76
+ set () {
77
+ this.$emit('input', this.autoNumeric.getNumber())
78
+ }
79
+ }
80
+ },
81
+
82
+ async created () {
83
+ const AutoNumeric = (await import('autonumeric')).default
84
+ const autoNumericPredefinedOptions = AutoNumeric.getPredefinedOptions()
85
+
86
+ let option = this.preset || this.defaultMode
87
+
88
+ if (!Array.isArray(option)) {
89
+ option = [option]
90
+ }
91
+
92
+ const options = {}
93
+
94
+ for (const value of option) {
95
+ Object.assign(options, autoNumericPredefinedOptions[value])
96
+ }
97
+
98
+ if (!this.allowNegative) {
99
+ options.minimumValue = 0
100
+ }
101
+
102
+ if (!this.allowPositive) {
103
+ options.maximumValue = 0
104
+ }
105
+
106
+ if (this.mode !== 'integer') {
107
+ options.decimalPlaces = this.decimalPlaces
108
+ }
109
+
110
+ Object.assign(options, this.autonumericProps)
111
+
112
+ this.$nextTick(() => {
113
+ this.$refs.input.value = this.value
114
+ this.autoNumeric = new AutoNumeric(this.$refs.input, options)
115
+ })
116
+ },
117
+
118
+ beforeDestroy () {
119
+ this.autoNumeric.remove()
120
+ }
121
+ }
122
+ </script>
@@ -26,6 +26,8 @@
26
26
 
27
27
  <script>
28
28
  export default {
29
+ name: 'QasSelect',
30
+
29
31
  props: {
30
32
  fuseOptions: {
31
33
  default: () => ({}),
@@ -96,6 +96,8 @@ function handleMasks (value) {
96
96
 
97
97
  // Labels
98
98
  function humanize (field = {}, value) {
99
+ if (!value) return value
100
+
99
101
  const mappedMasks = handleMasks(value)
100
102
 
101
103
  if (mappedMasks[field.mask]) {
@@ -1,8 +1,9 @@
1
1
  import base64ToBlob from './base64ToBlob.js'
2
+ import constructObject from './constructObject.js'
2
3
  import filterObject from './filter-object.js'
3
4
  import greatestCommonDivisor from './greatestCommonDivisor.js'
5
+ import isLocalDevelopment from './isLocalDevelopment.js'
4
6
  import { history, handleHistory } from './historyHandler.js'
5
- import constructObject from './constructObject.js'
6
7
 
7
8
  import {
8
9
  asset,
@@ -53,5 +54,6 @@ export {
53
54
 
54
55
  base64ToBlob,
55
56
  filterObject,
56
- greatestCommonDivisor
57
+ greatestCommonDivisor,
58
+ isLocalDevelopment
57
59
  }
@@ -0,0 +1,3 @@
1
+ export default function () {
2
+ return ['localhost', '127.0.0.1'].includes(window.location.hostname)
3
+ }
package/src/index.js CHANGED
@@ -14,7 +14,6 @@ import QasCheckboxGroup from './components/checkbox-group/QasCheckboxGroup'
14
14
  import QasCopy from './components/copy/QasCopy'
15
15
  import QasDateTimeInput from './components/date-time-input/QasDateTimeInput'
16
16
  import QasDebugger from './components/debugger/QasDebugger'
17
- import QasDecimalInput from './components/decimal-input/QasDecimalInput'
18
17
  import QasDelete from './components/delete/QasDelete'
19
18
  import QasDialog from './components/dialog/QasDialog'
20
19
  import QasDialogRouter from './components/dialog-router/QasDialogRouter'
@@ -26,10 +25,12 @@ import QasGallery from './components/gallery/QasGallery'
26
25
  import QasGridGenerator from './components/grid-generator/QasGridGenerator'
27
26
  import QasInput from './components/input/QasInput'
28
27
  import QasLabel from './components/label/QasLabel'
28
+ import QasLayout from './components/layout/QasLayout'
29
29
  import QasListItems from './components/list-items/QasListItems'
30
30
  import QasListView from './components/list-view/QasListView'
31
31
  import QasMap from './components/map/QasMap'
32
32
  import QasNestedFields from './components/nested-fields/QasNestedFields'
33
+ import QasNumericInput from './components/numeric-input/QasNumericInput'
33
34
  import QasPageHeader from './components/page-header/QasPageHeader'
34
35
  import QasPasswordInput from './components/password-input/QasPasswordInput'
35
36
  import QasPasswordStrengthChecker from './components/password-strength-checker/QasPasswordStrengthChecker'
@@ -87,7 +88,6 @@ export {
87
88
  QasCopy,
88
89
  QasDateTimeInput,
89
90
  QasDebugger,
90
- QasDecimalInput,
91
91
  QasDelete,
92
92
  QasDialog,
93
93
  QasDialogRouter,
@@ -99,10 +99,12 @@ export {
99
99
  QasGridGenerator,
100
100
  QasInput,
101
101
  QasLabel,
102
+ QasLayout,
102
103
  QasListItems,
103
104
  QasListView,
104
105
  QasMap,
105
106
  QasNestedFields,
107
+ QasNumericInput,
106
108
  QasPageHeader,
107
109
  QasPasswordInput,
108
110
  QasPasswordStrengthChecker,
@@ -146,7 +148,6 @@ export default {
146
148
  QasCopy,
147
149
  QasDateTimeInput,
148
150
  QasDebugger,
149
- QasDecimalInput,
150
151
  QasDelete,
151
152
  QasDialog,
152
153
  QasDialogRouter,
@@ -158,10 +159,12 @@ export default {
158
159
  QasGridGenerator,
159
160
  QasInput,
160
161
  QasLabel,
162
+ QasLayout,
161
163
  QasListItems,
162
164
  QasListView,
163
165
  QasMap,
164
166
  QasNestedFields,
167
+ QasNumericInput,
165
168
  QasPageHeader,
166
169
  QasPasswordInput,
167
170
  QasPasswordStrengthChecker,
@@ -204,7 +207,6 @@ export default {
204
207
  Vue.component('QasCopy', QasCopy)
205
208
  Vue.component('QasDateTimeInput', QasDateTimeInput)
206
209
  Vue.component('QasDebugger', QasDebugger)
207
- Vue.component('QasDecimalInput', QasDecimalInput)
208
210
  Vue.component('QasDelete', QasDelete)
209
211
  Vue.component('QasDialog', QasDialog)
210
212
  Vue.component('QasDialogRouter', QasDialogRouter)
@@ -216,10 +218,12 @@ export default {
216
218
  Vue.component('QasGridGenerator', QasGridGenerator)
217
219
  Vue.component('QasInput', QasInput)
218
220
  Vue.component('QasLabel', QasLabel)
221
+ Vue.component('QasLayout', QasLayout)
219
222
  Vue.component('QasListItems', QasListItems)
220
223
  Vue.component('QasListView', QasListView)
221
224
  Vue.component('QasMap', QasMap)
222
225
  Vue.component('QasNestedFields', QasNestedFields)
226
+ Vue.component('QasNumericInput', QasNumericInput)
223
227
  Vue.component('QasPageHeader', QasPageHeader)
224
228
  Vue.component('QasPasswordInput', QasPasswordInput)
225
229
  Vue.component('QasPasswordStrengthChecker', QasPasswordStrengthChecker)
package/src/index.scss CHANGED
@@ -9,7 +9,7 @@ $secondary-contrast: var(--q-color-secondary-contrast);
9
9
 
10
10
  // Asteroid variables
11
11
  :root {
12
- --qas-background-color: #fcfcff;
12
+ --qas-background-color: #f5f5f5;
13
13
  --qas-generic-border-radius: 8px;
14
14
  }
15
15
 
@@ -1,90 +0,0 @@
1
- <template>
2
- <q-input v-bind="$attrs" fill-mask="0" :mask="mask" reverse-fill-mask :value="inputValue" v-on="events" @input="input" />
3
- </template>
4
-
5
- <script>
6
- export default {
7
- props: {
8
- comma: {
9
- default: false,
10
- type: Boolean
11
- },
12
-
13
- places: {
14
- default: 2,
15
- type: Number
16
- },
17
-
18
- value: {
19
- default: 0,
20
- required: true,
21
- type: Number
22
- }
23
- },
24
-
25
- data () {
26
- return {
27
- inputValue: this.toMask(this.value),
28
- inputedValue: 0
29
- }
30
- },
31
-
32
- computed: {
33
- events () {
34
- const { input, ...events } = this.$listeners
35
- return events
36
- },
37
-
38
- mask () {
39
- return `#${this.separator}${'#'.repeat(this.places)}`
40
- },
41
-
42
- separator () {
43
- return this.comma ? ',' : '.'
44
- }
45
- },
46
-
47
- watch: {
48
- value (current) {
49
- this.inputValue = this.toMask(current)
50
- }
51
- },
52
-
53
- mounted () {
54
- this.$emit('mount', this)
55
- },
56
-
57
- methods: {
58
- blur () {
59
- this.$el.blur()
60
- },
61
-
62
- focus () {
63
- this.$el.focus()
64
- },
65
-
66
- input (value) {
67
- this.inputedValue = this.toDecimal(value)
68
- this.$emit('input', this.inputedValue)
69
- },
70
-
71
- toDecimal (value) {
72
- if (this.comma) {
73
- value = value.replace(',', '.')
74
- }
75
-
76
- return parseFloat(value)
77
- },
78
-
79
- toMask (value) {
80
- value = value.toFixed(this.places)
81
-
82
- if (this.comma) {
83
- value = value.replace('.', ',')
84
- }
85
-
86
- return value
87
- }
88
- }
89
- }
90
- </script>