unpoly-rails 3.7.1 → 3.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@
5
5
  /***/ (() => {
6
6
 
7
7
  window.up = {
8
- version: '3.7.1'
8
+ version: '3.7.2'
9
9
  };
10
10
 
11
11
 
@@ -1989,9 +1989,6 @@ up.RenderJob = (_a = class RenderJob {
1989
1989
  this._rendered = this._executePromise();
1990
1990
  return this;
1991
1991
  }
1992
- getPreflightFragments() {
1993
- return this._getChange().getPreflightProps().fragments;
1994
- }
1995
1992
  async _executePromise() {
1996
1993
  try {
1997
1994
  this._guardRender();
@@ -3668,9 +3665,7 @@ up.FieldWatcher = class FieldWatcher {
3668
3665
  if (target !== this._root)
3669
3666
  this._watchFieldsWithin(target);
3670
3667
  });
3671
- for (let abortableElement of this._abortableElements()) {
3672
- this._unbindFns.push(up.fragment.onAborted(abortableElement, () => this._abort()));
3673
- }
3668
+ this._unbindFns.push(up.fragment.onAborted(this._scope, () => this._abort()));
3674
3669
  this._unbindFns.push(up.on(this._scope, 'reset', () => this._onFormReset()));
3675
3670
  }
3676
3671
  stop() {
@@ -3682,14 +3677,6 @@ up.FieldWatcher = class FieldWatcher {
3682
3677
  let rootOptions = u.copy(this._options);
3683
3678
  return up.form.watchOptions(field, rootOptions, { defaults: { event: 'input' } });
3684
3679
  }
3685
- _abortableElements() {
3686
- if (this._abortable === false) {
3687
- return [];
3688
- }
3689
- else {
3690
- return u.wrapList(this._abortable ?? this._scope);
3691
- }
3692
- }
3693
3680
  _watchFieldsWithin(container) {
3694
3681
  for (let field of up.form.fields(container)) {
3695
3682
  this._watchField(field);
@@ -3796,10 +3783,14 @@ up.FormValidator = class FormValidator {
3796
3783
  this._honorAbort();
3797
3784
  }
3798
3785
  _honorAbort() {
3799
- up.fragment.onAborted(this._form, { around: true }, ({ target }) => this._unscheduleSolutionsWithin(target));
3786
+ up.fragment.onAborted(this._form, (event) => this._onAborted(event));
3800
3787
  }
3801
- _unscheduleSolutionsWithin(container) {
3802
- this._dirtySolutions = u.reject(this._dirtySolutions, ({ element }) => container.contains(element));
3788
+ _onAborted(event) {
3789
+ if (this._dirtySolutions.length) {
3790
+ this._dirtySolutions = [];
3791
+ this._nextRenderPromise.reject(new up.Aborted(event.reason));
3792
+ this._resetNextRenderPromise();
3793
+ }
3803
3794
  }
3804
3795
  _resetNextRenderPromise() {
3805
3796
  this._nextRenderPromise = u.newDeferred();
@@ -3880,20 +3871,22 @@ up.FormValidator = class FormValidator {
3880
3871
  _scheduleNextRender() {
3881
3872
  let solutionDelays = this._dirtySolutions.map((solution) => solution.renderOptions.delay);
3882
3873
  let shortestDelay = Math.min(...solutionDelays) || 0;
3883
- this._unscheduleNextRender();
3884
- this._nextRenderTimer = u.timer(shortestDelay, () => this._renderDirtySolutions());
3885
- }
3886
- _unscheduleNextRender() {
3887
3874
  clearTimeout(this._nextRenderTimer);
3875
+ this._nextRenderTimer = u.timer(shortestDelay, () => {
3876
+ this._nextRenderTimer = null;
3877
+ this._renderDirtySolutions();
3878
+ });
3888
3879
  }
3889
3880
  _renderDirtySolutions() {
3890
3881
  up.error.muteUncriticalRejection(this._doRenderDirtySolutions());
3891
3882
  }
3892
3883
  async _doRenderDirtySolutions() {
3893
- this._dirtySolutions = u.filter(this._dirtySolutions, ({ element, origin }) => up.fragment.isAlive(element) && up.fragment.isAlive(origin));
3894
- if (!this._dirtySolutions.length || this._rendering) {
3884
+ if (!this._dirtySolutions.length)
3885
+ return;
3886
+ if (this._rendering)
3887
+ return;
3888
+ if (this._nextRenderTimer)
3895
3889
  return;
3896
- }
3897
3890
  let dirtySolutions = this._dirtySolutions;
3898
3891
  this._dirtySolutions = [];
3899
3892
  let dirtyOrigins = u.map(dirtySolutions, 'origin');
@@ -3907,6 +3900,7 @@ up.FormValidator = class FormValidator {
3907
3900
  options.origin = this._form;
3908
3901
  options.focus ??= 'keep';
3909
3902
  options.failOptions = false;
3903
+ options.defaultMaybe = true;
3910
3904
  options.params = up.Params.merge(options.params, ...u.map(dirtyRenderOptionsList, 'params'));
3911
3905
  options.headers = u.merge(...u.map(dirtyRenderOptionsList, 'headers'));
3912
3906
  this._addValidateHeader(options.headers, dirtyNames);
@@ -8544,13 +8538,14 @@ up.fragment = (function () {
8544
8538
  }
8545
8539
  function parseTargetSteps(target, options = {}) {
8546
8540
  let defaultPlacement = options.defaultPlacement || 'swap';
8541
+ let defaultMaybe = options.defaultMaybe ?? false;
8547
8542
  let steps = [];
8548
8543
  let simpleSelectors = splitTarget(target);
8549
8544
  for (let selector of simpleSelectors) {
8550
8545
  if (selector === ':none')
8551
8546
  continue;
8552
8547
  let placement = defaultPlacement;
8553
- let maybe = false;
8548
+ let maybe = defaultMaybe;
8554
8549
  selector = selector.replace(/\b::?(before|after)\b/, (_match, customPlacement) => {
8555
8550
  placement = customPlacement;
8556
8551
  return '';
@@ -8594,8 +8589,8 @@ up.fragment = (function () {
8594
8589
  return request.fromCache && u.evalAutoOption(options.revalidate, config.autoRevalidate, response);
8595
8590
  }
8596
8591
  function targetForSteps(steps) {
8597
- let requiredSteps = u.reject(steps, 'maybe');
8598
- let selectors = u.map(requiredSteps, 'selector');
8592
+ let bestSteps = steps.filter((step) => !step.maybe || step.oldElement?.isConnected);
8593
+ let selectors = u.map(bestSteps, 'selector');
8599
8594
  return selectors.join(', ') || ':none';
8600
8595
  }
8601
8596
  function isContainedByRivalStep(steps, candidateStep) {
@@ -8631,13 +8626,11 @@ up.fragment = (function () {
8631
8626
  let testFnWithAbortable = (request) => request.abortable && testFn(request);
8632
8627
  up.network.abort(testFnWithAbortable, { ...options, reason });
8633
8628
  for (let element of elements) {
8634
- up.emit(element, 'up:fragment:aborted', { newLayer, log: false });
8629
+ up.emit(element, 'up:fragment:aborted', { reason, newLayer, log: false });
8635
8630
  }
8636
8631
  }
8637
- function onAborted(fragment, ...args) {
8638
- let callback = u.extractCallback(args);
8639
- let options = u.extractOptions(args);
8640
- let guard = (event) => event.target.contains(fragment) || (options.around && fragment.contains(event.target));
8632
+ function onAborted(fragment, callback) {
8633
+ let guard = (event) => event.target.contains(fragment);
8641
8634
  let unsubscribe = up.on('up:fragment:aborted', { guard }, callback);
8642
8635
  up.destructor(fragment, unsubscribe);
8643
8636
  return unsubscribe;
@@ -10046,11 +10039,8 @@ up.form = (function () {
10046
10039
  return config.selector('submitButtonSelectors');
10047
10040
  }
10048
10041
  const submit = up.mockable((form, options) => {
10049
- return buildSubmitJob(form, options).execute();
10042
+ return up.render(submitOptions(form, options));
10050
10043
  });
10051
- function buildSubmitJob(form, options) {
10052
- return new up.RenderJob(submitOptions(form, options));
10053
- }
10054
10044
  function submitOptions(form, options, parserOptions) {
10055
10045
  form = getForm(form);
10056
10046
  options = u.options(options);
@@ -10067,9 +10057,6 @@ up.form = (function () {
10067
10057
  parser.include(up.link.followOptions);
10068
10058
  return options;
10069
10059
  }
10070
- function getPreflightFragments(form) {
10071
- return buildSubmitJob(form).getPreflightFragments();
10072
- }
10073
10060
  function watchOptions(field, options, parserOptions = {}) {
10074
10061
  options = u.options(options);
10075
10062
  let parser = new up.OptionsParser(field, options, { ...parserOptions, closest: true, attrPrefix: 'up-watch-' });
@@ -10193,10 +10180,8 @@ up.form = (function () {
10193
10180
  }
10194
10181
  }
10195
10182
  function autosubmit(target, options = {}) {
10196
- const form = getForm(target);
10197
- options.abortable ??= [form, ...getPreflightFragments(form)];
10198
- const onChange = (_value, _name, renderOptions) => submit(target, renderOptions);
10199
- return watch(target, options, onChange);
10183
+ const onChange = (_diff, renderOptions) => submit(target, renderOptions);
10184
+ return watch(target, { options, batch: true }, onChange);
10200
10185
  }
10201
10186
  function getGroupSelectors() {
10202
10187
  return up.migrate.migratedFormGroupSelectors?.() || config.groupSelectors;