persian-date-kit 0.0.10 → 0.0.11
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 +82 -53
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -135,64 +135,82 @@ All values you receive in `onChange` are **Gregorian** (`Date | null`). Jalali i
|
|
|
135
135
|
|
|
136
136
|
### `PersianDatePicker`
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
- **`classes?`**: `PersianDatePickerClasses` — per-slot class overrides
|
|
138
|
+
| Prop | Type | Default | Description |
|
|
139
|
+
|---|---|---:|---|
|
|
140
|
+
| `value` | `Date \| null` | — | Controlled value (**Gregorian**) |
|
|
141
|
+
| `onChange` | `(date: Date \| null) => void` | — | Called with the next value (**Gregorian**) |
|
|
142
|
+
| `placeholder?` | `string` | `undefined` | Input placeholder (popover mode) |
|
|
143
|
+
| `classes?` | `PersianDatePickerClasses` | `undefined` | Per-slot class overrides (see **Classes table** below) |
|
|
145
144
|
|
|
146
145
|
### `PersianDateRangePicker`
|
|
147
146
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
147
|
+
| Prop | Type | Default | Description |
|
|
148
|
+
|---|---|---:|---|
|
|
149
|
+
| `value` | `{ start: Date \| null; end: Date \| null }` | — | Controlled range (**Gregorian**) |
|
|
150
|
+
| `onChange` | `(range: { start: Date \| null; end: Date \| null }) => void` | — | Called with the next range (**Gregorian**) |
|
|
151
|
+
| `inputVariant?` | `'two' \| 'single'` | `'two'` | Two inputs (start/end) or a single combined input |
|
|
152
|
+
| `placeholder?` | `string` | `undefined` | Placeholder for **single** input mode |
|
|
153
|
+
| `rangeSeparator?` | `string` | `" - "` | Separator used in single-input mode (`start{sep}end`) |
|
|
154
|
+
| `placeholderStart?` | `string` | `undefined` | Placeholder for start input (two-input mode) |
|
|
155
|
+
| `placeholderEnd?` | `string` | `undefined` | Placeholder for end input (two-input mode) |
|
|
156
|
+
| `classes?` | `PersianDateRangePickerClasses` | `undefined` | Per-slot class overrides (see **Classes table** below) |
|
|
158
157
|
|
|
159
158
|
### Shared props (`BasePickerProps`)
|
|
160
159
|
|
|
161
160
|
These props exist on both pickers:
|
|
162
161
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
162
|
+
| Prop | Type | Default | Description |
|
|
163
|
+
|---|---|---:|---|
|
|
164
|
+
| `minDate?` | `Date` | `undefined` | Minimum selectable day (**Gregorian**) |
|
|
165
|
+
| `maxDate?` | `Date` | `undefined` | Maximum selectable day (**Gregorian**) |
|
|
166
|
+
| `disabled?` | `boolean` | `false` | Disable interactions |
|
|
167
|
+
| `mode?` | `'popover' \| 'inline'` | `'popover'` | `inline` shows calendar without input |
|
|
168
|
+
| `open?` | `boolean` | `undefined` | Control popover open state (popover mode) |
|
|
169
|
+
| `onOpenChange?` | `(open: boolean) => void` | `undefined` | Notified when open state changes (popover mode) |
|
|
170
|
+
| `popover?` | `PopoverConfig` | `{ portal: true }` | Popover positioning options (popover mode) |
|
|
171
|
+
| `formatValue?` | `(date: Date) => string` | built-in | Format input display (default: numeric Jalali `YYYY/MM/DD`) |
|
|
172
|
+
| `parseValue?` | `(text: string) => Date \| null` | built-in | Parse user text into **Gregorian** (default: numeric Jalali `YYYY/MM/DD`) |
|
|
173
|
+
| `weekdays?` | `string[]` | numeric | 7 weekday labels; if omitted, numeric labels are shown |
|
|
174
|
+
| `monthLabels?` | `string[]` | numeric | 12 month labels (index 0 => month 1); if omitted, month numbers |
|
|
175
|
+
| `renderMonthLabel?` | `(jy: number, jm: number) => React.ReactNode` | `undefined` | Custom header label renderer |
|
|
176
|
+
| `prevIcon?` | `React.ReactNode` | `undefined` | Custom previous icon |
|
|
177
|
+
| `nextIcon?` | `React.ReactNode` | `undefined` | Custom next icon |
|
|
178
|
+
| `className?` | `string` | `undefined` | Extra class on the root element |
|
|
175
179
|
|
|
176
180
|
### `PopoverConfig`
|
|
177
181
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
| Prop | Type | Default | Description |
|
|
183
|
+
|---|---|---:|---|
|
|
184
|
+
| `portal?` | `boolean` | `true` | Render popover in a portal (recommended for **modals/overflow** containers) |
|
|
185
|
+
| `gutter?` | `number` | `8` | Gap between anchor and popover |
|
|
186
|
+
| `padding?` | `number` | `8` | Minimum distance from viewport edges (clamping) |
|
|
187
|
+
| `strategy?` | `'fixed' \| 'absolute'` | `'fixed'` | Positioning strategy |
|
|
188
|
+
| `placements?` | `Array<'bottom' \| 'top' \| 'left' \| 'right'>` | `['bottom','top','left','right']` | Preferred placements order (auto-flip chooses best fit) |
|
|
189
|
+
| `align?` | `'start' \| 'center' \| 'end'` | `'end'` | Cross-axis alignment |
|
|
184
190
|
|
|
185
191
|
### Styling slots (`classes`)
|
|
186
192
|
|
|
187
|
-
You can override
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
You can override class names per slot:
|
|
194
|
+
|
|
195
|
+
| Slot | Used for |
|
|
196
|
+
|---|---|
|
|
197
|
+
| `root` | Root wrapper |
|
|
198
|
+
| `input` | Input element |
|
|
199
|
+
| `button` | Clear button (single picker) |
|
|
200
|
+
| `popover` | Popover container |
|
|
201
|
+
| `header` | Calendar header |
|
|
202
|
+
| `navButton` | Navigation buttons (prev/next) |
|
|
203
|
+
| `monthLabel` | Header month/year label button |
|
|
204
|
+
| `grid` | Grid container |
|
|
205
|
+
| `weekday` | Weekday header cell |
|
|
206
|
+
| `day` | Day button |
|
|
207
|
+
| `dayOutside` | Day that belongs to adjacent month |
|
|
208
|
+
| `dayDisabled` | Disabled day |
|
|
209
|
+
| `dayToday` | Today day |
|
|
210
|
+
| `daySelected` | **Single picker** selected day |
|
|
211
|
+
| `dayInRange` | **Range picker** day inside range |
|
|
212
|
+
| `dayRangeStart` | **Range picker** range start day |
|
|
213
|
+
| `dayRangeEnd` | **Range picker** range end day |
|
|
196
214
|
|
|
197
215
|
## Styling / Theming
|
|
198
216
|
|
|
@@ -208,15 +226,17 @@ The default CSS is built around **CSS variables**, so it’s easy to theme.
|
|
|
208
226
|
|
|
209
227
|
These variables control most of the look:
|
|
210
228
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
229
|
+
| CSS variable | Purpose | Default (light) |
|
|
230
|
+
|---|---|---|
|
|
231
|
+
| `--dvx-pdp-bg` | Surface background | `#ffffff` |
|
|
232
|
+
| `--dvx-pdp-fg` | Main text | `#111827` |
|
|
233
|
+
| `--dvx-pdp-muted` | Muted text | `#6b7280` |
|
|
234
|
+
| `--dvx-pdp-border` | Borders | `#e5e7eb` |
|
|
235
|
+
| `--dvx-pdp-shadow` | Popover shadow | `0 10px 20px rgba(0, 0, 0, 0.08)` |
|
|
236
|
+
| `--dvx-pdp-accent` | Accent / selected | `#2563eb` |
|
|
237
|
+
| `--dvx-pdp-accentFg` | Text on accent | `#ffffff` |
|
|
238
|
+
| `--dvx-pdp-ring` | Focus ring | `rgba(37, 99, 235, 0.3)` |
|
|
239
|
+
| `--dvx-pdp-dayHover` | Hover background | `rgba(37, 99, 235, 0.08)` |
|
|
220
240
|
|
|
221
241
|
Example:
|
|
222
242
|
|
|
@@ -249,6 +269,15 @@ If you **don’t** import `styles.css`, you should provide your own CSS for the
|
|
|
249
269
|
component class hooks (ex: `.dvx-pdp`, `.dvx-pdp__input`, `.dvx-pdp__day`, ...),
|
|
250
270
|
or rely entirely on `classes` and your own styles.
|
|
251
271
|
|
|
272
|
+
### Styling approaches (summary table)
|
|
273
|
+
|
|
274
|
+
| Approach | What you do | Best for |
|
|
275
|
+
|---|---|---|
|
|
276
|
+
| Default styles | Import `persian-date-kit/styles.css` | Fastest start, good baseline |
|
|
277
|
+
| Theme variables | Override `--dvx-pdp-*` in your CSS | Brand theming without rewriting CSS |
|
|
278
|
+
| `classes` overrides | Pass Tailwind/utility classes via `classes` | Integrate into your design system |
|
|
279
|
+
| Full custom | Don’t import `styles.css`; write your own | Complete visual control |
|
|
280
|
+
|
|
252
281
|
## Development (this repo)
|
|
253
282
|
|
|
254
283
|
Clone the repository:
|