persian-date-kit 0.0.3 → 0.0.4

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),b=require("react"),g=require("react-hook-form"),m=require("./PersianDatePicker-CCakBpBo.cjs");function D(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const j=D(b);function c(e){const{name:t,control:r,rules:n,defaultValue:i,shouldUnregister:s,disabled:a,...l}=e,{field:o,fieldState:u,formState:P}=g.useController({name:t,control:r,rules:n,defaultValue:i??null,shouldUnregister:s,disabled:a}),f=o.value??null,d=j.useCallback(p=>{o.onChange(p)},[o]);return{field:o,fieldState:u,formState:P,pickerProps:{...l,value:f,onChange:d,disabled:a}}}function C(e){const{pickerProps:t}=c(e);return k.jsx(m.PersianDatePicker,{...t})}exports.RHF_PersianDatePicker=C;exports.usePersianDatePickerController=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react/jsx-runtime"),b=require("react"),g=require("react-hook-form"),m=require("./PersianDatePicker-Bcz6VNVe.cjs");function D(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const j=D(b);function c(e){const{name:t,control:r,rules:n,defaultValue:i,shouldUnregister:s,disabled:a,...l}=e,{field:o,fieldState:u,formState:P}=g.useController({name:t,control:r,rules:n,defaultValue:i??null,shouldUnregister:s,disabled:a}),f=o.value??null,d=j.useCallback(p=>{o.onChange(p)},[o]);return{field:o,fieldState:u,formState:P,pickerProps:{...l,value:f,onChange:d,disabled:a}}}function C(e){const{pickerProps:t}=c(e);return k.jsx(m.PersianDatePicker,{...t})}exports.RHF_PersianDatePicker=C;exports.usePersianDatePickerController=c;
@@ -22,10 +22,11 @@ export declare function usePersianDatePickerController<TFieldValues extends Fiel
22
22
  value: RHFDateValue;
23
23
  onChange: (date: RHFDateValue) => void;
24
24
  disabled: boolean | undefined;
25
+ open?: boolean | undefined;
26
+ popover?: import(".").PopoverConfig | undefined;
25
27
  minDate?: Date | undefined;
26
28
  maxDate?: Date | undefined;
27
29
  placeholder?: string | undefined;
28
- open?: boolean | undefined;
29
30
  onOpenChange?: ((open: boolean) => void) | undefined;
30
31
  mode?: "popover" | "inline" | undefined;
31
32
  formatValue?: ((date: Date) => string) | undefined;
@@ -33,6 +34,8 @@ export declare function usePersianDatePickerController<TFieldValues extends Fiel
33
34
  weekdays?: string[] | undefined;
34
35
  monthLabels?: string[] | undefined;
35
36
  renderMonthLabel?: ((jy: number, jm: number) => React.ReactNode) | undefined;
37
+ prevIcon?: React.ReactNode;
38
+ nextIcon?: React.ReactNode;
36
39
  className?: string | undefined;
37
40
  classes?: import(".").PersianDatePickerClasses | undefined;
38
41
  };
@@ -1 +1 @@
1
- {"version":3,"file":"react-hook-form.d.ts","sourceRoot":"","sources":["../src/react-hook-form.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAElF,OAAO,EAAqB,KAAK,sBAAsB,EAAE,MAAM,gCAAgC,CAAA;AAE/F,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,CAAA;AAEtC,MAAM,MAAM,oCAAoC,CAAC,YAAY,SAAS,WAAW,IAAI;IACnF,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;IACxB,OAAO,EAAE,OAAO,CA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gB,CAAC,EAAE,OAAO,CAAA;CAC3B,GAAG,IAAI,CAAC,sBAAsB,EAAE,OAAO,GAAG,UAAU,CAAC,CAAA;AAEtD;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,YAAY,SAAS,WAAW,EAC7E,MAAM,EAAE,oCAAoC,CAAC,YAAY,CAAC;;;;;;yBAgBjD,YAAY;;;;;;;;;;;;;;;;;;;EAiBtB;AAED,MAAM,MAAM,0BAA0B,CAAC,YAAY,SAAS,WAAW,IAAI,oCAAoC,CAAC,YAAY,CAAC,CAAA;AAE7H;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,SAAS,WAAW,EAAE,KAAK,EAAE,0BAA0B,CAAC,YAAY,CAAC,2CAGtH"}
@@ -1,7 +1,7 @@
1
1
  import { jsx as P } from "react/jsx-runtime";
2
2
  import * as d from "react";
3
3
  import { useController as k } from "react-hook-form";
4
- import { P as C } from "./PersianDatePicker-BicyzfQH.js";
4
+ import { P as C } from "./PersianDatePicker-DFMNtlIF.js";
5
5
  function g(r) {
6
6
  const { name: o, control: n, rules: a, defaultValue: l, shouldUnregister: s, disabled: t, ...i } = r, { field: e, fieldState: u, formState: c } = k({
7
7
  name: o,
package/dist/styles.css CHANGED
@@ -83,6 +83,11 @@
83
83
  z-index: 50;
84
84
  }
85
85
 
86
+ .dvx-pdp__popover--portal {
87
+ position: fixed;
88
+ z-index: 9999;
89
+ }
90
+
86
91
  .dvx-pdp__calendar {
87
92
  width: 280px;
88
93
  border-radius: 14px;
@@ -0,0 +1,120 @@
1
+ import type * as React from 'react';
2
+ /**
3
+ * Popover positioning options.
4
+ */
5
+ export type PopoverConfig = {
6
+ /**
7
+ * Render popover in a portal (default: `true`).
8
+ * Portals help with z-index and overflow issues, but may cause issues in SSR.
9
+ */
10
+ portal?: boolean;
11
+ /**
12
+ * Gap between anchor and popover (default: `8`).
13
+ */
14
+ gutter?: number;
15
+ /**
16
+ * Minimum padding from viewport edges (default: `8`).
17
+ */
18
+ padding?: number;
19
+ /**
20
+ * Positioning strategy: `fixed` (default) or `absolute`.
21
+ */
22
+ strategy?: 'fixed' | 'absolute';
23
+ /**
24
+ * Preferred placements in order (default: `['bottom', 'top', 'left', 'right']`).
25
+ */
26
+ placements?: Array<'bottom' | 'top' | 'left' | 'right'>;
27
+ /**
28
+ * Alignment on the cross axis (default: `'end'`).
29
+ */
30
+ align?: 'start' | 'center' | 'end';
31
+ };
32
+ /**
33
+ * Common props shared between date picker components.
34
+ */
35
+ export type BasePickerProps = {
36
+ /**
37
+ * Minimum selectable date (Gregorian).
38
+ */
39
+ minDate?: Date;
40
+ /**
41
+ * Maximum selectable date (Gregorian).
42
+ */
43
+ maxDate?: Date;
44
+ /**
45
+ * Disable the picker.
46
+ */
47
+ disabled?: boolean;
48
+ /**
49
+ * Control the open state of the calendar popover (popover mode only).
50
+ * If provided, the component becomes controlled for open/close.
51
+ */
52
+ open?: boolean;
53
+ /**
54
+ * Callback when open state changes (popover mode only).
55
+ */
56
+ onOpenChange?: (open: boolean) => void;
57
+ /**
58
+ * Rendering mode:
59
+ * - `popover`: default input + popover calendar
60
+ * - `inline`: always-visible calendar, no input
61
+ */
62
+ mode?: 'popover' | 'inline';
63
+ /**
64
+ * Popover positioning options (popover mode only).
65
+ */
66
+ popover?: PopoverConfig;
67
+ /**
68
+ * Formats a Date for display in inputs.
69
+ * Default: numeric Jalali `YYYY/MM/DD` (no locale month/day names).
70
+ */
71
+ formatValue?: (date: Date) => string;
72
+ /**
73
+ * Parses user text into a Gregorian Date.
74
+ * Default: parses numeric Jalali `YYYY/MM/DD` (also accepts loose separators).
75
+ */
76
+ parseValue?: (text: string) => Date | null;
77
+ /**
78
+ * Weekday headers. If omitted, numeric headers are used.
79
+ * Provide 7 items matching the calendar grid order.
80
+ */
81
+ weekdays?: string[];
82
+ /**
83
+ * Month labels (index 0 => month 1). If omitted, month numbers are shown.
84
+ * Provide 12 items.
85
+ */
86
+ monthLabels?: string[];
87
+ /**
88
+ * Month label renderer (e.g. supply localized month name).
89
+ * Default: `jy / jm` numeric.
90
+ */
91
+ renderMonthLabel?: (jy: number, jm: number) => React.ReactNode;
92
+ /**
93
+ * Custom navigation icons for previous/next month (and year panel paging).
94
+ */
95
+ prevIcon?: React.ReactNode;
96
+ nextIcon?: React.ReactNode;
97
+ /**
98
+ * Additional CSS class for the root element.
99
+ */
100
+ className?: string;
101
+ };
102
+ /**
103
+ * Base classes structure for styling customization.
104
+ */
105
+ export type BasePickerClasses = {
106
+ root?: string;
107
+ input?: string;
108
+ button?: string;
109
+ popover?: string;
110
+ header?: string;
111
+ navButton?: string;
112
+ monthLabel?: string;
113
+ grid?: string;
114
+ weekday?: string;
115
+ day?: string;
116
+ dayOutside?: string;
117
+ dayDisabled?: string;
118
+ dayToday?: string;
119
+ };
120
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/types/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAA;AAEnC;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,GAAG,UAAU,CAAA;IAC/B;;OAEG;IACH,UAAU,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC,CAAA;IACvD;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAA;CACnC,CAAA;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,IAAI,CAAA;IACd;;OAEG;IACH,OAAO,CAAC,EAAE,IAAI,CAA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ChB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA"}
@@ -0,0 +1,29 @@
1
+ import * as React from "react";
2
+ export type PopoverPlacement = "bottom" | "top" | "left" | "right";
3
+ export type PopoverAlign = "start" | "center" | "end";
4
+ export type PopoverPositionOptions = {
5
+ gutter?: number;
6
+ padding?: number;
7
+ strategy?: "fixed" | "absolute";
8
+ /**
9
+ * Placement preference order. The first placement that fits is chosen; otherwise
10
+ * the placement with the most available space is used.
11
+ *
12
+ * Default: ['bottom', 'top', 'left', 'right']
13
+ */
14
+ placements?: PopoverPlacement[];
15
+ /**
16
+ * Cross-axis alignment:
17
+ * - For `top`/`bottom` this aligns horizontally (x-axis).
18
+ * - For `left`/`right` this aligns vertically (y-axis).
19
+ *
20
+ * Default: 'end' (RTL-friendly for top/bottom).
21
+ */
22
+ align?: PopoverAlign;
23
+ };
24
+ export declare function usePopoverPosition<TAnchor extends HTMLElement, TPopover extends HTMLElement>(open: boolean, anchorRef: React.RefObject<TAnchor | null>, popoverRef: React.RefObject<TPopover | null>, opts?: PopoverPositionOptions): {
25
+ style: React.CSSProperties;
26
+ placement: PopoverPlacement;
27
+ update: () => void;
28
+ };
29
+ //# sourceMappingURL=usePopoverPosition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePopoverPosition.d.ts","sourceRoot":"","sources":["../../src/utils/usePopoverPosition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,CAAC;AACnE,MAAM,MAAM,YAAY,GAAG,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC;AAStD,MAAM,MAAM,sBAAsB,GAAG;IACnC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAChC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAChC;;;;;;OAMG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB,CAAC;AASF,wBAAgB,kBAAkB,CAChC,OAAO,SAAS,WAAW,EAC3B,QAAQ,SAAS,WAAW,EAE5B,IAAI,EAAE,OAAO,EACb,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,GAAG,IAAI,CAAC,EAC1C,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC,EAC5C,IAAI,GAAE,sBAA2B;;;;EAkIlC"}
package/package.json CHANGED
@@ -1,7 +1,33 @@
1
1
  {
2
2
  "name": "persian-date-kit",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
+ "description": "Production-ready Persian (Jalali) date pickers for React with Gregorian-only values.",
5
+ "keywords": [
6
+ "react",
7
+ "datepicker",
8
+ "date-picker",
9
+ "jalali",
10
+ "persian",
11
+ "shamsi",
12
+ "calendar",
13
+ "rtl",
14
+ "dayjs",
15
+ "typescript"
16
+ ],
17
+ "license": "MIT",
18
+ "author": "Darvix",
4
19
  "type": "module",
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "https://github.com/darvix/persian-date-kit.git"
23
+ },
24
+ "homepage": "https://github.com/darvix/persian-date-kit#readme",
25
+ "bugs": {
26
+ "url": "https://github.com/darvix/persian-date-kit/issues"
27
+ },
28
+ "engines": {
29
+ "node": ">=18"
30
+ },
5
31
  "main": "./dist/index.cjs",
6
32
  "module": "./dist/index.mjs",
7
33
  "types": "./dist/index.d.ts",
@@ -19,7 +45,9 @@
19
45
  "./styles.css": "./dist/styles.css"
20
46
  },
21
47
  "files": [
22
- "dist"
48
+ "dist",
49
+ "README.md",
50
+ "LICENSE"
23
51
  ],
24
52
  "sideEffects": [
25
53
  "**/*.css"
@@ -46,6 +74,7 @@
46
74
  },
47
75
  "devDependencies": {
48
76
  "@eslint/js": "^9.39.1",
77
+ "@fontsource/vazirmatn": "^5.2.8",
49
78
  "@types/node": "^24.10.1",
50
79
  "@types/react": "^19.2.5",
51
80
  "@types/react-dom": "^19.2.3",