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.
Files changed (297) hide show
  1. package/index.js +7 -137
  2. package/lib/components/dataframe.ts +0 -569
  3. package/lib/components/tag.ts +68 -0
  4. package/lib/styles/shadcn.css +20 -7
  5. package/lib/utils/idgen.ts +6 -0
  6. package/package.json +5 -6
  7. package/index.d.ts +0 -239
  8. package/index.d.ts.map +0 -1
  9. package/lib/components/alert.d.ts +0 -36
  10. package/lib/components/alert.d.ts.map +0 -1
  11. package/lib/components/alert.js +0 -172
  12. package/lib/components/alert.ts +0 -219
  13. package/lib/components/app.d.ts +0 -89
  14. package/lib/components/app.d.ts.map +0 -1
  15. package/lib/components/app.js +0 -175
  16. package/lib/components/app.ts +0 -247
  17. package/lib/components/badge.d.ts +0 -26
  18. package/lib/components/badge.d.ts.map +0 -1
  19. package/lib/components/badge.js +0 -91
  20. package/lib/components/badge.ts +0 -118
  21. package/lib/components/base/Animations.d.ts +0 -36
  22. package/lib/components/base/Animations.d.ts.map +0 -1
  23. package/lib/components/base/Animations.js +0 -70
  24. package/lib/components/base/Animations.ts +0 -112
  25. package/lib/components/base/BaseComponent.d.ts +0 -294
  26. package/lib/components/base/BaseComponent.d.ts.map +0 -1
  27. package/lib/components/base/BaseComponent.js +0 -735
  28. package/lib/components/base/BaseComponent.ts +0 -884
  29. package/lib/components/base/FormInput.d.ts +0 -77
  30. package/lib/components/base/FormInput.d.ts.map +0 -1
  31. package/lib/components/base/FormInput.js +0 -171
  32. package/lib/components/base/FormInput.ts +0 -237
  33. package/lib/components/blueprint.d.ts +0 -40
  34. package/lib/components/blueprint.d.ts.map +0 -1
  35. package/lib/components/blueprint.js +0 -327
  36. package/lib/components/button.d.ts +0 -70
  37. package/lib/components/button.d.ts.map +0 -1
  38. package/lib/components/button.js +0 -177
  39. package/lib/components/button.ts +0 -237
  40. package/lib/components/card.d.ts +0 -35
  41. package/lib/components/card.d.ts.map +0 -1
  42. package/lib/components/card.js +0 -130
  43. package/lib/components/card.ts +0 -177
  44. package/lib/components/chart.d.ts +0 -49
  45. package/lib/components/chart.d.ts.map +0 -1
  46. package/lib/components/chart.js +0 -205
  47. package/lib/components/chart.ts +0 -254
  48. package/lib/components/checkbox.d.ts +0 -33
  49. package/lib/components/checkbox.d.ts.map +0 -1
  50. package/lib/components/checkbox.js +0 -202
  51. package/lib/components/checkbox.ts +0 -260
  52. package/lib/components/code.d.ts +0 -52
  53. package/lib/components/code.d.ts.map +0 -1
  54. package/lib/components/code.js +0 -201
  55. package/lib/components/code.ts +0 -260
  56. package/lib/components/container.d.ts +0 -60
  57. package/lib/components/container.d.ts.map +0 -1
  58. package/lib/components/container.js +0 -195
  59. package/lib/components/container.ts +0 -259
  60. package/lib/components/data.d.ts +0 -36
  61. package/lib/components/data.d.ts.map +0 -1
  62. package/lib/components/data.js +0 -110
  63. package/lib/components/data.ts +0 -135
  64. package/lib/components/dataframe/DataFrameSource.d.ts +0 -118
  65. package/lib/components/dataframe/DataFrameSource.d.ts.map +0 -1
  66. package/lib/components/dataframe/DataFrameSource.js +0 -421
  67. package/lib/components/dataframe/DataFrameSource.ts +0 -532
  68. package/lib/components/dataframe/ImportSettingsModal.d.ts +0 -60
  69. package/lib/components/dataframe/ImportSettingsModal.d.ts.map +0 -1
  70. package/lib/components/dataframe/ImportSettingsModal.js +0 -442
  71. package/lib/components/dataframe/ImportSettingsModal.ts +0 -531
  72. package/lib/components/dataframe.d.ts +0 -110
  73. package/lib/components/dataframe.d.ts.map +0 -1
  74. package/lib/components/dataframe.js +0 -470
  75. package/lib/components/datepicker.d.ts +0 -40
  76. package/lib/components/datepicker.d.ts.map +0 -1
  77. package/lib/components/datepicker.js +0 -193
  78. package/lib/components/datepicker.ts +0 -251
  79. package/lib/components/dialog.d.ts +0 -39
  80. package/lib/components/dialog.d.ts.map +0 -1
  81. package/lib/components/dialog.js +0 -131
  82. package/lib/components/dialog.ts +0 -178
  83. package/lib/components/divider.d.ts +0 -31
  84. package/lib/components/divider.d.ts.map +0 -1
  85. package/lib/components/divider.js +0 -72
  86. package/lib/components/divider.ts +0 -104
  87. package/lib/components/dropdown-menu.d.ts +0 -42
  88. package/lib/components/dropdown-menu.d.ts.map +0 -1
  89. package/lib/components/dropdown-menu.js +0 -177
  90. package/lib/components/dropdown-menu.ts +0 -214
  91. package/lib/components/dropdown.d.ts +0 -41
  92. package/lib/components/dropdown.d.ts.map +0 -1
  93. package/lib/components/dropdown.js +0 -136
  94. package/lib/components/dropdown.ts +0 -188
  95. package/lib/components/element.d.ts +0 -51
  96. package/lib/components/element.d.ts.map +0 -1
  97. package/lib/components/element.js +0 -209
  98. package/lib/components/element.ts +0 -271
  99. package/lib/components/event-chain.d.ts +0 -9
  100. package/lib/components/event-chain.d.ts.map +0 -1
  101. package/lib/components/event-chain.js +0 -33
  102. package/lib/components/fileupload.d.ts +0 -98
  103. package/lib/components/fileupload.d.ts.map +0 -1
  104. package/lib/components/fileupload.js +0 -351
  105. package/lib/components/fileupload.ts +0 -449
  106. package/lib/components/grid.d.ts +0 -88
  107. package/lib/components/grid.d.ts.map +0 -1
  108. package/lib/components/grid.js +0 -208
  109. package/lib/components/grid.ts +0 -295
  110. package/lib/components/heading.d.ts +0 -25
  111. package/lib/components/heading.d.ts.map +0 -1
  112. package/lib/components/heading.js +0 -83
  113. package/lib/components/heading.ts +0 -113
  114. package/lib/components/helpers.d.ts +0 -9
  115. package/lib/components/helpers.d.ts.map +0 -1
  116. package/lib/components/helpers.js +0 -30
  117. package/lib/components/helpers.ts +0 -41
  118. package/lib/components/hero.d.ts +0 -60
  119. package/lib/components/hero.d.ts.map +0 -1
  120. package/lib/components/hero.js +0 -239
  121. package/lib/components/hero.ts +0 -302
  122. package/lib/components/history/StateHistory.d.ts +0 -91
  123. package/lib/components/history/StateHistory.d.ts.map +0 -1
  124. package/lib/components/history/StateHistory.js +0 -154
  125. package/lib/components/history/StateHistory.ts +0 -200
  126. package/lib/components/icon.d.ts +0 -36
  127. package/lib/components/icon.d.ts.map +0 -1
  128. package/lib/components/icon.js +0 -135
  129. package/lib/components/icon.ts +0 -182
  130. package/lib/components/icons.d.ts +0 -25
  131. package/lib/components/icons.d.ts.map +0 -1
  132. package/lib/components/icons.js +0 -440
  133. package/lib/components/icons.ts +0 -464
  134. package/lib/components/image.d.ts +0 -42
  135. package/lib/components/image.d.ts.map +0 -1
  136. package/lib/components/image.js +0 -204
  137. package/lib/components/image.ts +0 -260
  138. package/lib/components/include.d.ts +0 -86
  139. package/lib/components/include.d.ts.map +0 -1
  140. package/lib/components/include.js +0 -238
  141. package/lib/components/include.ts +0 -281
  142. package/lib/components/input.d.ts +0 -85
  143. package/lib/components/input.d.ts.map +0 -1
  144. package/lib/components/input.js +0 -362
  145. package/lib/components/input.ts +0 -473
  146. package/lib/components/layer.d.ts +0 -72
  147. package/lib/components/layer.d.ts.map +0 -1
  148. package/lib/components/layer.js +0 -219
  149. package/lib/components/layer.ts +0 -304
  150. package/lib/components/link.d.ts +0 -41
  151. package/lib/components/link.d.ts.map +0 -1
  152. package/lib/components/link.js +0 -216
  153. package/lib/components/link.ts +0 -268
  154. package/lib/components/list.d.ts +0 -83
  155. package/lib/components/list.d.ts.map +0 -1
  156. package/lib/components/list.js +0 -314
  157. package/lib/components/list.ts +0 -423
  158. package/lib/components/loading.d.ts +0 -25
  159. package/lib/components/loading.d.ts.map +0 -1
  160. package/lib/components/loading.js +0 -76
  161. package/lib/components/loading.ts +0 -104
  162. package/lib/components/menu.d.ts +0 -38
  163. package/lib/components/menu.d.ts.map +0 -1
  164. package/lib/components/menu.js +0 -205
  165. package/lib/components/menu.ts +0 -279
  166. package/lib/components/modal.d.ts +0 -97
  167. package/lib/components/modal.d.ts.map +0 -1
  168. package/lib/components/modal.js +0 -463
  169. package/lib/components/modal.ts +0 -576
  170. package/lib/components/nav.d.ts +0 -46
  171. package/lib/components/nav.d.ts.map +0 -1
  172. package/lib/components/nav.js +0 -193
  173. package/lib/components/nav.ts +0 -261
  174. package/lib/components/paragraph.d.ts +0 -30
  175. package/lib/components/paragraph.d.ts.map +0 -1
  176. package/lib/components/paragraph.js +0 -93
  177. package/lib/components/paragraph.ts +0 -123
  178. package/lib/components/pen.d.ts +0 -125
  179. package/lib/components/pen.d.ts.map +0 -1
  180. package/lib/components/pen.js +0 -443
  181. package/lib/components/pen.ts +0 -567
  182. package/lib/components/progress.d.ts +0 -40
  183. package/lib/components/progress.d.ts.map +0 -1
  184. package/lib/components/progress.js +0 -116
  185. package/lib/components/progress.ts +0 -163
  186. package/lib/components/radio.d.ts +0 -43
  187. package/lib/components/radio.d.ts.map +0 -1
  188. package/lib/components/radio.js +0 -226
  189. package/lib/components/radio.ts +0 -303
  190. package/lib/components/registry.d.ts +0 -34
  191. package/lib/components/registry.d.ts.map +0 -1
  192. package/lib/components/registry.js +0 -163
  193. package/lib/components/registry.ts +0 -193
  194. package/lib/components/req.d.ts +0 -155
  195. package/lib/components/req.d.ts.map +0 -1
  196. package/lib/components/req.js +0 -253
  197. package/lib/components/req.ts +0 -303
  198. package/lib/components/script.d.ts +0 -14
  199. package/lib/components/script.d.ts.map +0 -1
  200. package/lib/components/script.js +0 -33
  201. package/lib/components/script.ts +0 -41
  202. package/lib/components/select.d.ts +0 -42
  203. package/lib/components/select.d.ts.map +0 -1
  204. package/lib/components/select.js +0 -209
  205. package/lib/components/select.ts +0 -281
  206. package/lib/components/sidebar.d.ts +0 -59
  207. package/lib/components/sidebar.d.ts.map +0 -1
  208. package/lib/components/sidebar.js +0 -298
  209. package/lib/components/sidebar.ts +0 -395
  210. package/lib/components/stack/BaseStack.d.ts +0 -65
  211. package/lib/components/stack/BaseStack.d.ts.map +0 -1
  212. package/lib/components/stack/BaseStack.js +0 -274
  213. package/lib/components/stack/BaseStack.ts +0 -328
  214. package/lib/components/stack/HStack.d.ts +0 -18
  215. package/lib/components/stack/HStack.d.ts.map +0 -1
  216. package/lib/components/stack/HStack.js +0 -22
  217. package/lib/components/stack/HStack.ts +0 -25
  218. package/lib/components/stack/VStack.d.ts +0 -19
  219. package/lib/components/stack/VStack.d.ts.map +0 -1
  220. package/lib/components/stack/VStack.js +0 -23
  221. package/lib/components/stack/VStack.ts +0 -26
  222. package/lib/components/stack/ZStack.d.ts +0 -18
  223. package/lib/components/stack/ZStack.d.ts.map +0 -1
  224. package/lib/components/stack/ZStack.js +0 -22
  225. package/lib/components/stack/ZStack.ts +0 -25
  226. package/lib/components/style.d.ts +0 -14
  227. package/lib/components/style.d.ts.map +0 -1
  228. package/lib/components/style.js +0 -33
  229. package/lib/components/style.ts +0 -41
  230. package/lib/components/switch.d.ts +0 -34
  231. package/lib/components/switch.d.ts.map +0 -1
  232. package/lib/components/switch.js +0 -209
  233. package/lib/components/switch.ts +0 -272
  234. package/lib/components/table.d.ts +0 -137
  235. package/lib/components/table.d.ts.map +0 -1
  236. package/lib/components/table.js +0 -1019
  237. package/lib/components/table.ts +0 -1225
  238. package/lib/components/tabs.d.ts +0 -53
  239. package/lib/components/tabs.d.ts.map +0 -1
  240. package/lib/components/tabs.js +0 -275
  241. package/lib/components/tabs.ts +0 -349
  242. package/lib/components/theme-toggle.d.ts +0 -45
  243. package/lib/components/theme-toggle.d.ts.map +0 -1
  244. package/lib/components/theme-toggle.js +0 -218
  245. package/lib/components/theme-toggle.ts +0 -297
  246. package/lib/components/tooltip.d.ts +0 -31
  247. package/lib/components/tooltip.d.ts.map +0 -1
  248. package/lib/components/tooltip.js +0 -112
  249. package/lib/components/tooltip.ts +0 -148
  250. package/lib/components/watcher.d.ts +0 -195
  251. package/lib/components/watcher.d.ts.map +0 -1
  252. package/lib/components/watcher.js +0 -241
  253. package/lib/components/watcher.ts +0 -261
  254. package/lib/components/write.d.ts +0 -107
  255. package/lib/components/write.d.ts.map +0 -1
  256. package/lib/components/write.js +0 -222
  257. package/lib/components/write.ts +0 -272
  258. package/lib/data/DataPipeline.d.ts +0 -113
  259. package/lib/data/DataPipeline.d.ts.map +0 -1
  260. package/lib/data/DataPipeline.js +0 -359
  261. package/lib/data/DataPipeline.ts +0 -452
  262. package/lib/facades/dataframe.jux +0 -0
  263. package/lib/globals.d.ts +0 -21
  264. package/lib/reactivity/state.d.ts +0 -36
  265. package/lib/reactivity/state.d.ts.map +0 -1
  266. package/lib/reactivity/state.js +0 -67
  267. package/lib/reactivity/state.ts +0 -78
  268. package/lib/storage/DataFrame.d.ts +0 -284
  269. package/lib/storage/DataFrame.d.ts.map +0 -1
  270. package/lib/storage/DataFrame.js +0 -1022
  271. package/lib/storage/DataFrame.ts +0 -1195
  272. package/lib/storage/DataFrameSource.d.ts +0 -158
  273. package/lib/storage/DataFrameSource.d.ts.map +0 -1
  274. package/lib/storage/DataFrameSource.js +0 -409
  275. package/lib/storage/DataFrameSource.ts +0 -556
  276. package/lib/storage/FileStorage.d.ts +0 -53
  277. package/lib/storage/FileStorage.d.ts.map +0 -1
  278. package/lib/storage/FileStorage.js +0 -80
  279. package/lib/storage/FileStorage.ts +0 -95
  280. package/lib/storage/IndexedDBDriver.d.ts +0 -75
  281. package/lib/storage/IndexedDBDriver.d.ts.map +0 -1
  282. package/lib/storage/IndexedDBDriver.js +0 -177
  283. package/lib/storage/IndexedDBDriver.ts +0 -226
  284. package/lib/storage/TabularDriver.d.ts +0 -118
  285. package/lib/storage/TabularDriver.d.ts.map +0 -1
  286. package/lib/storage/TabularDriver.js +0 -731
  287. package/lib/storage/TabularDriver.ts +0 -874
  288. package/lib/utils/codeparser.d.ts +0 -29
  289. package/lib/utils/codeparser.d.ts.map +0 -1
  290. package/lib/utils/codeparser.js +0 -409
  291. package/lib/utils/fetch.d.ts +0 -176
  292. package/lib/utils/fetch.d.ts.map +0 -1
  293. package/lib/utils/fetch.js +0 -427
  294. package/lib/utils/formatId.d.ts +0 -16
  295. package/lib/utils/formatId.d.ts.map +0 -1
  296. package/lib/utils/formatId.js +0 -27
  297. package/lib/utils/path-resolver.js +0 -23
@@ -1,123 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
-
3
- // Event definitions
4
- const TRIGGER_EVENTS = [] as const;
5
- const CALLBACK_EVENTS = [] as const;
6
-
7
- export interface ParagraphOptions {
8
- content?: string;
9
- class?: string;
10
- style?: string;
11
- }
12
-
13
- type ParagraphState = {
14
- content: string;
15
- class: string;
16
- style: string;
17
- };
18
-
19
- export class Paragraph extends BaseComponent<ParagraphState> {
20
- constructor(id: string, options: ParagraphOptions = {}) {
21
- super(id, {
22
- content: options.content ?? '',
23
- class: options.class ?? '',
24
- style: options.style ?? ''
25
- });
26
- }
27
-
28
- protected getTriggerEvents(): readonly string[] {
29
- return TRIGGER_EVENTS;
30
- }
31
-
32
- protected getCallbackEvents(): readonly string[] {
33
- return CALLBACK_EVENTS;
34
- }
35
-
36
- /**
37
- * ✅ Reactive update implementation for Paragraph
38
- * Called automatically when this.state[prop] changes via Proxy
39
- */
40
- update(prop: string, value: any): void {
41
- const el = document.getElementById(this._id);
42
- if (!el) return;
43
-
44
- switch (prop) {
45
- case 'content':
46
- el.textContent = value;
47
- break;
48
-
49
- default:
50
- super.update(prop, value);
51
- break;
52
- }
53
- }
54
-
55
- /* ═════════════════════════════════════════════════════════════════
56
- * FLUENT API
57
- * ═════════════════════════════════════════════════════════════════ */
58
-
59
- // ✅ Inherited from BaseComponent:
60
- // - style(), class()
61
- // - bind(), sync(), renderTo()
62
- // - All other base methods
63
-
64
- content(value: string): this {
65
- this.state.content = value; // ✅ Triggers update()
66
- return this;
67
- }
68
-
69
- /**
70
- * Alias for content() - more intuitive naming
71
- */
72
- text(value: string): this {
73
- return this.content(value);
74
- }
75
-
76
- /* ═════════════════════════════════════════════════════════════════
77
- * RENDER
78
- * ═════════════════════════════════════════════════════════════════ */
79
-
80
- render(targetId?: string | HTMLElement | BaseComponent<any>): this {
81
- const container = this._setupContainer(targetId);
82
-
83
- const { content, style, class: className } = this.state;
84
-
85
- const paragraph = document.createElement('p');
86
- paragraph.className = 'jux-paragraph';
87
- paragraph.id = this._id;
88
- paragraph.textContent = content;
89
- if (className) paragraph.className += ` ${className}`;
90
- if (style) paragraph.setAttribute('style', style);
91
-
92
- this._wireStandardEvents(paragraph);
93
-
94
- // Wire sync bindings
95
- this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
96
- if (property === 'content') {
97
- const transform = toComponent || ((v: any) => String(v));
98
-
99
- stateObj.subscribe((val: any) => {
100
- const transformed = transform(val);
101
- paragraph.textContent = transformed;
102
- this.state.content = transformed;
103
- });
104
- }
105
- else if (property === 'class') {
106
- const transform = toComponent || ((v: any) => String(v));
107
-
108
- stateObj.subscribe((val: any) => {
109
- const transformed = transform(val);
110
- paragraph.className = `jux-paragraph ${transformed}`;
111
- this.state.class = transformed;
112
- });
113
- }
114
- });
115
-
116
- container.appendChild(paragraph);
117
- return this;
118
- }
119
- }
120
-
121
- export function paragraph(id: string, options: ParagraphOptions = {}): Paragraph {
122
- return new Paragraph(id, options);
123
- }
@@ -1,125 +0,0 @@
1
- import { BaseComponent, BaseState } from './base/BaseComponent.js';
2
- export interface PenShape {
3
- id: string;
4
- type: 'line' | 'rectangle' | 'circle' | 'text';
5
- x: number;
6
- y: number;
7
- width?: number;
8
- height?: number;
9
- radius?: number;
10
- text?: string;
11
- color?: string;
12
- fillColor?: string;
13
- strokeWidth?: number;
14
- connectedTo?: string[];
15
- }
16
- export interface PenConnection {
17
- from: string;
18
- to: string;
19
- color?: string;
20
- strokeWidth?: number;
21
- dashed?: boolean;
22
- }
23
- export interface PenOptions {
24
- width?: number | string;
25
- height?: number | string;
26
- backgroundColor?: string;
27
- backgroundImage?: string;
28
- border?: string;
29
- text?: string;
30
- radius?: number;
31
- gridEnabled?: boolean;
32
- gridSize?: number;
33
- gridColor?: string;
34
- style?: string;
35
- class?: string;
36
- }
37
- type PenState = BaseState & {
38
- width: number | string;
39
- height: number | string;
40
- backgroundColor: string;
41
- backgroundImage: string;
42
- border: string;
43
- text: string;
44
- radius: number;
45
- gridEnabled: boolean;
46
- gridSize: number;
47
- gridColor: string;
48
- shapes: PenShape[];
49
- connections: PenConnection[];
50
- };
51
- export declare class Pen extends BaseComponent<PenState> {
52
- private _canvas;
53
- private _ctx;
54
- private _animationFrame?;
55
- constructor(id: string, options?: PenOptions);
56
- protected getTriggerEvents(): readonly string[];
57
- protected getCallbackEvents(): readonly string[];
58
- update(prop: string, value: any): void;
59
- width(value: number | string): this;
60
- height(value: number | string): this;
61
- backgroundColor(value: string): this;
62
- backgroundImage(value: string): this;
63
- border(value: string): this;
64
- text(value: string): this;
65
- radius(value: number): this;
66
- grid(enabled: boolean, size?: number, color?: string): this;
67
- /**
68
- * Add a line shape
69
- */
70
- drawLine(x1: number, y1: number, x2: number, y2: number, options?: Partial<PenShape>): this;
71
- /**
72
- * Add a rectangle shape
73
- */
74
- drawRect(x: number, y: number, width: number, height: number, options?: Partial<PenShape>): this;
75
- /**
76
- * Add a circle shape
77
- */
78
- drawCircle(x: number, y: number, radius: number, options?: Partial<PenShape>): this;
79
- /**
80
- * Add text to canvas
81
- */
82
- drawText(x: number, y: number, text: string, options?: Partial<PenShape>): this;
83
- /**
84
- * Connect two shapes with a line
85
- */
86
- connect(fromId: string, toId: string, options?: Partial<PenConnection>): this;
87
- /**
88
- * Remove a shape by ID
89
- */
90
- removeShape(id: string): this;
91
- /**
92
- * Clear all shapes and connections
93
- */
94
- clear(): this;
95
- /**
96
- * Get shape by ID
97
- */
98
- getShape(id: string): PenShape | undefined;
99
- /**
100
- * Get all shapes
101
- */
102
- getShapes(): PenShape[];
103
- /**
104
- * Export canvas as data URL
105
- */
106
- toDataURL(type?: string): string;
107
- /**
108
- * Download canvas as image
109
- */
110
- download(filename?: string): this;
111
- private _updateCanvasSize;
112
- private _redraw;
113
- private _drawContent;
114
- private _drawGrid;
115
- private _drawShape;
116
- private _drawConnection;
117
- render(targetId?: string | HTMLElement | BaseComponent<any>): this;
118
- /**
119
- * Cleanup on destroy
120
- */
121
- destroy(): void;
122
- }
123
- export declare function pen(id: string, options?: PenOptions): Pen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GAAE,MAAoB,GAAG,MAAM;IAI7C;;OAEG;IACH,QAAQ,CAAC,QAAQ,GAAE,MAA0B,GAAG,IAAI;IAapD,OAAO,CAAC,iBAAiB;IASzB,OAAO,CAAC,OAAO;IA2Bf,OAAO,CAAC,YAAY;IAwBpB,OAAO,CAAC,SAAS;IA0BjB,OAAO,CAAC,UAAU;IAwClB,OAAO,CAAC,eAAe;IAmCvB,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,IAAI;IA2ClE;;OAEG;IACH,OAAO,IAAI,IAAI;CAMlB;AAED,wBAAgB,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,UAAe,GAAG,GAAG,CAE7D"}
@@ -1,443 +0,0 @@
1
- import { BaseComponent } from './base/BaseComponent.js';
2
- // Event definitions
3
- const TRIGGER_EVENTS = [];
4
- const CALLBACK_EVENTS = ['draw', 'shapeAdd', 'shapeRemove', 'connectionAdd'];
5
- export class Pen extends BaseComponent {
6
- constructor(id, options = {}) {
7
- super(id, {
8
- width: options.width ?? '100%',
9
- height: options.height ?? 400,
10
- backgroundColor: options.backgroundColor ?? '#ffffff',
11
- backgroundImage: options.backgroundImage ?? '',
12
- border: options.border ?? '1px solid #e5e7eb',
13
- text: options.text ?? '',
14
- radius: options.radius ?? 0,
15
- gridEnabled: options.gridEnabled ?? false,
16
- gridSize: options.gridSize ?? 20,
17
- gridColor: options.gridColor ?? '#f0f0f0',
18
- shapes: [],
19
- connections: [],
20
- style: options.style ?? '',
21
- class: options.class ?? ''
22
- });
23
- this._canvas = null;
24
- this._ctx = null;
25
- }
26
- getTriggerEvents() {
27
- return TRIGGER_EVENTS;
28
- }
29
- getCallbackEvents() {
30
- return CALLBACK_EVENTS;
31
- }
32
- /* ═════════════════════════════════════════════════════════════════
33
- * REACTIVE UPDATE
34
- * ═════════════════════════════════════════════════════════════════ */
35
- update(prop, value) {
36
- super.update(prop, value);
37
- if (!this._canvas || !this._ctx)
38
- return;
39
- switch (prop) {
40
- case 'backgroundColor':
41
- this._redraw();
42
- break;
43
- case 'backgroundImage':
44
- this._redraw();
45
- break;
46
- case 'text':
47
- this._redraw();
48
- break;
49
- case 'gridEnabled':
50
- case 'gridSize':
51
- case 'gridColor':
52
- this._redraw();
53
- break;
54
- case 'shapes':
55
- case 'connections':
56
- this._redraw();
57
- break;
58
- }
59
- }
60
- /* ═════════════════════════════════════════════════════════════════
61
- * FLUENT API
62
- * ═════════════════════════════════════════════════════════════════ */
63
- width(value) {
64
- this.state.width = value;
65
- if (this._canvas) {
66
- this._canvas.style.width = typeof value === 'number' ? `${value}px` : value;
67
- this._updateCanvasSize();
68
- }
69
- return this;
70
- }
71
- height(value) {
72
- this.state.height = value;
73
- if (this._canvas) {
74
- this._canvas.style.height = typeof value === 'number' ? `${value}px` : value;
75
- this._updateCanvasSize();
76
- }
77
- return this;
78
- }
79
- backgroundColor(value) {
80
- this.state.backgroundColor = value;
81
- return this;
82
- }
83
- backgroundImage(value) {
84
- this.state.backgroundImage = value;
85
- return this;
86
- }
87
- border(value) {
88
- this.state.border = value;
89
- if (this._canvas) {
90
- this._canvas.style.border = value;
91
- }
92
- return this;
93
- }
94
- text(value) {
95
- this.state.text = value;
96
- return this;
97
- }
98
- radius(value) {
99
- this.state.radius = value;
100
- if (this._canvas) {
101
- this._canvas.style.borderRadius = `${value}px`;
102
- }
103
- return this;
104
- }
105
- grid(enabled, size, color) {
106
- this.state.gridEnabled = enabled;
107
- if (size !== undefined)
108
- this.state.gridSize = size;
109
- if (color !== undefined)
110
- this.state.gridColor = color;
111
- return this;
112
- }
113
- /* ═════════════════════════════════════════════════════════════════
114
- * DRAWING API
115
- * ═════════════════════════════════════════════════════════════════ */
116
- /**
117
- * Add a line shape
118
- */
119
- drawLine(x1, y1, x2, y2, options = {}) {
120
- const shape = {
121
- id: options.id || `line-${Date.now()}-${Math.random()}`,
122
- type: 'line',
123
- x: x1,
124
- y: y1,
125
- width: x2 - x1,
126
- height: y2 - y1,
127
- color: options.color || '#000000',
128
- strokeWidth: options.strokeWidth || 2,
129
- connectedTo: options.connectedTo || []
130
- };
131
- this.state.shapes = [...this.state.shapes, shape];
132
- this._triggerCallback('shapeAdd', shape);
133
- return this;
134
- }
135
- /**
136
- * Add a rectangle shape
137
- */
138
- drawRect(x, y, width, height, options = {}) {
139
- const shape = {
140
- id: options.id || `rect-${Date.now()}-${Math.random()}`,
141
- type: 'rectangle',
142
- x,
143
- y,
144
- width,
145
- height,
146
- color: options.color || '#000000',
147
- fillColor: options.fillColor,
148
- strokeWidth: options.strokeWidth || 2,
149
- connectedTo: options.connectedTo || []
150
- };
151
- this.state.shapes = [...this.state.shapes, shape];
152
- this._triggerCallback('shapeAdd', shape);
153
- return this;
154
- }
155
- /**
156
- * Add a circle shape
157
- */
158
- drawCircle(x, y, radius, options = {}) {
159
- const shape = {
160
- id: options.id || `circle-${Date.now()}-${Math.random()}`,
161
- type: 'circle',
162
- x,
163
- y,
164
- radius,
165
- color: options.color || '#000000',
166
- fillColor: options.fillColor,
167
- strokeWidth: options.strokeWidth || 2,
168
- connectedTo: options.connectedTo || []
169
- };
170
- this.state.shapes = [...this.state.shapes, shape];
171
- this._triggerCallback('shapeAdd', shape);
172
- return this;
173
- }
174
- /**
175
- * Add text to canvas
176
- */
177
- drawText(x, y, text, options = {}) {
178
- const shape = {
179
- id: options.id || `text-${Date.now()}-${Math.random()}`,
180
- type: 'text',
181
- x,
182
- y,
183
- text,
184
- color: options.color || '#000000',
185
- connectedTo: options.connectedTo || []
186
- };
187
- this.state.shapes = [...this.state.shapes, shape];
188
- this._triggerCallback('shapeAdd', shape);
189
- return this;
190
- }
191
- /**
192
- * Connect two shapes with a line
193
- */
194
- connect(fromId, toId, options = {}) {
195
- const connection = {
196
- from: fromId,
197
- to: toId,
198
- color: options.color || '#666666',
199
- strokeWidth: options.strokeWidth || 1,
200
- dashed: options.dashed || false
201
- };
202
- this.state.connections = [...this.state.connections, connection];
203
- // Update connected shapes
204
- const fromShape = this.state.shapes.find(s => s.id === fromId);
205
- if (fromShape && !fromShape.connectedTo?.includes(toId)) {
206
- fromShape.connectedTo = [...(fromShape.connectedTo || []), toId];
207
- }
208
- this._triggerCallback('connectionAdd', connection);
209
- return this;
210
- }
211
- /**
212
- * Remove a shape by ID
213
- */
214
- removeShape(id) {
215
- this.state.shapes = this.state.shapes.filter(s => s.id !== id);
216
- this.state.connections = this.state.connections.filter(c => c.from !== id && c.to !== id);
217
- this._triggerCallback('shapeRemove', id);
218
- return this;
219
- }
220
- /**
221
- * Clear all shapes and connections
222
- */
223
- clear() {
224
- this.state.shapes = [];
225
- this.state.connections = [];
226
- return this;
227
- }
228
- /**
229
- * Get shape by ID
230
- */
231
- getShape(id) {
232
- return this.state.shapes.find(s => s.id === id);
233
- }
234
- /**
235
- * Get all shapes
236
- */
237
- getShapes() {
238
- return this.state.shapes;
239
- }
240
- /**
241
- * Export canvas as data URL
242
- */
243
- toDataURL(type = 'image/png') {
244
- return this._canvas?.toDataURL(type) || '';
245
- }
246
- /**
247
- * Download canvas as image
248
- */
249
- download(filename = 'pen-drawing.png') {
250
- const dataURL = this.toDataURL();
251
- const link = document.createElement('a');
252
- link.download = filename;
253
- link.href = dataURL;
254
- link.click();
255
- return this;
256
- }
257
- /* ═════════════════════════════════════════════════════════════════
258
- * PRIVATE RENDERING
259
- * ═════════════════════════════════════════════════════════════════ */
260
- _updateCanvasSize() {
261
- if (!this._canvas)
262
- return;
263
- const rect = this._canvas.getBoundingClientRect();
264
- this._canvas.width = rect.width;
265
- this._canvas.height = rect.height;
266
- this._redraw();
267
- }
268
- _redraw() {
269
- if (!this._ctx || !this._canvas)
270
- return;
271
- const { width, height } = this._canvas;
272
- // Clear canvas
273
- this._ctx.clearRect(0, 0, width, height);
274
- // Draw background
275
- if (this.state.backgroundColor) {
276
- this._ctx.fillStyle = this.state.backgroundColor;
277
- this._ctx.fillRect(0, 0, width, height);
278
- }
279
- // Draw background image
280
- if (this.state.backgroundImage) {
281
- const img = new Image();
282
- img.src = this.state.backgroundImage;
283
- img.onload = () => {
284
- this._ctx?.drawImage(img, 0, 0, width, height);
285
- this._drawContent();
286
- };
287
- }
288
- else {
289
- this._drawContent();
290
- }
291
- }
292
- _drawContent() {
293
- if (!this._ctx || !this._canvas)
294
- return;
295
- // Draw grid
296
- if (this.state.gridEnabled) {
297
- this._drawGrid();
298
- }
299
- // Draw connections first (under shapes)
300
- this.state.connections.forEach(conn => this._drawConnection(conn));
301
- // Draw shapes
302
- this.state.shapes.forEach(shape => this._drawShape(shape));
303
- // Draw text overlay
304
- if (this.state.text) {
305
- this._ctx.fillStyle = '#000000';
306
- this._ctx.font = '16px sans-serif';
307
- this._ctx.fillText(this.state.text, 10, 30);
308
- }
309
- this._triggerCallback('draw', { shapes: this.state.shapes, connections: this.state.connections });
310
- }
311
- _drawGrid() {
312
- if (!this._ctx || !this._canvas)
313
- return;
314
- const { width, height } = this._canvas;
315
- const { gridSize, gridColor } = this.state;
316
- this._ctx.strokeStyle = gridColor;
317
- this._ctx.lineWidth = 1;
318
- // Vertical lines
319
- for (let x = 0; x <= width; x += gridSize) {
320
- this._ctx.beginPath();
321
- this._ctx.moveTo(x, 0);
322
- this._ctx.lineTo(x, height);
323
- this._ctx.stroke();
324
- }
325
- // Horizontal lines
326
- for (let y = 0; y <= height; y += gridSize) {
327
- this._ctx.beginPath();
328
- this._ctx.moveTo(0, y);
329
- this._ctx.lineTo(width, y);
330
- this._ctx.stroke();
331
- }
332
- }
333
- _drawShape(shape) {
334
- if (!this._ctx)
335
- return;
336
- this._ctx.strokeStyle = shape.color || '#000000';
337
- this._ctx.lineWidth = shape.strokeWidth || 2;
338
- switch (shape.type) {
339
- case 'line':
340
- this._ctx.beginPath();
341
- this._ctx.moveTo(shape.x, shape.y);
342
- this._ctx.lineTo(shape.x + (shape.width || 0), shape.y + (shape.height || 0));
343
- this._ctx.stroke();
344
- break;
345
- case 'rectangle':
346
- if (shape.fillColor) {
347
- this._ctx.fillStyle = shape.fillColor;
348
- this._ctx.fillRect(shape.x, shape.y, shape.width || 0, shape.height || 0);
349
- }
350
- this._ctx.strokeRect(shape.x, shape.y, shape.width || 0, shape.height || 0);
351
- break;
352
- case 'circle':
353
- this._ctx.beginPath();
354
- this._ctx.arc(shape.x, shape.y, shape.radius || 0, 0, Math.PI * 2);
355
- if (shape.fillColor) {
356
- this._ctx.fillStyle = shape.fillColor;
357
- this._ctx.fill();
358
- }
359
- this._ctx.stroke();
360
- break;
361
- case 'text':
362
- this._ctx.fillStyle = shape.color || '#000000';
363
- this._ctx.font = '14px sans-serif';
364
- this._ctx.fillText(shape.text || '', shape.x, shape.y);
365
- break;
366
- }
367
- }
368
- _drawConnection(conn) {
369
- if (!this._ctx)
370
- return;
371
- const fromShape = this.state.shapes.find(s => s.id === conn.from);
372
- const toShape = this.state.shapes.find(s => s.id === conn.to);
373
- if (!fromShape || !toShape)
374
- return;
375
- // Calculate center points
376
- const fromX = fromShape.x + (fromShape.width || fromShape.radius || 0) / 2;
377
- const fromY = fromShape.y + (fromShape.height || fromShape.radius || 0) / 2;
378
- const toX = toShape.x + (toShape.width || toShape.radius || 0) / 2;
379
- const toY = toShape.y + (toShape.height || toShape.radius || 0) / 2;
380
- this._ctx.strokeStyle = conn.color || '#666666';
381
- this._ctx.lineWidth = conn.strokeWidth || 1;
382
- if (conn.dashed) {
383
- this._ctx.setLineDash([5, 5]);
384
- }
385
- this._ctx.beginPath();
386
- this._ctx.moveTo(fromX, fromY);
387
- this._ctx.lineTo(toX, toY);
388
- this._ctx.stroke();
389
- if (conn.dashed) {
390
- this._ctx.setLineDash([]);
391
- }
392
- }
393
- /* ═════════════════════════════════════════════════════════════════
394
- * RENDER
395
- * ═════════════════════════════════════════════════════════════════ */
396
- render(targetId) {
397
- const container = this._setupContainer(targetId);
398
- const { width, height, backgroundColor, border, radius, style, class: className } = this.state;
399
- const wrapper = document.createElement('div');
400
- wrapper.className = 'jux-pen';
401
- wrapper.id = `${this._id}-wrapper`;
402
- if (className)
403
- wrapper.className += ` ${className}`;
404
- if (style)
405
- wrapper.setAttribute('style', style);
406
- const canvas = document.createElement('canvas');
407
- canvas.id = this._id;
408
- canvas.className = 'jux-pen-canvas';
409
- canvas.style.width = typeof width === 'number' ? `${width}px` : width;
410
- canvas.style.height = typeof height === 'number' ? `${height}px` : height;
411
- canvas.style.backgroundColor = backgroundColor;
412
- canvas.style.border = border;
413
- canvas.style.borderRadius = `${radius}px`;
414
- canvas.style.display = 'block';
415
- this._canvas = canvas;
416
- this._ctx = canvas.getContext('2d');
417
- // Set initial canvas size
418
- requestAnimationFrame(() => {
419
- this._updateCanvasSize();
420
- });
421
- // Handle window resize
422
- window.addEventListener('resize', () => {
423
- this._updateCanvasSize();
424
- });
425
- this._wireStandardEvents(wrapper);
426
- this._wireAllSyncs();
427
- wrapper.appendChild(canvas);
428
- container.appendChild(wrapper);
429
- return this;
430
- }
431
- /**
432
- * Cleanup on destroy
433
- */
434
- destroy() {
435
- if (this._animationFrame) {
436
- cancelAnimationFrame(this._animationFrame);
437
- }
438
- this.remove();
439
- }
440
- }
441
- export function pen(id, options = {}) {
442
- return new Pen(id, options);
443
- }