@fibrae/semi-foundation 0.1.1 → 0.3.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 -4
- package/dist/anchor/foundation.js +21 -22
- package/dist/audio-player/foundation.d.ts +10 -13
- package/dist/audio-player/foundation.js +19 -20
- package/dist/auto-complete/foundation.d.ts +12 -14
- package/dist/auto-complete/foundation.js +51 -52
- package/dist/avatar/foundation.d.ts +5 -6
- package/dist/avatar/foundation.js +16 -16
- package/dist/avatar/variables.scss +0 -1
- package/dist/backtop/foundation.d.ts +2 -5
- package/dist/backtop/foundation.js +7 -8
- package/dist/banner/foundation.d.ts +1 -1
- package/dist/banner/foundation.js +4 -4
- package/dist/base/auto-close-foundation.d.ts +8 -9
- package/dist/base/auto-close-foundation.js +15 -15
- package/dist/base/foundation.d.ts +4 -4
- package/dist/base/foundation.js +12 -11
- package/dist/base/list-store.d.ts +0 -1
- 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.d.ts +0 -10
- package/dist/calendar/event-util.js +1 -11
- package/dist/calendar/foundation.d.ts +1 -6
- package/dist/calendar/foundation.js +5 -9
- package/dist/calendar/month-foundation.d.ts +2 -3
- package/dist/calendar/month-foundation.js +6 -7
- package/dist/carousel/foundation.d.ts +17 -19
- package/dist/carousel/foundation.js +51 -51
- package/dist/cascader/foundation.d.ts +36 -32
- package/dist/cascader/foundation.js +145 -132
- package/dist/cascader/util.d.ts +1 -8
- package/dist/cascader/util.js +1 -8
- package/dist/checkbox/checkbox-foundation.d.ts +3 -7
- package/dist/checkbox/checkbox-foundation.js +15 -17
- package/dist/checkbox/checkbox-group-foundation.d.ts +2 -3
- package/dist/checkbox/checkbox-group-foundation.js +8 -8
- package/dist/code-highlight/index.d.ts +1 -2
- 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-picker.scss +0 -2
- 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/color-picker/interface.d.ts +0 -1
- package/dist/config-provider/breakpoint-observer.d.ts +3 -3
- package/dist/config-provider/breakpoint-observer.js +6 -6
- package/dist/config-provider/responsive-types.d.ts +0 -16
- package/dist/cropper/foundation.d.ts +15 -16
- package/dist/cropper/foundation.js +26 -24
- package/dist/date-picker/_utils/get-default-picker-date.d.ts +0 -3
- package/dist/date-picker/_utils/get-default-picker-date.js +0 -3
- package/dist/date-picker/_utils/get-inset-input-format-token.d.ts +0 -2
- package/dist/date-picker/_utils/get-inset-input-format-token.js +0 -2
- package/dist/date-picker/_utils/get-inset-input-value-from-inset-input-str.d.ts +0 -2
- package/dist/date-picker/_utils/get-inset-input-value-from-inset-input-str.js +0 -2
- package/dist/date-picker/_utils/parser.d.ts +0 -3
- package/dist/date-picker/_utils/parser.js +0 -7
- package/dist/date-picker/_utils/picker-type.d.ts +1 -3
- package/dist/date-picker/_utils/picker-type.js +0 -2
- package/dist/date-picker/_utils/to-callback-args.d.ts +0 -1
- package/dist/date-picker/_utils/to-callback-args.js +0 -1
- package/dist/date-picker/date-picker.scss +0 -3
- package/dist/date-picker/foundation.d.ts +39 -58
- package/dist/date-picker/foundation.js +126 -153
- package/dist/date-picker/input-foundation.d.ts +10 -16
- package/dist/date-picker/input-foundation.js +28 -30
- package/dist/date-picker/month-foundation.d.ts +0 -3
- package/dist/date-picker/month-foundation.js +0 -2
- package/dist/date-picker/months-grid-foundation.d.ts +17 -26
- package/dist/date-picker/months-grid-foundation.js +65 -75
- 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 -3
- package/dist/drag-move/foundation.js +15 -13
- package/dist/dropdown/foundation.d.ts +8 -7
- package/dist/dropdown/foundation.js +32 -28
- package/dist/dropdown/menu-foundation.d.ts +1 -2
- package/dist/dropdown/menu-foundation.js +11 -11
- package/dist/feedback/foundation.d.ts +9 -10
- package/dist/feedback/foundation.js +33 -33
- package/dist/feedback/variables.scss +1 -5
- package/dist/float-button/float-button.css +0 -1
- package/dist/float-button/float-button.scss +0 -2
- package/dist/form/form-api-proxy.d.ts +8 -7
- package/dist/form/form-api-proxy.js +25 -25
- package/dist/form/form.scss +0 -12
- package/dist/form/foundation.d.ts +5 -5
- package/dist/form/foundation.js +60 -76
- package/dist/form/interface.d.ts +2 -15
- package/dist/form/utils.d.ts +0 -8
- package/dist/form/utils.js +0 -7
- package/dist/form/variables.scss +1 -4
- package/dist/grid/variables.scss +0 -10
- package/dist/highlight/foundation.d.ts +0 -2
- package/dist/highlight/foundation.js +1 -3
- package/dist/hot-keys/foundation.d.ts +2 -3
- package/dist/hot-keys/foundation.js +5 -5
- package/dist/image/image-foundation.d.ts +4 -6
- package/dist/image/image-foundation.js +10 -10
- package/dist/image/preview-footer-foundation.d.ts +3 -4
- package/dist/image/preview-footer-foundation.js +10 -10
- package/dist/image/preview-foundation.d.ts +0 -3
- package/dist/image/preview-foundation.js +7 -6
- package/dist/image/preview-image-foundation.d.ts +6 -9
- package/dist/image/preview-image-foundation.js +14 -14
- package/dist/image/preview-inner-foundation.d.ts +9 -10
- package/dist/image/preview-inner-foundation.js +38 -38
- package/dist/input/foundation.d.ts +10 -11
- package/dist/input/foundation.js +47 -49
- package/dist/input/text-entry-foundation.d.ts +3 -5
- package/dist/input/text-entry-foundation.js +14 -15
- package/dist/input/textarea-foundation.d.ts +7 -8
- package/dist/input/textarea-foundation.js +36 -36
- package/dist/input-number/caret.d.ts +0 -1
- package/dist/input-number/caret.js +0 -1
- package/dist/input-number/foundation.d.ts +16 -19
- package/dist/input-number/foundation.js +54 -58
- package/dist/json-viewer/foundation.d.ts +8 -10
- package/dist/json-viewer/foundation.js +23 -24
- package/dist/locale/interface.d.ts +0 -3
- package/dist/lottie/foundation.d.ts +1 -1
- package/dist/lottie/foundation.js +4 -4
- package/dist/markdown-render/foundation.d.ts +2 -7
- package/dist/markdown-render/foundation.js +5 -9
- 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 -8
- package/dist/navigation/foundation.js +14 -20
- 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 -4
- package/dist/navigation/sub-nav-foundation.js +17 -17
- package/dist/notification/notification-list-foundation.d.ts +7 -8
- package/dist/notification/notification-list-foundation.js +12 -13
- package/dist/notification/variables.scss +0 -1
- package/dist/overflow-list/foundation.d.ts +4 -6
- package/dist/overflow-list/foundation.js +18 -19
- package/dist/pagination/foundation.d.ts +8 -10
- package/dist/pagination/foundation.js +28 -28
- package/dist/pincode/foundation.d.ts +6 -9
- package/dist/pincode/foundation.js +23 -26
- package/dist/popconfirm/popconfirm-foundation.d.ts +7 -9
- package/dist/popconfirm/popconfirm-foundation.js +26 -26
- package/dist/progress/generates.d.ts +1 -4
- package/dist/progress/generates.js +1 -4
- package/dist/progress/utils.d.ts +1 -1
- package/dist/progress/utils.js +1 -1
- package/dist/radio/radio-foundation.d.ts +5 -9
- package/dist/radio/radio-foundation.js +15 -16
- package/dist/radio/radio-group-foundation.d.ts +2 -3
- package/dist/radio/radio-group-foundation.js +9 -9
- package/dist/rating/foundation.d.ts +10 -15
- package/dist/rating/foundation.js +35 -38
- package/dist/resizable/group/index.d.ts +6 -10
- package/dist/resizable/group/index.js +40 -44
- package/dist/resizable/resizable.scss +0 -1
- package/dist/resizable/single/index.d.ts +3 -7
- package/dist/resizable/single/index.js +10 -13
- package/dist/scroll-list/item-foundation.d.ts +7 -9
- package/dist/scroll-list/item-foundation.js +35 -36
- package/dist/scroll-list/variables.scss +1 -6
- package/dist/select/foundation.d.ts +42 -57
- package/dist/select/foundation.js +214 -279
- package/dist/select/option-foundation.d.ts +23 -28
- package/dist/select/option-foundation.js +10 -19
- package/dist/select/variables.scss +1 -8
- package/dist/side-sheet/side-sheet-foundation.d.ts +7 -12
- package/dist/side-sheet/side-sheet-foundation.js +23 -27
- package/dist/side-sheet/variables.scss +1 -3
- package/dist/slider/foundation.d.ts +17 -28
- package/dist/slider/foundation.js +47 -59
- package/dist/slider/variables.scss +1 -5
- package/dist/sortable/accessibility.d.ts +1 -1
- package/dist/sortable/accessibility.js +2 -2
- package/dist/spin/foundation.d.ts +2 -4
- package/dist/spin/foundation.js +6 -7
- package/dist/spin/variables.scss +1 -3
- package/dist/steps/utils.d.ts +1 -1
- package/dist/switch/foundation.d.ts +2 -3
- package/dist/switch/foundation.js +7 -7
- package/dist/switch/switch.scss +1 -1
- package/dist/switch/variables.scss +1 -5
- package/dist/table/foundation.d.ts +24 -33
- package/dist/table/foundation.js +144 -108
- package/dist/table/table.scss +0 -1
- package/dist/table/utils.d.ts +2 -10
- package/dist/table/utils.js +0 -13
- package/dist/table/variables.scss +1 -5
- package/dist/tabs/foundation.d.ts +5 -14
- package/dist/tabs/foundation.js +17 -21
- package/dist/tabs/tabs.scss +1 -1
- package/dist/tag/focus.js +0 -1
- package/dist/tag-input/foundation.d.ts +11 -13
- package/dist/tag-input/foundation.js +52 -53
- package/dist/tag-input/tag-input.scss +0 -1
- package/dist/tag-input/utils/tag-focus.d.ts +0 -1
- package/dist/tag-input/utils/tag-focus.js +0 -1
- package/dist/time-picker/combox-foundation.d.ts +3 -11
- package/dist/time-picker/combox-foundation.js +3 -10
- package/dist/time-picker/foundation.d.ts +13 -23
- package/dist/time-picker/foundation.js +39 -48
- package/dist/time-picker/input-foundation.d.ts +4 -4
- package/dist/time-picker/input-foundation.js +13 -13
- package/dist/time-picker/utils/index.d.ts +0 -11
- package/dist/time-picker/utils/index.js +0 -11
- package/dist/toast/toast-list-foundation.d.ts +7 -7
- package/dist/toast/toast-list-foundation.js +14 -14
- package/dist/tooltip/adjust-position.d.ts +1 -2
- package/dist/tooltip/constants.d.ts +0 -3
- package/dist/tooltip/constants.js +0 -3
- package/dist/tooltip/foundation.d.ts +9 -12
- package/dist/tooltip/foundation.js +67 -63
- package/dist/tooltip/position.scss +0 -1
- package/dist/transfer/foundation.d.ts +22 -13
- package/dist/transfer/foundation.js +38 -24
- package/dist/tree/foundation.d.ts +14 -16
- package/dist/tree/foundation.js +61 -62
- package/dist/tree/shared.d.ts +2 -4
- package/dist/tree/shared.js +0 -2
- package/dist/tree/tree-util.d.ts +0 -5
- package/dist/tree/tree-util.js +0 -5
- package/dist/tree-select/foundation.d.ts +26 -22
- package/dist/tree-select/foundation.js +91 -86
- package/dist/typography/ellipsis.d.ts +5 -7
- package/dist/typography/ellipsis.js +8 -10
- package/dist/typography/format-numeral.d.ts +1 -1
- package/dist/typography/format-numeral.js +2 -2
- package/dist/typography/typography.scss +0 -1
- package/dist/upload/constants.d.ts +1 -1
- package/dist/upload/foundation.d.ts +17 -23
- package/dist/upload/foundation.js +93 -103
- package/dist/upload/utils.d.ts +3 -8
- package/dist/upload/utils.js +6 -11
- package/dist/user-guide/foundation.d.ts +3 -5
- package/dist/user-guide/foundation.js +19 -19
- package/dist/utils/a11y.d.ts +2 -6
- package/dist/utils/a11y.js +1 -4
- package/dist/utils/announcer.d.ts +2 -2
- package/dist/utils/announcer.js +4 -4
- package/dist/utils/array.d.ts +0 -6
- package/dist/utils/array.js +0 -6
- package/dist/utils/date-fns-extra.js +1 -5
- package/dist/utils/dom.d.ts +0 -1
- package/dist/utils/dom.js +0 -1
- package/dist/utils/escape-html.js +0 -3
- package/dist/utils/field-sizing.d.ts +0 -2
- package/dist/utils/field-sizing.js +0 -2
- package/dist/utils/focus-handle.d.ts +1 -2
- package/dist/utils/focus-handle.js +1 -3
- package/dist/utils/focus-scope.d.ts +5 -6
- package/dist/utils/focus-scope.js +10 -11
- 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/utils/scroll-lock.d.ts +3 -4
- package/dist/utils/scroll-lock.js +3 -4
- package/dist/utils/tween.d.ts +0 -1
- package/dist/utils/tween.js +0 -1
- package/dist/utils/uuid.d.ts +0 -1
- package/dist/utils/uuid.js +0 -1
- package/dist/utils/warning.d.ts +0 -1
- package/dist/utils/warning.js +0 -1
- 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 -3
- package/dist/video-player/progress-foundation.js +12 -13
- package/dist/video-player/variables.scss +1 -1
- 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,28 +183,15 @@ 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
|
});
|
|
194
194
|
}
|
|
195
|
-
/**
|
|
196
|
-
* Case A:
|
|
197
|
-
* All fields: a[0]、a[1]、b.type、b.name[2]、b.name[0]
|
|
198
|
-
* input => output:
|
|
199
|
-
* a => a[0]、a[1]
|
|
200
|
-
* b => b.type、b.name[0]、b.name[2]
|
|
201
|
-
*
|
|
202
|
-
* Case B:
|
|
203
|
-
* All fields: activity.a[0]、activity.a[1]、activity.c、activity.d、other
|
|
204
|
-
* input => output:
|
|
205
|
-
* activity.a => activity.a[0]、activity.a[1]
|
|
206
|
-
*
|
|
207
|
-
*/
|
|
208
195
|
#getNestedField(path) {
|
|
209
196
|
const allRegisterField = this.#fields;
|
|
210
197
|
const allFieldPath = [...allRegisterField].map((item) => item[0]);
|
|
@@ -239,7 +226,7 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
239
226
|
const arrayFieldPaths = [...this.#registeredArrayField.keys()].filter((path) => fieldPaths === void 0 || fieldPaths.some((target) => isPathWithin(path, target)));
|
|
240
227
|
arrayFieldPaths.forEach((path) => {
|
|
241
228
|
const arrayFieldState = this.#registeredArrayField.get(path);
|
|
242
|
-
const arrayFieldInitValue = this.
|
|
229
|
+
const arrayFieldInitValue = this.adapter.cloneDeep(arrayFieldState.initValue);
|
|
243
230
|
this.#updateStateValue(path, arrayFieldInitValue, {
|
|
244
231
|
skipNotify: true,
|
|
245
232
|
skipRender: true
|
|
@@ -329,7 +316,6 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
329
316
|
if (!silent) this.#validations.set(field, validation);
|
|
330
317
|
return validation;
|
|
331
318
|
}
|
|
332
|
-
/** Resolves with the field's error value, undefined when valid */
|
|
333
319
|
#validateCustom(registration, value, opts) {
|
|
334
320
|
const { validate } = registration.getValidateOptions();
|
|
335
321
|
const epoch = this.#epoch;
|
|
@@ -452,7 +438,7 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
452
438
|
this.#unregisterNotifyPending = true;
|
|
453
439
|
this.#forceUpdate(() => {
|
|
454
440
|
this.#unregisterNotifyPending = false;
|
|
455
|
-
this.
|
|
441
|
+
this.adapter.notifyChange(this.#data);
|
|
456
442
|
});
|
|
457
443
|
};
|
|
458
444
|
#registerArrayField = (arrayFieldPath, val) => {
|
|
@@ -485,14 +471,14 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
485
471
|
value: this.#getValue(item.path)
|
|
486
472
|
}));
|
|
487
473
|
this.#registerArrayField(arrayFieldPath, val);
|
|
488
|
-
this.#updateStateValue(arrayFieldPath, this.
|
|
474
|
+
this.#updateStateValue(arrayFieldPath, this.adapter.cloneDeep(val), SILENT);
|
|
489
475
|
nestedValues.forEach(({ path, allowEmpty, value }) => {
|
|
490
476
|
this.#updateStateValue(path, value, {
|
|
491
477
|
...SILENT,
|
|
492
478
|
allowEmpty
|
|
493
479
|
});
|
|
494
480
|
});
|
|
495
|
-
this.#updateArrayField(arrayFieldPath, { initValue: this.
|
|
481
|
+
this.#updateArrayField(arrayFieldPath, { initValue: this.adapter.cloneDeep(this.#getValue(arrayFieldPath)) });
|
|
496
482
|
this.#forceUpdate();
|
|
497
483
|
};
|
|
498
484
|
/** Inserts an empty row before `index`, or appends one without it; returns the ArrayField's new updateKey */
|
|
@@ -508,12 +494,11 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
508
494
|
this.#forceUpdate();
|
|
509
495
|
return updateKey;
|
|
510
496
|
};
|
|
511
|
-
/** Inserts a row holding `rowValue` before `index`, or appends it without one */
|
|
512
497
|
#addArrayFieldRowWithValue = (arrayFieldPath, rowValue, index) => {
|
|
513
498
|
const values = this.#getValue(arrayFieldPath);
|
|
514
499
|
const rows = values ? values.slice() : [];
|
|
515
500
|
const rowIndex = typeof index === "number" ? Math.max(0, Math.min(index, rows.length)) : rows.length;
|
|
516
|
-
rows.splice(rowIndex, 0, this.
|
|
501
|
+
rows.splice(rowIndex, 0, this.adapter.cloneDeep(rowValue));
|
|
517
502
|
const updateKey = nextUpdateKey();
|
|
518
503
|
this.#updateArrayField(arrayFieldPath, { updateKey });
|
|
519
504
|
this.#updateStateValue(arrayFieldPath, rows, {});
|
|
@@ -535,13 +520,13 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
535
520
|
#getArrayField = (arrayField) => {
|
|
536
521
|
return this.#registeredArrayField.get(arrayField);
|
|
537
522
|
};
|
|
538
|
-
#updateArrayField
|
|
523
|
+
#updateArrayField(arrayField, updateValue) {
|
|
539
524
|
const mergeVal = {
|
|
540
525
|
...this.#registeredArrayField.get(arrayField),
|
|
541
526
|
...updateValue
|
|
542
527
|
};
|
|
543
528
|
this.#registeredArrayField.set(arrayField, mergeVal);
|
|
544
|
-
}
|
|
529
|
+
}
|
|
545
530
|
#validate(fieldPaths) {
|
|
546
531
|
const { validator } = this.getProps();
|
|
547
532
|
let fields;
|
|
@@ -565,10 +550,10 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
565
550
|
}
|
|
566
551
|
#getValue = (field, opts) => {
|
|
567
552
|
const value = typeof field === "undefined" ? { ...this.#data.values } : get$1(this.#data.values, field);
|
|
568
|
-
return opts?.needClone ? this.
|
|
553
|
+
return opts?.needClone ? this.adapter.cloneDeep(value) : value;
|
|
569
554
|
};
|
|
570
|
-
#setValues
|
|
571
|
-
const _values = this.
|
|
555
|
+
#setValues(values, { isOverride = false }) {
|
|
556
|
+
const _values = this.adapter.cloneDeep(values);
|
|
572
557
|
this.#fields.forEach((field) => {
|
|
573
558
|
const value = get$1(_values, field.field);
|
|
574
559
|
const opts = {
|
|
@@ -585,10 +570,10 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
585
570
|
...this.#data,
|
|
586
571
|
values: _values
|
|
587
572
|
};
|
|
588
|
-
this.
|
|
589
|
-
this.
|
|
573
|
+
this.adapter.notifyChange(this.#data);
|
|
574
|
+
this.adapter.notifyValueChange(this.#data.values, { ...values });
|
|
590
575
|
this.#forceUpdate();
|
|
591
|
-
}
|
|
576
|
+
}
|
|
592
577
|
#updateStateValue = (field, value, opts, callback) => {
|
|
593
578
|
const skipNotify = opts && opts.skipNotify;
|
|
594
579
|
const skipRender = opts && opts.skipRender;
|
|
@@ -598,8 +583,8 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
598
583
|
values: set$1(this.#data.values, field, value, allowEmpty)
|
|
599
584
|
};
|
|
600
585
|
if (!skipNotify) {
|
|
601
|
-
this.
|
|
602
|
-
this.
|
|
586
|
+
this.adapter.notifyChange(this.#data);
|
|
587
|
+
this.adapter.notifyValueChange(this.#data.values, { [field]: value });
|
|
603
588
|
}
|
|
604
589
|
if (!skipRender) this.#forceUpdate(callback);
|
|
605
590
|
};
|
|
@@ -614,7 +599,7 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
614
599
|
...this.#data,
|
|
615
600
|
touched: set$1(this.#data.touched, field, isTouched)
|
|
616
601
|
};
|
|
617
|
-
if (!skipNotify) this.
|
|
602
|
+
if (!skipNotify) this.adapter.notifyChange(this.#data);
|
|
618
603
|
if (!skipRender) this.#forceUpdate(callback);
|
|
619
604
|
};
|
|
620
605
|
#getError = (field) => {
|
|
@@ -629,14 +614,13 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
629
614
|
errors: set$1(this.#data.errors, field, error)
|
|
630
615
|
};
|
|
631
616
|
if (!skipNotify) {
|
|
632
|
-
this.
|
|
633
|
-
this.
|
|
617
|
+
this.adapter.notifyChange(this.#data);
|
|
618
|
+
this.adapter.notifyErrorChange(this.#data.errors, { [field]: error });
|
|
634
619
|
}
|
|
635
620
|
if (!skipRender) this.#forceUpdate(callback);
|
|
636
621
|
};
|
|
637
|
-
#setFieldError = (
|
|
622
|
+
#setFieldError = ({ store, field }, error, opts) => {
|
|
638
623
|
if (opts?.silent) return;
|
|
639
|
-
const { store, field } = registration;
|
|
640
624
|
this.#batch(() => {
|
|
641
625
|
if (opts?.status) this.#updateField(store, { status: opts.status });
|
|
642
626
|
if (error === store.getSnapshot().error) return;
|
|
@@ -698,35 +682,35 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
698
682
|
return {
|
|
699
683
|
setValue: (field, value, opts) => {
|
|
700
684
|
this.#getOperateFieldMap([field]).forEach((_, path) => this.#validations.delete(path));
|
|
701
|
-
this.#setByPath("values", field, this.
|
|
685
|
+
this.#setByPath("values", field, this.adapter.cloneDeep(value), opts);
|
|
702
686
|
},
|
|
703
|
-
setError: (field, error, opts) => this.#setByPath("errors", field, this.
|
|
687
|
+
setError: (field, error, opts) => this.#setByPath("errors", field, this.adapter.cloneDeep(error), opts),
|
|
704
688
|
setTouched: (field, isTouched, opts) => this.#setByPath("touched", field, isTouched, opts)
|
|
705
689
|
};
|
|
706
690
|
}
|
|
707
|
-
#getFieldExist
|
|
691
|
+
#getFieldExist(field) {
|
|
708
692
|
return Boolean(this.#fields.has(field));
|
|
709
|
-
}
|
|
693
|
+
}
|
|
710
694
|
#getFieldDOM(field) {
|
|
711
|
-
return this.
|
|
695
|
+
return this.adapter.getFormElement()?.querySelector(`.${prefix}-field[x-field-id="${CSS.escape(field)}"]`) ?? null;
|
|
712
696
|
}
|
|
713
697
|
/** The root elements of the fields showing an error message, in document order */
|
|
714
698
|
#getErrorFieldDOMs() {
|
|
715
|
-
const errorDOMs = this.
|
|
699
|
+
const errorDOMs = this.adapter.getFormElement()?.querySelectorAll(ERROR_SELECTOR) ?? [];
|
|
716
700
|
return Array.from(errorDOMs, errorField).filter((fieldDOM) => fieldDOM !== null);
|
|
717
701
|
}
|
|
718
702
|
#getErrorFieldDOM(field) {
|
|
719
703
|
const errorDOM = this.#getFieldDOM(field)?.querySelector(ERROR_SELECTOR);
|
|
720
704
|
return errorDOM && errorField(errorDOM);
|
|
721
705
|
}
|
|
722
|
-
#scrollToField
|
|
706
|
+
#scrollToField(field, scrollOpts = {
|
|
723
707
|
behavior: "smooth",
|
|
724
708
|
block: "start"
|
|
725
|
-
})
|
|
709
|
+
}) {
|
|
726
710
|
const fieldDOM = this.#getFieldExist(field) ? this.#getFieldDOM(field) : null;
|
|
727
711
|
if (fieldDOM) scrollIntoView$1(fieldDOM, scrollOpts);
|
|
728
|
-
}
|
|
729
|
-
#scrollToError
|
|
712
|
+
}
|
|
713
|
+
#scrollToError(config) {
|
|
730
714
|
const { field, index, scrollOpts = {
|
|
731
715
|
behavior: "smooth",
|
|
732
716
|
block: "start"
|
|
@@ -736,16 +720,16 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
736
720
|
else if (field) fieldDOM = this.#getErrorFieldDOM(field);
|
|
737
721
|
else if (typeof field === "undefined") fieldDOM = this.#getErrorFieldDOMs()[0];
|
|
738
722
|
if (fieldDOM) scrollIntoView$1(fieldDOM, scrollOpts);
|
|
739
|
-
}
|
|
723
|
+
}
|
|
740
724
|
getInitValues() {
|
|
741
|
-
return this.
|
|
725
|
+
return this.adapter.getInitValues();
|
|
742
726
|
}
|
|
743
727
|
getInitValue(field) {
|
|
744
|
-
if (typeof field === "undefined") return this.
|
|
745
|
-
return get$1(this.
|
|
728
|
+
if (typeof field === "undefined") return this.adapter.getInitValues();
|
|
729
|
+
return get$1(this.adapter.getInitValues(), field);
|
|
746
730
|
}
|
|
747
731
|
getFormProps(keys) {
|
|
748
|
-
return this.
|
|
732
|
+
return this.adapter.getFormProps(keys);
|
|
749
733
|
}
|
|
750
734
|
init() {
|
|
751
735
|
this.#destroyed = false;
|
|
@@ -753,39 +737,39 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
753
737
|
destroy() {
|
|
754
738
|
this.#destroyed = true;
|
|
755
739
|
}
|
|
756
|
-
submit(e) {
|
|
740
|
+
submit = (e) => {
|
|
757
741
|
const epoch = this.#epoch;
|
|
758
742
|
this.#validate().then((resolveValues) => {
|
|
759
743
|
if (this.#isCancelled(epoch)) return;
|
|
760
|
-
const _values = this.
|
|
761
|
-
this.
|
|
744
|
+
const _values = this.adapter.cloneDeep(resolveValues);
|
|
745
|
+
this.adapter.notifySubmit(_values, e);
|
|
762
746
|
}, (errors) => {
|
|
763
747
|
if (this.#isCancelled(epoch)) return;
|
|
764
|
-
const _errors = this.
|
|
765
|
-
const _values = this.
|
|
766
|
-
this.
|
|
748
|
+
const _errors = this.adapter.cloneDeep(errors);
|
|
749
|
+
const _values = this.adapter.cloneDeep(this.#data.values);
|
|
750
|
+
this.adapter.notifySubmitFail(_errors, _values, e);
|
|
767
751
|
});
|
|
768
|
-
}
|
|
769
|
-
reset(fieldPaths) {
|
|
752
|
+
};
|
|
753
|
+
reset = (fieldPaths) => {
|
|
770
754
|
const targetFields = this.#getOperateFieldMap(fieldPaths);
|
|
771
755
|
if (fieldPaths === void 0) this.#epoch += 1;
|
|
772
756
|
else targetFields.forEach((_, path) => this.#validations.delete(path));
|
|
773
757
|
const prevErrors = this.#data.errors;
|
|
774
758
|
this.#batch(() => {
|
|
775
759
|
targetFields.forEach((field) => {
|
|
776
|
-
this.#setFieldValue(field, field.initValue !== null ? this.
|
|
760
|
+
this.#setFieldValue(field, field.initValue !== null ? this.adapter.cloneDeep(field.initValue) : void 0, SILENT);
|
|
777
761
|
this.#setFieldError(field, void 0, SILENT);
|
|
778
762
|
this.#setFieldTouched(field, void 0, SILENT);
|
|
779
763
|
this.#updateField(field.store, { status: "default" });
|
|
780
764
|
});
|
|
781
765
|
});
|
|
782
766
|
if (this.#registeredArrayField.size) this.#resetArrayField(fieldPaths);
|
|
783
|
-
this.
|
|
767
|
+
this.adapter.notifyChange(this.#data);
|
|
784
768
|
this.#notifyErrorChange(prevErrors, targetFields.keys());
|
|
785
769
|
this.#forceUpdate();
|
|
786
|
-
this.
|
|
787
|
-
}
|
|
788
|
-
getFieldBridge() {
|
|
770
|
+
this.adapter.notifyReset();
|
|
771
|
+
};
|
|
772
|
+
getFieldBridge = () => {
|
|
789
773
|
return {
|
|
790
774
|
register: this.#register,
|
|
791
775
|
unRegister: this.#unRegister,
|
|
@@ -807,8 +791,8 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
807
791
|
addArrayFieldRowWithValue: this.#addArrayFieldRowWithValue,
|
|
808
792
|
removeArrayFieldRow: this.#removeArrayFieldRow
|
|
809
793
|
};
|
|
810
|
-
}
|
|
811
|
-
getFormApi() {
|
|
794
|
+
};
|
|
795
|
+
getFormApi = () => {
|
|
812
796
|
return {
|
|
813
797
|
...this.#getFieldSetterApi(),
|
|
814
798
|
reset: (fields) => this.reset(fields),
|
|
@@ -827,10 +811,10 @@ var FormFoundation = class extends BaseFoundation {
|
|
|
827
811
|
scrollToField: (field, scrollOpts) => this.#scrollToField(field, scrollOpts),
|
|
828
812
|
scrollToError: (opts) => this.#scrollToError(opts)
|
|
829
813
|
};
|
|
830
|
-
}
|
|
814
|
+
};
|
|
831
815
|
getFormState = (needClone = false) => {
|
|
832
816
|
if (!needClone) return { ...this.#data };
|
|
833
|
-
else return this.
|
|
817
|
+
else return this.adapter.cloneDeep(this.#data);
|
|
834
818
|
};
|
|
835
819
|
};
|
|
836
820
|
export { FormFoundation as default };
|
package/dist/form/interface.d.ts
CHANGED
|
@@ -52,35 +52,24 @@ export interface ValidateOptions<K extends keyof any = keyof any> {
|
|
|
52
52
|
silent?: boolean;
|
|
53
53
|
}
|
|
54
54
|
export interface BaseFormApi<T extends object = any> {
|
|
55
|
-
/** get value of field */
|
|
56
55
|
getValue: <P extends FieldPath<T>>(field?: P) => FieldPathValue<T, P>;
|
|
57
|
-
/** set value of field */
|
|
58
56
|
setValue: <K extends FieldPath<T>>(field: K, newFieldValue: any) => void;
|
|
59
|
-
/** get error of field */
|
|
60
57
|
getError: <K extends FieldPath<T>>(field: K) => any;
|
|
61
|
-
/** set error of field */
|
|
62
58
|
setError: <K extends FieldPath<T>>(field: K, fieldError: any) => void;
|
|
63
|
-
/** get touched of field */
|
|
64
59
|
getTouched: <K extends FieldPath<T>>(field: K) => boolean;
|
|
65
|
-
/**
|
|
60
|
+
/** A parent path takes the nested touched object of its fields */
|
|
66
61
|
setTouched: <K extends FieldPath<T>>(field: K, fieldTouch: boolean | Record<string, any>) => void;
|
|
67
|
-
/** judge field exist */
|
|
68
62
|
getFieldExist: <K extends FieldPath<T>>(field: K) => boolean;
|
|
69
|
-
/** get formState of form */
|
|
70
63
|
getFormState: () => FormState<T extends object ? T : object>;
|
|
71
|
-
/** get formProps of form */
|
|
72
64
|
getFormProps: (keys?: Array<string>) => ComponentProps;
|
|
73
|
-
/** submit form manual */
|
|
74
65
|
submitForm: () => void;
|
|
75
|
-
/** reset form manual */
|
|
76
66
|
reset: (fields?: Array<string>) => void;
|
|
77
|
-
/**
|
|
67
|
+
/** Resolves with the form values */
|
|
78
68
|
validate: <K extends FieldPath<T>>(fields?: Array<K> | ValidateOptions<K>) => Promise<T>;
|
|
79
69
|
/** Without a field, returns all the initial values */
|
|
80
70
|
getInitValue: <K extends FieldPath<T>>(field?: K) => any;
|
|
81
71
|
getInitValues: () => any;
|
|
82
72
|
getValues: () => T;
|
|
83
|
-
/** set value of multiple fields */
|
|
84
73
|
setValues: (fieldsValue: Partial<T>, config?: setValuesConfig) => void;
|
|
85
74
|
scrollToField: <K extends FieldPath<T>>(field: K, scrollConfig?: Options) => void;
|
|
86
75
|
scrollToError: <K extends FieldPath<T>>(config?: ScrollToErrorOptions<K>) => void;
|
|
@@ -112,7 +101,6 @@ export interface FieldValidateOptions {
|
|
|
112
101
|
transform?: (value: any) => any;
|
|
113
102
|
stopValidateWithError?: boolean;
|
|
114
103
|
}
|
|
115
|
-
/** A registered field: what the Form keeps per field to validate, reset and restore it */
|
|
116
104
|
export interface FieldRegistration {
|
|
117
105
|
/** Identifies the field component instance, which a remounted field of the same name does not share */
|
|
118
106
|
id: string;
|
|
@@ -143,7 +131,6 @@ export interface ArrayFieldRegistration {
|
|
|
143
131
|
updateKey?: number;
|
|
144
132
|
initValue?: any;
|
|
145
133
|
}
|
|
146
|
-
/** What fields and ArrayFields use to read and write the Form's state and to register themselves */
|
|
147
134
|
export interface FieldBridge {
|
|
148
135
|
register: (field: string, registration: FieldRegistration) => void;
|
|
149
136
|
unRegister: (field: string) => void;
|
package/dist/form/utils.d.ts
CHANGED
|
@@ -5,13 +5,6 @@ export declare function isRequired(rules?: any[] | Record<string, any>): boolean
|
|
|
5
5
|
export declare function isValid(errors: any): boolean;
|
|
6
6
|
/** One stable key per ArrayField row: rows that already have a key keep it, new rows get a fresh one */
|
|
7
7
|
export declare function generateKeys(value: unknown, oldKeys?: string[]): string[];
|
|
8
|
-
/**
|
|
9
|
-
* trigger transform rule
|
|
10
|
-
1. If the user has set fieldProps, follow the user's fieldProps
|
|
11
|
-
2. If the user does not set fieldProps, follow formProps
|
|
12
|
-
3. If there is no formProps, follow the change
|
|
13
|
-
4. If it is an array, follow the array, if it is not an array (pure string), convert it to a string array
|
|
14
|
-
*/
|
|
15
8
|
export declare function transformTrigger(fieldTrigger: FieldValidateTriggerType, formTrigger: FieldValidateTriggerType): Array<BasicTriggerType>;
|
|
16
9
|
export declare function transformDefaultBooleanAPI(fieldProp: boolean, formProp: boolean, defaultVal?: boolean): boolean;
|
|
17
10
|
export declare function nextUpdateKey(): number;
|
|
@@ -20,7 +13,6 @@ export declare function nextUpdateKey(): number;
|
|
|
20
13
|
* after setValues a row field keeps the form value and falls back to initValue only when the form has none.
|
|
21
14
|
*/
|
|
22
15
|
export declare function resolveFieldInitValue(initValue: unknown, valueInForm: unknown, shouldUseInitValue: boolean): unknown;
|
|
23
|
-
/** The props a field falls back to its Form for when it does not set them itself */
|
|
24
16
|
export interface FieldConfig {
|
|
25
17
|
labelPosition?: string;
|
|
26
18
|
labelWidth?: number | string;
|
package/dist/form/utils.js
CHANGED
|
@@ -32,13 +32,6 @@ function generateKeys(value, oldKeys = []) {
|
|
|
32
32
|
}
|
|
33
33
|
return value.map((_, i) => oldKeys[i] ?? createId());
|
|
34
34
|
}
|
|
35
|
-
/**
|
|
36
|
-
* trigger transform rule
|
|
37
|
-
1. If the user has set fieldProps, follow the user's fieldProps
|
|
38
|
-
2. If the user does not set fieldProps, follow formProps
|
|
39
|
-
3. If there is no formProps, follow the change
|
|
40
|
-
4. If it is an array, follow the array, if it is not an array (pure string), convert it to a string array
|
|
41
|
-
*/
|
|
42
35
|
function transformTrigger(fieldTrigger, formTrigger) {
|
|
43
36
|
let result = [];
|
|
44
37
|
let finalResult = [];
|
package/dist/form/variables.scss
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
@use 'semi:theme' as *;
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
$spacing-form_field_horizontal-paddingRight: $spacing-base; // 水平布局表单项右侧内边距
|
|
4
4
|
$spacing-form_field_group_horizontal-paddingRight: $spacing-base; // 水平布局表单组标题右侧内边距
|
|
5
5
|
$spacing-form_field_vertical-paddingTop: $spacing-base-tight; // 表单项顶部内边距(垂直布局)
|
|
@@ -7,7 +7,6 @@ $spacing-form_field_vertical-paddingBottom: $spacing-base-tight; // 表单项底
|
|
|
7
7
|
$spacing-form_field_group_vertical-paddingTop: $spacing-base-tight; // 垂直布局表单组顶部内边距
|
|
8
8
|
$spacing-form_field_group_vertical-paddingBottom: $spacing-base-tight; // 垂直布局表单组底部内边距
|
|
9
9
|
|
|
10
|
-
// form label
|
|
11
10
|
$spacing-form_label-paddingRight: $spacing-base; // 表单项标签右侧边距(水平布局)
|
|
12
11
|
$spacing-form_label-paddingTop: ($height-control-default - 20px) * 0.5; // 表单项标签顶部内边距(水平布局)
|
|
13
12
|
$spacing-form_label-marginBottom: $spacing-extra-tight; // 表单项标签底部外边距
|
|
@@ -36,13 +35,11 @@ $color-form_label_extra-text-default: var(--semi-color-tertiary); // 表单项
|
|
|
36
35
|
$color-form_requiredMark-text-default: var(--semi-color-danger); // 必填标记颜色
|
|
37
36
|
$font-form_requiredMark-fontWeight: $font-weight-bold; // 表单必填标识字重
|
|
38
37
|
|
|
39
|
-
// form errormessage
|
|
40
38
|
$color-form_message_error-text-default: var(--semi-color-danger); // 错误提示颜色
|
|
41
39
|
$color-form_alertIcon-icon-default: var(--semi-color-warning); // 警告图标颜色
|
|
42
40
|
$spacing-form_statusIcon-marginRight: $spacing-extra-tight; // 表单校验状态图标右侧外边距
|
|
43
41
|
$spacing-form_message-marginTop: $spacing-extra-tight; // 表单错误信息、辅助文字顶部外边距
|
|
44
42
|
|
|
45
|
-
// form section
|
|
46
43
|
$color-form_section-text-default: var(--semi-color-text-0); // 表单分组标题文字颜色
|
|
47
44
|
$color-form_section-border-default: var(--semi-color-border); // 表单分组标题底部描边颜色
|
|
48
45
|
$width-form_section-border: $border-thickness-control; // 表单分组标题底部描边宽度
|
package/dist/grid/variables.scss
CHANGED
|
@@ -1,29 +1,19 @@
|
|
|
1
1
|
@use 'semi:theme' as *;
|
|
2
|
-
// Media queries breakpoints
|
|
3
|
-
// Extra small screen / phone
|
|
4
2
|
|
|
5
|
-
// Small screen / tablet
|
|
6
3
|
$width-grid_screen-sm: 576px; // 小尺寸设备 - 平板
|
|
7
4
|
$width-grid_screen-sm-min: $width-grid_screen-sm;
|
|
8
5
|
|
|
9
|
-
// Medium screen / desktop
|
|
10
6
|
$width-grid_screen-md: 768px; // 中尺寸设备 - 水平平板
|
|
11
7
|
$width-grid_screen-md-min: $width-grid_screen-md;
|
|
12
8
|
|
|
13
|
-
// Large screen / wide desktop
|
|
14
9
|
$width-grid_screen-lg: 992px; // 大尺寸设备 - 小尺寸桌面端
|
|
15
10
|
$width-grid_screen-lg-min: $width-grid_screen-lg;
|
|
16
11
|
|
|
17
|
-
// Extra large screen / full hd
|
|
18
12
|
$width-grid_screen-xl: 1200px; // 超大尺寸设备 - 桌面端
|
|
19
13
|
$width-grid_screen-xl-min: $width-grid_screen-xl;
|
|
20
14
|
|
|
21
|
-
// Extra extra large screen / large desktop
|
|
22
15
|
$width-grid_screen-xxl: 1600px; // 超大尺寸设备 - 桌面端 HD
|
|
23
16
|
$width-grid_screen-xxl-min: $width-grid_screen-xxl;
|
|
24
17
|
|
|
25
|
-
// provide a maximum
|
|
26
|
-
|
|
27
|
-
// Grid system
|
|
28
18
|
$width-grid_columns: 24; // 栅格宽度
|
|
29
19
|
$width-grid_gutter: 0; // 槽宽度
|
|
@@ -50,8 +50,6 @@ export type SearchWords = SearchWord[];
|
|
|
50
50
|
{ start: 7, end: 13, highlight: true },
|
|
51
51
|
{ start: 13, end: 17, highlight: false },
|
|
52
52
|
]
|
|
53
|
-
|
|
54
|
-
* @return Array of "chunks" (where a Chunk is { start:number, end:number, highlight:boolean })
|
|
55
53
|
*/
|
|
56
54
|
export declare function findAll({ autoEscape, caseSensitive, searchWords, sourceString }: Omit<ChunkQuery, 'searchWords'> & {
|
|
57
55
|
searchWords: string | SearchWords;
|
|
@@ -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();
|
|
@@ -93,8 +93,6 @@ findAll ['do', 'dollar'], 'aaa do dollar aaa'
|
|
|
93
93
|
{ start: 7, end: 13, highlight: true },
|
|
94
94
|
{ start: 13, end: 17, highlight: false },
|
|
95
95
|
]
|
|
96
|
-
|
|
97
|
-
* @return Array of "chunks" (where a Chunk is { start:number, end:number, highlight:boolean })
|
|
98
96
|
*/
|
|
99
97
|
function findAll({ autoEscape = true, caseSensitive = false, searchWords, sourceString }) {
|
|
100
98
|
return fillInChunks({
|
|
@@ -2,7 +2,6 @@ import BaseFoundation, { DefaultAdapter } from "../base/foundation.js";
|
|
|
2
2
|
export interface HotKeysAdapter<P extends HotKeysBaseProps = HotKeysBaseProps, S extends object = object> extends DefaultAdapter<P, S> {
|
|
3
3
|
notifyHotKey: (e: KeyboardEvent) => void;
|
|
4
4
|
}
|
|
5
|
-
/** The props the foundation reads with getProps */
|
|
6
5
|
export interface HotKeysBaseProps {
|
|
7
6
|
hotKeys: KeyboardEvent['key'][];
|
|
8
7
|
preventDefault?: boolean;
|
|
@@ -12,8 +11,8 @@ export default class HotKeysFoundation<P extends HotKeysBaseProps = HotKeysBaseP
|
|
|
12
11
|
#private;
|
|
13
12
|
init(): void;
|
|
14
13
|
/** Applies the same check as mounting, so an invalid combination set later fails just as loudly */
|
|
15
|
-
handleHotKeysChange()
|
|
14
|
+
handleHotKeysChange: () => void;
|
|
16
15
|
/** Moves the keydown listener when `getListenerTarget` now returns a different element */
|
|
17
|
-
handleTargetChange()
|
|
16
|
+
handleTargetChange: () => void;
|
|
18
17
|
destroy(): void;
|
|
19
18
|
}
|
|
@@ -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
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from "../base/foundation.js";
|
|
2
2
|
export type ImageLoadStatus = 'loading' | 'success' | 'error';
|
|
3
|
-
/** The props the foundation reads */
|
|
4
3
|
export interface ImageBaseProps {
|
|
5
4
|
preview?: boolean | {
|
|
6
5
|
visible?: boolean;
|
|
@@ -9,7 +8,6 @@ export interface ImageBaseProps {
|
|
|
9
8
|
export interface ImageBaseState {}
|
|
10
9
|
export interface ImageAdapter<P extends ImageBaseProps = ImageBaseProps, S extends ImageBaseState = ImageBaseState> extends DefaultAdapter<P, S> {
|
|
11
10
|
getIsInGroup: () => boolean;
|
|
12
|
-
/** Opens the group preview at this image */
|
|
13
11
|
openGroupPreview: () => void;
|
|
14
12
|
setLoadStatus: (status: ImageLoadStatus) => void;
|
|
15
13
|
setPreviewVisible: (visible: boolean) => void;
|
|
@@ -22,9 +20,9 @@ export default class ImageFoundation<P extends ImageBaseProps = ImageBaseProps,
|
|
|
22
20
|
static canOpen(preview: ImageBaseProps['preview'], loadStatus: ImageLoadStatus, isInGroup: boolean): boolean;
|
|
23
21
|
/** 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
22
|
static canPreview(preview: ImageBaseProps['preview'], isInGroup: boolean): boolean;
|
|
25
|
-
handleClick: (_e:
|
|
26
|
-
handleKeyDown: (e:
|
|
27
|
-
handleLoaded: (e:
|
|
28
|
-
handleError: (e:
|
|
23
|
+
handleClick: (_e: unknown) => void;
|
|
24
|
+
handleKeyDown: (e: Pick<KeyboardEvent, "currentTarget" | "key" | "preventDefault" | "target">) => void;
|
|
25
|
+
handleLoaded: (e: unknown) => void;
|
|
26
|
+
handleError: (e: unknown) => void;
|
|
29
27
|
handlePreviewVisibleChange: (newVisible: boolean) => void;
|
|
30
28
|
}
|
|
@@ -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 };
|