juxscript 1.0.20 → 1.0.21

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 (76) hide show
  1. package/bin/cli.js +121 -72
  2. package/lib/components/alert.ts +143 -92
  3. package/lib/components/badge.ts +93 -94
  4. package/lib/components/base/BaseComponent.ts +397 -0
  5. package/lib/components/base/FormInput.ts +322 -0
  6. package/lib/components/button.ts +40 -131
  7. package/lib/components/card.ts +57 -79
  8. package/lib/components/charts/areachart.ts +315 -0
  9. package/lib/components/charts/barchart.ts +421 -0
  10. package/lib/components/charts/doughnutchart.ts +263 -0
  11. package/lib/components/charts/lib/BaseChart.ts +402 -0
  12. package/lib/components/{chart-types.ts → charts/lib/chart-types.ts} +1 -1
  13. package/lib/components/{chart-utils.ts → charts/lib/chart-utils.ts} +1 -1
  14. package/lib/components/{chart.ts → charts/lib/chart.ts} +3 -3
  15. package/lib/components/checkbox.ts +255 -204
  16. package/lib/components/code.ts +31 -78
  17. package/lib/components/container.ts +113 -130
  18. package/lib/components/data.ts +37 -5
  19. package/lib/components/datepicker.ts +180 -147
  20. package/lib/components/dialog.ts +218 -221
  21. package/lib/components/divider.ts +63 -87
  22. package/lib/components/docs-data.json +498 -2404
  23. package/lib/components/dropdown.ts +191 -236
  24. package/lib/components/element.ts +196 -145
  25. package/lib/components/fileupload.ts +253 -167
  26. package/lib/components/guard.ts +92 -0
  27. package/lib/components/heading.ts +31 -97
  28. package/lib/components/helpers.ts +13 -6
  29. package/lib/components/hero.ts +51 -114
  30. package/lib/components/icon.ts +33 -120
  31. package/lib/components/icons.ts +2 -1
  32. package/lib/components/include.ts +76 -3
  33. package/lib/components/input.ts +155 -407
  34. package/lib/components/kpicard.ts +16 -16
  35. package/lib/components/list.ts +358 -261
  36. package/lib/components/loading.ts +142 -211
  37. package/lib/components/menu.ts +63 -152
  38. package/lib/components/modal.ts +42 -129
  39. package/lib/components/nav.ts +79 -101
  40. package/lib/components/paragraph.ts +38 -102
  41. package/lib/components/progress.ts +108 -166
  42. package/lib/components/radio.ts +283 -234
  43. package/lib/components/script.ts +19 -87
  44. package/lib/components/select.ts +189 -199
  45. package/lib/components/sidebar.ts +110 -141
  46. package/lib/components/style.ts +19 -82
  47. package/lib/components/switch.ts +254 -183
  48. package/lib/components/table.ts +1078 -208
  49. package/lib/components/tabs.ts +42 -106
  50. package/lib/components/theme-toggle.ts +73 -165
  51. package/lib/components/tooltip.ts +85 -316
  52. package/lib/components/write.ts +108 -127
  53. package/lib/jux.ts +67 -41
  54. package/machinery/build.js +466 -0
  55. package/machinery/compiler.js +354 -105
  56. package/machinery/server.js +23 -100
  57. package/machinery/watcher.js +153 -130
  58. package/package.json +1 -1
  59. package/presets/base.css +1166 -0
  60. package/presets/notion.css +2 -1975
  61. package/lib/adapters/base-adapter.js +0 -35
  62. package/lib/adapters/index.js +0 -33
  63. package/lib/adapters/mysql-adapter.js +0 -65
  64. package/lib/adapters/postgres-adapter.js +0 -70
  65. package/lib/adapters/sqlite-adapter.js +0 -56
  66. package/lib/components/areachart.ts +0 -1128
  67. package/lib/components/areachartsmooth.ts +0 -1380
  68. package/lib/components/barchart.ts +0 -1322
  69. package/lib/components/doughnutchart.ts +0 -1259
  70. package/lib/components/footer.ts +0 -165
  71. package/lib/components/header.ts +0 -187
  72. package/lib/components/layout.ts +0 -239
  73. package/lib/components/main.ts +0 -137
  74. package/lib/layouts/default.jux +0 -8
  75. package/lib/layouts/figma.jux +0 -0
  76. /package/lib/{themes → components/charts/lib}/charts.js +0 -0
@@ -1,45 +1,44 @@
1
- import { getOrCreateContainer } from './helpers.js';
2
- import { State } from '../reactivity/state.js';
1
+ import { BaseComponent } from './base/BaseComponent.js';
2
+
3
+ // Event definitions
4
+ const TRIGGER_EVENTS = [] as const;
5
+ const CALLBACK_EVENTS = [] as const;
3
6
 
4
7
  export interface DividerOptions {
5
8
  text?: string;
6
- orientation?: 'horizontal' | 'vertical';
9
+ variant?: 'default' | 'dashed' | 'dotted';
10
+ margin?: string;
7
11
  style?: string;
8
12
  class?: string;
9
13
  }
10
14
 
11
15
  type DividerState = {
12
16
  text: string;
13
- orientation: string;
17
+ variant: string;
18
+ margin: string;
14
19
  style: string;
15
20
  class: string;
21
+ orientation: string;
16
22
  };
17
23
 
18
- export class Divider {
19
- state: DividerState;
20
- container: HTMLElement | null = null;
21
- _id: string;
22
- id: string;
23
-
24
- // CRITICAL: Store bind/sync instructions for deferred wiring
25
- private _bindings: Array<{ event: string, handler: Function }> = [];
26
- private _syncBindings: Array<{
27
- property: string,
28
- stateObj: State<any>,
29
- toState?: Function,
30
- toComponent?: Function
31
- }> = [];
32
-
33
- constructor(id: string, options: DividerOptions = {}) {
34
- this._id = id;
35
- this.id = id;
36
-
37
- this.state = {
24
+ export class Divider extends BaseComponent<DividerState> {
25
+ constructor(id: string = `divider-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, options: DividerOptions = {}) {
26
+ super(id, {
38
27
  text: options.text ?? '',
39
- orientation: options.orientation ?? 'horizontal',
28
+ variant: options.variant ?? 'default',
29
+ margin: options.margin ?? '1rem 0',
40
30
  style: options.style ?? '',
41
- class: options.class ?? ''
42
- };
31
+ class: options.class ?? '',
32
+ orientation: 'horizontal'
33
+ });
34
+ }
35
+
36
+ protected getTriggerEvents(): readonly string[] {
37
+ return TRIGGER_EVENTS;
38
+ }
39
+
40
+ protected getCallbackEvents(): readonly string[] {
41
+ return CALLBACK_EVENTS;
43
42
  }
44
43
 
45
44
  text(value: string): this {
@@ -62,79 +61,29 @@ export class Divider {
62
61
  return this;
63
62
  }
64
63
 
65
- bind(event: string, handler: Function): this {
66
- this._bindings.push({ event, handler });
67
- return this;
68
- }
69
-
70
- sync(property: string, stateObj: State<any>, toState?: Function, toComponent?: Function): this {
71
- if (!stateObj || typeof stateObj.subscribe !== 'function') {
72
- throw new Error(`Divider.sync: Expected a State object for property "${property}"`);
73
- }
74
- this._syncBindings.push({ property, stateObj, toState, toComponent });
75
- return this;
76
- }
77
-
78
64
  render(targetId?: string): this {
79
- // === 1. SETUP: Get or create container ===
80
- let container: HTMLElement;
81
- if (targetId) {
82
- const target = document.querySelector(targetId);
83
- if (!target || !(target instanceof HTMLElement)) {
84
- throw new Error(`Divider: Target "${targetId}" not found`);
85
- }
86
- container = target;
87
- } else {
88
- container = getOrCreateContainer(this._id);
89
- }
90
- this.container = container;
65
+ const container = this._setupContainer(targetId);
91
66
 
92
- // === 2. PREPARE: Destructure state ===
93
- const { text, orientation, style, class: className } = this.state;
67
+ const { text, variant, margin, style, class: className } = this.state;
94
68
 
95
- // === 3. BUILD: Create DOM elements ===
96
69
  const divider = document.createElement('div');
97
- divider.className = `jux-divider jux-divider-${orientation}`;
70
+ divider.className = `jux-divider jux-divider-${variant}`;
98
71
  divider.id = this._id;
72
+ divider.style.margin = margin;
99
73
  if (className) divider.className += ` ${className}`;
100
- if (style) divider.setAttribute('style', style);
74
+ if (style) divider.setAttribute('style', `${divider.getAttribute('style')}; ${style}`);
101
75
 
102
76
  if (text) {
103
77
  const textEl = document.createElement('span');
104
78
  textEl.className = 'jux-divider-text';
105
79
  textEl.textContent = text;
106
80
  divider.appendChild(textEl);
107
- } else {
108
- const line = document.createElement('hr');
109
- line.className = 'jux-divider-line';
110
- divider.appendChild(line);
111
81
  }
112
82
 
113
- // === 4. WIRE: Attach event listeners and sync bindings ===
114
-
115
- // Wire custom bindings from .bind() calls
116
- this._bindings.forEach(({ event, handler }) => {
117
- divider.addEventListener(event, handler as EventListener);
118
- });
119
-
120
- // Wire sync bindings from .sync() calls
121
- this._syncBindings.forEach(({ property, stateObj, toState, toComponent }) => {
122
- if (property === 'text') {
123
- const transformToComponent = toComponent || ((v: any) => String(v));
124
-
125
- stateObj.subscribe((val: any) => {
126
- const transformed = transformToComponent(val);
127
- const textEl = divider.querySelector('.jux-divider-text');
128
- if (textEl) {
129
- textEl.textContent = transformed;
130
- }
131
- this.state.text = transformed;
132
- });
133
- }
134
- });
135
-
136
- // === 5. RENDER: Append to DOM and finalize ===
83
+ this._wireStandardEvents(divider);
137
84
  container.appendChild(divider);
85
+ this._injectDividerStyles();
86
+
138
87
  return this;
139
88
  }
140
89
 
@@ -144,8 +93,35 @@ export class Divider {
144
93
  }
145
94
  return this.render(`#${juxComponent._id}`);
146
95
  }
96
+
97
+ private _injectDividerStyles(): void {
98
+ if (document.getElementById('jux-divider-styles')) return;
99
+
100
+ const style = document.createElement('style');
101
+ style.id = 'jux-divider-styles';
102
+ style.textContent = `
103
+ .jux-divider {
104
+ display: flex;
105
+ align-items: center;
106
+ border-top: 1px solid #e0e0e0;
107
+ }
108
+ .jux-divider-dashed {
109
+ border-top-style: dashed;
110
+ }
111
+ .jux-divider-dotted {
112
+ border-top-style: dotted;
113
+ }
114
+ .jux-divider-text {
115
+ padding: 0 1rem;
116
+ background: white;
117
+ position: relative;
118
+ }
119
+ `;
120
+ document.head.appendChild(style);
121
+ }
147
122
  }
148
123
 
149
- export function divider(id: string, options: DividerOptions = {}): Divider {
150
- return new Divider(id, options);
124
+ // ID is now optional - auto-generated if not provided
125
+ export function divider(options: DividerOptions = {}): Divider {
126
+ return new Divider(undefined, options);
151
127
  }