@povio/ui 2.3.0-rc.5 → 2.3.0-rc.6

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.
@@ -64,9 +64,12 @@ var DatePickerBase = (props) => {
64
64
  const datePickerRef = useMemo(() => ({ get current() {
65
65
  return datePickerInputRef.current?.getContainer?.() || null;
66
66
  } }), []);
67
- useImperativeHandle(ref, () => ({ clear: () => {
68
- datePickerInputRef.current?.clear();
69
- } }));
67
+ useImperativeHandle(ref, () => ({
68
+ clear: () => {
69
+ datePickerInputRef.current?.clear();
70
+ },
71
+ getContainer: () => datePickerInputRef.current?.getContainer?.() ?? null
72
+ }));
70
73
  const handleBlur = (val) => {
71
74
  onBlur?.({ target: { value: val } });
72
75
  };
@@ -241,7 +244,8 @@ var DatePicker = ({ fullIso = true, granularity = "day", minValue, maxValue, ren
241
244
  renderInput,
242
245
  setRenderInput,
243
246
  getFocusTarget: (input) => {
244
- return (input.getContainer?.() ?? input).querySelector("input, button, [tabindex]:not([tabindex='-1'])");
247
+ const container = input.getContainer?.() ?? input;
248
+ return container instanceof HTMLElement ? container.querySelector("input, button, [tabindex]:not([tabindex='-1'])") : null;
245
249
  }
246
250
  });
247
251
  const watchedValue = "formControl" in props && props.formControl ? useWatch({
@@ -76,9 +76,12 @@ var DateRangePickerBase = (props) => {
76
76
  shouldForceLeadingZeros
77
77
  }, dialogState, dateRangePickerRef);
78
78
  const { locale } = useLocale$1();
79
- useImperativeHandle(ref, () => ({ clear: () => {
80
- datePickerInputRef.current?.clear();
81
- } }));
79
+ useImperativeHandle(ref, () => ({
80
+ clear: () => {
81
+ datePickerInputRef.current?.clear();
82
+ },
83
+ getContainer: () => datePickerInputRef.current?.getContainer?.() ?? null
84
+ }));
82
85
  const handleBlur = (newValue) => {
83
86
  onBlur?.({ target: { value: newValue } });
84
87
  };
@@ -570,7 +573,8 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
570
573
  renderInput,
571
574
  setRenderInput,
572
575
  getFocusTarget: (input) => {
573
- return (input.getContainer?.() ?? input).querySelector("input, button, [tabindex]:not([tabindex='-1'])");
576
+ const container = input.getContainer?.() ?? input;
577
+ return container instanceof HTMLElement ? container.querySelector("input, button, [tabindex]:not([tabindex='-1'])") : null;
574
578
  }
575
579
  });
576
580
  const watchedValue = "formControl" in props && props.formControl ? useWatch({
@@ -57,9 +57,12 @@ var DateTimePickerBase = (props) => {
57
57
  const datePickerRef = useMemo(() => ({ get current() {
58
58
  return datePickerInputRef.current?.getContainer?.() || null;
59
59
  } }), []);
60
- useImperativeHandle(ref, () => ({ clear: () => {
61
- datePickerInputRef.current?.clear();
62
- } }));
60
+ useImperativeHandle(ref, () => ({
61
+ clear: () => {
62
+ datePickerInputRef.current?.clear();
63
+ },
64
+ getContainer: () => datePickerInputRef.current?.getContainer?.() ?? null
65
+ }));
63
66
  const handleBlur = (val) => {
64
67
  onBlur?.({ target: { value: val } });
65
68
  };
@@ -243,7 +246,8 @@ var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
243
246
  renderInput,
244
247
  setRenderInput,
245
248
  getFocusTarget: (input) => {
246
- return (input.getContainer?.() ?? input).querySelector("input, button, [tabindex]:not([tabindex='-1'])");
249
+ const container = input.getContainer?.() ?? input;
250
+ return container instanceof HTMLElement ? container.querySelector("input, button, [tabindex]:not([tabindex='-1'])") : null;
247
251
  }
248
252
  });
249
253
  const watchedValue = "formControl" in props && props.formControl ? useWatch({
@@ -120,6 +120,7 @@ var NumberRangeInputBase = (props) => {
120
120
  });
121
121
  };
122
122
  var NumberRangeInput = ({ renderStaticInput, ...props }) => {
123
+ const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
123
124
  const ui = UIConfig.useConfig();
124
125
  const { locale } = useLocale();
125
126
  const [renderInput, setRenderInput] = useState(!(renderStaticInput ?? ui.renderStaticInput));
@@ -144,6 +145,7 @@ var NumberRangeInput = ({ renderStaticInput, ...props }) => {
144
145
  const rangeError = staticValue.min !== null && staticValue.max !== null && staticValue.min > staticValue.max ? props.invalidRangeError ?? "Minimum cannot be greater than maximum" : void 0;
145
146
  const effectiveError = props.error || rangeError;
146
147
  const as = props.as ?? ui.input.as;
148
+ const size = props.size ?? ui.input.size;
147
149
  let isDisabled = !!props.isDisabled;
148
150
  if (isFormControlDisabled) isDisabled = true;
149
151
  const isClearable = props.isClearable ?? ui.input.isClearable;
@@ -165,12 +167,15 @@ var NumberRangeInput = ({ renderStaticInput, ...props }) => {
165
167
  inputClassName: props.inputClassName,
166
168
  contentClassName: "pr-0!",
167
169
  trailingClassName: "py-0! pl-0!",
168
- contentWrapperClassName: "flex w-full items-center gap-input-gap-input-text-to-elements",
170
+ contentWrapperClassName: clsx("flex w-full items-center gap-input-gap-input-text-to-elements pr-0! py-0! px-0!", inputSizeCva({
171
+ size,
172
+ as
173
+ })),
169
174
  dataAttributes,
170
175
  renderStatic: true,
171
176
  onStaticInteract: renderRealInput,
172
177
  isClearable: false,
173
- labelPlacement: "content-row",
178
+ labelPlacement: "content-wrapper",
174
179
  children: ({ id, ...dataAttributeProps }) => /* @__PURE__ */ jsxs(Fragment, { children: [
175
180
  /* @__PURE__ */ jsx("input", {
176
181
  id,
@@ -1,8 +1,8 @@
1
- import { ArrowDropDownIcon } from "../../../../assets/icons/ArrowDropDown.js";
2
1
  import { UIConfig } from "../../../../config/uiConfig.context.js";
3
2
  import { InputFrame } from "../../Skeleton/InputFrame.js";
4
3
  import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
5
4
  import { SelectBase } from "../shared/SelectBase.js";
5
+ import { StaticSelectTrailingContent } from "../shared/StaticSelectTrailingContent.js";
6
6
  import { getStaticSelectValue } from "../shared/staticSelect.utils.js";
7
7
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
8
8
  import { clsx } from "clsx";
@@ -54,6 +54,7 @@ function Autocomplete({ renderStaticInput, ...props }) {
54
54
  if (!renderInput && !!props.customTrigger) setRenderInput(true);
55
55
  if (!renderInput) {
56
56
  const as = props.as ?? ui.input.as;
57
+ const size = props.size ?? ui.input.size;
57
58
  let isDisabled = !!props.isDisabled;
58
59
  if (isFormControlDisabled) isDisabled = true;
59
60
  const mode = props.selectionMode ?? ui.select.selectionMode;
@@ -69,7 +70,12 @@ function Autocomplete({ renderStaticInput, ...props }) {
69
70
  selectedTagsType: props.selectedTagsType ?? ui.select.selectedTagsType
70
71
  });
71
72
  const isMultiple = mode === "multiple";
72
- const trailingContent = props.trailingContent || !props.hideDropdownIcon ? /* @__PURE__ */ jsxs(Fragment, { children: [props.trailingContent, !props.hideDropdownIcon ? /* @__PURE__ */ jsx(ArrowDropDownIcon, { className: "size-6 shrink-0 text-interactive-text-secondary-idle" }) : void 0] }) : void 0;
73
+ const trailingContent = /* @__PURE__ */ jsx(StaticSelectTrailingContent, {
74
+ trailingContent: props.trailingContent,
75
+ hideDropdownIcon: props.hideDropdownIcon,
76
+ isDisabled,
77
+ size
78
+ });
73
79
  const placeholder = as === "floating" ? null : props.placeholder;
74
80
  const shouldRenderPlaceholderAfterValue = mode !== "single" && props.placeholder && !isEmpty;
75
81
  const inputValue = !isMultiple && selectedItem ? selectedItem.label : "";
@@ -94,7 +100,7 @@ function Autocomplete({ renderStaticInput, ...props }) {
94
100
  dataAttributes,
95
101
  renderStatic: true,
96
102
  onStaticInteract: renderRealInput,
97
- trailingClassName: "pl-1-5 gap-0!",
103
+ wrapTrailingContent: false,
98
104
  leadingContent: props.leadingContent && /* @__PURE__ */ jsx("div", {
99
105
  className: "ml-input-side-default flex shrink-0 items-center",
100
106
  children: props.leadingContent
@@ -1,9 +1,9 @@
1
- import { ArrowDropDownIcon } from "../../../../assets/icons/ArrowDropDown.js";
2
1
  import { Typography } from "../../../text/Typography/Typography.js";
3
2
  import { UIConfig } from "../../../../config/uiConfig.context.js";
4
3
  import { InputFrame } from "../../Skeleton/InputFrame.js";
5
4
  import { useStaticInputHandoff } from "../../shared/useStaticInputHandoff.js";
6
5
  import { SelectBase } from "../shared/SelectBase.js";
6
+ import { StaticSelectTrailingContent } from "../shared/StaticSelectTrailingContent.js";
7
7
  import { getStaticSelectValue } from "../shared/staticSelect.utils.js";
8
8
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { clsx } from "clsx";
@@ -51,6 +51,7 @@ function Select({ renderStaticInput, ...props }) {
51
51
  if (!renderInput && !!props.customTrigger) setRenderInput(true);
52
52
  if (!renderInput) {
53
53
  const as = props.as ?? ui.input.as;
54
+ const size = props.size ?? ui.input.size;
54
55
  let isDisabled = !!props.isDisabled;
55
56
  if (isFormControlDisabled) isDisabled = true;
56
57
  const mode = props.selectionMode ?? ui.select.selectionMode;
@@ -67,7 +68,12 @@ function Select({ renderStaticInput, ...props }) {
67
68
  selectedTagsType: props.selectedTagsType ?? ui.select.selectedTagsType
68
69
  });
69
70
  const isSearchable = props.isSearchable ?? ui.select.isSearchable;
70
- const trailingContent = props.trailingContent || !props.hideDropdownIcon ? /* @__PURE__ */ jsxs(Fragment, { children: [props.trailingContent, !props.hideDropdownIcon ? /* @__PURE__ */ jsx(ArrowDropDownIcon, { className: `size-6 shrink-0 ${isDisabled ? "text-interactive-text-secondary-disabled" : "text-interactive-text-secondary-idle"}` }) : void 0] }) : void 0;
71
+ const trailingContent = /* @__PURE__ */ jsx(StaticSelectTrailingContent, {
72
+ trailingContent: props.trailingContent,
73
+ hideDropdownIcon: props.hideDropdownIcon,
74
+ isDisabled,
75
+ size
76
+ });
71
77
  const placeholder = as === "floating" ? null : props.placeholder;
72
78
  const inputValue = !isMultiple && selectedItem ? selectedItem.label : "";
73
79
  const shouldRenderPlaceholderAfterValue = isMultiple && props.placeholder && !isEmpty;
@@ -102,7 +108,7 @@ function Select({ renderStaticInput, ...props }) {
102
108
  labelPlacement: "content-row",
103
109
  dataAttributes,
104
110
  renderStatic: true,
105
- trailingClassName: "pl-1-5 gap-0!",
111
+ wrapTrailingContent: false,
106
112
  onStaticInteract: renderRealInput,
107
113
  leadingContent: props.leadingContent && /* @__PURE__ */ jsx("div", {
108
114
  className: "ml-input-side-default flex shrink-0 items-center",
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ import { InputVariantProps } from '../../shared/input.cva';
3
+ interface StaticSelectTrailingContentProps extends Pick<InputVariantProps, "size"> {
4
+ trailingContent?: ReactNode;
5
+ hideDropdownIcon?: boolean;
6
+ isDisabled?: boolean;
7
+ }
8
+ export declare const StaticSelectTrailingContent: ({ trailingContent, hideDropdownIcon, isDisabled, size, }: StaticSelectTrailingContentProps) => import("react/jsx-runtime").JSX.Element | null;
9
+ export {};
@@ -0,0 +1,22 @@
1
+ import { ArrowDropDownIcon } from "../../../../assets/icons/ArrowDropDown.js";
2
+ import { UIStyle } from "../../../../config/uiStyle.context.js";
3
+ import { inputSize } from "../../shared/input.cva.js";
4
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ import { clsx } from "clsx";
6
+ //#region src/components/inputs/Selection/shared/StaticSelectTrailingContent.tsx
7
+ var StaticSelectTrailingContent = ({ trailingContent, hideDropdownIcon, isDisabled, size }) => {
8
+ const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
9
+ if (!trailingContent && hideDropdownIcon) return null;
10
+ return /* @__PURE__ */ jsxs(Fragment, { children: [trailingContent && /* @__PURE__ */ jsx("div", {
11
+ className: "flex shrink-0 items-center",
12
+ children: trailingContent
13
+ }), !hideDropdownIcon ? /* @__PURE__ */ jsx("button", {
14
+ type: "button",
15
+ tabIndex: -1,
16
+ className: clsx("self-stretch border-0! pl-1-5 outline-none", inputSizeCva({ size })),
17
+ "aria-hidden": "true",
18
+ children: /* @__PURE__ */ jsx(ArrowDropDownIcon, { className: clsx("size-6 shrink-0", isDisabled ? "text-interactive-text-secondary-disabled" : "text-interactive-text-secondary-idle") })
19
+ }) : void 0] });
20
+ };
21
+ //#endregion
22
+ export { StaticSelectTrailingContent };
@@ -71,6 +71,7 @@ export interface InputFrameProps extends InputVariantProps, Partial<FormFieldPro
71
71
  contentWrapperClassName?: string;
72
72
  contentAndTrailingClassName?: string;
73
73
  wrapContentAndTrailing?: boolean;
74
+ wrapTrailingContent?: boolean;
74
75
  labelPlacement?: InputFrameLabelPlacement;
75
76
  trailingClassName?: string;
76
77
  }
@@ -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, contentAndTrailingClassName, wrapContentAndTrailing, labelPlacement = "content-wrapper", trailingClassName, onMouseEnter, onFocusCapture, 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, contentAndTrailingClassName, wrapContentAndTrailing, wrapTrailingContent = true, 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;
@@ -96,45 +96,46 @@ var InputFrame = (props) => {
96
96
  })
97
97
  ]
98
98
  });
99
- const trailingRow = hasTrailingContent ? /* @__PURE__ */ jsxs("div", {
99
+ const trailingContentNodes = hasTrailingContent ? /* @__PURE__ */ jsxs(Fragment, { children: [
100
+ hasClear && /* @__PURE__ */ jsx(InputClear, {
101
+ onClear: () => onClear?.(),
102
+ className: clearClassName,
103
+ show: !!showClear,
104
+ renderStatic
105
+ }),
106
+ trailingContent,
107
+ unit && /* @__PURE__ */ jsx("span", {
108
+ className: typographyCva({
109
+ size: "label-2",
110
+ sizeMobile: "label-2",
111
+ variant: "prominent-1",
112
+ className: "text-text-default-3"
113
+ }),
114
+ children: unit
115
+ }),
116
+ isLoading && /* @__PURE__ */ jsx("div", {
117
+ className: "inline-flex",
118
+ children: /* @__PURE__ */ jsx(Loader, {})
119
+ }),
120
+ !isLoading && action && /* @__PURE__ */ jsx(InlineIconButton, {
121
+ color: "secondary",
122
+ icon: action.icon,
123
+ isDisabled,
124
+ onPress: action.onClick,
125
+ excludeFromTabOrder: true,
126
+ label: action.altText,
127
+ className: clsx("border-0!", action.className)
128
+ }),
129
+ !isLoading && !action && trailingIcon && renderIconVisual(trailingIcon),
130
+ trailingAction
131
+ ] }) : null;
132
+ const trailingRow = wrapTrailingContent && trailingContentNodes ? /* @__PURE__ */ jsx("div", {
100
133
  className: clsx("flex items-center gap-input-gap-trailing-elements", inputSizeCva({
101
134
  size,
102
135
  as
103
136
  }), !isTrailingInteractive && "pointer-events-none", trailingClassName),
104
- children: [
105
- hasClear && /* @__PURE__ */ jsx(InputClear, {
106
- onClear: () => onClear?.(),
107
- className: clearClassName,
108
- show: !!showClear,
109
- renderStatic
110
- }),
111
- trailingContent,
112
- unit && /* @__PURE__ */ jsx("span", {
113
- className: typographyCva({
114
- size: "label-2",
115
- sizeMobile: "label-2",
116
- variant: "prominent-1",
117
- className: "text-text-default-3"
118
- }),
119
- children: unit
120
- }),
121
- isLoading && /* @__PURE__ */ jsx("div", {
122
- className: "inline-flex",
123
- children: /* @__PURE__ */ jsx(Loader, {})
124
- }),
125
- !isLoading && action && /* @__PURE__ */ jsx(InlineIconButton, {
126
- color: "secondary",
127
- icon: action.icon,
128
- isDisabled,
129
- onPress: action.onClick,
130
- excludeFromTabOrder: true,
131
- label: action.altText,
132
- className: clsx("border-0!", action.className)
133
- }),
134
- !isLoading && !action && trailingIcon && renderIconVisual(trailingIcon),
135
- trailingAction
136
- ]
137
- }) : null;
137
+ children: trailingContentNodes
138
+ }) : trailingContentNodes;
138
139
  const inputFrameContent = wrapContentAndTrailing ? /* @__PURE__ */ jsxs("div", {
139
140
  className: clsx("flex w-full items-center gap-input-gap-input-text-to-elements", contentAndTrailingClassName),
140
141
  children: [contentRow, trailingRow]
@@ -4,12 +4,24 @@ var useStaticInputHandoff = ({ inputRef, renderInput, setRenderInput, getFocusTa
4
4
  const [shouldFocus, setShouldFocus] = useState(false);
5
5
  const pendingStaticChangeRef = useRef(null);
6
6
  const shouldReplayStaticPressRef = useRef(false);
7
+ const shouldReplayStaticHoverRef = useRef(false);
7
8
  useLayoutEffect(() => {
8
- if (!renderInput || !shouldFocus) return;
9
- const focusRealInput = (replayPendingInteraction) => {
9
+ if (!renderInput) return;
10
+ const getInteractionTarget = () => {
10
11
  const input = inputRef.current;
12
+ return input ? getFocusTarget?.(input) ?? input : null;
13
+ };
14
+ if (shouldReplayStaticHoverRef.current) {
15
+ shouldReplayStaticHoverRef.current = false;
16
+ const target = getInteractionTarget();
17
+ target?.dispatchEvent(new PointerEvent("pointerover", { bubbles: true }));
18
+ target?.dispatchEvent(new MouseEvent("mouseover", { bubbles: true }));
19
+ target?.dispatchEvent(new MouseEvent("mouseenter"));
20
+ }
21
+ if (!shouldFocus) return;
22
+ const focusRealInput = (replayPendingInteraction) => {
11
23
  const pendingValue = pendingStaticChangeRef.current;
12
- const focusTarget = input ? getFocusTarget?.(input) ?? input : null;
24
+ const focusTarget = getInteractionTarget();
13
25
  if (replayPendingInteraction && focusTarget instanceof HTMLInputElement && pendingValue != null) {
14
26
  (Object.getOwnPropertyDescriptor(window.HTMLInputElement.prototype, "value")?.set)?.call(focusTarget, pendingValue);
15
27
  focusTarget.dispatchEvent(new Event("input", { bubbles: true }));
@@ -39,14 +51,17 @@ var useStaticInputHandoff = ({ inputRef, renderInput, setRenderInput, getFocusTa
39
51
  shouldFocus,
40
52
  renderRealInput: (focus) => {
41
53
  setShouldFocus(focus);
54
+ shouldReplayStaticHoverRef.current = !focus;
42
55
  setRenderInput(true);
43
56
  },
44
57
  replayStaticInputChange: (value) => {
58
+ shouldReplayStaticHoverRef.current = false;
45
59
  pendingStaticChangeRef.current = value;
46
60
  setShouldFocus(true);
47
61
  setRenderInput(true);
48
62
  },
49
63
  replayStaticInputPress: () => {
64
+ shouldReplayStaticHoverRef.current = false;
50
65
  shouldReplayStaticPressRef.current = true;
51
66
  setShouldFocus(true);
52
67
  setRenderInput(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.3.0-rc.5",
3
+ "version": "2.3.0-rc.6",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",