@fibrae/semi-foundation 0.1.0 → 0.2.0
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/anchor/foundation.d.ts +1 -1
- package/dist/anchor/foundation.js +21 -21
- package/dist/audio-player/foundation.d.ts +10 -10
- package/dist/audio-player/foundation.js +19 -19
- package/dist/auto-complete/foundation.d.ts +12 -12
- package/dist/auto-complete/foundation.js +51 -51
- package/dist/avatar/foundation.d.ts +5 -5
- package/dist/avatar/foundation.js +16 -16
- package/dist/backtop/foundation.d.ts +2 -2
- package/dist/backtop/foundation.js +7 -7
- package/dist/banner/foundation.d.ts +1 -1
- package/dist/banner/foundation.js +4 -4
- package/dist/base/auto-close-foundation.d.ts +8 -8
- package/dist/base/auto-close-foundation.js +15 -15
- package/dist/base/foundation.d.ts +4 -3
- package/dist/base/foundation.js +12 -11
- package/dist/breadcrumb/foundation.d.ts +5 -5
- package/dist/breadcrumb/foundation.js +9 -10
- package/dist/breadcrumb/item-foundation.d.ts +3 -3
- package/dist/breadcrumb/item-foundation.js +6 -6
- package/dist/calendar/event-util.js +1 -1
- package/dist/calendar/foundation.js +4 -4
- package/dist/calendar/month-foundation.d.ts +2 -2
- package/dist/calendar/month-foundation.js +6 -6
- package/dist/carousel/foundation.d.ts +17 -17
- package/dist/carousel/foundation.js +51 -51
- package/dist/cascader/foundation.d.ts +34 -26
- package/dist/cascader/foundation.js +143 -121
- package/dist/checkbox/checkbox-foundation.d.ts +2 -2
- package/dist/checkbox/checkbox-foundation.js +15 -15
- package/dist/checkbox/checkbox-group-foundation.d.ts +2 -2
- package/dist/checkbox/checkbox-group-foundation.js +8 -8
- package/dist/code-highlight/index.d.ts +1 -1
- package/dist/code-highlight/index.js +3 -3
- package/dist/collapse/foundation.d.ts +2 -2
- package/dist/collapse/foundation.js +7 -7
- package/dist/collapsible/foundation.d.ts +3 -3
- package/dist/collapsible/foundation.js +8 -8
- package/dist/color-picker/alpha-slider-foundation.d.ts +2 -4
- package/dist/color-picker/alpha-slider-foundation.js +10 -10
- package/dist/color-picker/color-choose-area-foundation.d.ts +2 -5
- package/dist/color-picker/color-choose-area-foundation.js +14 -14
- package/dist/color-picker/color-slider-foundation.d.ts +2 -4
- package/dist/color-picker/color-slider-foundation.js +10 -10
- package/dist/color-picker/data-part-foundation.d.ts +5 -5
- package/dist/color-picker/data-part-foundation.js +11 -11
- package/dist/color-picker/foundation.d.ts +4 -4
- package/dist/color-picker/foundation.js +10 -10
- package/dist/config-provider/breakpoint-observer.d.ts +3 -3
- package/dist/config-provider/breakpoint-observer.js +6 -6
- package/dist/cropper/foundation.d.ts +15 -15
- package/dist/cropper/foundation.js +26 -23
- package/dist/date-picker/_utils/picker-type.d.ts +1 -1
- package/dist/date-picker/foundation.d.ts +36 -36
- package/dist/date-picker/foundation.js +125 -129
- package/dist/date-picker/input-foundation.d.ts +9 -9
- package/dist/date-picker/input-foundation.js +28 -28
- package/dist/date-picker/months-grid-foundation.d.ts +17 -17
- package/dist/date-picker/months-grid-foundation.js +64 -65
- package/dist/date-picker/year-and-month-foundation.d.ts +3 -3
- package/dist/date-picker/year-and-month-foundation.js +11 -11
- package/dist/drag-move/foundation.d.ts +2 -2
- package/dist/drag-move/foundation.js +15 -13
- package/dist/dropdown/foundation.d.ts +8 -5
- package/dist/dropdown/foundation.js +32 -28
- package/dist/dropdown/menu-foundation.d.ts +1 -1
- package/dist/dropdown/menu-foundation.js +11 -11
- package/dist/feedback/foundation.d.ts +9 -9
- package/dist/feedback/foundation.js +33 -33
- package/dist/form/form-api-proxy.d.ts +8 -7
- package/dist/form/form-api-proxy.js +25 -25
- package/dist/form/foundation.d.ts +5 -5
- package/dist/form/foundation.js +60 -61
- package/dist/highlight/foundation.js +1 -1
- package/dist/hot-keys/foundation.d.ts +2 -2
- package/dist/hot-keys/foundation.js +5 -5
- package/dist/image/image-foundation.d.ts +4 -4
- package/dist/image/image-foundation.js +10 -10
- package/dist/image/preview-footer-foundation.d.ts +3 -3
- package/dist/image/preview-footer-foundation.js +10 -10
- package/dist/image/preview-foundation.js +7 -6
- package/dist/image/preview-image-foundation.d.ts +6 -8
- package/dist/image/preview-image-foundation.js +14 -14
- package/dist/image/preview-inner-foundation.d.ts +9 -9
- package/dist/image/preview-inner-foundation.js +38 -38
- package/dist/input/foundation.d.ts +10 -10
- package/dist/input/foundation.js +47 -49
- package/dist/input/text-entry-foundation.d.ts +3 -3
- package/dist/input/text-entry-foundation.js +14 -14
- package/dist/input/textarea-foundation.d.ts +7 -7
- package/dist/input/textarea-foundation.js +36 -36
- package/dist/input-number/foundation.d.ts +16 -14
- package/dist/input-number/foundation.js +54 -53
- package/dist/json-viewer/foundation.d.ts +8 -8
- package/dist/json-viewer/foundation.js +23 -23
- package/dist/lottie/foundation.d.ts +1 -1
- package/dist/lottie/foundation.js +4 -4
- package/dist/markdown-render/foundation.d.ts +1 -1
- package/dist/markdown-render/foundation.js +4 -4
- package/dist/modal/modal-content-foundation.d.ts +7 -7
- package/dist/modal/modal-content-foundation.js +20 -20
- package/dist/modal/modal-foundation.d.ts +6 -6
- package/dist/modal/modal-foundation.js +24 -24
- package/dist/navigation/foundation.d.ts +1 -1
- package/dist/navigation/foundation.js +14 -14
- package/dist/navigation/item-foundation.d.ts +1 -1
- package/dist/navigation/item-foundation.js +8 -8
- package/dist/navigation/sub-nav-foundation.d.ts +3 -3
- package/dist/navigation/sub-nav-foundation.js +17 -17
- package/dist/notification/notification-list-foundation.d.ts +7 -7
- package/dist/notification/notification-list-foundation.js +12 -12
- package/dist/overflow-list/foundation.d.ts +4 -4
- package/dist/overflow-list/foundation.js +18 -18
- package/dist/pagination/foundation.d.ts +8 -8
- package/dist/pagination/foundation.js +28 -28
- package/dist/pincode/foundation.d.ts +5 -5
- package/dist/pincode/foundation.js +22 -22
- package/dist/popconfirm/popconfirm-foundation.d.ts +7 -7
- package/dist/popconfirm/popconfirm-foundation.js +26 -26
- package/dist/radio/radio-foundation.d.ts +5 -5
- package/dist/radio/radio-foundation.js +15 -15
- package/dist/radio/radio-group-foundation.d.ts +2 -2
- package/dist/radio/radio-group-foundation.js +9 -9
- package/dist/rating/foundation.d.ts +10 -10
- package/dist/rating/foundation.js +35 -35
- package/dist/resizable/group/index.d.ts +6 -6
- package/dist/resizable/group/index.js +40 -40
- package/dist/resizable/single/index.d.ts +2 -2
- package/dist/resizable/single/index.js +9 -9
- package/dist/scroll-list/item-foundation.d.ts +7 -7
- package/dist/scroll-list/item-foundation.js +35 -35
- package/dist/select/foundation.d.ts +42 -56
- package/dist/select/foundation.js +214 -279
- package/dist/select/option-foundation.d.ts +23 -27
- package/dist/select/option-foundation.js +10 -18
- package/dist/side-sheet/side-sheet-foundation.d.ts +6 -6
- package/dist/side-sheet/side-sheet-foundation.js +22 -22
- package/dist/slider/foundation.d.ts +16 -16
- package/dist/slider/foundation.js +46 -46
- package/dist/sortable/accessibility.d.ts +1 -1
- package/dist/sortable/accessibility.js +2 -2
- package/dist/spin/foundation.d.ts +2 -2
- package/dist/spin/foundation.js +6 -6
- package/dist/steps/utils.d.ts +1 -1
- package/dist/switch/foundation.d.ts +2 -2
- package/dist/switch/foundation.js +7 -7
- package/dist/table/foundation.d.ts +14 -14
- package/dist/table/foundation.js +93 -93
- package/dist/table/utils.d.ts +2 -2
- package/dist/tabs/foundation.d.ts +5 -5
- package/dist/tabs/foundation.js +17 -17
- package/dist/tag-input/foundation.d.ts +11 -11
- package/dist/tag-input/foundation.js +52 -52
- package/dist/time-picker/foundation.d.ts +13 -13
- package/dist/time-picker/foundation.js +39 -39
- package/dist/time-picker/input-foundation.d.ts +4 -4
- package/dist/time-picker/input-foundation.js +13 -13
- package/dist/toast/toast-list-foundation.d.ts +7 -7
- package/dist/toast/toast-list-foundation.js +14 -14
- package/dist/tooltip/foundation.d.ts +9 -9
- package/dist/tooltip/foundation.js +67 -61
- package/dist/transfer/foundation.d.ts +22 -9
- package/dist/transfer/foundation.js +38 -23
- package/dist/tree/foundation.d.ts +14 -14
- package/dist/tree/foundation.js +61 -61
- package/dist/tree/shared.d.ts +1 -1
- package/dist/tree-select/foundation.d.ts +26 -20
- package/dist/tree-select/foundation.js +91 -83
- package/dist/typography/ellipsis.d.ts +4 -4
- package/dist/typography/ellipsis.js +8 -8
- package/dist/typography/format-numeral.d.ts +1 -1
- package/dist/typography/format-numeral.js +2 -2
- package/dist/upload/constants.d.ts +1 -1
- package/dist/upload/foundation.d.ts +17 -17
- package/dist/upload/foundation.js +92 -92
- package/dist/upload/utils.d.ts +3 -3
- package/dist/upload/utils.js +6 -6
- package/dist/user-guide/foundation.d.ts +3 -3
- package/dist/user-guide/foundation.js +19 -19
- package/dist/utils/a11y.d.ts +1 -1
- package/dist/utils/announcer.d.ts +2 -2
- package/dist/utils/announcer.js +4 -4
- package/dist/utils/focus-handle.d.ts +1 -1
- package/dist/utils/focus-handle.js +1 -2
- package/dist/utils/focus-scope.d.ts +5 -5
- package/dist/utils/focus-scope.js +10 -10
- package/dist/utils/is-promise.d.ts +1 -1
- package/dist/utils/release-holder.d.ts +2 -2
- package/dist/utils/release-holder.js +4 -4
- package/dist/video-player/foundation.d.ts +15 -15
- package/dist/video-player/foundation.js +89 -89
- package/dist/video-player/progress-foundation.d.ts +2 -2
- package/dist/video-player/progress-foundation.js +12 -12
- package/package.json +2 -2
package/dist/form/foundation.js
CHANGED
|
@@ -38,8 +38,8 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
38
38
|
#unregisterNotifyPending = false;
|
|
39
39
|
constructor(adapter) {
|
|
40
40
|
super(adapter);
|
|
41
|
-
let { initValues } = this.
|
|
42
|
-
initValues = this.
|
|
41
|
+
let { initValues } = this.adapter.getProps();
|
|
42
|
+
initValues = this.adapter.cloneDeep(initValues);
|
|
43
43
|
this.#data = {
|
|
44
44
|
values: initValues ? initValues : {},
|
|
45
45
|
errors: {},
|
|
@@ -50,7 +50,7 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
50
50
|
this.#registeredArrayField = /* @__PURE__ */ new Map();
|
|
51
51
|
}
|
|
52
52
|
#forceUpdate(callback) {
|
|
53
|
-
this.
|
|
53
|
+
this.adapter.forceUpdate(this.getFormState(), callback);
|
|
54
54
|
}
|
|
55
55
|
#updateField(store, snapshot) {
|
|
56
56
|
if (!store.update(snapshot)) return;
|
|
@@ -77,7 +77,7 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
77
77
|
errors: {}
|
|
78
78
|
};
|
|
79
79
|
this.#injectErrorToField({});
|
|
80
|
-
this.
|
|
80
|
+
this.adapter.notifyChange(this.#data);
|
|
81
81
|
this.#notifyErrorChange(prevErrors, this.#fields.keys());
|
|
82
82
|
this.#forceUpdate();
|
|
83
83
|
}
|
|
@@ -89,7 +89,7 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
89
89
|
errors: formErrors
|
|
90
90
|
};
|
|
91
91
|
this.#injectErrorToField(formErrors);
|
|
92
|
-
this.
|
|
92
|
+
this.adapter.notifyChange(this.#data);
|
|
93
93
|
this.#notifyErrorChange(prevErrors, this.#fields.keys());
|
|
94
94
|
this.#forceUpdate(() => this.#autoScroll());
|
|
95
95
|
}
|
|
@@ -103,7 +103,7 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
103
103
|
const error = get$1(this.#data.errors, path);
|
|
104
104
|
if (error !== get$1(prevErrors, path)) changedError[path] = error;
|
|
105
105
|
}
|
|
106
|
-
if (Object.keys(changedError).length) this.
|
|
106
|
+
if (Object.keys(changedError).length) this.adapter.notifyErrorChange(this.#data.errors, changedError);
|
|
107
107
|
}
|
|
108
108
|
#isCancelled(epoch) {
|
|
109
109
|
return this.#destroyed || epoch !== this.#epoch;
|
|
@@ -118,7 +118,7 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
118
118
|
const writes = () => validation === this.#formValidation;
|
|
119
119
|
return new Promise((resolve, reject) => {
|
|
120
120
|
const pass = () => {
|
|
121
|
-
resolve(this.
|
|
121
|
+
resolve(this.adapter.cloneDeep(this.#data.values));
|
|
122
122
|
if (writes()) this.#clearFormErrors();
|
|
123
123
|
};
|
|
124
124
|
const fail = (errors) => {
|
|
@@ -183,11 +183,11 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
183
183
|
valid = isEmpty(errors);
|
|
184
184
|
}
|
|
185
185
|
if (!silent) {
|
|
186
|
-
this.
|
|
186
|
+
this.adapter.notifyChange(this.#data);
|
|
187
187
|
this.#notifyErrorChange(prevErrors, paths);
|
|
188
188
|
this.#forceUpdate(valid ? void 0 : () => this.#autoScroll());
|
|
189
189
|
}
|
|
190
|
-
if (valid) resolve(this.
|
|
190
|
+
if (valid) resolve(this.adapter.cloneDeep(this.#data.values));
|
|
191
191
|
else reject(errors);
|
|
192
192
|
});
|
|
193
193
|
});
|
|
@@ -239,7 +239,7 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
239
239
|
const arrayFieldPaths = [...this.#registeredArrayField.keys()].filter((path) => fieldPaths === void 0 || fieldPaths.some((target) => isPathWithin(path, target)));
|
|
240
240
|
arrayFieldPaths.forEach((path) => {
|
|
241
241
|
const arrayFieldState = this.#registeredArrayField.get(path);
|
|
242
|
-
const arrayFieldInitValue = this.
|
|
242
|
+
const arrayFieldInitValue = this.adapter.cloneDeep(arrayFieldState.initValue);
|
|
243
243
|
this.#updateStateValue(path, arrayFieldInitValue, {
|
|
244
244
|
skipNotify: true,
|
|
245
245
|
skipRender: true
|
|
@@ -452,7 +452,7 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
452
452
|
this.#unregisterNotifyPending = true;
|
|
453
453
|
this.#forceUpdate(() => {
|
|
454
454
|
this.#unregisterNotifyPending = false;
|
|
455
|
-
this.
|
|
455
|
+
this.adapter.notifyChange(this.#data);
|
|
456
456
|
});
|
|
457
457
|
};
|
|
458
458
|
#registerArrayField = (arrayFieldPath, val) => {
|
|
@@ -485,14 +485,14 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
485
485
|
value: this.#getValue(item.path)
|
|
486
486
|
}));
|
|
487
487
|
this.#registerArrayField(arrayFieldPath, val);
|
|
488
|
-
this.#updateStateValue(arrayFieldPath, this.
|
|
488
|
+
this.#updateStateValue(arrayFieldPath, this.adapter.cloneDeep(val), SILENT);
|
|
489
489
|
nestedValues.forEach(({ path, allowEmpty, value }) => {
|
|
490
490
|
this.#updateStateValue(path, value, {
|
|
491
491
|
...SILENT,
|
|
492
492
|
allowEmpty
|
|
493
493
|
});
|
|
494
494
|
});
|
|
495
|
-
this.#updateArrayField(arrayFieldPath, { initValue: this.
|
|
495
|
+
this.#updateArrayField(arrayFieldPath, { initValue: this.adapter.cloneDeep(this.#getValue(arrayFieldPath)) });
|
|
496
496
|
this.#forceUpdate();
|
|
497
497
|
};
|
|
498
498
|
/** Inserts an empty row before `index`, or appends one without it; returns the ArrayField's new updateKey */
|
|
@@ -513,7 +513,7 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
513
513
|
const values = this.#getValue(arrayFieldPath);
|
|
514
514
|
const rows = values ? values.slice() : [];
|
|
515
515
|
const rowIndex = typeof index === "number" ? Math.max(0, Math.min(index, rows.length)) : rows.length;
|
|
516
|
-
rows.splice(rowIndex, 0, this.
|
|
516
|
+
rows.splice(rowIndex, 0, this.adapter.cloneDeep(rowValue));
|
|
517
517
|
const updateKey = nextUpdateKey();
|
|
518
518
|
this.#updateArrayField(arrayFieldPath, { updateKey });
|
|
519
519
|
this.#updateStateValue(arrayFieldPath, rows, {});
|
|
@@ -535,13 +535,13 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
535
535
|
#getArrayField = (arrayField) => {
|
|
536
536
|
return this.#registeredArrayField.get(arrayField);
|
|
537
537
|
};
|
|
538
|
-
#updateArrayField
|
|
538
|
+
#updateArrayField(arrayField, updateValue) {
|
|
539
539
|
const mergeVal = {
|
|
540
540
|
...this.#registeredArrayField.get(arrayField),
|
|
541
541
|
...updateValue
|
|
542
542
|
};
|
|
543
543
|
this.#registeredArrayField.set(arrayField, mergeVal);
|
|
544
|
-
}
|
|
544
|
+
}
|
|
545
545
|
#validate(fieldPaths) {
|
|
546
546
|
const { validator } = this.getProps();
|
|
547
547
|
let fields;
|
|
@@ -565,10 +565,10 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
565
565
|
}
|
|
566
566
|
#getValue = (field, opts) => {
|
|
567
567
|
const value = typeof field === "undefined" ? { ...this.#data.values } : get$1(this.#data.values, field);
|
|
568
|
-
return opts?.needClone ? this.
|
|
568
|
+
return opts?.needClone ? this.adapter.cloneDeep(value) : value;
|
|
569
569
|
};
|
|
570
|
-
#setValues
|
|
571
|
-
const _values = this.
|
|
570
|
+
#setValues(values, { isOverride = false }) {
|
|
571
|
+
const _values = this.adapter.cloneDeep(values);
|
|
572
572
|
this.#fields.forEach((field) => {
|
|
573
573
|
const value = get$1(_values, field.field);
|
|
574
574
|
const opts = {
|
|
@@ -585,10 +585,10 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
585
585
|
...this.#data,
|
|
586
586
|
values: _values
|
|
587
587
|
};
|
|
588
|
-
this.
|
|
589
|
-
this.
|
|
588
|
+
this.adapter.notifyChange(this.#data);
|
|
589
|
+
this.adapter.notifyValueChange(this.#data.values, { ...values });
|
|
590
590
|
this.#forceUpdate();
|
|
591
|
-
}
|
|
591
|
+
}
|
|
592
592
|
#updateStateValue = (field, value, opts, callback) => {
|
|
593
593
|
const skipNotify = opts && opts.skipNotify;
|
|
594
594
|
const skipRender = opts && opts.skipRender;
|
|
@@ -598,8 +598,8 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
598
598
|
values: set$1(this.#data.values, field, value, allowEmpty)
|
|
599
599
|
};
|
|
600
600
|
if (!skipNotify) {
|
|
601
|
-
this.
|
|
602
|
-
this.
|
|
601
|
+
this.adapter.notifyChange(this.#data);
|
|
602
|
+
this.adapter.notifyValueChange(this.#data.values, { [field]: value });
|
|
603
603
|
}
|
|
604
604
|
if (!skipRender) this.#forceUpdate(callback);
|
|
605
605
|
};
|
|
@@ -614,7 +614,7 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
614
614
|
...this.#data,
|
|
615
615
|
touched: set$1(this.#data.touched, field, isTouched)
|
|
616
616
|
};
|
|
617
|
-
if (!skipNotify) this.
|
|
617
|
+
if (!skipNotify) this.adapter.notifyChange(this.#data);
|
|
618
618
|
if (!skipRender) this.#forceUpdate(callback);
|
|
619
619
|
};
|
|
620
620
|
#getError = (field) => {
|
|
@@ -629,14 +629,13 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
629
629
|
errors: set$1(this.#data.errors, field, error)
|
|
630
630
|
};
|
|
631
631
|
if (!skipNotify) {
|
|
632
|
-
this.
|
|
633
|
-
this.
|
|
632
|
+
this.adapter.notifyChange(this.#data);
|
|
633
|
+
this.adapter.notifyErrorChange(this.#data.errors, { [field]: error });
|
|
634
634
|
}
|
|
635
635
|
if (!skipRender) this.#forceUpdate(callback);
|
|
636
636
|
};
|
|
637
|
-
#setFieldError = (
|
|
637
|
+
#setFieldError = ({ store, field }, error, opts) => {
|
|
638
638
|
if (opts?.silent) return;
|
|
639
|
-
const { store, field } = registration;
|
|
640
639
|
this.#batch(() => {
|
|
641
640
|
if (opts?.status) this.#updateField(store, { status: opts.status });
|
|
642
641
|
if (error === store.getSnapshot().error) return;
|
|
@@ -698,35 +697,35 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
698
697
|
return {
|
|
699
698
|
setValue: (field, value, opts) => {
|
|
700
699
|
this.#getOperateFieldMap([field]).forEach((_, path) => this.#validations.delete(path));
|
|
701
|
-
this.#setByPath("values", field, this.
|
|
700
|
+
this.#setByPath("values", field, this.adapter.cloneDeep(value), opts);
|
|
702
701
|
},
|
|
703
|
-
setError: (field, error, opts) => this.#setByPath("errors", field, this.
|
|
702
|
+
setError: (field, error, opts) => this.#setByPath("errors", field, this.adapter.cloneDeep(error), opts),
|
|
704
703
|
setTouched: (field, isTouched, opts) => this.#setByPath("touched", field, isTouched, opts)
|
|
705
704
|
};
|
|
706
705
|
}
|
|
707
|
-
#getFieldExist
|
|
706
|
+
#getFieldExist(field) {
|
|
708
707
|
return Boolean(this.#fields.has(field));
|
|
709
|
-
}
|
|
708
|
+
}
|
|
710
709
|
#getFieldDOM(field) {
|
|
711
|
-
return this.
|
|
710
|
+
return this.adapter.getFormElement()?.querySelector(`.${prefix}-field[x-field-id="${CSS.escape(field)}"]`) ?? null;
|
|
712
711
|
}
|
|
713
712
|
/** The root elements of the fields showing an error message, in document order */
|
|
714
713
|
#getErrorFieldDOMs() {
|
|
715
|
-
const errorDOMs = this.
|
|
714
|
+
const errorDOMs = this.adapter.getFormElement()?.querySelectorAll(ERROR_SELECTOR) ?? [];
|
|
716
715
|
return Array.from(errorDOMs, errorField).filter((fieldDOM) => fieldDOM !== null);
|
|
717
716
|
}
|
|
718
717
|
#getErrorFieldDOM(field) {
|
|
719
718
|
const errorDOM = this.#getFieldDOM(field)?.querySelector(ERROR_SELECTOR);
|
|
720
719
|
return errorDOM && errorField(errorDOM);
|
|
721
720
|
}
|
|
722
|
-
#scrollToField
|
|
721
|
+
#scrollToField(field, scrollOpts = {
|
|
723
722
|
behavior: "smooth",
|
|
724
723
|
block: "start"
|
|
725
|
-
})
|
|
724
|
+
}) {
|
|
726
725
|
const fieldDOM = this.#getFieldExist(field) ? this.#getFieldDOM(field) : null;
|
|
727
726
|
if (fieldDOM) scrollIntoView$1(fieldDOM, scrollOpts);
|
|
728
|
-
}
|
|
729
|
-
#scrollToError
|
|
727
|
+
}
|
|
728
|
+
#scrollToError(config) {
|
|
730
729
|
const { field, index, scrollOpts = {
|
|
731
730
|
behavior: "smooth",
|
|
732
731
|
block: "start"
|
|
@@ -736,16 +735,16 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
736
735
|
else if (field) fieldDOM = this.#getErrorFieldDOM(field);
|
|
737
736
|
else if (typeof field === "undefined") fieldDOM = this.#getErrorFieldDOMs()[0];
|
|
738
737
|
if (fieldDOM) scrollIntoView$1(fieldDOM, scrollOpts);
|
|
739
|
-
}
|
|
738
|
+
}
|
|
740
739
|
getInitValues() {
|
|
741
|
-
return this.
|
|
740
|
+
return this.adapter.getInitValues();
|
|
742
741
|
}
|
|
743
742
|
getInitValue(field) {
|
|
744
|
-
if (typeof field === "undefined") return this.
|
|
745
|
-
return get$1(this.
|
|
743
|
+
if (typeof field === "undefined") return this.adapter.getInitValues();
|
|
744
|
+
return get$1(this.adapter.getInitValues(), field);
|
|
746
745
|
}
|
|
747
746
|
getFormProps(keys) {
|
|
748
|
-
return this.
|
|
747
|
+
return this.adapter.getFormProps(keys);
|
|
749
748
|
}
|
|
750
749
|
init() {
|
|
751
750
|
this.#destroyed = false;
|
|
@@ -753,39 +752,39 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
753
752
|
destroy() {
|
|
754
753
|
this.#destroyed = true;
|
|
755
754
|
}
|
|
756
|
-
submit(e) {
|
|
755
|
+
submit = (e) => {
|
|
757
756
|
const epoch = this.#epoch;
|
|
758
757
|
this.#validate().then((resolveValues) => {
|
|
759
758
|
if (this.#isCancelled(epoch)) return;
|
|
760
|
-
const _values = this.
|
|
761
|
-
this.
|
|
759
|
+
const _values = this.adapter.cloneDeep(resolveValues);
|
|
760
|
+
this.adapter.notifySubmit(_values, e);
|
|
762
761
|
}, (errors) => {
|
|
763
762
|
if (this.#isCancelled(epoch)) return;
|
|
764
|
-
const _errors = this.
|
|
765
|
-
const _values = this.
|
|
766
|
-
this.
|
|
763
|
+
const _errors = this.adapter.cloneDeep(errors);
|
|
764
|
+
const _values = this.adapter.cloneDeep(this.#data.values);
|
|
765
|
+
this.adapter.notifySubmitFail(_errors, _values, e);
|
|
767
766
|
});
|
|
768
|
-
}
|
|
769
|
-
reset(fieldPaths) {
|
|
767
|
+
};
|
|
768
|
+
reset = (fieldPaths) => {
|
|
770
769
|
const targetFields = this.#getOperateFieldMap(fieldPaths);
|
|
771
770
|
if (fieldPaths === void 0) this.#epoch += 1;
|
|
772
771
|
else targetFields.forEach((_, path) => this.#validations.delete(path));
|
|
773
772
|
const prevErrors = this.#data.errors;
|
|
774
773
|
this.#batch(() => {
|
|
775
774
|
targetFields.forEach((field) => {
|
|
776
|
-
this.#setFieldValue(field, field.initValue !== null ? this.
|
|
775
|
+
this.#setFieldValue(field, field.initValue !== null ? this.adapter.cloneDeep(field.initValue) : void 0, SILENT);
|
|
777
776
|
this.#setFieldError(field, void 0, SILENT);
|
|
778
777
|
this.#setFieldTouched(field, void 0, SILENT);
|
|
779
778
|
this.#updateField(field.store, { status: "default" });
|
|
780
779
|
});
|
|
781
780
|
});
|
|
782
781
|
if (this.#registeredArrayField.size) this.#resetArrayField(fieldPaths);
|
|
783
|
-
this.
|
|
782
|
+
this.adapter.notifyChange(this.#data);
|
|
784
783
|
this.#notifyErrorChange(prevErrors, targetFields.keys());
|
|
785
784
|
this.#forceUpdate();
|
|
786
|
-
this.
|
|
787
|
-
}
|
|
788
|
-
getFieldBridge() {
|
|
785
|
+
this.adapter.notifyReset();
|
|
786
|
+
};
|
|
787
|
+
getFieldBridge = () => {
|
|
789
788
|
return {
|
|
790
789
|
register: this.#register,
|
|
791
790
|
unRegister: this.#unRegister,
|
|
@@ -807,8 +806,8 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
807
806
|
addArrayFieldRowWithValue: this.#addArrayFieldRowWithValue,
|
|
808
807
|
removeArrayFieldRow: this.#removeArrayFieldRow
|
|
809
808
|
};
|
|
810
|
-
}
|
|
811
|
-
getFormApi() {
|
|
809
|
+
};
|
|
810
|
+
getFormApi = () => {
|
|
812
811
|
return {
|
|
813
812
|
...this.#getFieldSetterApi(),
|
|
814
813
|
reset: (fields) => this.reset(fields),
|
|
@@ -827,10 +826,10 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
827
826
|
scrollToField: (field, scrollOpts) => this.#scrollToField(field, scrollOpts),
|
|
828
827
|
scrollToError: (opts) => this.#scrollToError(opts)
|
|
829
828
|
};
|
|
830
|
-
}
|
|
829
|
+
};
|
|
831
830
|
getFormState = (needClone = false) => {
|
|
832
831
|
if (!needClone) return { ...this.#data };
|
|
833
|
-
else return this.
|
|
832
|
+
else return this.adapter.cloneDeep(this.#data);
|
|
834
833
|
};
|
|
835
834
|
};
|
|
836
835
|
export { FormFoundation as default };
|
|
@@ -20,7 +20,7 @@ function findChunks({ autoEscape, caseSensitive, searchWords, sourceString }) {
|
|
|
20
20
|
}, []);
|
|
21
21
|
}
|
|
22
22
|
function combineChunks({ chunks }) {
|
|
23
|
-
return chunks.
|
|
23
|
+
return chunks.toSorted((first, second) => first.start - second.start).reduce((processedChunks, nextChunk) => {
|
|
24
24
|
if (processedChunks.length === 0) return [nextChunk];
|
|
25
25
|
else {
|
|
26
26
|
const prevChunk = processedChunks.pop();
|
|
@@ -12,8 +12,8 @@ export default class HotKeysFoundation<P extends HotKeysBaseProps = HotKeysBaseP
|
|
|
12
12
|
#private;
|
|
13
13
|
init(): void;
|
|
14
14
|
/** Applies the same check as mounting, so an invalid combination set later fails just as loudly */
|
|
15
|
-
handleHotKeysChange()
|
|
15
|
+
handleHotKeysChange: () => void;
|
|
16
16
|
/** Moves the keydown listener when `getListenerTarget` now returns a different element */
|
|
17
|
-
handleTargetChange()
|
|
17
|
+
handleTargetChange: () => void;
|
|
18
18
|
destroy(): void;
|
|
19
19
|
}
|
|
@@ -63,7 +63,7 @@ var HotKeysFoundation = class extends BaseFoundation {
|
|
|
63
63
|
if (!allModifier.every((value, index) => value === clickedModifier[index])) return;
|
|
64
64
|
if (keysPressed.every(Boolean)) {
|
|
65
65
|
if (preventDefault) event.preventDefault();
|
|
66
|
-
this.
|
|
66
|
+
this.adapter.notifyHotKey(event);
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
};
|
|
@@ -75,16 +75,16 @@ var HotKeysFoundation = class extends BaseFoundation {
|
|
|
75
75
|
this.#bind();
|
|
76
76
|
}
|
|
77
77
|
/** Applies the same check as mounting, so an invalid combination set later fails just as loudly */
|
|
78
|
-
handleHotKeysChange() {
|
|
78
|
+
handleHotKeysChange = () => {
|
|
79
79
|
this.#validate();
|
|
80
|
-
}
|
|
80
|
+
};
|
|
81
81
|
/** Moves the keydown listener when `getListenerTarget` now returns a different element */
|
|
82
|
-
handleTargetChange() {
|
|
82
|
+
handleTargetChange = () => {
|
|
83
83
|
if (this.#getTarget() !== this.#target) {
|
|
84
84
|
this.#unbind();
|
|
85
85
|
this.#bind();
|
|
86
86
|
}
|
|
87
|
-
}
|
|
87
|
+
};
|
|
88
88
|
destroy() {
|
|
89
89
|
this.#unbind();
|
|
90
90
|
}
|
|
@@ -22,9 +22,9 @@ export default class ImageFoundation<P extends ImageBaseProps = ImageBaseProps,
|
|
|
22
22
|
static canOpen(preview: ImageBaseProps['preview'], loadStatus: ImageLoadStatus, isInGroup: boolean): boolean;
|
|
23
23
|
/** The lone image's own preview stays mounted while the thumbnail loads, so an open preview survives a reload, a controlled visible need not wait for it, and closing it can restore focus */
|
|
24
24
|
static canPreview(preview: ImageBaseProps['preview'], isInGroup: boolean): boolean;
|
|
25
|
-
handleClick: (_e:
|
|
26
|
-
handleKeyDown: (e:
|
|
27
|
-
handleLoaded: (e:
|
|
28
|
-
handleError: (e:
|
|
25
|
+
handleClick: (_e: unknown) => void;
|
|
26
|
+
handleKeyDown: (e: Pick<KeyboardEvent, "currentTarget" | "key" | "preventDefault" | "target">) => void;
|
|
27
|
+
handleLoaded: (e: unknown) => void;
|
|
28
|
+
handleError: (e: unknown) => void;
|
|
29
29
|
handlePreviewVisibleChange: (newVisible: boolean) => void;
|
|
30
30
|
}
|
|
@@ -12,29 +12,29 @@ var ImageFoundation = class extends BaseFoundation {
|
|
|
12
12
|
handleClick = (_e) => {
|
|
13
13
|
const { preview } = this.getProps();
|
|
14
14
|
if (!preview) return;
|
|
15
|
-
if (this.
|
|
15
|
+
if (this.adapter.getIsInGroup()) this.adapter.openGroupPreview();
|
|
16
16
|
else this.handlePreviewVisibleChange(true);
|
|
17
17
|
};
|
|
18
18
|
handleKeyDown = (e) => {
|
|
19
|
-
if (e.target === e.currentTarget && (e.key === "Enter" || e.key === " ")) {
|
|
19
|
+
if (e.target === e.currentTarget && e.currentTarget instanceof HTMLElement && (e.key === "Enter" || e.key === " ")) {
|
|
20
20
|
e.preventDefault();
|
|
21
|
-
e.currentTarget.querySelector(":scope > img")
|
|
21
|
+
e.currentTarget.querySelector(":scope > img")?.click();
|
|
22
22
|
}
|
|
23
23
|
};
|
|
24
24
|
handleLoaded = (e) => {
|
|
25
|
-
this.
|
|
26
|
-
this.
|
|
25
|
+
this.adapter.notifyLoad(e);
|
|
26
|
+
this.adapter.setLoadStatus("success");
|
|
27
27
|
};
|
|
28
28
|
handleError = (e) => {
|
|
29
|
-
this.
|
|
30
|
-
this.
|
|
29
|
+
this.adapter.notifyError(e);
|
|
30
|
+
this.adapter.setLoadStatus("error");
|
|
31
31
|
};
|
|
32
32
|
handlePreviewVisibleChange = (newVisible) => {
|
|
33
33
|
const { preview } = this.getProps();
|
|
34
34
|
if (typeof preview === "object" && preview !== null) {
|
|
35
|
-
this.
|
|
36
|
-
if (preview.visible === void 0) this.
|
|
37
|
-
} else this.
|
|
35
|
+
this.adapter.notifyPreviewVisibleChange(newVisible);
|
|
36
|
+
if (preview.visible === void 0) this.adapter.setPreviewVisible(newVisible);
|
|
37
|
+
} else this.adapter.setPreviewVisible(newVisible);
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
export { ImageFoundation as default };
|
|
@@ -20,7 +20,7 @@ export default class PreviewFooterFoundation<P extends PreviewFooterBaseProps =
|
|
|
20
20
|
protected handleValueChange(value: number): void;
|
|
21
21
|
handleSlideChange: ThrottledFunction<(value: number | number[]) => void>;
|
|
22
22
|
destroy(): void;
|
|
23
|
-
changeSliderValue(type:
|
|
24
|
-
handleRatioClick()
|
|
25
|
-
handleRotate(direction: RotateDirection)
|
|
23
|
+
changeSliderValue: (type: "plus" | "minus") => void;
|
|
24
|
+
handleRatioClick: () => void;
|
|
25
|
+
handleRotate: (direction: RotateDirection) => void;
|
|
26
26
|
}
|
|
@@ -5,8 +5,8 @@ import { throttle } from "es-toolkit";
|
|
|
5
5
|
var PreviewFooterFoundation = class extends BaseFoundation {
|
|
6
6
|
handleValueChange(value) {
|
|
7
7
|
const { zoom } = this.getProps();
|
|
8
|
-
if (value > zoom) this.
|
|
9
|
-
else this.
|
|
8
|
+
if (value > zoom) this.adapter.notifyZoomIn(Number((value / 100).toFixed(2)));
|
|
9
|
+
else this.adapter.notifyZoomOut(Number((value / 100).toFixed(2)));
|
|
10
10
|
}
|
|
11
11
|
handleSlideChange = throttle((value) => {
|
|
12
12
|
this.handleValueChange(value);
|
|
@@ -14,17 +14,17 @@ var PreviewFooterFoundation = class extends BaseFoundation {
|
|
|
14
14
|
destroy() {
|
|
15
15
|
this.handleSlideChange.cancel();
|
|
16
16
|
}
|
|
17
|
-
changeSliderValue(type) {
|
|
17
|
+
changeSliderValue = (type) => {
|
|
18
18
|
const { zoom, step, min, max } = this.getProps();
|
|
19
19
|
this.handleValueChange(clampZoom(type === "plus" ? zoom + step : zoom - step, min, max));
|
|
20
|
-
}
|
|
21
|
-
handleRatioClick() {
|
|
20
|
+
};
|
|
21
|
+
handleRatioClick = () => {
|
|
22
22
|
const { ratio } = this.getProps();
|
|
23
23
|
const type = ratio === "adaptation" ? "realSize" : "adaptation";
|
|
24
|
-
this.
|
|
25
|
-
}
|
|
26
|
-
handleRotate(direction) {
|
|
27
|
-
this.
|
|
28
|
-
}
|
|
24
|
+
this.adapter.notifyAdjustRatio(type);
|
|
25
|
+
};
|
|
26
|
+
handleRotate = (direction) => {
|
|
27
|
+
this.adapter.notifyRotate(direction);
|
|
28
|
+
};
|
|
29
29
|
};
|
|
30
30
|
export { PreviewFooterFoundation as default };
|
|
@@ -23,7 +23,8 @@ function getGroupPreviewList(src, images) {
|
|
|
23
23
|
/** Gives the imgs that entered the viewport their src; a loaded img has no data-src left and is skipped */
|
|
24
24
|
function loadLazyImages(entries, observer) {
|
|
25
25
|
for (const entry of entries) {
|
|
26
|
-
const target = entry
|
|
26
|
+
const { target } = entry;
|
|
27
|
+
if (!(target instanceof HTMLImageElement)) continue;
|
|
27
28
|
const lazySrc = target.dataset.src;
|
|
28
29
|
if (entry.isIntersecting && lazySrc) {
|
|
29
30
|
target.src = lazySrc;
|
|
@@ -35,7 +36,7 @@ function loadLazyImages(entries, observer) {
|
|
|
35
36
|
var PreviewFoundation = class extends BaseFoundation {
|
|
36
37
|
#images = /* @__PURE__ */ new Map();
|
|
37
38
|
#syncImages() {
|
|
38
|
-
const images = [...this.#images.values()].
|
|
39
|
+
const images = [...this.#images.values()].toSorted(byDocumentOrder);
|
|
39
40
|
const current = this.getState("images") ?? [];
|
|
40
41
|
if (images.length !== current.length || images.some((image, i) => image !== current[i])) this.setState({ images });
|
|
41
42
|
return images;
|
|
@@ -59,12 +60,12 @@ var PreviewFoundation = class extends BaseFoundation {
|
|
|
59
60
|
this.handleVisibleChange(true);
|
|
60
61
|
};
|
|
61
62
|
handleVisibleChange = (newVisible) => {
|
|
62
|
-
if (!this.
|
|
63
|
-
this.
|
|
63
|
+
if (!this.isControlledComponent("visible")) this.setState({ visible: newVisible });
|
|
64
|
+
this.adapter.notifyVisibleChange(newVisible);
|
|
64
65
|
};
|
|
65
66
|
handleCurrentIndexChange = (index) => {
|
|
66
|
-
if (!this.
|
|
67
|
-
this.
|
|
67
|
+
if (!this.isControlledComponent("currentIndex")) this.setState({ currentIndex: index });
|
|
68
|
+
this.adapter.notifyChange(index);
|
|
68
69
|
};
|
|
69
70
|
};
|
|
70
71
|
export { PreviewFoundation as default, getGroupPreviewList, loadLazyImages };
|
|
@@ -54,17 +54,15 @@ export default class PreviewImageFoundation<P extends PreviewImageBaseProps = Pr
|
|
|
54
54
|
};
|
|
55
55
|
init(): void;
|
|
56
56
|
handleWindowResize: () => void;
|
|
57
|
-
handleLoad: (e:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
handleError: (_e: any) => void;
|
|
61
|
-
handlePropsUpdate(prevProps: {
|
|
57
|
+
handleLoad: (e: Pick<Event, "target">) => void;
|
|
58
|
+
handleError: (_e: unknown) => void;
|
|
59
|
+
handlePropsUpdate: (prevProps: {
|
|
62
60
|
src?: string;
|
|
63
61
|
ratio?: string;
|
|
64
62
|
rotation?: number;
|
|
65
63
|
zoom?: number;
|
|
66
|
-
}, zoomEvent?: WheelEvent)
|
|
67
|
-
handleRightClickImage: (e:
|
|
68
|
-
handleImageMove(e: Pick<PointerEvent,
|
|
64
|
+
}, zoomEvent?: WheelEvent) => void;
|
|
65
|
+
handleRightClickImage: (e: Pick<Event, "preventDefault" | "stopPropagation">) => boolean;
|
|
66
|
+
handleImageMove: (e: Pick<PointerEvent, "buttons" | "clientX" | "clientY">) => void;
|
|
69
67
|
handleImagePointerDown: (e: Pick<PointerEvent, "button" | "clientX" | "clientY" | "pointerId">) => void;
|
|
70
68
|
}
|
|
@@ -25,7 +25,7 @@ var PreviewImageFoundation = class extends BaseFoundation {
|
|
|
25
25
|
return clampZoom(zoom, minZoom, maxZoom);
|
|
26
26
|
}
|
|
27
27
|
#getContainerBoundingRectSize() {
|
|
28
|
-
const containerDOM = this.
|
|
28
|
+
const containerDOM = this.adapter.getContainer();
|
|
29
29
|
if (containerDOM) {
|
|
30
30
|
this.#containerWidth = containerDOM.clientWidth;
|
|
31
31
|
this.#containerHeight = containerDOM.clientHeight;
|
|
@@ -33,7 +33,7 @@ var PreviewImageFoundation = class extends BaseFoundation {
|
|
|
33
33
|
}
|
|
34
34
|
#getAdaptationZoom() {
|
|
35
35
|
let _zoom = 1;
|
|
36
|
-
if (this.
|
|
36
|
+
if (this.adapter.getContainer() && this.#originImageWidth && this.#originImageHeight) {
|
|
37
37
|
const { rotation } = this.getProps();
|
|
38
38
|
const { width: imageWidth, height: imageHeight } = this.calcBoundingRectSize(this.#originImageWidth, this.#originImageHeight, rotation);
|
|
39
39
|
const reservedWidth = this.#containerWidth - 80;
|
|
@@ -54,7 +54,7 @@ var PreviewImageFoundation = class extends BaseFoundation {
|
|
|
54
54
|
return this.#clampZoom(_zoom);
|
|
55
55
|
}
|
|
56
56
|
#setLoading(loading) {
|
|
57
|
-
this.
|
|
57
|
+
this.adapter.setLoading(loading);
|
|
58
58
|
}
|
|
59
59
|
#handleRatioChange() {
|
|
60
60
|
this.#initializeImage();
|
|
@@ -62,7 +62,7 @@ var PreviewImageFoundation = class extends BaseFoundation {
|
|
|
62
62
|
#initializeImageZoom(reportToUser = true) {
|
|
63
63
|
const { zoom } = this.getProps();
|
|
64
64
|
const _zoom = this.#getInitialZoom();
|
|
65
|
-
if (zoom !== _zoom) this.
|
|
65
|
+
if (zoom !== _zoom) this.adapter.requestZoom(_zoom, reportToUser);
|
|
66
66
|
else this.#applyZoom(zoom);
|
|
67
67
|
}
|
|
68
68
|
#initializeTranslate() {
|
|
@@ -92,7 +92,7 @@ var PreviewImageFoundation = class extends BaseFoundation {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
#applyZoom(prevZoom, e) {
|
|
95
|
-
const imageDOM = this.
|
|
95
|
+
const imageDOM = this.adapter.getImage();
|
|
96
96
|
const { translate, width, height } = this.getStates();
|
|
97
97
|
const { rotation, zoom: newZoom } = this.getProps();
|
|
98
98
|
const changeScale = newZoom / (prevZoom || 1);
|
|
@@ -135,7 +135,7 @@ var PreviewImageFoundation = class extends BaseFoundation {
|
|
|
135
135
|
if (imageDOM) {
|
|
136
136
|
const { canDragVertical, canDragHorizontal } = this.getCanDragDirection(newImageBound.width, newImageBound.height);
|
|
137
137
|
const canDrag = canDragVertical || canDragHorizontal;
|
|
138
|
-
this.
|
|
138
|
+
this.adapter.setImageCursor(canDrag);
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
calcBoundingRectSize(width = 0, height = 0, rotation = 0) {
|
|
@@ -179,7 +179,7 @@ var PreviewImageFoundation = class extends BaseFoundation {
|
|
|
179
179
|
this.#initializeImage();
|
|
180
180
|
};
|
|
181
181
|
handleLoad = (e) => {
|
|
182
|
-
if (e.target) {
|
|
182
|
+
if (e.target instanceof HTMLImageElement) {
|
|
183
183
|
const { naturalWidth: w, naturalHeight: h } = e.target;
|
|
184
184
|
this.#originImageHeight = h;
|
|
185
185
|
this.#originImageWidth = w;
|
|
@@ -187,13 +187,13 @@ var PreviewImageFoundation = class extends BaseFoundation {
|
|
|
187
187
|
this.setState({ loading: false });
|
|
188
188
|
this.#initializeImage(false);
|
|
189
189
|
}
|
|
190
|
-
this.
|
|
190
|
+
this.adapter.notifyLoad(this.getProp("src"));
|
|
191
191
|
};
|
|
192
192
|
handleError = (_e) => {
|
|
193
193
|
this.setState({ loading: false });
|
|
194
|
-
this.
|
|
194
|
+
this.adapter.notifyError(this.getProp("src"));
|
|
195
195
|
};
|
|
196
|
-
handlePropsUpdate(prevProps, zoomEvent) {
|
|
196
|
+
handlePropsUpdate = (prevProps, zoomEvent) => {
|
|
197
197
|
const { zoom, src, ratio, rotation } = this.getProps();
|
|
198
198
|
const srcChange = src && src !== prevProps.src;
|
|
199
199
|
if (srcChange) this.#setLoading(true);
|
|
@@ -202,7 +202,7 @@ var PreviewImageFoundation = class extends BaseFoundation {
|
|
|
202
202
|
if (ratio !== prevProps.ratio) this.#handleRatioChange();
|
|
203
203
|
if (rotation !== prevProps.rotation) this.handleWindowResize();
|
|
204
204
|
}
|
|
205
|
-
}
|
|
205
|
+
};
|
|
206
206
|
handleRightClickImage = (e) => {
|
|
207
207
|
const { disableDownload } = this.getProps();
|
|
208
208
|
if (disableDownload) {
|
|
@@ -211,16 +211,16 @@ var PreviewImageFoundation = class extends BaseFoundation {
|
|
|
211
211
|
return false;
|
|
212
212
|
} else return true;
|
|
213
213
|
};
|
|
214
|
-
handleImageMove(e) {
|
|
214
|
+
handleImageMove = (e) => {
|
|
215
215
|
if (e.buttons === 1) this.#moveImage(e);
|
|
216
|
-
}
|
|
216
|
+
};
|
|
217
217
|
handleImagePointerDown = (e) => {
|
|
218
218
|
if (isSecondaryPress(e)) return;
|
|
219
219
|
this.#startMouseClientPosition = {
|
|
220
220
|
x: e.clientX,
|
|
221
221
|
y: e.clientY
|
|
222
222
|
};
|
|
223
|
-
this.
|
|
223
|
+
this.adapter.capturePointer(e.pointerId);
|
|
224
224
|
};
|
|
225
225
|
};
|
|
226
226
|
export { PreviewImageFoundation as default };
|