@shopify/app-bridge-react 4.1.7 → 4.1.9
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.
- package/CHANGELOG.md +15 -0
- package/build/cjs/components/Modal.cjs +104 -0
- package/build/cjs/components/NavMenu.cjs +13 -0
- package/build/cjs/components/SaveBar.cjs +67 -0
- package/build/cjs/components/TitleBar.cjs +14 -0
- package/build/cjs/hooks/useAppBridge.cjs +49 -0
- package/build/cjs/index.cjs +17 -0
- package/build/esm/components/Modal.js +96 -0
- package/build/esm/components/NavMenu.js +9 -0
- package/build/esm/components/SaveBar.js +63 -0
- package/build/esm/components/TitleBar.js +10 -0
- package/build/esm/hooks/useAppBridge.js +45 -0
- package/build/esm/index.js +5 -0
- package/build/esnext/components/Modal.esnext +96 -0
- package/build/esnext/components/NavMenu.esnext +9 -0
- package/build/esnext/components/SaveBar.esnext +63 -0
- package/build/esnext/components/TitleBar.esnext +10 -0
- package/build/esnext/hooks/useAppBridge.esnext +45 -0
- package/build/esnext/index.esnext +5 -0
- package/build/types/cjs/components/Modal.d.cts +38 -0
- package/build/types/cjs/components/Modal.d.cts.map +1 -0
- package/build/types/cjs/components/NavMenu.d.cts +23 -0
- package/build/types/cjs/components/NavMenu.d.cts.map +1 -0
- package/build/types/cjs/components/SaveBar.d.cts +37 -0
- package/build/types/cjs/components/SaveBar.d.cts.map +1 -0
- package/build/types/cjs/components/TitleBar.d.cts +24 -0
- package/build/types/cjs/components/TitleBar.d.cts.map +1 -0
- package/build/types/cjs/hooks/useAppBridge.d.cts +28 -0
- package/build/types/cjs/hooks/useAppBridge.d.cts.map +1 -0
- package/build/types/cjs/index.d.cts +12 -0
- package/build/types/cjs/index.d.cts.map +1 -0
- package/build/types/esm/components/Modal.d.ts +38 -0
- package/build/types/esm/components/Modal.d.ts.map +1 -0
- package/build/types/esm/components/NavMenu.d.ts +23 -0
- package/build/types/esm/components/NavMenu.d.ts.map +1 -0
- package/build/types/esm/components/SaveBar.d.ts +37 -0
- package/build/types/esm/components/SaveBar.d.ts.map +1 -0
- package/build/types/esm/components/TitleBar.d.ts +24 -0
- package/build/types/esm/components/TitleBar.d.ts.map +1 -0
- package/build/types/esm/hooks/useAppBridge.d.ts +28 -0
- package/build/types/esm/hooks/useAppBridge.d.ts.map +1 -0
- package/build/types/esm/index.d.ts +12 -0
- package/build/types/esm/index.d.ts.map +1 -0
- package/package.json +44 -33
- package/dist/index.cjs +0 -28
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -115
- package/dist/index.js +0 -740
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { forwardRef, useState, useEffect } from 'react';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This component is a wrapper around the App Bridge `ui-save-bar` element.
|
|
6
|
+
* It is used to display a contextual save bar to signal dirty state in the app.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://shopify.dev/docs/api/app-bridge-library/react-components/save-bar}
|
|
9
|
+
*/
|
|
10
|
+
const SaveBar = /*#__PURE__*/forwardRef(function InternalSaveBar({
|
|
11
|
+
open,
|
|
12
|
+
onShow,
|
|
13
|
+
onHide,
|
|
14
|
+
children,
|
|
15
|
+
...rest
|
|
16
|
+
}, forwardedRef) {
|
|
17
|
+
const [saveBar, setSaveBar] = useState();
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!saveBar) return;
|
|
20
|
+
if (open) {
|
|
21
|
+
saveBar.show();
|
|
22
|
+
} else {
|
|
23
|
+
saveBar.hide();
|
|
24
|
+
}
|
|
25
|
+
}, [saveBar, open]);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (!saveBar || !onShow) return;
|
|
28
|
+
saveBar.addEventListener('show', onShow);
|
|
29
|
+
return () => {
|
|
30
|
+
saveBar.removeEventListener('show', onShow);
|
|
31
|
+
};
|
|
32
|
+
}, [saveBar, onShow]);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (!saveBar || !onHide) return;
|
|
35
|
+
saveBar.addEventListener('hide', onHide);
|
|
36
|
+
return () => {
|
|
37
|
+
saveBar.removeEventListener('hide', onHide);
|
|
38
|
+
};
|
|
39
|
+
}, [saveBar, onHide]);
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
if (!saveBar) return;
|
|
42
|
+
return () => {
|
|
43
|
+
saveBar.hide();
|
|
44
|
+
};
|
|
45
|
+
}, [saveBar]);
|
|
46
|
+
return /*#__PURE__*/jsx("ui-save-bar", {
|
|
47
|
+
...rest,
|
|
48
|
+
ref: saveBar => {
|
|
49
|
+
setSaveBar(saveBar);
|
|
50
|
+
if (forwardedRef) {
|
|
51
|
+
if (typeof forwardedRef === 'function') {
|
|
52
|
+
forwardedRef(saveBar);
|
|
53
|
+
} else {
|
|
54
|
+
forwardedRef.current = saveBar;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
children: children
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
SaveBar.displayName = 'ui-save-bar';
|
|
62
|
+
|
|
63
|
+
export { SaveBar };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This component is a wrapper around the App Bridge `ui-title-bar` element.
|
|
3
|
+
* It is used to to populate the app title bar with button actions or the
|
|
4
|
+
* modal header and footer when used within the Modal component.
|
|
5
|
+
*
|
|
6
|
+
* @see {@link https://shopify.dev/docs/api/app-bridge-library/react-components/titlebar}
|
|
7
|
+
*/
|
|
8
|
+
const TitleBar = 'ui-title-bar';
|
|
9
|
+
|
|
10
|
+
export { TitleBar };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This proxy is used to throw a helpful error message when trying to access
|
|
3
|
+
* the `shopify` global in a server environment.
|
|
4
|
+
*/
|
|
5
|
+
const serverProxy = new Proxy({}, {
|
|
6
|
+
get(_, prop) {
|
|
7
|
+
throw Error(`shopify.${String(prop)} can't be used in a server environment. You likely need to move this code into an Effect.`);
|
|
8
|
+
}
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* This hook returns the `shopify` global variable to use
|
|
14
|
+
* App Bridge APIs such as `toast` and `resourcePicker`.
|
|
15
|
+
*
|
|
16
|
+
* @see {@link https://shopify.dev/docs/api/app-bridge-library/react-hooks/useappbridge}
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```jsx
|
|
20
|
+
* import {useAppBridge} from '@shopify/app-bridge-react';
|
|
21
|
+
* function GenerateBlogPostButton() {
|
|
22
|
+
* const shopify = useAppBridge();
|
|
23
|
+
*
|
|
24
|
+
* function generateBlogPost() {
|
|
25
|
+
* // Handle generating
|
|
26
|
+
* shopify.toast.show('Blog post template generated');
|
|
27
|
+
* }
|
|
28
|
+
*
|
|
29
|
+
* return <button onClick={generateBlogPost}>Generate Blog Post</button>;
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @returns `shopify` variable or a Proxy that throws when incorrectly accessed when not in a browser context
|
|
34
|
+
*/
|
|
35
|
+
function useAppBridge() {
|
|
36
|
+
if (typeof window === 'undefined') {
|
|
37
|
+
return serverProxy;
|
|
38
|
+
}
|
|
39
|
+
if (!window.shopify) {
|
|
40
|
+
throw Error('The shopify global is not defined. This likely means the App Bridge script tag was not added correctly to this page');
|
|
41
|
+
}
|
|
42
|
+
return window.shopify;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { useAppBridge };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Modal } from './components/Modal.esnext';
|
|
2
|
+
export { NavMenu } from './components/NavMenu.esnext';
|
|
3
|
+
export { TitleBar } from './components/TitleBar.esnext';
|
|
4
|
+
export { SaveBar } from './components/SaveBar.esnext';
|
|
5
|
+
export { useAppBridge } from './hooks/useAppBridge.esnext';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
import { ReactNode, LegacyRef } from 'react';
|
|
3
|
+
import { UIModalAttributes } from '@shopify/app-bridge-types';
|
|
4
|
+
declare global {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'ui-modal': UIModalAttributes & {
|
|
8
|
+
ref?: LegacyRef<UIModalElement | null>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface ModalProps extends Omit<UIModalAttributes, 'children'> {
|
|
14
|
+
/**
|
|
15
|
+
* Whether the modal is open or not
|
|
16
|
+
*
|
|
17
|
+
* @defaultValue false
|
|
18
|
+
*/
|
|
19
|
+
open?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Callback that is called when the modal is opened
|
|
22
|
+
*/
|
|
23
|
+
onShow?(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Callback that is called when the modal is closed
|
|
26
|
+
*/
|
|
27
|
+
onHide?(): void;
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* This component is a wrapper around the App Bridge `ui-modal` element.
|
|
32
|
+
* It is used to display an overlay that prevents interaction with the
|
|
33
|
+
* rest of the app until dismissed.
|
|
34
|
+
*
|
|
35
|
+
* @see {@link https://shopify.dev/docs/api/app-bridge-library/react-components/modal}
|
|
36
|
+
*/
|
|
37
|
+
export declare const Modal: React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<UIModalElement>>;
|
|
38
|
+
//# sourceMappingURL=Modal.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.d.cts","sourceRoot":"","sources":["../../../../src/components/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAEjE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,iBAAiB;YACzB,UAAU,EAAE,iBAAiB,GAAG;gBAC9B,GAAG,CAAC,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;aACxC,CAAC;SACH;KACF;CACF;AAED,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC;IACrE;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,IAAI,IAAI,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,IAAI,IAAI,CAAC;IAChB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,mFAoFhB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
import { LegacyRef, ReactNode } from 'react';
|
|
3
|
+
import { UINavMenuAttributes } from '@shopify/app-bridge-types';
|
|
4
|
+
declare global {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'ui-nav-menu': UINavMenuAttributes & {
|
|
8
|
+
ref?: LegacyRef<UINavMenuElement | null>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface NavMenuProps extends Omit<UINavMenuAttributes, 'children'> {
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* This component is a wrapper around the App Bridge `ui-nav-menu` element.
|
|
18
|
+
* It is used to create a navigation menu for your app.
|
|
19
|
+
*
|
|
20
|
+
* @see {@link https://shopify.dev/docs/api/app-bridge-library/react-components/navmenu}
|
|
21
|
+
*/
|
|
22
|
+
export declare const NavMenu: React.ComponentType<NavMenuProps>;
|
|
23
|
+
//# sourceMappingURL=NavMenu.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavMenu.d.cts","sourceRoot":"","sources":["../../../../src/components/NavMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,2BAA2B,CAAC;AAEnE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,iBAAiB;YACzB,aAAa,EAAE,mBAAmB,GAAG;gBACnC,GAAG,CAAC,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;aAC1C,CAAC;SACH;KACF;CACF;AAED,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC;IACzE,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;GAKG;AACH,eAAO,MAAM,OAAO,mCAC2C,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import { ReactNode, LegacyRef } from 'react';
|
|
3
|
+
import { UISaveBarAttributes } from '@shopify/app-bridge-types';
|
|
4
|
+
declare global {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'ui-save-bar': UISaveBarAttributes & {
|
|
8
|
+
ref?: LegacyRef<UISaveBarElement | null>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface SaveBarProps extends Omit<UISaveBarAttributes, 'children'> {
|
|
14
|
+
/**
|
|
15
|
+
* Whether the saveBar is open or not
|
|
16
|
+
*
|
|
17
|
+
* @defaultValue false
|
|
18
|
+
*/
|
|
19
|
+
open?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Callback that is called when the saveBar is opened
|
|
22
|
+
*/
|
|
23
|
+
onShow?(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Callback that is called when the saveBar is closed
|
|
26
|
+
*/
|
|
27
|
+
onHide?(): void;
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* This component is a wrapper around the App Bridge `ui-save-bar` element.
|
|
32
|
+
* It is used to display a contextual save bar to signal dirty state in the app.
|
|
33
|
+
*
|
|
34
|
+
* @see {@link https://shopify.dev/docs/api/app-bridge-library/react-components/save-bar}
|
|
35
|
+
*/
|
|
36
|
+
export declare const SaveBar: React.ForwardRefExoticComponent<SaveBarProps & React.RefAttributes<UISaveBarElement>>;
|
|
37
|
+
//# sourceMappingURL=SaveBar.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SaveBar.d.cts","sourceRoot":"","sources":["../../../../src/components/SaveBar.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,2BAA2B,CAAC;AAEnE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,iBAAiB;YACzB,aAAa,EAAE,mBAAmB,GAAG;gBACnC,GAAG,CAAC,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;aAC1C,CAAC;SACH;KACF;CACF;AAED,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC;IACzE;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,IAAI,IAAI,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,IAAI,IAAI,CAAC;IAChB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;GAKG;AACH,eAAO,MAAM,OAAO,uFAuDlB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
import { LegacyRef, ReactNode } from 'react';
|
|
3
|
+
import { UITitleBarAttributes } from '@shopify/app-bridge-types';
|
|
4
|
+
declare global {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'ui-title-bar': UITitleBarAttributes & {
|
|
8
|
+
ref?: LegacyRef<UITitleBarElement | null>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface TitleBarProps extends Omit<UITitleBarAttributes, 'children'> {
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* This component is a wrapper around the App Bridge `ui-title-bar` element.
|
|
18
|
+
* It is used to to populate the app title bar with button actions or the
|
|
19
|
+
* modal header and footer when used within the Modal component.
|
|
20
|
+
*
|
|
21
|
+
* @see {@link https://shopify.dev/docs/api/app-bridge-library/react-components/titlebar}
|
|
22
|
+
*/
|
|
23
|
+
export declare const TitleBar: React.ComponentType<TitleBarProps>;
|
|
24
|
+
//# sourceMappingURL=TitleBar.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TitleBar.d.cts","sourceRoot":"","sources":["../../../../src/components/TitleBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAEpE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,iBAAiB;YACzB,cAAc,EAAE,oBAAoB,GAAG;gBACrC,GAAG,CAAC,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;aAC3C,CAAC;SACH;KACF;CACF;AAED,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC;IAC3E,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,oCAC4C,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
import { ShopifyGlobal } from '@shopify/app-bridge-types';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* This hook returns the `shopify` global variable to use
|
|
6
|
+
* App Bridge APIs such as `toast` and `resourcePicker`.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://shopify.dev/docs/api/app-bridge-library/react-hooks/useappbridge}
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```jsx
|
|
12
|
+
* import {useAppBridge} from '@shopify/app-bridge-react';
|
|
13
|
+
* function GenerateBlogPostButton() {
|
|
14
|
+
* const shopify = useAppBridge();
|
|
15
|
+
*
|
|
16
|
+
* function generateBlogPost() {
|
|
17
|
+
* // Handle generating
|
|
18
|
+
* shopify.toast.show('Blog post template generated');
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* return <button onClick={generateBlogPost}>Generate Blog Post</button>;
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @returns `shopify` variable or a Proxy that throws when incorrectly accessed when not in a browser context
|
|
26
|
+
*/
|
|
27
|
+
export declare function useAppBridge(): ShopifyGlobal;
|
|
28
|
+
//# sourceMappingURL=useAppBridge.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAppBridge.d.cts","sourceRoot":"","sources":["../../../../src/hooks/useAppBridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAmB7D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,kBAU3B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
export type { ModalProps } from './components/Modal.cjs';
|
|
3
|
+
export { Modal } from './components/Modal.cjs';
|
|
4
|
+
export type { NavMenuProps } from './components/NavMenu.cjs';
|
|
5
|
+
export { NavMenu } from './components/NavMenu.cjs';
|
|
6
|
+
export type { TitleBarProps } from './components/TitleBar.cjs';
|
|
7
|
+
export { TitleBar } from './components/TitleBar.cjs';
|
|
8
|
+
export type { SaveBarProps } from './components/SaveBar.cjs';
|
|
9
|
+
export { SaveBar } from './components/SaveBar.cjs';
|
|
10
|
+
export { useAppBridge } from './hooks/useAppBridge.cjs';
|
|
11
|
+
export type * from '@shopify/app-bridge-types';
|
|
12
|
+
//# sourceMappingURL=index.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAEzC,YAAY,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAC,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAE7C,YAAY,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAE/C,YAAY,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAC,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAE7C,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAElD,mBAAmB,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
|
|
2
|
+
import { ReactNode, LegacyRef } from 'react';
|
|
3
|
+
import { UIModalAttributes } from '@shopify/app-bridge-types';
|
|
4
|
+
declare global {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'ui-modal': UIModalAttributes & {
|
|
8
|
+
ref?: LegacyRef<UIModalElement | null>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface ModalProps extends Omit<UIModalAttributes, 'children'> {
|
|
14
|
+
/**
|
|
15
|
+
* Whether the modal is open or not
|
|
16
|
+
*
|
|
17
|
+
* @defaultValue false
|
|
18
|
+
*/
|
|
19
|
+
open?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Callback that is called when the modal is opened
|
|
22
|
+
*/
|
|
23
|
+
onShow?(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Callback that is called when the modal is closed
|
|
26
|
+
*/
|
|
27
|
+
onHide?(): void;
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* This component is a wrapper around the App Bridge `ui-modal` element.
|
|
32
|
+
* It is used to display an overlay that prevents interaction with the
|
|
33
|
+
* rest of the app until dismissed.
|
|
34
|
+
*
|
|
35
|
+
* @see {@link https://shopify.dev/docs/api/app-bridge-library/react-components/modal}
|
|
36
|
+
*/
|
|
37
|
+
export declare const Modal: React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<UIModalElement>>;
|
|
38
|
+
//# sourceMappingURL=Modal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../../src/components/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,SAAS,EAKf,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAEjE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,iBAAiB;YACzB,UAAU,EAAE,iBAAiB,GAAG;gBAC9B,GAAG,CAAC,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;aACxC,CAAC;SACH;KACF;CACF;AAED,MAAM,WAAW,UAAW,SAAQ,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC;IACrE;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,IAAI,IAAI,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,IAAI,IAAI,CAAC;IAChB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,mFAoFhB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
import { LegacyRef, ReactNode } from 'react';
|
|
3
|
+
import { UINavMenuAttributes } from '@shopify/app-bridge-types';
|
|
4
|
+
declare global {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'ui-nav-menu': UINavMenuAttributes & {
|
|
8
|
+
ref?: LegacyRef<UINavMenuElement | null>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface NavMenuProps extends Omit<UINavMenuAttributes, 'children'> {
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* This component is a wrapper around the App Bridge `ui-nav-menu` element.
|
|
18
|
+
* It is used to create a navigation menu for your app.
|
|
19
|
+
*
|
|
20
|
+
* @see {@link https://shopify.dev/docs/api/app-bridge-library/react-components/navmenu}
|
|
21
|
+
*/
|
|
22
|
+
export declare const NavMenu: React.ComponentType<NavMenuProps>;
|
|
23
|
+
//# sourceMappingURL=NavMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavMenu.d.ts","sourceRoot":"","sources":["../../../../src/components/NavMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,2BAA2B,CAAC;AAEnE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,iBAAiB;YACzB,aAAa,EAAE,mBAAmB,GAAG;gBACnC,GAAG,CAAC,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;aAC1C,CAAC;SACH;KACF;CACF;AAED,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC;IACzE,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;GAKG;AACH,eAAO,MAAM,OAAO,mCAC2C,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
import { ReactNode, LegacyRef } from 'react';
|
|
3
|
+
import { UISaveBarAttributes } from '@shopify/app-bridge-types';
|
|
4
|
+
declare global {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'ui-save-bar': UISaveBarAttributes & {
|
|
8
|
+
ref?: LegacyRef<UISaveBarElement | null>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface SaveBarProps extends Omit<UISaveBarAttributes, 'children'> {
|
|
14
|
+
/**
|
|
15
|
+
* Whether the saveBar is open or not
|
|
16
|
+
*
|
|
17
|
+
* @defaultValue false
|
|
18
|
+
*/
|
|
19
|
+
open?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Callback that is called when the saveBar is opened
|
|
22
|
+
*/
|
|
23
|
+
onShow?(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Callback that is called when the saveBar is closed
|
|
26
|
+
*/
|
|
27
|
+
onHide?(): void;
|
|
28
|
+
children?: ReactNode;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* This component is a wrapper around the App Bridge `ui-save-bar` element.
|
|
32
|
+
* It is used to display a contextual save bar to signal dirty state in the app.
|
|
33
|
+
*
|
|
34
|
+
* @see {@link https://shopify.dev/docs/api/app-bridge-library/react-components/save-bar}
|
|
35
|
+
*/
|
|
36
|
+
export declare const SaveBar: React.ForwardRefExoticComponent<SaveBarProps & React.RefAttributes<UISaveBarElement>>;
|
|
37
|
+
//# sourceMappingURL=SaveBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SaveBar.d.ts","sourceRoot":"","sources":["../../../../src/components/SaveBar.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EAEd,KAAK,SAAS,EAIf,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,2BAA2B,CAAC;AAEnE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,iBAAiB;YACzB,aAAa,EAAE,mBAAmB,GAAG;gBACnC,GAAG,CAAC,EAAE,SAAS,CAAC,gBAAgB,GAAG,IAAI,CAAC,CAAC;aAC1C,CAAC;SACH;KACF;CACF;AAED,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC;IACzE;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,MAAM,CAAC,IAAI,IAAI,CAAC;IAChB;;OAEG;IACH,MAAM,CAAC,IAAI,IAAI,CAAC;IAChB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;GAKG;AACH,eAAO,MAAM,OAAO,uFAuDlB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
|
|
2
|
+
import { LegacyRef, ReactNode } from 'react';
|
|
3
|
+
import { UITitleBarAttributes } from '@shopify/app-bridge-types';
|
|
4
|
+
declare global {
|
|
5
|
+
namespace JSX {
|
|
6
|
+
interface IntrinsicElements {
|
|
7
|
+
'ui-title-bar': UITitleBarAttributes & {
|
|
8
|
+
ref?: LegacyRef<UITitleBarElement | null>;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export interface TitleBarProps extends Omit<UITitleBarAttributes, 'children'> {
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* This component is a wrapper around the App Bridge `ui-title-bar` element.
|
|
18
|
+
* It is used to to populate the app title bar with button actions or the
|
|
19
|
+
* modal header and footer when used within the Modal component.
|
|
20
|
+
*
|
|
21
|
+
* @see {@link https://shopify.dev/docs/api/app-bridge-library/react-components/titlebar}
|
|
22
|
+
*/
|
|
23
|
+
export declare const TitleBar: React.ComponentType<TitleBarProps>;
|
|
24
|
+
//# sourceMappingURL=TitleBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TitleBar.d.ts","sourceRoot":"","sources":["../../../../src/components/TitleBar.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,SAAS,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAEpE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,GAAG,CAAC;QACZ,UAAU,iBAAiB;YACzB,cAAc,EAAE,oBAAoB,GAAG;gBACrC,GAAG,CAAC,EAAE,SAAS,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;aAC3C,CAAC;SACH;KACF;CACF;AAED,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC;IAC3E,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,oCAC4C,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
import { ShopifyGlobal } from '@shopify/app-bridge-types';
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* This hook returns the `shopify` global variable to use
|
|
6
|
+
* App Bridge APIs such as `toast` and `resourcePicker`.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://shopify.dev/docs/api/app-bridge-library/react-hooks/useappbridge}
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```jsx
|
|
12
|
+
* import {useAppBridge} from '@shopify/app-bridge-react';
|
|
13
|
+
* function GenerateBlogPostButton() {
|
|
14
|
+
* const shopify = useAppBridge();
|
|
15
|
+
*
|
|
16
|
+
* function generateBlogPost() {
|
|
17
|
+
* // Handle generating
|
|
18
|
+
* shopify.toast.show('Blog post template generated');
|
|
19
|
+
* }
|
|
20
|
+
*
|
|
21
|
+
* return <button onClick={generateBlogPost}>Generate Blog Post</button>;
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @returns `shopify` variable or a Proxy that throws when incorrectly accessed when not in a browser context
|
|
26
|
+
*/
|
|
27
|
+
export declare function useAppBridge(): ShopifyGlobal;
|
|
28
|
+
//# sourceMappingURL=useAppBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAppBridge.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useAppBridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,2BAA2B,CAAC;AAmB7D;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,kBAU3B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
|
|
2
|
+
export type { ModalProps } from './components/Modal.js';
|
|
3
|
+
export { Modal } from './components/Modal.js';
|
|
4
|
+
export type { NavMenuProps } from './components/NavMenu.js';
|
|
5
|
+
export { NavMenu } from './components/NavMenu.js';
|
|
6
|
+
export type { TitleBarProps } from './components/TitleBar.js';
|
|
7
|
+
export { TitleBar } from './components/TitleBar.js';
|
|
8
|
+
export type { SaveBarProps } from './components/SaveBar.js';
|
|
9
|
+
export { SaveBar } from './components/SaveBar.js';
|
|
10
|
+
export { useAppBridge } from './hooks/useAppBridge.js';
|
|
11
|
+
export type * from '@shopify/app-bridge-types';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,UAAU,EAAC,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAEzC,YAAY,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAC,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAE7C,YAAY,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAC,QAAQ,EAAC,MAAM,uBAAuB,CAAC;AAE/C,YAAY,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAC,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAE7C,OAAO,EAAC,YAAY,EAAC,MAAM,sBAAsB,CAAC;AAElD,mBAAmB,2BAA2B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,65 +1,76 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopify/app-bridge-react",
|
|
3
|
-
"version": "4.1.
|
|
4
|
-
"license": "MIT",
|
|
3
|
+
"version": "4.1.9",
|
|
5
4
|
"description": "React wrappers for the Shopify App Bridge library",
|
|
6
|
-
"
|
|
7
|
-
"publishConfig": {
|
|
8
|
-
"access": "public",
|
|
9
|
-
"@shopify:registry": "https://registry.npmjs.org"
|
|
10
|
-
},
|
|
11
|
-
"sideEffects": false,
|
|
5
|
+
"license": "MIT",
|
|
12
6
|
"author": "Shopify Inc.",
|
|
13
7
|
"repository": {
|
|
14
8
|
"type": "git",
|
|
15
9
|
"url": "git+https://github.com/Shopify/shopify-app-bridge.git"
|
|
16
10
|
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/Shopify/shopify-app-bridge/issues"
|
|
13
|
+
},
|
|
17
14
|
"homepage": "https://shopify.dev/docs/api/app-bridge",
|
|
15
|
+
"private": false,
|
|
16
|
+
"publishConfig": {
|
|
17
|
+
"access": "public",
|
|
18
|
+
"@shopify:registry": "https://registry.npmjs.org"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": "^20.11"
|
|
22
|
+
},
|
|
23
|
+
"sideEffects": false,
|
|
18
24
|
"type": "module",
|
|
19
|
-
"main": "./
|
|
20
|
-
"types": "./
|
|
21
|
-
"module": "./
|
|
25
|
+
"main": "./build/cjs/index.cjs",
|
|
26
|
+
"types": "./build/types/esm/index.d.ts",
|
|
27
|
+
"module": "./build/esm/index.js",
|
|
28
|
+
"esnext": "./build/esnext/index.esnext",
|
|
22
29
|
"exports": {
|
|
23
30
|
".": {
|
|
24
|
-
"
|
|
31
|
+
"esnext": "./build/esnext/index.esnext",
|
|
25
32
|
"import": {
|
|
26
|
-
"types": "./
|
|
27
|
-
"default": "./
|
|
33
|
+
"types": "./build/types/esm/index.d.ts",
|
|
34
|
+
"default": "./build/esm/index.js"
|
|
28
35
|
},
|
|
29
36
|
"require": {
|
|
30
|
-
"types": "./
|
|
31
|
-
"default": "./
|
|
37
|
+
"types": "./build/types/cjs/index.d.cts",
|
|
38
|
+
"default": "./build/cjs/index.cjs"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"./*": {
|
|
42
|
+
"esnext": "./build/esnext/*.esnext",
|
|
43
|
+
"import": {
|
|
44
|
+
"types": "./build/types/esm/*.d.ts",
|
|
45
|
+
"default": "./build/esm/*.js"
|
|
32
46
|
},
|
|
33
|
-
"
|
|
47
|
+
"require": {
|
|
48
|
+
"types": "./build/types/cjs/*.d.cts",
|
|
49
|
+
"default": "./build/cjs/*.cjs"
|
|
50
|
+
}
|
|
34
51
|
}
|
|
35
52
|
},
|
|
36
53
|
"files": [
|
|
37
|
-
"
|
|
54
|
+
"build",
|
|
38
55
|
"CHANGELOG.md"
|
|
39
56
|
],
|
|
40
57
|
"dependencies": {
|
|
41
|
-
"@shopify/app-bridge-types": "0.0.
|
|
58
|
+
"@shopify/app-bridge-types": "0.0.18"
|
|
42
59
|
},
|
|
43
60
|
"devDependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"@types/react": "^18.
|
|
46
|
-
"@types/react-dom": "^18.2.17",
|
|
47
|
-
"@vitejs/plugin-react": "^4.2.1",
|
|
61
|
+
"@types/react": "^18.3.4",
|
|
62
|
+
"@types/react-dom": "^18.3.0",
|
|
48
63
|
"react": "^18.2.0",
|
|
49
|
-
"react-dom": "^18.2.0"
|
|
50
|
-
"typescript": "^5.3.3",
|
|
51
|
-
"vite": "^4.5.3",
|
|
52
|
-
"vite-plugin-dts": "^2.3.0",
|
|
53
|
-
"vitest": "^0.32.2"
|
|
64
|
+
"react-dom": "^18.2.0"
|
|
54
65
|
},
|
|
55
66
|
"peerDependencies": {
|
|
56
|
-
"react": "
|
|
57
|
-
"react-dom": "
|
|
67
|
+
"react": "*",
|
|
68
|
+
"react-dom": "*"
|
|
58
69
|
},
|
|
59
70
|
"scripts": {
|
|
60
71
|
"build": "vite build",
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"type-check": "tsc"
|
|
72
|
+
"watch": "vite build --watch --mode=development",
|
|
73
|
+
"test": "vitest run --passWithNoTests",
|
|
74
|
+
"type-check": "tsc --noEmit"
|
|
64
75
|
}
|
|
65
76
|
}
|