lutra 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.
- package/README.md +29 -0
- package/dist/Data/Stat.svelte +89 -0
- package/dist/Data/Stat.svelte.d.ts +33 -0
- package/dist/DataTable/DataTable.svelte +36 -0
- package/dist/DataTable/DataTable.svelte.d.ts +19 -0
- package/dist/DataTable/DataTableColumn.svelte +20 -0
- package/dist/DataTable/DataTableColumn.svelte.d.ts +18 -0
- package/dist/DataTable/DataTableRow.svelte +28 -0
- package/dist/DataTable/DataTableRow.svelte.d.ts +18 -0
- package/dist/Display/Avatar.svelte +61 -0
- package/dist/Display/Avatar.svelte.d.ts +18 -0
- package/dist/Display/Badge.svelte +93 -0
- package/dist/Display/Badge.svelte.d.ts +30 -0
- package/dist/Display/Callout.svelte +105 -0
- package/dist/Display/Callout.svelte.d.ts +34 -0
- package/dist/Display/Code.svelte +195 -0
- package/dist/Display/Code.svelte.d.ts +29 -0
- package/dist/Display/ContextTip.svelte +23 -0
- package/dist/Display/ContextTip.svelte.d.ts +17 -0
- package/dist/Display/Details.svelte +49 -0
- package/dist/Display/Details.svelte.d.ts +26 -0
- package/dist/Display/Hero.svelte +50 -0
- package/dist/Display/Hero.svelte.d.ts +25 -0
- package/dist/Display/Icon.svelte +35 -0
- package/dist/Display/Icon.svelte.d.ts +18 -0
- package/dist/Display/IconButton.svelte +85 -0
- package/dist/Display/IconButton.svelte.d.ts +28 -0
- package/dist/Display/Indicator.svelte +352 -0
- package/dist/Display/Indicator.svelte.d.ts +22 -0
- package/dist/Display/Popup.svelte +111 -0
- package/dist/Display/Popup.svelte.d.ts +26 -0
- package/dist/Display/Tag.svelte +90 -0
- package/dist/Display/Tag.svelte.d.ts +31 -0
- package/dist/Display/Tooltip.svelte +96 -0
- package/dist/Display/Tooltip.svelte.d.ts +22 -0
- package/dist/Form/Button.svelte +34 -0
- package/dist/Form/Button.svelte.d.ts +24 -0
- package/dist/Form/FieldActions.svelte +25 -0
- package/dist/Form/FieldActions.svelte.d.ts +17 -0
- package/dist/Form/FieldContainer.svelte +31 -0
- package/dist/Form/FieldContainer.svelte.d.ts +18 -0
- package/dist/Form/FieldContent.svelte +78 -0
- package/dist/Form/FieldContent.svelte.d.ts +32 -0
- package/dist/Form/FieldSection.svelte +97 -0
- package/dist/Form/FieldSection.svelte.d.ts +23 -0
- package/dist/Form/Fieldset.svelte +63 -0
- package/dist/Form/Fieldset.svelte.d.ts +32 -0
- package/dist/Form/Form.svelte +19 -0
- package/dist/Form/Form.svelte.d.ts +18 -0
- package/dist/Form/Input.svelte +266 -0
- package/dist/Form/Input.svelte.d.ts +113 -0
- package/dist/Form/InputLength.svelte +32 -0
- package/dist/Form/InputLength.svelte.d.ts +19 -0
- package/dist/Form/Label.svelte +26 -0
- package/dist/Form/Label.svelte.d.ts +25 -0
- package/dist/Form/Select.svelte +24 -0
- package/dist/Form/Select.svelte.d.ts +28 -0
- package/dist/Form/form.d.ts +34 -0
- package/dist/Form/form.js +31 -0
- package/dist/Form/types.d.ts +4 -0
- package/dist/Form/types.js +1 -0
- package/dist/Grid/Column.svelte +11 -0
- package/dist/Grid/Column.svelte.d.ts +17 -0
- package/dist/Grid/Grid.svelte +19 -0
- package/dist/Grid/Grid.svelte.d.ts +18 -0
- package/dist/Grid/Row.svelte +44 -0
- package/dist/Grid/Row.svelte.d.ts +19 -0
- package/dist/Icons/Alert.svelte +3 -0
- package/dist/Icons/Alert.svelte.d.ts +23 -0
- package/dist/Icons/Copy.svelte +3 -0
- package/dist/Icons/Copy.svelte.d.ts +23 -0
- package/dist/Icons/Done.svelte +3 -0
- package/dist/Icons/Done.svelte.d.ts +23 -0
- package/dist/Icons/Error.svelte +3 -0
- package/dist/Icons/Error.svelte.d.ts +23 -0
- package/dist/Icons/Help.svelte +3 -0
- package/dist/Icons/Help.svelte.d.ts +23 -0
- package/dist/Icons/Hide.svelte +3 -0
- package/dist/Icons/Hide.svelte.d.ts +23 -0
- package/dist/Icons/Info.svelte +3 -0
- package/dist/Icons/Info.svelte.d.ts +23 -0
- package/dist/Icons/Link.svelte +3 -0
- package/dist/Icons/Link.svelte.d.ts +23 -0
- package/dist/Icons/Show.svelte +3 -0
- package/dist/Icons/Show.svelte.d.ts +23 -0
- package/dist/Icons/Success.svelte +3 -0
- package/dist/Icons/Success.svelte.d.ts +23 -0
- package/dist/Icons/Warning.svelte +3 -0
- package/dist/Icons/Warning.svelte.d.ts +23 -0
- package/dist/Layout/Layout.svelte +43 -0
- package/dist/Layout/Layout.svelte.d.ts +21 -0
- package/dist/Layout/LayoutFooter.svelte +21 -0
- package/dist/Layout/LayoutFooter.svelte.d.ts +17 -0
- package/dist/Layout/LayoutGrid.svelte +51 -0
- package/dist/Layout/LayoutGrid.svelte.d.ts +30 -0
- package/dist/Layout/LayoutHeader.svelte +94 -0
- package/dist/Layout/LayoutHeader.svelte.d.ts +38 -0
- package/dist/Layout/LayoutTypes.svelte.d.ts +15 -0
- package/dist/Layout/LayoutTypes.svelte.js +9 -0
- package/dist/Layout/PageContent.svelte +89 -0
- package/dist/Layout/PageContent.svelte.d.ts +23 -0
- package/dist/Layout/Theme.svelte +215 -0
- package/dist/Layout/Theme.svelte.d.ts +18 -0
- package/dist/Layout/UIContent.svelte +15 -0
- package/dist/Layout/UIContent.svelte.d.ts +17 -0
- package/dist/Navigation/Breadcrumb.svelte +82 -0
- package/dist/Navigation/Breadcrumb.svelte.d.ts +29 -0
- package/dist/Navigation/Menu.svelte +180 -0
- package/dist/Navigation/Menu.svelte.d.ts +18 -0
- package/dist/Navigation/MenuTypes.svelte.d.ts +37 -0
- package/dist/Navigation/MenuTypes.svelte.js +1 -0
- package/dist/Navigation/TabbedContent.svelte +43 -0
- package/dist/Navigation/TabbedContent.svelte.d.ts +22 -0
- package/dist/Navigation/Tabs.svelte +118 -0
- package/dist/Navigation/Tabs.svelte.d.ts +24 -0
- package/dist/Pages/LoginPage.svelte +32 -0
- package/dist/Pages/LoginPage.svelte.d.ts +14 -0
- package/dist/Typography/Clamp.svelte +25 -0
- package/dist/Typography/Clamp.svelte.d.ts +23 -0
- package/dist/Typography/H.svelte +51 -0
- package/dist/Typography/H.svelte.d.ts +25 -0
- package/dist/Typography/H1.svelte +14 -0
- package/dist/Typography/H1.svelte.d.ts +23 -0
- package/dist/Typography/H2.svelte +13 -0
- package/dist/Typography/H2.svelte.d.ts +23 -0
- package/dist/Typography/H3.svelte +13 -0
- package/dist/Typography/H3.svelte.d.ts +23 -0
- package/dist/Typography/H4.svelte +13 -0
- package/dist/Typography/H4.svelte.d.ts +23 -0
- package/dist/Typography/H5.svelte +13 -0
- package/dist/Typography/H5.svelte.d.ts +23 -0
- package/dist/Typography/H6.svelte +13 -0
- package/dist/Typography/H6.svelte.d.ts +23 -0
- package/dist/Typography/P.svelte +32 -0
- package/dist/Typography/P.svelte.d.ts +23 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/style.css +787 -0
- package/dist/utils/attr.d.ts +5 -0
- package/dist/utils/attr.js +21 -0
- package/dist/utils/color.d.ts +51 -0
- package/dist/utils/color.js +97 -0
- package/dist/utils/defaults.d.ts +4 -0
- package/dist/utils/defaults.js +1 -0
- package/dist/utils/hooks.server.d.ts +2 -0
- package/dist/utils/hooks.server.js +16 -0
- package/dist/utils/id.d.ts +1 -0
- package/dist/utils/id.js +3 -0
- package/dist/utils/isSnippet.d.ts +5 -0
- package/dist/utils/isSnippet.js +6 -0
- package/dist/utils/transitions.d.ts +29 -0
- package/dist/utils/transitions.js +66 -0
- package/package.json +58 -0
@@ -0,0 +1,266 @@
|
|
1
|
+
<script>import Label from "./Label.svelte";
|
2
|
+
import { createId } from "../utils/id.js";
|
3
|
+
import Copy from "../Icons/Copy.svelte";
|
4
|
+
import Done from "../Icons/Done.svelte";
|
5
|
+
import Show from "../Icons/Show.svelte";
|
6
|
+
import Hide from "../Icons/Hide.svelte";
|
7
|
+
import Tooltip from "../Display/Tooltip.svelte";
|
8
|
+
import IconButton from "../Display/IconButton.svelte";
|
9
|
+
import Icon from "../Display/Icon.svelte";
|
10
|
+
let {
|
11
|
+
alt,
|
12
|
+
autocapitalize,
|
13
|
+
autocomplete,
|
14
|
+
autocorrect,
|
15
|
+
capture,
|
16
|
+
checked,
|
17
|
+
contained,
|
18
|
+
copyable,
|
19
|
+
defaultValue,
|
20
|
+
dirname,
|
21
|
+
disabled,
|
22
|
+
enterkeyhint,
|
23
|
+
height,
|
24
|
+
help,
|
25
|
+
id = $bindable(createId()),
|
26
|
+
indeterminate,
|
27
|
+
inputmode,
|
28
|
+
label,
|
29
|
+
labelTip,
|
30
|
+
list,
|
31
|
+
maxlength,
|
32
|
+
minlength,
|
33
|
+
max,
|
34
|
+
min,
|
35
|
+
multiple,
|
36
|
+
name,
|
37
|
+
pattern,
|
38
|
+
placeholder,
|
39
|
+
suffix,
|
40
|
+
prefix,
|
41
|
+
readonly,
|
42
|
+
required,
|
43
|
+
results,
|
44
|
+
shape = "rounded",
|
45
|
+
src,
|
46
|
+
step,
|
47
|
+
tabindex,
|
48
|
+
title,
|
49
|
+
type = "text",
|
50
|
+
value = $bindable(""),
|
51
|
+
viewable,
|
52
|
+
webkitdirectory
|
53
|
+
} = $props();
|
54
|
+
let el = $state();
|
55
|
+
let copyTitle = $state("Copy");
|
56
|
+
let viewTitle = $state("Show");
|
57
|
+
let copyTooltipOpen = $state(false);
|
58
|
+
let copyBtnIcon = $state(Copy);
|
59
|
+
let viewBtnIcon = $state(Show);
|
60
|
+
function view(e) {
|
61
|
+
e.preventDefault();
|
62
|
+
if (!el)
|
63
|
+
return;
|
64
|
+
if (el.type === "password") {
|
65
|
+
el.type = "text";
|
66
|
+
viewBtnIcon = Hide;
|
67
|
+
viewTitle = "Hide";
|
68
|
+
} else {
|
69
|
+
el.type = "password";
|
70
|
+
viewBtnIcon = Show;
|
71
|
+
viewTitle = "Show";
|
72
|
+
}
|
73
|
+
el.focus();
|
74
|
+
}
|
75
|
+
function copy(e) {
|
76
|
+
e.preventDefault();
|
77
|
+
if (!el)
|
78
|
+
return;
|
79
|
+
if (navigator.clipboard) {
|
80
|
+
navigator.clipboard.writeText(value);
|
81
|
+
} else {
|
82
|
+
el.focus();
|
83
|
+
el.select();
|
84
|
+
document.execCommand("copy");
|
85
|
+
}
|
86
|
+
copyBtnIcon = Done;
|
87
|
+
copyTitle = "Copied!";
|
88
|
+
copyTooltipOpen = true;
|
89
|
+
setTimeout(() => {
|
90
|
+
copyBtnIcon = Copy;
|
91
|
+
copyTitle = "Copy";
|
92
|
+
copyTooltipOpen = false;
|
93
|
+
}, 1500);
|
94
|
+
}
|
95
|
+
</script>
|
96
|
+
|
97
|
+
{#snippet input()}
|
98
|
+
<input
|
99
|
+
bind:this={el}
|
100
|
+
{alt}
|
101
|
+
autocapitalize={typeof autocapitalize === 'string' ? autocapitalize : (typeof autocapitalize === 'boolean' ? (autocapitalize ? 'on' : 'off') : undefined)}
|
102
|
+
{autocomplete}
|
103
|
+
autocorrect={typeof autocorrect === 'boolean' ? (autocorrect ? 'on' : 'off') : undefined}
|
104
|
+
{capture}
|
105
|
+
{checked}
|
106
|
+
{dirname}
|
107
|
+
{disabled}
|
108
|
+
{enterkeyhint}
|
109
|
+
{height}
|
110
|
+
{id}
|
111
|
+
{indeterminate}
|
112
|
+
{inputmode}
|
113
|
+
{list}
|
114
|
+
{maxlength}
|
115
|
+
{minlength}
|
116
|
+
{max}
|
117
|
+
{min}
|
118
|
+
{multiple}
|
119
|
+
{name}
|
120
|
+
{pattern}
|
121
|
+
{placeholder}
|
122
|
+
{readonly}
|
123
|
+
{required}
|
124
|
+
{results}
|
125
|
+
{src}
|
126
|
+
{step}
|
127
|
+
{tabindex}
|
128
|
+
{title}
|
129
|
+
{type}
|
130
|
+
{value}
|
131
|
+
{webkitdirectory}
|
132
|
+
/>
|
133
|
+
{/snippet}
|
134
|
+
|
135
|
+
<div class="FieldContainer {type}" class:checkOrRadio={type === "checkbox" || type === "radio"}>
|
136
|
+
|
137
|
+
<Label {id} {label} tip={labelTip} />
|
138
|
+
|
139
|
+
{#if type === "checkbox" || type === "radio"}
|
140
|
+
{@render input()}
|
141
|
+
{:else}
|
142
|
+
|
143
|
+
<div
|
144
|
+
class="Field {type}"
|
145
|
+
class:hasPrefix={!!prefix}
|
146
|
+
class:hasSuffix={!!suffix}
|
147
|
+
>
|
148
|
+
{#if prefix}
|
149
|
+
<div class="Fix Prefix">
|
150
|
+
{#if typeof prefix === 'string'}
|
151
|
+
{prefix}
|
152
|
+
{:else}
|
153
|
+
{@render prefix()}
|
154
|
+
{/if}
|
155
|
+
</div>
|
156
|
+
{/if}
|
157
|
+
|
158
|
+
{@render input()}
|
159
|
+
|
160
|
+
{#if copyable}
|
161
|
+
<Tooltip tip={copyTitle} open={copyTooltipOpen}>
|
162
|
+
<IconButton icon={copyBtnIcon} onclick={copy} disabled={copyTooltipOpen} />
|
163
|
+
</Tooltip>
|
164
|
+
{/if}
|
165
|
+
|
166
|
+
{#if type === "password" && viewable}
|
167
|
+
<Tooltip tip={viewTitle}>
|
168
|
+
<IconButton icon={viewBtnIcon} onclick={view} />
|
169
|
+
</Tooltip>
|
170
|
+
{/if}
|
171
|
+
|
172
|
+
{#if suffix}
|
173
|
+
<div class="Fix Suffix">
|
174
|
+
{#if typeof suffix === 'string'}
|
175
|
+
{suffix}
|
176
|
+
{:else}
|
177
|
+
{@render suffix()}
|
178
|
+
{/if}
|
179
|
+
</div>
|
180
|
+
{/if}
|
181
|
+
</div>
|
182
|
+
{/if}
|
183
|
+
</div>
|
184
|
+
|
185
|
+
<style>
|
186
|
+
.FieldContainer {
|
187
|
+
display: flex;
|
188
|
+
gap: 0.75em;
|
189
|
+
flex-direction: column;
|
190
|
+
font-size: var(--font-size, 1em);
|
191
|
+
}
|
192
|
+
.Field {
|
193
|
+
background-color: var(--field-bg);
|
194
|
+
border: var(--border-size) var(--border-style) var(--border-color);
|
195
|
+
border-radius: var(--field-radius);
|
196
|
+
display: flex;
|
197
|
+
padding-inline: 0.15em;
|
198
|
+
}
|
199
|
+
.Field > *:not(input) {
|
200
|
+
flex-grow: 0;
|
201
|
+
flex-shrink: 0;
|
202
|
+
}
|
203
|
+
.Fix {
|
204
|
+
display: flex;
|
205
|
+
align-items: center;
|
206
|
+
padding-inline: 0.75em;
|
207
|
+
font-size: 1em;
|
208
|
+
line-height: 1.5;
|
209
|
+
color: var(--text-subtle);
|
210
|
+
}
|
211
|
+
.Suffix {
|
212
|
+
padding-inline-start: 0;
|
213
|
+
}
|
214
|
+
.Prefix {
|
215
|
+
padding-inline-end: 0;
|
216
|
+
}
|
217
|
+
.Field:has(input:focus-visible) {
|
218
|
+
outline: var(--focus-outline);
|
219
|
+
}
|
220
|
+
/**
|
221
|
+
* Input element
|
222
|
+
*/
|
223
|
+
input:not([type="checkbox"]):not([type="radio"]) {
|
224
|
+
border: none;
|
225
|
+
flex-grow: 1;
|
226
|
+
flex-shrink: 0;
|
227
|
+
}
|
228
|
+
input:not([type="checkbox"]):not([type="radio"]):focus-visible,
|
229
|
+
input:not([type="checkbox"]):not([type="radio"]):active {
|
230
|
+
outline: none;
|
231
|
+
}
|
232
|
+
.Field.hasPrefix input {
|
233
|
+
padding-inline-start: 0.35em;
|
234
|
+
}
|
235
|
+
/**
|
236
|
+
* Buttons
|
237
|
+
*/
|
238
|
+
.Field :global(button:focus-visible) {
|
239
|
+
outline: var(--focus-outline);
|
240
|
+
outline-offset: 3px;
|
241
|
+
border-radius: calc(var(--field-radius) - 2px);
|
242
|
+
}
|
243
|
+
/**
|
244
|
+
* Checkbox and radio
|
245
|
+
*/
|
246
|
+
input[type="checkbox"] {
|
247
|
+
border-radius: 6px;
|
248
|
+
}
|
249
|
+
|
250
|
+
.FieldContainer.checkOrRadio {
|
251
|
+
flex-direction: row-reverse;
|
252
|
+
align-items: center;
|
253
|
+
justify-content: start;
|
254
|
+
gap: 1em;
|
255
|
+
width: fit-content;
|
256
|
+
}
|
257
|
+
.FieldContainer.checkOrRadio .Field {
|
258
|
+
display: flex;
|
259
|
+
align-items: center;
|
260
|
+
border: none;
|
261
|
+
}
|
262
|
+
.FieldContainer.checkOrRadio input:focus-visible,
|
263
|
+
.FieldContainer.checkOrRadio input:hover {
|
264
|
+
outline: var(--focus-outline);
|
265
|
+
}
|
266
|
+
</style>
|
@@ -0,0 +1,113 @@
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
2
|
+
import type { Autocomplete } from "./types.js";
|
3
|
+
declare const __propDef: {
|
4
|
+
props: {
|
5
|
+
/** alt attribute for the image type. Required for accessibility */
|
6
|
+
alt?: string | undefined;
|
7
|
+
/** Whether the input should be autocapitalized. */
|
8
|
+
autocapitalize?: boolean | "none" | "off" | "on" | "sentences" | "words" | "characters" | undefined;
|
9
|
+
/** Specifies whether autocomplete is enabled for the input. */
|
10
|
+
autocomplete?: Autocomplete | undefined;
|
11
|
+
/** Whether the input should be autocorrected. (Safari only) */
|
12
|
+
autocorrect?: boolean | undefined;
|
13
|
+
/** A hint to the browser for which capture method to use. */
|
14
|
+
capture?: "user" | "environment" | undefined;
|
15
|
+
/** Whether the input should be checked. */
|
16
|
+
checked?: boolean | undefined;
|
17
|
+
/** Whether the input should be contained. */
|
18
|
+
contained?: boolean | undefined;
|
19
|
+
/** Whether the input should be copyable. */
|
20
|
+
copyable?: boolean | undefined;
|
21
|
+
/** The default value of the input element. */
|
22
|
+
defaultValue?: string | undefined;
|
23
|
+
/** Form field name for the directionality of the element's text content during form submission */
|
24
|
+
dirname?: string | undefined;
|
25
|
+
/** Whether the input should be disabled. */
|
26
|
+
disabled?: boolean | undefined;
|
27
|
+
/** A hint to the browser for which enter key to display for the input. */
|
28
|
+
enterkeyhint?: "search" | "enter" | "done" | "go" | "next" | "previous" | "send" | undefined;
|
29
|
+
/** The height of the input element. Valid for image inputs. */
|
30
|
+
height?: number | undefined;
|
31
|
+
/** Help text to display below the input. */
|
32
|
+
help?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
33
|
+
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
34
|
+
}) | undefined;
|
35
|
+
/** A random id is generated if not provided. */
|
36
|
+
id?: string | undefined;
|
37
|
+
/** Whether the input should be indeterminate. */
|
38
|
+
indeterminate?: boolean | undefined;
|
39
|
+
/** A hint to the browser for which keyboard to display. This is only used for type="text" inputs. Strongly consider using type="email" or type="url" etc. instead */
|
40
|
+
inputmode?: "none" | "search" | "text" | "email" | "tel" | "url" | "numeric" | "decimal" | undefined;
|
41
|
+
/** The label for the input */
|
42
|
+
label?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
43
|
+
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
44
|
+
}) | undefined;
|
45
|
+
/** Context tooltip for a label. Renders with a questionmark using ContextTip. */
|
46
|
+
labelTip?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
47
|
+
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
48
|
+
}) | undefined;
|
49
|
+
/** The id of a datalist element that contains pre-defined options for the input element. */
|
50
|
+
list?: string | undefined;
|
51
|
+
/** The maximum number of characters (as UTF-16 code units) the user can enter into the input. Valid for text, search, url, tel, email, and password. */
|
52
|
+
maxlength?: number | undefined;
|
53
|
+
/** The minimum number of characters (as UTF-16 code units) the user can enter into the input. Valid for text, search, url, tel, email, and password. */
|
54
|
+
minlength?: number | undefined;
|
55
|
+
/** Allow multiple f
|
56
|
+
/** The maximum value of the input element. Valid for date, month, week, time, datetime-local, number, and range. */
|
57
|
+
max?: number | undefined;
|
58
|
+
/** The minimum value of the input element. Valid for date, month, week, time, datetime-local, number, and range. */
|
59
|
+
min?: number | undefined;
|
60
|
+
/** Whether the input should allow multiple values. Valid for email and file inputs. */
|
61
|
+
multiple?: boolean | undefined;
|
62
|
+
/** The name of the input element. */
|
63
|
+
name?: string | undefined;
|
64
|
+
/** A regular expression that the input's value is checked against. Valid for text, search, url, tel, email, and password. */
|
65
|
+
pattern?: string | undefined;
|
66
|
+
/** Placeholder text to display when the input is empty. */
|
67
|
+
placeholder?: string | undefined;
|
68
|
+
/** Suffix content, to display after the input. */
|
69
|
+
suffix?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
70
|
+
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
71
|
+
}) | undefined;
|
72
|
+
/** Prefix content, to display before the input. */
|
73
|
+
prefix?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
74
|
+
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
75
|
+
}) | undefined;
|
76
|
+
/** Whether the input should be read-only. */
|
77
|
+
readonly?: boolean | undefined;
|
78
|
+
/** Whether the input should be required. */
|
79
|
+
required?: boolean | undefined;
|
80
|
+
/** The maximum number of items that should be displayed in the drop-down list of previous search queries. Safari only. */
|
81
|
+
results?: number | undefined;
|
82
|
+
/** The shape of the input element. */
|
83
|
+
shape?: "default" | "circle" | "rounded" | "pill" | undefined;
|
84
|
+
/** Source URL for the image type. */
|
85
|
+
src?: string | undefined;
|
86
|
+
/** Spellcheck the input. */
|
87
|
+
spellcheck?: boolean | undefined;
|
88
|
+
/** A number that specifies the granularity that the value must adhere to. Valid for date, month, week, time, datetime-local, number, and range. */
|
89
|
+
step?: number | undefined;
|
90
|
+
/** An integer attribute indicating if the element can take input focus (is focusable), if it should participate to sequential keyboard navigation. */
|
91
|
+
tabindex?: number | undefined;
|
92
|
+
/** A string that defines the title of the input element. */
|
93
|
+
title?: string | undefined;
|
94
|
+
/** The type of input to display. */
|
95
|
+
type?: "number" | "color" | "button" | "search" | "time" | "image" | "text" | "submit" | "email" | "tel" | "url" | "checkbox" | "radio" | "hidden" | "password" | "file" | "range" | "date" | "datetime-local" | "month" | "week" | undefined;
|
96
|
+
/** The value of the input element. */
|
97
|
+
value?: string | undefined;
|
98
|
+
/** Whether the input should be viewable. Valid for password inputs. */
|
99
|
+
viewable?: boolean | undefined;
|
100
|
+
/** Whether the input should only accept directory uploads. */
|
101
|
+
webkitdirectory?: boolean | undefined;
|
102
|
+
};
|
103
|
+
events: {
|
104
|
+
[evt: string]: CustomEvent<any>;
|
105
|
+
};
|
106
|
+
slots: {};
|
107
|
+
};
|
108
|
+
export type InputProps = typeof __propDef.props;
|
109
|
+
export type InputEvents = typeof __propDef.events;
|
110
|
+
export type InputSlots = typeof __propDef.slots;
|
111
|
+
export default class Input extends SvelteComponent<InputProps, InputEvents, InputSlots> {
|
112
|
+
}
|
113
|
+
export {};
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<script>let {
|
2
|
+
value,
|
3
|
+
maxlength
|
4
|
+
} = $props();
|
5
|
+
</script>
|
6
|
+
|
7
|
+
{#if maxlength}
|
8
|
+
<div class="InputLength">
|
9
|
+
<div class="Length" class:warn={(value?.length || 0) > maxlength - 5}>
|
10
|
+
{value?.length || 0}/{maxlength}
|
11
|
+
</div>
|
12
|
+
</div>
|
13
|
+
{/if}
|
14
|
+
|
15
|
+
<style>
|
16
|
+
.InputLength {
|
17
|
+
display: flex;
|
18
|
+
justify-content: flex-end;
|
19
|
+
align-items: center;
|
20
|
+
font-size: 0.8rem;
|
21
|
+
font-weight: 500;
|
22
|
+
color: var(--text-subtle);
|
23
|
+
}
|
24
|
+
.InputLength .Length {
|
25
|
+
display: flex;
|
26
|
+
align-items: center;
|
27
|
+
gap: 0.25rem;
|
28
|
+
}
|
29
|
+
.InputLength .Length.warn {
|
30
|
+
color: var(--text-warn);
|
31
|
+
}
|
32
|
+
</style>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
2
|
+
declare const __propDef: {
|
3
|
+
props: {
|
4
|
+
/** The value of the input. */
|
5
|
+
value: string;
|
6
|
+
/** The maximum length of the input. */
|
7
|
+
maxlength: number;
|
8
|
+
};
|
9
|
+
events: {
|
10
|
+
[evt: string]: CustomEvent<any>;
|
11
|
+
};
|
12
|
+
slots: {};
|
13
|
+
};
|
14
|
+
export type InputLengthProps = typeof __propDef.props;
|
15
|
+
export type InputLengthEvents = typeof __propDef.events;
|
16
|
+
export type InputLengthSlots = typeof __propDef.slots;
|
17
|
+
export default class InputLength extends SvelteComponent<InputLengthProps, InputLengthEvents, InputLengthSlots> {
|
18
|
+
}
|
19
|
+
export {};
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<script>import ContextTip from "../Display/ContextTip.svelte";
|
2
|
+
let {
|
3
|
+
id,
|
4
|
+
label,
|
5
|
+
tip
|
6
|
+
} = $props();
|
7
|
+
</script>
|
8
|
+
|
9
|
+
{#if label}
|
10
|
+
<label for={id}>
|
11
|
+
{#if typeof label === 'string'}
|
12
|
+
{label}
|
13
|
+
{:else}
|
14
|
+
{@render label()}
|
15
|
+
{/if}
|
16
|
+
{#if tip}
|
17
|
+
<ContextTip {tip} />
|
18
|
+
{/if}
|
19
|
+
</label>
|
20
|
+
{/if}
|
21
|
+
|
22
|
+
<style>
|
23
|
+
label {
|
24
|
+
cursor: var(--cursor, default);
|
25
|
+
}
|
26
|
+
</style>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
2
|
+
declare const __propDef: {
|
3
|
+
props: {
|
4
|
+
/** The id of the input element */
|
5
|
+
id?: string | undefined;
|
6
|
+
/** The label for the input */
|
7
|
+
label?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
8
|
+
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
9
|
+
}) | undefined;
|
10
|
+
/** The help text for the input */
|
11
|
+
tip?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
12
|
+
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
13
|
+
}) | undefined;
|
14
|
+
};
|
15
|
+
events: {
|
16
|
+
[evt: string]: CustomEvent<any>;
|
17
|
+
};
|
18
|
+
slots: {};
|
19
|
+
};
|
20
|
+
export type LabelProps = typeof __propDef.props;
|
21
|
+
export type LabelEvents = typeof __propDef.events;
|
22
|
+
export type LabelSlots = typeof __propDef.slots;
|
23
|
+
export default class Label extends SvelteComponent<LabelProps, LabelEvents, LabelSlots> {
|
24
|
+
}
|
25
|
+
export {};
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<script>import FieldContent from "./FieldContent.svelte";
|
2
|
+
let {
|
3
|
+
label,
|
4
|
+
labelTip,
|
5
|
+
help,
|
6
|
+
options
|
7
|
+
} = $props();
|
8
|
+
let id = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
9
|
+
</script>
|
10
|
+
|
11
|
+
<FieldContent {id} {label} {labelTip}>
|
12
|
+
<select>
|
13
|
+
{#each options as option}
|
14
|
+
{#if typeof option === "string"}
|
15
|
+
<option value={option}>{option}</option>
|
16
|
+
{:else}
|
17
|
+
<option value={option.value}>{option.label}</option>
|
18
|
+
{/if}
|
19
|
+
{/each}
|
20
|
+
</select>
|
21
|
+
</FieldContent>
|
22
|
+
|
23
|
+
<style>
|
24
|
+
</style>
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
2
|
+
declare const __propDef: {
|
3
|
+
props: {
|
4
|
+
label?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
5
|
+
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
6
|
+
}) | undefined;
|
7
|
+
labelTip?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
8
|
+
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
9
|
+
}) | undefined;
|
10
|
+
help?: string | ((this: void) => typeof import("svelte").SnippetReturn & {
|
11
|
+
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
|
12
|
+
}) | undefined;
|
13
|
+
options: string[] | {
|
14
|
+
value: string;
|
15
|
+
label: string;
|
16
|
+
}[];
|
17
|
+
};
|
18
|
+
events: {
|
19
|
+
[evt: string]: CustomEvent<any>;
|
20
|
+
};
|
21
|
+
slots: {};
|
22
|
+
};
|
23
|
+
export type SelectProps = typeof __propDef.props;
|
24
|
+
export type SelectEvents = typeof __propDef.events;
|
25
|
+
export type SelectSlots = typeof __propDef.slots;
|
26
|
+
export default class Select extends SvelteComponent<SelectProps, SelectEvents, SelectSlots> {
|
27
|
+
}
|
28
|
+
export {};
|
@@ -0,0 +1,34 @@
|
|
1
|
+
/// <reference types="svelte" />
|
2
|
+
import { type Writable } from 'svelte/store';
|
3
|
+
export declare const FormItems: Writable<Record<string, FormElement | FormElement[]>>;
|
4
|
+
export type FormElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
5
|
+
export type SuccessType = {
|
6
|
+
success: true;
|
7
|
+
value: any;
|
8
|
+
};
|
9
|
+
export type ErrorType = {
|
10
|
+
success: false;
|
11
|
+
error: string;
|
12
|
+
};
|
13
|
+
export type FormRegistry = {
|
14
|
+
items: Record<string, FormElement | FormElement[]>;
|
15
|
+
getValues(): Record<string, string>;
|
16
|
+
register(name: string, el: FormElement | FormElement[]): void;
|
17
|
+
updateFormValues(): void;
|
18
|
+
validate(): boolean;
|
19
|
+
validateField(nameOrElement: string): SuccessType | ErrorType;
|
20
|
+
validateField(nameOrElement: FormElement): SuccessType | ErrorType;
|
21
|
+
validateField(nameOrElement: FormElement[]): SuccessType | ErrorType;
|
22
|
+
validateSingleField(nameOrElement: string | FormElement): SuccessType | ErrorType;
|
23
|
+
};
|
24
|
+
export type BeforeSubmitFn = (opts: {
|
25
|
+
form: HTMLFormElement;
|
26
|
+
data: FormData;
|
27
|
+
cancel: () => void;
|
28
|
+
}) => void | Promise<void>;
|
29
|
+
export type AddBeforeSubmitFn = (id: string, fn: BeforeSubmitFn) => void;
|
30
|
+
export declare const getPropertyPaths: (schema: ZodType) => string[];
|
31
|
+
/**
|
32
|
+
* Keys that should be ignored when marking a field as changed.
|
33
|
+
*/
|
34
|
+
export declare const ignoreChangeKeys: string[];
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { writable } from 'svelte/store';
|
2
|
+
import { ZodArray, ZodNullable, ZodObject, ZodOptional, union, boolean, literal } from 'zod';
|
3
|
+
export const FormItems = writable({});
|
4
|
+
export const getPropertyPaths = (schema) => {
|
5
|
+
// check if schema is nullable or optional
|
6
|
+
if (schema instanceof ZodNullable ||
|
7
|
+
schema instanceof ZodOptional) {
|
8
|
+
return getPropertyPaths(schema.unwrap());
|
9
|
+
}
|
10
|
+
// check if schema is an array
|
11
|
+
if (schema instanceof ZodArray) {
|
12
|
+
return getPropertyPaths(schema.element);
|
13
|
+
}
|
14
|
+
// check if schema is an object
|
15
|
+
if (schema instanceof ZodObject) {
|
16
|
+
// loop through key/value pairs
|
17
|
+
const entries = Object.entries(schema.shape);
|
18
|
+
return entries.flatMap(([key, value]) => {
|
19
|
+
// get nested keys
|
20
|
+
const nested = getPropertyPaths(value).map((subKey) => `${key}.${subKey}`);
|
21
|
+
// return nested keys
|
22
|
+
return nested.length ? nested : key;
|
23
|
+
});
|
24
|
+
}
|
25
|
+
// return empty array
|
26
|
+
return [];
|
27
|
+
};
|
28
|
+
/**
|
29
|
+
* Keys that should be ignored when marking a field as changed.
|
30
|
+
*/
|
31
|
+
export const ignoreChangeKeys = ['Tab', 'Shift', 'Control', 'Alt', 'Meta', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight', 'Home', 'End', 'PageUp', 'PageDown', 'Escape', 'CapsLock', 'NumLock', 'ScrollLock', 'Pause', 'ContextMenu', 'PrintScreen', 'Help', 'Clear', 'OS', 'F1', 'F2', 'F3', 'F4', 'F5', 'F6', 'F7', 'F8', 'F9', 'F10', 'F12'];
|
@@ -0,0 +1,4 @@
|
|
1
|
+
export type Autocomplete = 'on' | 'off' | AutocompleteSingleToken | AutocompleteBilling | AutocompleteShipping;
|
2
|
+
export type AutocompleteBilling = 'billing' | `billing ${AutocompleteSingleToken}`;
|
3
|
+
export type AutocompleteShipping = 'shipping' | `shipping ${AutocompleteSingleToken}`;
|
4
|
+
export type AutocompleteSingleToken = `section-${string}` | "name" | "honorific-prefix" | "given-name" | "additional-name" | "family-name" | "honorific-suffix" | "nickname" | "email" | "username" | "new-password" | "current-password" | "one-time-code" | "organization-title" | "organization" | "street-address" | "address-line1" | "address-line2" | "address-line3" | "address-level4" | "address-level3" | "address-level2" | "address-level1" | "country" | "country-name" | "postal-code" | "cc-name" | "cc-given-name" | "cc-additional-name" | "cc-family-name" | "cc-number" | "cc-exp" | "cc-exp-month" | "cc-exp-year" | "cc-csc" | "cc-type" | "transaction-currency" | "transaction-amount" | "language" | "bday" | "bday-day" | "bday-month" | "bday-year" | "sex" | "tel" | "tel-country-code" | "tel-national" | "tel-area-code" | "tel-local" | "tel-extension" | "impp" | "url" | "photo" | "webauthn";
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
2
|
+
import { type Snippet } from "svelte";
|
3
|
+
declare const __propDef: {
|
4
|
+
props: {
|
5
|
+
children: Snippet;
|
6
|
+
};
|
7
|
+
events: {
|
8
|
+
[evt: string]: CustomEvent<any>;
|
9
|
+
};
|
10
|
+
slots: {};
|
11
|
+
};
|
12
|
+
export type ColumnProps = typeof __propDef.props;
|
13
|
+
export type ColumnEvents = typeof __propDef.events;
|
14
|
+
export type ColumnSlots = typeof __propDef.slots;
|
15
|
+
export default class Column extends SvelteComponent<ColumnProps, ColumnEvents, ColumnSlots> {
|
16
|
+
}
|
17
|
+
export {};
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<script>import { setContext } from "svelte";
|
2
|
+
let {
|
3
|
+
children,
|
4
|
+
fullWidth = false
|
5
|
+
} = $props();
|
6
|
+
</script>
|
7
|
+
|
8
|
+
<div class="Grid" class:fullWidth>
|
9
|
+
{@render children()}
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<style>
|
13
|
+
.Grid {
|
14
|
+
display: grid;
|
15
|
+
grid-template-columns: repeat(12, minmax(0, 1fr));
|
16
|
+
grid-gap: 1.5rem;
|
17
|
+
}
|
18
|
+
.Grid.fullWidth { block-size: 100%; }
|
19
|
+
</style>
|