@optionfactory/ful 3.0.0 → 3.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.iife.js +24 -19
- package/dist/ful.iife.js.map +1 -1
- package/dist/ful.iife.min.js +1 -1
- package/dist/ful.iife.min.js.map +1 -1
- package/dist/ful.min.mjs +1 -1
- package/dist/ful.min.mjs.map +1 -1
- package/dist/ful.mjs +24 -19
- package/dist/ful.mjs.map +1 -1
- package/package.json +2 -2
package/dist/ful.mjs
CHANGED
|
@@ -1436,24 +1436,29 @@ class Input extends ParsedElement {
|
|
|
1436
1436
|
<ful-field-error></ful-field-error>
|
|
1437
1437
|
`;
|
|
1438
1438
|
static formAssociated = true;
|
|
1439
|
-
|
|
1440
|
-
|
|
1439
|
+
_input;
|
|
1440
|
+
_fieldError;
|
|
1441
1441
|
constructor() {
|
|
1442
1442
|
super();
|
|
1443
1443
|
this.internals = this.attachInternals();
|
|
1444
1444
|
this.internals.role = 'presentation';
|
|
1445
1445
|
}
|
|
1446
|
+
_type(){
|
|
1447
|
+
return this.getAttribute("type") ?? 'text'; }
|
|
1448
|
+
_fragment(type, slots){
|
|
1449
|
+
return this.template().withOverlay({ type, slots }).render();
|
|
1450
|
+
}
|
|
1446
1451
|
render({ slots, observed, disabled }) {
|
|
1447
|
-
const type = this.
|
|
1448
|
-
const fragment = this.
|
|
1449
|
-
this
|
|
1452
|
+
const type = this._type();
|
|
1453
|
+
const fragment = this._fragment(type, slots );
|
|
1454
|
+
this._input = fragment.querySelector("input,textarea");
|
|
1450
1455
|
|
|
1451
|
-
Attributes.forward('input-', this, this
|
|
1456
|
+
Attributes.forward('input-', this, this._input);
|
|
1452
1457
|
this.disabled = disabled;
|
|
1453
1458
|
this.readonly = observed.readonly;
|
|
1454
1459
|
this.value = observed.value;
|
|
1455
1460
|
|
|
1456
|
-
this
|
|
1461
|
+
this._input.addEventListener('change', (evt) => {
|
|
1457
1462
|
evt.stopPropagation();
|
|
1458
1463
|
this.dispatchEvent(new CustomEvent('change', {
|
|
1459
1464
|
bubbles: true,
|
|
@@ -1465,40 +1470,40 @@ class Input extends ParsedElement {
|
|
|
1465
1470
|
});
|
|
1466
1471
|
const label = fragment.querySelector('label');
|
|
1467
1472
|
label.addEventListener('click', () => this.focus());
|
|
1468
|
-
this
|
|
1469
|
-
this
|
|
1470
|
-
this
|
|
1473
|
+
this._fieldError = fragment.querySelector('ful-field-error');
|
|
1474
|
+
this._input.ariaDescribedByElements = [this._fieldError];
|
|
1475
|
+
this._input.ariaLabelledByElements = [label];
|
|
1471
1476
|
this.replaceChildren(fragment);
|
|
1472
1477
|
}
|
|
1473
1478
|
get value() {
|
|
1474
|
-
return this
|
|
1479
|
+
return this._input.value === '' ? null : this._input.value;
|
|
1475
1480
|
}
|
|
1476
1481
|
set value(value) {
|
|
1477
|
-
this
|
|
1482
|
+
this._input.value = value === '' ? null : value;
|
|
1478
1483
|
}
|
|
1479
1484
|
get readonly(){
|
|
1480
|
-
return this
|
|
1485
|
+
return this._input.readOnly;
|
|
1481
1486
|
}
|
|
1482
1487
|
set readonly(v) {
|
|
1483
|
-
this
|
|
1488
|
+
this._input.readOnly = v;
|
|
1484
1489
|
}
|
|
1485
1490
|
get disabled(){
|
|
1486
|
-
return this
|
|
1491
|
+
return this._input.hasAttribute('disabled');
|
|
1487
1492
|
}
|
|
1488
1493
|
set disabled(d){
|
|
1489
|
-
Attributes.toggle(this
|
|
1494
|
+
Attributes.toggle(this._input, 'disabled', d);
|
|
1490
1495
|
}
|
|
1491
1496
|
focus(options) {
|
|
1492
|
-
this
|
|
1497
|
+
this._input.focus(options);
|
|
1493
1498
|
}
|
|
1494
1499
|
setCustomValidity(error) {
|
|
1495
1500
|
if (!error) {
|
|
1496
1501
|
this.internals.setValidity({});
|
|
1497
|
-
this
|
|
1502
|
+
this._fieldError.innerText = "";
|
|
1498
1503
|
return;
|
|
1499
1504
|
}
|
|
1500
1505
|
this.internals.setValidity({ customError: true }, " ");
|
|
1501
|
-
this
|
|
1506
|
+
this._fieldError.innerText = error;
|
|
1502
1507
|
}
|
|
1503
1508
|
formResetCallback(){
|
|
1504
1509
|
this.value = this.getAttribute("value");
|