@plures/design-dojo 0.2.0

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.
@@ -0,0 +1,87 @@
1
+ /**
2
+ * Spring physics engine for Svelte animations.
3
+ *
4
+ * Based on damped harmonic oscillator:
5
+ * F = -kx - cv
6
+ * where k = stiffness, c = damping, x = displacement, v = velocity
7
+ *
8
+ * This is what makes UI feel physical instead of robotic.
9
+ */
10
+ export interface SpringConfig {
11
+ /** Restoring force strength. Higher = snappier. Default: 300 */
12
+ stiffness: number;
13
+ /** Resistance to motion. Higher = less bouncy. Default: 24 */
14
+ damping: number;
15
+ /** Inertia. Higher = heavier feel. Default: 1 */
16
+ mass: number;
17
+ /** Velocity threshold to consider "at rest". Default: 0.01 */
18
+ restThreshold: number;
19
+ }
20
+ export declare const SPRING_PRESETS: {
21
+ /** Gentle hover, focus ring expansion */
22
+ readonly gentle: {
23
+ readonly stiffness: 120;
24
+ readonly damping: 14;
25
+ readonly mass: 1;
26
+ readonly restThreshold: 0.01;
27
+ };
28
+ /** Button press, toggle switch */
29
+ readonly snappy: {
30
+ readonly stiffness: 300;
31
+ readonly damping: 24;
32
+ readonly mass: 1;
33
+ readonly restThreshold: 0.01;
34
+ };
35
+ /** Playful bounce, notification pop */
36
+ readonly bouncy: {
37
+ readonly stiffness: 400;
38
+ readonly damping: 10;
39
+ readonly mass: 1;
40
+ readonly restThreshold: 0.01;
41
+ };
42
+ /** Modal open, panel slide */
43
+ readonly heavy: {
44
+ readonly stiffness: 200;
45
+ readonly damping: 30;
46
+ readonly mass: 1.5;
47
+ readonly restThreshold: 0.01;
48
+ };
49
+ /** Tooltip, popover */
50
+ readonly quick: {
51
+ readonly stiffness: 500;
52
+ readonly damping: 30;
53
+ readonly mass: 0.5;
54
+ readonly restThreshold: 0.01;
55
+ };
56
+ };
57
+ export type SpringPreset = keyof typeof SPRING_PRESETS;
58
+ interface SpringState {
59
+ value: number;
60
+ velocity: number;
61
+ target: number;
62
+ done: boolean;
63
+ }
64
+ /**
65
+ * Simulate one frame of spring physics.
66
+ * @param dt Time delta in seconds
67
+ */
68
+ export declare function springStep(state: SpringState, config: SpringConfig, dt: number): SpringState;
69
+ /**
70
+ * Create a spring animation that calls `onUpdate` each frame.
71
+ * Returns a controller to change target or stop.
72
+ */
73
+ export declare function createSpring(initial: number, config: (SpringConfig | SpringPreset) | undefined, onUpdate: (value: number) => void): {
74
+ /** Set a new target value. Animation starts automatically. */
75
+ set(target: number): void;
76
+ /** Jump to value immediately (no animation). */
77
+ jump(value: number): void;
78
+ /** Add velocity impulse (e.g., from a flick gesture). */
79
+ impulse(velocity: number): void;
80
+ /** Stop animation. */
81
+ stop(): void;
82
+ /** Get current value. */
83
+ readonly value: number;
84
+ /** Whether the spring has settled. */
85
+ readonly done: boolean;
86
+ };
87
+ export {};
@@ -0,0 +1 @@
1
+ export { SvelteComponent as default } from 'svelte';
@@ -0,0 +1 @@
1
+ export { SvelteComponent as default } from 'svelte';
@@ -0,0 +1 @@
1
+ export { SvelteComponent as default } from 'svelte';
@@ -0,0 +1,7 @@
1
+ /** Shared type definitions for SearchInput. */
2
+ export interface SearchResult {
3
+ text: string;
4
+ score: number;
5
+ id?: string;
6
+ meta?: Record<string, unknown>;
7
+ }
@@ -0,0 +1 @@
1
+ export { SvelteComponent as default } from 'svelte';
@@ -0,0 +1,8 @@
1
+ /** Message shape for the ChatPane component. */
2
+ export interface ChatMessage {
3
+ id: string;
4
+ author: string;
5
+ content: string;
6
+ timestamp: Date;
7
+ type?: "user" | "agent" | "system";
8
+ }
@@ -0,0 +1 @@
1
+ export { SvelteComponent as default } from 'svelte';
@@ -0,0 +1,25 @@
1
+ /**
2
+ * useTui — Shared composable for propagating `tui` mode through a component tree.
3
+ *
4
+ * Usage (parent component):
5
+ * import { provideTui } from '../useTui.js';
6
+ * let { tui = false } = $props();
7
+ * provideTui(() => tui);
8
+ *
9
+ * Usage (child component):
10
+ * import { useTui } from '../useTui.js';
11
+ * const getTui = useTui();
12
+ * // Access reactively: getTui() or const isTui = $derived(getTui());
13
+ */
14
+ /**
15
+ * Provide TUI mode to all descendant components.
16
+ * Pass a reactive getter (e.g. `() => tui`) so children receive updates.
17
+ * Call at component initialization (not inside $effect).
18
+ */
19
+ export declare function provideTui(getTui: () => boolean): void;
20
+ /**
21
+ * Consume TUI mode from the nearest ancestor that called `provideTui`.
22
+ * Falls back to `() => false` when no ancestor provides context.
23
+ * Call at component initialization (not inside $effect).
24
+ */
25
+ export declare function useTui(): () => boolean;
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@plures/design-dojo",
3
+ "version": "0.2.0",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/index.js",
11
+ "types": "./dist/index.d.ts"
12
+ },
13
+ "./tokens.css": "./dist/tokens.css",
14
+ "./tui-tokens.css": "./dist/tui-tokens.css"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public",
18
+ "registry": "https://registry.npmjs.org/"
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "scripts": {
24
+ "dev": "vite dev",
25
+ "build": "vite build",
26
+ "preview": "vite preview",
27
+ "check": "svelte-check --tsconfig ./tsconfig.json",
28
+ "storybook": "storybook dev -p 6006",
29
+ "build-storybook": "storybook build"
30
+ },
31
+ "peerDependencies": {
32
+ "svelte": "^5.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "@storybook/addon-essentials": "^8.5.0",
36
+ "@storybook/addon-svelte-csf": "^5.0.0",
37
+ "@storybook/svelte": "^8.5.0",
38
+ "@storybook/sveltekit": "^8.5.0",
39
+ "@sveltejs/vite-plugin-svelte": "^5.0.0",
40
+ "@tsconfig/svelte": "^5.0.0",
41
+ "storybook": "^8.5.0",
42
+ "svelte": "^5.0.0",
43
+ "svelte-check": "^4.0.0",
44
+ "typescript": "^5.7.0",
45
+ "vite": "^6.0.0",
46
+ "vite-plugin-dts": "^4.5.4"
47
+ }
48
+ }