@ncdai/react-wheel-picker 1.0.2 → 1.0.3
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/README.md +11 -90
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
iOS-like wheel picker for React with smooth inertia scrolling and infinite loop support.
|
|
4
4
|
|
|
5
|
-
Check out the live demo:
|
|
5
|
+
Check out the live demo: https://chanhdai.com/blog/react-wheel-picker
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
To start using the library, install it in your project:
|
|
8
10
|
|
|
9
11
|
```bash
|
|
10
12
|
pnpm add @ncdai/react-wheel-picker
|
|
@@ -12,54 +14,19 @@ pnpm add @ncdai/react-wheel-picker
|
|
|
12
14
|
yarn add @ncdai/react-wheel-picker
|
|
13
15
|
# or
|
|
14
16
|
npm install @ncdai/react-wheel-picker
|
|
17
|
+
# or
|
|
18
|
+
bun add @ncdai/react-wheel-picker
|
|
15
19
|
```
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
The wheel picker consists of two main components:
|
|
20
|
-
|
|
21
|
-
### WheelPickerWrapper
|
|
22
|
-
|
|
23
|
-
The wrapper component that contains one or more wheel pickers. It provides the container structure and handles the layout of multiple wheels.
|
|
24
|
-
|
|
25
|
-
```tsx
|
|
26
|
-
<WheelPickerWrapper>
|
|
27
|
-
<WheelPicker />
|
|
28
|
-
<WheelPicker />
|
|
29
|
-
<WheelPicker />
|
|
30
|
-
</WheelPickerWrapper>
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
### WheelPicker
|
|
34
|
-
|
|
35
|
-
The core component that renders a single wheel of options. Each wheel picker consists of:
|
|
36
|
-
|
|
37
|
-
- A container with a 3D perspective
|
|
38
|
-
- A scrollable list of options
|
|
39
|
-
- A highlight area that indicates the selected option
|
|
40
|
-
- A mask that creates the fade effect at the top and bottom
|
|
41
|
-
|
|
42
|
-
```tsx
|
|
43
|
-
<WheelPicker
|
|
44
|
-
options={[
|
|
45
|
-
{ label: "React", value: "react" },
|
|
46
|
-
{ label: "Vue", value: "vue" },
|
|
47
|
-
{ label: "Angular", value: "angular" },
|
|
48
|
-
]}
|
|
49
|
-
/>
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Usage
|
|
53
|
-
|
|
54
|
-
### Import CSS
|
|
21
|
+
Add the core CSS to your app's entry point (e.g., `src/app/layout.tsx`, `src/main.tsx`, or `src/index.tsx`):
|
|
55
22
|
|
|
56
23
|
```tsx
|
|
57
24
|
import "@ncdai/react-wheel-picker/dist/style.css";
|
|
58
25
|
```
|
|
59
26
|
|
|
60
|
-
This CSS
|
|
27
|
+
> This CSS includes only basic layout. Use classNames to customize visuals (see below).
|
|
61
28
|
|
|
62
|
-
|
|
29
|
+
Use the component in your app:
|
|
63
30
|
|
|
64
31
|
```tsx
|
|
65
32
|
import {
|
|
@@ -68,11 +35,7 @@ import {
|
|
|
68
35
|
type WheelPickerOption,
|
|
69
36
|
type WheelPickerClassNames,
|
|
70
37
|
} from "@ncdai/react-wheel-picker";
|
|
71
|
-
```
|
|
72
38
|
|
|
73
|
-
### Example with Tailwind CSS
|
|
74
|
-
|
|
75
|
-
```tsx
|
|
76
39
|
const options: WheelPickerOption[] = [
|
|
77
40
|
{
|
|
78
41
|
label: "React",
|
|
@@ -106,48 +69,6 @@ export function WheelPickerDemo() {
|
|
|
106
69
|
}
|
|
107
70
|
```
|
|
108
71
|
|
|
109
|
-
##
|
|
110
|
-
|
|
111
|
-
### WheelPicker
|
|
112
|
-
|
|
113
|
-
Props for the WheelPicker component:
|
|
114
|
-
|
|
115
|
-
| Prop | Type | Default | Description |
|
|
116
|
-
| ----------------- | ------------------------- | ---------- | -------------------------------------------------------------- |
|
|
117
|
-
| `options` | `WheelPickerOption[]` | (required) | Array of options to display in the wheel |
|
|
118
|
-
| `value` | `string` | - | Current value of the picker (controlled mode) |
|
|
119
|
-
| `defaultValue` | `string` | - | Default value of the picker (uncontrolled mode) |
|
|
120
|
-
| `onValueChange` | `(value: string) => void` | - | Callback fired when the selected value changes |
|
|
121
|
-
| `infinite` | `boolean` | `false` | Enable infinite scrolling |
|
|
122
|
-
| `visibleCount` | `number` | `20` | Number of options visible on the wheel (must be multiple of 4) |
|
|
123
|
-
| `dragSensitivity` | `number` | `3` | Sensitivity of the drag interaction (higher = more sensitive) |
|
|
124
|
-
| `classNames` | `WheelPickerClassNames` | - | Custom class names for styling |
|
|
125
|
-
|
|
126
|
-
### WheelPickerWrapper
|
|
72
|
+
## Documentation
|
|
127
73
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
| Prop | Type | Default | Description |
|
|
131
|
-
| ----------- | ----------------- | ---------- | -------------------------- |
|
|
132
|
-
| `className` | `string` | - | CSS class name for wrapper |
|
|
133
|
-
| `children` | `React.ReactNode` | (required) | WheelPicker components |
|
|
134
|
-
|
|
135
|
-
### Types
|
|
136
|
-
|
|
137
|
-
```tsx
|
|
138
|
-
type WheelPickerOption = {
|
|
139
|
-
/** Value that will be returned when this option is selected */
|
|
140
|
-
value: string;
|
|
141
|
-
/** Text label displayed for this option */
|
|
142
|
-
label: string;
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
type WheelPickerClassNames = {
|
|
146
|
-
/** Class name for individual option items */
|
|
147
|
-
optionItem?: string;
|
|
148
|
-
/** Class name for the wrapper of the highlighted area */
|
|
149
|
-
highlightWrapper?: string;
|
|
150
|
-
/** Class name for the highlighted item */
|
|
151
|
-
highlightItem?: string;
|
|
152
|
-
};
|
|
153
|
-
```
|
|
74
|
+
Find the full API reference in the [documentation](https://react-wheel-picker.chanhdai.com/docs/getting-started).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ncdai/react-wheel-picker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "iOS-like wheel picker for React with smooth inertia scrolling and infinite loop support.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
"dev:website": "turbo run dev --filter=website...",
|
|
30
30
|
"prettier:check": "prettier --check .",
|
|
31
31
|
"format": "prettier --write .",
|
|
32
|
+
"registry:internal:build": "pnpm --filter=website registry:internal:build",
|
|
33
|
+
"registry:build": "pnpm --filter=website registry:build",
|
|
32
34
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
33
35
|
},
|
|
34
36
|
"keywords": [
|