@optionfactory/fml 9.0.0-rc11 → 9.0.0-rc12

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.
package/dist/fml.iife.js CHANGED
@@ -7641,15 +7641,22 @@ var fml = (function (exports) {
7641
7641
 
7642
7642
  const signed = (v, digits) => (v.startsWith('-') ? '-' : '') + digits(v);
7643
7643
 
7644
- const NUMERIC_FILTERS = {
7645
- numeric: (v) => signed(v, (t) => t.replace(/\D/g, '')),
7644
+ const NUMERIC_DIGITS = {
7645
+ numeric: (t) => t.replace(/\D/g, ''),
7646
7646
  //one separator, the first: the rest are a slip while typing, not a value
7647
- decimal: (v) =>
7648
- signed(v, (t) => {
7649
- const kept = t.replace(/[^\d.,]/g, '');
7650
- const at = kept.search(/[.,]/);
7651
- return at === -1 ? kept : kept.slice(0, at + 1) + kept.slice(at + 1).replace(/[.,]/g, '');
7652
- }),
7647
+ decimal: (t) => {
7648
+ const kept = t.replace(/[^\d.,]/g, '');
7649
+ const at = kept.search(/[.,]/);
7650
+ return at === -1 ? kept : kept.slice(0, at + 1) + kept.slice(at + 1).replace(/[.,]/g, '');
7651
+ },
7652
+ };
7653
+
7654
+ const numericFilter = (type, unsigned) => {
7655
+ const digits = NUMERIC_DIGITS[type];
7656
+ if (!digits) {
7657
+ return null;
7658
+ }
7659
+ return unsigned ? digits : (v) => signed(v, digits);
7653
7660
  };
7654
7661
 
7655
7662
  const warnedBoth = new WeakSet();
@@ -7671,7 +7678,7 @@ var fml = (function (exports) {
7671
7678
  const re = compiled('reject', reject);
7672
7679
  return re && ((v) => v.replace(re, ''));
7673
7680
  }
7674
- return NUMERIC_FILTERS[el._type()] ?? null;
7681
+ return numericFilter(el._type(), el.declared('unsigned'));
7675
7682
  };
7676
7683
 
7677
7684
  /** A labelled text input over any native type or textarea; the temporal inputs are its subclasses. */
@@ -7686,6 +7693,7 @@ var fml = (function (exports) {
7686
7693
  'reject',
7687
7694
  'uppercase:presence',
7688
7695
  'trim:presence',
7696
+ 'unsigned:presence',
7689
7697
  'autocomplete',
7690
7698
  ];
7691
7699
  static slots = true;
@@ -11065,27 +11073,41 @@ var fml = (function (exports) {
11065
11073
  * operator, differing only in what the server converts them to.
11066
11074
  */
11067
11075
  class InFilter extends Select {
11068
- async upgrade() {
11069
- //the snapshot is taken inside super.upgrade(), so an attribute this
11070
- //element does not let an author turn off has to be written before it
11071
- this.toggleAttribute('multiple', true);
11072
- await super.upgrade();
11076
+ static attributes = ['operator'];
11077
+ /** the selection as the array the wire takes, whether one key was chosen or many */
11078
+ #keys() {
11079
+ const chosen = super.value;
11080
+ if (this.multiple) {
11081
+ return chosen;
11082
+ }
11083
+ return chosen === null || chosen === undefined ? [] : [chosen];
11073
11084
  }
11074
11085
  get value() {
11075
- const keys = super.value;
11086
+ const keys = this.#keys();
11076
11087
  //an empty set is no filter: the table drops a falsy value, where an
11077
11088
  //empty array would travel and match nothing
11078
- return keys.length === 0 ? null : keys;
11089
+ if (keys.length === 0) {
11090
+ return null;
11091
+ }
11092
+ const operator = this.declared('operator');
11093
+ return operator ? [operator, ...keys] : keys;
11079
11094
  }
11080
11095
  set value(v) {
11081
- super.value = v ?? [];
11096
+ const operator = this.declared('operator');
11097
+ let keys = v === null || v === undefined ? [] : Array.isArray(v) ? v : [v];
11098
+ //what the getter answers has to be assignable back, and it carries the
11099
+ //operator in front of the keys
11100
+ if (operator && keys[0] === operator) {
11101
+ keys = keys.slice(1);
11102
+ }
11103
+ super.value = this.multiple ? keys : (keys[0] ?? null);
11082
11104
  }
11083
11105
  /** @returns {FilterCriterion|null} */
11084
11106
  get criterion() {
11085
11107
  return asCriterion(
11086
11108
  labelTextOf(this),
11087
- null,
11088
- (super.entry ?? []).map((e) => e.label),
11109
+ this.declared('operator'),
11110
+ [super.entry].flat().filter((e) => e).map((e) => e.label),
11089
11111
  );
11090
11112
  }
11091
11113
  }