@wix/public-editor-platform-interfaces 1.38.0 → 1.40.0

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.
@@ -1,83 +1,52 @@
1
- import { ProviderItem } from './Providers';
2
- export type UnbindAll = 'ALL';
3
- export interface BindingsMap {
4
- [key: string]: PropertyBinding;
5
- }
6
- export type PropertyBinding = ContextItemBinding | MethodBinding;
7
- export declare enum BindingItemType {
8
- ContextItem = "ContextItem",
9
- Method = "Method"
1
+ import { ProviderType } from './Providers';
2
+ export declare const UNBIND_ALL: "ALL";
3
+ export type UnbindAll = typeof UNBIND_ALL;
4
+ export interface BindingProperties {
5
+ bindingsMap: ProviderBindingsMap;
6
+ displayName?: string;
7
+ providerIdentifier: string;
8
+ providerType: ProviderType;
10
9
  }
11
- export interface ContextItemBinding {
12
- bindingItemType: BindingItemType.ContextItem;
10
+ export type ProviderBindingsMap = Record<string, PropertyBinding>;
11
+ export type PropertyBinding = MethodBinding | ProviderItemBinding;
12
+ export interface ProviderItemBinding {
13
+ bindingItemType: BindingItemType.ItemBinding;
13
14
  displayName?: string;
14
15
  itemPath: string;
15
16
  }
16
17
  export interface MethodBinding {
17
- bindingItemType: BindingItemType.Method;
18
+ bindingItemType: BindingItemType.MethodBinding;
18
19
  callOptions: CallOptions;
19
20
  displayName?: string;
20
21
  methodPath: string;
21
22
  }
22
- export type BindingArgument = ContextBindingArgument | FunctionBinding | StaticArgument;
23
+ export declare enum BindingItemType {
24
+ ItemBinding = "ItemBinding",
25
+ MethodBinding = "MethodBinding"
26
+ }
27
+ export type BindingArgument = ProviderItemBindingArgument | StaticArgument;
23
28
  export interface CallOptions {
24
29
  arguments: BindingArgument[];
25
30
  asCallback: boolean;
26
31
  }
27
- export interface FunctionBinding extends CallOptions {
28
- displayName?: string;
29
- function: string;
30
- functionLibraryType: string;
31
- type: ArgumentType.FunctionBinding;
32
+ export declare enum ArgumentType {
33
+ ProviderBinding = "ProviderBindingItem",
34
+ Static = "StaticArgItem"
32
35
  }
33
- export interface ContextBindingArgument {
34
- contextItem: PropertyBinding;
35
- contextProvider: string;
36
+ export interface ProviderItemBindingArgument {
36
37
  displayName?: string;
37
- type: ArgumentType.ContextBinding;
38
+ providerIdentifier: string;
39
+ providerItem: PropertyBinding;
40
+ providerType: ProviderType;
41
+ type: ArgumentType.ProviderBinding;
38
42
  }
39
43
  export interface StaticArgument {
40
44
  dataType: string;
41
45
  type: ArgumentType.Static;
42
46
  value: string;
43
47
  }
44
- export declare enum ArgumentType {
45
- ContextBinding = "ContextBindingItem",
46
- FunctionBinding = "FunctionBindingItem",
47
- Static = "StaticArgItem"
48
- }
49
- export interface FunctionBindingsMap {
50
- [key: string]: FunctionPropertyBinding;
51
- }
52
- export interface FunctionPropertyBinding {
53
- callOptions: CallOptions;
54
- function: string;
55
- }
56
- export interface BoundPropertiesPerProvider {
57
- [key: string]: BoundProperties;
58
- }
59
- export type BoundProperties = ContextProviderBindings | FunctionLibraryBinding;
60
- export declare enum BindingType {
61
- ContextProvider = "ContextProvider",
62
- FunctionLibrary = "FunctionLibrary"
63
- }
64
- export interface ContextProviderBindings {
65
- bindingsMap: BindingsMap;
66
- bindingType: BindingType.ContextProvider;
67
- displayName?: string;
68
- }
69
- export interface FunctionLibraryBinding {
70
- bindingsMap: FunctionBindingsMap;
71
- bindingType: BindingType.FunctionLibrary;
48
+ export interface ListBindingsOptions {
49
+ includeDisplayNames?: boolean;
50
+ providerIdentifiers?: string[];
51
+ providerTypes?: ProviderType[];
72
52
  }
73
- export type Binding = {
74
- bindings: BindingsMap;
75
- providerType: string;
76
- };
77
- export type ListBindingsResponse = {
78
- bindings: BoundProperties;
79
- providerType: string;
80
- }[];
81
- export type BindingCandidate = ProviderItem & {
82
- isBound: boolean;
83
- };
package/dist/Bindings.js CHANGED
@@ -1,19 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BindingType = exports.ArgumentType = exports.BindingItemType = void 0;
3
+ exports.ArgumentType = exports.BindingItemType = exports.UNBIND_ALL = void 0;
4
+ exports.UNBIND_ALL = 'ALL';
4
5
  var BindingItemType;
5
6
  (function (BindingItemType) {
6
- BindingItemType["ContextItem"] = "ContextItem";
7
- BindingItemType["Method"] = "Method";
7
+ BindingItemType["ItemBinding"] = "ItemBinding";
8
+ BindingItemType["MethodBinding"] = "MethodBinding";
8
9
  })(BindingItemType || (exports.BindingItemType = BindingItemType = {}));
9
10
  var ArgumentType;
10
11
  (function (ArgumentType) {
11
- ArgumentType["ContextBinding"] = "ContextBindingItem";
12
- ArgumentType["FunctionBinding"] = "FunctionBindingItem";
12
+ ArgumentType["ProviderBinding"] = "ProviderBindingItem";
13
13
  ArgumentType["Static"] = "StaticArgItem";
14
14
  })(ArgumentType || (exports.ArgumentType = ArgumentType = {}));
15
- var BindingType;
16
- (function (BindingType) {
17
- BindingType["ContextProvider"] = "ContextProvider";
18
- BindingType["FunctionLibrary"] = "FunctionLibrary";
19
- })(BindingType || (exports.BindingType = BindingType = {}));
@@ -1,11 +1,65 @@
1
- export interface IElementBase<TType, TProps extends Record<string, any>> {
2
- type: TType;
3
- getProp: <K extends keyof TProps | string>(prop: K) => Promise<TProps[K] | null | undefined | void>;
4
- setProp<K extends keyof TProps>(prop: K, value: TProps[K] | null | undefined): Promise<void>;
1
+ import type { ElementData, ElementDataInput, ElementDataDefinitions, ElementStyles, ElementStylesUpdate, ElementStylesRemoval, ElementStyleDefinitions, ElementPresetDefinitions, ElementStateDefinitions, ElementLink, ElementDataValue } from './sdk';
2
+ import type { BackgroundPickerOptions } from './Inputs';
3
+ import type { SelectFontParams, SelectFontFamilyParams, SelectFontWeightParams, SelectMediaParams, SelectLinkParams, SelectColorParams, SelectTextThemeParams, IFontFamily, IFontWeight, IFontFamilyAndWeight } from './sdk/pickers';
4
+ /**
5
+ * Unified element interface returned by `elements.getSelection()` (Classic / Studio)
6
+ * and structurally satisfied by the `element` singleton (Harmony).
7
+ *
8
+ * @remarks
9
+ * In Classic / Studio editors, builder-specific methods (`getStyles`, `getData`,
10
+ * `applyPreset`, pickers, etc.) return inert empty values. They are functional only
11
+ * when the component is selected in Harmony (Editor 3).
12
+ */
13
+ export interface IElement {
14
+ /** Component type id. Populated in Classic/Studio (text|image|null). Always null in Harmony. */
15
+ type: string | null;
16
+ getProp<T = unknown>(prop: string): Promise<T | null | undefined | void>;
17
+ setProp<T = unknown>(prop: string, value: T | null | undefined): Promise<void>;
18
+ getData<T extends ElementData = ElementData>(): Promise<T>;
19
+ setData<T extends ElementData = ElementData>(values: ElementDataInput<T>): Promise<void>;
20
+ getResolvedData(options: {
21
+ dataItemKey: string;
22
+ }): Promise<ElementDataValue>;
23
+ getDataDefinitions(): Promise<ElementDataDefinitions>;
24
+ getStyles(): Promise<ElementStyles>;
25
+ setStyles(values?: ElementStylesUpdate): Promise<void>;
26
+ removeStyles(values?: ElementStylesRemoval): Promise<void>;
27
+ getStyleDefinitions(): Promise<ElementStyleDefinitions>;
28
+ getPresetDefinitions(): Promise<ElementPresetDefinitions>;
29
+ getAppliedPreset(): Promise<string | null>;
30
+ applyPreset(options: {
31
+ key: string;
32
+ }): Promise<void>;
33
+ getState(): Promise<string | null>;
34
+ setState(stateKey: string | null): Promise<void>;
35
+ getStateDefinitions(): Promise<ElementStateDefinitions>;
36
+ getDisplayGroupDefinitions(options?: {
37
+ filter?: {
38
+ groupType?: string;
39
+ };
40
+ }): Promise<Record<string, unknown>>;
41
+ getDisplayName(): Promise<string>;
42
+ onChange(callback: (patch: {
43
+ type: 'styles' | 'data' | 'state' | 'preset' | 'props' | 'manifest';
44
+ value: unknown;
45
+ }) => void): Promise<() => void>;
46
+ selectFont(params: SelectFontParams): Promise<IFontFamilyAndWeight | undefined>;
47
+ selectFontFamily(params: SelectFontFamilyParams): Promise<IFontFamily | undefined>;
48
+ selectFontWeight(params: SelectFontWeightParams): Promise<IFontWeight>;
49
+ selectMedia(params: SelectMediaParams): Promise<unknown>;
50
+ selectLink(params: SelectLinkParams): Promise<ElementLink | null | undefined>;
51
+ selectColor(params: SelectColorParams): Promise<string | undefined>;
52
+ selectBackground(options: BackgroundPickerOptions): Promise<unknown>;
53
+ selectTextTheme(params: SelectTextThemeParams): Promise<unknown>;
54
+ getArrayItemsSelectedIndex(options?: {
55
+ arrayItemsDisplayGroupKey?: string;
56
+ }): Promise<number>;
57
+ setArrayItemsSelectedIndex(options: {
58
+ index: number;
59
+ arrayItemsDisplayGroupKey?: string;
60
+ }): Promise<void>;
61
+ resetArrayItemsSelectedIndex(options?: {
62
+ arrayItemsDisplayGroupKey?: string;
63
+ }): Promise<void>;
64
+ getBiToken(): Promise<string>;
5
65
  }
6
- export type IElement = IElementBase<'text', {
7
- text: string;
8
- }> | IElementBase<'image', {
9
- src: string;
10
- responsive: boolean;
11
- }> | IElementBase<null, Record<string, string | number | boolean>>;
@@ -1,30 +1,53 @@
1
+ import { DataType, EditorFunction, TextEnum } from '@wix/app-extensions/trusted';
2
+ export declare enum ProviderType {
3
+ Context = "Context",
4
+ FunctionLibrary = "FunctionLibrary",
5
+ Template = "Template"
6
+ }
1
7
  export type Provider = {
2
- attachState?: AttachState;
3
- contextDependencies?: string[];
4
8
  displayName: string;
5
9
  items?: Record<string, ProviderItem>;
6
- providerType: string;
7
- };
10
+ providerIdentifier: string;
11
+ } & ({
12
+ attachState?: AttachState.Above | AttachState.None | AttachState.Self;
13
+ contextDependencies?: string[];
14
+ providerType: ProviderType.Context;
15
+ } | {
16
+ attachState?: AttachState.Above | AttachState.Self;
17
+ providerType: ProviderType.Template;
18
+ } | {
19
+ attachState?: AttachState.System;
20
+ providerType: ProviderType.FunctionLibrary;
21
+ });
8
22
  type ProviderItemBase = {
9
23
  displayName: string;
10
24
  itemName: string;
11
- providerType: string;
12
25
  };
13
26
  export type ProviderArrayItem = ProviderItemBase & {
14
27
  arrayItem: ProviderItem;
15
- dataType: String;
28
+ dataType: DataType.arrayItems;
16
29
  };
17
30
  export type ProviderObjectItem = ProviderItemBase & {
18
- dataType: String;
31
+ dataType: DataType.data;
19
32
  objectItem: Record<string, ProviderItem>;
20
33
  };
34
+ export type ProviderFunctionItem = ProviderItemBase & {
35
+ dataType: DataType.function;
36
+ function?: EditorFunction;
37
+ };
38
+ export type ProviderTextEnumItem = ProviderItemBase & {
39
+ dataType: DataType.textEnum;
40
+ textEnum: TextEnum;
41
+ };
21
42
  export type ProviderSimpleItem = ProviderItemBase & {
22
- dataType: String;
43
+ dataType: Exclude<DataType, DataType.arrayItems | DataType.data | DataType.function | DataType.textEnum>;
23
44
  };
24
- export type ProviderItem = ProviderArrayItem | ProviderObjectItem | ProviderSimpleItem;
25
- export type AttachState = 'above' | 'none' | 'self';
26
- export interface AttachedProvider extends Provider {
27
- attachState: AttachState;
45
+ export type ProviderItem = ProviderArrayItem | ProviderFunctionItem | ProviderObjectItem | ProviderSimpleItem | ProviderTextEnumItem;
46
+ export declare enum AttachState {
47
+ Above = "above",
48
+ None = "none",
49
+ Self = "self",
50
+ System = "system"
28
51
  }
29
52
  export type AttachStateFilter = boolean | {
30
53
  filterAttachedState?: AttachState[];
@@ -33,6 +56,7 @@ export type ListProvidersOptions = {
33
56
  includeAttachState?: AttachStateFilter;
34
57
  includeDependencies?: boolean;
35
58
  includeItems?: boolean;
36
- providerTypes?: string[];
59
+ providerIdentifiers?: string[];
60
+ providerTypes?: ProviderType[];
37
61
  };
38
62
  export {};
package/dist/Providers.js CHANGED
@@ -1,2 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AttachState = exports.ProviderType = void 0;
4
+ var ProviderType;
5
+ (function (ProviderType) {
6
+ ProviderType["Context"] = "Context";
7
+ ProviderType["FunctionLibrary"] = "FunctionLibrary";
8
+ ProviderType["Template"] = "Template";
9
+ })(ProviderType || (exports.ProviderType = ProviderType = {}));
10
+ var AttachState;
11
+ (function (AttachState) {
12
+ AttachState["Above"] = "above";
13
+ AttachState["None"] = "none";
14
+ AttachState["Self"] = "self";
15
+ AttachState["System"] = "system";
16
+ })(AttachState || (exports.AttachState = AttachState = {}));
@@ -2,3 +2,4 @@ export * from './data';
2
2
  export * from './styles';
3
3
  export * from './definitions';
4
4
  export * from './css-properties';
5
+ export * from './pickers';
package/dist/sdk/index.js CHANGED
@@ -18,3 +18,4 @@ __exportStar(require("./data"), exports);
18
18
  __exportStar(require("./styles"), exports);
19
19
  __exportStar(require("./definitions"), exports);
20
20
  __exportStar(require("./css-properties"), exports);
21
+ __exportStar(require("./pickers"), exports);
@@ -0,0 +1,97 @@
1
+ import type { ElementLink } from './data';
2
+ /** Represents a font family and its weight. */
3
+ export interface IFontFamily {
4
+ /** The font family name. For example, 'Arial' or 'Helvetica Neue'. */
5
+ family: string;
6
+ /** The font weight. For example, '400' or 'bold'. */
7
+ weight: string;
8
+ }
9
+ /** Represents a font weight value. */
10
+ export interface IFontWeight {
11
+ /** The font weight. For example, '400' or 'bold'. */
12
+ weight: string;
13
+ }
14
+ /** Combination of font family and weight properties. */
15
+ export type IFontFamilyAndWeight = IFontFamily & IFontWeight;
16
+ export type ISelectLinkSharedOptions = {
17
+ /** Identifier for the origin of the link selection (used for BI tracking). */
18
+ origin?: string;
19
+ };
20
+ /** Options for positioning a picker panel relative to a target element. */
21
+ export type IPanelOptions = {
22
+ /** Where to place the picker panel relative to the target element. */
23
+ placement?: 'top' | 'bottom' | 'top-start' | 'bottom-start' | 'top-end' | 'bottom-end';
24
+ /** Vertical offset in pixels to shift the panel from its computed position. */
25
+ YShift?: number;
26
+ };
27
+ export type SelectFontParams = {
28
+ styleItemKey: string;
29
+ } | {
30
+ selectedFontFamily?: IFontFamilyAndWeight;
31
+ target?: HTMLElement;
32
+ panelOptions?: IPanelOptions;
33
+ onChange?: (value: IFontFamilyAndWeight) => void;
34
+ onPreview?: (value: IFontFamilyAndWeight) => void;
35
+ };
36
+ export type SelectFontFamilyParams = {
37
+ styleItemKey: string;
38
+ } | {
39
+ selectedFontFamily?: IFontFamily;
40
+ target?: HTMLElement;
41
+ panelOptions?: IPanelOptions;
42
+ onChange?: (value: IFontFamily) => void;
43
+ onPreview?: (value: IFontFamily) => void;
44
+ };
45
+ export type SelectFontWeightParams = {
46
+ fontFamilyStyleItemKey: string;
47
+ fontWeightStyleItemKey: string;
48
+ } | {
49
+ fontStyleItemKey: string;
50
+ } | {
51
+ fontFamily?: IFontFamily;
52
+ target?: HTMLElement;
53
+ onChange?: (value: IFontWeight) => void;
54
+ };
55
+ export type SelectMediaParams = {
56
+ dataItemKey: string;
57
+ } | {
58
+ isMultiSelect?: boolean;
59
+ category?: string;
60
+ };
61
+ export type SelectLinkParams = {
62
+ dataItemKey: string;
63
+ options?: ISelectLinkSharedOptions;
64
+ } | {
65
+ value?: ElementLink;
66
+ options?: ISelectLinkSharedOptions & {
67
+ linkTypes?: string[];
68
+ };
69
+ };
70
+ export type SelectColorParams = {
71
+ styleItemKey: string;
72
+ } | {
73
+ initialValue?: string;
74
+ mode?: ('solid' | 'gradient')[];
75
+ showBrand?: boolean;
76
+ showCustom?: boolean;
77
+ showAdvancedSettings?: boolean;
78
+ showOpacity?: boolean;
79
+ position?: {
80
+ x: number;
81
+ y: number;
82
+ };
83
+ biData?: {
84
+ origin: string;
85
+ };
86
+ onChange?: (color: string) => void;
87
+ onApply?: (color: string) => void;
88
+ onClose?: () => void;
89
+ onCancel?: () => void;
90
+ };
91
+ export type SelectTextThemeParams = {
92
+ target?: HTMLElement;
93
+ initialValue?: {
94
+ font?: string;
95
+ color?: string;
96
+ };
97
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/public-editor-platform-interfaces",
3
- "version": "1.38.0",
3
+ "version": "1.40.0",
4
4
  "license": "UNLICENSED",
5
5
  "contributors": [
6
6
  {
@@ -23,6 +23,7 @@
23
23
  "*.{js,ts}": "yarn lint"
24
24
  },
25
25
  "dependencies": {
26
+ "@wix/app-extensions": "^1.0.29",
26
27
  "@wix/sdk-types": "^1.14.0"
27
28
  },
28
29
  "devDependencies": {
@@ -51,5 +52,5 @@
51
52
  ]
52
53
  }
53
54
  },
54
- "falconPackageHash": "4844f880d36f8a57c20c081b07a678a6a6f957e5344d551778a412de"
55
+ "falconPackageHash": "a8c951ca90455f089a3982bab36d21f4e7525ffa07a5eb1201a8378e"
55
56
  }