ish-ui 1.3.3 → 1.3.5

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Ish UI
2
2
 
3
- UI elements for onCourse and other ish apps
3
+ UI elements for onCourse apps
4
4
 
5
5
  [![npm latest package](https://img.shields.io/npm/v/ish-ui/latest.svg)](https://www.npmjs.com/package/ish-ui)
6
6
 
@@ -77,7 +77,7 @@ const useStyles = makeAppStyles()(({ spacing, palette, zIndex, transitions }, p,
77
77
  marginBottom: spacing(1.25)
78
78
  },
79
79
  customAlfa: {
80
- '& > div > div:first-child > div': {
80
+ '& > div > div:first-of-type > div': {
81
81
  background: 'none !important'
82
82
  }
83
83
  },
@@ -1,5 +1,7 @@
1
1
  import React from 'react';
2
- interface AutosizeInputProps extends React.ComponentPropsWithRef<"input"> {
2
+ import { InputBaseComponentProps } from '@mui/material';
3
+ type InputElementProps = React.ComponentPropsWithRef<"input">;
4
+ interface AutosizeInputProps extends InputElementProps {
3
5
  placeholder?: string;
4
6
  /**
5
7
  * Space kept free after the text, in px. Defaults to the advance width of a
@@ -9,6 +11,7 @@ interface AutosizeInputProps extends React.ComponentPropsWithRef<"input"> {
9
11
  reserveWidth?: number;
10
12
  /** MUI InputBase hands the DOM node over through this prop instead of `ref`. */
11
13
  inputRef?: React.Ref<HTMLInputElement>;
14
+ inputComponent?: React.ElementType<InputBaseComponentProps> | undefined;
12
15
  }
13
16
  export declare const AutosizeInput: React.FC<AutosizeInputProps>;
14
17
  export {};
@@ -86,8 +86,7 @@ const getSpaceWidth = (probe, typographySignature) => {
86
86
  return spaceWidth;
87
87
  };
88
88
  export const AutosizeInput = (_a) => {
89
- var { placeholder, reserveWidth, inputRef, ref } = _a, props = __rest(_a, ["placeholder", "reserveWidth", "inputRef", "ref"]);
90
- const [value, setValue] = useState(props.value || "");
89
+ var { placeholder, inputComponent, reserveWidth, inputRef, ref, value } = _a, props = __rest(_a, ["placeholder", "inputComponent", "reserveWidth", "inputRef", "ref", "value"]);
91
90
  const [width, setWidth] = useState(0);
92
91
  const spanRef = useRef(null);
93
92
  const probeRef = useRef(null);
@@ -143,14 +142,20 @@ export const AutosizeInput = (_a) => {
143
142
  return () => fonts.removeEventListener("loadingdone", onLoadingDone);
144
143
  }, [measure]);
145
144
  const handleChange = (e) => {
146
- setValue(e.target.value);
147
145
  if (props.onChange)
148
146
  props.onChange(e);
149
147
  };
148
+ // `React.ElementType<InputBaseComponentProps>` widens to every intrinsic tag,
149
+ // because InputBaseComponentProps carries an `[arbitrary: string]: any` index
150
+ // signature. The prop keeps that type for compatibility with MUI's InputBase,
151
+ // but rendering needs the narrower, input shaped contract this component
152
+ // actually passes. Falling back to the `input` tag rather than a wrapper
153
+ // component also keeps the element identity stable across renders.
154
+ const InputElement = (inputComponent !== null && inputComponent !== void 0 ? inputComponent : "input");
150
155
  return (React.createElement("div", { style: { display: "inline-block", position: "relative" } },
151
156
  React.createElement("span", { ref: spanRef, style: measureStyle, "aria-hidden": true }, value || placeholder || ""),
152
157
  React.createElement("span", { ref: probeRef, style: measureStyle, "aria-hidden": true }),
153
- React.createElement("input", Object.assign({}, props, { ref: setInputNode, type: "text", value: value, onChange: handleChange, placeholder: placeholder, style: Object.assign(Object.assign({}, props.style), { letterSpacing: "inherit", textTransform: "inherit", width: `${width}px`, boxSizing: "border-box",
158
+ React.createElement(InputElement, Object.assign({}, props, { ref: setInputNode, type: "text", value: value, onChange: handleChange, placeholder: placeholder, style: Object.assign(Object.assign({}, props.style), { letterSpacing: "inherit", textTransform: "inherit", width: `${width}px`, boxSizing: "border-box",
154
159
  // CRITICAL: Padding and borders must be 0, the measuring span has none either
155
160
  paddingLeft: 0, paddingRight: 0, borderLeft: "none", borderRight: "none", margin: 0, textOverflow: "unset" }) }))));
156
161
  };
@@ -37,14 +37,14 @@ const useStyles = makeAppStyles()((theme, p, classes) => ({
37
37
  },
38
38
  hideArrows: {
39
39
  '&::-webkit-outer-spin-button': {
40
- '-webkit-appearance': 'none',
40
+ 'WebkitAppearance': 'none',
41
41
  margin: 0
42
42
  },
43
43
  '&::-webkit-inner-spin-button': {
44
- '-webkit-appearance': 'none',
44
+ 'WebkitAppearance': 'none',
45
45
  margin: 0
46
46
  },
47
- '-moz-appearance': 'textfield'
47
+ 'MozAppearance': 'textfield'
48
48
  },
49
49
  inlineInput: {
50
50
  padding: 0,
@@ -73,6 +73,11 @@ const EditInPlaceFieldBase = ({ invalid, className, inline, label, fieldClasses
73
73
  return OutlinedInput;
74
74
  }
75
75
  }, [variant]);
76
+ const inputComponent = useMemo((props) => inline
77
+ ? (InputProps === null || InputProps === void 0 ? void 0 : InputProps.inputComponent)
78
+ ? props => React.createElement(AutosizeInput, Object.assign({}, props, { inputComponent: InputProps.inputComponent }))
79
+ : AutosizeInput
80
+ : InputProps === null || InputProps === void 0 ? void 0 : InputProps.inputComponent, [inline, InputProps === null || InputProps === void 0 ? void 0 : InputProps.inputComponent]);
76
81
  return (React.createElement(FormControl, { fullWidth: true, error: invalid, variant: variant, margin: "none", className: cx(className, classes.inputWrapper) },
77
82
  label && (React.createElement(InputLabel, { classes: {
78
83
  root: cx(fieldClasses.label, 'd-flex', 'overflow-visible', rightAligned && classes.rightLabel),
@@ -80,7 +85,7 @@ const EditInPlaceFieldBase = ({ invalid, className, inline, label, fieldClasses
80
85
  React.createElement("span", { className: classes.label }, label),
81
86
  labelAdornment)),
82
87
  CustomInput ||
83
- React.createElement(InputComp, Object.assign({}, InputProps || {}, { inputComponent: inline ? AutosizeInput : undefined, inputRef: inputNode, inputProps: Object.assign({ placeholder,
88
+ React.createElement(InputComp, Object.assign({}, InputProps || {}, { inputComponent: inputComponent, inputRef: inputNode, inputProps: Object.assign({ placeholder,
84
89
  disabled, className: cx(fieldClasses.text, {
85
90
  [classes.inlineInput]: inline,
86
91
  [classes.readonly]: disabled,
@@ -34,7 +34,7 @@ function EditInPlaceMoneyField(_a) {
34
34
  var _b;
35
35
  var { InputProps, currencySymbol, className } = _a, restProps = __rest(_a, ["InputProps", "currencySymbol", "className"]);
36
36
  const { cx } = useStyles();
37
- return (React.createElement(EditInPlaceField, Object.assign({}, restProps, { preformatDisplayValue: preformatDisplayValue, InputProps: Object.assign(Object.assign({}, InputProps), { startAdornment: React.createElement(InputAdornment, { position: "start", className: (_b = restProps.fieldClasses) === null || _b === void 0 ? void 0 : _b.text },
37
+ return (React.createElement(EditInPlaceField, Object.assign({}, restProps, { preformatDisplayValue: preformatDisplayValue, InputProps: Object.assign(Object.assign({}, InputProps), { startAdornment: React.createElement(InputAdornment, { position: "start", className: cx((_b = restProps.fieldClasses) === null || _b === void 0 ? void 0 : _b.text, restProps.inline && 'mr-0-5') },
38
38
  React.createElement("span", null, currencySymbol)), inputComponent: NumberFormatCustom }), className: cx('money', className) })));
39
39
  }
40
40
  export default EditInPlaceMoneyField;
@@ -219,6 +219,9 @@ function EditInPlaceSearchSelect({ label, disabled, className, labelAdornment, i
219
219
  if (typeof itemRenderer === 'function') {
220
220
  return [itemRenderer(getHighlightedPartLabel(getOptionLabel(data), searchValue), data, searchValue, optionProps), optionProps];
221
221
  }
222
+ if (inline || categoryKey) {
223
+ return getHighlightedPartLabel(getOptionLabel(data), searchValue, optionProps);
224
+ }
222
225
  return [getHighlightedPartLabel(getOptionLabel(data), searchValue), optionProps];
223
226
  };
224
227
  const selectedOption = useMemo(() => sortedItems.find(i => multiple
@@ -268,7 +271,7 @@ function EditInPlaceSearchSelect({ label, disabled, className, labelAdornment, i
268
271
  : (React.createElement("div", null,
269
272
  allowEmpty && input.value && (React.createElement(IconButton, { size: "small", onClick: onClear, color: "inherit" },
270
273
  React.createElement(CloseIcon, { fontSize: "inherit" }))),
271
- editIcon === undefined ? React.createElement(IconButton, { size: "small", color: "inherit", className: cx(classes.expandIcon, 'pl-0 pr-0'), disableRipple: true },
274
+ editIcon === undefined ? React.createElement(IconButton, { size: "small", color: "inherit", className: cx(classes.expandIcon, 'pl-0 pr-0', inline && 'p-0'), disableRipple: true },
272
275
  React.createElement(ExpandMore, { className: inline && 'fsInherit' })) : editIcon))), [disabled, loading, inline, allowEmpty, input.value]);
273
276
  const inputValue = useMemo(() => {
274
277
  if (multiple) {
@@ -23,8 +23,8 @@ export const animateStyles = Object.assign(Object.assign(Object.assign(Object.as
23
23
  from: Object.assign(Object.assign({}, transform('translate3d(80px, 0, 0)')), prefixer('animationDuration', '0.5s', ['webkit', 'spec'])),
24
24
  to: Object.assign(Object.assign({}, transform('translate3d(0px, 0, 0)')), prefixer('animationDuration', '0s', ['webkit', 'spec']))
25
25
  })), keyframes('rotateOutCustom', {
26
- from: Object.assign({}, prefixer('transform-origin', 'center', ['webkit', 'spec'])),
27
- to: Object.assign(Object.assign({}, transform('rotate3d(0, 0, 1, 720deg)')), prefixer('transform-origin', 'center', ['webkit', 'spec']))
26
+ from: Object.assign({}, prefixer('transformOrigin', 'center', ['webkit', 'spec'])),
27
+ to: Object.assign(Object.assign({}, transform('rotate3d(0, 0, 1, 720deg)')), prefixer('transformOrigin', 'center', ['webkit', 'spec']))
28
28
  }, Object.assign({}, prefixer('animationDuration', '2.5s', ['webkit', 'spec'])))), keyframes('shake', {
29
29
  '10%, 90%': Object.assign({}, transform('translate3d(-2px, 0, 0)')),
30
30
  '20%, 80%': Object.assign({}, transform('translate3d(4px, 0, 0)')),
@@ -189,7 +189,7 @@ function TagInputList({ input, tags, placeholder, labelAdornment, meta, label =
189
189
  return (React.createElement("div", { className: className, id: input.name },
190
190
  React.createElement("div", { className: cx('relative', {
191
191
  'pointer-events-none': disabled
192
- }) }, React.createElement(Autocomplete, { value: input.value, multiple: true, open: menuIsOpen, options: filteredOptions, onBlur: exit, onChange: handleChange, renderOption: renderOption, filterOptions: filterOptionsInner, getOptionLabel: getOptionLabel, slots: {
192
+ }) }, React.createElement(Autocomplete, { value: (input === null || input === void 0 ? void 0 : input.value) || [], multiple: true, open: menuIsOpen, options: filteredOptions, onBlur: exit, onChange: handleChange, renderOption: renderOption, filterOptions: filterOptionsInner, getOptionLabel: getOptionLabel, slots: {
193
193
  popper: inputValue || !trackCarretPosition ? undefined : popperAdapter,
194
194
  listbox: inputValue ? undefined : listboxAdapter
195
195
  }, classes: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ish-ui",
3
3
  "sideEffects": false,
4
- "version": "1.3.3",
4
+ "version": "1.3.5",
5
5
  "description": "UI elements for onCourse and other ish apps",
6
6
  "main": "main.ts",
7
7
  "devDependencies": {