persian-date-kit 0.0.8 → 0.0.10

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 +115 -10
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -129,20 +129,125 @@ 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
+ #### Required props
139
+ - **`value`**: `Date | null` controlled value (Gregorian)
140
+ - **`onChange`**: `(date: Date | null) => void` — controlled change handler
141
+
142
+ #### Extra props (single picker)
143
+ - **`placeholder?`**: `string` — input placeholder (popover mode)
144
+ - **`classes?`**: `PersianDatePickerClasses` — per-slot class overrides
141
145
 
142
146
  ### `PersianDateRangePicker`
143
- - **`value`**: `{ start: Date | null; end: Date | null }`
144
- - **`onChange`**: `(range) => void`
145
- - **`inputVariant`**: `'two' | 'single'`
147
+
148
+ #### Required props
149
+ - **`value`**: `{ start: Date | null; end: Date | null }` — controlled range (Gregorian)
150
+ - **`onChange`**: `(range: { start: Date | null; end: Date | null }) => void`
151
+
152
+ #### Extra props (range picker)
153
+ - **`inputVariant?`**: `'two' | 'single'` — two inputs (default) or one combined input
154
+ - **`placeholder?`**: `string` — used for single-input mode
155
+ - **`rangeSeparator?`**: `string` — separator for single-input text (default: `" - "`)
156
+ - **`placeholderStart?` / `placeholderEnd?`**: `string` — used for two-input mode
157
+ - **`classes?`**: `PersianDateRangePickerClasses` — per-slot class overrides
158
+
159
+ ### Shared props (`BasePickerProps`)
160
+
161
+ These props exist on both pickers:
162
+
163
+ - **`minDate?` / `maxDate?`**: `Date` — limits selectable days (Gregorian)
164
+ - **`disabled?`**: `boolean`
165
+ - **`mode?`**: `'popover' | 'inline'` — default is `'popover'`
166
+ - **`open?` / `onOpenChange?`**: control popover open state (only meaningful in popover mode)
167
+ - **`popover?`**: `PopoverConfig` — positioning options (popover mode)
168
+ - **`formatValue?`**: `(date: Date) => string` — formats input text (default: numeric Jalali `YYYY/MM/DD`)
169
+ - **`parseValue?`**: `(text: string) => Date | null` — parses input text into Gregorian (default: numeric Jalali `YYYY/MM/DD`)
170
+ - **`weekdays?`**: `string[]` — 7 labels for weekday header (if omitted, the picker uses numeric labels)
171
+ - **`monthLabels?`**: `string[]` — 12 labels (index 0 => month 1). If omitted, month numbers are shown.
172
+ - **`renderMonthLabel?`**: `(jy: number, jm: number) => React.ReactNode` — custom header label
173
+ - **`prevIcon?` / `nextIcon?`**: `React.ReactNode` — customize navigation icons
174
+ - **`className?`**: `string` — extra class on root
175
+
176
+ ### `PopoverConfig`
177
+
178
+ - **`portal?`**: `boolean` (default: `true`) — recommended inside modals / overflow containers
179
+ - **`gutter?`**: `number` (default: `8`) — gap between anchor and popover
180
+ - **`padding?`**: `number` (default: `8`) — minimum distance from viewport edges (clamping)
181
+ - **`strategy?`**: `'fixed' | 'absolute'` (default: `'fixed'`)
182
+ - **`placements?`**: `Array<'bottom' | 'top' | 'left' | 'right'>` (default: `['bottom','top','left','right']`)
183
+ - **`align?`**: `'start' | 'center' | 'end'` (default: `'end'`)
184
+
185
+ ### Styling slots (`classes`)
186
+
187
+ You can override the class names per slot:
188
+
189
+ - **Base slots** (`BasePickerClasses`):
190
+ - `root`, `input`, `button`, `popover`, `header`, `navButton`, `monthLabel`, `grid`, `weekday`
191
+ - `day`, `dayOutside`, `dayDisabled`, `dayToday`
192
+ - **Single picker extra slots** (`PersianDatePickerClasses`):
193
+ - `daySelected`
194
+ - **Range picker extra slots** (`PersianDateRangePickerClasses`):
195
+ - `dayRangeStart`, `dayRangeEnd`, `dayInRange`
196
+
197
+ ## Styling / Theming
198
+
199
+ ### 1) Use the default styles (recommended)
200
+
201
+ ```ts
202
+ import 'persian-date-kit/styles.css'
203
+ ```
204
+
205
+ The default CSS is built around **CSS variables**, so it’s easy to theme.
206
+
207
+ ### 2) Theme via CSS variables (quickest)
208
+
209
+ These variables control most of the look:
210
+
211
+ - `--dvx-pdp-bg`
212
+ - `--dvx-pdp-fg`
213
+ - `--dvx-pdp-muted`
214
+ - `--dvx-pdp-border`
215
+ - `--dvx-pdp-shadow`
216
+ - `--dvx-pdp-accent`
217
+ - `--dvx-pdp-accentFg`
218
+ - `--dvx-pdp-ring`
219
+ - `--dvx-pdp-dayHover`
220
+
221
+ Example:
222
+
223
+ ```css
224
+ :root {
225
+ --dvx-pdp-accent: #16a34a;
226
+ --dvx-pdp-ring: rgba(22, 163, 74, 0.25);
227
+ }
228
+ ```
229
+
230
+ ### 3) Override per-slot classes (`classes` prop)
231
+
232
+ If you use Tailwind (or your own utility classes), pass overrides:
233
+
234
+ ```tsx
235
+ <PersianDatePicker
236
+ value={value}
237
+ onChange={setValue}
238
+ classes={{
239
+ input: 'w-full rounded-xl border border-slate-300 bg-white px-3 py-2',
240
+ popover: 'z-[9999]',
241
+ daySelected: '!bg-emerald-600 !text-white',
242
+ }}
243
+ />
244
+ ```
245
+
246
+ ### 4) Fully custom CSS (no default stylesheet)
247
+
248
+ If you **don’t** import `styles.css`, you should provide your own CSS for the
249
+ component class hooks (ex: `.dvx-pdp`, `.dvx-pdp__input`, `.dvx-pdp__day`, ...),
250
+ or rely entirely on `classes` and your own styles.
146
251
 
147
252
  ## Development (this repo)
148
253
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "persian-date-kit",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "Production-ready Persian (Jalali) date pickers for React with Gregorian-only values.",
5
5
  "keywords": [
6
6
  "react",