zabi-components 4.0.0 → 5.0.1

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 (89) hide show
  1. package/README.md +70 -2
  2. package/dist/SSRSafe.svelte +47 -0
  3. package/dist/SSRSafe.svelte.d.ts +11 -0
  4. package/dist/atoms/Badge.svelte +76 -0
  5. package/dist/atoms/Badge.svelte.d.ts +9 -0
  6. package/dist/atoms/Button.svelte +72 -0
  7. package/dist/atoms/Button.svelte.d.ts +13 -0
  8. package/dist/atoms/Card.svelte +59 -0
  9. package/dist/atoms/Card.svelte.d.ts +12 -0
  10. package/dist/atoms/Checkbox.svelte +60 -0
  11. package/dist/atoms/Checkbox.svelte.d.ts +10 -0
  12. package/dist/atoms/CodeBlock.svelte +125 -0
  13. package/dist/atoms/CodeBlock.svelte.d.ts +8 -0
  14. package/dist/atoms/ColorPicker.svelte +171 -0
  15. package/dist/atoms/ColorPicker.svelte.d.ts +9 -0
  16. package/dist/atoms/FeatureCard.svelte +74 -0
  17. package/dist/atoms/FeatureCard.svelte.d.ts +17 -0
  18. package/dist/atoms/Heading.svelte +5 -0
  19. package/dist/atoms/Heading.svelte.d.ts +7 -0
  20. package/dist/atoms/Input.svelte +98 -0
  21. package/dist/atoms/Input.svelte.d.ts +14 -0
  22. package/dist/atoms/OptimizedImage.svelte +32 -0
  23. package/dist/atoms/OptimizedImage.svelte.d.ts +13 -0
  24. package/dist/atoms/Progress.svelte +61 -0
  25. package/dist/atoms/Progress.svelte.d.ts +9 -0
  26. package/dist/atoms/Select.svelte +85 -0
  27. package/dist/atoms/Select.svelte.d.ts +16 -0
  28. package/dist/atoms/Skeleton.svelte +20 -0
  29. package/dist/atoms/Skeleton.svelte.d.ts +8 -0
  30. package/dist/atoms/Textarea.svelte +116 -0
  31. package/dist/atoms/Textarea.svelte.d.ts +14 -0
  32. package/dist/atoms/ThemeToggle.svelte +89 -0
  33. package/dist/atoms/ThemeToggle.svelte.d.ts +7 -0
  34. package/dist/atoms/Toast.svelte +58 -0
  35. package/dist/atoms/Toast.svelte.d.ts +9 -0
  36. package/dist/atoms/Toggle.svelte +94 -0
  37. package/dist/atoms/Toggle.svelte.d.ts +12 -0
  38. package/dist/atoms/Tooltip.svelte +188 -0
  39. package/dist/atoms/Tooltip.svelte.d.ts +12 -0
  40. package/dist/atoms/index.d.ts +4 -15
  41. package/dist/atoms/index.js +10 -664
  42. package/dist/components/atoms/index.d.ts +10 -0
  43. package/dist/components/atoms/index.d.ts.map +1 -0
  44. package/dist/components/index.d.ts +31 -0
  45. package/dist/components/index.d.ts.map +1 -0
  46. package/dist/components/molecules/index.d.ts +1 -0
  47. package/dist/components/molecules/index.d.ts.map +1 -0
  48. package/dist/components/organisms/index.d.ts +1 -0
  49. package/dist/components/organisms/index.d.ts.map +1 -0
  50. package/dist/index.d.ts +30 -15
  51. package/dist/index.js +74 -0
  52. package/dist/molecules/Alert.svelte +114 -0
  53. package/dist/molecules/Alert.svelte.d.ts +14 -0
  54. package/dist/molecules/ComponentDemo.svelte +96 -0
  55. package/dist/molecules/ComponentDemo.svelte.d.ts +13 -0
  56. package/dist/molecules/ContactForm.svelte +98 -0
  57. package/dist/molecules/ContactForm.svelte.d.ts +10 -0
  58. package/dist/molecules/Dropdown.svelte +128 -0
  59. package/dist/molecules/Dropdown.svelte.d.ts +11 -0
  60. package/dist/molecules/Form.svelte +37 -0
  61. package/dist/molecules/Form.svelte.d.ts +12 -0
  62. package/dist/molecules/ImageUpload.svelte +112 -0
  63. package/dist/molecules/ImageUpload.svelte.d.ts +14 -0
  64. package/dist/molecules/Modal.svelte +85 -0
  65. package/dist/molecules/Modal.svelte.d.ts +13 -0
  66. package/dist/molecules/SlideUp.svelte +73 -0
  67. package/dist/molecules/SlideUp.svelte.d.ts +12 -0
  68. package/dist/molecules/Tabs.svelte +68 -0
  69. package/dist/molecules/Tabs.svelte.d.ts +17 -0
  70. package/dist/molecules/index.d.ts +0 -11
  71. package/dist/molecules/index.js +2 -580
  72. package/dist/organisms/Navbar.svelte +99 -0
  73. package/dist/organisms/Navbar.svelte.d.ts +14 -0
  74. package/dist/organisms/Navigation.svelte +48 -0
  75. package/dist/organisms/Navigation.svelte.d.ts +15 -0
  76. package/dist/organisms/index.d.ts +0 -4
  77. package/dist/organisms/index.js +2 -104
  78. package/dist/routes/lib/ssr-safe.ts +57 -0
  79. package/dist/routes/lib/variant-utils.ts +98 -0
  80. package/dist/zabi-components.css +399 -1
  81. package/package.json +43 -18
  82. package/dist/CodeBlock-Bbv6JfD2.js +0 -422
  83. package/dist/ThemeToggle-Z2Ndc0if.js +0 -42
  84. package/dist/index/index.js +0 -51
  85. package/dist/molecules/KeyValueForm.types.d.ts +0 -11
  86. package/dist/props-BKbHJRuR.js +0 -2213
  87. package/dist/types/index.d.ts +0 -4
  88. package/dist/types/index.js +0 -1
  89. package/dist/vite.svg +0 -1
@@ -0,0 +1,14 @@
1
+ interface Props {
2
+ brand?: string;
3
+ showThemeToggle?: boolean;
4
+ className?: string;
5
+ onclick?: (event: Event) => void;
6
+ }
7
+ type $$ComponentProps = Props & {
8
+ children?: any;
9
+ nav?: any;
10
+ actions?: any;
11
+ };
12
+ declare const Navbar: import("svelte").Component<$$ComponentProps, {}, "">;
13
+ type Navbar = ReturnType<typeof Navbar>;
14
+ export default Navbar;
@@ -0,0 +1,48 @@
1
+ <script lang="ts">
2
+ interface Props {
3
+ variant?: "header" | "sidebar";
4
+ items?: Array<{
5
+ label: string;
6
+ href: string;
7
+ }>;
8
+ currentPath?: string;
9
+ onclick?: (event: Event) => void;
10
+ }
11
+
12
+ let {
13
+ variant = "header",
14
+ items = [],
15
+ currentPath = "",
16
+ children,
17
+ ...restProps
18
+ }: Props & { children?: any } = $props();
19
+
20
+ function handleClick(item: any, event: MouseEvent) {
21
+ event.preventDefault();
22
+ // Navigation is now handled by the parent component
23
+ // through event forwarding
24
+ }
25
+ </script>
26
+
27
+ <nav class="navigation navigation-{variant}" {...restProps}>
28
+ <ul
29
+ class="flex {variant === 'sidebar'
30
+ ? 'flex-col space-y-2'
31
+ : 'space-x-6'}"
32
+ >
33
+ {#each items as item}
34
+ <li>
35
+ <a
36
+ href={item.href}
37
+ class="px-3 py-2 text-sm font-medium rounded-md transition-colors {currentPath ===
38
+ item.href
39
+ ? 'bg-blue-100 text-body'
40
+ : 'text-description hover:text-body hover:bg-gray-100'}"
41
+ onclick={(e) => handleClick(item, e)}
42
+ >
43
+ {item.label}
44
+ </a>
45
+ </li>
46
+ {/each}
47
+ </ul>
48
+ </nav>
@@ -0,0 +1,15 @@
1
+ interface Props {
2
+ variant?: "header" | "sidebar";
3
+ items?: Array<{
4
+ label: string;
5
+ href: string;
6
+ }>;
7
+ currentPath?: string;
8
+ onclick?: (event: Event) => void;
9
+ }
10
+ type $$ComponentProps = Props & {
11
+ children?: any;
12
+ };
13
+ declare const Navigation: import("svelte").Component<$$ComponentProps, {}, "">;
14
+ type Navigation = ReturnType<typeof Navigation>;
15
+ export default Navigation;
@@ -1,4 +0,0 @@
1
- // Organism Components - Complex components with state management
2
- export { default as Navbar } from './Navbar.svelte';
3
- export { default as ToastContainer } from './NotificationManager.svelte';
4
- export { default as ToastManager } from './ToastManager.svelte';
@@ -1,104 +1,2 @@
1
- import { D as G, p as d, f as m, a as M, h as e, q as u, i as w, e as Z, t as N, b, y as r, s as $, g as o, r as A, w as y, C as E, F as aa, G as ea, z as q, B as ta } from "../props-BKbHJRuR.js";
2
- import { T as F } from "../ThemeToggle-Z2Ndc0if.js";
3
- function sa(v, a) {
4
- $(a, !o(a));
5
- }
6
- function ia() {
7
- }
8
- var ra = m('<div class="mt-2"><!></div>'), va = m('<div class="md:hidden"><div class="px-2 pt-2 pb-3 space-y-1 sm:px-3 border-t border-gray-200"><!> <div class="pt-4"><!> <!></div></div></div>'), la = m('<nav><div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"><div class="flex justify-between items-center h-16"><div class="flex-shrink-0"><button type="button" class="text-xl font-bold text-gray-900"> </button></div> <div class="hidden md:block"><div class="ml-10 flex items-baseline space-x-4"><!></div></div> <div class="hidden md:block"><div class="ml-4 flex items-center space-x-4"><!> <!></div></div> <div class="md:hidden"><button type="button" class="text-gray-500 hover:text-gray-600" aria-label="Toggle menu"><span class="text-2xl">☰</span></button></div></div> <!></div></nav>');
9
- function ba(v, a) {
10
- let l = d(a, "brand", 3, ""), x = d(a, "showThemeToggle", 3, !0), p = d(a, "className", 3, ""), k = A(a, [
11
- "$$slots",
12
- "$$events",
13
- "$$legacy",
14
- "brand",
15
- "showThemeToggle",
16
- "className",
17
- "children",
18
- "nav",
19
- "actions"
20
- ]), g = Z(!1);
21
- var s = la();
22
- M(s, () => ({
23
- class: `bg-white border-b border-gray-200 sticky top-0 z-50 ${// Brand click is now handled by the parent component
24
- // through event forwarding
25
- p() ?? ""}`,
26
- ...k
27
- }));
28
- var h = e(s), c = e(h), t = e(c), _ = e(t);
29
- _.__click = [ia];
30
- var n = e(_), f = r(t, 2), H = e(f), I = e(H);
31
- u(I, () => a.nav ?? y);
32
- var P = r(f, 2), J = e(P), C = e(J);
33
- u(C, () => a.actions ?? y);
34
- var K = r(C, 2);
35
- {
36
- var L = (i) => {
37
- F(i, {});
38
- };
39
- w(K, (i) => {
40
- x() && i(L);
41
- });
42
- }
43
- var O = r(P, 2), Q = e(O);
44
- Q.__click = [sa, g];
45
- var R = r(c, 2);
46
- {
47
- var S = (i) => {
48
- var z = va(), U = e(z), B = e(U);
49
- u(B, () => a.nav ?? y);
50
- var V = r(B, 2), D = e(V);
51
- u(D, () => a.actions ?? y);
52
- var W = r(D, 2);
53
- {
54
- var X = (T) => {
55
- var j = ra(), Y = e(j);
56
- F(Y, {}), b(T, j);
57
- };
58
- w(W, (T) => {
59
- x() && T(X);
60
- });
61
- }
62
- b(i, z);
63
- };
64
- w(R, (i) => {
65
- o(g) && i(S);
66
- });
67
- }
68
- N(() => E(n, l())), b(v, s);
69
- }
70
- G(["click"]);
71
- var na = (v, a, l) => a(o(l), v), da = m("<li><a> </a></li>"), oa = m("<nav><ul></ul></nav>");
72
- function ma(v, a) {
73
- let l = d(a, "variant", 3, "header"), x = d(a, "items", 19, () => []), p = d(a, "currentPath", 3, ""), k = A(a, [
74
- "$$slots",
75
- "$$events",
76
- "$$legacy",
77
- "variant",
78
- "items",
79
- "currentPath",
80
- "children"
81
- ]);
82
- function g(c, t) {
83
- t.preventDefault();
84
- }
85
- var s = oa();
86
- M(s, () => ({
87
- class: `navigation navigation-${l() ?? ""}`,
88
- ...k
89
- }));
90
- var h = e(s);
91
- aa(h, 21, x, ea, (c, t) => {
92
- var _ = da(), n = e(_);
93
- n.__click = [na, g, t];
94
- var f = e(n);
95
- N(() => {
96
- ta(n, "href", o(t).href), q(n, 1, `px-3 py-2 text-sm font-medium rounded-md transition-colors ${p() === o(t).href ? "bg-blue-100 text-blue-700" : "text-gray-600 hover:text-gray-900 hover:bg-gray-100"}`), E(f, o(t).label);
97
- }), b(c, _);
98
- }), N(() => q(h, 1, `flex ${l() === "sidebar" ? "flex-col space-y-2" : "space-x-6"}`)), b(v, s);
99
- }
100
- G(["click"]);
101
- export {
102
- ba as Navbar,
103
- ma as Navigation
104
- };
1
+ "use strict";
2
+ // Export organism components - Temporarily disabled to avoid SSR issues
@@ -0,0 +1,57 @@
1
+ // SSR-safe utilities for zabi-components
2
+ // This ensures components work properly during server-side rendering
3
+
4
+ // Check if we're in a browser environment
5
+ export function isBrowser(): boolean {
6
+ return typeof window !== 'undefined';
7
+ }
8
+
9
+ export function safeWindow(): Window | undefined {
10
+ return isBrowser() ? window : undefined;
11
+ }
12
+
13
+ export function safeDocument(): Document | undefined {
14
+ return isBrowser() ? document : undefined;
15
+ }
16
+
17
+ export function safeLocalStorage(): Storage | undefined {
18
+ return isBrowser() ? localStorage : undefined;
19
+ }
20
+
21
+ export function safeSessionStorage(): Storage | undefined {
22
+ return isBrowser() ? sessionStorage : undefined;
23
+ }
24
+
25
+ export function safeRequestAnimationFrame(callback: FrameRequestCallback): number | undefined {
26
+ return isBrowser() ? requestAnimationFrame(callback) : undefined;
27
+ }
28
+
29
+ export function safeSetTimeout(callback: () => void, delay: number): NodeJS.Timeout | undefined {
30
+ return isBrowser() ? setTimeout(callback, delay) : undefined;
31
+ }
32
+
33
+ export function safeClearTimeout(id: NodeJS.Timeout | undefined): void {
34
+ if (isBrowser() && id) {
35
+ clearTimeout(id);
36
+ }
37
+ }
38
+
39
+ export function safeSetInterval(callback: () => void, delay: number): NodeJS.Timeout | undefined {
40
+ return isBrowser() ? setInterval(callback, delay) : undefined;
41
+ }
42
+
43
+ export function safeClearInterval(id: NodeJS.Timeout | undefined): void {
44
+ if (isBrowser() && id) {
45
+ clearInterval(id);
46
+ }
47
+ }
48
+
49
+ // Generate SSR-safe unique IDs
50
+ let idCounter = 0;
51
+ export function generateId(prefix: string = 'id'): string {
52
+ if (isBrowser()) {
53
+ return `${prefix}-${Math.random().toString(36).substr(2, 9)}`;
54
+ } else {
55
+ return `${prefix}-ssr-${++idCounter}`;
56
+ }
57
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Utility functions for handling component variants with semantic colors
3
+ */
4
+
5
+ export type Variant = 'default' | 'success' | 'warning' | 'error' | 'info';
6
+
7
+ /**
8
+ * Get variant classes for input components (Input, Textarea)
9
+ */
10
+ export function getInputVariantClasses(variant: Variant): string {
11
+ const variantMap: Record<Variant, string> = {
12
+ default: 'border-gray-300 focus:border-blue-500 focus:ring-blue-500',
13
+ success: 'border-green-300 focus:border-green-500 focus:ring-green-500',
14
+ warning: 'border-yellow-300 focus:border-yellow-500 focus:ring-yellow-500',
15
+ error: 'border-red-300 focus:border-red-500 focus:ring-red-500',
16
+ info: 'border-blue-300 focus:border-blue-500 focus:ring-blue-500',
17
+ };
18
+
19
+ return variantMap[variant] || variantMap.default;
20
+ }
21
+
22
+ /**
23
+ * Get variant classes for card components
24
+ */
25
+ export function getCardVariantClasses(variant: Variant): string {
26
+ const variantMap: Record<Variant, string> = {
27
+ default: 'border-gray-200 bg-white',
28
+ success: 'border-green-200 bg-green-50',
29
+ warning: 'border-yellow-200 bg-yellow-50',
30
+ error: 'border-red-200 bg-red-50',
31
+ info: 'border-blue-200 bg-blue-50',
32
+ };
33
+
34
+ return variantMap[variant] || variantMap.default;
35
+ }
36
+
37
+ /**
38
+ * Get generic variant classes for any component
39
+ */
40
+ export function getVariantClasses(variant: Variant, type: 'border' | 'text' | 'bg'): string {
41
+ const variantMap: Record<Variant, Record<'border' | 'text' | 'bg', string>> = {
42
+ default: {
43
+ border: 'border-gray-300',
44
+ text: 'text-gray-900',
45
+ bg: 'bg-white'
46
+ },
47
+ success: {
48
+ border: 'border-green-300',
49
+ text: 'text-green-900',
50
+ bg: 'bg-green-50'
51
+ },
52
+ warning: {
53
+ border: 'border-yellow-300',
54
+ text: 'text-yellow-900',
55
+ bg: 'bg-yellow-50'
56
+ },
57
+ error: {
58
+ border: 'border-red-300',
59
+ text: 'text-red-900',
60
+ bg: 'bg-red-50'
61
+ },
62
+ info: {
63
+ border: 'border-blue-300',
64
+ text: 'text-blue-900',
65
+ bg: 'bg-blue-50'
66
+ },
67
+ };
68
+
69
+ return variantMap[variant]?.[type] || variantMap.default[type];
70
+ }
71
+
72
+ /**
73
+ * Get all variant classes for a component (border, text, background)
74
+ */
75
+ export function getAllVariantClasses(variant: Variant): {
76
+ border: string;
77
+ text: string;
78
+ bg: string;
79
+ } {
80
+ return {
81
+ border: getVariantClasses(variant, 'border'),
82
+ text: getVariantClasses(variant, 'text'),
83
+ bg: getVariantClasses(variant, 'bg'),
84
+ };
85
+ }
86
+
87
+ /**
88
+ * Create a variant class map for use in reactive statements
89
+ */
90
+ export function createVariantClassMap<T extends string>(
91
+ variants: T[],
92
+ prefix: string
93
+ ): Record<T, string> {
94
+ return variants.reduce((acc, variant) => {
95
+ acc[variant] = `${prefix}-${variant}`;
96
+ return acc;
97
+ }, {} as Record<T, string>);
98
+ }