ish-ui 1.3.8 → 1.4.0
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.
|
@@ -113,16 +113,19 @@ const ColorPickerBase = React.memo(({ color, input: { value, onChange }, Transit
|
|
|
113
113
|
const [hueColor, setHueColor] = useState(color);
|
|
114
114
|
const [alfaColor, setAlfaColor] = useState(color);
|
|
115
115
|
const hueRef = useRef(undefined);
|
|
116
|
-
const
|
|
117
|
-
setHueColor(color.hsv);
|
|
118
|
-
setAlfaColor(color.hsv);
|
|
119
|
-
}, []);
|
|
120
|
-
const onAlfaChange = useCallback(color => {
|
|
116
|
+
const onColorChange = useCallback(color => {
|
|
121
117
|
setHueColor({
|
|
122
118
|
h: color.hsv.h, s: color.hsv.a, v: color.hsv.v, a: 1
|
|
123
119
|
});
|
|
124
120
|
setAlfaColor(color.hsv);
|
|
125
121
|
}, []);
|
|
122
|
+
const onChangeComplete = (color) => {
|
|
123
|
+
var _a, _b;
|
|
124
|
+
const hex = ((_b = (_a = hueRef.current) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.hex) || (color === null || color === void 0 ? void 0 : color.hex);
|
|
125
|
+
if (hex) {
|
|
126
|
+
onChange(hex.replace('#', ''));
|
|
127
|
+
}
|
|
128
|
+
};
|
|
126
129
|
const handleClickAway = useCallback(() => {
|
|
127
130
|
setAnchorEl(null);
|
|
128
131
|
}, []);
|
|
@@ -141,28 +144,18 @@ const ColorPickerBase = React.memo(({ color, input: { value, onChange }, Transit
|
|
|
141
144
|
h: hueHsv.h, s: 1, v: hueHsv.v, a: hueHsv.s
|
|
142
145
|
});
|
|
143
146
|
}, [hueRef.current]);
|
|
144
|
-
const onMaterialChange = useCallback(color => {
|
|
145
|
-
setHueColor(color.hsv);
|
|
146
|
-
}, []);
|
|
147
|
-
const onChangeComplete = (color) => {
|
|
148
|
-
var _a, _b;
|
|
149
|
-
const hex = ((_b = (_a = hueRef.current) === null || _a === void 0 ? void 0 : _a.state) === null || _b === void 0 ? void 0 : _b.hex) || (color === null || color === void 0 ? void 0 : color.hex);
|
|
150
|
-
if (hex) {
|
|
151
|
-
onChange(hex.replace('#', ''));
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
147
|
return (React.createElement(ClickAwayListener, { onClickAway: handleClickAway },
|
|
155
148
|
React.createElement(Grow, Object.assign({}, TransitionProps, { timeout: 200 }),
|
|
156
149
|
React.createElement(Paper, { className: classes.paper },
|
|
157
150
|
React.createElement("span", { className: classes.arrow, "data-popper-arrow": true }),
|
|
158
|
-
React.createElement(HuePicker, { ref: hueRef, color: hueColor, onChange:
|
|
159
|
-
React.createElement(AlphaPicker, { className: classes.customAlfa, color: alfaColor, width: "168", onChange:
|
|
151
|
+
React.createElement(HuePicker, { ref: hueRef, color: hueColor, onChange: onColorChange, onChangeComplete: onChangeComplete, width: "168", className: classes.bottomOffset }),
|
|
152
|
+
React.createElement(AlphaPicker, { className: classes.customAlfa, color: alfaColor, width: "168", onChange: onColorChange, onChangeComplete: onChangeComplete }),
|
|
160
153
|
React.createElement("div", { className: classes.material },
|
|
161
154
|
React.createElement(MaterialPicker, { styles: {
|
|
162
155
|
default: {
|
|
163
156
|
material: { width: '100%', height: 'unset', padding: 0, fontFamily: 'inherit' }
|
|
164
157
|
}
|
|
165
|
-
}, color: hueColor, onChange:
|
|
158
|
+
}, color: hueColor, onChange: onColorChange, onChangeComplete: onChangeComplete }))))));
|
|
166
159
|
});
|
|
167
160
|
const ColorPickerWrapper = React.memo(({ input, placement = 'top', width }) => {
|
|
168
161
|
const { classes, cx } = useStyles();
|
package/dist/model/Fields.d.ts
CHANGED
|
@@ -32,9 +32,9 @@ export interface MenuTag<T> {
|
|
|
32
32
|
queryPrefix?: string;
|
|
33
33
|
indeterminate?: boolean;
|
|
34
34
|
}
|
|
35
|
-
export interface FieldInputProps {
|
|
35
|
+
export interface FieldInputProps<T = any> {
|
|
36
36
|
checked?: boolean | undefined;
|
|
37
|
-
value:
|
|
37
|
+
value: T;
|
|
38
38
|
name: string;
|
|
39
39
|
onBlur: EventOrValueHandler<FocusEvent<any>>;
|
|
40
40
|
onChange: EventOrValueHandler<ChangeEvent<any>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FieldInputProps, FieldMetaProps, TagLike, TagsFieldProps } from '../model';
|
|
3
|
-
declare function TagInputList<T extends TagLike, IP extends FieldInputProps
|
|
3
|
+
declare function TagInputList<T extends TagLike, IP extends FieldInputProps<TagLike['id'][]>, MP extends FieldMetaProps>({ input, tags, placeholder, labelAdornment, meta, label, disabled, className, warning, allowParentSelect, fieldClasses, editIcon, variant, hideColor, trackCarretPosition }: TagsFieldProps<T, IP, MP>): React.JSX.Element;
|
|
4
4
|
export default TagInputList;
|
|
@@ -110,8 +110,9 @@ function TagInputList({ input, tags, placeholder, labelAdornment, meta, label =
|
|
|
110
110
|
const tagMenuNode = useRef(undefined);
|
|
111
111
|
const menuTags = useMemo(() => (tags && input.value ? getMenuTags(tags.filter(t => allowParentSelect || t.childrenCount > 0), input.value) : []), [tags, input.value, allowParentSelect]);
|
|
112
112
|
const allMenuTags = useMemo(() => getAllMenuTags(menuTags), [menuTags]);
|
|
113
|
+
const normalizedValue = useMemo(() => { var _a; return ((_a = input === null || input === void 0 ? void 0 : input.value) === null || _a === void 0 ? void 0 : _a.filter(id => allMenuTags.some(t => t.tagBody.id === id))) || []; }, [input.value, allMenuTags]);
|
|
113
114
|
const onTagAdd = (tag) => {
|
|
114
|
-
const updated = [...
|
|
115
|
+
const updated = [...normalizedValue];
|
|
115
116
|
const index = updated.findIndex(id => id === tag.tagBody.id);
|
|
116
117
|
if (index !== -1) {
|
|
117
118
|
updated.splice(index, 1);
|
|
@@ -189,7 +190,7 @@ function TagInputList({ input, tags, placeholder, labelAdornment, meta, label =
|
|
|
189
190
|
return (React.createElement("div", { className: className, id: input.name },
|
|
190
191
|
React.createElement("div", { className: cx('relative', {
|
|
191
192
|
'pointer-events-none': disabled
|
|
192
|
-
}) }, React.createElement(Autocomplete, { value:
|
|
193
|
+
}) }, React.createElement(Autocomplete, { value: normalizedValue, multiple: true, open: menuIsOpen, options: filteredOptions, onBlur: exit, onChange: handleChange, renderOption: renderOption, filterOptions: filterOptionsInner, getOptionLabel: getOptionLabel, slots: {
|
|
193
194
|
popper: inputValue || !trackCarretPosition ? undefined : popperAdapter,
|
|
194
195
|
listbox: inputValue ? undefined : listboxAdapter
|
|
195
196
|
}, classes: {
|
|
@@ -224,12 +225,15 @@ function TagInputList({ input, tags, placeholder, labelAdornment, meta, label =
|
|
|
224
225
|
color: textColors.dark
|
|
225
226
|
}
|
|
226
227
|
} })));
|
|
227
|
-
}), renderInput: (_a) => {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
228
|
+
}), renderInput: (_a) => {
|
|
229
|
+
var { slotProps: { input: InputProps, htmlInput: inputProps } } = _a, params = __rest(_a, ["slotProps"]);
|
|
230
|
+
return (React.createElement(EditInPlaceFieldBase, Object.assign({}, params, { value: inputValue, variant: variant, name: input.name, error: meta.error, invalid: meta === null || meta === void 0 ? void 0 : meta.invalid, label: label, warning: warning, disabled: disabled, fieldClasses: fieldClasses, shrink: Boolean(label || input.value), labelAdornment: labelAdornment, placeholder: normalizedValue.length ? '' : placeholder, editIcon: editIcon === undefined ? React.createElement(Edit, { className: classes.expandIcon }) : editIcon, InputProps: Object.assign(Object.assign({}, InputProps), { endAdornment: null, onChange: handleInputChange, onFocus, classes: {
|
|
231
|
+
underline: fieldClasses.underline,
|
|
232
|
+
input: cx(disabled && classes.readonly, fieldClasses.text),
|
|
233
|
+
}, inputProps: Object.assign(Object.assign({}, inputProps), { ref: ref => {
|
|
234
|
+
inputProps.ref.current = ref;
|
|
235
|
+
inputNode.current = ref;
|
|
236
|
+
}, className: cx(inputProps.className, fieldClasses.text, 'mr-auto') }) }) })));
|
|
237
|
+
}, popupIcon: stubComponent(), disableListWrap: true, openOnFocus: true }))));
|
|
234
238
|
}
|
|
235
239
|
export default TagInputList;
|