@benbraide/inlinejs-stripe 1.0.4 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -207,16 +207,18 @@ class BaseComponent {
207
207
  }
208
208
  let scope = new _scope__WEBPACK_IMPORTED_MODULE_12__.Scope(this.id_, this.GenerateUniqueId('scope_'), root);
209
209
  this.scopes_[scope.GetId()] = scope;
210
+ this.AddProxy(scope.GetProxy());
210
211
  return scope;
211
212
  }
212
213
  RemoveScope(scope) {
213
214
  let id = ((typeof scope === 'string') ? scope : scope.GetId());
214
- if (id in this.scopes_) {
215
+ if (this.scopes_.hasOwnProperty(id)) {
216
+ this.RemoveProxy(this.scopes_[id].GetProxy());
215
217
  delete this.scopes_[id];
216
218
  }
217
219
  }
218
220
  FindScopeById(id) {
219
- return ((id in this.scopes_) ? this.scopes_[id] : null);
221
+ return (this.scopes_.hasOwnProperty(id) ? this.scopes_[id] : null);
220
222
  }
221
223
  FindScopeByName(name) {
222
224
  return (Object.values(this.scopes_).find(scope => (scope.GetName() === name)) || null);
@@ -315,7 +317,7 @@ class BaseComponent {
315
317
  }
316
318
  RemoveProxy(proxy) {
317
319
  let path = ((typeof proxy === 'string') ? proxy : proxy.GetPath());
318
- if (path in this.proxies_) {
320
+ if (this.proxies_.hasOwnProperty(path)) {
319
321
  delete this.proxies_[path];
320
322
  }
321
323
  }
@@ -392,6 +394,7 @@ class Changes {
392
394
  }
393
395
  AddNextTickHandler(handler) {
394
396
  this.nextTickHandlers_.push(handler);
397
+ this.Schedule();
395
398
  }
396
399
  Schedule() {
397
400
  if (this.isScheduled_) {
@@ -617,13 +620,19 @@ class Context {
617
620
  (this.record_[key] = (this.record_[key] || new _stack__WEBPACK_IMPORTED_MODULE_0__.Stack())).Push(value);
618
621
  }
619
622
  Pop(key, noResult) {
620
- return ((key in this.record_) ? this.record_[key].Pop() : (noResult || null));
623
+ return (this.record_.hasOwnProperty(key) ? this.record_[key].Pop() : (noResult || null));
621
624
  }
622
625
  Peek(key, noResult) {
623
- return ((key in this.record_) ? this.record_[key].Peek() : (noResult || null));
626
+ return (this.record_.hasOwnProperty(key) ? this.record_[key].Peek() : (noResult || null));
624
627
  }
625
628
  Get(key) {
626
- return ((key in this.record_) ? this.record_[key] : null);
629
+ return (this.record_.hasOwnProperty(key) ? this.record_[key] : null);
630
+ }
631
+ GetHistory(key) {
632
+ return (this.record_.hasOwnProperty(key) ? this.record_[key].GetHistory() : []);
633
+ }
634
+ GetRecordKeys() {
635
+ return Object.keys(this.record_);
627
636
  }
628
637
  }
629
638
 
@@ -876,7 +885,7 @@ class ElementScope {
876
885
  return;
877
886
  }
878
887
  this.state_.isMarked = true;
879
- if (!(this.element_ instanceof HTMLTemplateElement) && this.element_.tagName.toLowerCase() !== 'svg') {
888
+ if (!(this.element_ instanceof HTMLTemplateElement)) {
880
889
  let component = (0,_find__WEBPACK_IMPORTED_MODULE_6__.FindComponentById)(this.componentId_);
881
890
  if (component) {
882
891
  this.DestroyChildren_(component, this.element_, (markOnly || false));
@@ -917,7 +926,7 @@ class ElementScope {
917
926
  return (this.managers_.directive = (this.managers_.directive || new _directive_manager__WEBPACK_IMPORTED_MODULE_0__.DirectiveManager()));
918
927
  }
919
928
  DestroyChildren_(component, target, markOnly) {
920
- Array.from(target.children).forEach((child) => {
929
+ Array.from(target.children).filter(child => !child.contains(target)).forEach((child) => {
921
930
  let childScope = component.FindElementScope(child);
922
931
  if (childScope) { //Destroy element scope
923
932
  childScope.Destroy(markOnly);
@@ -1199,8 +1208,12 @@ __webpack_require__.r(__webpack_exports__);
1199
1208
  /* harmony export */ });
1200
1209
  /* harmony import */ var _directive_process__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../directive/process */ "./node_modules/@benbraide/inlinejs/lib/esm/directive/process.js");
1201
1210
  /* harmony import */ var _directive_transition__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../directive/transition */ "./node_modules/@benbraide/inlinejs/lib/esm/directive/transition.js");
1202
- /* harmony import */ var _journal_try__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../journal/try */ "./node_modules/@benbraide/inlinejs/lib/esm/journal/try.js");
1203
- /* harmony import */ var _find__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./find */ "./node_modules/@benbraide/inlinejs/lib/esm/component/find.js");
1211
+ /* harmony import */ var _global_get__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../global/get */ "./node_modules/@benbraide/inlinejs/lib/esm/global/get.js");
1212
+ /* harmony import */ var _journal_try__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../journal/try */ "./node_modules/@benbraide/inlinejs/lib/esm/journal/try.js");
1213
+ /* harmony import */ var _element_scope_id__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./element-scope-id */ "./node_modules/@benbraide/inlinejs/lib/esm/component/element-scope-id.js");
1214
+ /* harmony import */ var _find__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./find */ "./node_modules/@benbraide/inlinejs/lib/esm/component/find.js");
1215
+
1216
+
1204
1217
 
1205
1218
 
1206
1219
 
@@ -1215,8 +1228,8 @@ function InsertHtml({ element, html, type = 'replace', component, processDirecti
1215
1228
  else if (type === 'prepend') { //Insert before child nodes
1216
1229
  element.prepend(...Array.from(tmpl.content.childNodes));
1217
1230
  }
1218
- (afterInsert && (0,_journal_try__WEBPACK_IMPORTED_MODULE_2__.JournalTry)(afterInsert, 'InlineJS.InsertHtml', element));
1219
- let resolvedComponent = (0,_find__WEBPACK_IMPORTED_MODULE_3__.FindComponentById)(componentId);
1231
+ (afterInsert && (0,_journal_try__WEBPACK_IMPORTED_MODULE_3__.JournalTry)(afterInsert, 'InlineJS.InsertHtml', element));
1232
+ let resolvedComponent = (0,_find__WEBPACK_IMPORTED_MODULE_5__.FindComponentById)(componentId);
1220
1233
  if (processDirectives && resolvedComponent) {
1221
1234
  Array.from(element.children).forEach(child => (0,_directive_process__WEBPACK_IMPORTED_MODULE_0__.ProcessDirectives)({
1222
1235
  component: resolvedComponent,
@@ -1239,10 +1252,11 @@ function InsertHtml({ element, html, type = 'replace', component, processDirecti
1239
1252
  };
1240
1253
  if (type === 'replace') { //Remove all child nodes
1241
1254
  let destroyOffspring = (el) => {
1242
- let resolvedComponent = (0,_find__WEBPACK_IMPORTED_MODULE_3__.FindComponentById)(componentId);
1255
+ let resolvedComponent = (0,_find__WEBPACK_IMPORTED_MODULE_5__.FindComponentById)(componentId), global = (0,_global_get__WEBPACK_IMPORTED_MODULE_2__.GetGlobal)();
1243
1256
  Array.from(el.children).forEach((child) => {
1257
+ var _a;
1244
1258
  let elementScope = resolvedComponent === null || resolvedComponent === void 0 ? void 0 : resolvedComponent.FindElementScope(child);
1245
- if (elementScope) {
1259
+ if (elementScope || (_element_scope_id__WEBPACK_IMPORTED_MODULE_4__.ElementScopeKey in child && (elementScope = (_a = global.InferComponentFrom(child)) === null || _a === void 0 ? void 0 : _a.FindElementScope(child)))) {
1246
1260
  elementScope.Destroy();
1247
1261
  }
1248
1262
  else {
@@ -1329,12 +1343,15 @@ __webpack_require__.r(__webpack_exports__);
1329
1343
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1330
1344
  /* harmony export */ "Scope": () => (/* binding */ Scope)
1331
1345
  /* harmony export */ });
1346
+ /* harmony import */ var _proxy_root__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../proxy/root */ "./node_modules/@benbraide/inlinejs/lib/esm/proxy/root.js");
1347
+
1332
1348
  class Scope {
1333
1349
  constructor(componentId_, id_, root_) {
1334
1350
  this.componentId_ = componentId_;
1335
1351
  this.id_ = id_;
1336
1352
  this.root_ = root_;
1337
1353
  this.name_ = '';
1354
+ this.proxy_ = new _proxy_root__WEBPACK_IMPORTED_MODULE_0__.RootProxy(this.componentId_, {}, this.id_);
1338
1355
  }
1339
1356
  GetComponentId() {
1340
1357
  return this.componentId_;
@@ -1351,6 +1368,9 @@ class Scope {
1351
1368
  GetRoot() {
1352
1369
  return this.root_;
1353
1370
  }
1371
+ GetProxy() {
1372
+ return this.proxy_;
1373
+ }
1354
1374
  FindElement(deepestElement, predicate) {
1355
1375
  if (deepestElement === this.root_ || !this.root_.contains(deepestElement)) {
1356
1376
  return null;
@@ -1986,7 +2006,9 @@ __webpack_require__.r(__webpack_exports__);
1986
2006
 
1987
2007
 
1988
2008
  function CheckElement(element, { checkTemplate = true, checkDocument = true }) {
1989
- return ((element === null || element === void 0 ? void 0 : element.nodeType) === 1 && (!checkDocument || document.contains(element)) && (!checkTemplate || element instanceof HTMLTemplateElement || !element.closest('template')));
2009
+ return ((element === null || element === void 0 ? void 0 : element.nodeType) === 1 &&
2010
+ (!checkDocument || document.contains(element)) &&
2011
+ (!checkTemplate || element instanceof HTMLTemplateElement || !element.closest('template')));
1990
2012
  }
1991
2013
  function ProcessDirectives({ component, element, options = {} }) {
1992
2014
  var _a;
@@ -2019,12 +2041,12 @@ function ProcessDirectives({ component, element, options = {} }) {
2019
2041
  });
2020
2042
  if (!options.ignoreChildren && !(element instanceof HTMLTemplateElement)) { //Process children
2021
2043
  resolvedComponent === null || resolvedComponent === void 0 ? void 0 : resolvedComponent.PushSelectionScope();
2022
- Array.from(element.children).forEach(child => ProcessDirectives({ component, options,
2044
+ Array.from(element.children).filter(child => !child.contains(element)).forEach(child => ProcessDirectives({ component, options,
2023
2045
  element: child,
2024
2046
  }));
2025
2047
  resolvedComponent === null || resolvedComponent === void 0 ? void 0 : resolvedComponent.PopSelectionScope();
2026
2048
  }
2027
- (_a = resolvedComponent === null || resolvedComponent === void 0 ? void 0 : resolvedComponent.CreateElementScope(element)) === null || _a === void 0 ? void 0 : _a.ExecutePostProcessCallbacks();
2049
+ (_a = resolvedComponent === null || resolvedComponent === void 0 ? void 0 : resolvedComponent.FindElementScope(element)) === null || _a === void 0 ? void 0 : _a.ExecutePostProcessCallbacks();
2028
2050
  }
2029
2051
 
2030
2052
 
@@ -2198,7 +2220,7 @@ __webpack_require__.r(__webpack_exports__);
2198
2220
  const InlineJSContextKey = '__InlineJS_Context__';
2199
2221
  let InlineJSValueFunctions = {};
2200
2222
  let InlineJSVoidFunctions = {};
2201
- function GenerateValueReturningFunction(expression, contextElement, componentId) {
2223
+ function GenerateValueReturningFunction(expression, componentId) {
2202
2224
  if (InlineJSValueFunctions.hasOwnProperty(expression)) {
2203
2225
  return InlineJSValueFunctions[expression];
2204
2226
  }
@@ -2210,7 +2232,7 @@ function GenerateValueReturningFunction(expression, contextElement, componentId)
2210
2232
  with (${InlineJSContextKey}){
2211
2233
  return (${expression});
2212
2234
  };
2213
- `)).bind(contextElement);
2235
+ `));
2214
2236
  return (InlineJSValueFunctions[expression] = newFunction);
2215
2237
  }
2216
2238
  catch (err) {
@@ -2220,7 +2242,7 @@ function GenerateValueReturningFunction(expression, contextElement, componentId)
2220
2242
  }
2221
2243
  return null;
2222
2244
  }
2223
- function GenerateVoidFunction(expression, contextElement, componentId) {
2245
+ function GenerateVoidFunction(expression, componentId) {
2224
2246
  if (InlineJSVoidFunctions.hasOwnProperty(expression)) {
2225
2247
  return InlineJSVoidFunctions[expression];
2226
2248
  }
@@ -2229,7 +2251,7 @@ function GenerateVoidFunction(expression, contextElement, componentId) {
2229
2251
  with (${InlineJSContextKey}){
2230
2252
  ${expression};
2231
2253
  };
2232
- `)).bind(contextElement);
2254
+ `));
2233
2255
  return (InlineJSVoidFunctions[expression] = newFunction);
2234
2256
  }
2235
2257
  catch (err) {
@@ -2254,7 +2276,7 @@ function GenerateFunctionFromString({ componentId, contextElement, expression, d
2254
2276
  return null;
2255
2277
  };
2256
2278
  }
2257
- let runFunction = (handler, target, params, contexts, forwardSyntaxErrors = true) => {
2279
+ let runFunction = (handler, target, params, contexts, forwardSyntaxErrors = true, waitMessage) => {
2258
2280
  var _a;
2259
2281
  let component = (0,_component_find__WEBPACK_IMPORTED_MODULE_1__.FindComponentById)(componentId), proxy = component === null || component === void 0 ? void 0 : component.GetRootProxy().GetNative();
2260
2282
  if (!proxy || ((_a = component === null || component === void 0 ? void 0 : component.FindElementScope(contextElement)) === null || _a === void 0 ? void 0 : _a.IsDestroyed())) {
@@ -2274,8 +2296,9 @@ function GenerateFunctionFromString({ componentId, contextElement, expression, d
2274
2296
  return (disableFunctionCall ? result : CallIfFunction(result, handler, componentId, params));
2275
2297
  }
2276
2298
  let handleResult = (value) => {
2277
- if (waitPromise !== 'none') {
2299
+ if (value && waitPromise !== 'none') {
2278
2300
  (0,_wait_promise__WEBPACK_IMPORTED_MODULE_5__.WaitPromise)(value, handler, waitPromise === 'recursive');
2301
+ return (waitMessage || 'Loading data...');
2279
2302
  }
2280
2303
  else { //Immediate
2281
2304
  handler(value);
@@ -2302,18 +2325,18 @@ function GenerateFunctionFromString({ componentId, contextElement, expression, d
2302
2325
  context === null || context === void 0 ? void 0 : context.Pop(_utilities_context_keys__WEBPACK_IMPORTED_MODULE_4__.ContextKeys.self);
2303
2326
  }
2304
2327
  };
2305
- let valueReturnFunction = GenerateValueReturningFunction(expression, contextElement, componentId), voidFunction = null;
2328
+ let valueReturnFunction = GenerateValueReturningFunction(expression, componentId), voidFunction = null;
2306
2329
  if (!valueReturnFunction) {
2307
- voidFunction = GenerateVoidFunction(expression, contextElement, componentId);
2330
+ voidFunction = GenerateVoidFunction(expression, componentId);
2308
2331
  }
2309
- return (handler, params = [], contexts) => {
2332
+ return (handler, params = [], contexts, waitMessage) => {
2310
2333
  if (!voidFunction && valueReturnFunction) {
2311
2334
  try {
2312
- return runFunction(handler, valueReturnFunction, (params || []), (contexts || {}));
2335
+ return runFunction(handler, valueReturnFunction.bind(contextElement), (params || []), (contexts || {}), undefined, waitMessage);
2313
2336
  }
2314
2337
  catch (err) {
2315
2338
  if (err instanceof SyntaxError) {
2316
- voidFunction = GenerateVoidFunction(expression, contextElement, componentId);
2339
+ voidFunction = GenerateVoidFunction(expression, componentId);
2317
2340
  }
2318
2341
  else {
2319
2342
  throw err;
@@ -2321,7 +2344,7 @@ function GenerateFunctionFromString({ componentId, contextElement, expression, d
2321
2344
  }
2322
2345
  }
2323
2346
  if (voidFunction) {
2324
- return (runFunction(handler, voidFunction, (params || []), (contexts || {}), false) || null);
2347
+ return (runFunction(handler, voidFunction.bind(contextElement), (params || []), (contexts || {}), false) || null);
2325
2348
  }
2326
2349
  handler && handler(null);
2327
2350
  return null;
@@ -2745,6 +2768,7 @@ const InlineJSGlobalKey = '__InlineJS_GLOBAL_KEY__';
2745
2768
  function CreateGlobal(configOptions, idOffset = 0) {
2746
2769
  (0,_component_find__WEBPACK_IMPORTED_MODULE_0__.InitComponentCache)();
2747
2770
  globalThis[InlineJSGlobalKey] = new _base__WEBPACK_IMPORTED_MODULE_1__.BaseGlobal(configOptions, idOffset);
2771
+ (globalThis['InlineJS'] = (globalThis['InlineJS'] || {}))['global'] = globalThis[InlineJSGlobalKey];
2748
2772
  window.dispatchEvent(new CustomEvent(_get__WEBPACK_IMPORTED_MODULE_2__.GlobalCreatedEvent));
2749
2773
  return globalThis[InlineJSGlobalKey];
2750
2774
  }
@@ -3679,21 +3703,32 @@ class MutationObserver {
3679
3703
  });
3680
3704
  };
3681
3705
  entries.forEach((entry) => {
3682
- var _a;
3683
- let key = ((entry.target instanceof HTMLElement) ? (0,_component_element_scope_id__WEBPACK_IMPORTED_MODULE_0__.GetElementScopeId)(((_a = (0,_component_infer__WEBPACK_IMPORTED_MODULE_1__.InferComponent)(entry.target)) === null || _a === void 0 ? void 0 : _a.GetRoot()) || null) : '');
3684
- if (!key) { //Invalid target
3685
- return;
3686
- }
3706
+ var _a, _b;
3687
3707
  if ((entry === null || entry === void 0 ? void 0 : entry.type) === 'childList') {
3688
- let info = getInfo(key);
3689
- info.added.push(...Array.from(entry.addedNodes));
3690
- info.removed.push(...Array.from(entry.removedNodes));
3708
+ let pushRemovedNode = (node) => {
3709
+ var _a;
3710
+ let key = (0,_component_element_scope_id__WEBPACK_IMPORTED_MODULE_0__.GetElementScopeId)(((_a = (0,_component_infer__WEBPACK_IMPORTED_MODULE_1__.InferComponent)(node)) === null || _a === void 0 ? void 0 : _a.GetRoot()) || null);
3711
+ if (key) {
3712
+ getInfo(key).removed.push(node);
3713
+ }
3714
+ else { //Try children
3715
+ Array.from(node.childNodes).filter(child => !child.contains(node)).forEach(pushRemovedNode);
3716
+ }
3717
+ };
3718
+ entry.removedNodes.forEach(pushRemovedNode);
3719
+ let key = ((entry.target instanceof HTMLElement) ? (0,_component_element_scope_id__WEBPACK_IMPORTED_MODULE_0__.GetElementScopeId)(((_a = (0,_component_infer__WEBPACK_IMPORTED_MODULE_1__.InferComponent)(entry.target)) === null || _a === void 0 ? void 0 : _a.GetRoot()) || null) : '');
3720
+ if (key) {
3721
+ getInfo(key).added.push(...Array.from(entry.addedNodes));
3722
+ }
3691
3723
  }
3692
3724
  else if ((entry === null || entry === void 0 ? void 0 : entry.type) === 'attributes' && entry.attributeName) {
3693
- getInfo(key).attributes.push({
3694
- name: entry.attributeName,
3695
- target: entry.target,
3696
- });
3725
+ let key = ((entry.target instanceof HTMLElement) ? (0,_component_element_scope_id__WEBPACK_IMPORTED_MODULE_0__.GetElementScopeId)(((_b = (0,_component_infer__WEBPACK_IMPORTED_MODULE_1__.InferComponent)(entry.target)) === null || _b === void 0 ? void 0 : _b.GetRoot()) || null) : '');
3726
+ if (key) {
3727
+ getInfo(key).attributes.push({
3728
+ name: entry.attributeName,
3729
+ target: entry.target,
3730
+ });
3731
+ }
3697
3732
  }
3698
3733
  });
3699
3734
  if (Object.keys(mutations).length == 0) {
@@ -3890,13 +3925,13 @@ function CreateInplaceProxy({ target, getter, setter, deleter, lookup, alert })
3890
3925
  if (typeof prop === 'symbol' || (typeof prop === 'string' && prop === 'prototype')) {
3891
3926
  return Reflect.set(target, prop, value);
3892
3927
  }
3893
- return (setter ? setter(prop.toString(), value, target) : (!!target[prop] || true));
3928
+ return (setter ? (setter(prop.toString(), value, target) !== false) : (!!target[prop] || true));
3894
3929
  },
3895
3930
  deleteProperty(target, prop) {
3896
3931
  if (typeof prop === 'symbol' || (typeof prop === 'string' && prop === 'prototype')) {
3897
3932
  return Reflect.deleteProperty(target, prop);
3898
3933
  }
3899
- return (deleter ? deleter(prop.toString(), target) : (!!(delete target[prop]) || true));
3934
+ return (deleter ? (deleter(prop.toString(), target) !== false) : (!!(delete target[prop]) || true));
3900
3935
  },
3901
3936
  has(target, prop) {
3902
3937
  if (Reflect.has(target, prop)) {
@@ -3981,7 +4016,7 @@ __webpack_require__.r(__webpack_exports__);
3981
4016
 
3982
4017
 
3983
4018
  class GenericProxy {
3984
- constructor(componentId_, target_, name_, parent) {
4019
+ constructor(componentId_, target_, name_, parent, isFalseRoot = false) {
3985
4020
  this.componentId_ = componentId_;
3986
4021
  this.target_ = target_;
3987
4022
  this.name_ = name_;
@@ -4007,7 +4042,7 @@ class GenericProxy {
4007
4042
  }
4008
4043
  return result;
4009
4044
  };
4010
- let isRoot = !this.parentPath_, handler = {
4045
+ let isRoot = (!isFalseRoot && !this.parentPath_), handler = {
4011
4046
  get(target, prop) {
4012
4047
  if (typeof prop === 'symbol' || prop === 'prototype') {
4013
4048
  return Reflect.get(target, prop);
@@ -4167,8 +4202,8 @@ __webpack_require__.r(__webpack_exports__);
4167
4202
  /* harmony import */ var _generic__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./generic */ "./node_modules/@benbraide/inlinejs/lib/esm/proxy/generic.js");
4168
4203
 
4169
4204
  class RootProxy extends _generic__WEBPACK_IMPORTED_MODULE_0__.GenericProxy {
4170
- constructor(componentId, target) {
4171
- super(componentId, target, `Proxy<${componentId}>`);
4205
+ constructor(componentId, target, id) {
4206
+ super(componentId, target, `Proxy<${id || componentId}>`, undefined, !!id);
4172
4207
  }
4173
4208
  }
4174
4209
 
@@ -4370,6 +4405,9 @@ class Stack {
4370
4405
  IsEmpty() {
4371
4406
  return (this.list_.length == 0);
4372
4407
  }
4408
+ GetHistory() {
4409
+ return this.list_.map(item => item);
4410
+ }
4373
4411
  }
4374
4412
 
4375
4413
 
@@ -5265,6 +5303,7 @@ let StripeUrl = 'https://js.stripe.com/v3/';
5265
5303
  let StripeStyles = null;
5266
5304
  let StripeClasses = null;
5267
5305
  exports.StripeDirectiveHandler = (0, inlinejs_1.CreateDirectiveHandlerCallback)(StripeDirectiveName, ({ componentId, component, contextElement, expression, argKey, argOptions }) => {
5306
+ var _a;
5268
5307
  if ((0, inlinejs_1.BindEvent)({ contextElement, expression,
5269
5308
  component: (component || componentId),
5270
5309
  key: StripeDirectiveName,
@@ -5291,159 +5330,150 @@ exports.StripeDirectiveHandler = (0, inlinejs_1.CreateDirectiveHandlerCallback)(
5291
5330
  elementScope.SetLocal(localKey, (0, inlinejs_1.CreateInplaceProxy)((0, inlinejs_1.BuildGetterProxyOptions)({
5292
5331
  getter: (prop) => {
5293
5332
  var _a;
5333
+ let local = (contextElement.parentElement ? (_a = (0, inlinejs_1.FindComponentById)(componentId)) === null || _a === void 0 ? void 0 : _a.FindElementLocalValue(contextElement.parentElement, localKey, true) : null);
5294
5334
  if (prop === 'parent') {
5295
- return (contextElement.parentElement ? (_a = (0, inlinejs_1.FindComponentById)(componentId)) === null || _a === void 0 ? void 0 : _a.FindElementLocalValue(contextElement.parentElement, localKey, true) : null);
5335
+ return local;
5296
5336
  }
5337
+ return ((prop && local) ? local[prop] : null);
5297
5338
  },
5298
5339
  lookup: ['parent'],
5299
5340
  })));
5300
5341
  }
5301
5342
  return;
5302
5343
  }
5303
- if (argKey in StripeKeys) { //Bind Stripe field
5304
- let details = resolvedComponent.FindElementLocalValue(contextElement, detailsKey, true);
5305
- if (!details) { //No parent
5306
- return;
5307
- }
5308
- let id = resolvedComponent.GenerateUniqueId(`${StripeDirectiveName}_proxy_`), field = {
5309
- name: argKey,
5310
- mount: contextElement,
5311
- element: details.elements.create(StripeKeys[argKey], {
5312
- style: (StripeStyles || undefined),
5313
- classes: (StripeClasses || undefined),
5314
- }),
5315
- ready: false,
5316
- complete: false,
5317
- error: undefined,
5318
- };
5319
- if (!field.element) {
5320
- return;
5321
- }
5322
- field.element.mount(contextElement);
5323
- details.fields.push(field);
5324
- elementScope.SetLocal(localKey, (0, inlinejs_1.CreateInplaceProxy)((0, inlinejs_1.BuildGetterProxyOptions)({
5325
- getter: (prop) => {
5326
- var _a, _b, _c, _d;
5327
- if (prop === 'complete') {
5328
- (_a = (0, inlinejs_1.FindComponentById)(componentId)) === null || _a === void 0 ? void 0 : _a.GetBackend().changes.AddGetAccess(`${id}.${prop}`);
5329
- return field.complete;
5330
- }
5331
- if (prop === 'focused') {
5332
- (_b = (0, inlinejs_1.FindComponentById)(componentId)) === null || _b === void 0 ? void 0 : _b.GetBackend().changes.AddGetAccess(`${id}.${prop}`);
5333
- return field.focused;
5334
- }
5335
- if (prop === 'error') {
5336
- (_c = (0, inlinejs_1.FindComponentById)(componentId)) === null || _c === void 0 ? void 0 : _c.GetBackend().changes.AddGetAccess(`${id}.${prop}`);
5337
- return field.error;
5338
- }
5339
- if (prop === 'parent') {
5340
- return (contextElement.parentElement ? (_d = (0, inlinejs_1.FindComponentById)(componentId)) === null || _d === void 0 ? void 0 : _d.FindElementLocalValue(contextElement.parentElement, localKey, true) : null);
5341
- }
5342
- if (prop === 'clear') {
5343
- return () => {
5344
- if (field.element) {
5345
- field.element.clear();
5346
- }
5347
- };
5348
- }
5349
- if (prop === 'focus') {
5350
- return () => {
5351
- if (field.element) {
5352
- field.element.focus();
5353
- }
5354
- };
5355
- }
5356
- if (prop === 'blur') {
5357
- return () => {
5358
- if (field.element) {
5359
- field.element.blur();
5360
- }
5361
- };
5362
- }
5363
- },
5364
- lookup: ['complete', 'focused', 'error', 'parent', 'clear', 'focus', 'blur'],
5365
- })));
5366
- let fields = details.fields;
5367
- elementScope.AddUninitCallback(() => {
5368
- var _a;
5369
- (_a = field.element) === null || _a === void 0 ? void 0 : _a.destroy();
5370
- fields.splice(fields.indexOf(field), 1);
5371
- });
5372
- field.element.on('ready', () => {
5373
- if (!field.ready) {
5374
- field.ready = true;
5375
- field.mount.dispatchEvent(new CustomEvent(`${StripeDirectiveName}.ready`));
5376
- details.onReady();
5377
- }
5378
- });
5379
- field.element.on('change', (e) => {
5380
- var _a, _b;
5381
- if ((e === null || e === void 0 ? void 0 : e.complete) === field.complete) {
5344
+ if (StripeKeys.hasOwnProperty(argKey)) { //Bind Stripe field
5345
+ return (_a = resolvedComponent.FindElementLocalValue(contextElement, detailsKey, true)) === null || _a === void 0 ? void 0 : _a.addField(argKey, contextElement, (field, details) => {
5346
+ let resolvedComponent = (0, inlinejs_1.FindComponentById)(componentId), elementScope = resolvedComponent === null || resolvedComponent === void 0 ? void 0 : resolvedComponent.FindElementScope(contextElement);
5347
+ let id = resolvedComponent === null || resolvedComponent === void 0 ? void 0 : resolvedComponent.GenerateUniqueId(`${StripeDirectiveName}_proxy_`);
5348
+ if (!field.element) {
5382
5349
  return;
5383
5350
  }
5384
- field.complete = e === null || e === void 0 ? void 0 : e.complete;
5385
- field.mount.dispatchEvent(new CustomEvent(`${StripeDirectiveName}.complete`, {
5386
- detail: {
5387
- completed: e === null || e === void 0 ? void 0 : e.complete,
5388
- },
5389
- }));
5390
- if (field.complete) {
5391
- if (field.error) {
5392
- field.error = undefined;
5393
- (0, inlinejs_1.AddChanges)('set', `${id}.error`, 'error', (_a = (0, inlinejs_1.FindComponentById)(componentId)) === null || _a === void 0 ? void 0 : _a.GetBackend().changes);
5394
- }
5395
- if (details.options.autofocus) { //Focus next if any
5396
- let index = details.fields.indexOf(field);
5397
- if (index != -1 && index < (details.fields.length - 1)) {
5398
- let nextField = details.fields[index + 1];
5399
- if (nextField.element) {
5400
- nextField.element.focus();
5401
- }
5402
- else if ('focus' in nextField.mount && typeof nextField.mount.focus === 'function') {
5403
- nextField.mount.focus();
5404
- }
5351
+ elementScope === null || elementScope === void 0 ? void 0 : elementScope.SetLocal(localKey, (0, inlinejs_1.CreateInplaceProxy)((0, inlinejs_1.BuildGetterProxyOptions)({
5352
+ getter: (prop) => {
5353
+ var _a, _b, _c, _d, _e;
5354
+ if (prop === 'complete') {
5355
+ (_a = (0, inlinejs_1.FindComponentById)(componentId)) === null || _a === void 0 ? void 0 : _a.GetBackend().changes.AddGetAccess(`${id}.${prop}`);
5356
+ return field.complete;
5405
5357
  }
5406
- else if (details.specialMounts.submit) {
5407
- details.specialMounts.submit.focus();
5358
+ if (prop === 'focused') {
5359
+ (_b = (0, inlinejs_1.FindComponentById)(componentId)) === null || _b === void 0 ? void 0 : _b.GetBackend().changes.AddGetAccess(`${id}.${prop}`);
5360
+ return field.focused;
5361
+ }
5362
+ if (prop === 'error') {
5363
+ (_c = (0, inlinejs_1.FindComponentById)(componentId)) === null || _c === void 0 ? void 0 : _c.GetBackend().changes.AddGetAccess(`${id}.${prop}`);
5364
+ return field.error;
5365
+ }
5366
+ if (prop === 'parent') {
5367
+ return (contextElement.parentElement ? (_d = (0, inlinejs_1.FindComponentById)(componentId)) === null || _d === void 0 ? void 0 : _d.FindElementLocalValue(contextElement.parentElement, localKey, true) : null);
5408
5368
  }
5369
+ if (prop === 'clear') {
5370
+ return () => {
5371
+ if (field.element) {
5372
+ field.element.clear();
5373
+ }
5374
+ };
5375
+ }
5376
+ if (prop === 'focus') {
5377
+ return () => {
5378
+ if (field.element) {
5379
+ field.element.focus();
5380
+ }
5381
+ };
5382
+ }
5383
+ if (prop === 'blur') {
5384
+ return () => {
5385
+ if (field.element) {
5386
+ field.element.blur();
5387
+ }
5388
+ };
5389
+ }
5390
+ if (prop === 'disable') {
5391
+ return (state = true) => {
5392
+ if (field.element) {
5393
+ field.element.update({ disabled: state });
5394
+ }
5395
+ };
5396
+ }
5397
+ let local = (contextElement.parentElement ? (_e = (0, inlinejs_1.FindComponentById)(componentId)) === null || _e === void 0 ? void 0 : _e.FindElementLocalValue(contextElement.parentElement, localKey, true) : null);
5398
+ return ((prop && local) ? local[prop] : null);
5399
+ },
5400
+ lookup: ['complete', 'focused', 'error', 'parent', 'clear', 'focus', 'blur', 'disable'],
5401
+ })));
5402
+ field.element.on('ready', () => {
5403
+ if (!field.ready) {
5404
+ field.ready = true;
5405
+ field.mount.dispatchEvent(new CustomEvent(`${StripeDirectiveName}.ready`));
5406
+ details.onReady();
5409
5407
  }
5410
- }
5411
- else if ((e === null || e === void 0 ? void 0 : e.error) && e.error.message !== field.error) {
5412
- field.error = e.error.message;
5413
- (0, inlinejs_1.AddChanges)('set', `${id}.error`, 'error', (_b = (0, inlinejs_1.FindComponentById)(componentId)) === null || _b === void 0 ? void 0 : _b.GetBackend().changes);
5414
- field.mount.dispatchEvent(new CustomEvent(`${StripeDirectiveName}.error`, {
5415
- detail: {
5416
- message: e.error.message,
5417
- },
5418
- }));
5419
- }
5420
- details.onChange();
5421
- });
5422
- field.element.on('focus', () => {
5423
- var _a;
5424
- if (!field.focused) {
5425
- field.focused = true;
5426
- (0, inlinejs_1.AddChanges)('set', `${id}.focused`, 'focused', (_a = (0, inlinejs_1.FindComponentById)(componentId)) === null || _a === void 0 ? void 0 : _a.GetBackend().changes);
5427
- field.mount.dispatchEvent(new CustomEvent(`${StripeDirectiveName}.focus`, {
5428
- detail: {
5429
- focused: true,
5430
- },
5431
- }));
5432
- }
5433
- });
5434
- field.element.on('blur', () => {
5435
- var _a;
5436
- if (field.focused) {
5437
- field.focused = false;
5438
- (0, inlinejs_1.AddChanges)('set', `${id}.focused`, 'focused', (_a = (0, inlinejs_1.FindComponentById)(componentId)) === null || _a === void 0 ? void 0 : _a.GetBackend().changes);
5439
- field.mount.dispatchEvent(new CustomEvent(`${StripeDirectiveName}.focus`, {
5408
+ });
5409
+ field.element.on('change', (e) => {
5410
+ var _a, _b;
5411
+ if ((e === null || e === void 0 ? void 0 : e.complete) === field.complete) {
5412
+ return;
5413
+ }
5414
+ field.complete = e === null || e === void 0 ? void 0 : e.complete;
5415
+ field.mount.dispatchEvent(new CustomEvent(`${StripeDirectiveName}.complete`, {
5440
5416
  detail: {
5441
- focused: false,
5417
+ completed: e === null || e === void 0 ? void 0 : e.complete,
5442
5418
  },
5443
5419
  }));
5444
- }
5420
+ if (field.complete) {
5421
+ if (field.error) {
5422
+ field.error = undefined;
5423
+ (0, inlinejs_1.AddChanges)('set', `${id}.error`, 'error', (_a = (0, inlinejs_1.FindComponentById)(componentId)) === null || _a === void 0 ? void 0 : _a.GetBackend().changes);
5424
+ }
5425
+ if (details.options.autofocus) { //Focus next if any
5426
+ let index = details.fields.indexOf(field);
5427
+ if (index != -1 && index < (details.fields.length - 1)) {
5428
+ let nextField = details.fields[index + 1];
5429
+ if (nextField.element) {
5430
+ nextField.element.focus();
5431
+ }
5432
+ else if ('focus' in nextField.mount && typeof nextField.mount.focus === 'function') {
5433
+ nextField.mount.focus();
5434
+ }
5435
+ }
5436
+ else if (details.specialMounts.submit) {
5437
+ details.specialMounts.submit.focus();
5438
+ }
5439
+ }
5440
+ }
5441
+ else if ((e === null || e === void 0 ? void 0 : e.error) && e.error.message !== field.error) {
5442
+ field.error = e.error.message;
5443
+ (0, inlinejs_1.AddChanges)('set', `${id}.error`, 'error', (_b = (0, inlinejs_1.FindComponentById)(componentId)) === null || _b === void 0 ? void 0 : _b.GetBackend().changes);
5444
+ field.mount.dispatchEvent(new CustomEvent(`${StripeDirectiveName}.error`, {
5445
+ detail: {
5446
+ message: e.error.message,
5447
+ },
5448
+ }));
5449
+ }
5450
+ details.onChange();
5451
+ });
5452
+ field.element.on('focus', () => {
5453
+ var _a;
5454
+ if (!field.focused) {
5455
+ field.focused = true;
5456
+ (0, inlinejs_1.AddChanges)('set', `${id}.focused`, 'focused', (_a = (0, inlinejs_1.FindComponentById)(componentId)) === null || _a === void 0 ? void 0 : _a.GetBackend().changes);
5457
+ field.mount.dispatchEvent(new CustomEvent(`${StripeDirectiveName}.focus`, {
5458
+ detail: {
5459
+ focused: true,
5460
+ },
5461
+ }));
5462
+ }
5463
+ });
5464
+ field.element.on('blur', () => {
5465
+ var _a;
5466
+ if (field.focused) {
5467
+ field.focused = false;
5468
+ (0, inlinejs_1.AddChanges)('set', `${id}.focused`, 'focused', (_a = (0, inlinejs_1.FindComponentById)(componentId)) === null || _a === void 0 ? void 0 : _a.GetBackend().changes);
5469
+ field.mount.dispatchEvent(new CustomEvent(`${StripeDirectiveName}.focus`, {
5470
+ detail: {
5471
+ focused: false,
5472
+ },
5473
+ }));
5474
+ }
5475
+ });
5445
5476
  });
5446
- return;
5447
5477
  }
5448
5478
  let stripeInstance = null, elements = null, backlog = new Array(), init = () => {
5449
5479
  (0, inlinejs_1.EvaluateLater)({ componentId, contextElement, expression })((value) => {
@@ -5482,6 +5512,31 @@ exports.StripeDirectiveHandler = (0, inlinejs_1.CreateDirectiveHandlerCallback)(
5482
5512
  }
5483
5513
  };
5484
5514
  let details = { fields, specialMounts, options,
5515
+ addField(key, target, callback) {
5516
+ let add = () => {
5517
+ var _a, _b;
5518
+ let field = {
5519
+ name: key,
5520
+ mount: target,
5521
+ element: elements.create(StripeKeys[key], {
5522
+ style: (StripeStyles || undefined),
5523
+ classes: (StripeClasses || undefined),
5524
+ }),
5525
+ ready: false,
5526
+ complete: false,
5527
+ error: undefined,
5528
+ };
5529
+ field.element.mount(target);
5530
+ this.fields.push(field);
5531
+ (_b = (_a = (0, inlinejs_1.FindComponentById)(componentId)) === null || _a === void 0 ? void 0 : _a.FindElementScope(target)) === null || _b === void 0 ? void 0 : _b.AddUninitCallback(() => {
5532
+ var _a;
5533
+ (_a = field.element) === null || _a === void 0 ? void 0 : _a.destroy();
5534
+ this.fields = this.fields.filter(item => (item !== field));
5535
+ });
5536
+ callback(field, this);
5537
+ };
5538
+ elements ? add() : backlog.push(add);
5539
+ },
5485
5540
  onReady: () => { var _a; return (0, inlinejs_1.AddChanges)('set', `${id}.readyCount`, 'readyCount', (_a = (0, inlinejs_1.FindComponentById)(componentId)) === null || _a === void 0 ? void 0 : _a.GetBackend().changes); },
5486
5541
  onChange: () => {
5487
5542
  var _a;
@@ -5639,9 +5694,9 @@ exports.StripeDirectiveHandler = (0, inlinejs_1.CreateDirectiveHandlerCallback)(
5639
5694
  };
5640
5695
  }
5641
5696
  if (prop === 'setup') {
5642
- return (clientSecret, paymentMethod, save = false) => {
5697
+ return (clientSecret, paymentMethod) => {
5643
5698
  payOrSetup(() => {
5644
- let paymentDetails = getPaymentDetails(paymentMethod, save);
5699
+ let paymentDetails = getPaymentDetails(paymentMethod, false);
5645
5700
  if (paymentDetails) {
5646
5701
  stripeInstance === null || stripeInstance === void 0 ? void 0 : stripeInstance.confirmCardSetup(clientSecret, paymentDetails).then(onSuccess).catch(onError);
5647
5702
  }