svelte-ag 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/dist/lib/api/form.svelte.d.ts +4 -4
  2. package/dist/lib/api/form.svelte.d.ts.map +1 -1
  3. package/dist/lib/api/form.svelte.js +6 -3
  4. package/dist/lib/components/breakpoint-badge/BreakpointBadge.svelte +86 -0
  5. package/dist/lib/components/breakpoint-badge/BreakpointBadge.svelte.d.ts +7 -0
  6. package/dist/lib/components/breakpoint-badge/BreakpointBadge.svelte.d.ts.map +1 -0
  7. package/dist/lib/components/breakpoint-badge/index.d.ts +3 -0
  8. package/dist/lib/components/breakpoint-badge/index.d.ts.map +1 -0
  9. package/dist/lib/components/breakpoint-badge/index.js +2 -0
  10. package/dist/lib/components/carousel/carousel-content.svelte +1 -1
  11. package/dist/lib/components/carousel/carousel-dots.svelte +1 -1
  12. package/dist/lib/components/carousel/carousel-item.svelte +1 -1
  13. package/dist/lib/components/carousel/carousel-next.svelte +1 -1
  14. package/dist/lib/components/carousel/carousel-previous.svelte +1 -1
  15. package/dist/lib/components/carousel/carousel.svelte +1 -1
  16. package/dist/lib/components/dnd/dnd-sortable-context.svelte +1 -1
  17. package/dist/lib/components/dnd/dnd-sortable-context.svelte.d.ts +1 -1
  18. package/dist/lib/components/dnd/dnd-sortable-context.svelte.d.ts.map +1 -1
  19. package/dist/lib/components/dnd/dnd-sortable-item.svelte +1 -1
  20. package/dist/lib/components/dnd/sortable.svelte.d.ts.map +1 -1
  21. package/dist/lib/components/dnd/sortable.svelte.js +15 -4
  22. package/dist/lib/components/dnd/utils.svelte.d.ts +6 -0
  23. package/dist/lib/components/dnd/utils.svelte.d.ts.map +1 -1
  24. package/dist/lib/components/form/form-button.svelte +6 -2
  25. package/dist/lib/components/form/form-button.svelte.d.ts +1 -0
  26. package/dist/lib/components/form/form-button.svelte.d.ts.map +1 -1
  27. package/dist/lib/components/form/form-control.svelte +33 -0
  28. package/dist/lib/components/form/form-control.svelte.d.ts +17 -0
  29. package/dist/lib/components/form/form-control.svelte.d.ts.map +1 -0
  30. package/dist/lib/components/form/form-description.svelte +1 -1
  31. package/dist/lib/components/form/form-field-errors.svelte +2 -1
  32. package/dist/lib/components/form/form-field-errors.svelte.d.ts +6 -1
  33. package/dist/lib/components/form/form-field-errors.svelte.d.ts.map +1 -1
  34. package/dist/lib/components/form/form-field-full.svelte +18 -8
  35. package/dist/lib/components/form/form-field-full.svelte.d.ts +9 -8
  36. package/dist/lib/components/form/form-field-full.svelte.d.ts.map +1 -1
  37. package/dist/lib/components/form/form-field.svelte +12 -2
  38. package/dist/lib/components/form/form-field.svelte.d.ts +5 -2
  39. package/dist/lib/components/form/form-field.svelte.d.ts.map +1 -1
  40. package/dist/lib/components/form/form-label.svelte +2 -1
  41. package/dist/lib/components/form/form-label.svelte.d.ts +1 -1
  42. package/dist/lib/components/form/form-label.svelte.d.ts.map +1 -1
  43. package/dist/lib/components/form/form-message.svelte +31 -0
  44. package/dist/lib/components/form/form-message.svelte.d.ts +8 -0
  45. package/dist/lib/components/form/form-message.svelte.d.ts.map +1 -0
  46. package/dist/lib/components/form/form.svelte +6 -10
  47. package/dist/lib/components/form/form.svelte.d.ts +7 -7
  48. package/dist/lib/components/form/form.svelte.d.ts.map +1 -1
  49. package/dist/lib/components/form/index.d.ts +14 -3
  50. package/dist/lib/components/form/index.d.ts.map +1 -1
  51. package/dist/lib/components/form/index.js +15 -4
  52. package/dist/lib/components/gallery/gallery.svelte +18 -21
  53. package/dist/lib/components/gallery/gallery.svelte.d.ts +5 -1
  54. package/dist/lib/components/gallery/gallery.svelte.d.ts.map +1 -1
  55. package/dist/lib/components/search/combinations/searchPopover.svelte +3 -4
  56. package/dist/lib/components/search/combinations/searchPopover.svelte.d.ts +2 -1
  57. package/dist/lib/components/search/combinations/searchPopover.svelte.d.ts.map +1 -1
  58. package/dist/lib/components/search/components/search-list.svelte +2 -2
  59. package/dist/lib/components/search/components/search.svelte +3 -3
  60. package/dist/lib/components/search/components/search.svelte.d.ts +1 -1
  61. package/dist/lib/components/search/components/search.svelte.d.ts.map +1 -1
  62. package/dist/lib/components/search/search.svelte.d.ts +1 -1
  63. package/dist/lib/components/search/search.svelte.d.ts.map +1 -1
  64. package/dist/lib/components/sidebar/sidebar-content.svelte +1 -1
  65. package/dist/lib/components/sidebar/sidebar-footer.svelte +1 -1
  66. package/dist/lib/components/sidebar/sidebar-group-action.svelte +1 -1
  67. package/dist/lib/components/sidebar/sidebar-group-content.svelte +1 -1
  68. package/dist/lib/components/sidebar/sidebar-group-label.svelte +1 -1
  69. package/dist/lib/components/sidebar/sidebar-group.svelte +1 -1
  70. package/dist/lib/components/sidebar/sidebar-header.svelte +1 -1
  71. package/dist/lib/components/sidebar/sidebar-input.svelte +1 -1
  72. package/dist/lib/components/sidebar/sidebar-inset.svelte +1 -1
  73. package/dist/lib/components/sidebar/sidebar-menu-action.svelte +1 -1
  74. package/dist/lib/components/sidebar/sidebar-menu-badge.svelte +1 -1
  75. package/dist/lib/components/sidebar/sidebar-menu-button.svelte +1 -1
  76. package/dist/lib/components/sidebar/sidebar-menu-item.svelte +1 -1
  77. package/dist/lib/components/sidebar/sidebar-menu-skeleton.svelte +1 -1
  78. package/dist/lib/components/sidebar/sidebar-menu-sub-button.svelte +1 -1
  79. package/dist/lib/components/sidebar/sidebar-menu-sub.svelte +1 -1
  80. package/dist/lib/components/sidebar/sidebar-menu.svelte +1 -1
  81. package/dist/lib/components/sidebar/sidebar-provider.svelte +1 -1
  82. package/dist/lib/components/sidebar/sidebar-rail.svelte +1 -1
  83. package/dist/lib/components/sidebar/sidebar-separator.svelte +1 -1
  84. package/dist/lib/components/sidebar/sidebar-trigger.svelte +3 -4
  85. package/dist/lib/components/sidebar/sidebar-trigger.svelte.d.ts.map +1 -1
  86. package/dist/lib/components/sidebar/sidebar.svelte +1 -1
  87. package/dist/lib/styles/scrollbar.css +11 -0
  88. package/dist/lib/vite/vite-plugin-component-source-collector.d.ts.map +1 -1
  89. package/dist/lib/vite/vite-plugin-component-source-collector.js +29 -15
  90. package/package.json +2 -2
  91. package/src/lib/api/form.svelte.ts +17 -6
  92. package/src/lib/components/breakpoint-badge/BreakpointBadge.svelte +86 -0
  93. package/src/lib/components/breakpoint-badge/index.ts +2 -0
  94. package/src/lib/components/carousel/carousel-content.svelte +1 -1
  95. package/src/lib/components/carousel/carousel-dots.svelte +1 -1
  96. package/src/lib/components/carousel/carousel-item.svelte +1 -1
  97. package/src/lib/components/carousel/carousel-next.svelte +1 -1
  98. package/src/lib/components/carousel/carousel-previous.svelte +1 -1
  99. package/src/lib/components/carousel/carousel.svelte +1 -1
  100. package/src/lib/components/dnd/dnd-sortable-context.svelte +1 -1
  101. package/src/lib/components/dnd/dnd-sortable-item.svelte +1 -1
  102. package/src/lib/components/dnd/sortable.svelte.ts +21 -4
  103. package/src/lib/components/dnd/utils.svelte.ts +4 -4
  104. package/src/lib/components/form/form-button.svelte +6 -2
  105. package/src/lib/components/form/form-control.svelte +33 -0
  106. package/src/lib/components/form/form-description.svelte +1 -1
  107. package/src/lib/components/form/form-field-errors.svelte +2 -1
  108. package/src/lib/components/form/form-field-full.svelte +18 -8
  109. package/src/lib/components/form/form-field.svelte +12 -2
  110. package/src/lib/components/form/form-label.svelte +2 -1
  111. package/src/lib/components/form/form-message.svelte +31 -0
  112. package/src/lib/components/form/form.svelte +6 -10
  113. package/src/lib/components/form/index.ts +15 -2
  114. package/src/lib/components/gallery/gallery.svelte +18 -21
  115. package/src/lib/components/search/combinations/searchPopover.svelte +3 -4
  116. package/src/lib/components/search/components/search-list.svelte +2 -2
  117. package/src/lib/components/search/components/search.svelte +3 -3
  118. package/src/lib/components/search/search.svelte.ts +1 -1
  119. package/src/lib/components/sidebar/sidebar-content.svelte +1 -1
  120. package/src/lib/components/sidebar/sidebar-footer.svelte +1 -1
  121. package/src/lib/components/sidebar/sidebar-group-action.svelte +1 -1
  122. package/src/lib/components/sidebar/sidebar-group-content.svelte +1 -1
  123. package/src/lib/components/sidebar/sidebar-group-label.svelte +1 -1
  124. package/src/lib/components/sidebar/sidebar-group.svelte +1 -1
  125. package/src/lib/components/sidebar/sidebar-header.svelte +1 -1
  126. package/src/lib/components/sidebar/sidebar-input.svelte +1 -1
  127. package/src/lib/components/sidebar/sidebar-inset.svelte +1 -1
  128. package/src/lib/components/sidebar/sidebar-menu-action.svelte +1 -1
  129. package/src/lib/components/sidebar/sidebar-menu-badge.svelte +1 -1
  130. package/src/lib/components/sidebar/sidebar-menu-button.svelte +1 -1
  131. package/src/lib/components/sidebar/sidebar-menu-item.svelte +1 -1
  132. package/src/lib/components/sidebar/sidebar-menu-skeleton.svelte +1 -1
  133. package/src/lib/components/sidebar/sidebar-menu-sub-button.svelte +1 -1
  134. package/src/lib/components/sidebar/sidebar-menu-sub.svelte +1 -1
  135. package/src/lib/components/sidebar/sidebar-menu.svelte +1 -1
  136. package/src/lib/components/sidebar/sidebar-provider.svelte +1 -1
  137. package/src/lib/components/sidebar/sidebar-rail.svelte +1 -1
  138. package/src/lib/components/sidebar/sidebar-separator.svelte +1 -1
  139. package/src/lib/components/sidebar/sidebar-trigger.svelte +3 -4
  140. package/src/lib/components/sidebar/sidebar.svelte +1 -1
  141. package/src/lib/styles/scrollbar.css +11 -0
  142. package/src/lib/vite/vite-plugin-component-source-collector.ts +31 -17
@@ -1,6 +1,5 @@
1
- import { type SuperForm, type SuperValidated } from 'sveltekit-superforms';
2
- import type { ApiRequestFunction, HTTPMethod, ApiEndpoints, ApiInput, ApiSuccessBody, ApiErrorBody } from 'ts-ag';
3
- import type * as v from 'valibot';
1
+ import { superForm, type SuperForm, type SuperValidated } from 'sveltekit-superforms';
2
+ import type { ApiRequestFunction, HTTPMethod, ApiEndpoints, ApiInput, ApiSuccessBody, ApiErrorBody, ApiSchema } from 'ts-ag';
4
3
  type ValidInput<E extends ApiEndpoints, P extends E['path'], M extends E['method']> = NonNullable<ApiInput<E, P, M>>;
5
4
  export type ApiRequestForm<API extends ApiEndpoints> = <Path extends API['path'], Method extends Extract<API, {
6
5
  path: Path;
@@ -12,7 +11,8 @@ export type ApiRequestForm<API extends ApiEndpoints> = <Path extends API['path']
12
11
  onFail?: (form: SuperValidated<ValidInput<API, Path, Method>>, response: ApiErrorBody<API, Path, Method>) => void | Promise<void>;
13
12
  };
14
13
  defaultValue?: Partial<ApiInput<API, Path, Method>>;
14
+ formProps?: Parameters<typeof superForm<ValidInput<API, Path, Method>>>[1];
15
15
  }) => SuperForm<ValidInput<API, Path, Method>>;
16
- export declare function createFormFunction<API extends ApiEndpoints>(schemas: Record<API['path'], Record<HTTPMethod, v.GenericSchema>>, request: ApiRequestFunction<API>): ApiRequestForm<API>;
16
+ export declare function createFormFunction<API extends ApiEndpoints>(schemas: Partial<Record<API['path'], Partial<Record<HTTPMethod, ApiSchema>>>>, request: ApiRequestFunction<API>): ApiRequestForm<API>;
17
17
  export {};
18
18
  //# sourceMappingURL=form.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"form.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/api/form.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6C,KAAK,SAAS,EAAE,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtH,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AAClH,OAAO,KAAK,KAAK,CAAC,MAAM,SAAS,CAAC;AAElC,KAAK,UAAU,CAAC,CAAC,SAAS,YAAY,EAAE,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAErH,MAAM,MAAM,cAAc,CAAC,GAAG,SAAS,YAAY,IAAI,CACrD,IAAI,SAA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C,CAAC;IACpD,SAAS,CAAC,EAAE,UAAU,CAAC,OAAO,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAC5E,KAAK,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;AAE/C,wBAAgB,kBAAkB,CAAC,GAAG,SAAS,YAAY,EACzD,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,EAC7E,OAAO,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAC/B,cAAc,CAAC,GAAG,CAAC,CA4CrB"}
@@ -1,7 +1,7 @@
1
1
  import { superForm, defaults, setError, setMessage } from 'sveltekit-superforms';
2
2
  import { valibot } from 'sveltekit-superforms/adapters';
3
3
  export function createFormFunction(schemas, request) {
4
- return ({ path, method, actions, defaultValue }) => {
4
+ return ({ path, method, actions, defaultValue, formProps }) => {
5
5
  const schema = schemas[path]?.[method];
6
6
  if (schema === undefined)
7
7
  throw new Error('Invalid schema for form');
@@ -20,8 +20,10 @@ export function createFormFunction(schemas, request) {
20
20
  const res = await request(path, method, form.data);
21
21
  if (res.ok === false) {
22
22
  const body = await res.json();
23
+ // TODO set some kind of overall form error if there is no field
23
24
  if (!body.field) {
24
- setError(form, '', body.message);
25
+ setMessage(form, body.message);
26
+ // setError(form, '', body.message);
25
27
  }
26
28
  else {
27
29
  setError(form, body.field.name, body.field.value, { status: res.status });
@@ -37,7 +39,8 @@ export function createFormFunction(schemas, request) {
37
39
  await actions.onSuccess(form, body);
38
40
  }
39
41
  }
40
- }
42
+ },
43
+ ...formProps
41
44
  });
42
45
  };
43
46
  }
@@ -0,0 +1,86 @@
1
+ <script lang="ts" module>
2
+ export type SvelteBreakpointBadgeProps = { dev: boolean };
3
+ </script>
4
+
5
+ <script lang="ts">
6
+ const { dev = true }: SvelteBreakpointBadgeProps = $props();
7
+
8
+ const breakpoints = [
9
+ {
10
+ name: 'default',
11
+ bgClass: 'bg-red-100',
12
+ borderClass: 'border-red-300',
13
+ textClass: 'text-red-600',
14
+ hideClass: 'sm:hidden',
15
+ rounded: 'rounded-md'
16
+ },
17
+ {
18
+ name: 'sm',
19
+ bgClass: 'bg-blue-100',
20
+ borderClass: 'border-blue-300',
21
+ textClass: 'text-blue-600',
22
+ hideClass: 'hidden sm:block md:hidden',
23
+ rounded: 'rounded-md'
24
+ },
25
+ {
26
+ name: 'md',
27
+ bgClass: 'bg-purple-100',
28
+ borderClass: 'border-purple-300',
29
+ textClass: 'text-purple-600',
30
+ hideClass: 'hidden md:block lg:hidden',
31
+ rounded: 'rounded-md'
32
+ },
33
+ {
34
+ name: 'lg',
35
+ bgClass: 'bg-green-100',
36
+ borderClass: 'border-green-300',
37
+ textClass: 'text-green-800',
38
+ hideClass: 'hidden lg:block xl:hidden',
39
+ rounded: 'rounded-md'
40
+ },
41
+ {
42
+ name: 'xl',
43
+ bgClass: 'bg-orange-100',
44
+ borderClass: 'border-orange-300',
45
+ textClass: 'text-orange-600',
46
+ hideClass: 'hidden xl:block 2xl:hidden',
47
+ rounded: 'rounded-md'
48
+ },
49
+ {
50
+ name: '2xl',
51
+ bgClass: 'bg-yellow-100',
52
+ borderClass: 'border-yellow-300',
53
+ textClass: 'text-yellow-600',
54
+ hideClass: 'hidden 2xl:block 3xl:hidden',
55
+ rounded: 'rounded-md'
56
+ },
57
+ {
58
+ name: '3xl',
59
+ bgClass: 'bg-blue-100',
60
+ borderClass: 'border-blue-300',
61
+ textClass: 'text-blue-600',
62
+ hideClass: 'hidden 3xl:block 4xl:hidden',
63
+ rounded: 'rounded-md'
64
+ },
65
+ {
66
+ name: '4xl',
67
+ bgClass: 'bg-red-100',
68
+ borderClass: 'border-red-300',
69
+ textClass: 'text-red-600',
70
+ hideClass: 'hidden 4xl:block 5xl:hidden',
71
+ rounded: 'rounded-md'
72
+ }
73
+ ];
74
+ </script>
75
+
76
+ {#if dev}
77
+ <div class="w-fit">
78
+ {#each breakpoints as bp (bp.name)}
79
+ <div
80
+ class="{bp.rounded} {bp.bgClass} {bp.hideClass} border {bp.borderClass} px-2 text-xs font-bold {bp.textClass}"
81
+ >
82
+ {bp.name}
83
+ </div>
84
+ {/each}
85
+ </div>
86
+ {/if}
@@ -0,0 +1,7 @@
1
+ export type SvelteBreakpointBadgeProps = {
2
+ dev: boolean;
3
+ };
4
+ declare const BreakpointBadge: import("svelte").Component<SvelteBreakpointBadgeProps, {}, "">;
5
+ type BreakpointBadge = ReturnType<typeof BreakpointBadge>;
6
+ export default BreakpointBadge;
7
+ //# sourceMappingURL=BreakpointBadge.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BreakpointBadge.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/breakpoint-badge/BreakpointBadge.svelte.ts"],"names":[],"mappings":"AAGE,MAAM,MAAM,0BAA0B,GAAG;IAAE,GAAG,EAAE,OAAO,CAAA;CAAE,CAAC;AAuF5D,QAAA,MAAM,eAAe,gEAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { default as BreakpointBadge } from './BreakpointBadge.svelte';
2
+ export * from './BreakpointBadge.svelte';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/breakpoint-badge/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,0BAA0B,CAAC;AACtE,cAAc,0BAA0B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as BreakpointBadge } from './BreakpointBadge.svelte';
2
+ export * from './BreakpointBadge.svelte';
@@ -2,7 +2,7 @@
2
2
  import type { WithElementRef } from 'bits-ui';
3
3
  import type { HTMLAttributes } from 'svelte/elements';
4
4
  import { getEmblaContext } from './context.js';
5
- import { cn } from '$shadcn/utils.js';
5
+ import { cn } from '../../utils/utils.js';
6
6
 
7
7
  let {
8
8
  ref = $bindable(null),
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { WithoutChildren } from 'bits-ui';
3
3
  import { getEmblaContext } from './context.js';
4
- import { cn } from '$shadcn/utils.js';
4
+ import { cn } from '../../utils/utils.js';
5
5
  import { Button, type Props } from '$shadcn/button/index.js';
6
6
 
7
7
  let {
@@ -2,7 +2,7 @@
2
2
  import type { WithElementRef } from 'bits-ui';
3
3
  import type { HTMLAttributes } from 'svelte/elements';
4
4
  import { getEmblaContext } from './context.js';
5
- import { cn } from '$shadcn/utils.js';
5
+ import { cn } from '../../utils/utils.js';
6
6
 
7
7
  let {
8
8
  ref = $bindable(null),
@@ -2,7 +2,7 @@
2
2
  import ArrowRight from '@lucide/svelte/icons/arrow-right';
3
3
  import type { WithoutChildren } from 'bits-ui';
4
4
  import { getEmblaContext } from './context.js';
5
- import { cn } from '$shadcn/utils.js';
5
+ import { cn } from '../../utils/utils.js';
6
6
  import { Button, type Props } from '$shadcn/button/index.js';
7
7
  import { tv, type VariantProps } from 'tailwind-variants';
8
8
 
@@ -2,7 +2,7 @@
2
2
  import ArrowLeft from '@lucide/svelte/icons/arrow-left';
3
3
  import type { WithoutChildren } from 'bits-ui';
4
4
  import { getEmblaContext } from './context.js';
5
- import { cn } from '$shadcn/utils.js';
5
+ import { cn } from '../../utils/utils.js';
6
6
  import { Button, type Props } from '$shadcn/button/index.js';
7
7
  import { type VariantProps, tv } from 'tailwind-variants';
8
8
 
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import { type CarouselAPI, type CarouselProps, type EmblaContext, setEmblaContext } from './context.js';
3
- import { cn } from '$shadcn/utils.js';
3
+ import { cn } from '../../utils/utils.js';
4
4
  import emblaCarouselSvelte from 'embla-carousel-svelte';
5
5
 
6
6
  let {
@@ -2,7 +2,7 @@
2
2
  import type { Snippet } from 'svelte';
3
3
 
4
4
  export type SortableContextProps = {
5
- items: string[];
5
+ items: string[] | number[];
6
6
  children: Snippet<[]>;
7
7
  };
8
8
  </script>
@@ -1,6 +1,6 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  export type SortableContextProps = {
3
- items: string[];
3
+ items: string[] | number[];
4
4
  children: Snippet<[]>;
5
5
  };
6
6
  import type { HTMLDivAttributes } from '../../utils/bits.js';
@@ -1 +1 @@
1
- {"version":3,"file":"dnd-sortable-context.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/dnd/dnd-sortable-context.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;CACvB,CAAC;AAQJ,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,KAAK,gBAAgB,GAAI,oBAAoB,GAAG,iBAAiB,GAAG;IAAE,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAA;CAAE,CAAC;AAyBjH,QAAA,MAAM,kBAAkB,sDAAwC,CAAC;AACjE,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,eAAe,kBAAkB,CAAC"}
1
+ {"version":3,"file":"dnd-sortable-context.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/dnd/dnd-sortable-context.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC,MAAM,MAAM,oBAAoB,GAAG;IACjC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;CACvB,CAAC;AAQJ,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEvD,KAAK,gBAAgB,GAAI,oBAAoB,GAAG,iBAAiB,GAAG;IAAE,WAAW,CAAC,EAAE,UAAU,GAAG,YAAY,CAAA;CAAE,CAAC;AAyBjH,QAAA,MAAM,kBAAkB,sDAAwC,CAAC;AACjE,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,eAAe,kBAAkB,CAAC"}
@@ -50,7 +50,7 @@
50
50
 
51
51
  const { attributes, listeners, node, activatorNode, transform, transition, isDragging, isSorting, isOver } =
52
52
  useSortable({
53
- id: () => item.id,
53
+ id: () => ('id' in item ? item.id : item.idx),
54
54
  data: () => ({
55
55
  type: box.with(
56
56
  () => type,
@@ -1 +1 @@
1
- {"version":3,"file":"sortable.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/dnd/sortable.svelte.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAO3E;;GAEG;AACH,iBAAS,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,cAAc,QAKnD;AAED,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,YAAY,QAoC5D;AAED,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,aAAa,QAkC9D;;;;;;AAED,wBAIE"}
1
+ {"version":3,"file":"sortable.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/dnd/sortable.svelte.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAO3E;;GAEG;AACH,iBAAS,WAAW,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,cAAc,QAKnD;AAED,wBAAgB,SAAS,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,YAAY,QAkD5D;AAED,wBAAgB,UAAU,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,aAAa,QAqC9D;;;;;;AAED,wBAIE"}
@@ -20,14 +20,24 @@ export function onDragEnd({ active, over, dnd }) {
20
20
  const activeData = data(active);
21
21
  const overData = data(over);
22
22
  // Add this in as well accepts.includes(activeType)
23
+ // console.log('Acitve/over', $state.snapshot(activeData), $state.snapshot(overData));
24
+ const usesId = 'id' in activeData.item.current;
23
25
  if (activeData.type.current === overData.type.current) {
24
26
  if (dnd.activeParent.id === overData.parent.current.id) {
25
27
  // Same containing list reorder
26
- const oldIndex = dnd.activeParent.children.findIndex((item) => item.id === active.id);
27
- const newIndex = overData.parent.current.children.findIndex((item) => item.id === over.id);
28
- // console.log('Drag end reorder', oldIndex, newIndex);
28
+ const oldIndex = usesId
29
+ ? dnd.activeParent.children.findIndex((item) => item.id === active.id)
30
+ : activeData.item.current.idx;
31
+ const newIndex = usesId
32
+ ? overData.parent.current.children.findIndex((item) => item.id === over.id)
33
+ : overData.item.current.idx;
34
+ console.log('Drag end reorder', oldIndex, newIndex);
29
35
  if (oldIndex !== newIndex)
30
36
  moveIndex(dnd.activeParent.children, oldIndex, newIndex);
37
+ // const arr = $state.snapshot(dnd.activeParent.children);
38
+ // const [item] = arr.splice(oldIndex, 1);
39
+ // arr.splice(newIndex, 0, item);
40
+ // activeData.parent.current.setChildren(arr);
31
41
  }
32
42
  else {
33
43
  // Move between containing lists
@@ -53,8 +63,9 @@ export function onDragOver({ active, over, dnd }) {
53
63
  throw new Error('No active parent found');
54
64
  const activeData = data(active);
55
65
  const overData = data(over);
66
+ const usesId = 'id' in activeData.item.current;
56
67
  // add this accepts.includes(activeType)
57
- if (activeData.item.current.id === overData.item.current.id)
68
+ if (usesId && activeData.item.current.id === overData.item.current.id)
58
69
  return;
59
70
  if (activeData.type.current === overData.type.current) {
60
71
  if (dnd.activeParent.id === overData.parent.current.id) {
@@ -13,20 +13,26 @@ export type DataType = {
13
13
  type: WritableBox<string>;
14
14
  item: WritableBox<{
15
15
  id: string;
16
+ } | {
17
+ idx: number;
16
18
  }>;
17
19
  parent: WritableBox<{
18
20
  id: string;
19
21
  children: any[];
22
+ setChildren: (i: any[]) => void;
20
23
  }>;
21
24
  };
22
25
  export type DataInputType = {
23
26
  type: string;
24
27
  item: {
25
28
  id: string;
29
+ } | {
30
+ idx: number;
26
31
  };
27
32
  parent: {
28
33
  id: string;
29
34
  children: any[];
35
+ setChildren: (i: any[]) => void;
30
36
  };
31
37
  };
32
38
  export declare function data(input: {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/dnd/utils.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAGnD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI;;;;EAK3D;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAKrE;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1B,IAAI,EAAE,WAAW,CAAC;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClC,MAAM,EAAE,WAAW,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,GAAG,EAAE,CAAA;KAAE,CAAC,CAAC;CACtD,CAAC;AAEF,MAAM,MA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AAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,MAAM,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,GAAG,EAAE,CAAC;QAAC,WAAW,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,IAAI,CAAA;KAAE,CAAC;CAC1E,CAAC;AAGF,wBAAgB,IAAI,CAAC,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,GAAG,CAAA;CAAE,GAAG,QAAQ,CAWpD"}
@@ -1,9 +1,13 @@
1
- <script lang="ts">
1
+ <script module lang="ts">
2
2
  import * as Button from '$shadcn/button/index.js';
3
+ export type FormButtonProps = Button.Props;
4
+ </script>
5
+
6
+ <script lang="ts">
3
7
  import { cn, flyAndScale } from '../../utils/utils.js';
4
8
  import { getFormContext } from './form.svelte';
5
9
 
6
- let { ref = $bindable(null), children, class: className, ...restProps }: Button.Props = $props();
10
+ let { ref = $bindable(null), children, class: className, ...restProps }: FormButtonProps = $props();
7
11
 
8
12
  const form = getFormContext();
9
13
  const { submitting, delayed } = form;
@@ -1,4 +1,5 @@
1
1
  import * as Button from '$shadcn/button/index.js';
2
+ export type FormButtonProps = Button.Props;
2
3
  declare const FormButton: import("svelte").Component<Button.Props, {}, "ref">;
3
4
  type FormButton = ReturnType<typeof FormButton>;
4
5
  export default FormButton;
@@ -1 +1 @@
1
- {"version":3,"file":"form-button.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/form/form-button.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,MAAM,MAAM,yBAAyB,CAAC;AA2BlD,QAAA,MAAM,UAAU,qDAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"form-button.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/form/form-button.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,MAAM,MAAM,yBAAyB,CAAC;AAClD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,KAAK,CAAC;AA8B7C,QAAA,MAAM,UAAU,qDAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
@@ -0,0 +1,33 @@
1
+ <script module lang="ts">
2
+ import type { ControlAttrs, ControlProps } from 'formsnap';
3
+ export type FormControlProps = ControlProps;
4
+ </script>
5
+
6
+ <script lang="ts">
7
+ import { Control } from 'formsnap';
8
+ import { getFormContext, type FormContext } from './form.svelte';
9
+ import type { Snippet } from 'svelte';
10
+ import type { Expand } from 'svelte-toolbelt';
11
+
12
+ let {
13
+ children: childrenProp,
14
+ ...restProps
15
+ }: Omit<FormControlProps, 'children'> & {
16
+ children?: Snippet<
17
+ [
18
+ {
19
+ props: Expand<ControlAttrs>;
20
+ formData: FormContext<any, any>['form'];
21
+ }
22
+ ]
23
+ >;
24
+ } = $props();
25
+
26
+ const formData = getFormContext().form;
27
+ </script>
28
+
29
+ <Control {...restProps}>
30
+ {#snippet children({ props })}
31
+ {@render childrenProp?.({ props, formData })}
32
+ {/snippet}
33
+ </Control>
@@ -0,0 +1,17 @@
1
+ import type { ControlAttrs, ControlProps } from 'formsnap';
2
+ export type FormControlProps = ControlProps;
3
+ import { type FormContext } from './form.svelte';
4
+ import type { Snippet } from 'svelte';
5
+ import type { Expand } from 'svelte-toolbelt';
6
+ type $$ComponentProps = Omit<FormControlProps, 'children'> & {
7
+ children?: Snippet<[
8
+ {
9
+ props: Expand<ControlAttrs>;
10
+ formData: FormContext<any, any>['form'];
11
+ }
12
+ ]>;
13
+ };
14
+ declare const FormControl: import("svelte").Component<$$ComponentProps, {}, "">;
15
+ type FormControl = ReturnType<typeof FormControl>;
16
+ export default FormControl;
17
+ //# sourceMappingURL=form-control.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-control.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/form/form-control.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC3D,MAAM,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAI9C,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE7C,KAAK,gBAAgB,GAAI,IAAI,CAAC,gBAAgB,EAAE,UAAU,CAAC,GAAG;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAChB;QACE;YACE,KAAK,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC;YAC5B,QAAQ,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC;SACzC;KACF,CACF,CAAC;CACH,CAAC;AAyBJ,QAAA,MAAM,WAAW,sDAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}
@@ -1,6 +1,6 @@
1
1
  <script lang="ts">
2
2
  import * as FormPrimitive from 'formsnap';
3
- import { cn } from '$shadcn/utils.js';
3
+ import { cn } from '../../utils/utils.js';
4
4
  import type { WithoutChild } from 'svelte-toolbelt';
5
5
 
6
6
  let {
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import * as FormPrimitive from 'formsnap';
3
- import { cn, type WithoutChild } from '$shadcn/utils.js';
3
+ import { cn } from '$shadcn/utils.js';
4
+ import type { WithoutChild } from 'svelte-toolbelt';
4
5
 
5
6
  let {
6
7
  ref = $bindable(null),
@@ -1,4 +1,9 @@
1
- declare const FormFieldErrors: import("svelte").Component<any, {}, "ref">;
1
+ import * as FormPrimitive from 'formsnap';
2
+ import type { WithoutChild } from 'svelte-toolbelt';
3
+ type $$ComponentProps = WithoutChild<FormPrimitive.FieldErrorsProps> & {
4
+ errorClasses?: string | undefined | null;
5
+ };
6
+ declare const FormFieldErrors: import("svelte").Component<$$ComponentProps, {}, "ref">;
2
7
  type FormFieldErrors = ReturnType<typeof FormFieldErrors>;
3
8
  export default FormFieldErrors;
4
9
  //# sourceMappingURL=form-field-errors.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"form-field-errors.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/form/form-field-errors.svelte.ts"],"names":[],"mappings":"AAoCA,QAAA,MAAM,eAAe,4CAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"form-field-errors.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/form/form-field-errors.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,aAAa,MAAM,UAAU,CAAC;AAE1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEnD,KAAK,gBAAgB,GAAI,YAAY,CAAC,aAAa,CAAC,gBAAgB,CAAC,GAAG;IACrE,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;CAC1C,CAAC;AA6BJ,QAAA,MAAM,eAAe,yDAAwC,CAAC;AAC9D,KAAK,eAAe,GAAG,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;AAC1D,eAAe,eAAe,CAAC"}
@@ -1,30 +1,38 @@
1
+ <script module lang="ts">
2
+ export type FormFullFieldProps<T extends Record<string, unknown>, U extends FormPath<T>> = FormFieldProps<T, U> & {
3
+ label: string;
4
+ description?: string;
5
+ inputProps: HTMLInputAttributes;
6
+ } & WithoutChildren<WithElementRef<HTMLAttributes<HTMLDivElement>>>;
7
+ </script>
8
+
1
9
  <script lang="ts" generics="T extends Record<string, unknown>, U extends FormPath<T>">
2
- import Field from './form-field.svelte';
10
+ import Field, { type FormFieldProps } from './form-field.svelte';
3
11
  import Label from './form-label.svelte';
4
12
  import Description from './form-description.svelte';
5
13
  import FieldErrors from './form-field-errors.svelte';
6
14
  import { Input } from '$shadcn/input/index.js';
7
15
  import * as Form from 'formsnap';
8
- import type { FormPath } from 'sveltekit-superforms';
16
+ import { type FormPath } from 'sveltekit-superforms';
17
+ import { get, set } from 'radash';
9
18
  import { type WithElementRef, type WithoutChildren } from 'svelte-toolbelt';
10
19
  import { cn } from '../../utils/index.js';
11
20
  import type { HTMLAttributes, HTMLInputAttributes } from 'svelte/elements';
12
21
  import { mergeProps } from 'svelte-toolbelt';
22
+ import { getFormContext } from './form.svelte';
13
23
 
14
24
  let {
15
25
  ref = $bindable(null),
16
26
  class: className,
17
- form,
27
+ form = getFormContext<T, U>(),
18
28
  name,
19
29
  label,
20
30
  description = '',
21
31
  inputProps,
22
32
  ...restProps
23
- }: Form.FieldProps<T, U> & { label: string; description?: string; inputProps: HTMLInputAttributes } & WithoutChildren<
24
- WithElementRef<HTMLAttributes<HTMLDivElement>>
25
- > = $props();
33
+ }: FormFullFieldProps<T, U> = $props();
26
34
 
27
- const { form: formData } = form;
35
+ const formData = $derived(form.form);
28
36
  </script>
29
37
 
30
38
  <Field {form} {name} class={cn(className)} {...restProps}>
@@ -32,7 +40,9 @@
32
40
  {#snippet children({ props })}
33
41
  {@const inProps = mergeProps({ ...inputProps, ...props }) as typeof props}
34
42
  <Label>{label}</Label>
35
- <Input {...inProps} bind:value={$formData[name]} />
43
+
44
+ <!-- get and set because we need to dynamically index $formData -->
45
+ <Input {...inProps} bind:value={() => get($formData, name), (v) => ($formData = set($formData, name, v))} />
36
46
  {/snippet}
37
47
  </Form.Control>
38
48
 
@@ -1,13 +1,14 @@
1
- import * as Form from 'formsnap';
2
- import type { FormPath } from 'sveltekit-superforms';
3
- import { type WithElementRef } from 'svelte-toolbelt';
1
+ export type FormFullFieldProps<T extends Record<string, unknown>, U extends FormPath<T>> = FormFieldProps<T, U> & {
2
+ label: string;
3
+ description?: string;
4
+ inputProps: HTMLInputAttributes;
5
+ } & WithoutChildren<WithElementRef<HTMLAttributes<HTMLDivElement>>>;
6
+ import { type FormFieldProps } from './form-field.svelte';
7
+ import { type FormPath } from 'sveltekit-superforms';
8
+ import { type WithElementRef, type WithoutChildren } from 'svelte-toolbelt';
4
9
  import type { HTMLAttributes, HTMLInputAttributes } from 'svelte/elements';
5
10
  declare class __sveltets_Render<T extends Record<string, unknown>, U extends FormPath<T>> {
6
- props(): Form.FieldProps<T, U, any> & {
7
- label: string;
8
- description?: string;
9
- inputProps: HTMLInputAttributes;
10
- } & Omit<WithElementRef<HTMLAttributes<HTMLDivElement>>, "children">;
11
+ props(): FormFullFieldProps<T, U>;
11
12
  events(): {};
12
13
  slots(): {};
13
14
  bindings(): "ref";
@@ -1 +1 @@
1
- {"version":3,"file":"form-field-full.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/form/form-field-full.svelte.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,IAAI,MAAM,UAAU,CAAC;AACjC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,KAAK,cAAc,EAAwB,MAAM,iBAAiB,CAAC;AAE5E,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AA+C3E,cAAM,iBAAiB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAC,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC;IAC3E,KAAK;eAlCoD,MAAM;sBAAgB,MAAM;oBAAc,mBAAmB;;IAqCtH,MAAM;IAGN,KAAK;IAGL,QAAQ;IACR,OAAO;CACV;AAED,UAAU,qBAAqB;IAC3B,KAAK,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAC,CAAC,SAAS,QAAQ,C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ps<T extends Record<string, unknown>, U extends FormPath<T>> = Omit<
3
+ FormPrimitive.FieldProps<T, U>,
4
+ 'form'
5
+ > & { form?: FormPrimitive.FieldProps<T, U>['form'] } & WithoutChildren<
6
+ WithElementRef<HTMLAttributes<HTMLDivElement>>
7
+ >;
8
+ </script>
9
+
1
10
  <script lang="ts" generics="T extends Record<string, unknown>, U extends FormPath<T>">
2
11
  import * as FormPrimitive from 'formsnap';
3
12
  import type { FormPath } from 'sveltekit-superforms';
4
13
  import { type WithElementRef, type WithoutChildren } from 'svelte-toolbelt';
5
14
  import { cn } from '../../utils/index.js';
6
15
  import type { HTMLAttributes } from 'svelte/elements';
16
+ import { getFormContext } from './form.svelte';
7
17
 
8
18
  let {
9
19
  ref = $bindable(null),
10
20
  class: className,
11
- form,
21
+ form = getFormContext<T, U>(),
12
22
  name,
13
23
  children: childrenProp,
14
24
  ...restProps
15
- }: FormPrimitive.FieldProps<T, U> & WithoutChildren<WithElementRef<HTMLAttributes<HTMLDivElement>>> = $props();
25
+ }: FormFieldProps<T, U> = $props();
16
26
  </script>
17
27
 
18
28
  <FormPrimitive.Field {form} {name}>
@@ -1,9 +1,12 @@
1
+ export type FormFieldProps<T extends Record<string, unknown>, U extends FormPath<T>> = Omit<FormPrimitive.FieldProps<T, U>, 'form'> & {
2
+ form?: FormPrimitive.FieldProps<T, U>['form'];
3
+ } & WithoutChildren<WithElementRef<HTMLAttributes<HTMLDivElement>>>;
1
4
  import * as FormPrimitive from 'formsnap';
2
5
  import type { FormPath } from 'sveltekit-superforms';
3
- import { type WithElementRef } from 'svelte-toolbelt';
6
+ import { type WithElementRef, type WithoutChildren } from 'svelte-toolbelt';
4
7
  import type { HTMLAttributes } from 'svelte/elements';
5
8
  declare class __sveltets_Render<T extends Record<string, unknown>, U extends FormPath<T>> {
6
- props(): FormPrimitive.FieldProps<T, U, any> & Omit<WithElementRef<HTMLAttributes<HTMLDivElement>>, "children">;
9
+ props(): FormFieldProps<T, U>;
7
10
  events(): {};
8
11
  slots(): {};
9
12
  bindings(): "ref";