@povio/ui 2.2.1 → 2.2.2

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 (66) hide show
  1. package/README.md +8 -1
  2. package/dist/components/Breadcrumbs/Breadcrumbs.js +5 -6
  3. package/dist/components/Menu/MenuItem.js +1 -1
  4. package/dist/components/Menu/MenuMobile.js +2 -3
  5. package/dist/components/Menu/MenuPopover.js +8 -7
  6. package/dist/components/buttons/Button/Button.js +24 -8
  7. package/dist/components/buttons/PillButton/PillButton.js +2 -3
  8. package/dist/components/buttons/shared/ButtonContent.js +1 -1
  9. package/dist/components/inputs/Checkbox/Checkbox.js +2 -2
  10. package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +2 -3
  11. package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +2 -6
  12. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +3 -10
  13. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +1 -3
  14. package/dist/components/inputs/DateTime/shared/DatePickerInput.js +63 -78
  15. package/dist/components/inputs/DateTime/shared/TimePickerInput.js +33 -50
  16. package/dist/components/inputs/File/shared/InputUploadContent.js +2 -2
  17. package/dist/components/inputs/File/shared/InputUploadFilled.js +1 -1
  18. package/dist/components/inputs/FormField/FormField.js +1 -1
  19. package/dist/components/inputs/FormField/FormFieldError.js +4 -4
  20. package/dist/components/inputs/FormField/FormFieldLabel.d.ts +2 -1
  21. package/dist/components/inputs/FormField/FormFieldLabel.js +14 -21
  22. package/dist/components/inputs/Input/NumberInput/NumberInput.js +29 -26
  23. package/dist/components/inputs/Input/TextArea/TextArea.js +15 -7
  24. package/dist/components/inputs/Input/TextInput/TextInput.js +30 -27
  25. package/dist/components/inputs/Input/shared/InputContent.d.ts +2 -2
  26. package/dist/components/inputs/Input/shared/InputContent.js +53 -73
  27. package/dist/components/inputs/RadioGroup/RadioGroup.js +3 -4
  28. package/dist/components/inputs/Selection/shared/SelectBase.js +1 -1
  29. package/dist/components/inputs/Selection/shared/SelectDesktop.js +15 -4
  30. package/dist/components/inputs/Selection/shared/SelectInput.js +24 -41
  31. package/dist/components/inputs/Slider/Slider.js +1 -1
  32. package/dist/components/inputs/TextEditor/TextEditor.js +9 -2
  33. package/dist/components/inputs/Toggle/Toggle.js +3 -4
  34. package/dist/components/inputs/shared/CheckContent.js +1 -1
  35. package/dist/components/inputs/shared/InputClear.d.ts +2 -1
  36. package/dist/components/inputs/shared/InputClear.js +2 -2
  37. package/dist/components/inputs/shared/input.cva.js +34 -25
  38. package/dist/components/inputs/shared/label.cva.js +10 -38
  39. package/dist/components/navigation/Accordion/Accordion.js +1 -1
  40. package/dist/components/navigation/Accordion/AccordionItem.js +9 -10
  41. package/dist/components/navigation/Stepper/Stepper.js +1 -1
  42. package/dist/components/navigation/Stepper/StepperItem.js +5 -6
  43. package/dist/components/navigation/Stepper/StepperSeparator.js +1 -1
  44. package/dist/components/outline.clsx.js +1 -1
  45. package/dist/components/overlays/ActionModal/ActionModal.d.ts +6 -1
  46. package/dist/components/overlays/ActionModal/ActionModal.js +7 -6
  47. package/dist/components/overlays/Modal/Modal.d.ts +2 -1
  48. package/dist/components/overlays/Modal/Modal.js +5 -5
  49. package/dist/components/overlays/Tooltip/Tooltip.js +4 -5
  50. package/dist/components/segment/Segment.js +1 -2
  51. package/dist/components/segment/SegmentItem.js +1 -1
  52. package/dist/components/status/Alert/Alert.js +3 -4
  53. package/dist/components/status/Toast/Toast.js +4 -5
  54. package/dist/components/table/Table.js +16 -11
  55. package/dist/components/text/Link/Link.js +1 -1
  56. package/dist/components/text/Tag/Tag.js +1 -1
  57. package/dist/components/text/Typography/Typography.d.ts +1 -1
  58. package/dist/components/text/Typography/Typography.js +1 -1
  59. package/dist/config/uiConfig.context.d.ts +4 -0
  60. package/dist/config/uiConfig.context.js +11 -0
  61. package/dist/config/uiStyle.context.d.ts +7 -3
  62. package/dist/config/uiStyle.context.js +13 -1
  63. package/dist/index.js +4 -4
  64. package/dist/tw-ui-plugin.d.ts +3 -0
  65. package/dist/utils/compoundMapper.d.ts +1 -1
  66. package/package.json +25 -26
package/README.md CHANGED
@@ -32,13 +32,20 @@ This is required for buttons to behave as expected. It is based on [Tailwind Upg
32
32
  In order for Tailwind to also compile classes for @povio/ui package, you need to include @source directive in Tailwind config.
33
33
  In your globals.css add (make sure path is correct):
34
34
  ```css
35
- @source "../../../../node_modules/@povio/ui/dist";
35
+ @source "../../node_modules/@povio/ui/dist";
36
36
  ```
37
37
 
38
38
  ### React Aria
39
39
 
40
40
  We are using `react-aria-components` for our UI components including their plugin for Tailwind that makes classes for modifiers a bit shorter. As such, make sure to install and setup [`tailwindcss-react-aria-components`](https://www.npmjs.com/package/tailwindcss-react-aria-components)
41
41
 
42
+ ### Custom Tailwind plugin
43
+
44
+ We also use a custom tailwind plugin to shorten some selectors inside the @povio/ui package. Install it by adding the following line to your `base.css`.
45
+ ```css
46
+ @plugin "@povio/ui/tw-ui-plugin";
47
+ ```
48
+
42
49
  ### Translations
43
50
 
44
51
  We're using `i18next` for translations. Make sure the package versions match in your project. Out of sync major version might cause issues.
@@ -10,12 +10,11 @@ import { clsx } from "clsx";
10
10
  import { useLayoutEffect, useRef, useState } from "react";
11
11
  import { Breadcrumb, Breadcrumbs, Button, Link } from "react-aria-components";
12
12
  const Breadcrumbs$1 = ({ items, className, onAction, iconOnly = false }) => {
13
- const uiStyle = UIStyle.useConfig();
14
- const breadcrumbsCva$1 = uiStyle?.breadcrumbs?.cva ?? breadcrumbsCva;
15
- const breadcrumbItem$1 = uiStyle?.breadcrumbs?.itemCva ?? breadcrumbItem;
16
- const breadcrumbSegmentCva = uiStyle?.breadcrumbs?.segmentCva ?? breadcrumbSegment;
17
- const breadcrumbChevronCva = uiStyle?.breadcrumbs?.chevronCva ?? breadcrumbChevron;
18
- const breadcrumbIconCva = uiStyle?.breadcrumbs?.iconCva ?? breadcrumbIcon;
13
+ const breadcrumbsCva$1 = UIStyle.useCva("breadcrumbs.cva", breadcrumbsCva);
14
+ const breadcrumbItem$1 = UIStyle.useCva("breadcrumbs.itemCva", breadcrumbItem);
15
+ const breadcrumbSegmentCva = UIStyle.useCva("breadcrumbs.segmentCva", breadcrumbSegment);
16
+ const breadcrumbChevronCva = UIStyle.useCva("breadcrumbs.chevronCva", breadcrumbChevron);
17
+ const breadcrumbIconCva = UIStyle.useCva("breadcrumbs.iconCva", breadcrumbIcon);
19
18
  const containerRef = useRef(null);
20
19
  const [isOverflowing, setIsOverflowing] = useState(items.length <= 2 ? false : null);
21
20
  useLayoutEffect(() => {
@@ -6,7 +6,7 @@ import { clsx } from "clsx";
6
6
  import { MenuItem } from "react-aria-components";
7
7
  const MenuItem$1 = ({ label, content, children, className, ...item }) => {
8
8
  const hasSubmenu = !!children && children?.length > 0;
9
- const menuItemCva$1 = UIStyle.useConfig()?.menu?.itemCva ?? menuItemCva;
9
+ const menuItemCva$1 = UIStyle.useCva("menu.itemCva", menuItemCva);
10
10
  return /* @__PURE__ */ jsxs(MenuItem, {
11
11
  ...item,
12
12
  textValue: label,
@@ -8,9 +8,8 @@ import { clsx } from "clsx";
8
8
  import { useRef, useState } from "react";
9
9
  import { Button, Menu } from "react-aria-components";
10
10
  const MenuMobile = ({ trigger, items, onAction, ...props }) => {
11
- const uiStyle = UIStyle.useConfig();
12
- const menuItemCva$1 = uiStyle?.menu?.itemCva ?? menuItemCva;
13
- const menuCva$1 = uiStyle?.menu?.cva ?? menuCva;
11
+ const menuItemCva$1 = UIStyle.useCva("menu.itemCva", menuItemCva);
12
+ const menuCva$1 = UIStyle.useCva("menu.cva", menuCva);
14
13
  const activeItemRef = useRef(null);
15
14
  const activeItemParentsRef = useRef([]);
16
15
  const lastEventRef = useRef(null);
@@ -2,20 +2,21 @@ import { menuCva, menuPopoverCva, menuPopoverWrapperCva } from "./menu.cva.js";
2
2
  import { UIStyle } from "../../config/uiStyle.context.js";
3
3
  import { MenuItem as MenuItem$1 } from "./MenuItem.js";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
- import { clsx } from "clsx";
6
5
  import { useRef } from "react";
7
6
  import { Menu, Popover, SubmenuTrigger } from "react-aria-components";
8
7
  const MenuPopover = ({ items, className, onAction, ...props }) => {
9
8
  const lastEventRef = useRef(null);
10
- const uiStyle = UIStyle.useConfig();
11
- const menuPopoverCva$1 = uiStyle?.menu?.popoverCva ?? menuPopoverCva;
12
- const menuPopoverWrapperCva$1 = uiStyle?.menu?.popoverWrapperCva ?? menuPopoverWrapperCva;
13
- const menuCva$1 = uiStyle?.menu?.cva ?? menuCva;
9
+ const menuPopoverCva$1 = UIStyle.useCva("menu.popoverCva", menuPopoverCva);
10
+ const menuPopoverWrapperCva$1 = UIStyle.useCva("menu.popoverWrapperCva", menuPopoverWrapperCva);
11
+ const menuCva$1 = UIStyle.useCva("menu.cva", menuCva);
14
12
  return /* @__PURE__ */ jsx(Popover, {
15
13
  ...props,
16
- className: clsx(menuPopoverCva$1({ ...props }), className),
14
+ className: menuPopoverCva$1({
15
+ ...props,
16
+ className
17
+ }),
17
18
  children: /* @__PURE__ */ jsx("div", {
18
- className: menuPopoverWrapperCva$1({ ...props }),
19
+ className: menuPopoverWrapperCva$1({}),
19
20
  children: /* @__PURE__ */ jsx("div", {
20
21
  onClickCapture: (e) => {
21
22
  lastEventRef.current = e;
@@ -1,18 +1,20 @@
1
1
  import { UIStyle } from "../../../config/uiStyle.context.js";
2
2
  import { LinkContext } from "../../../config/link.context.js";
3
3
  import { ButtonContent } from "../shared/ButtonContent.js";
4
+ import { UIConfig } from "../../../config/uiConfig.context.js";
4
5
  import { button, buttonContent, buttonIconSize, buttonSize, buttonTypography } from "./button.cva.js";
5
6
  import { jsx } from "react/jsx-runtime";
6
7
  import { clsx } from "clsx";
7
8
  import { Button, Link, ToggleButton } from "react-aria-components";
8
9
  const Button$1 = ({ icon: Icon, iconPosition, children, isLoading, className, link, iconClassName, noDisableWhenLoading, contentRef, ...props }) => {
9
10
  const linkContext = LinkContext.useLinkContext();
10
- const uiStyle = UIStyle.useConfig();
11
- const buttonCva = uiStyle?.button?.cva ?? button;
12
- const buttonSizeCva = uiStyle?.button?.sizeCva ?? buttonSize;
13
- const buttonContentCva = uiStyle?.button?.contentCva ?? buttonContent;
14
- const buttonIconSizeCva = uiStyle?.button?.iconSize ?? buttonIconSize;
15
- const typographyMap = uiStyle?.button?.typography ?? buttonTypography;
11
+ const uiConfig = UIConfig.useConfig();
12
+ const { variant = uiConfig.button.variant, size = uiConfig.button.size } = props;
13
+ const buttonCva = UIStyle.useCva("button.cva", button);
14
+ const buttonSizeCva = UIStyle.useCva("button.sizeCva", buttonSize);
15
+ const buttonContentCva = UIStyle.useCva("button.contentCva", buttonContent);
16
+ const buttonIconSizeCva = UIStyle.useCva("button.iconSize", buttonIconSize);
17
+ const typographyMap = UIStyle.useMapper("button.typography", buttonTypography);
16
18
  const Component = (() => {
17
19
  if (link) return linkContext?.LinkComponent ?? Link;
18
20
  if (props.toggle != null) return ToggleButton;
@@ -25,9 +27,17 @@ const Button$1 = ({ icon: Icon, iconPosition, children, isLoading, className, li
25
27
  isDisabled: props.isDisabled || isLoading && !noDisableWhenLoading,
26
28
  className: clsx(buttonCva({
27
29
  ...props,
30
+ variant,
31
+ size,
28
32
  className
29
- }), buttonSizeCva({ ...props }), buttonContentCva({
33
+ }), buttonSizeCva({
30
34
  ...props,
35
+ variant,
36
+ size
37
+ }), buttonContentCva({
38
+ ...props,
39
+ variant,
40
+ size,
31
41
  iconPosition: !Icon ? "none" : iconPosition
32
42
  })),
33
43
  children: /* @__PURE__ */ jsx(ButtonContent, {
@@ -39,9 +49,15 @@ const Button$1 = ({ icon: Icon, iconPosition, children, isLoading, className, li
39
49
  iconPosition,
40
50
  iconClassName: buttonIconSizeCva({
41
51
  ...props,
52
+ variant,
53
+ size,
42
54
  className: iconClassName
43
55
  }),
44
- typography: typographyMap({ ...props })
56
+ typography: typographyMap({
57
+ ...props,
58
+ variant,
59
+ size
60
+ })
45
61
  })
46
62
  });
47
63
  };
@@ -6,9 +6,8 @@ import { jsx } from "react/jsx-runtime";
6
6
  import { clsx } from "clsx";
7
7
  import { Button, ToggleButton } from "react-aria-components";
8
8
  const PillButton = ({ children, dismissable, toggle, icon, iconPosition, contentRef, ...props }) => {
9
- const uiStyle = UIStyle.useConfig();
10
- const pillButtonCva = uiStyle?.pillButton?.cva ?? pillButton;
11
- const pillButtonTypographyMap = uiStyle?.pillButton?.typography ?? pillButtonTypography;
9
+ const pillButtonCva = UIStyle.useCva("pillButton.cva", pillButton);
10
+ const pillButtonTypographyMap = UIStyle.useMapper("pillButton.typography", pillButtonTypography);
12
11
  const Component = toggle ? ToggleButton : Button;
13
12
  const getIconPosition = () => {
14
13
  if (dismissable) return "right";
@@ -6,7 +6,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
6
  import { clsx } from "clsx";
7
7
  import { isValidElement } from "react";
8
8
  const ButtonContent = ({ ref, text, isLoading, icon: Icon, iconClassName, hideText, iconPosition = "left", typography: typographyOverrides }) => {
9
- const typographyCva = UIStyle.useConfig()?.typography?.cva ?? typography;
9
+ const typographyCva = UIStyle.useCva("typography.cva", typography);
10
10
  let iconOrLoader = null;
11
11
  if (isLoading) iconOrLoader = /* @__PURE__ */ jsx(Loader, { className: "shrink-0" });
12
12
  else if (Icon) if (isValidElement(Icon)) iconOrLoader = Icon;
@@ -1,8 +1,8 @@
1
1
  import { UIStyle } from "../../../config/uiStyle.context.js";
2
+ import { UIConfig } from "../../../config/uiConfig.context.js";
2
3
  import { checkboxIndicatorClass, checkboxTypography } from "./checkbox.cva.js";
3
4
  import { FormFieldError } from "../FormField/FormFieldError.js";
4
5
  import { CheckContent } from "../shared/CheckContent.js";
5
- import { UIConfig } from "../../../config/uiConfig.context.js";
6
6
  import { CheckboxCheckmark } from "./CheckboxCheckmark.js";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
8
  import { clsx } from "clsx";
@@ -11,7 +11,7 @@ import { mergeRefs } from "@react-aria/utils";
11
11
  import { Controller } from "react-hook-form";
12
12
  var CheckboxBase = (props) => {
13
13
  const ui = UIConfig.useConfig();
14
- const checkboxTypographyMap = UIStyle.useConfig()?.checkbox?.typography ?? checkboxTypography;
14
+ const checkboxTypographyMap = UIStyle.useMapper("checkbox.typography", checkboxTypography);
15
15
  const { className, children, isDisabled, error, variant = ui.checkbox.variant, hideLabel = ui.input.hideLabel, ...rest } = props;
16
16
  const formFieldErrorProps = {
17
17
  error,
@@ -4,9 +4,8 @@ import { UIStyle } from "../../../config/uiStyle.context.js";
4
4
  import { checkbox, checkboxIcon } from "./checkbox.cva.js";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  const CheckboxCheckmark = ({ variant, className, selectedIcon: SelectedIcon = CheckboxCheckmarkIcon, indeterminateIcon: IndeterminateIcon = CheckboxIndeterminateIcon, ...props }) => {
7
- const uiStyle = UIStyle.useConfig();
8
- const checkboxCva = uiStyle?.checkbox?.cva ?? checkbox;
9
- const checkboxIconCva = uiStyle?.checkbox?.iconCva ?? checkboxIcon;
7
+ const checkboxCva = UIStyle.useCva("checkbox.cva", checkbox);
8
+ const checkboxIconCva = UIStyle.useCva("checkbox.iconCva", checkboxIcon);
10
9
  return /* @__PURE__ */ jsxs("div", {
11
10
  className: checkboxCva({
12
11
  variant,
@@ -12,10 +12,9 @@ import { useImperativeHandle, useMemo, useRef } from "react";
12
12
  import { useDatePicker, useLocale } from "react-aria";
13
13
  import { mergeRefs } from "@react-aria/utils";
14
14
  import { Controller } from "react-hook-form";
15
- import { CalendarDate, createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
15
+ import { createCalendar, getLocalTimeZone, toCalendarDate, today } from "@internationalized/date";
16
16
  import { DateTime } from "luxon";
17
17
  import { useCalendarState, useDatePickerState } from "react-stately";
18
- var PLACEHOLDER_VALUE = new CalendarDate(2024, 1, 1);
19
18
  var DatePickerBase = (props) => {
20
19
  const ui = UIConfig.useConfig();
21
20
  const { ref, label, tooltipText, helperText, isRequired, rightContent, isDirty, isDisabled, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, className, placeholder, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
@@ -114,10 +113,7 @@ var DatePickerBase = (props) => {
114
113
  ref: mergeRefs(ref, datePickerInputRef),
115
114
  as,
116
115
  groupProps,
117
- fieldProps: {
118
- ...fieldProps,
119
- placeholderValue: PLACEHOLDER_VALUE
120
- },
116
+ fieldProps,
121
117
  buttonProps,
122
118
  isDirty,
123
119
  isDisabled,
@@ -15,11 +15,10 @@ import { Button } from "react-aria-components";
15
15
  import { useDateRangePicker, useLocale as useLocale$1 } from "react-aria";
16
16
  import { mergeRefs } from "@react-aria/utils";
17
17
  import { Controller } from "react-hook-form";
18
- import { CalendarDate, createCalendar, endOfMonth, endOfWeek, endOfYear, getLocalTimeZone, startOfMonth, startOfWeek, startOfYear, toCalendarDate, today } from "@internationalized/date";
18
+ import { createCalendar, endOfMonth, endOfWeek, endOfYear, getLocalTimeZone, startOfMonth, startOfWeek, startOfYear, toCalendarDate, today } from "@internationalized/date";
19
19
  import { DateTime } from "luxon";
20
20
  import { useDateRangePickerState, useRangeCalendarState } from "react-stately";
21
21
  import { useTranslation } from "react-i18next";
22
- var PLACEHOLDER_VALUE = new CalendarDate(2024, 1, 1);
23
22
  var DateRangePickerBase = (props) => {
24
23
  const ui = UIConfig.useConfig();
25
24
  const { t } = useTranslation();
@@ -464,14 +463,8 @@ var DateRangePickerBase = (props) => {
464
463
  ref: mergeRefs(ref, datePickerInputRef),
465
464
  as,
466
465
  groupProps,
467
- fieldProps: {
468
- ...startFieldProps,
469
- placeholderValue: PLACEHOLDER_VALUE
470
- },
471
- endFieldProps: {
472
- ...endFieldProps,
473
- placeholderValue: PLACEHOLDER_VALUE
474
- },
466
+ fieldProps: startFieldProps,
467
+ endFieldProps,
475
468
  buttonProps,
476
469
  isDisabled,
477
470
  isInvalid: !!error,
@@ -11,9 +11,8 @@ import { useEffect, useImperativeHandle, useMemo, useRef } from "react";
11
11
  import { useDatePicker, useLocale } from "react-aria";
12
12
  import { mergeRefs } from "@react-aria/utils";
13
13
  import { Controller } from "react-hook-form";
14
- import { CalendarDateTime, Time, createCalendar, getLocalTimeZone, now, toCalendarDateTime, today } from "@internationalized/date";
14
+ import { Time, createCalendar, getLocalTimeZone, now, toCalendarDateTime, today } from "@internationalized/date";
15
15
  import { useCalendarState, useDatePickerState } from "react-stately";
16
- var PLACEHOLDER_VALUE = new CalendarDateTime(2024, 1, 1);
17
16
  var DateTimePickerBase = (props) => {
18
17
  const ui = UIConfig.useConfig();
19
18
  const { ref, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, onChange, value, disableDropdown, isTimeOptional, placeholder, hideLabel = ui.input.hideLabel, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, isClearable = ui.input.isClearable, todayIcon = ui.dateInput.todayIcon, shouldForceLeadingZeros = ui.dateInput.shouldForceLeadingZeros, disableManualEntry = ui.dateInput.disableManualEntry, ...rest } = props;
@@ -129,7 +128,6 @@ var DateTimePickerBase = (props) => {
129
128
  groupProps,
130
129
  fieldProps: {
131
130
  ...fieldProps,
132
- placeholderValue: PLACEHOLDER_VALUE,
133
131
  onBlur: (e) => {
134
132
  fieldProps.onBlur?.(e);
135
133
  onInputBlur(e);
@@ -6,19 +6,18 @@ import { IconButton } from "../../../buttons/IconButton/IconButton.js";
6
6
  import { InlineIconButton } from "../../../buttons/InlineIconButton/InlineIconButton.js";
7
7
  import { TodayIcon } from "../../../../assets/icons/Today.js";
8
8
  import { DateField } from "./DateField.js";
9
- import { inputSide, useInputCva } from "../../shared/input.cva.js";
10
9
  import { FormFieldLabel } from "../../FormField/FormFieldLabel.js";
11
10
  import { InputClear } from "../../shared/InputClear.js";
11
+ import { inputBase, inputSize } from "../../shared/input.cva.js";
12
12
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
13
  import { clsx } from "clsx";
14
- import { useCallback, useImperativeHandle, useMemo, useRef, useState } from "react";
14
+ import { useCallback, useImperativeHandle, useRef, useState } from "react";
15
15
  import { Button } from "react-aria-components";
16
16
  import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
17
17
  import { getLocalTimeZone, now, toCalendarDateTime, today } from "@internationalized/date";
18
- import useMeasure from "react-use-measure";
19
18
  const DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, isDirty, isRequired, disableManualEntry, placeholder, onOpenDropdown, ...props }) => {
20
- const inputCva = useInputCva();
21
- const inputSideCva = UIStyle.useConfig()?.input?.sideCva ?? inputSide;
19
+ const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
20
+ const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
22
21
  const [canClear, setCanClear] = useState(false);
23
22
  const { hoverProps, isHovered } = useHover({ isDisabled });
24
23
  const [isFocused, setIsFocused] = useState(false);
@@ -33,8 +32,6 @@ const DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, butto
33
32
  const dateFieldRef = useRef(null);
34
33
  const endDateFieldRef = useRef(null);
35
34
  const containerRef = useRef(null);
36
- const [labelContentRef, { width: labelWidth }] = useMeasure();
37
- const [trailingContentRef, { width: trailingWidth }] = useMeasure();
38
35
  useImperativeHandle(ref, () => ({
39
36
  clear: () => {
40
37
  dateFieldRef.current?.clearField();
@@ -66,30 +63,11 @@ const DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, butto
66
63
  }
67
64
  };
68
65
  const hidePlaceholder = as === "floating" && !fieldProps.value && !isFocused;
69
- const style = useMemo(() => {
70
- return {
71
- paddingLeft: as === "filter" ? `calc(var(${inputSideCva({
72
- size,
73
- type: "var"
74
- })}) + ${labelWidth}px)` : "0px",
75
- paddingRight: `calc(var(${inputSideCva({
76
- size,
77
- type: "var"
78
- })}) + ${trailingWidth}px)`
79
- };
80
- }, [
81
- labelWidth,
82
- trailingWidth,
83
- as,
84
- size,
85
- inputSideCva
86
- ]);
87
66
  return /* @__PURE__ */ jsxs("div", {
88
67
  ref: containerRef,
89
- className: inputCva({
68
+ className: inputBaseCva({
90
69
  variant,
91
70
  as,
92
- size,
93
71
  ...props,
94
72
  className: clsx("group/date-picker-content relative flex min-w-input-width-min-width items-center justify-between gap-2")
95
73
  }),
@@ -107,63 +85,70 @@ const DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, butto
107
85
  ...groupProps,
108
86
  ...focusWithinProps,
109
87
  ...hoverProps,
110
- children: [/* @__PURE__ */ jsxs("div", { children: [as && ["filter", "floating"].includes(as) && headerProps && /* @__PURE__ */ jsx(FormFieldLabel, {
111
- ref: labelContentRef,
112
- as,
113
- ...headerProps
88
+ children: [/* @__PURE__ */ jsxs("div", {
89
+ className: clsx(inputSizeCva({
90
+ size,
91
+ as
92
+ }), "flex w-full items-center gap-input-gap-input-text-to-elements pr-0!"),
93
+ children: [as && ["filter", "floating"].includes(as) && headerProps && /* @__PURE__ */ jsx(FormFieldLabel, {
94
+ as,
95
+ ...headerProps
96
+ }), /* @__PURE__ */ jsxs("div", {
97
+ className: "flex items-center gap-input-gap-input-text-to-elements",
98
+ children: [
99
+ disableManualEntry && /* @__PURE__ */ jsx(Button, {
100
+ onPress: onOpenDropdown,
101
+ className: "absolute inset-0 z-0",
102
+ isDisabled
103
+ }),
104
+ todayIcon && /* @__PURE__ */ jsx(IconButton, {
105
+ label: "",
106
+ icon: TodayIcon,
107
+ size: "none",
108
+ onPress: onToday,
109
+ className: "relative z-1"
110
+ }),
111
+ disableManualEntry && placeholder && !fieldProps.value ? /* @__PURE__ */ jsx(Typography, {
112
+ size: "label-1",
113
+ className: "text-text-default-3",
114
+ children: placeholder
115
+ }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(DateField, {
116
+ ref: dateFieldRef,
117
+ ...fieldProps,
118
+ isDisabled,
119
+ isInvalid,
120
+ onClearChange,
121
+ hidePlaceholder,
122
+ disableManualEntry
123
+ }), endFieldProps && /* @__PURE__ */ jsxs(Fragment, { children: [!((as === "floating" || as === "filter") && hidePlaceholder) && /* @__PURE__ */ jsx("span", {
124
+ className: clsx("pointer-events-none select-none", isDisabled && "text-interactive-text-secondary-disabled"),
125
+ children: "–"
126
+ }), /* @__PURE__ */ jsx(DateField, {
127
+ ref: endDateFieldRef,
128
+ ...endFieldProps,
129
+ isDisabled,
130
+ isInvalid,
131
+ onClearChange,
132
+ hidePlaceholder,
133
+ disableManualEntry
134
+ })] })] })
135
+ ]
136
+ })]
114
137
  }), /* @__PURE__ */ jsxs("div", {
115
- className: "flex items-center gap-2",
116
- style,
117
- children: [
118
- disableManualEntry && /* @__PURE__ */ jsx(Button, {
119
- onPress: onOpenDropdown,
120
- className: "absolute inset-0 z-0",
121
- isDisabled
122
- }),
123
- todayIcon && /* @__PURE__ */ jsx(IconButton, {
124
- label: "",
125
- icon: TodayIcon,
126
- size: "none",
127
- onPress: onToday,
128
- className: "relative z-1"
129
- }),
130
- disableManualEntry && placeholder && !fieldProps.value ? /* @__PURE__ */ jsx(Typography, {
131
- size: "label-1",
132
- className: "text-text-default-3",
133
- children: placeholder
134
- }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(DateField, {
135
- ref: dateFieldRef,
136
- ...fieldProps,
137
- isDisabled,
138
- isInvalid,
139
- onClearChange,
140
- hidePlaceholder,
141
- disableManualEntry
142
- }), endFieldProps && /* @__PURE__ */ jsxs(Fragment, { children: [!((as === "floating" || as === "filter") && hidePlaceholder) && /* @__PURE__ */ jsx("span", {
143
- className: clsx("pointer-events-none select-none", isDisabled && "text-interactive-text-secondary-disabled"),
144
- children: "–"
145
- }), /* @__PURE__ */ jsx(DateField, {
146
- ref: endDateFieldRef,
147
- ...endFieldProps,
148
- isDisabled,
149
- isInvalid,
150
- onClearChange,
151
- hidePlaceholder,
152
- disableManualEntry
153
- })] })] })
154
- ]
155
- })] }), /* @__PURE__ */ jsxs("div", {
156
- ref: trailingContentRef,
157
- className: clsx("absolute top-1/2 flex -translate-y-1/2 items-center gap-2", inputSideCva({
138
+ className: clsx(inputSizeCva({
158
139
  size,
159
- type: "right"
160
- })),
161
- children: [isClearable && canClear && /* @__PURE__ */ jsx(InputClear, { onClear }), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(InlineIconButton, {
140
+ as
141
+ }), "flex items-center gap-input-gap-trailing-elements py-0! pl-0!"),
142
+ children: [isClearable && /* @__PURE__ */ jsx(InputClear, {
143
+ onClear,
144
+ show: canClear
145
+ }), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(InlineIconButton, {
162
146
  label: "",
163
147
  color: "secondary",
164
148
  ...buttonProps,
165
149
  icon: isDateTime ? DateTimeIcon : CalendarIcon,
166
- isDisabled
150
+ isDisabled,
151
+ className: "border-0!"
167
152
  })]
168
153
  })]
169
154
  });
@@ -2,53 +2,31 @@ import { ClockIcon } from "../../../../assets/icons/Clock.js";
2
2
  import { UIStyle } from "../../../../config/uiStyle.context.js";
3
3
  import { Typography } from "../../../text/Typography/Typography.js";
4
4
  import { InlineIconButton } from "../../../buttons/InlineIconButton/InlineIconButton.js";
5
- import { inputSide, useInputCva } from "../../shared/input.cva.js";
6
5
  import { FormFieldLabel } from "../../FormField/FormFieldLabel.js";
7
6
  import { InputClear } from "../../shared/InputClear.js";
7
+ import { inputBase, inputSize } from "../../shared/input.cva.js";
8
8
  import { TimeField } from "./TimeField.js";
9
9
  import { jsx, jsxs } from "react/jsx-runtime";
10
10
  import { clsx } from "clsx";
11
- import { useMemo, useState } from "react";
11
+ import { useState } from "react";
12
12
  import { Button } from "react-aria-components";
13
13
  import { useFocusVisible, useFocusWithin, useHover } from "react-aria";
14
- import useMeasure from "react-use-measure";
15
14
  const TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isInvalid, disableDropdown, variant, size, isClearable, headerProps, disableManualEntry, placeholder, onPress, ...props }) => {
16
- const inputCva = useInputCva();
17
- const inputSideCva = UIStyle.useConfig()?.input?.sideCva ?? inputSide;
15
+ const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
16
+ const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
18
17
  const { hoverProps, isHovered } = useHover({ isDisabled });
19
18
  const [isFocused, setIsFocused] = useState(false);
20
19
  const { focusWithinProps } = useFocusWithin({ onFocusWithinChange: setIsFocused });
21
20
  const { isFocusVisible } = useFocusVisible();
22
- const [labelContentRef, { width: labelWidth }] = useMeasure();
23
- const [trailingContentRef, { width: trailingWidth }] = useMeasure();
24
21
  const hidePlaceholder = as === "floating" && !state.value && !isFocused;
25
- const style = useMemo(() => {
26
- return {
27
- paddingLeft: as === "filter" ? `calc(var(${inputSideCva({
28
- size,
29
- type: "var"
30
- })}) + ${labelWidth}px)` : "0px",
31
- paddingRight: `calc(var(${inputSideCva({
32
- size,
33
- type: "var"
34
- })}) + ${trailingWidth}px)`
35
- };
36
- }, [
37
- labelWidth,
38
- trailingWidth,
39
- as,
40
- size,
41
- inputSideCva
42
- ]);
43
22
  const canClear = state.segments.some((segment) => segment.type !== "literal" && segment.isPlaceholder === false);
44
23
  return /* @__PURE__ */ jsxs("div", {
45
24
  ref,
46
- className: inputCva({
25
+ className: inputBaseCva({
47
26
  variant,
48
27
  as,
49
- size,
50
28
  ...props,
51
- className: clsx("group/date-picker-content relative flex min-w-input-width-min-width items-center justify-between gap-2")
29
+ className: clsx("group/date-picker-content relative min-w-input-width-min-width", "flex items-center justify-between gap-input-gap-input-text-to-elements")
52
30
  }),
53
31
  "data-rac": "",
54
32
  "data-datetime-input": "",
@@ -63,19 +41,21 @@ const TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isIn
63
41
  ...fieldProps,
64
42
  ...focusWithinProps,
65
43
  ...hoverProps,
66
- children: [/* @__PURE__ */ jsxs("div", { children: [
67
- disableManualEntry && /* @__PURE__ */ jsx(Button, {
68
- onPress,
69
- className: "absolute inset-0 z-0"
70
- }),
71
- as && ["filter", "floating"].includes(as) && headerProps && /* @__PURE__ */ jsx(FormFieldLabel, {
72
- ref: labelContentRef,
73
- as,
74
- ...headerProps
75
- }),
76
- /* @__PURE__ */ jsx("div", {
77
- style,
78
- children: disableManualEntry && placeholder && !state.value ? /* @__PURE__ */ jsx(Typography, {
44
+ children: [/* @__PURE__ */ jsxs("div", {
45
+ className: clsx(inputSizeCva({
46
+ size,
47
+ as
48
+ }), "flex w-full items-center gap-input-gap-input-text-to-elements pr-0!"),
49
+ children: [
50
+ disableManualEntry && /* @__PURE__ */ jsx(Button, {
51
+ onPress,
52
+ className: "absolute inset-0 z-0"
53
+ }),
54
+ as && ["filter", "floating"].includes(as) && headerProps && /* @__PURE__ */ jsx(FormFieldLabel, {
55
+ as,
56
+ ...headerProps
57
+ }),
58
+ /* @__PURE__ */ jsx("div", { children: disableManualEntry && placeholder && !state.value ? /* @__PURE__ */ jsx(Typography, {
79
59
  size: "label-1",
80
60
  className: "text-text-default-3",
81
61
  children: placeholder
@@ -84,20 +64,23 @@ const TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isIn
84
64
  state,
85
65
  isDisabled,
86
66
  hidePlaceholder
87
- })
88
- })
89
- ] }), /* @__PURE__ */ jsxs("div", {
90
- ref: trailingContentRef,
91
- className: clsx("absolute top-1/2 flex -translate-y-1/2 items-center gap-2", inputSideCva({
67
+ }) })
68
+ ]
69
+ }), /* @__PURE__ */ jsxs("div", {
70
+ className: clsx(inputSizeCva({
92
71
  size,
93
- type: "right"
94
- })),
95
- children: [isClearable && canClear && /* @__PURE__ */ jsx(InputClear, { onClear: () => state.setValue(null) }), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(InlineIconButton, {
72
+ as
73
+ }), "flex items-center gap-input-gap-trailing-elements py-0! pl-0!"),
74
+ children: [isClearable && /* @__PURE__ */ jsx(InputClear, {
75
+ onClear: () => state.setValue(null),
76
+ show: canClear
77
+ }), (!disableDropdown || disableManualEntry) && /* @__PURE__ */ jsx(InlineIconButton, {
96
78
  label: "",
97
79
  color: "secondary",
98
80
  onPress,
99
81
  icon: ClockIcon,
100
- isDisabled
82
+ isDisabled,
83
+ className: "border-0!"
101
84
  })]
102
85
  })]
103
86
  });
@@ -2,8 +2,8 @@ import { UIStyle } from "../../../../config/uiStyle.context.js";
2
2
  import { Typography } from "../../../text/Typography/Typography.js";
3
3
  import { Button as Button$1 } from "../../../buttons/Button/Button.js";
4
4
  import { TextButton } from "../../../buttons/TextButton/TextButton.js";
5
- import { inputSize } from "../../shared/input.cva.js";
6
5
  import { ns } from "../../../../config/i18n.js";
6
+ import { inputSize } from "../../shared/input.cva.js";
7
7
  import { UploadIcon } from "../../../../assets/icons/Upload.js";
8
8
  import { inputUploadButton, inputUploadDropZone } from "./inputUploadButton.cva.js";
9
9
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -13,7 +13,7 @@ import { useTranslation } from "react-i18next";
13
13
  const InputUploadContent = (props) => {
14
14
  const { variant, isDisabled, error, placeholder, buttonText, ...rest } = props;
15
15
  const { t } = useTranslation("ui");
16
- const inputSizeCva = UIStyle.useConfig()?.input?.sizeCva ?? inputSize;
16
+ const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
17
17
  return /* @__PURE__ */ jsx(FileTrigger, {
18
18
  ...rest,
19
19
  children: /* @__PURE__ */ jsxs("div", {
@@ -7,7 +7,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
7
7
  import { clsx } from "clsx";
8
8
  const InputUploadFilled = ({ files, onRemove, isDisabled }) => {
9
9
  return /* @__PURE__ */ jsxs("div", {
10
- className: clsx("flex items-center rounded-input-rounding-default border border-input-outlined-outline-idle border-solid bg-input-outlined-idle", (UIStyle.useConfig()?.input?.sizeCva ?? inputSize)({ size: "default" })),
10
+ className: clsx("flex items-center rounded-input-rounding-default border border-input-outlined-outline-idle border-solid bg-input-outlined-idle", UIStyle.useCva("input.sizeCva", inputSize)({ size: "default" })),
11
11
  children: [/* @__PURE__ */ jsx(Typography, {
12
12
  variant: "default",
13
13
  size: "label-1",
@@ -16,7 +16,7 @@ const FormField = ({ ref, as, label, tooltipText, helperText, isRequired, rightC
16
16
  const errorProps = {
17
17
  error,
18
18
  isDisabled,
19
- isHidden: isHeaderHidden,
19
+ isHidden: ["filter", "inline"].includes(as ?? ""),
20
20
  className: errorClassName
21
21
  };
22
22
  return /* @__PURE__ */ jsxs("div", {