@povio/ui 2.2.9-rc.27 → 2.2.9-rc.29

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.
@@ -235,7 +235,8 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...pr
235
235
  isDisabled,
236
236
  className: clsx("relative inline-flex w-full flex-col text-left", props.className),
237
237
  inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
238
- contentClassName: datePickerInputContentRowCva({ size }),
238
+ contentWrapperClassName: datePickerInputContentRowCva({ size }),
239
+ labelPlacement: "content-row",
239
240
  dataAttributes: {
240
241
  dataIsEmpty: dateValue === null,
241
242
  dataIsFilled: dateValue !== null,
@@ -636,7 +636,8 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
636
636
  isDisabled,
637
637
  className: clsx("relative inline-flex w-full flex-col text-left", props.className),
638
638
  inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
639
- contentClassName: datePickerInputContentRowCva({ size }),
639
+ contentWrapperClassName: datePickerInputContentRowCva({ size }),
640
+ labelPlacement: "content-row",
640
641
  dataAttributes: {
641
642
  dataIsEmpty: !hasProvidedRangeValue,
642
643
  dataIsFilled: hasProvidedRangeValue,
@@ -249,7 +249,8 @@ var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
249
249
  isDisabled,
250
250
  className: clsx("relative inline-flex w-full flex-col text-left", props.className),
251
251
  inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
252
- contentClassName: datePickerInputContentRowCva({ size }),
252
+ contentWrapperClassName: datePickerInputContentRowCva({ size }),
253
+ labelPlacement: "content-row",
253
254
  dataAttributes: {
254
255
  dataIsEmpty: dateTimeValue === null,
255
256
  dataIsFilled: dateTimeValue !== null,
@@ -192,6 +192,7 @@ var TimePicker = ({ renderStaticInput, ...props }) => {
192
192
  isDisabled,
193
193
  className: clsx("relative inline-flex w-full flex-col text-left", props.className),
194
194
  inputClassName: clsx("min-w-input-width-min-width", props.inputClassName),
195
+ labelPlacement: "content-row",
195
196
  dataAttributes: {
196
197
  dataIsEmpty: timeValue === null,
197
198
  dataIsFilled: timeValue !== null,
@@ -1,20 +1,21 @@
1
- import { UIStyle } from "../../../../config/uiStyle.context.js";
2
- import { buttonIconSize } from "../../../buttons/Button/button.cva.js";
1
+ import { InlineIconButton } from "../../../buttons/InlineIconButton/InlineIconButton.js";
3
2
  import { TodayIcon } from "../../../../assets/icons/Today.js";
4
3
  import { jsx } from "react/jsx-runtime";
5
- import { clsx } from "clsx";
6
- import { isValidElement } from "react";
7
4
  //#region src/components/inputs/DateTime/shared/datePickerTodayIcon.tsx
8
5
  var getDatePickerTodayIcon = (todayIcon) => {
9
6
  if (!todayIcon) return null;
10
7
  return todayIcon === true ? TodayIcon : todayIcon;
11
8
  };
12
9
  var renderDatePickerTodayIcon = (todayIcon, size = "none", className) => {
13
- const buttonIconSizeCva = UIStyle.useCva("button.iconSize", buttonIconSize);
14
10
  const icon = getDatePickerTodayIcon(todayIcon);
15
11
  if (!icon) return;
16
- if (isValidElement(icon)) return icon;
17
- return /* @__PURE__ */ jsx(icon, { className: clsx(buttonIconSizeCva({ size }), "text-interactive-text-secondary-idle", className) });
12
+ return /* @__PURE__ */ jsx(InlineIconButton, {
13
+ label: "",
14
+ icon,
15
+ size,
16
+ staticRender: true,
17
+ className: className ?? "relative z-1 !border-none"
18
+ });
18
19
  };
19
20
  //#endregion
20
21
  export { getDatePickerTodayIcon, renderDatePickerTodayIcon };
@@ -56,8 +56,8 @@ var renderStaticSegments = (value, options) => {
56
56
  className: "flex",
57
57
  children: tokenizeStaticSegmentText(value).map((token, index) => /* @__PURE__ */ jsx(DateSegmentItemView, {
58
58
  type: token.type,
59
- text: token.text,
60
- placeholder: token.text,
59
+ text: getStaticSegmentText(token),
60
+ placeholder: getStaticSegmentText(token),
61
61
  isPlaceholder: options.isPlaceholder && token.type !== "literal",
62
62
  isInputEmpty: options.isInputEmpty,
63
63
  isDisabled: options.isDisabled,
@@ -72,5 +72,9 @@ var tokenizeStaticSegmentText = (value) => {
72
72
  type: /^[^\p{Letter}\p{Number}]+$/u.test(text) ? "literal" : "day"
73
73
  }));
74
74
  };
75
+ var getStaticSegmentText = (token) => {
76
+ if (token.type !== "literal") return token.text;
77
+ return token.text.replaceAll(" ", "\xA0");
78
+ };
75
79
  //#endregion
76
80
  export { getStaticCalendarDateSegments, getStaticCalendarDateTimeSegments, getStaticDateRangeSegments, getStaticTimeSegments };
@@ -190,7 +190,8 @@ var NumberInput = ({ renderStaticInput, ...props }) => {
190
190
  "data-is-disabled": dataAttributes.dataIsDisabled || void 0,
191
191
  "data-disabled": dataAttributes.dataDisabled || void 0,
192
192
  "data-invalid": dataAttributes.dataInvalid || void 0,
193
- "data-has-selection": dataAttributes.dataHasSelection || void 0
193
+ "data-has-selection": dataAttributes.dataHasSelection || void 0,
194
+ "data-rac": true
194
195
  })
195
196
  });
196
197
  }
@@ -188,7 +188,8 @@ var TextInput = ({ renderStaticInput, ...props }) => {
188
188
  "data-is-disabled": dataAttributes.dataIsDisabled || void 0,
189
189
  "data-disabled": dataAttributes.dataDisabled || void 0,
190
190
  "data-invalid": dataAttributes.dataInvalid || void 0,
191
- "data-has-selection": dataAttributes.dataHasSelection || void 0
191
+ "data-has-selection": dataAttributes.dataHasSelection || void 0,
192
+ "data-rac": true
192
193
  })
193
194
  });
194
195
  }
@@ -79,6 +79,8 @@ function Autocomplete({ renderStaticInput, ...props }) {
79
79
  isDisabled,
80
80
  className: clsx("w-full", props.containerClassName),
81
81
  inputClassName: clsx(props.className, props.inputClassName),
82
+ contentWrapperClassName: "flex flex-1 flex-wrap gap-input-gap-input-text-to-elements truncate",
83
+ labelPlacement: "content-row",
82
84
  dataAttributes: {
83
85
  dataIsEmpty: isEmpty,
84
86
  dataIsFilled: !isEmpty,
@@ -98,7 +100,7 @@ function Autocomplete({ renderStaticInput, ...props }) {
98
100
  as,
99
101
  size: props.size ?? ui.input.size,
100
102
  variant: props.variant ?? ui.input.variant,
101
- actionContent: props.leadingContent && /* @__PURE__ */ jsx("div", {
103
+ leadingContent: props.leadingContent && /* @__PURE__ */ jsx("div", {
102
104
  className: "ml-input-side-default flex shrink-0 items-center",
103
105
  children: props.leadingContent
104
106
  }),
@@ -68,8 +68,7 @@ function Select({ renderStaticInput, ...props }) {
68
68
  });
69
69
  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;
70
70
  const placeholder = as === "floating" ? null : props.placeholder;
71
- const shouldRenderPlaceholderAfterValue = mode !== "single" && props.placeholder && !isEmpty;
72
- return /* @__PURE__ */ jsxs(InputFrame, {
71
+ return /* @__PURE__ */ jsx(InputFrame, {
73
72
  ...props,
74
73
  isHeaderHidden: props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating",
75
74
  hideLabel: props.hideLabel ?? ui.input.hideLabel,
@@ -77,6 +76,7 @@ function Select({ renderStaticInput, ...props }) {
77
76
  className: clsx("w-full", props.containerClassName),
78
77
  inputClassName: clsx(props.className, props.inputClassName),
79
78
  typographySize: "label-1",
79
+ labelPlacement: "content-row",
80
80
  dataAttributes: {
81
81
  dataIsEmpty: isEmpty,
82
82
  dataIsFilled: !isEmpty,
@@ -96,20 +96,17 @@ function Select({ renderStaticInput, ...props }) {
96
96
  as,
97
97
  size: props.size ?? ui.input.size,
98
98
  variant: props.variant ?? ui.input.variant,
99
- actionContent: props.leadingContent && /* @__PURE__ */ jsx("div", {
99
+ leadingContent: props.leadingContent && /* @__PURE__ */ jsx("div", {
100
100
  className: "ml-input-side-default flex shrink-0 items-center",
101
101
  children: props.leadingContent
102
102
  }),
103
103
  isClearable,
104
104
  showClear: false,
105
105
  trailingContent,
106
- children: [isEmpty ? /* @__PURE__ */ jsx("span", {
106
+ children: isEmpty ? /* @__PURE__ */ jsx("span", {
107
107
  className: "text-text-default-3",
108
108
  children: placeholder
109
- }) : displayValue, shouldRenderPlaceholderAfterValue && /* @__PURE__ */ jsx("div", {
110
- className: "shrink-0 text-text-default-3",
111
- children: props.placeholder
112
- })]
109
+ }) : displayValue
113
110
  });
114
111
  }
115
112
  return /* @__PURE__ */ jsx(_Select, {
@@ -44,7 +44,12 @@ var SelectContext;
44
44
  hasLoadMore,
45
45
  isClientSearchDisabled: ignoreInputValueFiltering ?? isClientSearchDisabled
46
46
  });
47
- const selectedItems = useMemo(() => allItems.filter(({ id }) => Array.isArray(fieldState.value) ? fieldState.value.includes(id) : id === fieldState.value), [allItems, fieldState.value]);
47
+ const selectedItems = useMemo(() => {
48
+ const getItem = (id) => allItems.find((item) => item.id === id) ?? null;
49
+ if (Array.isArray(fieldState.value)) return fieldState.value.map((id) => getItem(id)).filter((item) => item !== null);
50
+ const selectedItem = fieldState.value != null ? getItem(fieldState.value) : null;
51
+ return selectedItem ? [selectedItem] : [];
52
+ }, [allItems, fieldState.value]);
48
53
  const selectedIds = useMemo(() => selectedItems.map(({ id }) => id), [selectedItems]);
49
54
  const getItem = useCallback((value) => allItems.find((item) => item && item.id === value) ?? null, [allItems]);
50
55
  const updateValue = useCallback((value) => {
@@ -8,8 +8,7 @@ var getStaticSelectValue = ({ items, value, selectionMode, initialSelection, map
8
8
  const initialSelectedItems = initialSelection ? (Array.isArray(initialSelection) ? initialSelection : [initialSelection]).map((item) => mapInitialToSelectItem(item)) : [];
9
9
  const allItemsMap = /* @__PURE__ */ new Map();
10
10
  [...initialSelectedItems, ...items].forEach((item) => allItemsMap.set(item.id, item));
11
- const allItems = Array.from(allItemsMap.values());
12
- const getItem = (id) => allItems.find((item) => item.id === id) ?? null;
11
+ const getItem = (id) => allItemsMap.get(id) ?? null;
13
12
  const selectedItems = Array.isArray(value) ? value.map((id) => getItem(id)).filter((item) => item != null) : [];
14
13
  const selectedItem = !Array.isArray(value) && value != null ? getItem(value) : null;
15
14
  if (selectionMode === "multiple") return {
@@ -22,6 +22,7 @@ interface InputFrameDataAttributes {
22
22
  dataIsFilled?: boolean;
23
23
  dataIsRequired?: boolean;
24
24
  }
25
+ type InputFrameLabelPlacement = "content-wrapper" | "content-row";
25
26
  export interface InputFrameProps extends InputVariantProps, Partial<FormFieldProps> {
26
27
  ref?: Ref<HTMLDivElement>;
27
28
  children: ReactNode;
@@ -48,7 +49,8 @@ export interface InputFrameProps extends InputVariantProps, Partial<FormFieldPro
48
49
  inputClassName?: string;
49
50
  contentClassName?: string;
50
51
  contentWrapperClassName?: string;
52
+ labelPlacement?: InputFrameLabelPlacement;
51
53
  trailingClassName?: string;
52
54
  }
53
- export declare const InputFrame: ({ ref, children, formFieldRef, labelProps, headerProps, error, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isHeaderHidden, hideLabel, headerClassName, errorClassName, className, leadingContent, leadingIcon, actionContent, trailingContent, trailingIcon, trailingAction, unit, isLoading, action, isClearable, showClear, renderStatic, onStaticInteract, clearClassName, onClear, dataAttributes, typographySize, inputClassName, contentClassName, contentWrapperClassName, trailingClassName, variant, as, size, }: InputFrameProps) => import("react/jsx-runtime").JSX.Element;
55
+ export declare const InputFrame: ({ ref, children, formFieldRef, labelProps, headerProps, error, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isHeaderHidden, hideLabel, headerClassName, errorClassName, className, leadingContent, leadingIcon, actionContent, trailingContent, trailingIcon, trailingAction, unit, isLoading, action, isClearable, showClear, renderStatic, onStaticInteract, clearClassName, onClear, dataAttributes, typographySize, inputClassName, contentClassName, contentWrapperClassName, labelPlacement, trailingClassName, variant, as, size, }: InputFrameProps) => import("react/jsx-runtime").JSX.Element;
54
56
  export {};
@@ -11,7 +11,7 @@ import { jsx, jsxs } from "react/jsx-runtime";
11
11
  import { clsx } from "clsx";
12
12
  import { isValidElement } from "react";
13
13
  //#region src/components/inputs/Skeleton/InputFrame.tsx
14
- var InputFrame = ({ ref, children, formFieldRef, labelProps, headerProps, error, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isHeaderHidden, hideLabel, headerClassName, errorClassName, className, leadingContent, leadingIcon, actionContent, trailingContent, trailingIcon, trailingAction, unit, isLoading, action, isClearable, showClear, renderStatic, onStaticInteract, clearClassName, onClear, dataAttributes, typographySize, inputClassName, contentClassName, contentWrapperClassName, trailingClassName, variant, as, size }) => {
14
+ var InputFrame = ({ ref, children, formFieldRef, labelProps, headerProps, error, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isHeaderHidden, hideLabel, headerClassName, errorClassName, className, leadingContent, leadingIcon, actionContent, trailingContent, trailingIcon, trailingAction, unit, isLoading, action, isClearable, showClear, renderStatic, onStaticInteract, clearClassName, onClear, dataAttributes, typographySize, inputClassName, contentClassName, contentWrapperClassName, labelPlacement = "content-wrapper", trailingClassName, variant, as, size }) => {
15
15
  const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
16
16
  const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
17
17
  const inputContentWrapperCva = UIStyle.useCva("input.contentWrapperCva", inputContentWrapper);
@@ -47,6 +47,11 @@ var InputFrame = ({ ref, children, formFieldRef, labelProps, headerProps, error,
47
47
  className: headerClassName,
48
48
  labelProps
49
49
  };
50
+ const labelContent = as && ["filter", "floating"].includes(as) ? /* @__PURE__ */ jsx(FormFieldLabel, {
51
+ as,
52
+ size,
53
+ ...resolvedHeaderProps
54
+ }) : null;
50
55
  return /* @__PURE__ */ jsx(TooltipWrapper, {
51
56
  as,
52
57
  error,
@@ -92,14 +97,14 @@ var InputFrame = ({ ref, children, formFieldRef, labelProps, headerProps, error,
92
97
  className: clsx(!isLeadingIconElement && "pointer-events-none"),
93
98
  children: renderIconVisual(leadingIcon)
94
99
  }),
100
+ labelPlacement === "content-row" && labelContent,
95
101
  /* @__PURE__ */ jsxs("div", {
96
- className: clsx(inputContentWrapperCva({ as }), contentWrapperClassName),
102
+ className: inputContentWrapperCva({
103
+ as,
104
+ className: contentWrapperClassName
105
+ }),
97
106
  children: [
98
- as && ["filter", "floating"].includes(as) && /* @__PURE__ */ jsx(FormFieldLabel, {
99
- as,
100
- size,
101
- ...resolvedHeaderProps
102
- }),
107
+ labelPlacement === "content-wrapper" && labelContent,
103
108
  actionContent,
104
109
  children
105
110
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.2.9-rc.27",
3
+ "version": "2.2.9-rc.29",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",