inviton-powerduck 0.0.102 → 0.0.104

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.
@@ -63,6 +63,12 @@ class DropzoneGalleryComponent extends TsxComponent<DropzoneGalleryArgs> impleme
63
63
  this.bindScript();
64
64
  }
65
65
 
66
+ beforeUnmount() {
67
+ try {
68
+ (this.$refs.galleryDropzone as any).dropzone.destroy();
69
+ } catch (error) { }
70
+ }
71
+
66
72
  updateSortOrder(itemArr?: DropzoneGalleryItem[]) {
67
73
  let applySort = false;
68
74
  if (itemArr == null) {
@@ -0,0 +1,4 @@
1
+ .swiper {
2
+ width: 100%;
3
+ overflow: hidden;
4
+ }
@@ -4,9 +4,9 @@ interface SwiperSlideArgs { }
4
4
 
5
5
  @Component
6
6
  class SwiperSlideComponent extends TsxComponent<SwiperSlideArgs> implements SwiperSlideArgs {
7
- render(h) {
8
- return (<div class="swiper-slide">{this.$slots.default}</div>)
9
- }
7
+ render(h) {
8
+ return (<div class="swiper-slide">{this.$slots?.default()}</div>)
9
+ }
10
10
  }
11
11
 
12
12
  const SwiperSlide = toNative(SwiperSlideComponent)
@@ -1,134 +1,202 @@
1
1
  import { toNative, Prop } from "vue-facing-decorator";
2
2
  import TsxComponent, { Component } from "../../app/vuetsx";
3
3
  import SwiperCore from 'swiper';
4
+ import type { Vue } from 'vue-facing-decorator';
5
+ import { Navigation, Pagination } from 'swiper/modules';
4
6
  import 'swiper/css'
5
7
  import 'swiper/css/navigation'
6
8
  import 'swiper/css/pagination'
9
+ import './css/swiper.css';
7
10
 
11
+ type VueType = typeof Vue.prototype;
12
+ interface IVue extends VueType { }
13
+ SwiperCore.use([Navigation, Pagination]);
8
14
 
9
15
  interface SwiperArgs {
10
- hasPagination?: boolean
11
- direction?: 'horizontal' | 'vertical'
12
- spaceBetween?: number
13
- slideChanged?: (e?: SwiperSlideChangedArgs) => void,
14
- zoomChanged?: (scale: number) => void
15
- zoom?: boolean | SwiperZoomArgs
16
+ hasPagination?: boolean
17
+ direction?: 'horizontal' | 'vertical'
18
+ slidesPerView?: 'auto' | number
19
+ slidesPerGroup?: number
20
+ spaceBetween?: number
21
+ freeMode?: boolean
22
+ grabCursor?: boolean
23
+ speed?: number
24
+ autoplay?: boolean
25
+ preventClicks?: boolean
26
+ navigation?: { nextEl: () => HTMLElement | string | IVue, prevEl: () => HTMLElement | string | IVue }
27
+ slideChanged?: (e?: SwiperSlideChangedArgs) => void,
28
+ zoomChanged?: (scale: number) => void
29
+ zoom?: boolean | SwiperZoomArgs
16
30
 
17
31
  }
18
32
 
19
33
  export interface SwiperSlideChangedArgs {
20
- activeIndex: number
21
- previousIndex: number
22
- swiper: any
34
+ activeIndex: number
35
+ previousIndex: number
36
+ swiper: any
23
37
  }
24
38
 
25
39
  export interface SwiperZoomArgs {
26
- enabled: boolean
27
- maxRatio?: number
28
- minRatio?: number
40
+ enabled: boolean
41
+ maxRatio?: number
42
+ minRatio?: number
29
43
  }
30
44
 
31
45
 
32
46
  @Component
33
47
  class SwiperComponent extends TsxComponent<SwiperArgs> implements SwiperArgs {
34
- @Prop() key: string;
35
- @Prop() hasPagination?: boolean
36
- @Prop() direction?: 'horizontal' | 'vertical'
37
- @Prop() spaceBetween?: number
38
- @Prop() zoom?: boolean | SwiperZoomArgs
39
- @Prop() slideChanged?: (e?: SwiperSlideChangedArgs) => void
40
- @Prop() zoomChanged?: (scale: number) => void
41
- zoomed: boolean = false;
42
-
43
- mounted() {
44
- const rootElem = this.$el;
45
- if (rootElem != null) {
46
- let existingInstance = (rootElem as any).swiper;
47
- if (existingInstance == null) {
48
- let args: any = {
49
- zoom: this.getZoomArgs(),
50
- direction: this.direction || 'horizontal',
51
- spaceBetween: this.spaceBetween > 0 ? this.spaceBetween : 0,
52
- pagination: this.shouldRenderPagination() ? {
53
- el: this.$refs.swiperPagination,
54
- type: 'bullets',
55
- } : {
56
- el: null
57
- }
58
- };
59
-
60
- if (this.slideChanged != null) {
61
- args.on = {
62
- slideChange: (swiper: any) => {
63
- this.slideChanged({
64
- activeIndex: swiper.activeIndex,
65
- previousIndex: swiper.previousIndex,
66
- swiper: swiper
67
- });
68
- }
69
- }
70
- }
71
-
72
- if (this.zoomChanged != null) {
73
- args.on = {
74
- ...args.on,
75
- zoomChange: (swiperEvent: any, scale: number) => {
76
- this.zoomed = scale > 1 ? true : false;
77
- this.zoomChanged(scale)
78
- }
79
- }
80
- }
81
-
82
- new SwiperCore(rootElem as any, args);
83
- }
84
- }
85
- }
86
-
87
- getSwiperInstance() {
88
- const rootElem = this.$el;
89
- if (rootElem != null) {
90
- return (rootElem as any).swiper;
91
- }
92
-
93
- return null;
94
- }
95
-
96
- getZoomArgs(): SwiperZoomArgs {
97
- if (this.zoom == true) {
98
- return {
99
- enabled: true
100
- }
101
- }
102
-
103
- return this.zoom as SwiperZoomArgs;
104
- }
105
-
106
- shouldRenderPagination(): boolean {
107
- return this.hasPagination != false;
108
- }
109
-
110
-
111
-
112
- render(h) {
113
- const zoomEnabled = (this.zoom == true || (this.zoom as SwiperZoomArgs)?.enabled == true);
114
-
115
- return (
116
-
117
- <div class="swiper">
118
-
119
- {this.shouldRenderPagination() &&
120
- <div ref="swiperPagination" class={`swiper-pagination swiper-pagination-bullets swiper-pagination-horizontal ${this.zoomed ?
121
- "hide-swiper-pagination-bulets" :
122
- ""}`
123
- }></div>
124
- }
125
-
126
- <div class="swiper-wrapper">
127
- {this.$slots.default}
128
- </div>
129
- </div>
130
- )
131
- }
48
+ @Prop() key: string;
49
+ @Prop() hasPagination?: boolean
50
+ @Prop() direction?: 'horizontal' | 'vertical'
51
+ @Prop() slidesPerView?: 'auto' | number
52
+ @Prop() slidesPerGroup?: number
53
+ @Prop() spaceBetween?: number
54
+ @Prop() freeMode?: boolean
55
+ @Prop() grabCursor?: boolean
56
+ @Prop() speed: number
57
+ @Prop() autoplay: boolean
58
+ @Prop() preventClicks: boolean
59
+ @Prop() navigation?: { nextEl: () => HTMLElement | string | IVue, prevEl: () => HTMLElement | string | IVue }
60
+ @Prop() zoom?: boolean | SwiperZoomArgs
61
+ @Prop() slideChanged?: (e?: SwiperSlideChangedArgs) => void
62
+ @Prop() zoomChanged?: (scale: number) => void
63
+ zoomed: boolean = false;
64
+
65
+ mounted() {
66
+ const rootElem = this.$el;
67
+ if (rootElem != null) {
68
+ let existingInstance = (rootElem as any).swiper;
69
+ if (existingInstance == null) {
70
+ let args: any = {
71
+ zoom: this.getZoomArgs(),
72
+ direction: this.direction || 'horizontal',
73
+ spaceBetween: this.spaceBetween > 0 ? this.spaceBetween : 0,
74
+ pagination: this.shouldRenderPagination() ? {
75
+ el: this.$refs.swiperPagination,
76
+ type: 'bullets',
77
+ } : {
78
+ el: null
79
+ }
80
+ };
81
+
82
+ if (this.slidesPerView != null) {
83
+ args.slidesPerView = this.slidesPerView;
84
+ }
85
+
86
+ if (this.slidesPerGroup != null) {
87
+ args.slidesPerGroup = this.slidesPerGroup;
88
+ }
89
+
90
+ if (this.freeMode != null) {
91
+ args.freeMode = this.freeMode;
92
+ }
93
+
94
+ if (this.grabCursor != null) {
95
+ args.grabCursor = this.grabCursor;
96
+ }
97
+
98
+ if (this.speed != null) {
99
+ args.speed = this.speed;
100
+ }
101
+
102
+ if (this.autoplay != null) {
103
+ args.autoplay = this.autoplay;
104
+ }
105
+
106
+ if (this.preventClicks != null) {
107
+ args.preventClicks = this.preventClicks;
108
+ }
109
+
110
+ if (this.navigation != null) {
111
+ const getForProp = (prop) => {
112
+ if (prop == null) {
113
+ return null;
114
+ }
115
+
116
+ const propVal = prop();
117
+ if (propVal == null) {
118
+ return null;
119
+ }
120
+
121
+ return propVal.$el ?? propVal;
122
+ }
123
+
124
+ args.navigation = {
125
+ prevEl: getForProp(this.navigation.prevEl),
126
+ nextEl: getForProp(this.navigation.nextEl),
127
+ }
128
+ }
129
+
130
+ if (this.slideChanged != null) {
131
+ args.on = {
132
+ slideChange: (swiper: any) => {
133
+ this.slideChanged({
134
+ activeIndex: swiper.activeIndex,
135
+ previousIndex: swiper.previousIndex,
136
+ swiper: swiper
137
+ });
138
+ }
139
+ }
140
+ }
141
+
142
+ if (this.zoomChanged != null) {
143
+ args.on = {
144
+ ...args.on,
145
+ zoomChange: (swiperEvent: any, scale: number) => {
146
+ this.zoomed = scale > 1 ? true : false;
147
+ this.zoomChanged(scale)
148
+ }
149
+ }
150
+ }
151
+
152
+ new SwiperCore(rootElem as any, args);
153
+ }
154
+ }
155
+ }
156
+
157
+ getSwiperInstance() {
158
+ const rootElem = this.$el;
159
+ if (rootElem != null) {
160
+ return (rootElem as any).swiper;
161
+ }
162
+
163
+ return null;
164
+ }
165
+
166
+ getZoomArgs(): SwiperZoomArgs {
167
+ if (this.zoom == true) {
168
+ return {
169
+ enabled: true
170
+ }
171
+ }
172
+
173
+ return this.zoom as SwiperZoomArgs;
174
+ }
175
+
176
+ shouldRenderPagination(): boolean {
177
+ return this.hasPagination != false;
178
+ }
179
+
180
+
181
+
182
+ render(h) {
183
+ const zoomEnabled = (this.zoom == true || (this.zoom as SwiperZoomArgs)?.enabled == true);
184
+
185
+ return (
186
+ <div class="swiper">
187
+ {this.shouldRenderPagination() &&
188
+ <div ref="swiperPagination" class={`swiper-pagination swiper-pagination-bullets swiper-pagination-horizontal ${this.zoomed ?
189
+ "hide-swiper-pagination-bulets" :
190
+ ""}`
191
+ }></div>
192
+ }
193
+
194
+ <div class="swiper-wrapper">
195
+ {this.$slots?.default()}
196
+ </div>
197
+ </div>
198
+ )
199
+ }
132
200
  }
133
201
 
134
202
  const Swiper = toNative(SwiperComponent)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inviton-powerduck",
3
- "version": "0.0.102",
3
+ "version": "0.0.104",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": " vite build && vue-tsc --declaration --emitDeclarationOnly",