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

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.
Files changed (24) hide show
  1. package/dist/components/buttons/Button/Button.d.ts +2 -1
  2. package/dist/components/buttons/Button/Button.js +41 -32
  3. package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +1 -0
  4. package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +32 -28
  5. package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +31 -46
  6. package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +33 -28
  7. package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +29 -25
  8. package/dist/components/inputs/DateTime/shared/DateSegmentItem.d.ts +14 -0
  9. package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +19 -6
  10. package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.d.ts +35 -0
  11. package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +76 -0
  12. package/dist/components/inputs/Input/NumberInput/NumberInput.js +39 -40
  13. package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +1 -1
  14. package/dist/components/inputs/Input/TextInput/TextInput.js +40 -40
  15. package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +24 -15
  16. package/dist/components/inputs/Selection/Select/Select.js +27 -17
  17. package/dist/components/inputs/Skeleton/InputFrame.d.ts +54 -0
  18. package/dist/components/inputs/Skeleton/InputFrame.js +167 -0
  19. package/dist/components/inputs/shared/InputClear.d.ts +2 -1
  20. package/dist/components/inputs/shared/InputClear.js +13 -1
  21. package/dist/index.js +1 -1
  22. package/dist/utils/date-time.utils.d.ts +7 -0
  23. package/dist/utils/date-time.utils.js +16 -0
  24. package/package.json +1 -1
@@ -0,0 +1,167 @@
1
+ import { UIStyle } from "../../../config/uiStyle.context.js";
2
+ import { typography } from "../../text/Typography/typography.cva.js";
3
+ import { Loader } from "../../status/Loader/Loader.js";
4
+ import { InlineIconButton } from "../../buttons/InlineIconButton/InlineIconButton.js";
5
+ import { FormFieldLabel } from "../FormField/FormFieldLabel.js";
6
+ import { InputClear } from "../shared/InputClear.js";
7
+ import { inputBase, inputContentWrapper, inputSize } from "../shared/input.cva.js";
8
+ import { FormField } from "../FormField/FormField.js";
9
+ import { TooltipWrapper } from "../shared/TooltipWrapper.js";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ import { clsx } from "clsx";
12
+ import { isValidElement } from "react";
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 }) => {
15
+ const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
16
+ const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
17
+ const inputContentWrapperCva = UIStyle.useCva("input.contentWrapperCva", inputContentWrapper);
18
+ const typographyCva = UIStyle.useCva("typography.cva", typography);
19
+ const hasClear = !!isClearable;
20
+ const isLeadingIconElement = leadingIcon && isValidElement(leadingIcon);
21
+ const isTrailingIconElement = trailingIcon && isValidElement(trailingIcon);
22
+ const hasTrailingContent = hasClear || !!trailingContent || !!unit || !!isLoading || !!action || !!trailingIcon || !!trailingAction;
23
+ const isTrailingInteractive = !!action || !!trailingAction || !!isTrailingIconElement || hasClear && !!showClear || !!trailingContent;
24
+ const dataAttributeProps = getInputFrameDataAttributeProps(dataAttributes);
25
+ const formFieldProps = {
26
+ error,
27
+ label: label ?? "",
28
+ tooltipText,
29
+ helperText,
30
+ isRequired,
31
+ rightContent,
32
+ isHeaderHidden: isHeaderHidden || as === "inline" || as === "filter" || as === "floating",
33
+ hideLabel,
34
+ isDisabled,
35
+ headerClassName,
36
+ errorClassName,
37
+ className
38
+ };
39
+ const resolvedHeaderProps = headerProps ?? {
40
+ label: label ?? "",
41
+ tooltipText,
42
+ helperText,
43
+ isRequired,
44
+ rightContent,
45
+ isHeaderHidden: hideLabel || isHeaderHidden,
46
+ isDisabled,
47
+ className: headerClassName,
48
+ labelProps
49
+ };
50
+ return /* @__PURE__ */ jsx(TooltipWrapper, {
51
+ as,
52
+ error,
53
+ triggerTabIndex: as === "inline" ? -1 : void 0,
54
+ children: /* @__PURE__ */ jsx(FormField, {
55
+ ...formFieldProps,
56
+ ...dataAttributeProps,
57
+ ref: formFieldRef,
58
+ as,
59
+ labelProps,
60
+ tabIndex: as === "inline" ? -1 : void 0,
61
+ onMouseEnter: () => {
62
+ if (renderStatic) onStaticInteract?.(false);
63
+ },
64
+ onFocusCapture: () => {
65
+ if (renderStatic) onStaticInteract?.(true);
66
+ },
67
+ children: /* @__PURE__ */ jsxs("div", {
68
+ ref,
69
+ ...dataAttributeProps,
70
+ className: clsx("relative flex cursor-text has-disabled:cursor-default", inputBaseCva({
71
+ variant,
72
+ as
73
+ }), inputClassName),
74
+ tabIndex: renderStatic ? isDisabled ? -1 : 0 : void 0,
75
+ onFocus: () => {
76
+ if (renderStatic) onStaticInteract?.(true);
77
+ },
78
+ onClick: () => {
79
+ if (renderStatic) onStaticInteract?.(true);
80
+ },
81
+ onPointerDown: () => {
82
+ if (renderStatic) onStaticInteract?.(true);
83
+ },
84
+ children: [/* @__PURE__ */ jsxs("div", {
85
+ 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({
86
+ size,
87
+ as
88
+ }), typographySize && typographyCva({ size: typographySize }), contentClassName),
89
+ children: [
90
+ leadingContent,
91
+ leadingIcon && /* @__PURE__ */ jsx("div", {
92
+ className: clsx(!isLeadingIconElement && "pointer-events-none"),
93
+ children: renderIconVisual(leadingIcon)
94
+ }),
95
+ /* @__PURE__ */ jsxs("div", {
96
+ className: clsx(inputContentWrapperCva({ as }), contentWrapperClassName),
97
+ children: [
98
+ as && ["filter", "floating"].includes(as) && /* @__PURE__ */ jsx(FormFieldLabel, {
99
+ as,
100
+ size,
101
+ ...resolvedHeaderProps
102
+ }),
103
+ actionContent,
104
+ children
105
+ ]
106
+ })
107
+ ]
108
+ }), hasTrailingContent && /* @__PURE__ */ jsxs("div", {
109
+ className: clsx("flex items-center gap-input-gap-trailing-elements py-0! pl-0!", inputSizeCva({
110
+ size,
111
+ as
112
+ }), !isTrailingInteractive && "pointer-events-none", trailingClassName),
113
+ children: [
114
+ hasClear && /* @__PURE__ */ jsx(InputClear, {
115
+ onClear: () => onClear?.(),
116
+ className: clearClassName,
117
+ show: !!showClear,
118
+ renderStatic
119
+ }),
120
+ trailingContent,
121
+ unit && /* @__PURE__ */ jsx("span", {
122
+ className: typographyCva({
123
+ size: "label-2",
124
+ sizeMobile: "label-2",
125
+ variant: "prominent-1",
126
+ className: "text-text-default-3"
127
+ }),
128
+ children: unit
129
+ }),
130
+ isLoading && /* @__PURE__ */ jsx("div", {
131
+ className: "inline-flex",
132
+ children: /* @__PURE__ */ jsx(Loader, {})
133
+ }),
134
+ !isLoading && action && /* @__PURE__ */ jsx(InlineIconButton, {
135
+ color: "secondary",
136
+ icon: action.icon,
137
+ isDisabled,
138
+ onPress: action.onClick,
139
+ excludeFromTabOrder: true,
140
+ label: action.altText,
141
+ className: clsx("border-0!", action.className)
142
+ }),
143
+ !isLoading && !action && trailingIcon && renderIconVisual(trailingIcon),
144
+ trailingAction
145
+ ]
146
+ })]
147
+ })
148
+ })
149
+ });
150
+ };
151
+ var renderIconVisual = (icon) => {
152
+ if (isValidElement(icon)) return icon;
153
+ return /* @__PURE__ */ jsx(icon, { className: "size-6 text-interactive-text-secondary-idle" });
154
+ };
155
+ var getInputFrameDataAttributeProps = (dataAttributes) => ({
156
+ "data-is-empty": dataAttributes?.dataIsEmpty || void 0,
157
+ "data-is-filled": dataAttributes?.dataIsFilled || void 0,
158
+ "data-is-dirty": dataAttributes?.dataIsDirty || void 0,
159
+ "data-is-required": dataAttributes?.dataIsRequired || void 0,
160
+ "data-is-disabled": dataAttributes?.dataIsDisabled || void 0,
161
+ "data-disabled": dataAttributes?.dataDisabled || void 0,
162
+ "data-has-search": dataAttributes?.dataHasSearch || void 0,
163
+ "data-invalid": dataAttributes?.dataInvalid || void 0,
164
+ "data-has-selection": dataAttributes?.dataHasSelection || void 0
165
+ });
166
+ //#endregion
167
+ export { InputFrame };
@@ -2,8 +2,9 @@ import { CSSProperties } from 'react';
2
2
  interface InputClearProps {
3
3
  onClear: () => void;
4
4
  show?: boolean;
5
+ renderStatic?: boolean;
5
6
  className?: string;
6
7
  style?: CSSProperties;
7
8
  }
8
- export declare const InputClear: ({ onClear, className, style, show }: InputClearProps) => import("react/jsx-runtime").JSX.Element;
9
+ export declare const InputClear: ({ onClear, className, style, show, renderStatic }: InputClearProps) => import("react/jsx-runtime").JSX.Element;
9
10
  export {};
@@ -5,7 +5,19 @@ import { jsx } from "react/jsx-runtime";
5
5
  import { clsx } from "clsx";
6
6
  import { useTranslation } from "react-i18next";
7
7
  //#region src/components/inputs/shared/InputClear.tsx
8
- var InputClear = ({ onClear, className, style, show }) => {
8
+ var InputClear = ({ onClear, className, style, show, renderStatic }) => {
9
+ if (renderStatic) return /* @__PURE__ */ jsx("div", {
10
+ className: clsx("size-6 shrink-0", className),
11
+ style
12
+ });
13
+ return /* @__PURE__ */ jsx(InputClearButton, {
14
+ onClear,
15
+ className,
16
+ style,
17
+ show
18
+ });
19
+ };
20
+ var InputClearButton = ({ onClear, className, style, show }) => {
9
21
  const { t } = useTranslation("ui");
10
22
  return /* @__PURE__ */ jsx(InlineIconButton, {
11
23
  color: "secondary",
package/dist/index.js CHANGED
@@ -67,9 +67,9 @@ import { ToggleButton } from "./components/buttons/ToggleButton/ToggleButton.js"
67
67
  import { Checkbox } from "./components/inputs/Checkbox/Checkbox.js";
68
68
  import { useLongPressRepeat } from "./hooks/useLongPressRepeat.js";
69
69
  import { useScrollableListBox } from "./hooks/useScrollableListBox.js";
70
+ import { DateTimeUtils } from "./utils/date-time.utils.js";
70
71
  import { FormField } from "./components/inputs/FormField/FormField.js";
71
72
  import { useDebounceCallback } from "./hooks/useDebounceCallback.js";
72
- import { DateTimeUtils } from "./utils/date-time.utils.js";
73
73
  import { DatePicker } from "./components/inputs/DateTime/DatePicker/DatePicker.js";
74
74
  import { Tag } from "./components/text/Tag/Tag.js";
75
75
  import { useIntersectionObserver } from "./hooks/useIntersectionObserver.js";
@@ -3,11 +3,18 @@ export declare namespace DateTimeUtils {
3
3
  interface LocalizedDateFormatOptions {
4
4
  shouldForceLeadingZeros?: boolean;
5
5
  }
6
+ export interface LocalizedDatePart {
7
+ type: Intl.DateTimeFormatPartTypes;
8
+ value: string;
9
+ placeholder: string;
10
+ isPlaceholder: boolean;
11
+ }
6
12
  export function getDatePlaceholder(locale?: string, options?: LocalizedDateFormatOptions): string;
7
13
  export function getTimePlaceholder(locale?: string): string;
8
14
  export function getDateTimePlaceholder(locale?: string, options?: LocalizedDateFormatOptions): string;
9
15
  export function getDateRangePlaceholder(locale?: string, options?: LocalizedDateFormatOptions): string;
10
16
  export function formatCalendarDateLocalized(calendarDate: CalendarDate, locale?: string, options?: LocalizedDateFormatOptions): string;
17
+ export function formatCalendarDatePartsLocalized(calendarDate?: CalendarDate | null, locale?: string, options?: LocalizedDateFormatOptions): LocalizedDatePart[];
11
18
  export function formatTimeLocalized(timeValue: {
12
19
  hour: number;
13
20
  minute: number;
@@ -67,6 +67,18 @@ var DateTimeUtils;
67
67
  return part.value;
68
68
  }).join(""));
69
69
  };
70
+ const formatLocalizedDatePartList = (formatter, date, isPlaceholder, options) => {
71
+ const locale = formatter.resolvedOptions().locale;
72
+ return formatter.formatToParts(date).map((part) => {
73
+ const value = options?.shouldForceLeadingZeros === false && (part.type === "day" || part.type === "month") ? removeLeadingZero(part.value) : part.value.replace(/\s+/gu, "");
74
+ return {
75
+ type: part.type,
76
+ value,
77
+ placeholder: mapTypeToPlaceholder(part.type, locale) ?? part.value.replace(/\s+/gu, ""),
78
+ isPlaceholder
79
+ };
80
+ });
81
+ };
70
82
  function getDatePlaceholder(locale, options) {
71
83
  return formatPlaceholder(getDatePlaceholderFormatter(locale, options), DATE_SAMPLE_DATE_UTC);
72
84
  }
@@ -88,6 +100,10 @@ var DateTimeUtils;
88
100
  return formatLocalizedDateParts(getDateFormatter(locale, options), calendarDate.toDate("UTC"), options);
89
101
  }
90
102
  _DateTimeUtils.formatCalendarDateLocalized = formatCalendarDateLocalized;
103
+ function formatCalendarDatePartsLocalized(calendarDate, locale, options) {
104
+ return formatLocalizedDatePartList(getDateFormatter(locale, options), calendarDate?.toDate("UTC") ?? DATE_SAMPLE_DATE_UTC, !calendarDate, options);
105
+ }
106
+ _DateTimeUtils.formatCalendarDatePartsLocalized = formatCalendarDatePartsLocalized;
91
107
  function formatTimeLocalized(timeValue, locale) {
92
108
  const dateTime = new CalendarDateTime(2e3, 11, 22, timeValue.hour, timeValue.minute);
93
109
  return getTimeFormatter(locale).format(dateTime.toDate("UTC"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@povio/ui",
3
- "version": "2.2.9-rc.26",
3
+ "version": "2.2.9-rc.27",
4
4
  "type": "module",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",