diff --git a/src/lib/components/Recipies/feedback.md b/src/lib/components/Recipies/feedback.md
new file mode 100644
index 0000000..e69de29
diff --git a/src/lib/components/Recipies/machines/authMachine.ts b/src/lib/components/Recipies/machines/authMachine.ts
new file mode 100644
index 0000000..ab95a35
--- /dev/null
+++ b/src/lib/components/Recipies/machines/authMachine.ts
@@ -0,0 +1,88 @@
+// src/lib/components/Recipies/machines/authMachine.ts
+import { createMachine } from 'xstate';
+
+export const authMachine = createMachine(
+ {
+ id: 'auth',
+ initial: 'notAuthenticated',
+ states: {
+ notAuthenticated: {
+ meta: {
+ title: 'Welcome!',
+ buttons: [
+ {
+ type: 'START',
+ label: 'Login',
+ disabled: false
+ }
+ ]
+ },
+ on: {
+ START: {
+ target: 'signIn',
+ actions: 'startSignIn'
+ }
+ }
+ },
+ signIn: {
+ meta: {
+ title: 'Sign In',
+ composite: {
+ id: 'signInForm',
+ component: 'oForm'
+ },
+ buttons: [
+ {
+ type: 'BACK',
+ label: 'Back',
+ disabled: true
+ },
+ {
+ type: 'NEXT',
+ label: 'Authenticate',
+ disabled: false
+ }
+ ]
+ },
+ on: {
+ BACK: 'notAuthenticated',
+ NEXT: {
+ target: 'authenticated',
+ actions: 'authenticate'
+ }
+ }
+ },
+ authenticated: {
+ meta: {
+ title: 'Authenticated',
+ buttons: [
+ {
+ type: 'LOGOUT',
+ label: 'Logout',
+ disabled: false
+ }
+ ]
+ },
+ on: {
+ LOGOUT: {
+ target: 'notAuthenticated',
+ actions: 'logout'
+ }
+ }
+ }
+ }
+ },
+ {
+ actions: {
+ startSignIn: (context, event) => {
+ console.log('Starting sign in process...');
+ },
+ authenticate: (context, event) => {
+ console.log('Authenticating...');
+ },
+ logout: (context, event) => {
+ console.log('Logging out...');
+ }
+ }
+ }
+)
\ No newline at end of file
diff --git a/src/lib/components/Recipies/oForm.svelte b/src/lib/components/Recipies/oForm.svelte
new file mode 100644
index 0000000..0e14700
--- /dev/null
+++ b/src/lib/components/Recipies/oForm.svelte
@@ -0,0 +1,168 @@
+
+
+{#if isStoreLoaded}
+
+ {#if $successMessage}
+
+ {:else}
+
+ {/if}
+
+{/if}
diff --git a/src/lib/components/Recipies/oRecipe.svelte b/src/lib/components/Recipies/oRecipe.svelte
new file mode 100644
index 0000000..fcce5c5
--- /dev/null
+++ b/src/lib/components/Recipies/oRecipe.svelte
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+ {#each possibleActions as { type, label, disabled } (type)}
+
+ {/each}
+
+
+
+
diff --git a/src/lib/components/examples/Form.svelte b/src/lib/components/examples/Form.svelte
index 24b50bc..e979239 100644
--- a/src/lib/components/examples/Form.svelte
+++ b/src/lib/components/examples/Form.svelte
@@ -16,12 +16,12 @@
email: '',
about: '',
age: '',
- favoriteFood: '',
- slider: 0,
- toggle: false
+ favoriteFood: ''
+ // slider: 0,
+ // toggle: false
};
- const fields = ['name', 'email', 'about', 'age', 'favoriteFood', 'slider', 'toggle'];
+ const fields = ['name', 'email', 'about', 'age', 'favoriteFood'];
const { form, errors, validate, constraints } = superForm(initialFormData, {
validators: UserSchema,
@@ -45,20 +45,6 @@
);
}
- $: {
- if (
- !$errors.name &&
- !$errors.email &&
- !$errors.about &&
- !$errors.age &&
- !$errors.favoriteFood
- ) {
- services.validationRecipe.validateMe().send('VALIDATE');
- } else {
- services.validationRecipe.validateMe().send('INVALIDATE');
- }
- }
-
async function handleSubmit() {
// Manually validate the form
const validationResult = await validate();
diff --git a/src/lib/components/examples/feedback.md b/src/lib/components/examples/feedback.md
deleted file mode 100644
index 6b726cc..0000000
--- a/src/lib/components/examples/feedback.md
+++ /dev/null
@@ -1 +0,0 @@
-{"core":{},"composite.Interpreter2":{"id":"validation"},"helloEarthAlert":{}}
\ No newline at end of file
diff --git a/src/lib/components/maschines/SignIn.svelte b/src/lib/components/maschines/SignIn.svelte
new file mode 100644
index 0000000..9f01321
--- /dev/null
+++ b/src/lib/components/maschines/SignIn.svelte
@@ -0,0 +1,50 @@
+
+
+
+{#if $state.matches('notSignedIn')}
+
+{:else if $state.matches('email')}
+
+
+
+ {#if errors.email}{$errors.email}{/if}
+
+
+{:else if $state.matches('name')}
+
+
+
+ {#if errors.name}{$errors.name}{/if}
+
+
+{:else if $state.matches('signedIn')}
+ account signed in
+{/if}
diff --git a/src/lib/components/maschines/signInMachine.ts b/src/lib/components/maschines/signInMachine.ts
new file mode 100644
index 0000000..5324dab
--- /dev/null
+++ b/src/lib/components/maschines/signInMachine.ts
@@ -0,0 +1,35 @@
+// src/lib/components/machines/SignInMachine.ts
+import { createMachine, assign } from 'xstate';
+
+export const SignInMachine = createMachine({
+ id: 'signIn',
+ initial: 'notSignedIn',
+ context: {
+ email: '',
+ name: ''
+ },
+ states: {
+ notSignedIn: {
+ on: { START: 'email' }
+ },
+ email: {
+ on: {
+ NEXT: {
+ target: 'name',
+ actions: assign({ email: (_, event) => event.value })
+ }
+ }
+ },
+ name: {
+ on: {
+ NEXT: {
+ target: 'signedIn',
+ actions: assign({ name: (_, event) => event.value })
+ }
+ }
+ },
+ signedIn: {
+ type: 'final'
+ }
+ }
+});
\ No newline at end of file
diff --git a/src/lib/types/HelloUserSchema.ts b/src/lib/types/HelloUserSchema.ts
new file mode 100644
index 0000000..5298345
--- /dev/null
+++ b/src/lib/types/HelloUserSchema.ts
@@ -0,0 +1,7 @@
+// src/lib/types/HelloUserSchema.ts
+import { z } from 'zod';
+
+export const HelloUserSchema = z.object({
+ email: z.string().email('Invalid email').nonempty('Email is required'),
+ name: z.string().min(2, 'Name is too short').max(50, 'Name is too long').nonempty('Name is required')
+});
\ No newline at end of file
diff --git a/src/routes/dashboard/+page.svelte b/src/routes/dashboard/+page.svelte
new file mode 100644
index 0000000..c3d86d8
--- /dev/null
+++ b/src/routes/dashboard/+page.svelte
@@ -0,0 +1,6 @@
+
+
+