lwc
Version:
Lightning Web Components (LWC)
1,767 lines (1,475 loc) • 188 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LWC = {}));
}(this, (function (exports) { 'use strict';
/* proxy-compat-disable */
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function detect$1() {
// Don't apply polyfill when ProxyCompat is enabled.
if ('getKey' in Proxy) {
return false;
}
const proxy = new Proxy([3, 4], {});
const res = [1, 2].concat(proxy);
return res.length !== 4;
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
const {
isConcatSpreadable
} = Symbol;
const {
isArray: isArray$3
} = Array;
const {
slice: ArraySlice$2,
unshift: ArrayUnshift$2,
shift: ArrayShift
} = Array.prototype;
function isObject$2(O) {
return typeof O === 'object' ? O !== null : typeof O === 'function';
} // https://www.ecma-international.org/ecma-262/6.0/#sec-isconcatspreadable
function isSpreadable(O) {
if (!isObject$2(O)) {
return false;
}
const spreadable = O[isConcatSpreadable];
return spreadable !== undefined ? Boolean(spreadable) : isArray$3(O);
} // https://www.ecma-international.org/ecma-262/6.0/#sec-array.prototype.concat
function ArrayConcatPolyfill(..._args) {
const O = Object(this);
const A = [];
let N = 0;
const items = ArraySlice$2.call(arguments);
ArrayUnshift$2.call(items, O);
while (items.length) {
const E = ArrayShift.call(items);
if (isSpreadable(E)) {
let k = 0;
const length = E.length;
for (k; k < length; k += 1, N += 1) {
if (k in E) {
const subElement = E[k];
A[N] = subElement;
}
}
} else {
A[N] = E;
N += 1;
}
}
return A;
}
function apply() {
// eslint-disable-next-line no-extend-native
Array.prototype.concat = ArrayConcatPolyfill;
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
if (detect$1()) {
apply();
}
/**
* Copyright (C) 2018 salesforce.com, inc.
*/
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function invariant$1(value, msg) {
if (!value) {
throw new Error(`Invariant Violation: ${msg}`);
}
}
function isTrue$1$1(value, msg) {
if (!value) {
throw new Error(`Assert Violation: ${msg}`);
}
}
function isFalse$1$1(value, msg) {
if (value) {
throw new Error(`Assert Violation: ${msg}`);
}
}
function fail$1(msg) {
throw new Error(msg);
}
var assert$1 = /*#__PURE__*/Object.freeze({
__proto__: null,
invariant: invariant$1,
isTrue: isTrue$1$1,
isFalse: isFalse$1$1,
fail: fail$1
});
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
const {
assign: assign$2,
create: create$3,
defineProperties: defineProperties$2,
defineProperty: defineProperty$2,
freeze: freeze$2,
getOwnPropertyDescriptor: getOwnPropertyDescriptor$3,
getOwnPropertyNames: getOwnPropertyNames$3,
getPrototypeOf: getPrototypeOf$3,
hasOwnProperty: hasOwnProperty$3,
isFrozen: isFrozen$2,
keys: keys$2,
seal: seal$2,
setPrototypeOf: setPrototypeOf$2
} = Object;
const {
isArray: isArray$2
} = Array;
const {
filter: ArrayFilter$1,
find: ArrayFind$1,
indexOf: ArrayIndexOf$2,
join: ArrayJoin$1,
map: ArrayMap$2,
push: ArrayPush$3,
reduce: ArrayReduce$1,
reverse: ArrayReverse$1,
slice: ArraySlice$1,
splice: ArraySplice$2,
unshift: ArrayUnshift$1,
forEach: forEach$1
} = Array.prototype;
const {
charCodeAt: StringCharCodeAt$1,
replace: StringReplace$1,
slice: StringSlice$1,
toLowerCase: StringToLowerCase$1
} = String.prototype;
function isUndefined$4(obj) {
return obj === undefined;
}
function isNull$1(obj) {
return obj === null;
}
function isFalse$3(obj) {
return obj === false;
}
function isFunction$2(obj) {
return typeof obj === 'function';
}
function isObject$1(obj) {
return typeof obj === 'object';
}
const OtS$2 = {}.toString;
function toString$2(obj) {
if (obj && obj.toString) {
// Arrays might hold objects with "null" prototype So using
// Array.prototype.toString directly will cause an error Iterate through
// all the items and handle individually.
if (isArray$2(obj)) {
return ArrayJoin$1.call(ArrayMap$2.call(obj, toString$2), ',');
}
return obj.toString();
} else if (typeof obj === 'object') {
return OtS$2.call(obj);
} else {
return obj + '';
}
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
/**
* According to the following list, there are 48 aria attributes of which two (ariaDropEffect and
* ariaGrabbed) are deprecated:
* https://www.w3.org/TR/wai-aria-1.1/#x6-6-definitions-of-states-and-properties-all-aria-attributes
*
* The above list of 46 aria attributes is consistent with the following resources:
* https://github.com/w3c/aria/pull/708/files#diff-eacf331f0ffc35d4b482f1d15a887d3bR11060
* https://wicg.github.io/aom/spec/aria-reflection.html
*/
const AriaPropertyNames$1 = ['ariaActiveDescendant', 'ariaAtomic', 'ariaAutoComplete', 'ariaBusy', 'ariaChecked', 'ariaColCount', 'ariaColIndex', 'ariaColSpan', 'ariaControls', 'ariaCurrent', 'ariaDescribedBy', 'ariaDetails', 'ariaDisabled', 'ariaErrorMessage', 'ariaExpanded', 'ariaFlowTo', 'ariaHasPopup', 'ariaHidden', 'ariaInvalid', 'ariaKeyShortcuts', 'ariaLabel', 'ariaLabelledBy', 'ariaLevel', 'ariaLive', 'ariaModal', 'ariaMultiLine', 'ariaMultiSelectable', 'ariaOrientation', 'ariaOwns', 'ariaPlaceholder', 'ariaPosInSet', 'ariaPressed', 'ariaReadOnly', 'ariaRelevant', 'ariaRequired', 'ariaRoleDescription', 'ariaRowCount', 'ariaRowIndex', 'ariaRowSpan', 'ariaSelected', 'ariaSetSize', 'ariaSort', 'ariaValueMax', 'ariaValueMin', 'ariaValueNow', 'ariaValueText', 'role'];
const {
AriaAttrNameToPropNameMap: AriaAttrNameToPropNameMap$1,
AriaPropNameToAttrNameMap: AriaPropNameToAttrNameMap$1
} = /*@__PURE__*/(() => {
const AriaAttrNameToPropNameMap = create$3(null);
const AriaPropNameToAttrNameMap = create$3(null); // Synthetic creation of all AOM property descriptors for Custom Elements
forEach$1.call(AriaPropertyNames$1, propName => {
const attrName = StringToLowerCase$1.call(StringReplace$1.call(propName, /^aria/, () => 'aria-'));
AriaAttrNameToPropNameMap[attrName] = propName;
AriaPropNameToAttrNameMap[propName] = attrName;
});
return {
AriaAttrNameToPropNameMap,
AriaPropNameToAttrNameMap
};
})();
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
// We use this to detect symbol support in order to avoid the expensive symbol polyfill. Note that
// we can't use typeof since it will fail when transpiling.
const hasNativeSymbolSupport$1 = /*@__PURE__*/(() => Symbol('x').toString() === 'Symbol(x)')();
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
// This method abstracts the creation of symbols, so we can fallback to strings when native symbols
// are not supported.
function createHiddenField$1(key, namespace) {
return hasNativeSymbolSupport$1 ? Symbol(key) : `$$lwc-${namespace}-${key}$$`;
}
const hiddenFieldsMap$1 = new WeakMap();
function setHiddenField$1(o, field, value) {
let valuesByField = hiddenFieldsMap$1.get(o);
if (isUndefined$4(valuesByField)) {
valuesByField = create$3(null);
hiddenFieldsMap$1.set(o, valuesByField);
}
valuesByField[field] = value;
}
function getHiddenField$1(o, field) {
const valuesByField = hiddenFieldsMap$1.get(o);
if (!isUndefined$4(valuesByField)) {
return valuesByField[field];
}
}
/** version: 2.1.2 */
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function detect(propName) {
return Object.getOwnPropertyDescriptor(Element.prototype, propName) === undefined;
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
const nodeToAriaPropertyValuesMap = new WeakMap();
function getAriaPropertyMap(elm) {
let map = nodeToAriaPropertyValuesMap.get(elm);
if (map === undefined) {
map = {};
nodeToAriaPropertyValuesMap.set(elm, map);
}
return map;
}
function getNormalizedAriaPropertyValue(value) {
return value == null ? null : String(value);
}
function createAriaPropertyPropertyDescriptor(propName, attrName) {
return {
get() {
const map = getAriaPropertyMap(this);
if (hasOwnProperty$3.call(map, propName)) {
return map[propName];
} // otherwise just reflect what's in the attribute
return this.hasAttribute(attrName) ? this.getAttribute(attrName) : null;
},
set(newValue) {
const normalizedValue = getNormalizedAriaPropertyValue(newValue);
const map = getAriaPropertyMap(this);
map[propName] = normalizedValue; // reflect into the corresponding attribute
if (newValue === null) {
this.removeAttribute(attrName);
} else {
this.setAttribute(attrName, newValue);
}
},
configurable: true,
enumerable: true
};
}
function patch(propName) {
// Typescript is inferring the wrong function type for this particular
// overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
// @ts-ignore type-mismatch
const attrName = AriaPropNameToAttrNameMap$1[propName];
const descriptor = createAriaPropertyPropertyDescriptor(propName, attrName);
Object.defineProperty(Element.prototype, propName, descriptor);
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
const ElementPrototypeAriaPropertyNames = keys$2(AriaPropNameToAttrNameMap$1);
for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1) {
const propName = ElementPrototypeAriaPropertyNames[i];
if (detect(propName)) {
patch(propName);
}
}
/* proxy-compat-disable */
/**
* Copyright (C) 2018 salesforce.com, inc.
*/
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function invariant(value, msg) {
if (!value) {
throw new Error(`Invariant Violation: ${msg}`);
}
}
function isTrue$1(value, msg) {
if (!value) {
throw new Error(`Assert Violation: ${msg}`);
}
}
function isFalse$1(value, msg) {
if (value) {
throw new Error(`Assert Violation: ${msg}`);
}
}
function fail(msg) {
throw new Error(msg);
}
var assert = /*#__PURE__*/Object.freeze({
__proto__: null,
invariant: invariant,
isTrue: isTrue$1,
isFalse: isFalse$1,
fail: fail
});
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
const {
assign: assign$1,
create: create$2,
defineProperties: defineProperties$1,
defineProperty: defineProperty$1,
freeze: freeze$1,
getOwnPropertyDescriptor: getOwnPropertyDescriptor$2,
getOwnPropertyNames: getOwnPropertyNames$2,
getPrototypeOf: getPrototypeOf$2,
hasOwnProperty: hasOwnProperty$2,
isFrozen: isFrozen$1,
keys: keys$1,
seal: seal$1,
setPrototypeOf: setPrototypeOf$1
} = Object;
const {
isArray: isArray$1
} = Array;
const {
filter: ArrayFilter,
find: ArrayFind,
indexOf: ArrayIndexOf$1,
join: ArrayJoin,
map: ArrayMap$1,
push: ArrayPush$2,
reduce: ArrayReduce,
reverse: ArrayReverse,
slice: ArraySlice,
splice: ArraySplice$1,
unshift: ArrayUnshift,
forEach
} = Array.prototype;
const {
fromCharCode: StringFromCharCode
} = String;
const {
charCodeAt: StringCharCodeAt,
replace: StringReplace,
slice: StringSlice,
toLowerCase: StringToLowerCase
} = String.prototype;
function isUndefined$3(obj) {
return obj === undefined;
}
function isNull(obj) {
return obj === null;
}
function isTrue$2(obj) {
return obj === true;
}
function isFalse$2(obj) {
return obj === false;
}
function isFunction$1(obj) {
return typeof obj === 'function';
}
function isString(obj) {
return typeof obj === 'string';
}
const OtS$1 = {}.toString;
function toString$1(obj) {
if (obj && obj.toString) {
// Arrays might hold objects with "null" prototype So using
// Array.prototype.toString directly will cause an error Iterate through
// all the items and handle individually.
if (isArray$1(obj)) {
return ArrayJoin.call(ArrayMap$1.call(obj, toString$1), ',');
}
return obj.toString();
} else if (typeof obj === 'object') {
return OtS$1.call(obj);
} else {
return obj + '';
}
}
function getPropertyDescriptor(o, p) {
do {
const d = getOwnPropertyDescriptor$2(o, p);
if (!isUndefined$3(d)) {
return d;
}
o = getPrototypeOf$2(o);
} while (o !== null);
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
/**
* According to the following list, there are 48 aria attributes of which two (ariaDropEffect and
* ariaGrabbed) are deprecated:
* https://www.w3.org/TR/wai-aria-1.1/#x6-6-definitions-of-states-and-properties-all-aria-attributes
*
* The above list of 46 aria attributes is consistent with the following resources:
* https://github.com/w3c/aria/pull/708/files#diff-eacf331f0ffc35d4b482f1d15a887d3bR11060
* https://wicg.github.io/aom/spec/aria-reflection.html
*/
const AriaPropertyNames = ['ariaActiveDescendant', 'ariaAtomic', 'ariaAutoComplete', 'ariaBusy', 'ariaChecked', 'ariaColCount', 'ariaColIndex', 'ariaColSpan', 'ariaControls', 'ariaCurrent', 'ariaDescribedBy', 'ariaDetails', 'ariaDisabled', 'ariaErrorMessage', 'ariaExpanded', 'ariaFlowTo', 'ariaHasPopup', 'ariaHidden', 'ariaInvalid', 'ariaKeyShortcuts', 'ariaLabel', 'ariaLabelledBy', 'ariaLevel', 'ariaLive', 'ariaModal', 'ariaMultiLine', 'ariaMultiSelectable', 'ariaOrientation', 'ariaOwns', 'ariaPlaceholder', 'ariaPosInSet', 'ariaPressed', 'ariaReadOnly', 'ariaRelevant', 'ariaRequired', 'ariaRoleDescription', 'ariaRowCount', 'ariaRowIndex', 'ariaRowSpan', 'ariaSelected', 'ariaSetSize', 'ariaSort', 'ariaValueMax', 'ariaValueMin', 'ariaValueNow', 'ariaValueText', 'role'];
const {
AriaAttrNameToPropNameMap,
AriaPropNameToAttrNameMap
} = /*@__PURE__*/(() => {
const AriaAttrNameToPropNameMap = create$2(null);
const AriaPropNameToAttrNameMap = create$2(null); // Synthetic creation of all AOM property descriptors for Custom Elements
forEach.call(AriaPropertyNames, propName => {
const attrName = StringToLowerCase.call(StringReplace.call(propName, /^aria/, () => 'aria-'));
AriaAttrNameToPropNameMap[attrName] = propName;
AriaPropNameToAttrNameMap[propName] = attrName;
});
return {
AriaAttrNameToPropNameMap,
AriaPropNameToAttrNameMap
};
})();
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
// We use this to detect symbol support in order to avoid the expensive symbol polyfill. Note that
// we can't use typeof since it will fail when transpiling.
const hasNativeSymbolSupport = /*@__PURE__*/(() => Symbol('x').toString() === 'Symbol(x)')();
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
// This method abstracts the creation of symbols, so we can fallback to strings when native symbols
// are not supported.
function createHiddenField(key, namespace) {
return hasNativeSymbolSupport ? Symbol(key) : `$$lwc-${namespace}-${key}$$`;
}
const hiddenFieldsMap = new WeakMap();
function setHiddenField(o, field, value) {
let valuesByField = hiddenFieldsMap.get(o);
if (isUndefined$3(valuesByField)) {
valuesByField = create$2(null);
hiddenFieldsMap.set(o, valuesByField);
}
valuesByField[field] = value;
}
function getHiddenField(o, field) {
const valuesByField = hiddenFieldsMap.get(o);
if (!isUndefined$3(valuesByField)) {
return valuesByField[field];
}
}
/**
* Map composed of properties to attributes not following the HTML property to attribute mapping
* convention.
*/
const NO_STANDARD_PROPERTY_ATTRIBUTE_MAPPING = new Map([['accessKey', 'accesskey'], ['readOnly', 'readonly'], ['tabIndex', 'tabindex'], ['bgColor', 'bgcolor'], ['colSpan', 'colspan'], ['rowSpan', 'rowspan'], ['contentEditable', 'contenteditable'], ['crossOrigin', 'crossorigin'], ['dateTime', 'datetime'], ['formAction', 'formaction'], ['isMap', 'ismap'], ['maxLength', 'maxlength'], ['minLength', 'minlength'], ['noValidate', 'novalidate'], ['useMap', 'usemap'], ['htmlFor', 'for']]);
/**
* Map associating previously transformed HTML property into HTML attribute.
*/
const CACHED_PROPERTY_ATTRIBUTE_MAPPING = new Map();
function htmlPropertyToAttribute(propName) {
const ariaAttributeName = AriaPropNameToAttrNameMap[propName];
if (!isUndefined$3(ariaAttributeName)) {
return ariaAttributeName;
}
const specialAttributeName = NO_STANDARD_PROPERTY_ATTRIBUTE_MAPPING.get(propName);
if (!isUndefined$3(specialAttributeName)) {
return specialAttributeName;
}
const cachedAttributeName = CACHED_PROPERTY_ATTRIBUTE_MAPPING.get(propName);
if (!isUndefined$3(cachedAttributeName)) {
return cachedAttributeName;
}
let attributeName = '';
for (let i = 0, len = propName.length; i < len; i++) {
const code = StringCharCodeAt.call(propName, i);
if (code >= 65 && // "A"
code <= 90 // "Z"
) {
attributeName += '-' + StringFromCharCode(code + 32);
} else {
attributeName += StringFromCharCode(code);
}
}
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
return attributeName;
}
/** version: 2.1.2 */
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
let nextTickCallbackQueue = [];
const SPACE_CHAR = 32;
const EmptyObject = seal$1(create$2(null));
const EmptyArray = seal$1([]);
function flushCallbackQueue() {
const callbacks = nextTickCallbackQueue;
nextTickCallbackQueue = []; // reset to a new queue
for (let i = 0, len = callbacks.length; i < len; i += 1) {
callbacks[i]();
}
}
function addCallbackToNextTick(callback) {
if (nextTickCallbackQueue.length === 0) {
Promise.resolve().then(flushCallbackQueue);
}
ArrayPush$2.call(nextTickCallbackQueue, callback);
}
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
}
/*
* Copyright (c) 2019, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
const {
create: create$1
} = Object;
const {
splice: ArraySplice,
indexOf: ArrayIndexOf,
push: ArrayPush$1
} = Array.prototype;
const TargetToReactiveRecordMap = new WeakMap();
function isUndefined$2(obj) {
return obj === undefined;
}
function getReactiveRecord(target) {
let reactiveRecord = TargetToReactiveRecordMap.get(target);
if (isUndefined$2(reactiveRecord)) {
const newRecord = create$1(null);
reactiveRecord = newRecord;
TargetToReactiveRecordMap.set(target, newRecord);
}
return reactiveRecord;
}
let currentReactiveObserver = null;
function valueMutated(target, key) {
const reactiveRecord = TargetToReactiveRecordMap.get(target);
if (!isUndefined$2(reactiveRecord)) {
const reactiveObservers = reactiveRecord[key];
if (!isUndefined$2(reactiveObservers)) {
for (let i = 0, len = reactiveObservers.length; i < len; i += 1) {
const ro = reactiveObservers[i];
ro.notify();
}
}
}
}
function valueObserved(target, key) {
// We should determine if an active Observing Record is present to track mutations.
if (currentReactiveObserver === null) {
return;
}
const ro = currentReactiveObserver;
const reactiveRecord = getReactiveRecord(target);
let reactiveObservers = reactiveRecord[key];
if (isUndefined$2(reactiveObservers)) {
reactiveObservers = [];
reactiveRecord[key] = reactiveObservers;
} else if (reactiveObservers[0] === ro) {
return; // perf optimization considering that most subscriptions will come from the same record
}
if (ArrayIndexOf.call(reactiveObservers, ro) === -1) {
ro.link(reactiveObservers);
}
}
class ReactiveObserver {
constructor(callback) {
this.listeners = [];
this.callback = callback;
}
observe(job) {
const inceptionReactiveRecord = currentReactiveObserver;
currentReactiveObserver = this;
let error;
try {
job();
} catch (e) {
error = Object(e);
} finally {
currentReactiveObserver = inceptionReactiveRecord;
if (error !== undefined) {
throw error; // eslint-disable-line no-unsafe-finally
}
}
}
/**
* This method is responsible for disconnecting the Reactive Observer
* from any Reactive Record that has a reference to it, to prevent future
* notifications about previously recorded access.
*/
reset() {
const {
listeners
} = this;
const len = listeners.length;
if (len > 0) {
for (let i = 0; i < len; i += 1) {
const set = listeners[i];
const pos = ArrayIndexOf.call(listeners[i], this);
ArraySplice.call(set, pos, 1);
}
listeners.length = 0;
}
} // friend methods
notify() {
this.callback.call(undefined, this);
}
link(reactiveObservers) {
ArrayPush$1.call(reactiveObservers, this); // we keep track of observing records where the observing record was added to so we can do some clean up later on
ArrayPush$1.call(this.listeners, reactiveObservers);
}
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function componentValueMutated(vm, key) {
valueMutated(vm.component, key);
}
function componentValueObserved(vm, key) {
valueObserved(vm.component, key);
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function getComponentTag(vm) {
return `<${StringToLowerCase.call(vm.tagName)}>`;
} // TODO [#1695]: Unify getComponentStack and getErrorComponentStack
function getErrorComponentStack(vm) {
const wcStack = [];
let currentVm = vm;
while (!isNull(currentVm)) {
ArrayPush$2.call(wcStack, getComponentTag(currentVm));
currentVm = currentVm.owner;
}
return wcStack.reverse().join('\n\t');
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function handleEvent(event, vnode) {
const {
type
} = event;
const {
data: {
on
}
} = vnode;
const handler = on && on[type]; // call event handler if exists
if (handler) {
handler.call(undefined, event);
}
}
function createListener() {
return function handler(event) {
handleEvent(event, handler.vnode);
};
}
function updateAllEventListeners(oldVnode, vnode) {
if (isUndefined$3(oldVnode.listener)) {
createAllEventListeners(vnode);
} else {
vnode.listener = oldVnode.listener;
vnode.listener.vnode = vnode;
}
}
function createAllEventListeners(vnode) {
const {
elm,
data: {
on
},
owner: {
renderer
}
} = vnode;
if (isUndefined$3(on)) {
return;
}
const listener = vnode.listener = createListener();
listener.vnode = vnode;
let name;
for (name in on) {
renderer.addEventListener(elm, name, listener);
}
}
var modEvents = {
update: updateAllEventListeners,
create: createAllEventListeners
};
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
const defaultDefHTMLPropertyNames = ['accessKey', 'dir', 'draggable', 'hidden', 'id', 'lang', 'spellcheck', 'tabIndex', 'title'];
function offsetPropertyErrorMessage(name) {
return `Using the \`${name}\` property is an anti-pattern because it rounds the value to an integer. Instead, use the \`getBoundingClientRect\` method to obtain fractional values for the size of an element and its position relative to the viewport.`;
} // Global HTML Attributes & Properties
// https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
assign$1(create$2(null), {
accessKey: {
attribute: 'accesskey'
},
accessKeyLabel: {
readOnly: true
},
className: {
attribute: 'class',
error: 'Using the `className` property is an anti-pattern because of slow runtime behavior and potential conflicts with classes provided by the owner element. Use the `classList` API instead.'
},
contentEditable: {
attribute: 'contenteditable'
},
dataset: {
readOnly: true,
error: "Using the `dataset` property is an anti-pattern because it can't be statically analyzed. Expose each property individually using the `@api` decorator instead."
},
dir: {
attribute: 'dir'
},
draggable: {
attribute: 'draggable'
},
dropzone: {
attribute: 'dropzone',
readOnly: true
},
hidden: {
attribute: 'hidden'
},
id: {
attribute: 'id'
},
inputMode: {
attribute: 'inputmode'
},
lang: {
attribute: 'lang'
},
slot: {
attribute: 'slot',
error: 'Using the `slot` property is an anti-pattern.'
},
spellcheck: {
attribute: 'spellcheck'
},
style: {
attribute: 'style'
},
tabIndex: {
attribute: 'tabindex'
},
title: {
attribute: 'title'
},
translate: {
attribute: 'translate'
},
// additional "global attributes" that are not present in the link above.
isContentEditable: {
readOnly: true
},
offsetHeight: {
readOnly: true,
error: offsetPropertyErrorMessage('offsetHeight')
},
offsetLeft: {
readOnly: true,
error: offsetPropertyErrorMessage('offsetLeft')
},
offsetParent: {
readOnly: true
},
offsetTop: {
readOnly: true,
error: offsetPropertyErrorMessage('offsetTop')
},
offsetWidth: {
readOnly: true,
error: offsetPropertyErrorMessage('offsetWidth')
},
role: {
attribute: 'role'
}
});
let controlledElement = null;
let controlledAttributeName;
function isAttributeLocked(elm, attrName) {
return elm !== controlledElement || attrName !== controlledAttributeName;
}
function lockAttribute(_elm, _key) {
controlledElement = null;
controlledAttributeName = undefined;
}
function unlockAttribute(elm, key) {
controlledElement = elm;
controlledAttributeName = key;
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
const xlinkNS = 'http://www.w3.org/1999/xlink';
const xmlNS = 'http://www.w3.org/XML/1998/namespace';
const ColonCharCode = 58;
function updateAttrs(oldVnode, vnode) {
const {
data: {
attrs
},
owner: {
renderer
}
} = vnode;
if (isUndefined$3(attrs)) {
return;
}
let {
data: {
attrs: oldAttrs
}
} = oldVnode;
if (oldAttrs === attrs) {
return;
}
const elm = vnode.elm;
const {
setAttribute,
removeAttribute
} = renderer;
let key;
oldAttrs = isUndefined$3(oldAttrs) ? EmptyObject : oldAttrs; // update modified attributes, add new attributes
// this routine is only useful for data-* attributes in all kind of elements
// and aria-* in standard elements (custom elements will use props for these)
for (key in attrs) {
const cur = attrs[key];
const old = oldAttrs[key];
if (old !== cur) {
unlockAttribute(elm, key);
if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
// Assume xml namespace
setAttribute(elm, key, cur, xmlNS);
} else if (StringCharCodeAt.call(key, 5) === ColonCharCode) {
// Assume xlink namespace
setAttribute(elm, key, cur, xlinkNS);
} else if (isNull(cur)) {
removeAttribute(elm, key);
} else {
setAttribute(elm, key, cur);
}
lockAttribute();
}
}
}
const emptyVNode$3 = {
data: {}
};
var modAttrs = {
create: vnode => updateAttrs(emptyVNode$3, vnode),
update: updateAttrs
};
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function isLiveBindingProp(sel, key) {
// For properties with live bindings, we read values from the DOM element
// instead of relying on internally tracked values.
return sel === 'input' && (key === 'value' || key === 'checked');
}
function update(oldVnode, vnode) {
const props = vnode.data.props;
if (isUndefined$3(props)) {
return;
}
const oldProps = oldVnode.data.props;
if (oldProps === props) {
return;
}
const isFirstPatch = isUndefined$3(oldProps);
const {
elm,
sel,
owner: {
renderer
}
} = vnode;
for (const key in props) {
const cur = props[key]; // if it is the first time this element is patched, or the current value is different to the previous value...
if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? renderer.getProperty(elm, key) : oldProps[key])) {
renderer.setProperty(elm, key, cur);
}
}
}
const emptyVNode$2 = {
data: {}
};
var modProps = {
create: vnode => update(emptyVNode$2, vnode),
update
};
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
const classNameToClassMap = create$2(null);
function getMapFromClassName(className) {
// Intentionally using == to match undefined and null values from computed style attribute
if (className == null) {
return EmptyObject;
} // computed class names must be string
className = isString(className) ? className : className + '';
let map = classNameToClassMap[className];
if (map) {
return map;
}
map = create$2(null);
let start = 0;
let o;
const len = className.length;
for (o = 0; o < len; o++) {
if (StringCharCodeAt.call(className, o) === SPACE_CHAR) {
if (o > start) {
map[StringSlice.call(className, start, o)] = true;
}
start = o + 1;
}
}
if (o > start) {
map[StringSlice.call(className, start, o)] = true;
}
classNameToClassMap[className] = map;
return map;
}
function updateClassAttribute(oldVnode, vnode) {
const {
elm,
data: {
className: newClass
},
owner: {
renderer
}
} = vnode;
const {
data: {
className: oldClass
}
} = oldVnode;
if (oldClass === newClass) {
return;
}
const classList = renderer.getClassList(elm);
const newClassMap = getMapFromClassName(newClass);
const oldClassMap = getMapFromClassName(oldClass);
let name;
for (name in oldClassMap) {
// remove only if it is not in the new class collection and it is not set from within the instance
if (isUndefined$3(newClassMap[name])) {
classList.remove(name);
}
}
for (name in newClassMap) {
if (isUndefined$3(oldClassMap[name])) {
classList.add(name);
}
}
}
const emptyVNode$1 = {
data: {}
};
var modComputedClassName = {
create: vnode => updateClassAttribute(emptyVNode$1, vnode),
update: updateClassAttribute
};
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
function updateStyleAttribute(oldVnode, vnode) {
const {
elm,
data: {
style: newStyle
},
owner: {
renderer
}
} = vnode;
const {
setAttribute,
removeAttribute
} = renderer;
if (oldVnode.data.style === newStyle) {
return;
}
if (!isString(newStyle) || newStyle === '') {
removeAttribute(elm, 'style');
} else {
setAttribute(elm, 'style', newStyle);
}
}
const emptyVNode = {
data: {}
};
var modComputedStyle = {
create: vnode => updateStyleAttribute(emptyVNode, vnode),
update: updateStyleAttribute
};
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
// The compiler takes care of transforming the inline classnames into an object. It's faster to set the
// different classnames properties individually instead of via a string.
function createClassAttribute(vnode) {
const {
elm,
data: {
classMap
},
owner: {
renderer
}
} = vnode;
if (isUndefined$3(classMap)) {
return;
}
const classList = renderer.getClassList(elm);
for (const name in classMap) {
classList.add(name);
}
}
var modStaticClassName = {
create: createClassAttribute
};
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
// The compiler takes care of transforming the inline style into an object. It's faster to set the
// different style properties individually instead of via a string.
function createStyleAttribute(vnode) {
const {
elm,
data: {
styleMap
},
owner: {
renderer
}
} = vnode;
if (isUndefined$3(styleMap)) {
return;
}
for (const name in styleMap) {
renderer.setCSSStyleProperty(elm, name, styleMap[name]);
}
}
var modStaticStyle = {
create: createStyleAttribute
};
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
/**
@license
Copyright (c) 2015 Simon Friis Vindum.
This code may only be used under the MIT License found at
https://github.com/snabbdom/snabbdom/blob/master/LICENSE
Code distributed by Snabbdom as part of the Snabbdom project at
https://github.com/snabbdom/snabbdom/
*/
function isUndef(s) {
return s === undefined;
}
function sameVnode(vnode1, vnode2) {
return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
}
function isVNode(vnode) {
return vnode != null;
}
function createKeyToOldIdx(children, beginIdx, endIdx) {
const map = {};
let j, key, ch; // TODO [#1637]: simplify this by assuming that all vnodes has keys
for (j = beginIdx; j <= endIdx; ++j) {
ch = children[j];
if (isVNode(ch)) {
key = ch.key;
if (key !== undefined) {
map[key] = j;
}
}
}
return map;
}
function addVnodes(parentElm, before, vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) {
const ch = vnodes[startIdx];
if (isVNode(ch)) {
ch.hook.create(ch);
ch.hook.insert(ch, parentElm, before);
}
}
}
function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
for (; startIdx <= endIdx; ++startIdx) {
const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
if (isVNode(ch)) {
ch.hook.remove(ch, parentElm);
}
}
}
function updateDynamicChildren(parentElm, oldCh, newCh) {
let oldStartIdx = 0;
let newStartIdx = 0;
let oldEndIdx = oldCh.length - 1;
let oldStartVnode = oldCh[0];
let oldEndVnode = oldCh[oldEndIdx];
const newChEnd = newCh.length - 1;
let newEndIdx = newChEnd;
let newStartVnode = newCh[0];
let newEndVnode = newCh[newEndIdx];
let oldKeyToIdx;
let idxInOld;
let elmToMove;
let before;
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
if (!isVNode(oldStartVnode)) {
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
} else if (!isVNode(oldEndVnode)) {
oldEndVnode = oldCh[--oldEndIdx];
} else if (!isVNode(newStartVnode)) {
newStartVnode = newCh[++newStartIdx];
} else if (!isVNode(newEndVnode)) {
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldStartVnode, newStartVnode)) {
patchVnode(oldStartVnode, newStartVnode);
oldStartVnode = oldCh[++oldStartIdx];
newStartVnode = newCh[++newStartIdx];
} else if (sameVnode(oldEndVnode, newEndVnode)) {
patchVnode(oldEndVnode, newEndVnode);
oldEndVnode = oldCh[--oldEndIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldStartVnode, newEndVnode)) {
// Vnode moved right
patchVnode(oldStartVnode, newEndVnode);
newEndVnode.hook.move(oldStartVnode, parentElm, oldEndVnode.owner.renderer.nextSibling(oldEndVnode.elm));
oldStartVnode = oldCh[++oldStartIdx];
newEndVnode = newCh[--newEndIdx];
} else if (sameVnode(oldEndVnode, newStartVnode)) {
// Vnode moved left
patchVnode(oldEndVnode, newStartVnode);
newStartVnode.hook.move(oldEndVnode, parentElm, oldStartVnode.elm);
oldEndVnode = oldCh[--oldEndIdx];
newStartVnode = newCh[++newStartIdx];
} else {
if (oldKeyToIdx === undefined) {
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
}
idxInOld = oldKeyToIdx[newStartVnode.key];
if (isUndef(idxInOld)) {
// New element
newStartVnode.hook.create(newStartVnode);
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
newStartVnode = newCh[++newStartIdx];
} else {
elmToMove = oldCh[idxInOld];
if (isVNode(elmToMove)) {
if (elmToMove.sel !== newStartVnode.sel) {
// New element
newStartVnode.hook.create(newStartVnode);
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
} else {
patchVnode(elmToMove, newStartVnode);
oldCh[idxInOld] = undefined;
newStartVnode.hook.move(elmToMove, parentElm, oldStartVnode.elm);
}
}
newStartVnode = newCh[++newStartIdx];
}
}
}
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
if (oldStartIdx > oldEndIdx) {
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
let i = newEndIdx;
let n;
do {
n = newCh[++i];
} while (!isVNode(n) && i < newChEnd);
before = isVNode(n) ? n.elm : null;
addVnodes(parentElm, before, newCh, newStartIdx, newEndIdx);
} else {
removeVnodes(parentElm, oldCh, oldStartIdx, oldEndIdx);
}
}
}
function updateStaticChildren(parentElm, oldCh, newCh) {
const oldChLength = oldCh.length;
const newChLength = newCh.length;
if (oldChLength === 0) {
// the old list is empty, we can directly insert anything new
addVnodes(parentElm, null, newCh, 0, newChLength);
return;
}
if (newChLength === 0) {
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
// this is the case in which the dynamic children of an if-directive should be removed
removeVnodes(parentElm, oldCh, 0, oldChLength);
return;
} // if the old list is not empty, the new list MUST have the same
// amount of nodes, that's why we call this static children
let referenceElm = null;
for (let i = newChLength - 1; i >= 0; i -= 1) {
const vnode = newCh[i];
const oldVNode = oldCh[i];
if (vnode !== oldVNode) {
if (isVNode(oldVNode)) {
if (isVNode(vnode)) {
// both vnodes must be equivalent, and se just need to patch them
patchVnode(oldVNode, vnode);
referenceElm = vnode.elm;
} else {
// removing the old vnode since the new one is null
oldVNode.hook.remove(oldVNode, parentElm);
}
} else if (isVNode(vnode)) {
// this condition is unnecessary
vnode.hook.create(vnode); // insert the new node one since the old one is null
vnode.hook.insert(vnode, parentElm, referenceElm);
referenceElm = vnode.elm;
}
}
}
}
function patchVnode(oldVnode, vnode) {
if (oldVnode !== vnode) {
vnode.elm = oldVnode.elm;
vnode.hook.update(oldVnode, vnode);
}
}
/**
* Copyright (C) 2018 salesforce.com, inc.
*/
/**
* Copyright (C) 2018 salesforce.com, inc.
*/
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
const {
assign,
create,
defineProperties,
defineProperty,
freeze,
getOwnPropertyDescriptor: getOwnPropertyDescriptor$1,
getOwnPropertyNames: getOwnPropertyNames$1,
getPrototypeOf: getPrototypeOf$1,
hasOwnProperty: hasOwnProperty$1,
isFrozen,
keys,
seal,
setPrototypeOf
} = Object;
function isUndefined$1(obj) {
return obj === undefined;
}
function isTrue(obj) {
return obj === true;
}
function isFalse(obj) {
return obj === false;
}
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
// Inspired from: https://mathiasbynens.be/notes/globalthis
const _globalThis = /*@__PURE__*/function () {
// On recent browsers, `globalThis` is already defined. In this case return it directly.
if (typeof globalThis === 'object') {
return globalThis;
}
let _globalThis;
try {
// eslint-disable-next-line no-extend-native
Object.defineProperty(Object.prototype, '__magic__', {
get: function () {
return this;
},
configurable: true
}); // __magic__ is undefined in Safari 10 and IE10 and older.
// @ts-ignore
// eslint-disable-next-line no-undef
_globalThis = __magic__; // @ts-ignore
delete Object.prototype.__magic__;
} catch (ex) {// In IE8, Object.defineProperty only works on DOM objects.
} finally {
// If the magic above fails for some reason we assume that we are in a legacy browser.
// Assume `window` exists in this case.
if (typeof _globalThis === 'undefined') {
// @ts-ignore
_globalThis = window;
}
}
return _globalThis;
}();
/** version: 2.1.2 */
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
if (!_globalThis.lwcRuntimeFlags) {
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', {
value: create(null)
});
}
const runtimeFlags = _globalThis.lwcRuntimeFlags; // This function is not supported for use within components and is meant for
// configuring runtime feature flags during app initialization.
function setFeatureFlag(name, value) {
const isBoolean = isTrue(value) || isFalse(value);
if (!isBoolean) {
const message = `Failed to set the value "${value}" for the runtime feature flag "${name}". Runtime feature flags can only be set to a boolean value.`;
{
// eslint-disable-next-line no-console
console.error(message);
return;
}
}
if (isUndefined$1(featureFlagLookup[name])) {
// eslint-disable-next-line no-console
console.warn(`Failed to set the value "${value}" for the runtime feature flag "${name}" because it is undefined. Possible reasons are that 1) it was misspelled or 2) it was removed from the @lwc/features package.`);
return;
}
{
// Disallow the same flag to be set more than once in production
const runtimeValue = runtimeFlags[name];
if (!isUndefined$1(runtimeValue)) {
// eslint-disable-next-line no-console
console.error(`Failed to set the value "${value}" for the runtime feature flag "${name}". "${name}" has already been set with the value "${runtimeValue}".`);
return;
}
Object.defineProperty(runtimeFlags, name, {
value
});
}
} // This function is exposed to components to facilitate testing so we add a
// check to make sure it is not invoked in production.
function setFeatureFlagForTest(name, value) {
}
const featureFlagLookup = {
ENABLE_REACTIVE_SETTER: null,
ENABLE_HMR: null,
// Flag to toggle on/off the enforcement of innerText/outerText shadow dom semantic in elem