@rovula/ui 0.0.28 → 0.0.30
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/cjs/bundle.css +40 -0
- package/dist/cjs/bundle.js +3 -3
- package/dist/cjs/bundle.js.map +1 -1
- package/dist/cjs/types/components/DatePicker/DatePicker.d.ts +2 -1
- package/dist/cjs/types/components/DatePicker/DatePicker.stories.d.ts +720 -1
- package/dist/cjs/types/components/Dropdown/Dropdown.d.ts +2 -0
- package/dist/cjs/types/components/Dropdown/Dropdown.stories.d.ts +8 -0
- package/dist/cjs/types/components/InputFilter/InputFilter.d.ts +5 -0
- package/dist/cjs/types/components/InputFilter/InputFilter.stories.d.ts +334 -0
- package/dist/cjs/types/components/InputFilter/InputFilter.styles.d.ts +7 -0
- package/dist/cjs/types/components/Search/Search.d.ts +2 -20
- package/dist/cjs/types/components/Search/Search.stories.d.ts +20 -38
- package/dist/cjs/types/components/TextInput/TextInput.d.ts +10 -0
- package/dist/cjs/types/components/TextInput/TextInput.stories.d.ts +10 -0
- package/dist/cjs/types/components/TextInput/TextInput.styles.d.ts +1 -0
- package/dist/cjs/types/index.d.ts +1 -0
- package/dist/components/DatePicker/DatePicker.js +16 -3
- package/dist/components/Dropdown/Dropdown.js +26 -15
- package/dist/components/Dropdown/Dropdown.stories.js +1 -0
- package/dist/components/InputFilter/InputFilter.js +18 -0
- package/dist/components/InputFilter/InputFilter.stories.js +33 -0
- package/dist/components/InputFilter/InputFilter.styles.js +60 -0
- package/dist/components/Search/Search.js +1 -1
- package/dist/components/TextInput/TextInput.js +22 -6
- package/dist/components/TextInput/TextInput.styles.js +84 -11
- package/dist/esm/bundle.css +40 -0
- package/dist/esm/bundle.js +3 -3
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/types/components/DatePicker/DatePicker.d.ts +2 -1
- package/dist/esm/types/components/DatePicker/DatePicker.stories.d.ts +720 -1
- package/dist/esm/types/components/Dropdown/Dropdown.d.ts +2 -0
- package/dist/esm/types/components/Dropdown/Dropdown.stories.d.ts +8 -0
- package/dist/esm/types/components/InputFilter/InputFilter.d.ts +5 -0
- package/dist/esm/types/components/InputFilter/InputFilter.stories.d.ts +334 -0
- package/dist/esm/types/components/InputFilter/InputFilter.styles.d.ts +7 -0
- package/dist/esm/types/components/Search/Search.d.ts +2 -20
- package/dist/esm/types/components/Search/Search.stories.d.ts +20 -38
- package/dist/esm/types/components/TextInput/TextInput.d.ts +10 -0
- package/dist/esm/types/components/TextInput/TextInput.stories.d.ts +10 -0
- package/dist/esm/types/components/TextInput/TextInput.styles.d.ts +1 -0
- package/dist/esm/types/index.d.ts +1 -0
- package/dist/index.d.ts +19 -22
- package/dist/index.js +1 -0
- package/dist/src/theme/global.css +65 -0
- package/dist/theme/tokens/components/action-button.css +13 -0
- package/package.json +1 -1
- package/src/components/DatePicker/DatePicker.tsx +8 -3
- package/src/components/Dropdown/Dropdown.stories.tsx +1 -0
- package/src/components/Dropdown/Dropdown.tsx +51 -34
- package/src/components/InputFilter/InputFilter.stories.tsx +71 -0
- package/src/components/InputFilter/InputFilter.styles.ts +69 -0
- package/src/components/InputFilter/InputFilter.tsx +55 -0
- package/src/components/Search/Search.stories.tsx +1 -1
- package/src/components/Search/Search.tsx +13 -2
- package/src/components/TextInput/TextInput.styles.ts +84 -11
- package/src/components/TextInput/TextInput.tsx +51 -10
- package/src/index.ts +1 -0
- package/src/theme/tokens/components/action-button.css +13 -0
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
14
|
import { useState } from "react";
|
|
4
15
|
import { CalendarIcon } from "@heroicons/react/16/solid";
|
|
@@ -6,11 +17,13 @@ import { Calendar } from "../Calendar";
|
|
|
6
17
|
import { Popover, PopoverContent, PopoverTrigger } from "../Popover/Popover";
|
|
7
18
|
import { TextInput } from "../TextInput/TextInput";
|
|
8
19
|
import { format } from "date-fns/format";
|
|
9
|
-
const DatePicker = (
|
|
20
|
+
const DatePicker = (_a) => {
|
|
21
|
+
var { date, onSelect, textInputProps } = _a, props = __rest(_a, ["date", "onSelect", "textInputProps"]);
|
|
10
22
|
const [isOpen, setIsOpen] = useState(false);
|
|
11
|
-
return (_jsx("div", { children: _jsxs(Popover, { open: isOpen, onOpenChange: setIsOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("div", { className: "flex", children: _jsx(TextInput, Object.assign({ fullwidth: true, id: "2"
|
|
23
|
+
return (_jsx("div", { children: _jsxs(Popover, { open: isOpen, onOpenChange: setIsOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("div", { className: "flex", children: _jsx(TextInput, Object.assign({ fullwidth: true, id: "2" // TODO
|
|
24
|
+
, readOnly: true, label: "Date", size: "md", value: date ? format(date, "dd MMM yyyy") : isOpen ? " " : "", hasClearIcon: false, endIcon: _jsx(CalendarIcon, { fill: "inherit", className: "cursor-pointer" }) }, textInputProps)) }) }), _jsx(PopoverContent, { className: "w-auto p-0", children: _jsx(Calendar, Object.assign({ defaultMonth: date }, props, { mode: "single", selected: date, onSelect: (...value) => {
|
|
12
25
|
onSelect === null || onSelect === void 0 ? void 0 : onSelect(...value);
|
|
13
26
|
setIsOpen(false);
|
|
14
|
-
} }) })] }) }));
|
|
27
|
+
} })) })] }) }));
|
|
15
28
|
};
|
|
16
29
|
export default DatePicker;
|
|
@@ -15,7 +15,7 @@ import TextInput from "../TextInput/TextInput";
|
|
|
15
15
|
import { customInputVariant, dropdownIconVariant, iconWrapperVariant, } from "./Dropdown.styles";
|
|
16
16
|
import { ChevronDownIcon } from "@heroicons/react/16/solid";
|
|
17
17
|
const Dropdown = forwardRef((_a, ref) => {
|
|
18
|
-
var { id, options = [], value, label, size = "md", rounded = "normal", variant = "outline", helperText, errorMessage, fullwidth = true, disabled = false, error = false, filterMode = false, required = true, onChangeText, onSelect } = _a, props = __rest(_a, ["id", "options", "value", "label", "size", "rounded", "variant", "helperText", "errorMessage", "fullwidth", "disabled", "error", "filterMode", "required", "onChangeText", "onSelect"]);
|
|
18
|
+
var { id, options = [], value, label, size = "md", rounded = "normal", variant = "outline", helperText, errorMessage, fullwidth = true, disabled = false, error = false, filterMode = false, required = true, onChangeText, onSelect, renderOptions: customRenderOptions } = _a, props = __rest(_a, ["id", "options", "value", "label", "size", "rounded", "variant", "helperText", "errorMessage", "fullwidth", "disabled", "error", "filterMode", "required", "onChangeText", "onSelect", "renderOptions"]);
|
|
19
19
|
const _id = id || `${label}-select`;
|
|
20
20
|
const [isFocused, setIsFocused] = useState(false);
|
|
21
21
|
const [selectedOption, setSelectedOption] = useState(null);
|
|
@@ -24,11 +24,15 @@ const Dropdown = forwardRef((_a, ref) => {
|
|
|
24
24
|
useEffect(() => {
|
|
25
25
|
if (value && !selectedOption) {
|
|
26
26
|
setSelectedOption(value);
|
|
27
|
+
setTextValue(value.label);
|
|
27
28
|
}
|
|
28
29
|
}, [value, selectedOption]);
|
|
29
30
|
const handleOnChangeText = useCallback((event) => {
|
|
30
31
|
onChangeText === null || onChangeText === void 0 ? void 0 : onChangeText(event);
|
|
31
32
|
setTextValue(event.target.value);
|
|
33
|
+
if (!event.target.value) {
|
|
34
|
+
clearMismatchValue(event);
|
|
35
|
+
}
|
|
32
36
|
}, [onChangeText]);
|
|
33
37
|
const handleOptionClick = useCallback((option) => {
|
|
34
38
|
setSelectedOption(option);
|
|
@@ -42,19 +46,26 @@ const Dropdown = forwardRef((_a, ref) => {
|
|
|
42
46
|
((_a = option.label) === null || _a === void 0 ? void 0 : _a.toLowerCase().includes(textValue === null || textValue === void 0 ? void 0 : textValue.toLowerCase()));
|
|
43
47
|
});
|
|
44
48
|
}, [options, filterMode, textValue]);
|
|
45
|
-
const renderOptions = () =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
const renderOptions = () => {
|
|
50
|
+
if (customRenderOptions) {
|
|
51
|
+
return customRenderOptions(optionsFiltered);
|
|
52
|
+
}
|
|
53
|
+
return (_jsxs("ul", { className: "absolute mt-1 w-full bg-base-popup border border-base-popup text-base-popup-foreground rounded-md shadow-md z-10 max-h-60 overflow-y-auto", children: [optionsFiltered.map((option) => {
|
|
54
|
+
if (option.renderLabel) {
|
|
55
|
+
return (_jsx(Fragment, { children: option.renderLabel({
|
|
56
|
+
value: option.value,
|
|
57
|
+
label: option.label,
|
|
58
|
+
handleOnClick: () => handleOptionClick(option),
|
|
59
|
+
className: `px-4 py-2 hover:bg-gray-100 cursor-pointer ${(selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) === option.value
|
|
60
|
+
? " bg-gray-200"
|
|
61
|
+
: ""}`,
|
|
62
|
+
}) }, option.value));
|
|
63
|
+
}
|
|
64
|
+
return (_jsx("li", { onMouseDown: () => handleOptionClick(option), className: `px-4 py-2 hover:bg-primary-hover-bg cursor-pointer ${(selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.value) === option.value
|
|
65
|
+
? "bg-base-popup-highligh"
|
|
66
|
+
: ""}`, children: option.label }, option.value));
|
|
67
|
+
}), optionsFiltered.length === 0 && (_jsx("li", { className: "px-4 py-14 text-center text-input-text", children: "Not found" }))] }));
|
|
68
|
+
};
|
|
58
69
|
const handleOnFocus = useCallback((e) => {
|
|
59
70
|
var _a;
|
|
60
71
|
setIsFocused(true);
|
|
@@ -85,7 +96,7 @@ const Dropdown = forwardRef((_a, ref) => {
|
|
|
85
96
|
setIsFocused(false);
|
|
86
97
|
clearMismatchValue(e);
|
|
87
98
|
(_a = props === null || props === void 0 ? void 0 : props.onBlur) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
88
|
-
}, [props === null || props === void 0 ? void 0 : props.onBlur]);
|
|
99
|
+
}, [props === null || props === void 0 ? void 0 : props.onBlur, clearMismatchValue]);
|
|
89
100
|
const handleOnKeyDown = useCallback((e) => {
|
|
90
101
|
var _a;
|
|
91
102
|
keyCode.current = e.code;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import Dropdown from "../Dropdown/Dropdown";
|
|
4
|
+
import Icon from "../Icon/Icon";
|
|
5
|
+
import { filterIconVariant } from "./InputFilter.styles";
|
|
6
|
+
const InputFilter = forwardRef((props, ref) => {
|
|
7
|
+
var _a;
|
|
8
|
+
const filterIconClassName = filterIconVariant({
|
|
9
|
+
size: props.size,
|
|
10
|
+
rounded: props.rounded,
|
|
11
|
+
error: props.error,
|
|
12
|
+
active: !!((_a = props.value) === null || _a === void 0 ? void 0 : _a.value),
|
|
13
|
+
});
|
|
14
|
+
return (_jsx(Dropdown, Object.assign({ label: "Placeholder Text", required: false }, props, { ref: ref, renderEndIcon: () => (_jsx("div", { className: filterIconClassName, children: _jsx(Icon, { type: "heroicons", name: "adjustments-horizontal", variant: "outline", color: "inherit", stroke: "inherit", fill: "transparent" }) })), renderOptions: (optionsFiltered) => {
|
|
15
|
+
return "";
|
|
16
|
+
}, filterMode: true, isFloatingLabel: false })));
|
|
17
|
+
});
|
|
18
|
+
export { InputFilter };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { InputFilter } from "./InputFilter";
|
|
4
|
+
const meta = {
|
|
5
|
+
title: "Components/InputFilter",
|
|
6
|
+
component: InputFilter,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
parameters: {
|
|
9
|
+
layout: "fullscreen",
|
|
10
|
+
},
|
|
11
|
+
decorators: [
|
|
12
|
+
(Story) => (_jsx("div", { className: "p-5 flex w-full bg-base-bg2", children: _jsx(Story, {}) })),
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
const options = new Array(100).fill("").map((__, index) => ({
|
|
17
|
+
value: `option${index + 1}`,
|
|
18
|
+
label: `Option ${index + 1}`,
|
|
19
|
+
}));
|
|
20
|
+
export const Default = {
|
|
21
|
+
args: {
|
|
22
|
+
label: "Choose an option:",
|
|
23
|
+
fullwidth: true,
|
|
24
|
+
options,
|
|
25
|
+
},
|
|
26
|
+
render: (args) => {
|
|
27
|
+
const [value, setValue] = useState();
|
|
28
|
+
const handleOnSelect = (e) => {
|
|
29
|
+
setValue(e);
|
|
30
|
+
};
|
|
31
|
+
return (_jsxs("div", { className: "flex flex-row gap-4 w-full", children: [_jsx(InputFilter, Object.assign({ id: "1", size: "lg", options: options, value: value, onSelect: handleOnSelect }, args)), _jsx(InputFilter, Object.assign({ id: "2", size: "md", options: options, value: value, onSelect: handleOnSelect }, args)), _jsx(InputFilter, Object.assign({ id: "3", size: "sm", options: options, value: value, onSelect: handleOnSelect }, args))] }));
|
|
32
|
+
},
|
|
33
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { cva } from "class-variance-authority";
|
|
2
|
+
export const filterIconVariant = cva([
|
|
3
|
+
// Base styles
|
|
4
|
+
"absolute flex items-center justify-center cursor-pointer",
|
|
5
|
+
// Border styles
|
|
6
|
+
"border-l border-l-input-default-stroke",
|
|
7
|
+
"peer-hover:border-l-input-active-stroke",
|
|
8
|
+
"peer-focus:border-l-input-active-stroke",
|
|
9
|
+
"peer-disabled:border-l-input-disable-stroke",
|
|
10
|
+
// Fill styles
|
|
11
|
+
"fill-primary",
|
|
12
|
+
"peer-hover:fill-input-filled-text",
|
|
13
|
+
"peer-focus:fill-input-filled-text",
|
|
14
|
+
"peer-disabled:fill-input-disable-stroke",
|
|
15
|
+
// Stroke styles
|
|
16
|
+
"stroke-input-default-stroke",
|
|
17
|
+
"peer-hover:stroke-input-active-stroke",
|
|
18
|
+
"peer-focus:stroke-input-filled-text",
|
|
19
|
+
], {
|
|
20
|
+
variants: {
|
|
21
|
+
size: {
|
|
22
|
+
sm: "p-1 size-[30px]",
|
|
23
|
+
md: "p-2 size-[38px]",
|
|
24
|
+
lg: "p-3 size-14",
|
|
25
|
+
},
|
|
26
|
+
rounded: {
|
|
27
|
+
none: "rounded-r-none",
|
|
28
|
+
normal: "rounded-r-xl",
|
|
29
|
+
full: "rounded-r-full",
|
|
30
|
+
},
|
|
31
|
+
error: {
|
|
32
|
+
true: "border-l-input-error",
|
|
33
|
+
},
|
|
34
|
+
position: {
|
|
35
|
+
start: "inset-y-0 left-0",
|
|
36
|
+
end: "inset-y-0 right-0",
|
|
37
|
+
},
|
|
38
|
+
active: {
|
|
39
|
+
false: "",
|
|
40
|
+
true: [
|
|
41
|
+
// Fill styles
|
|
42
|
+
"fill-primary-default",
|
|
43
|
+
"peer-hover:fill-primary-default", // TODO wait for refactor color after change function button colors
|
|
44
|
+
"peer-focus:fill-primary-hover", // TODO wait for refactor color after change function button colors
|
|
45
|
+
// "peer-disabled:fill-input-disable-stroke",
|
|
46
|
+
// Stroke styles
|
|
47
|
+
"stroke-primary-default",
|
|
48
|
+
"peer-hover:stroke-primary-default",
|
|
49
|
+
"peer-focus:stroke-primary-hover",
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
defaultVariants: {
|
|
54
|
+
size: "md",
|
|
55
|
+
rounded: "normal",
|
|
56
|
+
error: false,
|
|
57
|
+
position: "end",
|
|
58
|
+
active: false,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
@@ -2,6 +2,6 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef } from "react";
|
|
3
3
|
import Dropdown from "../Dropdown/Dropdown";
|
|
4
4
|
const Search = forwardRef((props, ref) => {
|
|
5
|
-
return (_jsx(Dropdown, Object.assign({}, props, { ref: ref,
|
|
5
|
+
return (_jsx(Dropdown, Object.assign({ label: "Search" }, props, { ref: ref, keepCloseIconOnValue: true, hasClearIcon: true, hasSearchIcon: true, endIcon: null, filterMode: true, isFloatingLabel: false })));
|
|
6
6
|
});
|
|
7
7
|
export { Search };
|
|
@@ -10,12 +10,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import { forwardRef, useImperativeHandle, useRef, } from "react";
|
|
13
|
+
import { forwardRef, useCallback, useImperativeHandle, useRef, } from "react";
|
|
14
14
|
import { helperTextVariant, iconSearchWrapperVariant, iconVariant, iconWrapperVariant, inputVariant, labelVariant, sectionIconWrapperVariant, } from "./TextInput.styles";
|
|
15
15
|
import { XCircleIcon, ExclamationCircleIcon, MagnifyingGlassIcon, } from "@heroicons/react/16/solid";
|
|
16
16
|
import { cn } from "@/utils/cn";
|
|
17
17
|
export const TextInput = forwardRef((_a, ref) => {
|
|
18
|
-
var { id, label, size = "md", rounded = "normal", variant = "outline", type = "text", helperText, errorMessage, fullwidth = true, disabled = false, error = false, required = true, hasClearIcon = true, hasSearchIcon = false, startIcon, endIcon, labelClassName } = _a, props = __rest(_a, ["id", "label", "size", "rounded", "variant", "type", "helperText", "errorMessage", "fullwidth", "disabled", "error", "required", "hasClearIcon", "hasSearchIcon", "startIcon", "endIcon", "labelClassName"]);
|
|
18
|
+
var { id, label, size = "md", rounded = "normal", variant = "outline", type = "text", helperText, errorMessage, fullwidth = true, disabled = false, error = false, required = true, isFloatingLabel = true, keepCloseIconOnValue = false, hasClearIcon = true, hasSearchIcon = false, startIcon, endIcon, labelClassName, onClickEndIcon, renderEndIcon } = _a, props = __rest(_a, ["id", "label", "size", "rounded", "variant", "type", "helperText", "errorMessage", "fullwidth", "disabled", "error", "required", "isFloatingLabel", "keepCloseIconOnValue", "hasClearIcon", "hasSearchIcon", "startIcon", "endIcon", "labelClassName", "onClickEndIcon", "renderEndIcon"]);
|
|
19
19
|
const inputRef = useRef(null);
|
|
20
20
|
const _id = id || `${type}-${label}-input`;
|
|
21
21
|
const hasLeftSectionIcon = !!startIcon;
|
|
@@ -37,6 +37,7 @@ export const TextInput = forwardRef((_a, ref) => {
|
|
|
37
37
|
disabled,
|
|
38
38
|
error,
|
|
39
39
|
hasSearchIcon,
|
|
40
|
+
isFloatingLabel,
|
|
40
41
|
});
|
|
41
42
|
const helperTextClassname = helperTextVariant({ size, error, disabled });
|
|
42
43
|
const iconWrapperClassname = iconWrapperVariant({ size });
|
|
@@ -49,13 +50,28 @@ export const TextInput = forwardRef((_a, ref) => {
|
|
|
49
50
|
error,
|
|
50
51
|
});
|
|
51
52
|
useImperativeHandle(ref, () => inputRef === null || inputRef === void 0 ? void 0 : inputRef.current);
|
|
52
|
-
const handleClearInput = () => {
|
|
53
|
+
const handleClearInput = useCallback(() => {
|
|
53
54
|
if (inputRef.current) {
|
|
54
55
|
inputRef.current.value = "";
|
|
56
|
+
if (props.onChange) {
|
|
57
|
+
const event = new Event("input", { bubbles: true });
|
|
58
|
+
props.onChange({ target: { value: "" } });
|
|
59
|
+
}
|
|
55
60
|
}
|
|
56
|
-
};
|
|
57
|
-
|
|
61
|
+
}, [props.onChange]);
|
|
62
|
+
// TODO startIcon
|
|
63
|
+
const handleOnClickRightSectionIcon = useCallback(() => {
|
|
64
|
+
if (disabled)
|
|
65
|
+
return;
|
|
66
|
+
onClickEndIcon === null || onClickEndIcon === void 0 ? void 0 : onClickEndIcon();
|
|
67
|
+
if (inputRef.current) {
|
|
68
|
+
inputRef.current.focus();
|
|
69
|
+
}
|
|
70
|
+
}, [disabled, onClickEndIcon]);
|
|
71
|
+
return (_jsxs("div", { className: `inline-flex flex-col ${fullwidth ? "w-full" : ""}`, children: [_jsxs("div", { className: "relative", children: [hasSearchIcon && (_jsx("div", { className: iconSearchWrapperClassname, children: _jsx(MagnifyingGlassIcon, { className: iconClassname }) })), _jsx("input", Object.assign({}, props, { placeholder: " ", ref: inputRef, type: type, id: _id, disabled: disabled, className: cn(inputClassname, props.className) })), hasClearIcon && !hasRightSectionIcon && (_jsx("div", { className: iconWrapperClassname, style: {
|
|
72
|
+
display: keepCloseIconOnValue && props.value ? "flex" : undefined,
|
|
73
|
+
}, children: _jsx(XCircleIcon, { type: "button", className: iconClassname, onMouseDown: handleClearInput }) })), hasRightSectionIcon && renderEndIcon ? (renderEndIcon()) : (_jsx("div", { className: endIconWrapperClassname, onClick: handleOnClickRightSectionIcon, children: endIcon })), _jsxs("label", { htmlFor: _id, className: cn(labelClassname, labelClassName), children: [label, " ", required && (_jsx("span", { className: cn("text-error", {
|
|
58
74
|
"text-input-disable-text": disabled,
|
|
59
|
-
}), children: "*" }))] })] }), (errorMessage || helperText) && (_jsxs("span", { className: helperTextClassname, children: [_jsx(ExclamationCircleIcon, { width: 16, height: 16, className: error ? "fill-error" : "" })
|
|
75
|
+
}), children: "*" }))] })] }), (errorMessage || helperText) && (_jsxs("span", { className: helperTextClassname, children: [_jsx("span", { className: "h-full", children: _jsx(ExclamationCircleIcon, { width: 16, height: 16, className: error ? "fill-error" : "" }) }), errorMessage || helperText] }))] }));
|
|
60
76
|
});
|
|
61
77
|
export default TextInput;
|
|
@@ -134,34 +134,78 @@ export const labelVariant = cva([
|
|
|
134
134
|
], {
|
|
135
135
|
variants: {
|
|
136
136
|
size: {
|
|
137
|
-
sm: [
|
|
137
|
+
sm: [],
|
|
138
|
+
md: [],
|
|
139
|
+
lg: [],
|
|
140
|
+
},
|
|
141
|
+
disabled: {
|
|
142
|
+
true: "text-input-default-text placeholder:text-input-default-text",
|
|
143
|
+
},
|
|
144
|
+
error: {
|
|
145
|
+
true: "ring-error",
|
|
146
|
+
},
|
|
147
|
+
hasSearchIcon: {
|
|
148
|
+
false: "",
|
|
149
|
+
},
|
|
150
|
+
isFloatingLabel: {
|
|
151
|
+
false: "hidden peer-placeholder-shown:block peer-focus:bg-transparent",
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
compoundVariants: [
|
|
155
|
+
// floating = true
|
|
156
|
+
{
|
|
157
|
+
isFloatingLabel: true,
|
|
158
|
+
size: "sm",
|
|
159
|
+
className: [
|
|
138
160
|
"left-3 -top-1.5 typography-label2 bg-input-label-bg",
|
|
139
161
|
"peer-placeholder-shown:top-2 peer-placeholder-shown:typography-small1 peer-placeholder-shown:bg-transparent",
|
|
140
162
|
"peer-focus:-top-1.5 peer-focus:typography-label2",
|
|
141
163
|
],
|
|
142
|
-
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
isFloatingLabel: true,
|
|
167
|
+
size: "md",
|
|
168
|
+
className: [
|
|
143
169
|
"left-3 -top-1.5 typography-label1 bg-input-label-bg",
|
|
144
170
|
"peer-placeholder-shown:top-2 peer-placeholder-shown:typography-subtitile4 peer-placeholder-shown:bg-transparent",
|
|
145
171
|
"peer-focus:-top-1.5 peer-focus:typography-label1",
|
|
146
172
|
],
|
|
147
|
-
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
isFloatingLabel: true,
|
|
176
|
+
size: "lg",
|
|
177
|
+
className: [
|
|
148
178
|
"left-4 -top-1.5 typography-label1 bg-input-label-bg",
|
|
149
179
|
"peer-placeholder-shown:top-4 peer-placeholder-shown:typography-subtitile1 peer-placeholder-shown:bg-transparent",
|
|
150
180
|
"peer-focus:-top-1.5 peer-focus:typography-label1",
|
|
151
181
|
],
|
|
152
182
|
},
|
|
153
|
-
|
|
154
|
-
|
|
183
|
+
// --------------
|
|
184
|
+
// flating = false
|
|
185
|
+
{
|
|
186
|
+
isFloatingLabel: false,
|
|
187
|
+
size: "sm",
|
|
188
|
+
className: [
|
|
189
|
+
"left-3 peer-placeholder-shown:top-2 peer-placeholder-shown:typography-small1",
|
|
190
|
+
],
|
|
155
191
|
},
|
|
156
|
-
|
|
157
|
-
|
|
192
|
+
{
|
|
193
|
+
isFloatingLabel: false,
|
|
194
|
+
size: "md",
|
|
195
|
+
className: [
|
|
196
|
+
"left-3 peer-placeholder-shown:top-2 peer-placeholder-shown:typography-subtitile4",
|
|
197
|
+
],
|
|
158
198
|
},
|
|
159
|
-
|
|
160
|
-
|
|
199
|
+
{
|
|
200
|
+
isFloatingLabel: false,
|
|
201
|
+
size: "lg",
|
|
202
|
+
className: [
|
|
203
|
+
"left-4 peer-placeholder-shown:top-4 peer-placeholder-shown:typography-subtitile1",
|
|
204
|
+
],
|
|
161
205
|
},
|
|
162
|
-
|
|
163
|
-
compoundVariants: [
|
|
206
|
+
// --------------
|
|
164
207
|
{
|
|
208
|
+
isFloatingLabel: true,
|
|
165
209
|
hasSearchIcon: true,
|
|
166
210
|
size: "sm",
|
|
167
211
|
className: [
|
|
@@ -171,6 +215,7 @@ export const labelVariant = cva([
|
|
|
171
215
|
],
|
|
172
216
|
},
|
|
173
217
|
{
|
|
218
|
+
isFloatingLabel: true,
|
|
174
219
|
hasSearchIcon: true,
|
|
175
220
|
size: "md",
|
|
176
221
|
className: [
|
|
@@ -180,6 +225,7 @@ export const labelVariant = cva([
|
|
|
180
225
|
],
|
|
181
226
|
},
|
|
182
227
|
{
|
|
228
|
+
isFloatingLabel: true,
|
|
183
229
|
hasSearchIcon: true,
|
|
184
230
|
size: "lg",
|
|
185
231
|
className: [
|
|
@@ -188,12 +234,38 @@ export const labelVariant = cva([
|
|
|
188
234
|
"peer-focus:-top-1.5 peer-focus:typography-label1",
|
|
189
235
|
],
|
|
190
236
|
},
|
|
237
|
+
// floating = false and has search icon
|
|
238
|
+
{
|
|
239
|
+
isFloatingLabel: false,
|
|
240
|
+
hasSearchIcon: true,
|
|
241
|
+
size: "sm",
|
|
242
|
+
className: [
|
|
243
|
+
"left-6 peer-placeholder-shown:top-2 peer-placeholder-shown:typography-small1",
|
|
244
|
+
],
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
isFloatingLabel: false,
|
|
248
|
+
hasSearchIcon: true,
|
|
249
|
+
size: "md",
|
|
250
|
+
className: [
|
|
251
|
+
"left-9 peer-placeholder-shown:top-2 peer-placeholder-shown:typography-subtitile4",
|
|
252
|
+
],
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
isFloatingLabel: false,
|
|
256
|
+
hasSearchIcon: true,
|
|
257
|
+
size: "lg",
|
|
258
|
+
className: [
|
|
259
|
+
"left-11 peer-placeholder-shown:top-4 peer-placeholder-shown:typography-subtitile1",
|
|
260
|
+
],
|
|
261
|
+
},
|
|
191
262
|
],
|
|
192
263
|
defaultVariants: {
|
|
193
264
|
size: "md",
|
|
194
265
|
disabled: false,
|
|
195
266
|
error: false,
|
|
196
267
|
hasSearchIcon: false,
|
|
268
|
+
isFloatingLabel: true,
|
|
197
269
|
},
|
|
198
270
|
});
|
|
199
271
|
export const helperTextVariant = cva(["text-small1 flex flex-row items-center gap-1"], {
|
|
@@ -258,6 +330,7 @@ export const iconVariant = cva([
|
|
|
258
330
|
},
|
|
259
331
|
});
|
|
260
332
|
export const sectionIconWrapperVariant = cva([
|
|
333
|
+
"cursor-pointer",
|
|
261
334
|
"absolute items-center justify-center flex",
|
|
262
335
|
"border-l border-l-input-default-stroke peer-hover:border-l-input-active-stroke peer-focus:border-l-input-active-stroke peer-disabled:border-l-input-disable-stroke",
|
|
263
336
|
"fill-input-default-text peer-hover:fill-input-filled-text peer-focus:fill-input-filled-text peer-disabled:fill-input-disable-stroke",
|
package/dist/esm/bundle.css
CHANGED
|
@@ -1391,6 +1391,10 @@ body {
|
|
|
1391
1391
|
--tw-bg-opacity: 1;
|
|
1392
1392
|
background-color: color-mix(in srgb, var(--background) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
1393
1393
|
}
|
|
1394
|
+
.bg-base-bg2{
|
|
1395
|
+
--tw-bg-opacity: 1;
|
|
1396
|
+
background-color: color-mix(in srgb, var(--base-color-bg2) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
1397
|
+
}
|
|
1394
1398
|
.bg-base-popup{
|
|
1395
1399
|
--tw-bg-opacity: 1;
|
|
1396
1400
|
background-color: color-mix(in srgb, var(--base-color-popup) calc(100% * var(--tw-bg-opacity)), transparent);
|
|
@@ -1678,6 +1682,15 @@ body {
|
|
|
1678
1682
|
.fill-primary{
|
|
1679
1683
|
fill: color-mix(in srgb, var(--state-color-primary-default) calc(100% * 1), transparent);
|
|
1680
1684
|
}
|
|
1685
|
+
.fill-primary-default{
|
|
1686
|
+
fill: color-mix(in srgb, var(--state-color-primary-default) calc(100% * 1), transparent);
|
|
1687
|
+
}
|
|
1688
|
+
.stroke-input-default-stroke{
|
|
1689
|
+
stroke: color-mix(in srgb, var(--input-color-default-stroke) calc(100% * 1), transparent);
|
|
1690
|
+
}
|
|
1691
|
+
.stroke-primary-default{
|
|
1692
|
+
stroke: color-mix(in srgb, var(--state-color-primary-default) calc(100% * 1), transparent);
|
|
1693
|
+
}
|
|
1681
1694
|
.p-0{
|
|
1682
1695
|
padding: 0px;
|
|
1683
1696
|
}
|
|
@@ -3909,6 +3922,12 @@ body {
|
|
|
3909
3922
|
.peer:placeholder-shown ~ .peer-placeholder-shown\:top-4{
|
|
3910
3923
|
top: 1rem;
|
|
3911
3924
|
}
|
|
3925
|
+
.peer:-moz-placeholder-shown ~ .peer-placeholder-shown\:block{
|
|
3926
|
+
display: block;
|
|
3927
|
+
}
|
|
3928
|
+
.peer:placeholder-shown ~ .peer-placeholder-shown\:block{
|
|
3929
|
+
display: block;
|
|
3930
|
+
}
|
|
3912
3931
|
.peer:-moz-placeholder-shown ~ .peer-placeholder-shown\:bg-transparent{
|
|
3913
3932
|
background-color: transparent;
|
|
3914
3933
|
}
|
|
@@ -3952,6 +3971,15 @@ body {
|
|
|
3952
3971
|
.peer:hover ~ .peer-hover\:fill-input-filled-text{
|
|
3953
3972
|
fill: color-mix(in srgb, var(--input-color-filled-text) calc(100% * 1), transparent);
|
|
3954
3973
|
}
|
|
3974
|
+
.peer:hover ~ .peer-hover\:fill-primary-default{
|
|
3975
|
+
fill: color-mix(in srgb, var(--state-color-primary-default) calc(100% * 1), transparent);
|
|
3976
|
+
}
|
|
3977
|
+
.peer:hover ~ .peer-hover\:stroke-input-active-stroke{
|
|
3978
|
+
stroke: color-mix(in srgb, var(--input-color-active-stroke) calc(100% * 1), transparent);
|
|
3979
|
+
}
|
|
3980
|
+
.peer:hover ~ .peer-hover\:stroke-primary-default{
|
|
3981
|
+
stroke: color-mix(in srgb, var(--state-color-primary-default) calc(100% * 1), transparent);
|
|
3982
|
+
}
|
|
3955
3983
|
.peer:focus ~ .peer-focus\:-top-1{
|
|
3956
3984
|
top: -0.25rem;
|
|
3957
3985
|
}
|
|
@@ -3973,9 +4001,21 @@ body {
|
|
|
3973
4001
|
--tw-bg-opacity: 1;
|
|
3974
4002
|
background-color: rgb(239 68 68 / var(--tw-bg-opacity));
|
|
3975
4003
|
}
|
|
4004
|
+
.peer:focus ~ .peer-focus\:bg-transparent{
|
|
4005
|
+
background-color: transparent;
|
|
4006
|
+
}
|
|
3976
4007
|
.peer:focus ~ .peer-focus\:fill-input-filled-text{
|
|
3977
4008
|
fill: color-mix(in srgb, var(--input-color-filled-text) calc(100% * 1), transparent);
|
|
3978
4009
|
}
|
|
4010
|
+
.peer:focus ~ .peer-focus\:fill-primary-hover{
|
|
4011
|
+
fill: color-mix(in srgb, var(--state-color-primary-hover) calc(100% * 1), transparent);
|
|
4012
|
+
}
|
|
4013
|
+
.peer:focus ~ .peer-focus\:stroke-input-filled-text{
|
|
4014
|
+
stroke: color-mix(in srgb, var(--input-color-filled-text) calc(100% * 1), transparent);
|
|
4015
|
+
}
|
|
4016
|
+
.peer:focus ~ .peer-focus\:stroke-primary-hover{
|
|
4017
|
+
stroke: color-mix(in srgb, var(--state-color-primary-hover) calc(100% * 1), transparent);
|
|
4018
|
+
}
|
|
3979
4019
|
.peer:focus ~ .peer-focus\:text-input-filled-text{
|
|
3980
4020
|
--tw-text-opacity: 1;
|
|
3981
4021
|
color: color-mix(in srgb, var(--input-color-filled-text) calc(100% * var(--tw-text-opacity)), transparent);
|