@mond-design-system/react 4.12.0 → 5.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
@@ -3,6 +3,7 @@
3
3
  var react = require('react');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var reactDom = require('react-dom');
6
+ var dom = require('@floating-ui/dom');
6
7
 
7
8
  // src/internal/cx.ts
8
9
  function cx(...parts) {
@@ -80,15 +81,15 @@ function Heading({
80
81
  // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Spinner/Spinner.module.css?mds-scoped
81
82
  var Spinner_module_default = { "spinner": "mds-Spinner__spinner"};
82
83
  function Spinner({
83
- size = 20,
84
+ size: size2 = 20,
84
85
  label,
85
86
  className,
86
87
  style,
87
88
  ...rest
88
89
  }) {
89
90
  const vars = {
90
- "--spinner-size": `${size}px`,
91
- "--spinner-border": `${Math.max(2, Math.round(size / 10))}px`
91
+ "--spinner-size": `${size2}px`,
92
+ "--spinner-border": `${Math.max(2, Math.round(size2 / 10))}px`
92
93
  };
93
94
  return /* @__PURE__ */ jsxRuntime.jsx(
94
95
  "span",
@@ -110,7 +111,7 @@ function IconProvider({ render, children }) {
110
111
  }
111
112
  var SIZE_PX = { sm: 16, md: 20, lg: 24 };
112
113
  var warned = /* @__PURE__ */ new Set();
113
- function Icon({ name, size, label, className, ...rest }) {
114
+ function Icon({ name, size: size2, label, className, ...rest }) {
114
115
  const render = react.useContext(IconContext);
115
116
  if (render === null && !warned.has(name)) {
116
117
  warned.add(name);
@@ -121,10 +122,10 @@ function Icon({ name, size, label, className, ...rest }) {
121
122
  return /* @__PURE__ */ jsxRuntime.jsx(
122
123
  "span",
123
124
  {
124
- className: cx(Icon_module_default.icon, Icon_module_default[`size-${size ?? "slot"}`], className),
125
+ className: cx(Icon_module_default.icon, Icon_module_default[`size-${size2 ?? "slot"}`], className),
125
126
  ...label ? { role: "img", "aria-label": label } : { "aria-hidden": true },
126
127
  ...rest,
127
- children: render?.(name, { size: size === void 0 ? void 0 : SIZE_PX[size] })
128
+ children: render?.(name, { size: size2 === void 0 ? void 0 : SIZE_PX[size2] })
128
129
  }
129
130
  );
130
131
  }
@@ -134,7 +135,7 @@ var Button_module_default = { "button": "mds-Button__button", "size-sm": "mds-Bu
134
135
  var ICON_PX = { sm: 16, md: 20, lg: 24 };
135
136
  function Button({
136
137
  variant = "primary",
137
- size = "md",
138
+ size: size2 = "md",
138
139
  shape,
139
140
  onMedia = false,
140
141
  iconLeft,
@@ -161,7 +162,7 @@ function Button({
161
162
  className: cx(
162
163
  Button_module_default.button,
163
164
  Button_module_default[`variant-${variant}`],
164
- Button_module_default[`size-${size}`],
165
+ Button_module_default[`size-${size2}`],
165
166
  fullWidth && Button_module_default.fullWidth,
166
167
  iconOnly && Button_module_default["icon-only"],
167
168
  shape !== void 0 && Button_module_default[`shape-${shape}`],
@@ -172,7 +173,7 @@ function Button({
172
173
  ...own,
173
174
  ...rest,
174
175
  children: [
175
- loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: Button_module_default.slot, children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: ICON_PX[size], label: "", "aria-hidden": "true" }) }) : iconLeft ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: Button_module_default.slot, children: iconLeft }) : null,
176
+ loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: Button_module_default.slot, children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { size: ICON_PX[size2], label: "", "aria-hidden": "true" }) }) : iconLeft ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: Button_module_default.slot, children: iconLeft }) : null,
176
177
  body,
177
178
  !loading && iconRight ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: Button_module_default.slot, children: iconRight }) : null
178
179
  ]
@@ -184,7 +185,7 @@ function Button({
184
185
  var Link_module_default = { "link": "mds-Link__link", "variant-inline": "mds-Link__variant-inline", "variant-standalone": "mds-Link__variant-standalone", "variant-plain": "mds-Link__variant-plain", "size-xs": "mds-Link__size-xs", "size-sm": "mds-Link__size-sm", "size-base": "mds-Link__size-base", "size-lg": "mds-Link__size-lg", "size-xl": "mds-Link__size-xl" };
185
186
  function Link({
186
187
  variant = "inline",
187
- size,
188
+ size: size2,
188
189
  external = false,
189
190
  as,
190
191
  ...rest
@@ -199,7 +200,7 @@ function Link({
199
200
  className: cx(
200
201
  Link_module_default.link,
201
202
  Link_module_default[`variant-${variant}`],
202
- size && Link_module_default[`size-${size}`],
203
+ size2 && Link_module_default[`size-${size2}`],
203
204
  className
204
205
  ),
205
206
  ...externalProps,
@@ -220,7 +221,7 @@ function initials(name) {
220
221
  function Avatar({
221
222
  name,
222
223
  src,
223
- size = "md",
224
+ size: size2 = "md",
224
225
  tone,
225
226
  decorative = false,
226
227
  className,
@@ -231,7 +232,7 @@ function Avatar({
231
232
  {
232
233
  className: cx(
233
234
  Avatar_module_default.avatar,
234
- Avatar_module_default[`size-${size}`],
235
+ Avatar_module_default[`size-${size2}`],
235
236
  tone !== void 0 && Avatar_module_default[`tone-${tone}`],
236
237
  className
237
238
  ),
@@ -255,7 +256,7 @@ var AvatarGroup_module_default = { "group": "mds-AvatarGroup__group", "item": "m
255
256
  function AvatarGroup({
256
257
  children,
257
258
  max = 4,
258
- size = "md",
259
+ size: size2 = "md",
259
260
  overflowLabel,
260
261
  className,
261
262
  ...rest
@@ -268,7 +269,7 @@ function AvatarGroup({
268
269
  hidden > 0 && /* @__PURE__ */ jsxRuntime.jsxs(
269
270
  "span",
270
271
  {
271
- className: cx(AvatarGroup_module_default.item, AvatarGroup_module_default.overflow, AvatarGroup_module_default[`size-${size}`]),
272
+ className: cx(AvatarGroup_module_default.item, AvatarGroup_module_default.overflow, AvatarGroup_module_default[`size-${size2}`]),
272
273
  "aria-label": overflowLabel(hidden),
273
274
  children: [
274
275
  "+",
@@ -519,7 +520,7 @@ function Field({ label, children, hint, error, required = false, className }) {
519
520
 
520
521
  // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Select/Select.module.css?mds-scoped
521
522
  var Select_module_default = { "wrap": "mds-Select__wrap", "select": "mds-Select__select", "size-sm": "mds-Select__size-sm", "size-md": "mds-Select__size-md", "size-lg": "mds-Select__size-lg", "chevron": "mds-Select__chevron" };
522
- function Select({ size = "md", className, children, ...rest }) {
523
+ function Select({ size: size2 = "md", className, children, ...rest }) {
523
524
  const field = useFieldContext();
524
525
  return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: Select_module_default.wrap, children: [
525
526
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -528,7 +529,7 @@ function Select({ size = "md", className, children, ...rest }) {
528
529
  id: rest.id ?? field?.id,
529
530
  "aria-describedby": rest["aria-describedby"] ?? field?.describedBy,
530
531
  "aria-invalid": rest["aria-invalid"] ?? (field?.invalid || void 0),
531
- className: cx(Select_module_default.select, Select_module_default[`size-${size}`], className),
532
+ className: cx(Select_module_default.select, Select_module_default[`size-${size2}`], className),
532
533
  ...rest,
533
534
  children
534
535
  }
@@ -542,7 +543,7 @@ var OverlayHistoryContext = react.createContext(null);
542
543
  var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
543
544
  function useOverlay(options) {
544
545
  const ref = react.useRef(null);
545
- const { open, onClose } = options;
546
+ const { open, onClose, lockScroll = true } = options;
546
547
  const close = react.useRef(onClose);
547
548
  react.useEffect(() => {
548
549
  close.current = onClose;
@@ -583,13 +584,13 @@ function useOverlay(options) {
583
584
  };
584
585
  document.addEventListener("keydown", onKeyDown);
585
586
  const bodyOverflow = document.body.style.overflow;
586
- document.body.style.overflow = "hidden";
587
+ if (lockScroll) document.body.style.overflow = "hidden";
587
588
  return () => {
588
589
  document.removeEventListener("keydown", onKeyDown);
589
- document.body.style.overflow = bodyOverflow;
590
+ if (lockScroll) document.body.style.overflow = bodyOverflow;
590
591
  previous?.focus();
591
592
  };
592
- }, [open]);
593
+ }, [open, lockScroll]);
593
594
  return ref;
594
595
  }
595
596
  function usePresence(open, durationMs) {
@@ -1094,38 +1095,68 @@ function ProgressBar({
1094
1095
  );
1095
1096
  }
1096
1097
 
1098
+ // src/internal/forkRef.ts
1099
+ function forkRef(own, given) {
1100
+ return (node) => {
1101
+ own.current = node;
1102
+ if (typeof given === "function") given(node);
1103
+ else if (given != null) given.current = node;
1104
+ };
1105
+ }
1106
+
1097
1107
  // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Input/Input.module.css?mds-scoped
1098
- var Input_module_default = { "input": "mds-Input__input", "size-sm": "mds-Input__size-sm", "size-md": "mds-Input__size-md", "size-lg": "mds-Input__size-lg", "iconWrap": "mds-Input__iconWrap", "icon": "mds-Input__icon", "iconLeft": "mds-Input__iconLeft", "iconRight": "mds-Input__iconRight", "with-icon-left": "mds-Input__with-icon-left", "with-icon-right": "mds-Input__with-icon-right" };
1108
+ var Input_module_default = { "input": "mds-Input__input", "own-clear": "mds-Input__own-clear", "size-sm": "mds-Input__size-sm", "size-md": "mds-Input__size-md", "size-lg": "mds-Input__size-lg", "iconWrap": "mds-Input__iconWrap", "icon": "mds-Input__icon", "slot-sm": "mds-Input__slot-sm", "slot-md": "mds-Input__slot-md", "slot-lg": "mds-Input__slot-lg", "iconLeft": "mds-Input__iconLeft", "iconRight": "mds-Input__iconRight", "with-icon-left": "mds-Input__with-icon-left", "with-icon-right": "mds-Input__with-icon-right", "clear": "mds-Input__clear mds-hit-area__hitArea", "clearGlyph": "mds-Input__clearGlyph" };
1099
1109
  function Input({
1100
- size = "md",
1110
+ size: size2 = "md",
1101
1111
  invalid,
1102
1112
  iconLeft,
1103
1113
  iconRight,
1114
+ onClear,
1115
+ clearLabel,
1104
1116
  className,
1117
+ ref,
1105
1118
  ...rest
1106
1119
  }) {
1107
1120
  const field = useFieldContext();
1121
+ const own = react.useRef(null);
1122
+ const [typedInto, setTypedInto] = react.useState(() => String(rest.defaultValue ?? "") !== "");
1123
+ const hasText = rest.value !== void 0 ? String(rest.value) !== "" : typedInto;
1124
+ const showClear = onClear != null && hasText;
1125
+ const handleChange = (event) => {
1126
+ if (onClear != null) setTypedInto(event.target.value !== "");
1127
+ rest.onChange?.(event);
1128
+ };
1129
+ const clear = () => {
1130
+ if (rest.value === void 0 && own.current != null) own.current.value = "";
1131
+ setTypedInto(false);
1132
+ own.current?.focus();
1133
+ onClear?.();
1134
+ };
1108
1135
  const input = /* @__PURE__ */ jsxRuntime.jsx(
1109
1136
  "input",
1110
1137
  {
1138
+ ref: forkRef(own, ref),
1111
1139
  id: rest.id ?? field?.id,
1112
1140
  "aria-describedby": rest["aria-describedby"] ?? field?.describedBy,
1113
1141
  "aria-invalid": rest["aria-invalid"] ?? ((invalid ?? field?.invalid) || void 0),
1114
1142
  className: cx(
1115
1143
  Input_module_default.input,
1116
- Input_module_default[`size-${size}`],
1144
+ Input_module_default[`size-${size2}`],
1117
1145
  iconLeft != null && Input_module_default["with-icon-left"],
1118
- iconRight != null && Input_module_default["with-icon-right"],
1146
+ (iconRight != null || showClear) && Input_module_default["with-icon-right"],
1147
+ onClear != null && Input_module_default["own-clear"],
1119
1148
  className
1120
1149
  ),
1121
- ...rest
1150
+ ...rest,
1151
+ onChange: handleChange
1122
1152
  }
1123
1153
  );
1124
- if (iconLeft == null && iconRight == null) return input;
1125
- return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: Input_module_default.iconWrap, children: [
1154
+ if (iconLeft == null && iconRight == null && onClear == null) return input;
1155
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cx(Input_module_default.iconWrap, Input_module_default[`slot-${size2}`]), children: [
1126
1156
  input,
1127
1157
  iconLeft != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx(Input_module_default.icon, Input_module_default.iconLeft), "aria-hidden": "true", children: iconLeft }),
1128
- iconRight != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx(Input_module_default.icon, Input_module_default.iconRight), "aria-hidden": "true", children: iconRight })
1158
+ iconRight != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx(Input_module_default.icon, Input_module_default.iconRight), "aria-hidden": "true", children: iconRight }),
1159
+ showClear && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", "aria-label": clearLabel, className: Input_module_default.clear, onClick: clear, children: /* @__PURE__ */ jsxRuntime.jsx(CloseGlyph, { className: Input_module_default.clearGlyph }) })
1129
1160
  ] });
1130
1161
  }
1131
1162
 
@@ -1197,15 +1228,6 @@ function Textarea({ rows = 3, showCount = false, className, ...rest }) {
1197
1228
  ] });
1198
1229
  }
1199
1230
 
1200
- // src/internal/forkRef.ts
1201
- function forkRef(own, given) {
1202
- return (node) => {
1203
- own.current = node;
1204
- if (typeof given === "function") given(node);
1205
- else if (given != null) given.current = node;
1206
- };
1207
- }
1208
-
1209
1231
  // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Checkbox/Checkbox.module.css?mds-scoped
1210
1232
  var Checkbox_module_default = { "root": "mds-Checkbox__root", "box": "mds-Checkbox__box mds-hit-area__hitArea", "bare": "mds-Checkbox__bare", "label": "mds-Checkbox__label" };
1211
1233
  function Checkbox({
@@ -1280,7 +1302,7 @@ function SegmentedControl({
1280
1302
  onChange,
1281
1303
  disabled = false,
1282
1304
  fullWidth = false,
1283
- size = "md",
1305
+ size: size2 = "md",
1284
1306
  bare = false,
1285
1307
  repick = false,
1286
1308
  className
@@ -1293,7 +1315,7 @@ function SegmentedControl({
1293
1315
  "aria-label": label,
1294
1316
  className: cx(
1295
1317
  SegmentedControl_module_default.group,
1296
- SegmentedControl_module_default[`size-${size}`],
1318
+ SegmentedControl_module_default[`size-${size2}`],
1297
1319
  fullWidth && SegmentedControl_module_default.fullWidth,
1298
1320
  bare && SegmentedControl_module_default.bare,
1299
1321
  className
@@ -1318,51 +1340,6 @@ function SegmentedControl({
1318
1340
  );
1319
1341
  }
1320
1342
 
1321
- // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/SearchField/SearchField.module.css?mds-scoped
1322
- var SearchField_module_default = { "wrap": "mds-SearchField__wrap", "glass": "mds-SearchField__glass", "input": "mds-SearchField__input", "clear": "mds-SearchField__clear mds-hit-area__hitArea", "clearGlyph": "mds-SearchField__clearGlyph" };
1323
- function SearchField({
1324
- label,
1325
- clearLabel,
1326
- value,
1327
- onChange,
1328
- className,
1329
- ...rest
1330
- }) {
1331
- return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cx(SearchField_module_default.wrap, className), children: [
1332
- /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", className: SearchField_module_default.glass, children: /* @__PURE__ */ jsxRuntime.jsx(
1333
- "path",
1334
- {
1335
- d: "M7 12a5 5 0 1 1 0-10 5 5 0 0 1 0 10Zm7 2-3.5-3.5",
1336
- fill: "none",
1337
- stroke: "currentColor",
1338
- strokeWidth: "1.5",
1339
- strokeLinecap: "round"
1340
- }
1341
- ) }),
1342
- /* @__PURE__ */ jsxRuntime.jsx(
1343
- "input",
1344
- {
1345
- type: "search",
1346
- "aria-label": label,
1347
- value,
1348
- onChange: (event) => onChange(event.target.value),
1349
- className: SearchField_module_default.input,
1350
- ...rest
1351
- }
1352
- ),
1353
- value !== "" && /* @__PURE__ */ jsxRuntime.jsx(
1354
- "button",
1355
- {
1356
- type: "button",
1357
- "aria-label": clearLabel,
1358
- className: SearchField_module_default.clear,
1359
- onClick: () => onChange(""),
1360
- children: /* @__PURE__ */ jsxRuntime.jsx(CloseGlyph, { className: SearchField_module_default.clearGlyph })
1361
- }
1362
- )
1363
- ] });
1364
- }
1365
-
1366
1343
  // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Scroller/Scroller.module.css?mds-scoped
1367
1344
  var Scroller_module_default = { "scroller": "mds-Scroller__scroller", "header": "mds-Scroller__header", "trailing": "mds-Scroller__trailing", "track": "mds-Scroller__track", "arrows": "mds-Scroller__arrows" };
1368
1345
  var STEP = 0.8;
@@ -1909,6 +1886,304 @@ function ModalBody({ children }) {
1909
1886
  function ModalFooter({ children }) {
1910
1887
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: Modal_module_default.footer, children });
1911
1888
  }
1889
+ var VIEWPORT_PAD = 8;
1890
+ var MIN_HEIGHT = 120;
1891
+ function useAnchoredPosition({
1892
+ open,
1893
+ anchorRef,
1894
+ floatingRef,
1895
+ placement,
1896
+ gap
1897
+ }) {
1898
+ react.useEffect(() => {
1899
+ const anchor = anchorRef.current;
1900
+ const floating = floatingRef.current;
1901
+ if (!open || anchor === null || floating === null) return;
1902
+ const update = () => {
1903
+ void dom.computePosition(anchor, floating, {
1904
+ placement,
1905
+ strategy: "fixed",
1906
+ middleware: [
1907
+ dom.offset(gap),
1908
+ // Order is load-bearing: choose the side first, then cap the height
1909
+ // to what that side has, then slide along the cross axis. Sizing
1910
+ // before flipping caps against the side being abandoned.
1911
+ dom.flip({ padding: VIEWPORT_PAD }),
1912
+ dom.size({
1913
+ padding: VIEWPORT_PAD,
1914
+ apply({ availableHeight, elements }) {
1915
+ elements.floating.style.maxHeight = `${Math.max(availableHeight, MIN_HEIGHT)}px`;
1916
+ }
1917
+ }),
1918
+ dom.shift({ padding: VIEWPORT_PAD })
1919
+ ]
1920
+ }).then(({ x, y, placement: resolved }) => {
1921
+ floating.style.left = `${x}px`;
1922
+ floating.style.top = `${y}px`;
1923
+ floating.dataset.placement = resolved;
1924
+ });
1925
+ };
1926
+ return dom.autoUpdate(anchor, floating, update);
1927
+ }, [open, anchorRef, floatingRef, placement, gap]);
1928
+ }
1929
+ function useDismissOnOutside(open, onDismiss, inside) {
1930
+ const latest = react.useRef({ onDismiss, inside });
1931
+ react.useEffect(() => {
1932
+ latest.current = { onDismiss, inside };
1933
+ });
1934
+ react.useEffect(() => {
1935
+ if (!open) return;
1936
+ const onPointerDown = (event) => {
1937
+ const target = event.target;
1938
+ if (!(target instanceof Node)) return;
1939
+ const { onDismiss: dismiss, inside: refs } = latest.current;
1940
+ if (refs.some((ref) => ref.current?.contains(target))) return;
1941
+ dismiss();
1942
+ };
1943
+ document.addEventListener("pointerdown", onPointerDown);
1944
+ return () => document.removeEventListener("pointerdown", onPointerDown);
1945
+ }, [open]);
1946
+ }
1947
+
1948
+ // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Popover/Popover.module.css?mds-scoped
1949
+ var Popover_module_default = { "panel": "mds-Popover__panel", "header": "mds-Popover__header", "headerTitle": "mds-Popover__headerTitle", "close": "mds-Popover__close", "closeGlyph": "mds-Popover__closeGlyph", "body": "mds-Popover__body", "footer": "mds-Popover__footer" };
1950
+ var POPOVER_EXIT_MS = 120;
1951
+ var GAP = 8;
1952
+ function Popover({
1953
+ open,
1954
+ onClose,
1955
+ anchorRef,
1956
+ label,
1957
+ placement = "bottom-start",
1958
+ className,
1959
+ children
1960
+ }) {
1961
+ const { mounted, visible } = usePresence(open, POPOVER_EXIT_MS);
1962
+ const panelRef = useOverlay({ open, onClose, lockScroll: false });
1963
+ useAnchoredPosition({ open: mounted, anchorRef, floatingRef: panelRef, placement, gap: GAP });
1964
+ useDismissOnOutside(open, onClose, [panelRef, anchorRef]);
1965
+ if (!mounted) return null;
1966
+ return reactDom.createPortal(
1967
+ /* @__PURE__ */ jsxRuntime.jsx(
1968
+ "div",
1969
+ {
1970
+ ref: panelRef,
1971
+ role: "dialog",
1972
+ "aria-label": label,
1973
+ tabIndex: -1,
1974
+ className: cx(Popover_module_default.panel, className),
1975
+ "data-open": visible || void 0,
1976
+ children
1977
+ }
1978
+ ),
1979
+ document.body
1980
+ );
1981
+ }
1982
+ function PopoverHeader({ children, onClose, closeLabel }) {
1983
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: Popover_module_default.header, children: [
1984
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: Popover_module_default.headerTitle, children }),
1985
+ onClose !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", "aria-label": closeLabel, className: Popover_module_default.close, onClick: onClose, children: /* @__PURE__ */ jsxRuntime.jsx(CloseGlyph, { className: Popover_module_default.closeGlyph }) })
1986
+ ] });
1987
+ }
1988
+ function PopoverBody({ children }) {
1989
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: Popover_module_default.body, children });
1990
+ }
1991
+ function PopoverFooter({ children }) {
1992
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: Popover_module_default.footer, children });
1993
+ }
1994
+ function useRovingGroup(ref, { selector, orientation = "horizontal" }) {
1995
+ return react.useCallback(
1996
+ (event) => {
1997
+ const horizontal = orientation !== "vertical";
1998
+ const vertical = orientation !== "horizontal";
1999
+ const forward = horizontal && event.key === "ArrowRight" || vertical && event.key === "ArrowDown";
2000
+ const backward = horizontal && event.key === "ArrowLeft" || vertical && event.key === "ArrowUp";
2001
+ const home = event.key === "Home";
2002
+ const end = event.key === "End";
2003
+ if (!forward && !backward && !home && !end) return;
2004
+ const container = ref.current;
2005
+ if (container === null) return;
2006
+ const items = [...container.querySelectorAll(selector)].filter(
2007
+ (item) => !item.hasAttribute("disabled")
2008
+ );
2009
+ const current = items.indexOf(document.activeElement);
2010
+ if (items.length === 0 || current === -1) return;
2011
+ event.preventDefault();
2012
+ const next = home ? 0 : end ? items.length - 1 : (current + (forward ? 1 : -1) + items.length) % items.length;
2013
+ items[next]?.focus();
2014
+ },
2015
+ [ref, selector, orientation]
2016
+ );
2017
+ }
2018
+
2019
+ // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Menu/Menu.module.css?mds-scoped
2020
+ var Menu_module_default = { "panel": "mds-Menu__panel", "item": "mds-Menu__item", "tone-danger": "mds-Menu__tone-danger" };
2021
+ var MENU_EXIT_MS = 120;
2022
+ var GAP2 = 8;
2023
+ var ITEM_SELECTOR = '[role="menuitem"]';
2024
+ var MenuContext = react.createContext(null);
2025
+ function Menu({ label, trigger, placement = "bottom-end", className, children }) {
2026
+ const [open, setOpen] = react.useState(false);
2027
+ const { mounted, visible } = usePresence(open, MENU_EXIT_MS);
2028
+ const triggerRef = react.useRef(null);
2029
+ const panelRef = react.useRef(null);
2030
+ const close = () => {
2031
+ setOpen(false);
2032
+ triggerRef.current?.focus();
2033
+ };
2034
+ const dismiss = () => setOpen(false);
2035
+ useAnchoredPosition({ open: mounted, anchorRef: triggerRef, floatingRef: panelRef, placement, gap: GAP2 });
2036
+ useDismissOnOutside(open, dismiss, [panelRef, triggerRef]);
2037
+ const onArrowKeys = useRovingGroup(panelRef, {
2038
+ selector: ITEM_SELECTOR,
2039
+ orientation: "vertical"
2040
+ });
2041
+ react.useEffect(() => {
2042
+ if (!open) return;
2043
+ const first = panelRef.current?.querySelector(
2044
+ `${ITEM_SELECTOR}:not([disabled])`
2045
+ );
2046
+ first?.focus();
2047
+ }, [open]);
2048
+ const openWithKeyboard = (event) => {
2049
+ if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
2050
+ event.preventDefault();
2051
+ setOpen(true);
2052
+ };
2053
+ const { type: Trigger, props: triggerProps } = trigger;
2054
+ return /* @__PURE__ */ jsxRuntime.jsxs(MenuContext.Provider, { value: { close }, children: [
2055
+ /* @__PURE__ */ jsxRuntime.jsx(
2056
+ Trigger,
2057
+ {
2058
+ ...triggerProps,
2059
+ ref: forkRef(triggerRef, triggerProps.ref),
2060
+ "aria-haspopup": "menu",
2061
+ "aria-expanded": open,
2062
+ onClick: (event) => {
2063
+ triggerProps.onClick?.(event);
2064
+ setOpen((v) => !v);
2065
+ },
2066
+ onKeyDown: (event) => {
2067
+ triggerProps.onKeyDown?.(event);
2068
+ openWithKeyboard(event);
2069
+ }
2070
+ }
2071
+ ),
2072
+ mounted && reactDom.createPortal(
2073
+ /* @__PURE__ */ jsxRuntime.jsx(
2074
+ "div",
2075
+ {
2076
+ ref: panelRef,
2077
+ role: "menu",
2078
+ "aria-label": label,
2079
+ className: cx(Menu_module_default.panel, className),
2080
+ "data-open": visible || void 0,
2081
+ onKeyDown: (event) => {
2082
+ if (event.key === "Escape") {
2083
+ event.stopPropagation();
2084
+ close();
2085
+ return;
2086
+ }
2087
+ if (event.key === "Tab") {
2088
+ event.preventDefault();
2089
+ close();
2090
+ return;
2091
+ }
2092
+ onArrowKeys(event);
2093
+ },
2094
+ children
2095
+ }
2096
+ ),
2097
+ document.body
2098
+ )
2099
+ ] });
2100
+ }
2101
+ function MenuItem({ onSelect, disabled = false, tone = "default", children }) {
2102
+ const menu = react.useContext(MenuContext);
2103
+ return /* @__PURE__ */ jsxRuntime.jsx(
2104
+ "button",
2105
+ {
2106
+ type: "button",
2107
+ role: "menuitem",
2108
+ tabIndex: -1,
2109
+ disabled,
2110
+ className: cx(Menu_module_default.item, Menu_module_default[`tone-${tone}`]),
2111
+ onClick: () => {
2112
+ onSelect();
2113
+ menu?.close();
2114
+ },
2115
+ children
2116
+ }
2117
+ );
2118
+ }
2119
+
2120
+ // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Tooltip/Tooltip.module.css?mds-scoped
2121
+ var Tooltip_module_default = { "surface": "mds-Tooltip__surface" };
2122
+ var GAP3 = 8;
2123
+ var DEFAULT_DELAY_MS = 400;
2124
+ function Tooltip({
2125
+ content,
2126
+ placement = "top",
2127
+ delayMs = DEFAULT_DELAY_MS,
2128
+ children
2129
+ }) {
2130
+ const id = react.useId();
2131
+ const [open, setOpen] = react.useState(false);
2132
+ const anchorRef = react.useRef(null);
2133
+ const surfaceRef = react.useRef(null);
2134
+ const timer = react.useRef(void 0);
2135
+ const show = () => {
2136
+ clearTimeout(timer.current);
2137
+ setOpen(true);
2138
+ };
2139
+ const hide = () => {
2140
+ clearTimeout(timer.current);
2141
+ setOpen(false);
2142
+ };
2143
+ react.useEffect(() => clearTimeout(timer.current), []);
2144
+ useAnchoredPosition({ open, anchorRef, floatingRef: surfaceRef, placement, gap: GAP3 });
2145
+ react.useEffect(() => {
2146
+ if (!open) return;
2147
+ const onKeyDown = (event) => {
2148
+ if (event.key === "Escape") hide();
2149
+ };
2150
+ document.addEventListener("keydown", onKeyDown);
2151
+ return () => document.removeEventListener("keydown", onKeyDown);
2152
+ }, [open]);
2153
+ const { type: Trigger, props: triggerProps } = children;
2154
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2155
+ /* @__PURE__ */ jsxRuntime.jsx(
2156
+ Trigger,
2157
+ {
2158
+ ...triggerProps,
2159
+ ref: forkRef(anchorRef, triggerProps.ref),
2160
+ "aria-describedby": open ? id : triggerProps["aria-describedby"],
2161
+ onPointerEnter: (event) => {
2162
+ triggerProps.onPointerEnter?.(event);
2163
+ if (event.pointerType === "touch") return;
2164
+ clearTimeout(timer.current);
2165
+ timer.current = setTimeout(show, delayMs);
2166
+ },
2167
+ onPointerLeave: (event) => {
2168
+ triggerProps.onPointerLeave?.(event);
2169
+ hide();
2170
+ },
2171
+ onFocus: (event) => {
2172
+ triggerProps.onFocus?.(event);
2173
+ show();
2174
+ },
2175
+ onBlur: (event) => {
2176
+ triggerProps.onBlur?.(event);
2177
+ hide();
2178
+ }
2179
+ }
2180
+ ),
2181
+ open && reactDom.createPortal(
2182
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: surfaceRef, id, role: "tooltip", className: Tooltip_module_default.surface, children: content }),
2183
+ document.body
2184
+ )
2185
+ ] });
2186
+ }
1912
2187
 
1913
2188
  // mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/ConfirmDialog/ConfirmDialog.module.css?mds-scoped
1914
2189
  var ConfirmDialog_module_default = { "description": "mds-ConfirmDialog__description", "error": "mds-ConfirmDialog__error" };
@@ -2454,7 +2729,7 @@ var distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
2454
2729
  function Lightbox({ open, onClose, src, alt = "", caption, labels }) {
2455
2730
  const [surface, setSurface] = react.useState(null);
2456
2731
  const [scale, setScale] = react.useState(MIN_SCALE);
2457
- const [offset, setOffset] = react.useState(ORIGIN);
2732
+ const [offset2, setOffset] = react.useState(ORIGIN);
2458
2733
  const points = react.useRef(/* @__PURE__ */ new Map());
2459
2734
  const from = react.useRef({ spread: 0, scale: MIN_SCALE, x: 0, y: 0, offset: ORIGIN });
2460
2735
  const [shown, setShown] = react.useState({ src, open });
@@ -2504,7 +2779,7 @@ function Lightbox({ open, onClose, src, alt = "", caption, labels }) {
2504
2779
  from.current = { ...from.current, spread: distance(first, second), scale };
2505
2780
  return;
2506
2781
  }
2507
- if (first) from.current = { ...from.current, x: first.x, y: first.y, offset };
2782
+ if (first) from.current = { ...from.current, x: first.x, y: first.y, offset: offset2 };
2508
2783
  }
2509
2784
  function onPointerMove(event) {
2510
2785
  if (!points.current.has(event.pointerId)) return;
@@ -2531,12 +2806,12 @@ function Lightbox({ open, onClose, src, alt = "", caption, labels }) {
2531
2806
  function onPointerUp(event) {
2532
2807
  points.current.delete(event.pointerId);
2533
2808
  const [rest] = [...points.current.values()];
2534
- if (rest) from.current = { ...from.current, x: rest.x, y: rest.y, offset };
2809
+ if (rest) from.current = { ...from.current, x: rest.x, y: rest.y, offset: offset2 };
2535
2810
  }
2536
2811
  const vars = {
2537
2812
  "--zoom": String(round(scale)),
2538
- "--pan-x": `${round(offset.x)}px`,
2539
- "--pan-y": `${round(offset.y)}px`
2813
+ "--pan-x": `${round(offset2.x)}px`,
2814
+ "--pan-y": `${round(offset2.y)}px`
2540
2815
  };
2541
2816
  return /* @__PURE__ */ jsxRuntime.jsxs(
2542
2817
  Overlay,
@@ -2807,30 +3082,6 @@ function Breadcrumb({
2807
3082
  ] }, `${item.label}-${index}`);
2808
3083
  }) }) });
2809
3084
  }
2810
- function useRovingGroup(ref, { selector, orientation = "horizontal" }) {
2811
- return react.useCallback(
2812
- (event) => {
2813
- const horizontal = orientation !== "vertical";
2814
- const vertical = orientation !== "horizontal";
2815
- const forward = horizontal && event.key === "ArrowRight" || vertical && event.key === "ArrowDown";
2816
- const backward = horizontal && event.key === "ArrowLeft" || vertical && event.key === "ArrowUp";
2817
- const home = event.key === "Home";
2818
- const end = event.key === "End";
2819
- if (!forward && !backward && !home && !end) return;
2820
- const container = ref.current;
2821
- if (container === null) return;
2822
- const items = [...container.querySelectorAll(selector)].filter(
2823
- (item) => !item.hasAttribute("disabled")
2824
- );
2825
- const current = items.indexOf(document.activeElement);
2826
- if (items.length === 0 || current === -1) return;
2827
- event.preventDefault();
2828
- const next = home ? 0 : end ? items.length - 1 : (current + (forward ? 1 : -1) + items.length) % items.length;
2829
- items[next]?.focus();
2830
- },
2831
- [ref, selector, orientation]
2832
- );
2833
- }
2834
3085
 
2835
3086
  exports.AppBar = AppBar;
2836
3087
  exports.Avatar = Avatar;
@@ -2866,18 +3117,23 @@ exports.Link = Link;
2866
3117
  exports.ListGroup = ListGroup;
2867
3118
  exports.ListItem = ListItem;
2868
3119
  exports.MediaPlaceholder = MediaPlaceholder;
3120
+ exports.Menu = Menu;
3121
+ exports.MenuItem = MenuItem;
2869
3122
  exports.Modal = Modal;
2870
3123
  exports.ModalBody = ModalBody;
2871
3124
  exports.ModalFooter = ModalFooter;
2872
3125
  exports.ModalHeader = ModalHeader;
2873
3126
  exports.OverlayHistoryContext = OverlayHistoryContext;
2874
3127
  exports.PasswordInput = PasswordInput;
3128
+ exports.Popover = Popover;
3129
+ exports.PopoverBody = PopoverBody;
3130
+ exports.PopoverFooter = PopoverFooter;
3131
+ exports.PopoverHeader = PopoverHeader;
2875
3132
  exports.ProgressBar = ProgressBar;
2876
3133
  exports.Radio = Radio;
2877
3134
  exports.Screen = Screen;
2878
3135
  exports.ScreenContent = ScreenContent;
2879
3136
  exports.Scroller = Scroller;
2880
- exports.SearchField = SearchField;
2881
3137
  exports.SegmentedControl = SegmentedControl;
2882
3138
  exports.Select = Select;
2883
3139
  exports.Sheet = Sheet;
@@ -2902,6 +3158,7 @@ exports.Tag = Tag;
2902
3158
  exports.Text = Text;
2903
3159
  exports.Textarea = Textarea;
2904
3160
  exports.ToastProvider = ToastProvider;
3161
+ exports.Tooltip = Tooltip;
2905
3162
  exports.UploadProgress = UploadProgress;
2906
3163
  exports.VideoPlayer = VideoPlayer;
2907
3164
  exports.VisuallyHidden = VisuallyHidden;