@povio/ui 2.2.9-rc.14 → 2.2.9-rc.16

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 (40) hide show
  1. package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +2 -1
  2. package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +62 -4
  3. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +2 -1
  4. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +91 -4
  5. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +2 -1
  6. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +62 -4
  7. package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -1
  8. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +58 -3
  9. package/dist/components/inputs/DateTime/shared/DatePickerInput.js +4 -3
  10. package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
  11. package/dist/components/inputs/Input/NumberInput/NumberInput.js +80 -8
  12. package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
  13. package/dist/components/inputs/Input/TextInput/TextInput.js +83 -8
  14. package/dist/components/inputs/Inputs/InputItem.d.ts +7 -7
  15. package/dist/components/inputs/RadioGroup/RadioGroup.js +15 -12
  16. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +3 -1
  17. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +64 -3
  18. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.d.ts +1 -1
  19. package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +13 -9
  20. package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +22 -26
  21. package/dist/components/inputs/Selection/Select/QuerySelect.js +1 -1
  22. package/dist/components/inputs/Selection/Select/Select.d.ts +3 -1
  23. package/dist/components/inputs/Selection/Select/Select.js +65 -3
  24. package/dist/components/inputs/Selection/shared/SelectInput.js +7 -5
  25. package/dist/components/inputs/shared/StaticInput.d.ts +19 -0
  26. package/dist/components/inputs/shared/StaticInput.js +69 -0
  27. package/dist/components/inputs/shared/TooltipWrapper.js +5 -1
  28. package/dist/components/inputs/shared/input.cva.d.ts +5 -0
  29. package/dist/components/inputs/shared/input.cva.js +10 -1
  30. package/dist/components/inputs/shared/tooltipWrapper.cva.d.ts +4 -0
  31. package/dist/components/inputs/shared/tooltipWrapper.cva.js +5 -0
  32. package/dist/config/uiConfig.context.d.ts +4 -1
  33. package/dist/config/uiConfig.context.js +5 -0
  34. package/dist/config/uiStyle.context.d.ts +6 -1
  35. package/dist/hooks/useQueryAutocomplete.d.ts +5 -17
  36. package/dist/hooks/useQueryAutocomplete.js +6 -4
  37. package/dist/index.d.ts +1 -0
  38. package/dist/utils/date-time.utils.d.ts +10 -0
  39. package/dist/utils/date-time.utils.js +82 -1
  40. package/package.json +1 -1
@@ -1,9 +1,13 @@
1
+ import { ArrowDropDownIcon } from "../../../../assets/icons/ArrowDropDown.js";
2
+ import { UIConfig } from "../../../../config/uiConfig.context.js";
3
+ import { StaticInput } from "../../shared/StaticInput.js";
1
4
  import { SelectBase } from "../shared/SelectBase.js";
2
- import { jsx } from "react/jsx-runtime";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { isValidElement, useEffect, useRef, useState } from "react";
3
7
  import { mergeRefs } from "@react-aria/utils";
4
- import { Controller } from "react-hook-form";
8
+ import { Controller, useWatch } from "react-hook-form";
5
9
  //#region src/components/inputs/Selection/Select/Select.tsx
6
- function Select(props) {
10
+ function _Select(props) {
7
11
  if ("formControl" in props && props.formControl) {
8
12
  const { formControl, ref, ...innerProps } = props;
9
13
  return /* @__PURE__ */ jsx(Controller, {
@@ -23,5 +27,63 @@ function Select(props) {
23
27
  }
24
28
  return /* @__PURE__ */ jsx(SelectBase, { ...props });
25
29
  }
30
+ function Select({ renderStaticInput, ...props }) {
31
+ const ui = UIConfig.useConfig();
32
+ const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
33
+ const [shouldFocus, setShouldFocus] = useState(false);
34
+ const rootRef = useRef(null);
35
+ const currentValue = ("formControl" in props && props.formControl ? useWatch({
36
+ control: props.formControl.control,
37
+ name: props.formControl.name
38
+ }) : props.value) ?? props.value;
39
+ let isFormControlDisabled = false;
40
+ if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
41
+ if (!renderInput && props.selectionMode !== "multiple" && !!props.showSelectionContent && currentValue != null) setRenderInput(true);
42
+ if (!renderInput && !!props.customTrigger) setRenderInput(true);
43
+ useEffect(() => {
44
+ if (!renderInput || !shouldFocus) return;
45
+ requestAnimationFrame(() => {
46
+ (rootRef.current?.querySelector("[data-type='select-trigger'], input, button, [tabindex]"))?.focus();
47
+ });
48
+ setShouldFocus(false);
49
+ }, [renderInput, shouldFocus]);
50
+ if (!renderInput) {
51
+ const getItemLabel = (id) => {
52
+ const item = props.items.find((innerItem) => innerItem.id === id);
53
+ if (!item) return "";
54
+ if (props.showSelectionContent && item.content) return isValidElement(item.content) ? item.label : item.content;
55
+ return item.label;
56
+ };
57
+ const mode = props.selectionMode ?? ui.select.selectionMode;
58
+ let displayValue = "";
59
+ if (mode === "multiple") {
60
+ if (Array.isArray(currentValue) && currentValue.length > 0) displayValue = /* @__PURE__ */ jsx(Fragment, { children: currentValue.map((id) => getItemLabel(id)).filter(Boolean).map((item, index) => /* @__PURE__ */ jsxs("span", { children: [item, index < currentValue.length - 1 && ","] }, `${index}`)) });
61
+ } else if (currentValue != null) displayValue = getItemLabel(currentValue);
62
+ const as = props.as ?? ui.input.as;
63
+ let isDisabled = !!props.isDisabled;
64
+ if (isFormControlDisabled) isDisabled = true;
65
+ return /* @__PURE__ */ jsx(StaticInput, {
66
+ ...props,
67
+ onInteract: (focus) => {
68
+ setShouldFocus(focus);
69
+ setRenderInput(true);
70
+ },
71
+ as,
72
+ size: props.size ?? ui.input.size,
73
+ variant: props.variant ?? ui.input.variant,
74
+ isHeaderHidden: props.isHeaderHidden || as === "inline",
75
+ hideLabel: props.hideLabel ?? ui.input.hideLabel,
76
+ isDisabled,
77
+ placeholder: as === "floating" ? "" : props.placeholder,
78
+ displayValue,
79
+ isEmpty: !displayValue,
80
+ trailingVisual: /* @__PURE__ */ jsx(ArrowDropDownIcon, { className: "size-6 shrink-0 text-interactive-text-secondary-idle" })
81
+ });
82
+ }
83
+ return /* @__PURE__ */ jsx(_Select, {
84
+ ...props,
85
+ ref: mergeRefs(props.ref, rootRef)
86
+ });
87
+ }
26
88
  //#endregion
27
89
  export { Select };
@@ -4,7 +4,7 @@ import { Typography } from "../../../text/Typography/Typography.js";
4
4
  import "../../../../config/i18n.js";
5
5
  import { FormFieldLabel } from "../../FormField/FormFieldLabel.js";
6
6
  import { InputClear } from "../../shared/InputClear.js";
7
- import { inputBase, inputSize } from "../../shared/input.cva.js";
7
+ import { inputBase, inputClearClass, inputSize } from "../../shared/input.cva.js";
8
8
  import { SelectInputTags } from "./SelectInputTags.js";
9
9
  import { SelectContext } from "./select.context.js";
10
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -17,6 +17,7 @@ import { useTranslation } from "react-i18next";
17
17
  var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid, className, hideDropdownIcon, isSearchable, isClearable, showSelectionContent, inputClassName, fieldProps, headerProps, selectedTagsType, collapseAfter, isRequired, isDirty, onCloseComboBox, onBlur, fireBlurOnChange, leadingContent, trailingContent, onMouseEnter, onFocusCapture, ...props }) => {
18
18
  const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
19
19
  const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
20
+ const inputClearClassCva = UIStyle.useCva("input.clearClassCva", inputClearClass);
20
21
  const { t } = useTranslation("ui");
21
22
  const state = use(ComboBoxStateContext);
22
23
  const { hoverProps, isHovered } = useHover({ isDisabled });
@@ -137,17 +138,18 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
137
138
  })
138
139
  ]
139
140
  }),
140
- trailingContent && /* @__PURE__ */ jsx("div", {
141
- className: "flex shrink-0 items-center",
142
- children: trailingContent
143
- }),
144
141
  isClearable && /* @__PURE__ */ jsx(InputClear, {
145
142
  onClear: () => {
146
143
  onClear();
147
144
  if (fireBlurOnChange) onBlur?.({});
148
145
  },
146
+ className: inputClearClassCva({ as }),
149
147
  show: showClearButton
150
148
  }),
149
+ trailingContent && /* @__PURE__ */ jsx("div", {
150
+ className: "flex shrink-0 items-center",
151
+ children: trailingContent
152
+ }),
151
153
  !hideDropdownIcon && /* @__PURE__ */ jsx(Button, {
152
154
  excludeFromTabOrder: true,
153
155
  "aria-label": t(($) => isOpen ? $.ui.closeAlt : $.ui.openAlt),
@@ -0,0 +1,19 @@
1
+ import { ReactNode } from 'react';
2
+ import { FormFieldProps } from '../FormField/FormField';
3
+ import { TextInputProps } from '../Input/TextInput/TextInput';
4
+ import { InputSizeProps, InputVariantProps } from './input.cva';
5
+ interface StaticInputProps extends FormFieldProps {
6
+ onInteract: (shouldFocus: boolean) => void;
7
+ as?: TextInputProps["as"];
8
+ size?: InputSizeProps["size"];
9
+ variant?: InputVariantProps["variant"];
10
+ applyMinInputWidth?: boolean;
11
+ placeholder?: ReactNode;
12
+ displayValue?: ReactNode;
13
+ isEmpty?: boolean;
14
+ leadingVisual?: ReactNode;
15
+ trailingVisual?: ReactNode;
16
+ inputClassName?: string;
17
+ }
18
+ export declare const StaticInput: ({ onInteract, as, size, variant, applyMinInputWidth, placeholder, displayValue, isEmpty, leadingVisual, trailingVisual, inputClassName, className, ...formFieldProps }: StaticInputProps) => import("react/jsx-runtime").JSX.Element;
19
+ export {};
@@ -0,0 +1,69 @@
1
+ import { UIStyle } from "../../../config/uiStyle.context.js";
2
+ import { FormFieldLabel } from "../FormField/FormFieldLabel.js";
3
+ import { inputBase, inputSize } from "./input.cva.js";
4
+ import { FormField } from "../FormField/FormField.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { clsx } from "clsx";
7
+ //#region src/components/inputs/shared/StaticInput.tsx
8
+ var StaticInput = ({ onInteract, as, size, variant, applyMinInputWidth, placeholder, displayValue, isEmpty, leadingVisual, trailingVisual, inputClassName, className, ...formFieldProps }) => {
9
+ const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
10
+ const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
11
+ let hasValue = !!displayValue;
12
+ if (isEmpty != null) hasValue = !isEmpty;
13
+ let staticDisplayContent = placeholder;
14
+ if (hasValue) staticDisplayContent = displayValue;
15
+ else if (as === "floating") staticDisplayContent = null;
16
+ const shouldRenderFloatingLineSpacer = as === "floating" && !hasValue;
17
+ return /* @__PURE__ */ jsx(FormField, {
18
+ ...formFieldProps,
19
+ as,
20
+ className,
21
+ onMouseEnter: () => onInteract(false),
22
+ tabIndex: as === "inline" ? -1 : void 0,
23
+ children: /* @__PURE__ */ jsxs("div", {
24
+ tabIndex: formFieldProps.isDisabled ? -1 : 0,
25
+ onFocus: () => onInteract(true),
26
+ onClick: () => onInteract(true),
27
+ onPointerDown: () => onInteract(true),
28
+ "data-is-empty": !hasValue || void 0,
29
+ "data-disabled": formFieldProps.isDisabled || void 0,
30
+ "data-is-disabled": formFieldProps.isDisabled || void 0,
31
+ "data-has-selection": hasValue || void 0,
32
+ "data-rac": "",
33
+ className: clsx("group/static-input group/input-content group/select-content relative flex items-center justify-between gap-input-gap-input-text-to-elements", applyMinInputWidth && "min-w-input-width-min-width", inputBaseCva({
34
+ as,
35
+ variant
36
+ }), inputClassName),
37
+ children: [/* @__PURE__ */ jsxs("div", {
38
+ className: clsx(inputSizeCva({
39
+ size,
40
+ as
41
+ }), "flex w-full items-center gap-input-gap-input-text-to-elements pr-0!"),
42
+ children: [leadingVisual && /* @__PURE__ */ jsx("div", {
43
+ className: "pointer-events-none shrink-0",
44
+ children: leadingVisual
45
+ }), /* @__PURE__ */ jsxs("div", {
46
+ className: clsx("flex w-full truncate", as === "floating" && "flex-col", as === "filter" && "gap-input-gap-input-text-to-elements"),
47
+ children: [as && ["filter", "floating"].includes(as) && /* @__PURE__ */ jsx(FormFieldLabel, {
48
+ as,
49
+ size,
50
+ label: formFieldProps.label,
51
+ isRequired: formFieldProps.isRequired,
52
+ isDisabled: formFieldProps.isDisabled
53
+ }), /* @__PURE__ */ jsxs("div", {
54
+ className: clsx("truncate", !hasValue && "text-text-default-3"),
55
+ children: [staticDisplayContent, shouldRenderFloatingLineSpacer && /* @__PURE__ */ jsx(Fragment, { children: "\xA0" })]
56
+ })]
57
+ })]
58
+ }), trailingVisual && /* @__PURE__ */ jsx("div", {
59
+ className: clsx(inputSizeCva({
60
+ size,
61
+ as
62
+ }), "pointer-events-none flex items-center gap-input-gap-trailing-elements py-0! pl-0!"),
63
+ children: trailingVisual
64
+ })]
65
+ })
66
+ });
67
+ };
68
+ //#endregion
69
+ export { StaticInput };
@@ -1,7 +1,10 @@
1
+ import { UIStyle } from "../../../config/uiStyle.context.js";
1
2
  import { Tooltip } from "../../overlays/Tooltip/Tooltip.js";
3
+ import { tooltipWrapperTrigger } from "./tooltipWrapper.cva.js";
2
4
  import { jsx } from "react/jsx-runtime";
3
5
  //#region src/components/inputs/shared/TooltipWrapper.tsx
4
6
  var TooltipWrapper = (props) => {
7
+ const tooltipWrapperTriggerCva = UIStyle.useCva("tooltipWrapper.triggerCva", tooltipWrapperTrigger);
5
8
  if (props.as !== "inline") return props.children;
6
9
  return /* @__PURE__ */ jsx(Tooltip, {
7
10
  text: props.error || void 0,
@@ -9,10 +12,11 @@ var TooltipWrapper = (props) => {
9
12
  color: "error",
10
13
  hidden: !props.error,
11
14
  isNonInteractiveTrigger: true,
12
- triggerClassName: props.triggerClassName,
15
+ triggerClassName: tooltipWrapperTriggerCva({ className: props.triggerClassName }),
13
16
  triggerTabIndex: props.triggerTabIndex,
14
17
  children: /* @__PURE__ */ jsx("div", {
15
18
  tabIndex: -1,
19
+ className: tooltipWrapperTriggerCva({}),
16
20
  children: props.children
17
21
  })
18
22
  });
@@ -12,6 +12,11 @@ export declare const inputSize: (props?: ({
12
12
  } & ClassProp) | undefined) => string;
13
13
  export interface InputSizeProps extends VariantProps<typeof inputSize> {
14
14
  }
15
+ export declare const inputClearClass: (props?: ({
16
+ as?: "filter" | "default" | "floating" | "inline" | null | undefined;
17
+ } & ClassProp) | undefined) => string;
18
+ export interface InputClearClassProps extends VariantProps<typeof inputClearClass> {
19
+ }
15
20
  export declare const inputSide: (props?: ({
16
21
  size?: "small" | "default" | "extra-small" | "large" | null | undefined;
17
22
  type?: "left" | "right" | "var" | null | undefined;
@@ -191,6 +191,15 @@ var inputSize = cva("", {
191
191
  as: "default"
192
192
  }
193
193
  });
194
+ var inputClearClass = cva("", {
195
+ variants: { as: {
196
+ default: "",
197
+ floating: "",
198
+ filter: "",
199
+ inline: ""
200
+ } },
201
+ defaultVariants: { as: "default" }
202
+ });
194
203
  var inputSide = cva("", {
195
204
  variants: {
196
205
  size: {
@@ -277,4 +286,4 @@ var useInputCva = () => {
277
286
  };
278
287
  };
279
288
  //#endregion
280
- export { inputBase, inputSide, inputSize, useInputCva };
289
+ export { inputBase, inputClearClass, inputSide, inputSize, useInputCva };
@@ -0,0 +1,4 @@
1
+ import { VariantProps } from 'class-variance-authority';
2
+ export declare const tooltipWrapperTrigger: (props?: import('class-variance-authority/types').ClassProp | undefined) => string;
3
+ export interface TooltipWrapperTriggerVariantProps extends VariantProps<typeof tooltipWrapperTrigger> {
4
+ }
@@ -0,0 +1,5 @@
1
+ import { cva } from "class-variance-authority";
2
+ //#region src/components/inputs/shared/tooltipWrapper.cva.ts
3
+ var tooltipWrapperTrigger = cva("inline-flex");
4
+ //#endregion
5
+ export { tooltipWrapperTrigger };
@@ -1,4 +1,4 @@
1
- import { PropsWithChildren } from 'react';
1
+ import { PropsWithChildren, ReactElement } from 'react';
2
2
  import { ButtonProps } from '../components/buttons/Button/Button';
3
3
  import { CheckboxProps } from '../components/inputs/Checkbox/Checkbox';
4
4
  import { DatePickerProps } from '../components/inputs/DateTime/DatePicker/DatePicker';
@@ -19,6 +19,7 @@ export declare namespace UIConfig {
19
19
  [P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : Exclude<T[P], null | undefined>;
20
20
  };
21
21
  export interface Options {
22
+ renderStaticInput: boolean;
22
23
  input: Pick<TextInputProps, "variant" | "isClearable" | "hideLabel" | "as" | "size">;
23
24
  button: Pick<ButtonProps, "variant" | "size">;
24
25
  numberInput: Pick<NumberInputProps, "formatOptions">;
@@ -34,6 +35,8 @@ export declare namespace UIConfig {
34
35
  toggle: Pick<ToggleProps, "variant">;
35
36
  slider: Pick<SliderProps, "minValue" | "maxValue">;
36
37
  dateInput: Pick<DatePickerProps, "todayIcon" | "todayIconButtonSize" | "shouldForceLeadingZeros" | "disableManualEntry" | "autoFixYear"> & {
38
+ calendarIcon?: ReactElement;
39
+ dateTimeIcon?: ReactElement;
37
40
  setDateValueOnDateSelection?: boolean;
38
41
  };
39
42
  actionModal: Pick<ActionModalProps, "titleTypography" | "descriptionTypography">;
@@ -1,3 +1,5 @@
1
+ import { CalendarIcon } from "../assets/icons/Calendar.js";
2
+ import { DateTimeIcon } from "../assets/icons/DateTime.js";
1
3
  import { ObjectUtils } from "../utils/object.utils.js";
2
4
  import { useDeepCompareMemo } from "../hooks/useDeepCompare.js";
3
5
  import { jsx } from "react/jsx-runtime";
@@ -6,6 +8,7 @@ import { createContext, use } from "react";
6
8
  var UIConfig;
7
9
  (function(_UIConfig) {
8
10
  const DEFAULT_CONFIG = {
11
+ renderStaticInput: true,
9
12
  input: {
10
13
  variant: "outlined",
11
14
  as: "default",
@@ -47,6 +50,8 @@ var UIConfig;
47
50
  shouldForceLeadingZeros: false,
48
51
  disableManualEntry: false,
49
52
  autoFixYear: false,
53
+ calendarIcon: /* @__PURE__ */ jsx(CalendarIcon, { className: "size-5" }),
54
+ dateTimeIcon: /* @__PURE__ */ jsx(DateTimeIcon, { className: "size-5" }),
50
55
  setDateValueOnDateSelection: false
51
56
  },
52
57
  actionModal: {
@@ -11,8 +11,9 @@ import { FormFieldHelperVariantProps } from '../components/inputs/FormField/form
11
11
  import { RadioVariantProps } from '../components/inputs/RadioGroup/radio.cva';
12
12
  import { SelectPopoverCva } from '../components/inputs/Selection/shared/selectDesktop.cva';
13
13
  import { SelectListBoxItemCva } from '../components/inputs/Selection/shared/selectItem.cva';
14
- import { InputBaseProps, InputSideProps, InputSizeProps } from '../components/inputs/shared/input.cva';
14
+ import { InputBaseProps, InputClearClassProps, InputSideProps, InputSizeProps } from '../components/inputs/shared/input.cva';
15
15
  import { LabelBaseProps } from '../components/inputs/shared/label.cva';
16
+ import { TooltipWrapperTriggerVariantProps } from '../components/inputs/shared/tooltipWrapper.cva';
16
17
  import { ToggleVariantProps } from '../components/inputs/Toggle/toggle.cva';
17
18
  import { MenuCvaVariantProps, MenuItemVariantProps, MenuPopoverVariantProps, MenuPopoverWrapperVariantProps } from '../components/Menu/menu.cva';
18
19
  import { AccordionChevronVariantProps, AccordionHeadingSubtitleVariantProps, AccordionHeadingTitleVariantProps, AccordionHeadingVariantProps, AccordionIconVariantProps, AccordionItemVariantProps, AccordionPanelContentVariantProps, AccordionPanelVariantProps, AccordionTriggerVariantProps, AccordionVariantProps } from '../components/navigation/Accordion/accordion.cva';
@@ -69,9 +70,13 @@ export declare namespace UIStyle {
69
70
  };
70
71
  input: {
71
72
  baseCva?: Cva<InputBaseProps>;
73
+ clearClassCva?: Cva<InputClearClassProps>;
72
74
  sizeCva?: Cva<InputSizeProps>;
73
75
  sideCva?: Cva<InputSideProps>;
74
76
  };
77
+ tooltipWrapper: {
78
+ triggerCva?: Cva<TooltipWrapperTriggerVariantProps>;
79
+ };
75
80
  datePickerInput: {
76
81
  contentRowCva?: Cva<DatePickerInputContentRowProps>;
77
82
  };
@@ -1,26 +1,14 @@
1
- import { UseInfiniteQueryResult, UseQueryResult } from '@tanstack/react-query';
1
+ import { InfiniteData } from '@tanstack/react-query';
2
2
  import { Key } from 'react-aria-components';
3
- import { SelectItem } from '../components/inputs/Selection/shared/select.types';
4
- type QueryResult<TData = any> = UseQueryResult<TData> | UseInfiniteQueryResult<TData>;
5
- type QueryFn<TData = any> = (...args: any[]) => QueryResult<TData>;
6
- type QueryDataType<TQueryFn extends QueryFn> = Exclude<ReturnType<TQueryFn>["data"], undefined>;
7
- interface UseQueryAutocompleteOptions<TQueryFn extends QueryFn, TKey extends Key = Key> {
8
- query: TQueryFn;
9
- queryParams?: Parameters<TQueryFn>[0];
10
- queryOptions?: Parameters<TQueryFn>[1];
11
- mapItems: (data: QueryDataType<TQueryFn>) => SelectItem<TKey>[];
12
- initialQueryState?: boolean;
13
- search?: string;
14
- }
3
+ import { InfiniteQueryPage, QueryFn, UseQueryAutocompleteOptions } from '../components/inputs/Selection/Autocomplete/queryAutocomplete.types';
15
4
  export declare const useQueryAutocomplete: <TQueryFn extends QueryFn, TKey extends Key = Key>({ query, queryParams, queryOptions, mapItems, initialQueryState, search, }: UseQueryAutocompleteOptions<TQueryFn, TKey>) => {
16
5
  data: any;
17
6
  isLoading: boolean;
18
7
  isQueryEnabled: boolean;
19
8
  handleEnableQuery: () => void;
20
- items: SelectItem<TKey>[];
21
- totalItems: any;
9
+ items: import('..').SelectItem<TKey>[];
10
+ totalItems: number | undefined;
22
11
  hasNextPage: boolean;
23
- fetchNextPage: (() => Promise<unknown>) | ((options?: import('@tanstack/react-query').FetchNextPageOptions) => Promise<import('@tanstack/react-query').InfiniteQueryObserverResult<any, Error>>) | undefined;
12
+ fetchNextPage: ((options?: import('@tanstack/react-query').FetchNextPageOptions) => Promise<import('@tanstack/react-query').InfiniteQueryObserverResult<InfiniteData<InfiniteQueryPage<TKey>, unknown>, Error>>) | undefined;
24
13
  isFetchingNextPage: boolean;
25
14
  };
26
- export {};
@@ -1,16 +1,19 @@
1
1
  import { ApiQueryUtils } from "../utils/query.utils.js";
2
2
  import { useMemo, useState } from "react";
3
3
  //#region src/hooks/useQueryAutocomplete.ts
4
+ var isFilterSearchParams = (params) => {
5
+ return typeof params === "object" && params !== null && "filter" in params;
6
+ };
4
7
  var useQueryAutocomplete = ({ query, queryParams, queryOptions, mapItems, initialQueryState, search }) => {
5
8
  const [isQueryEnabled, setIsQueryEnabled] = useState(!initialQueryState);
6
9
  const queryResult = query(search === void 0 ? queryParams : {
7
10
  ...queryParams,
8
11
  limit: queryParams?.limit ?? ApiQueryUtils.DEFAULT_LIMIT,
9
12
  search,
10
- filter: queryParams && "filter" in queryParams ? {
13
+ ...isFilterSearchParams(queryParams) ? { filter: {
11
14
  ...queryParams.filter,
12
15
  search
13
- } : void 0
16
+ } } : {}
14
17
  }, {
15
18
  ...queryOptions,
16
19
  enabled: isQueryEnabled && (queryOptions?.enabled ?? true)
@@ -20,11 +23,10 @@ var useQueryAutocomplete = ({ query, queryParams, queryOptions, mapItems, initia
20
23
  const isInfiniteQueryResult = (result) => {
21
24
  return "hasNextPage" in result && "fetchNextPage" in result;
22
25
  };
23
- const isInfiniteQuery = isInfiniteQueryResult(queryResult);
24
26
  const handleEnableQuery = () => {
25
27
  setIsQueryEnabled(true);
26
28
  };
27
- const infiniteQueryResult = isInfiniteQuery ? queryResult : void 0;
29
+ const infiniteQueryResult = isInfiniteQueryResult(queryResult) ? queryResult : void 0;
28
30
  const hasNextPage = infiniteQueryResult?.hasNextPage ?? false;
29
31
  const fetchNextPage = infiniteQueryResult?.fetchNextPage;
30
32
  const isFetchingNextPage = infiniteQueryResult?.isFetchingNextPage ?? false;
package/dist/index.d.ts CHANGED
@@ -103,6 +103,7 @@ export { Select } from './components/inputs/Selection/Select/Select';
103
103
  export type { ControlledSliderProps, SliderProps } from './components/inputs/Slider/Slider';
104
104
  export { Slider } from './components/inputs/Slider/Slider';
105
105
  export type { InputVariantProps } from './components/inputs/shared/input.cva';
106
+ export type { TooltipWrapperTriggerVariantProps } from './components/inputs/shared/tooltipWrapper.cva';
106
107
  export type { ControlledToggleProps, ToggleProps } from './components/inputs/Toggle/Toggle';
107
108
  export { Toggle } from './components/inputs/Toggle/Toggle';
108
109
  export type { MenuProps } from './components/Menu/Menu';
@@ -1,5 +1,15 @@
1
1
  import { CalendarDate, CalendarDateTime, DateValue, ZonedDateTime } from '@internationalized/date';
2
2
  export declare namespace DateTimeUtils {
3
+ function getDatePlaceholder(locale?: string): string;
4
+ function getTimePlaceholder(locale?: string): string;
5
+ function getDateTimePlaceholder(locale?: string): string;
6
+ function getDateRangePlaceholder(locale?: string): string;
7
+ function formatCalendarDateLocalized(calendarDate: CalendarDate, locale?: string): string;
8
+ function formatTimeLocalized(timeValue: {
9
+ hour: number;
10
+ minute: number;
11
+ }, locale?: string): string;
12
+ function formatCalendarDateTimeLocalized(calendarDateTime: Pick<CalendarDateTime, "day" | "month" | "year" | "hour" | "minute">, locale?: string): string;
3
13
  function fromISOtoZonedDateTime(isoString: string): ZonedDateTime;
4
14
  function fromDateValueToISO(dateValue: DateValue): string;
5
15
  function fromLocalToZonedDateTime(date: Date): ZonedDateTime;
@@ -1,7 +1,88 @@
1
- import { CalendarDate, CalendarDateTime, fromDate, getLocalTimeZone, parseAbsolute, parseAbsoluteToLocal } from "@internationalized/date";
1
+ import { CalendarDate, CalendarDateTime, DateFormatter, fromDate, getLocalTimeZone, parseAbsolute, parseAbsoluteToLocal } from "@internationalized/date";
2
2
  //#region src/utils/date-time.utils.ts
3
3
  var DateTimeUtils;
4
4
  (function(_DateTimeUtils) {
5
+ const DATE_SAMPLE_DATE_UTC = new Date(Date.UTC(2e3, 10, 22));
6
+ const TIME_SAMPLE_DATE_UTC = new Date(Date.UTC(2e3, 10, 22, 13, 45));
7
+ const getDatePlaceholderFormatter = (locale) => new Intl.DateTimeFormat(locale, {
8
+ day: "2-digit",
9
+ month: "2-digit",
10
+ year: "numeric"
11
+ });
12
+ const getTimePlaceholderFormatter = (locale) => new Intl.DateTimeFormat(locale, {
13
+ hour: "2-digit",
14
+ minute: "2-digit",
15
+ hourCycle: "h23"
16
+ });
17
+ const getResolvedLocale = (locale) => {
18
+ if (locale) return locale;
19
+ return new Intl.DateTimeFormat().resolvedOptions().locale;
20
+ };
21
+ const getDateFormatter = (locale) => new DateFormatter(getResolvedLocale(locale), {
22
+ day: "2-digit",
23
+ month: "2-digit",
24
+ year: "numeric",
25
+ timeZone: "UTC"
26
+ });
27
+ const getTimeFormatter = (locale) => new DateFormatter(getResolvedLocale(locale), {
28
+ hour: "2-digit",
29
+ minute: "2-digit",
30
+ hourCycle: "h23",
31
+ timeZone: "UTC"
32
+ });
33
+ const getDateTimeFormatter = (locale) => new DateFormatter(getResolvedLocale(locale), {
34
+ day: "2-digit",
35
+ month: "2-digit",
36
+ year: "numeric",
37
+ hour: "2-digit",
38
+ minute: "2-digit",
39
+ hourCycle: "h23",
40
+ timeZone: "UTC"
41
+ });
42
+ const mapTypeToPlaceholder = (type) => {
43
+ switch (type) {
44
+ case "day": return "dd";
45
+ case "month": return "mm";
46
+ case "year": return "yyyy";
47
+ case "hour": return "hh";
48
+ case "minute": return "mm";
49
+ default: return null;
50
+ }
51
+ };
52
+ const formatPlaceholder = (formatter, sampleDate) => {
53
+ return formatter.formatToParts(sampleDate).map((part) => mapTypeToPlaceholder(part.type) ?? part.value).join("");
54
+ };
55
+ function getDatePlaceholder(locale) {
56
+ return formatPlaceholder(getDatePlaceholderFormatter(locale), DATE_SAMPLE_DATE_UTC);
57
+ }
58
+ _DateTimeUtils.getDatePlaceholder = getDatePlaceholder;
59
+ function getTimePlaceholder(locale) {
60
+ return formatPlaceholder(getTimePlaceholderFormatter(locale), TIME_SAMPLE_DATE_UTC);
61
+ }
62
+ _DateTimeUtils.getTimePlaceholder = getTimePlaceholder;
63
+ function getDateTimePlaceholder(locale) {
64
+ return `${getDatePlaceholder(locale)}, ${getTimePlaceholder(locale)}`;
65
+ }
66
+ _DateTimeUtils.getDateTimePlaceholder = getDateTimePlaceholder;
67
+ function getDateRangePlaceholder(locale) {
68
+ const datePlaceholder = getDatePlaceholder(locale);
69
+ return `${datePlaceholder} – ${datePlaceholder}`;
70
+ }
71
+ _DateTimeUtils.getDateRangePlaceholder = getDateRangePlaceholder;
72
+ function formatCalendarDateLocalized(calendarDate, locale) {
73
+ return getDateFormatter(locale).format(calendarDate.toDate("UTC"));
74
+ }
75
+ _DateTimeUtils.formatCalendarDateLocalized = formatCalendarDateLocalized;
76
+ function formatTimeLocalized(timeValue, locale) {
77
+ const dateTime = new CalendarDateTime(2e3, 11, 22, timeValue.hour, timeValue.minute);
78
+ return getTimeFormatter(locale).format(dateTime.toDate("UTC"));
79
+ }
80
+ _DateTimeUtils.formatTimeLocalized = formatTimeLocalized;
81
+ function formatCalendarDateTimeLocalized(calendarDateTime, locale) {
82
+ const normalizedValue = new CalendarDateTime(calendarDateTime.year, calendarDateTime.month, calendarDateTime.day, calendarDateTime.hour, calendarDateTime.minute);
83
+ return getDateTimeFormatter(locale).format(normalizedValue.toDate("UTC"));
84
+ }
85
+ _DateTimeUtils.formatCalendarDateTimeLocalized = formatCalendarDateTimeLocalized;
5
86
  function fromISOtoZonedDateTime(isoString) {
6
87
  return parseAbsoluteToLocal(isoString);
7
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.2.9-rc.14",
3
+ "version": "2.2.9-rc.16",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",