@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.
Files changed (79) hide show
  1. package/dist/exports.d.ts +2 -1
  2. package/dist/fetcher.d.ts +1 -1
  3. package/dist/host.esm.js +1 -1
  4. package/dist/host.esm.js.map +1 -1
  5. package/dist/index.cjs.js +1 -1
  6. package/dist/index.cjs.js.map +1 -1
  7. package/dist/prop-types.d.ts +387 -0
  8. package/dist/registerComponent.d.ts +2 -368
  9. package/dist/registerGlobalContext.d.ts +4 -3
  10. package/dist/version.d.ts +1 -1
  11. package/package.json +2 -2
  12. package/registerComponent/dist/canvas-host.d.ts +41 -0
  13. package/registerComponent/dist/common.d.ts +1 -0
  14. package/registerComponent/dist/data.d.ts +43 -0
  15. package/registerComponent/dist/exports.d.ts +11 -0
  16. package/registerComponent/dist/fetcher.d.ts +40 -0
  17. package/registerComponent/dist/global-actions.d.ts +9 -0
  18. package/registerComponent/dist/index.cjs.js.map +1 -1
  19. package/registerComponent/dist/index.d.ts +1 -0
  20. package/registerComponent/dist/index.esm.js.map +1 -1
  21. package/registerComponent/dist/lang-utils.d.ts +3 -0
  22. package/registerComponent/dist/prop-types.d.ts +387 -0
  23. package/registerComponent/dist/registerComponent.d.ts +2 -368
  24. package/registerComponent/dist/registerGlobalContext.d.ts +76 -0
  25. package/registerComponent/dist/registerToken.d.ts +13 -0
  26. package/registerComponent/dist/registerTrait.d.ts +20 -0
  27. package/registerComponent/dist/repeatedElement.d.ts +15 -0
  28. package/registerComponent/dist/useForceUpdate.d.ts +1 -0
  29. package/registerComponent/dist/version.d.ts +1 -0
  30. package/registerGlobalContext/dist/canvas-host.d.ts +41 -0
  31. package/registerGlobalContext/dist/common.d.ts +1 -0
  32. package/registerGlobalContext/dist/data.d.ts +43 -0
  33. package/registerGlobalContext/dist/exports.d.ts +11 -0
  34. package/registerGlobalContext/dist/fetcher.d.ts +40 -0
  35. package/registerGlobalContext/dist/global-actions.d.ts +9 -0
  36. package/registerGlobalContext/dist/index.cjs.js.map +1 -1
  37. package/registerGlobalContext/dist/index.d.ts +1 -0
  38. package/registerGlobalContext/dist/index.esm.js.map +1 -1
  39. package/registerGlobalContext/dist/lang-utils.d.ts +3 -0
  40. package/registerGlobalContext/dist/prop-types.d.ts +387 -0
  41. package/registerGlobalContext/dist/registerComponent.d.ts +2 -368
  42. package/registerGlobalContext/dist/registerGlobalContext.d.ts +4 -3
  43. package/registerGlobalContext/dist/registerToken.d.ts +13 -0
  44. package/registerGlobalContext/dist/registerTrait.d.ts +20 -0
  45. package/registerGlobalContext/dist/repeatedElement.d.ts +15 -0
  46. package/registerGlobalContext/dist/useForceUpdate.d.ts +1 -0
  47. package/registerGlobalContext/dist/version.d.ts +1 -0
  48. package/registerToken/dist/canvas-host.d.ts +41 -0
  49. package/registerToken/dist/common.d.ts +1 -0
  50. package/registerToken/dist/data.d.ts +43 -0
  51. package/registerToken/dist/element-types.d.ts +115 -0
  52. package/registerToken/dist/exports.d.ts +11 -0
  53. package/registerToken/dist/fetcher.d.ts +40 -0
  54. package/registerToken/dist/global-actions.d.ts +9 -0
  55. package/registerToken/dist/index.d.ts +1 -0
  56. package/registerToken/dist/lang-utils.d.ts +3 -0
  57. package/registerToken/dist/prop-types.d.ts +387 -0
  58. package/registerToken/dist/registerComponent.d.ts +231 -0
  59. package/registerToken/dist/registerGlobalContext.d.ts +76 -0
  60. package/registerToken/dist/registerTrait.d.ts +20 -0
  61. package/registerToken/dist/repeatedElement.d.ts +15 -0
  62. package/registerToken/dist/useForceUpdate.d.ts +1 -0
  63. package/registerToken/dist/version.d.ts +1 -0
  64. package/registerTrait/dist/canvas-host.d.ts +41 -0
  65. package/registerTrait/dist/common.d.ts +1 -0
  66. package/registerTrait/dist/data.d.ts +43 -0
  67. package/registerTrait/dist/element-types.d.ts +115 -0
  68. package/registerTrait/dist/exports.d.ts +11 -0
  69. package/registerTrait/dist/fetcher.d.ts +40 -0
  70. package/registerTrait/dist/global-actions.d.ts +9 -0
  71. package/registerTrait/dist/index.d.ts +1 -0
  72. package/registerTrait/dist/lang-utils.d.ts +3 -0
  73. package/registerTrait/dist/prop-types.d.ts +387 -0
  74. package/registerTrait/dist/registerComponent.d.ts +231 -0
  75. package/registerTrait/dist/registerGlobalContext.d.ts +76 -0
  76. package/registerTrait/dist/registerToken.d.ts +13 -0
  77. package/registerTrait/dist/repeatedElement.d.ts +15 -0
  78. package/registerTrait/dist/useForceUpdate.d.ts +1 -0
  79. package/registerTrait/dist/version.d.ts +1 -0
@@ -0,0 +1,387 @@
1
+ /// <reference types="react" />
2
+ import { CSSProperties, PlasmicElement } from "./element-types";
3
+ import { StyleSection } from "./registerComponent";
4
+ export interface CanvasComponentProps<Data = any> {
5
+ /**
6
+ * This prop is only provided within the canvas of Plasmic Studio.
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
+ };
14
+ export type InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;
15
+ /**
16
+ * Context that we pass back to control functions.
17
+ */
18
+ export type ControlContext<P> = [
19
+ /**
20
+ * props
21
+ */
22
+ P,
23
+ /**
24
+ * `contextData` can be `null` if the prop controls are rendering before
25
+ * the component instance itself (it will re-render once the component
26
+ * calls `setControlContextData`)
27
+ */
28
+ InferDataType<P> | null,
29
+ /**
30
+ * Extra information for the control to use
31
+ */
32
+ ControlExtras
33
+ ];
34
+ /**
35
+ * Config option that takes the context (e.g., props) of the component instance
36
+ * to dynamically set its value.
37
+ */
38
+ export type ContextDependentConfig<P, R> = (...args: ControlContext<P>) => R;
39
+ export interface PropTypeBase<P> {
40
+ displayName?: string;
41
+ description?: string;
42
+ helpText?: string;
43
+ /**
44
+ * If the user has chosen to use a dynamic expression for this prop, provide
45
+ * a hint as to the expected values that the expression should evaluate to.
46
+ * This hint will be displayed alongside the code editor. You may use
47
+ * markdown in the text here.
48
+ */
49
+ exprHint?: string;
50
+ /**
51
+ * Function for whether this prop should be hidden in the right panel,
52
+ * given the current props for this component
53
+ */
54
+ hidden?: ContextDependentConfig<P, boolean>;
55
+ readOnly?: boolean | ContextDependentConfig<P, boolean>;
56
+ /**
57
+ * If true, will hide the prop in a collapsed section; good for props that
58
+ * should not usually be used.
59
+ */
60
+ advanced?: boolean;
61
+ /**
62
+ * If true, does not allow the user to use a dynamic expression for this prop
63
+ */
64
+ disableDynamicValue?: boolean;
65
+ /**
66
+ * If set to true, the component will be remounted when the prop value is updated.
67
+ * (This behavior only applies to canvas)
68
+ */
69
+ forceRemount?: boolean;
70
+ }
71
+ interface Defaultable<P, T> {
72
+ /**
73
+ * Default value to set for this prop when the component is instantiated
74
+ */
75
+ defaultValue?: T;
76
+ /**
77
+ * If no prop is given, the component uses a default; specify whaat
78
+ * that default is so the Plasmic user can see it in the studio UI
79
+ */
80
+ defaultValueHint?: T | ContextDependentConfig<P, T | undefined>;
81
+ /**
82
+ * Use a dynamic value expression as the default instead
83
+ */
84
+ defaultExpr?: string;
85
+ defaultExprHint?: string;
86
+ }
87
+ interface Controllable {
88
+ /**
89
+ * If true, this is a prop that should only be used inside Plasmic
90
+ * Studio for rendering artboards; will not be actually used in
91
+ * generated code.
92
+ */
93
+ editOnly?: boolean;
94
+ /**
95
+ * If specified, the value used for this prop will instead be
96
+ * mapped to the uncontrolledProp when generating code. This is
97
+ * useful if, for example, in the artboard, you want to use `value`
98
+ * prop to control the component, but in generated code, you want to
99
+ * map it to `defaultValue`.
100
+ */
101
+ uncontrolledProp?: string;
102
+ }
103
+ interface PropTypeBaseDefault<P, T> extends PropTypeBase<P>, Defaultable<P, T>, Controllable {
104
+ }
105
+ interface PlainStringType<P> extends PropTypeBaseDefault<P, string> {
106
+ type: "string";
107
+ control?: "default" | "large";
108
+ }
109
+ interface CodeStringType<P> extends PropTypeBaseDefault<P, string> {
110
+ type: "code";
111
+ lang: "css" | "html" | "javascript" | "json";
112
+ }
113
+ interface RichTextType<P> extends PropTypeBaseDefault<P, string> {
114
+ type: "richText";
115
+ }
116
+ interface ColorType<P> extends PropTypeBaseDefault<P, string> {
117
+ type: "color";
118
+ /**
119
+ * If specified, and the user picks a color token in the Studio, then
120
+ * the value passed in as prop is a css variable reference, like
121
+ * `var(--TOKEN_ID)`, instead of the resolved hex value of the token.
122
+ * You should take care in using this in the proper css context --
123
+ * the css token is only defined if you are rendering under some
124
+ * Plasmic component in the DOM tree, which is usually the case,
125
+ * unless you are using a React portal.
126
+ */
127
+ keepCssVar?: boolean;
128
+ }
129
+ interface ClassType<P> extends PropTypeBase<P> {
130
+ type: "class";
131
+ /**
132
+ * Additional css selectors that can change how this style should look.
133
+ * Some examples:
134
+ *
135
+ * * `:hover` -- on hover
136
+ * * `[data-something="blah"] -- when the element with this class has
137
+ * an html attribute "data-something=blah"
138
+ * * :component[data-something="blah"] :self -- when the root of the
139
+ * component has an html attribute "data-something=blah". Note that
140
+ * the non-standard `:component` selector is used to select the
141
+ * component root, and the non-standard `:self` selector is used
142
+ * to select the element that this class is attached to.
143
+ */
144
+ selectors?: {
145
+ /**
146
+ * A css selector, like `:hover` or `[data-something="blah"]`.
147
+ */
148
+ selector: string;
149
+ /**
150
+ * An optional human-friendly label for the selector, so the studio user
151
+ * knows what this selector means.
152
+ */
153
+ label?: string;
154
+ }[];
155
+ /**
156
+ * If specified, then only shows these style sections for styling this class
157
+ */
158
+ styleSections?: StyleSection[];
159
+ }
160
+ interface ThemeResetClassType<P> extends PropTypeBase<P> {
161
+ type: "themeResetClass";
162
+ /**
163
+ * Normally, theme reset class will only target Plasmic-generated tags
164
+ * with the default tag styles. If you also want to target non-Plasmic-generated
165
+ * tags (say, rendered by your code components, or fetched as an HTML blob
166
+ * from somewhere), then specify `true` here.
167
+ */
168
+ targetAllTags?: boolean;
169
+ }
170
+ interface CardPickerType<P> extends PropTypeBaseDefault<P, string> {
171
+ type: "cardPicker";
172
+ modalTitle?: React.ReactNode | ContextDependentConfig<P, React.ReactNode>;
173
+ options: {
174
+ value: string;
175
+ label?: string;
176
+ imgUrl: string;
177
+ footer?: React.ReactNode;
178
+ }[] | ContextDependentConfig<P, {
179
+ value: string;
180
+ label?: string;
181
+ imgUrl: string;
182
+ footer?: React.ReactNode;
183
+ }[]>;
184
+ showInput?: boolean | ContextDependentConfig<P, boolean>;
185
+ onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;
186
+ }
187
+ type RichStringType<P> = PlainStringType<P> | CodeStringType<P> | RichTextType<P> | ColorType<P> | ClassType<P> | ThemeResetClassType<P> | CardPickerType<P>;
188
+ export type StringType<P> = "string" | RichStringType<P>;
189
+ interface RichBooleanType<P> extends PropTypeBaseDefault<P, boolean> {
190
+ type: "boolean";
191
+ }
192
+ export type BooleanType<P> = "boolean" | RichBooleanType<P>;
193
+ type GraphQLValue = {
194
+ query: string;
195
+ variables?: Record<string, any>;
196
+ };
197
+ interface GraphQLType<P> extends PropTypeBaseDefault<P, GraphQLValue> {
198
+ type: "code";
199
+ lang: "graphql";
200
+ endpoint: string | ContextDependentConfig<P, string>;
201
+ method?: string | ContextDependentConfig<P, string>;
202
+ headers?: object | ContextDependentConfig<P, object>;
203
+ }
204
+ interface NumberTypeBase<P> extends PropTypeBaseDefault<P, number> {
205
+ type: "number";
206
+ min?: number | ContextDependentConfig<P, number>;
207
+ max?: number | ContextDependentConfig<P, number>;
208
+ }
209
+ interface PlainNumberType<P> extends NumberTypeBase<P> {
210
+ control?: "default";
211
+ }
212
+ interface SliderNumberType<P> extends NumberTypeBase<P> {
213
+ control: "slider";
214
+ step?: number | ContextDependentConfig<P, number>;
215
+ }
216
+ type RichNumberType<P> = PlainNumberType<P> | SliderNumberType<P>;
217
+ export type NumberType<P> = "number" | RichNumberType<P>;
218
+ interface ObjectType<P> extends PropTypeBaseDefault<P, Record<string, any>> {
219
+ type: "object";
220
+ fields?: Record<string, PropType<P>>;
221
+ nameFunc?: (item: any, ...args: ControlContext<P>) => string | undefined;
222
+ }
223
+ interface ArrayType<P> extends PropTypeBaseDefault<P, any[]> {
224
+ type: "array";
225
+ itemType?: ObjectType<P>;
226
+ /**
227
+ * Optional function that determines whether the user can delete a given item.
228
+ */
229
+ unstable__canDelete?: (item: any, ...args: ControlContext<P>) => boolean;
230
+ /**
231
+ * Specify how to let Plasmic know how to update its own internal representation of the data when the value has
232
+ * changed, or when issuing a minimalValue or shownValue that is different.
233
+ *
234
+ * Important to specify this if you are expecting any nested expression values in this data type!
235
+ */
236
+ unstable__keyFunc?: (item: any) => any;
237
+ /**
238
+ * Specify what would be the tentative new value that is set if the user makes any changes.
239
+ *
240
+ * Useful for field mappings.
241
+ *
242
+ * For instance, consider a Table where we have a `fields` prop:
243
+ *
244
+ * - Initially, the value is undefined. But if the user makes any changes, we would want to save an array of at
245
+ * least three items (corresponding to, say, three columns inferred from a schema).
246
+ *
247
+ * - Let's say there are 5 columns in the value. The data schema changes, removing a column and adding two new
248
+ * ones. Now we would want a different minimal value, containing 6 items.
249
+ */
250
+ unstable__minimalValue?: ContextDependentConfig<P, any>;
251
+ }
252
+ export type JSONLikeType<P> = "object" | ObjectType<P> | ArrayType<P>;
253
+ export interface DataSourceType<P> extends PropTypeBase<P> {
254
+ type: "dataSource";
255
+ dataSource: "airtable" | "cms";
256
+ }
257
+ type DataPickerValueType = string | number | (string | number)[];
258
+ interface DataPickerType<P> extends PropTypeBaseDefault<P, DataPickerValueType> {
259
+ type: "dataSelector";
260
+ data: Record<string, any> | ContextDependentConfig<P, Record<string, any>>;
261
+ alwaysShowValuePathAsLabel?: boolean;
262
+ }
263
+ interface ExprEditorType<P> extends PropTypeBaseDefault<P, DataPickerValueType> {
264
+ type: "exprEditor";
265
+ data: Record<string, any> | ContextDependentConfig<P, Record<string, any>>;
266
+ }
267
+ interface FormValidationRulesType<P> extends PropTypeBaseDefault<P, any> {
268
+ type: "formValidationRules";
269
+ }
270
+ interface EventHandlerType<P> extends PropTypeBase<P> {
271
+ type: "eventHandler";
272
+ argTypes: {
273
+ name: string;
274
+ type: PropType<any>;
275
+ }[];
276
+ }
277
+ interface ChoiceTypeBase<P, T> extends PropTypeBaseDefault<P, T> {
278
+ type: "choice";
279
+ options: string[] | {
280
+ label: string;
281
+ value: string | number | boolean;
282
+ }[] | ContextDependentConfig<P, string[] | {
283
+ label: string;
284
+ value: string | number | boolean;
285
+ }[]>;
286
+ allowSearch?: boolean;
287
+ filterOption?: boolean;
288
+ onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;
289
+ }
290
+ interface SingleChoiceType<P> extends ChoiceTypeBase<P, string | number | boolean> {
291
+ multiSelect?: false;
292
+ }
293
+ interface MultiChoiceType<P> extends ChoiceTypeBase<P, (string | number | boolean)[]> {
294
+ multiSelect: true;
295
+ }
296
+ interface CustomChoiceType<P> extends ChoiceTypeBase<P, string | number | boolean | (string | number | boolean)[]> {
297
+ multiSelect: ContextDependentConfig<P, boolean>;
298
+ }
299
+ export type ChoiceType<P> = SingleChoiceType<P> | MultiChoiceType<P> | CustomChoiceType<P>;
300
+ interface RichSlotType<P> {
301
+ type: "slot";
302
+ /**
303
+ * The unique names of all code components that can be placed in the slot
304
+ */
305
+ allowedComponents?: string[];
306
+ /**
307
+ * Whether the "empty slot" placeholder should be hidden in the canvas.
308
+ */
309
+ hidePlaceholder?: boolean;
310
+ /**
311
+ * Whether the slot is repeated, i.e., is rendered multiple times using
312
+ * repeatedElement().
313
+ */
314
+ isRepeated?: boolean;
315
+ /**
316
+ * A nicer, human-readable display name for your slot prop
317
+ */
318
+ displayName?: string;
319
+ /**
320
+ * Function for whether this slot should be hidden from the left tree,
321
+ * given the current props for this component
322
+ */
323
+ hidden?: ContextDependentConfig<P, boolean>;
324
+ /**
325
+ * If slot is a render prop (accepts a function that takes in some
326
+ * arguments and returns some JSX), then specify the names of the
327
+ * arguments expected by the render prop function.
328
+ */
329
+ renderPropParams?: string[];
330
+ /**
331
+ * When inserting top-level "page sections", should this slot be the default target?
332
+ */
333
+ unstable__isMainContentSlot?: boolean;
334
+ defaultValue?: PlasmicElement | PlasmicElement[];
335
+ }
336
+ type SlotType<P> = "slot" | RichSlotType<P>;
337
+ interface RichImageUrlType<P> extends PropTypeBaseDefault<P, string> {
338
+ type: "imageUrl";
339
+ }
340
+ type ImageUrlType<P> = "imageUrl" | RichImageUrlType<P>;
341
+ export interface ModalProps {
342
+ show?: boolean;
343
+ children?: React.ReactNode;
344
+ onClose: () => void;
345
+ style?: CSSProperties;
346
+ }
347
+ interface CustomControlProps<P> {
348
+ componentProps: P;
349
+ /**
350
+ * `contextData` can be `null` if the prop controls are rendering before
351
+ * the component instance itself (it will re-render once the component
352
+ * calls `setControlContextData`)
353
+ */
354
+ contextData: InferDataType<P> | null;
355
+ value: any;
356
+ /**
357
+ * Sets the value to be passed to the prop. Expects a JSON-compatible value.
358
+ */
359
+ updateValue: (newVal: any) => void;
360
+ /**
361
+ * Full screen modal component
362
+ */
363
+ FullscreenModal: React.ComponentType<ModalProps>;
364
+ /**
365
+ * Modal component for the side pane
366
+ */
367
+ SideModal: React.ComponentType<ModalProps>;
368
+ /**
369
+ * The document that the component will be rendered into; instead of using
370
+ * `document` directly (for, say, `document.querySelector()` etc.), you
371
+ * should use this instead.
372
+ */
373
+ studioDocument: typeof document;
374
+ }
375
+ type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;
376
+ interface RichCustomType<P> extends PropTypeBaseDefault<P, any> {
377
+ type: "custom";
378
+ control: CustomControl<P>;
379
+ }
380
+ export type CustomType<P> = RichCustomType<P> | CustomControl<P>;
381
+ export type PrimitiveType<P = any> = Extract<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>, string>;
382
+ 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>;
383
+ type StringCompatType<P> = StringType<P> | ChoiceType<P> | JSONLikeType<P> | ImageUrlType<P> | CustomType<P> | DataPickerType<P>;
384
+ type BoolCompatType<P> = BooleanType<P> | CustomType<P> | DataPickerType<P>;
385
+ type NumberCompatType<P> = NumberType<P> | CustomType<P> | DataPickerType<P>;
386
+ export type RestrictPropType<T, P> = T extends string ? StringCompatType<P> : T extends boolean ? BoolCompatType<P> : T extends number ? NumberCompatType<P> : PropType<P>;
387
+ export {};