@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
|
@@ -58,7 +58,7 @@ var DragMoveFoundation = class extends BaseFoundation {
|
|
|
58
58
|
#allowMove(e) {
|
|
59
59
|
const { allowMove, allowInputDrag } = this.getProps();
|
|
60
60
|
if (!allowInputDrag) {
|
|
61
|
-
const target = e.target.tagName.toLowerCase();
|
|
61
|
+
const target = e.target instanceof Element ? e.target.tagName.toLowerCase() : "";
|
|
62
62
|
if (target === "input" || target === "textarea") return false;
|
|
63
63
|
}
|
|
64
64
|
if (allowMove) return allowMove(e, this.#element);
|
|
@@ -100,16 +100,16 @@ var DragMoveFoundation = class extends BaseFoundation {
|
|
|
100
100
|
}
|
|
101
101
|
#onPointerMove = (e) => {
|
|
102
102
|
if (e.pointerId !== this.#pointerId) return;
|
|
103
|
-
if (this.#isTouch(e)) this.
|
|
104
|
-
else this.
|
|
103
|
+
if (this.#isTouch(e)) this.adapter.notifyTouchMove(e);
|
|
104
|
+
else this.adapter.notifyMouseMove(e);
|
|
105
105
|
this.#changePos(e);
|
|
106
106
|
};
|
|
107
107
|
#onPointerEnd = (e) => {
|
|
108
108
|
if (e.pointerId !== this.#pointerId) return;
|
|
109
109
|
this.#stopDrag();
|
|
110
|
-
if (e.type === "pointercancel") this.
|
|
111
|
-
else if (this.#isTouch(e)) this.
|
|
112
|
-
else this.
|
|
110
|
+
if (e.type === "pointercancel") this.adapter.notifyTouchCancel(e);
|
|
111
|
+
else if (this.#isTouch(e)) this.adapter.notifyTouchEnd(e);
|
|
112
|
+
else this.adapter.notifyMouseUp(e);
|
|
113
113
|
};
|
|
114
114
|
#stopDrag() {
|
|
115
115
|
this.#dragController?.abort();
|
|
@@ -131,11 +131,13 @@ var DragMoveFoundation = class extends BaseFoundation {
|
|
|
131
131
|
if (this.#dragController) return;
|
|
132
132
|
if (isSecondaryPress(e)) return;
|
|
133
133
|
const element = e.currentTarget;
|
|
134
|
-
if (!
|
|
134
|
+
if (!(element instanceof HTMLElement)) return;
|
|
135
|
+
const handler = this.#getHandler(element);
|
|
136
|
+
if (!(e.target instanceof Node && handler.contains(e.target))) return;
|
|
135
137
|
this.#element = element;
|
|
136
138
|
this.#calcMoveRange();
|
|
137
|
-
if (this.#isTouch(e)) this.
|
|
138
|
-
else this.
|
|
139
|
+
if (this.#isTouch(e)) this.adapter.notifyTouchStart(e);
|
|
140
|
+
else this.adapter.notifyMouseDown(e);
|
|
139
141
|
if (!this.#allowMove(e)) return;
|
|
140
142
|
this.#pointerId = e.pointerId;
|
|
141
143
|
const controller = new AbortController();
|
|
@@ -151,7 +153,7 @@ var DragMoveFoundation = class extends BaseFoundation {
|
|
|
151
153
|
* Prepares host children as they appear: the position strategy, a move cursor on the handler, and
|
|
152
154
|
* `touch-action: none` so a touch drag is not taken over by scrolling.
|
|
153
155
|
*/
|
|
154
|
-
prepareElements(elements) {
|
|
156
|
+
prepareElements = (elements) => {
|
|
155
157
|
for (const element of this.#elements) if (!element.isConnected) this.#elements.delete(element);
|
|
156
158
|
for (const element of elements) {
|
|
157
159
|
if (this.#elements.has(element)) continue;
|
|
@@ -164,10 +166,10 @@ var DragMoveFoundation = class extends BaseFoundation {
|
|
|
164
166
|
});
|
|
165
167
|
}
|
|
166
168
|
this.#prepareHandlers();
|
|
167
|
-
}
|
|
168
|
-
updatePositionStrategy() {
|
|
169
|
+
};
|
|
170
|
+
updatePositionStrategy = () => {
|
|
169
171
|
for (const element of this.#elements) this.#applyPositionStrategy(element);
|
|
170
|
-
}
|
|
172
|
+
};
|
|
171
173
|
destroy() {
|
|
172
174
|
this.#stopDrag();
|
|
173
175
|
this.#handlerObserver?.disconnect();
|
|
@@ -9,12 +9,12 @@ export interface DropdownAdapter<P extends DropdownBaseProps = DropdownBaseProps
|
|
|
9
9
|
/** Hides the popup through Tooltip's hide(), without moving focus: a controlled one only reports the request */
|
|
10
10
|
hidePopup(): void;
|
|
11
11
|
}
|
|
12
|
-
/** The
|
|
12
|
+
/** The members of a keyboard event the foundation reads; DOM events and React synthetic events both satisfy it */
|
|
13
|
+
type DropdownKeyEvent = Pick<KeyboardEvent, 'defaultPrevented' | 'key' | 'preventDefault' | 'stopPropagation' | 'target'>;
|
|
13
14
|
export interface DropdownBaseProps {
|
|
14
15
|
trigger?: string;
|
|
15
16
|
visible?: boolean;
|
|
16
17
|
}
|
|
17
|
-
/** The state the foundation reads */
|
|
18
18
|
export interface DropdownBaseState {
|
|
19
19
|
popVisible: boolean;
|
|
20
20
|
}
|
|
@@ -22,16 +22,17 @@ export default class DropdownFoundation<P extends DropdownBaseProps = DropdownBa
|
|
|
22
22
|
#private;
|
|
23
23
|
destroy(): void;
|
|
24
24
|
/** Closes the menu without moving focus */
|
|
25
|
-
close()
|
|
25
|
+
close: () => void;
|
|
26
26
|
/** Tooltip's onVisibleChange: an actual change when uncontrolled, only a request to the owner when controlled */
|
|
27
|
-
handleVisibleChange(visible: boolean)
|
|
27
|
+
handleVisibleChange: (visible: boolean) => void;
|
|
28
28
|
/**
|
|
29
29
|
* Tooltip's initial focus of each opening, right after the popup is shown, controlled or not. Not deferred to
|
|
30
30
|
* afterOpen: a keyboard user would wait out the enter animation.
|
|
31
31
|
*/
|
|
32
|
-
handleOpened()
|
|
32
|
+
handleOpened: () => void;
|
|
33
33
|
/**
|
|
34
34
|
* @param isMenuButton whether the trigger is a menu button: only then Up and Down open a closed menu
|
|
35
35
|
*/
|
|
36
|
-
handleKeyDown(event:
|
|
37
|
-
}
|
|
36
|
+
handleKeyDown: (event: DropdownKeyEvent, isMenuButton?: boolean) => void;
|
|
37
|
+
}
|
|
38
|
+
export {};
|
|
@@ -19,8 +19,9 @@ var DropdownFoundation = class extends BaseFoundation {
|
|
|
19
19
|
return this.getProp("visible") ?? this.getState("popVisible");
|
|
20
20
|
}
|
|
21
21
|
#handleParentItemKeyDown(event, popup) {
|
|
22
|
+
const { target } = event;
|
|
22
23
|
const popVisible = this.#isOpen();
|
|
23
|
-
const openKey = this.
|
|
24
|
+
const openKey = this.adapter.getContext("direction") === "rtl" ? "ArrowLeft" : "ArrowRight";
|
|
24
25
|
const handled = event.defaultPrevented;
|
|
25
26
|
switch (event.key) {
|
|
26
27
|
case "Enter":
|
|
@@ -32,44 +33,45 @@ var DropdownFoundation = class extends BaseFoundation {
|
|
|
32
33
|
this.#focusOnOpen = "first";
|
|
33
34
|
const trigger = this.getProp("trigger");
|
|
34
35
|
if (trigger === "click") {
|
|
35
|
-
if (!handled)
|
|
36
|
-
} else if (trigger === "hover" || trigger === "focus") {
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
if (!handled && target instanceof HTMLElement) target.click();
|
|
37
|
+
} else if ((trigger === "hover" || trigger === "focus") && target instanceof HTMLElement) {
|
|
38
|
+
target.blur();
|
|
39
|
+
target.focus();
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
}
|
|
43
44
|
destroy() {
|
|
44
|
-
this.
|
|
45
|
+
this.adapter.setPopVisible(false);
|
|
45
46
|
}
|
|
46
47
|
/** Closes the menu without moving focus */
|
|
47
|
-
close() {
|
|
48
|
-
this.
|
|
49
|
-
}
|
|
48
|
+
close = () => {
|
|
49
|
+
this.adapter.hidePopup();
|
|
50
|
+
};
|
|
50
51
|
/** Tooltip's onVisibleChange: an actual change when uncontrolled, only a request to the owner when controlled */
|
|
51
|
-
handleVisibleChange(visible) {
|
|
52
|
-
if (this.getProp("visible") === void 0) this.
|
|
52
|
+
handleVisibleChange = (visible) => {
|
|
53
|
+
if (this.getProp("visible") === void 0) this.adapter.setPopVisible(visible);
|
|
53
54
|
if (!visible) this.#focusOnOpen = null;
|
|
54
|
-
this.
|
|
55
|
-
}
|
|
55
|
+
this.adapter.notifyVisibleChange(visible);
|
|
56
|
+
};
|
|
56
57
|
/**
|
|
57
58
|
* Tooltip's initial focus of each opening, right after the popup is shown, controlled or not. Not deferred to
|
|
58
59
|
* afterOpen: a keyboard user would wait out the enter animation.
|
|
59
60
|
*/
|
|
60
|
-
handleOpened() {
|
|
61
|
-
const popup = this.
|
|
61
|
+
handleOpened = () => {
|
|
62
|
+
const popup = this.adapter.getPopup();
|
|
62
63
|
const trigger = popup && getMenuButton(popup.id, popup.getRootNode());
|
|
63
64
|
const focusOnOpen = trigger?.contains(FocusTrapHandle.getActiveElement(trigger)) ? this.#focusOnOpen : null;
|
|
64
65
|
if (["click", "contextMenu"].includes(this.getProp("trigger")) || focusOnOpen) this.#focusEdgeItem(popup, focusOnOpen ?? "first");
|
|
65
66
|
this.#focusOnOpen = null;
|
|
66
|
-
}
|
|
67
|
+
};
|
|
67
68
|
/**
|
|
68
69
|
* @param isMenuButton whether the trigger is a menu button: only then Up and Down open a closed menu
|
|
69
70
|
*/
|
|
70
|
-
handleKeyDown(event, isMenuButton = false) {
|
|
71
|
-
const
|
|
72
|
-
|
|
71
|
+
handleKeyDown = (event, isMenuButton = false) => {
|
|
72
|
+
const { target } = event;
|
|
73
|
+
const popup = this.adapter.getPopup();
|
|
74
|
+
if (this.adapter.getContext("menuDepth") > 0) {
|
|
73
75
|
this.#handleParentItemKeyDown(event, popup);
|
|
74
76
|
return;
|
|
75
77
|
}
|
|
@@ -77,9 +79,9 @@ var DropdownFoundation = class extends BaseFoundation {
|
|
|
77
79
|
switch (event.key) {
|
|
78
80
|
case " ":
|
|
79
81
|
case "Enter":
|
|
80
|
-
if (isTextEditor(
|
|
81
|
-
if (!event.defaultPrevented && !
|
|
82
|
-
|
|
82
|
+
if (isTextEditor(target)) break;
|
|
83
|
+
if (!event.defaultPrevented && target instanceof HTMLElement && !target.matches(NATIVE_KEY_CLICK_SELECTOR)) {
|
|
84
|
+
target.click();
|
|
83
85
|
event.preventDefault();
|
|
84
86
|
}
|
|
85
87
|
break;
|
|
@@ -102,19 +104,21 @@ var DropdownFoundation = class extends BaseFoundation {
|
|
|
102
104
|
].includes(trigger)) break;
|
|
103
105
|
handlePrevent(event);
|
|
104
106
|
this.#focusOnOpen = edge;
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
107
|
+
if (target instanceof HTMLElement) {
|
|
108
|
+
if (trigger === "click") target.click();
|
|
109
|
+
else {
|
|
110
|
+
target.blur();
|
|
111
|
+
target.focus();
|
|
112
|
+
}
|
|
109
113
|
}
|
|
110
114
|
}
|
|
111
115
|
break;
|
|
112
116
|
}
|
|
113
117
|
case "Tab": if (popVisible) {
|
|
114
118
|
this.close();
|
|
115
|
-
this.
|
|
119
|
+
this.adapter.getContext("closeAll")?.();
|
|
116
120
|
}
|
|
117
121
|
}
|
|
118
|
-
}
|
|
122
|
+
};
|
|
119
123
|
};
|
|
120
124
|
export { DropdownFoundation as default };
|
|
@@ -23,7 +23,6 @@ export interface DropdownMenuContext extends DirectionContext {
|
|
|
23
23
|
/** Id of the popup that renders the menu; its trigger carries it as data-popupid */
|
|
24
24
|
getPopupId?: () => string;
|
|
25
25
|
}
|
|
26
|
-
/** The adapter of a foundation that reads DropdownMenuContext */
|
|
27
26
|
export interface DropdownContextAdapter<P = object, S = object> extends DefaultAdapter<P, S, DropdownMenuContext> {}
|
|
28
27
|
/**
|
|
29
28
|
* Keyboard of a menu (WAI-ARIA APG menu pattern): arrows, Home and End move focus between the enabled items of this
|
|
@@ -32,5 +31,5 @@ export interface DropdownContextAdapter<P = object, S = object> extends DefaultA
|
|
|
32
31
|
*/
|
|
33
32
|
export default class DropdownMenuFoundation<P extends object = object, S extends object = object> extends BaseFoundation<DropdownContextAdapter<P, S>, P, S> {
|
|
34
33
|
#private;
|
|
35
|
-
onMenuKeydown(event:
|
|
34
|
+
onMenuKeydown: (event: Pick<KeyboardEvent, "altKey" | "ctrlKey" | "currentTarget" | "defaultPrevented" | "key" | "metaKey" | "preventDefault" | "stopPropagation" | "target">) => void;
|
|
36
35
|
}
|
|
@@ -19,22 +19,22 @@ function getItemRole(selectionMode, showTick) {
|
|
|
19
19
|
var DropdownMenuFoundation = class extends BaseFoundation {
|
|
20
20
|
#typeahead = new Typeahead();
|
|
21
21
|
#focusMenuButton(menu) {
|
|
22
|
-
getMenuButton(this.
|
|
22
|
+
getMenuButton(this.adapter.getContext("getPopupId")?.() ?? "", menu.getRootNode())?.focus();
|
|
23
23
|
}
|
|
24
24
|
#getItems(menu) {
|
|
25
25
|
return [...menu.querySelectorAll(ITEM_SELECTOR)].filter((item) => item.closest("[role=\"menu\"]") === menu && item.getAttribute("aria-disabled") !== "true");
|
|
26
26
|
}
|
|
27
|
-
onMenuKeydown(event) {
|
|
28
|
-
const menu = event
|
|
29
|
-
|
|
27
|
+
onMenuKeydown = (event) => {
|
|
28
|
+
const { currentTarget: menu, target } = event;
|
|
29
|
+
if (!(menu instanceof Element) || !(target instanceof HTMLElement)) return;
|
|
30
30
|
if (target.closest("[role=\"menu\"]") !== menu) {
|
|
31
31
|
if (event.key !== "Escape") event.stopPropagation();
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
const items = this.#getItems(menu);
|
|
35
35
|
const index = items.findIndex((item) => item.contains(target));
|
|
36
|
-
const isRtl = this.
|
|
37
|
-
const isSubmenu = this.
|
|
36
|
+
const isRtl = this.adapter.getContext("direction") === "rtl";
|
|
37
|
+
const isSubmenu = this.adapter.getContext("menuDepth") > 1;
|
|
38
38
|
switch (event.key) {
|
|
39
39
|
case " ":
|
|
40
40
|
case "Enter":
|
|
@@ -44,7 +44,7 @@ var DropdownMenuFoundation = class extends BaseFoundation {
|
|
|
44
44
|
}
|
|
45
45
|
break;
|
|
46
46
|
case "Escape":
|
|
47
|
-
if (this.
|
|
47
|
+
if (this.adapter.getContext("trigger") === "custom") this.#focusMenuButton(menu);
|
|
48
48
|
break;
|
|
49
49
|
case "ArrowDown":
|
|
50
50
|
case "ArrowUp":
|
|
@@ -60,15 +60,15 @@ var DropdownMenuFoundation = class extends BaseFoundation {
|
|
|
60
60
|
if (isSubmenu && event.key === (isRtl ? "ArrowRight" : "ArrowLeft")) {
|
|
61
61
|
handlePrevent(event);
|
|
62
62
|
this.#focusMenuButton(menu);
|
|
63
|
-
this.
|
|
63
|
+
this.adapter.getContext("close")?.();
|
|
64
64
|
}
|
|
65
65
|
break;
|
|
66
66
|
case "Tab": {
|
|
67
67
|
const root = menu.getRootNode();
|
|
68
|
-
let button = getMenuButton(this.
|
|
68
|
+
let button = getMenuButton(this.adapter.getContext("getPopupId")?.() ?? "", root);
|
|
69
69
|
while (button?.matches(ITEM_SELECTOR)) button = getMenuButton(button.closest("[popover]")?.id ?? "", root);
|
|
70
70
|
button?.focus();
|
|
71
|
-
this.
|
|
71
|
+
this.adapter.getContext("closeAll")?.();
|
|
72
72
|
break;
|
|
73
73
|
}
|
|
74
74
|
default: if (this.#typeahead.accepts(event)) {
|
|
@@ -77,6 +77,6 @@ var DropdownMenuFoundation = class extends BaseFoundation {
|
|
|
77
77
|
if (found >= 0) setFocusToItem(items, items[found]);
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
}
|
|
80
|
+
};
|
|
81
81
|
};
|
|
82
82
|
export { DropdownMenuFoundation as default, getItemRole };
|
|
@@ -9,7 +9,6 @@ export type FeedbackValue = CheckboxValue | CheckboxValue[] | EmojiResult;
|
|
|
9
9
|
/** Nothing chosen: null, undefined, an empty string or an empty array. 0 and false are real radio values. */
|
|
10
10
|
export declare function isFeedbackValueEmpty(value?: FeedbackValue | null): boolean;
|
|
11
11
|
type PromiseStatus = 'pending' | 'fulfilled' | 'rejected';
|
|
12
|
-
/** The state the foundation reads with getState */
|
|
13
12
|
export interface FeedbackBaseState {
|
|
14
13
|
value: FeedbackValue | null;
|
|
15
14
|
onOKReturnPromiseStatus?: PromiseStatus;
|
|
@@ -30,14 +29,14 @@ export interface FeedbackAdapter<P extends object = object, S extends FeedbackBa
|
|
|
30
29
|
}
|
|
31
30
|
export default class FeedbackFoundation<P extends object = object, S extends FeedbackBaseState = FeedbackBaseState, CE = unknown, OE = unknown, TE = unknown> extends BaseFoundation<FeedbackAdapter<P, S, CE, OE, TE>, P, S> {
|
|
32
31
|
#private;
|
|
33
|
-
handleRadioChange(e: RadioChangeEvent)
|
|
34
|
-
handleEmojiReasonChange(value: string, e?: TE)
|
|
35
|
-
handleTextChange(value: string, e?: TE)
|
|
36
|
-
handleEmojiChange(emoji: string)
|
|
37
|
-
handleCheckboxChange(value: CheckboxValue[])
|
|
38
|
-
handleCancel(e: CE)
|
|
39
|
-
handleSubmit(e: OE)
|
|
40
|
-
handleModalOk(e: OE)
|
|
41
|
-
handleModalCancel(e: CE)
|
|
32
|
+
handleRadioChange: (e: RadioChangeEvent) => void;
|
|
33
|
+
handleEmojiReasonChange: (value: string, e?: TE) => void;
|
|
34
|
+
handleTextChange: (value: string, e?: TE) => void;
|
|
35
|
+
handleEmojiChange: (emoji: string) => void;
|
|
36
|
+
handleCheckboxChange: (value: CheckboxValue[]) => void;
|
|
37
|
+
handleCancel: (e: CE) => void;
|
|
38
|
+
handleSubmit: (e: OE) => void;
|
|
39
|
+
handleModalOk: (e: OE) => Promise<void>;
|
|
40
|
+
handleModalCancel: (e: CE) => Promise<void>;
|
|
42
41
|
}
|
|
43
42
|
export {};
|
|
@@ -7,18 +7,18 @@ function isFeedbackValueEmpty(value) {
|
|
|
7
7
|
}
|
|
8
8
|
var FeedbackFoundation = class extends BaseFoundation {
|
|
9
9
|
#changeValue(value) {
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
10
|
+
this.adapter.setValue(value);
|
|
11
|
+
this.adapter.notifyValueChange(value);
|
|
12
12
|
}
|
|
13
13
|
#settlePopup(result, report) {
|
|
14
14
|
if (!isPromise(result)) {
|
|
15
|
-
this.
|
|
15
|
+
this.adapter.setValue(null);
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
report("pending");
|
|
19
19
|
result.then(() => {
|
|
20
20
|
report("fulfilled");
|
|
21
|
-
this.
|
|
21
|
+
this.adapter.setValue(null);
|
|
22
22
|
}).catch((e) => {
|
|
23
23
|
report("rejected");
|
|
24
24
|
throw e;
|
|
@@ -26,47 +26,47 @@ var FeedbackFoundation = class extends BaseFoundation {
|
|
|
26
26
|
}
|
|
27
27
|
#settleModal(result) {
|
|
28
28
|
if (!isPromise(result)) {
|
|
29
|
-
this.
|
|
29
|
+
this.adapter.setValue(null);
|
|
30
30
|
return null;
|
|
31
31
|
}
|
|
32
|
-
return result.then(() => this.
|
|
32
|
+
return result.then(() => this.adapter.setValue(null));
|
|
33
33
|
}
|
|
34
|
-
handleRadioChange(e) {
|
|
34
|
+
handleRadioChange = (e) => {
|
|
35
35
|
const { value } = e.target;
|
|
36
|
-
this.
|
|
36
|
+
this.adapter.notifyRadioChange(e);
|
|
37
37
|
this.#changeValue(value);
|
|
38
|
-
}
|
|
39
|
-
handleEmojiReasonChange(value, e) {
|
|
40
|
-
this.
|
|
41
|
-
const oldValue = this.
|
|
38
|
+
};
|
|
39
|
+
handleEmojiReasonChange = (value, e) => {
|
|
40
|
+
this.adapter.notifyTextAreaChange(value, e);
|
|
41
|
+
const oldValue = this.adapter.getState("value");
|
|
42
42
|
const emoji = typeof oldValue === "object" && !Array.isArray(oldValue) ? oldValue?.emoji : void 0;
|
|
43
43
|
this.#changeValue({
|
|
44
44
|
...emoji !== void 0 && { emoji },
|
|
45
45
|
text: value
|
|
46
46
|
});
|
|
47
|
-
}
|
|
48
|
-
handleTextChange(value, e) {
|
|
49
|
-
this.
|
|
47
|
+
};
|
|
48
|
+
handleTextChange = (value, e) => {
|
|
49
|
+
this.adapter.notifyTextAreaChange(value, e);
|
|
50
50
|
this.#changeValue(value);
|
|
51
|
-
}
|
|
52
|
-
handleEmojiChange(emoji) {
|
|
51
|
+
};
|
|
52
|
+
handleEmojiChange = (emoji) => {
|
|
53
53
|
this.#changeValue({ emoji });
|
|
54
|
-
}
|
|
55
|
-
handleCheckboxChange(value) {
|
|
56
|
-
this.
|
|
54
|
+
};
|
|
55
|
+
handleCheckboxChange = (value) => {
|
|
56
|
+
this.adapter.notifyCheckboxChange(value);
|
|
57
57
|
this.#changeValue(value);
|
|
58
|
-
}
|
|
59
|
-
handleCancel(e) {
|
|
60
|
-
this.#settlePopup(this.
|
|
61
|
-
}
|
|
62
|
-
handleSubmit(e) {
|
|
63
|
-
this.#settlePopup(this.
|
|
64
|
-
}
|
|
65
|
-
handleModalOk(e) {
|
|
66
|
-
return this.#settleModal(this.
|
|
67
|
-
}
|
|
68
|
-
handleModalCancel(e) {
|
|
69
|
-
return this.#settleModal(this.
|
|
70
|
-
}
|
|
58
|
+
};
|
|
59
|
+
handleCancel = (e) => {
|
|
60
|
+
this.#settlePopup(this.adapter.notifyCancel(e), (onCancelReturnPromiseStatus) => this.adapter.setState({ onCancelReturnPromiseStatus }));
|
|
61
|
+
};
|
|
62
|
+
handleSubmit = (e) => {
|
|
63
|
+
this.#settlePopup(this.adapter.notifyOk(e), (onOKReturnPromiseStatus) => this.adapter.setState({ onOKReturnPromiseStatus }));
|
|
64
|
+
};
|
|
65
|
+
handleModalOk = (e) => {
|
|
66
|
+
return this.#settleModal(this.adapter.notifyOk(e));
|
|
67
|
+
};
|
|
68
|
+
handleModalCancel = (e) => {
|
|
69
|
+
return this.#settleModal(this.adapter.notifyCancel(e));
|
|
70
|
+
};
|
|
71
71
|
};
|
|
72
72
|
export { FeedbackFoundation as default, isFeedbackValueEmpty };
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
@use 'semi:theme' as *;
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
$color-feedback_thank_text: var(--semi-color-text-2); // 感谢文字的文本颜色
|
|
4
4
|
|
|
5
|
-
// width
|
|
6
5
|
$width-feedback: 400px; // 除去文本类型外其他类型的宽度
|
|
7
6
|
$width-feedback_text: 600px; // 文本类型的宽度
|
|
8
7
|
|
|
9
|
-
// spacing
|
|
10
8
|
$spacing-feedback_emoji_container-columnGap: 24px; // emoji容器中emoji的间距
|
|
11
9
|
$spacing-feedback_emoji_container-marginY: 24px; // emoji容器的上下间距
|
|
12
10
|
$spacing-feedback_thank_text-marginTop: 24px; // 感谢文字的文本的顶部间距
|
|
@@ -16,11 +14,9 @@ $spacing-feedback_footer-columnGap: 12px; // 底部按钮的间距
|
|
|
16
14
|
$spacing-feedback_sidesheet_bottom-right: 20px; // 底部弹窗的右间距
|
|
17
15
|
$spacing-feedback_sidesheet_bottom_inner_wrap-bottom: 50px; // 底部弹窗的底部间距
|
|
18
16
|
|
|
19
|
-
// font
|
|
20
17
|
$font-feedback_emoji-fontSize: 36px; // emoji的大小
|
|
21
18
|
$font-feedback_thank_text-fontSize: $font-size-regular; // 感谢文字的文本大小
|
|
22
19
|
$font-feedback_thank_text-lineHeight: 20px; // 感谢文字的文本行高
|
|
23
20
|
$font-feedback_thank_text-fontWeight: $font-weight-regular; // 感谢文字的文本字体粗细
|
|
24
21
|
|
|
25
|
-
// radius
|
|
26
22
|
$radius-feedback_sidesheet_inner: 12px; // 底部弹窗的圆角
|
|
@@ -64,7 +64,6 @@
|
|
|
64
64
|
.semi-floatButton-default.semi-floatButton-round .semi-badge-dot,
|
|
65
65
|
.semi-floatButton-default.semi-floatButton-round .semi-badge-count {
|
|
66
66
|
inset-inline-end: 4.64px;
|
|
67
|
-
/* Badge center sits on the circle's diagonal: 0.29 * R, R = 0.5 * width */
|
|
68
67
|
top: 4.64px;
|
|
69
68
|
}
|
|
70
69
|
.semi-floatButton-small {
|
|
@@ -87,8 +87,6 @@ $moduleGroup: #{$prefix}-floatButtonGroup;
|
|
|
87
87
|
.#{$prefix}-badge-dot,
|
|
88
88
|
.#{$prefix}-badge-count {
|
|
89
89
|
inset-inline-end: calc(0.29 * 0.5 * $width-floatButton);
|
|
90
|
-
|
|
91
|
-
/* Badge center sits on the circle's diagonal: 0.29 * R, R = 0.5 * width */
|
|
92
90
|
top: calc(0.29 * 0.5 * $width-floatButton);
|
|
93
91
|
}
|
|
94
92
|
}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { BaseFormApi, FormState } from "./interface.js";
|
|
2
2
|
export declare const EMPTY_FORM_STATE: FormState;
|
|
3
3
|
export interface FormApiProxyInternals<T extends Record<string, any> = any> {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
__updateState: ((state: FormState<T>) => void) | null;
|
|
4
|
+
bind: (api: BaseFormApi<T>) => void;
|
|
5
|
+
unbind: () => void;
|
|
6
|
+
updateState: (state: FormState<T>) => void;
|
|
8
7
|
}
|
|
8
|
+
/** The binding hooks of a proxy made by createFormApiProxy; undefined for any other object. */
|
|
9
|
+
export declare function getFormApiProxyInternals<T extends Record<string, any> = any>(proxy?: object): FormApiProxyInternals<T>;
|
|
9
10
|
/**
|
|
10
|
-
* A FormApi that exists before its Form mounts: the Form binds the real api through `
|
|
11
|
-
* form state through `
|
|
11
|
+
* A FormApi that exists before its Form mounts: the Form binds the real api through `bind` and pushes every
|
|
12
|
+
* form state through `updateState`, which the framework hook stores in its own state.
|
|
12
13
|
*/
|
|
13
|
-
export declare function createFormApiProxy<T extends Record<string, any>>(setFormState: (state: FormState<T>) => void): BaseFormApi<T
|
|
14
|
+
export declare function createFormApiProxy<T extends Record<string, any>>(setFormState: (state: FormState<T>) => void): BaseFormApi<T>;
|
|
@@ -4,28 +4,20 @@ const EMPTY_FORM_STATE = {
|
|
|
4
4
|
errors: {},
|
|
5
5
|
touched: {}
|
|
6
6
|
};
|
|
7
|
+
const internalsOf = /* @__PURE__ */ new WeakMap();
|
|
8
|
+
/** The binding hooks of a proxy made by createFormApiProxy; undefined for any other object. */
|
|
9
|
+
function getFormApiProxyInternals(proxy) {
|
|
10
|
+
return proxy && internalsOf.get(proxy);
|
|
11
|
+
}
|
|
7
12
|
/**
|
|
8
|
-
* A FormApi that exists before its Form mounts: the Form binds the real api through `
|
|
9
|
-
* form state through `
|
|
13
|
+
* A FormApi that exists before its Form mounts: the Form binds the real api through `bind` and pushes every
|
|
14
|
+
* form state through `updateState`, which the framework hook stores in its own state.
|
|
10
15
|
*/
|
|
11
16
|
function createFormApiProxy(setFormState) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
setFormState(api.getFormState());
|
|
17
|
-
},
|
|
18
|
-
__unbind: () => {
|
|
19
|
-
internals.__realApi = null;
|
|
20
|
-
setFormState(EMPTY_FORM_STATE);
|
|
21
|
-
},
|
|
22
|
-
__updateState: setFormState
|
|
23
|
-
};
|
|
24
|
-
return new Proxy(internals, {
|
|
25
|
-
get(target, prop) {
|
|
26
|
-
if (typeof prop !== "string") return Reflect.get(target, prop);
|
|
27
|
-
if (prop.startsWith("__")) return target[prop];
|
|
28
|
-
const realApi = target.__realApi;
|
|
17
|
+
let realApi = null;
|
|
18
|
+
const proxy = new Proxy({}, {
|
|
19
|
+
get(_target, prop) {
|
|
20
|
+
if (typeof prop !== "string") return;
|
|
29
21
|
if (!realApi) {
|
|
30
22
|
if (prop === "then") return;
|
|
31
23
|
return () => {
|
|
@@ -36,13 +28,21 @@ function createFormApiProxy(setFormState) {
|
|
|
36
28
|
if (typeof value === "function") return value.bind(realApi);
|
|
37
29
|
return value;
|
|
38
30
|
},
|
|
39
|
-
set(
|
|
40
|
-
if (typeof prop === "string" && prop.startsWith("__")) {
|
|
41
|
-
Reflect.set(target, prop, value);
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
31
|
+
set() {
|
|
44
32
|
return false;
|
|
45
33
|
}
|
|
46
34
|
});
|
|
35
|
+
internalsOf.set(proxy, {
|
|
36
|
+
bind: (api) => {
|
|
37
|
+
realApi = api;
|
|
38
|
+
setFormState(api.getFormState());
|
|
39
|
+
},
|
|
40
|
+
unbind: () => {
|
|
41
|
+
realApi = null;
|
|
42
|
+
setFormState(EMPTY_FORM_STATE);
|
|
43
|
+
},
|
|
44
|
+
updateState: setFormState
|
|
45
|
+
});
|
|
46
|
+
return proxy;
|
|
47
47
|
}
|
|
48
|
-
export { EMPTY_FORM_STATE, createFormApiProxy };
|
|
48
|
+
export { EMPTY_FORM_STATE, createFormApiProxy, getFormApiProxyInternals };
|
package/dist/form/form.scss
CHANGED
|
@@ -50,12 +50,6 @@ $rating: #{$prefix}-rating;
|
|
|
50
50
|
margin: 0;
|
|
51
51
|
overflow: hidden;
|
|
52
52
|
|
|
53
|
-
&[x-label-pos='top'] {
|
|
54
|
-
// .#{$col}-right,
|
|
55
|
-
// .#{$col}-left {
|
|
56
|
-
// width: 100%;
|
|
57
|
-
// }
|
|
58
|
-
}
|
|
59
53
|
.#{$col} {
|
|
60
54
|
&-right {
|
|
61
55
|
display: flex;
|
|
@@ -82,12 +76,6 @@ $rating: #{$prefix}-rating;
|
|
|
82
76
|
}
|
|
83
77
|
}
|
|
84
78
|
}
|
|
85
|
-
|
|
86
|
-
.#{$field}-pure {
|
|
87
|
-
// padding-top: 0;
|
|
88
|
-
// padding-bottom: 0;
|
|
89
|
-
// overflow: inherit;
|
|
90
|
-
}
|
|
91
79
|
}
|
|
92
80
|
|
|
93
81
|
&-field-label {
|
|
@@ -14,9 +14,9 @@ export default class FormFoundation<E = unknown> extends BaseFoundation<BaseForm
|
|
|
14
14
|
protected getFormProps(keys?: Array<string>): ComponentProps;
|
|
15
15
|
init(): void;
|
|
16
16
|
destroy(): void;
|
|
17
|
-
submit(e?: E)
|
|
18
|
-
reset(fieldPaths?: Array<string>)
|
|
19
|
-
getFieldBridge()
|
|
17
|
+
submit: (e?: E) => void;
|
|
18
|
+
reset: (fieldPaths?: Array<string>) => void;
|
|
19
|
+
getFieldBridge: () => {
|
|
20
20
|
register: (field: string, registration: FieldRegistration) => void;
|
|
21
21
|
unRegister: (field: string) => void;
|
|
22
22
|
setFieldTouched: (registration: FieldRegistration, touched: boolean, opts?: CallOpts) => void;
|
|
@@ -28,7 +28,7 @@ export default class FormFoundation<E = unknown> extends BaseFoundation<BaseForm
|
|
|
28
28
|
getInitValues: () => any;
|
|
29
29
|
getInitValue: (field?: string) => any;
|
|
30
30
|
getFormProps: (keys?: Array<string>) => ComponentProps;
|
|
31
|
-
getField: (field: string) => FieldRegistration
|
|
31
|
+
getField: (field: string) => FieldRegistration;
|
|
32
32
|
registerArrayField: (arrayFieldPath: string, val: any) => void;
|
|
33
33
|
mountArrayField: (arrayFieldPath: string, val: any) => void;
|
|
34
34
|
unRegisterArrayField: (arrayField: string) => void;
|
|
@@ -40,7 +40,7 @@ export default class FormFoundation<E = unknown> extends BaseFoundation<BaseForm
|
|
|
40
40
|
};
|
|
41
41
|
removeArrayFieldRow: (arrayFieldPath: string, index: number) => void;
|
|
42
42
|
};
|
|
43
|
-
getFormApi()
|
|
43
|
+
getFormApi: () => {
|
|
44
44
|
reset: (fields?: Array<string>) => void;
|
|
45
45
|
validate: (fields?: Array<string> | ValidateOptions) => Promise<unknown>;
|
|
46
46
|
getValue: (field?: string) => any;
|