@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/router/README.md
DELETED
|
@@ -1,397 +0,0 @@
|
|
|
1
|
-
# Custom Svelte 5 Router
|
|
2
|
-
|
|
3
|
-
A lightweight, type-safe client-side router built specifically for Svelte 5 using runes. Designed to replace svelte-routing with modern reactivity patterns and support for persistent app version hashes.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- 🚀 **Svelte 5 Native**: Built with runes for optimal reactivity
|
|
8
|
-
- 🎯 **Type-Safe**: Full TypeScript support with comprehensive type definitions
|
|
9
|
-
- 📦 **Lightweight**: Minimal bundle size with no external dependencies
|
|
10
|
-
- 🔄 **Reactive**: All router state is reactive using Svelte 5 runes
|
|
11
|
-
- 🛣️ **Parameter Support**: URL parameters like `/users/:id`
|
|
12
|
-
- 🔍 **Query Params**: Built-in query parameter handling
|
|
13
|
-
- 🏠 **App Version Support**: Persistent app version hashes across navigation
|
|
14
|
-
- 📱 **Hash Mode**: Optional hash-based routing
|
|
15
|
-
- 🎣 **Rich Hooks**: Comprehensive set of utility hooks
|
|
16
|
-
- ♿ **Accessible**: Built-in accessibility features for navigation
|
|
17
|
-
|
|
18
|
-
## Installation
|
|
19
|
-
|
|
20
|
-
The router is included in your project. Import from:
|
|
21
|
-
|
|
22
|
-
```typescript
|
|
23
|
-
import { Router, RouterComponent, Route, Link } from './router';
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Quick Start
|
|
27
|
-
|
|
28
|
-
### 1. Create and Configure Router
|
|
29
|
-
|
|
30
|
-
```typescript
|
|
31
|
-
// router.ts
|
|
32
|
-
import { createRouter } from './lib/router';
|
|
33
|
-
|
|
34
|
-
export const appRouter = createRouter({
|
|
35
|
-
autoInit: true
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
// Export the router instance for use throughout the app
|
|
39
|
-
export default appRouter;
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
### 2. Initialize with App Version
|
|
43
|
-
|
|
44
|
-
```typescript
|
|
45
|
-
// In your app initialization
|
|
46
|
-
const awaitRouter = async () => {
|
|
47
|
-
const current = new URL(window.location.href);
|
|
48
|
-
const appVersionID = current.pathname.split('/')[1] || 'dev-mode';
|
|
49
|
-
|
|
50
|
-
// Initialize app version - this persists across all navigation
|
|
51
|
-
appRouter.initAppVersion(`/${appVersionID}`);
|
|
52
|
-
|
|
53
|
-
// Define routes without app version prefix
|
|
54
|
-
appRouter.addRoutes([
|
|
55
|
-
{ path: '/', component: MyComponentsLinks },
|
|
56
|
-
{ path: '/finsweetbuilder', component: BuilderLinks },
|
|
57
|
-
{ path: '/finsweetlibrary', component: LibraryLinks },
|
|
58
|
-
{ path: '/finsweetlibrary-admin', component: LibraryAdminLinks }
|
|
59
|
-
]);
|
|
60
|
-
|
|
61
|
-
// Update your existing router store
|
|
62
|
-
routerStore.set({
|
|
63
|
-
hash: appVersionID,
|
|
64
|
-
url: current
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
### 3. Setup Router in Your App
|
|
70
|
-
|
|
71
|
-
```svelte
|
|
72
|
-
<!-- App.svelte -->
|
|
73
|
-
<script lang="ts">
|
|
74
|
-
import { RouterComponent, Route } from './lib/router';
|
|
75
|
-
import appRouter from './router.ts';
|
|
76
|
-
import { routerStore } from '@finsweet/components-utils';
|
|
77
|
-
|
|
78
|
-
const awaitRouter = async () => {
|
|
79
|
-
const current = new URL(window.location.href);
|
|
80
|
-
const appVersionID = current.pathname.split('/')[1] || 'dev-mode';
|
|
81
|
-
|
|
82
|
-
// Initialize app version - this persists across all navigation
|
|
83
|
-
appRouter.initAppVersion(`/${appVersionID}`);
|
|
84
|
-
|
|
85
|
-
// Update your existing router store
|
|
86
|
-
routerStore.set({
|
|
87
|
-
hash: appVersionID,
|
|
88
|
-
url: current
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
// Update configurator if needed
|
|
92
|
-
configurator.update((state) => ({
|
|
93
|
-
...state,
|
|
94
|
-
pathname: current.pathname,
|
|
95
|
-
appVersionID: appVersionID
|
|
96
|
-
}));
|
|
97
|
-
|
|
98
|
-
await delay(50);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// ... rest of your init logic
|
|
102
|
-
</script>
|
|
103
|
-
|
|
104
|
-
<!-- Replace your existing Router with RouterComponent -->
|
|
105
|
-
<RouterComponent router={appRouter}>
|
|
106
|
-
<!-- Define routes without app version prefix -->
|
|
107
|
-
<Route path="/" component={MyComponentsLinks} />
|
|
108
|
-
<Route path="/finsweetbuilder" component={BuilderLinks} />
|
|
109
|
-
<Route path="/finsweetlibrary" component={LibraryLinks} />
|
|
110
|
-
<Route path="/finsweetlibrary-admin" component={LibraryAdminLinks} />
|
|
111
|
-
|
|
112
|
-
<!-- Dynamic component routes -->
|
|
113
|
-
{#each $finsweetComponentsList as { solution, live, key }}
|
|
114
|
-
{#if live}
|
|
115
|
-
<Route path="/finsweetbuilder/{key}" component={solution} />
|
|
116
|
-
{/if}
|
|
117
|
-
{/each}
|
|
118
|
-
</RouterComponent>
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### 4. Navigate with Links
|
|
122
|
-
|
|
123
|
-
```svelte
|
|
124
|
-
<!-- LeftNavBarLinks.svelte -->
|
|
125
|
-
<script lang="ts">
|
|
126
|
-
import { Link, useAppVersion, useLocation } from '../lib/router';
|
|
127
|
-
|
|
128
|
-
const appVersionPath = useAppVersion();
|
|
129
|
-
const location = useLocation();
|
|
130
|
-
|
|
131
|
-
// Routes are now clean without app version prefix
|
|
132
|
-
const navLinks = [
|
|
133
|
-
{ path: '/', label: 'My Components', icon: ComponentsIcon },
|
|
134
|
-
{ path: '/finsweetbuilder', label: 'Builder', icon: BuilderIcon },
|
|
135
|
-
{ path: '/finsweetlibrary', label: 'Library', icon: FinsweetLibraryIcon }
|
|
136
|
-
];
|
|
137
|
-
</script>
|
|
138
|
-
|
|
139
|
-
<div class="nav-container">
|
|
140
|
-
{#each navLinks as link}
|
|
141
|
-
<Link to={link.path} activeClass="active" class="nav-links parent-link">
|
|
142
|
-
<svelte:component this={link.icon} />
|
|
143
|
-
<Text label={link.label} fontSize="normal" />
|
|
144
|
-
</Link>
|
|
145
|
-
{/each}
|
|
146
|
-
</div>
|
|
147
|
-
|
|
148
|
-
<style>
|
|
149
|
-
.active {
|
|
150
|
-
font-weight: bold;
|
|
151
|
-
color: blue;
|
|
152
|
-
}
|
|
153
|
-
</style>
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
### 5. Use Router Hooks for Navigation
|
|
157
|
-
|
|
158
|
-
```svelte
|
|
159
|
-
<!-- BackNavLink.svelte -->
|
|
160
|
-
<script lang="ts">
|
|
161
|
-
import { useNavigate, useAppVersion } from '../lib/router';
|
|
162
|
-
|
|
163
|
-
export let fsComponent: string;
|
|
164
|
-
|
|
165
|
-
const navigate = useNavigate();
|
|
166
|
-
const appVersionPath = useAppVersion();
|
|
167
|
-
|
|
168
|
-
const goBack = () => {
|
|
169
|
-
// Navigate to builder page - app version is automatically included
|
|
170
|
-
navigate('/finsweetbuilder');
|
|
171
|
-
|
|
172
|
-
// Update your existing store if needed
|
|
173
|
-
const appVersionID = appVersionPath.slice(1); // Remove leading slash
|
|
174
|
-
routerStore.set({
|
|
175
|
-
hash: appVersionID,
|
|
176
|
-
url: new URL(`${appVersionPath}/finsweetbuilder`, window.location.origin)
|
|
177
|
-
});
|
|
178
|
-
};
|
|
179
|
-
</script>
|
|
180
|
-
|
|
181
|
-
<div class="nav-links-wrapper">
|
|
182
|
-
<Clickable on:click={goBack}>
|
|
183
|
-
<!-- ... rest of your template -->
|
|
184
|
-
</Clickable>
|
|
185
|
-
</div>
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
## Core Concepts
|
|
189
|
-
|
|
190
|
-
### App Version Hash Support
|
|
191
|
-
|
|
192
|
-
The router's key feature is maintaining app version hashes across all navigation:
|
|
193
|
-
|
|
194
|
-
```typescript
|
|
195
|
-
// Once initialized, all routes automatically include the app version
|
|
196
|
-
appRouter.initAppVersion('/test-app-hash');
|
|
197
|
-
|
|
198
|
-
// These routes work automatically with app version:
|
|
199
|
-
navigate('/'); // Goes to /test-app-hash/
|
|
200
|
-
navigate('/finsweetbuilder'); // Goes to /test-app-hash/finsweetbuilder
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
### Links with App Version
|
|
204
|
-
|
|
205
|
-
Links automatically include the app version prefix:
|
|
206
|
-
|
|
207
|
-
```svelte
|
|
208
|
-
<!-- These automatically include the app version prefix -->
|
|
209
|
-
<Link to="/">Home</Link>
|
|
210
|
-
<!-- Renders as href="/test-app-hash/" -->
|
|
211
|
-
|
|
212
|
-
<Link to="/finsweetbuilder">Builder</Link>
|
|
213
|
-
<!-- Renders as href="/test-app-hash/finsweetbuilder" -->
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### App Version Utility Hooks
|
|
217
|
-
|
|
218
|
-
```svelte
|
|
219
|
-
<script lang="ts">
|
|
220
|
-
import { useAppVersion, useFullPathname, useLocation } from './router';
|
|
221
|
-
|
|
222
|
-
const appVersionPath = useAppVersion(); // Returns '/test-app-hash'
|
|
223
|
-
const fullPathname = useFullPathname(); // Returns '/test-app-hash/users/123'
|
|
224
|
-
const location = useLocation(); // location.pathname is clean: '/users/123'
|
|
225
|
-
</script>
|
|
226
|
-
|
|
227
|
-
<p>App Version: {appVersionPath}</p>
|
|
228
|
-
<p>Full Path: {fullPathname}</p>
|
|
229
|
-
<p>Clean Path: {location.pathname}</p>
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
### Working with Route Parameters
|
|
233
|
-
|
|
234
|
-
```svelte
|
|
235
|
-
<!-- UserDetail.svelte -->
|
|
236
|
-
<script lang="ts">
|
|
237
|
-
import { useParams, useNavigate, useLocation } from './router';
|
|
238
|
-
|
|
239
|
-
const params = useParams();
|
|
240
|
-
const navigate = useNavigate();
|
|
241
|
-
const location = useLocation();
|
|
242
|
-
|
|
243
|
-
// Reactive access to route parameters
|
|
244
|
-
$: userId = params.id;
|
|
245
|
-
|
|
246
|
-
function goBack() {
|
|
247
|
-
navigate('/users');
|
|
248
|
-
}
|
|
249
|
-
</script>
|
|
250
|
-
|
|
251
|
-
<h1>User {userId}</h1>
|
|
252
|
-
<button onclick={goBack}>Back to Users</button>
|
|
253
|
-
<p>Current path: {location.pathname}</p>
|
|
254
|
-
```
|
|
255
|
-
|
|
256
|
-
### Component Modal Updates
|
|
257
|
-
|
|
258
|
-
```svelte
|
|
259
|
-
<!-- NewComponent.svelte -->
|
|
260
|
-
<script lang="ts">
|
|
261
|
-
import { useNavigate } from '../lib/router';
|
|
262
|
-
|
|
263
|
-
const navigate = useNavigate();
|
|
264
|
-
|
|
265
|
-
const handleBuilderClick = () => {
|
|
266
|
-
// Navigate to builder - app version automatically included
|
|
267
|
-
navigate('/finsweetbuilder');
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
const handleLibraryClick = () => {
|
|
271
|
-
// Navigate to library - app version automatically included
|
|
272
|
-
navigate('/finsweetlibrary');
|
|
273
|
-
};
|
|
274
|
-
</script>
|
|
275
|
-
|
|
276
|
-
<!-- Navigation calls with new navigate function -->
|
|
277
|
-
<WebflowTooltip>
|
|
278
|
-
<div slot="tooltip">
|
|
279
|
-
<Section clickable on:click={handleBuilderClick}>
|
|
280
|
-
<!-- Builder option -->
|
|
281
|
-
</Section>
|
|
282
|
-
<Section clickable on:click={handleLibraryClick}>
|
|
283
|
-
<!-- Library option -->
|
|
284
|
-
</Section>
|
|
285
|
-
</div>
|
|
286
|
-
</WebflowTooltip>
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
## API Reference
|
|
290
|
-
|
|
291
|
-
### Router Class
|
|
292
|
-
|
|
293
|
-
```typescript
|
|
294
|
-
const router = createRouter({
|
|
295
|
-
basePath: '/app', // Optional base path
|
|
296
|
-
hashMode: false, // Use hash-based routing
|
|
297
|
-
fallbackRoute: '/404', // Fallback for unmatched routes
|
|
298
|
-
autoInit: true // Auto-initialize in browser
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
// Methods
|
|
302
|
-
router.navigate('/path', { replace: false, state: {} });
|
|
303
|
-
router.addRoute({ path: '/users/:id', component: UserComponent });
|
|
304
|
-
router.addRoutes([...routes]);
|
|
305
|
-
router.initAppVersion('/app-version'); // Set persistent app version
|
|
306
|
-
router.isActive('/path', (exact = false));
|
|
307
|
-
router.getParams();
|
|
308
|
-
router.getQuery();
|
|
309
|
-
router.back();
|
|
310
|
-
router.forward();
|
|
311
|
-
```
|
|
312
|
-
|
|
313
|
-
### Hooks
|
|
314
|
-
|
|
315
|
-
```typescript
|
|
316
|
-
// Get router instance
|
|
317
|
-
const router = useRouter();
|
|
318
|
-
|
|
319
|
-
// Reactive location information
|
|
320
|
-
const location = useLocation();
|
|
321
|
-
|
|
322
|
-
// Current route information
|
|
323
|
-
const route = useRoute();
|
|
324
|
-
|
|
325
|
-
// Route parameters
|
|
326
|
-
const params = useParams();
|
|
327
|
-
|
|
328
|
-
// Query parameters
|
|
329
|
-
const query = useQuery();
|
|
330
|
-
|
|
331
|
-
// Navigation function
|
|
332
|
-
const navigate = useNavigate();
|
|
333
|
-
|
|
334
|
-
// Check if path is active
|
|
335
|
-
const isActive = useIsActiveRoute();
|
|
336
|
-
|
|
337
|
-
// App version utilities
|
|
338
|
-
const appVersionPath = useAppVersion();
|
|
339
|
-
const fullPathname = useFullPathname();
|
|
340
|
-
|
|
341
|
-
// Navigation state
|
|
342
|
-
const isNavigating = useNavigating();
|
|
343
|
-
|
|
344
|
-
// History tracking
|
|
345
|
-
const history = useHistory();
|
|
346
|
-
|
|
347
|
-
// Search params helper
|
|
348
|
-
const search = useSearchParams();
|
|
349
|
-
search.set('page', '2');
|
|
350
|
-
search.get('page');
|
|
351
|
-
search.delete('page');
|
|
352
|
-
```
|
|
353
|
-
|
|
354
|
-
### Components
|
|
355
|
-
|
|
356
|
-
#### RouterComponent
|
|
357
|
-
|
|
358
|
-
```svelte
|
|
359
|
-
<RouterComponent {router} autoInit={true}>
|
|
360
|
-
<!-- Route components go here -->
|
|
361
|
-
</RouterComponent>
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
#### Route
|
|
365
|
-
|
|
366
|
-
```svelte
|
|
367
|
-
<Route path="/users/:id" component={UserComponent} exact={true} meta={{ requiresAuth: true }} />
|
|
368
|
-
|
|
369
|
-
<!-- Or with slot content -->
|
|
370
|
-
<Route path="/about">
|
|
371
|
-
<AboutPage />
|
|
372
|
-
</Route>
|
|
373
|
-
```
|
|
374
|
-
|
|
375
|
-
#### Link
|
|
376
|
-
|
|
377
|
-
```svelte
|
|
378
|
-
<Link
|
|
379
|
-
to="/users/123"
|
|
380
|
-
activeClass="active"
|
|
381
|
-
exact={false}
|
|
382
|
-
replace={false}
|
|
383
|
-
disabled={false}
|
|
384
|
-
element="a">View User</Link
|
|
385
|
-
>
|
|
386
|
-
```
|
|
387
|
-
|
|
388
|
-
## Key Benefits
|
|
389
|
-
|
|
390
|
-
1. **Persistent App Version**: Once `initAppVersion` is called, the app version hash persists across all navigation
|
|
391
|
-
2. **Clean Route Definitions**: Define routes without app version prefixes (`/finsweetbuilder` instead of `/{appVersionID}/finsweetbuilder`)
|
|
392
|
-
3. **Automatic URL Generation**: Links and navigation automatically include the app version prefix
|
|
393
|
-
4. **Backward Compatibility**: Works with your existing `routerStore` and other components
|
|
394
|
-
5. **Type Safety**: Full TypeScript support with proper typing
|
|
395
|
-
6. **Modern Reactivity**: Built on Svelte 5 runes for optimal performance
|
|
396
|
-
|
|
397
|
-
The router handles all the app version complexity automatically while maintaining compatibility with your existing application structure and providing a modern, type-safe routing solution for Svelte 5.
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export type GlobalStoreState = {
|
|
2
|
-
componentKey: string | null;
|
|
3
|
-
editMode: boolean;
|
|
4
|
-
state: Record<string, any> | null;
|
|
5
|
-
repairMode: boolean;
|
|
6
|
-
formKey: string | null;
|
|
7
|
-
formUpdateKey: string | null;
|
|
8
|
-
title: string | null;
|
|
9
|
-
};
|
|
10
|
-
export declare const globalStore: import("svelte/store").Writable<GlobalStoreState>;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
-
$$bindings?: Bindings;
|
|
4
|
-
} & Exports;
|
|
5
|
-
(internal: unknown, props: Props & {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const ButtonGroup: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
-
id: string;
|
|
16
|
-
buttons?: {
|
|
17
|
-
name: string;
|
|
18
|
-
value: string;
|
|
19
|
-
}[];
|
|
20
|
-
selected: string;
|
|
21
|
-
disabled?: boolean;
|
|
22
|
-
}, {
|
|
23
|
-
select: CustomEvent<string>;
|
|
24
|
-
} & {
|
|
25
|
-
[evt: string]: CustomEvent<any>;
|
|
26
|
-
}, {}, {}, string>;
|
|
27
|
-
type ButtonGroup = InstanceType<typeof ButtonGroup>;
|
|
28
|
-
export default ButtonGroup;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { createEventDispatcher } from 'svelte';
|
|
3
|
-
|
|
4
|
-
import { SquareCheckIcon } from '../icons';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* This is the value of the checkbox.
|
|
8
|
-
*/
|
|
9
|
-
export let value: boolean = false;
|
|
10
|
-
/**
|
|
11
|
-
* This means the checkbox is disabled.
|
|
12
|
-
*/
|
|
13
|
-
export let disabled: boolean = false;
|
|
14
|
-
/**
|
|
15
|
-
* This means you are using an external state to control the checkbox.
|
|
16
|
-
*/
|
|
17
|
-
export let preventChange: boolean = false;
|
|
18
|
-
/**
|
|
19
|
-
* This is the id of the checkbox.
|
|
20
|
-
*/
|
|
21
|
-
export let id: string = '';
|
|
22
|
-
/**
|
|
23
|
-
* This is the type of the checkbox. Defaults to `checkbox`.
|
|
24
|
-
*/
|
|
25
|
-
export let type: 'checkbox' | 'radio' = 'checkbox';
|
|
26
|
-
|
|
27
|
-
let checked: boolean = false;
|
|
28
|
-
const dispatch = createEventDispatcher<{
|
|
29
|
-
change: boolean;
|
|
30
|
-
}>();
|
|
31
|
-
|
|
32
|
-
// Ensure checked is always in sync with value
|
|
33
|
-
$: checked = value;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Handles click events on the toggle, dispatching the change.
|
|
37
|
-
*/
|
|
38
|
-
const handleClick = (): void => {
|
|
39
|
-
if (disabled || preventChange) return;
|
|
40
|
-
checked = !checked;
|
|
41
|
-
|
|
42
|
-
dispatch('change', checked);
|
|
43
|
-
};
|
|
44
|
-
</script>
|
|
45
|
-
|
|
46
|
-
<div
|
|
47
|
-
class="custom-checkbox {type} {checked ? 'checked' : ''} {disabled ? 'disabled' : ''}"
|
|
48
|
-
on:click={handleClick}
|
|
49
|
-
on:keydown={() => {}}
|
|
50
|
-
role="checkbox"
|
|
51
|
-
tabindex="0"
|
|
52
|
-
aria-checked={`${checked}`}
|
|
53
|
-
{id}
|
|
54
|
-
>
|
|
55
|
-
{#if checked}
|
|
56
|
-
<SquareCheckIcon />
|
|
57
|
-
{/if}
|
|
58
|
-
</div>
|
|
59
|
-
|
|
60
|
-
<style>
|
|
61
|
-
.custom-checkbox {
|
|
62
|
-
width: 16px;
|
|
63
|
-
height: 16px;
|
|
64
|
-
border-radius: 4px;
|
|
65
|
-
border: 2px solid #ffffff1a;
|
|
66
|
-
display: flex;
|
|
67
|
-
justify-content: center;
|
|
68
|
-
align-items: center;
|
|
69
|
-
cursor: pointer;
|
|
70
|
-
}
|
|
71
|
-
.custom-checkbox.radio {
|
|
72
|
-
border-radius: 50%;
|
|
73
|
-
}
|
|
74
|
-
.custom-checkbox :global(svg) {
|
|
75
|
-
width: 16px;
|
|
76
|
-
height: 16px;
|
|
77
|
-
}
|
|
78
|
-
.custom-checkbox.checked {
|
|
79
|
-
color: white;
|
|
80
|
-
border: none;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.custom-checkbox.checked :global(svg) {
|
|
84
|
-
color: white;
|
|
85
|
-
background: #006acc;
|
|
86
|
-
border-radius: 4px;
|
|
87
|
-
}
|
|
88
|
-
.custom-checkbox.checked.radio :global(svg) {
|
|
89
|
-
border-radius: 50%;
|
|
90
|
-
}
|
|
91
|
-
.custom-checkbox.disabled {
|
|
92
|
-
cursor: not-allowed;
|
|
93
|
-
}
|
|
94
|
-
</style>
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
-
$$bindings?: Bindings;
|
|
4
|
-
} & Exports;
|
|
5
|
-
(internal: unknown, props: Props & {
|
|
6
|
-
$$events?: Events;
|
|
7
|
-
$$slots?: Slots;
|
|
8
|
-
}): Exports & {
|
|
9
|
-
$set?: any;
|
|
10
|
-
$on?: any;
|
|
11
|
-
};
|
|
12
|
-
z_$$bindings?: Bindings;
|
|
13
|
-
}
|
|
14
|
-
declare const Checkbox: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
-
/**
|
|
16
|
-
* This is the value of the checkbox.
|
|
17
|
-
*/ value?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* This means the checkbox is disabled.
|
|
20
|
-
*/ disabled?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* This means you are using an external state to control the checkbox.
|
|
23
|
-
*/ preventChange?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* This is the id of the checkbox.
|
|
26
|
-
*/ id?: string;
|
|
27
|
-
/**
|
|
28
|
-
* This is the type of the checkbox. Defaults to `checkbox`.
|
|
29
|
-
*/ type?: "checkbox" | "radio";
|
|
30
|
-
}, {
|
|
31
|
-
change: CustomEvent<boolean>;
|
|
32
|
-
} & {
|
|
33
|
-
[evt: string]: CustomEvent<any>;
|
|
34
|
-
}, {}, {}, string>;
|
|
35
|
-
type Checkbox = InstanceType<typeof Checkbox>;
|
|
36
|
-
export default Checkbox;
|