@herca/r-kit 0.0.20 → 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
@@ -10206,7 +10206,7 @@ function createDateStyleHelpers({
10206
10206
  // src/components/calendar/partials/calendar-day-item.tsx
10207
10207
  var import_jsx_runtime308 = require("react/jsx-runtime");
10208
10208
  var date_size_map = {
10209
- md: "size-9",
10209
+ md: "size-7.5",
10210
10210
  sm: "size-6",
10211
10211
  lg: "size-9"
10212
10212
  };
@@ -10418,70 +10418,80 @@ function CalendarGrid({
10418
10418
  { length: Math.ceil(days2.length / 7) },
10419
10419
  (_, i) => days2.slice(i * 7, i * 7 + 7)
10420
10420
  );
10421
- return /* @__PURE__ */ (0, import_jsx_runtime310.jsx)("div", { className: "relative", children: weeks.map((week, weekIndex) => {
10422
- const segments = getWeekEventSegments({
10423
- week,
10424
- events
10425
- });
10426
- const columnEventCount = Array(7).fill(0);
10427
- segments.forEach((seg) => {
10428
- for (let i = 0; i < seg.span; i++) {
10429
- const colIndex = seg.startCol + i;
10430
- if (colIndex >= 0 && colIndex < 7) {
10431
- columnEventCount[colIndex]++;
10432
- }
10433
- }
10434
- });
10435
- return /* @__PURE__ */ (0, import_jsx_runtime310.jsxs)(
10436
- "div",
10437
- {
10438
- className: (0, import_clsx5.default)(
10439
- "relative",
10440
- variant === "default" && "border-b border-gray-300 last:border-b-0!",
10441
- //prettier-ignore
10442
- className
10443
- ),
10444
- children: [
10445
- /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(
10446
- "div",
10447
- {
10448
- className: (0, import_clsx5.default)(
10449
- "grid w-full grid-cols-7",
10450
- variant === "default" && "*:border-r *:border-gray-300 [&>*:nth-last-child(1)]:border-r-0"
10451
- //prettier-ignore
10452
- ),
10453
- children: week.map((day, dayIndex) => /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(
10454
- CalendarDayItem,
10455
- {
10456
- day,
10457
- helpers,
10458
- size,
10459
- mode,
10460
- styleConfig,
10461
- onClick,
10462
- variant,
10463
- events
10464
- },
10465
- dayIndex
10466
- ))
10421
+ return /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(
10422
+ "div",
10423
+ {
10424
+ className: (0, import_clsx5.default)(
10425
+ "relative",
10426
+ variant === "compact" && size === "sm" && "space-y-1"
10427
+ ),
10428
+ children: weeks.map((week, weekIndex) => {
10429
+ const segments = getWeekEventSegments({
10430
+ week,
10431
+ events
10432
+ });
10433
+ const columnEventCount = Array(7).fill(0);
10434
+ segments.forEach((seg) => {
10435
+ for (let i = 0; i < seg.span; i++) {
10436
+ const colIndex = seg.startCol + i;
10437
+ if (colIndex >= 0 && colIndex < 7) {
10438
+ columnEventCount[colIndex]++;
10467
10439
  }
10468
- ),
10469
- segments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime310.jsxs)("div", { className: "absolute inset-x-0 bottom-2 grid grid-cols-7 gap-0.5", children: [
10470
- segments.slice(0, isMobile ? 1 : 2).map((seg, index) => /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(
10471
- EventBar,
10472
- {
10473
- segment: seg,
10474
- showTooltip: showCalendarTooltip
10475
- },
10476
- index
10477
- )),
10478
- /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(ButtonMore, { segments })
10479
- ] })
10480
- ]
10481
- },
10482
- weekIndex
10483
- );
10484
- }) });
10440
+ }
10441
+ });
10442
+ return /* @__PURE__ */ (0, import_jsx_runtime310.jsxs)(
10443
+ "div",
10444
+ {
10445
+ className: (0, import_clsx5.default)(
10446
+ "relative",
10447
+ variant === "default" && "border-b border-gray-300 last:border-b-0!",
10448
+ //prettier-ignore
10449
+ className
10450
+ ),
10451
+ children: [
10452
+ /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(
10453
+ "div",
10454
+ {
10455
+ className: (0, import_clsx5.default)(
10456
+ "grid w-full grid-cols-7",
10457
+ variant === "default" && "*:border-r *:border-gray-300 [&>*:nth-last-child(1)]:border-r-0",
10458
+ //prettier-ignore
10459
+ variant === "compact" && "place-items-center"
10460
+ ),
10461
+ children: week.map((day, dayIndex) => /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(
10462
+ CalendarDayItem,
10463
+ {
10464
+ day,
10465
+ helpers,
10466
+ size,
10467
+ mode,
10468
+ styleConfig,
10469
+ onClick,
10470
+ variant,
10471
+ events
10472
+ },
10473
+ dayIndex
10474
+ ))
10475
+ }
10476
+ ),
10477
+ segments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime310.jsxs)("div", { className: "absolute inset-x-0 bottom-2 grid grid-cols-7 gap-0.5", children: [
10478
+ segments.slice(0, isMobile ? 1 : 2).map((seg, index) => /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(
10479
+ EventBar,
10480
+ {
10481
+ segment: seg,
10482
+ showTooltip: showCalendarTooltip
10483
+ },
10484
+ index
10485
+ )),
10486
+ /* @__PURE__ */ (0, import_jsx_runtime310.jsx)(ButtonMore, { segments })
10487
+ ] })
10488
+ ]
10489
+ },
10490
+ weekIndex
10491
+ );
10492
+ })
10493
+ }
10494
+ );
10485
10495
  }
10486
10496
 
10487
10497
  // src/components/calendar/partials/calendar-header.tsx
@@ -10679,7 +10689,7 @@ function NavigatorButton({
10679
10689
  var import_clsx6 = __toESM(require("clsx"), 1);
10680
10690
  var import_jsx_runtime313 = require("react/jsx-runtime");
10681
10691
  var day_of_week_size = {
10682
- sm: "t3",
10692
+ sm: "t2",
10683
10693
  md: "t2",
10684
10694
  lg: "t1"
10685
10695
  };
@@ -10687,38 +10697,75 @@ function DaysOfWeek({
10687
10697
  daysOfWeek,
10688
10698
  size = "md",
10689
10699
  wrapperClassName,
10690
- variant = "default"
10700
+ variant = "default",
10701
+ type = "month",
10702
+ renderItem
10691
10703
  }) {
10692
- return /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
10704
+ return /* @__PURE__ */ (0, import_jsx_runtime313.jsxs)(
10693
10705
  "div",
10694
10706
  {
10695
10707
  className: (0, import_clsx6.default)(
10696
10708
  "grid justify-items-center",
10697
10709
  variant === "compact" && "calendar-cols mb-3 gap-x-1 *:text-center!",
10698
- variant === "default" && "w-full grid-cols-7 bg-gray-100 *:p-3 *:w-full *:text-start! *:border-r *:border-gray-300 *:last:border-r-0",
10710
+ variant === "default" && "w-full bg-gray-100 *:p-3 *:w-full *:text-start! *:border-r *:border-gray-300 *:last:border-r-0",
10711
+ //prettier-ignore
10712
+ variant === "default" && type === "month" && "grid-cols-7",
10713
+ variant === "default" && type === "week" && "grid-cols-[60px_1fr_1fr_1fr_1fr_1fr_1fr_1fr]",
10699
10714
  //prettier-ignore
10700
10715
  wrapperClassName
10701
10716
  ),
10702
- children: daysOfWeek.map((day) => /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
10703
- Text,
10704
- {
10705
- as: "h5",
10706
- weight: variant === "compact" ? "medium" : "semibold",
10707
- value: day,
10708
- className: (0, import_clsx6.default)(
10709
- variant === "compact" && "text-gray-600!",
10710
- variant === "default" && "text-gray-900! uppercase"
10711
- ),
10712
- variant: variant === "compact" ? day_of_week_size[size] : "t1"
10713
- },
10714
- day
10715
- ))
10717
+ children: [
10718
+ type === "week" && variant === "default" && renderItem === void 0 && /* @__PURE__ */ (0, import_jsx_runtime313.jsxs)(import_jsx_runtime313.Fragment, { children: [
10719
+ /* @__PURE__ */ (0, import_jsx_runtime313.jsx)("div", {}),
10720
+ daysOfWeek.map((day) => /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(Text, { as: "h5", value: day, variant: "t1" }, day))
10721
+ ] }),
10722
+ type === "month" && renderItem === void 0 && daysOfWeek.map((day) => /* @__PURE__ */ (0, import_jsx_runtime313.jsx)(
10723
+ Text,
10724
+ {
10725
+ as: "h5",
10726
+ weight: variant === "compact" ? "medium" : "semibold",
10727
+ value: day,
10728
+ className: (0, import_clsx6.default)(
10729
+ variant === "compact" && "text-gray-600!",
10730
+ variant === "default" && "text-gray-900! uppercase"
10731
+ ),
10732
+ variant: variant === "compact" ? day_of_week_size[size] : "t1"
10733
+ },
10734
+ day
10735
+ ))
10736
+ ]
10716
10737
  }
10717
10738
  );
10718
10739
  }
10719
10740
 
10720
10741
  // src/components/calendar/calendar.tsx
10721
10742
  var import_clsx7 = __toESM(require("clsx"), 1);
10743
+
10744
+ // src/components/calendar/constants.tsx
10745
+ var typeOptions = [
10746
+ {
10747
+ label: "Year",
10748
+ value: "year"
10749
+ },
10750
+ {
10751
+ label: "Month",
10752
+ value: "month"
10753
+ },
10754
+ {
10755
+ label: "Week",
10756
+ value: "week"
10757
+ },
10758
+ {
10759
+ label: "Day",
10760
+ value: "day"
10761
+ },
10762
+ {
10763
+ label: "Agenda",
10764
+ value: "agenda"
10765
+ }
10766
+ ];
10767
+
10768
+ // src/components/calendar/calendar.tsx
10722
10769
  var import_jsx_runtime314 = require("react/jsx-runtime");
10723
10770
  var days = ["Min", "Sen", "Sel", "Rab", "Kam", "Jum", "Sab"];
10724
10771
  var month = [
@@ -10770,6 +10817,14 @@ var Calendar2 = ({
10770
10817
  const [selectedTypeIndex, setSelectedTypeIndex] = (0, import_react295.useState)(
10771
10818
  null
10772
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
+ });
10773
10828
  const calendarDays = getCalendarDays({ currentMonth, currentYear });
10774
10829
  const calendarHelpers = createCalendarHelpers({
10775
10830
  disabledDates,
@@ -10798,6 +10853,24 @@ var Calendar2 = ({
10798
10853
  }
10799
10854
  onChange?.(day.fullDate);
10800
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
+ };
10801
10874
  const changeMonth = (delta) => {
10802
10875
  let newMonth = currentMonth + delta;
10803
10876
  let newYear = currentYear;
@@ -10811,28 +10884,22 @@ var Calendar2 = ({
10811
10884
  setCurrentMonth(newMonth);
10812
10885
  setCurrentYear(newYear);
10813
10886
  };
10814
- const typeOptions = [
10815
- {
10816
- label: "Year",
10817
- value: "year"
10818
- },
10819
- {
10820
- label: "Month",
10821
- value: "month"
10822
- },
10823
- {
10824
- label: "Week",
10825
- value: "week"
10826
- },
10827
- {
10828
- label: "Day",
10829
- value: "day"
10830
- },
10831
- {
10832
- label: "Agenda",
10833
- value: "agenda"
10887
+ const handleNavigationDefault = (type2, action) => {
10888
+ if (type2 === "month") {
10889
+ if (action === "next") {
10890
+ return changeMonth(-1);
10891
+ } else {
10892
+ return changeMonth(1);
10893
+ }
10834
10894
  }
10835
- ];
10895
+ if (type2 === "week") {
10896
+ if (action === "next") {
10897
+ return changeWeek(1);
10898
+ } else {
10899
+ return changeWeek(-1);
10900
+ }
10901
+ }
10902
+ };
10836
10903
  (0, import_react295.useEffect)(() => {
10837
10904
  if (value !== void 0) {
10838
10905
  setCurrentMonth(
@@ -10852,22 +10919,20 @@ var Calendar2 = ({
10852
10919
  variant === "default" && /* @__PURE__ */ (0, import_jsx_runtime314.jsxs)("div", { className: "flex items-center justify-between", children: [
10853
10920
  /* @__PURE__ */ (0, import_jsx_runtime314.jsxs)("div", { className: "flex items-center gap-6", children: [
10854
10921
  /* @__PURE__ */ (0, import_jsx_runtime314.jsxs)("div", { className: "*:cursor-pointer", children: [
10855
- /* @__PURE__ */ (0, import_jsx_runtime314.jsx)("button", { onClick: () => changeMonth(-1), children: /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
10856
- Icon_default,
10922
+ /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
10923
+ ButtonNavigation,
10857
10924
  {
10858
- name: "angle-left-small",
10859
- size: 30,
10860
- className: "text-gray-900"
10925
+ onClick: () => handleNavigationDefault(selectedType, "prev"),
10926
+ type: "prev"
10861
10927
  }
10862
- ) }),
10863
- /* @__PURE__ */ (0, import_jsx_runtime314.jsx)("button", { onClick: () => changeMonth(1), children: /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
10864
- Icon_default,
10928
+ ),
10929
+ /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
10930
+ ButtonNavigation,
10865
10931
  {
10866
- name: "angle-right-small",
10867
- size: 30,
10868
- className: "text-gray-900"
10932
+ onClick: () => handleNavigationDefault(selectedType, "next"),
10933
+ type: "next"
10869
10934
  }
10870
- ) })
10935
+ )
10871
10936
  ] }),
10872
10937
  /* @__PURE__ */ (0, import_jsx_runtime314.jsxs)(
10873
10938
  Text,
@@ -10891,6 +10956,7 @@ var Calendar2 = ({
10891
10956
  color: "gray",
10892
10957
  variant: "outline",
10893
10958
  className: "capitalize",
10959
+ onClick: () => setCurrentMonth((/* @__PURE__ */ new Date()).getMonth()),
10894
10960
  children: "Today"
10895
10961
  }
10896
10962
  ),
@@ -10946,6 +11012,16 @@ var Calendar2 = ({
10946
11012
  wrapperClassname
10947
11013
  ),
10948
11014
  children: [
11015
+ selectedType === "week" && /* @__PURE__ */ (0, import_jsx_runtime314.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
11016
+ DaysOfWeek,
11017
+ {
11018
+ type: "week",
11019
+ size,
11020
+ variant,
11021
+ daysOfWeek: getWeekDaysLabel(currentWeekStart),
11022
+ wrapperClassName: weekWrapperClassname
11023
+ }
11024
+ ) }),
10949
11025
  type === "year" && /* @__PURE__ */ (0, import_jsx_runtime314.jsx)("div", { className: "grid w-full grid-cols-3", children: /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
10950
11026
  CalendarGrid,
10951
11027
  {
@@ -11006,6 +11082,19 @@ var Calendar2 = ({
11006
11082
  )
11007
11083
  ] });
11008
11084
  };
11085
+ var ButtonNavigation = ({
11086
+ onClick,
11087
+ type
11088
+ }) => {
11089
+ return /* @__PURE__ */ (0, import_jsx_runtime314.jsx)("button", { onClick, children: /* @__PURE__ */ (0, import_jsx_runtime314.jsx)(
11090
+ Icon_default,
11091
+ {
11092
+ name: type === "next" ? "angle-right-small" : "angle-left-small",
11093
+ size: 30,
11094
+ className: "text-gray-900"
11095
+ }
11096
+ ) });
11097
+ };
11009
11098
 
11010
11099
  // src/components/date-picker/helpers.ts
11011
11100
  var monthsShort = [
@@ -12220,7 +12309,8 @@ var Select = ({
12220
12309
  }
12221
12310
  }, [isOpen, isSearchable]);
12222
12311
  const getDisplayValue = () => {
12223
- if (value !== null || value !== void 0 || isMulti && asArray(value).length === 0) {
12312
+ const isEmpty = value == null || isMulti && asArray(value).length === 0;
12313
+ if (isEmpty) {
12224
12314
  return /* @__PURE__ */ (0, import_jsx_runtime322.jsx)("span", { className: "text-gray-500", children: placeholder });
12225
12315
  }
12226
12316
  if (isMulti) {
@@ -12229,7 +12319,7 @@ var Select = ({
12229
12319
  {
12230
12320
  className: "border-primary-200 flex items-center gap-1 rounded border bg-white px-2 py-0.5 text-xs text-gray-900",
12231
12321
  children: [
12232
- renderValue !== void 0 ? renderValue?.(item) : item.label,
12322
+ renderValue !== void 0 && renderValue !== null ? renderValue?.(item) : item.label,
12233
12323
  /* @__PURE__ */ (0, import_jsx_runtime322.jsx)(
12234
12324
  "button",
12235
12325
  {
@@ -12243,7 +12333,7 @@ var Select = ({
12243
12333
  item.value
12244
12334
  )) });
12245
12335
  }
12246
- return renderValue !== void 0 ? renderValue?.(value) : value.label;
12336
+ return renderValue !== void 0 && renderValue !== null ? renderValue?.(value) : value.label;
12247
12337
  };
12248
12338
  const showClearButton = isClearable && (isMulti && asArray(value).length > 0 || !isMulti && value !== null);
12249
12339
  const hasError = fieldHasError(errorMessages);
@@ -12344,7 +12434,7 @@ var Select = ({
12344
12434
  highlighted && "bg-primary-100",
12345
12435
  selected ? "bg-primary-50 border-primary-300" : "hover:bg-gray-50"
12346
12436
  ),
12347
- 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 }) })
12348
12438
  },
12349
12439
  option.value
12350
12440
  );