legend-state-dev-tools 0.0.2 → 0.0.5

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.
@@ -1,108 +0,0 @@
1
- import { renderToolbar, type ToolbarData } from './template-engine';
2
- import { getStoredBoolean, setStoredBoolean } from './shared-utils';
3
-
4
- export class Toolbar {
5
- private container: HTMLElement | null = null;
6
- private isDragging = false;
7
- private offsetX = 0;
8
- private offsetY = 0;
9
- private isMinimized: boolean = getStoredBoolean('toolbar-minimized', false);
10
- private panelVisible = false;
11
-
12
- private onTogglePanel?: () => void;
13
- private rootName: string;
14
-
15
- constructor(options: { onTogglePanel?: () => void; rootName?: string } = {}) {
16
- this.onTogglePanel = options.onTogglePanel;
17
- this.rootName = options.rootName || 'state$';
18
- }
19
-
20
- public mount(): void {
21
- if (this.container) return;
22
-
23
- this.container = document.createElement('div');
24
- this.container.id = 'lsdt-toolbar';
25
- if (this.isMinimized) {
26
- this.container.classList.add('lsdt-toolbar-minimized');
27
- }
28
-
29
- document.body.appendChild(this.container);
30
- this.render();
31
- this.attachEventListeners();
32
- }
33
-
34
- private render(): void {
35
- if (!this.container) return;
36
-
37
- const data: ToolbarData = {
38
- isMinimized: this.isMinimized,
39
- panelVisible: this.panelVisible,
40
- rootName: this.rootName,
41
- };
42
-
43
- this.container.innerHTML = renderToolbar(data);
44
- }
45
-
46
- private attachEventListeners(): void {
47
- if (!this.container) return;
48
-
49
- this.container.addEventListener('click', this.handleClick);
50
- this.container.addEventListener('mousedown', this.handleMouseDown);
51
- document.addEventListener('mousemove', this.handleMouseMove);
52
- document.addEventListener('mouseup', this.handleMouseUp);
53
- }
54
-
55
- private handleClick = (e: Event): void => {
56
- const target = e.target as HTMLElement;
57
- const actionElement = target.closest('[data-action]');
58
- if (!actionElement) return;
59
-
60
- const action = actionElement.getAttribute('data-action');
61
- if (action === 'toggle-panel') {
62
- this.onTogglePanel?.();
63
- }
64
- };
65
-
66
- private handleMouseDown = (e: MouseEvent): void => {
67
- const target = e.target as HTMLElement;
68
- if (target.tagName === 'BUTTON') return;
69
-
70
- this.isDragging = true;
71
- if (this.container) {
72
- this.container.classList.add('dragging');
73
- const rect = this.container.getBoundingClientRect();
74
- this.offsetX = e.clientX - rect.left;
75
- this.offsetY = e.clientY - rect.top;
76
- }
77
- };
78
-
79
- private handleMouseMove = (e: MouseEvent): void => {
80
- if (!this.isDragging || !this.container) return;
81
-
82
- this.container.style.left = `${e.clientX - this.offsetX}px`;
83
- this.container.style.top = `${e.clientY - this.offsetY}px`;
84
- this.container.style.right = 'auto';
85
- this.container.style.bottom = 'auto';
86
- };
87
-
88
- private handleMouseUp = (): void => {
89
- this.isDragging = false;
90
- this.container?.classList.remove('dragging');
91
- };
92
-
93
- public setPanelVisible(visible: boolean): void {
94
- this.panelVisible = visible;
95
- this.render();
96
- }
97
-
98
- public unmount(): void {
99
- if (this.container) {
100
- this.container.removeEventListener('click', this.handleClick);
101
- this.container.removeEventListener('mousedown', this.handleMouseDown);
102
- this.container.remove();
103
- this.container = null;
104
- }
105
- document.removeEventListener('mousemove', this.handleMouseMove);
106
- document.removeEventListener('mouseup', this.handleMouseUp);
107
- }
108
- }
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "./dist",
5
- "rootDir": "./src"
6
- },
7
- "include": ["src/**/*"],
8
- "exclude": ["dist/**/*"]
9
- }
@@ -1,71 +0,0 @@
1
- import { defineConfig } from 'vite';
2
- import { resolve } from 'path';
3
- import { copyFileSync } from 'fs';
4
- import dts from 'vite-plugin-dts';
5
-
6
- export default defineConfig({
7
- plugins: [
8
- {
9
- name: 'eta-raw-loader',
10
- transform(code, id) {
11
- if (id.endsWith('.eta')) {
12
- return {
13
- code: `export default ${JSON.stringify(code)};`,
14
- map: null,
15
- };
16
- }
17
- },
18
- },
19
- dts({
20
- include: ['src/**/*.ts', 'src/**/*.tsx'],
21
- exclude: ['src/**/*.test.ts'],
22
- rollupTypes: true,
23
- insertTypesEntry: true,
24
- }),
25
- {
26
- name: 'copy-styles',
27
- closeBundle() {
28
- copyFileSync(
29
- resolve(__dirname, 'src/styles.css'),
30
- resolve(__dirname, 'dist/styles.css')
31
- );
32
- },
33
- },
34
- ],
35
- build: {
36
- lib: {
37
- entry: resolve(__dirname, 'src/index.ts'),
38
- name: 'LegendStateDevTools',
39
- formats: ['es', 'cjs'],
40
- fileName: (format) => (format === 'es' ? 'index.mjs' : 'index.js'),
41
- },
42
- rollupOptions: {
43
- external: [
44
- 'react',
45
- 'react-dom',
46
- 'react-dom/client',
47
- 'react/jsx-runtime',
48
- 'eta',
49
- 'json-edit-react',
50
- '@legendapp/state',
51
- ],
52
- output: {
53
- globals: {
54
- react: 'React',
55
- 'react-dom': 'ReactDOM',
56
- 'react-dom/client': 'ReactDOMClient',
57
- eta: 'Eta',
58
- 'json-edit-react': 'JsonEditReact',
59
- '@legendapp/state': 'LegendState',
60
- },
61
- },
62
- },
63
- outDir: 'dist',
64
- emptyOutDir: true,
65
- sourcemap: true,
66
- minify: 'esbuild',
67
- },
68
- resolve: {
69
- extensions: ['.ts', '.tsx', '.js', '.jsx', '.eta'],
70
- },
71
- });
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "ESNext",
5
- "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
- "moduleResolution": "bundler",
7
- "strict": true,
8
- "skipLibCheck": true,
9
- "esModuleInterop": true,
10
- "resolveJsonModule": true,
11
- "isolatedModules": true,
12
- "declaration": true,
13
- "declarationMap": true,
14
- "jsx": "react-jsx"
15
- },
16
- "exclude": ["examples/**/*", "node_modules/**/*", "**/dist/**/*"]
17
- }
File without changes