@egjs/react-flicking 4.16.2-beta.0 → 4.16.3-beta.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/dist/flicking.cjs.js +121 -54
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +132 -65
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +122 -55
- package/dist/flicking.js.map +1 -1
- package/package.json +3 -3
package/dist/flicking.esm.js
CHANGED
|
@@ -1,3 +1,57 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
8
|
+
var __reflectGet = Reflect.get;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
+
var __objRest = (source, exclude) => {
|
|
23
|
+
var target = {};
|
|
24
|
+
for (var prop in source)
|
|
25
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
26
|
+
target[prop] = source[prop];
|
|
27
|
+
if (source != null && __getOwnPropSymbols)
|
|
28
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
29
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
30
|
+
target[prop] = source[prop];
|
|
31
|
+
}
|
|
32
|
+
return target;
|
|
33
|
+
};
|
|
34
|
+
var __superGet = (cls, obj, key) => __reflectGet(__getProtoOf(cls), key, obj);
|
|
35
|
+
var __async = (__this, __arguments, generator) => {
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
var fulfilled = (value) => {
|
|
38
|
+
try {
|
|
39
|
+
step(generator.next(value));
|
|
40
|
+
} catch (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
var rejected = (value) => {
|
|
45
|
+
try {
|
|
46
|
+
step(generator.throw(value));
|
|
47
|
+
} catch (e) {
|
|
48
|
+
reject(e);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
52
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
53
|
+
});
|
|
54
|
+
};
|
|
1
55
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
2
56
|
import VanillaFlicking__default, { ExternalRenderer, getFlickingAttached, VirtualRenderingStrategy, NormalRenderingStrategy, sync, range, EVENTS, getDefaultCameraTransform, getRenderingPanels, withFlickingMethods, CrossFlicking as CrossFlicking$1, SIDE_EVENTS, flickingReactiveAPIAdapter } from "@egjs/flicking";
|
|
3
57
|
export * from "@egjs/flicking";
|
|
@@ -51,19 +105,23 @@ const DEFAULT_PROPS = {
|
|
|
51
105
|
};
|
|
52
106
|
class ReactElementProvider {
|
|
53
107
|
get element() {
|
|
54
|
-
|
|
108
|
+
var _a;
|
|
109
|
+
return (_a = this._el) == null ? void 0 : _a.nativeElement;
|
|
55
110
|
}
|
|
56
111
|
get rendered() {
|
|
57
|
-
|
|
112
|
+
var _a;
|
|
113
|
+
return (_a = this._el) == null ? void 0 : _a.rendered;
|
|
58
114
|
}
|
|
59
115
|
constructor(el) {
|
|
60
116
|
this._el = el;
|
|
61
117
|
}
|
|
62
118
|
show() {
|
|
63
|
-
|
|
119
|
+
var _a;
|
|
120
|
+
(_a = this._el) == null ? void 0 : _a.show();
|
|
64
121
|
}
|
|
65
122
|
hide() {
|
|
66
|
-
|
|
123
|
+
var _a;
|
|
124
|
+
(_a = this._el) == null ? void 0 : _a.hide();
|
|
67
125
|
}
|
|
68
126
|
}
|
|
69
127
|
class ReactRenderer extends ExternalRenderer {
|
|
@@ -72,37 +130,41 @@ class ReactRenderer extends ExternalRenderer {
|
|
|
72
130
|
this._reactFlicking = options.reactFlicking;
|
|
73
131
|
}
|
|
74
132
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
133
|
+
render() {
|
|
134
|
+
return __async(this, null, function* () {
|
|
135
|
+
const flicking = getFlickingAttached(this._flicking);
|
|
136
|
+
const reactFlicking = this._reactFlicking;
|
|
137
|
+
const strategy = this._strategy;
|
|
138
|
+
if (flicking.virtualEnabled) {
|
|
139
|
+
strategy.updateRenderingPanels(flicking);
|
|
140
|
+
this._rendering = true;
|
|
141
|
+
} else {
|
|
142
|
+
this._rendering = true;
|
|
143
|
+
strategy.updateRenderingPanels(flicking);
|
|
144
|
+
}
|
|
145
|
+
strategy.renderPanels(flicking);
|
|
146
|
+
return new Promise((resolve) => {
|
|
147
|
+
reactFlicking.renderEmitter.once("render", () => {
|
|
148
|
+
this._rendering = false;
|
|
149
|
+
this._afterRender();
|
|
150
|
+
resolve();
|
|
151
|
+
});
|
|
152
|
+
reactFlicking.forceUpdate();
|
|
92
153
|
});
|
|
93
|
-
reactFlicking.forceUpdate();
|
|
94
154
|
});
|
|
95
155
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
156
|
+
forceRenderAllPanels() {
|
|
157
|
+
return __async(this, null, function* () {
|
|
158
|
+
const reactFlicking = this._reactFlicking;
|
|
159
|
+
this._rendering = true;
|
|
160
|
+
yield __superGet(ReactRenderer.prototype, this, "forceRenderAllPanels").call(this);
|
|
161
|
+
return new Promise((resolve) => {
|
|
162
|
+
reactFlicking.renderEmitter.once("render", () => {
|
|
163
|
+
this._rendering = false;
|
|
164
|
+
resolve();
|
|
165
|
+
});
|
|
166
|
+
reactFlicking.forceUpdate();
|
|
104
167
|
});
|
|
105
|
-
reactFlicking.forceUpdate();
|
|
106
168
|
});
|
|
107
169
|
}
|
|
108
170
|
destroy() {
|
|
@@ -150,13 +212,13 @@ class StrictPanel extends React.Component {
|
|
|
150
212
|
}
|
|
151
213
|
}
|
|
152
214
|
const ViewportSlot = React__default.memo((props) => /* @__PURE__ */ jsx(Fragment, { children: props.children }));
|
|
153
|
-
var
|
|
215
|
+
var __defProp2 = Object.defineProperty;
|
|
154
216
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
155
217
|
var result = void 0;
|
|
156
218
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
157
219
|
if (decorator = decorators[i])
|
|
158
220
|
result = decorator(target, key, result) || result;
|
|
159
|
-
if (result)
|
|
221
|
+
if (result) __defProp2(target, key, result);
|
|
160
222
|
return result;
|
|
161
223
|
};
|
|
162
224
|
const _Flicking = class _Flicking extends React.Component {
|
|
@@ -183,10 +245,9 @@ const _Flicking = class _Flicking extends React.Component {
|
|
|
183
245
|
providerCtor: ReactElementProvider
|
|
184
246
|
})
|
|
185
247
|
};
|
|
186
|
-
const flicking = new VanillaFlicking__default(this._viewportElement, {
|
|
187
|
-
...props,
|
|
248
|
+
const flicking = new VanillaFlicking__default(this._viewportElement, __spreadProps(__spreadValues({}, props), {
|
|
188
249
|
externalRenderer: new ReactRenderer(rendererOptions)
|
|
189
|
-
});
|
|
250
|
+
}));
|
|
190
251
|
this._vanillaFlicking = flicking;
|
|
191
252
|
const children = this._getChildren();
|
|
192
253
|
this._jsxDiffer = new ListDiffer(children, (panel) => panel.key);
|
|
@@ -199,13 +260,14 @@ const _Flicking = class _Flicking extends React.Component {
|
|
|
199
260
|
}
|
|
200
261
|
}
|
|
201
262
|
componentWillUnmount() {
|
|
202
|
-
|
|
263
|
+
var _a;
|
|
264
|
+
(_a = this._vanillaFlicking) == null ? void 0 : _a.destroy();
|
|
203
265
|
}
|
|
204
266
|
shouldComponentUpdate(nextProps) {
|
|
205
267
|
const vanillaFlicking = this._vanillaFlicking;
|
|
206
268
|
const prevProps = this.props;
|
|
207
269
|
if (!vanillaFlicking || !vanillaFlicking.initialized) return false;
|
|
208
|
-
const { children,
|
|
270
|
+
const _a = nextProps, { children } = _a, restProps = __objRest(_a, ["children"]);
|
|
209
271
|
for (const key in restProps) {
|
|
210
272
|
if (prevProps[key] !== nextProps[key]) {
|
|
211
273
|
return true;
|
|
@@ -235,7 +297,7 @@ const _Flicking = class _Flicking extends React.Component {
|
|
|
235
297
|
this._checkPlugins();
|
|
236
298
|
renderEmitter.trigger("render");
|
|
237
299
|
flicking.camera.updateOffset();
|
|
238
|
-
const { virtual,
|
|
300
|
+
const _a = this.props, { virtual } = _a, props = __objRest(_a, ["virtual"]);
|
|
239
301
|
for (const key in props) {
|
|
240
302
|
if (key in flicking && flicking[key] !== props[key]) {
|
|
241
303
|
flicking[key] = props[key];
|
|
@@ -246,6 +308,7 @@ const _Flicking = class _Flicking extends React.Component {
|
|
|
246
308
|
this._diffResult = null;
|
|
247
309
|
}
|
|
248
310
|
render() {
|
|
311
|
+
var _a;
|
|
249
312
|
const props = this.props;
|
|
250
313
|
const Viewport = props.viewportTag;
|
|
251
314
|
const Camera = props.cameraTag;
|
|
@@ -257,24 +320,24 @@ const _Flicking = class _Flicking extends React.Component {
|
|
|
257
320
|
}
|
|
258
321
|
}
|
|
259
322
|
const { viewportClasses, cameraClasses, cameraProps } = this._getClasses(attributes, props);
|
|
260
|
-
const panels = !!props.virtual && (props.panelsPerView
|
|
323
|
+
const panels = !!props.virtual && ((_a = props.panelsPerView) != null ? _a : -1) > 0 ? this._getVirtualPanels() : this._getPanels();
|
|
261
324
|
return /* @__PURE__ */ jsxs(
|
|
262
325
|
Viewport,
|
|
263
|
-
{
|
|
264
|
-
...attributes,
|
|
326
|
+
__spreadProps(__spreadValues({}, attributes), {
|
|
265
327
|
className: viewportClasses.join(" "),
|
|
266
328
|
ref: (e) => {
|
|
267
329
|
e && (this._viewportElement = e);
|
|
268
330
|
},
|
|
269
331
|
children: [
|
|
270
|
-
/* @__PURE__ */ jsx(Camera, { className: cameraClasses.join(" "),
|
|
332
|
+
/* @__PURE__ */ jsx(Camera, __spreadProps(__spreadValues({ className: cameraClasses.join(" ") }, cameraProps), { children: panels })),
|
|
271
333
|
this._getViewportSlot()
|
|
272
334
|
]
|
|
273
|
-
}
|
|
335
|
+
})
|
|
274
336
|
);
|
|
275
337
|
}
|
|
276
338
|
_createPanelRefs(props, children) {
|
|
277
|
-
|
|
339
|
+
var _a;
|
|
340
|
+
const panelsPerView = (_a = props.panelsPerView) != null ? _a : -1;
|
|
278
341
|
return panelsPerView > 0 && !!props.virtual ? range(panelsPerView + 1).map(() => React.createRef()) : children.map(() => React.createRef());
|
|
279
342
|
}
|
|
280
343
|
_bindEvents() {
|
|
@@ -302,11 +365,12 @@ const _Flicking = class _Flicking extends React.Component {
|
|
|
302
365
|
flicking.removePlugins(...removed.map((index) => prevList[index]));
|
|
303
366
|
}
|
|
304
367
|
_getClasses(attributes, props) {
|
|
368
|
+
var _a;
|
|
305
369
|
const flicking = this._vanillaFlicking;
|
|
306
|
-
const initialized = flicking
|
|
370
|
+
const initialized = flicking == null ? void 0 : flicking.initialized;
|
|
307
371
|
const viewportClasses = ["flicking-viewport"];
|
|
308
372
|
const cameraClasses = ["flicking-camera"];
|
|
309
|
-
const isHorizontal = flicking ? flicking.horizontal : props.horizontal
|
|
373
|
+
const isHorizontal = flicking ? flicking.horizontal : (_a = props.horizontal) != null ? _a : true;
|
|
310
374
|
if (!isHorizontal) {
|
|
311
375
|
viewportClasses.push("vertical");
|
|
312
376
|
}
|
|
@@ -361,9 +425,9 @@ const _Flicking = class _Flicking extends React.Component {
|
|
|
361
425
|
const { panelClass = "flicking-panel" } = this.props.virtual;
|
|
362
426
|
const panelsPerView = this.props.panelsPerView;
|
|
363
427
|
const flicking = this._vanillaFlicking;
|
|
364
|
-
const initialized = flicking
|
|
428
|
+
const initialized = flicking == null ? void 0 : flicking.initialized;
|
|
365
429
|
const renderingIndexes = initialized ? flicking.renderer.strategy.getRenderingIndexesByOrder(flicking) : range(panelsPerView + 1);
|
|
366
|
-
const firstPanel = flicking
|
|
430
|
+
const firstPanel = flicking == null ? void 0 : flicking.panels[0];
|
|
367
431
|
const size = firstPanel ? flicking.horizontal ? { width: firstPanel.size } : { height: firstPanel.size } : {};
|
|
368
432
|
return renderingIndexes.map((idx) => {
|
|
369
433
|
return /* @__PURE__ */ jsx(StrictPanel, { ref: this._panels[idx], children: /* @__PURE__ */ jsx("div", { "data-element-index": idx, className: panelClass, style: size }) }, idx);
|
|
@@ -373,7 +437,7 @@ const _Flicking = class _Flicking extends React.Component {
|
|
|
373
437
|
const origChildren = this._getChildren();
|
|
374
438
|
const vanillaFlicking = this._vanillaFlicking;
|
|
375
439
|
const diffResult = this._diffResult;
|
|
376
|
-
const children = vanillaFlicking
|
|
440
|
+
const children = (vanillaFlicking == null ? void 0 : vanillaFlicking.initialized) ? diffResult ? getRenderingPanels(vanillaFlicking, diffResult) : getRenderingPanels(vanillaFlicking, diff(origChildren, origChildren)) : origChildren;
|
|
377
441
|
return children.map((child, idx) => /* @__PURE__ */ jsx(StrictPanel, { ref: this._panels[idx], children: child }, child.key));
|
|
378
442
|
}
|
|
379
443
|
_isFragment(child) {
|
|
@@ -388,8 +452,7 @@ let Flicking = _Flicking;
|
|
|
388
452
|
__decorateClass([
|
|
389
453
|
withFlickingMethods
|
|
390
454
|
], Flicking.prototype, "_vanillaFlicking");
|
|
391
|
-
const CROSSFLICKING_DEFAULT_PROPS = {
|
|
392
|
-
...DEFAULT_PROPS,
|
|
455
|
+
const CROSSFLICKING_DEFAULT_PROPS = __spreadProps(__spreadValues({}, DEFAULT_PROPS), {
|
|
393
456
|
onSideHoldStart: (e) => {
|
|
394
457
|
},
|
|
395
458
|
onSideHoldEnd: (e) => {
|
|
@@ -408,7 +471,7 @@ const CROSSFLICKING_DEFAULT_PROPS = {
|
|
|
408
471
|
},
|
|
409
472
|
onSideRestored: (e) => {
|
|
410
473
|
}
|
|
411
|
-
};
|
|
474
|
+
});
|
|
412
475
|
const _CrossFlicking = class _CrossFlicking extends Flicking {
|
|
413
476
|
componentDidMount() {
|
|
414
477
|
const props = {};
|
|
@@ -423,10 +486,9 @@ const _CrossFlicking = class _CrossFlicking extends Flicking {
|
|
|
423
486
|
providerCtor: ReactElementProvider
|
|
424
487
|
})
|
|
425
488
|
};
|
|
426
|
-
const flicking = new CrossFlicking$1(this._viewportElement, {
|
|
427
|
-
...props,
|
|
489
|
+
const flicking = new CrossFlicking$1(this._viewportElement, __spreadProps(__spreadValues({}, props), {
|
|
428
490
|
externalRenderer: new ReactRenderer(rendererOptions)
|
|
429
|
-
});
|
|
491
|
+
}));
|
|
430
492
|
this._vanillaFlicking = flicking;
|
|
431
493
|
const children = this._getChildren();
|
|
432
494
|
this._jsxDiffer = new ListDiffer(children, (panel) => panel.key);
|
|
@@ -453,17 +515,16 @@ const _CrossFlicking = class _CrossFlicking extends Flicking {
|
|
|
453
515
|
const panels = this._getPanels();
|
|
454
516
|
return /* @__PURE__ */ jsxs(
|
|
455
517
|
Viewport,
|
|
456
|
-
{
|
|
457
|
-
...attributes,
|
|
518
|
+
__spreadProps(__spreadValues({}, attributes), {
|
|
458
519
|
className: viewportClasses.join(" "),
|
|
459
520
|
ref: (e) => {
|
|
460
521
|
e && (this._viewportElement = e);
|
|
461
522
|
},
|
|
462
523
|
children: [
|
|
463
|
-
/* @__PURE__ */ jsx(Camera, { className: cameraClasses.join(" "),
|
|
524
|
+
/* @__PURE__ */ jsx(Camera, __spreadProps(__spreadValues({ className: cameraClasses.join(" ") }, cameraProps), { children: panels })),
|
|
464
525
|
this._getViewportSlot()
|
|
465
526
|
]
|
|
466
|
-
}
|
|
527
|
+
})
|
|
467
528
|
);
|
|
468
529
|
}
|
|
469
530
|
_bindEvents() {
|
|
@@ -476,7 +537,10 @@ const _CrossFlicking = class _CrossFlicking extends Flicking {
|
|
|
476
537
|
};
|
|
477
538
|
_CrossFlicking.defaultProps = CROSSFLICKING_DEFAULT_PROPS;
|
|
478
539
|
let CrossFlicking = _CrossFlicking;
|
|
479
|
-
const CrossGroup = React__default.forwardRef((
|
|
540
|
+
const CrossGroup = React__default.forwardRef((_a, ref) => {
|
|
541
|
+
var _b = _a, { children } = _b, rest = __objRest(_b, ["children"]);
|
|
542
|
+
return /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({ ref }, rest), { children }));
|
|
543
|
+
});
|
|
480
544
|
function keys(obj) {
|
|
481
545
|
return Object.keys(obj);
|
|
482
546
|
}
|
|
@@ -787,10 +851,13 @@ function useReactive(reactiveAdapter, props) {
|
|
|
787
851
|
return result;
|
|
788
852
|
}
|
|
789
853
|
const useFlickingReactiveAPI = (flickingRef, options) => {
|
|
790
|
-
return useReactive(flickingReactiveAPIAdapter, () =>
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
854
|
+
return useReactive(flickingReactiveAPIAdapter, () => {
|
|
855
|
+
var _a;
|
|
856
|
+
return {
|
|
857
|
+
flicking: (_a = flickingRef.current) != null ? _a : void 0,
|
|
858
|
+
options
|
|
859
|
+
};
|
|
860
|
+
});
|
|
794
861
|
};
|
|
795
862
|
export {
|
|
796
863
|
CrossFlicking,
|