@egjs/react-flicking 4.15.0 → 4.16.0-beta.1
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/dev/archive/App.css +32 -0
- package/dev/archive/App.tsx +52 -0
- package/dev/archive/DebugPage.css +21 -0
- package/dev/archive/DebugPage.tsx +93 -0
- package/dev/archive/Header.tsx +52 -0
- package/dev/archive/StatePage.css +21 -0
- package/dev/archive/StatePage.tsx +107 -0
- package/dev/archive/css/align.css +79 -0
- package/dev/archive/css/bound.css +88 -0
- package/dev/archive/css/common.css +76 -0
- package/dev/archive/css/cross.css +21 -0
- package/dev/archive/css/features.css +49 -0
- package/dev/archive/css/gap.css +13 -0
- package/dev/archive/css/highlight.css +96 -0
- package/dev/archive/css/infinite.css +35 -0
- package/dev/archive/css/parallax.css +3 -0
- package/dev/archive/css/plugins.css +46 -0
- package/dev/archive/css/progress.css +16 -0
- package/dev/archive/css/variable-size.css +15 -0
- package/dev/archive/features/Align.tsx +149 -0
- package/dev/archive/features/Bound.tsx +83 -0
- package/dev/archive/features/CrossFlicking.tsx +74 -0
- package/dev/archive/features/FreeScroll.tsx +66 -0
- package/dev/archive/features/InfiniteFlicking.tsx +192 -0
- package/dev/archive/features/PlaceHolderItem.tsx +36 -0
- package/dev/archive/features/Progress.tsx +241 -0
- package/dev/archive/features/PropChange.tsx +171 -0
- package/dev/archive/features/Snap.tsx +95 -0
- package/dev/archive/features/VariableSize.tsx +42 -0
- package/dev/archive/features/Virtual.tsx +45 -0
- package/dev/archive/plugins/Arrow.tsx +25 -0
- package/dev/archive/plugins/AutoPlay.tsx +70 -0
- package/dev/archive/plugins/Fade.tsx +69 -0
- package/dev/archive/plugins/Parallax.tsx +70 -0
- package/dev/archive/utils.ts +3 -0
- package/dev/basic-sample/App.tsx +36 -0
- package/dev/basic-sample/index.html +12 -0
- package/dev/basic-sample/main.tsx +10 -0
- package/dev/index.html +18 -0
- package/dev/plugin-check/App.tsx +341 -0
- package/dev/plugin-check/index.html +15 -0
- package/dev/plugin-check/main.tsx +6 -0
- package/dev/scratch/App.tsx +34 -0
- package/dev/scratch/index.html +15 -0
- package/dev/scratch/main.tsx +13 -0
- package/dev/tsconfig.json +12 -0
- package/dev/vite-env.d.ts +3 -0
- package/{declaration → dist}/CrossFlicking.d.ts +3 -5
- package/{declaration → dist}/CrossGroup.d.ts +1 -1
- package/{declaration → dist}/Flicking.d.ts +8 -8
- package/{declaration → dist}/NonStrictPanel.d.ts +1 -1
- package/{declaration → dist}/ReactRenderer.d.ts +1 -1
- package/{declaration → dist}/StrictPanel.d.ts +1 -1
- package/{declaration → dist}/ViewportSlot.d.ts +1 -1
- package/dist/flicking.cjs.js +1514 -579
- package/dist/flicking.cjs.js.map +1 -1
- package/dist/flicking.esm.js +1573 -651
- package/dist/flicking.esm.js.map +1 -1
- package/dist/flicking.js +1634 -0
- package/dist/flicking.js.map +1 -0
- package/{declaration → dist}/index.d.ts +3 -3
- package/{declaration → dist}/types.d.ts +1 -2
- package/package.json +18 -33
- package/src/react-flicking/CrossFlicking.tsx +28 -37
- package/src/react-flicking/CrossGroup.tsx +6 -8
- package/src/react-flicking/Flicking.tsx +81 -69
- package/src/react-flicking/NonStrictPanel.tsx +15 -7
- package/src/react-flicking/ReactElementProvider.ts +6 -4
- package/src/react-flicking/ReactRenderer.ts +1 -2
- package/src/react-flicking/StrictPanel.tsx +10 -6
- package/src/react-flicking/consts.ts +14 -14
- package/src/react-flicking/index.ts +4 -7
- package/src/react-flicking/index.umd.ts +1 -1
- package/src/react-flicking/reactive.ts +3 -3
- package/src/react-flicking/types.ts +17 -17
- package/tsconfig.json +2 -9
- package/vite.config.ts +38 -0
- package/vite.dev.config.ts +58 -0
- package/dist/flicking.umd.js +0 -699
- package/dist/flicking.umd.js.map +0 -1
- /package/{declaration → dist}/ReactElementProvider.d.ts +0 -0
- /package/{declaration → dist}/consts.d.ts +0 -0
- /package/{declaration → dist}/index.umd.d.ts +0 -0
- /package/{declaration → dist}/reactive.d.ts +0 -0
|
@@ -2,30 +2,31 @@
|
|
|
2
2
|
* Copyright (c) 2015 NAVER Corp.
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
import Component from "@egjs/component";
|
|
7
|
-
import ListDiffer, { diff, DiffResult } from "@egjs/list-differ";
|
|
8
7
|
import VanillaFlicking, {
|
|
9
|
-
FlickingOptions,
|
|
10
|
-
VirtualRenderingStrategy,
|
|
11
8
|
EVENTS,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
getRenderingPanels,
|
|
9
|
+
FlickingEvents,
|
|
10
|
+
FlickingOptions,
|
|
15
11
|
getDefaultCameraTransform,
|
|
12
|
+
getRenderingPanels,
|
|
13
|
+
NormalRenderingStrategy,
|
|
16
14
|
Plugin,
|
|
17
15
|
range,
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
sync,
|
|
17
|
+
VirtualRenderingStrategy,
|
|
18
|
+
withFlickingMethods
|
|
20
19
|
} from "@egjs/flicking";
|
|
20
|
+
import ListDiffer, { DiffResult, diff } from "@egjs/list-differ";
|
|
21
|
+
import * as React from "react";
|
|
21
22
|
|
|
22
23
|
import { DEFAULT_PROPS } from "./consts";
|
|
23
|
-
import
|
|
24
|
+
import NonStrictPanel from "./NonStrictPanel";
|
|
25
|
+
import ReactElementProvider from "./ReactElementProvider";
|
|
24
26
|
import ReactRenderer, { ReactRendererOptions } from "./ReactRenderer";
|
|
25
27
|
import StrictPanel from "./StrictPanel";
|
|
26
|
-
import
|
|
28
|
+
import { FlickingProps } from "./types";
|
|
27
29
|
import ViewportSlot from "./ViewportSlot";
|
|
28
|
-
import ReactElementProvider from "./ReactElementProvider";
|
|
29
30
|
|
|
30
31
|
class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>> {
|
|
31
32
|
public static defaultProps: FlickingProps = DEFAULT_PROPS;
|
|
@@ -36,11 +37,15 @@ class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>
|
|
|
36
37
|
protected _jsxDiffer: ListDiffer<React.ReactElement>;
|
|
37
38
|
protected _viewportElement: HTMLElement;
|
|
38
39
|
private _diffResult: DiffResult<React.ReactElement> | null;
|
|
39
|
-
private _renderEmitter = new Component<{ render:
|
|
40
|
+
private _renderEmitter = new Component<{ render: undefined }>();
|
|
40
41
|
protected _prevChildren: React.ReactElement[];
|
|
41
42
|
|
|
42
|
-
public get reactPanels() {
|
|
43
|
-
|
|
43
|
+
public get reactPanels() {
|
|
44
|
+
return this._panels.map(panel => panel.current!);
|
|
45
|
+
}
|
|
46
|
+
public get renderEmitter() {
|
|
47
|
+
return this._renderEmitter;
|
|
48
|
+
}
|
|
44
49
|
|
|
45
50
|
public constructor(props: Partial<FlickingProps & FlickingOptions>) {
|
|
46
51
|
super(props);
|
|
@@ -55,20 +60,18 @@ class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>
|
|
|
55
60
|
const rendererOptions: ReactRendererOptions = {
|
|
56
61
|
reactFlicking: this,
|
|
57
62
|
align: props.align,
|
|
58
|
-
strategy:
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
strategy:
|
|
64
|
+
props.virtual && props.panelsPerView > 0
|
|
65
|
+
? new VirtualRenderingStrategy()
|
|
66
|
+
: new NormalRenderingStrategy({
|
|
67
|
+
providerCtor: ReactElementProvider
|
|
68
|
+
})
|
|
63
69
|
};
|
|
64
70
|
|
|
65
|
-
const flicking = new VanillaFlicking(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
externalRenderer: new ReactRenderer(rendererOptions)
|
|
70
|
-
},
|
|
71
|
-
);
|
|
71
|
+
const flicking = new VanillaFlicking(this._viewportElement, {
|
|
72
|
+
...props,
|
|
73
|
+
externalRenderer: new ReactRenderer(rendererOptions)
|
|
74
|
+
});
|
|
72
75
|
|
|
73
76
|
this._vanillaFlicking = flicking;
|
|
74
77
|
|
|
@@ -168,23 +171,28 @@ class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>
|
|
|
168
171
|
|
|
169
172
|
const { viewportClasses, cameraClasses, cameraProps } = this._getClasses(attributes, props);
|
|
170
173
|
|
|
171
|
-
const panels = !!props.virtual && (props.panelsPerView ?? -1) > 0
|
|
172
|
-
? this._getVirtualPanels()
|
|
173
|
-
: this._getPanels();
|
|
174
|
+
const panels = !!props.virtual && (props.panelsPerView ?? -1) > 0 ? this._getVirtualPanels() : this._getPanels();
|
|
174
175
|
|
|
175
176
|
return (
|
|
176
|
-
<Viewport
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
<Viewport
|
|
178
|
+
{...attributes}
|
|
179
|
+
className={viewportClasses.join(" ")}
|
|
180
|
+
ref={(e?: HTMLElement) => {
|
|
181
|
+
e && (this._viewportElement = e);
|
|
182
|
+
}}
|
|
183
|
+
>
|
|
179
184
|
<Camera className={cameraClasses.join(" ")} {...cameraProps}>
|
|
180
|
-
{
|
|
185
|
+
{panels}
|
|
181
186
|
</Camera>
|
|
182
|
-
{
|
|
187
|
+
{this._getViewportSlot()}
|
|
183
188
|
</Viewport>
|
|
184
189
|
);
|
|
185
190
|
}
|
|
186
191
|
|
|
187
|
-
private _createPanelRefs(
|
|
192
|
+
private _createPanelRefs(
|
|
193
|
+
props: this["props"],
|
|
194
|
+
children: Array<React.ReactElement<any>>
|
|
195
|
+
): React.RefObject<StrictPanel | NonStrictPanel | HTMLDivElement>[] {
|
|
188
196
|
const panelsPerView = props.panelsPerView ?? -1;
|
|
189
197
|
|
|
190
198
|
return panelsPerView > 0 && !!props.virtual
|
|
@@ -227,12 +235,10 @@ class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>
|
|
|
227
235
|
protected _getClasses(attributes: { [key: string]: any }, props: typeof this.props) {
|
|
228
236
|
const flicking = this._vanillaFlicking;
|
|
229
237
|
|
|
230
|
-
const initialized = flicking
|
|
238
|
+
const initialized = flicking?.initialized;
|
|
231
239
|
const viewportClasses: string[] = ["flicking-viewport"];
|
|
232
240
|
const cameraClasses: string[] = ["flicking-camera"];
|
|
233
|
-
const isHorizontal = flicking
|
|
234
|
-
? flicking.horizontal
|
|
235
|
-
: props.horizontal ?? true;
|
|
241
|
+
const isHorizontal = flicking ? flicking.horizontal : (props.horizontal ?? true);
|
|
236
242
|
|
|
237
243
|
if (!isHorizontal) {
|
|
238
244
|
viewportClasses.push("vertical");
|
|
@@ -247,16 +253,19 @@ class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>
|
|
|
247
253
|
cameraClasses.push(props.cameraClass);
|
|
248
254
|
}
|
|
249
255
|
|
|
250
|
-
const cameraProps =
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
256
|
+
const cameraProps =
|
|
257
|
+
!initialized && props.firstPanelSize
|
|
258
|
+
? {
|
|
259
|
+
style: {
|
|
260
|
+
transform: getDefaultCameraTransform(this.props.align, this.props.horizontal, this.props.firstPanelSize)
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
: {};
|
|
255
264
|
|
|
256
265
|
return {
|
|
257
266
|
viewportClasses,
|
|
258
267
|
cameraClasses,
|
|
259
|
-
cameraProps
|
|
268
|
+
cameraProps
|
|
260
269
|
};
|
|
261
270
|
}
|
|
262
271
|
|
|
@@ -281,43 +290,42 @@ class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>
|
|
|
281
290
|
}
|
|
282
291
|
|
|
283
292
|
protected _getViewportSlot() {
|
|
284
|
-
return (React.Children.toArray(this.props.children) as Array<React.ReactElement<any>>)
|
|
285
|
-
|
|
293
|
+
return (React.Children.toArray(this.props.children) as Array<React.ReactElement<any>>).filter(
|
|
294
|
+
child => child.type === ViewportSlot
|
|
295
|
+
);
|
|
286
296
|
}
|
|
287
297
|
|
|
288
298
|
private _unpackFragment(child: React.ReactElement) {
|
|
289
299
|
return this._isFragment(child)
|
|
290
|
-
? React.Children.toArray(child.props.children)
|
|
291
|
-
|
|
300
|
+
? React.Children.toArray(child.props.children).reduce(
|
|
301
|
+
(allChilds: React.ReactElement[], fragChild: React.ReactElement) => [
|
|
302
|
+
...allChilds,
|
|
303
|
+
...this._unpackFragment(fragChild)
|
|
304
|
+
],
|
|
305
|
+
[] as React.ReactElement[]
|
|
306
|
+
)
|
|
292
307
|
: [child];
|
|
293
308
|
}
|
|
294
309
|
|
|
295
310
|
private _getVirtualPanels() {
|
|
296
|
-
const {
|
|
297
|
-
panelClass = "flicking-panel"
|
|
298
|
-
} = this.props.virtual!;
|
|
311
|
+
const { panelClass = "flicking-panel" } = this.props.virtual!;
|
|
299
312
|
const panelsPerView = this.props.panelsPerView!;
|
|
300
313
|
const flicking = this._vanillaFlicking;
|
|
301
|
-
const initialized = flicking
|
|
314
|
+
const initialized = flicking?.initialized;
|
|
302
315
|
|
|
303
316
|
const renderingIndexes = initialized
|
|
304
317
|
? flicking.renderer.strategy.getRenderingIndexesByOrder(flicking)
|
|
305
318
|
: range(panelsPerView + 1);
|
|
306
319
|
|
|
307
|
-
const firstPanel = flicking
|
|
308
|
-
const size = firstPanel
|
|
309
|
-
? flicking.horizontal
|
|
310
|
-
? { width: firstPanel.size }
|
|
311
|
-
: { height: firstPanel.size }
|
|
312
|
-
: {};
|
|
320
|
+
const firstPanel = flicking?.panels[0];
|
|
321
|
+
const size = firstPanel ? (flicking.horizontal ? { width: firstPanel.size } : { height: firstPanel.size }) : {};
|
|
313
322
|
|
|
314
323
|
return renderingIndexes.map(idx => {
|
|
315
|
-
return
|
|
316
|
-
|
|
317
|
-
data-element-index={idx}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
</StrictPanel>;
|
|
324
|
+
return (
|
|
325
|
+
<StrictPanel key={idx} ref={this._panels[idx] as any}>
|
|
326
|
+
<div data-element-index={idx} className={panelClass} style={size} />
|
|
327
|
+
</StrictPanel>
|
|
328
|
+
);
|
|
321
329
|
});
|
|
322
330
|
}
|
|
323
331
|
|
|
@@ -326,13 +334,17 @@ class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>
|
|
|
326
334
|
const vanillaFlicking = this._vanillaFlicking;
|
|
327
335
|
const diffResult = this._diffResult;
|
|
328
336
|
|
|
329
|
-
const children: React.ReactElement[] = vanillaFlicking
|
|
337
|
+
const children: React.ReactElement[] = vanillaFlicking?.initialized
|
|
330
338
|
? diffResult
|
|
331
339
|
? getRenderingPanels(vanillaFlicking, diffResult)
|
|
332
340
|
: getRenderingPanels(vanillaFlicking, diff(origChildren, origChildren))
|
|
333
341
|
: origChildren;
|
|
334
342
|
|
|
335
|
-
|
|
343
|
+
return children.map((child, idx) => (
|
|
344
|
+
<StrictPanel key={child.key!} ref={this._panels[idx] as any}>
|
|
345
|
+
{child}
|
|
346
|
+
</StrictPanel>
|
|
347
|
+
));
|
|
336
348
|
}
|
|
337
349
|
|
|
338
350
|
private _isFragment(child: React.ReactElement) {
|
|
@@ -344,5 +356,5 @@ class Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>
|
|
|
344
356
|
}
|
|
345
357
|
}
|
|
346
358
|
|
|
347
|
-
interface Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>, VanillaFlicking {
|
|
359
|
+
interface Flicking extends React.Component<Partial<FlickingProps & FlickingOptions>>, VanillaFlicking {}
|
|
348
360
|
export default Flicking;
|
|
@@ -8,16 +8,24 @@ class NonStrictPanel extends React.Component<{ children?: React.ReactElement }>
|
|
|
8
8
|
private _hide: boolean = false;
|
|
9
9
|
private _elRef: React.RefObject<HTMLElement> = React.createRef();
|
|
10
10
|
|
|
11
|
-
public get nativeElement() {
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
public get nativeElement() {
|
|
12
|
+
return this._elRef.current!;
|
|
13
|
+
}
|
|
14
|
+
public get rendered() {
|
|
15
|
+
return !this._hide;
|
|
16
|
+
}
|
|
17
|
+
public get elRef() {
|
|
18
|
+
return this._elRef;
|
|
19
|
+
}
|
|
14
20
|
|
|
15
21
|
public render() {
|
|
16
|
-
return this._hide
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
return this._hide ? (
|
|
23
|
+
<></>
|
|
24
|
+
) : (
|
|
25
|
+
React.cloneElement(React.Children.only(this.props.children) as React.ReactElement, {
|
|
19
26
|
ref: this._elRef
|
|
20
|
-
})
|
|
27
|
+
})
|
|
28
|
+
);
|
|
21
29
|
}
|
|
22
30
|
|
|
23
31
|
public show() {
|
|
@@ -4,14 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { ElementProvider } from "@egjs/flicking";
|
|
6
6
|
import StrictPanel from "./StrictPanel";
|
|
7
|
-
import NonStrictPanel from "./NonStrictPanel";
|
|
8
|
-
import React from "react";
|
|
9
7
|
|
|
10
8
|
class ReactElementProvider implements ElementProvider {
|
|
11
9
|
private _el: StrictPanel;
|
|
12
10
|
|
|
13
|
-
public get element() {
|
|
14
|
-
|
|
11
|
+
public get element() {
|
|
12
|
+
return this._el?.nativeElement;
|
|
13
|
+
}
|
|
14
|
+
public get rendered() {
|
|
15
|
+
return this._el?.rendered;
|
|
16
|
+
}
|
|
15
17
|
|
|
16
18
|
public constructor(el: StrictPanel) {
|
|
17
19
|
this._el = el;
|
|
@@ -2,11 +2,10 @@
|
|
|
2
2
|
* Copyright (c) 2015 NAVER Corp.
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import { ExternalRenderer, PanelOptions, RendererOptions
|
|
5
|
+
import { ExternalRenderer, getFlickingAttached, PanelOptions, RendererOptions } from "@egjs/flicking";
|
|
6
6
|
|
|
7
7
|
import ReactFlicking from "./Flicking";
|
|
8
8
|
import StrictPanel from "./StrictPanel";
|
|
9
|
-
import NonStrictPanel from "./NonStrictPanel";
|
|
10
9
|
|
|
11
10
|
export interface ReactRendererOptions extends RendererOptions {
|
|
12
11
|
reactFlicking: ReactFlicking;
|
|
@@ -9,14 +9,18 @@ class StrictPanel extends React.Component<{ children?: React.ReactElement }> {
|
|
|
9
9
|
|
|
10
10
|
private _elRef: React.RefObject<HTMLElement> = React.createRef();
|
|
11
11
|
|
|
12
|
-
public get nativeElement() {
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
public get nativeElement() {
|
|
13
|
+
return this._elRef.current!;
|
|
14
|
+
}
|
|
15
|
+
public get rendered() {
|
|
16
|
+
return !this._hide;
|
|
17
|
+
}
|
|
18
|
+
public get elRef() {
|
|
19
|
+
return this._elRef;
|
|
20
|
+
}
|
|
15
21
|
|
|
16
22
|
public render() {
|
|
17
|
-
return this._hide
|
|
18
|
-
? <></>
|
|
19
|
-
: this._getElement();
|
|
23
|
+
return this._hide ? <></> : this._getElement();
|
|
20
24
|
}
|
|
21
25
|
|
|
22
26
|
public show() {
|
|
@@ -3,23 +3,23 @@
|
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
HoldStartEvent,
|
|
6
|
+
AfterResizeEvent,
|
|
7
|
+
BeforeResizeEvent,
|
|
8
|
+
ChangedEvent,
|
|
10
9
|
HoldEndEvent,
|
|
11
|
-
|
|
12
|
-
MoveEvent,
|
|
10
|
+
HoldStartEvent,
|
|
13
11
|
MoveEndEvent,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
ReadyEvent,
|
|
19
|
-
BeforeResizeEvent,
|
|
20
|
-
AfterResizeEvent,
|
|
12
|
+
MoveEvent,
|
|
13
|
+
MoveStartEvent,
|
|
14
|
+
NeedPanelEvent,
|
|
15
|
+
PanelChangeEvent,
|
|
21
16
|
ReachEdgeEvent,
|
|
22
|
-
|
|
17
|
+
ReadyEvent,
|
|
18
|
+
RestoredEvent,
|
|
19
|
+
SelectEvent,
|
|
20
|
+
VisibleChangeEvent,
|
|
21
|
+
WillChangeEvent,
|
|
22
|
+
WillRestoreEvent
|
|
23
23
|
} from "@egjs/flicking";
|
|
24
24
|
|
|
25
25
|
import { FlickingProps } from "./types";
|
|
@@ -2,18 +2,15 @@
|
|
|
2
2
|
* Copyright (c) 2015 NAVER Corp.
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
import CrossFlicking from "./CrossFlicking";
|
|
7
7
|
import CrossGroup from "./CrossGroup";
|
|
8
|
+
import Flicking from "./Flicking";
|
|
8
9
|
import ViewportSlot from "./ViewportSlot";
|
|
9
10
|
|
|
10
11
|
export * from "@egjs/flicking";
|
|
11
|
-
export * from "./types";
|
|
12
12
|
export * from "./reactive";
|
|
13
|
+
export * from "./types";
|
|
13
14
|
|
|
14
|
-
export {
|
|
15
|
-
CrossFlicking,
|
|
16
|
-
CrossGroup,
|
|
17
|
-
ViewportSlot,
|
|
18
|
-
}
|
|
15
|
+
export { CrossFlicking, CrossGroup, ViewportSlot };
|
|
19
16
|
export default Flicking;
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
5
|
import Flicking from "./Flicking";
|
|
6
|
-
import ViewportSlot from "./ViewportSlot";
|
|
7
6
|
import { useFlickingReactiveAPI } from "./reactive";
|
|
7
|
+
import ViewportSlot from "./ViewportSlot";
|
|
8
8
|
|
|
9
9
|
(Flicking as any).ViewportSlot = ViewportSlot;
|
|
10
10
|
(Flicking as any).useFlickingReactiveAPI = useFlickingReactiveAPI;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { useReactive } from "@cfcs/react";
|
|
1
2
|
import { FlickingReactiveAPIOptions, flickingReactiveAPIAdapter } from "@egjs/flicking";
|
|
2
3
|
import { RefObject } from "react";
|
|
3
4
|
import Flicking from "./Flicking";
|
|
4
|
-
import { useReactive } from "@cfcs/react";
|
|
5
5
|
|
|
6
6
|
export const useFlickingReactiveAPI = (flickingRef: RefObject<Flicking>, options?: FlickingReactiveAPIOptions) => {
|
|
7
7
|
return useReactive(flickingReactiveAPIAdapter, () => ({
|
|
8
8
|
flicking: flickingRef.current ?? undefined,
|
|
9
9
|
options
|
|
10
|
-
}))
|
|
11
|
-
}
|
|
10
|
+
}));
|
|
11
|
+
};
|
|
@@ -2,28 +2,29 @@
|
|
|
2
2
|
* Copyright (c) 2015 NAVER Corp.
|
|
3
3
|
* egjs projects are licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
HoldStartEvent,
|
|
7
|
+
AfterResizeEvent,
|
|
8
|
+
BeforeResizeEvent,
|
|
9
|
+
ChangedEvent,
|
|
11
10
|
HoldEndEvent,
|
|
12
|
-
|
|
13
|
-
MoveEvent,
|
|
11
|
+
HoldStartEvent,
|
|
14
12
|
MoveEndEvent,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
RestoredEvent,
|
|
19
|
-
ReadyEvent,
|
|
20
|
-
BeforeResizeEvent,
|
|
21
|
-
AfterResizeEvent,
|
|
22
|
-
ReachEdgeEvent,
|
|
13
|
+
MoveEvent,
|
|
14
|
+
MoveStartEvent,
|
|
15
|
+
NeedPanelEvent,
|
|
23
16
|
PanelChangeEvent,
|
|
24
17
|
Plugin,
|
|
25
|
-
|
|
18
|
+
ReachEdgeEvent,
|
|
19
|
+
ReadyEvent,
|
|
20
|
+
RestoredEvent,
|
|
21
|
+
SelectEvent,
|
|
22
|
+
Status,
|
|
23
|
+
VisibleChangeEvent,
|
|
24
|
+
WillChangeEvent,
|
|
25
|
+
WillRestoreEvent
|
|
26
26
|
} from "@egjs/flicking";
|
|
27
|
+
import ReactFlicking from "./Flicking";
|
|
27
28
|
|
|
28
29
|
export interface FlickingProps {
|
|
29
30
|
viewportTag: keyof JSX.IntrinsicElements;
|
|
@@ -54,4 +55,3 @@ export interface FlickingProps {
|
|
|
54
55
|
onPanelChange: (e: PanelChangeEvent<ReactFlicking>) => any;
|
|
55
56
|
[key: string]: any;
|
|
56
57
|
}
|
|
57
|
-
|
package/tsconfig.json
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
3
|
"target": "es5",
|
|
4
|
-
"lib": [
|
|
5
|
-
"dom",
|
|
6
|
-
"dom.iterable",
|
|
7
|
-
"esnext"
|
|
8
|
-
],
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
9
5
|
"allowJs": true,
|
|
10
6
|
"skipLibCheck": true,
|
|
11
7
|
"strictNullChecks": true,
|
|
12
8
|
"esModuleInterop": true,
|
|
13
9
|
"importHelpers": true,
|
|
14
10
|
"experimentalDecorators": true,
|
|
15
|
-
"suppressImplicitAnyIndexErrors": true,
|
|
16
11
|
"allowSyntheticDefaultImports": true,
|
|
17
12
|
"forceConsistentCasingInFileNames": true,
|
|
18
13
|
"module": "esnext",
|
|
@@ -24,7 +19,5 @@
|
|
|
24
19
|
"noEmit": true,
|
|
25
20
|
"noFallthroughCasesInSwitch": true
|
|
26
21
|
},
|
|
27
|
-
"include": [
|
|
28
|
-
"src"
|
|
29
|
-
]
|
|
22
|
+
"include": ["src"]
|
|
30
23
|
}
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createViteConfig } from "../../config/vite-build-helper";
|
|
2
|
+
// @ts-expect-error: resolveJsonModule issue in build environment
|
|
3
|
+
import pkg from "./package.json";
|
|
4
|
+
|
|
5
|
+
const name = "ReactFlicking";
|
|
6
|
+
const external = {
|
|
7
|
+
react: "React",
|
|
8
|
+
"react-dom": "ReactDOM",
|
|
9
|
+
"@egjs/flicking": "Flicking",
|
|
10
|
+
"@egjs/component": "Component",
|
|
11
|
+
"@egjs/list-differ": "eg.ListDiffer"
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// Determine build target based on environment variable
|
|
15
|
+
// usage: VITE_BUILD_FORMAT=umd vite build
|
|
16
|
+
const buildFormat = process.env.VITE_BUILD_FORMAT || "esm";
|
|
17
|
+
|
|
18
|
+
let input = "src/react-flicking/index.ts";
|
|
19
|
+
let formats: any[] = ["es"];
|
|
20
|
+
|
|
21
|
+
if (buildFormat === "cjs") {
|
|
22
|
+
input = "src/react-flicking/index.umd.ts";
|
|
23
|
+
formats = ["cjs"];
|
|
24
|
+
} else if (buildFormat === "umd") {
|
|
25
|
+
input = "src/react-flicking/index.umd.ts";
|
|
26
|
+
formats = ["umd"];
|
|
27
|
+
}
|
|
28
|
+
// Default (esm) uses index.ts
|
|
29
|
+
|
|
30
|
+
export default createViteConfig({
|
|
31
|
+
input,
|
|
32
|
+
name,
|
|
33
|
+
packageJson: pkg,
|
|
34
|
+
external,
|
|
35
|
+
formats,
|
|
36
|
+
tsconfig: "tsconfig.build.json", // Use build specific tsconfig
|
|
37
|
+
output: "dist/flicking" // Base name for output files
|
|
38
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import react from "@vitejs/plugin-react";
|
|
3
|
+
import { defineConfig } from "vite";
|
|
4
|
+
|
|
5
|
+
export default defineConfig(({ mode }) => {
|
|
6
|
+
const useBuild = mode === "production";
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
plugins: [
|
|
10
|
+
react({
|
|
11
|
+
babel: {
|
|
12
|
+
plugins: [
|
|
13
|
+
["@babel/plugin-proposal-decorators", { legacy: true }],
|
|
14
|
+
["@babel/plugin-proposal-class-properties", { loose: true }]
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
],
|
|
19
|
+
root: path.resolve(__dirname, "dev"),
|
|
20
|
+
server: {
|
|
21
|
+
port: 3001,
|
|
22
|
+
open: true,
|
|
23
|
+
fs: {
|
|
24
|
+
allow: [".."]
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
resolve: {
|
|
28
|
+
alias: useBuild
|
|
29
|
+
? {
|
|
30
|
+
// 빌드 검증 모드 - 빌드 결과물 사용
|
|
31
|
+
"@dev/flicking": path.resolve(__dirname, "../flicking/dist/flicking.esm.js"),
|
|
32
|
+
"@dev/react-flicking": path.resolve(__dirname, "dist/flicking.esm.js"),
|
|
33
|
+
"@dev/plugins": path.resolve(__dirname, "../flicking-plugins/dist/plugins.esm.js"),
|
|
34
|
+
"@dev/flicking-css": path.resolve(__dirname, "../flicking/dist/flicking.css"),
|
|
35
|
+
"@dev/plugins-css": path.resolve(__dirname, "../flicking-plugins/dist/flicking-plugins.css"),
|
|
36
|
+
// 소스코드 내부의 @egjs/flicking 참조용
|
|
37
|
+
"@egjs/flicking": path.resolve(__dirname, "../flicking/dist/flicking.esm.js")
|
|
38
|
+
}
|
|
39
|
+
: {
|
|
40
|
+
// 개발 모드 - 모든 소스 직접 참조 (HMR!)
|
|
41
|
+
"@dev/flicking": path.resolve(__dirname, "../flicking/src/index.ts"),
|
|
42
|
+
"@dev/react-flicking": path.resolve(__dirname, "src/react-flicking/index.ts"),
|
|
43
|
+
"@dev/plugins": path.resolve(__dirname, "../flicking-plugins/src/index.ts"),
|
|
44
|
+
"@dev/flicking-css": path.resolve(__dirname, "../flicking/sass/flicking.sass"),
|
|
45
|
+
"@dev/plugins-css": path.resolve(__dirname, "../flicking-plugins/css/all.css"),
|
|
46
|
+
// 소스코드 내부의 @egjs/flicking 참조용
|
|
47
|
+
"@egjs/flicking": path.resolve(__dirname, "../flicking/src/index.ts")
|
|
48
|
+
},
|
|
49
|
+
extensions: [".ts", ".tsx", ".js", ".jsx"]
|
|
50
|
+
},
|
|
51
|
+
optimizeDeps: {
|
|
52
|
+
include: ["react", "react-dom", "@egjs/axes", "@egjs/component", "@egjs/imready", "@egjs/list-differ"]
|
|
53
|
+
},
|
|
54
|
+
define: {
|
|
55
|
+
__DEV__: JSON.stringify(!useBuild)
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
});
|