@m4l/components 9.9.0 → 9.9.1-beta-feature-m4l-components-rhf-image-selector.1
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/@types/types.d.ts +8 -0
- package/components/ImageSelector/ImageSelector.d.ts +6 -0
- package/components/ImageSelector/ImageSelector.d.ts.map +1 -0
- package/components/ImageSelector/ImageSelector.js +226 -0
- package/components/ImageSelector/ImageSelector.styles.d.ts +3 -0
- package/components/ImageSelector/ImageSelector.styles.d.ts.map +1 -0
- package/components/ImageSelector/ImageSelector.styles.js +246 -0
- package/components/ImageSelector/constants.d.ts +16 -0
- package/components/ImageSelector/constants.d.ts.map +1 -0
- package/components/ImageSelector/constants.js +23 -0
- package/components/ImageSelector/dictionary.d.ts +8 -0
- package/components/ImageSelector/dictionary.d.ts.map +1 -0
- package/components/ImageSelector/dictionary.js +11 -0
- package/components/ImageSelector/hooks/useImageSelector.d.ts +6 -0
- package/components/ImageSelector/hooks/useImageSelector.d.ts.map +1 -0
- package/components/ImageSelector/hooks/useImageSelector.js +279 -0
- package/components/ImageSelector/index.d.ts +4 -0
- package/components/ImageSelector/index.d.ts.map +1 -0
- package/components/ImageSelector/slots/ImageSelectorEnum.d.ts +15 -0
- package/components/ImageSelector/slots/ImageSelectorEnum.d.ts.map +1 -0
- package/components/ImageSelector/slots/ImageSelectorEnum.js +4 -0
- package/components/ImageSelector/slots/ImageSelectorSlots.d.ts +19 -0
- package/components/ImageSelector/slots/ImageSelectorSlots.d.ts.map +1 -0
- package/components/ImageSelector/slots/ImageSelectorSlots.js +75 -0
- package/components/ImageSelector/slots/index.d.ts +3 -0
- package/components/ImageSelector/slots/index.d.ts.map +1 -0
- package/components/ImageSelector/types.d.ts +210 -0
- package/components/ImageSelector/types.d.ts.map +1 -0
- package/components/hook-form/RHFImageSelector/RHFImageSelector.d.ts +9 -0
- package/components/hook-form/RHFImageSelector/RHFImageSelector.d.ts.map +1 -0
- package/components/hook-form/RHFImageSelector/RHFImageSelector.js +6 -0
- package/components/hook-form/RHFImageSelector/index.d.ts +3 -0
- package/components/hook-form/RHFImageSelector/index.d.ts.map +1 -0
- package/components/hook-form/RHFImageSelector/types.d.ts +7 -0
- package/components/hook-form/RHFImageSelector/types.d.ts.map +1 -0
- package/components/hook-form/index.d.ts +1 -0
- package/components/hook-form/index.d.ts.map +1 -1
- package/components/index.d.ts +1 -0
- package/components/index.d.ts.map +1 -1
- package/index.js +296 -290
- package/package.json +6 -6
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { useEnvironment as De, useNetwork as Re, getPropertyByString as _e } from "@m4l/core";
|
|
2
|
+
import { useRef as E, useState as C, useId as be, useMemo as k, useEffect as re, useCallback as n } from "react";
|
|
3
|
+
import { DEFAULT_TIMEOUT as ye, DEFAULT_RESULT_FIELD as Fe, DEFAULT_PLACEHOLDER_IMAGE_SRC as ve, DEFAULT_PLACEHOLDER_ALT as xe, DEFAULT_MAX_COLUMNS as Ue, DEFAULT_MAX_ROWS as ke, DEFAULT_PRESENTATION_TYPE as Pe, OVERLAY_ICON as Me } from "../constants.js";
|
|
4
|
+
function $e(P) {
|
|
5
|
+
return {
|
|
6
|
+
target: {
|
|
7
|
+
value: P
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function Ke(P) {
|
|
12
|
+
const {
|
|
13
|
+
value: d,
|
|
14
|
+
onChange: V,
|
|
15
|
+
endpoint: w,
|
|
16
|
+
refetchOnOpen: B = !1,
|
|
17
|
+
getOptionLabel: se,
|
|
18
|
+
getOptionImage: oe,
|
|
19
|
+
isOptionEqualToValue: T,
|
|
20
|
+
presentationType: u = Pe,
|
|
21
|
+
imageSize: h,
|
|
22
|
+
maxColumns: i = Ue,
|
|
23
|
+
maxRows: g = ke,
|
|
24
|
+
size: O = "medium",
|
|
25
|
+
disabled: s = !1,
|
|
26
|
+
error: I = !1,
|
|
27
|
+
timeout: L = ye,
|
|
28
|
+
parms: S,
|
|
29
|
+
resultField: D = Fe,
|
|
30
|
+
isExternalUrl: R = !1,
|
|
31
|
+
isRemote: _ = !0,
|
|
32
|
+
responseToCamelCase: b,
|
|
33
|
+
forwardedRef: A,
|
|
34
|
+
blurHandler: z
|
|
35
|
+
} = P, { host_static_assets: G, environment_assets: X } = De(), { networkOperation: Y } = Re(), J = E(null), W = E(null), M = E(null), $ = E([]), p = E(null), y = E(!1), [le, F] = C(!1), [r, j] = C(!1), [o, v] = C([]), [Q, Z] = C(!1), [N, ce] = C(null), q = be(), H = k(() => JSON.stringify({
|
|
36
|
+
endpoint: w,
|
|
37
|
+
isExternalUrl: R,
|
|
38
|
+
isRemote: _,
|
|
39
|
+
parms: S ?? null,
|
|
40
|
+
responseToCamelCase: b ?? null,
|
|
41
|
+
resultField: D,
|
|
42
|
+
timeout: L
|
|
43
|
+
}), [
|
|
44
|
+
w,
|
|
45
|
+
R,
|
|
46
|
+
_,
|
|
47
|
+
S,
|
|
48
|
+
b,
|
|
49
|
+
D,
|
|
50
|
+
L
|
|
51
|
+
]), ee = u === "grid" || r;
|
|
52
|
+
if (!w)
|
|
53
|
+
throw new Error("ImageSelector requires the endpoint prop.");
|
|
54
|
+
re(() => {
|
|
55
|
+
if (!ee)
|
|
56
|
+
return;
|
|
57
|
+
if (!B && W.current === H && M.current !== null) {
|
|
58
|
+
F(!1), v(M.current);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
let e = !1;
|
|
62
|
+
J.current?.abort();
|
|
63
|
+
const t = new AbortController();
|
|
64
|
+
return J.current = t, F(!0), v([]), Y({
|
|
65
|
+
method: "GET",
|
|
66
|
+
endPoint: w,
|
|
67
|
+
timeout: L,
|
|
68
|
+
isExternalUrl: R,
|
|
69
|
+
parms: S,
|
|
70
|
+
responseToCamelCase: b,
|
|
71
|
+
isRemote: _,
|
|
72
|
+
signal: t.signal
|
|
73
|
+
}).then((l) => {
|
|
74
|
+
if (e)
|
|
75
|
+
return;
|
|
76
|
+
const c = _e(l, D), ne = Array.isArray(c) ? c : [];
|
|
77
|
+
W.current = H, M.current = ne, v(ne), F(!1);
|
|
78
|
+
}).catch(() => {
|
|
79
|
+
e || (v([]), F(!1));
|
|
80
|
+
}), () => {
|
|
81
|
+
e = !0, t.abort();
|
|
82
|
+
};
|
|
83
|
+
}, [
|
|
84
|
+
w,
|
|
85
|
+
R,
|
|
86
|
+
_,
|
|
87
|
+
Y,
|
|
88
|
+
S,
|
|
89
|
+
B,
|
|
90
|
+
H,
|
|
91
|
+
b,
|
|
92
|
+
D,
|
|
93
|
+
ee,
|
|
94
|
+
L
|
|
95
|
+
]);
|
|
96
|
+
const f = d != null, ue = f ? oe(d) : `${G}/${X}/${ve}`, ae = f ? se(d) : xe, ie = `${G}/${X}/${Me}`, te = i > 0 && g > 0 && o.length > i * g, fe = k(() => ({
|
|
97
|
+
disabled: s,
|
|
98
|
+
error: I,
|
|
99
|
+
hasValue: f,
|
|
100
|
+
imageSize: h,
|
|
101
|
+
isFocused: Q,
|
|
102
|
+
isOpen: r,
|
|
103
|
+
maxColumns: i,
|
|
104
|
+
maxRows: g,
|
|
105
|
+
presentationType: u,
|
|
106
|
+
size: O
|
|
107
|
+
}), [
|
|
108
|
+
s,
|
|
109
|
+
I,
|
|
110
|
+
f,
|
|
111
|
+
h,
|
|
112
|
+
Q,
|
|
113
|
+
i,
|
|
114
|
+
g,
|
|
115
|
+
r,
|
|
116
|
+
u,
|
|
117
|
+
O
|
|
118
|
+
]), de = k(() => ({
|
|
119
|
+
disabled: s,
|
|
120
|
+
error: I,
|
|
121
|
+
hasVerticalScroll: te,
|
|
122
|
+
imageSize: h,
|
|
123
|
+
maxColumns: i,
|
|
124
|
+
maxRows: g,
|
|
125
|
+
presentationType: u,
|
|
126
|
+
size: O
|
|
127
|
+
}), [s, I, te, h, i, g, u, O]), pe = k(() => ({
|
|
128
|
+
disabled: s,
|
|
129
|
+
imageSize: h,
|
|
130
|
+
isOpen: r,
|
|
131
|
+
isPlaceholder: !f,
|
|
132
|
+
presentationType: u,
|
|
133
|
+
size: O
|
|
134
|
+
}), [s, f, h, r, u, O]), x = n((e = !1) => {
|
|
135
|
+
if (f) {
|
|
136
|
+
const t = o.findIndex((l) => T(l, d));
|
|
137
|
+
if (t >= 0)
|
|
138
|
+
return t;
|
|
139
|
+
}
|
|
140
|
+
return e && o.length > 0 ? o.length - 1 : 0;
|
|
141
|
+
}, [f, T, o, d]), U = n((e) => {
|
|
142
|
+
if (o.length === 0)
|
|
143
|
+
return;
|
|
144
|
+
const t = Math.max(0, Math.min(e, o.length - 1));
|
|
145
|
+
$.current[t]?.focus();
|
|
146
|
+
}, [o.length]), he = n((e) => {
|
|
147
|
+
if (ce(e), typeof A == "function") {
|
|
148
|
+
A(e);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
A && (A.current = e);
|
|
152
|
+
}, [A]), m = n((e) => {
|
|
153
|
+
s || (typeof e < "u" && (p.current = e), j(!0));
|
|
154
|
+
}, [s]), K = n((e = !1) => {
|
|
155
|
+
const t = e ? "selected-or-last" : "selected-or-first";
|
|
156
|
+
p.current = t, r && o.length > 0 && (U(x(e)), p.current = null);
|
|
157
|
+
}, [U, x, r, o.length]), a = n((e = !1) => {
|
|
158
|
+
p.current = null, y.current = e, j(!1);
|
|
159
|
+
}, []), ge = n(() => {
|
|
160
|
+
if (r) {
|
|
161
|
+
a();
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
m("selected-or-first");
|
|
165
|
+
}, [a, m, r]), Oe = n(() => {
|
|
166
|
+
Z(!0);
|
|
167
|
+
}, []), me = n((e) => {
|
|
168
|
+
Z(!1), z?.(e);
|
|
169
|
+
}, [z]), Ee = n((e, t) => {
|
|
170
|
+
$.current[e] = t;
|
|
171
|
+
const l = p.current, c = typeof l == "number" ? l : l === null ? null : x(l === "selected-or-last");
|
|
172
|
+
t && c === e && (p.current = null, t.focus());
|
|
173
|
+
}, [x]), we = n((e) => {
|
|
174
|
+
p.current = null;
|
|
175
|
+
}, []), Ae = n((e) => `${q}-option-${e}`, [q]), Ce = n((e, t) => {
|
|
176
|
+
if (s || o.length === 0)
|
|
177
|
+
return;
|
|
178
|
+
const l = typeof i == "number" && i > 0 ? i : null;
|
|
179
|
+
let c = null;
|
|
180
|
+
switch (t.key) {
|
|
181
|
+
case "ArrowRight":
|
|
182
|
+
c = e + 1;
|
|
183
|
+
break;
|
|
184
|
+
case "ArrowLeft":
|
|
185
|
+
c = e - 1;
|
|
186
|
+
break;
|
|
187
|
+
case "ArrowDown":
|
|
188
|
+
if (!l)
|
|
189
|
+
return;
|
|
190
|
+
c = e + l;
|
|
191
|
+
break;
|
|
192
|
+
case "ArrowUp":
|
|
193
|
+
if (!l)
|
|
194
|
+
return;
|
|
195
|
+
c = e - l;
|
|
196
|
+
break;
|
|
197
|
+
case "Home":
|
|
198
|
+
c = 0;
|
|
199
|
+
break;
|
|
200
|
+
case "End":
|
|
201
|
+
c = o.length - 1;
|
|
202
|
+
break;
|
|
203
|
+
case "Escape":
|
|
204
|
+
u === "standard" && (t.preventDefault(), a(!0));
|
|
205
|
+
return;
|
|
206
|
+
default:
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
c !== null && (t.preventDefault(), U(c));
|
|
210
|
+
}, [s, U, a, i, o.length, u]), Te = n((e) => {
|
|
211
|
+
if (!s)
|
|
212
|
+
switch (e.key) {
|
|
213
|
+
case "Enter":
|
|
214
|
+
case " ": {
|
|
215
|
+
if (e.preventDefault(), r) {
|
|
216
|
+
a();
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
m("selected-or-first");
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
case "ArrowDown":
|
|
223
|
+
if (e.preventDefault(), r) {
|
|
224
|
+
K();
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
m("selected-or-first");
|
|
228
|
+
return;
|
|
229
|
+
case "ArrowUp":
|
|
230
|
+
if (e.preventDefault(), r) {
|
|
231
|
+
K(!0);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
m("selected-or-last");
|
|
235
|
+
return;
|
|
236
|
+
case "Escape":
|
|
237
|
+
e.preventDefault(), a();
|
|
238
|
+
return;
|
|
239
|
+
default:
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
}, [s, K, a, m, r]), Ie = n((e) => f ? T(e, d) : !1, [f, T, d]), Le = n((e) => {
|
|
243
|
+
s || (V?.($e(e), e), u === "standard" && a(!0));
|
|
244
|
+
}, [s, a, V, u]), Se = n(() => {
|
|
245
|
+
a();
|
|
246
|
+
}, [a]);
|
|
247
|
+
return re(() => {
|
|
248
|
+
r || ($.current = [], y.current && queueMicrotask(() => {
|
|
249
|
+
y.current && (y.current = !1, N?.focus());
|
|
250
|
+
}));
|
|
251
|
+
}, [r, N]), {
|
|
252
|
+
getOptionId: Ae,
|
|
253
|
+
handleBlur: me,
|
|
254
|
+
handleFocus: Oe,
|
|
255
|
+
handleKeyDown: Te,
|
|
256
|
+
handleOptionFocus: we,
|
|
257
|
+
handleOptionKeyDown: Ce,
|
|
258
|
+
handleOptionRef: Ee,
|
|
259
|
+
handlePopoverClose: Se,
|
|
260
|
+
handleSelect: Le,
|
|
261
|
+
handleToggle: ge,
|
|
262
|
+
handleTriggerRef: he,
|
|
263
|
+
gridOwnerState: de,
|
|
264
|
+
isOptionSelected: Ie,
|
|
265
|
+
loading: le,
|
|
266
|
+
open: r,
|
|
267
|
+
options: o,
|
|
268
|
+
optionsListId: q,
|
|
269
|
+
overlayIconSrc: ie,
|
|
270
|
+
previewLabel: ae,
|
|
271
|
+
previewOwnerState: pe,
|
|
272
|
+
previewSource: ue,
|
|
273
|
+
rootOwnerState: fe,
|
|
274
|
+
triggerElement: N
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
export {
|
|
278
|
+
Ke as useImageSelector
|
|
279
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../packages/components/src/components/ImageSelector/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,oCAAoC,EAAE,MAAM,cAAc,CAAC;AACpE,YAAY,EACV,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare enum ImageSelectorSlots {
|
|
2
|
+
root = "root",
|
|
3
|
+
trigger = "trigger",
|
|
4
|
+
previewFrame = "previewFrame",
|
|
5
|
+
previewImage = "previewImage",
|
|
6
|
+
overlay = "overlay",
|
|
7
|
+
overlayIcon = "overlayIcon",
|
|
8
|
+
popover = "popover",
|
|
9
|
+
optionsGrid = "optionsGrid",
|
|
10
|
+
option = "option",
|
|
11
|
+
optionImage = "optionImage",
|
|
12
|
+
loadingState = "loadingState",
|
|
13
|
+
emptyState = "emptyState"
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ImageSelectorEnum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageSelectorEnum.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/components/ImageSelector/slots/ImageSelectorEnum.ts"],"names":[],"mappings":"AAAA,oBAAY,kBAAkB;IAC5B,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,YAAY,iBAAiB;IAC7B,YAAY,iBAAiB;IAC7B,OAAO,YAAY;IACnB,WAAW,gBAAgB;IAC3B,OAAO,YAAY;IACnB,WAAW,gBAAgB;IAC3B,MAAM,WAAW;IACjB,WAAW,gBAAgB;IAC3B,YAAY,iBAAiB;IAC7B,UAAU,eAAe;CAC1B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
var i = /* @__PURE__ */ ((p) => (p.root = "root", p.trigger = "trigger", p.previewFrame = "previewFrame", p.previewImage = "previewImage", p.overlay = "overlay", p.overlayIcon = "overlayIcon", p.popover = "popover", p.optionsGrid = "optionsGrid", p.option = "option", p.optionImage = "optionImage", p.loadingState = "loadingState", p.emptyState = "emptyState", p))(i || {});
|
|
2
|
+
export {
|
|
3
|
+
i as ImageSelectorSlots
|
|
4
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ImageSelectorOwnerState } from '../types';
|
|
2
|
+
type ImageSelectorStyledProps = {
|
|
3
|
+
ownerState?: ImageSelectorOwnerState;
|
|
4
|
+
};
|
|
5
|
+
declare const RootStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & ImageSelectorStyledProps, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
6
|
+
declare const TriggerStyled: import('@emotion/styled').StyledComponent<import('@mui/material').ButtonBaseOwnProps & Omit<import('@mui/material').ButtonBaseOwnProps, "classes"> & import('@mui/material/OverridableComponent').CommonProps & Omit<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "action" | "className" | "style" | "classes" | "children" | "sx" | "tabIndex" | "disabled" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef"> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & ImageSelectorStyledProps, {}, {}>;
|
|
7
|
+
declare const PreviewFrameStyled: import('@emotion/styled').StyledComponent<import('@mui/system').BoxOwnProps<import('@mui/material').Theme> & Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import('@mui/system').BoxOwnProps<import('@mui/material').Theme>> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & ImageSelectorStyledProps, {}, {}>;
|
|
8
|
+
declare const PreviewImageStyled: import('@emotion/styled').StyledComponent<import('../..').ImageProps & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & ImageSelectorStyledProps, {}, {}>;
|
|
9
|
+
declare const OverlayStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & ImageSelectorStyledProps, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, {}>;
|
|
10
|
+
declare const OverlayIconStyled: import('@emotion/styled').StyledComponent<Pick<import('@mui/material').SvgIconOwnProps & import('@mui/material/OverridableComponent').CommonProps & Omit<import('react').SVGProps<SVGSVGElement>, "color" | "fontSize" | "shapeRendering" | "className" | "style" | "classes" | "children" | "sx" | "viewBox" | "htmlColor" | "inheritViewBox" | "titleAccess">, "string" | "version" | "color" | "alignmentBaseline" | "baselineShift" | "clipPath" | "clipRule" | "colorInterpolationFilters" | "cursor" | "cx" | "cy" | "d" | "direction" | "display" | "dominantBaseline" | "fill" | "fillOpacity" | "fillRule" | "filter" | "floodColor" | "floodOpacity" | "fontFamily" | "fontSize" | "fontSizeAdjust" | "fontStyle" | "fontVariant" | "fontWeight" | "height" | "imageRendering" | "letterSpacing" | "lightingColor" | "markerEnd" | "markerMid" | "markerStart" | "opacity" | "order" | "paintOrder" | "pointerEvents" | "r" | "rotate" | "rx" | "ry" | "scale" | "shapeRendering" | "stopColor" | "stopOpacity" | "stroke" | "strokeDasharray" | "strokeDashoffset" | "strokeLinecap" | "strokeLinejoin" | "strokeMiterlimit" | "strokeOpacity" | "strokeWidth" | "textAnchor" | "textRendering" | "transform" | "unicodeBidi" | "vectorEffect" | "visibility" | "width" | "wordSpacing" | "writingMode" | "x" | "y" | "mask" | "offset" | "overflow" | "textDecoration" | "clip" | "fontStretch" | "colorInterpolation" | "colorRendering" | "glyphOrientationVertical" | "mode" | "end" | "className" | "style" | "classes" | "children" | "sx" | "path" | "ref" | "key" | "suppressHydrationWarning" | "id" | "lang" | "tabIndex" | "role" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-braillelabel" | "aria-brailleroledescription" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colindextext" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-description" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowindextext" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerLeave" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onScrollEnd" | "onScrollEndCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onToggle" | "onBeforeToggle" | "onTransitionCancel" | "onTransitionCancelCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "onTransitionRun" | "onTransitionRunCapture" | "onTransitionStart" | "onTransitionStartCapture" | "name" | "values" | "max" | "type" | "href" | "media" | "target" | "elevation" | "in" | "alphabetic" | "ideographic" | "mathematical" | "accumulate" | "local" | "hanging" | "unicode" | "method" | "min" | "crossOrigin" | "accentHeight" | "additive" | "allowReorder" | "amplitude" | "arabicForm" | "ascent" | "attributeName" | "attributeType" | "autoReverse" | "azimuth" | "baseFrequency" | "baseProfile" | "bbox" | "begin" | "bias" | "by" | "calcMode" | "capHeight" | "clipPathUnits" | "colorProfile" | "contentScriptType" | "contentStyleType" | "decelerate" | "descent" | "diffuseConstant" | "divisor" | "dur" | "dx" | "dy" | "edgeMode" | "enableBackground" | "exponent" | "externalResourcesRequired" | "filterRes" | "filterUnits" | "focusable" | "format" | "fr" | "from" | "fx" | "fy" | "g1" | "g2" | "glyphName" | "glyphOrientationHorizontal" | "glyphRef" | "gradientTransform" | "gradientUnits" | "horizAdvX" | "horizOriginX" | "in2" | "intercept" | "k1" | "k2" | "k3" | "k4" | "k" | "kernelMatrix" | "kernelUnitLength" | "kerning" | "keyPoints" | "keySplines" | "keyTimes" | "lengthAdjust" | "limitingConeAngle" | "markerHeight" | "markerUnits" | "markerWidth" | "maskContentUnits" | "maskUnits" | "numOctaves" | "operator" | "orient" | "orientation" | "origin" | "overlinePosition" | "overlineThickness" | "panose1" | "pathLength" | "patternContentUnits" | "patternTransform" | "patternUnits" | "points" | "pointsAtX" | "pointsAtY" | "pointsAtZ" | "preserveAlpha" | "preserveAspectRatio" | "primitiveUnits" | "radius" | "refX" | "refY" | "renderingIntent" | "repeatCount" | "repeatDur" | "requiredExtensions" | "requiredFeatures" | "restart" | "result" | "seed" | "slope" | "spacing" | "specularConstant" | "specularExponent" | "speed" | "spreadMethod" | "startOffset" | "stdDeviation" | "stemh" | "stemv" | "stitchTiles" | "strikethroughPosition" | "strikethroughThickness" | "surfaceScale" | "systemLanguage" | "tableValues" | "targetX" | "targetY" | "textLength" | "to" | "u1" | "u2" | "underlinePosition" | "underlineThickness" | "unicodeRange" | "unitsPerEm" | "vAlphabetic" | "vertAdvY" | "vertOriginX" | "vertOriginY" | "vHanging" | "vIdeographic" | "viewBox" | "viewTarget" | "vMathematical" | "widths" | "x1" | "x2" | "xChannelSelector" | "xHeight" | "xlinkActuate" | "xlinkArcrole" | "xlinkHref" | "xlinkRole" | "xlinkShow" | "xlinkTitle" | "xlinkType" | "xmlBase" | "xmlLang" | "xmlns" | "xmlnsXlink" | "xmlSpace" | "y1" | "y2" | "yChannelSelector" | "z" | "zoomAndPan" | "htmlColor" | "inheritViewBox" | "titleAccess"> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme>, {}, {}>;
|
|
11
|
+
declare const PopoverStyled: import('@emotion/styled').StyledComponent<Pick<import('../../extended/mui/Popover/types').PopoverProps, keyof import('../../extended/mui/Popover/types').PopoverProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme>, {}, {}>;
|
|
12
|
+
declare const OptionsGridStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & ImageSelectorStyledProps, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
13
|
+
declare const OptionButtonStyled: import('@emotion/styled').StyledComponent<import('@mui/material').ButtonBaseOwnProps & Omit<import('@mui/material').ButtonBaseOwnProps, "classes"> & import('@mui/material/OverridableComponent').CommonProps & Omit<import('react').DetailedHTMLProps<import('react').ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "action" | "className" | "style" | "classes" | "children" | "sx" | "tabIndex" | "disabled" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef"> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & ImageSelectorStyledProps, {}, {}>;
|
|
14
|
+
declare const OptionImageStyled: import('@emotion/styled').StyledComponent<Pick<import('../..').ImageProps, keyof import('../..').ImageProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme>, {}, {}>;
|
|
15
|
+
declare const LoadingStateStyled: import('@emotion/styled').StyledComponent<import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & ImageSelectorStyledProps, import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
|
|
16
|
+
declare const EmptyStateStyled: import('@emotion/styled').StyledComponent<Omit<import('@m4l/base').TypographyProps, "ref"> & import('react').RefAttributes<HTMLSpanElement> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme> & ImageSelectorStyledProps, {}, {}>;
|
|
17
|
+
declare const CircularProgressStyled: import('@emotion/styled').StyledComponent<Pick<import('../../extended/mui/CircularProgress/types').CircularProgressProps, keyof import('../../extended/mui/CircularProgress/types').CircularProgressProps> & import('@mui/system').MUIStyledCommonProps<import('@mui/material').Theme>, {}, {}>;
|
|
18
|
+
export { CircularProgressStyled, EmptyStateStyled, OptionButtonStyled, OptionImageStyled, OptionsGridStyled, OverlayIconStyled, OverlayStyled, PopoverStyled, PreviewFrameStyled, PreviewImageStyled, RootStyled, TriggerStyled, LoadingStateStyled, };
|
|
19
|
+
//# sourceMappingURL=ImageSelectorSlots.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageSelectorSlots.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/components/ImageSelector/slots/ImageSelectorSlots.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAGxD,KAAK,wBAAwB,GAAG;IAC9B,UAAU,CAAC,EAAE,uBAAuB,CAAC;CACtC,CAAC;AAEF,QAAA,MAAM,UAAU,wPAIsC,CAAC;AAEvD,QAAA,MAAM,aAAa,ksBAIsC,CAAC;AAE1D,QAAA,MAAM,kBAAkB,8YAIsC,CAAC;AAE/D,QAAA,MAAM,kBAAkB,sLAIsC,CAAC;AAE/D,QAAA,MAAM,aAAa,0PAIsC,CAAC;AAE1D,QAAA,MAAM,iBAAiB,myQAGY,CAAC;AAEpC,QAAA,MAAM,aAAa,6PAGY,CAAC;AAEhC,QAAA,MAAM,iBAAiB,wPAIsC,CAAC;AAE9D,QAAA,MAAM,kBAAkB,ksBAIgC,CAAC;AAEzD,QAAA,MAAM,iBAAiB,mMAGY,CAAC;AAEpC,QAAA,MAAM,kBAAkB,wPAIsC,CAAC;AAE/D,QAAA,MAAM,gBAAgB,6PAIsC,CAAC;AAE7D,QAAA,MAAM,sBAAsB,iSAGG,CAAC;AAChC,OAAO,EACL,sBAAsB,EACtB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,kBAAkB,EAClB,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,kBAAkB,GACnB,CAAC"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { ButtonBase as n, Box as m } from "@mui/material";
|
|
2
|
+
import { styled as t } from "@mui/material/styles";
|
|
3
|
+
import { ArrowRefreshMdOutlined as s } from "@m4l/icons";
|
|
4
|
+
import { Typography as p } from "@m4l/base";
|
|
5
|
+
import { imageSelectorStyles as e } from "../ImageSelector.styles.js";
|
|
6
|
+
import { IMAGE_SELECTOR_KEY_COMPONENT as r } from "../constants.js";
|
|
7
|
+
import { ImageSelectorSlots as a } from "./ImageSelectorEnum.js";
|
|
8
|
+
import { CircularProgress as d } from "../../extended/mui/CircularProgress/CircularProgress.js";
|
|
9
|
+
import { Image as l } from "../../Image/Image.js";
|
|
10
|
+
import { Popover as i } from "../../extended/mui/Popover/Popover.js";
|
|
11
|
+
const h = t("div", {
|
|
12
|
+
name: r,
|
|
13
|
+
slot: a.root,
|
|
14
|
+
shouldForwardProp: (o) => o !== "ownerState"
|
|
15
|
+
})(e.root), I = t(n, {
|
|
16
|
+
name: r,
|
|
17
|
+
slot: a.trigger,
|
|
18
|
+
shouldForwardProp: (o) => o !== "ownerState"
|
|
19
|
+
})(e.trigger), O = t(m, {
|
|
20
|
+
name: r,
|
|
21
|
+
slot: a.previewFrame,
|
|
22
|
+
shouldForwardProp: (o) => o !== "ownerState"
|
|
23
|
+
})(e.previewFrame), E = t(l, {
|
|
24
|
+
name: r,
|
|
25
|
+
slot: a.previewImage,
|
|
26
|
+
shouldForwardProp: (o) => o !== "ownerState"
|
|
27
|
+
})(e.previewImage), B = t("span", {
|
|
28
|
+
name: r,
|
|
29
|
+
slot: a.overlay,
|
|
30
|
+
shouldForwardProp: (o) => o !== "ownerState"
|
|
31
|
+
})(e.overlay);
|
|
32
|
+
t(s, {
|
|
33
|
+
name: r,
|
|
34
|
+
slot: a.overlayIcon
|
|
35
|
+
})(e.overlayIcon);
|
|
36
|
+
const C = t(i, {
|
|
37
|
+
name: r,
|
|
38
|
+
slot: a.popover
|
|
39
|
+
})(e.popover), G = t("div", {
|
|
40
|
+
name: r,
|
|
41
|
+
slot: a.optionsGrid,
|
|
42
|
+
shouldForwardProp: (o) => o !== "ownerState"
|
|
43
|
+
})(e.optionsGrid), T = t(n, {
|
|
44
|
+
name: r,
|
|
45
|
+
slot: a.option,
|
|
46
|
+
shouldForwardProp: (o) => o !== "ownerState"
|
|
47
|
+
})(e.option), M = t(l, {
|
|
48
|
+
name: r,
|
|
49
|
+
slot: a.optionImage
|
|
50
|
+
})(e.optionImage), R = t("div", {
|
|
51
|
+
name: r,
|
|
52
|
+
slot: a.loadingState,
|
|
53
|
+
shouldForwardProp: (o) => o !== "ownerState"
|
|
54
|
+
})(e.loadingState), _ = t(p, {
|
|
55
|
+
name: r,
|
|
56
|
+
slot: a.emptyState,
|
|
57
|
+
shouldForwardProp: (o) => o !== "ownerState"
|
|
58
|
+
})(e.emptyState), x = t(d, {
|
|
59
|
+
name: r,
|
|
60
|
+
slot: a.loadingState
|
|
61
|
+
})(e.trigger);
|
|
62
|
+
export {
|
|
63
|
+
x as CircularProgressStyled,
|
|
64
|
+
_ as EmptyStateStyled,
|
|
65
|
+
R as LoadingStateStyled,
|
|
66
|
+
T as OptionButtonStyled,
|
|
67
|
+
M as OptionImageStyled,
|
|
68
|
+
G as OptionsGridStyled,
|
|
69
|
+
B as OverlayStyled,
|
|
70
|
+
C as PopoverStyled,
|
|
71
|
+
O as PreviewFrameStyled,
|
|
72
|
+
E as PreviewImageStyled,
|
|
73
|
+
h as RootStyled,
|
|
74
|
+
I as TriggerStyled
|
|
75
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../packages/components/src/components/ImageSelector/slots/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { Interpolation, Theme } from '@mui/material';
|
|
2
|
+
import { Sizes } from '@m4l/styles';
|
|
3
|
+
import { ChangeEvent, FocusEvent, KeyboardEvent, Ref } from 'react';
|
|
4
|
+
import { ImageSelectorSlots } from './slots/ImageSelectorEnum';
|
|
5
|
+
export type ImageSelectorChangeHandler<T = unknown> = (event: ChangeEvent<unknown>, value: T | null) => void;
|
|
6
|
+
export type ImageSelectorPresentationType = 'standard' | 'grid';
|
|
7
|
+
export interface ImageSelectorProps<T = unknown> {
|
|
8
|
+
/**
|
|
9
|
+
* Controlled selected option.
|
|
10
|
+
*/
|
|
11
|
+
value: T | null | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Called when the selected image changes.
|
|
14
|
+
*/
|
|
15
|
+
onChange?: ImageSelectorChangeHandler<T>;
|
|
16
|
+
/**
|
|
17
|
+
* Endpoint used to fetch options for the popover grid.
|
|
18
|
+
*/
|
|
19
|
+
endpoint: string;
|
|
20
|
+
/**
|
|
21
|
+
* Whether the selector should refetch options every time the popover opens.
|
|
22
|
+
*/
|
|
23
|
+
refetchOnOpen?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Returns the accessible label for an option.
|
|
26
|
+
*/
|
|
27
|
+
getOptionLabel: (option: T) => string;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the image URL for an option.
|
|
30
|
+
*/
|
|
31
|
+
getOptionImage: (option: T) => string;
|
|
32
|
+
/**
|
|
33
|
+
* Compares an option against the selected value.
|
|
34
|
+
*/
|
|
35
|
+
isOptionEqualToValue: (option: T, value: T) => boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Render mode for the selector surface.
|
|
38
|
+
*/
|
|
39
|
+
presentationType?: ImageSelectorPresentationType;
|
|
40
|
+
/**
|
|
41
|
+
* Square image size used by the selector surfaces when provided.
|
|
42
|
+
*/
|
|
43
|
+
imageSize?: number;
|
|
44
|
+
/**
|
|
45
|
+
* Maximum number of visible columns before the options wrap.
|
|
46
|
+
*/
|
|
47
|
+
maxColumns?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Maximum number of visible rows before vertical scrolling is applied.
|
|
50
|
+
*/
|
|
51
|
+
maxRows?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Visual density for the trigger and option content.
|
|
54
|
+
*/
|
|
55
|
+
size?: Extract<Sizes, 'small' | 'medium'>;
|
|
56
|
+
/**
|
|
57
|
+
* Disables the selector trigger and option changes.
|
|
58
|
+
*/
|
|
59
|
+
disabled?: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Marks the selector trigger with an error state.
|
|
62
|
+
*/
|
|
63
|
+
error?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Optional CSS class name.
|
|
66
|
+
*/
|
|
67
|
+
className?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Optional test id suffix.
|
|
70
|
+
*/
|
|
71
|
+
dataTestId?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Trigger id.
|
|
74
|
+
*/
|
|
75
|
+
id?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Trigger name.
|
|
78
|
+
*/
|
|
79
|
+
name?: string;
|
|
80
|
+
/**
|
|
81
|
+
* Network timeout used for the async request.
|
|
82
|
+
*/
|
|
83
|
+
timeout?: number;
|
|
84
|
+
/**
|
|
85
|
+
* Request params merged into the async request.
|
|
86
|
+
*/
|
|
87
|
+
parms?: Record<string, unknown>;
|
|
88
|
+
/**
|
|
89
|
+
* Response field that contains the option list.
|
|
90
|
+
*/
|
|
91
|
+
resultField?: string;
|
|
92
|
+
/**
|
|
93
|
+
* Whether the endpoint is external to the current host.
|
|
94
|
+
*/
|
|
95
|
+
isExternalUrl?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Whether the request should use the remote network client.
|
|
98
|
+
*/
|
|
99
|
+
isRemote?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Whether the response should be transformed to camelCase.
|
|
102
|
+
*/
|
|
103
|
+
responseToCamelCase?: boolean;
|
|
104
|
+
}
|
|
105
|
+
export interface ImageSelectorOwnerState extends Pick<ImageSelectorProps<unknown>, 'presentationType' | 'imageSize' | 'maxColumns' | 'maxRows' | 'disabled' | 'error' | 'size'> {
|
|
106
|
+
hasVerticalScroll?: boolean;
|
|
107
|
+
hasValue?: boolean;
|
|
108
|
+
isFocused?: boolean;
|
|
109
|
+
isOpen?: boolean;
|
|
110
|
+
isPlaceholder?: boolean;
|
|
111
|
+
selected?: boolean;
|
|
112
|
+
}
|
|
113
|
+
export type ImageSelectorSlotsType = keyof typeof ImageSelectorSlots;
|
|
114
|
+
export interface ImageSelectorStyleRuleProps {
|
|
115
|
+
ownerState?: ImageSelectorOwnerState;
|
|
116
|
+
theme: Theme;
|
|
117
|
+
}
|
|
118
|
+
export type ImageSelectorStyles = Record<ImageSelectorSlotsType, Interpolation<ImageSelectorStyleRuleProps>>;
|
|
119
|
+
export interface UseImageSelectorProps<T = unknown> {
|
|
120
|
+
/**
|
|
121
|
+
* Controlled selected option.
|
|
122
|
+
*/
|
|
123
|
+
value: T | null | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Called when the selected image changes.
|
|
126
|
+
*/
|
|
127
|
+
onChange?: ImageSelectorChangeHandler<T>;
|
|
128
|
+
/**
|
|
129
|
+
* Endpoint used to fetch options for the popover grid.
|
|
130
|
+
*/
|
|
131
|
+
endpoint: string;
|
|
132
|
+
/**
|
|
133
|
+
* Whether the selector should refetch options every time the popover opens.
|
|
134
|
+
*/
|
|
135
|
+
refetchOnOpen?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Returns the accessible label for an option.
|
|
138
|
+
*/
|
|
139
|
+
getOptionLabel: (option: T) => string;
|
|
140
|
+
/**
|
|
141
|
+
* Returns the image URL for an option.
|
|
142
|
+
*/
|
|
143
|
+
getOptionImage: (option: T) => string;
|
|
144
|
+
/**
|
|
145
|
+
* Compares an option against the selected value.
|
|
146
|
+
*/
|
|
147
|
+
isOptionEqualToValue: (option: T, value: T) => boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Render mode for the selector surface.
|
|
150
|
+
*/
|
|
151
|
+
presentationType?: ImageSelectorPresentationType;
|
|
152
|
+
/**
|
|
153
|
+
* Square image size used by the selector surfaces when provided.
|
|
154
|
+
*/
|
|
155
|
+
imageSize?: number;
|
|
156
|
+
/**
|
|
157
|
+
* Maximum number of visible columns before the options wrap.
|
|
158
|
+
*/
|
|
159
|
+
maxColumns?: number;
|
|
160
|
+
/**
|
|
161
|
+
* Maximum number of visible rows before vertical scrolling is applied.
|
|
162
|
+
*/
|
|
163
|
+
maxRows?: number;
|
|
164
|
+
/**
|
|
165
|
+
* Visual density for the trigger and option content.
|
|
166
|
+
*/
|
|
167
|
+
size?: Extract<Sizes, 'small' | 'medium'>;
|
|
168
|
+
disabled?: boolean;
|
|
169
|
+
error?: boolean;
|
|
170
|
+
timeout?: number;
|
|
171
|
+
parms?: Record<string, unknown>;
|
|
172
|
+
resultField?: string;
|
|
173
|
+
isExternalUrl?: boolean;
|
|
174
|
+
isRemote?: boolean;
|
|
175
|
+
responseToCamelCase?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Forwarded trigger ref kept in sync with the internal anchor element.
|
|
178
|
+
*/
|
|
179
|
+
forwardedRef: Ref<HTMLButtonElement>;
|
|
180
|
+
/**
|
|
181
|
+
* Optional internal blur callback used by wrappers such as RHF.
|
|
182
|
+
*/
|
|
183
|
+
blurHandler?: (...args: unknown[]) => void;
|
|
184
|
+
}
|
|
185
|
+
export interface UseImageSelectorResult<T = unknown> {
|
|
186
|
+
getOptionId: (index: number) => string;
|
|
187
|
+
handleBlur: (event: FocusEvent<HTMLButtonElement>) => void;
|
|
188
|
+
handleFocus: () => void;
|
|
189
|
+
handleKeyDown: (event: KeyboardEvent<HTMLButtonElement>) => void;
|
|
190
|
+
handleOptionFocus: (index: number) => void;
|
|
191
|
+
handleOptionKeyDown: (index: number, event: KeyboardEvent<HTMLButtonElement>) => void;
|
|
192
|
+
handleOptionRef: (index: number, node: HTMLButtonElement | null) => void;
|
|
193
|
+
handlePopoverClose: () => void;
|
|
194
|
+
handleSelect: (option: T) => void;
|
|
195
|
+
handleToggle: () => void;
|
|
196
|
+
handleTriggerRef: (node: HTMLButtonElement | null) => void;
|
|
197
|
+
gridOwnerState: ImageSelectorOwnerState;
|
|
198
|
+
isOptionSelected: (option: T) => boolean;
|
|
199
|
+
loading: boolean;
|
|
200
|
+
open: boolean;
|
|
201
|
+
options: T[];
|
|
202
|
+
optionsListId: string;
|
|
203
|
+
overlayIconSrc: string;
|
|
204
|
+
previewLabel: string;
|
|
205
|
+
previewOwnerState: ImageSelectorOwnerState;
|
|
206
|
+
previewSource: string;
|
|
207
|
+
rootOwnerState: ImageSelectorOwnerState;
|
|
208
|
+
triggerElement: HTMLButtonElement | null;
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../packages/components/src/components/ImageSelector/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa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