fleetcor-lwc 2.3.1 → 2.4.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 +66 -1
- package/frontend/common/mixins_amber.scss +27 -2
- package/frontend/common/mixins_aquamarine.scss +25 -0
- package/frontend/components/flt/checkbox/checkbox.scss +4 -2
- package/frontend/components/flt/radioGroup/__test__/radioGroup.test.js +65 -0
- package/frontend/components/flt/radioGroup/radioGroup.html +16 -0
- package/frontend/components/flt/radioGroup/radioGroup.js +31 -0
- package/frontend/components/flt/radioGroup/radioGroup.scss +55 -0
- package/frontend/components/flt/radioItem/__test__/radioItem.test.js +56 -0
- package/frontend/components/flt/radioItem/radioItem.html +6 -0
- package/frontend/components/flt/radioItem/radioItem.js +33 -0
- package/frontend/components/flt/radioItem/radioItem.scss +55 -0
- package/frontend/core/index.js +1 -0
- package/frontend/core/interface/SelectElement.js +45 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -50,6 +50,22 @@ const pathConstants = 'frontend/common/mixins.scss';
|
|
|
50
50
|
|
|
51
51
|
## Components
|
|
52
52
|
|
|
53
|
+
```html
|
|
54
|
+
Radio Group:
|
|
55
|
+
|
|
56
|
+
<flt-radio-group
|
|
57
|
+
size="s"
|
|
58
|
+
name="city"
|
|
59
|
+
disabled="true"
|
|
60
|
+
required="true"
|
|
61
|
+
group="main"
|
|
62
|
+
options="[{label:'London', value:'London'}, {label:'Leon', value:'Leon'}]"
|
|
63
|
+
value="London"
|
|
64
|
+
label="City"
|
|
65
|
+
></flt-radio-group>
|
|
66
|
+
...
|
|
67
|
+
```
|
|
68
|
+
|
|
53
69
|
```html
|
|
54
70
|
Checkbox:
|
|
55
71
|
|
|
@@ -166,7 +182,6 @@ $FLT_BUTTON_LARGE_HEIGHT: var(--flt-button-large-height, 56px);
|
|
|
166
182
|
$FLT_BUTTON_LARGE_FONT_SIZE: var(--flt-button-large-font-size, 15px);
|
|
167
183
|
|
|
168
184
|
$FLT_BUTTON_LABEL_PADDING: var(--flt-button-label-padding, 0);
|
|
169
|
-
|
|
170
185
|
// <- BUTTON
|
|
171
186
|
|
|
172
187
|
// CHECKBOX ->
|
|
@@ -194,10 +209,60 @@ $FLT_CHECKBOX_HOVER_BG_COLOR: var(--flt-checkbox-hover-bg-color, #f9fafb);
|
|
|
194
209
|
$FLT_CHECKBOX_LABEL_HREF_COLOR: var(--flt-checkbox-color, #3782c8);
|
|
195
210
|
$FLT_CHECKBOX_LABEL_HREF_HOVER_COLOR: var(--flt-checkbox-color, #67cdda);
|
|
196
211
|
// <- CHECKBOX
|
|
212
|
+
|
|
213
|
+
// RADIO GROUP ->
|
|
214
|
+
$FLT_RADIO_GROUP_COLOR: var(--flt-radio-group-color, #111827);
|
|
215
|
+
$FLT_RADIO_GROUP_DISABLED_COLOR: var(--flt-radio-group-disabled-color, #6b7280);
|
|
216
|
+
$FLT_RADIO_GROUP_ERROR_COLOR: var(--flt-radio-group-error-color, #ed123d);
|
|
217
|
+
|
|
218
|
+
$FLT_RADIO_GROUP_CIRCLE_COLOR: var(--flt-radio-group-circle-color, #6b7280);
|
|
219
|
+
$FLT_RADIO_GROUP_CIRCLE_BG_COLOR: var(
|
|
220
|
+
--flt-radio-group-circle-bg-color,
|
|
221
|
+
#ffffff
|
|
222
|
+
);
|
|
223
|
+
$FLT_RADIO_GROUP_CIRCLE_HOVER_COLOR: var(
|
|
224
|
+
--flt-radio-group-circle-hover-color,
|
|
225
|
+
#111827
|
|
226
|
+
);
|
|
227
|
+
$FLT_RADIO_GROUP_CIRCLE_DISABLED_COLOR: var(
|
|
228
|
+
--flt-radio-group-circle-disabled-color,
|
|
229
|
+
#9ca3af
|
|
230
|
+
);
|
|
231
|
+
$FLT_RADIO_GROUP_CIRCLE_DISABLED_BG_COLOR: var(
|
|
232
|
+
--flt-radio-group-circle-disabled-bg-color,
|
|
233
|
+
#e5e7eb
|
|
234
|
+
);
|
|
235
|
+
$FLT_RADIO_GROUP_CIRCLE_SELECTED_HOVER_COLOR: var(
|
|
236
|
+
--flt-radio-group-circle-selected-hover-color,
|
|
237
|
+
#59eb9c
|
|
238
|
+
);
|
|
239
|
+
$FLT_RADIO_GROUP_CIRCLE_SELECTED_COLOR: var(
|
|
240
|
+
--flt-radio-group-circle-selected-color,
|
|
241
|
+
#52d990
|
|
242
|
+
);
|
|
243
|
+
$FLT_RADIO_GROUP_CIRCLE_DISABLED_SELECTED_COLOR: var(
|
|
244
|
+
--flt-radio-group-circle-disabled-selected-color,
|
|
245
|
+
#d1d5db
|
|
246
|
+
);
|
|
247
|
+
$FLT_RADIO_GROUP_CIRCLE_DISABLED_SELECTED_BG_COLOR: var(
|
|
248
|
+
--flt-radio-group-circle-disabled-selected-bg-color,
|
|
249
|
+
#ffffff
|
|
250
|
+
);
|
|
251
|
+
// <- RADIO GROUP
|
|
197
252
|
```
|
|
198
253
|
|
|
199
254
|
## Release Notes:
|
|
200
255
|
|
|
256
|
+
- v.2.4.0
|
|
257
|
+
- Added Component `flt-radio-group`
|
|
258
|
+
|
|
259
|
+
---
|
|
260
|
+
|
|
261
|
+
- v.2.3.2
|
|
262
|
+
- Change icon style at checkbox
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
201
266
|
- v.2.3.1
|
|
202
267
|
- Change links at checkbox's label
|
|
203
268
|
|
|
@@ -60,6 +60,31 @@ $FLT_CHECKBOX_DISABLED_AGREE_COLOR: var(--flt-checkbox-agree-color, #9ca3af);
|
|
|
60
60
|
$FLT_CHECKBOX_HOVER_BORDER_COLOR: var(--flt-checkbox-hover-border-color, #111827);
|
|
61
61
|
$FLT_CHECKBOX_HOVER_BG_COLOR: var(--flt-checkbox-hover-bg-color, #f9fafb);
|
|
62
62
|
|
|
63
|
-
$FLT_CHECKBOX_LABEL_HREF_COLOR: var(--flt-checkbox-color, #
|
|
64
|
-
$FLT_CHECKBOX_LABEL_HREF_HOVER_COLOR: var(--flt-checkbox-color, #
|
|
63
|
+
$FLT_CHECKBOX_LABEL_HREF_COLOR: var(--flt-checkbox-color, #ffcd00);
|
|
64
|
+
$FLT_CHECKBOX_LABEL_HREF_HOVER_COLOR: var(--flt-checkbox-color, #ecc300);
|
|
65
65
|
// <- CHECKBOX
|
|
66
|
+
|
|
67
|
+
// RADIO GROUP ->
|
|
68
|
+
$FLT_RADIO_GROUP_COLOR: var(--flt-radio-group-color, #111827);
|
|
69
|
+
$FLT_RADIO_GROUP_DISABLED_COLOR: var(--flt-radio-group-disabled-color, #6b7280);
|
|
70
|
+
$FLT_RADIO_GROUP_ERROR_COLOR: var(--flt-radio-group-error-color, #ed123d);
|
|
71
|
+
|
|
72
|
+
$FLT_RADIO_GROUP_CIRCLE_COLOR: var(--flt-radio-group-circle-color, #6b7280);
|
|
73
|
+
$FLT_RADIO_GROUP_CIRCLE_BG_COLOR: var(--flt-radio-group-circle-bg-color, #ffffff);
|
|
74
|
+
$FLT_RADIO_GROUP_CIRCLE_HOVER_COLOR: var(--flt-radio-group-circle-hover-color, #111827);
|
|
75
|
+
$FLT_RADIO_GROUP_CIRCLE_DISABLED_COLOR: var(--flt-radio-group-circle-disabled-color, #9ca3af);
|
|
76
|
+
$FLT_RADIO_GROUP_CIRCLE_DISABLED_BG_COLOR: var(--flt-radio-group-circle-disabled-bg-color, #e5e7eb);
|
|
77
|
+
$FLT_RADIO_GROUP_CIRCLE_SELECTED_HOVER_COLOR: var(
|
|
78
|
+
--flt-radio-group-circle-selected-hover-color,
|
|
79
|
+
#59eb9c
|
|
80
|
+
);
|
|
81
|
+
$FLT_RADIO_GROUP_CIRCLE_SELECTED_COLOR: var(--flt-radio-group-circle-selected-color, #52d990);
|
|
82
|
+
$FLT_RADIO_GROUP_CIRCLE_DISABLED_SELECTED_COLOR: var(
|
|
83
|
+
--flt-radio-group-circle-disabled-selected-color,
|
|
84
|
+
#d1d5db
|
|
85
|
+
);
|
|
86
|
+
$FLT_RADIO_GROUP_CIRCLE_DISABLED_SELECTED_BG_COLOR: var(
|
|
87
|
+
--flt-radio-group-circle-disabled-selected-bg-color,
|
|
88
|
+
#ffffff
|
|
89
|
+
);
|
|
90
|
+
// <- RADIO GROUP
|
|
@@ -64,3 +64,28 @@ $FLT_CHECKBOX_HOVER_BG_COLOR: var(--flt-checkbox-hover-bg-color, #f9fafb);
|
|
|
64
64
|
$FLT_CHECKBOX_LABEL_HREF_COLOR: var(--flt-checkbox-color, #3782c8);
|
|
65
65
|
$FLT_CHECKBOX_LABEL_HREF_HOVER_COLOR: var(--flt-checkbox-color, #67cdda);
|
|
66
66
|
// <- CHECKBOX
|
|
67
|
+
|
|
68
|
+
// RADIO GROUP ->
|
|
69
|
+
$FLT_RADIO_GROUP_COLOR: var(--flt-radio-group-color, #111827);
|
|
70
|
+
$FLT_RADIO_GROUP_DISABLED_COLOR: var(--flt-radio-group-disabled-color, #6b7280);
|
|
71
|
+
$FLT_RADIO_GROUP_ERROR_COLOR: var(--flt-radio-group-error-color, #ed123d);
|
|
72
|
+
|
|
73
|
+
$FLT_RADIO_GROUP_CIRCLE_COLOR: var(--flt-radio-group-circle-color, #6b7280);
|
|
74
|
+
$FLT_RADIO_GROUP_CIRCLE_BG_COLOR: var(--flt-radio-group-circle-bg-color, #ffffff);
|
|
75
|
+
$FLT_RADIO_GROUP_CIRCLE_HOVER_COLOR: var(--flt-radio-group-circle-hover-color, #111827);
|
|
76
|
+
$FLT_RADIO_GROUP_CIRCLE_DISABLED_COLOR: var(--flt-radio-group-circle-disabled-color, #9ca3af);
|
|
77
|
+
$FLT_RADIO_GROUP_CIRCLE_DISABLED_BG_COLOR: var(--flt-radio-group-circle-disabled-bg-color, #e5e7eb);
|
|
78
|
+
$FLT_RADIO_GROUP_CIRCLE_SELECTED_HOVER_COLOR: var(
|
|
79
|
+
--flt-radio-group-circle-selected-hover-color,
|
|
80
|
+
#59eb9c
|
|
81
|
+
);
|
|
82
|
+
$FLT_RADIO_GROUP_CIRCLE_SELECTED_COLOR: var(--flt-radio-group-circle-selected-color, #52d990);
|
|
83
|
+
$FLT_RADIO_GROUP_CIRCLE_DISABLED_SELECTED_COLOR: var(
|
|
84
|
+
--flt-radio-group-circle-disabled-selected-color,
|
|
85
|
+
#d1d5db
|
|
86
|
+
);
|
|
87
|
+
$FLT_RADIO_GROUP_CIRCLE_DISABLED_SELECTED_BG_COLOR: var(
|
|
88
|
+
--flt-radio-group-circle-disabled-selected-bg-color,
|
|
89
|
+
#ffffff
|
|
90
|
+
);
|
|
91
|
+
// <- RADIO GROUP
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
&__icon {
|
|
57
|
-
|
|
57
|
+
position: relative;
|
|
58
58
|
border: 1px solid $FLT_CHECKBOX_BORDER_COLOR;
|
|
59
59
|
background-color: $FLT_CHECKBOX_BG_COLOR;
|
|
60
60
|
border-radius: 6px;
|
|
@@ -65,7 +65,9 @@
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
&__icon-agree {
|
|
68
|
-
|
|
68
|
+
position: absolute;
|
|
69
|
+
left: 0;
|
|
70
|
+
top: 0;
|
|
69
71
|
width: 100%;
|
|
70
72
|
height: 100%;
|
|
71
73
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { createElement } from 'lwc'
|
|
2
|
+
|
|
3
|
+
import RadioGroup from 'flt/radioGroup'
|
|
4
|
+
|
|
5
|
+
describe('flt-radio-group', () => {
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
while (document.body.firstChild) {
|
|
8
|
+
document.body.removeChild(document.body.firstChild)
|
|
9
|
+
}
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('Generate default radioGroup', async () => {
|
|
13
|
+
const radioGroupDefault = createElement('flt-radio-group', { is: RadioGroup })
|
|
14
|
+
radioGroupDefault.label = 'Hello world'
|
|
15
|
+
radioGroupDefault.required = true
|
|
16
|
+
radioGroupDefault.options = [
|
|
17
|
+
{
|
|
18
|
+
label: 'Man',
|
|
19
|
+
value: 'man'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: 'Woman',
|
|
23
|
+
value: 'woman'
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
radioGroupDefault.name = 'sex'
|
|
27
|
+
document.body.appendChild(radioGroupDefault)
|
|
28
|
+
await expect(radioGroupDefault.firstChild.classList).toContain('flt-radio-group')
|
|
29
|
+
|
|
30
|
+
const errorElement = document.body.querySelector('.flt-radio-group__error-message')
|
|
31
|
+
|
|
32
|
+
await expect(errorElement.classList).not.toContain('flt-radio-group__error-message_active')
|
|
33
|
+
|
|
34
|
+
let items = radioGroupDefault.firstChild.querySelectorAll('flt-radio-item')
|
|
35
|
+
await expect(items.length).toBe(2)
|
|
36
|
+
let data = radioGroupDefault.getData()
|
|
37
|
+
await expect(data.value).toBeUndefined()
|
|
38
|
+
await expect(errorElement.classList).toContain('flt-radio-group__error-message_active')
|
|
39
|
+
items[0].querySelector('.flt-radio-item').click()
|
|
40
|
+
data = radioGroupDefault.getData()
|
|
41
|
+
await expect(data.value).toBe('man')
|
|
42
|
+
await expect(errorElement.classList).not.toContain('flt-radio-group__error-message_active')
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
it('Generate default radioGroup', async () => {
|
|
46
|
+
const radioGroupDefault = createElement('flt-radio-group', { is: RadioGroup })
|
|
47
|
+
radioGroupDefault.label = 'Hello world'
|
|
48
|
+
radioGroupDefault.disabled = true
|
|
49
|
+
radioGroupDefault.options = [
|
|
50
|
+
{
|
|
51
|
+
label: 'Man',
|
|
52
|
+
value: 'man'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
label: 'Woman',
|
|
56
|
+
value: 'woman'
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
radioGroupDefault.name = 'sex'
|
|
60
|
+
document.body.appendChild(radioGroupDefault)
|
|
61
|
+
|
|
62
|
+
const item = radioGroupDefault.firstChild.querySelector('flt-radio-item')
|
|
63
|
+
await expect(item.option.disabled).toBeTruthy()
|
|
64
|
+
})
|
|
65
|
+
})
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<template lwc:render-mode="light">
|
|
2
|
+
<div class="flt-radio-group">
|
|
3
|
+
<div class="flt-radio-group__title">{label}</div>
|
|
4
|
+
<div class="flt-radio-group__items">
|
|
5
|
+
<template for:each={optionsToDisplay} for:item="option">
|
|
6
|
+
<flt-radio-item
|
|
7
|
+
key={option.key}
|
|
8
|
+
class="flt-radio-group__item"
|
|
9
|
+
size={size}
|
|
10
|
+
option={option}
|
|
11
|
+
onchange={handleChange}></flt-radio-item>
|
|
12
|
+
</template>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
<div class={computedErrorMessage}>{errorMessage}</div>
|
|
16
|
+
</template>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import './radioGroup.scss'
|
|
2
|
+
|
|
3
|
+
import { api } from 'lwc'
|
|
4
|
+
import { SelectElement } from 'fleetcor-lwc'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @class RadioGroup
|
|
8
|
+
* @extends SelectElement
|
|
9
|
+
* @description Flt Radio Group component
|
|
10
|
+
*/
|
|
11
|
+
export default class RadioGroup extends SelectElement {
|
|
12
|
+
error
|
|
13
|
+
|
|
14
|
+
@api size = SIZES.SMALL
|
|
15
|
+
@api errorMessage
|
|
16
|
+
|
|
17
|
+
@api validate() {
|
|
18
|
+
this.error = !this.isValid()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get computedErrorMessage() {
|
|
22
|
+
return this.generateClassNameList({
|
|
23
|
+
'flt-radio-group__error-message': true,
|
|
24
|
+
'flt-radio-group__error-message_active': this.error
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const SIZES = {
|
|
30
|
+
SMALL: 's'
|
|
31
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
@import './../../../common/mixins_aquamarine';
|
|
2
|
+
/* mixins */
|
|
3
|
+
|
|
4
|
+
.flt-radio-group {
|
|
5
|
+
@media (min-width: 768px) {
|
|
6
|
+
display: flex;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
&__title {
|
|
10
|
+
font-weight: 600;
|
|
11
|
+
color: $FLT_RADIO_GROUP_COLOR;
|
|
12
|
+
font-size: 15px;
|
|
13
|
+
line-height: 20px;
|
|
14
|
+
margin-bottom: 0.25rem;
|
|
15
|
+
|
|
16
|
+
@media (min-width: 768px) {
|
|
17
|
+
margin-bottom: 0;
|
|
18
|
+
flex-shrink: 0;
|
|
19
|
+
margin-right: 2rem;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&__items {
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
|
|
27
|
+
@media (min-width: 768px) {
|
|
28
|
+
flex-direction: row;
|
|
29
|
+
flex-wrap: wrap;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
&__item {
|
|
34
|
+
display: inline-block;
|
|
35
|
+
margin: 0.5rem 0;
|
|
36
|
+
margin-right: 2.5rem;
|
|
37
|
+
|
|
38
|
+
@media (min-width: 768px) {
|
|
39
|
+
margin-top: 0;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
&__error-message {
|
|
44
|
+
color: $FLT_RADIO_GROUP_ERROR_COLOR;
|
|
45
|
+
opacity: 0;
|
|
46
|
+
line-height: 0;
|
|
47
|
+
transition: all 0.3s;
|
|
48
|
+
font-size: 12px;
|
|
49
|
+
|
|
50
|
+
&_active {
|
|
51
|
+
opacity: 1;
|
|
52
|
+
line-height: 1.5;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { createElement } from 'lwc'
|
|
2
|
+
|
|
3
|
+
import RadioItem from 'flt/radioItem'
|
|
4
|
+
|
|
5
|
+
describe('flt-radio-item', () => {
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
while (document.body.firstChild) {
|
|
8
|
+
document.body.removeChild(document.body.firstChild)
|
|
9
|
+
}
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('Generate active radio item', async () => {
|
|
13
|
+
const radioItemDefault = createElement('flt-radio-item', { is: RadioItem })
|
|
14
|
+
radioItemDefault.option = {
|
|
15
|
+
label: 'Label 1',
|
|
16
|
+
value: 'value 1',
|
|
17
|
+
selected: true,
|
|
18
|
+
disabled: false
|
|
19
|
+
}
|
|
20
|
+
document.body.appendChild(radioItemDefault)
|
|
21
|
+
|
|
22
|
+
await expect(radioItemDefault.firstChild.classList).toContain('flt-radio-item_selected')
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
it('Generate default radio item', async () => {
|
|
26
|
+
const radioItemDefault = createElement('flt-radio-item', { is: RadioItem })
|
|
27
|
+
radioItemDefault.option = {
|
|
28
|
+
label: 'Label 1',
|
|
29
|
+
value: 'value 1',
|
|
30
|
+
selected: false,
|
|
31
|
+
disabled: false
|
|
32
|
+
}
|
|
33
|
+
document.body.appendChild(radioItemDefault)
|
|
34
|
+
|
|
35
|
+
await expect(radioItemDefault.firstChild.classList).toContain('flt-radio-item')
|
|
36
|
+
await expect(radioItemDefault.firstChild.classList).toContain('flt-radio-item_size_s')
|
|
37
|
+
await expect(radioItemDefault.firstChild.classList).not.toContain('flt-radio-item_disabled')
|
|
38
|
+
await expect(radioItemDefault.firstChild.classList).not.toContain('flt-radio-item_selected')
|
|
39
|
+
|
|
40
|
+
await radioItemDefault.firstChild.click()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('Generate disabled radio item', async () => {
|
|
44
|
+
const radioItemDefault = createElement('flt-radio-item', { is: RadioItem })
|
|
45
|
+
radioItemDefault.option = {
|
|
46
|
+
label: 'Label 1',
|
|
47
|
+
value: 'value 1',
|
|
48
|
+
selected: false,
|
|
49
|
+
disabled: true
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
document.body.appendChild(radioItemDefault)
|
|
53
|
+
|
|
54
|
+
await expect(radioItemDefault.firstChild.classList).toContain('flt-radio-item_disabled')
|
|
55
|
+
})
|
|
56
|
+
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import './radioItem.scss'
|
|
2
|
+
|
|
3
|
+
import { api } from 'lwc'
|
|
4
|
+
import { BaseElement } from 'fleetcor-lwc'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @class RadioItem
|
|
8
|
+
* @extends BaseElement
|
|
9
|
+
* @description Flt Radio Item component
|
|
10
|
+
*/
|
|
11
|
+
export default class RadioItem extends BaseElement {
|
|
12
|
+
@api option
|
|
13
|
+
@api size = SIZES.SMALL
|
|
14
|
+
|
|
15
|
+
get styleClass() {
|
|
16
|
+
return this.generateClassNameList({
|
|
17
|
+
'flt-radio-item': true,
|
|
18
|
+
[`flt-radio-item_size_${this.size}`]: true,
|
|
19
|
+
'flt-radio-item_selected': this.option.selected,
|
|
20
|
+
'flt-radio-item_disabled': this.option.disabled
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
handleClick() {
|
|
25
|
+
if (!this.option.disabled || !this.option.selected) {
|
|
26
|
+
this.dispatchEvent(new CustomEvent('change', { detail: { ...this.option } }))
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const SIZES = {
|
|
32
|
+
SMALL: 's'
|
|
33
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
@import './../../../common/mixins_aquamarine';
|
|
2
|
+
/* mixins */
|
|
3
|
+
|
|
4
|
+
.flt-radio-item {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
cursor: pointer;
|
|
8
|
+
|
|
9
|
+
&:hover:not(.flt-radio-item_disabled) &__circle {
|
|
10
|
+
border-color: $FLT_RADIO_GROUP_CIRCLE_HOVER_COLOR;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&:hover:not(.flt-radio-item_disabled).flt-radio-item_selected &__circle {
|
|
14
|
+
border-color: $FLT_RADIO_GROUP_CIRCLE_SELECTED_HOVER_COLOR;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&_selected &__circle {
|
|
18
|
+
border: 5px solid $FLT_RADIO_GROUP_CIRCLE_SELECTED_COLOR;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&_disabled {
|
|
22
|
+
cursor: not-allowed;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&_disabled &__label {
|
|
26
|
+
color: $FLT_RADIO_GROUP_DISABLED_COLOR;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&_disabled &__circle {
|
|
30
|
+
border-color: $FLT_RADIO_GROUP_CIRCLE_DISABLED_COLOR;
|
|
31
|
+
background-color: $FLT_RADIO_GROUP_CIRCLE_DISABLED_BG_COLOR;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&_selected.flt-radio-item_disabled &__circle {
|
|
35
|
+
border-color: $FLT_RADIO_GROUP_CIRCLE_DISABLED_SELECTED_COLOR;
|
|
36
|
+
background-color: $FLT_RADIO_GROUP_CIRCLE_DISABLED_SELECTED_BG_COLOR;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&__label {
|
|
40
|
+
line-height: 20px;
|
|
41
|
+
font-size: 15px;
|
|
42
|
+
color: $FLT_RADIO_GROUP_COLOR;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
&__circle {
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
border: 1px solid $FLT_RADIO_GROUP_CIRCLE_COLOR;
|
|
48
|
+
width: 20px;
|
|
49
|
+
height: 20px;
|
|
50
|
+
transition: all 0.3s;
|
|
51
|
+
background-color: #ffffff;
|
|
52
|
+
margin-right: 1rem;
|
|
53
|
+
border-radius: 100%;
|
|
54
|
+
}
|
|
55
|
+
}
|
package/frontend/core/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { default as BaseElement } from './interface/BaseElement'
|
|
|
4
4
|
export { default as UserDataManager } from './interface/UserDataManager'
|
|
5
5
|
export { default as UserDataValidator } from './interface/UserDataValidator'
|
|
6
6
|
export { default as CheckboxElement } from './interface/CheckboxElement'
|
|
7
|
+
export { default as SelectElement } from './interface/SelectElement'
|
|
7
8
|
|
|
8
9
|
// ERROR
|
|
9
10
|
export * from './error/errors'
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { api } from 'lwc'
|
|
2
|
+
import { UserDataValidator } from 'fleetcor-lwc'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @abstract
|
|
6
|
+
* @class SelectElement
|
|
7
|
+
* @extends UserDataValidator
|
|
8
|
+
* @description This class is used to select item
|
|
9
|
+
*/
|
|
10
|
+
export default class SelectElement extends UserDataValidator {
|
|
11
|
+
@api options
|
|
12
|
+
|
|
13
|
+
@api isValid() {
|
|
14
|
+
return this.required ? !!this.value : true
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get optionsToDisplay() {
|
|
18
|
+
let result = []
|
|
19
|
+
|
|
20
|
+
if (this.options?.length) {
|
|
21
|
+
result = this.options.map((item) => {
|
|
22
|
+
return {
|
|
23
|
+
label: item.label,
|
|
24
|
+
key: `${this.name}_${item.value}`,
|
|
25
|
+
disabled: this.disabled,
|
|
26
|
+
value: item.value,
|
|
27
|
+
selected: this.value === item.value
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
return result
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
handleChange(event) {
|
|
35
|
+
event.stopPropagation()
|
|
36
|
+
if (!this.disabled) {
|
|
37
|
+
this.value = event.detail.value
|
|
38
|
+
this.dispatchEvent(
|
|
39
|
+
new CustomEvent('change', {
|
|
40
|
+
detail: this.getData()
|
|
41
|
+
})
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetcor-lwc",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "LWC framework by Fleetcor",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,9 +28,10 @@
|
|
|
28
28
|
}
|
|
29
29
|
],
|
|
30
30
|
"expose": [
|
|
31
|
-
"flt/checkbox",
|
|
32
31
|
"flt/button",
|
|
32
|
+
"flt/checkbox",
|
|
33
33
|
"flt/icon",
|
|
34
|
+
"flt/radioGroup",
|
|
34
35
|
"flt/tooltip"
|
|
35
36
|
]
|
|
36
37
|
},
|