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,220 @@
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
+ var _UserAgentService = _interopRequireDefault(require("../../src/services/UserAgentService"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
+ 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); }
11
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
12
+ 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); } }
13
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
15
+ 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); } //Require static assets
16
+ /*
17
+ Problems:
18
+ 1) Requiring a specific ID – The code as-is requires a specific ID for the search field (code: let input = document.querySelector('#address-search-field');). This requires that we only use 1 instance of this address autocomplete on the screen at one time and forces us to use specific IDs. I’ve complained about this pattern repeatedly over the last couple years and it still seems to be the go to solution for the design team implementations of things. (NOTE: it also requires specific IDs for each and every field of the address that directly match data coming back from google’s apis.)
19
+ 2) The implementation doesn’t seem to keep in mind anything related to single-page application design (regardless of technology):
20
+ a. The implementation requires a global javascript function to be present at page load time.
21
+ b. It presumes to know what the IDs and types of all the input fields are and auto-populates them with no ability to notify client code when this has occurred. This screws up any kind of data binding technology (angular, knockout, etc)
22
+ 3) It does not seem to include Zip +4 (which it looks like the Google APIs don’t return)
23
+ 4) It hard codes English text (code: message.innerHTML = 'No Results Found';)
24
+ 5) It watches the entire document body for changes to see if a DOM node is inserted. (code: document.body.addEventListener('DOMNodeInserted', function (event)…). That can’t possibly be necessary.
25
+
26
+ Questions:
27
+ 1) Is this supposed to be the new way all addresses are entered in the system, or just an optional component for teams to use? (did you talk to multiple teams to gather requirements or was this just implemented at the request of one team?)
28
+ */
29
+ var validateSettings = [{
30
+ setting: "content",
31
+ isRequired: true,
32
+ validate: "type",
33
+ possibleValues: ["string", "object"],
34
+ errorMessage: ["GDK AddressAutoComplete : Content must be defined and set to a DOM selector or Node"]
35
+ }];
36
+ var ieVersion = _UserAgentService["default"]._detectIE();
37
+ var ValueSelected = false;
38
+ var selector;
39
+ var event;
40
+ if (ieVersion) {
41
+ //set event for IE
42
+ console.log('This is the Windows IE Setup: ' + ieVersion);
43
+ event = document.createEvent('HTMLEvents');
44
+ event.initEvent('gdk-address-updated', true, true);
45
+ } else {
46
+ //set event for non IE
47
+ event = new Event('gdk-address-updated');
48
+ }
49
+ var AddressAutoComplete = /*#__PURE__*/function () {
50
+ function AddressAutoComplete(options) {
51
+ _classCallCheck(this, AddressAutoComplete);
52
+ this._internalVars = {
53
+ node: null //used for content item
54
+ };
55
+
56
+ //options with defaults set
57
+ this._defaults = {};
58
+
59
+ // Create options by extending defaults with the passed in arugments
60
+ if (options && _typeof(options) === "object") {
61
+ this._options = _baseComponent["default"].extendDefaults(this._defaults, options);
62
+ }
63
+
64
+ //if the required options are valid set up the environment
65
+ if (_baseComponent["default"].validateSettings(this._options, validateSettings)) {
66
+ if (document.querySelector(this._options.content)) {
67
+ selector = this._options.content;
68
+ this._internalVars.contentType = _baseComponent["default"].getContentType(this);
69
+ setLocalVars.call(this);
70
+ setEvents.call(this);
71
+ init.call(this);
72
+ }
73
+ }
74
+ }
75
+
76
+ //Public Methods
77
+
78
+ // Bias the autocomplete object to the user's geographical location,
79
+ // as supplied by the browser's 'navigator.geolocation' object.
80
+ return _createClass(AddressAutoComplete, [{
81
+ key: "geolocate",
82
+ value: function geolocate() {
83
+ if (navigator.geolocation) {
84
+ navigator.geolocation.getCurrentPosition(function (position) {
85
+ var geolocation = {
86
+ lat: position.coords.latitude,
87
+ lng: position.coords.longitude
88
+ };
89
+ var circle = new google.maps.Circle({
90
+ center: geolocation,
91
+ radius: position.coords.accuracy
92
+ });
93
+ this.autoComplete.setBounds(circle.getBounds());
94
+ });
95
+ }
96
+ }
97
+ }, {
98
+ key: "getAddressObject",
99
+ value: function getAddressObject() {
100
+ var formattedAddress = {
101
+ formatted_address: this._internalVars.placesObject.formatted_address,
102
+ address_components: this._internalVars.placesObject.address_components,
103
+ geolocation: this._internalVars.placesObject.geometry.location
104
+ };
105
+ return formattedAddress;
106
+ }
107
+ }]);
108
+ }();
109
+ /**
110
+ * setLocalVars()
111
+ * set all the local vars to passed in options
112
+ */
113
+ function setLocalVars() {
114
+ //determine the type of content passed in
115
+ if (this._internalVars.contentType === 'string') {
116
+ this._internalVars.node = document.querySelector(this._options.content);
117
+ } else if (this._internalVars.contentType === 'domNode') {
118
+ this._internalVars.node = this._options.content;
119
+ }
120
+ this._internalVars.addressSearchField = this._internalVars.node.querySelector('.address-search-field');
121
+ this._internalVars.searchClearBtn = this._internalVars.node.querySelector('.btn--search-clear');
122
+
123
+ // Create the autocomplete object, restricting the search to geographical
124
+ // location types.
125
+ this.autoComplete = new google.maps.places.Autocomplete( /** @type {!HTMLInputElement} */this._internalVars.addressSearchField, {
126
+ types: ['geocode']
127
+ });
128
+ this._internalVars.componentForm = {
129
+ street_number: 'short_name',
130
+ route: 'long_name',
131
+ locality: 'long_name',
132
+ administrative_area_level_1: 'short_name',
133
+ country: 'long_name',
134
+ postal_code: 'short_name'
135
+ };
136
+ this._internalVars.placesObject = {};
137
+ }
138
+
139
+ /**
140
+ * setEvents()
141
+ * Sets all the events needed for the component
142
+ */
143
+ function setEvents() {
144
+ this._internalVars.searchClearBtn.addEventListener('click', clearSearch.bind(this));
145
+ this._internalVars.addressSearchField.addEventListener('input', toggleClearButton.bind(this));
146
+ }
147
+ function clearSearch() {
148
+ this._internalVars.addressSearchField.value = '';
149
+ toggleClearButton.call(this);
150
+ }
151
+ function toggleClearButton() {
152
+ if (this._internalVars.addressSearchField.value !== '') {
153
+ this._internalVars.searchClearBtn.classList.remove('hidden');
154
+ } else {
155
+ this._internalVars.searchClearBtn.classList.add('hidden');
156
+ }
157
+ }
158
+ function init() {
159
+ console.log('stop here');
160
+ // Hide the search close button
161
+ if (this._internalVars.addressSearchField.value === '' && !this._internalVars.searchClearBtn.classList.contains('hidden')) {
162
+ this._internalVars.searchClearBtn.classList.add('hidden');
163
+ }
164
+
165
+ // When the user selects an address from the dropdown, populate the address
166
+ // fields in the form.
167
+ this.autoComplete.addListener('place_changed', fillInAddress.bind(this));
168
+ var styleInitialized = false;
169
+ if (document.querySelector(selector).querySelector('.address-search-field') !== null) {
170
+ document.querySelector(selector).querySelector('.address-search-field').addEventListener('blur', function (event) {
171
+ if (document.querySelector('.pac-container') && document.querySelector('.pac-container').children.length === 0 && event.target.value.length !== 0 && document.querySelector('.address_1').value.length === 0) {
172
+ document.querySelector('.address_1').value = event.target.value;
173
+ event.target.value = '';
174
+ }
175
+ });
176
+ }
177
+ }
178
+ function fillInAddress() {
179
+ console.log('new results :) ');
180
+ ValueSelected = true;
181
+
182
+ // Get the place details from the autocomplete object.
183
+ var place = this.autoComplete.getPlace();
184
+ this._internalVars.placesObject = place;
185
+ document.dispatchEvent(event);
186
+
187
+ // Reset All Fields
188
+ var address1Element = this._internalVars.node.querySelector('.address_1');
189
+ address1Element.value = '';
190
+ address1Element.disabled = false;
191
+ for (var component in this._internalVars.componentForm) {
192
+ if (component !== 'street_number' && component !== 'route' && this._internalVars.node.querySelector('.' + component) !== null) {
193
+ var element = this._internalVars.node.querySelector('.' + component);
194
+ element.value = '';
195
+ element.disabled = false;
196
+ }
197
+ }
198
+
199
+ // Get each component of the address from the place details
200
+ // and fill the corresponding field on the form.
201
+ for (var i = 0; i < place.address_components.length; i++) {
202
+ var addressType = place.address_components[i].types[0];
203
+ if (this._internalVars.componentForm[addressType]) {
204
+ var val = place.address_components[i][this._internalVars.componentForm[addressType]];
205
+ if (addressType === 'street_number') {
206
+ address1Element.value = val + ' ';
207
+ } else if (addressType === 'route') {
208
+ address1Element.value = address1Element.value + val;
209
+ } else {
210
+ if (this._internalVars.node.querySelector('.' + addressType)) {
211
+ this._internalVars.node.querySelector('.' + addressType).value = val;
212
+ }
213
+ }
214
+ }
215
+ }
216
+ clearSearch.call(this);
217
+
218
+ // document.querySelector(selector).value = '';
219
+ }
220
+ var _default = exports["default"] = AddressAutoComplete;
@@ -0,0 +1,145 @@
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 Alert : Content must be defined and set to a DOM selector or Node']
21
+ }];
22
+ var Alert = /*#__PURE__*/function () {
23
+ /**
24
+ * These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
25
+ * @param {string|Object} content
26
+ * A reference to the html alert node
27
+ */
28
+ function Alert(options) {
29
+ _classCallCheck(this, Alert);
30
+ this._internalVars = {
31
+ node: null,
32
+ //used for current node
33
+ alertContentClass: "alert-content",
34
+ alertContent: null,
35
+ alertCloseBtnClass: "icon-close-20",
36
+ alertCloseBtn: null
37
+ };
38
+
39
+ //options with defaults set
40
+ this._defaults = {};
41
+
42
+ // Create options by extending defaults with the passed in arugments
43
+ if (options && _typeof(options) === "object") {
44
+ this._options = _baseComponent["default"].extendDefaults(this._defaults, options);
45
+ }
46
+
47
+ //if the required options are valid set up the environment
48
+ if (_baseComponent["default"].validateSettings(this._options, validateSettings)) {
49
+ this._internalVars.contentType = _baseComponent["default"].getContentType(this);
50
+ setLocalVars.call(this);
51
+ setEvents.call(this);
52
+ }
53
+ }
54
+
55
+ //Public Methods
56
+
57
+ /**
58
+ * removes the node from the dom and any events attached
59
+ */
60
+ return _createClass(Alert, [{
61
+ key: "destroy",
62
+ value: function destroy() {
63
+ removeEvents.call(this);
64
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
65
+
66
+ //a little garbage collection
67
+ for (var variableKey in this) {
68
+ if (this.hasOwnProperty(variableKey)) {
69
+ delete this[variableKey];
70
+ }
71
+ }
72
+ }
73
+ }]);
74
+ }(); // Private Methods
75
+ function setLocalVars() {
76
+ if (this._internalVars.contentType === 'string') {
77
+ this._internalVars.node = document.querySelector(this._options.content);
78
+ } else if (this._internalVars.contentType === 'domNode') {
79
+ this._internalVars.node = this._options.content;
80
+ }
81
+ this._internalVars.alertCloseBtn = this._internalVars.node.querySelectorAll('button.' + this._internalVars.alertCloseBtnClass);
82
+ }
83
+
84
+ /**
85
+ * setEvents()
86
+ * Sets all the events needed for the component
87
+ */
88
+ function setEvents() {
89
+ for (var i = 0; i < this._internalVars.alertCloseBtn.length; i++) {
90
+ this._internalVars.alertCloseBtn[i].addEventListener("click", removeAlert.bind(this, this._internalVars.alertCloseBtn[i]));
91
+ }
92
+ }
93
+ function removeEvents() {
94
+ for (var i = 0; i < this._internalVars.alertCloseBtn.length; i++) {
95
+ this._internalVars.alertCloseBtn[i].removeEventListener("click", removeAlert.bind(this, this._internalVars.alertCloseBtn[i]));
96
+ }
97
+ }
98
+
99
+ /**
100
+ * removeAlert()
101
+ * checks to remove Alert appropriately
102
+ */
103
+ function removeAlert(e) {
104
+ if (this._internalVars.node.children.length == 1 && e.parentNode.parentNode.children.length == 1) {
105
+ fadeAndRemove(this._internalVars.node);
106
+ }
107
+ if (e.parentNode.parentNode.children.length == 1) {
108
+ fadeAndRemove(e.parentNode.parentNode.parentNode);
109
+ }
110
+ fadeAndRemove(e.parentNode);
111
+ }
112
+
113
+ /**
114
+ * fade()
115
+ * fade effect
116
+ */
117
+ function fadeOutEffect(e) {
118
+ var op = 1; // initial opacity
119
+ var timer = setInterval(function () {
120
+ if (op <= 0.01) {
121
+ clearInterval(timer);
122
+ }
123
+ e.style.opacity = op;
124
+ e.style.filter = 'alpha(opacity=' + op * 100 + ")";
125
+ op -= op * 0.1;
126
+ }, 15);
127
+ }
128
+
129
+ /**
130
+ * removeChildCall
131
+ * Instantiate removal of child element
132
+ */
133
+ function removeChildCall(e) {
134
+ e.parentNode.removeChild(e);
135
+ }
136
+
137
+ /**
138
+ * fadeAndRemove()
139
+ * Combine fade effect with delayed removal of element
140
+ */
141
+ function fadeAndRemove(e) {
142
+ fadeOutEffect(e);
143
+ setTimeout(removeChildCall, 500, e);
144
+ }
145
+ var _default = exports["default"] = Alert;
@@ -0,0 +1,99 @@
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 Trianglify = require('trianglify');
16
+ var validateSettings = [{
17
+ setting: "content",
18
+ isRequired: true,
19
+ validate: "type",
20
+ possibleValues: ["string", "object"],
21
+ errorMessage: ["GDK BackgroundPattern : Content must be defined and set to a DOM selector or Node"]
22
+ }];
23
+ var BackgroundPattern = /*#__PURE__*/function () {
24
+ /**
25
+ * These are settings for the instantiation. Refer to the design kit section of this component for JS setting examples.
26
+ * @param {string|Object} content
27
+ * A reference to the html More Background Pattern node
28
+ */
29
+ function BackgroundPattern(options) {
30
+ _classCallCheck(this, BackgroundPattern);
31
+ console.log('BackgroundPattern initialized');
32
+
33
+ //SM=75 MED=125 LG=175
34
+
35
+ this._internalVars = {
36
+ node: null //used for current node
37
+ };
38
+
39
+ //options with defaults set
40
+ this._defaults = {};
41
+
42
+ // Create options by extending defaults with the passed in arugments
43
+ if (options && _typeof(options) === "object") {
44
+ this._options = _baseComponent["default"].extendDefaults(this._defaults, options);
45
+ }
46
+
47
+ //if the required options are valid set up the environment
48
+ if (_baseComponent["default"].validateSettings(this._options, validateSettings)) {
49
+ this._internalVars.contentType = _baseComponent["default"].getContentType(this);
50
+ setLocalVars.call(this);
51
+ init.call(this);
52
+ }
53
+ }
54
+
55
+ /**
56
+ * destroy()
57
+ * removes the node from the dom and any events attached
58
+ */
59
+ return _createClass(BackgroundPattern, [{
60
+ key: "destroy",
61
+ value: function destroy() {
62
+ this._internalVars.node.parentNode.removeChild(this._internalVars.node);
63
+
64
+ //a little garbage collection
65
+ for (var variableKey in this) {
66
+ if (this.hasOwnProperty(variableKey)) {
67
+ delete this[variableKey];
68
+ }
69
+ }
70
+ }
71
+ }]);
72
+ }(); // Private Methods
73
+ /**
74
+ * init()
75
+ * Initializes the Trianglify pattern
76
+ */
77
+ function init() {
78
+ var pattern = Trianglify({
79
+ variance: "0.7",
80
+ cell_size: 175,
81
+ x_colors: ["#ffffff", "#dcdcdc", "#e6e6e6", "#ffffff", "e8e8e8", "f0f0f0", "#dcdcdc", "#ffffff", "#f5f5f5", "e8e8e8", "#ffffff", "#e6e6e6", "#f5f5f5", "#fafafa", "#ffffff"],
82
+ width: 3000,
83
+ height: 800
84
+ });
85
+ this._internalVars.node.appendChild(pattern.canvas());
86
+ }
87
+
88
+ /**
89
+ * setLocalVars()
90
+ * set local vars to the ones passed in options
91
+ */
92
+ function setLocalVars() {
93
+ if (this._internalVars.contentType === 'string') {
94
+ this._internalVars.node = document.querySelector(this._options.content);
95
+ } else if (this._internalVars.contentType === 'domNode') {
96
+ this._internalVars.node = this._options.content;
97
+ }
98
+ }
99
+ var _default = exports["default"] = BackgroundPattern;