polaris-vue-elements 0.5.0 → 0.6.1
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 +59 -2
- package/README.md +2 -1
- package/dist/app-bridge/AppWindow.d.ts +9 -0
- package/dist/app-bridge/AppWindow.d.ts.map +1 -0
- package/dist/app-bridge/Modal.d.ts +17 -0
- package/dist/app-bridge/Modal.d.ts.map +1 -0
- package/dist/app-bridge/NavMenu.d.ts +11 -0
- package/dist/app-bridge/NavMenu.d.ts.map +1 -0
- package/dist/app-bridge/SaveBar.d.ts +11 -0
- package/dist/app-bridge/SaveBar.d.ts.map +1 -0
- package/dist/app-bridge/TitleBar.d.ts +14 -0
- package/dist/app-bridge/TitleBar.d.ts.map +1 -0
- package/dist/app-bridge/elements.d.ts +27 -0
- package/dist/app-bridge/elements.d.ts.map +1 -0
- package/dist/app-bridge/index.d.ts +9 -0
- package/dist/app-bridge/index.d.ts.map +1 -0
- package/dist/app-bridge/index.js +159 -0
- package/dist/app-bridge/index.js.map +1 -0
- package/dist/app-bridge/splitModalChildren.d.ts +15 -0
- package/dist/app-bridge/splitModalChildren.d.ts.map +1 -0
- package/dist/app-bridge/types.d.ts +70 -0
- package/dist/app-bridge/types.d.ts.map +1 -0
- package/dist/app-bridge/useAppBridge.d.ts +13 -0
- package/dist/app-bridge/useAppBridge.d.ts.map +1 -0
- package/dist/app-bridge/useOverlaySync.d.ts +33 -0
- package/dist/app-bridge/useOverlaySync.d.ts.map +1 -0
- package/package.json +26 -9
package/CHANGELOG.md
CHANGED
|
@@ -11,6 +11,61 @@ major your app loads (`polaris-1.js`, `polaris-2.js`, …).
|
|
|
11
11
|
|
|
12
12
|
## [Unreleased]
|
|
13
13
|
|
|
14
|
+
## [0.6.1] - 2026-11-16
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
|
|
18
|
+
- Docs: the App Bridge pages carry a beta notice, and the sidebar marks the section as
|
|
19
|
+
beta, until the components have been tested in a live Shopify admin.
|
|
20
|
+
- Docs: clearer page titles and descriptions on the App Bridge pages, an App Bridge
|
|
21
|
+
section on the homepage, and a link from Getting started.
|
|
22
|
+
- `package.json`: the description and keywords mention App Bridge and Shopify embedded apps.
|
|
23
|
+
- Docs: generated [App Bridge types](https://polaris-vue-elements.dev/app-bridge/types/)
|
|
24
|
+
pages with the 128 types the App Bridge docs reach in `@shopify/app-bridge-types`, split
|
|
25
|
+
by Shopify's API categories, with an A–Z index. Type names on the App Bridge pages link
|
|
26
|
+
to them, and the sync job regenerates them.
|
|
27
|
+
- Docs: the App Bridge types pages show each type as one card, with members listed by
|
|
28
|
+
name and type instead of three-column tables.
|
|
29
|
+
- Docs: an Examples section on every App Bridge page, with 36 Vue use cases based on
|
|
30
|
+
Shopify's documentation (confirm dialogs, `src` modals, save bars with dirty tracking and
|
|
31
|
+
leave confirmation, app nav from vue-router, resource picker, toast, loading, and more).
|
|
32
|
+
They have not yet been tested in a live admin.
|
|
33
|
+
- `docs:build` runs VitePress with a larger Node heap, so the docs build no longer runs out
|
|
34
|
+
of memory on Cloudflare.
|
|
35
|
+
|
|
36
|
+
## [0.6.0] - 2026-11-13
|
|
37
|
+
|
|
38
|
+
Still generated from `@shopify/polaris-types` 2.0.0. No changes to the components.
|
|
39
|
+
|
|
40
|
+
The App Bridge wrappers follow Shopify's own React wrapper, but have not been tested in a
|
|
41
|
+
live Shopify admin yet; the docs mark the behavior that is still unverified. Please open an
|
|
42
|
+
issue if something doesn't work.
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
|
|
46
|
+
- `polaris-vue-elements/app-bridge`: Vue 3 counterparts of Shopify's
|
|
47
|
+
`@shopify/app-bridge-react` 4.3.0. It has the components `Modal`, `SaveBar`, `AppWindow`,
|
|
48
|
+
`TitleBar` and `NavMenu`, and the composable `useAppBridge()`.
|
|
49
|
+
- `Modal`, `SaveBar` and `AppWindow` support `v-model:open` and emit `@show` and `@hide`.
|
|
50
|
+
- `Modal` renders its content inside the App Bridge modal, as the React version does.
|
|
51
|
+
- Types come from `@shopify/app-bridge-types`, a new optional peer dependency. Install it
|
|
52
|
+
only if you use App Bridge.
|
|
53
|
+
- The main `polaris-vue-elements` entry is unchanged and loads no App Bridge code.
|
|
54
|
+
|
|
55
|
+
See [App Bridge components](https://polaris-vue-elements.dev/app-bridge/).
|
|
56
|
+
- `polaris-vue-elements/app-bridge/elements`: types for the raw `<ui-modal>`,
|
|
57
|
+
`<ui-save-bar>`, `<ui-title-bar>`, `<ui-nav-menu>`, `<s-app-window>` and `<s-app-nav>`
|
|
58
|
+
tags in Vue templates.
|
|
59
|
+
|
|
60
|
+
### Changed
|
|
61
|
+
|
|
62
|
+
- Docs: App Bridge and CSS variables are now sections of their own, next to Guide and
|
|
63
|
+
Components in the nav and the sidebar. The CSS variables page is split into an
|
|
64
|
+
[overview](https://polaris-vue-elements.dev/css-variables/), the
|
|
65
|
+
[full list](https://polaris-vue-elements.dev/css-variables/reference) and
|
|
66
|
+
[migrating from `@shopify/polaris-tokens`](https://polaris-vue-elements.dev/css-variables/migration).
|
|
67
|
+
Old `/guide/css-variables` links redirect.
|
|
68
|
+
|
|
14
69
|
## [0.5.0] - 2026-11-09
|
|
15
70
|
|
|
16
71
|
Still generated from `@shopify/polaris-types` 2.0.0. No changes to the components.
|
|
@@ -23,7 +78,7 @@ Still generated from `@shopify/polaris-types` 2.0.0. No changes to the component
|
|
|
23
78
|
the names. Unofficial: values follow the CDN, and a daily job opens a pull request
|
|
24
79
|
when they change. Includes the `admin-next` theme, which applies under the class the
|
|
25
80
|
runtime puts on `<html>`.
|
|
26
|
-
See [CSS variables](https://polaris-vue-elements.dev/
|
|
81
|
+
See [CSS variables](https://polaris-vue-elements.dev/css-variables/).
|
|
27
82
|
- Docs: a "Best practices" section on 50 component pages, before the example. Each is
|
|
28
83
|
our own summary of Shopify's guidance for that component, with Vue snippets, and links
|
|
29
84
|
to the full section on shopify.dev. Components Shopify publishes no guidance for have
|
|
@@ -147,7 +202,9 @@ Initial release: typed Vue 3 wrappers for the 59 Shopify Polaris web components
|
|
|
147
202
|
`showOverlay()` / `hideOverlay()` / `toggleOverlay()`).
|
|
148
203
|
- ESM build with bundled type declarations; `vue` ^3.5 as a peer dependency.
|
|
149
204
|
|
|
150
|
-
[Unreleased]: https://github.com/HQCuong/polaris-vue/compare/v0.
|
|
205
|
+
[Unreleased]: https://github.com/HQCuong/polaris-vue/compare/v0.6.1...HEAD
|
|
206
|
+
[0.6.1]: https://github.com/HQCuong/polaris-vue/compare/v0.6.0...v0.6.1
|
|
207
|
+
[0.6.0]: https://github.com/HQCuong/polaris-vue/compare/v0.5.0...v0.6.0
|
|
151
208
|
[0.5.0]: https://github.com/HQCuong/polaris-vue/compare/v0.4.2...v0.5.0
|
|
152
209
|
[0.4.2]: https://github.com/HQCuong/polaris-vue/compare/v0.4.1...v0.4.2
|
|
153
210
|
[0.4.1]: https://github.com/HQCuong/polaris-vue/compare/v0.4.0...v0.4.1
|
package/README.md
CHANGED
|
@@ -91,8 +91,9 @@ Everything lives at **[polaris-vue-elements.dev](https://polaris-vue-elements.de
|
|
|
91
91
|
|
|
92
92
|
- [Getting started](https://polaris-vue-elements.dev/guide/getting-started): setup, `v-model`, overlays and typed raw tags.
|
|
93
93
|
- [Build a Shopify embedded app with Vue 3](https://polaris-vue-elements.dev/guide/shopify-embedded-app): App Bridge, authenticated `fetch`, navigation and the save bar.
|
|
94
|
+
- [App Bridge components](https://polaris-vue-elements.dev/app-bridge/): `Modal`, `SaveBar`, `AppWindow`, `TitleBar`, `NavMenu` and `useAppBridge` from `polaris-vue-elements/app-bridge`, mirroring `@shopify/app-bridge-react`.
|
|
94
95
|
- [Known quirks](https://polaris-vue-elements.dev/guide/quirks): Polaris behaviors verified in a real browser.
|
|
95
|
-
- [CSS variables](https://polaris-vue-elements.dev/
|
|
96
|
+
- [CSS variables](https://polaris-vue-elements.dev/css-variables/): Polaris design tokens (`--p-color-*`, `--p-space-*`, …) as an importable `polaris-vue-elements/tokens.css` for your own layout CSS.
|
|
96
97
|
- [Component reference](https://polaris-vue-elements.dev/components/): props, events, slots, best practices and live examples for all 62 components.
|
|
97
98
|
|
|
98
99
|
The site's source is in [`docs/`](./docs); run it locally with `npm run docs:dev`.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AppWindowProps, OverlayComponent } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Wrapper around the App Bridge `s-app-window` element, a fullscreen window that loads
|
|
4
|
+
* `src` in an iframe. Mirrors `AppWindow` in `@shopify/app-bridge-react` 4.3.0: `open`
|
|
5
|
+
* calls `show()`/`hide()`, `show`/`hide` events are emitted, and `hide()` runs on
|
|
6
|
+
* unmount. It has no slot: `SAppWindowAttributes` defines no children.
|
|
7
|
+
*/
|
|
8
|
+
export declare const AppWindow: OverlayComponent<AppWindowProps, SAppWindowElement, Record<never, never>>;
|
|
9
|
+
//# sourceMappingURL=AppWindow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppWindow.d.ts","sourceRoot":"","sources":["../../src/lib/app-bridge/AppWindow.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAG/D;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAYL,gBAAgB,CAAC,cAAc,EAAE,iBAAiB,EAAE,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ModalProps, OverlayComponent } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Wrapper around the App Bridge `ui-modal` element. Mirrors `Modal` in
|
|
4
|
+
* `@shopify/app-bridge-react` 4.3.0:
|
|
5
|
+
*
|
|
6
|
+
* - `open` calls `show()`/`hide()`, `show`/`hide` events are emitted, and `hide()`
|
|
7
|
+
* runs on unmount.
|
|
8
|
+
* - A `TitleBar` (or `<ui-title-bar>`) and a `SaveBar` (or `<ui-save-bar>`) in the
|
|
9
|
+
* default slot stay as direct children of `ui-modal`.
|
|
10
|
+
* - Everything else is teleported into the element's `content`, inside an empty
|
|
11
|
+
* `<div>` child. Until `ui-modal` is defined (and during SSR) the content is not
|
|
12
|
+
* rendered, as in React, where the portal is `null` until `modal.content` exists.
|
|
13
|
+
*
|
|
14
|
+
* @see https://shopify.dev/docs/api/app-bridge-library/react-components/modal
|
|
15
|
+
*/
|
|
16
|
+
export declare const Modal: OverlayComponent<ModalProps, UIModalElement>;
|
|
17
|
+
//# sourceMappingURL=Modal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../src/lib/app-bridge/Modal.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAG3D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,KAAK,EAuCD,gBAAgB,CAAC,UAAU,EAAE,cAAc,CAAC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { NavMenuProps, PassThroughComponent } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Renders the App Bridge `ui-nav-menu` element. `@shopify/app-bridge-react` 4.3.0
|
|
4
|
+
* exports `NavMenu` as the bare tag name; this component adds typing.
|
|
5
|
+
*
|
|
6
|
+
* Shopify now documents `<s-app-nav>` for app navigation.
|
|
7
|
+
*
|
|
8
|
+
* @see https://shopify.dev/docs/api/app-bridge-library/react-components/navmenu
|
|
9
|
+
*/
|
|
10
|
+
export declare const NavMenu: PassThroughComponent<NavMenuProps, UINavMenuElement>;
|
|
11
|
+
//# sourceMappingURL=NavMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavMenu.d.ts","sourceRoot":"","sources":["../../src/lib/app-bridge/NavMenu.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAEjE;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,EAMH,oBAAoB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { OverlayComponent, SaveBarProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Wrapper around the App Bridge `ui-save-bar` element. Mirrors `SaveBar` in
|
|
4
|
+
* `@shopify/app-bridge-react` 4.3.0: `open` calls `show()`/`hide()`, `show`/`hide`
|
|
5
|
+
* events are emitted, and `hide()` runs on unmount. Put a `<button variant="primary">`
|
|
6
|
+
* (Save) and a `<button>` (Discard) in the default slot.
|
|
7
|
+
*
|
|
8
|
+
* @see https://shopify.dev/docs/api/app-bridge-library/react-components/savebar
|
|
9
|
+
*/
|
|
10
|
+
export declare const SaveBar: OverlayComponent<SaveBarProps, UISaveBarElement>;
|
|
11
|
+
//# sourceMappingURL=SaveBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SaveBar.d.ts","sourceRoot":"","sources":["../../src/lib/app-bridge/SaveBar.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAY7D;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,EA+BH,gBAAgB,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { PassThroughComponent, TitleBarProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Renders the App Bridge `ui-title-bar` element. `@shopify/app-bridge-react` 4.3.0
|
|
4
|
+
* exports `TitleBar` as the bare tag name; this component adds prop typing and lets
|
|
5
|
+
* `Modal` recognise it. `title` is always set as an attribute, as in Shopify's
|
|
6
|
+
* examples (`UITitleBarElement` omits the `HTMLElement` `title` property).
|
|
7
|
+
*
|
|
8
|
+
* Shopify now documents `s-page` (`SPage`) for the page title bar; a `TitleBar` in a
|
|
9
|
+
* `Modal` sets the modal's header and footer.
|
|
10
|
+
*
|
|
11
|
+
* @see https://shopify.dev/docs/api/app-bridge-library/react-components/titlebar
|
|
12
|
+
*/
|
|
13
|
+
export declare const TitleBar: PassThroughComponent<TitleBarProps, UITitleBarElement>;
|
|
14
|
+
//# sourceMappingURL=TitleBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TitleBar.d.ts","sourceRoot":"","sources":["../../src/lib/app-bridge/TitleBar.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAElE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,QAAQ,EAUJ,oBAAoB,CAAC,aAAa,EAAE,iBAAiB,CAAC,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { SAppNavAttributes, SAppWindowAttributes, UIModalAttributes, UINavMenuAttributes, UISaveBarAttributes, UITitleBarAttributes } from '@shopify/app-bridge-types';
|
|
2
|
+
import type { AppBridgeElementTag, OverlayEvents } from './types';
|
|
3
|
+
type NoChildren<T> = Omit<T, 'children'>;
|
|
4
|
+
/** The raw App Bridge tags this file types (every `AppBridgeElements` key except `s-page`). */
|
|
5
|
+
export type AppBridgeElementTagName = 'ui-modal' | 'ui-save-bar' | 's-app-window' | 'ui-title-bar' | 'ui-nav-menu' | 's-app-nav';
|
|
6
|
+
declare module 'vue' {
|
|
7
|
+
interface GlobalComponents {
|
|
8
|
+
'ui-modal': AppBridgeElementTag<NoChildren<UIModalAttributes>, OverlayEvents, UIModalElement>;
|
|
9
|
+
'ui-save-bar': AppBridgeElementTag<NoChildren<UISaveBarAttributes>, OverlayEvents, UISaveBarElement>;
|
|
10
|
+
's-app-window': AppBridgeElementTag<SAppWindowAttributes, OverlayEvents, SAppWindowElement>;
|
|
11
|
+
'ui-title-bar': AppBridgeElementTag<NoChildren<UITitleBarAttributes>, Record<string, never>, UITitleBarElement>;
|
|
12
|
+
'ui-nav-menu': AppBridgeElementTag<NoChildren<UINavMenuAttributes>, Record<string, never>, UINavMenuElement>;
|
|
13
|
+
's-app-nav': AppBridgeElementTag<NoChildren<SAppNavAttributes>, Record<string, never>, SAppNavElement>;
|
|
14
|
+
}
|
|
15
|
+
interface ButtonHTMLAttributes {
|
|
16
|
+
variant?: HTMLButtonElement['variant'];
|
|
17
|
+
tone?: HTMLButtonElement['tone'];
|
|
18
|
+
loading?: HTMLButtonElement['loading'];
|
|
19
|
+
}
|
|
20
|
+
interface AnchorHTMLAttributes {
|
|
21
|
+
variant?: HTMLAnchorElement['variant'];
|
|
22
|
+
tone?: HTMLAnchorElement['tone'];
|
|
23
|
+
loading?: HTMLAnchorElement['loading'];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=elements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elements.d.ts","sourceRoot":"","sources":["../../src/lib/app-bridge/elements.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACV,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEjE,KAAK,UAAU,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;AAExC,+FAA+F;AAC/F,MAAM,MAAM,uBAAuB,GAC/B,UAAU,GACV,aAAa,GACb,cAAc,GACd,cAAc,GACd,aAAa,GACb,WAAW,CAAA;AAEf,OAAO,QAAQ,KAAK,CAAC;IACnB,UAAU,gBAAgB;QACxB,UAAU,EAAE,mBAAmB,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,aAAa,EAAE,cAAc,CAAC,CAAA;QAC7F,aAAa,EAAE,mBAAmB,CAChC,UAAU,CAAC,mBAAmB,CAAC,EAC/B,aAAa,EACb,gBAAgB,CACjB,CAAA;QACD,cAAc,EAAE,mBAAmB,CAAC,oBAAoB,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAA;QAC3F,cAAc,EAAE,mBAAmB,CACjC,UAAU,CAAC,oBAAoB,CAAC,EAChC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACrB,iBAAiB,CAClB,CAAA;QACD,aAAa,EAAE,mBAAmB,CAChC,UAAU,CAAC,mBAAmB,CAAC,EAC/B,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACrB,gBAAgB,CACjB,CAAA;QACD,WAAW,EAAE,mBAAmB,CAC9B,UAAU,CAAC,iBAAiB,CAAC,EAC7B,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACrB,cAAc,CACf,CAAA;KACF;IAKD,UAAU,oBAAoB;QAC5B,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAA;QACtC,IAAI,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAA;QAChC,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAA;KACvC;IACD,UAAU,oBAAoB;QAC5B,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAA;QACtC,IAAI,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAA;QAChC,OAAO,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAA;KACvC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type * from '@shopify/app-bridge-types';
|
|
2
|
+
export { useAppBridge } from './useAppBridge';
|
|
3
|
+
export { Modal } from './Modal';
|
|
4
|
+
export { SaveBar } from './SaveBar';
|
|
5
|
+
export { AppWindow } from './AppWindow';
|
|
6
|
+
export { TitleBar } from './TitleBar';
|
|
7
|
+
export { NavMenu } from './NavMenu';
|
|
8
|
+
export type { AppWindowProps, ModalProps, NavMenuProps, OverlayEvents, OverlayOpenProps, SaveBarProps, TitleBarProps, } from './types';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lib/app-bridge/index.ts"],"names":[],"mappings":"AAOA,mBAAmB,2BAA2B,CAAA;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,YAAY,EACV,cAAc,EACd,UAAU,EACV,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,YAAY,EACZ,aAAa,GACd,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { Comment as e, Fragment as t, Teleport as n, defineComponent as r, h as i, nextTick as a, onBeforeUnmount as o, onMounted as s, shallowRef as c, watch as l } from "vue";
|
|
2
|
+
// src/lib/app-bridge/useAppBridge.ts
|
|
3
|
+
var u;
|
|
4
|
+
function d() {
|
|
5
|
+
if (typeof window > "u") return u ??= new Proxy({}, { get(e, t) {
|
|
6
|
+
throw Error(`shopify.${String(t)} can't be used in a server environment. You likely need to move this code into onMounted().`);
|
|
7
|
+
} }), u;
|
|
8
|
+
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");
|
|
9
|
+
return window.shopify;
|
|
10
|
+
}
|
|
11
|
+
// src/lib/app-bridge/useOverlaySync.ts
|
|
12
|
+
var f = 3e3;
|
|
13
|
+
function p(e, t, n, r, i = {}) {
|
|
14
|
+
let a = !1, c = !1, u, d = () => {
|
|
15
|
+
let e = t.value;
|
|
16
|
+
e && a && (n.open ? e.show() : e.hide());
|
|
17
|
+
}, p = (e) => {
|
|
18
|
+
i.onShow?.(), r("show", e), n.open || r("update:open", !0);
|
|
19
|
+
}, m = (e) => {
|
|
20
|
+
r("hide", e), n.open && r("update:open", !1);
|
|
21
|
+
}, h = async () => {
|
|
22
|
+
await customElements.whenDefined(e), c || (await i.beforeFirstSync?.(), c || (a = !0, d()));
|
|
23
|
+
};
|
|
24
|
+
return s(() => {
|
|
25
|
+
let n = t.value;
|
|
26
|
+
n && typeof customElements < "u" && (n.addEventListener("show", p), n.addEventListener("hide", m), typeof process < "u" && process.env.NODE_ENV !== "production" && !customElements.get(e) && (u = setTimeout(() => {
|
|
27
|
+
!c && !customElements.get(e) && console.warn(`[polaris-vue-elements] <${e}> is still not defined ${f / 1e3} s after mount. This likely means the App Bridge script tag was not added correctly to this page.`);
|
|
28
|
+
}, f)), h());
|
|
29
|
+
}), l(() => n.open, d), o(() => {
|
|
30
|
+
c = !0, u !== void 0 && clearTimeout(u);
|
|
31
|
+
let e = t.value;
|
|
32
|
+
e && (e.removeEventListener("show", p), e.removeEventListener("hide", m), a && e.hide());
|
|
33
|
+
}), { isReady: () => a };
|
|
34
|
+
}
|
|
35
|
+
// src/lib/app-bridge/SaveBar.ts
|
|
36
|
+
function m(e) {
|
|
37
|
+
return e === "" || !!e;
|
|
38
|
+
}
|
|
39
|
+
var h = /*@__PURE__*/ r({
|
|
40
|
+
name: "ui-save-bar",
|
|
41
|
+
inheritAttrs: !1,
|
|
42
|
+
props: {
|
|
43
|
+
open: {
|
|
44
|
+
type: Boolean,
|
|
45
|
+
default: !1
|
|
46
|
+
},
|
|
47
|
+
discardConfirmation: {
|
|
48
|
+
type: null,
|
|
49
|
+
default: void 0
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
emits: [
|
|
53
|
+
"show",
|
|
54
|
+
"hide",
|
|
55
|
+
"update:open"
|
|
56
|
+
],
|
|
57
|
+
setup(e, { attrs: t, slots: n, emit: r }) {
|
|
58
|
+
let a = c(null), o = () => {
|
|
59
|
+
let t = a.value;
|
|
60
|
+
t && e.discardConfirmation !== void 0 && (t.discardConfirmation = m(e.discardConfirmation));
|
|
61
|
+
}, s = p("ui-save-bar", a, e, r, { beforeFirstSync: o });
|
|
62
|
+
return l(() => e.discardConfirmation, () => {
|
|
63
|
+
s.isReady() && o();
|
|
64
|
+
}), () => i("ui-save-bar", {
|
|
65
|
+
...t,
|
|
66
|
+
ref: a
|
|
67
|
+
}, n.default?.());
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
// src/lib/app-bridge/splitModalChildren.ts
|
|
71
|
+
function g(n, r = []) {
|
|
72
|
+
for (let i of n) i.type === t && Array.isArray(i.children) ? g(i.children, r) : i.type !== e && r.push(i);
|
|
73
|
+
return r;
|
|
74
|
+
}
|
|
75
|
+
function _(e, t, n) {
|
|
76
|
+
let r, i, a = [];
|
|
77
|
+
for (let o of g(e)) o.type === "ui-title-bar" || t(o.type) ? r = o : o.type === "ui-save-bar" || n(o.type) ? i = o : a.push(o);
|
|
78
|
+
return {
|
|
79
|
+
titleBar: r,
|
|
80
|
+
saveBar: i,
|
|
81
|
+
content: a
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
// src/lib/app-bridge/TitleBar.ts
|
|
85
|
+
var v = /*@__PURE__*/ r({
|
|
86
|
+
name: "ui-title-bar",
|
|
87
|
+
inheritAttrs: !1,
|
|
88
|
+
setup(e, { attrs: t, slots: n }) {
|
|
89
|
+
return () => {
|
|
90
|
+
let { title: e, ...r } = t, a = e === void 0 ? r : {
|
|
91
|
+
...r,
|
|
92
|
+
"^title": e
|
|
93
|
+
};
|
|
94
|
+
return i("ui-title-bar", a, n.default?.());
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
}), y = /*@__PURE__*/ r({
|
|
98
|
+
name: "ui-modal",
|
|
99
|
+
inheritAttrs: !1,
|
|
100
|
+
props: { open: {
|
|
101
|
+
type: Boolean,
|
|
102
|
+
default: !1
|
|
103
|
+
} },
|
|
104
|
+
emits: [
|
|
105
|
+
"show",
|
|
106
|
+
"hide",
|
|
107
|
+
"update:open"
|
|
108
|
+
],
|
|
109
|
+
setup(e, { attrs: t, slots: r, emit: o }) {
|
|
110
|
+
let s = c(null), l = c(null), u = () => {
|
|
111
|
+
let e = s.value?.content;
|
|
112
|
+
e && e !== l.value && (l.value = e);
|
|
113
|
+
};
|
|
114
|
+
return p("ui-modal", s, e, o, {
|
|
115
|
+
beforeFirstSync: async () => {
|
|
116
|
+
u(), await a();
|
|
117
|
+
},
|
|
118
|
+
onShow: u
|
|
119
|
+
}), () => {
|
|
120
|
+
let { titleBar: e, saveBar: a, content: o } = _(r.default?.() ?? [], (e) => e === v, (e) => e === h);
|
|
121
|
+
return i("ui-modal", {
|
|
122
|
+
...t,
|
|
123
|
+
ref: s
|
|
124
|
+
}, [
|
|
125
|
+
e,
|
|
126
|
+
a,
|
|
127
|
+
i("div", null, l.value ? [i(n, { to: l.value }, o)] : [])
|
|
128
|
+
]);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}), b = /*@__PURE__*/ r({
|
|
132
|
+
name: "s-app-window",
|
|
133
|
+
inheritAttrs: !1,
|
|
134
|
+
props: { open: {
|
|
135
|
+
type: Boolean,
|
|
136
|
+
default: !1
|
|
137
|
+
} },
|
|
138
|
+
emits: [
|
|
139
|
+
"show",
|
|
140
|
+
"hide",
|
|
141
|
+
"update:open"
|
|
142
|
+
],
|
|
143
|
+
setup(e, { attrs: t, emit: n }) {
|
|
144
|
+
let r = c(null);
|
|
145
|
+
return p("s-app-window", r, e, n), () => i("s-app-window", {
|
|
146
|
+
...t,
|
|
147
|
+
ref: r
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
}), x = /*@__PURE__*/ r({
|
|
151
|
+
name: "ui-nav-menu",
|
|
152
|
+
inheritAttrs: !1,
|
|
153
|
+
setup(e, { attrs: t, slots: n }) {
|
|
154
|
+
return () => i("ui-nav-menu", t, n.default?.());
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
export { b as AppWindow, y as Modal, x as NavMenu, h as SaveBar, v as TitleBar, d as useAppBridge };
|
|
158
|
+
|
|
159
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["serverProxy","useAppBridge","prop","MISSING_TAG_WARNING_DELAY","useOverlaySync","ready","disposed","warnTimer","sync","el","elRef","props","onShow","hooks","emit","event","onHide","firstSync","tag","onMounted","watch","onBeforeUnmount","isBooleanOn","value","SaveBar","shallowRef","applyDiscardConfirmation","h","attrs","slots","flatten","node","nodes","Fragment","out","Comment","splitModalChildren","titleBar","saveBar","content","isTitleBar","isSaveBar","TitleBar","rest","data","title","Modal","target","resolveTarget","nextTick","type","Teleport","AppWindow","NavMenu"],"sources":["../../src/lib/app-bridge/useAppBridge.ts","../../src/lib/app-bridge/useOverlaySync.ts","../../src/lib/app-bridge/SaveBar.ts","../../src/lib/app-bridge/splitModalChildren.ts","../../src/lib/app-bridge/TitleBar.ts","../../src/lib/app-bridge/Modal.ts","../../src/lib/app-bridge/AppWindow.ts","../../src/lib/app-bridge/NavMenu.ts"],"sourcesContent":["import type { ShopifyGlobal } from '@shopify/app-bridge-types'\n\nlet serverProxy: ShopifyGlobal | undefined\n\n/**\n * Returns the `shopify` global, to use App Bridge APIs such as `toast` and\n * `resourcePicker`. Mirrors `useAppBridge` in `@shopify/app-bridge-react` 4.3.0.\n *\n * - On the server (no `window`), it returns a proxy that throws when you read any\n * property, so call the APIs from `onMounted()` or an event handler.\n * - In the browser, it throws when the App Bridge script has not defined `shopify`.\n *\n * @see https://shopify.dev/docs/api/app-bridge-library/react-hooks/useappbridge\n */\nexport function useAppBridge(): ShopifyGlobal {\n if (typeof window === 'undefined') {\n // Created lazily, so importing this module has no side effect.\n serverProxy ??= new Proxy({} as ShopifyGlobal, {\n get(_, prop) {\n throw new Error(\n `shopify.${String(prop)} can't be used in a server environment. You likely need to move this code into onMounted().`,\n )\n },\n })\n return serverProxy\n }\n if (!window.shopify) {\n throw new Error(\n 'The shopify global is not defined. This likely means the App Bridge script tag was not added correctly to this page',\n )\n }\n return window.shopify\n}\n","/// <reference types=\"@shopify/app-bridge-types\" />\nimport { onBeforeUnmount, onMounted, watch, type ShallowRef } from 'vue'\n\n/** The App Bridge elements whose open state the wrappers sync. */\nexport type OverlayElement = UIModalElement | UISaveBarElement | SAppWindowElement\n\nexport type OverlayEmit = (event: 'show' | 'hide' | 'update:open', ...args: unknown[]) => void\n\nexport interface OverlaySyncHooks {\n /** Runs once the tag is defined, before the first `show()`/`hide()`. */\n beforeFirstSync?: () => void | Promise<void>\n /** Runs on every native `show` event, before `show` is emitted. */\n onShow?: () => void\n}\n\nexport interface OverlaySync {\n /** True once the tag is defined and the first sync has run. */\n isReady: () => boolean\n}\n\n// Declared locally so the library needs no Node types. Bundlers replace\n// `process.env.NODE_ENV` in the consumer's build; the `typeof` guard covers the rest.\ndeclare const process: { env: { NODE_ENV?: string } } | undefined\n\nconst MISSING_TAG_WARNING_DELAY = 3000\n\n/**\n * Syncs the `open` prop of an App Bridge overlay element with its `show()`/`hide()`\n * methods, and its native `show`/`hide` events with Vue emits.\n *\n * Mirrors the effects of `Modal`, `SaveBar` and `AppWindow` in\n * `@shopify/app-bridge-react` 4.3.0: `open ? show() : hide()` whenever the element or\n * `open` changes (so `hide()` also runs on mount when `open` is false), `onShow`/`onHide`\n * listeners, and `hide()` on unmount. Differences:\n *\n * - The first sync waits for `customElements.whenDefined(tag)`, so a late App Bridge\n * script still gets the initial state.\n * - `update:open` is emitted only when the element's state differs from `open`.\n * - `hide()` on unmount runs in `onBeforeUnmount`, while the element is still in the\n * document; React's cleanup runs after the element is removed.\n */\nexport function useOverlaySync(\n tag: string,\n elRef: Readonly<ShallowRef<OverlayElement | null>>,\n props: { readonly open: boolean },\n emit: OverlayEmit,\n hooks: OverlaySyncHooks = {},\n): OverlaySync {\n let ready = false\n let disposed = false\n let warnTimer: ReturnType<typeof setTimeout> | undefined\n\n const sync = (): void => {\n const el = elRef.value\n if (!el || !ready) return\n if (props.open) void el.show()\n else void el.hide()\n }\n\n const onShow = (event: Event): void => {\n hooks.onShow?.()\n emit('show', event)\n if (!props.open) emit('update:open', true)\n }\n const onHide = (event: Event): void => {\n emit('hide', event)\n if (props.open) emit('update:open', false)\n }\n\n const firstSync = async (): Promise<void> => {\n await customElements.whenDefined(tag)\n if (disposed) return\n await hooks.beforeFirstSync?.()\n if (disposed) return\n ready = true\n sync()\n }\n\n onMounted(() => {\n const el = elRef.value\n if (!el || typeof customElements === 'undefined') return\n el.addEventListener('show', onShow)\n el.addEventListener('hide', onHide)\n\n if (\n typeof process !== 'undefined' &&\n process.env.NODE_ENV !== 'production' &&\n !customElements.get(tag)\n ) {\n warnTimer = setTimeout(() => {\n if (!disposed && !customElements.get(tag)) {\n console.warn(\n `[polaris-vue-elements] <${tag}> is still not defined ${MISSING_TAG_WARNING_DELAY / 1000} s after mount. This likely means the App Bridge script tag was not added correctly to this page.`,\n )\n }\n }, MISSING_TAG_WARNING_DELAY)\n }\n\n void firstSync()\n })\n\n watch(() => props.open, sync)\n\n onBeforeUnmount(() => {\n disposed = true\n if (warnTimer !== undefined) clearTimeout(warnTimer)\n const el = elRef.value\n if (!el) return\n el.removeEventListener('show', onShow)\n el.removeEventListener('hide', onHide)\n if (ready) void el.hide()\n })\n\n return { isReady: () => ready }\n}\n","/// <reference types=\"@shopify/app-bridge-types\" />\nimport { defineComponent, h, shallowRef, watch } from 'vue'\nimport type { OverlayComponent, SaveBarProps } from './types'\nimport { useOverlaySync } from './useOverlaySync'\n\n/**\n * A boolean prop is on for `true` and for the empty string (a bare attribute). Copied\n * from `runtime/createWrapper.ts` on purpose: sharing a module with the main entry\n * would make Rollup emit a shared chunk that `dist/index.js` imports.\n */\nfunction isBooleanOn(value: unknown): boolean {\n return value === '' || Boolean(value)\n}\n\n/**\n * Wrapper around the App Bridge `ui-save-bar` element. Mirrors `SaveBar` in\n * `@shopify/app-bridge-react` 4.3.0: `open` calls `show()`/`hide()`, `show`/`hide`\n * events are emitted, and `hide()` runs on unmount. Put a `<button variant=\"primary\">`\n * (Save) and a `<button>` (Discard) in the default slot.\n *\n * @see https://shopify.dev/docs/api/app-bridge-library/react-components/savebar\n */\nexport const SaveBar = /*@__PURE__*/ defineComponent({\n name: 'ui-save-bar',\n inheritAttrs: false,\n props: {\n open: { type: Boolean, default: false },\n // Assigned as a DOM property: `@shopify/app-bridge-types` documents only the\n // `discardConfirmation` getter/setter, not an attribute name.\n discardConfirmation: { type: null, default: undefined },\n },\n emits: ['show', 'hide', 'update:open'],\n setup(props, { attrs, slots, emit }) {\n const elRef = shallowRef<UISaveBarElement | null>(null)\n\n const applyDiscardConfirmation = (): void => {\n const el = elRef.value\n if (!el || props.discardConfirmation === undefined) return\n el.discardConfirmation = isBooleanOn(props.discardConfirmation)\n }\n\n const sync = useOverlaySync('ui-save-bar', elRef, props, emit, {\n beforeFirstSync: applyDiscardConfirmation,\n })\n watch(\n () => props.discardConfirmation,\n () => {\n if (sync.isReady()) applyDiscardConfirmation()\n },\n )\n\n return () => h('ui-save-bar', { ...attrs, ref: elRef }, slots.default?.())\n },\n}) as unknown as OverlayComponent<SaveBarProps, UISaveBarElement>\n","import { Comment, Fragment, type VNode } from 'vue'\n\nexport interface ModalChildren {\n titleBar: VNode | undefined\n saveBar: VNode | undefined\n content: VNode[]\n}\n\nfunction flatten(nodes: VNode[], out: VNode[] = []): VNode[] {\n for (const node of nodes) {\n if (node.type === Fragment && Array.isArray(node.children)) {\n // v-for and <template v-if> render fragments; React's Children.toArray flattens too.\n flatten(node.children as VNode[], out)\n } else if (node.type !== Comment) {\n // Comments are v-if placeholders.\n out.push(node)\n }\n }\n return out\n}\n\n/**\n * Splits a `Modal` default slot the way `Modal` in `@shopify/app-bridge-react` 4.3.0\n * does: the last title bar and the last save bar stay as direct children of\n * `ui-modal`, everything else is modal content. `isTitleBar`/`isSaveBar` identify the\n * `TitleBar`/`SaveBar` components; raw `<ui-title-bar>`/`<ui-save-bar>` tags are\n * matched by tag name.\n */\nexport function splitModalChildren(\n nodes: VNode[],\n isTitleBar: (type: unknown) => boolean,\n isSaveBar: (type: unknown) => boolean,\n): ModalChildren {\n let titleBar: VNode | undefined\n let saveBar: VNode | undefined\n const content: VNode[] = []\n for (const node of flatten(nodes)) {\n if (node.type === 'ui-title-bar' || isTitleBar(node.type)) titleBar = node\n else if (node.type === 'ui-save-bar' || isSaveBar(node.type)) saveBar = node\n else content.push(node)\n }\n return { titleBar, saveBar, content }\n}\n","/// <reference types=\"@shopify/app-bridge-types\" />\nimport { defineComponent, h } from 'vue'\nimport type { PassThroughComponent, TitleBarProps } from './types'\n\n/**\n * Renders the App Bridge `ui-title-bar` element. `@shopify/app-bridge-react` 4.3.0\n * exports `TitleBar` as the bare tag name; this component adds prop typing and lets\n * `Modal` recognise it. `title` is always set as an attribute, as in Shopify's\n * examples (`UITitleBarElement` omits the `HTMLElement` `title` property).\n *\n * Shopify now documents `s-page` (`SPage`) for the page title bar; a `TitleBar` in a\n * `Modal` sets the modal's header and footer.\n *\n * @see https://shopify.dev/docs/api/app-bridge-library/react-components/titlebar\n */\nexport const TitleBar = /*@__PURE__*/ defineComponent({\n name: 'ui-title-bar',\n inheritAttrs: false,\n setup(_, { attrs, slots }) {\n return () => {\n const { title, ...rest } = attrs\n const data = title === undefined ? rest : { ...rest, '^title': title }\n return h('ui-title-bar', data, slots.default?.())\n }\n },\n}) as unknown as PassThroughComponent<TitleBarProps, UITitleBarElement>\n","/// <reference types=\"@shopify/app-bridge-types\" />\nimport { defineComponent, h, nextTick, shallowRef, Teleport } from 'vue'\nimport { SaveBar } from './SaveBar'\nimport { splitModalChildren } from './splitModalChildren'\nimport { TitleBar } from './TitleBar'\nimport type { ModalProps, OverlayComponent } from './types'\nimport { useOverlaySync } from './useOverlaySync'\n\n/**\n * Wrapper around the App Bridge `ui-modal` element. Mirrors `Modal` in\n * `@shopify/app-bridge-react` 4.3.0:\n *\n * - `open` calls `show()`/`hide()`, `show`/`hide` events are emitted, and `hide()`\n * runs on unmount.\n * - A `TitleBar` (or `<ui-title-bar>`) and a `SaveBar` (or `<ui-save-bar>`) in the\n * default slot stay as direct children of `ui-modal`.\n * - Everything else is teleported into the element's `content`, inside an empty\n * `<div>` child. Until `ui-modal` is defined (and during SSR) the content is not\n * rendered, as in React, where the portal is `null` until `modal.content` exists.\n *\n * @see https://shopify.dev/docs/api/app-bridge-library/react-components/modal\n */\nexport const Modal = /*@__PURE__*/ defineComponent({\n name: 'ui-modal',\n inheritAttrs: false,\n props: {\n open: { type: Boolean, default: false },\n },\n emits: ['show', 'hide', 'update:open'],\n setup(props, { attrs, slots, emit }) {\n const elRef = shallowRef<UIModalElement | null>(null)\n const target = shallowRef<HTMLElement | null>(null)\n\n const resolveTarget = (): void => {\n const content = elRef.value?.content\n if (content && content !== target.value) target.value = content\n }\n\n useOverlaySync('ui-modal', elRef, props, emit, {\n // Place the content before the first show(), which copies it into the modal.\n beforeFirstSync: async () => {\n resolveTarget()\n await nextTick()\n },\n // Re-read in case App Bridge replaced `content` (UNVERIFIED whether it does).\n onShow: resolveTarget,\n })\n\n return () => {\n const { titleBar, saveBar, content } = splitModalChildren(\n slots.default?.() ?? [],\n (type) => type === TitleBar,\n (type) => type === SaveBar,\n )\n return h('ui-modal', { ...attrs, ref: elRef }, [\n titleBar,\n saveBar,\n h('div', null, target.value ? [h(Teleport, { to: target.value }, content)] : []),\n ])\n }\n },\n}) as unknown as OverlayComponent<ModalProps, UIModalElement>\n","/// <reference types=\"@shopify/app-bridge-types\" />\nimport { defineComponent, h, shallowRef } from 'vue'\nimport type { AppWindowProps, OverlayComponent } from './types'\nimport { useOverlaySync } from './useOverlaySync'\n\n/**\n * Wrapper around the App Bridge `s-app-window` element, a fullscreen window that loads\n * `src` in an iframe. Mirrors `AppWindow` in `@shopify/app-bridge-react` 4.3.0: `open`\n * calls `show()`/`hide()`, `show`/`hide` events are emitted, and `hide()` runs on\n * unmount. It has no slot: `SAppWindowAttributes` defines no children.\n */\nexport const AppWindow = /*@__PURE__*/ defineComponent({\n name: 's-app-window',\n inheritAttrs: false,\n props: {\n open: { type: Boolean, default: false },\n },\n emits: ['show', 'hide', 'update:open'],\n setup(props, { attrs, emit }) {\n const elRef = shallowRef<SAppWindowElement | null>(null)\n useOverlaySync('s-app-window', elRef, props, emit)\n return () => h('s-app-window', { ...attrs, ref: elRef })\n },\n}) as unknown as OverlayComponent<AppWindowProps, SAppWindowElement, Record<never, never>>\n","/// <reference types=\"@shopify/app-bridge-types\" />\nimport { defineComponent, h } from 'vue'\nimport type { NavMenuProps, PassThroughComponent } from './types'\n\n/**\n * Renders the App Bridge `ui-nav-menu` element. `@shopify/app-bridge-react` 4.3.0\n * exports `NavMenu` as the bare tag name; this component adds typing.\n *\n * Shopify now documents `<s-app-nav>` for app navigation.\n *\n * @see https://shopify.dev/docs/api/app-bridge-library/react-components/navmenu\n */\nexport const NavMenu = /*@__PURE__*/ defineComponent({\n name: 'ui-nav-menu',\n inheritAttrs: false,\n setup(_, { attrs, slots }) {\n return () => h('ui-nav-menu', attrs, slots.default?.())\n },\n}) as unknown as PassThroughComponent<NavMenuProps, UINavMenuElement>\n"],"mappings":"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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type VNode } from 'vue';
|
|
2
|
+
export interface ModalChildren {
|
|
3
|
+
titleBar: VNode | undefined;
|
|
4
|
+
saveBar: VNode | undefined;
|
|
5
|
+
content: VNode[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Splits a `Modal` default slot the way `Modal` in `@shopify/app-bridge-react` 4.3.0
|
|
9
|
+
* does: the last title bar and the last save bar stay as direct children of
|
|
10
|
+
* `ui-modal`, everything else is modal content. `isTitleBar`/`isSaveBar` identify the
|
|
11
|
+
* `TitleBar`/`SaveBar` components; raw `<ui-title-bar>`/`<ui-save-bar>` tags are
|
|
12
|
+
* matched by tag name.
|
|
13
|
+
*/
|
|
14
|
+
export declare function splitModalChildren(nodes: VNode[], isTitleBar: (type: unknown) => boolean, isSaveBar: (type: unknown) => boolean): ModalChildren;
|
|
15
|
+
//# sourceMappingURL=splitModalChildren.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"splitModalChildren.d.ts","sourceRoot":"","sources":["../../src/lib/app-bridge/splitModalChildren.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,KAAK,KAAK,EAAE,MAAM,KAAK,CAAA;AAEnD,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,KAAK,GAAG,SAAS,CAAA;IAC3B,OAAO,EAAE,KAAK,GAAG,SAAS,CAAA;IAC1B,OAAO,EAAE,KAAK,EAAE,CAAA;CACjB;AAeD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,KAAK,EAAE,EACd,UAAU,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,EACtC,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,GACpC,aAAa,CAUf"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { VNode } from 'vue';
|
|
2
|
+
import type { SAppWindowAttributes, UIModalAttributes, UINavMenuAttributes, UISaveBarAttributes, UITitleBarAttributes } from '@shopify/app-bridge-types';
|
|
3
|
+
import type { EventListenerProps } from '../runtime/createWrapper';
|
|
4
|
+
/**
|
|
5
|
+
* Events that `ui-modal`, `ui-save-bar` and `s-app-window` dispatch
|
|
6
|
+
* (`addEventListener(type: "show" | "hide", ...)` in `@shopify/app-bridge-types`).
|
|
7
|
+
*/
|
|
8
|
+
export interface OverlayEvents {
|
|
9
|
+
show: Event;
|
|
10
|
+
hide: Event;
|
|
11
|
+
}
|
|
12
|
+
export interface OverlayOpenProps {
|
|
13
|
+
/**
|
|
14
|
+
* Whether the element is shown. Mirrors `open` in `@shopify/app-bridge-react`.
|
|
15
|
+
* Use `v-model:open` to keep it in sync when App Bridge closes the element.
|
|
16
|
+
* @defaultValue false
|
|
17
|
+
*/
|
|
18
|
+
open?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Props of the `Modal` component (`ui-modal`). Note: the main `polaris-vue-elements`
|
|
22
|
+
* entry also exports a `ModalProps`, for `SModal` (`s-modal`).
|
|
23
|
+
*/
|
|
24
|
+
export type ModalProps = Omit<UIModalAttributes, 'children'> & OverlayOpenProps;
|
|
25
|
+
/** Props of the `SaveBar` component (`ui-save-bar`). */
|
|
26
|
+
export type SaveBarProps = Omit<UISaveBarAttributes, 'children'> & OverlayOpenProps;
|
|
27
|
+
/** Props of the `AppWindow` component (`s-app-window`). `src` is required. */
|
|
28
|
+
export type AppWindowProps = SAppWindowAttributes & OverlayOpenProps;
|
|
29
|
+
/** Props of the `TitleBar` component (`ui-title-bar`). */
|
|
30
|
+
export type TitleBarProps = Omit<UITitleBarAttributes, 'children'>;
|
|
31
|
+
/** Props of the `NavMenu` component (`ui-nav-menu`). */
|
|
32
|
+
export type NavMenuProps = Omit<UINavMenuAttributes, 'children'>;
|
|
33
|
+
/** Default slot of a component that renders children. */
|
|
34
|
+
export interface DefaultSlot {
|
|
35
|
+
default?: () => VNode[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Constructor-shaped component type, in the style of `WrapperComponent` in
|
|
39
|
+
* `runtime/createWrapper.ts`, for `Modal`, `SaveBar` and `AppWindow`. `El` is not
|
|
40
|
+
* constrained to `HTMLElement`: App Bridge's element interfaces omit some
|
|
41
|
+
* `HTMLElement` members (for example `UITitleBarElement` omits `title`).
|
|
42
|
+
*/
|
|
43
|
+
export type OverlayComponent<P, El, S = DefaultSlot> = {
|
|
44
|
+
new (): {
|
|
45
|
+
$props: P & EventListenerProps<OverlayEvents> & {
|
|
46
|
+
'onUpdate:open'?: (open: boolean) => void;
|
|
47
|
+
};
|
|
48
|
+
$slots: S;
|
|
49
|
+
$el: El;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
/** Constructor-shaped component type for `TitleBar` and `NavMenu`. */
|
|
53
|
+
export type PassThroughComponent<P, El> = {
|
|
54
|
+
new (): {
|
|
55
|
+
$props: P;
|
|
56
|
+
$slots: DefaultSlot;
|
|
57
|
+
$el: El;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* The type of a raw App Bridge tag in a Vue template, used by the opt-in
|
|
62
|
+
* `polaris-vue-elements/app-bridge/elements` augmentation of `GlobalComponents`.
|
|
63
|
+
*/
|
|
64
|
+
export type AppBridgeElementTag<P, E = Record<string, never>, El = HTMLElement> = {
|
|
65
|
+
new (): {
|
|
66
|
+
$props: P & EventListenerProps<E>;
|
|
67
|
+
$el: El;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/lib/app-bridge/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,KAAK,CAAA;AAChC,OAAO,KAAK,EACV,oBAAoB,EACpB,iBAAiB,EACjB,mBAAmB,EACnB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAElE;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,KAAK,CAAA;IACX,IAAI,EAAE,KAAK,CAAA;CACZ;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,GAAG,gBAAgB,CAAA;AAC/E,wDAAwD;AACxD,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,GAAG,gBAAgB,CAAA;AACnF,8EAA8E;AAC9E,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG,gBAAgB,CAAA;AACpE,0DAA0D;AAC1D,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC,CAAA;AAClE,wDAAwD;AACxD,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAA;AAEhE,yDAAyD;AACzD,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,KAAK,EAAE,CAAA;CACxB;AAED;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,WAAW,IAAI;IACrD,QAAQ;QACN,MAAM,EAAE,CAAC,GACP,kBAAkB,CAAC,aAAa,CAAC,GAAG;YAClC,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAA;SAC1C,CAAA;QACH,MAAM,EAAE,CAAC,CAAA;QACT,GAAG,EAAE,EAAE,CAAA;KACR,CAAA;CACF,CAAA;AAED,sEAAsE;AACtE,MAAM,MAAM,oBAAoB,CAAC,CAAC,EAAE,EAAE,IAAI;IACxC,QAAQ;QACN,MAAM,EAAE,CAAC,CAAA;QACT,MAAM,EAAE,WAAW,CAAA;QACnB,GAAG,EAAE,EAAE,CAAA;KACR,CAAA;CACF,CAAA;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,GAAG,WAAW,IAAI;IAChF,QAAQ;QACN,MAAM,EAAE,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAA;QACjC,GAAG,EAAE,EAAE,CAAA;KACR,CAAA;CACF,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ShopifyGlobal } from '@shopify/app-bridge-types';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the `shopify` global, to use App Bridge APIs such as `toast` and
|
|
4
|
+
* `resourcePicker`. Mirrors `useAppBridge` in `@shopify/app-bridge-react` 4.3.0.
|
|
5
|
+
*
|
|
6
|
+
* - On the server (no `window`), it returns a proxy that throws when you read any
|
|
7
|
+
* property, so call the APIs from `onMounted()` or an event handler.
|
|
8
|
+
* - In the browser, it throws when the App Bridge script has not defined `shopify`.
|
|
9
|
+
*
|
|
10
|
+
* @see https://shopify.dev/docs/api/app-bridge-library/react-hooks/useappbridge
|
|
11
|
+
*/
|
|
12
|
+
export declare function useAppBridge(): ShopifyGlobal;
|
|
13
|
+
//# sourceMappingURL=useAppBridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAppBridge.d.ts","sourceRoot":"","sources":["../../src/lib/app-bridge/useAppBridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAI9D;;;;;;;;;GASG;AACH,wBAAgB,YAAY,IAAI,aAAa,CAkB5C"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type ShallowRef } from 'vue';
|
|
2
|
+
/** The App Bridge elements whose open state the wrappers sync. */
|
|
3
|
+
export type OverlayElement = UIModalElement | UISaveBarElement | SAppWindowElement;
|
|
4
|
+
export type OverlayEmit = (event: 'show' | 'hide' | 'update:open', ...args: unknown[]) => void;
|
|
5
|
+
export interface OverlaySyncHooks {
|
|
6
|
+
/** Runs once the tag is defined, before the first `show()`/`hide()`. */
|
|
7
|
+
beforeFirstSync?: () => void | Promise<void>;
|
|
8
|
+
/** Runs on every native `show` event, before `show` is emitted. */
|
|
9
|
+
onShow?: () => void;
|
|
10
|
+
}
|
|
11
|
+
export interface OverlaySync {
|
|
12
|
+
/** True once the tag is defined and the first sync has run. */
|
|
13
|
+
isReady: () => boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Syncs the `open` prop of an App Bridge overlay element with its `show()`/`hide()`
|
|
17
|
+
* methods, and its native `show`/`hide` events with Vue emits.
|
|
18
|
+
*
|
|
19
|
+
* Mirrors the effects of `Modal`, `SaveBar` and `AppWindow` in
|
|
20
|
+
* `@shopify/app-bridge-react` 4.3.0: `open ? show() : hide()` whenever the element or
|
|
21
|
+
* `open` changes (so `hide()` also runs on mount when `open` is false), `onShow`/`onHide`
|
|
22
|
+
* listeners, and `hide()` on unmount. Differences:
|
|
23
|
+
*
|
|
24
|
+
* - The first sync waits for `customElements.whenDefined(tag)`, so a late App Bridge
|
|
25
|
+
* script still gets the initial state.
|
|
26
|
+
* - `update:open` is emitted only when the element's state differs from `open`.
|
|
27
|
+
* - `hide()` on unmount runs in `onBeforeUnmount`, while the element is still in the
|
|
28
|
+
* document; React's cleanup runs after the element is removed.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useOverlaySync(tag: string, elRef: Readonly<ShallowRef<OverlayElement | null>>, props: {
|
|
31
|
+
readonly open: boolean;
|
|
32
|
+
}, emit: OverlayEmit, hooks?: OverlaySyncHooks): OverlaySync;
|
|
33
|
+
//# sourceMappingURL=useOverlaySync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOverlaySync.d.ts","sourceRoot":"","sources":["../../src/lib/app-bridge/useOverlaySync.ts"],"names":[],"mappings":"AACA,OAAO,EAAqC,KAAK,UAAU,EAAE,MAAM,KAAK,CAAA;AAExE,kEAAkE;AAClE,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,gBAAgB,GAAG,iBAAiB,CAAA;AAElF,MAAM,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,aAAa,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAA;AAE9F,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,eAAe,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5C,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,+DAA+D;IAC/D,OAAO,EAAE,MAAM,OAAO,CAAA;CACvB;AAQD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,QAAQ,CAAC,UAAU,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC,EAClD,KAAK,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;CAAE,EACjC,IAAI,EAAE,WAAW,EACjB,KAAK,GAAE,gBAAqB,GAC3B,WAAW,CAmEb"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polaris-vue-elements",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Typed Vue 3 components for Shopify Polaris web components — build Shopify app UIs (App Home) in Vue with props, events and v-model.",
|
|
3
|
+
"version": "0.6.1",
|
|
4
|
+
"description": "Typed Vue 3 components for Shopify Polaris web components and App Bridge — build Shopify embedded app UIs (App Home) in Vue with props, events and v-model.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://polaris-vue-elements.dev",
|
|
7
7
|
"repository": {
|
|
@@ -19,7 +19,10 @@
|
|
|
19
19
|
"vue",
|
|
20
20
|
"vue3",
|
|
21
21
|
"typescript",
|
|
22
|
-
"wrapper"
|
|
22
|
+
"wrapper",
|
|
23
|
+
"app-bridge",
|
|
24
|
+
"shopify-app-bridge",
|
|
25
|
+
"embedded-app"
|
|
23
26
|
],
|
|
24
27
|
"type": "module",
|
|
25
28
|
"main": "./dist/index.js",
|
|
@@ -33,6 +36,13 @@
|
|
|
33
36
|
"./elements": {
|
|
34
37
|
"types": "./dist/generated/elements.d.ts"
|
|
35
38
|
},
|
|
39
|
+
"./app-bridge": {
|
|
40
|
+
"types": "./dist/app-bridge/index.d.ts",
|
|
41
|
+
"import": "./dist/app-bridge/index.js"
|
|
42
|
+
},
|
|
43
|
+
"./app-bridge/elements": {
|
|
44
|
+
"types": "./dist/app-bridge/elements.d.ts"
|
|
45
|
+
},
|
|
36
46
|
"./tokens.css": "./tokens/tokens.css",
|
|
37
47
|
"./tokens.json": "./tokens/tokens.json"
|
|
38
48
|
},
|
|
@@ -51,7 +61,7 @@
|
|
|
51
61
|
"scripts": {
|
|
52
62
|
"prepare": "simple-git-hooks",
|
|
53
63
|
"prepublishOnly": "npm run type-check && vitest run && npm run build:lib",
|
|
54
|
-
"check": "oxlint . && eslint . && npm run type-check",
|
|
64
|
+
"check": "oxlint . && eslint . && oxfmt --check src/ && npm run type-check",
|
|
55
65
|
"dev": "vite",
|
|
56
66
|
"build": "run-p type-check \"build-only {@}\" --",
|
|
57
67
|
"preview": "vite preview",
|
|
@@ -65,14 +75,21 @@
|
|
|
65
75
|
"format": "oxfmt src/",
|
|
66
76
|
"generate": "node scripts/generate.mjs",
|
|
67
77
|
"docs:dev": "vitepress dev docs",
|
|
68
|
-
"docs:build": "vitepress build docs",
|
|
78
|
+
"docs:build": "node --max-old-space-size=6144 node_modules/vitepress/bin/vitepress.js build docs",
|
|
69
79
|
"docs:preview": "vitepress preview docs",
|
|
70
80
|
"docs:generate": "node scripts/generate-docs.mjs"
|
|
71
81
|
},
|
|
72
82
|
"peerDependencies": {
|
|
83
|
+
"@shopify/app-bridge-types": ">=0.7.4",
|
|
73
84
|
"vue": "^3.5.0"
|
|
74
85
|
},
|
|
86
|
+
"peerDependenciesMeta": {
|
|
87
|
+
"@shopify/app-bridge-types": {
|
|
88
|
+
"optional": true
|
|
89
|
+
}
|
|
90
|
+
},
|
|
75
91
|
"devDependencies": {
|
|
92
|
+
"@shopify/app-bridge-types": "^0.7.4",
|
|
76
93
|
"@shopify/polaris-types": "^2.0.0",
|
|
77
94
|
"@tsconfig/node24": "^24.0.4",
|
|
78
95
|
"@types/jsdom": "^30.0.0",
|
|
@@ -84,13 +101,13 @@
|
|
|
84
101
|
"@vue/tsconfig": "^0.9.1",
|
|
85
102
|
"eslint": "^10.7.0",
|
|
86
103
|
"eslint-config-prettier": "^10.1.8",
|
|
87
|
-
"eslint-plugin-oxlint": "~1.
|
|
104
|
+
"eslint-plugin-oxlint": "~1.93.0",
|
|
88
105
|
"eslint-plugin-vue": "~10.12.0",
|
|
89
106
|
"jiti": "^2.7.0",
|
|
90
|
-
"jsdom": "^
|
|
107
|
+
"jsdom": "^31.0.0",
|
|
91
108
|
"npm-run-all2": "^9.0.2",
|
|
92
|
-
"oxfmt": "^0.
|
|
93
|
-
"oxlint": "~1.
|
|
109
|
+
"oxfmt": "^0.78.0",
|
|
110
|
+
"oxlint": "~1.93.0",
|
|
94
111
|
"postcss": "^8.5.32",
|
|
95
112
|
"simple-git-hooks": "^2.13.1",
|
|
96
113
|
"typescript": "~6.0.0",
|