@octax-app/hot-date-react 0.1.2 → 0.1.3
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/README.md
CHANGED
|
@@ -75,7 +75,7 @@ function MyForm() {
|
|
|
75
75
|
/>
|
|
76
76
|
```
|
|
77
77
|
|
|
78
|
-
Tokens are case-insensitive: `YYYY`/`yyyy`, `MM`/`mm`, `DD`/`dd`, `YY`/`yy`, `M`/`m`, `D`/`d
|
|
78
|
+
Tokens are case-insensitive: `YYYY`/`yyyy`, `MM`/`mm`, `DD`/`dd`, `YY`/`yy`, `M`/`m`, `D`/`d`, `MMM` (short month name e.g. `Jan`), `MMMM` (full month name e.g. `January`). Month name tokens respect the `locale` prop.
|
|
79
79
|
|
|
80
80
|
For ranges, `onChange` returns `[formattedStart, formattedEnd]`.
|
|
81
81
|
|
|
@@ -299,7 +299,7 @@ console.log(ref.current?.value); // string | null
|
|
|
299
299
|
| `onMouseDown` | `(e: MouseEvent) => void` | — | Fires on mousedown. |
|
|
300
300
|
| `onMouseUp` | `(e: MouseEvent) => void` | — | Fires on mouseup. |
|
|
301
301
|
| `onMouseMove` | `(e: MouseEvent) => void` | — | Fires on mousemove. |
|
|
302
|
-
| `format` | `string` | `"YYYY-MM-DD"` | Output format. Tokens: `YYYY MM DD
|
|
302
|
+
| `format` | `string` | `"YYYY-MM-DD"` | Output format. Tokens: `YYYY YY MM DD M D MMM MMMM` (case-insensitive). `MMM`/`MMMM` render locale-aware short/full month names. |
|
|
303
303
|
| `dateType` | `"point" \| "range" \| "combined"` | `"point"` | `"point"` = single date only, `"range"` = range only, `"combined"` = both simultaneously (returns `string` or `[string, string]`). |
|
|
304
304
|
| `startDate` | `Date \| string` | — | Minimum date. Accepts a JS `Date` or `"YYYY-MM-DD"` string. |
|
|
305
305
|
| `endDate` | `Date \| string` | — | Maximum date. Accepts a JS `Date` or `"YYYY-MM-DD"` string. |
|
|
@@ -322,11 +322,11 @@ console.log(ref.current?.value); // string | null
|
|
|
322
322
|
|
|
323
323
|
## Output Format
|
|
324
324
|
|
|
325
|
-
| `dateType` | `format` not set | `format="MM/DD/YYYY"` |
|
|
326
|
-
| --- | --- | --- |
|
|
327
|
-
| `"point"` | `"2026-06-13"` | `"06/13/2026"` |
|
|
328
|
-
| `"range"` | `["2026-06-01", "2026-06-30"]` | `["06/01/2026", "06/30/2026"]` |
|
|
329
|
-
| `"combined"` | `"2026-06-13"` or `["2026-06-01", "2026-06-30"]` | `"06/13/2026"` or `["06/01/2026", "06/30/2026"]` |
|
|
325
|
+
| `dateType` | `format` not set | `format="MM/DD/YYYY"` | `format="MMM DD, YYYY"` |
|
|
326
|
+
| --- | --- | --- | --- |
|
|
327
|
+
| `"point"` | `"2026-06-13"` | `"06/13/2026"` | `"Jun 13, 2026"` |
|
|
328
|
+
| `"range"` | `["2026-06-01", "2026-06-30"]` | `["06/01/2026", "06/30/2026"]` | `["Jun 01, 2026", "Jun 30, 2026"]` |
|
|
329
|
+
| `"combined"` | `"2026-06-13"` or `["2026-06-01", "2026-06-30"]` | `"06/13/2026"` or `["06/01/2026", "06/30/2026"]` | `"Jun 13, 2026"` or `["Jun 01, 2026", "Jun 30, 2026"]` |
|
|
330
330
|
|
|
331
331
|
Empty / no selection always returns `""` regardless of `dateType` or `format`.
|
|
332
332
|
|
|
@@ -9167,27 +9167,29 @@ var Gc = class extends HTMLElement {
|
|
|
9167
9167
|
this.internals.setValidity({});
|
|
9168
9168
|
}
|
|
9169
9169
|
}
|
|
9170
|
-
formatSingleIso(e, t) {
|
|
9171
|
-
let [
|
|
9172
|
-
return t.replace(/YYYY|YY|MM|DD|M|D/gi, (e) => {
|
|
9170
|
+
formatSingleIso(e, t, n) {
|
|
9171
|
+
let [r, i, a] = e.split("-"), o = parseInt(i, 10), s = parseInt(a, 10);
|
|
9172
|
+
return t.replace(/YYYY|YY|MMMM|MMM|MM|DD|M|D/gi, (e) => {
|
|
9173
9173
|
switch (e.toUpperCase()) {
|
|
9174
|
-
case "YYYY": return
|
|
9175
|
-
case "YY": return
|
|
9176
|
-
case "
|
|
9177
|
-
case "
|
|
9178
|
-
case "
|
|
9179
|
-
case "
|
|
9174
|
+
case "YYYY": return r;
|
|
9175
|
+
case "YY": return r.slice(-2);
|
|
9176
|
+
case "MMMM": return new Date(parseInt(r, 10), o - 1, s).toLocaleString(n ?? "en", { month: "long" });
|
|
9177
|
+
case "MMM": return new Date(parseInt(r, 10), o - 1, s).toLocaleString(n ?? "en", { month: "short" });
|
|
9178
|
+
case "MM": return i;
|
|
9179
|
+
case "M": return String(o);
|
|
9180
|
+
case "DD": return a;
|
|
9181
|
+
case "D": return String(s);
|
|
9180
9182
|
default: return e;
|
|
9181
9183
|
}
|
|
9182
9184
|
});
|
|
9183
9185
|
}
|
|
9184
9186
|
formatValue(e) {
|
|
9185
|
-
let t = this.getAttribute("format");
|
|
9187
|
+
let t = this.getAttribute("format"), n = this.getAttribute("locale") ?? navigator.language ?? "en";
|
|
9186
9188
|
if (e.includes("/")) {
|
|
9187
|
-
let [
|
|
9188
|
-
return t ? `${this.formatSingleIso(
|
|
9189
|
+
let [r, i] = e.split("/");
|
|
9190
|
+
return t ? `${this.formatSingleIso(r, t, n)} — ${this.formatSingleIso(i, t, n)}` : `${r} — ${i}`;
|
|
9189
9191
|
}
|
|
9190
|
-
return t ? this.formatSingleIso(e, t) : this.parseState.previewLabel ?? e;
|
|
9192
|
+
return t ? this.formatSingleIso(e, t, n) : this.parseState.previewLabel ?? e;
|
|
9191
9193
|
}
|
|
9192
9194
|
emit(e, t) {
|
|
9193
9195
|
this.dispatchEvent(new CustomEvent(e, {
|
package/dist/hot-date-react.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "./hot-date-
|
|
1
|
+
import { t as e } from "./hot-date-CbxBFP6K.js";
|
|
2
2
|
import { forwardRef as t, useEffect as n, useImperativeHandle as r, useRef as i, useState as a } from "react";
|
|
3
3
|
import { jsx as o } from "react/jsx-runtime";
|
|
4
4
|
//#region src/react/format.ts
|
package/dist/hot-date.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "./hot-date-
|
|
1
|
+
import { t as e } from "./hot-date-CbxBFP6K.js";
|
|
2
2
|
export { e as HotDateElement };
|