fleetcor-lwc 3.0.0 → 3.3.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 (73) hide show
  1. package/README.md +146 -4
  2. package/frontend/components/flt/button/button.scss +2 -1
  3. package/frontend/components/flt/inputEmail/__test__/inputEmail.test.js +39 -0
  4. package/frontend/components/flt/inputEmail/inputEmail.js +8 -0
  5. package/frontend/components/flt/inputPhone/__test__/radioItem.test.js +56 -0
  6. package/frontend/components/flt/inputPhone/arrow.svg +3 -0
  7. package/frontend/components/flt/inputPhone/close-button.svg +3 -0
  8. package/frontend/components/flt/inputPhone/flags/AD@2x.png +0 -0
  9. package/frontend/components/flt/inputPhone/flags/AL@2x.png +0 -0
  10. package/frontend/components/flt/inputPhone/flags/AT@2x.png +0 -0
  11. package/frontend/components/flt/inputPhone/flags/BA@2x.png +0 -0
  12. package/frontend/components/flt/inputPhone/flags/BE@2x.png +0 -0
  13. package/frontend/components/flt/inputPhone/flags/BG@2x.png +0 -0
  14. package/frontend/components/flt/inputPhone/flags/BY@2x.png +0 -0
  15. package/frontend/components/flt/inputPhone/flags/CH@2x.png +0 -0
  16. package/frontend/components/flt/inputPhone/flags/CZ@2x.png +0 -0
  17. package/frontend/components/flt/inputPhone/flags/DE@2x.png +0 -0
  18. package/frontend/components/flt/inputPhone/flags/DK@2x.png +0 -0
  19. package/frontend/components/flt/inputPhone/flags/EE@2x.png +0 -0
  20. package/frontend/components/flt/inputPhone/flags/ES@2x.png +0 -0
  21. package/frontend/components/flt/inputPhone/flags/FI@2x.png +0 -0
  22. package/frontend/components/flt/inputPhone/flags/FO@2x.png +0 -0
  23. package/frontend/components/flt/inputPhone/flags/FR@2x.png +0 -0
  24. package/frontend/components/flt/inputPhone/flags/GB@2x.png +0 -0
  25. package/frontend/components/flt/inputPhone/flags/GI@2x.png +0 -0
  26. package/frontend/components/flt/inputPhone/flags/GR@2x.png +0 -0
  27. package/frontend/components/flt/inputPhone/flags/HR@2x.png +0 -0
  28. package/frontend/components/flt/inputPhone/flags/HU@2x.png +0 -0
  29. package/frontend/components/flt/inputPhone/flags/IE@2x.png +0 -0
  30. package/frontend/components/flt/inputPhone/flags/IS@2x.png +0 -0
  31. package/frontend/components/flt/inputPhone/flags/IT@2x.png +0 -0
  32. package/frontend/components/flt/inputPhone/flags/LI@2x.png +0 -0
  33. package/frontend/components/flt/inputPhone/flags/LT@2x.png +0 -0
  34. package/frontend/components/flt/inputPhone/flags/LU@2x.png +0 -0
  35. package/frontend/components/flt/inputPhone/flags/LV@2x.png +0 -0
  36. package/frontend/components/flt/inputPhone/flags/MC@2x.png +0 -0
  37. package/frontend/components/flt/inputPhone/flags/MD@2x.png +0 -0
  38. package/frontend/components/flt/inputPhone/flags/ME@2x.png +0 -0
  39. package/frontend/components/flt/inputPhone/flags/MK@2x.png +0 -0
  40. package/frontend/components/flt/inputPhone/flags/MT@2x.png +0 -0
  41. package/frontend/components/flt/inputPhone/flags/NL@2x.png +0 -0
  42. package/frontend/components/flt/inputPhone/flags/NO@2x.png +0 -0
  43. package/frontend/components/flt/inputPhone/flags/PL@2x.png +0 -0
  44. package/frontend/components/flt/inputPhone/flags/PT@2x.png +0 -0
  45. package/frontend/components/flt/inputPhone/flags/RO@2x.png +0 -0
  46. package/frontend/components/flt/inputPhone/flags/RS@2x.png +0 -0
  47. package/frontend/components/flt/inputPhone/flags/RU@2x.png +0 -0
  48. package/frontend/components/flt/inputPhone/flags/SE@2x.png +0 -0
  49. package/frontend/components/flt/inputPhone/flags/SI@2x.png +0 -0
  50. package/frontend/components/flt/inputPhone/flags/SK@2x.png +0 -0
  51. package/frontend/components/flt/inputPhone/flags/SM@2x.png +0 -0
  52. package/frontend/components/flt/inputPhone/flags/UA@2x.png +0 -0
  53. package/frontend/components/flt/inputPhone/flags/VA@2x.png +0 -0
  54. package/frontend/components/flt/inputPhone/inputPhone.html +109 -0
  55. package/frontend/components/flt/inputPhone/inputPhone.js +252 -0
  56. package/frontend/components/flt/inputPhone/inputPhone.scss +288 -0
  57. package/frontend/components/flt/inputPhone/utils.js +325 -0
  58. package/frontend/components/flt/inputText/__test__/inputText.test.js +211 -0
  59. package/frontend/components/flt/inputText/inputText.html +24 -0
  60. package/frontend/components/flt/inputText/inputText.js +99 -0
  61. package/frontend/components/flt/inputText/inputText.scss +124 -0
  62. package/frontend/components/flt/modal/__test__/modal.test.js +30 -0
  63. package/frontend/components/flt/modal/modal.html +6 -0
  64. package/frontend/components/flt/modal/modal.js +8 -0
  65. package/frontend/components/flt/modal/modal.scss +34 -0
  66. package/frontend/components/flt/progressStep/__test__/progressStep.test.js +17 -1
  67. package/frontend/components/flt/progressStep/progressStep.scss +6 -6
  68. package/frontend/components/flt/tooltip/tooltip.js +4 -4
  69. package/frontend/core/index.js +2 -0
  70. package/frontend/core/interface/InputElement.js +87 -0
  71. package/frontend/core/interface/ModalViewer.js +26 -0
  72. package/frontend/core/interface/UserDataManager.js +11 -1
  73. package/package.json +12 -7
package/README.md CHANGED
@@ -191,7 +191,7 @@ Add / update `lwc.config.json` file in your project
191
191
 
192
192
  | slot | description |
193
193
  | --------- | ---------------------------------------------- |
194
- | defalt | any html element can be there |
194
+ | default | any html element can be there |
195
195
  | iconLeft | any html element can override left icon place |
196
196
  | iconRight | any html element can override right icon place |
197
197
 
@@ -227,9 +227,25 @@ Add / update `lwc.config.json` file in your project
227
227
 
228
228
  #### Tooltip slot
229
229
 
230
- | slot | description |
231
- | ------ | ----------------------------- |
232
- | defalt | any html element can be there |
230
+ | slot | description |
231
+ | ------- | ----------------------------- |
232
+ | default | any html element can be there |
233
+
234
+ ### Modal
235
+
236
+ ```html
237
+ <flt-modal>
238
+ <flt-icon icon="arrow-left"></flt-icon>
239
+ </flt-modal>
240
+
241
+ ...
242
+ ```
243
+
244
+ #### Modal slot
245
+
246
+ | slot | description |
247
+ | ------- | ----------------------------- |
248
+ | default | any html element can be there |
233
249
 
234
250
  ### Progress Step
235
251
 
@@ -289,6 +305,113 @@ Add / update `lwc.config.json` file in your project
289
305
  | ------ | ------------ | ------ | ------------------------------------- |
290
306
  | change | event.detail | object | Return full data of component's state |
291
307
 
308
+ ### Input Text
309
+
310
+ ```html
311
+ <flt-input-text
312
+ name="FirstName"
313
+ label="First Name"
314
+ value="Jos"
315
+ error-message="Error! Required field"
316
+ required
317
+ reg-exp="^[a-zA-Z]*$"
318
+ placeholder="First Name"
319
+ max-length="16"
320
+ type="text"
321
+ placeholde-visible
322
+ ></flt-input-text>
323
+
324
+ <flt-input-text
325
+ name="Currency"
326
+ label="Currency"
327
+ value="100"
328
+ error-message="Error! Required field"
329
+ required
330
+ prefix="$"
331
+ reg-exp="^[0-9]$"
332
+ placeholder="Currency"
333
+ max-length="7"
334
+ min-value="100"
335
+ max-value="1000000"
336
+ type="text"
337
+ placeholde-visible
338
+ ></flt-input-text>
339
+ ...
340
+ ```
341
+
342
+ #### Input Text variables
343
+
344
+ | @api variables | type | values | required | description |
345
+ | ------------------ | ------ | ------------ | -------- | ----------- |
346
+ | name | string | | + | |
347
+ | label | string | | - | |
348
+ | value | string | | - | |
349
+ | error-message | string | | - | |
350
+ | required | bool | | - | |
351
+ | disabled | bool | | - | |
352
+ | placeholde-visible | bool | | - | |
353
+ | prefix | string | | - | |
354
+ | reg-exp | string | | - | |
355
+ | placeholder | string | | - | |
356
+ | max-length | int | | - | |
357
+ | min-value | int | | - | |
358
+ | max-value | int | | - | |
359
+ | type | string | `text`,`tel` | - | |
360
+
361
+ #### Input Text methods
362
+
363
+ | @api | params | return type | description |
364
+ | -------- | ----------- | ----------- | ----------------------------------------------------------------------------------------------------------------------- |
365
+ | validate | | void | Check component validation and show error message to user |
366
+ | isValid | | bool | Return `true` or `false` |
367
+ | getData | silent:bool | object | Return full data of component's state. If `silent` true - return value will be without any errors displaying for client |
368
+
369
+ #### Input Text events
370
+
371
+ | name | handle | return | description |
372
+ | ------------- | ------------ | ------ | ------------------------------------- |
373
+ | focus_happend | event | object | Return common Event object |
374
+ | blur_happend | event | object | Return common Event object |
375
+ | change | event.detail | object | Return full data of component's state |
376
+
377
+ ### Input Email
378
+ This component fully extends from `Input Text`
379
+
380
+ ```html
381
+ <flt-input-email
382
+ name="Email"
383
+ label="Email"
384
+ value="example@example.com"
385
+ error-message="Error! Required field"
386
+ required
387
+ placeholder="Email"
388
+ type="email"
389
+ placeholde-visible
390
+ ></flt-input-email>
391
+ ...
392
+ ```
393
+
394
+ ## Interfaces
395
+
396
+ #### ModalViewer
397
+
398
+ - `ModalViewer.showModalWithComponent(element)` - to show modal window with element inside
399
+ - `ModalViewer.hideModals()` - remove all modals
400
+
401
+ ```js
402
+ import { ModalViewer } from "fleetcor-lwc";
403
+ import { createElement } from "lwc";
404
+ import Button from "flt/button";
405
+
406
+ const btn = createElement("flt-button", { is: Button });
407
+ btn.label = "Close";
408
+ btn.onclick = () => {
409
+ ModalViewer.hideModals();
410
+ };
411
+
412
+ ModalViewer.showModalWithComponent(btn);
413
+ ```
414
+
292
415
  ## Override styles
293
416
 
294
417
  You can override them as you wish by global css variables as priority.
@@ -328,6 +451,7 @@ You can override them as you wish by global css variables as priority.
328
451
  --flt-button-label-padding: 0;
329
452
  --flt-button-border-radius: 32px;
330
453
  --flt-button-padding: 0 24px;
454
+ --flt-button-gap: 16px;
331
455
  --flt-checkbox-border-color: #6b7280;
332
456
  --flt-checkbox-bg-color: #ffffff;
333
457
  --flt-checkbox-agree-color: #59eb9c;
@@ -353,11 +477,29 @@ You can override them as you wish by global css variables as priority.
353
477
  --flt-radio-group-circle-selected-color: #59eb9c;
354
478
  --flt-radio-group-circle-disabled-selected-color: #d1d5db;
355
479
  --flt-radio-group-circle-disabled-selected-bg-color: #ffffff;
480
+ --flt-modal-glass-bgc: rgba(0, 0, 0, 0.4);
481
+ --flt-input-text-color: #111827;
482
+ --flt-input-text-font-weight: 400;
483
+ --flt-input-border-color-active: #6b7280;
484
+ --flt-input-border-color-success: #59eb9c;
485
+ --flt-input-border-radius: 12px;
356
486
  }
357
487
  ```
358
488
 
359
489
  ## Release Notes:
360
490
 
491
+ - v.3.3.0
492
+ - Added components `flt-input-text`, `flt-input-email`, `flt-modal`
493
+ - For modal added new interface `ModalViewer` for dynamically creation modals
494
+ - Update button styles `gap` as variable
495
+
496
+ ---
497
+
498
+ - v.3.0.1
499
+ - Bug fix with firstChild for tooltip component
500
+
501
+ ---
502
+
361
503
  - v.3.0.0
362
504
  - Added `flt-progress-step` and `flt-radio-group-chips` components
363
505
  - Update .css overriding of styles
@@ -36,6 +36,7 @@ $FLT_BUTTON_LABEL_PADDING: var(--flt-button-label-padding, 0);
36
36
  $FLT_BUTTON_BORDER_RADIUS: var(--flt-button-border-radius, 32px);
37
37
 
38
38
  $FLT_BUTTON_PADDING: var(--flt-button-padding, 0 24px);
39
+ $FLT_BUTTON_GAP: var(--flt-button-gap, 16px);
39
40
 
40
41
  button {
41
42
  display: inline-block;
@@ -90,7 +91,7 @@ button {
90
91
  border-radius: $FLT_BUTTON_BORDER_RADIUS;
91
92
  box-sizing: border-box;
92
93
  padding: $FLT_BUTTON_PADDING;
93
- gap: 16px;
94
+ gap: $FLT_BUTTON_GAP;
94
95
 
95
96
  &_primary[disabled] {
96
97
  cursor: not-allowed;
@@ -0,0 +1,39 @@
1
+ import { createElement } from 'lwc'
2
+ import InputEmail from 'flt/inputEmail'
3
+
4
+ describe('flt-input-email', () => {
5
+ afterEach(() => {
6
+ while (document.body.firstChild) {
7
+ document.body.removeChild(document.body.firstChild)
8
+ }
9
+ })
10
+
11
+ it('flt-input-email general', async () => {
12
+ const inputEmailElement = createElement('flt-input-email', { is: InputEmail })
13
+ inputEmailElement.name = 'Email'
14
+ inputEmailElement.label = 'Email'
15
+ inputEmailElement.errorMessage = 'Error message of email'
16
+ document.body.appendChild(inputEmailElement)
17
+
18
+ await expect(inputEmailElement.firstChild.classList).toContain('flt-input-text')
19
+
20
+ inputEmailElement.value = 'example'
21
+ inputEmailElement.validate()
22
+ inputEmailElement.dispatchEvent(new CustomEvent('change'))
23
+
24
+ return Promise.resolve().then(async () => {
25
+ await expect(inputEmailElement.firstChild.classList).toContain('flt-input-text_error')
26
+ const data = inputEmailElement.getData()
27
+ expect(data.value).toBe('example')
28
+ expect(inputEmailElement.isValid()).toBeFalsy()
29
+ inputEmailElement.value = 'example@example.com'
30
+ inputEmailElement.dispatchEvent(new CustomEvent('change'))
31
+
32
+ return Promise.resolve().then(() => {
33
+ const data = inputEmailElement.getData()
34
+ expect(data.value).toBe('example@example.com')
35
+ expect(inputEmailElement.isValid()).toBeTruthy()
36
+ })
37
+ })
38
+ })
39
+ })
@@ -0,0 +1,8 @@
1
+ import InputText from 'flt/inputText'
2
+ import { api } from 'lwc'
3
+
4
+ export default class InputEmail extends InputText {
5
+ required = true
6
+ regExp = '^\\w+([.-]\\w+)*@\\w+([.-]\\w+)*(\\.\\w{2,7})+$'
7
+ @api type = 'email'
8
+ }
@@ -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,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M6.2762 8.65164C6.6345 8.30713 7.20424 8.3183 7.54875 8.67659L12 13.4019L16.4513 8.67659C16.7958 8.3183 17.3655 8.30713 17.7238 8.65164C18.0821 8.99616 18.0933 9.5659 17.7487 9.92419L12.6488 15.3242C12.4791 15.5007 12.2448 15.6004 12 15.6004C11.7552 15.6004 11.5209 15.5007 11.3513 15.3242L6.25125 9.92419C5.90674 9.5659 5.91791 8.99616 6.2762 8.65164Z" fill="#111827"/>
3
+ </svg>
@@ -0,0 +1,3 @@
1
+ <svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
2
+ <path fill-rule="evenodd" clip-rule="evenodd" d="M5.46967 5.46967C5.76256 5.17678 6.23744 5.17678 6.53033 5.46967L12 10.9393L17.4697 5.46967C17.7626 5.17678 18.2374 5.17678 18.5303 5.46967C18.8232 5.76256 18.8232 6.23744 18.5303 6.53033L13.0607 12L18.5303 17.4697C18.8232 17.7626 18.8232 18.2374 18.5303 18.5303C18.2374 18.8232 17.7626 18.8232 17.4697 18.5303L12 13.0607L6.53033 18.5303C6.23744 18.8232 5.76256 18.8232 5.46967 18.5303C5.17678 18.2374 5.17678 17.7626 5.46967 17.4697L10.9393 12L5.46967 6.53033C5.17678 6.23744 5.17678 5.76256 5.46967 5.46967Z" fill="black"/>
3
+ </svg>
@@ -0,0 +1,109 @@
1
+ <template lwc:render-mode="light">
2
+ <div class={inputStyle} tabindex="0">
3
+ <div class="flt-input-phone__block">
4
+ <div class="flt-input-phone__flag-wrapper">
5
+ <div class="flt-input-phone__flag-block" onclick={handleFlagActivate}>
6
+ <div class="flt-input-phone__flag-container">
7
+ <div class="flt-input-phone__flag-selected-value">
8
+ <img
9
+ class="flt-input-phone__flag-selected-icon"
10
+ src={selectedFlag}
11
+ alt="Flag" />
12
+ </div>
13
+ </div>
14
+ </div>
15
+ </div>
16
+ <label onclick={handleLabelClick} class="flt-input-phone__wrapp" for={name}>
17
+ <div class="flt-input-phone__placeholder">{placeholder}</div>
18
+ <div class="flt-input-phone__number">
19
+ <span class="flt-input-phone__code">{selectedFlagOption.label}</span>
20
+ <input
21
+ id={name}
22
+ onfocus={handleFocused}
23
+ onblur={handleBlur}
24
+ oninput={handleInput}
25
+ class="flt-input-phone__input"
26
+ maxlength={maxLength}
27
+ type="tel"
28
+ name={name} />
29
+ </div>
30
+ </label>
31
+ </div>
32
+
33
+ <template if:true={picklistInsideModalView}>
34
+ <div class={computedModalClass}>
35
+ <div class="flt-input-phone__modal-glass" onclick={handleFlagActivate}></div>
36
+ <div class="flt-input-phone__modal-container">
37
+ <div class="flt-input-phone__modal-header">
38
+ <span class="flt-input-phone__modal-header-title"
39
+ >Select country code:</span
40
+ >
41
+ <a
42
+ href="javascript:void(0);"
43
+ onclick={handleFlagActivate}
44
+ class="flt-input-phone__modal-close-button">
45
+ <img
46
+ src={closeButton}
47
+ class="flt-input-phone__modal-close-button-icon"
48
+ alt="close button" />
49
+ </a>
50
+ </div>
51
+ <ul class="flt-input-phone__flag-list">
52
+ <template for:each={flagOptions} for:item="item">
53
+ <li
54
+ if:true={item.selected}
55
+ key={item.key}
56
+ onclick={handleSelectFlag}
57
+ data-value={item.value}
58
+ class="flt-input-phone__flag-list-item flt-input-phone__flag-list-item_selected">
59
+ <img
60
+ class="flt-input-phone__flag-icon"
61
+ src={item.icon}
62
+ alt={item.value} />
63
+ <span class="flt-input-phone__flag-icon-label">{item.label}</span>
64
+ </li>
65
+ <li
66
+ if:false={item.selected}
67
+ key={item.key}
68
+ onclick={handleSelectFlag}
69
+ data-value={item.value}
70
+ class="flt-input-phone__flag-list-item">
71
+ <img
72
+ class="flt-input-phone__flag-icon"
73
+ src={item.icon}
74
+ alt={item.value} />
75
+ <span class="flt-input-phone__flag-icon-label">{item.label}</span>
76
+ </li>
77
+ </template>
78
+ </ul>
79
+ </div>
80
+ </div>
81
+ </template>
82
+ <template if:false={picklistInsideModalView}>
83
+ <ul class="flt-input-phone__flag-list">
84
+ <template for:each={flagOptions} for:item="item">
85
+ <li
86
+ if:true={item.selected}
87
+ key={item.key}
88
+ onclick={handleSelectFlag}
89
+ data-value={item.value}
90
+ class="flt-input-phone__flag-list-item flt-input-phone__flag-list-item_selected">
91
+ <img class="flt-input-phone__flag-icon" src={item.icon} alt={item.value} />
92
+ <span class="flt-input-phone__flag-icon-label">{item.label}</span>
93
+ </li>
94
+ <li
95
+ if:false={item.selected}
96
+ key={item.key}
97
+ onclick={handleSelectFlag}
98
+ data-value={item.value}
99
+ class="flt-input-phone__flag-list-item">
100
+ <img class="flt-input-phone__flag-icon" src={item.icon} alt={item.value} />
101
+ <span class="flt-input-phone__flag-icon-label">{item.label}</span>
102
+ </li>
103
+ </template>
104
+ </ul>
105
+ </template>
106
+
107
+ <div class="flt-input-phone__error">{errorMessage}</div>
108
+ </div>
109
+ </template>