@povio/ui 2.2.6 → 2.2.8-rc
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/README.md +2 -0
- package/dist/assets/icons/AlignCenter.js +3 -1
- package/dist/assets/icons/AlignLeft.js +3 -1
- package/dist/assets/icons/AlignLeftRight.js +3 -1
- package/dist/assets/icons/AlignRight.js +3 -1
- package/dist/assets/icons/ArrowDropDown.js +3 -1
- package/dist/assets/icons/ArrowDropUp.js +3 -1
- package/dist/assets/icons/ArrowLeft.js +3 -1
- package/dist/assets/icons/ArrowRight.js +3 -1
- package/dist/assets/icons/Bold.js +3 -1
- package/dist/assets/icons/BulletedList.js +3 -1
- package/dist/assets/icons/Calendar.js +3 -1
- package/dist/assets/icons/Check.js +3 -1
- package/dist/assets/icons/CheckCircle.js +3 -1
- package/dist/assets/icons/CheckboxCheckmark.js +3 -1
- package/dist/assets/icons/CheckboxIndeterminate.js +3 -1
- package/dist/assets/icons/ChevronDown.js +3 -1
- package/dist/assets/icons/ChevronLeft.js +3 -1
- package/dist/assets/icons/ChevronRight.js +3 -1
- package/dist/assets/icons/ChevronUp.js +3 -1
- package/dist/assets/icons/ChevronsLeft.js +3 -1
- package/dist/assets/icons/ChevronsRight.js +3 -1
- package/dist/assets/icons/Clock.js +3 -1
- package/dist/assets/icons/Close.js +3 -1
- package/dist/assets/icons/DateTime.js +3 -1
- package/dist/assets/icons/DragIndicator.js +3 -1
- package/dist/assets/icons/File.js +3 -1
- package/dist/assets/icons/Highlight.js +3 -1
- package/dist/assets/icons/HighlightOn.js +3 -1
- package/dist/assets/icons/Home.js +3 -1
- package/dist/assets/icons/Info.js +3 -1
- package/dist/assets/icons/Italic.js +3 -1
- package/dist/assets/icons/Link.js +3 -1
- package/dist/assets/icons/Menu.js +3 -1
- package/dist/assets/icons/NumberedList.js +3 -1
- package/dist/assets/icons/PointerHorizontal.js +3 -1
- package/dist/assets/icons/PointerVertical.js +3 -1
- package/dist/assets/icons/Search.js +3 -1
- package/dist/assets/icons/Send.js +3 -1
- package/dist/assets/icons/Strikethrough.js +3 -1
- package/dist/assets/icons/TextColor.js +3 -1
- package/dist/assets/icons/Today.js +3 -1
- package/dist/assets/icons/Underlined.js +3 -1
- package/dist/assets/icons/Upload.js +3 -1
- package/dist/assets/icons/Visibility.js +3 -1
- package/dist/assets/icons/VisibilityOff.js +3 -1
- package/dist/assets/icons/WarningFilled.js +3 -1
- package/dist/assets/locales/en/translation.json.js +1 -0
- package/dist/assets/locales/sl/translation.json.js +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.js +5 -3
- package/dist/components/Breadcrumbs/breadcrumbs.cva.js +7 -5
- package/dist/components/Menu/Menu.js +3 -1
- package/dist/components/Menu/MenuDesktop.js +3 -1
- package/dist/components/Menu/MenuItem.js +3 -1
- package/dist/components/Menu/MenuMobile.js +3 -1
- package/dist/components/Menu/MenuPopover.js +3 -1
- package/dist/components/Menu/menu.cva.js +6 -4
- package/dist/components/buttons/Button/Button.js +3 -1
- package/dist/components/buttons/Button/button.cva.js +7 -5
- package/dist/components/buttons/IconButton/IconButton.js +3 -1
- package/dist/components/buttons/InlineIconButton/InlineIconButton.js +3 -1
- package/dist/components/buttons/PillButton/PillButton.js +3 -1
- package/dist/components/buttons/PillButton/pillButton.cva.js +6 -4
- package/dist/components/buttons/SplitButton/SplitButton.js +3 -1
- package/dist/components/buttons/TextButton/TextButton.js +3 -1
- package/dist/components/buttons/ToggleButton/ToggleButton.js +3 -1
- package/dist/components/buttons/shared/ButtonContent.js +3 -1
- package/dist/components/buttons/shared/buttonContent.cva.js +2 -1
- package/dist/components/inputs/Checkbox/Checkbox.js +3 -1
- package/dist/components/inputs/Checkbox/CheckboxCheckmark.js +3 -1
- package/dist/components/inputs/Checkbox/checkbox.cva.js +6 -4
- package/dist/components/inputs/DateTime/DatePicker/DatePicker.js +63 -4
- package/dist/components/inputs/DateTime/DateRangePicker/DateRangePicker.js +98 -10
- package/dist/components/inputs/DateTime/DateTimePicker/DateTimePicker.js +63 -4
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.d.ts +1 -0
- package/dist/components/inputs/DateTime/TimePicker/TimePicker.js +64 -6
- package/dist/components/inputs/DateTime/shared/Calendar.js +3 -1
- package/dist/components/inputs/DateTime/shared/CalendarCell.js +3 -1
- package/dist/components/inputs/DateTime/shared/CalendarGrid.js +3 -1
- package/dist/components/inputs/DateTime/shared/CalendarHeader.js +3 -1
- package/dist/components/inputs/DateTime/shared/CalendarSelectHeader.js +4 -2
- package/dist/components/inputs/DateTime/shared/DateField.js +3 -1
- package/dist/components/inputs/DateTime/shared/DatePickerInput.js +3 -1
- package/dist/components/inputs/DateTime/shared/DateSegmentItem.js +4 -2
- package/dist/components/inputs/DateTime/shared/DateTimeDialog.js +3 -1
- package/dist/components/inputs/DateTime/shared/DateTimeDialogFooter.js +4 -2
- package/dist/components/inputs/DateTime/shared/MonthPicker.js +3 -1
- package/dist/components/inputs/DateTime/shared/RangeCalendar.js +3 -1
- package/dist/components/inputs/DateTime/shared/TimeField.js +3 -1
- package/dist/components/inputs/DateTime/shared/TimePickerForm.js +3 -1
- package/dist/components/inputs/DateTime/shared/TimePickerInput.d.ts +2 -1
- package/dist/components/inputs/DateTime/shared/TimePickerInput.js +6 -5
- package/dist/components/inputs/DateTime/shared/YearPicker.js +3 -1
- package/dist/components/inputs/File/FileUpload.js +6 -4
- package/dist/components/inputs/File/FileUploadContainer.js +3 -1
- package/dist/components/inputs/File/InputUpload.js +3 -1
- package/dist/components/inputs/File/shared/FileCard.js +3 -1
- package/dist/components/inputs/File/shared/FileCardList.js +3 -1
- package/dist/components/inputs/File/shared/FileUploadContent.js +3 -1
- package/dist/components/inputs/File/shared/FileUploadContentEmpty.js +3 -1
- package/dist/components/inputs/File/shared/FileUploadContentError.js +4 -2
- package/dist/components/inputs/File/shared/FileUploadContentFilled.js +4 -2
- package/dist/components/inputs/File/shared/FileUploadContentLoading.js +4 -2
- package/dist/components/inputs/File/shared/InputUploadContent.js +4 -2
- package/dist/components/inputs/File/shared/InputUploadFilled.js +3 -1
- package/dist/components/inputs/File/shared/ProgressBar.js +3 -1
- package/dist/components/inputs/File/shared/fileUpload.cva.js +4 -2
- package/dist/components/inputs/File/shared/inputUploadButton.cva.js +6 -3
- package/dist/components/inputs/FormField/FormField.js +3 -1
- package/dist/components/inputs/FormField/FormFieldError.js +3 -1
- package/dist/components/inputs/FormField/FormFieldHeader.js +3 -1
- package/dist/components/inputs/FormField/FormFieldHeaderClose.js +4 -2
- package/dist/components/inputs/FormField/FormFieldHelper.js +3 -1
- package/dist/components/inputs/FormField/FormFieldLabel.js +3 -1
- package/dist/components/inputs/FormField/formFieldError.cva.js +3 -1
- package/dist/components/inputs/FormField/formFieldHelper.cva.js +3 -1
- package/dist/components/inputs/Input/NumberInput/NumberInput.d.ts +1 -0
- package/dist/components/inputs/Input/NumberInput/NumberInput.js +82 -8
- package/dist/components/inputs/Input/PasswordInput/PasswordInput.js +4 -2
- package/dist/components/inputs/Input/TextArea/TextArea.js +3 -1
- package/dist/components/inputs/Input/TextInput/TextInput.d.ts +1 -0
- package/dist/components/inputs/Input/TextInput/TextInput.js +85 -8
- package/dist/components/inputs/Input/shared/InputContent.js +3 -1
- package/dist/components/inputs/Inputs/Form.js +2 -0
- package/dist/components/inputs/Inputs/InputItem.js +2 -0
- package/dist/components/inputs/Inputs/Inputs.js +2 -0
- package/dist/components/inputs/RadioGroup/RadioGroup.js +3 -1
- package/dist/components/inputs/RadioGroup/radio.cva.js +5 -3
- package/dist/components/inputs/Selection/Autocomplete/Autocomplete.js +64 -2
- package/dist/components/inputs/Selection/Autocomplete/QueryAutocomplete.js +3 -1
- package/dist/components/inputs/Selection/Select/Select.js +65 -2
- package/dist/components/inputs/Selection/shared/SelectBase.js +3 -1
- package/dist/components/inputs/Selection/shared/SelectDesktop.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectInput.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectInputTags.js +3 -1
- package/dist/components/inputs/Selection/shared/SelectListBox.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectListBoxItem.js +5 -3
- package/dist/components/inputs/Selection/shared/SelectListBoxItemSelectAll.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectListBoxLoadingItem.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectListBoxSelectionBar.js +4 -2
- package/dist/components/inputs/Selection/shared/SelectMobile.js +3 -1
- package/dist/components/inputs/Selection/shared/select.context.js +20 -18
- package/dist/components/inputs/Selection/shared/useSelectItems.js +6 -4
- package/dist/components/inputs/Slider/Slider.js +3 -1
- package/dist/components/inputs/TextEditor/TextEditor.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/ColorPicker.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/ColorPickerDropdown.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/HyperlinkAction.js +4 -2
- package/dist/components/inputs/TextEditor/Toolbar/TextAlignSelect.js +4 -2
- package/dist/components/inputs/TextEditor/Toolbar/TextColorSelect.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/TextEditorToolbar.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/TextHighlightSelect.js +3 -1
- package/dist/components/inputs/TextEditor/Toolbar/TextListActions.js +4 -2
- package/dist/components/inputs/TextEditor/Toolbar/TextMarksActions.js +4 -2
- package/dist/components/inputs/TextEditor/Toolbar/TextStyleSelect.js +4 -2
- package/dist/components/inputs/TextEditor/textEditor.types.js +3 -1
- package/dist/components/inputs/Toggle/Toggle.js +3 -1
- package/dist/components/inputs/Toggle/toggle.cva.js +4 -2
- package/dist/components/inputs/shared/CheckContent.js +3 -1
- package/dist/components/inputs/shared/InputClear.js +5 -3
- package/dist/components/inputs/shared/StaticInput.d.ts +18 -0
- package/dist/components/inputs/shared/StaticInput.js +69 -0
- package/dist/components/inputs/shared/TooltipWrapper.js +3 -1
- package/dist/components/inputs/shared/input.cva.js +6 -4
- package/dist/components/inputs/shared/label.cva.js +4 -2
- package/dist/components/navigation/Accordion/Accordion.js +3 -1
- package/dist/components/navigation/Accordion/AccordionItem.js +3 -1
- package/dist/components/navigation/Accordion/accordion.cva.js +12 -10
- package/dist/components/navigation/Stepper/Stepper.js +3 -1
- package/dist/components/navigation/Stepper/StepperItem.js +3 -1
- package/dist/components/navigation/Stepper/StepperSeparator.js +3 -1
- package/dist/components/navigation/Stepper/stepper.cva.js +9 -7
- package/dist/components/outline.clsx.js +4 -2
- package/dist/components/overlays/ActionModal/ActionModal.js +3 -1
- package/dist/components/overlays/BottomSheet/BottomSheet.js +3 -1
- package/dist/components/overlays/BottomSheet/BottomSheetHeader.js +4 -2
- package/dist/components/overlays/Drawer/Drawer.js +3 -1
- package/dist/components/overlays/Modal/Modal.js +4 -2
- package/dist/components/overlays/Modal/modal.cva.js +5 -3
- package/dist/components/overlays/ResponsivePopover/ResponsivePopover.js +3 -1
- package/dist/components/overlays/Tooltip/Tooltip.js +7 -2
- package/dist/components/overlays/Tooltip/TooltipEllipsis.js +3 -1
- package/dist/components/overlays/Tooltip/tooltip.cva.js +6 -4
- package/dist/components/segment/Segment.js +3 -1
- package/dist/components/segment/SegmentItem.js +3 -1
- package/dist/components/segment/segment.cva.js +4 -2
- package/dist/components/shared/pagination/Pagination.js +4 -2
- package/dist/components/shared/pagination/PaginationList.js +4 -2
- package/dist/components/shared/pagination/minWidth.cva.js +3 -1
- package/dist/components/shared/popover.cva.js +3 -1
- package/dist/components/status/Alert/Alert.js +3 -1
- package/dist/components/status/Alert/alert.cva.js +3 -1
- package/dist/components/status/Loader/Loader.js +3 -1
- package/dist/components/status/Loader/loader.cva.js +4 -2
- package/dist/components/status/Toast/Toast.js +15 -6
- package/dist/components/status/Toast/toast.cva.js +6 -20
- package/dist/components/status/Toast/useToast.js +3 -1
- package/dist/components/status/shared/status.cva.js +4 -2
- package/dist/components/table/CellText.js +3 -1
- package/dist/components/table/ColumnConfig.js +3 -1
- package/dist/components/table/HeaderText.js +3 -1
- package/dist/components/table/InfiniteTable.js +3 -1
- package/dist/components/table/PaginatedTable.js +3 -1
- package/dist/components/table/Table.js +4 -2
- package/dist/components/table/table.cva.js +8 -6
- package/dist/components/text/Link/Link.js +3 -1
- package/dist/components/text/Link/link.cva.js +3 -1
- package/dist/components/text/Tag/Tag.d.ts +3 -0
- package/dist/components/text/Tag/Tag.js +9 -4
- package/dist/components/text/Tag/tag.cva.js +3 -1
- package/dist/components/text/Typography/Typography.js +3 -1
- package/dist/components/text/Typography/typography.cva.js +3 -1
- package/dist/config/confirmation.context.js +4 -2
- package/dist/config/i18n.js +4 -2
- package/dist/config/link.context.js +3 -1
- package/dist/config/router.context.js +3 -1
- package/dist/config/theme.context.js +8 -6
- package/dist/config/uiConfig.context.d.ts +5 -0
- package/dist/config/uiConfig.context.js +10 -2
- package/dist/config/uiStyle.context.js +3 -1
- package/dist/helpers/dynamicColumns.js +4 -2
- package/dist/helpers/dynamicInputs.js +5 -3
- package/dist/hooks/useAutosave.js +2 -0
- package/dist/hooks/useBreakpoint.js +5 -3
- package/dist/hooks/useDebounceCallback.js +2 -0
- package/dist/hooks/useDeepCompare.js +5 -3
- package/dist/hooks/useFilters.js +3 -1
- package/dist/hooks/useForm.js +2 -0
- package/dist/hooks/useFormAutosave.js +2 -0
- package/dist/hooks/useIntersectionObserver.js +3 -1
- package/dist/hooks/useLocalStorage.js +3 -1
- package/dist/hooks/useLongPressRepeat.js +3 -1
- package/dist/hooks/usePagination.js +2 -0
- package/dist/hooks/useScrollableListBox.js +2 -0
- package/dist/hooks/useSorting.js +2 -0
- package/dist/hooks/useStateAndRef.js +3 -1
- package/dist/hooks/useTableColumnConfig.js +2 -0
- package/dist/hooks/useTableNav.js +124 -20
- package/dist/hooks/useTranslationMemo.js +2 -0
- package/dist/tw-ui-plugin.js +4 -2
- package/dist/utils/array.utils.js +3 -1
- package/dist/utils/compoundMapper.js +3 -1
- package/dist/utils/date-time.utils.d.ts +10 -0
- package/dist/utils/date-time.utils.js +85 -2
- package/dist/utils/date.utils.js +3 -1
- package/dist/utils/dom.utils.js +3 -1
- package/dist/utils/file.utils.js +3 -1
- package/dist/utils/isEqual.js +3 -1
- package/dist/utils/logger.js +3 -1
- package/dist/utils/object.utils.js +3 -1
- package/dist/utils/queries.utils.js +3 -1
- package/dist/utils/rest.utils.js +3 -1
- package/dist/utils/routing.utils.js +3 -1
- package/dist/utils/string.utils.js +3 -1
- package/dist/utils/zod.utils.js +3 -1
- package/package.json +2 -2
|
@@ -4,7 +4,8 @@ import { labelBase, labelTypography } from "../shared/label.cva.js";
|
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { clsx } from "clsx";
|
|
6
6
|
import { Label } from "react-aria-components";
|
|
7
|
-
|
|
7
|
+
//#region src/components/inputs/FormField/FormFieldLabel.tsx
|
|
8
|
+
var FormFieldLabel = ({ ref, as, label, isRequired, isDisabled, labelProps, className }) => {
|
|
8
9
|
const typographyCva = UIStyle.useCva("typography.cva", typography);
|
|
9
10
|
const labelTypographyMap = UIStyle.useMapper("label.typography", labelTypography);
|
|
10
11
|
const labelBaseCva = UIStyle.useCva("label.cva", labelBase);
|
|
@@ -23,4 +24,5 @@ const FormFieldLabel = ({ ref, as, label, isRequired, isDisabled, labelProps, cl
|
|
|
23
24
|
})]
|
|
24
25
|
});
|
|
25
26
|
};
|
|
27
|
+
//#endregion
|
|
26
28
|
export { FormFieldLabel };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { cva } from "class-variance-authority";
|
|
2
|
-
|
|
2
|
+
//#region src/components/inputs/FormField/formFieldError.cva.ts
|
|
3
|
+
var formFieldError = cva("text-label-3 text-text-error-1", {
|
|
3
4
|
variants: { visible: {
|
|
4
5
|
true: "mt-1-5",
|
|
5
6
|
false: "sr-only"
|
|
6
7
|
} },
|
|
7
8
|
defaultVariants: { visible: false }
|
|
8
9
|
});
|
|
10
|
+
//#endregion
|
|
9
11
|
export { formFieldError };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { cva } from "class-variance-authority";
|
|
2
|
-
|
|
2
|
+
//#region src/components/inputs/FormField/formFieldHelper.cva.ts
|
|
3
|
+
var formFieldHelper = cva("text-label-3 text-text-default-2", {
|
|
3
4
|
variants: { visible: {
|
|
4
5
|
true: "mt-1-5",
|
|
5
6
|
false: "sr-only"
|
|
6
7
|
} },
|
|
7
8
|
defaultVariants: { visible: false }
|
|
8
9
|
});
|
|
10
|
+
//#endregion
|
|
9
11
|
export { formFieldHelper };
|
|
@@ -13,6 +13,7 @@ interface NumberInputBaseProps extends FormFieldProps, InputVariantProps, Omit<I
|
|
|
13
13
|
value?: number | null;
|
|
14
14
|
onChange?: (value: number | null) => void;
|
|
15
15
|
onBlur?: (e: FocusEvent<HTMLInputElement>) => void;
|
|
16
|
+
autoFocusOnMount?: boolean;
|
|
16
17
|
}
|
|
17
18
|
export type NumberInputProps = NumberInputBaseProps;
|
|
18
19
|
export type ControlledNumberInputProps<TFieldValues extends FieldValues> = ControlProps<NumberInputProps, TFieldValues>;
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import { UIStyle } from "../../../../config/uiStyle.context.js";
|
|
2
|
+
import { Loader } from "../../../status/Loader/Loader.js";
|
|
2
3
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
4
|
import { inputBase } from "../../shared/input.cva.js";
|
|
4
5
|
import { FormField } from "../../FormField/FormField.js";
|
|
6
|
+
import { StaticInput } from "../../shared/StaticInput.js";
|
|
5
7
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
6
8
|
import { InputContent } from "../shared/InputContent.js";
|
|
7
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
10
|
import { clsx } from "clsx";
|
|
9
|
-
import { useCallback, useRef } from "react";
|
|
11
|
+
import { isValidElement, useCallback, useEffect, useRef, useState } from "react";
|
|
10
12
|
import { Input, useLocale } from "react-aria-components";
|
|
11
13
|
import { useFocusVisible, useNumberField } from "react-aria";
|
|
12
14
|
import { mergeRefs } from "@react-aria/utils";
|
|
13
|
-
import { Controller } from "react-hook-form";
|
|
15
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
14
16
|
import { useNumberFieldState } from "react-stately";
|
|
17
|
+
//#region src/components/inputs/Input/NumberInput/NumberInput.tsx
|
|
15
18
|
var NumberInputBase = (props) => {
|
|
16
19
|
const ui = UIConfig.useConfig();
|
|
17
20
|
const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
|
|
18
21
|
const inputRef = useRef(null);
|
|
19
|
-
const { ref, inputClassName, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, className, unit, isLoading, action, leadingIcon, trailingIcon, value, onChange, onBlur, formatOptions = ui.numberInput.formatOptions, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, hideLabel = ui.input.hideLabel, isClearable = ui.input.isClearable, ...rest } = props;
|
|
22
|
+
const { ref, inputClassName, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, className, unit, isLoading, action, leadingIcon, trailingIcon, value, onChange, onBlur, formatOptions = ui.numberInput.formatOptions, variant = ui.input.variant, as = ui.input.as, size = ui.input.size, hideLabel = ui.input.hideLabel, isClearable = ui.input.isClearable, autoFocusOnMount, ...rest } = props;
|
|
20
23
|
const numberFieldRef = useRef(null);
|
|
21
24
|
const { isFocusVisible } = useFocusVisible();
|
|
22
25
|
const { locale } = useLocale();
|
|
@@ -33,6 +36,10 @@ var NumberInputBase = (props) => {
|
|
|
33
36
|
formatOptions
|
|
34
37
|
};
|
|
35
38
|
const { labelProps, inputProps } = useNumberField(numberProps, useNumberFieldState(numberProps), numberFieldRef);
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
if (!autoFocusOnMount || isDisabled) return;
|
|
41
|
+
requestAnimationFrame(() => inputRef.current?.focus());
|
|
42
|
+
}, [autoFocusOnMount, isDisabled]);
|
|
36
43
|
const formFieldProps = {
|
|
37
44
|
error,
|
|
38
45
|
label,
|
|
@@ -112,7 +119,68 @@ var NumberInputBase = (props) => {
|
|
|
112
119
|
})
|
|
113
120
|
});
|
|
114
121
|
};
|
|
115
|
-
|
|
122
|
+
var renderIconVisual = (icon) => {
|
|
123
|
+
if (!icon) return null;
|
|
124
|
+
if (isValidElement(icon)) return icon;
|
|
125
|
+
return /* @__PURE__ */ jsx(icon, { className: "size-6 text-interactive-text-secondary-idle" });
|
|
126
|
+
};
|
|
127
|
+
var NumberInput = (props) => {
|
|
128
|
+
const ui = UIConfig.useConfig();
|
|
129
|
+
const [renderInput, setRenderInput] = useState(!ui.renderStaticInput);
|
|
130
|
+
const [shouldFocus, setShouldFocus] = useState(false);
|
|
131
|
+
const inputRef = useRef(null);
|
|
132
|
+
const watchedValue = "formControl" in props && props.formControl ? useWatch({
|
|
133
|
+
control: props.formControl.control,
|
|
134
|
+
name: props.formControl.name
|
|
135
|
+
}) : props.value;
|
|
136
|
+
let isFormControlDisabled = false;
|
|
137
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
138
|
+
useEffect(() => {
|
|
139
|
+
if (!renderInput || !shouldFocus) return;
|
|
140
|
+
requestAnimationFrame(() => inputRef.current?.focus());
|
|
141
|
+
setShouldFocus(false);
|
|
142
|
+
}, [renderInput, shouldFocus]);
|
|
143
|
+
if (!renderInput) {
|
|
144
|
+
const staticValue = watchedValue ?? props.value ?? props.defaultValue;
|
|
145
|
+
const displayValue = staticValue == null ? "" : `${staticValue}`;
|
|
146
|
+
const hasValue = displayValue !== "";
|
|
147
|
+
const as = props.as ?? ui.input.as;
|
|
148
|
+
const size = props.size ?? ui.input.size;
|
|
149
|
+
const variant = props.variant ?? ui.input.variant;
|
|
150
|
+
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
151
|
+
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
152
|
+
let isDisabled = !!props.isDisabled;
|
|
153
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
154
|
+
const trailingVisual = !!props.unit || !!props.isLoading || !!props.action && !props.isLoading || !!props.trailingIcon && !props.isLoading && !props.action ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
155
|
+
props.unit && /* @__PURE__ */ jsx("span", {
|
|
156
|
+
className: "text-label-2 text-text-default-3",
|
|
157
|
+
children: props.unit
|
|
158
|
+
}),
|
|
159
|
+
props.isLoading && /* @__PURE__ */ jsx(Loader, {}),
|
|
160
|
+
!props.isLoading && props.action && renderIconVisual(props.action.icon),
|
|
161
|
+
!props.isLoading && !props.action && props.trailingIcon && renderIconVisual(props.trailingIcon)
|
|
162
|
+
] }) : void 0;
|
|
163
|
+
return /* @__PURE__ */ jsx(StaticInput, {
|
|
164
|
+
...props,
|
|
165
|
+
onInteract: (focus) => {
|
|
166
|
+
setShouldFocus(focus);
|
|
167
|
+
setRenderInput(true);
|
|
168
|
+
},
|
|
169
|
+
as,
|
|
170
|
+
size,
|
|
171
|
+
variant,
|
|
172
|
+
hideLabel,
|
|
173
|
+
isHeaderHidden,
|
|
174
|
+
isDisabled,
|
|
175
|
+
className: clsx("group w-full", as === "inline" && "h-full", props.className),
|
|
176
|
+
inputClassName: props.inputClassName,
|
|
177
|
+
placeholder: as === "floating" ? "" : props.placeholder,
|
|
178
|
+
displayValue,
|
|
179
|
+
isEmpty: !hasValue,
|
|
180
|
+
leadingVisual: renderIconVisual(props.leadingIcon),
|
|
181
|
+
trailingVisual
|
|
182
|
+
});
|
|
183
|
+
}
|
|
116
184
|
if ("formControl" in props && props.formControl) {
|
|
117
185
|
const { formControl, ref, ...innerProps } = props;
|
|
118
186
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -120,16 +188,22 @@ const NumberInput = (props) => {
|
|
|
120
188
|
name: formControl.name,
|
|
121
189
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(NumberInputBase, {
|
|
122
190
|
...innerProps,
|
|
123
|
-
ref: mergeRefs(ref, field.ref),
|
|
191
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
124
192
|
value: field.value,
|
|
125
193
|
onChange: field.onChange,
|
|
126
194
|
onBlur: field.onBlur,
|
|
127
195
|
isDirty,
|
|
128
196
|
isDisabled: field.disabled || props.isDisabled,
|
|
129
|
-
error: props.error ?? error?.message
|
|
197
|
+
error: props.error ?? error?.message,
|
|
198
|
+
autoFocusOnMount: shouldFocus
|
|
130
199
|
}, field.value === null || field.value === void 0 ? "empty" : "filled")
|
|
131
200
|
});
|
|
132
201
|
}
|
|
133
|
-
return /* @__PURE__ */ jsx(NumberInputBase, {
|
|
202
|
+
return /* @__PURE__ */ jsx(NumberInputBase, {
|
|
203
|
+
...props,
|
|
204
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
205
|
+
autoFocusOnMount: shouldFocus
|
|
206
|
+
}, props.value === null || props.value === void 0 ? "empty" : "filled");
|
|
134
207
|
};
|
|
208
|
+
//#endregion
|
|
135
209
|
export { NumberInput };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { VisibilityIcon } from "../../../../assets/icons/Visibility.js";
|
|
2
2
|
import { VisibilityOffIcon } from "../../../../assets/icons/VisibilityOff.js";
|
|
3
|
-
import
|
|
3
|
+
import "../../../../config/i18n.js";
|
|
4
4
|
import { TextInput } from "../TextInput/TextInput.js";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { useState } from "react";
|
|
7
7
|
import { useTranslation } from "react-i18next";
|
|
8
|
-
|
|
8
|
+
//#region src/components/inputs/Input/PasswordInput/PasswordInput.tsx
|
|
9
|
+
var PasswordInput = (props) => {
|
|
9
10
|
const { t } = useTranslation("ui");
|
|
10
11
|
const [isRevealed, setIsRevealed] = useState(false);
|
|
11
12
|
return /* @__PURE__ */ jsx(TextInput, {
|
|
@@ -18,4 +19,5 @@ const PasswordInput = (props) => {
|
|
|
18
19
|
}
|
|
19
20
|
});
|
|
20
21
|
};
|
|
22
|
+
//#endregion
|
|
21
23
|
export { PasswordInput };
|
|
@@ -12,6 +12,7 @@ import { TextArea } from "react-aria-components";
|
|
|
12
12
|
import { useTextField } from "react-aria";
|
|
13
13
|
import { mergeRefs } from "@react-aria/utils";
|
|
14
14
|
import { Controller } from "react-hook-form";
|
|
15
|
+
//#region src/components/inputs/Input/TextArea/TextArea.tsx
|
|
15
16
|
var TextAreaBase = (props) => {
|
|
16
17
|
const ui = UIConfig.useConfig();
|
|
17
18
|
const inputCva = useInputCva();
|
|
@@ -105,7 +106,7 @@ var TextAreaBase = (props) => {
|
|
|
105
106
|
})
|
|
106
107
|
});
|
|
107
108
|
};
|
|
108
|
-
|
|
109
|
+
var TextArea$1 = (props) => {
|
|
109
110
|
if ("formControl" in props && props.formControl) {
|
|
110
111
|
const { formControl, ref, ...innerProps } = props;
|
|
111
112
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -125,4 +126,5 @@ const TextArea$1 = (props) => {
|
|
|
125
126
|
}
|
|
126
127
|
return /* @__PURE__ */ jsx(TextAreaBase, { ...props });
|
|
127
128
|
};
|
|
129
|
+
//#endregion
|
|
128
130
|
export { TextArea$1 as TextArea };
|
|
@@ -13,6 +13,7 @@ interface TextInputBaseProps extends FormFieldProps, InputVariantProps, Omit<Inp
|
|
|
13
13
|
type?: AllowedHTMLInputTypeAttribute;
|
|
14
14
|
todayIcon?: boolean;
|
|
15
15
|
isDirty?: boolean;
|
|
16
|
+
autoFocusOnMount?: boolean;
|
|
16
17
|
}
|
|
17
18
|
export interface TextInputProps extends TextInputBaseProps {
|
|
18
19
|
}
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import { UIStyle } from "../../../../config/uiStyle.context.js";
|
|
2
|
+
import { Loader } from "../../../status/Loader/Loader.js";
|
|
2
3
|
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
4
|
import { inputBase } from "../../shared/input.cva.js";
|
|
4
5
|
import { FormField } from "../../FormField/FormField.js";
|
|
6
|
+
import { StaticInput } from "../../shared/StaticInput.js";
|
|
5
7
|
import { TooltipWrapper } from "../../shared/TooltipWrapper.js";
|
|
6
8
|
import { InputContent } from "../shared/InputContent.js";
|
|
7
|
-
import { jsx } from "react/jsx-runtime";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
10
|
import { clsx } from "clsx";
|
|
9
|
-
import { useRef } from "react";
|
|
11
|
+
import { isValidElement, useEffect, useRef, useState } from "react";
|
|
10
12
|
import { Input } from "react-aria-components";
|
|
11
13
|
import { useFocusVisible, useTextField } from "react-aria";
|
|
12
14
|
import { mergeRefs } from "@react-aria/utils";
|
|
13
|
-
import { Controller } from "react-hook-form";
|
|
15
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
16
|
+
//#region src/components/inputs/Input/TextInput/TextInput.tsx
|
|
14
17
|
var TextInputBase = (props) => {
|
|
15
18
|
const ui = UIConfig.useConfig();
|
|
16
19
|
const inputBaseCva = UIStyle.useCva("input.baseCva", inputBase);
|
|
17
20
|
const inputRef = useRef(null);
|
|
18
|
-
const { ref, inputClassName, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, className, unit, isLoading, action, leadingIcon, trailingIcon, value, onChange, onBlur, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, ...rest } = props;
|
|
21
|
+
const { ref, inputClassName, label, tooltipText, helperText, isRequired, rightContent, isDisabled, isDirty, headerClassName, errorClassName, isHeaderHidden, error, className, unit, isLoading, action, leadingIcon, trailingIcon, value, onChange, onBlur, as = ui.input.as, hideLabel = ui.input.hideLabel, variant = ui.input.variant, size = ui.input.size, isClearable = ui.input.isClearable, autoFocusOnMount, ...rest } = props;
|
|
19
22
|
const textFieldRef = useRef(null);
|
|
20
23
|
const { isFocusVisible } = useFocusVisible();
|
|
21
24
|
const { labelProps, inputProps } = useTextField({
|
|
@@ -28,6 +31,10 @@ var TextInputBase = (props) => {
|
|
|
28
31
|
onChange,
|
|
29
32
|
onBlur
|
|
30
33
|
}, textFieldRef);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!autoFocusOnMount || isDisabled) return;
|
|
36
|
+
requestAnimationFrame(() => inputRef.current?.focus());
|
|
37
|
+
}, [autoFocusOnMount, isDisabled]);
|
|
31
38
|
const formFieldProps = {
|
|
32
39
|
error,
|
|
33
40
|
label,
|
|
@@ -105,7 +112,71 @@ var TextInputBase = (props) => {
|
|
|
105
112
|
})
|
|
106
113
|
});
|
|
107
114
|
};
|
|
108
|
-
|
|
115
|
+
var renderIconVisual = (icon) => {
|
|
116
|
+
if (!icon) return null;
|
|
117
|
+
if (isValidElement(icon)) return icon;
|
|
118
|
+
return /* @__PURE__ */ jsx(icon, { className: "size-6 text-interactive-text-secondary-idle" });
|
|
119
|
+
};
|
|
120
|
+
var TextInput = (props) => {
|
|
121
|
+
const ui = UIConfig.useConfig();
|
|
122
|
+
const [renderInput, setRenderInput] = useState(!ui.renderStaticInput);
|
|
123
|
+
const [shouldFocus, setShouldFocus] = useState(false);
|
|
124
|
+
const inputRef = useRef(null);
|
|
125
|
+
const watchedValue = "formControl" in props && props.formControl ? useWatch({
|
|
126
|
+
control: props.formControl.control,
|
|
127
|
+
name: props.formControl.name
|
|
128
|
+
}) : props.value;
|
|
129
|
+
let isFormControlDisabled = false;
|
|
130
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
131
|
+
const staticValue = watchedValue ?? props.value ?? props.defaultValue ?? "";
|
|
132
|
+
const inputType = props.type;
|
|
133
|
+
if (!renderInput && inputType === "password" && `${staticValue}`.length > 0) setRenderInput(true);
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
if (!renderInput || !shouldFocus) return;
|
|
136
|
+
requestAnimationFrame(() => inputRef.current?.focus());
|
|
137
|
+
setShouldFocus(false);
|
|
138
|
+
}, [renderInput, shouldFocus]);
|
|
139
|
+
if (!renderInput) {
|
|
140
|
+
const as = props.as ?? ui.input.as;
|
|
141
|
+
const size = props.size ?? ui.input.size;
|
|
142
|
+
const variant = props.variant ?? ui.input.variant;
|
|
143
|
+
const hideLabel = props.hideLabel ?? ui.input.hideLabel;
|
|
144
|
+
const isHeaderHidden = props.isHeaderHidden || as === "inline" || as === "filter" || as === "floating";
|
|
145
|
+
let isDisabled = !!props.isDisabled;
|
|
146
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
147
|
+
const maskedPasswordValue = inputType === "password" && `${staticValue}`.length > 0 ? "•".repeat(`${staticValue}`.length) : staticValue;
|
|
148
|
+
const displayValue = maskedPasswordValue == null ? "" : `${maskedPasswordValue}`;
|
|
149
|
+
const hasValue = displayValue !== "";
|
|
150
|
+
const trailingVisual = !!props.unit || !!props.isLoading || !!props.action && !props.isLoading || !!props.trailingIcon && !props.isLoading && !props.action ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
151
|
+
props.unit && /* @__PURE__ */ jsx("span", {
|
|
152
|
+
className: "text-label-2 text-text-default-3",
|
|
153
|
+
children: props.unit
|
|
154
|
+
}),
|
|
155
|
+
props.isLoading && /* @__PURE__ */ jsx(Loader, {}),
|
|
156
|
+
!props.isLoading && props.action && renderIconVisual(props.action.icon),
|
|
157
|
+
!props.isLoading && !props.action && props.trailingIcon && renderIconVisual(props.trailingIcon)
|
|
158
|
+
] }) : void 0;
|
|
159
|
+
return /* @__PURE__ */ jsx(StaticInput, {
|
|
160
|
+
...props,
|
|
161
|
+
onInteract: (focus) => {
|
|
162
|
+
setShouldFocus(focus);
|
|
163
|
+
setRenderInput(true);
|
|
164
|
+
},
|
|
165
|
+
as,
|
|
166
|
+
size,
|
|
167
|
+
variant,
|
|
168
|
+
hideLabel,
|
|
169
|
+
isHeaderHidden,
|
|
170
|
+
isDisabled,
|
|
171
|
+
className: clsx("group w-full", as === "inline" && "h-full", props.className),
|
|
172
|
+
inputClassName: props.inputClassName,
|
|
173
|
+
placeholder: as === "floating" ? "" : props.placeholder,
|
|
174
|
+
displayValue,
|
|
175
|
+
isEmpty: !hasValue,
|
|
176
|
+
leadingVisual: renderIconVisual(props.leadingIcon),
|
|
177
|
+
trailingVisual
|
|
178
|
+
});
|
|
179
|
+
}
|
|
109
180
|
if ("formControl" in props && props.formControl) {
|
|
110
181
|
const { formControl, ref, ...innerProps } = props;
|
|
111
182
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -113,16 +184,22 @@ const TextInput = (props) => {
|
|
|
113
184
|
name: formControl.name,
|
|
114
185
|
render: ({ field, fieldState: { error, isDirty } }) => /* @__PURE__ */ jsx(TextInputBase, {
|
|
115
186
|
...innerProps,
|
|
116
|
-
ref: mergeRefs(ref, field.ref),
|
|
187
|
+
ref: mergeRefs(ref, field.ref, inputRef),
|
|
117
188
|
value: field.value,
|
|
118
189
|
onChange: field.onChange,
|
|
119
190
|
onBlur: field.onBlur,
|
|
120
191
|
isDirty,
|
|
121
192
|
isDisabled: field.disabled || props.isDisabled,
|
|
122
|
-
error: props.error ?? error?.message
|
|
193
|
+
error: props.error ?? error?.message,
|
|
194
|
+
autoFocusOnMount: shouldFocus
|
|
123
195
|
})
|
|
124
196
|
});
|
|
125
197
|
}
|
|
126
|
-
return /* @__PURE__ */ jsx(TextInputBase, {
|
|
198
|
+
return /* @__PURE__ */ jsx(TextInputBase, {
|
|
199
|
+
...props,
|
|
200
|
+
ref: mergeRefs(props.ref, inputRef),
|
|
201
|
+
autoFocusOnMount: shouldFocus
|
|
202
|
+
});
|
|
127
203
|
};
|
|
204
|
+
//#endregion
|
|
128
205
|
export { TextInput };
|
|
@@ -8,7 +8,8 @@ import { inputSize } from "../../shared/input.cva.js";
|
|
|
8
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
9
|
import { clsx } from "clsx";
|
|
10
10
|
import { isValidElement } from "react";
|
|
11
|
-
|
|
11
|
+
//#region src/components/inputs/Input/shared/InputContent.tsx
|
|
12
|
+
var InputContent = ({ leadingIcon: LeadingIcon, trailingIcon: TrailingIcon, unit, isLoading, isDisabled, action, isClearable, value, onChange, onBlur, children, headerProps, as, size }) => {
|
|
12
13
|
const typographyCva = UIStyle.useCva("typography.cva", typography);
|
|
13
14
|
const inputSizeCva = UIStyle.useCva("input.sizeCva", inputSize);
|
|
14
15
|
const isLeadingIconElement = LeadingIcon && isValidElement(LeadingIcon);
|
|
@@ -72,4 +73,5 @@ const InputContent = ({ leadingIcon: LeadingIcon, trailingIcon: TrailingIcon, un
|
|
|
72
73
|
})]
|
|
73
74
|
});
|
|
74
75
|
};
|
|
76
|
+
//#endregion
|
|
75
77
|
export { InputContent };
|
|
@@ -5,6 +5,7 @@ import { getDefaultInputComponentType } from "../../../helpers/dynamicInputs.js"
|
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
import { useMemo } from "react";
|
|
7
7
|
import { z } from "zod";
|
|
8
|
+
//#region src/components/inputs/Inputs/Form.tsx
|
|
8
9
|
var createFieldComponent = (field, schemaKeyType, form) => {
|
|
9
10
|
return function FieldComponent({ inputType, label, placeholder, ...inputProps }) {
|
|
10
11
|
return /* @__PURE__ */ jsx(InputItem, {
|
|
@@ -39,4 +40,5 @@ function Form({ form, schema, onSubmit, onError, className, children }) {
|
|
|
39
40
|
children: children(components)
|
|
40
41
|
});
|
|
41
42
|
}
|
|
43
|
+
//#endregion
|
|
42
44
|
export { Form };
|
|
@@ -14,6 +14,7 @@ import { Slider } from "../Slider/Slider.js";
|
|
|
14
14
|
import { Toggle } from "../Toggle/Toggle.js";
|
|
15
15
|
import { Segment } from "../../segment/Segment.js";
|
|
16
16
|
import { jsx } from "react/jsx-runtime";
|
|
17
|
+
//#region src/components/inputs/Inputs/InputItem.tsx
|
|
17
18
|
var componentRegistry = {
|
|
18
19
|
toggle: Toggle,
|
|
19
20
|
checkbox: Checkbox,
|
|
@@ -51,4 +52,5 @@ function InputItem({ form, inputDef }) {
|
|
|
51
52
|
});
|
|
52
53
|
return inputWrapper ? inputWrapper(inputComponent, label) : inputComponent;
|
|
53
54
|
}
|
|
55
|
+
//#endregion
|
|
54
56
|
export { InputItem };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { InputItem } from "./InputItem.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
//#region src/components/inputs/Inputs/Inputs.tsx
|
|
3
4
|
function Inputs({ form, inputDefs, children }) {
|
|
4
5
|
if (!children) return inputDefs.map((inputDef) => /* @__PURE__ */ jsx(InputItem, {
|
|
5
6
|
form,
|
|
@@ -12,4 +13,5 @@ function Inputs({ form, inputDefs, children }) {
|
|
|
12
13
|
});
|
|
13
14
|
return children(childrenParams);
|
|
14
15
|
}
|
|
16
|
+
//#endregion
|
|
15
17
|
export { Inputs };
|
|
@@ -8,6 +8,7 @@ import { clsx } from "clsx";
|
|
|
8
8
|
import { Radio, RadioGroup } from "react-aria-components";
|
|
9
9
|
import { mergeRefs } from "@react-aria/utils";
|
|
10
10
|
import { Controller } from "react-hook-form";
|
|
11
|
+
//#region src/components/inputs/RadioGroup/RadioGroup.tsx
|
|
11
12
|
var RadioGroupBase = (props) => {
|
|
12
13
|
const ui = UIConfig.useConfig();
|
|
13
14
|
const radioCva = UIStyle.useCva("radio.cva", radio);
|
|
@@ -56,7 +57,7 @@ var RadioGroupBase = (props) => {
|
|
|
56
57
|
})
|
|
57
58
|
});
|
|
58
59
|
};
|
|
59
|
-
|
|
60
|
+
var RadioGroup$1 = (props) => {
|
|
60
61
|
if ("formControl" in props && props.formControl) {
|
|
61
62
|
const { formControl, ref, ...innerProps } = props;
|
|
62
63
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -77,4 +78,5 @@ const RadioGroup$1 = (props) => {
|
|
|
77
78
|
}
|
|
78
79
|
return /* @__PURE__ */ jsx(RadioGroupBase, { ...props });
|
|
79
80
|
};
|
|
81
|
+
//#endregion
|
|
80
82
|
export { RadioGroup$1 as RadioGroup };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { uiGroupOutlineClass } from "../../outline.clsx.js";
|
|
2
2
|
import { compoundMapper } from "../../../utils/compoundMapper.js";
|
|
3
3
|
import { cva } from "class-variance-authority";
|
|
4
|
-
|
|
4
|
+
//#region src/components/inputs/RadioGroup/radio.cva.ts
|
|
5
|
+
var radio = cva([
|
|
5
6
|
"flex items-center justify-center border-2",
|
|
6
7
|
"relative size-3-5 rounded-full p-1-5",
|
|
7
8
|
"before:absolute before:hidden before:size-1 before:rounded-full",
|
|
@@ -24,10 +25,11 @@ const radio = cva([
|
|
|
24
25
|
] } },
|
|
25
26
|
defaultVariants: { variant: "default" }
|
|
26
27
|
});
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
var radioIndicatorClass = "group flex items-center gap-2";
|
|
29
|
+
var radioTypography = compoundMapper({ default: {
|
|
29
30
|
size: "label-1",
|
|
30
31
|
sizeMobile: "label-1",
|
|
31
32
|
variant: "default"
|
|
32
33
|
} });
|
|
34
|
+
//#endregion
|
|
33
35
|
export { radio, radioIndicatorClass, radioTypography };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import { ArrowDropDownIcon } from "../../../../assets/icons/ArrowDropDown.js";
|
|
2
|
+
import { UIConfig } from "../../../../config/uiConfig.context.js";
|
|
3
|
+
import { StaticInput } from "../../shared/StaticInput.js";
|
|
1
4
|
import { SelectBase } from "../shared/SelectBase.js";
|
|
2
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
import { isValidElement, useEffect, useRef, useState } from "react";
|
|
3
7
|
import { mergeRefs } from "@react-aria/utils";
|
|
4
|
-
import { Controller } from "react-hook-form";
|
|
5
|
-
|
|
8
|
+
import { Controller, useWatch } from "react-hook-form";
|
|
9
|
+
//#region src/components/inputs/Selection/Autocomplete/Autocomplete.tsx
|
|
10
|
+
var _Autocomplete = (props) => {
|
|
6
11
|
if ("formControl" in props && props.formControl) {
|
|
7
12
|
const { formControl, ref, ...innerProps } = props;
|
|
8
13
|
return /* @__PURE__ */ jsx(Controller, {
|
|
@@ -25,4 +30,61 @@ const Autocomplete = (props) => {
|
|
|
25
30
|
isSearchable: true
|
|
26
31
|
});
|
|
27
32
|
};
|
|
33
|
+
var Autocomplete = (props) => {
|
|
34
|
+
const ui = UIConfig.useConfig();
|
|
35
|
+
const [renderInput, setRenderInput] = useState(!ui.renderStaticInput);
|
|
36
|
+
const [shouldFocus, setShouldFocus] = useState(false);
|
|
37
|
+
const rootRef = useRef(null);
|
|
38
|
+
const currentValue = ("formControl" in props && props.formControl ? useWatch({
|
|
39
|
+
control: props.formControl.control,
|
|
40
|
+
name: props.formControl.name
|
|
41
|
+
}) : props.value) ?? props.value;
|
|
42
|
+
let isFormControlDisabled = false;
|
|
43
|
+
if ("formControl" in props && props.formControl) isFormControlDisabled = !!props.formControl.control._options?.disabled;
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
if (!renderInput || !shouldFocus) return;
|
|
46
|
+
requestAnimationFrame(() => {
|
|
47
|
+
(rootRef.current?.querySelector("input, [data-type='select-trigger'], button, [tabindex]"))?.focus();
|
|
48
|
+
});
|
|
49
|
+
setShouldFocus(false);
|
|
50
|
+
}, [renderInput, shouldFocus]);
|
|
51
|
+
if (!renderInput) {
|
|
52
|
+
const getItemLabel = (id) => {
|
|
53
|
+
const item = props.items.find((innerItem) => innerItem.id === id);
|
|
54
|
+
if (!item) return "";
|
|
55
|
+
if (props.showSelectionContent && item.content) return isValidElement(item.content) ? item.label : item.content;
|
|
56
|
+
return item.label;
|
|
57
|
+
};
|
|
58
|
+
const mode = props.selectionMode ?? ui.select.selectionMode;
|
|
59
|
+
let displayValue = "";
|
|
60
|
+
if (mode === "multiple") {
|
|
61
|
+
if (Array.isArray(currentValue) && currentValue.length > 0) displayValue = currentValue.map((id) => getItemLabel(id)).filter(Boolean).join(", ");
|
|
62
|
+
} else if (currentValue != null) displayValue = getItemLabel(currentValue);
|
|
63
|
+
const as = props.as ?? ui.input.as;
|
|
64
|
+
let isDisabled = !!props.isDisabled;
|
|
65
|
+
if (isFormControlDisabled) isDisabled = true;
|
|
66
|
+
return /* @__PURE__ */ jsx(StaticInput, {
|
|
67
|
+
...props,
|
|
68
|
+
onInteract: (focus) => {
|
|
69
|
+
setShouldFocus(focus);
|
|
70
|
+
setRenderInput(true);
|
|
71
|
+
},
|
|
72
|
+
as,
|
|
73
|
+
size: props.size ?? ui.input.size,
|
|
74
|
+
variant: props.variant ?? ui.input.variant,
|
|
75
|
+
isHeaderHidden: props.isHeaderHidden || as === "inline",
|
|
76
|
+
hideLabel: props.hideLabel ?? ui.input.hideLabel,
|
|
77
|
+
isDisabled,
|
|
78
|
+
placeholder: as === "floating" ? "" : props.placeholder,
|
|
79
|
+
displayValue,
|
|
80
|
+
isEmpty: !displayValue,
|
|
81
|
+
trailingVisual: /* @__PURE__ */ jsx(ArrowDropDownIcon, { className: "size-6 shrink-0 text-interactive-text-secondary-idle" })
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return /* @__PURE__ */ jsx(_Autocomplete, {
|
|
85
|
+
...props,
|
|
86
|
+
ref: mergeRefs(props.ref, rootRef)
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
//#endregion
|
|
28
90
|
export { Autocomplete };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Autocomplete } from "./Autocomplete.js";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
-
|
|
4
|
+
//#region src/components/inputs/Selection/Autocomplete/QueryAutocomplete.tsx
|
|
5
|
+
var QueryAutocomplete = ({ query, queryParams, queryOptions, ...props }) => {
|
|
5
6
|
const [search, setSearch] = useState("");
|
|
6
7
|
const { data: items, isLoading } = query({
|
|
7
8
|
search,
|
|
@@ -15,4 +16,5 @@ const QueryAutocomplete = ({ query, queryParams, queryOptions, ...props }) => {
|
|
|
15
16
|
isLoading
|
|
16
17
|
});
|
|
17
18
|
};
|
|
19
|
+
//#endregion
|
|
18
20
|
export { QueryAutocomplete };
|