@xplortech/apollo-core 0.5.2 → 0.5.3

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 (173) hide show
  1. package/dist/apollo-core/apollo-core.css +5468 -9
  2. package/dist/apollo-core/apollo-core.esm.js +125 -1
  3. package/dist/apollo-core/app-globals-0f993ce5.js +3 -0
  4. package/dist/apollo-core/css-shim-bbdf0cc6.js +4 -0
  5. package/dist/apollo-core/dom-1f98a75f.js +73 -0
  6. package/dist/apollo-core/index-3c9f25ef.js +2938 -0
  7. package/dist/apollo-core/index-912d1a21.js +584 -0
  8. package/dist/apollo-core/index.esm.js +1 -0
  9. package/dist/{cjs/regular-872f5226.js → apollo-core/regular-133c23b5.js} +12 -3
  10. package/dist/apollo-core/shadow-css-67b66845.js +389 -0
  11. package/dist/apollo-core/xpl-application-shell.entry.js +50 -0
  12. package/dist/apollo-core/xpl-avatar.entry.js +19 -0
  13. package/dist/apollo-core/xpl-backdrop.entry.js +21 -0
  14. package/dist/{esm → apollo-core}/xpl-badge.entry.js +1 -1
  15. package/dist/{collection/components/xpl-breadcrumbs/xpl-breadcrumb-item/xpl-breadcrumb-item.js → apollo-core/xpl-breadcrumb-item.entry.js} +9 -12
  16. package/dist/apollo-core/xpl-breadcrumbs.entry.js +14 -0
  17. package/dist/{esm → apollo-core}/xpl-button-row.entry.js +1 -1
  18. package/dist/apollo-core/xpl-button.entry.js +34 -0
  19. package/dist/apollo-core/xpl-checkbox.entry.js +25 -0
  20. package/dist/{esm → apollo-core}/xpl-choicelist.entry.js +1 -1
  21. package/dist/apollo-core/xpl-content-area.entry.js +16 -0
  22. package/dist/{esm → apollo-core}/xpl-divider.entry.js +1 -1
  23. package/dist/{esm → apollo-core}/xpl-grid-item.entry.js +1 -1
  24. package/dist/{esm → apollo-core}/xpl-grid.entry.js +1 -1
  25. package/dist/{esm → apollo-core}/xpl-input.entry.js +20 -3
  26. package/dist/{esm → apollo-core}/xpl-list.entry.js +2 -2
  27. package/dist/apollo-core/xpl-main-nav.entry.js +26 -0
  28. package/dist/apollo-core/xpl-nav-item.entry.js +12 -0
  29. package/dist/{esm → apollo-core}/xpl-pagination.entry.js +1 -1
  30. package/dist/apollo-core/xpl-radio.entry.js +25 -0
  31. package/dist/apollo-core/xpl-secondary-nav.entry.js +12 -0
  32. package/dist/{esm → apollo-core}/xpl-select.entry.js +43 -3
  33. package/dist/{esm → apollo-core}/xpl-table.entry.js +1 -1
  34. package/dist/{esm → apollo-core}/xpl-tag.entry.js +1 -1
  35. package/dist/{esm → apollo-core}/xpl-toggle.entry.js +2 -2
  36. package/dist/apollo-core/xpl-utility-bar.entry.js +25 -0
  37. package/dist/types/components/xpl-choicelist/choice.d.ts +1 -1
  38. package/dist/types/components/xpl-choicelist/xpl-choicelist.d.ts +1 -0
  39. package/dist/types/components/xpl-dropdown/dropdownchoice.d.ts +5 -5
  40. package/dist/types/components/xpl-dropdown/xpl-dropdown.d.ts +1 -0
  41. package/dist/types/components/xpl-list/listitem.d.ts +15 -15
  42. package/dist/types/components/xpl-list/xpl-list.d.ts +1 -0
  43. package/dist/types/components/xpl-select/xpl-select.d.ts +1 -0
  44. package/dist/types/components.d.ts +3 -0
  45. package/package.json +1 -1
  46. package/dist/apollo-core/p-0203d4e8.entry.js +0 -1
  47. package/dist/apollo-core/p-0b2c612e.entry.js +0 -1
  48. package/dist/apollo-core/p-128a0240.entry.js +0 -1
  49. package/dist/apollo-core/p-2f90296c.js +0 -10
  50. package/dist/apollo-core/p-30003b15.entry.js +0 -1
  51. package/dist/apollo-core/p-4e56a2ca.entry.js +0 -1
  52. package/dist/apollo-core/p-5854d1e4.entry.js +0 -1
  53. package/dist/apollo-core/p-611536d8.entry.js +0 -1
  54. package/dist/apollo-core/p-7c9fee7e.entry.js +0 -1
  55. package/dist/apollo-core/p-8b6633c7.js +0 -1
  56. package/dist/apollo-core/p-97cd1f73.entry.js +0 -1
  57. package/dist/apollo-core/p-9c5ca308.entry.js +0 -1
  58. package/dist/apollo-core/p-ad90fe4d.js +0 -1
  59. package/dist/apollo-core/p-bd4a7e3c.entry.js +0 -1
  60. package/dist/apollo-core/p-dab8e7a1.entry.js +0 -1
  61. package/dist/apollo-core/p-eb63b401.entry.js +0 -1
  62. package/dist/apollo-core/p-ee2f4422.entry.js +0 -1
  63. package/dist/apollo-core/p-f167aa05.entry.js +0 -1
  64. package/dist/cjs/apollo-core.cjs.js +0 -19
  65. package/dist/cjs/index-944adb2e.js +0 -1609
  66. package/dist/cjs/index.cjs.js +0 -2
  67. package/dist/cjs/loader.cjs.js +0 -21
  68. package/dist/cjs/v4-14140ff3.js +0 -77
  69. package/dist/cjs/xpl-application-shell_11.cjs.entry.js +0 -230
  70. package/dist/cjs/xpl-badge.cjs.entry.js +0 -21
  71. package/dist/cjs/xpl-button-row.cjs.entry.js +0 -24
  72. package/dist/cjs/xpl-checkbox_2.cjs.entry.js +0 -51
  73. package/dist/cjs/xpl-choicelist.cjs.entry.js +0 -36
  74. package/dist/cjs/xpl-divider.cjs.entry.js +0 -18
  75. package/dist/cjs/xpl-grid-item.cjs.entry.js +0 -25
  76. package/dist/cjs/xpl-grid.cjs.entry.js +0 -35
  77. package/dist/cjs/xpl-input.cjs.entry.js +0 -2527
  78. package/dist/cjs/xpl-list.cjs.entry.js +0 -63
  79. package/dist/cjs/xpl-pagination.cjs.entry.js +0 -76
  80. package/dist/cjs/xpl-select.cjs.entry.js +0 -623
  81. package/dist/cjs/xpl-table.cjs.entry.js +0 -89
  82. package/dist/cjs/xpl-tag.cjs.entry.js +0 -21
  83. package/dist/cjs/xpl-toggle.cjs.entry.js +0 -34
  84. package/dist/collection/collection-manifest.json +0 -37
  85. package/dist/collection/components/xpl-application-shell/xpl-application-shell.js +0 -143
  86. package/dist/collection/components/xpl-avatar/xpl-avatar.js +0 -158
  87. package/dist/collection/components/xpl-backdrop/xpl-backdrop.js +0 -41
  88. package/dist/collection/components/xpl-badge/xpl-badge.js +0 -50
  89. package/dist/collection/components/xpl-breadcrumbs/xpl-breadcrumbs/xpl-breadcrumbs.js +0 -15
  90. package/dist/collection/components/xpl-button/xpl-button.js +0 -214
  91. package/dist/collection/components/xpl-button-row/xpl-button-row.js +0 -119
  92. package/dist/collection/components/xpl-checkbox/xpl-checkbox.js +0 -185
  93. package/dist/collection/components/xpl-choicelist/xpl-choicelist.js +0 -143
  94. package/dist/collection/components/xpl-content-area/xpl-content-area.js +0 -39
  95. package/dist/collection/components/xpl-divider/xpl-divider.js +0 -30
  96. package/dist/collection/components/xpl-dropdown/xpl-dropdown.js +0 -32
  97. package/dist/collection/components/xpl-grid/xpl-grid.js +0 -26
  98. package/dist/collection/components/xpl-grid-item/xpl-grid-item.js +0 -93
  99. package/dist/collection/components/xpl-input/xpl-input.js +0 -471
  100. package/dist/collection/components/xpl-list/xpl-list.js +0 -93
  101. package/dist/collection/components/xpl-main-nav/xpl-main-nav.js +0 -72
  102. package/dist/collection/components/xpl-nav-item/xpl-nav-item.js +0 -10
  103. package/dist/collection/components/xpl-pagination/xpl-pagination.js +0 -189
  104. package/dist/collection/components/xpl-radio/xpl-radio.js +0 -168
  105. package/dist/collection/components/xpl-secondary-nav/xpl-secondary-nav.js +0 -9
  106. package/dist/collection/components/xpl-select/xpl-select.js +0 -311
  107. package/dist/collection/components/xpl-table/xpl-table.js +0 -194
  108. package/dist/collection/components/xpl-tag/xpl-tag.js +0 -30
  109. package/dist/collection/components/xpl-toggle/xpl-toggle.js +0 -157
  110. package/dist/collection/components/xpl-utility-bar/xpl-utility-bar.js +0 -70
  111. package/dist/custom-elements/index.js +0 -19959
  112. package/dist/esm/apollo-core.js +0 -17
  113. package/dist/esm/index-899dba3b.js +0 -1580
  114. package/dist/esm/index.js +0 -1
  115. package/dist/esm/loader.js +0 -17
  116. package/dist/esm/polyfills/core-js.js +0 -11
  117. package/dist/esm/polyfills/css-shim.js +0 -1
  118. package/dist/esm/polyfills/dom.js +0 -79
  119. package/dist/esm/polyfills/es5-html-element.js +0 -1
  120. package/dist/esm/polyfills/index.js +0 -34
  121. package/dist/esm/polyfills/system.js +0 -6
  122. package/dist/esm/regular-86225e9d.js +0 -16041
  123. package/dist/esm/v4-929670b7.js +0 -75
  124. package/dist/esm/xpl-application-shell_11.entry.js +0 -216
  125. package/dist/esm/xpl-checkbox_2.entry.js +0 -46
  126. package/dist/index.cjs.js +0 -1
  127. package/dist/index.js +0 -1
  128. package/dist/stories/application-shell.stories.js +0 -766
  129. package/dist/stories/avatar.stories.js +0 -173
  130. package/dist/stories/backdrop.stories.js +0 -18
  131. package/dist/stories/badge.stories.js +0 -48
  132. package/dist/stories/breadcrumbs.stories.js +0 -115
  133. package/dist/stories/button-row.stories.js +0 -64
  134. package/dist/stories/button.stories.js +0 -98
  135. package/dist/stories/checkbox.stories.js +0 -76
  136. package/dist/stories/choicelist.stories.js +0 -112
  137. package/dist/stories/content-area.stories.js +0 -53
  138. package/dist/stories/divider.stories.js +0 -34
  139. package/dist/stories/grid.stories.js +0 -100
  140. package/dist/stories/input.stories.js +0 -252
  141. package/dist/stories/list.stories.js +0 -134
  142. package/dist/stories/main-nav.stories.js +0 -308
  143. package/dist/stories/pagination.stories.js +0 -84
  144. package/dist/stories/radio.stories.js +0 -66
  145. package/dist/stories/secondary-nav.stories.js +0 -76
  146. package/dist/stories/select.stories.js +0 -111
  147. package/dist/stories/table.stories.js +0 -107
  148. package/dist/stories/tabs.stories.js +0 -24
  149. package/dist/stories/toggle.stories.js +0 -80
  150. package/dist/stories/utility-bar.stories.js +0 -94
  151. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/application-shell.stories.d.ts +0 -0
  152. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/avatar.stories.d.ts +0 -0
  153. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/backdrop.stories.d.ts +0 -0
  154. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/badge.stories.d.ts +0 -0
  155. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/breadcrumbs.stories.d.ts +0 -0
  156. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/button-row.stories.d.ts +0 -0
  157. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/button.stories.d.ts +0 -0
  158. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/checkbox.stories.d.ts +0 -0
  159. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/choicelist.stories.d.ts +0 -0
  160. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/content-area.stories.d.ts +0 -0
  161. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/divider.stories.d.ts +0 -0
  162. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/grid.stories.d.ts +0 -0
  163. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/input.stories.d.ts +0 -0
  164. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/list.stories.d.ts +0 -0
  165. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/main-nav.stories.d.ts +0 -0
  166. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/pagination.stories.d.ts +0 -0
  167. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/radio.stories.d.ts +0 -0
  168. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/secondary-nav.stories.d.ts +0 -0
  169. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/select.stories.d.ts +0 -0
  170. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/table.stories.d.ts +0 -0
  171. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/tabs.stories.d.ts +0 -0
  172. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/toggle.stories.d.ts +0 -0
  173. /package/dist/types/Users/{fernandogelin/Projects → roc/Sites}/apollo/.stencil/stories/utility-bar.stories.d.ts +0 -0
@@ -1,623 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const index = require('./index-944adb2e.js');
6
- const v4 = require('./v4-14140ff3.js');
7
-
8
- /// <reference path="./dropdownchoice.d.ts"></reference>
9
- const XplDropdown = ({ active, choices, mode, selected, update, }) => {
10
- return (index.h("div", { class: {
11
- "xpl-dropdown": true,
12
- "xpl-dropdown--multi": mode === "multi",
13
- "active": active,
14
- } },
15
- index.h("ul", null, choices.map(({ label, isGroupHeading }, i) => {
16
- return isGroupHeading ?
17
- index.h("span", null, label) :
18
- index.h("li", null,
19
- index.h("button", { class: {
20
- selected: selected[i]
21
- }, onClick: () => {
22
- let newSelected;
23
- if (mode === "single") {
24
- // @ts-expect-error
25
- newSelected = selected.map((v, j) => {
26
- return i === j ? !selected[i] : false;
27
- });
28
- active = false;
29
- }
30
- else if (mode === "multi") {
31
- newSelected = selected.map((v, j) => {
32
- return i === j ? !selected[i] : v;
33
- });
34
- }
35
- update(newSelected);
36
- }, tabIndex: active ? 0 : -1 }, label));
37
- }))));
38
- };
39
-
40
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
41
-
42
- /**
43
- * lodash (Custom Build) <https://lodash.com/>
44
- * Build: `lodash modularize exports="npm" -o ./`
45
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
46
- * Released under MIT license <https://lodash.com/license>
47
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
48
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
49
- */
50
-
51
- /** Used as the `TypeError` message for "Functions" methods. */
52
- var FUNC_ERROR_TEXT = 'Expected a function';
53
-
54
- /** Used as references for various `Number` constants. */
55
- var NAN = 0 / 0;
56
-
57
- /** `Object#toString` result references. */
58
- var symbolTag = '[object Symbol]';
59
-
60
- /** Used to match leading and trailing whitespace. */
61
- var reTrim = /^\s+|\s+$/g;
62
-
63
- /** Used to detect bad signed hexadecimal string values. */
64
- var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
65
-
66
- /** Used to detect binary string values. */
67
- var reIsBinary = /^0b[01]+$/i;
68
-
69
- /** Used to detect octal string values. */
70
- var reIsOctal = /^0o[0-7]+$/i;
71
-
72
- /** Built-in method references without a dependency on `root`. */
73
- var freeParseInt = parseInt;
74
-
75
- /** Detect free variable `global` from Node.js. */
76
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
77
-
78
- /** Detect free variable `self`. */
79
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
80
-
81
- /** Used as a reference to the global object. */
82
- var root = freeGlobal || freeSelf || Function('return this')();
83
-
84
- /** Used for built-in method references. */
85
- var objectProto = Object.prototype;
86
-
87
- /**
88
- * Used to resolve the
89
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
90
- * of values.
91
- */
92
- var objectToString = objectProto.toString;
93
-
94
- /* Built-in method references for those with the same name as other `lodash` methods. */
95
- var nativeMax = Math.max,
96
- nativeMin = Math.min;
97
-
98
- /**
99
- * Gets the timestamp of the number of milliseconds that have elapsed since
100
- * the Unix epoch (1 January 1970 00:00:00 UTC).
101
- *
102
- * @static
103
- * @memberOf _
104
- * @since 2.4.0
105
- * @category Date
106
- * @returns {number} Returns the timestamp.
107
- * @example
108
- *
109
- * _.defer(function(stamp) {
110
- * console.log(_.now() - stamp);
111
- * }, _.now());
112
- * // => Logs the number of milliseconds it took for the deferred invocation.
113
- */
114
- var now = function() {
115
- return root.Date.now();
116
- };
117
-
118
- /**
119
- * Creates a debounced function that delays invoking `func` until after `wait`
120
- * milliseconds have elapsed since the last time the debounced function was
121
- * invoked. The debounced function comes with a `cancel` method to cancel
122
- * delayed `func` invocations and a `flush` method to immediately invoke them.
123
- * Provide `options` to indicate whether `func` should be invoked on the
124
- * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
125
- * with the last arguments provided to the debounced function. Subsequent
126
- * calls to the debounced function return the result of the last `func`
127
- * invocation.
128
- *
129
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
130
- * invoked on the trailing edge of the timeout only if the debounced function
131
- * is invoked more than once during the `wait` timeout.
132
- *
133
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
134
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
135
- *
136
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
137
- * for details over the differences between `_.debounce` and `_.throttle`.
138
- *
139
- * @static
140
- * @memberOf _
141
- * @since 0.1.0
142
- * @category Function
143
- * @param {Function} func The function to debounce.
144
- * @param {number} [wait=0] The number of milliseconds to delay.
145
- * @param {Object} [options={}] The options object.
146
- * @param {boolean} [options.leading=false]
147
- * Specify invoking on the leading edge of the timeout.
148
- * @param {number} [options.maxWait]
149
- * The maximum time `func` is allowed to be delayed before it's invoked.
150
- * @param {boolean} [options.trailing=true]
151
- * Specify invoking on the trailing edge of the timeout.
152
- * @returns {Function} Returns the new debounced function.
153
- * @example
154
- *
155
- * // Avoid costly calculations while the window size is in flux.
156
- * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
157
- *
158
- * // Invoke `sendMail` when clicked, debouncing subsequent calls.
159
- * jQuery(element).on('click', _.debounce(sendMail, 300, {
160
- * 'leading': true,
161
- * 'trailing': false
162
- * }));
163
- *
164
- * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
165
- * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
166
- * var source = new EventSource('/stream');
167
- * jQuery(source).on('message', debounced);
168
- *
169
- * // Cancel the trailing debounced invocation.
170
- * jQuery(window).on('popstate', debounced.cancel);
171
- */
172
- function debounce(func, wait, options) {
173
- var lastArgs,
174
- lastThis,
175
- maxWait,
176
- result,
177
- timerId,
178
- lastCallTime,
179
- lastInvokeTime = 0,
180
- leading = false,
181
- maxing = false,
182
- trailing = true;
183
-
184
- if (typeof func != 'function') {
185
- throw new TypeError(FUNC_ERROR_TEXT);
186
- }
187
- wait = toNumber(wait) || 0;
188
- if (isObject(options)) {
189
- leading = !!options.leading;
190
- maxing = 'maxWait' in options;
191
- maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
192
- trailing = 'trailing' in options ? !!options.trailing : trailing;
193
- }
194
-
195
- function invokeFunc(time) {
196
- var args = lastArgs,
197
- thisArg = lastThis;
198
-
199
- lastArgs = lastThis = undefined;
200
- lastInvokeTime = time;
201
- result = func.apply(thisArg, args);
202
- return result;
203
- }
204
-
205
- function leadingEdge(time) {
206
- // Reset any `maxWait` timer.
207
- lastInvokeTime = time;
208
- // Start the timer for the trailing edge.
209
- timerId = setTimeout(timerExpired, wait);
210
- // Invoke the leading edge.
211
- return leading ? invokeFunc(time) : result;
212
- }
213
-
214
- function remainingWait(time) {
215
- var timeSinceLastCall = time - lastCallTime,
216
- timeSinceLastInvoke = time - lastInvokeTime,
217
- result = wait - timeSinceLastCall;
218
-
219
- return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
220
- }
221
-
222
- function shouldInvoke(time) {
223
- var timeSinceLastCall = time - lastCallTime,
224
- timeSinceLastInvoke = time - lastInvokeTime;
225
-
226
- // Either this is the first call, activity has stopped and we're at the
227
- // trailing edge, the system time has gone backwards and we're treating
228
- // it as the trailing edge, or we've hit the `maxWait` limit.
229
- return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
230
- (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
231
- }
232
-
233
- function timerExpired() {
234
- var time = now();
235
- if (shouldInvoke(time)) {
236
- return trailingEdge(time);
237
- }
238
- // Restart the timer.
239
- timerId = setTimeout(timerExpired, remainingWait(time));
240
- }
241
-
242
- function trailingEdge(time) {
243
- timerId = undefined;
244
-
245
- // Only invoke if we have `lastArgs` which means `func` has been
246
- // debounced at least once.
247
- if (trailing && lastArgs) {
248
- return invokeFunc(time);
249
- }
250
- lastArgs = lastThis = undefined;
251
- return result;
252
- }
253
-
254
- function cancel() {
255
- if (timerId !== undefined) {
256
- clearTimeout(timerId);
257
- }
258
- lastInvokeTime = 0;
259
- lastArgs = lastCallTime = lastThis = timerId = undefined;
260
- }
261
-
262
- function flush() {
263
- return timerId === undefined ? result : trailingEdge(now());
264
- }
265
-
266
- function debounced() {
267
- var time = now(),
268
- isInvoking = shouldInvoke(time);
269
-
270
- lastArgs = arguments;
271
- lastThis = this;
272
- lastCallTime = time;
273
-
274
- if (isInvoking) {
275
- if (timerId === undefined) {
276
- return leadingEdge(lastCallTime);
277
- }
278
- if (maxing) {
279
- // Handle invocations in a tight loop.
280
- timerId = setTimeout(timerExpired, wait);
281
- return invokeFunc(lastCallTime);
282
- }
283
- }
284
- if (timerId === undefined) {
285
- timerId = setTimeout(timerExpired, wait);
286
- }
287
- return result;
288
- }
289
- debounced.cancel = cancel;
290
- debounced.flush = flush;
291
- return debounced;
292
- }
293
-
294
- /**
295
- * Creates a throttled function that only invokes `func` at most once per
296
- * every `wait` milliseconds. The throttled function comes with a `cancel`
297
- * method to cancel delayed `func` invocations and a `flush` method to
298
- * immediately invoke them. Provide `options` to indicate whether `func`
299
- * should be invoked on the leading and/or trailing edge of the `wait`
300
- * timeout. The `func` is invoked with the last arguments provided to the
301
- * throttled function. Subsequent calls to the throttled function return the
302
- * result of the last `func` invocation.
303
- *
304
- * **Note:** If `leading` and `trailing` options are `true`, `func` is
305
- * invoked on the trailing edge of the timeout only if the throttled function
306
- * is invoked more than once during the `wait` timeout.
307
- *
308
- * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
309
- * until to the next tick, similar to `setTimeout` with a timeout of `0`.
310
- *
311
- * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
312
- * for details over the differences between `_.throttle` and `_.debounce`.
313
- *
314
- * @static
315
- * @memberOf _
316
- * @since 0.1.0
317
- * @category Function
318
- * @param {Function} func The function to throttle.
319
- * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
320
- * @param {Object} [options={}] The options object.
321
- * @param {boolean} [options.leading=true]
322
- * Specify invoking on the leading edge of the timeout.
323
- * @param {boolean} [options.trailing=true]
324
- * Specify invoking on the trailing edge of the timeout.
325
- * @returns {Function} Returns the new throttled function.
326
- * @example
327
- *
328
- * // Avoid excessively updating the position while scrolling.
329
- * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
330
- *
331
- * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
332
- * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
333
- * jQuery(element).on('click', throttled);
334
- *
335
- * // Cancel the trailing throttled invocation.
336
- * jQuery(window).on('popstate', throttled.cancel);
337
- */
338
- function throttle(func, wait, options) {
339
- var leading = true,
340
- trailing = true;
341
-
342
- if (typeof func != 'function') {
343
- throw new TypeError(FUNC_ERROR_TEXT);
344
- }
345
- if (isObject(options)) {
346
- leading = 'leading' in options ? !!options.leading : leading;
347
- trailing = 'trailing' in options ? !!options.trailing : trailing;
348
- }
349
- return debounce(func, wait, {
350
- 'leading': leading,
351
- 'maxWait': wait,
352
- 'trailing': trailing
353
- });
354
- }
355
-
356
- /**
357
- * Checks if `value` is the
358
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
359
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
360
- *
361
- * @static
362
- * @memberOf _
363
- * @since 0.1.0
364
- * @category Lang
365
- * @param {*} value The value to check.
366
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
367
- * @example
368
- *
369
- * _.isObject({});
370
- * // => true
371
- *
372
- * _.isObject([1, 2, 3]);
373
- * // => true
374
- *
375
- * _.isObject(_.noop);
376
- * // => true
377
- *
378
- * _.isObject(null);
379
- * // => false
380
- */
381
- function isObject(value) {
382
- var type = typeof value;
383
- return !!value && (type == 'object' || type == 'function');
384
- }
385
-
386
- /**
387
- * Checks if `value` is object-like. A value is object-like if it's not `null`
388
- * and has a `typeof` result of "object".
389
- *
390
- * @static
391
- * @memberOf _
392
- * @since 4.0.0
393
- * @category Lang
394
- * @param {*} value The value to check.
395
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
396
- * @example
397
- *
398
- * _.isObjectLike({});
399
- * // => true
400
- *
401
- * _.isObjectLike([1, 2, 3]);
402
- * // => true
403
- *
404
- * _.isObjectLike(_.noop);
405
- * // => false
406
- *
407
- * _.isObjectLike(null);
408
- * // => false
409
- */
410
- function isObjectLike(value) {
411
- return !!value && typeof value == 'object';
412
- }
413
-
414
- /**
415
- * Checks if `value` is classified as a `Symbol` primitive or object.
416
- *
417
- * @static
418
- * @memberOf _
419
- * @since 4.0.0
420
- * @category Lang
421
- * @param {*} value The value to check.
422
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
423
- * @example
424
- *
425
- * _.isSymbol(Symbol.iterator);
426
- * // => true
427
- *
428
- * _.isSymbol('abc');
429
- * // => false
430
- */
431
- function isSymbol(value) {
432
- return typeof value == 'symbol' ||
433
- (isObjectLike(value) && objectToString.call(value) == symbolTag);
434
- }
435
-
436
- /**
437
- * Converts `value` to a number.
438
- *
439
- * @static
440
- * @memberOf _
441
- * @since 4.0.0
442
- * @category Lang
443
- * @param {*} value The value to process.
444
- * @returns {number} Returns the number.
445
- * @example
446
- *
447
- * _.toNumber(3.2);
448
- * // => 3.2
449
- *
450
- * _.toNumber(Number.MIN_VALUE);
451
- * // => 5e-324
452
- *
453
- * _.toNumber(Infinity);
454
- * // => Infinity
455
- *
456
- * _.toNumber('3.2');
457
- * // => 3.2
458
- */
459
- function toNumber(value) {
460
- if (typeof value == 'number') {
461
- return value;
462
- }
463
- if (isSymbol(value)) {
464
- return NAN;
465
- }
466
- if (isObject(value)) {
467
- var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
468
- value = isObject(other) ? (other + '') : other;
469
- }
470
- if (typeof value != 'string') {
471
- return value === 0 ? value : +value;
472
- }
473
- value = value.replace(reTrim, '');
474
- var isBinary = reIsBinary.test(value);
475
- return (isBinary || reIsOctal.test(value))
476
- ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
477
- : (reIsBadHex.test(value) ? NAN : +value);
478
- }
479
-
480
- var lodash_throttle = throttle;
481
-
482
- function tagWidth(text) {
483
- const context = document.createElement("canvas").getContext("2d");
484
- context.font = "14px apple-system, system-ui, 'Segoe UI', Arial, Helvetica, Roboto, sans-serif";
485
- return context.measureText(text).width + 44; // = text + l/r padding + margin-right
486
- }
487
- const XplSelect = class {
488
- constructor(hostRef) {
489
- index.registerInstance(this, hostRef);
490
- /**
491
- * An array of choices for the user to choose from.
492
- * Each choice should be of the form:
493
- * {
494
- * label: string;
495
- * href?: string;
496
- * value?: string;
497
- * isGroupHeading?: boolean;
498
- * }
499
- */
500
- this.choices = [];
501
- /**
502
- * Whether to allow a single choice or multiple choices.
503
- */
504
- this.mode = "single";
505
- /**
506
- * Only used in multi-choice selects. If `true`,
507
- * badges representing selections that would overflow the
508
- * container are replaced with "+x more" (where x is the
509
- * number not shown). If `false`, the container's height will
510
- * adjust to show all badges representing selections.
511
- */
512
- this.truncate = true;
513
- this.active = false;
514
- this.id = v4.v4();
515
- this.keepFocus = false;
516
- this.value = "";
517
- // infinity isn't real, it's just a mathematical construct, it can't hurt you
518
- this.visibleChoices = Infinity;
519
- }
520
- componentWillLoad() {
521
- this.selected = this.choices && this.choices.length > 0 ? this.choices.map(() => false) : [];
522
- window.addEventListener("click", (e) => {
523
- const el = e.target;
524
- const select = el.closest(".xpl-select");
525
- if (select === null || select !== this.container) {
526
- this.active = false;
527
- }
528
- });
529
- window.addEventListener("resize", lodash_throttle(() => {
530
- this.maybeTruncateChoices();
531
- }, 250));
532
- }
533
- maybeTruncateChoices() {
534
- if (this.mode === "single" || !this.truncate)
535
- return;
536
- const containerWidth = this.container.getBoundingClientRect().width;
537
- let visibleChoices = 0;
538
- let visibleChoicesWidth = 0;
539
- const actualNumSelected = this.selected.filter(a => a).length;
540
- for (let i = 0; i < actualNumSelected; i++) {
541
- visibleChoicesWidth += tagWidth(this.getDisplayValue(i));
542
- if (visibleChoicesWidth > containerWidth - 140)
543
- break;
544
- visibleChoices++;
545
- }
546
- if (visibleChoices >= actualNumSelected)
547
- visibleChoices = Infinity;
548
- if (visibleChoices < 1)
549
- visibleChoices = 1;
550
- this.visibleChoices = visibleChoices;
551
- }
552
- getDisplayValue(i) {
553
- return this.choices[i].label;
554
- }
555
- getActualValue(i) {
556
- return this.choices[i].value || this.choices[i].label;
557
- }
558
- update(selected) {
559
- this.selected = selected;
560
- if (this.mode === "single") {
561
- const selected = this.selected.findIndex(v => v);
562
- this.value = selected >= 0 ?
563
- this.getActualValue(selected) :
564
- "";
565
- }
566
- else if (this.mode === "multi") {
567
- this.value = this.selected.map((v, i) => {
568
- return v ? this.getActualValue(i) : "";
569
- }).filter(v => v.length > 0).join("|");
570
- }
571
- }
572
- render() {
573
- let visibleChoices = 0;
574
- return (index.h(index.Host, { class: {
575
- "xpl-select": true,
576
- "xpl-select--disabled": this.disabled,
577
- "xpl-select--no-truncate": !this.truncate,
578
- }, onKeyDown: (e) => {
579
- if (e.key === "Escape")
580
- this.active = false;
581
- }, ref: (el) => (this.container = el) }, this.label || this.description ? (index.h("label", { class: {
582
- "xpl-label": true,
583
- "xpl-label--disabled": this.disabled,
584
- }, htmlFor: this.id }, this.label, this.description && index.h("small", { class: {
585
- "xpl-description": true,
586
- "xpl-description--disabled": this.disabled,
587
- } }, this.description))) : null, index.h("div", { class: {
588
- "xpl-input": true,
589
- "xpl-input--disabled": this.disabled,
590
- "xpl-input--error": this.error !== undefined
591
- } }, index.h("div", { class: "xpl-input-wrapper" }, index.h("div", { class: {
592
- "xpl-select-value": true,
593
- "xpl-select-value--active": this.mode === "multi" && this.value.length > 0,
594
- "has-value": this.value.length > 0,
595
- } }, this.mode === "single" ?
596
- (this.value || this.placeholder) :
597
- (this.value.length > 0 ?
598
- this.selected.map((v, i) => {
599
- if (!v)
600
- return null;
601
- if (visibleChoices >= this.visibleChoices)
602
- return null;
603
- visibleChoices++;
604
- return (index.h("xpl-tag", { onClose: () => {
605
- this.selected = this.selected.map((v, j) => i === j ? false : v);
606
- this.update(this.selected);
607
- this.maybeTruncateChoices();
608
- } }, this.getDisplayValue(i)));
609
- }) :
610
- this.placeholder), this.visibleChoices < Infinity && `+ ${this.selected.filter(a => a).length - this.visibleChoices} more`), index.h("button", { disabled: this.disabled, id: this.id, onKeyDown: (e) => {
611
- if (e.key === "Tab")
612
- this.keepFocus = true;
613
- }, onClick: () => {
614
- if (!this.disabled)
615
- this.active = !this.active;
616
- } })), !this.disabled && (index.h(XplDropdown, { active: this.active, choices: this.choices, mode: this.mode, selected: this.selected, update: (selected) => {
617
- this.update(selected);
618
- this.maybeTruncateChoices();
619
- } })), this.error !== undefined && this.error.length > 0 && index.h("label", { class: "xpl-input-error", htmlFor: this.id }, index.h("svg", { width: "10", height: "11", viewBox: "0 0 10 11", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, index.h("path", { d: "M9.84375 5.25C9.84375 2.59375 7.65625 0.40625 5 0.40625C2.32422 0.40625 0.15625 2.59375 0.15625 5.25C0.15625 7.92578 2.32422 10.0938 5 10.0938C7.65625 10.0938 9.84375 7.92578 9.84375 5.25ZM5 6.22656C5.48828 6.22656 5.89844 6.63672 5.89844 7.125C5.89844 7.63281 5.48828 8.02344 5 8.02344C4.49219 8.02344 4.10156 7.63281 4.10156 7.125C4.10156 6.63672 4.49219 6.22656 5 6.22656ZM4.14062 3.00391C4.12109 2.86719 4.23828 2.75 4.375 2.75H5.60547C5.74219 2.75 5.85938 2.86719 5.83984 3.00391L5.70312 5.66016C5.68359 5.79688 5.58594 5.875 5.46875 5.875H4.51172C4.39453 5.875 4.29688 5.79688 4.27734 5.66016L4.14062 3.00391Z" })), this.error)), index.h("input", { type: "hidden", value: this.value })));
620
- }
621
- };
622
-
623
- exports.xpl_select = XplSelect;