juxscript 1.1.80 → 1.1.82
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/dom-structure-map.json +1 -1
- package/index.d.ts +2 -2
- package/index.d.ts.map +1 -1
- package/index.js +2 -2
- package/lib/components/badge.d.ts.map +1 -1
- package/lib/components/badge.js +2 -1
- package/lib/components/badge.ts +2 -1
- package/lib/components/base/BaseComponent.d.ts +55 -1
- package/lib/components/base/BaseComponent.d.ts.map +1 -1
- package/lib/components/base/BaseComponent.js +168 -2
- package/lib/components/base/BaseComponent.ts +203 -3
- package/lib/components/checkbox.d.ts +5 -4
- package/lib/components/checkbox.d.ts.map +1 -1
- package/lib/components/checkbox.js +33 -16
- package/lib/components/checkbox.ts +39 -22
- package/lib/components/datepicker.d.ts +5 -4
- package/lib/components/datepicker.d.ts.map +1 -1
- package/lib/components/datepicker.js +31 -16
- package/lib/components/datepicker.ts +37 -22
- package/lib/components/dropdown.d.ts.map +1 -1
- package/lib/components/dropdown.js +2 -1
- package/lib/components/dropdown.ts +2 -1
- package/lib/components/fileupload.d.ts +6 -6
- package/lib/components/fileupload.d.ts.map +1 -1
- package/lib/components/fileupload.js +77 -52
- package/lib/components/fileupload.ts +88 -58
- package/lib/components/input.d.ts +5 -4
- package/lib/components/input.d.ts.map +1 -1
- package/lib/components/input.js +38 -24
- package/lib/components/input.ts +48 -33
- package/lib/components/paragraph.d.ts +8 -0
- package/lib/components/paragraph.d.ts.map +1 -1
- package/lib/components/paragraph.js +33 -2
- package/lib/components/paragraph.ts +37 -2
- package/lib/components/radio.d.ts +5 -4
- package/lib/components/radio.d.ts.map +1 -1
- package/lib/components/radio.js +37 -14
- package/lib/components/radio.ts +40 -16
- package/lib/components/select.d.ts +5 -4
- package/lib/components/select.d.ts.map +1 -1
- package/lib/components/select.js +32 -11
- package/lib/components/select.ts +38 -16
- package/lib/components/switch.d.ts +5 -4
- package/lib/components/switch.d.ts.map +1 -1
- package/lib/components/switch.js +34 -11
- package/lib/components/switch.ts +42 -16
- package/lib/components/watcher.d.ts +195 -0
- package/lib/components/watcher.d.ts.map +1 -0
- package/lib/components/watcher.js +241 -0
- package/lib/components/watcher.ts +261 -0
- package/package.json +1 -1
- package/lib/components/base/FormInput.d.ts +0 -77
- package/lib/components/base/FormInput.d.ts.map +0 -1
- package/lib/components/base/FormInput.js +0 -171
- package/lib/components/base/FormInput.ts +0 -237
- package/lib/components/event-chain.ts +0 -31
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
2
|
import { renderIcon } from './icons.js';
|
|
3
|
+
import { formatIdAsLabel } from '../utils/formatId.js'; // ✅ Import
|
|
3
4
|
// Event definitions
|
|
4
5
|
const TRIGGER_EVENTS = [];
|
|
5
6
|
const CALLBACK_EVENTS = ['change'];
|
|
6
|
-
export class Checkbox extends
|
|
7
|
+
export class Checkbox extends BaseComponent {
|
|
7
8
|
constructor(id, options = {}) {
|
|
8
9
|
super(id, {
|
|
9
|
-
|
|
10
|
-
value: options.value ?? 'on',
|
|
11
|
-
label: options.label ?? '',
|
|
12
|
-
required: options.required ?? false,
|
|
10
|
+
visible: true,
|
|
13
11
|
disabled: options.disabled ?? false,
|
|
14
|
-
|
|
15
|
-
style: options.style ?? '',
|
|
12
|
+
loading: false,
|
|
16
13
|
class: options.class ?? '',
|
|
17
|
-
|
|
14
|
+
style: options.style ?? '',
|
|
15
|
+
attributes: {},
|
|
16
|
+
label: options.label ?? formatIdAsLabel(id), // ✅ Auto-generate
|
|
17
|
+
required: options.required ?? false,
|
|
18
|
+
name: options.name ?? id,
|
|
19
|
+
errorMessage: undefined,
|
|
20
|
+
checked: options.checked ?? false,
|
|
21
|
+
value: options.value ?? 'on'
|
|
18
22
|
});
|
|
19
23
|
if (options.onValidate) {
|
|
20
24
|
this._onValidate = options.onValidate;
|
|
@@ -29,12 +33,6 @@ export class Checkbox extends FormInput {
|
|
|
29
33
|
/* ═════════════════════════════════════════════════════════════════
|
|
30
34
|
* FLUENT API
|
|
31
35
|
* ═════════════════════════════════════════════════════════════════ */
|
|
32
|
-
// ✅ Inherited from FormInput/BaseComponent:
|
|
33
|
-
// - label(), required(), name(), onValidate()
|
|
34
|
-
// - validate(), isValid()
|
|
35
|
-
// - style(), class()
|
|
36
|
-
// - bind(), sync(), renderTo()
|
|
37
|
-
// - disabled(), enable(), disable()
|
|
38
36
|
checked(value) {
|
|
39
37
|
return this.setValue(value);
|
|
40
38
|
}
|
|
@@ -55,6 +53,23 @@ export class Checkbox extends FormInput {
|
|
|
55
53
|
}
|
|
56
54
|
return this;
|
|
57
55
|
}
|
|
56
|
+
validate() {
|
|
57
|
+
this._hasBeenValidated = true;
|
|
58
|
+
const value = this.getValue();
|
|
59
|
+
const result = this._validateValue(value);
|
|
60
|
+
if (result === true) {
|
|
61
|
+
this._clearError();
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this._showError(result);
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
isValid() {
|
|
70
|
+
const value = this.getValue();
|
|
71
|
+
return this._validateValue(value) === true;
|
|
72
|
+
}
|
|
58
73
|
_validateValue(checked) {
|
|
59
74
|
const { required } = this.state;
|
|
60
75
|
if (required && !checked) {
|
|
@@ -166,7 +181,9 @@ export class Checkbox extends FormInput {
|
|
|
166
181
|
}
|
|
167
182
|
// Always add blur validation
|
|
168
183
|
inputEl.addEventListener('blur', () => {
|
|
169
|
-
this.
|
|
184
|
+
if (this._hasBeenValidated) {
|
|
185
|
+
this.validate();
|
|
186
|
+
}
|
|
170
187
|
});
|
|
171
188
|
// Sync label changes
|
|
172
189
|
const labelSync = this._syncBindings.find(b => b.property === 'label');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseComponent } from './base/BaseComponent.js';
|
|
1
|
+
import { BaseComponent, BaseState } from './base/BaseComponent.js';
|
|
3
2
|
import { renderIcon } from './icons.js';
|
|
3
|
+
import { formatIdAsLabel } from '../utils/formatId.js'; // ✅ Import
|
|
4
4
|
|
|
5
5
|
// Event definitions
|
|
6
6
|
const TRIGGER_EVENTS = [] as const;
|
|
@@ -18,23 +18,26 @@ export interface CheckboxOptions {
|
|
|
18
18
|
onValidate?: (checked: boolean) => boolean | string;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
interface CheckboxState extends
|
|
21
|
+
interface CheckboxState extends BaseState {
|
|
22
22
|
checked: boolean;
|
|
23
23
|
value: string;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export class Checkbox extends
|
|
26
|
+
export class Checkbox extends BaseComponent<CheckboxState> {
|
|
27
27
|
constructor(id: string, options: CheckboxOptions = {}) {
|
|
28
28
|
super(id, {
|
|
29
|
-
|
|
30
|
-
value: options.value ?? 'on',
|
|
31
|
-
label: options.label ?? '',
|
|
32
|
-
required: options.required ?? false,
|
|
29
|
+
visible: true,
|
|
33
30
|
disabled: options.disabled ?? false,
|
|
34
|
-
|
|
35
|
-
style: options.style ?? '',
|
|
31
|
+
loading: false,
|
|
36
32
|
class: options.class ?? '',
|
|
37
|
-
|
|
33
|
+
style: options.style ?? '',
|
|
34
|
+
attributes: {},
|
|
35
|
+
label: options.label ?? formatIdAsLabel(id), // ✅ Auto-generate
|
|
36
|
+
required: options.required ?? false,
|
|
37
|
+
name: options.name ?? id,
|
|
38
|
+
errorMessage: undefined,
|
|
39
|
+
checked: options.checked ?? false,
|
|
40
|
+
value: options.value ?? 'on'
|
|
38
41
|
});
|
|
39
42
|
|
|
40
43
|
if (options.onValidate) {
|
|
@@ -54,13 +57,6 @@ export class Checkbox extends FormInput<CheckboxState> {
|
|
|
54
57
|
* FLUENT API
|
|
55
58
|
* ═════════════════════════════════════════════════════════════════ */
|
|
56
59
|
|
|
57
|
-
// ✅ Inherited from FormInput/BaseComponent:
|
|
58
|
-
// - label(), required(), name(), onValidate()
|
|
59
|
-
// - validate(), isValid()
|
|
60
|
-
// - style(), class()
|
|
61
|
-
// - bind(), sync(), renderTo()
|
|
62
|
-
// - disabled(), enable(), disable()
|
|
63
|
-
|
|
64
60
|
checked(value: boolean): this {
|
|
65
61
|
return this.setValue(value);
|
|
66
62
|
}
|
|
@@ -86,6 +82,25 @@ export class Checkbox extends FormInput<CheckboxState> {
|
|
|
86
82
|
return this;
|
|
87
83
|
}
|
|
88
84
|
|
|
85
|
+
validate(): boolean {
|
|
86
|
+
this._hasBeenValidated = true;
|
|
87
|
+
const value = this.getValue();
|
|
88
|
+
const result = this._validateValue(value);
|
|
89
|
+
|
|
90
|
+
if (result === true) {
|
|
91
|
+
this._clearError();
|
|
92
|
+
return true;
|
|
93
|
+
} else {
|
|
94
|
+
this._showError(result as string);
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
isValid(): boolean {
|
|
100
|
+
const value = this.getValue();
|
|
101
|
+
return this._validateValue(value) === true;
|
|
102
|
+
}
|
|
103
|
+
|
|
89
104
|
protected _validateValue(checked: boolean): boolean | string {
|
|
90
105
|
const { required } = this.state;
|
|
91
106
|
|
|
@@ -110,11 +125,11 @@ export class Checkbox extends FormInput<CheckboxState> {
|
|
|
110
125
|
input.type = 'checkbox';
|
|
111
126
|
input.className = 'jux-checkbox-input';
|
|
112
127
|
input.id = `${this._id}-input`;
|
|
113
|
-
input.name = name
|
|
128
|
+
input.name = name!;
|
|
114
129
|
input.value = value;
|
|
115
130
|
input.checked = checked;
|
|
116
|
-
input.required = required
|
|
117
|
-
input.disabled = disabled
|
|
131
|
+
input.required = required!;
|
|
132
|
+
input.disabled = disabled!;
|
|
118
133
|
|
|
119
134
|
return input;
|
|
120
135
|
}
|
|
@@ -221,7 +236,9 @@ export class Checkbox extends FormInput<CheckboxState> {
|
|
|
221
236
|
|
|
222
237
|
// Always add blur validation
|
|
223
238
|
inputEl.addEventListener('blur', () => {
|
|
224
|
-
this.
|
|
239
|
+
if (this._hasBeenValidated) {
|
|
240
|
+
this.validate();
|
|
241
|
+
}
|
|
225
242
|
});
|
|
226
243
|
|
|
227
244
|
// Sync label changes
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseComponent } from './base/BaseComponent.js';
|
|
1
|
+
import { BaseComponent, BaseState } from './base/BaseComponent.js';
|
|
3
2
|
export interface DatePickerOptions {
|
|
4
3
|
value?: string;
|
|
5
4
|
label?: string;
|
|
@@ -13,13 +12,13 @@ export interface DatePickerOptions {
|
|
|
13
12
|
class?: string;
|
|
14
13
|
onValidate?: (value: string) => boolean | string;
|
|
15
14
|
}
|
|
16
|
-
interface DatePickerState extends
|
|
15
|
+
interface DatePickerState extends BaseState {
|
|
17
16
|
value: string;
|
|
18
17
|
placeholder: string;
|
|
19
18
|
min?: string;
|
|
20
19
|
max?: string;
|
|
21
20
|
}
|
|
22
|
-
export declare class DatePicker extends
|
|
21
|
+
export declare class DatePicker extends BaseComponent<DatePickerState> {
|
|
23
22
|
constructor(id: string, options?: DatePickerOptions);
|
|
24
23
|
protected getTriggerEvents(): readonly string[];
|
|
25
24
|
protected getCallbackEvents(): readonly string[];
|
|
@@ -30,6 +29,8 @@ export declare class DatePicker extends FormInput<DatePickerState> {
|
|
|
30
29
|
getValue(): string;
|
|
31
30
|
setValue(value: string): this;
|
|
32
31
|
getDate(): Date | null;
|
|
32
|
+
validate(): boolean;
|
|
33
|
+
isValid(): boolean;
|
|
33
34
|
protected _validateValue(value: string): boolean | string;
|
|
34
35
|
protected _buildInputElement(): HTMLElement;
|
|
35
36
|
render(targetId?: string | HTMLElement | BaseComponent<any>): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"datepicker.d.ts","sourceRoot":"","sources":["datepicker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"datepicker.d.ts","sourceRoot":"","sources":["datepicker.ts"],"names":[],"mappings":"AAAA,OAA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;IAcnB,OAAO,IAAI,OAAO;IAKlB,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM;IAuCzD,SAAS,CAAC,kBAAkB,IAAI,WAAW;IAuB3C,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI;CA0DrE;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB,GAAG,UAAU,CAElF"}
|
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
2
|
import { renderIcon } from './icons.js';
|
|
3
|
+
import { formatIdAsLabel } from '../utils/formatId.js'; // ✅ Import
|
|
3
4
|
// Event definitions
|
|
4
5
|
const TRIGGER_EVENTS = [];
|
|
5
6
|
const CALLBACK_EVENTS = ['change'];
|
|
6
|
-
export class DatePicker extends
|
|
7
|
+
export class DatePicker extends BaseComponent {
|
|
7
8
|
constructor(id, options = {}) {
|
|
8
9
|
super(id, {
|
|
9
|
-
|
|
10
|
-
placeholder: options.placeholder ?? 'Select a date',
|
|
11
|
-
label: options.label ?? '',
|
|
12
|
-
required: options.required ?? false,
|
|
10
|
+
visible: true,
|
|
13
11
|
disabled: options.disabled ?? false,
|
|
12
|
+
loading: false,
|
|
13
|
+
class: options.class ?? '',
|
|
14
|
+
style: options.style ?? '',
|
|
15
|
+
attributes: {},
|
|
16
|
+
label: options.label ?? formatIdAsLabel(id), // ✅ Auto-generate
|
|
17
|
+
required: options.required ?? false,
|
|
14
18
|
name: options.name ?? id,
|
|
19
|
+
errorMessage: undefined,
|
|
20
|
+
value: options.value ?? '',
|
|
21
|
+
placeholder: options.placeholder ?? 'Select a date',
|
|
15
22
|
min: options.min,
|
|
16
|
-
max: options.max
|
|
17
|
-
style: options.style ?? '',
|
|
18
|
-
class: options.class ?? '',
|
|
19
|
-
errorMessage: undefined
|
|
23
|
+
max: options.max
|
|
20
24
|
});
|
|
21
25
|
if (options.onValidate) {
|
|
22
26
|
this._onValidate = options.onValidate;
|
|
@@ -31,12 +35,6 @@ export class DatePicker extends FormInput {
|
|
|
31
35
|
/* ═════════════════════════════════════════════════════════════════
|
|
32
36
|
* FLUENT API
|
|
33
37
|
* ═════════════════════════════════════════════════════════════════ */
|
|
34
|
-
// ✅ Inherited from FormInput/BaseComponent:
|
|
35
|
-
// - label(), required(), name(), onValidate()
|
|
36
|
-
// - validate(), isValid()
|
|
37
|
-
// - style(), class()
|
|
38
|
-
// - bind(), sync(), renderTo()
|
|
39
|
-
// - disabled(), enable(), disable()
|
|
40
38
|
value(value) {
|
|
41
39
|
return this.setValue(value);
|
|
42
40
|
}
|
|
@@ -71,6 +69,23 @@ export class DatePicker extends FormInput {
|
|
|
71
69
|
const date = new Date(this.state.value);
|
|
72
70
|
return isNaN(date.getTime()) ? null : date;
|
|
73
71
|
}
|
|
72
|
+
validate() {
|
|
73
|
+
this._hasBeenValidated = true;
|
|
74
|
+
const value = this.getValue();
|
|
75
|
+
const result = this._validateValue(value);
|
|
76
|
+
if (result === true) {
|
|
77
|
+
this._clearError();
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
this._showError(result);
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
isValid() {
|
|
86
|
+
const value = this.getValue();
|
|
87
|
+
return this._validateValue(value) === true;
|
|
88
|
+
}
|
|
74
89
|
_validateValue(value) {
|
|
75
90
|
const { required, min, max } = this.state;
|
|
76
91
|
if (required && !value) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseComponent, BaseState } from './base/BaseComponent.js';
|
|
2
2
|
import { renderIcon } from './icons.js';
|
|
3
|
-
import {
|
|
3
|
+
import { formatIdAsLabel } from '../utils/formatId.js'; // ✅ Import
|
|
4
4
|
|
|
5
5
|
// Event definitions
|
|
6
6
|
const TRIGGER_EVENTS = [] as const;
|
|
@@ -20,27 +20,30 @@ export interface DatePickerOptions {
|
|
|
20
20
|
onValidate?: (value: string) => boolean | string;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
interface DatePickerState extends
|
|
23
|
+
interface DatePickerState extends BaseState {
|
|
24
24
|
value: string;
|
|
25
25
|
placeholder: string;
|
|
26
26
|
min?: string;
|
|
27
27
|
max?: string;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
export class DatePicker extends
|
|
30
|
+
export class DatePicker extends BaseComponent<DatePickerState> {
|
|
31
31
|
constructor(id: string, options: DatePickerOptions = {}) {
|
|
32
32
|
super(id, {
|
|
33
|
-
|
|
34
|
-
placeholder: options.placeholder ?? 'Select a date',
|
|
35
|
-
label: options.label ?? '',
|
|
36
|
-
required: options.required ?? false,
|
|
33
|
+
visible: true,
|
|
37
34
|
disabled: options.disabled ?? false,
|
|
35
|
+
loading: false,
|
|
36
|
+
class: options.class ?? '',
|
|
37
|
+
style: options.style ?? '',
|
|
38
|
+
attributes: {},
|
|
39
|
+
label: options.label ?? formatIdAsLabel(id), // ✅ Auto-generate
|
|
40
|
+
required: options.required ?? false,
|
|
38
41
|
name: options.name ?? id,
|
|
42
|
+
errorMessage: undefined,
|
|
43
|
+
value: options.value ?? '',
|
|
44
|
+
placeholder: options.placeholder ?? 'Select a date',
|
|
39
45
|
min: options.min,
|
|
40
|
-
max: options.max
|
|
41
|
-
style: options.style ?? '',
|
|
42
|
-
class: options.class ?? '',
|
|
43
|
-
errorMessage: undefined
|
|
46
|
+
max: options.max
|
|
44
47
|
});
|
|
45
48
|
|
|
46
49
|
if (options.onValidate) {
|
|
@@ -60,13 +63,6 @@ export class DatePicker extends FormInput<DatePickerState> {
|
|
|
60
63
|
* FLUENT API
|
|
61
64
|
* ═════════════════════════════════════════════════════════════════ */
|
|
62
65
|
|
|
63
|
-
// ✅ Inherited from FormInput/BaseComponent:
|
|
64
|
-
// - label(), required(), name(), onValidate()
|
|
65
|
-
// - validate(), isValid()
|
|
66
|
-
// - style(), class()
|
|
67
|
-
// - bind(), sync(), renderTo()
|
|
68
|
-
// - disabled(), enable(), disable()
|
|
69
|
-
|
|
70
66
|
value(value: string): this {
|
|
71
67
|
return this.setValue(value);
|
|
72
68
|
}
|
|
@@ -108,6 +104,25 @@ export class DatePicker extends FormInput<DatePickerState> {
|
|
|
108
104
|
return isNaN(date.getTime()) ? null : date;
|
|
109
105
|
}
|
|
110
106
|
|
|
107
|
+
validate(): boolean {
|
|
108
|
+
this._hasBeenValidated = true;
|
|
109
|
+
const value = this.getValue();
|
|
110
|
+
const result = this._validateValue(value);
|
|
111
|
+
|
|
112
|
+
if (result === true) {
|
|
113
|
+
this._clearError();
|
|
114
|
+
return true;
|
|
115
|
+
} else {
|
|
116
|
+
this._showError(result as string);
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
isValid(): boolean {
|
|
122
|
+
const value = this.getValue();
|
|
123
|
+
return this._validateValue(value) === true;
|
|
124
|
+
}
|
|
125
|
+
|
|
111
126
|
protected _validateValue(value: string): boolean | string {
|
|
112
127
|
const { required, min, max } = this.state;
|
|
113
128
|
|
|
@@ -154,11 +169,11 @@ export class DatePicker extends FormInput<DatePickerState> {
|
|
|
154
169
|
input.type = 'date';
|
|
155
170
|
input.className = 'jux-input-element jux-datepicker-input';
|
|
156
171
|
input.id = `${this._id}-input`;
|
|
157
|
-
input.name = name
|
|
172
|
+
input.name = name!;
|
|
158
173
|
input.value = value;
|
|
159
174
|
input.placeholder = placeholder;
|
|
160
|
-
input.required = required
|
|
161
|
-
input.disabled = disabled
|
|
175
|
+
input.required = required!;
|
|
176
|
+
input.disabled = disabled!;
|
|
162
177
|
|
|
163
178
|
if (min) input.min = min;
|
|
164
179
|
if (max) input.max = max;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["d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C,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,cAAc,GAAG,UAAU,GAAG,WAAW,GAAG,IAAI;IAKhF,IAAI,IAAI,IAAI;IAQZ,KAAK,IAAI,IAAI;IAQb,MAAM,IAAI,IAAI;IAQd,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI;IAsFlE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;CAGzC;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,QAAQ,CAE5E"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
+
import { formatIdAsLabel } from '../utils/formatId.js'; // ✅ Import
|
|
2
3
|
// Event definitions
|
|
3
4
|
const TRIGGER_EVENTS = [];
|
|
4
5
|
const CALLBACK_EVENTS = ['select'];
|
|
5
6
|
export class Dropdown extends BaseComponent {
|
|
6
7
|
constructor(id, options = {}) {
|
|
7
8
|
super(id, {
|
|
8
|
-
triggerLabel: options.triggerLabel ??
|
|
9
|
+
triggerLabel: options.triggerLabel ?? formatIdAsLabel(id), // ✅ Auto-generate
|
|
9
10
|
items: options.items ?? [],
|
|
10
11
|
position: options.position ?? 'bottom-left',
|
|
11
12
|
open: false,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
+
import { formatIdAsLabel } from '../utils/formatId.js'; // ✅ Import
|
|
2
3
|
|
|
3
4
|
// Event definitions
|
|
4
5
|
const TRIGGER_EVENTS = [] as const;
|
|
@@ -34,7 +35,7 @@ export class Dropdown extends BaseComponent<DropdownState> {
|
|
|
34
35
|
|
|
35
36
|
constructor(id: string, options: DropdownOptions = {}) {
|
|
36
37
|
super(id, {
|
|
37
|
-
triggerLabel: options.triggerLabel ??
|
|
38
|
+
triggerLabel: options.triggerLabel ?? formatIdAsLabel(id), // ✅ Auto-generate
|
|
38
39
|
items: options.items ?? [],
|
|
39
40
|
position: options.position ?? 'bottom-left',
|
|
40
41
|
open: false,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BaseComponent } from './base/BaseComponent.js';
|
|
1
|
+
import { BaseComponent, BaseState } from './base/BaseComponent.js';
|
|
3
2
|
export interface FileUploadOptions {
|
|
4
3
|
label?: string;
|
|
5
4
|
accept?: string;
|
|
@@ -12,13 +11,13 @@ export interface FileUploadOptions {
|
|
|
12
11
|
class?: string;
|
|
13
12
|
onValidate?: (files: File[]) => boolean | string;
|
|
14
13
|
}
|
|
15
|
-
interface FileUploadState extends
|
|
14
|
+
interface FileUploadState extends BaseState {
|
|
16
15
|
files: File[];
|
|
17
16
|
accept: string;
|
|
18
17
|
multiple: boolean;
|
|
19
18
|
icon: string;
|
|
20
19
|
}
|
|
21
|
-
export declare class FileUpload extends
|
|
20
|
+
export declare class FileUpload extends BaseComponent<FileUploadState> {
|
|
22
21
|
private _fileListElement;
|
|
23
22
|
constructor(id: string, options?: FileUploadOptions);
|
|
24
23
|
protected getTriggerEvents(): readonly string[];
|
|
@@ -29,12 +28,13 @@ export declare class FileUpload extends FormInput<FileUploadState> {
|
|
|
29
28
|
clear(): this;
|
|
30
29
|
getValue(): File[];
|
|
31
30
|
setValue(files: File[]): this;
|
|
32
|
-
|
|
31
|
+
validate(): boolean;
|
|
32
|
+
isValid(): boolean;
|
|
33
33
|
protected _validateValue(files: File[]): boolean | string;
|
|
34
34
|
protected _buildInputElement(): HTMLElement;
|
|
35
|
-
render(targetId?: string | HTMLElement | BaseComponent<any>): this;
|
|
36
35
|
private _updateFileList;
|
|
37
36
|
private _formatFileSize;
|
|
37
|
+
render(targetId?: string | HTMLElement | BaseComponent<any>): this;
|
|
38
38
|
}
|
|
39
39
|
export declare function fileupload(id: string, options?: FileUploadOptions): FileUpload;
|
|
40
40
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileupload.d.ts","sourceRoot":"","sources":["fileupload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"fileupload.d.ts","sourceRoot":"","sources":["fileupload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAQnE,MAAM,WAAW,iBAAiB;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,OAAO,GAAG,MAAM,CAAC;CACpD;AAED,UAAU,eAAgB,SAAQ,SAAS;IACvC,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,UAAW,SAAQ,aAAa,CAAC,eAAe,CAAC;IAC1D,OAAO,CAAC,gBAAgB,CAA4B;gBAExC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,iBAAsB;IAuBvD,SAAS,CAAC,gBAAgB,IAAI,SAAS,MAAM,EAAE;IAI/C,SAAS,CAAC,iBAAiB,IAAI,SAAS,MAAM,EAAE;IAQhD,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK3B,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAK9B,IAAI,CAAC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