@shopify/app-bridge-react 3.1.2 → 3.1.3-alpha.0

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/CHANGELOG.md +8 -0
  2. package/package.json +3 -3
  3. package/components/ClientRouter/ClientRouter.d.ts +0 -21
  4. package/components/ClientRouter/ClientRouter.js +0 -52
  5. package/components/ClientRouter/hook.d.ts +0 -10
  6. package/components/ClientRouter/hook.js +0 -20
  7. package/components/ClientRouter/index.d.ts +0 -3
  8. package/components/ClientRouter/index.js +0 -10
  9. package/components/ClientRouter/router.d.ts +0 -5
  10. package/components/ClientRouter/router.js +0 -11
  11. package/components/ContextualSaveBar/ContextualSaveBar.d.ts +0 -13
  12. package/components/ContextualSaveBar/ContextualSaveBar.js +0 -73
  13. package/components/ContextualSaveBar/index.d.ts +0 -3
  14. package/components/ContextualSaveBar/index.js +0 -7
  15. package/components/Loading/Loading.d.ts +0 -17
  16. package/components/Loading/Loading.js +0 -55
  17. package/components/Loading/index.d.ts +0 -2
  18. package/components/Loading/index.js +0 -7
  19. package/components/Modal/Modal.d.ts +0 -32
  20. package/components/Modal/Modal.js +0 -139
  21. package/components/Modal/ModalContent/ModalContent.d.ts +0 -22
  22. package/components/Modal/ModalContent/ModalContent.js +0 -61
  23. package/components/Modal/ModalContent/index.d.ts +0 -2
  24. package/components/Modal/ModalContent/index.js +0 -7
  25. package/components/Modal/index.d.ts +0 -4
  26. package/components/Modal/index.js +0 -10
  27. package/components/NavigationMenu/NavigationMenu.d.ts +0 -17
  28. package/components/NavigationMenu/NavigationMenu.js +0 -40
  29. package/components/NavigationMenu/index.d.ts +0 -3
  30. package/components/NavigationMenu/index.js +0 -7
  31. package/components/Provider/Provider.d.ts +0 -81
  32. package/components/Provider/Provider.js +0 -78
  33. package/components/Provider/index.d.ts +0 -3
  34. package/components/Provider/index.js +0 -7
  35. package/components/ResourcePicker/ResourcePicker.d.ts +0 -68
  36. package/components/ResourcePicker/ResourcePicker.js +0 -114
  37. package/components/ResourcePicker/index.d.ts +0 -3
  38. package/components/ResourcePicker/index.js +0 -7
  39. package/components/RoutePropagator/RoutePropagator.d.ts +0 -20
  40. package/components/RoutePropagator/RoutePropagator.js +0 -54
  41. package/components/RoutePropagator/globals.d.ts +0 -3
  42. package/components/RoutePropagator/globals.js +0 -15
  43. package/components/RoutePropagator/hook.d.ts +0 -10
  44. package/components/RoutePropagator/hook.js +0 -20
  45. package/components/RoutePropagator/index.d.ts +0 -3
  46. package/components/RoutePropagator/index.js +0 -10
  47. package/components/RoutePropagator/route-propagator.d.ts +0 -7
  48. package/components/RoutePropagator/route-propagator.js +0 -91
  49. package/components/TitleBar/TitleBar.d.ts +0 -27
  50. package/components/TitleBar/TitleBar.js +0 -108
  51. package/components/TitleBar/index.d.ts +0 -3
  52. package/components/TitleBar/index.js +0 -7
  53. package/components/Toast/Toast.d.ts +0 -31
  54. package/components/Toast/Toast.js +0 -59
  55. package/components/Toast/index.d.ts +0 -3
  56. package/components/Toast/index.js +0 -7
  57. package/components/index.d.ts +0 -11
  58. package/components/index.js +0 -37
  59. package/components/unstable_Picker/index.d.ts +0 -3
  60. package/components/unstable_Picker/index.js +0 -7
  61. package/components/unstable_Picker/unstable_Picker.d.ts +0 -23
  62. package/components/unstable_Picker/unstable_Picker.js +0 -85
  63. package/context.d.ts +0 -13
  64. package/context.js +0 -10
  65. package/hooks/index.d.ts +0 -9
  66. package/hooks/index.js +0 -19
  67. package/hooks/useAppBridgeState/index.d.ts +0 -1
  68. package/hooks/useAppBridgeState/index.js +0 -13
  69. package/hooks/useAppBridgeState/useAppBridgeState.d.ts +0 -10
  70. package/hooks/useAppBridgeState/useAppBridgeState.js +0 -89
  71. package/hooks/useContextualSaveBar/index.d.ts +0 -1
  72. package/hooks/useContextualSaveBar/index.js +0 -5
  73. package/hooks/useContextualSaveBar/useContextualSaveBar.d.ts +0 -31
  74. package/hooks/useContextualSaveBar/useContextualSaveBar.js +0 -74
  75. package/hooks/useFeatureRequest/index.d.ts +0 -1
  76. package/hooks/useFeatureRequest/index.js +0 -13
  77. package/hooks/useFeatureRequest/useFeatureRequest.d.ts +0 -13
  78. package/hooks/useFeatureRequest/useFeatureRequest.js +0 -49
  79. package/hooks/useFeaturesAvailable/index.d.ts +0 -2
  80. package/hooks/useFeaturesAvailable/index.js +0 -5
  81. package/hooks/useFeaturesAvailable/useFeaturesAvailable.d.ts +0 -12
  82. package/hooks/useFeaturesAvailable/useFeaturesAvailable.js +0 -101
  83. package/hooks/useLocale/index.d.ts +0 -1
  84. package/hooks/useLocale/index.js +0 -5
  85. package/hooks/useLocale/useLocale.d.ts +0 -1
  86. package/hooks/useLocale/useLocale.js +0 -8
  87. package/hooks/useNavigate/index.d.ts +0 -1
  88. package/hooks/useNavigate/index.js +0 -5
  89. package/hooks/useNavigate/useNavigate.d.ts +0 -24
  90. package/hooks/useNavigate/useNavigate.js +0 -109
  91. package/hooks/useNavigationHistory/index.d.ts +0 -1
  92. package/hooks/useNavigationHistory/index.js +0 -5
  93. package/hooks/useNavigationHistory/useNavigationHistory.d.ts +0 -16
  94. package/hooks/useNavigationHistory/useNavigationHistory.js +0 -28
  95. package/hooks/useToast/index.d.ts +0 -1
  96. package/hooks/useToast/index.js +0 -5
  97. package/hooks/useToast/useToast.d.ts +0 -13
  98. package/hooks/useToast/useToast.js +0 -41
  99. package/index.d.ts +0 -4
  100. package/index.js +0 -19
  101. package/types.d.ts +0 -35
  102. package/types.js +0 -5
  103. package/umd/index.js +0 -14
  104. package/useAppBridge.d.ts +0 -1
  105. package/useAppBridge.js +0 -13
  106. package/utilities/transformers.d.ts +0 -20
  107. package/utilities/transformers.js +0 -105
@@ -1,91 +0,0 @@
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.updateHistory = void 0;
40
- var MessageTransport_1 = require("@shopify/app-bridge/MessageTransport");
41
- var actions_1 = require("@shopify/app-bridge/actions");
42
- var globals_1 = require("./globals");
43
- // These parameters are added to the iframe url but we don't want to propagate
44
- // them up to the address bar as they are not provided by the application
45
- // Removing hmac is especially important as its presence may cause infinite
46
- // oauth authentication loops
47
- var embeddedFrameParamsToRemove = [
48
- 'hmac',
49
- 'locale',
50
- 'protocol',
51
- 'session',
52
- 'shop',
53
- 'timestamp',
54
- 'host',
55
- ];
56
- function updateHistory(app, location) {
57
- return __awaiter(this, void 0, void 0, function () {
58
- var selfWindow, topWindow, renderedInTheTopWindow, renderedAsMainApp, normalizedLocation, pathname, search, hash, locationStr;
59
- return __generator(this, function (_a) {
60
- switch (_a.label) {
61
- case 0:
62
- selfWindow = globals_1.getSelfWindow();
63
- topWindow = globals_1.getTopWindow();
64
- renderedInTheTopWindow = selfWindow === topWindow;
65
- return [4 /*yield*/, app.getState('context').then(function (context) {
66
- return context === MessageTransport_1.Context.Main;
67
- })];
68
- case 1:
69
- renderedAsMainApp = _a.sent();
70
- if (renderedInTheTopWindow || !renderedAsMainApp) {
71
- return [2 /*return*/];
72
- }
73
- normalizedLocation = getNormalizedURL(location);
74
- embeddedFrameParamsToRemove.forEach(function (param) { return normalizedLocation.searchParams.delete(param); });
75
- pathname = normalizedLocation.pathname, search = normalizedLocation.search, hash = normalizedLocation.hash;
76
- locationStr = "" + pathname + search + hash;
77
- actions_1.History.create(app).dispatch(actions_1.History.Action.REPLACE, locationStr);
78
- return [2 /*return*/];
79
- }
80
- });
81
- });
82
- }
83
- exports.updateHistory = updateHistory;
84
- function getNormalizedURL(location) {
85
- var origin = globals_1.getOrigin();
86
- if (typeof location === 'string') {
87
- return new URL(location, origin);
88
- }
89
- var pathname = location.pathname, search = location.search, hash = location.hash;
90
- return new URL("" + pathname + search + hash, origin);
91
- }
@@ -1,27 +0,0 @@
1
- import { ActionProps, ActionGroupProps, Target } from '../../types';
2
- export interface Breadcrumb {
3
- /** Content the action displays */
4
- content?: string;
5
- /** A destination to link to */
6
- url?: string;
7
- /**
8
- * Where to display the target link
9
- * @default 'APP'
10
- */
11
- target?: Target;
12
- /** Callback when an action takes place */
13
- onAction?(): void;
14
- }
15
- export interface Props {
16
- /** TitleBar title */
17
- title: string;
18
- /** The current breadcrumb; only displays the last item in array */
19
- breadcrumbs?: Breadcrumb | Breadcrumb[];
20
- /** Primary TitleBar action */
21
- primaryAction?: ActionProps;
22
- /** Collection of secondary TitleBar actions */
23
- secondaryActions?: ActionProps[];
24
- /** Collection of TitleBar groups of secondary actions */
25
- actionGroups?: ActionGroupProps[];
26
- }
27
- export default function TitleBar(props: Props): null;
@@ -1,108 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var react_1 = require("react");
4
- var Button_1 = require("@shopify/app-bridge/actions/Button");
5
- var TitleBar_1 = require("@shopify/app-bridge/actions/TitleBar");
6
- var ButtonGroup_1 = require("@shopify/app-bridge/actions/ButtonGroup");
7
- var transformers_1 = require("../../utilities/transformers");
8
- var useAppBridge_1 = require("../../useAppBridge");
9
- function TitleBar(props) {
10
- var title = props.title;
11
- var app = useAppBridge_1.useAppBridge();
12
- var currentProps = react_1.useRef({ title: title });
13
- var titleBar = react_1.useMemo(function () {
14
- /**
15
- * We purposely don't pass buttons here as they will be replaced
16
- * by the subsequent useEffect to call `set` to update the options.
17
- * If we pass them in here button subscriptions will be created without
18
- * being cleaned up.
19
- */
20
- return TitleBar_1.create(app, {});
21
- }, [app]);
22
- /**
23
- * All option updates are handled in this useEffect so they can be cleaned up.
24
- */
25
- react_1.useEffect(function () {
26
- var _a;
27
- var propsChanged = JSON.stringify(currentProps.current) !== JSON.stringify(props);
28
- currentProps.current = props;
29
- if (propsChanged) {
30
- titleBar.set(transformProps(app, props));
31
- }
32
- else {
33
- /**
34
- * We manually update the button callbacks when no props have changed aside from the
35
- * callbacks to avoid sending an unnecessary UPDATE action to the host
36
- */
37
- var primaryAction = props.primaryAction, secondaryActions = props.secondaryActions, actionGroups = props.actionGroups, breadcrumbs = props.breadcrumbs;
38
- var breadcrumb = Array.isArray(breadcrumbs)
39
- ? breadcrumbs[breadcrumbs.length - 1]
40
- : breadcrumbs;
41
- updateButton(breadcrumb, titleBar.options.breadcrumbs);
42
- updateButton(primaryAction, (_a = titleBar.options.buttons) === null || _a === void 0 ? void 0 : _a.primary);
43
- updateSecondaryActions(titleBar, secondaryActions);
44
- updateActionGroups(titleBar, actionGroups);
45
- }
46
- return function () {
47
- titleBar.unsubscribe();
48
- };
49
- }, [titleBar, props]);
50
- return null;
51
- }
52
- exports.default = TitleBar;
53
- function updateSecondaryActions(titleBar, secondaryActions) {
54
- var _a, _b;
55
- var secondaryButtons = ((_b = (_a = titleBar.options.buttons) === null || _a === void 0 ? void 0 : _a.secondary) === null || _b === void 0 ? void 0 : _b.filter(function (button) { return !ButtonGroup_1.isGroupedButton(button); })) || [];
56
- secondaryButtons === null || secondaryButtons === void 0 ? void 0 : secondaryButtons.forEach(function (secondaryButton, index) {
57
- return updateButton(secondaryActions === null || secondaryActions === void 0 ? void 0 : secondaryActions[index],
58
- // This needs to be casted as the React TitleBar component doesn't accept button groups for secondary actions
59
- secondaryButton);
60
- });
61
- }
62
- function updateActionGroups(titleBar, actionGroups) {
63
- var _a, _b;
64
- var actionGroupButtons = ((_b = (_a = titleBar.options.buttons) === null || _a === void 0 ? void 0 : _a.secondary) === null || _b === void 0 ? void 0 : _b.filter(ButtonGroup_1.isGroupedButton)) ||
65
- [];
66
- actionGroupButtons === null || actionGroupButtons === void 0 ? void 0 : actionGroupButtons.forEach(function (actionBroupButton, index) {
67
- var actionGroup = actionGroups === null || actionGroups === void 0 ? void 0 : actionGroups[index];
68
- if (!actionGroup) {
69
- return;
70
- }
71
- actionBroupButton.options.buttons.forEach(function (nestedButton, nestedIndex) {
72
- return updateButton(actionGroup.actions[nestedIndex], nestedButton);
73
- });
74
- });
75
- }
76
- function transformProps(app, _a) {
77
- var actionGroups = _a.actionGroups, breadcrumbs = _a.breadcrumbs, primaryAction = _a.primaryAction, secondaryActions = _a.secondaryActions, title = _a.title;
78
- var breadcrumb = Array.isArray(breadcrumbs) ? breadcrumbs[breadcrumbs.length - 1] : breadcrumbs;
79
- return {
80
- title: title,
81
- buttons: transformers_1.transformActions(app, {
82
- primaryAction: primaryAction,
83
- secondaryActions: secondaryActions,
84
- actionGroups: actionGroups,
85
- }),
86
- breadcrumbs: breadcrumb ? transformBreadcrumb(app, breadcrumb) : undefined,
87
- };
88
- }
89
- function transformBreadcrumb(app, breadcrumb, updateBreadcrumb) {
90
- var button = updateBreadcrumb ||
91
- Button_1.create(app, {
92
- label: breadcrumb.content || '',
93
- });
94
- updateButton(breadcrumb, button);
95
- return button;
96
- }
97
- function updateButton(actionProps, button) {
98
- if (!actionProps || !button) {
99
- return;
100
- }
101
- var redirect = transformers_1.generateRedirect(button.app, actionProps.url, actionProps.target, actionProps.external);
102
- if (redirect) {
103
- button.subscribe(Button_1.Action.CLICK, redirect, button);
104
- }
105
- if (actionProps === null || actionProps === void 0 ? void 0 : actionProps.onAction) {
106
- button.subscribe(Button_1.Action.CLICK, actionProps.onAction, button);
107
- }
108
- }
@@ -1,3 +0,0 @@
1
- import TitleBar from './TitleBar';
2
- export { Props } from './TitleBar';
3
- export default TitleBar;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var TitleBar_1 = __importDefault(require("./TitleBar"));
7
- exports.default = TitleBar_1.default;
@@ -1,31 +0,0 @@
1
- import React from 'react';
2
- export interface Props {
3
- /** The content that should appear in the toast message */
4
- content: string;
5
- /**
6
- * The length of time in milliseconds the toast message should persist
7
- * @default 5000
8
- */
9
- duration?: number;
10
- /** Display an error toast. */
11
- error?: boolean;
12
- /** Callback when the dismiss icon is clicked */
13
- onDismiss(): void;
14
- }
15
- export declare const DEFAULT_TOAST_DURATION = 5000;
16
- /**
17
- * Toast component
18
- *
19
- * @remarks
20
- * React component which wraps the Shopify App Bridge Toast action.
21
- *
22
- * @public
23
- */
24
- declare class Toast extends React.PureComponent<Props, never> {
25
- static contextType: React.Context<import("../../context").IAppBridgeContext>;
26
- private toast;
27
- componentDidMount(): void;
28
- componentWillUnmount(): void;
29
- render(): null;
30
- }
31
- export default Toast;
@@ -1,59 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __importDefault = (this && this.__importDefault) || function (mod) {
18
- return (mod && mod.__esModule) ? mod : { "default": mod };
19
- };
20
- Object.defineProperty(exports, "__esModule", { value: true });
21
- exports.DEFAULT_TOAST_DURATION = void 0;
22
- var react_1 = __importDefault(require("react"));
23
- var actions_1 = require("@shopify/app-bridge/actions");
24
- var context_1 = require("../../context");
25
- exports.DEFAULT_TOAST_DURATION = 5000;
26
- /**
27
- * Toast component
28
- *
29
- * @remarks
30
- * React component which wraps the Shopify App Bridge Toast action.
31
- *
32
- * @public
33
- */
34
- var Toast = /** @class */ (function (_super) {
35
- __extends(Toast, _super);
36
- function Toast() {
37
- return _super !== null && _super.apply(this, arguments) || this;
38
- }
39
- Toast.prototype.componentDidMount = function () {
40
- var app = this.context;
41
- var _a = this.props, error = _a.error, content = _a.content, _b = _a.duration, duration = _b === void 0 ? exports.DEFAULT_TOAST_DURATION : _b, onDismiss = _a.onDismiss;
42
- this.toast = actions_1.Toast.create(app, {
43
- message: content,
44
- duration: duration,
45
- isError: error,
46
- });
47
- this.toast.subscribe(actions_1.Toast.Action.CLEAR, onDismiss);
48
- this.toast.dispatch(actions_1.Toast.Action.SHOW);
49
- };
50
- Toast.prototype.componentWillUnmount = function () {
51
- this.toast.unsubscribe();
52
- };
53
- Toast.prototype.render = function () {
54
- return null;
55
- };
56
- Toast.contextType = context_1.AppBridgeContext;
57
- return Toast;
58
- }(react_1.default.PureComponent));
59
- exports.default = Toast;
@@ -1,3 +0,0 @@
1
- import Toast from './Toast';
2
- export { Props } from './Toast';
3
- export default Toast;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var Toast_1 = __importDefault(require("./Toast"));
7
- exports.default = Toast_1.default;
@@ -1,11 +0,0 @@
1
- export { default as ContextualSaveBar, Props as ContextualSaveBarProps } from './ContextualSaveBar';
2
- export { default as Loading } from './Loading';
3
- export { default as Modal, Props as ModalProps, ModalContent } from './Modal';
4
- export { default as NavigationMenu, Props as NavigationMenuProps } from './NavigationMenu';
5
- export { default as Provider, Props as ProviderProps } from './Provider';
6
- export { default as ResourcePicker, Props as ResourcePickerProps } from './ResourcePicker';
7
- export { default as TitleBar } from './TitleBar';
8
- export { default as Toast, Props as ToastProps } from './Toast';
9
- export { default as unstable_Picker } from './unstable_Picker';
10
- export * from './RoutePropagator';
11
- export * from './ClientRouter';
@@ -1,37 +0,0 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- var __importDefault = (this && this.__importDefault) || function (mod) {
13
- return (mod && mod.__esModule) ? mod : { "default": mod };
14
- };
15
- Object.defineProperty(exports, "__esModule", { value: true });
16
- exports.unstable_Picker = exports.Toast = exports.TitleBar = exports.ResourcePicker = exports.Provider = exports.NavigationMenu = exports.ModalContent = exports.Modal = exports.Loading = exports.ContextualSaveBar = void 0;
17
- var ContextualSaveBar_1 = require("./ContextualSaveBar");
18
- Object.defineProperty(exports, "ContextualSaveBar", { enumerable: true, get: function () { return __importDefault(ContextualSaveBar_1).default; } });
19
- var Loading_1 = require("./Loading");
20
- Object.defineProperty(exports, "Loading", { enumerable: true, get: function () { return __importDefault(Loading_1).default; } });
21
- var Modal_1 = require("./Modal");
22
- Object.defineProperty(exports, "Modal", { enumerable: true, get: function () { return __importDefault(Modal_1).default; } });
23
- Object.defineProperty(exports, "ModalContent", { enumerable: true, get: function () { return Modal_1.ModalContent; } });
24
- var NavigationMenu_1 = require("./NavigationMenu");
25
- Object.defineProperty(exports, "NavigationMenu", { enumerable: true, get: function () { return __importDefault(NavigationMenu_1).default; } });
26
- var Provider_1 = require("./Provider");
27
- Object.defineProperty(exports, "Provider", { enumerable: true, get: function () { return __importDefault(Provider_1).default; } });
28
- var ResourcePicker_1 = require("./ResourcePicker");
29
- Object.defineProperty(exports, "ResourcePicker", { enumerable: true, get: function () { return __importDefault(ResourcePicker_1).default; } });
30
- var TitleBar_1 = require("./TitleBar");
31
- Object.defineProperty(exports, "TitleBar", { enumerable: true, get: function () { return __importDefault(TitleBar_1).default; } });
32
- var Toast_1 = require("./Toast");
33
- Object.defineProperty(exports, "Toast", { enumerable: true, get: function () { return __importDefault(Toast_1).default; } });
34
- var unstable_Picker_1 = require("./unstable_Picker");
35
- Object.defineProperty(exports, "unstable_Picker", { enumerable: true, get: function () { return __importDefault(unstable_Picker_1).default; } });
36
- __exportStar(require("./RoutePropagator"), exports);
37
- __exportStar(require("./ClientRouter"), exports);
@@ -1,3 +0,0 @@
1
- import Picker from './unstable_Picker';
2
- export { Props } from './unstable_Picker';
3
- export default Picker;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- var unstable_Picker_1 = __importDefault(require("./unstable_Picker"));
7
- exports.default = unstable_Picker_1.default;
@@ -1,23 +0,0 @@
1
- import { SearchPayload, SelectPayload, EmptySearchLabel } from '@shopify/app-bridge/actions/Picker';
2
- import type { BaseResource } from '@shopify/app-bridge/actions/Picker';
3
- /**
4
- * @unstable This API may be updated without warning in the future
5
- */
6
- export interface Props {
7
- open: boolean;
8
- items: BaseResource[];
9
- selectedItems?: BaseResource[];
10
- maxSelectable?: number;
11
- title?: string;
12
- loading?: boolean;
13
- searchQueryPlaceholder?: string;
14
- searchQuery?: string;
15
- primaryActionLabel?: string;
16
- secondaryActionLabel?: string;
17
- emptySearchLabel?: EmptySearchLabel;
18
- onCancel?(): void;
19
- onSelect?(selectPayload: SelectPayload): void;
20
- onSearch?(searchPayload: SearchPayload): void;
21
- onLoadMore?(): void;
22
- }
23
- export default function Picker(props: Props): null;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- var react_1 = require("react");
15
- var Picker_1 = require("@shopify/app-bridge/actions/Picker");
16
- var useAppBridge_1 = require("../../useAppBridge");
17
- function Picker(props) {
18
- var app = useAppBridge_1.useAppBridge();
19
- var prevProps = react_1.useRef({ open: false });
20
- var picker = react_1.useMemo(function () { return Picker_1.create(app, getActionOptions(props)); }, [app]);
21
- react_1.useEffect(function () {
22
- var _a;
23
- if (!props.open && ((_a = prevProps.current) === null || _a === void 0 ? void 0 : _a.open) === props.open) {
24
- return;
25
- }
26
- if (props.open) {
27
- picker.dispatch(Picker_1.Action.OPEN);
28
- }
29
- else {
30
- picker.dispatch(Picker_1.Action.CANCEL);
31
- }
32
- }, [props.open]);
33
- react_1.useEffect(function () {
34
- var unsubscribeList = [];
35
- if (props.onSelect) {
36
- unsubscribeList.push(picker.subscribe(Picker_1.Action.SELECT, props.onSelect));
37
- }
38
- if (props.onCancel) {
39
- unsubscribeList.push(picker.subscribe(Picker_1.Action.CANCEL, props.onCancel));
40
- }
41
- if (props.onSearch) {
42
- unsubscribeList.push(picker.subscribe(Picker_1.Action.SEARCH, props.onSearch));
43
- }
44
- if (props.onLoadMore) {
45
- unsubscribeList.push(picker.subscribe(Picker_1.Action.LOAD_MORE, props.onLoadMore));
46
- }
47
- return function () {
48
- unsubscribeList.forEach(function (unsubscribe) { return unsubscribe(); });
49
- };
50
- }, [props.onSelect, props.onCancel, props.onSearch]);
51
- react_1.useEffect(function () {
52
- var shouldUpdate = JSON.stringify(__assign(__assign({}, prevProps.current), { open: undefined })) !==
53
- JSON.stringify(__assign(__assign({}, props), { open: undefined }));
54
- if (!shouldUpdate) {
55
- return;
56
- }
57
- picker.set(getActionOptions(props));
58
- prevProps.current = props;
59
- }, [props]);
60
- react_1.useEffect(function () {
61
- return function () {
62
- if (prevProps.current.open) {
63
- picker.dispatch(Picker_1.Action.CANCEL);
64
- }
65
- };
66
- }, []);
67
- return null;
68
- }
69
- exports.default = Picker;
70
- function getActionOptions(_a) {
71
- var items = _a.items, selectedItems = _a.selectedItems, maxSelectable = _a.maxSelectable, title = _a.title, loading = _a.loading, searchQueryPlaceholder = _a.searchQueryPlaceholder, searchQuery = _a.searchQuery, primaryActionLabel = _a.primaryActionLabel, secondaryActionLabel = _a.secondaryActionLabel, emptySearchLabel = _a.emptySearchLabel;
72
- var result = {
73
- items: items,
74
- selectedItems: selectedItems,
75
- maxSelectable: maxSelectable,
76
- title: title,
77
- loading: loading,
78
- searchQueryPlaceholder: searchQueryPlaceholder,
79
- searchQuery: searchQuery,
80
- primaryActionLabel: primaryActionLabel,
81
- secondaryActionLabel: secondaryActionLabel,
82
- emptySearchLabel: emptySearchLabel,
83
- };
84
- return result;
85
- }
package/context.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import type { ClientApplication } from '@shopify/app-bridge/client';
2
- /**
3
- * App Bridge context consumer type.
4
- *
5
- * @public
6
- */
7
- export declare type IAppBridgeContext = ClientApplication | null;
8
- /**
9
- * App Bridge context.
10
- *
11
- * @public
12
- */
13
- export declare const AppBridgeContext: import("react").Context<IAppBridgeContext>;
package/context.js DELETED
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AppBridgeContext = void 0;
4
- var react_1 = require("react");
5
- /**
6
- * App Bridge context.
7
- *
8
- * @public
9
- */
10
- exports.AppBridgeContext = react_1.createContext(null);
package/hooks/index.d.ts DELETED
@@ -1,9 +0,0 @@
1
- export { useAppBridgeState } from './useAppBridgeState';
2
- export { useContextualSaveBar } from './useContextualSaveBar';
3
- export { useFeaturesAvailable } from './useFeaturesAvailable';
4
- export type { FeaturesAvailable } from './useFeaturesAvailable';
5
- export { useFeatureRequest } from './useFeatureRequest';
6
- export { useLocale } from './useLocale';
7
- export { useNavigate } from './useNavigate';
8
- export { useNavigationHistory } from './useNavigationHistory';
9
- export { useToast } from './useToast';
package/hooks/index.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useToast = exports.useNavigationHistory = exports.useNavigate = exports.useLocale = exports.useFeatureRequest = exports.useFeaturesAvailable = exports.useContextualSaveBar = exports.useAppBridgeState = void 0;
4
- var useAppBridgeState_1 = require("./useAppBridgeState");
5
- Object.defineProperty(exports, "useAppBridgeState", { enumerable: true, get: function () { return useAppBridgeState_1.useAppBridgeState; } });
6
- var useContextualSaveBar_1 = require("./useContextualSaveBar");
7
- Object.defineProperty(exports, "useContextualSaveBar", { enumerable: true, get: function () { return useContextualSaveBar_1.useContextualSaveBar; } });
8
- var useFeaturesAvailable_1 = require("./useFeaturesAvailable");
9
- Object.defineProperty(exports, "useFeaturesAvailable", { enumerable: true, get: function () { return useFeaturesAvailable_1.useFeaturesAvailable; } });
10
- var useFeatureRequest_1 = require("./useFeatureRequest");
11
- Object.defineProperty(exports, "useFeatureRequest", { enumerable: true, get: function () { return useFeatureRequest_1.useFeatureRequest; } });
12
- var useLocale_1 = require("./useLocale");
13
- Object.defineProperty(exports, "useLocale", { enumerable: true, get: function () { return useLocale_1.useLocale; } });
14
- var useNavigate_1 = require("./useNavigate");
15
- Object.defineProperty(exports, "useNavigate", { enumerable: true, get: function () { return useNavigate_1.useNavigate; } });
16
- var useNavigationHistory_1 = require("./useNavigationHistory");
17
- Object.defineProperty(exports, "useNavigationHistory", { enumerable: true, get: function () { return useNavigationHistory_1.useNavigationHistory; } });
18
- var useToast_1 = require("./useToast");
19
- Object.defineProperty(exports, "useToast", { enumerable: true, get: function () { return useToast_1.useToast; } });
@@ -1 +0,0 @@
1
- export * from './useAppBridgeState';
@@ -1,13 +0,0 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./useAppBridgeState"), exports);
@@ -1,10 +0,0 @@
1
- import type { AppBridgeState, Path, PathValue, StateWithoutFeatures } from '@shopify/app-bridge';
2
- declare type Query = keyof AppBridgeState | Path<StateWithoutFeatures<AppBridgeState>>;
3
- declare type State<K extends Query> = K extends keyof AppBridgeState ? AppBridgeState[K] : K extends Path<StateWithoutFeatures<AppBridgeState>> ? PathValue<StateWithoutFeatures<AppBridgeState>, K> : K extends never ? AppBridgeState : never;
4
- interface UseAppBridgeState {
5
- (): AppBridgeState | undefined;
6
- <K extends Query>(query: K): State<K> | undefined;
7
- <PartialState>(query: keyof AppBridgeState): PartialState | undefined;
8
- }
9
- export declare const useAppBridgeState: UseAppBridgeState;
10
- export {};