@mond-design-system/react 4.10.1 → 4.11.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.d.cts CHANGED
@@ -1125,16 +1125,21 @@ interface ToastProviderProps {
1125
1125
  */
1126
1126
  declare function ToastProvider({ children, regionLabel, dismissLabel, }: ToastProviderProps): ReactElement;
1127
1127
 
1128
+ /** A component's own props, plus every prop the element it renders takes. */
1129
+ type Polymorphic<T extends ElementType, Own> = Own & {
1130
+ /** Element to render. Default div. */
1131
+ as?: T;
1132
+ } & Omit<ComponentPropsWithRef<T>, keyof Own | "as">;
1133
+
1128
1134
  type StackGap = "hairline" | "tight" | "base" | "loose" | "group" | "section";
1129
1135
  type StackAlign = "start" | "center" | "end" | "stretch";
1130
- interface StackProps extends HTMLAttributes<HTMLElement> {
1136
+ interface StackOwnProps {
1131
1137
  /** Space between children, on the gap scale. Default "base". */
1132
1138
  gap?: StackGap;
1133
1139
  /** Cross-axis alignment. Default "stretch". */
1134
1140
  align?: StackAlign;
1135
- /** Element to render. Default div. */
1136
- as?: ElementType;
1137
1141
  }
1142
+ type StackProps<T extends ElementType = "div"> = Polymorphic<T, StackOwnProps>;
1138
1143
  /**
1139
1144
  * Vertical flow. The parent owns spacing between siblings via gap —
1140
1145
  * children carry no outer margins. Token-bounded on purpose: no arbitrary
@@ -1147,12 +1152,12 @@ interface StackProps extends HTMLAttributes<HTMLElement> {
1147
1152
  * </Stack>
1148
1153
  * ```
1149
1154
  */
1150
- declare function Stack({ gap, align, as, className, ...rest }: StackProps): ReactElement;
1155
+ declare function Stack<T extends ElementType = "div">(props: StackProps<T>): ReactElement;
1151
1156
 
1152
1157
  type InlineGap = "hairline" | "tight" | "base" | "loose";
1153
1158
  type InlineAlign = "start" | "center" | "end" | "baseline";
1154
1159
  type InlineJustify = "start" | "center" | "end" | "between";
1155
- interface InlineProps extends HTMLAttributes<HTMLElement> {
1160
+ interface InlineOwnProps {
1156
1161
  /** Space between children, on the gap scale. Default "base". */
1157
1162
  gap?: InlineGap;
1158
1163
  /** Cross-axis alignment. Default "center". */
@@ -1161,9 +1166,8 @@ interface InlineProps extends HTMLAttributes<HTMLElement> {
1161
1166
  justify?: InlineJustify;
1162
1167
  /** Allow wrapping onto new lines. */
1163
1168
  wrap?: boolean;
1164
- /** Element to render. Default div. */
1165
- as?: ElementType;
1166
1169
  }
1170
+ type InlineProps<T extends ElementType = "div"> = Polymorphic<T, InlineOwnProps>;
1167
1171
  /**
1168
1172
  * Horizontal flow — Stack's row twin. Same token-bounded contract.
1169
1173
  *
@@ -1174,15 +1178,14 @@ interface InlineProps extends HTMLAttributes<HTMLElement> {
1174
1178
  * </Inline>
1175
1179
  * ```
1176
1180
  */
1177
- declare function Inline({ gap, align, justify, wrap, as, className, ...rest }: InlineProps): ReactElement;
1181
+ declare function Inline<T extends ElementType = "div">(props: InlineProps<T>): ReactElement;
1178
1182
 
1179
1183
  type ContainerWidth = "content" | "wide";
1180
- interface ContainerProps extends HTMLAttributes<HTMLElement> {
1184
+ interface ContainerOwnProps {
1181
1185
  /** content = reading column, wide = desktop shell. Default "content". */
1182
1186
  width?: ContainerWidth;
1183
- /** Element to render. Default div. */
1184
- as?: ElementType;
1185
1187
  }
1188
+ type ContainerProps<T extends ElementType = "div"> = Polymorphic<T, ContainerOwnProps>;
1186
1189
  /**
1187
1190
  * Centered max-width column with page-edge padding.
1188
1191
  *
@@ -1192,7 +1195,7 @@ interface ContainerProps extends HTMLAttributes<HTMLElement> {
1192
1195
  * </Container>
1193
1196
  * ```
1194
1197
  */
1195
- declare function Container({ width, as, className, ...rest }: ContainerProps): ReactElement;
1198
+ declare function Container<T extends ElementType = "div">(props: ContainerProps<T>): ReactElement;
1196
1199
 
1197
1200
  type CardVariant = "card" | "raised" | "sunken";
1198
1201
  interface CardProps extends Omit<HTMLAttributes<HTMLElement>, "onClick"> {
package/dist/index.d.ts CHANGED
@@ -1125,16 +1125,21 @@ interface ToastProviderProps {
1125
1125
  */
1126
1126
  declare function ToastProvider({ children, regionLabel, dismissLabel, }: ToastProviderProps): ReactElement;
1127
1127
 
1128
+ /** A component's own props, plus every prop the element it renders takes. */
1129
+ type Polymorphic<T extends ElementType, Own> = Own & {
1130
+ /** Element to render. Default div. */
1131
+ as?: T;
1132
+ } & Omit<ComponentPropsWithRef<T>, keyof Own | "as">;
1133
+
1128
1134
  type StackGap = "hairline" | "tight" | "base" | "loose" | "group" | "section";
1129
1135
  type StackAlign = "start" | "center" | "end" | "stretch";
1130
- interface StackProps extends HTMLAttributes<HTMLElement> {
1136
+ interface StackOwnProps {
1131
1137
  /** Space between children, on the gap scale. Default "base". */
1132
1138
  gap?: StackGap;
1133
1139
  /** Cross-axis alignment. Default "stretch". */
1134
1140
  align?: StackAlign;
1135
- /** Element to render. Default div. */
1136
- as?: ElementType;
1137
1141
  }
1142
+ type StackProps<T extends ElementType = "div"> = Polymorphic<T, StackOwnProps>;
1138
1143
  /**
1139
1144
  * Vertical flow. The parent owns spacing between siblings via gap —
1140
1145
  * children carry no outer margins. Token-bounded on purpose: no arbitrary
@@ -1147,12 +1152,12 @@ interface StackProps extends HTMLAttributes<HTMLElement> {
1147
1152
  * </Stack>
1148
1153
  * ```
1149
1154
  */
1150
- declare function Stack({ gap, align, as, className, ...rest }: StackProps): ReactElement;
1155
+ declare function Stack<T extends ElementType = "div">(props: StackProps<T>): ReactElement;
1151
1156
 
1152
1157
  type InlineGap = "hairline" | "tight" | "base" | "loose";
1153
1158
  type InlineAlign = "start" | "center" | "end" | "baseline";
1154
1159
  type InlineJustify = "start" | "center" | "end" | "between";
1155
- interface InlineProps extends HTMLAttributes<HTMLElement> {
1160
+ interface InlineOwnProps {
1156
1161
  /** Space between children, on the gap scale. Default "base". */
1157
1162
  gap?: InlineGap;
1158
1163
  /** Cross-axis alignment. Default "center". */
@@ -1161,9 +1166,8 @@ interface InlineProps extends HTMLAttributes<HTMLElement> {
1161
1166
  justify?: InlineJustify;
1162
1167
  /** Allow wrapping onto new lines. */
1163
1168
  wrap?: boolean;
1164
- /** Element to render. Default div. */
1165
- as?: ElementType;
1166
1169
  }
1170
+ type InlineProps<T extends ElementType = "div"> = Polymorphic<T, InlineOwnProps>;
1167
1171
  /**
1168
1172
  * Horizontal flow — Stack's row twin. Same token-bounded contract.
1169
1173
  *
@@ -1174,15 +1178,14 @@ interface InlineProps extends HTMLAttributes<HTMLElement> {
1174
1178
  * </Inline>
1175
1179
  * ```
1176
1180
  */
1177
- declare function Inline({ gap, align, justify, wrap, as, className, ...rest }: InlineProps): ReactElement;
1181
+ declare function Inline<T extends ElementType = "div">(props: InlineProps<T>): ReactElement;
1178
1182
 
1179
1183
  type ContainerWidth = "content" | "wide";
1180
- interface ContainerProps extends HTMLAttributes<HTMLElement> {
1184
+ interface ContainerOwnProps {
1181
1185
  /** content = reading column, wide = desktop shell. Default "content". */
1182
1186
  width?: ContainerWidth;
1183
- /** Element to render. Default div. */
1184
- as?: ElementType;
1185
1187
  }
1188
+ type ContainerProps<T extends ElementType = "div"> = Polymorphic<T, ContainerOwnProps>;
1186
1189
  /**
1187
1190
  * Centered max-width column with page-edge padding.
1188
1191
  *
@@ -1192,7 +1195,7 @@ interface ContainerProps extends HTMLAttributes<HTMLElement> {
1192
1195
  * </Container>
1193
1196
  * ```
1194
1197
  */
1195
- declare function Container({ width, as, className, ...rest }: ContainerProps): ReactElement;
1198
+ declare function Container<T extends ElementType = "div">(props: ContainerProps<T>): ReactElement;
1196
1199
 
1197
1200
  type CardVariant = "card" | "raised" | "sunken";
1198
1201
  interface CardProps extends Omit<HTMLAttributes<HTMLElement>, "onClick"> {
package/dist/index.js CHANGED
@@ -148,6 +148,8 @@ function Button({
148
148
  children,
149
149
  ...rest
150
150
  }) {
151
+ const glyph = iconOnly && children != null ? /* @__PURE__ */ jsx("span", { className: Button_module_default.slot, children }) : children;
152
+ const body = loading && iconOnly ? null : glyph;
151
153
  const Element = as ?? (href !== void 0 ? "a" : "button");
152
154
  const isButton = Element === "button";
153
155
  const own = isButton ? { type, disabled: disabled || loading } : { href };
@@ -169,7 +171,7 @@ function Button({
169
171
  ...rest,
170
172
  children: [
171
173
  loading ? /* @__PURE__ */ jsx("span", { className: Button_module_default.slot, children: /* @__PURE__ */ jsx(Spinner, { size: ICON_PX[size], label: "", "aria-hidden": "true" }) }) : iconLeft ? /* @__PURE__ */ jsx("span", { className: Button_module_default.slot, children: iconLeft }) : null,
172
- children,
174
+ body,
173
175
  !loading && iconRight ? /* @__PURE__ */ jsx("span", { className: Button_module_default.slot, children: iconRight }) : null
174
176
  ]
175
177
  }
@@ -383,10 +385,10 @@ function CountButton({
383
385
  );
384
386
  }
385
387
  function CloseGlyph({ className }) {
386
- return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", className, children: /* @__PURE__ */ jsx("path", { d: "M4 4l8 8M12 4l-8 8", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round" }) });
388
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", width: "1em", height: "1em", "aria-hidden": "true", className, children: /* @__PURE__ */ jsx("path", { d: "M4 4l8 8M12 4l-8 8", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round" }) });
387
389
  }
388
390
  function ChevronLeftGlyph({ className }) {
389
- return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", className, children: /* @__PURE__ */ jsx(
391
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", width: "1em", height: "1em", "aria-hidden": "true", className, children: /* @__PURE__ */ jsx(
390
392
  "path",
391
393
  {
392
394
  d: "M10 3l-5 5 5 5",
@@ -399,7 +401,7 @@ function ChevronLeftGlyph({ className }) {
399
401
  ) });
400
402
  }
401
403
  function ChevronRightGlyph({ className }) {
402
- return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", className, children: /* @__PURE__ */ jsx(
404
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", width: "1em", height: "1em", "aria-hidden": "true", className, children: /* @__PURE__ */ jsx(
403
405
  "path",
404
406
  {
405
407
  d: "M6 3l5 5-5 5",
@@ -412,7 +414,7 @@ function ChevronRightGlyph({ className }) {
412
414
  ) });
413
415
  }
414
416
  function Magnifier({ className, children }) {
415
- return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", className, children: /* @__PURE__ */ jsxs("g", { fill: "none", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", children: [
417
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", width: "1em", height: "1em", "aria-hidden": "true", className, children: /* @__PURE__ */ jsxs("g", { fill: "none", stroke: "currentColor", strokeWidth: "1.75", strokeLinecap: "round", children: [
416
418
  /* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "4.25" }),
417
419
  /* @__PURE__ */ jsx("path", { d: "M10.2 10.2L14 14" }),
418
420
  children
@@ -425,35 +427,35 @@ function ZoomOutGlyph({ className }) {
425
427
  return /* @__PURE__ */ jsx(Magnifier, { className, children: /* @__PURE__ */ jsx("path", { d: "M4.75 7h4.5" }) });
426
428
  }
427
429
  function PlayGlyph({ className }) {
428
- return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", className, children: /* @__PURE__ */ jsx("path", { d: "M5 3.2l7.5 4.8L5 12.8z", fill: "currentColor" }) });
430
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", width: "1em", height: "1em", "aria-hidden": "true", className, children: /* @__PURE__ */ jsx("path", { d: "M5 3.2l7.5 4.8L5 12.8z", fill: "currentColor" }) });
429
431
  }
430
432
  function PauseGlyph({ className }) {
431
- return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", className, children: /* @__PURE__ */ jsx("path", { d: "M4.5 3h2.25v10H4.5zM9.25 3h2.25v10H9.25z", fill: "currentColor" }) });
433
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", width: "1em", height: "1em", "aria-hidden": "true", className, children: /* @__PURE__ */ jsx("path", { d: "M4.5 3h2.25v10H4.5zM9.25 3h2.25v10H9.25z", fill: "currentColor" }) });
432
434
  }
433
435
  function Speaker() {
434
436
  return /* @__PURE__ */ jsx("path", { d: "M2.5 6.25h2.25L8 3.4v9.2L4.75 9.75H2.5z", fill: "currentColor", stroke: "none" });
435
437
  }
436
438
  function VolumeGlyph({ className }) {
437
- return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", className, children: /* @__PURE__ */ jsxs("g", { fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: [
439
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", width: "1em", height: "1em", "aria-hidden": "true", className, children: /* @__PURE__ */ jsxs("g", { fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: [
438
440
  /* @__PURE__ */ jsx(Speaker, {}),
439
441
  /* @__PURE__ */ jsx("path", { d: "M10.5 5.75a3.25 3.25 0 010 4.5" }),
440
442
  /* @__PURE__ */ jsx("path", { d: "M12.5 3.9a5.75 5.75 0 010 8.2" })
441
443
  ] }) });
442
444
  }
443
445
  function VolumeOffGlyph({ className }) {
444
- return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", className, children: /* @__PURE__ */ jsxs("g", { fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: [
446
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", width: "1em", height: "1em", "aria-hidden": "true", className, children: /* @__PURE__ */ jsxs("g", { fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: [
445
447
  /* @__PURE__ */ jsx(Speaker, {}),
446
448
  /* @__PURE__ */ jsx("path", { d: "M10.75 6.25l3.5 3.5M14.25 6.25l-3.5 3.5" })
447
449
  ] }) });
448
450
  }
449
451
  function CaptionsGlyph({ className }) {
450
- return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", className, children: /* @__PURE__ */ jsxs("g", { fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: [
452
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", width: "1em", height: "1em", "aria-hidden": "true", className, children: /* @__PURE__ */ jsxs("g", { fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", children: [
451
453
  /* @__PURE__ */ jsx("rect", { x: "1.75", y: "3.25", width: "12.5", height: "9.5", rx: "2" }),
452
454
  /* @__PURE__ */ jsx("path", { d: "M6.25 6.75a2 2 0 100 2.5M11.25 6.75a2 2 0 100 2.5" })
453
455
  ] }) });
454
456
  }
455
457
  function FullscreenGlyph({ className }) {
456
- return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", className, children: /* @__PURE__ */ jsx(
458
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", width: "1em", height: "1em", "aria-hidden": "true", className, children: /* @__PURE__ */ jsx(
457
459
  "path",
458
460
  {
459
461
  d: "M6 2.5H2.5V6M10 2.5h3.5V6M6 13.5H2.5V10M10 13.5h3.5V10",
@@ -466,7 +468,7 @@ function FullscreenGlyph({ className }) {
466
468
  ) });
467
469
  }
468
470
  function FullscreenExitGlyph({ className }) {
469
- return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", className, children: /* @__PURE__ */ jsx(
471
+ return /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", width: "1em", height: "1em", "aria-hidden": "true", className, children: /* @__PURE__ */ jsx(
470
472
  "path",
471
473
  {
472
474
  d: "M2.5 6H6V2.5M13.5 6H10V2.5M2.5 10H6v3.5M13.5 10H10v3.5",
@@ -1784,13 +1786,14 @@ function ToastProvider({
1784
1786
  var Stack_module_default = { "stack": "mds-Stack__stack", "gap-hairline": "mds-Stack__gap-hairline", "gap-tight": "mds-Stack__gap-tight", "gap-base": "mds-Stack__gap-base", "gap-loose": "mds-Stack__gap-loose", "gap-group": "mds-Stack__gap-group", "gap-section": "mds-Stack__gap-section", "align-start": "mds-Stack__align-start", "align-center": "mds-Stack__align-center", "align-end": "mds-Stack__align-end", "align-stretch": "mds-Stack__align-stretch" };
1785
1787
 
1786
1788
  // src/components/Stack/Stack.tsx
1787
- function Stack({
1788
- gap = "base",
1789
- align = "stretch",
1790
- as = "div",
1791
- className,
1792
- ...rest
1793
- }) {
1789
+ function Stack(props) {
1790
+ const {
1791
+ gap = "base",
1792
+ align = "stretch",
1793
+ as = "div",
1794
+ className,
1795
+ ...rest
1796
+ } = props;
1794
1797
  return createElement(as, {
1795
1798
  className: cx(Stack_module_default.stack, Stack_module_default[`gap-${gap}`], Stack_module_default[`align-${align}`], className),
1796
1799
  ...rest
@@ -1801,15 +1804,16 @@ function Stack({
1801
1804
  var Inline_module_default = { "inline": "mds-Inline__inline", "gap-hairline": "mds-Inline__gap-hairline", "gap-tight": "mds-Inline__gap-tight", "gap-base": "mds-Inline__gap-base", "gap-loose": "mds-Inline__gap-loose", "align-start": "mds-Inline__align-start", "align-center": "mds-Inline__align-center", "align-end": "mds-Inline__align-end", "align-baseline": "mds-Inline__align-baseline", "justify-start": "mds-Inline__justify-start", "justify-center": "mds-Inline__justify-center", "justify-end": "mds-Inline__justify-end", "justify-between": "mds-Inline__justify-between", "wrap": "mds-Inline__wrap" };
1802
1805
 
1803
1806
  // src/components/Inline/Inline.tsx
1804
- function Inline({
1805
- gap = "base",
1806
- align = "center",
1807
- justify = "start",
1808
- wrap = false,
1809
- as = "div",
1810
- className,
1811
- ...rest
1812
- }) {
1807
+ function Inline(props) {
1808
+ const {
1809
+ gap = "base",
1810
+ align = "center",
1811
+ justify = "start",
1812
+ wrap = false,
1813
+ as = "div",
1814
+ className,
1815
+ ...rest
1816
+ } = props;
1813
1817
  return createElement(as, {
1814
1818
  className: cx(
1815
1819
  Inline_module_default.inline,
@@ -1827,12 +1831,8 @@ function Inline({
1827
1831
  var Container_module_default = { "container": "mds-Container__container", "width-content": "mds-Container__width-content", "width-wide": "mds-Container__width-wide" };
1828
1832
 
1829
1833
  // src/components/Container/Container.tsx
1830
- function Container({
1831
- width = "content",
1832
- as = "div",
1833
- className,
1834
- ...rest
1835
- }) {
1834
+ function Container(props) {
1835
+ const { width = "content", as = "div", className, ...rest } = props;
1836
1836
  return createElement(as, {
1837
1837
  className: cx(Container_module_default.container, Container_module_default[`width-${width}`], className),
1838
1838
  ...rest