@scaleflex/ui-tw 0.0.139 → 0.0.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/input/input.component.js
CHANGED
|
@@ -70,17 +70,16 @@ function Input(_ref) {
|
|
|
70
70
|
readOnly: readOnly,
|
|
71
71
|
value: value,
|
|
72
72
|
className: cn.apply(void 0, ['flex w-full min-w-0'].concat(_toConsumableArray(getBaseInputClasses()), [readOnlyClassNames, selectionHighlightClassNames, inputVariants({
|
|
73
|
-
size: size
|
|
74
|
-
className: hasAddon ? undefined : className
|
|
73
|
+
size: size
|
|
75
74
|
}), (Icon || suffix) && !clearable && inputWithIconVariants({
|
|
76
75
|
size: size
|
|
77
|
-
}), clearable && inputClearablePaddingOptions[size]]))
|
|
76
|
+
}), clearable && inputClearablePaddingOptions[size], className]))
|
|
78
77
|
}, props));
|
|
79
78
|
if (!hasAddon) {
|
|
80
79
|
return inputElement;
|
|
81
80
|
}
|
|
82
81
|
return /*#__PURE__*/React.createElement("div", {
|
|
83
|
-
className: cn('relative',
|
|
82
|
+
className: cn('relative', wrapperClassName)
|
|
84
83
|
}, inputElement, Icon && /*#__PURE__*/React.createElement(Icon, {
|
|
85
84
|
className: cn(inputIconSizeVariants({
|
|
86
85
|
size: size
|
package/label/label.component.js
CHANGED
|
@@ -34,7 +34,7 @@ function Label(_ref) {
|
|
|
34
34
|
className: className
|
|
35
35
|
}))
|
|
36
36
|
}, props), noTruncate ? children : /*#__PURE__*/React.createElement("span", {
|
|
37
|
-
className:
|
|
37
|
+
className: "min-w-0 truncate"
|
|
38
38
|
}, children), (icon || tooltip || disabledTooltip) && /*#__PURE__*/React.createElement(LabelIcon, {
|
|
39
39
|
size: size,
|
|
40
40
|
icon: icon,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scaleflex/ui-tw",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.141",
|
|
4
4
|
"author": "scaleflex",
|
|
5
5
|
"repository": "github:scaleflex/ui",
|
|
6
6
|
"homepage": "https://github.com/scaleflex/ui/blob/master/README.md",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@radix-ui/react-switch": "^1.0.1",
|
|
30
30
|
"@radix-ui/react-tabs": "^1.1.13",
|
|
31
31
|
"@radix-ui/react-tooltip": "^1.2.6",
|
|
32
|
-
"@scaleflex/icons-tw": "^0.0.
|
|
32
|
+
"@scaleflex/icons-tw": "^0.0.141",
|
|
33
33
|
"@tanstack/react-table": "^8.21.3",
|
|
34
34
|
"@types/lodash.merge": "^4.6.9",
|
|
35
35
|
"class-variance-authority": "^0.7.1",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { InputProps } from '@scaleflex/ui-tw/input';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export declare function Search({ className, wrapperClassName, size, disabled, readOnly, onChange, ...rest }: InputProps): React.JSX.Element;
|
|
3
|
+
export declare function Search({ className, wrapperClassName, size, disabled, readOnly, onChange, value: controlledValue, defaultValue, clearable, onClear, icon, suffix, ...rest }: InputProps): React.JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["className", "wrapperClassName", "size", "disabled", "readOnly", "onChange"];
|
|
4
|
+
var _excluded = ["className", "wrapperClassName", "size", "disabled", "readOnly", "onChange", "value", "defaultValue", "clearable", "onClear", "icon", "suffix"];
|
|
5
5
|
import { buttonVariants } from '@scaleflex/ui-tw/button';
|
|
6
6
|
import { ButtonVariant } from '@scaleflex/ui-tw/button/button.constants';
|
|
7
7
|
import { Input } from '@scaleflex/ui-tw/input';
|
|
@@ -11,48 +11,62 @@ import { cn } from '@scaleflex/ui-tw/utils/cn';
|
|
|
11
11
|
import { Search as SearchIcon, XIcon } from 'lucide-react';
|
|
12
12
|
import React, { useState } from 'react';
|
|
13
13
|
export function Search(_ref) {
|
|
14
|
-
var
|
|
14
|
+
var _defaultValue$toStrin;
|
|
15
15
|
var className = _ref.className,
|
|
16
16
|
wrapperClassName = _ref.wrapperClassName,
|
|
17
17
|
_ref$size = _ref.size,
|
|
18
18
|
size = _ref$size === void 0 ? FormSize.Md : _ref$size,
|
|
19
19
|
disabled = _ref.disabled,
|
|
20
20
|
readOnly = _ref.readOnly,
|
|
21
|
-
|
|
21
|
+
onChange = _ref.onChange,
|
|
22
|
+
controlledValue = _ref.value,
|
|
23
|
+
defaultValue = _ref.defaultValue,
|
|
24
|
+
clearable = _ref.clearable,
|
|
25
|
+
onClear = _ref.onClear,
|
|
26
|
+
icon = _ref.icon,
|
|
27
|
+
suffix = _ref.suffix,
|
|
22
28
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
29
|
+
void clearable, onClear, icon, suffix;
|
|
23
30
|
var padding = searchPaddingMap[size];
|
|
24
31
|
var iconSize = iconSizeOptions[size];
|
|
25
32
|
var crossSize = crossSizeOptions[size];
|
|
26
|
-
var
|
|
33
|
+
var isControlled = controlledValue !== undefined;
|
|
34
|
+
var _useState = useState((_defaultValue$toStrin = defaultValue === null || defaultValue === void 0 ? void 0 : defaultValue.toString()) !== null && _defaultValue$toStrin !== void 0 ? _defaultValue$toStrin : ''),
|
|
27
35
|
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
internalValue = _useState2[0],
|
|
37
|
+
setInternalValue = _useState2[1];
|
|
38
|
+
var value = isControlled ? controlledValue : internalValue;
|
|
39
|
+
var handleChange = function handleChange(e) {
|
|
40
|
+
if (!isControlled) {
|
|
41
|
+
setInternalValue(e.target.value);
|
|
42
|
+
}
|
|
43
|
+
onChange === null || onChange === void 0 || onChange(e);
|
|
44
|
+
};
|
|
30
45
|
var handleClear = function handleClear() {
|
|
31
46
|
var syntheticEvent = {
|
|
32
47
|
target: {
|
|
33
48
|
value: ''
|
|
34
49
|
}
|
|
35
50
|
};
|
|
36
|
-
|
|
37
|
-
|
|
51
|
+
if (!isControlled) {
|
|
52
|
+
setInternalValue('');
|
|
53
|
+
}
|
|
54
|
+
onChange === null || onChange === void 0 || onChange(syntheticEvent);
|
|
38
55
|
};
|
|
39
56
|
return /*#__PURE__*/React.createElement("div", {
|
|
40
57
|
className: cn('relative w-full', wrapperClassName)
|
|
41
58
|
}, /*#__PURE__*/React.createElement(SearchIcon, {
|
|
42
|
-
className: cn('text-muted-foreground pointer-events-none absolute top-1/2 -translate-y-1/2', iconSize, padding.icon)
|
|
59
|
+
className: cn('text-muted-foreground pointer-events-none absolute top-1/2 -translate-y-1/2', iconSize, padding.icon, disabled && 'opacity-50')
|
|
43
60
|
}), /*#__PURE__*/React.createElement(Input, _extends({
|
|
44
61
|
value: value,
|
|
45
|
-
onChange:
|
|
46
|
-
setValue(e.target.value);
|
|
47
|
-
_onChange === null || _onChange === void 0 || _onChange(e);
|
|
48
|
-
},
|
|
62
|
+
onChange: handleChange,
|
|
49
63
|
type: "search",
|
|
50
64
|
size: size,
|
|
51
65
|
disabled: disabled,
|
|
52
66
|
readOnly: readOnly,
|
|
53
67
|
className: cn('[&::-webkit-search-cancel-button]:hidden [&::-webkit-search-cancel-button]:appearance-none', padding.input, className)
|
|
54
68
|
}, rest)), value && !readOnly && !disabled && /*#__PURE__*/React.createElement("button", {
|
|
55
|
-
|
|
69
|
+
type: "button",
|
|
56
70
|
tabIndex: 0,
|
|
57
71
|
onClick: handleClear,
|
|
58
72
|
"data-clear-icon": "true",
|
|
@@ -63,6 +77,6 @@ export function Search(_ref) {
|
|
|
63
77
|
}), 'absolute top-1/2 right-2 -translate-y-1/2')
|
|
64
78
|
}, /*#__PURE__*/React.createElement(XIcon, {
|
|
65
79
|
"data-clear-icon": true,
|
|
66
|
-
className:
|
|
80
|
+
className: "text-muted-foreground/70 hover:text-muted-foreground shrink-0"
|
|
67
81
|
})));
|
|
68
82
|
}
|