@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.js CHANGED
@@ -10574,7 +10574,8 @@ function DaysOfWeek({
10574
10574
  size = "md",
10575
10575
  wrapperClassName,
10576
10576
  variant = "default",
10577
- type = "month"
10577
+ type = "month",
10578
+ renderItem
10578
10579
  }) {
10579
10580
  return /* @__PURE__ */ jsxs44(
10580
10581
  "div",
@@ -10590,11 +10591,11 @@ function DaysOfWeek({
10590
10591
  wrapperClassName
10591
10592
  ),
10592
10593
  children: [
10593
- type === "week" && variant === "default" && /* @__PURE__ */ jsxs44(Fragment7, { children: [
10594
+ type === "week" && variant === "default" && renderItem === void 0 && /* @__PURE__ */ jsxs44(Fragment7, { children: [
10594
10595
  /* @__PURE__ */ jsx313("div", {}),
10595
10596
  daysOfWeek.map((day) => /* @__PURE__ */ jsx313(Text, { as: "h5", value: day, variant: "t1" }, day))
10596
10597
  ] }),
10597
- type === "month" && daysOfWeek.map((day) => /* @__PURE__ */ jsx313(
10598
+ type === "month" && renderItem === void 0 && daysOfWeek.map((day) => /* @__PURE__ */ jsx313(
10598
10599
  Text,
10599
10600
  {
10600
10601
  as: "h5",
@@ -10692,6 +10693,14 @@ var Calendar2 = ({
10692
10693
  const [selectedTypeIndex, setSelectedTypeIndex] = useState10(
10693
10694
  null
10694
10695
  );
10696
+ const [currentWeekStart, setCurrentWeekStart] = useState10(() => {
10697
+ const today = /* @__PURE__ */ new Date();
10698
+ const day = today.getDay();
10699
+ const start = new Date(today);
10700
+ start.setDate(today.getDate() - day);
10701
+ start.setHours(0, 0, 0, 0);
10702
+ return start;
10703
+ });
10695
10704
  const calendarDays = getCalendarDays({ currentMonth, currentYear });
10696
10705
  const calendarHelpers = createCalendarHelpers({
10697
10706
  disabledDates,
@@ -10720,6 +10729,24 @@ var Calendar2 = ({
10720
10729
  }
10721
10730
  onChange?.(day.fullDate);
10722
10731
  };
10732
+ const getWeekDaysLabel = (weekStart) => {
10733
+ return Array.from({ length: 7 }, (_, i) => {
10734
+ const d = new Date(weekStart);
10735
+ d.setDate(weekStart.getDate() + i);
10736
+ const dayName = daysOfWeek[d.getDay()];
10737
+ const date = d.getDate();
10738
+ return `${dayName} ${date}`;
10739
+ });
10740
+ };
10741
+ const changeWeek = (delta) => {
10742
+ setCurrentWeekStart((prev) => {
10743
+ const next = new Date(prev);
10744
+ next.setDate(prev.getDate() + delta * 7);
10745
+ setCurrentMonth(next.getMonth());
10746
+ setCurrentYear(next.getFullYear());
10747
+ return next;
10748
+ });
10749
+ };
10723
10750
  const changeMonth = (delta) => {
10724
10751
  let newMonth = currentMonth + delta;
10725
10752
  let newYear = currentYear;
@@ -10733,6 +10760,22 @@ var Calendar2 = ({
10733
10760
  setCurrentMonth(newMonth);
10734
10761
  setCurrentYear(newYear);
10735
10762
  };
10763
+ const handleNavigationDefault = (type2, action) => {
10764
+ if (type2 === "month") {
10765
+ if (action === "next") {
10766
+ return changeMonth(-1);
10767
+ } else {
10768
+ return changeMonth(1);
10769
+ }
10770
+ }
10771
+ if (type2 === "week") {
10772
+ if (action === "next") {
10773
+ return changeWeek(1);
10774
+ } else {
10775
+ return changeWeek(-1);
10776
+ }
10777
+ }
10778
+ };
10736
10779
  useEffect7(() => {
10737
10780
  if (value !== void 0) {
10738
10781
  setCurrentMonth(
@@ -10752,8 +10795,20 @@ var Calendar2 = ({
10752
10795
  variant === "default" && /* @__PURE__ */ jsxs45("div", { className: "flex items-center justify-between", children: [
10753
10796
  /* @__PURE__ */ jsxs45("div", { className: "flex items-center gap-6", children: [
10754
10797
  /* @__PURE__ */ jsxs45("div", { className: "*:cursor-pointer", children: [
10755
- /* @__PURE__ */ jsx314(ButtonNavigation, { onClick: () => changeMonth(-1), type: "prev" }),
10756
- /* @__PURE__ */ jsx314(ButtonNavigation, { onClick: () => changeMonth(1), type: "next" })
10798
+ /* @__PURE__ */ jsx314(
10799
+ ButtonNavigation,
10800
+ {
10801
+ onClick: () => handleNavigationDefault(selectedType, "prev"),
10802
+ type: "prev"
10803
+ }
10804
+ ),
10805
+ /* @__PURE__ */ jsx314(
10806
+ ButtonNavigation,
10807
+ {
10808
+ onClick: () => handleNavigationDefault(selectedType, "next"),
10809
+ type: "next"
10810
+ }
10811
+ )
10757
10812
  ] }),
10758
10813
  /* @__PURE__ */ jsxs45(
10759
10814
  Text,
@@ -10777,6 +10832,7 @@ var Calendar2 = ({
10777
10832
  color: "gray",
10778
10833
  variant: "outline",
10779
10834
  className: "capitalize",
10835
+ onClick: () => setCurrentMonth((/* @__PURE__ */ new Date()).getMonth()),
10780
10836
  children: "Today"
10781
10837
  }
10782
10838
  ),
@@ -10838,7 +10894,7 @@ var Calendar2 = ({
10838
10894
  type: "week",
10839
10895
  size,
10840
10896
  variant,
10841
- daysOfWeek,
10897
+ daysOfWeek: getWeekDaysLabel(currentWeekStart),
10842
10898
  wrapperClassName: weekWrapperClassname
10843
10899
  }
10844
10900
  ) }),
@@ -12133,7 +12189,8 @@ var Select = ({
12133
12189
  }
12134
12190
  }, [isOpen, isSearchable]);
12135
12191
  const getDisplayValue = () => {
12136
- if (value !== null || value !== void 0 || isMulti && asArray(value).length === 0) {
12192
+ const isEmpty = value == null || isMulti && asArray(value).length === 0;
12193
+ if (isEmpty) {
12137
12194
  return /* @__PURE__ */ jsx322("span", { className: "text-gray-500", children: placeholder });
12138
12195
  }
12139
12196
  if (isMulti) {
@@ -12142,7 +12199,7 @@ var Select = ({
12142
12199
  {
12143
12200
  className: "border-primary-200 flex items-center gap-1 rounded border bg-white px-2 py-0.5 text-xs text-gray-900",
12144
12201
  children: [
12145
- renderValue !== void 0 ? renderValue?.(item) : item.label,
12202
+ renderValue !== void 0 && renderValue !== null ? renderValue?.(item) : item.label,
12146
12203
  /* @__PURE__ */ jsx322(
12147
12204
  "button",
12148
12205
  {
@@ -12156,7 +12213,7 @@ var Select = ({
12156
12213
  item.value
12157
12214
  )) });
12158
12215
  }
12159
- return renderValue !== void 0 ? renderValue?.(value) : value.label;
12216
+ return renderValue !== void 0 && renderValue !== null ? renderValue?.(value) : value.label;
12160
12217
  };
12161
12218
  const showClearButton = isClearable && (isMulti && asArray(value).length > 0 || !isMulti && value !== null);
12162
12219
  const hasError = fieldHasError(errorMessages);
@@ -12257,7 +12314,7 @@ var Select = ({
12257
12314
  highlighted && "bg-primary-100",
12258
12315
  selected ? "bg-primary-50 border-primary-300" : "hover:bg-gray-50"
12259
12316
  ),
12260
- children: /* @__PURE__ */ jsx322("div", { className: "flex-1", children: renderOption !== void 0 ? renderOption?.(option, { selected }) : /* @__PURE__ */ jsx322("div", { className: cn(selected && "font-medium"), children: option.label }) })
12317
+ children: /* @__PURE__ */ jsx322("div", { className: "flex-1", children: renderOption !== void 0 && renderOption !== null ? renderOption?.(option, { selected }) : /* @__PURE__ */ jsx322("div", { className: cn(selected && "font-medium"), children: option.label }) })
12261
12318
  },
12262
12319
  option.value
12263
12320
  );