@plasmicapp/react-web 0.2.212 → 0.2.216

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 +347 -329
  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,11 @@ 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)[];
11226
+ item?: any;
11005
11227
  };
11228
+ type InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;
11006
11229
  /**
11007
11230
  * Context that we pass back to control functions.
11008
11231
  */
@@ -11055,31 +11278,56 @@ interface PropTypeBase<P> {
11055
11278
  disableDynamicValue?: boolean;
11056
11279
  /**
11057
11280
  * If set to true, the component will be remounted when the prop value is updated.
11058
- * (This behavior only appliees to canvas)
11281
+ * (This behavior only applies to canvas)
11059
11282
  */
11060
11283
  forceRemount?: boolean;
11061
11284
  }
11062
- type DefaultValueOrExpr<P, T> = {
11063
- defaultExpr?: undefined;
11064
- defaultExprHint?: undefined;
11285
+ interface Defaultable<P, T> {
11286
+ /**
11287
+ * Default value to set for this prop when the component is instantiated
11288
+ */
11065
11289
  defaultValue?: T;
11290
+ /**
11291
+ * If no prop is given, the component uses a default; specify whaat
11292
+ * that default is so the Plasmic user can see it in the studio UI
11293
+ */
11066
11294
  defaultValueHint?: T | ContextDependentConfig<P, T | undefined>;
11067
- } | {
11068
- defaultValue?: undefined;
11069
- defaultValueHint?: undefined;
11295
+ /**
11296
+ * Use a dynamic value expression as the default instead
11297
+ */
11070
11298
  defaultExpr?: string;
11071
11299
  defaultExprHint?: string;
11072
- };
11073
- type StringTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, string>;
11074
- type StringType<P> = "string" | (({
11300
+ }
11301
+ interface Controllable {
11302
+ /**
11303
+ * If true, this is a prop that should only be used inside Plasmic
11304
+ * Studio for rendering artboards; will not be actually used in
11305
+ * generated code.
11306
+ */
11307
+ editOnly?: boolean;
11308
+ /**
11309
+ * If specified, the value used for this prop will instead be
11310
+ * mapped to the uncontrolledProp when generating code. This is
11311
+ * useful if, for example, in the artboard, you want to use `value`
11312
+ * prop to control the component, but in generated code, you want to
11313
+ * map it to `defaultValue`.
11314
+ */
11315
+ uncontrolledProp?: string;
11316
+ }
11317
+ interface PropTypeBaseDefault<P, T> extends PropTypeBase<P>, Defaultable<P, T>, Controllable {
11318
+ }
11319
+ interface PlainStringType<P> extends PropTypeBaseDefault<P, string> {
11075
11320
  type: "string";
11076
11321
  control?: "default" | "large";
11077
- } | {
11322
+ }
11323
+ interface CodeStringType<P> extends PropTypeBaseDefault<P, string> {
11078
11324
  type: "code";
11079
11325
  lang: "css" | "html" | "javascript" | "json";
11080
- } | {
11326
+ }
11327
+ interface RichTextType<P> extends PropTypeBaseDefault<P, string> {
11081
11328
  type: "richText";
11082
- } | {
11329
+ }
11330
+ interface ColorType<P> extends PropTypeBaseDefault<P, string> {
11083
11331
  type: "color";
11084
11332
  /**
11085
11333
  * If specified, and the user picks a color token in the Studio, then
@@ -11091,7 +11339,8 @@ type StringType<P> = "string" | (({
11091
11339
  * unless you are using a React portal.
11092
11340
  */
11093
11341
  keepCssVar?: boolean;
11094
- } | {
11342
+ }
11343
+ interface ClassType<P> extends PropTypeBase<P> {
11095
11344
  type: "class";
11096
11345
  /**
11097
11346
  * Additional css selectors that can change how this style should look.
@@ -11121,7 +11370,8 @@ type StringType<P> = "string" | (({
11121
11370
  * If specified, then only shows these style sections for styling this class
11122
11371
  */
11123
11372
  styleSections?: StyleSection[];
11124
- } | {
11373
+ }
11374
+ interface ThemeResetClassType<P> extends PropTypeBase<P> {
11125
11375
  type: "themeResetClass";
11126
11376
  /**
11127
11377
  * Normally, theme reset class will only target Plasmic-generated tags
@@ -11130,7 +11380,8 @@ type StringType<P> = "string" | (({
11130
11380
  * from somewhere), then specify `true` here.
11131
11381
  */
11132
11382
  targetAllTags?: boolean;
11133
- } | {
11383
+ }
11384
+ interface CardPickerType<P> extends PropTypeBaseDefault<P, string> {
11134
11385
  type: "cardPicker";
11135
11386
  modalTitle?: React.ReactNode | ContextDependentConfig<P, React.ReactNode>;
11136
11387
  options: {
@@ -11146,58 +11397,46 @@ type StringType<P> = "string" | (({
11146
11397
  }[]>;
11147
11398
  showInput?: boolean | ContextDependentConfig<P, boolean>;
11148
11399
  onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;
11149
- }) & StringTypeBase<P>);
11150
- type BooleanType<P> = "boolean" | ({
11400
+ }
11401
+ type RichStringType<P> = PlainStringType<P> | CodeStringType<P> | RichTextType<P> | ColorType<P> | ClassType<P> | ThemeResetClassType<P> | CardPickerType<P>;
11402
+ type StringType<P> = "string" | RichStringType<P>;
11403
+ interface RichBooleanType<P> extends PropTypeBaseDefault<P, boolean> {
11151
11404
  type: "boolean";
11152
- } & DefaultValueOrExpr<P, boolean> & PropTypeBase<P>);
11405
+ }
11406
+ type BooleanType<P> = "boolean" | RichBooleanType<P>;
11153
11407
  type GraphQLValue = {
11154
11408
  query: string;
11155
11409
  variables?: Record<string, any>;
11156
11410
  };
11157
- type GraphQLType<P> = {
11411
+ interface GraphQLType<P> extends PropTypeBaseDefault<P, GraphQLValue> {
11158
11412
  type: "code";
11159
11413
  lang: "graphql";
11160
11414
  endpoint: string | ContextDependentConfig<P, string>;
11161
11415
  method?: string | ContextDependentConfig<P, string>;
11162
11416
  headers?: object | ContextDependentConfig<P, object>;
11163
- } & DefaultValueOrExpr<P, GraphQLValue> & PropTypeBase<P>;
11164
- type NumberTypeBase<P> = PropTypeBase<P> & DefaultValueOrExpr<P, number> & {
11417
+ }
11418
+ interface NumberTypeBase<P> extends PropTypeBaseDefault<P, number> {
11165
11419
  type: "number";
11166
- };
11167
- type NumberType<P> = "number" | (({
11168
- control?: "default";
11169
11420
  min?: number | ContextDependentConfig<P, number>;
11170
11421
  max?: number | ContextDependentConfig<P, number>;
11171
- } | {
11422
+ }
11423
+ interface PlainNumberType<P> extends NumberTypeBase<P> {
11424
+ control?: "default";
11425
+ }
11426
+ interface SliderNumberType<P> extends NumberTypeBase<P> {
11172
11427
  control: "slider";
11173
- min: number | ContextDependentConfig<P, number>;
11174
- max: number | ContextDependentConfig<P, number>;
11175
11428
  step?: number | ContextDependentConfig<P, number>;
11176
- }) & NumberTypeBase<P>);
11177
- /**
11178
- * Expects defaultValue to be a JSON-compatible value
11179
- */
11180
- type JSONLikeType<P> = "object" | ({
11429
+ }
11430
+ type RichNumberType<P> = PlainNumberType<P> | SliderNumberType<P>;
11431
+ type NumberType<P> = "number" | RichNumberType<P>;
11432
+ interface ObjectType<P> extends PropTypeBaseDefault<P, Record<string, any>> {
11181
11433
  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
- */
11434
+ fields?: Record<string, PropType$1<P>>;
11188
11435
  nameFunc?: (item: any, ...args: ControlContext<P>) => string | undefined;
11189
- } & DefaultValueOrExpr<P, any> & PropTypeBase<P>) | ({
11436
+ }
11437
+ interface ArrayType<P> extends PropTypeBaseDefault<P, any[]> {
11190
11438
  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
- };
11439
+ itemType?: ObjectType<P>;
11201
11440
  /**
11202
11441
  * Optional function that determines whether the user can delete a given item.
11203
11442
  */
@@ -11223,30 +11462,33 @@ type JSONLikeType<P> = "object" | ({
11223
11462
  * ones. Now we would want a different minimal value, containing 6 items.
11224
11463
  */
11225
11464
  unstable__minimalValue?: ContextDependentConfig<P, any>;
11226
- } & DefaultValueOrExpr<P, any[]> & PropTypeBase<P>) | ({
11465
+ }
11466
+ type JSONLikeType<P> = "object" | ObjectType<P> | ArrayType<P>;
11467
+ interface DataSourceType<P> extends PropTypeBase<P> {
11227
11468
  type: "dataSource";
11228
11469
  dataSource: "airtable" | "cms";
11229
- } & PropTypeBase<P>);
11470
+ }
11230
11471
  type DataPickerValueType = string | number | (string | number)[];
11231
- type DataPickerType<P> = ({
11472
+ interface DataPickerType<P> extends PropTypeBaseDefault<P, DataPickerValueType> {
11232
11473
  type: "dataSelector";
11233
11474
  data: Record<string, any> | ContextDependentConfig<P, Record<string, any>>;
11234
11475
  alwaysShowValuePathAsLabel?: boolean;
11235
- } & DefaultValueOrExpr<P, DataPickerValueType> & PropTypeBase<P>) | ({
11476
+ }
11477
+ interface ExprEditorType<P> extends PropTypeBaseDefault<P, DataPickerValueType> {
11236
11478
  type: "exprEditor";
11237
11479
  data: Record<string, any> | ContextDependentConfig<P, Record<string, any>>;
11238
- } & DefaultValueOrExpr<P, DataPickerValueType> & PropTypeBase<P>);
11239
- type FormValidationRulesType<P> = {
11480
+ }
11481
+ interface FormValidationRulesType<P> extends PropTypeBaseDefault<P, any> {
11240
11482
  type: "formValidationRules";
11241
- } & DefaultValueOrExpr<P, any> & PropTypeBase<P>;
11242
- type EventHandlerType<P> = {
11483
+ }
11484
+ interface EventHandlerType<P> extends PropTypeBase<P> {
11243
11485
  type: "eventHandler";
11244
11486
  argTypes: {
11245
11487
  name: string;
11246
11488
  type: PropType$1<any>;
11247
11489
  }[];
11248
- } & DefaultValueOrExpr<P, (...args: any) => any> & PropTypeBase<P>;
11249
- interface ChoiceTypeBase<P> extends PropTypeBase<P> {
11490
+ }
11491
+ interface ChoiceTypeBase<P, T> extends PropTypeBaseDefault<P, T> {
11250
11492
  type: "choice";
11251
11493
  options: string[] | {
11252
11494
  label: string;
@@ -11259,56 +11501,17 @@ interface ChoiceTypeBase<P> extends PropTypeBase<P> {
11259
11501
  filterOption?: boolean;
11260
11502
  onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;
11261
11503
  }
11262
- type ChoiceType<P> = (({
11504
+ interface SingleChoiceType<P> extends ChoiceTypeBase<P, string | number | boolean> {
11263
11505
  multiSelect?: false;
11264
- } & DefaultValueOrExpr<P, string | number | boolean>) | ({
11506
+ }
11507
+ interface MultiChoiceType<P> extends ChoiceTypeBase<P, (string | number | boolean)[]> {
11265
11508
  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
11509
  }
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;
11510
+ interface CustomChoiceType<P> extends ChoiceTypeBase<P, string | number | boolean | (string | number | boolean)[]> {
11511
+ multiSelect: ContextDependentConfig<P, boolean>;
11302
11512
  }
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" | ({
11513
+ type ChoiceType<P> = SingleChoiceType<P> | MultiChoiceType<P> | CustomChoiceType<P>;
11514
+ interface RichSlotType<P> {
11312
11515
  type: "slot";
11313
11516
  /**
11314
11517
  * The unique names of all code components that can be placed in the slot
@@ -11342,24 +11545,20 @@ type SlotType<P> = "slot" | ({
11342
11545
  * When inserting top-level "page sections", should this slot be the default target?
11343
11546
  */
11344
11547
  unstable__isMainContentSlot?: boolean;
11345
- } & Omit<DefaultValueOrExpr<P, PlasmicElement | PlasmicElement[]>, "defaultValueHint" | "defaultExpr" | "defaultExprHint">);
11346
- type ImageUrlType<P> = "imageUrl" | ({
11548
+ defaultValue?: PlasmicElement | PlasmicElement[];
11549
+ }
11550
+ type SlotType<P> = "slot" | RichSlotType<P>;
11551
+ interface RichImageUrlType<P> extends PropTypeBaseDefault<P, string> {
11347
11552
  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> {
11553
+ }
11554
+ type ImageUrlType<P> = "imageUrl" | RichImageUrlType<P>;
11555
+ interface ModalProps {
11556
+ show?: boolean;
11557
+ children?: React.ReactNode;
11558
+ onClose: () => void;
11559
+ style?: CSSProperties;
11560
+ }
11561
+ interface CustomControlProps<P> {
11363
11562
  componentProps: P;
11364
11563
  /**
11365
11564
  * `contextData` can be `null` if the prop controls are rendering before
@@ -11367,219 +11566,38 @@ interface ActionProps<P> {
11367
11566
  * calls `setControlContextData`)
11368
11567
  */
11369
11568
  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
- hidden?: ContextDependentConfig<P, boolean>;
11391
- } | {
11392
- type: "custom-action";
11393
- control: React.ComponentType<ActionProps<P>>;
11394
- hidden?: ContextDependentConfig<P, boolean>;
11395
- };
11396
- type DistributedKeyOf$1<T> = T extends any ? keyof T : never;
11397
- interface ComponentTemplate<P> extends Omit<CodeComponentElement<P>, "type" | "name"> {
11398
- /**
11399
- * A preview picture for the template.
11400
- */
11401
- previewImg?: string;
11402
- }
11403
- interface ComponentTemplates<P> {
11404
- [name: string]: ComponentTemplate<P>;
11405
- }
11406
- type StateSpec = {
11407
- onChangeProp: string;
11408
- } & ({
11409
- type: "readonly";
11410
- variableType: "text";
11411
- initVal?: string;
11412
- } | {
11413
- type: "readonly";
11414
- variableType: "number";
11415
- initVal?: number;
11416
- } | {
11417
- type: "readonly";
11418
- variableType: "boolean";
11419
- initVal?: boolean;
11420
- } | {
11421
- type: "readonly";
11422
- variableType: "array";
11423
- initVal?: any[];
11424
- } | {
11425
- type: "readonly";
11426
- variableType: "object";
11427
- initVal?: object;
11428
- } | {
11429
- type: "writable";
11430
- variableType: "text" | "number" | "boolean" | "array" | "object";
11431
- valueProp: string;
11432
- });
11433
- interface StateHelpers<P, T> {
11434
- initFunc?: ($props: P) => T;
11435
- onChangeArgsToValue?: (...args: any) => T;
11436
- }
11437
- type ComponentHelpers<P> = {
11438
- states: Record<string, StateHelpers<P, any>>;
11439
- };
11440
- type ExternalComponentHelpers<P> = {
11441
- helpers: ComponentHelpers<P>;
11442
- importPath: string;
11443
- } & ({
11444
- importName: string;
11445
- } | {
11446
- isDefaultExport: true;
11447
- });
11448
- type StyleSection = "visibility" | "typography" | "sizing" | "spacing" | "background" | "transform" | "transitions" | "layout" | "overflow" | "border" | "shadows" | "effects";
11449
- interface CodeComponentMeta<P> {
11450
- /**
11451
- * Any unique string name used to identify that component. Each component
11452
- * should be registered with a different `meta.name`, even if they have the
11453
- * same name in the code.
11454
- */
11455
- name: string;
11456
- /**
11457
- * The name to be displayed for the component in Studio. Optional: if not
11458
- * specified, `meta.name` is used.
11459
- */
11460
- displayName?: string;
11461
- /**
11462
- * The description of the component to be shown in Studio.
11463
- */
11464
- description?: string;
11465
- /**
11466
- * The javascript name to be used when generating code. Optional: if not
11467
- * provided, `meta.name` is used.
11468
- */
11469
- importName?: string;
11470
- /**
11471
- * An object describing the component properties to be used in Studio.
11472
- * For each `prop`, there should be an entry `meta.props[prop]` describing
11473
- * its type.
11474
- */
11475
- props: {
11476
- [prop in DistributedKeyOf$1<P>]?: RestrictPropType$1<P[prop], P>;
11477
- } & {
11478
- [prop: string]: PropType$1<P>;
11479
- };
11480
- /**
11481
- * An object describing the component states to be used in Studio.
11482
- */
11483
- states?: Record<string, StateSpec>;
11484
- /**
11485
- * An object describing the components helpers to be used in Studio.
11486
- * 1. states helpers: Each state can receive an "initFunc" prop to initialize
11487
- * the implicit state in Studio, and an "onChangeArgsToValue" prop to
11488
- * transform the event handler arguments into a value
11489
- */
11490
- componentHelpers?: ExternalComponentHelpers<P>;
11491
- /**
11492
- * An array describing the component actions to be used in Studio.
11493
- */
11494
- actions?: Action<P>[];
11495
- /**
11496
- * Whether style sections should be shown in Studio. For styles to work, the
11497
- * component must accept a `className` prop. If unset, defaults to all styles.
11498
- * Set to `false` if this component cannot be styled (for example, if it doesn't
11499
- * render any DOM elements).
11500
- */
11501
- styleSections?: StyleSection[] | boolean;
11502
- /**
11503
- * Whether the element can be repeated in Studio. If unset, defaults to true.
11504
- */
11505
- isRepeatable?: boolean;
11506
- /**
11507
- * The path to be used when importing the component in the generated code.
11508
- * It can be the name of the package that contains the component, or the path
11509
- * to the file in the project (relative to the root directory).
11510
- */
11511
- importPath: string;
11512
- /**
11513
- * Whether the component is the default export from that path. Optional: if
11514
- * not specified, it's considered `false`.
11515
- */
11516
- isDefaultExport?: boolean;
11517
- /**
11518
- * The prop that expects the CSS classes with styles to be applied to the
11519
- * component. Optional: if not specified, Plasmic will expect it to be
11520
- * `className`. Notice that if the component does not accept CSS classes, the
11521
- * component will not be able to receive styles from the Studio.
11522
- */
11523
- classNameProp?: string;
11524
- /**
11525
- * The prop that receives and forwards a React `ref`. Plasmic only uses `ref`
11526
- * to interact with components, so it's not used in the generated code.
11527
- * Optional: If not provided, the usual `ref` is used.
11528
- */
11529
- refProp?: string;
11530
- /**
11531
- * Default styles to start with when instantiating the component in Plasmic.
11532
- */
11533
- defaultStyles?: CSSProperties;
11534
- /**
11535
- * Component templates to start with on Plasmic.
11536
- */
11537
- templates?: ComponentTemplates<P>;
11538
- /**
11539
- * Registered name of parent component, used for grouping related components.
11540
- */
11541
- parentComponentName?: string;
11569
+ value: any;
11542
11570
  /**
11543
- * Whether the component can be used as an attachment to an element.
11571
+ * Sets the value to be passed to the prop. Expects a JSON-compatible value.
11544
11572
  */
11545
- isAttachment?: boolean;
11573
+ updateValue: (newVal: any) => void;
11546
11574
  /**
11547
- * Whether the component provides data to its slots using DataProvider.
11575
+ * Full screen modal component
11548
11576
  */
11549
- providesData?: boolean;
11577
+ FullscreenModal: React.ComponentType<ModalProps>;
11550
11578
  /**
11551
- * If specified, then Figma components with the specified names will be mapped
11552
- * to this component when you paste Figma content into Plasmic
11579
+ * Modal component for the side pane
11553
11580
  */
11554
- figmaMappings?: {
11555
- figmaComponentName: string;
11556
- }[];
11581
+ SideModal: React.ComponentType<ModalProps>;
11557
11582
  /**
11558
- * If true, when an instance of this component is added, the element
11559
- * will always be named by the name of this component.
11583
+ * The document that the component will be rendered into; instead of using
11584
+ * `document` directly (for, say, `document.querySelector()` etc.), you
11585
+ * should use this instead.
11560
11586
  */
11561
- alwaysAutoName?: boolean;
11562
- refActions?: Record<string, RefActionRegistration<P>>;
11563
- }
11564
- interface FunctionParam<P> {
11565
- name: string;
11566
- displayName?: string;
11567
- type: PropType$1<P>;
11568
- }
11569
- interface RefActionRegistration<P> {
11570
- displayName?: string;
11571
- description?: string;
11572
- argTypes: FunctionParam<P>[];
11573
- }
11574
- interface ComponentRegistration {
11575
- component: React.ComponentType<any>;
11576
- meta: CodeComponentMeta<any>;
11587
+ studioDocument: typeof document;
11577
11588
  }
11578
- declare global {
11579
- interface Window {
11580
- __PlasmicComponentRegistry: ComponentRegistration[];
11581
- }
11589
+ type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;
11590
+ interface RichCustomType<P> extends PropTypeBaseDefault<P, any> {
11591
+ type: "custom";
11592
+ control: CustomControl<P>;
11582
11593
  }
11594
+ type CustomType<P> = RichCustomType<P> | CustomControl<P>;
11595
+ type PrimitiveType<P = any> = Extract<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>, string>;
11596
+ 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>;
11597
+ type StringCompatType<P> = StringType<P> | ChoiceType<P> | JSONLikeType<P> | ImageUrlType<P> | CustomType<P> | DataPickerType<P>;
11598
+ type BoolCompatType<P> = BooleanType<P> | CustomType<P> | DataPickerType<P>;
11599
+ type NumberCompatType<P> = NumberType<P> | CustomType<P> | DataPickerType<P>;
11600
+ type RestrictPropType$1<T, P> = T extends string ? StringCompatType<P> : T extends boolean ? BoolCompatType<P> : T extends number ? NumberCompatType<P> : PropType$1<P>;
11583
11601
 
11584
11602
  type Fetcher = (...args: any[]) => Promise<any>;
11585
11603
  interface FetcherMeta {
@@ -11620,8 +11638,8 @@ declare global {
11620
11638
  }
11621
11639
  }
11622
11640
 
11623
- type PropType<P> = SupportControlled<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | CustomType<P>>;
11624
- 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>;
11641
+ type PropType<P> = StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P> | ChoiceType<P> | CustomType<P> | DataSourceType<P>;
11642
+ 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>;
11625
11643
  type DistributedKeyOf<T> = T extends any ? keyof T : never;
11626
11644
  interface GlobalContextMeta<P> {
11627
11645
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/react-web",
3
- "version": "0.2.212",
3
+ "version": "0.2.216",
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.78",
78
+ "@plasmicapp/data-sources": "0.1.82",
79
79
  "@plasmicapp/data-sources-context": "0.1.11",
80
- "@plasmicapp/host": "1.0.136",
80
+ "@plasmicapp/host": "1.0.140",
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": "9f7e1bff70ae5f945027b4718d85d2a17f89501e"
146
+ "gitHead": "a9f2eda1e2d7d4aa9bb169cee7bc1fb00061a941"
147
147
  }