fleetcor-lwc 3.0.1 → 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 (72) hide show
  1. package/README.md +141 -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/core/index.js +2 -0
  69. package/frontend/core/interface/InputElement.js +87 -0
  70. package/frontend/core/interface/ModalViewer.js +26 -0
  71. package/frontend/core/interface/UserDataManager.js +11 -1
  72. package/package.json +12 -7
@@ -0,0 +1,124 @@
1
+ .flt-input-text {
2
+ box-sizing: border-box;
3
+ color: var(--flt-input-text-color, #111827);
4
+ font-weight: var(--flt-input-text-font-weight, 400);
5
+ cursor: pointer;
6
+
7
+ &__prefix {
8
+ padding-right: 2px;
9
+ }
10
+
11
+ &_disabled {
12
+ color: #d1d5db;
13
+
14
+ .flt-input-text__wrapp {
15
+ border-color: #d1d5db !important;
16
+ background: #f9fafb !important;
17
+ cursor: not-allowed;
18
+ }
19
+
20
+ -webkit-user-select: none;
21
+ -ms-user-select: none;
22
+ user-select: none;
23
+
24
+ input {
25
+ background-color: #f9fafb;
26
+ color: #bdc1c7;
27
+ cursor: not-allowed;
28
+ }
29
+ }
30
+
31
+ &_active,
32
+ &_activate {
33
+ .flt-input-text__input-block {
34
+ display: flex;
35
+ height: 20px;
36
+ opacity: 1;
37
+ }
38
+
39
+ .flt-input-text__placeholder {
40
+ font-size: 12px;
41
+ line-height: 16px;
42
+ }
43
+
44
+ .flt-input-text__wrapp {
45
+ border-color: var(--flt-input-border-color-active, #6b7280);
46
+ }
47
+ }
48
+
49
+ &_error {
50
+ .flt-input-text__wrapp {
51
+ border-color: #ef4444;
52
+ }
53
+
54
+ .flt-input-text__error {
55
+ height: 16px;
56
+ opacity: 1;
57
+ }
58
+ }
59
+
60
+ &_success {
61
+ .flt-input-text__wrapp {
62
+ border-color: var(--flt-input-border-color-success, #59eb9c);
63
+ }
64
+ }
65
+
66
+ &__wrapp {
67
+ background-color: #ffffff;
68
+ border: 1px solid #6b7280;
69
+ border-radius: var(--flt-input-border-radius, 12px);
70
+ overflow: hidden;
71
+ height: 44px;
72
+ display: flex;
73
+ flex-direction: column;
74
+ padding-left: 16px;
75
+ padding-right: 16px;
76
+ justify-content: center;
77
+ transition: all 0.3s;
78
+ }
79
+
80
+ &__input-block {
81
+ height: 0;
82
+ opacity: 0;
83
+ line-height: 20px;
84
+ font-size: 16px;
85
+ transition: all 0.3s;
86
+ }
87
+
88
+ &__input {
89
+ height: inherit;
90
+ font-size: 16px;
91
+ }
92
+
93
+ &__placeholder {
94
+ font-size: 16px;
95
+ line-height: 20px;
96
+ }
97
+
98
+ &__error {
99
+ height: 0;
100
+ opacity: 0;
101
+ margin-top: 4px;
102
+ font-size: 12px;
103
+ line-height: 16px;
104
+ color: #ef4444;
105
+ transition: all 0.3s;
106
+ }
107
+
108
+ input {
109
+ width: 100%;
110
+ outline: none;
111
+ border: none;
112
+ padding: 0;
113
+ }
114
+
115
+ input::-webkit-outer-spin-button,
116
+ input::-webkit-inner-spin-button {
117
+ -webkit-appearance: none;
118
+ margin: 0;
119
+ }
120
+
121
+ input[type='number'] {
122
+ -moz-appearance: textfield;
123
+ }
124
+ }
@@ -0,0 +1,30 @@
1
+ import { createElement } from 'lwc'
2
+ import { ModalViewer } from 'fleetcor-lwc'
3
+ import ProgressStep from 'flt/progressStep'
4
+ import { doc } from 'prettier'
5
+
6
+ describe('flt-modal', () => {
7
+ afterEach(() => {
8
+ ModalViewer.hideModals()
9
+ })
10
+
11
+ it('base test', () => {
12
+ const progressStep = createElement('flt-progress-step', { is: ProgressStep })
13
+ progressStep.total = 9
14
+ progressStep.current = 2
15
+ progressStep.title = 'Good job'
16
+ ModalViewer.showModalWithComponent(progressStep)
17
+
18
+ const modalElement = document.body.querySelector('flt-modal')
19
+ expect(modalElement.firstChild.classList).toContain('flt-modal')
20
+ const progressStepElemet = modalElement.querySelector('flt-progress-step')
21
+ expect(progressStepElemet.total).toBe(9)
22
+ expect(progressStepElemet.current).toBe(2)
23
+ expect(progressStepElemet.title).toBe('Good job')
24
+
25
+ const glassEl = modalElement.querySelector('.flt-modal__glass')
26
+ glassEl.click()
27
+ const removedModalElement = document.body.querySelector('flt-modal')
28
+ expect(removedModalElement).toBeFalsy()
29
+ })
30
+ })
@@ -0,0 +1,6 @@
1
+ <template lwc:render-mode="light">
2
+ <div class="flt-modal">
3
+ <div class="flt-modal__glass" onclick={handleCloseButton}></div>
4
+ <div class="flt-modal__container"><slot></slot></div>
5
+ </div>
6
+ </template>
@@ -0,0 +1,8 @@
1
+ import { BaseElement, ModalViewer } from 'fleetcor-lwc'
2
+ import './modal.scss'
3
+
4
+ export default class Modal extends BaseElement {
5
+ handleCloseButton() {
6
+ ModalViewer.hideModals()
7
+ }
8
+ }
@@ -0,0 +1,34 @@
1
+ .flt-modal {
2
+ position: fixed;
3
+ width: 100%;
4
+ height: 100%;
5
+ left: 0;
6
+ top: 0;
7
+ z-index: 999999;
8
+ display: flex;
9
+ align-items: center;
10
+ justify-content: center;
11
+ animation: fadeIn 0.3s ease-in-out;
12
+
13
+ &__glass {
14
+ position: absolute;
15
+ width: 100%;
16
+ height: 100%;
17
+ left: 0;
18
+ top: 0;
19
+ background: var(--flt-modal-glass-bgc, rgba(0, 0, 0, 0.4));
20
+ }
21
+
22
+ &__container {
23
+ position: relative;
24
+ }
25
+ }
26
+
27
+ @keyframes fadeIn {
28
+ 0% {
29
+ opacity: 0;
30
+ }
31
+ 100% {
32
+ opacity: 1;
33
+ }
34
+ }
@@ -9,7 +9,7 @@ describe('flt-progress-step', () => {
9
9
  }
10
10
  })
11
11
 
12
- it('base test', () => {
12
+ it('base test 2/9', () => {
13
13
  const progressStep = createElement('flt-progress-step', { is: ProgressStep })
14
14
  progressStep.total = 9
15
15
  progressStep.current = 2
@@ -24,4 +24,20 @@ describe('flt-progress-step', () => {
24
24
  const title = progressStep.firstChild.querySelector('.progress-step__current-title')
25
25
  expect(title.textContent).toBe('Good job')
26
26
  })
27
+
28
+ it('base test 8/9', () => {
29
+ const progressStep = createElement('flt-progress-step', { is: ProgressStep })
30
+ progressStep.total = 9
31
+ progressStep.current = 8
32
+ progressStep.title = 'Good job'
33
+ document.body.appendChild(progressStep)
34
+
35
+ expect(progressStep.firstChild.classList).toContain('progress-step')
36
+
37
+ const position = progressStep.firstChild.querySelector('.progress-step__number-propotion')
38
+ expect(position.textContent).toBe('8/9')
39
+
40
+ const title = progressStep.firstChild.querySelector('.progress-step__current-title')
41
+ expect(title.textContent).toBe('Good job')
42
+ })
27
43
  })
@@ -1,12 +1,12 @@
1
- $FLT_STEP_POSITION_TITLE_FONT_WEIGHT: var(--step-position-title-font-weight, 500);
2
- $FLT_STEP_POSITION_TITLE_COLOR: var(--step-position-title-color, #0a7db8);
1
+ $FLT_STEP_POSITION_TITLE_FONT_WEIGHT: var(--flt-step-position-title-font-weight, 500);
2
+ $FLT_STEP_POSITION_TITLE_COLOR: var(--flt-step-position-title-color, #0a7db8);
3
3
  $FLT_STEP_POSITION_NUMBER_PROPOTION_FONT_WEIGHT: var(
4
- --step-position-number-propotion-font-weight,
4
+ --flt--step-position-number-propotion-font-weight,
5
5
  300
6
6
  );
7
- $FLT_STEP_POSITION_NUMBER_COLOR: var(--step-position-number-color, #111827);
8
- $FLT_STEP_POSITION_CIRCLE_COLOR: var(--step-position-circle-color, #0a7db8);
9
- $FLT_STEP_POSITION_CIRCLE_BACKGROUND: var(--step-position-circle-background, #bbe6fb);
7
+ $FLT_STEP_POSITION_NUMBER_COLOR: var(--flt-step-position-number-color, #111827);
8
+ $FLT_STEP_POSITION_CIRCLE_COLOR: var(--flt-step-position-circle-color, #0a7db8);
9
+ $FLT_STEP_POSITION_CIRCLE_BACKGROUND: var(--flt-step-position-circle-background, #bbe6fb);
10
10
 
11
11
  .progress-step {
12
12
  position: relative;
@@ -5,6 +5,8 @@ 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
7
  export { default as SelectElement } from './interface/SelectElement'
8
+ export { default as InputElement } from './interface/InputElement'
9
+ export { default as ModalViewer } from './interface/ModalViewer'
8
10
 
9
11
  // ERROR
10
12
  export * from './error/errors'
@@ -0,0 +1,87 @@
1
+ import { api } from 'lwc'
2
+ import { UserDataValidator, FltOverrideError } from 'fleetcor-lwc'
3
+
4
+ /**
5
+ * @abstract
6
+ * @class InputElement
7
+ * @extends UserDataValidator
8
+ * @description This class is used to input form data
9
+ */
10
+ export default class InputElement extends UserDataValidator {
11
+ error
12
+
13
+ @api regExp
14
+ @api placeholder
15
+ @api maxLength
16
+ @api minValue
17
+ @api maxValue
18
+
19
+ @api validate() {
20
+ this.error = !this.isValid()
21
+ }
22
+
23
+ @api isValid() {
24
+ let result = true
25
+ if (this.required) {
26
+ if (this.regExp && this.value && !new RegExp(this.regExp).test(this.value)) {
27
+ result = false
28
+ } else if (!this.value) {
29
+ result = false
30
+ }
31
+ }
32
+
33
+ if (
34
+ result &&
35
+ this.maxLength &&
36
+ this.value &&
37
+ this.value.length > parseInt(this.maxLength)
38
+ ) {
39
+ result = false
40
+ }
41
+
42
+ if (result && this.minValue) {
43
+ const numberValue = parseInt(this.value)
44
+ result = false
45
+ if (!isNaN(numberValue) && numberValue >= parseInt(this.minValue)) {
46
+ result = true
47
+ }
48
+ }
49
+
50
+ if (result && this.maxValue) {
51
+ const numberValue = parseInt(this.value)
52
+ result = false
53
+ if (!isNaN(numberValue) && numberValue <= parseInt(this.maxValue)) {
54
+ result = true
55
+ }
56
+ }
57
+
58
+ return result
59
+ }
60
+
61
+ @api getData(silent) {
62
+ return {
63
+ ...super.getData(silent),
64
+ regExp: this.regExp,
65
+ placeholder: this.placeholder,
66
+ maxLength: this.maxLength,
67
+ minValue: this.minValue,
68
+ maxValue: this.maxValue
69
+ }
70
+ }
71
+
72
+ handleInput(event) {
73
+ throw new FltOverrideError('handleInput')
74
+ }
75
+
76
+ handleChange(event) {
77
+ throw new FltOverrideError('handleChange')
78
+ }
79
+
80
+ handleFocused(event) {
81
+ throw new FltOverrideError('handleFocused')
82
+ }
83
+
84
+ handleBlur(event) {
85
+ throw new FltOverrideError('handleBlur')
86
+ }
87
+ }
@@ -0,0 +1,26 @@
1
+ import { createElement } from 'lwc'
2
+ import Modal from 'flt/modal'
3
+
4
+ /**
5
+ * @abstract
6
+ * @class ModalViewer
7
+ * @description This class is used to show and hide modal view
8
+ */
9
+ export default class ModalViewer {
10
+ static showModalWithComponent(cmp) {
11
+ const appEl = createElement('flt-modal', { is: Modal })
12
+ document.body.appendChild(appEl)
13
+ document.body.style.overflow = 'hidden'
14
+ if (cmp) {
15
+ appEl.querySelector('.flt-modal__container').appendChild(cmp)
16
+ }
17
+ }
18
+
19
+ static hideModals() {
20
+ document.body.style.overflow = null
21
+ const items = document.body.querySelectorAll('flt-modal')
22
+ items.forEach((item) => {
23
+ item.remove()
24
+ })
25
+ }
26
+ }
@@ -9,8 +9,18 @@ import { BaseElement, FltMissingAttributeError } from 'fleetcor-lwc'
9
9
  * @description This class used to manage user data
10
10
  */
11
11
  export default class UserDataManager extends BaseElement {
12
+ _value
13
+
12
14
  @api name
13
- @api value
15
+ @api
16
+ get value() {
17
+ return this._value
18
+ }
19
+ set value(v) {
20
+ if (!this.disabled) {
21
+ this._value = v
22
+ }
23
+ }
14
24
  @api group
15
25
  @api disabled
16
26
  @api required
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fleetcor-lwc",
3
- "version": "3.0.1",
3
+ "version": "3.3.0",
4
4
  "description": "LWC framework by Fleetcor",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,6 +28,9 @@
28
28
  "flt/button",
29
29
  "flt/checkbox",
30
30
  "flt/icon",
31
+ "flt/inputText",
32
+ "flt/inputEmail",
33
+ "flt/modal",
31
34
  "flt/radioGroup",
32
35
  "flt/radioGroupIcon",
33
36
  "flt/tooltip",
@@ -43,7 +46,7 @@
43
46
  "test:unit": "sfdx-lwc-jest",
44
47
  "test:unit:watch": "sfdx-lwc-jest --watch",
45
48
  "test:unit:debug": "sfdx-lwc-jest --debug",
46
- "test:unit:coverage": "sfdx-lwc-jest --coverage",
49
+ "test:unit:coverage": "sfdx-lwc-jest -- --clearCache && sfdx-lwc-jest --coverage",
47
50
  "prettier": "prettier --config .prettierrc --write ./"
48
51
  },
49
52
  "devDependencies": {
@@ -55,21 +58,23 @@
55
58
  "babel-loader": "^10.0.0",
56
59
  "css-loader": "^7.1.4",
57
60
  "d": "^1.0.1",
61
+ "google-libphonenumber": "^3.2.44",
58
62
  "html-loader": "^2.1.2",
59
63
  "html-webpack-plugin": "^5.3.2",
60
64
  "identity-obj-proxy": "^3.0.0",
61
65
  "lwc": "^9.0.2",
62
66
  "lwc-webpack-plugin": "^3.1.0",
67
+ "prettier": "^2.3.2",
68
+ "pug-html-loader": "^1.1.5",
69
+ "pug-loader": "^2.4.0",
63
70
  "resolve-url-loader": "^5.0.0",
64
71
  "sass": "^1.97.3",
65
- "terser-webpack-plugin": "^5.3.16",
66
72
  "sass-loader": "^16.0.7",
67
73
  "style-loader": "^4.0.0",
68
- "prettier": "^2.3.2",
69
- "pug-html-loader": "^1.1.5",
70
- "pug-loader": "^2.4.0",
74
+ "terser-webpack-plugin": "^5.3.16",
71
75
  "webpack": "^5.105.2",
72
76
  "webpack-cli": "^6.0.1",
73
- "webpack-dev-server": "^5.2.3"
77
+ "webpack-dev-server": "^5.2.3",
78
+ "imask": "^7.6.1"
74
79
  }
75
80
  }