@cwncollab-org/mui-component-kit 0.14.0 → 0.14.1
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.
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { BoxProps as MuiBoxProps } from '@mui/material';
|
|
1
|
+
import { BoxProps as MuiBoxProps, FormControlProps as MuiFormControlProps, ListProps as MuiListProps } from '@mui/material';
|
|
2
2
|
export type CheckboxListProps<TOption = string | any> = {
|
|
3
3
|
label?: string;
|
|
4
4
|
labelBehavior?: 'auto' | 'shrink' | 'static';
|
|
5
|
-
|
|
5
|
+
fullWidth?: MuiFormControlProps['fullWidth'];
|
|
6
|
+
options?: TOption[];
|
|
7
|
+
dense?: MuiListProps['dense'];
|
|
6
8
|
disabled?: boolean;
|
|
7
9
|
isLoading?: boolean;
|
|
8
10
|
getOptionLabel?: (option: TOption) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxList.d.ts","sourceRoot":"","sources":["../../src/lib/form/CheckboxList.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"CheckboxList.d.ts","sourceRoot":"","sources":["../../src/lib/form/CheckboxList.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,IAAI,WAAW,EAGvB,gBAAgB,IAAI,mBAAmB,EAQvC,SAAS,IAAI,YAAY,EAE1B,MAAM,eAAe,CAAA;AAKtB,MAAM,MAAM,iBAAiB,CAAC,OAAO,GAAG,MAAM,GAAG,GAAG,IAAI;IACtD,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,aAAa,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAA;IAC5C,SAAS,CAAC,EAAE,mBAAmB,CAAC,WAAW,CAAC,CAAA;IAC5C,OAAO,CAAC,EAAE,OAAO,EAAE,CAAA;IACnB,KAAK,CAAC,EAAE,YAAY,CAAC,OAAO,CAAC,CAAA;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAA;IAC5C,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,CAAA;IAC5C,oBAAoB,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;IACrE,EAAE,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,CAAA;CACvB,CAAA;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,2CA2GpD"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { Box as MuiBox, Checkbox as MuiCheckbox, FormControl as MuiFormControl, FormHelperText as MuiFormHelperText, FormLabel as MuiFormLabel, List as MuiList, ListItem as MuiListItem, ListItemButton as MuiListItemButton, ListItemIcon as MuiListItemIcon, ListItemText as MuiListItemText, Skeleton, } from '@mui/material';
|
|
3
3
|
import { useMemo } from 'react';
|
|
4
4
|
import { useFieldContext } from './formContext';
|
|
5
5
|
import { renderOptions } from './utils';
|
|
6
6
|
export function CheckboxList(props) {
|
|
7
|
-
const { disabled, isLoading, sx, label, labelBehavior = 'auto', options, getOptionLabel, getOptionValue, getOptionDescription, ...rest } = props;
|
|
7
|
+
const { disabled, isLoading, sx, label, labelBehavior = 'auto', fullWidth, options, dense, getOptionLabel, getOptionValue, getOptionDescription, ...rest } = props;
|
|
8
8
|
const field = useFieldContext();
|
|
9
9
|
const errorText = useMemo(() => {
|
|
10
10
|
if (field.state.meta.errors.length === 0)
|
|
@@ -26,9 +26,11 @@ export function CheckboxList(props) {
|
|
|
26
26
|
}
|
|
27
27
|
field.handleChange(newValues);
|
|
28
28
|
};
|
|
29
|
-
return (_jsxs(MuiFormControl, { error: !!errorText, component: 'fieldset', variant: 'standard', sx: sx, ...rest, children: [label && _jsx(MuiFormLabel, { component: 'legend', children: label }),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
return (_jsxs(MuiFormControl, { error: !!errorText, component: 'fieldset', variant: 'standard', fullWidth: fullWidth, sx: sx, ...rest, children: [label && _jsx(MuiFormLabel, { component: 'legend', children: label }), _jsx(MuiList, { dense: dense, role: 'group', "aria-label": label, children: isLoading
|
|
30
|
+
? Array.from({ length: 3 }).map((_, index) => (_jsx(MuiListItem, { disablePadding: true, children: _jsxs(MuiListItemButton, { dense: dense, disabled: true, children: [_jsx(MuiListItemIcon, { children: _jsx(MuiBox, { sx: { p: '9px', ml: '-11px', display: 'flex' }, children: _jsx(Skeleton, { variant: 'circular', width: 24, height: 24 }) }) }), _jsx(MuiListItemText, { primary: _jsx(Skeleton, { variant: 'text', width: '60%' }) })] }) }, index)))
|
|
31
|
+
: renderedOptions.map(option => {
|
|
32
|
+
const labelId = `checkbox-list-label-${option.value}`;
|
|
33
|
+
return (_jsx(MuiListItem, { disablePadding: true, children: _jsxs(MuiListItemButton, { role: undefined, onClick: handleToggle(option.value), dense: dense, disabled: disabled, children: [_jsx(MuiListItemIcon, { children: _jsx(MuiCheckbox, { edge: 'start', checked: (field.state.value || []).indexOf(option.value) !== -1, tabIndex: -1, disableRipple: true, slotProps: { input: { 'aria-labelledby': labelId } } }) }), _jsx(MuiListItemText, { id: labelId, primary: option.label, secondary: option.description })] }) }, option.value));
|
|
34
|
+
}) }), errorText && _jsx(MuiFormHelperText, { children: errorText })] }));
|
|
33
35
|
}
|
|
34
36
|
//# sourceMappingURL=CheckboxList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckboxList.js","sourceRoot":"","sources":["../../src/lib/form/CheckboxList.tsx"],"names":[],"mappings":";AAAA,OAAO,EACL,
|
|
1
|
+
{"version":3,"file":"CheckboxList.js","sourceRoot":"","sources":["../../src/lib/form/Check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