juxscript 1.0.19 → 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 (77) hide show
  1. package/bin/cli.js +121 -72
  2. package/lib/components/alert.ts +212 -165
  3. package/lib/components/badge.ts +93 -103
  4. package/lib/components/base/BaseComponent.ts +397 -0
  5. package/lib/components/base/FormInput.ts +322 -0
  6. package/lib/components/button.ts +63 -122
  7. package/lib/components/card.ts +109 -155
  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/charts/lib/chart-types.ts +159 -0
  13. package/lib/components/charts/lib/chart-utils.ts +160 -0
  14. package/lib/components/charts/lib/chart.ts +707 -0
  15. package/lib/components/checkbox.ts +264 -127
  16. package/lib/components/code.ts +75 -108
  17. package/lib/components/container.ts +113 -130
  18. package/lib/components/data.ts +37 -5
  19. package/lib/components/datepicker.ts +195 -147
  20. package/lib/components/dialog.ts +187 -157
  21. package/lib/components/divider.ts +85 -191
  22. package/lib/components/docs-data.json +544 -2027
  23. package/lib/components/dropdown.ts +178 -136
  24. package/lib/components/element.ts +227 -171
  25. package/lib/components/fileupload.ts +285 -228
  26. package/lib/components/guard.ts +92 -0
  27. package/lib/components/heading.ts +46 -69
  28. package/lib/components/helpers.ts +13 -6
  29. package/lib/components/hero.ts +107 -95
  30. package/lib/components/icon.ts +160 -0
  31. package/lib/components/icons.ts +175 -0
  32. package/lib/components/include.ts +153 -5
  33. package/lib/components/input.ts +174 -374
  34. package/lib/components/kpicard.ts +16 -16
  35. package/lib/components/list.ts +378 -240
  36. package/lib/components/loading.ts +142 -211
  37. package/lib/components/menu.ts +103 -97
  38. package/lib/components/modal.ts +138 -144
  39. package/lib/components/nav.ts +169 -90
  40. package/lib/components/paragraph.ts +49 -150
  41. package/lib/components/progress.ts +118 -200
  42. package/lib/components/radio.ts +297 -149
  43. package/lib/components/script.ts +19 -87
  44. package/lib/components/select.ts +184 -186
  45. package/lib/components/sidebar.ts +152 -140
  46. package/lib/components/style.ts +19 -82
  47. package/lib/components/switch.ts +258 -188
  48. package/lib/components/table.ts +1117 -170
  49. package/lib/components/tabs.ts +162 -145
  50. package/lib/components/theme-toggle.ts +108 -169
  51. package/lib/components/tooltip.ts +86 -157
  52. package/lib/components/write.ts +108 -127
  53. package/lib/jux.ts +86 -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 -2
  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 -1246
  67. package/lib/components/areachartsmooth.ts +0 -1380
  68. package/lib/components/barchart.ts +0 -1250
  69. package/lib/components/chart.ts +0 -127
  70. package/lib/components/doughnutchart.ts +0 -1191
  71. package/lib/components/footer.ts +0 -165
  72. package/lib/components/header.ts +0 -187
  73. package/lib/components/layout.ts +0 -239
  74. package/lib/components/main.ts +0 -137
  75. package/lib/layouts/default.jux +0 -8
  76. package/lib/layouts/figma.jux +0 -0
  77. /package/lib/{themes → components/charts/lib}/charts.js +0 -0
@@ -0,0 +1,160 @@
1
+ import { ChartDataPoint, ChartTheme } from './chart-types.js';
2
+ import {
3
+ googleTheme,
4
+ seriesaTheme,
5
+ hrTheme,
6
+ figmaTheme,
7
+ notionTheme,
8
+ chalkTheme,
9
+ mintTheme
10
+ } from './charts.js';
11
+
12
+ /**
13
+ * Lighten a hex color by a percentage
14
+ */
15
+ export function lightenColor(color: string, percent: number): string {
16
+ const num = parseInt(color.replace('#', ''), 16);
17
+ const r = Math.min(255, Math.floor((num >> 16) + ((255 - (num >> 16)) * percent / 100)));
18
+ const g = Math.min(255, Math.floor(((num >> 8) & 0x00FF) + ((255 - ((num >> 8) & 0x00FF)) * percent / 100)));
19
+ const b = Math.min(255, Math.floor((num & 0x0000FF) + ((255 - (num & 0x0000FF)) * percent / 100)));
20
+ return `#${((r << 16) | (g << 8) | b).toString(16).padStart(6, '0')}`;
21
+ }
22
+
23
+ /**
24
+ * Get theme configuration by name
25
+ */
26
+ export function getThemeConfig(themeName: ChartTheme): any {
27
+ const themes: Record<ChartTheme, any> = {
28
+ google: googleTheme,
29
+ seriesa: seriesaTheme,
30
+ hr: hrTheme,
31
+ figma: figmaTheme,
32
+ notion: notionTheme,
33
+ chalk: chalkTheme,
34
+ mint: mintTheme
35
+ };
36
+ return themes[themeName];
37
+ }
38
+
39
+ /**
40
+ * Create legend HTML element
41
+ */
42
+ export function createLegend(data: ChartDataPoint[], colors: string[], className: string): HTMLElement {
43
+ const legend = document.createElement('div');
44
+ legend.className = `${className}-legend`;
45
+
46
+ data.forEach((point, index) => {
47
+ const color = point.color || colors[index % colors.length];
48
+
49
+ const item = document.createElement('div');
50
+ item.className = `${className}-legend-item`;
51
+
52
+ const swatch = document.createElement('div');
53
+ swatch.className = `${className}-legend-swatch`;
54
+ swatch.style.background = color;
55
+
56
+ const label = document.createElement('span');
57
+ label.className = `${className}-legend-label`;
58
+ label.textContent = point.label;
59
+
60
+ item.appendChild(swatch);
61
+ item.appendChild(label);
62
+ legend.appendChild(item);
63
+ });
64
+
65
+ return legend;
66
+ }
67
+
68
+ /**
69
+ * Create data table HTML element
70
+ */
71
+ export function createDataTable(
72
+ data: ChartDataPoint[],
73
+ xAxisLabel: string,
74
+ yAxisLabel: string,
75
+ className: string,
76
+ chartOrientation?: 'vertical' | 'horizontal'
77
+ ): HTMLElement {
78
+ const table = document.createElement('table');
79
+ table.className = `${className}-table`;
80
+
81
+ const thead = document.createElement('thead');
82
+ const headerRow = document.createElement('tr');
83
+
84
+ // Swap headers based on orientation for bar/area charts
85
+ const columnHeaders = chartOrientation === 'horizontal'
86
+ ? [yAxisLabel || 'Label', xAxisLabel || 'Value']
87
+ : [xAxisLabel || 'Label', yAxisLabel || 'Value'];
88
+
89
+ columnHeaders.forEach(text => {
90
+ const th = document.createElement('th');
91
+ th.textContent = text;
92
+ headerRow.appendChild(th);
93
+ });
94
+ thead.appendChild(headerRow);
95
+ table.appendChild(thead);
96
+
97
+ const tbody = document.createElement('tbody');
98
+ data.forEach(point => {
99
+ const row = document.createElement('tr');
100
+
101
+ const labelCell = document.createElement('td');
102
+ labelCell.textContent = point.label;
103
+
104
+ const valueCell = document.createElement('td');
105
+ valueCell.textContent = point.value.toString();
106
+
107
+ row.appendChild(labelCell);
108
+ row.appendChild(valueCell);
109
+ tbody.appendChild(row);
110
+ });
111
+ table.appendChild(tbody);
112
+
113
+ return table;
114
+ }
115
+
116
+ /**
117
+ * Apply theme styles to document
118
+ */
119
+ export function applyThemeStyles(themeName: ChartTheme, className: string, baseStyles: string): void {
120
+ const theme = getThemeConfig(themeName);
121
+ if (!theme) return;
122
+
123
+ // Inject base styles (once)
124
+ const baseStyleId = `${className}-base-styles`;
125
+ if (!document.getElementById(baseStyleId)) {
126
+ const style = document.createElement('style');
127
+ style.id = baseStyleId;
128
+ style.textContent = baseStyles;
129
+ document.head.appendChild(style);
130
+ }
131
+
132
+ // Inject font (once per theme)
133
+ if (theme.font && !document.querySelector(`link[href="${theme.font}"]`)) {
134
+ const link = document.createElement('link');
135
+ link.rel = 'stylesheet';
136
+ link.href = theme.font;
137
+ document.head.appendChild(link);
138
+ }
139
+
140
+ // Apply theme-specific styles
141
+ const styleId = `${className}-theme-${themeName}`;
142
+ let styleElement = document.getElementById(styleId) as HTMLStyleElement;
143
+
144
+ if (!styleElement) {
145
+ styleElement = document.createElement('style');
146
+ styleElement.id = styleId;
147
+ document.head.appendChild(styleElement);
148
+ }
149
+
150
+ // Generate CSS with theme variables
151
+ const variablesCSS = Object.entries(theme.variables)
152
+ .map(([key, value]) => ` ${key}: ${value};`)
153
+ .join('\n');
154
+
155
+ styleElement.textContent = `
156
+ .${className}.theme-${themeName} {
157
+ ${variablesCSS}
158
+ }
159
+ `;
160
+ }