@shopify/app-bridge-react 2.0.21 → 2.0.24
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 +36 -0
- package/components/ClientRouter/ClientRouter.js +3 -1
- package/components/ClientRouter/index.js +6 -2
- package/components/ClientRouter/router.d.ts +1 -1
- package/components/Loading/Loading.js +3 -1
- package/components/Modal/Modal.js +4 -3
- package/components/Modal/ModalContent/ModalContent.js +3 -1
- package/components/Modal/index.js +2 -1
- package/components/NavigationMenu/NavigationMenu.d.ts +17 -0
- package/components/NavigationMenu/NavigationMenu.js +55 -0
- package/components/NavigationMenu/index.d.ts +3 -0
- package/components/NavigationMenu/index.js +7 -0
- package/components/Provider/Provider.d.ts +1 -2
- package/components/Provider/Provider.js +6 -3
- package/components/ResourcePicker/ResourcePicker.js +3 -1
- package/components/RoutePropagator/RoutePropagator.js +3 -1
- package/components/RoutePropagator/index.js +6 -2
- package/components/RoutePropagator/route-propagator.d.ts +1 -1
- package/components/TitleBar/TitleBar.js +3 -1
- package/components/Toast/Toast.js +3 -1
- package/components/index.d.ts +4 -3
- package/components/index.js +17 -11
- package/context.d.ts +2 -2
- package/hooks/index.d.ts +2 -0
- package/hooks/index.js +5 -0
- package/hooks/useAppBridgeState/index.d.ts +1 -0
- package/hooks/useAppBridgeState/index.js +13 -0
- package/hooks/useAppBridgeState/useAppBridgeState.d.ts +10 -0
- package/hooks/useAppBridgeState/useAppBridgeState.js +75 -0
- package/hooks/useContextualSaveBar/index.js +1 -0
- package/hooks/useLocale/index.d.ts +1 -0
- package/hooks/useLocale/index.js +5 -0
- package/hooks/useLocale/useLocale.d.ts +1 -0
- package/hooks/useLocale/useLocale.js +8 -0
- package/hooks/useNavigate/index.d.ts +1 -0
- package/hooks/useNavigate/index.js +5 -0
- package/hooks/useNavigate/useNavigate.d.ts +24 -0
- package/hooks/useNavigate/useNavigate.js +109 -0
- package/hooks/useNavigationHistory/index.js +1 -0
- package/hooks/useToast/index.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +3 -1
- package/package.json +3 -3
- package/umd/index.js +3 -3
- package/useAppBridge.d.ts +1 -1
- package/utilities/transformers.d.ts +3 -3
- package/utilities/transformers.js +7 -9
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,42 @@
|
|
|
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.24](https://github.com/Shopify/app-bridge/compare/v2.0.23...v2.0.24) (2022-04-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **app-bridge-react:** add useNavigate hook ([ae818cb](https://github.com/Shopify/app-bridge/commit/ae818cb7b26e4f416bf9dfa9153940775bdf98df))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [2.0.23](https://github.com/Shopify/app-bridge/compare/v2.0.22...v2.0.23) (2022-04-07)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* NavigationMenu component ([0205cb3](https://github.com/Shopify/app-bridge/commit/0205cb396d8b4ed679dd465348a6dc45227cedb9))
|
|
23
|
+
* **app-bridge-react:** add useAppBridgeState hook ([1fc64f1](https://github.com/Shopify/app-bridge/commit/1fc64f142cbd0a72adccb75fec36d31cde1ed552))
|
|
24
|
+
* **app-bridge-react:** add useLocale hook ([e17dbad](https://github.com/Shopify/app-bridge/commit/e17dbadedbded9d274744738821bef49e52eb43b))
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## [2.0.22](https://github.com/Shopify/app-bridge/compare/v2.0.21...v2.0.22) (2022-03-30)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Features
|
|
34
|
+
|
|
35
|
+
* **app-bridge:** add TypeScript interface for App Bridge State ([7a4a0f2](https://github.com/Shopify/app-bridge/commit/7a4a0f24bb8f4eeb8093c25b6580167ce100e200))
|
|
36
|
+
* **app-bridge:** improve app.getState TypeScript support when using dot notation ([7cf14f6](https://github.com/Shopify/app-bridge/commit/7cf14f6f6a703356114953a119c23adb93c8ca9a))
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
6
42
|
## [2.0.21](https://github.com/Shopify/app-bridge/compare/v2.0.20...v2.0.21) (2022-03-23)
|
|
7
43
|
|
|
8
44
|
**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 __());
|
|
@@ -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;
|
|
@@ -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,8 +115,7 @@ var Modal = /** @class */ (function (_super) {
|
|
|
113
115
|
srcPayload.path = src;
|
|
114
116
|
}
|
|
115
117
|
}
|
|
116
|
-
return __assign(__assign({ title: title,
|
|
117
|
-
message: message, size: safeSize }, srcPayload), { footer: {
|
|
118
|
+
return __assign(__assign({ title: title, message: message, size: safeSize }, srcPayload), { footer: {
|
|
118
119
|
buttons: transformers_1.transformActions(app, {
|
|
119
120
|
primaryAction: primaryAction,
|
|
120
121
|
secondaryActions: secondaryActions,
|
|
@@ -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;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface NavigationLink {
|
|
2
|
+
label: string;
|
|
3
|
+
destination: string;
|
|
4
|
+
}
|
|
5
|
+
export interface Props {
|
|
6
|
+
/**
|
|
7
|
+
* List of links in navigation menu
|
|
8
|
+
*/
|
|
9
|
+
navigationLinks: NavigationLink[];
|
|
10
|
+
/**
|
|
11
|
+
* Custom matcher to set active link.
|
|
12
|
+
* This function will be called with each link and the current location.
|
|
13
|
+
* If it returns true the current link will be set to the active link.
|
|
14
|
+
*/
|
|
15
|
+
matcher?: (link: NavigationLink, location: Location) => boolean;
|
|
16
|
+
}
|
|
17
|
+
export default function NavigationMenu({ navigationLinks, matcher }: Props): null;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
var react_1 = require("react");
|
|
23
|
+
var AppBridgeAppLinks = __importStar(require("@shopify/app-bridge/actions/Link/AppLink"));
|
|
24
|
+
var AppBridgeNavigationMenu = __importStar(require("@shopify/app-bridge/actions/Menu/NavigationMenu"));
|
|
25
|
+
var useAppBridge_1 = require("../../useAppBridge");
|
|
26
|
+
function NavigationMenu(_a) {
|
|
27
|
+
var navigationLinks = _a.navigationLinks, matcher = _a.matcher;
|
|
28
|
+
var app = useAppBridge_1.useAppBridge();
|
|
29
|
+
var _b = react_1.useState(), activeLink = _b[0], setActiveLink = _b[1];
|
|
30
|
+
var items = react_1.useMemo(function () {
|
|
31
|
+
return navigationLinks.map(function (link) {
|
|
32
|
+
var appLink = AppBridgeAppLinks.create(app, link);
|
|
33
|
+
if ((matcher === null || matcher === void 0 ? void 0 : matcher(link, location)) || link.destination === location.pathname) {
|
|
34
|
+
setActiveLink(appLink);
|
|
35
|
+
}
|
|
36
|
+
return appLink;
|
|
37
|
+
});
|
|
38
|
+
}, [app, location.pathname, matcher, navigationLinks]);
|
|
39
|
+
var navigationMenu = react_1.useMemo(function () {
|
|
40
|
+
return AppBridgeNavigationMenu.create(app, {
|
|
41
|
+
items: items,
|
|
42
|
+
active: activeLink,
|
|
43
|
+
});
|
|
44
|
+
/* We want to reuse the same NavigationMenu instance, even when props change
|
|
45
|
+
* (so we don't include all the props in the dependency array).
|
|
46
|
+
* Instead of recreating the component on every change, we use the set method,
|
|
47
|
+
* in the useEffect block below, to dispatch updates when props change.
|
|
48
|
+
*/
|
|
49
|
+
}, [app]);
|
|
50
|
+
react_1.useEffect(function () {
|
|
51
|
+
navigationMenu.set({ items: items, active: activeLink });
|
|
52
|
+
}, [activeLink, items]);
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
exports.default = NavigationMenu;
|
|
@@ -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 NavigationMenu_1 = __importDefault(require("./NavigationMenu"));
|
|
7
|
+
exports.default = NavigationMenu_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 __());
|
|
@@ -27,7 +29,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
27
29
|
var __importStar = (this && this.__importStar) || function (mod) {
|
|
28
30
|
if (mod && mod.__esModule) return mod;
|
|
29
31
|
var result = {};
|
|
30
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
31
33
|
__setModuleDefault(result, mod);
|
|
32
34
|
return result;
|
|
33
35
|
};
|
|
@@ -82,7 +84,7 @@ exports.default = Provider;
|
|
|
82
84
|
*
|
|
83
85
|
* @internal
|
|
84
86
|
*/
|
|
85
|
-
|
|
87
|
+
var setClientInterfaceHook = function (next) {
|
|
86
88
|
return function (action) {
|
|
87
89
|
action.clientInterface = {
|
|
88
90
|
name: '@shopify/app-bridge-react',
|
|
@@ -91,3 +93,4 @@ exports.setClientInterfaceHook = function (next) {
|
|
|
91
93
|
return next(action);
|
|
92
94
|
};
|
|
93
95
|
};
|
|
96
|
+
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 __());
|
|
@@ -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>;
|
|
@@ -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 __());
|
package/components/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { default as ContextualSaveBar, Props as ContextualSaveBarProps } from './ContextualSaveBar';
|
|
2
|
-
export { default as Provider, Props as ProviderProps } from './Provider';
|
|
3
2
|
export { default as Loading } from './Loading';
|
|
4
|
-
export { default as Toast, Props as ToastProps } from './Toast';
|
|
5
|
-
export { default as TitleBar } from './TitleBar';
|
|
6
3
|
export { default as Modal, Props as ModalProps, ModalContent } from './Modal';
|
|
4
|
+
export { default as NavigationMenu, Props as NavigationMenuProps } from './NavigationMenu';
|
|
5
|
+
export { default as Provider, Props as ProviderProps } from './Provider';
|
|
7
6
|
export { default as ResourcePicker, Props as ResourcePickerProps } from './ResourcePicker';
|
|
7
|
+
export { default as TitleBar } from './TitleBar';
|
|
8
|
+
export { default as Toast, Props as ToastProps } from './Toast';
|
|
8
9
|
export * from './RoutePropagator';
|
|
9
10
|
export * from './ClientRouter';
|
package/components/index.js
CHANGED
|
@@ -7,23 +7,29 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
7
7
|
o[k2] = m[k];
|
|
8
8
|
}));
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
13
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
14
|
};
|
|
12
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.Toast = exports.TitleBar = exports.ResourcePicker = exports.Provider = exports.NavigationMenu = exports.ModalContent = exports.Modal = exports.Loading = exports.ContextualSaveBar = void 0;
|
|
13
17
|
var ContextualSaveBar_1 = require("./ContextualSaveBar");
|
|
14
|
-
Object.defineProperty(exports, "ContextualSaveBar", { enumerable: true, get: function () { return ContextualSaveBar_1.default; } });
|
|
15
|
-
var Provider_1 = require("./Provider");
|
|
16
|
-
Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return Provider_1.default; } });
|
|
18
|
+
Object.defineProperty(exports, "ContextualSaveBar", { enumerable: true, get: function () { return __importDefault(ContextualSaveBar_1).default; } });
|
|
17
19
|
var Loading_1 = require("./Loading");
|
|
18
|
-
Object.defineProperty(exports, "Loading", { enumerable: true, get: function () { return Loading_1.default; } });
|
|
19
|
-
var Toast_1 = require("./Toast");
|
|
20
|
-
Object.defineProperty(exports, "Toast", { enumerable: true, get: function () { return Toast_1.default; } });
|
|
21
|
-
var TitleBar_1 = require("./TitleBar");
|
|
22
|
-
Object.defineProperty(exports, "TitleBar", { enumerable: true, get: function () { return TitleBar_1.default; } });
|
|
20
|
+
Object.defineProperty(exports, "Loading", { enumerable: true, get: function () { return __importDefault(Loading_1).default; } });
|
|
23
21
|
var Modal_1 = require("./Modal");
|
|
24
|
-
Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return Modal_1.default; } });
|
|
22
|
+
Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return __importDefault(Modal_1).default; } });
|
|
25
23
|
Object.defineProperty(exports, "ModalContent", { enumerable: true, get: function () { return Modal_1.ModalContent; } });
|
|
24
|
+
var NavigationMenu_1 = require("./NavigationMenu");
|
|
25
|
+
Object.defineProperty(exports, "NavigationMenu", { enumerable: true, get: function () { return __importDefault(NavigationMenu_1).default; } });
|
|
26
|
+
var Provider_1 = require("./Provider");
|
|
27
|
+
Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return __importDefault(Provider_1).default; } });
|
|
26
28
|
var ResourcePicker_1 = require("./ResourcePicker");
|
|
27
|
-
Object.defineProperty(exports, "ResourcePicker", { enumerable: true, get: function () { return ResourcePicker_1.default; } });
|
|
29
|
+
Object.defineProperty(exports, "ResourcePicker", { enumerable: true, get: function () { return __importDefault(ResourcePicker_1).default; } });
|
|
30
|
+
var TitleBar_1 = require("./TitleBar");
|
|
31
|
+
Object.defineProperty(exports, "TitleBar", { enumerable: true, get: function () { return __importDefault(TitleBar_1).default; } });
|
|
32
|
+
var Toast_1 = require("./Toast");
|
|
33
|
+
Object.defineProperty(exports, "Toast", { enumerable: true, get: function () { return __importDefault(Toast_1).default; } });
|
|
28
34
|
__exportStar(require("./RoutePropagator"), exports);
|
|
29
35
|
__exportStar(require("./ClientRouter"), exports);
|
package/context.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ClientApplication } from '@shopify/app-bridge/client';
|
|
1
|
+
import type { ClientApplication } from '@shopify/app-bridge/client';
|
|
2
2
|
/**
|
|
3
3
|
* App Bridge context consumer type.
|
|
4
4
|
*
|
|
5
5
|
* @public
|
|
6
6
|
*/
|
|
7
|
-
export declare type IAppBridgeContext = ClientApplication
|
|
7
|
+
export declare type IAppBridgeContext = ClientApplication | null;
|
|
8
8
|
/**
|
|
9
9
|
* App Bridge context.
|
|
10
10
|
*
|
package/hooks/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { useContextualSaveBar } from './useContextualSaveBar';
|
|
2
2
|
export { useNavigationHistory } from './useNavigationHistory';
|
|
3
3
|
export { useToast } from './useToast';
|
|
4
|
+
export { useAppBridgeState } from './useAppBridgeState';
|
|
5
|
+
export { useNavigate } from './useNavigate';
|
package/hooks/index.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useNavigate = exports.useAppBridgeState = exports.useToast = exports.useNavigationHistory = exports.useContextualSaveBar = void 0;
|
|
3
4
|
var useContextualSaveBar_1 = require("./useContextualSaveBar");
|
|
4
5
|
Object.defineProperty(exports, "useContextualSaveBar", { enumerable: true, get: function () { return useContextualSaveBar_1.useContextualSaveBar; } });
|
|
5
6
|
var useNavigationHistory_1 = require("./useNavigationHistory");
|
|
6
7
|
Object.defineProperty(exports, "useNavigationHistory", { enumerable: true, get: function () { return useNavigationHistory_1.useNavigationHistory; } });
|
|
7
8
|
var useToast_1 = require("./useToast");
|
|
8
9
|
Object.defineProperty(exports, "useToast", { enumerable: true, get: function () { return useToast_1.useToast; } });
|
|
10
|
+
var useAppBridgeState_1 = require("./useAppBridgeState");
|
|
11
|
+
Object.defineProperty(exports, "useAppBridgeState", { enumerable: true, get: function () { return useAppBridgeState_1.useAppBridgeState; } });
|
|
12
|
+
var useNavigate_1 = require("./useNavigate");
|
|
13
|
+
Object.defineProperty(exports, "useNavigate", { enumerable: true, get: function () { return useNavigate_1.useNavigate; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './useAppBridgeState';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./useAppBridgeState"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AppBridgeState, Path, PathValue, StateWithoutFeatures } from '@shopify/app-bridge';
|
|
2
|
+
declare type Query = keyof AppBridgeState | Path<StateWithoutFeatures<AppBridgeState>>;
|
|
3
|
+
declare type State<K extends Query> = K extends keyof AppBridgeState ? AppBridgeState[K] : K extends Path<StateWithoutFeatures<AppBridgeState>> ? PathValue<StateWithoutFeatures<AppBridgeState>, K> : K extends never ? AppBridgeState : never;
|
|
4
|
+
interface UseAppBridgeState {
|
|
5
|
+
(): AppBridgeState | undefined;
|
|
6
|
+
<K extends Query>(query: K): State<K> | undefined;
|
|
7
|
+
<PartialState>(query: keyof AppBridgeState): PartialState | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare const useAppBridgeState: UseAppBridgeState;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
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.useAppBridgeState = void 0;
|
|
40
|
+
var react_1 = require("react");
|
|
41
|
+
var useAppBridge_1 = require("../../useAppBridge");
|
|
42
|
+
var useAppBridgeState = function (query) {
|
|
43
|
+
var app = useAppBridge_1.useAppBridge();
|
|
44
|
+
var _a = react_1.useState(), state = _a[0], setState = _a[1];
|
|
45
|
+
var refresh = react_1.useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
+
var state, _a;
|
|
47
|
+
return __generator(this, function (_b) {
|
|
48
|
+
switch (_b.label) {
|
|
49
|
+
case 0:
|
|
50
|
+
if (!query) return [3 /*break*/, 2];
|
|
51
|
+
return [4 /*yield*/, app.getState(query)];
|
|
52
|
+
case 1:
|
|
53
|
+
_a = _b.sent();
|
|
54
|
+
return [3 /*break*/, 4];
|
|
55
|
+
case 2: return [4 /*yield*/, app.getState()];
|
|
56
|
+
case 3:
|
|
57
|
+
_a = _b.sent();
|
|
58
|
+
_b.label = 4;
|
|
59
|
+
case 4:
|
|
60
|
+
state = _a;
|
|
61
|
+
setState(state);
|
|
62
|
+
return [2 /*return*/, state];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}); }, [app, query]);
|
|
66
|
+
react_1.useEffect(function () {
|
|
67
|
+
refresh();
|
|
68
|
+
// Automatically check to see if the state has changed every time an action has been dispatched
|
|
69
|
+
return app.subscribe(function () {
|
|
70
|
+
refresh();
|
|
71
|
+
});
|
|
72
|
+
}, [app, refresh]);
|
|
73
|
+
return state;
|
|
74
|
+
};
|
|
75
|
+
exports.useAppBridgeState = useAppBridgeState;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useContextualSaveBar = void 0;
|
|
3
4
|
var useContextualSaveBar_1 = require("./useContextualSaveBar");
|
|
4
5
|
Object.defineProperty(exports, "useContextualSaveBar", { enumerable: true, get: function () { return useContextualSaveBar_1.useContextualSaveBar; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useLocale } from './useLocale';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLocale = void 0;
|
|
4
|
+
var useLocale_1 = require("./useLocale");
|
|
5
|
+
Object.defineProperty(exports, "useLocale", { enumerable: true, get: function () { return useLocale_1.useLocale; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useLocale(): string | undefined;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useLocale = void 0;
|
|
4
|
+
var useAppBridgeState_1 = require("../useAppBridgeState");
|
|
5
|
+
function useLocale() {
|
|
6
|
+
return useAppBridgeState_1.useAppBridgeState('staffMember.locale');
|
|
7
|
+
}
|
|
8
|
+
exports.useLocale = useLocale;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useNavigate } from './useNavigate';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useNavigate = void 0;
|
|
4
|
+
var useNavigate_1 = require("./useNavigate");
|
|
5
|
+
Object.defineProperty(exports, "useNavigate", { enumerable: true, get: function () { return useNavigate_1.useNavigate; } });
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as Redirect from '@shopify/app-bridge/actions/Navigation/Redirect';
|
|
2
|
+
export interface Location {
|
|
3
|
+
pathname: string;
|
|
4
|
+
search?: string | URLSearchParams;
|
|
5
|
+
hash?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface AppOptions {
|
|
8
|
+
replace?: boolean;
|
|
9
|
+
target?: 'self';
|
|
10
|
+
}
|
|
11
|
+
export interface HostOptions {
|
|
12
|
+
target: 'host' | 'new';
|
|
13
|
+
}
|
|
14
|
+
export declare type Options = AppOptions | HostOptions;
|
|
15
|
+
export declare type To = Location | URL | string;
|
|
16
|
+
export interface SectionStringName extends Omit<Redirect.Section, 'name'> {
|
|
17
|
+
name: keyof typeof Redirect.ResourceType;
|
|
18
|
+
}
|
|
19
|
+
export interface Navigate {
|
|
20
|
+
(to: To, options?: AppOptions): void;
|
|
21
|
+
(to: To | SectionStringName, options?: HostOptions): void;
|
|
22
|
+
}
|
|
23
|
+
export declare function useNavigate(): Navigate;
|
|
24
|
+
export declare function isAdminSection(to: any): to is SectionStringName;
|