@herca/r-kit 0.0.21 → 0.0.22

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/clients.cjs CHANGED
@@ -10698,7 +10698,8 @@ function DaysOfWeek({
10698
10698
  size = "md",
10699
10699
  wrapperClassName,
10700
10700
  variant = "default",
10701
- type = "month"
10701
+ type = "month",
10702
+ renderItem
10702
10703
  }) {
10703
10704
  return /* @__PURE__ */ (0, import_jsx_runtime313.jsxs)(
10704
10705
  "div",
@@ -10714,11 +10715,11 @@ function DaysOfWeek({
10714
10715
  wrapperClassName
10715
10716
  ),
10716
10717
  children: [
10717
- type === "week" && variant === "default" && /* @__PURE__ */ (0, import_jsx_runtime313.jsxs)(import_jsx_runtime313.Fragment, { children: [
10718
+ type === "week" && variant === "default" && renderItem === void 0 && /* @__PURE__ */ (0, import_jsx_runtime313.jsxs)(import_jsx_runtime313.Fragment, { children: [
10718
10719
  /* @__PURE__ */ (0, import_jsx_runtime313.jsx)("div", {}),
10719
10720
  daysOfWeek.map((day) => /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(Text, { as: "h5", value: day, variant: "t1" }, day))
10720
10721
  ] }),
10721
- type === "month" && daysOfWeek.map((day) => /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
10722
+ type === "month" && renderItem === void 0 && daysOfWeek.map((day) => /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
10722
10723
  Text,
10723
10724
  {
10724
10725
  as: "h5",
@@ -10816,6 +10817,14 @@ var Calendar2 = ({
10816
10817
  const [selectedTypeIndex, setSelectedTypeIndex] = (0, import_react295.useState)(
10817
10818
  null
10818
10819
  );
10820
+ const [currentWeekStart, setCurrentWeekStart] = (0, import_react295.useState)(() => {
10821
+ const today = /* @__PURE__ */ new Date();
10822
+ const day = today.getDay();
10823
+ const start = new Date(today);
10824
+ start.setDate(today.getDate() - day);
10825
+ start.setHours(0, 0, 0, 0);
10826
+ return start;
10827
+ });
10819
10828
  const calendarDays = getCalendarDays({ currentMonth, currentYear });
10820
10829
  const calendarHelpers = createCalendarHelpers({
10821
10830
  disabledDates,
@@ -10844,6 +10853,24 @@ var Calendar2 = ({
10844
10853
  }
10845
10854
  onChange?.(day.fullDate);
10846
10855
  };
10856
+ const getWeekDaysLabel = (weekStart) => {
10857
+ return Array.from({ length: 7 }, (_, i) => {
10858
+ const d = new Date(weekStart);
10859
+ d.setDate(weekStart.getDate() + i);
10860
+ const dayName = daysOfWeek[d.getDay()];
10861
+ const date = d.getDate();
10862
+ return `${dayName} ${date}`;
10863
+ });
10864
+ };
10865
+ const changeWeek = (delta) => {
10866
+ setCurrentWeekStart((prev) => {
10867
+ const next = new Date(prev);
10868
+ next.setDate(prev.getDate() + delta * 7);
10869
+ setCurrentMonth(next.getMonth());
10870
+ setCurrentYear(next.getFullYear());
10871
+ return next;
10872
+ });
10873
+ };
10847
10874
  const changeMonth = (delta) => {
10848
10875
  let newMonth = currentMonth + delta;
10849
10876
  let newYear = currentYear;
@@ -10857,6 +10884,22 @@ var Calendar2 = ({
10857
10884
  setCurrentMonth(newMonth);
10858
10885
  setCurrentYear(newYear);
10859
10886
  };
10887
+ const handleNavigationDefault = (type2, action) => {
10888
+ if (type2 === "month") {
10889
+ if (action === "next") {
10890
+ return changeMonth(-1);
10891
+ } else {
10892
+ return changeMonth(1);
10893
+ }
10894
+ }
10895
+ if (type2 === "week") {
10896
+ if (action === "next") {
10897
+ return changeWeek(1);
10898
+ } else {
10899
+ return changeWeek(-1);
10900
+ }
10901
+ }
10902
+ };
10860
10903
  (0, import_react295.useEffect)(() => {
10861
10904
  if (value !== void 0) {
10862
10905
  setCurrentMonth(
@@ -10876,8 +10919,20 @@ var Calendar2 = ({
10876
10919
  variant === "default" && /* @__PURE__ */ (0, import_jsx_runtime314.jsxs)("div", { className: "flex items-center justify-between", children: [
10877
10920
  /* @__PURE__ */ (0, import_jsx_runtime314.jsxs)("div", { className: "flex items-center gap-6", children: [
10878
10921
  /* @__PURE__ */ (0, import_jsx_runtime314.jsxs)("div", { className: "*:cursor-pointer", children: [
10879
- /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(ButtonNavigation, { onClick: () => changeMonth(-1), type: "prev" }),
10880
- /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(ButtonNavigation, { onClick: () => changeMonth(1), type: "next" })
10922
+ /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
10923
+ ButtonNavigation,
10924
+ {
10925
+ onClick: () => handleNavigationDefault(selectedType, "prev"),
10926
+ type: "prev"
10927
+ }
10928
+ ),
10929
+ /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
10930
+ ButtonNavigation,
10931
+ {
10932
+ onClick: () => handleNavigationDefault(selectedType, "next"),
10933
+ type: "next"
10934
+ }
10935
+ )
10881
10936
  ] }),
10882
10937
  /* @__PURE__ */ (0, import_jsx_runtime314.jsxs)(
10883
10938
  Text,
@@ -10901,6 +10956,7 @@ var Calendar2 = ({
10901
10956
  color: "gray",
10902
10957
  variant: "outline",
10903
10958
  className: "capitalize",
10959
+ onClick: () => setCurrentMonth((/* @__PURE__ */ new Date()).getMonth()),
10904
10960
  children: "Today"
10905
10961
  }
10906
10962
  ),
@@ -10962,7 +11018,7 @@ var Calendar2 = ({
10962
11018
  type: "week",
10963
11019
  size,
10964
11020
  variant,
10965
- daysOfWeek,
11021
+ daysOfWeek: getWeekDaysLabel(currentWeekStart),
10966
11022
  wrapperClassName: weekWrapperClassname
10967
11023
  }
10968
11024
  ) }),
@@ -12253,7 +12309,8 @@ var Select = ({
12253
12309
  }
12254
12310
  }, [isOpen, isSearchable]);
12255
12311
  const getDisplayValue = () => {
12256
- if (value !== null || value !== void 0 || isMulti && asArray(value).length === 0) {
12312
+ const isEmpty = value == null || isMulti && asArray(value).length === 0;
12313
+ if (isEmpty) {
12257
12314
  return /* @__PURE__ */ (0, import_jsx_runtime322.jsx)("span", { className: "text-gray-500", children: placeholder });
12258
12315
  }
12259
12316
  if (isMulti) {
@@ -12262,7 +12319,7 @@ var Select = ({
12262
12319
  {
12263
12320
  className: "border-primary-200 flex items-center gap-1 rounded border bg-white px-2 py-0.5 text-xs text-gray-900",
12264
12321
  children: [
12265
- renderValue !== void 0 ? renderValue?.(item) : item.label,
12322
+ renderValue !== void 0 && renderValue !== null ? renderValue?.(item) : item.label,
12266
12323
  /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
12267
12324
  "button",
12268
12325
  {
@@ -12276,7 +12333,7 @@ var Select = ({
12276
12333
  item.value
12277
12334
  )) });
12278
12335
  }
12279
- return renderValue !== void 0 ? renderValue?.(value) : value.label;
12336
+ return renderValue !== void 0 && renderValue !== null ? renderValue?.(value) : value.label;
12280
12337
  };
12281
12338
  const showClearButton = isClearable && (isMulti && asArray(value).length > 0 || !isMulti && value !== null);
12282
12339
  const hasError = fieldHasError(errorMessages);
@@ -12377,7 +12434,7 @@ var Select = ({
12377
12434
  highlighted && "bg-primary-100",
12378
12435
  selected ? "bg-primary-50 border-primary-300" : "hover:bg-gray-50"
12379
12436
  ),
12380
- children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)("div", { className: "flex-1", children: renderOption !== void 0 ? renderOption?.(option, { selected }) : /* @__PURE__ */ (0, import_jsx_runtime322.jsx)("div", { className: cn(selected && "font-medium"), children: option.label }) })
12437
+ children: /* @__PURE__ */ (0, import_jsx_runtime322.jsx)("div", { className: "flex-1", children: renderOption !== void 0 && renderOption !== null ? renderOption?.(option, { selected }) : /* @__PURE__ */ (0, import_jsx_runtime322.jsx)("div", { className: cn(selected && "font-medium"), children: option.label }) })
12381
12438
  },
12382
12439
  option.value
12383
12440
  );