@dragunio/fe-libs 0.1.6 → 0.1.8
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.md +40 -1
- package/dist/{chunk-NDMLXSI5.mjs → chunk-HM3V3DVO.mjs} +20 -4
- package/dist/icons.d.mts +3 -1
- package/dist/icons.d.ts +3 -1
- package/dist/icons.js +22 -4
- package/dist/icons.mjs +5 -1
- package/dist/index.d.mts +115 -3
- package/dist/index.d.ts +115 -3
- package/dist/index.js +1194 -304
- package/dist/index.mjs +1183 -306
- package/dist/styles.css +278 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2,6 +2,8 @@ import {
|
|
|
2
2
|
ChevronDownIcon,
|
|
3
3
|
ChevronUpIcon,
|
|
4
4
|
CloseIcon,
|
|
5
|
+
MoreHorizontalIcon,
|
|
6
|
+
MoreVerticalIcon,
|
|
5
7
|
PlusIcon,
|
|
6
8
|
SearchIcon,
|
|
7
9
|
arrow_left,
|
|
@@ -21,7 +23,7 @@ import {
|
|
|
21
23
|
search,
|
|
22
24
|
trash,
|
|
23
25
|
x_close
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-HM3V3DVO.mjs";
|
|
25
27
|
|
|
26
28
|
// packages/button/src/index.tsx
|
|
27
29
|
import { forwardRef } from "react";
|
|
@@ -89,21 +91,349 @@ var Button = forwardRef(
|
|
|
89
91
|
);
|
|
90
92
|
Button.displayName = "Button";
|
|
91
93
|
|
|
94
|
+
// packages/button-bar/src/index.tsx
|
|
95
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
96
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
97
|
+
import { createElement } from "react";
|
|
98
|
+
function ButtonBar({
|
|
99
|
+
actions,
|
|
100
|
+
maxVisible = actions.length,
|
|
101
|
+
moreButtonProps,
|
|
102
|
+
moreLabel = "More actions",
|
|
103
|
+
className,
|
|
104
|
+
...props
|
|
105
|
+
}) {
|
|
106
|
+
const [isMoreOpen, setIsMoreOpen] = useState(false);
|
|
107
|
+
const rootRef = useRef(null);
|
|
108
|
+
const moreMenuId = useId();
|
|
109
|
+
const visibleCount = Math.max(0, Math.floor(maxVisible));
|
|
110
|
+
const actionCount = actions.filter(
|
|
111
|
+
(item) => item !== "|"
|
|
112
|
+
).length;
|
|
113
|
+
const hasOverflow = actionCount > visibleCount;
|
|
114
|
+
let visibleActionEndIndex = actions.length;
|
|
115
|
+
if (hasOverflow) {
|
|
116
|
+
visibleActionEndIndex = 0;
|
|
117
|
+
let renderedActionCount = 0;
|
|
118
|
+
while (visibleActionEndIndex < actions.length && renderedActionCount < visibleCount) {
|
|
119
|
+
if (actions[visibleActionEndIndex] !== "|") renderedActionCount += 1;
|
|
120
|
+
visibleActionEndIndex += 1;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
const visibleActions = actions.slice(0, visibleActionEndIndex).filter((item) => item !== "|");
|
|
124
|
+
const overflowItems = actions.slice(visibleActionEndIndex).filter(
|
|
125
|
+
(item, index, items) => item !== "|" || items.slice(0, index).some((candidate) => candidate !== "|") && items.slice(index + 1).some((candidate) => candidate !== "|") && items[index - 1] !== "|"
|
|
126
|
+
);
|
|
127
|
+
const {
|
|
128
|
+
onClick: onMoreClick,
|
|
129
|
+
disabled: moreDisabled,
|
|
130
|
+
"aria-label": moreAriaLabel,
|
|
131
|
+
...moreButtonRestProps
|
|
132
|
+
} = moreButtonProps ?? {};
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
if (!isMoreOpen) return;
|
|
135
|
+
const onPointerDown = (event) => {
|
|
136
|
+
if (!rootRef.current?.contains(event.target)) {
|
|
137
|
+
setIsMoreOpen(false);
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
const onKeyDown = (event) => {
|
|
141
|
+
if (event.key === "Escape") setIsMoreOpen(false);
|
|
142
|
+
};
|
|
143
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
144
|
+
document.addEventListener("keydown", onKeyDown);
|
|
145
|
+
return () => {
|
|
146
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
147
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
148
|
+
};
|
|
149
|
+
}, [isMoreOpen]);
|
|
150
|
+
const renderAction = (action, isOverflowAction = false) => {
|
|
151
|
+
const { id, className: className2, onClick, disabled, prefix, ...buttonProps } = action;
|
|
152
|
+
return /* @__PURE__ */ createElement(
|
|
153
|
+
Button,
|
|
154
|
+
{
|
|
155
|
+
...buttonProps,
|
|
156
|
+
className: [className2, isOverflowAction && "fe-button-bar__menu-action"].filter(Boolean).join(" ") || void 0,
|
|
157
|
+
disabled,
|
|
158
|
+
key: id,
|
|
159
|
+
onClick: (event) => {
|
|
160
|
+
onClick?.(event);
|
|
161
|
+
if (isOverflowAction && !disabled) setIsMoreOpen(false);
|
|
162
|
+
},
|
|
163
|
+
prefix: isOverflowAction ? /* @__PURE__ */ jsx2("span", { className: "fe-button-bar__menu-icon", children: prefix }) : prefix
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
};
|
|
167
|
+
return /* @__PURE__ */ jsxs2(
|
|
168
|
+
"div",
|
|
169
|
+
{
|
|
170
|
+
...props,
|
|
171
|
+
className: ["fe-button-bar", className].filter(Boolean).join(" "),
|
|
172
|
+
ref: rootRef,
|
|
173
|
+
children: [
|
|
174
|
+
visibleActions.map((action) => renderAction(action)),
|
|
175
|
+
hasOverflow && /* @__PURE__ */ jsxs2("div", { className: "fe-button-bar__more", children: [
|
|
176
|
+
/* @__PURE__ */ jsx2(
|
|
177
|
+
Button,
|
|
178
|
+
{
|
|
179
|
+
hierarchy: "secondary-gray",
|
|
180
|
+
...moreButtonRestProps,
|
|
181
|
+
"aria-controls": moreMenuId,
|
|
182
|
+
"aria-expanded": isMoreOpen,
|
|
183
|
+
"aria-haspopup": "true",
|
|
184
|
+
"aria-label": moreAriaLabel ?? moreLabel,
|
|
185
|
+
disabled: moreDisabled,
|
|
186
|
+
icon: /* @__PURE__ */ jsx2(MoreHorizontalIcon, {}),
|
|
187
|
+
iconOnly: true,
|
|
188
|
+
onClick: (event) => {
|
|
189
|
+
onMoreClick?.(event);
|
|
190
|
+
if (!event.defaultPrevented) setIsMoreOpen((open) => !open);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
),
|
|
194
|
+
isMoreOpen && /* @__PURE__ */ jsx2(
|
|
195
|
+
"div",
|
|
196
|
+
{
|
|
197
|
+
"aria-label": moreLabel,
|
|
198
|
+
className: "fe-button-bar__menu",
|
|
199
|
+
id: moreMenuId,
|
|
200
|
+
role: "group",
|
|
201
|
+
children: overflowItems.map(
|
|
202
|
+
(item, index) => item === "|" ? /* @__PURE__ */ jsx2(
|
|
203
|
+
"div",
|
|
204
|
+
{
|
|
205
|
+
"aria-orientation": "horizontal",
|
|
206
|
+
className: "fe-button-bar__menu-divider",
|
|
207
|
+
role: "separator"
|
|
208
|
+
},
|
|
209
|
+
`divider-${index}`
|
|
210
|
+
) : renderAction(item, true)
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
] })
|
|
215
|
+
]
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
// packages/tabs/src/index.tsx
|
|
221
|
+
import {
|
|
222
|
+
forwardRef as forwardRef2,
|
|
223
|
+
useCallback,
|
|
224
|
+
useEffect as useEffect2,
|
|
225
|
+
useId as useId2,
|
|
226
|
+
useRef as useRef2,
|
|
227
|
+
useState as useState2
|
|
228
|
+
} from "react";
|
|
229
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
230
|
+
var hasPanel = (item) => Object.prototype.hasOwnProperty.call(item, "content");
|
|
231
|
+
function findSelectableTab(items, value) {
|
|
232
|
+
return items.find((item) => item.id === value && !item.disabled) ?? items.find((item) => !item.disabled);
|
|
233
|
+
}
|
|
234
|
+
function scrollBehavior() {
|
|
235
|
+
return typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
|
|
236
|
+
}
|
|
237
|
+
var Tabs = forwardRef2(function Tabs2({
|
|
238
|
+
items,
|
|
239
|
+
value,
|
|
240
|
+
defaultValue,
|
|
241
|
+
onChange,
|
|
242
|
+
variant = "tab",
|
|
243
|
+
scrollButtons = "auto",
|
|
244
|
+
previousScrollLabel = "Scroll tabs backward",
|
|
245
|
+
nextScrollLabel = "Scroll tabs forward",
|
|
246
|
+
className,
|
|
247
|
+
"aria-label": ariaLabel = "Tabs",
|
|
248
|
+
"aria-labelledby": ariaLabelledBy,
|
|
249
|
+
...props
|
|
250
|
+
}, ref) {
|
|
251
|
+
const generatedId = useId2();
|
|
252
|
+
const listRef = useRef2(null);
|
|
253
|
+
const tabRefs = useRef2(/* @__PURE__ */ new Map());
|
|
254
|
+
const [uncontrolledValue, setUncontrolledValue] = useState2(
|
|
255
|
+
() => findSelectableTab(items, defaultValue)?.id
|
|
256
|
+
);
|
|
257
|
+
const [scrollState, setScrollState] = useState2({
|
|
258
|
+
hasOverflow: false,
|
|
259
|
+
canScrollBackward: false,
|
|
260
|
+
canScrollForward: false
|
|
261
|
+
});
|
|
262
|
+
const activeTab = findSelectableTab(items, value ?? uncontrolledValue);
|
|
263
|
+
const activeIndex = activeTab ? items.findIndex((item) => item.id === activeTab.id) : -1;
|
|
264
|
+
useEffect2(() => {
|
|
265
|
+
if (value === void 0 && activeTab?.id !== uncontrolledValue) {
|
|
266
|
+
setUncontrolledValue(activeTab?.id);
|
|
267
|
+
}
|
|
268
|
+
}, [activeTab?.id, uncontrolledValue, value]);
|
|
269
|
+
const updateScrollState = useCallback(() => {
|
|
270
|
+
const list = listRef.current;
|
|
271
|
+
if (!list) return;
|
|
272
|
+
const maxScroll = Math.max(0, list.scrollWidth - list.clientWidth);
|
|
273
|
+
setScrollState({
|
|
274
|
+
hasOverflow: maxScroll > 1,
|
|
275
|
+
canScrollBackward: list.scrollLeft > 1,
|
|
276
|
+
canScrollForward: list.scrollLeft < maxScroll - 1
|
|
277
|
+
});
|
|
278
|
+
}, []);
|
|
279
|
+
useEffect2(() => {
|
|
280
|
+
const list = listRef.current;
|
|
281
|
+
if (!list) return;
|
|
282
|
+
updateScrollState();
|
|
283
|
+
list.addEventListener("scroll", updateScrollState, { passive: true });
|
|
284
|
+
const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(updateScrollState);
|
|
285
|
+
observer?.observe(list);
|
|
286
|
+
window.addEventListener("resize", updateScrollState);
|
|
287
|
+
return () => {
|
|
288
|
+
list.removeEventListener("scroll", updateScrollState);
|
|
289
|
+
observer?.disconnect();
|
|
290
|
+
window.removeEventListener("resize", updateScrollState);
|
|
291
|
+
};
|
|
292
|
+
}, [items, updateScrollState]);
|
|
293
|
+
useEffect2(() => {
|
|
294
|
+
const tab = activeTab ? tabRefs.current.get(activeTab.id) : void 0;
|
|
295
|
+
tab?.scrollIntoView?.({
|
|
296
|
+
behavior: scrollBehavior(),
|
|
297
|
+
block: "nearest",
|
|
298
|
+
inline: "nearest"
|
|
299
|
+
});
|
|
300
|
+
}, [activeTab?.id]);
|
|
301
|
+
const selectTab = (item, event) => {
|
|
302
|
+
if (item.disabled || item.id === activeTab?.id) return;
|
|
303
|
+
if (value === void 0) setUncontrolledValue(item.id);
|
|
304
|
+
onChange?.(item.id, item, event);
|
|
305
|
+
};
|
|
306
|
+
const selectFromKeyboard = (item, event) => {
|
|
307
|
+
const enabledItems = items.filter((candidate) => !candidate.disabled);
|
|
308
|
+
const currentIndex = enabledItems.findIndex(
|
|
309
|
+
(candidate) => candidate.id === item.id
|
|
310
|
+
);
|
|
311
|
+
if (currentIndex === -1) return;
|
|
312
|
+
let nextIndex;
|
|
313
|
+
if (event.key === "ArrowRight" || event.key === "ArrowDown") {
|
|
314
|
+
nextIndex = (currentIndex + 1) % enabledItems.length;
|
|
315
|
+
} else if (event.key === "ArrowLeft" || event.key === "ArrowUp") {
|
|
316
|
+
nextIndex = (currentIndex - 1 + enabledItems.length) % enabledItems.length;
|
|
317
|
+
} else if (event.key === "Home") {
|
|
318
|
+
nextIndex = 0;
|
|
319
|
+
} else if (event.key === "End") {
|
|
320
|
+
nextIndex = enabledItems.length - 1;
|
|
321
|
+
}
|
|
322
|
+
if (nextIndex === void 0) return;
|
|
323
|
+
event.preventDefault();
|
|
324
|
+
const nextItem = enabledItems[nextIndex];
|
|
325
|
+
if (!nextItem) return;
|
|
326
|
+
tabRefs.current.get(nextItem.id)?.focus();
|
|
327
|
+
selectTab(nextItem, event);
|
|
328
|
+
};
|
|
329
|
+
const scrollTabs = (direction) => {
|
|
330
|
+
const list = listRef.current;
|
|
331
|
+
if (!list) return;
|
|
332
|
+
list.scrollBy({
|
|
333
|
+
left: direction * Math.max(160, Math.round(list.clientWidth * 0.75)),
|
|
334
|
+
behavior: scrollBehavior()
|
|
335
|
+
});
|
|
336
|
+
};
|
|
337
|
+
const showScrollButtons = scrollButtons === "always" || scrollButtons === "auto" && scrollState.hasOverflow;
|
|
338
|
+
const classes = ["fe-tabs", `fe-tabs--${variant}`, className].filter(Boolean).join(" ");
|
|
339
|
+
return /* @__PURE__ */ jsxs3("div", { ...props, className: classes, ref, children: [
|
|
340
|
+
/* @__PURE__ */ jsxs3("div", { className: "fe-tabs__navigation", children: [
|
|
341
|
+
showScrollButtons && /* @__PURE__ */ jsx3(
|
|
342
|
+
Button,
|
|
343
|
+
{
|
|
344
|
+
"aria-label": previousScrollLabel,
|
|
345
|
+
className: "fe-tabs__scroll-button",
|
|
346
|
+
disabled: !scrollState.canScrollBackward,
|
|
347
|
+
hierarchy: "tertiary-gray",
|
|
348
|
+
icon: /* @__PURE__ */ jsx3(chevron_left, { size: 18 }),
|
|
349
|
+
iconOnly: true,
|
|
350
|
+
onClick: () => scrollTabs(-1),
|
|
351
|
+
size: "32"
|
|
352
|
+
}
|
|
353
|
+
),
|
|
354
|
+
/* @__PURE__ */ jsx3("div", { className: "fe-tabs__scroller", ref: listRef, children: /* @__PURE__ */ jsx3(
|
|
355
|
+
"div",
|
|
356
|
+
{
|
|
357
|
+
"aria-label": ariaLabelledBy ? void 0 : ariaLabel,
|
|
358
|
+
"aria-labelledby": ariaLabelledBy,
|
|
359
|
+
"aria-orientation": "horizontal",
|
|
360
|
+
className: "fe-tabs__list",
|
|
361
|
+
role: "tablist",
|
|
362
|
+
children: items.map((item, index) => {
|
|
363
|
+
const selected = item.id === activeTab?.id;
|
|
364
|
+
const panelId = `${generatedId}-panel-${index}`;
|
|
365
|
+
return /* @__PURE__ */ jsx3(
|
|
366
|
+
"button",
|
|
367
|
+
{
|
|
368
|
+
"aria-controls": hasPanel(item) ? panelId : void 0,
|
|
369
|
+
"aria-selected": selected,
|
|
370
|
+
className: "fe-tabs__tab",
|
|
371
|
+
disabled: item.disabled,
|
|
372
|
+
id: `${generatedId}-tab-${index}`,
|
|
373
|
+
onClick: (event) => selectTab(item, event),
|
|
374
|
+
onKeyDown: (event) => selectFromKeyboard(item, event),
|
|
375
|
+
ref: (node) => {
|
|
376
|
+
if (node) tabRefs.current.set(item.id, node);
|
|
377
|
+
else tabRefs.current.delete(item.id);
|
|
378
|
+
},
|
|
379
|
+
role: "tab",
|
|
380
|
+
tabIndex: selected ? 0 : -1,
|
|
381
|
+
type: "button",
|
|
382
|
+
children: item.label
|
|
383
|
+
},
|
|
384
|
+
item.id
|
|
385
|
+
);
|
|
386
|
+
})
|
|
387
|
+
}
|
|
388
|
+
) }),
|
|
389
|
+
showScrollButtons && /* @__PURE__ */ jsx3(
|
|
390
|
+
Button,
|
|
391
|
+
{
|
|
392
|
+
"aria-label": nextScrollLabel,
|
|
393
|
+
className: "fe-tabs__scroll-button",
|
|
394
|
+
disabled: !scrollState.canScrollForward,
|
|
395
|
+
hierarchy: "tertiary-gray",
|
|
396
|
+
icon: /* @__PURE__ */ jsx3(chevron_right, { size: 18 }),
|
|
397
|
+
iconOnly: true,
|
|
398
|
+
onClick: () => scrollTabs(1),
|
|
399
|
+
size: "32"
|
|
400
|
+
}
|
|
401
|
+
)
|
|
402
|
+
] }),
|
|
403
|
+
items.map(
|
|
404
|
+
(item, index) => hasPanel(item) ? /* @__PURE__ */ jsx3(
|
|
405
|
+
"div",
|
|
406
|
+
{
|
|
407
|
+
"aria-labelledby": `${generatedId}-tab-${index}`,
|
|
408
|
+
className: "fe-tabs__panel",
|
|
409
|
+
hidden: item.id !== activeTab?.id,
|
|
410
|
+
id: `${generatedId}-panel-${index}`,
|
|
411
|
+
role: "tabpanel",
|
|
412
|
+
tabIndex: 0,
|
|
413
|
+
children: item.content
|
|
414
|
+
},
|
|
415
|
+
item.id
|
|
416
|
+
) : null
|
|
417
|
+
)
|
|
418
|
+
] });
|
|
419
|
+
});
|
|
420
|
+
Tabs.displayName = "Tabs";
|
|
421
|
+
|
|
92
422
|
// packages/table/src/index.tsx
|
|
93
423
|
import {
|
|
94
424
|
createContext,
|
|
95
425
|
isValidElement,
|
|
96
|
-
useCallback,
|
|
426
|
+
useCallback as useCallback2,
|
|
97
427
|
useContext,
|
|
98
|
-
useEffect,
|
|
428
|
+
useEffect as useEffect3,
|
|
99
429
|
useMemo as useMemo2,
|
|
100
|
-
useRef,
|
|
101
|
-
useState as
|
|
430
|
+
useRef as useRef3,
|
|
431
|
+
useState as useState4
|
|
102
432
|
} from "react";
|
|
103
433
|
|
|
104
434
|
// packages/pagination/src/index.tsx
|
|
105
|
-
import { useMemo, useState } from "react";
|
|
106
|
-
import { jsx as
|
|
435
|
+
import { useMemo, useState as useState3 } from "react";
|
|
436
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
107
437
|
var clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
108
438
|
var range = (start, end) => Array.from({ length: Math.max(0, end - start + 1) }, (_, index) => start + index);
|
|
109
439
|
function getItems(totalPages, page, siblingCount, boundaryCount) {
|
|
@@ -135,7 +465,7 @@ function Pagination({
|
|
|
135
465
|
...props
|
|
136
466
|
}) {
|
|
137
467
|
const safeTotalPages = Math.max(1, Math.floor(totalPages));
|
|
138
|
-
const [uncontrolledPage, setUncontrolledPage] =
|
|
468
|
+
const [uncontrolledPage, setUncontrolledPage] = useState3(() => clamp(defaultPage, 1, safeTotalPages));
|
|
139
469
|
const currentPage = clamp(page ?? uncontrolledPage, 1, safeTotalPages);
|
|
140
470
|
const items = useMemo(
|
|
141
471
|
() => getItems(safeTotalPages, currentPage, Math.max(0, siblingCount), Math.max(0, boundaryCount)),
|
|
@@ -146,9 +476,9 @@ function Pagination({
|
|
|
146
476
|
if (page === void 0) setUncontrolledPage(resolvedPage);
|
|
147
477
|
if (resolvedPage !== currentPage) onPageChange?.(resolvedPage);
|
|
148
478
|
};
|
|
149
|
-
return /* @__PURE__ */
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
items.map((item, index) => item === "start-ellipsis" || item === "end-ellipsis" ? /* @__PURE__ */
|
|
479
|
+
return /* @__PURE__ */ jsxs4("nav", { className: ["fe-pagination", className].filter(Boolean).join(" "), "aria-label": "Pagination", ...props, children: [
|
|
480
|
+
/* @__PURE__ */ jsx4(Button, { className: "fe-pagination__button fe-pagination__button--control", hierarchy: "secondary-gray", size: "40", iconOnly: true, icon: "\u2039", "aria-label": previousLabel, disabled: disabled || currentPage === 1, onClick: () => selectPage(currentPage - 1) }),
|
|
481
|
+
items.map((item, index) => item === "start-ellipsis" || item === "end-ellipsis" ? /* @__PURE__ */ jsx4("span", { className: "fe-pagination__ellipsis", "aria-hidden": "true", children: "\u2026" }, `${item}-${index}`) : /* @__PURE__ */ jsx4(
|
|
152
482
|
Button,
|
|
153
483
|
{
|
|
154
484
|
className: "fe-pagination__button",
|
|
@@ -162,12 +492,12 @@ function Pagination({
|
|
|
162
492
|
},
|
|
163
493
|
item
|
|
164
494
|
)),
|
|
165
|
-
/* @__PURE__ */
|
|
495
|
+
/* @__PURE__ */ jsx4(Button, { className: "fe-pagination__button fe-pagination__button--control", hierarchy: "secondary-gray", size: "40", iconOnly: true, icon: "\u203A", "aria-label": nextLabel, disabled: disabled || currentPage === safeTotalPages, onClick: () => selectPage(currentPage + 1) })
|
|
166
496
|
] });
|
|
167
497
|
}
|
|
168
498
|
|
|
169
499
|
// packages/table/src/index.tsx
|
|
170
|
-
import { jsx as
|
|
500
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
171
501
|
var TableContext = createContext({ striped: false });
|
|
172
502
|
var MIN_COLUMN_WIDTH = 96;
|
|
173
503
|
var MAX_COLUMN_WIDTH = 1200;
|
|
@@ -217,33 +547,33 @@ function DataTable({
|
|
|
217
547
|
() => getInitialColumnSizes(headers, data, defaultColumnSizes, safeMinWidth),
|
|
218
548
|
[headers, data, defaultColumnSizes, safeMinWidth]
|
|
219
549
|
);
|
|
220
|
-
const [uncontrolledSizes, setUncontrolledSizes] =
|
|
550
|
+
const [uncontrolledSizes, setUncontrolledSizes] = useState4(generatedSizes);
|
|
221
551
|
const shouldPaginate = pagination ?? pageSize !== void 0;
|
|
222
552
|
const safePageSize = Math.max(1, Math.floor(pageSize ?? 10));
|
|
223
553
|
const totalPages = Math.max(1, Math.ceil(data.length / safePageSize));
|
|
224
|
-
const [uncontrolledPage, setUncontrolledPage] =
|
|
554
|
+
const [uncontrolledPage, setUncontrolledPage] = useState4(() => Math.min(Math.max(1, defaultPage), totalPages));
|
|
225
555
|
const currentPage = Math.min(Math.max(1, page ?? uncontrolledPage), totalPages);
|
|
226
556
|
const pagedData = shouldPaginate ? data.slice((currentPage - 1) * safePageSize, currentPage * safePageSize) : data;
|
|
227
|
-
const resizeState =
|
|
228
|
-
const [isResizing, setIsResizing] =
|
|
557
|
+
const resizeState = useRef3();
|
|
558
|
+
const [isResizing, setIsResizing] = useState4(false);
|
|
229
559
|
const sizes2 = columnSizes ? getInitialColumnSizes(headers, data, columnSizes, safeMinWidth).map((size) => Math.max(safeMinWidth, size)) : uncontrolledSizes.map((size) => Math.max(safeMinWidth, size));
|
|
230
|
-
|
|
560
|
+
useEffect3(() => {
|
|
231
561
|
if (columnSizes) return;
|
|
232
562
|
setUncontrolledSizes((currentSizes) => {
|
|
233
563
|
const nextSizes = generatedSizes.map((generatedSize, index) => currentSizes[index] ?? generatedSize);
|
|
234
564
|
return sameSizes(currentSizes, nextSizes) ? currentSizes : nextSizes;
|
|
235
565
|
});
|
|
236
566
|
}, [columnSizes, generatedSizes]);
|
|
237
|
-
|
|
567
|
+
useEffect3(() => {
|
|
238
568
|
if (page === void 0 && uncontrolledPage > totalPages) setUncontrolledPage(totalPages);
|
|
239
569
|
}, [page, totalPages, uncontrolledPage]);
|
|
240
|
-
const updateColumnSize =
|
|
570
|
+
const updateColumnSize = useCallback2((columnIndex, nextSize) => {
|
|
241
571
|
const clampedSize = Math.min(MAX_COLUMN_WIDTH, Math.max(safeMinWidth, Math.round(nextSize)));
|
|
242
572
|
const nextSizes = sizes2.map((size, index) => index === columnIndex ? clampedSize : size);
|
|
243
573
|
if (!columnSizes) setUncontrolledSizes(nextSizes);
|
|
244
574
|
onColumnResize?.(nextSizes, columnIndex);
|
|
245
575
|
}, [columnSizes, onColumnResize, safeMinWidth, sizes2]);
|
|
246
|
-
|
|
576
|
+
useEffect3(() => {
|
|
247
577
|
const onPointerMove = (event) => {
|
|
248
578
|
const activeResize = resizeState.current;
|
|
249
579
|
if (!activeResize) return;
|
|
@@ -267,14 +597,14 @@ function DataTable({
|
|
|
267
597
|
if (nextPage !== currentPage) onPageChange?.(nextPage);
|
|
268
598
|
};
|
|
269
599
|
const resolvedPaginationPosition = paginationPosition === "middle-bottom" ? "bottom-center" : paginationPosition;
|
|
270
|
-
const paginationControl = shouldPaginate && totalPages > 1 ? /* @__PURE__ */
|
|
271
|
-
return /* @__PURE__ */
|
|
600
|
+
const paginationControl = shouldPaginate && totalPages > 1 ? /* @__PURE__ */ jsx5("div", { className: `fe-table__pagination fe-table__pagination--${resolvedPaginationPosition}`, children: /* @__PURE__ */ jsx5(Pagination, { page: currentPage, totalPages, onPageChange: changePage }) }) : null;
|
|
601
|
+
return /* @__PURE__ */ jsxs5("div", { className: "fe-table", "data-resizing": isResizing || void 0, children: [
|
|
272
602
|
resolvedPaginationPosition === "top-right" && paginationControl,
|
|
273
|
-
/* @__PURE__ */
|
|
274
|
-
/* @__PURE__ */
|
|
275
|
-
/* @__PURE__ */
|
|
276
|
-
/* @__PURE__ */
|
|
277
|
-
/* @__PURE__ */
|
|
603
|
+
/* @__PURE__ */ jsxs5("table", { className: ["fe-table__table", className].filter(Boolean).join(" "), "data-fe-table": true, "data-striped": striped || void 0, ...props, children: [
|
|
604
|
+
/* @__PURE__ */ jsx5("colgroup", { children: sizes2.map((size, index) => /* @__PURE__ */ jsx5("col", { style: { width: `${size}px` } }, index)) }),
|
|
605
|
+
/* @__PURE__ */ jsx5("thead", { children: /* @__PURE__ */ jsx5("tr", { children: Array.from({ length: columnCount }, (_, columnIndex) => /* @__PURE__ */ jsxs5("th", { scope: "col", children: [
|
|
606
|
+
/* @__PURE__ */ jsx5("span", { className: "fe-table__header-content", children: headers[columnIndex] ?? `Column ${columnIndex + 1}` }),
|
|
607
|
+
/* @__PURE__ */ jsx5(
|
|
278
608
|
"span",
|
|
279
609
|
{
|
|
280
610
|
className: "fe-table__resize-handle",
|
|
@@ -298,7 +628,7 @@ function DataTable({
|
|
|
298
628
|
}
|
|
299
629
|
)
|
|
300
630
|
] }, columnIndex)) }) }),
|
|
301
|
-
/* @__PURE__ */
|
|
631
|
+
/* @__PURE__ */ jsx5("tbody", { children: pagedData.map((row, rowIndex) => /* @__PURE__ */ jsx5("tr", { children: Array.from({ length: columnCount }, (_, columnIndex) => /* @__PURE__ */ jsx5("td", { children: row[columnIndex] }, columnIndex)) }, shouldPaginate ? (currentPage - 1) * safePageSize + rowIndex : rowIndex)) })
|
|
302
632
|
] }),
|
|
303
633
|
resolvedPaginationPosition !== "top-right" && paginationControl
|
|
304
634
|
] });
|
|
@@ -316,35 +646,35 @@ function Table({
|
|
|
316
646
|
paginationPosition,
|
|
317
647
|
...props
|
|
318
648
|
}) {
|
|
319
|
-
if (headers || data) return /* @__PURE__ */
|
|
320
|
-
return /* @__PURE__ */
|
|
649
|
+
if (headers || data) return /* @__PURE__ */ jsx5(DataTable, { headers: headers ?? [], data: data ?? [], striped: striped ?? true, pagination, pageSize, page, defaultPage, onPageChange, paginationPosition, ...props });
|
|
650
|
+
return /* @__PURE__ */ jsx5(TableContext.Provider, { value: { striped: striped ?? false }, children: /* @__PURE__ */ jsx5("table", { "data-fe-table": true, "data-striped": striped || void 0, ...props, children }) });
|
|
321
651
|
}
|
|
322
652
|
function TableHead(props) {
|
|
323
|
-
return /* @__PURE__ */
|
|
653
|
+
return /* @__PURE__ */ jsx5("thead", { ...props });
|
|
324
654
|
}
|
|
325
655
|
function TableBody(props) {
|
|
326
|
-
return /* @__PURE__ */
|
|
656
|
+
return /* @__PURE__ */ jsx5("tbody", { ...props });
|
|
327
657
|
}
|
|
328
658
|
function TableRow({ children, ...props }) {
|
|
329
659
|
const { striped } = useContext(TableContext);
|
|
330
|
-
return /* @__PURE__ */
|
|
660
|
+
return /* @__PURE__ */ jsx5("tr", { "data-striped": striped || void 0, ...props, children });
|
|
331
661
|
}
|
|
332
662
|
function TableCell({ children, ...props }) {
|
|
333
|
-
return /* @__PURE__ */
|
|
663
|
+
return /* @__PURE__ */ jsx5("td", { ...props, children });
|
|
334
664
|
}
|
|
335
665
|
function TableHeader({ children, ...props }) {
|
|
336
|
-
return /* @__PURE__ */
|
|
666
|
+
return /* @__PURE__ */ jsx5("th", { scope: "col", ...props, children });
|
|
337
667
|
}
|
|
338
668
|
function TableCaption(props) {
|
|
339
|
-
return /* @__PURE__ */
|
|
669
|
+
return /* @__PURE__ */ jsx5("caption", { ...props });
|
|
340
670
|
}
|
|
341
671
|
|
|
342
672
|
// packages/toggle/src/index.tsx
|
|
343
673
|
import {
|
|
344
|
-
forwardRef as
|
|
674
|
+
forwardRef as forwardRef3
|
|
345
675
|
} from "react";
|
|
346
|
-
import { jsx as
|
|
347
|
-
var Toggle =
|
|
676
|
+
import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
677
|
+
var Toggle = forwardRef3(function Toggle2({
|
|
348
678
|
color = "#16a34a",
|
|
349
679
|
label,
|
|
350
680
|
labelPosition = "right",
|
|
@@ -358,9 +688,9 @@ var Toggle = forwardRef2(function Toggle2({
|
|
|
358
688
|
"--fe-toggle-color": color,
|
|
359
689
|
...style
|
|
360
690
|
};
|
|
361
|
-
return /* @__PURE__ */
|
|
362
|
-
label && labelPosition === "top" && /* @__PURE__ */
|
|
363
|
-
/* @__PURE__ */
|
|
691
|
+
return /* @__PURE__ */ jsxs6("label", { className: classes, style: toggleStyle, children: [
|
|
692
|
+
label && labelPosition === "top" && /* @__PURE__ */ jsx6("span", { className: "fe-toggle__label", children: label }),
|
|
693
|
+
/* @__PURE__ */ jsx6(
|
|
364
694
|
"input",
|
|
365
695
|
{
|
|
366
696
|
ref,
|
|
@@ -371,18 +701,18 @@ var Toggle = forwardRef2(function Toggle2({
|
|
|
371
701
|
...props
|
|
372
702
|
}
|
|
373
703
|
),
|
|
374
|
-
/* @__PURE__ */
|
|
375
|
-
label && labelPosition === "right" && /* @__PURE__ */
|
|
704
|
+
/* @__PURE__ */ jsx6("span", { className: "fe-toggle__control", "aria-hidden": "true" }),
|
|
705
|
+
label && labelPosition === "right" && /* @__PURE__ */ jsx6("span", { className: "fe-toggle__label", children: label })
|
|
376
706
|
] });
|
|
377
707
|
});
|
|
378
708
|
Toggle.displayName = "Toggle";
|
|
379
709
|
|
|
380
710
|
// packages/drawer/src/index.tsx
|
|
381
|
-
import { useEffect as
|
|
711
|
+
import { useEffect as useEffect4 } from "react";
|
|
382
712
|
import { createPortal } from "react-dom";
|
|
383
|
-
import { jsx as
|
|
713
|
+
import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
384
714
|
function Drawer({ open, onClose, title, footer, side = "right", width = 400, fullScreen = false, children, closeOnBackdropClick = true, className, style, ...props }) {
|
|
385
|
-
|
|
715
|
+
useEffect4(() => {
|
|
386
716
|
if (!open) return;
|
|
387
717
|
const onKeyDown = (event) => {
|
|
388
718
|
if (event.key === "Escape") onClose();
|
|
@@ -392,27 +722,27 @@ function Drawer({ open, onClose, title, footer, side = "right", width = 400, ful
|
|
|
392
722
|
}, [onClose, open]);
|
|
393
723
|
if (!open || typeof document === "undefined") return null;
|
|
394
724
|
const panelStyle = !fullScreen && (side === "left" || side === "right") ? { ...style, width: typeof width === "number" ? `${width}px` : width } : style;
|
|
395
|
-
return createPortal(/* @__PURE__ */
|
|
725
|
+
return createPortal(/* @__PURE__ */ jsx7("div", { className: "fe-drawer-backdrop", role: "presentation", onMouseDown: (event) => {
|
|
396
726
|
if (event.target === event.currentTarget && closeOnBackdropClick) onClose();
|
|
397
|
-
}, children: /* @__PURE__ */
|
|
398
|
-
/* @__PURE__ */
|
|
399
|
-
title && /* @__PURE__ */
|
|
400
|
-
/* @__PURE__ */
|
|
727
|
+
}, children: /* @__PURE__ */ jsxs7("aside", { className: ["fe-drawer", `fe-drawer--${side}`, fullScreen && "fe-drawer--full-screen", className].filter(Boolean).join(" "), style: panelStyle, role: "dialog", "aria-modal": "true", "aria-label": typeof title === "string" ? title : "Drawer", ...props, children: [
|
|
728
|
+
/* @__PURE__ */ jsxs7("header", { className: "fe-drawer__header", children: [
|
|
729
|
+
title && /* @__PURE__ */ jsx7("h2", { children: title }),
|
|
730
|
+
/* @__PURE__ */ jsx7("button", { type: "button", "aria-label": "Close drawer", onClick: onClose, children: "\xD7" })
|
|
401
731
|
] }),
|
|
402
|
-
/* @__PURE__ */
|
|
403
|
-
footer && /* @__PURE__ */
|
|
732
|
+
/* @__PURE__ */ jsx7("div", { className: "fe-drawer__body", children }),
|
|
733
|
+
footer && /* @__PURE__ */ jsx7("footer", { className: "fe-drawer__footer", children: footer })
|
|
404
734
|
] }) }), document.body);
|
|
405
735
|
}
|
|
406
736
|
|
|
407
737
|
// packages/form-controls/src/controls/TextInput/text-input.tsx
|
|
408
|
-
import { forwardRef as
|
|
738
|
+
import { forwardRef as forwardRef4, useId as useId4, useState as useState6 } from "react";
|
|
409
739
|
|
|
410
740
|
// packages/tooltip/src/index.tsx
|
|
411
|
-
import { cloneElement, useId, useState as
|
|
412
|
-
import { jsx as
|
|
741
|
+
import { cloneElement, useId as useId3, useState as useState5 } from "react";
|
|
742
|
+
import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
413
743
|
function Tooltip({ content, children, placement = "top", disabled, className, ...props }) {
|
|
414
|
-
const [visible, setVisible] =
|
|
415
|
-
const id =
|
|
744
|
+
const [visible, setVisible] = useState5(false);
|
|
745
|
+
const id = useId3();
|
|
416
746
|
const trigger = cloneElement(children, { "aria-describedby": visible ? id : void 0, onMouseEnter: (event) => {
|
|
417
747
|
children.props.onMouseEnter?.(event);
|
|
418
748
|
setVisible(true);
|
|
@@ -426,14 +756,14 @@ function Tooltip({ content, children, placement = "top", disabled, className, ..
|
|
|
426
756
|
children.props.onBlur?.(event);
|
|
427
757
|
setVisible(false);
|
|
428
758
|
} });
|
|
429
|
-
return /* @__PURE__ */
|
|
759
|
+
return /* @__PURE__ */ jsxs8("span", { className: ["fe-tooltip", `fe-tooltip--${placement}`, className].filter(Boolean).join(" "), ...props, children: [
|
|
430
760
|
trigger,
|
|
431
|
-
visible && !disabled && /* @__PURE__ */
|
|
761
|
+
visible && !disabled && /* @__PURE__ */ jsx8("span", { id, role: "tooltip", className: "fe-tooltip__content", children: content })
|
|
432
762
|
] });
|
|
433
763
|
}
|
|
434
764
|
|
|
435
765
|
// packages/form-controls/src/controls/Field/field.tsx
|
|
436
|
-
import { jsx as
|
|
766
|
+
import { jsx as jsx9, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
437
767
|
function getFieldError(error, errorMessage) {
|
|
438
768
|
if (errorMessage !== void 0 && errorMessage !== null) return errorMessage;
|
|
439
769
|
if (typeof error !== "boolean") return error;
|
|
@@ -450,10 +780,10 @@ function FieldLabel({
|
|
|
450
780
|
isRequired = false
|
|
451
781
|
}) {
|
|
452
782
|
if (!label) return null;
|
|
453
|
-
return /* @__PURE__ */
|
|
454
|
-
/* @__PURE__ */
|
|
455
|
-
isRequired && /* @__PURE__ */
|
|
456
|
-
description && descriptionDisplay === "tooltip" && /* @__PURE__ */
|
|
783
|
+
return /* @__PURE__ */ jsxs9("span", { className: "fe-field__label", children: [
|
|
784
|
+
/* @__PURE__ */ jsx9("span", { id, children: label }),
|
|
785
|
+
isRequired && /* @__PURE__ */ jsx9("span", { className: "fe-field__required", "aria-hidden": "true", children: "*" }),
|
|
786
|
+
description && descriptionDisplay === "tooltip" && /* @__PURE__ */ jsx9(Tooltip, { content: description, children: /* @__PURE__ */ jsx9(
|
|
457
787
|
"span",
|
|
458
788
|
{
|
|
459
789
|
className: "fe-field__info",
|
|
@@ -472,7 +802,7 @@ function FieldMessage({
|
|
|
472
802
|
descriptionDisplay
|
|
473
803
|
}) {
|
|
474
804
|
if (error !== void 0 && error !== false && error !== null)
|
|
475
|
-
return /* @__PURE__ */
|
|
805
|
+
return /* @__PURE__ */ jsx9(
|
|
476
806
|
"span",
|
|
477
807
|
{
|
|
478
808
|
id,
|
|
@@ -482,13 +812,13 @@ function FieldMessage({
|
|
|
482
812
|
}
|
|
483
813
|
);
|
|
484
814
|
if (description && descriptionDisplay === "inline")
|
|
485
|
-
return /* @__PURE__ */
|
|
815
|
+
return /* @__PURE__ */ jsx9("span", { id, className: "fe-field__message", children: description });
|
|
486
816
|
return null;
|
|
487
817
|
}
|
|
488
818
|
|
|
489
819
|
// packages/form-controls/src/controls/TextInput/text-input.tsx
|
|
490
|
-
import { jsx as
|
|
491
|
-
var TextInput =
|
|
820
|
+
import { jsx as jsx10, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
821
|
+
var TextInput = forwardRef4(
|
|
492
822
|
function TextInput2({
|
|
493
823
|
value,
|
|
494
824
|
defaultValue = "",
|
|
@@ -518,12 +848,12 @@ var TextInput = forwardRef3(
|
|
|
518
848
|
"aria-labelledby": ariaLabelledBy,
|
|
519
849
|
...props
|
|
520
850
|
}, ref) {
|
|
521
|
-
const generatedId =
|
|
851
|
+
const generatedId = useId4();
|
|
522
852
|
const inputId = id ?? generatedId + "-input";
|
|
523
853
|
const labelId = generatedId + "-label";
|
|
524
854
|
const messageId2 = generatedId + "-message";
|
|
525
855
|
const controlled = value !== void 0;
|
|
526
|
-
const [internalValue, setInternalValue] =
|
|
856
|
+
const [internalValue, setInternalValue] = useState6(defaultValue);
|
|
527
857
|
const currentValue = controlled ? value : internalValue;
|
|
528
858
|
const fieldError = getFieldError(error, errorMessage);
|
|
529
859
|
const hasError = fieldError !== void 0 && fieldError !== false && fieldError !== null;
|
|
@@ -544,7 +874,7 @@ var TextInput = forwardRef3(
|
|
|
544
874
|
onValueChange?.("");
|
|
545
875
|
onClear?.();
|
|
546
876
|
};
|
|
547
|
-
return /* @__PURE__ */
|
|
877
|
+
return /* @__PURE__ */ jsxs10(
|
|
548
878
|
"div",
|
|
549
879
|
{
|
|
550
880
|
className: [
|
|
@@ -553,7 +883,7 @@ var TextInput = forwardRef3(
|
|
|
553
883
|
className
|
|
554
884
|
].filter(Boolean).join(" "),
|
|
555
885
|
children: [
|
|
556
|
-
/* @__PURE__ */
|
|
886
|
+
/* @__PURE__ */ jsx10(
|
|
557
887
|
FieldLabel,
|
|
558
888
|
{
|
|
559
889
|
id: labelId,
|
|
@@ -563,10 +893,10 @@ var TextInput = forwardRef3(
|
|
|
563
893
|
isRequired
|
|
564
894
|
}
|
|
565
895
|
),
|
|
566
|
-
/* @__PURE__ */
|
|
567
|
-
resolvedPrefix && /* @__PURE__ */
|
|
568
|
-
/* @__PURE__ */
|
|
569
|
-
/* @__PURE__ */
|
|
896
|
+
/* @__PURE__ */ jsxs10("span", { className: "fe-text-input__control", children: [
|
|
897
|
+
resolvedPrefix && /* @__PURE__ */ jsx10("span", { className: "fe-text-input__prefix", children: resolvedPrefix }),
|
|
898
|
+
/* @__PURE__ */ jsxs10("span", { className: "fe-text-input__input-wrap", children: [
|
|
899
|
+
/* @__PURE__ */ jsx10(
|
|
570
900
|
"input",
|
|
571
901
|
{
|
|
572
902
|
ref,
|
|
@@ -588,26 +918,26 @@ var TextInput = forwardRef3(
|
|
|
588
918
|
...props
|
|
589
919
|
}
|
|
590
920
|
),
|
|
591
|
-
isRequired && placeholder && !currentValue && /* @__PURE__ */
|
|
592
|
-
/* @__PURE__ */
|
|
593
|
-
/* @__PURE__ */
|
|
921
|
+
isRequired && placeholder && !currentValue && /* @__PURE__ */ jsxs10("span", { className: "fe-text-input__placeholder", "aria-hidden": "true", children: [
|
|
922
|
+
/* @__PURE__ */ jsx10("span", { children: placeholder }),
|
|
923
|
+
/* @__PURE__ */ jsx10("span", { className: "fe-field__required", children: "*" })
|
|
594
924
|
] })
|
|
595
925
|
] }),
|
|
596
|
-
resolvedSuffix && /* @__PURE__ */
|
|
597
|
-
clearable && currentValue && !disabled && !readOnly && /* @__PURE__ */
|
|
926
|
+
resolvedSuffix && /* @__PURE__ */ jsx10("span", { className: "fe-text-input__suffix", children: resolvedSuffix }),
|
|
927
|
+
clearable && currentValue && !disabled && !readOnly && /* @__PURE__ */ jsx10(
|
|
598
928
|
Button,
|
|
599
929
|
{
|
|
600
930
|
hierarchy: "tertiary-gray",
|
|
601
931
|
size: "24",
|
|
602
932
|
iconOnly: true,
|
|
603
|
-
icon: /* @__PURE__ */
|
|
933
|
+
icon: /* @__PURE__ */ jsx10(CloseIcon, { size: 14 }),
|
|
604
934
|
"aria-label": clearLabel,
|
|
605
935
|
onClick: clear,
|
|
606
936
|
className: "fe-text-input__clear"
|
|
607
937
|
}
|
|
608
938
|
)
|
|
609
939
|
] }),
|
|
610
|
-
/* @__PURE__ */
|
|
940
|
+
/* @__PURE__ */ jsx10(
|
|
611
941
|
FieldMessage,
|
|
612
942
|
{
|
|
613
943
|
id: messageId2,
|
|
@@ -625,15 +955,15 @@ TextInput.displayName = "TextInput";
|
|
|
625
955
|
|
|
626
956
|
// packages/form-controls/src/controls/TextArea/text-area.tsx
|
|
627
957
|
import {
|
|
628
|
-
forwardRef as
|
|
629
|
-
useId as
|
|
958
|
+
forwardRef as forwardRef5,
|
|
959
|
+
useId as useId5,
|
|
630
960
|
useImperativeHandle,
|
|
631
961
|
useLayoutEffect,
|
|
632
|
-
useRef as
|
|
633
|
-
useState as
|
|
962
|
+
useRef as useRef4,
|
|
963
|
+
useState as useState7
|
|
634
964
|
} from "react";
|
|
635
|
-
import { jsx as
|
|
636
|
-
var TextArea =
|
|
965
|
+
import { jsx as jsx11, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
966
|
+
var TextArea = forwardRef5(
|
|
637
967
|
function TextArea2({
|
|
638
968
|
value,
|
|
639
969
|
defaultValue = "",
|
|
@@ -660,13 +990,13 @@ var TextArea = forwardRef4(
|
|
|
660
990
|
"aria-labelledby": ariaLabelledBy,
|
|
661
991
|
...props
|
|
662
992
|
}, ref) {
|
|
663
|
-
const generatedId =
|
|
993
|
+
const generatedId = useId5();
|
|
664
994
|
const inputId = id ?? generatedId + "-input";
|
|
665
995
|
const labelId = generatedId + "-label";
|
|
666
996
|
const messageId2 = generatedId + "-message";
|
|
667
997
|
const controlled = value !== void 0;
|
|
668
|
-
const [internalValue, setInternalValue] =
|
|
669
|
-
const textareaRef =
|
|
998
|
+
const [internalValue, setInternalValue] = useState7(defaultValue);
|
|
999
|
+
const textareaRef = useRef4(null);
|
|
670
1000
|
const currentValue = controlled ? value : internalValue;
|
|
671
1001
|
const fieldError = getFieldError(error, errorMessage);
|
|
672
1002
|
const hasError = fieldError !== void 0 && fieldError !== false && fieldError !== null;
|
|
@@ -695,7 +1025,7 @@ var TextArea = forwardRef4(
|
|
|
695
1025
|
onValueChange?.("");
|
|
696
1026
|
onClear?.();
|
|
697
1027
|
};
|
|
698
|
-
return /* @__PURE__ */
|
|
1028
|
+
return /* @__PURE__ */ jsxs11(
|
|
699
1029
|
"div",
|
|
700
1030
|
{
|
|
701
1031
|
className: [
|
|
@@ -705,7 +1035,7 @@ var TextArea = forwardRef4(
|
|
|
705
1035
|
className
|
|
706
1036
|
].filter(Boolean).join(" "),
|
|
707
1037
|
children: [
|
|
708
|
-
/* @__PURE__ */
|
|
1038
|
+
/* @__PURE__ */ jsx11(
|
|
709
1039
|
FieldLabel,
|
|
710
1040
|
{
|
|
711
1041
|
id: labelId,
|
|
@@ -715,8 +1045,8 @@ var TextArea = forwardRef4(
|
|
|
715
1045
|
isRequired
|
|
716
1046
|
}
|
|
717
1047
|
),
|
|
718
|
-
/* @__PURE__ */
|
|
719
|
-
/* @__PURE__ */
|
|
1048
|
+
/* @__PURE__ */ jsxs11("span", { className: "fe-text-area__control", children: [
|
|
1049
|
+
/* @__PURE__ */ jsx11(
|
|
720
1050
|
"textarea",
|
|
721
1051
|
{
|
|
722
1052
|
ref: textareaRef,
|
|
@@ -739,24 +1069,24 @@ var TextArea = forwardRef4(
|
|
|
739
1069
|
...props
|
|
740
1070
|
}
|
|
741
1071
|
),
|
|
742
|
-
isRequired && placeholder && !currentValue && /* @__PURE__ */
|
|
743
|
-
/* @__PURE__ */
|
|
744
|
-
/* @__PURE__ */
|
|
1072
|
+
isRequired && placeholder && !currentValue && /* @__PURE__ */ jsxs11("span", { className: "fe-text-area__placeholder", "aria-hidden": "true", children: [
|
|
1073
|
+
/* @__PURE__ */ jsx11("span", { children: placeholder }),
|
|
1074
|
+
/* @__PURE__ */ jsx11("span", { className: "fe-field__required", children: "*" })
|
|
745
1075
|
] }),
|
|
746
|
-
clearable && currentValue && !disabled && !readOnly && /* @__PURE__ */
|
|
1076
|
+
clearable && currentValue && !disabled && !readOnly && /* @__PURE__ */ jsx11(
|
|
747
1077
|
Button,
|
|
748
1078
|
{
|
|
749
1079
|
hierarchy: "tertiary-gray",
|
|
750
1080
|
size: "24",
|
|
751
1081
|
iconOnly: true,
|
|
752
|
-
icon: /* @__PURE__ */
|
|
1082
|
+
icon: /* @__PURE__ */ jsx11(CloseIcon, { size: 14 }),
|
|
753
1083
|
"aria-label": clearLabel,
|
|
754
1084
|
onClick: clear,
|
|
755
1085
|
className: "fe-text-area__clear"
|
|
756
1086
|
}
|
|
757
1087
|
)
|
|
758
1088
|
] }),
|
|
759
|
-
/* @__PURE__ */
|
|
1089
|
+
/* @__PURE__ */ jsx11(
|
|
760
1090
|
FieldMessage,
|
|
761
1091
|
{
|
|
762
1092
|
id: messageId2,
|
|
@@ -774,16 +1104,16 @@ TextArea.displayName = "TextArea";
|
|
|
774
1104
|
|
|
775
1105
|
// packages/form-controls/src/controls/Selection/selection.tsx
|
|
776
1106
|
import {
|
|
777
|
-
forwardRef as
|
|
778
|
-
useEffect as
|
|
779
|
-
useId as
|
|
1107
|
+
forwardRef as forwardRef6,
|
|
1108
|
+
useEffect as useEffect5,
|
|
1109
|
+
useId as useId6,
|
|
780
1110
|
useLayoutEffect as useLayoutEffect2,
|
|
781
|
-
useRef as
|
|
782
|
-
useState as
|
|
1111
|
+
useRef as useRef5,
|
|
1112
|
+
useState as useState8
|
|
783
1113
|
} from "react";
|
|
784
1114
|
import { createPortal as createPortal2 } from "react-dom";
|
|
785
|
-
import { Fragment as Fragment2, jsx as
|
|
786
|
-
var Selection =
|
|
1115
|
+
import { Fragment as Fragment2, jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1116
|
+
var Selection = forwardRef6(
|
|
787
1117
|
function Selection2({
|
|
788
1118
|
className,
|
|
789
1119
|
label,
|
|
@@ -812,7 +1142,7 @@ var Selection = forwardRef5(
|
|
|
812
1142
|
"aria-labelledby": ariaLabelledBy,
|
|
813
1143
|
...props
|
|
814
1144
|
}, ref) {
|
|
815
|
-
const generatedId =
|
|
1145
|
+
const generatedId = useId6();
|
|
816
1146
|
const triggerId = id ?? generatedId + "-trigger";
|
|
817
1147
|
const listboxId = triggerId + "-listbox";
|
|
818
1148
|
const labelId = generatedId + "-label";
|
|
@@ -830,7 +1160,7 @@ var Selection = forwardRef5(
|
|
|
830
1160
|
label ? labelId : void 0
|
|
831
1161
|
);
|
|
832
1162
|
const isControlled = value !== void 0;
|
|
833
|
-
const [internalValue, setInternalValue] =
|
|
1163
|
+
const [internalValue, setInternalValue] = useState8(
|
|
834
1164
|
defaultValue ?? (multiple ? [] : "")
|
|
835
1165
|
);
|
|
836
1166
|
const selectedValue = isControlled ? value : internalValue;
|
|
@@ -838,13 +1168,13 @@ var Selection = forwardRef5(
|
|
|
838
1168
|
const selectedOptions = options.filter(
|
|
839
1169
|
(option) => selectedValues.some((item) => String(item) === String(option.value))
|
|
840
1170
|
);
|
|
841
|
-
const [open, setOpen] =
|
|
842
|
-
const [query, setQuery] =
|
|
843
|
-
const [activeIndex, setActiveIndex] =
|
|
844
|
-
const rootRef =
|
|
845
|
-
const menuRef =
|
|
846
|
-
const [menuPosition, setMenuPosition] =
|
|
847
|
-
|
|
1171
|
+
const [open, setOpen] = useState8(false);
|
|
1172
|
+
const [query, setQuery] = useState8("");
|
|
1173
|
+
const [activeIndex, setActiveIndex] = useState8(0);
|
|
1174
|
+
const rootRef = useRef5(null);
|
|
1175
|
+
const menuRef = useRef5(null);
|
|
1176
|
+
const [menuPosition, setMenuPosition] = useState8(null);
|
|
1177
|
+
useEffect5(() => {
|
|
848
1178
|
const close = (event) => {
|
|
849
1179
|
const target = event.target;
|
|
850
1180
|
if (!rootRef.current?.contains(target) && !menuRef.current?.contains(target))
|
|
@@ -930,7 +1260,7 @@ var Selection = forwardRef5(
|
|
|
930
1260
|
}
|
|
931
1261
|
if (event.key === "Escape") setOpen(false);
|
|
932
1262
|
};
|
|
933
|
-
return /* @__PURE__ */
|
|
1263
|
+
return /* @__PURE__ */ jsxs12(
|
|
934
1264
|
"div",
|
|
935
1265
|
{
|
|
936
1266
|
ref,
|
|
@@ -945,7 +1275,7 @@ var Selection = forwardRef5(
|
|
|
945
1275
|
].filter(Boolean).join(" "),
|
|
946
1276
|
...props,
|
|
947
1277
|
children: [
|
|
948
|
-
/* @__PURE__ */
|
|
1278
|
+
/* @__PURE__ */ jsx12(
|
|
949
1279
|
FieldLabel,
|
|
950
1280
|
{
|
|
951
1281
|
id: labelId,
|
|
@@ -955,8 +1285,8 @@ var Selection = forwardRef5(
|
|
|
955
1285
|
isRequired
|
|
956
1286
|
}
|
|
957
1287
|
),
|
|
958
|
-
/* @__PURE__ */
|
|
959
|
-
name && selectedValues.map((item) => /* @__PURE__ */
|
|
1288
|
+
/* @__PURE__ */ jsxs12("div", { ref: rootRef, className: "fe-selection__control", children: [
|
|
1289
|
+
name && selectedValues.map((item) => /* @__PURE__ */ jsx12(
|
|
960
1290
|
"input",
|
|
961
1291
|
{
|
|
962
1292
|
type: "hidden",
|
|
@@ -965,7 +1295,7 @@ var Selection = forwardRef5(
|
|
|
965
1295
|
},
|
|
966
1296
|
String(item)
|
|
967
1297
|
)),
|
|
968
|
-
/* @__PURE__ */
|
|
1298
|
+
/* @__PURE__ */ jsxs12(
|
|
969
1299
|
"button",
|
|
970
1300
|
{
|
|
971
1301
|
id: triggerId,
|
|
@@ -983,7 +1313,7 @@ var Selection = forwardRef5(
|
|
|
983
1313
|
onClick: () => setOpen((current) => !current),
|
|
984
1314
|
onKeyDown: onTriggerKeyDown,
|
|
985
1315
|
children: [
|
|
986
|
-
/* @__PURE__ */
|
|
1316
|
+
/* @__PURE__ */ jsx12(
|
|
987
1317
|
"span",
|
|
988
1318
|
{
|
|
989
1319
|
className: [
|
|
@@ -991,30 +1321,30 @@ var Selection = forwardRef5(
|
|
|
991
1321
|
!selectedOptions.length && "is-placeholder",
|
|
992
1322
|
tag && selectedOptions.length > 1 && "is-tags"
|
|
993
1323
|
].filter(Boolean).join(" "),
|
|
994
|
-
children: displayLabel ? tag && multiple ? selectedOptions.map((option) => /* @__PURE__ */
|
|
1324
|
+
children: displayLabel ? tag && multiple ? selectedOptions.map((option) => /* @__PURE__ */ jsxs12(
|
|
995
1325
|
"span",
|
|
996
1326
|
{
|
|
997
1327
|
className: "fe-selection__tag",
|
|
998
1328
|
children: [
|
|
999
1329
|
option.label,
|
|
1000
|
-
/* @__PURE__ */
|
|
1330
|
+
/* @__PURE__ */ jsx12("span", { "aria-hidden": "true", children: "\xD7" })
|
|
1001
1331
|
]
|
|
1002
1332
|
},
|
|
1003
1333
|
String(option.value)
|
|
1004
|
-
)) : displayLabel.map((item, index) => /* @__PURE__ */
|
|
1334
|
+
)) : displayLabel.map((item, index) => /* @__PURE__ */ jsxs12("span", { children: [
|
|
1005
1335
|
item,
|
|
1006
1336
|
index < displayLabel.length - 1 ? ", " : ""
|
|
1007
|
-
] }, index)) : /* @__PURE__ */
|
|
1008
|
-
/* @__PURE__ */
|
|
1009
|
-
isRequired && /* @__PURE__ */
|
|
1337
|
+
] }, index)) : /* @__PURE__ */ jsxs12(Fragment2, { children: [
|
|
1338
|
+
/* @__PURE__ */ jsx12("span", { children: placeholder }),
|
|
1339
|
+
isRequired && /* @__PURE__ */ jsx12("span", { className: "fe-field__required", "aria-hidden": "true", children: "*" })
|
|
1010
1340
|
] })
|
|
1011
1341
|
}
|
|
1012
1342
|
),
|
|
1013
|
-
/* @__PURE__ */
|
|
1343
|
+
/* @__PURE__ */ jsx12("span", { className: "fe-selection__actions", children: /* @__PURE__ */ jsx12("span", { className: "fe-selection__chevron", "aria-hidden": "true" }) })
|
|
1014
1344
|
]
|
|
1015
1345
|
}
|
|
1016
1346
|
),
|
|
1017
|
-
clearable && selectedOptions.length > 0 && !disabled && /* @__PURE__ */
|
|
1347
|
+
clearable && selectedOptions.length > 0 && !disabled && /* @__PURE__ */ jsx12(
|
|
1018
1348
|
"button",
|
|
1019
1349
|
{
|
|
1020
1350
|
type: "button",
|
|
@@ -1024,7 +1354,7 @@ var Selection = forwardRef5(
|
|
|
1024
1354
|
}
|
|
1025
1355
|
),
|
|
1026
1356
|
open && menuPosition && createPortal2(
|
|
1027
|
-
/* @__PURE__ */
|
|
1357
|
+
/* @__PURE__ */ jsxs12(
|
|
1028
1358
|
"div",
|
|
1029
1359
|
{
|
|
1030
1360
|
ref: menuRef,
|
|
@@ -1039,9 +1369,9 @@ var Selection = forwardRef5(
|
|
|
1039
1369
|
role: "listbox",
|
|
1040
1370
|
"aria-multiselectable": multiple || void 0,
|
|
1041
1371
|
children: [
|
|
1042
|
-
searchable && /* @__PURE__ */
|
|
1043
|
-
/* @__PURE__ */
|
|
1044
|
-
/* @__PURE__ */
|
|
1372
|
+
searchable && /* @__PURE__ */ jsxs12("div", { className: "fe-selection__search", children: [
|
|
1373
|
+
/* @__PURE__ */ jsx12("span", { "aria-hidden": "true", children: "\u2315" }),
|
|
1374
|
+
/* @__PURE__ */ jsx12(
|
|
1045
1375
|
"input",
|
|
1046
1376
|
{
|
|
1047
1377
|
autoFocus: true,
|
|
@@ -1055,11 +1385,11 @@ var Selection = forwardRef5(
|
|
|
1055
1385
|
}
|
|
1056
1386
|
)
|
|
1057
1387
|
] }),
|
|
1058
|
-
/* @__PURE__ */
|
|
1388
|
+
/* @__PURE__ */ jsx12("div", { className: "fe-selection__options", children: filteredOptions.length ? filteredOptions.map((option, index) => {
|
|
1059
1389
|
const isSelected = selectedValues.some(
|
|
1060
1390
|
(item) => String(item) === String(option.value)
|
|
1061
1391
|
);
|
|
1062
|
-
return /* @__PURE__ */
|
|
1392
|
+
return /* @__PURE__ */ jsxs12(
|
|
1063
1393
|
"button",
|
|
1064
1394
|
{
|
|
1065
1395
|
type: "button",
|
|
@@ -1073,8 +1403,8 @@ var Selection = forwardRef5(
|
|
|
1073
1403
|
onMouseMove: () => setActiveIndex(index),
|
|
1074
1404
|
onClick: () => choose(option),
|
|
1075
1405
|
children: [
|
|
1076
|
-
/* @__PURE__ */
|
|
1077
|
-
isSelected && /* @__PURE__ */
|
|
1406
|
+
/* @__PURE__ */ jsx12("span", { children: option.label }),
|
|
1407
|
+
isSelected && /* @__PURE__ */ jsx12(
|
|
1078
1408
|
"span",
|
|
1079
1409
|
{
|
|
1080
1410
|
className: "fe-selection__check",
|
|
@@ -1086,14 +1416,14 @@ var Selection = forwardRef5(
|
|
|
1086
1416
|
},
|
|
1087
1417
|
String(option.value)
|
|
1088
1418
|
);
|
|
1089
|
-
}) : /* @__PURE__ */
|
|
1419
|
+
}) : /* @__PURE__ */ jsx12("p", { className: "fe-selection__empty", children: "No matching options" }) })
|
|
1090
1420
|
]
|
|
1091
1421
|
}
|
|
1092
1422
|
),
|
|
1093
1423
|
document.body
|
|
1094
1424
|
)
|
|
1095
1425
|
] }),
|
|
1096
|
-
/* @__PURE__ */
|
|
1426
|
+
/* @__PURE__ */ jsx12(
|
|
1097
1427
|
FieldMessage,
|
|
1098
1428
|
{
|
|
1099
1429
|
id: messageId2,
|
|
@@ -1111,13 +1441,13 @@ Selection.displayName = "Selection";
|
|
|
1111
1441
|
|
|
1112
1442
|
// packages/form-controls/src/controls/NumberInput/number-input.tsx
|
|
1113
1443
|
import {
|
|
1114
|
-
forwardRef as
|
|
1115
|
-
useEffect as
|
|
1116
|
-
useId as
|
|
1117
|
-
useRef as
|
|
1118
|
-
useState as
|
|
1444
|
+
forwardRef as forwardRef7,
|
|
1445
|
+
useEffect as useEffect6,
|
|
1446
|
+
useId as useId7,
|
|
1447
|
+
useRef as useRef6,
|
|
1448
|
+
useState as useState9
|
|
1119
1449
|
} from "react";
|
|
1120
|
-
import { jsx as
|
|
1450
|
+
import { jsx as jsx13, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1121
1451
|
function formatNumber(value, decimals = 2, thousandSeparator = ",", decimalSeparator = ".") {
|
|
1122
1452
|
return new Intl.NumberFormat("en-US", {
|
|
1123
1453
|
minimumFractionDigits: 0,
|
|
@@ -1174,7 +1504,7 @@ function normalizeNumberInput(raw, options) {
|
|
|
1174
1504
|
value
|
|
1175
1505
|
};
|
|
1176
1506
|
}
|
|
1177
|
-
var NumberInput =
|
|
1507
|
+
var NumberInput = forwardRef7(
|
|
1178
1508
|
function NumberInput2({
|
|
1179
1509
|
value,
|
|
1180
1510
|
defaultValue = null,
|
|
@@ -1211,14 +1541,14 @@ var NumberInput = forwardRef6(
|
|
|
1211
1541
|
onKeyDown,
|
|
1212
1542
|
...props
|
|
1213
1543
|
}, ref) {
|
|
1214
|
-
const inputRef =
|
|
1215
|
-
const generatedId =
|
|
1544
|
+
const inputRef = useRef6(null);
|
|
1545
|
+
const generatedId = useId7();
|
|
1216
1546
|
const messageId2 = generatedId + "-message";
|
|
1217
1547
|
const isControlled = value !== void 0;
|
|
1218
|
-
const [internalValue, setInternalValue] =
|
|
1219
|
-
const [focused, setFocused] =
|
|
1548
|
+
const [internalValue, setInternalValue] = useState9(defaultValue);
|
|
1549
|
+
const [focused, setFocused] = useState9(false);
|
|
1220
1550
|
const actualValue = isControlled ? value ?? null : internalValue;
|
|
1221
|
-
const [text, setText] =
|
|
1551
|
+
const [text, setText] = useState9(
|
|
1222
1552
|
actualValue === null ? "" : formatNumber(
|
|
1223
1553
|
actualValue,
|
|
1224
1554
|
decimals,
|
|
@@ -1241,7 +1571,7 @@ var NumberInput = forwardRef6(
|
|
|
1241
1571
|
);
|
|
1242
1572
|
const resolvedPrefix = prefix ?? Prefix;
|
|
1243
1573
|
const resolvedSuffix = suffix ?? Suffix;
|
|
1244
|
-
|
|
1574
|
+
useEffect6(() => {
|
|
1245
1575
|
if (!focused)
|
|
1246
1576
|
setText(
|
|
1247
1577
|
actualValue === null ? "" : formatNumber(
|
|
@@ -1295,7 +1625,7 @@ var NumberInput = forwardRef6(
|
|
|
1295
1625
|
const stepIsUsable = Number.isFinite(step) && step > 0;
|
|
1296
1626
|
const disableIncrement = Boolean(props.disabled || props.readOnly) || !stepIsUsable || max !== void 0 && actualValue !== null && actualValue >= max;
|
|
1297
1627
|
const disableDecrement = Boolean(props.disabled || props.readOnly) || !stepIsUsable || min !== void 0 && actualValue !== null && actualValue <= min;
|
|
1298
|
-
return /* @__PURE__ */
|
|
1628
|
+
return /* @__PURE__ */ jsxs13(
|
|
1299
1629
|
"div",
|
|
1300
1630
|
{
|
|
1301
1631
|
className: [
|
|
@@ -1304,7 +1634,7 @@ var NumberInput = forwardRef6(
|
|
|
1304
1634
|
className
|
|
1305
1635
|
].filter(Boolean).join(" "),
|
|
1306
1636
|
children: [
|
|
1307
|
-
/* @__PURE__ */
|
|
1637
|
+
/* @__PURE__ */ jsx13(
|
|
1308
1638
|
FieldLabel,
|
|
1309
1639
|
{
|
|
1310
1640
|
id: labelId,
|
|
@@ -1314,10 +1644,10 @@ var NumberInput = forwardRef6(
|
|
|
1314
1644
|
isRequired
|
|
1315
1645
|
}
|
|
1316
1646
|
),
|
|
1317
|
-
/* @__PURE__ */
|
|
1318
|
-
resolvedPrefix && /* @__PURE__ */
|
|
1319
|
-
/* @__PURE__ */
|
|
1320
|
-
/* @__PURE__ */
|
|
1647
|
+
/* @__PURE__ */ jsxs13("span", { className: "fe-number-input__control", children: [
|
|
1648
|
+
resolvedPrefix && /* @__PURE__ */ jsx13("span", { className: "fe-number-input__prefix", children: resolvedPrefix }),
|
|
1649
|
+
/* @__PURE__ */ jsxs13("span", { className: "fe-number-input__input-wrap", children: [
|
|
1650
|
+
/* @__PURE__ */ jsx13(
|
|
1321
1651
|
"input",
|
|
1322
1652
|
{
|
|
1323
1653
|
ref: (node) => {
|
|
@@ -1353,41 +1683,41 @@ var NumberInput = forwardRef6(
|
|
|
1353
1683
|
"aria-describedby": describedBy
|
|
1354
1684
|
}
|
|
1355
1685
|
),
|
|
1356
|
-
isRequired && placeholder && !text && /* @__PURE__ */
|
|
1686
|
+
isRequired && placeholder && !text && /* @__PURE__ */ jsxs13(
|
|
1357
1687
|
"span",
|
|
1358
1688
|
{
|
|
1359
1689
|
className: "fe-number-input__placeholder",
|
|
1360
1690
|
"aria-hidden": "true",
|
|
1361
1691
|
children: [
|
|
1362
|
-
/* @__PURE__ */
|
|
1363
|
-
/* @__PURE__ */
|
|
1692
|
+
/* @__PURE__ */ jsx13("span", { children: placeholder }),
|
|
1693
|
+
/* @__PURE__ */ jsx13("span", { className: "fe-field__required", children: "*" })
|
|
1364
1694
|
]
|
|
1365
1695
|
}
|
|
1366
1696
|
)
|
|
1367
1697
|
] }),
|
|
1368
|
-
resolvedSuffix && /* @__PURE__ */
|
|
1698
|
+
resolvedSuffix && /* @__PURE__ */ jsx13("span", { className: "fe-number-input__suffix", children: resolvedSuffix }),
|
|
1369
1699
|
endAdornment,
|
|
1370
|
-
showStepper && /* @__PURE__ */
|
|
1371
|
-
/* @__PURE__ */
|
|
1700
|
+
showStepper && /* @__PURE__ */ jsxs13("span", { className: "fe-number-input__stepper", children: [
|
|
1701
|
+
/* @__PURE__ */ jsx13(
|
|
1372
1702
|
Button,
|
|
1373
1703
|
{
|
|
1374
1704
|
hierarchy: "tertiary-gray",
|
|
1375
1705
|
size: "24",
|
|
1376
1706
|
iconOnly: true,
|
|
1377
|
-
icon: /* @__PURE__ */
|
|
1707
|
+
icon: /* @__PURE__ */ jsx13(ChevronUpIcon, { size: 12 }),
|
|
1378
1708
|
"aria-label": incrementLabel,
|
|
1379
1709
|
disabled: disableIncrement,
|
|
1380
1710
|
onMouseDown: (event) => event.preventDefault(),
|
|
1381
1711
|
onClick: () => adjustValue(1)
|
|
1382
1712
|
}
|
|
1383
1713
|
),
|
|
1384
|
-
/* @__PURE__ */
|
|
1714
|
+
/* @__PURE__ */ jsx13(
|
|
1385
1715
|
Button,
|
|
1386
1716
|
{
|
|
1387
1717
|
hierarchy: "tertiary-gray",
|
|
1388
1718
|
size: "24",
|
|
1389
1719
|
iconOnly: true,
|
|
1390
|
-
icon: /* @__PURE__ */
|
|
1720
|
+
icon: /* @__PURE__ */ jsx13(ChevronDownIcon, { size: 12 }),
|
|
1391
1721
|
"aria-label": decrementLabel,
|
|
1392
1722
|
disabled: disableDecrement,
|
|
1393
1723
|
onMouseDown: (event) => event.preventDefault(),
|
|
@@ -1396,7 +1726,7 @@ var NumberInput = forwardRef6(
|
|
|
1396
1726
|
)
|
|
1397
1727
|
] })
|
|
1398
1728
|
] }),
|
|
1399
|
-
/* @__PURE__ */
|
|
1729
|
+
/* @__PURE__ */ jsx13(
|
|
1400
1730
|
FieldMessage,
|
|
1401
1731
|
{
|
|
1402
1732
|
id: messageId2,
|
|
@@ -1413,8 +1743,8 @@ var NumberInput = forwardRef6(
|
|
|
1413
1743
|
NumberInput.displayName = "NumberInput";
|
|
1414
1744
|
|
|
1415
1745
|
// packages/form-controls/src/controls/CurrencyInput/currency-input.tsx
|
|
1416
|
-
import { useState as
|
|
1417
|
-
import { jsx as
|
|
1746
|
+
import { useState as useState10 } from "react";
|
|
1747
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1418
1748
|
function CurrencyInput({
|
|
1419
1749
|
suffix = "VND",
|
|
1420
1750
|
currencies,
|
|
@@ -1425,13 +1755,13 @@ function CurrencyInput({
|
|
|
1425
1755
|
disabled,
|
|
1426
1756
|
...props
|
|
1427
1757
|
}) {
|
|
1428
|
-
const [internalCurrency, setInternalCurrency] =
|
|
1758
|
+
const [internalCurrency, setInternalCurrency] = useState10(
|
|
1429
1759
|
defaultCurrency ?? currencies?.[0]?.code ?? ""
|
|
1430
1760
|
);
|
|
1431
1761
|
const selectedCurrency = currency ?? internalCurrency;
|
|
1432
1762
|
const current = currencies?.find((item) => item.code === selectedCurrency);
|
|
1433
1763
|
const currencySuffix = current?.suffix ?? current?.code ?? suffix;
|
|
1434
|
-
const endAdornment = currencies?.length ? /* @__PURE__ */
|
|
1764
|
+
const endAdornment = currencies?.length ? /* @__PURE__ */ jsx14(
|
|
1435
1765
|
Selection,
|
|
1436
1766
|
{
|
|
1437
1767
|
className: "fe-currency-input__currency",
|
|
@@ -1450,8 +1780,8 @@ function CurrencyInput({
|
|
|
1450
1780
|
onCurrencyChange?.(next);
|
|
1451
1781
|
}
|
|
1452
1782
|
}
|
|
1453
|
-
) : /* @__PURE__ */
|
|
1454
|
-
return /* @__PURE__ */
|
|
1783
|
+
) : /* @__PURE__ */ jsx14("span", { className: "fe-currency-input__suffix", children: currencySuffix });
|
|
1784
|
+
return /* @__PURE__ */ jsx14(
|
|
1455
1785
|
NumberInput,
|
|
1456
1786
|
{
|
|
1457
1787
|
...props,
|
|
@@ -1463,8 +1793,8 @@ function CurrencyInput({
|
|
|
1463
1793
|
}
|
|
1464
1794
|
|
|
1465
1795
|
// packages/form-controls/src/controls/DateTimePicker/date-time-picker.tsx
|
|
1466
|
-
import { useEffect as
|
|
1467
|
-
import { jsx as
|
|
1796
|
+
import { useEffect as useEffect7, useId as useId8, useRef as useRef7, useState as useState11 } from "react";
|
|
1797
|
+
import { jsx as jsx15, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
1468
1798
|
var pad = (value) => String(value).padStart(2, "0");
|
|
1469
1799
|
function formatDate(date, format) {
|
|
1470
1800
|
return format.replace(/yyyy/g, String(date.getFullYear())).replace(/MM/g, pad(date.getMonth() + 1)).replace(/dd/g, pad(date.getDate())).replace(/HH/g, pad(date.getHours())).replace(/mm/g, pad(date.getMinutes()));
|
|
@@ -1500,7 +1830,7 @@ function DateTimePicker(props) {
|
|
|
1500
1830
|
"aria-describedby": ariaDescribedBy,
|
|
1501
1831
|
"aria-labelledby": ariaLabelledBy
|
|
1502
1832
|
} = props;
|
|
1503
|
-
const generatedId =
|
|
1833
|
+
const generatedId = useId8();
|
|
1504
1834
|
const triggerId = id ?? generatedId + "-trigger";
|
|
1505
1835
|
const labelId = generatedId + "-label";
|
|
1506
1836
|
const messageId2 = generatedId + "-message";
|
|
@@ -1518,28 +1848,28 @@ function DateTimePicker(props) {
|
|
|
1518
1848
|
);
|
|
1519
1849
|
const isRange = mode === "range";
|
|
1520
1850
|
const controlled = props.value !== void 0;
|
|
1521
|
-
const [singleInternal, setSingleInternal] =
|
|
1851
|
+
const [singleInternal, setSingleInternal] = useState11(
|
|
1522
1852
|
(!isRange ? props.defaultValue : null) ?? null
|
|
1523
1853
|
);
|
|
1524
|
-
const [rangeInternal, setRangeInternal] =
|
|
1854
|
+
const [rangeInternal, setRangeInternal] = useState11(
|
|
1525
1855
|
(isRange ? props.defaultValue : void 0) ?? [null, null]
|
|
1526
1856
|
);
|
|
1527
1857
|
const singleValue = !isRange ? props.value ?? singleInternal : null;
|
|
1528
1858
|
const rangeValue = isRange ? props.value ?? rangeInternal : [null, null];
|
|
1529
|
-
const [open, setOpen] =
|
|
1530
|
-
const [month, setMonth] =
|
|
1859
|
+
const [open, setOpen] = useState11(false);
|
|
1860
|
+
const [month, setMonth] = useState11(
|
|
1531
1861
|
() => new Date((isRange ? rangeValue[0] : singleValue) ?? /* @__PURE__ */ new Date())
|
|
1532
1862
|
);
|
|
1533
|
-
const [editingEnd, setEditingEnd] =
|
|
1534
|
-
const rootRef =
|
|
1535
|
-
|
|
1863
|
+
const [editingEnd, setEditingEnd] = useState11(false);
|
|
1864
|
+
const rootRef = useRef7(null);
|
|
1865
|
+
useEffect7(() => {
|
|
1536
1866
|
const onPointerDown = (event) => {
|
|
1537
1867
|
if (!rootRef.current?.contains(event.target)) setOpen(false);
|
|
1538
1868
|
};
|
|
1539
1869
|
document.addEventListener("mousedown", onPointerDown);
|
|
1540
1870
|
return () => document.removeEventListener("mousedown", onPointerDown);
|
|
1541
1871
|
}, []);
|
|
1542
|
-
|
|
1872
|
+
useEffect7(() => {
|
|
1543
1873
|
if (disabled) setOpen(false);
|
|
1544
1874
|
}, [disabled]);
|
|
1545
1875
|
const setSingle = (next) => {
|
|
@@ -1595,7 +1925,7 @@ function DateTimePicker(props) {
|
|
|
1595
1925
|
setRange(editingEnd ? [rangeValue[0], next] : [next, rangeValue[1]]);
|
|
1596
1926
|
else setSingle(next);
|
|
1597
1927
|
};
|
|
1598
|
-
return /* @__PURE__ */
|
|
1928
|
+
return /* @__PURE__ */ jsxs14(
|
|
1599
1929
|
"div",
|
|
1600
1930
|
{
|
|
1601
1931
|
ref: rootRef,
|
|
@@ -1605,7 +1935,7 @@ function DateTimePicker(props) {
|
|
|
1605
1935
|
className
|
|
1606
1936
|
].filter(Boolean).join(" "),
|
|
1607
1937
|
children: [
|
|
1608
|
-
/* @__PURE__ */
|
|
1938
|
+
/* @__PURE__ */ jsx15(
|
|
1609
1939
|
FieldLabel,
|
|
1610
1940
|
{
|
|
1611
1941
|
id: labelId,
|
|
@@ -1615,7 +1945,7 @@ function DateTimePicker(props) {
|
|
|
1615
1945
|
isRequired
|
|
1616
1946
|
}
|
|
1617
1947
|
),
|
|
1618
|
-
/* @__PURE__ */
|
|
1948
|
+
/* @__PURE__ */ jsxs14(
|
|
1619
1949
|
"button",
|
|
1620
1950
|
{
|
|
1621
1951
|
id: triggerId,
|
|
@@ -1629,29 +1959,29 @@ function DateTimePicker(props) {
|
|
|
1629
1959
|
"aria-expanded": open,
|
|
1630
1960
|
onClick: () => setOpen((current) => !current),
|
|
1631
1961
|
children: [
|
|
1632
|
-
/* @__PURE__ */
|
|
1633
|
-
/* @__PURE__ */
|
|
1962
|
+
/* @__PURE__ */ jsx15("span", { "aria-hidden": "true", children: "\u25F7" }),
|
|
1963
|
+
/* @__PURE__ */ jsxs14(
|
|
1634
1964
|
"span",
|
|
1635
1965
|
{
|
|
1636
1966
|
className: !shownValue && placeholder ? "fe-datetime-picker__value is-placeholder" : "fe-datetime-picker__value",
|
|
1637
1967
|
children: [
|
|
1638
1968
|
shownValue || placeholder || (isRange ? "Select date range" : "Select date and time"),
|
|
1639
|
-
isRequired && placeholder && !shownValue && /* @__PURE__ */
|
|
1969
|
+
isRequired && placeholder && !shownValue && /* @__PURE__ */ jsx15("span", { className: "fe-field__required", "aria-hidden": "true", children: "*" })
|
|
1640
1970
|
]
|
|
1641
1971
|
}
|
|
1642
1972
|
)
|
|
1643
1973
|
]
|
|
1644
1974
|
}
|
|
1645
1975
|
),
|
|
1646
|
-
open && /* @__PURE__ */
|
|
1976
|
+
open && /* @__PURE__ */ jsxs14(
|
|
1647
1977
|
"div",
|
|
1648
1978
|
{
|
|
1649
1979
|
className: "fe-datetime-picker__popper",
|
|
1650
1980
|
role: "dialog",
|
|
1651
1981
|
"aria-label": "Date and time picker",
|
|
1652
1982
|
children: [
|
|
1653
|
-
/* @__PURE__ */
|
|
1654
|
-
/* @__PURE__ */
|
|
1983
|
+
/* @__PURE__ */ jsxs14("div", { className: "fe-datetime-picker__month", children: [
|
|
1984
|
+
/* @__PURE__ */ jsx15(
|
|
1655
1985
|
"button",
|
|
1656
1986
|
{
|
|
1657
1987
|
type: "button",
|
|
@@ -1662,11 +1992,11 @@ function DateTimePicker(props) {
|
|
|
1662
1992
|
children: "\u2039"
|
|
1663
1993
|
}
|
|
1664
1994
|
),
|
|
1665
|
-
/* @__PURE__ */
|
|
1995
|
+
/* @__PURE__ */ jsx15("strong", { children: month.toLocaleDateString(locale, {
|
|
1666
1996
|
month: "long",
|
|
1667
1997
|
year: "numeric"
|
|
1668
1998
|
}) }),
|
|
1669
|
-
/* @__PURE__ */
|
|
1999
|
+
/* @__PURE__ */ jsx15(
|
|
1670
2000
|
"button",
|
|
1671
2001
|
{
|
|
1672
2002
|
type: "button",
|
|
@@ -1678,12 +2008,12 @@ function DateTimePicker(props) {
|
|
|
1678
2008
|
}
|
|
1679
2009
|
)
|
|
1680
2010
|
] }),
|
|
1681
|
-
/* @__PURE__ */
|
|
1682
|
-
/* @__PURE__ */
|
|
2011
|
+
/* @__PURE__ */ jsx15("div", { className: "fe-datetime-picker__weekdays", children: ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"].map((day) => /* @__PURE__ */ jsx15("span", { children: day }, day)) }),
|
|
2012
|
+
/* @__PURE__ */ jsx15("div", { className: "fe-datetime-picker__days", children: days.map((day) => {
|
|
1683
2013
|
const inMonth = day.getMonth() === month.getMonth();
|
|
1684
2014
|
const selected = isRange ? sameDay(day, rangeValue[0]) || sameDay(day, rangeValue[1]) : sameDay(day, singleValue);
|
|
1685
2015
|
const inRange = isRange && rangeValue[0] && rangeValue[1] && day > startOfDay(rangeValue[0]) && day < startOfDay(rangeValue[1]);
|
|
1686
|
-
return /* @__PURE__ */
|
|
2016
|
+
return /* @__PURE__ */ jsx15(
|
|
1687
2017
|
"button",
|
|
1688
2018
|
{
|
|
1689
2019
|
type: "button",
|
|
@@ -1698,8 +2028,8 @@ function DateTimePicker(props) {
|
|
|
1698
2028
|
day.toISOString()
|
|
1699
2029
|
);
|
|
1700
2030
|
}) }),
|
|
1701
|
-
isRange && /* @__PURE__ */
|
|
1702
|
-
/* @__PURE__ */
|
|
2031
|
+
isRange && /* @__PURE__ */ jsxs14("div", { className: "fe-datetime-picker__range-tabs", children: [
|
|
2032
|
+
/* @__PURE__ */ jsx15(
|
|
1703
2033
|
"button",
|
|
1704
2034
|
{
|
|
1705
2035
|
type: "button",
|
|
@@ -1708,7 +2038,7 @@ function DateTimePicker(props) {
|
|
|
1708
2038
|
children: "Start"
|
|
1709
2039
|
}
|
|
1710
2040
|
),
|
|
1711
|
-
/* @__PURE__ */
|
|
2041
|
+
/* @__PURE__ */ jsx15(
|
|
1712
2042
|
"button",
|
|
1713
2043
|
{
|
|
1714
2044
|
type: "button",
|
|
@@ -1718,9 +2048,9 @@ function DateTimePicker(props) {
|
|
|
1718
2048
|
}
|
|
1719
2049
|
)
|
|
1720
2050
|
] }),
|
|
1721
|
-
/* @__PURE__ */
|
|
2051
|
+
/* @__PURE__ */ jsxs14("label", { className: "fe-datetime-picker__time", children: [
|
|
1722
2052
|
"Time",
|
|
1723
|
-
/* @__PURE__ */
|
|
2053
|
+
/* @__PURE__ */ jsx15(
|
|
1724
2054
|
"input",
|
|
1725
2055
|
{
|
|
1726
2056
|
type: "time",
|
|
@@ -1733,7 +2063,7 @@ function DateTimePicker(props) {
|
|
|
1733
2063
|
]
|
|
1734
2064
|
}
|
|
1735
2065
|
),
|
|
1736
|
-
/* @__PURE__ */
|
|
2066
|
+
/* @__PURE__ */ jsx15(
|
|
1737
2067
|
FieldMessage,
|
|
1738
2068
|
{
|
|
1739
2069
|
id: messageId2,
|
|
@@ -1748,9 +2078,9 @@ function DateTimePicker(props) {
|
|
|
1748
2078
|
}
|
|
1749
2079
|
|
|
1750
2080
|
// packages/form-controls/src/controls/Checkbox/checkbox.tsx
|
|
1751
|
-
import { forwardRef as
|
|
1752
|
-
import { jsx as
|
|
1753
|
-
var Checkbox =
|
|
2081
|
+
import { forwardRef as forwardRef8 } from "react";
|
|
2082
|
+
import { jsx as jsx16, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
2083
|
+
var Checkbox = forwardRef8(
|
|
1754
2084
|
function Checkbox2({
|
|
1755
2085
|
label,
|
|
1756
2086
|
labelPosition = "right",
|
|
@@ -1766,10 +2096,10 @@ var Checkbox = forwardRef7(
|
|
|
1766
2096
|
disabled && "fe-checkbox--disabled",
|
|
1767
2097
|
className
|
|
1768
2098
|
].filter(Boolean).join(" ");
|
|
1769
|
-
return /* @__PURE__ */
|
|
1770
|
-
label && labelPosition === "top" && /* @__PURE__ */
|
|
1771
|
-
/* @__PURE__ */
|
|
1772
|
-
/* @__PURE__ */
|
|
2099
|
+
return /* @__PURE__ */ jsxs15("label", { className: classes, style, children: [
|
|
2100
|
+
label && labelPosition === "top" && /* @__PURE__ */ jsx16("span", { className: "fe-checkbox__label", children: label }),
|
|
2101
|
+
/* @__PURE__ */ jsxs15("span", { className: "fe-checkbox__content", children: [
|
|
2102
|
+
/* @__PURE__ */ jsx16(
|
|
1773
2103
|
"input",
|
|
1774
2104
|
{
|
|
1775
2105
|
ref,
|
|
@@ -1780,8 +2110,8 @@ var Checkbox = forwardRef7(
|
|
|
1780
2110
|
...props
|
|
1781
2111
|
}
|
|
1782
2112
|
),
|
|
1783
|
-
/* @__PURE__ */
|
|
1784
|
-
label && labelPosition === "right" && /* @__PURE__ */
|
|
2113
|
+
/* @__PURE__ */ jsx16("span", { className: "fe-checkbox__control", "aria-hidden": "true" }),
|
|
2114
|
+
label && labelPosition === "right" && /* @__PURE__ */ jsx16("span", { className: "fe-checkbox__label", children: label })
|
|
1785
2115
|
] })
|
|
1786
2116
|
] });
|
|
1787
2117
|
}
|
|
@@ -1789,9 +2119,9 @@ var Checkbox = forwardRef7(
|
|
|
1789
2119
|
Checkbox.displayName = "Checkbox";
|
|
1790
2120
|
|
|
1791
2121
|
// packages/form-controls/src/controls/RadioButton/radio-button.tsx
|
|
1792
|
-
import { forwardRef as
|
|
1793
|
-
import { jsx as
|
|
1794
|
-
var RadioButton =
|
|
2122
|
+
import { forwardRef as forwardRef9 } from "react";
|
|
2123
|
+
import { jsx as jsx17, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2124
|
+
var RadioButton = forwardRef9(
|
|
1795
2125
|
function RadioButton2({
|
|
1796
2126
|
label,
|
|
1797
2127
|
labelPosition = "right",
|
|
@@ -1807,10 +2137,10 @@ var RadioButton = forwardRef8(
|
|
|
1807
2137
|
disabled && "fe-radio-button--disabled",
|
|
1808
2138
|
className
|
|
1809
2139
|
].filter(Boolean).join(" ");
|
|
1810
|
-
return /* @__PURE__ */
|
|
1811
|
-
label && labelPosition === "top" && /* @__PURE__ */
|
|
1812
|
-
/* @__PURE__ */
|
|
1813
|
-
/* @__PURE__ */
|
|
2140
|
+
return /* @__PURE__ */ jsxs16("label", { className: classes, style, children: [
|
|
2141
|
+
label && labelPosition === "top" && /* @__PURE__ */ jsx17("span", { className: "fe-radio-button__label", children: label }),
|
|
2142
|
+
/* @__PURE__ */ jsxs16("span", { className: "fe-radio-button__content", children: [
|
|
2143
|
+
/* @__PURE__ */ jsx17(
|
|
1814
2144
|
"input",
|
|
1815
2145
|
{
|
|
1816
2146
|
ref,
|
|
@@ -1821,8 +2151,8 @@ var RadioButton = forwardRef8(
|
|
|
1821
2151
|
...props
|
|
1822
2152
|
}
|
|
1823
2153
|
),
|
|
1824
|
-
/* @__PURE__ */
|
|
1825
|
-
label && labelPosition === "right" && /* @__PURE__ */
|
|
2154
|
+
/* @__PURE__ */ jsx17("span", { className: "fe-radio-button__control", "aria-hidden": "true" }),
|
|
2155
|
+
label && labelPosition === "right" && /* @__PURE__ */ jsx17("span", { className: "fe-radio-button__label", children: label })
|
|
1826
2156
|
] })
|
|
1827
2157
|
] });
|
|
1828
2158
|
}
|
|
@@ -1830,9 +2160,9 @@ var RadioButton = forwardRef8(
|
|
|
1830
2160
|
RadioButton.displayName = "RadioButton";
|
|
1831
2161
|
|
|
1832
2162
|
// packages/form-controls/src/controls/RadioGroup/radio-group.tsx
|
|
1833
|
-
import { forwardRef as
|
|
1834
|
-
import { jsx as
|
|
1835
|
-
var RadioGroup =
|
|
2163
|
+
import { forwardRef as forwardRef10, useId as useId9 } from "react";
|
|
2164
|
+
import { jsx as jsx18, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
2165
|
+
var RadioGroup = forwardRef10(
|
|
1836
2166
|
function RadioGroup2({
|
|
1837
2167
|
label,
|
|
1838
2168
|
labelPosition = "top",
|
|
@@ -1850,7 +2180,7 @@ var RadioGroup = forwardRef9(
|
|
|
1850
2180
|
"aria-labelledby": ariaLabelledBy,
|
|
1851
2181
|
...props
|
|
1852
2182
|
}, ref) {
|
|
1853
|
-
const generatedId =
|
|
2183
|
+
const generatedId = useId9();
|
|
1854
2184
|
const groupName = name ?? `fe-radio-group-${generatedId}`;
|
|
1855
2185
|
const labelId = `${id ?? generatedId}-label`;
|
|
1856
2186
|
const isControlled = value !== void 0;
|
|
@@ -1864,12 +2194,12 @@ var RadioGroup = forwardRef9(
|
|
|
1864
2194
|
const handleChange = (option, event) => {
|
|
1865
2195
|
if (event.target.checked) onChange?.(option.value, option, event);
|
|
1866
2196
|
};
|
|
1867
|
-
return /* @__PURE__ */
|
|
1868
|
-
label && labelPosition === "top" && /* @__PURE__ */
|
|
2197
|
+
return /* @__PURE__ */ jsxs17("div", { ref, className: classes, ...props, children: [
|
|
2198
|
+
label && labelPosition === "top" && /* @__PURE__ */ jsxs17("span", { id: labelId, className: "fe-radio-group__label", children: [
|
|
1869
2199
|
label,
|
|
1870
|
-
isRequired && /* @__PURE__ */
|
|
2200
|
+
isRequired && /* @__PURE__ */ jsx18("span", { className: "fe-radio-group__required", "aria-hidden": "true", children: "*" })
|
|
1871
2201
|
] }),
|
|
1872
|
-
/* @__PURE__ */
|
|
2202
|
+
/* @__PURE__ */ jsx18(
|
|
1873
2203
|
"div",
|
|
1874
2204
|
{
|
|
1875
2205
|
id,
|
|
@@ -1881,7 +2211,7 @@ var RadioGroup = forwardRef9(
|
|
|
1881
2211
|
children: options.map((option) => {
|
|
1882
2212
|
const optionDisabled = disabled || option.disabled;
|
|
1883
2213
|
const optionValue = String(option.value);
|
|
1884
|
-
return /* @__PURE__ */
|
|
2214
|
+
return /* @__PURE__ */ jsx18(
|
|
1885
2215
|
RadioButton,
|
|
1886
2216
|
{
|
|
1887
2217
|
name: groupName,
|
|
@@ -1898,9 +2228,9 @@ var RadioGroup = forwardRef9(
|
|
|
1898
2228
|
})
|
|
1899
2229
|
}
|
|
1900
2230
|
),
|
|
1901
|
-
label && labelPosition === "right" && /* @__PURE__ */
|
|
2231
|
+
label && labelPosition === "right" && /* @__PURE__ */ jsxs17("span", { id: labelId, className: "fe-radio-group__label", children: [
|
|
1902
2232
|
label,
|
|
1903
|
-
isRequired && /* @__PURE__ */
|
|
2233
|
+
isRequired && /* @__PURE__ */ jsx18("span", { className: "fe-radio-group__required", "aria-hidden": "true", children: "*" })
|
|
1904
2234
|
] })
|
|
1905
2235
|
] });
|
|
1906
2236
|
}
|
|
@@ -1908,29 +2238,29 @@ var RadioGroup = forwardRef9(
|
|
|
1908
2238
|
RadioGroup.displayName = "RadioGroup";
|
|
1909
2239
|
|
|
1910
2240
|
// packages/expandable-section/src/index.tsx
|
|
1911
|
-
import { useId as
|
|
1912
|
-
import { jsx as
|
|
2241
|
+
import { useId as useId10, useState as useState12 } from "react";
|
|
2242
|
+
import { jsx as jsx19, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
1913
2243
|
function ExpandableSection({ title, children, expanded, defaultExpanded = false, onExpandedChange, disabled, className, ...props }) {
|
|
1914
|
-
const [internalExpanded, setInternalExpanded] =
|
|
2244
|
+
const [internalExpanded, setInternalExpanded] = useState12(defaultExpanded);
|
|
1915
2245
|
const isExpanded = expanded ?? internalExpanded;
|
|
1916
|
-
const id =
|
|
2246
|
+
const id = useId10();
|
|
1917
2247
|
const toggle = () => {
|
|
1918
2248
|
if (disabled) return;
|
|
1919
2249
|
const next = !isExpanded;
|
|
1920
2250
|
if (expanded === void 0) setInternalExpanded(next);
|
|
1921
2251
|
onExpandedChange?.(next);
|
|
1922
2252
|
};
|
|
1923
|
-
return /* @__PURE__ */
|
|
1924
|
-
/* @__PURE__ */
|
|
1925
|
-
/* @__PURE__ */
|
|
1926
|
-
/* @__PURE__ */
|
|
2253
|
+
return /* @__PURE__ */ jsxs18("section", { className: ["fe-expandable-section", isExpanded && "fe-expandable-section--expanded", disabled && "fe-expandable-section--disabled", className].filter(Boolean).join(" "), ...props, children: [
|
|
2254
|
+
/* @__PURE__ */ jsxs18("button", { className: "fe-expandable-section__trigger", type: "button", "aria-expanded": isExpanded, "aria-controls": id, disabled, onClick: toggle, children: [
|
|
2255
|
+
/* @__PURE__ */ jsx19("span", { children: title }),
|
|
2256
|
+
/* @__PURE__ */ jsx19("span", { className: "fe-expandable-section__chevron", "aria-hidden": "true" })
|
|
1927
2257
|
] }),
|
|
1928
|
-
/* @__PURE__ */
|
|
2258
|
+
/* @__PURE__ */ jsx19("div", { id, className: "fe-expandable-section__content", "aria-hidden": !isExpanded, children: /* @__PURE__ */ jsx19("div", { className: "fe-expandable-section__content-inner", children }) })
|
|
1929
2259
|
] });
|
|
1930
2260
|
}
|
|
1931
2261
|
|
|
1932
2262
|
// packages/loading/src/index.tsx
|
|
1933
|
-
import { jsx as
|
|
2263
|
+
import { jsx as jsx20, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
1934
2264
|
var sizes = {
|
|
1935
2265
|
small: "16px",
|
|
1936
2266
|
medium: "24px",
|
|
@@ -1943,15 +2273,15 @@ function Loading({ size = "medium", color = "#2878f0", label, className, style,
|
|
|
1943
2273
|
"--fe-loading-color": color,
|
|
1944
2274
|
...style
|
|
1945
2275
|
};
|
|
1946
|
-
return /* @__PURE__ */
|
|
1947
|
-
/* @__PURE__ */
|
|
1948
|
-
label && /* @__PURE__ */
|
|
1949
|
-
!label && /* @__PURE__ */
|
|
2276
|
+
return /* @__PURE__ */ jsxs19("span", { className: ["fe-loading", className].filter(Boolean).join(" "), style: loadingStyle, role: "status", ...props, children: [
|
|
2277
|
+
/* @__PURE__ */ jsx20("span", { className: "fe-loading__spinner", "aria-hidden": "true" }),
|
|
2278
|
+
label && /* @__PURE__ */ jsx20("span", { className: "fe-loading__label", children: label }),
|
|
2279
|
+
!label && /* @__PURE__ */ jsx20("span", { className: "fe-loading__sr-only", children: "Loading" })
|
|
1950
2280
|
] });
|
|
1951
2281
|
}
|
|
1952
2282
|
|
|
1953
2283
|
// packages/skeleton/src/index.tsx
|
|
1954
|
-
import { Fragment as Fragment3, jsx as
|
|
2284
|
+
import { Fragment as Fragment3, jsx as jsx21 } from "react/jsx-runtime";
|
|
1955
2285
|
var pixels = (value) => typeof value === "number" ? `${value}px` : value;
|
|
1956
2286
|
function SkeletonBase({ variant = "box", shape, width, height, count = 1, animated = true, className, style, ...props }) {
|
|
1957
2287
|
const resolvedVariant = shape ?? variant;
|
|
@@ -1962,7 +2292,7 @@ function SkeletonBase({ variant = "box", shape, width, height, count = 1, animat
|
|
|
1962
2292
|
"--fe-skeleton-height": resolvedHeight,
|
|
1963
2293
|
...style
|
|
1964
2294
|
};
|
|
1965
|
-
return /* @__PURE__ */
|
|
2295
|
+
return /* @__PURE__ */ jsx21(Fragment3, { children: Array.from({ length: Math.max(1, count) }, (_, index) => /* @__PURE__ */ jsx21(
|
|
1966
2296
|
"div",
|
|
1967
2297
|
{
|
|
1968
2298
|
className: ["fe-skeleton", `fe-skeleton--${resolvedVariant}`, animated && "fe-skeleton--animated", className].filter(Boolean).join(" "),
|
|
@@ -1974,16 +2304,16 @@ function SkeletonBase({ variant = "box", shape, width, height, count = 1, animat
|
|
|
1974
2304
|
)) });
|
|
1975
2305
|
}
|
|
1976
2306
|
function SkeletonCircle({ size = 40, ...props }) {
|
|
1977
|
-
return /* @__PURE__ */
|
|
2307
|
+
return /* @__PURE__ */ jsx21(SkeletonBase, { variant: "circle", width: size, height: size, ...props });
|
|
1978
2308
|
}
|
|
1979
2309
|
function SkeletonSquare({ size = 80, ...props }) {
|
|
1980
|
-
return /* @__PURE__ */
|
|
2310
|
+
return /* @__PURE__ */ jsx21(SkeletonBase, { variant: "box", width: size, height: size, ...props });
|
|
1981
2311
|
}
|
|
1982
2312
|
function SkeletonBox({ width = "100%", height = 80, ...props }) {
|
|
1983
|
-
return /* @__PURE__ */
|
|
2313
|
+
return /* @__PURE__ */ jsx21(SkeletonBase, { variant: "box", width, height, ...props });
|
|
1984
2314
|
}
|
|
1985
2315
|
function SkeletonLine({ width = "100%", height = 12, ...props }) {
|
|
1986
|
-
return /* @__PURE__ */
|
|
2316
|
+
return /* @__PURE__ */ jsx21(SkeletonBase, { variant: "line", width, height, ...props });
|
|
1987
2317
|
}
|
|
1988
2318
|
var Skeleton = Object.assign(SkeletonBase, {
|
|
1989
2319
|
Circle: SkeletonCircle,
|
|
@@ -1993,9 +2323,9 @@ var Skeleton = Object.assign(SkeletonBase, {
|
|
|
1993
2323
|
});
|
|
1994
2324
|
|
|
1995
2325
|
// packages/modal/src/index.tsx
|
|
1996
|
-
import { useEffect as
|
|
2326
|
+
import { useEffect as useEffect8, useId as useId11, useRef as useRef8 } from "react";
|
|
1997
2327
|
import { createPortal as createPortal3 } from "react-dom";
|
|
1998
|
-
import { jsx as
|
|
2328
|
+
import { jsx as jsx22, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
1999
2329
|
function Modal({
|
|
2000
2330
|
open,
|
|
2001
2331
|
onClose,
|
|
@@ -2011,9 +2341,9 @@ function Modal({
|
|
|
2011
2341
|
className,
|
|
2012
2342
|
...props
|
|
2013
2343
|
}) {
|
|
2014
|
-
const titleId =
|
|
2015
|
-
const panelRef =
|
|
2016
|
-
|
|
2344
|
+
const titleId = useId11();
|
|
2345
|
+
const panelRef = useRef8(null);
|
|
2346
|
+
useEffect8(() => {
|
|
2017
2347
|
if (!open) return;
|
|
2018
2348
|
const onKeyDown = (event) => {
|
|
2019
2349
|
if (event.key === "Escape") onClose();
|
|
@@ -2025,9 +2355,9 @@ function Modal({
|
|
|
2025
2355
|
if (!open || typeof document === "undefined") return null;
|
|
2026
2356
|
const hasFooter = footer || actions.length > 0;
|
|
2027
2357
|
return createPortal3(
|
|
2028
|
-
/* @__PURE__ */
|
|
2358
|
+
/* @__PURE__ */ jsx22("div", { className: "fe-modal-backdrop", role: "presentation", onMouseDown: (event) => {
|
|
2029
2359
|
if (event.target === event.currentTarget && closeOnBackdropClick) onClose();
|
|
2030
|
-
}, children: /* @__PURE__ */
|
|
2360
|
+
}, children: /* @__PURE__ */ jsxs20(
|
|
2031
2361
|
"div",
|
|
2032
2362
|
{
|
|
2033
2363
|
ref: panelRef,
|
|
@@ -2039,17 +2369,17 @@ function Modal({
|
|
|
2039
2369
|
tabIndex: -1,
|
|
2040
2370
|
...props,
|
|
2041
2371
|
children: [
|
|
2042
|
-
(title || description || closeButton) && /* @__PURE__ */
|
|
2043
|
-
/* @__PURE__ */
|
|
2044
|
-
title && /* @__PURE__ */
|
|
2045
|
-
description && /* @__PURE__ */
|
|
2372
|
+
(title || description || closeButton) && /* @__PURE__ */ jsxs20("header", { className: "fe-modal__header", children: [
|
|
2373
|
+
/* @__PURE__ */ jsxs20("div", { className: "fe-modal__heading", children: [
|
|
2374
|
+
title && /* @__PURE__ */ jsx22("h2", { id: titleId, children: title }),
|
|
2375
|
+
description && /* @__PURE__ */ jsx22("p", { children: description })
|
|
2046
2376
|
] }),
|
|
2047
|
-
closeButton && /* @__PURE__ */
|
|
2377
|
+
closeButton && /* @__PURE__ */ jsx22(Button, { hierarchy: "tertiary-gray", size: "32", iconOnly: true, icon: /* @__PURE__ */ jsx22(CloseIcon, {}), "aria-label": closeLabel, onClick: onClose })
|
|
2048
2378
|
] }),
|
|
2049
|
-
/* @__PURE__ */
|
|
2050
|
-
hasFooter && /* @__PURE__ */
|
|
2051
|
-
footer && /* @__PURE__ */
|
|
2052
|
-
actions.length > 0 && /* @__PURE__ */
|
|
2379
|
+
/* @__PURE__ */ jsx22("div", { className: "fe-modal__body", children }),
|
|
2380
|
+
hasFooter && /* @__PURE__ */ jsxs20("footer", { className: "fe-modal__footer", children: [
|
|
2381
|
+
footer && /* @__PURE__ */ jsx22("div", { className: "fe-modal__footer-content", children: footer }),
|
|
2382
|
+
actions.length > 0 && /* @__PURE__ */ jsx22("div", { className: "fe-modal__actions", children: actions.map(({ label, ...action }, index) => /* @__PURE__ */ jsx22(Button, { ...action, children: label }, index)) })
|
|
2053
2383
|
] })
|
|
2054
2384
|
]
|
|
2055
2385
|
}
|
|
@@ -2059,7 +2389,7 @@ function Modal({
|
|
|
2059
2389
|
}
|
|
2060
2390
|
|
|
2061
2391
|
// packages/progress/src/index.tsx
|
|
2062
|
-
import { jsx as
|
|
2392
|
+
import { jsx as jsx23, jsxs as jsxs21 } from "react/jsx-runtime";
|
|
2063
2393
|
function ProgressBar({ value, max = 100, label, showValue = true, size = "medium", color = "#2878f0", className, style, "aria-label": ariaLabel, ...props }) {
|
|
2064
2394
|
const indeterminate = value === null || value === void 0;
|
|
2065
2395
|
const percentage = indeterminate ? 0 : Math.min(100, Math.max(0, Number(value) / Math.max(1, max) * 100));
|
|
@@ -2069,17 +2399,17 @@ function ProgressBar({ value, max = 100, label, showValue = true, size = "medium
|
|
|
2069
2399
|
...style
|
|
2070
2400
|
};
|
|
2071
2401
|
const visibleValue = `${Math.round(percentage)}%`;
|
|
2072
|
-
return /* @__PURE__ */
|
|
2073
|
-
(label || !indeterminate && showValue) && /* @__PURE__ */
|
|
2074
|
-
label && /* @__PURE__ */
|
|
2075
|
-
!indeterminate && showValue && /* @__PURE__ */
|
|
2402
|
+
return /* @__PURE__ */ jsxs21("div", { className: ["fe-progress", `fe-progress--${size}`, indeterminate && "fe-progress--indeterminate", className].filter(Boolean).join(" "), style: progressStyle, ...props, children: [
|
|
2403
|
+
(label || !indeterminate && showValue) && /* @__PURE__ */ jsxs21("div", { className: "fe-progress__meta", children: [
|
|
2404
|
+
label && /* @__PURE__ */ jsx23("span", { className: "fe-progress__label", children: label }),
|
|
2405
|
+
!indeterminate && showValue && /* @__PURE__ */ jsx23("output", { className: "fe-progress__value", children: visibleValue })
|
|
2076
2406
|
] }),
|
|
2077
|
-
/* @__PURE__ */
|
|
2407
|
+
/* @__PURE__ */ jsx23("div", { className: "fe-progress__track", role: "progressbar", "aria-label": ariaLabel ?? (typeof label === "string" ? label : "Progress"), "aria-valuemin": indeterminate ? void 0 : 0, "aria-valuemax": indeterminate ? void 0 : max, "aria-valuenow": indeterminate ? void 0 : Number(value), "aria-valuetext": indeterminate ? "Loading" : visibleValue, children: /* @__PURE__ */ jsx23("span", { className: "fe-progress__indicator" }) })
|
|
2078
2408
|
] });
|
|
2079
2409
|
}
|
|
2080
2410
|
|
|
2081
2411
|
// packages/chip/src/index.tsx
|
|
2082
|
-
import { jsx as
|
|
2412
|
+
import { jsx as jsx24, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
2083
2413
|
var statuses = ["default", "info", "success", "warning", "error", "neutral", "pending", "processing"];
|
|
2084
2414
|
function Chip({ children, status = "default", color, variant = "subtle", dot = false, onRemove, removeLabel = "Remove", className, style, ...props }) {
|
|
2085
2415
|
const usesCustomColor = Boolean(color);
|
|
@@ -2088,16 +2418,16 @@ function Chip({ children, status = "default", color, variant = "subtle", dot = f
|
|
|
2088
2418
|
...style
|
|
2089
2419
|
};
|
|
2090
2420
|
const resolvedStatus = statuses.includes(status) ? status : "default";
|
|
2091
|
-
return /* @__PURE__ */
|
|
2092
|
-
dot && /* @__PURE__ */
|
|
2093
|
-
/* @__PURE__ */
|
|
2094
|
-
onRemove && /* @__PURE__ */
|
|
2421
|
+
return /* @__PURE__ */ jsxs22("span", { className: ["fe-chip", `fe-chip--${variant}`, `fe-chip--${usesCustomColor ? "custom" : resolvedStatus}`, className].filter(Boolean).join(" "), style: chipStyle, ...props, children: [
|
|
2422
|
+
dot && /* @__PURE__ */ jsx24("span", { className: "fe-chip__dot", "aria-hidden": "true" }),
|
|
2423
|
+
/* @__PURE__ */ jsx24("span", { className: "fe-chip__content", children }),
|
|
2424
|
+
onRemove && /* @__PURE__ */ jsx24(Button, { hierarchy: "tertiary-gray", size: "24", iconOnly: true, icon: /* @__PURE__ */ jsx24(CloseIcon, { size: 14 }), "aria-label": removeLabel, onClick: onRemove, className: "fe-chip__remove" })
|
|
2095
2425
|
] });
|
|
2096
2426
|
}
|
|
2097
2427
|
|
|
2098
2428
|
// packages/message/src/index.tsx
|
|
2099
|
-
import { useEffect as
|
|
2100
|
-
import { jsx as
|
|
2429
|
+
import { useEffect as useEffect9, useState as useState13 } from "react";
|
|
2430
|
+
import { jsx as jsx25, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
2101
2431
|
var messageId = 0;
|
|
2102
2432
|
var entries = [];
|
|
2103
2433
|
var listeners = /* @__PURE__ */ new Set();
|
|
@@ -2130,22 +2460,22 @@ var message = {
|
|
|
2130
2460
|
};
|
|
2131
2461
|
var icons = { success: "\u2713", info: "i", warning: "!", error: "\xD7" };
|
|
2132
2462
|
function Message({ maxCount = 4, closeLabel = "Close notification", className, ...props }) {
|
|
2133
|
-
const [visibleEntries, setVisibleEntries] =
|
|
2134
|
-
|
|
2463
|
+
const [visibleEntries, setVisibleEntries] = useState13(entries);
|
|
2464
|
+
useEffect9(() => {
|
|
2135
2465
|
const listener = (nextEntries) => setVisibleEntries(nextEntries);
|
|
2136
2466
|
listeners.add(listener);
|
|
2137
2467
|
return () => {
|
|
2138
2468
|
listeners.delete(listener);
|
|
2139
2469
|
};
|
|
2140
2470
|
}, []);
|
|
2141
|
-
return /* @__PURE__ */
|
|
2142
|
-
/* @__PURE__ */
|
|
2143
|
-
/* @__PURE__ */
|
|
2144
|
-
entry.title && /* @__PURE__ */
|
|
2145
|
-
/* @__PURE__ */
|
|
2471
|
+
return /* @__PURE__ */ jsx25("div", { className: ["fe-message-viewport", className].filter(Boolean).join(" "), "aria-live": "polite", ...props, children: visibleEntries.slice(-Math.max(1, maxCount)).map((entry) => /* @__PURE__ */ jsxs23("div", { className: `fe-message fe-message--${entry.severity ?? "info"}`, role: entry.severity === "error" ? "alert" : "status", children: [
|
|
2472
|
+
/* @__PURE__ */ jsx25("span", { className: "fe-message__icon", "aria-hidden": "true", children: icons[entry.severity ?? "info"] }),
|
|
2473
|
+
/* @__PURE__ */ jsxs23("div", { className: "fe-message__body", children: [
|
|
2474
|
+
entry.title && /* @__PURE__ */ jsx25("strong", { className: "fe-message__title", children: entry.title }),
|
|
2475
|
+
/* @__PURE__ */ jsx25("div", { className: "fe-message__content", children: entry.content })
|
|
2146
2476
|
] }),
|
|
2147
|
-
entry.action && /* @__PURE__ */
|
|
2148
|
-
/* @__PURE__ */
|
|
2477
|
+
entry.action && /* @__PURE__ */ jsx25("span", { className: "fe-message__action", children: entry.action }),
|
|
2478
|
+
/* @__PURE__ */ jsx25(Button, { className: "fe-message__close", hierarchy: "tertiary-gray", size: "24", iconOnly: true, icon: "\xD7", "aria-label": closeLabel, onClick: () => dismiss(entry.id) })
|
|
2149
2479
|
] }, entry.id)) });
|
|
2150
2480
|
}
|
|
2151
2481
|
((Message2) => {
|
|
@@ -2159,8 +2489,8 @@ function Message({ maxCount = 4, closeLabel = "Close notification", className, .
|
|
|
2159
2489
|
})(Message || (Message = {}));
|
|
2160
2490
|
|
|
2161
2491
|
// packages/snackbar/src/index.tsx
|
|
2162
|
-
import { useEffect as
|
|
2163
|
-
import { jsx as
|
|
2492
|
+
import { useEffect as useEffect10 } from "react";
|
|
2493
|
+
import { jsx as jsx26, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
2164
2494
|
function Snackbar({
|
|
2165
2495
|
open,
|
|
2166
2496
|
message: message2,
|
|
@@ -2174,12 +2504,12 @@ function Snackbar({
|
|
|
2174
2504
|
}) {
|
|
2175
2505
|
const vertical = anchorOrigin.vertical ?? "bottom";
|
|
2176
2506
|
const horizontal = anchorOrigin.horizontal ?? "center";
|
|
2177
|
-
|
|
2507
|
+
useEffect10(() => {
|
|
2178
2508
|
if (!open || autoHideDuration === null) return void 0;
|
|
2179
2509
|
const timer = window.setTimeout(() => onClose?.("timeout"), autoHideDuration);
|
|
2180
2510
|
return () => window.clearTimeout(timer);
|
|
2181
2511
|
}, [open, autoHideDuration, onClose]);
|
|
2182
|
-
|
|
2512
|
+
useEffect10(() => {
|
|
2183
2513
|
if (!open) return void 0;
|
|
2184
2514
|
const onKeyDown = (event) => {
|
|
2185
2515
|
if (event.key === "Escape") onClose?.("escapeKeyDown");
|
|
@@ -2188,14 +2518,558 @@ function Snackbar({
|
|
|
2188
2518
|
return () => window.removeEventListener("keydown", onKeyDown);
|
|
2189
2519
|
}, [open, onClose]);
|
|
2190
2520
|
if (!open) return null;
|
|
2191
|
-
return /* @__PURE__ */
|
|
2192
|
-
/* @__PURE__ */
|
|
2193
|
-
action && /* @__PURE__ */
|
|
2194
|
-
onClose && /* @__PURE__ */
|
|
2521
|
+
return /* @__PURE__ */ jsx26("div", { className: ["fe-snackbar", `fe-snackbar--${vertical}`, `fe-snackbar--${horizontal}`, className].filter(Boolean).join(" "), ...props, children: /* @__PURE__ */ jsxs24("div", { className: "fe-snackbar__content", role: "status", "aria-live": "polite", children: [
|
|
2522
|
+
/* @__PURE__ */ jsx26("span", { className: "fe-snackbar__message", children: message2 }),
|
|
2523
|
+
action && /* @__PURE__ */ jsx26("span", { className: "fe-snackbar__action", children: action }),
|
|
2524
|
+
onClose && /* @__PURE__ */ jsx26(Button, { className: "fe-snackbar__close", hierarchy: "tertiary-gray", size: "24", iconOnly: true, icon: "\xD7", "aria-label": closeLabel, onClick: () => onClose("closeButton") })
|
|
2195
2525
|
] }) });
|
|
2196
2526
|
}
|
|
2527
|
+
|
|
2528
|
+
// packages/avatar/src/index.tsx
|
|
2529
|
+
import { Children, isValidElement as isValidElement2, useState as useState14 } from "react";
|
|
2530
|
+
import { jsx as jsx27, jsxs as jsxs25 } from "react/jsx-runtime";
|
|
2531
|
+
var FALLBACK_AVATARS = [
|
|
2532
|
+
{
|
|
2533
|
+
background: "#E0E7FF",
|
|
2534
|
+
skin: "#F6C6A6",
|
|
2535
|
+
hair: "#432818",
|
|
2536
|
+
shirt: "#5B5BD6",
|
|
2537
|
+
accent: "#A5B4FC",
|
|
2538
|
+
hairStyle: 0,
|
|
2539
|
+
expression: 0
|
|
2540
|
+
},
|
|
2541
|
+
{
|
|
2542
|
+
background: "#FDE68A",
|
|
2543
|
+
skin: "#E7AF87",
|
|
2544
|
+
hair: "#5A3424",
|
|
2545
|
+
shirt: "#D97706",
|
|
2546
|
+
accent: "#FCD34D",
|
|
2547
|
+
hairStyle: 1,
|
|
2548
|
+
expression: 1
|
|
2549
|
+
},
|
|
2550
|
+
{
|
|
2551
|
+
background: "#CCFBF1",
|
|
2552
|
+
skin: "#F4C7A1",
|
|
2553
|
+
hair: "#1F2937",
|
|
2554
|
+
shirt: "#0F766E",
|
|
2555
|
+
accent: "#5EEAD4",
|
|
2556
|
+
hairStyle: 2,
|
|
2557
|
+
expression: 2
|
|
2558
|
+
},
|
|
2559
|
+
{
|
|
2560
|
+
background: "#FCE7F3",
|
|
2561
|
+
skin: "#E5A47F",
|
|
2562
|
+
hair: "#6B2D2D",
|
|
2563
|
+
shirt: "#BE185D",
|
|
2564
|
+
accent: "#F9A8D4",
|
|
2565
|
+
hairStyle: 3,
|
|
2566
|
+
expression: 3,
|
|
2567
|
+
glasses: true
|
|
2568
|
+
},
|
|
2569
|
+
{
|
|
2570
|
+
background: "#DBEAFE",
|
|
2571
|
+
skin: "#8B5E3C",
|
|
2572
|
+
hair: "#24130B",
|
|
2573
|
+
shirt: "#2563EB",
|
|
2574
|
+
accent: "#93C5FD",
|
|
2575
|
+
hairStyle: 0,
|
|
2576
|
+
expression: 1
|
|
2577
|
+
},
|
|
2578
|
+
{
|
|
2579
|
+
background: "#DCFCE7",
|
|
2580
|
+
skin: "#D99B72",
|
|
2581
|
+
hair: "#3F2A20",
|
|
2582
|
+
shirt: "#15803D",
|
|
2583
|
+
accent: "#86EFAC",
|
|
2584
|
+
hairStyle: 1,
|
|
2585
|
+
expression: 2,
|
|
2586
|
+
glasses: true
|
|
2587
|
+
},
|
|
2588
|
+
{
|
|
2589
|
+
background: "#EDE9FE",
|
|
2590
|
+
skin: "#F3C9AD",
|
|
2591
|
+
hair: "#33221A",
|
|
2592
|
+
shirt: "#7C3AED",
|
|
2593
|
+
accent: "#C4B5FD",
|
|
2594
|
+
hairStyle: 2,
|
|
2595
|
+
expression: 3
|
|
2596
|
+
},
|
|
2597
|
+
{
|
|
2598
|
+
background: "#FFE4E6",
|
|
2599
|
+
skin: "#9B6547",
|
|
2600
|
+
hair: "#27150D",
|
|
2601
|
+
shirt: "#E11D48",
|
|
2602
|
+
accent: "#FDA4AF",
|
|
2603
|
+
hairStyle: 3,
|
|
2604
|
+
expression: 0
|
|
2605
|
+
},
|
|
2606
|
+
{
|
|
2607
|
+
background: "#FEF3C7",
|
|
2608
|
+
skin: "#F0B88B",
|
|
2609
|
+
hair: "#855F3B",
|
|
2610
|
+
shirt: "#B45309",
|
|
2611
|
+
accent: "#FBBF24",
|
|
2612
|
+
hairStyle: 0,
|
|
2613
|
+
expression: 2,
|
|
2614
|
+
glasses: true
|
|
2615
|
+
},
|
|
2616
|
+
{
|
|
2617
|
+
background: "#D1FAE5",
|
|
2618
|
+
skin: "#F8D0B0",
|
|
2619
|
+
hair: "#593A28",
|
|
2620
|
+
shirt: "#047857",
|
|
2621
|
+
accent: "#6EE7B7",
|
|
2622
|
+
hairStyle: 1,
|
|
2623
|
+
expression: 3
|
|
2624
|
+
},
|
|
2625
|
+
{
|
|
2626
|
+
background: "#E0F2FE",
|
|
2627
|
+
skin: "#CE8D65",
|
|
2628
|
+
hair: "#372015",
|
|
2629
|
+
shirt: "#0369A1",
|
|
2630
|
+
accent: "#7DD3FC",
|
|
2631
|
+
hairStyle: 2,
|
|
2632
|
+
expression: 0
|
|
2633
|
+
},
|
|
2634
|
+
{
|
|
2635
|
+
background: "#F3E8FF",
|
|
2636
|
+
skin: "#F4C6A3",
|
|
2637
|
+
hair: "#2B1B15",
|
|
2638
|
+
shirt: "#9333EA",
|
|
2639
|
+
accent: "#D8B4FE",
|
|
2640
|
+
hairStyle: 3,
|
|
2641
|
+
expression: 1,
|
|
2642
|
+
glasses: true
|
|
2643
|
+
},
|
|
2644
|
+
{
|
|
2645
|
+
background: "#FFE4C7",
|
|
2646
|
+
skin: "#A96D4C",
|
|
2647
|
+
hair: "#3A2116",
|
|
2648
|
+
shirt: "#C2410C",
|
|
2649
|
+
accent: "#FDBA74",
|
|
2650
|
+
hairStyle: 0,
|
|
2651
|
+
expression: 3
|
|
2652
|
+
},
|
|
2653
|
+
{
|
|
2654
|
+
background: "#ECFCCB",
|
|
2655
|
+
skin: "#F6CCA9",
|
|
2656
|
+
hair: "#7C5135",
|
|
2657
|
+
shirt: "#4D7C0F",
|
|
2658
|
+
accent: "#BEF264",
|
|
2659
|
+
hairStyle: 1,
|
|
2660
|
+
expression: 0
|
|
2661
|
+
},
|
|
2662
|
+
{
|
|
2663
|
+
background: "#CFFAFE",
|
|
2664
|
+
skin: "#E7A27A",
|
|
2665
|
+
hair: "#1F1814",
|
|
2666
|
+
shirt: "#0E7490",
|
|
2667
|
+
accent: "#67E8F9",
|
|
2668
|
+
hairStyle: 2,
|
|
2669
|
+
expression: 1,
|
|
2670
|
+
glasses: true
|
|
2671
|
+
},
|
|
2672
|
+
{
|
|
2673
|
+
background: "#FAE8FF",
|
|
2674
|
+
skin: "#F5C9AA",
|
|
2675
|
+
hair: "#5F3344",
|
|
2676
|
+
shirt: "#A21CAF",
|
|
2677
|
+
accent: "#F0ABFC",
|
|
2678
|
+
hairStyle: 3,
|
|
2679
|
+
expression: 2
|
|
2680
|
+
},
|
|
2681
|
+
{
|
|
2682
|
+
background: "#E0E7FF",
|
|
2683
|
+
skin: "#CF8F67",
|
|
2684
|
+
hair: "#1E1B18",
|
|
2685
|
+
shirt: "#4338CA",
|
|
2686
|
+
accent: "#A5B4FC",
|
|
2687
|
+
hairStyle: 0,
|
|
2688
|
+
expression: 3,
|
|
2689
|
+
glasses: true
|
|
2690
|
+
},
|
|
2691
|
+
{
|
|
2692
|
+
background: "#FFEDD5",
|
|
2693
|
+
skin: "#F7C9A6",
|
|
2694
|
+
hair: "#4E3326",
|
|
2695
|
+
shirt: "#EA580C",
|
|
2696
|
+
accent: "#FDBA74",
|
|
2697
|
+
hairStyle: 1,
|
|
2698
|
+
expression: 0
|
|
2699
|
+
},
|
|
2700
|
+
{
|
|
2701
|
+
background: "#D9F99D",
|
|
2702
|
+
skin: "#A66A49",
|
|
2703
|
+
hair: "#2B1911",
|
|
2704
|
+
shirt: "#65A30D",
|
|
2705
|
+
accent: "#BEF264",
|
|
2706
|
+
hairStyle: 2,
|
|
2707
|
+
expression: 1
|
|
2708
|
+
},
|
|
2709
|
+
{
|
|
2710
|
+
background: "#FCE7F3",
|
|
2711
|
+
skin: "#E9B08A",
|
|
2712
|
+
hair: "#4A2F24",
|
|
2713
|
+
shirt: "#DB2777",
|
|
2714
|
+
accent: "#F9A8D4",
|
|
2715
|
+
hairStyle: 3,
|
|
2716
|
+
expression: 2,
|
|
2717
|
+
glasses: true
|
|
2718
|
+
},
|
|
2719
|
+
{
|
|
2720
|
+
background: "#DBEAFE",
|
|
2721
|
+
skin: "#F2C3A1",
|
|
2722
|
+
hair: "#312018",
|
|
2723
|
+
shirt: "#1D4ED8",
|
|
2724
|
+
accent: "#93C5FD",
|
|
2725
|
+
hairStyle: 0,
|
|
2726
|
+
expression: 0
|
|
2727
|
+
},
|
|
2728
|
+
{
|
|
2729
|
+
background: "#CCFBF1",
|
|
2730
|
+
skin: "#9D6244",
|
|
2731
|
+
hair: "#1F130E",
|
|
2732
|
+
shirt: "#0D9488",
|
|
2733
|
+
accent: "#5EEAD4",
|
|
2734
|
+
hairStyle: 1,
|
|
2735
|
+
expression: 1,
|
|
2736
|
+
glasses: true
|
|
2737
|
+
},
|
|
2738
|
+
{
|
|
2739
|
+
background: "#FEE2E2",
|
|
2740
|
+
skin: "#F6CBAA",
|
|
2741
|
+
hair: "#75452A",
|
|
2742
|
+
shirt: "#DC2626",
|
|
2743
|
+
accent: "#FCA5A5",
|
|
2744
|
+
hairStyle: 2,
|
|
2745
|
+
expression: 2
|
|
2746
|
+
},
|
|
2747
|
+
{
|
|
2748
|
+
background: "#EDE9FE",
|
|
2749
|
+
skin: "#D98E65",
|
|
2750
|
+
hair: "#412720",
|
|
2751
|
+
shirt: "#6D28D9",
|
|
2752
|
+
accent: "#C4B5FD",
|
|
2753
|
+
hairStyle: 3,
|
|
2754
|
+
expression: 3
|
|
2755
|
+
},
|
|
2756
|
+
{
|
|
2757
|
+
background: "#FEF9C3",
|
|
2758
|
+
skin: "#F5C7A4",
|
|
2759
|
+
hair: "#2B1A12",
|
|
2760
|
+
shirt: "#A16207",
|
|
2761
|
+
accent: "#FDE047",
|
|
2762
|
+
hairStyle: 0,
|
|
2763
|
+
expression: 1,
|
|
2764
|
+
glasses: true
|
|
2765
|
+
},
|
|
2766
|
+
{
|
|
2767
|
+
background: "#DCFCE7",
|
|
2768
|
+
skin: "#B97855",
|
|
2769
|
+
hair: "#291A13",
|
|
2770
|
+
shirt: "#16A34A",
|
|
2771
|
+
accent: "#86EFAC",
|
|
2772
|
+
hairStyle: 1,
|
|
2773
|
+
expression: 2
|
|
2774
|
+
},
|
|
2775
|
+
{
|
|
2776
|
+
background: "#E0F2FE",
|
|
2777
|
+
skin: "#F6C5A2",
|
|
2778
|
+
hair: "#6A4031",
|
|
2779
|
+
shirt: "#0284C7",
|
|
2780
|
+
accent: "#7DD3FC",
|
|
2781
|
+
hairStyle: 2,
|
|
2782
|
+
expression: 3,
|
|
2783
|
+
glasses: true
|
|
2784
|
+
},
|
|
2785
|
+
{
|
|
2786
|
+
background: "#FAE8FF",
|
|
2787
|
+
skin: "#DE9B72",
|
|
2788
|
+
hair: "#211714",
|
|
2789
|
+
shirt: "#C026D3",
|
|
2790
|
+
accent: "#F0ABFC",
|
|
2791
|
+
hairStyle: 3,
|
|
2792
|
+
expression: 0
|
|
2793
|
+
},
|
|
2794
|
+
{
|
|
2795
|
+
background: "#FFE4E6",
|
|
2796
|
+
skin: "#F7CEAF",
|
|
2797
|
+
hair: "#42291E",
|
|
2798
|
+
shirt: "#E11D48",
|
|
2799
|
+
accent: "#FDA4AF",
|
|
2800
|
+
hairStyle: 0,
|
|
2801
|
+
expression: 2
|
|
2802
|
+
},
|
|
2803
|
+
{
|
|
2804
|
+
background: "#ECFCCB",
|
|
2805
|
+
skin: "#CE8C65",
|
|
2806
|
+
hair: "#3C2419",
|
|
2807
|
+
shirt: "#3F6212",
|
|
2808
|
+
accent: "#BEF264",
|
|
2809
|
+
hairStyle: 1,
|
|
2810
|
+
expression: 3,
|
|
2811
|
+
glasses: true
|
|
2812
|
+
},
|
|
2813
|
+
{
|
|
2814
|
+
background: "#CFFAFE",
|
|
2815
|
+
skin: "#F0BE99",
|
|
2816
|
+
hair: "#29201B",
|
|
2817
|
+
shirt: "#0891B2",
|
|
2818
|
+
accent: "#67E8F9",
|
|
2819
|
+
hairStyle: 2,
|
|
2820
|
+
expression: 0
|
|
2821
|
+
},
|
|
2822
|
+
{
|
|
2823
|
+
background: "#F3E8FF",
|
|
2824
|
+
skin: "#A76B4B",
|
|
2825
|
+
hair: "#241710",
|
|
2826
|
+
shirt: "#7E22CE",
|
|
2827
|
+
accent: "#D8B4FE",
|
|
2828
|
+
hairStyle: 3,
|
|
2829
|
+
expression: 1,
|
|
2830
|
+
glasses: true
|
|
2831
|
+
}
|
|
2832
|
+
];
|
|
2833
|
+
function getInitials(content) {
|
|
2834
|
+
const words = content.trim().split(/\s+/).filter(Boolean);
|
|
2835
|
+
return words.slice(-2).map((word) => Array.from(word)[0] ?? "").join("").toLocaleUpperCase();
|
|
2836
|
+
}
|
|
2837
|
+
function resolveSize(size) {
|
|
2838
|
+
if (typeof size === "number") return `${size}px`;
|
|
2839
|
+
return /^\d+(?:\.\d+)?$/.test(size) ? `${size}px` : size;
|
|
2840
|
+
}
|
|
2841
|
+
function resolveFontSize(size) {
|
|
2842
|
+
const numericSize = typeof size === "number" ? size : Number(size);
|
|
2843
|
+
if (Number.isFinite(numericSize)) {
|
|
2844
|
+
return `${Math.min(28, Math.max(10, numericSize * 0.38))}px`;
|
|
2845
|
+
}
|
|
2846
|
+
return "1em";
|
|
2847
|
+
}
|
|
2848
|
+
function getFallbackIndex(index) {
|
|
2849
|
+
if (!Number.isFinite(index)) return 0;
|
|
2850
|
+
return Math.abs(Math.trunc(index)) % FALLBACK_AVATARS.length;
|
|
2851
|
+
}
|
|
2852
|
+
function AvatarFallbackIcon({ avatar }) {
|
|
2853
|
+
const {
|
|
2854
|
+
accent,
|
|
2855
|
+
background,
|
|
2856
|
+
expression,
|
|
2857
|
+
glasses,
|
|
2858
|
+
hair,
|
|
2859
|
+
hairStyle,
|
|
2860
|
+
shirt,
|
|
2861
|
+
skin
|
|
2862
|
+
} = avatar;
|
|
2863
|
+
return /* @__PURE__ */ jsxs25(
|
|
2864
|
+
"svg",
|
|
2865
|
+
{
|
|
2866
|
+
className: "fe-avatar__fallback-icon",
|
|
2867
|
+
viewBox: "0 0 24 24",
|
|
2868
|
+
focusable: "false",
|
|
2869
|
+
"aria-hidden": "true",
|
|
2870
|
+
children: [
|
|
2871
|
+
/* @__PURE__ */ jsx27("rect", { width: "24", height: "24", fill: background }),
|
|
2872
|
+
/* @__PURE__ */ jsx27(
|
|
2873
|
+
"path",
|
|
2874
|
+
{
|
|
2875
|
+
d: "M3 24c.52-3.79 3.58-6.25 9-6.25S20.48 20.21 21 24",
|
|
2876
|
+
fill: shirt
|
|
2877
|
+
}
|
|
2878
|
+
),
|
|
2879
|
+
/* @__PURE__ */ jsx27(
|
|
2880
|
+
"path",
|
|
2881
|
+
{
|
|
2882
|
+
d: "M8.1 17.65h7.8l1.05 2.05H7.05l1.05-2.05Z",
|
|
2883
|
+
fill: accent,
|
|
2884
|
+
opacity: ".72"
|
|
2885
|
+
}
|
|
2886
|
+
),
|
|
2887
|
+
/* @__PURE__ */ jsx27("circle", { cx: "12", cy: "10.25", r: "5.25", fill: skin }),
|
|
2888
|
+
hairStyle === 0 && /* @__PURE__ */ jsx27(
|
|
2889
|
+
"path",
|
|
2890
|
+
{
|
|
2891
|
+
d: "M6.75 10.25C6.75 6.34 9.02 4 12.15 4c3.22 0 5.1 2.33 5.1 5.54-1.6-1.41-3.46-2.1-5.59-2.1-1.63 0-3.27.56-4.91 1.68Z",
|
|
2892
|
+
fill: hair
|
|
2893
|
+
}
|
|
2894
|
+
),
|
|
2895
|
+
hairStyle === 1 && /* @__PURE__ */ jsx27(
|
|
2896
|
+
"path",
|
|
2897
|
+
{
|
|
2898
|
+
d: "M6.6 10.1c.16-3.93 2.57-6.2 5.62-6.2 3.57 0 5.3 2.75 5.08 6.32-1.42-1.23-2.91-1.82-4.48-1.82-2.4 0-3.9.65-6.22 1.7Z",
|
|
2899
|
+
fill: hair
|
|
2900
|
+
}
|
|
2901
|
+
),
|
|
2902
|
+
hairStyle === 2 && /* @__PURE__ */ jsx27(
|
|
2903
|
+
"path",
|
|
2904
|
+
{
|
|
2905
|
+
d: "M6.8 10.55C6.8 6.28 9.43 4 12.2 4c3.46 0 5.13 2.83 4.93 6.38-1.38-1.58-3.03-2.38-4.92-2.38-1.81 0-3.61.85-5.41 2.55Z",
|
|
2906
|
+
fill: hair
|
|
2907
|
+
}
|
|
2908
|
+
),
|
|
2909
|
+
hairStyle === 3 && /* @__PURE__ */ jsx27(
|
|
2910
|
+
"path",
|
|
2911
|
+
{
|
|
2912
|
+
d: "M6.66 10.1C6.94 6.12 9.18 4 12.1 4c3.77 0 5.2 2.95 5.18 6.21-1.5-1.07-3.1-1.6-4.8-1.6-2.18 0-3.98.5-5.82 1.49Z",
|
|
2913
|
+
fill: hair
|
|
2914
|
+
}
|
|
2915
|
+
),
|
|
2916
|
+
/* @__PURE__ */ jsx27("circle", { cx: "10.05", cy: "10.65", r: ".48", fill: "#3B2924" }),
|
|
2917
|
+
/* @__PURE__ */ jsx27("circle", { cx: "13.95", cy: "10.65", r: ".48", fill: "#3B2924" }),
|
|
2918
|
+
expression === 0 && /* @__PURE__ */ jsx27(
|
|
2919
|
+
"path",
|
|
2920
|
+
{
|
|
2921
|
+
d: "M10.25 13.2c1.08.66 2.42.66 3.5 0",
|
|
2922
|
+
fill: "none",
|
|
2923
|
+
stroke: "#A94F4F",
|
|
2924
|
+
strokeWidth: ".7",
|
|
2925
|
+
strokeLinecap: "round"
|
|
2926
|
+
}
|
|
2927
|
+
),
|
|
2928
|
+
expression === 1 && /* @__PURE__ */ jsx27(
|
|
2929
|
+
"path",
|
|
2930
|
+
{
|
|
2931
|
+
d: "M10.5 13.2h3",
|
|
2932
|
+
fill: "none",
|
|
2933
|
+
stroke: "#A94F4F",
|
|
2934
|
+
strokeWidth: ".7",
|
|
2935
|
+
strokeLinecap: "round"
|
|
2936
|
+
}
|
|
2937
|
+
),
|
|
2938
|
+
expression === 2 && /* @__PURE__ */ jsx27(
|
|
2939
|
+
"path",
|
|
2940
|
+
{
|
|
2941
|
+
d: "M10.6 13.38c.84-.44 1.96-.44 2.8 0",
|
|
2942
|
+
fill: "none",
|
|
2943
|
+
stroke: "#A94F4F",
|
|
2944
|
+
strokeWidth: ".7",
|
|
2945
|
+
strokeLinecap: "round"
|
|
2946
|
+
}
|
|
2947
|
+
),
|
|
2948
|
+
expression === 3 && /* @__PURE__ */ jsx27("circle", { cx: "12", cy: "13.2", r: ".82", fill: "#B95A5A" }),
|
|
2949
|
+
glasses && /* @__PURE__ */ jsxs25("g", { fill: "none", stroke: "#3C4355", strokeWidth: ".65", children: [
|
|
2950
|
+
/* @__PURE__ */ jsx27("circle", { cx: "10", cy: "10.55", r: "1.45" }),
|
|
2951
|
+
/* @__PURE__ */ jsx27("circle", { cx: "14", cy: "10.55", r: "1.45" }),
|
|
2952
|
+
/* @__PURE__ */ jsx27("path", { d: "M11.45 10.55h1.1M8.55 10.55H7.5m9 0h-1.05" })
|
|
2953
|
+
] })
|
|
2954
|
+
]
|
|
2955
|
+
}
|
|
2956
|
+
);
|
|
2957
|
+
}
|
|
2958
|
+
function Avatar({
|
|
2959
|
+
src,
|
|
2960
|
+
content,
|
|
2961
|
+
alt,
|
|
2962
|
+
size = 40,
|
|
2963
|
+
shape = "circle",
|
|
2964
|
+
fallbackIndex,
|
|
2965
|
+
className,
|
|
2966
|
+
style,
|
|
2967
|
+
role,
|
|
2968
|
+
"aria-label": ariaLabel,
|
|
2969
|
+
...props
|
|
2970
|
+
}) {
|
|
2971
|
+
const [generatedFallbackIndex] = useState14(
|
|
2972
|
+
() => Math.floor(Math.random() * FALLBACK_AVATARS.length)
|
|
2973
|
+
);
|
|
2974
|
+
const [failedImageSrc, setFailedImageSrc] = useState14();
|
|
2975
|
+
const imageSrc = src?.trim();
|
|
2976
|
+
const trimmedContent = content?.trim() ?? "";
|
|
2977
|
+
const showImage = Boolean(imageSrc && failedImageSrc !== imageSrc);
|
|
2978
|
+
const initials = trimmedContent ? getInitials(trimmedContent) : "";
|
|
2979
|
+
const selectedFallback = FALLBACK_AVATARS[getFallbackIndex(fallbackIndex ?? generatedFallbackIndex)];
|
|
2980
|
+
const avatarStyle = {
|
|
2981
|
+
"--fe-avatar-size": resolveSize(size),
|
|
2982
|
+
"--fe-avatar-font-size": resolveFontSize(size),
|
|
2983
|
+
...style
|
|
2984
|
+
};
|
|
2985
|
+
const fallbackLabel = (alt ?? trimmedContent) || "Avatar";
|
|
2986
|
+
return /* @__PURE__ */ jsxs25(
|
|
2987
|
+
"span",
|
|
2988
|
+
{
|
|
2989
|
+
className: ["fe-avatar", `fe-avatar--${shape}`, className].filter(Boolean).join(" "),
|
|
2990
|
+
style: avatarStyle,
|
|
2991
|
+
role: showImage ? role : role ?? "img",
|
|
2992
|
+
"aria-label": showImage ? ariaLabel : ariaLabel ?? fallbackLabel,
|
|
2993
|
+
...props,
|
|
2994
|
+
children: [
|
|
2995
|
+
showImage && /* @__PURE__ */ jsx27(
|
|
2996
|
+
"img",
|
|
2997
|
+
{
|
|
2998
|
+
className: "fe-avatar__image",
|
|
2999
|
+
src: imageSrc,
|
|
3000
|
+
alt: alt ?? trimmedContent,
|
|
3001
|
+
onError: () => setFailedImageSrc(imageSrc)
|
|
3002
|
+
}
|
|
3003
|
+
),
|
|
3004
|
+
!showImage && initials && /* @__PURE__ */ jsx27("span", { className: "fe-avatar__initials", "aria-hidden": "true", children: initials }),
|
|
3005
|
+
!showImage && !initials && /* @__PURE__ */ jsx27(AvatarFallbackIcon, { avatar: selectedFallback })
|
|
3006
|
+
]
|
|
3007
|
+
}
|
|
3008
|
+
);
|
|
3009
|
+
}
|
|
3010
|
+
function AvatarGroup({
|
|
3011
|
+
children,
|
|
3012
|
+
maxCount,
|
|
3013
|
+
className,
|
|
3014
|
+
style,
|
|
3015
|
+
role,
|
|
3016
|
+
...props
|
|
3017
|
+
}) {
|
|
3018
|
+
const avatars = Children.toArray(children).filter(isValidElement2);
|
|
3019
|
+
const hasMaxCount = typeof maxCount === "number" && Number.isFinite(maxCount) && maxCount > 0;
|
|
3020
|
+
const itemLimit = hasMaxCount ? Math.floor(maxCount) : avatars.length;
|
|
3021
|
+
const hasOverflow = avatars.length > itemLimit;
|
|
3022
|
+
const visibleCount = hasOverflow ? Math.max(0, itemLimit - 1) : itemLimit;
|
|
3023
|
+
const visibleAvatars = avatars.slice(0, visibleCount);
|
|
3024
|
+
const overflowCount = avatars.length - visibleAvatars.length;
|
|
3025
|
+
const firstAvatarSize = avatars[0]?.props.size ?? 40;
|
|
3026
|
+
const overflowStyle = {
|
|
3027
|
+
"--fe-avatar-size": resolveSize(firstAvatarSize),
|
|
3028
|
+
"--fe-avatar-font-size": resolveFontSize(firstAvatarSize)
|
|
3029
|
+
};
|
|
3030
|
+
const singleContent = avatars.length === 1 ? avatars[0]?.props.content?.trim() ?? "" : "";
|
|
3031
|
+
return /* @__PURE__ */ jsxs25(
|
|
3032
|
+
"div",
|
|
3033
|
+
{
|
|
3034
|
+
className: ["fe-avatar-group", className].filter(Boolean).join(" "),
|
|
3035
|
+
style,
|
|
3036
|
+
role: role ?? "group",
|
|
3037
|
+
...props,
|
|
3038
|
+
children: [
|
|
3039
|
+
/* @__PURE__ */ jsxs25("div", { className: "fe-avatar-group__items", children: [
|
|
3040
|
+
visibleAvatars.map((avatar, index) => /* @__PURE__ */ jsx27(
|
|
3041
|
+
"span",
|
|
3042
|
+
{
|
|
3043
|
+
className: "fe-avatar-group__item",
|
|
3044
|
+
style: { zIndex: visibleAvatars.length - index },
|
|
3045
|
+
children: avatar
|
|
3046
|
+
},
|
|
3047
|
+
avatar.key ?? index
|
|
3048
|
+
)),
|
|
3049
|
+
hasOverflow && /* @__PURE__ */ jsxs25(
|
|
3050
|
+
"span",
|
|
3051
|
+
{
|
|
3052
|
+
className: "fe-avatar-group__more",
|
|
3053
|
+
style: overflowStyle,
|
|
3054
|
+
role: "img",
|
|
3055
|
+
"aria-label": `${overflowCount} more avatars`,
|
|
3056
|
+
children: [
|
|
3057
|
+
"+",
|
|
3058
|
+
overflowCount
|
|
3059
|
+
]
|
|
3060
|
+
}
|
|
3061
|
+
)
|
|
3062
|
+
] }),
|
|
3063
|
+
singleContent && /* @__PURE__ */ jsx27("span", { className: "fe-avatar-group__content", children: singleContent })
|
|
3064
|
+
]
|
|
3065
|
+
}
|
|
3066
|
+
);
|
|
3067
|
+
}
|
|
2197
3068
|
export {
|
|
3069
|
+
Avatar,
|
|
3070
|
+
AvatarGroup,
|
|
2198
3071
|
Button,
|
|
3072
|
+
ButtonBar,
|
|
2199
3073
|
Checkbox,
|
|
2200
3074
|
ChevronDownIcon,
|
|
2201
3075
|
ChevronUpIcon,
|
|
@@ -2208,6 +3082,8 @@ export {
|
|
|
2208
3082
|
Loading,
|
|
2209
3083
|
Message,
|
|
2210
3084
|
Modal,
|
|
3085
|
+
MoreHorizontalIcon,
|
|
3086
|
+
MoreVerticalIcon,
|
|
2211
3087
|
NumberInput,
|
|
2212
3088
|
Pagination,
|
|
2213
3089
|
PlusIcon,
|
|
@@ -2229,6 +3105,7 @@ export {
|
|
|
2229
3105
|
TableHead,
|
|
2230
3106
|
TableHeader,
|
|
2231
3107
|
TableRow,
|
|
3108
|
+
Tabs,
|
|
2232
3109
|
TextArea,
|
|
2233
3110
|
TextInput,
|
|
2234
3111
|
Toggle,
|