@tabler/core 1.0.0-beta17 → 1.0.0-beta19

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 (209) hide show
  1. package/README.md +23 -7
  2. package/dist/.DS_Store +0 -0
  3. package/dist/css/demo.css +13 -43
  4. package/dist/css/demo.min.css +3 -3
  5. package/dist/css/demo.rtl.css +13 -43
  6. package/dist/css/demo.rtl.min.css +3 -3
  7. package/dist/css/tabler-flags.css +5 -3
  8. package/dist/css/tabler-flags.min.css +3 -3
  9. package/dist/css/tabler-flags.rtl.css +5 -3
  10. package/dist/css/tabler-flags.rtl.min.css +3 -3
  11. package/dist/css/tabler-payments.css +12 -2
  12. package/dist/css/tabler-payments.min.css +3 -3
  13. package/dist/css/tabler-payments.rtl.css +12 -2
  14. package/dist/css/tabler-payments.rtl.min.css +3 -3
  15. package/dist/css/tabler-social.css +10 -0
  16. package/dist/css/tabler-social.min.css +8 -0
  17. package/dist/css/tabler-social.rtl.css +10 -0
  18. package/dist/css/tabler-social.rtl.min.css +8 -0
  19. package/dist/css/tabler-vendors.css +114 -38
  20. package/dist/css/tabler-vendors.min.css +3 -3
  21. package/dist/css/tabler-vendors.rtl.css +114 -38
  22. package/dist/css/tabler-vendors.rtl.min.css +3 -3
  23. package/dist/css/tabler.css +3831 -2185
  24. package/dist/css/tabler.min.css +7 -3
  25. package/dist/css/tabler.rtl.css +3831 -2186
  26. package/dist/css/tabler.rtl.min.css +7 -3
  27. package/dist/img/payments/epayco-dark.svg +1 -0
  28. package/dist/img/payments/epayco.svg +1 -0
  29. package/dist/js/demo-theme.js +9 -6
  30. package/dist/js/demo-theme.min.js +3 -3
  31. package/dist/js/demo.js +16 -16
  32. package/dist/js/demo.min.js +2 -2
  33. package/dist/js/tabler.esm.js +2115 -2970
  34. package/dist/js/tabler.esm.min.js +6 -6
  35. package/dist/js/tabler.js +2115 -2970
  36. package/dist/js/tabler.min.js +6 -6
  37. package/dist/libs/apexcharts/dist/apexcharts.amd.js +1 -1
  38. package/dist/libs/apexcharts/dist/apexcharts.common.js +5 -5
  39. package/dist/libs/apexcharts/dist/apexcharts.esm.js +5 -5
  40. package/dist/libs/apexcharts/dist/apexcharts.js +3010 -2741
  41. package/dist/libs/apexcharts/dist/apexcharts.min.js +5 -5
  42. package/dist/libs/bootstrap/dist/js/bootstrap.bundle.js +228 -228
  43. package/dist/libs/bootstrap/dist/js/bootstrap.bundle.js.map +1 -1
  44. package/dist/libs/bootstrap/dist/js/bootstrap.bundle.min.js +3 -3
  45. package/dist/libs/bootstrap/dist/js/bootstrap.bundle.min.js.map +1 -1
  46. package/dist/libs/bootstrap/dist/js/bootstrap.esm.js +196 -195
  47. package/dist/libs/bootstrap/dist/js/bootstrap.esm.js.map +1 -1
  48. package/dist/libs/bootstrap/dist/js/bootstrap.esm.min.js +3 -3
  49. package/dist/libs/bootstrap/dist/js/bootstrap.esm.min.js.map +1 -1
  50. package/dist/libs/bootstrap/dist/js/bootstrap.js +197 -196
  51. package/dist/libs/bootstrap/dist/js/bootstrap.js.map +1 -1
  52. package/dist/libs/bootstrap/dist/js/bootstrap.min.js +3 -3
  53. package/dist/libs/bootstrap/dist/js/bootstrap.min.js.map +1 -1
  54. package/dist/libs/countup.js/dist/countUp.d.ts +8 -3
  55. package/dist/libs/countup.js/dist/countUp.js +26 -8
  56. package/dist/libs/countup.js/dist/countUp.min.js +1 -1
  57. package/dist/libs/countup.js/dist/countUp.umd.js +1 -293
  58. package/dist/libs/countup.js/dist/requestAnimationFrame.polyfill.js +26 -0
  59. package/dist/libs/fslightbox/README.md +39 -33
  60. package/dist/libs/fslightbox/index.js +1 -1
  61. package/dist/libs/fslightbox/package.json +10 -44
  62. package/dist/libs/jsvectormap/dist/js/jsvectormap.js +517 -857
  63. package/dist/libs/jsvectormap/dist/js/jsvectormap.min.js +1 -1
  64. package/dist/libs/nouislider/dist/nouislider.d.ts +2 -0
  65. package/dist/libs/nouislider/dist/nouislider.js +28 -0
  66. package/dist/libs/nouislider/dist/nouislider.min.js +1 -1
  67. package/dist/libs/nouislider/dist/nouislider.min.mjs +1 -1
  68. package/dist/libs/nouislider/dist/nouislider.mjs +28 -0
  69. package/dist/libs/plyr/dist/plyr.css +1 -1
  70. package/dist/libs/plyr/dist/plyr.js +289 -229
  71. package/dist/libs/plyr/dist/plyr.min.js +1 -1
  72. package/dist/libs/plyr/dist/plyr.min.js.map +1 -1
  73. package/dist/libs/plyr/dist/plyr.min.mjs +1 -1
  74. package/dist/libs/plyr/dist/plyr.min.mjs.map +1 -1
  75. package/dist/libs/plyr/dist/plyr.mjs +289 -229
  76. package/dist/libs/plyr/dist/plyr.polyfilled.js +289 -229
  77. package/dist/libs/plyr/dist/plyr.polyfilled.min.js +1 -1
  78. package/dist/libs/plyr/dist/plyr.polyfilled.min.js.map +1 -1
  79. package/dist/libs/plyr/dist/plyr.polyfilled.min.mjs +1 -1
  80. package/dist/libs/plyr/dist/plyr.polyfilled.min.mjs.map +1 -1
  81. package/dist/libs/plyr/dist/plyr.polyfilled.mjs +289 -229
  82. package/dist/libs/star-rating.js/dist/star-rating.cjs.js +481 -0
  83. package/dist/libs/star-rating.js/dist/star-rating.css +220 -0
  84. package/dist/libs/star-rating.js/dist/star-rating.esm.js +479 -0
  85. package/dist/libs/star-rating.js/dist/star-rating.esm.min.js +1 -0
  86. package/dist/libs/star-rating.js/dist/star-rating.js +491 -0
  87. package/dist/libs/star-rating.js/dist/star-rating.min.css +8 -0
  88. package/dist/libs/star-rating.js/dist/star-rating.min.js +8 -0
  89. package/dist/libs/tinymce/CHANGELOG.md +112 -0
  90. package/dist/libs/tinymce/composer.json +1 -1
  91. package/dist/libs/tinymce/icons/default/icons.js +4 -0
  92. package/dist/libs/tinymce/icons/default/icons.min.js +1 -1
  93. package/dist/libs/tinymce/models/dom/model.js +79 -23
  94. package/dist/libs/tinymce/models/dom/model.min.js +2 -2
  95. package/dist/libs/tinymce/package.json +1 -1
  96. package/dist/libs/tinymce/plugins/advlist/plugin.js +34 -28
  97. package/dist/libs/tinymce/plugins/advlist/plugin.min.js +2 -2
  98. package/dist/libs/tinymce/plugins/anchor/plugin.js +1 -1
  99. package/dist/libs/tinymce/plugins/anchor/plugin.min.js +1 -1
  100. package/dist/libs/tinymce/plugins/autolink/plugin.js +1 -1
  101. package/dist/libs/tinymce/plugins/autolink/plugin.min.js +1 -1
  102. package/dist/libs/tinymce/plugins/autoresize/plugin.js +46 -11
  103. package/dist/libs/tinymce/plugins/autoresize/plugin.min.js +2 -2
  104. package/dist/libs/tinymce/plugins/autosave/plugin.js +1 -1
  105. package/dist/libs/tinymce/plugins/autosave/plugin.min.js +1 -1
  106. package/dist/libs/tinymce/plugins/charmap/plugin.js +1 -1
  107. package/dist/libs/tinymce/plugins/charmap/plugin.min.js +1 -1
  108. package/dist/libs/tinymce/plugins/code/plugin.js +1 -1
  109. package/dist/libs/tinymce/plugins/code/plugin.min.js +1 -1
  110. package/dist/libs/tinymce/plugins/codesample/plugin.js +1 -1
  111. package/dist/libs/tinymce/plugins/codesample/plugin.min.js +1 -1
  112. package/dist/libs/tinymce/plugins/directionality/plugin.js +1 -1
  113. package/dist/libs/tinymce/plugins/directionality/plugin.min.js +1 -1
  114. package/dist/libs/tinymce/plugins/emoticons/plugin.js +1 -1
  115. package/dist/libs/tinymce/plugins/emoticons/plugin.min.js +1 -1
  116. package/dist/libs/tinymce/plugins/fullscreen/plugin.js +1 -1
  117. package/dist/libs/tinymce/plugins/fullscreen/plugin.min.js +1 -1
  118. package/dist/libs/tinymce/plugins/help/plugin.js +12 -4
  119. package/dist/libs/tinymce/plugins/help/plugin.min.js +2 -2
  120. package/dist/libs/tinymce/plugins/image/plugin.js +1 -1
  121. package/dist/libs/tinymce/plugins/image/plugin.min.js +1 -1
  122. package/dist/libs/tinymce/plugins/importcss/plugin.js +1 -1
  123. package/dist/libs/tinymce/plugins/importcss/plugin.min.js +1 -1
  124. package/dist/libs/tinymce/plugins/insertdatetime/plugin.js +1 -1
  125. package/dist/libs/tinymce/plugins/insertdatetime/plugin.min.js +1 -1
  126. package/dist/libs/tinymce/plugins/link/plugin.js +21 -7
  127. package/dist/libs/tinymce/plugins/link/plugin.min.js +2 -2
  128. package/dist/libs/tinymce/plugins/lists/plugin.js +132 -50
  129. package/dist/libs/tinymce/plugins/lists/plugin.min.js +2 -2
  130. package/dist/libs/tinymce/plugins/media/plugin.js +7 -2
  131. package/dist/libs/tinymce/plugins/media/plugin.min.js +2 -2
  132. package/dist/libs/tinymce/plugins/nonbreaking/plugin.js +1 -1
  133. package/dist/libs/tinymce/plugins/nonbreaking/plugin.min.js +1 -1
  134. package/dist/libs/tinymce/plugins/pagebreak/plugin.js +1 -1
  135. package/dist/libs/tinymce/plugins/pagebreak/plugin.min.js +1 -1
  136. package/dist/libs/tinymce/plugins/preview/plugin.js +1 -1
  137. package/dist/libs/tinymce/plugins/preview/plugin.min.js +1 -1
  138. package/dist/libs/tinymce/plugins/quickbars/plugin.js +21 -13
  139. package/dist/libs/tinymce/plugins/quickbars/plugin.min.js +2 -2
  140. package/dist/libs/tinymce/plugins/save/plugin.js +1 -1
  141. package/dist/libs/tinymce/plugins/save/plugin.min.js +1 -1
  142. package/dist/libs/tinymce/plugins/searchreplace/plugin.js +56 -43
  143. package/dist/libs/tinymce/plugins/searchreplace/plugin.min.js +2 -2
  144. package/dist/libs/tinymce/plugins/table/plugin.js +73 -55
  145. package/dist/libs/tinymce/plugins/table/plugin.min.js +2 -2
  146. package/dist/libs/tinymce/plugins/template/plugin.js +17 -14
  147. package/dist/libs/tinymce/plugins/template/plugin.min.js +2 -2
  148. package/dist/libs/tinymce/plugins/visualblocks/plugin.js +1 -1
  149. package/dist/libs/tinymce/plugins/visualblocks/plugin.min.js +1 -1
  150. package/dist/libs/tinymce/plugins/visualchars/plugin.js +58 -7
  151. package/dist/libs/tinymce/plugins/visualchars/plugin.min.js +2 -2
  152. package/dist/libs/tinymce/plugins/wordcount/plugin.js +1 -1
  153. package/dist/libs/tinymce/plugins/wordcount/plugin.min.js +1 -1
  154. package/dist/libs/tinymce/skins/ui/oxide/skin.css +454 -6
  155. package/dist/libs/tinymce/skins/ui/oxide/skin.min.css +1 -1
  156. package/dist/libs/tinymce/skins/ui/oxide-dark/skin.css +454 -6
  157. package/dist/libs/tinymce/skins/ui/oxide-dark/skin.min.css +1 -1
  158. package/dist/libs/tinymce/skins/ui/tinymce-5/skin.css +455 -6
  159. package/dist/libs/tinymce/skins/ui/tinymce-5/skin.min.css +1 -1
  160. package/dist/libs/tinymce/skins/ui/tinymce-5-dark/skin.css +454 -5
  161. package/dist/libs/tinymce/skins/ui/tinymce-5-dark/skin.min.css +1 -1
  162. package/dist/libs/tinymce/themes/silver/theme.js +4374 -3074
  163. package/dist/libs/tinymce/themes/silver/theme.min.js +2 -2
  164. package/dist/libs/tinymce/tinymce.d.ts +305 -236
  165. package/dist/libs/tinymce/tinymce.js +1957 -1597
  166. package/dist/libs/tinymce/tinymce.min.js +2 -2
  167. package/package.json +63 -42
  168. package/src/js/demo-theme.js +13 -10
  169. package/src/js/demo.js +18 -15
  170. package/src/js/tabler.esm.js +7 -8
  171. package/src/js/tabler.js +12 -12
  172. package/src/scss/_bootstrap-components.scss +33 -33
  173. package/src/scss/_bootstrap-config.scss +6 -6
  174. package/src/scss/_bootstrap-override.scss +8 -12
  175. package/src/scss/_config.scss +2 -1
  176. package/src/scss/_core.scss +1 -1
  177. package/src/scss/_debug.scss +41 -30
  178. package/src/scss/_utilities.scss +21 -19
  179. package/src/scss/_variables-dark.scss +17 -0
  180. package/src/scss/_variables.scss +233 -169
  181. package/src/scss/demo/_examples.scss +0 -16
  182. package/src/scss/demo.scss +36 -25
  183. package/src/scss/layout/_core.scss +0 -1
  184. package/src/scss/layout/_dark.scss +47 -162
  185. package/src/scss/layout/_navbar.scss +19 -99
  186. package/src/scss/layout/_page.scss +9 -6
  187. package/src/scss/layout/_root.scss +21 -7
  188. package/src/scss/mixins/_functions.scss +2 -6
  189. package/src/scss/mixins/_mixins.scss +0 -32
  190. package/src/scss/tabler-social.scss +1 -0
  191. package/src/scss/tabler-vendors.scss +1 -0
  192. package/src/scss/tabler.scss +0 -1
  193. package/src/scss/ui/_avatars.scss +1 -1
  194. package/src/scss/ui/_buttons.scss +1 -1
  195. package/src/scss/ui/_dropdowns.scss +1 -3
  196. package/src/scss/ui/_grid.scss +2 -18
  197. package/src/scss/ui/_payments.scss +1 -1
  198. package/src/scss/ui/_status.scss +0 -10
  199. package/src/scss/ui/_tables.scss +12 -26
  200. package/src/scss/ui/_timeline.scss +3 -3
  201. package/src/scss/utils/_colors.scss +6 -2
  202. package/src/scss/vendor/_apexcharts.scss +16 -0
  203. package/src/scss/vendor/_jsvectormap.scss +1 -1
  204. package/src/scss/vendor/_nouislider.scss +1 -1
  205. package/src/scss/vendor/_stars-rating.scss +20 -0
  206. package/src/scss/vendor/_tinymce.scss +5 -7
  207. package/src/scss/vendor/_tom-select.scss +43 -2
  208. package/dist/libs/countup.js/dist/countUp.withPolyfill.min.js +0 -1
  209. package/dist/libs/fslightbox/jest-setup.js +0 -1
@@ -0,0 +1,481 @@
1
+ 'use strict';
2
+
3
+ function _classCallCheck(instance, Constructor) {
4
+ if (!(instance instanceof Constructor)) {
5
+ throw new TypeError("Cannot call a class as a function");
6
+ }
7
+ }
8
+
9
+ function _defineProperties(target, props) {
10
+ for (var i = 0; i < props.length; i++) {
11
+ var descriptor = props[i];
12
+ descriptor.enumerable = descriptor.enumerable || false;
13
+ descriptor.configurable = true;
14
+ if ("value" in descriptor) descriptor.writable = true;
15
+ Object.defineProperty(target, descriptor.key, descriptor);
16
+ }
17
+ }
18
+
19
+ function _createClass(Constructor, protoProps, staticProps) {
20
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
21
+ if (staticProps) _defineProperties(Constructor, staticProps);
22
+ return Constructor;
23
+ }
24
+
25
+ var defaults = {
26
+ classNames: {
27
+ active: 'gl-active',
28
+ base: 'gl-star-rating',
29
+ selected: 'gl-selected'
30
+ },
31
+ clearable: true,
32
+ maxStars: 10,
33
+ prebuilt: false,
34
+ stars: null,
35
+ tooltip: 'Select a Rating'
36
+ };
37
+
38
+ var addRemoveClass = function addRemoveClass(el, bool, className) {
39
+ el.classList[bool ? 'add' : 'remove'](className);
40
+ };
41
+ var createSpanEl = function createSpanEl(attributes) {
42
+ var el = document.createElement('span');
43
+ attributes = attributes || {};
44
+
45
+ for (var key in attributes) {
46
+ el.setAttribute(key, attributes[key]);
47
+ }
48
+
49
+ return el;
50
+ };
51
+ var inRange = function inRange(value, min, max) {
52
+ return /^\d+$/.test(value) && min <= value && value <= max;
53
+ };
54
+ var insertSpanEl = function insertSpanEl(el, after, attributes) {
55
+ var newEl = createSpanEl(attributes);
56
+ el.parentNode.insertBefore(newEl, after ? el.nextSibling : el);
57
+ return newEl;
58
+ };
59
+ var merge = function merge() {
60
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
61
+ args[_key] = arguments[_key];
62
+ }
63
+
64
+ // adapted from https://github.com/firstandthird/aug
65
+ var results = {};
66
+ args.forEach(function (prop) {
67
+ Object.keys(prop || {}).forEach(function (propName) {
68
+ if (args[0][propName] === undefined) return; // restrict keys to the defaults
69
+
70
+ var propValue = prop[propName];
71
+
72
+ if (type(propValue) === 'Object' && type(results[propName]) === 'Object') {
73
+ results[propName] = merge(results[propName], propValue);
74
+ return;
75
+ }
76
+
77
+ results[propName] = propValue;
78
+ });
79
+ });
80
+ return results;
81
+ };
82
+ var type = function type(value) {
83
+ return {}.toString.call(value).slice(8, -1);
84
+ };
85
+ var values = function values(selectEl) {
86
+ var values = [];
87
+ [].forEach.call(selectEl.options, function (el) {
88
+ var value = parseInt(el.value, 10) || 0;
89
+
90
+ if (value > 0) {
91
+ values.push({
92
+ index: el.index,
93
+ text: el.text,
94
+ value: value
95
+ });
96
+ }
97
+ });
98
+ return values.sort(function (a, b) {
99
+ return a.value - b.value;
100
+ });
101
+ };
102
+
103
+ var Widget = /*#__PURE__*/function () {
104
+ function Widget(el, props) {
105
+ _classCallCheck(this, Widget);
106
+
107
+ // (HTMLElement, object):void
108
+ this.direction = window.getComputedStyle(el, null).getPropertyValue('direction');
109
+ this.el = el;
110
+ this.events = {
111
+ change: this.onChange.bind(this),
112
+ keydown: this.onKeyDown.bind(this),
113
+ mousedown: this.onPointerDown.bind(this),
114
+ mouseleave: this.onPointerLeave.bind(this),
115
+ mousemove: this.onPointerMove.bind(this),
116
+ reset: this.onReset.bind(this),
117
+ touchend: this.onPointerDown.bind(this),
118
+ touchmove: this.onPointerMove.bind(this)
119
+ };
120
+ this.indexActive = null; // the active span index
121
+
122
+ this.indexSelected = null; // the selected span index
123
+
124
+ this.props = props;
125
+ this.tick = null;
126
+ this.ticking = false;
127
+ this.values = values(el);
128
+ this.widgetEl = null;
129
+
130
+ if (this.el.widget) {
131
+ this.el.widget.destroy(); // remove any stale event listeners
132
+ }
133
+
134
+ if (inRange(this.values.length, 1, this.props.maxStars)) {
135
+ this.build();
136
+ } else {
137
+ this.destroy();
138
+ }
139
+ }
140
+
141
+ _createClass(Widget, [{
142
+ key: "build",
143
+ value: function build() {
144
+ // ():void
145
+ this.destroy();
146
+ this.buildWidget();
147
+ this.selectValue(this.indexSelected = this.selected(), false); // set the initial value but do not trigger change event
148
+
149
+ this.handleEvents('add');
150
+ this.el.widget = this; // store a reference to this widget on the SELECT so that we can remove stale event listeners
151
+ }
152
+ }, {
153
+ key: "buildWidget",
154
+ value: function buildWidget() {
155
+ var _this = this;
156
+
157
+ // ():void
158
+ var parentEl, widgetEl;
159
+
160
+ if (this.props.prebuilt) {
161
+ parentEl = this.el.parentNode;
162
+ widgetEl = parentEl.querySelector('.' + this.props.classNames.base + '--stars');
163
+ } else {
164
+ parentEl = insertSpanEl(this.el, false, {
165
+ "class": this.props.classNames.base
166
+ });
167
+ parentEl.appendChild(this.el);
168
+ widgetEl = insertSpanEl(this.el, true, {
169
+ "class": this.props.classNames.base + '--stars'
170
+ });
171
+ this.values.forEach(function (item, index) {
172
+ var el = createSpanEl({
173
+ 'data-index': index,
174
+ 'data-value': item.value
175
+ });
176
+
177
+ if ('function' === typeof _this.props.stars) {
178
+ _this.props.stars.call(_this, el, item, index);
179
+ }
180
+
181
+ [].forEach.call(el.children, function (el) {
182
+ return el.style.pointerEvents = 'none';
183
+ });
184
+ widgetEl.innerHTML += el.outerHTML;
185
+ });
186
+ }
187
+
188
+ parentEl.dataset.starRating = '';
189
+ parentEl.classList.add(this.props.classNames.base + '--' + this.direction);
190
+
191
+ if (this.props.tooltip) {
192
+ widgetEl.setAttribute('role', 'tooltip');
193
+ }
194
+
195
+ this.widgetEl = widgetEl;
196
+ }
197
+ }, {
198
+ key: "changeIndexTo",
199
+ value: function changeIndexTo(index, force) {
200
+ var _this2 = this;
201
+
202
+ // (int):void
203
+ if (this.indexActive !== index || force) {
204
+ [].forEach.call(this.widgetEl.children, function (el, i) {
205
+ // i starts at zero
206
+ addRemoveClass(el, i <= index, _this2.props.classNames.active);
207
+ addRemoveClass(el, i === _this2.indexSelected, _this2.props.classNames.selected);
208
+ });
209
+ this.widgetEl.setAttribute('data-rating', index + 1);
210
+
211
+ if ('function' !== typeof this.props.stars && !this.props.prebuilt) {
212
+ // @v3 compat
213
+ this.widgetEl.classList.remove('s' + 10 * (this.indexActive + 1));
214
+ this.widgetEl.classList.add('s' + 10 * (index + 1));
215
+ }
216
+
217
+ if (this.props.tooltip) {
218
+ var _this$values$index;
219
+
220
+ var label = index < 0 ? this.props.tooltip : (_this$values$index = this.values[index]) === null || _this$values$index === void 0 ? void 0 : _this$values$index.text;
221
+ this.widgetEl.setAttribute('aria-label', label);
222
+ }
223
+
224
+ this.indexActive = index;
225
+ }
226
+
227
+ this.ticking = false;
228
+ }
229
+ }, {
230
+ key: "destroy",
231
+ value: function destroy() {
232
+ // ():void
233
+ this.indexActive = null; // the active span index
234
+
235
+ this.indexSelected = this.selected(); // the selected span index
236
+
237
+ var parentEl = this.el.parentNode;
238
+
239
+ if (parentEl.classList.contains(this.props.classNames.base)) {
240
+ if (this.props.prebuilt) {
241
+ this.widgetEl = parentEl.querySelector('.' + this.props.classNames.base + '--stars');
242
+ parentEl.classList.remove(this.props.classNames.base + '--' + this.direction);
243
+ delete parentEl.dataset.starRating;
244
+ } else {
245
+ parentEl.parentNode.replaceChild(this.el, parentEl);
246
+ }
247
+
248
+ this.handleEvents('remove');
249
+ }
250
+
251
+ delete this.el.widget; // remove the widget reference
252
+ }
253
+ }, {
254
+ key: "eventListener",
255
+ value: function eventListener(el, action, events, items) {
256
+ var _this3 = this;
257
+
258
+ // (HTMLElement, string, array, object):void
259
+ events.forEach(function (ev) {
260
+ return el[action + 'EventListener'](ev, _this3.events[ev], items || false);
261
+ });
262
+ }
263
+ }, {
264
+ key: "handleEvents",
265
+ value: function handleEvents(action) {
266
+ // (string):void
267
+ var formEl = this.el.closest('form');
268
+
269
+ if (formEl && formEl.tagName === 'FORM') {
270
+ this.eventListener(formEl, action, ['reset']);
271
+ }
272
+
273
+ this.eventListener(this.el, action, ['change']); // always trigger the change event, even when SELECT is disabled
274
+
275
+ if ('add' === action && this.el.disabled) return;
276
+ this.eventListener(this.el, action, ['keydown']);
277
+ this.eventListener(this.widgetEl, action, ['mousedown', 'mouseleave', 'mousemove', 'touchend', 'touchmove'], false);
278
+ }
279
+ }, {
280
+ key: "indexFromEvent",
281
+ value: function indexFromEvent(ev) {
282
+ var _ev$touches, _ev$changedTouches;
283
+
284
+ // (MouseEvent|TouchEvent):void
285
+ var origin = ((_ev$touches = ev.touches) === null || _ev$touches === void 0 ? void 0 : _ev$touches[0]) || ((_ev$changedTouches = ev.changedTouches) === null || _ev$changedTouches === void 0 ? void 0 : _ev$changedTouches[0]) || ev;
286
+ var el = document.elementFromPoint(origin.clientX, origin.clientY);
287
+
288
+ if (el.parentNode === this.widgetEl) {
289
+ return [].slice.call(el.parentNode.children).indexOf(el);
290
+ }
291
+
292
+ return this.indexActive;
293
+ }
294
+ }, {
295
+ key: "onChange",
296
+ value: function onChange() {
297
+ // ():void
298
+ this.changeIndexTo(this.selected(), true);
299
+ }
300
+ }, {
301
+ key: "onKeyDown",
302
+ value: function onKeyDown(ev) {
303
+ // (KeyboardEvent):void
304
+ var key = ev.key.slice(5);
305
+ if (!~['Left', 'Right'].indexOf(key)) return;
306
+ ev.preventDefault();
307
+ var increment = key === 'Left' ? -1 : 1;
308
+
309
+ if (this.direction === 'rtl') {
310
+ increment *= -1;
311
+ }
312
+
313
+ var maxIndex = this.values.length - 1;
314
+ var minIndex = -1;
315
+ var index = Math.min(Math.max(this.selected() + increment, minIndex), maxIndex);
316
+ this.selectValue(index, true); // trigger change event
317
+ }
318
+ }, {
319
+ key: "onPointerDown",
320
+ value: function onPointerDown(ev) {
321
+ // (MouseEvent|TouchEvent):void
322
+ ev.preventDefault(); // this.el.focus(); // highlight the rating field
323
+
324
+ var index = this.indexFromEvent(ev);
325
+
326
+ if (this.props.clearable && index === this.indexSelected) {
327
+ index = -1; // remove the value
328
+ }
329
+
330
+ this.selectValue(index, true); // trigger change event
331
+ }
332
+ }, {
333
+ key: "onPointerLeave",
334
+ value: function onPointerLeave(ev) {
335
+ var _this4 = this;
336
+
337
+ // (MouseEvent):void
338
+ ev.preventDefault();
339
+ cancelAnimationFrame(this.tick);
340
+ requestAnimationFrame(function () {
341
+ return _this4.changeIndexTo(_this4.indexSelected);
342
+ });
343
+ }
344
+ }, {
345
+ key: "onPointerMove",
346
+ value: function onPointerMove(ev) {
347
+ var _this5 = this;
348
+
349
+ // (MouseEvent|TouchEvent):void
350
+ ev.preventDefault();
351
+
352
+ if (!this.ticking) {
353
+ this.tick = requestAnimationFrame(function () {
354
+ return _this5.changeIndexTo(_this5.indexFromEvent(ev));
355
+ });
356
+ this.ticking = true;
357
+ }
358
+ }
359
+ }, {
360
+ key: "onReset",
361
+ value: function onReset() {
362
+ var _this$el$querySelecto;
363
+
364
+ // ():void
365
+ var index = this.valueIndex((_this$el$querySelecto = this.el.querySelector('[selected]')) === null || _this$el$querySelecto === void 0 ? void 0 : _this$el$querySelecto.value);
366
+ this.selectValue(index || -1, false); // do not trigger change event
367
+ }
368
+ }, {
369
+ key: "selected",
370
+ value: function selected() {
371
+ // ():int
372
+ return this.valueIndex(this.el.value); // get the selected span index
373
+ }
374
+ }, {
375
+ key: "selectValue",
376
+ value: function selectValue(index, triggerChangeEvent) {
377
+ var _this$values$index2;
378
+
379
+ // (int, bool):void
380
+ this.el.value = ((_this$values$index2 = this.values[index]) === null || _this$values$index2 === void 0 ? void 0 : _this$values$index2.value) || ''; // first set the new value
381
+
382
+ this.indexSelected = this.selected(); // get the actual index from the selected value
383
+
384
+ if (false === triggerChangeEvent) {
385
+ this.changeIndexTo(this.selected(), true);
386
+ } else {
387
+ this.el.dispatchEvent(new Event('change'));
388
+ }
389
+ }
390
+ }, {
391
+ key: "valueIndex",
392
+ value: function valueIndex(value) {
393
+ return this.values.findIndex(function (val) {
394
+ return val.value === +value;
395
+ });
396
+ }
397
+ }]);
398
+
399
+ return Widget;
400
+ }();
401
+
402
+ var StarRating = /*#__PURE__*/function () {
403
+ function StarRating(selector, props) {
404
+ _classCallCheck(this, StarRating);
405
+
406
+ // (HTMLSelectElement|NodeList|string, object):void
407
+ this.destroy = this.destroy.bind(this);
408
+ this.props = props;
409
+ this.rebuild = this.rebuild.bind(this);
410
+ this.selector = selector;
411
+ this.widgets = [];
412
+ this.build();
413
+ }
414
+
415
+ _createClass(StarRating, [{
416
+ key: "build",
417
+ value: function build() {
418
+ var _this = this;
419
+
420
+ // (HTMLSelectElement|NodeList|string, object):void
421
+ this.queryElements(this.selector).forEach(function (el) {
422
+ var options = merge(defaults, _this.props, JSON.parse(el.getAttribute('data-options')));
423
+
424
+ if ('SELECT' === el.tagName && !el.widget) {
425
+ // check for an existing Widget reference
426
+ if (!options.prebuilt && el.parentNode.classList.contains(options.classNames.base)) {
427
+ _this.unwrap(el);
428
+ }
429
+
430
+ _this.widgets.push(new Widget(el, options));
431
+ }
432
+ });
433
+ }
434
+ }, {
435
+ key: "destroy",
436
+ value: function destroy() {
437
+ // ():void
438
+ this.widgets.forEach(function (widget) {
439
+ return widget.destroy();
440
+ });
441
+ this.widgets = [];
442
+ }
443
+ }, {
444
+ key: "queryElements",
445
+ value: function queryElements(selector) {
446
+ // (HTMLSelectElement|NodeList|string):array
447
+ if ('HTMLSelectElement' === type(selector)) {
448
+ return [selector];
449
+ }
450
+
451
+ if ('NodeList' === type(selector)) {
452
+ return [].slice.call(selector);
453
+ }
454
+
455
+ if ('String' === type(selector)) {
456
+ return [].slice.call(document.querySelectorAll(selector));
457
+ }
458
+
459
+ return [];
460
+ }
461
+ }, {
462
+ key: "rebuild",
463
+ value: function rebuild() {
464
+ // ():void
465
+ this.destroy();
466
+ this.build();
467
+ }
468
+ }, {
469
+ key: "unwrap",
470
+ value: function unwrap(el) {
471
+ var removeEl = el.parentNode;
472
+ var parentEl = removeEl.parentNode;
473
+ parentEl.insertBefore(el, removeEl);
474
+ parentEl.removeChild(removeEl);
475
+ }
476
+ }]);
477
+
478
+ return StarRating;
479
+ }();
480
+
481
+ module.exports = StarRating;
@@ -0,0 +1,220 @@
1
+ :root {
2
+ --gl-star-color: #fdd835;
3
+ --gl-star-color-inactive: #dcdce6;
4
+ --gl-star-empty: url('../img/star-empty.svg');
5
+ --gl-star-full: url('../img/star-full.svg');
6
+ --gl-star-size: 24px;
7
+ --gl-tooltip-border-radius: 4px;
8
+ --gl-tooltip-font-size: 0.875rem;
9
+ --gl-tooltip-font-weight: 400;
10
+ --gl-tooltip-line-height: 1;
11
+ --gl-tooltip-margin: 12px;
12
+ --gl-tooltip-padding: .5em 1em;
13
+ --gl-tooltip-size: 6px;
14
+ }
15
+
16
+ [data-star-rating] > select {
17
+ -webkit-clip-path: circle(1px at 0 0) !important;
18
+ clip-path: circle(1px at 0 0) !important;
19
+ clip: rect(1px, 1px, 1px, 1px) !important;
20
+ height: 1px !important;
21
+ margin: 0 !important;
22
+ overflow: hidden !important;
23
+ padding: 0 !important;
24
+ position: absolute !important;
25
+ top: 0 !important;
26
+ visibility: visible !important;
27
+ white-space: nowrap !important;
28
+ width: 1px !important;
29
+ }
30
+
31
+ [data-star-rating] > select {
32
+ -webkit-appearance: none;
33
+ -moz-appearance: none;
34
+ appearance: none;
35
+ pointer-events: none;
36
+ }
37
+
38
+ [data-star-rating] > select::before,
39
+ [data-star-rating] > select::after {
40
+ display: none !important;
41
+ }
42
+
43
+ [data-star-rating].gl-star-rating--ltr > select {
44
+ left: 0 !important;
45
+ }
46
+
47
+ [data-star-rating].gl-star-rating--rtl > select {
48
+ right: 0 !important;
49
+ }
50
+
51
+ [data-star-rating] {
52
+ align-items: center;
53
+ display: flex;
54
+ position: relative;
55
+ }
56
+
57
+ .gl-star-rating:not([data-star-rating]) .gl-star-rating--stars {
58
+ display: none;
59
+ }
60
+
61
+ [data-star-rating] .gl-star-rating--stars {
62
+ align-items: center;
63
+ cursor: pointer;
64
+ display: flex;
65
+ position: relative;
66
+ }
67
+
68
+ [data-star-rating] > select:focus + .gl-star-rating--stars span:first-child::before {
69
+ box-shadow: 0 0 0 3px -moz-mac-focusring;
70
+ box-shadow: 0 0 0 3px -webkit-focus-ring-color;
71
+ box-shadow: 0 0 0 3px Highlight;
72
+ content: '';
73
+ display: block;
74
+ height: 100%;
75
+ outline: 1px solid transparent;
76
+ pointer-events: none;
77
+ position: absolute;
78
+ width: 100%;
79
+ }
80
+
81
+ [data-star-rating] select[disabled] + .gl-star-rating--stars {
82
+ cursor: default;
83
+ }
84
+
85
+ [data-star-rating] .gl-star-rating--stars > span {
86
+ display: flex;
87
+ height: 24px;
88
+ height: 24px;
89
+ height: var(--gl-star-size);
90
+ margin: 0;
91
+ width: 24px;
92
+ width: 24px;
93
+ width: var(--gl-star-size);
94
+ }
95
+
96
+ [data-star-rating] .gl-star-rating--stars[aria-label]::before,
97
+ [data-star-rating] .gl-star-rating--stars[aria-label]::after {
98
+ -webkit-backface-visibility: hidden;
99
+ backface-visibility: hidden;
100
+ bottom: auto;
101
+ box-sizing: border-box;
102
+ left: 100%;
103
+ pointer-events: none;
104
+ position: absolute;
105
+ top: 50%;
106
+ opacity: .9;
107
+ transform-origin: top;
108
+ transform: translate3d(0,-50%,0);
109
+ white-space: nowrap;
110
+ z-index: 10;
111
+ }
112
+
113
+ [data-star-rating] .gl-star-rating--stars[aria-label]::before {
114
+ background-size: 100% auto !important;
115
+ background-position: 50% !important;
116
+ }
117
+
118
+ [data-star-rating] .gl-star-rating--stars[aria-label]::before {
119
+ background: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 31"%3E%3Cpath fill="%23111" d="M12.002 31C12.002 25 0 19.838 0 15.5 0 11.24 12 6 12 0l.002 31z"/%3E%3C/svg%3E') no-repeat;
120
+ content: '';
121
+ height: 18px;
122
+ margin-bottom: 0;
123
+ margin-left: 6px;
124
+ margin-left: 6px;
125
+ margin-left: var(--gl-tooltip-size);
126
+ width: 6px;
127
+ width: 6px;
128
+ width: var(--gl-tooltip-size);
129
+ }
130
+
131
+ [data-star-rating] .gl-star-rating--stars[aria-label]::after {
132
+ background: #111;
133
+ border-radius: 4px;
134
+ border-radius: 4px;
135
+ border-radius: var(--gl-tooltip-border-radius);
136
+ color: #fff;
137
+ content: attr(aria-label);
138
+ font-size: 0.875rem;
139
+ font-size: 0.875rem;
140
+ font-size: var(--gl-tooltip-font-size);
141
+ font-weight: normal;
142
+ margin-left: 12px;
143
+ margin-left: 12px;
144
+ margin-left: var(--gl-tooltip-margin);
145
+ padding: .5em 1em;
146
+ padding: .5em 1em;
147
+ padding: var(--gl-tooltip-padding);
148
+ text-transform: none;
149
+ }
150
+
151
+ [data-star-rating].gl-star-rating--rtl .gl-star-rating--stars[aria-label]::before,
152
+ [data-star-rating].gl-star-rating--rtl .gl-star-rating--stars[aria-label]::after {
153
+ left: auto;
154
+ right: 100%;
155
+ }
156
+
157
+ [data-star-rating].gl-star-rating--rtl .gl-star-rating--stars[aria-label]::before {
158
+ transform: scaleX(-1) translate3d(0,-50%,0);
159
+ margin-left: 0;
160
+ margin-right: 6px;
161
+ margin-right: 6px;
162
+ margin-right: var(--gl-tooltip-size);
163
+ }
164
+
165
+ [data-star-rating].gl-star-rating--rtl .gl-star-rating--stars[aria-label]::after {
166
+ margin-left: 0;
167
+ margin-right: 12px;
168
+ margin-right: 12px;
169
+ margin-right: var(--gl-tooltip-margin);
170
+ }
171
+
172
+ [data-star-rating] svg {
173
+ height: 100%;
174
+ width: 100%;
175
+ }
176
+
177
+ [data-star-rating] .gl-star-half {
178
+ fill: none;
179
+ stroke: none;
180
+ }
181
+
182
+ [data-star-rating] .gl-star-full {
183
+ fill: #dcdce6;
184
+ fill: #dcdce6;
185
+ fill: var(--gl-star-color-inactive);
186
+ stroke: #dcdce6;
187
+ stroke: #dcdce6;
188
+ stroke: var(--gl-star-color-inactive);
189
+ transition: fill 0.15s ease-in-out, stroke 0.15s ease-in-out;
190
+ }
191
+
192
+ [data-star-rating] .gl-active .gl-star-full {
193
+ fill: #fdd835;
194
+ fill: #fdd835;
195
+ fill: var(--gl-star-color);
196
+ stroke: #fdd835;
197
+ stroke: #fdd835;
198
+ stroke: var(--gl-star-color);
199
+ }
200
+
201
+ /* Compatibilty with v3 */
202
+
203
+ .gl-star-rating--stars[class*=" s"] > span {
204
+ background-image: url('../img/star-empty.svg') !important;
205
+ background-image: url('../img/star-empty.svg') !important;
206
+ background-image: var(--gl-star-empty) !important;
207
+ }
208
+
209
+ .gl-star-rating--stars[class*=" s"] > span {
210
+ background-position: center;
211
+ background-repeat: no-repeat;
212
+ background-size: 90%;
213
+ }
214
+
215
+ .gl-star-rating--stars[class*=" s"] > span.gl-active,
216
+ .gl-star-rating--stars[class*=" s"] > span.gl-active.gl-selected {
217
+ background-image: url('../img/star-full.svg') !important;
218
+ background-image: url('../img/star-full.svg') !important;
219
+ background-image: var(--gl-star-full) !important;
220
+ }