juxscript 1.1.239 → 1.1.243
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/index.js +7 -137
- package/lib/components/dataframe.ts +0 -569
- package/lib/components/tag.ts +68 -0
- package/lib/styles/shadcn.css +20 -7
- package/lib/utils/idgen.ts +6 -0
- package/package.json +5 -6
- package/index.d.ts +0 -239
- package/index.d.ts.map +0 -1
- package/lib/components/alert.d.ts +0 -36
- package/lib/components/alert.d.ts.map +0 -1
- package/lib/components/alert.js +0 -172
- package/lib/components/alert.ts +0 -219
- package/lib/components/app.d.ts +0 -89
- package/lib/components/app.d.ts.map +0 -1
- package/lib/components/app.js +0 -175
- package/lib/components/app.ts +0 -247
- package/lib/components/badge.d.ts +0 -26
- package/lib/components/badge.d.ts.map +0 -1
- package/lib/components/badge.js +0 -91
- package/lib/components/badge.ts +0 -118
- package/lib/components/base/Animations.d.ts +0 -36
- package/lib/components/base/Animations.d.ts.map +0 -1
- package/lib/components/base/Animations.js +0 -70
- package/lib/components/base/Animations.ts +0 -112
- package/lib/components/base/BaseComponent.d.ts +0 -294
- package/lib/components/base/BaseComponent.d.ts.map +0 -1
- package/lib/components/base/BaseComponent.js +0 -735
- package/lib/components/base/BaseComponent.ts +0 -884
- package/lib/components/base/FormInput.d.ts +0 -77
- package/lib/components/base/FormInput.d.ts.map +0 -1
- package/lib/components/base/FormInput.js +0 -171
- package/lib/components/base/FormInput.ts +0 -237
- package/lib/components/blueprint.d.ts +0 -40
- package/lib/components/blueprint.d.ts.map +0 -1
- package/lib/components/blueprint.js +0 -327
- package/lib/components/button.d.ts +0 -70
- package/lib/components/button.d.ts.map +0 -1
- package/lib/components/button.js +0 -177
- package/lib/components/button.ts +0 -237
- package/lib/components/card.d.ts +0 -35
- package/lib/components/card.d.ts.map +0 -1
- package/lib/components/card.js +0 -130
- package/lib/components/card.ts +0 -177
- package/lib/components/chart.d.ts +0 -49
- package/lib/components/chart.d.ts.map +0 -1
- package/lib/components/chart.js +0 -205
- package/lib/components/chart.ts +0 -254
- package/lib/components/checkbox.d.ts +0 -33
- package/lib/components/checkbox.d.ts.map +0 -1
- package/lib/components/checkbox.js +0 -202
- package/lib/components/checkbox.ts +0 -260
- package/lib/components/code.d.ts +0 -52
- package/lib/components/code.d.ts.map +0 -1
- package/lib/components/code.js +0 -201
- package/lib/components/code.ts +0 -260
- package/lib/components/container.d.ts +0 -60
- package/lib/components/container.d.ts.map +0 -1
- package/lib/components/container.js +0 -195
- package/lib/components/container.ts +0 -259
- package/lib/components/data.d.ts +0 -36
- package/lib/components/data.d.ts.map +0 -1
- package/lib/components/data.js +0 -110
- package/lib/components/data.ts +0 -135
- package/lib/components/dataframe/DataFrameSource.d.ts +0 -118
- package/lib/components/dataframe/DataFrameSource.d.ts.map +0 -1
- package/lib/components/dataframe/DataFrameSource.js +0 -421
- package/lib/components/dataframe/DataFrameSource.ts +0 -532
- package/lib/components/dataframe/ImportSettingsModal.d.ts +0 -60
- package/lib/components/dataframe/ImportSettingsModal.d.ts.map +0 -1
- package/lib/components/dataframe/ImportSettingsModal.js +0 -442
- package/lib/components/dataframe/ImportSettingsModal.ts +0 -531
- package/lib/components/dataframe.d.ts +0 -110
- package/lib/components/dataframe.d.ts.map +0 -1
- package/lib/components/dataframe.js +0 -470
- package/lib/components/datepicker.d.ts +0 -40
- package/lib/components/datepicker.d.ts.map +0 -1
- package/lib/components/datepicker.js +0 -193
- package/lib/components/datepicker.ts +0 -251
- package/lib/components/dialog.d.ts +0 -39
- package/lib/components/dialog.d.ts.map +0 -1
- package/lib/components/dialog.js +0 -131
- package/lib/components/dialog.ts +0 -178
- package/lib/components/divider.d.ts +0 -31
- package/lib/components/divider.d.ts.map +0 -1
- package/lib/components/divider.js +0 -72
- package/lib/components/divider.ts +0 -104
- package/lib/components/dropdown-menu.d.ts +0 -42
- package/lib/components/dropdown-menu.d.ts.map +0 -1
- package/lib/components/dropdown-menu.js +0 -177
- package/lib/components/dropdown-menu.ts +0 -214
- package/lib/components/dropdown.d.ts +0 -41
- package/lib/components/dropdown.d.ts.map +0 -1
- package/lib/components/dropdown.js +0 -136
- package/lib/components/dropdown.ts +0 -188
- package/lib/components/element.d.ts +0 -51
- package/lib/components/element.d.ts.map +0 -1
- package/lib/components/element.js +0 -209
- package/lib/components/element.ts +0 -271
- package/lib/components/event-chain.d.ts +0 -9
- package/lib/components/event-chain.d.ts.map +0 -1
- package/lib/components/event-chain.js +0 -33
- package/lib/components/fileupload.d.ts +0 -98
- package/lib/components/fileupload.d.ts.map +0 -1
- package/lib/components/fileupload.js +0 -351
- package/lib/components/fileupload.ts +0 -449
- package/lib/components/grid.d.ts +0 -88
- package/lib/components/grid.d.ts.map +0 -1
- package/lib/components/grid.js +0 -208
- package/lib/components/grid.ts +0 -295
- package/lib/components/heading.d.ts +0 -25
- package/lib/components/heading.d.ts.map +0 -1
- package/lib/components/heading.js +0 -83
- package/lib/components/heading.ts +0 -113
- package/lib/components/helpers.d.ts +0 -9
- package/lib/components/helpers.d.ts.map +0 -1
- package/lib/components/helpers.js +0 -30
- package/lib/components/helpers.ts +0 -41
- package/lib/components/hero.d.ts +0 -60
- package/lib/components/hero.d.ts.map +0 -1
- package/lib/components/hero.js +0 -239
- package/lib/components/hero.ts +0 -302
- package/lib/components/history/StateHistory.d.ts +0 -91
- package/lib/components/history/StateHistory.d.ts.map +0 -1
- package/lib/components/history/StateHistory.js +0 -154
- package/lib/components/history/StateHistory.ts +0 -200
- package/lib/components/icon.d.ts +0 -36
- package/lib/components/icon.d.ts.map +0 -1
- package/lib/components/icon.js +0 -135
- package/lib/components/icon.ts +0 -182
- package/lib/components/icons.d.ts +0 -25
- package/lib/components/icons.d.ts.map +0 -1
- package/lib/components/icons.js +0 -440
- package/lib/components/icons.ts +0 -464
- package/lib/components/image.d.ts +0 -42
- package/lib/components/image.d.ts.map +0 -1
- package/lib/components/image.js +0 -204
- package/lib/components/image.ts +0 -260
- package/lib/components/include.d.ts +0 -86
- package/lib/components/include.d.ts.map +0 -1
- package/lib/components/include.js +0 -238
- package/lib/components/include.ts +0 -281
- package/lib/components/input.d.ts +0 -85
- package/lib/components/input.d.ts.map +0 -1
- package/lib/components/input.js +0 -362
- package/lib/components/input.ts +0 -473
- package/lib/components/layer.d.ts +0 -72
- package/lib/components/layer.d.ts.map +0 -1
- package/lib/components/layer.js +0 -219
- package/lib/components/layer.ts +0 -304
- package/lib/components/link.d.ts +0 -41
- package/lib/components/link.d.ts.map +0 -1
- package/lib/components/link.js +0 -216
- package/lib/components/link.ts +0 -268
- package/lib/components/list.d.ts +0 -83
- package/lib/components/list.d.ts.map +0 -1
- package/lib/components/list.js +0 -314
- package/lib/components/list.ts +0 -423
- package/lib/components/loading.d.ts +0 -25
- package/lib/components/loading.d.ts.map +0 -1
- package/lib/components/loading.js +0 -76
- package/lib/components/loading.ts +0 -104
- package/lib/components/menu.d.ts +0 -38
- package/lib/components/menu.d.ts.map +0 -1
- package/lib/components/menu.js +0 -205
- package/lib/components/menu.ts +0 -279
- package/lib/components/modal.d.ts +0 -97
- package/lib/components/modal.d.ts.map +0 -1
- package/lib/components/modal.js +0 -463
- package/lib/components/modal.ts +0 -576
- package/lib/components/nav.d.ts +0 -46
- package/lib/components/nav.d.ts.map +0 -1
- package/lib/components/nav.js +0 -193
- package/lib/components/nav.ts +0 -261
- package/lib/components/paragraph.d.ts +0 -30
- package/lib/components/paragraph.d.ts.map +0 -1
- package/lib/components/paragraph.js +0 -93
- package/lib/components/paragraph.ts +0 -123
- package/lib/components/pen.d.ts +0 -125
- package/lib/components/pen.d.ts.map +0 -1
- package/lib/components/pen.js +0 -443
- package/lib/components/pen.ts +0 -567
- package/lib/components/progress.d.ts +0 -40
- package/lib/components/progress.d.ts.map +0 -1
- package/lib/components/progress.js +0 -116
- package/lib/components/progress.ts +0 -163
- package/lib/components/radio.d.ts +0 -43
- package/lib/components/radio.d.ts.map +0 -1
- package/lib/components/radio.js +0 -226
- package/lib/components/radio.ts +0 -303
- package/lib/components/registry.d.ts +0 -34
- package/lib/components/registry.d.ts.map +0 -1
- package/lib/components/registry.js +0 -163
- package/lib/components/registry.ts +0 -193
- package/lib/components/req.d.ts +0 -155
- package/lib/components/req.d.ts.map +0 -1
- package/lib/components/req.js +0 -253
- package/lib/components/req.ts +0 -303
- package/lib/components/script.d.ts +0 -14
- package/lib/components/script.d.ts.map +0 -1
- package/lib/components/script.js +0 -33
- package/lib/components/script.ts +0 -41
- package/lib/components/select.d.ts +0 -42
- package/lib/components/select.d.ts.map +0 -1
- package/lib/components/select.js +0 -209
- package/lib/components/select.ts +0 -281
- package/lib/components/sidebar.d.ts +0 -59
- package/lib/components/sidebar.d.ts.map +0 -1
- package/lib/components/sidebar.js +0 -298
- package/lib/components/sidebar.ts +0 -395
- package/lib/components/stack/BaseStack.d.ts +0 -65
- package/lib/components/stack/BaseStack.d.ts.map +0 -1
- package/lib/components/stack/BaseStack.js +0 -274
- package/lib/components/stack/BaseStack.ts +0 -328
- package/lib/components/stack/HStack.d.ts +0 -18
- package/lib/components/stack/HStack.d.ts.map +0 -1
- package/lib/components/stack/HStack.js +0 -22
- package/lib/components/stack/HStack.ts +0 -25
- package/lib/components/stack/VStack.d.ts +0 -19
- package/lib/components/stack/VStack.d.ts.map +0 -1
- package/lib/components/stack/VStack.js +0 -23
- package/lib/components/stack/VStack.ts +0 -26
- package/lib/components/stack/ZStack.d.ts +0 -18
- package/lib/components/stack/ZStack.d.ts.map +0 -1
- package/lib/components/stack/ZStack.js +0 -22
- package/lib/components/stack/ZStack.ts +0 -25
- package/lib/components/style.d.ts +0 -14
- package/lib/components/style.d.ts.map +0 -1
- package/lib/components/style.js +0 -33
- package/lib/components/style.ts +0 -41
- package/lib/components/switch.d.ts +0 -34
- package/lib/components/switch.d.ts.map +0 -1
- package/lib/components/switch.js +0 -209
- package/lib/components/switch.ts +0 -272
- package/lib/components/table.d.ts +0 -137
- package/lib/components/table.d.ts.map +0 -1
- package/lib/components/table.js +0 -1019
- package/lib/components/table.ts +0 -1225
- package/lib/components/tabs.d.ts +0 -53
- package/lib/components/tabs.d.ts.map +0 -1
- package/lib/components/tabs.js +0 -275
- package/lib/components/tabs.ts +0 -349
- package/lib/components/theme-toggle.d.ts +0 -45
- package/lib/components/theme-toggle.d.ts.map +0 -1
- package/lib/components/theme-toggle.js +0 -218
- package/lib/components/theme-toggle.ts +0 -297
- package/lib/components/tooltip.d.ts +0 -31
- package/lib/components/tooltip.d.ts.map +0 -1
- package/lib/components/tooltip.js +0 -112
- package/lib/components/tooltip.ts +0 -148
- package/lib/components/watcher.d.ts +0 -195
- package/lib/components/watcher.d.ts.map +0 -1
- package/lib/components/watcher.js +0 -241
- package/lib/components/watcher.ts +0 -261
- package/lib/components/write.d.ts +0 -107
- package/lib/components/write.d.ts.map +0 -1
- package/lib/components/write.js +0 -222
- package/lib/components/write.ts +0 -272
- package/lib/data/DataPipeline.d.ts +0 -113
- package/lib/data/DataPipeline.d.ts.map +0 -1
- package/lib/data/DataPipeline.js +0 -359
- package/lib/data/DataPipeline.ts +0 -452
- package/lib/facades/dataframe.jux +0 -0
- package/lib/globals.d.ts +0 -21
- package/lib/reactivity/state.d.ts +0 -36
- package/lib/reactivity/state.d.ts.map +0 -1
- package/lib/reactivity/state.js +0 -67
- package/lib/reactivity/state.ts +0 -78
- package/lib/storage/DataFrame.d.ts +0 -284
- package/lib/storage/DataFrame.d.ts.map +0 -1
- package/lib/storage/DataFrame.js +0 -1022
- package/lib/storage/DataFrame.ts +0 -1195
- package/lib/storage/DataFrameSource.d.ts +0 -158
- package/lib/storage/DataFrameSource.d.ts.map +0 -1
- package/lib/storage/DataFrameSource.js +0 -409
- package/lib/storage/DataFrameSource.ts +0 -556
- package/lib/storage/FileStorage.d.ts +0 -53
- package/lib/storage/FileStorage.d.ts.map +0 -1
- package/lib/storage/FileStorage.js +0 -80
- package/lib/storage/FileStorage.ts +0 -95
- package/lib/storage/IndexedDBDriver.d.ts +0 -75
- package/lib/storage/IndexedDBDriver.d.ts.map +0 -1
- package/lib/storage/IndexedDBDriver.js +0 -177
- package/lib/storage/IndexedDBDriver.ts +0 -226
- package/lib/storage/TabularDriver.d.ts +0 -118
- package/lib/storage/TabularDriver.d.ts.map +0 -1
- package/lib/storage/TabularDriver.js +0 -731
- package/lib/storage/TabularDriver.ts +0 -874
- package/lib/utils/codeparser.d.ts +0 -29
- package/lib/utils/codeparser.d.ts.map +0 -1
- package/lib/utils/codeparser.js +0 -409
- package/lib/utils/fetch.d.ts +0 -176
- package/lib/utils/fetch.d.ts.map +0 -1
- package/lib/utils/fetch.js +0 -427
- package/lib/utils/formatId.d.ts +0 -16
- package/lib/utils/formatId.d.ts.map +0 -1
- package/lib/utils/formatId.js +0 -27
- package/lib/utils/path-resolver.js +0 -23
package/lib/components/pen.ts
DELETED
|
@@ -1,567 +0,0 @@
|
|
|
1
|
-
import { BaseComponent, BaseState } from './base/BaseComponent.js';
|
|
2
|
-
|
|
3
|
-
// Event definitions
|
|
4
|
-
const TRIGGER_EVENTS = [] as const;
|
|
5
|
-
const CALLBACK_EVENTS = ['draw', 'shapeAdd', 'shapeRemove', 'connectionAdd'] as const;
|
|
6
|
-
|
|
7
|
-
export interface PenShape {
|
|
8
|
-
id: string;
|
|
9
|
-
type: 'line' | 'rectangle' | 'circle' | 'text';
|
|
10
|
-
x: number;
|
|
11
|
-
y: number;
|
|
12
|
-
width?: number;
|
|
13
|
-
height?: number;
|
|
14
|
-
radius?: number;
|
|
15
|
-
text?: string;
|
|
16
|
-
color?: string;
|
|
17
|
-
fillColor?: string;
|
|
18
|
-
strokeWidth?: number;
|
|
19
|
-
connectedTo?: string[]; // IDs of shapes connected to this one
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface PenConnection {
|
|
23
|
-
from: string;
|
|
24
|
-
to: string;
|
|
25
|
-
color?: string;
|
|
26
|
-
strokeWidth?: number;
|
|
27
|
-
dashed?: boolean;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface PenOptions {
|
|
31
|
-
width?: number | string;
|
|
32
|
-
height?: number | string;
|
|
33
|
-
backgroundColor?: string;
|
|
34
|
-
backgroundImage?: string;
|
|
35
|
-
border?: string;
|
|
36
|
-
text?: string;
|
|
37
|
-
radius?: number;
|
|
38
|
-
gridEnabled?: boolean;
|
|
39
|
-
gridSize?: number;
|
|
40
|
-
gridColor?: string;
|
|
41
|
-
style?: string;
|
|
42
|
-
class?: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
type PenState = BaseState & {
|
|
46
|
-
width: number | string;
|
|
47
|
-
height: number | string;
|
|
48
|
-
backgroundColor: string;
|
|
49
|
-
backgroundImage: string;
|
|
50
|
-
border: string;
|
|
51
|
-
text: string;
|
|
52
|
-
radius: number;
|
|
53
|
-
gridEnabled: boolean;
|
|
54
|
-
gridSize: number;
|
|
55
|
-
gridColor: string;
|
|
56
|
-
shapes: PenShape[];
|
|
57
|
-
connections: PenConnection[];
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export class Pen extends BaseComponent<PenState> {
|
|
61
|
-
private _canvas: HTMLCanvasElement | null = null;
|
|
62
|
-
private _ctx: CanvasRenderingContext2D | null = null;
|
|
63
|
-
private _animationFrame?: number;
|
|
64
|
-
|
|
65
|
-
constructor(id: string, options: PenOptions = {}) {
|
|
66
|
-
super(id, {
|
|
67
|
-
width: options.width ?? '100%',
|
|
68
|
-
height: options.height ?? 400,
|
|
69
|
-
backgroundColor: options.backgroundColor ?? '#ffffff',
|
|
70
|
-
backgroundImage: options.backgroundImage ?? '',
|
|
71
|
-
border: options.border ?? '1px solid #e5e7eb',
|
|
72
|
-
text: options.text ?? '',
|
|
73
|
-
radius: options.radius ?? 0,
|
|
74
|
-
gridEnabled: options.gridEnabled ?? false,
|
|
75
|
-
gridSize: options.gridSize ?? 20,
|
|
76
|
-
gridColor: options.gridColor ?? '#f0f0f0',
|
|
77
|
-
shapes: [],
|
|
78
|
-
connections: [],
|
|
79
|
-
style: options.style ?? '',
|
|
80
|
-
class: options.class ?? ''
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
protected getTriggerEvents(): readonly string[] {
|
|
85
|
-
return TRIGGER_EVENTS;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
protected getCallbackEvents(): readonly string[] {
|
|
89
|
-
return CALLBACK_EVENTS;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
93
|
-
* REACTIVE UPDATE
|
|
94
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
95
|
-
|
|
96
|
-
update(prop: string, value: any): void {
|
|
97
|
-
super.update(prop, value);
|
|
98
|
-
|
|
99
|
-
if (!this._canvas || !this._ctx) return;
|
|
100
|
-
|
|
101
|
-
switch (prop) {
|
|
102
|
-
case 'backgroundColor':
|
|
103
|
-
this._redraw();
|
|
104
|
-
break;
|
|
105
|
-
case 'backgroundImage':
|
|
106
|
-
this._redraw();
|
|
107
|
-
break;
|
|
108
|
-
case 'text':
|
|
109
|
-
this._redraw();
|
|
110
|
-
break;
|
|
111
|
-
case 'gridEnabled':
|
|
112
|
-
case 'gridSize':
|
|
113
|
-
case 'gridColor':
|
|
114
|
-
this._redraw();
|
|
115
|
-
break;
|
|
116
|
-
case 'shapes':
|
|
117
|
-
case 'connections':
|
|
118
|
-
this._redraw();
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
124
|
-
* FLUENT API
|
|
125
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
126
|
-
|
|
127
|
-
width(value: number | string): this {
|
|
128
|
-
this.state.width = value;
|
|
129
|
-
if (this._canvas) {
|
|
130
|
-
this._canvas.style.width = typeof value === 'number' ? `${value}px` : value;
|
|
131
|
-
this._updateCanvasSize();
|
|
132
|
-
}
|
|
133
|
-
return this;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
height(value: number | string): this {
|
|
137
|
-
this.state.height = value;
|
|
138
|
-
if (this._canvas) {
|
|
139
|
-
this._canvas.style.height = typeof value === 'number' ? `${value}px` : value;
|
|
140
|
-
this._updateCanvasSize();
|
|
141
|
-
}
|
|
142
|
-
return this;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
backgroundColor(value: string): this {
|
|
146
|
-
this.state.backgroundColor = value;
|
|
147
|
-
return this;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
backgroundImage(value: string): this {
|
|
151
|
-
this.state.backgroundImage = value;
|
|
152
|
-
return this;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
border(value: string): this {
|
|
156
|
-
this.state.border = value;
|
|
157
|
-
if (this._canvas) {
|
|
158
|
-
this._canvas.style.border = value;
|
|
159
|
-
}
|
|
160
|
-
return this;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
text(value: string): this {
|
|
164
|
-
this.state.text = value;
|
|
165
|
-
return this;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
radius(value: number): this {
|
|
169
|
-
this.state.radius = value;
|
|
170
|
-
if (this._canvas) {
|
|
171
|
-
this._canvas.style.borderRadius = `${value}px`;
|
|
172
|
-
}
|
|
173
|
-
return this;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
grid(enabled: boolean, size?: number, color?: string): this {
|
|
177
|
-
this.state.gridEnabled = enabled;
|
|
178
|
-
if (size !== undefined) this.state.gridSize = size;
|
|
179
|
-
if (color !== undefined) this.state.gridColor = color;
|
|
180
|
-
return this;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
184
|
-
* DRAWING API
|
|
185
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
186
|
-
|
|
187
|
-
/**
|
|
188
|
-
* Add a line shape
|
|
189
|
-
*/
|
|
190
|
-
drawLine(x1: number, y1: number, x2: number, y2: number, options: Partial<PenShape> = {}): this {
|
|
191
|
-
const shape: PenShape = {
|
|
192
|
-
id: options.id || `line-${Date.now()}-${Math.random()}`,
|
|
193
|
-
type: 'line',
|
|
194
|
-
x: x1,
|
|
195
|
-
y: y1,
|
|
196
|
-
width: x2 - x1,
|
|
197
|
-
height: y2 - y1,
|
|
198
|
-
color: options.color || '#000000',
|
|
199
|
-
strokeWidth: options.strokeWidth || 2,
|
|
200
|
-
connectedTo: options.connectedTo || []
|
|
201
|
-
};
|
|
202
|
-
|
|
203
|
-
this.state.shapes = [...this.state.shapes, shape];
|
|
204
|
-
this._triggerCallback('shapeAdd', shape);
|
|
205
|
-
return this;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Add a rectangle shape
|
|
210
|
-
*/
|
|
211
|
-
drawRect(x: number, y: number, width: number, height: number, options: Partial<PenShape> = {}): this {
|
|
212
|
-
const shape: PenShape = {
|
|
213
|
-
id: options.id || `rect-${Date.now()}-${Math.random()}`,
|
|
214
|
-
type: 'rectangle',
|
|
215
|
-
x,
|
|
216
|
-
y,
|
|
217
|
-
width,
|
|
218
|
-
height,
|
|
219
|
-
color: options.color || '#000000',
|
|
220
|
-
fillColor: options.fillColor,
|
|
221
|
-
strokeWidth: options.strokeWidth || 2,
|
|
222
|
-
connectedTo: options.connectedTo || []
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
this.state.shapes = [...this.state.shapes, shape];
|
|
226
|
-
this._triggerCallback('shapeAdd', shape);
|
|
227
|
-
return this;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Add a circle shape
|
|
232
|
-
*/
|
|
233
|
-
drawCircle(x: number, y: number, radius: number, options: Partial<PenShape> = {}): this {
|
|
234
|
-
const shape: PenShape = {
|
|
235
|
-
id: options.id || `circle-${Date.now()}-${Math.random()}`,
|
|
236
|
-
type: 'circle',
|
|
237
|
-
x,
|
|
238
|
-
y,
|
|
239
|
-
radius,
|
|
240
|
-
color: options.color || '#000000',
|
|
241
|
-
fillColor: options.fillColor,
|
|
242
|
-
strokeWidth: options.strokeWidth || 2,
|
|
243
|
-
connectedTo: options.connectedTo || []
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
this.state.shapes = [...this.state.shapes, shape];
|
|
247
|
-
this._triggerCallback('shapeAdd', shape);
|
|
248
|
-
return this;
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Add text to canvas
|
|
253
|
-
*/
|
|
254
|
-
drawText(x: number, y: number, text: string, options: Partial<PenShape> = {}): this {
|
|
255
|
-
const shape: PenShape = {
|
|
256
|
-
id: options.id || `text-${Date.now()}-${Math.random()}`,
|
|
257
|
-
type: 'text',
|
|
258
|
-
x,
|
|
259
|
-
y,
|
|
260
|
-
text,
|
|
261
|
-
color: options.color || '#000000',
|
|
262
|
-
connectedTo: options.connectedTo || []
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
this.state.shapes = [...this.state.shapes, shape];
|
|
266
|
-
this._triggerCallback('shapeAdd', shape);
|
|
267
|
-
return this;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
/**
|
|
271
|
-
* Connect two shapes with a line
|
|
272
|
-
*/
|
|
273
|
-
connect(fromId: string, toId: string, options: Partial<PenConnection> = {}): this {
|
|
274
|
-
const connection: PenConnection = {
|
|
275
|
-
from: fromId,
|
|
276
|
-
to: toId,
|
|
277
|
-
color: options.color || '#666666',
|
|
278
|
-
strokeWidth: options.strokeWidth || 1,
|
|
279
|
-
dashed: options.dashed || false
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
this.state.connections = [...this.state.connections, connection];
|
|
283
|
-
|
|
284
|
-
// Update connected shapes
|
|
285
|
-
const fromShape = this.state.shapes.find(s => s.id === fromId);
|
|
286
|
-
if (fromShape && !fromShape.connectedTo?.includes(toId)) {
|
|
287
|
-
fromShape.connectedTo = [...(fromShape.connectedTo || []), toId];
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
this._triggerCallback('connectionAdd', connection);
|
|
291
|
-
return this;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
/**
|
|
295
|
-
* Remove a shape by ID
|
|
296
|
-
*/
|
|
297
|
-
removeShape(id: string): this {
|
|
298
|
-
this.state.shapes = this.state.shapes.filter(s => s.id !== id);
|
|
299
|
-
this.state.connections = this.state.connections.filter(c => c.from !== id && c.to !== id);
|
|
300
|
-
this._triggerCallback('shapeRemove', id);
|
|
301
|
-
return this;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Clear all shapes and connections
|
|
306
|
-
*/
|
|
307
|
-
clear(): this {
|
|
308
|
-
this.state.shapes = [];
|
|
309
|
-
this.state.connections = [];
|
|
310
|
-
return this;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* Get shape by ID
|
|
315
|
-
*/
|
|
316
|
-
getShape(id: string): PenShape | undefined {
|
|
317
|
-
return this.state.shapes.find(s => s.id === id);
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Get all shapes
|
|
322
|
-
*/
|
|
323
|
-
getShapes(): PenShape[] {
|
|
324
|
-
return this.state.shapes;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
/**
|
|
328
|
-
* Export canvas as data URL
|
|
329
|
-
*/
|
|
330
|
-
toDataURL(type: string = 'image/png'): string {
|
|
331
|
-
return this._canvas?.toDataURL(type) || '';
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* Download canvas as image
|
|
336
|
-
*/
|
|
337
|
-
download(filename: string = 'pen-drawing.png'): this {
|
|
338
|
-
const dataURL = this.toDataURL();
|
|
339
|
-
const link = document.createElement('a');
|
|
340
|
-
link.download = filename;
|
|
341
|
-
link.href = dataURL;
|
|
342
|
-
link.click();
|
|
343
|
-
return this;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
347
|
-
* PRIVATE RENDERING
|
|
348
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
349
|
-
|
|
350
|
-
private _updateCanvasSize(): void {
|
|
351
|
-
if (!this._canvas) return;
|
|
352
|
-
|
|
353
|
-
const rect = this._canvas.getBoundingClientRect();
|
|
354
|
-
this._canvas.width = rect.width;
|
|
355
|
-
this._canvas.height = rect.height;
|
|
356
|
-
this._redraw();
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
private _redraw(): void {
|
|
360
|
-
if (!this._ctx || !this._canvas) return;
|
|
361
|
-
|
|
362
|
-
const { width, height } = this._canvas;
|
|
363
|
-
|
|
364
|
-
// Clear canvas
|
|
365
|
-
this._ctx.clearRect(0, 0, width, height);
|
|
366
|
-
|
|
367
|
-
// Draw background
|
|
368
|
-
if (this.state.backgroundColor) {
|
|
369
|
-
this._ctx.fillStyle = this.state.backgroundColor;
|
|
370
|
-
this._ctx.fillRect(0, 0, width, height);
|
|
371
|
-
}
|
|
372
|
-
|
|
373
|
-
// Draw background image
|
|
374
|
-
if (this.state.backgroundImage) {
|
|
375
|
-
const img = new Image();
|
|
376
|
-
img.src = this.state.backgroundImage;
|
|
377
|
-
img.onload = () => {
|
|
378
|
-
this._ctx?.drawImage(img, 0, 0, width, height);
|
|
379
|
-
this._drawContent();
|
|
380
|
-
};
|
|
381
|
-
} else {
|
|
382
|
-
this._drawContent();
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
private _drawContent(): void {
|
|
387
|
-
if (!this._ctx || !this._canvas) return;
|
|
388
|
-
|
|
389
|
-
// Draw grid
|
|
390
|
-
if (this.state.gridEnabled) {
|
|
391
|
-
this._drawGrid();
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
// Draw connections first (under shapes)
|
|
395
|
-
this.state.connections.forEach(conn => this._drawConnection(conn));
|
|
396
|
-
|
|
397
|
-
// Draw shapes
|
|
398
|
-
this.state.shapes.forEach(shape => this._drawShape(shape));
|
|
399
|
-
|
|
400
|
-
// Draw text overlay
|
|
401
|
-
if (this.state.text) {
|
|
402
|
-
this._ctx.fillStyle = '#000000';
|
|
403
|
-
this._ctx.font = '16px sans-serif';
|
|
404
|
-
this._ctx.fillText(this.state.text, 10, 30);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
this._triggerCallback('draw', { shapes: this.state.shapes, connections: this.state.connections });
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
private _drawGrid(): void {
|
|
411
|
-
if (!this._ctx || !this._canvas) return;
|
|
412
|
-
|
|
413
|
-
const { width, height } = this._canvas;
|
|
414
|
-
const { gridSize, gridColor } = this.state;
|
|
415
|
-
|
|
416
|
-
this._ctx.strokeStyle = gridColor;
|
|
417
|
-
this._ctx.lineWidth = 1;
|
|
418
|
-
|
|
419
|
-
// Vertical lines
|
|
420
|
-
for (let x = 0; x <= width; x += gridSize) {
|
|
421
|
-
this._ctx.beginPath();
|
|
422
|
-
this._ctx.moveTo(x, 0);
|
|
423
|
-
this._ctx.lineTo(x, height);
|
|
424
|
-
this._ctx.stroke();
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
// Horizontal lines
|
|
428
|
-
for (let y = 0; y <= height; y += gridSize) {
|
|
429
|
-
this._ctx.beginPath();
|
|
430
|
-
this._ctx.moveTo(0, y);
|
|
431
|
-
this._ctx.lineTo(width, y);
|
|
432
|
-
this._ctx.stroke();
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
private _drawShape(shape: PenShape): void {
|
|
437
|
-
if (!this._ctx) return;
|
|
438
|
-
|
|
439
|
-
this._ctx.strokeStyle = shape.color || '#000000';
|
|
440
|
-
this._ctx.lineWidth = shape.strokeWidth || 2;
|
|
441
|
-
|
|
442
|
-
switch (shape.type) {
|
|
443
|
-
case 'line':
|
|
444
|
-
this._ctx.beginPath();
|
|
445
|
-
this._ctx.moveTo(shape.x, shape.y);
|
|
446
|
-
this._ctx.lineTo(shape.x + (shape.width || 0), shape.y + (shape.height || 0));
|
|
447
|
-
this._ctx.stroke();
|
|
448
|
-
break;
|
|
449
|
-
|
|
450
|
-
case 'rectangle':
|
|
451
|
-
if (shape.fillColor) {
|
|
452
|
-
this._ctx.fillStyle = shape.fillColor;
|
|
453
|
-
this._ctx.fillRect(shape.x, shape.y, shape.width || 0, shape.height || 0);
|
|
454
|
-
}
|
|
455
|
-
this._ctx.strokeRect(shape.x, shape.y, shape.width || 0, shape.height || 0);
|
|
456
|
-
break;
|
|
457
|
-
|
|
458
|
-
case 'circle':
|
|
459
|
-
this._ctx.beginPath();
|
|
460
|
-
this._ctx.arc(shape.x, shape.y, shape.radius || 0, 0, Math.PI * 2);
|
|
461
|
-
if (shape.fillColor) {
|
|
462
|
-
this._ctx.fillStyle = shape.fillColor;
|
|
463
|
-
this._ctx.fill();
|
|
464
|
-
}
|
|
465
|
-
this._ctx.stroke();
|
|
466
|
-
break;
|
|
467
|
-
|
|
468
|
-
case 'text':
|
|
469
|
-
this._ctx.fillStyle = shape.color || '#000000';
|
|
470
|
-
this._ctx.font = '14px sans-serif';
|
|
471
|
-
this._ctx.fillText(shape.text || '', shape.x, shape.y);
|
|
472
|
-
break;
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
private _drawConnection(conn: PenConnection): void {
|
|
477
|
-
if (!this._ctx) return;
|
|
478
|
-
|
|
479
|
-
const fromShape = this.state.shapes.find(s => s.id === conn.from);
|
|
480
|
-
const toShape = this.state.shapes.find(s => s.id === conn.to);
|
|
481
|
-
|
|
482
|
-
if (!fromShape || !toShape) return;
|
|
483
|
-
|
|
484
|
-
// Calculate center points
|
|
485
|
-
const fromX = fromShape.x + (fromShape.width || fromShape.radius || 0) / 2;
|
|
486
|
-
const fromY = fromShape.y + (fromShape.height || fromShape.radius || 0) / 2;
|
|
487
|
-
const toX = toShape.x + (toShape.width || toShape.radius || 0) / 2;
|
|
488
|
-
const toY = toShape.y + (toShape.height || toShape.radius || 0) / 2;
|
|
489
|
-
|
|
490
|
-
this._ctx.strokeStyle = conn.color || '#666666';
|
|
491
|
-
this._ctx.lineWidth = conn.strokeWidth || 1;
|
|
492
|
-
|
|
493
|
-
if (conn.dashed) {
|
|
494
|
-
this._ctx.setLineDash([5, 5]);
|
|
495
|
-
}
|
|
496
|
-
|
|
497
|
-
this._ctx.beginPath();
|
|
498
|
-
this._ctx.moveTo(fromX, fromY);
|
|
499
|
-
this._ctx.lineTo(toX, toY);
|
|
500
|
-
this._ctx.stroke();
|
|
501
|
-
|
|
502
|
-
if (conn.dashed) {
|
|
503
|
-
this._ctx.setLineDash([]);
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
|
|
507
|
-
/* ═════════════════════════════════════════════════════════════════
|
|
508
|
-
* RENDER
|
|
509
|
-
* ═════════════════════════════════════════════════════════════════ */
|
|
510
|
-
|
|
511
|
-
render(targetId?: string | HTMLElement | BaseComponent<any>): this {
|
|
512
|
-
const container = this._setupContainer(targetId);
|
|
513
|
-
|
|
514
|
-
const { width, height, backgroundColor, border, radius, style, class: className } = this.state;
|
|
515
|
-
|
|
516
|
-
const wrapper = document.createElement('div');
|
|
517
|
-
wrapper.className = 'jux-pen';
|
|
518
|
-
wrapper.id = `${this._id}-wrapper`;
|
|
519
|
-
if (className) wrapper.className += ` ${className}`;
|
|
520
|
-
if (style) wrapper.setAttribute('style', style);
|
|
521
|
-
|
|
522
|
-
const canvas = document.createElement('canvas');
|
|
523
|
-
canvas.id = this._id;
|
|
524
|
-
canvas.className = 'jux-pen-canvas';
|
|
525
|
-
canvas.style.width = typeof width === 'number' ? `${width}px` : width;
|
|
526
|
-
canvas.style.height = typeof height === 'number' ? `${height}px` : height;
|
|
527
|
-
canvas.style.backgroundColor = backgroundColor;
|
|
528
|
-
canvas.style.border = border;
|
|
529
|
-
canvas.style.borderRadius = `${radius}px`;
|
|
530
|
-
canvas.style.display = 'block';
|
|
531
|
-
|
|
532
|
-
this._canvas = canvas;
|
|
533
|
-
this._ctx = canvas.getContext('2d');
|
|
534
|
-
|
|
535
|
-
// Set initial canvas size
|
|
536
|
-
requestAnimationFrame(() => {
|
|
537
|
-
this._updateCanvasSize();
|
|
538
|
-
});
|
|
539
|
-
|
|
540
|
-
// Handle window resize
|
|
541
|
-
window.addEventListener('resize', () => {
|
|
542
|
-
this._updateCanvasSize();
|
|
543
|
-
});
|
|
544
|
-
|
|
545
|
-
this._wireStandardEvents(wrapper);
|
|
546
|
-
this._wireAllSyncs();
|
|
547
|
-
|
|
548
|
-
wrapper.appendChild(canvas);
|
|
549
|
-
container.appendChild(wrapper);
|
|
550
|
-
|
|
551
|
-
return this;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
* Cleanup on destroy
|
|
556
|
-
*/
|
|
557
|
-
destroy(): void {
|
|
558
|
-
if (this._animationFrame) {
|
|
559
|
-
cancelAnimationFrame(this._animationFrame);
|
|
560
|
-
}
|
|
561
|
-
this.remove();
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
export function pen(id: string, options: PenOptions = {}): Pen {
|
|
566
|
-
return new Pen(id, options);
|
|
567
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from './base/BaseComponent.js';
|
|
2
|
-
export interface ProgressOptions {
|
|
3
|
-
value?: number;
|
|
4
|
-
max?: number;
|
|
5
|
-
variant?: 'default' | 'success' | 'warning' | 'error';
|
|
6
|
-
showPercentage?: boolean;
|
|
7
|
-
label?: string;
|
|
8
|
-
size?: 'sm' | 'md' | 'lg';
|
|
9
|
-
style?: string;
|
|
10
|
-
class?: string;
|
|
11
|
-
}
|
|
12
|
-
type ProgressState = {
|
|
13
|
-
value: number;
|
|
14
|
-
max: number;
|
|
15
|
-
variant: string;
|
|
16
|
-
showPercentage: boolean;
|
|
17
|
-
label: string;
|
|
18
|
-
size: string;
|
|
19
|
-
style: string;
|
|
20
|
-
class: string;
|
|
21
|
-
};
|
|
22
|
-
export declare class Progress extends BaseComponent<ProgressState> {
|
|
23
|
-
private _bar;
|
|
24
|
-
private _label;
|
|
25
|
-
constructor(id: string, options?: ProgressOptions);
|
|
26
|
-
protected getTriggerEvents(): readonly string[];
|
|
27
|
-
protected getCallbackEvents(): readonly string[];
|
|
28
|
-
value(val: number): this;
|
|
29
|
-
max(val: number): this;
|
|
30
|
-
variant(value: 'default' | 'success' | 'warning' | 'error'): this;
|
|
31
|
-
showPercentage(value: boolean): this;
|
|
32
|
-
label(value: string): this;
|
|
33
|
-
size(value: 'sm' | 'md' | 'lg'): this;
|
|
34
|
-
private _updateProgress;
|
|
35
|
-
render(targetId?: string | HTMLElement | BaseComponent<any>): this;
|
|
36
|
-
update(prop: string, value: any): void;
|
|
37
|
-
}
|
|
38
|
-
export declare function progress(id: string, options?: ProgressOptions): Progress;
|
|
39
|
-
export {};
|
|
40
|
-
//# sourceMappingURL=progress.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"progress.d.ts","sourceRoot":"","sources":["progress.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAMxD,MAAM,WAAW,eAAe;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,CAAC;IACtD,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,KAAK,aAAa,GAAG;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,OAAO,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,qBAAa,QAAS,SAAQ,aAAa,CAAC,aAAa,CAAC;IACtD,OAAO,CAAC,IAAI,CAA4B;IACxC,OAAO,CAAC,MAAM,CAA4B;gBAE9B,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB;IAarD,SAAS,CAAC,gBAAgB,IAAI,SAAS,MAAM,EAAE;IAI/C,SAAS,CAAC,iBAAiB,IAAI,SAAS,MAAM,EAAE;IAQhD,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAMxB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAMtB,OAAO,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,IAAI;IAKjE,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI;IAKpC,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAQ1B,IAAI,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI;IAKrC,OAAO,CAAC,eAAe;IAevB,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI;IAgDlE,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI;CAGzC;AAED,wBAAgB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,QAAQ,CAE5E"}
|