@povio/ui 2.2.9-rc.34 → 2.2.9-rc.36

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.
@@ -97,6 +97,8 @@ var NumberInputBase = (props) => {
97
97
  ...rest
98
98
  }), inputClassName),
99
99
  onClick: () => inputRef.current?.focus(),
100
+ "data-is-empty": value === null || value === void 0 || void 0,
101
+ "data-is-required": isRequired || void 0,
100
102
  children: /* @__PURE__ */ jsx(InputContent, {
101
103
  ...inputContentProps,
102
104
  headerProps,
@@ -164,6 +166,7 @@ var NumberInput = ({ renderStaticInput, ...props }) => {
164
166
  onStaticInteract: renderRealInput,
165
167
  inputClassName: props.inputClassName,
166
168
  children: (dataAttributeProps) => /* @__PURE__ */ jsx("input", {
169
+ type: "number",
167
170
  ref: inputRef,
168
171
  disabled: isDisabled,
169
172
  tabIndex: -1,
@@ -4,7 +4,8 @@ import { FieldValues } from 'react-hook-form';
4
4
  import { FormFieldProps } from '../FormField/FormField';
5
5
  import { RadioVariantProps } from './radio.cva';
6
6
  import { ControlProps } from '../shared/form.types';
7
- interface RadioGroupBaseProps extends Omit<FormFieldProps, "variant">, RadioVariantProps, Omit<AriaRadioGroupProps, "className"> {
7
+ import { InputVariantProps } from '../shared/input.cva';
8
+ interface RadioGroupBaseProps extends Omit<FormFieldProps, "variant">, RadioVariantProps, Omit<InputVariantProps, "variant">, Omit<AriaRadioGroupProps, "className"> {
8
9
  ref?: Ref<HTMLDivElement>;
9
10
  options: {
10
11
  label: string | ReactElement;
@@ -1,20 +1,30 @@
1
1
  import { UIStyle } from "../../../config/uiStyle.context.js";
2
2
  import { UIConfig } from "../../../config/uiConfig.context.js";
3
3
  import { CheckContent } from "../shared/CheckContent.js";
4
+ import { FormFieldLabel } from "../FormField/FormFieldLabel.js";
5
+ import { inputBase, inputSize } from "../shared/input.cva.js";
4
6
  import { FormField } from "../FormField/FormField.js";
7
+ import { TooltipWrapper } from "../shared/TooltipWrapper.js";
5
8
  import { radio, radioContentClassName, radioIndicatorClass, radioTypography } from "./radio.cva.js";
6
9
  import { jsx, jsxs } from "react/jsx-runtime";
7
10
  import { clsx } from "clsx";
8
11
  import { Radio, RadioGroup } from "react-aria-components";
12
+ import { useLabel } from "react-aria";
9
13
  import { mergeRefs } from "@react-aria/utils";
10
14
  import { Controller } from "react-hook-form";
11
15
  //#region src/components/inputs/RadioGroup/RadioGroup.tsx
12
16
  var RadioGroupBase = (props) => {
13
17
  const ui = UIConfig.useConfig();
14
18
  const radioCva = UIStyle.useCva("radio.cva", radio);
19
+ const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
20
+ const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
15
21
  const radioTypographyMap = UIStyle.useMapper("radio.typography", radioTypography);
16
22
  const radioContentClassNameMap = UIStyle.useMapper("radio.contentClassName", radioContentClassName);
17
- const { label, tooltipText, helperText, isDirty, isRequired, rightContent, isDisabled, headerClassName, errorClassName, labelClassName, inputClassName, isHeaderHidden, error, className, options, variant = ui.radioGroup.variant, hideLabel = ui.radioGroup.hideLabel, ...rest } = props;
23
+ const { ref, label, tooltipText, helperText, isDirty, isRequired, rightContent, isDisabled, headerClassName, errorClassName, labelClassName, inputClassName, isHeaderHidden, error, className, options, value, defaultValue, as: asProp, size: sizeProp, variant: variantProp, hideLabel: hideLabelProp, ...rest } = props;
24
+ const as = asProp ?? ui.input.as;
25
+ const size = sizeProp ?? ui.input.size;
26
+ const variant = variantProp ?? ui.radioGroup.variant;
27
+ const hideLabel = hideLabelProp ?? ui.radioGroup.hideLabel;
18
28
  const radioClassName = radioCva({
19
29
  variant,
20
30
  ...rest
@@ -35,32 +45,80 @@ var RadioGroupBase = (props) => {
35
45
  helperText,
36
46
  isRequired,
37
47
  rightContent,
38
- isHeaderHidden,
48
+ isHeaderHidden: isHeaderHidden || as === "inline" || as === "filter" || as === "floating",
39
49
  hideLabel,
40
50
  isDisabled,
41
51
  headerClassName,
42
52
  errorClassName
43
53
  };
44
- return /* @__PURE__ */ jsx(RadioGroup, {
45
- ...rest,
54
+ const { labelProps, fieldProps } = useLabel({ label });
55
+ const headerProps = {
56
+ label,
57
+ tooltipText,
58
+ helperText,
59
+ isRequired,
60
+ rightContent,
61
+ isHeaderHidden: hideLabel || isHeaderHidden,
46
62
  isDisabled,
47
- isInvalid: !!error,
48
- "data-is-dirty": isDirty || void 0,
49
- "data-is-required": isRequired || void 0,
50
- children: /* @__PURE__ */ jsx(FormField, {
51
- ...formFieldProps,
52
- children: /* @__PURE__ */ jsx("div", {
53
- className: clsx("flex flex-col", inputClassName),
54
- children: options.map((option) => /* @__PURE__ */ jsxs(Radio, {
55
- value: option.value,
56
- className: clsx("relative", radioIndicatorClass),
57
- children: [/* @__PURE__ */ jsx("div", { className: radioClassName }), /* @__PURE__ */ jsx(CheckContent, {
58
- typography: radioTypographyProps,
59
- contentClassName: radioContentClassNameValue,
60
- className: labelClassName,
61
- children: option.label
62
- })]
63
- }, option.value))
63
+ className: headerClassName,
64
+ labelProps
65
+ };
66
+ const selectedValue = value ?? defaultValue;
67
+ const shouldRenderInputFrame = as !== "default";
68
+ return /* @__PURE__ */ jsx(TooltipWrapper, {
69
+ as,
70
+ error,
71
+ triggerTabIndex: as === "inline" ? -1 : void 0,
72
+ children: /* @__PURE__ */ jsx(RadioGroup, {
73
+ ...rest,
74
+ ...fieldProps,
75
+ ref,
76
+ value,
77
+ defaultValue,
78
+ isDisabled,
79
+ isInvalid: !!error,
80
+ "data-is-dirty": isDirty || void 0,
81
+ "data-is-required": isRequired || void 0,
82
+ children: /* @__PURE__ */ jsx(FormField, {
83
+ ...formFieldProps,
84
+ as,
85
+ labelProps,
86
+ className: clsx("w-full", as === "inline" && "h-full", className),
87
+ tabIndex: as === "inline" ? -1 : void 0,
88
+ children: /* @__PURE__ */ jsx("div", {
89
+ className: clsx("group/radio-group-content relative", shouldRenderInputFrame && inputBaseCva({
90
+ variant: ui.input.variant,
91
+ as
92
+ }), inputClassName),
93
+ "data-rac": "",
94
+ "data-disabled": isDisabled || void 0,
95
+ "data-is-disabled": isDisabled || void 0,
96
+ "data-invalid": !!error || void 0,
97
+ "data-has-selection": selectedValue != null && selectedValue !== "" ? true : void 0,
98
+ "data-radio-group-content": "",
99
+ children: /* @__PURE__ */ jsxs("div", {
100
+ className: clsx("relative flex", as === "inline" || as === "filter" ? "flex-row flex-wrap items-center gap-2" : "flex-col", shouldRenderInputFrame && clsx("gap-2", inputSizeCva({
101
+ as,
102
+ size
103
+ }))),
104
+ "data-is-dirty": isDirty || void 0,
105
+ "data-is-required": isRequired || void 0,
106
+ children: [as && ["filter", "floating"].includes(as) && /* @__PURE__ */ jsx(FormFieldLabel, {
107
+ as,
108
+ size,
109
+ ...headerProps
110
+ }), options.map((option) => /* @__PURE__ */ jsxs(Radio, {
111
+ value: option.value,
112
+ className: clsx("relative", radioIndicatorClass),
113
+ children: [/* @__PURE__ */ jsx("div", { className: radioClassName }), /* @__PURE__ */ jsx(CheckContent, {
114
+ typography: radioTypographyProps,
115
+ contentClassName: radioContentClassNameValue,
116
+ className: labelClassName,
117
+ children: option.label
118
+ })]
119
+ }, option.value))]
120
+ })
121
+ })
64
122
  })
65
123
  })
66
124
  });
@@ -1,4 +1,4 @@
1
- import { FC, ReactElement, ReactNode, Ref, SVGProps } from 'react';
1
+ import { FC, FocusEventHandler, MouseEventHandler, ReactElement, ReactNode, Ref, SVGProps } from 'react';
2
2
  import { InlineIconButtonProps } from '../../buttons/InlineIconButton/InlineIconButton';
3
3
  import { FormFieldProps } from '../FormField/FormField';
4
4
  import { FormFieldHeaderProps } from '../FormField/FormFieldHeader';
@@ -43,6 +43,8 @@ export interface InputFrameProps extends InputVariantProps, Partial<FormFieldPro
43
43
  ref?: Ref<HTMLDivElement>;
44
44
  children: InputFrameChildren;
45
45
  formFieldRef?: Ref<HTMLDivElement>;
46
+ onMouseEnter?: MouseEventHandler<HTMLDivElement>;
47
+ onFocusCapture?: FocusEventHandler<HTMLDivElement>;
46
48
  labelProps?: FormFieldHeaderProps["labelProps"];
47
49
  headerProps?: FormFieldHeaderProps;
48
50
  leadingContent?: ReactNode;
@@ -19,7 +19,7 @@ var InputFrame = (props) => {
19
19
  const inputContentWrapperCva = UIStyle.useCva("input.contentWrapperCva", inputContentWrapper);
20
20
  const typographyCva = UIStyle.useCva("typography.cva", typography);
21
21
  const generatedInputId = useId();
22
- const { ref, children, formFieldRef, labelProps: labelPropsProp, headerProps, error, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isHeaderHidden, hideLabel: hideLabelProp, headerClassName, errorClassName, className, leadingContent, leadingIcon, actionContent, actionContentPlacement = "content-wrapper", trailingContent, trailingIcon, trailingAction, unit, isLoading, action, isClearable: isClearableProp, showClear, renderStatic, onStaticInteract, clearClassName, onClear, dataAttributes, typographySize, id: idProp, inputClassName, contentClassName, contentWrapperClassName, labelPlacement = "content-wrapper", trailingClassName, variant: variantProp, as: asProp, size: sizeProp } = props;
22
+ const { ref, children, formFieldRef, labelProps: labelPropsProp, headerProps, error, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isHeaderHidden, hideLabel: hideLabelProp, headerClassName, errorClassName, className, leadingContent, leadingIcon, actionContent, actionContentPlacement = "content-wrapper", trailingContent, trailingIcon, trailingAction, unit, isLoading, action, isClearable: isClearableProp, showClear, renderStatic, onStaticInteract, clearClassName, onClear, dataAttributes, typographySize, id: idProp, inputClassName, contentClassName, contentWrapperClassName, labelPlacement = "content-wrapper", trailingClassName, onMouseEnter, onFocusCapture, variant: variantProp, as: asProp, size: sizeProp } = props;
23
23
  const as = asProp ?? ui.input.as;
24
24
  const size = sizeProp ?? ui.input.size;
25
25
  const variant = variantProp ?? ui.input.variant;
@@ -81,10 +81,12 @@ var InputFrame = (props) => {
81
81
  as,
82
82
  labelProps,
83
83
  tabIndex: as === "inline" ? -1 : void 0,
84
- onMouseEnter: () => {
84
+ onMouseEnter: (event) => {
85
+ onMouseEnter?.(event);
85
86
  if (renderStatic) onStaticInteract?.(false);
86
87
  },
87
- onFocusCapture: () => {
88
+ onFocusCapture: (event) => {
89
+ onFocusCapture?.(event);
88
90
  if (renderStatic) onStaticInteract?.(true);
89
91
  },
90
92
  children: /* @__PURE__ */ jsxs("div", {
@@ -10,10 +10,10 @@ var useQueryAutocomplete = ({ query, queryParams, queryOptions, mapItems, initia
10
10
  ...queryParams,
11
11
  limit: queryParams?.limit ?? ApiQueryUtils.DEFAULT_LIMIT,
12
12
  search,
13
- ...isFilterSearchParams(queryParams) ? { filter: {
14
- ...queryParams.filter,
13
+ filter: {
14
+ ...isFilterSearchParams(queryParams) ? queryParams.filter : {},
15
15
  search
16
- } } : {}
16
+ }
17
17
  }, {
18
18
  ...queryOptions,
19
19
  enabled: isQueryEnabled && (queryOptions?.enabled ?? true)
@@ -27,14 +27,19 @@ var useQueryAutocomplete = ({ query, queryParams, queryOptions, mapItems, initia
27
27
  setIsQueryEnabled(true);
28
28
  };
29
29
  const infiniteQueryResult = isInfiniteQueryResult(queryResult) ? queryResult : void 0;
30
+ const isInfiniteQuery = infiniteQueryResult !== void 0;
30
31
  const hasNextPage = infiniteQueryResult?.hasNextPage ?? false;
31
32
  const fetchNextPage = infiniteQueryResult?.fetchNextPage;
32
33
  const isFetchingNextPage = infiniteQueryResult?.isFetchingNextPage ?? false;
33
34
  const totalItems = infiniteQueryResult?.data?.pages?.[0]?.totalItems;
34
35
  const items = useMemo(() => {
35
36
  if (!data) return [];
36
- return mapItems(data);
37
- }, [data, mapItems]);
37
+ return mapItems(isInfiniteQuery ? data.pages?.flatMap((page) => page?.items ?? []) : data);
38
+ }, [
39
+ data,
40
+ isInfiniteQuery,
41
+ mapItems
42
+ ]);
38
43
  return {
39
44
  data,
40
45
  isLoading: isLoading || isFetchingNextPage,
@@ -7,6 +7,7 @@ var uiPlugin = plugin(({ addVariant }) => {
7
7
  "&:is(:where(.group\\/select-content)[data-has-selection] *)",
8
8
  "&:is(:where(.group\\/select-content)[data-has-search] *)",
9
9
  "&:is(:where(.group\\/select-content)[data-searchable-focus-within] *)",
10
+ "&:is(:where(.group\\/radio-group-content)[data-radio-group-content] *)",
10
11
  "&:is(:where(.group\\/date-picker-content)[data-has-selection] *)",
11
12
  "&:is(:where(.group\\/date-picker-content)[data-focus-within] *)"
12
13
  ].join(", "));
@@ -14,6 +15,7 @@ var uiPlugin = plugin(({ addVariant }) => {
14
15
  "&:is(:where(.group\\/input-content):has(*:is(input:disabled)) *)",
15
16
  "&:is(:where(.group\\/select-content)[data-disabled] *)",
16
17
  "&:is(:where(.group\\/select-content):has(*:is(input:disabled)) *)",
18
+ "&:is(:where(.group\\/radio-group-content)[data-disabled] *)",
17
19
  "&:is(:where(.group\\/text-area):has(*:is(textarea:disabled)) *)",
18
20
  "&:is(:where(.group\\/text-editor):where([data-rac])[data-disabled] *)",
19
21
  "&:is(:where(.group\\/date-picker-content):where([data-rac])[data-disabled] *)"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.2.9-rc.34",
3
+ "version": "2.2.9-rc.36",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",