@etsoo/materialui 1.4.35 → 1.4.36

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/MUGlobal.js CHANGED
@@ -158,7 +158,10 @@ export class MUGlobal {
158
158
  const mediaRaw = theme.breakpoints.up(key);
159
159
  const mediaQuery = mediaRaw.substring(mediaRaw.indexOf("("));
160
160
  if (window.matchMedia(mediaQuery).matches) {
161
- return parseInt(theme.spacing(value), 10);
161
+ let space = parseInt(theme.spacing(value), 10);
162
+ if (isNaN(space))
163
+ space = 8 * value;
164
+ return space;
162
165
  }
163
166
  }
164
167
  }
@@ -7,6 +7,10 @@ export interface SearchBarProps {
7
7
  * Style class name
8
8
  */
9
9
  className?: string;
10
+ /**
11
+ * Item gap
12
+ */
13
+ itemGap?: number;
10
14
  /**
11
15
  * Item width
12
16
  */
package/lib/SearchBar.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Button, Drawer, IconButton, Stack, useTheme } from "@mui/material";
2
+ import { Button, Drawer, IconButton, Stack } from "@mui/material";
3
3
  import React from "react";
4
4
  import MoreHorizIcon from "@mui/icons-material/MoreHoriz";
5
5
  import { DomUtils } from "@etsoo/shared";
@@ -54,12 +54,9 @@ const setChildState = (child, enabled) => {
54
54
  */
55
55
  export function SearchBar(props) {
56
56
  // Destruct
57
- const { className, fields, onSubmit, itemWidth = 160 } = props;
57
+ const { className, fields, onSubmit, itemGap = 6, itemWidth = 160 } = props;
58
58
  // Labels
59
59
  const labels = Labels.CommonPage;
60
- // Spacing
61
- const theme = useTheme();
62
- const gap = parseFloat(theme.spacing(1));
63
60
  // Menu index
64
61
  const [index, updateIndex] = React.useState();
65
62
  // Drawer open / close
@@ -68,7 +65,7 @@ export function SearchBar(props) {
68
65
  const state = React.useRef({ hasMore: true, lastMaxWidth: 9999 }).current;
69
66
  // Watch container
70
67
  const { dimensions } = useDimensions(1, (target, rect) => {
71
- // Same logic from resetButtonRef
68
+ // Same logic from resetButtonRefe);
72
69
  if (rect.width === state.lastMaxWidth ||
73
70
  (!state.hasMore && rect.width > state.lastMaxWidth))
74
71
  return false;
@@ -114,7 +111,7 @@ export function SearchBar(props) {
114
111
  // More button rect
115
112
  const buttonMoreRect = buttonMore.getBoundingClientRect();
116
113
  // Total
117
- const totalButtonWidth = resetButtonRect.width + buttonMoreRect.width + 3 * gap;
114
+ const totalButtonWidth = resetButtonRect.width + buttonMoreRect.width + 3 * itemGap;
118
115
  // Cache
119
116
  container.setAttribute(cachedWidthName, totalButtonWidth.toString());
120
117
  maxWidth -= totalButtonWidth;
@@ -136,7 +133,7 @@ export function SearchBar(props) {
136
133
  }
137
134
  else {
138
135
  const childD = child.getBoundingClientRect();
139
- childWidth = childD.width + gap;
136
+ childWidth = childD.width + itemGap;
140
137
  child.setAttribute(cachedWidthName, childWidth.toString());
141
138
  }
142
139
  // No gap here, child width includes the gap
@@ -224,7 +221,7 @@ export function SearchBar(props) {
224
221
  return (_jsxs(React.Fragment, { children: [_jsx("form", { id: "SearchBarForm", className: className, onChange: handleForm, ref: (form) => {
225
222
  if (form)
226
223
  state.form = form;
227
- }, children: _jsxs(Stack, { ref: dimensions[0][0], className: "SearchBarContainer", justifyContent: "center", alignItems: "center", direction: "row", spacing: 1, width: "100%", overflow: "hidden", paddingTop: "6px", sx: {
224
+ }, children: _jsxs(Stack, { ref: dimensions[0][0], className: "SearchBarContainer", justifyContent: "center", alignItems: "center", direction: "row", spacing: `${itemGap}px`, width: "100%", overflow: "hidden", paddingTop: "6px", sx: {
228
225
  "& > :not(style)": {
229
226
  flexBasis: "auto",
230
227
  flexGrow: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/materialui",
3
- "version": "1.4.35",
3
+ "version": "1.4.36",
4
4
  "description": "TypeScript Material-UI Implementation",
5
5
  "main": "lib/index.js",
6
6
  "type": "module",
@@ -73,6 +73,6 @@
73
73
  "@vitejs/plugin-react": "^4.3.4",
74
74
  "jsdom": "^25.0.1",
75
75
  "typescript": "^5.7.2",
76
- "vitest": "^2.1.6"
76
+ "vitest": "^2.1.8"
77
77
  }
78
78
  }
package/src/MUGlobal.ts CHANGED
@@ -187,7 +187,9 @@ export class MUGlobal {
187
187
  const mediaRaw = theme.breakpoints.up(key as Breakpoint);
188
188
  const mediaQuery = mediaRaw.substring(mediaRaw.indexOf("("));
189
189
  if (window.matchMedia(mediaQuery).matches) {
190
- return parseInt(theme.spacing(value), 10);
190
+ let space = parseInt(theme.spacing(value), 10);
191
+ if (isNaN(space)) space = 8 * value;
192
+ return space;
191
193
  }
192
194
  }
193
195
  }
package/src/SearchBar.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { Button, Drawer, IconButton, Stack, useTheme } from "@mui/material";
1
+ import { Button, Drawer, IconButton, Stack } from "@mui/material";
2
2
  import React from "react";
3
3
  import MoreHorizIcon from "@mui/icons-material/MoreHoriz";
4
4
  import { DomUtils } from "@etsoo/shared";
@@ -14,6 +14,11 @@ export interface SearchBarProps {
14
14
  */
15
15
  className?: string;
16
16
 
17
+ /**
18
+ * Item gap
19
+ */
20
+ itemGap?: number;
21
+
17
22
  /**
18
23
  * Item width
19
24
  */
@@ -83,15 +88,11 @@ const setChildState = (child: Element, enabled: boolean) => {
83
88
  */
84
89
  export function SearchBar(props: SearchBarProps) {
85
90
  // Destruct
86
- const { className, fields, onSubmit, itemWidth = 160 } = props;
91
+ const { className, fields, onSubmit, itemGap = 6, itemWidth = 160 } = props;
87
92
 
88
93
  // Labels
89
94
  const labels = Labels.CommonPage;
90
95
 
91
- // Spacing
92
- const theme = useTheme();
93
- const gap = parseFloat(theme.spacing(1));
94
-
95
96
  // Menu index
96
97
  const [index, updateIndex] = React.useState<number>();
97
98
 
@@ -110,7 +111,7 @@ export function SearchBar(props: SearchBarProps) {
110
111
  const { dimensions } = useDimensions(
111
112
  1,
112
113
  (target, rect) => {
113
- // Same logic from resetButtonRef
114
+ // Same logic from resetButtonRefe);
114
115
  if (
115
116
  rect.width === state.lastMaxWidth ||
116
117
  (!state.hasMore && rect.width > state.lastMaxWidth)
@@ -170,7 +171,7 @@ export function SearchBar(props: SearchBarProps) {
170
171
 
171
172
  // Total
172
173
  const totalButtonWidth =
173
- resetButtonRect.width + buttonMoreRect.width + 3 * gap;
174
+ resetButtonRect.width + buttonMoreRect.width + 3 * itemGap;
174
175
 
175
176
  // Cache
176
177
  container.setAttribute(cachedWidthName, totalButtonWidth.toString());
@@ -196,7 +197,7 @@ export function SearchBar(props: SearchBarProps) {
196
197
  childWidth = Number.parseFloat(cachedWidth);
197
198
  } else {
198
199
  const childD = child.getBoundingClientRect();
199
- childWidth = childD.width + gap;
200
+ childWidth = childD.width + itemGap;
200
201
  child.setAttribute(cachedWidthName, childWidth.toString());
201
202
  }
202
203
 
@@ -312,7 +313,7 @@ export function SearchBar(props: SearchBarProps) {
312
313
  justifyContent="center"
313
314
  alignItems="center"
314
315
  direction="row"
315
- spacing={1}
316
+ spacing={`${itemGap}px`}
316
317
  width="100%"
317
318
  overflow="hidden"
318
319
  paddingTop="6px"
@@ -336,7 +337,6 @@ export function SearchBar(props: SearchBarProps) {
336
337
  {fields.map((item, index) => (
337
338
  <React.Fragment key={index}>{item}</React.Fragment>
338
339
  ))}
339
-
340
340
  <IconButton
341
341
  title={labels.more}
342
342
  size="medium"