@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
|
@@ -8,7 +8,6 @@ export interface RadioChangeEvent {
|
|
|
8
8
|
stopPropagation: () => void;
|
|
9
9
|
preventDefault: () => void;
|
|
10
10
|
}
|
|
11
|
-
/** What a radio reads from the enclosing RadioGroup */
|
|
12
11
|
export interface RadioGroupView {
|
|
13
12
|
value?: unknown;
|
|
14
13
|
disabled?: boolean;
|
|
@@ -24,7 +23,6 @@ export interface RadioContextView {
|
|
|
24
23
|
mode?: string;
|
|
25
24
|
radioGroup?: RadioGroupView;
|
|
26
25
|
}
|
|
27
|
-
/** The props the foundation reads with getProps */
|
|
28
26
|
export interface RadioBaseProps {
|
|
29
27
|
checked?: boolean;
|
|
30
28
|
defaultChecked?: boolean;
|
|
@@ -55,7 +53,6 @@ export interface RadioView {
|
|
|
55
53
|
buttonSize?: string;
|
|
56
54
|
prefixCls?: string;
|
|
57
55
|
}
|
|
58
|
-
/** The part of the native event the foundation forwards */
|
|
59
56
|
interface RadioSourceEvent {
|
|
60
57
|
stopPropagation: () => void;
|
|
61
58
|
preventDefault: () => void;
|
|
@@ -63,16 +60,15 @@ interface RadioSourceEvent {
|
|
|
63
60
|
export default class RadioFoundation<P extends RadioBaseProps = RadioBaseProps, S extends RadioBaseState = RadioBaseState> extends BaseFoundation<RadioAdapter<P, S>, P, S> {
|
|
64
61
|
#private;
|
|
65
62
|
static getInitialState(props: Pick<RadioBaseProps, 'checked' | 'defaultChecked'>): RadioBaseState;
|
|
66
|
-
/** How the radio looks and behaves, from its own props or, inside a group, from the group */
|
|
67
63
|
static deriveView(props: RadioBaseProps, state: RadioBaseState, context?: RadioContextView | null): RadioView;
|
|
68
64
|
init(): void;
|
|
69
65
|
destroy(): void;
|
|
70
|
-
setChecked(checked: boolean)
|
|
66
|
+
setChecked: (checked: boolean) => void;
|
|
71
67
|
/** `checked` is the value the native input reports, or false for the uncheck of advanced mode */
|
|
72
|
-
handleChange(checked: boolean, e: RadioSourceEvent)
|
|
73
|
-
handleClick(e: RadioSourceEvent)
|
|
74
|
-
handleKeyUp(e: RadioSourceEvent & {
|
|
68
|
+
handleChange: (checked: boolean, e: RadioSourceEvent) => void;
|
|
69
|
+
handleClick: (e: RadioSourceEvent) => void;
|
|
70
|
+
handleKeyUp: (e: RadioSourceEvent & {
|
|
75
71
|
key: string;
|
|
76
|
-
})
|
|
72
|
+
}) => void;
|
|
77
73
|
}
|
|
78
74
|
export {};
|
|
@@ -7,21 +7,20 @@ var RadioFoundation = class RadioFoundation extends BaseFoundation {
|
|
|
7
7
|
return RadioFoundation.deriveView(this.getProps(), this.getStates(), this.getContexts());
|
|
8
8
|
}
|
|
9
9
|
#isStandalone() {
|
|
10
|
-
return !this.getContexts()?.radioGroup && !this.
|
|
10
|
+
return !this.getContexts()?.radioGroup && !this.isControlledComponent("checked");
|
|
11
11
|
}
|
|
12
12
|
/** Unchecks, without notifying, the standalone radios that share this one's native group (same form and name) */
|
|
13
13
|
#uncheckPeers() {
|
|
14
|
-
const input = this.
|
|
14
|
+
const input = this.adapter.getInput();
|
|
15
15
|
if (!input?.name || !this.#isStandalone()) return;
|
|
16
16
|
for (const peer of RadioFoundation.#standalone) {
|
|
17
|
-
const peerInput = peer.
|
|
17
|
+
const peerInput = peer.adapter.getInput();
|
|
18
18
|
if (peer !== this && peer.#isStandalone() && peerInput?.name === input.name && peerInput.form === input.form && peerInput.getRootNode() === input.getRootNode() && peer.getState("checked")) peer.setChecked(false);
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
static getInitialState(props) {
|
|
22
22
|
return { checked: typeof props.checked === "boolean" ? props.checked : Boolean(props.defaultChecked) };
|
|
23
23
|
}
|
|
24
|
-
/** How the radio looks and behaves, from its own props or, inside a group, from the group */
|
|
25
24
|
static deriveView(props, state, context) {
|
|
26
25
|
const group = context?.radioGroup;
|
|
27
26
|
if (group) return {
|
|
@@ -54,11 +53,11 @@ var RadioFoundation = class RadioFoundation extends BaseFoundation {
|
|
|
54
53
|
destroy() {
|
|
55
54
|
RadioFoundation.#standalone.delete(this);
|
|
56
55
|
}
|
|
57
|
-
setChecked(checked) {
|
|
58
|
-
this.
|
|
59
|
-
}
|
|
56
|
+
setChecked = (checked) => {
|
|
57
|
+
this.adapter.setChecked(checked);
|
|
58
|
+
};
|
|
60
59
|
/** `checked` is the value the native input reports, or false for the uncheck of advanced mode */
|
|
61
|
-
handleChange(checked, e) {
|
|
60
|
+
handleChange = (checked, e) => {
|
|
62
61
|
const props = this.getProps();
|
|
63
62
|
const group = this.getContexts()?.radioGroup;
|
|
64
63
|
const event = {
|
|
@@ -72,23 +71,23 @@ var RadioFoundation = class RadioFoundation extends BaseFoundation {
|
|
|
72
71
|
stopPropagation: () => e.stopPropagation(),
|
|
73
72
|
preventDefault: () => e.preventDefault()
|
|
74
73
|
};
|
|
75
|
-
this.
|
|
76
|
-
if (!this.
|
|
74
|
+
this.adapter.notifyGroupChange(event);
|
|
75
|
+
if (!this.isControlledComponent("checked")) {
|
|
77
76
|
if (checked) this.#uncheckPeers();
|
|
78
77
|
this.setChecked(checked);
|
|
79
78
|
}
|
|
80
|
-
this.
|
|
81
|
-
}
|
|
82
|
-
handleClick(e) {
|
|
79
|
+
this.adapter.notifyChange(event);
|
|
80
|
+
};
|
|
81
|
+
handleClick = (e) => {
|
|
83
82
|
const { checked, mode } = this.#getView();
|
|
84
83
|
if (mode === "advanced" && checked) this.handleChange(false, e);
|
|
85
|
-
}
|
|
86
|
-
handleKeyUp(e) {
|
|
84
|
+
};
|
|
85
|
+
handleKeyUp = (e) => {
|
|
87
86
|
const { checked, mode } = this.#getView();
|
|
88
87
|
if (e.key === " " && mode === "advanced" && checked) {
|
|
89
88
|
e.preventDefault();
|
|
90
89
|
this.handleChange(false, e);
|
|
91
90
|
}
|
|
92
|
-
}
|
|
91
|
+
};
|
|
93
92
|
};
|
|
94
93
|
export { RadioFoundation as default };
|
|
@@ -4,7 +4,6 @@ export interface RadioGroupAdapter<P extends RadioGroupBaseProps = RadioGroupBas
|
|
|
4
4
|
notifyChange: (e: RadioChangeEvent) => void;
|
|
5
5
|
setValue: (value: any) => void;
|
|
6
6
|
}
|
|
7
|
-
/** The props the foundation reads with getProp */
|
|
8
7
|
export interface RadioGroupBaseProps {
|
|
9
8
|
mode?: string;
|
|
10
9
|
value?: unknown;
|
|
@@ -13,6 +12,6 @@ export interface RadioGroupBaseState {
|
|
|
13
12
|
value?: any;
|
|
14
13
|
}
|
|
15
14
|
export default class RadioGroupFoundation<P extends RadioGroupBaseProps = RadioGroupBaseProps, S extends RadioGroupBaseState = RadioGroupBaseState> extends BaseFoundation<RadioGroupAdapter<P, S>, P, S> {
|
|
16
|
-
handleChange(evt: RadioChangeEvent)
|
|
17
|
-
handlePropValueChange(propValue: string | number | boolean)
|
|
15
|
+
handleChange: (evt: RadioChangeEvent) => void;
|
|
16
|
+
handlePropValueChange: (propValue: string | number | boolean) => void;
|
|
18
17
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import BaseFoundation from "../base/foundation.js";
|
|
2
2
|
// src/radio/radio-group-foundation.ts
|
|
3
3
|
var RadioGroupFoundation = class extends BaseFoundation {
|
|
4
|
-
handleChange(evt) {
|
|
4
|
+
handleChange = (evt) => {
|
|
5
5
|
const mode = this.getProp("mode");
|
|
6
6
|
const lastValue = this.getState("value");
|
|
7
7
|
const { checked, value } = evt.target;
|
|
8
|
-
const isControlledComponent = this.
|
|
8
|
+
const isControlledComponent = this.isControlledComponent();
|
|
9
9
|
const cbValue = {
|
|
10
10
|
...evt,
|
|
11
11
|
target: {
|
|
@@ -15,13 +15,13 @@ var RadioGroupFoundation = class extends BaseFoundation {
|
|
|
15
15
|
};
|
|
16
16
|
if (mode === "advanced" && !checked) cbValue.target.value = void 0;
|
|
17
17
|
if (!isControlledComponent) {
|
|
18
|
-
if (mode === "advanced" && !checked) this.
|
|
19
|
-
else this.
|
|
18
|
+
if (mode === "advanced" && !checked) this.adapter.setValue(void 0);
|
|
19
|
+
else this.adapter.setValue(value);
|
|
20
20
|
}
|
|
21
|
-
if (mode === "advanced" || lastValue !== value) this.
|
|
22
|
-
}
|
|
23
|
-
handlePropValueChange(propValue) {
|
|
24
|
-
this.
|
|
25
|
-
}
|
|
21
|
+
if (mode === "advanced" || lastValue !== value) this.adapter.notifyChange(cbValue);
|
|
22
|
+
};
|
|
23
|
+
handlePropValueChange = (propValue) => {
|
|
24
|
+
this.adapter.setValue(propValue);
|
|
25
|
+
};
|
|
26
26
|
};
|
|
27
27
|
export { RadioGroupFoundation as default };
|
|
@@ -42,10 +42,8 @@ export interface RatingState {
|
|
|
42
42
|
value: number;
|
|
43
43
|
hoverValue: number;
|
|
44
44
|
clearedValue: number;
|
|
45
|
-
/** index of the star that holds keyboard focus */
|
|
46
45
|
focusVisibleStar?: number;
|
|
47
46
|
}
|
|
48
|
-
/** The props the foundation reads with getProps */
|
|
49
47
|
export interface RatingBaseProps extends RatingValueProps {
|
|
50
48
|
count?: number;
|
|
51
49
|
allowHalf?: boolean;
|
|
@@ -75,7 +73,6 @@ export default class RatingFoundation<P extends RatingBaseProps = RatingBaseProp
|
|
|
75
73
|
disabled: boolean;
|
|
76
74
|
firstTabStop: boolean;
|
|
77
75
|
}): RatingItemModel;
|
|
78
|
-
/** Whether a focus on `value` belongs to the first (half) radio of the star at `index` */
|
|
79
76
|
static isFirstRadio(value: number, index: number, allowHalf: boolean): boolean;
|
|
80
77
|
/**
|
|
81
78
|
* The value a click selects through the radio it hit, or undefined when it is an ordinary pointer click. Detail 0 is
|
|
@@ -83,7 +80,6 @@ export default class RatingFoundation<P extends RatingBaseProps = RatingBaseProp
|
|
|
83
80
|
* activated radio decides the value
|
|
84
81
|
*/
|
|
85
82
|
static resolveClickRadio(detail: number, radioValue?: number): number | undefined;
|
|
86
|
-
/** What Enter or Space on a radio does: whether to `preventDefault` the key, and the value to select if any */
|
|
87
83
|
static resolveKeyActivation(key: string, radioValue: number | undefined, value: number): {
|
|
88
84
|
preventDefault: boolean;
|
|
89
85
|
selectValue?: number;
|
|
@@ -92,18 +88,17 @@ export default class RatingFoundation<P extends RatingBaseProps = RatingBaseProp
|
|
|
92
88
|
static isTipVisible(index: number, hoverValue?: number, focusVisibleStar?: number, tip?: string): boolean;
|
|
93
89
|
init(): void;
|
|
94
90
|
/** A value prop that goes back to undefined (a form reset) returns to defaultValue, like Slider (Switch and Checkbox become unchecked) */
|
|
95
|
-
resetValue()
|
|
96
|
-
handleHover(event: Pick<MouseEvent,
|
|
97
|
-
handleMouseLeave()
|
|
98
|
-
handleClick(event: CE & Pick<MouseEvent,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
handleFocus(e: FE): void;
|
|
91
|
+
resetValue: () => void;
|
|
92
|
+
handleHover: (event: Pick<MouseEvent, "pageX">, index: number) => void;
|
|
93
|
+
handleMouseLeave: () => void;
|
|
94
|
+
handleClick: (event: CE & Pick<MouseEvent, "pageX">, index: number) => void;
|
|
95
|
+
handleSelect: (event: CE, index: number, newValue: number) => void;
|
|
96
|
+
handleFocus: (e: FE) => void;
|
|
102
97
|
/** A radio of the star at `index` got focus; index === count is the empty star */
|
|
103
|
-
handleStarFocus(e: {
|
|
98
|
+
handleStarFocus: (e: {
|
|
104
99
|
target: Element;
|
|
105
|
-
}, index: number)
|
|
106
|
-
handleBlur(e: FE)
|
|
107
|
-
handleKeyDown(event: KE, value: number)
|
|
100
|
+
}, index: number) => void;
|
|
101
|
+
handleBlur: (e: FE) => void;
|
|
102
|
+
handleKeyDown: (event: KE, value: number) => void;
|
|
108
103
|
}
|
|
109
104
|
export {};
|
|
@@ -6,20 +6,20 @@ var RatingFoundation = class RatingFoundation extends BaseFoundation {
|
|
|
6
6
|
return el.getBoundingClientRect().left + el.ownerDocument.defaultView.scrollX;
|
|
7
7
|
}
|
|
8
8
|
#changeHover(hoverValue, clearedValue) {
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
9
|
+
this.adapter.setHover(hoverValue, clearedValue);
|
|
10
|
+
this.adapter.notifyHoverChange(hoverValue);
|
|
11
11
|
}
|
|
12
12
|
#updateValue(value) {
|
|
13
|
-
if (!this.
|
|
14
|
-
this.
|
|
13
|
+
if (!this.isControlledComponent()) this.adapter.setValue(value);
|
|
14
|
+
this.adapter.notifyChange(value);
|
|
15
15
|
}
|
|
16
16
|
getStarValue(index, pos) {
|
|
17
17
|
const { allowHalf, count } = this.getProps();
|
|
18
18
|
if (index === count) return 0;
|
|
19
|
-
const reverse = this.
|
|
19
|
+
const reverse = this.adapter.getContext("direction") === "rtl";
|
|
20
20
|
let value = index + 1;
|
|
21
21
|
if (allowHalf) {
|
|
22
|
-
const starEle = this.
|
|
22
|
+
const starEle = this.adapter.getStarDOM(index);
|
|
23
23
|
if (!starEle) return value;
|
|
24
24
|
const leftDis = this.#getOffsetLeft(starEle);
|
|
25
25
|
const width = starEle.clientWidth;
|
|
@@ -64,7 +64,6 @@ var RatingFoundation = class RatingFoundation extends BaseFoundation {
|
|
|
64
64
|
secondPosInSet: allowHalf ? isEmpty ? 2 * count + 1 : 2 * (index + 1) : index + 1
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
/** Whether a focus on `value` belongs to the first (half) radio of the star at `index` */
|
|
68
67
|
static isFirstRadio(value, index, allowHalf) {
|
|
69
68
|
return allowHalf && value - index === .5;
|
|
70
69
|
}
|
|
@@ -76,7 +75,6 @@ var RatingFoundation = class RatingFoundation extends BaseFoundation {
|
|
|
76
75
|
static resolveClickRadio(detail, radioValue) {
|
|
77
76
|
return detail === 0 ? radioValue : void 0;
|
|
78
77
|
}
|
|
79
|
-
/** What Enter or Space on a radio does: whether to `preventDefault` the key, and the value to select if any */
|
|
80
78
|
static resolveKeyActivation(key, radioValue, value) {
|
|
81
79
|
const isSpace = key === " ";
|
|
82
80
|
if (key !== "Enter" && !isSpace || radioValue === void 0) return { preventDefault: false };
|
|
@@ -93,51 +91,50 @@ var RatingFoundation = class RatingFoundation extends BaseFoundation {
|
|
|
93
91
|
if (this.#initialized) return;
|
|
94
92
|
this.#initialized = true;
|
|
95
93
|
const { autoFocus, disabled } = this.getProps();
|
|
96
|
-
if (autoFocus && !disabled) this.
|
|
94
|
+
if (autoFocus && !disabled) this.adapter.focusStar(RatingFoundation.deriveValue(this.getProps(), this.getStates()));
|
|
97
95
|
}
|
|
98
96
|
/** A value prop that goes back to undefined (a form reset) returns to defaultValue, like Slider (Switch and Checkbox become unchecked) */
|
|
99
|
-
resetValue() {
|
|
100
|
-
this.
|
|
101
|
-
}
|
|
102
|
-
handleHover(event, index) {
|
|
97
|
+
resetValue = () => {
|
|
98
|
+
this.adapter.setValue(this.getProps().defaultValue);
|
|
99
|
+
};
|
|
100
|
+
handleHover = (event, index) => {
|
|
103
101
|
const currValue = this.getStarValue(index, event.pageX);
|
|
104
102
|
const { clearedValue, hoverValue } = this.getStates();
|
|
105
103
|
if (currValue !== hoverValue && currValue !== clearedValue) this.#changeHover(currValue, null);
|
|
106
|
-
}
|
|
107
|
-
handleMouseLeave() {
|
|
104
|
+
};
|
|
105
|
+
handleMouseLeave = () => {
|
|
108
106
|
this.#changeHover(void 0, null);
|
|
109
|
-
}
|
|
110
|
-
handleClick(event, index) {
|
|
107
|
+
};
|
|
108
|
+
handleClick = (event, index) => {
|
|
111
109
|
this.handleSelect(event, index, this.getStarValue(index, event.pageX));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
handleSelect(event, index, newValue) {
|
|
110
|
+
};
|
|
111
|
+
handleSelect = (event, index, newValue) => {
|
|
115
112
|
const { allowClear } = this.getProps();
|
|
116
113
|
const value = RatingFoundation.deriveValue(this.getProps(), this.getStates());
|
|
117
114
|
const isReset = allowClear ? newValue === value : false;
|
|
118
115
|
this.#updateValue(isReset ? 0 : newValue);
|
|
119
116
|
if (isReset) this.#changeHover(void 0, newValue);
|
|
120
|
-
else this.
|
|
121
|
-
this.
|
|
122
|
-
}
|
|
123
|
-
handleFocus(e) {
|
|
124
|
-
if (!e.currentTarget.contains(e.relatedTarget)) this.
|
|
125
|
-
}
|
|
117
|
+
else this.adapter.setClearedValue(null);
|
|
118
|
+
this.adapter.notifyClick(event, index);
|
|
119
|
+
};
|
|
120
|
+
handleFocus = (e) => {
|
|
121
|
+
if (!e.currentTarget.contains(e.relatedTarget)) this.adapter.notifyFocus(e);
|
|
122
|
+
};
|
|
126
123
|
/** A radio of the star at `index` got focus; index === count is the empty star */
|
|
127
|
-
handleStarFocus(e, index) {
|
|
128
|
-
if (e.target.matches(":focus-visible") || this.getStates().focusVisibleStar !== void 0) this.
|
|
129
|
-
}
|
|
130
|
-
handleBlur(e) {
|
|
124
|
+
handleStarFocus = (e, index) => {
|
|
125
|
+
if (e.target.matches(":focus-visible") || this.getStates().focusVisibleStar !== void 0) this.adapter.setFocusVisibleStar(index);
|
|
126
|
+
};
|
|
127
|
+
handleBlur = (e) => {
|
|
131
128
|
if (!e.currentTarget.contains(e.relatedTarget)) {
|
|
132
|
-
this.
|
|
133
|
-
this.
|
|
129
|
+
this.adapter.notifyBlur(e);
|
|
130
|
+
this.adapter.setFocusVisibleStar(void 0);
|
|
134
131
|
}
|
|
135
|
-
}
|
|
136
|
-
handleKeyDown(event, value) {
|
|
132
|
+
};
|
|
133
|
+
handleKeyDown = (event, value) => {
|
|
137
134
|
if (event.altKey || event.ctrlKey || event.metaKey) return;
|
|
138
135
|
const { key } = event;
|
|
139
136
|
const { count, allowHalf } = this.getProps();
|
|
140
|
-
const reverse = this.
|
|
137
|
+
const reverse = this.adapter.getContext("direction") === "rtl";
|
|
141
138
|
const step = allowHalf ? .5 : 1;
|
|
142
139
|
const next = (Math.floor(value / step) + 1) * step;
|
|
143
140
|
const previous = (Math.ceil(value / step) - 1) * step;
|
|
@@ -156,12 +153,12 @@ var RatingFoundation = class RatingFoundation extends BaseFoundation {
|
|
|
156
153
|
"ArrowLeft",
|
|
157
154
|
"ArrowDown"
|
|
158
155
|
].includes(key)) {
|
|
159
|
-
this.
|
|
156
|
+
this.adapter.notifyKeyDown(event);
|
|
160
157
|
this.#updateValue(newValue);
|
|
161
|
-
this.
|
|
158
|
+
this.adapter.focusStar(newValue);
|
|
162
159
|
event.preventDefault();
|
|
163
160
|
this.#changeHover(void 0, null);
|
|
164
161
|
}
|
|
165
|
-
}
|
|
162
|
+
};
|
|
166
163
|
};
|
|
167
164
|
export { RatingFoundation as default };
|
|
@@ -19,7 +19,6 @@ export interface ResizeGroupAdapter<P extends ResizeGroupBaseProps = ResizeGroup
|
|
|
19
19
|
getItemEnd: (index: number) => ResizeCallback | undefined;
|
|
20
20
|
getItemDefaultSize: (index: number) => string | number | undefined;
|
|
21
21
|
}
|
|
22
|
-
/** The props the foundation reads with getProp */
|
|
23
22
|
export interface ResizeGroupBaseProps {
|
|
24
23
|
direction?: 'horizontal' | 'vertical';
|
|
25
24
|
}
|
|
@@ -37,19 +36,16 @@ export declare class ResizeGroupFoundation<P extends ResizeGroupBaseProps = Resi
|
|
|
37
36
|
/**
|
|
38
37
|
* Re-runs initSpace the first time the group is measurable (#3336); later resizes must not, or the drag is lost.
|
|
39
38
|
*/
|
|
40
|
-
handleGroupResize()
|
|
41
|
-
|
|
42
|
-
* Moves each item's inline size to the new axis, where the handlers take a different length
|
|
43
|
-
*/
|
|
44
|
-
handleDirectionChange(): void;
|
|
39
|
+
handleGroupResize: () => void;
|
|
40
|
+
handleDirectionChange: () => void;
|
|
45
41
|
/**
|
|
46
42
|
* Keyboard resize, reported like a drag: arrows move 1% of the group (Shift: 10%), Home and End go to the
|
|
47
43
|
* limits. Returns whether the key was handled.
|
|
48
44
|
*/
|
|
49
|
-
resizeByKey(handlerIndex: number, e: KeyboardEvent)
|
|
50
|
-
onResizeStart(handlerIndex: number, e: PointerEvent)
|
|
51
|
-
onResizing(e: PointerEvent)
|
|
52
|
-
onResizeEnd(e: PointerEvent)
|
|
45
|
+
resizeByKey: (handlerIndex: number, e: KeyboardEvent) => boolean;
|
|
46
|
+
onResizeStart: (handlerIndex: number, e: PointerEvent) => void;
|
|
47
|
+
onResizing: (e: PointerEvent) => void;
|
|
48
|
+
onResizeEnd: (e: PointerEvent) => void;
|
|
53
49
|
ensureConstraint: import("es-toolkit").DebouncedFunction<() => void>;
|
|
54
50
|
destroy(): void;
|
|
55
51
|
}
|
|
@@ -12,7 +12,7 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
12
12
|
return this.getProp("direction");
|
|
13
13
|
}
|
|
14
14
|
get #groupRef() {
|
|
15
|
-
return this.
|
|
15
|
+
return this.adapter.getGroupRef();
|
|
16
16
|
}
|
|
17
17
|
get #groupSize() {
|
|
18
18
|
return this.#direction === "horizontal" ? this.#groupRef.offsetWidth : this.#groupRef.offsetHeight;
|
|
@@ -29,11 +29,11 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
29
29
|
}
|
|
30
30
|
#clampItem(index, size) {
|
|
31
31
|
const groupSize = this.#groupSize;
|
|
32
|
-
return clamp$1(size, this.#toPixels(this.
|
|
32
|
+
return clamp$1(size, this.#toPixels(this.adapter.getItemMin(index) ?? "0%", groupSize), this.#toPixels(this.adapter.getItemMax(index) ?? "100%", groupSize));
|
|
33
33
|
}
|
|
34
34
|
#applyDelta(curHandler, { lastItemSize, nextItemSize }, delta, e) {
|
|
35
35
|
const direction = this.#direction;
|
|
36
|
-
let lastItem = this.
|
|
36
|
+
let lastItem = this.adapter.getItem(curHandler), nextItem = this.adapter.getItem(curHandler + 1);
|
|
37
37
|
let parentSize = this.#groupSize;
|
|
38
38
|
let lastNewSize = lastItemSize + delta;
|
|
39
39
|
let nextNewSize = nextItemSize - delta;
|
|
@@ -59,7 +59,7 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
59
59
|
lastItem.style.height = `calc(${lastNewPercent}% - ${this.#itemMinusMap.get(curHandler)}px)`;
|
|
60
60
|
nextItem.style.height = `calc(${nextNewPercent}% - ${this.#itemMinusMap.get(curHandler + 1)}px)`;
|
|
61
61
|
}
|
|
62
|
-
let lastFunc = this.
|
|
62
|
+
let lastFunc = this.adapter.getItemChange(curHandler), nextFunc = this.adapter.getItemChange(curHandler + 1);
|
|
63
63
|
let [lastDir, nextDir] = getItemDirection(direction);
|
|
64
64
|
if (lastFunc) lastFunc({
|
|
65
65
|
width: lastItem.offsetWidth,
|
|
@@ -72,8 +72,8 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
72
72
|
this.#syncAria();
|
|
73
73
|
}
|
|
74
74
|
#notifyResizeEnd(curHandler, e) {
|
|
75
|
-
let lastItem = this.
|
|
76
|
-
let lastFunc = this.
|
|
75
|
+
let lastItem = this.adapter.getItem(curHandler), nextItem = this.adapter.getItem(curHandler + 1);
|
|
76
|
+
let lastFunc = this.adapter.getItemEnd(curHandler), nextFunc = this.adapter.getItemEnd(curHandler + 1);
|
|
77
77
|
let [lastDir, nextDir] = getItemDirection(this.#direction);
|
|
78
78
|
if (lastFunc) lastFunc({
|
|
79
79
|
width: lastItem.offsetWidth,
|
|
@@ -89,8 +89,8 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
89
89
|
if (!parentSize) return;
|
|
90
90
|
const percent = (px) => px / parentSize * 100;
|
|
91
91
|
const limits = (index) => {
|
|
92
|
-
const min = this.
|
|
93
|
-
const max = this.
|
|
92
|
+
const min = this.adapter.getItemMin(index);
|
|
93
|
+
const max = this.adapter.getItemMax(index);
|
|
94
94
|
const minus = this.#itemMinusMap.get(index);
|
|
95
95
|
return {
|
|
96
96
|
min: percent((min ? this.#toPixels(min, parentSize) : 0) + minus),
|
|
@@ -98,9 +98,9 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
98
98
|
};
|
|
99
99
|
};
|
|
100
100
|
const round = (value) => String(Number(value.toFixed(1)));
|
|
101
|
-
for (let i = 0; i < this.
|
|
102
|
-
const handler = this.
|
|
103
|
-
const item = this.
|
|
101
|
+
for (let i = 0; i < this.adapter.getHandlerCount() && i + 1 < this.adapter.getItemCount(); i++) {
|
|
102
|
+
const handler = this.adapter.getHandler(i);
|
|
103
|
+
const item = this.adapter.getItem(i);
|
|
104
104
|
const last = limits(i);
|
|
105
105
|
const next = limits(i + 1);
|
|
106
106
|
const total = this.#itemPercentMap.get(i) + this.#itemPercentMap.get(i + 1);
|
|
@@ -113,11 +113,11 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
113
113
|
}
|
|
114
114
|
#measureHandlerRoom() {
|
|
115
115
|
const horizontal = this.#direction === "horizontal";
|
|
116
|
-
const handlerSizes = Array.from({ length: this.
|
|
117
|
-
const handler = this.
|
|
116
|
+
const handlerSizes = Array.from({ length: this.adapter.getHandlerCount() }, (_, i) => {
|
|
117
|
+
const handler = this.adapter.getHandler(i);
|
|
118
118
|
return horizontal ? handler.offsetWidth : handler.offsetHeight;
|
|
119
119
|
});
|
|
120
|
-
const itemCount = this.
|
|
120
|
+
const itemCount = this.adapter.getItemCount();
|
|
121
121
|
for (let i = 0; i < itemCount; i++) {
|
|
122
122
|
const before = i > 0 ? handlerSizes[i - 1] / 2 : 0;
|
|
123
123
|
const after = i < itemCount - 1 ? handlerSizes[i] / 2 : 0;
|
|
@@ -131,12 +131,12 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
131
131
|
this.#measureHandlerRoom();
|
|
132
132
|
let totalSizePercent = 0;
|
|
133
133
|
let undefineLoc = /* @__PURE__ */ new Map(), undefinedTotal = 0;
|
|
134
|
-
for (let i = 0; i < this.
|
|
135
|
-
const child = this.
|
|
136
|
-
let minSize = this.
|
|
134
|
+
for (let i = 0; i < this.adapter.getItemCount(); i++) {
|
|
135
|
+
const child = this.adapter.getItem(i);
|
|
136
|
+
let minSize = this.adapter.getItemMin(i), maxSize = this.adapter.getItemMax(i);
|
|
137
137
|
let minSizePercent = minSize ? this.#toPixels(minSize, parentSize) / parentSize * 100 : 0, maxSizePercent = maxSize ? this.#toPixels(maxSize, parentSize) / parentSize * 100 : 100;
|
|
138
138
|
if (minSizePercent > maxSizePercent) console.warn("[Semi ResizableItem]: min size bigger than max size");
|
|
139
|
-
let defaultSize = this.
|
|
139
|
+
let defaultSize = this.adapter.getItemDefaultSize(i);
|
|
140
140
|
if (defaultSize) {
|
|
141
141
|
let itemSizePercent;
|
|
142
142
|
if (typeof defaultSize === "string") {
|
|
@@ -168,7 +168,7 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
168
168
|
undefineSizePercent = 10;
|
|
169
169
|
}
|
|
170
170
|
undefineLoc.forEach((value, key) => {
|
|
171
|
-
const child = this.
|
|
171
|
+
const child = this.adapter.getItem(key);
|
|
172
172
|
const percent = value / undefinedTotal * undefineSizePercent;
|
|
173
173
|
this.#itemPercentMap.set(key, percent);
|
|
174
174
|
if (direction === "horizontal") child.style.width = `calc(${percent}% - ${this.#itemMinusMap.get(key)}px)`;
|
|
@@ -177,7 +177,7 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
177
177
|
this.#syncAria();
|
|
178
178
|
}
|
|
179
179
|
#measure(handlerIndex, x, y) {
|
|
180
|
-
let lastItem = this.
|
|
180
|
+
let lastItem = this.adapter.getItem(handlerIndex), nextItem = this.adapter.getItem(handlerIndex + 1);
|
|
181
181
|
return {
|
|
182
182
|
x,
|
|
183
183
|
y,
|
|
@@ -185,11 +185,10 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
185
185
|
nextItemSize: (this.#direction === "horizontal" ? nextItem.offsetWidth : nextItem.offsetHeight) + this.#itemMinusMap.get(handlerIndex + 1)
|
|
186
186
|
};
|
|
187
187
|
}
|
|
188
|
-
/** Returns false when either item's onResizeStart returned false */
|
|
189
188
|
#notifyResizeStart(handlerIndex, e) {
|
|
190
189
|
const [lastDir, nextDir] = getItemDirection(this.#direction);
|
|
191
|
-
const lastResult = this.
|
|
192
|
-
const nextResult = this.
|
|
190
|
+
const lastResult = this.adapter.getItemStart(handlerIndex)?.(e, lastDir);
|
|
191
|
+
const nextResult = this.adapter.getItemStart(handlerIndex + 1)?.(e, nextDir);
|
|
193
192
|
return lastResult !== false && nextResult !== false;
|
|
194
193
|
}
|
|
195
194
|
init() {
|
|
@@ -200,27 +199,24 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
200
199
|
/**
|
|
201
200
|
* Re-runs initSpace the first time the group is measurable (#3336); later resizes must not, or the drag is lost.
|
|
202
201
|
*/
|
|
203
|
-
handleGroupResize() {
|
|
202
|
+
handleGroupResize = () => {
|
|
204
203
|
if (!this.#sizeInitialized && this.#groupSize > 0) this.#initSpace();
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
* Moves each item's inline size to the new axis, where the handlers take a different length
|
|
208
|
-
*/
|
|
209
|
-
handleDirectionChange() {
|
|
204
|
+
};
|
|
205
|
+
handleDirectionChange = () => {
|
|
210
206
|
const [stale, current] = this.#direction === "horizontal" ? ["height", "width"] : ["width", "height"];
|
|
211
207
|
this.#measureHandlerRoom();
|
|
212
|
-
for (let i = 0; i < this.
|
|
213
|
-
const item = this.
|
|
208
|
+
for (let i = 0; i < this.adapter.getItemCount(); i++) {
|
|
209
|
+
const item = this.adapter.getItem(i);
|
|
214
210
|
item.style.removeProperty(stale);
|
|
215
211
|
item.style[current] = `calc(${this.#itemPercentMap.get(i)}% - ${this.#itemMinusMap.get(i)}px)`;
|
|
216
212
|
}
|
|
217
213
|
this.#syncAria();
|
|
218
|
-
}
|
|
214
|
+
};
|
|
219
215
|
/**
|
|
220
216
|
* Keyboard resize, reported like a drag: arrows move 1% of the group (Shift: 10%), Home and End go to the
|
|
221
217
|
* limits. Returns whether the key was handled.
|
|
222
218
|
*/
|
|
223
|
-
resizeByKey(handlerIndex, e) {
|
|
219
|
+
resizeByKey = (handlerIndex, e) => {
|
|
224
220
|
if (e.altKey || e.ctrlKey || e.metaKey) return false;
|
|
225
221
|
const [backKey, forwardKey] = this.#direction === "horizontal" ? ["ArrowLeft", "ArrowRight"] : ["ArrowUp", "ArrowDown"];
|
|
226
222
|
const groupSize = this.#groupSize;
|
|
@@ -237,8 +233,8 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
237
233
|
this.#notifyResizeEnd(handlerIndex, e);
|
|
238
234
|
}
|
|
239
235
|
return true;
|
|
240
|
-
}
|
|
241
|
-
onResizeStart(handlerIndex, e) {
|
|
236
|
+
};
|
|
237
|
+
onResizeStart = (handlerIndex, e) => {
|
|
242
238
|
if (isSecondaryPress(e) || !this.#notifyResizeStart(handlerIndex, e)) return;
|
|
243
239
|
const states = this.getStates();
|
|
244
240
|
this.setState({
|
|
@@ -250,15 +246,15 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
250
246
|
},
|
|
251
247
|
curHandler: handlerIndex
|
|
252
248
|
});
|
|
253
|
-
}
|
|
254
|
-
onResizing(e) {
|
|
249
|
+
};
|
|
250
|
+
onResizing = (e) => {
|
|
255
251
|
const state = this.getStates();
|
|
256
252
|
if (!state.isResizing) return;
|
|
257
253
|
const { curHandler, originalPosition } = state;
|
|
258
254
|
const delta = this.#direction === "horizontal" ? e.clientX - originalPosition.x : e.clientY - originalPosition.y;
|
|
259
255
|
this.#applyDelta(curHandler, originalPosition, delta, e);
|
|
260
|
-
}
|
|
261
|
-
onResizeEnd(e) {
|
|
256
|
+
};
|
|
257
|
+
onResizeEnd = (e) => {
|
|
262
258
|
const { isResizing, curHandler } = this.getStates();
|
|
263
259
|
if (!isResizing) return;
|
|
264
260
|
this.#notifyResizeEnd(curHandler, e);
|
|
@@ -266,19 +262,19 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
266
262
|
isResizing: false,
|
|
267
263
|
curHandler: null
|
|
268
264
|
});
|
|
269
|
-
}
|
|
265
|
+
};
|
|
270
266
|
ensureConstraint = debounce(() => {
|
|
271
267
|
if (!this.#groupSize) return;
|
|
272
268
|
const direction = this.#direction;
|
|
273
|
-
const itemCount = this.
|
|
269
|
+
const itemCount = this.adapter.getItemCount();
|
|
274
270
|
let continueFlag = true;
|
|
275
271
|
for (let i = 0; i < itemCount; i++) {
|
|
276
|
-
const child = this.
|
|
272
|
+
const child = this.adapter.getItem(i);
|
|
277
273
|
const childSize = direction === "horizontal" ? child.offsetWidth : child.offsetHeight;
|
|
278
274
|
const childNewSize = this.#clampItem(i, childSize);
|
|
279
275
|
if (childNewSize !== childSize) {
|
|
280
276
|
const j = [...Array.from({ length: itemCount - i - 1 }, (_, k) => i + 1 + k), ...Array.from({ length: i }, (_, k) => i - 1 - k)].find((index) => {
|
|
281
|
-
const item = this.
|
|
277
|
+
const item = this.adapter.getItem(index);
|
|
282
278
|
const itemSize = direction === "horizontal" ? item.offsetWidth : item.offsetHeight;
|
|
283
279
|
return this.#clampItem(index, itemSize) === itemSize;
|
|
284
280
|
});
|
|
@@ -286,7 +282,7 @@ var ResizeGroupFoundation = class extends BaseFoundation {
|
|
|
286
282
|
continueFlag = false;
|
|
287
283
|
console.warn("[Semi ResizableGroup]: no enough space to adjust min/max size");
|
|
288
284
|
} else {
|
|
289
|
-
const item = this.
|
|
285
|
+
const item = this.adapter.getItem(j);
|
|
290
286
|
const childPercent = this.#itemPercentMap.get(i);
|
|
291
287
|
const itemPercent = this.#itemPercentMap.get(j);
|
|
292
288
|
const childNewPercent = (childNewSize + this.#itemMinusMap.get(i)) / this.#groupSize * 100;
|
|
@@ -111,7 +111,6 @@ $module: #{$prefix}-resizable;
|
|
|
111
111
|
&-handler {
|
|
112
112
|
@include flex-center;
|
|
113
113
|
z-index: $z-resizable_handler;
|
|
114
|
-
// a touch drag would otherwise scroll the page and cancel the pointer
|
|
115
114
|
touch-action: none;
|
|
116
115
|
user-select: none;
|
|
117
116
|
background-color: var(--semi-color-fill-0);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import BaseFoundation, { DefaultAdapter } from "../../base/foundation.js";
|
|
2
2
|
import { Direction, ResizeCallback, ResizeStartCallback, Size } from "../types.js";
|
|
3
|
-
/** The props the foundation reads */
|
|
4
3
|
export interface ResizableBaseProps extends SizeProps {
|
|
5
4
|
grid?: [number, number];
|
|
6
5
|
snap?: {
|
|
@@ -73,16 +72,13 @@ export declare class ResizableFoundation<P extends ResizableBaseProps = Resizabl
|
|
|
73
72
|
height: string;
|
|
74
73
|
};
|
|
75
74
|
init(): void;
|
|
76
|
-
/**
|
|
77
|
-
|
|
78
|
-
* unnoticed until the next resize.
|
|
79
|
-
*/
|
|
80
|
-
updateAriaRange(): void;
|
|
75
|
+
/** A change of the limits alone goes unnoticed until the next resize. */
|
|
76
|
+
updateAriaRange: () => void;
|
|
81
77
|
/**
|
|
82
78
|
* Keyboard resize along the axis of the edge, KEYBOARD_STEP px per press, reported like a drag.
|
|
83
79
|
* Returns whether the key was handled.
|
|
84
80
|
*/
|
|
85
|
-
resizeByKey(direction: Direction, e: KeyboardEvent)
|
|
81
|
+
resizeByKey: (direction: Direction, e: KeyboardEvent) => boolean;
|
|
86
82
|
onResizeStart: (e: PointerEvent, direction: Direction) => void;
|
|
87
83
|
onResizing: (event: PointerEvent) => void;
|
|
88
84
|
onResizeEnd: (event: PointerEvent) => void;
|