unpoly-rails 3.6.1.1 → 3.7.0.1

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.6.1'
8
+ version: '3.7.0'
9
9
  };
10
10
 
11
11
 
@@ -954,15 +954,7 @@ up.element = (function () {
954
954
  return Node.prototype.contains.call(root, element);
955
955
  }
956
956
  function ancestor(element, selector) {
957
- let parentElement = element.parentElement;
958
- if (parentElement) {
959
- if (parentElement.matches(selector)) {
960
- return parentElement;
961
- }
962
- else {
963
- return ancestor(parentElement, selector);
964
- }
965
- }
957
+ return element.parentNode?.closest(selector);
966
958
  }
967
959
  function around(element, selector) {
968
960
  return getList(element.closest(selector), subtree(element, selector));
@@ -1992,11 +1984,18 @@ const u = up.util;
1992
1984
  up.RenderJob = (_a = class RenderJob {
1993
1985
  constructor(options) {
1994
1986
  this.options = up.RenderOptions.preprocess(options);
1995
- this._rendered = this._execute();
1996
1987
  }
1997
- async _execute() {
1988
+ execute() {
1989
+ this._rendered = this._executePromise();
1990
+ return this;
1991
+ }
1992
+ getPreflightFragments() {
1993
+ return this._getChange().getPreflightProps().fragments;
1994
+ }
1995
+ async _executePromise() {
1998
1996
  try {
1999
- let result = await this._makeChange();
1997
+ this._guardRender();
1998
+ let result = await this._getChange().execute();
2000
1999
  this._handleResult(result);
2001
2000
  return result;
2002
2001
  }
@@ -2039,21 +2038,19 @@ up.RenderJob = (_a = class RenderJob {
2039
2038
  }
2040
2039
  }
2041
2040
  }
2042
- _makeChange() {
2043
- this._guardRender();
2041
+ _getChange() {
2044
2042
  if (this.options.url) {
2045
2043
  let onRequest = (request) => this._handleAbortOption(request);
2046
- this.change = new up.Change.FromURL({ ...this.options, onRequest });
2044
+ return new up.Change.FromURL({ ...this.options, onRequest });
2047
2045
  }
2048
2046
  else if (this.options.response) {
2049
- this.change = new up.Change.FromResponse(this.options);
2050
- this._handleAbortOption(null);
2047
+ let onRender = () => this._handleAbortOption(null);
2048
+ return new up.Change.FromResponse({ ...this.options, onRender });
2051
2049
  }
2052
2050
  else {
2053
- this.change = new up.Change.FromContent(this.options);
2054
- this._handleAbortOption(null);
2051
+ let onRender = () => this._handleAbortOption(null);
2052
+ return new up.Change.FromContent({ ...this.options, onRender });
2055
2053
  }
2056
- return this.change.execute();
2057
2054
  }
2058
2055
  _guardRender() {
2059
2056
  up.browser.assertConfirmed(this.options);
@@ -2070,7 +2067,7 @@ up.RenderJob = (_a = class RenderJob {
2070
2067
  let { abort } = this.options;
2071
2068
  if (!abort || !up.network.isBusy())
2072
2069
  return;
2073
- let { fragments, layer, origin, newLayer } = this.change.getPreflightProps();
2070
+ let { fragments, layer, origin, newLayer } = this._getChange().getPreflightProps();
2074
2071
  let abortOptions = {
2075
2072
  except: request,
2076
2073
  logOnce: ['up.render()', 'Change with { abort } option will abort other requests'],
@@ -2097,7 +2094,8 @@ up.RenderJob = (_a = class RenderJob {
2097
2094
  (() => {
2098
2095
  u.delegate(_a.prototype, ['then', 'catch', 'finally'], function () { return this._rendered; });
2099
2096
  u.memoizeMethod(_a.prototype, {
2100
- _awaitFinished: true
2097
+ _awaitFinished: true,
2098
+ _getChange: true,
2101
2099
  });
2102
2100
  })(),
2103
2101
  _a);
@@ -2272,7 +2270,8 @@ up.Change.OpenLayer = class OpenLayer extends up.Change.Addition {
2272
2270
  const fragmentFocus = new up.FragmentFocus({
2273
2271
  fragment: this._content,
2274
2272
  layer: this.layer,
2275
- autoMeans: ['autofocus', 'layer']
2273
+ autoMeans: ['autofocus', 'layer'],
2274
+ inputDevice: this.options.inputDevice,
2276
2275
  });
2277
2276
  fragmentFocus.process(this.options.focus);
2278
2277
  }
@@ -2745,7 +2744,7 @@ up.Change.CloseLayer = class CloseLayer extends up.Change.Removal {
2745
2744
  this._layer.overlayFocus.teardown();
2746
2745
  formerParent.overlayFocus?.moveToFront();
2747
2746
  let newFocusElement = this._layer.origin || formerParent.element;
2748
- newFocusElement.focus({ preventScroll: true });
2747
+ up.focus(newFocusElement, { preventScroll: true });
2749
2748
  }
2750
2749
  };
2751
2750
 
@@ -3033,6 +3032,7 @@ up.Change.FromContent = (_a = class FromContent extends up.Change {
3033
3032
  if (assets) {
3034
3033
  up.script.assertAssetsOK(assets, plan.options);
3035
3034
  }
3035
+ this.options.onRender?.();
3036
3036
  }
3037
3037
  _getResponseDoc() {
3038
3038
  if (this._preview)
@@ -3482,6 +3482,7 @@ up.EventListener = class EventListener extends up.Record {
3482
3482
  'baseLayer',
3483
3483
  'passive',
3484
3484
  'once',
3485
+ 'capture',
3485
3486
  'beforeBoot',
3486
3487
  ];
3487
3488
  }
@@ -3501,7 +3502,7 @@ up.EventListener = class EventListener extends up.Record {
3501
3502
  this.element.addEventListener(...this._addListenerArg());
3502
3503
  }
3503
3504
  _addListenerArg() {
3504
- let options = u.compactObject(u.pick(this, ['once', 'passive']));
3505
+ let options = u.compactObject(u.pick(this, ['once', 'passive', 'capture']));
3505
3506
  return [this.eventType, this.nativeCallback, options];
3506
3507
  }
3507
3508
  unbind() {
@@ -3585,6 +3586,7 @@ up.EventListenerGroup = class EventListenerGroup extends up.Record {
3585
3586
  'baseLayer',
3586
3587
  'passive',
3587
3588
  'once',
3589
+ 'capture',
3588
3590
  'beforeBoot',
3589
3591
  ];
3590
3592
  }
@@ -3647,88 +3649,102 @@ up.EventListenerGroup = class EventListenerGroup extends up.Record {
3647
3649
 
3648
3650
  const u = up.util;
3649
3651
  up.FieldWatcher = class FieldWatcher {
3650
- constructor(fields, options, callback) {
3651
- this._callback = callback;
3652
- this._fields = fields;
3652
+ constructor(root, options, callback) {
3653
3653
  this._options = options;
3654
+ this._root = root;
3655
+ this._scope = up.form.getScope(root);
3656
+ this._callback = callback;
3654
3657
  this._batch = options.batch;
3655
- this._unbindFns = [];
3656
- }
3657
- _fieldOptions(field) {
3658
- let options = u.copy(this._options);
3659
- return up.form.watchOptions(field, options, { defaults: { event: 'input' } });
3658
+ this._abortable = options.abortable;
3660
3659
  }
3661
3660
  start() {
3662
3661
  this._scheduledValues = null;
3663
3662
  this._processedValues = this._readFieldValues();
3664
3663
  this._currentTimer = null;
3665
3664
  this._callbackRunning = false;
3666
- for (let field of this._fields) {
3667
- this._watchField(field);
3665
+ this._unbindFns = [];
3666
+ this._watchFieldsWithin(this._root);
3667
+ this._root.addEventListener('up:fragment:inserted', ({ target }) => {
3668
+ if (target !== this._root)
3669
+ this._watchFieldsWithin(target);
3670
+ });
3671
+ for (let abortableElement of this._abortableElements()) {
3672
+ this._unbindFns.push(up.fragment.onAborted(abortableElement, () => this._abort()));
3668
3673
  }
3669
- }
3670
- _watchField(field) {
3671
- let _fieldOptions = this._fieldOptions(field);
3672
- this._unbindFns.push(up.on(field, _fieldOptions.event, (event) => this._check(event, _fieldOptions)));
3673
- this._unbindFns.push(up.fragment.onAborted(field, () => this._cancelTimer()));
3674
+ this._unbindFns.push(up.on(this._scope, 'reset', () => this._onFormReset()));
3674
3675
  }
3675
3676
  stop() {
3677
+ this._abort();
3676
3678
  for (let unbindFn of this._unbindFns)
3677
3679
  unbindFn();
3678
- this._cancelTimer();
3679
3680
  }
3680
- _cancelTimer() {
3681
- clearTimeout(this._currentTimer);
3682
- this._currentTimer = null;
3681
+ _fieldOptions(field) {
3682
+ let rootOptions = u.copy(this._options);
3683
+ return up.form.watchOptions(field, rootOptions, { defaults: { event: 'input' } });
3684
+ }
3685
+ _abortableElements() {
3686
+ if (this._abortable === false) {
3687
+ return [];
3688
+ }
3689
+ else {
3690
+ return u.wrapList(this._abortable ?? this._scope);
3691
+ }
3692
+ }
3693
+ _watchFieldsWithin(container) {
3694
+ for (let field of up.form.fields(container)) {
3695
+ this._watchField(field);
3696
+ }
3683
3697
  }
3684
- _isAnyFieldAttached() {
3685
- return u.some(this._fields, 'isConnected');
3698
+ _watchField(field) {
3699
+ let fieldOptions = this._fieldOptions(field);
3700
+ this._unbindFns.push(up.on(field, fieldOptions.event, () => this._check(fieldOptions)));
3701
+ }
3702
+ _abort() {
3703
+ this._scheduledValues = null;
3686
3704
  }
3687
- _scheduleValues(values, event, _fieldOptions) {
3688
- this._cancelTimer();
3705
+ _scheduleValues(values, fieldOptions) {
3706
+ clearTimeout(this._currentTimer);
3689
3707
  this._scheduledValues = values;
3690
- let delay = u.evalOption(_fieldOptions.delay, event);
3708
+ let delay = fieldOptions.delay || 0;
3691
3709
  this._currentTimer = u.timer(delay, () => {
3692
- this._currentTimer = null;
3693
- if (this._isAnyFieldAttached()) {
3694
- this.scheduledFieldOptions = _fieldOptions;
3695
- this._requestCallback();
3696
- }
3697
- else {
3698
- this._scheduledValues = null;
3699
- }
3710
+ this._scheduledFieldOptions = fieldOptions;
3711
+ this._requestCallback();
3700
3712
  });
3701
3713
  }
3702
3714
  _isNewValues(values) {
3703
3715
  return !u.isEqual(values, this._processedValues) && !u.isEqual(this._scheduledValues, values);
3704
3716
  }
3705
3717
  async _requestCallback() {
3706
- let _fieldOptions = this.scheduledFieldOptions;
3707
- if ((this._scheduledValues !== null) && !this._currentTimer && !this._callbackRunning) {
3708
- const diff = this._changedValues(this._processedValues, this._scheduledValues);
3709
- this._processedValues = this._scheduledValues;
3710
- this._scheduledValues = null;
3711
- this._callbackRunning = true;
3712
- this.scheduledFieldOptions = null;
3713
- let callbackOptions = { ..._fieldOptions, disable: false };
3714
- const callbackReturnValues = [];
3715
- if (this._batch) {
3716
- callbackReturnValues.push(this._runCallback(diff, callbackOptions));
3717
- }
3718
- else {
3719
- for (let name in diff) {
3720
- const value = diff[name];
3721
- callbackReturnValues.push(this._runCallback(value, name, callbackOptions));
3722
- }
3723
- }
3724
- if (u.some(callbackReturnValues, u.isPromise)) {
3725
- let callbackDone = Promise.allSettled(callbackReturnValues);
3726
- up.form.disableWhile(callbackDone, _fieldOptions);
3727
- await callbackDone;
3718
+ if (!this._scheduledValues)
3719
+ return;
3720
+ if (this._callbackRunning)
3721
+ return;
3722
+ if (!this._scope.isConnected)
3723
+ return;
3724
+ let fieldOptions = this._scheduledFieldOptions;
3725
+ const diff = this._changedValues(this._processedValues, this._scheduledValues);
3726
+ this._processedValues = this._scheduledValues;
3727
+ this._scheduledValues = null;
3728
+ this._callbackRunning = true;
3729
+ this._scheduledFieldOptions = null;
3730
+ let callbackOptions = { ...fieldOptions, disable: false };
3731
+ const callbackReturnValues = [];
3732
+ if (this._batch) {
3733
+ callbackReturnValues.push(this._runCallback(diff, callbackOptions));
3734
+ }
3735
+ else {
3736
+ for (let name in diff) {
3737
+ const value = diff[name];
3738
+ callbackReturnValues.push(this._runCallback(value, name, callbackOptions));
3728
3739
  }
3729
- this._callbackRunning = false;
3730
- this._requestCallback();
3731
3740
  }
3741
+ if (u.some(callbackReturnValues, u.isPromise)) {
3742
+ let callbackDone = Promise.allSettled(callbackReturnValues);
3743
+ up.form.disableWhile(callbackDone, fieldOptions);
3744
+ await callbackDone;
3745
+ }
3746
+ this._callbackRunning = false;
3747
+ this._requestCallback();
3732
3748
  }
3733
3749
  _runCallback(...args) {
3734
3750
  return up.error.guard(() => this._callback(...args));
@@ -3748,14 +3764,17 @@ up.FieldWatcher = class FieldWatcher {
3748
3764
  return changes;
3749
3765
  }
3750
3766
  _readFieldValues() {
3751
- return up.Params.fromFields(this._fields).toObject();
3767
+ return up.Params.fromContainer(this._root).toObject();
3752
3768
  }
3753
- _check(event, _fieldOptions) {
3769
+ _check(fieldOptions = {}) {
3754
3770
  const values = this._readFieldValues();
3755
3771
  if (this._isNewValues(values)) {
3756
- this._scheduleValues(values, event, _fieldOptions);
3772
+ this._scheduleValues(values, fieldOptions);
3757
3773
  }
3758
3774
  }
3775
+ _onFormReset() {
3776
+ u.task(() => this._check());
3777
+ }
3759
3778
  };
3760
3779
 
3761
3780
 
@@ -4091,7 +4110,8 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
4091
4110
  keys() {
4092
4111
  return super.keys().concat([
4093
4112
  'hash',
4094
- 'focusCapsule'
4113
+ 'focusCapsule',
4114
+ 'inputDevice',
4095
4115
  ]);
4096
4116
  }
4097
4117
  processPrimitive(opt) {
@@ -4148,7 +4168,7 @@ up.FragmentFocus = class FragmentFocus extends up.FragmentProcessor {
4148
4168
  }
4149
4169
  _focusElement(element) {
4150
4170
  if (element) {
4151
- up.focus(element, { force: true, ...PREVENT_SCROLL_OPTIONS });
4171
+ up.focus(element, { force: true, ...PREVENT_SCROLL_OPTIONS, inputDevice: this.inputDevice });
4152
4172
  return true;
4153
4173
  }
4154
4174
  }
@@ -5789,8 +5809,11 @@ up.Params = class Params {
5789
5809
  return this.entries.length === 0;
5790
5810
  }
5791
5811
  static fromForm(form) {
5792
- form = up.fragment.get(form);
5793
- return this.fromFields(up.form.fields(form));
5812
+ return this.fromContainer(form);
5813
+ }
5814
+ static fromContainer(container) {
5815
+ let fields = up.form.fields(container);
5816
+ return this.fromFields(fields);
5794
5817
  }
5795
5818
  static fromFields(fields) {
5796
5819
  const params = new (this)();
@@ -5974,7 +5997,7 @@ up.RenderOptions = (function () {
5974
5997
  function preprocess(options) {
5975
5998
  up.migrate.preprocessRenderOptions?.(options);
5976
5999
  const defaults = u.merge(GLOBAL_DEFAULTS, navigateDefaults(options));
5977
- return u.merge(u.omit(defaults, LATE_KEYS), { defaults }, options, preloadOverrides(options));
6000
+ return u.merge(u.omit(defaults, LATE_KEYS), { defaults }, { inputDevice: up.event.inputDevice }, options, preloadOverrides(options));
5978
6001
  }
5979
6002
  function finalize(preprocessedOptions, lateDefaults) {
5980
6003
  return u.merge(preprocessedOptions.defaults, lateDefaults, preprocessedOptions);
@@ -7014,14 +7037,14 @@ const u = up.util;
7014
7037
  up.RevealMotion = class RevealMotion {
7015
7038
  constructor(element, options = {}) {
7016
7039
  this._element = element;
7017
- this._options = options;
7018
- this._viewport = e.get(this._options.viewport) || up.viewport.get(this._element);
7040
+ this._viewport = e.get(options.viewport) || up.viewport.get(this._element);
7019
7041
  this._obstructionsLayer = up.layer.get(this._viewport);
7042
+ this._behavior = options.behavior ?? 'instant';
7020
7043
  const viewportConfig = up.viewport.config;
7021
- this._snap = this._options.snap ?? this._options.revealSnap ?? viewportConfig.revealSnap;
7022
- this._padding = this._options.padding ?? this._options.revealPadding ?? viewportConfig.revealPadding;
7023
- this._top = this._options.top ?? this._options.revealTop ?? viewportConfig.revealTop;
7024
- this._max = this._options.max ?? this._options.revealMax ?? viewportConfig.revealMax;
7044
+ this._snap = options.snap ?? options.revealSnap ?? viewportConfig.revealSnap;
7045
+ this._padding = options.padding ?? options.revealPadding ?? viewportConfig.revealPadding;
7046
+ this._top = options.top ?? options.revealTop ?? viewportConfig.revealTop;
7047
+ this._max = options.max ?? options.revealMax ?? viewportConfig.revealMax;
7025
7048
  this._topObstructionSelector = viewportConfig.selector('fixedTopSelectors');
7026
7049
  this._bottomObstructionSelector = viewportConfig.selector('fixedBottomSelectors');
7027
7050
  }
@@ -7055,7 +7078,7 @@ up.RevealMotion = class RevealMotion {
7055
7078
  newScrollTop = 0;
7056
7079
  }
7057
7080
  if (newScrollTop !== originalScrollTop) {
7058
- this._viewport.scrollTo({ ...this._options, top: newScrollTop });
7081
+ this._viewport.scrollTo({ top: newScrollTop, behavior: this._behavior });
7059
7082
  }
7060
7083
  }
7061
7084
  _getViewportRect() {
@@ -7534,6 +7557,16 @@ up.event = (function () {
7534
7557
  up.emit(element, forkedEvent);
7535
7558
  }
7536
7559
  on('up:click', 'a[up-emit]', executeEmitAttr);
7560
+ let inputDevices = ['unknown'];
7561
+ function getInputDevice() {
7562
+ return u.last(inputDevices);
7563
+ }
7564
+ function observeInputDevice(newModality) {
7565
+ inputDevices.push(newModality);
7566
+ setTimeout(() => inputDevices.pop());
7567
+ }
7568
+ on('keydown keyup', { capture: true }, () => observeInputDevice('key'));
7569
+ on('pointerdown pointerup', { capture: true }, () => observeInputDevice('pointer'));
7537
7570
  on('up:framework:reset', reset);
7538
7571
  return {
7539
7572
  on,
@@ -7546,6 +7579,7 @@ up.event = (function () {
7546
7579
  isUnmodified,
7547
7580
  fork,
7548
7581
  keyModifiers,
7582
+ get inputDevice() { return getInputDevice(); }
7549
7583
  };
7550
7584
  })();
7551
7585
  up.on = up.event.on;
@@ -8208,7 +8242,7 @@ up.fragment = (function () {
8208
8242
  }
8209
8243
  const render = up.mockable((...args) => {
8210
8244
  let options = parseTargetAndOptions(args);
8211
- return new up.RenderJob(options);
8245
+ return new up.RenderJob(options).execute();
8212
8246
  });
8213
8247
  const navigate = up.mockable((...args) => {
8214
8248
  const options = parseTargetAndOptions(args);
@@ -8689,6 +8723,7 @@ up.viewport = (function () {
8689
8723
  revealPadding: 0,
8690
8724
  revealTop: false,
8691
8725
  revealMax() { return 0.5 * window.innerHeight; },
8726
+ autoFocusVisible({ element, inputDevice }) { return inputDevice === 'key' || up.form.isField(element); }
8692
8727
  }));
8693
8728
  const bodyShifter = new up.BodyShifter();
8694
8729
  up.compiler(config.selectorFn('anchoredRightSelectors'), function (element) {
@@ -8707,25 +8742,35 @@ up.viewport = (function () {
8707
8742
  motion.start();
8708
8743
  return up.migrate.formerlyAsync?.('up.reveal()') || true;
8709
8744
  }
8710
- function doFocus(element, options = {}) {
8711
- if (options.force) {
8712
- makeFocusable(element);
8745
+ function doFocus(element, { preventScroll, force, inputDevice, focusVisible } = {}) {
8746
+ if (force) {
8747
+ if (!element.hasAttribute('tabindex') && element.tabIndex === -1) {
8748
+ element.setAttribute('tabindex', '-1');
8749
+ }
8713
8750
  }
8714
- element.focus({ preventScroll: true });
8715
- if (!options.preventScroll) {
8751
+ inputDevice ??= up.event.inputDevice;
8752
+ focusVisible ??= 'auto';
8753
+ focusVisible = u.evalAutoOption(focusVisible, config.autoFocusVisible, { element, inputDevice });
8754
+ element.focus({
8755
+ preventScroll: true,
8756
+ focusVisible,
8757
+ });
8758
+ removeFocusClasses(element);
8759
+ element.classList.add(focusVisible ? 'up-focus-visible' : 'up-focus-hidden');
8760
+ if (!preventScroll) {
8716
8761
  return reveal(element);
8717
8762
  }
8718
8763
  }
8764
+ function removeFocusClasses(element) {
8765
+ element?.classList.remove('up-focus-hidden', 'up-focus-visible');
8766
+ }
8767
+ up.on('focusin', function ({ relatedTarget }) {
8768
+ removeFocusClasses(relatedTarget);
8769
+ });
8719
8770
  function tryFocus(element, options) {
8720
8771
  doFocus(element, options);
8721
8772
  return element === document.activeElement;
8722
8773
  }
8723
- function makeFocusable(element) {
8724
- if (!element.hasAttribute('tabindex') && element.tabIndex === -1) {
8725
- element.setAttribute('tabindex', '-1');
8726
- element.classList.add('up-focusable-content');
8727
- }
8728
- }
8729
8774
  function revealHash(hash = location.hash, options) {
8730
8775
  let match = firstHashTarget(hash, options);
8731
8776
  if (match) {
@@ -9998,8 +10043,11 @@ up.form = (function () {
9998
10043
  return config.selector('submitButtonSelectors');
9999
10044
  }
10000
10045
  const submit = up.mockable((form, options) => {
10001
- return up.render(submitOptions(form, options));
10046
+ return buildSubmitJob(form, options).execute();
10002
10047
  });
10048
+ function buildSubmitJob(form, options) {
10049
+ return new up.RenderJob(submitOptions(form, options));
10050
+ }
10003
10051
  function submitOptions(form, options, parserOptions) {
10004
10052
  form = getForm(form);
10005
10053
  options = u.options(options);
@@ -10016,6 +10064,9 @@ up.form = (function () {
10016
10064
  parser.include(up.link.followOptions);
10017
10065
  return options;
10018
10066
  }
10067
+ function getPreflightFragments(form) {
10068
+ return buildSubmitJob(form).getPreflightFragments();
10069
+ }
10019
10070
  function watchOptions(field, options, parserOptions = {}) {
10020
10071
  options = u.options(options);
10021
10072
  let parser = new up.OptionsParser(field, options, { ...parserOptions, closest: true, attrPrefix: 'up-watch-' });
@@ -10081,7 +10132,7 @@ up.form = (function () {
10081
10132
  return u.noop;
10082
10133
  let missingOption = (key) => { up.fail("Cannot process { disable: '%s' } option without { %s }", disable, key); };
10083
10134
  let getOrigin = () => origin || missingOption('origin');
10084
- let getOriginForm = () => getContainer(getOrigin());
10135
+ let getOriginForm = () => getScope(getOrigin());
10085
10136
  let containers;
10086
10137
  if (disable === true) {
10087
10138
  containers = [getOriginForm()];
@@ -10124,17 +10175,13 @@ up.form = (function () {
10124
10175
  button.focus();
10125
10176
  }
10126
10177
  });
10127
- function watch(container, ...args) {
10128
- const fields = findFields(container);
10129
- const unnamedFields = u.reject(fields, 'name');
10130
- if (unnamedFields.length) {
10131
- up.puts('up.watch()', 'Will not watch fields without a [name]: %o', unnamedFields);
10132
- }
10133
- const callback = u.extractCallback(args) || watchCallbackFromElement(container) || up.fail('No callback given for up.watch()');
10178
+ function watch(root, ...args) {
10179
+ root = up.element.get(root);
10180
+ const callback = u.extractCallback(args) || watchCallbackFromElement(root) || up.fail('No callback given for up.watch()');
10134
10181
  let options = u.extractOptions(args);
10135
- const watch = new up.FieldWatcher(fields, options, callback);
10136
- watch.start();
10137
- return () => watch.stop();
10182
+ const watcher = new up.FieldWatcher(root, options, callback);
10183
+ watcher.start();
10184
+ return () => watcher.stop();
10138
10185
  }
10139
10186
  function watchCallbackFromElement(element) {
10140
10187
  let rawCallback = element.getAttribute('up-watch');
@@ -10142,8 +10189,11 @@ up.form = (function () {
10142
10189
  return up.NonceableCallback.fromString(rawCallback).toFunction('value', 'name').bind(element);
10143
10190
  }
10144
10191
  }
10145
- function autosubmit(target, options) {
10146
- return watch(target, options, (_value, _name, renderOptions) => submit(target, renderOptions));
10192
+ function autosubmit(target, options = {}) {
10193
+ const form = getForm(target);
10194
+ options.abortable ??= [form, ...getPreflightFragments(form)];
10195
+ const onChange = (_value, _name, renderOptions) => submit(target, renderOptions);
10196
+ return watch(target, options, onChange);
10147
10197
  }
10148
10198
  function getGroupSelectors() {
10149
10199
  return up.migrate.migratedFormGroupSelectors?.() || config.groupSelectors;
@@ -10197,7 +10247,7 @@ up.form = (function () {
10197
10247
  }
10198
10248
  }
10199
10249
  else if (field.matches('input[type=radio]')) {
10200
- const form = getContainer(field);
10250
+ const form = getScope(field);
10201
10251
  const groupName = field.getAttribute('name');
10202
10252
  const checkedButton = form.querySelector(`input[type=radio]${e.attrSelector('name', groupName)}:checked`);
10203
10253
  if (checkedButton) {
@@ -10226,7 +10276,7 @@ up.form = (function () {
10226
10276
  }
10227
10277
  function switchTargets(switcher, options = {}) {
10228
10278
  const targetSelector = options.target || options.target || switcher.getAttribute('up-switch');
10229
- const form = getContainer(switcher);
10279
+ const form = getScope(switcher);
10230
10280
  targetSelector || up.fail("No switch target given for %o", switcher);
10231
10281
  const fieldValues = switcherValues(switcher);
10232
10282
  for (let target of up.fragment.all(form, targetSelector)) {
@@ -10253,7 +10303,7 @@ up.form = (function () {
10253
10303
  return u.parseTokens(str, { json: true });
10254
10304
  }
10255
10305
  function findSwitcherForTarget(target) {
10256
- const form = getContainer(target);
10306
+ const form = getScope(target);
10257
10307
  const switchers = form.querySelectorAll('[up-switch]');
10258
10308
  const switcher = u.find(switchers, function (switcher) {
10259
10309
  const targetSelector = switcher.getAttribute('up-switch');
@@ -10265,7 +10315,7 @@ up.form = (function () {
10265
10315
  const element = up.fragment.get(elementOrSelector, options);
10266
10316
  return element.form || element.closest('form');
10267
10317
  }
10268
- function getContainer(element, options) {
10318
+ function getScope(element, options) {
10269
10319
  return getForm(element, options) || up.layer.get(element).element;
10270
10320
  }
10271
10321
  function focusedField() {
@@ -10321,6 +10371,7 @@ up.form = (function () {
10321
10371
  groupSolution: findGroupSolution,
10322
10372
  groupSelectors: getGroupSelectors,
10323
10373
  get: getForm,
10374
+ getScope,
10324
10375
  };
10325
10376
  })();
10326
10377
  up.submit = up.form.submit;
@@ -1,6 +1,6 @@
1
1
  [hidden][hidden]{display:none !important}
2
2
  up-wrapper{display:inline-block}
3
- up-bounds{position:absolute}.up-focusable-content:focus,.up-focusable-content:focus-visible{outline:0}
3
+ up-bounds{position:absolute}.up-focus-hidden:focus-visible{outline:none !important}
4
4
  .up-request-loader{display:none}up-progress-bar{position:fixed;top:0;left:0;z-index:999999999;height:3px;background-color:#007bff}
5
5
  up-focus-trap{position:fixed;top:0;left:0;width:0;height:0}up-cover-viewport,up-drawer-viewport,up-modal-viewport,up-drawer-backdrop,up-modal-backdrop,up-cover,up-drawer,up-modal{top:0;left:0;bottom:0;right:0}up-drawer-box,up-modal-box{box-shadow:0 0 10px 1px rgba(0,0,0,.3)}up-popup{box-shadow:0 0 4px rgba(0,0,0,.3)}up-popup:focus,up-cover-box:focus,up-drawer-box:focus,up-modal-box:focus,up-cover:focus,up-drawer:focus,up-modal:focus,up-popup:focus-visible,up-cover-box:focus-visible,up-drawer-box:focus-visible,up-modal-box:focus-visible,up-cover:focus-visible,up-drawer:focus-visible,up-modal:focus-visible{outline:none}up-cover,up-drawer,up-modal{z-index:2000;position:fixed}up-drawer-backdrop,up-modal-backdrop{position:absolute;background:rgba(0,0,0,.4)}up-cover-viewport,up-drawer-viewport,up-modal-viewport{position:absolute;overflow-y:scroll;overflow-x:hidden;overscroll-behavior:contain;display:flex;align-items:flex-start;justify-content:center}up-popup,up-cover-box,up-drawer-box,up-modal-box{position:relative;box-sizing:border-box;max-width:100%;background-color:#fff;padding:20px;overflow-x:hidden}up-popup-content,up-cover-content,up-drawer-content,up-modal-content{display:block}up-popup{z-index:1000}up-popup-dismiss,up-cover-dismiss,up-drawer-dismiss,up-modal-dismiss{color:#888;position:absolute;top:10px;right:10px;font-size:1.7rem;line-height:.5}up-modal[nesting="0"] up-modal-viewport{padding:25px 15px}up-modal[nesting="1"] up-modal-viewport{padding:50px 30px}up-modal[nesting="2"] up-modal-viewport{padding:75px 45px}up-modal[nesting="3"] up-modal-viewport{padding:100px 60px}up-modal[nesting="4"] up-modal-viewport{padding:125px 75px}up-modal[size=small] up-modal-box{width:350px}up-modal[size=medium] up-modal-box{width:650px}up-modal[size=large] up-modal-box{width:1000px}up-modal[size=grow] up-modal-box{width:auto}up-modal[size=full] up-modal-box{width:100%}up-drawer-viewport{justify-content:flex-start}up-drawer[position=right] up-drawer-viewport{justify-content:flex-end}up-drawer-box{min-height:100vh}up-drawer[size=small] up-drawer-box{width:150px}up-drawer[size=medium] up-drawer-box{width:340px}up-drawer[size=large] up-drawer-box{width:600px}up-drawer[size=grow] up-drawer-box{width:auto}up-drawer[size=full] up-drawer-box{width:100%}up-cover-box{width:100%;min-height:100vh;padding:0}up-popup{padding:15px;text-align:left}up-popup[size=small]{width:180px}up-popup[size=medium]{width:300px}up-popup[size=large]{width:550px}up-popup[size=grow] up-popup{width:auto}up-popup[size=full] up-popup{width:100%}
6
6
  [up-href],[up-clickable]{cursor:pointer}