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 +65 -1
- package/README.md +65 -20
- 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 +33 -8
- package/tokens/tokens.css +1239 -0
- package/tokens/tokens.json +1455 -0
|
@@ -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;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GG;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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polaris-vue-elements",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
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.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://polaris-vue-elements.dev",
|
|
@@ -32,20 +32,33 @@
|
|
|
32
32
|
},
|
|
33
33
|
"./elements": {
|
|
34
34
|
"types": "./dist/generated/elements.d.ts"
|
|
35
|
-
}
|
|
35
|
+
},
|
|
36
|
+
"./app-bridge": {
|
|
37
|
+
"types": "./dist/app-bridge/index.d.ts",
|
|
38
|
+
"import": "./dist/app-bridge/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./app-bridge/elements": {
|
|
41
|
+
"types": "./dist/app-bridge/elements.d.ts"
|
|
42
|
+
},
|
|
43
|
+
"./tokens.css": "./tokens/tokens.css",
|
|
44
|
+
"./tokens.json": "./tokens/tokens.json"
|
|
36
45
|
},
|
|
37
46
|
"files": [
|
|
38
47
|
"dist",
|
|
48
|
+
"tokens/tokens.css",
|
|
49
|
+
"tokens/tokens.json",
|
|
39
50
|
"CHANGELOG.md"
|
|
40
51
|
],
|
|
41
|
-
"sideEffects":
|
|
52
|
+
"sideEffects": [
|
|
53
|
+
"*.css"
|
|
54
|
+
],
|
|
42
55
|
"simple-git-hooks": {
|
|
43
56
|
"pre-push": "npm run check"
|
|
44
57
|
},
|
|
45
58
|
"scripts": {
|
|
46
59
|
"prepare": "simple-git-hooks",
|
|
47
60
|
"prepublishOnly": "npm run type-check && vitest run && npm run build:lib",
|
|
48
|
-
"check": "oxlint . && eslint . && npm run type-check",
|
|
61
|
+
"check": "oxlint . && eslint . && oxfmt --check src/ && npm run type-check",
|
|
49
62
|
"dev": "vite",
|
|
50
63
|
"build": "run-p type-check \"build-only {@}\" --",
|
|
51
64
|
"preview": "vite preview",
|
|
@@ -64,9 +77,16 @@
|
|
|
64
77
|
"docs:generate": "node scripts/generate-docs.mjs"
|
|
65
78
|
},
|
|
66
79
|
"peerDependencies": {
|
|
80
|
+
"@shopify/app-bridge-types": ">=0.7.4",
|
|
67
81
|
"vue": "^3.5.0"
|
|
68
82
|
},
|
|
83
|
+
"peerDependenciesMeta": {
|
|
84
|
+
"@shopify/app-bridge-types": {
|
|
85
|
+
"optional": true
|
|
86
|
+
}
|
|
87
|
+
},
|
|
69
88
|
"devDependencies": {
|
|
89
|
+
"@shopify/app-bridge-types": "^0.7.4",
|
|
70
90
|
"@shopify/polaris-types": "^2.0.0",
|
|
71
91
|
"@tsconfig/node24": "^24.0.4",
|
|
72
92
|
"@types/jsdom": "^30.0.0",
|
|
@@ -78,13 +98,14 @@
|
|
|
78
98
|
"@vue/tsconfig": "^0.9.1",
|
|
79
99
|
"eslint": "^10.7.0",
|
|
80
100
|
"eslint-config-prettier": "^10.1.8",
|
|
81
|
-
"eslint-plugin-oxlint": "~1.
|
|
101
|
+
"eslint-plugin-oxlint": "~1.93.0",
|
|
82
102
|
"eslint-plugin-vue": "~10.12.0",
|
|
83
103
|
"jiti": "^2.7.0",
|
|
84
|
-
"jsdom": "^
|
|
104
|
+
"jsdom": "^31.0.0",
|
|
85
105
|
"npm-run-all2": "^9.0.2",
|
|
86
|
-
"oxfmt": "^0.
|
|
87
|
-
"oxlint": "~1.
|
|
106
|
+
"oxfmt": "^0.78.0",
|
|
107
|
+
"oxlint": "~1.93.0",
|
|
108
|
+
"postcss": "^8.5.32",
|
|
88
109
|
"simple-git-hooks": "^2.13.1",
|
|
89
110
|
"typescript": "~6.0.0",
|
|
90
111
|
"vite": "^8.1.5",
|
|
@@ -108,6 +129,10 @@
|
|
|
108
129
|
"overrides": {
|
|
109
130
|
"vitepress": {
|
|
110
131
|
"vite": "^6.4.5"
|
|
132
|
+
},
|
|
133
|
+
"minimatch@>=7.0.0 <11.0.1": "^11.0.1",
|
|
134
|
+
"js-beautify": {
|
|
135
|
+
"glob": "^14.0.2"
|
|
111
136
|
}
|
|
112
137
|
}
|
|
113
138
|
}
|