geico-design-kit 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of geico-design-kit might be problematic. Click here for more details.
- package/.babelrc +5 -0
- package/LICENSE +0 -0
- package/dist/analytics.js +119 -0
- package/dist/appState.js +56 -0
- package/dist/baseComponent.js +110 -0
- package/dist/components/Accordion.js +312 -0
- package/dist/components/AddressAutoComplete.js +220 -0
- package/dist/components/Alert.js +145 -0
- package/dist/components/BackgroundPattern.js +99 -0
- package/dist/components/BackgroundPatternPortfolio.js +242 -0
- package/dist/components/ButtonSwitch.js +236 -0
- package/dist/components/CardSelections.js +230 -0
- package/dist/components/CommonQuestionsSquares.js +169 -0
- package/dist/components/Confirmation.js +156 -0
- package/dist/components/ConsolidatedSummary.js +489 -0
- package/dist/components/CoverageGraph.js +201 -0
- package/dist/components/CreditCard.js +591 -0
- package/dist/components/CurrencyInput.js +302 -0
- package/dist/components/DatePicker.js +468 -0
- package/dist/components/DockedMessage.js +146 -0
- package/dist/components/DotNavigation.js +200 -0
- package/dist/components/EditComponent.js +128 -0
- package/dist/components/EditableTable.js +113 -0
- package/dist/components/InPageNavigation.js +360 -0
- package/dist/components/Loader.js +232 -0
- package/dist/components/MakePayment.js +361 -0
- package/dist/components/Modal.js +254 -0
- package/dist/components/MoreInfoButton.js +227 -0
- package/dist/components/MultipleSelectBox.js +217 -0
- package/dist/components/NavigationalBox.js +161 -0
- package/dist/components/Navigator.js +294 -0
- package/dist/components/PasswordMeter.js +201 -0
- package/dist/components/PayPlans.js +534 -0
- package/dist/components/SegmentedControl.js +327 -0
- package/dist/components/SortableTable.js +166 -0
- package/dist/components/Tabs.js +1 -0
- package/dist/components/TextAreaCountdown.js +219 -0
- package/dist/components/Timeline.js +498 -0
- package/dist/components/TimelineFilter.js +492 -0
- package/dist/components/ToTopArrow.js +153 -0
- package/dist/components/Tooltip.js +329 -0
- package/dist/components/Upsell.js +168 -0
- package/dist/components/VIN.js +271 -0
- package/dist/components/ValidateForm.js +938 -0
- package/dist/components/ViewMoreLess.js +191 -0
- package/dist/components/ZipCode.js +191 -0
- package/dist/components/portfolio.js +99 -0
- package/dist/geico-design-kit.js +141 -0
- package/dist/global/components.js +98 -0
- package/dist/global/footer.js +26 -0
- package/dist/global/nav.js +1257 -0
- package/dist/services/CharacterTypeService.js +106 -0
- package/dist/services/UserAgentService.js +73 -0
- package/dist/utils.js +79 -0
- package/package.json +32 -0
- package/src/analytics.js +82 -0
- package/src/appState.js +56 -0
- package/src/baseComponent.js +156 -0
- package/src/components/Accordion.js +336 -0
- package/src/components/AddressAutoComplete.js +236 -0
- package/src/components/Alert.js +135 -0
- package/src/components/BackgroundPattern.js +96 -0
- package/src/components/BackgroundPatternPortfolio.js +284 -0
- package/src/components/ButtonSwitch.js +241 -0
- package/src/components/CardSelections.js +240 -0
- package/src/components/CommonQuestionsSquares.js +179 -0
- package/src/components/Confirmation.js +160 -0
- package/src/components/ConsolidatedSummary.js +505 -0
- package/src/components/CoverageGraph.js +203 -0
- package/src/components/CreditCard.js +595 -0
- package/src/components/CurrencyInput.js +321 -0
- package/src/components/DatePicker.js +487 -0
- package/src/components/DockedMessage.js +142 -0
- package/src/components/DotNavigation.js +206 -0
- package/src/components/EditComponent.js +130 -0
- package/src/components/EditableTable.js +106 -0
- package/src/components/InPageNavigation.js +391 -0
- package/src/components/Loader.js +272 -0
- package/src/components/MakePayment.js +397 -0
- package/src/components/Modal.js +279 -0
- package/src/components/MoreInfoButton.js +243 -0
- package/src/components/MultipleSelectBox.js +211 -0
- package/src/components/NavigationalBox.js +163 -0
- package/src/components/Navigator.js +338 -0
- package/src/components/PasswordMeter.js +209 -0
- package/src/components/PayPlans.js +604 -0
- package/src/components/SegmentedControl.js +365 -0
- package/src/components/SortableTable.js +176 -0
- package/src/components/Tabs.js +0 -0
- package/src/components/TextAreaCountdown.js +231 -0
- package/src/components/Timeline.js +532 -0
- package/src/components/TimelineFilter.js +533 -0
- package/src/components/ToTopArrow.js +153 -0
- package/src/components/Tooltip.js +344 -0
- package/src/components/Upsell.js +196 -0
- package/src/components/VIN.js +289 -0
- package/src/components/ValidateForm.js +1030 -0
- package/src/components/ViewMoreLess.js +193 -0
- package/src/components/ZipCode.js +193 -0
- package/src/components/portfolio.js +106 -0
- package/src/geico-design-kit.js +144 -0
- package/src/global/components.js +92 -0
- package/src/global/footer.js +25 -0
- package/src/global/nav.js +1457 -0
- package/src/services/CharacterTypeService.js +107 -0
- package/src/services/UserAgentService.js +59 -0
- package/src/utils.js +82 -0
@@ -0,0 +1,302 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports["default"] = void 0;
|
7
|
+
var utils = _interopRequireWildcard(require("../../src/utils"));
|
8
|
+
var _baseComponent = _interopRequireDefault(require("../../src/baseComponent"));
|
9
|
+
var _appState = _interopRequireDefault(require("../../src/appState"));
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
13
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
14
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
15
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
16
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
18
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
19
|
+
var validateSettings = [{
|
20
|
+
setting: "content",
|
21
|
+
isRequired: true,
|
22
|
+
validate: "type",
|
23
|
+
possibleValues: ["string", "object"],
|
24
|
+
errorMessage: ["GDK CurrencyInput : Content must be defined and set to a DOM selector or Node"]
|
25
|
+
}, {
|
26
|
+
setting: "numType",
|
27
|
+
isRequired: false,
|
28
|
+
validate: "value",
|
29
|
+
possibleValues: ["whole", "decimal"],
|
30
|
+
errorMessage: ["GDK CurrencyInput : numType must be set to whole or decimal"]
|
31
|
+
}, {
|
32
|
+
setting: "onCompleteFormat",
|
33
|
+
isRequired: false,
|
34
|
+
validate: "type",
|
35
|
+
possibleValues: ["function"],
|
36
|
+
errorMessage: ["GDK CurrencyInput : onCompleteFormat must be a defined and set function"]
|
37
|
+
}];
|
38
|
+
|
39
|
+
/**
|
40
|
+
* CurrencyInput Class
|
41
|
+
*/
|
42
|
+
var CurrencyInput = /*#__PURE__*/function () {
|
43
|
+
/**
|
44
|
+
* These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
|
45
|
+
* @param {string|Object} content
|
46
|
+
* A reference to the component node of currency input field
|
47
|
+
*
|
48
|
+
* @param {string} [numType="decimal"]
|
49
|
+
* A string representing the number type of the currency input field
|
50
|
+
*
|
51
|
+
* @param {function} [onCompleteFormat]
|
52
|
+
* A callback function fired on blur after formatting is complete in the input field
|
53
|
+
*/
|
54
|
+
function CurrencyInput(options) {
|
55
|
+
_classCallCheck(this, CurrencyInput);
|
56
|
+
console.log('CurrencyInput initialized');
|
57
|
+
this._internalVars = {
|
58
|
+
node: null //used for current node
|
59
|
+
};
|
60
|
+
|
61
|
+
//options with defaults set
|
62
|
+
this._defaults = {
|
63
|
+
numType: 'decimal'
|
64
|
+
};
|
65
|
+
|
66
|
+
// Create options by extending defaults with the passed in arugments
|
67
|
+
if (options && _typeof(options) === "object") {
|
68
|
+
this._options = _baseComponent["default"].extendDefaults(this._defaults, options);
|
69
|
+
}
|
70
|
+
|
71
|
+
//if the required options are valid set up the environment
|
72
|
+
if (_baseComponent["default"].validateSettings(this._options, validateSettings)) {
|
73
|
+
this._internalVars.contentType = _baseComponent["default"].getContentType(this);
|
74
|
+
setLocalVars.call(this);
|
75
|
+
setEvents.call(this);
|
76
|
+
if (this._internalVars.node.getAttribute('type') != 'text') {
|
77
|
+
this._internalVars.node.setAttribute('type', 'text');
|
78
|
+
}
|
79
|
+
if (!this._internalVars.node.hasAttribute('placeholder') && this._options.numType == 'decimal') {
|
80
|
+
this._internalVars.node.setAttribute('placeholder', '0.00');
|
81
|
+
} else if (!this._internalVars.node.hasAttribute('placeholder') && this._options.numType == 'whole') {
|
82
|
+
this._internalVars.node.setAttribute('placeholder', '0');
|
83
|
+
}
|
84
|
+
if (this._internalVars.inputValue !== '') {
|
85
|
+
this._internalVars.inputValue = parsedValue(this._internalVars.inputValue, this._options.numType);
|
86
|
+
this._internalVars.inputValue = insertCommas(this._internalVars.inputValue.toString());
|
87
|
+
this._internalVars.node.setAttribute('value', this._internalVars.inputValue);
|
88
|
+
}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
|
92
|
+
//Public Methods
|
93
|
+
|
94
|
+
/**
|
95
|
+
* removes the node from the dom and any events attached
|
96
|
+
*/
|
97
|
+
return _createClass(CurrencyInput, [{
|
98
|
+
key: "destroy",
|
99
|
+
value: function destroy() {
|
100
|
+
removeEvents.call(this);
|
101
|
+
this._internalVars.node.parentNode.removeChild(this._internalVars.node);
|
102
|
+
|
103
|
+
//a little garbage collection
|
104
|
+
for (var variableKey in this) {
|
105
|
+
if (this.hasOwnProperty(variableKey)) {
|
106
|
+
delete this[variableKey];
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
/**
|
112
|
+
* getCurrencyInput()
|
113
|
+
* return a type float number from currency input field
|
114
|
+
* @returns {float}
|
115
|
+
*/
|
116
|
+
}, {
|
117
|
+
key: "getCurrencyInput",
|
118
|
+
value: function getCurrencyInput() {
|
119
|
+
return parseFloat(parsedValue(this._internalVars.node.value, this._options.numType));
|
120
|
+
}
|
121
|
+
}]);
|
122
|
+
}(); // Private Methods
|
123
|
+
/**
|
124
|
+
* setEvents()
|
125
|
+
* Sets all the events needed for the component
|
126
|
+
*/
|
127
|
+
function setEvents() {
|
128
|
+
this._internalVars.node.addEventListener("keydown", this._internalVars.keyDownHandler);
|
129
|
+
this._internalVars.node.addEventListener("keyup", this._internalVars.keyUpHandler);
|
130
|
+
this._internalVars.node.addEventListener("keypress", this._internalVars.keyPressHandler);
|
131
|
+
this._internalVars.node.addEventListener("blur", this._internalVars.blurHandler);
|
132
|
+
}
|
133
|
+
|
134
|
+
/**
|
135
|
+
* removeEvents()
|
136
|
+
* removes all events from the component
|
137
|
+
*/
|
138
|
+
function removeEvents() {
|
139
|
+
this._internalVars.node.removeEventListener("keydown", this._internalVars.keyDownHandler);
|
140
|
+
this._internalVars.node.removeEventListener("keyup", this._internalVars.keyUpHandler);
|
141
|
+
this._internalVars.node.removeEventListener("keypress", this._internalVars.keyPressHandler);
|
142
|
+
this._internalVars.node.removeEventListener("blur", this._internalVars.blurHandler);
|
143
|
+
}
|
144
|
+
function decimalExist(value) {
|
145
|
+
if (value.indexOf('.') != -1) {
|
146
|
+
return true;
|
147
|
+
} else {
|
148
|
+
return false;
|
149
|
+
}
|
150
|
+
}
|
151
|
+
function numOfCharAfterDecimal(value) {
|
152
|
+
return value.toString().substr(value.toString().indexOf(".") + 1).length;
|
153
|
+
}
|
154
|
+
function isCharacterValid(e, type) {
|
155
|
+
var keyCode = e.which || e.keyCode;
|
156
|
+
//numeric arrow key backspace and tab enter
|
157
|
+
if (keyCode >= 48 && keyCode <= 57 || keyCode >= 37 && keyCode <= 40 || keyCode >= 8 && keyCode <= 9 || keyCode == 13 || type == 'decimal' && keyCode == 190 || keyCode == 46) {
|
158
|
+
return true;
|
159
|
+
} else {
|
160
|
+
return false;
|
161
|
+
}
|
162
|
+
}
|
163
|
+
function parsedValue(value, type) {
|
164
|
+
if (type == 'decimal') {
|
165
|
+
return parseFloat(removeCommas(value)).toFixed(2);
|
166
|
+
} else if (type == 'whole') {
|
167
|
+
return parseInt(removeCommas(value));
|
168
|
+
}
|
169
|
+
}
|
170
|
+
function insertCommas(value) {
|
171
|
+
value = value.split('.');
|
172
|
+
if (value[1] !== undefined) {
|
173
|
+
return value[0].replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,") + '.' + value[1];
|
174
|
+
} else {
|
175
|
+
return value[0].replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");
|
176
|
+
}
|
177
|
+
}
|
178
|
+
function removeCommas(value) {
|
179
|
+
return value.replace(/[^\d\.]/g, '');
|
180
|
+
}
|
181
|
+
function commaCount(value) {
|
182
|
+
var counter = 0;
|
183
|
+
for (var i = 0; i < value.length; i++) {
|
184
|
+
if (value.charAt(i) == ',') {
|
185
|
+
counter++;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
return counter;
|
189
|
+
}
|
190
|
+
function isCaretBeforeDecimal(caretPos, decimalPos) {
|
191
|
+
if (caretPos <= decimalPos) {
|
192
|
+
return true;
|
193
|
+
} else if (caretPos > decimalPos) {
|
194
|
+
return false;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
function isSelected() {
|
198
|
+
if (document.getSelection().toString() !== '') {
|
199
|
+
return true;
|
200
|
+
} else if (document.getSelection().toString === '') {
|
201
|
+
return false;
|
202
|
+
}
|
203
|
+
}
|
204
|
+
|
205
|
+
//blur
|
206
|
+
function completeDisplay() {
|
207
|
+
this._internalVars.inputValue = this._internalVars.node.value;
|
208
|
+
if (this._internalVars.node.value !== '') {
|
209
|
+
this._internalVars.node.value = insertCommas(parsedValue(this._internalVars.inputValue, this._options.numType).toString());
|
210
|
+
if (this._options.onCompleteFormat) {
|
211
|
+
this._options.onCompleteFormat(parsedValue(this._internalVars.node.value, this._options.numType));
|
212
|
+
}
|
213
|
+
}
|
214
|
+
}
|
215
|
+
|
216
|
+
//keydown-initial
|
217
|
+
function inputCharacters(e) {
|
218
|
+
this._internalVars.inputValue = this._internalVars.node.value;
|
219
|
+
this._internalVars.caretLocation = this._internalVars.node.selectionStart;
|
220
|
+
this._internalVars.decimalLocation = this._internalVars.node.value.indexOf('.');
|
221
|
+
if (this._options.numType == 'decimal') {
|
222
|
+
if (decimalExist(this._internalVars.inputValue)) {
|
223
|
+
this._internalVars.allowDecimal = false;
|
224
|
+
} else {
|
225
|
+
this._internalVars.allowDecimal = true;
|
226
|
+
}
|
227
|
+
if (decimalExist(this._internalVars.inputValue) && !isCaretBeforeDecimal(this._internalVars.caretLocation, this._internalVars.decimalLocation) && numOfCharAfterDecimal(this._internalVars.inputValue) == 2 && !isSelected()) {
|
228
|
+
this._internalVars.allowCharacters = false;
|
229
|
+
this._internalVars.node.setAttribute('maxlength', this._internalVars.inputValue.length);
|
230
|
+
} else if (decimalExist(this._internalVars.inputValue) && isCaretBeforeDecimal(this._internalVars.caretLocation, this._internalVars.decimalLocation) && numOfCharAfterDecimal(this._internalVars.inputValue) <= 2 || isSelected()) {
|
231
|
+
this._internalVars.allowCharacters = true;
|
232
|
+
this._internalVars.node.removeAttribute('maxlength');
|
233
|
+
} else {
|
234
|
+
this._internalVars.allowCharacters = true;
|
235
|
+
this._internalVars.node.removeAttribute('maxlength');
|
236
|
+
}
|
237
|
+
} else if (this._options.numType == 'whole') {
|
238
|
+
this._internalVars.allowDecimal = false;
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
//keyup-after
|
243
|
+
function inputAutoCommas(e) {
|
244
|
+
var keyCode = e.which || e.keyCode;
|
245
|
+
this._internalVars.inputValue = this._internalVars.node.value;
|
246
|
+
this._internalVars.caretLocation = this._internalVars.node.selectionStart;
|
247
|
+
var beforeCommaCount = commaCount(this._internalVars.inputValue);
|
248
|
+
if (keyCode != 9 && keyCode != 16 && !(keyCode >= 37 && keyCode <= 40)) {
|
249
|
+
this._internalVars.node.value = insertCommas(removeCommas(this._internalVars.inputValue));
|
250
|
+
this._internalVars.inputValue = this._internalVars.node.value;
|
251
|
+
if (this._options.numType == 'whole') {
|
252
|
+
this._internalVars.node.value = this._internalVars.inputValue.replace('.', '');
|
253
|
+
}
|
254
|
+
var afterCommaCount = commaCount(this._internalVars.inputValue);
|
255
|
+
if (beforeCommaCount != afterCommaCount) {
|
256
|
+
this._internalVars.node.selectionStart = this._internalVars.caretLocation + 1;
|
257
|
+
this._internalVars.node.selectionEnd = this._internalVars.caretLocation + 1;
|
258
|
+
if (keyCode == 8) {
|
259
|
+
this._internalVars.node.selectionStart = this._internalVars.caretLocation - 1;
|
260
|
+
this._internalVars.node.selectionEnd = this._internalVars.caretLocation - 1;
|
261
|
+
}
|
262
|
+
} else {
|
263
|
+
this._internalVars.node.selectionStart = this._internalVars.caretLocation;
|
264
|
+
this._internalVars.node.selectionEnd = this._internalVars.caretLocation;
|
265
|
+
}
|
266
|
+
}
|
267
|
+
}
|
268
|
+
|
269
|
+
//keypress
|
270
|
+
function preventInput(event) {
|
271
|
+
if (!isCharacterValid(event, this._options.numType) || !this._internalVars.allowCharacters && event.which != 8) {
|
272
|
+
event.preventDefault();
|
273
|
+
}
|
274
|
+
if (!this._internalVars.allowDecimal && event.which == 46) {
|
275
|
+
event.preventDefault();
|
276
|
+
}
|
277
|
+
if (event.shiftKey && event.which == 37 || event.which == 38) {
|
278
|
+
event.preventDefault();
|
279
|
+
}
|
280
|
+
}
|
281
|
+
|
282
|
+
/**
|
283
|
+
* setLocalVars()
|
284
|
+
* set local vars to the ones passed in options
|
285
|
+
*/
|
286
|
+
function setLocalVars() {
|
287
|
+
if (this._internalVars.contentType === 'string') {
|
288
|
+
this._internalVars.node = document.querySelector(this._options.content);
|
289
|
+
} else if (this._internalVars.contentType === 'domNode') {
|
290
|
+
this._internalVars.node = this._options.content;
|
291
|
+
}
|
292
|
+
this._internalVars.keyDownHandler = inputCharacters.bind(this);
|
293
|
+
this._internalVars.keyUpHandler = inputAutoCommas.bind(this);
|
294
|
+
this._internalVars.keyPressHandler = preventInput.bind(this);
|
295
|
+
this._internalVars.blurHandler = completeDisplay.bind(this);
|
296
|
+
this._internalVars.inputValue = this._internalVars.node.value;
|
297
|
+
this._internalVars.caretLocation = this._internalVars.node.selectionStart;
|
298
|
+
this._internalVars.decimalLocation = this._internalVars.node.value.indexOf('.');
|
299
|
+
this._internalVars.allowCharacters = true;
|
300
|
+
this._internalVars.allowDecimal = true;
|
301
|
+
}
|
302
|
+
var _default = exports["default"] = CurrencyInput;
|