@shopify/app-bridge-react 2.0.19 → 2.0.22
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 +28 -0
- package/components/ClientRouter/ClientRouter.js +4 -2
- package/components/ClientRouter/hook.js +3 -3
- package/components/ClientRouter/index.js +6 -2
- package/components/ClientRouter/router.d.ts +1 -1
- package/components/ContextualSaveBar/ContextualSaveBar.d.ts +13 -0
- package/components/ContextualSaveBar/ContextualSaveBar.js +64 -0
- package/components/ContextualSaveBar/index.d.ts +3 -0
- package/components/ContextualSaveBar/index.js +7 -0
- package/components/Loading/Loading.js +3 -1
- package/components/Modal/Modal.js +5 -4
- package/components/Modal/ModalContent/ModalContent.js +3 -1
- package/components/Modal/index.js +2 -1
- package/components/Provider/Provider.js +12 -5
- package/components/ResourcePicker/ResourcePicker.js +3 -1
- package/components/RoutePropagator/RoutePropagator.js +5 -3
- package/components/RoutePropagator/globals.d.ts +1 -1
- package/components/RoutePropagator/hook.js +3 -3
- package/components/RoutePropagator/index.js +6 -2
- package/components/RoutePropagator/route-propagator.d.ts +1 -1
- package/components/RoutePropagator/route-propagator.js +5 -5
- package/components/TitleBar/TitleBar.js +5 -3
- package/components/Toast/Toast.js +3 -1
- package/components/index.d.ts +1 -0
- package/components/index.js +18 -8
- package/context.d.ts +1 -1
- package/context.js +1 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +3 -0
- package/hooks/useContextualSaveBar/index.d.ts +1 -0
- package/hooks/useContextualSaveBar/index.js +5 -0
- package/hooks/useContextualSaveBar/useContextualSaveBar.d.ts +13 -0
- package/hooks/useContextualSaveBar/useContextualSaveBar.js +68 -0
- package/hooks/useNavigationHistory/index.js +1 -0
- package/hooks/useNavigationHistory/useNavigationHistory.js +2 -2
- package/hooks/useToast/index.js +1 -0
- package/hooks/useToast/useToast.js +4 -4
- package/index.js +7 -2
- package/package.json +3 -3
- package/umd/index.js +3 -3
- package/useAppBridge.d.ts +1 -1
- package/useAppBridge.js +1 -1
- package/utilities/transformers.d.ts +3 -3
- package/utilities/transformers.js +13 -11
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,34 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [2.0.22](https://github.com/Shopify/app-bridge/compare/v2.0.21...v2.0.22) (2022-03-30)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **app-bridge:** add TypeScript interface for App Bridge State ([7a4a0f2](https://github.com/Shopify/app-bridge/commit/7a4a0f24bb8f4eeb8093c25b6580167ce100e200))
|
|
12
|
+
* **app-bridge:** improve app.getState TypeScript support when using dot notation ([7cf14f6](https://github.com/Shopify/app-bridge/commit/7cf14f6f6a703356114953a119c23adb93c8ca9a))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [2.0.21](https://github.com/Shopify/app-bridge/compare/v2.0.20...v2.0.21) (2022-03-23)
|
|
19
|
+
|
|
20
|
+
**Note:** Version bump only for package @shopify/app-bridge-react
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## [2.0.20](https://github.com/Shopify/app-bridge/compare/v2.0.19...v2.0.20) (2022-03-23)
|
|
27
|
+
|
|
28
|
+
**Note:** Version bump only for package @shopify/app-bridge-react
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
6
34
|
## [2.0.19](https://github.com/Shopify/app-bridge/compare/v2.0.17...v2.0.19) (2022-03-15)
|
|
7
35
|
|
|
8
36
|
**Note:** Version bump only for package @shopify/app-bridge-react
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -34,7 +36,7 @@ var ClientRouter = /** @class */ (function (_super) {
|
|
|
34
36
|
}
|
|
35
37
|
ClientRouter.prototype.componentDidMount = function () {
|
|
36
38
|
var history = this.props.history;
|
|
37
|
-
this.unsubscribe = router_1.handleRouteChange(this.context, history);
|
|
39
|
+
this.unsubscribe = (0, router_1.handleRouteChange)(this.context, history);
|
|
38
40
|
};
|
|
39
41
|
ClientRouter.prototype.componentWillUnmount = function () {
|
|
40
42
|
if (this.unsubscribe) {
|
|
@@ -12,9 +12,9 @@ var router_1 = require("./router");
|
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
14
|
function useClientRouting(history) {
|
|
15
|
-
var app = useAppBridge_1.useAppBridge();
|
|
16
|
-
react_1.useEffect(function () {
|
|
17
|
-
return router_1.handleRouteChange(app, history);
|
|
15
|
+
var app = (0, useAppBridge_1.useAppBridge)();
|
|
16
|
+
(0, react_1.useEffect)(function () {
|
|
17
|
+
return (0, router_1.handleRouteChange)(app, history);
|
|
18
18
|
}, [app, history]);
|
|
19
19
|
}
|
|
20
20
|
exports.default = useClientRouting;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useClientRouting = exports.ClientRouter = void 0;
|
|
3
7
|
var ClientRouter_1 = require("./ClientRouter");
|
|
4
|
-
Object.defineProperty(exports, "ClientRouter", { enumerable: true, get: function () { return ClientRouter_1.default; } });
|
|
8
|
+
Object.defineProperty(exports, "ClientRouter", { enumerable: true, get: function () { return __importDefault(ClientRouter_1).default; } });
|
|
5
9
|
var hook_1 = require("./hook");
|
|
6
|
-
Object.defineProperty(exports, "useClientRouting", { enumerable: true, get: function () { return hook_1.default; } });
|
|
10
|
+
Object.defineProperty(exports, "useClientRouting", { enumerable: true, get: function () { return __importDefault(hook_1).default; } });
|
|
@@ -2,4 +2,4 @@ import { ClientApplication } from '@shopify/app-bridge';
|
|
|
2
2
|
export interface History {
|
|
3
3
|
replace(path: string): void;
|
|
4
4
|
}
|
|
5
|
-
export declare function handleRouteChange(app: ClientApplication
|
|
5
|
+
export declare function handleRouteChange(app: ClientApplication, history: History): import("@shopify/app-bridge").Unsubscribe;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ContextAction, DiscardAction } from '@shopify/app-bridge/actions/ContextualSaveBar';
|
|
2
|
+
export interface Props {
|
|
3
|
+
discardAction: DiscardAction & {
|
|
4
|
+
onAction(): void;
|
|
5
|
+
};
|
|
6
|
+
saveAction: ContextAction & {
|
|
7
|
+
onAction(): void;
|
|
8
|
+
};
|
|
9
|
+
fullWidth?: boolean;
|
|
10
|
+
leaveConfirmationDisable?: boolean;
|
|
11
|
+
visible?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export default function ContextualSaveBar({ discardAction, saveAction, fullWidth, leaveConfirmationDisable, visible, }: Props): null;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
var react_1 = require("react");
|
|
15
|
+
var actions_1 = require("@shopify/app-bridge/actions");
|
|
16
|
+
var useAppBridge_1 = require("../../useAppBridge");
|
|
17
|
+
var Action = actions_1.ContextualSaveBar.Action, create = actions_1.ContextualSaveBar.create;
|
|
18
|
+
function ContextualSaveBar(_a) {
|
|
19
|
+
var discardAction = _a.discardAction, saveAction = _a.saveAction, fullWidth = _a.fullWidth, leaveConfirmationDisable = _a.leaveConfirmationDisable, visible = _a.visible;
|
|
20
|
+
var app = (0, useAppBridge_1.useAppBridge)();
|
|
21
|
+
var onSaveAction = saveAction.onAction, saveActionProps = __rest(saveAction, ["onAction"]);
|
|
22
|
+
var onDiscardAction = discardAction.onAction, discardActionProps = __rest(discardAction, ["onAction"]);
|
|
23
|
+
var contextualSaveBar = (0, react_1.useMemo)(function () {
|
|
24
|
+
return create(app, {
|
|
25
|
+
saveAction: saveActionProps,
|
|
26
|
+
discardAction: discardActionProps,
|
|
27
|
+
fullWidth: fullWidth,
|
|
28
|
+
leaveConfirmationDisable: leaveConfirmationDisable,
|
|
29
|
+
});
|
|
30
|
+
}, [app]);
|
|
31
|
+
(0, react_1.useEffect)(function () {
|
|
32
|
+
contextualSaveBar.set({
|
|
33
|
+
saveAction: saveActionProps,
|
|
34
|
+
discardAction: discardActionProps,
|
|
35
|
+
fullWidth: fullWidth,
|
|
36
|
+
leaveConfirmationDisable: leaveConfirmationDisable,
|
|
37
|
+
}, visible);
|
|
38
|
+
}, [
|
|
39
|
+
app,
|
|
40
|
+
contextualSaveBar,
|
|
41
|
+
saveActionProps,
|
|
42
|
+
discardActionProps,
|
|
43
|
+
fullWidth,
|
|
44
|
+
leaveConfirmationDisable,
|
|
45
|
+
visible,
|
|
46
|
+
]);
|
|
47
|
+
(0, react_1.useEffect)(function () {
|
|
48
|
+
contextualSaveBar.subscribe(Action.DISCARD, onDiscardAction);
|
|
49
|
+
contextualSaveBar.subscribe(Action.SAVE, onSaveAction);
|
|
50
|
+
return function () {
|
|
51
|
+
contextualSaveBar.unsubscribe();
|
|
52
|
+
};
|
|
53
|
+
}, [contextualSaveBar]);
|
|
54
|
+
(0, react_1.useEffect)(function () {
|
|
55
|
+
if (visible) {
|
|
56
|
+
contextualSaveBar.dispatch(Action.SHOW);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
contextualSaveBar.dispatch(Action.HIDE);
|
|
60
|
+
}
|
|
61
|
+
}, [contextualSaveBar, visible]);
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
exports.default = ContextualSaveBar;
|
|
@@ -0,0 +1,7 @@
|
|
|
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 ContextualSaveBar_1 = __importDefault(require("./ContextualSaveBar"));
|
|
7
|
+
exports.default = ContextualSaveBar_1.default;
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -113,9 +115,8 @@ var Modal = /** @class */ (function (_super) {
|
|
|
113
115
|
srcPayload.path = src;
|
|
114
116
|
}
|
|
115
117
|
}
|
|
116
|
-
return __assign(__assign({ title: title,
|
|
117
|
-
|
|
118
|
-
buttons: transformers_1.transformActions(app, {
|
|
118
|
+
return __assign(__assign({ title: title, message: message, size: safeSize }, srcPayload), { footer: {
|
|
119
|
+
buttons: (0, transformers_1.transformActions)(app, {
|
|
119
120
|
primaryAction: primaryAction,
|
|
120
121
|
secondaryActions: secondaryActions,
|
|
121
122
|
}),
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ModalContent = void 0;
|
|
6
7
|
var Modal_1 = __importDefault(require("./Modal"));
|
|
7
8
|
var ModalContent_1 = require("./ModalContent");
|
|
8
|
-
Object.defineProperty(exports, "ModalContent", { enumerable: true, get: function () { return ModalContent_1.default; } });
|
|
9
|
+
Object.defineProperty(exports, "ModalContent", { enumerable: true, get: function () { return __importDefault(ModalContent_1).default; } });
|
|
9
10
|
exports.default = Modal_1.default;
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -14,7 +16,11 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
16
|
})();
|
|
15
17
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
18
|
if (k2 === undefined) k2 = k;
|
|
17
|
-
Object.
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
18
24
|
}) : (function(o, m, k, k2) {
|
|
19
25
|
if (k2 === undefined) k2 = k;
|
|
20
26
|
o[k2] = m[k];
|
|
@@ -27,7 +33,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
27
33
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
28
34
|
if (mod && mod.__esModule) return mod;
|
|
29
35
|
var result = {};
|
|
30
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
36
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
31
37
|
__setModuleDefault(result, mod);
|
|
32
38
|
return result;
|
|
33
39
|
};
|
|
@@ -61,7 +67,7 @@ var Provider = /** @class */ (function (_super) {
|
|
|
61
67
|
Object.defineProperty(Provider.prototype, "appInstance", {
|
|
62
68
|
get: function () {
|
|
63
69
|
if (!this.app) {
|
|
64
|
-
this.app = app_bridge_1.default(this.props.config);
|
|
70
|
+
this.app = (0, app_bridge_1.default)(this.props.config);
|
|
65
71
|
if (this.app && this.app.hooks) {
|
|
66
72
|
this.app.hooks.set(app_bridge_1.LifecycleHook.DispatchAction, exports.setClientInterfaceHook);
|
|
67
73
|
}
|
|
@@ -82,7 +88,7 @@ exports.default = Provider;
|
|
|
82
88
|
*
|
|
83
89
|
* @internal
|
|
84
90
|
*/
|
|
85
|
-
|
|
91
|
+
var setClientInterfaceHook = function (next) {
|
|
86
92
|
return function (action) {
|
|
87
93
|
action.clientInterface = {
|
|
88
94
|
name: '@shopify/app-bridge-react',
|
|
@@ -91,3 +97,4 @@ exports.setClientInterfaceHook = function (next) {
|
|
|
91
97
|
return next(action);
|
|
92
98
|
};
|
|
93
99
|
};
|
|
100
|
+
exports.setClientInterfaceHook = setClientInterfaceHook;
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -34,13 +36,13 @@ var RoutePropagator = /** @class */ (function (_super) {
|
|
|
34
36
|
}
|
|
35
37
|
RoutePropagator.prototype.componentDidMount = function () {
|
|
36
38
|
var location = this.props.location;
|
|
37
|
-
route_propagator_1.updateHistory(this.context, location);
|
|
39
|
+
(0, route_propagator_1.updateHistory)(this.context, location);
|
|
38
40
|
};
|
|
39
41
|
RoutePropagator.prototype.componentDidUpdate = function (_a) {
|
|
40
42
|
var prevLocation = _a.location;
|
|
41
43
|
var location = this.props.location;
|
|
42
44
|
if (location !== prevLocation) {
|
|
43
|
-
route_propagator_1.updateHistory(this.context, location);
|
|
45
|
+
(0, route_propagator_1.updateHistory)(this.context, location);
|
|
44
46
|
}
|
|
45
47
|
};
|
|
46
48
|
RoutePropagator.prototype.render = function () {
|
|
@@ -12,9 +12,9 @@ var route_propagator_1 = require("./route-propagator");
|
|
|
12
12
|
* @public
|
|
13
13
|
*/
|
|
14
14
|
function useRoutePropagation(location) {
|
|
15
|
-
var app = useAppBridge_1.useAppBridge();
|
|
16
|
-
react_1.useEffect(function () {
|
|
17
|
-
route_propagator_1.updateHistory(app, location);
|
|
15
|
+
var app = (0, useAppBridge_1.useAppBridge)();
|
|
16
|
+
(0, react_1.useEffect)(function () {
|
|
17
|
+
(0, route_propagator_1.updateHistory)(app, location);
|
|
18
18
|
}, [app, location]);
|
|
19
19
|
}
|
|
20
20
|
exports.default = useRoutePropagation;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useRoutePropagation = exports.RoutePropagator = void 0;
|
|
3
7
|
var RoutePropagator_1 = require("./RoutePropagator");
|
|
4
|
-
Object.defineProperty(exports, "RoutePropagator", { enumerable: true, get: function () { return RoutePropagator_1.default; } });
|
|
8
|
+
Object.defineProperty(exports, "RoutePropagator", { enumerable: true, get: function () { return __importDefault(RoutePropagator_1).default; } });
|
|
5
9
|
var hook_1 = require("./hook");
|
|
6
|
-
Object.defineProperty(exports, "useRoutePropagation", { enumerable: true, get: function () { return hook_1.default; } });
|
|
10
|
+
Object.defineProperty(exports, "useRoutePropagation", { enumerable: true, get: function () { return __importDefault(hook_1).default; } });
|
|
@@ -4,4 +4,4 @@ export declare type LocationOrHref = string | {
|
|
|
4
4
|
hash: string;
|
|
5
5
|
pathname: string;
|
|
6
6
|
};
|
|
7
|
-
export declare function updateHistory(app: ClientApplication
|
|
7
|
+
export declare function updateHistory(app: ClientApplication, location: LocationOrHref): Promise<void>;
|
|
@@ -59,8 +59,8 @@ function updateHistory(app, location) {
|
|
|
59
59
|
return __generator(this, function (_a) {
|
|
60
60
|
switch (_a.label) {
|
|
61
61
|
case 0:
|
|
62
|
-
selfWindow = globals_1.getSelfWindow();
|
|
63
|
-
topWindow = globals_1.getTopWindow();
|
|
62
|
+
selfWindow = (0, globals_1.getSelfWindow)();
|
|
63
|
+
topWindow = (0, globals_1.getTopWindow)();
|
|
64
64
|
renderedInTheTopWindow = selfWindow === topWindow;
|
|
65
65
|
return [4 /*yield*/, app.getState('context').then(function (context) {
|
|
66
66
|
return context === MessageTransport_1.Context.Main;
|
|
@@ -73,7 +73,7 @@ function updateHistory(app, location) {
|
|
|
73
73
|
normalizedLocation = getNormalizedURL(location);
|
|
74
74
|
embeddedFrameParamsToRemove.forEach(function (param) { return normalizedLocation.searchParams.delete(param); });
|
|
75
75
|
pathname = normalizedLocation.pathname, search = normalizedLocation.search, hash = normalizedLocation.hash;
|
|
76
|
-
locationStr = ""
|
|
76
|
+
locationStr = "".concat(pathname).concat(search).concat(hash);
|
|
77
77
|
actions_1.History.create(app).dispatch(actions_1.History.Action.REPLACE, locationStr);
|
|
78
78
|
return [2 /*return*/];
|
|
79
79
|
}
|
|
@@ -82,10 +82,10 @@ function updateHistory(app, location) {
|
|
|
82
82
|
}
|
|
83
83
|
exports.updateHistory = updateHistory;
|
|
84
84
|
function getNormalizedURL(location) {
|
|
85
|
-
var origin = globals_1.getOrigin();
|
|
85
|
+
var origin = (0, globals_1.getOrigin)();
|
|
86
86
|
if (typeof location === 'string') {
|
|
87
87
|
return new URL(location, origin);
|
|
88
88
|
}
|
|
89
89
|
var pathname = location.pathname, search = location.search, hash = location.hash;
|
|
90
|
-
return new URL(""
|
|
90
|
+
return new URL("".concat(pathname).concat(search).concat(hash), origin);
|
|
91
91
|
}
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
@@ -44,7 +46,7 @@ var TitleBar = /** @class */ (function (_super) {
|
|
|
44
46
|
var _a = this.props, title = _a.title, primaryAction = _a.primaryAction, secondaryActions = _a.secondaryActions, actionGroups = _a.actionGroups;
|
|
45
47
|
return {
|
|
46
48
|
title: title,
|
|
47
|
-
buttons: transformers_1.transformActions(app, {
|
|
49
|
+
buttons: (0, transformers_1.transformActions)(app, {
|
|
48
50
|
primaryAction: primaryAction,
|
|
49
51
|
secondaryActions: secondaryActions,
|
|
50
52
|
actionGroups: actionGroups,
|
|
@@ -63,7 +65,7 @@ var TitleBar = /** @class */ (function (_super) {
|
|
|
63
65
|
var button = actions_1.Button.create(app, {
|
|
64
66
|
label: content || '',
|
|
65
67
|
});
|
|
66
|
-
var redirect = transformers_1.generateRedirect(app, url, target);
|
|
68
|
+
var redirect = (0, transformers_1.generateRedirect)(app, url, target);
|
|
67
69
|
if (redirect != null) {
|
|
68
70
|
button.subscribe(actions_1.Button.Action.CLICK, redirect);
|
|
69
71
|
}
|
|
@@ -3,10 +3,12 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
3
3
|
var extendStatics = function (d, b) {
|
|
4
4
|
extendStatics = Object.setPrototypeOf ||
|
|
5
5
|
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
7
|
return extendStatics(d, b);
|
|
8
8
|
};
|
|
9
9
|
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
10
12
|
extendStatics(d, b);
|
|
11
13
|
function __() { this.constructor = d; }
|
|
12
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
package/components/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { default as ContextualSaveBar, Props as ContextualSaveBarProps } from './ContextualSaveBar';
|
|
1
2
|
export { default as Provider, Props as ProviderProps } from './Provider';
|
|
2
3
|
export { default as Loading } from './Loading';
|
|
3
4
|
export { default as Toast, Props as ToastProps } from './Toast';
|
package/components/index.js
CHANGED
|
@@ -1,27 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
8
12
|
}));
|
|
9
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
18
|
};
|
|
12
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.ResourcePicker = exports.ModalContent = exports.Modal = exports.TitleBar = exports.Toast = exports.Loading = exports.Provider = exports.ContextualSaveBar = void 0;
|
|
21
|
+
var ContextualSaveBar_1 = require("./ContextualSaveBar");
|
|
22
|
+
Object.defineProperty(exports, "ContextualSaveBar", { enumerable: true, get: function () { return __importDefault(ContextualSaveBar_1).default; } });
|
|
13
23
|
var Provider_1 = require("./Provider");
|
|
14
|
-
Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return Provider_1.default; } });
|
|
24
|
+
Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return __importDefault(Provider_1).default; } });
|
|
15
25
|
var Loading_1 = require("./Loading");
|
|
16
|
-
Object.defineProperty(exports, "Loading", { enumerable: true, get: function () { return Loading_1.default; } });
|
|
26
|
+
Object.defineProperty(exports, "Loading", { enumerable: true, get: function () { return __importDefault(Loading_1).default; } });
|
|
17
27
|
var Toast_1 = require("./Toast");
|
|
18
|
-
Object.defineProperty(exports, "Toast", { enumerable: true, get: function () { return Toast_1.default; } });
|
|
28
|
+
Object.defineProperty(exports, "Toast", { enumerable: true, get: function () { return __importDefault(Toast_1).default; } });
|
|
19
29
|
var TitleBar_1 = require("./TitleBar");
|
|
20
|
-
Object.defineProperty(exports, "TitleBar", { enumerable: true, get: function () { return TitleBar_1.default; } });
|
|
30
|
+
Object.defineProperty(exports, "TitleBar", { enumerable: true, get: function () { return __importDefault(TitleBar_1).default; } });
|
|
21
31
|
var Modal_1 = require("./Modal");
|
|
22
|
-
Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return Modal_1.default; } });
|
|
32
|
+
Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return __importDefault(Modal_1).default; } });
|
|
23
33
|
Object.defineProperty(exports, "ModalContent", { enumerable: true, get: function () { return Modal_1.ModalContent; } });
|
|
24
34
|
var ResourcePicker_1 = require("./ResourcePicker");
|
|
25
|
-
Object.defineProperty(exports, "ResourcePicker", { enumerable: true, get: function () { return ResourcePicker_1.default; } });
|
|
35
|
+
Object.defineProperty(exports, "ResourcePicker", { enumerable: true, get: function () { return __importDefault(ResourcePicker_1).default; } });
|
|
26
36
|
__exportStar(require("./RoutePropagator"), exports);
|
|
27
37
|
__exportStar(require("./ClientRouter"), exports);
|
package/context.d.ts
CHANGED
package/context.js
CHANGED
package/hooks/index.d.ts
CHANGED
package/hooks/index.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useToast = exports.useNavigationHistory = exports.useContextualSaveBar = void 0;
|
|
4
|
+
var useContextualSaveBar_1 = require("./useContextualSaveBar");
|
|
5
|
+
Object.defineProperty(exports, "useContextualSaveBar", { enumerable: true, get: function () { return useContextualSaveBar_1.useContextualSaveBar; } });
|
|
3
6
|
var useNavigationHistory_1 = require("./useNavigationHistory");
|
|
4
7
|
Object.defineProperty(exports, "useNavigationHistory", { enumerable: true, get: function () { return useNavigationHistory_1.useNavigationHistory; } });
|
|
5
8
|
var useToast_1 = require("./useToast");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useContextualSaveBar } from './useContextualSaveBar';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useContextualSaveBar = void 0;
|
|
4
|
+
var useContextualSaveBar_1 = require("./useContextualSaveBar");
|
|
5
|
+
Object.defineProperty(exports, "useContextualSaveBar", { enumerable: true, get: function () { return useContextualSaveBar_1.useContextualSaveBar; } });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ContextAction, DiscardAction } from '@shopify/app-bridge/actions/ContextualSaveBar';
|
|
2
|
+
export interface Props {
|
|
3
|
+
discardAction: DiscardAction & {
|
|
4
|
+
onAction(): void;
|
|
5
|
+
};
|
|
6
|
+
saveAction: ContextAction & {
|
|
7
|
+
onAction(): void;
|
|
8
|
+
};
|
|
9
|
+
fullWidth?: boolean;
|
|
10
|
+
leaveConfirmationDisable?: boolean;
|
|
11
|
+
visible?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function useContextualSaveBar({ discardAction, saveAction, fullWidth, leaveConfirmationDisable, visible, }: Props): null;
|