@picked/svelte 0.0.1-dev.1775016219245 → 0.0.1-dev.1775627395474

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.
@@ -1 +1 @@
1
- import{getExperience as e,getPicked as t}from"../hooks/client.js";import{createForm as n}from"@picked/client/form";import*as r from"svelte/internal/client";function i(i,a,o){let s=n({client:t(),experienceInstance:e()},i,a,o);return{...s,form:{...s.form,onBeforeSubmit:e=>{r.user_effect(()=>s.form.onBeforeSubmit(e))},onSuccess:e=>{r.user_effect(()=>s.form.onSuccess(e))},onError:e=>{r.user_effect(()=>s.form.onError(e))}}}}export{i as createForm};
1
+ import{getExperience as e,getPicked as t}from"../hooks/client.js";import{createForm as n}from"@picked/client/form";import*as r from"svelte/internal/client";function i(i,a,o){let s=n({client:t(),experienceInstance:e()},i,a,o);return{...s,form:{...s.form,props:{...s.form.props,onsubmit:e=>s.form.props.onsubmit(e)},onBeforeSubmit:e=>{r.user_effect(()=>s.form.onBeforeSubmit(e))},onSuccess:e=>{r.user_effect(()=>s.form.onSuccess(e))},onError:e=>{r.user_effect(()=>s.form.onError(e))}}}}export{i as createForm};
@@ -1,12 +1,15 @@
1
1
  import { Store } from 'effector';
2
- import { FormInstance as CoreFormInstance, ErrorCallback, SubmitCallback, SuccessCallback } from '@picked/client/form';
2
+ import { FormInstance as CoreFormInstance, ErrorCallback, SubmitCallback, SubmitEventWithCurrentTarget, SuccessCallback } from '@picked/client/form';
3
3
  export type { FormField } from '@picked/client/form';
4
4
  /**
5
5
  * Svelte FormInstance — identical to core but callback registration returns void
6
6
  * (cleanup is handled automatically via $effect, not by the consumer).
7
7
  */
8
8
  export interface FormInstance<TFieldIds extends string = string> extends Omit<CoreFormInstance<TFieldIds>, 'form'> {
9
- form: Omit<CoreFormInstance<TFieldIds>['form'], 'onBeforeSubmit' | 'onSuccess' | 'onError'> & {
9
+ form: Omit<CoreFormInstance<TFieldIds>['form'], 'onBeforeSubmit' | 'onSuccess' | 'onError' | 'props'> & {
10
+ props: {
11
+ onsubmit: (e: SubmitEventWithCurrentTarget) => void;
12
+ };
10
13
  onBeforeSubmit: (callback: SubmitCallback<TFieldIds>) => void;
11
14
  onSuccess: (callback: SuccessCallback<TFieldIds>) => void;
12
15
  onError: (callback: ErrorCallback) => void;
@@ -15,10 +18,20 @@ export interface FormInstance<TFieldIds extends string = string> extends Omit<Co
15
18
  /**
16
19
  * Creates a form instance with Svelte lifecycle management.
17
20
  *
18
- * Wraps the framework-agnostic createForm from @picked/client/form:
19
- * - Injects client and experienceInstance from Svelte context
20
- * - Auto-wires callback cleanup via $effect so consumers don't need to manage lifecycle
21
+ * Wraps the framework-agnostic createForm from `@picked/client/form`:
22
+ * - Injects client and experienceInstance from Svelte context.
23
+ * - Wraps `form.props.onsubmit` as a plain function (not an Effector EventCallable).
24
+ * - Auto-wires callback cleanup via `$effect` so consumers don't need to manage lifecycle.
21
25
  *
22
26
  * Used internally by setStepContext — access via getStep() in components.
27
+ *
28
+ * @param {string} formId - Unique identifier for this form instance.
29
+ * @param {Store<string>} title - Reactive store holding the form/step title.
30
+ * @param {Store<string[]>} fieldIds - Reactive store of field IDs that belong to this form.
31
+ * @returns {FormInstance} A form instance with reactive field stores, submission handlers, and callback registration.
32
+ * @example
33
+ * ```ts
34
+ * const { form, fields } = createForm('lead-capture', $title, $fieldIds)
35
+ * ```
23
36
  */
24
37
  export declare function createForm(formId: string, title: Store<string>, fieldIds: Store<string[]>): FormInstance;
@@ -1,2 +1,25 @@
1
- export declare function getAction(actionName: string): import('effector').Store<(<T = void>(params?: T) => void) | undefined>;
2
- export declare function getActionResult(actionName: string): import('effector').StoreWritable<void | undefined>;
1
+ import { Action } from '@picked/client';
2
+ import { Store } from 'effector';
3
+ /**
4
+ * Returns the reactive evokable action store for the given action name.
5
+ *
6
+ * @param {string} actionName - The registered action name.
7
+ * @returns {Store<() => ReturnType<Action>>} A store containing the callable action function or undefined.
8
+ * @example
9
+ * ```ts
10
+ * const actionStore = getAction('logEvent')
11
+ * ```
12
+ */
13
+ export declare function getAction(actionName: string): Store<() => ReturnType<Action>>;
14
+ /**
15
+ * Returns a reactive store holding the latest result of invoking the named action.
16
+ * Re-evaluates automatically when the underlying action store updates.
17
+ *
18
+ * @param {string} actionName - The registered action name.
19
+ * @returns {Store<string | string[] | boolean | void | undefined>} A store containing the latest action return value.
20
+ * @example
21
+ * ```ts
22
+ * const result = getActionResult('isLoggedIn')
23
+ * ```
24
+ */
25
+ export declare function getActionResult(actionName: string): import('effector').StoreWritable<string | boolean | void | string[] | undefined>;
@@ -1 +1 @@
1
- import{getPicked as e}from"./client.js";import{attach as t,createEffect as n,createEvent as r,createStore as i,sample as a}from"effector";function o(t){return e().actions.getEvokableAction(t)}function s(e){let s=o(e),c=i(void 0,{skipVoid:!1}),l=r(),u=t({source:s,mapParams:(e,t)=>t,effect:n(async e=>{if(e)return e()})});return a({clock:l,target:u}),a({clock:u.doneData,target:c}),l(),c}export{o as getAction,s as getActionResult};
1
+ import{getPicked as e}from"./client.js";import{attach as t,createEffect as n,createEvent as r,createStore as i,sample as a}from"effector";import"@picked/client";function o(t){return e().actions.getEvokableAction(t)}function s(e){let s=o(e),c=i(void 0,{skipVoid:!1}),l=r(),u=t({source:s,mapParams:(e,t)=>t,effect:n(async e=>{if(e)return await e()})});return a({clock:l,target:u}),a({clock:u.doneData,target:c}),l(),a({clock:s,target:l}),c}export{o as getAction,s as getActionResult};
@@ -1,10 +1,11 @@
1
1
  <script lang="ts">
2
+ /** @file Accessible tab container that renders dynamic Svelte components per tab. */
2
3
  import type { Component } from 'svelte'
3
4
 
4
5
  interface Tab {
5
6
  id: string
6
7
  label: string
7
- component: Component<any>
8
+ component: Component<Record<string, unknown>>
8
9
  props?: Record<string, unknown>
9
10
  }
10
11
 
@@ -13,10 +14,28 @@
13
14
 
14
15
  let activeTab = initialTab
15
16
 
17
+ /**
18
+ * Sets the active tab to the given index.
19
+ *
20
+ * @param {number} index - The zero-based tab index to activate.
21
+ * @example
22
+ * ```typescript
23
+ * activateTab(2) // switches to the third tab
24
+ * ```
25
+ */
16
26
  function activateTab(index: number) {
17
27
  activeTab = index
18
28
  }
19
29
 
30
+ /**
31
+ * Handles arrow-key, Home, and End navigation within the tab list.
32
+ *
33
+ * @param {KeyboardEvent} event - The keyboard event from the tab list.
34
+ * @example
35
+ * ```typescript
36
+ * handleKeydown(new KeyboardEvent('keydown', { key: 'ArrowRight' }))
37
+ * ```
38
+ */
20
39
  function handleKeydown(event: KeyboardEvent) {
21
40
  const tabCount = tabs.length
22
41
  let newIndex = activeTab
@@ -83,6 +102,7 @@
83
102
  display: flex;
84
103
  flex-direction: column;
85
104
  flex: 1;
105
+ min-height: 0;
86
106
  }
87
107
 
88
108
  .tab-list {
@@ -124,7 +144,7 @@
124
144
  .tab-panel {
125
145
  flex: 1 1 auto;
126
146
  display: grid;
127
- align-content: start;
147
+ min-height: 0;
128
148
  overflow: auto;
129
149
  }
130
150
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@picked/svelte",
3
- "version": "0.0.1-dev.1775016219245",
3
+ "version": "0.0.1-dev.1775627395474",
4
4
  "dependencies": {
5
5
  "d3": "^7.9.0"
6
6
  },
@@ -24,7 +24,7 @@
24
24
  "svelte-check": "^4.2.2",
25
25
  "typedoc": "^0.28.5",
26
26
  "typedoc-plugin-markdown": "^4.6.3",
27
- "vite": "^8.0.1",
27
+ "vite": "^8.0.7",
28
28
  "vite-plugin-dts": "^4.5.4",
29
29
  "vitest": "^4.1.0"
30
30
  },
@@ -88,7 +88,7 @@
88
88
  },
89
89
  "module": "./dist/index.js",
90
90
  "peerDependencies": {
91
- "@picked/client": "0.0.1-dev.1775016219245",
91
+ "@picked/client": "0.0.1-dev.1775627395474",
92
92
  "effector": "^23.3.0",
93
93
  "svelte": "^5.46.4"
94
94
  },