@danielito1996/compose-svelted 0.2.7 → 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.
Files changed (70) hide show
  1. package/README.md +196 -113
  2. package/dist/components/AppRoot.svelte +26 -14
  3. package/dist/components/Surface.svelte +29 -19
  4. package/dist/components/Text.svelte +37 -23
  5. package/dist/components/buttons/Button.svelte +66 -34
  6. package/dist/components/buttons/CheckButton.svelte +2 -2
  7. package/dist/components/layouts/Alignment.d.ts +40 -18
  8. package/dist/components/layouts/Alignment.js +40 -18
  9. package/dist/components/layouts/Arrangement.d.ts +27 -11
  10. package/dist/components/layouts/Arrangement.js +34 -41
  11. package/dist/components/layouts/Box.svelte +54 -25
  12. package/dist/components/layouts/Box.svelte.d.ts +8 -1
  13. package/dist/components/layouts/Column.svelte +52 -23
  14. package/dist/components/layouts/Column.svelte.d.ts +10 -2
  15. package/dist/components/layouts/LayoutContext.d.ts +1 -0
  16. package/dist/components/layouts/LayoutContext.js +1 -0
  17. package/dist/components/layouts/LazyColumn.svelte +12 -12
  18. package/dist/components/layouts/LazyRow.svelte +81 -45
  19. package/dist/components/layouts/LazyRow.svelte.d.ts +3 -6
  20. package/dist/components/layouts/Row.svelte +52 -23
  21. package/dist/components/layouts/Row.svelte.d.ts +10 -2
  22. package/dist/components/layouts/Scaffold.svelte +86 -73
  23. package/dist/components/layouts/Scaffold.svelte.d.ts +5 -1
  24. package/dist/components/layouts/resolveAlignment.d.ts +25 -0
  25. package/dist/components/layouts/resolveAlignment.js +48 -0
  26. package/dist/components/layouts/resolveFlexAlignSelf.d.ts +6 -0
  27. package/dist/components/layouts/resolveFlexAlignSelf.js +8 -0
  28. package/dist/components/motion/motion/AnimatedContent.svelte +41 -0
  29. package/dist/components/motion/{AnimatedContent.svelte.d.ts → motion/AnimatedContent.svelte.d.ts} +1 -1
  30. package/dist/components/motion/{AnimatedVisibility.svelte → motion/AnimatedVisibility.svelte} +3 -3
  31. package/dist/components/motion/{AnimatedVisibility.svelte.d.ts → motion/AnimatedVisibility.svelte.d.ts} +1 -1
  32. package/dist/components/motion/motion/AnimationSpec.d.ts +6 -0
  33. package/dist/components/motion/motion/AnimationSpec.js +1 -0
  34. package/dist/components/motion/motion/ContentTransition.d.ts +5 -0
  35. package/dist/components/motion/motion/ContentTransition.js +1 -0
  36. package/dist/components/motion/motion/applyAnimation.d.ts +0 -0
  37. package/dist/components/motion/motion/applyAnimation.js +0 -0
  38. package/dist/components/motion/motion/contentTransitions.d.ts +4 -0
  39. package/dist/components/motion/motion/contentTransitions.js +22 -0
  40. package/dist/components/motion/motion/transitions.d.ts +7 -0
  41. package/dist/components/motion/motion/transitions.js +70 -0
  42. package/dist/components/textFields/BaseTextField.svelte +4 -3
  43. package/dist/components/textFields/BaseTextField.svelte.d.ts +1 -0
  44. package/dist/components/textFields/OutlinedTextField.svelte +8 -7
  45. package/dist/components/textFields/TextField.svelte +8 -8
  46. package/dist/core/modifier/Modifier.d.ts +11 -171
  47. package/dist/core/modifier/Modifier.js +8 -170
  48. package/dist/core/modifier/ModifierImpl.d.ts +29 -17
  49. package/dist/core/modifier/ModifierImpl.js +112 -151
  50. package/dist/core/motion/AnimationSpec.d.ts +1 -6
  51. package/dist/core/motion/ContentTransition.d.ts +1 -5
  52. package/dist/core/motion/applyAnimation.d.ts +2 -0
  53. package/dist/core/motion/applyAnimation.js +3 -0
  54. package/dist/core/motion/contentTransitions.d.ts +1 -4
  55. package/dist/core/motion/contentTransitions.js +1 -22
  56. package/dist/core/motion/transitions.d.ts +1 -7
  57. package/dist/core/motion/transitions.js +1 -70
  58. package/dist/core/navigation/NavHost.svelte +46 -45
  59. package/dist/core/styles/baseline-safe.css +34 -0
  60. package/dist/core/styles/baseline.css +45 -0
  61. package/dist/core/theme/ColorScheme.d.ts +2 -0
  62. package/dist/core/theme/ColorScheme.js +2 -0
  63. package/dist/core/theme/ComposeTheme.svelte +36 -21
  64. package/dist/core/theme/colors.d.ts +2 -0
  65. package/dist/core/theme/defaults/darkColors.js +2 -0
  66. package/dist/core/theme/defaults/lightColors.js +2 -0
  67. package/dist/index.d.ts +48 -129
  68. package/dist/index.js +7 -2
  69. package/package.json +73 -58
  70. package/dist/components/motion/AnimatedContent.svelte +0 -34
@@ -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,6 +19,11 @@ 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
+ import { resolveBoxPlaceSelf, resolveColumnAlignSelf, resolveRowAlignSelf } from "../../components/layouts/resolveAlignment";
23
+ function toCssLength(value, unit) {
24
+ if (unit === void 0) { unit = "px"; }
25
+ return typeof value === "number" ? "".concat(value).concat(unit) : value;
26
+ }
11
27
  var ModifierImpl = /** @class */ (function () {
12
28
  function ModifierImpl(entries) {
13
29
  if (entries === void 0) { entries = []; }
@@ -16,198 +32,143 @@ var ModifierImpl = /** @class */ (function () {
16
32
  ModifierImpl.prototype.then = function (other) {
17
33
  return new ModifierImpl(__spreadArray(__spreadArray([], this.entries, true), other.entries, true));
18
34
  };
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
- };
45
35
  ModifierImpl.prototype.fillMaxWidth = function () {
46
- return this.then(new ModifierImpl([{ style: "width:100%;" }]));
36
+ // En flexbox, width:100% y align-self:stretch aseguran ocupar el ancho
37
+ return this.then(new ModifierImpl([{ style: "width:100%;align-self:stretch;" }]));
47
38
  };
48
39
  ModifierImpl.prototype.fillMaxHeight = function () {
49
- return this.then(new ModifierImpl([{ style: "height:100%;" }]));
40
+ // En flexbox (como Row), align-self:stretch es clave para llenar el alto transversal
41
+ // height:100% ayuda en contextos de bloque o flex-direction: column
42
+ return this.then(new ModifierImpl([{ style: "height:100%;align-self:stretch;" }]));
50
43
  };
51
44
  ModifierImpl.prototype.fillMaxSize = function () {
52
- return this.then(new ModifierImpl([{ style: "width:100%;height:100%;" }]));
45
+ return this.then(new ModifierImpl([{ style: "width:100%;height:100%;align-self:stretch;" }]));
53
46
  };
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
- ]));
47
+ ModifierImpl.prototype.width = function (value, unit) {
48
+ if (unit === void 0) { unit = "px"; }
49
+ return this.then(new ModifierImpl([{ style: "width:".concat(toCssLength(value, unit), ";") }]));
50
+ };
51
+ ModifierImpl.prototype.height = function (value, unit) {
52
+ if (unit === void 0) { unit = "px"; }
53
+ return this.then(new ModifierImpl([{ style: "height:".concat(toCssLength(value, unit), ";") }]));
54
+ };
55
+ ModifierImpl.prototype.size = function (value, unit) {
56
+ if (unit === void 0) { unit = "px"; }
57
+ var cssValue = toCssLength(value, unit);
58
+ return this.then(new ModifierImpl([{ style: "width:".concat(cssValue, ";height:").concat(cssValue, ";") }]));
72
59
  };
73
60
  ModifierImpl.prototype.weight = function (weight, fill) {
74
61
  if (fill === void 0) { fill = true; }
75
62
  if (weight <= 0) {
76
- console.warn("Modifier.weight() debe ser > 0");
77
63
  return this;
78
64
  }
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%);';
65
+ return this.then(new ModifierImpl([
66
+ {
67
+ style: "flex-grow:".concat(weight, ";flex-shrink:").concat(fill ? 1 : 0, ";flex-basis:0%;")
116
68
  }
117
- }
118
- return this.then(new ModifierImpl([{ style: style }]));
69
+ ]));
119
70
  };
120
71
  ModifierImpl.prototype.padding = function (valueOrParams, unit) {
121
72
  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();
73
+ if (unit === void 0) { unit = "px"; }
74
+ if (typeof valueOrParams === "number") {
75
+ return this.then(new ModifierImpl([{ style: "padding:".concat(valueOrParams).concat(unit, ";") }]));
132
76
  }
133
- return this.then(new ModifierImpl([{ style: style }]));
77
+ 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;
78
+ return this.then(new ModifierImpl([
79
+ {
80
+ style: [
81
+ "padding-top:".concat(top).concat(unit, ";"),
82
+ "padding-bottom:".concat(bottom).concat(unit, ";"),
83
+ "padding-left:".concat(start).concat(unit, ";"),
84
+ "padding-right:".concat(end).concat(unit, ";")
85
+ ].join("")
86
+ }
87
+ ]));
134
88
  };
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, ";") }]));
89
+ ModifierImpl.prototype.paddingHorizontal = function (value) {
90
+ return this.then(new ModifierImpl([
91
+ { style: "padding-left:".concat(value, "px;padding-right:").concat(value, "px;") }
92
+ ]));
139
93
  };
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, ";") }]));
94
+ ModifierImpl.prototype.paddingVertical = function (value) {
95
+ return this.then(new ModifierImpl([
96
+ { style: "padding-top:".concat(value, "px;padding-bottom:").concat(value, "px;") }
97
+ ]));
144
98
  };
145
99
  ModifierImpl.prototype.marginTop = function (value, unit) {
146
- if (unit === void 0) { unit = 'px'; }
100
+ if (unit === void 0) { unit = "px"; }
147
101
  return this.then(new ModifierImpl([{ style: "margin-top:".concat(value).concat(unit, ";") }]));
148
102
  };
149
- ModifierImpl.prototype.clip = function (shape) {
150
- return this.then(new ModifierImpl([
151
- {
152
- style: "\n border-radius:".concat(shape.toCssBorderRadius(), ";\n overflow:hidden;\n ")
153
- }
154
- ]));
103
+ ModifierImpl.prototype.background = function (color) {
104
+ var resolved = typeof color === "string" ? color : resolveColor(color);
105
+ return this.then(new ModifierImpl([{ style: "background:".concat(resolved, ";") }]));
155
106
  };
156
- ModifierImpl.prototype.size = function (value, unit) {
157
- if (unit === void 0) { unit = "px"; }
158
- if (value === null || value === undefined) {
107
+ ModifierImpl.prototype.border = function (width, color, shape) {
108
+ if (width <= 0) {
159
109
  return this;
160
110
  }
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
- }
111
+ var borderRadius = shape ? "border-radius:".concat(shape.toCssBorderRadius(), ";") : "";
172
112
  return this.then(new ModifierImpl([
173
- {
174
- style: "width:".concat(resolved, ";height:").concat(resolved, ";")
175
- }
113
+ { style: "border:".concat(width, "px solid ").concat(color, ";").concat(borderRadius) }
176
114
  ]));
177
115
  };
178
- ModifierImpl.prototype.offset = function (x, y) {
179
- if (isNaN(x) || isNaN(y))
180
- return this;
116
+ ModifierImpl.prototype.clip = function (shape) {
181
117
  return this.then(new ModifierImpl([
182
- {
183
- style: "transform: translate(".concat(x, "px, ").concat(y, "px);")
184
- }
118
+ { style: "border-radius:".concat(shape.toCssBorderRadius(), ";overflow:hidden;") }
185
119
  ]));
186
120
  };
187
- ModifierImpl.prototype.clickable = function (onClick) {
121
+ ModifierImpl.prototype.offset = function (x, y) {
188
122
  return this.then(new ModifierImpl([
189
- {
190
- className: "compose-clickable",
191
- style: "\n cursor: pointer;\n user-select: none;\n "
192
- }
123
+ { style: "transform:translate(".concat(x, "px, ").concat(y, "px);") }
193
124
  ]));
194
125
  };
195
- ModifierImpl.prototype.border = function (width, color, shape) {
196
- if (width <= 0)
197
- return this;
198
- var radius = shape ? shape.toCssBorderRadius() : undefined;
126
+ /**
127
+ * Sobreescribe la alineación de este hijo dentro de un contenedor (Box, Column, Row).
128
+ * Equivalente a Modifier.align() en Jetpack Compose.
129
+ */
130
+ ModifierImpl.prototype.align = function (alignment) {
131
+ return this.then(new ModifierImpl([{ meta: { align: alignment } }]));
132
+ };
133
+ ModifierImpl.prototype.clickable = function (_onClick) {
199
134
  return this.then(new ModifierImpl([
200
- {
201
- style: "\n border:".concat(width, "px solid ").concat(color, ";\n ").concat(radius ? "border-radius:".concat(radius, ";") : "", "\n ")
202
- }
135
+ { className: "compose-clickable", style: "cursor:pointer;user-select:none;" }
203
136
  ]));
204
137
  };
205
- // ---- consumo interno ----
138
+ ModifierImpl.prototype.verticalScroll = function (enabled) {
139
+ if (enabled === void 0) { enabled = true; }
140
+ return enabled
141
+ ? this.then(new ModifierImpl([{ style: "overflow-y:auto;" }]))
142
+ : this;
143
+ };
144
+ ModifierImpl.prototype.horizontalScroll = function (enabled) {
145
+ if (enabled === void 0) { enabled = true; }
146
+ return enabled
147
+ ? this.then(new ModifierImpl([{ style: "overflow-x:auto;" }]))
148
+ : this;
149
+ };
206
150
  ModifierImpl.prototype.toStyle = function () {
207
- return this.entries.map(function (e) { var _a; return (_a = e.style) !== null && _a !== void 0 ? _a : ""; }).join("");
151
+ var meta = this.getMeta();
152
+ var alignStyle = "";
153
+ if (meta.align) {
154
+ var a = meta.align;
155
+ if (a._brand === 'BoxAlignment') {
156
+ alignStyle = resolveBoxPlaceSelf(a);
157
+ }
158
+ else if (a._brand === 'HorizontalAlignment') {
159
+ alignStyle = resolveColumnAlignSelf(a);
160
+ }
161
+ else if (a._brand === 'VerticalAlignment') {
162
+ alignStyle = resolveRowAlignSelf(a);
163
+ }
164
+ }
165
+ return this.entries.map(function (entry) { var _a; return (_a = entry.style) !== null && _a !== void 0 ? _a : ""; }).join("") + alignStyle;
208
166
  };
209
167
  ModifierImpl.prototype.toClass = function () {
210
- return this.entries.map(function (e) { var _a; return (_a = e.className) !== null && _a !== void 0 ? _a : ""; }).join(" ");
168
+ return this.entries.map(function (entry) { var _a; return (_a = entry.className) !== null && _a !== void 0 ? _a : ""; }).filter(Boolean).join(" ");
169
+ };
170
+ ModifierImpl.prototype.getMeta = function () {
171
+ return this.entries.reduce(function (acc, entry) { var _a; return (__assign(__assign({}, acc), ((_a = entry.meta) !== null && _a !== void 0 ? _a : {}))); }, {});
211
172
  };
212
173
  return ModifierImpl;
213
174
  }());
@@ -1,6 +1 @@
1
- export type AnimationSpec = {
2
- base: string;
3
- from: string;
4
- to: string;
5
- duration: number;
6
- };
1
+ export type { AnimationSpec } from "../../components/motion/motion/AnimationSpec";
@@ -1,5 +1 @@
1
- export type ContentTransition = {
2
- enter: string;
3
- exit: string;
4
- duration: number;
5
- };
1
+ export type { ContentTransition } from "../../components/motion/motion/ContentTransition";
@@ -0,0 +1,2 @@
1
+ import type { AnimationSpec } from "./AnimationSpec";
2
+ export declare function applyAnimation(spec: AnimationSpec): string;
@@ -0,0 +1,3 @@
1
+ export function applyAnimation(spec) {
2
+ return [spec.base, spec.to].filter(Boolean).join(" ");
3
+ }
@@ -1,4 +1 @@
1
- import type { ContentTransition } from "./ContentTransition";
2
- export declare function slideHorizontal(): ContentTransition;
3
- export declare function scaleFade(): ContentTransition;
4
- export declare function fade(duration?: number): ContentTransition;
1
+ export { fade, scaleFade, slideHorizontal } from "../../components/motion/motion/contentTransitions";
@@ -1,22 +1 @@
1
- export function slideHorizontal() {
2
- return {
3
- enter: "transition-transform duration-200 ease-out translate-x-0",
4
- exit: "transition-transform duration-200 ease-in -translate-x-full",
5
- duration: 200
6
- };
7
- }
8
- export function scaleFade() {
9
- return {
10
- enter: "transition-all duration-220 ease-out opacity-100 scale-100",
11
- exit: "transition-all duration-180 ease-in opacity-0 scale-95",
12
- duration: 220
13
- };
14
- }
15
- export function fade(duration) {
16
- if (duration === void 0) { duration = 300; }
17
- return {
18
- enter: "animate-fade-in",
19
- exit: "animate-fade-out",
20
- duration: duration
21
- };
22
- }
1
+ export { fade, scaleFade, slideHorizontal } from "../../components/motion/motion/contentTransitions";
@@ -1,7 +1 @@
1
- import type { AnimationSpec } from "./AnimationSpec";
2
- export declare function fadeIn(duration?: number): AnimationSpec;
3
- export declare function fadeOut(duration?: number): AnimationSpec;
4
- export declare function scaleIn(duration?: number): AnimationSpec;
5
- export declare function scaleOut(duration?: number): AnimationSpec;
6
- export declare function slideIn(duration?: number, direction?: "left" | "right" | "up" | "down"): AnimationSpec;
7
- export declare function slideOut(duration?: number, direction?: "left" | "right" | "up" | "down"): AnimationSpec;
1
+ export { fadeIn, fadeOut, scaleIn, scaleOut, slideIn, slideOut } from "../../components/motion/motion/transitions";
@@ -1,70 +1 @@
1
- var defaultEnter = 280;
2
- var defaultExit = 220;
3
- export function fadeIn(duration) {
4
- if (duration === void 0) { duration = defaultEnter; }
5
- return {
6
- base: "transition-opacity duration-[".concat(duration, "ms] ease-out"),
7
- from: "opacity-0",
8
- to: "opacity-100",
9
- duration: duration
10
- };
11
- }
12
- export function fadeOut(duration) {
13
- if (duration === void 0) { duration = defaultExit; }
14
- return {
15
- base: "transition-opacity duration-[".concat(duration, "ms] ease-in"),
16
- from: "opacity-100",
17
- to: "opacity-0",
18
- duration: duration
19
- };
20
- }
21
- export function scaleIn(duration) {
22
- if (duration === void 0) { duration = defaultEnter; }
23
- return {
24
- base: "transition-all duration-[".concat(duration, "ms] ease-out"),
25
- from: "opacity-0 scale-95",
26
- to: "opacity-100 scale-100",
27
- duration: duration
28
- };
29
- }
30
- export function scaleOut(duration) {
31
- if (duration === void 0) { duration = defaultExit; }
32
- return {
33
- base: "transition-all duration-[".concat(duration, "ms] ease-in"),
34
- from: "opacity-100 scale-100",
35
- to: "opacity-0 scale-95",
36
- duration: duration
37
- };
38
- }
39
- export function slideIn(duration, direction) {
40
- if (duration === void 0) { duration = defaultEnter; }
41
- if (direction === void 0) { direction = "right"; }
42
- var fromMap = {
43
- left: "-translate-x-4",
44
- right: "translate-x-4",
45
- up: "-translate-y-4",
46
- down: "translate-y-4"
47
- };
48
- return {
49
- base: "transition-all duration-[".concat(duration, "ms] ease-out"),
50
- from: "opacity-0 ".concat(fromMap[direction]),
51
- to: "opacity-100 translate-x-0 translate-y-0",
52
- duration: duration
53
- };
54
- }
55
- export function slideOut(duration, direction) {
56
- if (duration === void 0) { duration = defaultExit; }
57
- if (direction === void 0) { direction = "right"; }
58
- var toMap = {
59
- left: "-translate-x-4",
60
- right: "translate-x-4",
61
- up: "-translate-y-4",
62
- down: "translate-y-4"
63
- };
64
- return {
65
- base: "transition-all duration-[".concat(duration, "ms] ease-in"),
66
- from: "opacity-100 translate-x-0 translate-y-0",
67
- to: "opacity-0 ".concat(toMap[direction]),
68
- duration: duration
69
- };
70
- }
1
+ export { fadeIn, fadeOut, scaleIn, scaleOut, slideIn, slideOut } from "../../components/motion/motion/transitions";
@@ -1,45 +1,46 @@
1
- <script lang="ts">
2
- import { Modifier } from "../modifier/Modifier";
3
- import type { NavController } from "./NavController";
4
- import AnimatedContent from "../../components/motion/AnimatedContent.svelte";
5
- import type { ContentTransition } from "../motion/ContentTransition";
6
- import { fade } from "../motion/contentTransitions";
7
-
8
- export let navController: NavController;
9
-
10
- export let routes: {
11
- route: { path: string };
12
- component: any;
13
- }[];
14
-
15
- // 🔹 Transición única, Compose-like
16
- export let transition: ContentTransition = fade(320);
17
-
18
- export let modifier: Modifier = Modifier.empty();
19
-
20
- // 🔹 Store interno (estable)
21
- const stackStore = navController._getStackStore();
22
-
23
- $: stack = $stackStore;
24
- $: currentEntry = stack.at(-1);
25
-
26
- $: active =
27
- routes.find(r => r.route.path === currentEntry?.route);
28
- </script>
29
-
30
- <div style={modifier.toStyle()}>
31
- <AnimatedContent
32
- targetState={currentEntry?.route}
33
- transition={transition}
34
- modifier={Modifier.fillMaxSize()}
35
- let:value
36
- >
37
- {#if active}
38
- <svelte:component
39
- this={active.component}
40
- navController={navController}
41
- navBackStackEntry={currentEntry}
42
- />
43
- {/if}
44
- </AnimatedContent>
45
- </div>
1
+ <script lang="ts">
2
+ import { Modifier } from "../modifier/Modifier";
3
+ import type { NavController } from "./NavController";
4
+ import AnimatedContent from "../../components/motion/motion/AnimatedContent.svelte";
5
+ import type { ContentTransition } from "../motion/ContentTransition";
6
+ import { fade } from "../motion/contentTransitions";
7
+
8
+ export let navController: NavController;
9
+
10
+ export let routes: {
11
+ route: { path: string };
12
+ component: any;
13
+ }[];
14
+
15
+ // Transición única, Compose-like
16
+ export let transition: ContentTransition = fade(320);
17
+
18
+ export let modifier: Modifier = Modifier.empty();
19
+
20
+ const stackStore = navController._getStackStore();
21
+
22
+ $: stack = $stackStore;
23
+ $: currentEntry = stack.at(-1);
24
+
25
+ $: active =
26
+ routes.find(r => r.route.path === currentEntry?.route);
27
+ </script>
28
+
29
+ <!--
30
+ NavHost ocupa todo el espacio disponible del padre.
31
+ Cada screen registrada recibe navController y navBackStackEntry como props.
32
+ -->
33
+ <div style={`width:100%;height:100%;position:relative;${modifier.toStyle()}`}>
34
+ <AnimatedContent
35
+ targetState={currentEntry?.route}
36
+ transition={transition}
37
+ >
38
+ {#if active}
39
+ <svelte:component
40
+ this={active.component}
41
+ navController={navController}
42
+ navBackStackEntry={currentEntry}
43
+ />
44
+ {/if}
45
+ </AnimatedContent>
46
+ </div>
@@ -0,0 +1,34 @@
1
+ /**
2
+ * compose-svelted — baseline-safe.css
3
+ *
4
+ * Variante conservadora para apps existentes:
5
+ * - Mantiene contrato mínimo de layout (box-sizing + root 100%)
6
+ * - No fuerza overflow global
7
+ * - No normaliza media globalmente
8
+ * - No aplica min-width/min-height universal
9
+ */
10
+
11
+ * ,
12
+ *::before,
13
+ *::after {
14
+ box-sizing: border-box;
15
+ }
16
+
17
+ html,
18
+ body,
19
+ #app {
20
+ width: 100%;
21
+ height: 100%;
22
+ margin: 0;
23
+ padding: 0;
24
+ }
25
+
26
+ .cs-clickable {
27
+ cursor: pointer;
28
+ user-select: none;
29
+ -webkit-user-select: none;
30
+ }
31
+
32
+ .cs-relative {
33
+ position: relative;
34
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * compose-svelted — baseline.css
3
+ *
4
+ * Este CSS establece la base mínima necesaria para que los layouts de
5
+ * compose-svelted funcionen con la filosofía de Jetpack Compose:
6
+ *
7
+ * • El viewport es la unidad raíz — html/body/app ocupan exactamente 100%.
8
+ * • NO hay scroll por defecto — el overflow está bloqueado en el root.
9
+ * El scroll solo ocurre cuando el layout o Modifier lo habilitan
10
+ * explícitamente (verticalScroll, LazyColumn, LazyRow).
11
+ * • Los layouts controlan tamaños y alineaciones — el CSS global no impone
12
+ * ninguna opinión sobre disposición de hijos.
13
+ * • box-sizing: border-box universal — padding no suma al ancho declarado.
14
+ * • min-width/min-height: 0 universal — los hijos flex/grid no desbordan
15
+ * si su contenido es mayor que el espacio asignado.
16
+ */
17
+
18
+ /* ── 1. Box model consistente ──────────────────────────────────────────────── */
19
+ *,
20
+ *::before,
21
+ *::after {
22
+ box-sizing: border-box;
23
+ }
24
+
25
+ /* 2) Root sizing + bloqueo de overflow global */
26
+ html,
27
+ body,
28
+ #app {
29
+ width: 100%;
30
+ height: 100%;
31
+ margin: 0;
32
+ padding: 0;
33
+ overflow: hidden;
34
+ }
35
+
36
+ /* 3) Utilidades internas usadas por la librería */
37
+ .cs-clickable {
38
+ cursor: pointer;
39
+ user-select: none;
40
+ -webkit-user-select: none;
41
+ }
42
+
43
+ .cs-relative {
44
+ position: relative;
45
+ }
@@ -11,6 +11,8 @@ export declare const ColorScheme: {
11
11
  readonly OnSurface: "onSurface";
12
12
  readonly SurfaceVariant: "surfaceVariant";
13
13
  readonly OnSurfaceVariant: "onSurfaceVariant";
14
+ readonly Tertiary: "tertiary";
15
+ readonly OnTertiary: "onTertiary";
14
16
  readonly Outline: "outline";
15
17
  readonly Error: "error";
16
18
  readonly OnError: "onError";
@@ -9,6 +9,8 @@ export var ColorScheme = {
9
9
  OnSurface: "onSurface",
10
10
  SurfaceVariant: "surfaceVariant",
11
11
  OnSurfaceVariant: "onSurfaceVariant",
12
+ Tertiary: "tertiary",
13
+ OnTertiary: "onTertiary",
12
14
  Outline: "outline",
13
15
  Error: "error",
14
16
  OnError: "onError",