fynixui 1.0.11 → 1.0.12

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 @@
1
+ "use strict";
@@ -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,2 @@
1
- export { Button } from "./button";
1
+ export { Button, PrimaryButton, SecondaryButton, SuccessButton, DangerButton, WarningButton, InfoButton, LightButton, DarkButton, LinkButton, } from "./button";
2
2
  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,7 +1,9 @@
1
- import { Fragment } from "../runtime";
1
+ import { Fragment } from "../runtime.js";
2
2
  export function For(props) {
3
3
  let items = [];
4
- if (props.each && typeof props.each === "object" && "_isNixState" in props.each) {
4
+ if (props.each &&
5
+ typeof props.each === "object" &&
6
+ "_isNixState" in props.each) {
5
7
  items = props.each.value;
6
8
  }
7
9
  else if (Array.isArray(props.each)) {
@@ -33,9 +35,9 @@ export function For(props) {
33
35
  type: "div",
34
36
  props: {
35
37
  children: ["Error rendering item"],
36
- style: "color: red;"
38
+ style: "color: red;",
37
39
  },
38
- key: index
40
+ key: index,
39
41
  };
40
42
  }
41
43
  });
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fynixui",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "type": "module",
5
5
  "description": "Core package for Fynix UI framework - A lightweight, reactive UI framework with TypeScript support.",
6
6
  "main": "./dist/fynix/index.js",
@@ -214,6 +214,5 @@
214
214
  "./types/global.d.ts"
215
215
  ]
216
216
  }
217
- },
218
- "dependencies": {}
217
+ }
219
218
  }
@@ -1,8 +1,18 @@
1
1
  import { transform } from "esbuild";
2
2
  import { normalizePath } from "vite";
3
+ import crypto from "crypto";
3
4
  export default function fynixPlugin(options = {}) {
4
- const { jsxFactory = "Fynix", jsxFragment = "Fynix.Fragment", include = [".ts", ".js", ".jsx", ".tsx", ".fnx"], exclude = ["node_modules"], sourcemap = true, esbuildOptions = {}, } = options;
5
+ const { jsxFactory = "Fynix", jsxFragment = "Fynix.Fragment", include = [".ts", ".js", ".jsx", ".tsx", ".fnx"], exclude = ["node_modules"], esbuildOptions = {}, } = options;
5
6
  let viteServer = null;
7
+ const transformCache = new Map();
8
+ function hasJsxLike(code) {
9
+ return (/<[A-Za-z]/.test(code) ||
10
+ /Fynix\s*\(/.test(code) ||
11
+ /Fragment|<>/.test(code));
12
+ }
13
+ function getContentHash(code) {
14
+ return crypto.createHash("md5").update(code).digest("hex");
15
+ }
6
16
  return {
7
17
  name: "vite-plugin-fynix",
8
18
  enforce: "pre",
@@ -17,6 +27,14 @@ export default function fynixPlugin(options = {}) {
17
27
  const shouldInclude = include.some((ext) => normalizedId.endsWith(ext));
18
28
  if (!shouldInclude)
19
29
  return null;
30
+ if (!hasJsxLike(code)) {
31
+ return null;
32
+ }
33
+ const contentHash = getContentHash(code);
34
+ const cached = transformCache.get(normalizedId);
35
+ if (cached && cached.contentHash === contentHash) {
36
+ return { code: cached.code, map: cached.map };
37
+ }
20
38
  const ctx = this;
21
39
  if (typeof ctx.addWatchFile === "function") {
22
40
  ctx.addWatchFile(id);
@@ -39,16 +57,19 @@ export default function fynixPlugin(options = {}) {
39
57
  loader,
40
58
  jsxFactory,
41
59
  jsxFragment,
42
- sourcemap,
60
+ sourcemap: false,
43
61
  sourcefile: id,
44
62
  target: "esnext",
45
63
  format: "esm",
46
64
  ...esbuildOptions,
47
65
  });
48
- return {
66
+ const transformed = {
49
67
  code: result.code,
50
- map: result.map || null,
68
+ map: null,
69
+ contentHash,
51
70
  };
71
+ transformCache.set(normalizedId, transformed);
72
+ return { code: transformed.code, map: transformed.map };
52
73
  }
53
74
  catch (error) {
54
75
  const err = error;
@@ -71,6 +92,7 @@ export default function fynixPlugin(options = {}) {
71
92
  handleHotUpdate(ctx) {
72
93
  const { file, server } = ctx;
73
94
  const normalizedFile = normalizePath(file);
95
+ transformCache.delete(normalizedFile);
74
96
  const shouldReload = include.some((ext) => normalizedFile.endsWith(ext));
75
97
  if (shouldReload) {
76
98
  console.log(`\x1b[32m[vite-plugin-fynix]\x1b[0m HMR: full-reload triggered by ${normalizedFile}`);