@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.
- package/README.de.md +46 -1
- package/README.md +46 -1
- package/dist/components/color-picker/ColorPicker.d.ts +11 -0
- package/dist/components/color-picker/ColorPicker.js +527 -0
- package/dist/components/color-picker/ColorPicker.types.d.ts +65 -0
- package/dist/components/color-picker/ColorPicker.types.js +18 -0
- package/dist/components/color-picker/util/colorConversion.util.d.ts +51 -0
- package/dist/components/color-picker/util/colorConversion.util.js +166 -0
- package/dist/components/tag-selection/TagSelection.d.ts +1 -1
- package/dist/components/tag-selection/TagSelection.js +83 -70
- package/dist/components/tag-selection/TagSelection.types.d.ts +2 -0
- package/dist/components/tag-selection/TagSelectionAutocomplete.d.ts +2 -1
- package/dist/components/tag-selection/TagSelectionAutocomplete.js +88 -85
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/package.json +2 -2
|
@@ -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
|
|
5
|
-
import
|
|
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
|
|
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
|
-
],
|
|
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
|
|
37
|
+
function h(e) {
|
|
38
38
|
return /^#[0-9A-Fa-f]{6}$/.test(e);
|
|
39
39
|
}
|
|
40
|
-
function
|
|
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
|
|
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
|
|
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
|
|
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 && !
|
|
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:
|
|
101
|
+
backgroundColor: h(e) ? e : "action.disabledBackground",
|
|
102
102
|
border: "1px solid",
|
|
103
103
|
borderColor: "divider"
|
|
104
104
|
} }) } }
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
function
|
|
108
|
-
let [
|
|
109
|
-
if (
|
|
110
|
-
let e =
|
|
111
|
-
|
|
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:
|
|
116
|
+
backgroundColor: N,
|
|
117
117
|
foregroundColor: X
|
|
118
118
|
} : {
|
|
119
119
|
id: t,
|
|
120
120
|
label: e,
|
|
121
121
|
selected: !0,
|
|
122
|
-
color:
|
|
123
|
-
}),
|
|
122
|
+
color: j
|
|
123
|
+
}), M("default"), P(null), I(null), R(!0), B(!1), C("");
|
|
124
124
|
}, Q = () => {
|
|
125
|
-
|
|
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
|
-
|
|
127
|
+
P(e), W(e), M("default");
|
|
130
128
|
}, ce = (e) => {
|
|
131
|
-
|
|
129
|
+
W(e), h(e) && (P(e), M("default"));
|
|
132
130
|
}, le = (e) => {
|
|
133
|
-
|
|
131
|
+
I(e), K(e);
|
|
134
132
|
}, ue = (e) => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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:
|
|
144
|
+
options: b,
|
|
145
|
+
filterOptions: A ? (e) => e : void 0,
|
|
145
146
|
value: null,
|
|
146
|
-
open:
|
|
147
|
+
open: oe,
|
|
147
148
|
onOpen: () => {
|
|
148
|
-
Y ||
|
|
149
|
+
Y || H(!0);
|
|
149
150
|
},
|
|
150
|
-
onClose: () =>
|
|
151
|
-
size:
|
|
152
|
-
disabled:
|
|
153
|
-
loading:
|
|
151
|
+
onClose: () => H(!1),
|
|
152
|
+
size: ne,
|
|
153
|
+
disabled: q,
|
|
154
|
+
loading: re,
|
|
154
155
|
getOptionLabel: (e) => e.label,
|
|
155
|
-
inputValue:
|
|
156
|
-
onInputChange: (e, t) =>
|
|
156
|
+
inputValue: x,
|
|
157
|
+
onInputChange: (e, t, n) => {
|
|
158
|
+
n === "input" && C(t);
|
|
159
|
+
},
|
|
157
160
|
onChange: (e, t) => {
|
|
158
|
-
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:
|
|
173
|
-
placeholder:
|
|
174
|
-
helperText: O && !
|
|
175
|
+
label: S.autoCompleteLabel,
|
|
176
|
+
placeholder: S.placeholder,
|
|
177
|
+
helperText: O && !D ? S.maxTagsReachedText : void 0,
|
|
175
178
|
onKeyDown: (e) => {
|
|
176
|
-
Y && !
|
|
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:
|
|
188
|
-
"aria-label":
|
|
189
|
-
children: /* @__PURE__ */ u(
|
|
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":
|
|
195
|
-
children: /* @__PURE__ */ u(
|
|
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:
|
|
211
|
-
label:
|
|
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:
|
|
222
|
-
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: [
|
|
235
|
-
size:
|
|
237
|
+
children: [p.map((e) => /* @__PURE__ */ u(r, {
|
|
238
|
+
size: E,
|
|
236
239
|
color: e,
|
|
237
240
|
label: e,
|
|
238
|
-
variant: !
|
|
241
|
+
variant: !J && j === e ? "filled" : "outlined",
|
|
239
242
|
onClick: () => {
|
|
240
|
-
|
|
243
|
+
M(e), P(null), I(null), B(!1);
|
|
241
244
|
},
|
|
242
245
|
clickable: !0
|
|
243
246
|
}, e)), /* @__PURE__ */ u(s, {
|
|
244
|
-
title:
|
|
247
|
+
title: S.colorPickerLabel,
|
|
245
248
|
children: /* @__PURE__ */ u(r, {
|
|
246
|
-
size:
|
|
247
|
-
label:
|
|
249
|
+
size: E,
|
|
250
|
+
label: J ? N : "···",
|
|
248
251
|
variant: "outlined",
|
|
249
252
|
onClick: () => {
|
|
250
|
-
|
|
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
|
-
...
|
|
257
|
-
backgroundColor:
|
|
259
|
+
...J ? {
|
|
260
|
+
backgroundColor: N,
|
|
258
261
|
color: X,
|
|
259
262
|
border: "1.5px solid transparent",
|
|
260
|
-
backgroundImage: `linear-gradient(${
|
|
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
|
-
}),
|
|
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:
|
|
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: [
|
|
311
|
+
children: [m.map((e) => /* @__PURE__ */ u(v, {
|
|
309
312
|
color: e,
|
|
310
|
-
selected:
|
|
311
|
-
onClick: () =>
|
|
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(
|
|
318
|
-
value:
|
|
319
|
-
onChange:
|
|
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:
|
|
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:
|
|
339
|
-
pointerEvents:
|
|
341
|
+
opacity: L ? .3 : 1,
|
|
342
|
+
pointerEvents: L ? "none" : "auto",
|
|
340
343
|
transition: "opacity 0.15s"
|
|
341
344
|
},
|
|
342
|
-
children: [
|
|
345
|
+
children: [m.map((e) => /* @__PURE__ */ u(v, {
|
|
343
346
|
color: e,
|
|
344
|
-
selected:
|
|
345
|
-
onClick: () =>
|
|
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(
|
|
352
|
-
value:
|
|
353
|
-
onChange:
|
|
354
|
-
disabled:
|
|
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:
|
|
373
|
+
children: S.autoTextColorLabel
|
|
371
374
|
}), /* @__PURE__ */ u(ee, {
|
|
372
375
|
size: "small",
|
|
373
|
-
checked:
|
|
374
|
-
onChange: (e) =>
|
|
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 {
|
|
387
|
+
export { b as TagSelectionAutocomplete };
|