@uxf/ui 1.0.0-beta.138 → 1.0.0-beta.141
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/{file-input/_file-input-base.d.ts → _file-input-base/file-input-base.d.ts} +2 -2
- package/{file-input/_file-input-base.js → _file-input-base/file-input-base.js} +1 -1
- package/_file-input-base/index.d.ts +2 -0
- package/_file-input-base/index.js +5 -0
- package/_input-with-popover/index.d.ts +2 -0
- package/_input-with-popover/index.js +5 -0
- package/_input-with-popover/input-with-popover.d.ts +23 -0
- package/_input-with-popover/input-with-popover.js +81 -0
- package/_select-base/_select-base.d.ts +52 -0
- package/_select-base/_select-base.js +72 -0
- package/_select-base/index.d.ts +2 -0
- package/_select-base/index.js +5 -0
- package/avatar/avatar.js +1 -1
- package/avatar-file-input/avatar-file-input.d.ts +2 -2
- package/avatar-file-input/avatar-file-input.js +2 -2
- package/badge/badge.js +1 -1
- package/button/button.js +1 -1
- package/button-group/button-group.js +1 -0
- package/button-list/button-list.js +1 -0
- package/checkbox/checkbox.d.ts +1 -1
- package/checkbox/checkbox.js +2 -2
- package/checkbox/checkbox.stories.js +1 -1
- package/checkbox-button/checkbox-button.js +1 -1
- package/checkbox-input/checkbox-input.d.ts +1 -1
- package/checkbox-input/checkbox-input.js +1 -1
- package/chip/chip.js +1 -1
- package/color-radio/color-radio.js +1 -1
- package/color-radio-group/color-radio-group.js +1 -1
- package/combobox/combobox.d.ts +11 -17
- package/combobox/combobox.js +11 -38
- package/combobox/combobox.stories.d.ts +5 -2
- package/combobox/combobox.stories.js +5 -5
- package/context/provider.js +1 -0
- package/css/button.css +6 -3
- package/css/checkbox.css +4 -3
- package/css/input-with-popover.css +44 -0
- package/css/input.css +14 -10
- package/css/select-base.css +73 -0
- package/date-picker-input/date-picker-day.js +1 -1
- package/date-picker-input/date-picker-decade.js +1 -1
- package/date-picker-input/date-picker-input.d.ts +3 -18
- package/date-picker-input/date-picker-input.js +3 -81
- package/date-picker-input/date-picker-input.stories.js +1 -1
- package/date-picker-input/date-picker-month.js +1 -1
- package/date-picker-input/date-picker-provider.js +1 -0
- package/date-picker-input/date-picker-year.js +1 -1
- package/date-picker-input/date-picker.js +1 -0
- package/dropdown/dropdown.js +2 -2
- package/dropzone/dropzone-input.js +2 -2
- package/dropzone/dropzone-list.js +1 -0
- package/error-message/error-message.d.ts +3 -4
- package/error-message/error-message.js +3 -2
- package/error-message/error-message.stories.d.ts +2 -3
- package/file-input/file-input.d.ts +2 -2
- package/file-input/file-input.js +2 -2
- package/flash-messages/flash-message.js +1 -0
- package/flash-messages/flash-messages.d.ts +1 -1
- package/flash-messages/flash-messages.js +2 -2
- package/flash-messages/flash-messages.stories.d.ts +1 -1
- package/form-control/form-control.js +1 -1
- package/icon/icon.js +1 -1
- package/image-gallery/components/arrow-button.d.ts +3 -3
- package/image-gallery/components/arrow-button.js +5 -3
- package/image-gallery/components/close-button.d.ts +3 -3
- package/image-gallery/components/close-button.js +5 -3
- package/image-gallery/components/dot.d.ts +3 -3
- package/image-gallery/components/dot.js +5 -3
- package/image-gallery/components/gallery.d.ts +3 -3
- package/image-gallery/components/gallery.js +12 -13
- package/image-gallery/image-gallery.d.ts +3 -4
- package/image-gallery/image-gallery.js +7 -8
- package/image-gallery/image-gallery.stories.d.ts +4 -3
- package/image-gallery/image-gallery.stories.js +4 -5
- package/image-gallery/image.d.ts +2 -3
- package/image-gallery/image.js +5 -3
- package/image-gallery/index.d.ts +4 -2
- package/image-gallery/index.js +4 -8
- package/input/index.d.ts +4 -8
- package/input/input-element.js +26 -6
- package/input/input-left-addon.d.ts +3 -7
- package/input/input-left-addon.js +7 -4
- package/input/input-left-element.d.ts +3 -7
- package/input/input-left-element.js +7 -4
- package/input/input-remove-button.js +3 -1
- package/input/input-right-addon.d.ts +3 -7
- package/input/input-right-addon.js +7 -4
- package/input/input-right-element.d.ts +3 -7
- package/input/input-right-element.js +7 -4
- package/input/input.d.ts +9 -1
- package/input/input.js +15 -12
- package/input/input.stories.d.ts +4 -4
- package/label/label.js +1 -1
- package/layout/layout.js +1 -0
- package/list-item/list-item.js +1 -1
- package/loader/loader.js +1 -1
- package/modal/modal-dialog.js +1 -1
- package/modal/modal.d.ts +1 -1
- package/modal/modal.js +2 -2
- package/modal/modal.stories.d.ts +1 -1
- package/multi-combobox/_multi-combobox-base.d.ts +2 -2
- package/multi-combobox/_multi-combobox-base.js +2 -2
- package/multi-combobox/multi-combobox.js +1 -1
- package/multi-combobox/multi-combobox.stories.js +7 -7
- package/multi-select/_multi-select-base.d.ts +2 -2
- package/multi-select/_multi-select-base.js +1 -1
- package/multi-select/multi-select.js +1 -1
- package/multi-select/multi-select.stories.js +1 -1
- package/package.json +1 -1
- package/pagination/pagination.js +1 -0
- package/paper/paper.js +1 -1
- package/radio/radio.js +1 -1
- package/radio-group/radio-group.js +1 -1
- package/raster-image/raster-image.js +1 -0
- package/select/select.d.ts +14 -18
- package/select/select.js +14 -37
- package/select/select.stories.d.ts +5 -3
- package/select/select.stories.js +10 -10
- package/tabs/tabs.js +2 -1
- package/text-input/text-input.js +1 -1
- package/text-link/text-link.js +1 -1
- package/textarea/textarea.js +1 -1
- package/time-picker-input/time-picker-hour.js +1 -0
- package/time-picker-input/time-picker-hours.js +1 -0
- package/time-picker-input/time-picker-input.d.ts +3 -17
- package/time-picker-input/time-picker-input.js +11 -79
- package/time-picker-input/time-picker-minute.js +1 -0
- package/time-picker-input/time-picker-minutes.js +1 -0
- package/time-picker-input/time-picker.js +1 -0
- package/toggle/toggle.d.ts +2 -2
- package/toggle/toggle.js +1 -1
- package/tooltip/tooltip.js +1 -1
- package/css/combobox.css +0 -116
- package/css/date-picker-input.css +0 -135
- package/css/select.css +0 -86
- package/css/time-picker-input.css +0 -138
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FileResponse, FormControlProps } from "@uxf/ui/types";
|
|
2
2
|
import React from "react";
|
|
3
|
-
export interface
|
|
3
|
+
export interface FileInputBaseProps extends FormControlProps<FileResponse | null> {
|
|
4
4
|
"aria-describedby"?: string;
|
|
5
5
|
accept?: string;
|
|
6
6
|
className?: string;
|
|
@@ -9,4 +9,4 @@ export interface _FileInputBaseProps extends FormControlProps<FileResponse | nul
|
|
|
9
9
|
onUploadError?: (err: unknown) => void;
|
|
10
10
|
onUploadFile: (file: File) => Promise<FileResponse>;
|
|
11
11
|
}
|
|
12
|
-
export declare const _FileInputBase: React.ForwardRefExoticComponent<
|
|
12
|
+
export declare const _FileInputBase: React.ForwardRefExoticComponent<FileInputBaseProps & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports._FileInputBase = void 0;
|
|
7
7
|
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
|
-
exports._FileInputBase = (0, forwardRef_1.forwardRef)("
|
|
9
|
+
exports._FileInputBase = (0, forwardRef_1.forwardRef)("UxfUiFileInputBase", (props, ref) => {
|
|
10
10
|
const onChange = (e) => props.onChange(null, e);
|
|
11
11
|
return (react_1.default.createElement("input", { accept: props.accept, "aria-invalid": props.isInvalid, "aria-describedby": props["aria-describedby"], className: props.className, disabled: props.isDisabled, form: props.form, id: props.id, name: props.name, onBlur: props.onBlur, onChange: onChange, onFocus: props.onFocus, readOnly: props.isReadOnly, ref: ref, required: props.isRequired, tabIndex: props.isDisabled ? -1 : undefined, type: "file" }));
|
|
12
12
|
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._FileInputBase = void 0;
|
|
4
|
+
var file_input_base_1 = require("./file-input-base");
|
|
5
|
+
Object.defineProperty(exports, "_FileInputBase", { enumerable: true, get: function () { return file_input_base_1._FileInputBase; } });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._InputWithPopover = void 0;
|
|
4
|
+
var input_with_popover_1 = require("./input-with-popover");
|
|
5
|
+
Object.defineProperty(exports, "_InputWithPopover", { enumerable: true, get: function () { return input_with_popover_1._InputWithPopover; } });
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Clearable, FormControlProps } from "../types";
|
|
2
|
+
import { InputProps } from "../input";
|
|
3
|
+
import React, { MutableRefObject, ReactElement, ReactNode } from "react";
|
|
4
|
+
export interface InputWithPopoverProps<ValueType = string> extends FormControlProps<ValueType>, Pick<InputProps, "size" | "variant">, Clearable {
|
|
5
|
+
className?: string;
|
|
6
|
+
children: (args: {
|
|
7
|
+
close: (focusableElement?: HTMLElement | MutableRefObject<HTMLElement | null>) => void;
|
|
8
|
+
}) => ReactElement;
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
error?: ReactNode;
|
|
11
|
+
errorId?: string;
|
|
12
|
+
form?: string;
|
|
13
|
+
helperText?: ReactNode;
|
|
14
|
+
hiddenLabel?: boolean;
|
|
15
|
+
id?: string;
|
|
16
|
+
label?: ReactNode;
|
|
17
|
+
leftAddon?: ReactNode;
|
|
18
|
+
leftElement?: ReactNode;
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
rightAddon?: ReactNode;
|
|
21
|
+
rightElement?: ReactNode;
|
|
22
|
+
}
|
|
23
|
+
export declare const _InputWithPopover: React.ForwardRefExoticComponent<InputWithPopoverProps<string> & React.RefAttributes<HTMLInputElement>>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports._InputWithPopover = void 0;
|
|
27
|
+
const input_1 = require("../input");
|
|
28
|
+
const react_1 = __importStar(require("react"));
|
|
29
|
+
const useInputFocus_1 = require("@uxf/core/hooks/useInputFocus");
|
|
30
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
31
|
+
const classes_1 = require("@uxf/core/constants/classes");
|
|
32
|
+
const react_2 = require("@floating-ui/react");
|
|
33
|
+
const composeRefs_1 = require("@uxf/core/utils/composeRefs");
|
|
34
|
+
const form_control_1 = require("../form-control");
|
|
35
|
+
const react_3 = require("@headlessui/react");
|
|
36
|
+
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
37
|
+
exports._InputWithPopover = (0, forwardRef_1.forwardRef)("UxfUiInputWithPopover", (props, ref) => {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
const generatedId = (0, react_1.useId)();
|
|
40
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : generatedId;
|
|
41
|
+
const innerRef = (0, react_1.useRef)(null);
|
|
42
|
+
const input = (0, useInputFocus_1.useInputFocus)(innerRef, props.onBlur, props.onFocus);
|
|
43
|
+
const errorId = props.isInvalid ? `${id}--error-message` : undefined;
|
|
44
|
+
const rootClassName = (0, cx_1.cx)("uxf-iwp", ((_b = props.isFocused) !== null && _b !== void 0 ? _b : input.focused) && classes_1.CLASSES.IS_FOCUSED, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.isRequired && classes_1.CLASSES.IS_REQUIRED);
|
|
45
|
+
const floatingPopover = (0, react_2.useFloating)({
|
|
46
|
+
placement: "bottom",
|
|
47
|
+
middleware: [
|
|
48
|
+
(0, react_2.offset)(8),
|
|
49
|
+
(0, react_2.flip)(),
|
|
50
|
+
(0, react_2.shift)(),
|
|
51
|
+
(0, react_2.size)({
|
|
52
|
+
apply({ availableHeight, availableWidth, elements, strategy, x, y }) {
|
|
53
|
+
Object.assign(elements.floating.style, {
|
|
54
|
+
left: x + "px",
|
|
55
|
+
maxHeight: Math.max(50, availableHeight) + "px",
|
|
56
|
+
maxWidth: availableWidth,
|
|
57
|
+
position: strategy,
|
|
58
|
+
top: y + "px",
|
|
59
|
+
});
|
|
60
|
+
},
|
|
61
|
+
}),
|
|
62
|
+
],
|
|
63
|
+
whileElementsMounted: (reference, floating, update) => (0, react_2.autoUpdate)(reference, floating, update, {
|
|
64
|
+
elementResize: typeof ResizeObserver !== "undefined",
|
|
65
|
+
}),
|
|
66
|
+
});
|
|
67
|
+
const stableRef = (0, react_1.useMemo)(() => (0, composeRefs_1.composeRefs)(ref, floatingPopover.reference), [ref, floatingPopover.reference]);
|
|
68
|
+
const onChange = () => props.onChange;
|
|
69
|
+
return (react_1.default.createElement(form_control_1.FormControl, { className: rootClassName, errorId: errorId, form: props.form, helperText: props.helperText, hiddenLabel: props.hiddenLabel, inputId: id, isRequired: props.isRequired, label: props.label },
|
|
70
|
+
react_1.default.createElement(react_3.Popover, { className: "uxf-iwp__popover" },
|
|
71
|
+
react_1.default.createElement(react_3.Popover.Button, { as: input_1.Input, inputFocus: input, size: props.size, variant: props.variant, ref: stableRef },
|
|
72
|
+
props.leftAddon && react_1.default.createElement(input_1.Input.LeftAddon, null, props.leftAddon),
|
|
73
|
+
props.leftElement && react_1.default.createElement(input_1.Input.LeftElement, null, props.leftElement),
|
|
74
|
+
react_1.default.createElement(input_1.Input.Element, { "aria-describedby": errorId, "aria-errormessage": props.error && errorId ? `${errorId}__error-message` : undefined, "aria-invalid": !!props.error, "aria-live": "polite", autoComplete: "off", form: props.form, id: id, inputMode: "none", isDisabled: props.isDisabled, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, name: props.name, onChange: onChange, placeholder: props.placeholder, ref: (0, composeRefs_1.composeRefs)(innerRef, ref), value: props.value }),
|
|
75
|
+
react_1.default.createElement(input_1.Input.RightElement, null,
|
|
76
|
+
props.value && !props.isDisabled && !props.isReadOnly && props.isClearable && (react_1.default.createElement(input_1.Input.RemoveButton, { onChange: props.onChange })),
|
|
77
|
+
props.rightElement),
|
|
78
|
+
props.rightAddon && react_1.default.createElement(input_1.Input.RightAddon, null, props.rightAddon)),
|
|
79
|
+
!props.isDisabled && !props.isReadOnly && (react_1.default.createElement(react_3.Transition, { as: react_1.Fragment, enter: "uxf-iwp__popover-panel--enter", enterFrom: "uxf-iwp__popover-panel--enter-from", enterTo: "uxf-iwp__popover-panel--enter-to", leave: "uxf-iwp__popover-panel--leave", leaveFrom: "uxf-iwp__popover-panel--leave-from", leaveTo: "uxf-iwp__popover-panel--leave-to" },
|
|
80
|
+
react_1.default.createElement(react_3.Popover.Panel, { className: "uxf-iwp__popover-panel", ref: floatingPopover.floating, static: true }, props.children))))));
|
|
81
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Placement } from "@floating-ui/react";
|
|
2
|
+
import type { Combobox, Listbox } from "@headlessui/react";
|
|
3
|
+
import { IconsSet } from "@uxf/ui/icon/theme";
|
|
4
|
+
import { Clearable, FormControlProps } from "@uxf/ui/types";
|
|
5
|
+
import { ReactElement, ReactNode, Ref } from "react";
|
|
6
|
+
import { InputGroupSizes, InputGroupVariants } from "../input/theme";
|
|
7
|
+
export type SelectBaseValueId = number | string;
|
|
8
|
+
export type SelectBaseValue<ValueId = SelectBaseValueId> = {
|
|
9
|
+
id: ValueId;
|
|
10
|
+
label: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
export interface SelectBaseOption<ValueId = SelectBaseValueId> extends SelectBaseValue<ValueId> {
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
}
|
|
15
|
+
type SelectBaseTypeRef = HTMLDivElement;
|
|
16
|
+
export interface SelectBaseProps<Value, Option> extends FormControlProps<Value | null>, Clearable {
|
|
17
|
+
children: ReactElement;
|
|
18
|
+
className?: string;
|
|
19
|
+
customInputElementDisplayName: string;
|
|
20
|
+
dropdownPlacement?: Placement;
|
|
21
|
+
emptyMessage: string;
|
|
22
|
+
helperText?: ReactNode;
|
|
23
|
+
hiddenLabel?: boolean;
|
|
24
|
+
iconName?: keyof IconsSet;
|
|
25
|
+
id?: string;
|
|
26
|
+
keyExtractor?: (option: Option) => string | number;
|
|
27
|
+
label: ReactNode;
|
|
28
|
+
options?: Option[];
|
|
29
|
+
placeholder?: string;
|
|
30
|
+
renderOption?: (option: Option) => ReactNode;
|
|
31
|
+
variant?: keyof InputGroupVariants;
|
|
32
|
+
size?: keyof InputGroupSizes;
|
|
33
|
+
leftAddon?: ReactNode;
|
|
34
|
+
leftElement?: ReactNode;
|
|
35
|
+
rightAddon?: ReactNode;
|
|
36
|
+
rightElement?: ReactNode;
|
|
37
|
+
forwardRef?: Ref<SelectBaseTypeRef> | undefined;
|
|
38
|
+
}
|
|
39
|
+
type Props<ValueId = SelectBaseValue, Value = ValueId, Option = SelectBaseOption<ValueId>> = SelectBaseProps<Value, Option> & ({
|
|
40
|
+
HUIComponent: typeof Combobox;
|
|
41
|
+
onChange?(value: Value | null): void;
|
|
42
|
+
value: Value | null;
|
|
43
|
+
} | {
|
|
44
|
+
HUIComponent: typeof Listbox;
|
|
45
|
+
onChange?(value: Value | null): void;
|
|
46
|
+
value: ValueId | null;
|
|
47
|
+
});
|
|
48
|
+
export declare const _SelectBase: {
|
|
49
|
+
<ValueId = SelectBaseValue<SelectBaseValueId>, Value = ValueId, Option = SelectBaseOption<ValueId>>(props: Props<ValueId, Value, Option>): JSX.Element;
|
|
50
|
+
displayName: string;
|
|
51
|
+
};
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports._SelectBase = void 0;
|
|
27
|
+
const classes_1 = require("@uxf/core/constants/classes");
|
|
28
|
+
const useInputFocus_1 = require("@uxf/core/hooks/useInputFocus");
|
|
29
|
+
const composeRefs_1 = require("@uxf/core/utils/composeRefs");
|
|
30
|
+
const cx_1 = require("@uxf/core/utils/cx");
|
|
31
|
+
const use_dropdown_1 = require("@uxf/ui/hooks/use-dropdown");
|
|
32
|
+
const icon_1 = require("@uxf/ui/icon");
|
|
33
|
+
const input_1 = require("@uxf/ui/input");
|
|
34
|
+
const label_1 = require("@uxf/ui/label");
|
|
35
|
+
const react_1 = __importStar(require("react"));
|
|
36
|
+
const Options = (props) => {
|
|
37
|
+
const Component = props.component;
|
|
38
|
+
return (react_1.default.createElement(Component.Options, { className: (0, cx_1.cx)("uxf-dropdown", props.placement === "bottom" && "uxf-dropdown--bottom", props.placement === "top" && "uxf-dropdown--top"), ref: props.forwardRef }, props.options && props.options.length > 0 ? (props.options.map((option) => {
|
|
39
|
+
var _a;
|
|
40
|
+
const optionKey = (_a = props.keyExtractor) === null || _a === void 0 ? void 0 : _a.call(props, option);
|
|
41
|
+
return (react_1.default.createElement(Component.Option, { className: (optionState) => (0, cx_1.cx)("uxf-dropdown__item", optionState.active && classes_1.CLASSES.IS_ACTIVE, optionState.disabled && classes_1.CLASSES.IS_DISABLED, optionState.selected && classes_1.CLASSES.IS_SELECTED), key: optionKey !== null && optionKey !== void 0 ? optionKey : option.id, value: option }, optionKey !== null && optionKey !== void 0 ? optionKey : option.label));
|
|
42
|
+
})) : (react_1.default.createElement("div", { className: "uxf-dropdown__empty-wrapper" }, props.emptyMessage))));
|
|
43
|
+
};
|
|
44
|
+
Options.displayName = "UxfUiSelectBaseOptions";
|
|
45
|
+
const _SelectBase = (props) => {
|
|
46
|
+
var _a, _b, _c;
|
|
47
|
+
const generatedId = (0, react_1.useId)();
|
|
48
|
+
const id = (_a = props.id) !== null && _a !== void 0 ? _a : generatedId;
|
|
49
|
+
const innerRef = (0, react_1.useRef)(null);
|
|
50
|
+
const errorId = props.isInvalid ? `${id}--error-message` : undefined;
|
|
51
|
+
const input = (0, useInputFocus_1.useInputFocus)(innerRef, props.onBlur, props.onFocus);
|
|
52
|
+
const dropdown = (0, use_dropdown_1.useDropdown)((_b = props.dropdownPlacement) !== null && _b !== void 0 ? _b : "bottom", true);
|
|
53
|
+
const stableRef = (0, react_1.useMemo)(() => (0, composeRefs_1.composeRefs)(dropdown.reference), [dropdown.reference]);
|
|
54
|
+
const iconName = (_c = props.iconName) !== null && _c !== void 0 ? _c : "chevronDown";
|
|
55
|
+
const Component = props.HUIComponent;
|
|
56
|
+
return (react_1.default.createElement(Component, { as: "div", className: (0, cx_1.cx)("uxf-form-control uxf-sb", props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isRequired && classes_1.CLASSES.IS_REQUIRED, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.className), disabled: props.isDisabled || props.isReadOnly, onChange: props.onChange, value: props.value }, (renderProps) => (react_1.default.createElement(react_1.default.Fragment, null,
|
|
57
|
+
react_1.default.createElement("div", { className: "uxf-form-control__label" },
|
|
58
|
+
react_1.default.createElement(Component.Label, { as: label_1.Label, isHidden: props.hiddenLabel, onClick: props.isDisabled || props.isReadOnly ? undefined : input.focus }, props.label)),
|
|
59
|
+
react_1.default.createElement("div", { className: "uxf-form-control__input" },
|
|
60
|
+
react_1.default.createElement(Component.Button, { "aria-invalid": props.isInvalid, "aria-describedby": errorId, as: input_1.Input, className: (0, cx_1.cx)("uxf-sb__button", dropdown.placement === "bottom" && `${classes_1.CLASSES.IS_OPEN}--bottom`, dropdown.placement === "top" && `${classes_1.CLASSES.IS_OPEN}--top`, renderProps.open && classes_1.CLASSES.IS_OPEN), customInputElementDisplayName: props.customInputElementDisplayName, inputFocus: input, isDisabled: props.isDisabled, isFocused: renderProps.open, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, ref: (0, composeRefs_1.composeRefs)(innerRef, props.forwardRef), size: props.size, variant: props.variant, wrapperRef: stableRef },
|
|
61
|
+
props.leftAddon && react_1.default.createElement(input_1.Input.LeftAddon, null, props.leftAddon),
|
|
62
|
+
props.leftElement && react_1.default.createElement(input_1.Input.LeftElement, null, props.leftElement),
|
|
63
|
+
props.children,
|
|
64
|
+
react_1.default.createElement(input_1.Input.RightElement, null,
|
|
65
|
+
props.value && !props.isDisabled && !props.isReadOnly && props.isClearable && (react_1.default.createElement(input_1.Input.RemoveButton, { onChange: props.onChange })),
|
|
66
|
+
react_1.default.createElement(icon_1.Icon, { className: (0, cx_1.cx)("uxf-sb__button-icon", renderProps.open && classes_1.CLASSES.IS_OPEN), name: iconName })),
|
|
67
|
+
props.rightAddon && react_1.default.createElement(input_1.Input.RightAddon, null, props.rightAddon)),
|
|
68
|
+
react_1.default.createElement(Options, { component: Component, emptyMessage: props.emptyMessage, forwardRef: dropdown.floating, keyExtractor: props.keyExtractor, options: props.options, placement: dropdown.placement }),
|
|
69
|
+
props.helperText && (react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-helper-text", props.isInvalid && classes_1.CLASSES.IS_INVALID), id: errorId }, props.helperText)))))));
|
|
70
|
+
};
|
|
71
|
+
exports._SelectBase = _SelectBase;
|
|
72
|
+
exports._SelectBase.displayName = "UxfUiSelectBase";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._SelectBase = void 0;
|
|
4
|
+
var _select_base_1 = require("./_select-base");
|
|
5
|
+
Object.defineProperty(exports, "_SelectBase", { enumerable: true, get: function () { return _select_base_1._SelectBase; } });
|
package/avatar/avatar.js
CHANGED
|
@@ -8,7 +8,7 @@ const cx_1 = require("@uxf/core/utils/cx");
|
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
10
10
|
const icon_1 = require("../icon");
|
|
11
|
-
exports.Avatar = (0, forwardRef_1.forwardRef)("
|
|
11
|
+
exports.Avatar = (0, forwardRef_1.forwardRef)("UxfUiAvatar", (props, ref) => {
|
|
12
12
|
const avatarClassName = (0, cx_1.cx)("uxf-avatar", props.className);
|
|
13
13
|
return (react_1.default.createElement("div", { ref: ref, className: avatarClassName }, props.src ? react_1.default.createElement("img", { alt: "", className: "uxf-avatar__image", src: props.src }) : react_1.default.createElement(icon_1.Icon, { name: "user", size: 16 })));
|
|
14
14
|
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
|
-
import {
|
|
3
|
-
export interface AvatarFileInputProps extends
|
|
2
|
+
import { FileInputBaseProps } from "../_file-input-base";
|
|
3
|
+
export interface AvatarFileInputProps extends FileInputBaseProps {
|
|
4
4
|
helperText?: ReactNode;
|
|
5
5
|
label?: ReactNode;
|
|
6
6
|
}
|
|
@@ -29,9 +29,9 @@ const useInputFocus_1 = require("@uxf/core/hooks/useInputFocus");
|
|
|
29
29
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
30
30
|
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
31
31
|
const react_1 = __importStar(require("react"));
|
|
32
|
-
const _file_input_base_1 = require("../
|
|
32
|
+
const _file_input_base_1 = require("../_file-input-base");
|
|
33
33
|
const icon_1 = require("../icon");
|
|
34
|
-
exports.AvatarFileInput = (0, forwardRef_1.forwardRef)("
|
|
34
|
+
exports.AvatarFileInput = (0, forwardRef_1.forwardRef)("UxfUiAvatarFileInput", (props, ref) => {
|
|
35
35
|
const generatedId = (0, react_1.useId)();
|
|
36
36
|
const id = props.id || generatedId;
|
|
37
37
|
const innerRef = (0, react_1.useRef)(null);
|
package/badge/badge.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.Badge = void 0;
|
|
|
7
7
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
10
|
-
exports.Badge = (0, forwardRef_1.forwardRef)("
|
|
10
|
+
exports.Badge = (0, forwardRef_1.forwardRef)("UxfUiBadge", (props, ref) => {
|
|
11
11
|
var _a;
|
|
12
12
|
const badgeClassName = (0, cx_1.cx)("uxf-badge", `uxf-badge--size-${(_a = props.size) !== null && _a !== void 0 ? _a : "medium"}`, props.className);
|
|
13
13
|
return (react_1.default.createElement("div", { ref: ref, className: badgeClassName },
|
package/button/button.js
CHANGED
|
@@ -8,7 +8,7 @@ const useAnchorProps_1 = require("@uxf/core/hooks/useAnchorProps");
|
|
|
8
8
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
10
10
|
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
11
|
-
exports.Button = (0, forwardRef_1.forwardRef)("
|
|
11
|
+
exports.Button = (0, forwardRef_1.forwardRef)("UxfUiButton", (props, ref) => {
|
|
12
12
|
// eslint-disable-next-line react/destructuring-assignment
|
|
13
13
|
const { color, isIconButton, isFullWidth, size, variant, className, ...restProps } = props;
|
|
14
14
|
const anchorProps = (0, useAnchorProps_1.useAnchorProps)({
|
|
@@ -10,3 +10,4 @@ const ButtonGroup = (props) => {
|
|
|
10
10
|
return (react_1.default.createElement("div", { className: (0, cx_1.cx)("uxf-button-group", props.className), style: props.style }, props.children));
|
|
11
11
|
};
|
|
12
12
|
exports.ButtonGroup = ButtonGroup;
|
|
13
|
+
exports.ButtonGroup.displayName = "UxfUiButtonGroup";
|
package/checkbox/checkbox.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { CSSProperties, ReactNode } from "react";
|
|
2
2
|
import { FormControlProps } from "../types";
|
|
3
3
|
import { CheckboxSize } from "./theme";
|
|
4
|
-
export interface CheckboxProps extends FormControlProps<boolean> {
|
|
4
|
+
export interface CheckboxProps extends FormControlProps<boolean | undefined> {
|
|
5
5
|
className?: string;
|
|
6
6
|
indeterminate?: boolean;
|
|
7
7
|
renderContent?: (className: string, checked: boolean | undefined) => ReactNode;
|
package/checkbox/checkbox.js
CHANGED
|
@@ -10,7 +10,7 @@ const cx_1 = require("@uxf/core/utils/cx");
|
|
|
10
10
|
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
11
11
|
const react_1 = __importDefault(require("react"));
|
|
12
12
|
const icon_1 = require("../icon");
|
|
13
|
-
exports.Checkbox = (0, forwardRef_1.forwardRef)("
|
|
13
|
+
exports.Checkbox = (0, forwardRef_1.forwardRef)("UxfUiCheckbox", (props, ref) => {
|
|
14
14
|
var _a, _b, _c;
|
|
15
15
|
const onChange = () => props.onChange(!props.value);
|
|
16
16
|
const clickableProps = (0, useClickableProps_1.useClickableProps)({
|
|
@@ -19,7 +19,7 @@ exports.Checkbox = (0, forwardRef_1.forwardRef)("Checkbox", (props, ref) => {
|
|
|
19
19
|
"aria-invalid": props.isInvalid,
|
|
20
20
|
"aria-readonly": props.isReadOnly,
|
|
21
21
|
"aria-required": props.isRequired,
|
|
22
|
-
className: (0, cx_1.cx)("uxf-checkbox", `uxf-checkbox--size-${(_a = props.size) !== null && _a !== void 0 ? _a : "default"}`, props.indeterminate && classes_1.CLASSES.IS_INDETERMINATE, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.isFocused && classes_1.CLASSES.IS_FOCUSED, props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.value && classes_1.CLASSES.IS_SELECTED
|
|
22
|
+
className: (0, cx_1.cx)("uxf-checkbox", `uxf-checkbox--size-${(_a = props.size) !== null && _a !== void 0 ? _a : "default"}`, props.className, props.indeterminate && classes_1.CLASSES.IS_INDETERMINATE, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.isFocused && classes_1.CLASSES.IS_FOCUSED, props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.value && classes_1.CLASSES.IS_SELECTED),
|
|
23
23
|
onBlur: props.onBlur,
|
|
24
24
|
onClick: onChange,
|
|
25
25
|
onFocus: props.onFocus,
|
|
@@ -28,7 +28,7 @@ const react_1 = __importStar(require("react"));
|
|
|
28
28
|
const checkbox_1 = require("./checkbox");
|
|
29
29
|
const action_1 = require("../utils/action");
|
|
30
30
|
exports.default = {
|
|
31
|
-
title: "UI/
|
|
31
|
+
title: "UI/Checkbox",
|
|
32
32
|
component: checkbox_1.Checkbox,
|
|
33
33
|
};
|
|
34
34
|
function Default() {
|
|
@@ -10,7 +10,7 @@ const cx_1 = require("@uxf/core/utils/cx");
|
|
|
10
10
|
const classes_1 = require("@uxf/core/constants/classes");
|
|
11
11
|
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
12
12
|
const icon_1 = require("../icon");
|
|
13
|
-
exports.CheckboxButton = (0, forwardRef_1.forwardRef)("
|
|
13
|
+
exports.CheckboxButton = (0, forwardRef_1.forwardRef)("UxfUiCheckboxButton", (props, ref) => {
|
|
14
14
|
return (react_2.default.createElement(react_1.Switch, { checked: props.value, className: (0, cx_1.cx)("uxf-checkbox-button", props.className, props.isDisabled && classes_1.CLASSES.IS_DISABLED, props.isInvalid && classes_1.CLASSES.IS_INVALID, props.isReadOnly && classes_1.CLASSES.IS_READONLY, props.value && classes_1.CLASSES.IS_SELECTED), disabled: props.isDisabled, name: props.name, onChange: props.onChange, ref: ref, style: props.style },
|
|
15
15
|
react_2.default.createElement("span", { className: "uxf-checkbox-button__label" }, props.label),
|
|
16
16
|
react_2.default.createElement("span", { className: "uxf-checkbox-button__icon" },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { CSSProperties, ReactNode } from "react";
|
|
2
2
|
import { FormControlProps } from "../types";
|
|
3
3
|
import { CheckboxSize } from "../checkbox";
|
|
4
|
-
export interface CheckboxInputProps extends FormControlProps<boolean> {
|
|
4
|
+
export interface CheckboxInputProps extends FormControlProps<boolean | undefined> {
|
|
5
5
|
className?: string;
|
|
6
6
|
indeterminate?: boolean;
|
|
7
7
|
label: ReactNode;
|
|
@@ -28,7 +28,7 @@ const react_1 = require("@headlessui/react");
|
|
|
28
28
|
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
29
29
|
const react_2 = __importStar(require("react"));
|
|
30
30
|
const checkbox_1 = require("../checkbox");
|
|
31
|
-
exports.CheckboxInput = (0, forwardRef_1.forwardRef)("
|
|
31
|
+
exports.CheckboxInput = (0, forwardRef_1.forwardRef)("UxfUiCheckboxInput", (props, ref) => {
|
|
32
32
|
var _a;
|
|
33
33
|
return (react_2.default.createElement(react_1.Switch.Group, null,
|
|
34
34
|
react_2.default.createElement("div", { className: `uxf-checkbox-input__wrapper ${(_a = props.className) !== null && _a !== void 0 ? _a : ""}` },
|
package/chip/chip.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.Chip = void 0;
|
|
|
7
7
|
const cx_1 = require("@uxf/core/utils/cx");
|
|
8
8
|
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
9
9
|
const react_1 = __importDefault(require("react"));
|
|
10
|
-
exports.Chip = (0, forwardRef_1.forwardRef)("
|
|
10
|
+
exports.Chip = (0, forwardRef_1.forwardRef)("UxfUiChip", (props, ref) => {
|
|
11
11
|
var _a, _b;
|
|
12
12
|
const chipClassName = (0, cx_1.cx)("uxf-chip", `uxf-chip--color-${(_a = props.color) !== null && _a !== void 0 ? _a : "default"}`, `uxf-chip--size-${(_b = props.size) !== null && _b !== void 0 ? _b : "default"}`, props.onClose && "has-button", props.className);
|
|
13
13
|
return (react_1.default.createElement("div", { ref: ref, className: chipClassName },
|
|
@@ -11,7 +11,7 @@ const color2k_1 = require("color2k");
|
|
|
11
11
|
const react_1 = __importDefault(require("react"));
|
|
12
12
|
const useClickableProps_1 = require("@uxf/core/hooks/useClickableProps");
|
|
13
13
|
const icon_1 = require("../icon");
|
|
14
|
-
exports.ColorRadio = (0, forwardRef_1.forwardRef)("
|
|
14
|
+
exports.ColorRadio = (0, forwardRef_1.forwardRef)("UxfUiColorRadio", (props, ref) => {
|
|
15
15
|
var _a, _b, _c;
|
|
16
16
|
const colorRadioStyle = {
|
|
17
17
|
"--bg-color": props.color,
|
|
@@ -32,7 +32,7 @@ const cx_1 = require("@uxf/core/utils/cx");
|
|
|
32
32
|
const classes_1 = require("@uxf/core/constants/classes");
|
|
33
33
|
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
34
34
|
const color_radio_1 = require("../color-radio");
|
|
35
|
-
exports.ColorRadioGroup = (0, forwardRef_1.forwardRef)("
|
|
35
|
+
exports.ColorRadioGroup = (0, forwardRef_1.forwardRef)("UxfUiColorRadioGroup", (props, ref) => {
|
|
36
36
|
const innerRef = (0, react_2.useRef)(null);
|
|
37
37
|
(0, use_input_submit_1.useInputSubmit)(innerRef, "radio-group", props.isDisabled);
|
|
38
38
|
const errorId = props.isInvalid ? `${props.id}--errormessage` : undefined;
|
package/combobox/combobox.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import React, { ReactNode } from "react";
|
|
5
|
-
export type ComboboxValueId = number | string;
|
|
1
|
+
import { ReactNode, Ref } from "react";
|
|
2
|
+
import { SelectBaseProps, SelectBaseValueId } from "../_select-base";
|
|
3
|
+
export type ComboboxValueId = SelectBaseValueId;
|
|
6
4
|
export type ComboboxValue<ValueId = ComboboxValueId> = {
|
|
7
5
|
id: ValueId;
|
|
8
6
|
label: string;
|
|
@@ -10,20 +8,16 @@ export type ComboboxValue<ValueId = ComboboxValueId> = {
|
|
|
10
8
|
export interface ComboboxOption<ValueId = ComboboxValueId> extends ComboboxValue<ValueId> {
|
|
11
9
|
disabled?: boolean;
|
|
12
10
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
helperText?: ReactNode;
|
|
17
|
-
hiddenLabel?: boolean;
|
|
18
|
-
iconName?: keyof IconsSet;
|
|
19
|
-
id?: string;
|
|
20
|
-
keyExtractor?: (option: Option) => string | number;
|
|
21
|
-
label: string;
|
|
11
|
+
type ComboboxTypeRef = HTMLDivElement;
|
|
12
|
+
export interface ComboboxProps<ValueId = SelectBaseValueId, Option = ComboboxOption<ValueId>, Value = Option> extends Omit<SelectBaseProps<Value, Option>, "children" | "customInputElementDisplayName" | "emptyMessage"> {
|
|
13
|
+
forwardRef?: Ref<ComboboxTypeRef> | undefined;
|
|
22
14
|
loadOptions?: (query: string) => Promise<Option[]>;
|
|
23
15
|
noQueryMessage?: string;
|
|
24
16
|
notFoundMessage?: string;
|
|
25
|
-
options?: Option[];
|
|
26
|
-
placeholder?: string;
|
|
27
17
|
renderOption?: (option: Option) => ReactNode;
|
|
28
18
|
}
|
|
29
|
-
export declare const Combobox:
|
|
19
|
+
export declare const Combobox: {
|
|
20
|
+
<ValueId = SelectBaseValueId, Option = ComboboxOption<ValueId>, Value = Option>(props: ComboboxProps<ValueId, Option, Value>): JSX.Element;
|
|
21
|
+
displayName: string;
|
|
22
|
+
};
|
|
23
|
+
export {};
|
package/combobox/combobox.js
CHANGED
|
@@ -25,51 +25,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.Combobox = void 0;
|
|
27
27
|
const react_1 = require("@headlessui/react");
|
|
28
|
-
const classes_1 = require("@uxf/core/constants/classes");
|
|
29
|
-
const useInputFocus_1 = require("@uxf/core/hooks/useInputFocus");
|
|
30
|
-
const composeRefs_1 = require("@uxf/core/utils/composeRefs");
|
|
31
|
-
const cx_1 = require("@uxf/core/utils/cx");
|
|
32
|
-
const forwardRef_1 = require("@uxf/core/utils/forwardRef");
|
|
33
28
|
const slugify_1 = require("@uxf/core/utils/slugify");
|
|
34
29
|
const use_async_loading_1 = require("@uxf/ui/hooks/use-async-loading");
|
|
35
|
-
const use_dropdown_1 = require("@uxf/ui/hooks/use-dropdown");
|
|
36
|
-
const icon_1 = require("@uxf/ui/icon");
|
|
37
|
-
const input_1 = require("@uxf/ui/input");
|
|
38
|
-
const label_1 = require("@uxf/ui/label");
|
|
39
30
|
const react_2 = __importStar(require("react"));
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var _a, _b, _c
|
|
43
|
-
const generatedId = (0, react_2.useId)();
|
|
44
|
-
const id = (_a = props.id) !== null && _a !== void 0 ? _a : generatedId;
|
|
31
|
+
const _select_base_1 = require("../_select-base");
|
|
32
|
+
const Combobox = (props) => {
|
|
33
|
+
var _a, _b, _c;
|
|
45
34
|
const isAsync = !!props.loadOptions;
|
|
46
35
|
const [query, setQuery] = (0, react_2.useState)("");
|
|
47
|
-
const options = (0, use_async_loading_1.useAsyncLoading)(query, (
|
|
36
|
+
const options = (0, use_async_loading_1.useAsyncLoading)(query, (_a = props.options) !== null && _a !== void 0 ? _a : [], props.loadOptions);
|
|
48
37
|
const filteredData = query === "" || isAsync ? options : options.filter((item) => (0, slugify_1.slugify)(item.label).includes((0, slugify_1.slugify)(query)));
|
|
49
|
-
const innerRef = (0, react_2.useRef)(null);
|
|
50
|
-
const errorId = props.isInvalid ? `${id}--error-message` : undefined;
|
|
51
|
-
const input = (0, useInputFocus_1.useInputFocus)(innerRef, props.onBlur, props.onFocus);
|
|
52
|
-
const dropdown = (0, use_dropdown_1.useDropdown)((_c = props.dropdownPlacement) !== null && _c !== void 0 ? _c : "bottom", true);
|
|
53
|
-
const stableRef = (0, react_2.useMemo)(() => (0, composeRefs_1.composeRefs)(innerRef, ref, dropdown.reference), [ref, dropdown.reference]);
|
|
54
|
-
const iconName = (_d = props.iconName) !== null && _d !== void 0 ? _d : "chevronDown";
|
|
55
38
|
const emptyMessage = query.length === 0
|
|
56
|
-
? (
|
|
57
|
-
: (
|
|
39
|
+
? (_b = props.noQueryMessage) !== null && _b !== void 0 ? _b : "Pro zobrazení možností začněte psát"
|
|
40
|
+
: (_c = props.notFoundMessage) !== null && _c !== void 0 ? _c : "Nic nenalezeno";
|
|
58
41
|
const onChange = (v) => props.onChange(v);
|
|
59
42
|
const onInputChange = (event) => setQuery(event.target.value);
|
|
60
43
|
const displayValue = (item) => { var _a; return (_a = item === null || item === void 0 ? void 0 : item.label) !== null && _a !== void 0 ? _a : ""; };
|
|
61
|
-
return (react_2.default.createElement(
|
|
62
|
-
react_2.default.createElement("
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
react_2.default.createElement(react_1.Combobox.Input, { autoComplete: "off", className: "uxf-combobox__input", displayValue: displayValue, onBlur: props.onBlur, onChange: onInputChange, placeholder: props.placeholder, type: "text" }),
|
|
67
|
-
props.value && !props.isDisabled && !props.isReadOnly && props.isClearable && (react_2.default.createElement(input_1.Input.RemoveButton, { onChange: props.onChange })),
|
|
68
|
-
react_2.default.createElement(icon_1.Icon, { className: (0, cx_1.cx)("uxf-select__button-icon", renderProps.open && "is-open"), name: iconName })),
|
|
69
|
-
react_2.default.createElement(react_1.Combobox.Options, { className: (0, cx_1.cx)("uxf-dropdown", dropdown.placement === "bottom" && "uxf-dropdown--bottom", dropdown.placement === "top" && "uxf-dropdown--top"), ref: dropdown.floating }, filteredData.length > 0 ? (filteredData.map((option) => {
|
|
70
|
-
var _a;
|
|
71
|
-
const optionKey = (_a = props.keyExtractor) === null || _a === void 0 ? void 0 : _a.call(props, option);
|
|
72
|
-
return (react_2.default.createElement(react_1.Combobox.Option, { key: optionKey !== null && optionKey !== void 0 ? optionKey : option.id, value: option, className: (optionState) => (0, cx_1.cx)("uxf-dropdown__item", optionState.active && classes_1.CLASSES.IS_ACTIVE, optionState.disabled && classes_1.CLASSES.IS_DISABLED, optionState.selected && classes_1.CLASSES.IS_SELECTED) }, optionKey !== null && optionKey !== void 0 ? optionKey : option.label));
|
|
73
|
-
})) : (react_2.default.createElement("div", { className: "uxf-dropdown__empty-wrapper" }, emptyMessage))),
|
|
74
|
-
props.helperText && (react_2.default.createElement("div", { className: (0, cx_1.cx)("uxf-helper-text", props.isInvalid && classes_1.CLASSES.IS_INVALID), id: errorId }, props.helperText)))))));
|
|
75
|
-
});
|
|
44
|
+
return (react_2.default.createElement(_select_base_1._SelectBase, { HUIComponent: react_1.Combobox, className: props.className, customInputElementDisplayName: react_1.Combobox.Input.displayName, dropdownPlacement: props.dropdownPlacement, emptyMessage: emptyMessage, forwardRef: props.forwardRef, helperText: props.helperText, hiddenLabel: props.hiddenLabel, iconName: props.iconName, id: props.id, isClearable: props.isClearable, isDisabled: props.isDisabled, isFocused: props.isFocused, isInvalid: props.isInvalid, isReadOnly: props.isReadOnly, isRequired: props.isRequired, keyExtractor: props.keyExtractor, label: props.label, leftAddon: props.leftAddon, leftElement: props.leftElement, name: props.name, onBlur: props.onBlur, onChange: onChange, onFocus: props.onFocus, options: filteredData, placeholder: props.placeholder, renderOption: props.renderOption, rightAddon: props.rightAddon, rightElement: props.rightElement, size: props.size, value: props.value, variant: props.variant },
|
|
45
|
+
react_2.default.createElement(react_1.Combobox.Input, { autoComplete: "off", className: "uxf-input__element", displayValue: displayValue, onBlur: props.onBlur, onChange: onInputChange, placeholder: props.placeholder, type: "text" })));
|
|
46
|
+
};
|
|
47
|
+
exports.Combobox = Combobox;
|
|
48
|
+
exports.Combobox.displayName = "UxfUiCombobox";
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
declare const _default: {
|
|
3
3
|
title: string;
|
|
4
|
-
component:
|
|
4
|
+
component: {
|
|
5
|
+
<ValueId = import("../_select-base").SelectBaseValueId, Option = import("./combobox").ComboboxOption<ValueId>, Value = Option>(props: import("./combobox").ComboboxProps<ValueId, Option, Value>): JSX.Element;
|
|
6
|
+
displayName: string;
|
|
7
|
+
};
|
|
5
8
|
};
|
|
6
9
|
export default _default;
|
|
7
10
|
export declare function Default(): JSX.Element;
|