@shopify/app-bridge-react 2.0.24 → 2.0.27
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 +43 -0
- package/components/Modal/Modal.d.ts +3 -14
- package/components/Modal/Modal.js +101 -94
- package/components/NavigationMenu/NavigationMenu.js +29 -44
- package/components/Provider/Provider.d.ts +57 -11
- package/components/Provider/Provider.js +23 -49
- package/components/ResourcePicker/ResourcePicker.d.ts +7 -16
- package/components/ResourcePicker/ResourcePicker.js +77 -94
- package/components/TitleBar/TitleBar.d.ts +3 -14
- package/components/TitleBar/TitleBar.js +101 -73
- package/hooks/index.d.ts +3 -0
- package/hooks/index.js +5 -1
- package/hooks/useAppBridgeState/useAppBridgeState.js +18 -4
- package/hooks/useFeatureRequest/index.d.ts +1 -0
- package/hooks/useFeatureRequest/index.js +13 -0
- package/hooks/useFeatureRequest/useFeatureRequest.d.ts +13 -0
- package/hooks/useFeatureRequest/useFeatureRequest.js +49 -0
- package/hooks/useFeaturesAvailable/index.d.ts +2 -0
- package/hooks/useFeaturesAvailable/index.js +5 -0
- package/hooks/useFeaturesAvailable/useFeaturesAvailable.d.ts +12 -0
- package/hooks/useFeaturesAvailable/useFeaturesAvailable.js +101 -0
- package/package.json +3 -3
- package/types.d.ts +2 -0
- package/types.js +3 -0
- package/umd/index.js +3 -3
- package/utilities/transformers.d.ts +3 -2
- package/utilities/transformers.js +30 -9
|
@@ -0,0 +1,101 @@
|
|
|
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.useFeaturesAvailable = void 0;
|
|
40
|
+
var react_1 = require("react");
|
|
41
|
+
var types_1 = require("@shopify/app-bridge/actions/Features/types");
|
|
42
|
+
var useAppBridge_1 = require("../../useAppBridge");
|
|
43
|
+
/**
|
|
44
|
+
* useFeaturesAvailable hook
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* React hook that wraps the Shopify App Bridge getFeaturesAvailable method.
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
function useFeaturesAvailable() {
|
|
52
|
+
var _this = this;
|
|
53
|
+
var query = [];
|
|
54
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
55
|
+
query[_i] = arguments[_i];
|
|
56
|
+
}
|
|
57
|
+
var app = useAppBridge_1.useAppBridge();
|
|
58
|
+
var _a = react_1.useState(), state = _a[0], setState = _a[1];
|
|
59
|
+
var queryRef = react_1.useRef([]);
|
|
60
|
+
var refresh = react_1.useCallback(function () {
|
|
61
|
+
var isUnmounted = false;
|
|
62
|
+
(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
63
|
+
var features;
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
switch (_a.label) {
|
|
66
|
+
case 0: return [4 /*yield*/, app.featuresAvailable.apply(app, queryRef.current)];
|
|
67
|
+
case 1:
|
|
68
|
+
features = _a.sent();
|
|
69
|
+
if (!isUnmounted) {
|
|
70
|
+
setState(function (currentFeatures) {
|
|
71
|
+
if (JSON.stringify(currentFeatures) === JSON.stringify(features)) {
|
|
72
|
+
return currentFeatures;
|
|
73
|
+
}
|
|
74
|
+
return features;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return [2 /*return*/];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}); })();
|
|
81
|
+
return function () {
|
|
82
|
+
isUnmounted = true;
|
|
83
|
+
};
|
|
84
|
+
}, [app]);
|
|
85
|
+
react_1.useEffect(function () {
|
|
86
|
+
queryRef.current = query;
|
|
87
|
+
return refresh();
|
|
88
|
+
}, [JSON.stringify(query)]);
|
|
89
|
+
react_1.useEffect(function () {
|
|
90
|
+
var onRefreshCleanup;
|
|
91
|
+
var unsubscribe = app.subscribe(types_1.Action.UPDATE, function () {
|
|
92
|
+
onRefreshCleanup = refresh();
|
|
93
|
+
});
|
|
94
|
+
return function () {
|
|
95
|
+
unsubscribe();
|
|
96
|
+
onRefreshCleanup === null || onRefreshCleanup === void 0 ? void 0 : onRefreshCleanup();
|
|
97
|
+
};
|
|
98
|
+
}, [app, refresh]);
|
|
99
|
+
return state;
|
|
100
|
+
}
|
|
101
|
+
exports.useFeaturesAvailable = useFeaturesAvailable;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/app-bridge-react",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.27",
|
|
4
4
|
"types": "index.d.ts",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"unpkg": "umd/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
}
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@shopify/app-bridge": "^2.0.
|
|
48
|
+
"@shopify/app-bridge": "^2.0.27"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/react": "^17.0.38",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"react": "^16.0.0 || ^17.0.0"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "501905d48e16d7785e33b5bf12618b990b1cdabf"
|
|
59
59
|
}
|
package/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Redirect } from '@shopify/app-bridge/actions';
|
|
2
|
+
import { Group } from '@shopify/app-bridge/actions/types';
|
|
2
3
|
export declare type Target = Exclude<keyof typeof Redirect.Action, 'ADMIN_SECTION'>;
|
|
3
4
|
export interface ActionProps {
|
|
4
5
|
/** Content the action displays */
|
|
@@ -31,3 +32,4 @@ export interface ActionGroupProps {
|
|
|
31
32
|
/** List of actions */
|
|
32
33
|
actions: ActionProps[];
|
|
33
34
|
}
|
|
35
|
+
export { Group };
|
package/types.js
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Group = void 0;
|
|
4
|
+
var types_1 = require("@shopify/app-bridge/actions/types");
|
|
5
|
+
Object.defineProperty(exports, "Group", { enumerable: true, get: function () { return types_1.Group; } });
|