@plasmicapp/host 1.0.111 → 1.0.113

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.
@@ -67,6 +67,45 @@ export declare type StringType<P> = "string" | (({
67
67
  * unless you are using a React portal.
68
68
  */
69
69
  keepCssVar?: boolean;
70
+ } | {
71
+ type: "class";
72
+ /**
73
+ * Additional css selectors that can change how this style should look.
74
+ * Some examples:
75
+ *
76
+ * * `:hover` -- on hover
77
+ * * `[data-something="blah"] -- when the element with this class has
78
+ * an html attribute "data-something=blah"
79
+ * * :component[data-something="blah"] :self -- when the root of the
80
+ * component has an html attribute "data-something=blah". Note that
81
+ * the non-standard `:component` selector is used to select the
82
+ * component root, and the non-standard `:self` selector is used
83
+ * to select the element that this class is attached to.
84
+ */
85
+ selectors?: {
86
+ /**
87
+ * A css selector, like `:hover` or `[data-something="blah"]`.
88
+ */
89
+ selector: string;
90
+ /**
91
+ * An optional human-friendly label for the selector, so the studio user
92
+ * knows what this selector means.
93
+ */
94
+ label?: string;
95
+ }[];
96
+ /**
97
+ * If specified, then only shows these style sections for styling this class
98
+ */
99
+ styleSections?: StyleSection[];
100
+ } | {
101
+ type: "themeResetClass";
102
+ /**
103
+ * Normally, theme reset class will only target Plasmic-generated tags
104
+ * with the default tag styles. If you also want to target non-Plasmic-generated
105
+ * tags (say, rendered by your code components, or fetched as an HTML blob
106
+ * from somewhere), then specify `true` here.
107
+ */
108
+ targetAllTags?: boolean;
70
109
  } | {
71
110
  type: "cardPicker";
72
111
  modalTitle?: React.ReactNode | ContextDependentConfig<P, React.ReactNode>;
@@ -144,6 +183,13 @@ export declare type DataPickerType<P> = ({
144
183
  type: "exprEditor";
145
184
  data: Record<string, any> | ContextDependentConfig<P, Record<string, any>>;
146
185
  } & DefaultValueOrExpr<P, DataPickerValueType> & PropTypeBase<P>);
186
+ export declare type EventHandlerType<P> = {
187
+ type: "eventHandler";
188
+ argTypes: {
189
+ name: string;
190
+ type: PropType<any>;
191
+ }[];
192
+ } & DefaultValueOrExpr<P, (...args: any) => any> & PropTypeBase<P>;
147
193
  interface ChoiceTypeBase<P> extends PropTypeBase<P> {
148
194
  type: "choice";
149
195
  options: string[] | {
@@ -242,7 +288,7 @@ declare type ControlTypeBase = {
242
288
  uncontrolledProp?: string;
243
289
  };
244
290
  export declare type SupportControlled<T> = Extract<T, String | CustomControl<any>> | (Exclude<T, String | CustomControl<any>> & ControlTypeBase);
245
- export declare type PropType<P> = SupportControlled<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | ImageUrlType<P> | CustomType<P> | GraphQLType<P> | DataPickerType<P>> | SlotType<P>;
291
+ export declare type PropType<P> = SupportControlled<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | ImageUrlType<P> | CustomType<P> | GraphQLType<P> | DataPickerType<P> | EventHandlerType<P>> | SlotType<P>;
246
292
  declare 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>;
247
293
  export interface ActionProps<P> {
248
294
  componentProps: P;
@@ -286,16 +332,48 @@ interface ComponentTemplate<P> extends Omit<CodeComponentElement<P>, "type" | "n
286
332
  export interface ComponentTemplates<P> {
287
333
  [name: string]: ComponentTemplate<P>;
288
334
  }
289
- interface $State {
290
- [key: string]: any;
291
- }
292
- interface $StateSpec<T> {
293
- type: "private" | "readonly" | "writable";
294
- initFunc?: ($props: Record<string, any>, $state: $State) => T;
295
- initVal?: T;
296
- valueProp?: string;
297
- onChangeProp?: string;
335
+ export declare type StateSpec = {
336
+ onChangeProp: string;
337
+ } & ({
338
+ type: "readonly";
339
+ variableType: "text";
340
+ initVal?: string;
341
+ } | {
342
+ type: "readonly";
343
+ variableType: "number";
344
+ initVal?: number;
345
+ } | {
346
+ type: "readonly";
347
+ variableType: "boolean";
348
+ initVal?: boolean;
349
+ } | {
350
+ type: "readonly";
351
+ variableType: "array";
352
+ initVal?: any[];
353
+ } | {
354
+ type: "readonly";
355
+ variableType: "object";
356
+ initVal?: object;
357
+ } | {
358
+ type: "writable";
359
+ variableType: "text" | "number" | "boolean" | "array" | "object";
360
+ valueProp: string;
361
+ });
362
+ export interface StateHelpers<P, T> {
363
+ initFunc?: ($props: P) => T;
364
+ onChangeArgsToValue?: (...args: any) => T;
298
365
  }
366
+ export declare type ComponentHelpers<P> = {
367
+ helpers: {
368
+ states: Record<string, StateHelpers<P, any>>;
369
+ };
370
+ importPath: string;
371
+ } & ({
372
+ importName: string;
373
+ } | {
374
+ isDefaultExport: true;
375
+ });
376
+ export declare type StyleSection = "visibility" | "typography" | "sizing" | "spacing" | "background" | "transform" | "transitions" | "layout" | "overflow" | "border" | "shadows" | "effects";
299
377
  export interface ComponentMeta<P> {
300
378
  /**
301
379
  * Any unique string name used to identify that component. Each component
@@ -328,18 +406,27 @@ export interface ComponentMeta<P> {
328
406
  [prop: string]: PropType<P>;
329
407
  };
330
408
  /**
331
- * WIP: An object describing the component states to be used in Studio.
409
+ * An object describing the component states to be used in Studio.
410
+ */
411
+ states?: Record<string, StateSpec>;
412
+ /**
413
+ * An object describing the components helpers to be used in Studio.
414
+ * 1. states helpers: Each state can receive an "initFunc" prop to initialize
415
+ * the implicit state in Studio, and an "onChangeArgsToValue" prop to
416
+ * transform the event handler arguments into a value
332
417
  */
333
- unstable__states?: Record<string, $StateSpec<any>>;
418
+ componentHelpers?: ComponentHelpers<P>;
334
419
  /**
335
420
  * An array describing the component actions to be used in Studio.
336
421
  */
337
422
  actions?: Action<P>[];
338
423
  /**
339
424
  * Whether style sections should be shown in Studio. For styles to work, the
340
- * component must accept a `className` prop. If unset, defaults to true.
425
+ * component must accept a `className` prop. If unset, defaults to all styles.
426
+ * Set to `false` if this component cannot be styled (for example, if it doesn't
427
+ * render any DOM elements).
341
428
  */
342
- styleSections?: boolean;
429
+ styleSections?: StyleSection[] | boolean;
343
430
  /**
344
431
  * Whether the element can be repeated in Studio. If unset, defaults to true.
345
432
  */