@done-coding/forge-feedback 0.104.0 → 0.104.1-alpha.1
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/es/components/modal-porter/ModalPorter.vue.mjs +3 -3
- package/es/components/modal-porter/modal-global-symbol.mjs +1 -1
- package/es/components/modal-shelf/ModalShelf.vue.mjs +14 -7
- package/es/components/modal-shelf/modal-shelf-core.mjs +18 -2
- package/es/components/modal-shelf/use-shelf-controller.mjs +6 -1
- package/package.json +3 -3
- package/types/components/modal-shelf/modal-shelf-core.d.ts +3 -1
- package/types/components/modal-shelf/use-shelf-controller.d.ts +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent, getCurrentInstance, inject, renderSlot } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { MODAL_SHELF_INJECTION_KEYS } from "@done-coding/forge-core/inject";
|
|
3
3
|
import { usePorterGlobalConfig } from "./use-porter-global-config.mjs";
|
|
4
4
|
import { useActivated } from "@done-coding/forge-core/hooks";
|
|
5
5
|
import { APP_GLOBAL_MODAL_PORTER_SYMBOL } from "./modal-global-symbol.mjs";
|
|
@@ -16,8 +16,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
16
16
|
useModalPorterSlotMisuseWarn();
|
|
17
17
|
const uid = ((_a = getCurrentInstance()) == null ? void 0 : _a.uid) ?? Math.floor(Math.random() * 1e9);
|
|
18
18
|
const namedShelves = {
|
|
19
|
-
app: inject(
|
|
20
|
-
page: inject(
|
|
19
|
+
app: inject(MODAL_SHELF_INJECTION_KEYS.app, null),
|
|
20
|
+
page: inject(MODAL_SHELF_INJECTION_KEYS.page, null)
|
|
21
21
|
};
|
|
22
22
|
const isGlobalOnly = props.globalOnly === APP_GLOBAL_MODAL_PORTER_SYMBOL;
|
|
23
23
|
function nsOf(key) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent, useModel, provide, onMounted, inject, openBlock, createElementBlock, Fragment, renderSlot, renderList, unref, createBlock, resolveDynamicComponent, mergeModels, defineAsyncComponent } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { MODAL_SHELF_INJECTION_KEYS } from "@done-coding/forge-core/inject";
|
|
3
3
|
import { useShelfController } from "./use-shelf-controller.mjs";
|
|
4
4
|
import { assertLevelHierarchy } from "./modal-shelf-hierarchy.mjs";
|
|
5
5
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
@@ -8,8 +8,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
8
8
|
level: {}
|
|
9
9
|
}, {
|
|
10
10
|
"remote": {
|
|
11
|
-
// 初始空壳即带 modalKey 清单(挂载前 remote.modalKey
|
|
12
|
-
// 字面量直注 GlobalModalRemote 被 Record 索引签名拒绝,断言只作用于类型。
|
|
11
|
+
// 初始空壳即带 modalKey 清单(挂载前 remote.modalKey 恒存在,消费方零判空);架子创建即补上 open。
|
|
13
12
|
default: () => ({ modalKey: [] })
|
|
14
13
|
},
|
|
15
14
|
"remoteModifiers": {}
|
|
@@ -21,17 +20,25 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
21
20
|
const remote = useModel(__props, "remote");
|
|
22
21
|
const controller = useShelfController(level, remote);
|
|
23
22
|
__expose(controller);
|
|
24
|
-
provide(
|
|
23
|
+
provide(MODAL_SHELF_INJECTION_KEYS[level], controller);
|
|
24
|
+
const asyncByLoader = /* @__PURE__ */ new WeakMap();
|
|
25
25
|
function resolveComp(c) {
|
|
26
|
-
|
|
26
|
+
if (typeof c !== "function") return c;
|
|
27
|
+
const loader = c;
|
|
28
|
+
let comp = asyncByLoader.get(loader);
|
|
29
|
+
if (!comp) {
|
|
30
|
+
comp = defineAsyncComponent(loader);
|
|
31
|
+
asyncByLoader.set(loader, comp);
|
|
32
|
+
}
|
|
33
|
+
return comp;
|
|
27
34
|
}
|
|
28
35
|
onMounted(() => {
|
|
29
36
|
const ancestors = [];
|
|
30
37
|
["app", "page", "custom"].forEach((lv) => {
|
|
31
38
|
if (lv === level) return;
|
|
32
|
-
if (inject(
|
|
39
|
+
if (inject(MODAL_SHELF_INJECTION_KEYS[lv], null)) ancestors.push(lv);
|
|
33
40
|
});
|
|
34
|
-
const sameLevel = inject(
|
|
41
|
+
const sameLevel = inject(MODAL_SHELF_INJECTION_KEYS[level], null);
|
|
35
42
|
if (sameLevel && sameLevel !== controller) ancestors.push(level);
|
|
36
43
|
assertLevelHierarchy(level, ancestors);
|
|
37
44
|
});
|
|
@@ -2,7 +2,8 @@ import { ref, markRaw } from "vue";
|
|
|
2
2
|
const CLOSE_ANIM_MS = 300;
|
|
3
3
|
function createShelfController(level, remoteRef, {
|
|
4
4
|
report,
|
|
5
|
-
isActive = () => true
|
|
5
|
+
isActive = () => true,
|
|
6
|
+
warn
|
|
6
7
|
} = {}) {
|
|
7
8
|
let seq = 0;
|
|
8
9
|
const items = ref([]);
|
|
@@ -107,9 +108,23 @@ function createShelfController(level, remoteRef, {
|
|
|
107
108
|
update: (payload) => handleFor(key).update(payload)
|
|
108
109
|
};
|
|
109
110
|
});
|
|
110
|
-
|
|
111
|
+
const remote = Object.assign(handles, {
|
|
111
112
|
modalKey: [...configs.keys()]
|
|
112
113
|
});
|
|
114
|
+
Object.defineProperty(remote, "open", {
|
|
115
|
+
enumerable: false,
|
|
116
|
+
value: (key, payload) => {
|
|
117
|
+
const handle = handles[key];
|
|
118
|
+
if (handle) {
|
|
119
|
+
handle.evoke(payload);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
warn == null ? void 0 : warn(
|
|
123
|
+
`[forge] 弹窗「${key}」没拉起:没有登记。已登记:${[...configs.keys()].join("、") || "(无)"}。`
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
remoteRef.value = remote;
|
|
113
128
|
}
|
|
114
129
|
function registerConfig(entries) {
|
|
115
130
|
entries.forEach((e) => configs.set(e.key, e));
|
|
@@ -122,6 +137,7 @@ function createShelfController(level, remoteRef, {
|
|
|
122
137
|
});
|
|
123
138
|
syncRemote();
|
|
124
139
|
}
|
|
140
|
+
syncRemote();
|
|
125
141
|
return {
|
|
126
142
|
level,
|
|
127
143
|
items,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { useBridgeReport, useActivated } from "@done-coding/forge-core/hooks";
|
|
2
|
+
import { useIsDev } from "@done-coding/forge-core/internals";
|
|
2
3
|
import { createShelfController } from "./modal-shelf-core.mjs";
|
|
3
4
|
function useShelfController(level, remote) {
|
|
4
5
|
const report = useBridgeReport();
|
|
6
|
+
const isDev = useIsDev();
|
|
5
7
|
let active = true;
|
|
6
8
|
useActivated((info) => {
|
|
7
9
|
active = info.isActivated;
|
|
@@ -13,7 +15,10 @@ function useShelfController(level, remote) {
|
|
|
13
15
|
report: (event, data) => {
|
|
14
16
|
if (active) report(event, data);
|
|
15
17
|
},
|
|
16
|
-
isActive: () => active
|
|
18
|
+
isActive: () => active,
|
|
19
|
+
warn: (message) => {
|
|
20
|
+
if (isDev()) console.warn(message);
|
|
21
|
+
}
|
|
17
22
|
});
|
|
18
23
|
return controller;
|
|
19
24
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@done-coding/forge-feedback",
|
|
3
|
-
"version": "0.104.
|
|
3
|
+
"version": "0.104.1-alpha.1",
|
|
4
4
|
"description": "Forge 反馈组件:全局弹窗的调度与承载",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "es/index.mjs",
|
|
@@ -75,11 +75,11 @@
|
|
|
75
75
|
"vue": "^3.4.0"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@done-coding/forge-core": "0.104.
|
|
78
|
+
"@done-coding/forge-core": "0.104.1-alpha.1"
|
|
79
79
|
},
|
|
80
80
|
"engines": {
|
|
81
81
|
"node": ">=18.0.0",
|
|
82
82
|
"pnpm": ">=9.0.0"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "99399d6d8efdc28802fdbd1189fbf1b1f2b12bca"
|
|
85
85
|
}
|
|
@@ -14,10 +14,12 @@ export interface ShelfControllerInternal extends ShelfController {
|
|
|
14
14
|
* (`unregisterConfig`)时同步移除对应 key + 清掉该 key 活跃实例。page/custom
|
|
15
15
|
* 架子不传 remoteRef——registerConfig 只存配置不挂遥控器。
|
|
16
16
|
*/
|
|
17
|
-
export declare function createShelfController(level: ModalLevel, remoteRef?: Ref<GlobalModalRemote
|
|
17
|
+
export declare function createShelfController(level: ModalLevel, remoteRef?: Ref<Pick<GlobalModalRemote, "modalKey">>, { report, isActive, warn, }?: {
|
|
18
18
|
report?: (event: "modal-open" | "modal-close" | "modal-update", data: () => {
|
|
19
19
|
nsKey: string;
|
|
20
20
|
key: string;
|
|
21
21
|
}) => void;
|
|
22
22
|
isActive?: () => boolean;
|
|
23
|
+
/** 开发期诊断输出(调用方按 dev 闸决定是否传):遥控器 `open` 拉起未登记的名字时提示 */
|
|
24
|
+
warn?: (message: string) => void;
|
|
23
25
|
}): ShelfControllerInternal;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Ref } from 'vue';
|
|
2
2
|
import { GlobalModalRemote, ModalLevel } from '@done-coding/forge-core/components/feedback/shelf-contracts';
|
|
3
3
|
/** setup 接线与激活资源清理;纯工厂不依赖 Vue inject。 */
|
|
4
|
-
export declare function useShelfController(level: ModalLevel, remote: Ref<GlobalModalRemote
|
|
4
|
+
export declare function useShelfController(level: ModalLevel, remote: Ref<Pick<GlobalModalRemote, "modalKey">>): import('./modal-shelf-core').ShelfControllerInternal;
|