@finsweet/webflow-apps-utils 1.0.2 → 1.0.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 +162 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/providers/GlobalProvider.mdx +322 -0
- package/dist/providers/GlobalProvider.svelte +58 -0
- package/dist/providers/GlobalProvider.svelte.d.ts +4 -0
- package/dist/providers/configuratorUtils.d.ts +37 -0
- package/dist/providers/configuratorUtils.js +219 -0
- package/dist/providers/globalContext.svelte.d.ts +18 -0
- package/dist/providers/globalContext.svelte.js +439 -0
- package/dist/providers/index.d.ts +5 -0
- package/dist/providers/index.js +7 -0
- package/dist/providers/types.d.ts +103 -0
- package/dist/providers/types.js +6 -0
- package/dist/router/Router.mdx +958 -0
- package/dist/router/Router.stories.d.ts +6 -0
- package/dist/router/Router.stories.js +47 -0
- package/dist/router/examples/RouterExample.svelte +271 -0
- package/dist/{ui/components/NoSettingsNeeded.svelte.d.ts → router/examples/RouterExample.svelte.d.ts} +3 -3
- package/dist/router/examples/index.d.ts +4 -0
- package/dist/router/examples/index.js +4 -0
- package/dist/router/examples/pages/AboutPage.svelte +568 -0
- package/dist/router/examples/pages/AboutPage.svelte.d.ts +13 -0
- package/dist/router/examples/pages/HomePage.svelte +200 -0
- package/dist/router/examples/pages/HomePage.svelte.d.ts +14 -0
- package/dist/router/examples/pages/NotFoundPage.svelte +307 -0
- package/dist/router/examples/pages/NotFoundPage.svelte.d.ts +17 -0
- package/dist/router/hooks.svelte.d.ts +2 -2
- package/dist/router/index.d.ts +3 -0
- package/dist/router/index.js +3 -0
- package/dist/router/{Link.svelte → providers/Link.svelte} +1 -1
- package/dist/router/{Route.svelte → providers/Route.svelte} +1 -1
- package/dist/router/{Route.svelte.d.ts → providers/Route.svelte.d.ts} +1 -1
- package/dist/router/{Router.svelte → providers/RouterProvider.svelte} +22 -5
- package/dist/router/{Router.svelte.d.ts → providers/RouterProvider.svelte.d.ts} +8 -4
- package/dist/router/providers/index.d.ts +3 -0
- package/dist/router/providers/index.js +3 -0
- package/dist/router/{index.svelte.d.ts → router.svelte.d.ts} +1 -3
- package/dist/router/{index.svelte.js → router.svelte.js} +1 -4
- package/dist/stores/docs/Form.mdx +542 -0
- package/dist/stores/forms.d.ts +41 -4
- package/dist/stores/forms.js +86 -32
- package/dist/stores/index.d.ts +0 -1
- package/dist/stores/index.js +0 -1
- package/dist/types/customCode.d.ts +1 -1
- package/dist/types/webflow.d.ts +31 -47
- package/dist/types/window.d.ts +1 -0
- package/dist/ui/components/LoadingScreen.svelte +2 -1
- package/dist/ui/components/button/Button.svelte +1 -1
- package/dist/ui/components/button-group/ButtonGroup.stories.js +112 -0
- package/dist/ui/components/{ButtonGroup.svelte → button-group/ButtonGroup.svelte} +20 -33
- package/dist/ui/components/button-group/ButtonGroup.svelte.d.ts +13 -0
- package/dist/ui/components/button-group/index.d.ts +2 -0
- package/dist/ui/components/button-group/index.js +1 -0
- package/dist/ui/components/button-group/types.d.ts +32 -0
- package/dist/ui/components/checkbox/Checkbox.stories.d.ts +55 -0
- package/dist/ui/components/checkbox/Checkbox.stories.js +162 -0
- package/dist/ui/components/checkbox/Checkbox.svelte +141 -0
- package/dist/ui/components/checkbox/Checkbox.svelte.d.ts +4 -0
- package/dist/ui/components/checkbox/index.d.ts +2 -0
- package/dist/ui/components/checkbox/index.js +1 -0
- package/dist/ui/components/checkbox/types.d.ts +32 -0
- package/dist/ui/components/controlled-buttons/ControlledButtons.stories.d.ts +32 -0
- package/dist/ui/components/controlled-buttons/ControlledButtons.stories.js +152 -0
- package/dist/ui/components/{buttons/FooterButton.svelte → controlled-buttons/ControlledButtons.svelte} +18 -67
- package/dist/ui/components/controlled-buttons/ControlledButtons.svelte.d.ts +4 -0
- package/dist/ui/components/controlled-buttons/index.d.ts +2 -0
- package/dist/ui/components/controlled-buttons/index.js +1 -0
- package/dist/ui/components/{buttons → controlled-buttons}/types.d.ts +11 -4
- package/dist/ui/components/copy-text/CopyText.stories.d.ts +70 -0
- package/dist/ui/components/copy-text/CopyText.stories.js +241 -0
- package/dist/ui/components/copy-text/CopyText.svelte +249 -0
- package/dist/ui/components/copy-text/CopyText.svelte.d.ts +4 -0
- package/dist/ui/components/copy-text/index.d.ts +2 -0
- package/dist/ui/components/copy-text/index.js +1 -0
- package/dist/ui/components/copy-text/types.d.ts +52 -0
- package/dist/ui/components/copy-text/types.js +1 -0
- package/dist/ui/components/divider/Divider.stories.svelte +134 -0
- package/dist/ui/components/{clickable/Clickable.stories.svelte.d.ts → divider/Divider.stories.svelte.d.ts} +4 -4
- package/dist/ui/components/divider/Divider.svelte +30 -0
- package/dist/ui/components/divider/Divider.svelte.d.ts +4 -0
- package/dist/ui/components/divider/index.d.ts +2 -0
- package/dist/ui/components/divider/index.js +1 -0
- package/dist/ui/components/divider/types.d.ts +23 -0
- package/dist/ui/components/divider/types.js +1 -0
- package/dist/ui/components/iframe/Iframe.stories.svelte +122 -0
- package/dist/ui/components/{ToggleItem.svelte.d.ts → iframe/Iframe.stories.svelte.d.ts} +7 -8
- package/dist/ui/components/iframe/Iframe.svelte +75 -0
- package/dist/ui/components/iframe/Iframe.svelte.d.ts +4 -0
- package/dist/ui/components/iframe/index.d.ts +2 -0
- package/dist/ui/components/iframe/index.js +1 -0
- package/dist/ui/components/iframe/types.d.ts +38 -0
- package/dist/ui/components/iframe/types.js +1 -0
- package/dist/ui/components/index.d.ts +13 -39
- package/dist/ui/components/index.js +13 -39
- package/dist/ui/components/input/Input.stories.d.ts +33 -0
- package/dist/ui/components/input/Input.stories.js +176 -0
- package/dist/ui/components/input/Input.svelte +358 -81
- package/dist/ui/components/input/types.d.ts +33 -1
- package/dist/ui/components/layout/Layout.stories.svelte +3 -3
- package/dist/ui/components/layout/Layout.svelte +10 -64
- package/dist/ui/components/layout/Layout.svelte.d.ts +2 -2
- package/dist/ui/components/layout/common/EditModeMessage.svelte +24 -12
- package/dist/ui/components/layout/{ExampleLayout.svelte → examples/ExampleLayout.svelte} +56 -39
- package/dist/ui/components/layout/examples/Wrapper.svelte +9 -0
- package/dist/ui/components/{Header.svelte.d.ts → layout/examples/Wrapper.svelte.d.ts} +4 -6
- package/dist/ui/components/layout/examples/index.d.ts +2 -0
- package/dist/ui/components/layout/examples/index.js +2 -0
- package/dist/ui/components/layout/index.d.ts +3 -2
- package/dist/ui/components/layout/index.js +2 -1
- package/dist/ui/components/layout/test-helpers/TestLayoutWithFooter.svelte +20 -0
- package/dist/ui/components/layout/test-helpers/TestLayoutWithFooter.svelte.d.ts +7 -0
- package/dist/ui/components/layout/types.d.ts +1 -10
- package/dist/ui/components/modal/Example.svelte +320 -0
- package/dist/ui/components/modal/Example.svelte.d.ts +3 -0
- package/dist/ui/components/modal/Modal.stories.svelte +18 -0
- package/dist/ui/components/modal/Modal.stories.svelte.d.ts +26 -0
- package/dist/ui/components/modal/Modal.svelte +490 -0
- package/dist/ui/components/modal/Modal.svelte.d.ts +130 -0
- package/dist/ui/components/modal/index.d.ts +2 -0
- package/dist/ui/components/modal/index.js +1 -0
- package/dist/ui/components/modal/types.d.ts +75 -0
- package/dist/ui/components/modal/types.js +1 -0
- package/dist/ui/components/notification/Notification.stories.svelte +239 -0
- package/dist/ui/components/{ToggleList.svelte.d.ts → notification/Notification.stories.svelte.d.ts} +9 -21
- package/dist/ui/components/notification/Notification.svelte +294 -0
- package/dist/ui/components/notification/Notification.svelte.d.ts +67 -0
- package/dist/ui/components/notification/index.d.ts +2 -0
- package/dist/ui/components/notification/index.js +1 -0
- package/dist/ui/components/notification/types.d.ts +68 -0
- package/dist/ui/components/notification/types.js +1 -0
- package/dist/ui/components/section/Section.stories.svelte +263 -0
- package/dist/ui/components/section/Section.stories.svelte.d.ts +27 -0
- package/dist/ui/components/section/Section.svelte +326 -0
- package/dist/ui/components/section/Section.svelte.d.ts +5 -0
- package/dist/ui/components/section/index.d.ts +2 -0
- package/dist/ui/components/section/index.js +1 -0
- package/dist/ui/components/section/types.d.ts +114 -0
- package/dist/ui/components/section/types.js +1 -0
- package/dist/ui/components/{ImageUpload.svelte → shared/ImageUpload.svelte} +3 -3
- package/dist/ui/components/{SelectBodyOrDivBlock.svelte → shared/SelectBodyOrDivBlock.svelte} +1 -1
- package/dist/ui/components/shared/index.d.ts +2 -0
- package/dist/ui/components/shared/index.js +2 -0
- package/dist/ui/components/text/Text.stories.svelte +67 -1
- package/dist/ui/components/text/Text.svelte +209 -8
- package/dist/ui/components/text/types.d.ts +4 -0
- package/dist/ui/index.css +33 -5
- package/dist/utils/animations/factory.d.ts +7 -0
- package/dist/utils/animations/factory.js +101 -0
- package/dist/utils/animations/index.d.ts +7 -0
- package/dist/utils/animations/index.js +62 -0
- package/dist/utils/animations/types.d.ts +39 -0
- package/dist/utils/animations/types.js +1 -0
- package/dist/utils/api/checkIfAppModeIsDesign.d.ts +1 -2
- package/dist/utils/api/checkIfAppModeIsDesign.js +1 -2
- package/dist/utils/api/clipboard/handlePaste.d.ts +6 -37
- package/dist/utils/api/clipboard/handlePaste.js +2 -6
- package/dist/utils/api/getAllAssets.d.ts +1 -2
- package/dist/utils/api/getAllAssets.js +1 -2
- package/dist/utils/api/getFinsweetComponentsEnvironment.d.ts +1 -2
- package/dist/utils/api/getFinsweetComponentsEnvironment.js +3 -6
- package/dist/utils/api/index.d.ts +0 -1
- package/dist/utils/api/index.js +0 -1
- package/dist/utils/api/insertWithXSCP.d.ts +1 -2
- package/dist/utils/api/insertWithXSCP.js +1 -2
- package/dist/utils/auth/crossWindowLogin.d.ts +3 -0
- package/dist/utils/auth/crossWindowLogin.js +3 -0
- package/dist/utils/auth/index.d.ts +9 -25
- package/dist/utils/auth/index.js +9 -25
- package/dist/utils/browser-storage/localStorage.d.ts +4 -12
- package/dist/utils/browser-storage/localStorage.js +4 -12
- package/dist/utils/browser-storage/sessionStorage.d.ts +4 -12
- package/dist/utils/browser-storage/sessionStorage.js +4 -12
- package/dist/utils/custom-code/api.d.ts +3 -7
- package/dist/utils/custom-code/api.js +3 -7
- package/dist/utils/custom-code/configs.d.ts +22 -0
- package/dist/utils/custom-code/configs.js +40 -0
- package/dist/utils/custom-code/index.d.ts +1 -0
- package/dist/utils/custom-code/index.js +1 -0
- package/dist/utils/helpers/capitalizeFirstLetter.d.ts +4 -0
- package/dist/utils/helpers/capitalizeFirstLetter.js +9 -0
- package/dist/utils/helpers/cleanupTooltipMessage.d.ts +1 -2
- package/dist/utils/helpers/cleanupTooltipMessage.js +1 -2
- package/dist/utils/helpers/getTimeNow.d.ts +4 -0
- package/dist/utils/helpers/getTimeNow.js +8 -0
- package/dist/utils/helpers/goto.d.ts +1 -4
- package/dist/utils/helpers/goto.js +2 -7
- package/dist/utils/helpers/index.d.ts +5 -0
- package/dist/utils/helpers/index.js +5 -0
- package/dist/utils/helpers/minifyCode.d.ts +10 -0
- package/dist/utils/helpers/minifyCode.js +73 -0
- package/dist/utils/helpers/noop.d.ts +1 -1
- package/dist/utils/helpers/noop.js +1 -1
- package/dist/utils/helpers/numbers.d.ts +4 -14
- package/dist/utils/helpers/numbers.js +4 -14
- package/dist/utils/helpers/objectsToModuleExports.d.ts +2 -4
- package/dist/utils/helpers/objectsToModuleExports.js +2 -3
- package/dist/utils/helpers/toHumanReadableList.d.ts +4 -0
- package/dist/utils/helpers/toHumanReadableList.js +11 -0
- package/dist/utils/helpers/trimText.d.ts +1 -8
- package/dist/utils/helpers/trimText.js +1 -8
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/logger/index.d.ts +0 -2
- package/dist/utils/logger/index.js +0 -2
- package/dist/utils/webflow-canvas/attributes/getAllWebflowElementAttributes.d.ts +1 -3
- package/dist/utils/webflow-canvas/attributes/getAllWebflowElementAttributes.js +1 -3
- package/dist/utils/webflow-canvas/attributes/getInstanceNamesFromObject.d.ts +1 -5
- package/dist/utils/webflow-canvas/attributes/getInstanceNamesFromObject.js +1 -5
- package/dist/utils/webflow-canvas/attributes/getWebflowElementAttribute.d.ts +1 -4
- package/dist/utils/webflow-canvas/attributes/getWebflowElementAttribute.js +1 -4
- package/dist/utils/webflow-canvas/attributes/getWebflowElementTextContent.d.ts +1 -3
- package/dist/utils/webflow-canvas/attributes/getWebflowElementTextContent.js +1 -3
- package/dist/utils/webflow-canvas/attributes/removeWebflowElementAttribute.d.ts +1 -4
- package/dist/utils/webflow-canvas/attributes/removeWebflowElementAttribute.js +1 -4
- package/dist/utils/webflow-canvas/attributes/setStyles.d.ts +1 -3
- package/dist/utils/webflow-canvas/attributes/setStyles.js +1 -3
- package/dist/utils/webflow-canvas/attributes/setWebflowElementAttribute.d.ts +1 -8
- package/dist/utils/webflow-canvas/attributes/setWebflowElementAttribute.js +1 -13
- package/dist/utils/webflow-canvas/findInstanceElement.d.ts +0 -6
- package/dist/utils/webflow-canvas/findInstanceElement.js +1 -7
- package/dist/utils/webflow-canvas/getAllChildren.d.ts +16 -0
- package/dist/utils/webflow-canvas/getAllChildren.js +65 -0
- package/dist/utils/webflow-canvas/getAllPages.d.ts +3 -10
- package/dist/utils/webflow-canvas/getAllPages.js +3 -10
- package/dist/utils/webflow-canvas/getElementClassList.d.ts +9 -0
- package/dist/utils/webflow-canvas/getElementClassList.js +19 -0
- package/dist/utils/webflow-canvas/getSiteStagingUrl.d.ts +1 -4
- package/dist/utils/webflow-canvas/getSiteStagingUrl.js +1 -4
- package/dist/utils/webflow-canvas/index.d.ts +3 -0
- package/dist/utils/webflow-canvas/index.js +3 -0
- package/package.json +14 -2
- package/dist/router/README.md +0 -397
- package/dist/stores/globalStore.d.ts +0 -10
- package/dist/stores/globalStore.js +0 -10
- package/dist/ui/components/ButtonGroup.svelte.d.ts +0 -28
- package/dist/ui/components/Checkbox.svelte +0 -94
- package/dist/ui/components/Checkbox.svelte.d.ts +0 -36
- package/dist/ui/components/Copy.svelte +0 -329
- package/dist/ui/components/Copy.svelte.d.ts +0 -35
- package/dist/ui/components/CustomModal.svelte +0 -192
- package/dist/ui/components/CustomModal.svelte.d.ts +0 -45
- package/dist/ui/components/DisableInEditMode.svelte +0 -66
- package/dist/ui/components/DisableInEditMode.svelte.d.ts +0 -33
- package/dist/ui/components/Divider.svelte +0 -31
- package/dist/ui/components/Divider.svelte.d.ts +0 -31
- package/dist/ui/components/Header.svelte +0 -30
- package/dist/ui/components/Iframe.svelte +0 -89
- package/dist/ui/components/Iframe.svelte.d.ts +0 -40
- package/dist/ui/components/InjectComponent.svelte +0 -297
- package/dist/ui/components/InjectComponent.svelte.d.ts +0 -27
- package/dist/ui/components/Modal.svelte +0 -139
- package/dist/ui/components/Modal.svelte.d.ts +0 -42
- package/dist/ui/components/Navbar.svelte +0 -132
- package/dist/ui/components/Navbar.svelte.d.ts +0 -29
- package/dist/ui/components/NoSettingsNeeded.svelte +0 -31
- package/dist/ui/components/Notification.svelte +0 -193
- package/dist/ui/components/Notification.svelte.d.ts +0 -64
- package/dist/ui/components/PlusMinusButton.svelte +0 -91
- package/dist/ui/components/PlusMinusButton.svelte.d.ts +0 -22
- package/dist/ui/components/PreviewBar.svelte +0 -40
- package/dist/ui/components/PreviewBar.svelte.d.ts +0 -20
- package/dist/ui/components/ScrollableContent.svelte +0 -18
- package/dist/ui/components/ScrollableContent.svelte.d.ts +0 -31
- package/dist/ui/components/Section.svelte +0 -97
- package/dist/ui/components/Section.svelte.d.ts +0 -50
- package/dist/ui/components/Spacer.svelte +0 -9
- package/dist/ui/components/Spacer.svelte.d.ts +0 -22
- package/dist/ui/components/SpinnerPlusMinus.svelte +0 -75
- package/dist/ui/components/SpinnerPlusMinus.svelte.d.ts +0 -23
- package/dist/ui/components/SpinnerUpDown.svelte +0 -194
- package/dist/ui/components/SpinnerUpDown.svelte.d.ts +0 -31
- package/dist/ui/components/Tabs.svelte +0 -71
- package/dist/ui/components/Tabs.svelte.d.ts +0 -26
- package/dist/ui/components/ToggleItem.svelte +0 -29
- package/dist/ui/components/ToggleList.svelte +0 -57
- package/dist/ui/components/buttons/FooterButton.svelte.d.ts +0 -10
- package/dist/ui/components/buttons/index.d.ts +0 -5
- package/dist/ui/components/buttons/index.js +0 -5
- package/dist/ui/components/clickable/Clickable.stories.svelte +0 -213
- package/dist/ui/components/clickable/Clickable.svelte +0 -93
- package/dist/ui/components/clickable/Clickable.svelte.d.ts +0 -4
- package/dist/ui/components/clickable/index.d.ts +0 -2
- package/dist/ui/components/clickable/index.js +0 -1
- package/dist/ui/components/clickable/types.d.ts +0 -17
- package/dist/utils/api/copyPaste/index.d.ts +0 -18
- /package/dist/router/{Link.svelte.d.ts → providers/Link.svelte.d.ts} +0 -0
- /package/dist/ui/components/{buttons → button-group}/types.js +0 -0
- /package/dist/ui/components/{clickable → checkbox}/types.js +0 -0
- /package/dist/{utils/api/copyPaste/index.js → ui/components/controlled-buttons/types.js} +0 -0
- /package/dist/ui/components/layout/{ExampleLayout.svelte.d.ts → examples/ExampleLayout.svelte.d.ts} +0 -0
- /package/dist/ui/components/{ImageUpload.svelte.d.ts → shared/ImageUpload.svelte.d.ts} +0 -0
- /package/dist/ui/components/{SelectBodyOrDivBlock.svelte.d.ts → shared/SelectBodyOrDivBlock.svelte.d.ts} +0 -0
package/dist/stores/forms.js
CHANGED
|
@@ -6,18 +6,25 @@ const formsRegistry = writable({});
|
|
|
6
6
|
// Validates class name according to HTML class name rules
|
|
7
7
|
const classNameRegex = /^[a-zA-Z0-9_-]+$/;
|
|
8
8
|
/**
|
|
9
|
-
* Creates a form validation utility with
|
|
9
|
+
* Creates a form validation utility with Svelte 5 reactive stores
|
|
10
10
|
* @param identifier - Unique identifier for the form
|
|
11
11
|
* @param options - Configuration options
|
|
12
12
|
*/
|
|
13
13
|
export class FormValidator {
|
|
14
14
|
schema;
|
|
15
|
-
|
|
16
|
-
form;
|
|
15
|
+
_store;
|
|
17
16
|
instancesSet = new Set();
|
|
18
17
|
initialValues;
|
|
19
18
|
identifier;
|
|
20
19
|
currentInstanceToIgnore = null;
|
|
20
|
+
classValidationEnabled = true;
|
|
21
|
+
// Public reactive stores that components can directly use
|
|
22
|
+
values;
|
|
23
|
+
errors;
|
|
24
|
+
touched;
|
|
25
|
+
isValid;
|
|
26
|
+
isDirty;
|
|
27
|
+
isSubmitting;
|
|
21
28
|
/**
|
|
22
29
|
* Generates unique name, instance, and class based on solution name and existing instances
|
|
23
30
|
* @param existingInstances - Array of existing instance names
|
|
@@ -86,8 +93,8 @@ export class FormValidator {
|
|
|
86
93
|
if (options?.existingInstances) {
|
|
87
94
|
options.existingInstances.forEach((instance) => this.instancesSet.add(instance.toLowerCase()));
|
|
88
95
|
}
|
|
89
|
-
// Create the form state store
|
|
90
|
-
this.
|
|
96
|
+
// Create the internal form state store
|
|
97
|
+
this._store = writable({
|
|
91
98
|
values: initialValues,
|
|
92
99
|
errors: {},
|
|
93
100
|
touched: {},
|
|
@@ -96,7 +103,12 @@ export class FormValidator {
|
|
|
96
103
|
isSubmitting: false
|
|
97
104
|
});
|
|
98
105
|
// Create a derived store that's the primary interface to the form
|
|
99
|
-
this.
|
|
106
|
+
this.values = derived(this._store, ($store) => $store.values);
|
|
107
|
+
this.errors = derived(this._store, ($store) => $store.errors);
|
|
108
|
+
this.touched = derived(this._store, ($store) => $store.touched);
|
|
109
|
+
this.isValid = derived(this._store, ($store) => $store.isValid);
|
|
110
|
+
this.isDirty = derived(this._store, ($store) => $store.isDirty);
|
|
111
|
+
this.isSubmitting = derived(this._store, ($store) => $store.isSubmitting);
|
|
100
112
|
// Register this form with the global registry
|
|
101
113
|
formsRegistry.update((registry) => {
|
|
102
114
|
registry[identifier] = this;
|
|
@@ -120,7 +132,7 @@ export class FormValidator {
|
|
|
120
132
|
* Set the value of a specific field
|
|
121
133
|
*/
|
|
122
134
|
setField(field, value) {
|
|
123
|
-
this.
|
|
135
|
+
this._store.update((state) => {
|
|
124
136
|
const newState = {
|
|
125
137
|
...state,
|
|
126
138
|
values: {
|
|
@@ -141,7 +153,7 @@ export class FormValidator {
|
|
|
141
153
|
* Set multiple field values at once
|
|
142
154
|
*/
|
|
143
155
|
setFields(values) {
|
|
144
|
-
this.
|
|
156
|
+
this._store.update((state) => {
|
|
145
157
|
const newTouched = { ...state.touched };
|
|
146
158
|
// Mark all updated fields as touched
|
|
147
159
|
Object.keys(values).forEach((key) => {
|
|
@@ -171,7 +183,7 @@ export class FormValidator {
|
|
|
171
183
|
* Reset the form to initial values
|
|
172
184
|
*/
|
|
173
185
|
reset() {
|
|
174
|
-
this.
|
|
186
|
+
this._store.set({
|
|
175
187
|
values: { ...this.initialValues },
|
|
176
188
|
errors: {},
|
|
177
189
|
touched: {},
|
|
@@ -181,32 +193,46 @@ export class FormValidator {
|
|
|
181
193
|
});
|
|
182
194
|
this.validate();
|
|
183
195
|
}
|
|
196
|
+
/**
|
|
197
|
+
* Enable or disable class name validation
|
|
198
|
+
* @param enabled - Whether to enable class validation
|
|
199
|
+
*/
|
|
200
|
+
enableClassValidation(enabled) {
|
|
201
|
+
this.classValidationEnabled = enabled;
|
|
202
|
+
this.validate();
|
|
203
|
+
}
|
|
184
204
|
/**
|
|
185
205
|
* Validate the form values
|
|
186
206
|
*/
|
|
187
207
|
validate() {
|
|
188
|
-
this.
|
|
189
|
-
// Create a custom schema for validation that includes instance uniqueness
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
+
this._store.update((state) => {
|
|
209
|
+
// Create a custom schema for validation that includes instance uniqueness and conditional class validation
|
|
210
|
+
const nameSchema = z.string().min(1, { message: 'Name is required' });
|
|
211
|
+
const instanceSchema = z
|
|
212
|
+
.string()
|
|
213
|
+
.min(1, { message: 'Instance is required' })
|
|
214
|
+
.refine((value) => {
|
|
215
|
+
// Skip if empty (handled by min(1) above)
|
|
216
|
+
if (!value)
|
|
217
|
+
return true;
|
|
218
|
+
// If we're in edit mode and this is the current instance, skip duplicate validation
|
|
219
|
+
if (this.currentInstanceToIgnore &&
|
|
220
|
+
value.toLowerCase() === this.currentInstanceToIgnore) {
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
// Check for uniqueness against the set of existing instances
|
|
224
|
+
return !this.instancesSet.has(value.toLowerCase());
|
|
225
|
+
}, { message: 'Instance name must be unique' });
|
|
226
|
+
// Conditionally create class validation
|
|
227
|
+
const classSchema = this.classValidationEnabled
|
|
228
|
+
? z.string().min(1, { message: 'Class is required' }).regex(classNameRegex, {
|
|
208
229
|
message: 'Class must contain only letters, numbers, underscores, and hyphens'
|
|
209
230
|
})
|
|
231
|
+
: z.string();
|
|
232
|
+
const currentSchema = z.object({
|
|
233
|
+
name: nameSchema,
|
|
234
|
+
instance: instanceSchema,
|
|
235
|
+
class: classSchema
|
|
210
236
|
});
|
|
211
237
|
// Validate the current values against the schema
|
|
212
238
|
const result = currentSchema.safeParse(state.values);
|
|
@@ -233,18 +259,46 @@ export class FormValidator {
|
|
|
233
259
|
* Set the form as submitting
|
|
234
260
|
*/
|
|
235
261
|
setSubmitting(isSubmitting) {
|
|
236
|
-
this.
|
|
262
|
+
this._store.update((state) => ({
|
|
237
263
|
...state,
|
|
238
264
|
isSubmitting
|
|
239
265
|
}));
|
|
240
266
|
}
|
|
241
267
|
/**
|
|
242
|
-
* Get the current state of the form
|
|
268
|
+
* Get the current state of the form (for legacy compatibility)
|
|
243
269
|
*/
|
|
244
270
|
getState() {
|
|
245
|
-
return get(this.
|
|
271
|
+
return get(this._store);
|
|
246
272
|
}
|
|
247
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* Setup form hook
|
|
276
|
+
*/
|
|
277
|
+
export function createForm(identifier, initialValues, options) {
|
|
278
|
+
const form = new FormValidator(identifier, initialValues, options);
|
|
279
|
+
if (options?.enableClassValidation !== undefined) {
|
|
280
|
+
form.enableClassValidation(options.enableClassValidation);
|
|
281
|
+
}
|
|
282
|
+
return {
|
|
283
|
+
// Reactive stores that components can directly subscribe to
|
|
284
|
+
values: form.values,
|
|
285
|
+
errors: form.errors,
|
|
286
|
+
touched: form.touched,
|
|
287
|
+
isValid: form.isValid,
|
|
288
|
+
isDirty: form.isDirty,
|
|
289
|
+
isSubmitting: form.isSubmitting,
|
|
290
|
+
// Helper methods
|
|
291
|
+
setField: form.setField.bind(form),
|
|
292
|
+
setFields: form.setFields.bind(form),
|
|
293
|
+
reset: form.reset.bind(form),
|
|
294
|
+
enableClassValidation: form.enableClassValidation.bind(form),
|
|
295
|
+
ignoreInstanceValidation: form.ignoreInstanceValidation.bind(form),
|
|
296
|
+
setSubmitting: form.setSubmitting.bind(form),
|
|
297
|
+
// For advanced use cases
|
|
298
|
+
validate: () => form.validateWithInstances(options?.existingInstances || []),
|
|
299
|
+
getState: form.getState.bind(form)
|
|
300
|
+
};
|
|
301
|
+
}
|
|
248
302
|
/**
|
|
249
303
|
* Get a form by its identifier
|
|
250
304
|
*/
|
package/dist/stores/index.d.ts
CHANGED
package/dist/stores/index.js
CHANGED
package/dist/types/webflow.d.ts
CHANGED
|
@@ -75,51 +75,35 @@ export interface Webflow extends Pick<WebflowCallback[], 'push'> {
|
|
|
75
75
|
};
|
|
76
76
|
require: <Key extends WebflowModule>(key: Key) => (Key extends 'commerce' ? WebflowCommerce : Key extends 'lightbox' ? WebflowLightbox : Key extends 'slider' ? WebflowSlider : Key extends 'tabs' ? WebflowTabs : WebflowIx2) | undefined;
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
export type TabsContentElement = HTMLDivElement;
|
|
110
|
-
export type TabPaneElement = HTMLDivElement;
|
|
111
|
-
/**
|
|
112
|
-
* Rich Text Block
|
|
113
|
-
*/
|
|
114
|
-
export type RichTextBlockElement = HTMLDivElement;
|
|
115
|
-
/**
|
|
116
|
-
* Dropdowns
|
|
117
|
-
*/
|
|
118
|
-
export type DropdownElement = HTMLDivElement;
|
|
119
|
-
export type DropdownToggle = HTMLDivElement;
|
|
120
|
-
export type DropdownList = HTMLElement;
|
|
121
|
-
/**
|
|
122
|
-
* The default Webflow Breakpoint names.
|
|
123
|
-
*/
|
|
124
|
-
export type WebflowBreakpoint = 'main' | 'medium' | 'small' | 'tiny';
|
|
78
|
+
export type XSCPMetadata = {
|
|
79
|
+
meta: {
|
|
80
|
+
droppedLinks: number;
|
|
81
|
+
dynBindRemovedCount: number;
|
|
82
|
+
dynListBindRemovedCount: number;
|
|
83
|
+
paginationRemovedCount: number;
|
|
84
|
+
universalBindingsRemovedCount: number;
|
|
85
|
+
unlinkedSymbolCount: number;
|
|
86
|
+
};
|
|
87
|
+
type: string;
|
|
88
|
+
payload: {
|
|
89
|
+
nodes: PastedNodes[];
|
|
90
|
+
assets: object[];
|
|
91
|
+
ix1: object[];
|
|
92
|
+
ix2: object[];
|
|
93
|
+
styles: {
|
|
94
|
+
name: string;
|
|
95
|
+
type: string | 'class';
|
|
96
|
+
}[];
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
type PastedNodes = {
|
|
100
|
+
children: string[];
|
|
101
|
+
classes: string[];
|
|
102
|
+
tag: string;
|
|
103
|
+
type: string;
|
|
104
|
+
_id: string;
|
|
105
|
+
data: {
|
|
106
|
+
xattr: Attr[];
|
|
107
|
+
};
|
|
108
|
+
};
|
|
125
109
|
export {};
|
package/dist/types/window.d.ts
CHANGED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import ButtonGroup from './ButtonGroup.svelte';
|
|
2
|
+
const meta = {
|
|
3
|
+
title: 'Ui/ButtonGroup',
|
|
4
|
+
component: ButtonGroup,
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: 'centered',
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: 'A button group component that allows users to select one option from multiple choices. Provides keyboard navigation and accessibility features.'
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
tags: ['autodocs'],
|
|
14
|
+
argTypes: {
|
|
15
|
+
buttons: {
|
|
16
|
+
control: 'object',
|
|
17
|
+
description: 'Array of button options with name and value properties'
|
|
18
|
+
},
|
|
19
|
+
selected: {
|
|
20
|
+
control: 'text',
|
|
21
|
+
description: 'Currently selected value'
|
|
22
|
+
},
|
|
23
|
+
disabled: {
|
|
24
|
+
control: 'boolean',
|
|
25
|
+
description: 'Whether the entire button group is disabled'
|
|
26
|
+
},
|
|
27
|
+
id: {
|
|
28
|
+
control: 'text',
|
|
29
|
+
description: 'Unique identifier for the button group'
|
|
30
|
+
},
|
|
31
|
+
onselect: {
|
|
32
|
+
action: 'onselect',
|
|
33
|
+
description: 'Event handler called when a button is selected'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
export default meta;
|
|
38
|
+
// Basic stories
|
|
39
|
+
export const Default = {
|
|
40
|
+
args: {
|
|
41
|
+
buttons: [
|
|
42
|
+
{ name: 'Option 1', value: 'option1' },
|
|
43
|
+
{ name: 'Option 2', value: 'option2' }
|
|
44
|
+
],
|
|
45
|
+
selected: 'option1'
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
export const WithoutSelection = {
|
|
49
|
+
args: {
|
|
50
|
+
buttons: [
|
|
51
|
+
{ name: 'Left', value: 'left' },
|
|
52
|
+
{ name: 'Center', value: 'center' },
|
|
53
|
+
{ name: 'Right', value: 'right' }
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
export const Disabled = {
|
|
58
|
+
args: {
|
|
59
|
+
buttons: [
|
|
60
|
+
{ name: 'Edit', value: 'edit' },
|
|
61
|
+
{ name: 'Preview', value: 'preview' },
|
|
62
|
+
{ name: 'Publish', value: 'publish' }
|
|
63
|
+
],
|
|
64
|
+
selected: 'edit',
|
|
65
|
+
disabled: true
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
export const LongLabels = {
|
|
69
|
+
args: {
|
|
70
|
+
buttons: [
|
|
71
|
+
{ name: 'Short', value: 'short' },
|
|
72
|
+
{ name: 'Medium Length', value: 'medium' },
|
|
73
|
+
{ name: 'Very Long Button Label', value: 'long' }
|
|
74
|
+
],
|
|
75
|
+
selected: 'medium'
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export const ManyOptions = {
|
|
79
|
+
args: {
|
|
80
|
+
buttons: [
|
|
81
|
+
{ name: 'XS', value: 'xs' },
|
|
82
|
+
{ name: 'SM', value: 'sm' },
|
|
83
|
+
{ name: 'MD', value: 'md' },
|
|
84
|
+
{ name: 'LG', value: 'lg' },
|
|
85
|
+
{ name: 'XL', value: 'xl' },
|
|
86
|
+
{ name: 'XXL', value: 'xxl' }
|
|
87
|
+
],
|
|
88
|
+
selected: 'md'
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
// Interactive example
|
|
92
|
+
export const Interactive = {
|
|
93
|
+
render: (args) => ({
|
|
94
|
+
Component: ButtonGroup,
|
|
95
|
+
props: {
|
|
96
|
+
...args,
|
|
97
|
+
onselect: (value) => {
|
|
98
|
+
console.log('Selected:', value);
|
|
99
|
+
// Update the selected value to show selection change
|
|
100
|
+
args.selected = value;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}),
|
|
104
|
+
args: {
|
|
105
|
+
buttons: [
|
|
106
|
+
{ name: 'Grid', value: 'grid' },
|
|
107
|
+
{ name: 'List', value: 'list' },
|
|
108
|
+
{ name: 'Card', value: 'card' }
|
|
109
|
+
],
|
|
110
|
+
selected: 'grid'
|
|
111
|
+
}
|
|
112
|
+
};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
interface Props {
|
|
3
|
+
id?: string;
|
|
4
|
+
buttons?: { name: string; value: string }[];
|
|
5
|
+
selected?: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
onselect?: (value: string) => void;
|
|
8
|
+
}
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
select: string;
|
|
11
|
-
}>();
|
|
10
|
+
let { id, buttons = [], selected = $bindable(), disabled = false, onselect }: Props = $props();
|
|
12
11
|
|
|
13
12
|
/**
|
|
14
13
|
* Sets selected value and dispatches the select event.
|
|
@@ -17,7 +16,7 @@
|
|
|
17
16
|
const selectButton = (value: string) => {
|
|
18
17
|
if (disabled) return;
|
|
19
18
|
selected = value;
|
|
20
|
-
|
|
19
|
+
onselect?.(value);
|
|
21
20
|
};
|
|
22
21
|
|
|
23
22
|
/**
|
|
@@ -34,20 +33,15 @@
|
|
|
34
33
|
};
|
|
35
34
|
</script>
|
|
36
35
|
|
|
37
|
-
<div class="
|
|
36
|
+
<div class="btn-group">
|
|
38
37
|
{#each buttons as { name, value }, index (index)}
|
|
39
38
|
<div
|
|
40
39
|
{id}
|
|
41
|
-
class="
|
|
40
|
+
class="btn {selected === value ? 'active' : ''} {disabled ? 'disabled' : ''}"
|
|
42
41
|
role="button"
|
|
43
42
|
tabindex={disabled ? -1 : 0}
|
|
44
|
-
|
|
45
|
-
{
|
|
46
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
47
|
-
//@ts-ignore - svelte v4 types for markdown not supported https://github.com/sveltejs/svelte/issues/4701
|
|
48
|
-
//on:keydown: (event: KeyboardEvent) => handleKeydown(event, value)
|
|
49
|
-
}}
|
|
50
|
-
on:keydown={(event) => handleKeydown(event, value)}
|
|
43
|
+
onclick={() => selectButton(value)}
|
|
44
|
+
onkeydown={(event) => handleKeydown(event, value)}
|
|
51
45
|
aria-disabled={disabled}
|
|
52
46
|
>
|
|
53
47
|
{name}
|
|
@@ -56,7 +50,7 @@
|
|
|
56
50
|
</div>
|
|
57
51
|
|
|
58
52
|
<style>
|
|
59
|
-
.
|
|
53
|
+
.btn-group {
|
|
60
54
|
display: flex;
|
|
61
55
|
background: var(
|
|
62
56
|
--action-action-secondary-background,
|
|
@@ -66,41 +60,34 @@
|
|
|
66
60
|
box-shadow: var(--boxShadows-action-secondary);
|
|
67
61
|
}
|
|
68
62
|
|
|
69
|
-
.
|
|
63
|
+
.btn {
|
|
70
64
|
padding: 4px 8px;
|
|
71
65
|
cursor: pointer;
|
|
72
66
|
background: transparent;
|
|
73
|
-
border-radius:
|
|
74
|
-
transition: background-color 0.2s;
|
|
75
|
-
border-width: 0px;
|
|
67
|
+
border-radius: var(--border-radius);
|
|
76
68
|
margin: 2px 0px;
|
|
77
69
|
color: var(--text1);
|
|
78
70
|
}
|
|
79
71
|
|
|
80
|
-
.
|
|
72
|
+
.btn.disabled {
|
|
81
73
|
opacity: 0.75;
|
|
82
74
|
cursor: not-allowed;
|
|
83
75
|
}
|
|
84
76
|
|
|
85
|
-
.
|
|
77
|
+
.btn-group .btn:first-of-type {
|
|
86
78
|
margin-left: 2px;
|
|
87
79
|
border-top-left-radius: var(--border-radius);
|
|
88
80
|
border-bottom-left-radius: var(--border-radius);
|
|
89
81
|
}
|
|
90
82
|
|
|
91
|
-
.
|
|
83
|
+
.btn-group .btn:last-of-type {
|
|
92
84
|
margin-right: 2px;
|
|
93
85
|
border-top-right-radius: var(--border-radius);
|
|
94
86
|
border-bottom-right-radius: var(--border-radius);
|
|
95
87
|
}
|
|
96
88
|
|
|
97
|
-
.
|
|
98
|
-
background-color: var(--actionSecondaryBackgroundHover);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.button.active {
|
|
89
|
+
.btn.active {
|
|
102
90
|
background: var(--background1);
|
|
103
91
|
color: white;
|
|
104
|
-
border-radius: var(--border-radius);
|
|
105
92
|
}
|
|
106
93
|
</style>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface Props {
|
|
2
|
+
id?: string;
|
|
3
|
+
buttons?: {
|
|
4
|
+
name: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}[];
|
|
7
|
+
selected?: string;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
onselect?: (value: string) => void;
|
|
10
|
+
}
|
|
11
|
+
declare const ButtonGroup: import("svelte").Component<Props, {}, "selected">;
|
|
12
|
+
type ButtonGroup = ReturnType<typeof ButtonGroup>;
|
|
13
|
+
export default ButtonGroup;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ButtonGroup } from './ButtonGroup.svelte';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export interface ButtonGroupOption {
|
|
2
|
+
/**
|
|
3
|
+
* Display name for the button
|
|
4
|
+
*/
|
|
5
|
+
name: string;
|
|
6
|
+
/**
|
|
7
|
+
* Value associated with the button
|
|
8
|
+
*/
|
|
9
|
+
value: string;
|
|
10
|
+
}
|
|
11
|
+
export interface ButtonGroupProps {
|
|
12
|
+
/**
|
|
13
|
+
* Unique identifier for the button group
|
|
14
|
+
*/
|
|
15
|
+
id?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Array of button options
|
|
18
|
+
*/
|
|
19
|
+
buttons?: ButtonGroupOption[];
|
|
20
|
+
/**
|
|
21
|
+
* Currently selected value
|
|
22
|
+
*/
|
|
23
|
+
selected?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the entire button group is disabled
|
|
26
|
+
*/
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Event handler called when a button is selected
|
|
30
|
+
*/
|
|
31
|
+
onselect?: (value: string) => void;
|
|
32
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/sveltekit';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import("svelte").Component<import("./types").CheckboxProps, {}, "">;
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: string;
|
|
7
|
+
docs: {
|
|
8
|
+
description: {
|
|
9
|
+
component: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
tags: string[];
|
|
14
|
+
argTypes: {
|
|
15
|
+
checked: {
|
|
16
|
+
control: string;
|
|
17
|
+
description: string;
|
|
18
|
+
};
|
|
19
|
+
defaultChecked: {
|
|
20
|
+
control: string;
|
|
21
|
+
description: string;
|
|
22
|
+
};
|
|
23
|
+
disabled: {
|
|
24
|
+
control: string;
|
|
25
|
+
description: string;
|
|
26
|
+
};
|
|
27
|
+
variant: {
|
|
28
|
+
control: {
|
|
29
|
+
type: string;
|
|
30
|
+
};
|
|
31
|
+
options: string[];
|
|
32
|
+
description: string;
|
|
33
|
+
};
|
|
34
|
+
onChange: {
|
|
35
|
+
action: string;
|
|
36
|
+
description: string;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
export default meta;
|
|
41
|
+
type Story = StoryObj<typeof meta>;
|
|
42
|
+
export declare const Default: Story;
|
|
43
|
+
export declare const DefaultChecked: Story;
|
|
44
|
+
export declare const Controlled: Story;
|
|
45
|
+
export declare const CheckboxVariant: Story;
|
|
46
|
+
export declare const RadioVariant: Story;
|
|
47
|
+
export declare const Disabled: Story;
|
|
48
|
+
export declare const DisabledChecked: Story;
|
|
49
|
+
export declare const DisabledRadio: Story;
|
|
50
|
+
export declare const Uncontrolled: Story;
|
|
51
|
+
export declare const Interactive: Story;
|
|
52
|
+
export declare const InteractiveRadio: Story;
|
|
53
|
+
export declare const AccessibilityTest: Story;
|
|
54
|
+
export declare const MultipleCheckboxes: Story;
|
|
55
|
+
export declare const FocusStates: Story;
|