@webamoki/web-svelte 0.3.3 → 0.4.0

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.
@@ -0,0 +1,22 @@
1
+ <script lang="ts">
2
+ import Loader2Icon from '@lucide/svelte/icons/loader-2';
3
+ import { Button } from '../../shadcn/components/ui/button/index.js';
4
+ import type { ButtonProps } from '../../shadcn/components/ui/button/index.js';
5
+ import type { Readable } from 'svelte/store';
6
+
7
+ type Props = ButtonProps & {
8
+ loading?: boolean;
9
+ delayed?: Readable<boolean>;
10
+ };
11
+
12
+ let { disabled, loading, delayed, children, ...restProps }: Props = $props();
13
+ </script>
14
+
15
+ <Button disabled={disabled || loading || $delayed} {...restProps}>
16
+ {#if loading || $delayed}
17
+ <Loader2Icon class="mr-2 animate-spin" />
18
+ Please wait
19
+ {:else}
20
+ {@render children?.()}
21
+ {/if}
22
+ </Button>
@@ -0,0 +1,10 @@
1
+ import { Button } from '../../shadcn/components/ui/button/index.js';
2
+ import type { ButtonProps } from '../../shadcn/components/ui/button/index.js';
3
+ import type { Readable } from 'svelte/store';
4
+ type Props = ButtonProps & {
5
+ loading?: boolean;
6
+ delayed?: Readable<boolean>;
7
+ };
8
+ declare const Button: import("svelte").Component<Props, {}, "">;
9
+ type Button = ReturnType<typeof Button>;
10
+ export default Button;
@@ -0,0 +1,15 @@
1
+ <script lang="ts" generics="T extends Record<string, unknown>, U extends FormPath<T>, M">
2
+ import type { FormPath } from 'sveltekit-superforms';
3
+ import FieldWrapper, { type FieldWrapperProps } from '../FieldWrapper.svelte';
4
+ import ColorPicker from 'svelte-awesome-color-picker';
5
+ interface Props extends FieldWrapperProps<T, U, M> {
6
+ value?: string;
7
+ }
8
+ let { value = $bindable(), ...fieldProps }: Props = $props();
9
+ </script>
10
+
11
+ <FieldWrapper {...fieldProps}>
12
+ {#snippet formElem()}
13
+ <ColorPicker bind:hex={value} label={value} isAlpha={false} position="responsive" />
14
+ {/snippet}
15
+ </FieldWrapper>
@@ -0,0 +1,28 @@
1
+ import type { FormPath } from 'sveltekit-superforms';
2
+ import { type FieldWrapperProps } from '../FieldWrapper.svelte';
3
+ declare function $$render<T extends Record<string, unknown>, U extends FormPath<T>, M>(): {
4
+ props: FieldWrapperProps<T, U, M> & {
5
+ value?: string;
6
+ };
7
+ exports: {};
8
+ bindings: "value";
9
+ slots: {};
10
+ events: {};
11
+ };
12
+ declare class __sveltets_Render<T extends Record<string, unknown>, U extends FormPath<T>, M> {
13
+ props(): ReturnType<typeof $$render<T, U, M>>['props'];
14
+ events(): ReturnType<typeof $$render<T, U, M>>['events'];
15
+ slots(): ReturnType<typeof $$render<T, U, M>>['slots'];
16
+ bindings(): "value";
17
+ exports(): {};
18
+ }
19
+ interface $$IsomorphicComponent {
20
+ new <T extends Record<string, unknown>, U extends FormPath<T>, M>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<T, U, M>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<T, U, M>['props']>, ReturnType<__sveltets_Render<T, U, M>['events']>, ReturnType<__sveltets_Render<T, U, M>['slots']>> & {
21
+ $$bindings?: ReturnType<__sveltets_Render<T, U, M>['bindings']>;
22
+ } & ReturnType<__sveltets_Render<T, U, M>['exports']>;
23
+ <T extends Record<string, unknown>, U extends FormPath<T>, M>(internal: unknown, props: ReturnType<__sveltets_Render<T, U, M>['props']> & {}): ReturnType<__sveltets_Render<T, U, M>['exports']>;
24
+ z_$$bindings?: ReturnType<__sveltets_Render<any, any, any>['bindings']>;
25
+ }
26
+ declare const HexColorField: $$IsomorphicComponent;
27
+ type HexColorField<T extends Record<string, unknown>, U extends FormPath<T>, M> = InstanceType<typeof HexColorField<T, U, M>>;
28
+ export default HexColorField;
@@ -1,5 +1,6 @@
1
1
  import TextField from './form/fields/TextField.svelte';
2
2
  import PasswordField from './form/fields/PasswordField.svelte';
3
+ import HexColorField from './form/fields/HexColorField.svelte';
3
4
  import ChoiceField from './form/fields/ChoiceField.svelte';
4
5
  import ChoiceMultiField from './form/fields/ChoiceMultiField.svelte';
5
6
  import Choice from './ui/choice/Choice.svelte';
@@ -8,4 +9,5 @@ import WeekdayChoice from './ui/choice/WeekdayChoice.svelte';
8
9
  import WeekdayChoiceMulti from './ui/choice/WeekdayChoiceMulti.svelte';
9
10
  import WeekdayChoiceField from './form/fields/WeekdayChoiceField.svelte';
10
11
  import WeekdayChoiceMultiField from './form/fields/WeekdayChoiceMultiField.svelte';
11
- export { TextField, PasswordField, ChoiceMultiField, ChoiceField, WeekdayChoiceField, WeekdayChoiceMultiField, Choice, ChoiceMulti, WeekdayChoice, WeekdayChoiceMulti };
12
+ import Button from './form/Button.svelte';
13
+ export { TextField, PasswordField, HexColorField, ChoiceMultiField, ChoiceField, WeekdayChoiceField, WeekdayChoiceMultiField, Choice, ChoiceMulti, WeekdayChoice, WeekdayChoiceMulti, Button };
@@ -1,5 +1,6 @@
1
1
  import TextField from './form/fields/TextField.svelte';
2
2
  import PasswordField from './form/fields/PasswordField.svelte';
3
+ import HexColorField from './form/fields/HexColorField.svelte';
3
4
  import ChoiceField from './form/fields/ChoiceField.svelte';
4
5
  import ChoiceMultiField from './form/fields/ChoiceMultiField.svelte';
5
6
  import Choice from './ui/choice/Choice.svelte';
@@ -8,4 +9,5 @@ import WeekdayChoice from './ui/choice/WeekdayChoice.svelte';
8
9
  import WeekdayChoiceMulti from './ui/choice/WeekdayChoiceMulti.svelte';
9
10
  import WeekdayChoiceField from './form/fields/WeekdayChoiceField.svelte';
10
11
  import WeekdayChoiceMultiField from './form/fields/WeekdayChoiceMultiField.svelte';
11
- export { TextField, PasswordField, ChoiceMultiField, ChoiceField, WeekdayChoiceField, WeekdayChoiceMultiField, Choice, ChoiceMulti, WeekdayChoice, WeekdayChoiceMulti };
12
+ import Button from './form/Button.svelte';
13
+ export { TextField, PasswordField, HexColorField, ChoiceMultiField, ChoiceField, WeekdayChoiceField, WeekdayChoiceMultiField, Choice, ChoiceMulti, WeekdayChoice, WeekdayChoiceMulti, Button };
@@ -1,4 +1,4 @@
1
- <div class="overflow-hidden rounded-t-xl border bg-white shadow-sm">
1
+ <div class="rounded-t-xl border bg-white shadow-sm">
2
2
  <div class="border-b bg-gray-50 px-4 py-2 text-sm font-medium text-gray-700">Preview</div>
3
3
  <div class="p-6">
4
4
  <slot />
@@ -0,0 +1,83 @@
1
+ <script lang="ts" module>
2
+ import { cn, type WithElementRef } from '../../../utils.js';
3
+ import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
4
+ import { type VariantProps, tv } from 'tailwind-variants';
5
+
6
+ export const buttonVariants = tv({
7
+ base: "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
8
+ variants: {
9
+ variant: {
10
+ default: 'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90',
11
+ destructive:
12
+ 'bg-destructive shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60 text-white',
13
+ outline:
14
+ 'bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50 border',
15
+ secondary: 'bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80',
16
+ ghost: 'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
17
+ link: 'text-primary underline-offset-4 hover:underline'
18
+ },
19
+ size: {
20
+ default: 'h-9 px-4 py-2 has-[>svg]:px-3',
21
+ sm: 'h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5',
22
+ lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',
23
+ icon: 'size-9'
24
+ }
25
+ },
26
+ defaultVariants: {
27
+ variant: 'default',
28
+ size: 'default'
29
+ }
30
+ });
31
+
32
+ export type ButtonVariant = VariantProps<typeof buttonVariants>['variant'];
33
+ export type ButtonSize = VariantProps<typeof buttonVariants>['size'];
34
+
35
+ export type ButtonProps = WithElementRef<HTMLButtonAttributes> &
36
+ WithElementRef<HTMLAnchorAttributes> & {
37
+ variant?: ButtonVariant;
38
+ size?: ButtonSize;
39
+ };
40
+ </script>
41
+
42
+ <script lang="ts">
43
+ let {
44
+ class: className,
45
+ variant = 'default',
46
+ size = 'default',
47
+ ref = $bindable(null),
48
+ href = undefined,
49
+ type = 'button',
50
+ disabled,
51
+ children,
52
+ ...restProps
53
+ }: ButtonProps = $props();
54
+ </script>
55
+
56
+ <!-- eslint-disable svelte/no-navigation-without-resolve -->
57
+
58
+ {#if href}
59
+ <a
60
+ bind:this={ref}
61
+ data-slot="button"
62
+ class={cn(buttonVariants({ variant, size }), className)}
63
+ href={disabled ? undefined : href}
64
+ aria-disabled={disabled}
65
+ role={disabled ? 'link' : undefined}
66
+ tabindex={disabled ? -1 : undefined}
67
+ {...restProps}
68
+ >
69
+ {@render children?.()}
70
+ </a>
71
+ {:else}
72
+ <button
73
+ bind:this={ref}
74
+ data-slot="button"
75
+ class={cn(buttonVariants({ variant, size }), className)}
76
+ {type}
77
+ {disabled}
78
+ {...restProps}
79
+ >
80
+ {@render children?.()}
81
+ </button>
82
+ {/if}
83
+ <!-- eslint-enable svelte/no-navigation-without-resolve -->
@@ -0,0 +1,58 @@
1
+ import { type WithElementRef } from '../../../utils.js';
2
+ import type { HTMLAnchorAttributes, HTMLButtonAttributes } from 'svelte/elements';
3
+ import { type VariantProps } from 'tailwind-variants';
4
+ export declare const buttonVariants: import("tailwind-variants").TVReturnType<{
5
+ variant: {
6
+ default: string;
7
+ destructive: string;
8
+ outline: string;
9
+ secondary: string;
10
+ ghost: string;
11
+ link: string;
12
+ };
13
+ size: {
14
+ default: string;
15
+ sm: string;
16
+ lg: string;
17
+ icon: string;
18
+ };
19
+ }, undefined, "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0", {
20
+ variant: {
21
+ default: string;
22
+ destructive: string;
23
+ outline: string;
24
+ secondary: string;
25
+ ghost: string;
26
+ link: string;
27
+ };
28
+ size: {
29
+ default: string;
30
+ sm: string;
31
+ lg: string;
32
+ icon: string;
33
+ };
34
+ }, undefined, import("tailwind-variants").TVReturnType<{
35
+ variant: {
36
+ default: string;
37
+ destructive: string;
38
+ outline: string;
39
+ secondary: string;
40
+ ghost: string;
41
+ link: string;
42
+ };
43
+ size: {
44
+ default: string;
45
+ sm: string;
46
+ lg: string;
47
+ icon: string;
48
+ };
49
+ }, undefined, "focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-all focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0", unknown, unknown, undefined>>;
50
+ export type ButtonVariant = VariantProps<typeof buttonVariants>['variant'];
51
+ export type ButtonSize = VariantProps<typeof buttonVariants>['size'];
52
+ export type ButtonProps = WithElementRef<HTMLButtonAttributes> & WithElementRef<HTMLAnchorAttributes> & {
53
+ variant?: ButtonVariant;
54
+ size?: ButtonSize;
55
+ };
56
+ declare const Button: import("svelte").Component<ButtonProps, {}, "ref">;
57
+ type Button = ReturnType<typeof Button>;
58
+ export default Button;
@@ -0,0 +1,2 @@
1
+ import Root, { type ButtonProps, type ButtonSize, type ButtonVariant, buttonVariants } from './button.svelte';
2
+ export { Root, type ButtonProps as Props, Root as Button, buttonVariants, type ButtonProps, type ButtonSize, type ButtonVariant };
@@ -0,0 +1,4 @@
1
+ import Root, { buttonVariants } from './button.svelte';
2
+ export { Root,
3
+ //
4
+ Root as Button, buttonVariants };
@@ -1,7 +1,6 @@
1
1
  <script lang="ts">
2
2
  import type { HTMLInputAttributes, HTMLInputTypeAttribute } from 'svelte/elements';
3
3
  import { cn, type WithElementRef } from '../../../utils.js';
4
-
5
4
  type InputType = Exclude<HTMLInputTypeAttribute, 'file'>;
6
5
 
7
6
  type Props = WithElementRef<
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "0.3.3",
6
+ "version": "0.4.0",
7
7
  "license": "MIT",
8
8
  "files": [
9
9
  "dist",
@@ -80,7 +80,8 @@
80
80
  "dependencies": {
81
81
  "formsnap": "^2.0.1",
82
82
  "ramda": "^0.31.3",
83
- "sorted-array-functions": "^1.3.0"
83
+ "sorted-array-functions": "^1.3.0",
84
+ "svelte-awesome-color-picker": "^4.0.2"
84
85
  },
85
86
  "scripts": {
86
87
  "dev": "vite dev",