lexgui 8.2.2 → 8.2.3
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/build/components/BaseComponent.d.ts +75 -73
- package/build/components/Form.d.ts +14 -8
- package/build/components/TextInput.d.ts +13 -11
- package/build/core/Namespace.js +1 -1
- package/build/core/Namespace.js.map +1 -1
- package/build/extensions/AssetView.d.ts +137 -137
- package/build/extensions/AssetView.js +1 -1
- package/build/extensions/AssetView.js.map +1 -1
- package/build/extensions/Audio.js +163 -163
- package/build/extensions/Audio.js.map +1 -1
- package/build/extensions/DocMaker.d.ts +28 -27
- package/build/extensions/DocMaker.js +354 -331
- package/build/extensions/DocMaker.js.map +1 -1
- package/build/lexgui.all.js +204 -115
- package/build/lexgui.all.js.map +1 -1
- package/build/lexgui.all.min.js +1 -1
- package/build/lexgui.all.module.js +204 -115
- package/build/lexgui.all.module.js.map +1 -1
- package/build/lexgui.all.module.min.js +1 -1
- package/build/lexgui.css +55 -44
- package/build/lexgui.js +152 -86
- package/build/lexgui.js.map +1 -1
- package/build/lexgui.min.css +2 -2
- package/build/lexgui.min.js +1 -1
- package/build/lexgui.module.js +152 -86
- package/build/lexgui.module.js.map +1 -1
- package/build/lexgui.module.min.js +1 -1
- package/changelog.md +19 -1
- package/demo.js +2 -2
- package/examples/all-components.html +15 -1
- package/examples/editor.html +8 -6
- package/package.json +1 -1
package/build/lexgui.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
exports.LX = g.LX;
|
|
17
17
|
if (!exports.LX) {
|
|
18
18
|
exports.LX = {
|
|
19
|
-
version: '8.2.
|
|
19
|
+
version: '8.2.3',
|
|
20
20
|
ready: false,
|
|
21
21
|
extensions: [], // Store extensions used
|
|
22
22
|
extraCommandbarEntries: [], // User specific entries for command bar
|
|
@@ -453,6 +453,7 @@
|
|
|
453
453
|
onGetValue;
|
|
454
454
|
onAllowPaste;
|
|
455
455
|
onResize;
|
|
456
|
+
onSetDisabled;
|
|
456
457
|
_initialValue;
|
|
457
458
|
static NO_CONTEXT_TYPES = [
|
|
458
459
|
exports.ComponentType.BUTTON,
|
|
@@ -521,6 +522,7 @@
|
|
|
521
522
|
}
|
|
522
523
|
this.root = root;
|
|
523
524
|
this.root.jsInstance = this;
|
|
525
|
+
this.disabled = options.disabled ?? false;
|
|
524
526
|
this.options = options;
|
|
525
527
|
}
|
|
526
528
|
static _dispatchEvent(element, type, data, bubbles, cancelable) {
|
|
@@ -681,6 +683,12 @@
|
|
|
681
683
|
}
|
|
682
684
|
console.error(`Unknown Component type: ${this.type}`);
|
|
683
685
|
}
|
|
686
|
+
setDisabled(disabled) {
|
|
687
|
+
this.disabled = disabled;
|
|
688
|
+
if (this.onSetDisabled) {
|
|
689
|
+
this.onSetDisabled(disabled);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
684
692
|
refresh(value) {
|
|
685
693
|
}
|
|
686
694
|
}
|
|
@@ -752,6 +760,7 @@
|
|
|
752
760
|
var wValue = exports.LX.makeElement('button', exports.LX.mergeClass(['lexbutton', 'inline-flex', 'items-center', 'justify-center', 'whitespace-nowrap', 'transition-all', 'disabled:pointer-events-none',
|
|
753
761
|
'disabled:opacity-50', '[&_svg]:pointer-events-none', 'shrink-0', '[&_svg]:shrink-0', 'outline-none', 'select-none', 'cursor-pointer',
|
|
754
762
|
'font-medium', 'text-sm', 'border-1', 'h-9', 'px-2', 'overflow-hidden', 'bg-clip-padding'].join(' '), options.buttonClass ?? 'outline'));
|
|
763
|
+
wValue.disabled = this.disabled;
|
|
755
764
|
wValue.title = options.tooltip ? '' : (options.title ?? '');
|
|
756
765
|
this.root.appendChild(wValue);
|
|
757
766
|
if (options.selected) {
|
|
@@ -810,10 +819,6 @@
|
|
|
810
819
|
};
|
|
811
820
|
});
|
|
812
821
|
}
|
|
813
|
-
if (options.disabled) {
|
|
814
|
-
this.disabled = true;
|
|
815
|
-
wValue.setAttribute('disabled', true);
|
|
816
|
-
}
|
|
817
822
|
let trigger = wValue;
|
|
818
823
|
if (options.swap) {
|
|
819
824
|
wValue.classList.add('swap');
|
|
@@ -1473,6 +1478,7 @@
|
|
|
1473
1478
|
vecinput.max = options.max ?? 1e24;
|
|
1474
1479
|
vecinput.step = options.step ?? 'any';
|
|
1475
1480
|
vecinput.type = 'number';
|
|
1481
|
+
vecinput.disabled = this.disabled;
|
|
1476
1482
|
if (value.constructor == Number) {
|
|
1477
1483
|
value = exports.LX.clamp(value, +vecinput.min, +vecinput.max);
|
|
1478
1484
|
value = exports.LX.round(value, options.precision);
|
|
@@ -1485,9 +1491,6 @@
|
|
|
1485
1491
|
let unitBox = exports.LX.makeContainer(['auto', 'auto'], 'px-2 bg-card content-center break-keep', options.units, valueBox);
|
|
1486
1492
|
vecinput.unitBox = unitBox;
|
|
1487
1493
|
}
|
|
1488
|
-
if (options.disabled) {
|
|
1489
|
-
this.disabled = vecinput.disabled = true;
|
|
1490
|
-
}
|
|
1491
1494
|
// Add slider below
|
|
1492
1495
|
if (!options.skipSlider && options.min !== undefined && options.max !== undefined) {
|
|
1493
1496
|
let sliderBox = exports.LX.makeContainer(['100%', 'auto'], 'z-1 input-box', '', box);
|
|
@@ -1602,6 +1605,7 @@
|
|
|
1602
1605
|
*/
|
|
1603
1606
|
class TextInput extends BaseComponent {
|
|
1604
1607
|
valid;
|
|
1608
|
+
input;
|
|
1605
1609
|
_triggerEvent;
|
|
1606
1610
|
_lastValueTriggered;
|
|
1607
1611
|
constructor(name, value, callback, options = {}) {
|
|
@@ -1640,13 +1644,12 @@
|
|
|
1640
1644
|
container.style.display = 'flex';
|
|
1641
1645
|
container.style.position = 'relative';
|
|
1642
1646
|
this.root.appendChild(container);
|
|
1643
|
-
|
|
1647
|
+
// override disabled (default is options.disable)
|
|
1648
|
+
this.disabled = (this.disabled || options.warning) ?? (options.url ? true : false);
|
|
1644
1649
|
let wValue = null;
|
|
1645
1650
|
if (!this.disabled) {
|
|
1646
1651
|
wValue = exports.LX.makeElement('input', exports.LX.mergeClass('lextext text-sm', options.inputClass));
|
|
1647
1652
|
wValue.type = options.type || '';
|
|
1648
|
-
wValue.value = value || '';
|
|
1649
|
-
wValue.style.textAlign = options.float ?? '';
|
|
1650
1653
|
wValue.setAttribute('placeholder', options.placeholder ?? '');
|
|
1651
1654
|
if (options.required) {
|
|
1652
1655
|
wValue.setAttribute('required', options.required);
|
|
@@ -1693,17 +1696,46 @@
|
|
|
1693
1696
|
else {
|
|
1694
1697
|
wValue = document.createElement('input');
|
|
1695
1698
|
wValue.disabled = true;
|
|
1696
|
-
wValue.value = value;
|
|
1697
|
-
wValue.style.textAlign = options.float ?? '';
|
|
1698
1699
|
wValue.className = exports.LX.mergeClass('lextext ellipsis-overflow', options.inputClass);
|
|
1699
1700
|
}
|
|
1700
1701
|
if (options.fit) {
|
|
1701
1702
|
wValue.classList.add('field-sizing-content');
|
|
1702
1703
|
}
|
|
1704
|
+
if (wValue instanceof HTMLInputElement) {
|
|
1705
|
+
wValue.name = options.name;
|
|
1706
|
+
wValue.value = value ?? '';
|
|
1707
|
+
if (options.autocomplete) {
|
|
1708
|
+
wValue.autocomplete = options.autocomplete;
|
|
1709
|
+
}
|
|
1710
|
+
else if (wValue.type === 'password') {
|
|
1711
|
+
// allow password managers by default
|
|
1712
|
+
wValue.autocomplete = 'current-password';
|
|
1713
|
+
}
|
|
1714
|
+
else if (options.name === 'username' || options.name === 'email') {
|
|
1715
|
+
wValue.autocomplete = options.name;
|
|
1716
|
+
}
|
|
1717
|
+
else {
|
|
1718
|
+
// neutral default, don't break browser heuristics
|
|
1719
|
+
wValue.autocomplete = 'on';
|
|
1720
|
+
}
|
|
1721
|
+
wValue.style.textAlign = options.float ?? '';
|
|
1722
|
+
wValue.addEventListener('transitionstart', (e) => {
|
|
1723
|
+
if (e.propertyName === 'background-color' &&
|
|
1724
|
+
wValue.matches(':-webkit-autofill')) {
|
|
1725
|
+
this.syncFromDOM();
|
|
1726
|
+
}
|
|
1727
|
+
});
|
|
1728
|
+
}
|
|
1703
1729
|
Object.assign(wValue.style, options.style ?? {});
|
|
1704
1730
|
container.appendChild(wValue);
|
|
1731
|
+
this.input = wValue;
|
|
1705
1732
|
exports.LX.doAsync(this.onResize.bind(this));
|
|
1706
1733
|
}
|
|
1734
|
+
syncFromDOM(skipCallback = true) {
|
|
1735
|
+
if (this.input instanceof HTMLInputElement) {
|
|
1736
|
+
this.set(this.input.value, skipCallback);
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1707
1739
|
}
|
|
1708
1740
|
exports.LX.TextInput = TextInput;
|
|
1709
1741
|
|
|
@@ -1847,7 +1879,7 @@
|
|
|
1847
1879
|
if (filter) {
|
|
1848
1880
|
filter.root.querySelector('input').focus();
|
|
1849
1881
|
}
|
|
1850
|
-
}, { buttonClass: 'outline [&_a]:ml-auto', skipInlineCount: true, disabled:
|
|
1882
|
+
}, { buttonClass: 'outline [&_a]:ml-auto', skipInlineCount: true, disabled: this.disabled });
|
|
1851
1883
|
selectedOption.root.style.width = '100%';
|
|
1852
1884
|
selectedOption.root.querySelector('button').appendChild(exports.LX.makeIcon('Down', { svgClass: 'sm' }));
|
|
1853
1885
|
container.appendChild(selectedOption.root);
|
|
@@ -2071,36 +2103,40 @@
|
|
|
2071
2103
|
component = new TextInput(i + '', value, function (value) {
|
|
2072
2104
|
values[i] = value;
|
|
2073
2105
|
callback(values);
|
|
2074
|
-
}, { nameWidth: '12px', className: 'p-0', skipReset: true });
|
|
2106
|
+
}, { nameWidth: '12px', className: 'p-0', disabled: this.disabled, skipReset: true });
|
|
2075
2107
|
break;
|
|
2076
2108
|
case Number:
|
|
2077
2109
|
component = new NumberInput(i + '', value, function (value) {
|
|
2078
2110
|
values[i] = value;
|
|
2079
2111
|
callback(values);
|
|
2080
|
-
}, { nameWidth: '12px', className: 'p-0', skipReset: true });
|
|
2112
|
+
}, { nameWidth: '12px', className: 'p-0', disabled: this.disabled, skipReset: true });
|
|
2081
2113
|
break;
|
|
2082
2114
|
case 'select':
|
|
2083
2115
|
component = new Select(i + '', options.innerValues, value, function (value) {
|
|
2084
2116
|
values[i] = value;
|
|
2085
2117
|
callback(values);
|
|
2086
|
-
}, { nameWidth: '12px', className: 'p-0', skipReset: true });
|
|
2118
|
+
}, { nameWidth: '12px', className: 'p-0', disabled: this.disabled, skipReset: true });
|
|
2087
2119
|
break;
|
|
2088
2120
|
}
|
|
2089
2121
|
console.assert(component, `Value of type ${baseclass} cannot be modified in ArrayInput`);
|
|
2090
2122
|
arrayItems.appendChild(component.root);
|
|
2091
|
-
|
|
2092
|
-
|
|
2123
|
+
if (!this.disabled) {
|
|
2124
|
+
const removeComponent = new Button(null, '', (v, event) => {
|
|
2125
|
+
values.splice(values.indexOf(value), 1);
|
|
2126
|
+
this._updateItems();
|
|
2127
|
+
this._trigger(new IEvent(name, values, event), callback);
|
|
2128
|
+
}, { buttonClass: 'ghost sm p-0', title: 'Remove item', icon: 'Trash2' });
|
|
2129
|
+
component.root.appendChild(removeComponent.root);
|
|
2130
|
+
}
|
|
2131
|
+
}
|
|
2132
|
+
if (!this.disabled) {
|
|
2133
|
+
const addButton = new Button(null, exports.LX.makeIcon('Plus', { svgClass: 'sm' }).innerHTML + 'Add item', (v, event) => {
|
|
2134
|
+
values.push(options.innerValues ? options.innerValues[0] : '');
|
|
2093
2135
|
this._updateItems();
|
|
2094
2136
|
this._trigger(new IEvent(name, values, event), callback);
|
|
2095
|
-
}, { buttonClass: 'ghost
|
|
2096
|
-
|
|
2137
|
+
}, { buttonClass: 'ghost' });
|
|
2138
|
+
arrayItems.appendChild(addButton.root);
|
|
2097
2139
|
}
|
|
2098
|
-
const addButton = new Button(null, exports.LX.makeIcon('Plus', { svgClass: 'sm' }).innerHTML + 'Add item', (v, event) => {
|
|
2099
|
-
values.push(options.innerValues ? options.innerValues[0] : '');
|
|
2100
|
-
this._updateItems();
|
|
2101
|
-
this._trigger(new IEvent(name, values, event), callback);
|
|
2102
|
-
}, { buttonClass: 'ghost' });
|
|
2103
|
-
arrayItems.appendChild(addButton.root);
|
|
2104
2140
|
};
|
|
2105
2141
|
this._updateItems();
|
|
2106
2142
|
}
|
|
@@ -2195,7 +2231,7 @@
|
|
|
2195
2231
|
let checkbox = exports.LX.makeElement('input', exports.LX.mergeClass('lexcheckbox rounded-xl', options.className ?? 'primary'));
|
|
2196
2232
|
checkbox.type = 'checkbox';
|
|
2197
2233
|
checkbox.checked = value;
|
|
2198
|
-
checkbox.disabled =
|
|
2234
|
+
checkbox.disabled = this.disabled;
|
|
2199
2235
|
container.appendChild(checkbox);
|
|
2200
2236
|
exports.LX.makeElement('span', 'text-sm', options.label ?? 'On', container);
|
|
2201
2237
|
checkbox.addEventListener('change', (e) => {
|
|
@@ -2830,7 +2866,7 @@
|
|
|
2830
2866
|
let sampleContainer = exports.LX.makeContainer(['18px', '18px'], 'flex flex-row rounded overflow-hidden', '', container);
|
|
2831
2867
|
sampleContainer.tabIndex = '1';
|
|
2832
2868
|
sampleContainer.addEventListener('click', (e) => {
|
|
2833
|
-
if (
|
|
2869
|
+
if (this.disabled) {
|
|
2834
2870
|
return;
|
|
2835
2871
|
}
|
|
2836
2872
|
this._popover = new Popover(sampleContainer, [this.picker]);
|
|
@@ -2854,7 +2890,7 @@
|
|
|
2854
2890
|
this.set(v);
|
|
2855
2891
|
delete this._skipTextUpdate;
|
|
2856
2892
|
this.picker.fromHexColor(v);
|
|
2857
|
-
}, { width: 'calc( 100% - 24px )', disabled:
|
|
2893
|
+
}, { width: 'calc( 100% - 24px )', disabled: this.disabled });
|
|
2858
2894
|
textComponent.root.style.marginLeft = '6px';
|
|
2859
2895
|
container.appendChild(textComponent.root);
|
|
2860
2896
|
exports.LX.doAsync(this.onResize.bind(this));
|
|
@@ -2991,15 +3027,13 @@
|
|
|
2991
3027
|
const input = exports.LX.makeElement('input', 'lexcounter w-12 bg-card px-2 text-foreground', '', container);
|
|
2992
3028
|
input.type = 'number';
|
|
2993
3029
|
input.value = value;
|
|
2994
|
-
|
|
2995
|
-
input.setAttribute('disabled', 'true');
|
|
2996
|
-
}
|
|
3030
|
+
input.disabled = this.disabled;
|
|
2997
3031
|
const substrButton = new Button(null, '', (value, e) => {
|
|
2998
3032
|
let mult = step ?? 1;
|
|
2999
3033
|
if (e.shiftKey)
|
|
3000
3034
|
mult *= 10;
|
|
3001
3035
|
this.set(this.count - mult, false, e);
|
|
3002
|
-
}, { disabled:
|
|
3036
|
+
}, { disabled: this.disabled, className: `p-0 ${this.disabled ? '' : 'hover:bg-secondary'} border-l-color border-r-color`,
|
|
3003
3037
|
buttonClass: 'px-0 bg-none h-7', icon: 'Minus' });
|
|
3004
3038
|
container.appendChild(substrButton.root);
|
|
3005
3039
|
const addButton = new Button(null, '', (value, e) => {
|
|
@@ -3007,7 +3041,7 @@
|
|
|
3007
3041
|
if (e.shiftKey)
|
|
3008
3042
|
mult *= 10;
|
|
3009
3043
|
this.set(this.count + mult, false, e);
|
|
3010
|
-
}, { disabled:
|
|
3044
|
+
}, { disabled: this.disabled, className: `p-0 ${this.disabled ? '' : 'hover:bg-secondary'} rounded-r-lg`,
|
|
3011
3045
|
buttonClass: 'px-0 bg-none h-7', icon: 'Plus' });
|
|
3012
3046
|
container.appendChild(addButton.root);
|
|
3013
3047
|
}
|
|
@@ -3756,7 +3790,7 @@
|
|
|
3756
3790
|
const calendarIcon = exports.LX.makeIcon('Calendar');
|
|
3757
3791
|
const calendarButton = new Button(null, d0, () => {
|
|
3758
3792
|
this._popover = new Popover(calendarButton.root, [this.calendar]);
|
|
3759
|
-
}, { buttonClass: `outline flex flex-row px-3 ${emptyDate ? '' : 'text-muted-foreground'} justify-between` });
|
|
3793
|
+
}, { disabled: this.disabled, buttonClass: `outline flex flex-row px-3 ${emptyDate ? '' : 'text-muted-foreground'} justify-between` });
|
|
3760
3794
|
calendarButton.root.querySelector('button').appendChild(calendarIcon);
|
|
3761
3795
|
calendarButton.root.style.width = '100%';
|
|
3762
3796
|
container.appendChild(calendarButton.root);
|
|
@@ -3767,7 +3801,7 @@
|
|
|
3767
3801
|
const calendarIcon = exports.LX.makeIcon('Calendar');
|
|
3768
3802
|
const calendarButton = new Button(null, d1, () => {
|
|
3769
3803
|
this._popover = new Popover(calendarButton.root, [this.calendar]);
|
|
3770
|
-
}, { buttonClass: `outline flex flex-row px-3 ${emptyDate ? '' : 'text-muted-foreground'} justify-between` });
|
|
3804
|
+
}, { disabled: this.disabled, buttonClass: `outline flex flex-row px-3 ${emptyDate ? '' : 'text-muted-foreground'} justify-between` });
|
|
3771
3805
|
calendarButton.root.querySelector('button').appendChild(calendarIcon);
|
|
3772
3806
|
calendarButton.root.style.width = '100%';
|
|
3773
3807
|
container.appendChild(calendarButton.root);
|
|
@@ -4138,7 +4172,7 @@
|
|
|
4138
4172
|
let input = document.createElement('input');
|
|
4139
4173
|
input.className = 'lexfileinput';
|
|
4140
4174
|
input.type = 'file';
|
|
4141
|
-
input.disabled =
|
|
4175
|
+
input.disabled = this.disabled;
|
|
4142
4176
|
this.root.appendChild(input);
|
|
4143
4177
|
if (options.placeholder) {
|
|
4144
4178
|
input.placeholder = options.placeholder;
|
|
@@ -4188,7 +4222,7 @@
|
|
|
4188
4222
|
root.remove();
|
|
4189
4223
|
settingsDialog = null;
|
|
4190
4224
|
} });
|
|
4191
|
-
}, { skipInlineCount: true, title: 'Settings', disabled:
|
|
4225
|
+
}, { skipInlineCount: true, title: 'Settings', disabled: this.disabled, icon: 'Settings' });
|
|
4192
4226
|
this.root.appendChild(settingButton.root);
|
|
4193
4227
|
}
|
|
4194
4228
|
exports.LX.doAsync(this.onResize.bind(this));
|
|
@@ -4202,6 +4236,9 @@
|
|
|
4202
4236
|
* @description Form Component
|
|
4203
4237
|
*/
|
|
4204
4238
|
class Form extends BaseComponent {
|
|
4239
|
+
data;
|
|
4240
|
+
formData = {};
|
|
4241
|
+
primaryButton;
|
|
4205
4242
|
constructor(name, data, callback, options = {}) {
|
|
4206
4243
|
if (data.constructor != Object) {
|
|
4207
4244
|
console.error('Form data must be an Object');
|
|
@@ -4211,10 +4248,10 @@
|
|
|
4211
4248
|
options.hideName = true;
|
|
4212
4249
|
super(exports.ComponentType.FORM, name, null, options);
|
|
4213
4250
|
this.onGetValue = () => {
|
|
4214
|
-
return
|
|
4251
|
+
return this.formData;
|
|
4215
4252
|
};
|
|
4216
4253
|
this.onSetValue = (newValue, skipCallback, event) => {
|
|
4217
|
-
|
|
4254
|
+
this.formData = newValue;
|
|
4218
4255
|
const entries = container.querySelectorAll('.lexcomponent');
|
|
4219
4256
|
for (let i = 0; i < entries.length; ++i) {
|
|
4220
4257
|
const entry = entries[i];
|
|
@@ -4230,7 +4267,6 @@
|
|
|
4230
4267
|
let container = document.createElement('div');
|
|
4231
4268
|
container.className = 'flex flex-col gap-1';
|
|
4232
4269
|
container.style.width = '100%';
|
|
4233
|
-
container.formData = {};
|
|
4234
4270
|
this.root.appendChild(container);
|
|
4235
4271
|
for (let entry in data) {
|
|
4236
4272
|
let entryData = data[entry];
|
|
@@ -4248,42 +4284,68 @@
|
|
|
4248
4284
|
container.appendChild(label.root);
|
|
4249
4285
|
}
|
|
4250
4286
|
entryData.textComponent = new TextInput(null, entryData.constructor == Object ? entryData.value : entryData, (value, event) => {
|
|
4251
|
-
|
|
4252
|
-
if (entryData.submit && event
|
|
4253
|
-
|
|
4287
|
+
this.formData[entry] = value;
|
|
4288
|
+
if (entryData.submit && event?.constructor === KeyboardEvent) {
|
|
4289
|
+
this.submit();
|
|
4254
4290
|
}
|
|
4255
4291
|
}, entryData);
|
|
4256
4292
|
container.appendChild(entryData.textComponent.root);
|
|
4257
|
-
|
|
4293
|
+
this.formData[entry] = entryData.constructor == Object ? entryData.value : entryData;
|
|
4258
4294
|
}
|
|
4259
4295
|
const buttonContainer = exports.LX.makeContainer(['100%', 'auto'], 'flex flex-row mt-2', '', container);
|
|
4260
4296
|
if (options.secondaryActionName || options.secondaryActionCallback) {
|
|
4261
4297
|
const secondaryButton = new Button(null, options.secondaryActionName ?? 'Cancel', (value, event) => {
|
|
4262
4298
|
if (options.secondaryActionCallback) {
|
|
4263
|
-
options.secondaryActionCallback(
|
|
4299
|
+
options.secondaryActionCallback(this.formData, event);
|
|
4264
4300
|
}
|
|
4265
4301
|
}, { width: '100%', minWidth: '0', buttonClass: options.secondaryButtonClass ?? 'secondary' });
|
|
4266
4302
|
buttonContainer.appendChild(secondaryButton.root);
|
|
4267
4303
|
}
|
|
4268
|
-
|
|
4304
|
+
// This is basically the "submit" button
|
|
4305
|
+
this.primaryButton = new Button(null, options.primaryActionName ?? 'Submit', (value, event) => {
|
|
4269
4306
|
const errors = [];
|
|
4270
4307
|
for (let entry in data) {
|
|
4271
4308
|
let entryData = data[entry];
|
|
4272
4309
|
const pattern = entryData.pattern;
|
|
4273
|
-
const matchField = pattern?.fieldMatchName ?
|
|
4310
|
+
const matchField = pattern?.fieldMatchName ? this.formData[pattern.fieldMatchName] : undefined;
|
|
4274
4311
|
if (!entryData.textComponent.valid(undefined, matchField)) {
|
|
4275
4312
|
const err = { entry, type: 'input_not_valid', messages: [] };
|
|
4276
4313
|
if (pattern) {
|
|
4277
|
-
err.messages = exports.LX.validateValueAtPattern(
|
|
4314
|
+
err.messages = exports.LX.validateValueAtPattern(this.formData[entry], pattern, matchField);
|
|
4278
4315
|
}
|
|
4279
4316
|
errors.push(err);
|
|
4280
4317
|
}
|
|
4281
4318
|
}
|
|
4282
4319
|
if (callback) {
|
|
4283
|
-
callback(
|
|
4320
|
+
callback(this.formData, errors, event);
|
|
4284
4321
|
}
|
|
4285
4322
|
}, { width: '100%', minWidth: '0', buttonClass: options.primaryButtonClass ?? 'primary' });
|
|
4286
|
-
buttonContainer.appendChild(primaryButton.root);
|
|
4323
|
+
buttonContainer.appendChild(this.primaryButton.root);
|
|
4324
|
+
if (!(options.skipEnterSubmit ?? false)) {
|
|
4325
|
+
this.root.addEventListener('keydown', (e) => {
|
|
4326
|
+
if (e.key !== 'Enter' || e.shiftKey)
|
|
4327
|
+
return;
|
|
4328
|
+
const target = e.target;
|
|
4329
|
+
if (target.tagName === 'TEXTAREA')
|
|
4330
|
+
return;
|
|
4331
|
+
e.preventDefault();
|
|
4332
|
+
this.submit();
|
|
4333
|
+
});
|
|
4334
|
+
}
|
|
4335
|
+
this.data = data;
|
|
4336
|
+
}
|
|
4337
|
+
submit() {
|
|
4338
|
+
this.syncInputs();
|
|
4339
|
+
this.primaryButton?.click();
|
|
4340
|
+
}
|
|
4341
|
+
syncInputs() {
|
|
4342
|
+
for (const entry in this.data) {
|
|
4343
|
+
const component = this.data[entry].textComponent;
|
|
4344
|
+
if (component instanceof TextInput) {
|
|
4345
|
+
component.syncFromDOM();
|
|
4346
|
+
this.formData[entry] = component.value();
|
|
4347
|
+
}
|
|
4348
|
+
}
|
|
4287
4349
|
}
|
|
4288
4350
|
}
|
|
4289
4351
|
exports.LX.Form = Form;
|
|
@@ -4322,9 +4384,10 @@
|
|
|
4322
4384
|
binary = '0' + binary;
|
|
4323
4385
|
}
|
|
4324
4386
|
for (let bit = 0; bit < maxBits; ++bit) {
|
|
4325
|
-
let layer = document.createElement('
|
|
4326
|
-
layer.className =
|
|
4327
|
-
|
|
4387
|
+
let layer = document.createElement('button');
|
|
4388
|
+
layer.className = `lexlayer size-6 text-secondary-foreground text-center content-center place-self-center cursor-pointer font-semibold text-xs rounded-lg select-none
|
|
4389
|
+
disabled:pointer-events-none disabled:opacity-50`;
|
|
4390
|
+
layer.disabled = this.disabled;
|
|
4328
4391
|
if (val != undefined) {
|
|
4329
4392
|
const valueBit = binary[maxBits - bit - 1];
|
|
4330
4393
|
if (valueBit != undefined && valueBit == '1') {
|
|
@@ -4395,8 +4458,9 @@
|
|
|
4395
4458
|
icon = itemValue[1];
|
|
4396
4459
|
itemValue = itemValue[0];
|
|
4397
4460
|
}
|
|
4398
|
-
let listElement = document.createElement('
|
|
4399
|
-
listElement.className =
|
|
4461
|
+
let listElement = document.createElement('button');
|
|
4462
|
+
listElement.className = `lexlistitem disabled:pointer-events-none disabled:opacity-50 ${(value == itemValue) ? 'selected' : ''}`;
|
|
4463
|
+
listElement.disabled = this.disabled;
|
|
4400
4464
|
if (icon) {
|
|
4401
4465
|
listElement.appendChild(exports.LX.makeIcon(icon));
|
|
4402
4466
|
}
|
|
@@ -4855,10 +4919,10 @@
|
|
|
4855
4919
|
container.className = 'lexmap2d';
|
|
4856
4920
|
this.root.appendChild(container);
|
|
4857
4921
|
this.map2d = new CanvasMap2D(points, callback, options);
|
|
4858
|
-
const calendarIcon = exports.LX.makeIcon('SquareMousePointer');
|
|
4922
|
+
const calendarIcon = exports.LX.makeIcon(options.mapIcon ?? 'SquareMousePointer');
|
|
4859
4923
|
const calendarButton = new Button(null, 'Open Map', () => {
|
|
4860
4924
|
this._popover = new Popover(calendarButton.root, [this.map2d]);
|
|
4861
|
-
}, { buttonClass: `outline justify-between
|
|
4925
|
+
}, { buttonClass: `outline justify-between`, disabled: this.disabled });
|
|
4862
4926
|
calendarButton.root.querySelector('button').appendChild(calendarIcon);
|
|
4863
4927
|
container.appendChild(calendarButton.root);
|
|
4864
4928
|
exports.LX.doAsync(this.onResize.bind(this));
|
|
@@ -5540,7 +5604,6 @@
|
|
|
5540
5604
|
const realNameWidth = this.root.domName?.style.width ?? '0px';
|
|
5541
5605
|
container.style.width = `calc( 100% - ${realNameWidth})`;
|
|
5542
5606
|
};
|
|
5543
|
-
this.disabled = options.disabled ?? false;
|
|
5544
5607
|
const container = document.createElement('div');
|
|
5545
5608
|
container.className = 'lexotp flex flex-row items-center';
|
|
5546
5609
|
this.root.appendChild(container);
|
|
@@ -5651,17 +5714,18 @@
|
|
|
5651
5714
|
const realNameWidth = this.root.domName?.style.width ?? '0px';
|
|
5652
5715
|
container.style.width = `calc( 100% - ${realNameWidth})`;
|
|
5653
5716
|
};
|
|
5654
|
-
|
|
5717
|
+
let container = document.createElement('div');
|
|
5655
5718
|
container.className = 'lexpad';
|
|
5656
5719
|
this.root.appendChild(container);
|
|
5657
5720
|
let pad = document.createElement('div');
|
|
5658
5721
|
pad.id = 'lexpad-' + name;
|
|
5659
|
-
pad.className = 'lexinnerpad';
|
|
5722
|
+
pad.className = 'lexinnerpad data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 border-color';
|
|
5660
5723
|
pad.style.width = options.padSize ?? '96px';
|
|
5661
5724
|
pad.style.height = options.padSize ?? '96px';
|
|
5725
|
+
pad.dataset['disabled'] = this.disabled.toString();
|
|
5662
5726
|
container.appendChild(pad);
|
|
5663
5727
|
let thumb = document.createElement('div');
|
|
5664
|
-
thumb.className = 'lexpadthumb';
|
|
5728
|
+
thumb.className = 'lexpadthumb opacity-inherit';
|
|
5665
5729
|
thumb.value = new vec2(value[0], value[1]);
|
|
5666
5730
|
thumb.min = options.min ?? 0;
|
|
5667
5731
|
thumb.max = options.max ?? 1;
|
|
@@ -5854,7 +5918,7 @@
|
|
|
5854
5918
|
container.appendChild(optionItem);
|
|
5855
5919
|
const optionButton = document.createElement('button');
|
|
5856
5920
|
optionButton.className = 'flex p-0 rounded-lg cursor-pointer';
|
|
5857
|
-
optionButton.disabled =
|
|
5921
|
+
optionButton.disabled = this.disabled;
|
|
5858
5922
|
optionItem.appendChild(optionButton);
|
|
5859
5923
|
optionButton.addEventListener('click', (e) => {
|
|
5860
5924
|
this.set(i, false, e);
|
|
@@ -5966,7 +6030,7 @@
|
|
|
5966
6030
|
slider.max = options.max ?? 100;
|
|
5967
6031
|
slider.step = options.step ?? 1;
|
|
5968
6032
|
slider.type = 'range';
|
|
5969
|
-
slider.disabled =
|
|
6033
|
+
slider.disabled = this.disabled;
|
|
5970
6034
|
if (value.constructor == Number) {
|
|
5971
6035
|
value = exports.LX.clamp(value, +slider.min, +slider.max);
|
|
5972
6036
|
}
|
|
@@ -6025,7 +6089,7 @@
|
|
|
6025
6089
|
maxSlider.max = options.max ?? 100;
|
|
6026
6090
|
maxSlider.step = options.step ?? 1;
|
|
6027
6091
|
maxSlider.type = 'range';
|
|
6028
|
-
maxSlider.disabled =
|
|
6092
|
+
maxSlider.disabled = this.disabled;
|
|
6029
6093
|
this._maxSlider = maxSlider;
|
|
6030
6094
|
let maxRangeValue = ogValue[1];
|
|
6031
6095
|
maxSlider.value = maxRangeValue = exports.LX.clamp(maxRangeValue, +maxSlider.min, +maxSlider.max);
|
|
@@ -6066,7 +6130,8 @@
|
|
|
6066
6130
|
container.style.width = `calc( 100% - ${realNameWidth})`;
|
|
6067
6131
|
};
|
|
6068
6132
|
const container = document.createElement('div');
|
|
6069
|
-
container.className = 'lexrate relative';
|
|
6133
|
+
container.className = 'lexrate relative data-[disabled=true]:pointer-events-none';
|
|
6134
|
+
container.dataset['disabled'] = this.disabled.toString();
|
|
6070
6135
|
this.root.appendChild(container);
|
|
6071
6136
|
const starsContainer = exports.LX.makeContainer(['fit-content', 'auto'], 'flex flex-row gap-1', '', container);
|
|
6072
6137
|
const filledStarsContainer = exports.LX.makeContainer(['fit-content', 'auto'], 'absolute top-0 flex flex-row gap-1 pointer-events-none', '', container);
|
|
@@ -6165,7 +6230,7 @@
|
|
|
6165
6230
|
if (callback) {
|
|
6166
6231
|
callback(value);
|
|
6167
6232
|
}
|
|
6168
|
-
}, { min: 0, disabled:
|
|
6233
|
+
}, { min: 0, disabled: this.disabled, precision: options.precision, className: 'flex-auto-fill' });
|
|
6169
6234
|
container.appendChild(this.root.dimensions[i].root);
|
|
6170
6235
|
if ((i + 1) != value.length) {
|
|
6171
6236
|
const xIcon = exports.LX.makeIcon('X', { svgClass: 'text-foreground font-bold' });
|
|
@@ -7216,15 +7281,20 @@
|
|
|
7216
7281
|
for (let i = 0; i < value.length; ++i) {
|
|
7217
7282
|
const tagName = value[i];
|
|
7218
7283
|
const tag = exports.LX.makeElement('span', 'lextag bg-primary px-2 py-1 rounded-xl min-w-2 justify-center text-primary-foreground gap-1 text-sm select-none', tagName);
|
|
7219
|
-
|
|
7220
|
-
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
|
|
7224
|
-
|
|
7225
|
-
|
|
7284
|
+
if (!this.disabled) {
|
|
7285
|
+
const removeButton = exports.LX.makeIcon('X', { svgClass: 'sm' });
|
|
7286
|
+
tag.appendChild(removeButton);
|
|
7287
|
+
removeButton.addEventListener('click', (e) => {
|
|
7288
|
+
tag.remove();
|
|
7289
|
+
value.splice(value.indexOf(tagName), 1);
|
|
7290
|
+
this.set(value, false, e);
|
|
7291
|
+
});
|
|
7292
|
+
}
|
|
7226
7293
|
tagsContainer.appendChild(tag);
|
|
7227
7294
|
}
|
|
7295
|
+
if (this.disabled) {
|
|
7296
|
+
return;
|
|
7297
|
+
}
|
|
7228
7298
|
let tagInput = document.createElement('input');
|
|
7229
7299
|
tagInput.value = '';
|
|
7230
7300
|
tagInput.placeholder = 'Add tag...';
|
|
@@ -7276,6 +7346,7 @@
|
|
|
7276
7346
|
let wValue = exports.LX.makeElement('textarea', options.inputClass ?? '');
|
|
7277
7347
|
wValue.value = value ?? '';
|
|
7278
7348
|
wValue.style.textAlign = options.float ?? '';
|
|
7349
|
+
wValue.disabled = this.disabled;
|
|
7279
7350
|
Object.assign(wValue.style, options.style ?? {});
|
|
7280
7351
|
if (options.fitHeight ?? false) {
|
|
7281
7352
|
wValue.classList.add('field-sizing-content');
|
|
@@ -7284,10 +7355,6 @@
|
|
|
7284
7355
|
wValue.classList.add('resize-none');
|
|
7285
7356
|
}
|
|
7286
7357
|
container.appendChild(wValue);
|
|
7287
|
-
if (options.disabled ?? false) {
|
|
7288
|
-
this.disabled = true;
|
|
7289
|
-
wValue.setAttribute('disabled', 'true');
|
|
7290
|
-
}
|
|
7291
7358
|
if (options.placeholder) {
|
|
7292
7359
|
wValue.setAttribute('placeholder', options.placeholder);
|
|
7293
7360
|
}
|
|
@@ -7387,7 +7454,7 @@
|
|
|
7387
7454
|
toggle.type = 'checkbox';
|
|
7388
7455
|
toggle.checked = value;
|
|
7389
7456
|
toggle.iValue = value;
|
|
7390
|
-
toggle.disabled =
|
|
7457
|
+
toggle.disabled = this.disabled;
|
|
7391
7458
|
container.appendChild(toggle);
|
|
7392
7459
|
let valueName = document.createElement('span');
|
|
7393
7460
|
valueName.className = 'font-medium w-full overflow-hidden truncate';
|
|
@@ -7454,7 +7521,6 @@
|
|
|
7454
7521
|
var container = document.createElement('div');
|
|
7455
7522
|
container.className = 'lexvector flex';
|
|
7456
7523
|
this.root.appendChild(container);
|
|
7457
|
-
this.disabled = options.disabled ?? false;
|
|
7458
7524
|
const that = this;
|
|
7459
7525
|
for (let i = 0; i < numComponents; ++i) {
|
|
7460
7526
|
let box = document.createElement('div');
|
|
@@ -7468,6 +7534,7 @@
|
|
|
7468
7534
|
vecinput.type = 'number';
|
|
7469
7535
|
vecinput.id = 'vec' + numComponents + '_' + exports.LX.guidGenerator();
|
|
7470
7536
|
vecinput.idx = i;
|
|
7537
|
+
vecinput.disabled = this.disabled;
|
|
7471
7538
|
vectorInputs[i] = vecinput;
|
|
7472
7539
|
box.appendChild(vecinput);
|
|
7473
7540
|
if (value[i].constructor == Number) {
|
|
@@ -7477,9 +7544,6 @@
|
|
|
7477
7544
|
vecinput.value = vecinput.iValue = value[i];
|
|
7478
7545
|
const dragIcon = exports.LX.makeIcon('MoveVertical', { iconClass: 'drag-icon hidden-opacity', svgClass: 'sm' });
|
|
7479
7546
|
box.appendChild(dragIcon);
|
|
7480
|
-
if (this.disabled) {
|
|
7481
|
-
vecinput.disabled = true;
|
|
7482
|
-
}
|
|
7483
7547
|
// Add wheel input
|
|
7484
7548
|
vecinput.addEventListener('wheel', function (e) {
|
|
7485
7549
|
e.preventDefault();
|
|
@@ -10376,8 +10440,10 @@
|
|
|
10376
10440
|
const collapsed = options.collapsed ?? true;
|
|
10377
10441
|
const actionIcon = exports.LX.makeIcon('Right');
|
|
10378
10442
|
actionIcon.classList.add('collapser');
|
|
10379
|
-
if (collapsed)
|
|
10380
|
-
actionIcon.dataset['collapsed'] =
|
|
10443
|
+
if (collapsed) {
|
|
10444
|
+
actionIcon.dataset['collapsed'] = `true`;
|
|
10445
|
+
content.style.display = 'none';
|
|
10446
|
+
}
|
|
10381
10447
|
actionIcon.style.marginLeft = 'auto';
|
|
10382
10448
|
actionIcon.style.marginRight = '0.2rem';
|
|
10383
10449
|
actionIcon.addEventListener('click', function (e) {
|