@plasmicapp/host 1.0.136 → 1.0.138
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/exports.d.ts +2 -1
- package/dist/fetcher.d.ts +1 -1
- package/dist/host.esm.js +1 -1
- package/dist/host.esm.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/prop-types.d.ts +387 -0
- package/dist/registerComponent.d.ts +2 -368
- package/dist/registerGlobalContext.d.ts +4 -3
- package/dist/version.d.ts +1 -1
- package/package.json +2 -2
- package/registerComponent/dist/canvas-host.d.ts +41 -0
- package/registerComponent/dist/common.d.ts +1 -0
- package/registerComponent/dist/data.d.ts +43 -0
- package/registerComponent/dist/exports.d.ts +11 -0
- package/registerComponent/dist/fetcher.d.ts +40 -0
- package/registerComponent/dist/global-actions.d.ts +9 -0
- package/registerComponent/dist/index.cjs.js.map +1 -1
- package/registerComponent/dist/index.d.ts +1 -0
- package/registerComponent/dist/index.esm.js.map +1 -1
- package/registerComponent/dist/lang-utils.d.ts +3 -0
- package/registerComponent/dist/prop-types.d.ts +387 -0
- package/registerComponent/dist/registerComponent.d.ts +2 -368
- package/registerComponent/dist/registerGlobalContext.d.ts +76 -0
- package/registerComponent/dist/registerToken.d.ts +13 -0
- package/registerComponent/dist/registerTrait.d.ts +20 -0
- package/registerComponent/dist/repeatedElement.d.ts +15 -0
- package/registerComponent/dist/useForceUpdate.d.ts +1 -0
- package/registerComponent/dist/version.d.ts +1 -0
- package/registerGlobalContext/dist/canvas-host.d.ts +41 -0
- package/registerGlobalContext/dist/common.d.ts +1 -0
- package/registerGlobalContext/dist/data.d.ts +43 -0
- package/registerGlobalContext/dist/exports.d.ts +11 -0
- package/registerGlobalContext/dist/fetcher.d.ts +40 -0
- package/registerGlobalContext/dist/global-actions.d.ts +9 -0
- package/registerGlobalContext/dist/index.cjs.js.map +1 -1
- package/registerGlobalContext/dist/index.d.ts +1 -0
- package/registerGlobalContext/dist/index.esm.js.map +1 -1
- package/registerGlobalContext/dist/lang-utils.d.ts +3 -0
- package/registerGlobalContext/dist/prop-types.d.ts +387 -0
- package/registerGlobalContext/dist/registerComponent.d.ts +2 -368
- package/registerGlobalContext/dist/registerGlobalContext.d.ts +4 -3
- package/registerGlobalContext/dist/registerToken.d.ts +13 -0
- package/registerGlobalContext/dist/registerTrait.d.ts +20 -0
- package/registerGlobalContext/dist/repeatedElement.d.ts +15 -0
- package/registerGlobalContext/dist/useForceUpdate.d.ts +1 -0
- package/registerGlobalContext/dist/version.d.ts +1 -0
- package/registerToken/dist/canvas-host.d.ts +41 -0
- package/registerToken/dist/common.d.ts +1 -0
- package/registerToken/dist/data.d.ts +43 -0
- package/registerToken/dist/element-types.d.ts +115 -0
- package/registerToken/dist/exports.d.ts +11 -0
- package/registerToken/dist/fetcher.d.ts +40 -0
- package/registerToken/dist/global-actions.d.ts +9 -0
- package/registerToken/dist/index.d.ts +1 -0
- package/registerToken/dist/lang-utils.d.ts +3 -0
- package/registerToken/dist/prop-types.d.ts +387 -0
- package/registerToken/dist/registerComponent.d.ts +231 -0
- package/registerToken/dist/registerGlobalContext.d.ts +76 -0
- package/registerToken/dist/registerTrait.d.ts +20 -0
- package/registerToken/dist/repeatedElement.d.ts +15 -0
- package/registerToken/dist/useForceUpdate.d.ts +1 -0
- package/registerToken/dist/version.d.ts +1 -0
- package/registerTrait/dist/canvas-host.d.ts +41 -0
- package/registerTrait/dist/common.d.ts +1 -0
- package/registerTrait/dist/data.d.ts +43 -0
- package/registerTrait/dist/element-types.d.ts +115 -0
- package/registerTrait/dist/exports.d.ts +11 -0
- package/registerTrait/dist/fetcher.d.ts +40 -0
- package/registerTrait/dist/global-actions.d.ts +9 -0
- package/registerTrait/dist/index.d.ts +1 -0
- package/registerTrait/dist/lang-utils.d.ts +3 -0
- package/registerTrait/dist/prop-types.d.ts +387 -0
- package/registerTrait/dist/registerComponent.d.ts +231 -0
- package/registerTrait/dist/registerGlobalContext.d.ts +76 -0
- package/registerTrait/dist/registerToken.d.ts +13 -0
- package/registerTrait/dist/repeatedElement.d.ts +15 -0
- package/registerTrait/dist/useForceUpdate.d.ts +1 -0
- package/registerTrait/dist/version.d.ts +1 -0
|
@@ -1,372 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CodeComponentElement, CSSProperties, PlasmicElement } from "./element-types";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* This prop is only provided within the canvas of Plasmic Studio.
|
|
6
|
-
* Allows the component to set data to be consumed by the props' controls.
|
|
7
|
-
*/
|
|
8
|
-
setControlContextData?: (data: Data) => void;
|
|
9
|
-
}
|
|
10
|
-
type InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;
|
|
11
|
-
export type ControlExtras = {
|
|
12
|
-
path: (string | number)[];
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Context that we pass back to control functions.
|
|
16
|
-
*/
|
|
17
|
-
export type ControlContext<P> = [
|
|
18
|
-
/**
|
|
19
|
-
* props
|
|
20
|
-
*/
|
|
21
|
-
P,
|
|
22
|
-
/**
|
|
23
|
-
* `contextData` can be `null` if the prop controls are rendering before
|
|
24
|
-
* the component instance itself (it will re-render once the component
|
|
25
|
-
* calls `setControlContextData`)
|
|
26
|
-
*/
|
|
27
|
-
InferDataType<P> | null,
|
|
28
|
-
/**
|
|
29
|
-
* Extra information for the control to use
|
|
30
|
-
*/
|
|
31
|
-
ControlExtras
|
|
32
|
-
];
|
|
33
|
-
/**
|
|
34
|
-
* Config option that takes the context (e.g., props) of the component instance
|
|
35
|
-
* to dynamically set its value.
|
|
36
|
-
*/
|
|
37
|
-
export type ContextDependentConfig<P, R> = (...args: ControlContext<P>) => R;
|
|
38
|
-
export interface PropTypeBase<P> {
|
|
39
|
-
displayName?: string;
|
|
40
|
-
description?: string;
|
|
41
|
-
helpText?: string;
|
|
42
|
-
/**
|
|
43
|
-
* If the user has chosen to use a dynamic expression for this prop, provide
|
|
44
|
-
* a hint as to the expected values that the expression should evaluate to.
|
|
45
|
-
* This hint will be displayed alongside the code editor. You may use
|
|
46
|
-
* markdown in the text here.
|
|
47
|
-
*/
|
|
48
|
-
exprHint?: string;
|
|
49
|
-
/**
|
|
50
|
-
* Function for whether this prop should be hidden in the right panel,
|
|
51
|
-
* given the current props for this component
|
|
52
|
-
*/
|
|
53
|
-
hidden?: ContextDependentConfig<P, boolean>;
|
|
54
|
-
readOnly?: boolean | ContextDependentConfig<P, boolean>;
|
|
55
|
-
/**
|
|
56
|
-
* If true, will hide the prop in a collapsed section; good for props that
|
|
57
|
-
* should not usually be used.
|
|
58
|
-
*/
|
|
59
|
-
advanced?: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* If true, does not allow the user to use a dynamic expression for this prop
|
|
62
|
-
*/
|
|
63
|
-
disableDynamicValue?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* If set to true, the component will be remounted when the prop value is updated.
|
|
66
|
-
* (This behavior only appliees to canvas)
|
|
67
|
-
*/
|
|
68
|
-
forceRemount?: boolean;
|
|
69
|
-
}
|
|
70
|
-
export type DefaultValueOrExpr<P, T> = {
|
|
71
|
-
defaultExpr?: undefined;
|
|
72
|
-
defaultExprHint?: undefined;
|
|
73
|
-
defaultValue?: T;
|
|
74
|
-
defaultValueHint?: T | ContextDependentConfig<P, T | undefined>;
|
|
75
|
-
} | {
|
|
76
|
-
defaultValue?: undefined;
|
|
77
|
-
defaultValueHint?: undefined;
|
|
78
|
-
defaultExpr?: string;
|
|
79
|
-
defaultExprHint?: string;
|
|
80
|
-
};
|
|
81
|
-
type StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, string>;
|
|
82
|
-
export type StringType<P> = "string" | (({
|
|
83
|
-
type: "string";
|
|
84
|
-
control?: "default" | "large";
|
|
85
|
-
} | {
|
|
86
|
-
type: "code";
|
|
87
|
-
lang: "css" | "html" | "javascript" | "json";
|
|
88
|
-
} | {
|
|
89
|
-
type: "richText";
|
|
90
|
-
} | {
|
|
91
|
-
type: "color";
|
|
92
|
-
/**
|
|
93
|
-
* If specified, and the user picks a color token in the Studio, then
|
|
94
|
-
* the value passed in as prop is a css variable reference, like
|
|
95
|
-
* `var(--TOKEN_ID)`, instead of the resolved hex value of the token.
|
|
96
|
-
* You should take care in using this in the proper css context --
|
|
97
|
-
* the css token is only defined if you are rendering under some
|
|
98
|
-
* Plasmic component in the DOM tree, which is usually the case,
|
|
99
|
-
* unless you are using a React portal.
|
|
100
|
-
*/
|
|
101
|
-
keepCssVar?: boolean;
|
|
102
|
-
} | {
|
|
103
|
-
type: "class";
|
|
104
|
-
/**
|
|
105
|
-
* Additional css selectors that can change how this style should look.
|
|
106
|
-
* Some examples:
|
|
107
|
-
*
|
|
108
|
-
* * `:hover` -- on hover
|
|
109
|
-
* * `[data-something="blah"] -- when the element with this class has
|
|
110
|
-
* an html attribute "data-something=blah"
|
|
111
|
-
* * :component[data-something="blah"] :self -- when the root of the
|
|
112
|
-
* component has an html attribute "data-something=blah". Note that
|
|
113
|
-
* the non-standard `:component` selector is used to select the
|
|
114
|
-
* component root, and the non-standard `:self` selector is used
|
|
115
|
-
* to select the element that this class is attached to.
|
|
116
|
-
*/
|
|
117
|
-
selectors?: {
|
|
118
|
-
/**
|
|
119
|
-
* A css selector, like `:hover` or `[data-something="blah"]`.
|
|
120
|
-
*/
|
|
121
|
-
selector: string;
|
|
122
|
-
/**
|
|
123
|
-
* An optional human-friendly label for the selector, so the studio user
|
|
124
|
-
* knows what this selector means.
|
|
125
|
-
*/
|
|
126
|
-
label?: string;
|
|
127
|
-
}[];
|
|
128
|
-
/**
|
|
129
|
-
* If specified, then only shows these style sections for styling this class
|
|
130
|
-
*/
|
|
131
|
-
styleSections?: StyleSection[];
|
|
132
|
-
} | {
|
|
133
|
-
type: "themeResetClass";
|
|
134
|
-
/**
|
|
135
|
-
* Normally, theme reset class will only target Plasmic-generated tags
|
|
136
|
-
* with the default tag styles. If you also want to target non-Plasmic-generated
|
|
137
|
-
* tags (say, rendered by your code components, or fetched as an HTML blob
|
|
138
|
-
* from somewhere), then specify `true` here.
|
|
139
|
-
*/
|
|
140
|
-
targetAllTags?: boolean;
|
|
141
|
-
} | {
|
|
142
|
-
type: "cardPicker";
|
|
143
|
-
modalTitle?: React.ReactNode | ContextDependentConfig<P, React.ReactNode>;
|
|
144
|
-
options: {
|
|
145
|
-
value: string;
|
|
146
|
-
label?: string;
|
|
147
|
-
imgUrl: string;
|
|
148
|
-
footer?: React.ReactNode;
|
|
149
|
-
}[] | ContextDependentConfig<P, {
|
|
150
|
-
value: string;
|
|
151
|
-
label?: string;
|
|
152
|
-
imgUrl: string;
|
|
153
|
-
footer?: React.ReactNode;
|
|
154
|
-
}[]>;
|
|
155
|
-
showInput?: boolean | ContextDependentConfig<P, boolean>;
|
|
156
|
-
onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;
|
|
157
|
-
}) & StringTypeBase<P>);
|
|
158
|
-
export type BooleanType<P> = "boolean" | ({
|
|
159
|
-
type: "boolean";
|
|
160
|
-
} & DefaultValueOrExpr<P, boolean> & PropTypeBase<P>);
|
|
161
|
-
type GraphQLValue = {
|
|
162
|
-
query: string;
|
|
163
|
-
variables?: Record<string, any>;
|
|
164
|
-
};
|
|
165
|
-
export type GraphQLType<P> = {
|
|
166
|
-
type: "code";
|
|
167
|
-
lang: "graphql";
|
|
168
|
-
endpoint: string | ContextDependentConfig<P, string>;
|
|
169
|
-
method?: string | ContextDependentConfig<P, string>;
|
|
170
|
-
headers?: object | ContextDependentConfig<P, object>;
|
|
171
|
-
} & DefaultValueOrExpr<P, GraphQLValue> & PropTypeBase<P>;
|
|
172
|
-
type NumberTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, number> & {
|
|
173
|
-
type: "number";
|
|
174
|
-
};
|
|
175
|
-
export type NumberType<P> = "number" | (({
|
|
176
|
-
control?: "default";
|
|
177
|
-
min?: number | ContextDependentConfig<P, number>;
|
|
178
|
-
max?: number | ContextDependentConfig<P, number>;
|
|
179
|
-
} | {
|
|
180
|
-
control: "slider";
|
|
181
|
-
min: number | ContextDependentConfig<P, number>;
|
|
182
|
-
max: number | ContextDependentConfig<P, number>;
|
|
183
|
-
step?: number | ContextDependentConfig<P, number>;
|
|
184
|
-
}) & NumberTypeBase<P>);
|
|
185
|
-
/**
|
|
186
|
-
* Expects defaultValue to be a JSON-compatible value
|
|
187
|
-
*/
|
|
188
|
-
export type JSONLikeType<P> = "object" | ({
|
|
189
|
-
type: "object";
|
|
190
|
-
fields?: {
|
|
191
|
-
[p: string]: PropType<P>;
|
|
192
|
-
};
|
|
193
|
-
/**
|
|
194
|
-
* Optional function that generates a name for this item in the array
|
|
195
|
-
*/
|
|
196
|
-
nameFunc?: (item: any, ...args: ControlContext<P>) => string | undefined;
|
|
197
|
-
} & DefaultValueOrExpr<P, any> & PropTypeBase<P>) | ({
|
|
198
|
-
type: "array";
|
|
199
|
-
itemType?: {
|
|
200
|
-
type: "object";
|
|
201
|
-
fields: {
|
|
202
|
-
[p: string]: PropType<P>;
|
|
203
|
-
};
|
|
204
|
-
/**
|
|
205
|
-
* Optional function that generates a name for this item in the array
|
|
206
|
-
*/
|
|
207
|
-
nameFunc?: (item: any, ...args: ControlContext<P>) => string | undefined;
|
|
208
|
-
};
|
|
209
|
-
/**
|
|
210
|
-
* Optional function that determines whether the user can delete a given item.
|
|
211
|
-
*/
|
|
212
|
-
unstable__canDelete?: (item: any, ...args: ControlContext<P>) => boolean;
|
|
213
|
-
/**
|
|
214
|
-
* Specify how to let Plasmic know how to update its own internal representation of the data when the value has
|
|
215
|
-
* changed, or when issuing a minimalValue or shownValue that is different.
|
|
216
|
-
*
|
|
217
|
-
* Important to specify this if you are expecting any nested expression values in this data type!
|
|
218
|
-
*/
|
|
219
|
-
unstable__keyFunc?: (item: any) => any;
|
|
220
|
-
/**
|
|
221
|
-
* Specify what would be the tentative new value that is set if the user makes any changes.
|
|
222
|
-
*
|
|
223
|
-
* Useful for field mappings.
|
|
224
|
-
*
|
|
225
|
-
* For instance, consider a Table where we have a `fields` prop:
|
|
226
|
-
*
|
|
227
|
-
* - Initially, the value is undefined. But if the user makes any changes, we would want to save an array of at
|
|
228
|
-
* least three items (corresponding to, say, three columns inferred from a schema).
|
|
229
|
-
*
|
|
230
|
-
* - Let's say there are 5 columns in the value. The data schema changes, removing a column and adding two new
|
|
231
|
-
* ones. Now we would want a different minimal value, containing 6 items.
|
|
232
|
-
*/
|
|
233
|
-
unstable__minimalValue?: ContextDependentConfig<P, any>;
|
|
234
|
-
} & DefaultValueOrExpr<P, any[]> & PropTypeBase<P>) | ({
|
|
235
|
-
type: "dataSource";
|
|
236
|
-
dataSource: "airtable" | "cms";
|
|
237
|
-
} & PropTypeBase<P>);
|
|
238
|
-
type DataPickerValueType = string | number | (string | number)[];
|
|
239
|
-
export type DataPickerType<P> = ({
|
|
240
|
-
type: "dataSelector";
|
|
241
|
-
data: Record<string, any> | ContextDependentConfig<P, Record<string, any>>;
|
|
242
|
-
alwaysShowValuePathAsLabel?: boolean;
|
|
243
|
-
} & DefaultValueOrExpr<P, DataPickerValueType> & PropTypeBase<P>) | ({
|
|
244
|
-
type: "exprEditor";
|
|
245
|
-
data: Record<string, any> | ContextDependentConfig<P, Record<string, any>>;
|
|
246
|
-
} & DefaultValueOrExpr<P, DataPickerValueType> & PropTypeBase<P>);
|
|
247
|
-
export type FormValidationRulesType<P> = {
|
|
248
|
-
type: "formValidationRules";
|
|
249
|
-
} & DefaultValueOrExpr<P, any> & PropTypeBase<P>;
|
|
250
|
-
export type EventHandlerType<P> = {
|
|
251
|
-
type: "eventHandler";
|
|
252
|
-
argTypes: {
|
|
253
|
-
name: string;
|
|
254
|
-
type: PropType<any>;
|
|
255
|
-
}[];
|
|
256
|
-
} & DefaultValueOrExpr<P, (...args: any) => any> & PropTypeBase<P>;
|
|
257
|
-
interface ChoiceTypeBase<P> extends PropTypeBase<P> {
|
|
258
|
-
type: "choice";
|
|
259
|
-
options: string[] | {
|
|
260
|
-
label: string;
|
|
261
|
-
value: string | number | boolean;
|
|
262
|
-
}[] | ContextDependentConfig<P, string[] | {
|
|
263
|
-
label: string;
|
|
264
|
-
value: string | number | boolean;
|
|
265
|
-
}[]>;
|
|
266
|
-
allowSearch?: boolean;
|
|
267
|
-
filterOption?: boolean;
|
|
268
|
-
onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;
|
|
269
|
-
}
|
|
270
|
-
export type ChoiceType<P> = (({
|
|
271
|
-
multiSelect?: false;
|
|
272
|
-
} & DefaultValueOrExpr<P, string | number | boolean>) | ({
|
|
273
|
-
multiSelect: true;
|
|
274
|
-
} & DefaultValueOrExpr<P, (string | number | boolean)[]>) | ({
|
|
275
|
-
multiSelect: ContextDependentConfig<P, boolean>;
|
|
276
|
-
} & DefaultValueOrExpr<P, string | number | boolean | (string | number | boolean)[]>)) & ChoiceTypeBase<P>;
|
|
277
|
-
export interface ModalProps {
|
|
278
|
-
show?: boolean;
|
|
279
|
-
children?: React.ReactNode;
|
|
280
|
-
onClose: () => void;
|
|
281
|
-
style?: CSSProperties;
|
|
282
|
-
}
|
|
283
|
-
interface CustomControlProps<P> {
|
|
284
|
-
componentProps: P;
|
|
285
|
-
/**
|
|
286
|
-
* `contextData` can be `null` if the prop controls are rendering before
|
|
287
|
-
* the component instance itself (it will re-render once the component
|
|
288
|
-
* calls `setControlContextData`)
|
|
289
|
-
*/
|
|
290
|
-
contextData: InferDataType<P> | null;
|
|
291
|
-
value: any;
|
|
292
|
-
/**
|
|
293
|
-
* Sets the value to be passed to the prop. Expects a JSON-compatible value.
|
|
294
|
-
*/
|
|
295
|
-
updateValue: (newVal: any) => void;
|
|
296
|
-
/**
|
|
297
|
-
* Full screen modal component
|
|
298
|
-
*/
|
|
299
|
-
FullscreenModal: React.ComponentType<ModalProps>;
|
|
300
|
-
/**
|
|
301
|
-
* Modal component for the side pane
|
|
302
|
-
*/
|
|
303
|
-
SideModal: React.ComponentType<ModalProps>;
|
|
304
|
-
/**
|
|
305
|
-
* The document that the component will be rendered into; instead of using
|
|
306
|
-
* `document` directly (for, say, `document.querySelector()` etc.), you
|
|
307
|
-
* should use this instead.
|
|
308
|
-
*/
|
|
309
|
-
studioDocument: typeof document;
|
|
310
|
-
}
|
|
311
|
-
export type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;
|
|
312
|
-
/**
|
|
313
|
-
* Expects defaultValue to be a JSON-compatible value
|
|
314
|
-
*/
|
|
315
|
-
export type CustomType<P> = CustomControl<P> | ({
|
|
316
|
-
type: "custom";
|
|
317
|
-
control: CustomControl<P>;
|
|
318
|
-
} & PropTypeBase<P> & DefaultValueOrExpr<P, any>);
|
|
319
|
-
type SlotType<P> = "slot" | ({
|
|
320
|
-
type: "slot";
|
|
321
|
-
/**
|
|
322
|
-
* The unique names of all code components that can be placed in the slot
|
|
323
|
-
*/
|
|
324
|
-
allowedComponents?: string[];
|
|
325
|
-
/**
|
|
326
|
-
* Whether the "empty slot" placeholder should be hidden in the canvas.
|
|
327
|
-
*/
|
|
328
|
-
hidePlaceholder?: boolean;
|
|
329
|
-
/**
|
|
330
|
-
* Whether the slot is repeated, i.e., is rendered multiple times using
|
|
331
|
-
* repeatedElement().
|
|
332
|
-
*/
|
|
333
|
-
isRepeated?: boolean;
|
|
334
|
-
/**
|
|
335
|
-
* A nicer, human-readable display name for your slot prop
|
|
336
|
-
*/
|
|
337
|
-
displayName?: string;
|
|
338
|
-
/**
|
|
339
|
-
* Function for whether this slot should be hidden from the left tree,
|
|
340
|
-
* given the current props for this component
|
|
341
|
-
*/
|
|
342
|
-
hidden?: ContextDependentConfig<P, boolean>;
|
|
343
|
-
/**
|
|
344
|
-
* If slot is a render prop (accepts a function that takes in some
|
|
345
|
-
* arguments and returns some JSX), then specify the names of the
|
|
346
|
-
* arguments expected by the render prop function.
|
|
347
|
-
*/
|
|
348
|
-
renderPropParams?: string[];
|
|
349
|
-
/**
|
|
350
|
-
* When inserting top-level "page sections", should this slot be the default target?
|
|
351
|
-
*/
|
|
352
|
-
unstable__isMainContentSlot?: boolean;
|
|
353
|
-
} & Omit<DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>, "defaultValueHint" | "defaultExpr" | "defaultExprHint">);
|
|
354
|
-
type ImageUrlType<P> = "imageUrl" | ({
|
|
355
|
-
type: "imageUrl";
|
|
356
|
-
} & DefaultValueOrExpr<P, string> & PropTypeBase<P>);
|
|
357
|
-
export type PrimitiveType<P = any> = Extract<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>, string>;
|
|
358
|
-
type ControlTypeBase = {
|
|
359
|
-
editOnly?: false;
|
|
360
|
-
} | {
|
|
361
|
-
editOnly: true;
|
|
362
|
-
/**
|
|
363
|
-
* The prop where the values should be mapped to
|
|
364
|
-
*/
|
|
365
|
-
uncontrolledProp?: string;
|
|
366
|
-
};
|
|
367
|
-
export type SupportControlled<T> = Extract<T, string | CustomControl<any>> | (Exclude<T, string | CustomControl<any>> & ControlTypeBase);
|
|
368
|
-
export type PropType<P> = SupportControlled<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | ImageUrlType<P> | CustomType<P> | GraphQLType<P> | DataPickerType<P> | FormValidationRulesType<P> | EventHandlerType<P>> | SlotType<P>;
|
|
369
|
-
type RestrictPropType<T, P> = T extends string ? SupportControlled<StringType<P> | ChoiceType<P> | JSONLikeType<P> | ImageUrlType<P> | CustomType<P> | DataPickerType<P>> : T extends boolean ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P> | DataPickerType<P>> : T extends number ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P> | DataPickerType<P>> : PropType<P>;
|
|
3
|
+
import { ContextDependentConfig, InferDataType, ModalProps, PropType, RestrictPropType } from "./prop-types";
|
|
4
|
+
export type { CanvasComponentProps, ControlExtras, ControlContext, ContextDependentConfig, PropType, } from "./prop-types";
|
|
370
5
|
export interface ActionProps<P> {
|
|
371
6
|
componentProps: P;
|
|
372
7
|
/**
|
|
@@ -594,4 +229,3 @@ declare global {
|
|
|
594
229
|
}
|
|
595
230
|
}
|
|
596
231
|
export default function registerComponent<T extends React.ComponentType<any>>(component: T, meta: CodeComponentMeta<React.ComponentProps<T>>): void;
|
|
597
|
-
export {};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { BooleanType, ChoiceType, CustomType, JSONLikeType, NumberType, StringType, DataSourceType } from "./prop-types";
|
|
3
|
+
import { FunctionParam } from "./registerComponent";
|
|
4
|
+
export type PropType<P> = StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | CustomType<P> | DataSourceType<P>;
|
|
5
|
+
type RestrictPropType<T, P> = T extends string ? StringType<P> | ChoiceType<P> | JSONLikeType<P> | CustomType<P> : T extends boolean ? BooleanType<P> | JSONLikeType<P> | CustomType<P> : T extends number ? NumberType<P> | JSONLikeType<P> | CustomType<P> : PropType<P>;
|
|
6
|
+
type DistributedKeyOf<T> = T extends any ? keyof T : never;
|
|
7
|
+
export interface GlobalContextMeta<P> {
|
|
8
|
+
/**
|
|
9
|
+
* Any unique string name used to identify that context. Each context
|
|
10
|
+
* should be registered with a different `meta.name`, even if they have the
|
|
11
|
+
* same name in the code.
|
|
12
|
+
*/
|
|
13
|
+
name: string;
|
|
14
|
+
/**
|
|
15
|
+
* The name to be displayed for the context in Studio. Optional: if not
|
|
16
|
+
* specified, `meta.name` is used.
|
|
17
|
+
*/
|
|
18
|
+
displayName?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The description of the context to be shown in Studio.
|
|
21
|
+
*/
|
|
22
|
+
description?: string;
|
|
23
|
+
/**
|
|
24
|
+
* The javascript name to be used when generating code. Optional: if not
|
|
25
|
+
* provided, `meta.name` is used.
|
|
26
|
+
*/
|
|
27
|
+
importName?: string;
|
|
28
|
+
/**
|
|
29
|
+
* An object describing the context properties to be used in Studio.
|
|
30
|
+
* For each `prop`, there should be an entry `meta.props[prop]` describing
|
|
31
|
+
* its type.
|
|
32
|
+
*/
|
|
33
|
+
props: {
|
|
34
|
+
[prop in DistributedKeyOf<P>]?: RestrictPropType<P[prop], P>;
|
|
35
|
+
} & {
|
|
36
|
+
[prop: string]: PropType<P>;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The path to be used when importing the context in the generated code.
|
|
40
|
+
* It can be the name of the package that contains the context, or the path
|
|
41
|
+
* to the file in the project (relative to the root directory).
|
|
42
|
+
*/
|
|
43
|
+
importPath: string;
|
|
44
|
+
/**
|
|
45
|
+
* Whether the context is the default export from that path. Optional: if
|
|
46
|
+
* not specified, it's considered `false`.
|
|
47
|
+
*/
|
|
48
|
+
isDefaultExport?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The prop that receives and forwards a React `ref`. Plasmic only uses `ref`
|
|
51
|
+
* to interact with components, so it's not used in the generated code.
|
|
52
|
+
* Optional: If not provided, the usual `ref` is used.
|
|
53
|
+
*/
|
|
54
|
+
refProp?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Whether the global context provides data to its children using DataProvider.
|
|
57
|
+
*/
|
|
58
|
+
providesData?: boolean;
|
|
59
|
+
unstable__globalActions?: Record<string, GlobalActionRegistration<P>>;
|
|
60
|
+
}
|
|
61
|
+
export interface GlobalContextRegistration {
|
|
62
|
+
component: React.ComponentType<any>;
|
|
63
|
+
meta: GlobalContextMeta<any>;
|
|
64
|
+
}
|
|
65
|
+
export interface GlobalActionRegistration<P> {
|
|
66
|
+
displayName?: string;
|
|
67
|
+
description?: string;
|
|
68
|
+
parameters: FunctionParam<P>[];
|
|
69
|
+
}
|
|
70
|
+
declare global {
|
|
71
|
+
interface Window {
|
|
72
|
+
__PlasmicContextRegistry: GlobalContextRegistration[];
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export default function registerGlobalContext<T extends React.ComponentType<any>>(component: T, meta: GlobalContextMeta<React.ComponentProps<T>>): void;
|
|
76
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type TokenType = "color" | "spacing" | "font-family" | "font-size" | "line-height" | "opacity";
|
|
2
|
+
export interface TokenRegistration {
|
|
3
|
+
name: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
value: string;
|
|
6
|
+
type: TokenType;
|
|
7
|
+
}
|
|
8
|
+
declare global {
|
|
9
|
+
interface Window {
|
|
10
|
+
__PlasmicTokenRegistry: TokenRegistration[];
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export default function registerToken(token: TokenRegistration): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface BasicTrait {
|
|
2
|
+
label?: string;
|
|
3
|
+
type: "text" | "number" | "boolean";
|
|
4
|
+
}
|
|
5
|
+
export interface ChoiceTrait {
|
|
6
|
+
label?: string;
|
|
7
|
+
type: "choice";
|
|
8
|
+
options: string[];
|
|
9
|
+
}
|
|
10
|
+
export type TraitMeta = BasicTrait | ChoiceTrait;
|
|
11
|
+
export interface TraitRegistration {
|
|
12
|
+
trait: string;
|
|
13
|
+
meta: TraitMeta;
|
|
14
|
+
}
|
|
15
|
+
declare global {
|
|
16
|
+
interface Window {
|
|
17
|
+
__PlasmicTraitRegistry: TraitRegistration[];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export default function registerTrait(trait: string, meta: TraitMeta): void;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Allows elements to be repeated in Plasmic Studio.
|
|
3
|
+
* @param index The index of the copy (starting at 0).
|
|
4
|
+
* @param elt the React element to be repeated (or an array of such).
|
|
5
|
+
*/
|
|
6
|
+
export default function repeatedElement<T>(index: number, elt: T): T;
|
|
7
|
+
/**
|
|
8
|
+
* Allows elements to be repeated in Plasmic Studio.
|
|
9
|
+
* @param isPrimary should be true for at most one instance of the element, and
|
|
10
|
+
* indicates which copy of the element will be highlighted when the element is
|
|
11
|
+
* selected in Studio.
|
|
12
|
+
* @param elt the React element to be repeated (or an array of such).
|
|
13
|
+
*/
|
|
14
|
+
export default function repeatedElement<T>(isPrimary: boolean, elt: T): T;
|
|
15
|
+
export declare const setRepeatedElementFn: (fn: typeof repeatedElement) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function useForceUpdate(): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const hostVersion = "1.0.138";
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
__PlasmicHostVersion: string;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
export declare function setPlasmicRootNode(node: React.ReactElement | null): void;
|
|
8
|
+
export interface PlasmicCanvasContextValue {
|
|
9
|
+
componentName: string | null;
|
|
10
|
+
globalVariants: Record<string, string>;
|
|
11
|
+
interactive?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* React context to detect whether the component is rendered on Plasmic editor.
|
|
15
|
+
* If not, return false.
|
|
16
|
+
* If so, return an object with more information about the component
|
|
17
|
+
*/
|
|
18
|
+
export declare const PlasmicCanvasContext: React.Context<false | PlasmicCanvasContextValue>;
|
|
19
|
+
export declare const usePlasmicCanvasContext: () => false | PlasmicCanvasContextValue;
|
|
20
|
+
interface PlasmicCanvasHostProps {
|
|
21
|
+
/**
|
|
22
|
+
* Webpack hmr uses EventSource to listen to hot reloads, but that
|
|
23
|
+
* resultsin a persistent connection from each window. In Plasmic
|
|
24
|
+
* Studio, if a project is configured to use app-hosting with a
|
|
25
|
+
* nextjs or gatsby server running in dev mode, each artboard will
|
|
26
|
+
* be holding a persistent connection to the dev server.
|
|
27
|
+
* Because browsers have a limit to how many connections can
|
|
28
|
+
* be held at a time by domain, this means after X artboards, new
|
|
29
|
+
* artboards will freeze and not load.
|
|
30
|
+
*
|
|
31
|
+
* By default, <PlasmicCanvasHost /> will globally mutate
|
|
32
|
+
* window.EventSource to avoid using EventSource for HMR, which you
|
|
33
|
+
* typically don't need for your custom host page. If you do still
|
|
34
|
+
* want to retain HRM, then youc an pass enableWebpackHmr={true}.
|
|
35
|
+
*/
|
|
36
|
+
enableWebpackHmr?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export declare const PlasmicCanvasHost: React.FunctionComponent<PlasmicCanvasHostProps>;
|
|
39
|
+
type RenderErrorListener = (err: Error) => void;
|
|
40
|
+
export declare function registerRenderErrorListener(listener: RenderErrorListener): () => void;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const tuple: <T extends any[]>(...args: T) => T;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
export type DataDict = Record<string, any>;
|
|
3
|
+
export declare const DataContext: React.Context<DataDict | undefined>;
|
|
4
|
+
export type DataMeta = {
|
|
5
|
+
hidden?: boolean;
|
|
6
|
+
label?: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function mkMetaName(name: string): string;
|
|
9
|
+
export declare function mkMetaValue(meta: Partial<DataMeta>): DataMeta;
|
|
10
|
+
export declare function applySelector(rawData: DataDict | undefined, selector: string | undefined): any;
|
|
11
|
+
export type SelectorDict = Record<string, string | undefined>;
|
|
12
|
+
export declare function useSelector(selector: string | undefined): any;
|
|
13
|
+
export declare function useSelectors(selectors?: SelectorDict): any;
|
|
14
|
+
export declare function useDataEnv(): DataDict | undefined;
|
|
15
|
+
export interface DataProviderProps {
|
|
16
|
+
/**
|
|
17
|
+
* Key to set in data context.
|
|
18
|
+
*/
|
|
19
|
+
name?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Value to set for `name` in data context.
|
|
22
|
+
*/
|
|
23
|
+
data?: any;
|
|
24
|
+
/**
|
|
25
|
+
* If true, hide this entry in studio (data binding).
|
|
26
|
+
*/
|
|
27
|
+
hidden?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Label to be shown in the studio data picker for easier navigation (data binding).
|
|
30
|
+
*/
|
|
31
|
+
label?: string;
|
|
32
|
+
children?: ReactNode;
|
|
33
|
+
}
|
|
34
|
+
export declare function DataProvider({ name, data, hidden, label, children, }: DataProviderProps): JSX.Element;
|
|
35
|
+
export interface PageParamsProviderProps {
|
|
36
|
+
params?: Record<string, string | string[] | undefined>;
|
|
37
|
+
query?: Record<string, string | string[] | undefined>;
|
|
38
|
+
children?: ReactNode;
|
|
39
|
+
}
|
|
40
|
+
export declare function PageParamsProvider({ children, params, query, }: PageParamsProviderProps): JSX.Element;
|
|
41
|
+
export declare function DataCtxReader({ children, }: {
|
|
42
|
+
children: ($ctx: DataDict | undefined) => ReactNode;
|
|
43
|
+
}): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { PlasmicCanvasContext, PlasmicCanvasHost, usePlasmicCanvasContext, } from "./canvas-host";
|
|
2
|
+
export * from "./data";
|
|
3
|
+
export { PlasmicElement } from "./element-types";
|
|
4
|
+
export { registerFetcher as unstable_registerFetcher } from "./fetcher";
|
|
5
|
+
export * from "./global-actions";
|
|
6
|
+
export { Action, ActionProps, CodeComponentMeta, ComponentHelpers, ComponentMeta, ComponentRegistration, ComponentTemplates, default as registerComponent, StateHelpers, StateSpec, CodeComponentMode, } from "./registerComponent";
|
|
7
|
+
export { PropType, ContextDependentConfig } from "./prop-types";
|
|
8
|
+
export { default as registerGlobalContext, GlobalContextMeta, GlobalContextRegistration, PropType as GlobalContextPropType, } from "./registerGlobalContext";
|
|
9
|
+
export { default as registerToken, TokenRegistration, TokenType, } from "./registerToken";
|
|
10
|
+
export { BasicTrait, ChoiceTrait, default as registerTrait, TraitMeta, TraitRegistration, } from "./registerTrait";
|
|
11
|
+
export { default as repeatedElement } from "./repeatedElement";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PrimitiveType } from "./prop-types";
|
|
2
|
+
export type Fetcher = (...args: any[]) => Promise<any>;
|
|
3
|
+
export interface FetcherMeta {
|
|
4
|
+
/**
|
|
5
|
+
* Any unique identifying string for this fetcher.
|
|
6
|
+
*/
|
|
7
|
+
name: string;
|
|
8
|
+
/**
|
|
9
|
+
* The Studio-user-friendly display name.
|
|
10
|
+
*/
|
|
11
|
+
displayName?: string;
|
|
12
|
+
/**
|
|
13
|
+
* The symbol to import from the importPath.
|
|
14
|
+
*/
|
|
15
|
+
importName?: string;
|
|
16
|
+
args: {
|
|
17
|
+
name: string;
|
|
18
|
+
type: PrimitiveType;
|
|
19
|
+
}[];
|
|
20
|
+
returns: PrimitiveType;
|
|
21
|
+
/**
|
|
22
|
+
* Either the path to the fetcher relative to `rootDir` or the npm
|
|
23
|
+
* package name
|
|
24
|
+
*/
|
|
25
|
+
importPath: string;
|
|
26
|
+
/**
|
|
27
|
+
* Whether it's a default export or named export
|
|
28
|
+
*/
|
|
29
|
+
isDefaultExport?: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface FetcherRegistration {
|
|
32
|
+
fetcher: Fetcher;
|
|
33
|
+
meta: FetcherMeta;
|
|
34
|
+
}
|
|
35
|
+
declare global {
|
|
36
|
+
interface Window {
|
|
37
|
+
__PlasmicFetcherRegistry: FetcherRegistration[];
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export declare function registerFetcher(fetcher: Fetcher, meta: FetcherMeta): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type GlobalActionDict = Record<string, Function>;
|
|
3
|
+
export declare const GlobalActionsContext: React.Context<GlobalActionDict | undefined>;
|
|
4
|
+
export declare function GlobalActionsProvider(props: {
|
|
5
|
+
contextName: string;
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
actions: GlobalActionDict;
|
|
8
|
+
}): JSX.Element;
|
|
9
|
+
export declare function useGlobalActions(): GlobalActionDict;
|