@danielito1996/compose-svelted 0.2.6 → 0.2.7-alpha02

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.
package/README.md CHANGED
@@ -1,113 +1,193 @@
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
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
+ ## ⚠️ CSS Baseline (Required)
112
+
113
+ Compose Svelted assumes a neutral CSS baseline.
114
+
115
+ You MUST include the following reset in your app:
116
+
117
+ ```css
118
+ *,
119
+ *::before,
120
+ *::after {
121
+ box-sizing: border-box;
122
+ }
123
+
124
+ html,
125
+ body {
126
+ margin: 0;
127
+ padding: 0;
128
+ min-height: 100vh;
129
+ }
130
+ ```
131
+
132
+ ## 📄 License
133
+
134
+ MIT
135
+
136
+ ---
137
+
138
+ ## ⚠️ CSS Baseline Requirement (Important)
139
+
140
+ Compose Svelted is **layout-deterministic**.
141
+
142
+ To guarantee consistent and predictable behavior of layout components such as
143
+ `Box`, `Column`, `Row`, `Surface`, `Scaffold`, and navigation containers,
144
+ a **neutral CSS baseline is required** in the host application.
145
+
146
+ This is **intentional** and mirrors the contract-based approach of **Jetpack Compose**.
147
+
148
+ ### Required baseline
149
+
150
+ You must include the following reset in your global styles:
151
+
152
+ ```css
153
+ *,
154
+ *::before,
155
+ *::after {
156
+ box-sizing: border-box;
157
+ }
158
+
159
+ html,
160
+ body {
161
+ margin: 0;
162
+ padding: 0;
163
+ min-height: 100vh;
164
+ }
165
+ ```
166
+
167
+ ### Why this matters
168
+
169
+ Compose Svelted does **not**:
170
+ - force global CSS
171
+ - inject layout styles silently
172
+ - assume browser defaults
173
+
174
+ Instead, it expects a minimal, explicit layout contract.
175
+ Without this baseline, layout behavior may vary between browsers or projects.
176
+
177
+ ### Tailwind CSS
178
+
179
+ Compose Svelted **does not require Tailwind CSS**.
180
+
181
+ Tailwind is used internally as an implementation detail for predictable styling,
182
+ but consumers of the library are **not required** to install or configure Tailwind.
183
+
184
+ ### Future (Core V3)
185
+
186
+ A reusable `baseline.css` helper will be provided as an **optional import**
187
+ to simplify adoption:
188
+
189
+ ```ts
190
+ import "@danielito1996/compose-svelted/baseline.css";
191
+ ```
192
+
193
+ This will remain optional and opt-in.
@@ -5,11 +5,8 @@
5
5
  </script>
6
6
 
7
7
  <div
8
- style={`
9
- width:100vw;
10
- height:100vh;
11
- ${modifier.toStyle()}
12
- `}
8
+ class="compose-relative"
9
+ style={`width:100vw;height:100vh;${modifier.toStyle()}`}
13
10
  >
14
11
  <slot />
15
12
  </div>
@@ -1,25 +1,47 @@
1
1
  <script lang="ts">
2
2
  import { Modifier } from "../../core/modifier/Modifier";
3
- import type {BoxAlignment} from "./Alignment";
3
+ import type { BoxAlignment } from "./Alignment";
4
+ import {resolveBoxAlignment} from "./resolveAlignment";
4
5
 
5
6
  export let modifier: Modifier = Modifier.empty();
6
7
  export let contentAlignment: BoxAlignment | undefined = undefined;
7
8
 
8
- $: contentStyle = contentAlignment ? alignmentToFlexStyle(contentAlignment) : "";
9
+ /**
10
+ * Box-level alignment:
11
+ * Alinea TODOS los hijos (Compose Box behavior)
12
+ */
13
+ function contentAlignmentStyle(alignment: BoxAlignment): string {
14
+ const [h, v = h] = alignment.split(" ");
9
15
 
10
- function alignmentToFlexStyle(alignment: BoxAlignment): string {
11
- const parts = alignment.split(" ");
12
- const horiz = parts[0] === "flex-start" ? "flex-start" : parts[0] === "flex-end" ? "flex-end" : "center";
13
- const vert = parts[1] || parts[0];
14
- const v = vert === "flex-start" ? "flex-start" : vert === "flex-end" ? "flex-end" : "center";
16
+ const justify =
17
+ h === "flex-start" ? "flex-start" :
18
+ h === "flex-end" ? "flex-end" :
19
+ "center";
15
20
 
16
- return `display:flex; align-items:${v}; justify-content:${horiz};`;
21
+ const align =
22
+ v === "flex-start" ? "flex-start" :
23
+ v === "flex-end" ? "flex-end" :
24
+ "center";
25
+
26
+ return `
27
+ display:flex;
28
+ justify-content:${justify};
29
+ align-items:${align};
30
+ `;
17
31
  }
18
32
  </script>
19
33
 
20
34
  <div
21
- class="relative"
22
- style={`${contentStyle} ${modifier.toStyle()}`}
35
+ class="compose-box"
36
+ style={`
37
+ position:relative;
38
+ ${contentAlignment ? contentAlignmentStyle(contentAlignment) : ""}
39
+ ${modifier.toStyle()}
40
+ `}
23
41
  >
24
- <slot />
42
+ <!--
43
+ Slot con scope:
44
+ Cada hijo puede traer su propio Modifier
45
+ -->
46
+ style={`position:relative;${modifier.toStyle()}`}
25
47
  </div>
@@ -13,20 +13,11 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
13
13
  };
14
14
  z_$$bindings?: Bindings;
15
15
  }
16
- type $$__sveltets_2_PropsWithChildren<Props, Slots> = Props & (Slots extends {
17
- default: any;
18
- } ? Props extends Record<string, never> ? any : {
19
- children?: any;
20
- } : {});
21
- declare const Box: $$__sveltets_2_IsomorphicComponent<$$__sveltets_2_PropsWithChildren<{
16
+ declare const Box: $$__sveltets_2_IsomorphicComponent<{
22
17
  modifier?: Modifier;
23
18
  contentAlignment?: BoxAlignment | undefined;
24
19
  }, {
25
- default: {};
26
- }>, {
27
20
  [evt: string]: CustomEvent<any>;
28
- }, {
29
- default: {};
30
- }, {}, string>;
21
+ }, {}, {}, string>;
31
22
  type Box = InstanceType<typeof Box>;
32
23
  export default Box;
@@ -4,20 +4,43 @@
4
4
  import { Arrangement } from "./Arrangement";
5
5
  import type { ArrangementValue } from "./Arrangement";
6
6
  import type { HorizontalAlignment } from "./Alignment";
7
+ import {resolveFlexAlignSelf} from "./resolveFlexAlignSelf";
7
8
 
8
9
  export let modifier: Modifier = Modifier.empty();
10
+
11
+ // Cross-axis (horizontal en Column)
9
12
  export let horizontalAlignment: HorizontalAlignment = Alignment.Start;
13
+
14
+ // Main-axis (vertical en Column)
10
15
  export let verticalArrangement: ArrangementValue = Arrangement.Start;
16
+
17
+ $: gapStyle =
18
+ verticalArrangement.type === "spaced"
19
+ ? `gap:${verticalArrangement.gap}px;`
20
+ : "";
11
21
  </script>
12
22
 
13
23
  <div
14
- class="flex flex-col"
24
+ class="compose-column"
15
25
  style={`
16
- align-items: ${horizontalAlignment};
17
- justify-content: ${verticalArrangement.justifyContent};
18
- ${verticalArrangement.type === "spaced" ? `gap:${verticalArrangement.gap}px;` : ""}
19
- ${modifier.toStyle()}
20
- `}
26
+ display: flex;
27
+ flex-direction: column;
28
+ align-items: ${horizontalAlignment};
29
+ justify-content: ${verticalArrangement.justifyContent};
30
+ ${gapStyle}
31
+ ${modifier.toStyle()}
32
+ `}
21
33
  >
22
- <slot />
34
+ <slot let:modifier>
35
+ <div
36
+ style={`
37
+ ${modifier?.getMeta().align
38
+ ? resolveFlexAlignSelf(modifier.getMeta().align)
39
+ : ""}
40
+ ${modifier?.toStyle()}
41
+ `}
42
+ >
43
+ <slot />
44
+ </div>
45
+ </slot>
23
46
  </div>
@@ -0,0 +1 @@
1
+ export type LayoutContext = "flex" | "box";
@@ -0,0 +1 @@
1
+ export {};
@@ -4,20 +4,43 @@
4
4
  import { Arrangement } from "./Arrangement";
5
5
  import type { ArrangementValue } from "./Arrangement";
6
6
  import type { VerticalAlignment } from "./Alignment";
7
+ import {resolveFlexAlignSelf} from "./resolveFlexAlignSelf";
7
8
 
8
9
  export let modifier: Modifier = Modifier.empty();
9
- export let verticalAlignment: VerticalAlignment = Alignment.Top;
10
+
11
+ // Cross-axis (vertical en Row)
12
+ export let verticalAlignment: VerticalAlignment = Alignment.CenterVertically;
13
+
14
+ // Main-axis (horizontal en Row)
10
15
  export let horizontalArrangement: ArrangementValue = Arrangement.Start;
16
+
17
+ $: gapStyle =
18
+ horizontalArrangement.type === "spaced"
19
+ ? `gap:${horizontalArrangement.gap}px;`
20
+ : "";
11
21
  </script>
12
22
 
13
23
  <div
14
- class="flex flex-row"
24
+ class="compose-row"
15
25
  style={`
16
- align-items: ${verticalAlignment};
17
- justify-content: ${horizontalArrangement.justifyContent};
18
- ${horizontalArrangement.type === "spaced" ? `gap:${horizontalArrangement.gap}px;` : ""}
19
- ${modifier.toStyle()}
20
- `}
26
+ display: flex;
27
+ flex-direction: row;
28
+ align-items: ${verticalAlignment};
29
+ justify-content: ${horizontalArrangement.justifyContent};
30
+ ${gapStyle}
31
+ ${modifier.toStyle()}
32
+ `}
21
33
  >
22
- <slot />
34
+ <slot let:modifier>
35
+ <div
36
+ style={`
37
+ ${modifier?.getMeta().align
38
+ ? resolveFlexAlignSelf(modifier.getMeta().align)
39
+ : ""}
40
+ ${modifier?.toStyle()}
41
+ `}
42
+ >
43
+ <slot />
44
+ </div>
45
+ </slot>
23
46
  </div>
@@ -0,0 +1,4 @@
1
+ import { ModifierImpl } from "../../core/modifier/ModifierImpl";
2
+ import { BoxAlignment } from "./Alignment";
3
+ export declare function resolveBoxAlignment(alignment?: BoxAlignment): string;
4
+ export declare function resolveFlexAlignment(mod: ModifierImpl): string;
@@ -0,0 +1,44 @@
1
+ /* =========================
2
+ * Box (position:absolute)
3
+ * ========================= */
4
+ export function resolveBoxAlignment(alignment) {
5
+ var _a;
6
+ if (!alignment)
7
+ return "";
8
+ var parts = alignment.split(" ");
9
+ var h = parts[0];
10
+ var v = (_a = parts[1]) !== null && _a !== void 0 ? _a : parts[0];
11
+ var style = "position:absolute;";
12
+ // Vertical
13
+ if (v === "flex-start")
14
+ style += "top:0;";
15
+ else if (v === "flex-end")
16
+ style += "bottom:0;";
17
+ else
18
+ style += "top:50%;";
19
+ // Horizontal
20
+ if (h === "flex-start")
21
+ style += "left:0;";
22
+ else if (h === "flex-end")
23
+ style += "right:0;";
24
+ else
25
+ style += "left:50%;";
26
+ if (h === "center" || v === "center") {
27
+ style += "transform:translate(-50%,-50%);";
28
+ }
29
+ return style;
30
+ }
31
+ /* =========================
32
+ * Flex (Row / Column)
33
+ * ========================= */
34
+ export function resolveFlexAlignment(mod) {
35
+ var align = mod.getMeta().align;
36
+ if (!align)
37
+ return "";
38
+ var horizontal = align.split(" ")[0];
39
+ return "\n align-self:".concat(horizontal === "center"
40
+ ? "center"
41
+ : horizontal === "flex-end"
42
+ ? "flex-end"
43
+ : "flex-start", ";\n ");
44
+ }
@@ -0,0 +1,2 @@
1
+ import { BoxAlignment } from "./Alignment";
2
+ export declare function resolveFlexAlignSelf(alignment: BoxAlignment): string;
@@ -0,0 +1,10 @@
1
+ export function resolveFlexAlignSelf(alignment) {
2
+ var _a;
3
+ var parts = alignment.split(" ");
4
+ var vertical = (_a = parts[1]) !== null && _a !== void 0 ? _a : parts[0];
5
+ if (vertical === "flex-start")
6
+ return "align-self:flex-start;";
7
+ if (vertical === "flex-end")
8
+ return "align-self:flex-end;";
9
+ return "align-self:center;";
10
+ }
@@ -1,38 +1,32 @@
1
1
  import type { BoxAlignment } from "../../components/layouts/Alignment";
2
2
  import type { Shape } from "../shapes/Shape";
3
3
  import type { ColorToken } from "../theme/ColorScheme";
4
+ export type ModifierMeta = {
5
+ align?: BoxAlignment;
6
+ };
4
7
  export type ModifierEntry = {
5
8
  className?: string;
6
9
  style?: string;
10
+ meta?: ModifierMeta;
7
11
  };
8
12
  export declare class ModifierImpl {
9
13
  private readonly entries;
10
14
  constructor(entries?: ModifierEntry[]);
11
15
  then(other: ModifierImpl): ModifierImpl;
12
- paddingHorizontal(value: number): ModifierImpl;
13
- verticalScroll(enabled?: boolean): ModifierImpl;
14
- horizontalScroll(enabled?: boolean): ModifierImpl;
15
- paddingVertical(value: number): ModifierImpl;
16
16
  fillMaxWidth(): ModifierImpl;
17
17
  fillMaxHeight(): ModifierImpl;
18
18
  fillMaxSize(): ModifierImpl;
19
- background(color: ColorToken | string): ModifierImpl;
20
19
  weight(weight: number, fill?: boolean): ModifierImpl;
21
- align(alignment: BoxAlignment): ModifierImpl;
22
- padding(valueOrParams?: number | {
23
- top?: number;
24
- bottom?: number;
25
- start?: number;
26
- end?: number;
27
- }, unit?: string): ModifierImpl;
28
- width(value: number | string, unit?: string): ModifierImpl;
29
- height(value: number | string, unit?: string): ModifierImpl;
30
- marginTop(value: number, unit?: string): ModifierImpl;
31
- clip(shape: Shape): ModifierImpl;
32
- size(value: number | string, unit?: string): ModifierImpl;
33
- offset(x: number, y: number): ModifierImpl;
34
- clickable(onClick: () => void): ModifierImpl;
20
+ padding(value: number): ModifierImpl;
21
+ paddingHorizontal(value: number): ModifierImpl;
22
+ paddingVertical(value: number): ModifierImpl;
23
+ marginTop(value: number): ModifierImpl;
24
+ background(color: ColorToken | string): ModifierImpl;
35
25
  border(width: number, color: string, shape?: Shape): ModifierImpl;
26
+ clip(shape: Shape): ModifierImpl;
27
+ align(alignment: BoxAlignment): ModifierImpl;
28
+ clickable(): ModifierImpl;
36
29
  toStyle(): string;
37
30
  toClass(): string;
31
+ getMeta(): ModifierMeta;
38
32
  }
@@ -1,3 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
2
13
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
3
14
  if (ar || !(i in from)) {
@@ -8,40 +19,19 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
8
19
  return to.concat(ar || Array.prototype.slice.call(from));
9
20
  };
10
21
  import { resolveColor } from "../theme/resolve";
22
+ /* =========================
23
+ * ModifierImpl
24
+ * ========================= */
11
25
  var ModifierImpl = /** @class */ (function () {
12
26
  function ModifierImpl(entries) {
13
27
  if (entries === void 0) { entries = []; }
14
28
  this.entries = entries;
15
29
  }
30
+ /* -------- composición -------- */
16
31
  ModifierImpl.prototype.then = function (other) {
17
32
  return new ModifierImpl(__spreadArray(__spreadArray([], this.entries, true), other.entries, true));
18
33
  };
19
- ModifierImpl.prototype.paddingHorizontal = function (value) {
20
- return this.then(new ModifierImpl([
21
- { style: "padding-left:".concat(value, "px;padding-right:").concat(value, "px;") },
22
- ]));
23
- };
24
- ModifierImpl.prototype.verticalScroll = function (enabled) {
25
- if (enabled === void 0) { enabled = true; }
26
- return this.then(new ModifierImpl([{
27
- style: enabled
28
- ? "overflow-y:auto;overflow-x:hidden;-webkit-overflow-scrolling:touch;"
29
- : ''
30
- }]));
31
- };
32
- ModifierImpl.prototype.horizontalScroll = function (enabled) {
33
- if (enabled === void 0) { enabled = true; }
34
- return this.then(new ModifierImpl([{
35
- style: enabled
36
- ? "overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;white-space:nowrap;"
37
- : ''
38
- }]));
39
- };
40
- ModifierImpl.prototype.paddingVertical = function (value) {
41
- return this.then(new ModifierImpl([
42
- { style: "padding-top:".concat(value, "px;padding-bottom:").concat(value, "px;") },
43
- ]));
44
- };
34
+ /* -------- layout size -------- */
45
35
  ModifierImpl.prototype.fillMaxWidth = function () {
46
36
  return this.then(new ModifierImpl([{ style: "width:100%;" }]));
47
37
  };
@@ -51,164 +41,86 @@ var ModifierImpl = /** @class */ (function () {
51
41
  ModifierImpl.prototype.fillMaxSize = function () {
52
42
  return this.then(new ModifierImpl([{ style: "width:100%;height:100%;" }]));
53
43
  };
54
- ModifierImpl.prototype.background = function (color) {
55
- var resolved;
56
- if (typeof color === "string" &&
57
- (color.startsWith("#") ||
58
- color.startsWith("rgb") ||
59
- color.startsWith("hsl") ||
60
- color === "transparent" ||
61
- color === "currentColor")) {
62
- // Color CSS directo
63
- resolved = color;
64
- }
65
- else {
66
- // Token de ComposeTheme
67
- resolved = resolveColor(color);
68
- }
69
- return this.then(new ModifierImpl([
70
- { style: "background:".concat(resolved, ";") }
71
- ]));
72
- };
73
44
  ModifierImpl.prototype.weight = function (weight, fill) {
74
45
  if (fill === void 0) { fill = true; }
75
- if (weight <= 0) {
76
- console.warn("Modifier.weight() debe ser > 0");
46
+ if (weight <= 0)
77
47
  return this;
78
- }
79
- var styleParts = [
80
- "flex-grow: ".concat(weight, ";"),
81
- "flex-shrink: ".concat(fill ? 1 : 0, ";"),
82
- "flex-basis: 0%;" // importante para que el peso funcione bien
83
- ];
84
- return this.then(new ModifierImpl([{ style: styleParts.join(" ") }]));
85
- };
86
- ModifierImpl.prototype.align = function (alignment) {
87
- var parts = alignment.split(' ');
88
- var horizontal = parts[0]; // flex-start, center, flex-end
89
- var vertical = parts[1] || parts[0]; // para casos simples como "center"
90
- var style = 'position: absolute;';
91
- // Vertical
92
- if (vertical === 'flex-start') {
93
- style += 'top: 0;';
94
- }
95
- else if (vertical === 'flex-end') {
96
- style += 'bottom: 0;';
97
- }
98
- else if (vertical === 'center') {
99
- style += 'top: 50%; transform: translateY(-50%);';
100
- }
101
- // Horizontal
102
- if (horizontal === 'flex-start') {
103
- style += 'left: 0;';
104
- }
105
- else if (horizontal === 'flex-end') {
106
- style += 'right: 0;';
107
- }
108
- else if (horizontal === 'center') {
109
- style += 'left: 50%;';
110
- // Combinar transform si ya hay translateY
111
- if (style.includes('translateY')) {
112
- style = style.replace('translateY(-50%)', 'translate(-50%, -50%)');
113
- }
114
- else {
115
- style += 'transform: translateX(-50%);';
116
- }
117
- }
118
- return this.then(new ModifierImpl([{ style: style }]));
119
- };
120
- ModifierImpl.prototype.padding = function (valueOrParams, unit) {
121
- if (valueOrParams === void 0) { valueOrParams = 0; }
122
- if (unit === void 0) { unit = 'px'; }
123
- var style = '';
124
- if (typeof valueOrParams === 'number') {
125
- // Padding uniforme
126
- style = "padding:".concat(valueOrParams).concat(unit, ";");
127
- }
128
- else {
129
- // Padding direccional
130
- var _a = valueOrParams.top, top = _a === void 0 ? 0 : _a, _b = valueOrParams.bottom, bottom = _b === void 0 ? 0 : _b, _c = valueOrParams.start, start = _c === void 0 ? 0 : _c, _d = valueOrParams.end, end = _d === void 0 ? 0 : _d;
131
- style = "\n padding-top:".concat(top).concat(unit, ";\n padding-bottom:").concat(bottom).concat(unit, ";\n padding-left:").concat(start).concat(unit, ";\n //padding-right:").concat(end).concat(unit, ";\n ").trim();
132
- }
133
- return this.then(new ModifierImpl([{ style: style }]));
134
- };
135
- ModifierImpl.prototype.width = function (value, unit) {
136
- if (unit === void 0) { unit = 'px'; }
137
- var size = typeof value === 'number' ? "".concat(value).concat(unit) : value;
138
- return this.then(new ModifierImpl([{ style: "width:".concat(size, ";") }]));
48
+ return this.then(new ModifierImpl([
49
+ {
50
+ style: "\n flex-grow:".concat(weight, ";\n flex-shrink:").concat(fill ? 1 : 0, ";\n flex-basis:0%;\n "),
51
+ },
52
+ ]));
139
53
  };
140
- ModifierImpl.prototype.height = function (value, unit) {
141
- if (unit === void 0) { unit = 'px'; }
142
- var size = typeof value === 'number' ? "".concat(value).concat(unit) : value;
143
- return this.then(new ModifierImpl([{ style: "height:".concat(size, ";") }]));
54
+ /* -------- padding / margin -------- */
55
+ ModifierImpl.prototype.padding = function (value) {
56
+ return this.then(new ModifierImpl([{ style: "padding:".concat(value, "px;") }]));
144
57
  };
145
- ModifierImpl.prototype.marginTop = function (value, unit) {
146
- if (unit === void 0) { unit = 'px'; }
147
- return this.then(new ModifierImpl([{ style: "margin-top:".concat(value).concat(unit, ";") }]));
58
+ ModifierImpl.prototype.paddingHorizontal = function (value) {
59
+ return this.then(new ModifierImpl([
60
+ { style: "padding-left:".concat(value, "px;padding-right:").concat(value, "px;") },
61
+ ]));
148
62
  };
149
- ModifierImpl.prototype.clip = function (shape) {
63
+ ModifierImpl.prototype.paddingVertical = function (value) {
150
64
  return this.then(new ModifierImpl([
151
- {
152
- style: "\n border-radius:".concat(shape.toCssBorderRadius(), ";\n overflow:hidden;\n ")
153
- }
65
+ { style: "padding-top:".concat(value, "px;padding-bottom:").concat(value, "px;") },
154
66
  ]));
155
67
  };
156
- ModifierImpl.prototype.size = function (value, unit) {
157
- if (unit === void 0) { unit = "px"; }
158
- if (value === null || value === undefined) {
68
+ ModifierImpl.prototype.marginTop = function (value) {
69
+ return this.then(new ModifierImpl([{ style: "margin-top:".concat(value, "px;") }]));
70
+ };
71
+ /* -------- background / border -------- */
72
+ ModifierImpl.prototype.background = function (color) {
73
+ var resolved = typeof color === "string"
74
+ ? color
75
+ : resolveColor(color);
76
+ return this.then(new ModifierImpl([{ style: "background:".concat(resolved, ";") }]));
77
+ };
78
+ ModifierImpl.prototype.border = function (width, color, shape) {
79
+ if (width <= 0)
159
80
  return this;
160
- }
161
- var resolved;
162
- if (typeof value === "number") {
163
- if (isNaN(value))
164
- return this;
165
- resolved = "".concat(value).concat(unit);
166
- }
167
- else {
168
- if (value.trim() === "")
169
- return this;
170
- resolved = value;
171
- }
172
81
  return this.then(new ModifierImpl([
173
82
  {
174
- style: "width:".concat(resolved, ";height:").concat(resolved, ";")
175
- }
83
+ style: "\n border:".concat(width, "px solid ").concat(color, ";\n ").concat(shape ? "border-radius:".concat(shape.toCssBorderRadius(), ";") : "", "\n "),
84
+ },
176
85
  ]));
177
86
  };
178
- ModifierImpl.prototype.offset = function (x, y) {
179
- if (isNaN(x) || isNaN(y))
180
- return this;
87
+ ModifierImpl.prototype.clip = function (shape) {
181
88
  return this.then(new ModifierImpl([
182
89
  {
183
- style: "transform: translate(".concat(x, "px, ").concat(y, "px);")
184
- }
90
+ style: "\n border-radius:".concat(shape.toCssBorderRadius(), ";\n overflow:hidden;\n "),
91
+ },
185
92
  ]));
186
93
  };
187
- ModifierImpl.prototype.clickable = function (onClick) {
94
+ /* -------- posicionamiento semántico -------- */
95
+ ModifierImpl.prototype.align = function (alignment) {
188
96
  return this.then(new ModifierImpl([
189
97
  {
190
- className: "compose-clickable",
191
- style: "\n cursor: pointer;\n user-select: none;\n "
98
+ meta: { align: alignment }
192
99
  }
193
100
  ]));
194
101
  };
195
- ModifierImpl.prototype.border = function (width, color, shape) {
196
- if (width <= 0)
197
- return this;
198
- var radius = shape ? shape.toCssBorderRadius() : undefined;
102
+ /* -------- interacción -------- */
103
+ ModifierImpl.prototype.clickable = function () {
199
104
  return this.then(new ModifierImpl([
200
105
  {
201
- style: "\n border:".concat(width, "px solid ").concat(color, ";\n ").concat(radius ? "border-radius:".concat(radius, ";") : "", "\n ")
202
- }
106
+ className: "compose-clickable",
107
+ style: "cursor:pointer;user-select:none;",
108
+ },
203
109
  ]));
204
110
  };
205
- // ---- consumo interno ----
111
+ /* -------- consumo interno -------- */
206
112
  ModifierImpl.prototype.toStyle = function () {
207
113
  return this.entries.map(function (e) { var _a; return (_a = e.style) !== null && _a !== void 0 ? _a : ""; }).join("");
208
114
  };
209
115
  ModifierImpl.prototype.toClass = function () {
210
116
  return this.entries.map(function (e) { var _a; return (_a = e.className) !== null && _a !== void 0 ? _a : ""; }).join(" ");
211
117
  };
118
+ ModifierImpl.prototype.getMeta = function () {
119
+ return this.entries.reduce(function (acc, e) {
120
+ var _a;
121
+ return (__assign(__assign({}, acc), ((_a = e.meta) !== null && _a !== void 0 ? _a : {})));
122
+ }, {});
123
+ };
212
124
  return ModifierImpl;
213
125
  }());
214
126
  export { ModifierImpl };
package/dist/index.js ADDED
@@ -0,0 +1,51 @@
1
+ // Root
2
+ export { default as ComposeTheme } from "./core/theme/ComposeTheme.svelte";
3
+ export { default as AppRoot } from "./components/AppRoot.svelte";
4
+ // Layouts
5
+ export { default as Column } from "./components/layouts/Column.svelte";
6
+ export { default as Row } from "./components/layouts/Row.svelte";
7
+ export { default as Box } from "./components/layouts/Box.svelte";
8
+ export { default as Spacer } from "./components/Spacer.svelte";
9
+ export { default as LazyColumn } from "./components/layouts/LazyColumn.svelte";
10
+ export { default as LazyRow } from "./components/layouts/LazyRow.svelte";
11
+ export { default as Scaffold } from "./components/layouts/Scaffold.svelte";
12
+ // UI
13
+ export { default as Surface } from "./components/Surface.svelte";
14
+ export { default as Text } from "./components/Text.svelte";
15
+ export { default as Button } from "./components/buttons/Button.svelte";
16
+ export { default as TextButton } from "./components/buttons/TextButton.svelte";
17
+ export { default as TonalButton } from "./components/TonalButton.svelte";
18
+ export { default as IconButton } from "./components/buttons/IconButton.svelte";
19
+ export { default as ButtonWithIcon } from "./components/buttons/ButtonWithIcon.svelte";
20
+ export { default as OutlinedButton } from "./components/buttons/OutlinedButton.svelte";
21
+ export { default as OutlinedButtonWithIcon } from "./components/buttons/OutlinedButtonWithIcon.svelte";
22
+ export { default as CheckButton } from "./components/buttons/CheckButton.svelte";
23
+ export { default as Card } from "./components/cards/Card.svelte";
24
+ export { default as OutlinedCard } from "./components/cards/OutlinedCard.svelte";
25
+ export { default as TextField } from "./components/textFields/TextField.svelte";
26
+ export { default as OutlinedTextField } from "./components/textFields/OutlinedTextField.svelte";
27
+ export { default as Image } from "./components/Image.svelte";
28
+ export { default as Icon } from "./components/Icon.svelte";
29
+ // Motion
30
+ export { default as AnimatedVisibility } from "./components/motion/AnimatedVisibility.svelte";
31
+ export { default as AnimatedContent } from "./components/motion/AnimatedContent.svelte";
32
+ // Navigation
33
+ export { default as NavHost } from "./core/navigation/NavHost.svelte";
34
+ // Custom
35
+ export { default as CodeBlock } from "./components/custom/CodeBlock.svelte";
36
+ // TS-only exports
37
+ export * from "./core/modifier/Modifier";
38
+ export * from "./components/layouts/Alignment";
39
+ export * from "./components/layouts/Arrangement";
40
+ export * from "./components/ContentScale";
41
+ export * from "./core/theme/ColorScheme";
42
+ export * from "./core/theme/TextStyle";
43
+ export * from "./core/theme/Density";
44
+ export * from "./core/motion/AnimationSpec";
45
+ export * from "./core/motion/transitions";
46
+ export * from "./core/motion/contentTransitions";
47
+ export * from "./core/helpers/painterResource";
48
+ export * from "./core/navigation/Route";
49
+ export * from "./core/navigation/NavController";
50
+ export * from "./core/navigation/rememberNavController";
51
+ export * from "./core/navigation/composable";
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "@danielito1996/compose-svelted",
3
- "version": "0.2.6",
3
+ "version": "0.2.7-alpha02",
4
4
  "description": "Compose-like UI toolkit for Svelte, inspired by Jetpack Compose",
5
5
  "license": "MIT",
6
6
  "type": "module",
7
-
8
7
  "author": "Daniel Imbert Tabares",
9
8
  "repository": {
10
9
  "type": "git",
@@ -18,21 +17,18 @@
18
17
  ".": {
19
18
  "types": "./dist/index.d.ts",
20
19
  "import": "./dist/index.js",
21
- "svelte": "./dist/index.js",
22
- "default": "./dist/index.js"
20
+ "svelte": "./dist/index.js"
23
21
  }
24
22
  },
25
- "svelte": "./dist/index.js",
26
23
  "files": [
27
24
  "dist"
28
25
  ],
29
- "sideEffects": [
30
- "**/*.css"
31
- ],
32
26
  "peerDependencies": {
33
27
  "svelte": "^5.0.0"
34
28
  },
35
-
29
+ "sideEffects": [
30
+ "**/*.css"
31
+ ],
36
32
  "scripts": {
37
33
  "dev": "vite",
38
34
  "build": "vite build",