@thebuoyant-tsdev/mui-ts-library 3.11.3 → 3.13.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.
@@ -1,10 +1,10 @@
1
1
  import { useState as e } from "react";
2
2
  import { Autocomplete as t, Box as n, Chip as r, IconButton as i, Stack as a, Switch as ee, TextField as o, Tooltip as s, Typography as c } from "@mui/material";
3
3
  import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
4
- import te from "@mui/icons-material/Check";
5
- import f from "@mui/icons-material/Close";
4
+ import f from "@mui/icons-material/Check";
5
+ import te from "@mui/icons-material/Close";
6
6
  //#region src/components/tag-selection/TagSelectionAutocomplete.tsx
7
- var ne = [
7
+ var p = [
8
8
  "default",
9
9
  "primary",
10
10
  "secondary",
@@ -12,7 +12,7 @@ var ne = [
12
12
  "info",
13
13
  "success",
14
14
  "warning"
15
- ], p = [
15
+ ], m = [
16
16
  "#f44336",
17
17
  "#e91e63",
18
18
  "#9c27b0",
@@ -34,14 +34,14 @@ var ne = [
34
34
  "#607d8b",
35
35
  "#000000"
36
36
  ];
37
- function m(e) {
37
+ function h(e) {
38
38
  return /^#[0-9A-Fa-f]{6}$/.test(e);
39
39
  }
40
- function h(e) {
40
+ function g(e) {
41
41
  let t = parseInt(e.slice(1, 3), 16), n = parseInt(e.slice(3, 5), 16), r = parseInt(e.slice(5, 7), 16);
42
42
  return (.299 * t + .587 * n + .114 * r) / 255 > .5 ? "#000000" : "#ffffff";
43
43
  }
44
- function g(e, t) {
44
+ function _(e, t) {
45
45
  let n = t.trim();
46
46
  if (!n) return e;
47
47
  let r = e.toLowerCase().indexOf(n.toLowerCase());
@@ -51,7 +51,7 @@ function g(e, t) {
51
51
  e.slice(r + n.length)
52
52
  ] });
53
53
  }
54
- function _({ color: e, selected: t, onClick: r }) {
54
+ function v({ color: e, selected: t, onClick: r }) {
55
55
  return /* @__PURE__ */ u(n, {
56
56
  onClick: r,
57
57
  sx: {
@@ -74,7 +74,7 @@ function _({ color: e, selected: t, onClick: r }) {
74
74
  }
75
75
  });
76
76
  }
77
- function v({ value: e, onChange: t, disabled: r = !1 }) {
77
+ function y({ value: e, onChange: t, disabled: r = !1 }) {
78
78
  return /* @__PURE__ */ u(o, {
79
79
  size: "small",
80
80
  fullWidth: !0,
@@ -82,7 +82,7 @@ function v({ value: e, onChange: t, disabled: r = !1 }) {
82
82
  onChange: (e) => t(e.target.value),
83
83
  placeholder: "#rrggbb",
84
84
  disabled: r,
85
- error: !r && e.length > 1 && !m(e),
85
+ error: !r && e.length > 1 && !h(e),
86
86
  sx: {
87
87
  "& .MuiInputBase-root": { height: 28 },
88
88
  "& .MuiInputBase-input": {
@@ -98,64 +98,67 @@ function v({ value: e, onChange: t, disabled: r = !1 }) {
98
98
  borderRadius: .25,
99
99
  flexShrink: 0,
100
100
  mr: .5,
101
- backgroundColor: m(e) ? e : "action.disabledBackground",
101
+ backgroundColor: h(e) ? e : "action.disabledBackground",
102
102
  border: "1px solid",
103
103
  borderColor: "divider"
104
104
  } }) } }
105
105
  });
106
106
  }
107
- function y({ availableTags: y, searchValue: b, translation: x, onSearchChange: S, onTagSelect: re, onTagCreate: C, inputSize: w = "medium", chipSize: T = "medium", disabled: E = !1, loading: D = !1, isMaxReached: O = !1, allowCreate: ie = !1, listboxMaxHeight: k }) {
108
- let [A, j] = e("default"), [M, N] = e(null), [P, F] = e(null), [I, L] = e(!0), [R, z] = e(!1), [B, V] = e(!1), [H, U] = e("#1976d2"), [W, G] = e("#ffffff"), K = E || O, q = M !== null, J = y.filter((e) => e.label.toLowerCase().includes(b.trim().toLowerCase())), Y = ie && b.trim() !== "" && J.length === 0, ae = B && !Y, X = q ? I ? h(M) : P ?? "#000000" : void 0, Z = () => {
109
- if (K) return;
110
- let e = b.trim(), t = e.toLowerCase().replace(/\s+/g, "-");
111
- C?.(q && M ? {
107
+ function b({ availableTags: b, searchValue: x, translation: S, onSearchChange: C, onTagSelect: w, onTagCreate: T, inputSize: ne = "medium", chipSize: E = "medium", disabled: D = !1, loading: re = !1, isMaxReached: O = !1, allowCreate: ie = !1, listboxMaxHeight: k, serverSideFilter: A = !1 }) {
108
+ let [j, M] = e("default"), [N, P] = e(null), [F, I] = e(null), [L, R] = e(!0), [z, B] = e(!1), [V, H] = e(!1), [U, W] = e("#1976d2"), [G, K] = e("#ffffff"), q = D || O, J = N !== null, ae = A ? b : b.filter((e) => e.label.toLowerCase().includes(x.trim().toLowerCase())), Y = ie && x.trim() !== "" && ae.length === 0, oe = V && !Y, X = J ? L ? g(N) : F ?? "#000000" : void 0, Z = () => {
109
+ if (q) return;
110
+ let e = x.trim(), t = e.toLowerCase().replace(/\s+/g, "-");
111
+ T?.(J && N ? {
112
112
  id: t,
113
113
  label: e,
114
114
  selected: !0,
115
115
  color: "default",
116
- backgroundColor: M,
116
+ backgroundColor: N,
117
117
  foregroundColor: X
118
118
  } : {
119
119
  id: t,
120
120
  label: e,
121
121
  selected: !0,
122
- color: A
123
- }), j("default"), N(null), F(null), L(!0), z(!1), S("");
122
+ color: j
123
+ }), M("default"), P(null), I(null), R(!0), B(!1), C("");
124
124
  }, Q = () => {
125
- S(""), j("default"), N(null), F(null), L(!0), z(!1);
126
- }, oe = (e) => {
127
- N(e), U(e), j("default");
125
+ C(""), M("default"), P(null), I(null), R(!0), B(!1);
128
126
  }, se = (e) => {
129
- U(e), m(e) && (N(e), j("default"));
127
+ P(e), W(e), M("default");
130
128
  }, ce = (e) => {
131
- F(e), G(e);
129
+ W(e), h(e) && (P(e), M("default"));
132
130
  }, le = (e) => {
133
- G(e), m(e) && F(e);
131
+ I(e), K(e);
134
132
  }, ue = (e) => {
135
- if (L(e), e) F(null);
136
- else if (M) {
137
- let e = h(M);
138
- F(e), G(e);
133
+ K(e), h(e) && I(e);
134
+ }, de = (e) => {
135
+ if (R(e), e) I(null);
136
+ else if (N) {
137
+ let e = g(N);
138
+ I(e), K(e);
139
139
  }
140
140
  }, $ = (e) => e.preventDefault();
141
141
  return /* @__PURE__ */ d(n, {
142
142
  sx: { mb: 2 },
143
143
  children: [/* @__PURE__ */ u(t, {
144
- options: y,
144
+ options: b,
145
+ filterOptions: A ? (e) => e : void 0,
145
146
  value: null,
146
- open: ae,
147
+ open: oe,
147
148
  onOpen: () => {
148
- Y || V(!0);
149
+ Y || H(!0);
149
150
  },
150
- onClose: () => V(!1),
151
- size: w,
152
- disabled: K,
153
- loading: D,
151
+ onClose: () => H(!1),
152
+ size: ne,
153
+ disabled: q,
154
+ loading: re,
154
155
  getOptionLabel: (e) => e.label,
155
- inputValue: b,
156
- onInputChange: (e, t) => S(t),
156
+ inputValue: x,
157
+ onInputChange: (e, t, n) => {
158
+ n === "input" && C(t);
159
+ },
157
160
  onChange: (e, t) => {
158
- t && re(t);
161
+ t && w(t);
159
162
  },
160
163
  slotProps: { listbox: { sx: {
161
164
  display: "flex",
@@ -169,11 +172,11 @@ function y({ availableTags: y, searchValue: b, translation: x, onSearchChange: S
169
172
  } } },
170
173
  renderInput: (e) => /* @__PURE__ */ u(o, {
171
174
  ...e,
172
- label: x.autoCompleteLabel,
173
- placeholder: x.placeholder,
174
- helperText: O && !E ? x.maxTagsReachedText : void 0,
175
+ label: S.autoCompleteLabel,
176
+ placeholder: S.placeholder,
177
+ helperText: O && !D ? S.maxTagsReachedText : void 0,
175
178
  onKeyDown: (e) => {
176
- Y && !K && e.key === "Enter" && (e.preventDefault(), Z());
179
+ Y && !q && e.key === "Enter" && (e.preventDefault(), Z());
177
180
  },
178
181
  slotProps: {
179
182
  ...e.slotProps,
@@ -184,15 +187,15 @@ function y({ availableTags: y, searchValue: b, translation: x, onSearchChange: S
184
187
  sx: { color: "success.main" },
185
188
  onMouseDown: $,
186
189
  onClick: Z,
187
- disabled: K,
188
- "aria-label": x.confirmCreateLabel,
189
- children: /* @__PURE__ */ u(te, { fontSize: "small" })
190
+ disabled: q,
191
+ "aria-label": S.confirmCreateLabel,
192
+ children: /* @__PURE__ */ u(f, { fontSize: "small" })
190
193
  }), /* @__PURE__ */ u(i, {
191
194
  size: "small",
192
195
  onMouseDown: $,
193
196
  onClick: Q,
194
- "aria-label": x.cancelCreateLabel,
195
- children: /* @__PURE__ */ u(f, { fontSize: "small" })
197
+ "aria-label": S.cancelCreateLabel,
198
+ children: /* @__PURE__ */ u(te, { fontSize: "small" })
196
199
  })] }), e.slotProps?.input?.endAdornment] })
197
200
  }
198
201
  }
@@ -207,8 +210,8 @@ function y({ availableTags: y, searchValue: b, translation: x, onSearchChange: S
207
210
  margin: 0
208
211
  },
209
212
  children: /* @__PURE__ */ u(r, {
210
- size: T,
211
- label: g(n.label, b),
213
+ size: E,
214
+ label: _(n.label, x),
212
215
  color: i ? void 0 : n.color ?? "default",
213
216
  sx: i ? {
214
217
  color: n.foregroundColor ?? "inherit",
@@ -218,8 +221,8 @@ function y({ availableTags: y, searchValue: b, translation: x, onSearchChange: S
218
221
  }, e);
219
222
  },
220
223
  isOptionEqualToValue: (e, t) => e.id === t.id,
221
- noOptionsText: x.noAvailableTagsText,
222
- loadingText: x.loadingText
224
+ noOptionsText: S.noAvailableTagsText,
225
+ loadingText: S.loadingText
223
226
  }), Y && /* @__PURE__ */ d(n, {
224
227
  sx: { position: "relative" },
225
228
  onMouseDown: $,
@@ -231,33 +234,33 @@ function y({ availableTags: y, searchValue: b, translation: x, onSearchChange: S
231
234
  gap: .5,
232
235
  alignItems: "center"
233
236
  },
234
- children: [ne.map((e) => /* @__PURE__ */ u(r, {
235
- size: T,
237
+ children: [p.map((e) => /* @__PURE__ */ u(r, {
238
+ size: E,
236
239
  color: e,
237
240
  label: e,
238
- variant: !q && A === e ? "filled" : "outlined",
241
+ variant: !J && j === e ? "filled" : "outlined",
239
242
  onClick: () => {
240
- j(e), N(null), F(null), z(!1);
243
+ M(e), P(null), I(null), B(!1);
241
244
  },
242
245
  clickable: !0
243
246
  }, e)), /* @__PURE__ */ u(s, {
244
- title: x.colorPickerLabel,
247
+ title: S.colorPickerLabel,
245
248
  children: /* @__PURE__ */ u(r, {
246
- size: T,
247
- label: q ? M : "···",
249
+ size: E,
250
+ label: J ? N : "···",
248
251
  variant: "outlined",
249
252
  onClick: () => {
250
- z((e) => !e), M && U(M), P && G(P);
253
+ B((e) => !e), N && W(N), F && K(F);
251
254
  },
252
255
  sx: (e) => ({
253
256
  cursor: "pointer",
254
257
  fontFamily: "monospace",
255
258
  fontSize: "0.7rem",
256
- ...q ? {
257
- backgroundColor: M,
259
+ ...J ? {
260
+ backgroundColor: N,
258
261
  color: X,
259
262
  border: "1.5px solid transparent",
260
- backgroundImage: `linear-gradient(${M}, ${M}), linear-gradient(90deg, #f44336, #ff9800, #ffeb3b, #4caf50, #2196f3, #9c27b0)`,
263
+ backgroundImage: `linear-gradient(${N}, ${N}), linear-gradient(90deg, #f44336, #ff9800, #ffeb3b, #4caf50, #2196f3, #9c27b0)`,
261
264
  backgroundOrigin: "border-box",
262
265
  backgroundClip: "padding-box, border-box"
263
266
  } : {
@@ -270,7 +273,7 @@ function y({ availableTags: y, searchValue: b, translation: x, onSearchChange: S
270
273
  clickable: !0
271
274
  })
272
275
  })]
273
- }), R && /* @__PURE__ */ u(n, {
276
+ }), z && /* @__PURE__ */ u(n, {
274
277
  sx: {
275
278
  position: "absolute",
276
279
  top: "calc(100% + 4px)",
@@ -298,25 +301,25 @@ function y({ availableTags: y, searchValue: b, translation: x, onSearchChange: S
298
301
  display: "block",
299
302
  mb: .5
300
303
  },
301
- children: x.backgroundColorLabel
304
+ children: S.backgroundColorLabel
302
305
  }), /* @__PURE__ */ d(n, {
303
306
  sx: {
304
307
  display: "grid",
305
308
  gridTemplateColumns: "repeat(5, 24px)",
306
309
  gap: .5
307
310
  },
308
- children: [p.map((e) => /* @__PURE__ */ u(_, {
311
+ children: [m.map((e) => /* @__PURE__ */ u(v, {
309
312
  color: e,
310
- selected: M === e,
311
- onClick: () => oe(e)
313
+ selected: N === e,
314
+ onClick: () => se(e)
312
315
  }, e)), /* @__PURE__ */ u(n, {
313
316
  sx: {
314
317
  gridColumn: "span 5",
315
318
  mt: .25
316
319
  },
317
- children: /* @__PURE__ */ u(v, {
318
- value: H,
319
- onChange: se
320
+ children: /* @__PURE__ */ u(y, {
321
+ value: U,
322
+ onChange: ce
320
323
  })
321
324
  })]
322
325
  })] }), /* @__PURE__ */ d(n, { children: [
@@ -328,30 +331,30 @@ function y({ availableTags: y, searchValue: b, translation: x, onSearchChange: S
328
331
  display: "block",
329
332
  mb: .5
330
333
  },
331
- children: x.textColorLabel
334
+ children: S.textColorLabel
332
335
  }),
333
336
  /* @__PURE__ */ d(n, {
334
337
  sx: {
335
338
  display: "grid",
336
339
  gridTemplateColumns: "repeat(5, 24px)",
337
340
  gap: .5,
338
- opacity: I ? .3 : 1,
339
- pointerEvents: I ? "none" : "auto",
341
+ opacity: L ? .3 : 1,
342
+ pointerEvents: L ? "none" : "auto",
340
343
  transition: "opacity 0.15s"
341
344
  },
342
- children: [p.map((e) => /* @__PURE__ */ u(_, {
345
+ children: [m.map((e) => /* @__PURE__ */ u(v, {
343
346
  color: e,
344
- selected: P === e,
345
- onClick: () => ce(e)
347
+ selected: F === e,
348
+ onClick: () => le(e)
346
349
  }, e)), /* @__PURE__ */ u(n, {
347
350
  sx: {
348
351
  gridColumn: "span 5",
349
352
  mt: .25
350
353
  },
351
- children: /* @__PURE__ */ u(v, {
352
- value: I ? X ?? "#000000" : W,
353
- onChange: le,
354
- disabled: I
354
+ children: /* @__PURE__ */ u(y, {
355
+ value: L ? X ?? "#000000" : G,
356
+ onChange: ue,
357
+ disabled: L
355
358
  })
356
359
  })]
357
360
  }),
@@ -367,11 +370,11 @@ function y({ availableTags: y, searchValue: b, translation: x, onSearchChange: S
367
370
  children: [/* @__PURE__ */ u(c, {
368
371
  variant: "caption",
369
372
  color: "text.secondary",
370
- children: x.autoTextColorLabel
373
+ children: S.autoTextColorLabel
371
374
  }), /* @__PURE__ */ u(ee, {
372
375
  size: "small",
373
- checked: I,
374
- onChange: (e) => ue(e.target.checked)
376
+ checked: L,
377
+ onChange: (e) => de(e.target.checked)
375
378
  })]
376
379
  })
377
380
  ] })]
@@ -381,4 +384,4 @@ function y({ availableTags: y, searchValue: b, translation: x, onSearchChange: S
381
384
  });
382
385
  }
383
386
  //#endregion
384
- export { y as TagSelectionAutocomplete };
387
+ export { b as TagSelectionAutocomplete };