@builder.io/commerce-plugin-tools
Advanced tools
Comparing version 0.2.3-5 to 0.2.3
@@ -97,14 +97,17 @@ "use strict"; | ||
var _a; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
var _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: | ||
modelUrl = (_a = app_context_1.default.designerState.editingModel) === null || _a === void 0 ? void 0 : _a.examplePageUrl; | ||
modelUrl = (_b = app_context_1.default.designerState.editingModel) === null || _b === void 0 ? void 0 : _b.examplePageUrl; | ||
if (!(resourcePromise && modelUrl)) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, resourcePromise]; | ||
case 1: | ||
previewResource = _b.sent(); | ||
previewResource = _c.sent(); | ||
compiled = template_1.default(modelUrl); | ||
previewUrl = compiled(withDefaults({ | ||
previewResource: previewResource, | ||
})); | ||
previewUrl = compiled(withDefaults((_a = { | ||
previewResource: previewResource | ||
}, | ||
_a["preview" + capitalize_1.default(resourceName)] = previewResource, | ||
_a))); | ||
if (modelUrl !== previewUrl) { | ||
@@ -114,3 +117,3 @@ updatePreviewUrl(previewUrl); | ||
} | ||
_b.label = 2; | ||
_c.label = 2; | ||
case 2: return [2 /*return*/]; | ||
@@ -117,0 +120,0 @@ } |
@@ -155,5 +155,3 @@ "use strict"; | ||
core_1.jsx(core_2.Button, { color: "primary", variant: "outlined", fullWidth: true, css: { marginTop: 10 }, onClick: function () { | ||
var value = props.value, resourcePicker = props.resourcePicker, rest = __rest(props, ["value", "resourcePicker"]); | ||
var PickerCompnent = resourcePicker || ResourcesPicker_1.ResourcePicker; | ||
var close = app_context_1.default.globalState.openDialog(core_1.jsx(PickerCompnent, __assign({}, rest, { context: app_context_1.default, omitIds: store.value, onChange: mobx_1.action(function (resource) { | ||
var close = app_context_1.default.globalState.openDialog(core_1.jsx(ResourcesPicker_1.ResourcePicker, { resourceName: props.resourceName, api: props.api, context: app_context_1.default, omitIds: store.value, onChange: mobx_1.action(function (resource) { | ||
if (resource) { | ||
@@ -163,3 +161,3 @@ props.onChange(__spreadArrays((store.value || []), [String(resource.id)])); | ||
close(); | ||
}) }))); | ||
}) })); | ||
} }, | ||
@@ -166,0 +164,0 @@ "+ ", |
@@ -49,13 +49,2 @@ "use strict"; | ||
}; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
var t = {}; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) | ||
t[p] = s[p]; | ||
if (s != null && typeof Object.getOwnPropertySymbols === "function") | ||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { | ||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) | ||
t[p[i]] = s[p[i]]; | ||
} | ||
return t; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -205,37 +194,34 @@ /** @jsx jsx */ | ||
return __awaiter(this, void 0, void 0, function () { | ||
var value, resourcePicker, rest, PickerCompnent, close; | ||
var close; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
value = props.value, resourcePicker = props.resourcePicker, rest = __rest(props, ["value", "resourcePicker"]); | ||
PickerCompnent = resourcePicker || exports.ResourcePicker; | ||
return [4 /*yield*/, props.context.globalState.openDialog(core_1.jsx(PickerCompnent, __assign({}, rest, { resourceName: props.resourceName }, (this.resourceInfo && { value: this.resourceInfo }), { title: title, onChange: mobx_1.action(function (value) { | ||
var _a; | ||
if (value) { | ||
_this.resourceHandle = value.handle; | ||
_this.resourceId = String(value.id); | ||
_this.getResource(); | ||
if (props.handleOnly) { | ||
props.onChange(_this.resourceHandle); | ||
case 0: return [4 /*yield*/, props.context.globalState.openDialog(core_1.jsx(exports.ResourcePicker, __assign({ resourceName: props.resourceName, api: props.api, context: props.context }, (this.resourceInfo && { value: this.resourceInfo }), { title: title, onChange: mobx_1.action(function (value) { | ||
var _a; | ||
if (value) { | ||
_this.resourceHandle = value.handle; | ||
_this.resourceId = String(value.id); | ||
_this.getResource(); | ||
if (props.handleOnly) { | ||
props.onChange(_this.resourceHandle); | ||
} | ||
else { | ||
if ((_a = props.field) === null || _a === void 0 ? void 0 : _a.isTargeting) { | ||
props.onChange(_this.resourceId); | ||
} | ||
else { | ||
if ((_a = props.field) === null || _a === void 0 ? void 0 : _a.isTargeting) { | ||
props.onChange(_this.resourceId); | ||
} | ||
else { | ||
props.onChange(props.api[props.resourceName].getRequestObject(_this.resourceId, value)); | ||
} | ||
props.onChange(props.api[props.resourceName].getRequestObject(_this.resourceId, value)); | ||
} | ||
} | ||
close(); | ||
}) })), true, { | ||
PaperProps: { | ||
// Align modal to top so doesn't jump around centering itself when | ||
// grows and shrinks to show more/less resources or loading | ||
style: { | ||
alignSelf: 'flex-start', | ||
}, | ||
} | ||
close(); | ||
}) })), true, { | ||
PaperProps: { | ||
// Align modal to top so doesn't jump around centering itself when | ||
// grows and shrinks to show more/less resources or loading | ||
style: { | ||
alignSelf: 'flex-start', | ||
}, | ||
})]; | ||
}, | ||
})]; | ||
case 1: | ||
@@ -242,0 +228,0 @@ close = _a.sent(); |
@@ -80,3 +80,2 @@ "use strict"; | ||
react_1.Builder.register('editor.onLoad', on_editor_load_1.onEditorLoad(config, apiOperations, resourceName)); | ||
var resourcePicker = apiOperations[resourceName].resourcePicker; | ||
react_1.Builder.registerEditor({ | ||
@@ -87,11 +86,9 @@ name: "" + config.name + capitalize_1.default(resourceName), | ||
component: function (props) { return (react_2.default.createElement(error_boundary_1.ErrorBoundary, null, | ||
react_2.default.createElement(ResourcesPicker_1.ResourcesPickerButton, __assign({ resourcePicker: resourcePicker }, props, contextProps)))); }, | ||
react_2.default.createElement(ResourcesPicker_1.ResourcesPickerButton, __assign({}, props, contextProps)))); }, | ||
}); | ||
if (!config.noPreviewTypes) { | ||
react_1.Builder.registerEditor({ | ||
name: "" + config.name + capitalize_1.default(resourceName) + "Preview", | ||
component: function (props) { return (react_2.default.createElement(error_boundary_1.ErrorBoundary, null, | ||
react_2.default.createElement(ResourcesPicker_1.ResourcesPickerButton, __assign({ resourcePicker: resourcePicker }, props, contextProps, { previewType: "" + config.name + capitalize_1.default(resourceName) + "Preview", isPreview: true })))); }, | ||
}); | ||
} | ||
react_1.Builder.registerEditor({ | ||
name: "" + config.name + capitalize_1.default(resourceName) + "Preview", | ||
component: function (props) { return (react_2.default.createElement(error_boundary_1.ErrorBoundary, null, | ||
react_2.default.createElement(ResourcesPicker_1.ResourcesPickerButton, __assign({}, props, contextProps, { previewType: "" + config.name + capitalize_1.default(resourceName) + "Preview", isPreview: true })))); }, | ||
}); | ||
if (apiOperations[resourceName].findByHandle) { | ||
@@ -101,3 +98,3 @@ react_1.Builder.registerEditor({ | ||
component: function (props) { return (react_2.default.createElement(error_boundary_1.ErrorBoundary, null, | ||
react_2.default.createElement(ResourcesPicker_1.ResourcesPickerButton, __assign({ resourcePicker: resourcePicker }, props, contextProps, { handleOnly: true })))); }, | ||
react_2.default.createElement(ResourcesPicker_1.ResourcesPickerButton, __assign({}, props, contextProps, { handleOnly: true })))); }, | ||
}); | ||
@@ -108,3 +105,3 @@ } | ||
component: function (props) { return (react_2.default.createElement(error_boundary_1.ErrorBoundary, null, | ||
react_2.default.createElement(ResourcesList_1.PickResourcesListButton, __assign({ resourcePicker: resourcePicker }, props, contextProps)))); }, | ||
react_2.default.createElement(ResourcesList_1.PickResourcesListButton, __assign({}, props, contextProps)))); }, | ||
}); | ||
@@ -166,4 +163,2 @@ }); | ||
}); }; | ||
var ResourcesPicker_2 = require("./editors/ResourcesPicker"); | ||
exports.ResourcePreviewCell = ResourcesPicker_2.ResourcePreviewCell; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,2 @@ | ||
import React from 'react'; | ||
import { ResourcePickerProps } from './ResourcesPicker'; | ||
/// <reference types="react" /> | ||
import { CommerceAPIOperations } from '..'; | ||
@@ -8,3 +7,2 @@ export declare type PickResourceListProps = { | ||
onChange(newValue: string[]): void; | ||
resourcePicker?: React.FC<ResourcePickerProps>; | ||
onDone(): void; | ||
@@ -11,0 +9,0 @@ resourceName: string; |
@@ -10,3 +10,2 @@ import React from 'react'; | ||
api: CommerceAPIOperations; | ||
resourcePicker?: React.FC<ResourcePickerProps>; | ||
pluginId: string; | ||
@@ -24,3 +23,3 @@ pluginName: string; | ||
export declare const ResourcePreviewCell: React.FC<ResourcePreviewCellProps>; | ||
export declare type ResourcePickerProps = CustomReactEditorProps<Resource> & { | ||
export declare const ResourcePicker: React.FC<CustomReactEditorProps<Resource> & { | ||
api: CommerceAPIOperations; | ||
@@ -30,4 +29,3 @@ omitIds?: string[]; | ||
title?: string; | ||
}; | ||
export declare const ResourcePicker: React.FC<ResourcePickerProps>; | ||
}>; | ||
export declare const ResourcesPickerButton: React.FC<ResourcesPickerButtonProps>; |
@@ -1,3 +0,1 @@ | ||
import { ResourcePickerProps } from './editors/ResourcesPicker'; | ||
import React from 'react'; | ||
import { Resource } from './interfaces/resource'; | ||
@@ -20,10 +18,8 @@ import { BuilderRequest } from './interfaces/builder-request'; | ||
onSave?: (actions: OnSaveActions) => Promise<void>; | ||
noPreviewTypes?: boolean; | ||
} | ||
export interface CommerceAPIOperations { | ||
[resourceName: string]: { | ||
resourcePicker?: React.FC<ResourcePickerProps>; | ||
findById(id: string): Promise<Resource>; | ||
findByHandle?(handle: string): Promise<Resource>; | ||
search(search: string, offset?: number, limit?: number): Promise<Resource[]>; | ||
search(search: string): Promise<Resource[]>; | ||
getRequestObject(id: string, resource?: Resource): BuilderRequest; | ||
@@ -33,4 +29,2 @@ }; | ||
export declare const registerCommercePlugin: (config: CommercePluginConfig, apiOperationsFromSettings: (settings: any) => CommerceAPIOperations | Promise<CommerceAPIOperations>) => Promise<void>; | ||
export { Resource } from './interfaces/resource'; | ||
export { BuilderRequest } from './interfaces/builder-request'; | ||
export { ResourcePreviewCell, ResourcePickerProps, ResourcePreviewCellProps } from './editors/ResourcesPicker'; | ||
export {}; |
{ | ||
"name": "@builder.io/commerce-plugin-tools", | ||
"version": "0.2.3-5", | ||
"version": "0.2.3", | ||
"description": "", | ||
@@ -111,3 +111,3 @@ "keywords": [], | ||
"rollup-plugin-sourcemaps": "^0.4.2", | ||
"rollup-plugin-typescript2": "^0.31.2", | ||
"rollup-plugin-typescript2": "^0.30.0", | ||
"semantic-release": "^17.2.3", | ||
@@ -125,3 +125,3 @@ "shelljs": "^0.8.3", | ||
"dependencies": { | ||
"@builder.io/sdk": "^1.1.3-alpha.4", | ||
"@builder.io/sdk": "^1.1.26", | ||
"@emotion/core": "^10.0.22", | ||
@@ -128,0 +128,0 @@ "@emotion/styled": "^10.0.23", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9555085
68834
Updated@builder.io/sdk@^1.1.26