framer-code-link 0.7.0 → 0.8.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,488 @@
1
+ # Framer Property Control Types
2
+
3
+ TypeScript interfaces for all Framer property control types. For usage documentation and examples, see [Property Controls](PROPERTY_CONTROLS.md).
4
+
5
+ ## Base Control Description
6
+
7
+ All control descriptions extend this base interface:
8
+
9
+ ```typescript
10
+ export interface BaseControlDescription<P = any> {
11
+ title?: string;
12
+ description?: string;
13
+ hidden?: ((props: P, rootProps: any) => boolean) | boolean;
14
+ }
15
+
16
+ export interface WithOptional {
17
+ optional?: boolean;
18
+ }
19
+ ```
20
+
21
+ ## Control Type Interfaces
22
+
23
+ ### Boolean Control
24
+
25
+ ```typescript
26
+ export interface BooleanControlDescription<P = any>
27
+ extends BaseControlDescription<P>, WithOptional {
28
+ type: ControlType.Boolean;
29
+ defaultValue?: boolean;
30
+ /** @deprecated */
31
+ disabledTitle?: string;
32
+ /** @deprecated */
33
+ enabledTitle?: string;
34
+ }
35
+ ```
36
+
37
+ ### Number Control
38
+
39
+ ```typescript
40
+ export interface NumberControlDescription<P = any>
41
+ extends BaseControlDescription<P>, WithOptional {
42
+ type: ControlType.Number;
43
+ defaultValue?: number;
44
+ max?: number;
45
+ min?: number;
46
+ unit?: string;
47
+ step?: number;
48
+ displayStepper?: boolean;
49
+ }
50
+ ```
51
+
52
+ ### String Control
53
+
54
+ ```typescript
55
+ export interface StringControlDescription<P = any>
56
+ extends BaseControlDescription<P>, WithOptional {
57
+ type: ControlType.String;
58
+ defaultValue?: string;
59
+ placeholder?: string;
60
+ obscured?: boolean;
61
+ displayTextArea?: boolean;
62
+ preventLocalization?: boolean;
63
+ }
64
+ ```
65
+
66
+ ### Enum Control
67
+
68
+ ```typescript
69
+ export interface EnumControlDescription<
70
+ P = any,
71
+ > extends BaseControlDescription<P> {
72
+ type: ControlType.Enum;
73
+ defaultValue?: string | boolean | number | null;
74
+ options: (string | boolean | number | null)[];
75
+ optionTitles?: string[];
76
+ displaySegmentedControl?: boolean;
77
+ segmentedControlDirection?: "horizontal" | "vertical";
78
+ }
79
+ ```
80
+
81
+ ### Color Control
82
+
83
+ ```typescript
84
+ export interface ColorControlDescription<P = any>
85
+ extends BaseControlDescription<P>, WithOptional {
86
+ type: ControlType.Color;
87
+ defaultValue?: string;
88
+ }
89
+ ```
90
+
91
+ ### ResponsiveImage Control
92
+
93
+ ```typescript
94
+ export interface ResponsiveImageControlDescription<
95
+ P = any,
96
+ > extends BaseControlDescription<P> {
97
+ type: ControlType.ResponsiveImage;
98
+ }
99
+ ```
100
+
101
+ ### File Control
102
+
103
+ ```typescript
104
+ export type AllowedFileTypes = readonly string[];
105
+
106
+ export interface FileControlDescription<
107
+ P = any,
108
+ > extends BaseControlDescription<P> {
109
+ type: ControlType.File;
110
+ allowedFileTypes: AllowedFileTypes;
111
+ }
112
+ ```
113
+
114
+ ### Slot Control
115
+
116
+ ```typescript
117
+ export interface SlotControlDescription<
118
+ P = any,
119
+ > extends BaseControlDescription<P> {
120
+ type: ControlType.Slot;
121
+ maxCount?: number;
122
+ }
123
+ ```
124
+
125
+ ### Array Control
126
+
127
+ ```typescript
128
+ export interface ArrayControlDescription<
129
+ P = any,
130
+ > extends BaseControlDescription<P> {
131
+ type: ControlType.Array;
132
+ control: ArrayItemControlDescription<P>;
133
+ minCount?: number;
134
+ maxCount?: number;
135
+ defaultValue?: any[];
136
+ }
137
+ ```
138
+
139
+ ### Object Control
140
+
141
+ ```typescript
142
+ export type ObjectControlIcon =
143
+ | "object"
144
+ | "effect"
145
+ | "color"
146
+ | "interaction"
147
+ | "boolean";
148
+
149
+ export interface ObjectControlDescription<P = any>
150
+ extends BaseControlDescription<P>, WithOptional {
151
+ type: ControlType.Object;
152
+ controls: { [key: string]: ObjectPropertyControlDescription };
153
+ defaultValue?: { [key: string]: any };
154
+ buttonTitle?: string;
155
+ icon?: ObjectControlIcon;
156
+ }
157
+ ```
158
+
159
+ ### Event Handler Control
160
+
161
+ ```typescript
162
+ export interface EventHandlerControlDescription<
163
+ P = any,
164
+ > extends BaseControlDescription<P> {
165
+ type: ControlType.EventHandler;
166
+ }
167
+ ```
168
+
169
+ ### Transition Control
170
+
171
+ ```typescript
172
+ import type { Transition } from "framer-motion";
173
+
174
+ export interface TransitionControlDescription<
175
+ P = any,
176
+ > extends BaseControlDescription<P> {
177
+ type: ControlType.Transition;
178
+ defaultValue?: null | Transition;
179
+ }
180
+ ```
181
+
182
+ ### BoxShadow Control
183
+
184
+ ```typescript
185
+ export interface BoxShadowControlDescription<
186
+ P = any,
187
+ > extends BaseControlDescription<P> {
188
+ type: ControlType.BoxShadow;
189
+ defaultValue?: string | readonly BoxShadow[];
190
+ }
191
+ ```
192
+
193
+ ### Link Control
194
+
195
+ ```typescript
196
+ export interface LinkControlDescription<
197
+ P = any,
198
+ > extends BaseControlDescription<P> {
199
+ type: ControlType.Link;
200
+ defaultValue?: string;
201
+ }
202
+ ```
203
+
204
+ ### Date Control
205
+
206
+ ```typescript
207
+ export interface DateControlDescription<P = any>
208
+ extends BaseControlDescription<P>, WithOptional {
209
+ type: ControlType.Date;
210
+ displayTime?: boolean;
211
+ defaultValue?: string;
212
+ }
213
+ ```
214
+
215
+ ### Border Control
216
+
217
+ ```typescript
218
+ export type BorderStyle = "solid" | "dashed" | "dotted" | "double";
219
+
220
+ export interface Border {
221
+ borderColor?: string;
222
+ borderStyle?: BorderStyle;
223
+ borderWidth?: number;
224
+ borderTopWidth?: number;
225
+ borderLeftWidth?: number;
226
+ borderRightWidth?: number;
227
+ borderBottomWidth?: number;
228
+ }
229
+
230
+ export interface BorderControlDescription<P = any>
231
+ extends BaseControlDescription<P>, WithOptional {
232
+ type: ControlType.Border;
233
+ defaultValue?: Border;
234
+ }
235
+ ```
236
+
237
+ ### Cursor Control
238
+
239
+ ```typescript
240
+ export interface CursorControlDescription<
241
+ P = any,
242
+ > extends BaseControlDescription<P> {
243
+ type: ControlType.Cursor;
244
+ defaultValue?: string;
245
+ }
246
+ ```
247
+
248
+ ### Padding Control
249
+
250
+ ```typescript
251
+ export interface PaddingControlDescription<
252
+ P = any,
253
+ > extends BaseControlDescription<P> {
254
+ type: ControlType.Padding;
255
+ defaultValue?: string;
256
+ }
257
+ ```
258
+
259
+ ### Border Radius Control
260
+
261
+ ```typescript
262
+ export interface BorderRadiusControlDescription<
263
+ P = any,
264
+ > extends BaseControlDescription<P> {
265
+ type: ControlType.BorderRadius;
266
+ defaultValue?: string;
267
+ }
268
+ ```
269
+
270
+ ### Gap Control
271
+
272
+ ```typescript
273
+ export interface GapControlDescription<
274
+ P = any,
275
+ > extends BaseControlDescription<P> {
276
+ type: ControlType.Gap;
277
+ defaultValue?: string;
278
+ }
279
+ ```
280
+
281
+ ### Tracking ID Control
282
+
283
+ ```typescript
284
+ export interface TrackingIdControlDescription<
285
+ P = any,
286
+ > extends BaseControlDescription<P> {
287
+ type: ControlType.TrackingId;
288
+ defaultValue?: string;
289
+ }
290
+ ```
291
+
292
+ ### Font Control
293
+
294
+ ```typescript
295
+ interface FontControlDescriptionBase<
296
+ P = any,
297
+ > extends BaseControlDescription<P> {
298
+ type: ControlType.Font;
299
+ controls?: "basic" | "extended";
300
+ displayTextAlignment?: boolean;
301
+ displayFontSize?: boolean;
302
+ defaultValue?: FontControlDefaultValueBase;
303
+ }
304
+
305
+ interface FontControlDescriptionSansSerif<
306
+ P = any,
307
+ > extends FontControlDescriptionBase<P> {
308
+ defaultFontType?: "sans-serif";
309
+ defaultValue?: FontControlDefaultValueWithVariant;
310
+ }
311
+
312
+ interface FontControlDescriptionSerif<
313
+ P = any,
314
+ > extends FontControlDescriptionBase<P> {
315
+ defaultFontType?: "serif";
316
+ defaultValue?: FontControlDefaultValueBase;
317
+ }
318
+
319
+ interface FontControlDescriptionMonospace<
320
+ P = any,
321
+ > extends FontControlDescriptionBase<P> {
322
+ defaultFontType?: "monospace";
323
+ defaultValue?: FontControlDefaultValueBase;
324
+ }
325
+
326
+ export type FontControlDescription<P = any> =
327
+ | FontControlDescriptionSansSerif<P>
328
+ | FontControlDescriptionSerif<P>
329
+ | FontControlDescriptionMonospace<P>;
330
+
331
+ interface FontControlDefaultValueBase {
332
+ textAlign?: "left" | "right" | "center" | "justify";
333
+ fontSize?: string | number;
334
+ letterSpacing?: string | number;
335
+ lineHeight?: string | number;
336
+ }
337
+
338
+ interface FontControlDefaultValueWithVariant extends FontControlDefaultValueBase {
339
+ variant?: FramerFontVariant;
340
+ }
341
+
342
+ export const framerFontVariants = [
343
+ "Regular",
344
+ "Thin",
345
+ "Extra Light",
346
+ "Light",
347
+ "Medium",
348
+ "Semibold",
349
+ "Bold",
350
+ "Extra Bold",
351
+ "Black",
352
+ "Thin Italic",
353
+ "Extra Light Italic",
354
+ "Light Italic",
355
+ "Italic",
356
+ "Medium Italic",
357
+ "Semibold Italic",
358
+ "Bold Italic",
359
+ "Extra Bold Italic",
360
+ "Black Italic",
361
+ "Regular Italic",
362
+ "Variable",
363
+ "Variable Italic",
364
+ ] as const;
365
+
366
+ export type FramerFontVariant = (typeof framerFontVariants)[number];
367
+ ```
368
+
369
+ ## Composite Types
370
+
371
+ ### All Control Types
372
+
373
+ ```typescript
374
+ export type ControlDescription<P = any> =
375
+ | NumberControlDescription<P>
376
+ | EnumControlDescription<P>
377
+ | BooleanControlDescription<P>
378
+ | StringControlDescription<P>
379
+ | ColorControlDescription<P>
380
+ | ResponsiveImageControlDescription<P>
381
+ | FileControlDescription<P>
382
+ | SlotControlDescription<P>
383
+ | ArrayControlDescription<P>
384
+ | EventHandlerControlDescription<P>
385
+ | TransitionControlDescription<P>
386
+ | BoxShadowControlDescription<P>
387
+ | LinkControlDescription<P>
388
+ | DateControlDescription<P>
389
+ | ObjectControlDescription<P>
390
+ | FontControlDescription<P>
391
+ | BorderControlDescription<P>
392
+ | CursorControlDescription<P>
393
+ | PaddingControlDescription<P>
394
+ | BorderRadiusControlDescription<P>
395
+ | GapControlDescription<P>
396
+ | TrackingIdControlDescription<P>;
397
+ ```
398
+
399
+ ### Property Controls
400
+
401
+ ```typescript
402
+ export type PropertyControls<ComponentProps = any, ArrayTypes = any> = {
403
+ [K in keyof ComponentProps]?: ControlDescription<Partial<ComponentProps>>;
404
+ };
405
+ ```
406
+
407
+ ## Associated Methods and Types
408
+
409
+ ### addPropertyControls
410
+
411
+ ```typescript
412
+ export declare function addPropertyControls<Props = any>(
413
+ component:
414
+ | React.ComponentType<Props>
415
+ | React.ForwardRefExoticComponent<Props>,
416
+ propertyControls: PropertyControls<Props>,
417
+ ): void;
418
+ ```
419
+
420
+ ### addFonts
421
+
422
+ ```typescript
423
+ export declare function addFonts(
424
+ component: React.ComponentType<unknown>,
425
+ fonts: any[],
426
+ flags?: { supportsExplicitInterCodegen?: boolean },
427
+ ): void;
428
+ ```
429
+
430
+ ### Data API
431
+
432
+ ```typescript
433
+ export declare const Data: {
434
+ <T extends object = object>(initial?: Partial<T> | object): T;
435
+ };
436
+ ```
437
+
438
+ ### Renderer Detection APIs
439
+
440
+ ```typescript
441
+ export declare type RenderTarget = RenderTargetName;
442
+
443
+ export declare const RenderTarget: {
444
+ canvas: RenderTargetName;
445
+ export: RenderTargetName;
446
+ thumbnail: RenderTargetName;
447
+ preview: RenderTargetName;
448
+ current: () => RenderTargetName;
449
+ hasRestrictions: () => boolean;
450
+ };
451
+
452
+ /** Check if executed in a Framer Canvas or Export Canvas environment */
453
+ export declare function isStaticRenderer(): boolean;
454
+
455
+ /** Hook to check if in a static renderer (Canvas or Export) */
456
+ export declare function useIsStaticRenderer(): boolean;
457
+
458
+ /** Hook to observe data changes */
459
+ export declare function useObserveData(): boolean;
460
+ ```
461
+
462
+ ### Color Interface and Utilities
463
+
464
+ ```typescript
465
+ export interface Color {
466
+ r: number;
467
+ g: number;
468
+ b: number;
469
+ h: number;
470
+ s: number;
471
+ l: number;
472
+ a: number;
473
+ roundA: number;
474
+ format: ColorFormat;
475
+ initialValue?: string;
476
+ isValid?: boolean;
477
+ mix: any;
478
+ toValue: () => string;
479
+ }
480
+
481
+ export enum ColorFormat {
482
+ RGB = "rgb",
483
+ HSL = "hsl",
484
+ HSV = "hsv",
485
+ HEX = "hex",
486
+ NAME = "name",
487
+ }
488
+ ```