thailife-react 0.0.44 → 0.0.45
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/dist/cjs/index.js
CHANGED
|
@@ -263,16 +263,22 @@ const DatePicker = React.forwardRef(({ value, defaultValue, onChange, format = '
|
|
|
263
263
|
onChange === null || onChange === void 0 ? void 0 : onChange(date);
|
|
264
264
|
setIsOpen(false);
|
|
265
265
|
};
|
|
266
|
+
/** BE display must use BBBB/BB — do not add(543) years (breaks 29 Feb: 2567 is not a Gregorian leap year). */
|
|
267
|
+
const beDisplayFormat = React.useMemo(() => {
|
|
268
|
+
if (yearType !== 'BE')
|
|
269
|
+
return format;
|
|
270
|
+
return format.replace(/Y{4}/g, 'BBBB').replace(/Y{2}/g, 'BB');
|
|
271
|
+
}, [format, yearType]);
|
|
266
272
|
const formatDisplayValue = React.useMemo(() => {
|
|
267
273
|
return (date) => {
|
|
268
274
|
if (!date)
|
|
269
275
|
return '';
|
|
270
276
|
if (yearType === 'BE') {
|
|
271
|
-
return date.
|
|
277
|
+
return date.format(beDisplayFormat);
|
|
272
278
|
}
|
|
273
279
|
return date.format(format);
|
|
274
280
|
};
|
|
275
|
-
}, [format, yearType]);
|
|
281
|
+
}, [format, yearType, beDisplayFormat]);
|
|
276
282
|
const parseInputValue = React.useMemo(() => {
|
|
277
283
|
return (input) => {
|
|
278
284
|
if (!input)
|
|
@@ -365,7 +371,7 @@ const DatePicker = React.forwardRef(({ value, defaultValue, onChange, format = '
|
|
|
365
371
|
React.createElement("button", { type: "button", onClick: () => setCurrentMonth(prev => prev.subtract(1, 'month')), className: "p-1 hover:bg-gray-100 rounded" },
|
|
366
372
|
React.createElement("svg", { stroke: "#007AC2", fill: "none", "stroke-width": "1.5", viewBox: "0 0 24 24", "aria-hidden": "true", height: "1em", width: "1em", xmlns: "http://www.w3.org/2000/svg" },
|
|
367
373
|
React.createElement("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "M15.75 19.5 8.25 12l7.5-7.5" }))),
|
|
368
|
-
React.createElement("div", { className: "font-base text-primary" }, yearType === "BE" ? currentMonth.
|
|
374
|
+
React.createElement("div", { className: "font-base text-primary" }, yearType === "BE" ? currentMonth.format('MMMM BBBB') : currentMonth.format('MMMM YYYY')),
|
|
369
375
|
React.createElement("button", { type: "button", onClick: () => setCurrentMonth(prev => prev.add(1, 'month')), className: "p-1 hover:bg-gray-100 rounded" },
|
|
370
376
|
React.createElement("svg", { stroke: "#007AC2", fill: "none", "stroke-width": "1.5", viewBox: "0 0 24 24", "aria-hidden": "true", height: "1em", width: "1em", xmlns: "http://www.w3.org/2000/svg" },
|
|
371
377
|
React.createElement("path", { "stroke-linecap": "round", "stroke-linejoin": "round", d: "m8.25 4.5 7.5 7.5-7.5 7.5" })))),
|