@sincpro/web-composer 0.0.0-stage → 1.0.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/LICENSE +21 -0
- package/README.md +269 -2
- package/dist/domain/enums.d.ts +55 -0
- package/dist/domain/enums.js +48 -0
- package/dist/domain/index.d.ts +9 -0
- package/dist/domain/index.js +8 -0
- package/dist/domain/layout.d.ts +92 -0
- package/dist/domain/layout.js +216 -0
- package/dist/domain/palette.d.ts +42 -0
- package/dist/domain/palette.js +89 -0
- package/dist/domain/registry.d.ts +135 -0
- package/dist/domain/registry.js +37 -0
- package/dist/domain/resource.d.ts +21 -0
- package/dist/domain/resource.js +62 -0
- package/dist/domain/url.d.ts +16 -0
- package/dist/domain/url.js +145 -0
- package/dist/domain/workspace.d.ts +174 -0
- package/dist/domain/workspace.js +393 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +23 -0
- package/dist/shell/Composer.d.ts +23 -0
- package/dist/shell/Composer.js +88 -0
- package/dist/shell/Palette.d.ts +9 -0
- package/dist/shell/Palette.js +124 -0
- package/dist/shell/PanelFrame.d.ts +38 -0
- package/dist/shell/PanelFrame.js +70 -0
- package/dist/shell/PanelHost.d.ts +23 -0
- package/dist/shell/PanelHost.js +201 -0
- package/dist/shell/Peek.d.ts +26 -0
- package/dist/shell/Peek.js +64 -0
- package/dist/shell/RecordLink.d.ts +12 -0
- package/dist/shell/RecordLink.js +55 -0
- package/dist/shell/ViewHost.d.ts +11 -0
- package/dist/shell/ViewHost.js +53 -0
- package/dist/shell/copy.d.ts +73 -0
- package/dist/shell/copy.js +130 -0
- package/dist/shell/icons.d.ts +22 -0
- package/dist/shell/icons.js +19 -0
- package/dist/shell/skin.d.ts +72 -0
- package/dist/shell/skin.js +35 -0
- package/dist/shell/styles.d.ts +19 -0
- package/dist/shell/styles.js +212 -0
- package/dist/state/api.d.ts +36 -0
- package/dist/state/api.js +170 -0
- package/dist/state/drag.d.ts +31 -0
- package/dist/state/drag.js +95 -0
- package/dist/state/store.d.ts +69 -0
- package/dist/state/store.js +200 -0
- package/dist/state/useKeyboard.d.ts +16 -0
- package/dist/state/useKeyboard.js +63 -0
- package/dist/state/useWorkspace.d.ts +23 -0
- package/dist/state/useWorkspace.js +34 -0
- package/package.json +83 -4
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { PAGE, PEEK } from "../domain/index.js";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
/** Inside a field only Escape survives. Stealing a key from someone who is typing is worse than
|
|
4
|
+
* having no shortcuts. */
|
|
5
|
+
function isTyping(target) {
|
|
6
|
+
if (!(target instanceof HTMLElement))
|
|
7
|
+
return false;
|
|
8
|
+
return target.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(target.tagName);
|
|
9
|
+
}
|
|
10
|
+
export function useKeyboard({ workspace, enabled = true, onPalette }) {
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!enabled)
|
|
13
|
+
return;
|
|
14
|
+
function onKeyDown(e) {
|
|
15
|
+
const state = workspace.get();
|
|
16
|
+
if (e.key === "Escape") {
|
|
17
|
+
if (e.defaultPrevented)
|
|
18
|
+
return;
|
|
19
|
+
if (state.peek !== null) {
|
|
20
|
+
workspace.closePeek();
|
|
21
|
+
e.preventDefault();
|
|
22
|
+
}
|
|
23
|
+
else if (state.maximized !== null) {
|
|
24
|
+
workspace.maximize(state.maximized);
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
}
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
const mod = e.metaKey || e.ctrlKey;
|
|
30
|
+
if (onPalette !== undefined && mod && e.code === "KeyK") {
|
|
31
|
+
onPalette();
|
|
32
|
+
e.preventDefault();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (isTyping(e.target))
|
|
36
|
+
return;
|
|
37
|
+
if (e.altKey && !mod && e.code === "ArrowLeft") {
|
|
38
|
+
if (state.focus === PEEK && state.peekTrail.length > 0)
|
|
39
|
+
workspace.peekBack();
|
|
40
|
+
else
|
|
41
|
+
workspace.back();
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
}
|
|
44
|
+
else if (mod && e.altKey && (e.code === "BracketLeft" || e.code === "BracketRight")) {
|
|
45
|
+
workspace.cycleFocus(e.code === "BracketRight" ? 1 : -1);
|
|
46
|
+
e.preventDefault();
|
|
47
|
+
}
|
|
48
|
+
else if (mod && e.shiftKey && e.code === "Enter") {
|
|
49
|
+
workspace.maximize(state.maximized ?? state.focus);
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
}
|
|
52
|
+
else if (mod && e.shiftKey && e.code === "Backspace" && state.focus !== PAGE) {
|
|
53
|
+
if (state.focus === PEEK)
|
|
54
|
+
workspace.closePeek();
|
|
55
|
+
else
|
|
56
|
+
workspace.closePanel(state.focus);
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
window.addEventListener("keydown", onKeyDown);
|
|
61
|
+
return () => window.removeEventListener("keydown", onKeyDown);
|
|
62
|
+
}, [enabled, workspace, onPalette]);
|
|
63
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Workspace, WorkspaceApi } from "../domain/index.js";
|
|
2
|
+
import { type StoreOptions, type WorkspaceStore } from "./store.js";
|
|
3
|
+
/**
|
|
4
|
+
* `useSyncExternalStore` is React, not a state library. What it adds over
|
|
5
|
+
* `useState` is the one thing we needed: subscribe to a slice, so moving one
|
|
6
|
+
* panel does not redraw the other five.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useWorkspace(options?: StoreOptions): WorkspaceStore;
|
|
9
|
+
/**
|
|
10
|
+
* Watch a slice of the workspace and redraw only when THAT slice changes.
|
|
11
|
+
* The selector must return something comparable by identity. Reducers are
|
|
12
|
+
* pure and leave untouched data alone, so `tab.panels` stays the same array
|
|
13
|
+
* until someone moves a panel.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useWorkspaceSlice<T>(store: WorkspaceStore, select: (state: Workspace) => T): T;
|
|
16
|
+
export declare function useWorkspaceState(store: WorkspaceStore): Workspace;
|
|
17
|
+
/** For a global panel — the chat, the assistant — that follows what the user
|
|
18
|
+
* is working on. Redraws only when the focused resource or its selection change. */
|
|
19
|
+
export declare function useWorkspaceContext(api: WorkspaceApi): {
|
|
20
|
+
focused: import("../domain/index.js").ResourceRef | null;
|
|
21
|
+
selection: readonly import("../domain/index.js").ResourceRef[];
|
|
22
|
+
};
|
|
23
|
+
export type { StoreOptions as UseWorkspaceOptions, WorkspaceStore };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createWorkspaceStore, } from "./store.js";
|
|
2
|
+
import { useMemo, useRef, useSyncExternalStore } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* `useSyncExternalStore` is React, not a state library. What it adds over
|
|
5
|
+
* `useState` is the one thing we needed: subscribe to a slice, so moving one
|
|
6
|
+
* panel does not redraw the other five.
|
|
7
|
+
*/
|
|
8
|
+
export function useWorkspace(options = {}) {
|
|
9
|
+
const saved = useRef(null);
|
|
10
|
+
saved.current ??= createWorkspaceStore(options);
|
|
11
|
+
return saved.current;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Watch a slice of the workspace and redraw only when THAT slice changes.
|
|
15
|
+
* The selector must return something comparable by identity. Reducers are
|
|
16
|
+
* pure and leave untouched data alone, so `tab.panels` stays the same array
|
|
17
|
+
* until someone moves a panel.
|
|
18
|
+
*/
|
|
19
|
+
export function useWorkspaceSlice(store, select) {
|
|
20
|
+
const read = useMemo(() => () => select(store.get()), [store, select]);
|
|
21
|
+
return useSyncExternalStore(store.subscribe, read, read);
|
|
22
|
+
}
|
|
23
|
+
export function useWorkspaceState(store) {
|
|
24
|
+
return useSyncExternalStore(store.subscribe, store.get, store.get);
|
|
25
|
+
}
|
|
26
|
+
/** For a global panel — the chat, the assistant — that follows what the user
|
|
27
|
+
* is working on. Redraws only when the focused resource or its selection change. */
|
|
28
|
+
export function useWorkspaceContext(api) {
|
|
29
|
+
const { subscribe, focused, selection } = api.context;
|
|
30
|
+
return {
|
|
31
|
+
focused: useSyncExternalStore(subscribe, focused, focused),
|
|
32
|
+
selection: useSyncExternalStore(subscribe, selection, selection),
|
|
33
|
+
};
|
|
34
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,85 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-composer",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "The Sincpro workspace for React: one page with its breadcrumb, a peek, side panels and windows, and ⌘K — all over references, never data.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./domain": {
|
|
14
|
+
"types": "./dist/domain/index.d.ts",
|
|
15
|
+
"default": "./dist/domain/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"prettier": {
|
|
27
|
+
"printWidth": 94
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"react": ">=19",
|
|
31
|
+
"react-dom": ">=19"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@eslint/js": "^10.0.1",
|
|
35
|
+
"@sincpro/web-ui": "^0.2.0",
|
|
36
|
+
"@storybook/addon-a11y": "10.6.5",
|
|
37
|
+
"@storybook/addon-docs": "10.6.5",
|
|
38
|
+
"@storybook/addon-mcp": "10.6.5",
|
|
39
|
+
"@storybook/addon-vitest": "10.6.5",
|
|
40
|
+
"@storybook/react-vite": "10.6.5",
|
|
41
|
+
"@tailwindcss/vite": "4.3.3",
|
|
42
|
+
"@tanstack/react-table": "^9.3.1",
|
|
43
|
+
"@tanstack/react-virtual": "^3.14.24",
|
|
44
|
+
"@types/node": "^26.6.6",
|
|
45
|
+
"@types/react": "^19.3.0",
|
|
46
|
+
"@types/react-dom": "^19.3.0",
|
|
47
|
+
"@vitejs/plugin-react": "6.1.2",
|
|
48
|
+
"@vitest/browser-playwright": "5.0.5",
|
|
49
|
+
"eslint": "^10.14.0",
|
|
50
|
+
"eslint-config-prettier": "^10.1.8",
|
|
51
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
52
|
+
"eslint-plugin-simple-import-sort": "^14.0.0",
|
|
53
|
+
"lucide-react": "^1.65.0",
|
|
54
|
+
"playwright": "1.64.1",
|
|
55
|
+
"prettier": "^3.9.10",
|
|
56
|
+
"react": "19.3.1",
|
|
57
|
+
"react-dom": "19.3.1",
|
|
58
|
+
"storybook": "10.6.5",
|
|
59
|
+
"tailwindcss": "4.3.3",
|
|
60
|
+
"tsc-alias": "^1.9.9",
|
|
61
|
+
"typescript": "~6.0.3",
|
|
62
|
+
"typescript-eslint": "^8.72.1",
|
|
63
|
+
"vite": "8.3.5",
|
|
64
|
+
"vitest": "5.0.5"
|
|
65
|
+
},
|
|
66
|
+
"keywords": [
|
|
67
|
+
"workspace",
|
|
68
|
+
"react",
|
|
69
|
+
"breadcrumb",
|
|
70
|
+
"command-palette",
|
|
71
|
+
"sincpro"
|
|
72
|
+
],
|
|
73
|
+
"repository": {
|
|
74
|
+
"type": "git",
|
|
75
|
+
"url": "git+https://github.com/Sincpro-SRL/sincpro_web_composer.git"
|
|
76
|
+
},
|
|
77
|
+
"author": "Gutierrez, Andres <andres.gutierrez@sincpro.com.bo>",
|
|
78
|
+
"license": "MIT",
|
|
79
|
+
"engines": {
|
|
80
|
+
"node": ">=26"
|
|
81
|
+
},
|
|
82
|
+
"dependencies": {
|
|
83
|
+
"@atlaskit/pragmatic-drag-and-drop": "^4.0.0"
|
|
84
|
+
}
|
|
85
|
+
}
|