@finsweet/webflow-apps-utils 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/dist/types/customCode.d.ts +1 -1
- package/dist/ui/components/Loader.svelte +0 -2
- package/dist/ui/components/button/Button.stories.svelte +0 -8
- package/dist/ui/components/button/Button.svelte +68 -76
- package/dist/ui/components/button/index.d.ts +1 -1
- package/dist/ui/components/button/index.js +1 -0
- package/dist/ui/components/controlled-buttons/ControlledButtons.svelte +17 -7
- package/dist/ui/components/copy-text/CopyText.svelte +48 -39
- package/dist/ui/components/divider/Divider.stories.svelte +0 -4
- package/dist/ui/components/input/index.d.ts +1 -1
- package/dist/ui/components/input/index.js +1 -0
- package/dist/ui/components/layout/Layout.svelte +0 -6
- package/dist/ui/components/layout/common/EditModeMessage.svelte +1 -1
- package/dist/ui/components/layout/examples/ExampleLayout.svelte +2 -9
- package/dist/ui/components/layout/examples/Wrapper.svelte +1 -1
- package/dist/ui/components/modal/Example.svelte +0 -7
- package/dist/ui/components/modal/Modal.stories.svelte +0 -2
- package/dist/ui/components/modal/Modal.svelte +1 -1
- package/dist/ui/components/notification/Notification.stories.svelte +0 -8
- package/dist/ui/components/section/Section.stories.svelte +0 -1
- package/dist/ui/components/text/README.md +0 -2
- package/dist/ui/components/text/Text.stories.svelte +0 -6
- package/dist/ui/components/text/Text.svelte +0 -19
- package/dist/ui/components/tooltip/Tooltip.svelte +9 -4
- package/dist/ui/icons/FinsweetLogoOutlineIcon.svelte +17 -0
- package/dist/ui/icons/FinsweetLogoOutlineIcon.svelte.d.ts +26 -0
- package/dist/ui/icons/TriangleDownIconToggle.svelte +0 -1
- package/dist/ui/icons/index.d.ts +2 -1
- package/dist/ui/icons/index.js +2 -1
- package/dist/ui/index.css +1 -1
- package/dist/ui/index.d.ts +4 -0
- package/dist/ui/index.js +4 -0
- package/dist/{providers → ui/providers}/GlobalProvider.stories.js +7 -7
- package/dist/{providers → ui/providers}/GlobalProvider.svelte +1 -1
- package/dist/{providers → ui/providers}/GlobalProviderDemo.svelte +0 -2
- package/dist/{router → ui/router}/Router.stories.js +7 -7
- package/dist/{router → ui/router}/examples/RouterExample.svelte +0 -9
- package/dist/{router → ui/router}/examples/pages/AboutPage.svelte +0 -4
- package/dist/{router → ui/router}/providers/Link.svelte +0 -2
- package/dist/{router → ui/router}/providers/Route.svelte +0 -3
- package/dist/{router → ui/router}/providers/RouterProvider.svelte +1 -1
- package/dist/{router → ui/router}/router.svelte.d.ts +0 -1
- package/dist/{router → ui/router}/router.svelte.js +3 -2
- package/dist/ui/stores/form.d.ts +280 -0
- package/dist/{stores/forms.js → ui/stores/form.js} +310 -2
- package/dist/{stores → ui/stores}/forms/Form.stories.js +5 -5
- package/dist/{stores → ui/stores}/forms/FormDemo.svelte +1 -1
- package/dist/{stores → ui/stores}/index.d.ts +1 -3
- package/dist/{stores → ui/stores}/index.js +1 -3
- package/dist/ui/utils/api/checkIfAppModeIsDesign.d.ts +4 -0
- package/dist/ui/utils/api/checkIfAppModeIsDesign.js +19 -0
- package/dist/ui/utils/api/clipboard/handlePaste.d.ts +15 -0
- package/dist/ui/utils/api/clipboard/handlePaste.js +49 -0
- package/dist/ui/utils/api/clipboard/index.d.ts +1 -0
- package/dist/ui/utils/api/clipboard/index.js +1 -0
- package/dist/ui/utils/api/getAllAssets.d.ts +11 -0
- package/dist/ui/utils/api/getAllAssets.js +20 -0
- package/dist/ui/utils/api/getFinsweetComponentsEnvironment.d.ts +8 -0
- package/dist/ui/utils/api/getFinsweetComponentsEnvironment.js +66 -0
- package/dist/ui/utils/api/index.d.ts +5 -0
- package/dist/ui/utils/api/index.js +5 -0
- package/dist/ui/utils/api/insertWithXSCP.d.ts +4 -0
- package/dist/ui/utils/api/insertWithXSCP.js +12 -0
- package/dist/{utils → ui/utils}/auth/crossWindowLogin.d.ts +1 -1
- package/dist/{utils → ui/utils}/auth/crossWindowLogin.js +1 -1
- package/dist/{utils → ui/utils}/auth/index.d.ts +1 -1
- package/dist/{utils → ui/utils}/auth/index.js +4 -6
- package/dist/{utils → ui/utils}/diff-mapper/DiffMapper.stories.js +2 -2
- package/dist/{utils → ui/utils}/diff-mapper/DiffMapperDemo.svelte +1 -1
- package/dist/{utils → ui/utils}/helpers/goto.js +2 -4
- package/dist/ui/utils/helpers/index.d.ts +1 -0
- package/dist/ui/utils/helpers/index.js +1 -0
- package/dist/ui/utils/index.d.ts +3 -0
- package/dist/ui/utils/index.js +3 -0
- package/dist/utils/custom-code/api.d.ts +1 -1
- package/dist/utils/custom-code/api.js +4 -6
- package/dist/utils/custom-code/configs.d.ts +3 -2
- package/dist/utils/custom-code/configs.js +5 -8
- package/dist/utils/custom-code/index.d.ts +1 -1
- package/dist/utils/custom-code/index.js +1 -1
- package/dist/utils/helpers/index.d.ts +0 -1
- package/dist/utils/helpers/index.js +0 -1
- package/dist/utils/index.d.ts +2 -3
- package/dist/utils/index.js +1 -3
- package/dist/utils/logger/index.d.ts +1 -2
- package/dist/utils/stores/index.d.ts +2 -0
- package/dist/utils/stores/index.js +2 -0
- package/package.json +13 -4
- package/dist/stores/forms.d.ts +0 -147
- /package/dist/{providers → ui/providers}/GlobalProvider.stories.d.ts +0 -0
- /package/dist/{providers → ui/providers}/GlobalProvider.svelte.d.ts +0 -0
- /package/dist/{providers → ui/providers}/GlobalProviderDemo.svelte.d.ts +0 -0
- /package/dist/{providers → ui/providers}/configuratorUtils.d.ts +0 -0
- /package/dist/{providers → ui/providers}/configuratorUtils.js +0 -0
- /package/dist/{providers → ui/providers}/globalContext.svelte.d.ts +0 -0
- /package/dist/{providers → ui/providers}/globalContext.svelte.js +0 -0
- /package/dist/{providers → ui/providers}/index.d.ts +0 -0
- /package/dist/{providers → ui/providers}/index.js +0 -0
- /package/dist/{providers → ui/providers}/types.d.ts +0 -0
- /package/dist/{providers → ui/providers}/types.js +0 -0
- /package/dist/{router → ui/router}/Router.stories.d.ts +0 -0
- /package/dist/{router → ui/router}/examples/RouterExample.svelte.d.ts +0 -0
- /package/dist/{router → ui/router}/examples/index.d.ts +0 -0
- /package/dist/{router → ui/router}/examples/index.js +0 -0
- /package/dist/{router → ui/router}/examples/pages/AboutPage.svelte.d.ts +0 -0
- /package/dist/{router → ui/router}/examples/pages/HomePage.svelte +0 -0
- /package/dist/{router → ui/router}/examples/pages/HomePage.svelte.d.ts +0 -0
- /package/dist/{router → ui/router}/examples/pages/NotFoundPage.svelte +0 -0
- /package/dist/{router → ui/router}/examples/pages/NotFoundPage.svelte.d.ts +0 -0
- /package/dist/{router → ui/router}/hooks.svelte.d.ts +0 -0
- /package/dist/{router → ui/router}/hooks.svelte.js +0 -0
- /package/dist/{router → ui/router}/index.d.ts +0 -0
- /package/dist/{router → ui/router}/index.js +0 -0
- /package/dist/{router → ui/router}/providers/Link.svelte.d.ts +0 -0
- /package/dist/{router → ui/router}/providers/Route.svelte.d.ts +0 -0
- /package/dist/{router → ui/router}/providers/RouterProvider.svelte.d.ts +0 -0
- /package/dist/{router → ui/router}/providers/index.d.ts +0 -0
- /package/dist/{router → ui/router}/providers/index.js +0 -0
- /package/dist/{stores → ui/stores}/breakpoints.d.ts +0 -0
- /package/dist/{stores → ui/stores}/breakpoints.js +0 -0
- /package/dist/{stores → ui/stores}/componentInjectErrors.d.ts +0 -0
- /package/dist/{stores → ui/stores}/componentInjectErrors.js +0 -0
- /package/dist/{stores → ui/stores}/forms/Form.stories.d.ts +0 -0
- /package/dist/{stores → ui/stores}/forms/FormDemo.svelte.d.ts +0 -0
- /package/dist/{stores → ui/stores}/showConfirmActionModal.d.ts +0 -0
- /package/dist/{stores → ui/stores}/showConfirmActionModal.js +0 -0
- /package/dist/{stores → ui/stores}/siteInfo.d.ts +0 -0
- /package/dist/{stores → ui/stores}/siteInfo.js +0 -0
- /package/dist/{utils → ui/utils}/diff-mapper/DiffMapper.stories.d.ts +0 -0
- /package/dist/{utils → ui/utils}/diff-mapper/DiffMapperDemo.svelte.d.ts +0 -0
- /package/dist/{utils → ui/utils}/diff-mapper/deepDiffMapper.d.ts +0 -0
- /package/dist/{utils → ui/utils}/diff-mapper/deepDiffMapper.js +0 -0
- /package/dist/{utils → ui/utils}/diff-mapper/index.d.ts +0 -0
- /package/dist/{utils → ui/utils}/diff-mapper/index.js +0 -0
- /package/dist/{utils → ui/utils}/helpers/goto.d.ts +0 -0
- /package/dist/{stores → utils/stores}/isPreviewMode.d.ts +0 -0
- /package/dist/{stores → utils/stores}/isPreviewMode.js +0 -0
- /package/dist/{stores → utils/stores}/router.d.ts +0 -0
- /package/dist/{stores → utils/stores}/router.js +0 -0
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
<RouterProvider {router}>
|
|
37
37
|
{#snippet children({ router, currentRoute, currentLocation, isNavigating })}
|
|
38
38
|
<div class="app-layout">
|
|
39
|
-
<!-- Navigation -->
|
|
40
39
|
<nav class="navigation">
|
|
41
40
|
<div class="nav-brand">
|
|
42
41
|
<h3>My App</h3>
|
|
@@ -57,7 +56,6 @@
|
|
|
57
56
|
</ul>
|
|
58
57
|
</nav>
|
|
59
58
|
|
|
60
|
-
<!-- Loading indicator -->
|
|
61
59
|
{#if isNavigating}
|
|
62
60
|
<div class="loading-indicator">
|
|
63
61
|
<div class="spinner"></div>
|
|
@@ -65,7 +63,6 @@
|
|
|
65
63
|
</div>
|
|
66
64
|
{/if}
|
|
67
65
|
|
|
68
|
-
<!-- Route information display -->
|
|
69
66
|
<div class="route-info">
|
|
70
67
|
<strong>Current Route:</strong>
|
|
71
68
|
{currentLocation?.pathname || 'None'}<br />
|
|
@@ -77,9 +74,7 @@
|
|
|
77
74
|
{currentLocation?.search || 'None'}
|
|
78
75
|
</div>
|
|
79
76
|
|
|
80
|
-
<!-- Main content area -->
|
|
81
77
|
<main class="main-content">
|
|
82
|
-
<!-- Home Route -->
|
|
83
78
|
<Route path="/">
|
|
84
79
|
{#snippet children({ params, location, router, isActive })}
|
|
85
80
|
{#if isActive}
|
|
@@ -88,7 +83,6 @@
|
|
|
88
83
|
{/snippet}
|
|
89
84
|
</Route>
|
|
90
85
|
|
|
91
|
-
<!-- About Route (with optional section parameter) -->
|
|
92
86
|
<Route path="/about">
|
|
93
87
|
{#snippet children({ params, location, router, isActive })}
|
|
94
88
|
{#if isActive}
|
|
@@ -97,7 +91,6 @@
|
|
|
97
91
|
{/snippet}
|
|
98
92
|
</Route>
|
|
99
93
|
|
|
100
|
-
<!-- About with section parameter -->
|
|
101
94
|
<Route path="/about/:section">
|
|
102
95
|
{#snippet children({ params, location, router, isActive })}
|
|
103
96
|
{#if isActive}
|
|
@@ -106,7 +99,6 @@
|
|
|
106
99
|
{/snippet}
|
|
107
100
|
</Route>
|
|
108
101
|
|
|
109
|
-
<!-- Fallback route (404) -->
|
|
110
102
|
<Route path="*" exact={false}>
|
|
111
103
|
{#snippet children({ params, location, router, isActive })}
|
|
112
104
|
{#if isActive && !router.isActive('/') && !router.isActive('/about')}
|
|
@@ -116,7 +108,6 @@
|
|
|
116
108
|
</Route>
|
|
117
109
|
</main>
|
|
118
110
|
|
|
119
|
-
<!-- Router controls -->
|
|
120
111
|
<div class="router-controls">
|
|
121
112
|
<h4>Router Controls</h4>
|
|
122
113
|
<div class="controls-grid">
|
|
@@ -74,7 +74,6 @@
|
|
|
74
74
|
|
|
75
75
|
<div class="about-page">
|
|
76
76
|
{#if section && currentSection}
|
|
77
|
-
<!-- Section-specific content -->
|
|
78
77
|
<div class="section-header">
|
|
79
78
|
<button class="back-button" onclick={() => router.navigate('/about')}>
|
|
80
79
|
← Back to About
|
|
@@ -158,7 +157,6 @@
|
|
|
158
157
|
{/if}
|
|
159
158
|
</div>
|
|
160
159
|
|
|
161
|
-
<!-- Navigation to other sections -->
|
|
162
160
|
<div class="section-navigation">
|
|
163
161
|
<h3>Explore More</h3>
|
|
164
162
|
<div class="nav-buttons">
|
|
@@ -172,7 +170,6 @@
|
|
|
172
170
|
</div>
|
|
173
171
|
</div>
|
|
174
172
|
{:else}
|
|
175
|
-
<!-- Main about page -->
|
|
176
173
|
<div class="main-about">
|
|
177
174
|
<header class="about-header">
|
|
178
175
|
<h1>About Our Company</h1>
|
|
@@ -232,7 +229,6 @@
|
|
|
232
229
|
</div>
|
|
233
230
|
{/if}
|
|
234
231
|
|
|
235
|
-
<!-- Debug information -->
|
|
236
232
|
<div class="debug-section">
|
|
237
233
|
<h3>Route Debug Information</h3>
|
|
238
234
|
<div class="debug-info">
|
|
@@ -106,7 +106,6 @@
|
|
|
106
106
|
});
|
|
107
107
|
</script>
|
|
108
108
|
|
|
109
|
-
<!-- Render as anchor tag by default -->
|
|
110
109
|
{#if element === 'a'}
|
|
111
110
|
<a
|
|
112
111
|
{href}
|
|
@@ -122,7 +121,6 @@
|
|
|
122
121
|
{/if}
|
|
123
122
|
</a>
|
|
124
123
|
{:else if element === 'button'}
|
|
125
|
-
<!-- Render as button -->
|
|
126
124
|
<button
|
|
127
125
|
type="button"
|
|
128
126
|
class={className}
|
|
@@ -64,14 +64,11 @@
|
|
|
64
64
|
});
|
|
65
65
|
</script>
|
|
66
66
|
|
|
67
|
-
<!-- Render content only if route is active -->
|
|
68
67
|
{#if isActive}
|
|
69
68
|
{#if component}
|
|
70
|
-
<!-- Render provided component with route props -->
|
|
71
69
|
{@const Component = component}
|
|
72
70
|
<Component params={routeParams} location={currentLocation} {router} />
|
|
73
71
|
{:else if children}
|
|
74
|
-
<!-- Render children snippet with route data -->
|
|
75
72
|
{@render children({
|
|
76
73
|
params: routeParams,
|
|
77
74
|
location: currentLocation,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onDestroy, onMount, setContext, type Snippet } from 'svelte';
|
|
3
3
|
|
|
4
|
+
import { LoadingScreen } from '../..';
|
|
4
5
|
import type { RouteConfig, Router } from '../router.svelte';
|
|
5
|
-
import { LoadingScreen } from '../../ui';
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
8
8
|
/** Router instance to use for routing */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { routerStore } from '
|
|
2
|
+
import { routerStore } from '../../utils/stores';
|
|
3
3
|
/**
|
|
4
4
|
* Custom Client-Side Router for Svelte 5
|
|
5
5
|
*/
|
|
@@ -394,4 +394,5 @@ export function createRouter(config) {
|
|
|
394
394
|
export const router = createRouter();
|
|
395
395
|
// Export hooks and utilities
|
|
396
396
|
export * from './hooks.svelte.js';
|
|
397
|
-
|
|
397
|
+
// Providers moved to main package - import from @finsweet/webflow-apps-utils directly
|
|
398
|
+
// export * from './providers/index.js';
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import { derived } from 'svelte/store';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
interface FormState<T> {
|
|
4
|
+
values: T;
|
|
5
|
+
errors: Record<keyof T, string[]>;
|
|
6
|
+
touched: Record<keyof T, boolean>;
|
|
7
|
+
isValid: boolean;
|
|
8
|
+
isDirty: boolean;
|
|
9
|
+
isSubmitting: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Generic Form Manager for any Zod schema with cross-component field support
|
|
13
|
+
*/
|
|
14
|
+
export declare class FormManager<T extends Record<string, unknown>> {
|
|
15
|
+
private schema;
|
|
16
|
+
private _store;
|
|
17
|
+
private initialValues;
|
|
18
|
+
private identifier;
|
|
19
|
+
private fieldRegistrations;
|
|
20
|
+
readonly values: ReturnType<typeof derived<typeof this._store, T>>;
|
|
21
|
+
readonly errors: ReturnType<typeof derived<typeof this._store, Record<keyof T, string[]>>>;
|
|
22
|
+
readonly touched: ReturnType<typeof derived<typeof this._store, Record<keyof T, boolean>>>;
|
|
23
|
+
readonly isValid: ReturnType<typeof derived<typeof this._store, boolean>>;
|
|
24
|
+
readonly isDirty: ReturnType<typeof derived<typeof this._store, boolean>>;
|
|
25
|
+
readonly isSubmitting: ReturnType<typeof derived<typeof this._store, boolean>>;
|
|
26
|
+
constructor(identifier: string, schema: z.ZodType<T>, initialValues: T);
|
|
27
|
+
/**
|
|
28
|
+
* Register a field with the form for cross-component management
|
|
29
|
+
*/
|
|
30
|
+
registerField<K extends keyof T>(fieldName: K, options?: {
|
|
31
|
+
validate?: (value: T[K]) => string | null;
|
|
32
|
+
transform?: (value: unknown) => T[K];
|
|
33
|
+
}): {
|
|
34
|
+
value: import("svelte/store").Readable<T[K]>;
|
|
35
|
+
error: import("svelte/store").Readable<Record<keyof T, string[]>[K]>;
|
|
36
|
+
touched: import("svelte/store").Readable<false | Record<keyof T, boolean>[K]>;
|
|
37
|
+
setValue: (value: T[K]) => void;
|
|
38
|
+
setTouched: () => void;
|
|
39
|
+
validate: () => string[];
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Set the value of a specific field
|
|
43
|
+
*/
|
|
44
|
+
setField<K extends keyof T>(field: K, value: T[K]): void;
|
|
45
|
+
/**
|
|
46
|
+
* Set multiple field values at once
|
|
47
|
+
*/
|
|
48
|
+
setFields(values: Partial<T>): void;
|
|
49
|
+
/**
|
|
50
|
+
* Set a field as touched without changing its value
|
|
51
|
+
*/
|
|
52
|
+
setTouched<K extends keyof T>(field: K): void;
|
|
53
|
+
/**
|
|
54
|
+
* Validate a specific field
|
|
55
|
+
*/
|
|
56
|
+
validateField<K extends keyof T>(field: K): string[];
|
|
57
|
+
/**
|
|
58
|
+
* Reset the form to initial values
|
|
59
|
+
*/
|
|
60
|
+
reset(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Set the form as submitting
|
|
63
|
+
*/
|
|
64
|
+
setSubmitting(isSubmitting: boolean): void;
|
|
65
|
+
/**
|
|
66
|
+
* Update the schema (useful for dynamic forms)
|
|
67
|
+
*/
|
|
68
|
+
updateSchema(newSchema: z.ZodType<T>): void;
|
|
69
|
+
/**
|
|
70
|
+
* Validate the entire form
|
|
71
|
+
*/
|
|
72
|
+
private validate;
|
|
73
|
+
/**
|
|
74
|
+
* Get the current state of the form
|
|
75
|
+
*/
|
|
76
|
+
getState(): FormState<T>;
|
|
77
|
+
/**
|
|
78
|
+
* Destroy the form and clean up resources
|
|
79
|
+
*/
|
|
80
|
+
destroy(): void;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Creates a generic form with Zod validation
|
|
84
|
+
*/
|
|
85
|
+
export declare function createGenericForm<T extends Record<string, unknown>>(identifier: string, schema: z.ZodType<T>, initialValues: T): {
|
|
86
|
+
values: import("svelte/store").Readable<T>;
|
|
87
|
+
errors: import("svelte/store").Readable<Record<keyof T, string[]>>;
|
|
88
|
+
touched: import("svelte/store").Readable<Record<keyof T, boolean>>;
|
|
89
|
+
isValid: import("svelte/store").Readable<boolean>;
|
|
90
|
+
isDirty: import("svelte/store").Readable<boolean>;
|
|
91
|
+
isSubmitting: import("svelte/store").Readable<boolean>;
|
|
92
|
+
setField: <K extends keyof T>(field: K, value: T[K]) => void;
|
|
93
|
+
setFields: (values: Partial<T>) => void;
|
|
94
|
+
setTouched: <K extends keyof T>(field: K) => void;
|
|
95
|
+
reset: () => void;
|
|
96
|
+
setSubmitting: (isSubmitting: boolean) => void;
|
|
97
|
+
updateSchema: (newSchema: z.ZodType<T, z.ZodTypeDef, T>) => void;
|
|
98
|
+
registerField: <K extends keyof T>(fieldName: K, options?: {
|
|
99
|
+
validate?: ((value: T[K]) => string | null) | undefined;
|
|
100
|
+
transform?: ((value: unknown) => T[K]) | undefined;
|
|
101
|
+
} | undefined) => {
|
|
102
|
+
value: import("svelte/store").Readable<T[K]>;
|
|
103
|
+
error: import("svelte/store").Readable<Record<keyof T, string[]>[K]>;
|
|
104
|
+
touched: import("svelte/store").Readable<false | Record<keyof T, boolean>[K]>;
|
|
105
|
+
setValue: (value: T[K]) => void;
|
|
106
|
+
setTouched: () => void;
|
|
107
|
+
validate: () => string[];
|
|
108
|
+
};
|
|
109
|
+
validateField: <K extends keyof T>(field: K) => string[];
|
|
110
|
+
getState: () => FormState<T>;
|
|
111
|
+
destroy: () => void;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Creates a form validation utility with Svelte 5 reactive stores
|
|
115
|
+
* @param identifier - Unique identifier for the form
|
|
116
|
+
* @param options - Configuration options
|
|
117
|
+
*/
|
|
118
|
+
export declare class FormValidator<T extends {
|
|
119
|
+
name: string;
|
|
120
|
+
instance: string;
|
|
121
|
+
class: string;
|
|
122
|
+
}> {
|
|
123
|
+
private schema;
|
|
124
|
+
private _store;
|
|
125
|
+
private instancesSet;
|
|
126
|
+
private initialValues;
|
|
127
|
+
private identifier;
|
|
128
|
+
private currentInstanceToIgnore;
|
|
129
|
+
private classValidationEnabled;
|
|
130
|
+
readonly values: ReturnType<typeof derived<typeof this._store, T>>;
|
|
131
|
+
readonly errors: ReturnType<typeof derived<typeof this._store, Record<keyof T, string[]>>>;
|
|
132
|
+
readonly touched: ReturnType<typeof derived<typeof this._store, Record<keyof T, boolean>>>;
|
|
133
|
+
readonly isValid: ReturnType<typeof derived<typeof this._store, boolean>>;
|
|
134
|
+
readonly isDirty: ReturnType<typeof derived<typeof this._store, boolean>>;
|
|
135
|
+
readonly isSubmitting: ReturnType<typeof derived<typeof this._store, boolean>>;
|
|
136
|
+
/**
|
|
137
|
+
* Generates unique name, instance, and class based on solution name and existing instances
|
|
138
|
+
* @param existingInstances - Array of existing instance names
|
|
139
|
+
* @param solution - The base solution name
|
|
140
|
+
* @returns Object containing name, instance, and class values
|
|
141
|
+
*/
|
|
142
|
+
static generateNames(existingInstances: string[], solution: string, name: string): {
|
|
143
|
+
name: string;
|
|
144
|
+
instance: string;
|
|
145
|
+
class: string;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Cleans up the class name to ensure it's valid
|
|
149
|
+
* @param className - The class name to clean up
|
|
150
|
+
* @returns The cleaned up class name
|
|
151
|
+
*/
|
|
152
|
+
static sanitizeClassName(className: string): string;
|
|
153
|
+
constructor(identifier: string, initialValues: T, options?: {
|
|
154
|
+
existingInstances?: string[];
|
|
155
|
+
});
|
|
156
|
+
/**
|
|
157
|
+
* Set a specific instance to ignore during validation
|
|
158
|
+
* Used in edit mode to prevent the current instance from being flagged as invalid
|
|
159
|
+
*/
|
|
160
|
+
ignoreInstanceValidation(instanceValue: string, existingInstances: string[]): void;
|
|
161
|
+
/**
|
|
162
|
+
* Set the value of a specific field
|
|
163
|
+
*/
|
|
164
|
+
setField<K extends keyof T>(field: K, value: T[K]): void;
|
|
165
|
+
/**
|
|
166
|
+
* Set multiple field values at once
|
|
167
|
+
*/
|
|
168
|
+
setFields(values: Partial<T>): void;
|
|
169
|
+
/**
|
|
170
|
+
* Handle instance field validation with uniqueness check
|
|
171
|
+
*/
|
|
172
|
+
validateWithInstances(existingInstances: string[]): void;
|
|
173
|
+
/**
|
|
174
|
+
* Reset the form to initial values
|
|
175
|
+
*/
|
|
176
|
+
reset(): void;
|
|
177
|
+
/**
|
|
178
|
+
* Enable or disable class name validation
|
|
179
|
+
* @param enabled - Whether to enable class validation
|
|
180
|
+
*/
|
|
181
|
+
enableClassValidation(enabled: boolean): void;
|
|
182
|
+
/**
|
|
183
|
+
* Validate the form values
|
|
184
|
+
*/
|
|
185
|
+
private validate;
|
|
186
|
+
/**
|
|
187
|
+
* Set the form as submitting
|
|
188
|
+
*/
|
|
189
|
+
setSubmitting(isSubmitting: boolean): void;
|
|
190
|
+
/**
|
|
191
|
+
* Get the current state of the form
|
|
192
|
+
*/
|
|
193
|
+
getState(): FormState<T>;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Setup form hook
|
|
197
|
+
*/
|
|
198
|
+
export declare function createForm<T extends {
|
|
199
|
+
name: string;
|
|
200
|
+
instance: string;
|
|
201
|
+
class: string;
|
|
202
|
+
}>(identifier: string, initialValues: T, options?: {
|
|
203
|
+
existingInstances?: string[];
|
|
204
|
+
enableClassValidation?: boolean;
|
|
205
|
+
}): {
|
|
206
|
+
values: import("svelte/store").Readable<T>;
|
|
207
|
+
errors: import("svelte/store").Readable<Record<keyof T, string[]>>;
|
|
208
|
+
touched: import("svelte/store").Readable<Record<keyof T, boolean>>;
|
|
209
|
+
isValid: import("svelte/store").Readable<boolean>;
|
|
210
|
+
isDirty: import("svelte/store").Readable<boolean>;
|
|
211
|
+
isSubmitting: import("svelte/store").Readable<boolean>;
|
|
212
|
+
setField: <K extends keyof T>(field: K, value: T[K]) => void;
|
|
213
|
+
setFields: (values: Partial<T>) => void;
|
|
214
|
+
reset: () => void;
|
|
215
|
+
enableClassValidation: (enabled: boolean) => void;
|
|
216
|
+
ignoreInstanceValidation: (instanceValue: string, existingInstances: string[]) => void;
|
|
217
|
+
setSubmitting: (isSubmitting: boolean) => void;
|
|
218
|
+
validate: () => void;
|
|
219
|
+
getState: () => FormState<T>;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Get a form by its identifier
|
|
223
|
+
*/
|
|
224
|
+
export declare function getFormById(identifier: string): FormValidator<{
|
|
225
|
+
name: string;
|
|
226
|
+
instance: string;
|
|
227
|
+
class: string;
|
|
228
|
+
}> | FormManager<Record<string, unknown>> | undefined;
|
|
229
|
+
/**
|
|
230
|
+
* Check if a form with a specific identifier is valid
|
|
231
|
+
*/
|
|
232
|
+
export declare function isFormValid(identifier: string): boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Get error messages for a specific form
|
|
235
|
+
*/
|
|
236
|
+
export declare function getFormErrors(identifier: string): Record<string, string[]> | null;
|
|
237
|
+
/**
|
|
238
|
+
* Reset a form by its identifier
|
|
239
|
+
*/
|
|
240
|
+
export declare function resetForm(identifier: string): boolean;
|
|
241
|
+
export declare function createFormSubscription(identifier: string): import("svelte/store").Writable<{
|
|
242
|
+
isValid: boolean;
|
|
243
|
+
errors: {};
|
|
244
|
+
values: {};
|
|
245
|
+
}> | {
|
|
246
|
+
subscribe: (this: void, run: import("svelte/store").Subscriber<FormState<{
|
|
247
|
+
name: string;
|
|
248
|
+
instance: string;
|
|
249
|
+
class: string;
|
|
250
|
+
}> | FormState<Record<string, unknown>>>, invalidate?: () => void) => import("svelte/store").Unsubscriber;
|
|
251
|
+
destroy: () => void;
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Helper to get field state for a specific form and field
|
|
255
|
+
*/
|
|
256
|
+
export declare function getFieldState<T extends Record<string, unknown>>(formId: string, fieldName: keyof T): {
|
|
257
|
+
value: undefined;
|
|
258
|
+
error: never[];
|
|
259
|
+
touched: boolean;
|
|
260
|
+
isValid: boolean;
|
|
261
|
+
} | {
|
|
262
|
+
value: T[keyof T];
|
|
263
|
+
error: Record<keyof T, string[]>[keyof T];
|
|
264
|
+
touched: boolean | Record<keyof T, boolean>[keyof T];
|
|
265
|
+
isValid: boolean;
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Helper to update a field value for a specific form
|
|
269
|
+
*/
|
|
270
|
+
export declare function updateFieldValue<T extends Record<string, unknown>>(formId: string, fieldName: keyof T, value: T[typeof fieldName]): void;
|
|
271
|
+
/**
|
|
272
|
+
* Helper to get all registered field names for a form
|
|
273
|
+
*/
|
|
274
|
+
export declare function getFormFieldNames(formId: string): string[];
|
|
275
|
+
/**
|
|
276
|
+
* Store to track if the form is adding or updating to the Canvas
|
|
277
|
+
*/
|
|
278
|
+
export declare const isAddingOrUpdating: import("svelte/store").Writable<boolean>;
|
|
279
|
+
export declare const loadingSelectedElement: import("svelte/store").Writable<boolean>;
|
|
280
|
+
export {};
|