@shopify/app-bridge-react 0.0.0-snapshot-20221220002610

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 (107) hide show
  1. package/README.md +171 -0
  2. package/components/ClientRouter/ClientRouter.d.ts +23 -0
  3. package/components/ClientRouter/ClientRouter.js +52 -0
  4. package/components/ClientRouter/hook.d.ts +10 -0
  5. package/components/ClientRouter/hook.js +20 -0
  6. package/components/ClientRouter/index.d.ts +3 -0
  7. package/components/ClientRouter/index.js +10 -0
  8. package/components/ClientRouter/router.d.ts +5 -0
  9. package/components/ClientRouter/router.js +11 -0
  10. package/components/ContextualSaveBar/ContextualSaveBar.d.ts +9 -0
  11. package/components/ContextualSaveBar/ContextualSaveBar.js +24 -0
  12. package/components/ContextualSaveBar/index.d.ts +3 -0
  13. package/components/ContextualSaveBar/index.js +7 -0
  14. package/components/Loading/Loading.d.ts +19 -0
  15. package/components/Loading/Loading.js +55 -0
  16. package/components/Loading/index.d.ts +2 -0
  17. package/components/Loading/index.js +7 -0
  18. package/components/Modal/Modal.d.ts +32 -0
  19. package/components/Modal/Modal.js +139 -0
  20. package/components/Modal/ModalContent/ModalContent.d.ts +24 -0
  21. package/components/Modal/ModalContent/ModalContent.js +61 -0
  22. package/components/Modal/ModalContent/index.d.ts +2 -0
  23. package/components/Modal/ModalContent/index.js +7 -0
  24. package/components/Modal/index.d.ts +4 -0
  25. package/components/Modal/index.js +10 -0
  26. package/components/NavigationMenu/NavigationMenu.d.ts +17 -0
  27. package/components/NavigationMenu/NavigationMenu.js +40 -0
  28. package/components/NavigationMenu/index.d.ts +3 -0
  29. package/components/NavigationMenu/index.js +7 -0
  30. package/components/Provider/Provider.d.ts +81 -0
  31. package/components/Provider/Provider.js +78 -0
  32. package/components/Provider/index.d.ts +3 -0
  33. package/components/Provider/index.js +7 -0
  34. package/components/ResourcePicker/ResourcePicker.d.ts +36 -0
  35. package/components/ResourcePicker/ResourcePicker.js +120 -0
  36. package/components/ResourcePicker/index.d.ts +3 -0
  37. package/components/ResourcePicker/index.js +7 -0
  38. package/components/RoutePropagator/RoutePropagator.d.ts +22 -0
  39. package/components/RoutePropagator/RoutePropagator.js +54 -0
  40. package/components/RoutePropagator/globals.d.ts +3 -0
  41. package/components/RoutePropagator/globals.js +15 -0
  42. package/components/RoutePropagator/hook.d.ts +10 -0
  43. package/components/RoutePropagator/hook.js +20 -0
  44. package/components/RoutePropagator/index.d.ts +3 -0
  45. package/components/RoutePropagator/index.js +10 -0
  46. package/components/RoutePropagator/route-propagator.d.ts +7 -0
  47. package/components/RoutePropagator/route-propagator.js +91 -0
  48. package/components/TitleBar/TitleBar.d.ts +27 -0
  49. package/components/TitleBar/TitleBar.js +107 -0
  50. package/components/TitleBar/index.d.ts +3 -0
  51. package/components/TitleBar/index.js +7 -0
  52. package/components/Toast/Toast.d.ts +38 -0
  53. package/components/Toast/Toast.js +67 -0
  54. package/components/Toast/index.d.ts +3 -0
  55. package/components/Toast/index.js +7 -0
  56. package/components/index.d.ts +11 -0
  57. package/components/index.js +37 -0
  58. package/components/unstable_Picker/index.d.ts +3 -0
  59. package/components/unstable_Picker/index.js +7 -0
  60. package/components/unstable_Picker/unstable_Picker.d.ts +13 -0
  61. package/components/unstable_Picker/unstable_Picker.js +85 -0
  62. package/context.d.ts +14 -0
  63. package/context.js +10 -0
  64. package/hooks/index.d.ts +9 -0
  65. package/hooks/index.js +19 -0
  66. package/hooks/useAppBridgeState/index.d.ts +1 -0
  67. package/hooks/useAppBridgeState/index.js +13 -0
  68. package/hooks/useAppBridgeState/useAppBridgeState.d.ts +10 -0
  69. package/hooks/useAppBridgeState/useAppBridgeState.js +89 -0
  70. package/hooks/useContextualSaveBar/index.d.ts +1 -0
  71. package/hooks/useContextualSaveBar/index.js +5 -0
  72. package/hooks/useContextualSaveBar/useContextualSaveBar.d.ts +10 -0
  73. package/hooks/useContextualSaveBar/useContextualSaveBar.js +87 -0
  74. package/hooks/useFeatureRequest/index.d.ts +1 -0
  75. package/hooks/useFeatureRequest/index.js +13 -0
  76. package/hooks/useFeatureRequest/useFeatureRequest.d.ts +13 -0
  77. package/hooks/useFeatureRequest/useFeatureRequest.js +49 -0
  78. package/hooks/useFeaturesAvailable/index.d.ts +2 -0
  79. package/hooks/useFeaturesAvailable/index.js +5 -0
  80. package/hooks/useFeaturesAvailable/useFeaturesAvailable.d.ts +12 -0
  81. package/hooks/useFeaturesAvailable/useFeaturesAvailable.js +101 -0
  82. package/hooks/useLocale/index.d.ts +1 -0
  83. package/hooks/useLocale/index.js +5 -0
  84. package/hooks/useLocale/useLocale.d.ts +1 -0
  85. package/hooks/useLocale/useLocale.js +8 -0
  86. package/hooks/useNavigate/index.d.ts +1 -0
  87. package/hooks/useNavigate/index.js +5 -0
  88. package/hooks/useNavigate/useNavigate.d.ts +3 -0
  89. package/hooks/useNavigate/useNavigate.js +63 -0
  90. package/hooks/useNavigationHistory/index.d.ts +1 -0
  91. package/hooks/useNavigationHistory/index.js +5 -0
  92. package/hooks/useNavigationHistory/useNavigationHistory.d.ts +16 -0
  93. package/hooks/useNavigationHistory/useNavigationHistory.js +28 -0
  94. package/hooks/useToast/index.d.ts +1 -0
  95. package/hooks/useToast/index.js +5 -0
  96. package/hooks/useToast/useToast.d.ts +20 -0
  97. package/hooks/useToast/useToast.js +46 -0
  98. package/index.d.ts +4 -0
  99. package/index.js +19 -0
  100. package/package.json +58 -0
  101. package/types.d.ts +35 -0
  102. package/types.js +5 -0
  103. package/umd/index.js +10 -0
  104. package/useAppBridge.d.ts +1 -0
  105. package/useAppBridge.js +13 -0
  106. package/utilities/transformers.d.ts +20 -0
  107. package/utilities/transformers.js +105 -0
@@ -0,0 +1,105 @@
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
+ 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;
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.transformActions = exports.generateRedirect = void 0;
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"));
31
+ function generateRedirect(appBridge, url, target, external) {
32
+ if (target === void 0) { target = 'APP'; }
33
+ if (url == null) {
34
+ return undefined;
35
+ }
36
+ var redirect = Redirect.create(appBridge);
37
+ var payload = external === true
38
+ ? {
39
+ url: url,
40
+ newContext: true,
41
+ }
42
+ : url;
43
+ return function () {
44
+ redirect.dispatch(redirectAction(target, external), payload);
45
+ };
46
+ }
47
+ exports.generateRedirect = generateRedirect;
48
+ function redirectAction(target, external) {
49
+ if (external === true) {
50
+ return Redirect.Action.REMOTE;
51
+ }
52
+ return Redirect.Action[target];
53
+ }
54
+ function transformActions(appBridge, _a) {
55
+ var primaryAction = _a.primaryAction, secondaryActions = _a.secondaryActions, actionGroups = _a.actionGroups;
56
+ var primary = transformPrimaryAction(appBridge, primaryAction);
57
+ var secondary = __spreadArray(__spreadArray([], transformSecondaryActions(appBridge, secondaryActions)), transformActionGroups(appBridge, actionGroups));
58
+ return {
59
+ primary: primary,
60
+ secondary: secondary,
61
+ };
62
+ }
63
+ exports.transformActions = transformActions;
64
+ function transformAction(appBridge, action) {
65
+ var style = action.destructive === true ? Button.Style.Danger : undefined;
66
+ var button = Button.create(appBridge, {
67
+ label: action.content || '',
68
+ disabled: action.disabled,
69
+ loading: action.loading,
70
+ plain: action.plain,
71
+ style: style,
72
+ });
73
+ if (action.onAction) {
74
+ button.subscribe(Button.Action.CLICK, action.onAction);
75
+ }
76
+ var redirect = generateRedirect(appBridge, action.url, action.target, action.external);
77
+ if (redirect != null) {
78
+ button.subscribe(Button.Action.CLICK, redirect);
79
+ }
80
+ return button;
81
+ }
82
+ function transformPrimaryAction(appBridge, primaryAction) {
83
+ if (primaryAction == null) {
84
+ return undefined;
85
+ }
86
+ var primary = transformAction(appBridge, primaryAction);
87
+ return primary;
88
+ }
89
+ function transformSecondaryActions(appBridge, secondaryActions) {
90
+ if (secondaryActions === void 0) { secondaryActions = []; }
91
+ var secondary = __spreadArray([], secondaryActions.map(function (secondaryAction) {
92
+ return transformAction(appBridge, secondaryAction);
93
+ }));
94
+ return secondary;
95
+ }
96
+ function transformActionGroups(appBridge, actionGroups) {
97
+ if (actionGroups === void 0) { actionGroups = []; }
98
+ var buttonGroups = __spreadArray([], actionGroups.map(function (group) {
99
+ var buttons = group.actions.map(function (groupAction) {
100
+ return transformAction(appBridge, groupAction);
101
+ });
102
+ return ButtonGroup.create(appBridge, { label: group.title, plain: group.plain, buttons: buttons });
103
+ }));
104
+ return buttonGroups;
105
+ }