grep-components 2.4.0-GREPF-2436-test.1 → 2.4.0-GREPF-2422.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.
|
@@ -13,8 +13,6 @@ export type GrepSelectProps = SelectProps & {
|
|
|
13
13
|
errorMessage?: string;
|
|
14
14
|
selectItems: SelectItem[];
|
|
15
15
|
unselectOption?: boolean;
|
|
16
|
-
unselectOptionBottom?: boolean;
|
|
17
|
-
defaultHighlight?: string;
|
|
18
16
|
useCheckedSelect?: boolean;
|
|
19
17
|
inputProps?: InputBaseComponentProps | undefined;
|
|
20
18
|
};
|
package/dist/index.js
CHANGED
|
@@ -2646,8 +2646,7 @@ const GrepSelect = (props) => {
|
|
|
2646
2646
|
React.useEffect(() => {
|
|
2647
2647
|
setLabelWidth(inputLabel.current.offsetWidth);
|
|
2648
2648
|
}, []);
|
|
2649
|
-
const { unselectOption = true,
|
|
2650
|
-
const [highlightValue, setHighlightValue] = React.useState('');
|
|
2649
|
+
const { unselectOption = true, errorMessage, selectItems, helperText, fullWidth, outlined, disabled, required, label, inputProps, value, size, id, useCheckedSelect, ...rest } = props;
|
|
2651
2650
|
const error = errorMessage ? errorMessage.length > 0 : false;
|
|
2652
2651
|
const selected = value;
|
|
2653
2652
|
return (React.createElement(FormControl, { variant: outlined ? 'outlined' : 'standard', className: props.className, fullWidth: fullWidth, required: required, style: props.style, error: error, size: size, disabled: disabled },
|
|
@@ -2655,29 +2654,7 @@ const GrepSelect = (props) => {
|
|
|
2655
2654
|
minWidth: 'max-content',
|
|
2656
2655
|
overflow: 'visible',
|
|
2657
2656
|
} }, label),
|
|
2658
|
-
React.createElement(Select, { ...rest, inputProps: { id, ...inputProps },
|
|
2659
|
-
if (highlightValue) {
|
|
2660
|
-
props.onOpen && props.onOpen(e);
|
|
2661
|
-
return;
|
|
2662
|
-
}
|
|
2663
|
-
if (selectItems.length > 0 && defaultHighlight !== '') {
|
|
2664
|
-
const index = selectItems.findIndex((e) => e.value === defaultHighlight);
|
|
2665
|
-
if (index >= 0) {
|
|
2666
|
-
setHighlightValue(defaultHighlight);
|
|
2667
|
-
}
|
|
2668
|
-
}
|
|
2669
|
-
props.onOpen && props.onOpen(e);
|
|
2670
|
-
}, onChange: (e, c) => {
|
|
2671
|
-
//console.log(highlightValue, e.target.value);
|
|
2672
|
-
if (highlightValue === e.target.value) {
|
|
2673
|
-
setHighlightValue('');
|
|
2674
|
-
//console.log('asdlfjlasfjlkasd');
|
|
2675
|
-
}
|
|
2676
|
-
else {
|
|
2677
|
-
setHighlightValue(e.target.value);
|
|
2678
|
-
}
|
|
2679
|
-
props.onChange && props.onChange(e, c);
|
|
2680
|
-
}, disabled: !selectItems || disabled, value: value || highlightValue, style: { minWidth: labelWidth + (outlined ? 35 : 25) },
|
|
2657
|
+
React.createElement(Select, { ...rest, inputProps: { id, ...inputProps }, disabled: !selectItems || disabled, value: value === null ? '' : value, style: { minWidth: labelWidth + (outlined ? 35 : 25) },
|
|
2681
2658
|
// @todo: make input respect label length
|
|
2682
2659
|
input: outlined ? React.createElement(OutlinedInput, { label: label }) : React.createElement(Input, null), MenuProps: {
|
|
2683
2660
|
...rest.MenuProps,
|
|
@@ -2694,9 +2671,7 @@ const GrepSelect = (props) => {
|
|
|
2694
2671
|
React.createElement("em", null, "Fjern valgt"))),
|
|
2695
2672
|
selectItems.map(({ label, value, disabled, lang }, i) => (React.createElement(MenuItem$1, { key: i, value: value, disabled: disabled, lang: lang },
|
|
2696
2673
|
useCheckedSelect && (React.createElement(Checkbox, { checked: selected?.indexOf(value) > -1 })),
|
|
2697
|
-
React.createElement(ListItemText, { sx: { margin: '0px', span: { lineHeight: '1.4375em' } }, primary: label ? label : value })))),
|
|
2698
|
-
unselectOptionBottom && (React.createElement(MenuItem$1, { value: "" },
|
|
2699
|
-
React.createElement("em", null, "Fjern valgt")))),
|
|
2674
|
+
React.createElement(ListItemText, { sx: { margin: '0px', span: { lineHeight: '1.4375em' } }, primary: label ? label : value }))))),
|
|
2700
2675
|
React.createElement(FormHelperText, null, errorMessage || helperText)));
|
|
2701
2676
|
};
|
|
2702
2677
|
|