@plasmicapp/react-web 0.2.399 → 0.2.400

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 +275 -295
  2. package/package.json +4 -4
package/dist/all.d.ts CHANGED
@@ -11373,6 +11373,125 @@ interface CodeComponentElement<P> {
11373
11373
  }
11374
11374
  type PlasmicElement = ImageElement | TextElement | ContainerElement | ButtonElement | TextInputElement | CodeComponentElement<{}> | DefaultComponentElement<{}>;
11375
11375
 
11376
+ type GenericContext<Props, Data, Extra = unknown> = [Props, Data, Extra];
11377
+ /**
11378
+ * Config option that takes the context (e.g., props) of the component instance
11379
+ * or function to dynamically set its value.
11380
+ */
11381
+ type ContextDependentConfig<Ctx extends any[], R> = (...args: Ctx) => R;
11382
+ type MaybeContextDependentConfig<Ctx extends any[], V> = V | ContextDependentConfig<Ctx, V>;
11383
+ interface CanvasComponentProps<Data = any> {
11384
+ /**
11385
+ * This prop is only provided within the canvas of Plasmic Studio.
11386
+ * Allows the component to set data to be consumed by the props' controls.
11387
+ */
11388
+ setControlContextData?: (data: Data) => void;
11389
+ }
11390
+ type ControlExtras = {
11391
+ path: (string | number)[];
11392
+ item?: any;
11393
+ };
11394
+ type InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;
11395
+ interface CommonTypeBase<Ctx extends any[]> {
11396
+ description?: string;
11397
+ helpText?: string;
11398
+ required?: boolean;
11399
+ /**
11400
+ * If the user has chosen to use a dynamic expression for this prop, provide
11401
+ * a hint as to the expected values that the expression should evaluate to.
11402
+ * This hint will be displayed alongside the code editor. You may use
11403
+ * markdown in the text here.
11404
+ */
11405
+ exprHint?: string;
11406
+ /**
11407
+ * Function for whether this prop should be hidden in the right panel,
11408
+ * given the current props for this component
11409
+ */
11410
+ hidden?: ContextDependentConfig<Ctx, boolean>;
11411
+ /**
11412
+ * If true, does not allow the user to use a dynamic expression for this prop
11413
+ */
11414
+ disableDynamicValue?: boolean;
11415
+ }
11416
+
11417
+ type ChoiceValue = string | number | boolean;
11418
+ type ChoiceObject<T = ChoiceValue> = {
11419
+ label: string;
11420
+ value: T;
11421
+ };
11422
+ type ChoiceOptions<T extends ChoiceValue = ChoiceValue> = T[] | ChoiceObject<T>[];
11423
+ interface ChoiceCore<Ctx extends any[], T extends ChoiceValue> {
11424
+ type: "choice";
11425
+ options: MaybeContextDependentConfig<Ctx, ChoiceOptions<T>>;
11426
+ multiSelect?: MaybeContextDependentConfig<Ctx, boolean>;
11427
+ allowSearch?: boolean;
11428
+ filterOption?: boolean;
11429
+ onSearch?: MaybeContextDependentConfig<Ctx, ((v: string) => void) | undefined>;
11430
+ }
11431
+
11432
+ interface ObjectTypeBaseCore<Ctx extends any[], Fields> {
11433
+ type: "object";
11434
+ fields?: Record<string, Fields>;
11435
+ nameFunc?: (item: any, ...args: Ctx) => string | undefined;
11436
+ }
11437
+ interface ArrayTypeBaseCore<Ctx extends any[], Fields> {
11438
+ type: "array";
11439
+ itemType?: ObjectTypeBaseCore<Ctx, Fields>;
11440
+ /**
11441
+ * Optional function that determines whether the user can delete a given item.
11442
+ */
11443
+ unstable__canDelete?: (item: any, ...args: Ctx) => boolean;
11444
+ /**
11445
+ * Specify how to let Plasmic know how to update its own internal representation of the data when the value has
11446
+ * changed, or when issuing a minimalValue or shownValue that is different.
11447
+ *
11448
+ * Important to specify this if you are expecting any nested expression values in this data type!
11449
+ */
11450
+ unstable__keyFunc?: (item: any) => any;
11451
+ /**
11452
+ * Specify what would be the tentative new value that is set if the user makes any changes.
11453
+ *
11454
+ * Useful for field mappings.
11455
+ *
11456
+ * For instance, consider a Table where we have a `fields` prop:
11457
+ *
11458
+ * - Initially, the value is undefined. But if the user makes any changes, we would want to save an array of at
11459
+ * least three items (corresponding to, say, three columns inferred from a schema).
11460
+ *
11461
+ * - Let's say there are 5 columns in the value. The data schema changes, removing a column and adding two new
11462
+ * ones. Now we would want a different minimal value, containing 6 items.
11463
+ */
11464
+ unstable__minimalValue?: ContextDependentConfig<Ctx, any>;
11465
+ }
11466
+
11467
+ interface RichExprEditorCore<Ctx extends any[]> {
11468
+ type: "exprEditor";
11469
+ data?: Record<string, any> | ContextDependentConfig<Ctx, Record<string, any>>;
11470
+ isolateEnv?: boolean;
11471
+ }
11472
+ interface DataSourceCore {
11473
+ type: "dataSource";
11474
+ dataSource: "airtable" | "cms";
11475
+ }
11476
+ type DataPickerValueType = string | number | (string | number)[];
11477
+ interface RichDataPickerCore<Ctx extends any[]> {
11478
+ type: "dataSelector";
11479
+ data?: Record<string, any> | ContextDependentConfig<Ctx, Record<string, any>>;
11480
+ alwaysShowValuePathAsLabel?: boolean;
11481
+ isolateEnv?: boolean;
11482
+ }
11483
+ type GraphQLValue = {
11484
+ query: string;
11485
+ variables?: Record<string, any>;
11486
+ };
11487
+ interface GraphQLCore<Ctx extends any[]> {
11488
+ type: "code";
11489
+ lang: "graphql";
11490
+ endpoint: string | ContextDependentConfig<Ctx, string>;
11491
+ method?: string | ContextDependentConfig<Ctx, string>;
11492
+ headers?: object | ContextDependentConfig<Ctx, object>;
11493
+ }
11494
+
11376
11495
  type Nullish<T> = T | null | undefined;
11377
11496
 
11378
11497
  interface ActionProps<P> {
@@ -11402,11 +11521,11 @@ type Action<P> = {
11402
11521
  type: "button-action";
11403
11522
  label: string;
11404
11523
  onClick: (props: ActionProps<P>) => void;
11405
- hidden?: ContextDependentConfig$1<P, boolean>;
11524
+ hidden?: ComponentContextConfig<P, boolean>;
11406
11525
  } | {
11407
11526
  type: "custom-action";
11408
11527
  control: React.ComponentType<ActionProps<P>>;
11409
- hidden?: ContextDependentConfig$1<P, boolean>;
11528
+ hidden?: ComponentContextConfig<P, boolean>;
11410
11529
  };
11411
11530
  type DistributedKeyOf$1<T> = T extends any ? keyof T : never;
11412
11531
  interface ComponentTemplate<P> extends Omit<CodeComponentElement<P>, "type" | "name"> {
@@ -11423,12 +11542,12 @@ type StateSpec<P> = {
11423
11542
  /**
11424
11543
  * If true, will hide the state on studio.
11425
11544
  */
11426
- hidden?: ContextDependentConfig$1<P, boolean>;
11545
+ hidden?: ComponentContextConfig<P, boolean>;
11427
11546
  /**
11428
11547
  * If true, will hide the state in a collapsed section; good for states that
11429
11548
  * should not usually be used.
11430
11549
  */
11431
- advanced?: ContextDependentConfig$1<P, boolean>;
11550
+ advanced?: ComponentContextConfig<P, boolean>;
11432
11551
  } & ({
11433
11552
  type: "readonly";
11434
11553
  variableType: "text";
@@ -11618,7 +11737,7 @@ interface CodeComponentMeta<P> {
11618
11737
  * on the left of the Studio. This makes it easy to identify an element when
11619
11738
  * looking at the tree.
11620
11739
  */
11621
- treeLabel?: ContextDependentConfig$1<P, string>;
11740
+ treeLabel?: ComponentContextConfig<P, string>;
11622
11741
  /**
11623
11742
  * The value of the CSS display property used by this component.
11624
11743
  * Plasmic passes in a class name prop to components to let users style them,
@@ -11666,134 +11785,37 @@ declare global {
11666
11785
  }
11667
11786
  }
11668
11787
 
11669
- interface CanvasComponentProps<Data = any> {
11670
- /**
11671
- * This prop is only provided within the canvas of Plasmic Studio.
11672
- * Allows the component to set data to be consumed by the props' controls.
11673
- */
11674
- setControlContextData?: (data: Data) => void;
11675
- }
11676
- type ControlExtras = {
11677
- path: (string | number)[];
11678
- item?: any;
11679
- };
11680
- type InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;
11681
- /**
11682
- * Context that we pass back to control functions.
11683
- */
11684
- type ControlContext$1<P> = [
11685
- /**
11686
- * props
11687
- */
11688
- P,
11689
- /**
11690
- * `contextData` can be `null` if the prop controls are rendering before
11691
- * the component instance itself (it will re-render once the component
11692
- * calls `setControlContextData`)
11693
- */
11694
- InferDataType<P> | null,
11695
- /**
11696
- * Extra information for the control to use
11697
- */
11698
- ControlExtras
11699
- ];
11700
- /**
11701
- * Config option that takes the context (e.g., props) of the component instance
11702
- * to dynamically set its value.
11703
- */
11704
- type ContextDependentConfig$1<P, R> = (...args: ControlContext$1<P>) => R;
11705
- interface PropTypeBase<P> {
11706
- displayName?: string;
11707
- description?: string;
11708
- helpText?: string;
11709
- required?: boolean;
11710
- /**
11711
- * If the user has chosen to use a dynamic expression for this prop, provide
11712
- * a hint as to the expected values that the expression should evaluate to.
11713
- * This hint will be displayed alongside the code editor. You may use
11714
- * markdown in the text here.
11715
- */
11716
- exprHint?: string;
11717
- /**
11718
- * Function for whether this prop should be hidden in the right panel,
11719
- * given the current props for this component
11720
- */
11721
- hidden?: ContextDependentConfig$1<P, boolean>;
11722
- readOnly?: boolean | ContextDependentConfig$1<P, boolean>;
11723
- /**
11724
- * If true, will hide the prop in a collapsed section; good for props that
11725
- * should not usually be used.
11726
- */
11727
- advanced?: boolean;
11728
- /**
11729
- * If true, does not allow the user to use a dynamic expression for this prop
11730
- */
11731
- disableDynamicValue?: boolean;
11732
- /**
11733
- * If set to true, the component will be remounted when the prop value is updated.
11734
- * (This behavior only applies to canvas)
11735
- */
11736
- forceRemount?: boolean;
11737
- /**
11738
- * If true, the prop can't be overriden in different variants.
11739
- */
11740
- invariantable?: boolean;
11788
+ interface RichBooleanCore {
11789
+ type: "boolean";
11741
11790
  }
11742
- interface Defaultable<P, T> {
11743
- /**
11744
- * Default value to set for this prop when the component is instantiated
11745
- */
11746
- defaultValue?: T;
11747
- /**
11748
- * If no prop is given, the component uses a default; specify what
11749
- * that default is so the Plasmic user can see it in the studio UI
11750
- */
11751
- defaultValueHint?: T | ContextDependentConfig$1<P, T | undefined>;
11752
- /**
11753
- * Use a dynamic value expression as the default instead
11754
- */
11755
- defaultExpr?: string;
11756
- defaultExprHint?: string;
11757
- /**
11758
- * This function validates whether the prop value is valid.
11759
- * If the value is invalid, it returns an error message. Otherwise, it returns true.
11760
- */
11761
- validator?: (value: T, ...args: ControlContext$1<P>) => (string | true) | Promise<string | true>;
11791
+ interface NumberTypeBaseCore<Ctx extends any[]> {
11792
+ type: "number";
11793
+ min?: number | ContextDependentConfig<Ctx, number>;
11794
+ max?: number | ContextDependentConfig<Ctx, number>;
11762
11795
  }
11763
- interface Controllable {
11764
- /**
11765
- * If true, this is a prop that should only be used inside Plasmic
11766
- * Studio for rendering artboards; will not be actually used in
11767
- * generated code.
11768
- */
11769
- editOnly?: boolean;
11770
- /**
11771
- * If specified, the value used for this prop will instead be
11772
- * mapped to the uncontrolledProp when generating code. This is
11773
- * useful if, for example, in the artboard, you want to use `value`
11774
- * prop to control the component, but in generated code, you want to
11775
- * map it to `defaultValue`.
11776
- */
11777
- uncontrolledProp?: string;
11796
+ interface PlainNumberCore<Ctx extends any[]> extends NumberTypeBaseCore<Ctx> {
11797
+ control?: "default";
11778
11798
  }
11779
- interface PropTypeBaseDefault<P, T> extends PropTypeBase<P>, Defaultable<P, T>, Controllable {
11799
+ interface SliderNumberCore<Ctx extends any[]> extends NumberTypeBaseCore<Ctx> {
11800
+ control: "slider";
11801
+ step?: number | ContextDependentConfig<Ctx, number>;
11780
11802
  }
11781
- interface PlainStringType$1<P> extends PropTypeBaseDefault<P, string> {
11803
+ interface PlainStringCore {
11782
11804
  type: "string";
11783
11805
  control?: "default" | "large";
11784
11806
  isLocalizable?: boolean;
11785
11807
  }
11786
- interface CodeStringType<P> extends PropTypeBaseDefault<P, string> {
11808
+ interface CodeStringCore {
11787
11809
  type: "code";
11788
11810
  lang: "css" | "html" | "javascript" | "json";
11789
11811
  }
11790
- interface RichTextType<P> extends PropTypeBaseDefault<P, string> {
11812
+ interface RichTextCore {
11791
11813
  type: "richText";
11792
11814
  }
11793
- interface HrefType<P> extends PropTypeBaseDefault<P, string> {
11815
+ interface HrefCore {
11794
11816
  type: "href";
11795
11817
  }
11796
- interface ColorType<P> extends PropTypeBaseDefault<P, string> {
11818
+ interface ColorCore {
11797
11819
  type: "color";
11798
11820
  /**
11799
11821
  * If specified, and the user picks a color token in the Studio, then
@@ -11810,13 +11832,13 @@ interface ColorType<P> extends PropTypeBaseDefault<P, string> {
11810
11832
  */
11811
11833
  disableTokens?: boolean;
11812
11834
  }
11813
- interface DateStringType<P> extends PropTypeBaseDefault<P, string> {
11835
+ interface DateStringCore {
11814
11836
  type: "dateString";
11815
11837
  }
11816
- interface DateRangeStringsType<P> extends PropTypeBaseDefault<P, [string, string]> {
11838
+ interface DateRangeStringsCore {
11817
11839
  type: "dateRangeStrings";
11818
11840
  }
11819
- interface ClassType<P> extends PropTypeBase<P> {
11841
+ interface ClassCore {
11820
11842
  type: "class";
11821
11843
  /**
11822
11844
  * Additional css selectors that can change how this style should look.
@@ -11855,7 +11877,7 @@ interface ClassType<P> extends PropTypeBase<P> {
11855
11877
  */
11856
11878
  defaultStyles?: CSSProperties;
11857
11879
  }
11858
- interface ThemeResetClassType<P> extends PropTypeBase<P> {
11880
+ interface ThemeResetClassCore {
11859
11881
  type: "themeResetClass";
11860
11882
  /**
11861
11883
  * Normally, theme reset class will only target Plasmic-generated tags
@@ -11865,143 +11887,134 @@ interface ThemeResetClassType<P> extends PropTypeBase<P> {
11865
11887
  */
11866
11888
  targetAllTags?: boolean;
11867
11889
  }
11868
- interface CardPickerType<P> extends PropTypeBaseDefault<P, string> {
11890
+ interface CardPickerCore<Ctx extends any[]> {
11869
11891
  type: "cardPicker";
11870
- modalTitle?: React.ReactNode | ContextDependentConfig$1<P, React.ReactNode>;
11892
+ modalTitle?: React.ReactNode | ContextDependentConfig<Ctx, React.ReactNode>;
11871
11893
  options: {
11872
11894
  value: string;
11873
11895
  label?: string;
11874
11896
  imgUrl: string;
11875
11897
  footer?: React.ReactNode;
11876
- }[] | ContextDependentConfig$1<P, {
11898
+ }[] | ContextDependentConfig<Ctx, {
11877
11899
  value: string;
11878
11900
  label?: string;
11879
11901
  imgUrl: string;
11880
11902
  footer?: React.ReactNode;
11881
11903
  }[]>;
11882
- showInput?: boolean | ContextDependentConfig$1<P, boolean>;
11883
- onSearch?: ContextDependentConfig$1<P, ((value: string) => void) | undefined>;
11884
- }
11885
- type RichStringType<P> = PlainStringType$1<P> | CodeStringType<P> | RichTextType<P> | ColorType<P> | ClassType<P> | ThemeResetClassType<P> | CardPickerType<P> | HrefType<P>;
11886
- type StringType$1<P> = "string" | "href" | RichStringType<P>;
11887
- interface RichBooleanType<P> extends PropTypeBaseDefault<P, boolean> {
11888
- type: "boolean";
11904
+ showInput?: boolean | ContextDependentConfig<Ctx, boolean>;
11905
+ onSearch?: ContextDependentConfig<Ctx, ((value: string) => void) | undefined>;
11889
11906
  }
11890
- type BooleanType$1<P> = "boolean" | RichBooleanType<P>;
11891
- type GraphQLValue$1 = {
11892
- query: string;
11893
- variables?: Record<string, any>;
11894
- };
11895
- interface GraphQLType$1<P> extends PropTypeBaseDefault<P, GraphQLValue$1> {
11896
- type: "code";
11897
- lang: "graphql";
11898
- endpoint: string | ContextDependentConfig$1<P, string>;
11899
- method?: string | ContextDependentConfig$1<P, string>;
11900
- headers?: object | ContextDependentConfig$1<P, object>;
11901
- }
11902
- interface NumberTypeBase<P> extends PropTypeBaseDefault<P, number> {
11903
- type: "number";
11904
- min?: number | ContextDependentConfig$1<P, number>;
11905
- max?: number | ContextDependentConfig$1<P, number>;
11906
- }
11907
- interface PlainNumberType$1<P> extends NumberTypeBase<P> {
11908
- control?: "default";
11909
- }
11910
- interface SliderNumberType<P> extends NumberTypeBase<P> {
11911
- control: "slider";
11912
- step?: number | ContextDependentConfig$1<P, number>;
11913
- }
11914
- type RichNumberType<P> = PlainNumberType$1<P> | SliderNumberType<P>;
11915
- type NumberType$1<P> = "number" | RichNumberType<P>;
11916
- interface ObjectType$1<P> extends PropTypeBaseDefault<P, Record<string, any>> {
11917
- type: "object";
11918
- fields?: Record<string, PropType$1<P>>;
11919
- nameFunc?: (item: any, ...args: ControlContext$1<P>) => string | undefined;
11907
+
11908
+ type ComponentControlContext<P> = GenericContext<P, // Full component props
11909
+ // Full component props
11910
+ InferDataType<P> | null, // Canvas data
11911
+ ControlExtras>;
11912
+ type ComponentContextConfig<Props, R> = ContextDependentConfig<ComponentControlContext<Props>, R>;
11913
+ interface PropTypeBase<Ctx extends any[]> extends CommonTypeBase<Ctx> {
11914
+ displayName?: string;
11915
+ readOnly?: boolean | ContextDependentConfig<Ctx, boolean>;
11916
+ /**
11917
+ * If true, will hide the prop in a collapsed section; good for props that
11918
+ * should not usually be used.
11919
+ */
11920
+ advanced?: boolean;
11921
+ /**
11922
+ * If set to true, the component will be remounted when the prop value is updated.
11923
+ * (This behavior only applies to canvas)
11924
+ */
11925
+ forceRemount?: boolean;
11926
+ /**
11927
+ * If true, the prop can't be overriden in different variants.
11928
+ */
11929
+ invariantable?: boolean;
11920
11930
  }
11921
- interface ArrayType$1<P> extends PropTypeBaseDefault<P, any[]> {
11922
- type: "array";
11923
- itemType?: ObjectType$1<P>;
11931
+ interface Defaultable<Ctx extends any[], T> {
11924
11932
  /**
11925
- * Optional function that determines whether the user can delete a given item.
11933
+ * Default value to set for this prop when the component is instantiated
11926
11934
  */
11927
- unstable__canDelete?: (item: any, ...args: ControlContext$1<P>) => boolean;
11935
+ defaultValue?: T;
11928
11936
  /**
11929
- * Specify how to let Plasmic know how to update its own internal representation of the data when the value has
11930
- * changed, or when issuing a minimalValue or shownValue that is different.
11931
- *
11932
- * Important to specify this if you are expecting any nested expression values in this data type!
11937
+ * If no prop is given, the component uses a default; specify what
11938
+ * that default is so the Plasmic user can see it in the studio UI
11933
11939
  */
11934
- unstable__keyFunc?: (item: any) => any;
11940
+ defaultValueHint?: T | ContextDependentConfig<Ctx, T | undefined>;
11935
11941
  /**
11936
- * Specify what would be the tentative new value that is set if the user makes any changes.
11937
- *
11938
- * Useful for field mappings.
11939
- *
11940
- * For instance, consider a Table where we have a `fields` prop:
11941
- *
11942
- * - Initially, the value is undefined. But if the user makes any changes, we would want to save an array of at
11943
- * least three items (corresponding to, say, three columns inferred from a schema).
11944
- *
11945
- * - Let's say there are 5 columns in the value. The data schema changes, removing a column and adding two new
11946
- * ones. Now we would want a different minimal value, containing 6 items.
11942
+ * Use a dynamic value expression as the default instead
11943
+ */
11944
+ defaultExpr?: string;
11945
+ defaultExprHint?: string;
11946
+ /**
11947
+ * This function validates whether the prop value is valid.
11948
+ * If the value is invalid, it returns an error message. Otherwise, it returns true.
11949
+ */
11950
+ validator?: (value: T, ...args: Ctx) => (string | true) | Promise<string | true>;
11951
+ }
11952
+ interface Controllable {
11953
+ /**
11954
+ * If true, this is a prop that should only be used inside Plasmic
11955
+ * Studio for rendering artboards; will not be actually used in
11956
+ * generated code.
11947
11957
  */
11948
- unstable__minimalValue?: ContextDependentConfig$1<P, any>;
11958
+ editOnly?: boolean;
11959
+ /**
11960
+ * If specified, the value used for this prop will instead be
11961
+ * mapped to the uncontrolledProp when generating code. This is
11962
+ * useful if, for example, in the artboard, you want to use `value`
11963
+ * prop to control the component, but in generated code, you want to
11964
+ * map it to `defaultValue`.
11965
+ */
11966
+ uncontrolledProp?: string;
11949
11967
  }
11968
+ type PropTypeBaseDefault<P, T> = PropTypeBase<ComponentControlContext<P>> & Defaultable<ComponentControlContext<P>, T> & Controllable;
11969
+ type PlainStringType$1<P> = PropTypeBaseDefault<P, string> & PlainStringCore;
11970
+ type CodeStringType<P> = PropTypeBaseDefault<P, string> & CodeStringCore;
11971
+ type RichTextType<P> = PropTypeBaseDefault<P, string> & RichTextCore;
11972
+ type HrefType<P> = PropTypeBaseDefault<P, string> & HrefCore;
11973
+ type ColorType<P> = PropTypeBaseDefault<P, string> & ColorCore;
11974
+ type DateStringType$1<P> = PropTypeBaseDefault<P, string> & DateStringCore;
11975
+ type DateRangeStringsType$1<P> = PropTypeBaseDefault<P, [string, string]> & DateRangeStringsCore;
11976
+ type ClassType<P> = PropTypeBase<ComponentControlContext<P>> & ClassCore;
11977
+ type ThemeResetClassType<P> = PropTypeBase<ComponentControlContext<P>> & ThemeResetClassCore;
11978
+ type CardPickerType<P> = PropTypeBaseDefault<P, string> & CardPickerCore<ComponentControlContext<P>>;
11979
+ type RichStringType<P> = PlainStringType$1<P> | CodeStringType<P> | RichTextType<P> | ColorType<P> | ClassType<P> | ThemeResetClassType<P> | CardPickerType<P> | HrefType<P>;
11980
+ type StringType$1<P> = "string" | "href" | RichStringType<P>;
11981
+ type RichBooleanType<P> = PropTypeBaseDefault<P, boolean> & RichBooleanCore;
11982
+ type BooleanType$1<P> = "boolean" | RichBooleanType<P>;
11983
+ type GraphQLType$1<P> = PropTypeBaseDefault<P, GraphQLValue> & GraphQLCore<ComponentControlContext<P>>;
11984
+ type NumberTypeBase<P> = PropTypeBaseDefault<P, number> & NumberTypeBaseCore<ComponentControlContext<P>>;
11985
+ type PlainNumberType$1<P> = NumberTypeBase<P> & PlainNumberCore<ComponentControlContext<P>>;
11986
+ type SliderNumberType<P> = NumberTypeBase<P> & SliderNumberCore<ComponentControlContext<P>>;
11987
+ type RichNumberType<P> = PlainNumberType$1<P> | SliderNumberType<P>;
11988
+ type NumberType$1<P> = "number" | RichNumberType<P>;
11989
+ type ObjectType$1<P> = PropTypeBaseDefault<P, Record<string, any>> & ObjectTypeBaseCore<ComponentControlContext<P>, PropType$1<P>>;
11990
+ type ArrayType$1<P> = PropTypeBaseDefault<P, any[]> & ArrayTypeBaseCore<ComponentControlContext<P>, PropType$1<P>>;
11950
11991
  type JSONLikeType<P> = "object" | ObjectType$1<P> | ArrayType$1<P>;
11951
- interface DataSourceType<P> extends PropTypeBase<P> {
11952
- type: "dataSource";
11953
- dataSource: "airtable" | "cms";
11992
+ type DataSourceType<P> = PropTypeBase<ComponentControlContext<P>> & DataSourceCore;
11993
+ type RichDataPickerType<P> = PropTypeBaseDefault<P, DataPickerValueType> & RichDataPickerCore<ComponentControlContext<P>>;
11994
+ type DataPickerType<P> = "dataPicker" | RichDataPickerType<P>;
11995
+ type RichExprEditorType<P> = PropTypeBaseDefault<P, DataPickerValueType> & RichExprEditorCore<ComponentControlContext<P>>;
11996
+ type ExprEditorType<P> = "exprEditor" | RichExprEditorType<P>;
11997
+ type ComponentChoiceType<P, Opt extends ChoiceValue = ChoiceValue, Val = Opt | Opt[]> = PropTypeBaseDefault<P, Val> & ChoiceCore<ComponentControlContext<P>, Opt>;
11998
+ interface SingleChoiceType$1<P, Opt extends ChoiceValue = ChoiceValue> extends ComponentChoiceType<P, Opt, Opt> {
11999
+ multiSelect?: false;
11954
12000
  }
11955
- type DataPickerValueType = string | number | (string | number)[];
11956
- interface RichDataPickerType<P> extends PropTypeBaseDefault<P, DataPickerValueType> {
11957
- type: "dataSelector";
11958
- data?: Record<string, any> | ContextDependentConfig$1<P, Record<string, any>>;
11959
- alwaysShowValuePathAsLabel?: boolean;
11960
- isolateEnv?: boolean;
12001
+ interface MultiChoiceType$1<P, Opt extends ChoiceValue = ChoiceValue> extends ComponentChoiceType<P, Opt, Opt[]> {
12002
+ multiSelect: true;
11961
12003
  }
11962
- type DataPickerType<P> = "dataPicker" | RichDataPickerType<P>;
11963
- interface RichExprEditorType<P> extends PropTypeBaseDefault<P, DataPickerValueType> {
11964
- type: "exprEditor";
11965
- data?: Record<string, any> | ContextDependentConfig$1<P, Record<string, any>>;
11966
- isolateEnv?: boolean;
12004
+ interface CustomChoiceType$1<P> extends ComponentChoiceType<P, ChoiceValue, ChoiceValue | ChoiceValue[]> {
12005
+ multiSelect: ComponentContextConfig<P, boolean>;
11967
12006
  }
11968
- type ExprEditorType<P> = "exprEditor" | RichExprEditorType<P>;
12007
+ type ChoiceType$1<P> = SingleChoiceType$1<P> | MultiChoiceType$1<P> | CustomChoiceType$1<P>;
11969
12008
  interface FormValidationRulesType<P> extends PropTypeBaseDefault<P, any> {
11970
12009
  type: "formValidationRules";
11971
12010
  }
11972
- interface EventHandlerType<P> extends PropTypeBase<P> {
12011
+ interface EventHandlerType<P> extends PropTypeBase<ComponentControlContext<P>> {
11973
12012
  type: "eventHandler";
11974
12013
  argTypes: {
11975
12014
  name: string;
11976
12015
  type: ArgType<any>;
11977
12016
  }[];
11978
12017
  }
11979
- type ChoiceValue = string | number | boolean;
11980
- type ChoiceObject = {
11981
- label: string;
11982
- value: ChoiceValue;
11983
- };
11984
- type ChoiceOptions = ChoiceValue[] | ChoiceObject[];
11985
- interface ChoiceTypeBase$1<P, T> extends PropTypeBaseDefault<P, T> {
11986
- type: "choice";
11987
- options: ChoiceOptions | ContextDependentConfig$1<P, string[] | {
11988
- label: string;
11989
- value: string | number | boolean;
11990
- }[]>;
11991
- allowSearch?: boolean;
11992
- filterOption?: boolean;
11993
- onSearch?: ContextDependentConfig$1<P, ((value: string) => void) | undefined>;
11994
- }
11995
- interface SingleChoiceType$1<P> extends ChoiceTypeBase$1<P, string | number | boolean> {
11996
- multiSelect?: false;
11997
- }
11998
- interface MultiChoiceType$1<P> extends ChoiceTypeBase$1<P, (string | number | boolean)[]> {
11999
- multiSelect: true;
12000
- }
12001
- interface CustomChoiceType$1<P> extends ChoiceTypeBase$1<P, string | number | boolean | (string | number | boolean)[]> {
12002
- multiSelect: ContextDependentConfig$1<P, boolean>;
12003
- }
12004
- type ChoiceType$1<P> = SingleChoiceType$1<P> | MultiChoiceType$1<P> | CustomChoiceType$1<P>;
12005
12018
  interface RichSlotType<P> {
12006
12019
  type: "slot";
12007
12020
  description?: string;
@@ -12032,7 +12045,7 @@ interface RichSlotType<P> {
12032
12045
  * Function for whether this slot should be hidden from the left tree,
12033
12046
  * given the current props for this component
12034
12047
  */
12035
- hidden?: ContextDependentConfig$1<P, boolean>;
12048
+ hidden?: ComponentContextConfig<P, boolean>;
12036
12049
  /**
12037
12050
  * If slot is a render prop (accepts a function that takes in some
12038
12051
  * arguments and returns some JSX), then specify the names of the
@@ -12053,11 +12066,11 @@ interface RichSlotType<P> {
12053
12066
  * Furthermore, the component further shows the props of whatever is in the slot on
12054
12067
  * the parent component for the user's convenience. Handy for various “wrapper" components, form fields, and so on.
12055
12068
  */
12056
- mergeWithParent?: boolean | ContextDependentConfig$1<P, boolean>;
12069
+ mergeWithParent?: boolean | ComponentContextConfig<P, boolean>;
12057
12070
  /**
12058
12071
  * A function that returns true to hide the merged props conditionally.
12059
12072
  */
12060
- hiddenMergedProps?: ContextDependentConfig$1<P, boolean>;
12073
+ hiddenMergedProps?: ComponentContextConfig<P, boolean>;
12061
12074
  }
12062
12075
  type SlotType<P> = "slot" | RichSlotType<P>;
12063
12076
  interface RichImageUrlType<P> extends PropTypeBaseDefault<P, string> {
@@ -12135,9 +12148,9 @@ interface RichCustomType<P> extends PropTypeBaseDefault<P, any> {
12135
12148
  }
12136
12149
  type CustomType<P> = RichCustomType<P> | CustomControl<P>;
12137
12150
  type PrimitiveType<P = any> = Extract<StringType$1<P> | BooleanType$1<P> | NumberType$1<P> | JSONLikeType<P>, string>;
12138
- type PropType$1<P> = StringType$1<P> | BooleanType$1<P> | GraphQLType$1<P> | NumberType$1<P> | JSONLikeType<P> | DataSourceType<P> | DataPickerType<P> | ExprEditorType<P> | FormValidationRulesType<P> | EventHandlerType<P> | ChoiceType$1<P> | CustomType<P> | ImageUrlType<P> | SlotType<P> | DateStringType<P> | DateRangeStringsType<P>;
12151
+ type PropType$1<P> = StringType$1<P> | BooleanType$1<P> | GraphQLType$1<P> | NumberType$1<P> | JSONLikeType<P> | DataSourceType<P> | DataPickerType<P> | ExprEditorType<P> | FormValidationRulesType<P> | EventHandlerType<P> | ChoiceType$1<P> | CustomType<P> | ImageUrlType<P> | SlotType<P> | DateStringType$1<P> | DateRangeStringsType$1<P>;
12139
12152
  type ArgType<P> = Exclude<PropType$1<P>, SlotType<P> | EventHandlerType<P>>;
12140
- type StringCompatType<P> = DateStringType<P> | StringType$1<P> | ChoiceType$1<P> | JSONLikeType<P> | ImageUrlType<P> | CustomType<P> | DataPickerType<P>;
12153
+ type StringCompatType<P> = DateStringType$1<P> | StringType$1<P> | ChoiceType$1<P> | JSONLikeType<P> | ImageUrlType<P> | CustomType<P> | DataPickerType<P>;
12141
12154
  type BoolCompatType<P> = BooleanType$1<P> | CustomType<P> | DataPickerType<P>;
12142
12155
  type NumberCompatType<P> = NumberType$1<P> | CustomType<P> | DataPickerType<P>;
12143
12156
  type RestrictPropType$1<T, P> = T extends string ? StringCompatType<P> : T extends boolean ? BoolCompatType<P> : T extends number ? NumberCompatType<P> : PropType$1<P>;
@@ -12181,76 +12194,32 @@ declare global {
12181
12194
  }
12182
12195
  }
12183
12196
 
12184
- /**
12185
- * Context that we pass back to control functions.
12186
- */
12187
- type ControlContext<P> = [
12188
- /**
12189
- * props
12190
- */
12191
- Partial<P>,
12192
- /**
12193
- * context data
12194
- */
12195
- any
12196
- ];
12197
- /**
12198
- * Config option that takes the context (e.g., props) of the function call
12199
- * to dynamically set its value.
12200
- */
12201
- type ContextDependentConfig<P, R> = (...args: ControlContext<P>) => R;
12197
+ type FunctionControlContext<P> = GenericContext<Partial<P>, // Partial function props
12198
+ any>;
12199
+ type FunctionContextConfig<Args extends any[], R> = ContextDependentConfig<FunctionControlContext<Args>, R>;
12202
12200
  interface BaseParam {
12203
12201
  name: string;
12204
12202
  description?: string;
12205
12203
  isOptional?: boolean;
12206
12204
  isRestParameter?: boolean;
12207
12205
  }
12208
- interface ChoiceTypeBase<P, T> extends BaseParam {
12209
- type: "choice";
12210
- options: T[] | {
12211
- label: string;
12212
- value: T;
12213
- }[] | ContextDependentConfig<P, T[] | {
12214
- label: string;
12215
- value: T;
12216
- }[]>;
12217
- allowSearch?: boolean;
12218
- filterOption?: boolean;
12219
- onSearch?: ContextDependentConfig<P, ((value: string) => void) | undefined>;
12220
- }
12221
- interface SingleChoiceType<P, T> extends ChoiceTypeBase<P, T> {
12222
- multiSelect?: false;
12223
- }
12224
- interface MultiChoiceType<P, T> extends ChoiceTypeBase<P, T[]> {
12225
- multiSelect: true;
12226
- }
12227
- interface CustomChoiceType<P, T> extends ChoiceTypeBase<P, T | T[]> {
12228
- multiSelect: ContextDependentConfig<P, boolean>;
12206
+ interface FunctionMeta<Args extends any[] = any> extends CommonTypeBase<FunctionControlContext<Args>> {
12207
+ name: string;
12208
+ rest?: boolean;
12229
12209
  }
12230
- type ChoiceType<P, T> = SingleChoiceType<P, T> | MultiChoiceType<P, T> | CustomChoiceType<P, T>;
12231
12210
  interface PlainStringType<T extends Nullish<string> = string> extends BaseParam {
12232
12211
  type: "string" | `'${T}'`;
12233
12212
  }
12234
- type StringType<P, T extends Nullish<string> = string> = "string" | PlainStringType<T> | ChoiceType<P, T> | AnyType;
12213
+ type StringType<P, T extends string = string> = "string" | PlainStringType<T> | ChoiceType<P, T> | DateStringType | DateRangeStringsType | AnyType;
12235
12214
  interface PlainNumberType<T extends Nullish<number> = number> extends BaseParam {
12236
12215
  type: "number" | `${number extends T ? number : T}`;
12237
12216
  }
12238
- type NumberType<P, T extends Nullish<number> = number> = PlainNumberType<T> | ChoiceType<P, T> | AnyType;
12217
+ type NumberType<P, T extends number = number> = PlainNumberType<T> | (BaseParam & NumberTypeBaseCore<FunctionControlContext<P>>) | ChoiceType<P, T> | AnyType;
12239
12218
  interface PlainBooleanType<T extends Nullish<boolean> = boolean> extends BaseParam {
12240
12219
  type: "boolean" | `${boolean extends T ? boolean : T}`;
12241
12220
  }
12242
- type BooleanType<P, T extends Nullish<boolean> = boolean> = PlainBooleanType<T> | ChoiceType<P, T> | AnyType;
12243
- type GraphQLValue = {
12244
- query: string;
12245
- variables?: Record<string, any>;
12246
- };
12247
- interface GraphQLType<P> extends BaseParam {
12248
- type: "code";
12249
- lang: "graphql";
12250
- endpoint: string | ContextDependentConfig<P, string>;
12251
- method?: string | ContextDependentConfig<P, string>;
12252
- headers?: object | ContextDependentConfig<P, object>;
12253
- }
12221
+ type BooleanType<P, T extends boolean = boolean> = PlainBooleanType<T> | (BaseParam & RichBooleanCore) | ChoiceType<P, T> | AnyType;
12222
+ type GraphQLType<P> = BaseParam & GraphQLCore<FunctionControlContext<P>>;
12254
12223
  interface PlainNullType extends BaseParam {
12255
12224
  type: "null";
12256
12225
  }
@@ -12259,14 +12228,8 @@ interface PlainUndefinedType extends BaseParam {
12259
12228
  type: "undefined";
12260
12229
  }
12261
12230
  type UndefinedType = PlainUndefinedType | AnyType;
12262
- interface PlainArrayType extends BaseParam {
12263
- type: "array";
12264
- }
12265
- type ArrayType = PlainArrayType | AnyType;
12266
- interface PlainObjectType extends BaseParam {
12267
- type: "object";
12268
- }
12269
- type ObjectType = PlainObjectType | AnyType;
12231
+ type ObjectType<P> = BaseParam & ObjectTypeBaseCore<FunctionControlContext<P>, AnyTyping<P, any>>;
12232
+ type ArrayType<P> = BaseParam & ArrayTypeBaseCore<FunctionControlContext<P>, AnyTyping<P, any>>;
12270
12233
  interface PlainAnyType extends BaseParam {
12271
12234
  type: "any";
12272
12235
  }
@@ -12276,9 +12239,25 @@ interface PlainVoidType extends BaseParam {
12276
12239
  }
12277
12240
  type VoidType = PlainVoidType | AnyType;
12278
12241
  type IsAny<T> = 0 extends 1 & T ? true : false;
12279
- type CommonType<P, T> = T extends GraphQLValue ? GraphQLType<P> : T extends null ? NullType : T extends undefined ? UndefinedType : T extends Array<any> ? ArrayType : T extends object ? ObjectType : AnyType;
12242
+ type CommonType<P, T> = T extends GraphQLValue ? GraphQLType<P> : T extends null ? NullType : T extends undefined ? UndefinedType : T extends Array<any> ? ArrayType<P> : T extends object ? ObjectType<P> : AnyType;
12280
12243
  type AnyTyping<P, T> = T extends string ? StringType<P, T> : T extends number ? NumberType<P, T> : T extends boolean ? BooleanType<P, T> : CommonType<P, T>;
12281
- type RestrictedType<P, T> = IsAny<T> extends true ? AnyTyping<P, T> : [T] extends [Nullish<string>] ? StringType<P, T> : [T] extends [Nullish<number>] ? NumberType<P, T> : [T] extends [Nullish<boolean>] ? BooleanType<P, T> : CommonType<P, T>;
12244
+ type ToTuple<T> = T extends any[] ? T : never;
12245
+ type FunctionChoiceType<Args, Opt extends ChoiceValue = ChoiceValue> = FunctionMeta<ToTuple<Args>> & ChoiceCore<FunctionControlContext<ToTuple<Args>>, Opt>;
12246
+ interface SingleChoiceType<P, Opt extends ChoiceValue = ChoiceValue> extends FunctionChoiceType<P, Opt> {
12247
+ multiSelect?: false;
12248
+ }
12249
+ interface MultiChoiceType<P, Opt extends ChoiceValue = ChoiceValue> extends FunctionChoiceType<P, Opt> {
12250
+ multiSelect: true;
12251
+ }
12252
+ interface CustomChoiceType<P, Opt extends ChoiceValue = ChoiceValue> extends FunctionChoiceType<P, Opt> {
12253
+ multiSelect: FunctionContextConfig<ToTuple<P>, boolean>;
12254
+ }
12255
+ type ChoiceType<P, T extends ChoiceValue = ChoiceValue> = SingleChoiceType<P, T> | MultiChoiceType<P, T> | CustomChoiceType<P, T>;
12256
+ type DateStringType = BaseParam & DateStringCore;
12257
+ type DateRangeStringsType = BaseParam & DateRangeStringsCore;
12258
+ type RestrictedType<P, T> = IsAny<T> extends true ? AnyTyping<P, T> : [
12259
+ T
12260
+ ] extends [string] ? StringType<P, T> : [T] extends [number] ? NumberType<P, T> : [T] extends [boolean] ? BooleanType<P, T> : T extends string | null | undefined ? Exclude<T, null | undefined> extends string ? StringType<P, T extends string ? T : string> : CommonType<P, T> : T extends number | null | undefined ? Exclude<T, null | undefined> extends number ? NumberType<P, T extends number ? T : number> : CommonType<P, T> : T extends boolean | null | undefined ? Exclude<T, null | undefined> extends boolean ? BooleanType<P, T extends boolean ? T : boolean> : CommonType<P, T> : CommonType<P, T>;
12282
12261
  type ParamType<P, T> = RestrictedType<P, T>;
12283
12262
  type RequiredParam<P, T> = ParamType<P, T> & {
12284
12263
  isOptional?: false;
@@ -12306,6 +12285,7 @@ type HandleParams<P extends any[]> = [
12306
12285
  ...HandleOptionalParams<P, Required<OptionalParams<P>>>
12307
12286
  ];
12308
12287
  type HandleReturnType<P, T> = VoidType | ParamType<P, T>;
12288
+
12309
12289
  interface CustomFunctionMeta<F extends (...args: any[]) => any> {
12310
12290
  /**
12311
12291
  * The javascript name of the function. Notice it must be unique across all
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plasmicapp/react-web",
3
- "version": "0.2.399",
3
+ "version": "0.2.400",
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",
@@ -96,9 +96,9 @@
96
96
  },
97
97
  "dependencies": {
98
98
  "@plasmicapp/auth-react": "0.0.23",
99
- "@plasmicapp/data-sources": "0.1.188",
99
+ "@plasmicapp/data-sources": "0.1.189",
100
100
  "@plasmicapp/data-sources-context": "0.1.22",
101
- "@plasmicapp/host": "1.0.224",
101
+ "@plasmicapp/host": "1.0.225",
102
102
  "@plasmicapp/loader-splits": "1.0.64",
103
103
  "@plasmicapp/nextjs-app-router": "1.0.17",
104
104
  "@plasmicapp/prepass": "1.0.20",
@@ -155,5 +155,5 @@
155
155
  "react": ">=16.8.0",
156
156
  "react-dom": ">=16.8.0"
157
157
  },
158
- "gitHead": "569173f3355b4b4902be9faf33d55e6cda552701"
158
+ "gitHead": "d37fc3f8207cda80c220fc0130fa821c0aed7abe"
159
159
  }