@povio/ui 2.2.9-rc.31 → 2.2.9-rc.32

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.
@@ -215,6 +215,8 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...pr
215
215
  const isDisabled = isFormControlDisabled || !!props.isDisabled;
216
216
  const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
217
217
  const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
218
+ const todayIconPlacement = props.todayIconPlacement ?? ui.dateInput.todayIconPlacement;
219
+ const staticTodayIcon = renderDatePickerTodayIcon(todayIcon, todayIconButtonSize);
218
220
  const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
219
221
  const showDropdown = !props.disableDropdown || disableManualEntry;
220
222
  const staticSegments = getStaticCalendarDateSegments({
@@ -247,7 +249,8 @@ var DatePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput, ...pr
247
249
  setShouldFocus(focus);
248
250
  setRenderInput(true);
249
251
  },
250
- actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
252
+ actionContent: staticTodayIcon,
253
+ actionContentPlacement: todayIconPlacement === "fieldLabel" ? "content-row" : "content-wrapper",
251
254
  trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
252
255
  children: staticSegments
253
256
  });
@@ -615,6 +615,8 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
615
615
  const isDisabled = isFormControlDisabled || !!props.isDisabled;
616
616
  const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
617
617
  const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
618
+ const todayIconPlacement = props.todayIconPlacement ?? ui.dateInput.todayIconPlacement;
619
+ const staticTodayIcon = renderDatePickerTodayIcon(todayIcon, todayIconButtonSize);
618
620
  const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
619
621
  const showDropdown = !props.disableDropdown || disableManualEntry;
620
622
  const staticSegments = getStaticDateRangeSegments({
@@ -648,7 +650,8 @@ var DateRangePicker = ({ fullIso = true, minValue, maxValue, renderStaticInput,
648
650
  setShouldFocus(focus);
649
651
  setRenderInput(true);
650
652
  },
651
- actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
653
+ actionContent: staticTodayIcon,
654
+ actionContentPlacement: todayIconPlacement === "fieldLabel" ? "content-row" : "content-wrapper",
652
655
  trailingContent: showDropdown ? ui.dateInput.calendarIcon : void 0,
653
656
  children: staticSegments
654
657
  });
@@ -229,6 +229,8 @@ var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
229
229
  const isDisabled = isFormControlDisabled || !!props.isDisabled;
230
230
  const todayIcon = props.todayIcon ?? ui.dateInput.todayIcon;
231
231
  const todayIconButtonSize = props.todayIconButtonSize ?? ui.dateInput.todayIconButtonSize;
232
+ const todayIconPlacement = props.todayIconPlacement ?? ui.dateInput.todayIconPlacement;
233
+ const staticTodayIcon = renderDatePickerTodayIcon(todayIcon, todayIconButtonSize);
232
234
  const disableManualEntry = props.disableManualEntry ?? ui.dateInput.disableManualEntry;
233
235
  const showDropdown = !props.disableDropdown || disableManualEntry;
234
236
  const staticSegments = getStaticCalendarDateTimeSegments({
@@ -261,7 +263,8 @@ var DateTimePicker = ({ fullIso = true, renderStaticInput, ...props }) => {
261
263
  setShouldFocus(focus);
262
264
  setRenderInput(true);
263
265
  },
264
- actionContent: renderDatePickerTodayIcon(todayIcon, todayIconButtonSize),
266
+ actionContent: staticTodayIcon,
267
+ actionContentPlacement: todayIconPlacement === "fieldLabel" ? "content-row" : "content-wrapper",
265
268
  trailingContent: showDropdown ? ui.dateInput.dateTimeIcon : void 0,
266
269
  children: staticSegments
267
270
  });
@@ -1,5 +1,5 @@
1
1
  import { DOMAttributes } from '@react-types/shared';
2
- import { ReactNode } from 'react';
2
+ import { LabelHTMLAttributes, ReactNode } from 'react';
3
3
  export interface FormFieldHeaderProps {
4
4
  label: string;
5
5
  tooltipText?: string;
@@ -9,6 +9,6 @@ export interface FormFieldHeaderProps {
9
9
  isHeaderHidden?: boolean;
10
10
  isDisabled?: boolean;
11
11
  className?: string;
12
- labelProps?: DOMAttributes<HTMLLabelElement>;
12
+ labelProps?: DOMAttributes<HTMLLabelElement> & LabelHTMLAttributes<HTMLLabelElement>;
13
13
  }
14
14
  export declare const FormFieldHeader: ({ label, tooltipText, helperText, isRequired, rightContent, isHeaderHidden, isDisabled, className, labelProps, }: FormFieldHeaderProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import { DOMAttributes } from '@react-types/shared';
2
- import { RefCallback } from 'react';
2
+ import { LabelHTMLAttributes, RefCallback } from 'react';
3
3
  import { InputSizeProps } from '../shared/input.cva';
4
4
  import { LabelBaseProps } from '../shared/label.cva';
5
5
  export interface FormFieldLabelProps extends LabelBaseProps, InputSizeProps {
@@ -7,7 +7,7 @@ export interface FormFieldLabelProps extends LabelBaseProps, InputSizeProps {
7
7
  isRequired?: boolean;
8
8
  isDisabled?: boolean;
9
9
  ref?: RefCallback<HTMLOrSVGElement>;
10
- labelProps?: DOMAttributes<HTMLLabelElement>;
10
+ labelProps?: DOMAttributes<HTMLLabelElement> & LabelHTMLAttributes<HTMLLabelElement>;
11
11
  className?: string;
12
12
  }
13
13
  export declare const FormFieldLabel: ({ ref, as, label, isRequired, isDisabled, labelProps, className, }: FormFieldLabelProps) => import("react/jsx-runtime").JSX.Element;
@@ -170,8 +170,10 @@ var NumberRangeInput = ({ renderStaticInput, ...props }) => {
170
170
  setRenderInput(true);
171
171
  },
172
172
  isClearable: false,
173
- children: (dataAttributeProps) => /* @__PURE__ */ jsxs(Fragment, { children: [
173
+ labelPlacement: "content-row",
174
+ children: ({ id, ...dataAttributeProps }) => /* @__PURE__ */ jsxs(Fragment, { children: [
174
175
  /* @__PURE__ */ jsx("input", {
176
+ id,
175
177
  readOnly: true,
176
178
  disabled: isDisabled,
177
179
  tabIndex: -1,
@@ -190,6 +192,7 @@ var NumberRangeInput = ({ renderStaticInput, ...props }) => {
190
192
  children: "-"
191
193
  }),
192
194
  /* @__PURE__ */ jsx("input", {
195
+ id: `${id}-max`,
193
196
  readOnly: true,
194
197
  disabled: isDisabled,
195
198
  tabIndex: -1,
@@ -33,8 +33,12 @@ type InputFrameDataAttributeProps = {
33
33
  "data-is-filled"?: boolean;
34
34
  "data-is-required"?: boolean;
35
35
  };
36
- type InputFrameChildren = ReactNode | ((dataAttributeProps: InputFrameDataAttributeProps) => ReactNode);
36
+ type InputFrameChildProps = InputFrameDataAttributeProps & {
37
+ id: string;
38
+ };
39
+ type InputFrameChildren = ReactNode | ((childProps: InputFrameChildProps) => ReactNode);
37
40
  type InputFrameLabelPlacement = "content-wrapper" | "content-row";
41
+ type InputFrameActionContentPlacement = "content-wrapper" | "content-row";
38
42
  export interface InputFrameProps extends InputVariantProps, Partial<FormFieldProps> {
39
43
  ref?: Ref<HTMLDivElement>;
40
44
  children: InputFrameChildren;
@@ -44,6 +48,7 @@ export interface InputFrameProps extends InputVariantProps, Partial<FormFieldPro
44
48
  leadingContent?: ReactNode;
45
49
  leadingIcon?: InputFrameIcon;
46
50
  actionContent?: ReactNode;
51
+ actionContentPlacement?: InputFrameActionContentPlacement;
47
52
  trailingContent?: ReactNode;
48
53
  trailingIcon?: InputFrameIcon;
49
54
  trailingAction?: ReactNode;
@@ -58,6 +63,7 @@ export interface InputFrameProps extends InputVariantProps, Partial<FormFieldPro
58
63
  onClear?: () => void;
59
64
  dataAttributes?: InputFrameDataAttributes;
60
65
  typographySize?: TypographyVariantProps["size"];
66
+ id?: string;
61
67
  inputClassName?: string;
62
68
  contentClassName?: string;
63
69
  contentWrapperClassName?: string;
@@ -10,7 +10,7 @@ import { FormField } from "../FormField/FormField.js";
10
10
  import { TooltipWrapper } from "../shared/TooltipWrapper.js";
11
11
  import { jsx, jsxs } from "react/jsx-runtime";
12
12
  import { clsx } from "clsx";
13
- import { isValidElement } from "react";
13
+ import { isValidElement, useId } from "react";
14
14
  //#region src/components/inputs/Skeleton/InputFrame.tsx
15
15
  var InputFrame = (props) => {
16
16
  const ui = UIConfig.useConfig();
@@ -18,7 +18,8 @@ var InputFrame = (props) => {
18
18
  const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
19
19
  const inputContentWrapperCva = UIStyle.useCva("input.contentWrapperCva", inputContentWrapper);
20
20
  const typographyCva = UIStyle.useCva("typography.cva", typography);
21
- const { ref, children, formFieldRef, labelProps, headerProps, error, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isHeaderHidden, hideLabel: hideLabelProp, headerClassName, errorClassName, className, leadingContent, leadingIcon, actionContent, trailingContent, trailingIcon, trailingAction, unit, isLoading, action, isClearable: isClearableProp, showClear, renderStatic, onStaticInteract, clearClassName, onClear, dataAttributes, typographySize, inputClassName, contentClassName, contentWrapperClassName, labelPlacement = "content-wrapper", trailingClassName, variant: variantProp, as: asProp, size: sizeProp } = props;
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, labelPlacement = "content-wrapper", trailingClassName, variant: variantProp, as: asProp, size: sizeProp } = props;
22
23
  const as = asProp ?? ui.input.as;
23
24
  const size = sizeProp ?? ui.input.size;
24
25
  const variant = variantProp ?? ui.input.variant;
@@ -29,6 +30,12 @@ var InputFrame = (props) => {
29
30
  const hasTrailingContent = hasClear || !!trailingContent || !!unit || !!isLoading || !!action || !!trailingIcon || !!trailingAction;
30
31
  const isTrailingInteractive = !!action || !!trailingAction || !!isTrailingIconElement || hasClear && !!showClear || !!trailingContent;
31
32
  const dataAttributeProps = getInputFrameDataAttributeProps(dataAttributes);
33
+ const baseLabelProps = headerProps?.labelProps ?? labelPropsProp;
34
+ const inputId = idProp ?? baseLabelProps?.htmlFor ?? `input-frame_${generatedInputId}`;
35
+ const labelProps = {
36
+ ...baseLabelProps,
37
+ htmlFor: inputId
38
+ };
32
39
  const formFieldProps = {
33
40
  error,
34
41
  label: label ?? "",
@@ -43,7 +50,10 @@ var InputFrame = (props) => {
43
50
  errorClassName,
44
51
  className
45
52
  };
46
- const resolvedHeaderProps = headerProps ?? {
53
+ const resolvedHeaderProps = headerProps ? {
54
+ ...headerProps,
55
+ labelProps
56
+ } : {
47
57
  label: label ?? "",
48
58
  tooltipText,
49
59
  helperText,
@@ -107,12 +117,16 @@ var InputFrame = (props) => {
107
117
  children: renderIconVisual(leadingIcon)
108
118
  }),
109
119
  labelPlacement === "content-row" && labelContent,
120
+ actionContentPlacement === "content-row" && actionContent,
110
121
  /* @__PURE__ */ jsxs("div", {
111
122
  className: resolvedContentWrapperClassName,
112
123
  children: [
113
124
  labelPlacement === "content-wrapper" && labelContent,
114
- actionContent,
115
- typeof children === "function" ? children(dataAttributeProps) : children
125
+ actionContentPlacement === "content-wrapper" && actionContent,
126
+ typeof children === "function" ? children({
127
+ ...dataAttributeProps,
128
+ id: inputId
129
+ }) : children
116
130
  ]
117
131
  })
118
132
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.2.9-rc.31",
3
+ "version": "2.2.9-rc.32",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",