@choice-ui/react 1.5.8 → 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.
@@ -1,6 +1,7 @@
1
1
  import { default as React__default } from 'react';
2
2
  import { Locale, Quarter as Quarter$1, Day, isSameDay, isSameMonth, isSameYear, addMonths, startOfMonth, endOfMonth, startOfWeek, endOfWeek } from 'date-fns';
3
3
  import { TextFieldProps } from '../../text-field/src';
4
+ import { DropdownProps } from '../../dropdown/src';
4
5
  import { MenuTrigger } from '../../menus/src';
5
6
  import { TZDate } from '@date-fns/tz';
6
7
  import { Locale as Locale$1 } from 'date-fns/locale';
@@ -571,24 +572,15 @@ declare const DateRangeInput: (props: DateRangeInputProps) => react_jsx_runtime.
571
572
  interface TimeCalendarComponentType extends React__default.MemoExoticComponent<React__default.FC<TimeCalendarProps>> {
572
573
  Trigger: typeof MenuTrigger;
573
574
  }
574
- interface TimeCalendarProps extends BaseTimeProps, StepProps {
575
- /** Custom trigger element. Use Dropdown.Trigger as wrapper */
575
+ interface TimeCalendarProps extends BaseTimeProps, StepProps, Pick<DropdownProps, "offset" | "placement" | "matchTriggerWidth" | "variant" | "readOnly"> {
576
576
  children?: React__default.ReactNode;
577
- /** Custom class name for dropdown content */
578
577
  className?: string;
579
- /** Hour step, default 1 hour */
580
578
  hourStep?: number;
581
- /** Minute step, default 15 minutes */
582
579
  minuteStep?: number;
583
- /** Whether the dropdown is open (controlled) */
584
580
  open?: boolean;
585
- /** Callback when open state changes */
586
581
  onOpenChange?: (open: boolean) => void;
587
- /** Whether to close dropdown after selection */
588
582
  closeOnSelect?: boolean;
589
- /** External trigger element ref */
590
583
  triggerRef?: React__default.RefObject<HTMLElement>;
591
- /** CSS selector for external trigger element */
592
584
  triggerSelector?: string;
593
585
  }
594
586
  declare const TimeCalendar: TimeCalendarComponentType;
@@ -3050,6 +3050,10 @@ var TimeCalendarBase = memo(function TimeCalendar(props) {
3050
3050
  closeOnSelect = true,
3051
3051
  triggerRef,
3052
3052
  triggerSelector,
3053
+ offset,
3054
+ placement,
3055
+ matchTriggerWidth,
3056
+ variant,
3053
3057
  ...rest
3054
3058
  } = props;
3055
3059
  const [internalOpen, setInternalOpen] = useState(false);
@@ -3112,6 +3116,23 @@ var TimeCalendarBase = memo(function TimeCalendar(props) {
3112
3116
  const createPrefixElement = useCallback((isSelected) => {
3113
3117
  return isSelected ? /* @__PURE__ */ jsx(Check, {}) : /* @__PURE__ */ jsx(Fragment, {});
3114
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]);
3115
3136
  const handleTimeSelect = useEventCallback((timeValue) => {
3116
3137
  if (readOnly) return;
3117
3138
  const dateValue = timeStringToDate(timeValue);
@@ -3128,6 +3149,11 @@ var TimeCalendarBase = memo(function TimeCalendar(props) {
3128
3149
  selection: true,
3129
3150
  triggerRef,
3130
3151
  triggerSelector,
3152
+ offset,
3153
+ placement,
3154
+ matchTriggerWidth,
3155
+ variant,
3156
+ readOnly,
3131
3157
  ...rest,
3132
3158
  children: [
3133
3159
  children,
@@ -1,27 +1,19 @@
1
+ import { DropdownProps } from '../../../dropdown/src';
1
2
  import { MenuTrigger } from '../../../menus/src';
2
3
  import { default as React } from 'react';
3
4
  import { BaseTimeProps, StepProps } from '../types';
4
5
  interface TimeCalendarComponentType extends React.MemoExoticComponent<React.FC<TimeCalendarProps>> {
5
6
  Trigger: typeof MenuTrigger;
6
7
  }
7
- export interface TimeCalendarProps extends BaseTimeProps, StepProps {
8
- /** Custom trigger element. Use Dropdown.Trigger as wrapper */
8
+ export interface TimeCalendarProps extends BaseTimeProps, StepProps, Pick<DropdownProps, "offset" | "placement" | "matchTriggerWidth" | "variant" | "readOnly"> {
9
9
  children?: React.ReactNode;
10
- /** Custom class name for dropdown content */
11
10
  className?: string;
12
- /** Hour step, default 1 hour */
13
11
  hourStep?: number;
14
- /** Minute step, default 15 minutes */
15
12
  minuteStep?: number;
16
- /** Whether the dropdown is open (controlled) */
17
13
  open?: boolean;
18
- /** Callback when open state changes */
19
14
  onOpenChange?: (open: boolean) => void;
20
- /** Whether to close dropdown after selection */
21
15
  closeOnSelect?: boolean;
22
- /** External trigger element ref */
23
16
  triggerRef?: React.RefObject<HTMLElement>;
24
- /** CSS selector for external trigger element */
25
17
  triggerSelector?: string;
26
18
  }
27
19
  export declare const TimeCalendar: TimeCalendarComponentType;
@@ -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";
@@ -21,6 +21,10 @@ const TimeCalendarBase = memo(function TimeCalendar2(props) {
21
21
  closeOnSelect = true,
22
22
  triggerRef,
23
23
  triggerSelector,
24
+ offset,
25
+ placement,
26
+ matchTriggerWidth,
27
+ variant,
24
28
  ...rest
25
29
  } = props;
26
30
  const [internalOpen, setInternalOpen] = useState(false);
@@ -83,6 +87,23 @@ const TimeCalendarBase = memo(function TimeCalendar2(props) {
83
87
  const createPrefixElement = useCallback((isSelected) => {
84
88
  return isSelected ? /* @__PURE__ */ jsx(Check, {}) : /* @__PURE__ */ jsx(Fragment, {});
85
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]);
86
107
  const handleTimeSelect = useEventCallback((timeValue) => {
87
108
  if (readOnly) return;
88
109
  const dateValue = timeStringToDate(timeValue);
@@ -99,6 +120,11 @@ const TimeCalendarBase = memo(function TimeCalendar2(props) {
99
120
  selection: true,
100
121
  triggerRef,
101
122
  triggerSelector,
123
+ offset,
124
+ placement,
125
+ matchTriggerWidth,
126
+ variant,
127
+ readOnly,
102
128
  ...rest,
103
129
  children: [
104
130
  children,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@choice-ui/react",
3
- "version": "1.5.8",
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",