@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.
Files changed (2) hide show
  1. package/README.md +36 -69
  2. package/package.json +9 -4
package/README.md CHANGED
@@ -1,15 +1,17 @@
1
- # react-wheel-picker
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
- npm install @ncdai/react-wheel-picker
10
+ pnpm add @ncdai/react-wheel-picker
9
11
  # or
10
12
  yarn add @ncdai/react-wheel-picker
11
13
  # or
12
- pnpm add @ncdai/react-wheel-picker
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: "Option 1", value: "1" },
44
- { label: "Option 2", value: "2" },
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
- 1. Import CSS:
54
+ ### Import CSS
62
55
 
63
56
  ```tsx
64
57
  import "@ncdai/react-wheel-picker/dist/style.css";
65
58
  ```
66
59
 
67
- 2. Import components:
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
- 3. Example with TailwindCSS:
73
+ ### Example with Tailwind CSS
79
74
 
80
75
  ```tsx
81
- const createArray = (length: number, add = 0): WheelPickerOption[] =>
82
- Array.from({ length }, (_, i) => {
83
- const value = i + add;
84
- return {
85
- label: value.toString().padStart(2, "0"),
86
- value: value.toString(),
87
- };
88
- });
89
-
90
- const hourOptions = createArray(12, 1);
91
- const minuteOptions = createArray(60);
92
- const meridiemOptions: WheelPickerOption[] = [
93
- { label: "AM", value: "AM" },
94
- { label: "PM", value: "PM" },
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-muted-foreground",
99
- highlightWrapper: "bg-accent text-accent-foreground",
96
+ optionItem: "text-zinc-400",
97
+ highlightWrapper: "bg-zinc-100 text-zinc-950",
100
98
  };
101
99
 
102
- export function TimePicker() {
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
- <div className="container mx-auto space-y-4 p-4">
109
- <div className="mx-auto flex h-8 max-w-56 items-center justify-center text-lg font-semibold">
110
- {hour.padStart(2, "0")}:{minute.padStart(2, "0")} {meridiem}
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.1",
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
- "lint": "eslint . --ext .ts,.tsx --ignore-pattern 'website/**'",
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
+ }