@danielito1996/compose-svelted 0.0.1 → 0.2.0

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 (118) hide show
  1. package/README.md +113 -274
  2. package/dist/components/ContentScale.d.ts +10 -0
  3. package/dist/components/layouts/Alignment.d.ts +20 -0
  4. package/dist/components/layouts/Arrangement.d.ts +23 -0
  5. package/{src/lib/components/textFields/TextFieldColors.ts → dist/components/textFields/TextFieldColors.d.ts} +12 -11
  6. package/dist/components/textFields/TextFieldDefaults.d.ts +11 -0
  7. package/dist/core/elevation/elevation.d.ts +1 -0
  8. package/dist/core/helpers/painterResource.d.ts +12 -0
  9. package/{src/lib/core/modifier/Modifier.ts → dist/core/modifier/Modifier.d.ts} +195 -259
  10. package/dist/core/modifier/ModifierImpl.d.ts +38 -0
  11. package/dist/core/motion/AnimationSpec.d.ts +6 -0
  12. package/dist/core/motion/ContentTransition.d.ts +5 -0
  13. package/dist/core/motion/contentTransitions.d.ts +4 -0
  14. package/dist/core/motion/transitions.d.ts +7 -0
  15. package/dist/core/navigation/NavBackStackEntry.d.ts +4 -0
  16. package/dist/core/navigation/NavController.d.ts +8 -0
  17. package/dist/core/navigation/NavStore.d.ts +6 -0
  18. package/dist/core/navigation/Route.d.ts +3 -0
  19. package/dist/core/navigation/composable.d.ts +5 -0
  20. package/dist/core/navigation/rememberNavController.d.ts +2 -0
  21. package/dist/core/shapes/RoundedCornerShape.d.ts +13 -0
  22. package/{src/lib/core/shapes/Shape.ts → dist/core/shapes/Shape.d.ts} +3 -3
  23. package/dist/core/theme/ColorScheme.d.ts +17 -0
  24. package/dist/core/theme/Density.d.ts +5 -0
  25. package/dist/core/theme/TextStyle.d.ts +19 -0
  26. package/{src/lib/core/theme/colors.ts → dist/core/theme/colors.d.ts} +15 -21
  27. package/dist/core/theme/cssVars.d.ts +2 -0
  28. package/dist/core/theme/defaults/darkColors.d.ts +2 -0
  29. package/dist/core/theme/defaults/defaultTheme.d.ts +3 -0
  30. package/dist/core/theme/defaults/lightColors.d.ts +2 -0
  31. package/dist/core/theme/defaults/typography.d.ts +2 -0
  32. package/{src/lib/core/theme/elevation.ts → dist/core/theme/elevation.d.ts} +7 -7
  33. package/dist/core/theme/getCurrentColor.d.ts +1 -0
  34. package/dist/core/theme/resolve.d.ts +5 -0
  35. package/{src/lib/core/theme/shapes.ts → dist/core/theme/shapes.d.ts} +7 -7
  36. package/{src/lib/core/theme/spacing.ts → dist/core/theme/spacing.d.ts} +7 -7
  37. package/dist/core/theme/store.d.ts +2 -0
  38. package/dist/core/theme/systemTheme.d.ts +2 -0
  39. package/{src/lib/core/theme/theme.ts → dist/core/theme/theme.d.ts} +13 -15
  40. package/{src/lib/core/theme/typography.ts → dist/core/theme/typography.d.ts} +24 -29
  41. package/dist/index.d.ts +152 -0
  42. package/dist/index.js +1164 -0
  43. package/package.json +9 -35
  44. package/.vscode/extensions.json +0 -3
  45. package/docs/assets/components/button/button.png +0 -0
  46. package/docs/assets/components/surface/surface_simple.png +0 -0
  47. package/docs/assets/components/text/text.png +0 -0
  48. package/docs/assets/components/textfield/textfield_simple.png +0 -0
  49. package/docs/assets/svelted.png +0 -0
  50. package/docs/assets/svelted.svg +0 -41
  51. package/docs/getting_started.md +0 -116
  52. package/docs/index.md +0 -106
  53. package/index.html +0 -14
  54. package/screenshots/Captura de pantalla 2025-12-20 022710.png +0 -0
  55. package/screenshots/capturas.txt +0 -1
  56. package/src/App.svelte +0 -39
  57. package/src/app.css +0 -23
  58. package/src/assets/img/hav3m.png +0 -0
  59. package/src/assets/img/vessel.jpg +0 -0
  60. package/src/assets/raw/boat.svg +0 -15
  61. package/src/assets/raw/cash.svg +0 -39
  62. package/src/assets/raw/police.json +0 -1
  63. package/src/assets/raw/svelte.svg +0 -1
  64. package/src/lib/Counter.svelte +0 -10
  65. package/src/lib/components/AppRoot.svelte +0 -15
  66. package/src/lib/components/ContentScale.ts +0 -12
  67. package/src/lib/components/Icon.svelte +0 -47
  68. package/src/lib/components/Image.svelte +0 -31
  69. package/src/lib/components/Spacer.svelte +0 -11
  70. package/src/lib/components/Surface.svelte +0 -19
  71. package/src/lib/components/Text.svelte +0 -23
  72. package/src/lib/components/TonalButton.svelte +0 -34
  73. package/src/lib/components/buttons/Button.svelte +0 -34
  74. package/src/lib/components/buttons/IconButton.svelte +0 -0
  75. package/src/lib/components/buttons/OutlinedButton.svelte +0 -0
  76. package/src/lib/components/buttons/OutlinedButtonWithIcon.svelte +0 -0
  77. package/src/lib/components/buttons/OutlinedIconButton.svelte +0 -0
  78. package/src/lib/components/buttons/TextButton.svelte +0 -0
  79. package/src/lib/components/cards/Card.svelte +0 -0
  80. package/src/lib/components/cards/OutlinedCard.svelte +0 -0
  81. package/src/lib/components/layouts/Alignment.ts +0 -37
  82. package/src/lib/components/layouts/Arrangement.ts +0 -66
  83. package/src/lib/components/layouts/Box.svelte +0 -25
  84. package/src/lib/components/layouts/Column.svelte +0 -23
  85. package/src/lib/components/layouts/LazyColumn.svelte +0 -0
  86. package/src/lib/components/layouts/LazyRow.svelte +0 -0
  87. package/src/lib/components/layouts/Row.svelte +0 -23
  88. package/src/lib/components/layouts/Scafold.svelte +0 -0
  89. package/src/lib/components/menus/DropdownMenu.svelte +0 -0
  90. package/src/lib/components/menus/DropdownMenuItem.svelte +0 -0
  91. package/src/lib/components/textFields/BaseTextField.svelte +0 -130
  92. package/src/lib/components/textFields/OutlinedTextField.svelte +0 -52
  93. package/src/lib/components/textFields/TextField.svelte +0 -36
  94. package/src/lib/components/textFields/TextFieldDefaults.ts +0 -48
  95. package/src/lib/core/helpers/painterResource.ts +0 -26
  96. package/src/lib/core/modifier/ModifierImpl.ts +0 -275
  97. package/src/lib/core/shapes/RoundedCornerShape.ts +0 -53
  98. package/src/lib/core/theme/ColorScheme.ts +0 -25
  99. package/src/lib/core/theme/ComposeTheme.svelte +0 -22
  100. package/src/lib/core/theme/TextStyle.ts +0 -25
  101. package/src/lib/core/theme/cssVars.ts +0 -32
  102. package/src/lib/core/theme/defaults/darkColors.ts +0 -17
  103. package/src/lib/core/theme/defaults/defaultTheme.ts +0 -35
  104. package/src/lib/core/theme/defaults/lightColors.ts +0 -17
  105. package/src/lib/core/theme/defaults/typography.ts +0 -128
  106. package/src/lib/core/theme/getCurrentColor.ts +0 -10
  107. package/src/lib/core/theme/resolve.ts +0 -29
  108. package/src/lib/core/theme/store.ts +0 -26
  109. package/src/lib/core/theme/systemTheme.ts +0 -20
  110. package/src/lib/index.ts +0 -42
  111. package/src/main.ts +0 -9
  112. package/svelte.config.js +0 -8
  113. package/tsconfig.app.json +0 -21
  114. package/tsconfig.json +0 -7
  115. package/tsconfig.node.json +0 -26
  116. package/vite.config.ts +0 -11
  117. /package/{src/lib/components/buttons/ButtonWithIcon.svelte → dist/core/motion/applyAnimation.d.ts} +0 -0
  118. /package/{public → dist}/vite.svg +0 -0
package/README.md CHANGED
@@ -1,274 +1,113 @@
1
- # Compose-like UI for Svelte
2
- <p align="start">
3
- <a href="https://www.npmjs.com/package/compose-svelte">
4
- <img src="https://img.shields.io/npm/v/svelted.svg" alt="npm version" />
5
- </a>
6
- <a href="https://www.npmjs.com/package/compose-svelte">
7
- <img src="https://img.shields.io/npm/dm/svelted.svg" alt="npm downloads" />
8
- </a>
9
- <a href="https://github.com/danielitoCode/compose-svelte/blob/main/LICENSE">
10
- <img src="https://img.shields.io/github/license/danielitoCode/compose-svelte" alt="license" />
11
- </a>
12
- <img src="https://img.shields.io/badge/status-alpha-orange" />
13
- <img src="https://img.shields.io/badge/version-0.0.1-blue" />
14
- </p>
15
-
16
- <p align="center">
17
- <img src="docs/assets/svelted.png" width="310" alt="ios" />
18
- </p>
19
-
20
-
21
- A Compose-inspired UI toolkit for **Svelte**, focused on explicit composition,
22
- immutable modifiers, and theme-driven design.
23
-
24
- Inspired by **Jetpack Compose**, built natively for the web using Svelte and
25
- standard web technologies.
26
-
27
- <p align="center">
28
- <img src="https://img.shields.io/badge/Svelte-FF3E00?logo=svelte&logoColor=white" />
29
- <img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white" />
30
- <img src="https://img.shields.io/badge/Jetpack%20Compose-inspired-4285F4" />
31
- </p>
32
-
33
- ---
34
-
35
- ## ✨ Goals
36
-
37
- - Explicit and predictable UI composition
38
- - Immutable, chainable `Modifier`s
39
- - Strong separation between core, layout and components
40
- - Theme-driven design (tokens, not raw CSS)
41
- - No virtual DOM abstractions
42
- - No hidden magic
43
-
44
- > This is **not** a Material clone.
45
- > It is a Compose-like system that can be styled beyond Material Design.
46
-
47
- ---
48
-
49
- ## Why Compose-like for Svelte?
50
-
51
- Jetpack Compose introduced a clear, explicit and composable mental model for UI.
52
- This project explores how that same philosophy translates to the web,
53
- using Svelte as a native, compiler-driven foundation.
54
-
55
- The goal is not to replicate Android UI,
56
- but to bring Compose’s clarity and composability to modern web applications.
57
-
58
- ## 🚀 Installation
59
-
60
- ```bash
61
- npm install compose-svelte
62
- ```
63
-
64
- ---
65
-
66
- ## 🧭 Minimal Example
67
-
68
- ```svelte
69
- <script>
70
- import {
71
- ComposeTheme,
72
- AppRoot,
73
- Surface,
74
- Text,
75
- Modifier
76
- } from "compose-svelte";
77
- </script>
78
-
79
- <ComposeTheme mode="system">
80
- <AppRoot>
81
- <Surface modifier={Modifier.fillMaxSize()}>
82
- <Text>Hello Compose</Text>
83
- </Surface>
84
- </AppRoot>
85
- </ComposeTheme>
86
- ```
87
-
88
- ---
89
-
90
- ## 🧱 Layout
91
-
92
- ### Column
93
-
94
- ```svelte
95
- <Column modifier={Modifier.padding(16)}>
96
- <Text textStyle="titleLarge">Title</Text>
97
- <Text>Body text</Text>
98
- </Column>
99
- ```
100
-
101
- ### Row
102
-
103
- ```svelte
104
- <Row horizontalArrangement={Arrangement.spacedBy(8)}>
105
- <Text>Left</Text>
106
- <Text>Right</Text>
107
- </Row>
108
- ```
109
-
110
- ### Box
111
-
112
- ```svelte
113
- <Box modifier={Modifier.size(120)}>
114
- <Text modifier={Modifier.align(Alignment.Center)}>Centered</Text>
115
- </Box>
116
- ```
117
-
118
- ---
119
-
120
- ## 🎨 Theme
121
-
122
- ### ComposeTheme
123
-
124
- Provides theming for the entire app.
125
-
126
- - Light / Dark / System modes
127
- - Tokens exposed as CSS variables
128
- - Inspired by MaterialTheme
129
-
130
- ```svelte
131
- <ComposeTheme mode="dark">
132
- <AppRoot>
133
- <Surface>
134
- <Text>Dark mode</Text>
135
- </Surface>
136
- </AppRoot>
137
- </ComposeTheme>
138
- ```
139
-
140
- ---
141
-
142
- ## 📝 TextField
143
-
144
- ### Filled
145
-
146
- ```svelte
147
- <TextField
148
- label="Email"
149
- placeholder="you@email.com"
150
- value={email}
151
- onValueChange={(v) => email = v}
152
- />
153
- ```
154
-
155
- ### Outlined
156
-
157
- ```svelte
158
- <OutlinedTextField
159
- label="Email"
160
- value={email}
161
- onValueChange={(v) => email = v}
162
- />
163
- ```
164
-
165
- ---
166
-
167
- ## 🔘 Buttons
168
-
169
- ```svelte
170
- <Button onClick={submit}>
171
- Submit
172
- </Button>
173
-
174
- <TextButton onClick={cancel}>
175
- Cancel
176
- </TextButton>
177
-
178
- <OutlinedButton>
179
- Outlined
180
- </OutlinedButton>
181
- ```
182
-
183
- ---
184
-
185
- ## 🧩 Modifiers
186
-
187
- Modifiers are immutable and chainable.
188
-
189
- ```ts
190
- Modifier
191
- .padding(16)
192
- .fillMaxWidth()
193
- .background(ColorScheme.Surface)
194
- ```
195
-
196
- ### Available categories
197
-
198
- - Layout: `size`, `width`, `height`, `fill`, `weight`
199
- - Spacing: `padding`, `margin`
200
- - Drawing: `background`, `border`, `clip`
201
- - Interaction: `clickable`
202
- - Transform: `offset`
203
- - Scroll: `verticalScroll`, `horizontalScroll`
204
-
205
- ---
206
-
207
- ## 🔲 Shapes
208
-
209
- ```ts
210
- RoundedCornerShape(12)
211
- RoundedCornerShape({ topStart: 16, topEnd: 16 })
212
- ```
213
-
214
- Shapes are value objects and reusable across components.
215
-
216
- ---
217
-
218
- ## 🎨 Theme Tokens
219
-
220
- ### ColorScheme
221
-
222
- ```ts
223
- ColorScheme.Primary
224
- ColorScheme.Surface
225
- ColorScheme.OnSurface
226
- ```
227
-
228
- ### TextStyle
229
-
230
- ```ts
231
- TextStyle.TitleLarge
232
- TextStyle.BodyMedium
233
- TextStyle.LabelSmall
234
- ```
235
-
236
- ---
237
-
238
- ## 🖼️ Images & Icons
239
-
240
- ```svelte
241
- <Image
242
- painter={painterResource(Res.image("logo.png"))}
243
- contentScale={ContentScale.Fit}
244
- />
245
-
246
- <Icon
247
- painter="https://api.iconify.design/mdi/home.svg"
248
- modifier={Modifier.size(24)}
249
- />
250
- ```
251
-
252
- ---
253
-
254
- ## 📦 Project Status
255
-
256
- - Core v0.0.1: stable
257
- - Layout system: stable
258
- - Theme system: stable
259
- - Modifiers: stable
260
- - Lazy layouts: experimental
261
-
262
- ---
263
-
264
- ## 🧠 Philosophy
265
-
266
- Clarity over cleverness.
267
-
268
- If something is not explicit, it is probably not part of the API.
269
-
270
- ---
271
-
272
- ## 📄 License
273
-
274
- MIT
1
+ # compose-svelted
2
+
3
+ <p align="center">
4
+ <img src="docs/assets/svelted.png" width="960" alt="compose-svelted" />
5
+ </p>
6
+
7
+ <p align="center">
8
+ <b>Compose-inspired UI framework for Svelte</b><br/>
9
+ Declarative layout · Immutable modifiers · Structural motion · Compose-like navigation
10
+ </p>
11
+
12
+ <p align="center">
13
+ <img src="https://img.shields.io/badge/status-alpha-orange" />
14
+ <img src="https://img.shields.io/badge/Svelte-FF3E00?logo=svelte&logoColor=white" />
15
+ <img src="https://img.shields.io/badge/TypeScript-3178C6?logo=typescript&logoColor=white" />
16
+ </p>
17
+
18
+ ---
19
+
20
+ ## ✨ What is compose-svelted?
21
+
22
+ **compose-svelted** is an experimental but ambitious UI framework that brings the
23
+ **Jetpack Compose mental model** to the Svelte ecosystem.
24
+
25
+ It is **not** a Material Design clone, and it is **not** a thin component library.
26
+
27
+ Instead, it focuses on:
28
+ - explicit UI composition
29
+ - predictable layout
30
+ - declarative motion
31
+ - navigation as state
32
+
33
+ All built on top of **Svelte**, without virtual DOM abstractions or hidden magic.
34
+
35
+ ---
36
+
37
+ ## 🧠 Core Philosophy
38
+
39
+ > UI is a function of state.
40
+ > Layout, motion, and navigation must be explicit and predictable.
41
+
42
+ Key ideas:
43
+ - No implicit behavior
44
+ - No global side effects
45
+ - No magic context you cannot reason about
46
+ - Everything composes
47
+
48
+ ---
49
+
50
+ ## 🧱 Library Structure (High-Level)
51
+
52
+ ### Core V1 Layout & Styling
53
+ - Column, Row, Box
54
+ - Modifier (immutable, chainable)
55
+ - Shapes
56
+ - Theme system
57
+ - Typography
58
+
59
+ ### Core V2 – Motion & Navigation (CLOSED)
60
+ - AnimatedVisibility
61
+ - AnimatedContent
62
+ - Declarative motion
63
+ - NavController
64
+ - NavHost
65
+ - Internal backstack
66
+
67
+ ---
68
+
69
+ ## 💪 Strengths
70
+
71
+ ### Explicit Layout
72
+ Layouts are predictable and composable.
73
+
74
+ ### Immutable Modifiers
75
+ Describe intent, not CSS.
76
+
77
+ ### Structural Motion
78
+ Motion is part of the UI structure.
79
+
80
+ ### Compose-like Navigation
81
+ Navigation without external routers.
82
+
83
+ ---
84
+
85
+ ## 🚀 Innovation
86
+
87
+ - Compose mental model on the web
88
+ - Navigation as state
89
+ - Motion as structure
90
+ - No virtual DOM abstraction
91
+
92
+ ---
93
+
94
+ ## 📦 Status
95
+
96
+ - Alpha
97
+ - Core V2 closed
98
+ - Core V3 planned
99
+
100
+ ---
101
+
102
+ ## 🔮 Roadmap
103
+
104
+ ### Core V3
105
+ - Nested navigation
106
+ - Directional transitions
107
+ - Shared elements
108
+
109
+ ---
110
+
111
+ ## 📄 License
112
+
113
+ MIT
@@ -0,0 +1,10 @@
1
+ export declare const ContentScale: {
2
+ readonly Crop: "cover";
3
+ readonly Fit: "contain";
4
+ readonly FillBounds: "fill";
5
+ readonly Inside: "contain";
6
+ readonly FillWidth: "fillWidth";
7
+ readonly FillHeight: "fillHeight";
8
+ readonly None: "none";
9
+ };
10
+ export type ContentScaleToken = typeof ContentScale[keyof typeof ContentScale];
@@ -0,0 +1,20 @@
1
+ export declare const Alignment: {
2
+ readonly Start: "flex-start";
3
+ readonly CenterHorizontally: "center";
4
+ readonly End: "flex-end";
5
+ readonly Top: "flex-start";
6
+ readonly CenterVertically: "center";
7
+ readonly Bottom: "flex-end";
8
+ readonly TopStart: "flex-start flex-start";
9
+ readonly TopCenter: "center flex-start";
10
+ readonly TopEnd: "flex-end flex-start";
11
+ readonly CenterStart: "flex-start center";
12
+ readonly Center: "center center";
13
+ readonly CenterEnd: "flex-end center";
14
+ readonly BottomStart: "flex-start flex-end";
15
+ readonly BottomCenter: "center flex-end";
16
+ readonly BottomEnd: "flex-end flex-end";
17
+ };
18
+ export type HorizontalAlignment = typeof Alignment.Start | typeof Alignment.CenterHorizontally | typeof Alignment.End;
19
+ export type VerticalAlignment = typeof Alignment.Top | typeof Alignment.CenterVertically | typeof Alignment.Bottom;
20
+ export type BoxAlignment = typeof Alignment[keyof typeof Alignment];
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Arrangement — eje principal (main axis)
3
+ * Fiel a Jetpack Compose
4
+ */
5
+ export type ArrangementValue = {
6
+ type: "static";
7
+ justifyContent: string;
8
+ } | {
9
+ type: "spaced";
10
+ gap: number;
11
+ justifyContent: string;
12
+ };
13
+ export declare const Arrangement: {
14
+ readonly Start: ArrangementValue;
15
+ readonly Center: ArrangementValue;
16
+ readonly End: ArrangementValue;
17
+ readonly Bottom: ArrangementValue;
18
+ readonly Top: ArrangementValue;
19
+ readonly SpaceBetween: ArrangementValue;
20
+ readonly SpaceAround: ArrangementValue;
21
+ readonly SpaceEvenly: ArrangementValue;
22
+ readonly spacedBy: (value: number) => ArrangementValue;
23
+ };
@@ -1,11 +1,12 @@
1
- export interface TextFieldColors {
2
- container: string;
3
- label: string;
4
- placeholder: string;
5
- text: string;
6
- cursor: string;
7
- indicatorFocused: string;
8
- indicatorUnfocused: string;
9
- borderFocused?: string;
10
- borderUnfocused?: string;
11
- }
1
+ export interface TextFieldColors {
2
+ container: string;
3
+ label: string;
4
+ placeholder: string;
5
+ text: string;
6
+ cursor: string;
7
+ indicatorFocused: string;
8
+ indicatorUnfocused: string;
9
+ borderFocused?: string;
10
+ borderUnfocused?: string;
11
+ error?: string;
12
+ }
@@ -0,0 +1,11 @@
1
+ import type { TextFieldColors } from "./TextFieldColors";
2
+ export declare const TextFieldDefaults: {
3
+ /**
4
+ * FilledTextField (Material default)
5
+ */
6
+ filledColors(): TextFieldColors;
7
+ /**
8
+ * OutlinedTextField
9
+ */
10
+ outlinedColors(): TextFieldColors;
11
+ };
@@ -0,0 +1 @@
1
+ export declare function elevationToShadow(value: number | string): string;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * painterResource - como en Jetpack Compose
3
+ * Carga un recurso local desde src/lib/assets/
4
+ * Soporta SVG (?raw para string) e imágenes (?url para URL)
5
+ */
6
+ export declare const Res: {
7
+ readonly raw: (fileName: string) => string;
8
+ readonly image: (fileName: string) => string;
9
+ readonly values: (fileName: string) => string;
10
+ readonly fonts: (fileName: string) => string;
11
+ };
12
+ export declare function painterResource(resourceName: string): string;