@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.
Files changed (84) hide show
  1. package/dev/archive/App.css +32 -0
  2. package/dev/archive/App.tsx +52 -0
  3. package/dev/archive/DebugPage.css +21 -0
  4. package/dev/archive/DebugPage.tsx +93 -0
  5. package/dev/archive/Header.tsx +52 -0
  6. package/dev/archive/StatePage.css +21 -0
  7. package/dev/archive/StatePage.tsx +107 -0
  8. package/dev/archive/css/align.css +79 -0
  9. package/dev/archive/css/bound.css +88 -0
  10. package/dev/archive/css/common.css +76 -0
  11. package/dev/archive/css/cross.css +21 -0
  12. package/dev/archive/css/features.css +49 -0
  13. package/dev/archive/css/gap.css +13 -0
  14. package/dev/archive/css/highlight.css +96 -0
  15. package/dev/archive/css/infinite.css +35 -0
  16. package/dev/archive/css/parallax.css +3 -0
  17. package/dev/archive/css/plugins.css +46 -0
  18. package/dev/archive/css/progress.css +16 -0
  19. package/dev/archive/css/variable-size.css +15 -0
  20. package/dev/archive/features/Align.tsx +149 -0
  21. package/dev/archive/features/Bound.tsx +83 -0
  22. package/dev/archive/features/CrossFlicking.tsx +74 -0
  23. package/dev/archive/features/FreeScroll.tsx +66 -0
  24. package/dev/archive/features/InfiniteFlicking.tsx +192 -0
  25. package/dev/archive/features/PlaceHolderItem.tsx +36 -0
  26. package/dev/archive/features/Progress.tsx +241 -0
  27. package/dev/archive/features/PropChange.tsx +171 -0
  28. package/dev/archive/features/Snap.tsx +95 -0
  29. package/dev/archive/features/VariableSize.tsx +42 -0
  30. package/dev/archive/features/Virtual.tsx +45 -0
  31. package/dev/archive/plugins/Arrow.tsx +25 -0
  32. package/dev/archive/plugins/AutoPlay.tsx +70 -0
  33. package/dev/archive/plugins/Fade.tsx +69 -0
  34. package/dev/archive/plugins/Parallax.tsx +70 -0
  35. package/dev/archive/utils.ts +3 -0
  36. package/dev/basic-sample/App.tsx +36 -0
  37. package/dev/basic-sample/index.html +12 -0
  38. package/dev/basic-sample/main.tsx +10 -0
  39. package/dev/index.html +18 -0
  40. package/dev/plugin-check/App.tsx +341 -0
  41. package/dev/plugin-check/index.html +15 -0
  42. package/dev/plugin-check/main.tsx +6 -0
  43. package/dev/scratch/App.tsx +34 -0
  44. package/dev/scratch/index.html +15 -0
  45. package/dev/scratch/main.tsx +13 -0
  46. package/dev/tsconfig.json +12 -0
  47. package/dev/vite-env.d.ts +3 -0
  48. package/{declaration → dist}/CrossFlicking.d.ts +3 -5
  49. package/{declaration → dist}/CrossGroup.d.ts +1 -1
  50. package/{declaration → dist}/Flicking.d.ts +8 -8
  51. package/{declaration → dist}/NonStrictPanel.d.ts +1 -1
  52. package/{declaration → dist}/ReactRenderer.d.ts +1 -1
  53. package/{declaration → dist}/StrictPanel.d.ts +1 -1
  54. package/{declaration → dist}/ViewportSlot.d.ts +1 -1
  55. package/dist/flicking.cjs.js +1514 -579
  56. package/dist/flicking.cjs.js.map +1 -1
  57. package/dist/flicking.esm.js +1573 -651
  58. package/dist/flicking.esm.js.map +1 -1
  59. package/dist/flicking.js +1634 -0
  60. package/dist/flicking.js.map +1 -0
  61. package/{declaration → dist}/index.d.ts +3 -3
  62. package/{declaration → dist}/types.d.ts +1 -2
  63. package/package.json +18 -33
  64. package/src/react-flicking/CrossFlicking.tsx +28 -37
  65. package/src/react-flicking/CrossGroup.tsx +6 -8
  66. package/src/react-flicking/Flicking.tsx +81 -69
  67. package/src/react-flicking/NonStrictPanel.tsx +15 -7
  68. package/src/react-flicking/ReactElementProvider.ts +6 -4
  69. package/src/react-flicking/ReactRenderer.ts +1 -2
  70. package/src/react-flicking/StrictPanel.tsx +10 -6
  71. package/src/react-flicking/consts.ts +14 -14
  72. package/src/react-flicking/index.ts +4 -7
  73. package/src/react-flicking/index.umd.ts +1 -1
  74. package/src/react-flicking/reactive.ts +3 -3
  75. package/src/react-flicking/types.ts +17 -17
  76. package/tsconfig.json +2 -9
  77. package/vite.config.ts +38 -0
  78. package/vite.dev.config.ts +58 -0
  79. package/dist/flicking.umd.js +0 -699
  80. package/dist/flicking.umd.js.map +0 -1
  81. /package/{declaration → dist}/ReactElementProvider.d.ts +0 -0
  82. /package/{declaration → dist}/consts.d.ts +0 -0
  83. /package/{declaration → dist}/index.umd.d.ts +0 -0
  84. /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
- import * as React from "react";
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
- withFlickingMethods,
13
- sync,
14
- getRenderingPanels,
9
+ FlickingEvents,
10
+ FlickingOptions,
15
11
  getDefaultCameraTransform,
12
+ getRenderingPanels,
13
+ NormalRenderingStrategy,
16
14
  Plugin,
17
15
  range,
18
- NormalRenderingStrategy,
19
- FlickingEvents,
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 { FlickingProps } from "./types";
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 NonStrictPanel from "./NonStrictPanel";
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: void }>();
40
+ private _renderEmitter = new Component<{ render: undefined }>();
40
41
  protected _prevChildren: React.ReactElement[];
41
42
 
42
- public get reactPanels() { return this._panels.map(panel => panel.current!); }
43
- public get renderEmitter() { return this._renderEmitter; }
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: props.virtual && props.panelsPerView > 0
59
- ? new VirtualRenderingStrategy()
60
- : new NormalRenderingStrategy({
61
- providerCtor: ReactElementProvider
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
- this._viewportElement,
67
- {
68
- ...props,
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 {...attributes} className={viewportClasses.join(" ")} ref={(e?: HTMLElement) => {
177
- e && (this._viewportElement = e);
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
- { panels }
185
+ {panels}
181
186
  </Camera>
182
- { this._getViewportSlot() }
187
+ {this._getViewportSlot()}
183
188
  </Viewport>
184
189
  );
185
190
  }
186
191
 
187
- private _createPanelRefs(props: this["props"], children: Array<React.ReactElement<any>>): React.RefObject<StrictPanel | NonStrictPanel | HTMLDivElement>[] {
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 && flicking.initialized;
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 = !initialized && props.firstPanelSize
251
- ? { style: {
252
- transform: getDefaultCameraTransform(this.props.align, this.props.horizontal, this.props.firstPanelSize)
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
- .filter(child => child.type === ViewportSlot);
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
- .reduce((allChilds: React.ReactElement[], fragChild: React.ReactElement) => [...allChilds, ...this._unpackFragment(fragChild)], [] as React.ReactElement[])
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 && flicking.initialized;
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 && flicking.panels[0];
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 <StrictPanel key={idx} ref={this._panels[idx] as any}>
316
- <div
317
- data-element-index={idx}
318
- className={panelClass}
319
- style={size} />
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 && vanillaFlicking.initialized
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
- return children.map((child, idx) => <StrictPanel key={child.key!} ref={this._panels[idx] as any}>{child}</StrictPanel>);
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() { return this._elRef.current!; }
12
- public get rendered() { return !this._hide; }
13
- public get elRef() { return this._elRef; }
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
- : React.cloneElement(React.Children.only(this.props.children) as React.ReactElement, {
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() { return this._el?.nativeElement }
14
- public get rendered() { return this._el?.rendered; }
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, getFlickingAttached } from "@egjs/flicking";
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() { return this._elRef.current!; }
13
- public get rendered() { return !this._hide; }
14
- public get elRef() { return this._elRef; }
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
- SelectEvent,
7
- NeedPanelEvent,
8
- VisibleChangeEvent,
9
- HoldStartEvent,
6
+ AfterResizeEvent,
7
+ BeforeResizeEvent,
8
+ ChangedEvent,
10
9
  HoldEndEvent,
11
- MoveStartEvent,
12
- MoveEvent,
10
+ HoldStartEvent,
13
11
  MoveEndEvent,
14
- WillChangeEvent,
15
- ChangedEvent,
16
- WillRestoreEvent,
17
- RestoredEvent,
18
- ReadyEvent,
19
- BeforeResizeEvent,
20
- AfterResizeEvent,
12
+ MoveEvent,
13
+ MoveStartEvent,
14
+ NeedPanelEvent,
15
+ PanelChangeEvent,
21
16
  ReachEdgeEvent,
22
- PanelChangeEvent
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
- import Flicking from "./Flicking";
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
- import ReactFlicking from "./Flicking";
5
+
6
6
  import {
7
- SelectEvent,
8
- NeedPanelEvent,
9
- VisibleChangeEvent,
10
- HoldStartEvent,
7
+ AfterResizeEvent,
8
+ BeforeResizeEvent,
9
+ ChangedEvent,
11
10
  HoldEndEvent,
12
- MoveStartEvent,
13
- MoveEvent,
11
+ HoldStartEvent,
14
12
  MoveEndEvent,
15
- WillChangeEvent,
16
- ChangedEvent,
17
- WillRestoreEvent,
18
- RestoredEvent,
19
- ReadyEvent,
20
- BeforeResizeEvent,
21
- AfterResizeEvent,
22
- ReachEdgeEvent,
13
+ MoveEvent,
14
+ MoveStartEvent,
15
+ NeedPanelEvent,
23
16
  PanelChangeEvent,
24
17
  Plugin,
25
- Status
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
+ });