@shopify/app-bridge-react 2.0.23 → 2.0.26

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.
@@ -1,5 +1,6 @@
1
- import { ClientApplication } from '@shopify/app-bridge';
2
- import { Button, ButtonGroup } from '@shopify/app-bridge/actions';
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,4 +1,23 @@
1
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
+ };
2
21
  var __spreadArray = (this && this.__spreadArray) || function (to, from) {
3
22
  for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
4
23
  to[j] = from[i];
@@ -6,13 +25,15 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
6
25
  };
7
26
  Object.defineProperty(exports, "__esModule", { value: true });
8
27
  exports.transformActions = exports.generateRedirect = void 0;
9
- var actions_1 = require("@shopify/app-bridge/actions");
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"));
10
31
  function generateRedirect(appBridge, url, target, external) {
11
32
  if (target === void 0) { target = 'APP'; }
12
33
  if (url == null) {
13
34
  return undefined;
14
35
  }
15
- var redirect = actions_1.Redirect.create(appBridge);
36
+ var redirect = Redirect.create(appBridge);
16
37
  var payload = external === true
17
38
  ? {
18
39
  url: url,
@@ -26,9 +47,9 @@ function generateRedirect(appBridge, url, target, external) {
26
47
  exports.generateRedirect = generateRedirect;
27
48
  function redirectAction(target, external) {
28
49
  if (external === true) {
29
- return actions_1.Redirect.Action.REMOTE;
50
+ return Redirect.Action.REMOTE;
30
51
  }
31
- return actions_1.Redirect.Action[target];
52
+ return Redirect.Action[target];
32
53
  }
33
54
  function transformActions(appBridge, _a) {
34
55
  var primaryAction = _a.primaryAction, secondaryActions = _a.secondaryActions, actionGroups = _a.actionGroups;
@@ -41,8 +62,8 @@ function transformActions(appBridge, _a) {
41
62
  }
42
63
  exports.transformActions = transformActions;
43
64
  function transformAction(appBridge, action) {
44
- var style = action.destructive === true ? actions_1.Button.Style.Danger : undefined;
45
- var button = actions_1.Button.create(appBridge, {
65
+ var style = action.destructive === true ? Button.Style.Danger : undefined;
66
+ var button = Button.create(appBridge, {
46
67
  label: action.content || '',
47
68
  disabled: action.disabled,
48
69
  loading: action.loading,
@@ -50,11 +71,11 @@ function transformAction(appBridge, action) {
50
71
  style: style,
51
72
  });
52
73
  if (action.onAction) {
53
- button.subscribe(actions_1.Button.Action.CLICK, action.onAction);
74
+ button.subscribe(Button.Action.CLICK, action.onAction);
54
75
  }
55
76
  var redirect = generateRedirect(appBridge, action.url, action.target, action.external);
56
77
  if (redirect != null) {
57
- button.subscribe(actions_1.Button.Action.CLICK, redirect);
78
+ button.subscribe(Button.Action.CLICK, redirect);
58
79
  }
59
80
  return button;
60
81
  }
@@ -78,7 +99,7 @@ function transformActionGroups(appBridge, actionGroups) {
78
99
  var buttons = group.actions.map(function (groupAction) {
79
100
  return transformAction(appBridge, groupAction);
80
101
  });
81
- return actions_1.ButtonGroup.create(appBridge, { label: group.title, plain: group.plain, buttons: buttons });
102
+ return ButtonGroup.create(appBridge, { label: group.title, plain: group.plain, buttons: buttons });
82
103
  }));
83
104
  return buttonGroups;
84
105
  }