@kalyx/react 1.0.0-rc.0 → 1.0.0-rc.1

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.cts CHANGED
@@ -674,7 +674,7 @@ interface MonthPickerGridClassNames {
674
674
  monthCurrent?: string;
675
675
  monthDisabled?: string;
676
676
  }
677
- interface MonthPickerGridProps extends Omit<HTMLAttributes<HTMLDivElement>, "role"> {
677
+ interface MonthPickerGridProps extends Omit<HTMLAttributes<HTMLDivElement>, 'role'> {
678
678
  classNames?: MonthPickerGridClassNames;
679
679
  }
680
680
  /**
package/dist/index.d.ts CHANGED
@@ -674,7 +674,7 @@ interface MonthPickerGridClassNames {
674
674
  monthCurrent?: string;
675
675
  monthDisabled?: string;
676
676
  }
677
- interface MonthPickerGridProps extends Omit<HTMLAttributes<HTMLDivElement>, "role"> {
677
+ interface MonthPickerGridProps extends Omit<HTMLAttributes<HTMLDivElement>, 'role'> {
678
678
  classNames?: MonthPickerGridClassNames;
679
679
  }
680
680
  /**
package/dist/index.js CHANGED
@@ -301,10 +301,15 @@ var DatePickerTrigger = forwardRef(
301
301
  );
302
302
  }
303
303
  );
304
- function usePopover({ isOpen, close, referenceRef, placement = "bottom-start" }) {
304
+ function usePopover({
305
+ isOpen,
306
+ close,
307
+ referenceRef,
308
+ placement = "bottom-start"
309
+ }) {
305
310
  const floatingRef = useRef(null);
306
311
  const previousFocusRef = useRef(null);
307
- const { refs, floatingStyles } = useFloating({
312
+ const { refs, floatingStyles, isPositioned } = useFloating({
308
313
  open: isOpen,
309
314
  placement,
310
315
  middleware: [offset(4), flip(), shift({ padding: 8 })],
@@ -354,21 +359,28 @@ function usePopover({ isOpen, close, referenceRef, placement = "bottom-start" })
354
359
  document.addEventListener("keydown", handleKeyDown);
355
360
  return () => document.removeEventListener("keydown", handleKeyDown);
356
361
  }, [isOpen, close]);
357
- const setFloatingRef = (node) => {
358
- floatingRef.current = node;
359
- refs.setFloating(node);
360
- };
361
- return { floatingStyles, setFloatingRef };
362
+ const setFloatingRef = useCallback(
363
+ (node) => {
364
+ floatingRef.current = node;
365
+ refs.setFloating(node);
366
+ if (node && referenceRef.current) {
367
+ refs.setReference(referenceRef.current);
368
+ }
369
+ },
370
+ [refs, referenceRef]
371
+ );
372
+ return { floatingStyles, setFloatingRef, isPositioned };
362
373
  }
363
374
  function DatePickerPopover({ children, ...props }) {
364
375
  const ctx = useDatePickerContext("DatePicker.Popover");
365
376
  const calendarId = `${ctx.pickerId}-calendar`;
366
- const { floatingStyles, setFloatingRef } = usePopover({
377
+ const { floatingStyles, setFloatingRef, isPositioned } = usePopover({
367
378
  isOpen: ctx.isOpen,
368
379
  close: ctx.close,
369
380
  referenceRef: ctx.referenceRef
370
381
  });
371
382
  if (!ctx.isOpen) return null;
383
+ const { style: userStyle, ...rest } = props;
372
384
  return /* @__PURE__ */ jsx(
373
385
  "div",
374
386
  {
@@ -377,8 +389,12 @@ function DatePickerPopover({ children, ...props }) {
377
389
  role: "dialog",
378
390
  "aria-label": ctx.labels.popoverLabel,
379
391
  "aria-modal": "false",
380
- style: floatingStyles,
381
- ...props,
392
+ ...rest,
393
+ style: {
394
+ ...userStyle,
395
+ ...floatingStyles,
396
+ visibility: isPositioned ? void 0 : "hidden"
397
+ },
382
398
  children
383
399
  }
384
400
  );
@@ -401,7 +417,11 @@ var srOnly = {
401
417
  whiteSpace: "nowrap",
402
418
  border: 0
403
419
  };
404
- function DatePickerCalendar({ classNames, onTitleClick, ...props }) {
420
+ function DatePickerCalendar({
421
+ classNames,
422
+ onTitleClick,
423
+ ...props
424
+ }) {
405
425
  const ctx = useDatePickerContext("DatePicker.Calendar");
406
426
  const gridRef = useRef(null);
407
427
  const [announcement, setAnnouncement] = useState("");
@@ -419,9 +439,7 @@ function DatePickerCalendar({ classNames, onTitleClick, ...props }) {
419
439
  const title = formatMonthYear(year, month, locale);
420
440
  useEffect(() => {
421
441
  if (!ctx.isOpen || !gridRef.current) return;
422
- const focusedButton = gridRef.current.querySelector(
423
- '[data-focused="true"]'
424
- );
442
+ const focusedButton = gridRef.current.querySelector('[data-focused="true"]');
425
443
  focusedButton?.focus({ preventScroll: true });
426
444
  }, [focusedDate, ctx.isOpen]);
427
445
  const navigateMonth = useCallback(
@@ -644,15 +662,7 @@ function DatePickerMonthGrid({
644
662
  children: "<"
645
663
  }
646
664
  ),
647
- onTitleClick ? /* @__PURE__ */ jsx(
648
- "button",
649
- {
650
- type: "button",
651
- className: classNames?.title,
652
- onClick: onTitleClick,
653
- children: currentYear
654
- }
655
- ) : /* @__PURE__ */ jsx("span", { className: classNames?.title, children: currentYear }),
665
+ onTitleClick ? /* @__PURE__ */ jsx("button", { type: "button", className: classNames?.title, onClick: onTitleClick, children: currentYear }) : /* @__PURE__ */ jsx("span", { className: classNames?.title, children: currentYear }),
656
666
  /* @__PURE__ */ jsx(
657
667
  "button",
658
668
  {
@@ -697,11 +707,7 @@ function DatePickerMonthGrid({
697
707
  )
698
708
  ] });
699
709
  }
700
- function DatePickerYearGrid({
701
- classNames,
702
- onSelect,
703
- ...props
704
- }) {
710
+ function DatePickerYearGrid({ classNames, onSelect, ...props }) {
705
711
  const ctx = useDatePickerContext("DatePicker.YearGrid");
706
712
  const { adapter, viewMonth } = ctx;
707
713
  const currentYear = adapter.getYear(viewMonth);
@@ -795,16 +801,7 @@ function DatePickerYearGrid({
795
801
  }
796
802
  function DatePickerPresets({ classNames, children, ...props }) {
797
803
  const ctx = useDatePickerContext("DatePicker.Presets");
798
- return /* @__PURE__ */ jsx(
799
- "div",
800
- {
801
- role: "group",
802
- "aria-label": ctx.labels.popoverLabel,
803
- className: classNames?.root,
804
- ...props,
805
- children
806
- }
807
- );
804
+ return /* @__PURE__ */ jsx("div", { role: "group", "aria-label": ctx.labels.popoverLabel, className: classNames?.root, ...props, children });
808
805
  }
809
806
  function resolveDatePreset(key, today, adapter) {
810
807
  switch (key) {
@@ -858,11 +855,7 @@ function DatePickerPreset({
858
855
  if (directDate) {
859
856
  target = directDate;
860
857
  } else if (presetKey) {
861
- target = resolveDatePreset(
862
- presetKey,
863
- ctx.adapter.today(ctx.displayTimezone),
864
- ctx.adapter
865
- );
858
+ target = resolveDatePreset(presetKey, ctx.adapter.today(ctx.displayTimezone), ctx.adapter);
866
859
  } else {
867
860
  return false;
868
861
  }
@@ -1129,12 +1122,13 @@ var RangePickerInput = forwardRef(
1129
1122
  function RangePickerPopover({ children, ...props }) {
1130
1123
  const ctx = useRangePickerContext("RangePicker.Popover");
1131
1124
  const calendarId = `${ctx.pickerId}-calendar`;
1132
- const { floatingStyles, setFloatingRef } = usePopover({
1125
+ const { floatingStyles, setFloatingRef, isPositioned } = usePopover({
1133
1126
  isOpen: ctx.isOpen,
1134
1127
  close: ctx.close,
1135
1128
  referenceRef: ctx.referenceRef
1136
1129
  });
1137
1130
  if (!ctx.isOpen) return null;
1131
+ const { style: userStyle, ...rest } = props;
1138
1132
  return /* @__PURE__ */ jsx(
1139
1133
  "div",
1140
1134
  {
@@ -1143,8 +1137,12 @@ function RangePickerPopover({ children, ...props }) {
1143
1137
  role: "dialog",
1144
1138
  "aria-label": ctx.labels.popoverLabel,
1145
1139
  "aria-modal": "false",
1146
- style: floatingStyles,
1147
- ...props,
1140
+ ...rest,
1141
+ style: {
1142
+ ...userStyle,
1143
+ ...floatingStyles,
1144
+ visibility: isPositioned ? void 0 : "hidden"
1145
+ },
1148
1146
  children
1149
1147
  }
1150
1148
  );
@@ -1201,9 +1199,7 @@ function RangePickerCalendar({
1201
1199
  const title = formatMonthYear(year, month, locale);
1202
1200
  useEffect(() => {
1203
1201
  if (!ctx.isOpen || !gridRef.current) return;
1204
- const focusedButton = gridRef.current.querySelector(
1205
- '[data-focused="true"]'
1206
- );
1202
+ const focusedButton = gridRef.current.querySelector('[data-focused="true"]');
1207
1203
  focusedButton?.focus({ preventScroll: true });
1208
1204
  }, [focusedDate, ctx.isOpen]);
1209
1205
  const navigateMonth = useCallback(
@@ -1306,7 +1302,18 @@ function RangePickerCalendar({
1306
1302
  }
1307
1303
  }
1308
1304
  },
1309
- [adapter, focusedDate, viewMonth, weekStartsOn, disabled, ctx, selectionMode, selectingTarget, value.start, commitDay]
1305
+ [
1306
+ adapter,
1307
+ focusedDate,
1308
+ viewMonth,
1309
+ weekStartsOn,
1310
+ disabled,
1311
+ ctx,
1312
+ selectionMode,
1313
+ selectingTarget,
1314
+ value.start,
1315
+ commitDay
1316
+ ]
1310
1317
  );
1311
1318
  return /* @__PURE__ */ jsxs("div", { className: classNames?.root, ...props, onMouseLeave: handleMouseLeave, children: [
1312
1319
  /* @__PURE__ */ jsxs("div", { className: classNames?.header, children: [
@@ -1443,9 +1450,7 @@ function resolvePreset(key, today, adapter) {
1443
1450
  }
1444
1451
  case "thisYear": {
1445
1452
  const currentMonth = new Date(today).getUTCMonth();
1446
- const yearStart = adapter.startOfMonth(
1447
- adapter.addMonths(today, -currentMonth)
1448
- );
1453
+ const yearStart = adapter.startOfMonth(adapter.addMonths(today, -currentMonth));
1449
1454
  return { start: yearStart, end: today };
1450
1455
  }
1451
1456
  }
@@ -1581,7 +1586,19 @@ function TimePickerRoot({
1581
1586
  pickerId,
1582
1587
  labels: mergedLabels
1583
1588
  }),
1584
- [currentValue, setTime$1, format, step, withSeconds, displayTimezone, disabled, readOnly, currentTime, pickerId, mergedLabels]
1589
+ [
1590
+ currentValue,
1591
+ setTime$1,
1592
+ format,
1593
+ step,
1594
+ withSeconds,
1595
+ displayTimezone,
1596
+ disabled,
1597
+ readOnly,
1598
+ currentTime,
1599
+ pickerId,
1600
+ mergedLabels
1601
+ ]
1585
1602
  );
1586
1603
  return /* @__PURE__ */ jsx(TimePickerContext.Provider, { value: contextValue, children });
1587
1604
  }
@@ -1598,12 +1615,9 @@ var TimePickerInput = forwardRef(
1598
1615
  }
1599
1616
  setInputText(null);
1600
1617
  }, [inputText, ctx]);
1601
- const handleChange = useCallback(
1602
- (e) => {
1603
- setInputText(e.target.value);
1604
- },
1605
- []
1606
- );
1618
+ const handleChange = useCallback((e) => {
1619
+ setInputText(e.target.value);
1620
+ }, []);
1607
1621
  const handleBlur = useCallback(
1608
1622
  (e) => {
1609
1623
  commitInput();
@@ -1676,9 +1690,7 @@ function useListboxNavigation({
1676
1690
  onSelect(target);
1677
1691
  cancelAnimationFrame(rafIdRef.current);
1678
1692
  rafIdRef.current = requestAnimationFrame(() => {
1679
- const next = listRef.current?.querySelector(
1680
- '[data-selected="true"]'
1681
- );
1693
+ const next = listRef.current?.querySelector('[data-selected="true"]');
1682
1694
  next?.focus();
1683
1695
  });
1684
1696
  }
@@ -1815,10 +1827,19 @@ function TimePickerAmPmToggle({ classNames, ...props }) {
1815
1827
  }
1816
1828
  );
1817
1829
  };
1818
- return /* @__PURE__ */ jsxs("div", { role: "radiogroup", "aria-label": ctx.labels.amPmToggle, className: classNames?.root, ...props, children: [
1819
- renderButton("AM"),
1820
- renderButton("PM")
1821
- ] });
1830
+ return /* @__PURE__ */ jsxs(
1831
+ "div",
1832
+ {
1833
+ role: "radiogroup",
1834
+ "aria-label": ctx.labels.amPmToggle,
1835
+ className: classNames?.root,
1836
+ ...props,
1837
+ children: [
1838
+ renderButton("AM"),
1839
+ renderButton("PM")
1840
+ ]
1841
+ }
1842
+ );
1822
1843
  }
1823
1844
 
1824
1845
  // src/components/TimePicker/index.ts
@@ -1988,7 +2009,18 @@ function DateTimePickerRoot({
1988
2009
  pickerId,
1989
2010
  labels: mergedTimeLabels
1990
2011
  }),
1991
- [currentValue, setTime$1, format, step, displayTimezone, isDisabled, readOnly, currentTime, pickerId, mergedTimeLabels]
2012
+ [
2013
+ currentValue,
2014
+ setTime$1,
2015
+ format,
2016
+ step,
2017
+ displayTimezone,
2018
+ isDisabled,
2019
+ readOnly,
2020
+ currentTime,
2021
+ pickerId,
2022
+ mergedTimeLabels
2023
+ ]
1992
2024
  );
1993
2025
  return /* @__PURE__ */ jsx(DatePickerContext.Provider, { value: dateContext, children: /* @__PURE__ */ jsx(TimePickerContext.Provider, { value: timeContext, children }) });
1994
2026
  }
@@ -2067,10 +2099,7 @@ function MonthPickerRoot(props) {
2067
2099
  const displayFormat = props.displayFormat ?? "yyyy-MM";
2068
2100
  return /* @__PURE__ */ jsx(DatePickerRoot, { ...props, displayFormat });
2069
2101
  }
2070
- function MonthPickerGrid({
2071
- classNames,
2072
- ...props
2073
- }) {
2102
+ function MonthPickerGrid({ classNames, ...props }) {
2074
2103
  const ctx = useDatePickerContext("MonthPicker.Grid");
2075
2104
  const { adapter, viewMonth, locale, value, displayTimezone, labels } = ctx;
2076
2105
  const currentYear = adapter.getYear(viewMonth);
@@ -2094,9 +2123,7 @@ function MonthPickerGrid({
2094
2123
  );
2095
2124
  const handleMonthSelect = useCallback(
2096
2125
  (monthIndex) => {
2097
- const target = new Date(
2098
- Date.UTC(currentYear, monthIndex, 1)
2099
- ).toISOString();
2126
+ const target = new Date(Date.UTC(currentYear, monthIndex, 1)).toISOString();
2100
2127
  ctx.selectDate(target);
2101
2128
  },
2102
2129
  [currentYear, ctx]
@@ -2131,45 +2158,37 @@ function MonthPickerGrid({
2131
2158
  }
2132
2159
  )
2133
2160
  ] }),
2134
- /* @__PURE__ */ jsx(
2161
+ /* @__PURE__ */ jsx("div", { role: "grid", "aria-label": `${currentYear} months`, className: classNames?.grid, children: Array.from({ length: 4 }, (_, rowIndex) => /* @__PURE__ */ jsx(
2135
2162
  "div",
2136
2163
  {
2137
- role: "grid",
2138
- "aria-label": `${currentYear} months`,
2139
- className: classNames?.grid,
2140
- children: Array.from({ length: 4 }, (_, rowIndex) => /* @__PURE__ */ jsx(
2141
- "div",
2142
- {
2143
- role: "row",
2144
- className: classNames?.gridRow,
2145
- style: { display: "grid", gridTemplateColumns: "repeat(3, 1fr)" },
2146
- children: months.slice(rowIndex * 3, rowIndex * 3 + 3).map((m) => {
2147
- const monthClass = [
2148
- classNames?.month,
2149
- m.isSelected && classNames?.monthSelected,
2150
- m.isCurrent && classNames?.monthCurrent
2151
- ].filter(Boolean).join(" ") || void 0;
2152
- return /* @__PURE__ */ jsx(
2153
- "button",
2154
- {
2155
- type: "button",
2156
- role: "gridcell",
2157
- "aria-selected": m.isSelected || void 0,
2158
- "aria-current": m.isCurrent ? "date" : void 0,
2159
- "data-selected": m.isSelected || void 0,
2160
- "data-current": m.isCurrent || void 0,
2161
- className: monthClass,
2162
- onClick: () => handleMonthSelect(m.index),
2163
- children: m.name
2164
- },
2165
- m.index
2166
- );
2167
- })
2168
- },
2169
- rowIndex
2170
- ))
2171
- }
2172
- )
2164
+ role: "row",
2165
+ className: classNames?.gridRow,
2166
+ style: { display: "grid", gridTemplateColumns: "repeat(3, 1fr)" },
2167
+ children: months.slice(rowIndex * 3, rowIndex * 3 + 3).map((m) => {
2168
+ const monthClass = [
2169
+ classNames?.month,
2170
+ m.isSelected && classNames?.monthSelected,
2171
+ m.isCurrent && classNames?.monthCurrent
2172
+ ].filter(Boolean).join(" ") || void 0;
2173
+ return /* @__PURE__ */ jsx(
2174
+ "button",
2175
+ {
2176
+ type: "button",
2177
+ role: "gridcell",
2178
+ "aria-selected": m.isSelected || void 0,
2179
+ "aria-current": m.isCurrent ? "date" : void 0,
2180
+ "data-selected": m.isSelected || void 0,
2181
+ "data-current": m.isCurrent || void 0,
2182
+ className: monthClass,
2183
+ onClick: () => handleMonthSelect(m.index),
2184
+ children: m.name
2185
+ },
2186
+ m.index
2187
+ );
2188
+ })
2189
+ },
2190
+ rowIndex
2191
+ )) })
2173
2192
  ] });
2174
2193
  }
2175
2194
 
@@ -2244,45 +2263,37 @@ function YearPickerGrid({ classNames, ...props }) {
2244
2263
  }
2245
2264
  )
2246
2265
  ] }),
2247
- /* @__PURE__ */ jsx(
2266
+ /* @__PURE__ */ jsx("div", { role: "grid", "aria-label": rangeLabel, className: classNames?.grid, children: Array.from({ length: 4 }, (_, rowIndex) => /* @__PURE__ */ jsx(
2248
2267
  "div",
2249
2268
  {
2250
- role: "grid",
2251
- "aria-label": rangeLabel,
2252
- className: classNames?.grid,
2253
- children: Array.from({ length: 4 }, (_, rowIndex) => /* @__PURE__ */ jsx(
2254
- "div",
2255
- {
2256
- role: "row",
2257
- className: classNames?.gridRow,
2258
- style: { display: "grid", gridTemplateColumns: "repeat(3, 1fr)" },
2259
- children: years.slice(rowIndex * 3, rowIndex * 3 + 3).map((y) => {
2260
- const yearClass = [
2261
- classNames?.year,
2262
- y.isSelected && classNames?.yearSelected,
2263
- y.isCurrent && classNames?.yearCurrent
2264
- ].filter(Boolean).join(" ") || void 0;
2265
- return /* @__PURE__ */ jsx(
2266
- "button",
2267
- {
2268
- type: "button",
2269
- role: "gridcell",
2270
- "aria-selected": y.isSelected || void 0,
2271
- "aria-current": y.isCurrent ? "date" : void 0,
2272
- "data-selected": y.isSelected || void 0,
2273
- "data-current": y.isCurrent || void 0,
2274
- className: yearClass,
2275
- onClick: () => handleYearSelect(y.value),
2276
- children: y.value
2277
- },
2278
- y.value
2279
- );
2280
- })
2281
- },
2282
- rowIndex
2283
- ))
2284
- }
2285
- )
2269
+ role: "row",
2270
+ className: classNames?.gridRow,
2271
+ style: { display: "grid", gridTemplateColumns: "repeat(3, 1fr)" },
2272
+ children: years.slice(rowIndex * 3, rowIndex * 3 + 3).map((y) => {
2273
+ const yearClass = [
2274
+ classNames?.year,
2275
+ y.isSelected && classNames?.yearSelected,
2276
+ y.isCurrent && classNames?.yearCurrent
2277
+ ].filter(Boolean).join(" ") || void 0;
2278
+ return /* @__PURE__ */ jsx(
2279
+ "button",
2280
+ {
2281
+ type: "button",
2282
+ role: "gridcell",
2283
+ "aria-selected": y.isSelected || void 0,
2284
+ "aria-current": y.isCurrent ? "date" : void 0,
2285
+ "data-selected": y.isSelected || void 0,
2286
+ "data-current": y.isCurrent || void 0,
2287
+ className: yearClass,
2288
+ onClick: () => handleYearSelect(y.value),
2289
+ children: y.value
2290
+ },
2291
+ y.value
2292
+ );
2293
+ })
2294
+ },
2295
+ rowIndex
2296
+ )) })
2286
2297
  ] });
2287
2298
  }
2288
2299
 
@@ -2545,14 +2556,8 @@ function useTimePicker(options = {}) {
2545
2556
  },
2546
2557
  [format, period, setTime$1]
2547
2558
  );
2548
- const setMinute = useCallback(
2549
- (minute) => setTime$1({ minutes: minute }),
2550
- [setTime$1]
2551
- );
2552
- const setSecond = useCallback(
2553
- (second) => setTime$1({ seconds: second }),
2554
- [setTime$1]
2555
- );
2559
+ const setMinute = useCallback((minute) => setTime$1({ minutes: minute }), [setTime$1]);
2560
+ const setSecond = useCallback((second) => setTime$1({ seconds: second }), [setTime$1]);
2556
2561
  const setPeriod = useCallback(
2557
2562
  (newPeriod) => {
2558
2563
  if (format !== "12h") return;