@danielito1996/compose-svelted 0.2.7-alpha04 → 0.2.8-alpha01
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 +44 -41
- package/dist/components/AppRoot.svelte +26 -11
- package/dist/components/Surface.svelte +29 -19
- package/dist/components/Text.svelte +37 -23
- package/dist/components/buttons/Button.svelte +66 -34
- package/dist/components/buttons/CheckButton.svelte +2 -2
- package/dist/components/layouts/Alignment.d.ts +40 -18
- package/dist/components/layouts/Alignment.js +40 -18
- package/dist/components/layouts/Arrangement.d.ts +27 -11
- package/dist/components/layouts/Arrangement.js +34 -41
- package/dist/components/layouts/Box.svelte +54 -47
- package/dist/components/layouts/Box.svelte.d.ts +19 -3
- package/dist/components/layouts/Column.svelte +52 -46
- package/dist/components/layouts/Column.svelte.d.ts +10 -2
- package/dist/components/layouts/Row.svelte +52 -46
- package/dist/components/layouts/Row.svelte.d.ts +10 -2
- package/dist/components/layouts/Scaffold.svelte +86 -53
- package/dist/components/layouts/Scaffold.svelte.d.ts +5 -2
- package/dist/components/layouts/resolveAlignment.d.ts +25 -4
- package/dist/components/layouts/resolveAlignment.js +46 -42
- package/dist/components/layouts/resolveFlexAlignSelf.d.ts +5 -1
- package/dist/components/layouts/resolveFlexAlignSelf.js +6 -8
- package/dist/components/motion/motion/AnimatedContent.svelte +41 -0
- package/dist/components/motion/{AnimatedContent.svelte.d.ts → motion/AnimatedContent.svelte.d.ts} +1 -1
- package/dist/components/motion/{AnimatedVisibility.svelte → motion/AnimatedVisibility.svelte} +3 -3
- package/dist/components/motion/{AnimatedVisibility.svelte.d.ts → motion/AnimatedVisibility.svelte.d.ts} +1 -1
- package/dist/components/motion/motion/AnimationSpec.d.ts +6 -0
- package/dist/components/motion/motion/AnimationSpec.js +1 -0
- package/dist/components/motion/motion/ContentTransition.d.ts +5 -0
- package/dist/components/motion/motion/ContentTransition.js +1 -0
- package/dist/components/motion/motion/applyAnimation.d.ts +0 -0
- package/dist/components/motion/motion/applyAnimation.js +0 -0
- package/dist/components/motion/motion/contentTransitions.d.ts +4 -0
- package/dist/components/motion/motion/contentTransitions.js +22 -0
- package/dist/components/motion/motion/transitions.d.ts +7 -0
- package/dist/components/motion/motion/transitions.js +70 -0
- package/dist/components/textFields/BaseTextField.svelte +4 -3
- package/dist/components/textFields/BaseTextField.svelte.d.ts +1 -0
- package/dist/components/textFields/OutlinedTextField.svelte +8 -7
- package/dist/components/textFields/TextField.svelte +8 -8
- package/dist/core/modifier/Modifier.d.ts +11 -171
- package/dist/core/modifier/Modifier.js +8 -170
- package/dist/core/modifier/ModifierImpl.d.ts +24 -6
- package/dist/core/modifier/ModifierImpl.js +96 -47
- package/dist/core/motion/AnimationSpec.d.ts +1 -6
- package/dist/core/motion/ContentTransition.d.ts +1 -5
- package/dist/core/motion/applyAnimation.d.ts +2 -0
- package/dist/core/motion/applyAnimation.js +3 -0
- package/dist/core/motion/contentTransitions.d.ts +1 -4
- package/dist/core/motion/contentTransitions.js +1 -22
- package/dist/core/motion/transitions.d.ts +1 -7
- package/dist/core/motion/transitions.js +1 -70
- package/dist/core/navigation/NavHost.svelte +46 -45
- package/dist/core/styles/baseline-safe.css +34 -0
- package/dist/core/styles/baseline.css +44 -48
- package/dist/core/theme/ColorScheme.d.ts +2 -0
- package/dist/core/theme/ColorScheme.js +2 -0
- package/dist/core/theme/ComposeTheme.svelte +36 -21
- package/dist/core/theme/colors.d.ts +2 -0
- package/dist/core/theme/defaults/darkColors.js +2 -0
- package/dist/core/theme/defaults/lightColors.js +2 -0
- package/dist/index.d.ts +48 -129
- package/dist/index.js +7 -3
- package/package.json +73 -59
- package/dist/components/motion/AnimatedContent.svelte +0 -34
package/README.md
CHANGED
|
@@ -97,6 +97,27 @@ Navigation without external routers.
|
|
|
97
97
|
- Core V2 closed
|
|
98
98
|
- Core V3 planned
|
|
99
99
|
|
|
100
|
+
## Project Zones
|
|
101
|
+
|
|
102
|
+
- `src/lib`: publishable library source.
|
|
103
|
+
- `playground`: local app for developing and validating the library against live source changes.
|
|
104
|
+
- `src/App.svelte` and `src/samples`: legacy examples, not part of the active library/playground workflow.
|
|
105
|
+
|
|
106
|
+
## Development Commands
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
npm install
|
|
110
|
+
npm run dev
|
|
111
|
+
npm run build
|
|
112
|
+
npm run check
|
|
113
|
+
npm run playground:build
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- `npm run dev`: starts the playground.
|
|
117
|
+
- `npm run build`: packages the library into `dist/`.
|
|
118
|
+
- `npm run check`: type-checks the playground against the current library source.
|
|
119
|
+
- `playground/vite.config.ts` aliases `@danielito1996/compose-svelted` to `src/lib/index.ts`, so playground changes reflect library source immediately.
|
|
120
|
+
|
|
100
121
|
---
|
|
101
122
|
|
|
102
123
|
## 🔮 Roadmap
|
|
@@ -110,44 +131,31 @@ Navigation without external routers.
|
|
|
110
131
|
|
|
111
132
|
## ⚠️ CSS Baseline (Required)
|
|
112
133
|
|
|
113
|
-
Compose Svelted assumes a neutral CSS baseline.
|
|
134
|
+
Compose Svelted is **layout-deterministic**, assumes a neutral CSS baseline.
|
|
114
135
|
|
|
115
136
|
You MUST include the following reset in your app:
|
|
116
137
|
|
|
117
|
-
|
|
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
|
|
138
|
+
To avoid layout regressions in existing apps, use one of these two paths:
|
|
133
139
|
|
|
134
|
-
|
|
140
|
+
### Path A (Primary): import baseline from the package
|
|
135
141
|
|
|
136
|
-
|
|
142
|
+
- **Strict baseline** (Compose-like deterministic behavior):
|
|
137
143
|
|
|
138
|
-
|
|
144
|
+
```ts
|
|
145
|
+
import "@danielito1996/compose-svelted/baseline.css";
|
|
146
|
+
```
|
|
139
147
|
|
|
140
|
-
|
|
148
|
+
- **Safe baseline** (less intrusive for existing projects):
|
|
141
149
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
150
|
+
```ts
|
|
151
|
+
import "@danielito1996/compose-svelted/baseline-safe.css";
|
|
152
|
+
```
|
|
145
153
|
|
|
146
|
-
|
|
154
|
+
Use `baseline-safe.css` if your app already has strong global styles and you want minimal interference.
|
|
147
155
|
|
|
148
|
-
###
|
|
156
|
+
### Path B (Alternative): do not import baseline, adapt your own `app.css`
|
|
149
157
|
|
|
150
|
-
|
|
158
|
+
If you prefer full control, keep your app stylesheet and ensure at least:
|
|
151
159
|
|
|
152
160
|
```css
|
|
153
161
|
*,
|
|
@@ -156,14 +164,20 @@ You must include the following reset in your global styles:
|
|
|
156
164
|
box-sizing: border-box;
|
|
157
165
|
}
|
|
158
166
|
|
|
159
|
-
html,
|
|
160
|
-
|
|
167
|
+
html, body, #app {
|
|
168
|
+
width: 100%;
|
|
169
|
+
height: 100%;
|
|
161
170
|
margin: 0;
|
|
162
171
|
padding: 0;
|
|
163
|
-
min-height: 100vh;
|
|
164
172
|
}
|
|
165
173
|
```
|
|
166
174
|
|
|
175
|
+
To guarantee consistent and predictable behavior of layout components such as
|
|
176
|
+
`Box`, `Column`, `Row`, `Surface`, `Scaffold`, and navigation containers,
|
|
177
|
+
a **neutral CSS baseline is required** in the host application.
|
|
178
|
+
|
|
179
|
+
This is **intentional** and mirrors the contract-based approach of **Jetpack Compose**.
|
|
180
|
+
|
|
167
181
|
### Why this matters
|
|
168
182
|
|
|
169
183
|
Compose Svelted does **not**:
|
|
@@ -180,14 +194,3 @@ Compose Svelted **does not require Tailwind CSS**.
|
|
|
180
194
|
|
|
181
195
|
Tailwind is used internally as an implementation detail for predictable styling,
|
|
182
196
|
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.
|
|
@@ -1,12 +1,27 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Modifier } from "../core/modifier/Modifier";
|
|
3
|
-
|
|
4
|
-
export let modifier: Modifier = Modifier.empty();
|
|
5
|
-
</script>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Modifier } from "../core/modifier/Modifier";
|
|
3
|
+
|
|
4
|
+
export let modifier: Modifier = Modifier.empty();
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<!--
|
|
8
|
+
AppRoot — ancla de toda la aplicación.
|
|
9
|
+
|
|
10
|
+
Ocupa el 100% del contenedor padre (que gracias a baseline.css es el viewport).
|
|
11
|
+
overflow:hidden garantiza que ningún hijo desborde el viewport accidentalmente.
|
|
12
|
+
position:relative es el contexto de posicionamiento para capas absolutas internas.
|
|
13
|
+
Se añade display:flex para actuar como raíz sólida para el crecimiento de hijos.
|
|
14
|
+
-->
|
|
15
|
+
<div
|
|
16
|
+
class="cs-relative"
|
|
17
|
+
style={`
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: 100%;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
${modifier.toStyle()}
|
|
24
|
+
`}
|
|
25
|
+
>
|
|
26
|
+
<slot />
|
|
12
27
|
</div>
|
|
@@ -1,19 +1,29 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Modifier } from "../core/modifier/Modifier";
|
|
3
|
-
import { resolveColor } from "../core/theme/resolve";
|
|
4
|
-
import type { ColorToken } from "../core/theme/ColorScheme";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export let
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Modifier } from "../core/modifier/Modifier";
|
|
3
|
+
import { resolveColor } from "../core/theme/resolve";
|
|
4
|
+
import type { ColorToken } from "../core/theme/ColorScheme";
|
|
5
|
+
|
|
6
|
+
export let modifier: Modifier = Modifier.empty();
|
|
7
|
+
export let color: ColorToken = "surface";
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<!--
|
|
11
|
+
Surface — Contenedor base de Material 3.
|
|
12
|
+
Sin dependencias de Tailwind.
|
|
13
|
+
-->
|
|
14
|
+
<div
|
|
15
|
+
class="cs-surface"
|
|
16
|
+
style={`
|
|
17
|
+
background:${resolveColor(color)};
|
|
18
|
+
${modifier.toStyle()}
|
|
19
|
+
`}
|
|
20
|
+
>
|
|
21
|
+
<slot />
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<style>
|
|
25
|
+
.cs-surface {
|
|
26
|
+
display: block;
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
}
|
|
29
|
+
</style>
|
|
@@ -1,23 +1,37 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Modifier } from "../core/modifier/Modifier";
|
|
3
|
-
import { resolveTextStyle, resolveColor } from "../core/theme/resolve";
|
|
4
|
-
import type { TextStyleToken } from "../core/theme/TextStyle";
|
|
5
|
-
import { ColorScheme, type ColorToken } from "../core/theme/ColorScheme";
|
|
6
|
-
|
|
7
|
-
export let modifier: Modifier = Modifier.empty();
|
|
8
|
-
export let textStyle: TextStyleToken = "bodyMedium";
|
|
9
|
-
|
|
10
|
-
// Aceptamos token o string directo
|
|
11
|
-
export let color: ColorToken | string = "onSurface";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Modifier } from "../core/modifier/Modifier";
|
|
3
|
+
import { resolveTextStyle, resolveColor } from "../core/theme/resolve";
|
|
4
|
+
import type { TextStyleToken } from "../core/theme/TextStyle";
|
|
5
|
+
import { ColorScheme, type ColorToken } from "../core/theme/ColorScheme";
|
|
6
|
+
|
|
7
|
+
export let modifier: Modifier = Modifier.empty();
|
|
8
|
+
export let textStyle: TextStyleToken = "bodyMedium";
|
|
9
|
+
|
|
10
|
+
// Aceptamos token o string directo
|
|
11
|
+
export let color: ColorToken | string = "onSurface";
|
|
12
|
+
|
|
13
|
+
$: resolvedColor = typeof color === "string" ? resolveColor(color as ColorToken) : color;
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<!--
|
|
17
|
+
Text — Componente Material 3 independiente.
|
|
18
|
+
No depende de Tailwind.
|
|
19
|
+
-->
|
|
20
|
+
<p
|
|
21
|
+
class="cs-text"
|
|
22
|
+
style={`
|
|
23
|
+
${resolveTextStyle(textStyle)};
|
|
24
|
+
color: ${resolvedColor};
|
|
25
|
+
${modifier.toStyle()}
|
|
26
|
+
`}
|
|
27
|
+
>
|
|
28
|
+
<slot />
|
|
29
|
+
</p>
|
|
30
|
+
|
|
31
|
+
<style>
|
|
32
|
+
.cs-text {
|
|
33
|
+
display: block;
|
|
34
|
+
margin: 0;
|
|
35
|
+
padding: 0;
|
|
36
|
+
}
|
|
37
|
+
</style>
|
|
@@ -1,34 +1,66 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { Modifier } from "../../core/modifier/Modifier";
|
|
3
|
-
import { resolveColor } from "../../core/theme/resolve";
|
|
4
|
-
import { ColorScheme, type ColorToken } from "../../core/theme/ColorScheme";
|
|
5
|
-
|
|
6
|
-
export let onClick: () => void = () => {};
|
|
7
|
-
export let modifier: Modifier = Modifier.empty();
|
|
8
|
-
|
|
9
|
-
export let color: ColorToken | string = "primary";
|
|
10
|
-
export let onColor: ColorToken | string = "onPrimary";
|
|
11
|
-
|
|
12
|
-
export let shape: "none" | "extraSmall" | "small" | "medium" | "large" = "large";
|
|
13
|
-
export let elevation: "level0" | "level1" | "level2" | "level3" | "level4" = "level1";
|
|
14
|
-
|
|
15
|
-
$: backgroundColor = typeof color === "string" ? resolveColor(color as ColorToken) : color;
|
|
16
|
-
$: contentColor = typeof onColor === "string" ? resolveColor(onColor as ColorToken) : onColor;
|
|
17
|
-
$: borderRadius = `var(--md-sys-shape-${shape})`;
|
|
18
|
-
$: boxShadow = `var(--md-sys-elevation-${elevation})`;
|
|
19
|
-
</script>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
${
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Modifier } from "../../core/modifier/Modifier";
|
|
3
|
+
import { resolveColor } from "../../core/theme/resolve";
|
|
4
|
+
import { ColorScheme, type ColorToken } from "../../core/theme/ColorScheme";
|
|
5
|
+
|
|
6
|
+
export let onClick: () => void = () => {};
|
|
7
|
+
export let modifier: Modifier = Modifier.empty();
|
|
8
|
+
|
|
9
|
+
export let color: ColorToken | string = "primary";
|
|
10
|
+
export let onColor: ColorToken | string = "onPrimary";
|
|
11
|
+
|
|
12
|
+
export let shape: "none" | "extraSmall" | "small" | "medium" | "large" = "large";
|
|
13
|
+
export let elevation: "level0" | "level1" | "level2" | "level3" | "level4" = "level1";
|
|
14
|
+
|
|
15
|
+
$: backgroundColor = typeof color === "string" ? resolveColor(color as ColorToken) : color;
|
|
16
|
+
$: contentColor = typeof onColor === "string" ? resolveColor(onColor as ColorToken) : onColor;
|
|
17
|
+
$: borderRadius = `var(--md-sys-shape-${shape})`;
|
|
18
|
+
$: boxShadow = `var(--md-sys-elevation-${elevation})`;
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<!--
|
|
22
|
+
Button — Componente Material 3 independiente.
|
|
23
|
+
No depende de Tailwind.
|
|
24
|
+
-->
|
|
25
|
+
<button
|
|
26
|
+
on:click={onClick}
|
|
27
|
+
class="cs-button"
|
|
28
|
+
style={`
|
|
29
|
+
background: ${backgroundColor};
|
|
30
|
+
color: ${contentColor};
|
|
31
|
+
border-radius: ${borderRadius};
|
|
32
|
+
box-shadow: ${boxShadow};
|
|
33
|
+
${modifier.toStyle()}
|
|
34
|
+
`}
|
|
35
|
+
>
|
|
36
|
+
<slot />
|
|
37
|
+
</button>
|
|
38
|
+
|
|
39
|
+
<style>
|
|
40
|
+
.cs-button {
|
|
41
|
+
display: inline-flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
justify-content: center;
|
|
44
|
+
border: none;
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
padding: 10px 24px;
|
|
47
|
+
gap: 8px;
|
|
48
|
+
font-family: inherit;
|
|
49
|
+
font-weight: 500;
|
|
50
|
+
letter-spacing: 0.1px;
|
|
51
|
+
transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
|
|
52
|
+
user-select: none;
|
|
53
|
+
-webkit-tap-highlight-color: transparent;
|
|
54
|
+
outline: none;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.cs-button:hover {
|
|
58
|
+
opacity: 0.92;
|
|
59
|
+
box-shadow: var(--md-sys-elevation-level2);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.cs-button:active {
|
|
63
|
+
transform: scale(0.97);
|
|
64
|
+
opacity: 0.85;
|
|
65
|
+
}
|
|
66
|
+
</style>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { ColorScheme } from "../../core/theme/ColorScheme";
|
|
4
4
|
import { resolveColor } from "../../core/theme/resolve";
|
|
5
5
|
import { RoundedCornerShape } from "../../core/shapes/RoundedCornerShape";
|
|
6
|
-
import AnimatedVisibility from "../motion/AnimatedVisibility.svelte";
|
|
6
|
+
import AnimatedVisibility from "../motion/motion/AnimatedVisibility.svelte";
|
|
7
7
|
import { scaleIn, scaleOut } from "../../core/motion/transitions";
|
|
8
8
|
import type { Shape } from "../../core/shapes/Shape";
|
|
9
9
|
|
|
@@ -74,4 +74,4 @@
|
|
|
74
74
|
|
|
75
75
|
<!-- Content -->
|
|
76
76
|
<slot />
|
|
77
|
-
</button>
|
|
77
|
+
</button>
|
|
@@ -1,20 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alignment — tokens de alineación type-safe con branded types.
|
|
3
|
+
*
|
|
4
|
+
* Los objetos son opacos: nunca se puede pasar un VerticalAlignment donde
|
|
5
|
+
* se espera un HorizontalAlignment, aunque ambos representen "center" en CSS.
|
|
6
|
+
*
|
|
7
|
+
* Filosofía Jetpack Compose:
|
|
8
|
+
* - HorizontalAlignment → eje cross de Column
|
|
9
|
+
* - VerticalAlignment → eje cross de Row
|
|
10
|
+
* - BoxAlignment → alineación compuesta para Box (stack)
|
|
11
|
+
*/
|
|
12
|
+
export type HorizontalAlignment = {
|
|
13
|
+
readonly _brand: 'HorizontalAlignment';
|
|
14
|
+
readonly cssValue: string;
|
|
15
|
+
};
|
|
16
|
+
export type VerticalAlignment = {
|
|
17
|
+
readonly _brand: 'VerticalAlignment';
|
|
18
|
+
readonly cssValue: string;
|
|
19
|
+
};
|
|
20
|
+
/** Alineación compuesta para Box — encapsula horizontal + vertical */
|
|
21
|
+
export type BoxAlignment = {
|
|
22
|
+
readonly _brand: 'BoxAlignment';
|
|
23
|
+
readonly horizontal: string;
|
|
24
|
+
readonly vertical: string;
|
|
25
|
+
};
|
|
1
26
|
export declare const Alignment: {
|
|
2
|
-
readonly Start:
|
|
3
|
-
readonly CenterHorizontally:
|
|
4
|
-
readonly End:
|
|
5
|
-
readonly Top:
|
|
6
|
-
readonly CenterVertically:
|
|
7
|
-
readonly Bottom:
|
|
8
|
-
readonly TopStart:
|
|
9
|
-
readonly TopCenter:
|
|
10
|
-
readonly TopEnd:
|
|
11
|
-
readonly CenterStart:
|
|
12
|
-
readonly Center:
|
|
13
|
-
readonly CenterEnd:
|
|
14
|
-
readonly BottomStart:
|
|
15
|
-
readonly BottomCenter:
|
|
16
|
-
readonly BottomEnd:
|
|
27
|
+
readonly Start: HorizontalAlignment;
|
|
28
|
+
readonly CenterHorizontally: HorizontalAlignment;
|
|
29
|
+
readonly End: HorizontalAlignment;
|
|
30
|
+
readonly Top: VerticalAlignment;
|
|
31
|
+
readonly CenterVertically: VerticalAlignment;
|
|
32
|
+
readonly Bottom: VerticalAlignment;
|
|
33
|
+
readonly TopStart: BoxAlignment;
|
|
34
|
+
readonly TopCenter: BoxAlignment;
|
|
35
|
+
readonly TopEnd: BoxAlignment;
|
|
36
|
+
readonly CenterStart: BoxAlignment;
|
|
37
|
+
readonly Center: BoxAlignment;
|
|
38
|
+
readonly CenterEnd: BoxAlignment;
|
|
39
|
+
readonly BottomStart: BoxAlignment;
|
|
40
|
+
readonly BottomCenter: BoxAlignment;
|
|
41
|
+
readonly BottomEnd: BoxAlignment;
|
|
17
42
|
};
|
|
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];
|
|
@@ -1,20 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alignment — tokens de alineación type-safe con branded types.
|
|
3
|
+
*
|
|
4
|
+
* Los objetos son opacos: nunca se puede pasar un VerticalAlignment donde
|
|
5
|
+
* se espera un HorizontalAlignment, aunque ambos representen "center" en CSS.
|
|
6
|
+
*
|
|
7
|
+
* Filosofía Jetpack Compose:
|
|
8
|
+
* - HorizontalAlignment → eje cross de Column
|
|
9
|
+
* - VerticalAlignment → eje cross de Row
|
|
10
|
+
* - BoxAlignment → alineación compuesta para Box (stack)
|
|
11
|
+
*/
|
|
12
|
+
// ─── Helpers internos ────────────────────────────────────────────────────────
|
|
13
|
+
function h(cssValue) {
|
|
14
|
+
return { _brand: 'HorizontalAlignment', cssValue: cssValue };
|
|
15
|
+
}
|
|
16
|
+
function v(cssValue) {
|
|
17
|
+
return { _brand: 'VerticalAlignment', cssValue: cssValue };
|
|
18
|
+
}
|
|
19
|
+
function box(horizontal, vertical) {
|
|
20
|
+
return { _brand: 'BoxAlignment', horizontal: horizontal, vertical: vertical };
|
|
21
|
+
}
|
|
22
|
+
// ─── Tokens públicos ─────────────────────────────────────────────────────────
|
|
1
23
|
export var Alignment = {
|
|
2
|
-
// Horizontal
|
|
3
|
-
Start:
|
|
4
|
-
CenterHorizontally:
|
|
5
|
-
End:
|
|
6
|
-
// Vertical
|
|
7
|
-
Top:
|
|
8
|
-
CenterVertically:
|
|
9
|
-
Bottom:
|
|
10
|
-
//
|
|
11
|
-
TopStart:
|
|
12
|
-
TopCenter:
|
|
13
|
-
TopEnd:
|
|
14
|
-
CenterStart:
|
|
15
|
-
Center:
|
|
16
|
-
CenterEnd:
|
|
17
|
-
BottomStart:
|
|
18
|
-
BottomCenter:
|
|
19
|
-
BottomEnd:
|
|
24
|
+
// Horizontal — eje cross de Column
|
|
25
|
+
Start: h('flex-start'),
|
|
26
|
+
CenterHorizontally: h('center'),
|
|
27
|
+
End: h('flex-end'),
|
|
28
|
+
// Vertical — eje cross de Row
|
|
29
|
+
Top: v('flex-start'),
|
|
30
|
+
CenterVertically: v('center'),
|
|
31
|
+
Bottom: v('flex-end'),
|
|
32
|
+
// Box — alineación compuesta (stack)
|
|
33
|
+
TopStart: box('flex-start', 'flex-start'),
|
|
34
|
+
TopCenter: box('center', 'flex-start'),
|
|
35
|
+
TopEnd: box('flex-end', 'flex-start'),
|
|
36
|
+
CenterStart: box('flex-start', 'center'),
|
|
37
|
+
Center: box('center', 'center'),
|
|
38
|
+
CenterEnd: box('flex-end', 'center'),
|
|
39
|
+
BottomStart: box('flex-start', 'flex-end'),
|
|
40
|
+
BottomCenter: box('center', 'flex-end'),
|
|
41
|
+
BottomEnd: box('flex-end', 'flex-end'),
|
|
20
42
|
};
|
|
@@ -1,23 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Arrangement — eje principal (main axis)
|
|
3
|
-
*
|
|
2
|
+
* Arrangement — eje principal (main axis).
|
|
3
|
+
*
|
|
4
|
+
* Fiel a Jetpack Compose:
|
|
5
|
+
* - Arrangement.Start, Center, End, SpaceBetween, SpaceAround, SpaceEvenly
|
|
6
|
+
* - Arrangement.spacedBy(gap) → gap entre hijos, con justificación base opcional
|
|
7
|
+
* - Arrangement.spacedBy(gap, Arrangement.Center) → centrado + gap
|
|
4
8
|
*/
|
|
9
|
+
type JustifyContent = 'flex-start' | 'center' | 'flex-end' | 'space-between' | 'space-around' | 'space-evenly';
|
|
5
10
|
export type ArrangementValue = {
|
|
6
|
-
type:
|
|
7
|
-
justifyContent:
|
|
11
|
+
readonly type: 'static';
|
|
12
|
+
readonly justifyContent: JustifyContent;
|
|
13
|
+
readonly gap?: never;
|
|
8
14
|
} | {
|
|
9
|
-
type:
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
readonly type: 'spaced';
|
|
16
|
+
readonly justifyContent: JustifyContent;
|
|
17
|
+
readonly gap: number;
|
|
12
18
|
};
|
|
13
19
|
export declare const Arrangement: {
|
|
20
|
+
readonly Top: ArrangementValue;
|
|
21
|
+
readonly Bottom: ArrangementValue;
|
|
14
22
|
readonly Start: ArrangementValue;
|
|
15
|
-
readonly Center: ArrangementValue;
|
|
16
23
|
readonly End: ArrangementValue;
|
|
17
|
-
readonly
|
|
18
|
-
readonly Top: ArrangementValue;
|
|
24
|
+
readonly Center: ArrangementValue;
|
|
19
25
|
readonly SpaceBetween: ArrangementValue;
|
|
20
26
|
readonly SpaceAround: ArrangementValue;
|
|
21
27
|
readonly SpaceEvenly: ArrangementValue;
|
|
22
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Espaciado uniforme entre hijos con gap en px.
|
|
30
|
+
* @param gap Espacio en píxeles entre elementos
|
|
31
|
+
* @param baseAlign Alineación base del main-axis (por defecto flex-start)
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* Arrangement.spacedBy(16)
|
|
35
|
+
* Arrangement.spacedBy(16, Arrangement.Center)
|
|
36
|
+
*/
|
|
37
|
+
readonly spacedBy: (gap: number, baseAlign?: ArrangementValue) => ArrangementValue;
|
|
23
38
|
};
|
|
39
|
+
export {};
|
|
@@ -1,46 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Arrangement — eje principal (main axis)
|
|
3
|
-
*
|
|
2
|
+
* Arrangement — eje principal (main axis).
|
|
3
|
+
*
|
|
4
|
+
* Fiel a Jetpack Compose:
|
|
5
|
+
* - Arrangement.Start, Center, End, SpaceBetween, SpaceAround, SpaceEvenly
|
|
6
|
+
* - Arrangement.spacedBy(gap) → gap entre hijos, con justificación base opcional
|
|
7
|
+
* - Arrangement.spacedBy(gap, Arrangement.Center) → centrado + gap
|
|
4
8
|
*/
|
|
9
|
+
// ─── Tokens estáticos ────────────────────────────────────────────────────────
|
|
10
|
+
var staticArrangement = function (justifyContent) {
|
|
11
|
+
return ({ type: 'static', justifyContent: justifyContent });
|
|
12
|
+
};
|
|
13
|
+
// ─── Arrangement public API ──────────────────────────────────────────────────
|
|
5
14
|
export var Arrangement = {
|
|
6
|
-
//
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
type:
|
|
29
|
-
justifyContent: "space-between",
|
|
30
|
-
},
|
|
31
|
-
SpaceAround: {
|
|
32
|
-
type: "static",
|
|
33
|
-
justifyContent: "space-around",
|
|
34
|
-
},
|
|
35
|
-
SpaceEvenly: {
|
|
36
|
-
type: "static",
|
|
37
|
-
justifyContent: "space-evenly",
|
|
38
|
-
},
|
|
39
|
-
spacedBy: function (value) {
|
|
40
|
-
return {
|
|
41
|
-
type: "spaced",
|
|
42
|
-
gap: value,
|
|
43
|
-
justifyContent: "flex-start",
|
|
44
|
-
};
|
|
15
|
+
// Column main-axis (vertical)
|
|
16
|
+
Top: staticArrangement('flex-start'),
|
|
17
|
+
Bottom: staticArrangement('flex-end'),
|
|
18
|
+
// Row main-axis (horizontal)
|
|
19
|
+
Start: staticArrangement('flex-start'),
|
|
20
|
+
End: staticArrangement('flex-end'),
|
|
21
|
+
// Compartidos
|
|
22
|
+
Center: staticArrangement('center'),
|
|
23
|
+
SpaceBetween: staticArrangement('space-between'),
|
|
24
|
+
SpaceAround: staticArrangement('space-around'),
|
|
25
|
+
SpaceEvenly: staticArrangement('space-evenly'),
|
|
26
|
+
/**
|
|
27
|
+
* Espaciado uniforme entre hijos con gap en px.
|
|
28
|
+
* @param gap Espacio en píxeles entre elementos
|
|
29
|
+
* @param baseAlign Alineación base del main-axis (por defecto flex-start)
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* Arrangement.spacedBy(16)
|
|
33
|
+
* Arrangement.spacedBy(16, Arrangement.Center)
|
|
34
|
+
*/
|
|
35
|
+
spacedBy: function (gap, baseAlign) {
|
|
36
|
+
if (baseAlign === void 0) { baseAlign = staticArrangement('flex-start'); }
|
|
37
|
+
return { type: 'spaced', gap: gap, justifyContent: baseAlign.justifyContent };
|
|
45
38
|
},
|
|
46
39
|
};
|