@shopify/app-bridge-react 2.0.22 → 2.0.25
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 +44 -0
- package/components/ClientRouter/ClientRouter.js +1 -1
- package/components/ClientRouter/hook.js +3 -3
- package/components/ContextualSaveBar/ContextualSaveBar.js +5 -5
- package/components/Modal/Modal.js +1 -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 +58 -13
- package/components/Provider/Provider.js +24 -54
- package/components/ResourcePicker/ResourcePicker.d.ts +7 -16
- package/components/ResourcePicker/ResourcePicker.js +77 -94
- package/components/RoutePropagator/RoutePropagator.js +2 -2
- package/components/RoutePropagator/globals.d.ts +1 -1
- package/components/RoutePropagator/hook.js +3 -3
- package/components/RoutePropagator/route-propagator.js +5 -5
- package/components/TitleBar/TitleBar.d.ts +3 -14
- package/components/TitleBar/TitleBar.js +50 -75
- package/components/index.d.ts +4 -3
- package/components/index.js +10 -12
- package/context.d.ts +1 -1
- package/context.js +1 -1
- package/hooks/index.d.ts +5 -0
- package/hooks/index.js +9 -1
- 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 +89 -0
- package/hooks/useContextualSaveBar/useContextualSaveBar.js +6 -6
- 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/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/useNavigationHistory.js +2 -2
- package/hooks/useToast/useToast.js +4 -4
- package/index.d.ts +1 -0
- package/index.js +2 -5
- package/package.json +3 -3
- package/types.d.ts +2 -0
- package/types.js +3 -0
- package/umd/index.js +3 -3
- package/useAppBridge.js +1 -1
- package/utilities/transformers.d.ts +3 -2
- package/utilities/transformers.js +37 -20
package/useAppBridge.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.useAppBridge = void 0;
|
|
|
4
4
|
var react_1 = require("react");
|
|
5
5
|
var context_1 = require("./context");
|
|
6
6
|
function useAppBridge() {
|
|
7
|
-
var appBridge =
|
|
7
|
+
var appBridge = react_1.useContext(context_1.AppBridgeContext);
|
|
8
8
|
if (!appBridge) {
|
|
9
9
|
throw new Error('No AppBridge context provided. Your component must be wrapped in the <Provider> component from App Bridge React.');
|
|
10
10
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ClientApplication } from '@shopify/app-bridge';
|
|
2
|
-
import
|
|
1
|
+
import type { ClientApplication } from '@shopify/app-bridge';
|
|
2
|
+
import * as Button from '@shopify/app-bridge/actions/Button';
|
|
3
|
+
import * as ButtonGroup from '@shopify/app-bridge/actions/ButtonGroup';
|
|
3
4
|
import { Target, ActionProps, ActionGroupProps } from '../types';
|
|
4
5
|
export declare function generateRedirect(appBridge: ClientApplication, url?: string, target?: Target, external?: boolean): (() => void) | undefined;
|
|
5
6
|
export declare function transformActions(appBridge: ClientApplication, { primaryAction, secondaryActions, }: {
|
|
@@ -1,22 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
if (
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
22
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
23
|
+
to[j] = from[i];
|
|
24
|
+
return to;
|
|
10
25
|
};
|
|
11
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
27
|
exports.transformActions = exports.generateRedirect = void 0;
|
|
13
|
-
var
|
|
28
|
+
var Button = __importStar(require("@shopify/app-bridge/actions/Button"));
|
|
29
|
+
var ButtonGroup = __importStar(require("@shopify/app-bridge/actions/ButtonGroup"));
|
|
30
|
+
var Redirect = __importStar(require("@shopify/app-bridge/actions/Navigation/Redirect"));
|
|
14
31
|
function generateRedirect(appBridge, url, target, external) {
|
|
15
32
|
if (target === void 0) { target = 'APP'; }
|
|
16
33
|
if (url == null) {
|
|
17
34
|
return undefined;
|
|
18
35
|
}
|
|
19
|
-
var redirect =
|
|
36
|
+
var redirect = Redirect.create(appBridge);
|
|
20
37
|
var payload = external === true
|
|
21
38
|
? {
|
|
22
39
|
url: url,
|
|
@@ -30,14 +47,14 @@ function generateRedirect(appBridge, url, target, external) {
|
|
|
30
47
|
exports.generateRedirect = generateRedirect;
|
|
31
48
|
function redirectAction(target, external) {
|
|
32
49
|
if (external === true) {
|
|
33
|
-
return
|
|
50
|
+
return Redirect.Action.REMOTE;
|
|
34
51
|
}
|
|
35
|
-
return
|
|
52
|
+
return Redirect.Action[target];
|
|
36
53
|
}
|
|
37
54
|
function transformActions(appBridge, _a) {
|
|
38
55
|
var primaryAction = _a.primaryAction, secondaryActions = _a.secondaryActions, actionGroups = _a.actionGroups;
|
|
39
56
|
var primary = transformPrimaryAction(appBridge, primaryAction);
|
|
40
|
-
var secondary = __spreadArray(__spreadArray([], transformSecondaryActions(appBridge, secondaryActions)
|
|
57
|
+
var secondary = __spreadArray(__spreadArray([], transformSecondaryActions(appBridge, secondaryActions)), transformActionGroups(appBridge, actionGroups));
|
|
41
58
|
return {
|
|
42
59
|
primary: primary,
|
|
43
60
|
secondary: secondary,
|
|
@@ -45,8 +62,8 @@ function transformActions(appBridge, _a) {
|
|
|
45
62
|
}
|
|
46
63
|
exports.transformActions = transformActions;
|
|
47
64
|
function transformAction(appBridge, action) {
|
|
48
|
-
var style = action.destructive === true ?
|
|
49
|
-
var button =
|
|
65
|
+
var style = action.destructive === true ? Button.Style.Danger : undefined;
|
|
66
|
+
var button = Button.create(appBridge, {
|
|
50
67
|
label: action.content || '',
|
|
51
68
|
disabled: action.disabled,
|
|
52
69
|
loading: action.loading,
|
|
@@ -54,11 +71,11 @@ function transformAction(appBridge, action) {
|
|
|
54
71
|
style: style,
|
|
55
72
|
});
|
|
56
73
|
if (action.onAction) {
|
|
57
|
-
button.subscribe(
|
|
74
|
+
button.subscribe(Button.Action.CLICK, action.onAction);
|
|
58
75
|
}
|
|
59
76
|
var redirect = generateRedirect(appBridge, action.url, action.target, action.external);
|
|
60
77
|
if (redirect != null) {
|
|
61
|
-
button.subscribe(
|
|
78
|
+
button.subscribe(Button.Action.CLICK, redirect);
|
|
62
79
|
}
|
|
63
80
|
return button;
|
|
64
81
|
}
|
|
@@ -73,7 +90,7 @@ function transformSecondaryActions(appBridge, secondaryActions) {
|
|
|
73
90
|
if (secondaryActions === void 0) { secondaryActions = []; }
|
|
74
91
|
var secondary = __spreadArray([], secondaryActions.map(function (secondaryAction) {
|
|
75
92
|
return transformAction(appBridge, secondaryAction);
|
|
76
|
-
})
|
|
93
|
+
}));
|
|
77
94
|
return secondary;
|
|
78
95
|
}
|
|
79
96
|
function transformActionGroups(appBridge, actionGroups) {
|
|
@@ -82,7 +99,7 @@ function transformActionGroups(appBridge, actionGroups) {
|
|
|
82
99
|
var buttons = group.actions.map(function (groupAction) {
|
|
83
100
|
return transformAction(appBridge, groupAction);
|
|
84
101
|
});
|
|
85
|
-
return
|
|
86
|
-
})
|
|
102
|
+
return ButtonGroup.create(appBridge, { label: group.title, plain: group.plain, buttons: buttons });
|
|
103
|
+
}));
|
|
87
104
|
return buttonGroups;
|
|
88
105
|
}
|