@povio/ui 2.2.9-rc.25 → 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.
- package/dist/components/buttons/Button/Button.d.ts +2 -1
- package/dist/components/buttons/Button/Button.js +41 -32
- package/dist/components/buttons/InlineIconButton/InlineIconButton.d.ts +1 -0
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +34 -29
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +33 -47
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.d.ts +2 -1
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +35 -29
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +29 -25
- package/dist/components/inputs/DateTime/shared/DateField.js +3 -10
- package/dist/components/inputs/DateTime/shared/DatePickerInput.d.ts +3 -2
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +51 -45
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.d.ts +14 -0
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +19 -6
- package/dist/components/inputs/DateTime/shared/datePicker.types.d.ts +1 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.d.ts +2 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.js +9 -0
- package/dist/components/inputs/DateTime/shared/dateSegment.utils.spec.d.ts +1 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.d.ts +35 -0
- package/dist/components/inputs/DateTime/shared/staticDateTimeSegments.js +76 -0
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +39 -40
- package/dist/components/inputs/Input/NumberRangeInput/NumberRangeInput.js +1 -1
- package/dist/components/inputs/Input/TextInput/TextInput.js +40 -40
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +24 -15
- package/dist/components/inputs/Selection/Select/QuerySelect.d.ts +3 -3
- package/dist/components/inputs/Selection/Select/QuerySelect.js +5 -34
- package/dist/components/inputs/Selection/Select/Select.js +27 -17
- package/dist/components/inputs/Skeleton/InputFrame.d.ts +54 -0
- package/dist/components/inputs/Skeleton/InputFrame.js +167 -0
- package/dist/components/inputs/shared/InputClear.d.ts +2 -1
- package/dist/components/inputs/shared/InputClear.js +13 -1
- package/dist/config/uiConfig.context.d.ts +1 -1
- package/dist/config/uiConfig.context.js +1 -0
- package/dist/index.js +1 -1
- package/dist/utils/date-time.utils.d.ts +7 -0
- package/dist/utils/date-time.utils.js +16 -0
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { GroupedSelectControlProps, GroupedSelectProps, SelectItem } from '../shared/select.types';
|
|
2
|
-
import {
|
|
1
|
+
import { DefaultInitialSelectItem, GroupedSelectControlProps, GroupedSelectProps, SelectItem } from '../shared/select.types';
|
|
2
|
+
import { SelectProps } from './Select';
|
|
3
3
|
import { QueryDataType, QueryFn } from '../shared/querySelect.utils';
|
|
4
4
|
import { OmitDiscriminatedUnion } from '../../../../types/common';
|
|
5
5
|
import { Key } from 'react-aria-components';
|
|
6
6
|
import { FieldValues } from 'react-hook-form';
|
|
7
|
-
export type QuerySelectProps<TFieldValues extends FieldValues, TQueryFn extends QueryFn, TKey extends Key = Key
|
|
7
|
+
export type QuerySelectProps<TFieldValues extends FieldValues, TQueryFn extends QueryFn, TKey extends Key = Key, TInitialSelectItem = DefaultInitialSelectItem<TKey>> = OmitDiscriminatedUnion<SelectProps<TKey, TInitialSelectItem>, "items" | "totalItems" | keyof GroupedSelectProps> & GroupedSelectControlProps<TFieldValues, TKey, TInitialSelectItem> & {
|
|
8
8
|
query: TQueryFn;
|
|
9
9
|
queryParams?: Parameters<TQueryFn>[0];
|
|
10
10
|
queryOptions?: Parameters<TQueryFn>[1];
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
2
|
-
import {
|
|
2
|
+
import { Select } from "./Select.js";
|
|
3
3
|
import { getQueryItems } from "../shared/querySelect.utils.js";
|
|
4
4
|
import { useQueryAutocomplete } from "../../../../hooks/useQueryAutocomplete.js";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
-
import { mergeRefs } from "@react-aria/utils";
|
|
7
|
-
import { Controller } from "react-hook-form";
|
|
8
6
|
//#region src/components/inputs/Selection/Select/QuerySelect.tsx
|
|
9
7
|
var QuerySelect = ({ query, queryParams, queryOptions, queryMap, ...props }) => {
|
|
10
8
|
const ui = UIConfig.useConfig();
|
|
@@ -15,41 +13,14 @@ var QuerySelect = ({ query, queryParams, queryOptions, queryMap, ...props }) =>
|
|
|
15
13
|
mapItems: (data) => getQueryItems(data, queryMap),
|
|
16
14
|
initialQueryState: props.isInitialQueryDisabled ?? ui.querySelect?.isInitialQueryDisabled
|
|
17
15
|
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
control: formControl.control,
|
|
22
|
-
name: formControl.name,
|
|
23
|
-
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(SelectBase, {
|
|
24
|
-
...innerProps,
|
|
25
|
-
ref: mergeRefs(ref, field.ref),
|
|
26
|
-
items,
|
|
27
|
-
isLoading,
|
|
28
|
-
totalItems,
|
|
29
|
-
hasLoadMore: hasNextPage,
|
|
30
|
-
onLoadMore: fetchNextPage,
|
|
31
|
-
value: field.value,
|
|
32
|
-
onChange: (value) => {
|
|
33
|
-
field.onChange(value);
|
|
34
|
-
field.onBlur?.();
|
|
35
|
-
},
|
|
36
|
-
onBlur: field.onBlur,
|
|
37
|
-
isDirty,
|
|
38
|
-
isDisabled: field.disabled || props.isDisabled,
|
|
39
|
-
error: props.error ?? error?.message,
|
|
40
|
-
onMouseEnter: handleEnableQuery,
|
|
41
|
-
onFocusCapture: handleEnableQuery
|
|
42
|
-
})
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
const { isInitialQueryDisabled: _, ...restProps } = props;
|
|
46
|
-
return /* @__PURE__ */ jsx(SelectBase, {
|
|
47
|
-
...restProps,
|
|
16
|
+
const { isInitialQueryDisabled: _, ...selectProps } = props;
|
|
17
|
+
return /* @__PURE__ */ jsx(Select, {
|
|
18
|
+
...selectProps,
|
|
48
19
|
items,
|
|
49
20
|
isLoading,
|
|
50
21
|
totalItems,
|
|
51
22
|
hasLoadMore: hasNextPage,
|
|
52
|
-
onLoadMore: fetchNextPage
|
|
23
|
+
onLoadMore: fetchNextPage,
|
|
53
24
|
onMouseEnter: handleEnableQuery,
|
|
54
25
|
onFocusCapture: handleEnableQuery
|
|
55
26
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ArrowDropDownIcon } from "../../../../assets/icons/ArrowDropDown.js";
|
|
2
2
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
|
-
import {
|
|
3
|
+
import { InputFrame } from "../../Skeleton/InputFrame.js";
|
|
4
4
|
import { SelectBase } from "../shared/SelectBase.js";
|
|
5
5
|
import { getStaticSelectValue } from "../shared/staticSelect.utils.js";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -67,25 +67,16 @@ function Select({ renderStaticInput, ...props }) {
|
|
|
67
67
|
selectedTagsType: props.selectedTagsType ?? ui.select.selectedTagsType
|
|
68
68
|
});
|
|
69
69
|
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
|
-
|
|
70
|
+
const placeholder = as === "floating" ? null : props.placeholder;
|
|
71
|
+
const shouldRenderPlaceholderAfterValue = mode !== "single" && props.placeholder && !isEmpty;
|
|
72
|
+
return /* @__PURE__ */ jsxs(InputFrame, {
|
|
71
73
|
...props,
|
|
72
|
-
onInteract: (focus) => {
|
|
73
|
-
setShouldFocus(focus);
|
|
74
|
-
setRenderInput(true);
|
|
75
|
-
},
|
|
76
|
-
as,
|
|
77
|
-
typographySize: "label-1",
|
|
78
|
-
size: props.size ?? ui.input.size,
|
|
79
|
-
variant: props.variant ?? ui.input.variant,
|
|
80
74
|
isHeaderHidden: props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating",
|
|
81
75
|
hideLabel: props.hideLabel ?? ui.input.hideLabel,
|
|
82
76
|
isDisabled,
|
|
83
77
|
className: clsx("w-full", props.containerClassName),
|
|
84
78
|
inputClassName: clsx(props.className, props.inputClassName),
|
|
85
|
-
|
|
86
|
-
showPlacholderIfFilled: mode !== "single",
|
|
87
|
-
displayValue,
|
|
88
|
-
isEmpty,
|
|
79
|
+
typographySize: "label-1",
|
|
89
80
|
dataAttributes: {
|
|
90
81
|
dataIsEmpty: isEmpty,
|
|
91
82
|
dataIsFilled: !isEmpty,
|
|
@@ -97,9 +88,28 @@ function Select({ renderStaticInput, ...props }) {
|
|
|
97
88
|
dataHasSelection: !isEmpty,
|
|
98
89
|
dataHasSearch: false
|
|
99
90
|
},
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
91
|
+
renderStatic: true,
|
|
92
|
+
onStaticInteract: (focus) => {
|
|
93
|
+
setShouldFocus(focus);
|
|
94
|
+
setRenderInput(true);
|
|
95
|
+
},
|
|
96
|
+
as,
|
|
97
|
+
size: props.size ?? ui.input.size,
|
|
98
|
+
variant: props.variant ?? ui.input.variant,
|
|
99
|
+
actionContent: props.leadingContent && /* @__PURE__ */ jsx("div", {
|
|
100
|
+
className: "ml-input-side-default flex shrink-0 items-center",
|
|
101
|
+
children: props.leadingContent
|
|
102
|
+
}),
|
|
103
|
+
isClearable,
|
|
104
|
+
showClear: false,
|
|
105
|
+
trailingContent,
|
|
106
|
+
children: [isEmpty ? /* @__PURE__ */ jsx("span", {
|
|
107
|
+
className: "text-text-default-3",
|
|
108
|
+
children: placeholder
|
|
109
|
+
}) : displayValue, shouldRenderPlaceholderAfterValue && /* @__PURE__ */ jsx("div", {
|
|
110
|
+
className: "shrink-0 text-text-default-3",
|
|
111
|
+
children: props.placeholder
|
|
112
|
+
})]
|
|
103
113
|
});
|
|
104
114
|
}
|
|
105
115
|
return /* @__PURE__ */ jsx(_Select, {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { FC, ReactElement, ReactNode, Ref, SVGProps } from 'react';
|
|
2
|
+
import { InlineIconButtonProps } from '../../buttons/InlineIconButton/InlineIconButton';
|
|
3
|
+
import { FormFieldProps } from '../FormField/FormField';
|
|
4
|
+
import { FormFieldHeaderProps } from '../FormField/FormFieldHeader';
|
|
5
|
+
import { InputVariantProps } from '../shared/input.cva';
|
|
6
|
+
import { TypographyVariantProps } from '../../text/Typography/typography.cva';
|
|
7
|
+
type InputFrameIcon = FC<SVGProps<SVGSVGElement>> | ReactElement;
|
|
8
|
+
interface InputFrameAction {
|
|
9
|
+
icon: InlineIconButtonProps["icon"];
|
|
10
|
+
onClick: () => void;
|
|
11
|
+
altText: string;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
interface InputFrameDataAttributes {
|
|
15
|
+
dataDisabled?: boolean;
|
|
16
|
+
dataHasSearch?: boolean;
|
|
17
|
+
dataHasSelection?: boolean;
|
|
18
|
+
dataInvalid?: boolean;
|
|
19
|
+
dataIsDirty?: boolean;
|
|
20
|
+
dataIsDisabled?: boolean;
|
|
21
|
+
dataIsEmpty?: boolean;
|
|
22
|
+
dataIsFilled?: boolean;
|
|
23
|
+
dataIsRequired?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface InputFrameProps extends InputVariantProps, Partial<FormFieldProps> {
|
|
26
|
+
ref?: Ref<HTMLDivElement>;
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
formFieldRef?: Ref<HTMLDivElement>;
|
|
29
|
+
labelProps?: FormFieldHeaderProps["labelProps"];
|
|
30
|
+
headerProps?: FormFieldHeaderProps;
|
|
31
|
+
leadingContent?: ReactNode;
|
|
32
|
+
leadingIcon?: InputFrameIcon;
|
|
33
|
+
actionContent?: ReactNode;
|
|
34
|
+
trailingContent?: ReactNode;
|
|
35
|
+
trailingIcon?: InputFrameIcon;
|
|
36
|
+
trailingAction?: ReactNode;
|
|
37
|
+
unit?: string;
|
|
38
|
+
isLoading?: boolean;
|
|
39
|
+
action?: InputFrameAction;
|
|
40
|
+
isClearable?: boolean;
|
|
41
|
+
showClear?: boolean;
|
|
42
|
+
renderStatic?: boolean;
|
|
43
|
+
onStaticInteract?: (shouldFocus: boolean) => void;
|
|
44
|
+
clearClassName?: string;
|
|
45
|
+
onClear?: () => void;
|
|
46
|
+
dataAttributes?: InputFrameDataAttributes;
|
|
47
|
+
typographySize?: TypographyVariantProps["size"];
|
|
48
|
+
inputClassName?: string;
|
|
49
|
+
contentClassName?: string;
|
|
50
|
+
contentWrapperClassName?: string;
|
|
51
|
+
trailingClassName?: string;
|
|
52
|
+
}
|
|
53
|
+
export declare const 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, }: InputFrameProps) => import("react/jsx-runtime").JSX.Element;
|
|
54
|
+
export {};
|
|
@@ -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",
|
|
@@ -34,7 +34,7 @@ export declare namespace UIConfig {
|
|
|
34
34
|
};
|
|
35
35
|
toggle: Pick<ToggleProps, "variant">;
|
|
36
36
|
slider: Pick<SliderProps, "minValue" | "maxValue">;
|
|
37
|
-
dateInput: Pick<DatePickerProps, "todayIcon" | "todayIconButtonSize" | "shouldForceLeadingZeros" | "disableManualEntry" | "autoFixYear"> & {
|
|
37
|
+
dateInput: Pick<DatePickerProps, "todayIcon" | "todayIconButtonSize" | "todayIconPlacement" | "shouldForceLeadingZeros" | "disableManualEntry" | "autoFixYear"> & {
|
|
38
38
|
calendarIcon?: ReactElement;
|
|
39
39
|
dateTimeIcon?: ReactElement;
|
|
40
40
|
timeIcon?: ReactElement;
|
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"));
|