@danielito1996/compose-svelted 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/.vscode/extensions.json +3 -0
  2. package/README.md +274 -0
  3. package/docs/assets/components/button/button.png +0 -0
  4. package/docs/assets/components/surface/surface_simple.png +0 -0
  5. package/docs/assets/components/text/text.png +0 -0
  6. package/docs/assets/components/textfield/textfield_simple.png +0 -0
  7. package/docs/assets/svelted.png +0 -0
  8. package/docs/assets/svelted.svg +41 -0
  9. package/docs/getting_started.md +116 -0
  10. package/docs/index.md +106 -0
  11. package/index.html +14 -0
  12. package/package.json +49 -0
  13. package/public/vite.svg +1 -0
  14. package/screenshots/Captura de pantalla 2025-12-20 022710.png +0 -0
  15. package/screenshots/capturas.txt +1 -0
  16. package/src/App.svelte +39 -0
  17. package/src/app.css +23 -0
  18. package/src/assets/img/hav3m.png +0 -0
  19. package/src/assets/img/vessel.jpg +0 -0
  20. package/src/assets/raw/boat.svg +15 -0
  21. package/src/assets/raw/cash.svg +39 -0
  22. package/src/assets/raw/police.json +1 -0
  23. package/src/assets/raw/svelte.svg +1 -0
  24. package/src/lib/Counter.svelte +10 -0
  25. package/src/lib/components/AppRoot.svelte +15 -0
  26. package/src/lib/components/ContentScale.ts +12 -0
  27. package/src/lib/components/Icon.svelte +47 -0
  28. package/src/lib/components/Image.svelte +31 -0
  29. package/src/lib/components/Spacer.svelte +11 -0
  30. package/src/lib/components/Surface.svelte +19 -0
  31. package/src/lib/components/Text.svelte +23 -0
  32. package/src/lib/components/TonalButton.svelte +34 -0
  33. package/src/lib/components/buttons/Button.svelte +34 -0
  34. package/src/lib/components/buttons/ButtonWithIcon.svelte +0 -0
  35. package/src/lib/components/buttons/IconButton.svelte +0 -0
  36. package/src/lib/components/buttons/OutlinedButton.svelte +0 -0
  37. package/src/lib/components/buttons/OutlinedButtonWithIcon.svelte +0 -0
  38. package/src/lib/components/buttons/OutlinedIconButton.svelte +0 -0
  39. package/src/lib/components/buttons/TextButton.svelte +0 -0
  40. package/src/lib/components/cards/Card.svelte +0 -0
  41. package/src/lib/components/cards/OutlinedCard.svelte +0 -0
  42. package/src/lib/components/layouts/Alignment.ts +37 -0
  43. package/src/lib/components/layouts/Arrangement.ts +66 -0
  44. package/src/lib/components/layouts/Box.svelte +25 -0
  45. package/src/lib/components/layouts/Column.svelte +23 -0
  46. package/src/lib/components/layouts/LazyColumn.svelte +0 -0
  47. package/src/lib/components/layouts/LazyRow.svelte +0 -0
  48. package/src/lib/components/layouts/Row.svelte +23 -0
  49. package/src/lib/components/layouts/Scafold.svelte +0 -0
  50. package/src/lib/components/menus/DropdownMenu.svelte +0 -0
  51. package/src/lib/components/menus/DropdownMenuItem.svelte +0 -0
  52. package/src/lib/components/textFields/BaseTextField.svelte +130 -0
  53. package/src/lib/components/textFields/OutlinedTextField.svelte +52 -0
  54. package/src/lib/components/textFields/TextField.svelte +36 -0
  55. package/src/lib/components/textFields/TextFieldColors.ts +11 -0
  56. package/src/lib/components/textFields/TextFieldDefaults.ts +48 -0
  57. package/src/lib/core/helpers/painterResource.ts +26 -0
  58. package/src/lib/core/modifier/Modifier.ts +259 -0
  59. package/src/lib/core/modifier/ModifierImpl.ts +275 -0
  60. package/src/lib/core/shapes/RoundedCornerShape.ts +53 -0
  61. package/src/lib/core/shapes/Shape.ts +3 -0
  62. package/src/lib/core/theme/ColorScheme.ts +25 -0
  63. package/src/lib/core/theme/ComposeTheme.svelte +22 -0
  64. package/src/lib/core/theme/TextStyle.ts +25 -0
  65. package/src/lib/core/theme/colors.ts +21 -0
  66. package/src/lib/core/theme/cssVars.ts +32 -0
  67. package/src/lib/core/theme/defaults/darkColors.ts +17 -0
  68. package/src/lib/core/theme/defaults/defaultTheme.ts +35 -0
  69. package/src/lib/core/theme/defaults/lightColors.ts +17 -0
  70. package/src/lib/core/theme/defaults/typography.ts +128 -0
  71. package/src/lib/core/theme/elevation.ts +7 -0
  72. package/src/lib/core/theme/getCurrentColor.ts +10 -0
  73. package/src/lib/core/theme/resolve.ts +29 -0
  74. package/src/lib/core/theme/shapes.ts +7 -0
  75. package/src/lib/core/theme/spacing.ts +7 -0
  76. package/src/lib/core/theme/store.ts +26 -0
  77. package/src/lib/core/theme/systemTheme.ts +20 -0
  78. package/src/lib/core/theme/theme.ts +15 -0
  79. package/src/lib/core/theme/typography.ts +29 -0
  80. package/src/lib/index.ts +42 -0
  81. package/src/main.ts +9 -0
  82. package/svelte.config.js +8 -0
  83. package/tsconfig.app.json +21 -0
  84. package/tsconfig.json +7 -0
  85. package/tsconfig.node.json +26 -0
  86. package/vite.config.ts +11 -0
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="26.6" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 308"><path fill="#FF3E00" d="M239.682 40.707C211.113-.182 154.69-12.301 113.895 13.69L42.247 59.356a82.198 82.198 0 0 0-37.135 55.056a86.566 86.566 0 0 0 8.536 55.576a82.425 82.425 0 0 0-12.296 30.719a87.596 87.596 0 0 0 14.964 66.244c28.574 40.893 84.997 53.007 125.787 27.016l71.648-45.664a82.182 82.182 0 0 0 37.135-55.057a86.601 86.601 0 0 0-8.53-55.577a82.409 82.409 0 0 0 12.29-30.718a87.573 87.573 0 0 0-14.963-66.244"></path><path fill="#FFF" d="M106.889 270.841c-23.102 6.007-47.497-3.036-61.103-22.648a52.685 52.685 0 0 1-9.003-39.85a49.978 49.978 0 0 1 1.713-6.693l1.35-4.115l3.671 2.697a92.447 92.447 0 0 0 28.036 14.007l2.663.808l-.245 2.659a16.067 16.067 0 0 0 2.89 10.656a17.143 17.143 0 0 0 18.397 6.828a15.786 15.786 0 0 0 4.403-1.935l71.67-45.672a14.922 14.922 0 0 0 6.734-9.977a15.923 15.923 0 0 0-2.713-12.011a17.156 17.156 0 0 0-18.404-6.832a15.78 15.78 0 0 0-4.396 1.933l-27.35 17.434a52.298 52.298 0 0 1-14.553 6.391c-23.101 6.007-47.497-3.036-61.101-22.649a52.681 52.681 0 0 1-9.004-39.849a49.428 49.428 0 0 1 22.34-33.114l71.664-45.677a52.218 52.218 0 0 1 14.563-6.398c23.101-6.007 47.497 3.036 61.101 22.648a52.685 52.685 0 0 1 9.004 39.85a50.559 50.559 0 0 1-1.713 6.692l-1.35 4.116l-3.67-2.693a92.373 92.373 0 0 0-28.037-14.013l-2.664-.809l.246-2.658a16.099 16.099 0 0 0-2.89-10.656a17.143 17.143 0 0 0-18.398-6.828a15.786 15.786 0 0 0-4.402 1.935l-71.67 45.674a14.898 14.898 0 0 0-6.73 9.975a15.9 15.9 0 0 0 2.709 12.012a17.156 17.156 0 0 0 18.404 6.832a15.841 15.841 0 0 0 4.402-1.935l27.345-17.427a52.147 52.147 0 0 1 14.552-6.397c23.101-6.006 47.497 3.037 61.102 22.65a52.681 52.681 0 0 1 9.003 39.848a49.453 49.453 0 0 1-22.34 33.12l-71.664 45.673a52.218 52.218 0 0 1-14.563 6.398"></path></svg>
@@ -0,0 +1,10 @@
1
+ <script lang="ts">
2
+ let count: number = $state(0)
3
+ const increment = () => {
4
+ count += 1
5
+ }
6
+ </script>
7
+
8
+ <button onclick={increment}>
9
+ count is {count}
10
+ </button>
@@ -0,0 +1,15 @@
1
+ <script lang="ts">
2
+ import { Modifier } from "../core/modifier/Modifier";
3
+
4
+ export let modifier: Modifier = Modifier.empty();
5
+ </script>
6
+
7
+ <div
8
+ style={`
9
+ width:100vw;
10
+ height:100vh;
11
+ ${modifier.toStyle()}
12
+ `}
13
+ >
14
+ <slot />
15
+ </div>
@@ -0,0 +1,12 @@
1
+ export const ContentScale = {
2
+ Crop: "cover",
3
+ Fit: "contain",
4
+ FillBounds: "fill",
5
+ Inside: "contain",
6
+ FillWidth: "fillWidth",
7
+ FillHeight: "fillHeight",
8
+ None: "none",
9
+ } as const;
10
+
11
+ export type ContentScaleToken =
12
+ typeof ContentScale[keyof typeof ContentScale];
@@ -0,0 +1,47 @@
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 painter: string = "";
7
+
8
+ export let tint: ColorToken | string | undefined = undefined;
9
+
10
+ export let modifier: Modifier = Modifier.empty();
11
+
12
+ // Lógica simple y segura
13
+ $: backgroundColor = (() => {
14
+ if (!tint) return resolveColor(ColorScheme.OnBackground as ColorToken);
15
+
16
+ // Si es color directo (hex, rgb, hsl, named)
17
+ if (
18
+ typeof tint === "string" &&
19
+ (tint.startsWith("#") || tint.startsWith("rgb") || tint.startsWith("hsl") || tint === "transparent")
20
+ ) {
21
+ return tint;
22
+ }
23
+
24
+ // Si es token del tema (string key como "primary", "onSurface")
25
+ if (typeof tint === "string") {
26
+ return resolveColor(tint as ColorToken); // var(--md-sys-color-primary)
27
+ }
28
+
29
+ return "currentColor";
30
+ })();
31
+ </script>
32
+
33
+ <div
34
+ class="block"
35
+ style={`
36
+ -webkit-mask-image: url(${painter});
37
+ mask-image: url(${painter});
38
+ -webkit-mask-repeat: no-repeat;
39
+ mask-repeat: no-repeat;
40
+ -webkit-mask-size: contain;
41
+ mask-size: contain;
42
+ -webkit-mask-position: center;
43
+ mask-position: center;
44
+ background-color: ${backgroundColor};
45
+ ${modifier.toStyle()}
46
+ `}
47
+ ></div>
@@ -0,0 +1,31 @@
1
+ <script lang="ts">
2
+ import { Modifier } from "../core/modifier/Modifier";
3
+ import { ContentScale, type ContentScaleToken } from "./ContentScale";
4
+
5
+ export let painter: string = "";
6
+ export let contentScale: ContentScaleToken = ContentScale.Fit;
7
+ export let contentDescription: string = "";
8
+ export let modifier: Modifier = Modifier.empty();
9
+
10
+ $: isFillWidth = contentScale === "fillWidth";
11
+ $: isFillHeight = contentScale === "fillHeight";
12
+
13
+ $: objectFit =
14
+ isFillWidth || isFillHeight
15
+ ? "cover"
16
+ : contentScale;
17
+ </script>
18
+
19
+ <div class="relative overflow-hidden" style={modifier.toStyle()}>
20
+ <img
21
+ src={painter}
22
+ alt={contentDescription}
23
+ class="absolute inset-0"
24
+ style={`
25
+ width: ${isFillHeight ? "auto" : "100%"};
26
+ height: ${isFillWidth ? "auto" : "100%"};
27
+ object-fit: ${objectFit};
28
+ object-position: center;
29
+ `}
30
+ />
31
+ </div>
@@ -0,0 +1,11 @@
1
+ <script lang="ts">
2
+ import { Modifier } from "../core/modifier/Modifier";
3
+
4
+ /**
5
+ * Spacer: ocupa espacio vacío.
6
+ * Uso: <Spacer modifier={Modifier.height(16)} /> o width()
7
+ */
8
+ export let modifier: Modifier = Modifier.empty();
9
+ </script>
10
+
11
+ <div style={modifier.toStyle()}></div>
@@ -0,0 +1,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
+ // ✅ default = no-op modifier
7
+ export let modifier: Modifier = Modifier.empty();
8
+ export let color: ColorToken = "surface";
9
+ </script>
10
+
11
+ <div
12
+ class="block"
13
+ style={`
14
+ background:${resolveColor(color)};
15
+ ${modifier.toStyle()}
16
+ `}
17
+ >
18
+ <slot />
19
+ </div>
@@ -0,0 +1,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"; // string literal por defecto
12
+
13
+ // Usamos la misma lógica que Surface (que ya funciona)
14
+ $: resolvedColor = typeof color === "string" ? resolveColor(color as ColorToken) : color;
15
+ </script>
16
+
17
+ <p class="block m-0" style={`
18
+ ${resolveTextStyle(textStyle)};
19
+ color: ${resolvedColor};
20
+ ${modifier.toStyle()}
21
+ `}>
22
+ <slot />
23
+ </p>
@@ -0,0 +1,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
+ // Defaults para TonalButton (secundario suave)
10
+ export let color: ColorToken | string = "secondaryContainer";
11
+ export let onColor: ColorToken | string = "onSecondaryContainer";
12
+
13
+ export let shape: "none" | "extraSmall" | "small" | "medium" | "large" = "large";
14
+ export let elevation: "level0" | "level1" | "level2" | "level3" | "level4" = "level0"; // Tonal suele ser sin elevación
15
+
16
+ $: backgroundColor = typeof color === "string" ? resolveColor(color as ColorToken) : color;
17
+ $: contentColor = typeof onColor === "string" ? resolveColor(onColor as ColorToken) : onColor;
18
+ $: borderRadius = `var(--md-sys-shape-${shape})`;
19
+ $: boxShadow = `var(--md-sys-elevation-${elevation})`;
20
+ </script>
21
+
22
+ <button
23
+ on:click={onClick}
24
+ class="border-0 cursor-pointer flex items-center justify-center gap-8 px-24 py-12 font-medium tracking-wider transition-all hover:opacity-90 active:scale-95"
25
+ style={`
26
+ background: ${backgroundColor};
27
+ color: ${contentColor};
28
+ border-radius: ${borderRadius};
29
+ box-shadow: ${boxShadow};
30
+ ${modifier.toStyle()}
31
+ `}
32
+ >
33
+ <slot />
34
+ </button>
@@ -0,0 +1,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
+ <button
22
+ on:click={onClick}
23
+ class="border-0 cursor-pointer inline-flex items-center justify-center gap-8 font-medium tracking-wider transition-all hover:opacity-90 active:scale-95"
24
+ style={`
25
+ background: ${backgroundColor};
26
+ color: ${contentColor};
27
+ border-radius: ${borderRadius};
28
+ box-shadow: ${boxShadow};
29
+ padding: 10px 24px; <!-- Padding moderado: vertical 10px, horizontal 24px (como Compose) -->
30
+ ${modifier.toStyle()}
31
+ `}
32
+ >
33
+ <slot />
34
+ </button>
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,37 @@
1
+ export const Alignment = {
2
+ // Horizontal only (para Column)
3
+ Start: "flex-start",
4
+ CenterHorizontally: "center",
5
+ End: "flex-end",
6
+
7
+ // Vertical only (para Row)
8
+ Top: "flex-start",
9
+ CenterVertically: "center",
10
+ Bottom: "flex-end",
11
+
12
+ // Compuestos (para Box y layouts avanzados)
13
+ TopStart: "flex-start flex-start",
14
+ TopCenter: "center flex-start",
15
+ TopEnd: "flex-end flex-start",
16
+
17
+ CenterStart: "flex-start center",
18
+ Center: "center center",
19
+ CenterEnd: "flex-end center",
20
+
21
+ BottomStart: "flex-start flex-end",
22
+ BottomCenter: "center flex-end",
23
+ BottomEnd: "flex-end flex-end",
24
+ } as const;
25
+
26
+ // Tipos separados para mayor seguridad
27
+ export type HorizontalAlignment =
28
+ typeof Alignment.Start |
29
+ typeof Alignment.CenterHorizontally |
30
+ typeof Alignment.End;
31
+
32
+ export type VerticalAlignment =
33
+ typeof Alignment.Top |
34
+ typeof Alignment.CenterVertically |
35
+ typeof Alignment.Bottom;
36
+
37
+ export type BoxAlignment = typeof Alignment[keyof typeof Alignment];
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Arrangement — eje principal (main axis)
3
+ * Fiel a Jetpack Compose
4
+ */
5
+
6
+ export type ArrangementValue =
7
+ | {
8
+ type: "static";
9
+ justifyContent: string;
10
+ }
11
+ | {
12
+ type: "spaced";
13
+ gap: number;
14
+ justifyContent: string;
15
+ };
16
+
17
+ export const Arrangement = {
18
+ // --- simples ---
19
+ Start: {
20
+ type: "static",
21
+ justifyContent: "flex-start",
22
+ } as ArrangementValue,
23
+
24
+ Center: {
25
+ type: "static",
26
+ justifyContent: "center",
27
+ } as ArrangementValue,
28
+
29
+ End: {
30
+ type: "static",
31
+ justifyContent: "flex-end",
32
+ } as ArrangementValue,
33
+
34
+ Bottom: {
35
+ type: "static",
36
+ justifyContent: "flex-end"
37
+ } as ArrangementValue,
38
+
39
+ Top: {
40
+ type: "static",
41
+ justifyContent: "flex-start"
42
+ } as ArrangementValue,
43
+
44
+ SpaceBetween: {
45
+ type: "static",
46
+ justifyContent: "space-between",
47
+ } as ArrangementValue,
48
+
49
+ SpaceAround: {
50
+ type: "static",
51
+ justifyContent: "space-around",
52
+ } as ArrangementValue,
53
+
54
+ SpaceEvenly: {
55
+ type: "static",
56
+ justifyContent: "space-evenly",
57
+ } as ArrangementValue,
58
+
59
+ spacedBy(value: number): ArrangementValue {
60
+ return {
61
+ type: "spaced",
62
+ gap: value,
63
+ justifyContent: "flex-start",
64
+ };
65
+ },
66
+ } as const;
@@ -0,0 +1,25 @@
1
+ <script lang="ts">
2
+ import { Modifier } from "../../core/modifier/Modifier";
3
+ import type {BoxAlignment} from "./Alignment";
4
+
5
+ export let modifier: Modifier = Modifier.empty();
6
+ export let contentAlignment: BoxAlignment | undefined = undefined;
7
+
8
+ $: contentStyle = contentAlignment ? alignmentToFlexStyle(contentAlignment) : "";
9
+
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";
15
+
16
+ return `display:flex; align-items:${v}; justify-content:${horiz};`;
17
+ }
18
+ </script>
19
+
20
+ <div
21
+ class="relative"
22
+ style={`${contentStyle} ${modifier.toStyle()}`}
23
+ >
24
+ <slot />
25
+ </div>
@@ -0,0 +1,23 @@
1
+ <script lang="ts">
2
+ import { Modifier } from "../../core/modifier/Modifier";
3
+ import { Alignment } from "./Alignment";
4
+ import { Arrangement } from "./Arrangement";
5
+ import type { ArrangementValue } from "./Arrangement";
6
+ import type { HorizontalAlignment } from "./Alignment";
7
+
8
+ export let modifier: Modifier = Modifier.empty();
9
+ export let horizontalAlignment: HorizontalAlignment = Alignment.Start;
10
+ export let verticalArrangement: ArrangementValue = Arrangement.Start;
11
+ </script>
12
+
13
+ <div
14
+ class="flex flex-col"
15
+ style={`
16
+ align-items: ${horizontalAlignment};
17
+ justify-content: ${verticalArrangement.justifyContent};
18
+ ${verticalArrangement.type === "spaced" ? `gap:${verticalArrangement.gap}px;` : ""}
19
+ ${modifier.toStyle()}
20
+ `}
21
+ >
22
+ <slot />
23
+ </div>
File without changes
File without changes
@@ -0,0 +1,23 @@
1
+ <script lang="ts">
2
+ import { Modifier } from "../../core/modifier/Modifier";
3
+ import { Alignment } from "./Alignment";
4
+ import { Arrangement } from "./Arrangement";
5
+ import type { ArrangementValue } from "./Arrangement";
6
+ import type { VerticalAlignment } from "./Alignment";
7
+
8
+ export let modifier: Modifier = Modifier.empty();
9
+ export let verticalAlignment: VerticalAlignment = Alignment.Top;
10
+ export let horizontalArrangement: ArrangementValue = Arrangement.Start;
11
+ </script>
12
+
13
+ <div
14
+ class="flex flex-row"
15
+ style={`
16
+ align-items: ${verticalAlignment};
17
+ justify-content: ${horizontalArrangement.justifyContent};
18
+ ${horizontalArrangement.type === "spaced" ? `gap:${horizontalArrangement.gap}px;` : ""}
19
+ ${modifier.toStyle()}
20
+ `}
21
+ >
22
+ <slot />
23
+ </div>
File without changes
File without changes
@@ -0,0 +1,130 @@
1
+ <script lang="ts">
2
+ import { Modifier } from "../../core/modifier/Modifier";
3
+ import { resolveColor, resolveTextStyle } from "../../core/theme/resolve";
4
+ import type { TextStyleToken } from "../../core/theme/TextStyle";
5
+ import { RoundedCornerShape } from "../../core/shapes/RoundedCornerShape";
6
+ import type { Shape } from "../../core/shapes/Shape";
7
+ import type { TextFieldColors } from "./TextFieldColors";
8
+ import { TextFieldDefaults } from "./TextFieldDefaults";
9
+
10
+ export let value = "";
11
+ export let onValueChange = (v: string) => {};
12
+ export let label = "";
13
+ export let placeholder = "";
14
+ export let singleLine = true;
15
+ export let textStyle: TextStyleToken = "bodyLarge";
16
+ export let modifier: Modifier = Modifier.empty();
17
+ export let shape: Shape = RoundedCornerShape(12);
18
+ export let colors: TextFieldColors = TextFieldDefaults.filledColors();
19
+
20
+
21
+ let focused = false;
22
+
23
+ const height = 56;
24
+
25
+ $: hasText = value.length > 0;
26
+ $: floating = focused || hasText;
27
+
28
+ // Colores Material Filled // OPACO
29
+ $: onSurface = resolveColor("onSurface");
30
+ $: onSurfaceVariant = resolveColor("onSurfaceVariant");
31
+ $: primary = resolveColor("primary");
32
+ $: fieldHeight = singleLine ? 56 : "auto";
33
+ $: containerColor = colors.container;
34
+ $: labelColor = floating ? colors.cursor : colors.label;
35
+ $: textColor = colors.text;
36
+ $: cursorColor = colors.cursor;
37
+ $: indicatorColor = focused
38
+ ? colors.indicatorFocused
39
+ : colors.indicatorUnfocused;
40
+ const minMultilineHeight = 88; // Material guideline
41
+
42
+ function handleInput(e: Event) {
43
+ const target = e.target as HTMLInputElement | HTMLTextAreaElement;
44
+ onValueChange(target.value);
45
+ }
46
+ </script>
47
+
48
+ <div
49
+ class="relative overflow-hidden"
50
+ style={`
51
+ ${singleLine ? `height:56px;` : `min-height:88px;`}
52
+ background:${colors.container};
53
+ border-radius:${shape.toCssBorderRadius()};
54
+ border:1px solid transparent;
55
+ ${modifier.toStyle()}
56
+ `}
57
+ >
58
+ <div
59
+ class="grid h-full items-center"
60
+ style="grid-template-columns:auto 1fr auto; padding:0 16px;"
61
+ >
62
+ <!-- Leading icon -->
63
+ <div class="w-24 flex justify-center">
64
+ <slot name="leadingIcon" />
65
+ </div>
66
+
67
+ <!-- Field -->
68
+ <div class="relative h-full flex flex-col justify-center">
69
+ {#if label}
70
+ <label
71
+ class="absolute left-0 pointer-events-none transition-all duration-200"
72
+ style={`
73
+ top:${floating ? "6px" : "50%"};
74
+ transform:translateY(${floating ? "0" : "-50%"});
75
+ font-size:${floating ? "12px" : "16px"};
76
+ color:${labelColor};
77
+ `}
78
+ >
79
+ {label}
80
+ </label>
81
+ {/if}
82
+
83
+ {#if singleLine}
84
+ <input
85
+ type="text"
86
+ bind:value
87
+ on:input={handleInput}
88
+ on:focus={() => focused = true}
89
+ on:blur={() => focused = false}
90
+ placeholder={focused ? placeholder : ""}
91
+ class="w-full bg-transparent outline-none"
92
+ style={`
93
+ font:${resolveTextStyle(textStyle)};
94
+ color:${textColor};
95
+ caret-color:${cursorColor};
96
+ padding-top:20px;
97
+ `}
98
+ />
99
+ {:else}
100
+ <textarea
101
+ bind:value
102
+ on:input={handleInput}
103
+ on:focus={() => focused = true}
104
+ on:blur={() => focused = false}
105
+ placeholder={focused ? placeholder : ""}
106
+ rows="3"
107
+ class="w-full bg-transparent outline-none resize-none"
108
+ style={`
109
+ font:${resolveTextStyle(textStyle)};
110
+ color:${textColor};
111
+ caret-color:${cursorColor};
112
+ padding-top:20px;
113
+ padding-bottom:12px;
114
+ `}
115
+ ></textarea>
116
+ {/if}
117
+ </div>
118
+
119
+ <!-- Trailing icon -->
120
+ <div class="w-24 flex justify-center">
121
+ <slot name="trailingIcon" />
122
+ </div>
123
+ </div>
124
+
125
+ <!-- Indicator -->
126
+ <div
127
+ class="absolute bottom-0 left-0 right-0 h-1"
128
+ style={`background:${indicatorColor};`}
129
+ ></div>
130
+ </div>
@@ -0,0 +1,52 @@
1
+ <script lang="ts">
2
+ import BaseTextField from "./BaseTextField.svelte";
3
+ import { TextFieldDefaults } from "./TextFieldDefaults";
4
+ import type { TextFieldColors } from "./TextFieldColors";
5
+ import { Modifier } from "../../core/modifier/Modifier";
6
+ import { RoundedCornerShape } from "../../core/shapes/RoundedCornerShape";
7
+ import type { Shape } from "../../core/shapes/Shape";
8
+ import type { TextStyleToken } from "../../core/theme/TextStyle";
9
+
10
+ export let value = "";
11
+ export let onValueChange = (v: string) => {};
12
+ export let label = "";
13
+ export let placeholder = "";
14
+ export let singleLine = true;
15
+ export let textStyle: TextStyleToken = "bodyLarge";
16
+ export let modifier: Modifier = Modifier.empty();
17
+ export let shape: Shape = RoundedCornerShape(12);
18
+
19
+ // 🔒 OutlinedTextField SIEMPRE usa outlinedColors por defecto
20
+ export let colors: TextFieldColors = TextFieldDefaults.outlinedColors();
21
+
22
+ let focused = false;
23
+ </script>
24
+
25
+ <div
26
+ class="relative"
27
+ style={`
28
+ border:1px solid ${focused
29
+ ? colors.borderFocused
30
+ : colors.borderUnfocused};
31
+ border-radius:${shape.toCssBorderRadius()};
32
+ transition:border-color 200ms;
33
+ ${modifier.toStyle()}
34
+ `}
35
+ >
36
+ <BaseTextField
37
+ value={value}
38
+ onValueChange={onValueChange}
39
+ label={label}
40
+ placeholder={placeholder}
41
+ singleLine={singleLine}
42
+ textStyle={textStyle}
43
+ modifier={Modifier.empty()}
44
+ shape={shape}
45
+ colors={colors}
46
+ on:focus={() => focused = true}
47
+ on:blur={() => focused = false}
48
+ >
49
+ <slot name="leadingIcon" slot="leadingIcon" />
50
+ <slot name="trailingIcon" slot="trailingIcon" />
51
+ </BaseTextField>
52
+ </div>