@shopify/app-bridge-react 2.0.21 → 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.
Files changed (37) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/components/ClientRouter/ClientRouter.js +4 -2
  3. package/components/ClientRouter/hook.js +3 -3
  4. package/components/ClientRouter/index.js +6 -2
  5. package/components/ClientRouter/router.d.ts +1 -1
  6. package/components/ContextualSaveBar/ContextualSaveBar.js +5 -5
  7. package/components/Loading/Loading.js +3 -1
  8. package/components/Modal/Modal.js +5 -4
  9. package/components/Modal/ModalContent/ModalContent.js +3 -1
  10. package/components/Modal/index.js +2 -1
  11. package/components/Provider/Provider.js +12 -5
  12. package/components/ResourcePicker/ResourcePicker.js +3 -1
  13. package/components/RoutePropagator/RoutePropagator.js +5 -3
  14. package/components/RoutePropagator/globals.d.ts +1 -1
  15. package/components/RoutePropagator/hook.js +3 -3
  16. package/components/RoutePropagator/index.js +6 -2
  17. package/components/RoutePropagator/route-propagator.d.ts +1 -1
  18. package/components/RoutePropagator/route-propagator.js +5 -5
  19. package/components/TitleBar/TitleBar.js +5 -3
  20. package/components/Toast/Toast.js +3 -1
  21. package/components/index.js +17 -9
  22. package/context.d.ts +1 -1
  23. package/context.js +1 -1
  24. package/hooks/index.js +1 -0
  25. package/hooks/useContextualSaveBar/index.js +1 -0
  26. package/hooks/useContextualSaveBar/useContextualSaveBar.js +6 -6
  27. package/hooks/useNavigationHistory/index.js +1 -0
  28. package/hooks/useNavigationHistory/useNavigationHistory.js +2 -2
  29. package/hooks/useToast/index.js +1 -0
  30. package/hooks/useToast/useToast.js +4 -4
  31. package/index.js +7 -2
  32. package/package.json +3 -3
  33. package/umd/index.js +3 -3
  34. package/useAppBridge.d.ts +1 -1
  35. package/useAppBridge.js +1 -1
  36. package/utilities/transformers.d.ts +3 -3
  37. package/utilities/transformers.js +13 -11
package/useAppBridge.d.ts CHANGED
@@ -1 +1 @@
1
- export declare function useAppBridge(): import("@shopify/app-bridge").ClientApplication<any>;
1
+ export declare function useAppBridge(): import("@shopify/app-bridge").ClientApplication<import("@shopify/app-bridge").AppBridgeState>;
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 = react_1.useContext(context_1.AppBridgeContext);
7
+ var appBridge = (0, 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,15 +1,15 @@
1
1
  import { ClientApplication } from '@shopify/app-bridge';
2
2
  import { Button, ButtonGroup } from '@shopify/app-bridge/actions';
3
3
  import { Target, ActionProps, ActionGroupProps } from '../types';
4
- export declare function generateRedirect(appBridge: ClientApplication<{}>, url?: string, target?: Target, external?: boolean): (() => void) | undefined;
5
- export declare function transformActions(appBridge: ClientApplication<{}>, { primaryAction, secondaryActions, }: {
4
+ export declare function generateRedirect(appBridge: ClientApplication, url?: string, target?: Target, external?: boolean): (() => void) | undefined;
5
+ export declare function transformActions(appBridge: ClientApplication, { primaryAction, secondaryActions, }: {
6
6
  primaryAction?: ActionProps;
7
7
  secondaryActions?: ActionProps[];
8
8
  }): {
9
9
  primary?: Button.Button;
10
10
  secondary?: Button.Button[];
11
11
  };
12
- export declare function transformActions(appBridge: ClientApplication<{}>, { primaryAction, secondaryActions, actionGroups, }: {
12
+ export declare function transformActions(appBridge: ClientApplication, { primaryAction, secondaryActions, actionGroups, }: {
13
13
  primaryAction?: ActionProps;
14
14
  secondaryActions?: ActionProps[];
15
15
  actionGroups?: ActionGroupProps[];
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
- var __spreadArrays = (this && this.__spreadArrays) || function () {
3
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
4
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
5
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
6
- r[k] = a[j];
7
- return r;
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
8
10
  };
9
11
  Object.defineProperty(exports, "__esModule", { value: true });
10
12
  exports.transformActions = exports.generateRedirect = void 0;
@@ -35,7 +37,7 @@ function redirectAction(target, external) {
35
37
  function transformActions(appBridge, _a) {
36
38
  var primaryAction = _a.primaryAction, secondaryActions = _a.secondaryActions, actionGroups = _a.actionGroups;
37
39
  var primary = transformPrimaryAction(appBridge, primaryAction);
38
- var secondary = __spreadArrays(transformSecondaryActions(appBridge, secondaryActions), transformActionGroups(appBridge, actionGroups));
40
+ var secondary = __spreadArray(__spreadArray([], transformSecondaryActions(appBridge, secondaryActions), true), transformActionGroups(appBridge, actionGroups), true);
39
41
  return {
40
42
  primary: primary,
41
43
  secondary: secondary,
@@ -69,18 +71,18 @@ function transformPrimaryAction(appBridge, primaryAction) {
69
71
  }
70
72
  function transformSecondaryActions(appBridge, secondaryActions) {
71
73
  if (secondaryActions === void 0) { secondaryActions = []; }
72
- var secondary = __spreadArrays(secondaryActions.map(function (secondaryAction) {
74
+ var secondary = __spreadArray([], secondaryActions.map(function (secondaryAction) {
73
75
  return transformAction(appBridge, secondaryAction);
74
- }));
76
+ }), true);
75
77
  return secondary;
76
78
  }
77
79
  function transformActionGroups(appBridge, actionGroups) {
78
80
  if (actionGroups === void 0) { actionGroups = []; }
79
- var buttonGroups = __spreadArrays(actionGroups.map(function (group) {
81
+ var buttonGroups = __spreadArray([], actionGroups.map(function (group) {
80
82
  var buttons = group.actions.map(function (groupAction) {
81
83
  return transformAction(appBridge, groupAction);
82
84
  });
83
85
  return actions_1.ButtonGroup.create(appBridge, { label: group.title, plain: group.plain, buttons: buttons });
84
- }));
86
+ }), true);
85
87
  return buttonGroups;
86
88
  }