@danielito1996/compose-svelted 0.2.3 → 0.2.5
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/dist/components/AppRoot.svelte +15 -0
- package/dist/components/AppRoot.svelte.d.ts +30 -0
- package/dist/components/ContentScale.d.ts +10 -0
- package/dist/components/ContentScale.js +9 -0
- package/dist/components/Icon.svelte +47 -0
- package/dist/components/Icon.svelte.d.ts +24 -0
- package/dist/components/Image.svelte +31 -0
- package/dist/components/Image.svelte.d.ts +25 -0
- package/dist/components/Spacer.svelte +11 -0
- package/dist/components/Spacer.svelte.d.ts +24 -0
- package/dist/components/Surface.svelte +19 -0
- package/dist/components/Surface.svelte.d.ts +32 -0
- package/dist/components/Text.svelte +23 -0
- package/dist/components/Text.svelte.d.ts +34 -0
- package/dist/components/TonalButton.svelte +34 -0
- package/dist/components/TonalButton.svelte.d.ts +36 -0
- package/dist/components/buttons/Button.svelte +34 -0
- package/dist/components/buttons/Button.svelte.d.ts +36 -0
- package/dist/components/buttons/ButtonWithIcon.svelte +0 -0
- package/dist/components/buttons/ButtonWithIcon.svelte.d.ts +26 -0
- package/dist/components/buttons/CheckButton.svelte +77 -0
- package/dist/components/buttons/CheckButton.svelte.d.ts +35 -0
- package/dist/components/buttons/IconButton.svelte +0 -0
- package/dist/components/buttons/IconButton.svelte.d.ts +26 -0
- package/dist/components/buttons/OutlinedButton.svelte +0 -0
- package/dist/components/buttons/OutlinedButton.svelte.d.ts +26 -0
- package/dist/components/buttons/OutlinedButtonWithIcon.svelte +0 -0
- package/dist/components/buttons/OutlinedButtonWithIcon.svelte.d.ts +26 -0
- package/dist/components/buttons/OutlinedIconButton.svelte +0 -0
- package/dist/components/buttons/OutlinedIconButton.svelte.d.ts +26 -0
- package/dist/components/buttons/TextButton.svelte +0 -0
- package/dist/components/buttons/TextButton.svelte.d.ts +26 -0
- package/dist/components/cards/Card.svelte +26 -0
- package/dist/components/cards/Card.svelte.d.ts +33 -0
- package/dist/components/cards/OutlinedCard.svelte +0 -0
- package/dist/components/cards/OutlinedCard.svelte.d.ts +26 -0
- package/dist/components/custom/CodeBlock.svelte +41 -0
- package/dist/components/custom/CodeBlock.svelte.d.ts +32 -0
- package/dist/components/layouts/Alignment.d.ts +20 -0
- package/dist/components/layouts/Alignment.js +20 -0
- package/dist/components/layouts/Arrangement.d.ts +23 -0
- package/dist/components/layouts/Arrangement.js +46 -0
- package/dist/components/layouts/Box.svelte +25 -0
- package/dist/components/layouts/Box.svelte.d.ts +32 -0
- package/dist/components/layouts/Column.svelte +23 -0
- package/dist/components/layouts/Column.svelte.d.ts +34 -0
- package/dist/components/layouts/LazyColumn.svelte +107 -0
- package/dist/components/layouts/LazyColumn.svelte.d.ts +39 -0
- package/dist/components/layouts/LazyRow.svelte +71 -0
- package/dist/components/layouts/LazyRow.svelte.d.ts +42 -0
- package/dist/components/layouts/Row.svelte +23 -0
- package/dist/components/layouts/Row.svelte.d.ts +34 -0
- package/dist/components/layouts/Scaffold.svelte +73 -0
- package/dist/components/layouts/Scaffold.svelte.d.ts +38 -0
- package/dist/components/menus/DropdownMenu.svelte +0 -0
- package/dist/components/menus/DropdownMenu.svelte.d.ts +26 -0
- package/dist/components/menus/DropdownMenuItem.svelte +0 -0
- package/dist/components/menus/DropdownMenuItem.svelte.d.ts +26 -0
- package/dist/components/motion/AnimatedContent.svelte +34 -0
- package/dist/components/motion/AnimatedContent.svelte.d.ts +31 -0
- package/dist/components/motion/AnimatedVisibility.svelte +59 -0
- package/dist/components/motion/AnimatedVisibility.svelte.d.ts +32 -0
- package/dist/components/textFields/BaseTextField.svelte +188 -0
- package/dist/components/textFields/BaseTextField.svelte.d.ts +41 -0
- package/dist/components/textFields/OutlinedTextField.svelte +64 -0
- package/dist/components/textFields/OutlinedTextField.svelte.d.ts +46 -0
- package/dist/components/textFields/TextField.svelte +49 -0
- package/dist/components/textFields/TextField.svelte.d.ts +46 -0
- package/dist/components/textFields/TextFieldColors.d.ts +12 -0
- package/dist/components/textFields/TextFieldColors.js +1 -0
- package/dist/components/textFields/TextFieldDefaults.d.ts +11 -0
- package/dist/components/textFields/TextFieldDefaults.js +42 -0
- package/dist/core/elevation/elevation.d.ts +1 -0
- package/dist/core/elevation/elevation.js +6 -0
- package/dist/core/helpers/painterResource.d.ts +12 -0
- package/dist/core/helpers/painterResource.js +22 -0
- package/dist/core/modifier/Modifier.d.ts +195 -0
- package/dist/core/modifier/Modifier.js +237 -0
- package/dist/core/modifier/ModifierImpl.d.ts +38 -0
- package/dist/core/modifier/ModifierImpl.js +214 -0
- package/dist/core/motion/AnimationSpec.d.ts +6 -0
- package/dist/core/motion/AnimationSpec.js +1 -0
- package/dist/core/motion/ContentTransition.d.ts +5 -0
- package/dist/core/motion/ContentTransition.js +1 -0
- package/dist/core/motion/applyAnimation.d.ts +0 -0
- package/dist/core/motion/applyAnimation.js +0 -0
- package/dist/core/motion/contentTransitions.d.ts +4 -0
- package/dist/core/motion/contentTransitions.js +22 -0
- package/dist/core/motion/transitions.d.ts +7 -0
- package/dist/core/motion/transitions.js +70 -0
- package/dist/core/navigation/NavBackStackEntry.d.ts +4 -0
- package/dist/core/navigation/NavBackStackEntry.js +1 -0
- package/dist/core/navigation/NavController.d.ts +9 -0
- package/dist/core/navigation/NavController.js +31 -0
- package/dist/core/navigation/NavHost.svelte +45 -0
- package/dist/core/navigation/NavHost.svelte.d.ts +31 -0
- package/dist/core/navigation/NavStore.d.ts +7 -0
- package/dist/core/navigation/NavStore.js +24 -0
- package/dist/core/navigation/Route.d.ts +3 -0
- package/dist/core/navigation/Route.js +1 -0
- package/dist/core/navigation/composable.d.ts +5 -0
- package/dist/core/navigation/composable.js +6 -0
- package/dist/core/navigation/rememberNavController.d.ts +2 -0
- package/dist/core/navigation/rememberNavController.js +4 -0
- package/dist/core/shapes/RoundedCornerShape.d.ts +13 -0
- package/dist/core/shapes/RoundedCornerShape.js +27 -0
- package/dist/core/shapes/Shape.d.ts +3 -0
- package/dist/core/shapes/Shape.js +1 -0
- package/dist/core/theme/ColorScheme.d.ts +17 -0
- package/dist/core/theme/ColorScheme.js +15 -0
- package/dist/core/theme/ComposeTheme.svelte +22 -0
- package/dist/core/theme/ComposeTheme.svelte.d.ts +32 -0
- package/dist/core/theme/Density.d.ts +5 -0
- package/dist/core/theme/Density.js +4 -0
- package/dist/core/theme/TextStyle.d.ts +19 -0
- package/dist/core/theme/TextStyle.js +17 -0
- package/dist/core/theme/colors.d.ts +15 -0
- package/dist/core/theme/colors.js +1 -0
- package/dist/core/theme/cssVars.d.ts +2 -0
- package/dist/core/theme/cssVars.js +29 -0
- package/dist/core/theme/defaults/darkColors.d.ts +2 -0
- package/dist/core/theme/defaults/darkColors.js +15 -0
- package/dist/core/theme/defaults/defaultTheme.d.ts +3 -0
- package/dist/core/theme/defaults/defaultTheme.js +40 -0
- package/dist/core/theme/defaults/lightColors.d.ts +2 -0
- package/dist/core/theme/defaults/lightColors.js +15 -0
- package/dist/core/theme/defaults/typography.d.ts +2 -0
- package/dist/core/theme/defaults/typography.js +120 -0
- package/dist/core/theme/elevation.d.ts +7 -0
- package/dist/core/theme/elevation.js +1 -0
- package/dist/core/theme/getCurrentColor.d.ts +1 -0
- package/dist/core/theme/getCurrentColor.js +9 -0
- package/dist/core/theme/resolve.d.ts +5 -0
- package/dist/core/theme/resolve.js +17 -0
- package/dist/core/theme/shapes.d.ts +7 -0
- package/dist/core/theme/shapes.js +1 -0
- package/dist/core/theme/spacing.d.ts +7 -0
- package/dist/core/theme/spacing.js +1 -0
- package/dist/core/theme/store.d.ts +7 -0
- package/dist/core/theme/store.js +15 -0
- package/dist/core/theme/systemTheme.d.ts +2 -0
- package/dist/core/theme/systemTheme.js +14 -0
- package/dist/core/theme/theme.d.ts +13 -0
- package/dist/core/theme/theme.js +1 -0
- package/dist/core/theme/typography.d.ts +24 -0
- package/dist/core/theme/typography.js +1 -0
- package/dist/index.d.ts +22 -45
- package/package.json +46 -12
- package/dist/index.js +0 -1164
- package/dist/vite.svg +0 -1
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Modifier } from "../../core/modifier/Modifier";
|
|
3
|
+
import { 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
|
+
import { Density, type DensityToken } from "../../core/theme/Density";
|
|
10
|
+
|
|
11
|
+
// ===== Public API =====
|
|
12
|
+
export let value = "";
|
|
13
|
+
export let onValueChange = (_value: string) => {};
|
|
14
|
+
export let label = "";
|
|
15
|
+
export let placeholder = "";
|
|
16
|
+
export let supportingText: string | undefined;
|
|
17
|
+
|
|
18
|
+
export let singleLine = true;
|
|
19
|
+
export let textStyle: TextStyleToken = "bodyLarge";
|
|
20
|
+
export let modifier: Modifier = Modifier.empty();
|
|
21
|
+
export let shape: Shape = RoundedCornerShape(12);
|
|
22
|
+
export let colors: TextFieldColors = TextFieldDefaults.filledColors();
|
|
23
|
+
|
|
24
|
+
export let enabled = true;
|
|
25
|
+
export let readOnly = false;
|
|
26
|
+
export let isError = false;
|
|
27
|
+
export let density: DensityToken = Density.Default;
|
|
28
|
+
|
|
29
|
+
let focused = false;
|
|
30
|
+
|
|
31
|
+
const inputId = `tf-${Math.random().toString(36).slice(2)}`;
|
|
32
|
+
|
|
33
|
+
// ===== State =====
|
|
34
|
+
$: hasText = value.length > 0;
|
|
35
|
+
$: floating = focused || hasText;
|
|
36
|
+
|
|
37
|
+
$: hasLeading = !!$$slots.leadingIcon;
|
|
38
|
+
$: hasTrailing = !!$$slots.trailingIcon;
|
|
39
|
+
|
|
40
|
+
// ===== Density =====
|
|
41
|
+
$: fieldHeight = density === Density.Compact ? 44 : 56;
|
|
42
|
+
$: minMultilineHeight = density === Density.Compact ? 72 : 88;
|
|
43
|
+
$: paddingTop = density === Density.Compact ? 14 : 20;
|
|
44
|
+
$: paddingBottom = density === Density.Compact ? 6 : 8;
|
|
45
|
+
|
|
46
|
+
// ===== Colors =====
|
|
47
|
+
const errorColor = "var(--md-sys-color-error)";
|
|
48
|
+
|
|
49
|
+
$: labelColor = isError
|
|
50
|
+
? errorColor
|
|
51
|
+
: floating
|
|
52
|
+
? colors.cursor
|
|
53
|
+
: colors.label;
|
|
54
|
+
|
|
55
|
+
$: textColor = enabled ? colors.text : colors.label;
|
|
56
|
+
|
|
57
|
+
$: indicatorColor = isError
|
|
58
|
+
? errorColor
|
|
59
|
+
: focused
|
|
60
|
+
? colors.indicatorFocused
|
|
61
|
+
: colors.indicatorUnfocused;
|
|
62
|
+
|
|
63
|
+
$: supportingColor = isError ? errorColor : colors.label;
|
|
64
|
+
|
|
65
|
+
function handleInput(e: Event) {
|
|
66
|
+
if (!enabled || readOnly) return;
|
|
67
|
+
const target = e.target as HTMLInputElement | HTMLTextAreaElement;
|
|
68
|
+
onValueChange(target.value);
|
|
69
|
+
}
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<!-- Wrapper -->
|
|
73
|
+
<div class="flex flex-col gap-2" style={modifier.toStyle()}>
|
|
74
|
+
<!-- Field -->
|
|
75
|
+
<div
|
|
76
|
+
class="relative overflow-hidden transition-colors duration-150 group"
|
|
77
|
+
style={`
|
|
78
|
+
${singleLine ? `height:${fieldHeight}px;` : `min-height:${minMultilineHeight}px;`}
|
|
79
|
+
background:${colors.container};
|
|
80
|
+
border-radius:${shape.toCssBorderRadius()};
|
|
81
|
+
opacity:${enabled ? 1 : 0.6};
|
|
82
|
+
`}
|
|
83
|
+
>
|
|
84
|
+
<!-- Hover overlay (desktop only via CSS) -->
|
|
85
|
+
<div
|
|
86
|
+
class="absolute inset-0 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity"
|
|
87
|
+
style="background: rgba(0,0,0,0.04);"
|
|
88
|
+
></div>
|
|
89
|
+
|
|
90
|
+
<div
|
|
91
|
+
class="grid h-full items-center"
|
|
92
|
+
style={`
|
|
93
|
+
grid-template-columns: ${hasLeading ? "auto " : ""}1fr${hasTrailing ? " auto" : ""};
|
|
94
|
+
padding: 0 16px;
|
|
95
|
+
column-gap: 12px;
|
|
96
|
+
`}
|
|
97
|
+
>
|
|
98
|
+
{#if hasLeading}
|
|
99
|
+
<div class="flex items-center justify-center">
|
|
100
|
+
<slot name="leadingIcon" />
|
|
101
|
+
</div>
|
|
102
|
+
{/if}
|
|
103
|
+
|
|
104
|
+
<!-- Input / Label -->
|
|
105
|
+
<div class="relative h-full flex flex-col justify-center">
|
|
106
|
+
{#if label}
|
|
107
|
+
<label
|
|
108
|
+
for={inputId}
|
|
109
|
+
class="absolute left-0 pointer-events-none origin-left transition-all duration-200"
|
|
110
|
+
style={`
|
|
111
|
+
top:${floating ? "2px" : "50%"};
|
|
112
|
+
transform:
|
|
113
|
+
translateY(${floating ? "0" : "-50%"})
|
|
114
|
+
scale(${floating ? 0.72 : 1});
|
|
115
|
+
color:${labelColor};
|
|
116
|
+
`}
|
|
117
|
+
>
|
|
118
|
+
{label}
|
|
119
|
+
</label>
|
|
120
|
+
{/if}
|
|
121
|
+
|
|
122
|
+
{#if singleLine}
|
|
123
|
+
<input
|
|
124
|
+
id={inputId}
|
|
125
|
+
type="text"
|
|
126
|
+
bind:value
|
|
127
|
+
on:input={handleInput}
|
|
128
|
+
on:focus={() => (focused = true)}
|
|
129
|
+
on:blur={() => (focused = false)}
|
|
130
|
+
placeholder={focused ? placeholder : ""}
|
|
131
|
+
disabled={!enabled}
|
|
132
|
+
readonly={readOnly}
|
|
133
|
+
class="w-full bg-transparent outline-none"
|
|
134
|
+
style={`
|
|
135
|
+
font:${resolveTextStyle(textStyle)};
|
|
136
|
+
font-size:${floating ? "1.05em" : "1em"};
|
|
137
|
+
color:${textColor};
|
|
138
|
+
padding-top:${paddingTop}px;
|
|
139
|
+
padding-bottom:${paddingBottom}px;
|
|
140
|
+
`}
|
|
141
|
+
/>
|
|
142
|
+
{:else}
|
|
143
|
+
<textarea
|
|
144
|
+
id={inputId}
|
|
145
|
+
bind:value
|
|
146
|
+
on:input={handleInput}
|
|
147
|
+
on:focus={() => (focused = true)}
|
|
148
|
+
on:blur={() => (focused = false)}
|
|
149
|
+
placeholder={focused ? placeholder : ""}
|
|
150
|
+
rows="3"
|
|
151
|
+
disabled={!enabled}
|
|
152
|
+
readonly={readOnly}
|
|
153
|
+
class="w-full bg-transparent outline-none resize-none"
|
|
154
|
+
style={`
|
|
155
|
+
font:${resolveTextStyle(textStyle)};
|
|
156
|
+
font-size:${floating ? "1.05em" : "1em"};
|
|
157
|
+
color:${textColor};
|
|
158
|
+
padding-top:${paddingTop}px;
|
|
159
|
+
padding-bottom:12px;
|
|
160
|
+
`}
|
|
161
|
+
></textarea>
|
|
162
|
+
{/if}
|
|
163
|
+
</div>
|
|
164
|
+
|
|
165
|
+
{#if hasTrailing}
|
|
166
|
+
<div class="flex items-center justify-center">
|
|
167
|
+
<slot name="trailingIcon" />
|
|
168
|
+
</div>
|
|
169
|
+
{/if}
|
|
170
|
+
</div>
|
|
171
|
+
|
|
172
|
+
<!-- Indicator -->
|
|
173
|
+
<div
|
|
174
|
+
class="absolute bottom-0 left-0 right-0 h-1 transition-colors"
|
|
175
|
+
style={`background:${indicatorColor};`}
|
|
176
|
+
></div>
|
|
177
|
+
</div>
|
|
178
|
+
|
|
179
|
+
<!-- Supporting text -->
|
|
180
|
+
{#if supportingText}
|
|
181
|
+
<div
|
|
182
|
+
class="text-xs px-16"
|
|
183
|
+
style={`color:${supportingColor}; margin-top:2px;`}
|
|
184
|
+
>
|
|
185
|
+
{supportingText}
|
|
186
|
+
</div>
|
|
187
|
+
{/if}
|
|
188
|
+
</div>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Modifier } from "../../core/modifier/Modifier";
|
|
2
|
+
import type { TextStyleToken } from "../../core/theme/TextStyle";
|
|
3
|
+
import type { Shape } from "../../core/shapes/Shape";
|
|
4
|
+
import type { TextFieldColors } from "./TextFieldColors";
|
|
5
|
+
import { type DensityToken } from "../../core/theme/Density";
|
|
6
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
7
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
8
|
+
$$bindings?: Bindings;
|
|
9
|
+
} & Exports;
|
|
10
|
+
(internal: unknown, props: Props & {
|
|
11
|
+
$$events?: Events;
|
|
12
|
+
$$slots?: Slots;
|
|
13
|
+
}): Exports & {
|
|
14
|
+
$set?: any;
|
|
15
|
+
$on?: any;
|
|
16
|
+
};
|
|
17
|
+
z_$$bindings?: Bindings;
|
|
18
|
+
}
|
|
19
|
+
declare const BaseTextField: $$__sveltets_2_IsomorphicComponent<{
|
|
20
|
+
value?: string;
|
|
21
|
+
onValueChange?: (_value: string) => void;
|
|
22
|
+
label?: string;
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
supportingText: string | undefined;
|
|
25
|
+
singleLine?: boolean;
|
|
26
|
+
textStyle?: TextStyleToken;
|
|
27
|
+
modifier?: Modifier;
|
|
28
|
+
shape?: Shape;
|
|
29
|
+
colors?: TextFieldColors;
|
|
30
|
+
enabled?: boolean;
|
|
31
|
+
readOnly?: boolean;
|
|
32
|
+
isError?: boolean;
|
|
33
|
+
density?: DensityToken;
|
|
34
|
+
}, {
|
|
35
|
+
[evt: string]: CustomEvent<any>;
|
|
36
|
+
}, {
|
|
37
|
+
leadingIcon: {};
|
|
38
|
+
trailingIcon: {};
|
|
39
|
+
}, {}, string>;
|
|
40
|
+
type BaseTextField = InstanceType<typeof BaseTextField>;
|
|
41
|
+
export default BaseTextField;
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
import {Density, type DensityToken} from "../../core/theme/Density";
|
|
10
|
+
|
|
11
|
+
export let value = "";
|
|
12
|
+
export let onValueChange = (v: string) => {};
|
|
13
|
+
export let label = "";
|
|
14
|
+
export let enabled: boolean = true;
|
|
15
|
+
export let isError: boolean = false;
|
|
16
|
+
export let readOnly: boolean = false;
|
|
17
|
+
export let density: DensityToken = Density.Default;
|
|
18
|
+
export let supportingText: string | undefined;
|
|
19
|
+
export let floatingLabelScale: number = 0.78;
|
|
20
|
+
export let placeholder = "";
|
|
21
|
+
export let singleLine = true;
|
|
22
|
+
export let textStyle: TextStyleToken = "bodyLarge";
|
|
23
|
+
export let modifier: Modifier = Modifier.empty();
|
|
24
|
+
export let shape: Shape = RoundedCornerShape(12);
|
|
25
|
+
|
|
26
|
+
// 🔒 OutlinedTextField SIEMPRE usa outlinedColors por defecto
|
|
27
|
+
export let colors: TextFieldColors = TextFieldDefaults.outlinedColors();
|
|
28
|
+
|
|
29
|
+
let focused = false;
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<div
|
|
33
|
+
class="relative"
|
|
34
|
+
style={`
|
|
35
|
+
border:1px solid ${focused
|
|
36
|
+
? colors.borderFocused
|
|
37
|
+
: colors.borderUnfocused};
|
|
38
|
+
border-radius:${shape.toCssBorderRadius()};
|
|
39
|
+
transition:border-color 200ms;
|
|
40
|
+
${modifier.toStyle()}
|
|
41
|
+
`}
|
|
42
|
+
>
|
|
43
|
+
<BaseTextField
|
|
44
|
+
value={value}
|
|
45
|
+
supportingText={supportingText}
|
|
46
|
+
density={density}
|
|
47
|
+
readOnly={readOnly}
|
|
48
|
+
enabled={enabled}
|
|
49
|
+
isError={isError}
|
|
50
|
+
onValueChange={onValueChange}
|
|
51
|
+
label={label}
|
|
52
|
+
placeholder={placeholder}
|
|
53
|
+
singleLine={singleLine}
|
|
54
|
+
textStyle={textStyle}
|
|
55
|
+
modifier={Modifier.empty()}
|
|
56
|
+
shape={shape}
|
|
57
|
+
colors={colors}
|
|
58
|
+
on:focus={() => focused = true}
|
|
59
|
+
on:blur={() => focused = false}
|
|
60
|
+
>
|
|
61
|
+
<slot name="leadingIcon" slot="leadingIcon" />
|
|
62
|
+
<slot name="trailingIcon" slot="trailingIcon" />
|
|
63
|
+
</BaseTextField>
|
|
64
|
+
</div>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { TextFieldColors } from "./TextFieldColors";
|
|
2
|
+
import { Modifier } from "../../core/modifier/Modifier";
|
|
3
|
+
import type { Shape } from "../../core/shapes/Shape";
|
|
4
|
+
import type { TextStyleToken } from "../../core/theme/TextStyle";
|
|
5
|
+
import { type DensityToken } from "../../core/theme/Density";
|
|
6
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
7
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
8
|
+
$$bindings?: Bindings;
|
|
9
|
+
} & Exports;
|
|
10
|
+
(internal: unknown, props: Props & {
|
|
11
|
+
$$events?: Events;
|
|
12
|
+
$$slots?: Slots;
|
|
13
|
+
}): Exports & {
|
|
14
|
+
$set?: any;
|
|
15
|
+
$on?: any;
|
|
16
|
+
};
|
|
17
|
+
z_$$bindings?: Bindings;
|
|
18
|
+
}
|
|
19
|
+
declare const OutlinedTextField: $$__sveltets_2_IsomorphicComponent<{
|
|
20
|
+
value?: string;
|
|
21
|
+
onValueChange?: (v: string) => void;
|
|
22
|
+
label?: string;
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
isError?: boolean;
|
|
25
|
+
readOnly?: boolean;
|
|
26
|
+
density?: DensityToken;
|
|
27
|
+
supportingText: string | undefined;
|
|
28
|
+
floatingLabelScale?: number;
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
singleLine?: boolean;
|
|
31
|
+
textStyle?: TextStyleToken;
|
|
32
|
+
modifier?: Modifier;
|
|
33
|
+
shape?: Shape;
|
|
34
|
+
colors?: TextFieldColors;
|
|
35
|
+
}, {
|
|
36
|
+
[evt: string]: CustomEvent<any>;
|
|
37
|
+
}, {
|
|
38
|
+
leadingIcon: {
|
|
39
|
+
slot: string;
|
|
40
|
+
};
|
|
41
|
+
trailingIcon: {
|
|
42
|
+
slot: string;
|
|
43
|
+
};
|
|
44
|
+
}, {}, string>;
|
|
45
|
+
type OutlinedTextField = InstanceType<typeof OutlinedTextField>;
|
|
46
|
+
export default OutlinedTextField;
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
import {Density, type DensityToken} from "../../core/theme/Density";
|
|
10
|
+
|
|
11
|
+
export let value = "";
|
|
12
|
+
export let onValueChange = (v: string) => {};
|
|
13
|
+
export let label = "";
|
|
14
|
+
export let enabled: boolean = true;
|
|
15
|
+
export let isError: boolean = false;
|
|
16
|
+
export let floatingLabelScale: number = 0.78;
|
|
17
|
+
export let placeholder = "";
|
|
18
|
+
export let singleLine = true;
|
|
19
|
+
export let textStyle: TextStyleToken = "bodyLarge";
|
|
20
|
+
export let modifier: Modifier = Modifier.empty();
|
|
21
|
+
export let shape: Shape = RoundedCornerShape(12);
|
|
22
|
+
export let supportingText: string | undefined = undefined;
|
|
23
|
+
export let readOnly: boolean = false;
|
|
24
|
+
export let density: DensityToken = Density.Default;
|
|
25
|
+
|
|
26
|
+
// 🔒 FilledTextField SIEMPRE usa filledColors por defecto
|
|
27
|
+
export let colors: TextFieldColors = TextFieldDefaults.filledColors();
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<BaseTextField
|
|
31
|
+
value={value}
|
|
32
|
+
onValueChange={onValueChange}
|
|
33
|
+
supportingText={supportingText}
|
|
34
|
+
enabled={enabled}
|
|
35
|
+
isError={isError}
|
|
36
|
+
floatingLabelScale={floatingLabelScale}
|
|
37
|
+
label={label}
|
|
38
|
+
density={density}
|
|
39
|
+
readOnly={readOnly}
|
|
40
|
+
placeholder={placeholder}
|
|
41
|
+
singleLine={singleLine}
|
|
42
|
+
textStyle={textStyle}
|
|
43
|
+
modifier={modifier}
|
|
44
|
+
shape={shape}
|
|
45
|
+
colors={colors}
|
|
46
|
+
>
|
|
47
|
+
<slot name="leadingIcon" slot="leadingIcon" />
|
|
48
|
+
<slot name="trailingIcon" slot="trailingIcon" />
|
|
49
|
+
</BaseTextField>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { TextFieldColors } from "./TextFieldColors";
|
|
2
|
+
import { Modifier } from "../../core/modifier/Modifier";
|
|
3
|
+
import type { Shape } from "../../core/shapes/Shape";
|
|
4
|
+
import type { TextStyleToken } from "../../core/theme/TextStyle";
|
|
5
|
+
import { type DensityToken } from "../../core/theme/Density";
|
|
6
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
7
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
8
|
+
$$bindings?: Bindings;
|
|
9
|
+
} & Exports;
|
|
10
|
+
(internal: unknown, props: Props & {
|
|
11
|
+
$$events?: Events;
|
|
12
|
+
$$slots?: Slots;
|
|
13
|
+
}): Exports & {
|
|
14
|
+
$set?: any;
|
|
15
|
+
$on?: any;
|
|
16
|
+
};
|
|
17
|
+
z_$$bindings?: Bindings;
|
|
18
|
+
}
|
|
19
|
+
declare const TextField: $$__sveltets_2_IsomorphicComponent<{
|
|
20
|
+
value?: string;
|
|
21
|
+
onValueChange?: (v: string) => void;
|
|
22
|
+
label?: string;
|
|
23
|
+
enabled?: boolean;
|
|
24
|
+
isError?: boolean;
|
|
25
|
+
floatingLabelScale?: number;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
singleLine?: boolean;
|
|
28
|
+
textStyle?: TextStyleToken;
|
|
29
|
+
modifier?: Modifier;
|
|
30
|
+
shape?: Shape;
|
|
31
|
+
supportingText?: string | undefined;
|
|
32
|
+
readOnly?: boolean;
|
|
33
|
+
density?: DensityToken;
|
|
34
|
+
colors?: TextFieldColors;
|
|
35
|
+
}, {
|
|
36
|
+
[evt: string]: CustomEvent<any>;
|
|
37
|
+
}, {
|
|
38
|
+
leadingIcon: {
|
|
39
|
+
slot: string;
|
|
40
|
+
};
|
|
41
|
+
trailingIcon: {
|
|
42
|
+
slot: string;
|
|
43
|
+
};
|
|
44
|
+
}, {}, string>;
|
|
45
|
+
type TextField = InstanceType<typeof TextField>;
|
|
46
|
+
export default TextField;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface TextFieldColors {
|
|
2
|
+
container: string;
|
|
3
|
+
label: string;
|
|
4
|
+
placeholder: string;
|
|
5
|
+
text: string;
|
|
6
|
+
cursor: string;
|
|
7
|
+
indicatorFocused: string;
|
|
8
|
+
indicatorUnfocused: string;
|
|
9
|
+
borderFocused?: string;
|
|
10
|
+
borderUnfocused?: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TextFieldColors } from "./TextFieldColors";
|
|
2
|
+
export declare const TextFieldDefaults: {
|
|
3
|
+
/**
|
|
4
|
+
* FilledTextField (Material default)
|
|
5
|
+
*/
|
|
6
|
+
filledColors(): TextFieldColors;
|
|
7
|
+
/**
|
|
8
|
+
* OutlinedTextField
|
|
9
|
+
*/
|
|
10
|
+
outlinedColors(): TextFieldColors;
|
|
11
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { resolveColor } from "../../core/theme/resolve";
|
|
2
|
+
export var TextFieldDefaults = {
|
|
3
|
+
/**
|
|
4
|
+
* FilledTextField (Material default)
|
|
5
|
+
*/
|
|
6
|
+
filledColors: function () {
|
|
7
|
+
return {
|
|
8
|
+
// Container
|
|
9
|
+
container: resolveColor("surfaceVariant"),
|
|
10
|
+
// Content
|
|
11
|
+
label: resolveColor("onSurfaceVariant"),
|
|
12
|
+
placeholder: resolveColor("onSurfaceVariant"),
|
|
13
|
+
text: resolveColor("onSurface"),
|
|
14
|
+
cursor: resolveColor("primary"),
|
|
15
|
+
// Indicator (bottom line)
|
|
16
|
+
indicatorFocused: resolveColor("primary"),
|
|
17
|
+
indicatorUnfocused: resolveColor("onSurfaceVariant"),
|
|
18
|
+
error: resolveColor("error"),
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
/**
|
|
22
|
+
* OutlinedTextField
|
|
23
|
+
*/
|
|
24
|
+
outlinedColors: function () {
|
|
25
|
+
return {
|
|
26
|
+
// Container
|
|
27
|
+
container: "transparent",
|
|
28
|
+
// Content
|
|
29
|
+
label: resolveColor("onSurfaceVariant"),
|
|
30
|
+
placeholder: resolveColor("onSurfaceVariant"),
|
|
31
|
+
text: resolveColor("onSurface"),
|
|
32
|
+
cursor: resolveColor("primary"),
|
|
33
|
+
// Indicator (used only if needed)
|
|
34
|
+
indicatorFocused: resolveColor("primary"),
|
|
35
|
+
indicatorUnfocused: resolveColor("outline"),
|
|
36
|
+
// Border (outlined specific)
|
|
37
|
+
borderFocused: resolveColor("primary"),
|
|
38
|
+
borderUnfocused: resolveColor("outline"),
|
|
39
|
+
error: resolveColor("error"),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function elevationToShadow(value: number | string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* painterResource - como en Jetpack Compose
|
|
3
|
+
* Carga un recurso local desde src/lib/assets/
|
|
4
|
+
* Soporta SVG (?raw para string) e imágenes (?url para URL)
|
|
5
|
+
*/
|
|
6
|
+
export declare const Res: {
|
|
7
|
+
readonly raw: (fileName: string) => string;
|
|
8
|
+
readonly image: (fileName: string) => string;
|
|
9
|
+
readonly values: (fileName: string) => string;
|
|
10
|
+
readonly fonts: (fileName: string) => string;
|
|
11
|
+
};
|
|
12
|
+
export declare function painterResource(resourceName: string): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* painterResource - como en Jetpack Compose
|
|
3
|
+
* Carga un recurso local desde src/lib/assets/
|
|
4
|
+
* Soporta SVG (?raw para string) e imágenes (?url para URL)
|
|
5
|
+
*/
|
|
6
|
+
export var Res = {
|
|
7
|
+
raw: function (fileName) {
|
|
8
|
+
return "raw/" + fileName;
|
|
9
|
+
},
|
|
10
|
+
image: function (fileName) {
|
|
11
|
+
return "img/" + fileName;
|
|
12
|
+
},
|
|
13
|
+
values: function (fileName) {
|
|
14
|
+
return "values/" + fileName;
|
|
15
|
+
},
|
|
16
|
+
fonts: function (fileName) {
|
|
17
|
+
return "fonts/" + fileName;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
export function painterResource(resourceName) {
|
|
21
|
+
return "/src/assets/" + resourceName;
|
|
22
|
+
}
|