dialkit 0.2.1 → 1.0.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.
package/dist/index.d.cts CHANGED
@@ -10,6 +10,12 @@ type SpringConfig = {
10
10
  visualDuration?: number;
11
11
  bounce?: number;
12
12
  };
13
+ type EasingConfig = {
14
+ type: 'easing';
15
+ duration: number;
16
+ ease: [number, number, number, number];
17
+ };
18
+ type TransitionConfig = SpringConfig | EasingConfig;
13
19
  type ActionConfig = {
14
20
  type: 'action';
15
21
  label?: string;
@@ -31,21 +37,22 @@ type TextConfig = {
31
37
  default?: string;
32
38
  placeholder?: string;
33
39
  };
34
- type DialValue = number | boolean | string | SpringConfig | ActionConfig | SelectConfig | ColorConfig | TextConfig;
40
+ type DialValue = number | boolean | string | SpringConfig | EasingConfig | ActionConfig | SelectConfig | ColorConfig | TextConfig;
35
41
  type DialConfig = {
36
- [key: string]: DialValue | [number, number, number] | DialConfig;
42
+ [key: string]: DialValue | [number, number, number, number?] | DialConfig;
37
43
  };
38
44
  type ResolvedValues<T extends DialConfig> = {
39
- [K in keyof T]: T[K] extends [number, number, number] ? number : T[K] extends SpringConfig ? SpringConfig : T[K] extends SelectConfig ? string : T[K] extends ColorConfig ? string : T[K] extends TextConfig ? string : T[K] extends DialConfig ? ResolvedValues<T[K]> : T[K];
45
+ [K in keyof T]: T[K] extends [number, number, number, number?] ? number : T[K] extends SpringConfig ? TransitionConfig : T[K] extends EasingConfig ? TransitionConfig : T[K] extends SelectConfig ? string : T[K] extends ColorConfig ? string : T[K] extends TextConfig ? string : T[K] extends DialConfig ? ResolvedValues<T[K]> : T[K];
40
46
  };
41
47
  type ControlMeta = {
42
- type: 'slider' | 'toggle' | 'spring' | 'folder' | 'action' | 'select' | 'color' | 'text';
48
+ type: 'slider' | 'toggle' | 'spring' | 'transition' | 'folder' | 'action' | 'select' | 'color' | 'text';
43
49
  path: string;
44
50
  label: string;
45
51
  min?: number;
46
52
  max?: number;
47
53
  step?: number;
48
54
  children?: ControlMeta[];
55
+ defaultOpen?: boolean;
49
56
  options?: (string | {
50
57
  value: string;
51
58
  label: string;
@@ -75,10 +82,13 @@ declare class DialStoreClass {
75
82
  private activePreset;
76
83
  private baseValues;
77
84
  registerPanel(id: string, name: string, config: DialConfig): void;
85
+ updatePanel(id: string, name: string, config: DialConfig): void;
78
86
  unregisterPanel(id: string): void;
79
87
  updateValue(panelId: string, path: string, value: DialValue): void;
80
88
  updateSpringMode(panelId: string, path: string, mode: 'simple' | 'advanced'): void;
81
89
  getSpringMode(panelId: string, path: string): 'simple' | 'advanced';
90
+ updateTransitionMode(panelId: string, path: string, mode: 'easing' | 'simple' | 'advanced'): void;
91
+ getTransitionMode(panelId: string, path: string): 'easing' | 'simple' | 'advanced';
82
92
  getValue(panelId: string, path: string): DialValue | undefined;
83
93
  getValues(panelId: string): Record<string, DialValue>;
84
94
  getPanels(): PanelConfig[];
@@ -95,9 +105,11 @@ declare class DialStoreClass {
95
105
  clearActivePreset(panelId: string): void;
96
106
  private notify;
97
107
  private notifyGlobal;
108
+ private initTransitionModes;
98
109
  private parseConfig;
99
110
  private flattenValues;
100
111
  private isSpringConfig;
112
+ private isEasingConfig;
101
113
  private isActionConfig;
102
114
  private isSelectConfig;
103
115
  private isColorConfig;
@@ -106,6 +118,10 @@ declare class DialStoreClass {
106
118
  private formatLabel;
107
119
  private inferRange;
108
120
  private inferStep;
121
+ private normalizePreservedValue;
122
+ private roundToStep;
123
+ private stepPrecision;
124
+ private mapControlsByPath;
109
125
  }
110
126
  declare const DialStore: DialStoreClass;
111
127
 
@@ -117,8 +133,9 @@ declare function useDialKit<T extends DialConfig>(name: string, config: T, optio
117
133
  type DialPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
118
134
  interface DialRootProps {
119
135
  position?: DialPosition;
136
+ defaultOpen?: boolean;
120
137
  }
121
- declare function DialRoot({ position }: DialRootProps): react.ReactPortal | null;
138
+ declare function DialRoot({ position, defaultOpen }: DialRootProps): react.ReactPortal | null;
122
139
 
123
140
  interface SliderProps {
124
141
  label: string;
@@ -171,6 +188,20 @@ interface SpringVisualizationProps {
171
188
  }
172
189
  declare function SpringVisualization({ spring, isSimpleMode }: SpringVisualizationProps): react_jsx_runtime.JSX.Element;
173
190
 
191
+ interface TransitionControlProps {
192
+ panelId: string;
193
+ path: string;
194
+ label: string;
195
+ value: TransitionConfig;
196
+ onChange: (value: TransitionConfig) => void;
197
+ }
198
+ declare function TransitionControl({ panelId, path, label, value, onChange }: TransitionControlProps): react_jsx_runtime.JSX.Element;
199
+
200
+ interface EasingVisualizationProps {
201
+ easing: EasingConfig;
202
+ }
203
+ declare function EasingVisualization({ easing }: EasingVisualizationProps): react_jsx_runtime.JSX.Element;
204
+
174
205
  interface TextControlProps {
175
206
  label: string;
176
207
  value: string;
@@ -206,4 +237,4 @@ interface PresetManagerProps {
206
237
  }
207
238
  declare function PresetManager({ panelId, presets, activePresetId, onAdd }: PresetManagerProps): react_jsx_runtime.JSX.Element;
208
239
 
209
- export { type ActionConfig, ButtonGroup, type ColorConfig, ColorControl, type ControlMeta, type DialConfig, type DialPosition, DialRoot, DialStore, type DialValue, Folder, type PanelConfig, type Preset, PresetManager, type ResolvedValues, type SelectConfig, SelectControl, Slider, type SpringConfig, SpringControl, SpringVisualization, type TextConfig, TextControl, Toggle, type UseDialOptions, useDialKit };
240
+ export { type ActionConfig, ButtonGroup, type ColorConfig, ColorControl, type ControlMeta, type DialConfig, type DialPosition, DialRoot, DialStore, type DialValue, type EasingConfig, EasingVisualization, Folder, type PanelConfig, type Preset, PresetManager, type ResolvedValues, type SelectConfig, SelectControl, Slider, type SpringConfig, SpringControl, SpringVisualization, type TextConfig, TextControl, Toggle, type TransitionConfig, TransitionControl, type UseDialOptions, useDialKit };
package/dist/index.d.ts CHANGED
@@ -10,6 +10,12 @@ type SpringConfig = {
10
10
  visualDuration?: number;
11
11
  bounce?: number;
12
12
  };
13
+ type EasingConfig = {
14
+ type: 'easing';
15
+ duration: number;
16
+ ease: [number, number, number, number];
17
+ };
18
+ type TransitionConfig = SpringConfig | EasingConfig;
13
19
  type ActionConfig = {
14
20
  type: 'action';
15
21
  label?: string;
@@ -31,21 +37,22 @@ type TextConfig = {
31
37
  default?: string;
32
38
  placeholder?: string;
33
39
  };
34
- type DialValue = number | boolean | string | SpringConfig | ActionConfig | SelectConfig | ColorConfig | TextConfig;
40
+ type DialValue = number | boolean | string | SpringConfig | EasingConfig | ActionConfig | SelectConfig | ColorConfig | TextConfig;
35
41
  type DialConfig = {
36
- [key: string]: DialValue | [number, number, number] | DialConfig;
42
+ [key: string]: DialValue | [number, number, number, number?] | DialConfig;
37
43
  };
38
44
  type ResolvedValues<T extends DialConfig> = {
39
- [K in keyof T]: T[K] extends [number, number, number] ? number : T[K] extends SpringConfig ? SpringConfig : T[K] extends SelectConfig ? string : T[K] extends ColorConfig ? string : T[K] extends TextConfig ? string : T[K] extends DialConfig ? ResolvedValues<T[K]> : T[K];
45
+ [K in keyof T]: T[K] extends [number, number, number, number?] ? number : T[K] extends SpringConfig ? TransitionConfig : T[K] extends EasingConfig ? TransitionConfig : T[K] extends SelectConfig ? string : T[K] extends ColorConfig ? string : T[K] extends TextConfig ? string : T[K] extends DialConfig ? ResolvedValues<T[K]> : T[K];
40
46
  };
41
47
  type ControlMeta = {
42
- type: 'slider' | 'toggle' | 'spring' | 'folder' | 'action' | 'select' | 'color' | 'text';
48
+ type: 'slider' | 'toggle' | 'spring' | 'transition' | 'folder' | 'action' | 'select' | 'color' | 'text';
43
49
  path: string;
44
50
  label: string;
45
51
  min?: number;
46
52
  max?: number;
47
53
  step?: number;
48
54
  children?: ControlMeta[];
55
+ defaultOpen?: boolean;
49
56
  options?: (string | {
50
57
  value: string;
51
58
  label: string;
@@ -75,10 +82,13 @@ declare class DialStoreClass {
75
82
  private activePreset;
76
83
  private baseValues;
77
84
  registerPanel(id: string, name: string, config: DialConfig): void;
85
+ updatePanel(id: string, name: string, config: DialConfig): void;
78
86
  unregisterPanel(id: string): void;
79
87
  updateValue(panelId: string, path: string, value: DialValue): void;
80
88
  updateSpringMode(panelId: string, path: string, mode: 'simple' | 'advanced'): void;
81
89
  getSpringMode(panelId: string, path: string): 'simple' | 'advanced';
90
+ updateTransitionMode(panelId: string, path: string, mode: 'easing' | 'simple' | 'advanced'): void;
91
+ getTransitionMode(panelId: string, path: string): 'easing' | 'simple' | 'advanced';
82
92
  getValue(panelId: string, path: string): DialValue | undefined;
83
93
  getValues(panelId: string): Record<string, DialValue>;
84
94
  getPanels(): PanelConfig[];
@@ -95,9 +105,11 @@ declare class DialStoreClass {
95
105
  clearActivePreset(panelId: string): void;
96
106
  private notify;
97
107
  private notifyGlobal;
108
+ private initTransitionModes;
98
109
  private parseConfig;
99
110
  private flattenValues;
100
111
  private isSpringConfig;
112
+ private isEasingConfig;
101
113
  private isActionConfig;
102
114
  private isSelectConfig;
103
115
  private isColorConfig;
@@ -106,6 +118,10 @@ declare class DialStoreClass {
106
118
  private formatLabel;
107
119
  private inferRange;
108
120
  private inferStep;
121
+ private normalizePreservedValue;
122
+ private roundToStep;
123
+ private stepPrecision;
124
+ private mapControlsByPath;
109
125
  }
110
126
  declare const DialStore: DialStoreClass;
111
127
 
@@ -117,8 +133,9 @@ declare function useDialKit<T extends DialConfig>(name: string, config: T, optio
117
133
  type DialPosition = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
118
134
  interface DialRootProps {
119
135
  position?: DialPosition;
136
+ defaultOpen?: boolean;
120
137
  }
121
- declare function DialRoot({ position }: DialRootProps): react.ReactPortal | null;
138
+ declare function DialRoot({ position, defaultOpen }: DialRootProps): react.ReactPortal | null;
122
139
 
123
140
  interface SliderProps {
124
141
  label: string;
@@ -171,6 +188,20 @@ interface SpringVisualizationProps {
171
188
  }
172
189
  declare function SpringVisualization({ spring, isSimpleMode }: SpringVisualizationProps): react_jsx_runtime.JSX.Element;
173
190
 
191
+ interface TransitionControlProps {
192
+ panelId: string;
193
+ path: string;
194
+ label: string;
195
+ value: TransitionConfig;
196
+ onChange: (value: TransitionConfig) => void;
197
+ }
198
+ declare function TransitionControl({ panelId, path, label, value, onChange }: TransitionControlProps): react_jsx_runtime.JSX.Element;
199
+
200
+ interface EasingVisualizationProps {
201
+ easing: EasingConfig;
202
+ }
203
+ declare function EasingVisualization({ easing }: EasingVisualizationProps): react_jsx_runtime.JSX.Element;
204
+
174
205
  interface TextControlProps {
175
206
  label: string;
176
207
  value: string;
@@ -206,4 +237,4 @@ interface PresetManagerProps {
206
237
  }
207
238
  declare function PresetManager({ panelId, presets, activePresetId, onAdd }: PresetManagerProps): react_jsx_runtime.JSX.Element;
208
239
 
209
- export { type ActionConfig, ButtonGroup, type ColorConfig, ColorControl, type ControlMeta, type DialConfig, type DialPosition, DialRoot, DialStore, type DialValue, Folder, type PanelConfig, type Preset, PresetManager, type ResolvedValues, type SelectConfig, SelectControl, Slider, type SpringConfig, SpringControl, SpringVisualization, type TextConfig, TextControl, Toggle, type UseDialOptions, useDialKit };
240
+ export { type ActionConfig, ButtonGroup, type ColorConfig, ColorControl, type ControlMeta, type DialConfig, type DialPosition, DialRoot, DialStore, type DialValue, type EasingConfig, EasingVisualization, Folder, type PanelConfig, type Preset, PresetManager, type ResolvedValues, type SelectConfig, SelectControl, Slider, type SpringConfig, SpringControl, SpringVisualization, type TextConfig, TextControl, Toggle, type TransitionConfig, TransitionControl, type UseDialOptions, useDialKit };