@povio/ui 2.2.9-rc.21 → 2.2.9-rc.23

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.
@@ -618,14 +618,6 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
618
618
  const showDropdown = !props.disableDropdown || disableManualEntry;
619
619
  const defaultDatePlaceholder = DateTimeUtils.getDatePlaceholder(locale, { shouldForceLeadingZeros });
620
620
  const hasProvidedRangeValue = !!(rawValue?.start || rawValue?.end);
621
- const staticPlaceholder = props.placeholder ?? /* @__PURE__ */ jsxs(Fragment, { children: [
622
- /* @__PURE__ */ jsx("span", { children: defaultDatePlaceholder }),
623
- /* @__PURE__ */ jsx("span", {
624
- className: "pointer-events-none select-none",
625
- children: "–"
626
- }),
627
- /* @__PURE__ */ jsx("span", { children: defaultDatePlaceholder })
628
- ] });
629
621
  const formatStaticDate = (value) => {
630
622
  if (!value) return "";
631
623
  const parsedDate = parseCalendarDate(value);
@@ -634,15 +626,20 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
634
626
  };
635
627
  const start = formatStaticDate(rawValue?.start ?? null);
636
628
  const end = formatStaticDate(rawValue?.end ?? null);
637
- const hasRangeValue = !!(start && end);
638
- const displayValue = hasRangeValue ? /* @__PURE__ */ jsxs(Fragment, { children: [
639
- /* @__PURE__ */ jsx("span", { children: start }),
629
+ const displayValue = /* @__PURE__ */ jsxs(Fragment, { children: [
630
+ /* @__PURE__ */ jsx("span", {
631
+ className: rawValue?.start ? "" : "text-text-default-3",
632
+ children: rawValue?.start ? start : defaultDatePlaceholder
633
+ }),
640
634
  /* @__PURE__ */ jsx("span", {
641
635
  className: "pointer-events-none select-none",
642
636
  children: "–"
643
637
  }),
644
- /* @__PURE__ */ jsx("span", { children: end })
645
- ] }) : void 0;
638
+ /* @__PURE__ */ jsx("span", {
639
+ className: rawValue?.end ? "" : "text-text-default-3",
640
+ children: rawValue?.end ? end : defaultDatePlaceholder
641
+ })
642
+ ] });
646
643
  return /* @__PURE__ */ jsx(StaticInput, {
647
644
  ...props,
648
645
  onInteract: (focus) => {
@@ -657,18 +654,16 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
657
654
  hideLabel,
658
655
  isHeaderHidden,
659
656
  isDisabled,
660
- placeholder: staticPlaceholder,
661
657
  displayValue,
662
- isEmpty: !hasProvidedRangeValue,
663
658
  dataAttributes: {
664
- dataIsEmpty: !hasRangeValue,
665
- dataIsFilled: hasRangeValue,
659
+ dataIsEmpty: !hasProvidedRangeValue,
660
+ dataIsFilled: hasProvidedRangeValue,
666
661
  dataIsDirty: props.isDirty,
667
662
  dataIsRequired: props.isRequired,
668
663
  dataIsDisabled: isDisabled,
669
664
  dataDisabled: isDisabled,
670
665
  dataInvalid: !!props.error,
671
- dataHasSelection: hasRangeValue
666
+ dataHasSelection: hasProvidedRangeValue
672
667
  },
673
668
  contentRowClassName: datePickerInputContentRowCva({ size }),
674
669
  leadingContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
@@ -6,6 +6,7 @@ import { FormField } from "../../FormField/FormField.js";
6
6
  import { StaticInput } from "../../shared/StaticInput.js";
7
7
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
8
8
  import { InputContent } from "../shared/InputContent.js";
9
+ import { getStaticNumberDisplayValue } from "../shared/numberStatic.utils.js";
9
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
11
  import { clsx } from "clsx";
11
12
  import { isValidElement, useCallback, useEffect, useRef, useState } from "react";
@@ -145,7 +146,7 @@ var NumberInput = ({ renderStaticInput, ...props }) => {
145
146
  if (!renderInput) {
146
147
  const staticValue = watchedValue ?? props.value ?? props.defaultValue;
147
148
  const formatOptions = props.formatOptions ?? ui.numberInput.formatOptions;
148
- const displayValue = staticValue == null ? "" : new Intl.NumberFormat(locale, formatOptions).format(staticValue);
149
+ const displayValue = getStaticNumberDisplayValue(staticValue, new Intl.NumberFormat(locale, formatOptions)) ?? "";
149
150
  const hasValue = displayValue !== "";
150
151
  const as = props.as ?? ui.input.as;
151
152
  const size = props.size ?? ui.input.size;
@@ -181,12 +182,12 @@ var NumberInput = ({ renderStaticInput, ...props }) => {
181
182
  displayValue,
182
183
  isEmpty: !hasValue,
183
184
  dataAttributes: {
184
- dataIsEmpty: !staticValue,
185
- dataIsFilled: !(`${staticValue}` === "" || staticValue === null || staticValue === void 0),
185
+ dataIsEmpty: !hasValue,
186
+ dataIsFilled: hasValue,
186
187
  dataIsDirty: props.isDirty,
187
188
  dataIsRequired: props.isRequired,
188
- dataIsDisabled: isDisabled,
189
- dataDisabled: isDisabled,
189
+ dataIsDisabled: props.isDisabled,
190
+ dataDisabled: props.isDisabled,
190
191
  dataInvalid: !!props.error,
191
192
  dataHasSelection: hasValue
192
193
  },
@@ -6,6 +6,7 @@ import { inputBase, inputSize } from "../../shared/input.cva.js";
6
6
  import { FormField } from "../../FormField/FormField.js";
7
7
  import { StaticInput } from "../../shared/StaticInput.js";
8
8
  import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
9
+ import { getStaticNumberDisplayValue } from "../shared/numberStatic.utils.js";
9
10
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
11
  import { clsx } from "clsx";
11
12
  import { useEffect, useRef, useState } from "react";
@@ -234,13 +235,13 @@ var NumberRangeInput = ({ renderStaticInput, ...props }) => {
234
235
  const staticValue = normalizeRangeValue(watchedValue, props.minValue, props.maxValue);
235
236
  const formatOptions = props.formatOptions ?? ui.numberInput.formatOptions;
236
237
  const formatter = new Intl.NumberFormat(locale, formatOptions);
237
- const minDisplay = staticValue.min == null ? null : formatter.format(staticValue.min);
238
- const maxDisplay = staticValue.max == null ? null : formatter.format(staticValue.max);
239
- const hasValue = minDisplay !== "" || maxDisplay !== "";
238
+ const minDisplay = getStaticNumberDisplayValue(staticValue.min, formatter);
239
+ const maxDisplay = getStaticNumberDisplayValue(staticValue.max, formatter);
240
+ const hasValue = minDisplay !== null || maxDisplay !== null;
240
241
  const displayValue = /* @__PURE__ */ jsxs(Fragment, { children: [
241
242
  /* @__PURE__ */ jsx("span", {
242
243
  className: clsx("w-full bg-transparent outline-none", minDisplay ? props.minInputClassName : "text-text-default-3"),
243
- children: minDisplay ?? props.minPlaceholder
244
+ children: minDisplay ?? props.minPlaceholder ?? "Min"
244
245
  }),
245
246
  /* @__PURE__ */ jsx("span", {
246
247
  className: "pointer-events-none shrink-0 select-none text-label-2 text-text-default-3",
@@ -248,7 +249,7 @@ var NumberRangeInput = ({ renderStaticInput, ...props }) => {
248
249
  }),
249
250
  /* @__PURE__ */ jsx("span", {
250
251
  className: clsx("w-full bg-transparent outline-none", maxDisplay ? props.maxInputClassName : "text-text-default-3"),
251
- children: maxDisplay ?? props.maxPlaceholder
252
+ children: maxDisplay ?? props.maxPlaceholder ?? "Max"
252
253
  })
253
254
  ] });
254
255
  const rangeError = staticValue.min !== null && staticValue.max !== null && staticValue.min > staticValue.max ? props.invalidRangeError ?? "Minimum cannot be greater than maximum" : void 0;
@@ -257,6 +258,7 @@ var NumberRangeInput = ({ renderStaticInput, ...props }) => {
257
258
  const size = props.size ?? ui.input.size;
258
259
  const variant = props.variant ?? ui.input.variant;
259
260
  const hideLabel = props.hideLabel ?? ui.input.hideLabel;
261
+ const isClearable = props.isClearable ?? ui.input.isClearable;
260
262
  const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
261
263
  let isDisabled = !!props.isDisabled;
262
264
  if (isFormControlDisabled) isDisabled = true;
@@ -276,10 +278,8 @@ var NumberRangeInput = ({ renderStaticInput, ...props }) => {
276
278
  className: clsx("group w-full", as === "inline" && "h-full", props.className),
277
279
  inputClassName: props.inputClassName,
278
280
  displayValue,
279
- trailingContent: /* @__PURE__ */ jsx(InputClear, {
280
- show: !hasValue && !props.isDisabled && props.isClearable,
281
- onClear: () => {}
282
- }),
281
+ isEmpty: !hasValue,
282
+ hasClearIcon: !props.isDisabled && isClearable,
283
283
  dataAttributes: {
284
284
  dataIsEmpty: !hasValue,
285
285
  dataIsFilled: hasValue,
@@ -0,0 +1 @@
1
+ export declare const getStaticNumberDisplayValue: (value: unknown, formatter: Intl.NumberFormat) => string | null;
@@ -0,0 +1,7 @@
1
+ //#region src/components/inputs/Input/shared/numberStatic.utils.ts
2
+ var getStaticNumberDisplayValue = (value, formatter) => {
3
+ if (typeof value !== "number" || !Number.isFinite(value)) return null;
4
+ return formatter.format(value);
5
+ };
6
+ //#endregion
7
+ export { getStaticNumberDisplayValue };
@@ -53,6 +53,7 @@ function Select({ renderStaticInput, ...props }) {
53
53
  const as = props.as ?? ui.input.as;
54
54
  let isDisabled = !!props.isDisabled;
55
55
  if (isFormControlDisabled) isDisabled = true;
56
+ const isClearable = props.isClearable ?? ui.input.isClearable;
56
57
  const mode = props.selectionMode ?? ui.select.selectionMode;
57
58
  const { displayValue, isEmpty } = getStaticSelectValue({
58
59
  items: props.items,
@@ -97,6 +98,7 @@ function Select({ renderStaticInput, ...props }) {
97
98
  dataHasSearch: false
98
99
  },
99
100
  leadingContent: props.leadingContent,
101
+ hasClearIcon: isClearable,
100
102
  trailingContent
101
103
  });
102
104
  }
@@ -27,7 +27,10 @@ var getStaticSelectValue = ({ items, value, selectionMode, initialSelection, map
27
27
  return {
28
28
  selectedItem,
29
29
  selectedItems,
30
- displayValue: selectedItem != null ? showSelectionContent && selectedItem.content ? selectedItem.content : selectedItem.label : "",
30
+ displayValue: selectedItem != null ? showSelectionContent && selectedItem.content ? selectedItem.content : /* @__PURE__ */ jsx("div", {
31
+ className: "min-w-0 flex-1 truncate",
32
+ children: selectedItem.label
33
+ }) : "",
31
34
  isEmpty: selectedItem == null
32
35
  };
33
36
  };
@@ -28,10 +28,11 @@ interface StaticInputProps extends FormFieldProps {
28
28
  leadingVisual?: ReactNode;
29
29
  leadingContent?: ReactNode;
30
30
  leadingContentClassName?: string;
31
+ hasClearIcon?: boolean;
31
32
  trailingContent?: ReactNode;
32
33
  contentRowClassName?: string;
33
34
  inputClassName?: string;
34
35
  dataAttributes?: StaticInputDataAttributes;
35
36
  }
36
- export declare const StaticInput: ({ onInteract, as, typographySize, size, variant, applyMinInputWidth, placeholder, showPlacholderIfFilled, displayValue, isEmpty, leadingVisual, leadingContent, leadingContentClassName, trailingContent, contentRowClassName, inputClassName, dataAttributes, className, ...formFieldProps }: StaticInputProps) => import("react/jsx-runtime").JSX.Element;
37
+ export declare const StaticInput: ({ onInteract, as, typographySize, size, variant, applyMinInputWidth, placeholder, showPlacholderIfFilled, displayValue, isEmpty, leadingVisual, leadingContent, leadingContentClassName, hasClearIcon, trailingContent, contentRowClassName, inputClassName, dataAttributes, className, ...formFieldProps }: StaticInputProps) => import("react/jsx-runtime").JSX.Element;
37
38
  export {};
@@ -6,7 +6,7 @@ import { FormField } from "../FormField/FormField.js";
6
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
7
  import { clsx } from "clsx";
8
8
  //#region src/components/inputs/shared/StaticInput.tsx
9
- var StaticInput = ({ onInteract, as, typographySize, size, variant, applyMinInputWidth, placeholder, showPlacholderIfFilled = false, displayValue, isEmpty, leadingVisual, leadingContent, leadingContentClassName, trailingContent, contentRowClassName, inputClassName, dataAttributes, className, ...formFieldProps }) => {
9
+ var StaticInput = ({ onInteract, as, typographySize, size, variant, applyMinInputWidth, placeholder, showPlacholderIfFilled = false, displayValue, isEmpty, leadingVisual, leadingContent, leadingContentClassName, hasClearIcon, trailingContent, contentRowClassName, inputClassName, dataAttributes, className, ...formFieldProps }) => {
10
10
  const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
11
11
  const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
12
12
  const typographyCva = UIStyle.useCva("typography.cva", typography);
@@ -48,42 +48,55 @@ var StaticInput = ({ onInteract, as, typographySize, size, variant, applyMinInpu
48
48
  className: clsx("group/static-input group/input-content group/select-content relative flex items-center gap-input-gap-input-text-to-elements", applyMinInputWidth && "min-w-input-width-min-width", inputBaseCva({
49
49
  as,
50
50
  variant
51
- }), !hasValue && "text-text-default-3", inputClassName),
52
- children: [/* @__PURE__ */ jsxs("div", {
53
- className: clsx("group/input-content flex w-full items-center gap-input-gap-input-text-to-elements pr-0!", inputSizeCva({
54
- size,
55
- as
56
- }), typographySize && typographyCva({ size: typographySize }), contentRowClassName),
57
- children: [
58
- leadingVisual && /* @__PURE__ */ jsx("div", {
59
- className: "pointer-events-none shrink-0",
60
- children: leadingVisual
61
- }),
62
- as && ["filter", "floating"].includes(as) && /* @__PURE__ */ jsx(FormFieldLabel, {
63
- as,
51
+ }), inputClassName),
52
+ children: [
53
+ /* @__PURE__ */ jsxs("div", {
54
+ className: clsx("group/input-content flex min-w-0 w-full items-center gap-input-gap-input-text-to-elements pr-0!", inputSizeCva({
64
55
  size,
65
- label: formFieldProps.label,
66
- isRequired: formFieldProps.isRequired,
67
- isDisabled: formFieldProps.isDisabled
68
- }),
69
- leadingContent && /* @__PURE__ */ jsx("div", {
70
- className: clsx("ml-input-side-default flex shrink-0 items-center", leadingContentClassName),
71
- children: leadingContent
72
- }),
73
- staticDisplayContent,
74
- shouldRenderFloatingLineSpacer && /* @__PURE__ */ jsx(Fragment, { children: "\xA0" }),
75
- shouldRenderPlaceholderAfterValue && /* @__PURE__ */ jsx("div", {
76
- className: "text-text-default-3",
77
- children: placeholder
78
- })
79
- ]
80
- }), trailingContent && /* @__PURE__ */ jsx("div", {
81
- className: clsx(inputSizeCva({
82
- size,
83
- as
84
- }), "pointer-events-none flex items-center gap-input-gap-trailing-elements py-0! pl-0!"),
85
- children: trailingContent
86
- })]
56
+ as
57
+ }), typographySize && typographyCva({ size: typographySize }), contentRowClassName),
58
+ children: [
59
+ leadingVisual && /* @__PURE__ */ jsx("div", {
60
+ className: "pointer-events-none shrink-0",
61
+ children: leadingVisual
62
+ }),
63
+ as && ["filter", "floating"].includes(as) && /* @__PURE__ */ jsx(FormFieldLabel, {
64
+ as,
65
+ size,
66
+ label: formFieldProps.label,
67
+ isRequired: formFieldProps.isRequired,
68
+ isDisabled: formFieldProps.isDisabled
69
+ }),
70
+ leadingContent && /* @__PURE__ */ jsx("div", {
71
+ className: clsx("ml-input-side-default flex shrink-0 items-center", leadingContentClassName),
72
+ children: leadingContent
73
+ }),
74
+ !hasValue ? /* @__PURE__ */ jsx("div", {
75
+ className: "text-text-default-3",
76
+ children: staticDisplayContent
77
+ }) : staticDisplayContent,
78
+ shouldRenderFloatingLineSpacer && /* @__PURE__ */ jsx(Fragment, { children: "\xA0" }),
79
+ shouldRenderPlaceholderAfterValue && /* @__PURE__ */ jsx("div", {
80
+ className: "shrink-0 text-text-default-3",
81
+ children: placeholder
82
+ })
83
+ ]
84
+ }),
85
+ hasClearIcon && /* @__PURE__ */ jsx("div", {
86
+ className: clsx("flex items-center gap-input-gap-trailing-elements py-0! pl-0!", inputSizeCva({
87
+ size,
88
+ as
89
+ })),
90
+ children: /* @__PURE__ */ jsx("div", { className: "size-6 shrink-0" })
91
+ }),
92
+ trailingContent && /* @__PURE__ */ jsx("div", {
93
+ className: clsx(inputSizeCva({
94
+ size,
95
+ as
96
+ }), "pointer-events-none flex items-center gap-input-gap-trailing-elements py-0! pl-0!"),
97
+ children: trailingContent
98
+ })
99
+ ]
87
100
  })
88
101
  });
89
102
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.2.9-rc.21",
3
+ "version": "2.2.9-rc.23",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",