@choice-ui/react 1.5.9 → 1.6.0

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.
@@ -3116,6 +3116,23 @@ var TimeCalendarBase = memo(function TimeCalendar(props) {
3116
3116
  const createPrefixElement = useCallback((isSelected) => {
3117
3117
  return isSelected ? /* @__PURE__ */ jsx(Check, {}) : /* @__PURE__ */ jsx(Fragment, {});
3118
3118
  }, []);
3119
+ useEffect(() => {
3120
+ if (!isOpen || !normalizedTimeString) return;
3121
+ let attempts = 0;
3122
+ const maxAttempts = 10;
3123
+ const scrollToSelected = () => {
3124
+ const selectedItem = document.querySelector(
3125
+ `[data-testid="${normalizedTimeString}"]`
3126
+ );
3127
+ if (selectedItem) {
3128
+ selectedItem.scrollIntoView({ block: "center" });
3129
+ } else if (attempts < maxAttempts) {
3130
+ attempts++;
3131
+ requestAnimationFrame(scrollToSelected);
3132
+ }
3133
+ };
3134
+ requestAnimationFrame(scrollToSelected);
3135
+ }, [isOpen, normalizedTimeString]);
3119
3136
  const handleTimeSelect = useEventCallback((timeValue) => {
3120
3137
  if (readOnly) return;
3121
3138
  const dateValue = timeStringToDate(timeValue);
@@ -1,8 +1,8 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
- import { Check } from "@choiceform/icons-react";
3
2
  import { Dropdown as Dropdown2 } from "../../../dropdown/dist/index.js";
4
3
  import { MenuTrigger } from "../../../menus/dist/index.js";
5
- import React__default, { memo, useState, useMemo, useCallback } from "react";
4
+ import { Check } from "@choiceform/icons-react";
5
+ import React__default, { memo, useState, useMemo, useCallback, useEffect } from "react";
6
6
  import { useEventCallback } from "usehooks-ts";
7
7
  import { generateTimeOptions, normalizeTimeValue, timeStringToDate } from "../utils/time.js";
8
8
  import { useMergedValue } from "../../../../shared/hooks/use-merged-value/use-merged-value.js";
@@ -87,6 +87,23 @@ const TimeCalendarBase = memo(function TimeCalendar2(props) {
87
87
  const createPrefixElement = useCallback((isSelected) => {
88
88
  return isSelected ? /* @__PURE__ */ jsx(Check, {}) : /* @__PURE__ */ jsx(Fragment, {});
89
89
  }, []);
90
+ useEffect(() => {
91
+ if (!isOpen || !normalizedTimeString) return;
92
+ let attempts = 0;
93
+ const maxAttempts = 10;
94
+ const scrollToSelected = () => {
95
+ const selectedItem = document.querySelector(
96
+ `[data-testid="${normalizedTimeString}"]`
97
+ );
98
+ if (selectedItem) {
99
+ selectedItem.scrollIntoView({ block: "center" });
100
+ } else if (attempts < maxAttempts) {
101
+ attempts++;
102
+ requestAnimationFrame(scrollToSelected);
103
+ }
104
+ };
105
+ requestAnimationFrame(scrollToSelected);
106
+ }, [isOpen, normalizedTimeString]);
90
107
  const handleTimeSelect = useEventCallback((timeValue) => {
91
108
  if (readOnly) return;
92
109
  const dateValue = timeStringToDate(timeValue);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@choice-ui/react",
3
- "version": "1.5.9",
3
+ "version": "1.6.0",
4
4
  "description": "A desktop-first React UI component library built for professional desktop applications with comprehensive documentation",
5
5
  "sideEffects": false,
6
6
  "type": "module",