@povio/ui 2.2.9-rc.10 → 2.2.9-rc.12

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.
@@ -5,6 +5,7 @@ import { Typography } from "../../../text/Typography/Typography.js";
5
5
  import { InlineIconButton } from "../../../buttons/InlineIconButton/InlineIconButton.js";
6
6
  import { TodayIcon } from "../../../../assets/icons/Today.js";
7
7
  import { DateField } from "./DateField.js";
8
+ import { datePickerInputContentRow } from "./datePickerInput.cva.js";
8
9
  import { FormFieldLabel } from "../../FormField/FormFieldLabel.js";
9
10
  import { InputClear } from "../../shared/InputClear.js";
10
11
  import { inputBase, inputSize } from "../../shared/input.cva.js";
@@ -18,6 +19,7 @@ import { getLocalTimeZone, now, toCalendarDateTime, today } from "@international
18
19
  var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonProps, isDisabled, isInvalid, disableDropdown, variant, size, isDateTime, isClearable, headerProps, todayIcon, todayIconButtonSize = "none", isDirty, isRequired, disableManualEntry, autoFixYear = false, placeholder, className, onOpenDropdown, ...props }) => {
19
20
  const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
20
21
  const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
22
+ const datePickerInputContentRowCva = UIStyle.useCva("datePickerInput.contentRowCva", datePickerInputContentRow);
21
23
  const [canClear, setCanClear] = useState(false);
22
24
  const { hoverProps, isHovered } = useHover({ isDisabled });
23
25
  const [isFocused, setIsFocused] = useState(false);
@@ -101,7 +103,7 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
101
103
  as,
102
104
  ...headerProps
103
105
  }), /* @__PURE__ */ jsxs("div", {
104
- className: "flex items-center gap-input-gap-input-text-to-elements",
106
+ className: datePickerInputContentRowCva({ size }),
105
107
  children: [
106
108
  disableManualEntry && /* @__PURE__ */ jsx(Button, {
107
109
  onPress: onOpenDropdown,
@@ -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 };
@@ -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 {};
@@ -84,6 +84,8 @@ var TextInputBase = (props) => {
84
84
  ...rest
85
85
  }), inputClassName),
86
86
  onClick: () => inputRef.current?.focus(),
87
+ "data-is-empty": value === "" || value === null || value === void 0 || void 0,
88
+ "data-is-required": isRequired || void 0,
87
89
  children: /* @__PURE__ */ jsx(InputContent, {
88
90
  ...inputContentProps,
89
91
  headerProps,
@@ -11,7 +11,7 @@ var QueryAutocomplete = ({ query, queryParams, queryOptions, queryMap, ...props
11
11
  const extractedData = Array.isArray(data) ? data : data.pages.flatMap((page) => page.items ?? []);
12
12
  return queryMap?.(extractedData) ?? extractedData;
13
13
  };
14
- const { items, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete({
14
+ const { items, totalItems, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete({
15
15
  query,
16
16
  queryParams,
17
17
  queryOptions,
@@ -26,10 +26,11 @@ var QueryAutocomplete = ({ query, queryParams, queryOptions, queryMap, ...props
26
26
  onSearchChange: setSearch,
27
27
  isClientSearchDisabled: true,
28
28
  isLoading,
29
+ totalItems,
29
30
  onMouseEnter: handleEnableQuery,
30
31
  onFocusCapture: handleEnableQuery,
31
32
  hasLoadMore: hasNextPage,
32
- onLoadMore: fetchNextPage ? () => void fetchNextPage() : void 0
33
+ onLoadMore: fetchNextPage
33
34
  });
34
35
  };
35
36
  //#endregion
@@ -8,7 +8,7 @@ import { Controller } from "react-hook-form";
8
8
  //#region src/components/inputs/Selection/Select/QuerySelect.tsx
9
9
  var QuerySelect = ({ query, queryParams, queryOptions, queryMap, ...props }) => {
10
10
  const ui = UIConfig.useConfig();
11
- const { items, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete({
11
+ const { items, totalItems, isLoading, handleEnableQuery, hasNextPage, fetchNextPage } = useQueryAutocomplete({
12
12
  query,
13
13
  queryParams,
14
14
  queryOptions,
@@ -25,8 +25,9 @@ var QuerySelect = ({ query, queryParams, queryOptions, queryMap, ...props }) =>
25
25
  ref: mergeRefs(ref, field.ref),
26
26
  items,
27
27
  isLoading,
28
+ totalItems,
28
29
  hasLoadMore: hasNextPage,
29
- onLoadMore: fetchNextPage ? () => void fetchNextPage() : void 0,
30
+ onLoadMore: fetchNextPage,
30
31
  value: field.value,
31
32
  onChange: (value) => {
32
33
  field.onChange(value);
@@ -46,6 +47,7 @@ var QuerySelect = ({ query, queryParams, queryOptions, queryMap, ...props }) =>
46
47
  ...restProps,
47
48
  items,
48
49
  isLoading,
50
+ totalItems,
49
51
  hasLoadMore: hasNextPage,
50
52
  onLoadMore: fetchNextPage ? () => void fetchNextPage() : void 0,
51
53
  onMouseEnter: handleEnableQuery,
@@ -17,7 +17,7 @@ var SelectBase = (dProps) => {
17
17
  isClearable: dProps.isClearable ?? ui.input.isClearable,
18
18
  isSearchable: dProps.isSearchable ?? ui.select.isSearchable,
19
19
  selectedTagsType: dProps.selectedTagsType ?? ui.select.selectedTagsType,
20
- ignoreTriggerWidth: dProps.virtualizerOptions || dProps.items.length > 100 ? false : dProps.ignoreTriggerWidth ?? false,
20
+ ignoreTriggerWidth: dProps.virtualizerOptions || (dProps.totalItems ?? 0) > 100 || dProps.hasLoadMore ? false : dProps.ignoreTriggerWidth ?? false,
21
21
  collapseAfter: dProps.collapseAfter ?? ui.select.collapseAfter,
22
22
  hideSearchIcon: dProps.hideSearchIcon ?? ui.select.hideSearchIcon,
23
23
  fireBlurOnChange: dProps.fireBlurOnChange ?? ui.select.fireBlurOnChange,
@@ -6,6 +6,7 @@ import "./useSelectItems.js";
6
6
  import { SelectContext } from "./select.context.js";
7
7
  import { SelectInput } from "./SelectInput.js";
8
8
  import { SelectListBox } from "./SelectListBox.js";
9
+ import { selectPopoverCva } from "./selectDesktop.cva.js";
9
10
  import { jsx, jsxs } from "react/jsx-runtime";
10
11
  import { clsx } from "clsx";
11
12
  import { Fragment as Fragment$1, useLayoutEffect, useMemo, useRef, useState } from "react";
@@ -16,6 +17,7 @@ import { mergeRefs } from "@react-aria/utils";
16
17
  var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inputClassName, containerClassName, leadingContent, trailingContent, customTrigger, onBlur, onMouseEnter, onFocusCapture, ...props }) => {
17
18
  const { label, tooltipText, helperText, isDirty, isRequired, rightContent, isHeaderHidden, headerClassName, errorClassName, placeholder, variant, isDisabled, className, hideLabel, hideDropdownIcon, isSearchable, isClearable, isLoading, as, size, collapseAfter, selectedTagsType } = props;
18
19
  const popoverCva = UIStyle.useCva("popover.cva", popover);
20
+ const selectPopoverCva$1 = UIStyle.useCva("select.popoverCva", selectPopoverCva);
19
21
  const formFieldProps = {
20
22
  error,
21
23
  label,
@@ -113,14 +115,14 @@ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inp
113
115
  className: clsx("w-full", containerClassName)
114
116
  },
115
117
  as,
118
+ onMouseEnter,
119
+ onFocusCapture,
116
120
  ref: wrapperRef,
117
121
  children: [customTrigger ? /* @__PURE__ */ jsx(DialogTrigger, {
118
122
  ...dialogTriggerProps,
119
123
  children: /* @__PURE__ */ jsx("div", {
120
124
  ...fieldProps,
121
125
  ref: mergeRefs(ref, triggerRef),
122
- onMouseEnter,
123
- onFocusCapture,
124
126
  children: customTrigger
125
127
  })
126
128
  }) : /* @__PURE__ */ jsx(SelectInput, {
@@ -153,7 +155,7 @@ var SelectDesktop = ({ ref, error, ignoreTriggerWidth, showSelectionContent, inp
153
155
  triggerRef,
154
156
  isOpen,
155
157
  onOpenChange: setIsOpen,
156
- className: "my-4 outline-none",
158
+ className: selectPopoverCva$1({}),
157
159
  style: { width: !ignoreTriggerWidth ? popoverWidth : void 0 },
158
160
  offset: 0,
159
161
  children: /* @__PURE__ */ jsx(SelectListBox, {
@@ -1,9 +1,9 @@
1
1
  import { AriaListBoxProps } from 'react-aria';
2
2
  import { SelectBaseProps } from './SelectBase';
3
3
  import { SelectItem } from './select.types';
4
- export interface SelectListBoxProps extends Pick<SelectBaseProps, "label" | "newItemRender" | "onLoadMore" | "selectionMode" | "isSearchable" | "virtualizerOptions">, Omit<AriaListBoxProps<SelectItem>, "children" | "aria-label" | "selectionMode" | "items" | "selectedKeys" | "onSelectionChange" | "escapeKeyBehavior" | "shouldSelectOnPressUp" | "label"> {
4
+ export interface SelectListBoxProps extends Pick<SelectBaseProps, "label" | "newItemRender" | "onLoadMore" | "selectionMode" | "isSearchable" | "virtualizerOptions" | "totalItems" | "hasLoadMore">, Omit<AriaListBoxProps<SelectItem>, "children" | "aria-label" | "selectionMode" | "items" | "selectedKeys" | "onSelectionChange" | "escapeKeyBehavior" | "shouldSelectOnPressUp" | "label"> {
5
5
  className?: string;
6
6
  isScrollable?: boolean;
7
7
  onClose?: () => void;
8
8
  }
9
- export declare const SelectListBox: ({ label, selectionMode, isSearchable, isScrollable, virtualizerOptions, newItemRender, onLoadMore, className, onClose, ...props }: SelectListBoxProps) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const SelectListBox: ({ label, selectionMode, isSearchable, isScrollable, virtualizerOptions, totalItems, hasLoadMore, newItemRender, onLoadMore, className, onClose, ...props }: SelectListBoxProps) => import("react/jsx-runtime").JSX.Element;
@@ -7,7 +7,7 @@ import { jsx } from "react/jsx-runtime";
7
7
  import { clsx } from "clsx";
8
8
  import { ListBox, ListLayout, Virtualizer } from "react-aria-components";
9
9
  //#region src/components/inputs/Selection/shared/SelectListBox.tsx
10
- var SelectListBox = ({ label, selectionMode, isSearchable, isScrollable = true, virtualizerOptions, newItemRender, onLoadMore, className, onClose, ...props }) => {
10
+ var SelectListBox = ({ label, selectionMode, isSearchable, isScrollable = true, virtualizerOptions, totalItems, hasLoadMore, newItemRender, onLoadMore, className, onClose, ...props }) => {
11
11
  const { fieldState, onChange, listItems, selectableListItems, selectedIds, isMultiple, onClear, onSelectAll } = SelectContext.useSelect();
12
12
  const onSelectionChange = (value) => {
13
13
  const ids = Array.from(value);
@@ -42,7 +42,7 @@ var SelectListBox = ({ label, selectionMode, isSearchable, isScrollable = true,
42
42
  newItemRender
43
43
  }, item.id);
44
44
  };
45
- if (virtualizerOptions || listItems.length > 100) return /* @__PURE__ */ jsx(Virtualizer, {
45
+ if (virtualizerOptions || (totalItems ?? listItems.length) > 100 || hasLoadMore) return /* @__PURE__ */ jsx(Virtualizer, {
46
46
  layout: ListLayout,
47
47
  layoutOptions: virtualizerOptions,
48
48
  children: /* @__PURE__ */ jsx(ListBox, {
@@ -57,13 +57,13 @@ var SelectMobile = ({ ref, error, showSelectionContent, inputClassName, containe
57
57
  as,
58
58
  labelProps,
59
59
  className: clsx("w-full", containerClassName),
60
+ onMouseEnter,
61
+ onFocusCapture,
60
62
  children: /* @__PURE__ */ jsxs(DialogTrigger, {
61
63
  ...dialogTriggerProps,
62
64
  children: [customTrigger ? /* @__PURE__ */ jsx("div", {
63
65
  ...fieldProps,
64
66
  ref,
65
- onMouseEnter,
66
- onFocusCapture,
67
67
  children: customTrigger
68
68
  }) : /* @__PURE__ */ jsx(SelectInput, {
69
69
  ref,
@@ -54,6 +54,7 @@ export interface SelectAsyncProps {
54
54
  onLoadMore?: () => void;
55
55
  }
56
56
  export interface SelectVirtualizationProps {
57
+ totalItems?: number;
57
58
  virtualizerOptions?: {
58
59
  rowHeight?: number;
59
60
  estimatedRowHeight?: number;
@@ -0,0 +1,3 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ export declare const selectPopoverCva: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
3
+ export type SelectPopoverCva = VariantProps<typeof selectPopoverCva>;
@@ -0,0 +1,5 @@
1
+ import { cva } from "class-variance-authority";
2
+ //#region src/components/inputs/Selection/shared/selectDesktop.cva.ts
3
+ var selectPopoverCva = cva("my-4 outline-none");
4
+ //#endregion
5
+ export { selectPopoverCva };
@@ -4,10 +4,13 @@ import { BreadcrumbChevronVariantProps, BreadcrumbIconVariantProps, BreadcrumbIt
4
4
  import { ButtonVariantProps } from '../components/buttons/Button/button.cva';
5
5
  import { PillButtonVariants } from '../components/buttons/PillButton/pillButton.cva';
6
6
  import { CheckboxIconVariantProps, CheckboxVariantProps } from '../components/inputs/Checkbox/checkbox.cva';
7
+ import { DatePickerInputContentRowProps } from '../components/inputs/DateTime/shared/datePickerInput.cva';
7
8
  import { FormFieldErrorVariantProps } from '../components/inputs/FormField/formFieldError.cva';
8
9
  import { FormFieldHeaderVariantProps } from '../components/inputs/FormField/formFieldHeader.cva';
9
10
  import { FormFieldHelperVariantProps } from '../components/inputs/FormField/formFieldHelper.cva';
10
11
  import { RadioVariantProps } from '../components/inputs/RadioGroup/radio.cva';
12
+ import { SelectPopoverCva } from '../components/inputs/Selection/shared/selectDesktop.cva';
13
+ import { SelectListBoxItemCva } from '../components/inputs/Selection/shared/selectItem.cva';
11
14
  import { InputBaseProps, InputSideProps, InputSizeProps } from '../components/inputs/shared/input.cva';
12
15
  import { LabelBaseProps } from '../components/inputs/shared/label.cva';
13
16
  import { ToggleVariantProps } from '../components/inputs/Toggle/toggle.cva';
@@ -25,7 +28,6 @@ import { LinkVariantProps } from '../components/text/Link/link.cva';
25
28
  import { TagVariantProps } from '../components/text/Tag/tag.cva';
26
29
  import { TypographyVariantProps } from '../components/text/Typography/typography.cva';
27
30
  import { CompoundMapper, ConfigSchema } from '../utils/compoundMapper';
28
- import { SelectListBoxItemCva } from '../components/inputs/Selection/shared/selectItem.cva';
29
31
  export declare namespace UIStyle {
30
32
  export type Cva<T> = (props: (T & ClassProp) | ClassProp) => string;
31
33
  type OptionKey = {
@@ -70,6 +72,9 @@ export declare namespace UIStyle {
70
72
  sizeCva?: Cva<InputSizeProps>;
71
73
  sideCva?: Cva<InputSideProps>;
72
74
  };
75
+ datePickerInput: {
76
+ contentRowCva?: Cva<DatePickerInputContentRowProps>;
77
+ };
73
78
  label: {
74
79
  cva?: Cva<LabelBaseProps>;
75
80
  typography?: CompoundMapper<TypographyVariantProps, LabelBaseProps>;
@@ -155,6 +160,7 @@ export declare namespace UIStyle {
155
160
  };
156
161
  select: {
157
162
  listBoxItemCva?: Cva<SelectListBoxItemCva>;
163
+ popoverCva?: Cva<SelectPopoverCva>;
158
164
  };
159
165
  }
160
166
  interface ProviderProps {
@@ -18,6 +18,7 @@ export declare const useQueryAutocomplete: <TQueryFn extends QueryFn, TKey exten
18
18
  isQueryEnabled: boolean;
19
19
  handleEnableQuery: () => void;
20
20
  items: SelectItem<TKey>[];
21
+ totalItems: any;
21
22
  hasNextPage: boolean;
22
23
  fetchNextPage: (() => Promise<unknown>) | ((options?: import('@tanstack/react-query').FetchNextPageOptions) => Promise<import('@tanstack/react-query').InfiniteQueryObserverResult<any, Error>>) | undefined;
23
24
  isFetchingNextPage: boolean;
@@ -22,6 +22,7 @@ var useQueryAutocomplete = ({ query, queryParams, queryOptions, mapItems, initia
22
22
  const hasNextPage = infiniteQueryResult?.hasNextPage ?? false;
23
23
  const fetchNextPage = infiniteQueryResult?.fetchNextPage;
24
24
  const isFetchingNextPage = infiniteQueryResult?.isFetchingNextPage ?? false;
25
+ const totalItems = infiniteQueryResult?.data?.pages?.[0]?.totalItems;
25
26
  const items = useMemo(() => {
26
27
  if (!data) return [];
27
28
  return mapItems(data);
@@ -32,6 +33,7 @@ var useQueryAutocomplete = ({ query, queryParams, queryOptions, mapItems, initia
32
33
  isQueryEnabled,
33
34
  handleEnableQuery,
34
35
  items,
36
+ totalItems,
35
37
  hasNextPage,
36
38
  fetchNextPage,
37
39
  isFetchingNextPage
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.2.9-rc.10",
3
+ "version": "2.2.9-rc.12",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",