@tagplus/components 1.2.17 → 2.0.1

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.
@@ -361,6 +361,7 @@ export default {
361
361
  */
362
362
  formatedValue () {
363
363
  let newVal = ''
364
+
364
365
  if (typeof this.value === 'boolean') {
365
366
  newVal = ''
366
367
  } else if (Array.isArray(this.value)) {
@@ -384,39 +385,47 @@ export default {
384
385
  const hasExistingOption = this.options
385
386
  .filter(option => !option.created)
386
387
  .some(option => option.currentLabel === this.query)
388
+
387
389
  return this.filterable && this.allowCreate && !hasExistingOption
388
390
  },
389
391
  // Monta a lista com ou sem "Cadastrar Novo Item"
390
392
  suggestionsList () {
391
393
  if (this.loading) return []
394
+
392
395
  // transformando em Array
393
396
  const list =
394
397
  typeof this.suggestions === 'object'
395
398
  ? Object.values(this.suggestions)
396
399
  : this.suggestions
400
+
397
401
  if (this.allowCreate) {
398
402
  const createdSuggestion = { created: true }
403
+
399
404
  createdSuggestion[this.valueKey] = this.query !== '' ? this.query : null
400
405
  createdSuggestion[this.labelKey] = ''
401
406
  list.push(createdSuggestion)
402
407
  }
408
+
403
409
  return list
404
410
  },
405
411
 
406
412
  emptyText () {
407
413
  if (this.loading) {
408
414
  return this.loadingText || this.t('el.select.loading')
409
- } else {
410
- if (this.remote && this.query === '' && this.options.length === 0) {
411
- return this.noDataText || this.$tpI18n.t('autosuggests.sem_dados')
412
- }
413
- if (this.filterable && this.query && this.options.length > 0 && this.filteredOptionsCount === 0) {
414
- return this.noMatchText || this.t('el.select.noMatch')
415
- }
416
- if (this.options.length === 0) {
417
- return this.noDataText || this.$tpI18n.t('autosuggests.sem_dados')
418
- }
419
415
  }
416
+
417
+ if (this.remote && this.query === '' && this.options.length === 0) {
418
+ return this.noDataText || this.$tpI18n.t('autosuggests.sem_dados')
419
+ }
420
+
421
+ if (this.filterable && this.query && this.options.length > 0 && this.filteredOptionsCount === 0) {
422
+ return this.noMatchText || this.t('el.select.noMatch')
423
+ }
424
+
425
+ if (this.options.length === 0) {
426
+ return this.noDataText || this.$tpI18n.t('autosuggests.sem_dados')
427
+ }
428
+
420
429
  return null
421
430
  }
422
431
  },
@@ -429,6 +438,7 @@ export default {
429
438
  this.selectedLabelsArray = []
430
439
  } else if (newValue.length > oldValue.length) {
431
440
  const novoItem = newValue.filter(x => !oldValue.includes(x))
441
+
432
442
  this.suggestionsList.forEach(item => {
433
443
  if (item[this.valueKey] === novoItem[0]) {
434
444
  this.selectedLabelsArray.push(item)
@@ -436,6 +446,7 @@ export default {
436
446
  })
437
447
  } else {
438
448
  const itemApagado = oldValue.filter(x => !newValue.includes(x))
449
+
439
450
  this.selectedLabelsArray.forEach((item, index) => {
440
451
  if (item.id === itemApagado[0]) {
441
452
  this.selectedLabelsArray.splice(index, 1)
@@ -465,13 +476,16 @@ export default {
465
476
  // Pega valor ignorando composition mode
466
477
  this.query = e.target.value
467
478
  }
479
+
468
480
  this.handleQueryChange(this.query)
469
481
  } else {
470
482
  let forceBusca = false
483
+
471
484
  // Quando clica fora enquanto está editando refaz a busca
472
485
  if (!this.query && !e.target.value) {
473
486
  forceBusca = true
474
487
  }
488
+
475
489
  this.query = e.target.value
476
490
  this.handleQueryChange(e.target.value, forceBusca)
477
491
  }
@@ -573,26 +587,32 @@ export default {
573
587
  const isUndefined =
574
588
  Object.prototype.toString.call(value).toLowerCase() ===
575
589
  '[object undefined]'
590
+
576
591
  for (let i = 0; i <= this.cachedOptions.length - 1; i++) {
577
592
  const cachedOption = this.cachedOptions[i]
578
593
  const isEqual = isObject
579
594
  ? getValueByPath(cachedOption.value, this.valueKey) ===
580
595
  getValueByPath(value, this.valueKey)
581
596
  : cachedOption.value === value
597
+
582
598
  if (isEqual) {
583
599
  option = cachedOption
584
600
  break
585
601
  }
586
602
  }
603
+
587
604
  if (option) return option
605
+
588
606
  const label = !isObject && !isNull && !isUndefined ? value : ''
589
607
  const newOption = {
590
608
  value,
591
609
  currentLabel: initialLabel || label
592
610
  }
611
+
593
612
  if (this.multiple) {
594
613
  newOption.hitState = false
595
614
  }
615
+
596
616
  return newOption
597
617
  },
598
618
  checkDefaultFirstOption () {
@@ -601,6 +621,7 @@ export default {
601
621
 
602
622
  for (let i = 0; i !== this.options.length; ++i) {
603
623
  const option = this.options[i]
624
+
604
625
  if (this.query) {
605
626
  // highlight first options that passes the filter
606
627
  if (!option.disabled && !option.groupDisabled && option.visible) {
@@ -628,10 +649,12 @@ export default {
628
649
  } else {
629
650
  this.visible = !this.visible
630
651
  }
652
+
631
653
  if (this.doRequest) {
632
654
  this.handleQueryChange(this.query, true)
633
655
  this.doRequest = false
634
656
  }
657
+
635
658
  (this.$refs.input || this.$refs.reference).focus()
636
659
  }
637
660
  },
@@ -648,9 +671,11 @@ export default {
648
671
  */
649
672
  handleQueryChange (val, forceBusca = false) {
650
673
  const _this6 = this
674
+
651
675
  // Correção aqui para forçar primeira request com createOnLoad = false
652
676
  // Não considera isOnComposition mais
653
677
  if (!this.doRequest && this.previousQuery === val) return
678
+
654
679
  if (!forceBusca) {
655
680
  if (
656
681
  this.previousQuery === null &&
@@ -658,17 +683,21 @@ export default {
658
683
  typeof this.remoteMethod === 'function')
659
684
  ) {
660
685
  this.previousQuery = val
686
+
661
687
  return
662
688
  }
663
689
  }
690
+
664
691
  this.previousQuery = val
665
- this.$nextTick(function () {
692
+ this.$nextTick(() => {
666
693
  if (_this6.visible) _this6.broadcast('ElSelectDropdown', 'updatePopper')
667
694
  })
668
695
  this.hoverIndex = -1
696
+
669
697
  if (this.multiple && this.filterable) {
670
- this.$nextTick(function () {
698
+ this.$nextTick(() => {
671
699
  const length = _this6.$refs.input.value.length * 15 + 20
700
+
672
701
  _this6.inputLength = _this6.collapseTags
673
702
  ? Math.min(50, length)
674
703
  : length
@@ -676,6 +705,7 @@ export default {
676
705
  _this6.resetInputHeight()
677
706
  })
678
707
  }
708
+
679
709
  if (this.remote && typeof this.remoteMethod === 'function') {
680
710
  this.hoverIndex = -1
681
711
  this.remoteMethod(val)
@@ -687,6 +717,7 @@ export default {
687
717
  this.broadcast('ElOption', 'queryChange', val)
688
718
  this.broadcast('ElOptionGroup', 'queryChange')
689
719
  }
720
+
690
721
  if (
691
722
  this.defaultFirstOption &&
692
723
  (this.filterable || this.remote) &&
@@ -796,7 +827,7 @@ input.el-input__inner {
796
827
  &::before {
797
828
  position: absolute;
798
829
  left: 7px;
799
- font-family: "element-icons";
830
+ font-family: element-icons;
800
831
  content: "\e6da";
801
832
  font-size: 15px;
802
833
  }
@@ -72,6 +72,7 @@ export default {
72
72
  if (this.circle && this.width) {
73
73
  return `${this.width}px`
74
74
  }
75
+
75
76
  return `${this.width}%`
76
77
  },
77
78
 
@@ -79,6 +80,7 @@ export default {
79
80
  if (this.circle && this.width) {
80
81
  return `${this.width}px`
81
82
  }
83
+
82
84
  return `${this.height}em`
83
85
  }
84
86
  }
@@ -98,6 +98,7 @@ export default {
98
98
  },
99
99
  prevStatus () {
100
100
  const prevStep = this.$parent.steps[this.index - 1]
101
+
101
102
  return prevStep ? prevStep.currentStatus : 'wait'
102
103
  },
103
104
  isCenter () {
@@ -111,6 +112,7 @@ export default {
111
112
  },
112
113
  isLast () {
113
114
  const parent = this.$parent
115
+
114
116
  return parent.steps[parent.steps.length - 1] === this
115
117
  },
116
118
  stepsCount () {
@@ -118,6 +120,7 @@ export default {
118
120
  },
119
121
  space () {
120
122
  const { isSimple, $parent: { space } } = this
123
+
121
124
  return isSimple ? '' : space
122
125
  },
123
126
  style: function () {
@@ -126,16 +129,19 @@ export default {
126
129
  const len = parent.steps.length
127
130
 
128
131
  const space = (typeof this.space === 'number'
129
- ? this.space + 'px'
132
+ ? `${this.space }px`
130
133
  : this.space
131
134
  ? this.space
132
- : 100 / (len - (this.isCenter ? 0 : 1)) + '%')
135
+ : `${100 / (len - (this.isCenter ? 0 : 1)) }%`)
136
+
133
137
  style.flexBasis = space
138
+
134
139
  if (this.isVertical) return style
140
+
135
141
  if (this.isLast) {
136
- style.maxWidth = 100 / this.stepsCount + '%'
142
+ style.maxWidth = `${100 / this.stepsCount }%`
137
143
  } else {
138
- style.marginRight = -this.$parent.stepOffset + 'px'
144
+ style.marginRight = `${-this.$parent.stepOffset }px`
139
145
  }
140
146
 
141
147
  return style
@@ -157,6 +163,7 @@ export default {
157
163
  beforeDestroy () {
158
164
  const steps = this.$parent.steps
159
165
  const index = steps.indexOf(this)
166
+
160
167
  if (index >= 0) {
161
168
  steps.splice(index, 1)
162
169
  }
@@ -167,6 +174,7 @@ export default {
167
174
  this.$watch('$parent.active', this.updateStatus, { immediate: true })
168
175
  this.$watch('$parent.processStatus', () => {
169
176
  const activeIndex = this.$parent.active
177
+
170
178
  this.updateStatus(activeIndex)
171
179
  }, { immediate: true })
172
180
  unwatch()
@@ -194,19 +202,20 @@ export default {
194
202
  let step = 100
195
203
  const style = {}
196
204
 
197
- style.transitionDelay = 150 * this.index + 'ms'
205
+ style.transitionDelay = `${150 * this.index }ms`
206
+
198
207
  // if (status === this.$parent.processStatus) {
199
208
  // step = this.currentStatus !== 'error' ? 0 : 0
200
209
  // } else
201
210
  if (status === 'wait') {
202
211
  step = 0
203
- style.transitionDelay = (-50 * this.index) + 'ms'
212
+ style.transitionDelay = `${-50 * this.index }ms`
204
213
  }
205
214
 
206
215
  style.borderWidth = step && !this.isSimple ? '1px' : 0
207
216
  this.$parent.direction === 'vertical'
208
- ? style.height = step + '%'
209
- : style.width = step + '%'
217
+ ? style.height = `${step }%`
218
+ : style.width = `${step }%`
210
219
 
211
220
  this.lineStyle = style
212
221
  }
@@ -56,15 +56,19 @@ export default {
56
56
 
57
57
  tptipclasses () {
58
58
  const classes = ['grid-content', 'pa-3']
59
+
59
60
  if (this.type === 'error') {
60
61
  classes.push('tp-tip-error')
61
62
  }
63
+
62
64
  if (this.type === 'warning') {
63
65
  classes.push('tp-tip-warning')
64
66
  }
67
+
65
68
  if (this.type === 'success') {
66
69
  classes.push('tp-tip-success')
67
70
  }
71
+
68
72
  return classes
69
73
  }
70
74
  }
@@ -30,9 +30,11 @@ export const getCurrentLocale = () => {
30
30
  */
31
31
  export const messages = function () {
32
32
  const i18n = i18nHandler.apply(this, arguments)
33
+
33
34
  if (i18n !== null && i18n !== undefined && i18n.messages) {
34
35
  return i18n.messages
35
36
  }
37
+
36
38
  return defaultLang
37
39
  }
38
40
 
@@ -44,6 +46,7 @@ export const messages = function () {
44
46
  */
45
47
  export const t = function (path, options) {
46
48
  const i18n = i18nHandler.apply(this, arguments)
49
+
47
50
  if (i18n !== null && i18n !== undefined && i18n.t) {
48
51
  return i18n.t(path)
49
52
  }
@@ -54,15 +57,21 @@ export const t = function (path, options) {
54
57
 
55
58
  for (let i = 0, j = array.length; i < j; i++) {
56
59
  const property = array[i]
60
+
57
61
  value = current[property]
62
+
58
63
  if (!value) {
59
64
  // eslint-disable-next-line
60
65
  console.warn(`[Tp-i18n] Fall back to translate '${path}'. Key does not exist on language messages. Assuming key as value`)
66
+
61
67
  return path
62
68
  }
69
+
63
70
  if (i === j - 1) return format(value, options)
71
+
64
72
  current = value
65
73
  }
74
+
66
75
  return ''
67
76
  }
68
77
 
package/src/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import ElementUI from 'element-ui'
2
- import './assets/scss/index.scss'
2
+ // import './assets/scss/index.scss'
3
3
  import * as components from './components'
4
4
 
5
5
  const install = function (Vue, opts = {}) {
@@ -13,6 +13,7 @@ const install = function (Vue, opts = {}) {
13
13
  // components
14
14
  for (const componentName in components) {
15
15
  const component = components[componentName]
16
+
16
17
  Vue.component(component.name, component)
17
18
  }
18
19
  }
@@ -22,6 +23,4 @@ if (typeof window !== 'undefined' && window.Vue) {
22
23
  }
23
24
 
24
25
  // TODO: Validar encapsulamento do ElementUI
25
- export default Object.assign({}, ElementUI, components, {
26
- install
27
- })
26
+ export default ({ ...ElementUI, ...components, install })
@@ -29,6 +29,7 @@ export default {
29
29
  input (evt) {
30
30
  this.formattedValue = formatMoney(evt, true, this.locale)
31
31
  const moneyFormatado = formatMoney(evt, false, this.locale)
32
+
32
33
  this.$emit('input', moneyFormatado)
33
34
  },
34
35
 
@@ -6,6 +6,7 @@ function format (input, opt = defaults) {
6
6
  if (typeof input === 'number') {
7
7
  input = input.toFixed(fixed(opt.precision))
8
8
  }
9
+
9
10
  const negative = input.indexOf('-') >= 0 ? '-' : ''
10
11
 
11
12
  const numbers = onlyNumbers(input)
@@ -13,14 +14,17 @@ function format (input, opt = defaults) {
13
14
  const parts = toStr(currency).split('.')
14
15
  let integer = parts[0]
15
16
  const decimal = parts[1]
17
+
16
18
  integer = addThousandSeparator(integer, opt.thousands)
19
+
17
20
  return opt.prefix + negative + joinIntegerAndDecimal(integer, decimal, opt.decimal) + opt.suffix
18
21
  }
19
22
 
20
23
  function unformat (input, precision = defaults.precision) {
21
- const negative = ('' + input).indexOf('-') >= 0 ? -1 : 1
24
+ const negative = (`${ input}`).indexOf('-') >= 0 ? -1 : 1
22
25
  const numbers = onlyNumbers(input)
23
26
  const currency = numbersToCurrency(numbers, precision)
27
+
24
28
  return currency * negative
25
29
  }
26
30
 
@@ -33,8 +37,8 @@ function unformat (input, precision = defaults.precision) {
33
37
  * @returns
34
38
  */
35
39
  function formatMoney (input, toString = false, locale = defaults) {
36
- debugger
37
- let inputString = ('' + input)
40
+ let inputString = (`${ input}`)
41
+
38
42
  // Impede de digitar . ou , porque o formatador já adiciona
39
43
  if ((inputString.slice(-1).match(/[.,]/))) {
40
44
  inputString = inputString.substring(0, inputString.length - 1)
@@ -49,17 +53,20 @@ function formatMoney (input, toString = false, locale = defaults) {
49
53
  const precision = locale.number.precision
50
54
  const numbers = onlyNumbers(input, precision)
51
55
  const currency = numbersToCurrency(numbers, precision)
56
+
52
57
  if (toString) {
53
- let num = negative === -1 ? '-' + currency : '' + currency
58
+ let num = negative === -1 ? `-${ currency}` : `${ currency}`
59
+
54
60
  if (locale?.number?.decimal) {
55
61
  const decimalChar = locale?.number?.decimal
62
+
56
63
  num = num.replaceAll(',', decimalChar).replaceAll('.', decimalChar)
57
64
  }
58
65
 
59
66
  return num
60
- } else {
61
- return currency * negative
62
67
  }
68
+
69
+ return currency * negative
63
70
  }
64
71
 
65
72
  function completeZeros (input, locale) {
@@ -67,6 +74,7 @@ function completeZeros (input, locale) {
67
74
  const decimal = locale?.number?.decimal || defaults.decimal
68
75
  let i = input.lastIndexOf('.')
69
76
  const j = input.lastIndexOf(',')
77
+
70
78
  i = i > j ? i : j
71
79
  const qntDecimais = i ? input.length - i - 1 : 0
72
80
 
@@ -74,8 +82,9 @@ function completeZeros (input, locale) {
74
82
  if (i === -1) {
75
83
  input = input + decimal + '0'.repeat(precision)
76
84
  } else if (i && qntDecimais < precision) {
77
- input = input + '0'.repeat(precision - qntDecimais)
85
+ input += '0'.repeat(precision - qntDecimais)
78
86
  }
87
+
79
88
  return input
80
89
  }
81
90
 
@@ -95,11 +104,12 @@ function between (min, n, max) {
95
104
  function numbersToCurrency (numbers, precision) {
96
105
  const exp = Math.pow(10, precision)
97
106
  const float = parseFloat(numbers) / exp
107
+
98
108
  return float.toFixed(fixed(precision))
99
109
  }
100
110
 
101
111
  function addThousandSeparator (integer, separator) {
102
- return integer.replace(/(\d)(?=(?:\d{3})+\b)/gm, `$1${separator}`)
112
+ return integer.replace(/(\d)(?=(?:\d{3})+\b)/g, `$1${separator}`)
103
113
  }
104
114
 
105
115
  // eslint-disable-next-line
@@ -117,6 +127,7 @@ function toStr (value) {
117
127
 
118
128
  function setCursor (el, position) {
119
129
  const setSelectionRange = function () { el.setSelectionRange(position, position) }
130
+
120
131
  if (el === document.activeElement) {
121
132
  setSelectionRange()
122
133
  setTimeout(setSelectionRange, 1) // Android Fix
@@ -126,7 +137,9 @@ function setCursor (el, position) {
126
137
  // https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Creating_and_triggering_events#The_old-fashioned_way
127
138
  function event (name) {
128
139
  const evt = document.createEvent('Event')
140
+
129
141
  evt.initEvent(name, true, true)
142
+
130
143
  return evt
131
144
  }
132
145
 
@@ -30,10 +30,12 @@ export const toCurrency = (val, locale = false) => {
30
30
  }
31
31
 
32
32
  let with2Decimals = val.toString().match(/^-?\d+(?:\.\d{0,2})?/)[0]
33
+
33
34
  with2Decimals = Number(with2Decimals).toLocaleString(locale, {
34
35
  minimumFractionDigits: 2,
35
36
  maximumFractionDigits: 2
36
37
  })
38
+
37
39
  return with2Decimals
38
40
  } catch (Exception) {
39
41
  return val.toLocaleString(locale, {
@@ -49,6 +51,7 @@ export const toCurrency = (val, locale = false) => {
49
51
  */
50
52
  export const toDate = function (val) {
51
53
  if (val === undefined || val === '' || val === null) return ''
54
+
52
55
  if (val === '0000-00-00') return 'N/A'
53
56
 
54
57
  // let defaultFormat = 'DD/MM/YYYY'