@tagplus/components 4.7.12 → 5.1.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.
Files changed (88) hide show
  1. package/dist/tp.common.js +2 -1
  2. package/dist/tp.common.js.LICENSE.txt +9 -0
  3. package/dist/tp.common.js.map +1 -1
  4. package/dist/tp.common.lang-tp-en-js.js +2 -0
  5. package/dist/tp.common.lang-tp-en-js.js.map +1 -0
  6. package/dist/tp.css +11 -167
  7. package/dist/tp.umd.js +2 -1
  8. package/dist/tp.umd.js.LICENSE.txt +9 -0
  9. package/dist/tp.umd.js.map +1 -1
  10. package/dist/tp.umd.lang-tp-en-js.js +2 -0
  11. package/dist/tp.umd.lang-tp-en-js.js.map +1 -0
  12. package/dist/tp.umd.min.js +2 -1
  13. package/dist/tp.umd.min.js.LICENSE.txt +9 -0
  14. package/dist/tp.umd.min.js.map +1 -1
  15. package/dist/tp.umd.min.lang-tp-en-js.js +2 -0
  16. package/dist/tp.umd.min.lang-tp-en-js.js.map +1 -0
  17. package/package.json +51 -50
  18. package/src/assets/scss/_fonts.scss +24 -23
  19. package/src/assets/scss/_helpers.scss +4 -0
  20. package/src/assets/scss/_mixins.scss +2 -2
  21. package/src/assets/scss/_overrides.scss +5 -52
  22. package/src/assets/scss/_resass.scss +21 -12
  23. package/src/assets/scss/_variables.scss +0 -1
  24. package/src/assets/scss/index.scss +1 -4
  25. package/src/components/Autosuggest/Autosuggest.vue +340 -767
  26. package/src/components/Autosuggest/Multisuggest.vue +22 -0
  27. package/src/components/Autosuggest/autosuggest-props.js +210 -0
  28. package/src/components/Autosuggest/autosuggest-style.scss +127 -0
  29. package/src/components/Autosuggest/core.js +63 -0
  30. package/src/components/Autosuggest/index.js +2 -0
  31. package/src/components/Autosuggest/multisuggest-props.js +9 -0
  32. package/src/components/Autosuggest/option.vue +136 -0
  33. package/src/components/Autosuggest/select-dropdown.vue +64 -0
  34. package/src/components/Autosuggest/useOption.js +120 -0
  35. package/src/components/Autosuggest/useSelect.js +1133 -0
  36. package/src/components/AutosuggestTest.vue +56 -0
  37. package/src/components/CardExemplo.vue +49 -0
  38. package/src/components/CodeSample.vue +78 -0
  39. package/src/components/Inline/Inline.vue +24 -32
  40. package/src/components/InputNumber/InputNumber.vue +329 -378
  41. package/src/components/InputNumber/input-number.js +135 -0
  42. package/src/components/Loader/Loader.vue +42 -53
  43. package/src/components/Loader/animations.scss +13 -0
  44. package/src/components/Money/Money.vue +11 -20
  45. package/src/components/Multisuggest/index.js +2 -3
  46. package/src/components/MultisuggestTest.vue +56 -0
  47. package/src/components/OptionsList/OptionsList.vue +7 -6
  48. package/src/components/OptionsListItem/OptionsListItem.vue +46 -42
  49. package/src/components/Percent/Percent.vue +8 -14
  50. package/src/components/Skeleton/Skeleton.vue +16 -11
  51. package/src/components/Step/Step.vue +42 -35
  52. package/src/components/Steps/Steps.vue +4 -7
  53. package/src/components/TesteToCurrency.vue +171 -0
  54. package/src/components/Tip/Tip.vue +45 -30
  55. package/src/components/ValueSelector.vue +60 -0
  56. package/src/components/autosuggestMixin.js +301 -0
  57. package/src/components/index.js +4 -1
  58. package/src/locale/i18n.js +162 -0
  59. package/src/locale/lang/en.js +3 -2
  60. package/src/locale/lang/pt-br.js +3 -2
  61. package/src/main.js +8 -14
  62. package/src/mixins/floatFormatter.js +12 -16
  63. package/src/plugins/currency.js +100 -0
  64. package/src/utils/browser.js +6 -0
  65. package/src/utils/constants.js +3 -0
  66. package/src/utils/error.js +22 -0
  67. package/src/utils/filters.js +1 -14
  68. package/src/utils/helpers.js +41 -0
  69. package/src/utils/i18n.js +2 -0
  70. package/src/utils/icon.js +35 -0
  71. package/src/utils/index.js +20 -0
  72. package/src/utils/objects.js +17 -0
  73. package/src/utils/runtime.js +86 -0
  74. package/src/utils/scroll.js +100 -0
  75. package/src/utils/strings.js +17 -0
  76. package/src/utils/style.js +80 -0
  77. package/src/utils/types.js +39 -0
  78. package/src/utils/use-derived-namespace.js +112 -0
  79. package/src/utils/use-form-common-props.js +41 -0
  80. package/src/utils/use-form-item.js +80 -0
  81. package/src/utils/use-id.js +40 -0
  82. package/src/utils/use-input.js +33 -0
  83. package/src/components/Dialog/Dialog.vue +0 -253
  84. package/src/components/Dialog/index.js +0 -3
  85. package/src/components/Multisuggest/Multisuggest.vue +0 -858
  86. package/src/locale/index.js +0 -78
  87. package/src/mixins/locale.js +0 -9
  88. package/src/utils/currency.js +0 -180
@@ -1,78 +0,0 @@
1
- import defaultLang from 'tp-ui/locale/lang/en'
2
- import Vue from 'vue'
3
- import Format from 'element-ui/src/locale/format'
4
-
5
- const format = Format(Vue)
6
-
7
- const i18nHandler = function () {
8
- // Existe this e contem função "$t"
9
- if (this && this.$i18n) {
10
- return this.$i18n
11
- }
12
-
13
- // Tenta usar o vueI18n da instancia do TP, caso tenha sido carregada
14
- if (Vue.prototype.$tpI18n) {
15
- return Vue.prototype.$tpI18n
16
- }
17
-
18
- return null
19
- }
20
-
21
- /**
22
- * Recupera qual a locale de linguagem atualmente sendo utilizada
23
- */
24
- export const getCurrentLocale = () => {
25
- return (Vue.prototype.$tpI18n) ? Vue.prototype.$tpI18n.locale : Vue.prototype.$defaultLang
26
- }
27
-
28
- /**
29
- * Retorna as messages definidas na lang
30
- */
31
- export const messages = function () {
32
- const i18n = i18nHandler.apply(this, arguments)
33
-
34
- if (i18n !== null && i18n !== undefined && i18n.messages) {
35
- return i18n.messages
36
- }
37
-
38
- return defaultLang
39
- }
40
-
41
- /**
42
- * Recupera um item de linguagem nas messages registradas.
43
- * Caso não haja i18n registrado, utiliza da lingua padrão
44
- * @param {String} path
45
- * @param {Object} options
46
- */
47
- export const t = function (path, options) {
48
- const i18n = i18nHandler.apply(this, arguments)
49
-
50
- if (i18n !== null && i18n !== undefined && i18n.t) {
51
- return i18n.t(path)
52
- }
53
-
54
- const array = path.split('.')
55
- let current = defaultLang
56
- let value = null
57
-
58
- for (let i = 0, j = array.length; i < j; i++) {
59
- const property = array[i]
60
-
61
- value = current[property]
62
-
63
- if (!value) {
64
- // eslint-disable-next-line
65
- console.warn(`[Tp-i18n] Fall back to translate '${path}'. Key does not exist on language messages. Assuming key as value`)
66
-
67
- return path
68
- }
69
-
70
- if (i === j - 1) return format(value, options)
71
-
72
- current = value
73
- }
74
-
75
- return ''
76
- }
77
-
78
- export default { t, messages }
@@ -1,9 +0,0 @@
1
- import { t } from 'tp-ui/locale'
2
-
3
- export default {
4
- methods: {
5
- t (...args) {
6
- return t.apply(this, args)
7
- }
8
- }
9
- }
@@ -1,180 +0,0 @@
1
- import { messages } from 'tp-ui/locale'
2
-
3
- const defaults = messages().locale.number
4
-
5
- function format (input, opt = defaults) {
6
- if (typeof input === 'number') {
7
- input = input.toFixed(fixed(opt.precision))
8
- }
9
-
10
- const negative = input.indexOf('-') >= 0 ? '-' : ''
11
-
12
- const numbers = onlyNumbers(input)
13
- const currency = numbersToCurrency(numbers, opt.precision)
14
- const parts = toStr(currency).split('.')
15
- let integer = parts[0]
16
- const decimal = parts[1]
17
-
18
- integer = addThousandSeparator(integer, opt.thousands)
19
-
20
- return opt.prefix + negative + joinIntegerAndDecimal(integer, decimal, opt.decimal) + opt.suffix
21
- }
22
-
23
- function unformat (input, precision = defaults.precision) {
24
- const negative = (`${input}`).indexOf('-') >= 0 ? -1 : 1
25
- const numbers = onlyNumbers(input)
26
- const currency = numbersToCurrency(numbers, precision)
27
-
28
- return currency * negative
29
- }
30
-
31
- /**
32
- * Formata dinheiro para float sem arredondar ou para string garantindo decimais completos (.00) e respeitando caracter de decimal
33
- * @author gteixeira
34
- * @param {Float} input Valor
35
- * @param {Boolean} toString Se o retorno será float ou string
36
- * @param {Object} locale Configuração de localidade para saber número de casas decimais (precision) e caracter de decimal (decimal)
37
- * @param {Number} customPrecision Caso o usuário queira sobrescrever o número de casas decimais (precision) da configuração de localidade.
38
- * @returns
39
- */
40
- function formatMoney (input, toString = false, locale = defaults, customPrecision = false) {
41
- let inputString = removeSecondSeparator(`${input}`, locale)
42
-
43
- // Impede de digitar . ou , porque o formatador já adiciona
44
- if ((inputString.slice(-1).match(/[.,]/))) {
45
- inputString = inputString.substring(0, inputString.length - 1)
46
- }
47
-
48
- const negative = inputString.indexOf('-') >= 0 ? -1 : 1
49
-
50
- if (toString) {
51
- input = completeZeros(customPrecision, inputString, locale)
52
- }
53
-
54
- const precision = customPrecision || locale.number.precision
55
-
56
- const numbers = onlyNumbers(input, precision)
57
- const currency = numbersToCurrency(numbers, precision)
58
-
59
- if (toString) {
60
- let num = negative === -1 ? `-${currency}` : `${currency}`
61
-
62
- if (locale?.number?.decimal) {
63
- const decimalChar = locale?.number?.decimal
64
-
65
- num = num.replaceAll(',', decimalChar).replaceAll('.', decimalChar)
66
- }
67
-
68
- return num
69
- }
70
-
71
- return currency * negative
72
- }
73
-
74
- function completeZeros (customPrecision, input, locale) {
75
- const precision = customPrecision || locale?.number?.precision || defaults.precision
76
- const decimal = locale?.number?.decimal || defaults.decimal
77
- let i = input.lastIndexOf('.')
78
- const j = input.lastIndexOf(',')
79
-
80
- i = i > j ? i : j
81
- const qntDecimais = i ? input.length - i - 1 : 0
82
-
83
- // correção para decimal quebrado
84
- if (i === -1) {
85
- input = input + decimal + '0'.repeat(precision)
86
- } else if (i && qntDecimais < precision) {
87
- input += '0'.repeat(precision - qntDecimais)
88
- }
89
-
90
- return input
91
- }
92
-
93
- // Impede que seja adicionado um segundo separadador apos o ponto ou a virgula
94
- function removeSecondSeparator (input, locale) {
95
- const decimal = locale?.number?.decimal
96
-
97
- if (!decimal || !input) {
98
- return input
99
- }
100
-
101
- // Separa a string pelo decimal
102
- const newInputParts = input.split(decimal)
103
-
104
- if (newInputParts.length) {
105
- let newInput = ''
106
-
107
- // Percorre as partes dividas da string limpando tudo que nao for numerico depois do separador decimal
108
- for (let i = 0; i < newInputParts.length; i++) {
109
- newInputParts[i] = i >= 1 ? newInputParts[i].replace(/[^0-9]/g, '') : newInputParts[i] + decimal
110
- newInput += newInputParts[i]
111
- }
112
-
113
- return newInput
114
- }
115
-
116
- return input
117
- }
118
-
119
- function onlyNumbers (input) {
120
- return toStr(input).replace(/\D+/g, '') || '0'
121
- }
122
-
123
- // Uncaught RangeError: toFixed() digits argument must be between 0 and 20 at Number.toFixed
124
- function fixed (precision = defaults.precision) {
125
- return between(0, precision, 20)
126
- }
127
-
128
- function between (min, n, max) {
129
- return Math.max(min, Math.min(n, max))
130
- }
131
-
132
- function numbersToCurrency (numbers, precision) {
133
- const exp = Math.pow(10, precision)
134
- const float = parseFloat(numbers) / exp
135
- return float.toFixed(fixed(precision))
136
- }
137
-
138
- function addThousandSeparator (integer, separator) {
139
- return integer.replace(/(\d)(?=(?:\d{3})+\b)/g, `$1${separator}`)
140
- }
141
-
142
- // eslint-disable-next-line
143
- function currencyToIntegerAndDecimal (float) {
144
- return toStr(float).split('.')
145
- }
146
-
147
- function joinIntegerAndDecimal (integer, decimal, separator) {
148
- return decimal ? integer + separator + decimal : integer
149
- }
150
-
151
- function toStr (value) {
152
- return value ? value.toString() : ''
153
- }
154
-
155
- function setCursor (el, position) {
156
- const setSelectionRange = function () { el.setSelectionRange(position, position) }
157
-
158
- if (el === document.activeElement) {
159
- setSelectionRange()
160
- setTimeout(setSelectionRange, 1) // Android Fix
161
- }
162
- }
163
-
164
- // https://developer.mozilla.org/en-US/docs/Web/Guide/Events/Creating_and_triggering_events#The_old-fashioned_way
165
- function event (name) {
166
- const evt = document.createEvent('Event')
167
-
168
- evt.initEvent(name, true, true)
169
-
170
- return evt
171
- }
172
-
173
- export {
174
- formatMoney,
175
- format,
176
- unformat,
177
- setCursor,
178
- completeZeros,
179
- event
180
- }