@nepdatejs/react 0.0.0-bootstrap → 0.1.0
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/LICENSE +21 -0
- package/README.md +73 -1
- package/dist/date-text-BT82cZ7i.cjs +84 -0
- package/dist/date-text-BT82cZ7i.cjs.map +1 -0
- package/dist/date-text-Df1gFksR.js +61 -0
- package/dist/date-text-Df1gFksR.js.map +1 -0
- package/dist/date-text-Dipetpbp.d.cts +37 -0
- package/dist/date-text-Dipetpbp.d.ts +37 -0
- package/dist/headless-6BuUOtOR.d.cts +194 -0
- package/dist/headless-BK0XRHKb.js +513 -0
- package/dist/headless-BK0XRHKb.js.map +1 -0
- package/dist/headless-CFZ06zLn.d.ts +194 -0
- package/dist/headless-HxTkvgbz.cjs +572 -0
- package/dist/headless-HxTkvgbz.cjs.map +1 -0
- package/dist/headless.cjs +11 -0
- package/dist/headless.d.cts +2 -0
- package/dist/headless.d.ts +2 -0
- package/dist/headless.js +2 -0
- package/dist/index.cjs +891 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +245 -0
- package/dist/index.d.ts +245 -0
- package/dist/index.js +871 -0
- package/dist/index.js.map +1 -0
- package/dist/server.cjs +6 -0
- package/dist/server.d.cts +2 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +1 -0
- package/package.json +107 -4
- package/src/bindings.ts +247 -0
- package/src/calendar-body.tsx +133 -0
- package/src/calendar.tsx +34 -0
- package/src/date-picker.tsx +350 -0
- package/src/date-range-picker.tsx +223 -0
- package/src/date-text.tsx +110 -0
- package/src/date-time-picker.tsx +287 -0
- package/src/headless.ts +21 -0
- package/src/hooks.ts +474 -0
- package/src/icons.tsx +35 -0
- package/src/index.ts +21 -0
- package/src/multi-date-picker.tsx +243 -0
- package/src/panel.ts +67 -0
- package/src/presets.tsx +44 -0
- package/src/server.ts +8 -0
- package/src/time-columns.tsx +60 -0
- package/src/use-store.ts +113 -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
1
|
# @nepdatejs/react
|
|
2
2
|
|
|
3
|
-
|
|
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 = "en", 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-BT82cZ7i.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-text-BT82cZ7i.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 = 'en',\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,SAAS,MACT,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 = "en", 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-Df1gFksR.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"date-text-Df1gFksR.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 = 'en',\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,SAAS,MACT,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
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { ChangeEvent, KeyboardEvent, Ref } from "react";
|
|
2
|
+
import { CalendarDate, CalendarSystem, LocaleCode } from "@nepdatejs/core";
|
|
3
|
+
import { CalendarActions, CalendarOptions, CalendarState, CalendarStore, DayCell, PickerCell } from "@nepdatejs/calendar";
|
|
4
|
+
import { DatePickerOptions, DatePickerState, DatePickerStore, DateRangePickerOptions, DateRangePickerState, DateRangePickerStore, DateTimePickerOptions, DateTimePickerState, DateTimePickerStore, MultiDatePickerOptions, MultiDatePickerState, MultiDatePickerStore, PresetState, RangeField } from "@nepdatejs/datepicker";
|
|
5
|
+
//#region src/bindings.d.ts
|
|
6
|
+
type DataAttrs = Record<`data-${string}`, string | boolean | undefined>;
|
|
7
|
+
interface ButtonProps extends DataAttrs {
|
|
8
|
+
type: "button";
|
|
9
|
+
tabIndex?: number;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
"aria-label"?: string;
|
|
12
|
+
"aria-pressed"?: boolean;
|
|
13
|
+
"aria-current"?: "date";
|
|
14
|
+
onClick: () => void;
|
|
15
|
+
onFocus?: () => void;
|
|
16
|
+
onMouseEnter?: () => void;
|
|
17
|
+
}
|
|
18
|
+
interface GridProps {
|
|
19
|
+
role: "grid";
|
|
20
|
+
"aria-label": string;
|
|
21
|
+
ref: Ref<HTMLTableElement>;
|
|
22
|
+
onKeyDown: (event: KeyboardEvent) => void;
|
|
23
|
+
onMouseLeave: () => void;
|
|
24
|
+
}
|
|
25
|
+
/** Prop getters that turn a calendar store into accessible markup. */
|
|
26
|
+
interface CalendarBindings {
|
|
27
|
+
readonly state: CalendarState;
|
|
28
|
+
readonly actions: CalendarActions;
|
|
29
|
+
readonly getGridProps: () => GridProps;
|
|
30
|
+
readonly getDayProps: (cell: DayCell) => ButtonProps;
|
|
31
|
+
readonly getPrevProps: () => ButtonProps;
|
|
32
|
+
readonly getNextProps: () => ButtonProps;
|
|
33
|
+
/** The title buttons: month and year in the day view, the year (or page) otherwise. */
|
|
34
|
+
readonly getTitleButtons: () => {
|
|
35
|
+
key: string;
|
|
36
|
+
label: string;
|
|
37
|
+
props: ButtonProps;
|
|
38
|
+
}[];
|
|
39
|
+
readonly getOptionProps: (tile: PickerCell, index: number, tiles: readonly PickerCell[]) => ButtonProps;
|
|
40
|
+
/** Move focus into the grid (e.g. when a panel opens). */
|
|
41
|
+
readonly focusGrid: () => void;
|
|
42
|
+
}
|
|
43
|
+
declare function useCalendarBindings(state: CalendarState, actions: CalendarActions, locale: LocaleCode | undefined, options: {
|
|
44
|
+
/** The store's latest snapshot, to tell whether a key press changed anything. */
|
|
45
|
+
readonly getSnapshot: () => CalendarState;
|
|
46
|
+
readonly onDayActivate?: ((date: CalendarDate) => void) | undefined;
|
|
47
|
+
}): CalendarBindings;
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/hooks.d.ts
|
|
50
|
+
/** A standalone calendar: state, actions and prop getters. */
|
|
51
|
+
declare function useCalendar(options?: CalendarOptions): CalendarBindings & {
|
|
52
|
+
store: CalendarStore;
|
|
53
|
+
};
|
|
54
|
+
interface InputProps {
|
|
55
|
+
id: string;
|
|
56
|
+
/** Left out for an inline picker, whose calendar is always in the page. */
|
|
57
|
+
role?: "combobox";
|
|
58
|
+
type: "text";
|
|
59
|
+
inputMode: "numeric";
|
|
60
|
+
autoComplete: "off";
|
|
61
|
+
value: string;
|
|
62
|
+
placeholder: string;
|
|
63
|
+
"aria-haspopup"?: "dialog";
|
|
64
|
+
"aria-expanded"?: boolean;
|
|
65
|
+
"aria-controls": string;
|
|
66
|
+
"aria-invalid"?: true;
|
|
67
|
+
"aria-describedby"?: string;
|
|
68
|
+
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
69
|
+
onBlur: () => void;
|
|
70
|
+
onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => void;
|
|
71
|
+
}
|
|
72
|
+
interface PanelProps {
|
|
73
|
+
id: string;
|
|
74
|
+
/** 'group' for an inline picker. */
|
|
75
|
+
role: "dialog" | "group";
|
|
76
|
+
"aria-label": string;
|
|
77
|
+
}
|
|
78
|
+
interface DatePickerBindings {
|
|
79
|
+
readonly state: DatePickerState;
|
|
80
|
+
readonly actions: DatePickerStore["actions"];
|
|
81
|
+
readonly store: DatePickerStore;
|
|
82
|
+
/** Prop getters for the panel's calendar. */
|
|
83
|
+
readonly calendar: CalendarBindings;
|
|
84
|
+
readonly ids: {
|
|
85
|
+
input: string;
|
|
86
|
+
panel: string;
|
|
87
|
+
hint: string;
|
|
88
|
+
};
|
|
89
|
+
getInputProps(extra?: {
|
|
90
|
+
id?: string | undefined;
|
|
91
|
+
}): InputProps;
|
|
92
|
+
getToggleProps(): ButtonProps & {
|
|
93
|
+
"aria-expanded": boolean;
|
|
94
|
+
"aria-controls": string;
|
|
95
|
+
};
|
|
96
|
+
getClearProps(): ButtonProps;
|
|
97
|
+
/** The BS/AD switch inside the input. */
|
|
98
|
+
getSwitchProps(): ButtonProps;
|
|
99
|
+
/** One button of the BS/AD segment in the panel footer. */
|
|
100
|
+
getCalendarOptionProps(calendar: CalendarSystem): ButtonProps;
|
|
101
|
+
getTodayProps(): ButtonProps;
|
|
102
|
+
getPanelProps(): PanelProps;
|
|
103
|
+
/** A shortcut button (see state.presets). */
|
|
104
|
+
getPresetProps(preset: PresetState): ButtonProps;
|
|
105
|
+
}
|
|
106
|
+
/** A BS/AD date picker without markup: wire the getters to your own elements. */
|
|
107
|
+
declare function useDatePicker(options?: DatePickerOptions & {
|
|
108
|
+
id?: string | undefined;
|
|
109
|
+
}): DatePickerBindings;
|
|
110
|
+
interface DateRangePickerBindings {
|
|
111
|
+
readonly state: DateRangePickerState;
|
|
112
|
+
readonly actions: DateRangePickerStore["actions"];
|
|
113
|
+
readonly store: DateRangePickerStore;
|
|
114
|
+
readonly calendar: CalendarBindings;
|
|
115
|
+
readonly ids: {
|
|
116
|
+
start: string;
|
|
117
|
+
end: string;
|
|
118
|
+
panel: string;
|
|
119
|
+
hint: string;
|
|
120
|
+
};
|
|
121
|
+
getInputProps(field: RangeField): Omit<InputProps, "onChange" | "onBlur"> & {
|
|
122
|
+
onChange: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
123
|
+
onBlur: () => void;
|
|
124
|
+
};
|
|
125
|
+
getToggleProps(): ButtonProps & {
|
|
126
|
+
"aria-expanded": boolean;
|
|
127
|
+
"aria-controls": string;
|
|
128
|
+
};
|
|
129
|
+
getCalendarOptionProps(calendar: CalendarSystem): ButtonProps;
|
|
130
|
+
getPanelProps(): PanelProps;
|
|
131
|
+
getPresetProps(preset: PresetState): ButtonProps;
|
|
132
|
+
}
|
|
133
|
+
/** A BS/AD date range picker without markup. */
|
|
134
|
+
declare function useDateRangePicker(options?: DateRangePickerOptions): DateRangePickerBindings;
|
|
135
|
+
interface DateTimePickerBindings {
|
|
136
|
+
readonly state: DateTimePickerState;
|
|
137
|
+
readonly actions: DateTimePickerStore["actions"];
|
|
138
|
+
readonly store: DateTimePickerStore;
|
|
139
|
+
readonly calendar: CalendarBindings;
|
|
140
|
+
readonly ids: {
|
|
141
|
+
date: string;
|
|
142
|
+
time: string;
|
|
143
|
+
panel: string;
|
|
144
|
+
hint: string;
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
/** A BS/AD date + time picker without markup. The value is a zoned ISO timestamp. */
|
|
148
|
+
declare function useDateTimePicker(options?: DateTimePickerOptions & {
|
|
149
|
+
id?: string | undefined;
|
|
150
|
+
}): DateTimePickerBindings;
|
|
151
|
+
interface MultiDatePickerBindings {
|
|
152
|
+
readonly state: MultiDatePickerState;
|
|
153
|
+
readonly actions: MultiDatePickerStore["actions"];
|
|
154
|
+
readonly store: MultiDatePickerStore;
|
|
155
|
+
readonly calendar: CalendarBindings;
|
|
156
|
+
readonly ids: {
|
|
157
|
+
input: string;
|
|
158
|
+
panel: string;
|
|
159
|
+
hint: string;
|
|
160
|
+
};
|
|
161
|
+
getInputProps(): InputProps;
|
|
162
|
+
getToggleProps(): ButtonProps & {
|
|
163
|
+
"aria-expanded": boolean;
|
|
164
|
+
"aria-controls": string;
|
|
165
|
+
};
|
|
166
|
+
getClearProps(): ButtonProps;
|
|
167
|
+
getCalendarOptionProps(calendar: CalendarSystem): ButtonProps;
|
|
168
|
+
getPanelProps(): PanelProps;
|
|
169
|
+
}
|
|
170
|
+
/** A picker for several separate BS/AD days, without markup (PICK-001). */
|
|
171
|
+
declare function useMultiDatePicker(options?: MultiDatePickerOptions & {
|
|
172
|
+
id?: string | undefined;
|
|
173
|
+
}): MultiDatePickerBindings;
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/use-store.d.ts
|
|
176
|
+
interface StoreLike<O, S> {
|
|
177
|
+
getState(): S;
|
|
178
|
+
subscribe(listener: () => void): () => void;
|
|
179
|
+
setOptions(changes: Partial<O>): void;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Create a store once and keep its options in step with props, without
|
|
183
|
+
* loops: functions are wrapped once so their identity never changes, and data
|
|
184
|
+
* options are compared by value, so inline objects and arrays are fine.
|
|
185
|
+
*/
|
|
186
|
+
declare function useStore<O extends object, S, T extends StoreLike<O, S>>(create: (options: O) => T, options: O): {
|
|
187
|
+
store: T;
|
|
188
|
+
state: S;
|
|
189
|
+
};
|
|
190
|
+
/** Structural equality for plain data (dates, ranges, lists); identity for everything else. */
|
|
191
|
+
declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
192
|
+
//#endregion
|
|
193
|
+
export { useCalendarBindings as _, DateTimePickerBindings as a, PanelProps as c, useDateRangePicker as d, useDateTimePicker as f, GridProps as g, CalendarBindings as h, DateRangePickerBindings as i, useCalendar as l, ButtonProps as m, useStore as n, InputProps as o, useMultiDatePicker as p, DatePickerBindings as r, MultiDatePickerBindings as s, deepEqual as t, useDatePicker as u };
|
|
194
|
+
//# sourceMappingURL=headless-6BuUOtOR.d.cts.map
|