@plasmicapp/react-web 0.2.210 → 0.2.214

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 (2) hide show
  1. package/dist/all.d.ts +346 -327
  2. package/package.json +4 -4
package/dist/all.d.ts CHANGED
@@ -10992,6 +10992,228 @@ interface CodeComponentElement<P> {
10992
10992
  }
10993
10993
  type PlasmicElement = ImageElement | TextElement | ContainerElement | ButtonElement | TextInputElement | CodeComponentElement<{}> | DefaultComponentElement<{}>;
10994
10994
 
10995
+ interface ActionProps<P> {
10996
+ componentProps: P;
10997
+ /**
10998
+ * `contextData` can be `null` if the prop controls are rendering before
10999
+ * the component instance itself (it will re-render once the component
11000
+ * calls `setControlContextData`)
11001
+ */
11002
+ contextData: InferDataType<P> | null;
11003
+ studioOps: {
11004
+ showModal: (modalProps: Omit<ModalProps, "onClose"> & {
11005
+ onClose?: () => void;
11006
+ }) => void;
11007
+ refreshQueryData: () => void;
11008
+ appendToSlot: (element: PlasmicElement, slotName: string) => void;
11009
+ removeFromSlotAt: (pos: number, slotName: string) => void;
11010
+ updateProps: (newValues: any) => void;
11011
+ };
11012
+ /**
11013
+ * The document that the component will be rendered into; instead of using
11014
+ * `document` directly (for, say, `document.querySelector()` etc.), you
11015
+ * should use this instead.
11016
+ */
11017
+ studioDocument: typeof document;
11018
+ }
11019
+ type Action<P> = {
11020
+ type: "button-action";
11021
+ label: string;
11022
+ onClick: (props: ActionProps<P>) => void;
11023
+ hidden?: ContextDependentConfig<P, boolean>;
11024
+ } | {
11025
+ type: "custom-action";
11026
+ control: React.ComponentType<ActionProps<P>>;
11027
+ hidden?: ContextDependentConfig<P, boolean>;
11028
+ };
11029
+ type DistributedKeyOf$1<T> = T extends any ? keyof T : never;
11030
+ interface ComponentTemplate<P> extends Omit<CodeComponentElement<P>, "type" | "name"> {
11031
+ /**
11032
+ * A preview picture for the template.
11033
+ */
11034
+ previewImg?: string;
11035
+ }
11036
+ interface ComponentTemplates<P> {
11037
+ [name: string]: ComponentTemplate<P>;
11038
+ }
11039
+ type StateSpec = {
11040
+ onChangeProp: string;
11041
+ } & ({
11042
+ type: "readonly";
11043
+ variableType: "text";
11044
+ initVal?: string;
11045
+ } | {
11046
+ type: "readonly";
11047
+ variableType: "number";
11048
+ initVal?: number;
11049
+ } | {
11050
+ type: "readonly";
11051
+ variableType: "boolean";
11052
+ initVal?: boolean;
11053
+ } | {
11054
+ type: "readonly";
11055
+ variableType: "array";
11056
+ initVal?: any[];
11057
+ } | {
11058
+ type: "readonly";
11059
+ variableType: "object";
11060
+ initVal?: object;
11061
+ } | {
11062
+ type: "writable";
11063
+ variableType: "text" | "number" | "boolean" | "array" | "object";
11064
+ valueProp: string;
11065
+ });
11066
+ interface StateHelpers<P, T> {
11067
+ initFunc?: ($props: P) => T;
11068
+ onChangeArgsToValue?: (...args: any) => T;
11069
+ }
11070
+ type ComponentHelpers<P> = {
11071
+ states: Record<string, StateHelpers<P, any>>;
11072
+ };
11073
+ type ExternalComponentHelpers<P> = {
11074
+ helpers: ComponentHelpers<P>;
11075
+ importPath: string;
11076
+ } & ({
11077
+ importName: string;
11078
+ } | {
11079
+ isDefaultExport: true;
11080
+ });
11081
+ type StyleSection = "visibility" | "typography" | "sizing" | "spacing" | "background" | "transform" | "transitions" | "layout" | "overflow" | "border" | "shadows" | "effects";
11082
+ interface CodeComponentMeta<P> {
11083
+ /**
11084
+ * Any unique string name used to identify that component. Each component
11085
+ * should be registered with a different `meta.name`, even if they have the
11086
+ * same name in the code.
11087
+ */
11088
+ name: string;
11089
+ /**
11090
+ * The name to be displayed for the component in Studio. Optional: if not
11091
+ * specified, `meta.name` is used.
11092
+ */
11093
+ displayName?: string;
11094
+ /**
11095
+ * The description of the component to be shown in Studio.
11096
+ */
11097
+ description?: string;
11098
+ /**
11099
+ * The javascript name to be used when generating code. Optional: if not
11100
+ * provided, `meta.name` is used.
11101
+ */
11102
+ importName?: string;
11103
+ /**
11104
+ * An object describing the component properties to be used in Studio.
11105
+ * For each `prop`, there should be an entry `meta.props[prop]` describing
11106
+ * its type.
11107
+ */
11108
+ props: {
11109
+ [prop in DistributedKeyOf$1<P>]?: RestrictPropType$1<P[prop], P>;
11110
+ } & {
11111
+ [prop: string]: PropType$1<P>;
11112
+ };
11113
+ /**
11114
+ * An object describing the component states to be used in Studio.
11115
+ */
11116
+ states?: Record<string, StateSpec>;
11117
+ /**
11118
+ * An object describing the components helpers to be used in Studio.
11119
+ * 1. states helpers: Each state can receive an "initFunc" prop to initialize
11120
+ * the implicit state in Studio, and an "onChangeArgsToValue" prop to
11121
+ * transform the event handler arguments into a value
11122
+ */
11123
+ componentHelpers?: ExternalComponentHelpers<P>;
11124
+ /**
11125
+ * An array describing the component actions to be used in Studio.
11126
+ */
11127
+ actions?: Action<P>[];
11128
+ /**
11129
+ * Whether style sections should be shown in Studio. For styles to work, the
11130
+ * component must accept a `className` prop. If unset, defaults to all styles.
11131
+ * Set to `false` if this component cannot be styled (for example, if it doesn't
11132
+ * render any DOM elements).
11133
+ */
11134
+ styleSections?: StyleSection[] | boolean;
11135
+ /**
11136
+ * Whether the element can be repeated in Studio. If unset, defaults to true.
11137
+ */
11138
+ isRepeatable?: boolean;
11139
+ /**
11140
+ * The path to be used when importing the component in the generated code.
11141
+ * It can be the name of the package that contains the component, or the path
11142
+ * to the file in the project (relative to the root directory).
11143
+ */
11144
+ importPath: string;
11145
+ /**
11146
+ * Whether the component is the default export from that path. Optional: if
11147
+ * not specified, it's considered `false`.
11148
+ */
11149
+ isDefaultExport?: boolean;
11150
+ /**
11151
+ * The prop that expects the CSS classes with styles to be applied to the
11152
+ * component. Optional: if not specified, Plasmic will expect it to be
11153
+ * `className`. Notice that if the component does not accept CSS classes, the
11154
+ * component will not be able to receive styles from the Studio.
11155
+ */
11156
+ classNameProp?: string;
11157
+ /**
11158
+ * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`
11159
+ * to interact with components, so it's not used in the generated code.
11160
+ * Optional: If not provided, the usual `ref` is used.
11161
+ */
11162
+ refProp?: string;
11163
+ /**
11164
+ * Default styles to start with when instantiating the component in Plasmic.
11165
+ */
11166
+ defaultStyles?: CSSProperties;
11167
+ /**
11168
+ * Component templates to start with on Plasmic.
11169
+ */
11170
+ templates?: ComponentTemplates<P>;
11171
+ /**
11172
+ * Registered name of parent component, used for grouping related components.
11173
+ */
11174
+ parentComponentName?: string;
11175
+ /**
11176
+ * Whether the component can be used as an attachment to an element.
11177
+ */
11178
+ isAttachment?: boolean;
11179
+ /**
11180
+ * Whether the component provides data to its slots using DataProvider.
11181
+ */
11182
+ providesData?: boolean;
11183
+ /**
11184
+ * If specified, then Figma components with the specified names will be mapped
11185
+ * to this component when you paste Figma content into Plasmic
11186
+ */
11187
+ figmaMappings?: {
11188
+ figmaComponentName: string;
11189
+ }[];
11190
+ /**
11191
+ * If true, when an instance of this component is added, the element
11192
+ * will always be named by the name of this component.
11193
+ */
11194
+ alwaysAutoName?: boolean;
11195
+ refActions?: Record<string, RefActionRegistration<P>>;
11196
+ }
11197
+ interface FunctionParam<P> {
11198
+ name: string;
11199
+ displayName?: string;
11200
+ type: PropType$1<P>;
11201
+ }
11202
+ interface RefActionRegistration<P> {
11203
+ displayName?: string;
11204
+ description?: string;
11205
+ argTypes: FunctionParam<P>[];
11206
+ }
11207
+ interface ComponentRegistration {
11208
+ component: React.ComponentType<any>;
11209
+ meta: CodeComponentMeta<any>;
11210
+ }
11211
+ declare global {
11212
+ interface Window {
11213
+ __PlasmicComponentRegistry: ComponentRegistration[];
11214
+ }
11215
+ }
11216
+
10995
11217
  interface CanvasComponentProps<Data = any> {
10996
11218
  /**
10997
11219
  * This prop is only provided within the canvas of Plasmic Studio.
@@ -10999,10 +11221,10 @@ interface CanvasComponentProps<Data = any> {
10999
11221
  */
11000
11222
  setControlContextData?: (data: Data) => void;
11001
11223
  }
11002
- type InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;
11003
11224
  type ControlExtras = {
11004
11225
  path: (string | number)[];
11005
11226
  };
11227
+ type InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;
11006
11228
  /**
11007
11229
  * Context that we pass back to control functions.
11008
11230
  */
@@ -11055,31 +11277,56 @@ interface PropTypeBase<P> {
11055
11277
  disableDynamicValue?: boolean;
11056
11278
  /**
11057
11279
  * If set to true, the component will be remounted when the prop value is updated.
11058
- * (This behavior only appliees to canvas)
11280
+ * (This behavior only applies to canvas)
11059
11281
  */
11060
11282
  forceRemount?: boolean;
11061
11283
  }
11062
- type DefaultValueOrExpr<P, T> = {
11063
- defaultExpr?: undefined;
11064
- defaultExprHint?: undefined;
11284
+ interface Defaultable<P, T> {
11285
+ /**
11286
+ * Default value to set for this prop when the component is instantiated
11287
+ */
11065
11288
  defaultValue?: T;
11289
+ /**
11290
+ * If no prop is given, the component uses a default; specify whaat
11291
+ * that default is so the Plasmic user can see it in the studio UI
11292
+ */
11066
11293
  defaultValueHint?: T | ContextDependentConfig<P, T | undefined>;
11067
- } | {
11068
- defaultValue?: undefined;
11069
- defaultValueHint?: undefined;
11294
+ /**
11295
+ * Use a dynamic value expression as the default instead
11296
+ */
11070
11297
  defaultExpr?: string;
11071
11298
  defaultExprHint?: string;
11072
- };
11073
- type StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, string>;
11074
- type StringType<P> = "string" | (({
11299
+ }
11300
+ interface Controllable {
11301
+ /**
11302
+ * If true, this is a prop that should only be used inside Plasmic
11303
+ * Studio for rendering artboards; will not be actually used in
11304
+ * generated code.
11305
+ */
11306
+ editOnly?: boolean;
11307
+ /**
11308
+ * If specified, the value used for this prop will instead be
11309
+ * mapped to the uncontrolledProp when generating code. This is
11310
+ * useful if, for example, in the artboard, you want to use `value`
11311
+ * prop to control the component, but in generated code, you want to
11312
+ * map it to `defaultValue`.
11313
+ */
11314
+ uncontrolledProp?: string;
11315
+ }
11316
+ interface PropTypeBaseDefault<P, T> extends PropTypeBase<P>, Defaultable<P, T>, Controllable {
11317
+ }
11318
+ interface PlainStringType<P> extends PropTypeBaseDefault<P, string> {
11075
11319
  type: "string";
11076
11320
  control?: "default" | "large";
11077
- } | {
11321
+ }
11322
+ interface CodeStringType<P> extends PropTypeBaseDefault<P, string> {
11078
11323
  type: "code";
11079
11324
  lang: "css" | "html" | "javascript" | "json";
11080
- } | {
11325
+ }
11326
+ interface RichTextType<P> extends PropTypeBaseDefault<P, string> {
11081
11327
  type: "richText";
11082
- } | {
11328
+ }
11329
+ interface ColorType<P> extends PropTypeBaseDefault<P, string> {
11083
11330
  type: "color";
11084
11331
  /**
11085
11332
  * If specified, and the user picks a color token in the Studio, then
@@ -11091,7 +11338,8 @@ type StringType<P> = "string" | (({
11091
11338
  * unless you are using a React portal.
11092
11339
  */
11093
11340
  keepCssVar?: boolean;
11094
- } | {
11341
+ }
11342
+ interface ClassType<P> extends PropTypeBase<P> {
11095
11343
  type: "class";
11096
11344
  /**
11097
11345
  * Additional css selectors that can change how this style should look.
@@ -11121,7 +11369,8 @@ type StringType<P> = "string" | (({
11121
11369
  * If specified, then only shows these style sections for styling this class
11122
11370
  */
11123
11371
  styleSections?: StyleSection[];
11124
- } | {
11372
+ }
11373
+ interface ThemeResetClassType<P> extends PropTypeBase<P> {
11125
11374
  type: "themeResetClass";
11126
11375
  /**
11127
11376
  * Normally, theme reset class will only target Plasmic-generated tags
@@ -11130,7 +11379,8 @@ type StringType<P> = "string" | (({
11130
11379
  * from somewhere), then specify `true` here.
11131
11380
  */
11132
11381
  targetAllTags?: boolean;
11133
- } | {
11382
+ }
11383
+ interface CardPickerType<P> extends PropTypeBaseDefault<P, string> {
11134
11384
  type: "cardPicker";
11135
11385
  modalTitle?: React.ReactNode | ContextDependentConfig<P, React.ReactNode>;
11136
11386
  options: {
@@ -11146,58 +11396,46 @@ type StringType<P> = "string" | (({
11146
11396
  }[]>;
11147
11397
  showInput?: boolean | ContextDependentConfig<P, boolean>;
11148
11398
  onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;
11149
- }) & StringTypeBase<P>);
11150
- type BooleanType<P> = "boolean" | ({
11399
+ }
11400
+ type RichStringType<P> = PlainStringType<P> | CodeStringType<P> | RichTextType<P> | ColorType<P> | ClassType<P> | ThemeResetClassType<P> | CardPickerType<P>;
11401
+ type StringType<P> = "string" | RichStringType<P>;
11402
+ interface RichBooleanType<P> extends PropTypeBaseDefault<P, boolean> {
11151
11403
  type: "boolean";
11152
- } & DefaultValueOrExpr<P, boolean> & PropTypeBase<P>);
11404
+ }
11405
+ type BooleanType<P> = "boolean" | RichBooleanType<P>;
11153
11406
  type GraphQLValue = {
11154
11407
  query: string;
11155
11408
  variables?: Record<string, any>;
11156
11409
  };
11157
- type GraphQLType<P> = {
11410
+ interface GraphQLType<P> extends PropTypeBaseDefault<P, GraphQLValue> {
11158
11411
  type: "code";
11159
11412
  lang: "graphql";
11160
11413
  endpoint: string | ContextDependentConfig<P, string>;
11161
11414
  method?: string | ContextDependentConfig<P, string>;
11162
11415
  headers?: object | ContextDependentConfig<P, object>;
11163
- } & DefaultValueOrExpr<P, GraphQLValue> & PropTypeBase<P>;
11164
- type NumberTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, number> & {
11416
+ }
11417
+ interface NumberTypeBase<P> extends PropTypeBaseDefault<P, number> {
11165
11418
  type: "number";
11166
- };
11167
- type NumberType<P> = "number" | (({
11168
- control?: "default";
11169
11419
  min?: number | ContextDependentConfig<P, number>;
11170
11420
  max?: number | ContextDependentConfig<P, number>;
11171
- } | {
11421
+ }
11422
+ interface PlainNumberType<P> extends NumberTypeBase<P> {
11423
+ control?: "default";
11424
+ }
11425
+ interface SliderNumberType<P> extends NumberTypeBase<P> {
11172
11426
  control: "slider";
11173
- min: number | ContextDependentConfig<P, number>;
11174
- max: number | ContextDependentConfig<P, number>;
11175
11427
  step?: number | ContextDependentConfig<P, number>;
11176
- }) & NumberTypeBase<P>);
11177
- /**
11178
- * Expects defaultValue to be a JSON-compatible value
11179
- */
11180
- type JSONLikeType<P> = "object" | ({
11428
+ }
11429
+ type RichNumberType<P> = PlainNumberType<P> | SliderNumberType<P>;
11430
+ type NumberType<P> = "number" | RichNumberType<P>;
11431
+ interface ObjectType<P> extends PropTypeBaseDefault<P, Record<string, any>> {
11181
11432
  type: "object";
11182
- fields?: {
11183
- [p: string]: PropType$1<P>;
11184
- };
11185
- /**
11186
- * Optional function that generates a name for this item in the array
11187
- */
11433
+ fields?: Record<string, PropType$1<P>>;
11188
11434
  nameFunc?: (item: any, ...args: ControlContext<P>) => string | undefined;
11189
- } & DefaultValueOrExpr<P, any> & PropTypeBase<P>) | ({
11435
+ }
11436
+ interface ArrayType<P> extends PropTypeBaseDefault<P, any[]> {
11190
11437
  type: "array";
11191
- itemType?: {
11192
- type: "object";
11193
- fields: {
11194
- [p: string]: PropType$1<P>;
11195
- };
11196
- /**
11197
- * Optional function that generates a name for this item in the array
11198
- */
11199
- nameFunc?: (item: any, ...args: ControlContext<P>) => string | undefined;
11200
- };
11438
+ itemType?: ObjectType<P>;
11201
11439
  /**
11202
11440
  * Optional function that determines whether the user can delete a given item.
11203
11441
  */
@@ -11223,30 +11461,33 @@ type JSONLikeType<P> = "object" | ({
11223
11461
  * ones. Now we would want a different minimal value, containing 6 items.
11224
11462
  */
11225
11463
  unstable__minimalValue?: ContextDependentConfig<P, any>;
11226
- } & DefaultValueOrExpr<P, any[]> & PropTypeBase<P>) | ({
11464
+ }
11465
+ type JSONLikeType<P> = "object" | ObjectType<P> | ArrayType<P>;
11466
+ interface DataSourceType<P> extends PropTypeBase<P> {
11227
11467
  type: "dataSource";
11228
11468
  dataSource: "airtable" | "cms";
11229
- } & PropTypeBase<P>);
11469
+ }
11230
11470
  type DataPickerValueType = string | number | (string | number)[];
11231
- type DataPickerType<P> = ({
11471
+ interface DataPickerType<P> extends PropTypeBaseDefault<P, DataPickerValueType> {
11232
11472
  type: "dataSelector";
11233
11473
  data: Record<string, any> | ContextDependentConfig<P, Record<string, any>>;
11234
11474
  alwaysShowValuePathAsLabel?: boolean;
11235
- } & DefaultValueOrExpr<P, DataPickerValueType> & PropTypeBase<P>) | ({
11475
+ }
11476
+ interface ExprEditorType<P> extends PropTypeBaseDefault<P, DataPickerValueType> {
11236
11477
  type: "exprEditor";
11237
11478
  data: Record<string, any> | ContextDependentConfig<P, Record<string, any>>;
11238
- } & DefaultValueOrExpr<P, DataPickerValueType> & PropTypeBase<P>);
11239
- type FormValidationRulesType<P> = {
11479
+ }
11480
+ interface FormValidationRulesType<P> extends PropTypeBaseDefault<P, any> {
11240
11481
  type: "formValidationRules";
11241
- } & DefaultValueOrExpr<P, any> & PropTypeBase<P>;
11242
- type EventHandlerType<P> = {
11482
+ }
11483
+ interface EventHandlerType<P> extends PropTypeBase<P> {
11243
11484
  type: "eventHandler";
11244
11485
  argTypes: {
11245
11486
  name: string;
11246
11487
  type: PropType$1<any>;
11247
11488
  }[];
11248
- } & DefaultValueOrExpr<P, (...args: any) => any> & PropTypeBase<P>;
11249
- interface ChoiceTypeBase<P> extends PropTypeBase<P> {
11489
+ }
11490
+ interface ChoiceTypeBase<P, T> extends PropTypeBaseDefault<P, T> {
11250
11491
  type: "choice";
11251
11492
  options: string[] | {
11252
11493
  label: string;
@@ -11259,56 +11500,17 @@ interface ChoiceTypeBase<P> extends PropTypeBase<P> {
11259
11500
  filterOption?: boolean;
11260
11501
  onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;
11261
11502
  }
11262
- type ChoiceType<P> = (({
11503
+ interface SingleChoiceType<P> extends ChoiceTypeBase<P, string | number | boolean> {
11263
11504
  multiSelect?: false;
11264
- } & DefaultValueOrExpr<P, string | number | boolean>) | ({
11505
+ }
11506
+ interface MultiChoiceType<P> extends ChoiceTypeBase<P, (string | number | boolean)[]> {
11265
11507
  multiSelect: true;
11266
- } & DefaultValueOrExpr<P, (string | number | boolean)[]>) | ({
11267
- multiSelect: ContextDependentConfig<P, boolean>;
11268
- } & DefaultValueOrExpr<P, string | number | boolean | (string | number | boolean)[]>)) & ChoiceTypeBase<P>;
11269
- interface ModalProps {
11270
- show?: boolean;
11271
- children?: React.ReactNode;
11272
- onClose: () => void;
11273
- style?: CSSProperties;
11274
11508
  }
11275
- interface CustomControlProps<P> {
11276
- componentProps: P;
11277
- /**
11278
- * `contextData` can be `null` if the prop controls are rendering before
11279
- * the component instance itself (it will re-render once the component
11280
- * calls `setControlContextData`)
11281
- */
11282
- contextData: InferDataType<P> | null;
11283
- value: any;
11284
- /**
11285
- * Sets the value to be passed to the prop. Expects a JSON-compatible value.
11286
- */
11287
- updateValue: (newVal: any) => void;
11288
- /**
11289
- * Full screen modal component
11290
- */
11291
- FullscreenModal: React.ComponentType<ModalProps>;
11292
- /**
11293
- * Modal component for the side pane
11294
- */
11295
- SideModal: React.ComponentType<ModalProps>;
11296
- /**
11297
- * The document that the component will be rendered into; instead of using
11298
- * `document` directly (for, say, `document.querySelector()` etc.), you
11299
- * should use this instead.
11300
- */
11301
- studioDocument: typeof document;
11509
+ interface CustomChoiceType<P> extends ChoiceTypeBase<P, string | number | boolean | (string | number | boolean)[]> {
11510
+ multiSelect: ContextDependentConfig<P, boolean>;
11302
11511
  }
11303
- type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;
11304
- /**
11305
- * Expects defaultValue to be a JSON-compatible value
11306
- */
11307
- type CustomType<P> = CustomControl<P> | ({
11308
- type: "custom";
11309
- control: CustomControl<P>;
11310
- } & PropTypeBase<P> & DefaultValueOrExpr<P, any>);
11311
- type SlotType<P> = "slot" | ({
11512
+ type ChoiceType<P> = SingleChoiceType<P> | MultiChoiceType<P> | CustomChoiceType<P>;
11513
+ interface RichSlotType<P> {
11312
11514
  type: "slot";
11313
11515
  /**
11314
11516
  * The unique names of all code components that can be placed in the slot
@@ -11342,24 +11544,20 @@ type SlotType<P> = "slot" | ({
11342
11544
  * When inserting top-level "page sections", should this slot be the default target?
11343
11545
  */
11344
11546
  unstable__isMainContentSlot?: boolean;
11345
- } & Omit<DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>, "defaultValueHint" | "defaultExpr" | "defaultExprHint">);
11346
- type ImageUrlType<P> = "imageUrl" | ({
11547
+ defaultValue?: PlasmicElement | PlasmicElement[];
11548
+ }
11549
+ type SlotType<P> = "slot" | RichSlotType<P>;
11550
+ interface RichImageUrlType<P> extends PropTypeBaseDefault<P, string> {
11347
11551
  type: "imageUrl";
11348
- } & DefaultValueOrExpr<P, string> & PropTypeBase<P>);
11349
- type PrimitiveType<P = any> = Extract<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>, string>;
11350
- type ControlTypeBase = {
11351
- editOnly?: false;
11352
- } | {
11353
- editOnly: true;
11354
- /**
11355
- * The prop where the values should be mapped to
11356
- */
11357
- uncontrolledProp?: string;
11358
- };
11359
- type SupportControlled<T> = Extract<T, string | CustomControl<any>> | (Exclude<T, string | CustomControl<any>> & ControlTypeBase);
11360
- type PropType$1<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>;
11361
- type RestrictPropType$1<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$1<P>;
11362
- interface ActionProps<P> {
11552
+ }
11553
+ type ImageUrlType<P> = "imageUrl" | RichImageUrlType<P>;
11554
+ interface ModalProps {
11555
+ show?: boolean;
11556
+ children?: React.ReactNode;
11557
+ onClose: () => void;
11558
+ style?: CSSProperties;
11559
+ }
11560
+ interface CustomControlProps<P> {
11363
11561
  componentProps: P;
11364
11562
  /**
11365
11563
  * `contextData` can be `null` if the prop controls are rendering before
@@ -11367,217 +11565,38 @@ interface ActionProps<P> {
11367
11565
  * calls `setControlContextData`)
11368
11566
  */
11369
11567
  contextData: InferDataType<P> | null;
11370
- studioOps: {
11371
- showModal: (modalProps: Omit<ModalProps, "onClose"> & {
11372
- onClose?: () => void;
11373
- }) => void;
11374
- refreshQueryData: () => void;
11375
- appendToSlot: (element: PlasmicElement, slotName: string) => void;
11376
- removeFromSlotAt: (pos: number, slotName: string) => void;
11377
- updateProps: (newValues: any) => void;
11378
- };
11379
- /**
11380
- * The document that the component will be rendered into; instead of using
11381
- * `document` directly (for, say, `document.querySelector()` etc.), you
11382
- * should use this instead.
11383
- */
11384
- studioDocument: typeof document;
11385
- }
11386
- type Action<P> = {
11387
- type: "button-action";
11388
- label: string;
11389
- onClick: (props: ActionProps<P>) => void;
11390
- } | {
11391
- type: "custom-action";
11392
- control: React.ComponentType<ActionProps<P>>;
11393
- };
11394
- type DistributedKeyOf$1<T> = T extends any ? keyof T : never;
11395
- interface ComponentTemplate<P> extends Omit<CodeComponentElement<P>, "type" | "name"> {
11396
- /**
11397
- * A preview picture for the template.
11398
- */
11399
- previewImg?: string;
11400
- }
11401
- interface ComponentTemplates<P> {
11402
- [name: string]: ComponentTemplate<P>;
11403
- }
11404
- type StateSpec = {
11405
- onChangeProp: string;
11406
- } & ({
11407
- type: "readonly";
11408
- variableType: "text";
11409
- initVal?: string;
11410
- } | {
11411
- type: "readonly";
11412
- variableType: "number";
11413
- initVal?: number;
11414
- } | {
11415
- type: "readonly";
11416
- variableType: "boolean";
11417
- initVal?: boolean;
11418
- } | {
11419
- type: "readonly";
11420
- variableType: "array";
11421
- initVal?: any[];
11422
- } | {
11423
- type: "readonly";
11424
- variableType: "object";
11425
- initVal?: object;
11426
- } | {
11427
- type: "writable";
11428
- variableType: "text" | "number" | "boolean" | "array" | "object";
11429
- valueProp: string;
11430
- });
11431
- interface StateHelpers<P, T> {
11432
- initFunc?: ($props: P) => T;
11433
- onChangeArgsToValue?: (...args: any) => T;
11434
- }
11435
- type ComponentHelpers<P> = {
11436
- states: Record<string, StateHelpers<P, any>>;
11437
- };
11438
- type ExternalComponentHelpers<P> = {
11439
- helpers: ComponentHelpers<P>;
11440
- importPath: string;
11441
- } & ({
11442
- importName: string;
11443
- } | {
11444
- isDefaultExport: true;
11445
- });
11446
- type StyleSection = "visibility" | "typography" | "sizing" | "spacing" | "background" | "transform" | "transitions" | "layout" | "overflow" | "border" | "shadows" | "effects";
11447
- interface CodeComponentMeta<P> {
11448
- /**
11449
- * Any unique string name used to identify that component. Each component
11450
- * should be registered with a different `meta.name`, even if they have the
11451
- * same name in the code.
11452
- */
11453
- name: string;
11454
- /**
11455
- * The name to be displayed for the component in Studio. Optional: if not
11456
- * specified, `meta.name` is used.
11457
- */
11458
- displayName?: string;
11459
- /**
11460
- * The description of the component to be shown in Studio.
11461
- */
11462
- description?: string;
11463
- /**
11464
- * The javascript name to be used when generating code. Optional: if not
11465
- * provided, `meta.name` is used.
11466
- */
11467
- importName?: string;
11468
- /**
11469
- * An object describing the component properties to be used in Studio.
11470
- * For each `prop`, there should be an entry `meta.props[prop]` describing
11471
- * its type.
11472
- */
11473
- props: {
11474
- [prop in DistributedKeyOf$1<P>]?: RestrictPropType$1<P[prop], P>;
11475
- } & {
11476
- [prop: string]: PropType$1<P>;
11477
- };
11478
- /**
11479
- * An object describing the component states to be used in Studio.
11480
- */
11481
- states?: Record<string, StateSpec>;
11482
- /**
11483
- * An object describing the components helpers to be used in Studio.
11484
- * 1. states helpers: Each state can receive an "initFunc" prop to initialize
11485
- * the implicit state in Studio, and an "onChangeArgsToValue" prop to
11486
- * transform the event handler arguments into a value
11487
- */
11488
- componentHelpers?: ExternalComponentHelpers<P>;
11489
- /**
11490
- * An array describing the component actions to be used in Studio.
11491
- */
11492
- actions?: Action<P>[];
11493
- /**
11494
- * Whether style sections should be shown in Studio. For styles to work, the
11495
- * component must accept a `className` prop. If unset, defaults to all styles.
11496
- * Set to `false` if this component cannot be styled (for example, if it doesn't
11497
- * render any DOM elements).
11498
- */
11499
- styleSections?: StyleSection[] | boolean;
11500
- /**
11501
- * Whether the element can be repeated in Studio. If unset, defaults to true.
11502
- */
11503
- isRepeatable?: boolean;
11504
- /**
11505
- * The path to be used when importing the component in the generated code.
11506
- * It can be the name of the package that contains the component, or the path
11507
- * to the file in the project (relative to the root directory).
11508
- */
11509
- importPath: string;
11510
- /**
11511
- * Whether the component is the default export from that path. Optional: if
11512
- * not specified, it's considered `false`.
11513
- */
11514
- isDefaultExport?: boolean;
11515
- /**
11516
- * The prop that expects the CSS classes with styles to be applied to the
11517
- * component. Optional: if not specified, Plasmic will expect it to be
11518
- * `className`. Notice that if the component does not accept CSS classes, the
11519
- * component will not be able to receive styles from the Studio.
11520
- */
11521
- classNameProp?: string;
11522
- /**
11523
- * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`
11524
- * to interact with components, so it's not used in the generated code.
11525
- * Optional: If not provided, the usual `ref` is used.
11526
- */
11527
- refProp?: string;
11528
- /**
11529
- * Default styles to start with when instantiating the component in Plasmic.
11530
- */
11531
- defaultStyles?: CSSProperties;
11532
- /**
11533
- * Component templates to start with on Plasmic.
11534
- */
11535
- templates?: ComponentTemplates<P>;
11536
- /**
11537
- * Registered name of parent component, used for grouping related components.
11538
- */
11539
- parentComponentName?: string;
11568
+ value: any;
11540
11569
  /**
11541
- * Whether the component can be used as an attachment to an element.
11570
+ * Sets the value to be passed to the prop. Expects a JSON-compatible value.
11542
11571
  */
11543
- isAttachment?: boolean;
11572
+ updateValue: (newVal: any) => void;
11544
11573
  /**
11545
- * Whether the component provides data to its slots using DataProvider.
11574
+ * Full screen modal component
11546
11575
  */
11547
- providesData?: boolean;
11576
+ FullscreenModal: React.ComponentType<ModalProps>;
11548
11577
  /**
11549
- * If specified, then Figma components with the specified names will be mapped
11550
- * to this component when you paste Figma content into Plasmic
11578
+ * Modal component for the side pane
11551
11579
  */
11552
- figmaMappings?: {
11553
- figmaComponentName: string;
11554
- }[];
11580
+ SideModal: React.ComponentType<ModalProps>;
11555
11581
  /**
11556
- * If true, when an instance of this component is added, the element
11557
- * will always be named by the name of this component.
11582
+ * The document that the component will be rendered into; instead of using
11583
+ * `document` directly (for, say, `document.querySelector()` etc.), you
11584
+ * should use this instead.
11558
11585
  */
11559
- alwaysAutoName?: boolean;
11560
- refActions?: Record<string, RefActionRegistration<P>>;
11561
- }
11562
- interface FunctionParam<P> {
11563
- name: string;
11564
- displayName?: string;
11565
- type: PropType$1<P>;
11566
- }
11567
- interface RefActionRegistration<P> {
11568
- displayName?: string;
11569
- description?: string;
11570
- argTypes: FunctionParam<P>[];
11571
- }
11572
- interface ComponentRegistration {
11573
- component: React.ComponentType<any>;
11574
- meta: CodeComponentMeta<any>;
11586
+ studioDocument: typeof document;
11575
11587
  }
11576
- declare global {
11577
- interface Window {
11578
- __PlasmicComponentRegistry: ComponentRegistration[];
11579
- }
11588
+ type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;
11589
+ interface RichCustomType<P> extends PropTypeBaseDefault<P, any> {
11590
+ type: "custom";
11591
+ control: CustomControl<P>;
11580
11592
  }
11593
+ type CustomType<P> = RichCustomType<P> | CustomControl<P>;
11594
+ type PrimitiveType<P = any> = Extract<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>, string>;
11595
+ type PropType$1<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>;
11596
+ type StringCompatType<P> = StringType<P> | ChoiceType<P> | JSONLikeType<P> | ImageUrlType<P> | CustomType<P> | DataPickerType<P>;
11597
+ type BoolCompatType<P> = BooleanType<P> | CustomType<P> | DataPickerType<P>;
11598
+ type NumberCompatType<P> = NumberType<P> | CustomType<P> | DataPickerType<P>;
11599
+ type RestrictPropType$1<T, P> = T extends string ? StringCompatType<P> : T extends boolean ? BoolCompatType<P> : T extends number ? NumberCompatType<P> : PropType$1<P>;
11581
11600
 
11582
11601
  type Fetcher = (...args: any[]) => Promise<any>;
11583
11602
  interface FetcherMeta {
@@ -11618,8 +11637,8 @@ declare global {
11618
11637
  }
11619
11638
  }
11620
11639
 
11621
- type PropType<P> = SupportControlled<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | CustomType<P>>;
11622
- type RestrictPropType<T, P> = T extends string ? SupportControlled<StringType<P> | ChoiceType<P> | JSONLikeType<P> | CustomType<P>> : T extends boolean ? SupportControlled<BooleanType<P> | JSONLikeType<P> | CustomType<P>> : T extends number ? SupportControlled<NumberType<P> | JSONLikeType<P> | CustomType<P>> : PropType<P>;
11640
+ type PropType<P> = StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | CustomType<P> | DataSourceType<P>;
11641
+ 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>;
11623
11642
  type DistributedKeyOf<T> = T extends any ? keyof T : never;
11624
11643
  interface GlobalContextMeta<P> {
11625
11644
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/react-web",
3
- "version": "0.2.210",
3
+ "version": "0.2.214",
4
4
  "description": "plasmic library for rendering in the presentational style",
5
5
  "main": "dist/index.cjs.js",
6
6
  "types": "dist/index.d.ts",
@@ -75,9 +75,9 @@
75
75
  },
76
76
  "prettier": {},
77
77
  "dependencies": {
78
- "@plasmicapp/data-sources": "0.1.76",
78
+ "@plasmicapp/data-sources": "0.1.80",
79
79
  "@plasmicapp/data-sources-context": "0.1.11",
80
- "@plasmicapp/host": "1.0.134",
80
+ "@plasmicapp/host": "1.0.138",
81
81
  "@plasmicapp/query": "0.1.64",
82
82
  "@react-aria/checkbox": "^3.5.0",
83
83
  "@react-aria/focus": "^3.7.0",
@@ -143,5 +143,5 @@
143
143
  "react": ">=16.8.0",
144
144
  "react-dom": ">=16.8.0"
145
145
  },
146
- "gitHead": "411497d52815f71297b6268e358218711ddbb967"
146
+ "gitHead": "241834a7707bc26beff06edcdba7149717f93408"
147
147
  }