persian-date-kit 0.0.9 → 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.
Files changed (2) hide show
  1. package/README.md +144 -10
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -129,20 +129,154 @@ export function RHFExample() {
129
129
  }
130
130
  ```
131
131
 
132
- ## API notes
132
+ ## Props reference
133
+
134
+ All values you receive in `onChange` are **Gregorian** (`Date | null`). Jalali is only used for display/input.
133
135
 
134
136
  ### `PersianDatePicker`
135
- - **`value`**: `Date | null`
136
- - **`onChange`**: `(date: Date | null) => void`
137
- - **`minDate` / `maxDate`**: limit selectable dates (Gregorian dates)
138
- - **`mode`**: `'popover' | 'inline'`
139
- - **`monthLabels`**: 12 strings (no hardcoded locale in the library)
140
- - **`weekdays`**: 7 strings
137
+
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) |
141
144
 
142
145
  ### `PersianDateRangePicker`
143
- - **`value`**: `{ start: Date | null; end: Date | null }`
144
- - **`onChange`**: `(range) => void`
145
- - **`inputVariant`**: `'two' | 'single'`
146
+
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) |
157
+
158
+ ### Shared props (`BasePickerProps`)
159
+
160
+ These props exist on both pickers:
161
+
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 |
179
+
180
+ ### `PopoverConfig`
181
+
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 |
190
+
191
+ ### Styling slots (`classes`)
192
+
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 |
214
+
215
+ ## Styling / Theming
216
+
217
+ ### 1) Use the default styles (recommended)
218
+
219
+ ```ts
220
+ import 'persian-date-kit/styles.css'
221
+ ```
222
+
223
+ The default CSS is built around **CSS variables**, so it’s easy to theme.
224
+
225
+ ### 2) Theme via CSS variables (quickest)
226
+
227
+ These variables control most of the look:
228
+
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)` |
240
+
241
+ Example:
242
+
243
+ ```css
244
+ :root {
245
+ --dvx-pdp-accent: #16a34a;
246
+ --dvx-pdp-ring: rgba(22, 163, 74, 0.25);
247
+ }
248
+ ```
249
+
250
+ ### 3) Override per-slot classes (`classes` prop)
251
+
252
+ If you use Tailwind (or your own utility classes), pass overrides:
253
+
254
+ ```tsx
255
+ <PersianDatePicker
256
+ value={value}
257
+ onChange={setValue}
258
+ classes={{
259
+ input: 'w-full rounded-xl border border-slate-300 bg-white px-3 py-2',
260
+ popover: 'z-[9999]',
261
+ daySelected: '!bg-emerald-600 !text-white',
262
+ }}
263
+ />
264
+ ```
265
+
266
+ ### 4) Fully custom CSS (no default stylesheet)
267
+
268
+ If you **don’t** import `styles.css`, you should provide your own CSS for the
269
+ component class hooks (ex: `.dvx-pdp`, `.dvx-pdp__input`, `.dvx-pdp__day`, ...),
270
+ or rely entirely on `classes` and your own styles.
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 |
146
280
 
147
281
  ## Development (this repo)
148
282
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "persian-date-kit",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Production-ready Persian (Jalali) date pickers for React with Gregorian-only values.",
5
5
  "keywords": [
6
6
  "react",