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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84170dbbaa56e9d08bf7c57b22a3e9a96b04def816ba544e5c254d69bb5ba651
4
- data.tar.gz: cd9e91cd923091e80ba9be59fb62176c3c8f156c8af2f49f1fa7d7cdc77cd0ab
3
+ metadata.gz: 46d0ab0913d88d6ba567a358c4d0b23f11904c488a697101a5dcc6b65313c637
4
+ data.tar.gz: a16ee4e7ffd7214b2fb0ca7db84b0c0cefe113054fc9efc40924a2dc26e7911d
5
5
  SHA512:
6
- metadata.gz: 06c702b46d1e913493f0407f786772bfb65acdf088aab8f82238cee646a38125d8ef401e5255b5f5ada2994102b63416b21cac7f07f27fb5850671509d79f951
7
- data.tar.gz: c79fca122281fd2c14919504cdf7050c73a3e673ab2c7eab45891cd5b3f944b809b3f0c0cf79db5b362cd1f44f81b61321846a275c8c89108865469da4492503
6
+ metadata.gz: a8d6f8929e89a69be1aea26541a9bbd3b0b13033b2036abd84d0918dfbdec4cea88bb2201157280f59978fc683091d87e73c2498993bc9d30e275b22b57b8721
7
+ data.tar.gz: a4aef3a28a07bde970d01d01e993ff356bb55c9b8820dcf0278b171344bed7d3a881ce81c063ed19de723d4bf4a7a850062ffa1616e268b0ad6fdc079476a37f
@@ -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
 
@@ -2003,9 +2003,6 @@ up.RenderJob = (_a = class RenderJob {
2003
2003
  this._rendered = this._executePromise();
2004
2004
  return this;
2005
2005
  }
2006
- getPreflightFragments() {
2007
- return this._getChange().getPreflightProps().fragments;
2008
- }
2009
2006
  _executePromise() {
2010
2007
  return __awaiter(this, void 0, void 0, function* () {
2011
2008
  try {
@@ -3704,9 +3701,7 @@ up.FieldWatcher = class FieldWatcher {
3704
3701
  if (target !== this._root)
3705
3702
  this._watchFieldsWithin(target);
3706
3703
  });
3707
- for (let abortableElement of this._abortableElements()) {
3708
- this._unbindFns.push(up.fragment.onAborted(abortableElement, () => this._abort()));
3709
- }
3704
+ this._unbindFns.push(up.fragment.onAborted(this._scope, () => this._abort()));
3710
3705
  this._unbindFns.push(up.on(this._scope, 'reset', () => this._onFormReset()));
3711
3706
  }
3712
3707
  stop() {
@@ -3718,15 +3713,6 @@ up.FieldWatcher = class FieldWatcher {
3718
3713
  let rootOptions = u.copy(this._options);
3719
3714
  return up.form.watchOptions(field, rootOptions, { defaults: { event: 'input' } });
3720
3715
  }
3721
- _abortableElements() {
3722
- var _a;
3723
- if (this._abortable === false) {
3724
- return [];
3725
- }
3726
- else {
3727
- return u.wrapList((_a = this._abortable) !== null && _a !== void 0 ? _a : this._scope);
3728
- }
3729
- }
3730
3716
  _watchFieldsWithin(container) {
3731
3717
  for (let field of up.form.fields(container)) {
3732
3718
  this._watchField(field);
@@ -3855,10 +3841,14 @@ up.FormValidator = class FormValidator {
3855
3841
  this._honorAbort();
3856
3842
  }
3857
3843
  _honorAbort() {
3858
- up.fragment.onAborted(this._form, { around: true }, ({ target }) => this._unscheduleSolutionsWithin(target));
3844
+ up.fragment.onAborted(this._form, (event) => this._onAborted(event));
3859
3845
  }
3860
- _unscheduleSolutionsWithin(container) {
3861
- this._dirtySolutions = u.reject(this._dirtySolutions, ({ element }) => container.contains(element));
3846
+ _onAborted(event) {
3847
+ if (this._dirtySolutions.length) {
3848
+ this._dirtySolutions = [];
3849
+ this._nextRenderPromise.reject(new up.Aborted(event.reason));
3850
+ this._resetNextRenderPromise();
3851
+ }
3862
3852
  }
3863
3853
  _resetNextRenderPromise() {
3864
3854
  this._nextRenderPromise = u.newDeferred();
@@ -3940,11 +3930,11 @@ up.FormValidator = class FormValidator {
3940
3930
  _scheduleNextRender() {
3941
3931
  let solutionDelays = this._dirtySolutions.map((solution) => solution.renderOptions.delay);
3942
3932
  let shortestDelay = Math.min(...solutionDelays) || 0;
3943
- this._unscheduleNextRender();
3944
- this._nextRenderTimer = u.timer(shortestDelay, () => this._renderDirtySolutions());
3945
- }
3946
- _unscheduleNextRender() {
3947
3933
  clearTimeout(this._nextRenderTimer);
3934
+ this._nextRenderTimer = u.timer(shortestDelay, () => {
3935
+ this._nextRenderTimer = null;
3936
+ this._renderDirtySolutions();
3937
+ });
3948
3938
  }
3949
3939
  _renderDirtySolutions() {
3950
3940
  up.error.muteUncriticalRejection(this._doRenderDirtySolutions());
@@ -3952,10 +3942,12 @@ up.FormValidator = class FormValidator {
3952
3942
  _doRenderDirtySolutions() {
3953
3943
  var _a;
3954
3944
  return __awaiter(this, void 0, void 0, function* () {
3955
- this._dirtySolutions = u.filter(this._dirtySolutions, ({ element, origin }) => up.fragment.isAlive(element) && up.fragment.isAlive(origin));
3956
- if (!this._dirtySolutions.length || this._rendering) {
3945
+ if (!this._dirtySolutions.length)
3946
+ return;
3947
+ if (this._rendering)
3948
+ return;
3949
+ if (this._nextRenderTimer)
3957
3950
  return;
3958
- }
3959
3951
  let dirtySolutions = this._dirtySolutions;
3960
3952
  this._dirtySolutions = [];
3961
3953
  let dirtyOrigins = u.map(dirtySolutions, 'origin');
@@ -3969,6 +3961,7 @@ up.FormValidator = class FormValidator {
3969
3961
  options.origin = this._form;
3970
3962
  (_a = options.focus) !== null && _a !== void 0 ? _a : (options.focus = 'keep');
3971
3963
  options.failOptions = false;
3964
+ options.defaultMaybe = true;
3972
3965
  options.params = up.Params.merge(options.params, ...u.map(dirtyRenderOptionsList, 'params'));
3973
3966
  options.headers = u.merge(...u.map(dirtyRenderOptionsList, 'headers'));
3974
3967
  this._addValidateHeader(options.headers, dirtyNames);
@@ -4124,6 +4117,7 @@ up.FragmentProcessor = class FragmentProcessor extends up.Record {
4124
4117
  /* 45 */
4125
4118
  /***/ (() => {
4126
4119
 
4120
+ const u = up.util;
4127
4121
  const DESCENDANT_SELECTOR = /^([^ >+(]+) (.+)$/;
4128
4122
  up.FragmentFinder = class FragmentFinder {
4129
4123
  constructor(options) {
@@ -4153,13 +4147,16 @@ up.FragmentFinder = class FragmentFinder {
4153
4147
  return up.fragment.closest(this._origin, this._selector, this._options);
4154
4148
  }
4155
4149
  _findDescendantInRegion() {
4156
- let parts = this._selector.match(DESCENDANT_SELECTOR);
4157
- if (parts) {
4158
- let parent = up.fragment.closest(this._origin, parts[1], this._options);
4159
- if (parent) {
4160
- return up.fragment.getDumb(parent, parts[2]);
4150
+ let simpleSelectors = up.fragment.splitTarget(this._selector);
4151
+ return u.findResult(simpleSelectors, (simpleSelector) => {
4152
+ let parts = simpleSelector.match(DESCENDANT_SELECTOR);
4153
+ if (parts) {
4154
+ let parent = up.fragment.closest(this._origin, parts[1], this._options);
4155
+ if (parent) {
4156
+ return up.fragment.getDumb(parent, parts[2]);
4157
+ }
4161
4158
  }
4162
- }
4159
+ });
4163
4160
  }
4164
4161
  _findFirst() {
4165
4162
  return up.fragment.getDumb(this._document, this._selector, this._options);
@@ -8681,14 +8678,16 @@ up.fragment = (function () {
8681
8678
  return u.parseTokens(target, { separator: 'comma' });
8682
8679
  }
8683
8680
  function parseTargetSteps(target, options = {}) {
8681
+ var _a;
8684
8682
  let defaultPlacement = options.defaultPlacement || 'swap';
8683
+ let defaultMaybe = (_a = options.defaultMaybe) !== null && _a !== void 0 ? _a : false;
8685
8684
  let steps = [];
8686
8685
  let simpleSelectors = splitTarget(target);
8687
8686
  for (let selector of simpleSelectors) {
8688
8687
  if (selector === ':none')
8689
8688
  continue;
8690
8689
  let placement = defaultPlacement;
8691
- let maybe = false;
8690
+ let maybe = defaultMaybe;
8692
8691
  selector = selector.replace(/\b::?(before|after)\b/, (_match, customPlacement) => {
8693
8692
  placement = customPlacement;
8694
8693
  return '';
@@ -8728,8 +8727,8 @@ up.fragment = (function () {
8728
8727
  return request.fromCache && u.evalAutoOption(options.revalidate, config.autoRevalidate, response);
8729
8728
  }
8730
8729
  function targetForSteps(steps) {
8731
- let requiredSteps = u.reject(steps, 'maybe');
8732
- let selectors = u.map(requiredSteps, 'selector');
8730
+ let bestSteps = steps.filter((step) => { var _a; return !step.maybe || ((_a = step.oldElement) === null || _a === void 0 ? void 0 : _a.isConnected); });
8731
+ let selectors = u.map(bestSteps, 'selector');
8733
8732
  return selectors.join(', ') || ':none';
8734
8733
  }
8735
8734
  function isContainedByRivalStep(steps, candidateStep) {
@@ -8765,13 +8764,11 @@ up.fragment = (function () {
8765
8764
  let testFnWithAbortable = (request) => request.abortable && testFn(request);
8766
8765
  up.network.abort(testFnWithAbortable, Object.assign(Object.assign({}, options), { reason }));
8767
8766
  for (let element of elements) {
8768
- up.emit(element, 'up:fragment:aborted', { newLayer, log: false });
8767
+ up.emit(element, 'up:fragment:aborted', { reason, newLayer, log: false });
8769
8768
  }
8770
8769
  }
8771
- function onAborted(fragment, ...args) {
8772
- let callback = u.extractCallback(args);
8773
- let options = u.extractOptions(args);
8774
- let guard = (event) => event.target.contains(fragment) || (options.around && fragment.contains(event.target));
8770
+ function onAborted(fragment, callback) {
8771
+ let guard = (event) => event.target.contains(fragment);
8775
8772
  let unsubscribe = up.on('up:fragment:aborted', { guard }, callback);
8776
8773
  up.destructor(fragment, unsubscribe);
8777
8774
  return unsubscribe;
@@ -10185,11 +10182,8 @@ up.form = (function () {
10185
10182
  return config.selector('submitButtonSelectors');
10186
10183
  }
10187
10184
  const submit = up.mockable((form, options) => {
10188
- return buildSubmitJob(form, options).execute();
10185
+ return up.render(submitOptions(form, options));
10189
10186
  });
10190
- function buildSubmitJob(form, options) {
10191
- return new up.RenderJob(submitOptions(form, options));
10192
- }
10193
10187
  function submitOptions(form, options, parserOptions) {
10194
10188
  form = getForm(form);
10195
10189
  options = u.options(options);
@@ -10206,9 +10200,6 @@ up.form = (function () {
10206
10200
  parser.include(up.link.followOptions);
10207
10201
  return options;
10208
10202
  }
10209
- function getPreflightFragments(form) {
10210
- return buildSubmitJob(form).getPreflightFragments();
10211
- }
10212
10203
  function watchOptions(field, options, parserOptions = {}) {
10213
10204
  var _a;
10214
10205
  options = u.options(options);
@@ -10333,11 +10324,8 @@ up.form = (function () {
10333
10324
  }
10334
10325
  }
10335
10326
  function autosubmit(target, options = {}) {
10336
- var _a;
10337
- const form = getForm(target);
10338
- (_a = options.abortable) !== null && _a !== void 0 ? _a : (options.abortable = [form, ...getPreflightFragments(form)]);
10339
- const onChange = (_value, _name, renderOptions) => submit(target, renderOptions);
10340
- return watch(target, options, onChange);
10327
+ const onChange = (_diff, renderOptions) => submit(target, renderOptions);
10328
+ return watch(target, { options, batch: true }, onChange);
10341
10329
  }
10342
10330
  function getGroupSelectors() {
10343
10331
  var _a, _b;