@etsoo/materialui 1.1.75 → 1.1.76

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/lib/SearchBar.js CHANGED
@@ -170,6 +170,7 @@ export function SearchBar(props) {
170
170
  moreItems.push(React.createElement(React.Fragment, { key: i }, fields[i]));
171
171
  }
172
172
  }
173
+ const hasMoreItems = moreItems.length > 0;
173
174
  // Handle main form
174
175
  const handleForm = (event) => {
175
176
  if (event.nativeEvent.cancelable && !event.nativeEvent.composed)
@@ -217,13 +218,20 @@ export function SearchBar(props) {
217
218
  delayed.clear();
218
219
  };
219
220
  }, [className]);
221
+ React.useEffect(() => {
222
+ if (!hasMoreItems || state.form == null)
223
+ return;
224
+ const stack = state.form.querySelector(".SearchBarContainer");
225
+ if (stack)
226
+ stack.style.overflow = "visbile";
227
+ }, [hasMoreItems]);
220
228
  // Layout
221
229
  return (React.createElement(React.Fragment, null,
222
230
  React.createElement("form", { id: "SearchBarForm", className: className, onChange: handleForm, ref: (form) => {
223
231
  if (form)
224
232
  state.form = form;
225
233
  } },
226
- React.createElement(Stack, { ref: dimensions[0][0], justifyContent: "center", alignItems: "center", direction: "row", spacing: 1, width: "100%", overflow: "hidden", sx: {
234
+ React.createElement(Stack, { ref: dimensions[0][0], className: "SearchBarContainer", justifyContent: "center", alignItems: "center", direction: "row", spacing: 1, width: "100%", overflow: hasMoreItems ? "hidden" : undefined, sx: {
227
235
  "& > :not(style)": {
228
236
  flexBasis: "auto",
229
237
  flexGrow: 0,
@@ -243,7 +251,7 @@ export function SearchBar(props) {
243
251
  React.createElement(IconButton, { title: labels.more, size: "medium", sx: { height: "40px" }, onClick: handleMore },
244
252
  React.createElement(MoreHorizIcon, null)),
245
253
  React.createElement(Button, { variant: "contained", size: "medium", ref: resetButtonRef, onClick: handleReset }, labels.reset))),
246
- index != null && index < fields.length && (React.createElement(Drawer, { anchor: "right", sx: { minWidth: "250px" }, ModalProps: {
254
+ hasMoreItems && (React.createElement(Drawer, { anchor: "right", sx: { minWidth: "250px" }, ModalProps: {
247
255
  keepMounted: true
248
256
  }, open: open, onClose: () => updateOpen(false) },
249
257
  React.createElement("form", { onChange: moreFormChange, ref: (form) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.1.75",
3
+ "version": "1.1.76",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
package/src/SearchBar.tsx CHANGED
@@ -237,6 +237,7 @@ export function SearchBar(props: SearchBarProps) {
237
237
  moreItems.push(<React.Fragment key={i}>{fields[i]}</React.Fragment>);
238
238
  }
239
239
  }
240
+ const hasMoreItems = moreItems.length > 0;
240
241
 
241
242
  // Handle main form
242
243
  const handleForm = (event: React.FormEvent<HTMLFormElement>) => {
@@ -293,6 +294,14 @@ export function SearchBar(props: SearchBarProps) {
293
294
  };
294
295
  }, [className]);
295
296
 
297
+ React.useEffect(() => {
298
+ if (!hasMoreItems || state.form == null) return;
299
+ const stack = state.form.querySelector<HTMLDivElement>(
300
+ ".SearchBarContainer"
301
+ );
302
+ if (stack) stack.style.overflow = "visbile";
303
+ }, [hasMoreItems]);
304
+
296
305
  // Layout
297
306
  return (
298
307
  <React.Fragment>
@@ -306,12 +315,13 @@ export function SearchBar(props: SearchBarProps) {
306
315
  >
307
316
  <Stack
308
317
  ref={dimensions[0][0]}
318
+ className="SearchBarContainer"
309
319
  justifyContent="center"
310
320
  alignItems="center"
311
321
  direction="row"
312
322
  spacing={1}
313
323
  width="100%"
314
- overflow="hidden"
324
+ overflow={hasMoreItems ? "hidden" : undefined}
315
325
  sx={{
316
326
  "& > :not(style)": {
317
327
  flexBasis: "auto",
@@ -351,7 +361,7 @@ export function SearchBar(props: SearchBarProps) {
351
361
  </Button>
352
362
  </Stack>
353
363
  </form>
354
- {index != null && index < fields.length && (
364
+ {hasMoreItems && (
355
365
  <Drawer
356
366
  anchor="right"
357
367
  sx={{ minWidth: "250px" }}