niuma-ui 2.1.0 → 2.1.2
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/CHANGELOG.md +19 -0
- package/dist/components/auto-complete/src/RsAutoComplete.d.ts +2 -2
- package/dist/components/code-block/src/RsCodeBlock.css +26 -26
- package/dist/components/code-block/src/RsCodeBlock.impl.js +2 -2
- package/dist/components/code-block/src/RsCodeBlock.js +1 -1
- package/dist/components/context-menu/src/RsContextMenu.css +19 -19
- package/dist/components/date-picker/src/RsDatePicker.d.ts +2 -2
- package/dist/components/date-picker/src/RsDateTimePicker.d.ts +2 -2
- package/dist/components/dialog/src/RsConfirmDialog.css +25 -25
- package/dist/components/dialog/src/RsConfirmDialog.impl.js +4 -4
- package/dist/components/dialog/src/RsConfirmDialog.js +1 -1
- package/dist/components/dialog/src/RsDialog.css +63 -63
- package/dist/components/dialog/src/RsDialog.impl.js +56 -11
- package/dist/components/dialog/src/RsDialog.js +1 -1
- package/dist/components/dialog/src/dialog-window.d.ts +1 -0
- package/dist/components/dialog/src/dialog-window.js +1 -0
- package/dist/components/dynamic-tags/src/RsDynamicTags.d.ts +2 -2
- package/dist/components/icon/src/RsIcon.css +5 -5
- package/dist/components/icon/src/RsIcon.d.ts +1 -1
- package/dist/components/icon/src/RsIcon.impl.js +1 -1
- package/dist/components/icon/src/RsIcon.js +1 -1
- package/dist/components/input/src/RsInput.d.ts +2 -2
- package/dist/components/mentions/src/RsMentions.d.ts +2 -2
- package/dist/components/select/src/RsSelect.d.ts +2 -2
- package/dist/components/tabs/src/RsTabs.d.ts +3 -3
- package/dist/components/tabs/src/RsTabs.impl.js +1 -1
- package/dist/components/textarea/src/RsTextarea.d.ts +2 -2
- package/dist/components/time-picker/src/RsTimePicker.d.ts +2 -2
- package/dist/components/tree/src/RsTree.css +74 -74
- package/dist/components/tree/src/RsTree.js +1 -1
- package/dist/components/tree-select/src/RsTreeSelect.d.ts +2 -2
- package/dist/icons/host.d.ts +11 -0
- package/dist/icons/host.js +30 -0
- package/dist/icons/lucide.js +10 -3
- package/dist/icons/registry.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/styles.css +27 -11
- package/dist/utils/rs-clipboard.d.ts +1 -1
- package/dist/utils/rs-clipboard.js +17 -7
- package/dist/vite-plugins/niuma-ui-host.d.ts +2 -1
- package/dist/vite-plugins/niuma-ui-host.js +25 -6
- package/package.json +1 -1
|
@@ -158,6 +158,19 @@ async function writeClipboardText(text) {
|
|
|
158
158
|
return false;
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
+
/** 打开的 dialog 会把焦点留在框内。临时输入框必须挂在这个 dialog 里,挂到 body 上选不中,复制是空的。 */
|
|
162
|
+
function clipboardMount() {
|
|
163
|
+
const active = document.activeElement;
|
|
164
|
+
if (active instanceof Element) {
|
|
165
|
+
const dialog = active.closest("dialog");
|
|
166
|
+
if (dialog instanceof HTMLElement) return dialog;
|
|
167
|
+
}
|
|
168
|
+
if (typeof document.querySelector === "function") {
|
|
169
|
+
const open = document.querySelector("dialog[open]");
|
|
170
|
+
if (open instanceof HTMLElement) return open;
|
|
171
|
+
}
|
|
172
|
+
return document.body;
|
|
173
|
+
}
|
|
161
174
|
/** execCommand 兜底:CEF / 无 Clipboard API 权限时菜单复制仍可用 */
|
|
162
175
|
function copyTextWithExecCommand(text) {
|
|
163
176
|
if (!text || typeof document === "undefined") return false;
|
|
@@ -166,7 +179,7 @@ function copyTextWithExecCommand(text) {
|
|
|
166
179
|
textarea.value = text;
|
|
167
180
|
textarea.setAttribute("readonly", "");
|
|
168
181
|
textarea.style.cssText = "position:fixed;left:0;top:0;width:1px;height:1px;padding:0;border:0;opacity:0.01";
|
|
169
|
-
|
|
182
|
+
clipboardMount().appendChild(textarea);
|
|
170
183
|
if (typeof textarea.focus === "function") textarea.focus();
|
|
171
184
|
textarea.select();
|
|
172
185
|
if (typeof textarea.setSelectionRange === "function") textarea.setSelectionRange(0, text.length);
|
|
@@ -181,16 +194,13 @@ function copyTextWithExecCommand(text) {
|
|
|
181
194
|
function isInsecureClipboardContext() {
|
|
182
195
|
return typeof globalThis !== "undefined" && globalThis.isSecureContext === false;
|
|
183
196
|
}
|
|
184
|
-
/**
|
|
197
|
+
/** 写入系统剪贴板。先同步 execCommand,避免 await 丢掉点击手势;对话框里也要在这一拍写完。 */
|
|
185
198
|
async function copyTextToClipboard(text) {
|
|
186
199
|
if (!text) return false;
|
|
187
|
-
if (
|
|
188
|
-
|
|
189
|
-
return writeClipboardViaShell(text);
|
|
190
|
-
}
|
|
200
|
+
if (copyTextWithExecCommand(text)) return true;
|
|
201
|
+
if (isInsecureClipboardContext()) return writeClipboardViaShell(text);
|
|
191
202
|
await syncClipboardPermissionState();
|
|
192
203
|
if (!writeApiBlocked && await writeClipboardText(text)) return true;
|
|
193
|
-
if (copyTextWithExecCommand(text)) return true;
|
|
194
204
|
return writeClipboardViaShell(text);
|
|
195
205
|
}
|
|
196
206
|
//#endregion
|
|
@@ -64,7 +64,8 @@ export declare function emitLiveReexportIndex(map: Map<string, NiumaUiBinding>):
|
|
|
64
64
|
*/
|
|
65
65
|
export declare function parseRuntimeBindings(source: string): Map<string, NiumaUiBinding>;
|
|
66
66
|
/**
|
|
67
|
-
* FollowSourceBarrels
|
|
67
|
+
* FollowSourceBarrels 把目录 index,以及 `icons/registry.ts` 这类纯再导出,展开到实现文件。
|
|
68
68
|
* 只跟一层,避免评估整桶 `src/index.ts`。
|
|
69
|
+
* 非 index 只有名字本身是 `export { x } from` 时才改指向,这样 `isRsBrandIconName` 落到 `brand.ts`,不会把同文件再导出的 Lucide 一起求值。
|
|
69
70
|
*/
|
|
70
71
|
export declare function followSourceBarrels(root: string, map: Map<string, NiumaUiBinding>): Map<string, NiumaUiBinding>;
|
|
@@ -123,7 +123,16 @@ function niumaUiHostRewrite(ctx) {
|
|
|
123
123
|
return null;
|
|
124
124
|
if (!code.includes('@niuma/ui') && !code.includes('niuma-ui'))
|
|
125
125
|
return null;
|
|
126
|
-
|
|
126
|
+
const rewrite = () => rewriteHostModule(code, id, ctx.map, (from, spec) => resolveTarget(from, spec, ctx.root, ctx.useSource));
|
|
127
|
+
try {
|
|
128
|
+
return await rewrite();
|
|
129
|
+
}
|
|
130
|
+
catch (err) {
|
|
131
|
+
if (!(err instanceof Error) || !err.message.includes('未找到运行时导出'))
|
|
132
|
+
throw err;
|
|
133
|
+
ctx.map = loadRuntimeBindings(ctx.root, ctx.useSource);
|
|
134
|
+
return rewrite();
|
|
135
|
+
}
|
|
127
136
|
},
|
|
128
137
|
};
|
|
129
138
|
}
|
|
@@ -400,21 +409,31 @@ function loadRuntimeBindings(root, useSource) {
|
|
|
400
409
|
return map;
|
|
401
410
|
}
|
|
402
411
|
/**
|
|
403
|
-
* FollowSourceBarrels
|
|
412
|
+
* FollowSourceBarrels 把目录 index,以及 `icons/registry.ts` 这类纯再导出,展开到实现文件。
|
|
404
413
|
* 只跟一层,避免评估整桶 `src/index.ts`。
|
|
414
|
+
* 非 index 只有名字本身是 `export { x } from` 时才改指向,这样 `isRsBrandIconName` 落到 `brand.ts`,不会把同文件再导出的 Lucide 一起求值。
|
|
405
415
|
*/
|
|
406
416
|
export function followSourceBarrels(root, map) {
|
|
407
417
|
const next = new Map();
|
|
418
|
+
const parsed = new Map();
|
|
419
|
+
const bindingsIn = (file) => {
|
|
420
|
+
const cached = parsed.get(file);
|
|
421
|
+
if (cached)
|
|
422
|
+
return cached;
|
|
423
|
+
const child = parseRuntimeBindings(readFileSync(file, 'utf8'));
|
|
424
|
+
parsed.set(file, child);
|
|
425
|
+
return child;
|
|
426
|
+
};
|
|
408
427
|
for (const [name, binding] of map) {
|
|
409
428
|
const file = resolveSourceModule(root, binding.from);
|
|
410
|
-
if (!file
|
|
429
|
+
if (!file) {
|
|
411
430
|
next.set(name, binding);
|
|
412
431
|
continue;
|
|
413
432
|
}
|
|
414
|
-
const
|
|
415
|
-
const inner =
|
|
433
|
+
const barrel = /[/\\]index\.(ts|js)$/.test(file);
|
|
434
|
+
const inner = bindingsIn(file).get(name);
|
|
416
435
|
if (!inner) {
|
|
417
|
-
next.set(name, { ...binding, from: toSrcRel(root, file) });
|
|
436
|
+
next.set(name, barrel ? { ...binding, from: toSrcRel(root, file) } : binding);
|
|
418
437
|
continue;
|
|
419
438
|
}
|
|
420
439
|
const innerAbs = resolveRelativeModule(file, inner.from);
|