@plasmicapp/host 2.0.0-alpha.0 → 2.0.0-alpha.1

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 (99) hide show
  1. package/dist/data.d.ts +1 -5
  2. package/dist/exports.d.ts +3 -4
  3. package/dist/host.esm.js +6 -17
  4. package/dist/host.esm.js.map +1 -1
  5. package/dist/index.cjs.js +5 -17
  6. package/dist/index.cjs.js.map +1 -1
  7. package/dist/prop-types.d.ts +6 -475
  8. package/dist/registerComponent.d.ts +8 -11
  9. package/dist/registerFunction.d.ts +2 -127
  10. package/dist/types/choice-type.d.ts +16 -0
  11. package/dist/types/component-types.d.ts +251 -0
  12. package/dist/types/container-types.d.ts +42 -0
  13. package/dist/types/function-types.d.ts +101 -0
  14. package/dist/types/misc-types.d.ts +38 -0
  15. package/dist/types/primitive-types.d.ts +123 -0
  16. package/dist/types/query-builder-types.d.ts +51 -0
  17. package/dist/types/shared-controls.d.ts +50 -0
  18. package/dist/types/type-utils.d.ts +7 -0
  19. package/dist/version.d.ts +1 -1
  20. package/package.json +4 -3
  21. package/registerComponent/dist/data.d.ts +1 -5
  22. package/registerComponent/dist/exports.d.ts +3 -4
  23. package/registerComponent/dist/index.cjs.js.map +1 -1
  24. package/registerComponent/dist/index.esm.js.map +1 -1
  25. package/registerComponent/dist/prop-types.d.ts +6 -475
  26. package/registerComponent/dist/registerComponent.d.ts +8 -11
  27. package/registerComponent/dist/registerFunction.d.ts +2 -127
  28. package/registerComponent/dist/types/choice-type.d.ts +16 -0
  29. package/registerComponent/dist/types/component-types.d.ts +251 -0
  30. package/registerComponent/dist/types/container-types.d.ts +42 -0
  31. package/registerComponent/dist/types/function-types.d.ts +101 -0
  32. package/registerComponent/dist/types/misc-types.d.ts +38 -0
  33. package/registerComponent/dist/types/primitive-types.d.ts +123 -0
  34. package/registerComponent/dist/types/query-builder-types.d.ts +51 -0
  35. package/registerComponent/dist/types/shared-controls.d.ts +50 -0
  36. package/registerComponent/dist/types/type-utils.d.ts +7 -0
  37. package/registerComponent/dist/version.d.ts +1 -1
  38. package/registerFunction/dist/data.d.ts +1 -5
  39. package/registerFunction/dist/exports.d.ts +3 -4
  40. package/registerFunction/dist/index.cjs.js.map +1 -1
  41. package/registerFunction/dist/index.esm.js.map +1 -1
  42. package/registerFunction/dist/prop-types.d.ts +6 -475
  43. package/registerFunction/dist/registerComponent.d.ts +8 -11
  44. package/registerFunction/dist/registerFunction.d.ts +2 -127
  45. package/registerFunction/dist/types/choice-type.d.ts +16 -0
  46. package/registerFunction/dist/types/component-types.d.ts +251 -0
  47. package/registerFunction/dist/types/container-types.d.ts +42 -0
  48. package/registerFunction/dist/types/function-types.d.ts +101 -0
  49. package/registerFunction/dist/types/misc-types.d.ts +38 -0
  50. package/registerFunction/dist/types/primitive-types.d.ts +123 -0
  51. package/registerFunction/dist/types/query-builder-types.d.ts +51 -0
  52. package/registerFunction/dist/types/shared-controls.d.ts +50 -0
  53. package/registerFunction/dist/types/type-utils.d.ts +7 -0
  54. package/registerFunction/dist/version.d.ts +1 -1
  55. package/registerGlobalContext/dist/data.d.ts +1 -5
  56. package/registerGlobalContext/dist/exports.d.ts +3 -4
  57. package/registerGlobalContext/dist/prop-types.d.ts +6 -475
  58. package/registerGlobalContext/dist/registerComponent.d.ts +8 -11
  59. package/registerGlobalContext/dist/registerFunction.d.ts +2 -127
  60. package/registerGlobalContext/dist/types/choice-type.d.ts +16 -0
  61. package/registerGlobalContext/dist/types/component-types.d.ts +251 -0
  62. package/registerGlobalContext/dist/types/container-types.d.ts +42 -0
  63. package/registerGlobalContext/dist/types/function-types.d.ts +101 -0
  64. package/registerGlobalContext/dist/types/misc-types.d.ts +38 -0
  65. package/registerGlobalContext/dist/types/primitive-types.d.ts +123 -0
  66. package/registerGlobalContext/dist/types/query-builder-types.d.ts +51 -0
  67. package/registerGlobalContext/dist/types/shared-controls.d.ts +50 -0
  68. package/registerGlobalContext/dist/types/type-utils.d.ts +7 -0
  69. package/registerGlobalContext/dist/version.d.ts +1 -1
  70. package/registerToken/dist/data.d.ts +1 -5
  71. package/registerToken/dist/exports.d.ts +3 -4
  72. package/registerToken/dist/prop-types.d.ts +6 -475
  73. package/registerToken/dist/registerComponent.d.ts +8 -11
  74. package/registerToken/dist/registerFunction.d.ts +2 -127
  75. package/registerToken/dist/types/choice-type.d.ts +16 -0
  76. package/registerToken/dist/types/component-types.d.ts +251 -0
  77. package/registerToken/dist/types/container-types.d.ts +42 -0
  78. package/registerToken/dist/types/function-types.d.ts +101 -0
  79. package/registerToken/dist/types/misc-types.d.ts +38 -0
  80. package/registerToken/dist/types/primitive-types.d.ts +123 -0
  81. package/registerToken/dist/types/query-builder-types.d.ts +51 -0
  82. package/registerToken/dist/types/shared-controls.d.ts +50 -0
  83. package/registerToken/dist/types/type-utils.d.ts +7 -0
  84. package/registerToken/dist/version.d.ts +1 -1
  85. package/registerTrait/dist/data.d.ts +1 -5
  86. package/registerTrait/dist/exports.d.ts +3 -4
  87. package/registerTrait/dist/prop-types.d.ts +6 -475
  88. package/registerTrait/dist/registerComponent.d.ts +8 -11
  89. package/registerTrait/dist/registerFunction.d.ts +2 -127
  90. package/registerTrait/dist/types/choice-type.d.ts +16 -0
  91. package/registerTrait/dist/types/component-types.d.ts +251 -0
  92. package/registerTrait/dist/types/container-types.d.ts +42 -0
  93. package/registerTrait/dist/types/function-types.d.ts +101 -0
  94. package/registerTrait/dist/types/misc-types.d.ts +38 -0
  95. package/registerTrait/dist/types/primitive-types.d.ts +123 -0
  96. package/registerTrait/dist/types/query-builder-types.d.ts +51 -0
  97. package/registerTrait/dist/types/shared-controls.d.ts +50 -0
  98. package/registerTrait/dist/types/type-utils.d.ts +7 -0
  99. package/registerTrait/dist/version.d.ts +1 -1
@@ -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" | "multiLine";
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,51 @@
1
+ import { ContextDependentConfig } from "./shared-controls";
2
+ /**
3
+ * Control type for building a custom query format.
4
+ *
5
+ * This control is based on react-awesome-query-builder
6
+ * and returns data in JsonLogic format.
7
+ *
8
+ * If using this control type, it's recommended to install
9
+ * @react-awesome-query-builder/core and json-logic-js as devDependencies
10
+ * so that you can reference their types.
11
+ *
12
+ * References:
13
+ * - https://github.com/ukrbublik/react-awesome-query-builder
14
+ * - https://github.com/jwadhams/json-logic-js
15
+ * - https://jsonlogic.com/
16
+ */
17
+ export interface QueryBuilderCore<Ctx extends any[]> {
18
+ type: "queryBuilder";
19
+ /**
20
+ * Return a @react-awesome-query-builder/core `Config` that will be merged
21
+ * with Plasmic's built-in config.
22
+ *
23
+ * https://github.com/plasmicapp/plasmic/blob/master/platform/wab/src/wab/client/components/QueryBuilder/QueryBuilderConfig.tsx
24
+ *
25
+ * At a minimum, this should return fields and their types.
26
+ * For configuration options, see react-awesome-query-builder docs.
27
+ */
28
+ config: ContextDependentConfig<Ctx, SimplifiedConfig>;
29
+ }
30
+ /**
31
+ * A simplified subset of @react-awesome-query-builder/core `Config`.
32
+ */
33
+ interface SimplifiedConfig {
34
+ fields: SimplifiedFields;
35
+ }
36
+ /**
37
+ * A simplified subset of @react-awesome-query-builder/core `Fields`.
38
+ */
39
+ interface SimplifiedFields {
40
+ [key: string]: SimplifiedField;
41
+ }
42
+ /**
43
+ * A simplified subset of @react-awesome-query-builder/core `FieldOrGroup`.
44
+ */
45
+ interface SimplifiedField {
46
+ type: "text" | "number" | "boolean" | "date" | "time" | "datetime" | "select" | "multiselect" | "treeselect" | "treemultiselect" | string;
47
+ label?: string;
48
+ defaultValue?: unknown;
49
+ fieldSettings?: {};
50
+ }
51
+ export {};
@@ -0,0 +1,50 @@
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 {
21
+ description?: string;
22
+ helpText?: string;
23
+ /**
24
+ * If true, will hide the prop in a collapsed section; good for props that
25
+ * should not usually be used.
26
+ */
27
+ advanced?: boolean;
28
+ /**
29
+ * If the user has chosen to use a dynamic expression for this prop, provide
30
+ * a hint as to the expected values that the expression should evaluate to.
31
+ * This hint will be displayed alongside the code editor. You may use
32
+ * markdown in the text here.
33
+ */
34
+ exprHint?: string;
35
+ /**
36
+ * If true, does not allow the user to use a dynamic expression for this prop
37
+ */
38
+ disableDynamicValue?: boolean;
39
+ }
40
+ export interface Defaultable<Ctx extends any[], T> {
41
+ /**
42
+ * Default value to set for this prop when the component is instantiated
43
+ */
44
+ defaultValue?: T;
45
+ /**
46
+ * Specify that default when no prop/param is provided,
47
+ * so the Plasmic user can see it in the studio UI
48
+ */
49
+ defaultValueHint?: T | ContextDependentConfig<Ctx, T | undefined>;
50
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Converts a union type to a tuple type of the same members
3
+ */
4
+ export type TupleUnion<U extends string, R extends string[] = []> = {
5
+ [S in U]: Exclude<U, S> extends never ? [...R, S] : TupleUnion<Exclude<U, S>, [...R, S]>;
6
+ }[U] & string[];
7
+ export type Nullish<T> = T | null | undefined;
@@ -1 +1 @@
1
- export declare const hostVersion = "2.0.0-alpha.0";
1
+ export declare const hostVersion = "2.0.0-alpha.1";
@@ -51,12 +51,8 @@ export interface PageParamsProviderProps {
51
51
  * Page query params (e.g. { q: "search term" })
52
52
  */
53
53
  query?: Record<string, string | string[] | undefined>;
54
- /**
55
- * @deprecated Use `route` instead.
56
- */
57
- path?: string;
58
54
  }
59
- export declare function PageParamsProvider({ children, route, path: deprecatedRoute, params, query, }: PageParamsProviderProps): React.JSX.Element;
55
+ export declare function PageParamsProvider({ children, route, params, query, }: PageParamsProviderProps): React.JSX.Element;
60
56
  export declare function DataCtxReader({ children, }: {
61
57
  children: ($ctx: DataDict | undefined) => ReactNode;
62
58
  }): React.ReactElement<any, string | React.JSXElementConstructor<any>> | null;
@@ -1,12 +1,11 @@
1
1
  export { PlasmicCanvasContext, PlasmicCanvasHost, usePlasmicCanvasComponentInfo, usePlasmicCanvasContext, } from "./canvas-host";
2
2
  export * from "./data";
3
3
  export { PlasmicElement } from "./element-types";
4
- export { registerFetcher as unstable_registerFetcher } from "./fetcher";
5
4
  export * from "./global-actions";
6
5
  export * from "./link";
7
- export { ContextDependentConfig, CustomControlProps, ProjectData, PropType, StudioOps, } from "./prop-types";
8
- export { Action, ActionProps, CodeComponentMeta, CodeComponentMode, ComponentHelpers, ComponentMeta, ComponentRegistration, ComponentTemplates, StateHelpers, StateSpec, default as registerComponent, stateHelpersKeys, } from "./registerComponent";
9
- export { CustomFunctionMeta, CustomFunctionRegistration, ParamType, default as registerFunction, } from "./registerFunction";
6
+ export { ChoiceObject, ChoiceOptions, ChoiceValue, ComponentContextConfig, ComponentControlContext, ContextDependentConfig, ControlExtras, CustomControlProps, ProjectData, PropType, StudioOps, } from "./prop-types";
7
+ export { Action, ActionProps, CodeComponentMeta, CodeComponentMode, ComponentHelpers, ComponentRegistration, ComponentTemplates, StateHelpers, StateSpec, default as registerComponent, stateHelpersKeys, } from "./registerComponent";
8
+ export { CustomFunctionMeta, CustomFunctionRegistration, FunctionContextConfig, FunctionControlContext, ParamType, default as registerFunction, } from "./registerFunction";
10
9
  export { GlobalContextMeta, PropType as GlobalContextPropType, GlobalContextRegistration, default as registerGlobalContext, } from "./registerGlobalContext";
11
10
  export { TokenRegistration, TokenType, default as registerToken, } from "./registerToken";
12
11
  export { BasicTrait, ChoiceTrait, TraitMeta, TraitRegistration, default as registerTrait, } from "./registerTrait";