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

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.
@@ -175,7 +175,7 @@ var NumberInput = ({ renderStaticInput, ...props }) => {
175
175
  as,
176
176
  size,
177
177
  variant,
178
- children: /* @__PURE__ */ jsx("input", {
178
+ children: (dataAttributeProps) => /* @__PURE__ */ jsx("input", {
179
179
  ref: inputRef,
180
180
  readOnly: true,
181
181
  disabled: isDisabled,
@@ -183,14 +183,7 @@ var NumberInput = ({ renderStaticInput, ...props }) => {
183
183
  value: displayValue,
184
184
  placeholder: as === "floating" ? "" : props.placeholder,
185
185
  className: "w-full bg-transparent outline-none placeholder:text-text-default-3 disabled:text-interactive-text-secondary-disabled",
186
- "data-is-empty": dataAttributes.dataIsEmpty || void 0,
187
- "data-is-filled": dataAttributes.dataIsFilled || void 0,
188
- "data-is-dirty": dataAttributes.dataIsDirty || void 0,
189
- "data-is-required": dataAttributes.dataIsRequired || void 0,
190
- "data-is-disabled": dataAttributes.dataIsDisabled || void 0,
191
- "data-disabled": dataAttributes.dataDisabled || void 0,
192
- "data-invalid": dataAttributes.dataInvalid || void 0,
193
- "data-has-selection": dataAttributes.dataHasSelection || void 0,
186
+ ...dataAttributeProps,
194
187
  "data-rac": true
195
188
  })
196
189
  });
@@ -172,7 +172,7 @@ var TextInput = ({ renderStaticInput, ...props }) => {
172
172
  as,
173
173
  size,
174
174
  variant,
175
- children: /* @__PURE__ */ jsx("input", {
175
+ children: (dataAttributeProps) => /* @__PURE__ */ jsx("input", {
176
176
  ref: inputRef,
177
177
  type: inputType === "hidden" ? "password" : inputType,
178
178
  readOnly: true,
@@ -181,14 +181,7 @@ var TextInput = ({ renderStaticInput, ...props }) => {
181
181
  value: displayValue,
182
182
  placeholder: as === "floating" ? "" : props.placeholder,
183
183
  className: "w-full bg-transparent outline-none placeholder:text-text-default-3 disabled:text-interactive-text-secondary-disabled",
184
- "data-is-empty": dataAttributes.dataIsEmpty || void 0,
185
- "data-is-filled": dataAttributes.dataIsFilled || void 0,
186
- "data-is-dirty": dataAttributes.dataIsDirty || void 0,
187
- "data-is-required": dataAttributes.dataIsRequired || void 0,
188
- "data-is-disabled": dataAttributes.dataIsDisabled || void 0,
189
- "data-disabled": dataAttributes.dataDisabled || void 0,
190
- "data-invalid": dataAttributes.dataInvalid || void 0,
191
- "data-has-selection": dataAttributes.dataHasSelection || void 0,
184
+ ...dataAttributeProps,
192
185
  "data-rac": true
193
186
  })
194
187
  });
@@ -58,7 +58,7 @@ function Autocomplete({ renderStaticInput, ...props }) {
58
58
  let isDisabled = !!props.isDisabled;
59
59
  if (isFormControlDisabled) isDisabled = true;
60
60
  const mode = props.selectionMode ?? ui.select.selectionMode;
61
- const { displayValue, isEmpty } = getStaticSelectValue({
61
+ const { selectedItem, displayValue, isEmpty } = getStaticSelectValue({
62
62
  items: props.items,
63
63
  value: currentValue,
64
64
  selectionMode: mode,
@@ -69,10 +69,23 @@ function Autocomplete({ renderStaticInput, ...props }) {
69
69
  collapseAfter: props.collapseAfter ?? ui.select.collapseAfter,
70
70
  selectedTagsType: props.selectedTagsType ?? ui.select.selectedTagsType
71
71
  });
72
+ const isMultiple = mode === "multiple";
72
73
  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
74
  const placeholder = as === "floating" ? null : props.placeholder;
74
75
  const shouldRenderPlaceholderAfterValue = mode !== "single" && props.placeholder && !isEmpty;
75
- return /* @__PURE__ */ jsxs(InputFrame, {
76
+ const inputValue = !isMultiple && selectedItem ? selectedItem.label : "";
77
+ const dataAttributes = {
78
+ dataIsEmpty: isEmpty,
79
+ dataIsFilled: !isEmpty,
80
+ dataIsDirty: props.isDirty,
81
+ dataIsRequired: props.isRequired,
82
+ dataIsDisabled: isDisabled,
83
+ dataDisabled: isDisabled,
84
+ dataInvalid: !!props.error,
85
+ dataHasSelection: !isEmpty,
86
+ dataHasSearch: false
87
+ };
88
+ return /* @__PURE__ */ jsx(InputFrame, {
76
89
  ...props,
77
90
  isHeaderHidden: props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating",
78
91
  hideLabel: props.hideLabel ?? ui.input.hideLabel,
@@ -81,17 +94,7 @@ function Autocomplete({ renderStaticInput, ...props }) {
81
94
  inputClassName: clsx(props.className, props.inputClassName),
82
95
  contentWrapperClassName: "flex flex-1 flex-wrap gap-input-gap-input-text-to-elements truncate",
83
96
  labelPlacement: "content-row",
84
- dataAttributes: {
85
- dataIsEmpty: isEmpty,
86
- dataIsFilled: !isEmpty,
87
- dataIsDirty: props.isDirty,
88
- dataIsRequired: props.isRequired,
89
- dataIsDisabled: isDisabled,
90
- dataDisabled: isDisabled,
91
- dataInvalid: !!props.error,
92
- dataHasSelection: !isEmpty,
93
- dataHasSearch: false
94
- },
97
+ dataAttributes,
95
98
  renderStatic: true,
96
99
  onStaticInteract: (focus) => {
97
100
  setShouldFocus(focus);
@@ -105,13 +108,16 @@ function Autocomplete({ renderStaticInput, ...props }) {
105
108
  children: props.leadingContent
106
109
  }),
107
110
  trailingContent,
108
- children: [isEmpty ? /* @__PURE__ */ jsx("span", {
109
- className: "text-text-default-3",
110
- children: placeholder
111
- }) : displayValue, shouldRenderPlaceholderAfterValue && /* @__PURE__ */ jsx("div", {
112
- className: "shrink-0 text-text-default-3",
113
- children: props.placeholder
114
- })]
111
+ children: (dataAttributeProps) => /* @__PURE__ */ jsxs(Fragment, { children: [isMultiple && !isEmpty && displayValue, /* @__PURE__ */ jsx("input", {
112
+ readOnly: true,
113
+ disabled: isDisabled,
114
+ tabIndex: -1,
115
+ value: inputValue,
116
+ placeholder: isMultiple && shouldRenderPlaceholderAfterValue ? props.placeholder : placeholder ?? void 0,
117
+ className: clsx("w-full flex-1 bg-transparent outline-none placeholder:text-text-default-3 disabled:text-interactive-text-secondary-disabled", props.inputClassName),
118
+ ...dataAttributeProps,
119
+ "data-rac": true
120
+ })] })
115
121
  });
116
122
  }
117
123
  return /* @__PURE__ */ jsx(_Autocomplete, {
@@ -55,7 +55,8 @@ function Select({ renderStaticInput, ...props }) {
55
55
  if (isFormControlDisabled) isDisabled = true;
56
56
  const isClearable = props.isClearable ?? ui.input.isClearable;
57
57
  const mode = props.selectionMode ?? ui.select.selectionMode;
58
- const { displayValue, isEmpty } = getStaticSelectValue({
58
+ const isMultiple = mode === "multiple";
59
+ const { selectedItem, displayValue, isEmpty } = getStaticSelectValue({
59
60
  items: props.items,
60
61
  value: currentValue,
61
62
  selectionMode: mode,
@@ -66,8 +67,26 @@ function Select({ renderStaticInput, ...props }) {
66
67
  collapseAfter: props.collapseAfter ?? ui.select.collapseAfter,
67
68
  selectedTagsType: props.selectedTagsType ?? ui.select.selectedTagsType
68
69
  });
70
+ const isSearchable = props.isSearchable ?? ui.select.isSearchable;
69
71
  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
72
  const placeholder = as === "floating" ? null : props.placeholder;
73
+ const inputValue = !isMultiple && selectedItem ? selectedItem.label : "";
74
+ const shouldRenderPlaceholderAfterValue = isMultiple && props.placeholder && !isEmpty;
75
+ const dataAttributes = {
76
+ dataIsEmpty: isEmpty,
77
+ dataIsFilled: !isEmpty,
78
+ dataIsDirty: props.isDirty,
79
+ dataIsRequired: props.isRequired,
80
+ dataIsDisabled: isDisabled,
81
+ dataDisabled: isDisabled,
82
+ dataInvalid: !!props.error,
83
+ dataHasSelection: !isEmpty,
84
+ dataHasSearch: false
85
+ };
86
+ const buttonContent = isMultiple && !isEmpty ? /* @__PURE__ */ jsx(Fragment, { children: "\xA0" }) : isEmpty ? /* @__PURE__ */ jsx("span", {
87
+ className: "text-text-default-3",
88
+ children: placeholder
89
+ }) : displayValue;
71
90
  return /* @__PURE__ */ jsx(InputFrame, {
72
91
  ...props,
73
92
  isHeaderHidden: props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating",
@@ -77,17 +96,7 @@ function Select({ renderStaticInput, ...props }) {
77
96
  inputClassName: clsx(props.className, props.inputClassName),
78
97
  typographySize: "label-1",
79
98
  labelPlacement: "content-row",
80
- dataAttributes: {
81
- dataIsEmpty: isEmpty,
82
- dataIsFilled: !isEmpty,
83
- dataIsDirty: props.isDirty,
84
- dataIsRequired: props.isRequired,
85
- dataIsDisabled: isDisabled,
86
- dataDisabled: isDisabled,
87
- dataInvalid: !!props.error,
88
- dataHasSelection: !isEmpty,
89
- dataHasSearch: false
90
- },
99
+ dataAttributes,
91
100
  renderStatic: true,
92
101
  onStaticInteract: (focus) => {
93
102
  setShouldFocus(focus);
@@ -103,10 +112,25 @@ function Select({ renderStaticInput, ...props }) {
103
112
  isClearable,
104
113
  showClear: false,
105
114
  trailingContent,
106
- children: isEmpty ? /* @__PURE__ */ jsx("span", {
107
- className: "text-text-default-3",
108
- children: placeholder
109
- }) : displayValue
115
+ children: (dataAttributeProps) => /* @__PURE__ */ jsxs(Fragment, { children: [isMultiple && !isEmpty && displayValue, isSearchable ? /* @__PURE__ */ jsx("input", {
116
+ readOnly: true,
117
+ disabled: isDisabled,
118
+ tabIndex: -1,
119
+ value: inputValue,
120
+ placeholder: shouldRenderPlaceholderAfterValue ? props.placeholder : placeholder ?? void 0,
121
+ className: clsx("w-full flex-1 bg-transparent outline-none placeholder:text-text-default-3 disabled:text-interactive-text-secondary-disabled", props.inputClassName),
122
+ ...dataAttributeProps,
123
+ "data-rac": true
124
+ }) : /* @__PURE__ */ jsx("button", {
125
+ type: "button",
126
+ disabled: isDisabled,
127
+ tabIndex: -1,
128
+ "data-type": "select-trigger",
129
+ className: clsx("w-full truncate bg-transparent text-start outline-none disabled:text-interactive-text-secondary-disabled", isMultiple && !isEmpty && "absolute inset-0 z-0"),
130
+ ...dataAttributeProps,
131
+ "data-rac": true,
132
+ children: buttonContent
133
+ })] })
110
134
  });
111
135
  }
112
136
  return /* @__PURE__ */ jsx(_Select, {
@@ -22,10 +22,22 @@ interface InputFrameDataAttributes {
22
22
  dataIsFilled?: boolean;
23
23
  dataIsRequired?: boolean;
24
24
  }
25
+ type InputFrameDataAttributeProps = {
26
+ "data-disabled"?: boolean;
27
+ "data-has-search"?: boolean;
28
+ "data-has-selection"?: boolean;
29
+ "data-invalid"?: boolean;
30
+ "data-is-dirty"?: boolean;
31
+ "data-is-disabled"?: boolean;
32
+ "data-is-empty"?: boolean;
33
+ "data-is-filled"?: boolean;
34
+ "data-is-required"?: boolean;
35
+ };
36
+ type InputFrameChildren = ReactNode | ((dataAttributeProps: InputFrameDataAttributeProps) => ReactNode);
25
37
  type InputFrameLabelPlacement = "content-wrapper" | "content-row";
26
38
  export interface InputFrameProps extends InputVariantProps, Partial<FormFieldProps> {
27
39
  ref?: Ref<HTMLDivElement>;
28
- children: ReactNode;
40
+ children: InputFrameChildren;
29
41
  formFieldRef?: Ref<HTMLDivElement>;
30
42
  labelProps?: FormFieldHeaderProps["labelProps"];
31
43
  headerProps?: FormFieldHeaderProps;
@@ -52,6 +52,7 @@ var InputFrame = ({ ref, children, formFieldRef, labelProps, headerProps, error,
52
52
  size,
53
53
  ...resolvedHeaderProps
54
54
  }) : null;
55
+ const resolvedContentWrapperClassName = contentWrapperClassName ?? inputContentWrapperCva({ as });
55
56
  return /* @__PURE__ */ jsx(TooltipWrapper, {
56
57
  as,
57
58
  error,
@@ -86,6 +87,7 @@ var InputFrame = ({ ref, children, formFieldRef, labelProps, headerProps, error,
86
87
  onPointerDown: () => {
87
88
  if (renderStatic) onStaticInteract?.(true);
88
89
  },
90
+ "data-rac": "",
89
91
  children: [/* @__PURE__ */ jsxs("div", {
90
92
  className: clsx("group/input-frame flex min-w-0 w-full items-center gap-input-gap-input-text-to-elements pr-0!", as === "inline" && "h-full", inputSizeCva({
91
93
  size,
@@ -99,14 +101,11 @@ var InputFrame = ({ ref, children, formFieldRef, labelProps, headerProps, error,
99
101
  }),
100
102
  labelPlacement === "content-row" && labelContent,
101
103
  /* @__PURE__ */ jsxs("div", {
102
- className: inputContentWrapperCva({
103
- as,
104
- className: contentWrapperClassName
105
- }),
104
+ className: resolvedContentWrapperClassName,
106
105
  children: [
107
106
  labelPlacement === "content-wrapper" && labelContent,
108
107
  actionContent,
109
- children
108
+ typeof children === "function" ? children(dataAttributeProps) : children
110
109
  ]
111
110
  })
112
111
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.2.9-rc.29",
3
+ "version": "2.2.9-rc.30",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",