lutra 0.0.33 → 0.1.4
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 +4 -24
- package/dist/components/AspectRatio.svelte +26 -0
- package/dist/components/AspectRatio.svelte.d.ts +8 -0
- package/dist/components/Avatar.svelte +105 -0
- package/dist/components/Avatar.svelte.d.ts +14 -0
- package/dist/{display → components}/Close.svelte +25 -7
- package/dist/components/Close.svelte.d.ts +7 -0
- package/dist/components/ContextTip.svelte +41 -0
- package/dist/components/ContextTip.svelte.d.ts +7 -0
- package/dist/components/Dialog.svelte +78 -0
- package/dist/components/Dialog.svelte.d.ts +14 -0
- package/dist/components/Icon.svelte +62 -0
- package/dist/components/Icon.svelte.d.ts +8 -0
- package/dist/{display → components}/IconButton.svelte +43 -14
- package/dist/components/IconButton.svelte.d.ts +16 -0
- package/dist/components/Image.svelte +172 -0
- package/dist/components/Image.svelte.d.ts +56 -0
- package/dist/{display → components}/Indicator.svelte +44 -9
- package/dist/components/Indicator.svelte.d.ts +12 -0
- package/dist/{display → components}/Inset.svelte +8 -3
- package/dist/components/Inset.svelte.d.ts +7 -0
- package/dist/components/Layout.svelte +33 -0
- package/dist/components/Layout.svelte.d.ts +11 -0
- package/dist/components/MenuDropdown.svelte +195 -0
- package/dist/components/MenuDropdown.svelte.d.ts +16 -0
- package/dist/{nav → components}/MenuItem.svelte +46 -38
- package/dist/components/MenuItem.svelte.d.ts +11 -0
- package/dist/components/MenuItemContent.svelte +25 -0
- package/dist/components/MenuItemContent.svelte.d.ts +10 -0
- package/dist/{nav → components}/MenuTypes.d.ts +19 -5
- package/dist/components/Modal.svelte +149 -0
- package/dist/components/Modal.svelte.d.ts +16 -0
- package/dist/{display → components}/Notification.svelte +33 -22
- package/dist/components/Notification.svelte.d.ts +12 -0
- package/dist/components/Overlay.svelte +31 -0
- package/dist/components/Overlay.svelte.d.ts +14 -0
- package/dist/{layout → components}/OverlayContainer.svelte +6 -3
- package/dist/{layout → components}/OverlayContainer.svelte.d.ts +4 -1
- package/dist/components/OverlayLayer.svelte +168 -0
- package/dist/components/OverlayLayer.svelte.d.ts +8 -0
- package/dist/components/PageContent.svelte +108 -0
- package/dist/components/PageContent.svelte.d.ts +38 -0
- package/dist/components/TabbedContent.svelte +74 -0
- package/dist/components/TabbedContent.svelte.d.ts +11 -0
- package/dist/components/TabbedContentItem.svelte +33 -0
- package/dist/components/TabbedContentItem.svelte.d.ts +10 -0
- package/dist/components/Table.svelte +41 -0
- package/dist/components/Table.svelte.d.ts +13 -0
- package/dist/{nav → components}/Tabs.svelte +99 -41
- package/dist/components/Tabs.svelte.d.ts +20 -0
- package/dist/components/Tag.svelte +120 -0
- package/dist/components/Tag.svelte.d.ts +21 -0
- package/dist/components/Theme.svelte +105 -0
- package/dist/components/Theme.svelte.d.ts +17 -0
- package/dist/{display → components}/Tooltip.svelte +41 -16
- package/dist/components/Tooltip.svelte.d.ts +12 -0
- package/dist/components/UIContent.svelte +19 -0
- package/dist/components/UIContent.svelte.d.ts +7 -0
- package/dist/components/index.d.ts +28 -0
- package/dist/components/index.js +29 -0
- package/dist/{display → components}/notifications.svelte.d.ts +1 -1
- package/dist/{display → components}/notifications.svelte.js +3 -4
- package/dist/{layout → components}/overlays.svelte.d.ts +4 -2
- package/dist/config.d.ts +30 -0
- package/dist/config.js +18 -0
- package/dist/css/1-props.css +440 -0
- package/dist/css/2-base.css +343 -0
- package/dist/css/3-typo.css +106 -0
- package/dist/css/4-layout.css +368 -0
- package/dist/css/5-media.css +116 -0
- package/dist/css/lutra.css +7 -0
- package/dist/css/themes/DefaultTheme.css +209 -0
- package/dist/form/Button.svelte +35 -16
- package/dist/form/Button.svelte.d.ts +8 -19
- package/dist/form/Datepicker.svelte +311 -0
- package/dist/form/Datepicker.svelte.d.ts +9 -0
- package/dist/form/FieldContent.svelte +69 -44
- package/dist/form/FieldContent.svelte.d.ts +7 -17
- package/dist/form/FieldError.svelte +16 -6
- package/dist/form/FieldError.svelte.d.ts +4 -15
- package/dist/form/Fieldset.svelte +48 -13
- package/dist/form/Fieldset.svelte.d.ts +5 -16
- package/dist/form/Form.svelte +158 -74
- package/dist/form/Form.svelte.d.ts +17 -17
- package/dist/form/{FieldActions.svelte → FormActions.svelte} +29 -17
- package/dist/form/FormActions.svelte.d.ts +9 -0
- package/dist/form/FormSection.svelte +96 -0
- package/dist/form/FormSection.svelte.d.ts +9 -0
- package/dist/form/ImageUpload.svelte +134 -94
- package/dist/form/ImageUpload.svelte.d.ts +5 -16
- package/dist/form/Input.svelte +254 -136
- package/dist/form/Input.svelte.d.ts +12 -21
- package/dist/form/InputLength.svelte +15 -5
- package/dist/form/InputLength.svelte.d.ts +4 -15
- package/dist/form/Label.svelte +55 -11
- package/dist/form/Label.svelte.d.ts +6 -15
- package/dist/form/LogoUpload.svelte +36 -21
- package/dist/form/LogoUpload.svelte.d.ts +4 -15
- package/dist/form/Select.svelte +100 -50
- package/dist/form/Select.svelte.d.ts +5 -16
- package/dist/form/Textarea.svelte +200 -98
- package/dist/form/Textarea.svelte.d.ts +11 -24
- package/dist/form/Toggle.svelte +3 -1
- package/dist/form/Toggle.svelte.d.ts +4 -1
- package/dist/form/client.svelte.d.ts +1 -0
- package/dist/form/client.svelte.js +6 -2
- package/dist/form/form.d.ts +10 -9
- package/dist/form/form.js +37 -32
- package/dist/form/index.d.ts +3 -4
- package/dist/form/index.js +3 -4
- package/dist/form/types.d.ts +9 -16
- package/dist/icons/IconAlert.svelte.d.ts +4 -1
- package/dist/icons/IconCopy.svelte.d.ts +4 -1
- package/dist/icons/IconDone.svelte.d.ts +4 -1
- package/dist/icons/IconError.svelte.d.ts +4 -1
- package/dist/icons/IconHelp.svelte.d.ts +4 -1
- package/dist/icons/IconHide.svelte.d.ts +4 -1
- package/dist/icons/IconInfo.svelte.d.ts +4 -1
- package/dist/icons/IconLink.svelte.d.ts +4 -1
- package/dist/icons/IconMenuBurger.svelte.d.ts +4 -1
- package/dist/icons/IconMenuDots.svelte.d.ts +4 -1
- package/dist/icons/IconSearch.svelte.d.ts +4 -1
- package/dist/icons/IconShow.svelte.d.ts +4 -1
- package/dist/icons/IconSuccess.svelte.d.ts +4 -1
- package/dist/icons/IconWarning.svelte.d.ts +4 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -2
- package/dist/types.d.ts +39 -0
- package/dist/types.js +25 -0
- package/dist/util/StringOrComponent.svelte +20 -0
- package/dist/util/StringOrComponent.svelte.d.ts +8 -0
- package/dist/util/StringOrSnippet.svelte +16 -0
- package/dist/util/StringOrSnippet.svelte.d.ts +8 -0
- package/dist/{utils → util}/dom.js +1 -2
- package/dist/util/locale.d.ts +1 -0
- package/dist/util/locale.js +47 -0
- package/dist/util/settings.d.ts +4 -0
- package/package.json +35 -79
- package/dist/color.css +0 -0
- package/dist/display/Avatar.svelte +0 -61
- package/dist/display/Avatar.svelte.d.ts +0 -19
- package/dist/display/Badge.svelte +0 -91
- package/dist/display/Badge.svelte.d.ts +0 -30
- package/dist/display/Callout.svelte +0 -109
- package/dist/display/Callout.svelte.d.ts +0 -28
- package/dist/display/Close.svelte.d.ts +0 -18
- package/dist/display/Code.svelte +0 -190
- package/dist/display/Code.svelte.d.ts +0 -32
- package/dist/display/ContextTip.svelte +0 -23
- package/dist/display/ContextTip.svelte.d.ts +0 -18
- package/dist/display/DataList.svelte +0 -16
- package/dist/display/DataList.svelte.d.ts +0 -21
- package/dist/display/Details.svelte +0 -49
- package/dist/display/Details.svelte.d.ts +0 -27
- package/dist/display/Hero.svelte +0 -50
- package/dist/display/Hero.svelte.d.ts +0 -26
- package/dist/display/Icon.svelte +0 -39
- package/dist/display/Icon.svelte.d.ts +0 -19
- package/dist/display/IconButton.svelte.d.ts +0 -27
- package/dist/display/Image.svelte +0 -91
- package/dist/display/Image.svelte.d.ts +0 -26
- package/dist/display/Indicator.svelte.d.ts +0 -23
- package/dist/display/Inset.svelte.d.ts +0 -18
- package/dist/display/LineChart.svelte +0 -385
- package/dist/display/LineChart.svelte.d.ts +0 -24
- package/dist/display/LoadingIndicator.svelte +0 -33
- package/dist/display/LoadingIndicator.svelte.d.ts +0 -15
- package/dist/display/Modal.svelte +0 -116
- package/dist/display/Modal.svelte.d.ts +0 -27
- package/dist/display/Notification.svelte.d.ts +0 -23
- package/dist/display/Panel.svelte +0 -23
- package/dist/display/Panel.svelte.d.ts +0 -19
- package/dist/display/Popup.svelte +0 -111
- package/dist/display/Popup.svelte.d.ts +0 -25
- package/dist/display/Stat.svelte +0 -81
- package/dist/display/Stat.svelte.d.ts +0 -30
- package/dist/display/Table.svelte +0 -28
- package/dist/display/Table.svelte.d.ts +0 -24
- package/dist/display/TablePaginator.svelte +0 -51
- package/dist/display/TablePaginator.svelte.d.ts +0 -21
- package/dist/display/Tag.svelte +0 -90
- package/dist/display/Tag.svelte.d.ts +0 -32
- package/dist/display/Tooltip.svelte.d.ts +0 -23
- package/dist/display/chart.d.ts +0 -78
- package/dist/display/chart.js +0 -212
- package/dist/display/index.d.ts +0 -24
- package/dist/display/index.js +0 -24
- package/dist/form/FieldActions.svelte.d.ts +0 -20
- package/dist/form/FieldContainer.svelte +0 -37
- package/dist/form/FieldContainer.svelte.d.ts +0 -19
- package/dist/form/FieldSection.svelte +0 -86
- package/dist/form/FieldSection.svelte.d.ts +0 -20
- package/dist/layout/Layout.svelte +0 -47
- package/dist/layout/Layout.svelte.d.ts +0 -22
- package/dist/layout/LayoutFooter.svelte +0 -21
- package/dist/layout/LayoutFooter.svelte.d.ts +0 -18
- package/dist/layout/LayoutGrid.svelte +0 -51
- package/dist/layout/LayoutGrid.svelte.d.ts +0 -27
- package/dist/layout/LayoutHeader.svelte +0 -97
- package/dist/layout/LayoutHeader.svelte.d.ts +0 -34
- package/dist/layout/LayoutSideMenu.svelte +0 -55
- package/dist/layout/LayoutSideMenu.svelte.d.ts +0 -21
- package/dist/layout/LayoutTypes.d.ts +0 -15
- package/dist/layout/LayoutTypes.js +0 -9
- package/dist/layout/Overlay.svelte +0 -20
- package/dist/layout/Overlay.svelte.d.ts +0 -25
- package/dist/layout/OverlayLayer.svelte +0 -140
- package/dist/layout/OverlayLayer.svelte.d.ts +0 -19
- package/dist/layout/PageContent.svelte +0 -82
- package/dist/layout/PageContent.svelte.d.ts +0 -25
- package/dist/layout/Theme.svelte +0 -243
- package/dist/layout/Theme.svelte.d.ts +0 -19
- package/dist/layout/UIContent.svelte +0 -15
- package/dist/layout/UIContent.svelte.d.ts +0 -18
- package/dist/layout/index.d.ts +0 -11
- package/dist/layout/index.js +0 -11
- package/dist/nav/Breadcrumb.svelte +0 -82
- package/dist/nav/Breadcrumb.svelte.d.ts +0 -28
- package/dist/nav/Menu.svelte +0 -170
- package/dist/nav/Menu.svelte.d.ts +0 -27
- package/dist/nav/MenuItem.svelte.d.ts +0 -22
- package/dist/nav/NavMenu.svelte +0 -181
- package/dist/nav/NavMenu.svelte.d.ts +0 -19
- package/dist/nav/TabbedContent.svelte +0 -43
- package/dist/nav/TabbedContent.svelte.d.ts +0 -23
- package/dist/nav/Tabs.svelte.d.ts +0 -25
- package/dist/nav/index.d.ts +0 -7
- package/dist/nav/index.js +0 -6
- package/dist/style.css +0 -950
- package/dist/typo/Clamp.svelte +0 -25
- package/dist/typo/Clamp.svelte.d.ts +0 -24
- package/dist/typo/H.svelte +0 -52
- package/dist/typo/H.svelte.d.ts +0 -28
- package/dist/typo/H1.svelte +0 -14
- package/dist/typo/H1.svelte.d.ts +0 -26
- package/dist/typo/H2.svelte +0 -14
- package/dist/typo/H2.svelte.d.ts +0 -26
- package/dist/typo/H3.svelte +0 -14
- package/dist/typo/H3.svelte.d.ts +0 -26
- package/dist/typo/H4.svelte +0 -14
- package/dist/typo/H4.svelte.d.ts +0 -26
- package/dist/typo/H5.svelte +0 -14
- package/dist/typo/H5.svelte.d.ts +0 -26
- package/dist/typo/H6.svelte +0 -14
- package/dist/typo/H6.svelte.d.ts +0 -26
- package/dist/typo/P.svelte +0 -34
- package/dist/typo/P.svelte.d.ts +0 -26
- package/dist/typo/index.d.ts +0 -9
- package/dist/typo/index.js +0 -9
- package/dist/utils/StringOrComponent.svelte +0 -14
- package/dist/utils/StringOrComponent.svelte.d.ts +0 -19
- package/dist/utils/StringOrSnippet.svelte +0 -11
- package/dist/utils/StringOrSnippet.svelte.d.ts +0 -19
- package/dist/utils/defaults.d.ts +0 -4
- package/dist/utils/hooks.server.d.ts +0 -2
- package/dist/utils/hooks.server.js +0 -16
- package/dist/utils/id.d.ts +0 -1
- package/dist/utils/id.js +0 -3
- package/dist/utils/index.d.ts +0 -9
- package/dist/utils/index.js +0 -6
- package/dist/utils/isSnippet.d.ts +0 -3
- package/dist/utils/isSnippet.js +0 -11
- /package/dist/{nav → components}/MenuTypes.js +0 -0
- /package/dist/{layout → components}/overlays.svelte.js +0 -0
- /package/dist/{utils → util}/attr.d.ts +0 -0
- /package/dist/{utils → util}/attr.js +0 -0
- /package/dist/{utils → util}/color.d.ts +0 -0
- /package/dist/{utils → util}/color.js +0 -0
- /package/dist/{utils → util}/dom.d.ts +0 -0
- /package/dist/{utils → util}/keyboard.svelte.d.ts +0 -0
- /package/dist/{utils → util}/keyboard.svelte.js +0 -0
- /package/dist/{utils/defaults.js → util/settings.js} +0 -0
- /package/dist/{utils → util}/transitions.d.ts +0 -0
- /package/dist/{utils → util}/transitions.js +0 -0
@@ -1,25 +1,16 @@
|
|
1
1
|
import type { Snippet } from "svelte";
|
2
|
-
|
3
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
4
|
-
$$bindings?: Bindings;
|
5
|
-
} & Exports;
|
6
|
-
(internal: unknown, props: Props & {
|
7
|
-
$$events?: Events;
|
8
|
-
$$slots?: Slots;
|
9
|
-
}): Exports;
|
10
|
-
z_$$bindings?: Bindings;
|
11
|
-
}
|
12
|
-
declare const Label: $$__sveltets_2_IsomorphicComponent<{
|
2
|
+
type $$ComponentProps = {
|
13
3
|
/** The id of the input element */
|
14
4
|
id?: string;
|
15
5
|
/** The label for the input */
|
16
6
|
label?: string | Snippet;
|
17
7
|
/** The help text for the input */
|
18
8
|
tip?: string | Snippet;
|
9
|
+
/** The help text for the input */
|
10
|
+
help?: string | Snippet;
|
19
11
|
/** Whether the input is required */
|
20
12
|
required?: boolean;
|
21
|
-
}
|
22
|
-
|
23
|
-
|
24
|
-
type Label = InstanceType<typeof Label>;
|
13
|
+
};
|
14
|
+
declare const Label: import("svelte").Component<$$ComponentProps, {}, "">;
|
15
|
+
type Label = ReturnType<typeof Label>;
|
25
16
|
export default Label;
|
@@ -1,28 +1,43 @@
|
|
1
|
-
<script lang="ts">
|
2
|
-
import
|
3
|
-
import ImageUpload from "./ImageUpload.svelte";
|
4
|
-
import
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
1
|
+
<script lang="ts">
|
2
|
+
import Theme from "../components/Theme.svelte";
|
3
|
+
import ImageUpload from "./ImageUpload.svelte";
|
4
|
+
import type { Snippet } from "svelte";
|
5
|
+
import StringOrSnippet from "../util/StringOrSnippet.svelte";
|
6
|
+
|
7
|
+
let {
|
8
|
+
lightLogoInputName = 'logo_light_url',
|
9
|
+
darkLogoInputName = 'logo_dark_url',
|
10
|
+
lightLogoUploadUrl,
|
11
|
+
darkLogoUploadUrl,
|
12
|
+
buttonText = 'Select',
|
13
|
+
lightLogoSrc,
|
14
|
+
darkLogoSrc,
|
15
|
+
lightHelp = 'This logo will be used on a light theme background.',
|
16
|
+
darkHelp = 'If not set, the light theme logo will be used instead.',
|
17
|
+
accept = 'image/png,image/jpg',
|
18
|
+
maxSize = 1024 * 1024 * 4, // 4MB
|
19
|
+
removable = true
|
20
|
+
}: {
|
21
|
+
lightLogoInputName?: string;
|
22
|
+
darkLogoInputName?: string;
|
23
|
+
lightLogoUploadUrl: string;
|
24
|
+
darkLogoUploadUrl: string;
|
25
|
+
buttonText?: string;
|
26
|
+
lightLogoSrc?: string | null;
|
27
|
+
darkLogoSrc?: string | null;
|
28
|
+
lightHelp?: string | Snippet;
|
29
|
+
darkHelp?: string | Snippet;
|
30
|
+
accept: string;
|
31
|
+
maxSize?: number;
|
32
|
+
removable?: boolean;
|
33
|
+
} = $props();
|
34
|
+
|
20
35
|
</script>
|
21
36
|
|
22
37
|
<div class="LogoUpload">
|
23
38
|
<Theme theme="light">
|
24
39
|
<div class="Content">
|
25
|
-
<
|
40
|
+
<h5>Light theme</h5>
|
26
41
|
<div class="Info">
|
27
42
|
<small><StringOrSnippet content={lightHelp} /></small>
|
28
43
|
<ImageUpload
|
@@ -41,7 +56,7 @@ let {
|
|
41
56
|
</Theme>
|
42
57
|
<Theme theme="dark">
|
43
58
|
<div class="Content">
|
44
|
-
<
|
59
|
+
<h5>Dark theme</h5>
|
45
60
|
<div class="Info">
|
46
61
|
<small><StringOrSnippet content={darkHelp} /></small>
|
47
62
|
<ImageUpload
|
@@ -1,15 +1,5 @@
|
|
1
1
|
import type { Snippet } from "svelte";
|
2
|
-
|
3
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
4
|
-
$$bindings?: Bindings;
|
5
|
-
} & Exports;
|
6
|
-
(internal: unknown, props: Props & {
|
7
|
-
$$events?: Events;
|
8
|
-
$$slots?: Slots;
|
9
|
-
}): Exports;
|
10
|
-
z_$$bindings?: Bindings;
|
11
|
-
}
|
12
|
-
declare const LogoUpload: $$__sveltets_2_IsomorphicComponent<{
|
2
|
+
type $$ComponentProps = {
|
13
3
|
lightLogoInputName?: string;
|
14
4
|
darkLogoInputName?: string;
|
15
5
|
lightLogoUploadUrl: string;
|
@@ -22,8 +12,7 @@ declare const LogoUpload: $$__sveltets_2_IsomorphicComponent<{
|
|
22
12
|
accept: string;
|
23
13
|
maxSize?: number;
|
24
14
|
removable?: boolean;
|
25
|
-
}
|
26
|
-
|
27
|
-
|
28
|
-
type LogoUpload = InstanceType<typeof LogoUpload>;
|
15
|
+
};
|
16
|
+
declare const LogoUpload: import("svelte").Component<$$ComponentProps, {}, "">;
|
17
|
+
type LogoUpload = ReturnType<typeof LogoUpload>;
|
29
18
|
export default LogoUpload;
|
package/dist/form/Select.svelte
CHANGED
@@ -1,52 +1,102 @@
|
|
1
|
-
<script lang="ts">
|
2
|
-
import
|
3
|
-
import {
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import
|
7
|
-
import
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
1
|
+
<script lang="ts">
|
2
|
+
import { getContext, onMount, type Snippet } from "svelte";
|
3
|
+
import type { LutraForm } from "./types.js";
|
4
|
+
import { fieldChange, fieldKeydown, ignoreKeys } from "./client.svelte.js";
|
5
|
+
import { getFromObjWithStringPath } from "./form.js";
|
6
|
+
import { ZodType } from "zod";
|
7
|
+
import FieldContent from "./FieldContent.svelte";
|
8
|
+
|
9
|
+
let {
|
10
|
+
autofocus,
|
11
|
+
children,
|
12
|
+
disabled,
|
13
|
+
help,
|
14
|
+
id = $bindable(crypto.randomUUID()),
|
15
|
+
label,
|
16
|
+
labelTip,
|
17
|
+
name,
|
18
|
+
onblur,
|
19
|
+
onchange,
|
20
|
+
onclick,
|
21
|
+
onfocus,
|
22
|
+
onkeydown,
|
23
|
+
onkeyup,
|
24
|
+
onkeypress,
|
25
|
+
options,
|
26
|
+
placeholder,
|
27
|
+
required,
|
28
|
+
results,
|
29
|
+
shape = 'default',
|
30
|
+
tabindex,
|
31
|
+
value = $bindable(),
|
32
|
+
}: {
|
33
|
+
/** Whether the input should be autofocused. */
|
34
|
+
autofocus?: boolean;
|
35
|
+
/** Options for the select element. */
|
36
|
+
children?: Snippet;
|
37
|
+
/** Whether the input should be disabled. */
|
38
|
+
disabled?: boolean;
|
39
|
+
/** Help text to display below the input. */
|
40
|
+
help?: string | Snippet;
|
41
|
+
/** A random id is generated if not provided. */
|
42
|
+
id?: string;
|
43
|
+
/** The label for the input */
|
44
|
+
label?: string | Snippet
|
45
|
+
/** Context tooltip for a label. Renders with a questionmark using ContextTip. */
|
46
|
+
labelTip?: string | Snippet;
|
47
|
+
/** The name of the input element. */
|
48
|
+
name: string;
|
49
|
+
/** The onblur event handler */
|
50
|
+
onblur?: (e: FocusEvent) => void;
|
51
|
+
/** Onchange event handler */
|
52
|
+
onchange?: (e: Event) => void;
|
53
|
+
/** Onclick event handler */
|
54
|
+
onclick?: (e: MouseEvent) => void;
|
55
|
+
/** Onfocus event handler */
|
56
|
+
onfocus?: (e: FocusEvent) => void;
|
57
|
+
/** Keyup event handler */
|
58
|
+
onkeyup?: (e: KeyboardEvent) => void;
|
59
|
+
/** Keydown event handler */
|
60
|
+
onkeydown?: (e: KeyboardEvent) => void;
|
61
|
+
/** Keypress event handler */
|
62
|
+
onkeypress?: (e: KeyboardEvent) => void;
|
63
|
+
/** The options for the select element. */
|
64
|
+
options?: string[] | { value: string; label: string }[];
|
65
|
+
/** Placeholder text to display when the input is empty. */
|
66
|
+
placeholder?: string;
|
67
|
+
/** Suffix content, to display after the input. */
|
68
|
+
suffix?: string | Snippet;
|
69
|
+
/** Prefix content, to display before the input. */
|
70
|
+
prefix?: string | Snippet;
|
71
|
+
/** Whether the input should be required. */
|
72
|
+
required?: boolean;
|
73
|
+
/** The maximum number of items that should be displayed in the drop-down list of previous search queries. Safari only. */
|
74
|
+
results?: number;
|
75
|
+
/** The shape of the input element. */
|
76
|
+
shape?: 'default' | 'rounded' | 'pill' | 'circle';
|
77
|
+
/** Source URL for the image type. */
|
78
|
+
src?: string;
|
79
|
+
/** An integer attribute indicating if the element can take input focus (is focusable), if it should participate to sequential keyboard navigation. */
|
80
|
+
tabindex?: number;
|
81
|
+
/** The value of the input element. */
|
82
|
+
value?: string | number | boolean | null;
|
83
|
+
} = $props();
|
84
|
+
|
85
|
+
let el: HTMLSelectElement | undefined = $state();
|
86
|
+
|
87
|
+
// Set defaults from form context
|
88
|
+
const form = getContext<LutraForm<any>>('form');
|
89
|
+
const field = $derived(form?.fields[name]);
|
90
|
+
const issue = $derived(form?.issues?.find((issue) => issue.name === name));
|
91
|
+
const validator = getContext<Record<string, ZodType>>('form.validators')?.[name];
|
92
|
+
const data = form?.data;
|
93
|
+
const originalData = form?.originalData;
|
94
|
+
if(!value) value = form ? (getFromObjWithStringPath(Object.assign(originalData ?? {}, data ?? {}), name) as string) || form?.fields?.[name]?.defaultValue as string : '';
|
95
|
+
|
96
|
+
onMount(() => {
|
97
|
+
if(value) fieldChange(form, name, () => el)({} as any);
|
98
|
+
});
|
99
|
+
|
50
100
|
</script>
|
51
101
|
|
52
102
|
<FieldContent
|
@@ -128,7 +178,7 @@ onMount(() => {
|
|
128
178
|
}
|
129
179
|
svg {
|
130
180
|
display: block;
|
131
|
-
color: var(--field-text);
|
181
|
+
color: var(--field-text-color, light-dark(black, white));
|
132
182
|
}
|
133
183
|
select:focus-visible {
|
134
184
|
outline: none;
|
@@ -1,15 +1,5 @@
|
|
1
1
|
import { type Snippet } from "svelte";
|
2
|
-
|
3
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
4
|
-
$$bindings?: Bindings;
|
5
|
-
} & Exports;
|
6
|
-
(internal: unknown, props: Props & {
|
7
|
-
$$events?: Events;
|
8
|
-
$$slots?: Slots;
|
9
|
-
}): Exports;
|
10
|
-
z_$$bindings?: Bindings;
|
11
|
-
}
|
12
|
-
declare const Select: $$__sveltets_2_IsomorphicComponent<{
|
2
|
+
type $$ComponentProps = {
|
13
3
|
/** Whether the input should be autofocused. */
|
14
4
|
autofocus?: boolean;
|
15
5
|
/** Options for the select element. */
|
@@ -56,15 +46,14 @@ declare const Select: $$__sveltets_2_IsomorphicComponent<{
|
|
56
46
|
/** The maximum number of items that should be displayed in the drop-down list of previous search queries. Safari only. */
|
57
47
|
results?: number;
|
58
48
|
/** The shape of the input element. */
|
59
|
-
shape?:
|
49
|
+
shape?: 'default' | 'rounded' | 'pill' | 'circle';
|
60
50
|
/** Source URL for the image type. */
|
61
51
|
src?: string;
|
62
52
|
/** An integer attribute indicating if the element can take input focus (is focusable), if it should participate to sequential keyboard navigation. */
|
63
53
|
tabindex?: number;
|
64
54
|
/** The value of the input element. */
|
65
55
|
value?: string | number | boolean | null;
|
66
|
-
}
|
67
|
-
|
68
|
-
|
69
|
-
type Select = InstanceType<typeof Select>;
|
56
|
+
};
|
57
|
+
declare const Select: import("svelte").Component<$$ComponentProps, {}, "id" | "value">;
|
58
|
+
type Select = ReturnType<typeof Select>;
|
70
59
|
export default Select;
|
@@ -1,100 +1,203 @@
|
|
1
|
-
<script lang="ts">
|
2
|
-
import {
|
3
|
-
import { IconCopy, IconDone, IconShow } from "../icons/index.js";
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
1
|
+
<script lang="ts">
|
2
|
+
import { getContext, onMount, type Snippet } from "svelte";
|
3
|
+
import { IconCopy, IconDone, IconShow } from "../icons/index.js";
|
4
|
+
import Tooltip from "../components/Tooltip.svelte";
|
5
|
+
import IconButton from "../components/IconButton.svelte";
|
6
|
+
import type { Autocomplete, LutraForm } from "./types.js";
|
7
|
+
import FieldContent from "./FieldContent.svelte";
|
8
|
+
import { fieldChange, fieldKeydown } from "./client.svelte.js";
|
9
|
+
import { getFromObjWithStringPath } from "./form.js";
|
10
|
+
import { ZodType } from "zod";
|
11
|
+
|
12
|
+
let {
|
13
|
+
autofocus,
|
14
|
+
autocapitalize,
|
15
|
+
autocomplete,
|
16
|
+
autoresize,
|
17
|
+
checked,
|
18
|
+
contained,
|
19
|
+
copyable,
|
20
|
+
defaultValue,
|
21
|
+
dirname,
|
22
|
+
disabled,
|
23
|
+
enterkeyhint,
|
24
|
+
help,
|
25
|
+
id = $bindable(crypto.randomUUID()),
|
26
|
+
inputmode,
|
27
|
+
label,
|
28
|
+
labelTip,
|
29
|
+
list,
|
30
|
+
maxlength,
|
31
|
+
minlength,
|
32
|
+
name,
|
33
|
+
pattern,
|
34
|
+
placeholder,
|
35
|
+
suffix,
|
36
|
+
onblur,
|
37
|
+
onchange,
|
38
|
+
onclick,
|
39
|
+
onfocus,
|
40
|
+
onkeydown,
|
41
|
+
onkeyup,
|
42
|
+
onkeypress,
|
43
|
+
prefix,
|
44
|
+
readonly,
|
45
|
+
required,
|
46
|
+
resize = true,
|
47
|
+
shape = 'rounded',
|
48
|
+
step,
|
49
|
+
style,
|
50
|
+
tabindex,
|
51
|
+
title,
|
52
|
+
value = $bindable(),
|
53
|
+
...rest
|
54
|
+
}: {
|
55
|
+
/** Whether the input should be autofocused. */
|
56
|
+
autofocus?: boolean;
|
57
|
+
/** Whether the input should be autocapitalized. */
|
58
|
+
autocapitalize?: boolean | 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters';
|
59
|
+
/** Specifies whether autocomplete is enabled for the input. */
|
60
|
+
autocomplete?: Autocomplete;
|
61
|
+
/** Whether the input should resize automatically. */
|
62
|
+
autoresize?: boolean;
|
63
|
+
/** A hint to the browser for which capture method to use. */
|
64
|
+
capture?: 'user' | 'environment';
|
65
|
+
/** Whether the input should be checked. */
|
66
|
+
checked?: boolean;
|
67
|
+
/** Whether the input should be contained. */
|
68
|
+
contained?: boolean;
|
69
|
+
/** Whether the input should be copyable. */
|
70
|
+
copyable?: boolean;
|
71
|
+
/** The default value of the input element. */
|
72
|
+
defaultValue?: string;
|
73
|
+
/** Form field name for the directionality of the element's text content during form submission */
|
74
|
+
dirname?: string;
|
75
|
+
/** Whether the input should be disabled. */
|
76
|
+
disabled?: boolean;
|
77
|
+
/** A hint to the browser for which enter key to display for the input. */
|
78
|
+
enterkeyhint?: 'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send';
|
79
|
+
/** The height of the input element. Valid for image inputs. */
|
80
|
+
height?: number;
|
81
|
+
/** Help text to display below the input. */
|
82
|
+
help?: string | Snippet;
|
83
|
+
/** A random id is generated if not provided. */
|
84
|
+
id?: string;
|
85
|
+
/** Whether the input should be indeterminate. */
|
86
|
+
indeterminate?: boolean;
|
87
|
+
/** 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 */
|
88
|
+
inputmode?: 'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search';
|
89
|
+
/** The label for the input */
|
90
|
+
label?: string | Snippet
|
91
|
+
/** Context tooltip for a label. Renders with a questionmark using ContextTip. */
|
92
|
+
labelTip?: string | Snippet;
|
93
|
+
/** The id of a datalist element that contains pre-defined options for the input element. */
|
94
|
+
list?: string;
|
95
|
+
/** 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. */
|
96
|
+
maxlength?: number;
|
97
|
+
/** 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. */
|
98
|
+
minlength?: number;
|
99
|
+
/** The name of the input element. */
|
100
|
+
name: string;
|
101
|
+
/** The onblur event handler */
|
102
|
+
onblur?: (e: FocusEvent) => void;
|
103
|
+
/** Onchange event handler */
|
104
|
+
onchange?: (e: Event) => void;
|
105
|
+
/** Onclick event handler */
|
106
|
+
onclick?: (e: MouseEvent) => void;
|
107
|
+
/** Onfocus event handler */
|
108
|
+
onfocus?: (e: FocusEvent) => void;
|
109
|
+
/** Keyup event handler */
|
110
|
+
onkeyup?: (e: KeyboardEvent) => void;
|
111
|
+
/** Keydown event handler */
|
112
|
+
onkeydown?: (e: KeyboardEvent) => void;
|
113
|
+
/** Keypress event handler */
|
114
|
+
onkeypress?: (e: KeyboardEvent) => void;
|
115
|
+
/** A regular expression that the input's value is checked against. Valid for text, search, url, tel, email, and password. */
|
116
|
+
pattern?: string;
|
117
|
+
/** Placeholder text to display when the input is empty. */
|
118
|
+
placeholder?: string;
|
119
|
+
/** Suffix content, to display after the input. */
|
120
|
+
suffix?: string | Snippet;
|
121
|
+
/** Prefix content, to display before the input. */
|
122
|
+
prefix?: string | Snippet;
|
123
|
+
/** Whether the input should be read-only. */
|
124
|
+
readonly?: boolean;
|
125
|
+
/** Whether the input should be required. */
|
126
|
+
required?: boolean;
|
127
|
+
/** Whether the textarea is resizable. */
|
128
|
+
resize?: boolean | 'both' | 'horizontal' | 'vertical' | 'none';
|
129
|
+
/** The shape of the input element. */
|
130
|
+
shape?: 'default' | 'rounded' | 'pill' | 'circle';
|
131
|
+
/** Spellcheck the input. */
|
132
|
+
spellcheck?: boolean;
|
133
|
+
/** A number that specifies the granularity that the value must adhere to. Valid for date, month, week, time, datetime-local, number, and range. */
|
134
|
+
step?: number;
|
135
|
+
/** Inline styles to apply to the input element. */
|
136
|
+
style?: string;
|
137
|
+
/** An integer attribute indicating if the element can take input focus (is focusable), if it should participate to sequential keyboard navigation. */
|
138
|
+
tabindex?: number;
|
139
|
+
/** A string that defines the title of the input element. */
|
140
|
+
title?: string;
|
141
|
+
/** The value of the input element. */
|
142
|
+
value?: string | null;
|
143
|
+
} = $props();
|
144
|
+
|
145
|
+
let el: HTMLTextAreaElement | undefined = $state();
|
146
|
+
let copyTitle = $state('Copy');
|
147
|
+
let viewTitle = $state('Show');
|
148
|
+
let copyTooltipOpen = $state(false);
|
149
|
+
let copyBtnIcon = $state(IconCopy);
|
150
|
+
let viewBtnIcon = $state(IconShow);
|
151
|
+
let resizeClass = $derived(resize === true ? 'resize' : resize === false ? '' : resize);
|
152
|
+
|
153
|
+
// Set defaults from form context
|
154
|
+
const form = getContext<LutraForm<any>>('form');
|
155
|
+
const field = $derived(form?.fields[name]);
|
156
|
+
const issue = $derived(form?.issues?.find((issue) => issue.name === name));
|
157
|
+
const validator = getContext<Record<string, ZodType>>('form.validators')?.[name];
|
158
|
+
const data = form?.data;
|
159
|
+
const originalData = form?.originalData;
|
160
|
+
|
161
|
+
if(contained === undefined) { contained = getContext('lutra.form.input.contained') ?? getContext('lutra.form.contained') ?? getContext('lutra.contained') ?? false; }
|
162
|
+
|
163
|
+
if(!value) value = form ? (getFromObjWithStringPath(Object.assign(originalData ?? {}, data ?? {}), name) as string) || form?.fields?.[name]?.defaultValue as string : '';
|
164
|
+
|
165
|
+
function copy(e: MouseEvent) {
|
166
|
+
e.preventDefault();
|
167
|
+
if(!el) return;
|
168
|
+
// try with navigator.clipboard
|
169
|
+
if(navigator.clipboard) {
|
170
|
+
navigator.clipboard.writeText(value!);
|
171
|
+
} else {
|
172
|
+
el.focus();
|
173
|
+
el.select();
|
174
|
+
document.execCommand('copy');
|
175
|
+
}
|
176
|
+
copyBtnIcon = IconDone;
|
177
|
+
copyTitle = 'Copied!';
|
178
|
+
copyTooltipOpen = true;
|
179
|
+
setTimeout(() => {
|
180
|
+
copyBtnIcon = IconCopy;
|
181
|
+
copyTitle = 'Copy';
|
182
|
+
copyTooltipOpen = false;
|
183
|
+
}, 1500);
|
184
|
+
el!.focus();
|
185
|
+
}
|
186
|
+
|
187
|
+
function onresize() {
|
188
|
+
if(!autoresize || !el || !value) return;
|
189
|
+
setTimeout(() => {
|
190
|
+
el!.style.height = 'auto';
|
191
|
+
el!.style.height = `${el!.scrollHeight+2}px`;
|
192
|
+
}, 0);
|
193
|
+
}
|
194
|
+
|
195
|
+
onMount(() => {
|
196
|
+
if(value) fieldChange(form, name, () => el)({} as any);
|
197
|
+
setTimeout(() => {
|
198
|
+
onresize();
|
199
|
+
}, 5);
|
200
|
+
});
|
98
201
|
</script>
|
99
202
|
|
100
203
|
<svelte:window onresize={onresize} />
|
@@ -115,7 +218,6 @@ onMount(() => {
|
|
115
218
|
{autofocus}
|
116
219
|
autocapitalize={typeof autocapitalize === 'string' ? autocapitalize : (typeof autocapitalize === 'boolean' ? (autocapitalize ? 'on' : 'off') : undefined)}
|
117
220
|
{autocomplete}
|
118
|
-
autocorrect={typeof autocorrect === 'boolean' ? (autocorrect ? 'on' : 'off') : undefined}
|
119
221
|
{dirname}
|
120
222
|
{disabled}
|
121
223
|
{enterkeyhint}
|