@plasmicapp/host 1.0.224 → 1.0.225
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 -2
- 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 +6 -478
- package/dist/registerComponent.d.ts +8 -7
- package/dist/registerFunction.d.ts +2 -127
- package/dist/types/choice-type.d.ts +16 -0
- package/dist/types/component-types.d.ts +256 -0
- package/dist/types/container-types.d.ts +35 -0
- package/dist/types/function-types.d.ts +98 -0
- package/dist/types/misc-types.d.ts +28 -0
- package/dist/types/primitive-types.d.ts +123 -0
- package/dist/types/shared-controls.d.ts +40 -0
- package/dist/version.d.ts +1 -1
- package/package.json +4 -3
- package/registerComponent/dist/exports.d.ts +2 -2
- package/registerComponent/dist/index.cjs.js.map +1 -1
- package/registerComponent/dist/index.esm.js.map +1 -1
- package/registerComponent/dist/prop-types.d.ts +6 -478
- package/registerComponent/dist/registerComponent.d.ts +8 -7
- package/registerComponent/dist/registerFunction.d.ts +2 -127
- package/registerComponent/dist/types/choice-type.d.ts +16 -0
- package/registerComponent/dist/types/component-types.d.ts +256 -0
- package/registerComponent/dist/types/container-types.d.ts +35 -0
- package/registerComponent/dist/types/function-types.d.ts +98 -0
- package/registerComponent/dist/types/misc-types.d.ts +28 -0
- package/registerComponent/dist/types/primitive-types.d.ts +123 -0
- package/registerComponent/dist/types/shared-controls.d.ts +40 -0
- package/registerComponent/dist/version.d.ts +1 -1
- package/registerFunction/dist/exports.d.ts +2 -2
- package/registerFunction/dist/index.cjs.js.map +1 -1
- package/registerFunction/dist/index.esm.js.map +1 -1
- package/registerFunction/dist/prop-types.d.ts +6 -478
- package/registerFunction/dist/registerComponent.d.ts +8 -7
- package/registerFunction/dist/registerFunction.d.ts +2 -127
- package/registerFunction/dist/types/choice-type.d.ts +16 -0
- package/registerFunction/dist/types/component-types.d.ts +256 -0
- package/registerFunction/dist/types/container-types.d.ts +35 -0
- package/registerFunction/dist/types/function-types.d.ts +98 -0
- package/registerFunction/dist/types/misc-types.d.ts +28 -0
- package/registerFunction/dist/types/primitive-types.d.ts +123 -0
- package/registerFunction/dist/types/shared-controls.d.ts +40 -0
- package/registerFunction/dist/version.d.ts +1 -1
- package/registerGlobalContext/dist/exports.d.ts +2 -2
- package/registerGlobalContext/dist/prop-types.d.ts +6 -478
- package/registerGlobalContext/dist/registerComponent.d.ts +8 -7
- package/registerGlobalContext/dist/registerFunction.d.ts +2 -127
- package/registerGlobalContext/dist/types/choice-type.d.ts +16 -0
- package/registerGlobalContext/dist/types/component-types.d.ts +256 -0
- package/registerGlobalContext/dist/types/container-types.d.ts +35 -0
- package/registerGlobalContext/dist/types/function-types.d.ts +98 -0
- package/registerGlobalContext/dist/types/misc-types.d.ts +28 -0
- package/registerGlobalContext/dist/types/primitive-types.d.ts +123 -0
- package/registerGlobalContext/dist/types/shared-controls.d.ts +40 -0
- package/registerGlobalContext/dist/version.d.ts +1 -1
- package/registerToken/dist/exports.d.ts +2 -2
- package/registerToken/dist/prop-types.d.ts +6 -478
- package/registerToken/dist/registerComponent.d.ts +8 -7
- package/registerToken/dist/registerFunction.d.ts +2 -127
- package/registerToken/dist/types/choice-type.d.ts +16 -0
- package/registerToken/dist/types/component-types.d.ts +256 -0
- package/registerToken/dist/types/container-types.d.ts +35 -0
- package/registerToken/dist/types/function-types.d.ts +98 -0
- package/registerToken/dist/types/misc-types.d.ts +28 -0
- package/registerToken/dist/types/primitive-types.d.ts +123 -0
- package/registerToken/dist/types/shared-controls.d.ts +40 -0
- package/registerToken/dist/version.d.ts +1 -1
- package/registerTrait/dist/exports.d.ts +2 -2
- package/registerTrait/dist/prop-types.d.ts +6 -478
- package/registerTrait/dist/registerComponent.d.ts +8 -7
- package/registerTrait/dist/registerFunction.d.ts +2 -127
- package/registerTrait/dist/types/choice-type.d.ts +16 -0
- package/registerTrait/dist/types/component-types.d.ts +256 -0
- package/registerTrait/dist/types/container-types.d.ts +35 -0
- package/registerTrait/dist/types/function-types.d.ts +98 -0
- package/registerTrait/dist/types/misc-types.d.ts +28 -0
- package/registerTrait/dist/types/primitive-types.d.ts +123 -0
- package/registerTrait/dist/types/shared-controls.d.ts +40 -0
- package/registerTrait/dist/version.d.ts +1 -1
- /package/dist/{type-utils.d.ts → types/type-utils.d.ts} +0 -0
- /package/registerComponent/dist/{type-utils.d.ts → types/type-utils.d.ts} +0 -0
- /package/registerFunction/dist/{type-utils.d.ts → types/type-utils.d.ts} +0 -0
- /package/registerGlobalContext/dist/{type-utils.d.ts → types/type-utils.d.ts} +0 -0
- /package/registerToken/dist/{type-utils.d.ts → types/type-utils.d.ts} +0 -0
- /package/registerTrait/dist/{type-utils.d.ts → types/type-utils.d.ts} +0 -0
|
@@ -1,478 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Allows the component to set data to be consumed by the props' controls.
|
|
8
|
-
*/
|
|
9
|
-
setControlContextData?: (data: Data) => void;
|
|
10
|
-
}
|
|
11
|
-
export type ControlExtras = {
|
|
12
|
-
path: (string | number)[];
|
|
13
|
-
item?: any;
|
|
14
|
-
};
|
|
15
|
-
export type InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;
|
|
16
|
-
/**
|
|
17
|
-
* Context that we pass back to control functions.
|
|
18
|
-
*/
|
|
19
|
-
export type ControlContext<P> = [
|
|
20
|
-
/**
|
|
21
|
-
* props
|
|
22
|
-
*/
|
|
23
|
-
P,
|
|
24
|
-
/**
|
|
25
|
-
* `contextData` can be `null` if the prop controls are rendering before
|
|
26
|
-
* the component instance itself (it will re-render once the component
|
|
27
|
-
* calls `setControlContextData`)
|
|
28
|
-
*/
|
|
29
|
-
InferDataType<P> | null,
|
|
30
|
-
/**
|
|
31
|
-
* Extra information for the control to use
|
|
32
|
-
*/
|
|
33
|
-
ControlExtras
|
|
34
|
-
];
|
|
35
|
-
/**
|
|
36
|
-
* Config option that takes the context (e.g., props) of the component instance
|
|
37
|
-
* to dynamically set its value.
|
|
38
|
-
*/
|
|
39
|
-
export type ContextDependentConfig<P, R> = (...args: ControlContext<P>) => R;
|
|
40
|
-
export interface PropTypeBase<P> {
|
|
41
|
-
displayName?: string;
|
|
42
|
-
description?: string;
|
|
43
|
-
helpText?: string;
|
|
44
|
-
required?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* If the user has chosen to use a dynamic expression for this prop, provide
|
|
47
|
-
* a hint as to the expected values that the expression should evaluate to.
|
|
48
|
-
* This hint will be displayed alongside the code editor. You may use
|
|
49
|
-
* markdown in the text here.
|
|
50
|
-
*/
|
|
51
|
-
exprHint?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Function for whether this prop should be hidden in the right panel,
|
|
54
|
-
* given the current props for this component
|
|
55
|
-
*/
|
|
56
|
-
hidden?: ContextDependentConfig<P, boolean>;
|
|
57
|
-
readOnly?: boolean | ContextDependentConfig<P, boolean>;
|
|
58
|
-
/**
|
|
59
|
-
* If true, will hide the prop in a collapsed section; good for props that
|
|
60
|
-
* should not usually be used.
|
|
61
|
-
*/
|
|
62
|
-
advanced?: boolean;
|
|
63
|
-
/**
|
|
64
|
-
* If true, does not allow the user to use a dynamic expression for this prop
|
|
65
|
-
*/
|
|
66
|
-
disableDynamicValue?: boolean;
|
|
67
|
-
/**
|
|
68
|
-
* If set to true, the component will be remounted when the prop value is updated.
|
|
69
|
-
* (This behavior only applies to canvas)
|
|
70
|
-
*/
|
|
71
|
-
forceRemount?: boolean;
|
|
72
|
-
/**
|
|
73
|
-
* If true, the prop can't be overriden in different variants.
|
|
74
|
-
*/
|
|
75
|
-
invariantable?: boolean;
|
|
76
|
-
}
|
|
77
|
-
export interface Defaultable<P, T> {
|
|
78
|
-
/**
|
|
79
|
-
* Default value to set for this prop when the component is instantiated
|
|
80
|
-
*/
|
|
81
|
-
defaultValue?: T;
|
|
82
|
-
/**
|
|
83
|
-
* If no prop is given, the component uses a default; specify what
|
|
84
|
-
* that default is so the Plasmic user can see it in the studio UI
|
|
85
|
-
*/
|
|
86
|
-
defaultValueHint?: T | ContextDependentConfig<P, T | undefined>;
|
|
87
|
-
/**
|
|
88
|
-
* Use a dynamic value expression as the default instead
|
|
89
|
-
*/
|
|
90
|
-
defaultExpr?: string;
|
|
91
|
-
defaultExprHint?: string;
|
|
92
|
-
/**
|
|
93
|
-
* This function validates whether the prop value is valid.
|
|
94
|
-
* If the value is invalid, it returns an error message. Otherwise, it returns true.
|
|
95
|
-
*/
|
|
96
|
-
validator?: (value: T, ...args: ControlContext<P>) => (string | true) | Promise<string | true>;
|
|
97
|
-
}
|
|
98
|
-
export interface Controllable {
|
|
99
|
-
/**
|
|
100
|
-
* If true, this is a prop that should only be used inside Plasmic
|
|
101
|
-
* Studio for rendering artboards; will not be actually used in
|
|
102
|
-
* generated code.
|
|
103
|
-
*/
|
|
104
|
-
editOnly?: boolean;
|
|
105
|
-
/**
|
|
106
|
-
* If specified, the value used for this prop will instead be
|
|
107
|
-
* mapped to the uncontrolledProp when generating code. This is
|
|
108
|
-
* useful if, for example, in the artboard, you want to use `value`
|
|
109
|
-
* prop to control the component, but in generated code, you want to
|
|
110
|
-
* map it to `defaultValue`.
|
|
111
|
-
*/
|
|
112
|
-
uncontrolledProp?: string;
|
|
113
|
-
}
|
|
114
|
-
export interface PropTypeBaseDefault<P, T> extends PropTypeBase<P>, Defaultable<P, T>, Controllable {
|
|
115
|
-
}
|
|
116
|
-
export interface PlainStringType<P> extends PropTypeBaseDefault<P, string> {
|
|
117
|
-
type: "string";
|
|
118
|
-
control?: "default" | "large";
|
|
119
|
-
isLocalizable?: boolean;
|
|
120
|
-
}
|
|
121
|
-
export interface CodeStringType<P> extends PropTypeBaseDefault<P, string> {
|
|
122
|
-
type: "code";
|
|
123
|
-
lang: "css" | "html" | "javascript" | "json";
|
|
124
|
-
}
|
|
125
|
-
export interface RichTextType<P> extends PropTypeBaseDefault<P, string> {
|
|
126
|
-
type: "richText";
|
|
127
|
-
}
|
|
128
|
-
export interface HrefType<P> extends PropTypeBaseDefault<P, string> {
|
|
129
|
-
type: "href";
|
|
130
|
-
}
|
|
131
|
-
export interface ColorType<P> extends PropTypeBaseDefault<P, string> {
|
|
132
|
-
type: "color";
|
|
133
|
-
/**
|
|
134
|
-
* If specified, and the user picks a color token in the Studio, then
|
|
135
|
-
* the value passed in as prop is a css variable reference, like
|
|
136
|
-
* `var(--TOKEN_ID)`, instead of the resolved hex value of the token.
|
|
137
|
-
* You should take care in using this in the proper css context --
|
|
138
|
-
* the css token is only defined if you are rendering under some
|
|
139
|
-
* Plasmic component in the DOM tree, which is usually the case,
|
|
140
|
-
* unless you are using a React portal.
|
|
141
|
-
*/
|
|
142
|
-
keepCssVar?: boolean;
|
|
143
|
-
/**
|
|
144
|
-
* Prevent tokens from being selected.
|
|
145
|
-
*/
|
|
146
|
-
disableTokens?: boolean;
|
|
147
|
-
}
|
|
148
|
-
export interface DateStringType<P> extends PropTypeBaseDefault<P, string> {
|
|
149
|
-
type: "dateString";
|
|
150
|
-
}
|
|
151
|
-
export interface DateRangeStringsType<P> extends PropTypeBaseDefault<P, [string, string]> {
|
|
152
|
-
type: "dateRangeStrings";
|
|
153
|
-
}
|
|
154
|
-
export interface ClassType<P> extends PropTypeBase<P> {
|
|
155
|
-
type: "class";
|
|
156
|
-
/**
|
|
157
|
-
* Additional css selectors that can change how this style should look.
|
|
158
|
-
* Some examples:
|
|
159
|
-
*
|
|
160
|
-
* * `:hover` -- on hover
|
|
161
|
-
* * `[data-something="blah"] -- when the element with this class has
|
|
162
|
-
* an html attribute "data-something=blah"
|
|
163
|
-
* * :component[data-something="blah"] :self -- when the root of the
|
|
164
|
-
* component has an html attribute "data-something=blah". Note that
|
|
165
|
-
* the non-standard `:component` selector is used to select the
|
|
166
|
-
* component root, and the non-standard `:self` selector is used
|
|
167
|
-
* to select the element that this class is attached to.
|
|
168
|
-
*/
|
|
169
|
-
selectors?: {
|
|
170
|
-
/**
|
|
171
|
-
* A css selector, like `:hover` or `[data-something="blah"]`.
|
|
172
|
-
*/
|
|
173
|
-
selector: string;
|
|
174
|
-
/**
|
|
175
|
-
* An optional human-friendly label for the selector, so the studio user
|
|
176
|
-
* knows what this selector means.
|
|
177
|
-
*/
|
|
178
|
-
label?: string;
|
|
179
|
-
/**
|
|
180
|
-
* Initial styles to be applied for this selector
|
|
181
|
-
*/
|
|
182
|
-
defaultStyles?: CSSProperties;
|
|
183
|
-
}[];
|
|
184
|
-
/**
|
|
185
|
-
* If specified, then only shows these style sections for styling this class
|
|
186
|
-
*/
|
|
187
|
-
styleSections?: StyleSection[];
|
|
188
|
-
/**
|
|
189
|
-
* Initial styles to be applied for this class
|
|
190
|
-
*/
|
|
191
|
-
defaultStyles?: CSSProperties;
|
|
192
|
-
}
|
|
193
|
-
export interface ThemeResetClassType<P> extends PropTypeBase<P> {
|
|
194
|
-
type: "themeResetClass";
|
|
195
|
-
/**
|
|
196
|
-
* Normally, theme reset class will only target Plasmic-generated tags
|
|
197
|
-
* with the default tag styles. If you also want to target non-Plasmic-generated
|
|
198
|
-
* tags (say, rendered by your code components, or fetched as an HTML blob
|
|
199
|
-
* from somewhere), then specify `true` here.
|
|
200
|
-
*/
|
|
201
|
-
targetAllTags?: boolean;
|
|
202
|
-
}
|
|
203
|
-
export interface CardPickerType<P> extends PropTypeBaseDefault<P, string> {
|
|
204
|
-
type: "cardPicker";
|
|
205
|
-
modalTitle?: React.ReactNode | ContextDependentConfig<P, React.ReactNode>;
|
|
206
|
-
options: {
|
|
207
|
-
value: string;
|
|
208
|
-
label?: string;
|
|
209
|
-
imgUrl: string;
|
|
210
|
-
footer?: React.ReactNode;
|
|
211
|
-
}[] | ContextDependentConfig<P, {
|
|
212
|
-
value: string;
|
|
213
|
-
label?: string;
|
|
214
|
-
imgUrl: string;
|
|
215
|
-
footer?: React.ReactNode;
|
|
216
|
-
}[]>;
|
|
217
|
-
showInput?: boolean | ContextDependentConfig<P, boolean>;
|
|
218
|
-
onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;
|
|
219
|
-
}
|
|
220
|
-
export type RichStringType<P> = PlainStringType<P> | CodeStringType<P> | RichTextType<P> | ColorType<P> | ClassType<P> | ThemeResetClassType<P> | CardPickerType<P> | HrefType<P>;
|
|
221
|
-
export type StringType<P> = "string" | "href" | RichStringType<P>;
|
|
222
|
-
export interface RichBooleanType<P> extends PropTypeBaseDefault<P, boolean> {
|
|
223
|
-
type: "boolean";
|
|
224
|
-
}
|
|
225
|
-
export type BooleanType<P> = "boolean" | RichBooleanType<P>;
|
|
226
|
-
export type GraphQLValue = {
|
|
227
|
-
query: string;
|
|
228
|
-
variables?: Record<string, any>;
|
|
229
|
-
};
|
|
230
|
-
export interface GraphQLType<P> extends PropTypeBaseDefault<P, GraphQLValue> {
|
|
231
|
-
type: "code";
|
|
232
|
-
lang: "graphql";
|
|
233
|
-
endpoint: string | ContextDependentConfig<P, string>;
|
|
234
|
-
method?: string | ContextDependentConfig<P, string>;
|
|
235
|
-
headers?: object | ContextDependentConfig<P, object>;
|
|
236
|
-
}
|
|
237
|
-
export interface NumberTypeBase<P> extends PropTypeBaseDefault<P, number> {
|
|
238
|
-
type: "number";
|
|
239
|
-
min?: number | ContextDependentConfig<P, number>;
|
|
240
|
-
max?: number | ContextDependentConfig<P, number>;
|
|
241
|
-
}
|
|
242
|
-
export interface PlainNumberType<P> extends NumberTypeBase<P> {
|
|
243
|
-
control?: "default";
|
|
244
|
-
}
|
|
245
|
-
export interface SliderNumberType<P> extends NumberTypeBase<P> {
|
|
246
|
-
control: "slider";
|
|
247
|
-
step?: number | ContextDependentConfig<P, number>;
|
|
248
|
-
}
|
|
249
|
-
export type RichNumberType<P> = PlainNumberType<P> | SliderNumberType<P>;
|
|
250
|
-
export type NumberType<P> = "number" | RichNumberType<P>;
|
|
251
|
-
export interface ObjectType<P> extends PropTypeBaseDefault<P, Record<string, any>> {
|
|
252
|
-
type: "object";
|
|
253
|
-
fields?: Record<string, PropType<P>>;
|
|
254
|
-
nameFunc?: (item: any, ...args: ControlContext<P>) => string | undefined;
|
|
255
|
-
}
|
|
256
|
-
export interface ArrayType<P> extends PropTypeBaseDefault<P, any[]> {
|
|
257
|
-
type: "array";
|
|
258
|
-
itemType?: ObjectType<P>;
|
|
259
|
-
/**
|
|
260
|
-
* Optional function that determines whether the user can delete a given item.
|
|
261
|
-
*/
|
|
262
|
-
unstable__canDelete?: (item: any, ...args: ControlContext<P>) => boolean;
|
|
263
|
-
/**
|
|
264
|
-
* Specify how to let Plasmic know how to update its own internal representation of the data when the value has
|
|
265
|
-
* changed, or when issuing a minimalValue or shownValue that is different.
|
|
266
|
-
*
|
|
267
|
-
* Important to specify this if you are expecting any nested expression values in this data type!
|
|
268
|
-
*/
|
|
269
|
-
unstable__keyFunc?: (item: any) => any;
|
|
270
|
-
/**
|
|
271
|
-
* Specify what would be the tentative new value that is set if the user makes any changes.
|
|
272
|
-
*
|
|
273
|
-
* Useful for field mappings.
|
|
274
|
-
*
|
|
275
|
-
* For instance, consider a Table where we have a `fields` prop:
|
|
276
|
-
*
|
|
277
|
-
* - Initially, the value is undefined. But if the user makes any changes, we would want to save an array of at
|
|
278
|
-
* least three items (corresponding to, say, three columns inferred from a schema).
|
|
279
|
-
*
|
|
280
|
-
* - Let's say there are 5 columns in the value. The data schema changes, removing a column and adding two new
|
|
281
|
-
* ones. Now we would want a different minimal value, containing 6 items.
|
|
282
|
-
*/
|
|
283
|
-
unstable__minimalValue?: ContextDependentConfig<P, any>;
|
|
284
|
-
}
|
|
285
|
-
export type JSONLikeType<P> = "object" | ObjectType<P> | ArrayType<P>;
|
|
286
|
-
export interface DataSourceType<P> extends PropTypeBase<P> {
|
|
287
|
-
type: "dataSource";
|
|
288
|
-
dataSource: "airtable" | "cms";
|
|
289
|
-
}
|
|
290
|
-
export type DataPickerValueType = string | number | (string | number)[];
|
|
291
|
-
export interface RichDataPickerType<P> extends PropTypeBaseDefault<P, DataPickerValueType> {
|
|
292
|
-
type: "dataSelector";
|
|
293
|
-
data?: Record<string, any> | ContextDependentConfig<P, Record<string, any>>;
|
|
294
|
-
alwaysShowValuePathAsLabel?: boolean;
|
|
295
|
-
isolateEnv?: boolean;
|
|
296
|
-
}
|
|
297
|
-
export type DataPickerType<P> = "dataPicker" | RichDataPickerType<P>;
|
|
298
|
-
export interface RichExprEditorType<P> extends PropTypeBaseDefault<P, DataPickerValueType> {
|
|
299
|
-
type: "exprEditor";
|
|
300
|
-
data?: Record<string, any> | ContextDependentConfig<P, Record<string, any>>;
|
|
301
|
-
isolateEnv?: boolean;
|
|
302
|
-
}
|
|
303
|
-
export type ExprEditorType<P> = "exprEditor" | RichExprEditorType<P>;
|
|
304
|
-
export interface FormValidationRulesType<P> extends PropTypeBaseDefault<P, any> {
|
|
305
|
-
type: "formValidationRules";
|
|
306
|
-
}
|
|
307
|
-
export interface EventHandlerType<P> extends PropTypeBase<P> {
|
|
308
|
-
type: "eventHandler";
|
|
309
|
-
argTypes: {
|
|
310
|
-
name: string;
|
|
311
|
-
type: ArgType<any>;
|
|
312
|
-
}[];
|
|
313
|
-
}
|
|
314
|
-
export type ChoiceValue = string | number | boolean;
|
|
315
|
-
export type ChoiceObject = {
|
|
316
|
-
label: string;
|
|
317
|
-
value: ChoiceValue;
|
|
318
|
-
};
|
|
319
|
-
export type ChoiceOptions = ChoiceValue[] | ChoiceObject[];
|
|
320
|
-
export interface ChoiceTypeBase<P, T> extends PropTypeBaseDefault<P, T> {
|
|
321
|
-
type: "choice";
|
|
322
|
-
options: ChoiceOptions | ContextDependentConfig<P, string[] | {
|
|
323
|
-
label: string;
|
|
324
|
-
value: string | number | boolean;
|
|
325
|
-
}[]>;
|
|
326
|
-
allowSearch?: boolean;
|
|
327
|
-
filterOption?: boolean;
|
|
328
|
-
onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;
|
|
329
|
-
}
|
|
330
|
-
export interface SingleChoiceType<P> extends ChoiceTypeBase<P, string | number | boolean> {
|
|
331
|
-
multiSelect?: false;
|
|
332
|
-
}
|
|
333
|
-
export interface MultiChoiceType<P> extends ChoiceTypeBase<P, (string | number | boolean)[]> {
|
|
334
|
-
multiSelect: true;
|
|
335
|
-
}
|
|
336
|
-
export interface CustomChoiceType<P> extends ChoiceTypeBase<P, string | number | boolean | (string | number | boolean)[]> {
|
|
337
|
-
multiSelect: ContextDependentConfig<P, boolean>;
|
|
338
|
-
}
|
|
339
|
-
export type ChoiceType<P> = SingleChoiceType<P> | MultiChoiceType<P> | CustomChoiceType<P>;
|
|
340
|
-
export interface RichSlotType<P> {
|
|
341
|
-
type: "slot";
|
|
342
|
-
description?: string;
|
|
343
|
-
/**
|
|
344
|
-
* The unique names of all code components that can be placed in the slot
|
|
345
|
-
*/
|
|
346
|
-
allowedComponents?: string[];
|
|
347
|
-
/**
|
|
348
|
-
* Wheter Plasmic Components with a root component included in the
|
|
349
|
-
* "allowedComponents" list are valid or not.
|
|
350
|
-
* Only used if the "allowedComponents" list is set.
|
|
351
|
-
*/
|
|
352
|
-
allowRootWrapper?: boolean;
|
|
353
|
-
/**
|
|
354
|
-
* Whether the "empty slot" placeholder should be hidden in the canvas.
|
|
355
|
-
*/
|
|
356
|
-
hidePlaceholder?: boolean;
|
|
357
|
-
/**
|
|
358
|
-
* Whether the slot is repeated, i.e., is rendered multiple times using
|
|
359
|
-
* repeatedElement().
|
|
360
|
-
*/
|
|
361
|
-
isRepeated?: boolean;
|
|
362
|
-
/**
|
|
363
|
-
* A nicer, human-readable display name for your slot prop
|
|
364
|
-
*/
|
|
365
|
-
displayName?: string;
|
|
366
|
-
/**
|
|
367
|
-
* Function for whether this slot should be hidden from the left tree,
|
|
368
|
-
* given the current props for this component
|
|
369
|
-
*/
|
|
370
|
-
hidden?: ContextDependentConfig<P, boolean>;
|
|
371
|
-
/**
|
|
372
|
-
* If slot is a render prop (accepts a function that takes in some
|
|
373
|
-
* arguments and returns some JSX), then specify the names of the
|
|
374
|
-
* arguments expected by the render prop function.
|
|
375
|
-
*/
|
|
376
|
-
renderPropParams?: string[];
|
|
377
|
-
/**
|
|
378
|
-
* When inserting top-level "page sections", should this slot be the default target?
|
|
379
|
-
*/
|
|
380
|
-
unstable__isMainContentSlot?: boolean;
|
|
381
|
-
defaultValue?: PlasmicElement | PlasmicElement[];
|
|
382
|
-
/**
|
|
383
|
-
* When true, when you click for the first time in this slot and the component was not selected, the component itself
|
|
384
|
-
* is selected, making it easier to select the component instead of slot contents. So for
|
|
385
|
-
* instance, setting this on a Button slot ensures that clicking on the Button’s text will still select the Button and not
|
|
386
|
-
* the text element in its slot. Clicking again will deep-select the slot content. Similar in this regard to trapsFocus on components.
|
|
387
|
-
*
|
|
388
|
-
* Furthermore, the component further shows the props of whatever is in the slot on
|
|
389
|
-
* the parent component for the user's convenience. Handy for various “wrapper" components, form fields, and so on.
|
|
390
|
-
*/
|
|
391
|
-
mergeWithParent?: boolean | ContextDependentConfig<P, boolean>;
|
|
392
|
-
/**
|
|
393
|
-
* A function that returns true to hide the merged props conditionally.
|
|
394
|
-
*/
|
|
395
|
-
hiddenMergedProps?: ContextDependentConfig<P, boolean>;
|
|
396
|
-
}
|
|
397
|
-
export type SlotType<P> = "slot" | RichSlotType<P>;
|
|
398
|
-
export interface RichImageUrlType<P> extends PropTypeBaseDefault<P, string> {
|
|
399
|
-
type: "imageUrl";
|
|
400
|
-
}
|
|
401
|
-
export type ImageUrlType<P> = "imageUrl" | RichImageUrlType<P>;
|
|
402
|
-
export interface ModalProps {
|
|
403
|
-
show?: boolean;
|
|
404
|
-
children?: React.ReactNode;
|
|
405
|
-
onClose: () => void;
|
|
406
|
-
style?: CSSProperties;
|
|
407
|
-
}
|
|
408
|
-
export interface StudioOps {
|
|
409
|
-
showModal: (modalProps: Omit<ModalProps, "onClose"> & {
|
|
410
|
-
onClose?: () => void;
|
|
411
|
-
}) => void;
|
|
412
|
-
refreshQueryData: () => void;
|
|
413
|
-
appendToSlot: (element: PlasmicElement, slotName: string) => void;
|
|
414
|
-
removeFromSlotAt: (pos: number, slotName: string) => void;
|
|
415
|
-
updateProps: (newValues: any) => void;
|
|
416
|
-
updateStates: (newValues: any) => void;
|
|
417
|
-
}
|
|
418
|
-
export interface ProjectData {
|
|
419
|
-
components: {
|
|
420
|
-
name: string;
|
|
421
|
-
}[];
|
|
422
|
-
pages: {
|
|
423
|
-
name: string;
|
|
424
|
-
pageMeta: {
|
|
425
|
-
path: string;
|
|
426
|
-
};
|
|
427
|
-
}[];
|
|
428
|
-
}
|
|
429
|
-
export interface CustomControlProps<P> {
|
|
430
|
-
componentProps: P;
|
|
431
|
-
/**
|
|
432
|
-
* `contextData` can be `null` if the prop controls are rendering before
|
|
433
|
-
* the component instance itself (it will re-render once the component
|
|
434
|
-
* calls `setControlContextData`)
|
|
435
|
-
*/
|
|
436
|
-
contextData: InferDataType<P> | null;
|
|
437
|
-
/**
|
|
438
|
-
* Operations available to the editor that allow modifying the entire component.
|
|
439
|
-
* Can be null if the custom prop is used in a global context.
|
|
440
|
-
*/
|
|
441
|
-
studioOps: StudioOps | null;
|
|
442
|
-
/**
|
|
443
|
-
* Metadata from the studio project.
|
|
444
|
-
*/
|
|
445
|
-
projectData: ProjectData;
|
|
446
|
-
value: any;
|
|
447
|
-
/**
|
|
448
|
-
* Sets the value to be passed to the prop. Expects a JSON-compatible value.
|
|
449
|
-
*/
|
|
450
|
-
updateValue: (newVal: any) => void;
|
|
451
|
-
/**
|
|
452
|
-
* Full screen modal component
|
|
453
|
-
*/
|
|
454
|
-
FullscreenModal: React.ComponentType<ModalProps>;
|
|
455
|
-
/**
|
|
456
|
-
* Modal component for the side pane
|
|
457
|
-
*/
|
|
458
|
-
SideModal: React.ComponentType<ModalProps>;
|
|
459
|
-
/**
|
|
460
|
-
* The document that the component will be rendered into; instead of using
|
|
461
|
-
* `document` directly (for, say, `document.querySelector()` etc.), you
|
|
462
|
-
* should use this instead.
|
|
463
|
-
*/
|
|
464
|
-
studioDocument: typeof document;
|
|
465
|
-
}
|
|
466
|
-
export type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;
|
|
467
|
-
export interface RichCustomType<P> extends PropTypeBaseDefault<P, any> {
|
|
468
|
-
type: "custom";
|
|
469
|
-
control: CustomControl<P>;
|
|
470
|
-
}
|
|
471
|
-
export type CustomType<P> = RichCustomType<P> | CustomControl<P>;
|
|
472
|
-
export type PrimitiveType<P = any> = Extract<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>, string>;
|
|
473
|
-
export type PropType<P> = StringType<P> | BooleanType<P> | GraphQLType<P> | NumberType<P> | JSONLikeType<P> | DataSourceType<P> | DataPickerType<P> | ExprEditorType<P> | FormValidationRulesType<P> | EventHandlerType<P> | ChoiceType<P> | CustomType<P> | ImageUrlType<P> | SlotType<P> | DateStringType<P> | DateRangeStringsType<P>;
|
|
474
|
-
export type ArgType<P> = Exclude<PropType<P>, SlotType<P> | EventHandlerType<P>>;
|
|
475
|
-
export type StringCompatType<P> = DateStringType<P> | StringType<P> | ChoiceType<P> | JSONLikeType<P> | ImageUrlType<P> | CustomType<P> | DataPickerType<P>;
|
|
476
|
-
export type BoolCompatType<P> = BooleanType<P> | CustomType<P> | DataPickerType<P>;
|
|
477
|
-
export type NumberCompatType<P> = NumberType<P> | CustomType<P> | DataPickerType<P>;
|
|
478
|
-
export type RestrictPropType<T, P> = T extends string ? StringCompatType<P> : T extends boolean ? BoolCompatType<P> : T extends number ? NumberCompatType<P> : PropType<P>;
|
|
1
|
+
import { ChoiceObject, ChoiceOptions, ChoiceValue } from "./types/choice-type";
|
|
2
|
+
import { ComponentControlContext } from "./types/component-types";
|
|
3
|
+
import { DataPickerValueType, GraphQLValue } from "./types/misc-types";
|
|
4
|
+
import { CanvasComponentProps, ContextDependentConfig, ControlExtras, InferDataType } from "./types/shared-controls";
|
|
5
|
+
export type { CanvasComponentProps, ChoiceObject, ChoiceOptions, ChoiceValue, ComponentControlContext, ContextDependentConfig, ControlExtras, DataPickerValueType, GraphQLValue, InferDataType, };
|
|
6
|
+
export type * from "./types/component-types";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { CodeComponentElement, CSSProperties } from "./element-types";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { ComponentContextConfig, ProjectData, PropType, RestrictPropType, StudioOps } from "./types/component-types";
|
|
4
|
+
import { InferDataType } from "./types/shared-controls";
|
|
5
|
+
import { TupleUnion } from "./types/type-utils";
|
|
5
6
|
export type * from "./prop-types";
|
|
6
7
|
export interface ActionProps<P> {
|
|
7
8
|
componentProps: P;
|
|
@@ -30,11 +31,11 @@ export type Action<P> = {
|
|
|
30
31
|
type: "button-action";
|
|
31
32
|
label: string;
|
|
32
33
|
onClick: (props: ActionProps<P>) => void;
|
|
33
|
-
hidden?:
|
|
34
|
+
hidden?: ComponentContextConfig<P, boolean>;
|
|
34
35
|
} | {
|
|
35
36
|
type: "custom-action";
|
|
36
37
|
control: React.ComponentType<ActionProps<P>>;
|
|
37
|
-
hidden?:
|
|
38
|
+
hidden?: ComponentContextConfig<P, boolean>;
|
|
38
39
|
};
|
|
39
40
|
type DistributedKeyOf<T> = T extends any ? keyof T : never;
|
|
40
41
|
interface ComponentTemplate<P> extends Omit<CodeComponentElement<P>, "type" | "name"> {
|
|
@@ -51,12 +52,12 @@ export type StateSpec<P> = {
|
|
|
51
52
|
/**
|
|
52
53
|
* If true, will hide the state on studio.
|
|
53
54
|
*/
|
|
54
|
-
hidden?:
|
|
55
|
+
hidden?: ComponentContextConfig<P, boolean>;
|
|
55
56
|
/**
|
|
56
57
|
* If true, will hide the state in a collapsed section; good for states that
|
|
57
58
|
* should not usually be used.
|
|
58
59
|
*/
|
|
59
|
-
advanced?:
|
|
60
|
+
advanced?: ComponentContextConfig<P, boolean>;
|
|
60
61
|
} & ({
|
|
61
62
|
type: "readonly";
|
|
62
63
|
variableType: "text";
|
|
@@ -247,7 +248,7 @@ export interface CodeComponentMeta<P> {
|
|
|
247
248
|
* on the left of the Studio. This makes it easy to identify an element when
|
|
248
249
|
* looking at the tree.
|
|
249
250
|
*/
|
|
250
|
-
treeLabel?:
|
|
251
|
+
treeLabel?: ComponentContextConfig<P, string>;
|
|
251
252
|
/**
|
|
252
253
|
* The value of the CSS display property used by this component.
|
|
253
254
|
* Plasmic passes in a class name prop to components to let users style them,
|
|
@@ -1,129 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
* Context that we pass back to control functions.
|
|
4
|
-
*/
|
|
5
|
-
export type ControlContext<P> = [
|
|
6
|
-
/**
|
|
7
|
-
* props
|
|
8
|
-
*/
|
|
9
|
-
Partial<P>,
|
|
10
|
-
/**
|
|
11
|
-
* context data
|
|
12
|
-
*/
|
|
13
|
-
any
|
|
14
|
-
];
|
|
15
|
-
/**
|
|
16
|
-
* Config option that takes the context (e.g., props) of the function call
|
|
17
|
-
* to dynamically set its value.
|
|
18
|
-
*/
|
|
19
|
-
export type ContextDependentConfig<P, R> = (...args: ControlContext<P>) => R;
|
|
20
|
-
export interface BaseParam {
|
|
21
|
-
name: string;
|
|
22
|
-
description?: string;
|
|
23
|
-
isOptional?: boolean;
|
|
24
|
-
isRestParameter?: boolean;
|
|
25
|
-
}
|
|
26
|
-
export interface ChoiceTypeBase<P, T> extends BaseParam {
|
|
27
|
-
type: "choice";
|
|
28
|
-
options: T[] | {
|
|
29
|
-
label: string;
|
|
30
|
-
value: T;
|
|
31
|
-
}[] | ContextDependentConfig<P, T[] | {
|
|
32
|
-
label: string;
|
|
33
|
-
value: T;
|
|
34
|
-
}[]>;
|
|
35
|
-
allowSearch?: boolean;
|
|
36
|
-
filterOption?: boolean;
|
|
37
|
-
onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;
|
|
38
|
-
}
|
|
39
|
-
export interface SingleChoiceType<P, T> extends ChoiceTypeBase<P, T> {
|
|
40
|
-
multiSelect?: false;
|
|
41
|
-
}
|
|
42
|
-
export interface MultiChoiceType<P, T> extends ChoiceTypeBase<P, T[]> {
|
|
43
|
-
multiSelect: true;
|
|
44
|
-
}
|
|
45
|
-
export interface CustomChoiceType<P, T> extends ChoiceTypeBase<P, T | T[]> {
|
|
46
|
-
multiSelect: ContextDependentConfig<P, boolean>;
|
|
47
|
-
}
|
|
48
|
-
export type ChoiceType<P, T> = SingleChoiceType<P, T> | MultiChoiceType<P, T> | CustomChoiceType<P, T>;
|
|
49
|
-
export interface PlainStringType<T extends Nullish<string> = string> extends BaseParam {
|
|
50
|
-
type: "string" | `'${T}'`;
|
|
51
|
-
}
|
|
52
|
-
export type StringType<P, T extends Nullish<string> = string> = "string" | PlainStringType<T> | ChoiceType<P, T> | AnyType;
|
|
53
|
-
export interface PlainNumberType<T extends Nullish<number> = number> extends BaseParam {
|
|
54
|
-
type: "number" | `${number extends T ? number : T}`;
|
|
55
|
-
}
|
|
56
|
-
export type NumberType<P, T extends Nullish<number> = number> = PlainNumberType<T> | ChoiceType<P, T> | AnyType;
|
|
57
|
-
export interface PlainBooleanType<T extends Nullish<boolean> = boolean> extends BaseParam {
|
|
58
|
-
type: "boolean" | `${boolean extends T ? boolean : T}`;
|
|
59
|
-
}
|
|
60
|
-
export type BooleanType<P, T extends Nullish<boolean> = boolean> = PlainBooleanType<T> | ChoiceType<P, T> | AnyType;
|
|
61
|
-
export type GraphQLValue = {
|
|
62
|
-
query: string;
|
|
63
|
-
variables?: Record<string, any>;
|
|
64
|
-
};
|
|
65
|
-
export interface GraphQLType<P> extends BaseParam {
|
|
66
|
-
type: "code";
|
|
67
|
-
lang: "graphql";
|
|
68
|
-
endpoint: string | ContextDependentConfig<P, string>;
|
|
69
|
-
method?: string | ContextDependentConfig<P, string>;
|
|
70
|
-
headers?: object | ContextDependentConfig<P, object>;
|
|
71
|
-
}
|
|
72
|
-
export interface PlainNullType extends BaseParam {
|
|
73
|
-
type: "null";
|
|
74
|
-
}
|
|
75
|
-
export type NullType = PlainNullType | AnyType;
|
|
76
|
-
export interface PlainUndefinedType extends BaseParam {
|
|
77
|
-
type: "undefined";
|
|
78
|
-
}
|
|
79
|
-
export type UndefinedType = PlainUndefinedType | AnyType;
|
|
80
|
-
export interface PlainArrayType extends BaseParam {
|
|
81
|
-
type: "array";
|
|
82
|
-
}
|
|
83
|
-
export type ArrayType = PlainArrayType | AnyType;
|
|
84
|
-
export interface PlainObjectType extends BaseParam {
|
|
85
|
-
type: "object";
|
|
86
|
-
}
|
|
87
|
-
export type ObjectType = PlainObjectType | AnyType;
|
|
88
|
-
export interface PlainAnyType extends BaseParam {
|
|
89
|
-
type: "any";
|
|
90
|
-
}
|
|
91
|
-
export type AnyType = PlainAnyType;
|
|
92
|
-
export interface PlainVoidType extends BaseParam {
|
|
93
|
-
type: "void";
|
|
94
|
-
}
|
|
95
|
-
export type VoidType = PlainVoidType | AnyType;
|
|
96
|
-
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
97
|
-
type CommonType<P, T> = T extends GraphQLValue ? GraphQLType<P> : T extends null ? NullType : T extends undefined ? UndefinedType : T extends Array<any> ? ArrayType : T extends object ? ObjectType : AnyType;
|
|
98
|
-
type AnyTyping<P, T> = T extends string ? StringType<P, T> : T extends number ? NumberType<P, T> : T extends boolean ? BooleanType<P, T> : CommonType<P, T>;
|
|
99
|
-
export type RestrictedType<P, T> = IsAny<T> extends true ? AnyTyping<P, T> : [T] extends [Nullish<string>] ? StringType<P, T> : [T] extends [Nullish<number>] ? NumberType<P, T> : [T] extends [Nullish<boolean>] ? BooleanType<P, T> : CommonType<P, T>;
|
|
100
|
-
export type ParamType<P, T> = RestrictedType<P, T>;
|
|
101
|
-
export type RequiredParam<P, T> = ParamType<P, T> & {
|
|
102
|
-
isOptional?: false;
|
|
103
|
-
isRestParameter?: false;
|
|
104
|
-
};
|
|
105
|
-
export type OptionalParam<P, T> = ParamType<P, T> & {
|
|
106
|
-
isRestParameter?: false;
|
|
107
|
-
};
|
|
108
|
-
export type RestParam<P, T> = ParamType<P, T> & {
|
|
109
|
-
isOptional?: false;
|
|
110
|
-
isRestParameter: true;
|
|
111
|
-
};
|
|
112
|
-
type RequiredParams<T extends any[], U extends any[] = []> = Partial<T> extends T ? U : T extends [infer F, ...infer R] ? RequiredParams<R, [...U, F]> : U;
|
|
113
|
-
type OptionalParams<T extends any[]> = T extends [
|
|
114
|
-
...RequiredParams<T>,
|
|
115
|
-
...infer R
|
|
116
|
-
] ? [...R] : [];
|
|
117
|
-
type HandleRequiredParams<P, R extends any[]> = R extends [infer H, ...infer T] ? [string | RequiredParam<P, H>, ...HandleRequiredParams<P, T>] : [];
|
|
118
|
-
type HandleOptionalParams<P, R extends any[]> = R extends [infer H, ...infer T] ? [] | [
|
|
119
|
-
string | OptionalParam<P, H | undefined>,
|
|
120
|
-
...HandleOptionalParams<P, T>
|
|
121
|
-
] : R extends [] ? [] : R extends Array<infer T> ? [] | [RestParam<P, T[]>] : [];
|
|
122
|
-
export type HandleParams<P extends any[]> = [
|
|
123
|
-
...HandleRequiredParams<P, RequiredParams<P>>,
|
|
124
|
-
...HandleOptionalParams<P, Required<OptionalParams<P>>>
|
|
125
|
-
];
|
|
126
|
-
export type HandleReturnType<P, T> = VoidType | ParamType<P, T>;
|
|
1
|
+
import { HandleParams, HandleReturnType } from "./types/function-types";
|
|
2
|
+
export type * from "./types/function-types";
|
|
127
3
|
export interface CustomFunctionMeta<F extends (...args: any[]) => any> {
|
|
128
4
|
/**
|
|
129
5
|
* The javascript name of the function. Notice it must be unique across all
|
|
@@ -206,4 +82,3 @@ declare global {
|
|
|
206
82
|
}
|
|
207
83
|
}
|
|
208
84
|
export default function registerFunction<F extends (...args: any[]) => any>(fn: F, meta: CustomFunctionMeta<F>): void;
|
|
209
|
-
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MaybeContextDependentConfig } from "./shared-controls";
|
|
2
|
+
export type ChoiceValue = string | number | boolean;
|
|
3
|
+
export type ChoiceObject<T = ChoiceValue> = {
|
|
4
|
+
label: string;
|
|
5
|
+
value: T;
|
|
6
|
+
};
|
|
7
|
+
export type ChoiceOption<T extends ChoiceValue = ChoiceValue> = T | ChoiceObject<T>;
|
|
8
|
+
export type ChoiceOptions<T extends ChoiceValue = ChoiceValue> = T[] | ChoiceObject<T>[];
|
|
9
|
+
export interface ChoiceCore<Ctx extends any[], T extends ChoiceValue> {
|
|
10
|
+
type: "choice";
|
|
11
|
+
options: MaybeContextDependentConfig<Ctx, ChoiceOptions<T>>;
|
|
12
|
+
multiSelect?: MaybeContextDependentConfig<Ctx, boolean>;
|
|
13
|
+
allowSearch?: boolean;
|
|
14
|
+
filterOption?: boolean;
|
|
15
|
+
onSearch?: MaybeContextDependentConfig<Ctx, ((v: string) => void) | undefined>;
|
|
16
|
+
}
|