@tagplus/components 5.3.3 → 5.3.4

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 (203) hide show
  1. package/dist/demo.html +1 -0
  2. package/dist/fonts/bevi-bold.7e4dcd11.woff +0 -0
  3. package/dist/fonts/bevi-bold.873def84.woff2 +0 -0
  4. package/dist/fonts/bevi-medium.6187e050.woff2 +0 -0
  5. package/dist/fonts/bevi-medium.65b3056d.woff +0 -0
  6. package/dist/fonts/bevi-regular.c89f126e.woff +0 -0
  7. package/dist/fonts/bevi-regular.f81e4b8f.woff2 +0 -0
  8. package/dist/tp.common.js +2 -0
  9. package/dist/tp.common.js.map +1 -0
  10. package/dist/tp.css +167 -0
  11. package/dist/tp.umd.js +2 -0
  12. package/dist/tp.umd.js.map +1 -0
  13. package/dist/tp.umd.min.js +2 -0
  14. package/dist/tp.umd.min.js.map +1 -0
  15. package/package.json +62 -84
  16. package/src/assets/scss/_fonts.scss +27 -0
  17. package/src/assets/scss/_functions.scss +22 -0
  18. package/src/assets/scss/_helpers.scss +112 -0
  19. package/src/assets/scss/_mixins.scss +69 -0
  20. package/src/assets/scss/_overrides.scss +69 -0
  21. package/src/assets/scss/_resass.scss +83 -0
  22. package/src/assets/scss/_variables.scss +27 -0
  23. package/src/assets/scss/index.scss +11 -0
  24. package/src/components/Autosuggest/Autosuggest.vue +791 -0
  25. package/src/components/Autosuggest/index.js +3 -0
  26. package/src/components/Dialog/Dialog.vue +253 -0
  27. package/src/components/Dialog/index.js +3 -0
  28. package/src/components/Inline/Inline.vue +149 -0
  29. package/src/components/Inline/index.js +3 -0
  30. package/src/components/InputNumber/InputNumber.vue +430 -0
  31. package/src/components/InputNumber/index.js +3 -0
  32. package/src/components/Loader/Loader.vue +317 -0
  33. package/src/components/Loader/animations.scss +68 -0
  34. package/src/components/Loader/index.js +3 -0
  35. package/src/components/Money/Money.vue +82 -0
  36. package/src/components/Money/index.js +3 -0
  37. package/src/components/Multisuggest/Multisuggest.vue +858 -0
  38. package/src/components/Multisuggest/index.js +3 -0
  39. package/src/components/OptionsList/OptionsList.vue +61 -0
  40. package/src/components/OptionsList/index.js +3 -0
  41. package/src/components/OptionsListItem/OptionsListItem.vue +191 -0
  42. package/src/components/OptionsListItem/index.js +3 -0
  43. package/src/components/Percent/Percent.vue +81 -0
  44. package/src/components/Percent/index.js +3 -0
  45. package/src/components/Skeleton/Skeleton.vue +137 -0
  46. package/src/components/Skeleton/index.js +3 -0
  47. package/src/components/Step/Step.vue +230 -0
  48. package/src/components/Step/index.js +3 -0
  49. package/src/components/Steps/Steps.vue +18 -0
  50. package/src/components/Steps/index.js +3 -0
  51. package/src/components/Tip/Tip.vue +193 -0
  52. package/src/components/Tip/index.js +3 -0
  53. package/src/components/index.js +31 -0
  54. package/src/locale/index.js +78 -0
  55. package/{dist → src/locale}/lang/en.js +2 -3
  56. package/{dist → src/locale}/lang/pt-br.js +2 -3
  57. package/src/main.js +26 -0
  58. package/src/mixins/floatFormatter.js +53 -0
  59. package/src/mixins/locale.js +9 -0
  60. package/src/utils/currency.js +180 -0
  61. package/src/utils/filters.js +84 -0
  62. package/dist/es/_virtual/_plugin-vue_export-helper.mjs +0 -10
  63. package/dist/es/components.css +0 -2391
  64. package/dist/es/node_modules/@element-plus/icons-vue/dist/index.mjs +0 -148
  65. package/dist/es/node_modules/@popperjs/core/lib/enums.mjs +0 -22
  66. package/dist/es/node_modules/@vue/shared/dist/shared.esm-bundler.mjs +0 -28
  67. package/dist/es/node_modules/@vueuse/core/index.mjs +0 -172
  68. package/dist/es/node_modules/@vueuse/shared/index.mjs +0 -68
  69. package/dist/es/node_modules/element-plus/es/constants/size.mjs +0 -4
  70. package/dist/es/node_modules/element-plus/es/hooks/use-focus-controller/index.mjs +0 -64
  71. package/dist/es/node_modules/element-plus/es/hooks/use-id/index.mjs +0 -30
  72. package/dist/es/node_modules/element-plus/es/hooks/use-locale/index.mjs +0 -29
  73. package/dist/es/node_modules/element-plus/es/hooks/use-namespace/index.mjs +0 -79
  74. package/dist/es/node_modules/element-plus/es/hooks/use-prop/index.mjs +0 -11
  75. package/dist/es/node_modules/element-plus/es/hooks/use-size/index.mjs +0 -20
  76. package/dist/es/node_modules/element-plus/es/locale/lang/en.mjs +0 -182
  77. package/dist/es/node_modules/element-plus/es/utils/error.mjs +0 -16
  78. package/dist/es/node_modules/element-plus/es/utils/types.mjs +0 -9
  79. package/dist/es/node_modules/element-plus/es/utils/vue/props/runtime.mjs +0 -42
  80. package/dist/es/src/components/Autosuggest/Autosuggest.vue.mjs +0 -446
  81. package/dist/es/src/components/Autosuggest/Multisuggest.vue.mjs +0 -17
  82. package/dist/es/src/components/Autosuggest/autosuggest-props.mjs +0 -204
  83. package/dist/es/src/components/Autosuggest/core.mjs +0 -56
  84. package/dist/es/src/components/Autosuggest/multisuggest-props.mjs +0 -11
  85. package/dist/es/src/components/Autosuggest/option.vue.mjs +0 -118
  86. package/dist/es/src/components/Autosuggest/select-dropdown.vue.mjs +0 -62
  87. package/dist/es/src/components/Autosuggest/useOption.mjs +0 -93
  88. package/dist/es/src/components/Autosuggest/useSelect.mjs +0 -803
  89. package/dist/es/src/components/Inline/Inline.vue.mjs +0 -125
  90. package/dist/es/src/components/Inline/index.mjs +0 -4
  91. package/dist/es/src/components/InputNumber/InputNumber.vue.mjs +0 -360
  92. package/dist/es/src/components/InputNumber/index.mjs +0 -4
  93. package/dist/es/src/components/InputNumber/input-number.mjs +0 -128
  94. package/dist/es/src/components/Loader/Loader.vue.mjs +0 -59
  95. package/dist/es/src/components/Loader/index.mjs +0 -4
  96. package/dist/es/src/components/Money/Money.vue.mjs +0 -72
  97. package/dist/es/src/components/Money/index.mjs +0 -4
  98. package/dist/es/src/components/Multisuggest/index.mjs +0 -4
  99. package/dist/es/src/components/OptionsList/OptionsList.vue.mjs +0 -28
  100. package/dist/es/src/components/OptionsList/index.mjs +0 -4
  101. package/dist/es/src/components/OptionsListItem/OptionsListItem.vue.mjs +0 -96
  102. package/dist/es/src/components/OptionsListItem/index.mjs +0 -4
  103. package/dist/es/src/components/Percent/Percent.vue.mjs +0 -73
  104. package/dist/es/src/components/Percent/index.mjs +0 -4
  105. package/dist/es/src/components/Skeleton/Skeleton.vue.mjs +0 -79
  106. package/dist/es/src/components/Skeleton/index.mjs +0 -4
  107. package/dist/es/src/components/Step/Step.vue.mjs +0 -206
  108. package/dist/es/src/components/Step/index.mjs +0 -4
  109. package/dist/es/src/components/Steps/Steps.vue.mjs +0 -15
  110. package/dist/es/src/components/Steps/index.mjs +0 -4
  111. package/dist/es/src/components/Tip/Tip.vue.mjs +0 -160
  112. package/dist/es/src/components/Tip/index.mjs +0 -4
  113. package/dist/es/src/components/index.mjs +0 -22
  114. package/dist/es/src/locale/i18nCreator.mjs +0 -93
  115. package/dist/es/src/locale/lang/pt-br.mjs +0 -21
  116. package/dist/es/src/main.mjs +0 -18
  117. package/dist/es/src/mixins/floatFormatter.mjs +0 -42
  118. package/dist/es/src/plugins/currency.mjs +0 -69
  119. package/dist/es/src/utils/constants.mjs +0 -6
  120. package/dist/es/src/utils/error.mjs +0 -20
  121. package/dist/es/src/utils/i18n.mjs +0 -4
  122. package/dist/es/src/utils/icon.mjs +0 -9
  123. package/dist/es/src/utils/index.mjs +0 -8
  124. package/dist/es/src/utils/runtime.mjs +0 -50
  125. package/dist/es/src/utils/scroll.mjs +0 -26
  126. package/dist/es/src/utils/strings.mjs +0 -4
  127. package/dist/es/src/utils/types.mjs +0 -9
  128. package/dist/es/src/utils/use-derived-namespace.mjs +0 -15
  129. package/dist/es/src/utils/use-form-common-props.mjs +0 -25
  130. package/dist/es/src/utils/use-form-item.mjs +0 -61
  131. package/dist/es/src/utils/use-id.mjs +0 -35
  132. package/dist/es/src/utils/use-input.mjs +0 -31
  133. package/dist/lib/_virtual/_plugin-vue_export-helper.js +0 -10
  134. package/dist/lib/components.css +0 -2391
  135. package/dist/lib/node_modules/@element-plus/icons-vue/dist/index.js +0 -148
  136. package/dist/lib/node_modules/@popperjs/core/lib/enums.js +0 -22
  137. package/dist/lib/node_modules/@vue/shared/dist/shared.esm-bundler.js +0 -28
  138. package/dist/lib/node_modules/@vueuse/core/index.js +0 -170
  139. package/dist/lib/node_modules/@vueuse/shared/index.js +0 -68
  140. package/dist/lib/node_modules/element-plus/es/constants/size.js +0 -4
  141. package/dist/lib/node_modules/element-plus/es/hooks/use-focus-controller/index.js +0 -64
  142. package/dist/lib/node_modules/element-plus/es/hooks/use-id/index.js +0 -30
  143. package/dist/lib/node_modules/element-plus/es/hooks/use-locale/index.js +0 -29
  144. package/dist/lib/node_modules/element-plus/es/hooks/use-namespace/index.js +0 -79
  145. package/dist/lib/node_modules/element-plus/es/hooks/use-prop/index.js +0 -11
  146. package/dist/lib/node_modules/element-plus/es/hooks/use-size/index.js +0 -20
  147. package/dist/lib/node_modules/element-plus/es/locale/lang/en.js +0 -182
  148. package/dist/lib/node_modules/element-plus/es/utils/error.js +0 -16
  149. package/dist/lib/node_modules/element-plus/es/utils/types.js +0 -9
  150. package/dist/lib/node_modules/element-plus/es/utils/vue/props/runtime.js +0 -42
  151. package/dist/lib/src/components/Autosuggest/Autosuggest.vue.js +0 -446
  152. package/dist/lib/src/components/Autosuggest/Multisuggest.vue.js +0 -17
  153. package/dist/lib/src/components/Autosuggest/autosuggest-props.js +0 -204
  154. package/dist/lib/src/components/Autosuggest/core.js +0 -56
  155. package/dist/lib/src/components/Autosuggest/multisuggest-props.js +0 -11
  156. package/dist/lib/src/components/Autosuggest/option.vue.js +0 -118
  157. package/dist/lib/src/components/Autosuggest/select-dropdown.vue.js +0 -62
  158. package/dist/lib/src/components/Autosuggest/useOption.js +0 -93
  159. package/dist/lib/src/components/Autosuggest/useSelect.js +0 -803
  160. package/dist/lib/src/components/Inline/Inline.vue.js +0 -125
  161. package/dist/lib/src/components/Inline/index.js +0 -4
  162. package/dist/lib/src/components/InputNumber/InputNumber.vue.js +0 -360
  163. package/dist/lib/src/components/InputNumber/index.js +0 -4
  164. package/dist/lib/src/components/InputNumber/input-number.js +0 -128
  165. package/dist/lib/src/components/Loader/Loader.vue.js +0 -59
  166. package/dist/lib/src/components/Loader/index.js +0 -4
  167. package/dist/lib/src/components/Money/Money.vue.js +0 -72
  168. package/dist/lib/src/components/Money/index.js +0 -4
  169. package/dist/lib/src/components/Multisuggest/index.js +0 -4
  170. package/dist/lib/src/components/OptionsList/OptionsList.vue.js +0 -28
  171. package/dist/lib/src/components/OptionsList/index.js +0 -4
  172. package/dist/lib/src/components/OptionsListItem/OptionsListItem.vue.js +0 -96
  173. package/dist/lib/src/components/OptionsListItem/index.js +0 -4
  174. package/dist/lib/src/components/Percent/Percent.vue.js +0 -73
  175. package/dist/lib/src/components/Percent/index.js +0 -4
  176. package/dist/lib/src/components/Skeleton/Skeleton.vue.js +0 -79
  177. package/dist/lib/src/components/Skeleton/index.js +0 -4
  178. package/dist/lib/src/components/Step/Step.vue.js +0 -206
  179. package/dist/lib/src/components/Step/index.js +0 -4
  180. package/dist/lib/src/components/Steps/Steps.vue.js +0 -15
  181. package/dist/lib/src/components/Steps/index.js +0 -4
  182. package/dist/lib/src/components/Tip/Tip.vue.js +0 -160
  183. package/dist/lib/src/components/Tip/index.js +0 -4
  184. package/dist/lib/src/components/index.js +0 -22
  185. package/dist/lib/src/locale/i18nCreator.js +0 -93
  186. package/dist/lib/src/locale/lang/pt-br.js +0 -21
  187. package/dist/lib/src/main.js +0 -18
  188. package/dist/lib/src/mixins/floatFormatter.js +0 -42
  189. package/dist/lib/src/plugins/currency.js +0 -69
  190. package/dist/lib/src/utils/constants.js +0 -6
  191. package/dist/lib/src/utils/error.js +0 -20
  192. package/dist/lib/src/utils/i18n.js +0 -4
  193. package/dist/lib/src/utils/icon.js +0 -9
  194. package/dist/lib/src/utils/index.js +0 -8
  195. package/dist/lib/src/utils/runtime.js +0 -50
  196. package/dist/lib/src/utils/scroll.js +0 -26
  197. package/dist/lib/src/utils/strings.js +0 -4
  198. package/dist/lib/src/utils/types.js +0 -12
  199. package/dist/lib/src/utils/use-derived-namespace.js +0 -15
  200. package/dist/lib/src/utils/use-form-common-props.js +0 -25
  201. package/dist/lib/src/utils/use-form-item.js +0 -61
  202. package/dist/lib/src/utils/use-id.js +0 -35
  203. package/dist/lib/src/utils/use-input.js +0 -31
@@ -0,0 +1,3 @@
1
+ import Step from './Step'
2
+
3
+ export default Step
@@ -0,0 +1,18 @@
1
+ <script>
2
+ import { Steps } from 'element-ui'
3
+
4
+ export default {
5
+ name: 'TpSteps',
6
+ extends: Steps,
7
+ props: {
8
+ newItem: {
9
+ type: Boolean,
10
+ default: false
11
+ }
12
+ }
13
+ }
14
+
15
+ </script>
16
+
17
+ <style lang="scss" scoped>
18
+ </style>
@@ -0,0 +1,3 @@
1
+ import Steps from './Steps'
2
+
3
+ export default Steps
@@ -0,0 +1,193 @@
1
+ <template>
2
+ <el-row
3
+ v-if="!title"
4
+ :id="`${_id}`"
5
+ type="flex"
6
+ align="middle"
7
+ :class="tptipclasses"
8
+ class="text-black"
9
+ >
10
+ <el-col :xs="3" :sm="1" style="align-self: start;">
11
+ <em class="far fa-lightbulb-on" />
12
+ </el-col>
13
+
14
+ <el-col :xs="21" :sm="23">
15
+ <div
16
+ :id="`${_id}-text`"
17
+ v-html="text"
18
+ />
19
+ </el-col>
20
+ </el-row>
21
+
22
+ <el-row
23
+ v-else
24
+ :id="`${_id}`"
25
+ type="flex"
26
+ align="middle"
27
+ justify="center"
28
+ :class="tptipclasses"
29
+ class="text-black"
30
+ >
31
+
32
+ <el-col :xs="3" :sm="1">
33
+ <el-row type="flex" justify="start">
34
+ <em class="far fa-lightbulb-on" />
35
+ </el-row>
36
+ </el-col>
37
+
38
+ <el-col :xs="18" :sm="22">
39
+ <b class="tp-title">{{ title }}</b>
40
+ </el-col>
41
+
42
+ <el-col :xs="3" :sm="1">
43
+ <el-row type="flex" justify="end">
44
+ <em v-if="closed" class="fa fa-plus tp-close-button" @click="closed = !closed" />
45
+ <em v-else class="fa fa-minus tp-close-button" @click="closed = !closed" />
46
+ </el-row>
47
+ </el-col>
48
+
49
+ <el-col :xs="18" :sm="22" :class="'tp-text ' + (closed ? 'tp-vanish' : '' )">
50
+ <div
51
+ :id="`${_id}-text`"
52
+ v-html="text"
53
+ />
54
+ </el-col>
55
+ </el-row>
56
+ </template>
57
+
58
+ <script>
59
+ export default {
60
+ name: 'TpTip',
61
+ props: {
62
+ id: {
63
+ type: String,
64
+ required: false,
65
+ default: null
66
+ },
67
+
68
+ text: {
69
+ type: String,
70
+ required: true,
71
+ default: ''
72
+ },
73
+
74
+ title: {
75
+ type: String,
76
+ default: ''
77
+ },
78
+
79
+ type: {
80
+ type: String,
81
+ default: 'default'
82
+ }
83
+ },
84
+
85
+ data () {
86
+ return {
87
+ closed: true
88
+ }
89
+ },
90
+
91
+ computed: {
92
+ _id () {
93
+ return this.id || this.$options.name
94
+ },
95
+
96
+ tptipclasses () {
97
+ const classes = ['grid-content', 'pa-3']
98
+
99
+ if (this.type === 'error') {
100
+ classes.push('tp-tip-error')
101
+ }
102
+
103
+ if (this.type === 'warning') {
104
+ classes.push('tp-tip-warning')
105
+ }
106
+
107
+ if (this.type === 'success') {
108
+ classes.push('tp-tip-success')
109
+ }
110
+
111
+ return classes
112
+ }
113
+ }
114
+ }
115
+ </script>
116
+
117
+ <style lang="scss" scoped>
118
+ .far.fa-lightbulb-on {
119
+ font-size: 20px;
120
+ }
121
+
122
+ .grid-content {
123
+ flex-wrap: wrap;
124
+ border-radius: 4px;
125
+ background-color: rgba(76, 135, 251, 0.1);
126
+ border-radius: 4px;
127
+ border: solid 1px rgba(76, 135, 251, 0.2);
128
+ padding: 1rem;
129
+ font-size: 14px;
130
+ line-height: 24px;
131
+ color: #586d93;
132
+ }
133
+
134
+ .info-text {
135
+ font-size: 12px;
136
+ font-stretch: normal;
137
+ font-style: normal;
138
+ line-height: 1.33;
139
+ letter-spacing: normal;
140
+ text-align: left;
141
+ }
142
+
143
+ .tp-tip-error {
144
+ background: #f56c6c1a 0% 0% no-repeat padding-box;
145
+ border: 1px solid #ff6077;
146
+ :deep(){
147
+ strong, b, em {
148
+ color: #ff425f;
149
+ }
150
+ }
151
+ }
152
+
153
+ .tp-tip-warning {
154
+ background: #fff9ea 0% 0% no-repeat padding-box;
155
+ border: 1px solid #ffc437;
156
+ :deep(){
157
+ strong, b, em {
158
+ color: #ffc437;
159
+ }
160
+ }
161
+ }
162
+
163
+ .tp-tip-success {
164
+ background: #f3fcfc 0% 0% no-repeat padding-box;
165
+ border: 1px solid #08a19e;
166
+ :deep(){
167
+ strong, b, em {
168
+ color: #08a19e;
169
+ }
170
+ }
171
+ }
172
+
173
+ .tp-close-button {
174
+ cursor: pointer;
175
+ }
176
+
177
+ .tp-title {
178
+ font-size: 16px;
179
+ }
180
+
181
+ .tp-text {
182
+ height: auto;
183
+ transition: 0.4s opacity ease-out;
184
+ }
185
+
186
+ .tp-vanish {
187
+ position: absolute;
188
+ max-height:0;
189
+ transform: scale(0);
190
+ opacity:0;
191
+ transition: 0s opacity linear;
192
+ }
193
+ </style>
@@ -0,0 +1,3 @@
1
+ import Tip from './Tip'
2
+
3
+ export default Tip
@@ -0,0 +1,31 @@
1
+ import Autosuggest from './Autosuggest'
2
+ import Inline from './Inline'
3
+ import Money from './Money'
4
+ import Percent from './Percent'
5
+ import OptionsList from './OptionsList'
6
+ import OptionsListItem from './OptionsListItem'
7
+ import Loader from './Loader'
8
+ import Skeleton from './Skeleton'
9
+ import Tip from './Tip'
10
+ import Multisuggest from './Multisuggest'
11
+ import Step from './Step'
12
+ import Steps from './Steps'
13
+ import InputNumber from './InputNumber'
14
+ import Dialog from './Dialog'
15
+
16
+ export {
17
+ Autosuggest,
18
+ Inline,
19
+ Money,
20
+ Percent,
21
+ OptionsList,
22
+ OptionsListItem,
23
+ Loader,
24
+ Skeleton,
25
+ Tip,
26
+ Multisuggest,
27
+ Step,
28
+ Steps,
29
+ InputNumber,
30
+ Dialog
31
+ }
@@ -0,0 +1,78 @@
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,8 +1,7 @@
1
- import enLocale from 'element-plus/es/locale/lang/en'
1
+ import locale from 'element-ui/lib/locale/lang/en'
2
2
 
3
3
  export default {
4
- ...enLocale,
5
- lingua: 'English',
4
+ ...locale,
6
5
 
7
6
  tp: {
8
7
  money: {
@@ -1,8 +1,7 @@
1
- import ptbrLocale from 'element-plus/es/locale/lang/pt-br'
1
+ import locale from 'element-ui/lib/locale/lang/pt-br'
2
2
 
3
3
  export default {
4
- ...ptbrLocale,
5
- lingua: 'Português',
4
+ ...locale,
6
5
 
7
6
  tp: {
8
7
  money: {
package/src/main.js ADDED
@@ -0,0 +1,26 @@
1
+ import ElementUI from 'element-ui'
2
+ // import './assets/scss/index.scss'
3
+ import * as components from './components'
4
+
5
+ const install = function (Vue, opts = {}) {
6
+ Vue.prototype.$defaultLang = 'en'
7
+ Vue.prototype.$tpI18n = opts.locale || {}
8
+ opts.locale = null
9
+
10
+ // Element
11
+ ElementUI.install(Vue, opts)
12
+
13
+ // components
14
+ for (const componentName in components) {
15
+ const component = components[componentName]
16
+
17
+ Vue.component(component.name, component)
18
+ }
19
+ }
20
+
21
+ if (typeof window !== 'undefined' && window.Vue) {
22
+ install(window.Vue)
23
+ }
24
+
25
+ // TODO: Validar encapsulamento do ElementUI
26
+ export default ({ ...ElementUI, ...components, install })
@@ -0,0 +1,53 @@
1
+ import { formatMoney } from 'tp-ui/utils/currency'
2
+
3
+ /**
4
+ * Eventos para componentes tp-money e tp-percent mostratem o número formatado com a precisão correta e devolver float sem arredondar
5
+ */
6
+ export default {
7
+ data () {
8
+ return {
9
+ formattedValue: this.value
10
+ }
11
+ },
12
+
13
+ props: {
14
+ allowEmpty: {
15
+ type: Boolean,
16
+ default: false
17
+ },
18
+
19
+ customPrecision: {
20
+ default: false
21
+ }
22
+ },
23
+
24
+ computed: {
25
+ locale () {
26
+ return this.t('locale')
27
+ }
28
+ },
29
+
30
+ watch: {
31
+ value: {
32
+ immediate: true,
33
+ handler (newValue, oldValue) {
34
+ if (newValue === '' && this.allowEmpty) { this.formattedValue = ''; return }
35
+ this.formattedValue = formatMoney(newValue, true, this.locale, this.customPrecision)
36
+ }
37
+ }
38
+ },
39
+
40
+ methods: {
41
+ input (evt) {
42
+ this.formattedValue = formatMoney(evt, true, this.locale, this.customPrecision)
43
+ const moneyFormatado = formatMoney(evt, false, this.locale, this.customPrecision)
44
+
45
+ this.$emit('input', moneyFormatado)
46
+ },
47
+
48
+ handleChange (evt) {
49
+ this.$emit('change', formatMoney(evt, false, this.locale, this.customPrecision))
50
+ }
51
+ }
52
+
53
+ }
@@ -0,0 +1,9 @@
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
+ }
@@ -0,0 +1,180 @@
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
+ }