fleetcor-lwc 3.15.0 → 3.17.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.
- package/README.md +5 -0
- package/frontend/components/flt/inputText/__test__/inputText.test.js +41 -0
- package/frontend/components/flt/inputText/inputText.html +2 -1
- package/frontend/components/flt/inputText/inputText.js +46 -4
- package/frontend/components/flt/loader/loader.html +6 -1
- package/frontend/components/flt/loader/loader.js +4 -1
- package/frontend/components/flt/picklist/picklist.html +15 -5
- package/frontend/components/flt/picklist/picklist.js +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -952,6 +952,11 @@ You can override them as you wish by global css variables as priority.
|
|
|
952
952
|
<details>
|
|
953
953
|
<summary>Click to expand/collapse</summary>
|
|
954
954
|
|
|
955
|
+
v.3.16.0
|
|
956
|
+
|
|
957
|
+
- Update `flt-input-text` - it's become more powerfull with type number
|
|
958
|
+
|
|
959
|
+
---
|
|
955
960
|
v.3.15.0
|
|
956
961
|
|
|
957
962
|
- Added to `flt-input-with-picklist` api attribute `inputmode` and `input-type`
|
|
@@ -225,4 +225,45 @@ describe('flt-input-text', () => {
|
|
|
225
225
|
})
|
|
226
226
|
})
|
|
227
227
|
})
|
|
228
|
+
|
|
229
|
+
it('flt-input-text number', async () => {
|
|
230
|
+
const inputTextElement = createElement('flt-input-text', { is: InputText })
|
|
231
|
+
inputTextElement.name = 'Currency'
|
|
232
|
+
inputTextElement.label = 'Currency'
|
|
233
|
+
inputTextElement.type = 'number'
|
|
234
|
+
inputTextElement.inputmode = 'number'
|
|
235
|
+
inputTextElement.placeholder = 'Currency'
|
|
236
|
+
document.body.appendChild(inputTextElement)
|
|
237
|
+
|
|
238
|
+
await expect(inputTextElement.firstChild.classList).toContain('flt-input-text')
|
|
239
|
+
inputTextElement.validate()
|
|
240
|
+
return Promise.resolve().then(async () => {
|
|
241
|
+
await expect(inputTextElement.firstChild.classList).not.toContain(
|
|
242
|
+
'flt-input-text_success'
|
|
243
|
+
)
|
|
244
|
+
await expect(inputTextElement.isValid()).toBeTruthy()
|
|
245
|
+
let data = inputTextElement.getData()
|
|
246
|
+
await expect(data.placeholder).toBe('Currency')
|
|
247
|
+
|
|
248
|
+
inputTextElement.value = '100'
|
|
249
|
+
inputTextElement.dispatchEvent(new CustomEvent('change'))
|
|
250
|
+
inputTextElement.validate()
|
|
251
|
+
|
|
252
|
+
return Promise.resolve().then(async () => {
|
|
253
|
+
await expect(inputTextElement.firstChild.classList).toContain(
|
|
254
|
+
'flt-input-text_success'
|
|
255
|
+
)
|
|
256
|
+
await expect(inputTextElement.isValid()).toBeTruthy()
|
|
257
|
+
await expect(inputTextElement.getData().value).toBe('100')
|
|
258
|
+
|
|
259
|
+
const inputEl = inputTextElement.querySelector('input')
|
|
260
|
+
inputEl.focus()
|
|
261
|
+
inputEl.value = '3435234523'
|
|
262
|
+
inputEl.dispatchEvent(new CustomEvent('input'))
|
|
263
|
+
return Promise.resolve().then(async () => {
|
|
264
|
+
await expect(inputTextElement.getData().isValid).toBeTruthy()
|
|
265
|
+
})
|
|
266
|
+
})
|
|
267
|
+
})
|
|
268
|
+
})
|
|
228
269
|
})
|
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
<span lwc:if={prefix} class="flt-input-text__prefix" lwc:inner-html={prefix}></span>
|
|
7
7
|
<input
|
|
8
8
|
id={name}
|
|
9
|
+
lwc:ref="input"
|
|
9
10
|
onfocus={handleFocused}
|
|
10
11
|
onblur={handleBlur}
|
|
11
12
|
class="flt-input-text__input"
|
|
12
13
|
maxlength={maxLength}
|
|
13
|
-
type={
|
|
14
|
+
type={htmlInputType}
|
|
14
15
|
inputmode={inputmode}
|
|
15
16
|
disabled={disabled}
|
|
16
17
|
value={displayValue}
|
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import { api } from 'lwc'
|
|
2
2
|
import { InputElement } from 'fleetcor-lwc'
|
|
3
|
+
import IMask from 'imask'
|
|
3
4
|
import './inputText.scss'
|
|
4
5
|
|
|
6
|
+
const TYPE_NUMBER = 'number'
|
|
7
|
+
const TYPE_TEXT = 'text'
|
|
8
|
+
|
|
5
9
|
export default class InputText extends InputElement {
|
|
6
10
|
focused
|
|
7
11
|
touched
|
|
12
|
+
mask
|
|
13
|
+
|
|
8
14
|
@api prefix
|
|
9
|
-
@api type =
|
|
10
|
-
@api inputmode =
|
|
15
|
+
@api type = TYPE_TEXT
|
|
16
|
+
@api inputmode = TYPE_TEXT
|
|
11
17
|
@api placeholderVisible
|
|
12
18
|
@api errorMessage
|
|
13
19
|
|
|
20
|
+
get htmlInputType() {
|
|
21
|
+
return this.type == TYPE_NUMBER ? TYPE_TEXT : this.type
|
|
22
|
+
}
|
|
23
|
+
|
|
14
24
|
get displayValue() {
|
|
15
25
|
return this.value || ''
|
|
16
26
|
}
|
|
@@ -78,7 +88,7 @@ export default class InputText extends InputElement {
|
|
|
78
88
|
if (this.disabled) {
|
|
79
89
|
event.target.value = ''
|
|
80
90
|
event.preventDefault()
|
|
81
|
-
} else {
|
|
91
|
+
} else if (this.type != TYPE_NUMBER) {
|
|
82
92
|
this.value = event.target.value
|
|
83
93
|
this.dispatchEvent(
|
|
84
94
|
new CustomEvent('change', {
|
|
@@ -91,7 +101,7 @@ export default class InputText extends InputElement {
|
|
|
91
101
|
handleChange(event) {
|
|
92
102
|
if (this.disabled) {
|
|
93
103
|
event.target.value = ''
|
|
94
|
-
} else {
|
|
104
|
+
} else if (this.type != TYPE_NUMBER) {
|
|
95
105
|
this.value = (event.target.value || '').trim()
|
|
96
106
|
event.target.value = this.value
|
|
97
107
|
|
|
@@ -105,4 +115,36 @@ export default class InputText extends InputElement {
|
|
|
105
115
|
event.stopPropagation()
|
|
106
116
|
event.preventDefault()
|
|
107
117
|
}
|
|
118
|
+
|
|
119
|
+
renderedCallback() {
|
|
120
|
+
super.renderedCallback()
|
|
121
|
+
if (this.type == TYPE_NUMBER && !this.mask) {
|
|
122
|
+
this.mask = IMask(this.refs.input, {
|
|
123
|
+
mask: Number, // Enable built-in number mask
|
|
124
|
+
scale: 0, // Number of digits after decimal (0 for integers only)
|
|
125
|
+
signed: false, // Disallow negative numbers
|
|
126
|
+
thousandsSeparator: '',
|
|
127
|
+
padFractionalZeros: false,
|
|
128
|
+
normalizeZeros: true,
|
|
129
|
+
min: 0,
|
|
130
|
+
commit: (value, masked) => {
|
|
131
|
+
this.value = masked._value
|
|
132
|
+
this.dispatchEvent(
|
|
133
|
+
new CustomEvent('change', {
|
|
134
|
+
detail: { ...this.getData(), _onchage: true }
|
|
135
|
+
})
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
this.mask.on('accept', () => {
|
|
141
|
+
this.value = this.mask.value
|
|
142
|
+
this.dispatchEvent(
|
|
143
|
+
new CustomEvent('change', {
|
|
144
|
+
detail: { ...this.getData(), _oninput: true }
|
|
145
|
+
})
|
|
146
|
+
)
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
}
|
|
108
150
|
}
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
<template lwc:render-mode="light">
|
|
2
|
-
<div
|
|
2
|
+
<div
|
|
3
|
+
tabindex="0"
|
|
4
|
+
class={computedStyles}
|
|
5
|
+
onmousedown={handleMousedownView}
|
|
6
|
+
onfocus={handleShowView}
|
|
7
|
+
onblur={handleHideView}
|
|
8
|
+
>
|
|
3
9
|
<div class="flt-picklist__wrapp">
|
|
4
10
|
<div class="flt-picklist__wrapp-text">
|
|
5
11
|
<div lwc:if={placeholderVisible} class="flt-picklist__placeholder">{placeholder}</div>
|
|
@@ -10,13 +16,15 @@
|
|
|
10
16
|
height="24"
|
|
11
17
|
viewBox="0 0 24 24"
|
|
12
18
|
fill="none"
|
|
13
|
-
class="flt-picklist__view-arrow"
|
|
19
|
+
class="flt-picklist__view-arrow"
|
|
20
|
+
>
|
|
14
21
|
<path
|
|
15
22
|
d="M19 9L12 16L5 9"
|
|
16
23
|
stroke-width="2"
|
|
17
24
|
stroke-linecap="round"
|
|
18
25
|
stroke-linejoin="round"
|
|
19
|
-
class="flt-picklist__view-arrow-path"
|
|
26
|
+
class="flt-picklist__view-arrow-path"
|
|
27
|
+
></path>
|
|
20
28
|
</svg>
|
|
21
29
|
</div>
|
|
22
30
|
<div class="flt-picklist__dropdown-container">
|
|
@@ -28,14 +36,16 @@
|
|
|
28
36
|
onclick={handleChange}
|
|
29
37
|
data-value={option.value}
|
|
30
38
|
class="flt-picklist__option flt-picklist__option_selected"
|
|
31
|
-
lwc:inner-html={option.label}
|
|
39
|
+
lwc:inner-html={option.label}
|
|
40
|
+
></div>
|
|
32
41
|
<div
|
|
33
42
|
lwc:else
|
|
34
43
|
onclick={handleChange}
|
|
35
44
|
key={option.value}
|
|
36
45
|
data-value={option.value}
|
|
37
46
|
class="flt-picklist__option"
|
|
38
|
-
lwc:inner-html={option.label}
|
|
47
|
+
lwc:inner-html={option.label}
|
|
48
|
+
></div>
|
|
39
49
|
</template>
|
|
40
50
|
</div>
|
|
41
51
|
</div>
|
|
@@ -75,6 +75,13 @@ export default class Picklist extends SelectElement {
|
|
|
75
75
|
this.querySelector('.flt-picklist').blur()
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
handleMousedownView(event) {
|
|
79
|
+
if (event.currentTarget === document.activeElement) {
|
|
80
|
+
event.currentTarget.blur();
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
78
85
|
handleShowView(event) {
|
|
79
86
|
event.stopPropagation()
|
|
80
87
|
if (!this.disabled) {
|