@rehagro/ui 1.0.56 → 1.0.57
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/index.d.mts +12 -6
- package/dist/index.d.ts +12 -6
- package/dist/index.js +27 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -17
- package/dist/index.mjs.map +1 -1
- package/dist/native.js.map +1 -1
- package/dist/native.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import React9, { forwardRef, createContext, useState,
|
|
2
|
+
import React9, { forwardRef, createContext, useState, useMemo, useRef, useEffect, useCallback, useContext } from 'react';
|
|
3
3
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
4
4
|
import { createPortal } from 'react-dom';
|
|
5
5
|
|
|
@@ -2049,7 +2049,8 @@ var DateSelect = forwardRef(
|
|
|
2049
2049
|
wrapperClassName = "",
|
|
2050
2050
|
startYear,
|
|
2051
2051
|
endYear,
|
|
2052
|
-
backgroundColor
|
|
2052
|
+
backgroundColor,
|
|
2053
|
+
modes
|
|
2053
2054
|
} = props;
|
|
2054
2055
|
const triggerId = React9.useId();
|
|
2055
2056
|
const helperId = React9.useId();
|
|
@@ -2061,7 +2062,14 @@ var DateSelect = forwardRef(
|
|
|
2061
2062
|
);
|
|
2062
2063
|
const isControlled = props.value !== void 0;
|
|
2063
2064
|
const value = isControlled ? props.value ?? internalValue : internalValue;
|
|
2064
|
-
const
|
|
2065
|
+
const availableModes = useMemo(
|
|
2066
|
+
() => modes && modes.length > 0 ? MODE_OPTIONS.filter((o) => modes.includes(o.value)) : MODE_OPTIONS,
|
|
2067
|
+
[modes]
|
|
2068
|
+
);
|
|
2069
|
+
const defaultMode = availableModes[0]?.value ?? "day";
|
|
2070
|
+
const [activeMode, setActiveMode] = useState(
|
|
2071
|
+
availableModes.some((o) => o.value === (value.mode ?? "day")) ? value.mode ?? "day" : defaultMode
|
|
2072
|
+
);
|
|
2065
2073
|
const [selectedYear, setSelectedYear] = useState((/* @__PURE__ */ new Date()).getFullYear());
|
|
2066
2074
|
const [selectedMonth, setSelectedMonth] = useState((/* @__PURE__ */ new Date()).getMonth());
|
|
2067
2075
|
const rightMonth = selectedMonth === 11 ? 0 : selectedMonth + 1;
|
|
@@ -2177,19 +2185,22 @@ var DateSelect = forwardRef(
|
|
|
2177
2185
|
const [lo, hi] = start <= ref2 ? [start, ref2] : [ref2, start];
|
|
2178
2186
|
return date > lo && date < hi;
|
|
2179
2187
|
};
|
|
2180
|
-
const renderModeTabs = () =>
|
|
2181
|
-
|
|
2182
|
-
{
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2188
|
+
const renderModeTabs = () => {
|
|
2189
|
+
if (availableModes.length <= 1) return null;
|
|
2190
|
+
return /* @__PURE__ */ jsx("div", { className: "rh-flex rh-border-b rh-border-border rh-bg-transparent", children: availableModes.map((option) => /* @__PURE__ */ jsx(
|
|
2191
|
+
"button",
|
|
2192
|
+
{
|
|
2193
|
+
onClick: () => setActiveMode(option.value),
|
|
2194
|
+
className: [
|
|
2195
|
+
"rh-flex-1 rh-py-2 rh-px-4 rh-text-sm rh-transition-colors rh-duration-150 rh-text-text rh-font-bold",
|
|
2196
|
+
"rh-border-b-2 -rh-mb-px",
|
|
2197
|
+
activeMode === option.value ? "rh-border-primary" : "rh-border-transparent hover:rh-border-border"
|
|
2198
|
+
].join(" "),
|
|
2199
|
+
children: option.label
|
|
2200
|
+
},
|
|
2201
|
+
option.value
|
|
2202
|
+
)) });
|
|
2203
|
+
};
|
|
2193
2204
|
const renderYearGrid = () => /* @__PURE__ */ jsxs("div", { className: "rh-p-1", children: [
|
|
2194
2205
|
/* @__PURE__ */ jsxs("div", { className: "rh-flex rh-items-center rh-justify-between", children: [
|
|
2195
2206
|
/* @__PURE__ */ jsx(
|
|
@@ -2716,7 +2727,7 @@ var DateSelect = forwardRef(
|
|
|
2716
2727
|
},
|
|
2717
2728
|
children: [
|
|
2718
2729
|
renderModeTabs(),
|
|
2719
|
-
/* @__PURE__ */ jsx("div", { className: "rh-mt-2", children: renderContent() })
|
|
2730
|
+
/* @__PURE__ */ jsx("div", { className: availableModes.length > 1 ? "rh-mt-2" : "", children: renderContent() })
|
|
2720
2731
|
]
|
|
2721
2732
|
}
|
|
2722
2733
|
),
|