@damarkuncoro/layout-engine 0.1.0 → 0.1.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 (132) hide show
  1. package/README.md +16 -2
  2. package/lib/cjs/core/index.js +19 -0
  3. package/lib/cjs/core/render.js +45 -0
  4. package/lib/cjs/core/responsiveSystem.js +45 -0
  5. package/lib/cjs/core/spacingSystem.js +21 -0
  6. package/lib/cjs/core/styleResolver.js +14 -0
  7. package/lib/cjs/index.d.ts +9 -0
  8. package/lib/cjs/index.js +28 -0
  9. package/lib/cjs/package.json +3 -0
  10. package/lib/cjs/patterns/AuthLayout.d.ts +17 -0
  11. package/lib/cjs/patterns/AuthLayout.js +34 -0
  12. package/lib/cjs/patterns/DashboardLayout.js +14 -0
  13. package/lib/cjs/patterns/LandingLayout.d.ts +20 -0
  14. package/lib/cjs/patterns/LandingLayout.js +42 -0
  15. package/lib/cjs/patterns/index.d.ts +3 -0
  16. package/lib/cjs/patterns/index.js +19 -0
  17. package/lib/cjs/presets/index.d.ts +1 -0
  18. package/lib/cjs/presets/index.js +17 -0
  19. package/lib/cjs/presets/presets.d.ts +159 -0
  20. package/lib/cjs/presets/presets.js +229 -0
  21. package/lib/cjs/primitives/Box.js +26 -0
  22. package/lib/cjs/primitives/Center.d.ts +10 -0
  23. package/lib/cjs/primitives/Center.js +7 -0
  24. package/lib/cjs/primitives/Container.d.ts +17 -0
  25. package/lib/cjs/primitives/Container.js +27 -0
  26. package/lib/cjs/primitives/Flex.js +30 -0
  27. package/lib/cjs/primitives/Grid.d.ts +16 -0
  28. package/lib/cjs/primitives/Grid.js +37 -0
  29. package/lib/cjs/primitives/Spacer.d.ts +19 -0
  30. package/lib/cjs/primitives/Spacer.js +20 -0
  31. package/lib/cjs/primitives/Stack.js +24 -0
  32. package/lib/cjs/primitives/index.d.ts +7 -0
  33. package/lib/cjs/primitives/index.js +23 -0
  34. package/lib/cjs/structures/HeaderContentFooter.d.ts +13 -0
  35. package/lib/cjs/structures/HeaderContentFooter.js +10 -0
  36. package/lib/cjs/structures/HeaderLayout.d.ts +14 -0
  37. package/lib/cjs/structures/HeaderLayout.js +24 -0
  38. package/lib/cjs/structures/SidebarLayout.js +19 -0
  39. package/lib/cjs/structures/SplitLayout.d.ts +18 -0
  40. package/lib/cjs/structures/SplitLayout.js +30 -0
  41. package/lib/cjs/structures/index.d.ts +4 -0
  42. package/lib/cjs/structures/index.js +20 -0
  43. package/{dist → lib/cjs}/system/contracts.d.ts +20 -0
  44. package/lib/cjs/system/contracts.js +2 -0
  45. package/{dist → lib/cjs}/system/index.d.ts +1 -0
  46. package/lib/cjs/system/index.js +19 -0
  47. package/lib/cjs/system/theme.d.ts +134 -0
  48. package/lib/cjs/system/theme.js +195 -0
  49. package/lib/cjs/system/types.js +2 -0
  50. package/lib/cjs/tests/basic.test.js +72 -0
  51. package/lib/cjs/tests/structures.test.js +59 -0
  52. package/lib/esm/core/index.js +3 -0
  53. package/lib/esm/core/render.d.ts +5 -0
  54. package/lib/esm/core/responsiveSystem.d.ts +11 -0
  55. package/lib/esm/core/spacingSystem.d.ts +2 -0
  56. package/lib/esm/core/styleResolver.d.ts +5 -0
  57. package/lib/esm/index.d.ts +9 -0
  58. package/lib/esm/index.js +9 -0
  59. package/lib/esm/patterns/AuthLayout.d.ts +17 -0
  60. package/lib/esm/patterns/AuthLayout.js +31 -0
  61. package/lib/esm/patterns/DashboardLayout.d.ts +8 -0
  62. package/lib/esm/patterns/LandingLayout.d.ts +20 -0
  63. package/lib/esm/patterns/LandingLayout.js +39 -0
  64. package/lib/esm/patterns/index.d.ts +3 -0
  65. package/lib/esm/patterns/index.js +3 -0
  66. package/lib/esm/presets/index.d.ts +1 -0
  67. package/lib/esm/presets/index.js +1 -0
  68. package/lib/esm/presets/presets.d.ts +159 -0
  69. package/lib/esm/presets/presets.js +214 -0
  70. package/lib/esm/primitives/Box.d.ts +15 -0
  71. package/lib/esm/primitives/Center.d.ts +10 -0
  72. package/lib/esm/primitives/Center.js +4 -0
  73. package/lib/esm/primitives/Container.d.ts +17 -0
  74. package/lib/esm/primitives/Container.js +24 -0
  75. package/lib/esm/primitives/Flex.d.ts +20 -0
  76. package/lib/esm/primitives/Grid.d.ts +16 -0
  77. package/{dist → lib/esm}/primitives/Grid.js +10 -3
  78. package/lib/esm/primitives/Spacer.d.ts +19 -0
  79. package/lib/esm/primitives/Spacer.js +17 -0
  80. package/lib/esm/primitives/Stack.d.ts +13 -0
  81. package/lib/esm/primitives/index.d.ts +7 -0
  82. package/lib/esm/primitives/index.js +7 -0
  83. package/lib/esm/structures/HeaderContentFooter.d.ts +13 -0
  84. package/lib/esm/structures/HeaderContentFooter.js +7 -0
  85. package/lib/esm/structures/HeaderLayout.d.ts +14 -0
  86. package/lib/esm/structures/HeaderLayout.js +21 -0
  87. package/lib/esm/structures/SidebarLayout.d.ts +13 -0
  88. package/lib/esm/structures/SplitLayout.d.ts +18 -0
  89. package/lib/esm/structures/SplitLayout.js +27 -0
  90. package/lib/esm/structures/index.d.ts +4 -0
  91. package/lib/esm/structures/index.js +4 -0
  92. package/lib/esm/system/contracts.d.ts +37 -0
  93. package/lib/esm/system/index.d.ts +3 -0
  94. package/{dist → lib/esm}/system/index.js +1 -0
  95. package/lib/esm/system/theme.d.ts +134 -0
  96. package/lib/esm/system/theme.js +190 -0
  97. package/lib/esm/system/types.d.ts +38 -0
  98. package/lib/esm/tests/basic.test.d.ts +1 -0
  99. package/lib/esm/tests/structures.test.d.ts +1 -0
  100. package/package.json +21 -13
  101. package/dist/index.d.ts +0 -12
  102. package/dist/index.js +0 -12
  103. package/dist/primitives/Grid.d.ts +0 -15
  104. package/dist/primitives/index.d.ts +0 -4
  105. package/dist/primitives/index.js +0 -4
  106. /package/{dist → lib/cjs}/core/index.d.ts +0 -0
  107. /package/{dist → lib/cjs}/core/render.d.ts +0 -0
  108. /package/{dist → lib/cjs}/core/responsiveSystem.d.ts +0 -0
  109. /package/{dist → lib/cjs}/core/spacingSystem.d.ts +0 -0
  110. /package/{dist → lib/cjs}/core/styleResolver.d.ts +0 -0
  111. /package/{dist → lib/cjs}/patterns/DashboardLayout.d.ts +0 -0
  112. /package/{dist → lib/cjs}/primitives/Box.d.ts +0 -0
  113. /package/{dist → lib/cjs}/primitives/Flex.d.ts +0 -0
  114. /package/{dist → lib/cjs}/primitives/Stack.d.ts +0 -0
  115. /package/{dist → lib/cjs}/structures/SidebarLayout.d.ts +0 -0
  116. /package/{dist → lib/cjs}/system/types.d.ts +0 -0
  117. /package/{dist → lib/cjs}/tests/basic.test.d.ts +0 -0
  118. /package/{dist → lib/cjs}/tests/structures.test.d.ts +0 -0
  119. /package/{dist/core/index.js → lib/esm/core/index.d.ts} +0 -0
  120. /package/{dist → lib/esm}/core/render.js +0 -0
  121. /package/{dist → lib/esm}/core/responsiveSystem.js +0 -0
  122. /package/{dist → lib/esm}/core/spacingSystem.js +0 -0
  123. /package/{dist → lib/esm}/core/styleResolver.js +0 -0
  124. /package/{dist → lib/esm}/patterns/DashboardLayout.js +0 -0
  125. /package/{dist → lib/esm}/primitives/Box.js +0 -0
  126. /package/{dist → lib/esm}/primitives/Flex.js +0 -0
  127. /package/{dist → lib/esm}/primitives/Stack.js +0 -0
  128. /package/{dist → lib/esm}/structures/SidebarLayout.js +0 -0
  129. /package/{dist → lib/esm}/system/contracts.js +0 -0
  130. /package/{dist → lib/esm}/system/types.js +0 -0
  131. /package/{dist → lib/esm}/tests/basic.test.js +0 -0
  132. /package/{dist → lib/esm}/tests/structures.test.js +0 -0
@@ -0,0 +1,21 @@
1
+ import { Flex } from "../primitives/Flex.js";
2
+ import { Box } from "../primitives/Box.js";
3
+ /**
4
+ * HeaderLayout - layout dengan header di atas dan content di bawah
5
+ */
6
+ export function HeaderLayout({ header, children, headerHeight = 64 }) {
7
+ return Flex({
8
+ direction: "column",
9
+ children: [
10
+ Box({
11
+ height: headerHeight,
12
+ style: { position: "sticky", top: 0, zIndex: 10 },
13
+ children: header
14
+ }),
15
+ Box({
16
+ style: { flex: 1 },
17
+ children
18
+ })
19
+ ]
20
+ });
21
+ }
@@ -0,0 +1,13 @@
1
+ import type { SidebarLayoutContract } from "../system/contracts.js";
2
+ import type { CSSLength, ResponsiveValue } from "../system/types.js";
3
+ export interface ResponsiveSidebarLayoutProps extends Omit<SidebarLayoutContract, "sidebarWidth"> {
4
+ sidebarWidth?: ResponsiveValue<CSSLength>;
5
+ viewportWidth?: number;
6
+ }
7
+ export declare function SidebarLayout({ sidebar, children, sidebarWidth, viewportWidth }: ResponsiveSidebarLayoutProps): {
8
+ type: string;
9
+ props: {
10
+ children: any;
11
+ style: Record<string, any>;
12
+ };
13
+ };
@@ -0,0 +1,18 @@
1
+ import type { CSSLength, ResponsiveValue } from "../system/types.js";
2
+ export interface SplitLayoutProps {
3
+ left: any;
4
+ right: any;
5
+ leftWidth?: CSSLength | ResponsiveValue<CSSLength>;
6
+ splitRatio?: string;
7
+ viewportWidth?: number;
8
+ }
9
+ /**
10
+ * SplitLayout - layout dua kolom (kiri/kanan)
11
+ */
12
+ export declare function SplitLayout({ left, right, leftWidth, splitRatio, viewportWidth }: SplitLayoutProps): {
13
+ type: string;
14
+ props: {
15
+ children: any;
16
+ style: Record<string, any>;
17
+ };
18
+ };
@@ -0,0 +1,27 @@
1
+ import { Flex } from "../primitives/Flex.js";
2
+ import { Box } from "../primitives/Box.js";
3
+ import { resolveResponsive } from "../core/responsiveSystem.js";
4
+ import { normalizeUnit } from "../core/styleResolver.js";
5
+ /**
6
+ * SplitLayout - layout dua kolom (kiri/kanan)
7
+ */
8
+ export function SplitLayout({ left, right, leftWidth, splitRatio = "50%", viewportWidth = 1024 }) {
9
+ var _a;
10
+ const resolvedWidth = leftWidth
11
+ ? normalizeUnit((_a = resolveResponsive(leftWidth, viewportWidth)) !== null && _a !== void 0 ? _a : splitRatio)
12
+ : splitRatio;
13
+ return Flex({
14
+ gap: 4,
15
+ children: [
16
+ Box({
17
+ width: resolvedWidth,
18
+ style: { flexShrink: 0 },
19
+ children: left
20
+ }),
21
+ Box({
22
+ style: { flex: 1 },
23
+ children: right
24
+ })
25
+ ]
26
+ });
27
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./SidebarLayout.js";
2
+ export * from "./HeaderLayout.js";
3
+ export * from "./SplitLayout.js";
4
+ export * from "./HeaderContentFooter.js";
@@ -0,0 +1,4 @@
1
+ export * from "./SidebarLayout.js";
2
+ export * from "./HeaderLayout.js";
3
+ export * from "./SplitLayout.js";
4
+ export * from "./HeaderContentFooter.js";
@@ -0,0 +1,37 @@
1
+ import type { CSSLength, HeadlessNode, ResponsiveValue } from "./types.js";
2
+ export type NodeLike = HeadlessNode | string | number | boolean | null | undefined;
3
+ export interface SidebarLayoutContract {
4
+ sidebar: NodeLike;
5
+ children: NodeLike;
6
+ sidebarWidth?: CSSLength | ResponsiveValue<CSSLength>;
7
+ viewportWidth?: number;
8
+ }
9
+ export interface HeaderLayoutContract {
10
+ header: NodeLike;
11
+ children: NodeLike;
12
+ }
13
+ export interface DashboardLayoutContract {
14
+ header: NodeLike;
15
+ sidebar: NodeLike;
16
+ children: NodeLike;
17
+ }
18
+ export interface SplitLayoutContract {
19
+ left: NodeLike;
20
+ right: NodeLike;
21
+ leftWidth?: CSSLength | ResponsiveValue<CSSLength>;
22
+ splitRatio?: string;
23
+ viewportWidth?: number;
24
+ }
25
+ export interface AuthLayoutContract {
26
+ children: NodeLike;
27
+ logo?: NodeLike;
28
+ subtitle?: string;
29
+ }
30
+ export interface LandingLayoutContract {
31
+ header?: NodeLike;
32
+ hero?: NodeLike;
33
+ features?: NodeLike;
34
+ pricing?: NodeLike;
35
+ footer?: NodeLike;
36
+ children?: NodeLike;
37
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./types.js";
2
+ export * from "./contracts.js";
3
+ export * from "./theme.js";
@@ -1,2 +1,3 @@
1
1
  export * from "./types.js";
2
2
  export * from "./contracts.js";
3
+ export * from "./theme.js";
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Theme System untuk layout-engine
3
+ * Menyediakan tokens untuk colors, typography, spacing, dan dark mode
4
+ */
5
+ /**
6
+ * Theme colors
7
+ */
8
+ export interface ThemeColors {
9
+ primary: string;
10
+ primaryHover: string;
11
+ primaryFg: string;
12
+ secondary: string;
13
+ secondaryHover: string;
14
+ secondaryFg: string;
15
+ bg: string;
16
+ bgSubtle: string;
17
+ bgMuted: string;
18
+ fg: string;
19
+ fgMuted: string;
20
+ fgSubtle: string;
21
+ border: string;
22
+ borderFocus: string;
23
+ success: string;
24
+ warning: string;
25
+ error: string;
26
+ info: string;
27
+ }
28
+ /**
29
+ * Theme typography
30
+ */
31
+ export interface ThemeTypography {
32
+ fontSans: string;
33
+ fontMono: string;
34
+ textXs: string;
35
+ textSm: string;
36
+ textBase: string;
37
+ textLg: string;
38
+ textXl: string;
39
+ text2xl: string;
40
+ text3xl: string;
41
+ text4xl: string;
42
+ fontNormal: number;
43
+ fontMedium: number;
44
+ fontSemibold: number;
45
+ fontBold: number;
46
+ leadingTight: number;
47
+ leadingNormal: number;
48
+ leadingRelaxed: number;
49
+ }
50
+ /**
51
+ * Theme border radii
52
+ */
53
+ export interface ThemeRadii {
54
+ radiusNone: string;
55
+ radiusSm: string;
56
+ radiusBase: string;
57
+ radiusMd: string;
58
+ radiusLg: string;
59
+ radiusXl: string;
60
+ radiusFull: string;
61
+ }
62
+ /**
63
+ * Theme shadows
64
+ */
65
+ export interface ThemeShadows {
66
+ shadowSm: string;
67
+ shadowBase: string;
68
+ shadowMd: string;
69
+ shadowLg: string;
70
+ shadowXl: string;
71
+ }
72
+ /**
73
+ * Theme spacing (spacing tokens)
74
+ */
75
+ export interface ThemeSpacing {
76
+ space0: string;
77
+ space1: string;
78
+ space2: string;
79
+ space3: string;
80
+ space4: string;
81
+ space5: string;
82
+ space6: string;
83
+ space8: string;
84
+ space10: string;
85
+ space12: string;
86
+ space16: string;
87
+ space20: string;
88
+ space24: string;
89
+ space32: string;
90
+ space40: string;
91
+ space48: string;
92
+ space64: string;
93
+ space80: string;
94
+ space96: string;
95
+ }
96
+ /**
97
+ * Theme breakpoints
98
+ */
99
+ export interface ThemeBreakpoints {
100
+ bpSm: number;
101
+ bpMd: number;
102
+ bpLg: number;
103
+ bpXl: number;
104
+ bp2xl: number;
105
+ }
106
+ /**
107
+ * Complete theme type
108
+ */
109
+ export interface Theme extends ThemeColors, ThemeTypography, ThemeRadii, ThemeShadows, ThemeSpacing, ThemeBreakpoints {
110
+ }
111
+ /**
112
+ * Light theme
113
+ */
114
+ export declare const themeLight: Theme;
115
+ /**
116
+ * Dark theme
117
+ */
118
+ export declare const themeDark: Theme;
119
+ /**
120
+ * Default theme (light)
121
+ */
122
+ export declare const theme: Theme;
123
+ /**
124
+ * Color scheme type
125
+ */
126
+ export type ColorScheme = "light" | "dark" | "system";
127
+ /**
128
+ * Detect system color scheme preference
129
+ */
130
+ export declare function getSystemColorScheme(): "light" | "dark";
131
+ /**
132
+ * Get theme based on color scheme
133
+ */
134
+ export declare function getTheme(colorScheme?: ColorScheme): Theme;
@@ -0,0 +1,190 @@
1
+ /**
2
+ * Theme System untuk layout-engine
3
+ * Menyediakan tokens untuk colors, typography, spacing, dan dark mode
4
+ */
5
+ /**
6
+ * Light theme
7
+ */
8
+ export const themeLight = {
9
+ // Colors
10
+ primary: "#3b82f6",
11
+ primaryHover: "#2563eb",
12
+ primaryFg: "#ffffff",
13
+ secondary: "#64748b",
14
+ secondaryHover: "#475569",
15
+ secondaryFg: "#ffffff",
16
+ bg: "#ffffff",
17
+ bgSubtle: "#f8fafc",
18
+ bgMuted: "#f1f5f9",
19
+ fg: "#0f172a",
20
+ fgMuted: "#475569",
21
+ fgSubtle: "#94a3b8",
22
+ border: "#e2e8f0",
23
+ borderFocus: "#3b82f6",
24
+ success: "#22c55e",
25
+ warning: "#f59e0b",
26
+ error: "#ef4444",
27
+ info: "#3b82f6",
28
+ // Typography
29
+ fontSans: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
30
+ fontMono: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
31
+ textXs: "0.75rem",
32
+ textSm: "0.875rem",
33
+ textBase: "1rem",
34
+ textLg: "1.125rem",
35
+ textXl: "1.25rem",
36
+ text2xl: "1.5rem",
37
+ text3xl: "1.875rem",
38
+ text4xl: "2.25rem",
39
+ fontNormal: 400,
40
+ fontMedium: 500,
41
+ fontSemibold: 600,
42
+ fontBold: 700,
43
+ leadingTight: 1.25,
44
+ leadingNormal: 1.5,
45
+ leadingRelaxed: 1.625,
46
+ // Radii
47
+ radiusNone: "0",
48
+ radiusSm: "0.125rem",
49
+ radiusBase: "0.25rem",
50
+ radiusMd: "0.375rem",
51
+ radiusLg: "0.5rem",
52
+ radiusXl: "0.75rem",
53
+ radiusFull: "9999px",
54
+ // Shadows
55
+ shadowSm: "0 1px 2px 0 rgb(0 0 0 / 0.05)",
56
+ shadowBase: "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",
57
+ shadowMd: "0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1)",
58
+ shadowLg: "0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1)",
59
+ shadowXl: "0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1)",
60
+ // Spacing
61
+ space0: "0",
62
+ space1: "0.25rem",
63
+ space2: "0.5rem",
64
+ space3: "0.75rem",
65
+ space4: "1rem",
66
+ space5: "1.25rem",
67
+ space6: "1.5rem",
68
+ space8: "2rem",
69
+ space10: "2.5rem",
70
+ space12: "3rem",
71
+ space16: "4rem",
72
+ space20: "5rem",
73
+ space24: "6rem",
74
+ space32: "8rem",
75
+ space40: "10rem",
76
+ space48: "12rem",
77
+ space64: "16rem",
78
+ space80: "20rem",
79
+ space96: "24rem",
80
+ // Breakpoints
81
+ bpSm: 640,
82
+ bpMd: 768,
83
+ bpLg: 1024,
84
+ bpXl: 1280,
85
+ bp2xl: 1536,
86
+ };
87
+ /**
88
+ * Dark theme
89
+ */
90
+ export const themeDark = {
91
+ // Colors
92
+ primary: "#3b82f6",
93
+ primaryHover: "#60a5fa",
94
+ primaryFg: "#ffffff",
95
+ secondary: "#64748b",
96
+ secondaryHover: "#94a3b8",
97
+ secondaryFg: "#ffffff",
98
+ bg: "#0f172a",
99
+ bgSubtle: "#1e293b",
100
+ bgMuted: "#334155",
101
+ fg: "#f8fafc",
102
+ fgMuted: "#cbd5e1",
103
+ fgSubtle: "#64748b",
104
+ border: "#334155",
105
+ borderFocus: "#3b82f6",
106
+ success: "#22c55e",
107
+ warning: "#f59e0b",
108
+ error: "#ef4444",
109
+ info: "#3b82f6",
110
+ // Typography
111
+ fontSans: "system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif",
112
+ fontMono: "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",
113
+ textXs: "0.75rem",
114
+ textSm: "0.875rem",
115
+ textBase: "1rem",
116
+ textLg: "1.125rem",
117
+ textXl: "1.25rem",
118
+ text2xl: "1.5rem",
119
+ text3xl: "1.875rem",
120
+ text4xl: "2.25rem",
121
+ fontNormal: 400,
122
+ fontMedium: 500,
123
+ fontSemibold: 600,
124
+ fontBold: 700,
125
+ leadingTight: 1.25,
126
+ leadingNormal: 1.5,
127
+ leadingRelaxed: 1.625,
128
+ // Radii
129
+ radiusNone: "0",
130
+ radiusSm: "0.125rem",
131
+ radiusBase: "0.25rem",
132
+ radiusMd: "0.375rem",
133
+ radiusLg: "0.5rem",
134
+ radiusXl: "0.75rem",
135
+ radiusFull: "9999px",
136
+ // Shadows - lebih terang untuk dark mode
137
+ shadowSm: "0 1px 2px 0 rgb(0 0 0 / 0.3)",
138
+ shadowBase: "0 1px 3px 0 rgb(0 0 0 / 0.4), 0 1px 2px -1px rgb(0 0 0 / 0.4)",
139
+ shadowMd: "0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4)",
140
+ shadowLg: "0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4)",
141
+ shadowXl: "0 20px 25px -5px rgb(0 0 0 / 0.4), 0 8px 10px -6px rgb(0 0 0 / 0.4)",
142
+ // Spacing
143
+ space0: "0",
144
+ space1: "0.25rem",
145
+ space2: "0.5rem",
146
+ space3: "0.75rem",
147
+ space4: "1rem",
148
+ space5: "1.25rem",
149
+ space6: "1.5rem",
150
+ space8: "2rem",
151
+ space10: "2.5rem",
152
+ space12: "3rem",
153
+ space16: "4rem",
154
+ space20: "5rem",
155
+ space24: "6rem",
156
+ space32: "8rem",
157
+ space40: "10rem",
158
+ space48: "12rem",
159
+ space64: "16rem",
160
+ space80: "20rem",
161
+ space96: "24rem",
162
+ // Breakpoints
163
+ bpSm: 640,
164
+ bpMd: 768,
165
+ bpLg: 1024,
166
+ bpXl: 1280,
167
+ bp2xl: 1536,
168
+ };
169
+ /**
170
+ * Default theme (light)
171
+ */
172
+ export const theme = themeLight;
173
+ /**
174
+ * Detect system color scheme preference
175
+ */
176
+ export function getSystemColorScheme() {
177
+ var _a;
178
+ if (typeof window === "undefined")
179
+ return "light";
180
+ return ((_a = window.matchMedia) === null || _a === void 0 ? void 0 : _a.call(window, "(prefers-color-scheme: dark)").matches) ? "dark" : "light";
181
+ }
182
+ /**
183
+ * Get theme based on color scheme
184
+ */
185
+ export function getTheme(colorScheme = "system") {
186
+ if (colorScheme === "system") {
187
+ return getSystemColorScheme() === "dark" ? themeDark : themeLight;
188
+ }
189
+ return colorScheme === "dark" ? themeDark : themeLight;
190
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Tipe panjang CSS. Angka akan dinormalisasi ke 'px' oleh resolver.
3
+ */
4
+ export type CSSLength = number | string;
5
+ /**
6
+ * Responsive value that adapts based on viewport width.
7
+ */
8
+ export type ResponsiveValue<T> = T | {
9
+ base?: T;
10
+ sm?: T;
11
+ md?: T;
12
+ lg?: T;
13
+ xl?: T;
14
+ "2xl"?: T;
15
+ } | T[];
16
+ /**
17
+ * Props dasar untuk layout primitives.
18
+ * Hanya properti yang dipetakan ke style inline.
19
+ */
20
+ export interface LayoutProps {
21
+ padding?: CSSLength;
22
+ margin?: CSSLength;
23
+ width?: CSSLength;
24
+ height?: CSSLength;
25
+ display?: string;
26
+ style?: Record<string, any>;
27
+ }
28
+ /**
29
+ * Representasi node headless untuk renderer.
30
+ */
31
+ export interface HeadlessNode {
32
+ type: string;
33
+ props: {
34
+ style?: Record<string, any>;
35
+ children?: any;
36
+ [key: string]: any;
37
+ };
38
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@damarkuncoro/layout-engine",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Minimal layout engine primitives and resolvers",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
- "main": "dist/index.js",
8
- "module": "dist/index.js",
9
- "types": "dist/index.d.ts",
7
+ "main": "./lib/cjs/index.js",
8
+ "module": "./lib/esm/index.js",
9
+ "types": "./lib/esm/index.d.ts",
10
10
  "sideEffects": false,
11
11
  "files": [
12
- "dist"
12
+ "lib"
13
13
  ],
14
14
  "keywords": [
15
15
  "layout",
@@ -23,17 +23,25 @@
23
23
  },
24
24
  "exports": {
25
25
  ".": {
26
- "types": "./dist/index.d.ts",
27
- "import": "./dist/index.js"
28
- }
26
+ "types": "./lib/esm/index.d.ts",
27
+ "import": "./lib/esm/index.js",
28
+ "require": "./lib/cjs/index.js"
29
+ },
30
+ "./package.json": "./package.json"
29
31
  },
30
- "scripts": {
31
- "build": "tsc -p tsconfig.json",
32
- "typecheck": "tsc -p tsconfig.json --noEmit",
33
- "test": "npm run build && node dist/tests/basic.test.js && node dist/tests/structures.test.js"
32
+ "publishConfig": {
33
+ "access": "public"
34
34
  },
35
35
  "peerDependencies": {},
36
36
  "devDependencies": {
37
37
  "typescript": "^5.4.0"
38
+ },
39
+ "scripts": {
40
+ "build:esm": "tsc -p tsconfig.esm.json",
41
+ "build:cjs": "tsc -p tsconfig.cjs.json",
42
+ "postbuild:cjs": "node scripts/ensure-cjs.js",
43
+ "build": "npm run build:esm && npm run build:cjs && npm run postbuild:cjs",
44
+ "typecheck": "tsc -p tsconfig.json --noEmit",
45
+ "test": "npm run build && node lib/esm/tests/basic.test.js && node lib/esm/tests/structures.test.js"
38
46
  }
39
- }
47
+ }
package/dist/index.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export * from "./core/styleResolver.js";
2
- export * from "./core/spacingSystem.js";
3
- export { resolveResponsive, breakpoints, type BreakpointKey } from "./core/responsiveSystem.js";
4
- export * from "./core/render.js";
5
- export * from "./system/types.js";
6
- export * from "./system/contracts.js";
7
- export { Box, type LayoutProps } from "./primitives/Box.js";
8
- export { Flex, type FlexProps } from "./primitives/Flex.js";
9
- export { Stack, type StackProps } from "./primitives/Stack.js";
10
- export { Grid, type GridProps } from "./primitives/Grid.js";
11
- export { SidebarLayout, type ResponsiveSidebarLayoutProps } from "./structures/SidebarLayout.js";
12
- export * from "./patterns/DashboardLayout.js";
package/dist/index.js DELETED
@@ -1,12 +0,0 @@
1
- export * from "./core/styleResolver.js";
2
- export * from "./core/spacingSystem.js";
3
- export { resolveResponsive, breakpoints } from "./core/responsiveSystem.js";
4
- export * from "./core/render.js";
5
- export * from "./system/types.js";
6
- export * from "./system/contracts.js";
7
- export { Box } from "./primitives/Box.js";
8
- export { Flex } from "./primitives/Flex.js";
9
- export { Stack } from "./primitives/Stack.js";
10
- export { Grid } from "./primitives/Grid.js";
11
- export { SidebarLayout } from "./structures/SidebarLayout.js";
12
- export * from "./patterns/DashboardLayout.js";
@@ -1,15 +0,0 @@
1
- import type { CSSLength, LayoutProps } from "../system/types.js";
2
- export interface GridProps extends LayoutProps {
3
- columns?: number | string;
4
- rows?: number | string;
5
- gap?: CSSLength;
6
- }
7
- export declare function Grid({ children, columns, rows, gap, padding, margin, width, height, display, style, ...rest }: GridProps & {
8
- children?: any;
9
- }): {
10
- type: string;
11
- props: {
12
- children: any;
13
- style: Record<string, any>;
14
- };
15
- };
@@ -1,4 +0,0 @@
1
- export * from "./Box";
2
- export * from "./Flex";
3
- export * from "./Grid";
4
- export * from "./Stack";
@@ -1,4 +0,0 @@
1
- export * from "./Box";
2
- export * from "./Flex";
3
- export * from "./Grid";
4
- export * from "./Stack";
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes