@zephytiju/prism-quick-files 0.1.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.
Files changed (54) hide show
  1. package/README.md +192 -0
  2. package/dist/DropInModelCard.d.ts +9 -0
  3. package/dist/DropInModelCard.d.ts.map +1 -0
  4. package/dist/DropInModelCard.js +7 -0
  5. package/dist/FileList.d.ts +25 -0
  6. package/dist/FileList.d.ts.map +1 -0
  7. package/dist/FileList.js +23 -0
  8. package/dist/FileRow.d.ts +31 -0
  9. package/dist/FileRow.d.ts.map +1 -0
  10. package/dist/FileRow.js +54 -0
  11. package/dist/PanelHeader.d.ts +17 -0
  12. package/dist/PanelHeader.d.ts.map +1 -0
  13. package/dist/PanelHeader.js +11 -0
  14. package/dist/QuickFiles.d.ts +57 -0
  15. package/dist/QuickFiles.d.ts.map +1 -0
  16. package/dist/QuickFiles.js +75 -0
  17. package/dist/SearchBox.d.ts +13 -0
  18. package/dist/SearchBox.d.ts.map +1 -0
  19. package/dist/SearchBox.js +23 -0
  20. package/dist/SectionLabels.d.ts +9 -0
  21. package/dist/SectionLabels.d.ts.map +1 -0
  22. package/dist/SectionLabels.js +7 -0
  23. package/dist/clients.d.ts +22 -0
  24. package/dist/clients.d.ts.map +1 -0
  25. package/dist/clients.js +13 -0
  26. package/dist/dragState.d.ts +20 -0
  27. package/dist/dragState.d.ts.map +1 -0
  28. package/dist/dragState.js +56 -0
  29. package/dist/icons.d.ts +35 -0
  30. package/dist/icons.d.ts.map +1 -0
  31. package/dist/icons.js +58 -0
  32. package/dist/index.d.ts +11 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +5 -0
  35. package/dist/locales/en.json +20 -0
  36. package/dist/locales/index.d.ts +72 -0
  37. package/dist/locales/index.d.ts.map +1 -0
  38. package/dist/locales/index.js +27 -0
  39. package/dist/locales/zh-CN.json +20 -0
  40. package/dist/tokens.d.ts +19 -0
  41. package/dist/tokens.d.ts.map +1 -0
  42. package/dist/tokens.js +18 -0
  43. package/dist/types.d.ts +88 -0
  44. package/dist/types.d.ts.map +1 -0
  45. package/dist/types.js +1 -0
  46. package/dist/useQuickFilesEntries.d.ts +16 -0
  47. package/dist/useQuickFilesEntries.d.ts.map +1 -0
  48. package/dist/useQuickFilesEntries.js +40 -0
  49. package/dist/visibleRows.d.ts +12 -0
  50. package/dist/visibleRows.d.ts.map +1 -0
  51. package/dist/visibleRows.js +57 -0
  52. package/locales/en.json +20 -0
  53. package/locales/zh-CN.json +20 -0
  54. package/package.json +65 -0
@@ -0,0 +1,57 @@
1
+ /** Mono size formatter for the row meta fallback (B / KB / MB). */
2
+ export function formatBytes(sizeBytes) {
3
+ if (!Number.isFinite(sizeBytes) || sizeBytes < 0) {
4
+ return "—";
5
+ }
6
+ if (sizeBytes < 1024) {
7
+ return `${sizeBytes} B`;
8
+ }
9
+ if (sizeBytes < 1024 * 1024) {
10
+ return `${(sizeBytes / 1024).toFixed(1)} KB`;
11
+ }
12
+ return `${(sizeBytes / (1024 * 1024)).toFixed(1)} MB`;
13
+ }
14
+ /**
15
+ * Applies the panel's row visibility and ordering rules to the fetched
16
+ * entries: search-text match (name + meta + kind), the categoryFilters
17
+ * configuration key, and the recencyWindowMs configuration key (entries
18
+ * without a timestamp are kept) — then pinned-first, most-recently-opened,
19
+ * name ordering.
20
+ */
21
+ export function selectVisibleRows(entries, search, categoryFilters, recencyWindowMs) {
22
+ const needle = search.trim().toLowerCase();
23
+ const filters = categoryFilters ?? [];
24
+ const now = Date.now();
25
+ const visible = entries.filter((entry) => {
26
+ if (needle !== "") {
27
+ const meta = entry.meta ?? "";
28
+ const haystack = `${entry.name} ${meta} ${entry.kind}`.toLowerCase();
29
+ if (!haystack.includes(needle)) {
30
+ return false;
31
+ }
32
+ }
33
+ if (filters.length > 0 && !filters.includes(entry.kind)) {
34
+ return false;
35
+ }
36
+ if (recencyWindowMs !== undefined) {
37
+ const opened = Date.parse(entry.lastOpenedAt ?? "");
38
+ if (!Number.isNaN(opened) && now - opened > recencyWindowMs) {
39
+ return false;
40
+ }
41
+ }
42
+ return true;
43
+ });
44
+ return [...visible].sort((a, b) => {
45
+ if ((b.pinned ?? false) !== (a.pinned ?? false)) {
46
+ return (b.pinned ?? false) ? 1 : -1;
47
+ }
48
+ const at = Date.parse(a.lastOpenedAt ?? "");
49
+ const bt = Date.parse(b.lastOpenedAt ?? "");
50
+ const aTime = Number.isNaN(at) ? Number.NEGATIVE_INFINITY : at;
51
+ const bTime = Number.isNaN(bt) ? Number.NEGATIVE_INFINITY : bt;
52
+ if (aTime !== bTime) {
53
+ return bTime - aTime;
54
+ }
55
+ return a.name.localeCompare(b.name);
56
+ });
57
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "quick-files": {
3
+ "panelTitle": "QUICK FILE INSERT",
4
+ "panelSubtitle": "WORLD VIEWS, DOSSIERS, BOARDS, EVIDENCE",
5
+ "trailingMetaCount": "{count} FILES",
6
+ "searchPlaceholder": "Search recent files and world views",
7
+ "searchLabel": "Search files",
8
+ "sectionHint": "FILES ARE THE SHORTCUT",
9
+ "sectionRecent": "RECENT / COMMON FILES",
10
+ "infoCardTitle": "DROP-IN FILE MODEL",
11
+ "infoCardBody": "World views are versioned spatial metadata files. Insert one here to reload its saved selection, time, layers, camera, and scenario inside the dossier. Component types remain in each block's + menu.",
12
+ "insertLabel": "Insert {name}",
13
+ "dragLabel": "Drag {name} to insert",
14
+ "emptyTitle": "No files yet",
15
+ "emptyHint": "Files from VAULT appear here once opened or pinned.",
16
+ "noMatches": "No files match the search.",
17
+ "errorTitle": "File listing failed",
18
+ "retry": "Retry"
19
+ }
20
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "quick-files": {
3
+ "panelTitle": "快速插入文件",
4
+ "panelSubtitle": "世界视图 · 卷宗 · 看板 · 证据",
5
+ "trailingMetaCount": "{count} 个文件",
6
+ "searchPlaceholder": "搜索最近的文件与世界视图",
7
+ "searchLabel": "搜索文件",
8
+ "sectionHint": "文件即捷径",
9
+ "sectionRecent": "最近 / 常用文件",
10
+ "infoCardTitle": "置入文件模型",
11
+ "infoCardBody": "世界视图是带版本的空间元数据文件。在此插入即可在卷宗内恢复其保存的选择、时间、图层、相机与情景。组件类型仍保留在每个区块的 + 菜单中。",
12
+ "insertLabel": "插入 {name}",
13
+ "dragLabel": "拖动 {name} 以插入",
14
+ "emptyTitle": "暂无文件",
15
+ "emptyHint": "来自 VAULT 的文件在打开或固定后会显示在此。",
16
+ "noMatches": "没有符合搜索条件的文件。",
17
+ "errorTitle": "文件列表加载失败",
18
+ "retry": "重试"
19
+ }
20
+ }
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@zephytiju/prism-quick-files",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Platform Prism quick-files micro-UI (component id \"quick-files\"): the Dossier Quick File Insert side panel \u2014 QUICK FILE INSERT title header, search box, FILES ARE THE SHORTCUT / RECENT-COMMON FILES sections, per-prototype file rows (world view / dossier doc / board / folder icons with semantic kind tokens, name + mono meta line, + insert action) and the DROP-IN FILE MODEL info card. Rows are indexed through the IFileEntry list query; insert (+) and drag-start publish ONLY a bounded drag/insert state {entryId, kind, name, mime, snapshotRef, sourcePanel} on the quick-files.drag-state channel \u2014 receivers interpret it themselves (D6 decoupling); ESC / drag-end clears it. Ships en + zh-CN locale bundles.",
6
+ "license": "UNLICENSED",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./locales/*": "./locales/*"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "locales"
22
+ ],
23
+ "scripts": {
24
+ "dev": "vite --host 127.0.0.1",
25
+ "build": "tsc -p tsconfig.build.json && node scripts/copy-locales.mjs",
26
+ "typecheck": "tsc --noEmit",
27
+ "test": "vitest run",
28
+ "shot-demo": "node scripts/shot-demo.mjs"
29
+ },
30
+ "peerDependencies": {
31
+ "@mantine/core": "^8.1.1",
32
+ "@zephytiju/lattice-common-interfaces": ">=0.1.0",
33
+ "@zephytiju/prism-react": ">=0.1.0",
34
+ "react": "^19.1.0",
35
+ "react-dom": "^19.1.0"
36
+ },
37
+ "devDependencies": {
38
+ "@mantine/core": "8.1.1",
39
+ "@testing-library/dom": "^10.4.0",
40
+ "@testing-library/react": "^16.1.0",
41
+ "@types/node": "^22.10.2",
42
+ "@types/react": "^19.1.0",
43
+ "@types/react-dom": "^19.1.0",
44
+ "@zephytiju/lattice-common-interfaces": "0.1.0",
45
+ "@zephytiju/prism-react": "0.1.0",
46
+ "jsdom": "^25.0.1",
47
+ "puppeteer-core": "^24.10.0",
48
+ "react": "19.1.0",
49
+ "react-dom": "19.1.0",
50
+ "typescript": "^5.7.2",
51
+ "vite": "6.0.5",
52
+ "vitest": "^2.1.8"
53
+ },
54
+ "engines": {
55
+ "node": ">=20"
56
+ },
57
+ "repository": {
58
+ "type": "git",
59
+ "url": "git+https://github.com/zephytiju/PrismQuickFilesMicroUI.git"
60
+ },
61
+ "bugs": {
62
+ "url": "https://github.com/zephytiju/PrismQuickFilesMicroUI/issues"
63
+ },
64
+ "homepage": "https://github.com/zephytiju/PrismQuickFilesMicroUI#readme"
65
+ }