@nethru/ui 2.1.55 → 2.1.57

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.
@@ -0,0 +1,77 @@
1
+ import { forwardRef, useCallback, useMemo, useState } from "react";
2
+ import { Autocomplete, createFilterOptions, FormControl, FormHelperText } from "@mui/material";
3
+ import { TextField } from "./index";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { jsxs as _jsxs } from "react/jsx-runtime";
6
+ const AddableSelect = /*#__PURE__*/forwardRef(({
7
+ label,
8
+ placeholder = '새 값을 입력하거나 선택해주세요',
9
+ helperText,
10
+ value,
11
+ options,
12
+ onInputChange,
13
+ error,
14
+ fullWidth,
15
+ formControlProps,
16
+ ...props
17
+ }, ref) => {
18
+ const styles = useMemo(() => ({
19
+ mt: label ? '17px' : undefined,
20
+ ...formControlProps?.sx
21
+ }), [label, formControlProps]);
22
+ const [inputValue, setInputValue] = useState('');
23
+ const [open, setOpen] = useState(false);
24
+ const getOptionLabel = useCallback(option => typeof option === 'string' ? option : option.label ?? '', []);
25
+ const filter = useMemo(() => createFilterOptions({
26
+ stringify: getOptionLabel
27
+ }), [getOptionLabel]);
28
+ const filteredOptions = useMemo(() => {
29
+ return filter(options, {
30
+ inputValue,
31
+ getOptionLabel
32
+ });
33
+ }, [filter, options, inputValue, getOptionLabel]);
34
+ const handleInputChange = useCallback((event, newValue, reason) => {
35
+ if (onInputChange) onInputChange(event, newValue, reason);
36
+ setInputValue(newValue);
37
+ if (reason !== 'input') {
38
+ setOpen(false);
39
+ return;
40
+ }
41
+ const nextFiltered = filter(options, {
42
+ inputValue: newValue,
43
+ getOptionLabel
44
+ });
45
+ setOpen(nextFiltered.length > 0);
46
+ }, [filter, options, getOptionLabel, onInputChange]);
47
+ return /*#__PURE__*/_jsxs(FormControl, {
48
+ ref: ref,
49
+ disabled: props.disabled,
50
+ error: error,
51
+ sx: styles,
52
+ fullWidth: fullWidth,
53
+ ...formControlProps,
54
+ children: [/*#__PURE__*/_jsx(Autocomplete, {
55
+ freeSolo: true,
56
+ options: options,
57
+ value: value ?? '',
58
+ inputValue: inputValue,
59
+ open: open && filteredOptions.length > 0,
60
+ onOpen: () => {
61
+ if (filteredOptions.length > 0) setOpen(true);
62
+ },
63
+ onClose: () => setOpen(false),
64
+ onInputChange: handleInputChange,
65
+ filterOptions: (opts, state) => filter(opts, state),
66
+ renderInput: params => /*#__PURE__*/_jsx(TextField, {
67
+ ...params,
68
+ label: label,
69
+ placeholder: placeholder
70
+ }),
71
+ ...props
72
+ }), helperText && /*#__PURE__*/_jsx(FormHelperText, {
73
+ children: helperText
74
+ })]
75
+ });
76
+ });
77
+ export default AddableSelect;
@@ -40,21 +40,28 @@ const DataGrid = /*#__PURE__*/forwardRef(({
40
40
  footer: Footer,
41
41
  ...slots
42
42
  },
43
+ slotProps: {
44
+ toolbar: {
45
+ toolbarLeadingSlot
46
+ }
47
+ },
43
48
  ...props
44
49
  });
45
- function Toolbar() {
46
- return /*#__PURE__*/_jsxs(Stack, {
47
- direction: "row",
48
- justifyContent: "space-between",
49
- mb: 1.5,
50
- children: [/*#__PURE__*/_jsx(Box, {
51
- children: toolbarLeadingSlot
52
- }), /*#__PURE__*/_jsx(Box, {
53
- children: /*#__PURE__*/_jsx(GridToolbarQuickFilter, {
54
- variant: "outlined"
55
- })
56
- })]
57
- });
58
- }
59
50
  });
51
+ function Toolbar({
52
+ toolbarLeadingSlot
53
+ }) {
54
+ return /*#__PURE__*/_jsxs(Stack, {
55
+ direction: "row",
56
+ justifyContent: "space-between",
57
+ mb: 1.5,
58
+ children: [/*#__PURE__*/_jsx(Box, {
59
+ children: toolbarLeadingSlot
60
+ }), /*#__PURE__*/_jsx(Box, {
61
+ children: /*#__PURE__*/_jsx(GridToolbarQuickFilter, {
62
+ variant: "outlined"
63
+ })
64
+ })]
65
+ });
66
+ }
60
67
  export default DataGrid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nethru/ui",
3
- "version": "2.1.55",
3
+ "version": "2.1.57",
4
4
  "main": "base/index.js",
5
5
  "files": [
6
6
  "/base"