@povio/ui 2.2.9-rc.15 → 2.2.9-rc.17
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.
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +3 -2
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +66 -4
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +95 -4
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +66 -4
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +57 -3
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +6 -5
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +3 -2
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.d.ts +6 -0
- package/dist/components/inputs/DateTime/shared/datePickerTodayIcon.js +20 -0
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +5 -2
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +80 -8
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +83 -8
- package/dist/components/inputs/Inputs/InputItem.d.ts +6 -6
- package/dist/components/inputs/RadioGroup/RadioGroup.js +15 -12
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.d.ts +3 -1
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +69 -3
- package/dist/components/inputs/Selection/Autocomplete/queryAutocomplete.types.d.ts +1 -10
- package/dist/components/inputs/Selection/Select/Select.d.ts +3 -1
- package/dist/components/inputs/Selection/Select/Select.js +69 -3
- package/dist/components/inputs/Selection/shared/SelectInput.js +3 -1
- package/dist/components/inputs/shared/StaticInput.d.ts +21 -0
- package/dist/components/inputs/shared/StaticInput.js +79 -0
- package/dist/components/inputs/shared/input.cva.d.ts +5 -0
- package/dist/components/inputs/shared/input.cva.js +10 -1
- package/dist/components/inputs/shared/tooltipWrapper.cva.js +1 -1
- package/dist/config/uiConfig.context.d.ts +5 -1
- package/dist/config/uiConfig.context.js +7 -0
- package/dist/config/uiStyle.context.d.ts +2 -1
- package/dist/utils/date-time.utils.d.ts +10 -0
- package/dist/utils/date-time.utils.js +82 -1
- package/package.json +1 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { UIStyle } from "../../../config/uiStyle.context.js";
|
|
2
|
+
import { FormFieldLabel } from "../FormField/FormFieldLabel.js";
|
|
3
|
+
import { inputBase, inputSize } from "./input.cva.js";
|
|
4
|
+
import { FormField } from "../FormField/FormField.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { clsx } from "clsx";
|
|
7
|
+
//#region src/components/inputs/shared/StaticInput.tsx
|
|
8
|
+
var StaticInput = ({ onInteract, as, size, variant, applyMinInputWidth, placeholder, displayValue, isEmpty, leadingVisual, leadingContent, trailingContent, contentRowClassName, inputClassName, className, ...formFieldProps }) => {
|
|
9
|
+
const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
|
|
10
|
+
const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
|
|
11
|
+
let hasValue = !!displayValue;
|
|
12
|
+
if (isEmpty != null) hasValue = !isEmpty;
|
|
13
|
+
let staticDisplayContent = placeholder;
|
|
14
|
+
if (hasValue) staticDisplayContent = displayValue;
|
|
15
|
+
else if (as === "floating") staticDisplayContent = null;
|
|
16
|
+
const shouldRenderFloatingLineSpacer = as === "floating" && !hasValue;
|
|
17
|
+
return /* @__PURE__ */ jsx(FormField, {
|
|
18
|
+
...formFieldProps,
|
|
19
|
+
as,
|
|
20
|
+
className,
|
|
21
|
+
onMouseEnter: () => onInteract(false),
|
|
22
|
+
tabIndex: as === "inline" ? -1 : void 0,
|
|
23
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
24
|
+
tabIndex: formFieldProps.isDisabled ? -1 : 0,
|
|
25
|
+
onFocus: () => onInteract(true),
|
|
26
|
+
onClick: () => onInteract(true),
|
|
27
|
+
onPointerDown: () => onInteract(true),
|
|
28
|
+
"data-is-empty": !hasValue || void 0,
|
|
29
|
+
"data-disabled": formFieldProps.isDisabled || void 0,
|
|
30
|
+
"data-is-disabled": formFieldProps.isDisabled || void 0,
|
|
31
|
+
"data-has-selection": hasValue || void 0,
|
|
32
|
+
"data-rac": "",
|
|
33
|
+
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({
|
|
34
|
+
as,
|
|
35
|
+
variant
|
|
36
|
+
}), inputClassName),
|
|
37
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
38
|
+
className: "flex w-full items-center gap-input-gap-input-text-to-elements",
|
|
39
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
40
|
+
className: clsx(inputSizeCva({
|
|
41
|
+
size,
|
|
42
|
+
as
|
|
43
|
+
}), "group/input-content flex w-full items-center gap-input-gap-input-text-to-elements pr-0!", as === "inline" && "h-full"),
|
|
44
|
+
children: [leadingVisual && /* @__PURE__ */ jsx("div", {
|
|
45
|
+
className: "pointer-events-none shrink-0",
|
|
46
|
+
children: leadingVisual
|
|
47
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
48
|
+
className: clsx("flex w-full truncate", as === "floating" && "flex-col", as === "filter" && "gap-input-gap-input-text-to-elements", contentRowClassName),
|
|
49
|
+
children: [
|
|
50
|
+
as && ["filter", "floating"].includes(as) && /* @__PURE__ */ jsx(FormFieldLabel, {
|
|
51
|
+
as,
|
|
52
|
+
size,
|
|
53
|
+
label: formFieldProps.label,
|
|
54
|
+
isRequired: formFieldProps.isRequired,
|
|
55
|
+
isDisabled: formFieldProps.isDisabled
|
|
56
|
+
}),
|
|
57
|
+
leadingContent && /* @__PURE__ */ jsx("div", {
|
|
58
|
+
className: "ml-input-side-default flex shrink-0 items-center",
|
|
59
|
+
children: leadingContent
|
|
60
|
+
}),
|
|
61
|
+
/* @__PURE__ */ jsxs("div", {
|
|
62
|
+
className: clsx("w-full truncate", !hasValue && "text-text-default-3"),
|
|
63
|
+
children: [staticDisplayContent, shouldRenderFloatingLineSpacer && /* @__PURE__ */ jsx(Fragment, { children: "\xA0" })]
|
|
64
|
+
})
|
|
65
|
+
]
|
|
66
|
+
})]
|
|
67
|
+
})
|
|
68
|
+
}), trailingContent && /* @__PURE__ */ jsx("div", {
|
|
69
|
+
className: clsx(inputSizeCva({
|
|
70
|
+
size,
|
|
71
|
+
as
|
|
72
|
+
}), "pointer-events-none flex items-center gap-input-gap-trailing-elements py-0! pl-0!"),
|
|
73
|
+
children: trailingContent
|
|
74
|
+
})]
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
//#endregion
|
|
79
|
+
export { StaticInput };
|
|
@@ -12,6 +12,11 @@ export declare const inputSize: (props?: ({
|
|
|
12
12
|
} & ClassProp) | undefined) => string;
|
|
13
13
|
export interface InputSizeProps extends VariantProps<typeof inputSize> {
|
|
14
14
|
}
|
|
15
|
+
export declare const inputClearClass: (props?: ({
|
|
16
|
+
as?: "filter" | "default" | "floating" | "inline" | null | undefined;
|
|
17
|
+
} & ClassProp) | undefined) => string;
|
|
18
|
+
export interface InputClearClassProps extends VariantProps<typeof inputClearClass> {
|
|
19
|
+
}
|
|
15
20
|
export declare const inputSide: (props?: ({
|
|
16
21
|
size?: "small" | "default" | "extra-small" | "large" | null | undefined;
|
|
17
22
|
type?: "left" | "right" | "var" | null | undefined;
|
|
@@ -191,6 +191,15 @@ var inputSize = cva("", {
|
|
|
191
191
|
as: "default"
|
|
192
192
|
}
|
|
193
193
|
});
|
|
194
|
+
var inputClearClass = cva("", {
|
|
195
|
+
variants: { as: {
|
|
196
|
+
default: "",
|
|
197
|
+
floating: "",
|
|
198
|
+
filter: "",
|
|
199
|
+
inline: ""
|
|
200
|
+
} },
|
|
201
|
+
defaultVariants: { as: "default" }
|
|
202
|
+
});
|
|
194
203
|
var inputSide = cva("", {
|
|
195
204
|
variants: {
|
|
196
205
|
size: {
|
|
@@ -277,4 +286,4 @@ var useInputCva = () => {
|
|
|
277
286
|
};
|
|
278
287
|
};
|
|
279
288
|
//#endregion
|
|
280
|
-
export { inputBase, inputSide, inputSize, useInputCva };
|
|
289
|
+
export { inputBase, inputClearClass, inputSide, inputSize, useInputCva };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PropsWithChildren } from 'react';
|
|
1
|
+
import { PropsWithChildren, ReactElement } from 'react';
|
|
2
2
|
import { ButtonProps } from '../components/buttons/Button/Button';
|
|
3
3
|
import { CheckboxProps } from '../components/inputs/Checkbox/Checkbox';
|
|
4
4
|
import { DatePickerProps } from '../components/inputs/DateTime/DatePicker/DatePicker';
|
|
@@ -19,6 +19,7 @@ export declare namespace UIConfig {
|
|
|
19
19
|
[P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : Exclude<T[P], null | undefined>;
|
|
20
20
|
};
|
|
21
21
|
export interface Options {
|
|
22
|
+
renderStaticInput: boolean;
|
|
22
23
|
input: Pick<TextInputProps, "variant" | "isClearable" | "hideLabel" | "as" | "size">;
|
|
23
24
|
button: Pick<ButtonProps, "variant" | "size">;
|
|
24
25
|
numberInput: Pick<NumberInputProps, "formatOptions">;
|
|
@@ -34,6 +35,9 @@ export declare namespace UIConfig {
|
|
|
34
35
|
toggle: Pick<ToggleProps, "variant">;
|
|
35
36
|
slider: Pick<SliderProps, "minValue" | "maxValue">;
|
|
36
37
|
dateInput: Pick<DatePickerProps, "todayIcon" | "todayIconButtonSize" | "shouldForceLeadingZeros" | "disableManualEntry" | "autoFixYear"> & {
|
|
38
|
+
calendarIcon?: ReactElement;
|
|
39
|
+
dateTimeIcon?: ReactElement;
|
|
40
|
+
timeIcon?: ReactElement;
|
|
37
41
|
setDateValueOnDateSelection?: boolean;
|
|
38
42
|
};
|
|
39
43
|
actionModal: Pick<ActionModalProps, "titleTypography" | "descriptionTypography">;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { CalendarIcon } from "../assets/icons/Calendar.js";
|
|
2
|
+
import { ClockIcon } from "../assets/icons/Clock.js";
|
|
3
|
+
import { DateTimeIcon } from "../assets/icons/DateTime.js";
|
|
1
4
|
import { ObjectUtils } from "../utils/object.utils.js";
|
|
2
5
|
import { useDeepCompareMemo } from "../hooks/useDeepCompare.js";
|
|
3
6
|
import { jsx } from "react/jsx-runtime";
|
|
@@ -6,6 +9,7 @@ import { createContext, use } from "react";
|
|
|
6
9
|
var UIConfig;
|
|
7
10
|
(function(_UIConfig) {
|
|
8
11
|
const DEFAULT_CONFIG = {
|
|
12
|
+
renderStaticInput: true,
|
|
9
13
|
input: {
|
|
10
14
|
variant: "outlined",
|
|
11
15
|
as: "default",
|
|
@@ -47,6 +51,9 @@ var UIConfig;
|
|
|
47
51
|
shouldForceLeadingZeros: false,
|
|
48
52
|
disableManualEntry: false,
|
|
49
53
|
autoFixYear: false,
|
|
54
|
+
calendarIcon: /* @__PURE__ */ jsx(CalendarIcon, { className: "size-5" }),
|
|
55
|
+
dateTimeIcon: /* @__PURE__ */ jsx(DateTimeIcon, { className: "size-5" }),
|
|
56
|
+
timeIcon: /* @__PURE__ */ jsx(ClockIcon, { className: "size-6 text-interactive-text-secondary-idle" }),
|
|
50
57
|
setDateValueOnDateSelection: false
|
|
51
58
|
},
|
|
52
59
|
actionModal: {
|
|
@@ -11,7 +11,7 @@ import { FormFieldHelperVariantProps } from '../components/inputs/FormField/form
|
|
|
11
11
|
import { RadioVariantProps } from '../components/inputs/RadioGroup/radio.cva';
|
|
12
12
|
import { SelectPopoverCva } from '../components/inputs/Selection/shared/selectDesktop.cva';
|
|
13
13
|
import { SelectListBoxItemCva } from '../components/inputs/Selection/shared/selectItem.cva';
|
|
14
|
-
import { InputBaseProps, InputSideProps, InputSizeProps } from '../components/inputs/shared/input.cva';
|
|
14
|
+
import { InputBaseProps, InputClearClassProps, InputSideProps, InputSizeProps } from '../components/inputs/shared/input.cva';
|
|
15
15
|
import { LabelBaseProps } from '../components/inputs/shared/label.cva';
|
|
16
16
|
import { TooltipWrapperTriggerVariantProps } from '../components/inputs/shared/tooltipWrapper.cva';
|
|
17
17
|
import { ToggleVariantProps } from '../components/inputs/Toggle/toggle.cva';
|
|
@@ -70,6 +70,7 @@ export declare namespace UIStyle {
|
|
|
70
70
|
};
|
|
71
71
|
input: {
|
|
72
72
|
baseCva?: Cva<InputBaseProps>;
|
|
73
|
+
clearClassCva?: Cva<InputClearClassProps>;
|
|
73
74
|
sizeCva?: Cva<InputSizeProps>;
|
|
74
75
|
sideCva?: Cva<InputSideProps>;
|
|
75
76
|
};
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { CalendarDate, CalendarDateTime, DateValue, ZonedDateTime } from '@internationalized/date';
|
|
2
2
|
export declare namespace DateTimeUtils {
|
|
3
|
+
function getDatePlaceholder(locale?: string): string;
|
|
4
|
+
function getTimePlaceholder(locale?: string): string;
|
|
5
|
+
function getDateTimePlaceholder(locale?: string): string;
|
|
6
|
+
function getDateRangePlaceholder(locale?: string): string;
|
|
7
|
+
function formatCalendarDateLocalized(calendarDate: CalendarDate, locale?: string): string;
|
|
8
|
+
function formatTimeLocalized(timeValue: {
|
|
9
|
+
hour: number;
|
|
10
|
+
minute: number;
|
|
11
|
+
}, locale?: string): string;
|
|
12
|
+
function formatCalendarDateTimeLocalized(calendarDateTime: Pick<CalendarDateTime, "day" | "month" | "year" | "hour" | "minute">, locale?: string): string;
|
|
3
13
|
function fromISOtoZonedDateTime(isoString: string): ZonedDateTime;
|
|
4
14
|
function fromDateValueToISO(dateValue: DateValue): string;
|
|
5
15
|
function fromLocalToZonedDateTime(date: Date): ZonedDateTime;
|
|
@@ -1,7 +1,88 @@
|
|
|
1
|
-
import { CalendarDate, CalendarDateTime, fromDate, getLocalTimeZone, parseAbsolute, parseAbsoluteToLocal } from "@internationalized/date";
|
|
1
|
+
import { CalendarDate, CalendarDateTime, DateFormatter, fromDate, getLocalTimeZone, parseAbsolute, parseAbsoluteToLocal } from "@internationalized/date";
|
|
2
2
|
//#region src/utils/date-time.utils.ts
|
|
3
3
|
var DateTimeUtils;
|
|
4
4
|
(function(_DateTimeUtils) {
|
|
5
|
+
const DATE_SAMPLE_DATE_UTC = new Date(Date.UTC(2e3, 10, 22));
|
|
6
|
+
const TIME_SAMPLE_DATE_UTC = new Date(Date.UTC(2e3, 10, 22, 13, 45));
|
|
7
|
+
const getDatePlaceholderFormatter = (locale) => new Intl.DateTimeFormat(locale, {
|
|
8
|
+
day: "2-digit",
|
|
9
|
+
month: "2-digit",
|
|
10
|
+
year: "numeric"
|
|
11
|
+
});
|
|
12
|
+
const getTimePlaceholderFormatter = (locale) => new Intl.DateTimeFormat(locale, {
|
|
13
|
+
hour: "2-digit",
|
|
14
|
+
minute: "2-digit",
|
|
15
|
+
hourCycle: "h23"
|
|
16
|
+
});
|
|
17
|
+
const getResolvedLocale = (locale) => {
|
|
18
|
+
if (locale) return locale;
|
|
19
|
+
return new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
20
|
+
};
|
|
21
|
+
const getDateFormatter = (locale) => new DateFormatter(getResolvedLocale(locale), {
|
|
22
|
+
day: "2-digit",
|
|
23
|
+
month: "2-digit",
|
|
24
|
+
year: "numeric",
|
|
25
|
+
timeZone: "UTC"
|
|
26
|
+
});
|
|
27
|
+
const getTimeFormatter = (locale) => new DateFormatter(getResolvedLocale(locale), {
|
|
28
|
+
hour: "2-digit",
|
|
29
|
+
minute: "2-digit",
|
|
30
|
+
hourCycle: "h23",
|
|
31
|
+
timeZone: "UTC"
|
|
32
|
+
});
|
|
33
|
+
const getDateTimeFormatter = (locale) => new DateFormatter(getResolvedLocale(locale), {
|
|
34
|
+
day: "2-digit",
|
|
35
|
+
month: "2-digit",
|
|
36
|
+
year: "numeric",
|
|
37
|
+
hour: "2-digit",
|
|
38
|
+
minute: "2-digit",
|
|
39
|
+
hourCycle: "h23",
|
|
40
|
+
timeZone: "UTC"
|
|
41
|
+
});
|
|
42
|
+
const mapTypeToPlaceholder = (type) => {
|
|
43
|
+
switch (type) {
|
|
44
|
+
case "day": return "dd";
|
|
45
|
+
case "month": return "mm";
|
|
46
|
+
case "year": return "yyyy";
|
|
47
|
+
case "hour": return "hh";
|
|
48
|
+
case "minute": return "mm";
|
|
49
|
+
default: return null;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const formatPlaceholder = (formatter, sampleDate) => {
|
|
53
|
+
return formatter.formatToParts(sampleDate).map((part) => mapTypeToPlaceholder(part.type) ?? part.value).join("");
|
|
54
|
+
};
|
|
55
|
+
function getDatePlaceholder(locale) {
|
|
56
|
+
return formatPlaceholder(getDatePlaceholderFormatter(locale), DATE_SAMPLE_DATE_UTC);
|
|
57
|
+
}
|
|
58
|
+
_DateTimeUtils.getDatePlaceholder = getDatePlaceholder;
|
|
59
|
+
function getTimePlaceholder(locale) {
|
|
60
|
+
return formatPlaceholder(getTimePlaceholderFormatter(locale), TIME_SAMPLE_DATE_UTC);
|
|
61
|
+
}
|
|
62
|
+
_DateTimeUtils.getTimePlaceholder = getTimePlaceholder;
|
|
63
|
+
function getDateTimePlaceholder(locale) {
|
|
64
|
+
return `${getDatePlaceholder(locale)}, ${getTimePlaceholder(locale)}`;
|
|
65
|
+
}
|
|
66
|
+
_DateTimeUtils.getDateTimePlaceholder = getDateTimePlaceholder;
|
|
67
|
+
function getDateRangePlaceholder(locale) {
|
|
68
|
+
const datePlaceholder = getDatePlaceholder(locale);
|
|
69
|
+
return `${datePlaceholder} – ${datePlaceholder}`;
|
|
70
|
+
}
|
|
71
|
+
_DateTimeUtils.getDateRangePlaceholder = getDateRangePlaceholder;
|
|
72
|
+
function formatCalendarDateLocalized(calendarDate, locale) {
|
|
73
|
+
return getDateFormatter(locale).format(calendarDate.toDate("UTC"));
|
|
74
|
+
}
|
|
75
|
+
_DateTimeUtils.formatCalendarDateLocalized = formatCalendarDateLocalized;
|
|
76
|
+
function formatTimeLocalized(timeValue, locale) {
|
|
77
|
+
const dateTime = new CalendarDateTime(2e3, 11, 22, timeValue.hour, timeValue.minute);
|
|
78
|
+
return getTimeFormatter(locale).format(dateTime.toDate("UTC"));
|
|
79
|
+
}
|
|
80
|
+
_DateTimeUtils.formatTimeLocalized = formatTimeLocalized;
|
|
81
|
+
function formatCalendarDateTimeLocalized(calendarDateTime, locale) {
|
|
82
|
+
const normalizedValue = new CalendarDateTime(calendarDateTime.year, calendarDateTime.month, calendarDateTime.day, calendarDateTime.hour, calendarDateTime.minute);
|
|
83
|
+
return getDateTimeFormatter(locale).format(normalizedValue.toDate("UTC"));
|
|
84
|
+
}
|
|
85
|
+
_DateTimeUtils.formatCalendarDateTimeLocalized = formatCalendarDateTimeLocalized;
|
|
5
86
|
function fromISOtoZonedDateTime(isoString) {
|
|
6
87
|
return parseAbsoluteToLocal(isoString);
|
|
7
88
|
}
|