@dragunio/fe-libs 0.1.6 → 0.1.7
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 +11 -1
- package/dist/{chunk-NDMLXSI5.mjs → chunk-GT4546FD.mjs} +16 -0
- package/dist/icons.d.mts +3 -1
- package/dist/icons.d.ts +3 -1
- package/dist/icons.js +18 -0
- package/dist/icons.mjs +5 -1
- package/dist/index.d.mts +52 -3
- package/dist/index.d.ts +52 -3
- package/dist/index.js +967 -300
- package/dist/index.mjs +938 -290
- package/dist/styles.css +123 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20,7 +20,10 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
Avatar: () => Avatar,
|
|
24
|
+
AvatarGroup: () => AvatarGroup,
|
|
23
25
|
Button: () => Button,
|
|
26
|
+
ButtonBar: () => ButtonBar,
|
|
24
27
|
Checkbox: () => Checkbox,
|
|
25
28
|
ChevronDownIcon: () => ChevronDownIcon,
|
|
26
29
|
ChevronUpIcon: () => ChevronUpIcon,
|
|
@@ -33,6 +36,8 @@ __export(index_exports, {
|
|
|
33
36
|
Loading: () => Loading,
|
|
34
37
|
Message: () => Message,
|
|
35
38
|
Modal: () => Modal,
|
|
39
|
+
MoreHorizontalIcon: () => MoreHorizontalIcon,
|
|
40
|
+
MoreVerticalIcon: () => MoreVerticalIcon,
|
|
36
41
|
NumberInput: () => NumberInput,
|
|
37
42
|
Pagination: () => Pagination,
|
|
38
43
|
PlusIcon: () => PlusIcon,
|
|
@@ -147,6 +152,9 @@ var Button = (0, import_react.forwardRef)(
|
|
|
147
152
|
);
|
|
148
153
|
Button.displayName = "Button";
|
|
149
154
|
|
|
155
|
+
// packages/button-bar/src/index.tsx
|
|
156
|
+
var import_react2 = require("react");
|
|
157
|
+
|
|
150
158
|
// packages/icons/src/svgItems/general.tsx
|
|
151
159
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
152
160
|
var primaryColor = "#101828";
|
|
@@ -290,6 +298,20 @@ function CloseIcon(props) {
|
|
|
290
298
|
}
|
|
291
299
|
) });
|
|
292
300
|
}
|
|
301
|
+
function MoreHorizontalIcon(props) {
|
|
302
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { ...iconProps4(props), children: [
|
|
303
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { cx: "5", cy: "12", r: "1.75", fill: "currentColor" }),
|
|
304
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { cx: "12", cy: "12", r: "1.75", fill: "currentColor" }),
|
|
305
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { cx: "19", cy: "12", r: "1.75", fill: "currentColor" })
|
|
306
|
+
] });
|
|
307
|
+
}
|
|
308
|
+
function MoreVerticalIcon(props) {
|
|
309
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { ...iconProps4(props), children: [
|
|
310
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { cx: "12", cy: "5", r: "1.75", fill: "currentColor" }),
|
|
311
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { cx: "12", cy: "12", r: "1.75", fill: "currentColor" }),
|
|
312
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { cx: "12", cy: "19", r: "1.75", fill: "currentColor" })
|
|
313
|
+
] });
|
|
314
|
+
}
|
|
293
315
|
function SearchIcon(props) {
|
|
294
316
|
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("svg", { ...iconProps4(props), children: [
|
|
295
317
|
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("circle", { cx: "11", cy: "11", r: "6.5", stroke: "currentColor", strokeWidth: "2" }),
|
|
@@ -305,12 +327,111 @@ function SearchIcon(props) {
|
|
|
305
327
|
] });
|
|
306
328
|
}
|
|
307
329
|
|
|
308
|
-
// packages/
|
|
330
|
+
// packages/button-bar/src/index.tsx
|
|
331
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
309
332
|
var import_react3 = require("react");
|
|
333
|
+
function ButtonBar({
|
|
334
|
+
actions,
|
|
335
|
+
maxVisible = actions.length,
|
|
336
|
+
moreButtonProps,
|
|
337
|
+
moreLabel = "More actions",
|
|
338
|
+
className,
|
|
339
|
+
...props
|
|
340
|
+
}) {
|
|
341
|
+
const [isMoreOpen, setIsMoreOpen] = (0, import_react2.useState)(false);
|
|
342
|
+
const rootRef = (0, import_react2.useRef)(null);
|
|
343
|
+
const moreMenuId = (0, import_react2.useId)();
|
|
344
|
+
const visibleCount = Math.max(0, Math.floor(maxVisible));
|
|
345
|
+
const visibleActions = actions.slice(0, visibleCount);
|
|
346
|
+
const overflowActions = actions.slice(visibleCount);
|
|
347
|
+
const hasOverflow = overflowActions.length > 0;
|
|
348
|
+
const {
|
|
349
|
+
onClick: onMoreClick,
|
|
350
|
+
disabled: moreDisabled,
|
|
351
|
+
"aria-label": moreAriaLabel,
|
|
352
|
+
...moreButtonRestProps
|
|
353
|
+
} = moreButtonProps ?? {};
|
|
354
|
+
(0, import_react2.useEffect)(() => {
|
|
355
|
+
if (!isMoreOpen) return;
|
|
356
|
+
const onPointerDown = (event) => {
|
|
357
|
+
if (!rootRef.current?.contains(event.target)) {
|
|
358
|
+
setIsMoreOpen(false);
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
const onKeyDown = (event) => {
|
|
362
|
+
if (event.key === "Escape") setIsMoreOpen(false);
|
|
363
|
+
};
|
|
364
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
365
|
+
document.addEventListener("keydown", onKeyDown);
|
|
366
|
+
return () => {
|
|
367
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
368
|
+
document.removeEventListener("keydown", onKeyDown);
|
|
369
|
+
};
|
|
370
|
+
}, [isMoreOpen]);
|
|
371
|
+
const renderAction = (action, shouldCloseMore = false) => {
|
|
372
|
+
const { id, onClick, disabled, ...buttonProps } = action;
|
|
373
|
+
return /* @__PURE__ */ (0, import_react3.createElement)(
|
|
374
|
+
Button,
|
|
375
|
+
{
|
|
376
|
+
...buttonProps,
|
|
377
|
+
disabled,
|
|
378
|
+
key: id,
|
|
379
|
+
onClick: (event) => {
|
|
380
|
+
onClick?.(event);
|
|
381
|
+
if (shouldCloseMore && !disabled) setIsMoreOpen(false);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
);
|
|
385
|
+
};
|
|
386
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
387
|
+
"div",
|
|
388
|
+
{
|
|
389
|
+
...props,
|
|
390
|
+
className: ["fe-button-bar", className].filter(Boolean).join(" "),
|
|
391
|
+
ref: rootRef,
|
|
392
|
+
children: [
|
|
393
|
+
visibleActions.map((action) => renderAction(action)),
|
|
394
|
+
hasOverflow && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "fe-button-bar__more", children: [
|
|
395
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
396
|
+
Button,
|
|
397
|
+
{
|
|
398
|
+
hierarchy: "secondary-gray",
|
|
399
|
+
...moreButtonRestProps,
|
|
400
|
+
"aria-controls": moreMenuId,
|
|
401
|
+
"aria-expanded": isMoreOpen,
|
|
402
|
+
"aria-haspopup": "true",
|
|
403
|
+
"aria-label": moreAriaLabel ?? moreLabel,
|
|
404
|
+
disabled: moreDisabled,
|
|
405
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(MoreHorizontalIcon, {}),
|
|
406
|
+
iconOnly: true,
|
|
407
|
+
onClick: (event) => {
|
|
408
|
+
onMoreClick?.(event);
|
|
409
|
+
if (!event.defaultPrevented) setIsMoreOpen((open) => !open);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
),
|
|
413
|
+
isMoreOpen && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
414
|
+
"div",
|
|
415
|
+
{
|
|
416
|
+
"aria-label": moreLabel,
|
|
417
|
+
className: "fe-button-bar__menu",
|
|
418
|
+
id: moreMenuId,
|
|
419
|
+
role: "group",
|
|
420
|
+
children: overflowActions.map((action) => renderAction(action, true))
|
|
421
|
+
}
|
|
422
|
+
)
|
|
423
|
+
] })
|
|
424
|
+
]
|
|
425
|
+
}
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// packages/table/src/index.tsx
|
|
430
|
+
var import_react5 = require("react");
|
|
310
431
|
|
|
311
432
|
// packages/pagination/src/index.tsx
|
|
312
|
-
var
|
|
313
|
-
var
|
|
433
|
+
var import_react4 = require("react");
|
|
434
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
314
435
|
var clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
315
436
|
var range = (start, end) => Array.from({ length: Math.max(0, end - start + 1) }, (_, index) => start + index);
|
|
316
437
|
function getItems(totalPages, page, siblingCount, boundaryCount) {
|
|
@@ -342,9 +463,9 @@ function Pagination({
|
|
|
342
463
|
...props
|
|
343
464
|
}) {
|
|
344
465
|
const safeTotalPages = Math.max(1, Math.floor(totalPages));
|
|
345
|
-
const [uncontrolledPage, setUncontrolledPage] = (0,
|
|
466
|
+
const [uncontrolledPage, setUncontrolledPage] = (0, import_react4.useState)(() => clamp(defaultPage, 1, safeTotalPages));
|
|
346
467
|
const currentPage = clamp(page ?? uncontrolledPage, 1, safeTotalPages);
|
|
347
|
-
const items = (0,
|
|
468
|
+
const items = (0, import_react4.useMemo)(
|
|
348
469
|
() => getItems(safeTotalPages, currentPage, Math.max(0, siblingCount), Math.max(0, boundaryCount)),
|
|
349
470
|
[safeTotalPages, currentPage, siblingCount, boundaryCount]
|
|
350
471
|
);
|
|
@@ -353,9 +474,9 @@ function Pagination({
|
|
|
353
474
|
if (page === void 0) setUncontrolledPage(resolvedPage);
|
|
354
475
|
if (resolvedPage !== currentPage) onPageChange?.(resolvedPage);
|
|
355
476
|
};
|
|
356
|
-
return /* @__PURE__ */ (0,
|
|
357
|
-
/* @__PURE__ */ (0,
|
|
358
|
-
items.map((item, index) => item === "start-ellipsis" || item === "end-ellipsis" ? /* @__PURE__ */ (0,
|
|
477
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("nav", { className: ["fe-pagination", className].filter(Boolean).join(" "), "aria-label": "Pagination", ...props, children: [
|
|
478
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(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) }),
|
|
479
|
+
items.map((item, index) => item === "start-ellipsis" || item === "end-ellipsis" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "fe-pagination__ellipsis", "aria-hidden": "true", children: "\u2026" }, `${item}-${index}`) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
359
480
|
Button,
|
|
360
481
|
{
|
|
361
482
|
className: "fe-pagination__button",
|
|
@@ -369,13 +490,13 @@ function Pagination({
|
|
|
369
490
|
},
|
|
370
491
|
item
|
|
371
492
|
)),
|
|
372
|
-
/* @__PURE__ */ (0,
|
|
493
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(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) })
|
|
373
494
|
] });
|
|
374
495
|
}
|
|
375
496
|
|
|
376
497
|
// packages/table/src/index.tsx
|
|
377
|
-
var
|
|
378
|
-
var TableContext = (0,
|
|
498
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
499
|
+
var TableContext = (0, import_react5.createContext)({ striped: false });
|
|
379
500
|
var MIN_COLUMN_WIDTH = 96;
|
|
380
501
|
var MAX_COLUMN_WIDTH = 1200;
|
|
381
502
|
function getColumnCount(headers, data) {
|
|
@@ -384,7 +505,7 @@ function getColumnCount(headers, data) {
|
|
|
384
505
|
function getText(value) {
|
|
385
506
|
if (typeof value === "string" || typeof value === "number") return String(value);
|
|
386
507
|
if (Array.isArray(value)) return value.map(getText).join("");
|
|
387
|
-
if ((0,
|
|
508
|
+
if ((0, import_react5.isValidElement)(value)) return getText(value.props.children);
|
|
388
509
|
return "";
|
|
389
510
|
}
|
|
390
511
|
function autoColumnSize(columnIndex, headers, data) {
|
|
@@ -420,37 +541,37 @@ function DataTable({
|
|
|
420
541
|
}) {
|
|
421
542
|
const columnCount = getColumnCount(headers, data);
|
|
422
543
|
const safeMinWidth = Math.max(1, minColumnWidth);
|
|
423
|
-
const generatedSizes = (0,
|
|
544
|
+
const generatedSizes = (0, import_react5.useMemo)(
|
|
424
545
|
() => getInitialColumnSizes(headers, data, defaultColumnSizes, safeMinWidth),
|
|
425
546
|
[headers, data, defaultColumnSizes, safeMinWidth]
|
|
426
547
|
);
|
|
427
|
-
const [uncontrolledSizes, setUncontrolledSizes] = (0,
|
|
548
|
+
const [uncontrolledSizes, setUncontrolledSizes] = (0, import_react5.useState)(generatedSizes);
|
|
428
549
|
const shouldPaginate = pagination ?? pageSize !== void 0;
|
|
429
550
|
const safePageSize = Math.max(1, Math.floor(pageSize ?? 10));
|
|
430
551
|
const totalPages = Math.max(1, Math.ceil(data.length / safePageSize));
|
|
431
|
-
const [uncontrolledPage, setUncontrolledPage] = (0,
|
|
552
|
+
const [uncontrolledPage, setUncontrolledPage] = (0, import_react5.useState)(() => Math.min(Math.max(1, defaultPage), totalPages));
|
|
432
553
|
const currentPage = Math.min(Math.max(1, page ?? uncontrolledPage), totalPages);
|
|
433
554
|
const pagedData = shouldPaginate ? data.slice((currentPage - 1) * safePageSize, currentPage * safePageSize) : data;
|
|
434
|
-
const resizeState = (0,
|
|
435
|
-
const [isResizing, setIsResizing] = (0,
|
|
555
|
+
const resizeState = (0, import_react5.useRef)();
|
|
556
|
+
const [isResizing, setIsResizing] = (0, import_react5.useState)(false);
|
|
436
557
|
const sizes2 = columnSizes ? getInitialColumnSizes(headers, data, columnSizes, safeMinWidth).map((size) => Math.max(safeMinWidth, size)) : uncontrolledSizes.map((size) => Math.max(safeMinWidth, size));
|
|
437
|
-
(0,
|
|
558
|
+
(0, import_react5.useEffect)(() => {
|
|
438
559
|
if (columnSizes) return;
|
|
439
560
|
setUncontrolledSizes((currentSizes) => {
|
|
440
561
|
const nextSizes = generatedSizes.map((generatedSize, index) => currentSizes[index] ?? generatedSize);
|
|
441
562
|
return sameSizes(currentSizes, nextSizes) ? currentSizes : nextSizes;
|
|
442
563
|
});
|
|
443
564
|
}, [columnSizes, generatedSizes]);
|
|
444
|
-
(0,
|
|
565
|
+
(0, import_react5.useEffect)(() => {
|
|
445
566
|
if (page === void 0 && uncontrolledPage > totalPages) setUncontrolledPage(totalPages);
|
|
446
567
|
}, [page, totalPages, uncontrolledPage]);
|
|
447
|
-
const updateColumnSize = (0,
|
|
568
|
+
const updateColumnSize = (0, import_react5.useCallback)((columnIndex, nextSize) => {
|
|
448
569
|
const clampedSize = Math.min(MAX_COLUMN_WIDTH, Math.max(safeMinWidth, Math.round(nextSize)));
|
|
449
570
|
const nextSizes = sizes2.map((size, index) => index === columnIndex ? clampedSize : size);
|
|
450
571
|
if (!columnSizes) setUncontrolledSizes(nextSizes);
|
|
451
572
|
onColumnResize?.(nextSizes, columnIndex);
|
|
452
573
|
}, [columnSizes, onColumnResize, safeMinWidth, sizes2]);
|
|
453
|
-
(0,
|
|
574
|
+
(0, import_react5.useEffect)(() => {
|
|
454
575
|
const onPointerMove = (event) => {
|
|
455
576
|
const activeResize = resizeState.current;
|
|
456
577
|
if (!activeResize) return;
|
|
@@ -474,14 +595,14 @@ function DataTable({
|
|
|
474
595
|
if (nextPage !== currentPage) onPageChange?.(nextPage);
|
|
475
596
|
};
|
|
476
597
|
const resolvedPaginationPosition = paginationPosition === "middle-bottom" ? "bottom-center" : paginationPosition;
|
|
477
|
-
const paginationControl = shouldPaginate && totalPages > 1 ? /* @__PURE__ */ (0,
|
|
478
|
-
return /* @__PURE__ */ (0,
|
|
598
|
+
const paginationControl = shouldPaginate && totalPages > 1 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `fe-table__pagination fe-table__pagination--${resolvedPaginationPosition}`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Pagination, { page: currentPage, totalPages, onPageChange: changePage }) }) : null;
|
|
599
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "fe-table", "data-resizing": isResizing || void 0, children: [
|
|
479
600
|
resolvedPaginationPosition === "top-right" && paginationControl,
|
|
480
|
-
/* @__PURE__ */ (0,
|
|
481
|
-
/* @__PURE__ */ (0,
|
|
482
|
-
/* @__PURE__ */ (0,
|
|
483
|
-
/* @__PURE__ */ (0,
|
|
484
|
-
/* @__PURE__ */ (0,
|
|
601
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("table", { className: ["fe-table__table", className].filter(Boolean).join(" "), "data-fe-table": true, "data-striped": striped || void 0, ...props, children: [
|
|
602
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("colgroup", { children: sizes2.map((size, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("col", { style: { width: `${size}px` } }, index)) }),
|
|
603
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("tr", { children: Array.from({ length: columnCount }, (_, columnIndex) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("th", { scope: "col", children: [
|
|
604
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "fe-table__header-content", children: headers[columnIndex] ?? `Column ${columnIndex + 1}` }),
|
|
605
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
485
606
|
"span",
|
|
486
607
|
{
|
|
487
608
|
className: "fe-table__resize-handle",
|
|
@@ -505,7 +626,7 @@ function DataTable({
|
|
|
505
626
|
}
|
|
506
627
|
)
|
|
507
628
|
] }, columnIndex)) }) }),
|
|
508
|
-
/* @__PURE__ */ (0,
|
|
629
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("tbody", { children: pagedData.map((row, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("tr", { children: Array.from({ length: columnCount }, (_, columnIndex) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("td", { children: row[columnIndex] }, columnIndex)) }, shouldPaginate ? (currentPage - 1) * safePageSize + rowIndex : rowIndex)) })
|
|
509
630
|
] }),
|
|
510
631
|
resolvedPaginationPosition !== "top-right" && paginationControl
|
|
511
632
|
] });
|
|
@@ -523,33 +644,33 @@ function Table({
|
|
|
523
644
|
paginationPosition,
|
|
524
645
|
...props
|
|
525
646
|
}) {
|
|
526
|
-
if (headers || data) return /* @__PURE__ */ (0,
|
|
527
|
-
return /* @__PURE__ */ (0,
|
|
647
|
+
if (headers || data) return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DataTable, { headers: headers ?? [], data: data ?? [], striped: striped ?? true, pagination, pageSize, page, defaultPage, onPageChange, paginationPosition, ...props });
|
|
648
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TableContext.Provider, { value: { striped: striped ?? false }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("table", { "data-fe-table": true, "data-striped": striped || void 0, ...props, children }) });
|
|
528
649
|
}
|
|
529
650
|
function TableHead(props) {
|
|
530
|
-
return /* @__PURE__ */ (0,
|
|
651
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("thead", { ...props });
|
|
531
652
|
}
|
|
532
653
|
function TableBody(props) {
|
|
533
|
-
return /* @__PURE__ */ (0,
|
|
654
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("tbody", { ...props });
|
|
534
655
|
}
|
|
535
656
|
function TableRow({ children, ...props }) {
|
|
536
|
-
const { striped } = (0,
|
|
537
|
-
return /* @__PURE__ */ (0,
|
|
657
|
+
const { striped } = (0, import_react5.useContext)(TableContext);
|
|
658
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("tr", { "data-striped": striped || void 0, ...props, children });
|
|
538
659
|
}
|
|
539
660
|
function TableCell({ children, ...props }) {
|
|
540
|
-
return /* @__PURE__ */ (0,
|
|
661
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("td", { ...props, children });
|
|
541
662
|
}
|
|
542
663
|
function TableHeader({ children, ...props }) {
|
|
543
|
-
return /* @__PURE__ */ (0,
|
|
664
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("th", { scope: "col", ...props, children });
|
|
544
665
|
}
|
|
545
666
|
function TableCaption(props) {
|
|
546
|
-
return /* @__PURE__ */ (0,
|
|
667
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("caption", { ...props });
|
|
547
668
|
}
|
|
548
669
|
|
|
549
670
|
// packages/toggle/src/index.tsx
|
|
550
|
-
var
|
|
551
|
-
var
|
|
552
|
-
var Toggle = (0,
|
|
671
|
+
var import_react6 = require("react");
|
|
672
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
673
|
+
var Toggle = (0, import_react6.forwardRef)(function Toggle2({
|
|
553
674
|
color = "#16a34a",
|
|
554
675
|
label,
|
|
555
676
|
labelPosition = "right",
|
|
@@ -563,9 +684,9 @@ var Toggle = (0, import_react4.forwardRef)(function Toggle2({
|
|
|
563
684
|
"--fe-toggle-color": color,
|
|
564
685
|
...style
|
|
565
686
|
};
|
|
566
|
-
return /* @__PURE__ */ (0,
|
|
567
|
-
label && labelPosition === "top" && /* @__PURE__ */ (0,
|
|
568
|
-
/* @__PURE__ */ (0,
|
|
687
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("label", { className: classes, style: toggleStyle, children: [
|
|
688
|
+
label && labelPosition === "top" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "fe-toggle__label", children: label }),
|
|
689
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
569
690
|
"input",
|
|
570
691
|
{
|
|
571
692
|
ref,
|
|
@@ -576,18 +697,18 @@ var Toggle = (0, import_react4.forwardRef)(function Toggle2({
|
|
|
576
697
|
...props
|
|
577
698
|
}
|
|
578
699
|
),
|
|
579
|
-
/* @__PURE__ */ (0,
|
|
580
|
-
label && labelPosition === "right" && /* @__PURE__ */ (0,
|
|
700
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "fe-toggle__control", "aria-hidden": "true" }),
|
|
701
|
+
label && labelPosition === "right" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "fe-toggle__label", children: label })
|
|
581
702
|
] });
|
|
582
703
|
});
|
|
583
704
|
Toggle.displayName = "Toggle";
|
|
584
705
|
|
|
585
706
|
// packages/drawer/src/index.tsx
|
|
586
|
-
var
|
|
707
|
+
var import_react7 = require("react");
|
|
587
708
|
var import_react_dom = require("react-dom");
|
|
588
|
-
var
|
|
709
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
589
710
|
function Drawer({ open, onClose, title, footer, side = "right", width = 400, fullScreen = false, children, closeOnBackdropClick = true, className, style, ...props }) {
|
|
590
|
-
(0,
|
|
711
|
+
(0, import_react7.useEffect)(() => {
|
|
591
712
|
if (!open) return;
|
|
592
713
|
const onKeyDown = (event) => {
|
|
593
714
|
if (event.key === "Escape") onClose();
|
|
@@ -597,28 +718,28 @@ function Drawer({ open, onClose, title, footer, side = "right", width = 400, ful
|
|
|
597
718
|
}, [onClose, open]);
|
|
598
719
|
if (!open || typeof document === "undefined") return null;
|
|
599
720
|
const panelStyle = !fullScreen && (side === "left" || side === "right") ? { ...style, width: typeof width === "number" ? `${width}px` : width } : style;
|
|
600
|
-
return (0, import_react_dom.createPortal)(/* @__PURE__ */ (0,
|
|
721
|
+
return (0, import_react_dom.createPortal)(/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "fe-drawer-backdrop", role: "presentation", onMouseDown: (event) => {
|
|
601
722
|
if (event.target === event.currentTarget && closeOnBackdropClick) onClose();
|
|
602
|
-
}, children: /* @__PURE__ */ (0,
|
|
603
|
-
/* @__PURE__ */ (0,
|
|
604
|
-
title && /* @__PURE__ */ (0,
|
|
605
|
-
/* @__PURE__ */ (0,
|
|
723
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("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: [
|
|
724
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("header", { className: "fe-drawer__header", children: [
|
|
725
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h2", { children: title }),
|
|
726
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("button", { type: "button", "aria-label": "Close drawer", onClick: onClose, children: "\xD7" })
|
|
606
727
|
] }),
|
|
607
|
-
/* @__PURE__ */ (0,
|
|
608
|
-
footer && /* @__PURE__ */ (0,
|
|
728
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { className: "fe-drawer__body", children }),
|
|
729
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("footer", { className: "fe-drawer__footer", children: footer })
|
|
609
730
|
] }) }), document.body);
|
|
610
731
|
}
|
|
611
732
|
|
|
612
733
|
// packages/form-controls/src/controls/TextInput/text-input.tsx
|
|
613
|
-
var
|
|
734
|
+
var import_react9 = require("react");
|
|
614
735
|
|
|
615
736
|
// packages/tooltip/src/index.tsx
|
|
616
|
-
var
|
|
617
|
-
var
|
|
737
|
+
var import_react8 = require("react");
|
|
738
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
618
739
|
function Tooltip({ content, children, placement = "top", disabled, className, ...props }) {
|
|
619
|
-
const [visible, setVisible] = (0,
|
|
620
|
-
const id = (0,
|
|
621
|
-
const trigger = (0,
|
|
740
|
+
const [visible, setVisible] = (0, import_react8.useState)(false);
|
|
741
|
+
const id = (0, import_react8.useId)();
|
|
742
|
+
const trigger = (0, import_react8.cloneElement)(children, { "aria-describedby": visible ? id : void 0, onMouseEnter: (event) => {
|
|
622
743
|
children.props.onMouseEnter?.(event);
|
|
623
744
|
setVisible(true);
|
|
624
745
|
}, onMouseLeave: (event) => {
|
|
@@ -631,14 +752,14 @@ function Tooltip({ content, children, placement = "top", disabled, className, ..
|
|
|
631
752
|
children.props.onBlur?.(event);
|
|
632
753
|
setVisible(false);
|
|
633
754
|
} });
|
|
634
|
-
return /* @__PURE__ */ (0,
|
|
755
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("span", { className: ["fe-tooltip", `fe-tooltip--${placement}`, className].filter(Boolean).join(" "), ...props, children: [
|
|
635
756
|
trigger,
|
|
636
|
-
visible && !disabled && /* @__PURE__ */ (0,
|
|
757
|
+
visible && !disabled && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("span", { id, role: "tooltip", className: "fe-tooltip__content", children: content })
|
|
637
758
|
] });
|
|
638
759
|
}
|
|
639
760
|
|
|
640
761
|
// packages/form-controls/src/controls/Field/field.tsx
|
|
641
|
-
var
|
|
762
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
642
763
|
function getFieldError(error, errorMessage) {
|
|
643
764
|
if (errorMessage !== void 0 && errorMessage !== null) return errorMessage;
|
|
644
765
|
if (typeof error !== "boolean") return error;
|
|
@@ -655,10 +776,10 @@ function FieldLabel({
|
|
|
655
776
|
isRequired = false
|
|
656
777
|
}) {
|
|
657
778
|
if (!label) return null;
|
|
658
|
-
return /* @__PURE__ */ (0,
|
|
659
|
-
/* @__PURE__ */ (0,
|
|
660
|
-
isRequired && /* @__PURE__ */ (0,
|
|
661
|
-
description && descriptionDisplay === "tooltip" && /* @__PURE__ */ (0,
|
|
779
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("span", { className: "fe-field__label", children: [
|
|
780
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { id, children: label }),
|
|
781
|
+
isRequired && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "fe-field__required", "aria-hidden": "true", children: "*" }),
|
|
782
|
+
description && descriptionDisplay === "tooltip" && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Tooltip, { content: description, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
662
783
|
"span",
|
|
663
784
|
{
|
|
664
785
|
className: "fe-field__info",
|
|
@@ -677,7 +798,7 @@ function FieldMessage({
|
|
|
677
798
|
descriptionDisplay
|
|
678
799
|
}) {
|
|
679
800
|
if (error !== void 0 && error !== false && error !== null)
|
|
680
|
-
return /* @__PURE__ */ (0,
|
|
801
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
681
802
|
"span",
|
|
682
803
|
{
|
|
683
804
|
id,
|
|
@@ -687,13 +808,13 @@ function FieldMessage({
|
|
|
687
808
|
}
|
|
688
809
|
);
|
|
689
810
|
if (description && descriptionDisplay === "inline")
|
|
690
|
-
return /* @__PURE__ */ (0,
|
|
811
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { id, className: "fe-field__message", children: description });
|
|
691
812
|
return null;
|
|
692
813
|
}
|
|
693
814
|
|
|
694
815
|
// packages/form-controls/src/controls/TextInput/text-input.tsx
|
|
695
|
-
var
|
|
696
|
-
var TextInput = (0,
|
|
816
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
817
|
+
var TextInput = (0, import_react9.forwardRef)(
|
|
697
818
|
function TextInput2({
|
|
698
819
|
value,
|
|
699
820
|
defaultValue = "",
|
|
@@ -723,12 +844,12 @@ var TextInput = (0, import_react7.forwardRef)(
|
|
|
723
844
|
"aria-labelledby": ariaLabelledBy,
|
|
724
845
|
...props
|
|
725
846
|
}, ref) {
|
|
726
|
-
const generatedId = (0,
|
|
847
|
+
const generatedId = (0, import_react9.useId)();
|
|
727
848
|
const inputId = id ?? generatedId + "-input";
|
|
728
849
|
const labelId = generatedId + "-label";
|
|
729
850
|
const messageId2 = generatedId + "-message";
|
|
730
851
|
const controlled = value !== void 0;
|
|
731
|
-
const [internalValue, setInternalValue] = (0,
|
|
852
|
+
const [internalValue, setInternalValue] = (0, import_react9.useState)(defaultValue);
|
|
732
853
|
const currentValue = controlled ? value : internalValue;
|
|
733
854
|
const fieldError = getFieldError(error, errorMessage);
|
|
734
855
|
const hasError = fieldError !== void 0 && fieldError !== false && fieldError !== null;
|
|
@@ -749,7 +870,7 @@ var TextInput = (0, import_react7.forwardRef)(
|
|
|
749
870
|
onValueChange?.("");
|
|
750
871
|
onClear?.();
|
|
751
872
|
};
|
|
752
|
-
return /* @__PURE__ */ (0,
|
|
873
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
753
874
|
"div",
|
|
754
875
|
{
|
|
755
876
|
className: [
|
|
@@ -758,7 +879,7 @@ var TextInput = (0, import_react7.forwardRef)(
|
|
|
758
879
|
className
|
|
759
880
|
].filter(Boolean).join(" "),
|
|
760
881
|
children: [
|
|
761
|
-
/* @__PURE__ */ (0,
|
|
882
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
762
883
|
FieldLabel,
|
|
763
884
|
{
|
|
764
885
|
id: labelId,
|
|
@@ -768,10 +889,10 @@ var TextInput = (0, import_react7.forwardRef)(
|
|
|
768
889
|
isRequired
|
|
769
890
|
}
|
|
770
891
|
),
|
|
771
|
-
/* @__PURE__ */ (0,
|
|
772
|
-
resolvedPrefix && /* @__PURE__ */ (0,
|
|
773
|
-
/* @__PURE__ */ (0,
|
|
774
|
-
/* @__PURE__ */ (0,
|
|
892
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "fe-text-input__control", children: [
|
|
893
|
+
resolvedPrefix && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "fe-text-input__prefix", children: resolvedPrefix }),
|
|
894
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "fe-text-input__input-wrap", children: [
|
|
895
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
775
896
|
"input",
|
|
776
897
|
{
|
|
777
898
|
ref,
|
|
@@ -793,26 +914,26 @@ var TextInput = (0, import_react7.forwardRef)(
|
|
|
793
914
|
...props
|
|
794
915
|
}
|
|
795
916
|
),
|
|
796
|
-
isRequired && placeholder && !currentValue && /* @__PURE__ */ (0,
|
|
797
|
-
/* @__PURE__ */ (0,
|
|
798
|
-
/* @__PURE__ */ (0,
|
|
917
|
+
isRequired && placeholder && !currentValue && /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("span", { className: "fe-text-input__placeholder", "aria-hidden": "true", children: [
|
|
918
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { children: placeholder }),
|
|
919
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "fe-field__required", children: "*" })
|
|
799
920
|
] })
|
|
800
921
|
] }),
|
|
801
|
-
resolvedSuffix && /* @__PURE__ */ (0,
|
|
802
|
-
clearable && currentValue && !disabled && !readOnly && /* @__PURE__ */ (0,
|
|
922
|
+
resolvedSuffix && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "fe-text-input__suffix", children: resolvedSuffix }),
|
|
923
|
+
clearable && currentValue && !disabled && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
803
924
|
Button,
|
|
804
925
|
{
|
|
805
926
|
hierarchy: "tertiary-gray",
|
|
806
927
|
size: "24",
|
|
807
928
|
iconOnly: true,
|
|
808
|
-
icon: /* @__PURE__ */ (0,
|
|
929
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(CloseIcon, { size: 14 }),
|
|
809
930
|
"aria-label": clearLabel,
|
|
810
931
|
onClick: clear,
|
|
811
932
|
className: "fe-text-input__clear"
|
|
812
933
|
}
|
|
813
934
|
)
|
|
814
935
|
] }),
|
|
815
|
-
/* @__PURE__ */ (0,
|
|
936
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
816
937
|
FieldMessage,
|
|
817
938
|
{
|
|
818
939
|
id: messageId2,
|
|
@@ -829,9 +950,9 @@ var TextInput = (0, import_react7.forwardRef)(
|
|
|
829
950
|
TextInput.displayName = "TextInput";
|
|
830
951
|
|
|
831
952
|
// packages/form-controls/src/controls/TextArea/text-area.tsx
|
|
832
|
-
var
|
|
833
|
-
var
|
|
834
|
-
var TextArea = (0,
|
|
953
|
+
var import_react10 = require("react");
|
|
954
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
955
|
+
var TextArea = (0, import_react10.forwardRef)(
|
|
835
956
|
function TextArea2({
|
|
836
957
|
value,
|
|
837
958
|
defaultValue = "",
|
|
@@ -858,13 +979,13 @@ var TextArea = (0, import_react8.forwardRef)(
|
|
|
858
979
|
"aria-labelledby": ariaLabelledBy,
|
|
859
980
|
...props
|
|
860
981
|
}, ref) {
|
|
861
|
-
const generatedId = (0,
|
|
982
|
+
const generatedId = (0, import_react10.useId)();
|
|
862
983
|
const inputId = id ?? generatedId + "-input";
|
|
863
984
|
const labelId = generatedId + "-label";
|
|
864
985
|
const messageId2 = generatedId + "-message";
|
|
865
986
|
const controlled = value !== void 0;
|
|
866
|
-
const [internalValue, setInternalValue] = (0,
|
|
867
|
-
const textareaRef = (0,
|
|
987
|
+
const [internalValue, setInternalValue] = (0, import_react10.useState)(defaultValue);
|
|
988
|
+
const textareaRef = (0, import_react10.useRef)(null);
|
|
868
989
|
const currentValue = controlled ? value : internalValue;
|
|
869
990
|
const fieldError = getFieldError(error, errorMessage);
|
|
870
991
|
const hasError = fieldError !== void 0 && fieldError !== false && fieldError !== null;
|
|
@@ -882,8 +1003,8 @@ var TextArea = (0, import_react8.forwardRef)(
|
|
|
882
1003
|
textarea.style.height = "auto";
|
|
883
1004
|
textarea.style.height = `${textarea.scrollHeight}px`;
|
|
884
1005
|
};
|
|
885
|
-
(0,
|
|
886
|
-
(0,
|
|
1006
|
+
(0, import_react10.useImperativeHandle)(ref, () => textareaRef.current, []);
|
|
1007
|
+
(0, import_react10.useLayoutEffect)(() => {
|
|
887
1008
|
if (autosize && textareaRef.current) {
|
|
888
1009
|
resizeToContent(textareaRef.current);
|
|
889
1010
|
}
|
|
@@ -893,7 +1014,7 @@ var TextArea = (0, import_react8.forwardRef)(
|
|
|
893
1014
|
onValueChange?.("");
|
|
894
1015
|
onClear?.();
|
|
895
1016
|
};
|
|
896
|
-
return /* @__PURE__ */ (0,
|
|
1017
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
897
1018
|
"div",
|
|
898
1019
|
{
|
|
899
1020
|
className: [
|
|
@@ -903,7 +1024,7 @@ var TextArea = (0, import_react8.forwardRef)(
|
|
|
903
1024
|
className
|
|
904
1025
|
].filter(Boolean).join(" "),
|
|
905
1026
|
children: [
|
|
906
|
-
/* @__PURE__ */ (0,
|
|
1027
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
907
1028
|
FieldLabel,
|
|
908
1029
|
{
|
|
909
1030
|
id: labelId,
|
|
@@ -913,8 +1034,8 @@ var TextArea = (0, import_react8.forwardRef)(
|
|
|
913
1034
|
isRequired
|
|
914
1035
|
}
|
|
915
1036
|
),
|
|
916
|
-
/* @__PURE__ */ (0,
|
|
917
|
-
/* @__PURE__ */ (0,
|
|
1037
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "fe-text-area__control", children: [
|
|
1038
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
918
1039
|
"textarea",
|
|
919
1040
|
{
|
|
920
1041
|
ref: textareaRef,
|
|
@@ -937,24 +1058,24 @@ var TextArea = (0, import_react8.forwardRef)(
|
|
|
937
1058
|
...props
|
|
938
1059
|
}
|
|
939
1060
|
),
|
|
940
|
-
isRequired && placeholder && !currentValue && /* @__PURE__ */ (0,
|
|
941
|
-
/* @__PURE__ */ (0,
|
|
942
|
-
/* @__PURE__ */ (0,
|
|
1061
|
+
isRequired && placeholder && !currentValue && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("span", { className: "fe-text-area__placeholder", "aria-hidden": "true", children: [
|
|
1062
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { children: placeholder }),
|
|
1063
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "fe-field__required", children: "*" })
|
|
943
1064
|
] }),
|
|
944
|
-
clearable && currentValue && !disabled && !readOnly && /* @__PURE__ */ (0,
|
|
1065
|
+
clearable && currentValue && !disabled && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
945
1066
|
Button,
|
|
946
1067
|
{
|
|
947
1068
|
hierarchy: "tertiary-gray",
|
|
948
1069
|
size: "24",
|
|
949
1070
|
iconOnly: true,
|
|
950
|
-
icon: /* @__PURE__ */ (0,
|
|
1071
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(CloseIcon, { size: 14 }),
|
|
951
1072
|
"aria-label": clearLabel,
|
|
952
1073
|
onClick: clear,
|
|
953
1074
|
className: "fe-text-area__clear"
|
|
954
1075
|
}
|
|
955
1076
|
)
|
|
956
1077
|
] }),
|
|
957
|
-
/* @__PURE__ */ (0,
|
|
1078
|
+
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
958
1079
|
FieldMessage,
|
|
959
1080
|
{
|
|
960
1081
|
id: messageId2,
|
|
@@ -971,10 +1092,10 @@ var TextArea = (0, import_react8.forwardRef)(
|
|
|
971
1092
|
TextArea.displayName = "TextArea";
|
|
972
1093
|
|
|
973
1094
|
// packages/form-controls/src/controls/Selection/selection.tsx
|
|
974
|
-
var
|
|
1095
|
+
var import_react11 = require("react");
|
|
975
1096
|
var import_react_dom2 = require("react-dom");
|
|
976
|
-
var
|
|
977
|
-
var Selection = (0,
|
|
1097
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1098
|
+
var Selection = (0, import_react11.forwardRef)(
|
|
978
1099
|
function Selection2({
|
|
979
1100
|
className,
|
|
980
1101
|
label,
|
|
@@ -1003,7 +1124,7 @@ var Selection = (0, import_react9.forwardRef)(
|
|
|
1003
1124
|
"aria-labelledby": ariaLabelledBy,
|
|
1004
1125
|
...props
|
|
1005
1126
|
}, ref) {
|
|
1006
|
-
const generatedId = (0,
|
|
1127
|
+
const generatedId = (0, import_react11.useId)();
|
|
1007
1128
|
const triggerId = id ?? generatedId + "-trigger";
|
|
1008
1129
|
const listboxId = triggerId + "-listbox";
|
|
1009
1130
|
const labelId = generatedId + "-label";
|
|
@@ -1021,7 +1142,7 @@ var Selection = (0, import_react9.forwardRef)(
|
|
|
1021
1142
|
label ? labelId : void 0
|
|
1022
1143
|
);
|
|
1023
1144
|
const isControlled = value !== void 0;
|
|
1024
|
-
const [internalValue, setInternalValue] = (0,
|
|
1145
|
+
const [internalValue, setInternalValue] = (0, import_react11.useState)(
|
|
1025
1146
|
defaultValue ?? (multiple ? [] : "")
|
|
1026
1147
|
);
|
|
1027
1148
|
const selectedValue = isControlled ? value : internalValue;
|
|
@@ -1029,13 +1150,13 @@ var Selection = (0, import_react9.forwardRef)(
|
|
|
1029
1150
|
const selectedOptions = options.filter(
|
|
1030
1151
|
(option) => selectedValues.some((item) => String(item) === String(option.value))
|
|
1031
1152
|
);
|
|
1032
|
-
const [open, setOpen] = (0,
|
|
1033
|
-
const [query, setQuery] = (0,
|
|
1034
|
-
const [activeIndex, setActiveIndex] = (0,
|
|
1035
|
-
const rootRef = (0,
|
|
1036
|
-
const menuRef = (0,
|
|
1037
|
-
const [menuPosition, setMenuPosition] = (0,
|
|
1038
|
-
(0,
|
|
1153
|
+
const [open, setOpen] = (0, import_react11.useState)(false);
|
|
1154
|
+
const [query, setQuery] = (0, import_react11.useState)("");
|
|
1155
|
+
const [activeIndex, setActiveIndex] = (0, import_react11.useState)(0);
|
|
1156
|
+
const rootRef = (0, import_react11.useRef)(null);
|
|
1157
|
+
const menuRef = (0, import_react11.useRef)(null);
|
|
1158
|
+
const [menuPosition, setMenuPosition] = (0, import_react11.useState)(null);
|
|
1159
|
+
(0, import_react11.useEffect)(() => {
|
|
1039
1160
|
const close = (event) => {
|
|
1040
1161
|
const target = event.target;
|
|
1041
1162
|
if (!rootRef.current?.contains(target) && !menuRef.current?.contains(target))
|
|
@@ -1044,7 +1165,7 @@ var Selection = (0, import_react9.forwardRef)(
|
|
|
1044
1165
|
document.addEventListener("mousedown", close);
|
|
1045
1166
|
return () => document.removeEventListener("mousedown", close);
|
|
1046
1167
|
}, []);
|
|
1047
|
-
(0,
|
|
1168
|
+
(0, import_react11.useLayoutEffect)(() => {
|
|
1048
1169
|
if (!open) return;
|
|
1049
1170
|
const updateMenuPosition = () => {
|
|
1050
1171
|
const rect = rootRef.current?.getBoundingClientRect();
|
|
@@ -1121,7 +1242,7 @@ var Selection = (0, import_react9.forwardRef)(
|
|
|
1121
1242
|
}
|
|
1122
1243
|
if (event.key === "Escape") setOpen(false);
|
|
1123
1244
|
};
|
|
1124
|
-
return /* @__PURE__ */ (0,
|
|
1245
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1125
1246
|
"div",
|
|
1126
1247
|
{
|
|
1127
1248
|
ref,
|
|
@@ -1136,7 +1257,7 @@ var Selection = (0, import_react9.forwardRef)(
|
|
|
1136
1257
|
].filter(Boolean).join(" "),
|
|
1137
1258
|
...props,
|
|
1138
1259
|
children: [
|
|
1139
|
-
/* @__PURE__ */ (0,
|
|
1260
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1140
1261
|
FieldLabel,
|
|
1141
1262
|
{
|
|
1142
1263
|
id: labelId,
|
|
@@ -1146,8 +1267,8 @@ var Selection = (0, import_react9.forwardRef)(
|
|
|
1146
1267
|
isRequired
|
|
1147
1268
|
}
|
|
1148
1269
|
),
|
|
1149
|
-
/* @__PURE__ */ (0,
|
|
1150
|
-
name && selectedValues.map((item) => /* @__PURE__ */ (0,
|
|
1270
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { ref: rootRef, className: "fe-selection__control", children: [
|
|
1271
|
+
name && selectedValues.map((item) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1151
1272
|
"input",
|
|
1152
1273
|
{
|
|
1153
1274
|
type: "hidden",
|
|
@@ -1156,7 +1277,7 @@ var Selection = (0, import_react9.forwardRef)(
|
|
|
1156
1277
|
},
|
|
1157
1278
|
String(item)
|
|
1158
1279
|
)),
|
|
1159
|
-
/* @__PURE__ */ (0,
|
|
1280
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1160
1281
|
"button",
|
|
1161
1282
|
{
|
|
1162
1283
|
id: triggerId,
|
|
@@ -1174,7 +1295,7 @@ var Selection = (0, import_react9.forwardRef)(
|
|
|
1174
1295
|
onClick: () => setOpen((current) => !current),
|
|
1175
1296
|
onKeyDown: onTriggerKeyDown,
|
|
1176
1297
|
children: [
|
|
1177
|
-
/* @__PURE__ */ (0,
|
|
1298
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1178
1299
|
"span",
|
|
1179
1300
|
{
|
|
1180
1301
|
className: [
|
|
@@ -1182,30 +1303,30 @@ var Selection = (0, import_react9.forwardRef)(
|
|
|
1182
1303
|
!selectedOptions.length && "is-placeholder",
|
|
1183
1304
|
tag && selectedOptions.length > 1 && "is-tags"
|
|
1184
1305
|
].filter(Boolean).join(" "),
|
|
1185
|
-
children: displayLabel ? tag && multiple ? selectedOptions.map((option) => /* @__PURE__ */ (0,
|
|
1306
|
+
children: displayLabel ? tag && multiple ? selectedOptions.map((option) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1186
1307
|
"span",
|
|
1187
1308
|
{
|
|
1188
1309
|
className: "fe-selection__tag",
|
|
1189
1310
|
children: [
|
|
1190
1311
|
option.label,
|
|
1191
|
-
/* @__PURE__ */ (0,
|
|
1312
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { "aria-hidden": "true", children: "\xD7" })
|
|
1192
1313
|
]
|
|
1193
1314
|
},
|
|
1194
1315
|
String(option.value)
|
|
1195
|
-
)) : displayLabel.map((item, index) => /* @__PURE__ */ (0,
|
|
1316
|
+
)) : displayLabel.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("span", { children: [
|
|
1196
1317
|
item,
|
|
1197
1318
|
index < displayLabel.length - 1 ? ", " : ""
|
|
1198
|
-
] }, index)) : /* @__PURE__ */ (0,
|
|
1199
|
-
/* @__PURE__ */ (0,
|
|
1200
|
-
isRequired && /* @__PURE__ */ (0,
|
|
1319
|
+
] }, index)) : /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
1320
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: placeholder }),
|
|
1321
|
+
isRequired && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "fe-field__required", "aria-hidden": "true", children: "*" })
|
|
1201
1322
|
] })
|
|
1202
1323
|
}
|
|
1203
1324
|
),
|
|
1204
|
-
/* @__PURE__ */ (0,
|
|
1325
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "fe-selection__actions", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "fe-selection__chevron", "aria-hidden": "true" }) })
|
|
1205
1326
|
]
|
|
1206
1327
|
}
|
|
1207
1328
|
),
|
|
1208
|
-
clearable && selectedOptions.length > 0 && !disabled && /* @__PURE__ */ (0,
|
|
1329
|
+
clearable && selectedOptions.length > 0 && !disabled && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1209
1330
|
"button",
|
|
1210
1331
|
{
|
|
1211
1332
|
type: "button",
|
|
@@ -1215,7 +1336,7 @@ var Selection = (0, import_react9.forwardRef)(
|
|
|
1215
1336
|
}
|
|
1216
1337
|
),
|
|
1217
1338
|
open && menuPosition && (0, import_react_dom2.createPortal)(
|
|
1218
|
-
/* @__PURE__ */ (0,
|
|
1339
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1219
1340
|
"div",
|
|
1220
1341
|
{
|
|
1221
1342
|
ref: menuRef,
|
|
@@ -1230,9 +1351,9 @@ var Selection = (0, import_react9.forwardRef)(
|
|
|
1230
1351
|
role: "listbox",
|
|
1231
1352
|
"aria-multiselectable": multiple || void 0,
|
|
1232
1353
|
children: [
|
|
1233
|
-
searchable && /* @__PURE__ */ (0,
|
|
1234
|
-
/* @__PURE__ */ (0,
|
|
1235
|
-
/* @__PURE__ */ (0,
|
|
1354
|
+
searchable && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "fe-selection__search", children: [
|
|
1355
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { "aria-hidden": "true", children: "\u2315" }),
|
|
1356
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1236
1357
|
"input",
|
|
1237
1358
|
{
|
|
1238
1359
|
autoFocus: true,
|
|
@@ -1246,11 +1367,11 @@ var Selection = (0, import_react9.forwardRef)(
|
|
|
1246
1367
|
}
|
|
1247
1368
|
)
|
|
1248
1369
|
] }),
|
|
1249
|
-
/* @__PURE__ */ (0,
|
|
1370
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "fe-selection__options", children: filteredOptions.length ? filteredOptions.map((option, index) => {
|
|
1250
1371
|
const isSelected = selectedValues.some(
|
|
1251
1372
|
(item) => String(item) === String(option.value)
|
|
1252
1373
|
);
|
|
1253
|
-
return /* @__PURE__ */ (0,
|
|
1374
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1254
1375
|
"button",
|
|
1255
1376
|
{
|
|
1256
1377
|
type: "button",
|
|
@@ -1264,8 +1385,8 @@ var Selection = (0, import_react9.forwardRef)(
|
|
|
1264
1385
|
onMouseMove: () => setActiveIndex(index),
|
|
1265
1386
|
onClick: () => choose(option),
|
|
1266
1387
|
children: [
|
|
1267
|
-
/* @__PURE__ */ (0,
|
|
1268
|
-
isSelected && /* @__PURE__ */ (0,
|
|
1388
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { children: option.label }),
|
|
1389
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1269
1390
|
"span",
|
|
1270
1391
|
{
|
|
1271
1392
|
className: "fe-selection__check",
|
|
@@ -1277,14 +1398,14 @@ var Selection = (0, import_react9.forwardRef)(
|
|
|
1277
1398
|
},
|
|
1278
1399
|
String(option.value)
|
|
1279
1400
|
);
|
|
1280
|
-
}) : /* @__PURE__ */ (0,
|
|
1401
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "fe-selection__empty", children: "No matching options" }) })
|
|
1281
1402
|
]
|
|
1282
1403
|
}
|
|
1283
1404
|
),
|
|
1284
1405
|
document.body
|
|
1285
1406
|
)
|
|
1286
1407
|
] }),
|
|
1287
|
-
/* @__PURE__ */ (0,
|
|
1408
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1288
1409
|
FieldMessage,
|
|
1289
1410
|
{
|
|
1290
1411
|
id: messageId2,
|
|
@@ -1301,8 +1422,8 @@ var Selection = (0, import_react9.forwardRef)(
|
|
|
1301
1422
|
Selection.displayName = "Selection";
|
|
1302
1423
|
|
|
1303
1424
|
// packages/form-controls/src/controls/NumberInput/number-input.tsx
|
|
1304
|
-
var
|
|
1305
|
-
var
|
|
1425
|
+
var import_react12 = require("react");
|
|
1426
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1306
1427
|
function formatNumber(value, decimals = 2, thousandSeparator = ",", decimalSeparator = ".") {
|
|
1307
1428
|
return new Intl.NumberFormat("en-US", {
|
|
1308
1429
|
minimumFractionDigits: 0,
|
|
@@ -1359,7 +1480,7 @@ function normalizeNumberInput(raw, options) {
|
|
|
1359
1480
|
value
|
|
1360
1481
|
};
|
|
1361
1482
|
}
|
|
1362
|
-
var NumberInput = (0,
|
|
1483
|
+
var NumberInput = (0, import_react12.forwardRef)(
|
|
1363
1484
|
function NumberInput2({
|
|
1364
1485
|
value,
|
|
1365
1486
|
defaultValue = null,
|
|
@@ -1396,14 +1517,14 @@ var NumberInput = (0, import_react10.forwardRef)(
|
|
|
1396
1517
|
onKeyDown,
|
|
1397
1518
|
...props
|
|
1398
1519
|
}, ref) {
|
|
1399
|
-
const inputRef = (0,
|
|
1400
|
-
const generatedId = (0,
|
|
1520
|
+
const inputRef = (0, import_react12.useRef)(null);
|
|
1521
|
+
const generatedId = (0, import_react12.useId)();
|
|
1401
1522
|
const messageId2 = generatedId + "-message";
|
|
1402
1523
|
const isControlled = value !== void 0;
|
|
1403
|
-
const [internalValue, setInternalValue] = (0,
|
|
1404
|
-
const [focused, setFocused] = (0,
|
|
1524
|
+
const [internalValue, setInternalValue] = (0, import_react12.useState)(defaultValue);
|
|
1525
|
+
const [focused, setFocused] = (0, import_react12.useState)(false);
|
|
1405
1526
|
const actualValue = isControlled ? value ?? null : internalValue;
|
|
1406
|
-
const [text, setText] = (0,
|
|
1527
|
+
const [text, setText] = (0, import_react12.useState)(
|
|
1407
1528
|
actualValue === null ? "" : formatNumber(
|
|
1408
1529
|
actualValue,
|
|
1409
1530
|
decimals,
|
|
@@ -1426,7 +1547,7 @@ var NumberInput = (0, import_react10.forwardRef)(
|
|
|
1426
1547
|
);
|
|
1427
1548
|
const resolvedPrefix = prefix ?? Prefix;
|
|
1428
1549
|
const resolvedSuffix = suffix ?? Suffix;
|
|
1429
|
-
(0,
|
|
1550
|
+
(0, import_react12.useEffect)(() => {
|
|
1430
1551
|
if (!focused)
|
|
1431
1552
|
setText(
|
|
1432
1553
|
actualValue === null ? "" : formatNumber(
|
|
@@ -1480,7 +1601,7 @@ var NumberInput = (0, import_react10.forwardRef)(
|
|
|
1480
1601
|
const stepIsUsable = Number.isFinite(step) && step > 0;
|
|
1481
1602
|
const disableIncrement = Boolean(props.disabled || props.readOnly) || !stepIsUsable || max !== void 0 && actualValue !== null && actualValue >= max;
|
|
1482
1603
|
const disableDecrement = Boolean(props.disabled || props.readOnly) || !stepIsUsable || min !== void 0 && actualValue !== null && actualValue <= min;
|
|
1483
|
-
return /* @__PURE__ */ (0,
|
|
1604
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
1484
1605
|
"div",
|
|
1485
1606
|
{
|
|
1486
1607
|
className: [
|
|
@@ -1489,7 +1610,7 @@ var NumberInput = (0, import_react10.forwardRef)(
|
|
|
1489
1610
|
className
|
|
1490
1611
|
].filter(Boolean).join(" "),
|
|
1491
1612
|
children: [
|
|
1492
|
-
/* @__PURE__ */ (0,
|
|
1613
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1493
1614
|
FieldLabel,
|
|
1494
1615
|
{
|
|
1495
1616
|
id: labelId,
|
|
@@ -1499,10 +1620,10 @@ var NumberInput = (0, import_react10.forwardRef)(
|
|
|
1499
1620
|
isRequired
|
|
1500
1621
|
}
|
|
1501
1622
|
),
|
|
1502
|
-
/* @__PURE__ */ (0,
|
|
1503
|
-
resolvedPrefix && /* @__PURE__ */ (0,
|
|
1504
|
-
/* @__PURE__ */ (0,
|
|
1505
|
-
/* @__PURE__ */ (0,
|
|
1623
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "fe-number-input__control", children: [
|
|
1624
|
+
resolvedPrefix && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "fe-number-input__prefix", children: resolvedPrefix }),
|
|
1625
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "fe-number-input__input-wrap", children: [
|
|
1626
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1506
1627
|
"input",
|
|
1507
1628
|
{
|
|
1508
1629
|
ref: (node) => {
|
|
@@ -1538,41 +1659,41 @@ var NumberInput = (0, import_react10.forwardRef)(
|
|
|
1538
1659
|
"aria-describedby": describedBy
|
|
1539
1660
|
}
|
|
1540
1661
|
),
|
|
1541
|
-
isRequired && placeholder && !text && /* @__PURE__ */ (0,
|
|
1662
|
+
isRequired && placeholder && !text && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
1542
1663
|
"span",
|
|
1543
1664
|
{
|
|
1544
1665
|
className: "fe-number-input__placeholder",
|
|
1545
1666
|
"aria-hidden": "true",
|
|
1546
1667
|
children: [
|
|
1547
|
-
/* @__PURE__ */ (0,
|
|
1548
|
-
/* @__PURE__ */ (0,
|
|
1668
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { children: placeholder }),
|
|
1669
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "fe-field__required", children: "*" })
|
|
1549
1670
|
]
|
|
1550
1671
|
}
|
|
1551
1672
|
)
|
|
1552
1673
|
] }),
|
|
1553
|
-
resolvedSuffix && /* @__PURE__ */ (0,
|
|
1674
|
+
resolvedSuffix && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "fe-number-input__suffix", children: resolvedSuffix }),
|
|
1554
1675
|
endAdornment,
|
|
1555
|
-
showStepper && /* @__PURE__ */ (0,
|
|
1556
|
-
/* @__PURE__ */ (0,
|
|
1676
|
+
showStepper && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "fe-number-input__stepper", children: [
|
|
1677
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1557
1678
|
Button,
|
|
1558
1679
|
{
|
|
1559
1680
|
hierarchy: "tertiary-gray",
|
|
1560
1681
|
size: "24",
|
|
1561
1682
|
iconOnly: true,
|
|
1562
|
-
icon: /* @__PURE__ */ (0,
|
|
1683
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChevronUpIcon, { size: 12 }),
|
|
1563
1684
|
"aria-label": incrementLabel,
|
|
1564
1685
|
disabled: disableIncrement,
|
|
1565
1686
|
onMouseDown: (event) => event.preventDefault(),
|
|
1566
1687
|
onClick: () => adjustValue(1)
|
|
1567
1688
|
}
|
|
1568
1689
|
),
|
|
1569
|
-
/* @__PURE__ */ (0,
|
|
1690
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1570
1691
|
Button,
|
|
1571
1692
|
{
|
|
1572
1693
|
hierarchy: "tertiary-gray",
|
|
1573
1694
|
size: "24",
|
|
1574
1695
|
iconOnly: true,
|
|
1575
|
-
icon: /* @__PURE__ */ (0,
|
|
1696
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(ChevronDownIcon, { size: 12 }),
|
|
1576
1697
|
"aria-label": decrementLabel,
|
|
1577
1698
|
disabled: disableDecrement,
|
|
1578
1699
|
onMouseDown: (event) => event.preventDefault(),
|
|
@@ -1581,7 +1702,7 @@ var NumberInput = (0, import_react10.forwardRef)(
|
|
|
1581
1702
|
)
|
|
1582
1703
|
] })
|
|
1583
1704
|
] }),
|
|
1584
|
-
/* @__PURE__ */ (0,
|
|
1705
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1585
1706
|
FieldMessage,
|
|
1586
1707
|
{
|
|
1587
1708
|
id: messageId2,
|
|
@@ -1598,8 +1719,8 @@ var NumberInput = (0, import_react10.forwardRef)(
|
|
|
1598
1719
|
NumberInput.displayName = "NumberInput";
|
|
1599
1720
|
|
|
1600
1721
|
// packages/form-controls/src/controls/CurrencyInput/currency-input.tsx
|
|
1601
|
-
var
|
|
1602
|
-
var
|
|
1722
|
+
var import_react13 = require("react");
|
|
1723
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1603
1724
|
function CurrencyInput({
|
|
1604
1725
|
suffix = "VND",
|
|
1605
1726
|
currencies,
|
|
@@ -1610,13 +1731,13 @@ function CurrencyInput({
|
|
|
1610
1731
|
disabled,
|
|
1611
1732
|
...props
|
|
1612
1733
|
}) {
|
|
1613
|
-
const [internalCurrency, setInternalCurrency] = (0,
|
|
1734
|
+
const [internalCurrency, setInternalCurrency] = (0, import_react13.useState)(
|
|
1614
1735
|
defaultCurrency ?? currencies?.[0]?.code ?? ""
|
|
1615
1736
|
);
|
|
1616
1737
|
const selectedCurrency = currency ?? internalCurrency;
|
|
1617
1738
|
const current = currencies?.find((item) => item.code === selectedCurrency);
|
|
1618
1739
|
const currencySuffix = current?.suffix ?? current?.code ?? suffix;
|
|
1619
|
-
const endAdornment = currencies?.length ? /* @__PURE__ */ (0,
|
|
1740
|
+
const endAdornment = currencies?.length ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1620
1741
|
Selection,
|
|
1621
1742
|
{
|
|
1622
1743
|
className: "fe-currency-input__currency",
|
|
@@ -1635,8 +1756,8 @@ function CurrencyInput({
|
|
|
1635
1756
|
onCurrencyChange?.(next);
|
|
1636
1757
|
}
|
|
1637
1758
|
}
|
|
1638
|
-
) : /* @__PURE__ */ (0,
|
|
1639
|
-
return /* @__PURE__ */ (0,
|
|
1759
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("span", { className: "fe-currency-input__suffix", children: currencySuffix });
|
|
1760
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1640
1761
|
NumberInput,
|
|
1641
1762
|
{
|
|
1642
1763
|
...props,
|
|
@@ -1648,8 +1769,8 @@ function CurrencyInput({
|
|
|
1648
1769
|
}
|
|
1649
1770
|
|
|
1650
1771
|
// packages/form-controls/src/controls/DateTimePicker/date-time-picker.tsx
|
|
1651
|
-
var
|
|
1652
|
-
var
|
|
1772
|
+
var import_react14 = require("react");
|
|
1773
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1653
1774
|
var pad = (value) => String(value).padStart(2, "0");
|
|
1654
1775
|
function formatDate(date, format) {
|
|
1655
1776
|
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()));
|
|
@@ -1685,7 +1806,7 @@ function DateTimePicker(props) {
|
|
|
1685
1806
|
"aria-describedby": ariaDescribedBy,
|
|
1686
1807
|
"aria-labelledby": ariaLabelledBy
|
|
1687
1808
|
} = props;
|
|
1688
|
-
const generatedId = (0,
|
|
1809
|
+
const generatedId = (0, import_react14.useId)();
|
|
1689
1810
|
const triggerId = id ?? generatedId + "-trigger";
|
|
1690
1811
|
const labelId = generatedId + "-label";
|
|
1691
1812
|
const messageId2 = generatedId + "-message";
|
|
@@ -1703,28 +1824,28 @@ function DateTimePicker(props) {
|
|
|
1703
1824
|
);
|
|
1704
1825
|
const isRange = mode === "range";
|
|
1705
1826
|
const controlled = props.value !== void 0;
|
|
1706
|
-
const [singleInternal, setSingleInternal] = (0,
|
|
1827
|
+
const [singleInternal, setSingleInternal] = (0, import_react14.useState)(
|
|
1707
1828
|
(!isRange ? props.defaultValue : null) ?? null
|
|
1708
1829
|
);
|
|
1709
|
-
const [rangeInternal, setRangeInternal] = (0,
|
|
1830
|
+
const [rangeInternal, setRangeInternal] = (0, import_react14.useState)(
|
|
1710
1831
|
(isRange ? props.defaultValue : void 0) ?? [null, null]
|
|
1711
1832
|
);
|
|
1712
1833
|
const singleValue = !isRange ? props.value ?? singleInternal : null;
|
|
1713
1834
|
const rangeValue = isRange ? props.value ?? rangeInternal : [null, null];
|
|
1714
|
-
const [open, setOpen] = (0,
|
|
1715
|
-
const [month, setMonth] = (0,
|
|
1835
|
+
const [open, setOpen] = (0, import_react14.useState)(false);
|
|
1836
|
+
const [month, setMonth] = (0, import_react14.useState)(
|
|
1716
1837
|
() => new Date((isRange ? rangeValue[0] : singleValue) ?? /* @__PURE__ */ new Date())
|
|
1717
1838
|
);
|
|
1718
|
-
const [editingEnd, setEditingEnd] = (0,
|
|
1719
|
-
const rootRef = (0,
|
|
1720
|
-
(0,
|
|
1839
|
+
const [editingEnd, setEditingEnd] = (0, import_react14.useState)(false);
|
|
1840
|
+
const rootRef = (0, import_react14.useRef)(null);
|
|
1841
|
+
(0, import_react14.useEffect)(() => {
|
|
1721
1842
|
const onPointerDown = (event) => {
|
|
1722
1843
|
if (!rootRef.current?.contains(event.target)) setOpen(false);
|
|
1723
1844
|
};
|
|
1724
1845
|
document.addEventListener("mousedown", onPointerDown);
|
|
1725
1846
|
return () => document.removeEventListener("mousedown", onPointerDown);
|
|
1726
1847
|
}, []);
|
|
1727
|
-
(0,
|
|
1848
|
+
(0, import_react14.useEffect)(() => {
|
|
1728
1849
|
if (disabled) setOpen(false);
|
|
1729
1850
|
}, [disabled]);
|
|
1730
1851
|
const setSingle = (next) => {
|
|
@@ -1780,7 +1901,7 @@ function DateTimePicker(props) {
|
|
|
1780
1901
|
setRange(editingEnd ? [rangeValue[0], next] : [next, rangeValue[1]]);
|
|
1781
1902
|
else setSingle(next);
|
|
1782
1903
|
};
|
|
1783
|
-
return /* @__PURE__ */ (0,
|
|
1904
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1784
1905
|
"div",
|
|
1785
1906
|
{
|
|
1786
1907
|
ref: rootRef,
|
|
@@ -1790,7 +1911,7 @@ function DateTimePicker(props) {
|
|
|
1790
1911
|
className
|
|
1791
1912
|
].filter(Boolean).join(" "),
|
|
1792
1913
|
children: [
|
|
1793
|
-
/* @__PURE__ */ (0,
|
|
1914
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1794
1915
|
FieldLabel,
|
|
1795
1916
|
{
|
|
1796
1917
|
id: labelId,
|
|
@@ -1800,7 +1921,7 @@ function DateTimePicker(props) {
|
|
|
1800
1921
|
isRequired
|
|
1801
1922
|
}
|
|
1802
1923
|
),
|
|
1803
|
-
/* @__PURE__ */ (0,
|
|
1924
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1804
1925
|
"button",
|
|
1805
1926
|
{
|
|
1806
1927
|
id: triggerId,
|
|
@@ -1814,29 +1935,29 @@ function DateTimePicker(props) {
|
|
|
1814
1935
|
"aria-expanded": open,
|
|
1815
1936
|
onClick: () => setOpen((current) => !current),
|
|
1816
1937
|
children: [
|
|
1817
|
-
/* @__PURE__ */ (0,
|
|
1818
|
-
/* @__PURE__ */ (0,
|
|
1938
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { "aria-hidden": "true", children: "\u25F7" }),
|
|
1939
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1819
1940
|
"span",
|
|
1820
1941
|
{
|
|
1821
1942
|
className: !shownValue && placeholder ? "fe-datetime-picker__value is-placeholder" : "fe-datetime-picker__value",
|
|
1822
1943
|
children: [
|
|
1823
1944
|
shownValue || placeholder || (isRange ? "Select date range" : "Select date and time"),
|
|
1824
|
-
isRequired && placeholder && !shownValue && /* @__PURE__ */ (0,
|
|
1945
|
+
isRequired && placeholder && !shownValue && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "fe-field__required", "aria-hidden": "true", children: "*" })
|
|
1825
1946
|
]
|
|
1826
1947
|
}
|
|
1827
1948
|
)
|
|
1828
1949
|
]
|
|
1829
1950
|
}
|
|
1830
1951
|
),
|
|
1831
|
-
open && /* @__PURE__ */ (0,
|
|
1952
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
1832
1953
|
"div",
|
|
1833
1954
|
{
|
|
1834
1955
|
className: "fe-datetime-picker__popper",
|
|
1835
1956
|
role: "dialog",
|
|
1836
1957
|
"aria-label": "Date and time picker",
|
|
1837
1958
|
children: [
|
|
1838
|
-
/* @__PURE__ */ (0,
|
|
1839
|
-
/* @__PURE__ */ (0,
|
|
1959
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "fe-datetime-picker__month", children: [
|
|
1960
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1840
1961
|
"button",
|
|
1841
1962
|
{
|
|
1842
1963
|
type: "button",
|
|
@@ -1847,11 +1968,11 @@ function DateTimePicker(props) {
|
|
|
1847
1968
|
children: "\u2039"
|
|
1848
1969
|
}
|
|
1849
1970
|
),
|
|
1850
|
-
/* @__PURE__ */ (0,
|
|
1971
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("strong", { children: month.toLocaleDateString(locale, {
|
|
1851
1972
|
month: "long",
|
|
1852
1973
|
year: "numeric"
|
|
1853
1974
|
}) }),
|
|
1854
|
-
/* @__PURE__ */ (0,
|
|
1975
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1855
1976
|
"button",
|
|
1856
1977
|
{
|
|
1857
1978
|
type: "button",
|
|
@@ -1863,12 +1984,12 @@ function DateTimePicker(props) {
|
|
|
1863
1984
|
}
|
|
1864
1985
|
)
|
|
1865
1986
|
] }),
|
|
1866
|
-
/* @__PURE__ */ (0,
|
|
1867
|
-
/* @__PURE__ */ (0,
|
|
1987
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "fe-datetime-picker__weekdays", children: ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"].map((day) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { children: day }, day)) }),
|
|
1988
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "fe-datetime-picker__days", children: days.map((day) => {
|
|
1868
1989
|
const inMonth = day.getMonth() === month.getMonth();
|
|
1869
1990
|
const selected = isRange ? sameDay(day, rangeValue[0]) || sameDay(day, rangeValue[1]) : sameDay(day, singleValue);
|
|
1870
1991
|
const inRange = isRange && rangeValue[0] && rangeValue[1] && day > startOfDay(rangeValue[0]) && day < startOfDay(rangeValue[1]);
|
|
1871
|
-
return /* @__PURE__ */ (0,
|
|
1992
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1872
1993
|
"button",
|
|
1873
1994
|
{
|
|
1874
1995
|
type: "button",
|
|
@@ -1883,8 +2004,8 @@ function DateTimePicker(props) {
|
|
|
1883
2004
|
day.toISOString()
|
|
1884
2005
|
);
|
|
1885
2006
|
}) }),
|
|
1886
|
-
isRange && /* @__PURE__ */ (0,
|
|
1887
|
-
/* @__PURE__ */ (0,
|
|
2007
|
+
isRange && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "fe-datetime-picker__range-tabs", children: [
|
|
2008
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1888
2009
|
"button",
|
|
1889
2010
|
{
|
|
1890
2011
|
type: "button",
|
|
@@ -1893,7 +2014,7 @@ function DateTimePicker(props) {
|
|
|
1893
2014
|
children: "Start"
|
|
1894
2015
|
}
|
|
1895
2016
|
),
|
|
1896
|
-
/* @__PURE__ */ (0,
|
|
2017
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1897
2018
|
"button",
|
|
1898
2019
|
{
|
|
1899
2020
|
type: "button",
|
|
@@ -1903,9 +2024,9 @@ function DateTimePicker(props) {
|
|
|
1903
2024
|
}
|
|
1904
2025
|
)
|
|
1905
2026
|
] }),
|
|
1906
|
-
/* @__PURE__ */ (0,
|
|
2027
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("label", { className: "fe-datetime-picker__time", children: [
|
|
1907
2028
|
"Time",
|
|
1908
|
-
/* @__PURE__ */ (0,
|
|
2029
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1909
2030
|
"input",
|
|
1910
2031
|
{
|
|
1911
2032
|
type: "time",
|
|
@@ -1918,7 +2039,7 @@ function DateTimePicker(props) {
|
|
|
1918
2039
|
]
|
|
1919
2040
|
}
|
|
1920
2041
|
),
|
|
1921
|
-
/* @__PURE__ */ (0,
|
|
2042
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
1922
2043
|
FieldMessage,
|
|
1923
2044
|
{
|
|
1924
2045
|
id: messageId2,
|
|
@@ -1933,9 +2054,9 @@ function DateTimePicker(props) {
|
|
|
1933
2054
|
}
|
|
1934
2055
|
|
|
1935
2056
|
// packages/form-controls/src/controls/Checkbox/checkbox.tsx
|
|
1936
|
-
var
|
|
1937
|
-
var
|
|
1938
|
-
var Checkbox = (0,
|
|
2057
|
+
var import_react15 = require("react");
|
|
2058
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
2059
|
+
var Checkbox = (0, import_react15.forwardRef)(
|
|
1939
2060
|
function Checkbox2({
|
|
1940
2061
|
label,
|
|
1941
2062
|
labelPosition = "right",
|
|
@@ -1951,10 +2072,10 @@ var Checkbox = (0, import_react13.forwardRef)(
|
|
|
1951
2072
|
disabled && "fe-checkbox--disabled",
|
|
1952
2073
|
className
|
|
1953
2074
|
].filter(Boolean).join(" ");
|
|
1954
|
-
return /* @__PURE__ */ (0,
|
|
1955
|
-
label && labelPosition === "top" && /* @__PURE__ */ (0,
|
|
1956
|
-
/* @__PURE__ */ (0,
|
|
1957
|
-
/* @__PURE__ */ (0,
|
|
2075
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("label", { className: classes, style, children: [
|
|
2076
|
+
label && labelPosition === "top" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "fe-checkbox__label", children: label }),
|
|
2077
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("span", { className: "fe-checkbox__content", children: [
|
|
2078
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)(
|
|
1958
2079
|
"input",
|
|
1959
2080
|
{
|
|
1960
2081
|
ref,
|
|
@@ -1965,8 +2086,8 @@ var Checkbox = (0, import_react13.forwardRef)(
|
|
|
1965
2086
|
...props
|
|
1966
2087
|
}
|
|
1967
2088
|
),
|
|
1968
|
-
/* @__PURE__ */ (0,
|
|
1969
|
-
label && labelPosition === "right" && /* @__PURE__ */ (0,
|
|
2089
|
+
/* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "fe-checkbox__control", "aria-hidden": "true" }),
|
|
2090
|
+
label && labelPosition === "right" && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "fe-checkbox__label", children: label })
|
|
1970
2091
|
] })
|
|
1971
2092
|
] });
|
|
1972
2093
|
}
|
|
@@ -1974,9 +2095,9 @@ var Checkbox = (0, import_react13.forwardRef)(
|
|
|
1974
2095
|
Checkbox.displayName = "Checkbox";
|
|
1975
2096
|
|
|
1976
2097
|
// packages/form-controls/src/controls/RadioButton/radio-button.tsx
|
|
1977
|
-
var
|
|
1978
|
-
var
|
|
1979
|
-
var RadioButton = (0,
|
|
2098
|
+
var import_react16 = require("react");
|
|
2099
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
2100
|
+
var RadioButton = (0, import_react16.forwardRef)(
|
|
1980
2101
|
function RadioButton2({
|
|
1981
2102
|
label,
|
|
1982
2103
|
labelPosition = "right",
|
|
@@ -1992,10 +2113,10 @@ var RadioButton = (0, import_react14.forwardRef)(
|
|
|
1992
2113
|
disabled && "fe-radio-button--disabled",
|
|
1993
2114
|
className
|
|
1994
2115
|
].filter(Boolean).join(" ");
|
|
1995
|
-
return /* @__PURE__ */ (0,
|
|
1996
|
-
label && labelPosition === "top" && /* @__PURE__ */ (0,
|
|
1997
|
-
/* @__PURE__ */ (0,
|
|
1998
|
-
/* @__PURE__ */ (0,
|
|
2116
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("label", { className: classes, style, children: [
|
|
2117
|
+
label && labelPosition === "top" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "fe-radio-button__label", children: label }),
|
|
2118
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("span", { className: "fe-radio-button__content", children: [
|
|
2119
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
|
|
1999
2120
|
"input",
|
|
2000
2121
|
{
|
|
2001
2122
|
ref,
|
|
@@ -2006,8 +2127,8 @@ var RadioButton = (0, import_react14.forwardRef)(
|
|
|
2006
2127
|
...props
|
|
2007
2128
|
}
|
|
2008
2129
|
),
|
|
2009
|
-
/* @__PURE__ */ (0,
|
|
2010
|
-
label && labelPosition === "right" && /* @__PURE__ */ (0,
|
|
2130
|
+
/* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "fe-radio-button__control", "aria-hidden": "true" }),
|
|
2131
|
+
label && labelPosition === "right" && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "fe-radio-button__label", children: label })
|
|
2011
2132
|
] })
|
|
2012
2133
|
] });
|
|
2013
2134
|
}
|
|
@@ -2015,9 +2136,9 @@ var RadioButton = (0, import_react14.forwardRef)(
|
|
|
2015
2136
|
RadioButton.displayName = "RadioButton";
|
|
2016
2137
|
|
|
2017
2138
|
// packages/form-controls/src/controls/RadioGroup/radio-group.tsx
|
|
2018
|
-
var
|
|
2019
|
-
var
|
|
2020
|
-
var RadioGroup = (0,
|
|
2139
|
+
var import_react17 = require("react");
|
|
2140
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
2141
|
+
var RadioGroup = (0, import_react17.forwardRef)(
|
|
2021
2142
|
function RadioGroup2({
|
|
2022
2143
|
label,
|
|
2023
2144
|
labelPosition = "top",
|
|
@@ -2035,7 +2156,7 @@ var RadioGroup = (0, import_react15.forwardRef)(
|
|
|
2035
2156
|
"aria-labelledby": ariaLabelledBy,
|
|
2036
2157
|
...props
|
|
2037
2158
|
}, ref) {
|
|
2038
|
-
const generatedId = (0,
|
|
2159
|
+
const generatedId = (0, import_react17.useId)();
|
|
2039
2160
|
const groupName = name ?? `fe-radio-group-${generatedId}`;
|
|
2040
2161
|
const labelId = `${id ?? generatedId}-label`;
|
|
2041
2162
|
const isControlled = value !== void 0;
|
|
@@ -2049,12 +2170,12 @@ var RadioGroup = (0, import_react15.forwardRef)(
|
|
|
2049
2170
|
const handleChange = (option, event) => {
|
|
2050
2171
|
if (event.target.checked) onChange?.(option.value, option, event);
|
|
2051
2172
|
};
|
|
2052
|
-
return /* @__PURE__ */ (0,
|
|
2053
|
-
label && labelPosition === "top" && /* @__PURE__ */ (0,
|
|
2173
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("div", { ref, className: classes, ...props, children: [
|
|
2174
|
+
label && labelPosition === "top" && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { id: labelId, className: "fe-radio-group__label", children: [
|
|
2054
2175
|
label,
|
|
2055
|
-
isRequired && /* @__PURE__ */ (0,
|
|
2176
|
+
isRequired && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "fe-radio-group__required", "aria-hidden": "true", children: "*" })
|
|
2056
2177
|
] }),
|
|
2057
|
-
/* @__PURE__ */ (0,
|
|
2178
|
+
/* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2058
2179
|
"div",
|
|
2059
2180
|
{
|
|
2060
2181
|
id,
|
|
@@ -2066,7 +2187,7 @@ var RadioGroup = (0, import_react15.forwardRef)(
|
|
|
2066
2187
|
children: options.map((option) => {
|
|
2067
2188
|
const optionDisabled = disabled || option.disabled;
|
|
2068
2189
|
const optionValue = String(option.value);
|
|
2069
|
-
return /* @__PURE__ */ (0,
|
|
2190
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
|
|
2070
2191
|
RadioButton,
|
|
2071
2192
|
{
|
|
2072
2193
|
name: groupName,
|
|
@@ -2083,9 +2204,9 @@ var RadioGroup = (0, import_react15.forwardRef)(
|
|
|
2083
2204
|
})
|
|
2084
2205
|
}
|
|
2085
2206
|
),
|
|
2086
|
-
label && labelPosition === "right" && /* @__PURE__ */ (0,
|
|
2207
|
+
label && labelPosition === "right" && /* @__PURE__ */ (0, import_jsx_runtime21.jsxs)("span", { id: labelId, className: "fe-radio-group__label", children: [
|
|
2087
2208
|
label,
|
|
2088
|
-
isRequired && /* @__PURE__ */ (0,
|
|
2209
|
+
isRequired && /* @__PURE__ */ (0, import_jsx_runtime21.jsx)("span", { className: "fe-radio-group__required", "aria-hidden": "true", children: "*" })
|
|
2089
2210
|
] })
|
|
2090
2211
|
] });
|
|
2091
2212
|
}
|
|
@@ -2093,29 +2214,29 @@ var RadioGroup = (0, import_react15.forwardRef)(
|
|
|
2093
2214
|
RadioGroup.displayName = "RadioGroup";
|
|
2094
2215
|
|
|
2095
2216
|
// packages/expandable-section/src/index.tsx
|
|
2096
|
-
var
|
|
2097
|
-
var
|
|
2217
|
+
var import_react18 = require("react");
|
|
2218
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
2098
2219
|
function ExpandableSection({ title, children, expanded, defaultExpanded = false, onExpandedChange, disabled, className, ...props }) {
|
|
2099
|
-
const [internalExpanded, setInternalExpanded] = (0,
|
|
2220
|
+
const [internalExpanded, setInternalExpanded] = (0, import_react18.useState)(defaultExpanded);
|
|
2100
2221
|
const isExpanded = expanded ?? internalExpanded;
|
|
2101
|
-
const id = (0,
|
|
2222
|
+
const id = (0, import_react18.useId)();
|
|
2102
2223
|
const toggle = () => {
|
|
2103
2224
|
if (disabled) return;
|
|
2104
2225
|
const next = !isExpanded;
|
|
2105
2226
|
if (expanded === void 0) setInternalExpanded(next);
|
|
2106
2227
|
onExpandedChange?.(next);
|
|
2107
2228
|
};
|
|
2108
|
-
return /* @__PURE__ */ (0,
|
|
2109
|
-
/* @__PURE__ */ (0,
|
|
2110
|
-
/* @__PURE__ */ (0,
|
|
2111
|
-
/* @__PURE__ */ (0,
|
|
2229
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("section", { className: ["fe-expandable-section", isExpanded && "fe-expandable-section--expanded", disabled && "fe-expandable-section--disabled", className].filter(Boolean).join(" "), ...props, children: [
|
|
2230
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsxs)("button", { className: "fe-expandable-section__trigger", type: "button", "aria-expanded": isExpanded, "aria-controls": id, disabled, onClick: toggle, children: [
|
|
2231
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { children: title }),
|
|
2232
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("span", { className: "fe-expandable-section__chevron", "aria-hidden": "true" })
|
|
2112
2233
|
] }),
|
|
2113
|
-
/* @__PURE__ */ (0,
|
|
2234
|
+
/* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { id, className: "fe-expandable-section__content", "aria-hidden": !isExpanded, children: /* @__PURE__ */ (0, import_jsx_runtime22.jsx)("div", { className: "fe-expandable-section__content-inner", children }) })
|
|
2114
2235
|
] });
|
|
2115
2236
|
}
|
|
2116
2237
|
|
|
2117
2238
|
// packages/loading/src/index.tsx
|
|
2118
|
-
var
|
|
2239
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2119
2240
|
var sizes = {
|
|
2120
2241
|
small: "16px",
|
|
2121
2242
|
medium: "24px",
|
|
@@ -2128,15 +2249,15 @@ function Loading({ size = "medium", color = "#2878f0", label, className, style,
|
|
|
2128
2249
|
"--fe-loading-color": color,
|
|
2129
2250
|
...style
|
|
2130
2251
|
};
|
|
2131
|
-
return /* @__PURE__ */ (0,
|
|
2132
|
-
/* @__PURE__ */ (0,
|
|
2133
|
-
label && /* @__PURE__ */ (0,
|
|
2134
|
-
!label && /* @__PURE__ */ (0,
|
|
2252
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: ["fe-loading", className].filter(Boolean).join(" "), style: loadingStyle, role: "status", ...props, children: [
|
|
2253
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "fe-loading__spinner", "aria-hidden": "true" }),
|
|
2254
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "fe-loading__label", children: label }),
|
|
2255
|
+
!label && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("span", { className: "fe-loading__sr-only", children: "Loading" })
|
|
2135
2256
|
] });
|
|
2136
2257
|
}
|
|
2137
2258
|
|
|
2138
2259
|
// packages/skeleton/src/index.tsx
|
|
2139
|
-
var
|
|
2260
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2140
2261
|
var pixels = (value) => typeof value === "number" ? `${value}px` : value;
|
|
2141
2262
|
function SkeletonBase({ variant = "box", shape, width, height, count = 1, animated = true, className, style, ...props }) {
|
|
2142
2263
|
const resolvedVariant = shape ?? variant;
|
|
@@ -2147,7 +2268,7 @@ function SkeletonBase({ variant = "box", shape, width, height, count = 1, animat
|
|
|
2147
2268
|
"--fe-skeleton-height": resolvedHeight,
|
|
2148
2269
|
...style
|
|
2149
2270
|
};
|
|
2150
|
-
return /* @__PURE__ */ (0,
|
|
2271
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_jsx_runtime24.Fragment, { children: Array.from({ length: Math.max(1, count) }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2151
2272
|
"div",
|
|
2152
2273
|
{
|
|
2153
2274
|
className: ["fe-skeleton", `fe-skeleton--${resolvedVariant}`, animated && "fe-skeleton--animated", className].filter(Boolean).join(" "),
|
|
@@ -2159,16 +2280,16 @@ function SkeletonBase({ variant = "box", shape, width, height, count = 1, animat
|
|
|
2159
2280
|
)) });
|
|
2160
2281
|
}
|
|
2161
2282
|
function SkeletonCircle({ size = 40, ...props }) {
|
|
2162
|
-
return /* @__PURE__ */ (0,
|
|
2283
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SkeletonBase, { variant: "circle", width: size, height: size, ...props });
|
|
2163
2284
|
}
|
|
2164
2285
|
function SkeletonSquare({ size = 80, ...props }) {
|
|
2165
|
-
return /* @__PURE__ */ (0,
|
|
2286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SkeletonBase, { variant: "box", width: size, height: size, ...props });
|
|
2166
2287
|
}
|
|
2167
2288
|
function SkeletonBox({ width = "100%", height = 80, ...props }) {
|
|
2168
|
-
return /* @__PURE__ */ (0,
|
|
2289
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SkeletonBase, { variant: "box", width, height, ...props });
|
|
2169
2290
|
}
|
|
2170
2291
|
function SkeletonLine({ width = "100%", height = 12, ...props }) {
|
|
2171
|
-
return /* @__PURE__ */ (0,
|
|
2292
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SkeletonBase, { variant: "line", width, height, ...props });
|
|
2172
2293
|
}
|
|
2173
2294
|
var Skeleton = Object.assign(SkeletonBase, {
|
|
2174
2295
|
Circle: SkeletonCircle,
|
|
@@ -2178,9 +2299,9 @@ var Skeleton = Object.assign(SkeletonBase, {
|
|
|
2178
2299
|
});
|
|
2179
2300
|
|
|
2180
2301
|
// packages/modal/src/index.tsx
|
|
2181
|
-
var
|
|
2302
|
+
var import_react19 = require("react");
|
|
2182
2303
|
var import_react_dom3 = require("react-dom");
|
|
2183
|
-
var
|
|
2304
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2184
2305
|
function Modal({
|
|
2185
2306
|
open,
|
|
2186
2307
|
onClose,
|
|
@@ -2196,9 +2317,9 @@ function Modal({
|
|
|
2196
2317
|
className,
|
|
2197
2318
|
...props
|
|
2198
2319
|
}) {
|
|
2199
|
-
const titleId = (0,
|
|
2200
|
-
const panelRef = (0,
|
|
2201
|
-
(0,
|
|
2320
|
+
const titleId = (0, import_react19.useId)();
|
|
2321
|
+
const panelRef = (0, import_react19.useRef)(null);
|
|
2322
|
+
(0, import_react19.useEffect)(() => {
|
|
2202
2323
|
if (!open) return;
|
|
2203
2324
|
const onKeyDown = (event) => {
|
|
2204
2325
|
if (event.key === "Escape") onClose();
|
|
@@ -2210,9 +2331,9 @@ function Modal({
|
|
|
2210
2331
|
if (!open || typeof document === "undefined") return null;
|
|
2211
2332
|
const hasFooter = footer || actions.length > 0;
|
|
2212
2333
|
return (0, import_react_dom3.createPortal)(
|
|
2213
|
-
/* @__PURE__ */ (0,
|
|
2334
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "fe-modal-backdrop", role: "presentation", onMouseDown: (event) => {
|
|
2214
2335
|
if (event.target === event.currentTarget && closeOnBackdropClick) onClose();
|
|
2215
|
-
}, children: /* @__PURE__ */ (0,
|
|
2336
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
2216
2337
|
"div",
|
|
2217
2338
|
{
|
|
2218
2339
|
ref: panelRef,
|
|
@@ -2224,17 +2345,17 @@ function Modal({
|
|
|
2224
2345
|
tabIndex: -1,
|
|
2225
2346
|
...props,
|
|
2226
2347
|
children: [
|
|
2227
|
-
(title || description || closeButton) && /* @__PURE__ */ (0,
|
|
2228
|
-
/* @__PURE__ */ (0,
|
|
2229
|
-
title && /* @__PURE__ */ (0,
|
|
2230
|
-
description && /* @__PURE__ */ (0,
|
|
2348
|
+
(title || description || closeButton) && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("header", { className: "fe-modal__header", children: [
|
|
2349
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "fe-modal__heading", children: [
|
|
2350
|
+
title && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("h2", { id: titleId, children: title }),
|
|
2351
|
+
description && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { children: description })
|
|
2231
2352
|
] }),
|
|
2232
|
-
closeButton && /* @__PURE__ */ (0,
|
|
2353
|
+
closeButton && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Button, { hierarchy: "tertiary-gray", size: "32", iconOnly: true, icon: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(CloseIcon, {}), "aria-label": closeLabel, onClick: onClose })
|
|
2233
2354
|
] }),
|
|
2234
|
-
/* @__PURE__ */ (0,
|
|
2235
|
-
hasFooter && /* @__PURE__ */ (0,
|
|
2236
|
-
footer && /* @__PURE__ */ (0,
|
|
2237
|
-
actions.length > 0 && /* @__PURE__ */ (0,
|
|
2355
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "fe-modal__body", children }),
|
|
2356
|
+
hasFooter && /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("footer", { className: "fe-modal__footer", children: [
|
|
2357
|
+
footer && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "fe-modal__footer-content", children: footer }),
|
|
2358
|
+
actions.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "fe-modal__actions", children: actions.map(({ label, ...action }, index) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Button, { ...action, children: label }, index)) })
|
|
2238
2359
|
] })
|
|
2239
2360
|
]
|
|
2240
2361
|
}
|
|
@@ -2244,7 +2365,7 @@ function Modal({
|
|
|
2244
2365
|
}
|
|
2245
2366
|
|
|
2246
2367
|
// packages/progress/src/index.tsx
|
|
2247
|
-
var
|
|
2368
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2248
2369
|
function ProgressBar({ value, max = 100, label, showValue = true, size = "medium", color = "#2878f0", className, style, "aria-label": ariaLabel, ...props }) {
|
|
2249
2370
|
const indeterminate = value === null || value === void 0;
|
|
2250
2371
|
const percentage = indeterminate ? 0 : Math.min(100, Math.max(0, Number(value) / Math.max(1, max) * 100));
|
|
@@ -2254,17 +2375,17 @@ function ProgressBar({ value, max = 100, label, showValue = true, size = "medium
|
|
|
2254
2375
|
...style
|
|
2255
2376
|
};
|
|
2256
2377
|
const visibleValue = `${Math.round(percentage)}%`;
|
|
2257
|
-
return /* @__PURE__ */ (0,
|
|
2258
|
-
(label || !indeterminate && showValue) && /* @__PURE__ */ (0,
|
|
2259
|
-
label && /* @__PURE__ */ (0,
|
|
2260
|
-
!indeterminate && showValue && /* @__PURE__ */ (0,
|
|
2378
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: ["fe-progress", `fe-progress--${size}`, indeterminate && "fe-progress--indeterminate", className].filter(Boolean).join(" "), style: progressStyle, ...props, children: [
|
|
2379
|
+
(label || !indeterminate && showValue) && /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "fe-progress__meta", children: [
|
|
2380
|
+
label && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "fe-progress__label", children: label }),
|
|
2381
|
+
!indeterminate && showValue && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("output", { className: "fe-progress__value", children: visibleValue })
|
|
2261
2382
|
] }),
|
|
2262
|
-
/* @__PURE__ */ (0,
|
|
2383
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("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__ */ (0, import_jsx_runtime26.jsx)("span", { className: "fe-progress__indicator" }) })
|
|
2263
2384
|
] });
|
|
2264
2385
|
}
|
|
2265
2386
|
|
|
2266
2387
|
// packages/chip/src/index.tsx
|
|
2267
|
-
var
|
|
2388
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2268
2389
|
var statuses = ["default", "info", "success", "warning", "error", "neutral", "pending", "processing"];
|
|
2269
2390
|
function Chip({ children, status = "default", color, variant = "subtle", dot = false, onRemove, removeLabel = "Remove", className, style, ...props }) {
|
|
2270
2391
|
const usesCustomColor = Boolean(color);
|
|
@@ -2273,16 +2394,16 @@ function Chip({ children, status = "default", color, variant = "subtle", dot = f
|
|
|
2273
2394
|
...style
|
|
2274
2395
|
};
|
|
2275
2396
|
const resolvedStatus = statuses.includes(status) ? status : "default";
|
|
2276
|
-
return /* @__PURE__ */ (0,
|
|
2277
|
-
dot && /* @__PURE__ */ (0,
|
|
2278
|
-
/* @__PURE__ */ (0,
|
|
2279
|
-
onRemove && /* @__PURE__ */ (0,
|
|
2397
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("span", { className: ["fe-chip", `fe-chip--${variant}`, `fe-chip--${usesCustomColor ? "custom" : resolvedStatus}`, className].filter(Boolean).join(" "), style: chipStyle, ...props, children: [
|
|
2398
|
+
dot && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "fe-chip__dot", "aria-hidden": "true" }),
|
|
2399
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "fe-chip__content", children }),
|
|
2400
|
+
onRemove && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Button, { hierarchy: "tertiary-gray", size: "24", iconOnly: true, icon: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CloseIcon, { size: 14 }), "aria-label": removeLabel, onClick: onRemove, className: "fe-chip__remove" })
|
|
2280
2401
|
] });
|
|
2281
2402
|
}
|
|
2282
2403
|
|
|
2283
2404
|
// packages/message/src/index.tsx
|
|
2284
|
-
var
|
|
2285
|
-
var
|
|
2405
|
+
var import_react20 = require("react");
|
|
2406
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
2286
2407
|
var messageId = 0;
|
|
2287
2408
|
var entries = [];
|
|
2288
2409
|
var listeners = /* @__PURE__ */ new Set();
|
|
@@ -2315,22 +2436,22 @@ var message = {
|
|
|
2315
2436
|
};
|
|
2316
2437
|
var icons = { success: "\u2713", info: "i", warning: "!", error: "\xD7" };
|
|
2317
2438
|
function Message({ maxCount = 4, closeLabel = "Close notification", className, ...props }) {
|
|
2318
|
-
const [visibleEntries, setVisibleEntries] = (0,
|
|
2319
|
-
(0,
|
|
2439
|
+
const [visibleEntries, setVisibleEntries] = (0, import_react20.useState)(entries);
|
|
2440
|
+
(0, import_react20.useEffect)(() => {
|
|
2320
2441
|
const listener = (nextEntries) => setVisibleEntries(nextEntries);
|
|
2321
2442
|
listeners.add(listener);
|
|
2322
2443
|
return () => {
|
|
2323
2444
|
listeners.delete(listener);
|
|
2324
2445
|
};
|
|
2325
2446
|
}, []);
|
|
2326
|
-
return /* @__PURE__ */ (0,
|
|
2327
|
-
/* @__PURE__ */ (0,
|
|
2328
|
-
/* @__PURE__ */ (0,
|
|
2329
|
-
entry.title && /* @__PURE__ */ (0,
|
|
2330
|
-
/* @__PURE__ */ (0,
|
|
2447
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: ["fe-message-viewport", className].filter(Boolean).join(" "), "aria-live": "polite", ...props, children: visibleEntries.slice(-Math.max(1, maxCount)).map((entry) => /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: `fe-message fe-message--${entry.severity ?? "info"}`, role: entry.severity === "error" ? "alert" : "status", children: [
|
|
2448
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "fe-message__icon", "aria-hidden": "true", children: icons[entry.severity ?? "info"] }),
|
|
2449
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { className: "fe-message__body", children: [
|
|
2450
|
+
entry.title && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("strong", { className: "fe-message__title", children: entry.title }),
|
|
2451
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "fe-message__content", children: entry.content })
|
|
2331
2452
|
] }),
|
|
2332
|
-
entry.action && /* @__PURE__ */ (0,
|
|
2333
|
-
/* @__PURE__ */ (0,
|
|
2453
|
+
entry.action && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "fe-message__action", children: entry.action }),
|
|
2454
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Button, { className: "fe-message__close", hierarchy: "tertiary-gray", size: "24", iconOnly: true, icon: "\xD7", "aria-label": closeLabel, onClick: () => dismiss(entry.id) })
|
|
2334
2455
|
] }, entry.id)) });
|
|
2335
2456
|
}
|
|
2336
2457
|
((Message2) => {
|
|
@@ -2344,8 +2465,8 @@ function Message({ maxCount = 4, closeLabel = "Close notification", className, .
|
|
|
2344
2465
|
})(Message || (Message = {}));
|
|
2345
2466
|
|
|
2346
2467
|
// packages/snackbar/src/index.tsx
|
|
2347
|
-
var
|
|
2348
|
-
var
|
|
2468
|
+
var import_react21 = require("react");
|
|
2469
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
2349
2470
|
function Snackbar({
|
|
2350
2471
|
open,
|
|
2351
2472
|
message: message2,
|
|
@@ -2359,12 +2480,12 @@ function Snackbar({
|
|
|
2359
2480
|
}) {
|
|
2360
2481
|
const vertical = anchorOrigin.vertical ?? "bottom";
|
|
2361
2482
|
const horizontal = anchorOrigin.horizontal ?? "center";
|
|
2362
|
-
(0,
|
|
2483
|
+
(0, import_react21.useEffect)(() => {
|
|
2363
2484
|
if (!open || autoHideDuration === null) return void 0;
|
|
2364
2485
|
const timer = window.setTimeout(() => onClose?.("timeout"), autoHideDuration);
|
|
2365
2486
|
return () => window.clearTimeout(timer);
|
|
2366
2487
|
}, [open, autoHideDuration, onClose]);
|
|
2367
|
-
(0,
|
|
2488
|
+
(0, import_react21.useEffect)(() => {
|
|
2368
2489
|
if (!open) return void 0;
|
|
2369
2490
|
const onKeyDown = (event) => {
|
|
2370
2491
|
if (event.key === "Escape") onClose?.("escapeKeyDown");
|
|
@@ -2373,15 +2494,559 @@ function Snackbar({
|
|
|
2373
2494
|
return () => window.removeEventListener("keydown", onKeyDown);
|
|
2374
2495
|
}, [open, onClose]);
|
|
2375
2496
|
if (!open) return null;
|
|
2376
|
-
return /* @__PURE__ */ (0,
|
|
2377
|
-
/* @__PURE__ */ (0,
|
|
2378
|
-
action && /* @__PURE__ */ (0,
|
|
2379
|
-
onClose && /* @__PURE__ */ (0,
|
|
2497
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("div", { className: ["fe-snackbar", `fe-snackbar--${vertical}`, `fe-snackbar--${horizontal}`, className].filter(Boolean).join(" "), ...props, children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { className: "fe-snackbar__content", role: "status", "aria-live": "polite", children: [
|
|
2498
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "fe-snackbar__message", children: message2 }),
|
|
2499
|
+
action && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { className: "fe-snackbar__action", children: action }),
|
|
2500
|
+
onClose && /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Button, { className: "fe-snackbar__close", hierarchy: "tertiary-gray", size: "24", iconOnly: true, icon: "\xD7", "aria-label": closeLabel, onClick: () => onClose("closeButton") })
|
|
2380
2501
|
] }) });
|
|
2381
2502
|
}
|
|
2503
|
+
|
|
2504
|
+
// packages/avatar/src/index.tsx
|
|
2505
|
+
var import_react22 = require("react");
|
|
2506
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
2507
|
+
var FALLBACK_AVATARS = [
|
|
2508
|
+
{
|
|
2509
|
+
background: "#E0E7FF",
|
|
2510
|
+
skin: "#F6C6A6",
|
|
2511
|
+
hair: "#432818",
|
|
2512
|
+
shirt: "#5B5BD6",
|
|
2513
|
+
accent: "#A5B4FC",
|
|
2514
|
+
hairStyle: 0,
|
|
2515
|
+
expression: 0
|
|
2516
|
+
},
|
|
2517
|
+
{
|
|
2518
|
+
background: "#FDE68A",
|
|
2519
|
+
skin: "#E7AF87",
|
|
2520
|
+
hair: "#5A3424",
|
|
2521
|
+
shirt: "#D97706",
|
|
2522
|
+
accent: "#FCD34D",
|
|
2523
|
+
hairStyle: 1,
|
|
2524
|
+
expression: 1
|
|
2525
|
+
},
|
|
2526
|
+
{
|
|
2527
|
+
background: "#CCFBF1",
|
|
2528
|
+
skin: "#F4C7A1",
|
|
2529
|
+
hair: "#1F2937",
|
|
2530
|
+
shirt: "#0F766E",
|
|
2531
|
+
accent: "#5EEAD4",
|
|
2532
|
+
hairStyle: 2,
|
|
2533
|
+
expression: 2
|
|
2534
|
+
},
|
|
2535
|
+
{
|
|
2536
|
+
background: "#FCE7F3",
|
|
2537
|
+
skin: "#E5A47F",
|
|
2538
|
+
hair: "#6B2D2D",
|
|
2539
|
+
shirt: "#BE185D",
|
|
2540
|
+
accent: "#F9A8D4",
|
|
2541
|
+
hairStyle: 3,
|
|
2542
|
+
expression: 3,
|
|
2543
|
+
glasses: true
|
|
2544
|
+
},
|
|
2545
|
+
{
|
|
2546
|
+
background: "#DBEAFE",
|
|
2547
|
+
skin: "#8B5E3C",
|
|
2548
|
+
hair: "#24130B",
|
|
2549
|
+
shirt: "#2563EB",
|
|
2550
|
+
accent: "#93C5FD",
|
|
2551
|
+
hairStyle: 0,
|
|
2552
|
+
expression: 1
|
|
2553
|
+
},
|
|
2554
|
+
{
|
|
2555
|
+
background: "#DCFCE7",
|
|
2556
|
+
skin: "#D99B72",
|
|
2557
|
+
hair: "#3F2A20",
|
|
2558
|
+
shirt: "#15803D",
|
|
2559
|
+
accent: "#86EFAC",
|
|
2560
|
+
hairStyle: 1,
|
|
2561
|
+
expression: 2,
|
|
2562
|
+
glasses: true
|
|
2563
|
+
},
|
|
2564
|
+
{
|
|
2565
|
+
background: "#EDE9FE",
|
|
2566
|
+
skin: "#F3C9AD",
|
|
2567
|
+
hair: "#33221A",
|
|
2568
|
+
shirt: "#7C3AED",
|
|
2569
|
+
accent: "#C4B5FD",
|
|
2570
|
+
hairStyle: 2,
|
|
2571
|
+
expression: 3
|
|
2572
|
+
},
|
|
2573
|
+
{
|
|
2574
|
+
background: "#FFE4E6",
|
|
2575
|
+
skin: "#9B6547",
|
|
2576
|
+
hair: "#27150D",
|
|
2577
|
+
shirt: "#E11D48",
|
|
2578
|
+
accent: "#FDA4AF",
|
|
2579
|
+
hairStyle: 3,
|
|
2580
|
+
expression: 0
|
|
2581
|
+
},
|
|
2582
|
+
{
|
|
2583
|
+
background: "#FEF3C7",
|
|
2584
|
+
skin: "#F0B88B",
|
|
2585
|
+
hair: "#855F3B",
|
|
2586
|
+
shirt: "#B45309",
|
|
2587
|
+
accent: "#FBBF24",
|
|
2588
|
+
hairStyle: 0,
|
|
2589
|
+
expression: 2,
|
|
2590
|
+
glasses: true
|
|
2591
|
+
},
|
|
2592
|
+
{
|
|
2593
|
+
background: "#D1FAE5",
|
|
2594
|
+
skin: "#F8D0B0",
|
|
2595
|
+
hair: "#593A28",
|
|
2596
|
+
shirt: "#047857",
|
|
2597
|
+
accent: "#6EE7B7",
|
|
2598
|
+
hairStyle: 1,
|
|
2599
|
+
expression: 3
|
|
2600
|
+
},
|
|
2601
|
+
{
|
|
2602
|
+
background: "#E0F2FE",
|
|
2603
|
+
skin: "#CE8D65",
|
|
2604
|
+
hair: "#372015",
|
|
2605
|
+
shirt: "#0369A1",
|
|
2606
|
+
accent: "#7DD3FC",
|
|
2607
|
+
hairStyle: 2,
|
|
2608
|
+
expression: 0
|
|
2609
|
+
},
|
|
2610
|
+
{
|
|
2611
|
+
background: "#F3E8FF",
|
|
2612
|
+
skin: "#F4C6A3",
|
|
2613
|
+
hair: "#2B1B15",
|
|
2614
|
+
shirt: "#9333EA",
|
|
2615
|
+
accent: "#D8B4FE",
|
|
2616
|
+
hairStyle: 3,
|
|
2617
|
+
expression: 1,
|
|
2618
|
+
glasses: true
|
|
2619
|
+
},
|
|
2620
|
+
{
|
|
2621
|
+
background: "#FFE4C7",
|
|
2622
|
+
skin: "#A96D4C",
|
|
2623
|
+
hair: "#3A2116",
|
|
2624
|
+
shirt: "#C2410C",
|
|
2625
|
+
accent: "#FDBA74",
|
|
2626
|
+
hairStyle: 0,
|
|
2627
|
+
expression: 3
|
|
2628
|
+
},
|
|
2629
|
+
{
|
|
2630
|
+
background: "#ECFCCB",
|
|
2631
|
+
skin: "#F6CCA9",
|
|
2632
|
+
hair: "#7C5135",
|
|
2633
|
+
shirt: "#4D7C0F",
|
|
2634
|
+
accent: "#BEF264",
|
|
2635
|
+
hairStyle: 1,
|
|
2636
|
+
expression: 0
|
|
2637
|
+
},
|
|
2638
|
+
{
|
|
2639
|
+
background: "#CFFAFE",
|
|
2640
|
+
skin: "#E7A27A",
|
|
2641
|
+
hair: "#1F1814",
|
|
2642
|
+
shirt: "#0E7490",
|
|
2643
|
+
accent: "#67E8F9",
|
|
2644
|
+
hairStyle: 2,
|
|
2645
|
+
expression: 1,
|
|
2646
|
+
glasses: true
|
|
2647
|
+
},
|
|
2648
|
+
{
|
|
2649
|
+
background: "#FAE8FF",
|
|
2650
|
+
skin: "#F5C9AA",
|
|
2651
|
+
hair: "#5F3344",
|
|
2652
|
+
shirt: "#A21CAF",
|
|
2653
|
+
accent: "#F0ABFC",
|
|
2654
|
+
hairStyle: 3,
|
|
2655
|
+
expression: 2
|
|
2656
|
+
},
|
|
2657
|
+
{
|
|
2658
|
+
background: "#E0E7FF",
|
|
2659
|
+
skin: "#CF8F67",
|
|
2660
|
+
hair: "#1E1B18",
|
|
2661
|
+
shirt: "#4338CA",
|
|
2662
|
+
accent: "#A5B4FC",
|
|
2663
|
+
hairStyle: 0,
|
|
2664
|
+
expression: 3,
|
|
2665
|
+
glasses: true
|
|
2666
|
+
},
|
|
2667
|
+
{
|
|
2668
|
+
background: "#FFEDD5",
|
|
2669
|
+
skin: "#F7C9A6",
|
|
2670
|
+
hair: "#4E3326",
|
|
2671
|
+
shirt: "#EA580C",
|
|
2672
|
+
accent: "#FDBA74",
|
|
2673
|
+
hairStyle: 1,
|
|
2674
|
+
expression: 0
|
|
2675
|
+
},
|
|
2676
|
+
{
|
|
2677
|
+
background: "#D9F99D",
|
|
2678
|
+
skin: "#A66A49",
|
|
2679
|
+
hair: "#2B1911",
|
|
2680
|
+
shirt: "#65A30D",
|
|
2681
|
+
accent: "#BEF264",
|
|
2682
|
+
hairStyle: 2,
|
|
2683
|
+
expression: 1
|
|
2684
|
+
},
|
|
2685
|
+
{
|
|
2686
|
+
background: "#FCE7F3",
|
|
2687
|
+
skin: "#E9B08A",
|
|
2688
|
+
hair: "#4A2F24",
|
|
2689
|
+
shirt: "#DB2777",
|
|
2690
|
+
accent: "#F9A8D4",
|
|
2691
|
+
hairStyle: 3,
|
|
2692
|
+
expression: 2,
|
|
2693
|
+
glasses: true
|
|
2694
|
+
},
|
|
2695
|
+
{
|
|
2696
|
+
background: "#DBEAFE",
|
|
2697
|
+
skin: "#F2C3A1",
|
|
2698
|
+
hair: "#312018",
|
|
2699
|
+
shirt: "#1D4ED8",
|
|
2700
|
+
accent: "#93C5FD",
|
|
2701
|
+
hairStyle: 0,
|
|
2702
|
+
expression: 0
|
|
2703
|
+
},
|
|
2704
|
+
{
|
|
2705
|
+
background: "#CCFBF1",
|
|
2706
|
+
skin: "#9D6244",
|
|
2707
|
+
hair: "#1F130E",
|
|
2708
|
+
shirt: "#0D9488",
|
|
2709
|
+
accent: "#5EEAD4",
|
|
2710
|
+
hairStyle: 1,
|
|
2711
|
+
expression: 1,
|
|
2712
|
+
glasses: true
|
|
2713
|
+
},
|
|
2714
|
+
{
|
|
2715
|
+
background: "#FEE2E2",
|
|
2716
|
+
skin: "#F6CBAA",
|
|
2717
|
+
hair: "#75452A",
|
|
2718
|
+
shirt: "#DC2626",
|
|
2719
|
+
accent: "#FCA5A5",
|
|
2720
|
+
hairStyle: 2,
|
|
2721
|
+
expression: 2
|
|
2722
|
+
},
|
|
2723
|
+
{
|
|
2724
|
+
background: "#EDE9FE",
|
|
2725
|
+
skin: "#D98E65",
|
|
2726
|
+
hair: "#412720",
|
|
2727
|
+
shirt: "#6D28D9",
|
|
2728
|
+
accent: "#C4B5FD",
|
|
2729
|
+
hairStyle: 3,
|
|
2730
|
+
expression: 3
|
|
2731
|
+
},
|
|
2732
|
+
{
|
|
2733
|
+
background: "#FEF9C3",
|
|
2734
|
+
skin: "#F5C7A4",
|
|
2735
|
+
hair: "#2B1A12",
|
|
2736
|
+
shirt: "#A16207",
|
|
2737
|
+
accent: "#FDE047",
|
|
2738
|
+
hairStyle: 0,
|
|
2739
|
+
expression: 1,
|
|
2740
|
+
glasses: true
|
|
2741
|
+
},
|
|
2742
|
+
{
|
|
2743
|
+
background: "#DCFCE7",
|
|
2744
|
+
skin: "#B97855",
|
|
2745
|
+
hair: "#291A13",
|
|
2746
|
+
shirt: "#16A34A",
|
|
2747
|
+
accent: "#86EFAC",
|
|
2748
|
+
hairStyle: 1,
|
|
2749
|
+
expression: 2
|
|
2750
|
+
},
|
|
2751
|
+
{
|
|
2752
|
+
background: "#E0F2FE",
|
|
2753
|
+
skin: "#F6C5A2",
|
|
2754
|
+
hair: "#6A4031",
|
|
2755
|
+
shirt: "#0284C7",
|
|
2756
|
+
accent: "#7DD3FC",
|
|
2757
|
+
hairStyle: 2,
|
|
2758
|
+
expression: 3,
|
|
2759
|
+
glasses: true
|
|
2760
|
+
},
|
|
2761
|
+
{
|
|
2762
|
+
background: "#FAE8FF",
|
|
2763
|
+
skin: "#DE9B72",
|
|
2764
|
+
hair: "#211714",
|
|
2765
|
+
shirt: "#C026D3",
|
|
2766
|
+
accent: "#F0ABFC",
|
|
2767
|
+
hairStyle: 3,
|
|
2768
|
+
expression: 0
|
|
2769
|
+
},
|
|
2770
|
+
{
|
|
2771
|
+
background: "#FFE4E6",
|
|
2772
|
+
skin: "#F7CEAF",
|
|
2773
|
+
hair: "#42291E",
|
|
2774
|
+
shirt: "#E11D48",
|
|
2775
|
+
accent: "#FDA4AF",
|
|
2776
|
+
hairStyle: 0,
|
|
2777
|
+
expression: 2
|
|
2778
|
+
},
|
|
2779
|
+
{
|
|
2780
|
+
background: "#ECFCCB",
|
|
2781
|
+
skin: "#CE8C65",
|
|
2782
|
+
hair: "#3C2419",
|
|
2783
|
+
shirt: "#3F6212",
|
|
2784
|
+
accent: "#BEF264",
|
|
2785
|
+
hairStyle: 1,
|
|
2786
|
+
expression: 3,
|
|
2787
|
+
glasses: true
|
|
2788
|
+
},
|
|
2789
|
+
{
|
|
2790
|
+
background: "#CFFAFE",
|
|
2791
|
+
skin: "#F0BE99",
|
|
2792
|
+
hair: "#29201B",
|
|
2793
|
+
shirt: "#0891B2",
|
|
2794
|
+
accent: "#67E8F9",
|
|
2795
|
+
hairStyle: 2,
|
|
2796
|
+
expression: 0
|
|
2797
|
+
},
|
|
2798
|
+
{
|
|
2799
|
+
background: "#F3E8FF",
|
|
2800
|
+
skin: "#A76B4B",
|
|
2801
|
+
hair: "#241710",
|
|
2802
|
+
shirt: "#7E22CE",
|
|
2803
|
+
accent: "#D8B4FE",
|
|
2804
|
+
hairStyle: 3,
|
|
2805
|
+
expression: 1,
|
|
2806
|
+
glasses: true
|
|
2807
|
+
}
|
|
2808
|
+
];
|
|
2809
|
+
function getInitials(content) {
|
|
2810
|
+
const words = content.trim().split(/\s+/).filter(Boolean);
|
|
2811
|
+
return words.slice(-2).map((word) => Array.from(word)[0] ?? "").join("").toLocaleUpperCase();
|
|
2812
|
+
}
|
|
2813
|
+
function resolveSize(size) {
|
|
2814
|
+
if (typeof size === "number") return `${size}px`;
|
|
2815
|
+
return /^\d+(?:\.\d+)?$/.test(size) ? `${size}px` : size;
|
|
2816
|
+
}
|
|
2817
|
+
function resolveFontSize(size) {
|
|
2818
|
+
const numericSize = typeof size === "number" ? size : Number(size);
|
|
2819
|
+
if (Number.isFinite(numericSize)) {
|
|
2820
|
+
return `${Math.min(28, Math.max(10, numericSize * 0.38))}px`;
|
|
2821
|
+
}
|
|
2822
|
+
return "1em";
|
|
2823
|
+
}
|
|
2824
|
+
function getFallbackIndex(index) {
|
|
2825
|
+
if (!Number.isFinite(index)) return 0;
|
|
2826
|
+
return Math.abs(Math.trunc(index)) % FALLBACK_AVATARS.length;
|
|
2827
|
+
}
|
|
2828
|
+
function AvatarFallbackIcon({ avatar }) {
|
|
2829
|
+
const {
|
|
2830
|
+
accent,
|
|
2831
|
+
background,
|
|
2832
|
+
expression,
|
|
2833
|
+
glasses,
|
|
2834
|
+
hair,
|
|
2835
|
+
hairStyle,
|
|
2836
|
+
shirt,
|
|
2837
|
+
skin
|
|
2838
|
+
} = avatar;
|
|
2839
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
2840
|
+
"svg",
|
|
2841
|
+
{
|
|
2842
|
+
className: "fe-avatar__fallback-icon",
|
|
2843
|
+
viewBox: "0 0 24 24",
|
|
2844
|
+
focusable: "false",
|
|
2845
|
+
"aria-hidden": "true",
|
|
2846
|
+
children: [
|
|
2847
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("rect", { width: "24", height: "24", fill: background }),
|
|
2848
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
2849
|
+
"path",
|
|
2850
|
+
{
|
|
2851
|
+
d: "M3 24c.52-3.79 3.58-6.25 9-6.25S20.48 20.21 21 24",
|
|
2852
|
+
fill: shirt
|
|
2853
|
+
}
|
|
2854
|
+
),
|
|
2855
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
2856
|
+
"path",
|
|
2857
|
+
{
|
|
2858
|
+
d: "M8.1 17.65h7.8l1.05 2.05H7.05l1.05-2.05Z",
|
|
2859
|
+
fill: accent,
|
|
2860
|
+
opacity: ".72"
|
|
2861
|
+
}
|
|
2862
|
+
),
|
|
2863
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("circle", { cx: "12", cy: "10.25", r: "5.25", fill: skin }),
|
|
2864
|
+
hairStyle === 0 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
2865
|
+
"path",
|
|
2866
|
+
{
|
|
2867
|
+
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",
|
|
2868
|
+
fill: hair
|
|
2869
|
+
}
|
|
2870
|
+
),
|
|
2871
|
+
hairStyle === 1 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
2872
|
+
"path",
|
|
2873
|
+
{
|
|
2874
|
+
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",
|
|
2875
|
+
fill: hair
|
|
2876
|
+
}
|
|
2877
|
+
),
|
|
2878
|
+
hairStyle === 2 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
2879
|
+
"path",
|
|
2880
|
+
{
|
|
2881
|
+
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",
|
|
2882
|
+
fill: hair
|
|
2883
|
+
}
|
|
2884
|
+
),
|
|
2885
|
+
hairStyle === 3 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
2886
|
+
"path",
|
|
2887
|
+
{
|
|
2888
|
+
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",
|
|
2889
|
+
fill: hair
|
|
2890
|
+
}
|
|
2891
|
+
),
|
|
2892
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("circle", { cx: "10.05", cy: "10.65", r: ".48", fill: "#3B2924" }),
|
|
2893
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("circle", { cx: "13.95", cy: "10.65", r: ".48", fill: "#3B2924" }),
|
|
2894
|
+
expression === 0 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
2895
|
+
"path",
|
|
2896
|
+
{
|
|
2897
|
+
d: "M10.25 13.2c1.08.66 2.42.66 3.5 0",
|
|
2898
|
+
fill: "none",
|
|
2899
|
+
stroke: "#A94F4F",
|
|
2900
|
+
strokeWidth: ".7",
|
|
2901
|
+
strokeLinecap: "round"
|
|
2902
|
+
}
|
|
2903
|
+
),
|
|
2904
|
+
expression === 1 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
2905
|
+
"path",
|
|
2906
|
+
{
|
|
2907
|
+
d: "M10.5 13.2h3",
|
|
2908
|
+
fill: "none",
|
|
2909
|
+
stroke: "#A94F4F",
|
|
2910
|
+
strokeWidth: ".7",
|
|
2911
|
+
strokeLinecap: "round"
|
|
2912
|
+
}
|
|
2913
|
+
),
|
|
2914
|
+
expression === 2 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
2915
|
+
"path",
|
|
2916
|
+
{
|
|
2917
|
+
d: "M10.6 13.38c.84-.44 1.96-.44 2.8 0",
|
|
2918
|
+
fill: "none",
|
|
2919
|
+
stroke: "#A94F4F",
|
|
2920
|
+
strokeWidth: ".7",
|
|
2921
|
+
strokeLinecap: "round"
|
|
2922
|
+
}
|
|
2923
|
+
),
|
|
2924
|
+
expression === 3 && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("circle", { cx: "12", cy: "13.2", r: ".82", fill: "#B95A5A" }),
|
|
2925
|
+
glasses && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("g", { fill: "none", stroke: "#3C4355", strokeWidth: ".65", children: [
|
|
2926
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("circle", { cx: "10", cy: "10.55", r: "1.45" }),
|
|
2927
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("circle", { cx: "14", cy: "10.55", r: "1.45" }),
|
|
2928
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("path", { d: "M11.45 10.55h1.1M8.55 10.55H7.5m9 0h-1.05" })
|
|
2929
|
+
] })
|
|
2930
|
+
]
|
|
2931
|
+
}
|
|
2932
|
+
);
|
|
2933
|
+
}
|
|
2934
|
+
function Avatar({
|
|
2935
|
+
src,
|
|
2936
|
+
content,
|
|
2937
|
+
alt,
|
|
2938
|
+
size = 40,
|
|
2939
|
+
shape = "circle",
|
|
2940
|
+
fallbackIndex,
|
|
2941
|
+
className,
|
|
2942
|
+
style,
|
|
2943
|
+
role,
|
|
2944
|
+
"aria-label": ariaLabel,
|
|
2945
|
+
...props
|
|
2946
|
+
}) {
|
|
2947
|
+
const [generatedFallbackIndex] = (0, import_react22.useState)(
|
|
2948
|
+
() => Math.floor(Math.random() * FALLBACK_AVATARS.length)
|
|
2949
|
+
);
|
|
2950
|
+
const [failedImageSrc, setFailedImageSrc] = (0, import_react22.useState)();
|
|
2951
|
+
const imageSrc = src?.trim();
|
|
2952
|
+
const trimmedContent = content?.trim() ?? "";
|
|
2953
|
+
const showImage = Boolean(imageSrc && failedImageSrc !== imageSrc);
|
|
2954
|
+
const initials = trimmedContent ? getInitials(trimmedContent) : "";
|
|
2955
|
+
const selectedFallback = FALLBACK_AVATARS[getFallbackIndex(fallbackIndex ?? generatedFallbackIndex)];
|
|
2956
|
+
const avatarStyle = {
|
|
2957
|
+
"--fe-avatar-size": resolveSize(size),
|
|
2958
|
+
"--fe-avatar-font-size": resolveFontSize(size),
|
|
2959
|
+
...style
|
|
2960
|
+
};
|
|
2961
|
+
const fallbackLabel = (alt ?? trimmedContent) || "Avatar";
|
|
2962
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
2963
|
+
"span",
|
|
2964
|
+
{
|
|
2965
|
+
className: ["fe-avatar", `fe-avatar--${shape}`, className].filter(Boolean).join(" "),
|
|
2966
|
+
style: avatarStyle,
|
|
2967
|
+
role: showImage ? role : role ?? "img",
|
|
2968
|
+
"aria-label": showImage ? ariaLabel : ariaLabel ?? fallbackLabel,
|
|
2969
|
+
...props,
|
|
2970
|
+
children: [
|
|
2971
|
+
showImage && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
2972
|
+
"img",
|
|
2973
|
+
{
|
|
2974
|
+
className: "fe-avatar__image",
|
|
2975
|
+
src: imageSrc,
|
|
2976
|
+
alt: alt ?? trimmedContent,
|
|
2977
|
+
onError: () => setFailedImageSrc(imageSrc)
|
|
2978
|
+
}
|
|
2979
|
+
),
|
|
2980
|
+
!showImage && initials && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "fe-avatar__initials", "aria-hidden": "true", children: initials }),
|
|
2981
|
+
!showImage && !initials && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(AvatarFallbackIcon, { avatar: selectedFallback })
|
|
2982
|
+
]
|
|
2983
|
+
}
|
|
2984
|
+
);
|
|
2985
|
+
}
|
|
2986
|
+
function AvatarGroup({
|
|
2987
|
+
children,
|
|
2988
|
+
maxCount,
|
|
2989
|
+
className,
|
|
2990
|
+
style,
|
|
2991
|
+
role,
|
|
2992
|
+
...props
|
|
2993
|
+
}) {
|
|
2994
|
+
const avatars = import_react22.Children.toArray(children).filter(import_react22.isValidElement);
|
|
2995
|
+
const hasMaxCount = typeof maxCount === "number" && Number.isFinite(maxCount) && maxCount > 0;
|
|
2996
|
+
const itemLimit = hasMaxCount ? Math.floor(maxCount) : avatars.length;
|
|
2997
|
+
const hasOverflow = avatars.length > itemLimit;
|
|
2998
|
+
const visibleCount = hasOverflow ? Math.max(0, itemLimit - 1) : itemLimit;
|
|
2999
|
+
const visibleAvatars = avatars.slice(0, visibleCount);
|
|
3000
|
+
const overflowCount = avatars.length - visibleAvatars.length;
|
|
3001
|
+
const firstAvatarSize = avatars[0]?.props.size ?? 40;
|
|
3002
|
+
const overflowStyle = {
|
|
3003
|
+
"--fe-avatar-size": resolveSize(firstAvatarSize),
|
|
3004
|
+
"--fe-avatar-font-size": resolveFontSize(firstAvatarSize)
|
|
3005
|
+
};
|
|
3006
|
+
const singleContent = avatars.length === 1 ? avatars[0]?.props.content?.trim() ?? "" : "";
|
|
3007
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
3008
|
+
"div",
|
|
3009
|
+
{
|
|
3010
|
+
className: ["fe-avatar-group", className].filter(Boolean).join(" "),
|
|
3011
|
+
style,
|
|
3012
|
+
role: role ?? "group",
|
|
3013
|
+
...props,
|
|
3014
|
+
children: [
|
|
3015
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "fe-avatar-group__items", children: [
|
|
3016
|
+
visibleAvatars.map((avatar, index) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
3017
|
+
"span",
|
|
3018
|
+
{
|
|
3019
|
+
className: "fe-avatar-group__item",
|
|
3020
|
+
style: { zIndex: visibleAvatars.length - index },
|
|
3021
|
+
children: avatar
|
|
3022
|
+
},
|
|
3023
|
+
avatar.key ?? index
|
|
3024
|
+
)),
|
|
3025
|
+
hasOverflow && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(
|
|
3026
|
+
"span",
|
|
3027
|
+
{
|
|
3028
|
+
className: "fe-avatar-group__more",
|
|
3029
|
+
style: overflowStyle,
|
|
3030
|
+
role: "img",
|
|
3031
|
+
"aria-label": `${overflowCount} more avatars`,
|
|
3032
|
+
children: [
|
|
3033
|
+
"+",
|
|
3034
|
+
overflowCount
|
|
3035
|
+
]
|
|
3036
|
+
}
|
|
3037
|
+
)
|
|
3038
|
+
] }),
|
|
3039
|
+
singleContent && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("span", { className: "fe-avatar-group__content", children: singleContent })
|
|
3040
|
+
]
|
|
3041
|
+
}
|
|
3042
|
+
);
|
|
3043
|
+
}
|
|
2382
3044
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2383
3045
|
0 && (module.exports = {
|
|
3046
|
+
Avatar,
|
|
3047
|
+
AvatarGroup,
|
|
2384
3048
|
Button,
|
|
3049
|
+
ButtonBar,
|
|
2385
3050
|
Checkbox,
|
|
2386
3051
|
ChevronDownIcon,
|
|
2387
3052
|
ChevronUpIcon,
|
|
@@ -2394,6 +3059,8 @@ function Snackbar({
|
|
|
2394
3059
|
Loading,
|
|
2395
3060
|
Message,
|
|
2396
3061
|
Modal,
|
|
3062
|
+
MoreHorizontalIcon,
|
|
3063
|
+
MoreVerticalIcon,
|
|
2397
3064
|
NumberInput,
|
|
2398
3065
|
Pagination,
|
|
2399
3066
|
PlusIcon,
|