@ncdai/react-wheel-picker 1.0.1 → 1.0.2
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 +36 -69
- package/package.json +9 -4
package/README.md
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# React Wheel Picker
|
|
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: [react-wheel-picker.chanhdai.com](https://react-wheel-picker.chanhdai.com)
|
|
6
|
+
|
|
5
7
|
## Installation
|
|
6
8
|
|
|
7
9
|
```bash
|
|
8
|
-
|
|
10
|
+
pnpm add @ncdai/react-wheel-picker
|
|
9
11
|
# or
|
|
10
12
|
yarn add @ncdai/react-wheel-picker
|
|
11
13
|
# or
|
|
12
|
-
|
|
14
|
+
npm install @ncdai/react-wheel-picker
|
|
13
15
|
```
|
|
14
16
|
|
|
15
17
|
## Anatomy
|
|
@@ -40,31 +42,24 @@ The core component that renders a single wheel of options. Each wheel picker con
|
|
|
40
42
|
```tsx
|
|
41
43
|
<WheelPicker
|
|
42
44
|
options={[
|
|
43
|
-
{ label: "
|
|
44
|
-
{ label: "
|
|
45
|
+
{ label: "React", value: "react" },
|
|
46
|
+
{ label: "Vue", value: "vue" },
|
|
47
|
+
{ label: "Angular", value: "angular" },
|
|
45
48
|
]}
|
|
46
|
-
value="1"
|
|
47
|
-
onValueChange={(value) => {}}
|
|
48
49
|
/>
|
|
49
50
|
```
|
|
50
51
|
|
|
51
|
-
> **Styling:** The component is unstyled by default. You can customize the appearance using the `classNames` prop to style:
|
|
52
|
-
>
|
|
53
|
-
> - Individual options (`optionItem`)
|
|
54
|
-
> - The highlight area (`highlightWrapper`)
|
|
55
|
-
> - The highlighted option (`highlightItem`)
|
|
56
|
-
>
|
|
57
|
-
> Check out the TailwindCSS example below to see how to style the component.
|
|
58
|
-
|
|
59
52
|
## Usage
|
|
60
53
|
|
|
61
|
-
|
|
54
|
+
### Import CSS
|
|
62
55
|
|
|
63
56
|
```tsx
|
|
64
57
|
import "@ncdai/react-wheel-picker/dist/style.css";
|
|
65
58
|
```
|
|
66
59
|
|
|
67
|
-
|
|
60
|
+
This CSS file includes only the core layout for the wheel picker. For custom visuals, use the `classNames` prop as shown in the Tailwind CSS example below.
|
|
61
|
+
|
|
62
|
+
### Import components
|
|
68
63
|
|
|
69
64
|
```tsx
|
|
70
65
|
import {
|
|
@@ -75,70 +70,42 @@ import {
|
|
|
75
70
|
} from "@ncdai/react-wheel-picker";
|
|
76
71
|
```
|
|
77
72
|
|
|
78
|
-
|
|
73
|
+
### Example with Tailwind CSS
|
|
79
74
|
|
|
80
75
|
```tsx
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
{
|
|
76
|
+
const options: WheelPickerOption[] = [
|
|
77
|
+
{
|
|
78
|
+
label: "React",
|
|
79
|
+
value: "react",
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
label: "Vue",
|
|
83
|
+
value: "vue",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
label: "Angular",
|
|
87
|
+
value: "angular",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
label: "Svelte",
|
|
91
|
+
value: "svelte",
|
|
92
|
+
},
|
|
95
93
|
];
|
|
96
94
|
|
|
97
95
|
const classNames: WheelPickerClassNames = {
|
|
98
|
-
optionItem: "text-
|
|
99
|
-
highlightWrapper: "bg-
|
|
96
|
+
optionItem: "text-zinc-400",
|
|
97
|
+
highlightWrapper: "bg-zinc-100 text-zinc-950",
|
|
100
98
|
};
|
|
101
99
|
|
|
102
|
-
export function
|
|
103
|
-
const [hour, setHour] = useState("8");
|
|
104
|
-
const [minute, setMinute] = useState("30");
|
|
105
|
-
const [meridiem, setMeridiem] = useState("PM");
|
|
106
|
-
|
|
100
|
+
export function WheelPickerDemo() {
|
|
107
101
|
return (
|
|
108
|
-
<
|
|
109
|
-
<
|
|
110
|
-
|
|
111
|
-
</div>
|
|
112
|
-
|
|
113
|
-
<WheelPickerWrapper className="mx-auto max-w-56 rounded-xl border bg-background">
|
|
114
|
-
<WheelPicker
|
|
115
|
-
options={hourOptions}
|
|
116
|
-
value={hour}
|
|
117
|
-
onValueChange={setHour}
|
|
118
|
-
infinite
|
|
119
|
-
classNames={classNames}
|
|
120
|
-
/>
|
|
121
|
-
<WheelPicker
|
|
122
|
-
options={minuteOptions}
|
|
123
|
-
value={minute}
|
|
124
|
-
onValueChange={setMinute}
|
|
125
|
-
infinite
|
|
126
|
-
classNames={classNames}
|
|
127
|
-
/>
|
|
128
|
-
<WheelPicker
|
|
129
|
-
options={meridiemOptions}
|
|
130
|
-
value={meridiem}
|
|
131
|
-
onValueChange={setMeridiem}
|
|
132
|
-
classNames={classNames}
|
|
133
|
-
/>
|
|
134
|
-
</WheelPickerWrapper>
|
|
135
|
-
</div>
|
|
102
|
+
<WheelPickerWrapper className="max-w-56 rounded-md border border-zinc-200 bg-white shadow-xs">
|
|
103
|
+
<WheelPicker options={options} classNames={classNames} />
|
|
104
|
+
</WheelPickerWrapper>
|
|
136
105
|
);
|
|
137
106
|
}
|
|
138
107
|
```
|
|
139
108
|
|
|
140
|
-
> View the complete source code at [https://github.com/ncdai/react-wheel-picker/tree/main/website](https://github.com/ncdai/react-wheel-picker/tree/main/website)
|
|
141
|
-
|
|
142
109
|
## API
|
|
143
110
|
|
|
144
111
|
### WheelPicker
|
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.2",
|
|
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",
|
|
@@ -27,11 +27,16 @@
|
|
|
27
27
|
"type-check": "tsc --noEmit",
|
|
28
28
|
"copy-assets": "cp -r ./src/style.css ./dist/style.css",
|
|
29
29
|
"dev:website": "turbo run dev --filter=website...",
|
|
30
|
-
"
|
|
30
|
+
"prettier:check": "prettier --check .",
|
|
31
31
|
"format": "prettier --write .",
|
|
32
32
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
33
33
|
},
|
|
34
|
-
"keywords": [
|
|
34
|
+
"keywords": [
|
|
35
|
+
"react",
|
|
36
|
+
"wheel picker",
|
|
37
|
+
"wheel",
|
|
38
|
+
"picker"
|
|
39
|
+
],
|
|
35
40
|
"author": "Nguyen Chanh Dai <dai@chanhdai.com>",
|
|
36
41
|
"license": "MIT",
|
|
37
42
|
"homepage": "https://react-wheel-picker.chanhdai.com",
|
|
@@ -55,4 +60,4 @@
|
|
|
55
60
|
"peerDependencies": {
|
|
56
61
|
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0.0 || ^19.0.0-rc"
|
|
57
62
|
}
|
|
58
|
-
}
|
|
63
|
+
}
|