@shopify/app-bridge-react 4.1.8 → 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.
Files changed (49) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/build/cjs/components/Modal.cjs +104 -0
  3. package/build/cjs/components/NavMenu.cjs +13 -0
  4. package/build/cjs/components/SaveBar.cjs +67 -0
  5. package/build/cjs/components/TitleBar.cjs +14 -0
  6. package/build/cjs/hooks/useAppBridge.cjs +49 -0
  7. package/build/cjs/index.cjs +17 -0
  8. package/build/esm/components/Modal.js +96 -0
  9. package/build/esm/components/NavMenu.js +9 -0
  10. package/build/esm/components/SaveBar.js +63 -0
  11. package/build/esm/components/TitleBar.js +10 -0
  12. package/build/esm/hooks/useAppBridge.js +45 -0
  13. package/build/esm/index.js +5 -0
  14. package/build/esnext/components/Modal.esnext +96 -0
  15. package/build/esnext/components/NavMenu.esnext +9 -0
  16. package/build/esnext/components/SaveBar.esnext +63 -0
  17. package/build/esnext/components/TitleBar.esnext +10 -0
  18. package/build/esnext/hooks/useAppBridge.esnext +45 -0
  19. package/build/esnext/index.esnext +5 -0
  20. package/build/types/cjs/components/Modal.d.cts +38 -0
  21. package/build/types/cjs/components/Modal.d.cts.map +1 -0
  22. package/build/types/cjs/components/NavMenu.d.cts +23 -0
  23. package/build/types/cjs/components/NavMenu.d.cts.map +1 -0
  24. package/build/types/cjs/components/SaveBar.d.cts +37 -0
  25. package/build/types/cjs/components/SaveBar.d.cts.map +1 -0
  26. package/build/types/cjs/components/TitleBar.d.cts +24 -0
  27. package/build/types/cjs/components/TitleBar.d.cts.map +1 -0
  28. package/build/types/cjs/hooks/useAppBridge.d.cts +28 -0
  29. package/build/types/cjs/hooks/useAppBridge.d.cts.map +1 -0
  30. package/build/types/cjs/index.d.cts +12 -0
  31. package/build/types/cjs/index.d.cts.map +1 -0
  32. package/build/types/esm/components/Modal.d.ts +38 -0
  33. package/build/types/esm/components/Modal.d.ts.map +1 -0
  34. package/build/types/esm/components/NavMenu.d.ts +23 -0
  35. package/build/types/esm/components/NavMenu.d.ts.map +1 -0
  36. package/build/types/esm/components/SaveBar.d.ts +37 -0
  37. package/build/types/esm/components/SaveBar.d.ts.map +1 -0
  38. package/build/types/esm/components/TitleBar.d.ts +24 -0
  39. package/build/types/esm/components/TitleBar.d.ts.map +1 -0
  40. package/build/types/esm/hooks/useAppBridge.d.ts +28 -0
  41. package/build/types/esm/hooks/useAppBridge.d.ts.map +1 -0
  42. package/build/types/esm/index.d.ts +12 -0
  43. package/build/types/esm/index.d.ts.map +1 -0
  44. package/package.json +43 -32
  45. package/dist/index.cjs +0 -28
  46. package/dist/index.cjs.map +0 -1
  47. package/dist/index.d.ts +0 -115
  48. package/dist/index.js +0 -740
  49. package/dist/index.js.map +0 -1
@@ -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.8",
4
- "license": "MIT",
3
+ "version": "4.1.9",
5
4
  "description": "React wrappers for the Shopify App Bridge library",
6
- "private": false,
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": "./dist/index.cjs",
20
- "types": "./dist/index.d.ts",
21
- "module": "./dist/index.js",
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
- "module": "./dist/index.js",
31
+ "esnext": "./build/esnext/index.esnext",
25
32
  "import": {
26
- "types": "./dist/index.d.ts",
27
- "default": "./dist/index.js"
33
+ "types": "./build/types/esm/index.d.ts",
34
+ "default": "./build/esm/index.js"
28
35
  },
29
36
  "require": {
30
- "types": "./dist/index.d.ts",
31
- "default": "./dist/index.cjs"
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
- "default": "./dist/index.js"
47
+ "require": {
48
+ "types": "./build/types/cjs/*.d.cts",
49
+ "default": "./build/cjs/*.cjs"
50
+ }
34
51
  }
35
52
  },
36
53
  "files": [
37
- "dist",
54
+ "build",
38
55
  "CHANGELOG.md"
39
56
  ],
40
57
  "dependencies": {
41
58
  "@shopify/app-bridge-types": "0.0.18"
42
59
  },
43
60
  "devDependencies": {
44
- "@rollup/plugin-commonjs": "^25.0.7",
45
- "@types/react": "^18.2.42",
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": "^18.0.0",
57
- "react-dom": "^18.0.0"
67
+ "react": "*",
68
+ "react-dom": "*"
58
69
  },
59
70
  "scripts": {
60
71
  "build": "vite build",
61
- "format": "prettier --write src/",
62
- "lint": "oxlint src/*.{ts,tsx,js} -c .eslintrc.json",
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
  }
package/dist/index.cjs DELETED
@@ -1,28 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react"),fr=require("react-dom");var ee={exports:{}},L={};/**
2
- * @license React
3
- * react-jsx-runtime.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var Oe;function lr(){if(Oe)return L;Oe=1;var T=m,v=Symbol.for("react.element"),y=Symbol.for("react.fragment"),c=Object.prototype.hasOwnProperty,C=T.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,x={key:!0,ref:!0,__self:!0,__source:!0};function h(a,d,_){var E,w={},O=null,b=null;_!==void 0&&(O=""+_),d.key!==void 0&&(O=""+d.key),d.ref!==void 0&&(b=d.ref);for(E in d)c.call(d,E)&&!x.hasOwnProperty(E)&&(w[E]=d[E]);if(a&&a.defaultProps)for(E in d=a.defaultProps,d)w[E]===void 0&&(w[E]=d[E]);return{$$typeof:v,type:a,key:O,ref:b,props:w,_owner:C.current}}return L.Fragment=y,L.jsx=h,L.jsxs=h,L}var M={};/**
10
- * @license React
11
- * react-jsx-runtime.development.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var Pe;function cr(){return Pe||(Pe=1,process.env.NODE_ENV!=="production"&&function(){var T=m,v=Symbol.for("react.element"),y=Symbol.for("react.portal"),c=Symbol.for("react.fragment"),C=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),h=Symbol.for("react.provider"),a=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),b=Symbol.for("react.offscreen"),k=Symbol.iterator,$="@@iterator";function B(e){if(e===null||typeof e!="object")return null;var r=k&&e[k]||e[$];return typeof r=="function"?r:null}var P=T.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function p(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];xe("error",e,t)}}function xe(e,r,t){{var n=P.ReactDebugCurrentFrame,u=n.getStackAddendum();u!==""&&(r+="%s",t=t.concat([u]));var s=t.map(function(o){return String(o)});s.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,s)}}var ke=!1,De=!1,Ae=!1,Fe=!1,Ne=!1,te;te=Symbol.for("react.module.reference");function Ie(e){return!!(typeof e=="string"||typeof e=="function"||e===c||e===x||Ne||e===C||e===_||e===E||Fe||e===b||ke||De||Ae||typeof e=="object"&&e!==null&&(e.$$typeof===O||e.$$typeof===w||e.$$typeof===h||e.$$typeof===a||e.$$typeof===d||e.$$typeof===te||e.getModuleId!==void 0))}function Le(e,r,t){var n=e.displayName;if(n)return n;var u=r.displayName||r.name||"";return u!==""?t+"("+u+")":t}function ne(e){return e.displayName||"Context"}function S(e){if(e==null)return null;if(typeof e.tag=="number"&&p("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case c:return"Fragment";case y:return"Portal";case x:return"Profiler";case C:return"StrictMode";case _:return"Suspense";case E:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case a:var r=e;return ne(r)+".Consumer";case h:var t=e;return ne(t._context)+".Provider";case d:return Le(e,e.render,"ForwardRef");case w:var n=e.displayName||null;return n!==null?n:S(e.type)||"Memo";case O:{var u=e,s=u._payload,o=u._init;try{return S(o(s))}catch{return null}}}return null}var D=Object.assign,N=0,ae,ie,oe,ue,se,fe,le;function ce(){}ce.__reactDisabledLog=!0;function Me(){{if(N===0){ae=console.log,ie=console.info,oe=console.warn,ue=console.error,se=console.group,fe=console.groupCollapsed,le=console.groupEnd;var e={configurable:!0,enumerable:!0,value:ce,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}N++}}function $e(){{if(N--,N===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:D({},e,{value:ae}),info:D({},e,{value:ie}),warn:D({},e,{value:oe}),error:D({},e,{value:ue}),group:D({},e,{value:se}),groupCollapsed:D({},e,{value:fe}),groupEnd:D({},e,{value:le})})}N<0&&p("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var J=P.ReactCurrentDispatcher,G;function W(e,r,t){{if(G===void 0)try{throw Error()}catch(u){var n=u.stack.trim().match(/\n( *(at )?)/);G=n&&n[1]||""}return`
18
- `+G+e}}var z=!1,Y;{var Be=typeof WeakMap=="function"?WeakMap:Map;Y=new Be}function de(e,r){if(!e||z)return"";{var t=Y.get(e);if(t!==void 0)return t}var n;z=!0;var u=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var s;s=J.current,J.current=null,Me();try{if(r){var o=function(){throw Error()};if(Object.defineProperty(o.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(o,[])}catch(j){n=j}Reflect.construct(e,[],o)}else{try{o.call()}catch(j){n=j}e.call(o.prototype)}}else{try{throw Error()}catch(j){n=j}e()}}catch(j){if(j&&n&&typeof j.stack=="string"){for(var i=j.stack.split(`
19
- `),g=n.stack.split(`
20
- `),f=i.length-1,l=g.length-1;f>=1&&l>=0&&i[f]!==g[l];)l--;for(;f>=1&&l>=0;f--,l--)if(i[f]!==g[l]){if(f!==1||l!==1)do if(f--,l--,l<0||i[f]!==g[l]){var R=`
21
- `+i[f].replace(" at new "," at ");return e.displayName&&R.includes("<anonymous>")&&(R=R.replace("<anonymous>",e.displayName)),typeof e=="function"&&Y.set(e,R),R}while(f>=1&&l>=0);break}}}finally{z=!1,J.current=s,$e(),Error.prepareStackTrace=u}var F=e?e.displayName||e.name:"",Ce=F?W(F):"";return typeof e=="function"&&Y.set(e,Ce),Ce}function We(e,r,t){return de(e,!1)}function Ye(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function V(e,r,t){if(e==null)return"";if(typeof e=="function")return de(e,Ye(e));if(typeof e=="string")return W(e);switch(e){case _:return W("Suspense");case E:return W("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case d:return We(e.render);case w:return V(e.type,r,t);case O:{var n=e,u=n._payload,s=n._init;try{return V(s(u),r,t)}catch{}}}return""}var U=Object.prototype.hasOwnProperty,ve={},pe=P.ReactDebugCurrentFrame;function q(e){if(e){var r=e._owner,t=V(e.type,e._source,r?r.type:null);pe.setExtraStackFrame(t)}else pe.setExtraStackFrame(null)}function Ve(e,r,t,n,u){{var s=Function.call.bind(U);for(var o in e)if(s(e,o)){var i=void 0;try{if(typeof e[o]!="function"){var g=Error((n||"React class")+": "+t+" type `"+o+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[o]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw g.name="Invariant Violation",g}i=e[o](r,o,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(f){i=f}i&&!(i instanceof Error)&&(q(u),p("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,o,typeof i),q(null)),i instanceof Error&&!(i.message in ve)&&(ve[i.message]=!0,q(u),p("Failed %s type: %s",t,i.message),q(null))}}}var Ue=Array.isArray;function K(e){return Ue(e)}function qe(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function Je(e){try{return ye(e),!1}catch{return!0}}function ye(e){return""+e}function he(e){if(Je(e))return p("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",qe(e)),ye(e)}var I=P.ReactCurrentOwner,Ge={key:!0,ref:!0,__self:!0,__source:!0},Ee,ge,X;X={};function ze(e){if(U.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function Ke(e){if(U.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function Xe(e,r){if(typeof e.ref=="string"&&I.current&&r&&I.current.stateNode!==r){var t=S(I.current.type);X[t]||(p('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',S(I.current.type),e.ref),X[t]=!0)}}function Ze(e,r){{var t=function(){Ee||(Ee=!0,p("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function Qe(e,r){{var t=function(){ge||(ge=!0,p("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var He=function(e,r,t,n,u,s,o){var i={$$typeof:v,type:e,key:r,ref:t,props:o,_owner:s};return i._store={},Object.defineProperty(i._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(i,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(i,"_source",{configurable:!1,enumerable:!1,writable:!1,value:u}),Object.freeze&&(Object.freeze(i.props),Object.freeze(i)),i};function er(e,r,t,n,u){{var s,o={},i=null,g=null;t!==void 0&&(he(t),i=""+t),Ke(r)&&(he(r.key),i=""+r.key),ze(r)&&(g=r.ref,Xe(r,u));for(s in r)U.call(r,s)&&!Ge.hasOwnProperty(s)&&(o[s]=r[s]);if(e&&e.defaultProps){var f=e.defaultProps;for(s in f)o[s]===void 0&&(o[s]=f[s])}if(i||g){var l=typeof e=="function"?e.displayName||e.name||"Unknown":e;i&&Ze(o,l),g&&Qe(o,l)}return He(e,i,g,u,n,I.current,o)}}var Z=P.ReactCurrentOwner,me=P.ReactDebugCurrentFrame;function A(e){if(e){var r=e._owner,t=V(e.type,e._source,r?r.type:null);me.setExtraStackFrame(t)}else me.setExtraStackFrame(null)}var Q;Q=!1;function H(e){return typeof e=="object"&&e!==null&&e.$$typeof===v}function be(){{if(Z.current){var e=S(Z.current.type);if(e)return`
22
-
23
- Check the render method of \``+e+"`."}return""}}function rr(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),t=e.lineNumber;return`
24
-
25
- Check your code at `+r+":"+t+"."}return""}}var _e={};function tr(e){{var r=be();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
26
-
27
- Check the top-level render call using <`+t+">.")}return r}}function Re(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=tr(r);if(_e[t])return;_e[t]=!0;var n="";e&&e._owner&&e._owner!==Z.current&&(n=" It was passed a child from "+S(e._owner.type)+"."),A(e),p('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),A(null)}}function Te(e,r){{if(typeof e!="object")return;if(K(e))for(var t=0;t<e.length;t++){var n=e[t];H(n)&&Re(n,r)}else if(H(e))e._store&&(e._store.validated=!0);else if(e){var u=B(e);if(typeof u=="function"&&u!==e.entries)for(var s=u.call(e),o;!(o=s.next()).done;)H(o.value)&&Re(o.value,r)}}}function nr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===d||r.$$typeof===w))t=r.propTypes;else return;if(t){var n=S(r);Ve(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!Q){Q=!0;var u=S(r);p("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",u||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&p("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ar(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){A(e),p("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),A(null);break}}e.ref!==null&&(A(e),p("Invalid attribute `ref` supplied to `React.Fragment`."),A(null))}}function we(e,r,t,n,u,s){{var o=Ie(e);if(!o){var i="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(i+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var g=rr(u);g?i+=g:i+=be();var f;e===null?f="null":K(e)?f="array":e!==void 0&&e.$$typeof===v?(f="<"+(S(e.type)||"Unknown")+" />",i=" Did you accidentally export a JSX literal instead of a component?"):f=typeof e,p("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",f,i)}var l=er(e,r,t,u,s);if(l==null)return l;if(o){var R=r.children;if(R!==void 0)if(n)if(K(R)){for(var F=0;F<R.length;F++)Te(R[F],e);Object.freeze&&Object.freeze(R)}else p("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Te(R,e)}return e===c?ar(l):nr(l),l}}function ir(e,r,t){return we(e,r,t,!0)}function or(e,r,t){return we(e,r,t,!1)}var ur=or,sr=ir;M.Fragment=c,M.jsx=ur,M.jsxs=sr}()),M}process.env.NODE_ENV==="production"?ee.exports=lr():ee.exports=cr();var re=ee.exports;const Se=m.forwardRef(function({open:v,onShow:y,onHide:c,children:C,...x},h){const[a,d]=m.useState(),{titleBar:_,saveBar:E,modalContent:w}=m.Children.toArray(C).reduce((b,k)=>{const $=dr(k),B=$==="ui-title-bar",P=$==="ui-save-bar";return!B&&!P&&b.modalContent.push(k),{...b,titleBar:B?k:b.titleBar,saveBar:P?k:b.saveBar}},{modalContent:[]}),O=a&&a.content?fr.createPortal(w,a.content):null;return m.useEffect(()=>{a&&(v?a.show():a.hide())},[a,v]),m.useEffect(()=>{if(!(!a||!y))return a.addEventListener("show",y),()=>{a.removeEventListener("show",y)}},[a,y]),m.useEffect(()=>{if(!(!a||!c))return a.addEventListener("hide",c),()=>{a.removeEventListener("hide",c)}},[a,c]),m.useEffect(()=>{if(a)return()=>{a.hide()}},[a]),re.jsxs("ui-modal",{...x,ref:b=>{d(b),h&&(typeof h=="function"?h(b):h.current=b)},children:[_,E,re.jsx("div",{children:O})]})});Se.displayName="ui-modal";function dr(T){if(!T)return;const v=typeof T=="object"&&"type"in T?T.type:void 0,y=typeof v=="string"?v:void 0,c=typeof v=="object"?v.displayName:void 0;return y||(typeof c=="string"?c:void 0)}const vr="ui-nav-menu",pr="ui-title-bar",je=m.forwardRef(function({open:v,onShow:y,onHide:c,children:C,...x},h){const[a,d]=m.useState();return m.useEffect(()=>{a&&(v?a.show():a.hide())},[a,v]),m.useEffect(()=>{if(!(!a||!y))return a.addEventListener("show",y),()=>{a.removeEventListener("show",y)}},[a,y]),m.useEffect(()=>{if(!(!a||!c))return a.addEventListener("hide",c),()=>{a.removeEventListener("hide",c)}},[a,c]),m.useEffect(()=>{if(a)return()=>{a.hide()}},[a]),re.jsx("ui-save-bar",{...x,ref:_=>{d(_),h&&(typeof h=="function"?h(_):h.current=_)},children:C})});je.displayName="ui-save-bar";const yr=new Proxy({},{get(T,v){throw Error(`shopify.${String(v)} can't be used in a server environment. You likely need to move this code into an Effect.`)}});function hr(){if(typeof window>"u")return yr;if(!window.shopify)throw Error("The shopify global is not defined. This likely means the App Bridge script tag was not added correctly to this page");return window.shopify}exports.Modal=Se;exports.NavMenu=vr;exports.SaveBar=je;exports.TitleBar=pr;exports.useAppBridge=hr;
28
- //# sourceMappingURL=index.cjs.map