@povio/ui 2.2.9-rc.22 → 2.2.9-rc.24

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),
@@ -75,15 +75,16 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
75
75
  const pickerIcon = isDateTime ? uiConfig.dateInput.dateTimeIcon : uiConfig.dateInput.calendarIcon;
76
76
  return /* @__PURE__ */ jsxs("div", {
77
77
  ref: containerRef,
78
- className: clsx(inputBaseCva({
78
+ className: clsx("group/date-picker-content relative flex min-w-input-width-min-width items-center justify-between gap-2", inputBaseCva({
79
79
  variant,
80
80
  as,
81
81
  ...props
82
- }), "group/date-picker-content relative flex min-w-input-width-min-width items-center justify-between gap-2", className),
82
+ }), className),
83
83
  "data-rac": "",
84
84
  "data-datetime-input": "",
85
85
  "data-hovered": isHovered || void 0,
86
86
  "data-disabled": isDisabled || void 0,
87
+ "data-is-disabled": isDisabled || void 0,
87
88
  "data-invalid": isInvalid || void 0,
88
89
  "data-is-empty": fieldProps.value === null || void 0,
89
90
  "data-focus-within": isFocused || void 0,
@@ -96,10 +97,10 @@ var DatePickerInput = ({ ref, as, groupProps, fieldProps, endFieldProps, buttonP
96
97
  ...focusWithinProps,
97
98
  ...hoverProps,
98
99
  children: [/* @__PURE__ */ jsxs("div", {
99
- className: clsx(inputSizeCva({
100
+ className: clsx("flex w-full items-center gap-input-gap-input-text-to-elements pr-0!", inputSizeCva({
100
101
  size,
101
102
  as
102
- }), "flex w-full items-center gap-input-gap-input-text-to-elements pr-0!"),
103
+ })),
103
104
  children: [as && ["filter", "floating"].includes(as) && headerProps && /* @__PURE__ */ jsx(FormFieldLabel, {
104
105
  as,
105
106
  ...headerProps
@@ -33,6 +33,7 @@ var TimePickerInput = ({ ref, as, fieldProps, state, isDisabled, isDirty, isRequ
33
33
  "data-datetime-input": "",
34
34
  "data-hovered": isHovered || void 0,
35
35
  "data-disabled": isDisabled || void 0,
36
+ "data-is-disabled": isDisabled || void 0,
36
37
  "data-invalid": isInvalid || void 0,
37
38
  "data-is-empty": state.value === null || void 0,
38
39
  "data-focus-within": isFocused || void 0,
@@ -128,6 +128,7 @@ var FileUploadBase = (props) => {
128
128
  ...rest,
129
129
  "data-rac": "",
130
130
  "data-disabled": isDisabled || void 0,
131
+ "data-is-disabled": isDisabled || void 0,
131
132
  "data-invalid": !!error || void 0,
132
133
  "data-multiple": allowsMultiple || void 0,
133
134
  "data-has-files": uploadState.length > 0 || void 0,
@@ -21,6 +21,7 @@ var InputUploadContent = (props) => {
21
21
  children: /* @__PURE__ */ jsxs("div", {
22
22
  "data-rac": "",
23
23
  "data-disabled": isDisabled || void 0,
24
+ "data-is-disabled": isDisabled || void 0,
24
25
  "data-invalid": !!error || void 0,
25
26
  className: inputUploadButton({
26
27
  variant,
@@ -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,8 +182,8 @@ 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
189
  dataIsDisabled: props.isDisabled,
@@ -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";
@@ -26,7 +27,7 @@ var normalizeRangeValue = (value, minValue, maxValue) => {
26
27
  max: maxValue ?? null
27
28
  };
28
29
  };
29
- var NumberRangeField = ({ label, value, placeholder, isDisabled, isInvalid, isRequired, formatOptions, hideInnerLabels, autoFocusOnMount, className, onChange, onBlur, ...rest }) => {
30
+ var NumberRangeField = ({ label, value, placeholder, isDisabled, isInvalid, isRequired, formatOptions, hideInnerLabels, autoFocusOnMount, isClearable, className, onChange, onClear, onBlur, ...rest }) => {
30
31
  const ui = UIConfig.useConfig();
31
32
  const { locale } = useLocale();
32
33
  const { isFocusVisible } = useFocusVisible();
@@ -39,7 +40,7 @@ var NumberRangeField = ({ label, value, placeholder, isDisabled, isInvalid, isRe
39
40
  const numberProps = {
40
41
  ...rest,
41
42
  label,
42
- value: value ?? void 0,
43
+ value: value ?? NaN,
43
44
  placeholder,
44
45
  isDisabled,
45
46
  isInvalid,
@@ -58,15 +59,21 @@ var NumberRangeField = ({ label, value, placeholder, isDisabled, isInvalid, isRe
58
59
  isRequired,
59
60
  isDisabled,
60
61
  className: clsx(hideInnerLabels && "sr-only")
61
- }), /* @__PURE__ */ jsx(Input, {
62
- ...inputProps,
63
- ref: mergeRefs(inputRef, numberFieldRef),
64
- placeholder: inputProps.placeholder,
65
- className: clsx("w-full bg-transparent outline-none", className),
66
- onFocus: (e) => {
67
- inputProps.onFocus?.(e);
68
- if (isFocusVisible) e.target.select();
69
- }
62
+ }), /* @__PURE__ */ jsxs("div", {
63
+ className: "flex items-center gap-input-gap-trailing-elements",
64
+ children: [/* @__PURE__ */ jsx(Input, {
65
+ ...inputProps,
66
+ ref: mergeRefs(inputRef, numberFieldRef),
67
+ placeholder: inputProps.placeholder,
68
+ className: clsx("w-full min-w-0 bg-transparent outline-none", className),
69
+ onFocus: (e) => {
70
+ inputProps.onFocus?.(e);
71
+ if (isFocusVisible) e.target.select();
72
+ }
73
+ }), isClearable && /* @__PURE__ */ jsx(InputClear, {
74
+ onClear,
75
+ show: value !== null && !isDisabled
76
+ })]
70
77
  })]
71
78
  });
72
79
  };
@@ -120,11 +127,8 @@ var NumberRangeInputBase = (props) => {
120
127
  if (side === "min") onMinChange?.(nextValue);
121
128
  else onMaxChange?.(nextValue);
122
129
  };
123
- const onClear = () => {
124
- const nextRange = { ...EMPTY_RANGE };
125
- onChange?.(nextRange);
126
- onMinChange?.(null);
127
- onMaxChange?.(null);
130
+ const clearRangeSide = (side) => {
131
+ updateRange(side, null);
128
132
  onBlur?.({ target: { value: "" } });
129
133
  };
130
134
  return /* @__PURE__ */ jsx(TooltipWrapper, {
@@ -137,7 +141,7 @@ var NumberRangeInputBase = (props) => {
137
141
  as,
138
142
  className: clsx("group w-full", className),
139
143
  tabIndex: as === "inline" ? -1 : void 0,
140
- children: /* @__PURE__ */ jsxs("div", {
144
+ children: /* @__PURE__ */ jsx("div", {
141
145
  className: clsx(inputBaseCva({
142
146
  variant,
143
147
  as
@@ -145,6 +149,7 @@ var NumberRangeInputBase = (props) => {
145
149
  "data-rac": "",
146
150
  "data-hovered": isHovered || void 0,
147
151
  "data-disabled": isDisabled || void 0,
152
+ "data-is-disabled": isDisabled || void 0,
148
153
  "data-invalid": !!effectiveError || void 0,
149
154
  "data-is-empty": isEmpty || void 0,
150
155
  "data-focus-within": isFocused || void 0,
@@ -155,7 +160,7 @@ var NumberRangeInputBase = (props) => {
155
160
  "data-is-filled": !isEmpty || void 0,
156
161
  ...focusWithinProps,
157
162
  ...hoverProps,
158
- children: [/* @__PURE__ */ jsxs("div", {
163
+ children: /* @__PURE__ */ jsxs("div", {
159
164
  className: clsx("flex w-full items-center gap-input-gap-input-text-to-elements pr-0!", inputSizeCva({
160
165
  size,
161
166
  as
@@ -179,6 +184,10 @@ var NumberRangeInputBase = (props) => {
179
184
  isRequired,
180
185
  hideInnerLabels,
181
186
  autoFocusOnMount,
187
+ isClearable,
188
+ onClear: () => {
189
+ clearRangeSide("min");
190
+ },
182
191
  className: minInputClassName
183
192
  }),
184
193
  /* @__PURE__ */ jsx("span", {
@@ -198,19 +207,14 @@ var NumberRangeInputBase = (props) => {
198
207
  isInvalid: !!effectiveError,
199
208
  isRequired,
200
209
  hideInnerLabels,
210
+ isClearable,
211
+ onClear: () => {
212
+ clearRangeSide("max");
213
+ },
201
214
  className: maxInputClassName
202
215
  })
203
216
  ]
204
- }), /* @__PURE__ */ jsx("div", {
205
- className: clsx("flex items-center gap-input-gap-trailing-elements py-0! pl-0!", inputSizeCva({
206
- size,
207
- as
208
- })),
209
- children: isClearable && /* @__PURE__ */ jsx(InputClear, {
210
- onClear,
211
- show: !isEmpty && !isDisabled
212
- })
213
- })]
217
+ })
214
218
  })
215
219
  })
216
220
  });
@@ -234,13 +238,13 @@ var NumberRangeInput = ({ renderStaticInput, ...props }) => {
234
238
  const staticValue = normalizeRangeValue(watchedValue, props.minValue, props.maxValue);
235
239
  const formatOptions = props.formatOptions ?? ui.numberInput.formatOptions;
236
240
  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 !== "";
241
+ const minDisplay = getStaticNumberDisplayValue(staticValue.min, formatter);
242
+ const maxDisplay = getStaticNumberDisplayValue(staticValue.max, formatter);
243
+ const hasValue = minDisplay !== null || maxDisplay !== null;
240
244
  const displayValue = /* @__PURE__ */ jsxs(Fragment, { children: [
241
245
  /* @__PURE__ */ jsx("span", {
242
246
  className: clsx("w-full bg-transparent outline-none", minDisplay ? props.minInputClassName : "text-text-default-3"),
243
- children: minDisplay ?? props.minPlaceholder
247
+ children: minDisplay ?? props.minPlaceholder ?? "Min"
244
248
  }),
245
249
  /* @__PURE__ */ jsx("span", {
246
250
  className: "pointer-events-none shrink-0 select-none text-label-2 text-text-default-3",
@@ -248,7 +252,7 @@ var NumberRangeInput = ({ renderStaticInput, ...props }) => {
248
252
  }),
249
253
  /* @__PURE__ */ jsx("span", {
250
254
  className: clsx("w-full bg-transparent outline-none", maxDisplay ? props.maxInputClassName : "text-text-default-3"),
251
- children: maxDisplay ?? props.maxPlaceholder
255
+ children: maxDisplay ?? props.maxPlaceholder ?? "Max"
252
256
  })
253
257
  ] });
254
258
  const rangeError = staticValue.min !== null && staticValue.max !== null && staticValue.min > staticValue.max ? props.invalidRangeError ?? "Minimum cannot be greater than maximum" : void 0;
@@ -257,7 +261,6 @@ var NumberRangeInput = ({ renderStaticInput, ...props }) => {
257
261
  const size = props.size ?? ui.input.size;
258
262
  const variant = props.variant ?? ui.input.variant;
259
263
  const hideLabel = props.hideLabel ?? ui.input.hideLabel;
260
- const isClearable = props.isClearable ?? ui.input.isClearable;
261
264
  const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
262
265
  let isDisabled = !!props.isDisabled;
263
266
  if (isFormControlDisabled) isDisabled = true;
@@ -277,8 +280,6 @@ var NumberRangeInput = ({ renderStaticInput, ...props }) => {
277
280
  className: clsx("group w-full", as === "inline" && "h-full", props.className),
278
281
  inputClassName: props.inputClassName,
279
282
  displayValue,
280
- isEmpty: !hasValue,
281
- hasClearIcon: !props.isDisabled && isClearable,
282
283
  dataAttributes: {
283
284
  dataIsEmpty: !hasValue,
284
285
  dataIsFilled: hasValue,
@@ -18,10 +18,10 @@ var InputContent = ({ leadingIcon: LeadingIcon, trailingIcon: TrailingIcon, unit
18
18
  return /* @__PURE__ */ jsxs("div", {
19
19
  className: "flex w-full items-center gap-input-gap-input-text-to-elements",
20
20
  children: [/* @__PURE__ */ jsxs("div", {
21
- className: clsx(inputSizeCva({
21
+ className: clsx("group/input-content flex w-full items-center gap-input-gap-input-text-to-elements pr-0!", as === "inline" && "h-full", inputSizeCva({
22
22
  size,
23
23
  as
24
- }), "group/input-content flex w-full items-center gap-input-gap-input-text-to-elements pr-0!", as === "inline" && "h-full"),
24
+ })),
25
25
  children: [LeadingIcon && /* @__PURE__ */ jsx("div", {
26
26
  className: clsx(!isLeadingIconElement && "pointer-events-none"),
27
27
  children: isLeadingIconElement ? LeadingIcon : /* @__PURE__ */ jsx(LeadingIcon, { className: "size-6 text-interactive-text-secondary-idle" })
@@ -34,10 +34,10 @@ var InputContent = ({ leadingIcon: LeadingIcon, trailingIcon: TrailingIcon, unit
34
34
  }), children]
35
35
  })]
36
36
  }), /* @__PURE__ */ jsxs("div", {
37
- className: clsx(inputSizeCva({
37
+ className: clsx("flex items-center gap-input-gap-trailing-elements py-0! pl-0!", inputSizeCva({
38
38
  size,
39
39
  as
40
- }), "flex items-center gap-input-gap-trailing-elements py-0! pl-0!", !isTrailingIconElement && !action && !(isClearable && showClear) && "pointer-events-none"),
40
+ }), !isTrailingIconElement && !action && !(isClearable && showClear) && "pointer-events-none"),
41
41
  children: [
42
42
  isClearable && /* @__PURE__ */ jsx(InputClear, {
43
43
  onClear: () => {
@@ -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 };
@@ -71,6 +71,7 @@ var SelectInput = ({ ref, placeholder, variant, as, size, isDisabled, isInvalid,
71
71
  }),
72
72
  "data-rac": "",
73
73
  "data-disabled": isDisabled || void 0,
74
+ "data-is-disabled": isDisabled || void 0,
74
75
  "data-hovered": isHovered || void 0,
75
76
  "data-focused": isOpen || isFocused || void 0,
76
77
  "data-focus-within": isFocused || void 0,
@@ -106,6 +106,7 @@ var TextEditorBase = ({ ref, as = "default", placeholder, label, hideLabel, tool
106
106
  "data-rac": "",
107
107
  "data-hovered": isHovered || void 0,
108
108
  "data-disabled": isDisabled || void 0,
109
+ "data-is-disabled": isDisabled || void 0,
109
110
  "data-focus-within": isFocused || void 0,
110
111
  "data-focus-visible": isFocused && isFocusVisible || void 0,
111
112
  "data-is-filled": !editor?.isEmpty,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.2.9-rc.22",
3
+ "version": "2.2.9-rc.24",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",