@povio/ui 2.2.9-rc.3 → 2.2.9-rc.30

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.
Files changed (116) hide show
  1. package/dist/components/buttons/Button/Button.d.ts +2 -1
  2. package/dist/components/buttons/Button/Button.js +41 -32
  3. package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +2 -1
  4. package/dist/components/buttons/InlineIconButton/InlineIconButton.js +2 -2
  5. package/dist/components/inputs/Checkbox/Checkbox.js +6 -1
  6. package/dist/components/inputs/Checkbox/checkbox.cva.d.ts +3 -0
  7. package/dist/components/inputs/Checkbox/checkbox.cva.js +2 -1
  8. package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +8 -3
  9. package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +88 -6
  10. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +7 -2
  11. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +91 -6
  12. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +8 -2
  13. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +91 -7
  14. package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -1
  15. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +73 -4
  16. package/dist/components/inputs/DateTime/shared/Calendar.d.ts +5 -2
  17. package/dist/components/inputs/DateTime/shared/Calendar.js +23 -6
  18. package/dist/components/inputs/DateTime/shared/CalendarCell.d.ts +1 -1
  19. package/dist/components/inputs/DateTime/shared/CalendarCell.js +3 -3
  20. package/dist/components/inputs/DateTime/shared/CalendarGrid.d.ts +1 -1
  21. package/dist/components/inputs/DateTime/shared/DateField.js +3 -10
  22. package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +6 -2
  23. package/dist/components/inputs/DateTime/shared/DatePickerInput.js +65 -55
  24. package/dist/components/inputs/DateTime/shared/DateSegmentItem.d.ts +14 -0
  25. package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +19 -6
  26. package/dist/components/inputs/DateTime/shared/TimePickerInput.js +4 -2
  27. package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +4 -0
  28. package/dist/components/inputs/DateTime/shared/datePickerInput.cva.d.ts +7 -0
  29. package/dist/components/inputs/DateTime/shared/datePickerInput.cva.js +13 -0
  30. package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +6 -0
  31. package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +21 -0
  32. package/dist/components/inputs/DateTime/shared/dateSegment.utils.d.ts +2 -0
  33. package/dist/components/inputs/DateTime/shared/dateSegment.utils.js +9 -0
  34. package/dist/components/inputs/DateTime/shared/dateSegment.utils.spec.d.ts +1 -0
  35. package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.d.ts +35 -0
  36. package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +80 -0
  37. package/dist/components/inputs/File/FileUpload.js +1 -0
  38. package/dist/components/inputs/File/shared/InputUploadContent.js +1 -0
  39. package/dist/components/inputs/FormField/FormField.d.ts +3 -3
  40. package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
  41. package/dist/components/inputs/FormField/formFieldHeader.cva.d.ts +6 -0
  42. package/dist/components/inputs/FormField/formFieldHeader.cva.js +11 -0
  43. package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
  44. package/dist/components/inputs/Input/NumberInput/NumberInput.js +85 -7
  45. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.d.ts +38 -0
  46. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +318 -0
  47. package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
  48. package/dist/components/inputs/Input/TextInput/TextInput.js +88 -7
  49. package/dist/components/inputs/Input/shared/InputContent.js +7 -6
  50. package/dist/components/inputs/Input/shared/numberStatic.utils.d.ts +1 -0
  51. package/dist/components/inputs/Input/shared/numberStatic.utils.js +7 -0
  52. package/dist/components/inputs/Inputs/InputItem.d.ts +15 -18
  53. package/dist/components/inputs/Inputs/InputItem.js +2 -0
  54. package/dist/components/inputs/RadioGroup/RadioGroup.js +17 -9
  55. package/dist/components/inputs/RadioGroup/radio.cva.d.ts +3 -0
  56. package/dist/components/inputs/RadioGroup/radio.cva.js +2 -1
  57. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +6 -2
  58. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +104 -6
  59. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
  60. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +15 -10
  61. package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +25 -19
  62. package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +3 -4
  63. package/dist/components/inputs/Selection/Select/QuerySelect.js +8 -35
  64. package/dist/components/inputs/Selection/Select/Select.d.ts +7 -3
  65. package/dist/components/inputs/Selection/Select/Select.js +119 -4
  66. package/dist/components/inputs/Selection/shared/SelectBase.d.ts +4 -1
  67. package/dist/components/inputs/Selection/shared/SelectBase.js +3 -2
  68. package/dist/components/inputs/Selection/shared/SelectDesktop.d.ts +1 -1
  69. package/dist/components/inputs/Selection/shared/SelectDesktop.js +8 -4
  70. package/dist/components/inputs/Selection/shared/SelectInput.d.ts +2 -2
  71. package/dist/components/inputs/Selection/shared/SelectInput.js +13 -2
  72. package/dist/components/inputs/Selection/shared/SelectListBox.d.ts +2 -2
  73. package/dist/components/inputs/Selection/shared/SelectListBox.js +3 -3
  74. package/dist/components/inputs/Selection/shared/SelectMobile.d.ts +1 -1
  75. package/dist/components/inputs/Selection/shared/SelectMobile.js +5 -3
  76. package/dist/components/inputs/Selection/shared/select.context.d.ts +3 -2
  77. package/dist/components/inputs/Selection/shared/select.context.js +27 -4
  78. package/dist/components/inputs/Selection/shared/select.types.d.ts +3 -2
  79. package/dist/components/inputs/Selection/shared/selectDesktop.cva.d.ts +3 -0
  80. package/dist/components/inputs/Selection/shared/selectDesktop.cva.js +5 -0
  81. package/dist/components/inputs/Selection/shared/staticSelect.utils.d.ts +23 -0
  82. package/dist/components/inputs/Selection/shared/staticSelect.utils.js +37 -0
  83. package/dist/components/inputs/Selection/shared/staticSelect.utils.spec.d.ts +1 -0
  84. package/dist/components/inputs/Skeleton/InputFrame.d.ts +68 -0
  85. package/dist/components/inputs/Skeleton/InputFrame.js +171 -0
  86. package/dist/components/inputs/TextEditor/TextEditor.js +1 -0
  87. package/dist/components/inputs/Toggle/Toggle.js +6 -1
  88. package/dist/components/inputs/Toggle/toggle.cva.d.ts +3 -0
  89. package/dist/components/inputs/Toggle/toggle.cva.js +2 -1
  90. package/dist/components/inputs/shared/CheckContent.d.ts +2 -1
  91. package/dist/components/inputs/shared/CheckContent.js +3 -4
  92. package/dist/components/inputs/shared/InputClear.d.ts +2 -1
  93. package/dist/components/inputs/shared/InputClear.js +13 -1
  94. package/dist/components/inputs/shared/StaticInput.d.ts +38 -0
  95. package/dist/components/inputs/shared/StaticInput.js +104 -0
  96. package/dist/components/inputs/shared/TooltipWrapper.js +5 -1
  97. package/dist/components/inputs/shared/input.cva.d.ts +10 -0
  98. package/dist/components/inputs/shared/input.cva.js +19 -1
  99. package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +4 -0
  100. package/dist/components/inputs/shared/tooltipWrapper.cva.js +5 -0
  101. package/dist/config/uiConfig.context.d.ts +8 -2
  102. package/dist/config/uiConfig.context.js +12 -1
  103. package/dist/config/uiStyle.context.d.ts +20 -3
  104. package/dist/helpers/dynamicInputs.d.ts +1 -1
  105. package/dist/helpers/dynamicInputs.js +3 -0
  106. package/dist/hooks/useIntersectionObserver.d.ts +1 -1
  107. package/dist/hooks/useIntersectionObserver.js +29 -10
  108. package/dist/hooks/useQueryAutocomplete.d.ts +5 -16
  109. package/dist/hooks/useQueryAutocomplete.js +13 -3
  110. package/dist/index.d.ts +7 -0
  111. package/dist/index.js +4 -2
  112. package/dist/utils/date-time.utils.d.ts +30 -9
  113. package/dist/utils/date-time.utils.js +113 -1
  114. package/dist/utils/query.utils.d.ts +4 -0
  115. package/dist/utils/query.utils.js +8 -0
  116. package/package.json +1 -1
@@ -15,17 +15,30 @@ var getPlaceholder = (segment) => {
15
15
  var DateSegmentItem = ({ segment, state, isDisabled, timePickerOnly, hidePlaceholder }) => {
16
16
  const ref = useRef(null);
17
17
  const { segmentProps } = useDateSegment(segment, state, ref);
18
- const isInputEmpty = !state.value;
18
+ return /* @__PURE__ */ jsx(DateSegmentItemView, {
19
+ ref,
20
+ segmentProps,
21
+ type: segment.type,
22
+ text: segment.text,
23
+ placeholder: getPlaceholder(segment),
24
+ isPlaceholder: segment.isPlaceholder,
25
+ isInputEmpty: !state.value,
26
+ isDisabled,
27
+ timePickerOnly,
28
+ hidePlaceholder
29
+ });
30
+ };
31
+ var DateSegmentItemView = ({ ref, segmentProps, type, text, placeholder, isPlaceholder, isInputEmpty, isDisabled, timePickerOnly, hidePlaceholder }) => {
19
32
  return /* @__PURE__ */ jsx("div", {
20
33
  ...segmentProps,
21
34
  ref,
22
- className: clsx("box-content rounded-input-rounding-default", isDisabled && "text-interactive-text-secondary-disabled", !isDisabled && isInputEmpty && "text-text-default-3 group-focus-within:text-text-default-1", !isDisabled && !isInputEmpty && "text-text-default-1", "focus-within:outline-1 focus-within:outline-interactive-contained-primary-idle focus-within:outline-offset-1", ["hour", "dayPeriod"].includes(segment.type) && !timePickerOnly && "ml-1", hidePlaceholder && "opacity-0"),
23
- children: /* @__PURE__ */ jsxs(Fragment, { children: [segment.isPlaceholder && /* @__PURE__ */ jsx("span", {
35
+ className: clsx("box-content rounded-input-rounding-default", isDisabled && "text-interactive-text-secondary-disabled", !isDisabled && isInputEmpty && "text-text-default-3 group-focus-within:text-text-default-1", !isDisabled && !isInputEmpty && "text-text-default-1", "focus-within:outline-1 focus-within:outline-interactive-contained-primary-idle focus-within:outline-offset-1", type && ["hour", "dayPeriod"].includes(type) && !timePickerOnly && "ml-1", hidePlaceholder && "opacity-0"),
36
+ children: /* @__PURE__ */ jsxs(Fragment, { children: [isPlaceholder && /* @__PURE__ */ jsx("span", {
24
37
  "aria-hidden": "true",
25
38
  className: "pointer-events-none",
26
- children: getPlaceholder(segment)
27
- }), segment.isPlaceholder ? "" : segment.text] })
39
+ children: placeholder
40
+ }), isPlaceholder ? "" : text] })
28
41
  });
29
42
  };
30
43
  //#endregion
31
- export { DateSegmentItem, getPlaceholder };
44
+ export { DateSegmentItem, DateSegmentItemView, getPlaceholder };
@@ -1,6 +1,6 @@
1
- import { ClockIcon } from "../../../../assets/icons/Clock.js";
2
1
  import { UIStyle } from "../../../../config/uiStyle.context.js";
3
2
  import { Typography } from "../../../text/Typography/Typography.js";
3
+ import { UIConfig } from "../../../../config/uiConfig.context.js";
4
4
  import { InlineIconButton } from "../../../buttons/InlineIconButton/InlineIconButton.js";
5
5
  import { FormFieldLabel } from "../../FormField/FormFieldLabel.js";
6
6
  import { InputClear } from "../../shared/InputClear.js";
@@ -13,6 +13,7 @@ import { Button } from "react-aria-components";
13
13
  import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
14
14
  //#region src/components/inputs/DateTime/shared/TimePickerInput.tsx
15
15
  var TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isRequired, isInvalid, disableDropdown, variant, size, isClearable, headerProps, disableManualEntry, placeholder, className, onPress, ...props }) => {
16
+ const uiConfig = UIConfig.useConfig();
16
17
  const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
17
18
  const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
18
19
  const { hoverProps, isHovered } = useHover({ isDisabled });
@@ -32,6 +33,7 @@ var TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isRequ
32
33
  "data-datetime-input": "",
33
34
  "data-hovered": isHovered || void 0,
34
35
  "data-disabled": isDisabled || void 0,
36
+ "data-is-disabled": isDisabled || void 0,
35
37
  "data-invalid": isInvalid || void 0,
36
38
  "data-is-empty": state.value === null || void 0,
37
39
  "data-focus-within": isFocused || void 0,
@@ -83,7 +85,7 @@ var TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isRequ
83
85
  label: "",
84
86
  color: "secondary",
85
87
  onPress,
86
- icon: ClockIcon,
88
+ icon: uiConfig.dateInput.timeIcon,
87
89
  isDisabled,
88
90
  className: "border-0!"
89
91
  })]
@@ -0,0 +1,4 @@
1
+ import { IconButtonProps } from '../../../buttons/IconButton/IconButton';
2
+ export type DatePickerTodayIcon = boolean | IconButtonProps["icon"];
3
+ export type DatePickerTodayIconButtonSize = IconButtonProps["size"];
4
+ export type DatePickerTodayIconPlacement = "content" | "fieldLabel";
@@ -0,0 +1,7 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ import { InputSizeProps } from '../../shared/input.cva';
3
+ export declare const datePickerInputContentRow: (props?: ({
4
+ size?: "small" | "default" | "extra-small" | "large" | null | undefined;
5
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
6
+ export interface DatePickerInputContentRowProps extends VariantProps<typeof datePickerInputContentRow>, InputSizeProps {
7
+ }
@@ -0,0 +1,13 @@
1
+ import { cva } from "class-variance-authority";
2
+ //#region src/components/inputs/DateTime/shared/datePickerInput.cva.ts
3
+ var datePickerInputContentRow = cva("flex items-center gap-input-gap-input-text-to-elements", {
4
+ variants: { size: {
5
+ "extra-small": "",
6
+ small: "",
7
+ default: "",
8
+ large: ""
9
+ } },
10
+ defaultVariants: { size: "default" }
11
+ });
12
+ //#endregion
13
+ export { datePickerInputContentRow };
@@ -0,0 +1,6 @@
1
+ import { FC, ReactElement, SVGProps } from 'react';
2
+ import { DatePickerTodayIcon, DatePickerTodayIconButtonSize } from './datePicker.types';
3
+ type TodayIconComponent = FC<SVGProps<SVGSVGElement>> | ReactElement;
4
+ export declare const getDatePickerTodayIcon: (todayIcon: DatePickerTodayIcon | undefined) => TodayIconComponent | null;
5
+ export declare const renderDatePickerTodayIcon: (todayIcon: DatePickerTodayIcon | undefined, size?: DatePickerTodayIconButtonSize, className?: string) => import("react/jsx-runtime").JSX.Element | undefined;
6
+ export {};
@@ -0,0 +1,21 @@
1
+ import { InlineIconButton } from "../../../buttons/InlineIconButton/InlineIconButton.js";
2
+ import { TodayIcon } from "../../../../assets/icons/Today.js";
3
+ import { jsx } from "react/jsx-runtime";
4
+ //#region src/components/inputs/DateTime/shared/datePickerTodayIcon.tsx
5
+ var getDatePickerTodayIcon = (todayIcon) => {
6
+ if (!todayIcon) return null;
7
+ return todayIcon === true ? TodayIcon : todayIcon;
8
+ };
9
+ var renderDatePickerTodayIcon = (todayIcon, size = "none", className) => {
10
+ const icon = getDatePickerTodayIcon(todayIcon);
11
+ if (!icon) return;
12
+ return /* @__PURE__ */ jsx(InlineIconButton, {
13
+ label: "",
14
+ icon,
15
+ size,
16
+ staticRender: true,
17
+ className: className ?? "relative z-1 !border-none"
18
+ });
19
+ };
20
+ //#endregion
21
+ export { getDatePickerTodayIcon, renderDatePickerTodayIcon };
@@ -0,0 +1,2 @@
1
+ import { DateSegment } from '@react-stately/datepicker';
2
+ export declare const getTimeSegmentValue: (segment: DateSegment | undefined, fallbackValue?: number) => number;
@@ -0,0 +1,9 @@
1
+ //#region src/components/inputs/DateTime/shared/dateSegment.utils.ts
2
+ var getTimeSegmentValue = (segment, fallbackValue = 0) => {
3
+ if (!segment) return fallbackValue;
4
+ const parsedValue = Number.parseInt(segment.text, 10);
5
+ if (Number.isFinite(parsedValue)) return parsedValue;
6
+ return Number.isFinite(segment.value) ? segment.value ?? fallbackValue : fallbackValue;
7
+ };
8
+ //#endregion
9
+ export { getTimeSegmentValue };
@@ -0,0 +1,35 @@
1
+ import { CalendarDate } from '@internationalized/date';
2
+ import { DateValue, TimeValue } from 'react-aria';
3
+ interface StaticSegmentProps {
4
+ isDisabled?: boolean;
5
+ hidePlaceholder?: boolean;
6
+ }
7
+ interface StaticCalendarDateSegmentsProps extends StaticSegmentProps {
8
+ value?: CalendarDate | null;
9
+ locale: string;
10
+ placeholder?: string;
11
+ shouldForceLeadingZeros?: boolean;
12
+ }
13
+ interface StaticCalendarDateTimeSegmentsProps extends StaticSegmentProps {
14
+ value?: DateValue | null;
15
+ locale: string;
16
+ placeholder?: string;
17
+ shouldForceLeadingZeros?: boolean;
18
+ }
19
+ interface StaticDateRangeSegmentsProps extends StaticSegmentProps {
20
+ start?: CalendarDate | null;
21
+ end?: CalendarDate | null;
22
+ locale: string;
23
+ placeholder?: string;
24
+ shouldForceLeadingZeros?: boolean;
25
+ }
26
+ interface StaticTimeSegmentsProps extends StaticSegmentProps {
27
+ value?: TimeValue | null;
28
+ locale: string;
29
+ placeholder?: string;
30
+ }
31
+ export declare const getStaticCalendarDateSegments: ({ value, locale, placeholder, shouldForceLeadingZeros, isDisabled, hidePlaceholder, }: StaticCalendarDateSegmentsProps) => import("react/jsx-runtime").JSX.Element;
32
+ export declare const getStaticCalendarDateTimeSegments: ({ value, locale, placeholder, shouldForceLeadingZeros, isDisabled, hidePlaceholder, }: StaticCalendarDateTimeSegmentsProps) => import("react/jsx-runtime").JSX.Element;
33
+ export declare const getStaticDateRangeSegments: ({ start, end, locale, placeholder, shouldForceLeadingZeros, isDisabled, hidePlaceholder, }: StaticDateRangeSegmentsProps) => import("react/jsx-runtime").JSX.Element;
34
+ export declare const getStaticTimeSegments: ({ value, locale, placeholder, isDisabled, hidePlaceholder, }: StaticTimeSegmentsProps) => import("react/jsx-runtime").JSX.Element;
35
+ export {};
@@ -0,0 +1,80 @@
1
+ import { DateSegmentItemView } from "./DateSegmentItem.js";
2
+ import { DateTimeUtils } from "../../../../utils/date-time.utils.js";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ //#region src/components/inputs/DateTime/shared/staticDateTimeSegments.tsx
5
+ var getStaticCalendarDateSegments = ({ value, locale, placeholder, shouldForceLeadingZeros, isDisabled, hidePlaceholder }) => {
6
+ const hasValue = !!value;
7
+ return renderStaticSegments(value ? DateTimeUtils.formatCalendarDateLocalized(value, locale, { shouldForceLeadingZeros }) : placeholder ?? DateTimeUtils.getDatePlaceholder(locale, { shouldForceLeadingZeros }), {
8
+ isPlaceholder: !hasValue,
9
+ isInputEmpty: !hasValue,
10
+ isDisabled,
11
+ hidePlaceholder
12
+ });
13
+ };
14
+ var getStaticCalendarDateTimeSegments = ({ value, locale, placeholder, shouldForceLeadingZeros, isDisabled, hidePlaceholder }) => {
15
+ const hasValue = !!(value && "hour" in value);
16
+ return renderStaticSegments(hasValue ? DateTimeUtils.formatCalendarDateTimeLocalized(value, locale, { shouldForceLeadingZeros }) : placeholder ?? DateTimeUtils.getDateTimePlaceholder(locale, { shouldForceLeadingZeros }), {
17
+ isPlaceholder: !hasValue,
18
+ isInputEmpty: !hasValue,
19
+ isDisabled,
20
+ hidePlaceholder
21
+ });
22
+ };
23
+ var getStaticDateRangeSegments = ({ start, end, locale, placeholder, shouldForceLeadingZeros, isDisabled, hidePlaceholder }) => {
24
+ const defaultPlaceholder = placeholder ?? DateTimeUtils.getDatePlaceholder(locale, { shouldForceLeadingZeros });
25
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
26
+ renderStaticSegments(start ? DateTimeUtils.formatCalendarDateLocalized(start, locale, { shouldForceLeadingZeros }) : defaultPlaceholder, {
27
+ isPlaceholder: !start,
28
+ isInputEmpty: !start,
29
+ isDisabled,
30
+ hidePlaceholder: hidePlaceholder && !start
31
+ }),
32
+ /* @__PURE__ */ jsx("span", {
33
+ className: isDisabled ? "pointer-events-none select-none text-interactive-text-secondary-disabled" : "pointer-events-none select-none",
34
+ children: "–"
35
+ }),
36
+ renderStaticSegments(end ? DateTimeUtils.formatCalendarDateLocalized(end, locale, { shouldForceLeadingZeros }) : defaultPlaceholder, {
37
+ isPlaceholder: !end,
38
+ isInputEmpty: !end,
39
+ isDisabled,
40
+ hidePlaceholder: hidePlaceholder && !end
41
+ })
42
+ ] });
43
+ };
44
+ var getStaticTimeSegments = ({ value, locale, placeholder, isDisabled, hidePlaceholder }) => {
45
+ const hasValue = !!value;
46
+ return renderStaticSegments(value ? DateTimeUtils.formatTimeLocalized(value, locale) : placeholder ?? DateTimeUtils.getTimePlaceholder(locale), {
47
+ isPlaceholder: !hasValue,
48
+ isInputEmpty: !hasValue,
49
+ isDisabled,
50
+ hidePlaceholder,
51
+ timePickerOnly: true
52
+ });
53
+ };
54
+ var renderStaticSegments = (value, options) => {
55
+ return /* @__PURE__ */ jsx("div", {
56
+ className: "flex",
57
+ children: tokenizeStaticSegmentText(value).map((token, index) => /* @__PURE__ */ jsx(DateSegmentItemView, {
58
+ type: token.type,
59
+ text: getStaticSegmentText(token),
60
+ placeholder: getStaticSegmentText(token),
61
+ isPlaceholder: options.isPlaceholder && token.type !== "literal",
62
+ isInputEmpty: options.isInputEmpty,
63
+ isDisabled: options.isDisabled,
64
+ timePickerOnly: options.timePickerOnly,
65
+ hidePlaceholder: options.hidePlaceholder
66
+ }, index))
67
+ });
68
+ };
69
+ var tokenizeStaticSegmentText = (value) => {
70
+ return (value.match(/(\p{Letter}+|\p{Number}+|[^\p{Letter}\p{Number}]+)/gu) ?? [value]).map((text) => ({
71
+ text,
72
+ type: /^[^\p{Letter}\p{Number}]+$/u.test(text) ? "literal" : "day"
73
+ }));
74
+ };
75
+ var getStaticSegmentText = (token) => {
76
+ if (token.type !== "literal") return token.text;
77
+ return token.text.replaceAll(" ", "\xA0");
78
+ };
79
+ //#endregion
80
+ export { getStaticCalendarDateSegments, getStaticCalendarDateTimeSegments, getStaticDateRangeSegments, getStaticTimeSegments };
@@ -128,6 +128,7 @@ var FileUploadBase = (props) => {
128
128
  ...rest,
129
129
  "data-rac": "",
130
130
  "data-disabled": isDisabled || void 0,
131
+ "data-is-disabled": isDisabled || void 0,
131
132
  "data-invalid": !!error || void 0,
132
133
  "data-multiple": allowsMultiple || void 0,
133
134
  "data-has-files": uploadState.length > 0 || void 0,
@@ -21,6 +21,7 @@ var InputUploadContent = (props) => {
21
21
  children: /* @__PURE__ */ jsxs("div", {
22
22
  "data-rac": "",
23
23
  "data-disabled": isDisabled || void 0,
24
+ "data-is-disabled": isDisabled || void 0,
24
25
  "data-invalid": !!error || void 0,
25
26
  className: inputUploadButton({
26
27
  variant,
@@ -1,4 +1,4 @@
1
- import { PropsWithChildren, Ref } from 'react';
1
+ import { FocusEventHandler, MouseEventHandler, PropsWithChildren, Ref } from 'react';
2
2
  import { FormFieldErrorProps } from './FormFieldError';
3
3
  import { FormFieldHeaderProps } from './FormFieldHeader';
4
4
  import { TextInputProps } from '../Input/TextInput/TextInput';
@@ -13,8 +13,8 @@ interface FormFieldComponentProps extends PropsWithChildren<FormFieldProps> {
13
13
  labelProps?: FormFieldHeaderProps["labelProps"];
14
14
  as?: TextInputProps["as"];
15
15
  tabIndex?: number;
16
- onMouseEnter?: () => void;
17
- onFocusCapture?: () => void;
16
+ onMouseEnter?: MouseEventHandler<HTMLDivElement>;
17
+ onFocusCapture?: FocusEventHandler<HTMLDivElement>;
18
18
  }
19
19
  export declare const FormField: ({ ref, as, label, tooltipText, helperText, isRequired, rightContent, isDisabled, error, hideLabel, headerClassName, errorClassName, children, className, labelProps, isHeaderHidden, tabIndex, onMouseEnter, onFocusCapture, }: FormFieldComponentProps) => import("react/jsx-runtime").JSX.Element;
20
20
  export {};
@@ -1,14 +1,16 @@
1
1
  import { InfoIcon } from "../../../assets/icons/Info.js";
2
+ import { UIStyle } from "../../../config/uiStyle.context.js";
2
3
  import { Typography } from "../../text/Typography/Typography.js";
3
4
  import { Tooltip as Tooltip$1 } from "../../overlays/Tooltip/Tooltip.js";
4
5
  import { FormFieldLabel } from "./FormFieldLabel.js";
6
+ import { formFieldHeader } from "./formFieldHeader.cva.js";
5
7
  import { jsx, jsxs } from "react/jsx-runtime";
6
8
  import { clsx } from "clsx";
7
9
  import { Focusable } from "react-aria-components";
8
10
  //#region src/components/inputs/FormField/FormFieldHeader.tsx
9
11
  var FormFieldHeader = ({ label, tooltipText, helperText, isRequired, rightContent, isHeaderHidden, isDisabled, className, labelProps }) => {
10
12
  return /* @__PURE__ */ jsxs("div", {
11
- className: clsx(isHeaderHidden ? "sr-only" : "mb-1", className),
13
+ className: clsx(UIStyle.useCva("formField.headerCva", formFieldHeader)({ visible: !isHeaderHidden }), className),
12
14
  children: [/* @__PURE__ */ jsxs("div", {
13
15
  className: "flex items-start justify-between",
14
16
  children: [/* @__PURE__ */ jsxs("div", {
@@ -0,0 +1,6 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ export declare const formFieldHeader: (props?: ({
3
+ visible?: boolean | null | undefined;
4
+ } & import('class-variance-authority/types').ClassProp) | undefined) => string;
5
+ export interface FormFieldHeaderVariantProps extends VariantProps<typeof formFieldHeader> {
6
+ }
@@ -0,0 +1,11 @@
1
+ import { cva } from "class-variance-authority";
2
+ //#region src/components/inputs/FormField/formFieldHeader.cva.ts
3
+ var formFieldHeader = cva("", {
4
+ variants: { visible: {
5
+ true: "mb-1",
6
+ false: "sr-only"
7
+ } },
8
+ defaultVariants: { visible: true }
9
+ });
10
+ //#endregion
11
+ export { formFieldHeader };
@@ -13,8 +13,11 @@ interface NumberInputBaseProps extends FormFieldProps, InputVariantProps, Omit<I
13
13
  value?: number | null;
14
14
  onChange?: (value: number | null) => void;
15
15
  onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
16
+ autoFocusOnMount?: boolean;
16
17
  }
17
- export type NumberInputProps = NumberInputBaseProps;
18
+ export type NumberInputProps = NumberInputBaseProps & {
19
+ renderStaticInput?: boolean;
20
+ };
18
21
  export type ControlledNumberInputProps<TFieldValues extends FieldValues> = ControlProps<NumberInputProps, TFieldValues>;
19
- export declare const NumberInput: <TFieldValues extends FieldValues>(props: ControlledNumberInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
22
+ export declare const NumberInput: <TFieldValues extends FieldValues>({ renderStaticInput, ...props }: ControlledNumberInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
20
23
  export {};
@@ -3,21 +3,23 @@ import { UIConfig } from "../../../../config/uiConfig.context.js";
3
3
  import { inputBase } from "../../shared/input.cva.js";
4
4
  import { FormField } from "../../FormField/FormField.js";
5
5
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
6
+ import { InputFrame } from "../../Skeleton/InputFrame.js";
6
7
  import { InputContent } from "../shared/InputContent.js";
8
+ import { getStaticNumberDisplayValue } from "../shared/numberStatic.utils.js";
7
9
  import { jsx } from "react/jsx-runtime";
8
10
  import { clsx } from "clsx";
9
- import { useCallback, useRef } from "react";
11
+ import { useCallback, useEffect, useRef, useState } from "react";
10
12
  import { Input, useLocale } from "react-aria-components";
11
13
  import { useFocusVisible, useNumberField } from "react-aria";
12
14
  import { mergeRefs } from "@react-aria/utils";
13
- import { Controller } from "react-hook-form";
15
+ import { Controller, useWatch } from "react-hook-form";
14
16
  import { useNumberFieldState } from "react-stately";
15
17
  //#region src/components/inputs/Input/NumberInput/NumberInput.tsx
16
18
  var NumberInputBase = (props) => {
17
19
  const ui = UIConfig.useConfig();
18
20
  const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
19
21
  const inputRef = useRef(null);
20
- const { ref, inputClassName, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, className, unit, isLoading, action, leadingIcon, trailingIcon, value, onChange, onBlur, formatOptions = ui.numberInput.formatOptions, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, hideLabel = ui.input.hideLabel, isClearable = ui.input.isClearable, ...rest } = props;
22
+ const { ref, inputClassName, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, className, unit, isLoading, action, leadingIcon, trailingIcon, value, onChange, onBlur, formatOptions = ui.numberInput.formatOptions, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, hideLabel = ui.input.hideLabel, isClearable = ui.input.isClearable, autoFocusOnMount, ...rest } = props;
21
23
  const numberFieldRef = useRef(null);
22
24
  const { isFocusVisible } = useFocusVisible();
23
25
  const { locale } = useLocale();
@@ -34,6 +36,10 @@ var NumberInputBase = (props) => {
34
36
  formatOptions
35
37
  };
36
38
  const { labelProps, inputProps } = useNumberField(numberProps, useNumberFieldState(numberProps), numberFieldRef);
39
+ useEffect(() => {
40
+ if (!autoFocusOnMount || isDisabled) return;
41
+ requestAnimationFrame(() => inputRef.current?.focus());
42
+ }, [autoFocusOnMount, isDisabled]);
37
43
  const formFieldProps = {
38
44
  error,
39
45
  label,
@@ -114,7 +120,74 @@ var NumberInputBase = (props) => {
114
120
  })
115
121
  });
116
122
  };
117
- var NumberInput = (props) => {
123
+ var NumberInput = ({ renderStaticInput, ...props }) => {
124
+ const ui = UIConfig.useConfig();
125
+ const { locale } = useLocale();
126
+ const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
127
+ const [shouldFocus, setShouldFocus] = useState(false);
128
+ const inputRef = useRef(null);
129
+ const watchedValue = "formControl" in props && props.formControl ? useWatch({
130
+ control: props.formControl.control,
131
+ name: props.formControl.name
132
+ }) : props.value;
133
+ let isFormControlDisabled = false;
134
+ if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
135
+ useEffect(() => {
136
+ if (!renderInput || !shouldFocus) return;
137
+ requestAnimationFrame(() => inputRef.current?.focus());
138
+ setShouldFocus(false);
139
+ }, [renderInput, shouldFocus]);
140
+ if (!renderInput) {
141
+ const staticValue = watchedValue ?? props.value ?? props.defaultValue;
142
+ const formatOptions = props.formatOptions ?? ui.numberInput.formatOptions;
143
+ const displayValue = getStaticNumberDisplayValue(staticValue, new Intl.NumberFormat(locale, formatOptions)) ?? "";
144
+ const hasValue = displayValue !== "";
145
+ const as = props.as ?? ui.input.as;
146
+ const size = props.size ?? ui.input.size;
147
+ const variant = props.variant ?? ui.input.variant;
148
+ const hideLabel = props.hideLabel ?? ui.input.hideLabel;
149
+ const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
150
+ let isDisabled = !!props.isDisabled;
151
+ if (isFormControlDisabled) isDisabled = true;
152
+ const dataAttributes = {
153
+ dataIsEmpty: !hasValue,
154
+ dataIsFilled: hasValue,
155
+ dataIsDirty: props.isDirty,
156
+ dataIsRequired: props.isRequired,
157
+ dataIsDisabled: isDisabled,
158
+ dataDisabled: isDisabled,
159
+ dataInvalid: !!props.error,
160
+ dataHasSelection: hasValue
161
+ };
162
+ return /* @__PURE__ */ jsx(InputFrame, {
163
+ ...props,
164
+ isHeaderHidden,
165
+ hideLabel,
166
+ isDisabled,
167
+ className: clsx("group w-full", as === "inline" && "h-full", props.className),
168
+ dataAttributes,
169
+ renderStatic: true,
170
+ onStaticInteract: (focus) => {
171
+ setShouldFocus(focus);
172
+ setRenderInput(true);
173
+ },
174
+ inputClassName: props.inputClassName,
175
+ as,
176
+ size,
177
+ variant,
178
+ children: (dataAttributeProps) => /* @__PURE__ */ jsx("input", {
179
+ ref: inputRef,
180
+ readOnly: true,
181
+ disabled: isDisabled,
182
+ tabIndex: -1,
183
+ value: displayValue,
184
+ placeholder: as === "floating" ? "" : props.placeholder,
185
+ className: "w-full bg-transparent outline-none placeholder:text-text-default-3 disabled:text-interactive-text-secondary-disabled",
186
+ ...dataAttributeProps,
187
+ "data-rac": true
188
+ })
189
+ });
190
+ }
118
191
  if ("formControl" in props && props.formControl) {
119
192
  const { formControl, ref, ...innerProps } = props;
120
193
  return /* @__PURE__ */ jsx(Controller, {
@@ -122,17 +195,22 @@ var NumberInput = (props) => {
122
195
  name: formControl.name,
123
196
  render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(NumberInputBase, {
124
197
  ...innerProps,
125
- ref: mergeRefs(ref, field.ref),
198
+ ref: mergeRefs(ref, field.ref, inputRef),
126
199
  value: field.value,
127
200
  onChange: field.onChange,
128
201
  onBlur: field.onBlur,
129
202
  isDirty,
130
203
  isDisabled: field.disabled || props.isDisabled,
131
- error: props.error ?? error?.message
204
+ error: props.error ?? error?.message,
205
+ autoFocusOnMount: shouldFocus
132
206
  }, field.value === null || field.value === void 0 ? "empty" : "filled")
133
207
  });
134
208
  }
135
- return /* @__PURE__ */ jsx(NumberInputBase, { ...props }, props.value === null || props.value === void 0 ? "empty" : "filled");
209
+ return /* @__PURE__ */ jsx(NumberInputBase, {
210
+ ...props,
211
+ ref: mergeRefs(props.ref, inputRef),
212
+ autoFocusOnMount: shouldFocus
213
+ }, props.value === null || props.value === void 0 ? "empty" : "filled");
136
214
  };
137
215
  //#endregion
138
216
  export { NumberInput };
@@ -0,0 +1,38 @@
1
+ import { FocusEvent, Ref } from 'react';
2
+ import { NumberFieldProps as AriaNumberFieldProps } from 'react-aria-components';
3
+ import { FieldValues } from 'react-hook-form';
4
+ import { FormFieldProps } from '../../FormField/FormField';
5
+ import { ControlProps } from '../../shared/form.types';
6
+ import { InputVariantProps } from '../../shared/input.cva';
7
+ export interface NumberRangeValue {
8
+ min: number | null;
9
+ max: number | null;
10
+ }
11
+ interface NumberRangeInputBaseProps extends FormFieldProps, InputVariantProps, Omit<AriaNumberFieldProps, "className" | "defaultValue" | "label" | "maxValue" | "minValue" | "onBlur" | "onChange" | "value"> {
12
+ ref?: Ref<HTMLDivElement>;
13
+ value?: NumberRangeValue | null;
14
+ minValue?: number | null;
15
+ maxValue?: number | null;
16
+ minPlaceholder?: string;
17
+ maxPlaceholder?: string;
18
+ minLabel?: string;
19
+ maxLabel?: string;
20
+ invalidRangeError?: string;
21
+ inputClassName?: string;
22
+ minInputClassName?: string;
23
+ maxInputClassName?: string;
24
+ hideInnerLabels?: boolean;
25
+ isDirty?: boolean;
26
+ isClearable?: boolean;
27
+ autoFocusOnMount?: boolean;
28
+ onChange?: (value: NumberRangeValue) => void;
29
+ onMinChange?: (value: number | null) => void;
30
+ onMaxChange?: (value: number | null) => void;
31
+ onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
32
+ }
33
+ export type NumberRangeInputProps = NumberRangeInputBaseProps & {
34
+ renderStaticInput?: boolean;
35
+ };
36
+ export type ControlledNumberRangeInputProps<TFieldValues extends FieldValues> = ControlProps<NumberRangeInputProps, TFieldValues>;
37
+ export declare const NumberRangeInput: <TFieldValues extends FieldValues>({ renderStaticInput, ...props }: ControlledNumberRangeInputProps<TFieldValues>) => import("react/jsx-runtime").JSX.Element;
38
+ export {};