@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
|
@@ -13,7 +13,7 @@ var JsonViewerFoundation = class extends BaseFoundation {
|
|
|
13
13
|
#lastSearch = null;
|
|
14
14
|
jsonViewer = null;
|
|
15
15
|
#observeResize() {
|
|
16
|
-
const el = this.
|
|
16
|
+
const el = this.adapter.getEditorRef();
|
|
17
17
|
if (!el) return;
|
|
18
18
|
const rect = el.getBoundingClientRect();
|
|
19
19
|
this.#lastObservedSize = {
|
|
@@ -48,18 +48,18 @@ var JsonViewerFoundation = class extends BaseFoundation {
|
|
|
48
48
|
}
|
|
49
49
|
init() {
|
|
50
50
|
const props = this.getProps();
|
|
51
|
-
const editorRef = this.
|
|
51
|
+
const editorRef = this.adapter.getEditorRef();
|
|
52
52
|
this.jsonViewer = new JsonViewer(editorRef, props.value, {
|
|
53
53
|
prefixCls: cssClasses.PREFIX,
|
|
54
54
|
...props.options
|
|
55
55
|
});
|
|
56
56
|
this.jsonViewer.emitter.on("customRender", (e) => {
|
|
57
|
-
this.
|
|
57
|
+
this.adapter.setCustomRenderMap(e.customRenderMap);
|
|
58
58
|
});
|
|
59
59
|
this.jsonViewer.layout();
|
|
60
60
|
this.#searchAgain();
|
|
61
61
|
this.jsonViewer.emitter.on("contentChanged", () => {
|
|
62
|
-
this.
|
|
62
|
+
this.adapter.notifyChange(this.jsonViewer?.getModel().getValue());
|
|
63
63
|
this.#searchAgain();
|
|
64
64
|
});
|
|
65
65
|
this.#observeResize();
|
|
@@ -74,9 +74,9 @@ var JsonViewerFoundation = class extends BaseFoundation {
|
|
|
74
74
|
this.#resetMeasuredHeights = false;
|
|
75
75
|
this.jsonViewer?.dispose();
|
|
76
76
|
this.jsonViewer = null;
|
|
77
|
-
this.
|
|
77
|
+
this.adapter.setCustomRenderMap(/* @__PURE__ */ new Map());
|
|
78
78
|
}
|
|
79
|
-
search(searchText, caseSensitive, wholeWord, regex) {
|
|
79
|
+
search = (searchText, caseSensitive, wholeWord, regex) => {
|
|
80
80
|
let options;
|
|
81
81
|
if (caseSensitive !== void 0 || wholeWord !== void 0 || regex !== void 0) options = {
|
|
82
82
|
caseSensitive: caseSensitive ?? false,
|
|
@@ -89,36 +89,35 @@ var JsonViewerFoundation = class extends BaseFoundation {
|
|
|
89
89
|
...options
|
|
90
90
|
};
|
|
91
91
|
this.jsonViewer?.getSearchWidget().search(searchText, options.caseSensitive, options.wholeWord, options.regex);
|
|
92
|
-
}
|
|
93
|
-
prevSearch(step) {
|
|
92
|
+
};
|
|
93
|
+
prevSearch = (step) => {
|
|
94
94
|
if (step === void 0) this.jsonViewer?.getSearchWidget().navigateResults(-1);
|
|
95
95
|
else this.jsonViewer?.getSearchWidget().navigateResults(-step);
|
|
96
|
-
}
|
|
97
|
-
nextSearch(step) {
|
|
96
|
+
};
|
|
97
|
+
nextSearch = (step) => {
|
|
98
98
|
if (step === void 0) this.jsonViewer?.getSearchWidget().navigateResults(1);
|
|
99
99
|
else this.jsonViewer?.getSearchWidget().navigateResults(step);
|
|
100
|
-
}
|
|
101
|
-
replace(replaceText) {
|
|
100
|
+
};
|
|
101
|
+
replace = (replaceText) => {
|
|
102
102
|
if (this.getProps().options?.readOnly) return;
|
|
103
103
|
this.jsonViewer?.getSearchWidget().replace(replaceText);
|
|
104
|
-
}
|
|
105
|
-
replaceAll(replaceText) {
|
|
104
|
+
};
|
|
105
|
+
replaceAll = (replaceText) => {
|
|
106
106
|
if (this.getProps().options?.readOnly) return;
|
|
107
107
|
this.jsonViewer?.getSearchWidget().replaceAll(replaceText);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
this._adapter.toggleSearchOption(key);
|
|
108
|
+
};
|
|
109
|
+
toggleSearchOption = (key) => {
|
|
110
|
+
this.adapter.toggleSearchOption(key);
|
|
112
111
|
this.search(this.#lastSearch?.text ?? "");
|
|
113
|
-
}
|
|
114
|
-
toggleSearchBar() {
|
|
112
|
+
};
|
|
113
|
+
toggleSearchBar = () => {
|
|
115
114
|
this.#lastSearch = null;
|
|
116
115
|
this.jsonViewer?.getSearchWidget().clear();
|
|
117
|
-
this.
|
|
118
|
-
}
|
|
116
|
+
this.adapter.toggleSearchBar();
|
|
117
|
+
};
|
|
119
118
|
/** `null` when nothing was searched (or the bar was closed), `undefined` while there is no editor */
|
|
120
|
-
getSearchResults() {
|
|
119
|
+
getSearchResults = () => {
|
|
121
120
|
return this.jsonViewer?.getSearchWidget().searchResults;
|
|
122
|
-
}
|
|
121
|
+
};
|
|
123
122
|
};
|
|
124
123
|
export { JsonViewerFoundation as default };
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { Locale as Locale$1 } from "date-fns";
|
|
2
|
-
/** Keys of `Locale` that hold a component's strings */
|
|
3
2
|
export type LocaleComponentName = Exclude<keyof Locale, 'code' | 'dateFnsLocale' | 'currency'>;
|
|
4
3
|
export interface LocaleResult<T> {
|
|
5
|
-
/** `locale[componentName]`: the component's own strings */
|
|
6
4
|
locale: T;
|
|
7
5
|
localeCode: string;
|
|
8
|
-
/** For formatting dates in the locale's language, e.g. `format(date, 'EEEE', { locale: dateFnsLocale })` */
|
|
9
6
|
dateFnsLocale: Locale$1;
|
|
10
7
|
currency: string;
|
|
11
8
|
}
|
|
@@ -18,7 +18,7 @@ export default class LottieFoundation<P extends LottieBaseProps = LottieBaseProp
|
|
|
18
18
|
#private;
|
|
19
19
|
static getLottie: () => Promise<import("lottie-web").LottiePlayer>;
|
|
20
20
|
init(): void;
|
|
21
|
-
handleParamsUpdate()
|
|
21
|
+
handleParamsUpdate: () => void;
|
|
22
22
|
destroy(): void;
|
|
23
23
|
}
|
|
24
24
|
export {};
|
|
@@ -9,7 +9,7 @@ var LottieFoundation = class LottieFoundation extends BaseFoundation {
|
|
|
9
9
|
#getLoadParams() {
|
|
10
10
|
const params = this.getProp("params");
|
|
11
11
|
return {
|
|
12
|
-
container: params.container ?? this.
|
|
12
|
+
container: params.container ?? this.adapter.getContainer(),
|
|
13
13
|
renderer: "svg",
|
|
14
14
|
loop: true,
|
|
15
15
|
autoplay: !this.#reducedMotion?.matches,
|
|
@@ -33,7 +33,7 @@ var LottieFoundation = class LottieFoundation extends BaseFoundation {
|
|
|
33
33
|
this.getProp("getLottie")?.(lottie);
|
|
34
34
|
}
|
|
35
35
|
} catch (error) {
|
|
36
|
-
this.
|
|
36
|
+
this.adapter.notifyLoadError(error);
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
static getLottie = () => LottieFoundation.#pending ??= import("lottie-web").then((module) => module.default).catch((error) => {
|
|
@@ -47,11 +47,11 @@ var LottieFoundation = class LottieFoundation extends BaseFoundation {
|
|
|
47
47
|
this.#reducedMotion.addEventListener("change", this.#handleMotionChange, { signal: this.signal });
|
|
48
48
|
this.#load();
|
|
49
49
|
}
|
|
50
|
-
handleParamsUpdate() {
|
|
50
|
+
handleParamsUpdate = () => {
|
|
51
51
|
this.#animation?.destroy();
|
|
52
52
|
this.#animation = null;
|
|
53
53
|
this.#load();
|
|
54
|
-
}
|
|
54
|
+
};
|
|
55
55
|
destroy() {
|
|
56
56
|
super.destroy();
|
|
57
57
|
this.#generation++;
|
|
@@ -10,7 +10,6 @@ export interface MarkdownRenderAdapter<P extends MarkdownRenderBaseProps = Markd
|
|
|
10
10
|
* which breaks type checking of published declarations. The values are framework components this package cannot name.
|
|
11
11
|
*/
|
|
12
12
|
export type MarkdownComponents = Record<string, any>;
|
|
13
|
-
/** Renders the compiled source with the given element renderers */
|
|
14
13
|
export type MarkdownContent = (props: {
|
|
15
14
|
components?: MarkdownComponents;
|
|
16
15
|
}) => any;
|
|
@@ -28,7 +27,6 @@ export interface MarkdownRenderBaseState {
|
|
|
28
27
|
}
|
|
29
28
|
export default class MarkdownRenderFoundation<P extends MarkdownRenderBaseProps = MarkdownRenderBaseProps, S extends MarkdownRenderBaseState = MarkdownRenderBaseState> extends BaseFoundation<MarkdownRenderAdapter<P, S>, P, S> {
|
|
30
29
|
#private;
|
|
31
|
-
/** Returns a function that renders the source with its `components` prop */
|
|
32
30
|
protected evaluate(raw: string): Promise<MarkdownContent>;
|
|
33
31
|
/**
|
|
34
32
|
* Compiles `md` synchronously for the first render, so server output and hydration start with the content.
|
|
@@ -42,9 +40,6 @@ export default class MarkdownRenderFoundation<P extends MarkdownRenderBaseProps
|
|
|
42
40
|
/** Plugin lists match when each entry, or each item of a `[plugin, options]` entry, is the same reference */
|
|
43
41
|
static isSamePluginList(a?: PluggableList, b?: PluggableList): boolean;
|
|
44
42
|
destroy(): void;
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
* content and goes to `notifyCompileError`.
|
|
48
|
-
*/
|
|
49
|
-
updateContent(): Promise<void>;
|
|
43
|
+
/** A failed compile keeps the last content and goes to `notifyCompileError` */
|
|
44
|
+
updateContent: () => Promise<void>;
|
|
50
45
|
}
|
|
@@ -25,7 +25,6 @@ var MarkdownRenderFoundation = class MarkdownRenderFoundation extends BaseFounda
|
|
|
25
25
|
ignoreInvalidStyle: true
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
|
-
/** Returns a function that renders the source with its `components` prop */
|
|
29
28
|
async evaluate(raw) {
|
|
30
29
|
const props = {
|
|
31
30
|
format: this.getProp("format"),
|
|
@@ -33,7 +32,7 @@ var MarkdownRenderFoundation = class MarkdownRenderFoundation extends BaseFounda
|
|
|
33
32
|
rehypePlugins: this.getProp("rehypePlugins"),
|
|
34
33
|
remarkGfm: this.getProp("remarkGfm")
|
|
35
34
|
};
|
|
36
|
-
const runtime = this.
|
|
35
|
+
const runtime = this.adapter.getRuntime();
|
|
37
36
|
if (props.format === "md") {
|
|
38
37
|
const processor = MarkdownRenderFoundation.#createMdProcessor(props);
|
|
39
38
|
const tree = await processor.run(processor.parse(raw), raw);
|
|
@@ -84,18 +83,15 @@ var MarkdownRenderFoundation = class MarkdownRenderFoundation extends BaseFounda
|
|
|
84
83
|
destroy() {
|
|
85
84
|
this.#requestId++;
|
|
86
85
|
}
|
|
87
|
-
/**
|
|
88
|
-
|
|
89
|
-
* content and goes to `notifyCompileError`.
|
|
90
|
-
*/
|
|
91
|
-
async updateContent() {
|
|
86
|
+
/** A failed compile keeps the last content and goes to `notifyCompileError` */
|
|
87
|
+
updateContent = async () => {
|
|
92
88
|
const requestId = ++this.#requestId;
|
|
93
89
|
try {
|
|
94
90
|
const renderContent = await this.evaluate(this.getProp("raw"));
|
|
95
91
|
if (requestId === this.#requestId) this.setState({ renderContent });
|
|
96
92
|
} catch (error) {
|
|
97
|
-
if (requestId === this.#requestId) this.
|
|
93
|
+
if (requestId === this.#requestId) this.adapter.notifyCompileError(error);
|
|
98
94
|
}
|
|
99
|
-
}
|
|
95
|
+
};
|
|
100
96
|
};
|
|
101
97
|
export { MarkdownRenderFoundation as default };
|
|
@@ -26,15 +26,15 @@ export interface ModalContentAdapter<P extends ModalContentProps = ModalContentP
|
|
|
26
26
|
export default class ModalContentFoundation<P extends ModalContentProps = ModalContentProps, E extends Pick<Event, 'target' | 'currentTarget'> = Pick<Event, 'target' | 'currentTarget'>> extends BaseFoundation<ModalContentAdapter<P, E>, P> {
|
|
27
27
|
#private;
|
|
28
28
|
/** Called when the dialog is shown: joins the overlay stack and moves focus into the dialog */
|
|
29
|
-
show()
|
|
29
|
+
show: () => void;
|
|
30
30
|
/**
|
|
31
31
|
* The reverse of `show`. The layer goes first: it releases the page's inert, and an inert element cannot take
|
|
32
32
|
* the focus back.
|
|
33
33
|
*/
|
|
34
|
-
hide()
|
|
35
|
-
handleDialogMouseDown()
|
|
36
|
-
handleMaskMouseUp()
|
|
37
|
-
handleMaskClick(e: E)
|
|
38
|
-
close(e: E | KeyboardEvent)
|
|
39
|
-
restoreFocus()
|
|
34
|
+
hide: () => void;
|
|
35
|
+
handleDialogMouseDown: () => void;
|
|
36
|
+
handleMaskMouseUp: () => void;
|
|
37
|
+
handleMaskClick: (e: E) => void;
|
|
38
|
+
close: (e: E | KeyboardEvent) => void;
|
|
39
|
+
restoreFocus: () => void;
|
|
40
40
|
}
|
|
@@ -12,37 +12,37 @@ var ModalContentFoundation = class extends BaseFoundation {
|
|
|
12
12
|
return true;
|
|
13
13
|
};
|
|
14
14
|
/** Called when the dialog is shown: joins the overlay stack and moves focus into the dialog */
|
|
15
|
-
show() {
|
|
16
|
-
this.
|
|
17
|
-
this.
|
|
18
|
-
}
|
|
15
|
+
show = () => {
|
|
16
|
+
this.adapter.openLayer(this.#handleEscape);
|
|
17
|
+
this.adapter.trapFocus();
|
|
18
|
+
};
|
|
19
19
|
/**
|
|
20
20
|
* The reverse of `show`. The layer goes first: it releases the page's inert, and an inert element cannot take
|
|
21
21
|
* the focus back.
|
|
22
22
|
*/
|
|
23
|
-
hide() {
|
|
24
|
-
this.
|
|
25
|
-
this.
|
|
23
|
+
hide = () => {
|
|
24
|
+
this.adapter.closeLayer();
|
|
25
|
+
this.adapter.releaseFocus();
|
|
26
26
|
clearTimeout(this.#mouseUpTimer);
|
|
27
27
|
this.#dialogMouseDown = false;
|
|
28
28
|
this.restoreFocus();
|
|
29
|
-
}
|
|
30
|
-
handleDialogMouseDown() {
|
|
29
|
+
};
|
|
30
|
+
handleDialogMouseDown = () => {
|
|
31
31
|
this.#dialogMouseDown = true;
|
|
32
|
-
}
|
|
33
|
-
handleMaskMouseUp() {
|
|
32
|
+
};
|
|
33
|
+
handleMaskMouseUp = () => {
|
|
34
34
|
if (this.#dialogMouseDown) this.#mouseUpTimer = setTimeout(() => {
|
|
35
35
|
this.#dialogMouseDown = false;
|
|
36
36
|
}, 0);
|
|
37
|
-
}
|
|
38
|
-
handleMaskClick(e) {
|
|
37
|
+
};
|
|
38
|
+
handleMaskClick = (e) => {
|
|
39
39
|
if (e.target === e.currentTarget && !this.#dialogMouseDown) this.close(e);
|
|
40
|
-
}
|
|
41
|
-
close(e) {
|
|
42
|
-
this.
|
|
43
|
-
}
|
|
44
|
-
restoreFocus() {
|
|
45
|
-
this.
|
|
46
|
-
}
|
|
40
|
+
};
|
|
41
|
+
close = (e) => {
|
|
42
|
+
this.adapter.notifyClose(e);
|
|
43
|
+
};
|
|
44
|
+
restoreFocus = () => {
|
|
45
|
+
this.adapter.restoreFocus();
|
|
46
|
+
};
|
|
47
47
|
};
|
|
48
48
|
export { ModalContentFoundation as default, isModal };
|
|
@@ -76,10 +76,10 @@ export default class ModalFoundation<P extends ModalProps = ModalProps, S extend
|
|
|
76
76
|
};
|
|
77
77
|
}): 'ok' | 'cancel' | undefined;
|
|
78
78
|
destroy(): void;
|
|
79
|
-
handleCancel(e: CE)
|
|
80
|
-
handleOk(e: OE)
|
|
81
|
-
beforeShow()
|
|
82
|
-
afterHide()
|
|
83
|
-
afterClose()
|
|
84
|
-
toggleDisplayNone(displayNone: boolean)
|
|
79
|
+
handleCancel: (e: CE) => void;
|
|
80
|
+
handleOk: (e: OE) => void;
|
|
81
|
+
beforeShow: () => void;
|
|
82
|
+
afterHide: () => void;
|
|
83
|
+
afterClose: () => void;
|
|
84
|
+
toggleDisplayNone: (displayNone: boolean) => void;
|
|
85
85
|
}
|
|
@@ -12,25 +12,25 @@ var ModalFoundation = class extends BaseFoundation {
|
|
|
12
12
|
this.#invokeCancel(e);
|
|
13
13
|
}, 100, { edges: ["leading"] });
|
|
14
14
|
#invokeCancel(e) {
|
|
15
|
-
const result = this.
|
|
15
|
+
const result = this.adapter.notifyCancel(e);
|
|
16
16
|
if (isPromise(result)) {
|
|
17
|
-
this.
|
|
17
|
+
this.adapter.setState({ onCancelReturnPromiseStatus: "pending" });
|
|
18
18
|
result?.then(() => {
|
|
19
|
-
this.
|
|
19
|
+
this.adapter.setState({ onCancelReturnPromiseStatus: "fulfilled" });
|
|
20
20
|
})?.catch((e) => {
|
|
21
|
-
this.
|
|
21
|
+
this.adapter.setState({ onCancelReturnPromiseStatus: "rejected" });
|
|
22
22
|
throw e;
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
#invokeOk(e) {
|
|
27
|
-
const result = this.
|
|
27
|
+
const result = this.adapter.notifyOk(e);
|
|
28
28
|
if (isPromise(result)) {
|
|
29
|
-
this.
|
|
29
|
+
this.adapter.setState({ onOKReturnPromiseStatus: "pending" });
|
|
30
30
|
result?.then(() => {
|
|
31
|
-
this.
|
|
31
|
+
this.adapter.setState({ onOKReturnPromiseStatus: "fulfilled" });
|
|
32
32
|
})?.catch((e) => {
|
|
33
|
-
this.
|
|
33
|
+
this.adapter.setState({ onOKReturnPromiseStatus: "rejected" });
|
|
34
34
|
throw e;
|
|
35
35
|
});
|
|
36
36
|
}
|
|
@@ -45,30 +45,30 @@ var ModalFoundation = class extends BaseFoundation {
|
|
|
45
45
|
this.#debouncedOk.cancel();
|
|
46
46
|
this.#debouncedCancel.cancel();
|
|
47
47
|
}
|
|
48
|
-
handleCancel(e) {
|
|
48
|
+
handleCancel = (e) => {
|
|
49
49
|
if (!this.getProp("visible")) return;
|
|
50
50
|
const target = e?.currentTarget ?? e?.target ?? null;
|
|
51
51
|
if (target !== this.#lastCancelTarget) this.#debouncedCancel.cancel();
|
|
52
52
|
this.#lastCancelTarget = target;
|
|
53
53
|
this.#debouncedCancel(e);
|
|
54
|
-
}
|
|
55
|
-
handleOk(e) {
|
|
54
|
+
};
|
|
55
|
+
handleOk = (e) => {
|
|
56
56
|
const target = e?.currentTarget ?? e?.target ?? null;
|
|
57
57
|
if (target !== this.#lastOkTarget) this.#debouncedOk.cancel();
|
|
58
58
|
this.#lastOkTarget = target;
|
|
59
59
|
this.#debouncedOk(e);
|
|
60
|
-
}
|
|
61
|
-
beforeShow() {
|
|
62
|
-
this.
|
|
63
|
-
}
|
|
64
|
-
afterHide() {
|
|
65
|
-
this.
|
|
66
|
-
}
|
|
67
|
-
afterClose() {
|
|
68
|
-
this.
|
|
69
|
-
}
|
|
70
|
-
toggleDisplayNone(displayNone) {
|
|
71
|
-
this.
|
|
72
|
-
}
|
|
60
|
+
};
|
|
61
|
+
beforeShow = () => {
|
|
62
|
+
this.adapter.disabledBodyScroll();
|
|
63
|
+
};
|
|
64
|
+
afterHide = () => {
|
|
65
|
+
this.adapter.enabledBodyScroll();
|
|
66
|
+
};
|
|
67
|
+
afterClose = () => {
|
|
68
|
+
this.adapter.notifyClose();
|
|
69
|
+
};
|
|
70
|
+
toggleDisplayNone = (displayNone) => {
|
|
71
|
+
this.adapter.toggleDisplayNone(displayNone);
|
|
72
|
+
};
|
|
73
73
|
};
|
|
74
74
|
export { ModalFoundation as default };
|
|
@@ -25,7 +25,6 @@ export interface NavigationAdapter<P extends NavigationBaseProps = NavigationBas
|
|
|
25
25
|
updateSelectedKeys(keys: ItemKey[]): void;
|
|
26
26
|
updateOpenKeys(keys: ItemKey[]): void;
|
|
27
27
|
}
|
|
28
|
-
/** The props the foundation reads */
|
|
29
28
|
export interface NavigationBaseProps {
|
|
30
29
|
items?: (string | NavItemInput)[];
|
|
31
30
|
children?: unknown;
|
|
@@ -42,9 +41,6 @@ export default class NavigationFoundation<P extends NavigationBaseProps = Naviga
|
|
|
42
41
|
static getZeroParentKeys(itemKeysMap?: ItemKey2ParentKeysMap, ...itemKeys: ItemKey[]): any[];
|
|
43
42
|
static buildItemKeysMap(items?: NavItemType[], keysMap?: {}, parentKeys?: (string | number)[], keyPropName?: string): {};
|
|
44
43
|
static formatItems(items?: (string | NavItemInput)[]): NavItemType[];
|
|
45
|
-
/**
|
|
46
|
-
* Formatted items and the itemKey -> parent keys map
|
|
47
|
-
*/
|
|
48
44
|
static getFormattedItems({ items }: NavigationBaseProps, children?: NavItemType[]): {
|
|
49
45
|
itemKeysMap: ItemKey2ParentKeysMap;
|
|
50
46
|
formattedItems: NavItemType[];
|
|
@@ -64,10 +60,7 @@ export default class NavigationFoundation<P extends NavigationBaseProps = Naviga
|
|
|
64
60
|
* New items or children rebuild the menu from the props, otherwise a changed (deep compared) selectedKeys or
|
|
65
61
|
* openKeys is copied into state
|
|
66
62
|
*/
|
|
67
|
-
handlePropsUpdate(prevProps: NavigationBaseProps)
|
|
68
|
-
/**
|
|
69
|
-
* Selects keys together with their top level parents
|
|
70
|
-
*/
|
|
63
|
+
handlePropsUpdate: (prevProps: NavigationBaseProps) => void;
|
|
71
64
|
updateSelectedKeys: (keys: ItemKey[]) => void;
|
|
72
65
|
addOpenKey: (itemKey: ItemKey) => void;
|
|
73
66
|
removeOpenKey: (itemKey: ItemKey) => void;
|
|
@@ -4,7 +4,7 @@ import { isEqual } from "es-toolkit";
|
|
|
4
4
|
// src/navigation/foundation.ts
|
|
5
5
|
var NavigationFoundation = class NavigationFoundation extends BaseFoundation {
|
|
6
6
|
#getItemKeysMap() {
|
|
7
|
-
return NavigationFoundation.getFormattedItems(this.getProps(), this.
|
|
7
|
+
return NavigationFoundation.getFormattedItems(this.getProps(), this.adapter.getItemsFromChildren()).itemKeysMap;
|
|
8
8
|
}
|
|
9
9
|
#rebuild() {
|
|
10
10
|
const props = this.getProps();
|
|
@@ -12,8 +12,8 @@ var NavigationFoundation = class NavigationFoundation extends BaseFoundation {
|
|
|
12
12
|
const willOpenKeys = NavigationFoundation.getWillOpenKeys(props, this.getState("openKeys"), itemKeysMap);
|
|
13
13
|
const willSelectedKeys = props.selectedKeys || props.defaultSelectedKeys || [];
|
|
14
14
|
const selectedKeys = willSelectedKeys.concat(NavigationFoundation.getZeroParentKeys(itemKeysMap, ...willSelectedKeys));
|
|
15
|
-
if (!isEqual(selectedKeys, this.getState("selectedKeys"))) this.
|
|
16
|
-
if (!isEqual(willOpenKeys, this.getState("openKeys"))) this.
|
|
15
|
+
if (!isEqual(selectedKeys, this.getState("selectedKeys"))) this.adapter.updateSelectedKeys(selectedKeys);
|
|
16
|
+
if (!isEqual(willOpenKeys, this.getState("openKeys"))) this.adapter.updateOpenKeys(willOpenKeys);
|
|
17
17
|
}
|
|
18
18
|
static getZeroParentKeys(itemKeysMap = {}, ...itemKeys) {
|
|
19
19
|
const willAddKeys = [];
|
|
@@ -50,9 +50,6 @@ var NavigationFoundation = class NavigationFoundation extends BaseFoundation {
|
|
|
50
50
|
} : rest;
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Formatted items and the itemKey -> parent keys map
|
|
55
|
-
*/
|
|
56
53
|
static getFormattedItems({ items }, children = []) {
|
|
57
54
|
const formattedItems = NavigationFoundation.formatItems(items);
|
|
58
55
|
const willHandleItems = Array.isArray(items) && items.length ? formattedItems : children;
|
|
@@ -119,7 +116,7 @@ var NavigationFoundation = class NavigationFoundation extends BaseFoundation {
|
|
|
119
116
|
* New items or children rebuild the menu from the props, otherwise a changed (deep compared) selectedKeys or
|
|
120
117
|
* openKeys is copied into state
|
|
121
118
|
*/
|
|
122
|
-
handlePropsUpdate(prevProps) {
|
|
119
|
+
handlePropsUpdate = (prevProps) => {
|
|
123
120
|
const props = this.getProps();
|
|
124
121
|
if (prevProps.items !== props.items || prevProps.children !== props.children) {
|
|
125
122
|
this.#rebuild();
|
|
@@ -127,32 +124,29 @@ var NavigationFoundation = class NavigationFoundation extends BaseFoundation {
|
|
|
127
124
|
}
|
|
128
125
|
if (props.selectedKeys && !isEqual(prevProps.selectedKeys, props.selectedKeys)) {
|
|
129
126
|
this.updateSelectedKeys(props.selectedKeys);
|
|
130
|
-
this.
|
|
131
|
-
} else if (prevProps.selectedKeys !== void 0 && props.selectedKeys === void 0) this.
|
|
132
|
-
if (props.openKeys && !isEqual(prevProps.openKeys, props.openKeys)) this.
|
|
133
|
-
else if (prevProps.openKeys !== void 0 && props.openKeys === void 0) this.
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Selects keys together with their top level parents
|
|
137
|
-
*/
|
|
127
|
+
this.adapter.updateOpenKeys(NavigationFoundation.getWillOpenKeys(props, this.getState("openKeys"), this.#getItemKeysMap()));
|
|
128
|
+
} else if (prevProps.selectedKeys !== void 0 && props.selectedKeys === void 0) this.adapter.updateSelectedKeys([]);
|
|
129
|
+
if (props.openKeys && !isEqual(prevProps.openKeys, props.openKeys)) this.adapter.updateOpenKeys(props.openKeys);
|
|
130
|
+
else if (prevProps.openKeys !== void 0 && props.openKeys === void 0) this.adapter.updateOpenKeys(NavigationFoundation.getWillOpenKeys(props, [], this.#getItemKeysMap()));
|
|
131
|
+
};
|
|
138
132
|
updateSelectedKeys = (keys) => {
|
|
139
133
|
const parentKeys = NavigationFoundation.getZeroParentKeys(this.#getItemKeysMap(), ...keys);
|
|
140
|
-
this.
|
|
134
|
+
this.adapter.updateSelectedKeys(Array.from(new Set(keys.concat(parentKeys))));
|
|
141
135
|
};
|
|
142
136
|
addOpenKey = (itemKey) => {
|
|
143
137
|
const openKeys = new Set(this.getState("openKeys"));
|
|
144
138
|
if (itemKey != null) openKeys.add(itemKey);
|
|
145
|
-
this.
|
|
139
|
+
this.adapter.updateOpenKeys(Array.from(openKeys));
|
|
146
140
|
};
|
|
147
141
|
removeOpenKey = (itemKey) => {
|
|
148
142
|
const openKeys = new Set(this.getState("openKeys"));
|
|
149
143
|
if (itemKey != null) openKeys.delete(itemKey);
|
|
150
|
-
this.
|
|
144
|
+
this.adapter.updateOpenKeys(Array.from(openKeys));
|
|
151
145
|
};
|
|
152
146
|
handleCollapseChange = () => {
|
|
153
147
|
const isCollapsed = !NavigationFoundation.getIsCollapsed(this.getProps(), this.getStates());
|
|
154
|
-
if (!this.
|
|
155
|
-
this.
|
|
148
|
+
if (!this.isControlledComponent("isCollapsed")) this.adapter.setIsCollapsed(isCollapsed);
|
|
149
|
+
this.adapter.notifyCollapseChange(isCollapsed);
|
|
156
150
|
};
|
|
157
151
|
};
|
|
158
152
|
export { NavigationFoundation as default };
|
|
@@ -40,5 +40,5 @@ export declare function countPlaceholderIcons({ mode, limitIndent, isCollapsed,
|
|
|
40
40
|
}): number;
|
|
41
41
|
export default class ItemFoundation<P extends ItemProps = ItemProps, S extends object = object> extends BaseFoundation<ItemAdapter<P, S>, P, S> {
|
|
42
42
|
protected isValidKey(itemKey: string): boolean;
|
|
43
|
-
handleClick(e: MouseEvent | KeyboardEvent)
|
|
43
|
+
handleClick: (e: MouseEvent | KeyboardEvent) => void;
|
|
44
44
|
}
|
|
@@ -10,33 +10,33 @@ var ItemFoundation = class extends BaseFoundation {
|
|
|
10
10
|
isValidKey(itemKey) {
|
|
11
11
|
return itemKey != null && (typeof itemKey === "string" || typeof itemKey === "number");
|
|
12
12
|
}
|
|
13
|
-
handleClick(e) {
|
|
13
|
+
handleClick = (e) => {
|
|
14
14
|
const { isSubNav, itemKey, text, disabled } = this.getProps();
|
|
15
15
|
if (disabled) return;
|
|
16
|
-
const wasSelected = this.
|
|
17
|
-
if (!isSubNav && this.isValidKey(itemKey) && !this.
|
|
16
|
+
const wasSelected = this.adapter.getSelected();
|
|
17
|
+
if (!isSubNav && this.isValidKey(itemKey) && !this.adapter.getSelectedKeysIsControlled() && !wasSelected) this.adapter.selectSelf();
|
|
18
18
|
const selectedKeys = [itemKey];
|
|
19
19
|
if (!isSubNav) {
|
|
20
20
|
if (!wasSelected) {
|
|
21
|
-
const selectedItems = [this.
|
|
22
|
-
this.
|
|
21
|
+
const selectedItems = [this.adapter.cloneDeep(this.getProps())];
|
|
22
|
+
this.adapter.notifyGlobalOnSelect({
|
|
23
23
|
itemKey,
|
|
24
24
|
selectedKeys,
|
|
25
25
|
selectedItems,
|
|
26
26
|
domEvent: e
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
this.
|
|
29
|
+
this.adapter.notifyGlobalOnClick({
|
|
30
30
|
itemKey,
|
|
31
31
|
text,
|
|
32
32
|
domEvent: e
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
-
this.
|
|
35
|
+
this.adapter.notifyClick({
|
|
36
36
|
itemKey,
|
|
37
37
|
text,
|
|
38
38
|
domEvent: e
|
|
39
39
|
});
|
|
40
|
-
}
|
|
40
|
+
};
|
|
41
41
|
};
|
|
42
42
|
export { countPlaceholderIcons, ItemFoundation as default };
|
|
@@ -15,17 +15,16 @@ export interface SubNavAdapter<P extends SubNavBaseProps = SubNavBaseProps, S ex
|
|
|
15
15
|
notifyGlobalOnClick(data: OnClickData): void;
|
|
16
16
|
getIsOpen(): boolean;
|
|
17
17
|
}
|
|
18
|
-
/** The props the foundation reads */
|
|
19
18
|
export interface SubNavBaseProps {
|
|
20
19
|
itemKey?: string | number;
|
|
21
20
|
disabled?: boolean;
|
|
22
21
|
}
|
|
23
22
|
export default class SubNavFoundation<P extends SubNavBaseProps = SubNavBaseProps, S extends object = object> extends BaseFoundation<SubNavAdapter<P, S>, P, S> {
|
|
24
|
-
handleDropdownVisibleChange(visible: boolean)
|
|
25
|
-
handleClick(e: MouseEvent | KeyboardEvent)
|
|
23
|
+
handleDropdownVisibleChange: (visible: boolean) => void;
|
|
24
|
+
handleClick: (e: MouseEvent | KeyboardEvent) => void;
|
|
26
25
|
/**
|
|
27
26
|
* Only reports the click: the Dropdown owns the open state and reports it through handleDropdownVisibleChange,
|
|
28
27
|
* so toggling here would emit a second, possibly contradictory openChange.
|
|
29
28
|
*/
|
|
30
|
-
handlePopupClick(e: MouseEvent | KeyboardEvent)
|
|
29
|
+
handlePopupClick: (e: MouseEvent | KeyboardEvent) => void;
|
|
31
30
|
}
|
|
@@ -11,44 +11,44 @@ function removeKeys(originKeys = [], ...willRemoveKeys) {
|
|
|
11
11
|
return Array.from(keySet);
|
|
12
12
|
}
|
|
13
13
|
var SubNavFoundation = class extends BaseFoundation {
|
|
14
|
-
handleDropdownVisibleChange(visible) {
|
|
14
|
+
handleDropdownVisibleChange = (visible) => {
|
|
15
15
|
const itemKey = this.getProp("itemKey");
|
|
16
|
-
const rawOpenKeys = this.
|
|
16
|
+
const rawOpenKeys = this.adapter.getOpenKeys();
|
|
17
17
|
const openKeys = visible ? addKeys(rawOpenKeys, itemKey) : removeKeys(rawOpenKeys, itemKey);
|
|
18
|
-
this.
|
|
19
|
-
this.
|
|
18
|
+
this.adapter.updateOpen(visible);
|
|
19
|
+
this.adapter.notifyGlobalOpenChange({
|
|
20
20
|
itemKey,
|
|
21
21
|
openKeys,
|
|
22
22
|
isOpen: visible
|
|
23
23
|
});
|
|
24
|
-
}
|
|
25
|
-
handleClick(e) {
|
|
24
|
+
};
|
|
25
|
+
handleClick = (e) => {
|
|
26
26
|
const { itemKey, disabled } = this.getProps();
|
|
27
27
|
if (disabled) return;
|
|
28
|
-
const isOpen = !this.
|
|
28
|
+
const isOpen = !this.adapter.getIsOpen();
|
|
29
29
|
const cbVal = {
|
|
30
30
|
itemKey,
|
|
31
|
-
openKeys: isOpen ? addKeys(this.
|
|
31
|
+
openKeys: isOpen ? addKeys(this.adapter.getOpenKeys(), itemKey) : removeKeys(this.adapter.getOpenKeys(), itemKey),
|
|
32
32
|
isOpen,
|
|
33
33
|
domEvent: e
|
|
34
34
|
};
|
|
35
|
-
if (!this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
}
|
|
35
|
+
if (!this.adapter.getOpenKeysIsControlled()) this.adapter.updateOpen(isOpen);
|
|
36
|
+
this.adapter.notifyGlobalOpenChange(cbVal);
|
|
37
|
+
this.adapter.notifyGlobalOnClick(cbVal);
|
|
38
|
+
};
|
|
39
39
|
/**
|
|
40
40
|
* Only reports the click: the Dropdown owns the open state and reports it through handleDropdownVisibleChange,
|
|
41
41
|
* so toggling here would emit a second, possibly contradictory openChange.
|
|
42
42
|
*/
|
|
43
|
-
handlePopupClick(e) {
|
|
43
|
+
handlePopupClick = (e) => {
|
|
44
44
|
const { itemKey, disabled } = this.getProps();
|
|
45
45
|
if (disabled) return;
|
|
46
|
-
this.
|
|
46
|
+
this.adapter.notifyGlobalOnClick({
|
|
47
47
|
itemKey,
|
|
48
|
-
openKeys: this.
|
|
49
|
-
isOpen: this.
|
|
48
|
+
openKeys: this.adapter.getOpenKeys(),
|
|
49
|
+
isOpen: this.adapter.getIsOpen(),
|
|
50
50
|
domEvent: e
|
|
51
51
|
});
|
|
52
|
-
}
|
|
52
|
+
};
|
|
53
53
|
};
|
|
54
54
|
export { SubNavFoundation as default };
|