@shopify/app-bridge-react 2.0.17 → 2.0.18
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.
- package/CHANGELOG.md +8 -0
- package/package.json +3 -3
- package/components/ClientRouter/ClientRouter.d.ts +0 -21
- package/components/ClientRouter/ClientRouter.js +0 -50
- package/components/ClientRouter/hook.d.ts +0 -10
- package/components/ClientRouter/hook.js +0 -20
- package/components/ClientRouter/index.d.ts +0 -3
- package/components/ClientRouter/index.js +0 -6
- package/components/ClientRouter/router.d.ts +0 -5
- package/components/ClientRouter/router.js +0 -11
- package/components/Loading/Loading.d.ts +0 -17
- package/components/Loading/Loading.js +0 -53
- package/components/Loading/index.d.ts +0 -2
- package/components/Loading/index.js +0 -7
- package/components/Modal/Modal.d.ts +0 -43
- package/components/Modal/Modal.js +0 -131
- package/components/Modal/ModalContent/ModalContent.d.ts +0 -22
- package/components/Modal/ModalContent/ModalContent.js +0 -59
- package/components/Modal/ModalContent/index.d.ts +0 -2
- package/components/Modal/ModalContent/index.js +0 -7
- package/components/Modal/index.d.ts +0 -4
- package/components/Modal/index.js +0 -9
- package/components/Provider/Provider.d.ts +0 -36
- package/components/Provider/Provider.js +0 -93
- package/components/Provider/index.d.ts +0 -3
- package/components/Provider/index.js +0 -7
- package/components/ResourcePicker/ResourcePicker.d.ts +0 -77
- package/components/ResourcePicker/ResourcePicker.js +0 -129
- package/components/ResourcePicker/index.d.ts +0 -3
- package/components/ResourcePicker/index.js +0 -7
- package/components/RoutePropagator/RoutePropagator.d.ts +0 -20
- package/components/RoutePropagator/RoutePropagator.js +0 -52
- package/components/RoutePropagator/globals.d.ts +0 -3
- package/components/RoutePropagator/globals.js +0 -15
- package/components/RoutePropagator/hook.d.ts +0 -10
- package/components/RoutePropagator/hook.js +0 -20
- package/components/RoutePropagator/index.d.ts +0 -3
- package/components/RoutePropagator/index.js +0 -6
- package/components/RoutePropagator/route-propagator.d.ts +0 -7
- package/components/RoutePropagator/route-propagator.js +0 -91
- package/components/TitleBar/TitleBar.d.ts +0 -38
- package/components/TitleBar/TitleBar.js +0 -78
- package/components/TitleBar/index.d.ts +0 -3
- package/components/TitleBar/index.js +0 -7
- package/components/Toast/Toast.d.ts +0 -31
- package/components/Toast/Toast.js +0 -57
- package/components/Toast/index.d.ts +0 -3
- package/components/Toast/index.js +0 -7
- package/components/index.d.ts +0 -8
- package/components/index.js +0 -27
- package/context.d.ts +0 -13
- package/context.js +0 -10
- package/index.d.ts +0 -3
- package/index.js +0 -17
- package/types.d.ts +0 -33
- package/types.js +0 -2
- package/umd/index.js +0 -14
- package/useAppBridge.d.ts +0 -1
- package/useAppBridge.js +0 -13
- package/utilities/transformers.d.ts +0 -19
- package/utilities/transformers.js +0 -86
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
18
|
-
}) : (function(o, m, k, k2) {
|
|
19
|
-
if (k2 === undefined) k2 = k;
|
|
20
|
-
o[k2] = m[k];
|
|
21
|
-
}));
|
|
22
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
-
}) : function(o, v) {
|
|
25
|
-
o["default"] = v;
|
|
26
|
-
});
|
|
27
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.setClientInterfaceHook = void 0;
|
|
39
|
-
var react_1 = __importDefault(require("react"));
|
|
40
|
-
var app_bridge_1 = __importStar(require("@shopify/app-bridge"));
|
|
41
|
-
var context_1 = require("../../context");
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
43
|
-
var packageJson = require('../../package.json');
|
|
44
|
-
/**
|
|
45
|
-
* Create an App Bridge client application from a config and pass it as the
|
|
46
|
-
* value to the context provider.
|
|
47
|
-
*
|
|
48
|
-
* @remarks
|
|
49
|
-
* You'll probably want something a little more robust than storing the current
|
|
50
|
-
* app instance in a module-level global.
|
|
51
|
-
*
|
|
52
|
-
* @public
|
|
53
|
-
*/
|
|
54
|
-
var Provider = /** @class */ (function (_super) {
|
|
55
|
-
__extends(Provider, _super);
|
|
56
|
-
function Provider() {
|
|
57
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
58
|
-
_this.app = _this.appInstance;
|
|
59
|
-
return _this;
|
|
60
|
-
}
|
|
61
|
-
Object.defineProperty(Provider.prototype, "appInstance", {
|
|
62
|
-
get: function () {
|
|
63
|
-
if (!this.app) {
|
|
64
|
-
this.app = app_bridge_1.default(this.props.config);
|
|
65
|
-
if (this.app && this.app.hooks) {
|
|
66
|
-
this.app.hooks.set(app_bridge_1.LifecycleHook.DispatchAction, exports.setClientInterfaceHook);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return this.app;
|
|
70
|
-
},
|
|
71
|
-
enumerable: false,
|
|
72
|
-
configurable: true
|
|
73
|
-
});
|
|
74
|
-
Provider.prototype.render = function () {
|
|
75
|
-
return (react_1.default.createElement(context_1.AppBridgeContext.Provider, { value: this.appInstance }, this.props.children));
|
|
76
|
-
};
|
|
77
|
-
return Provider;
|
|
78
|
-
}(react_1.default.Component));
|
|
79
|
-
exports.default = Provider;
|
|
80
|
-
/**
|
|
81
|
-
* Augment actions with clientInterface metadata, identifying use of this library
|
|
82
|
-
*
|
|
83
|
-
* @internal
|
|
84
|
-
*/
|
|
85
|
-
exports.setClientInterfaceHook = function (next) {
|
|
86
|
-
return function (action) {
|
|
87
|
-
action.clientInterface = {
|
|
88
|
-
name: '@shopify/app-bridge-react',
|
|
89
|
-
version: packageJson.version,
|
|
90
|
-
};
|
|
91
|
-
return next(action);
|
|
92
|
-
};
|
|
93
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var Provider_1 = __importDefault(require("./Provider"));
|
|
7
|
-
exports.default = Provider_1.default;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ResourcePicker as AppBridgeResourcePicker } from '@shopify/app-bridge/actions';
|
|
3
|
-
import { BaseResource } from '@shopify/app-bridge/actions/ResourcePicker';
|
|
4
|
-
export interface SelectPayload {
|
|
5
|
-
/** The selected resources
|
|
6
|
-
* @see {@link https://help.shopify.com/en/api/embedded-apps/app-bridge/actions/resourcepicker|resource picker documentation} for more information
|
|
7
|
-
*/
|
|
8
|
-
selection: AppBridgeResourcePicker.ResourceSelection[];
|
|
9
|
-
}
|
|
10
|
-
interface BaseProps {
|
|
11
|
-
/** Whether the picker is open or not */
|
|
12
|
-
open: boolean;
|
|
13
|
-
/** GraphQL initial search query for filtering resources available in the picker
|
|
14
|
-
* @see {@link https://help.shopify.com/en/api/getting-started/search-syntax|search syntax} for more information
|
|
15
|
-
*/
|
|
16
|
-
initialQuery?: string;
|
|
17
|
-
/** Resources that should already be selected when the picker is opened */
|
|
18
|
-
initialSelectionIds?: BaseResource[];
|
|
19
|
-
/** Show products that are not published on the Online Store */
|
|
20
|
-
showHidden?: boolean;
|
|
21
|
-
/**
|
|
22
|
-
* @deprecated as of 1.28.0
|
|
23
|
-
*/
|
|
24
|
-
/** Whether to allow selection of multiple items */
|
|
25
|
-
allowMultiple?: boolean;
|
|
26
|
-
/** Whether to allow selection of multiple items, or the maximum number of selected items */
|
|
27
|
-
selectMultiple?: boolean | number;
|
|
28
|
-
/** Override default action verb `Add`. The actionVerb appears in the title `<actionVerb>` `<resourceType>` and as the primary action of the resource picker. */
|
|
29
|
-
actionVerb?: AppBridgeResourcePicker.ActionVerb;
|
|
30
|
-
/** Callback when a selection has been made */
|
|
31
|
-
onSelection?(selectPayload: SelectPayload): void;
|
|
32
|
-
/** Callback when the picker is closed without selection */
|
|
33
|
-
onCancel?(): void;
|
|
34
|
-
}
|
|
35
|
-
export interface ProductPickerProps extends BaseProps {
|
|
36
|
-
/** The type of resource you want to pick */
|
|
37
|
-
resourceType: 'Product';
|
|
38
|
-
/** Whether to show product variants or not. Only applies to the product resource type picker */
|
|
39
|
-
showVariants?: boolean;
|
|
40
|
-
/** Whether to show draft products or not. Only applies to the product resource type picker */
|
|
41
|
-
showDraft?: boolean;
|
|
42
|
-
/** Whether to show archived products or not. Only applies to the product resource type picker */
|
|
43
|
-
showArchived?: boolean;
|
|
44
|
-
/** Whether to show draft badge for draft products or not. Only works when `showDraft` prop is set, and only applies to the product resource type picker */
|
|
45
|
-
showDraftBadge?: boolean;
|
|
46
|
-
/** Whether to show archived badge for archived products or not. Only works when `showArchived` prop is set, and only applies to the product resource type picker */
|
|
47
|
-
showArchivedBadge?: boolean;
|
|
48
|
-
}
|
|
49
|
-
export interface ProductVariantProps extends BaseProps {
|
|
50
|
-
/** The type of resource you want to pick */
|
|
51
|
-
resourceType: 'ProductVariant';
|
|
52
|
-
}
|
|
53
|
-
export interface CollectionPickerProps extends BaseProps {
|
|
54
|
-
/** The type of resource you want to pick */
|
|
55
|
-
resourceType: 'Collection';
|
|
56
|
-
}
|
|
57
|
-
export declare type Props = ProductPickerProps | ProductVariantProps | CollectionPickerProps;
|
|
58
|
-
/**
|
|
59
|
-
* ResourcePicker component
|
|
60
|
-
*
|
|
61
|
-
* @remarks
|
|
62
|
-
* React component which wraps the Shopify App Bridge ResourcePicker action.
|
|
63
|
-
*
|
|
64
|
-
* @public
|
|
65
|
-
*/
|
|
66
|
-
declare class ResourcePicker extends React.PureComponent<Props, never> {
|
|
67
|
-
static contextType: React.Context<import("../../context").IAppBridgeContext>;
|
|
68
|
-
static ActionVerb: typeof AppBridgeResourcePicker.ActionVerb;
|
|
69
|
-
private focusReturnPoint;
|
|
70
|
-
private picker;
|
|
71
|
-
componentDidMount(): void;
|
|
72
|
-
componentDidUpdate(prevProps: Props): void;
|
|
73
|
-
componentWillUnmount(): void;
|
|
74
|
-
render(): null;
|
|
75
|
-
getActionOptions(): AppBridgeResourcePicker.Options | AppBridgeResourcePicker.ProductOptions;
|
|
76
|
-
}
|
|
77
|
-
export default ResourcePicker;
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
var __assign = (this && this.__assign) || function () {
|
|
16
|
-
__assign = Object.assign || function(t) {
|
|
17
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
18
|
-
s = arguments[i];
|
|
19
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
20
|
-
t[p] = s[p];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
|
-
return __assign.apply(this, arguments);
|
|
25
|
-
};
|
|
26
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
27
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
28
|
-
};
|
|
29
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
-
var react_1 = __importDefault(require("react"));
|
|
31
|
-
var actions_1 = require("@shopify/app-bridge/actions");
|
|
32
|
-
var context_1 = require("../../context");
|
|
33
|
-
/**
|
|
34
|
-
* ResourcePicker component
|
|
35
|
-
*
|
|
36
|
-
* @remarks
|
|
37
|
-
* React component which wraps the Shopify App Bridge ResourcePicker action.
|
|
38
|
-
*
|
|
39
|
-
* @public
|
|
40
|
-
*/
|
|
41
|
-
var ResourcePicker = /** @class */ (function (_super) {
|
|
42
|
-
__extends(ResourcePicker, _super);
|
|
43
|
-
function ResourcePicker() {
|
|
44
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
45
|
-
_this.focusReturnPoint = null;
|
|
46
|
-
return _this;
|
|
47
|
-
}
|
|
48
|
-
ResourcePicker.prototype.componentDidMount = function () {
|
|
49
|
-
var _a = this.props, open = _a.open, resourceType = _a.resourceType, onSelection = _a.onSelection, onCancel = _a.onCancel;
|
|
50
|
-
var app = this.context;
|
|
51
|
-
this.picker = actions_1.ResourcePicker.create(app, {
|
|
52
|
-
resourceType: actions_1.ResourcePicker.ResourceType[resourceType],
|
|
53
|
-
options: this.getActionOptions(),
|
|
54
|
-
});
|
|
55
|
-
if (onSelection != null) {
|
|
56
|
-
this.picker.subscribe(actions_1.ResourcePicker.Action.SELECT, onSelection);
|
|
57
|
-
}
|
|
58
|
-
if (onCancel != null) {
|
|
59
|
-
this.picker.subscribe(actions_1.ResourcePicker.Action.CANCEL, onCancel);
|
|
60
|
-
}
|
|
61
|
-
if (open) {
|
|
62
|
-
this.focusReturnPoint = document.activeElement;
|
|
63
|
-
this.picker.dispatch(actions_1.ResourcePicker.Action.OPEN);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
ResourcePicker.prototype.componentDidUpdate = function (prevProps) {
|
|
67
|
-
var wasOpen = prevProps.open;
|
|
68
|
-
var _a = this.props, open = _a.open, onCancel = _a.onCancel, onSelection = _a.onSelection;
|
|
69
|
-
this.picker.unsubscribe();
|
|
70
|
-
this.picker.set(this.getActionOptions());
|
|
71
|
-
if (onSelection != null) {
|
|
72
|
-
this.picker.subscribe(actions_1.ResourcePicker.Action.SELECT, onSelection);
|
|
73
|
-
}
|
|
74
|
-
if (onCancel != null) {
|
|
75
|
-
this.picker.subscribe(actions_1.ResourcePicker.Action.CANCEL, onCancel);
|
|
76
|
-
}
|
|
77
|
-
if (wasOpen !== open) {
|
|
78
|
-
if (open) {
|
|
79
|
-
this.picker.dispatch(actions_1.ResourcePicker.Action.OPEN);
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
this.picker.dispatch(actions_1.ResourcePicker.Action.CLOSE);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
if (!wasOpen && open) {
|
|
86
|
-
this.focusReturnPoint = document.activeElement;
|
|
87
|
-
}
|
|
88
|
-
else if (wasOpen &&
|
|
89
|
-
!open &&
|
|
90
|
-
this.focusReturnPoint != null &&
|
|
91
|
-
document.contains(this.focusReturnPoint)) {
|
|
92
|
-
this.focusReturnPoint.focus();
|
|
93
|
-
this.focusReturnPoint = null;
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
ResourcePicker.prototype.componentWillUnmount = function () {
|
|
97
|
-
this.picker.unsubscribe();
|
|
98
|
-
};
|
|
99
|
-
ResourcePicker.prototype.render = function () {
|
|
100
|
-
return null;
|
|
101
|
-
};
|
|
102
|
-
ResourcePicker.prototype.getActionOptions = function () {
|
|
103
|
-
var _a = this.props, initialQuery = _a.initialQuery, initialSelectionIds = _a.initialSelectionIds, showHidden = _a.showHidden, allowMultiple = _a.allowMultiple, selectMultiple = _a.selectMultiple, actionVerb = _a.actionVerb;
|
|
104
|
-
var sharedOptions = {
|
|
105
|
-
initialQuery: initialQuery,
|
|
106
|
-
initialSelectionIds: initialSelectionIds,
|
|
107
|
-
showHidden: showHidden,
|
|
108
|
-
selectMultiple: selectMultiple !== null && selectMultiple !== void 0 ? selectMultiple : allowMultiple,
|
|
109
|
-
actionVerb: actionVerb,
|
|
110
|
-
};
|
|
111
|
-
var result = sharedOptions;
|
|
112
|
-
if (this.props.resourceType === 'Product') {
|
|
113
|
-
var _b = this.props, showVariants = _b.showVariants, showDraft = _b.showDraft, showArchived = _b.showArchived, showDraftBadge = _b.showDraftBadge, showArchivedBadge = _b.showArchivedBadge;
|
|
114
|
-
var productSpecificOptions = {
|
|
115
|
-
showVariants: showVariants,
|
|
116
|
-
showDraft: showDraft,
|
|
117
|
-
showArchived: showArchived,
|
|
118
|
-
showDraftBadge: showDraftBadge,
|
|
119
|
-
showArchivedBadge: showArchivedBadge,
|
|
120
|
-
};
|
|
121
|
-
result = __assign(__assign({}, sharedOptions), productSpecificOptions);
|
|
122
|
-
}
|
|
123
|
-
return result;
|
|
124
|
-
};
|
|
125
|
-
ResourcePicker.contextType = context_1.AppBridgeContext;
|
|
126
|
-
ResourcePicker.ActionVerb = actions_1.ResourcePicker.ActionVerb;
|
|
127
|
-
return ResourcePicker;
|
|
128
|
-
}(react_1.default.PureComponent));
|
|
129
|
-
exports.default = ResourcePicker;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var ResourcePicker_1 = __importDefault(require("./ResourcePicker"));
|
|
7
|
-
exports.default = ResourcePicker_1.default;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { LocationOrHref } from './route-propagator';
|
|
3
|
-
export interface Props {
|
|
4
|
-
location: LocationOrHref;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* RoutePropagator component
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* React component which keeps the Shopify admin url in sync with the app url
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
declare class RoutePropagator extends React.Component<Props, never> {
|
|
15
|
-
static contextType: React.Context<import("../../context").IAppBridgeContext>;
|
|
16
|
-
componentDidMount(): void;
|
|
17
|
-
componentDidUpdate({ location: prevLocation }: Props): void;
|
|
18
|
-
render(): null;
|
|
19
|
-
}
|
|
20
|
-
export default RoutePropagator;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
extendStatics(d, b);
|
|
11
|
-
function __() { this.constructor = d; }
|
|
12
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
16
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
17
|
-
};
|
|
18
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
var react_1 = __importDefault(require("react"));
|
|
20
|
-
var context_1 = require("../../context");
|
|
21
|
-
var route_propagator_1 = require("./route-propagator");
|
|
22
|
-
/**
|
|
23
|
-
* RoutePropagator component
|
|
24
|
-
*
|
|
25
|
-
* @remarks
|
|
26
|
-
* React component which keeps the Shopify admin url in sync with the app url
|
|
27
|
-
*
|
|
28
|
-
* @public
|
|
29
|
-
*/
|
|
30
|
-
var RoutePropagator = /** @class */ (function (_super) {
|
|
31
|
-
__extends(RoutePropagator, _super);
|
|
32
|
-
function RoutePropagator() {
|
|
33
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
34
|
-
}
|
|
35
|
-
RoutePropagator.prototype.componentDidMount = function () {
|
|
36
|
-
var location = this.props.location;
|
|
37
|
-
route_propagator_1.updateHistory(this.context, location);
|
|
38
|
-
};
|
|
39
|
-
RoutePropagator.prototype.componentDidUpdate = function (_a) {
|
|
40
|
-
var prevLocation = _a.location;
|
|
41
|
-
var location = this.props.location;
|
|
42
|
-
if (location !== prevLocation) {
|
|
43
|
-
route_propagator_1.updateHistory(this.context, location);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
RoutePropagator.prototype.render = function () {
|
|
47
|
-
return null;
|
|
48
|
-
};
|
|
49
|
-
RoutePropagator.contextType = context_1.AppBridgeContext;
|
|
50
|
-
return RoutePropagator;
|
|
51
|
-
}(react_1.default.Component));
|
|
52
|
-
exports.default = RoutePropagator;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOrigin = exports.getTopWindow = exports.getSelfWindow = void 0;
|
|
4
|
-
function getSelfWindow() {
|
|
5
|
-
return window.self;
|
|
6
|
-
}
|
|
7
|
-
exports.getSelfWindow = getSelfWindow;
|
|
8
|
-
function getTopWindow() {
|
|
9
|
-
return window.top;
|
|
10
|
-
}
|
|
11
|
-
exports.getTopWindow = getTopWindow;
|
|
12
|
-
function getOrigin() {
|
|
13
|
-
return location.origin;
|
|
14
|
-
}
|
|
15
|
-
exports.getOrigin = getOrigin;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { LocationOrHref } from './route-propagator';
|
|
2
|
-
/**
|
|
3
|
-
* useRoutePropagation
|
|
4
|
-
*
|
|
5
|
-
* @remarks
|
|
6
|
-
* A hook which keeps the Shopify admin url in sync with the app url
|
|
7
|
-
*
|
|
8
|
-
* @public
|
|
9
|
-
*/
|
|
10
|
-
export default function useRoutePropagation(location: LocationOrHref): void;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var react_1 = require("react");
|
|
4
|
-
var useAppBridge_1 = require("../../useAppBridge");
|
|
5
|
-
var route_propagator_1 = require("./route-propagator");
|
|
6
|
-
/**
|
|
7
|
-
* useRoutePropagation
|
|
8
|
-
*
|
|
9
|
-
* @remarks
|
|
10
|
-
* A hook which keeps the Shopify admin url in sync with the app url
|
|
11
|
-
*
|
|
12
|
-
* @public
|
|
13
|
-
*/
|
|
14
|
-
function useRoutePropagation(location) {
|
|
15
|
-
var app = useAppBridge_1.useAppBridge();
|
|
16
|
-
react_1.useEffect(function () {
|
|
17
|
-
route_propagator_1.updateHistory(app, location);
|
|
18
|
-
}, [app, location]);
|
|
19
|
-
}
|
|
20
|
-
exports.default = useRoutePropagation;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var RoutePropagator_1 = require("./RoutePropagator");
|
|
4
|
-
Object.defineProperty(exports, "RoutePropagator", { enumerable: true, get: function () { return RoutePropagator_1.default; } });
|
|
5
|
-
var hook_1 = require("./hook");
|
|
6
|
-
Object.defineProperty(exports, "useRoutePropagation", { enumerable: true, get: function () { return hook_1.default; } });
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ClientApplication } from '@shopify/app-bridge';
|
|
2
|
-
export declare type LocationOrHref = string | {
|
|
3
|
-
search: string;
|
|
4
|
-
hash: string;
|
|
5
|
-
pathname: string;
|
|
6
|
-
};
|
|
7
|
-
export declare function updateHistory(app: ClientApplication<any>, location: LocationOrHref): Promise<void>;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.updateHistory = void 0;
|
|
40
|
-
var MessageTransport_1 = require("@shopify/app-bridge/MessageTransport");
|
|
41
|
-
var actions_1 = require("@shopify/app-bridge/actions");
|
|
42
|
-
var globals_1 = require("./globals");
|
|
43
|
-
// These parameters are added to the iframe url but we don't want to propagate
|
|
44
|
-
// them up to the address bar as they are not provided by the application
|
|
45
|
-
// Removing hmac is especially important as its presence may cause infinite
|
|
46
|
-
// oauth authentication loops
|
|
47
|
-
var embeddedFrameParamsToRemove = [
|
|
48
|
-
'hmac',
|
|
49
|
-
'locale',
|
|
50
|
-
'protocol',
|
|
51
|
-
'session',
|
|
52
|
-
'shop',
|
|
53
|
-
'timestamp',
|
|
54
|
-
'host',
|
|
55
|
-
];
|
|
56
|
-
function updateHistory(app, location) {
|
|
57
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
-
var selfWindow, topWindow, renderedInTheTopWindow, renderedAsMainApp, normalizedLocation, pathname, search, hash, locationStr;
|
|
59
|
-
return __generator(this, function (_a) {
|
|
60
|
-
switch (_a.label) {
|
|
61
|
-
case 0:
|
|
62
|
-
selfWindow = globals_1.getSelfWindow();
|
|
63
|
-
topWindow = globals_1.getTopWindow();
|
|
64
|
-
renderedInTheTopWindow = selfWindow === topWindow;
|
|
65
|
-
return [4 /*yield*/, app.getState('context').then(function (context) {
|
|
66
|
-
return context === MessageTransport_1.Context.Main;
|
|
67
|
-
})];
|
|
68
|
-
case 1:
|
|
69
|
-
renderedAsMainApp = _a.sent();
|
|
70
|
-
if (renderedInTheTopWindow || !renderedAsMainApp) {
|
|
71
|
-
return [2 /*return*/];
|
|
72
|
-
}
|
|
73
|
-
normalizedLocation = getNormalizedURL(location);
|
|
74
|
-
embeddedFrameParamsToRemove.forEach(function (param) { return normalizedLocation.searchParams.delete(param); });
|
|
75
|
-
pathname = normalizedLocation.pathname, search = normalizedLocation.search, hash = normalizedLocation.hash;
|
|
76
|
-
locationStr = "" + pathname + search + hash;
|
|
77
|
-
actions_1.History.create(app).dispatch(actions_1.History.Action.REPLACE, locationStr);
|
|
78
|
-
return [2 /*return*/];
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
exports.updateHistory = updateHistory;
|
|
84
|
-
function getNormalizedURL(location) {
|
|
85
|
-
var origin = globals_1.getOrigin();
|
|
86
|
-
if (typeof location === 'string') {
|
|
87
|
-
return new URL(location, origin);
|
|
88
|
-
}
|
|
89
|
-
var pathname = location.pathname, search = location.search, hash = location.hash;
|
|
90
|
-
return new URL("" + pathname + search + hash, origin);
|
|
91
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ActionProps, ActionGroupProps, Target } from '../../types';
|
|
3
|
-
export interface Breadcrumb {
|
|
4
|
-
/** Content the action displays */
|
|
5
|
-
content?: string;
|
|
6
|
-
/** A destination to link to */
|
|
7
|
-
url?: string;
|
|
8
|
-
/**
|
|
9
|
-
* Where to display the target link
|
|
10
|
-
* @default 'APP'
|
|
11
|
-
*/
|
|
12
|
-
target?: Target;
|
|
13
|
-
/** Callback when an action takes place */
|
|
14
|
-
onAction?(): void;
|
|
15
|
-
}
|
|
16
|
-
export interface Props {
|
|
17
|
-
/** TitleBar title */
|
|
18
|
-
title: string;
|
|
19
|
-
/** Collection of breadcrumbs */
|
|
20
|
-
breadcrumbs?: Breadcrumb[];
|
|
21
|
-
/** Primary TitleBar action */
|
|
22
|
-
primaryAction?: ActionProps;
|
|
23
|
-
/** Collection of secondary TitleBar actions */
|
|
24
|
-
secondaryActions?: ActionProps[];
|
|
25
|
-
/** Collection of TitleBar groups of secondary actions */
|
|
26
|
-
actionGroups?: ActionGroupProps[];
|
|
27
|
-
}
|
|
28
|
-
declare class TitleBar extends React.PureComponent<Props, never> {
|
|
29
|
-
static contextType: React.Context<import("../../context").IAppBridgeContext>;
|
|
30
|
-
private titleBar;
|
|
31
|
-
componentDidMount(): void;
|
|
32
|
-
componentDidUpdate(): void;
|
|
33
|
-
componentWillUnmount(): void;
|
|
34
|
-
render(): null;
|
|
35
|
-
private transformProps;
|
|
36
|
-
private transformBreadcrumbs;
|
|
37
|
-
}
|
|
38
|
-
export default TitleBar;
|