@mond-design-system/react 4.0.0 → 4.1.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
@@ -1229,7 +1229,7 @@ function Switch({
1229
1229
  }
1230
1230
 
1231
1231
  // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/SegmentedControl/SegmentedControl.module.css?mds-scoped
1232
- var SegmentedControl_module_default = { "group": "mds-SegmentedControl__group", "segment": "mds-SegmentedControl__segment", "fullWidth": "mds-SegmentedControl__fullWidth", "face": "mds-SegmentedControl__face", "input": "mds-SegmentedControl__input" };
1232
+ var SegmentedControl_module_default = { "group": "mds-SegmentedControl__group", "size-md": "mds-SegmentedControl__size-md", "face": "mds-SegmentedControl__face", "size-sm": "mds-SegmentedControl__size-sm", "bare": "mds-SegmentedControl__bare", "segment": "mds-SegmentedControl__segment", "fullWidth": "mds-SegmentedControl__fullWidth", "input": "mds-SegmentedControl__input" };
1233
1233
  function SegmentedControl({
1234
1234
  label,
1235
1235
  options,
@@ -1237,24 +1237,40 @@ function SegmentedControl({
1237
1237
  onChange,
1238
1238
  disabled = false,
1239
1239
  fullWidth = false,
1240
+ size = "md",
1241
+ bare = false,
1240
1242
  className
1241
1243
  }) {
1242
1244
  const name = react.useId();
1243
- return /* @__PURE__ */ jsxRuntime.jsx("div", { role: "radiogroup", "aria-label": label, className: cx(SegmentedControl_module_default.group, fullWidth && SegmentedControl_module_default.fullWidth, className), children: options.map((option) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: SegmentedControl_module_default.segment, children: [
1244
- /* @__PURE__ */ jsxRuntime.jsx(
1245
- "input",
1246
- {
1247
- type: "radio",
1248
- name,
1249
- value: option.value,
1250
- checked: option.value === value,
1251
- onChange: () => onChange(option.value),
1252
- disabled,
1253
- className: SegmentedControl_module_default.input
1254
- }
1255
- ),
1256
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: SegmentedControl_module_default.face, children: option.label })
1257
- ] }, option.value)) });
1245
+ return /* @__PURE__ */ jsxRuntime.jsx(
1246
+ "div",
1247
+ {
1248
+ role: "radiogroup",
1249
+ "aria-label": label,
1250
+ className: cx(
1251
+ SegmentedControl_module_default.group,
1252
+ SegmentedControl_module_default[`size-${size}`],
1253
+ fullWidth && SegmentedControl_module_default.fullWidth,
1254
+ bare && SegmentedControl_module_default.bare,
1255
+ className
1256
+ ),
1257
+ children: options.map((option) => /* @__PURE__ */ jsxRuntime.jsxs("label", { className: SegmentedControl_module_default.segment, children: [
1258
+ /* @__PURE__ */ jsxRuntime.jsx(
1259
+ "input",
1260
+ {
1261
+ type: "radio",
1262
+ name,
1263
+ value: option.value,
1264
+ checked: option.value === value,
1265
+ onChange: () => onChange(option.value),
1266
+ disabled,
1267
+ className: SegmentedControl_module_default.input
1268
+ }
1269
+ ),
1270
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: SegmentedControl_module_default.face, children: option.label })
1271
+ ] }, option.value))
1272
+ }
1273
+ );
1258
1274
  }
1259
1275
 
1260
1276
  // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/SearchField/SearchField.module.css?mds-scoped
@@ -1469,7 +1485,7 @@ function TabPanel({ value, className, children, ...rest }) {
1469
1485
  }
1470
1486
 
1471
1487
  // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Toast/Toast.module.css?mds-scoped
1472
- var Toast_module_default = { "viewport": "mds-Toast__viewport", "toast": "mds-Toast__toast", "tone-success": "mds-Toast__tone-success", "tone-danger": "mds-Toast__tone-danger", "body": "mds-Toast__body", "title": "mds-Toast__title", "description": "mds-Toast__description", "close": "mds-Toast__close mds-hit-area__hitArea", "closeGlyph": "mds-Toast__closeGlyph" };
1488
+ var Toast_module_default = { "viewport": "mds-Toast__viewport", "toast": "mds-Toast__toast", "tone-success": "mds-Toast__tone-success", "tone-danger": "mds-Toast__tone-danger", "body": "mds-Toast__body", "title": "mds-Toast__title", "description": "mds-Toast__description", "close": "mds-Toast__close mds-hit-area__hitArea", "closeGlyph": "mds-Toast__closeGlyph", "action": "mds-Toast__action mds-hit-area__hitArea" };
1473
1489
  var ToastContext = react.createContext(null);
1474
1490
  function useToast() {
1475
1491
  const context = react.useContext(ToastContext);
@@ -1483,13 +1499,20 @@ function ToastProvider({
1483
1499
  }) {
1484
1500
  const [toasts, setToasts] = react.useState([]);
1485
1501
  const nextId = react.useRef(1);
1502
+ const leaving = react.useRef(/* @__PURE__ */ new Map());
1486
1503
  const dismiss = react.useCallback((id) => {
1487
1504
  setToasts((current) => current.filter((entry) => entry.id !== id));
1505
+ const said = leaving.current.get(id);
1506
+ if (said !== void 0) {
1507
+ leaving.current.delete(id);
1508
+ said();
1509
+ }
1488
1510
  }, []);
1489
1511
  const toast = react.useCallback(
1490
- ({ title, description, tone = "neutral", duration = 5e3 }) => {
1512
+ ({ title, description, tone = "neutral", duration = 5e3, action, onDismiss }) => {
1491
1513
  const id = nextId.current++;
1492
- setToasts((current) => [...current, { id, title, description, tone }]);
1514
+ if (onDismiss !== void 0) leaving.current.set(id, onDismiss);
1515
+ setToasts((current) => [...current, { id, title, description, tone, action }]);
1493
1516
  if (duration > 0) setTimeout(() => dismiss(id), duration);
1494
1517
  return id;
1495
1518
  },
@@ -1503,6 +1526,18 @@ function ToastProvider({
1503
1526
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: Toast_module_default.title, children: entry.title }),
1504
1527
  entry.description !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: Toast_module_default.description, children: entry.description })
1505
1528
  ] }),
1529
+ entry.action !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(
1530
+ "button",
1531
+ {
1532
+ type: "button",
1533
+ className: Toast_module_default.action,
1534
+ onClick: () => {
1535
+ entry.action?.onClick();
1536
+ dismiss(entry.id);
1537
+ },
1538
+ children: entry.action.label
1539
+ }
1540
+ ),
1506
1541
  /* @__PURE__ */ jsxRuntime.jsx(
1507
1542
  "button",
1508
1543
  {
@@ -1720,9 +1755,9 @@ function ScreenContent({ children, flush = false, className, ref, ...rest }) {
1720
1755
 
1721
1756
  // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/AppBar/AppBar.module.css?mds-scoped
1722
1757
  var AppBar_module_default = { "bar": "mds-AppBar__bar", "title": "mds-AppBar__title", "text": "mds-AppBar__text", "subtitle": "mds-AppBar__subtitle", "slot": "mds-AppBar__slot", "trailing": "mds-AppBar__trailing" };
1723
- function AppBar({ title, subtitle, leading, trailing }) {
1758
+ function AppBar({ title, subtitle, leading, trailing, className, ref, ...rest }) {
1724
1759
  const heading = title ? /* @__PURE__ */ jsxRuntime.jsx("h1", { className: AppBar_module_default.title, children: title }) : null;
1725
- return /* @__PURE__ */ jsxRuntime.jsxs("header", { className: AppBar_module_default.bar, children: [
1760
+ return /* @__PURE__ */ jsxRuntime.jsxs("header", { ref, className: cx(AppBar_module_default.bar, className), ...rest, children: [
1726
1761
  leading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: AppBar_module_default.slot, children: leading }) : null,
1727
1762
  subtitle != null ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: AppBar_module_default.text, children: [
1728
1763
  heading,
@@ -1737,14 +1772,23 @@ var TabBar_module_default = { "bar": "mds-TabBar__bar", "item": "mds-TabBar__ite
1737
1772
  function TabBar({ label, children }) {
1738
1773
  return /* @__PURE__ */ jsxRuntime.jsx("nav", { "aria-label": label, className: TabBar_module_default.bar, children });
1739
1774
  }
1740
- function TabBarItem({ label, icon, href, onClick, active = false, badge = false, as }) {
1775
+ function TabBarItem({
1776
+ label,
1777
+ icon,
1778
+ href,
1779
+ onClick,
1780
+ active = false,
1781
+ badge = false,
1782
+ as,
1783
+ hideLabel = false
1784
+ }) {
1741
1785
  const className = cx(TabBar_module_default.item, active && TabBar_module_default.active);
1742
1786
  const content = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1743
1787
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: TabBar_module_default.icon, "aria-hidden": "true", children: [
1744
1788
  icon,
1745
1789
  badge ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: TabBar_module_default.badge, "data-testid": "mds-tabbar-badge" }) : null
1746
1790
  ] }),
1747
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: TabBar_module_default.label, children: label })
1791
+ hideLabel ? /* @__PURE__ */ jsxRuntime.jsx(VisuallyHidden, { children: label }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: TabBar_module_default.label, children: label })
1748
1792
  ] });
1749
1793
  if (href !== void 0) {
1750
1794
  const Element = as ?? "a";