polaris-vue-elements 0.4.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -11,6 +11,68 @@ major your app loads (`polaris-1.js`, `polaris-2.js`, …).
11
11
 
12
12
  ## [Unreleased]
13
13
 
14
+ ## [0.6.0] - 2026-11-13
15
+
16
+ Still generated from `@shopify/polaris-types` 2.0.0. No changes to the components.
17
+
18
+ The App Bridge wrappers follow Shopify's own React wrapper, but have not been tested in a
19
+ live Shopify admin yet; the docs mark the behavior that is still unverified. Please open an
20
+ issue if something doesn't work.
21
+
22
+ ### Added
23
+
24
+ - `polaris-vue-elements/app-bridge`: Vue 3 counterparts of Shopify's
25
+ `@shopify/app-bridge-react` 4.3.0. It has the components `Modal`, `SaveBar`, `AppWindow`,
26
+ `TitleBar` and `NavMenu`, and the composable `useAppBridge()`.
27
+ - `Modal`, `SaveBar` and `AppWindow` support `v-model:open` and emit `@show` and `@hide`.
28
+ - `Modal` renders its content inside the App Bridge modal, as the React version does.
29
+ - Types come from `@shopify/app-bridge-types`, a new optional peer dependency. Install it
30
+ only if you use App Bridge.
31
+ - The main `polaris-vue-elements` entry is unchanged and loads no App Bridge code.
32
+
33
+ See [App Bridge components](https://polaris-vue-elements.dev/app-bridge/).
34
+ - `polaris-vue-elements/app-bridge/elements`: types for the raw `<ui-modal>`,
35
+ `<ui-save-bar>`, `<ui-title-bar>`, `<ui-nav-menu>`, `<s-app-window>` and `<s-app-nav>`
36
+ tags in Vue templates.
37
+
38
+ ### Changed
39
+
40
+ - Docs: App Bridge and CSS variables are now sections of their own, next to Guide and
41
+ Components in the nav and the sidebar. The CSS variables page is split into an
42
+ [overview](https://polaris-vue-elements.dev/css-variables/), the
43
+ [full list](https://polaris-vue-elements.dev/css-variables/reference) and
44
+ [migrating from `@shopify/polaris-tokens`](https://polaris-vue-elements.dev/css-variables/migration).
45
+ Old `/guide/css-variables` links redirect.
46
+
47
+ ## [0.5.0] - 2026-11-09
48
+
49
+ Still generated from `@shopify/polaris-types` 2.0.0. No changes to the components.
50
+
51
+ ### Added
52
+
53
+ - `polaris-vue-elements/tokens.css` and `polaris-vue-elements/tokens.json`: the Polaris
54
+ CSS variables (`--p-color-*`, `--p-space-*`, `--p-border-radius-*`, …) for your app's
55
+ own layout CSS, extracted from the Polaris runtime with the build hash removed from
56
+ the names. Unofficial: values follow the CDN, and a daily job opens a pull request
57
+ when they change. Includes the `admin-next` theme, which applies under the class the
58
+ runtime puts on `<html>`.
59
+ See [CSS variables](https://polaris-vue-elements.dev/css-variables/).
60
+ - Docs: a "Best practices" section on 50 component pages, before the example. Each is
61
+ our own summary of Shopify's guidance for that component, with Vue snippets, and links
62
+ to the full section on shopify.dev. Components Shopify publishes no guidance for have
63
+ none.
64
+ - Docs: the whole site in Vietnamese, Korean, Simplified Chinese, Japanese, German, French,
65
+ Spanish, Hindi and Brazilian Portuguese (`/vi/`, `/ko/`, `/zh/`, `/ja/`, `/de/`, `/fr/`,
66
+ `/es/`, `/hi/`, `/pt/`), including every component page and Shopify's prop and slot
67
+ descriptions, with hreflang links between the languages.
68
+ - Docs: a redesigned homepage, a frosted-glass nav bar, a back-to-top button and thin,
69
+ rounded scrollbars.
70
+
71
+ ### Changed
72
+
73
+ - `sideEffects` in `package.json` is now `["*.css"]` instead of `false`, so bundlers keep
74
+ `import 'polaris-vue-elements/tokens.css'`. JavaScript still tree-shakes as before.
75
+
14
76
  ## [0.4.2] - 2026-10-30
15
77
 
16
78
  Still generated from `@shopify/polaris-types` 2.0.0. No changes to the components.
@@ -118,7 +180,9 @@ Initial release: typed Vue 3 wrappers for the 59 Shopify Polaris web components
118
180
  `showOverlay()` / `hideOverlay()` / `toggleOverlay()`).
119
181
  - ESM build with bundled type declarations; `vue` ^3.5 as a peer dependency.
120
182
 
121
- [Unreleased]: https://github.com/HQCuong/polaris-vue/compare/v0.4.2...HEAD
183
+ [Unreleased]: https://github.com/HQCuong/polaris-vue/compare/v0.6.0...HEAD
184
+ [0.6.0]: https://github.com/HQCuong/polaris-vue/compare/v0.5.0...v0.6.0
185
+ [0.5.0]: https://github.com/HQCuong/polaris-vue/compare/v0.4.2...v0.5.0
122
186
  [0.4.2]: https://github.com/HQCuong/polaris-vue/compare/v0.4.1...v0.4.2
123
187
  [0.4.1]: https://github.com/HQCuong/polaris-vue/compare/v0.4.0...v0.4.1
124
188
  [0.4.0]: https://github.com/HQCuong/polaris-vue/compare/v0.3.0...v0.4.0
package/README.md CHANGED
@@ -1,15 +1,41 @@
1
- # polaris-vue-elements
1
+ <div align="center">
2
2
 
3
- Typed Vue 3 wrapper components for [Shopify Polaris web components](https://shopify.dev/docs/api/app-home/web-components) — the `s-*` custom elements used to build Shopify App Home (embedded admin) apps.
3
+ <sub>**English** | [Tiếng Việt](./i18n/vi/README.md) | [한국어](./i18n/ko/README.md) | [简体中文](./i18n/zh/README.md) | [日本語](./i18n/ja/README.md) | [Deutsch](./i18n/de/README.md) | [Français](./i18n/fr/README.md) | [Español](./i18n/es/README.md) | [हिन्दी](./i18n/hi/README.md) | [Português (Brasil)](./i18n/pt/README.md)</sub>
4
4
 
5
- **📖 Documentation: [polaris-vue-elements.dev](https://polaris-vue-elements.dev/)** — guides, known quirks, and live examples for all 62 components.
5
+ <br>
6
6
 
7
- The Polaris runtime itself is loaded from Shopify's CDN (the `polaris-2.js` stable channel receives compatible updates automatically). This library gives you an idiomatic, fully typed Vue surface on top of it:
7
+ <a href="https://polaris-vue-elements.dev/">
8
+ <img src="https://polaris-vue-elements.dev/og.png" alt="polaris-vue-elements: typed Vue 3 wrappers for Shopify Polaris web components" width="720">
9
+ </a>
8
10
 
9
- - **Typed props & events for all 62 components**, generated from Shopify's official Custom Elements Manifest (`@shopify/polaris-types`) — union-typed props like `variant`, autocomplete in templates, typed `@click`/`@aftershow` listeners.
10
- - **`v-model` on 17 form components** (`STextField`, `SCheckbox`, `SSelect`, `SChoiceList`, …) with the correct property/event pair for each.
11
- - **Imperative overlay control** — `SModal` exposes a typed `$el` (`ModalElement`) so `modal.value?.$el.showOverlay()` type-checks, alongside Polaris's declarative `commandFor`/`command` pattern.
12
- - **Degrades gracefully, never blocks** — unknown props pass through via `$attrs`, user-provided slots are forwarded verbatim, and brand-new Polaris components can always be used as raw `s-*` tags. A stale wrapper means missing types for new features, never broken existing ones.
11
+ <br>
12
+ <br>
13
+
14
+ [![npm version](https://img.shields.io/npm/v/polaris-vue-elements?color=008060&label=npm)](https://www.npmjs.com/package/polaris-vue-elements)
15
+ [![npm downloads](https://img.shields.io/npm/dm/polaris-vue-elements?color=008060)](https://www.npmjs.com/package/polaris-vue-elements)
16
+ [![CI](https://github.com/HQCuong/polaris-vue/actions/workflows/ci.yml/badge.svg)](https://github.com/HQCuong/polaris-vue/actions/workflows/ci.yml)
17
+ [![License: MIT](https://img.shields.io/npm/l/polaris-vue-elements?color=008060)](./LICENSE)
18
+
19
+ **[Documentation](https://polaris-vue-elements.dev/)** ·
20
+ [Getting started](https://polaris-vue-elements.dev/guide/getting-started) ·
21
+ [Components](https://polaris-vue-elements.dev/components/) ·
22
+ [Embedded app guide](https://polaris-vue-elements.dev/guide/shopify-embedded-app) ·
23
+ [Changelog](./CHANGELOG.md)
24
+
25
+ </div>
26
+
27
+ ---
28
+
29
+ Typed Vue 3 wrapper components for [Shopify Polaris web components](https://shopify.dev/docs/api/app-home/web-components): the `s-*` custom elements used to build Shopify App Home (embedded admin) apps.
30
+
31
+ The Polaris runtime itself loads from Shopify's CDN (the `polaris-2.js` stable channel receives compatible updates automatically). This library gives you an idiomatic, fully typed Vue surface on top of it.
32
+
33
+ ## Features
34
+
35
+ - **Typed props and events for all 62 components**, generated from Shopify's official Custom Elements Manifest (`@shopify/polaris-types`): union-typed props like `variant`, autocomplete in templates, typed `@click` / `@aftershow` listeners.
36
+ - **`v-model` on 17 form components** (`STextField`, `SCheckbox`, `SSelect`, `SChoiceList`, …), each mapped to its correct property/event pair.
37
+ - **Imperative overlay control.** `SModal` exposes a typed `$el` (`ModalElement`), so `modal.value?.$el.showOverlay()` type-checks, alongside Polaris's declarative `commandFor` / `command` pattern.
38
+ - **Degrades gracefully, never blocks.** Unknown props pass through via `$attrs`, slots are forwarded verbatim, and brand-new Polaris components can always be used as raw `s-*` tags. A stale wrapper means missing types for new features, never broken existing ones.
13
39
 
14
40
  ## Installation
15
41
 
@@ -21,15 +47,13 @@ Vue `^3.5` is a peer dependency.
21
47
 
22
48
  ### Runtime setup (required)
23
49
 
24
- The wrappers are presentational only — your host app must load the Polaris runtime from Shopify's CDN, and tell Vue that `s-*` tags are custom elements:
50
+ The wrappers are presentational only. Your host app loads the Polaris runtime from Shopify's CDN and tells Vue that `s-*` tags are custom elements:
25
51
 
26
52
  ```html
27
53
  <!-- index.html -->
28
54
  <script src="https://cdn.shopify.com/shopifycloud/polaris-2.js"></script>
29
55
  ```
30
56
 
31
- `polaris-2.js` is Shopify's stable channel and brings the admin's new visual design. Apps still on `polaris-1.js` keep working — 2.0's component API is the same as 1.1 apart from a few additions. See [Polaris 2.0 and the new admin design](https://polaris-vue-elements.dev/guide/getting-started#polaris-2-0-and-the-new-admin-design).
32
-
33
57
  ```ts
34
58
  // vite.config.ts
35
59
  vue({
@@ -41,7 +65,9 @@ vue({
41
65
  })
42
66
  ```
43
67
 
44
- ### Quick start
68
+ > **Note:** `polaris-2.js` is Shopify's stable channel and brings the admin's new visual design. Apps still on `polaris-1.js` keep working: 2.0's component API is the same as 1.1 apart from a few additions. See [Polaris 2.0 and the new admin design](https://polaris-vue-elements.dev/guide/getting-started#polaris-2-0-and-the-new-admin-design).
69
+
70
+ ## Quick start
45
71
 
46
72
  ```vue
47
73
  <script setup lang="ts">
@@ -57,11 +83,22 @@ const name = ref('')
57
83
  </template>
58
84
  ```
59
85
 
60
- Prefer writing Polaris's own `<s-button>` tags? Add `"types": ["polaris-vue-elements/elements"]` to your `tsconfig.json` and Volar / `vue-tsc` type-check raw `<s-*>` tags too (types only; `v-model` stays wrapper-only). See [Typing raw `<s-*>` tags](https://polaris-vue-elements.dev/guide/getting-started#_7-typing-raw-s-tags-optional).
86
+ > **Tip:** prefer writing Polaris's own `<s-button>` tags? Add `"types": ["polaris-vue-elements/elements"]` to your `tsconfig.json`, and Volar / `vue-tsc` type-check raw `<s-*>` tags too (types only; `v-model` stays wrapper-only). See [Typing raw `<s-*>` tags](https://polaris-vue-elements.dev/guide/getting-started#_7-typing-raw-s-tags-optional).
87
+
88
+ ## Documentation
89
+
90
+ Everything lives at **[polaris-vue-elements.dev](https://polaris-vue-elements.dev/)**:
61
91
 
62
- Full documentation — guides, known quirks, and generated reference pages with live examples for all 62 components — is at **[polaris-vue-elements.dev](https://polaris-vue-elements.dev/)** (source in `docs/`, `npm run docs:dev` to run locally). Building a Shopify app? Start with the [embedded app guide](https://polaris-vue-elements.dev/guide/shopify-embedded-app).
92
+ - [Getting started](https://polaris-vue-elements.dev/guide/getting-started): setup, `v-model`, overlays and typed raw tags.
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`.
95
+ - [Known quirks](https://polaris-vue-elements.dev/guide/quirks): Polaris behaviors verified in a real browser.
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.
97
+ - [Component reference](https://polaris-vue-elements.dev/components/): props, events, slots, best practices and live examples for all 62 components.
63
98
 
64
- ## Architecture
99
+ The site's source is in [`docs/`](./docs); run it locally with `npm run docs:dev`.
100
+
101
+ ## How it works
65
102
 
66
103
  Everything derivable from Shopify's manifest is machine-generated; human judgment lives in one small file.
67
104
 
@@ -74,7 +111,10 @@ src/lib/runtime/ ← createWrapper: one generic factory for all 62 comp
74
111
  src/lib/overrides.ts ← hand-written: v-model mappings only
75
112
  ```
76
113
 
77
- When Shopify ships a new Polaris version:
114
+ Drift-guard tests make forgetting impossible: CI fails if generated code is stale, if a manifest component lacks a wrapper, or if a new form-like component is missing a v-model override. A scheduled workflow ([`sync-polaris.yml`](.github/workflows/sync-polaris.yml)) opens a sync PR automatically when a new `@shopify/polaris-types` is published.
115
+
116
+ <details>
117
+ <summary><strong>Updating to a new Polaris version by hand</strong></summary>
78
118
 
79
119
  ```sh
80
120
  npm update @shopify/polaris-types
@@ -83,7 +123,7 @@ npm run docs:generate # regenerate component reference docs
83
123
  git diff # review, then note API changes in CHANGELOG.md
84
124
  ```
85
125
 
86
- Drift-guard tests make forgetting impossible: CI fails if generated code is stale, if a manifest component lacks a wrapper, or if a new form-like component is missing a v-model override. A scheduled GitHub Actions workflow (`sync-polaris.yml`) opens a sync PR automatically when a new `@shopify/polaris-types` is published.
126
+ </details>
87
127
 
88
128
  ## Development
89
129
 
@@ -101,16 +141,21 @@ npm run build:lib # build the publishable package into dist/
101
141
 
102
142
  ## Contributing
103
143
 
104
- See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup, ground rules and the pre-PR checklist.
144
+ Bug reports, docs fixes and pull requests are welcome. See [CONTRIBUTING.md](./CONTRIBUTING.md) for setup, ground rules and the pre-PR checklist, and the [Code of Conduct](./CODE_OF_CONDUCT.md). To report a vulnerability, see [SECURITY.md](./SECURITY.md).
105
145
 
106
146
  ## Releasing
107
147
 
108
- Releases are cut from `main` by pushing a version tag; [`release.yml`](.github/workflows/release.yml) does the rest (checks, `npm publish` with provenance via npm Trusted Publishing, and a GitHub Release whose notes come from `CHANGELOG.md`).
148
+ Releases are cut from `main` by pushing a version tag. [`release.yml`](.github/workflows/release.yml) does the rest: checks, `npm publish` with provenance via npm Trusted Publishing, and a GitHub Release whose notes come from `CHANGELOG.md`.
149
+
150
+ <details>
151
+ <summary><strong>Release steps (maintainers)</strong></summary>
109
152
 
110
153
  1. In [`CHANGELOG.md`](./CHANGELOG.md), move the `## [Unreleased]` entries under a new `## [x.y.z] - YYYY-MM-DD` heading and update the compare links at the bottom. The polaris-types sync PRs record new/removed components there automatically; add prop, slot and icon changes by hand (removals are breaking).
111
154
  2. `npm version x.y.z --no-git-tag-version`, commit both files, and push to `main`.
112
155
  3. `git tag vx.y.z && git push origin vx.y.z`. Tags with a pre-release suffix (e.g. `v0.3.0-rc.0`) publish under the `next` dist-tag.
113
156
 
157
+ </details>
158
+
114
159
  ## License
115
160
 
116
- [MIT](./LICENSE)
161
+ [MIT](./LICENSE). Not affiliated with or endorsed by Shopify.
@@ -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"}