react-asc 18.6.1 → 18.7.3
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/components/AutoComplete/AutoComplete.d.ts +5 -1
- package/hooks/index.d.ts +1 -1
- package/hooks/useDebounce.d.ts +1 -0
- package/index.es.js +47 -12
- package/index.es.js.map +1 -1
- package/index.js +47 -11
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/react-asc.scss +4 -0
- package/hooks/Debounce.hook.d.ts +0 -1
|
@@ -8,8 +8,12 @@ export interface IAutoCompleteProps {
|
|
|
8
8
|
value?: string;
|
|
9
9
|
openOnFocus?: boolean;
|
|
10
10
|
disabled?: boolean;
|
|
11
|
+
placeholder?: string;
|
|
11
12
|
readOnly?: boolean;
|
|
12
|
-
|
|
13
|
+
debounce?: number;
|
|
14
|
+
showClearButton?: boolean;
|
|
15
|
+
onSelect?: (val: ISelectOption) => void;
|
|
16
|
+
onChange?: (val: string | undefined) => void;
|
|
13
17
|
onKeyDown?: (event: any) => void;
|
|
14
18
|
}
|
|
15
19
|
export declare const AutoComplete: (props: IAutoCompleteProps) => JSX.Element;
|
package/hooks/index.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useDebounce(callback: any, timeout: any, deps: any): void;
|
package/index.es.js
CHANGED
|
@@ -253,8 +253,9 @@ styleInject(css_248z$I);
|
|
|
253
253
|
// multiple
|
|
254
254
|
// custom template render items
|
|
255
255
|
const AutoComplete = (props) => {
|
|
256
|
-
const { id, name, className, options = [], openOnFocus = true, disabled, readOnly, onChange, value } = props;
|
|
256
|
+
const { id, name, className, options = [], openOnFocus = true, disabled, readOnly, debounce = 0, placeholder, showClearButton, onChange, onSelect, value } = props;
|
|
257
257
|
const [model, setModel] = useState('');
|
|
258
|
+
const [searchText, setSearchText] = useState('');
|
|
258
259
|
const [isShow, setIsShow] = useState(false);
|
|
259
260
|
const [optionsTemp, setOptionsTemp] = useState([]);
|
|
260
261
|
const selectConainter = useRef(null);
|
|
@@ -265,9 +266,31 @@ const AutoComplete = (props) => {
|
|
|
265
266
|
}
|
|
266
267
|
}, [value]);
|
|
267
268
|
useEffect(() => {
|
|
268
|
-
|
|
269
|
-
|
|
269
|
+
if (options && options.length > 0) {
|
|
270
|
+
const optionsOrigin = JSON.parse(JSON.stringify(options));
|
|
271
|
+
const regex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'), 'gi');
|
|
272
|
+
const optionsFiltered = optionsOrigin.filter(o => { var _a; return (_a = o.label) === null || _a === void 0 ? void 0 : _a.match(regex); });
|
|
273
|
+
setOptionsTemp(optionsFiltered);
|
|
274
|
+
}
|
|
270
275
|
}, [options]);
|
|
276
|
+
useDebounce(() => { onChange && onChange(searchText); }, debounce, [searchText]);
|
|
277
|
+
useEffect(() => {
|
|
278
|
+
if (isShow === true) {
|
|
279
|
+
document.body.classList.add('modal-open');
|
|
280
|
+
const main = document.querySelector('.main');
|
|
281
|
+
main === null || main === void 0 ? void 0 : main.classList.add('modal-open');
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
document.body.classList.remove('modal-open');
|
|
285
|
+
const main = document.querySelector('.main');
|
|
286
|
+
main === null || main === void 0 ? void 0 : main.classList.remove('modal-open');
|
|
287
|
+
}
|
|
288
|
+
}, [isShow]);
|
|
289
|
+
useEffect(() => {
|
|
290
|
+
return () => {
|
|
291
|
+
document.body.classList.remove('modal-open');
|
|
292
|
+
};
|
|
293
|
+
}, []);
|
|
271
294
|
const getCssClass = () => {
|
|
272
295
|
const cssClasses = [];
|
|
273
296
|
className && cssClasses.push(className);
|
|
@@ -278,26 +301,29 @@ const AutoComplete = (props) => {
|
|
|
278
301
|
const hide = () => setIsShow(false);
|
|
279
302
|
const handleOnClick = (option) => {
|
|
280
303
|
if (model !== option.value) {
|
|
281
|
-
|
|
304
|
+
onSelect && onSelect(option);
|
|
282
305
|
}
|
|
283
306
|
setModel(option.label);
|
|
284
307
|
hide();
|
|
285
308
|
};
|
|
286
309
|
const handleOnChange = (e) => {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
setModel(searchText);
|
|
290
|
-
const regex = new RegExp(searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'), 'gi');
|
|
291
|
-
const optionsFiltered = optionsOrigin.filter(o => { var _a; return (_a = o.label) === null || _a === void 0 ? void 0 : _a.match(regex); });
|
|
292
|
-
setOptionsTemp(optionsFiltered);
|
|
310
|
+
setModel(e.target.value);
|
|
311
|
+
setSearchText(e.target.value);
|
|
293
312
|
show();
|
|
294
313
|
};
|
|
295
314
|
const handleOnFocus = () => {
|
|
296
315
|
openOnFocus && show();
|
|
297
316
|
};
|
|
317
|
+
const handleClickReset = () => {
|
|
318
|
+
setModel('');
|
|
319
|
+
setSearchText('');
|
|
320
|
+
};
|
|
298
321
|
return (React.createElement(React.Fragment, null,
|
|
299
322
|
React.createElement("div", { ref: selectConainter, className: styles$I.selectContainer },
|
|
300
|
-
React.createElement("
|
|
323
|
+
React.createElement("div", { className: "d-flex" },
|
|
324
|
+
React.createElement("input", { type: "text", className: getCssClass(), id: id, name: name, tabIndex: 0, readOnly: readOnly, disabled: disabled, onChange: handleOnChange, onFocus: handleOnFocus, placeholder: placeholder, value: model }),
|
|
325
|
+
showClearButton && (model === null || model === void 0 ? void 0 : model.length) > 0 &&
|
|
326
|
+
React.createElement(IconButton, { icon: React.createElement(TimesSolidIcon, null), onClick: handleClickReset })),
|
|
301
327
|
isShow &&
|
|
302
328
|
React.createElement(React.Fragment, null,
|
|
303
329
|
React.createElement("div", { className: styles$I.selectMenu },
|
|
@@ -2126,6 +2152,15 @@ const useConstructor = (callBack = () => { }) => {
|
|
|
2126
2152
|
setHasBeenCalled(true);
|
|
2127
2153
|
};
|
|
2128
2154
|
|
|
2155
|
+
function useDebounce(callback, timeout, deps) {
|
|
2156
|
+
const timeoutId = useRef();
|
|
2157
|
+
useEffect(() => {
|
|
2158
|
+
clearTimeout(timeoutId.current);
|
|
2159
|
+
timeoutId.current = setTimeout(callback, timeout);
|
|
2160
|
+
return () => clearTimeout(timeoutId.current);
|
|
2161
|
+
}, deps);
|
|
2162
|
+
}
|
|
2163
|
+
|
|
2129
2164
|
var css_248z$4 = ".Step-module_stepWrapper__1se3l {\n display: flex;\n align-items: center;\n padding-left: 8px;\n padding-right: 8px;\n transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\n}\n.Step-module_stepWrapper__1se3l.Step-module_hasLabel__3cdCU:not(.Step-module_disabled__1R7hh):hover {\n cursor: pointer;\n background-color: rgba(0, 0, 0, 0.04);\n border-radius: var(--borderRadius);\n}\n\n.Step-module_step__2siYu {\n width: 40px;\n height: 40px;\n position: relative;\n display: flex;\n align-items: center;\n justify-content: center;\n transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;\n}\n.Step-module_step__2siYu:not(.Step-module_hasLabel__3cdCU):not(.Step-module_disabled__1R7hh):hover {\n border-radius: 100%;\n cursor: pointer;\n background-color: rgba(0, 0, 0, 0.04);\n}\n.Step-module_step__2siYu.Step-module_hasLabel__3cdCU svg {\n width: 18px !important;\n height: 18px !important;\n}\n\n.Step-module_stepIconCircle__3IyDn svg {\n width: 24px;\n height: 24px;\n}\n\n.Step-module_stepValue__2TVrP {\n position: absolute;\n color: var(--secondary-contrast-text);\n}\n.Step-module_stepValue__2TVrP .Step-module_isActive__1QTL4 {\n color: var(--primary-contrast-text);\n}";
|
|
2130
2165
|
var styles$4 = {"stepWrapper":"Step-module_stepWrapper__1se3l","hasLabel":"Step-module_hasLabel__3cdCU","disabled":"Step-module_disabled__1R7hh","step":"Step-module_step__2siYu","stepIconCircle":"Step-module_stepIconCircle__3IyDn","stepValue":"Step-module_stepValue__2TVrP","isActive":"Step-module_isActive__1QTL4"};
|
|
2131
2166
|
styleInject(css_248z$4);
|
|
@@ -2525,5 +2560,5 @@ const TreeView = (props) => {
|
|
|
2525
2560
|
})));
|
|
2526
2561
|
};
|
|
2527
2562
|
|
|
2528
|
-
export { Alert, AppBar, AppBarTitle, AutoComplete, Backdrop, Badge, Breadcrumb, BreadcrumbItem, Button, ButtonGroup, COLOR, Card, CardBody, CardFooter, CardImage, CardSubtitle, CardText, CardTitle, CaretDownSolidIcon, CheckSolidIcon, CheckSquareRegularIcon, Checkbox, ChevronDownSolidIcon, ChevronLeftSolidIcon, ChevronRightSolidIcon, ChevronUpSolidIcon, Chip, CircleSolidIcon, Column, ConditionalWrapper, DATEMODE, DateSelect, DaySelect, Drawer, EmailValidator, ExpansionPanel, ExpansionPanelContent, ExpansionPanelHeader, FileInput, FloatingActionButton, Form, FormControl, FormError, FormGroup, FormHint, FormInput, FormLabel, GlobalModal, HomeSolidIcon, HourSelect, Icon, IconButton, IsEmptyValidator, IsEqualValidator, Link, List, ListItem, ListItemAction, ListItemAvatar, ListItemIcon, ListItemText, LoadingIndicator, LoadingIndicatorContainer, MODALBUTTONTYPE, MODALTYPE, Menu, MenuBody, MenuDivider, MenuItem, MenuToggle, MilliSecondSelect, MinuteSelect, Modal, ModalBody, ModalFooter, ModalHeader, MonthSelect, NumberSelect, POSITION, PlusSolidIcon, Row, SIZE, STATUS, SecondSelect, Select, Sidebar, Snackbar, SpeedDial, SpeedDialAction, SpeedDialIcon, SpinnerSolidIcon, SquareRegularIcon, Step, Stepper, StepperActions, TIMEMODE, Tab, TabPanel, Table, Tabs, Textarea, TimeSelect, TimesCircleSolidIcon, TimesSolidIcon, Tooltip, TreeView, Typography, VARIANT, YearSelect, loadingIndicatorService, modalService, snackbarService, useConstructor, useHover, useWindowSize };
|
|
2563
|
+
export { Alert, AppBar, AppBarTitle, AutoComplete, Backdrop, Badge, Breadcrumb, BreadcrumbItem, Button, ButtonGroup, COLOR, Card, CardBody, CardFooter, CardImage, CardSubtitle, CardText, CardTitle, CaretDownSolidIcon, CheckSolidIcon, CheckSquareRegularIcon, Checkbox, ChevronDownSolidIcon, ChevronLeftSolidIcon, ChevronRightSolidIcon, ChevronUpSolidIcon, Chip, CircleSolidIcon, Column, ConditionalWrapper, DATEMODE, DateSelect, DaySelect, Drawer, EmailValidator, ExpansionPanel, ExpansionPanelContent, ExpansionPanelHeader, FileInput, FloatingActionButton, Form, FormControl, FormError, FormGroup, FormHint, FormInput, FormLabel, GlobalModal, HomeSolidIcon, HourSelect, Icon, IconButton, IsEmptyValidator, IsEqualValidator, Link, List, ListItem, ListItemAction, ListItemAvatar, ListItemIcon, ListItemText, LoadingIndicator, LoadingIndicatorContainer, MODALBUTTONTYPE, MODALTYPE, Menu, MenuBody, MenuDivider, MenuItem, MenuToggle, MilliSecondSelect, MinuteSelect, Modal, ModalBody, ModalFooter, ModalHeader, MonthSelect, NumberSelect, POSITION, PlusSolidIcon, Row, SIZE, STATUS, SecondSelect, Select, Sidebar, Snackbar, SpeedDial, SpeedDialAction, SpeedDialIcon, SpinnerSolidIcon, SquareRegularIcon, Step, Stepper, StepperActions, TIMEMODE, Tab, TabPanel, Table, Tabs, Textarea, TimeSelect, TimesCircleSolidIcon, TimesSolidIcon, Tooltip, TreeView, Typography, VARIANT, YearSelect, loadingIndicatorService, modalService, snackbarService, useConstructor, useDebounce, useHover, useWindowSize };
|
|
2529
2564
|
//# sourceMappingURL=index.es.js.map
|