@plasmicapp/host 1.0.224 → 1.0.226

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 (87) hide show
  1. package/dist/exports.d.ts +2 -2
  2. package/dist/host.esm.js +1 -1
  3. package/dist/host.esm.js.map +1 -1
  4. package/dist/index.cjs.js +1 -1
  5. package/dist/index.cjs.js.map +1 -1
  6. package/dist/prop-types.d.ts +6 -478
  7. package/dist/registerComponent.d.ts +8 -7
  8. package/dist/registerFunction.d.ts +2 -127
  9. package/dist/types/choice-type.d.ts +16 -0
  10. package/dist/types/component-types.d.ts +258 -0
  11. package/dist/types/container-types.d.ts +35 -0
  12. package/dist/types/function-types.d.ts +100 -0
  13. package/dist/types/misc-types.d.ts +38 -0
  14. package/dist/types/primitive-types.d.ts +123 -0
  15. package/dist/types/shared-controls.d.ts +40 -0
  16. package/dist/version.d.ts +1 -1
  17. package/package.json +4 -3
  18. package/registerComponent/dist/exports.d.ts +2 -2
  19. package/registerComponent/dist/index.cjs.js.map +1 -1
  20. package/registerComponent/dist/index.esm.js.map +1 -1
  21. package/registerComponent/dist/prop-types.d.ts +6 -478
  22. package/registerComponent/dist/registerComponent.d.ts +8 -7
  23. package/registerComponent/dist/registerFunction.d.ts +2 -127
  24. package/registerComponent/dist/types/choice-type.d.ts +16 -0
  25. package/registerComponent/dist/types/component-types.d.ts +258 -0
  26. package/registerComponent/dist/types/container-types.d.ts +35 -0
  27. package/registerComponent/dist/types/function-types.d.ts +100 -0
  28. package/registerComponent/dist/types/misc-types.d.ts +38 -0
  29. package/registerComponent/dist/types/primitive-types.d.ts +123 -0
  30. package/registerComponent/dist/types/shared-controls.d.ts +40 -0
  31. package/registerComponent/dist/version.d.ts +1 -1
  32. package/registerFunction/dist/exports.d.ts +2 -2
  33. package/registerFunction/dist/index.cjs.js.map +1 -1
  34. package/registerFunction/dist/index.esm.js.map +1 -1
  35. package/registerFunction/dist/prop-types.d.ts +6 -478
  36. package/registerFunction/dist/registerComponent.d.ts +8 -7
  37. package/registerFunction/dist/registerFunction.d.ts +2 -127
  38. package/registerFunction/dist/types/choice-type.d.ts +16 -0
  39. package/registerFunction/dist/types/component-types.d.ts +258 -0
  40. package/registerFunction/dist/types/container-types.d.ts +35 -0
  41. package/registerFunction/dist/types/function-types.d.ts +100 -0
  42. package/registerFunction/dist/types/misc-types.d.ts +38 -0
  43. package/registerFunction/dist/types/primitive-types.d.ts +123 -0
  44. package/registerFunction/dist/types/shared-controls.d.ts +40 -0
  45. package/registerFunction/dist/version.d.ts +1 -1
  46. package/registerGlobalContext/dist/exports.d.ts +2 -2
  47. package/registerGlobalContext/dist/prop-types.d.ts +6 -478
  48. package/registerGlobalContext/dist/registerComponent.d.ts +8 -7
  49. package/registerGlobalContext/dist/registerFunction.d.ts +2 -127
  50. package/registerGlobalContext/dist/types/choice-type.d.ts +16 -0
  51. package/registerGlobalContext/dist/types/component-types.d.ts +258 -0
  52. package/registerGlobalContext/dist/types/container-types.d.ts +35 -0
  53. package/registerGlobalContext/dist/types/function-types.d.ts +100 -0
  54. package/registerGlobalContext/dist/types/misc-types.d.ts +38 -0
  55. package/registerGlobalContext/dist/types/primitive-types.d.ts +123 -0
  56. package/registerGlobalContext/dist/types/shared-controls.d.ts +40 -0
  57. package/registerGlobalContext/dist/version.d.ts +1 -1
  58. package/registerToken/dist/exports.d.ts +2 -2
  59. package/registerToken/dist/prop-types.d.ts +6 -478
  60. package/registerToken/dist/registerComponent.d.ts +8 -7
  61. package/registerToken/dist/registerFunction.d.ts +2 -127
  62. package/registerToken/dist/types/choice-type.d.ts +16 -0
  63. package/registerToken/dist/types/component-types.d.ts +258 -0
  64. package/registerToken/dist/types/container-types.d.ts +35 -0
  65. package/registerToken/dist/types/function-types.d.ts +100 -0
  66. package/registerToken/dist/types/misc-types.d.ts +38 -0
  67. package/registerToken/dist/types/primitive-types.d.ts +123 -0
  68. package/registerToken/dist/types/shared-controls.d.ts +40 -0
  69. package/registerToken/dist/version.d.ts +1 -1
  70. package/registerTrait/dist/exports.d.ts +2 -2
  71. package/registerTrait/dist/prop-types.d.ts +6 -478
  72. package/registerTrait/dist/registerComponent.d.ts +8 -7
  73. package/registerTrait/dist/registerFunction.d.ts +2 -127
  74. package/registerTrait/dist/types/choice-type.d.ts +16 -0
  75. package/registerTrait/dist/types/component-types.d.ts +258 -0
  76. package/registerTrait/dist/types/container-types.d.ts +35 -0
  77. package/registerTrait/dist/types/function-types.d.ts +100 -0
  78. package/registerTrait/dist/types/misc-types.d.ts +38 -0
  79. package/registerTrait/dist/types/primitive-types.d.ts +123 -0
  80. package/registerTrait/dist/types/shared-controls.d.ts +40 -0
  81. package/registerTrait/dist/version.d.ts +1 -1
  82. /package/dist/{type-utils.d.ts → types/type-utils.d.ts} +0 -0
  83. /package/registerComponent/dist/{type-utils.d.ts → types/type-utils.d.ts} +0 -0
  84. /package/registerFunction/dist/{type-utils.d.ts → types/type-utils.d.ts} +0 -0
  85. /package/registerGlobalContext/dist/{type-utils.d.ts → types/type-utils.d.ts} +0 -0
  86. /package/registerToken/dist/{type-utils.d.ts → types/type-utils.d.ts} +0 -0
  87. /package/registerTrait/dist/{type-utils.d.ts → types/type-utils.d.ts} +0 -0
@@ -0,0 +1,258 @@
1
+ /// <reference types="react" />
2
+ import { CSSProperties, PlasmicElement } from "../element-types";
3
+ import { ChoiceCore, ChoiceValue } from "./choice-type";
4
+ import { ArrayTypeBaseCore, ObjectTypeBaseCore } from "./container-types";
5
+ import { DataPickerValueType, DataSourceCore, DynamicCore, GraphQLCore, GraphQLValue, RichDataPickerCore, RichExprEditorCore } from "./misc-types";
6
+ import { CardPickerCore, ClassCore, CodeStringCore, ColorCore, DateRangeStringsCore, DateStringCore, HrefCore, NumberTypeBaseCore, PlainNumberCore, PlainStringCore, RichBooleanCore, RichTextCore, SliderNumberCore, ThemeResetClassCore } from "./primitive-types";
7
+ import { CommonTypeBase, ContextDependentConfig, ControlExtras, GenericContext, InferDataType } from "./shared-controls";
8
+ export type ComponentControlContext<P> = GenericContext<P, // Full component props
9
+ // Full component props
10
+ InferDataType<P> | null, // Canvas data
11
+ ControlExtras>;
12
+ export type ComponentContextConfig<Props, R> = ContextDependentConfig<ComponentControlContext<Props>, R>;
13
+ export interface PropTypeBase<Ctx extends any[]> extends CommonTypeBase<Ctx> {
14
+ displayName?: string;
15
+ readOnly?: boolean | ContextDependentConfig<Ctx, boolean>;
16
+ /**
17
+ * If true, will hide the prop in a collapsed section; good for props that
18
+ * should not usually be used.
19
+ */
20
+ advanced?: boolean;
21
+ /**
22
+ * If set to true, the component will be remounted when the prop value is updated.
23
+ * (This behavior only applies to canvas)
24
+ */
25
+ forceRemount?: boolean;
26
+ /**
27
+ * If true, the prop can't be overriden in different variants.
28
+ */
29
+ invariantable?: boolean;
30
+ }
31
+ export interface Defaultable<Ctx extends any[], T> {
32
+ /**
33
+ * Default value to set for this prop when the component is instantiated
34
+ */
35
+ defaultValue?: T;
36
+ /**
37
+ * If no prop is given, the component uses a default; specify what
38
+ * that default is so the Plasmic user can see it in the studio UI
39
+ */
40
+ defaultValueHint?: T | ContextDependentConfig<Ctx, T | undefined>;
41
+ /**
42
+ * Use a dynamic value expression as the default instead
43
+ */
44
+ defaultExpr?: string;
45
+ defaultExprHint?: string;
46
+ /**
47
+ * This function validates whether the prop value is valid.
48
+ * If the value is invalid, it returns an error message. Otherwise, it returns true.
49
+ */
50
+ validator?: (value: T, ...args: Ctx) => (string | true) | Promise<string | true>;
51
+ }
52
+ export interface Controllable {
53
+ /**
54
+ * If true, this is a prop that should only be used inside Plasmic
55
+ * Studio for rendering artboards; will not be actually used in
56
+ * generated code.
57
+ */
58
+ editOnly?: boolean;
59
+ /**
60
+ * If specified, the value used for this prop will instead be
61
+ * mapped to the uncontrolledProp when generating code. This is
62
+ * useful if, for example, in the artboard, you want to use `value`
63
+ * prop to control the component, but in generated code, you want to
64
+ * map it to `defaultValue`.
65
+ */
66
+ uncontrolledProp?: string;
67
+ }
68
+ export type PropTypeBaseDefault<P, T> = PropTypeBase<ComponentControlContext<P>> & Defaultable<ComponentControlContext<P>, T> & Controllable;
69
+ export type PlainStringType<P> = PropTypeBaseDefault<P, string> & PlainStringCore;
70
+ export type CodeStringType<P> = PropTypeBaseDefault<P, string> & CodeStringCore;
71
+ export type RichTextType<P> = PropTypeBaseDefault<P, string> & RichTextCore;
72
+ export type HrefType<P> = PropTypeBaseDefault<P, string> & HrefCore;
73
+ export type ColorType<P> = PropTypeBaseDefault<P, string> & ColorCore;
74
+ export type DateStringType<P> = PropTypeBaseDefault<P, string> & DateStringCore;
75
+ export type DateRangeStringsType<P> = PropTypeBaseDefault<P, [string, string]> & DateRangeStringsCore;
76
+ export type ClassType<P> = PropTypeBase<ComponentControlContext<P>> & ClassCore;
77
+ export type ThemeResetClassType<P> = PropTypeBase<ComponentControlContext<P>> & ThemeResetClassCore;
78
+ export type CardPickerType<P> = PropTypeBaseDefault<P, string> & CardPickerCore<ComponentControlContext<P>>;
79
+ export type RichStringType<P> = PlainStringType<P> | CodeStringType<P> | RichTextType<P> | ColorType<P> | ClassType<P> | ThemeResetClassType<P> | CardPickerType<P> | HrefType<P>;
80
+ export type StringType<P> = "string" | "href" | RichStringType<P>;
81
+ export type RichBooleanType<P> = PropTypeBaseDefault<P, boolean> & RichBooleanCore;
82
+ export type BooleanType<P> = "boolean" | RichBooleanType<P>;
83
+ export type GraphQLType<P> = PropTypeBaseDefault<P, GraphQLValue> & GraphQLCore<ComponentControlContext<P>>;
84
+ export type NumberTypeBase<P> = PropTypeBaseDefault<P, number> & NumberTypeBaseCore<ComponentControlContext<P>>;
85
+ export type PlainNumberType<P> = NumberTypeBase<P> & PlainNumberCore<ComponentControlContext<P>>;
86
+ export type SliderNumberType<P> = NumberTypeBase<P> & SliderNumberCore<ComponentControlContext<P>>;
87
+ export type RichNumberType<P> = PlainNumberType<P> | SliderNumberType<P>;
88
+ export type NumberType<P> = "number" | RichNumberType<P>;
89
+ export type ObjectType<P> = PropTypeBaseDefault<P, Record<string, any>> & ObjectTypeBaseCore<ComponentControlContext<P>, PropType<P>>;
90
+ export type ArrayType<P> = PropTypeBaseDefault<P, any[]> & ArrayTypeBaseCore<ComponentControlContext<P>, PropType<P>>;
91
+ export type JSONLikeType<P> = "object" | ObjectType<P> | ArrayType<P>;
92
+ export type DataSourceType<P> = PropTypeBase<ComponentControlContext<P>> & DataSourceCore;
93
+ export type RichDataPickerType<P> = PropTypeBaseDefault<P, DataPickerValueType> & RichDataPickerCore<ComponentControlContext<P>>;
94
+ export type DataPickerType<P> = "dataPicker" | RichDataPickerType<P>;
95
+ export type RichExprEditorType<P> = PropTypeBaseDefault<P, DataPickerValueType> & RichExprEditorCore<ComponentControlContext<P>>;
96
+ export type ExprEditorType<P> = "exprEditor" | RichExprEditorType<P>;
97
+ export type ComponentChoiceType<P, Opt extends ChoiceValue = ChoiceValue, Val = Opt | Opt[]> = PropTypeBaseDefault<P, Val> & ChoiceCore<ComponentControlContext<P>, Opt>;
98
+ export interface SingleChoiceType<P, Opt extends ChoiceValue = ChoiceValue> extends ComponentChoiceType<P, Opt, Opt> {
99
+ multiSelect?: false;
100
+ }
101
+ export interface MultiChoiceType<P, Opt extends ChoiceValue = ChoiceValue> extends ComponentChoiceType<P, Opt, Opt[]> {
102
+ multiSelect: true;
103
+ }
104
+ export interface CustomChoiceType<P> extends ComponentChoiceType<P, ChoiceValue, ChoiceValue | ChoiceValue[]> {
105
+ multiSelect: ComponentContextConfig<P, boolean>;
106
+ }
107
+ export type ChoiceType<P> = SingleChoiceType<P> | MultiChoiceType<P> | CustomChoiceType<P>;
108
+ export interface FormValidationRulesType<P> extends PropTypeBaseDefault<P, any> {
109
+ type: "formValidationRules";
110
+ }
111
+ export interface EventHandlerType<P> extends PropTypeBase<ComponentControlContext<P>> {
112
+ type: "eventHandler";
113
+ argTypes: {
114
+ name: string;
115
+ type: ArgType<any>;
116
+ }[];
117
+ }
118
+ export interface RichSlotType<P> {
119
+ type: "slot";
120
+ description?: string;
121
+ /**
122
+ * The unique names of all code components that can be placed in the slot
123
+ */
124
+ allowedComponents?: string[];
125
+ /**
126
+ * Wheter Plasmic Components with a root component included in the
127
+ * "allowedComponents" list are valid or not.
128
+ * Only used if the "allowedComponents" list is set.
129
+ */
130
+ allowRootWrapper?: boolean;
131
+ /**
132
+ * Whether the "empty slot" placeholder should be hidden in the canvas.
133
+ */
134
+ hidePlaceholder?: boolean;
135
+ /**
136
+ * Whether the slot is repeated, i.e., is rendered multiple times using
137
+ * repeatedElement().
138
+ */
139
+ isRepeated?: boolean;
140
+ /**
141
+ * A nicer, human-readable display name for your slot prop
142
+ */
143
+ displayName?: string;
144
+ /**
145
+ * Function for whether this slot should be hidden from the left tree,
146
+ * given the current props for this component
147
+ */
148
+ hidden?: ComponentContextConfig<P, boolean>;
149
+ /**
150
+ * If slot is a render prop (accepts a function that takes in some
151
+ * arguments and returns some JSX), then specify the names of the
152
+ * arguments expected by the render prop function.
153
+ */
154
+ renderPropParams?: string[];
155
+ /**
156
+ * When inserting top-level "page sections", should this slot be the default target?
157
+ */
158
+ unstable__isMainContentSlot?: boolean;
159
+ defaultValue?: PlasmicElement | PlasmicElement[];
160
+ /**
161
+ * When true, when you click for the first time in this slot and the component was not selected, the component itself
162
+ * is selected, making it easier to select the component instead of slot contents. So for
163
+ * instance, setting this on a Button slot ensures that clicking on the Button’s text will still select the Button and not
164
+ * the text element in its slot. Clicking again will deep-select the slot content. Similar in this regard to trapsFocus on components.
165
+ *
166
+ * Furthermore, the component further shows the props of whatever is in the slot on
167
+ * the parent component for the user's convenience. Handy for various “wrapper" components, form fields, and so on.
168
+ */
169
+ mergeWithParent?: boolean | ComponentContextConfig<P, boolean>;
170
+ /**
171
+ * A function that returns true to hide the merged props conditionally.
172
+ */
173
+ hiddenMergedProps?: ComponentContextConfig<P, boolean>;
174
+ }
175
+ export type SlotType<P> = "slot" | RichSlotType<P>;
176
+ export interface RichImageUrlType<P> extends PropTypeBaseDefault<P, string> {
177
+ type: "imageUrl";
178
+ }
179
+ export type ImageUrlType<P> = "imageUrl" | RichImageUrlType<P>;
180
+ export interface ModalProps {
181
+ show?: boolean;
182
+ children?: React.ReactNode;
183
+ onClose: () => void;
184
+ style?: CSSProperties;
185
+ }
186
+ export interface StudioOps {
187
+ showModal: (modalProps: Omit<ModalProps, "onClose"> & {
188
+ onClose?: () => void;
189
+ }) => void;
190
+ refreshQueryData: () => void;
191
+ appendToSlot: (element: PlasmicElement, slotName: string) => void;
192
+ removeFromSlotAt: (pos: number, slotName: string) => void;
193
+ updateProps: (newValues: any) => void;
194
+ updateStates: (newValues: any) => void;
195
+ }
196
+ export interface ProjectData {
197
+ components: {
198
+ name: string;
199
+ }[];
200
+ pages: {
201
+ name: string;
202
+ pageMeta: {
203
+ path: string;
204
+ };
205
+ }[];
206
+ }
207
+ export interface CustomControlProps<P> {
208
+ componentProps: P;
209
+ /**
210
+ * `contextData` can be `null` if the prop controls are rendering before
211
+ * the component instance itself (it will re-render once the component
212
+ * calls `setControlContextData`)
213
+ */
214
+ contextData: InferDataType<P> | null;
215
+ /**
216
+ * Operations available to the editor that allow modifying the entire component.
217
+ * Can be null if the custom prop is used in a global context.
218
+ */
219
+ studioOps: StudioOps | null;
220
+ /**
221
+ * Metadata from the studio project.
222
+ */
223
+ projectData: ProjectData;
224
+ value: any;
225
+ /**
226
+ * Sets the value to be passed to the prop. Expects a JSON-compatible value.
227
+ */
228
+ updateValue: (newVal: any) => void;
229
+ /**
230
+ * Full screen modal component
231
+ */
232
+ FullscreenModal: React.ComponentType<ModalProps>;
233
+ /**
234
+ * Modal component for the side pane
235
+ */
236
+ SideModal: React.ComponentType<ModalProps>;
237
+ /**
238
+ * The document that the component will be rendered into; instead of using
239
+ * `document` directly (for, say, `document.querySelector()` etc.), you
240
+ * should use this instead.
241
+ */
242
+ studioDocument: typeof document;
243
+ }
244
+ export type CustomControl<P> = React.ComponentType<CustomControlProps<P>>;
245
+ export interface RichCustomType<P> extends PropTypeBaseDefault<P, any> {
246
+ type: "custom";
247
+ control: CustomControl<P>;
248
+ }
249
+ export type CustomType<P> = RichCustomType<P> | CustomControl<P>;
250
+ export interface DynamicType<P> extends PropTypeBase<ComponentControlContext<P>>, DynamicCore<ComponentControlContext<P>, PropType<P>> {
251
+ }
252
+ export type PrimitiveType<P = any> = Extract<StringType<P> | BooleanType<P> | NumberType<P> | JSONLikeType<P>, string>;
253
+ export type PropType<P> = StringType<P> | BooleanType<P> | GraphQLType<P> | NumberType<P> | JSONLikeType<P> | DataSourceType<P> | DataPickerType<P> | ExprEditorType<P> | FormValidationRulesType<P> | EventHandlerType<P> | ChoiceType<P> | CustomType<P> | DynamicType<P> | ImageUrlType<P> | SlotType<P> | DateStringType<P> | DateRangeStringsType<P>;
254
+ export type ArgType<P> = Exclude<PropType<P>, SlotType<P> | EventHandlerType<P>>;
255
+ export type StringCompatType<P> = DateStringType<P> | StringType<P> | ChoiceType<P> | JSONLikeType<P> | ImageUrlType<P> | CustomType<P> | DataPickerType<P>;
256
+ export type BoolCompatType<P> = BooleanType<P> | CustomType<P> | DataPickerType<P>;
257
+ export type NumberCompatType<P> = NumberType<P> | CustomType<P> | DataPickerType<P>;
258
+ export type RestrictPropType<T, P> = T extends string ? StringCompatType<P> : T extends boolean ? BoolCompatType<P> : T extends number ? NumberCompatType<P> : PropType<P>;
@@ -0,0 +1,35 @@
1
+ import { ContextDependentConfig } from "./shared-controls";
2
+ export interface ObjectTypeBaseCore<Ctx extends any[], Fields> {
3
+ type: "object";
4
+ fields?: Record<string, Fields>;
5
+ nameFunc?: (item: any, ...args: Ctx) => string | undefined;
6
+ }
7
+ export interface ArrayTypeBaseCore<Ctx extends any[], Fields> {
8
+ type: "array";
9
+ itemType?: ObjectTypeBaseCore<Ctx, Fields>;
10
+ /**
11
+ * Optional function that determines whether the user can delete a given item.
12
+ */
13
+ unstable__canDelete?: (item: any, ...args: Ctx) => boolean;
14
+ /**
15
+ * Specify how to let Plasmic know how to update its own internal representation of the data when the value has
16
+ * changed, or when issuing a minimalValue or shownValue that is different.
17
+ *
18
+ * Important to specify this if you are expecting any nested expression values in this data type!
19
+ */
20
+ unstable__keyFunc?: (item: any) => any;
21
+ /**
22
+ * Specify what would be the tentative new value that is set if the user makes any changes.
23
+ *
24
+ * Useful for field mappings.
25
+ *
26
+ * For instance, consider a Table where we have a `fields` prop:
27
+ *
28
+ * - Initially, the value is undefined. But if the user makes any changes, we would want to save an array of at
29
+ * least three items (corresponding to, say, three columns inferred from a schema).
30
+ *
31
+ * - Let's say there are 5 columns in the value. The data schema changes, removing a column and adding two new
32
+ * ones. Now we would want a different minimal value, containing 6 items.
33
+ */
34
+ unstable__minimalValue?: ContextDependentConfig<Ctx, any>;
35
+ }
@@ -0,0 +1,100 @@
1
+ import { ChoiceCore, ChoiceValue } from "./choice-type";
2
+ import { ArrayTypeBaseCore, ObjectTypeBaseCore } from "./container-types";
3
+ import { DynamicCore, GraphQLCore, GraphQLValue } from "./misc-types";
4
+ import { DateRangeStringsCore, DateStringCore, NumberTypeBaseCore, RichBooleanCore } from "./primitive-types";
5
+ import { CommonTypeBase, ContextDependentConfig, GenericContext } from "./shared-controls";
6
+ import { Nullish } from "./type-utils";
7
+ export type FunctionControlContext<P> = GenericContext<Partial<P>, // Partial function props
8
+ any>;
9
+ export type FunctionContextConfig<Args extends any[], R> = ContextDependentConfig<FunctionControlContext<Args>, R>;
10
+ export interface BaseParam {
11
+ name: string;
12
+ description?: string;
13
+ isOptional?: boolean;
14
+ isRestParameter?: boolean;
15
+ }
16
+ export interface FunctionMeta<Args extends any[] = any> extends CommonTypeBase<FunctionControlContext<Args>> {
17
+ name: string;
18
+ rest?: boolean;
19
+ }
20
+ export interface PlainStringType<T extends Nullish<string> = string> extends BaseParam {
21
+ type: "string" | `'${T}'`;
22
+ }
23
+ export type StringType<P, T extends string = string> = "string" | PlainStringType<T> | ChoiceType<P, T> | DateStringType | DateRangeStringsType | AnyType;
24
+ export interface PlainNumberType<T extends Nullish<number> = number> extends BaseParam {
25
+ type: "number" | `${number extends T ? number : T}`;
26
+ }
27
+ export type NumberType<P, T extends number = number> = PlainNumberType<T> | (BaseParam & NumberTypeBaseCore<FunctionControlContext<P>>) | ChoiceType<P, T> | AnyType;
28
+ export interface PlainBooleanType<T extends Nullish<boolean> = boolean> extends BaseParam {
29
+ type: "boolean" | `${boolean extends T ? boolean : T}`;
30
+ }
31
+ export type BooleanType<P, T extends boolean = boolean> = PlainBooleanType<T> | (BaseParam & RichBooleanCore) | ChoiceType<P, T> | AnyType;
32
+ export type GraphQLType<P> = BaseParam & GraphQLCore<FunctionControlContext<P>>;
33
+ export interface PlainNullType extends BaseParam {
34
+ type: "null";
35
+ }
36
+ export type NullType = PlainNullType | AnyType;
37
+ export interface PlainUndefinedType extends BaseParam {
38
+ type: "undefined";
39
+ }
40
+ export type UndefinedType = PlainUndefinedType | AnyType;
41
+ export type ObjectType<P> = BaseParam & ObjectTypeBaseCore<FunctionControlContext<P>, AnyTyping<P, any>>;
42
+ export type ArrayType<P> = BaseParam & ArrayTypeBaseCore<FunctionControlContext<P>, AnyTyping<P, any>>;
43
+ export interface PlainAnyType extends BaseParam {
44
+ type: "any";
45
+ }
46
+ export type AnyType = PlainAnyType;
47
+ export interface PlainVoidType extends BaseParam {
48
+ type: "void";
49
+ }
50
+ export type VoidType = PlainVoidType | AnyType;
51
+ type IsAny<T> = 0 extends 1 & T ? true : false;
52
+ 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;
53
+ 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>;
54
+ export type ToTuple<T> = T extends any[] ? T : never;
55
+ export type FunctionChoiceType<Args, Opt extends ChoiceValue = ChoiceValue> = FunctionMeta<ToTuple<Args>> & ChoiceCore<FunctionControlContext<ToTuple<Args>>, Opt>;
56
+ export interface SingleChoiceType<P, Opt extends ChoiceValue = ChoiceValue> extends FunctionChoiceType<P, Opt> {
57
+ multiSelect?: false;
58
+ }
59
+ export interface MultiChoiceType<P, Opt extends ChoiceValue = ChoiceValue> extends FunctionChoiceType<P, Opt> {
60
+ multiSelect: true;
61
+ }
62
+ export interface CustomChoiceType<P, Opt extends ChoiceValue = ChoiceValue> extends FunctionChoiceType<P, Opt> {
63
+ multiSelect: FunctionContextConfig<ToTuple<P>, boolean>;
64
+ }
65
+ export type ChoiceType<P, T extends ChoiceValue = ChoiceValue> = SingleChoiceType<P, T> | MultiChoiceType<P, T> | CustomChoiceType<P, T>;
66
+ export type DateStringType = BaseParam & DateStringCore;
67
+ export type DateRangeStringsType = BaseParam & DateRangeStringsCore;
68
+ export interface DynamicType<P> extends BaseParam, DynamicCore<FunctionControlContext<ToTuple<P>>, ParamType<P, any>> {
69
+ }
70
+ export type RestrictedType<P, T> = IsAny<T> extends true ? AnyTyping<P, T> : [
71
+ T
72
+ ] 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>;
73
+ export type ParamType<P, T> = RestrictedType<P, T> | DynamicType<P>;
74
+ export type RequiredParam<P, T> = ParamType<P, T> & {
75
+ isOptional?: false;
76
+ isRestParameter?: false;
77
+ };
78
+ export type OptionalParam<P, T> = ParamType<P, T> & {
79
+ isRestParameter?: false;
80
+ };
81
+ export type RestParam<P, T> = ParamType<P, T> & {
82
+ isOptional?: false;
83
+ isRestParameter: true;
84
+ };
85
+ type RequiredParams<T extends any[], U extends any[] = []> = Partial<T> extends T ? U : T extends [infer F, ...infer R] ? RequiredParams<R, [...U, F]> : U;
86
+ type OptionalParams<T extends any[]> = T extends [
87
+ ...RequiredParams<T>,
88
+ ...infer R
89
+ ] ? [...R] : [];
90
+ type HandleRequiredParams<P, R extends any[]> = R extends [infer H, ...infer T] ? [string | RequiredParam<P, H>, ...HandleRequiredParams<P, T>] : [];
91
+ type HandleOptionalParams<P, R extends any[]> = R extends [infer H, ...infer T] ? [] | [
92
+ string | OptionalParam<P, H | undefined>,
93
+ ...HandleOptionalParams<P, T>
94
+ ] : R extends [] ? [] : R extends Array<infer T> ? [] | [RestParam<P, T[]>] : [];
95
+ export type HandleParams<P extends any[]> = [
96
+ ...HandleRequiredParams<P, RequiredParams<P>>,
97
+ ...HandleOptionalParams<P, Required<OptionalParams<P>>>
98
+ ];
99
+ export type HandleReturnType<P, T> = VoidType | ParamType<P, T>;
100
+ export {};
@@ -0,0 +1,38 @@
1
+ import { ContextDependentConfig } from "./shared-controls";
2
+ export interface RichExprEditorCore<Ctx extends any[]> {
3
+ type: "exprEditor";
4
+ data?: Record<string, any> | ContextDependentConfig<Ctx, Record<string, any>>;
5
+ isolateEnv?: boolean;
6
+ }
7
+ export interface DataSourceCore {
8
+ type: "dataSource";
9
+ dataSource: "airtable" | "cms";
10
+ }
11
+ export type DataPickerValueType = string | number | (string | number)[];
12
+ export interface RichDataPickerCore<Ctx extends any[]> {
13
+ type: "dataSelector";
14
+ data?: Record<string, any> | ContextDependentConfig<Ctx, Record<string, any>>;
15
+ alwaysShowValuePathAsLabel?: boolean;
16
+ isolateEnv?: boolean;
17
+ }
18
+ export type GraphQLValue = {
19
+ query: string;
20
+ variables?: Record<string, any>;
21
+ };
22
+ export interface GraphQLCore<Ctx extends any[]> {
23
+ type: "code";
24
+ lang: "graphql";
25
+ endpoint: string | ContextDependentConfig<Ctx, string>;
26
+ method?: string | ContextDependentConfig<Ctx, string>;
27
+ headers?: object | ContextDependentConfig<Ctx, object>;
28
+ }
29
+ /**
30
+ * Dynamic prop/param type that returns different control types based on context
31
+ */
32
+ export interface DynamicCore<Ctx extends any[], ControlType> {
33
+ type: "dynamic";
34
+ /**
35
+ * Function that takes the context and returns a control type
36
+ */
37
+ control: ContextDependentConfig<Ctx, ControlType>;
38
+ }
@@ -0,0 +1,123 @@
1
+ /// <reference types="react" />
2
+ import { CSSProperties } from "../element-types";
3
+ import { StyleSection } from "../registerComponent";
4
+ import { ContextDependentConfig } from "./shared-controls";
5
+ export interface RichBooleanCore {
6
+ type: "boolean";
7
+ }
8
+ export interface NumberTypeBaseCore<Ctx extends any[]> {
9
+ type: "number";
10
+ min?: number | ContextDependentConfig<Ctx, number>;
11
+ max?: number | ContextDependentConfig<Ctx, number>;
12
+ }
13
+ export interface PlainNumberCore<Ctx extends any[]> extends NumberTypeBaseCore<Ctx> {
14
+ control?: "default";
15
+ }
16
+ export interface SliderNumberCore<Ctx extends any[]> extends NumberTypeBaseCore<Ctx> {
17
+ control: "slider";
18
+ step?: number | ContextDependentConfig<Ctx, number>;
19
+ }
20
+ export interface PlainStringCore {
21
+ type: "string";
22
+ control?: "default" | "large";
23
+ isLocalizable?: boolean;
24
+ }
25
+ export interface CodeStringCore {
26
+ type: "code";
27
+ lang: "css" | "html" | "javascript" | "json";
28
+ }
29
+ export interface RichTextCore {
30
+ type: "richText";
31
+ }
32
+ export interface HrefCore {
33
+ type: "href";
34
+ }
35
+ export interface ColorCore {
36
+ type: "color";
37
+ /**
38
+ * If specified, and the user picks a color token in the Studio, then
39
+ * the value passed in as prop is a css variable reference, like
40
+ * `var(--TOKEN_ID)`, instead of the resolved hex value of the token.
41
+ * You should take care in using this in the proper css context --
42
+ * the css token is only defined if you are rendering under some
43
+ * Plasmic component in the DOM tree, which is usually the case,
44
+ * unless you are using a React portal.
45
+ */
46
+ keepCssVar?: boolean;
47
+ /**
48
+ * Prevent tokens from being selected.
49
+ */
50
+ disableTokens?: boolean;
51
+ }
52
+ export interface DateStringCore {
53
+ type: "dateString";
54
+ }
55
+ export interface DateRangeStringsCore {
56
+ type: "dateRangeStrings";
57
+ }
58
+ export interface ClassCore {
59
+ type: "class";
60
+ /**
61
+ * Additional css selectors that can change how this style should look.
62
+ * Some examples:
63
+ *
64
+ * * `:hover` -- on hover
65
+ * * `[data-something="blah"] -- when the element with this class has
66
+ * an html attribute "data-something=blah"
67
+ * * :component[data-something="blah"] :self -- when the root of the
68
+ * component has an html attribute "data-something=blah". Note that
69
+ * the non-standard `:component` selector is used to select the
70
+ * component root, and the non-standard `:self` selector is used
71
+ * to select the element that this class is attached to.
72
+ */
73
+ selectors?: {
74
+ /**
75
+ * A css selector, like `:hover` or `[data-something="blah"]`.
76
+ */
77
+ selector: string;
78
+ /**
79
+ * An optional human-friendly label for the selector, so the studio user
80
+ * knows what this selector means.
81
+ */
82
+ label?: string;
83
+ /**
84
+ * Initial styles to be applied for this selector
85
+ */
86
+ defaultStyles?: CSSProperties;
87
+ }[];
88
+ /**
89
+ * If specified, then only shows these style sections for styling this class
90
+ */
91
+ styleSections?: StyleSection[];
92
+ /**
93
+ * Initial styles to be applied for this class
94
+ */
95
+ defaultStyles?: CSSProperties;
96
+ }
97
+ export interface ThemeResetClassCore {
98
+ type: "themeResetClass";
99
+ /**
100
+ * Normally, theme reset class will only target Plasmic-generated tags
101
+ * with the default tag styles. If you also want to target non-Plasmic-generated
102
+ * tags (say, rendered by your code components, or fetched as an HTML blob
103
+ * from somewhere), then specify `true` here.
104
+ */
105
+ targetAllTags?: boolean;
106
+ }
107
+ export interface CardPickerCore<Ctx extends any[]> {
108
+ type: "cardPicker";
109
+ modalTitle?: React.ReactNode | ContextDependentConfig<Ctx, React.ReactNode>;
110
+ options: {
111
+ value: string;
112
+ label?: string;
113
+ imgUrl: string;
114
+ footer?: React.ReactNode;
115
+ }[] | ContextDependentConfig<Ctx, {
116
+ value: string;
117
+ label?: string;
118
+ imgUrl: string;
119
+ footer?: React.ReactNode;
120
+ }[]>;
121
+ showInput?: boolean | ContextDependentConfig<Ctx, boolean>;
122
+ onSearch?: ContextDependentConfig<Ctx, ((value: string) => void) | undefined>;
123
+ }
@@ -0,0 +1,40 @@
1
+ export type GenericContext<Props, Data, Extra = unknown> = [Props, Data, Extra];
2
+ /**
3
+ * Config option that takes the context (e.g., props) of the component instance
4
+ * or function to dynamically set its value.
5
+ */
6
+ export type ContextDependentConfig<Ctx extends any[], R> = (...args: Ctx) => R;
7
+ export type MaybeContextDependentConfig<Ctx extends any[], V> = V | ContextDependentConfig<Ctx, V>;
8
+ export interface CanvasComponentProps<Data = any> {
9
+ /**
10
+ * This prop is only provided within the canvas of Plasmic Studio.
11
+ * Allows the component to set data to be consumed by the props' controls.
12
+ */
13
+ setControlContextData?: (data: Data) => void;
14
+ }
15
+ export type ControlExtras = {
16
+ path: (string | number)[];
17
+ item?: any;
18
+ };
19
+ export type InferDataType<P> = P extends CanvasComponentProps<infer Data> ? Data : any;
20
+ export interface CommonTypeBase<Ctx extends any[]> {
21
+ description?: string;
22
+ helpText?: string;
23
+ required?: boolean;
24
+ /**
25
+ * If the user has chosen to use a dynamic expression for this prop, provide
26
+ * a hint as to the expected values that the expression should evaluate to.
27
+ * This hint will be displayed alongside the code editor. You may use
28
+ * markdown in the text here.
29
+ */
30
+ exprHint?: string;
31
+ /**
32
+ * Function for whether this prop should be hidden in the right panel,
33
+ * given the current props for this component
34
+ */
35
+ hidden?: ContextDependentConfig<Ctx, boolean>;
36
+ /**
37
+ * If true, does not allow the user to use a dynamic expression for this prop
38
+ */
39
+ disableDynamicValue?: boolean;
40
+ }
@@ -1 +1 @@
1
- export declare const hostVersion = "1.0.224";
1
+ export declare const hostVersion = "1.0.226";
File without changes