juxscript 1.0.3 → 1.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.
Files changed (73) hide show
  1. package/README.md +37 -92
  2. package/bin/cli.js +57 -56
  3. package/lib/components/alert.ts +240 -0
  4. package/lib/components/app.ts +216 -82
  5. package/lib/components/badge.ts +164 -0
  6. package/lib/components/barchart.ts +1248 -0
  7. package/lib/components/button.ts +188 -53
  8. package/lib/components/card.ts +75 -61
  9. package/lib/components/chart.ts +17 -15
  10. package/lib/components/checkbox.ts +199 -0
  11. package/lib/components/code.ts +66 -152
  12. package/lib/components/container.ts +104 -208
  13. package/lib/components/data.ts +1 -3
  14. package/lib/components/datepicker.ts +226 -0
  15. package/lib/components/dialog.ts +258 -0
  16. package/lib/components/docs-data.json +1969 -423
  17. package/lib/components/dropdown.ts +244 -0
  18. package/lib/components/element.ts +271 -0
  19. package/lib/components/fileupload.ts +319 -0
  20. package/lib/components/footer.ts +37 -18
  21. package/lib/components/header.ts +53 -33
  22. package/lib/components/heading.ts +119 -0
  23. package/lib/components/helpers.ts +34 -0
  24. package/lib/components/hero.ts +57 -31
  25. package/lib/components/include.ts +292 -0
  26. package/lib/components/input.ts +508 -77
  27. package/lib/components/layout.ts +144 -18
  28. package/lib/components/list.ts +83 -74
  29. package/lib/components/loading.ts +263 -0
  30. package/lib/components/main.ts +43 -17
  31. package/lib/components/menu.ts +108 -24
  32. package/lib/components/modal.ts +50 -21
  33. package/lib/components/nav.ts +60 -18
  34. package/lib/components/paragraph.ts +111 -0
  35. package/lib/components/progress.ts +276 -0
  36. package/lib/components/radio.ts +236 -0
  37. package/lib/components/req.ts +300 -0
  38. package/lib/components/script.ts +33 -74
  39. package/lib/components/select.ts +280 -0
  40. package/lib/components/sidebar.ts +87 -37
  41. package/lib/components/style.ts +47 -70
  42. package/lib/components/switch.ts +261 -0
  43. package/lib/components/table.ts +47 -24
  44. package/lib/components/tabs.ts +105 -63
  45. package/lib/components/theme-toggle.ts +361 -0
  46. package/lib/components/token-calculator.ts +380 -0
  47. package/lib/components/tooltip.ts +244 -0
  48. package/lib/components/view.ts +36 -20
  49. package/lib/components/write.ts +284 -0
  50. package/lib/globals.d.ts +21 -0
  51. package/lib/jux.ts +178 -68
  52. package/lib/presets/notion.css +521 -0
  53. package/lib/presets/notion.jux +27 -0
  54. package/lib/reactivity/state.ts +364 -0
  55. package/lib/themes/charts.js +126 -0
  56. package/machinery/compiler.js +126 -38
  57. package/machinery/generators/html.js +2 -3
  58. package/machinery/server.js +2 -2
  59. package/package.json +29 -3
  60. package/lib/components/import.ts +0 -430
  61. package/lib/components/node.ts +0 -200
  62. package/lib/components/reactivity.js +0 -104
  63. package/lib/components/theme.ts +0 -97
  64. package/lib/layouts/notion.css +0 -258
  65. package/lib/styles/base-theme.css +0 -186
  66. package/lib/styles/dark-theme.css +0 -144
  67. package/lib/styles/light-theme.css +0 -144
  68. package/lib/styles/tokens/dark.css +0 -86
  69. package/lib/styles/tokens/light.css +0 -86
  70. package/lib/templates/index.juxt +0 -33
  71. package/lib/themes/dark.css +0 -86
  72. package/lib/themes/light.css +0 -86
  73. /package/lib/{styles → presets}/global.css +0 -0
package/lib/jux.ts CHANGED
@@ -3,11 +3,11 @@
3
3
  * Imports all components and provides the jux global object
4
4
  */
5
5
 
6
- import { Reactive } from './components/reactivity.js';
6
+ import { state } from './reactivity/state.js';
7
7
  import { Data, data } from './components/data.js';
8
8
  import { table, Table, type TableOptions, type TableColumn } from './components/table.js';
9
9
  import { hero, Hero, type HeroOptions } from './components/hero.js';
10
- import { card, Card, type CardOptions, type CardAction } from './components/card.js';
10
+ import { card, Card, type CardOptions } from './components/card.js';
11
11
  import { button, Button, type ButtonOptions } from './components/button.js';
12
12
  import { header, Header, type HeaderOptions } from './components/header.js';
13
13
  import { footer, Footer, type FooterOptions } from './components/footer.js';
@@ -23,13 +23,34 @@ import { chart, Chart, type ChartOptions } from './components/chart.js';
23
23
  import { view, View, type ViewOptions } from './components/view.js';
24
24
  import { code, Code, type CodeOptions } from './components/code.js';
25
25
  import { input, Input, type InputOptions } from './components/input.js';
26
- import { node, Node, type NodeOptions } from './components/node.js';
27
- import { App } from './components/app.js';
28
- import { Style } from './components/style.js';
29
- import { Script } from './components/script.js';
30
- import { Layout } from './components/layout.js';
26
+ import { app, App, AppOptions } from './components/app.js';
27
+ import { style, Style } from './components/style.js';
28
+ import { script, Script } from './components/script.js';
29
+ import { layout, Layout } from './components/layout.js';
31
30
  import { ErrorHandler } from './components/error-handler.js';
32
- import { theme, Theme } from './components/theme.js';
31
+ import { include, Include } from './components/include.js';
32
+ import { themeToggle, ThemeToggle, type ThemeToggleOptions, type Theme } from './components/theme-toggle.js';
33
+ import { tokenCalculator, TokenCalculator, type TokenCalculatorOptions } from './components/token-calculator.js';
34
+ import { write, Write, type WriteOptions } from './components/write.js';
35
+ import { element, Element, type ElementOptions } from './components/element.js';
36
+ import { alert, Alert, type AlertOptions } from './components/alert.js';
37
+ import { loading, Loading, type LoadingOptions } from './components/loading.js';
38
+ import { checkbox, Checkbox, type CheckboxOptions } from './components/checkbox.js';
39
+ import { select, Select, type SelectOptions, type SelectOption } from './components/select.js';
40
+ import { radio, Radio, type RadioOptions, type RadioOption } from './components/radio.js';
41
+ import { switchComponent, Switch, type SwitchOptions } from './components/switch.js';
42
+ import { badge, Badge, type BadgeOptions } from './components/badge.js';
43
+ import { progress, Progress, type ProgressOptions } from './components/progress.js';
44
+ import { tooltip, Tooltip, type TooltipOptions } from './components/tooltip.js';
45
+ import { dialog, Dialog, type DialogOptions } from './components/dialog.js';
46
+ import { dropdown, Dropdown, type DropdownOptions, type DropdownItem } from './components/dropdown.js';
47
+ import { datepicker, DatePicker, type DatePickerOptions } from './components/datepicker.js';
48
+ import { fileupload, FileUpload, type FileUploadOptions } from './components/fileupload.js';
49
+ import { req, Req, type RequestInfo } from './components/req.js';
50
+ import { heading, Heading, type HeadingOptions } from './components/heading.js';
51
+ import { paragraph, Paragraph, type ParagraphOptions } from './components/paragraph.js';
52
+ import { barchart, BarChart, type BarChartOptions, type BarChartDataPoint } from './components/barchart.js';
53
+
33
54
 
34
55
  /* -------------------------
35
56
  * Type Exports
@@ -58,9 +79,34 @@ export type {
58
79
  ChartOptions,
59
80
  CodeOptions,
60
81
  InputOptions,
61
- NodeOptions,
62
82
  CardOptions,
63
- CardAction
83
+ AppOptions,
84
+ ThemeToggleOptions,
85
+ Theme,
86
+ TokenCalculatorOptions,
87
+ WriteOptions,
88
+ ElementOptions,
89
+ AlertOptions,
90
+ LoadingOptions,
91
+ CheckboxOptions,
92
+ SelectOptions,
93
+ SelectOption,
94
+ RadioOptions,
95
+ RadioOption,
96
+ SwitchOptions,
97
+ BadgeOptions,
98
+ ProgressOptions,
99
+ TooltipOptions,
100
+ DialogOptions,
101
+ DropdownOptions,
102
+ DropdownItem,
103
+ DatePickerOptions,
104
+ FileUploadOptions,
105
+ RequestInfo,
106
+ HeadingOptions,
107
+ ParagraphOptions,
108
+ BarChartOptions,
109
+ BarChartDataPoint
64
110
  };
65
111
 
66
112
  /* -------------------------
@@ -68,7 +114,6 @@ export type {
68
114
  * ------------------------- */
69
115
 
70
116
  export {
71
- Reactive,
72
117
  Data,
73
118
  Hero,
74
119
  Card,
@@ -88,22 +133,101 @@ export {
88
133
  Code,
89
134
  Input,
90
135
  View,
91
- Node,
92
136
  App,
93
137
  Style,
94
138
  Script,
95
139
  Layout,
96
- Theme
140
+ Include,
141
+ ThemeToggle,
142
+ TokenCalculator,
143
+ Write,
144
+ Element,
145
+ Alert,
146
+ Loading,
147
+ Checkbox,
148
+ Select,
149
+ Radio,
150
+ Switch,
151
+ Badge,
152
+ Progress,
153
+ Tooltip,
154
+ Dialog,
155
+ Dropdown,
156
+ DatePicker,
157
+ FileUpload,
158
+ Req,
159
+ Heading,
160
+ Paragraph,
161
+ BarChart
97
162
  };
98
163
 
164
+ /* -------------------------
165
+ * Jux API Interface
166
+ * ------------------------- */
167
+
168
+ export interface JuxAPI {
169
+ // Utility methods
170
+ apiUrl: string;
171
+ param(name: string): string | null;
172
+ req: typeof req;
173
+
174
+ // Component factories
175
+ data: typeof data;
176
+ table: typeof table;
177
+ hero: typeof hero;
178
+ card: typeof card;
179
+ button: typeof button;
180
+ header: typeof header;
181
+ footer: typeof footer;
182
+ main: typeof main;
183
+ sidebar: typeof sidebar;
184
+ container: typeof container;
185
+ modal: typeof modal;
186
+ tabs: typeof tabs;
187
+ list: typeof list;
188
+ menu: typeof menu;
189
+ nav: typeof nav;
190
+ chart: typeof chart;
191
+ code: typeof code;
192
+ input: typeof input;
193
+ view: typeof view;
194
+ app: typeof app;
195
+ style: typeof style;
196
+ script: typeof script;
197
+ layout: typeof layout;
198
+ include: typeof include;
199
+ themeToggle: typeof themeToggle;
200
+ tokenCalculator: typeof tokenCalculator;
201
+ write: typeof write;
202
+ element: typeof element;
203
+ alert: typeof alert;
204
+ loading: typeof loading;
205
+ checkbox: typeof checkbox;
206
+ select: typeof select;
207
+ radio: typeof radio;
208
+ switch: typeof switchComponent;
209
+ badge: typeof badge;
210
+ progress: typeof progress;
211
+ tooltip: typeof tooltip;
212
+ dialog: typeof dialog;
213
+ dropdown: typeof dropdown;
214
+ datepicker: typeof datepicker;
215
+ fileupload: typeof fileupload;
216
+ heading: typeof heading;
217
+ paragraph: typeof paragraph;
218
+ barchart: typeof barchart;
219
+ }
220
+
99
221
  /* -------------------------
100
222
  * Jux Singleton
101
223
  * ------------------------- */
102
224
 
103
- class Jux {
225
+ class Jux implements JuxAPI {
104
226
  apiUrl: string = '/api/query';
105
227
 
106
- // Utility methods
228
+ /**
229
+ * Get URL parameter or juxContext value
230
+ */
107
231
  param(name: string): string | null {
108
232
  if (typeof window !== 'undefined' && (window as any).juxContext?.[name] !== undefined) {
109
233
  return (window as any).juxContext[name];
@@ -117,7 +241,10 @@ class Jux {
117
241
  return null;
118
242
  }
119
243
 
120
- // Component methods
244
+ // Request utilities
245
+ req = req;
246
+
247
+ // Component factory methods
121
248
  data = data;
122
249
  table = table;
123
250
  hero = hero;
@@ -135,69 +262,52 @@ class Jux {
135
262
  code = code;
136
263
  nav = nav;
137
264
  input = input;
138
- node = node;
139
265
  view = view;
140
266
  chart = chart;
141
- theme = theme;
142
-
143
- // App-level configuration methods
144
- app(): App {
145
- return new App();
146
- }
147
-
148
- style(contentOrUrl: string): Style {
149
- return new Style(contentOrUrl);
150
- }
151
-
152
- script(contentOrSrc: string): Script {
153
- return new Script(contentOrSrc);
154
- }
155
-
156
- layout(juxFile: string): Layout {
157
- return new Layout(juxFile);
158
- }
267
+ app = app;
268
+ include = include;
269
+ style = style;
270
+ script = script;
271
+ layout = layout;
272
+ themeToggle = themeToggle;
273
+ tokenCalculator = tokenCalculator;
274
+ write = write;
275
+ element = element;
276
+ alert = alert;
277
+ loading = loading;
278
+ checkbox = checkbox;
279
+ select = select;
280
+ radio = radio;
281
+ switch = switchComponent;
282
+ badge = badge;
283
+ progress = progress;
284
+ tooltip = tooltip;
285
+ dialog = dialog;
286
+ dropdown = dropdown;
287
+ datepicker = datepicker;
288
+ fileupload = fileupload;
289
+ heading = heading;
290
+ paragraph = paragraph;
291
+ barchart = barchart;
159
292
  }
160
293
 
294
+ /**
295
+ * Global jux singleton instance
296
+ */
161
297
  const jux = new Jux();
162
298
 
299
+ // Make jux available globally in browser
300
+ if (typeof window !== 'undefined') {
301
+ (window as any).jux = jux;
302
+ }
303
+
163
304
  /* -------------------------
164
305
  * Exports
165
- *
166
- * ⚠️ IMPORTANT: When adding a new component:
167
- * 1. Import it at the top
168
- * 2. Add to Jux class as a method
169
- * 3. Export as $ alias below
170
- * 4. Update machinery/compiler → COMPONENT_ALIASES array
171
306
  * ------------------------- */
172
307
 
173
308
  export {
174
309
  jux,
175
- // $ aliases - just re-export the factory functions
176
- table as $table,
177
- hero as $hero,
178
- card as $card,
179
- button as $button,
180
- header as $header,
181
- footer as $footer,
182
- main as $main,
183
- sidebar as $sidebar,
184
- container as $container,
185
- modal as $modal,
186
- tabs as $tabs,
187
- list as $list,
188
- menu as $menu,
189
- code as $code,
190
- nav as $nav,
191
- input as $input,
192
- node as $node,
193
- view as $view,
194
- chart as $chart,
195
- data as $data,
196
- App as $app,
197
- Style as $style,
198
- Script as $script,
199
- Layout as $layout,
200
- theme as $theme,
201
-
310
+ state,
311
+ req,
202
312
  ErrorHandler
203
313
  };