@finsweet/webflow-apps-utils 1.0.3 → 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/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- 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/router/examples/RouterExample.svelte.d.ts +18 -0
- 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/types/customCode.d.ts +1 -1
- package/dist/types/window.d.ts +1 -0
- 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/index.d.ts +1 -0
- package/dist/ui/components/index.js +1 -0
- package/dist/ui/components/input/Input.stories.d.ts +9 -0
- package/dist/ui/components/input/Input.stories.js +78 -0
- package/dist/ui/components/input/Input.svelte +39 -3
- package/dist/ui/components/input/types.d.ts +6 -0
- package/dist/ui/components/layout/Layout.svelte +7 -59
- package/dist/ui/components/layout/Layout.svelte.d.ts +2 -2
- package/dist/ui/components/layout/examples/ExampleLayout.svelte +22 -17
- package/dist/ui/components/layout/index.d.ts +1 -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/notification/Notification.stories.svelte +12 -1
- package/dist/ui/components/notification/Notification.svelte +10 -5
- package/dist/ui/components/notification/Notification.svelte.d.ts +1 -1
- package/dist/ui/components/notification/types.d.ts +1 -1
- package/dist/ui/components/section/Section.svelte +4 -2
- package/dist/ui/components/section/types.d.ts +8 -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/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/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/getTimeNow.d.ts +4 -0
- package/dist/utils/helpers/getTimeNow.js +8 -0
- package/dist/utils/helpers/index.d.ts +4 -0
- package/dist/utils/helpers/index.js +4 -0
- package/dist/utils/helpers/minifyCode.d.ts +10 -0
- package/dist/utils/helpers/minifyCode.js +73 -0
- package/dist/utils/helpers/objectsToModuleExports.d.ts +1 -1
- package/dist/utils/helpers/objectsToModuleExports.js +1 -0
- package/dist/utils/helpers/toHumanReadableList.d.ts +4 -0
- package/dist/utils/helpers/toHumanReadableList.js +11 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/webflow-canvas/getAllChildren.d.ts +16 -0
- package/dist/utils/webflow-canvas/getAllChildren.js +65 -0
- package/dist/utils/webflow-canvas/getElementClassList.d.ts +9 -0
- package/dist/utils/webflow-canvas/getElementClassList.js +19 -0
- package/dist/utils/webflow-canvas/index.d.ts +2 -0
- package/dist/utils/webflow-canvas/index.js +2 -0
- package/package.json +6 -1
- package/dist/router/README.md +0 -397
- /package/dist/router/{Link.svelte.d.ts → providers/Link.svelte.d.ts} +0 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/sveltekit';
|
|
2
|
+
import RouterExample from './examples/RouterExample.svelte';
|
|
3
|
+
declare const meta: Meta<typeof RouterExample>;
|
|
4
|
+
export default meta;
|
|
5
|
+
type Story = StoryObj<typeof meta>;
|
|
6
|
+
export declare const CompleteExample: Story;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import RouterExample from './examples/RouterExample.svelte';
|
|
2
|
+
const meta = {
|
|
3
|
+
title: 'Containers/Router',
|
|
4
|
+
component: RouterExample,
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: 'fullscreen'
|
|
7
|
+
},
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
argTypes: {}
|
|
10
|
+
};
|
|
11
|
+
export default meta;
|
|
12
|
+
export const CompleteExample = {
|
|
13
|
+
args: {},
|
|
14
|
+
parameters: {
|
|
15
|
+
docs: {
|
|
16
|
+
description: {
|
|
17
|
+
story: `
|
|
18
|
+
## Complete Router Example
|
|
19
|
+
|
|
20
|
+
This is a full-featured router implementation demonstrating:
|
|
21
|
+
|
|
22
|
+
### Routes Implemented:
|
|
23
|
+
- **Home Route** (\`/\`) - Landing page with feature overview
|
|
24
|
+
- **About Route** (\`/about\`) - Main about page with navigation cards
|
|
25
|
+
- **About Sections** (\`/about/:section\`) - Dynamic sections (team, history, mission)
|
|
26
|
+
- **404 Route** - Custom not found page with helpful navigation
|
|
27
|
+
|
|
28
|
+
### Features Demonstrated:
|
|
29
|
+
- **Link Components** - Active state management and navigation
|
|
30
|
+
- **Programmatic Navigation** - Using \`useNavigate()\` hook
|
|
31
|
+
- **Route Parameters** - Dynamic \`:section\` parameter handling
|
|
32
|
+
- **App Version Support** - Persistent version hash across all navigation
|
|
33
|
+
- **Debug Information** - Real-time route and parameter display
|
|
34
|
+
- **History Management** - Back/forward navigation support
|
|
35
|
+
|
|
36
|
+
### Navigation Examples:
|
|
37
|
+
- Click navigation links to see active states
|
|
38
|
+
- Use back/forward buttons to test history
|
|
39
|
+
- Try direct URL changes to test route matching
|
|
40
|
+
- Visit invalid routes to see 404 handling
|
|
41
|
+
|
|
42
|
+
The example shows how the router maintains app version hashes automatically while providing clean route definitions and reactive state management.
|
|
43
|
+
`
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
|
|
4
|
+
import { Link, Route, RouterProvider } from '../providers';
|
|
5
|
+
import { createRouter } from '../router.svelte';
|
|
6
|
+
import AboutPage from './pages/AboutPage.svelte';
|
|
7
|
+
// Page Components
|
|
8
|
+
import HomePage from './pages/HomePage.svelte';
|
|
9
|
+
import NotFoundPage from './pages/NotFoundPage.svelte';
|
|
10
|
+
|
|
11
|
+
// Create router instance with configuration
|
|
12
|
+
const router = createRouter({
|
|
13
|
+
basePath: '',
|
|
14
|
+
hashMode: false,
|
|
15
|
+
fallbackRoute: '/',
|
|
16
|
+
autoInit: false
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// Add routes
|
|
20
|
+
router.addRoutes([
|
|
21
|
+
{ path: '/', component: HomePage, meta: { title: 'Home' } },
|
|
22
|
+
{ path: '/about', component: AboutPage, meta: { title: 'About' } },
|
|
23
|
+
{ path: '/about/:section', component: AboutPage, meta: { title: 'About Section' } },
|
|
24
|
+
{ path: '*', component: NotFoundPage, meta: { title: 'Not Found' } }
|
|
25
|
+
]);
|
|
26
|
+
|
|
27
|
+
onMount(() => {
|
|
28
|
+
router.init();
|
|
29
|
+
});
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
<div class="router-example">
|
|
33
|
+
<h2>Router Example</h2>
|
|
34
|
+
<p>This example demonstrates the Router component with navigation between pages.</p>
|
|
35
|
+
|
|
36
|
+
<RouterProvider {router}>
|
|
37
|
+
{#snippet children({ router, currentRoute, currentLocation, isNavigating })}
|
|
38
|
+
<div class="app-layout">
|
|
39
|
+
<!-- Navigation -->
|
|
40
|
+
<nav class="navigation">
|
|
41
|
+
<div class="nav-brand">
|
|
42
|
+
<h3>My App</h3>
|
|
43
|
+
</div>
|
|
44
|
+
<ul class="nav-links">
|
|
45
|
+
<li>
|
|
46
|
+
<Link to="/" exact activeClass="active">Home</Link>
|
|
47
|
+
</li>
|
|
48
|
+
<li>
|
|
49
|
+
<Link to="/about" activeClass="active">About</Link>
|
|
50
|
+
</li>
|
|
51
|
+
<li>
|
|
52
|
+
<Link to="/about/team" activeClass="active">About Team</Link>
|
|
53
|
+
</li>
|
|
54
|
+
<li>
|
|
55
|
+
<Link to="/contact" activeClass="active">Contact (404)</Link>
|
|
56
|
+
</li>
|
|
57
|
+
</ul>
|
|
58
|
+
</nav>
|
|
59
|
+
|
|
60
|
+
<!-- Loading indicator -->
|
|
61
|
+
{#if isNavigating}
|
|
62
|
+
<div class="loading-indicator">
|
|
63
|
+
<div class="spinner"></div>
|
|
64
|
+
Navigating...
|
|
65
|
+
</div>
|
|
66
|
+
{/if}
|
|
67
|
+
|
|
68
|
+
<!-- Route information display -->
|
|
69
|
+
<div class="route-info">
|
|
70
|
+
<strong>Current Route:</strong>
|
|
71
|
+
{currentLocation?.pathname || 'None'}<br />
|
|
72
|
+
<strong>Route Title:</strong>
|
|
73
|
+
{currentRoute?.meta?.title || 'Unknown'}<br />
|
|
74
|
+
<strong>Parameters:</strong>
|
|
75
|
+
{JSON.stringify(currentLocation?.params || {})}<br />
|
|
76
|
+
<strong>Query:</strong>
|
|
77
|
+
{currentLocation?.search || 'None'}
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<!-- Main content area -->
|
|
81
|
+
<main class="main-content">
|
|
82
|
+
<!-- Home Route -->
|
|
83
|
+
<Route path="/">
|
|
84
|
+
{#snippet children({ params, location, router, isActive })}
|
|
85
|
+
{#if isActive}
|
|
86
|
+
<HomePage {params} {location} {router} />
|
|
87
|
+
{/if}
|
|
88
|
+
{/snippet}
|
|
89
|
+
</Route>
|
|
90
|
+
|
|
91
|
+
<!-- About Route (with optional section parameter) -->
|
|
92
|
+
<Route path="/about">
|
|
93
|
+
{#snippet children({ params, location, router, isActive })}
|
|
94
|
+
{#if isActive}
|
|
95
|
+
<AboutPage {params} {location} {router} />
|
|
96
|
+
{/if}
|
|
97
|
+
{/snippet}
|
|
98
|
+
</Route>
|
|
99
|
+
|
|
100
|
+
<!-- About with section parameter -->
|
|
101
|
+
<Route path="/about/:section">
|
|
102
|
+
{#snippet children({ params, location, router, isActive })}
|
|
103
|
+
{#if isActive}
|
|
104
|
+
<AboutPage {params} {location} {router} />
|
|
105
|
+
{/if}
|
|
106
|
+
{/snippet}
|
|
107
|
+
</Route>
|
|
108
|
+
|
|
109
|
+
<!-- Fallback route (404) -->
|
|
110
|
+
<Route path="*" exact={false}>
|
|
111
|
+
{#snippet children({ params, location, router, isActive })}
|
|
112
|
+
{#if isActive && !router.isActive('/') && !router.isActive('/about')}
|
|
113
|
+
<NotFoundPage {params} {location} {router} />
|
|
114
|
+
{/if}
|
|
115
|
+
{/snippet}
|
|
116
|
+
</Route>
|
|
117
|
+
</main>
|
|
118
|
+
|
|
119
|
+
<!-- Router controls -->
|
|
120
|
+
<div class="router-controls">
|
|
121
|
+
<h4>Router Controls</h4>
|
|
122
|
+
<div class="controls-grid">
|
|
123
|
+
<button onclick={() => router.navigate('/')}> Go Home </button>
|
|
124
|
+
<button onclick={() => router.navigate('/about')}> Go to About </button>
|
|
125
|
+
<button onclick={() => router.navigate('/about/team')}> Go to Team </button>
|
|
126
|
+
<button onclick={() => router.back()}> ← Back </button>
|
|
127
|
+
<button onclick={() => router.forward()}> Forward → </button>
|
|
128
|
+
<button onclick={() => router.navigate('/random-page')}> 404 Page </button>
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
</div>
|
|
132
|
+
{/snippet}
|
|
133
|
+
</RouterProvider>
|
|
134
|
+
</div>
|
|
135
|
+
|
|
136
|
+
<style>
|
|
137
|
+
.router-example {
|
|
138
|
+
width: 100%;
|
|
139
|
+
max-width: 800px;
|
|
140
|
+
margin: 0 auto;
|
|
141
|
+
padding: 1rem;
|
|
142
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.app-layout {
|
|
146
|
+
border: 1px solid #e1e5e9;
|
|
147
|
+
border-radius: 8px;
|
|
148
|
+
overflow: hidden;
|
|
149
|
+
background: white;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
.navigation {
|
|
153
|
+
display: flex;
|
|
154
|
+
align-items: center;
|
|
155
|
+
justify-content: space-between;
|
|
156
|
+
padding: 1rem 1.5rem;
|
|
157
|
+
background: #f8f9fa;
|
|
158
|
+
border-bottom: 1px solid #e1e5e9;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.nav-brand h3 {
|
|
162
|
+
margin: 0;
|
|
163
|
+
color: #2c3e50;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.nav-links {
|
|
167
|
+
display: flex;
|
|
168
|
+
list-style: none;
|
|
169
|
+
margin: 0;
|
|
170
|
+
padding: 0;
|
|
171
|
+
gap: 1rem;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.nav-links :global(a) {
|
|
175
|
+
padding: 0.5rem 1rem;
|
|
176
|
+
text-decoration: none;
|
|
177
|
+
color: #6c757d;
|
|
178
|
+
border-radius: 4px;
|
|
179
|
+
transition: all 0.2s ease;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.nav-links :global(a:hover) {
|
|
183
|
+
background: #e9ecef;
|
|
184
|
+
color: #495057;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.nav-links :global(a.active) {
|
|
188
|
+
background: #007bff;
|
|
189
|
+
color: white;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.loading-indicator {
|
|
193
|
+
display: flex;
|
|
194
|
+
align-items: center;
|
|
195
|
+
gap: 0.5rem;
|
|
196
|
+
padding: 0.75rem 1.5rem;
|
|
197
|
+
background: #fff3cd;
|
|
198
|
+
border-bottom: 1px solid #ffeaa7;
|
|
199
|
+
color: #856404;
|
|
200
|
+
font-size: 0.875rem;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
.spinner {
|
|
204
|
+
width: 16px;
|
|
205
|
+
height: 16px;
|
|
206
|
+
border: 2px solid #ffeaa7;
|
|
207
|
+
border-top: 2px solid #856404;
|
|
208
|
+
border-radius: 50%;
|
|
209
|
+
animation: spin 1s linear infinite;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
@keyframes spin {
|
|
213
|
+
0% {
|
|
214
|
+
transform: rotate(0deg);
|
|
215
|
+
}
|
|
216
|
+
100% {
|
|
217
|
+
transform: rotate(360deg);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.route-info {
|
|
222
|
+
padding: 1rem 1.5rem;
|
|
223
|
+
background: #f8f9fa;
|
|
224
|
+
border-bottom: 1px solid #e1e5e9;
|
|
225
|
+
font-size: 0.875rem;
|
|
226
|
+
color: #6c757d;
|
|
227
|
+
line-height: 1.5;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
.main-content {
|
|
231
|
+
min-height: 300px;
|
|
232
|
+
padding: 2rem 1.5rem;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.router-controls {
|
|
236
|
+
padding: 1.5rem;
|
|
237
|
+
background: #f8f9fa;
|
|
238
|
+
border-top: 1px solid #e1e5e9;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.router-controls h4 {
|
|
242
|
+
margin: 0 0 1rem 0;
|
|
243
|
+
color: #2c3e50;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.controls-grid {
|
|
247
|
+
display: grid;
|
|
248
|
+
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
|
|
249
|
+
gap: 0.5rem;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.controls-grid button {
|
|
253
|
+
padding: 0.5rem 1rem;
|
|
254
|
+
border: 1px solid #ddd;
|
|
255
|
+
border-radius: 4px;
|
|
256
|
+
background: white;
|
|
257
|
+
color: #495057;
|
|
258
|
+
cursor: pointer;
|
|
259
|
+
font-size: 0.875rem;
|
|
260
|
+
transition: all 0.2s ease;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.controls-grid button:hover {
|
|
264
|
+
background: #f8f9fa;
|
|
265
|
+
border-color: #adb5bd;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.controls-grid button:active {
|
|
269
|
+
background: #e9ecef;
|
|
270
|
+
}
|
|
271
|
+
</style>
|
|
@@ -0,0 +1,18 @@
|
|
|
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: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const RouterExample: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type RouterExample = InstanceType<typeof RouterExample>;
|
|
18
|
+
export default RouterExample;
|