@optionfactory/ful 4.0.0 → 4.0.2

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/ful.mjs CHANGED
@@ -1572,19 +1572,26 @@ class InputLocalDate extends Input {
1572
1572
  _type() {
1573
1573
  return 'date';
1574
1574
  }
1575
+ render(conf){
1576
+ const {observed} = conf;
1577
+ super.render(conf);
1578
+ this.min = observed.min;
1579
+ this.max = observed.max;
1580
+ this.step = observed.step;
1581
+ }
1575
1582
  get min() {
1576
1583
  const v = this._input.min;
1577
1584
  return v === '' ? null : v;
1578
1585
  }
1579
1586
  set min(v) {
1580
- this._input.min = v;
1587
+ this._input.min = InputLocalDate.#fromIsoOrOffset(v);
1581
1588
  }
1582
1589
  get max() {
1583
1590
  const v = this._input.max;
1584
1591
  return v === '' ? null : v;
1585
1592
  }
1586
1593
  set max(v) {
1587
- this._input.max = v;
1594
+ this._input.max = InputLocalDate.#fromIsoOrOffset(v);
1588
1595
  }
1589
1596
  get step() {
1590
1597
  const v = this._input.step;
@@ -1593,7 +1600,34 @@ class InputLocalDate extends Input {
1593
1600
  set step(v) {
1594
1601
  this._input.step = (v ?? '');
1595
1602
  }
1596
-
1603
+ static #fromIsoOrOffset(v) {
1604
+ if (!v) {
1605
+ return '';
1606
+ }
1607
+ if (v === 'now') {
1608
+ return new Date().toISOString().split("T")[0];
1609
+ }
1610
+ const re = /^([+-])(\d+)([dmy])$/;
1611
+ const match = re.exec(v);
1612
+ if (!match) {
1613
+ return v;
1614
+ }
1615
+ const sign = match[1] === "-" ? -1 : 1;
1616
+ const offset = +match[2];
1617
+ const r = new Date();
1618
+ switch (match[3]) {
1619
+ case 'd':
1620
+ r.setDate(r.getDate() + offset * sign);
1621
+ break;
1622
+ case 'm':
1623
+ r.setMonth(r.getMonth() + offset * sign);
1624
+ break;
1625
+ case 'y':
1626
+ r.setFullYear(r.getFullYear() + offset * sign);
1627
+ break;
1628
+ }
1629
+ return r.toISOString().split("T")[0];
1630
+ }
1597
1631
  }
1598
1632
 
1599
1633
  class InputLocalTime extends InputLocalDate {
@@ -1608,6 +1642,13 @@ class InputInstant extends Input {
1608
1642
  _type() {
1609
1643
  return 'datetime-local';
1610
1644
  }
1645
+ render(conf){
1646
+ const {observed} = conf;
1647
+ super.render(conf);
1648
+ this.min = observed.min;
1649
+ this.max = observed.min;
1650
+ this.step = observed.min;
1651
+ }
1611
1652
  get value() {
1612
1653
  const v = this._input.value;
1613
1654
  return v === '' ? null : new Date(v).toISOString();
@@ -2186,7 +2227,8 @@ class RadioGroup extends ParsedElement {
2186
2227
  }
2187
2228
  set readonly(v) {
2188
2229
  this.#fieldset.inert = v;
2189
- }
2230
+ }
2231
+ //@ts-ignore
2190
2232
  get disabled(){
2191
2233
  return this.#fieldset.hasAttribute('disabled');
2192
2234
  }
@@ -2274,7 +2316,8 @@ class Checkbox extends ParsedElement {
2274
2316
  }
2275
2317
  set readonly(v) {
2276
2318
  this.#container.inert = v;
2277
- }
2319
+ }
2320
+ //@ts-ignore
2278
2321
  get disabled() {
2279
2322
  return this.#input.hasAttribute('disabled');
2280
2323
  }