@nepdatejs/react 0.0.0-stage → 0.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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +74 -2
  3. package/dist/date-text-BX3Uag0O.cjs +84 -0
  4. package/dist/date-text-BX3Uag0O.cjs.map +1 -0
  5. package/dist/date-text-DLwhBmYj.js +61 -0
  6. package/dist/date-text-DLwhBmYj.js.map +1 -0
  7. package/dist/date-text-Dipetpbp.d.cts +37 -0
  8. package/dist/date-text-Dipetpbp.d.ts +37 -0
  9. package/dist/headless-AEI6dxTJ.cjs +619 -0
  10. package/dist/headless-AEI6dxTJ.cjs.map +1 -0
  11. package/dist/headless-CVj0DhD4.js +560 -0
  12. package/dist/headless-CVj0DhD4.js.map +1 -0
  13. package/dist/headless-ChE3zuYj.d.ts +195 -0
  14. package/dist/headless-CrIIPnOF.d.cts +195 -0
  15. package/dist/headless.cjs +11 -0
  16. package/dist/headless.d.cts +2 -0
  17. package/dist/headless.d.ts +2 -0
  18. package/dist/headless.js +2 -0
  19. package/dist/index.cjs +915 -0
  20. package/dist/index.cjs.map +1 -0
  21. package/dist/index.d.cts +245 -0
  22. package/dist/index.d.ts +245 -0
  23. package/dist/index.js +895 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/server.cjs +6 -0
  26. package/dist/server.d.cts +2 -0
  27. package/dist/server.d.ts +2 -0
  28. package/dist/server.js +1 -0
  29. package/package.json +110 -3
  30. package/src/bindings.ts +247 -0
  31. package/src/calendar-body.tsx +133 -0
  32. package/src/calendar.tsx +34 -0
  33. package/src/date-picker.tsx +343 -0
  34. package/src/date-range-picker.tsx +225 -0
  35. package/src/date-text.tsx +110 -0
  36. package/src/date-time-picker.tsx +289 -0
  37. package/src/headless.ts +21 -0
  38. package/src/hooks.ts +476 -0
  39. package/src/icons.tsx +35 -0
  40. package/src/index.ts +21 -0
  41. package/src/multi-date-picker.tsx +245 -0
  42. package/src/page-locale.ts +23 -0
  43. package/src/panel.ts +67 -0
  44. package/src/presets.tsx +44 -0
  45. package/src/server.ts +8 -0
  46. package/src/time-columns.tsx +60 -0
  47. package/src/use-store.ts +196 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Shishir Rai
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,75 @@
1
- # Temporary Holding Version
1
+ # @nepdatejs/react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The BS/AD date picker and calendar for React 18 and 19. It provides styled components, plus headless hooks for your own markup, and works with server rendering and React Server Components.
4
+
5
+ ```bash
6
+ npm install @nepdatejs/react @nepdatejs/styles
7
+ ```
8
+
9
+ ```tsx
10
+ import '@nepdatejs/styles';
11
+ import { useState } from 'react';
12
+ import { DatePicker } from '@nepdatejs/react';
13
+
14
+ export function Form() {
15
+ const [dob, setDob] = useState('');
16
+
17
+ return (
18
+ <label>
19
+ Date of birth
20
+ <DatePicker value={dob} onChange={setDob} max="2026-12-31" />
21
+ </label>
22
+ );
23
+ }
24
+ ```
25
+
26
+ `value` and `onChange` use the AD date as `"YYYY-MM-DD"`, the same as `<input type="date">`. Viewers see and type BS (or AD, after switching).
27
+
28
+ ## Components
29
+
30
+ | Component | Notes |
31
+ | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
32
+ | `<DatePicker>` | Props are listed below. |
33
+ | `<DateRangePicker>` | `value={{ start, end }}`, `minDays`, `maxDays`, `startName`/`endName` for forms. |
34
+ | `<MultiDatePicker>` | Several separate days: `value={['2026-10-18', …]}`, `maxDates`, `name` (one hidden input per day). Clicks toggle days. |
35
+ | `<Calendar>` | A standalone month view: `selected`, `onSelect`, `month`/`onMonthChange`, `selectionMode="range"`, `holidays`, `events`. |
36
+ | `<DateText value="2026-09-26" />` | "10 Ashwin 2083 · 26 Sep 2026". It has no hooks, so it's safe in server components (`@nepdatejs/react/server`). |
37
+ | `<ShortDate>`, `shortDate()`, `bothDates()` | Short text for tables and documents. |
38
+
39
+ **`<DatePicker>` props:**
40
+
41
+ - **Value:** `value`, `defaultValue`, `onChange(value, { ad, bs })`, `name` (submits with plain forms; form reset is supported).
42
+ - **Calendar:** `calendar` (fixed BS or AD), `defaultCalendar`, `onCalendarChange`, `persistCalendar` (localStorage key).
43
+ - **Limits:** `min`, `max`, `isDateDisabled`, `holidays`, `events`.
44
+ - **Shortcuts:** `presets={['today', 'yesterday']}` (or custom `{ id, label, resolve }`) beside the calendar.
45
+ - **Display:** `locale` (defaults to `ne` when `<html lang="ne">`), `displayFormat`, `showEquivalent`, `clearable`, `weekStartsOn`, `weekendDays`, `theme`.
46
+ - **Inline:** `inline` keeps the calendar in the page under the input, always open.
47
+ - **Typing:** dashes fill in as digits are typed (`20830624` → `2083-06-24`); `mask={false}` turns that off.
48
+ - **Phones:** below 480px the panel opens as a bottom sheet. `panelLayout="popover"` or `"sheet"` forces one layout at any width.
49
+ - **Field:** `required`, `disabled`, `placeholder`, `id`, `aria-*`.
50
+ - **Testing and server rendering:** `today`.
51
+
52
+ The panel opens in the browser's top layer, so dialogs and scrolling containers never clip it. Escape and outside clicks close it.
53
+
54
+ ## Headless hooks
55
+
56
+ ```tsx
57
+ import { useDatePicker } from '@nepdatejs/react/headless';
58
+
59
+ const picker = useDatePicker({ min: '2026-01-01' });
60
+ <input {...picker.getInputProps()} />
61
+ <button {...picker.getToggleProps()}>Open</button>
62
+ {picker.state.open && (
63
+ <div {...picker.getPanelProps()}>
64
+ <table {...picker.calendar.getGridProps()}>…{/* picker.calendar.getDayProps(cell) */}</table>
65
+ </div>
66
+ )}
67
+ ```
68
+
69
+ `useCalendar`, `useDatePicker` and `useDateRangePicker` return the state, the actions and prop getters with the right ARIA and keyboard handling. Inline objects, arrays and functions in options are fine: values are compared by content and callbacks are wrapped once, so nothing re-renders in a loop.
70
+
71
+ ## Server rendering
72
+
73
+ Nothing touches `window` during render. Pass `today` for markup that is identical on server and client. A remembered BS/AD choice is read after hydration.
74
+
75
+ MIT © Shishir Rai
@@ -0,0 +1,84 @@
1
+ let react_jsx_runtime = require("react/jsx-runtime");
2
+ let _nepdatejs_core = require("@nepdatejs/core");
3
+ //#region src/date-text.tsx
4
+ /**
5
+ * A server date shown in BS (or AD), with the other calendar alongside:
6
+ * "10 Ashwin 2083 · 26 Sep 2026". No hooks, so it works in server components.
7
+ */
8
+ function DateText({ value, calendar = "BS", withEquivalent = true, format = "long", locale, fallback = "—", className }) {
9
+ const date = (0, _nepdatejs_core.fromIsoDate)(value);
10
+ if (!date) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
11
+ className,
12
+ children: fallback
13
+ });
14
+ const other = calendar === "BS" ? "AD" : "BS";
15
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("time", {
16
+ dateTime: (0, _nepdatejs_core.formatDate)(date, "Y-m-d"),
17
+ className,
18
+ children: [(0, _nepdatejs_core.formatDate)((0, _nepdatejs_core.toCalendar)(date, calendar), format, locale), withEquivalent && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
19
+ className: "ndp-muted",
20
+ style: { color: "var(--ndp-text-muted, #64748b)" },
21
+ children: [" · ", (0, _nepdatejs_core.formatDate)((0, _nepdatejs_core.toCalendar)(date, other), other === "AD" ? "j M Y" : format, locale)]
22
+ })]
23
+ });
24
+ }
25
+ /**
26
+ * A server date as short text: "12 Ashwin 2083", keeping the time of day when
27
+ * the value has one. A timestamp with a zone is read in the configured zone
28
+ * (Nepal by default). Anything that is not a date is returned unchanged.
29
+ */
30
+ function shortDate(value) {
31
+ if (!value) return null;
32
+ const instant = (0, _nepdatejs_core.fromIsoTimestamp)(value);
33
+ const date = instant?.date ?? (0, _nepdatejs_core.fromIsoDate)(value);
34
+ if (!date) return value;
35
+ const time = instant?.time ?? /[T ](\d{2}:\d{2})/.exec(value)?.[1];
36
+ return `${(0, _nepdatejs_core.formatDate)((0, _nepdatejs_core.toCalendar)(date, "BS"), "j F Y")}${time ? `, ${time}` : ""}`;
37
+ }
38
+ /** A server date as documents print it, in both calendars: "31 Shrawan 2083 (16 Aug 2026)". */
39
+ function bothDates(value) {
40
+ const date = (0, _nepdatejs_core.fromIsoDate)(value);
41
+ return date ? `${(0, _nepdatejs_core.formatDate)((0, _nepdatejs_core.toCalendar)(date, "BS"), "j F Y")} (${(0, _nepdatejs_core.formatDate)(date, "j M Y")})` : value ?? "";
42
+ }
43
+ /** A server date for a table cell or list row, with the AD day on hover. */
44
+ function ShortDate({ value, fallback = "—", className }) {
45
+ const text = shortDate(value);
46
+ const date = (0, _nepdatejs_core.fromIsoDate)(value);
47
+ if (!text) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
48
+ className,
49
+ children: fallback
50
+ });
51
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("time", {
52
+ dateTime: value ?? void 0,
53
+ title: date ? (0, _nepdatejs_core.formatDate)(date, "j M Y") : void 0,
54
+ className,
55
+ children: text
56
+ });
57
+ }
58
+ //#endregion
59
+ Object.defineProperty(exports, "DateText", {
60
+ enumerable: true,
61
+ get: function() {
62
+ return DateText;
63
+ }
64
+ });
65
+ Object.defineProperty(exports, "ShortDate", {
66
+ enumerable: true,
67
+ get: function() {
68
+ return ShortDate;
69
+ }
70
+ });
71
+ Object.defineProperty(exports, "bothDates", {
72
+ enumerable: true,
73
+ get: function() {
74
+ return bothDates;
75
+ }
76
+ });
77
+ Object.defineProperty(exports, "shortDate", {
78
+ enumerable: true,
79
+ get: function() {
80
+ return shortDate;
81
+ }
82
+ });
83
+
84
+ //# sourceMappingURL=date-text-BX3Uag0O.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-text-BX3Uag0O.cjs","names":["fromIsoDate","formatDate","toCalendar","fromIsoTimestamp"],"sources":["../src/date-text.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport {\n formatDate,\n fromIsoDate,\n fromIsoTimestamp,\n toCalendar,\n type CalendarSystem,\n type DateFormatPattern,\n type LocaleCode,\n} from '@nepdatejs/core';\n\nexport interface DateTextProps {\n /** An AD date or timestamp from the server (\"2026-09-26\" or an ISO timestamp). */\n value: string | null | undefined;\n /** Which calendar to show first. Default 'BS'. */\n calendar?: CalendarSystem | undefined;\n /** Also show the day in the other calendar, muted. Default true. */\n withEquivalent?: boolean | undefined;\n format?: DateFormatPattern | undefined;\n locale?: LocaleCode | undefined;\n fallback?: string | undefined;\n className?: string | undefined;\n}\n\n/**\n * A server date shown in BS (or AD), with the other calendar alongside:\n * \"10 Ashwin 2083 · 26 Sep 2026\". No hooks, so it works in server components.\n */\nexport function DateText({\n value,\n calendar = 'BS',\n withEquivalent = true,\n format = 'long',\n locale,\n fallback = '—',\n className,\n}: DateTextProps): ReactElement {\n const date = fromIsoDate(value);\n if (!date) {\n return <span className={className}>{fallback}</span>;\n }\n const other: CalendarSystem = calendar === 'BS' ? 'AD' : 'BS';\n\n return (\n <time dateTime={formatDate(date, 'Y-m-d')} className={className}>\n {formatDate(toCalendar(date, calendar), format, locale)}\n {withEquivalent && (\n <span className=\"ndp-muted\" style={{ color: 'var(--ndp-text-muted, #64748b)' }}>\n {' · '}\n {formatDate(toCalendar(date, other), other === 'AD' ? 'j M Y' : format, locale)}\n </span>\n )}\n </time>\n );\n}\n\n/**\n * A server date as short text: \"12 Ashwin 2083\", keeping the time of day when\n * the value has one. A timestamp with a zone is read in the configured zone\n * (Nepal by default). Anything that is not a date is returned unchanged.\n */\nexport function shortDate(value: string | null | undefined): string | null {\n if (!value) {\n return null;\n }\n const instant = fromIsoTimestamp(value);\n const date = instant?.date ?? fromIsoDate(value);\n if (!date) {\n return value;\n }\n const time = instant?.time ?? /[T ](\\d{2}:\\d{2})/.exec(value)?.[1];\n\n return `${formatDate(toCalendar(date, 'BS'), 'j F Y')}${time ? `, ${time}` : ''}`;\n}\n\n/** A server date as documents print it, in both calendars: \"31 Shrawan 2083 (16 Aug 2026)\". */\nexport function bothDates(value: string | null | undefined): string {\n const date = fromIsoDate(value);\n\n return date\n ? `${formatDate(toCalendar(date, 'BS'), 'j F Y')} (${formatDate(date, 'j M Y')})`\n : (value ?? '');\n}\n\n/** A server date for a table cell or list row, with the AD day on hover. */\nexport function ShortDate({\n value,\n fallback = '—',\n className,\n}: {\n value: string | null | undefined;\n fallback?: string | undefined;\n className?: string | undefined;\n}): ReactElement {\n const text = shortDate(value);\n const date = fromIsoDate(value);\n if (!text) {\n return <span className={className}>{fallback}</span>;\n }\n\n return (\n <time\n dateTime={value ?? undefined}\n title={date ? formatDate(date, 'j M Y') : undefined}\n className={className}\n >\n {text}\n </time>\n );\n}\n"],"mappings":";;;;;;;AA4BA,SAAgB,SAAS,EACvB,OACA,WAAW,MACX,iBAAiB,MACjB,SAAS,QACT,QACA,WAAW,KACX,aAC8B;CAC9B,MAAM,QAAA,GAAOA,gBAAAA,YAAAA,CAAY,KAAK;CAC9B,IAAI,CAAC,MACH,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EAAiB;EAAY,UAAA;CAAe,CAAA;CAErD,MAAM,QAAwB,aAAa,OAAO,OAAO;CAEzD,OACE,iBAAA,GAAA,kBAAA,KAAA,CAAC,QAAD;EAAM,WAAA,GAAUC,gBAAAA,WAAAA,CAAW,MAAM,OAAO;EAAc;EAAtD,UAAA,EAAA,GACGA,gBAAAA,WAAAA,EAAAA,GAAWC,gBAAAA,WAAAA,CAAW,MAAM,QAAQ,GAAG,QAAQ,MAAM,GACrD,kBACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,QAAD;GAAM,WAAU;GAAY,OAAO,EAAE,OAAO,iCAAiC;GAA7E,UAAA,CACG,QAAA,GACAD,gBAAAA,WAAAA,EAAAA,GAAWC,gBAAAA,WAAAA,CAAW,MAAM,KAAK,GAAG,UAAU,OAAO,UAAU,QAAQ,MAAM,CAC1E;EAEJ,CAAA,CAAA;;AAEV;;;;;;AAOA,SAAgB,UAAU,OAAiD;CACzE,IAAI,CAAC,OACH,OAAO;CAET,MAAM,WAAA,GAAUC,gBAAAA,iBAAAA,CAAiB,KAAK;CACtC,MAAM,OAAO,SAAS,SAAA,GAAQH,gBAAAA,YAAAA,CAAY,KAAK;CAC/C,IAAI,CAAC,MACH,OAAO;CAET,MAAM,OAAO,SAAS,QAAQ,oBAAoB,KAAK,KAAK,CAAC,GAAG;CAEhE,OAAO,IAAA,GAAGC,gBAAAA,WAAAA,EAAAA,GAAWC,gBAAAA,WAAAA,CAAW,MAAM,IAAI,GAAG,OAAO,IAAI,OAAO,KAAK,SAAS;AAC/E;;AAGA,SAAgB,UAAU,OAA0C;CAClE,MAAM,QAAA,GAAOF,gBAAAA,YAAAA,CAAY,KAAK;CAE9B,OAAO,OACH,IAAA,GAAGC,gBAAAA,WAAAA,EAAAA,GAAWC,gBAAAA,WAAAA,CAAW,MAAM,IAAI,GAAG,OAAO,EAAE,KAAA,GAAID,gBAAAA,WAAAA,CAAW,MAAM,OAAO,EAAE,KAC5E,SAAS;AAChB;;AAGA,SAAgB,UAAU,EACxB,OACA,WAAW,KACX,aAKe;CACf,MAAM,OAAO,UAAU,KAAK;CAC5B,MAAM,QAAA,GAAOD,gBAAAA,YAAAA,CAAY,KAAK;CAC9B,IAAI,CAAC,MACH,OAAO,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EAAiB;EAAY,UAAA;CAAe,CAAA;CAGrD,OACE,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;EACE,UAAU,SAAS,KAAA;EACnB,OAAO,QAAA,GAAOC,gBAAAA,WAAAA,CAAW,MAAM,OAAO,IAAI,KAAA;EAC/B;EAEV,UAAA;CACG,CAAA;AAEV"}
@@ -0,0 +1,61 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { formatDate, fromIsoDate, fromIsoTimestamp, toCalendar } from "@nepdatejs/core";
3
+ //#region src/date-text.tsx
4
+ /**
5
+ * A server date shown in BS (or AD), with the other calendar alongside:
6
+ * "10 Ashwin 2083 · 26 Sep 2026". No hooks, so it works in server components.
7
+ */
8
+ function DateText({ value, calendar = "BS", withEquivalent = true, format = "long", locale, fallback = "—", className }) {
9
+ const date = fromIsoDate(value);
10
+ if (!date) return /* @__PURE__ */ jsx("span", {
11
+ className,
12
+ children: fallback
13
+ });
14
+ const other = calendar === "BS" ? "AD" : "BS";
15
+ return /* @__PURE__ */ jsxs("time", {
16
+ dateTime: formatDate(date, "Y-m-d"),
17
+ className,
18
+ children: [formatDate(toCalendar(date, calendar), format, locale), withEquivalent && /* @__PURE__ */ jsxs("span", {
19
+ className: "ndp-muted",
20
+ style: { color: "var(--ndp-text-muted, #64748b)" },
21
+ children: [" · ", formatDate(toCalendar(date, other), other === "AD" ? "j M Y" : format, locale)]
22
+ })]
23
+ });
24
+ }
25
+ /**
26
+ * A server date as short text: "12 Ashwin 2083", keeping the time of day when
27
+ * the value has one. A timestamp with a zone is read in the configured zone
28
+ * (Nepal by default). Anything that is not a date is returned unchanged.
29
+ */
30
+ function shortDate(value) {
31
+ if (!value) return null;
32
+ const instant = fromIsoTimestamp(value);
33
+ const date = instant?.date ?? fromIsoDate(value);
34
+ if (!date) return value;
35
+ const time = instant?.time ?? /[T ](\d{2}:\d{2})/.exec(value)?.[1];
36
+ return `${formatDate(toCalendar(date, "BS"), "j F Y")}${time ? `, ${time}` : ""}`;
37
+ }
38
+ /** A server date as documents print it, in both calendars: "31 Shrawan 2083 (16 Aug 2026)". */
39
+ function bothDates(value) {
40
+ const date = fromIsoDate(value);
41
+ return date ? `${formatDate(toCalendar(date, "BS"), "j F Y")} (${formatDate(date, "j M Y")})` : value ?? "";
42
+ }
43
+ /** A server date for a table cell or list row, with the AD day on hover. */
44
+ function ShortDate({ value, fallback = "—", className }) {
45
+ const text = shortDate(value);
46
+ const date = fromIsoDate(value);
47
+ if (!text) return /* @__PURE__ */ jsx("span", {
48
+ className,
49
+ children: fallback
50
+ });
51
+ return /* @__PURE__ */ jsx("time", {
52
+ dateTime: value ?? void 0,
53
+ title: date ? formatDate(date, "j M Y") : void 0,
54
+ className,
55
+ children: text
56
+ });
57
+ }
58
+ //#endregion
59
+ export { shortDate as i, ShortDate as n, bothDates as r, DateText as t };
60
+
61
+ //# sourceMappingURL=date-text-DLwhBmYj.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"date-text-DLwhBmYj.js","names":[],"sources":["../src/date-text.tsx"],"sourcesContent":["import type { ReactElement } from 'react';\nimport {\n formatDate,\n fromIsoDate,\n fromIsoTimestamp,\n toCalendar,\n type CalendarSystem,\n type DateFormatPattern,\n type LocaleCode,\n} from '@nepdatejs/core';\n\nexport interface DateTextProps {\n /** An AD date or timestamp from the server (\"2026-09-26\" or an ISO timestamp). */\n value: string | null | undefined;\n /** Which calendar to show first. Default 'BS'. */\n calendar?: CalendarSystem | undefined;\n /** Also show the day in the other calendar, muted. Default true. */\n withEquivalent?: boolean | undefined;\n format?: DateFormatPattern | undefined;\n locale?: LocaleCode | undefined;\n fallback?: string | undefined;\n className?: string | undefined;\n}\n\n/**\n * A server date shown in BS (or AD), with the other calendar alongside:\n * \"10 Ashwin 2083 · 26 Sep 2026\". No hooks, so it works in server components.\n */\nexport function DateText({\n value,\n calendar = 'BS',\n withEquivalent = true,\n format = 'long',\n locale,\n fallback = '—',\n className,\n}: DateTextProps): ReactElement {\n const date = fromIsoDate(value);\n if (!date) {\n return <span className={className}>{fallback}</span>;\n }\n const other: CalendarSystem = calendar === 'BS' ? 'AD' : 'BS';\n\n return (\n <time dateTime={formatDate(date, 'Y-m-d')} className={className}>\n {formatDate(toCalendar(date, calendar), format, locale)}\n {withEquivalent && (\n <span className=\"ndp-muted\" style={{ color: 'var(--ndp-text-muted, #64748b)' }}>\n {' · '}\n {formatDate(toCalendar(date, other), other === 'AD' ? 'j M Y' : format, locale)}\n </span>\n )}\n </time>\n );\n}\n\n/**\n * A server date as short text: \"12 Ashwin 2083\", keeping the time of day when\n * the value has one. A timestamp with a zone is read in the configured zone\n * (Nepal by default). Anything that is not a date is returned unchanged.\n */\nexport function shortDate(value: string | null | undefined): string | null {\n if (!value) {\n return null;\n }\n const instant = fromIsoTimestamp(value);\n const date = instant?.date ?? fromIsoDate(value);\n if (!date) {\n return value;\n }\n const time = instant?.time ?? /[T ](\\d{2}:\\d{2})/.exec(value)?.[1];\n\n return `${formatDate(toCalendar(date, 'BS'), 'j F Y')}${time ? `, ${time}` : ''}`;\n}\n\n/** A server date as documents print it, in both calendars: \"31 Shrawan 2083 (16 Aug 2026)\". */\nexport function bothDates(value: string | null | undefined): string {\n const date = fromIsoDate(value);\n\n return date\n ? `${formatDate(toCalendar(date, 'BS'), 'j F Y')} (${formatDate(date, 'j M Y')})`\n : (value ?? '');\n}\n\n/** A server date for a table cell or list row, with the AD day on hover. */\nexport function ShortDate({\n value,\n fallback = '—',\n className,\n}: {\n value: string | null | undefined;\n fallback?: string | undefined;\n className?: string | undefined;\n}): ReactElement {\n const text = shortDate(value);\n const date = fromIsoDate(value);\n if (!text) {\n return <span className={className}>{fallback}</span>;\n }\n\n return (\n <time\n dateTime={value ?? undefined}\n title={date ? formatDate(date, 'j M Y') : undefined}\n className={className}\n >\n {text}\n </time>\n );\n}\n"],"mappings":";;;;;;;AA4BA,SAAgB,SAAS,EACvB,OACA,WAAW,MACX,iBAAiB,MACjB,SAAS,QACT,QACA,WAAW,KACX,aAC8B;CAC9B,MAAM,OAAO,YAAY,KAAK;CAC9B,IAAI,CAAC,MACH,OAAO,oBAAC,QAAD;EAAiB;EAAY,UAAA;CAAe,CAAA;CAErD,MAAM,QAAwB,aAAa,OAAO,OAAO;CAEzD,OACE,qBAAC,QAAD;EAAM,UAAU,WAAW,MAAM,OAAO;EAAc;EAAtD,UAAA,CACG,WAAW,WAAW,MAAM,QAAQ,GAAG,QAAQ,MAAM,GACrD,kBACC,qBAAC,QAAD;GAAM,WAAU;GAAY,OAAO,EAAE,OAAO,iCAAiC;GAA7E,UAAA,CACG,OACA,WAAW,WAAW,MAAM,KAAK,GAAG,UAAU,OAAO,UAAU,QAAQ,MAAM,CAC1E;EAEJ,CAAA,CAAA;;AAEV;;;;;;AAOA,SAAgB,UAAU,OAAiD;CACzE,IAAI,CAAC,OACH,OAAO;CAET,MAAM,UAAU,iBAAiB,KAAK;CACtC,MAAM,OAAO,SAAS,QAAQ,YAAY,KAAK;CAC/C,IAAI,CAAC,MACH,OAAO;CAET,MAAM,OAAO,SAAS,QAAQ,oBAAoB,KAAK,KAAK,CAAC,GAAG;CAEhE,OAAO,GAAG,WAAW,WAAW,MAAM,IAAI,GAAG,OAAO,IAAI,OAAO,KAAK,SAAS;AAC/E;;AAGA,SAAgB,UAAU,OAA0C;CAClE,MAAM,OAAO,YAAY,KAAK;CAE9B,OAAO,OACH,GAAG,WAAW,WAAW,MAAM,IAAI,GAAG,OAAO,EAAE,IAAI,WAAW,MAAM,OAAO,EAAE,KAC5E,SAAS;AAChB;;AAGA,SAAgB,UAAU,EACxB,OACA,WAAW,KACX,aAKe;CACf,MAAM,OAAO,UAAU,KAAK;CAC5B,MAAM,OAAO,YAAY,KAAK;CAC9B,IAAI,CAAC,MACH,OAAO,oBAAC,QAAD;EAAiB;EAAY,UAAA;CAAe,CAAA;CAGrD,OACE,oBAAC,QAAD;EACE,UAAU,SAAS,KAAA;EACnB,OAAO,OAAO,WAAW,MAAM,OAAO,IAAI,KAAA;EAC/B;EAEV,UAAA;CACG,CAAA;AAEV"}
@@ -0,0 +1,37 @@
1
+ import { ReactElement } from "react";
2
+ import { CalendarSystem, DateFormatPattern, LocaleCode } from "@nepdatejs/core";
3
+ //#region src/date-text.d.ts
4
+ interface DateTextProps {
5
+ /** An AD date or timestamp from the server ("2026-09-26" or an ISO timestamp). */
6
+ value: string | null | undefined;
7
+ /** Which calendar to show first. Default 'BS'. */
8
+ calendar?: CalendarSystem | undefined;
9
+ /** Also show the day in the other calendar, muted. Default true. */
10
+ withEquivalent?: boolean | undefined;
11
+ format?: DateFormatPattern | undefined;
12
+ locale?: LocaleCode | undefined;
13
+ fallback?: string | undefined;
14
+ className?: string | undefined;
15
+ }
16
+ /**
17
+ * A server date shown in BS (or AD), with the other calendar alongside:
18
+ * "10 Ashwin 2083 · 26 Sep 2026". No hooks, so it works in server components.
19
+ */
20
+ declare function DateText({ value, calendar, withEquivalent, format, locale, fallback, className }: DateTextProps): ReactElement;
21
+ /**
22
+ * A server date as short text: "12 Ashwin 2083", keeping the time of day when
23
+ * the value has one. A timestamp with a zone is read in the configured zone
24
+ * (Nepal by default). Anything that is not a date is returned unchanged.
25
+ */
26
+ declare function shortDate(value: string | null | undefined): string | null;
27
+ /** A server date as documents print it, in both calendars: "31 Shrawan 2083 (16 Aug 2026)". */
28
+ declare function bothDates(value: string | null | undefined): string;
29
+ /** A server date for a table cell or list row, with the AD day on hover. */
30
+ declare function ShortDate({ value, fallback, className }: {
31
+ value: string | null | undefined;
32
+ fallback?: string | undefined;
33
+ className?: string | undefined;
34
+ }): ReactElement;
35
+ //#endregion
36
+ export { shortDate as a, bothDates as i, DateTextProps as n, ShortDate as r, DateText as t };
37
+ //# sourceMappingURL=date-text-Dipetpbp.d.cts.map
@@ -0,0 +1,37 @@
1
+ import { ReactElement } from "react";
2
+ import { CalendarSystem, DateFormatPattern, LocaleCode } from "@nepdatejs/core";
3
+ //#region src/date-text.d.ts
4
+ interface DateTextProps {
5
+ /** An AD date or timestamp from the server ("2026-09-26" or an ISO timestamp). */
6
+ value: string | null | undefined;
7
+ /** Which calendar to show first. Default 'BS'. */
8
+ calendar?: CalendarSystem | undefined;
9
+ /** Also show the day in the other calendar, muted. Default true. */
10
+ withEquivalent?: boolean | undefined;
11
+ format?: DateFormatPattern | undefined;
12
+ locale?: LocaleCode | undefined;
13
+ fallback?: string | undefined;
14
+ className?: string | undefined;
15
+ }
16
+ /**
17
+ * A server date shown in BS (or AD), with the other calendar alongside:
18
+ * "10 Ashwin 2083 · 26 Sep 2026". No hooks, so it works in server components.
19
+ */
20
+ declare function DateText({ value, calendar, withEquivalent, format, locale, fallback, className }: DateTextProps): ReactElement;
21
+ /**
22
+ * A server date as short text: "12 Ashwin 2083", keeping the time of day when
23
+ * the value has one. A timestamp with a zone is read in the configured zone
24
+ * (Nepal by default). Anything that is not a date is returned unchanged.
25
+ */
26
+ declare function shortDate(value: string | null | undefined): string | null;
27
+ /** A server date as documents print it, in both calendars: "31 Shrawan 2083 (16 Aug 2026)". */
28
+ declare function bothDates(value: string | null | undefined): string;
29
+ /** A server date for a table cell or list row, with the AD day on hover. */
30
+ declare function ShortDate({ value, fallback, className }: {
31
+ value: string | null | undefined;
32
+ fallback?: string | undefined;
33
+ className?: string | undefined;
34
+ }): ReactElement;
35
+ //#endregion
36
+ export { shortDate as a, bothDates as i, DateTextProps as n, ShortDate as r, DateText as t };
37
+ //# sourceMappingURL=date-text-Dipetpbp.d.ts.map