@ehmetlabs/webf-react-carousel-slider 1.0.0 → 1.0.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 (2) hide show
  1. package/README.md +157 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,157 @@
1
+ # WebF React Carousel Slider
2
+
3
+ React wrapper for the WebF `<carousel-slider>` custom element. It is intended for WebF environments where the Flutter custom element is registered.
4
+
5
+ ## Requirements
6
+
7
+ - React >= 16.8
8
+ - react-dom >= 16.8
9
+ - @openwebf/react-core-ui ^0.24.2
10
+ - Flutter-side registration via `webf_carousel_slider` (see `native_uis/webf_carousel_slider`)
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @ehmetlabs/webf-react-carousel-slider
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```tsx
21
+ import React, { useRef } from 'react';
22
+ import {
23
+ CarouselSlider,
24
+ CarouselSliderElement,
25
+ Axis,
26
+ Curve,
27
+ } from '@ehmetlabs/webf-react-carousel-slider';
28
+
29
+ export function App() {
30
+ const ref = useRef<CarouselSliderElement>(null);
31
+
32
+ return (
33
+ <CarouselSlider
34
+ ref={ref}
35
+ autoplay
36
+ autoplayInterval={4}
37
+ aspectRatio={16 / 9}
38
+ viewportFraction={0.8}
39
+ enlargeCenterPage
40
+ scrollDirection={Axis.horizontal}
41
+ autoPlayCurve={Curve.fastOutSlowIn}
42
+ onChange={(event) => {
43
+ console.log(event.detail.index, event.detail.reason);
44
+ }}
45
+ >
46
+ <img src="https://example.com/1.jpg" />
47
+ <img src="https://example.com/2.jpg" />
48
+ </CarouselSlider>
49
+ );
50
+ }
51
+ ```
52
+
53
+ ## Options JSON (batch config + items)
54
+
55
+ If you prefer a single JSON string, use `options`. Keys are camelCase.
56
+
57
+ ```tsx
58
+ <CarouselSlider
59
+ options={JSON.stringify({
60
+ autoplay: true,
61
+ autoplayInterval: 3,
62
+ items: [
63
+ { id: 1, url: 'https://example.com/1.jpg' },
64
+ { id: 2, url: 'https://example.com/2.jpg' },
65
+ ],
66
+ })}
67
+ onItemclick={(event) => {
68
+ console.log('Clicked:', event.detail.id);
69
+ }}
70
+ />;
71
+ ```
72
+
73
+ Notes:
74
+
75
+ - `items` is used only when there are no children.
76
+ - Invalid JSON triggers an `error` event on the underlying element.
77
+
78
+ ## Props
79
+
80
+ All props map to kebab-case attributes on `<carousel-slider>` unless noted.
81
+
82
+ | Prop | Type | Default | Attribute |
83
+ | --- | --- | --- | --- |
84
+ | `currentIndex` | number | 0 | `current-index` |
85
+ | `options` | string (JSON) | - | `options` |
86
+ | `height` | string | - | `height` |
87
+ | `aspectRatio` | number | 16/9 | `aspect-ratio` |
88
+ | `viewportFraction` | number | 0.8 | `viewport-fraction` |
89
+ | `initialPage` | number | 0 | `initial-page` |
90
+ | `padEnds` | boolean | true | `pad-ends` |
91
+ | `disableCenter` | boolean | false | `disable-center` |
92
+ | `enableInfiniteScroll` | boolean | true | `enable-infinite-scroll` |
93
+ | `animateToClosest` | boolean | true | `animate-to-closest` |
94
+ | `reverse` | boolean | false | `reverse` |
95
+ | `scrollDirection` | Axis | Axis.horizontal | `scroll-direction` |
96
+ | `pageSnapping` | boolean | true | `page-snapping` |
97
+ | `scrollPhysics` | string | - | `scroll-physics` |
98
+ | `autoplay` | boolean | false | `autoplay` |
99
+ | `autoplayInterval` | number (seconds) | 4.0 | `autoplay-interval` |
100
+ | `autoPlayAnimationDuration` | number (ms) | 800 | `auto-play-animation-duration` |
101
+ | `autoPlayCurve` | Curve | Curves.fastOutSlowIn | `auto-play-curve` |
102
+ | `pauseAutoPlayOnTouch` | boolean | true | `pause-auto-play-on-touch` |
103
+ | `pauseAutoPlayOnManualNavigate` | boolean | true | `pause-auto-play-on-manual-navigate` |
104
+ | `pauseAutoPlayInFiniteScroll` | boolean | false | `pause-auto-play-in-finite-scroll` |
105
+ | `enlargeCenterPage` | boolean | false | `enlarge-center-page` |
106
+ | `enlargeStrategy` | CenterPageEnlargeStrategy | scale | `enlarge-strategy` |
107
+ | `enlargeFactor` | number | 0.3 | `enlarge-factor` |
108
+ | `id` | string | - | `id` |
109
+ | `className` | string | - | `class` |
110
+ | `style` | React.CSSProperties | - | - |
111
+ | `children` | React.ReactNode | - | - |
112
+
113
+ Value notes:
114
+
115
+ - `scrollDirection`: use `Axis.horizontal` or `Axis.vertical` (strings like `horizontal` are also accepted).
116
+ - `autoPlayCurve`: use `Curve` enum values such as `Curves.fastOutSlowIn`.
117
+ - `enlargeStrategy`: `CenterPageEnlargeStrategy.scale`, `height`, or `zoom`.
118
+ - `scrollPhysics`: `clamping`, `bouncing`, or `fixed`.
119
+
120
+ ### Event props
121
+
122
+ | Prop | DOM event | Detail |
123
+ | --- | --- | --- |
124
+ | `onChange` | `change` | `{ index, reason }` |
125
+ | `onSlidestart` | `slidestart` | - |
126
+ | `onSlideend` | `slideend` | - |
127
+ | `onPageanimationstart` | `pageanimationstart` | `{ from, to }` |
128
+ | `onPageanimationend` | `pageanimationend` | `{ index }` |
129
+ | `onAutoplaypause` | `autoplaypause` | - |
130
+ | `onAutoplayresume` | `autoplayresume` | - |
131
+ | `onScrolled` | `scrolled` | `number` |
132
+ | `onItemclick` | `itemclick` | `{ id }` |
133
+
134
+ If you need events not exposed as props (for example, `error`), attach a listener via `ref.current?.addEventListener(...)`.
135
+
136
+ ## Ref methods
137
+
138
+ Use a ref to call imperative APIs on the element:
139
+
140
+ - `next()` - next page (fixed 300ms ease animation)
141
+ - `previous()` - previous page (fixed 300ms ease animation)
142
+ - `jumpToPage(page: number)` - jump without animation
143
+ - `pause()` / `resume()` - pause or resume autoplay
144
+ - `startAutoPlay()` / `stopAutoPlay()` - explicit autoplay control
145
+
146
+ ## Build
147
+
148
+ ```bash
149
+ npm run build
150
+ ```
151
+
152
+ ## Generated files
153
+
154
+ The following files are generated. Do not edit them manually:
155
+
156
+ - `src/index.ts`
157
+ - `src/types.ts`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ehmetlabs/webf-react-carousel-slider",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "WebF Custom Element wrapper for carousel_slider_plus. Provides hybrid UI carousel component with Flutter performance and JavaScript API.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",