unpoly-rails 3.1.0 → 3.1.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.1.0'
8
+ version: '3.1.1'
9
9
  };
10
10
 
11
11
 
@@ -194,6 +194,9 @@ up.util = (function () {
194
194
  function isRegExp(object) {
195
195
  return object instanceof RegExp;
196
196
  }
197
+ function isError(object) {
198
+ return object instanceof Error;
199
+ }
197
200
  function isJQuery(object) {
198
201
  return up.browser.canJQuery() && object instanceof jQuery;
199
202
  }
@@ -389,8 +392,8 @@ up.util = (function () {
389
392
  function queueMicrotask(task) {
390
393
  return Promise.resolve().then(task);
391
394
  }
392
- function last(array) {
393
- return array[array.length - 1];
395
+ function last(value) {
396
+ return value[value.length - 1];
394
397
  }
395
398
  function contains(value, subValue) {
396
399
  return value.indexOf(subValue) >= 0;
@@ -615,14 +618,20 @@ up.util = (function () {
615
618
  });
616
619
  }
617
620
  }
618
- function stringifyArg(arg) {
621
+ function stringifyArg(arg, placeholder = '%o') {
619
622
  let string;
620
623
  const maxLength = 200;
621
- let closer = '';
624
+ if (placeholder === '%c') {
625
+ return '';
626
+ }
627
+ if (placeholder === '%s' && isGiven(arg)) {
628
+ arg = arg.toString();
629
+ }
622
630
  if (isString(arg)) {
623
- string = arg.replace(/[\n\r\t ]+/g, ' ');
624
- string = string.replace(/^[\n\r\t ]+/, '');
625
- string = string.replace(/[\n\r\t ]$/, '');
631
+ string = arg.trim().replace(/[\n\r\t ]+/g, ' ');
632
+ if (placeholder === '%o') {
633
+ string = JSON.stringify(string);
634
+ }
626
635
  }
627
636
  else if (isUndefined(arg)) {
628
637
  string = 'undefined';
@@ -632,24 +641,21 @@ up.util = (function () {
632
641
  }
633
642
  else if (isArray(arg)) {
634
643
  string = `[${map(arg, stringifyArg).join(', ')}]`;
635
- closer = ']';
636
644
  }
637
645
  else if (isJQuery(arg)) {
638
646
  string = `$(${map(arg, stringifyArg).join(', ')})`;
639
- closer = ')';
640
647
  }
641
648
  else if (isElement(arg)) {
642
649
  string = `<${arg.tagName.toLowerCase()}`;
643
- for (let attr of ['id', 'name', 'class']) {
650
+ for (let attr of ['id', 'up-id', 'name', 'class']) {
644
651
  let value = arg.getAttribute(attr);
645
652
  if (value) {
646
653
  string += ` ${attr}="${value}"`;
647
654
  }
648
655
  }
649
656
  string += ">";
650
- closer = '>';
651
657
  }
652
- else if (isRegExp(arg)) {
658
+ else if (isRegExp(arg) || isError(arg)) {
653
659
  string = arg.toString();
654
660
  }
655
661
  else {
@@ -666,14 +672,13 @@ up.util = (function () {
666
672
  }
667
673
  }
668
674
  if (string.length > maxLength) {
669
- string = `${string.substr(0, maxLength)} …`;
670
- string += closer;
675
+ string = `${string.substr(0, maxLength)}…${last(string)}`;
671
676
  }
672
677
  return string;
673
678
  }
674
- const SPRINTF_PLACEHOLDERS = /%[oOdisf]/g;
679
+ const SPRINTF_PLACEHOLDERS = /%[oOdisfc]/g;
675
680
  function sprintf(message, ...args) {
676
- return message.replace(SPRINTF_PLACEHOLDERS, () => stringifyArg(args.shift()));
681
+ return message.replace(SPRINTF_PLACEHOLDERS, (placeholder) => stringifyArg(args.shift(), placeholder));
677
682
  }
678
683
  function negate(fn) {
679
684
  return function (...args) {
@@ -4656,13 +4661,13 @@ up.Layer.OverlayWithViewport = (_a = class OverlayWithViewport extends up.Layer.
4656
4661
  var _a;
4657
4662
  const e = up.element;
4658
4663
  up.Layer.Root = (_a = class Root extends up.Layer {
4659
- get element() {
4660
- return e.root;
4661
- }
4662
4664
  constructor(options) {
4663
4665
  super(options);
4664
4666
  this.setupHandlers();
4665
4667
  }
4668
+ get element() {
4669
+ return e.root;
4670
+ }
4666
4671
  getFirstSwappableElement() {
4667
4672
  return document.body;
4668
4673
  }
@@ -5813,6 +5818,26 @@ up.RenderResult = class RenderResult extends up.Record {
5813
5818
  var _a;
5814
5819
  const u = up.util;
5815
5820
  up.Request = (_a = class Request extends up.Record {
5821
+ constructor(options) {
5822
+ super(options);
5823
+ this.params = new up.Params(this.params);
5824
+ if (this.wrapMethod == null) {
5825
+ this.wrapMethod = up.network.config.wrapMethod;
5826
+ }
5827
+ this.normalize();
5828
+ if ((this.target || this.layer || this.origin) && !options.basic) {
5829
+ const layerLookupOptions = { origin: this.origin };
5830
+ this.layer = up.layer.get(this.layer, layerLookupOptions);
5831
+ this.failLayer = up.layer.get(this.failLayer || this.layer, layerLookupOptions);
5832
+ this.context || (this.context = this.layer.context || {});
5833
+ this.failContext || (this.failContext = this.failLayer.context || {});
5834
+ this.mode || (this.mode = this.layer.mode);
5835
+ this.failMode || (this.failMode = this.failLayer.mode);
5836
+ }
5837
+ this.deferred = u.newDeferred();
5838
+ this.badResponseTime ?? (this.badResponseTime = u.evalOption(up.network.config.badResponseTime, this));
5839
+ this.addAutoHeaders();
5840
+ }
5816
5841
  keys() {
5817
5842
  return [
5818
5843
  'method',
@@ -5855,26 +5880,6 @@ up.Request = (_a = class Request extends up.Record {
5855
5880
  builtAt: new Date(),
5856
5881
  };
5857
5882
  }
5858
- constructor(options) {
5859
- super(options);
5860
- this.params = new up.Params(this.params);
5861
- if (this.wrapMethod == null) {
5862
- this.wrapMethod = up.network.config.wrapMethod;
5863
- }
5864
- this.normalize();
5865
- if ((this.target || this.layer || this.origin) && !options.basic) {
5866
- const layerLookupOptions = { origin: this.origin };
5867
- this.layer = up.layer.get(this.layer, layerLookupOptions);
5868
- this.failLayer = up.layer.get(this.failLayer || this.layer, layerLookupOptions);
5869
- this.context || (this.context = this.layer.context || {});
5870
- this.failContext || (this.failContext = this.failLayer.context || {});
5871
- this.mode || (this.mode = this.layer.mode);
5872
- this.failMode || (this.failMode = this.failLayer.mode);
5873
- }
5874
- this.deferred = u.newDeferred();
5875
- this.badResponseTime ?? (this.badResponseTime = u.evalOption(up.network.config.badResponseTime, this));
5876
- this.addAutoHeaders();
5877
- }
5878
5883
  get xhr() {
5879
5884
  return this._xhr ?? (this._xhr = new XMLHttpRequest());
5880
5885
  }
@@ -7322,6 +7327,7 @@ up.protocol = (function () {
7322
7327
  /***/ (() => {
7323
7328
 
7324
7329
  up.log = (function () {
7330
+ const u = up.util;
7325
7331
  const config = new up.LogConfig();
7326
7332
  function reset() {
7327
7333
  config.reset();
@@ -7339,13 +7345,11 @@ up.log = (function () {
7339
7345
  function printToStreamStyled(stream, trace, customStyles, message, ...args) {
7340
7346
  if (message) {
7341
7347
  if (config.format) {
7342
- args.unshift('color: #666666; padding: 1px 3px; border: 1px solid #bbbbbb; border-radius: 2px; font-size: 90%; display: inline-block;' + customStyles, '');
7343
- message = `%c${trace}%c ${message}`;
7348
+ console[stream](`%c${trace}%c ${message}`, 'color: #666666; padding: 1px 3px; border: 1px solid #bbbbbb; border-radius: 2px; font-size: 90%; display: inline-block;' + customStyles, '', ...args);
7344
7349
  }
7345
7350
  else {
7346
- message = `[${trace}] ${message}`;
7351
+ console[stream](`[${trace}] ${u.sprintf(message, ...args)}`);
7347
7352
  }
7348
- console[stream](message, ...args);
7349
7353
  }
7350
7354
  }
7351
7355
  function printUserEvent(event) {
@@ -9367,7 +9371,6 @@ up.link = (function () {
9367
9371
  parser.booleanOrString('transition');
9368
9372
  parser.string('easing');
9369
9373
  parser.number('duration');
9370
- up.migrate.parseFollowOptions?.(parser);
9371
9374
  if (!options.guardEvent) {
9372
9375
  options.guardEvent = up.event.build('up:link:follow', { log: 'Following link' });
9373
9376
  }
@@ -9515,7 +9518,8 @@ up.link = (function () {
9515
9518
  convertClicks,
9516
9519
  config,
9517
9520
  combineFollowableSelectors,
9518
- preloadSelector: fullPreloadSelector
9521
+ preloadSelector: fullPreloadSelector,
9522
+ followSelector: fullFollowSelector,
9519
9523
  };
9520
9524
  })();
9521
9525
  up.follow = up.link.follow;
@@ -9914,6 +9918,7 @@ up.form = (function () {
9914
9918
  disable: disableContainer,
9915
9919
  group: findGroup,
9916
9920
  groupSolution: findGroupSolution,
9921
+ groupSelectors: getGroupSelectors,
9917
9922
  get: getForm,
9918
9923
  };
9919
9924
  })();