persian-date-kit 1.1.0 → 1.1.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.
- package/README.md +70 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -107,6 +107,56 @@ export function RangeExample() {
|
|
|
107
107
|
}
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
+
### Date picker with time
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
import { useState } from 'react'
|
|
114
|
+
import { PersianDatePicker } from 'persian-date-kit'
|
|
115
|
+
|
|
116
|
+
export function DateTimeExample() {
|
|
117
|
+
const [value, setValue] = useState<Date | null>(new Date())
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<PersianDatePicker
|
|
121
|
+
value={value}
|
|
122
|
+
onChange={setValue}
|
|
123
|
+
placeholder="YYYY/MM/DD HH:mm"
|
|
124
|
+
timePicker={{
|
|
125
|
+
enabled: true,
|
|
126
|
+
format: 'HH:mm',
|
|
127
|
+
defaultTime: { hour: 12, minute: 0 },
|
|
128
|
+
hourStep: 1,
|
|
129
|
+
minuteStep: 5,
|
|
130
|
+
}}
|
|
131
|
+
/>
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Or simply enable with defaults:
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
<PersianDatePicker
|
|
140
|
+
value={value}
|
|
141
|
+
onChange={setValue}
|
|
142
|
+
timePicker={true} // Uses default time 00:00
|
|
143
|
+
/>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
With seconds:
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
<PersianDatePicker
|
|
150
|
+
value={value}
|
|
151
|
+
onChange={setValue}
|
|
152
|
+
timePicker={{
|
|
153
|
+
enabled: true,
|
|
154
|
+
format: 'HH:mm:ss',
|
|
155
|
+
showSeconds: true,
|
|
156
|
+
}}
|
|
157
|
+
/>
|
|
158
|
+
```
|
|
159
|
+
|
|
110
160
|
## React Hook Form (optional adapter)
|
|
111
161
|
The core package has **no required** form dependency.
|
|
112
162
|
If you want React Hook Form integration, import from the subpath:
|
|
@@ -144,6 +194,7 @@ All values you receive in `onChange` are **Gregorian** (`Date | null`). Jalali i
|
|
|
144
194
|
| `value` | `Date \| null` | — | Controlled value (**Gregorian**) |
|
|
145
195
|
| `onChange` | `(date: Date \| null) => void` | — | Called with the next value (**Gregorian**) |
|
|
146
196
|
| `placeholder?` | `string` | `undefined` | Input placeholder (popover mode) |
|
|
197
|
+
| `timePicker?` | `TimePickerConfig \| boolean` | `undefined` | Enable time picker (see **TimePickerConfig** below) |
|
|
147
198
|
| `classes?` | `PersianDatePickerClasses` | `undefined` | Per-slot class overrides (see **Classes table** below) |
|
|
148
199
|
|
|
149
200
|
### `PersianDateRangePicker`
|
|
@@ -182,6 +233,20 @@ These props exist on both pickers:
|
|
|
182
233
|
| `nextIcon?` | `React.ReactNode` | `undefined` | Custom next icon |
|
|
183
234
|
| `className?` | `string` | `undefined` | Extra class on the root element |
|
|
184
235
|
|
|
236
|
+
### `TimePickerConfig`
|
|
237
|
+
|
|
238
|
+
| Prop | Type | Default | Description |
|
|
239
|
+
|---|---|---:|---|
|
|
240
|
+
| `enabled` | `boolean` | — | Enable time picker |
|
|
241
|
+
| `format?` | `'HH:mm' \| 'HH:mm:ss'` | `'HH:mm'` | Time format |
|
|
242
|
+
| `defaultTime?` | `{ hour: number; minute: number; second?: number }` | `undefined` | Default time when value is null (uses current time if not provided) |
|
|
243
|
+
| `showSeconds?` | `boolean` | `false` | Show seconds stepper (requires `format: 'HH:mm:ss'`) |
|
|
244
|
+
| `hourStep?` | `number` | `1` | Step size for hour increment/decrement |
|
|
245
|
+
| `minuteStep?` | `number` | `1` | Step size for minute increment/decrement |
|
|
246
|
+
| `secondStep?` | `number` | `1` | Step size for second increment/decrement |
|
|
247
|
+
|
|
248
|
+
**Note:** You can also pass `timePicker={true}` as a shorthand to enable with defaults.
|
|
249
|
+
|
|
185
250
|
### `PopoverConfig`
|
|
186
251
|
|
|
187
252
|
| Prop | Type | Default | Description |
|
|
@@ -216,6 +281,11 @@ You can override class names per slot:
|
|
|
216
281
|
| `dayInRange` | **Range picker** day inside range |
|
|
217
282
|
| `dayRangeStart` | **Range picker** range start day |
|
|
218
283
|
| `dayRangeEnd` | **Range picker** range end day |
|
|
284
|
+
| `timePicker` | Time picker container |
|
|
285
|
+
| `timeStepper` | Time stepper wrapper (hour/minute/second) |
|
|
286
|
+
| `timeStepperButton` | Stepper increment/decrement buttons |
|
|
287
|
+
| `timeStepperInput` | Time input field |
|
|
288
|
+
| `timeSeparator` | Time separator (`:`) |
|
|
219
289
|
|
|
220
290
|
## Styling / Theming
|
|
221
291
|
|