@nativescript-community/ui-material-bottomsheet 7.0.34 → 7.0.36

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/README.md CHANGED
@@ -122,7 +122,7 @@ export function openBottomSheet(args) {
122
122
 
123
123
  ##
124
124
 
125
- ### NativeScript + Vue
125
+ ### NativeScript + Vue 2
126
126
  ```typescript
127
127
  import Vue from 'nativescript-vue';
128
128
  import BottomSheetPlugin from '@nativescript-community/ui-material-bottomsheet/vue';
@@ -141,6 +141,32 @@ const options: VueBottomSheetOptions = {
141
141
  this.$showBottomSheet(MyComponent, options)
142
142
  ```
143
143
 
144
+ ### NativeScript + Vue 3
145
+ ```typescript
146
+ import { createApp } from 'nativescript-vue';
147
+ import { BottomSheetPlugin } from '@nativescript-community/ui-material-bottomsheet/vue3';
148
+ import { install } from "@nativescript-community/ui-material-bottomsheet";
149
+ install();
150
+
151
+ const app = createApp(...);
152
+ app.use(BottomSheetPlugin);
153
+ ```
154
+ Then you can show a Vue component:
155
+ ```typescript
156
+ import { useBottomSheet } from "@nativescript-community/ui-material-bottomsheet/vue3";
157
+ import MyComponent from 'MyComponent.vue';
158
+
159
+
160
+ const options: VueBottomSheetOptions = {
161
+ ...
162
+ };
163
+
164
+ const { showBottomSheet, closeBottomSheet } = useBottomSheet()
165
+
166
+ showBottomSheet(MyComponent, options);
167
+ closeBottomSheet();
168
+ ```
169
+
144
170
  ##
145
171
 
146
172
  ### NativeScript + Angular
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nativescript-community/ui-material-bottomsheet",
3
- "version": "7.0.34",
3
+ "version": "7.0.36",
4
4
  "description": "Material Design Bottom Sheets slide up from the bottom of the screen to reveal more content. Bottom sheets integrate with the app to display supporting content or present deep-linked content from other apps.",
5
5
  "main": "./bottomsheet",
6
6
  "sideEffects": false,
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "readmeFilename": "README.md",
48
48
  "dependencies": {
49
- "@nativescript-community/ui-material-core": "^7.0.34"
49
+ "@nativescript-community/ui-material-core": "^7.0.36"
50
50
  },
51
- "gitHead": "e0ccc861d2f6da556d045b069ebc6c8f32a6872a"
51
+ "gitHead": "aad043ae2a45c79505da543aeca02074b05373e6"
52
52
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "uses": [
3
- "com.google.android.material.bottomsheet:BottomSheetBehavior*",
4
- "com.google.android.material.bottomsheet.BottomSheetBehavior:BottomSheetCallback*"
3
+ "com.google.android.material.bottomsheet:BottomSheetBehavior",
4
+ "com.google.android.material.bottomsheet:BottomSheetBehavior.BottomSheetCallback"
5
5
  ]
6
6
  }
@@ -0,0 +1,20 @@
1
+ import { ViewBase } from '@nativescript/core';
2
+ import { BottomSheetOptions } from '../bottomsheet';
3
+ declare module '@vue/runtime-core' {
4
+ interface ComponentCustomProperties {
5
+ $showBottomSheet: (component: any, options: VueBottomSheetOptions) => Promise<any>;
6
+ $closeBottomSheet(...args: any[]): any;
7
+ }
8
+ }
9
+ declare const useBottomSheet: () => {
10
+ showBottomSheet: (component: any, options: VueBottomSheetOptions) => Promise<unknown>;
11
+ closeBottomSheet: (...args: any[]) => void;
12
+ };
13
+ declare const BottomSheetPlugin: {
14
+ install(app: any): void;
15
+ };
16
+ interface VueBottomSheetOptions extends Partial<BottomSheetOptions> {
17
+ view?: string | ViewBase;
18
+ props?: any;
19
+ }
20
+ export { BottomSheetPlugin, VueBottomSheetOptions, useBottomSheet };
package/vue3/index.js ADDED
@@ -0,0 +1,52 @@
1
+ import { App, createApp } from 'nativescript-vue3';
2
+ import { Frame, View, ViewBase } from '@nativescript/core';
3
+ const modalStack = [];
4
+ const useBottomSheet = () => {
5
+ const showBottomSheet = (component, options) => showSheet(component, options);
6
+ const closeBottomSheet = (...args) => closeSheet(args);
7
+ return {
8
+ showBottomSheet,
9
+ closeBottomSheet
10
+ };
11
+ };
12
+ const showSheet = (component, options) => new Promise((resolve) => {
13
+ let resolved = false;
14
+ let navEntryInstance = createNativeView(component, {
15
+ props: options.props
16
+ }).mount();
17
+ const viewAttached = options.view ?? Frame.topmost().currentPage;
18
+ viewAttached.showBottomSheet(Object.assign({}, options, {
19
+ view: navEntryInstance.$el.nativeView,
20
+ closeCallback: (...args) => {
21
+ if (resolved) {
22
+ return;
23
+ }
24
+ resolved = true;
25
+ if (navEntryInstance && navEntryInstance) {
26
+ options.closeCallback && options.closeCallback.apply(undefined, args);
27
+ resolve(...args);
28
+ navEntryInstance.$emit('bottomsheet:close');
29
+ navEntryInstance.$el = null;
30
+ navEntryInstance = null;
31
+ modalStack.splice(modalStack.length, 1);
32
+ }
33
+ }
34
+ }));
35
+ modalStack.push(navEntryInstance);
36
+ });
37
+ const closeSheet = (...args) => {
38
+ const modalPageInstanceInfo = modalStack[modalStack.length - 1];
39
+ if (modalPageInstanceInfo) {
40
+ modalPageInstanceInfo.$el.nativeView.closeBottomSheet(args);
41
+ }
42
+ };
43
+ const BottomSheetPlugin = {
44
+ install(app) {
45
+ const globals = app.config.globalProperties;
46
+ globals.$showBottomSheet = showSheet;
47
+ globals.$closeBottomSheet = closeSheet;
48
+ }
49
+ };
50
+ const createNativeView = (component, props) => createApp(component, props);
51
+ export { BottomSheetPlugin, useBottomSheet };
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"../src/","sources":["vue3/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAW3D,MAAM,UAAU,GAAG,EAAE,CAAC;AAEtB,MAAM,cAAc,GAAG,GAAG,EAAE;IACxB,MAAM,eAAe,GAAG,CAAC,SAAc,EAAE,OAA8B,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC1G,MAAM,gBAAgB,GAAG,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