UNPKG

test-isc

Version:

An Ionic component similar to Ionic Select, that allows to search items, including async search, group, add, edit, delete items, and much more.

110 lines (109 loc) 3.63 kB
var __spreadArrays = (this && this.__spreadArrays) || function () { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; }; /** * Patched version of requestAnimationFrame that avoids ngzone * Use only when you know ngzone should not run */ var raf = function (h) { if (typeof __zone_symbol__requestAnimationFrame === 'function') { return __zone_symbol__requestAnimationFrame(h); } if (typeof requestAnimationFrame === 'function') { return requestAnimationFrame(h); } return setTimeout(h); }; var hasShadowDom = function (el) { return !!el.shadowRoot && !!el.attachShadow; }; var findItemLabel = function (componentEl) { var itemEl = componentEl.closest('ion-item'); if (itemEl) { return itemEl.querySelector('ion-label'); } return null; }; var renderHiddenInput = function (always, container, name, value, disabled) { if (always || hasShadowDom(container)) { var input = container.querySelector('input.aux-input'); if (!input) { input = container.ownerDocument.createElement('input'); input.type = 'hidden'; input.classList.add('aux-input'); container.appendChild(input); } input.disabled = disabled; input.name = name; input.value = value || ''; } }; var clamp = function (min, n, max) { return Math.max(min, Math.min(n, max)); }; var assert = function (actual, reason) { if (!actual) { var message = 'ASSERT: ' + reason; console.error(message); debugger; // tslint:disable-line throw new Error(message); } }; var now = function (ev) { return ev.timeStamp || Date.now(); }; var pointerCoord = function (ev) { // get X coordinates for either a mouse click // or a touch depending on the given event if (ev) { var changedTouches = ev.changedTouches; if (changedTouches && changedTouches.length > 0) { var touch = changedTouches[0]; return { x: touch.clientX, y: touch.clientY }; } if (ev.pageX !== undefined) { return { x: ev.pageX, y: ev.pageY }; } } return { x: 0, y: 0 }; }; /** * @hidden * Given a side, return if it should be on the end * based on the value of dir * @param side the side * @param isRTL whether the application dir is rtl */ var isEndSide = function (side) { var isRTL = document.dir === 'rtl'; switch (side) { case 'start': return isRTL; case 'end': return !isRTL; default: throw new Error("\"" + side + "\" is not a valid value for [side]. Use \"start\" or \"end\" instead."); } }; var debounceEvent = function (event, wait) { var original = event._original || event; return { _original: event, emit: debounce(original.emit.bind(original), wait) }; }; var debounce = function (func, wait) { if (wait === void 0) { wait = 0; } var timer; return function () { var args = []; for (var _i = 0; _i < arguments.length; _i++) { args[_i] = arguments[_i]; } clearTimeout(timer); timer = setTimeout.apply(void 0, __spreadArrays([func, wait], args)); }; }; export { renderHiddenInput as a, assert as b, clamp as c, debounceEvent as d, debounce as e, findItemLabel as f, hasShadowDom as h, isEndSide as i, now as n, pointerCoord as p, raf as r };