unpoly-rails 3.7.1 → 3.7.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.
@@ -5,7 +5,7 @@
5
5
  /***/ (() => {
6
6
 
7
7
  window.up = {
8
- version: '3.7.1'
8
+ version: '3.7.3'
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);
@@ -4061,6 +4055,7 @@ up.FragmentProcessor = class FragmentProcessor extends up.Record {
4061
4055
  /* 45 */
4062
4056
  /***/ (() => {
4063
4057
 
4058
+ const u = up.util;
4064
4059
  const DESCENDANT_SELECTOR = /^([^ >+(]+) (.+)$/;
4065
4060
  up.FragmentFinder = class FragmentFinder {
4066
4061
  constructor(options) {
@@ -4088,13 +4083,16 @@ up.FragmentFinder = class FragmentFinder {
4088
4083
  return up.fragment.closest(this._origin, this._selector, this._options);
4089
4084
  }
4090
4085
  _findDescendantInRegion() {
4091
- let parts = this._selector.match(DESCENDANT_SELECTOR);
4092
- if (parts) {
4093
- let parent = up.fragment.closest(this._origin, parts[1], this._options);
4094
- if (parent) {
4095
- return up.fragment.getDumb(parent, parts[2]);
4086
+ let simpleSelectors = up.fragment.splitTarget(this._selector);
4087
+ return u.findResult(simpleSelectors, (simpleSelector) => {
4088
+ let parts = simpleSelector.match(DESCENDANT_SELECTOR);
4089
+ if (parts) {
4090
+ let parent = up.fragment.closest(this._origin, parts[1], this._options);
4091
+ if (parent) {
4092
+ return up.fragment.getDumb(parent, parts[2]);
4093
+ }
4096
4094
  }
4097
- }
4095
+ });
4098
4096
  }
4099
4097
  _findFirst() {
4100
4098
  return up.fragment.getDumb(this._document, this._selector, this._options);
@@ -8544,13 +8542,14 @@ up.fragment = (function () {
8544
8542
  }
8545
8543
  function parseTargetSteps(target, options = {}) {
8546
8544
  let defaultPlacement = options.defaultPlacement || 'swap';
8545
+ let defaultMaybe = options.defaultMaybe ?? false;
8547
8546
  let steps = [];
8548
8547
  let simpleSelectors = splitTarget(target);
8549
8548
  for (let selector of simpleSelectors) {
8550
8549
  if (selector === ':none')
8551
8550
  continue;
8552
8551
  let placement = defaultPlacement;
8553
- let maybe = false;
8552
+ let maybe = defaultMaybe;
8554
8553
  selector = selector.replace(/\b::?(before|after)\b/, (_match, customPlacement) => {
8555
8554
  placement = customPlacement;
8556
8555
  return '';
@@ -8594,8 +8593,8 @@ up.fragment = (function () {
8594
8593
  return request.fromCache && u.evalAutoOption(options.revalidate, config.autoRevalidate, response);
8595
8594
  }
8596
8595
  function targetForSteps(steps) {
8597
- let requiredSteps = u.reject(steps, 'maybe');
8598
- let selectors = u.map(requiredSteps, 'selector');
8596
+ let bestSteps = steps.filter((step) => !step.maybe || step.oldElement?.isConnected);
8597
+ let selectors = u.map(bestSteps, 'selector');
8599
8598
  return selectors.join(', ') || ':none';
8600
8599
  }
8601
8600
  function isContainedByRivalStep(steps, candidateStep) {
@@ -8631,13 +8630,11 @@ up.fragment = (function () {
8631
8630
  let testFnWithAbortable = (request) => request.abortable && testFn(request);
8632
8631
  up.network.abort(testFnWithAbortable, { ...options, reason });
8633
8632
  for (let element of elements) {
8634
- up.emit(element, 'up:fragment:aborted', { newLayer, log: false });
8633
+ up.emit(element, 'up:fragment:aborted', { reason, newLayer, log: false });
8635
8634
  }
8636
8635
  }
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));
8636
+ function onAborted(fragment, callback) {
8637
+ let guard = (event) => event.target.contains(fragment);
8641
8638
  let unsubscribe = up.on('up:fragment:aborted', { guard }, callback);
8642
8639
  up.destructor(fragment, unsubscribe);
8643
8640
  return unsubscribe;
@@ -10046,11 +10043,8 @@ up.form = (function () {
10046
10043
  return config.selector('submitButtonSelectors');
10047
10044
  }
10048
10045
  const submit = up.mockable((form, options) => {
10049
- return buildSubmitJob(form, options).execute();
10046
+ return up.render(submitOptions(form, options));
10050
10047
  });
10051
- function buildSubmitJob(form, options) {
10052
- return new up.RenderJob(submitOptions(form, options));
10053
- }
10054
10048
  function submitOptions(form, options, parserOptions) {
10055
10049
  form = getForm(form);
10056
10050
  options = u.options(options);
@@ -10067,9 +10061,6 @@ up.form = (function () {
10067
10061
  parser.include(up.link.followOptions);
10068
10062
  return options;
10069
10063
  }
10070
- function getPreflightFragments(form) {
10071
- return buildSubmitJob(form).getPreflightFragments();
10072
- }
10073
10064
  function watchOptions(field, options, parserOptions = {}) {
10074
10065
  options = u.options(options);
10075
10066
  let parser = new up.OptionsParser(field, options, { ...parserOptions, closest: true, attrPrefix: 'up-watch-' });
@@ -10193,10 +10184,8 @@ up.form = (function () {
10193
10184
  }
10194
10185
  }
10195
10186
  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);
10187
+ const onChange = (_diff, renderOptions) => submit(target, renderOptions);
10188
+ return watch(target, { options, batch: true }, onChange);
10200
10189
  }
10201
10190
  function getGroupSelectors() {
10202
10191
  return up.migrate.migratedFormGroupSelectors?.() || config.groupSelectors;