fleetcor-lwc 3.7.0 → 3.8.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 CHANGED
@@ -357,18 +357,18 @@ Add / update `lwc.config.json` file in your project
357
357
 
358
358
  #### Picklist variables
359
359
 
360
- | @api variables | type | values | required | description |
361
- | ------------------- | ------ | -------- | -------- | --------------------------------------------------------------------------------------------- |
362
- | name | string | | + | |
363
- | options | array | | + | Array of available items with `label` and `value` as unique string |
364
- | size | string | `medium` | - | Size of buttons (button sizes) |
365
- | showDropdownAsModal | bool | | - | Show modal with selected options |
366
- | modalDimentionStart | int | 1280 | - | If showDropdownAsModal is true, by default modal become visible window width less then 1280px |
367
- | value | string | | - | Current value from options items value |
368
- | disabled | bool | | - | |
369
- | required | bool | | - | |
370
- | group | string | | - | |
371
- | error-message | string | | - | |
360
+ | @api variables | type | values | required | description |
361
+ | ---------------------- | ------ | -------- | -------- | --------------------------------------------------------------------------------------------- |
362
+ | name | string | | + | |
363
+ | options | array | | + | Array of available items with `label` and `value` as unique string |
364
+ | size | string | `medium` | - | Size of buttons (button sizes) |
365
+ | show-dropdown-as-modal | bool | | - | Show modal with selected options |
366
+ | modal-dimention-start | int | 1280 | - | If showDropdownAsModal is true, by default modal become visible window width less then 1280px |
367
+ | value | string | | - | Current value from options items value |
368
+ | disabled | bool | | - | |
369
+ | required | bool | | - | |
370
+ | group | string | | - | |
371
+ | error-message | string | | - | |
372
372
 
373
373
  #### Picklist methods
374
374
 
@@ -447,11 +447,11 @@ Add / update `lwc.config.json` file in your project
447
447
 
448
448
  #### Input Text events
449
449
 
450
- | name | handle | return | description |
451
- | ------------- | ------------ | ------ | ------------------------------------- |
452
- | focus_happend | event | object | Return common Event object |
453
- | blur_happend | event | object | Return common Event object |
454
- | change | event.detail | object | Return full data of component's state |
450
+ | name | handle | return | description |
451
+ | ------ | ------------ | ------ | ------------------------------------- |
452
+ | focus | event | object | Return common Event object |
453
+ | blur | event | object | Return common Event object |
454
+ | change | event.detail | object | Return full data of component's state |
455
455
 
456
456
  ### Input Email
457
457
 
@@ -471,6 +471,50 @@ This component fully extends from `Input Text`
471
471
  ...
472
472
  ```
473
473
 
474
+ ### Input Phone
475
+
476
+ ```html
477
+ <flt-input-phone
478
+ name="phone"
479
+ value="+44 3435234523"
480
+ error-message="Error! Required field"
481
+ required
482
+ placeholder="Phone Number"
483
+ error-message="Please enter a valid phone"
484
+ ></flt-input-phone>
485
+ ...
486
+ ```
487
+
488
+ #### Input Phone variables
489
+
490
+ | @api variables | type | values | required | description |
491
+ | ---------------------- | ------ | ------ | -------- | --------------------------------------------------------------------------------------------- |
492
+ | name | string | | + | |
493
+ | error-message | string | | - | |
494
+ | value | string | | - | |
495
+ | required | bool | | - | |
496
+ | disabled | bool | | - | |
497
+ | placeholder | string | | - | |
498
+ | code-by-default | string | `GB` | - | Country code. by default UK country code `GB` |
499
+ | show-dropdown-as-modal | bool | | - | |
500
+ | modal-dimention-start | int | 1280 | - | If showDropdownAsModal is true, by default modal become visible window width less then 1280px |
501
+
502
+ #### Input Phone methods
503
+
504
+ | @api | params | return type | description |
505
+ | -------- | ----------- | ----------- | ----------------------------------------------------------------------------------------------------------------------- |
506
+ | validate | | void | Check component validation and show error message to user |
507
+ | isValid | | bool | Return `true` or `false` |
508
+ | getData | silent:bool | object | Return full data of component's state. If `silent` true - return value will be without any errors displaying for client |
509
+
510
+ #### Input Phone events
511
+
512
+ | name | handle | return | description |
513
+ | ------ | ------------ | ------ | ------------------------------------- |
514
+ | focus | event | object | Return common Event object |
515
+ | blur | event | object | Return common Event object |
516
+ | change | event.detail | object | Return full data of component's state |
517
+
474
518
  ## Interfaces
475
519
 
476
520
  #### ModalViewer
@@ -563,7 +607,9 @@ You can override them as you wish by global css variables as priority.
563
607
  --flt-input-text-font-weight: 400;
564
608
  --flt-input-border-color-active: #6b7280;
565
609
  --flt-input-border-color-success: #59eb9c;
610
+ --flt-input-border-color-error: #ed123d;
566
611
  --flt-input-border-radius: 12px;
612
+ --flt-input-prefix-gap: 8px;
567
613
  --flt-card-bgc: #fff;
568
614
  --flt-card-padding: 24px;
569
615
  --flt-card-border-radius: 20px;
@@ -612,11 +658,22 @@ You can override them as you wish by global css variables as priority.
612
658
  --flt-picklist-option-first-child-padding: 32px 16px 12px;
613
659
  --flt-picklist-option-padding: 12px 16px;
614
660
  --flt-picklist-dropdown-modal-header-bgc: #f3f4f6;
661
+ --flt-input-phone-border-color-success: #59eb9c;
662
+ --flt-input-phone-border-color-error: #ed123d;
615
663
  }
616
664
  ```
617
665
 
618
666
  ## Release Notes:
619
667
 
668
+ - v.3.8.1
669
+
670
+ - Bug fix visiability of `flt-picklist`
671
+
672
+ - v.3.8.0
673
+
674
+ - Added new component `flt-input-phone`
675
+ - Updated: `flt-input-text`, `flt-picklist`
676
+
620
677
  - v.3.7.0
621
678
 
622
679
  - Added new component `flt-picklist`
@@ -0,0 +1,119 @@
1
+ import { createElement, setHooks } from 'lwc'
2
+ import InputPhone from 'flt/inputPhone'
3
+
4
+ setHooks({
5
+ sanitizeHtmlContent(content) {
6
+ return content
7
+ }
8
+ })
9
+
10
+ Object.defineProperty(window, 'matchMedia', {
11
+ writable: true,
12
+ value: jest.fn().mockImplementation((query) => ({
13
+ matches: false
14
+ // media: query,
15
+ // onchange: null,
16
+ // addListener: jest.fn(), // Deprecated
17
+ // removeListener: jest.fn(), // Deprecated
18
+ // addEventListener: jest.fn(),
19
+ // removeEventListener: jest.fn(),
20
+ // dispatchEvent: jest.fn()
21
+ }))
22
+ })
23
+
24
+ describe('flt-input-phone', () => {
25
+ afterEach(() => {
26
+ while (document.body.firstChild) {
27
+ document.body.removeChild(document.body.firstChild)
28
+ }
29
+ })
30
+
31
+ it('flt-input-phone base', async () => {
32
+ const inputPhoneEl = createElement('flt-input-phone', { is: InputPhone })
33
+ inputPhoneEl.name = 'phone'
34
+ inputPhoneEl.required = true
35
+ inputPhoneEl.errorMessage = 'Please enter a valid phone'
36
+ inputPhoneEl.codeByDefault = 'BY'
37
+ inputPhoneEl.value = '+375 295558386'
38
+ inputPhoneEl.placeholder = 'Phone Number'
39
+ document.body.appendChild(inputPhoneEl)
40
+ await expect(inputPhoneEl.firstChild.classList).toContain('flt-input-phone')
41
+
42
+ const picklistEl = inputPhoneEl.querySelector('flt-picklist')
43
+ picklistEl.firstChild.focus()
44
+ return Promise.resolve().then(async () => {
45
+ const dropDownEl = picklistEl.querySelector('.flt-picklist__dropdown')
46
+ await expect(dropDownEl).toBeTruthy()
47
+ const options = dropDownEl.querySelectorAll('.flt-picklist__option')
48
+ options[options.length - 1].click()
49
+ inputPhoneEl.dispatchEvent(new CustomEvent('change'))
50
+ return Promise.resolve().then(async () => {
51
+ const data = picklistEl.getData()
52
+ await expect(data.value).toBe('+44')
53
+ const inputEl = inputPhoneEl.querySelector('flt-input-text')
54
+ inputEl.firstChild.focus()
55
+ inputEl.value = '3456'
56
+ inputEl.dispatchEvent(new CustomEvent('change', { detail: inputEl.getData() }))
57
+ return Promise.resolve().then(async () => {
58
+ inputEl.value = '03435234523'
59
+ inputEl.dispatchEvent(new CustomEvent('change', { detail: inputEl.getData() }))
60
+ return Promise.resolve().then(async () => {
61
+ await expect(inputPhoneEl.getData().isValid).toBeTruthy()
62
+ })
63
+ })
64
+ })
65
+ })
66
+ })
67
+
68
+ it('flt-input-phone negotive', async () => {
69
+ const inputPhoneEl = createElement('flt-input-phone', { is: InputPhone })
70
+ inputPhoneEl.name = 'phone'
71
+ inputPhoneEl.required = true
72
+ inputPhoneEl.errorMessage = 'Please enter a valid phone'
73
+ inputPhoneEl.codeByDefault = 'gg'
74
+ inputPhoneEl.value = '2958386'
75
+ inputPhoneEl.placeholder = 'Phone Number'
76
+ document.body.appendChild(inputPhoneEl)
77
+ await expect(inputPhoneEl.firstChild.classList).toContain('flt-input-phone')
78
+ await expect(inputPhoneEl.isValid()).toBeFalsy()
79
+ inputPhoneEl.value = ''
80
+ inputPhoneEl.validate()
81
+ await expect(inputPhoneEl.isValid()).toBeFalsy()
82
+ })
83
+
84
+ it('flt-input-phone negotive 2', async () => {
85
+ const inputPhoneEl = createElement('flt-input-phone', { is: InputPhone })
86
+ inputPhoneEl.name = 'phone'
87
+ inputPhoneEl.required = true
88
+ inputPhoneEl.errorMessage = 'Please enter a valid phone'
89
+ inputPhoneEl.value = '+44 3435234523'
90
+ inputPhoneEl.placeholder = 'Phone Number'
91
+ document.body.appendChild(inputPhoneEl)
92
+
93
+ return Promise.resolve().then(async () => {
94
+ await expect(inputPhoneEl.firstChild.classList).toContain('flt-input-phone')
95
+ await expect(inputPhoneEl.isValid()).toBeTruthy()
96
+ inputPhoneEl.value = undefined
97
+ return Promise.resolve().then(async () => {
98
+ await expect(inputPhoneEl.isValid()).toBeFalsy()
99
+ })
100
+ })
101
+ })
102
+
103
+ it('flt-input-phone disabled', async () => {
104
+ const inputPhoneEl = createElement('flt-input-phone', { is: InputPhone })
105
+ inputPhoneEl.name = 'phone'
106
+ inputPhoneEl.required = true
107
+ inputPhoneEl.disabled = true
108
+ inputPhoneEl.errorMessage = 'Please enter a valid phone'
109
+ inputPhoneEl.codeByDefault = 'gg'
110
+ inputPhoneEl.value = '2958386'
111
+ inputPhoneEl.placeholder = 'Phone Number'
112
+ document.body.appendChild(inputPhoneEl)
113
+ return Promise.resolve().then(async () => {
114
+ await expect(inputPhoneEl.firstChild.classList).toContain('flt-input-phone_disabled')
115
+ inputPhoneEl.validate()
116
+ await expect(inputPhoneEl.isValid()).toBeFalsy()
117
+ })
118
+ })
119
+ })
@@ -1,109 +1,30 @@
1
1
  <template lwc:render-mode="light">
2
- <div class={inputStyle} tabindex="0">
2
+ <div class={inputStyle}>
3
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>
4
+ <flt-picklist
5
+ class="flt-input-phone__code"
6
+ placeholder="Select country code"
7
+ value={codeValue}
8
+ options={flagOptions}
9
+ disabled={disabled}
10
+ onfocus={handleFocus}
11
+ onblur={handleBlur}
12
+ show-dropdown-as-modal={showDropdownAsModal}
13
+ modal-dimention-start={modalDimentionStart}
14
+ onchange={handleFlagChanged}
15
+ name="phoneCode"></flt-picklist>
16
+ <flt-input-text
17
+ class="flt-input-phone__number"
18
+ prefix={prefix}
19
+ disabled={disabled}
20
+ type="number"
21
+ onfocus={handleFocus}
22
+ onblur={handleBlur}
23
+ placeholder={placeholder}
24
+ value={phoneNumber}
25
+ onchange={handlePhoneNumberChanged}
26
+ name="phoneNumber"></flt-input-text>
31
27
  </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
28
  <div class="flt-input-phone__error">{errorMessage}</div>
108
29
  </div>
109
30
  </template>