fynixui 1.0.11 → 1.0.13

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.
@@ -0,0 +1,359 @@
1
+ import { Fynix } from "../runtime.js";
2
+ const VARIANT_THEMES = {
3
+ primary: {
4
+ headerBg: "rgba(13,110,253,0.08)",
5
+ headerColor: "#0d6efd",
6
+ headerBorder: "rgba(13,110,253,0.2)",
7
+ rowBorder: "rgba(13,110,253,0.09)",
8
+ rowHoverBg: "rgba(13,110,253,0.04)",
9
+ stripeBg: "rgba(13,110,253,0.03)",
10
+ accentBg: "#0d6efd",
11
+ accentColor: "#fff",
12
+ accentHoverBg: "#0b5ed7",
13
+ accentBorder: "#0d6efd",
14
+ },
15
+ secondary: {
16
+ headerBg: "rgba(108,117,125,0.08)",
17
+ headerColor: "#6c757d",
18
+ headerBorder: "rgba(108,117,125,0.2)",
19
+ rowBorder: "rgba(108,117,125,0.09)",
20
+ rowHoverBg: "rgba(108,117,125,0.04)",
21
+ stripeBg: "rgba(108,117,125,0.03)",
22
+ accentBg: "#6c757d",
23
+ accentColor: "#fff",
24
+ accentHoverBg: "#5c636a",
25
+ accentBorder: "#6c757d",
26
+ },
27
+ success: {
28
+ headerBg: "rgba(25,135,84,0.08)",
29
+ headerColor: "#198754",
30
+ headerBorder: "rgba(25,135,84,0.2)",
31
+ rowBorder: "rgba(25,135,84,0.09)",
32
+ rowHoverBg: "rgba(25,135,84,0.04)",
33
+ stripeBg: "rgba(25,135,84,0.03)",
34
+ accentBg: "#198754",
35
+ accentColor: "#fff",
36
+ accentHoverBg: "#157347",
37
+ accentBorder: "#198754",
38
+ },
39
+ danger: {
40
+ headerBg: "rgba(220,53,69,0.08)",
41
+ headerColor: "#dc3545",
42
+ headerBorder: "rgba(220,53,69,0.2)",
43
+ rowBorder: "rgba(220,53,69,0.09)",
44
+ rowHoverBg: "rgba(220,53,69,0.04)",
45
+ stripeBg: "rgba(220,53,69,0.03)",
46
+ accentBg: "#dc3545",
47
+ accentColor: "#fff",
48
+ accentHoverBg: "#bb2d3b",
49
+ accentBorder: "#dc3545",
50
+ },
51
+ warning: {
52
+ headerBg: "rgba(255,193,7,0.10)",
53
+ headerColor: "#856404",
54
+ headerBorder: "rgba(255,193,7,0.3)",
55
+ rowBorder: "rgba(255,193,7,0.12)",
56
+ rowHoverBg: "rgba(255,193,7,0.05)",
57
+ stripeBg: "rgba(255,193,7,0.04)",
58
+ accentBg: "#ffc107",
59
+ accentColor: "#212529",
60
+ accentHoverBg: "#ffca2c",
61
+ accentBorder: "#ffc107",
62
+ },
63
+ info: {
64
+ headerBg: "rgba(13,202,240,0.08)",
65
+ headerColor: "#055160",
66
+ headerBorder: "rgba(13,202,240,0.2)",
67
+ rowBorder: "rgba(13,202,240,0.09)",
68
+ rowHoverBg: "rgba(13,202,240,0.04)",
69
+ stripeBg: "rgba(13,202,240,0.03)",
70
+ accentBg: "#0dcaf0",
71
+ accentColor: "#212529",
72
+ accentHoverBg: "#31d2f2",
73
+ accentBorder: "#0dcaf0",
74
+ },
75
+ light: {
76
+ headerBg: "#f8f9fa",
77
+ headerColor: "#495057",
78
+ headerBorder: "#dee2e6",
79
+ rowBorder: "#e9ecef",
80
+ rowHoverBg: "#f1f3f5",
81
+ stripeBg: "#f8f9fa",
82
+ accentBg: "#f8f9fa",
83
+ accentColor: "#212529",
84
+ accentHoverBg: "#e2e6ea",
85
+ accentBorder: "#dee2e6",
86
+ },
87
+ dark: {
88
+ headerBg: "rgba(33,37,41,0.07)",
89
+ headerColor: "inherit",
90
+ headerBorder: "rgba(33,37,41,0.15)",
91
+ rowBorder: "rgba(33,37,41,0.08)",
92
+ rowHoverBg: "rgba(33,37,41,0.04)",
93
+ stripeBg: "rgba(33,37,41,0.03)",
94
+ accentBg: "#212529",
95
+ accentColor: "#fff",
96
+ accentHoverBg: "#424649",
97
+ accentBorder: "#212529",
98
+ },
99
+ };
100
+ const OUTLINE_THEMES = Object.fromEntries(Object.entries(VARIANT_THEMES).map(([k, v]) => [
101
+ k,
102
+ {
103
+ ...v,
104
+ headerBg: "transparent",
105
+ stripeBg: "transparent",
106
+ },
107
+ ]));
108
+ let tableStylesInjected = false;
109
+ function injectTableStyles() {
110
+ if (tableStylesInjected || typeof document === "undefined")
111
+ return;
112
+ tableStylesInjected = true;
113
+ const rules = [
114
+ `
115
+ [data-fynix-dt] {
116
+ width: 100%;
117
+ border-collapse: collapse;
118
+ font-size: 14px;
119
+ font-family: inherit;
120
+ }
121
+ [data-fynix-dt] th,
122
+ [data-fynix-dt] td {
123
+ padding: 8px 12px;
124
+ text-align: left;
125
+ vertical-align: middle;
126
+ border-bottom: 1px solid;
127
+ white-space: nowrap;
128
+ }
129
+ [data-fynix-dt] th {
130
+ font-weight: 500;
131
+ font-size: 12px;
132
+ }
133
+ [data-fynix-dt] tr:last-child td {
134
+ border-bottom: none;
135
+ }
136
+ [data-fynix-dt-actions] {
137
+ display: flex;
138
+ gap: 6px;
139
+ align-items: center;
140
+ }
141
+ [data-fynix-dt-btn] {
142
+ display: inline-block;
143
+ cursor: pointer;
144
+ font-size: 12px;
145
+ font-weight: 400;
146
+ padding: 3px 9px;
147
+ border-radius: 4px;
148
+ border: 1px solid;
149
+ line-height: 1.5;
150
+ transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out;
151
+ user-select: none;
152
+ text-decoration: none;
153
+ white-space: nowrap;
154
+ }
155
+ `,
156
+ ];
157
+ for (const [variant, theme] of Object.entries(VARIANT_THEMES)) {
158
+ rules.push(`
159
+ [data-fynix-dt="${variant}"] th {
160
+ background-color: ${theme.headerBg} !important;
161
+ color: ${theme.headerColor} !important;
162
+ border-color: ${theme.headerBorder} !important;
163
+ }
164
+ [data-fynix-dt="${variant}"] td {
165
+ border-color: ${theme.rowBorder} !important;
166
+ }
167
+ [data-fynix-dt="${variant}"][data-fynix-dt-hover] tr:hover td {
168
+ background-color: ${theme.rowHoverBg} !important;
169
+ }
170
+ [data-fynix-dt="${variant}"][data-fynix-dt-stripe] tr:nth-child(even) td {
171
+ background-color: ${theme.stripeBg} !important;
172
+ }
173
+
174
+ /* View button (filled with accent) */
175
+ [data-fynix-dt="${variant}"] [data-fynix-dt-btn="view"] {
176
+ background-color: ${theme.accentBg};
177
+ color: ${theme.accentColor};
178
+ border-color: ${theme.accentBorder};
179
+ }
180
+ [data-fynix-dt="${variant}"] [data-fynix-dt-btn="view"]:hover {
181
+ background-color: ${theme.accentHoverBg} !important;
182
+ }
183
+
184
+ /* Edit button (outline accent) */
185
+ [data-fynix-dt="${variant}"] [data-fynix-dt-btn="edit"] {
186
+ background-color: transparent;
187
+ color: ${theme.accentBg === "transparent" ? theme.headerColor : theme.accentBg};
188
+ border-color: ${theme.accentBorder};
189
+ }
190
+ [data-fynix-dt="${variant}"] [data-fynix-dt-btn="edit"]:hover {
191
+ background-color: ${theme.accentBg} !important;
192
+ color: ${theme.accentColor} !important;
193
+ }
194
+
195
+ /* Delete button (always danger outline regardless of variant) */
196
+ [data-fynix-dt="${variant}"] [data-fynix-dt-btn="delete"] {
197
+ background-color: transparent;
198
+ color: #dc3545;
199
+ border-color: #dc3545;
200
+ }
201
+ [data-fynix-dt="${variant}"] [data-fynix-dt-btn="delete"]:hover {
202
+ background-color: #dc3545 !important;
203
+ color: #fff !important;
204
+ }
205
+ `);
206
+ const outlineTheme = OUTLINE_THEMES[variant];
207
+ rules.push(`
208
+ [data-fynix-dt="outline-${variant}"] th {
209
+ background-color: ${outlineTheme.headerBg} !important;
210
+ color: ${theme.headerColor} !important;
211
+ border-color: ${theme.accentBorder} !important;
212
+ }
213
+ [data-fynix-dt="outline-${variant}"] td {
214
+ border-color: ${theme.rowBorder} !important;
215
+ }
216
+ [data-fynix-dt="outline-${variant}"][data-fynix-dt-hover] tr:hover td {
217
+ background-color: ${theme.rowHoverBg} !important;
218
+ }
219
+ [data-fynix-dt="outline-${variant}"] [data-fynix-dt-btn="view"] {
220
+ background-color: transparent;
221
+ color: ${theme.accentBg};
222
+ border-color: ${theme.accentBorder};
223
+ }
224
+ [data-fynix-dt="outline-${variant}"] [data-fynix-dt-btn="view"]:hover {
225
+ background-color: ${theme.accentBg} !important;
226
+ color: ${theme.accentColor} !important;
227
+ }
228
+ [data-fynix-dt="outline-${variant}"] [data-fynix-dt-btn="edit"] {
229
+ background-color: transparent;
230
+ color: #198754;
231
+ border-color: #198754;
232
+ }
233
+ [data-fynix-dt="outline-${variant}"] [data-fynix-dt-btn="edit"]:hover {
234
+ background-color: #198754 !important;
235
+ color: #fff !important;
236
+ }
237
+ [data-fynix-dt="outline-${variant}"] [data-fynix-dt-btn="delete"] {
238
+ background-color: transparent;
239
+ color: #dc3545;
240
+ border-color: #dc3545;
241
+ }
242
+ [data-fynix-dt="outline-${variant}"] [data-fynix-dt-btn="delete"]:hover {
243
+ background-color: #dc3545 !important;
244
+ color: #fff !important;
245
+ }
246
+ `);
247
+ }
248
+ const style = document.createElement("style");
249
+ style.setAttribute("data-fynix", "datatable-styles");
250
+ style.textContent = rules.join("\n");
251
+ document.head.appendChild(style);
252
+ }
253
+ function getCellValue(row, key) {
254
+ return row[key];
255
+ }
256
+ export function DataTable({ columns, data, actions, style: wrapStyle = {}, class: wrapClass = "", tableStyle = {}, tableClass = "", rc, ...rest }) {
257
+ const thead = Fynix("thead", {}, Fynix("tr", {}, ...columns.map((col) => Fynix("th", { style: col.style ?? {}, class: col.class ?? "" }, col.label)), actions ? Fynix("th", {}, "Actions") : null));
258
+ const tbody = Fynix("tbody", {}, ...data.map((row, rowIndex) => Fynix("tr", {}, ...columns.map((col) => {
259
+ const raw = getCellValue(row, col.key);
260
+ const cell = col.render ? col.render(raw, row, rowIndex) : raw;
261
+ return Fynix("td", { style: col.style ?? {}, class: col.class ?? "" }, cell);
262
+ }), actions
263
+ ? Fynix("td", {}, Fynix("div", { style: { display: "flex", gap: "6px" } }, actions.view !== false && actions.view
264
+ ? Fynix("button", {
265
+ type: "button",
266
+ "r-click": () => actions.view(row, rowIndex),
267
+ }, "View")
268
+ : null, actions.edit !== false && actions.edit
269
+ ? Fynix("button", {
270
+ type: "button",
271
+ "r-click": () => actions.edit(row, rowIndex),
272
+ }, "Edit")
273
+ : null, actions.delete !== false && actions.delete
274
+ ? Fynix("button", {
275
+ type: "button",
276
+ "r-click": () => actions.delete(row, rowIndex),
277
+ }, "Delete")
278
+ : null, ...(actions.extra ?? []).map((extra) => Fynix("button", {
279
+ type: "button",
280
+ style: extra.style ?? {},
281
+ class: extra.class ?? "",
282
+ "r-click": () => extra.handler(row, rowIndex),
283
+ }, extra.label))))
284
+ : null)));
285
+ return Fynix("div", { style: wrapStyle, class: wrapClass, rc }, Fynix("table", { style: tableStyle, class: tableClass, ...rest }, thead, tbody));
286
+ }
287
+ function UIDataTable({ columns, data, actions, variant = "primary", outline = false, striped = false, hoverable = true, bordered = true, style: wrapStyle = {}, class: wrapClass = "", tableStyle = {}, tableClass = "", rc, }) {
288
+ injectTableStyles();
289
+ const dataAttr = outline ? `outline-${variant}` : variant;
290
+ const tableAttrs = {
291
+ "data-fynix-dt": dataAttr,
292
+ ...(hoverable ? { "data-fynix-dt-hover": "" } : {}),
293
+ ...(striped ? { "data-fynix-dt-stripe": "" } : {}),
294
+ style: tableStyle,
295
+ class: tableClass,
296
+ };
297
+ const borderStyle = bordered
298
+ ? {
299
+ border: "1px solid",
300
+ borderColor: "rgba(0,0,0,0.08)",
301
+ borderRadius: "6px",
302
+ overflow: "hidden",
303
+ }
304
+ : {};
305
+ const wrapAttrs = {
306
+ style: { display: "block", ...borderStyle, ...wrapStyle },
307
+ class: wrapClass,
308
+ rc,
309
+ };
310
+ const thead = Fynix("thead", {}, Fynix("tr", {}, ...columns.map((col) => Fynix("th", { style: col.style ?? {}, class: col.class ?? "" }, col.label)), actions ? Fynix("th", {}, "Actions") : null));
311
+ const tbody = Fynix("tbody", {}, ...data.map((row, rowIndex) => Fynix("tr", {}, ...columns.map((col) => {
312
+ const raw = getCellValue(row, col.key);
313
+ const cell = col.render ? col.render(raw, row, rowIndex) : raw;
314
+ return Fynix("td", { style: col.style ?? {}, class: col.class ?? "" }, cell);
315
+ }), actions
316
+ ? Fynix("td", {}, Fynix("div", { "data-fynix-dt-actions": "" }, actions.view !== false && actions.view
317
+ ? Fynix("button", {
318
+ type: "button",
319
+ "data-fynix-dt-btn": "view",
320
+ "r-click": () => actions.view(row, rowIndex),
321
+ }, "View")
322
+ : null, actions.edit !== false && actions.edit
323
+ ? Fynix("button", {
324
+ type: "button",
325
+ "data-fynix-dt-btn": "edit",
326
+ "r-click": () => actions.edit(row, rowIndex),
327
+ }, "Edit")
328
+ : null, actions.delete !== false && actions.delete
329
+ ? Fynix("button", {
330
+ type: "button",
331
+ "data-fynix-dt-btn": "delete",
332
+ "r-click": () => actions.delete(row, rowIndex),
333
+ }, "Delete")
334
+ : null, ...(actions.extra ?? []).map((extra) => Fynix("button", {
335
+ type: "button",
336
+ "data-fynix-dt-btn": "extra",
337
+ style: extra.style ?? {},
338
+ class: extra.class ?? "",
339
+ "r-click": () => extra.handler(row, rowIndex),
340
+ }, extra.label))))
341
+ : null)));
342
+ return Fynix("div", wrapAttrs, Fynix("table", tableAttrs, thead, tbody));
343
+ }
344
+ export const PrimaryDataTable = (p) => UIDataTable({ ...p, variant: "primary" });
345
+ export const SecondaryDataTable = (p) => UIDataTable({ ...p, variant: "secondary" });
346
+ export const SuccessDataTable = (p) => UIDataTable({ ...p, variant: "success" });
347
+ export const DangerDataTable = (p) => UIDataTable({ ...p, variant: "danger" });
348
+ export const WarningDataTable = (p) => UIDataTable({ ...p, variant: "warning" });
349
+ export const InfoDataTable = (p) => UIDataTable({ ...p, variant: "info" });
350
+ export const LightDataTable = (p) => UIDataTable({ ...p, variant: "light" });
351
+ export const DarkDataTable = (p) => UIDataTable({ ...p, variant: "dark" });
352
+ export const OutlinePrimaryDataTable = (p) => UIDataTable({ ...p, variant: "primary", outline: true });
353
+ export const OutlineSecondaryDataTable = (p) => UIDataTable({ ...p, variant: "secondary", outline: true });
354
+ export const OutlineSuccessDataTable = (p) => UIDataTable({ ...p, variant: "success", outline: true });
355
+ export const OutlineDangerDataTable = (p) => UIDataTable({ ...p, variant: "danger", outline: true });
356
+ export const OutlineWarningDataTable = (p) => UIDataTable({ ...p, variant: "warning", outline: true });
357
+ export const OutlineInfoDataTable = (p) => UIDataTable({ ...p, variant: "info", outline: true });
358
+ export const OutlineLightDataTable = (p) => UIDataTable({ ...p, variant: "light", outline: true });
359
+ export const OutlineDarkDataTable = (p) => UIDataTable({ ...p, variant: "dark", outline: true });
@@ -1,4 +1,244 @@
1
1
  import { Fynix } from "../runtime.js";
2
+ const VARIANT_STYLES = {
3
+ primary: {
4
+ bg: "#0d6efd",
5
+ color: "#fff",
6
+ border: "#0d6efd",
7
+ hoverBg: "#0b5ed7",
8
+ hoverColor: "#fff",
9
+ hoverBorder: "#0a58ca",
10
+ },
11
+ secondary: {
12
+ bg: "#6c757d",
13
+ color: "#fff",
14
+ border: "#6c757d",
15
+ hoverBg: "#5c636a",
16
+ hoverColor: "#fff",
17
+ hoverBorder: "#565e64",
18
+ },
19
+ success: {
20
+ bg: "#198754",
21
+ color: "#fff",
22
+ border: "#198754",
23
+ hoverBg: "#157347",
24
+ hoverColor: "#fff",
25
+ hoverBorder: "#146c43",
26
+ },
27
+ danger: {
28
+ bg: "#dc3545",
29
+ color: "#fff",
30
+ border: "#dc3545",
31
+ hoverBg: "#bb2d3b",
32
+ hoverColor: "#fff",
33
+ hoverBorder: "#b02a37",
34
+ },
35
+ warning: {
36
+ bg: "#ffc107",
37
+ color: "#212529",
38
+ border: "#ffc107",
39
+ hoverBg: "#ffca2c",
40
+ hoverColor: "#212529",
41
+ hoverBorder: "#ffc720",
42
+ },
43
+ info: {
44
+ bg: "#0dcaf0",
45
+ color: "#212529",
46
+ border: "#0dcaf0",
47
+ hoverBg: "#31d2f2",
48
+ hoverColor: "#212529",
49
+ hoverBorder: "#25cff2",
50
+ },
51
+ light: {
52
+ bg: "#f8f9fa",
53
+ color: "#212529",
54
+ border: "#dee2e6",
55
+ hoverBg: "#f9fafb",
56
+ hoverColor: "#212529",
57
+ hoverBorder: "#d3d4d5",
58
+ },
59
+ dark: {
60
+ bg: "#212529",
61
+ color: "#fff",
62
+ border: "#212529",
63
+ hoverBg: "#424649",
64
+ hoverColor: "#fff",
65
+ hoverBorder: "#373b3e",
66
+ },
67
+ link: {
68
+ bg: "transparent",
69
+ color: "#0d6efd",
70
+ border: "transparent",
71
+ hoverBg: "transparent",
72
+ hoverColor: "#0a58ca",
73
+ hoverBorder: "transparent",
74
+ },
75
+ };
76
+ const OUTLINE_STYLES = {
77
+ primary: {
78
+ bg: "transparent",
79
+ color: "#0d6efd",
80
+ border: "#0d6efd",
81
+ hoverBg: "#0d6efd",
82
+ hoverColor: "#fff",
83
+ hoverBorder: "#0d6efd",
84
+ },
85
+ secondary: {
86
+ bg: "transparent",
87
+ color: "#6c757d",
88
+ border: "#6c757d",
89
+ hoverBg: "#6c757d",
90
+ hoverColor: "#fff",
91
+ hoverBorder: "#6c757d",
92
+ },
93
+ success: {
94
+ bg: "transparent",
95
+ color: "#198754",
96
+ border: "#198754",
97
+ hoverBg: "#198754",
98
+ hoverColor: "#fff",
99
+ hoverBorder: "#198754",
100
+ },
101
+ danger: {
102
+ bg: "transparent",
103
+ color: "#dc3545",
104
+ border: "#dc3545",
105
+ hoverBg: "#dc3545",
106
+ hoverColor: "#fff",
107
+ hoverBorder: "#dc3545",
108
+ },
109
+ warning: {
110
+ bg: "transparent",
111
+ color: "#ffc107",
112
+ border: "#ffc107",
113
+ hoverBg: "#ffc107",
114
+ hoverColor: "#212529",
115
+ hoverBorder: "#ffc107",
116
+ },
117
+ info: {
118
+ bg: "transparent",
119
+ color: "#0dcaf0",
120
+ border: "#0dcaf0",
121
+ hoverBg: "#0dcaf0",
122
+ hoverColor: "#212529",
123
+ hoverBorder: "#0dcaf0",
124
+ },
125
+ light: {
126
+ bg: "transparent",
127
+ color: "#adb5bd",
128
+ border: "#adb5bd",
129
+ hoverBg: "#f8f9fa",
130
+ hoverColor: "#212529",
131
+ hoverBorder: "#adb5bd",
132
+ },
133
+ dark: {
134
+ bg: "transparent",
135
+ color: "#212529",
136
+ border: "#212529",
137
+ hoverBg: "#212529",
138
+ hoverColor: "#fff",
139
+ hoverBorder: "#212529",
140
+ },
141
+ link: {
142
+ bg: "transparent",
143
+ color: "#0d6efd",
144
+ border: "transparent",
145
+ hoverBg: "transparent",
146
+ hoverColor: "#0a58ca",
147
+ hoverBorder: "transparent",
148
+ },
149
+ };
150
+ const SIZE_STYLES = {
151
+ sm: { padding: "4px 8px", fontSize: "12px" },
152
+ md: { padding: "6px 12px", fontSize: "14px" },
153
+ lg: { padding: "8px 16px", fontSize: "16px" },
154
+ };
155
+ const BASE_STYLE = {
156
+ display: "inline-block",
157
+ fontWeight: "400",
158
+ lineHeight: "1.5",
159
+ textAlign: "center",
160
+ textDecoration: "none",
161
+ verticalAlign: "middle",
162
+ cursor: "pointer",
163
+ userSelect: "none",
164
+ borderWidth: "1px",
165
+ borderStyle: "solid",
166
+ borderRadius: "4px",
167
+ transition: "color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out",
168
+ };
169
+ let stylesInjected = false;
170
+ function injectButtonStyles() {
171
+ if (stylesInjected || typeof document === "undefined")
172
+ return;
173
+ stylesInjected = true;
174
+ const rules = [];
175
+ for (const [variant, colors] of Object.entries(VARIANT_STYLES)) {
176
+ rules.push(`
177
+ button[data-fynix-btn="${variant}"]:not([disabled]):hover {
178
+ background-color: ${colors.hoverBg} !important;
179
+ color: ${colors.hoverColor} !important;
180
+ border-color: ${colors.hoverBorder} !important;
181
+ ${variant === "link" ? "text-decoration: underline !important;" : ""}
182
+ }
183
+ `);
184
+ }
185
+ for (const [variant, colors] of Object.entries(OUTLINE_STYLES)) {
186
+ rules.push(`
187
+ button[data-fynix-btn="outline-${variant}"]:not([disabled]):hover {
188
+ background-color: ${colors.hoverBg} !important;
189
+ color: ${colors.hoverColor} !important;
190
+ border-color: ${colors.hoverBorder} !important;
191
+ }
192
+ `);
193
+ }
194
+ const style = document.createElement("style");
195
+ style.setAttribute("data-fynix", "button-styles");
196
+ style.textContent = rules.join("\n");
197
+ document.head.appendChild(style);
198
+ }
2
199
  export function Button({ value = "", ...props }) {
3
- return Fynix("button", props, value);
200
+ const { value: _stripped, ...cleanProps } = props;
201
+ return Fynix("button", cleanProps, value);
202
+ }
203
+ function UIButton({ value = "", variant = "primary", size = "md", outline = false, style: customStyle = {}, disabled = false, ...props }) {
204
+ injectButtonStyles();
205
+ const colors = outline ? OUTLINE_STYLES[variant] : VARIANT_STYLES[variant];
206
+ const sizing = SIZE_STYLES[size];
207
+ const dataAttr = outline ? `outline-${variant}` : variant;
208
+ const computedStyle = {
209
+ ...BASE_STYLE,
210
+ backgroundColor: colors.bg,
211
+ color: colors.color,
212
+ borderColor: colors.border,
213
+ padding: sizing.padding,
214
+ fontSize: sizing.fontSize,
215
+ opacity: disabled ? "0.65" : "1",
216
+ pointerEvents: disabled ? "none" : "auto",
217
+ ...customStyle,
218
+ };
219
+ return Button({
220
+ value,
221
+ style: computedStyle,
222
+ disabled,
223
+ "data-fynix-btn": dataAttr,
224
+ ...props,
225
+ });
4
226
  }
227
+ export const PrimaryButton = (p) => UIButton({ ...p, variant: "primary" });
228
+ export const SecondaryButton = (p) => UIButton({ ...p, variant: "secondary" });
229
+ export const SuccessButton = (p) => UIButton({ ...p, variant: "success" });
230
+ export const DangerButton = (p) => UIButton({ ...p, variant: "danger" });
231
+ export const WarningButton = (p) => UIButton({ ...p, variant: "warning" });
232
+ export const InfoButton = (p) => UIButton({ ...p, variant: "info" });
233
+ export const LightButton = (p) => UIButton({ ...p, variant: "light" });
234
+ export const DarkButton = (p) => UIButton({ ...p, variant: "dark" });
235
+ export const LinkButton = (p) => UIButton({ ...p, variant: "link" });
236
+ export const OutlinePrimaryButton = (p) => UIButton({ ...p, variant: "primary", outline: true });
237
+ export const OutlineSecondaryButton = (p) => UIButton({ ...p, variant: "secondary", outline: true });
238
+ export const OutlineSuccessButton = (p) => UIButton({ ...p, variant: "success", outline: true });
239
+ export const OutlineDangerButton = (p) => UIButton({ ...p, variant: "danger", outline: true });
240
+ export const OutlineWarningButton = (p) => UIButton({ ...p, variant: "warning", outline: true });
241
+ export const OutlineInfoButton = (p) => UIButton({ ...p, variant: "info", outline: true });
242
+ export const OutlineLightButton = (p) => UIButton({ ...p, variant: "light", outline: true });
243
+ export const OutlineDarkButton = (p) => UIButton({ ...p, variant: "dark", outline: true });
244
+ export const OutlineLinkButton = (p) => UIButton({ ...p, variant: "link", outline: true });
@@ -1,2 +1,3 @@
1
- export { Button } from "./button";
1
+ export { Button, PrimaryButton, SecondaryButton, SuccessButton, DangerButton, WarningButton, InfoButton, LightButton, DarkButton, LinkButton, } from "./button";
2
+ export { DataTable, PrimaryDataTable, SecondaryDataTable, SuccessDataTable, DangerDataTable, WarningDataTable, InfoDataTable, LightDataTable, DarkDataTable, OutlinePrimaryDataTable, OutlineSecondaryDataTable, OutlineSuccessDataTable, OutlineDangerDataTable, OutlineWarningDataTable, OutlineInfoDataTable, OutlineLightDataTable, OutlineDarkDataTable, } from "./DataTable";
2
3
  export { Path } from "./path";
@@ -4,7 +4,7 @@ export function showErrorOverlay(error) {
4
4
  overlay.id = "dev-error-overlay";
5
5
  Object.assign(overlay.style, {
6
6
  position: "fixed",
7
- inset: 0,
7
+ inset: "0",
8
8
  width: "100%",
9
9
  height: "100%",
10
10
  backgroundColor: "rgba(0, 0, 0, 0.9)",
@@ -1,20 +1,19 @@
1
- import { Fragment } from "../runtime";
1
+ import { Fragment } from "../runtime.js";
2
2
  export function For(props) {
3
- let items = [];
4
- if (props.each && typeof props.each === "object" && "_isNixState" in props.each) {
5
- items = props.each.value;
6
- }
7
- else if (Array.isArray(props.each)) {
8
- items = props.each;
9
- }
3
+ const isReactive = props.each && typeof props.each === "object" && "_isNixState" in props.each;
4
+ const items = isReactive
5
+ ? props.each.value
6
+ : Array.isArray(props.each)
7
+ ? props.each
8
+ : [];
10
9
  let renderer;
11
10
  if (typeof props.children === "function") {
12
11
  renderer = props.children;
13
12
  }
14
13
  else if (Array.isArray(props.children)) {
15
- const firstChild = props.children[0];
16
- if (typeof firstChild === "function") {
17
- renderer = firstChild;
14
+ const first = props.children[0];
15
+ if (typeof first === "function") {
16
+ renderer = first;
18
17
  }
19
18
  }
20
19
  if (!renderer) {
@@ -23,19 +22,18 @@ export function For(props) {
23
22
  }
24
23
  return { type: Fragment, props: { children: [] }, key: null };
25
24
  }
25
+ const finalRenderer = renderer;
26
26
  const mapped = items.map((item, index) => {
27
27
  try {
28
- return renderer(item, index);
28
+ const vnode = finalRenderer(item, index);
29
+ return { ...vnode, key: vnode.key ?? index };
29
30
  }
30
31
  catch (error) {
31
32
  console.error(`[Fynix] Error rendering item at index ${index}:`, error);
32
33
  return {
33
34
  type: "div",
34
- props: {
35
- children: ["Error rendering item"],
36
- style: "color: red;"
37
- },
38
- key: index
35
+ props: { children: ["Error rendering item"], style: "color: red;" },
36
+ key: index,
39
37
  };
40
38
  }
41
39
  });