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.

Files changed (107) hide show
  1. package/.babelrc +5 -0
  2. package/LICENSE +0 -0
  3. package/dist/analytics.js +119 -0
  4. package/dist/appState.js +56 -0
  5. package/dist/baseComponent.js +110 -0
  6. package/dist/components/Accordion.js +312 -0
  7. package/dist/components/AddressAutoComplete.js +220 -0
  8. package/dist/components/Alert.js +145 -0
  9. package/dist/components/BackgroundPattern.js +99 -0
  10. package/dist/components/BackgroundPatternPortfolio.js +242 -0
  11. package/dist/components/ButtonSwitch.js +236 -0
  12. package/dist/components/CardSelections.js +230 -0
  13. package/dist/components/CommonQuestionsSquares.js +169 -0
  14. package/dist/components/Confirmation.js +156 -0
  15. package/dist/components/ConsolidatedSummary.js +489 -0
  16. package/dist/components/CoverageGraph.js +201 -0
  17. package/dist/components/CreditCard.js +591 -0
  18. package/dist/components/CurrencyInput.js +302 -0
  19. package/dist/components/DatePicker.js +468 -0
  20. package/dist/components/DockedMessage.js +146 -0
  21. package/dist/components/DotNavigation.js +200 -0
  22. package/dist/components/EditComponent.js +128 -0
  23. package/dist/components/EditableTable.js +113 -0
  24. package/dist/components/InPageNavigation.js +360 -0
  25. package/dist/components/Loader.js +232 -0
  26. package/dist/components/MakePayment.js +361 -0
  27. package/dist/components/Modal.js +254 -0
  28. package/dist/components/MoreInfoButton.js +227 -0
  29. package/dist/components/MultipleSelectBox.js +217 -0
  30. package/dist/components/NavigationalBox.js +161 -0
  31. package/dist/components/Navigator.js +294 -0
  32. package/dist/components/PasswordMeter.js +201 -0
  33. package/dist/components/PayPlans.js +534 -0
  34. package/dist/components/SegmentedControl.js +327 -0
  35. package/dist/components/SortableTable.js +166 -0
  36. package/dist/components/Tabs.js +1 -0
  37. package/dist/components/TextAreaCountdown.js +219 -0
  38. package/dist/components/Timeline.js +498 -0
  39. package/dist/components/TimelineFilter.js +492 -0
  40. package/dist/components/ToTopArrow.js +153 -0
  41. package/dist/components/Tooltip.js +329 -0
  42. package/dist/components/Upsell.js +168 -0
  43. package/dist/components/VIN.js +271 -0
  44. package/dist/components/ValidateForm.js +938 -0
  45. package/dist/components/ViewMoreLess.js +191 -0
  46. package/dist/components/ZipCode.js +191 -0
  47. package/dist/components/portfolio.js +99 -0
  48. package/dist/geico-design-kit.js +141 -0
  49. package/dist/global/components.js +98 -0
  50. package/dist/global/footer.js +26 -0
  51. package/dist/global/nav.js +1257 -0
  52. package/dist/services/CharacterTypeService.js +106 -0
  53. package/dist/services/UserAgentService.js +73 -0
  54. package/dist/utils.js +79 -0
  55. package/package.json +32 -0
  56. package/src/analytics.js +82 -0
  57. package/src/appState.js +56 -0
  58. package/src/baseComponent.js +156 -0
  59. package/src/components/Accordion.js +336 -0
  60. package/src/components/AddressAutoComplete.js +236 -0
  61. package/src/components/Alert.js +135 -0
  62. package/src/components/BackgroundPattern.js +96 -0
  63. package/src/components/BackgroundPatternPortfolio.js +284 -0
  64. package/src/components/ButtonSwitch.js +241 -0
  65. package/src/components/CardSelections.js +240 -0
  66. package/src/components/CommonQuestionsSquares.js +179 -0
  67. package/src/components/Confirmation.js +160 -0
  68. package/src/components/ConsolidatedSummary.js +505 -0
  69. package/src/components/CoverageGraph.js +203 -0
  70. package/src/components/CreditCard.js +595 -0
  71. package/src/components/CurrencyInput.js +321 -0
  72. package/src/components/DatePicker.js +487 -0
  73. package/src/components/DockedMessage.js +142 -0
  74. package/src/components/DotNavigation.js +206 -0
  75. package/src/components/EditComponent.js +130 -0
  76. package/src/components/EditableTable.js +106 -0
  77. package/src/components/InPageNavigation.js +391 -0
  78. package/src/components/Loader.js +272 -0
  79. package/src/components/MakePayment.js +397 -0
  80. package/src/components/Modal.js +279 -0
  81. package/src/components/MoreInfoButton.js +243 -0
  82. package/src/components/MultipleSelectBox.js +211 -0
  83. package/src/components/NavigationalBox.js +163 -0
  84. package/src/components/Navigator.js +338 -0
  85. package/src/components/PasswordMeter.js +209 -0
  86. package/src/components/PayPlans.js +604 -0
  87. package/src/components/SegmentedControl.js +365 -0
  88. package/src/components/SortableTable.js +176 -0
  89. package/src/components/Tabs.js +0 -0
  90. package/src/components/TextAreaCountdown.js +231 -0
  91. package/src/components/Timeline.js +532 -0
  92. package/src/components/TimelineFilter.js +533 -0
  93. package/src/components/ToTopArrow.js +153 -0
  94. package/src/components/Tooltip.js +344 -0
  95. package/src/components/Upsell.js +196 -0
  96. package/src/components/VIN.js +289 -0
  97. package/src/components/ValidateForm.js +1030 -0
  98. package/src/components/ViewMoreLess.js +193 -0
  99. package/src/components/ZipCode.js +193 -0
  100. package/src/components/portfolio.js +106 -0
  101. package/src/geico-design-kit.js +144 -0
  102. package/src/global/components.js +92 -0
  103. package/src/global/footer.js +25 -0
  104. package/src/global/nav.js +1457 -0
  105. package/src/services/CharacterTypeService.js +107 -0
  106. package/src/services/UserAgentService.js +59 -0
  107. package/src/utils.js +82 -0
@@ -0,0 +1,271 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _baseComponent = _interopRequireDefault(require("../../src/baseComponent"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
+ 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); }
10
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
11
+ 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); } }
12
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
13
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
+ 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); }
15
+ var validateSettings = [{
16
+ setting: "content",
17
+ isRequired: true,
18
+ validate: "type",
19
+ possibleValues: ["string", "object"],
20
+ errorMessage: ["GDK VINCountdown : Content must be defined and set to a DOM selector or Node"]
21
+ }, {
22
+ setting: "countdownMax",
23
+ isRequired: false,
24
+ validate: "type",
25
+ possibleValues: ["number"],
26
+ errorMessage: ["GDK VINCountdown : countdownMax must be a number"]
27
+ }, {
28
+ setting: "onCharacterType",
29
+ isRequired: false,
30
+ validate: "type",
31
+ possibleValues: ["function"],
32
+ errorMessage: ["GDK VINCountdown : Content must be defined and set to a function"]
33
+ }];
34
+ var VINCountdown = /*#__PURE__*/function () {
35
+ /**
36
+ * Refer to the design kit section of this component for JS examples and setting details.
37
+ * @param {string, Object} content
38
+ * A reference to the html textarea container node
39
+ *
40
+ * @param {number} [countdownMax=1000]
41
+ * The number of characters allowed in the textarea
42
+ *
43
+ */
44
+ function VINCountdown(options) {
45
+ _classCallCheck(this, VINCountdown);
46
+ this._internalVars = {
47
+ node: null,
48
+ //used for content item
49
+ geicoVINCountdownContainerClass: "vin-countdown-container",
50
+ geicoVINCountdownClass: "vin-area-countdown",
51
+ geicoTextAreaGoodClass: "vin-countdown--good",
52
+ geicoTextAreaCloseClass: "vin-countdown--close",
53
+ geicoTextAreaOverClass: "vin-countdown--over",
54
+ geicoVINCountdownInfoClass: "vin-countdown-info",
55
+ geicoVINCountdownInfoTextClass: "vin-countdown-info-text",
56
+ geicoVINCountdownInfoCounterClass: "vin-countdown-info-counter",
57
+ geicoTextGoodCopy: "Characters Remaining: ",
58
+ geicoTextCloseCopy: "Characters Remaining: ",
59
+ geicoTextOverCopy: "Over by: ",
60
+ closeNum: 10,
61
+ geicoVINCountdownData: null,
62
+ count: null
63
+ };
64
+
65
+ //options with defaults set
66
+ this._defaults = {
67
+ countdownMax: 17
68
+ };
69
+
70
+ // Create options by extending defaults with the passed in arguments
71
+ if (options && _typeof(options) === "object") {
72
+ this._options = _baseComponent["default"].extendDefaults(this._defaults, options);
73
+ }
74
+
75
+ //if the required options are valid set up the environment
76
+ if (_baseComponent["default"].validateSettings(this._options, validateSettings)) {
77
+ this._internalVars.contentType = _baseComponent["default"].getContentType(this);
78
+ setLocalVars.call(this);
79
+ setEvents.call(this);
80
+ }
81
+ }
82
+
83
+ //Public Methods
84
+
85
+ /**
86
+ * destroy()
87
+ * removes the node from the dom and any events attached
88
+ */
89
+ return _createClass(VINCountdown, [{
90
+ key: "destroy",
91
+ value: function destroy() {
92
+ removeEvents.call(this);
93
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
94
+
95
+ //a little garbage collection
96
+ for (var variableKey in this) {
97
+ if (this.hasOwnProperty(variableKey)) {
98
+ delete this[variableKey];
99
+ }
100
+ }
101
+ }
102
+
103
+ /**
104
+ * setVINLength(newLength)
105
+ * @param newLength
106
+ * sets the length of the VIN and updates the corresponding countdown number
107
+ */
108
+ }, {
109
+ key: "setVINLength",
110
+ value: function setVINLength(newLength) {
111
+ if (typeof newLength === "number") {
112
+ updateVINLength.call(this, newLength);
113
+ }
114
+ }
115
+ }]);
116
+ }(); // Private Methods
117
+ /**
118
+ * setEvents()
119
+ * Sets all the events needed for the component
120
+ */
121
+ function setEvents() {
122
+ this._internalVars.textArea.addEventListener("change", this._internalVars.handler);
123
+ this._internalVars.textArea.addEventListener("keyup", this._internalVars.handler);
124
+ this._internalVars.textArea.addEventListener("keydown", this._internalVars.handler);
125
+ this._internalVars.textArea.addEventListener("blur", this._internalVars.handler);
126
+ this._internalVars.textArea.addEventListener("paste", pasteHandler);
127
+ this._internalVars.textArea.addEventListener("keypress", this._internalVars.checkInputHandler);
128
+ this._internalVars.textArea.addEventListener("input", this._internalVars.replaceCharactersHandler);
129
+ }
130
+
131
+ /**
132
+ * removeEvents()
133
+ * removes all events from the component
134
+ */
135
+ function removeEvents() {
136
+ this._internalVars.textArea.removeEventListener("change", this._internalVars.handler);
137
+ this._internalVars.textArea.removeEventListener("keyup", this._internalVars.handler);
138
+ this._internalVars.textArea.removeEventListener("keydown", this._internalVars.handler);
139
+ this._internalVars.textArea.removeEventListener("blur", this._internalVars.handler);
140
+ this._internalVars.textArea.removeEventListener("paste", pasteHandler);
141
+ this._internalVars.textArea.removeEventListener("keypress", this._internalVars.checkInputHandler);
142
+ this._internalVars.textArea.removeEventListener("input", this._internalVars.replaceCharactersHandler);
143
+ }
144
+ function checkInputValue(evt) {
145
+ if (this._options.onCharacterType) {
146
+ this._options.onCharacterType();
147
+ }
148
+ }
149
+ function updateVINLength(newLength) {
150
+ this._options.countdownMax = newLength;
151
+ this._internalVars.countdownInfoCounter.innerHTML = newLength - this._internalVars.textArea.value.length;
152
+ this._internalVars.textArea.setAttribute("maxlength", newLength);
153
+ }
154
+
155
+ /**
156
+ * pasteHandler()
157
+ * triggers a keydown event on paste
158
+ */
159
+ function pasteHandler(evt) {
160
+ var _this = evt.currentTarget;
161
+ setTimeout(function () {
162
+ var event = document.createEvent('HTMLEvents');
163
+ event.initEvent('keydown', true, false);
164
+ _this.dispatchEvent(event);
165
+ }, 10);
166
+ }
167
+
168
+ /**
169
+ * updateCountdown()
170
+ * updates the countdown text and counter
171
+ */
172
+ function updateCountdown(evt) {
173
+ var _this = evt.currentTarget;
174
+ var container = _this.parentNode;
175
+ var text = _this.value;
176
+ var remaining = this._options.countdownMax - text.length;
177
+ if (remaining < 0) {
178
+ this._internalVars.countdownInfoText.textContent = this._internalVars.geicoTextOverCopy;
179
+ this._internalVars.countdownInfoTextCurrent = this._internalVars.geicoTextOverCopy;
180
+ container.classList.remove(this._internalVars.geicoTextAreaCloseClass);
181
+ container.classList.add(this._internalVars.geicoTextAreaOverClass);
182
+ } else if (remaining < 10) {
183
+ this._internalVars.countdownInfoText.textContent = this._internalVars.geicoTextCloseCopy;
184
+ this._internalVars.countdownInfoTextCurrent = this._internalVars.geicoTextCloseCopy;
185
+ container.classList.remove(this._internalVars.geicoTextAreaGoodClass);
186
+ container.classList.remove(this._internalVars.geicoTextAreaOverClass);
187
+ container.classList.add(this._internalVars.geicoTextAreaCloseClass);
188
+ } else if (this._internalVars.countdownInfoTextCurrent === this._internalVars.geicoTextCloseCopy || this._internalVars.countdownInfoTextCurrent === this._internalVars.geicoTextOverCopy) {
189
+ this._internalVars.countdownInfoText.textContent = this._internalVars.geicoTextGoodCopy;
190
+ this._internalVars.countdownInfoTextCurrent = this._internalVars.geicoTextGoodCopy;
191
+ container.classList.remove(this._internalVars.geicoTextAreaCloseClass);
192
+ container.classList.remove(this._internalVars.geicoTextAreaOverClass);
193
+ container.classList.add(this._internalVars.geicoTextAreaGoodClass);
194
+ }
195
+ updateRemaining.call(this, remaining, text.length, this._options.countdownMax, this._internalVars.countdownInfoCounter);
196
+ }
197
+
198
+ /**
199
+ * updateRemaining()
200
+ * updates the remaining characters left
201
+ */
202
+ function updateRemaining(remaining, tl, countdown, countdownInfoCounter) {
203
+ var val = remaining;
204
+ if (remaining === 0) val = 0;else if (remaining < 0) val = tl - countdown;
205
+ countdownInfoCounter.textContent = val;
206
+ }
207
+
208
+ /**
209
+ * setLocalVars()
210
+ * set all the local vars to passed in options
211
+ */
212
+ function setLocalVars() {
213
+ //determine the type of content passed in
214
+ if (this._internalVars.contentType === 'string') {
215
+ this._internalVars.node = document.querySelector(this._options.content);
216
+ } else if (this._internalVars.contentType === 'domNode') {
217
+ this._internalVars.node = this._options.content;
218
+ }
219
+
220
+ //node to hold status text
221
+ var infoText = document.createElement("SPAN");
222
+ infoText.classList.add(this._internalVars.geicoVINCountdownInfoTextClass);
223
+
224
+ //node to hold count of characters left
225
+ var infoCounter = document.createElement("SPAN");
226
+ infoCounter.classList.add(this._internalVars.geicoVINCountdownInfoCounterClass);
227
+
228
+ //node to hold count of characters left
229
+ var countdownInfo = document.createElement("DIV");
230
+ countdownInfo.classList.add(this._internalVars.geicoVINCountdownInfoClass);
231
+ countdownInfo.setAttribute('aria-live', 'polite');
232
+ countdownInfo.setAttribute('aria-atomic', 'true');
233
+
234
+ //add the text and counter to the container
235
+ countdownInfo.appendChild(infoText);
236
+ countdownInfo.appendChild(infoCounter);
237
+
238
+ //append the container to the node
239
+ this._internalVars.node.appendChild(countdownInfo);
240
+ //set initial class for container
241
+ this._internalVars.node.classList.add(this._internalVars.geicoTextAreaGoodClass);
242
+
243
+ //get access to the textarea, counter and counter info for future reference
244
+ this._internalVars.textArea = this._internalVars.node.querySelector("." + this._internalVars.geicoVINCountdownClass);
245
+ this._internalVars.countdownInfoText = this._internalVars.node.querySelector("." + this._internalVars.geicoVINCountdownInfoTextClass);
246
+ this._internalVars.countdownInfoCounter = this._internalVars.node.querySelector("." + this._internalVars.geicoVINCountdownInfoCounterClass);
247
+ this._internalVars.countdownInfoTextCurrent = this._internalVars.geicoTextGoodCopy;
248
+ this._internalVars.countdownInfoCounter.textContent = this._options.countdownMax;
249
+ this._internalVars.countdownInfoText.textContent = this._internalVars.countdownInfoTextCurrent;
250
+ this._internalVars.handler = updateCountdown.bind(this);
251
+ this._internalVars.replaceCharactersHandler = replaceCharacters.bind(this);
252
+ this._internalVars.checkInputHandler = checkInputValue.bind(this);
253
+ }
254
+ function replaceCharacters() {
255
+ var entryArray = this._internalVars.textArea.value.split('');
256
+ var convertedArray = [];
257
+ Array.prototype.forEach.call(entryArray, function (el) {
258
+ if (el === 'i' || el === 'I') {
259
+ convertedArray.push('1');
260
+ } else if (el === 'o' || el === 'O') {
261
+ convertedArray.push('0');
262
+ } else if (el === 'q' || el === 'Q') {
263
+ convertedArray.push('0');
264
+ } else {
265
+ convertedArray.push(el);
266
+ }
267
+ });
268
+ var entry = convertedArray.join('');
269
+ this._internalVars.textArea.value = entry;
270
+ }
271
+ var _default = exports["default"] = VINCountdown;