fleetcor-lwc 2.0.1 → 2.2.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.
- package/README.md +78 -7
- package/frontend/common/mixins_amber.scss +26 -2
- package/frontend/common/mixins_aquamarine.scss +25 -0
- package/frontend/components/flt/button/__test__/button.test.js +11 -0
- package/frontend/components/flt/button/button.js +2 -0
- package/frontend/components/flt/button/button.scss +22 -0
- package/frontend/components/flt/checkbox/__test__/checkbox.test.js +76 -0
- package/frontend/components/flt/checkbox/checkbox.html +29 -0
- package/frontend/components/flt/checkbox/checkbox.js +51 -0
- package/frontend/components/flt/checkbox/checkbox.scss +97 -0
- package/frontend/core/interface/CheckboxElement.js +18 -1
- package/frontend/core/interface/UserDataManager.js +6 -0
- package/loader/index.js +10 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -50,11 +50,27 @@ const pathConstants = 'frontend/common/mixins.scss';
|
|
|
50
50
|
|
|
51
51
|
## Components
|
|
52
52
|
|
|
53
|
+
```html
|
|
54
|
+
Checkbox:
|
|
55
|
+
|
|
56
|
+
<flt-checkbox
|
|
57
|
+
size="s"
|
|
58
|
+
name="agreement"
|
|
59
|
+
disabled="true"
|
|
60
|
+
required="true"
|
|
61
|
+
group="main"
|
|
62
|
+
value="true"
|
|
63
|
+
label="Next"
|
|
64
|
+
></flt-checkbox>
|
|
65
|
+
...
|
|
66
|
+
```
|
|
67
|
+
|
|
53
68
|
```html
|
|
54
69
|
Button:
|
|
55
70
|
|
|
56
71
|
<flt-button
|
|
57
|
-
type="base|primary|link"
|
|
72
|
+
type="base|primary|secondary|link"
|
|
73
|
+
size="xs|small|medium|large"
|
|
58
74
|
icon-left="arrow-left|arrow-right|..."
|
|
59
75
|
icon-right="arrow-left|arrow-right|..."
|
|
60
76
|
disabled
|
|
@@ -93,13 +109,13 @@ $FLT_TOOLTIP_BG_COLOR: var(--flt-tooltip-bg-color, #374151);
|
|
|
93
109
|
$FLT_TOOLTIP_COLOR: var(--flt-tooltip-bg-color, #f9fafb);
|
|
94
110
|
// <- TOOLTIP
|
|
95
111
|
|
|
96
|
-
|
|
112
|
+
// ICON ->
|
|
97
113
|
$FLT_ICON_COLOR: var(--flt-icon-color, #111827);
|
|
98
|
-
|
|
114
|
+
// <- ICON
|
|
99
115
|
|
|
100
|
-
|
|
101
|
-
$FLT_BUTTON_PRIMARY_BG_COLOR: var(--flt-button-primary-bg-color, #
|
|
102
|
-
$FLT_BUTTON_PRIMARY_COLOR: var(--flt-button-primary-color, #
|
|
116
|
+
// BUTTON ->
|
|
117
|
+
$FLT_BUTTON_PRIMARY_BG_COLOR: var(--flt-button-primary-bg-color, #3782c8);
|
|
118
|
+
$FLT_BUTTON_PRIMARY_COLOR: var(--flt-button-primary-color, #f9fafb);
|
|
103
119
|
$FLT_BUTTON_PRIMARY_DISABLED_COLOR: var(
|
|
104
120
|
--flt-button-primary-disabled-color,
|
|
105
121
|
#6b7280
|
|
@@ -109,6 +125,17 @@ $FLT_BUTTON_PRIMARY_DISABLED_BG_COLOR: var(
|
|
|
109
125
|
#f3f4f6
|
|
110
126
|
);
|
|
111
127
|
|
|
128
|
+
$FLT_BUTTON_SECONDARY_BG_COLOR: var(--flt-button-secondary-bg-color, #f2d400);
|
|
129
|
+
$FLT_BUTTON_SECONDARY_COLOR: var(--flt-button-secondary-color, #111827);
|
|
130
|
+
$FLT_BUTTON_SECONDARY_DISABLED_COLOR: var(
|
|
131
|
+
--flt-button-secondary-disabled-color,
|
|
132
|
+
#6b7280
|
|
133
|
+
);
|
|
134
|
+
$FLT_BUTTON_SECONDARY_DISABLED_BG_COLOR: var(
|
|
135
|
+
--flt-button-secondary-disabled-bg-color,
|
|
136
|
+
#f3f4f6
|
|
137
|
+
);
|
|
138
|
+
|
|
112
139
|
$FLT_BUTTON_BASE_BG_COLOR: var(--flt-button-base-bg-color, #ffffff);
|
|
113
140
|
$FLT_BUTTON_BASE_COLOR: var(--flt-button-base-color, #111827);
|
|
114
141
|
$FLT_BUTTON_BASE_BORDER_COLOR: var(--flt-button-base-border-color, #111827);
|
|
@@ -126,6 +153,9 @@ $FLT_BUTTON_LINK_COLOR: var(--flt-button-link-color, #111827);
|
|
|
126
153
|
$FLT_BUTTON_LINK_DISABLED_COLOR: var(--flt-button-link-disabled-color, #9ca3af);
|
|
127
154
|
$FLT_BUTTON_LINK_HOVER_COLOR: var(--flt-button-link-hover-color, #6b7280);
|
|
128
155
|
|
|
156
|
+
$FLT_BUTTON_X_SMALL_HEIGHT: var(--flt-button-x-small-height, 40px);
|
|
157
|
+
$FLT_BUTTON_X_SMALL_FONT_SIZE: var(--flt-button-x-small-font-size, 14px);
|
|
158
|
+
|
|
129
159
|
$FLT_BUTTON_SMALL_HEIGHT: var(--flt-button-small-height, 44px);
|
|
130
160
|
$FLT_BUTTON_SMALL_FONT_SIZE: var(--flt-button-small-font-size, 14px);
|
|
131
161
|
|
|
@@ -137,11 +167,51 @@ $FLT_BUTTON_LARGE_FONT_SIZE: var(--flt-button-large-font-size, 15px);
|
|
|
137
167
|
|
|
138
168
|
$FLT_BUTTON_LABEL_PADDING: var(--flt-button-label-padding, 0);
|
|
139
169
|
|
|
140
|
-
|
|
170
|
+
// <- BUTTON
|
|
171
|
+
|
|
172
|
+
// CHECKBOX ->
|
|
173
|
+
$FLT_CHECKBOX_BORDER_COLOR: var(--flt-checkbox-border-color, #6b7280);
|
|
174
|
+
$FLT_CHECKBOX_BG_COLOR: var(--flt-checkbox-bg-color, #ffffff);
|
|
175
|
+
|
|
176
|
+
$FLT_CHECKBOX_AGREE_COLOR: var(--flt-checkbox-agree-color, #59eb9c);
|
|
177
|
+
$FLT_CHECKBOX_COLOR: var(--flt-checkbox-color, #111827);
|
|
178
|
+
$FLT_CHECKBOX_ERROR_COLOR: var(--flt-checkbox-error-color, #ed123d);
|
|
179
|
+
|
|
180
|
+
$FLT_CHECKBOX_DISABLED_COLOR: var(--flt-checkbox-disabled-color, #6b7280);
|
|
181
|
+
$FLT_CHECKBOX_DISABLED_BORDER_COLOR: var(
|
|
182
|
+
--flt-checkbox-disabled-border-color,
|
|
183
|
+
#6b7280
|
|
184
|
+
);
|
|
185
|
+
$FLT_CHECKBOX_DISABLED_BG_COLOR: var(--flt-checkbox-disabled-bg-color, #e5e7eb);
|
|
186
|
+
$FLT_CHECKBOX_DISABLED_AGREE_COLOR: var(--flt-checkbox-agree-color, #9ca3af);
|
|
187
|
+
|
|
188
|
+
$FLT_CHECKBOX_HOVER_BORDER_COLOR: var(
|
|
189
|
+
--flt-checkbox-hover-border-color,
|
|
190
|
+
#111827
|
|
191
|
+
);
|
|
192
|
+
$FLT_CHECKBOX_HOVER_BG_COLOR: var(--flt-checkbox-hover-bg-color, #f9fafb);
|
|
193
|
+
// <- CHECKBOX
|
|
141
194
|
```
|
|
142
195
|
|
|
143
196
|
## Release Notes:
|
|
144
197
|
|
|
198
|
+
- v.2.2.1
|
|
199
|
+
- Bug fix expose flt/checkbox
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
- v.2.2.0
|
|
204
|
+
- Added Component `flt-checkbox`
|
|
205
|
+
|
|
206
|
+
---
|
|
207
|
+
|
|
208
|
+
- v.2.1.1
|
|
209
|
+
- Added to `Button` new type `secondary`
|
|
210
|
+
- Added to `Button` new size `xs`
|
|
211
|
+
- Bug fix `loader`, now you can override available theme with mixins
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
145
215
|
- v.2.0.1
|
|
146
216
|
- Bug fix export loader
|
|
147
217
|
|
|
@@ -163,6 +233,7 @@ $FLT_BUTTON_LABEL_PADDING: var(--flt-button-label-padding, 0);
|
|
|
163
233
|
- Small refactoring in all components
|
|
164
234
|
|
|
165
235
|
---
|
|
236
|
+
|
|
166
237
|
- v.1.6.0
|
|
167
238
|
- Added new extendable components: `BaseElement` and `LightningDomElement`
|
|
168
239
|
|
|
@@ -8,11 +8,16 @@ $FLT_ICON_COLOR: var(--flt-icon-color, #111827);
|
|
|
8
8
|
// <- ICON
|
|
9
9
|
|
|
10
10
|
// BUTTON ->
|
|
11
|
-
$FLT_BUTTON_PRIMARY_BG_COLOR: var(--flt-button-primary-bg-color, #
|
|
11
|
+
$FLT_BUTTON_PRIMARY_BG_COLOR: var(--flt-button-primary-bg-color, #59eb9c);
|
|
12
12
|
$FLT_BUTTON_PRIMARY_COLOR: var(--flt-button-primary-color, #111827);
|
|
13
13
|
$FLT_BUTTON_PRIMARY_DISABLED_COLOR: var(--flt-button-primary-disabled-color, #6b7280);
|
|
14
14
|
$FLT_BUTTON_PRIMARY_DISABLED_BG_COLOR: var(--flt-button-primary-disabled-bg-color, #f3f4f6);
|
|
15
15
|
|
|
16
|
+
$FLT_BUTTON_SECONDARY_BG_COLOR: var(--flt-button-secondary-bg-color, #f2d400);
|
|
17
|
+
$FLT_BUTTON_SECONDARY_COLOR: var(--flt-button-secondary-color, #111827);
|
|
18
|
+
$FLT_BUTTON_SECONDARY_DISABLED_COLOR: var(--flt-button-secondary-disabled-color, #6b7280);
|
|
19
|
+
$FLT_BUTTON_SECONDARY_DISABLED_BG_COLOR: var(--flt-button-secondary-disabled-bg-color, #f3f4f6);
|
|
20
|
+
|
|
16
21
|
$FLT_BUTTON_BASE_BG_COLOR: var(--flt-button-base-bg-color, #ffffff);
|
|
17
22
|
$FLT_BUTTON_BASE_COLOR: var(--flt-button-base-color, #111827);
|
|
18
23
|
$FLT_BUTTON_BASE_BORDER_COLOR: var(--flt-button-base-border-color, #111827);
|
|
@@ -24,6 +29,9 @@ $FLT_BUTTON_LINK_COLOR: var(--flt-button-link-color, #111827);
|
|
|
24
29
|
$FLT_BUTTON_LINK_DISABLED_COLOR: var(--flt-button-link-disabled-color, #9ca3af);
|
|
25
30
|
$FLT_BUTTON_LINK_HOVER_COLOR: var(--flt-button-link-hover-color, #6b7280);
|
|
26
31
|
|
|
32
|
+
$FLT_BUTTON_X_SMALL_HEIGHT: var(--flt-button-x-small-height, 40px);
|
|
33
|
+
$FLT_BUTTON_X_SMALL_FONT_SIZE: var(--flt-button-x-small-font-size, 14px);
|
|
34
|
+
|
|
27
35
|
$FLT_BUTTON_SMALL_HEIGHT: var(--flt-button-small-height, 44px);
|
|
28
36
|
$FLT_BUTTON_SMALL_FONT_SIZE: var(--flt-button-small-font-size, 14px);
|
|
29
37
|
|
|
@@ -34,5 +42,21 @@ $FLT_BUTTON_LARGE_HEIGHT: var(--flt-button-large-height, 56px);
|
|
|
34
42
|
$FLT_BUTTON_LARGE_FONT_SIZE: var(--flt-button-large-font-size, 15px);
|
|
35
43
|
|
|
36
44
|
$FLT_BUTTON_LABEL_PADDING: var(--flt-button-label-padding, 0);
|
|
37
|
-
|
|
38
45
|
// <- BUTTON
|
|
46
|
+
|
|
47
|
+
// CHECKBOX ->
|
|
48
|
+
$FLT_CHECKBOX_BORDER_COLOR: var(--flt-checkbox-border-color, #6b7280);
|
|
49
|
+
$FLT_CHECKBOX_BG_COLOR: var(--flt-checkbox-bg-color, #ffffff);
|
|
50
|
+
|
|
51
|
+
$FLT_CHECKBOX_AGREE_COLOR: var(--flt-checkbox-agree-color, #59eb9c);
|
|
52
|
+
$FLT_CHECKBOX_COLOR: var(--flt-checkbox-color, #111827);
|
|
53
|
+
$FLT_CHECKBOX_ERROR_COLOR: var(--flt-checkbox-error-color, #ed123d);
|
|
54
|
+
|
|
55
|
+
$FLT_CHECKBOX_DISABLED_COLOR: var(--flt-checkbox-disabled-color, #6b7280);
|
|
56
|
+
$FLT_CHECKBOX_DISABLED_BORDER_COLOR: var(--flt-checkbox-disabled-border-color, #6b7280);
|
|
57
|
+
$FLT_CHECKBOX_DISABLED_BG_COLOR: var(--flt-checkbox-disabled-bg-color, #e5e7eb);
|
|
58
|
+
$FLT_CHECKBOX_DISABLED_AGREE_COLOR: var(--flt-checkbox-agree-color, #9ca3af);
|
|
59
|
+
|
|
60
|
+
$FLT_CHECKBOX_HOVER_BORDER_COLOR: var(--flt-checkbox-hover-border-color, #111827);
|
|
61
|
+
$FLT_CHECKBOX_HOVER_BG_COLOR: var(--flt-checkbox-hover-bg-color, #f9fafb);
|
|
62
|
+
// <- CHECKBOX
|
|
@@ -13,6 +13,11 @@ $FLT_BUTTON_PRIMARY_COLOR: var(--flt-button-primary-color, #f9fafb);
|
|
|
13
13
|
$FLT_BUTTON_PRIMARY_DISABLED_COLOR: var(--flt-button-primary-disabled-color, #6b7280);
|
|
14
14
|
$FLT_BUTTON_PRIMARY_DISABLED_BG_COLOR: var(--flt-button-primary-disabled-bg-color, #f3f4f6);
|
|
15
15
|
|
|
16
|
+
$FLT_BUTTON_SECONDARY_BG_COLOR: var(--flt-button-secondary-bg-color, #f2d400);
|
|
17
|
+
$FLT_BUTTON_SECONDARY_COLOR: var(--flt-button-secondary-color, #111827);
|
|
18
|
+
$FLT_BUTTON_SECONDARY_DISABLED_COLOR: var(--flt-button-secondary-disabled-color, #6b7280);
|
|
19
|
+
$FLT_BUTTON_SECONDARY_DISABLED_BG_COLOR: var(--flt-button-secondary-disabled-bg-color, #f3f4f6);
|
|
20
|
+
|
|
16
21
|
$FLT_BUTTON_BASE_BG_COLOR: var(--flt-button-base-bg-color, #ffffff);
|
|
17
22
|
$FLT_BUTTON_BASE_COLOR: var(--flt-button-base-color, #111827);
|
|
18
23
|
$FLT_BUTTON_BASE_BORDER_COLOR: var(--flt-button-base-border-color, #111827);
|
|
@@ -24,6 +29,9 @@ $FLT_BUTTON_LINK_COLOR: var(--flt-button-link-color, #111827);
|
|
|
24
29
|
$FLT_BUTTON_LINK_DISABLED_COLOR: var(--flt-button-link-disabled-color, #9ca3af);
|
|
25
30
|
$FLT_BUTTON_LINK_HOVER_COLOR: var(--flt-button-link-hover-color, #6b7280);
|
|
26
31
|
|
|
32
|
+
$FLT_BUTTON_X_SMALL_HEIGHT: var(--flt-button-x-small-height, 40px);
|
|
33
|
+
$FLT_BUTTON_X_SMALL_FONT_SIZE: var(--flt-button-x-small-font-size, 14px);
|
|
34
|
+
|
|
27
35
|
$FLT_BUTTON_SMALL_HEIGHT: var(--flt-button-small-height, 44px);
|
|
28
36
|
$FLT_BUTTON_SMALL_FONT_SIZE: var(--flt-button-small-font-size, 14px);
|
|
29
37
|
|
|
@@ -36,3 +44,20 @@ $FLT_BUTTON_LARGE_FONT_SIZE: var(--flt-button-large-font-size, 15px);
|
|
|
36
44
|
$FLT_BUTTON_LABEL_PADDING: var(--flt-button-label-padding, 0);
|
|
37
45
|
|
|
38
46
|
// <- BUTTON
|
|
47
|
+
|
|
48
|
+
// CHECKBOX ->
|
|
49
|
+
$FLT_CHECKBOX_BORDER_COLOR: var(--flt-checkbox-border-color, #6b7280);
|
|
50
|
+
$FLT_CHECKBOX_BG_COLOR: var(--flt-checkbox-bg-color, #ffffff);
|
|
51
|
+
|
|
52
|
+
$FLT_CHECKBOX_AGREE_COLOR: var(--flt-checkbox-agree-color, #59eb9c);
|
|
53
|
+
$FLT_CHECKBOX_COLOR: var(--flt-checkbox-color, #111827);
|
|
54
|
+
$FLT_CHECKBOX_ERROR_COLOR: var(--flt-checkbox-error-color, #ed123d);
|
|
55
|
+
|
|
56
|
+
$FLT_CHECKBOX_DISABLED_COLOR: var(--flt-checkbox-disabled-color, #6b7280);
|
|
57
|
+
$FLT_CHECKBOX_DISABLED_BORDER_COLOR: var(--flt-checkbox-disabled-border-color, #6b7280);
|
|
58
|
+
$FLT_CHECKBOX_DISABLED_BG_COLOR: var(--flt-checkbox-disabled-bg-color, #e5e7eb);
|
|
59
|
+
$FLT_CHECKBOX_DISABLED_AGREE_COLOR: var(--flt-checkbox-agree-color, #9ca3af);
|
|
60
|
+
|
|
61
|
+
$FLT_CHECKBOX_HOVER_BORDER_COLOR: var(--flt-checkbox-hover-border-color, #111827);
|
|
62
|
+
$FLT_CHECKBOX_HOVER_BG_COLOR: var(--flt-checkbox-hover-bg-color, #f9fafb);
|
|
63
|
+
// <- CHECKBOX
|
|
@@ -30,6 +30,17 @@ describe('flt-button', () => {
|
|
|
30
30
|
expect(buttonSmallPrimary.firstChild.classList).toContain('flt-button_small')
|
|
31
31
|
expect(buttonSmallPrimary.firstChild.classList).not.toContain('flt-button_disabled')
|
|
32
32
|
|
|
33
|
+
const buttonXSmallSecondary = createElement('flt-button', { is: Button })
|
|
34
|
+
buttonXSmallSecondary.label = 'Small Primary'
|
|
35
|
+
buttonXSmallSecondary.type = 'secondary'
|
|
36
|
+
buttonXSmallSecondary.size = 'xs'
|
|
37
|
+
document.body.appendChild(buttonXSmallSecondary)
|
|
38
|
+
|
|
39
|
+
expect(buttonXSmallSecondary.firstChild.classList).toContain('flt-button')
|
|
40
|
+
expect(buttonXSmallSecondary.firstChild.classList).toContain('flt-button_secondary')
|
|
41
|
+
expect(buttonXSmallSecondary.firstChild.classList).toContain('flt-button_x-small')
|
|
42
|
+
expect(buttonXSmallSecondary.firstChild.classList).not.toContain('flt-button_disabled')
|
|
43
|
+
|
|
33
44
|
const buttonMediumBaseDisabled = createElement('flt-button', { is: Button })
|
|
34
45
|
buttonMediumBaseDisabled.label = 'Medium Base Disabled'
|
|
35
46
|
buttonMediumBaseDisabled.type = 'base'
|
|
@@ -30,6 +30,7 @@ export default class Button extends BaseElement {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
const SIZES = {
|
|
33
|
+
xs: 'x-small',
|
|
33
34
|
small: 'small',
|
|
34
35
|
medium: 'medium',
|
|
35
36
|
large: 'large'
|
|
@@ -37,6 +38,7 @@ const SIZES = {
|
|
|
37
38
|
|
|
38
39
|
const TYPES = {
|
|
39
40
|
primary: 'primary',
|
|
41
|
+
secondary: 'secondary',
|
|
40
42
|
base: 'base',
|
|
41
43
|
link: 'link'
|
|
42
44
|
}
|
|
@@ -72,6 +72,23 @@ button {
|
|
|
72
72
|
@include flt-icon-path($FLT_BUTTON_PRIMARY_COLOR);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
+
&_secondary[disabled] {
|
|
76
|
+
cursor: not-allowed;
|
|
77
|
+
color: $FLT_BUTTON_SECONDARY_DISABLED_COLOR;
|
|
78
|
+
background-color: $FLT_BUTTON_SECONDARY_DISABLED_BG_COLOR;
|
|
79
|
+
|
|
80
|
+
@include flt-icon-path($FLT_BUTTON_PRIMARY_DISABLED_COLOR);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&_secondary:not([disabled]) {
|
|
84
|
+
color: $FLT_BUTTON_SECONDARY_COLOR;
|
|
85
|
+
background-color: $FLT_BUTTON_SECONDARY_BG_COLOR;
|
|
86
|
+
transition: all 0.3s;
|
|
87
|
+
|
|
88
|
+
@include flt-button-hover();
|
|
89
|
+
@include flt-icon-path($FLT_BUTTON_SECONDARY_COLOR);
|
|
90
|
+
}
|
|
91
|
+
|
|
75
92
|
&_base:not([disabled]) {
|
|
76
93
|
color: $FLT_BUTTON_BASE_COLOR;
|
|
77
94
|
background-color: $FLT_BUTTON_BASE_BG_COLOR;
|
|
@@ -111,6 +128,11 @@ button {
|
|
|
111
128
|
@include flt-icon-path($FLT_BUTTON_LINK_COLOR);
|
|
112
129
|
}
|
|
113
130
|
|
|
131
|
+
&_x-small {
|
|
132
|
+
height: $FLT_BUTTON_X_SMALL_HEIGHT;
|
|
133
|
+
font-size: $FLT_BUTTON_X_SMALL_FONT_SIZE;
|
|
134
|
+
}
|
|
135
|
+
|
|
114
136
|
&_small {
|
|
115
137
|
height: $FLT_BUTTON_SMALL_HEIGHT;
|
|
116
138
|
font-size: $FLT_BUTTON_SMALL_FONT_SIZE;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { createElement } from 'lwc'
|
|
2
|
+
|
|
3
|
+
import Checkbox from 'flt/checkbox'
|
|
4
|
+
|
|
5
|
+
describe('flt-checkbox', () => {
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
while (document.body.firstChild) {
|
|
8
|
+
document.body.removeChild(document.body.firstChild)
|
|
9
|
+
}
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('Generate default checkbox', async () => {
|
|
13
|
+
const checkboxDefault = createElement('flt-checkbox', { is: Checkbox })
|
|
14
|
+
checkboxDefault.label = 'Hello world'
|
|
15
|
+
checkboxDefault.name = 'agree'
|
|
16
|
+
document.body.appendChild(checkboxDefault)
|
|
17
|
+
|
|
18
|
+
await expect(checkboxDefault.firstChild.classList).toContain('flt-checkbox')
|
|
19
|
+
await expect(checkboxDefault.firstChild.classList).toContain('flt-checkbox_size_s')
|
|
20
|
+
await expect(checkboxDefault.firstChild.classList).not.toContain('flt-checkbox_disabled')
|
|
21
|
+
|
|
22
|
+
const valid = checkboxDefault.isValid()
|
|
23
|
+
await expect(valid).toBeTruthy()
|
|
24
|
+
let data = checkboxDefault.getData()
|
|
25
|
+
await expect(data.value).toBeFalsy()
|
|
26
|
+
await checkboxDefault.firstChild.click()
|
|
27
|
+
data = checkboxDefault.getData()
|
|
28
|
+
await expect(data.value).toBeTruthy()
|
|
29
|
+
await expect(checkboxDefault.firstChild.classList).toContain('flt-checkbox_active')
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
it('Generate requie checkbox', async () => {
|
|
33
|
+
const checkboxRequie = createElement('flt-checkbox', { is: Checkbox })
|
|
34
|
+
checkboxRequie.label = 'Hello world'
|
|
35
|
+
checkboxRequie.name = 'agree'
|
|
36
|
+
checkboxRequie.required = true
|
|
37
|
+
document.body.appendChild(checkboxRequie)
|
|
38
|
+
|
|
39
|
+
const valid = checkboxRequie.isValid()
|
|
40
|
+
await expect(valid).toBeFalsy()
|
|
41
|
+
let data = checkboxRequie.getData()
|
|
42
|
+
await expect(data.value).toBeFalsy()
|
|
43
|
+
|
|
44
|
+
const checkboxRequieErrorElement = document.querySelector('.flt-checkbox__error-message')
|
|
45
|
+
await expect(checkboxRequieErrorElement.classList).toContain('flt-checkbox__error-message_active')
|
|
46
|
+
|
|
47
|
+
await checkboxRequie.firstChild.click()
|
|
48
|
+
data = checkboxRequie.getData()
|
|
49
|
+
await expect(data.value).toBeTruthy()
|
|
50
|
+
await expect(checkboxRequie.firstChild.classList).not.toContain('flt-checkbox_error')
|
|
51
|
+
await expect(checkboxRequieErrorElement.classList).not.toContain(
|
|
52
|
+
'flt-checkbox__error-message_active'
|
|
53
|
+
)
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
it('Generate disbled checkbox', async () => {
|
|
57
|
+
const checkboxDisabled = createElement('flt-checkbox', { is: Checkbox })
|
|
58
|
+
checkboxDisabled.label = 'Hello world'
|
|
59
|
+
checkboxDisabled.name = 'agree'
|
|
60
|
+
checkboxDisabled.disabled = true
|
|
61
|
+
document.body.appendChild(checkboxDisabled)
|
|
62
|
+
|
|
63
|
+
await expect(checkboxDisabled.firstChild.classList).toContain('flt-checkbox')
|
|
64
|
+
await expect(checkboxDisabled.firstChild.classList).toContain('flt-checkbox_size_s')
|
|
65
|
+
await expect(checkboxDisabled.firstChild.classList).toContain('flt-checkbox_disabled')
|
|
66
|
+
|
|
67
|
+
const valid = checkboxDisabled.isValid()
|
|
68
|
+
await expect(valid).toBeTruthy()
|
|
69
|
+
let data = checkboxDisabled.getData()
|
|
70
|
+
await expect(data.value).toBeFalsy()
|
|
71
|
+
await checkboxDisabled.firstChild.click()
|
|
72
|
+
data = checkboxDisabled.getData()
|
|
73
|
+
await expect(data.value).toBeFalsy()
|
|
74
|
+
await expect(checkboxDisabled.firstChild.classList).not.toContain('flt-checkbox_active')
|
|
75
|
+
})
|
|
76
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<template lwc:render-mode="light">
|
|
2
|
+
<label class={computedLabelClass}>
|
|
3
|
+
<input
|
|
4
|
+
class="flt-checkbox__input"
|
|
5
|
+
type="checkbox"
|
|
6
|
+
checked={value}
|
|
7
|
+
disabled={disabled}
|
|
8
|
+
onchange={handleChange} />
|
|
9
|
+
<span class={computedSpanClass}>
|
|
10
|
+
<svg
|
|
11
|
+
if:true={value}
|
|
12
|
+
class="flt-checkbox__icon-agree"
|
|
13
|
+
width="20"
|
|
14
|
+
height="20"
|
|
15
|
+
viewBox="0 0 20 20"
|
|
16
|
+
fill="none"
|
|
17
|
+
xmlns="http://www.w3.org/2000/svg">
|
|
18
|
+
<path
|
|
19
|
+
class="flt-checkbox__icon-agree-path"
|
|
20
|
+
d="M3.75 10.625L8.75 15.625L16.25 4.375"
|
|
21
|
+
stroke-width="2"
|
|
22
|
+
stroke-linecap="round"
|
|
23
|
+
stroke-linejoin="round"></path>
|
|
24
|
+
</svg>
|
|
25
|
+
</span>
|
|
26
|
+
<div class="flt-checkbox__label"></div>
|
|
27
|
+
</label>
|
|
28
|
+
<div class={computedErrorMessage}>{errorMessage}</div>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import './checkbox.scss'
|
|
2
|
+
|
|
3
|
+
import { api } from 'lwc'
|
|
4
|
+
import { CheckboxElement } from 'fleetcor-lwc'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @class Checkbox
|
|
8
|
+
* @extends CheckboxElement
|
|
9
|
+
* @description Flt checkbox component
|
|
10
|
+
*/
|
|
11
|
+
export default class Checkbox extends CheckboxElement {
|
|
12
|
+
error
|
|
13
|
+
|
|
14
|
+
@api errorMessage
|
|
15
|
+
@api size = SIZES.SMALL
|
|
16
|
+
|
|
17
|
+
@api validate() {
|
|
18
|
+
this.error = !this.isValid()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
get computedErrorMessage() {
|
|
22
|
+
return this.generateClassNameList({
|
|
23
|
+
'flt-checkbox__error-message': true,
|
|
24
|
+
'flt-checkbox__error-message_active': this.error
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
get computedSpanClass() {
|
|
28
|
+
return this.generateClassNameList({
|
|
29
|
+
'flt-checkbox__icon': true,
|
|
30
|
+
'flt-checkbox__icon_active': this.value
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
get computedLabelClass() {
|
|
34
|
+
return this.generateClassNameList({
|
|
35
|
+
'flt-checkbox': true,
|
|
36
|
+
'flt-checkbox_active': this.value,
|
|
37
|
+
'flt-checkbox_disabled': this.disabled,
|
|
38
|
+
'flt-checkbox_error': this.error,
|
|
39
|
+
[`flt-checkbox_size_${this.size}`]: true
|
|
40
|
+
})
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
renderedCallback() {
|
|
44
|
+
super.renderedCallback()
|
|
45
|
+
this.querySelector('.flt-checkbox__label').innerHTML = this.label
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const SIZES = {
|
|
50
|
+
SMALL: 's'
|
|
51
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
@import './../../../common/mixins_aquamarine';
|
|
2
|
+
/* mixins */
|
|
3
|
+
|
|
4
|
+
.flt-checkbox {
|
|
5
|
+
display: flex;
|
|
6
|
+
cursor: pointer;
|
|
7
|
+
|
|
8
|
+
&:hover:not(.flt-checkbox_disabled, .flt-checkbox_error) {
|
|
9
|
+
.flt-checkbox__icon {
|
|
10
|
+
border-color: $FLT_CHECKBOX_HOVER_BORDER_COLOR;
|
|
11
|
+
background-color: $FLT_CHECKBOX_HOVER_BG_COLOR;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
&_disabled {
|
|
16
|
+
cursor: not-allowed;
|
|
17
|
+
|
|
18
|
+
.flt-checkbox__icon {
|
|
19
|
+
border-color: $FLT_CHECKBOX_DISABLED_BORDER_COLOR;
|
|
20
|
+
background-color: $FLT_CHECKBOX_DISABLED_BG_COLOR;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.flt-checkbox__label {
|
|
24
|
+
color: $FLT_CHECKBOX_DISABLED_COLOR;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.flt-checkbox__icon-agree-path {
|
|
28
|
+
stroke: $FLT_CHECKBOX_DISABLED_AGREE_COLOR;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&_error {
|
|
33
|
+
.flt-checkbox__icon {
|
|
34
|
+
border-color: $FLT_CHECKBOX_ERROR_COLOR;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&_size_s {
|
|
39
|
+
font-size: 14px;
|
|
40
|
+
line-height: 1.5;
|
|
41
|
+
|
|
42
|
+
& + .flt-checkbox__error-message {
|
|
43
|
+
font-size: 12px;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.flt-checkbox__icon {
|
|
47
|
+
width: 1.25rem;
|
|
48
|
+
height: 1.25rem;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&__input {
|
|
53
|
+
display: none;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&__icon {
|
|
57
|
+
display: flex;
|
|
58
|
+
border: 1px solid $FLT_CHECKBOX_BORDER_COLOR;
|
|
59
|
+
background-color: $FLT_CHECKBOX_BG_COLOR;
|
|
60
|
+
border-radius: 6px;
|
|
61
|
+
box-sizing: border-box;
|
|
62
|
+
margin-right: 1rem;
|
|
63
|
+
flex-shrink: 0;
|
|
64
|
+
transition: all 0.3s;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&__icon-agree {
|
|
68
|
+
display: inline-block;
|
|
69
|
+
width: 100%;
|
|
70
|
+
height: 100%;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&__icon-agree-path {
|
|
74
|
+
stroke: $FLT_CHECKBOX_AGREE_COLOR;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
&__label {
|
|
78
|
+
color: $FLT_CHECKBOX_COLOR;
|
|
79
|
+
|
|
80
|
+
a {
|
|
81
|
+
color: inherit;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&__error-message {
|
|
86
|
+
color: $FLT_CHECKBOX_ERROR_COLOR;
|
|
87
|
+
margin-left: 36px;
|
|
88
|
+
opacity: 0;
|
|
89
|
+
line-height: 0;
|
|
90
|
+
transition: all 0.3s;
|
|
91
|
+
|
|
92
|
+
&_active {
|
|
93
|
+
opacity: 1;
|
|
94
|
+
line-height: 1.5;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { api } from 'lwc'
|
|
1
2
|
import { UserDataValidator } from 'fleetcor-lwc'
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -6,4 +7,20 @@ import { UserDataValidator } from 'fleetcor-lwc'
|
|
|
6
7
|
* @extends UserDataValidator
|
|
7
8
|
* @description This class is used to mark a component as a checkbox element
|
|
8
9
|
*/
|
|
9
|
-
export default class CheckboxElement extends UserDataValidator {
|
|
10
|
+
export default class CheckboxElement extends UserDataValidator {
|
|
11
|
+
@api isValid() {
|
|
12
|
+
return this.required ? !!this.value : true
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
handleChange(event) {
|
|
16
|
+
event.stopPropagation()
|
|
17
|
+
if (!this.disabled) {
|
|
18
|
+
this.value = !this.value
|
|
19
|
+
this.dispatchEvent(
|
|
20
|
+
new CustomEvent('change', {
|
|
21
|
+
detail: this.getData()
|
|
22
|
+
})
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -12,11 +12,17 @@ export default class UserDataManager extends BaseElement {
|
|
|
12
12
|
@api name
|
|
13
13
|
@api value
|
|
14
14
|
@api group
|
|
15
|
+
@api disabled
|
|
16
|
+
@api required
|
|
17
|
+
@api label
|
|
15
18
|
|
|
16
19
|
@api getData() {
|
|
17
20
|
return {
|
|
18
21
|
name: this.name,
|
|
22
|
+
disabled: this.disabled,
|
|
19
23
|
value: this.value,
|
|
24
|
+
required: this.required,
|
|
25
|
+
label: this.label,
|
|
20
26
|
group: this.group
|
|
21
27
|
}
|
|
22
28
|
}
|
package/loader/index.js
CHANGED
|
@@ -5,7 +5,16 @@ const path = require('path')
|
|
|
5
5
|
module.exports = function (source) {
|
|
6
6
|
const options = loaderUtils.getOptions(this)
|
|
7
7
|
let content = ''
|
|
8
|
-
if (options && options.mixins) {
|
|
8
|
+
if (options && options.mixins && options.theme) {
|
|
9
|
+
const pathMixin = path.resolve(options.mixins)
|
|
10
|
+
this.addDependency(pathMixin)
|
|
11
|
+
content = fs.readFileSync(pathMixin).toString()
|
|
12
|
+
source = source.replace(
|
|
13
|
+
`@import './../../../common/mixins_aquamarine';`,
|
|
14
|
+
`@import './../../../common/mixins_${options.theme}';`
|
|
15
|
+
)
|
|
16
|
+
source = source.replace('/* mixins */', content)
|
|
17
|
+
} else if (options && options.mixins) {
|
|
9
18
|
const pathMixin = path.resolve(options.mixins)
|
|
10
19
|
this.addDependency(pathMixin)
|
|
11
20
|
content = fs.readFileSync(pathMixin).toString()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fleetcor-lwc",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "LWC framework by Fleetcor",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
}
|
|
29
29
|
],
|
|
30
30
|
"expose": [
|
|
31
|
+
"flt/checkbox",
|
|
31
32
|
"flt/button",
|
|
32
33
|
"flt/icon",
|
|
33
34
|
"flt/tooltip"
|