@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,17 +0,0 @@
1
- export interface NavigationLink {
2
- label: string;
3
- destination: string;
4
- }
5
- export interface Props {
6
- /**
7
- * List of links in navigation menu
8
- */
9
- navigationLinks: NavigationLink[];
10
- /**
11
- * Custom matcher to set active link.
12
- * This function will be called with each link and the current location.
13
- * If it returns true the current link will be set to the active link.
14
- */
15
- matcher?: (link: NavigationLink, location: Location) => boolean;
16
- }
17
- export default function NavigationMenu({ navigationLinks, matcher }: Props): null;
@@ -1,40 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var react_1 = require("react");
4
- var AppLink_1 = require("@shopify/app-bridge/actions/Link/AppLink");
5
- var NavigationMenu_1 = require("@shopify/app-bridge/actions/Menu/NavigationMenu");
6
- var useAppBridge_1 = require("../../useAppBridge");
7
- function defaultMatcher(link, location) {
8
- return link.destination.replace(/\/$/, '') === location.pathname.replace(/\/$/, '');
9
- }
10
- function NavigationMenu(_a) {
11
- var navigationLinks = _a.navigationLinks, _b = _a.matcher, matcher = _b === void 0 ? defaultMatcher : _b;
12
- var app = useAppBridge_1.useAppBridge();
13
- var _c = react_1.useState(), items = _c[0], setItems = _c[1];
14
- react_1.useEffect(function () {
15
- var items = navigationLinks.map(function (link) { return AppLink_1.create(app, link); });
16
- setItems(items);
17
- }, [app, JSON.stringify(navigationLinks)]);
18
- var activeLink = react_1.useMemo(function () {
19
- var activeLinkIndex = (items || []).findIndex(function (link) {
20
- return matcher(link, location);
21
- });
22
- if (activeLinkIndex >= 0) {
23
- return items === null || items === void 0 ? void 0 : items[activeLinkIndex];
24
- }
25
- }, [app, location.pathname, matcher, items, location.pathname]);
26
- react_1.useEffect(function () {
27
- // Skip creating the navigation menu on initial render
28
- if (!items) {
29
- return;
30
- }
31
- /**
32
- * There isn't any advantage to keeping around a consistent instance of
33
- * the navigation menu as when we create a new one it results in
34
- * the same UPDATE action to be dispatched
35
- */
36
- NavigationMenu_1.create(app, { items: items, active: activeLink });
37
- }, [items, activeLink]);
38
- return null;
39
- }
40
- exports.default = NavigationMenu;
@@ -1,3 +0,0 @@
1
- import NavigationMenu from './NavigationMenu';
2
- export { Props } from './NavigationMenu';
3
- export default NavigationMenu;
@@ -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 NavigationMenu_1 = __importDefault(require("./NavigationMenu"));
7
- exports.default = NavigationMenu_1.default;
@@ -1,81 +0,0 @@
1
- import React, { PropsWithChildren } from 'react';
2
- import type { AppConfigV2, DispatchActionHook } from '@shopify/app-bridge/client';
3
- import type { History } from '../ClientRouter';
4
- import type { LocationOrHref } from '../RoutePropagator';
5
- /**
6
- * Provider props
7
- *
8
- * @public
9
- */
10
- export interface Props {
11
- /** Application configuration */
12
- config: AppConfigV2;
13
- /** The child elements to render. */
14
- children?: React.ReactNode;
15
- /**
16
- * Option to set up client routing and route propagation automatically.
17
- * Passing in a router will allow you to bypass setting these
18
- * utilities up yourself.
19
- *
20
- * If you are using React Router, ensure that the Provider is a child
21
- * of the router component. For example:
22
- *
23
- * import {useMemo} from 'react';
24
- * import {useLocation, useNavigate, BrowserRouter} from 'react-router-dom';
25
- * import {Provider} from '@shopify/app-bridge-react';
26
- * import Routes from './Routes';
27
- *
28
- * export function App() {
29
- * const navigate = useNavigate();
30
- * const location = useLocation();
31
- * const history = useMemo(
32
- * () => ({replace: (path: string) => navigate(path, {replace: true})}),
33
- * [navigate],
34
- * );
35
- * const router = useMemo(
36
- * () => ({
37
- * location,
38
- * history,
39
- * }),
40
- * [location, navigate],
41
- * );
42
- * return (
43
- * <Provider
44
- * apiKey={{
45
- * apiKey: 'API key from Shopify Partner Dashboard',
46
- * host: host,
47
- * }}
48
- * router={router}
49
- * >
50
- * <Routes />
51
- * </Provider>
52
- * );
53
- * }
54
- *
55
- * export default function AppWrapper() {
56
- * return (
57
- * <BrowserRouter>
58
- * <App />
59
- * </BrowserRouter>
60
- * );
61
- * }
62
- */
63
- router?: {
64
- location: LocationOrHref;
65
- history: History;
66
- };
67
- }
68
- /**
69
- * Create an App Bridge client application from a config and pass it as the
70
- * value to the context provider.
71
- *
72
- * @public
73
- */
74
- declare function Provider({ config, router, children }: PropsWithChildren<Props>): JSX.Element;
75
- /**
76
- * Augment actions with clientInterface metadata, identifying use of this library
77
- *
78
- * @internal
79
- */
80
- export declare const setClientInterfaceHook: DispatchActionHook;
81
- export default Provider;
@@ -1,78 +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 __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
- Object.defineProperty(exports, "__esModule", { value: true });
22
- exports.setClientInterfaceHook = void 0;
23
- var react_1 = __importStar(require("react"));
24
- var app_bridge_1 = __importStar(require("@shopify/app-bridge"));
25
- var context_1 = require("../../context");
26
- var ClientRouter_1 = require("../ClientRouter");
27
- var RoutePropagator_1 = require("../RoutePropagator");
28
- // eslint-disable-next-line @typescript-eslint/no-var-requires
29
- var packageJson = require('../../package.json');
30
- /**
31
- * Create an App Bridge client application from a config and pass it as the
32
- * value to the context provider.
33
- *
34
- * @public
35
- */
36
- function Provider(_a) {
37
- var config = _a.config, router = _a.router, children = _a.children;
38
- /**
39
- * We are intentionally ignoring the `config` prop here as it yields a
40
- * bug on apps build with Next.js which loses the `host` query param
41
- * upon redirect.
42
- *
43
- * This was the behavior of the original `Provider` component prior to
44
- * the refactor in version 2.0.25.
45
- */
46
- var app = react_1.useMemo(function () { return app_bridge_1.default(config); }, []);
47
- react_1.useEffect(function () {
48
- if (app === null || app === void 0 ? void 0 : app.hooks) {
49
- app.hooks.set(app_bridge_1.LifecycleHook.DispatchAction, exports.setClientInterfaceHook);
50
- }
51
- }, [app]);
52
- var routerMarkup = (router === null || router === void 0 ? void 0 : router.history) && (router === null || router === void 0 ? void 0 : router.location) ? (react_1.default.createElement(Router, { history: router.history, location: router.location })) : null;
53
- return (react_1.default.createElement(context_1.AppBridgeContext.Provider, { value: app },
54
- routerMarkup,
55
- children));
56
- }
57
- /**
58
- * Augment actions with clientInterface metadata, identifying use of this library
59
- *
60
- * @internal
61
- */
62
- var setClientInterfaceHook = function (next) {
63
- return function (action) {
64
- action.clientInterface = {
65
- name: '@shopify/app-bridge-react',
66
- version: packageJson.version,
67
- };
68
- return next(action);
69
- };
70
- };
71
- exports.setClientInterfaceHook = setClientInterfaceHook;
72
- function Router(_a) {
73
- var history = _a.history, location = _a.location;
74
- ClientRouter_1.useClientRouting(history);
75
- RoutePropagator_1.useRoutePropagation(location);
76
- return null;
77
- }
78
- exports.default = Provider;
@@ -1,3 +0,0 @@
1
- import Provider from './Provider';
2
- export { Props } from './Provider';
3
- export default Provider;
@@ -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 Provider_1 = __importDefault(require("./Provider"));
7
- exports.default = Provider_1.default;
@@ -1,68 +0,0 @@
1
- import { ActionVerb, ResourceType } from '@shopify/app-bridge/actions/ResourcePicker';
2
- import type { BaseResource, Options, ResourceSelection, ProductOptions } from '@shopify/app-bridge/actions/ResourcePicker';
3
- export interface SelectPayload {
4
- /** The selected resources
5
- * @see {@link https://help.shopify.com/en/api/embedded-apps/app-bridge/actions/resourcepicker|resource picker documentation} for more information
6
- */
7
- selection: ResourceSelection[];
8
- }
9
- interface BaseProps {
10
- /** Whether the picker is open or not */
11
- open: boolean;
12
- /** GraphQL initial search query for filtering resources available in the picker
13
- * @see {@link https://help.shopify.com/en/api/getting-started/search-syntax|search syntax} for more information
14
- */
15
- initialQuery?: string;
16
- /** Resources that should already be selected when the picker is opened */
17
- initialSelectionIds?: BaseResource[];
18
- /** Show products that are not published on the Online Store */
19
- showHidden?: boolean;
20
- /**
21
- * @deprecated as of 1.28.0
22
- */
23
- /** Whether to allow selection of multiple items */
24
- allowMultiple?: boolean;
25
- /** Whether to allow selection of multiple items, or the maximum number of selected items */
26
- selectMultiple?: boolean | number;
27
- /** Override default action verb `Add`. The actionVerb appears in the title `<actionVerb>` `<resourceType>` and as the primary action of the resource picker. */
28
- actionVerb?: ActionVerb;
29
- /** Callback when a selection has been made */
30
- onSelection?(selectPayload: SelectPayload): void;
31
- /** Callback when the picker is closed without selection */
32
- onCancel?(): void;
33
- }
34
- export interface ProductPickerProps extends BaseProps {
35
- /** The type of resource you want to pick */
36
- resourceType: 'Product';
37
- /** Whether to show product variants or not. Only applies to the product resource type picker */
38
- showVariants?: boolean;
39
- /** Whether to show draft products or not. Only applies to the product resource type picker */
40
- showDraft?: boolean;
41
- /** Whether to show archived products or not. Only applies to the product resource type picker */
42
- showArchived?: boolean;
43
- /** Whether to show draft badge for draft products or not. Only works when `showDraft` prop is set, and only applies to the product resource type picker */
44
- showDraftBadge?: boolean;
45
- /** Whether to show archived badge for archived products or not. Only works when `showArchived` prop is set, and only applies to the product resource type picker */
46
- showArchivedBadge?: boolean;
47
- }
48
- export interface ProductVariantProps extends BaseProps {
49
- /** The type of resource you want to pick */
50
- resourceType: 'ProductVariant';
51
- }
52
- export interface CollectionPickerProps extends BaseProps {
53
- /** The type of resource you want to pick */
54
- resourceType: 'Collection';
55
- }
56
- export declare type Props = ProductPickerProps | ProductVariantProps | CollectionPickerProps;
57
- /**
58
- * ResourcePicker component
59
- *
60
- * @remarks
61
- * React component which wraps the Shopify App Bridge ResourcePicker action.
62
- *
63
- * @public
64
- */
65
- declare function ResourcePicker(props: Props): null;
66
- export default ResourcePicker;
67
- export type { BaseResource, Options, ProductOptions };
68
- export { ActionVerb, ResourceType };
@@ -1,114 +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
- exports.ResourceType = exports.ActionVerb = void 0;
15
- var react_1 = require("react");
16
- var ResourcePicker_1 = require("@shopify/app-bridge/actions/ResourcePicker");
17
- Object.defineProperty(exports, "ActionVerb", { enumerable: true, get: function () { return ResourcePicker_1.ActionVerb; } });
18
- Object.defineProperty(exports, "ResourceType", { enumerable: true, get: function () { return ResourcePicker_1.ResourceType; } });
19
- var useAppBridge_1 = require("../../useAppBridge");
20
- /**
21
- * ResourcePicker component
22
- *
23
- * @remarks
24
- * React component which wraps the Shopify App Bridge ResourcePicker action.
25
- *
26
- * @public
27
- */
28
- function ResourcePicker(props) {
29
- var app = useAppBridge_1.useAppBridge();
30
- var focusReturnPoint = react_1.useRef(null);
31
- var resourceType = props.resourceType, onSelection = props.onSelection, onCancel = props.onCancel, open = props.open;
32
- // Initialize with open: false so the open action will dispatch on initial load
33
- var prevProps = react_1.useRef({ open: false });
34
- var picker = react_1.useMemo(function () {
35
- return ResourcePicker_1.create(app, {
36
- resourceType: ResourcePicker_1.ResourceType[resourceType],
37
- options: getActionOptions(props),
38
- });
39
- // We purposely want to reuse the same picker instance
40
- // and use a useEffect to call `picker.set` when needed
41
- }, [app]);
42
- react_1.useEffect(function () {
43
- var _a;
44
- var wasOpen = (_a = prevProps.current) === null || _a === void 0 ? void 0 : _a.open;
45
- if (wasOpen !== open) {
46
- if (open) {
47
- picker.dispatch(ResourcePicker_1.Action.OPEN);
48
- }
49
- else {
50
- picker.dispatch(ResourcePicker_1.Action.CLOSE);
51
- }
52
- }
53
- if (!wasOpen && open) {
54
- focusReturnPoint.current = document.activeElement;
55
- }
56
- else if (wasOpen &&
57
- !open &&
58
- focusReturnPoint.current != null &&
59
- document.contains(focusReturnPoint.current)) {
60
- focusReturnPoint.current.focus();
61
- focusReturnPoint.current = null;
62
- }
63
- }, [open]);
64
- react_1.useEffect(function () {
65
- var unsubscribeList = [];
66
- if (onSelection != null) {
67
- unsubscribeList.push(picker.subscribe(ResourcePicker_1.Action.SELECT, onSelection));
68
- }
69
- if (onCancel != null) {
70
- unsubscribeList.push(picker.subscribe(ResourcePicker_1.Action.CANCEL, onCancel));
71
- }
72
- return function () {
73
- var unsubscribe = unsubscribeList.pop();
74
- while (unsubscribe) {
75
- unsubscribe();
76
- unsubscribe = unsubscribeList.pop();
77
- }
78
- };
79
- }, [onSelection, onCancel]);
80
- react_1.useEffect(function () {
81
- var shouldUpdate = JSON.stringify(__assign(__assign({}, prevProps.current), { open: undefined })) !==
82
- JSON.stringify(__assign(__assign({}, props), { open: undefined }));
83
- if (!shouldUpdate) {
84
- return;
85
- }
86
- picker.set(getActionOptions(props));
87
- prevProps.current = props;
88
- }, [props]);
89
- return null;
90
- }
91
- function getActionOptions(props) {
92
- var initialQuery = props.initialQuery, initialSelectionIds = props.initialSelectionIds, showHidden = props.showHidden, allowMultiple = props.allowMultiple, selectMultiple = props.selectMultiple, actionVerb = props.actionVerb;
93
- var sharedOptions = {
94
- initialQuery: initialQuery,
95
- initialSelectionIds: initialSelectionIds,
96
- showHidden: showHidden,
97
- selectMultiple: selectMultiple !== null && selectMultiple !== void 0 ? selectMultiple : allowMultiple,
98
- actionVerb: actionVerb,
99
- };
100
- var result = sharedOptions;
101
- if (props.resourceType === 'Product') {
102
- var showVariants = props.showVariants, showDraft = props.showDraft, showArchived = props.showArchived, showDraftBadge = props.showDraftBadge, showArchivedBadge = props.showArchivedBadge;
103
- var productSpecificOptions = {
104
- showVariants: showVariants,
105
- showDraft: showDraft,
106
- showArchived: showArchived,
107
- showDraftBadge: showDraftBadge,
108
- showArchivedBadge: showArchivedBadge,
109
- };
110
- result = __assign(__assign({}, sharedOptions), productSpecificOptions);
111
- }
112
- return result;
113
- }
114
- exports.default = ResourcePicker;
@@ -1,3 +0,0 @@
1
- import ResourcePicker from './ResourcePicker';
2
- export { Props } from './ResourcePicker';
3
- export default ResourcePicker;
@@ -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 ResourcePicker_1 = __importDefault(require("./ResourcePicker"));
7
- exports.default = ResourcePicker_1.default;
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import { LocationOrHref } from './route-propagator';
3
- export interface Props {
4
- location: LocationOrHref;
5
- }
6
- /**
7
- * RoutePropagator component
8
- *
9
- * @remarks
10
- * React component which keeps the Shopify admin url in sync with the app url
11
- *
12
- * @public
13
- */
14
- declare class RoutePropagator extends React.Component<Props, never> {
15
- static contextType: React.Context<import("../../context").IAppBridgeContext>;
16
- componentDidMount(): void;
17
- componentDidUpdate({ location: prevLocation }: Props): void;
18
- render(): null;
19
- }
20
- export default RoutePropagator;
@@ -1,54 +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
- var react_1 = __importDefault(require("react"));
22
- var context_1 = require("../../context");
23
- var route_propagator_1 = require("./route-propagator");
24
- /**
25
- * RoutePropagator component
26
- *
27
- * @remarks
28
- * React component which keeps the Shopify admin url in sync with the app url
29
- *
30
- * @public
31
- */
32
- var RoutePropagator = /** @class */ (function (_super) {
33
- __extends(RoutePropagator, _super);
34
- function RoutePropagator() {
35
- return _super !== null && _super.apply(this, arguments) || this;
36
- }
37
- RoutePropagator.prototype.componentDidMount = function () {
38
- var location = this.props.location;
39
- route_propagator_1.updateHistory(this.context, location);
40
- };
41
- RoutePropagator.prototype.componentDidUpdate = function (_a) {
42
- var prevLocation = _a.location;
43
- var location = this.props.location;
44
- if (location !== prevLocation) {
45
- route_propagator_1.updateHistory(this.context, location);
46
- }
47
- };
48
- RoutePropagator.prototype.render = function () {
49
- return null;
50
- };
51
- RoutePropagator.contextType = context_1.AppBridgeContext;
52
- return RoutePropagator;
53
- }(react_1.default.Component));
54
- exports.default = RoutePropagator;
@@ -1,3 +0,0 @@
1
- export declare function getSelfWindow(): Window & typeof globalThis;
2
- export declare function getTopWindow(): Window;
3
- export declare function getOrigin(): string;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getOrigin = exports.getTopWindow = exports.getSelfWindow = void 0;
4
- function getSelfWindow() {
5
- return window.self;
6
- }
7
- exports.getSelfWindow = getSelfWindow;
8
- function getTopWindow() {
9
- return window.top;
10
- }
11
- exports.getTopWindow = getTopWindow;
12
- function getOrigin() {
13
- return location.origin;
14
- }
15
- exports.getOrigin = getOrigin;
@@ -1,10 +0,0 @@
1
- import { LocationOrHref } from './route-propagator';
2
- /**
3
- * useRoutePropagation
4
- *
5
- * @remarks
6
- * A hook which keeps the Shopify admin url in sync with the app url
7
- *
8
- * @public
9
- */
10
- export default function useRoutePropagation(location: LocationOrHref): void;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var react_1 = require("react");
4
- var useAppBridge_1 = require("../../useAppBridge");
5
- var route_propagator_1 = require("./route-propagator");
6
- /**
7
- * useRoutePropagation
8
- *
9
- * @remarks
10
- * A hook which keeps the Shopify admin url in sync with the app url
11
- *
12
- * @public
13
- */
14
- function useRoutePropagation(location) {
15
- var app = useAppBridge_1.useAppBridge();
16
- react_1.useEffect(function () {
17
- route_propagator_1.updateHistory(app, location);
18
- }, [app, location]);
19
- }
20
- exports.default = useRoutePropagation;
@@ -1,3 +0,0 @@
1
- export { default as RoutePropagator } from './RoutePropagator';
2
- export { default as useRoutePropagation } from './hook';
3
- export { LocationOrHref } from './route-propagator';
@@ -1,10 +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
- exports.useRoutePropagation = exports.RoutePropagator = void 0;
7
- var RoutePropagator_1 = require("./RoutePropagator");
8
- Object.defineProperty(exports, "RoutePropagator", { enumerable: true, get: function () { return __importDefault(RoutePropagator_1).default; } });
9
- var hook_1 = require("./hook");
10
- Object.defineProperty(exports, "useRoutePropagation", { enumerable: true, get: function () { return __importDefault(hook_1).default; } });
@@ -1,7 +0,0 @@
1
- import type { ClientApplication } from '@shopify/app-bridge';
2
- export declare type LocationOrHref = string | {
3
- search: string;
4
- hash: string;
5
- pathname: string;
6
- };
7
- export declare function updateHistory(app: ClientApplication, location: LocationOrHref): Promise<void>;