@mond-design-system/react 4.6.0 → 4.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -660,7 +660,7 @@ function Sheet({ open, onClose, label, closeOnScrimClick = true, children }) {
660
660
  }
661
661
  function SheetHeader({ children, onClose, closeLabel }) {
662
662
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: Sheet_module_default.header, children: [
663
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: Sheet_module_default.headerTitle, children }),
663
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: Sheet_module_default.headerTitle, children }),
664
664
  onClose !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", "aria-label": closeLabel, className: Sheet_module_default.close, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(CloseGlyph, { className: Sheet_module_default.closeGlyph }) })
665
665
  ] });
666
666
  }
@@ -1187,12 +1187,40 @@ function Textarea({ rows = 3, showCount = false, className, ...rest }) {
1187
1187
  ] });
1188
1188
  }
1189
1189
 
1190
+ // src/internal/forkRef.ts
1191
+ function forkRef(own, given) {
1192
+ return (node) => {
1193
+ own.current = node;
1194
+ if (typeof given === "function") given(node);
1195
+ else if (given != null) given.current = node;
1196
+ };
1197
+ }
1198
+
1190
1199
  // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Checkbox/Checkbox.module.css?mds-scoped
1191
- var Checkbox_module_default = { "root": "mds-Checkbox__root", "box": "mds-Checkbox__box mds-hit-area__hitArea", "label": "mds-Checkbox__label" };
1192
- function Checkbox({ label, className, ...rest }) {
1193
- return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: cx(Checkbox_module_default.root, className), children: [
1194
- /* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", className: Checkbox_module_default.box, ...rest }),
1195
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: Checkbox_module_default.label, children: label })
1200
+ var Checkbox_module_default = { "root": "mds-Checkbox__root", "box": "mds-Checkbox__box mds-hit-area__hitArea", "bare": "mds-Checkbox__bare", "label": "mds-Checkbox__label" };
1201
+ function Checkbox({
1202
+ label,
1203
+ labelHidden = false,
1204
+ indeterminate = false,
1205
+ className,
1206
+ ref,
1207
+ ...rest
1208
+ }) {
1209
+ const own = react.useRef(null);
1210
+ react.useEffect(() => {
1211
+ if (own.current !== null) own.current.indeterminate = indeterminate;
1212
+ }, [indeterminate]);
1213
+ return /* @__PURE__ */ jsxRuntime.jsxs("label", { className: cx(Checkbox_module_default.root, labelHidden && Checkbox_module_default.bare, className), children: [
1214
+ /* @__PURE__ */ jsxRuntime.jsx(
1215
+ "input",
1216
+ {
1217
+ type: "checkbox",
1218
+ className: Checkbox_module_default.box,
1219
+ ref: forkRef(own, ref),
1220
+ ...rest
1221
+ }
1222
+ ),
1223
+ labelHidden ? /* @__PURE__ */ jsxRuntime.jsx(VisuallyHidden, { className: Checkbox_module_default.label, children: label }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: Checkbox_module_default.label, children: label })
1196
1224
  ] });
1197
1225
  }
1198
1226
 
@@ -1399,6 +1427,97 @@ function ListItem({
1399
1427
  );
1400
1428
  }
1401
1429
 
1430
+ // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/DataTable/DataTable.module.css?mds-scoped
1431
+ var DataTable_module_default = { "root": "mds-DataTable__root", "table": "mds-DataTable__table", "body": "mds-DataTable__body", "row": "mds-DataTable__row", "cell": "mds-DataTable__cell", "select": "mds-DataTable__select", "actions": "mds-DataTable__actions", "key": "mds-DataTable__key", "lead": "mds-DataTable__lead", "selected": "mds-DataTable__selected", "muted": "mds-DataTable__muted", "empty": "mds-DataTable__empty", "bulk": "mds-DataTable__bulk", "bulkActions": "mds-DataTable__bulkActions", "head": "mds-DataTable__head" };
1432
+ function DataTable({
1433
+ label,
1434
+ columns,
1435
+ rows,
1436
+ rowKey,
1437
+ rowLabel,
1438
+ rowActions,
1439
+ actionsHeader,
1440
+ rowMuted,
1441
+ empty,
1442
+ ref,
1443
+ selected,
1444
+ onSelectedChange,
1445
+ selectionLabels,
1446
+ bulkActions,
1447
+ className,
1448
+ ...rest
1449
+ }) {
1450
+ const selectable = selected !== void 0;
1451
+ const keys = rows.map(rowKey);
1452
+ const all = selectable && keys.length > 0 && keys.every((key) => selected.includes(key));
1453
+ const some = selectable && !all && keys.some((key) => selected.includes(key));
1454
+ const span = columns.length + (selectable ? 1 : 0) + (rowActions ? 1 : 0);
1455
+ const toggle = (key, taken) => {
1456
+ if (selected === void 0) return;
1457
+ const next = taken ? [...selected, key] : selected.filter((each) => each !== key);
1458
+ onSelectedChange(keys.filter((each) => next.includes(each)));
1459
+ };
1460
+ const nameOf = (row) => {
1461
+ if (rowLabel !== void 0) return rowLabel(row);
1462
+ const first = columns[0]?.cell(row);
1463
+ return typeof first === "string" ? first : rowKey(row);
1464
+ };
1465
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx(DataTable_module_default.root, className), ref, ...rest, children: [
1466
+ /* @__PURE__ */ jsxRuntime.jsxs("table", { className: DataTable_module_default.table, "aria-label": label, children: [
1467
+ /* @__PURE__ */ jsxRuntime.jsxs("colgroup", { children: [
1468
+ selectable && /* @__PURE__ */ jsxRuntime.jsx("col", {}),
1469
+ columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx("col", { style: column.width !== void 0 ? { width: column.width } : void 0 }, column.key)),
1470
+ rowActions && /* @__PURE__ */ jsxRuntime.jsx("col", {})
1471
+ ] }),
1472
+ /* @__PURE__ */ jsxRuntime.jsx(VisuallyHidden, { as: "thead", className: DataTable_module_default.head, children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: DataTable_module_default.row, children: [
1473
+ selectable && /* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", className: DataTable_module_default.select, children: /* @__PURE__ */ jsxRuntime.jsx(
1474
+ Checkbox,
1475
+ {
1476
+ label: selectionLabels.all,
1477
+ labelHidden: true,
1478
+ checked: all,
1479
+ indeterminate: some,
1480
+ onChange: (event) => onSelectedChange(event.target.checked ? keys : [])
1481
+ }
1482
+ ) }),
1483
+ columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", className: DataTable_module_default.cell, children: column.header }, column.key)),
1484
+ rowActions && /* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", className: DataTable_module_default.actions, children: actionsHeader })
1485
+ ] }) }),
1486
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: DataTable_module_default.body, children: rows.length > 0 ? rows.map((row) => {
1487
+ const key = rowKey(row);
1488
+ const taken = selected?.includes(key) ?? false;
1489
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1490
+ "tr",
1491
+ {
1492
+ className: cx(DataTable_module_default.row, taken && DataTable_module_default.selected, rowMuted?.(row) === true && DataTable_module_default.muted),
1493
+ children: [
1494
+ selectable && /* @__PURE__ */ jsxRuntime.jsx("td", { className: DataTable_module_default.select, children: /* @__PURE__ */ jsxRuntime.jsx(
1495
+ Checkbox,
1496
+ {
1497
+ label: selectionLabels.row(nameOf(row)),
1498
+ labelHidden: true,
1499
+ checked: taken,
1500
+ onChange: (event) => toggle(key, event.target.checked)
1501
+ }
1502
+ ) }),
1503
+ columns.map((column, index) => /* @__PURE__ */ jsxRuntime.jsxs("td", { className: cx(DataTable_module_default.cell, index === 0 && DataTable_module_default.lead), children: [
1504
+ index > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: DataTable_module_default.key, "aria-hidden": "true", children: column.header }),
1505
+ column.cell(row)
1506
+ ] }, column.key)),
1507
+ rowActions && /* @__PURE__ */ jsxRuntime.jsx("td", { className: DataTable_module_default.actions, children: rowActions(row) })
1508
+ ]
1509
+ },
1510
+ key
1511
+ );
1512
+ }) : empty !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("tr", { className: DataTable_module_default.row, children: /* @__PURE__ */ jsxRuntime.jsx("td", { className: DataTable_module_default.empty, colSpan: span, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "note", children: empty }) }) }) })
1513
+ ] }),
1514
+ selectable && selected.length > 0 && bulkActions !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: DataTable_module_default.bulk, role: "status", children: [
1515
+ /* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "meta", children: selectionLabels.count(selected.length) }),
1516
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: DataTable_module_default.bulkActions, children: bulkActions })
1517
+ ] })
1518
+ ] });
1519
+ }
1520
+
1402
1521
  // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/EmptyState/EmptyState.module.css?mds-scoped
1403
1522
  var EmptyState_module_default = { "root": "mds-EmptyState__root", "icon": "mds-EmptyState__icon", "action": "mds-EmptyState__action" };
1404
1523
  function EmptyState({ title, description, icon, action, className }) {
@@ -1670,7 +1789,7 @@ function CardFooter({ className, ...rest }) {
1670
1789
  }
1671
1790
 
1672
1791
  // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Modal/Modal.module.css?mds-scoped
1673
- var Modal_module_default = { "panel": "mds-Modal__panel", "header": "mds-Modal__header", "body": "mds-Modal__body", "footer": "mds-Modal__footer" };
1792
+ var Modal_module_default = { "panel": "mds-Modal__panel", "header": "mds-Modal__header", "headerTitle": "mds-Modal__headerTitle", "body": "mds-Modal__body", "footer": "mds-Modal__footer" };
1674
1793
  function Modal({ open, onClose, label, closeOnScrimClick = true, role = "dialog", children }) {
1675
1794
  return /* @__PURE__ */ jsxRuntime.jsx(
1676
1795
  Overlay,
@@ -1687,7 +1806,7 @@ function Modal({ open, onClose, label, closeOnScrimClick = true, role = "dialog"
1687
1806
  );
1688
1807
  }
1689
1808
  function ModalHeader({ children }) {
1690
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: Modal_module_default.header, children });
1809
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: Modal_module_default.header, children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: Modal_module_default.headerTitle, children }) });
1691
1810
  }
1692
1811
  function ModalBody({ children }) {
1693
1812
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: Modal_module_default.body, children });
@@ -2343,11 +2462,7 @@ function VideoPlayer({
2343
2462
  {
2344
2463
  className: cx(VideoPlayer_module_default.player, covered && VideoPlayer_module_default.covered, className),
2345
2464
  "aria-label": labels.region,
2346
- ref: (node) => {
2347
- root.current = node;
2348
- if (typeof ref === "function") ref(node);
2349
- else if (ref) ref.current = node;
2350
- },
2465
+ ref: forkRef(root, ref),
2351
2466
  ...rest,
2352
2467
  children: [
2353
2468
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: VideoPlayer_module_default.frame, children: [
@@ -2512,6 +2627,7 @@ exports.ChipGroup = ChipGroup;
2512
2627
  exports.ConfirmDialog = ConfirmDialog;
2513
2628
  exports.Container = Container;
2514
2629
  exports.CountButton = CountButton;
2630
+ exports.DataTable = DataTable;
2515
2631
  exports.DateTimePicker = DateTimePicker;
2516
2632
  exports.Divider = Divider;
2517
2633
  exports.EmptyState = EmptyState;