@mond-design-system/react 5.0.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 +337 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +174 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +149 -4
- package/dist/index.d.ts +149 -4
- package/dist/index.js +331 -56
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
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": `${
|
|
91
|
-
"--spinner-border": `${Math.max(2, Math.round(
|
|
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-${
|
|
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:
|
|
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-${
|
|
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[
|
|
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
|
-
|
|
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-${
|
|
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-${
|
|
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-${
|
|
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) {
|
|
@@ -1106,7 +1107,7 @@ function forkRef(own, given) {
|
|
|
1106
1107
|
// mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Input/Input.module.css?mds-scoped
|
|
1107
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" };
|
|
1108
1109
|
function Input({
|
|
1109
|
-
size = "md",
|
|
1110
|
+
size: size2 = "md",
|
|
1110
1111
|
invalid,
|
|
1111
1112
|
iconLeft,
|
|
1112
1113
|
iconRight,
|
|
@@ -1140,7 +1141,7 @@ function Input({
|
|
|
1140
1141
|
"aria-invalid": rest["aria-invalid"] ?? ((invalid ?? field?.invalid) || void 0),
|
|
1141
1142
|
className: cx(
|
|
1142
1143
|
Input_module_default.input,
|
|
1143
|
-
Input_module_default[`size-${
|
|
1144
|
+
Input_module_default[`size-${size2}`],
|
|
1144
1145
|
iconLeft != null && Input_module_default["with-icon-left"],
|
|
1145
1146
|
(iconRight != null || showClear) && Input_module_default["with-icon-right"],
|
|
1146
1147
|
onClear != null && Input_module_default["own-clear"],
|
|
@@ -1151,7 +1152,7 @@ function Input({
|
|
|
1151
1152
|
}
|
|
1152
1153
|
);
|
|
1153
1154
|
if (iconLeft == null && iconRight == null && onClear == null) return input;
|
|
1154
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cx(Input_module_default.iconWrap, Input_module_default[`slot-${
|
|
1155
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: cx(Input_module_default.iconWrap, Input_module_default[`slot-${size2}`]), children: [
|
|
1155
1156
|
input,
|
|
1156
1157
|
iconLeft != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx(Input_module_default.icon, Input_module_default.iconLeft), "aria-hidden": "true", children: iconLeft }),
|
|
1157
1158
|
iconRight != null && /* @__PURE__ */ jsxRuntime.jsx("span", { className: cx(Input_module_default.icon, Input_module_default.iconRight), "aria-hidden": "true", children: iconRight }),
|
|
@@ -1301,7 +1302,7 @@ function SegmentedControl({
|
|
|
1301
1302
|
onChange,
|
|
1302
1303
|
disabled = false,
|
|
1303
1304
|
fullWidth = false,
|
|
1304
|
-
size = "md",
|
|
1305
|
+
size: size2 = "md",
|
|
1305
1306
|
bare = false,
|
|
1306
1307
|
repick = false,
|
|
1307
1308
|
className
|
|
@@ -1314,7 +1315,7 @@ function SegmentedControl({
|
|
|
1314
1315
|
"aria-label": label,
|
|
1315
1316
|
className: cx(
|
|
1316
1317
|
SegmentedControl_module_default.group,
|
|
1317
|
-
SegmentedControl_module_default[`size-${
|
|
1318
|
+
SegmentedControl_module_default[`size-${size2}`],
|
|
1318
1319
|
fullWidth && SegmentedControl_module_default.fullWidth,
|
|
1319
1320
|
bare && SegmentedControl_module_default.bare,
|
|
1320
1321
|
className
|
|
@@ -1885,6 +1886,304 @@ function ModalBody({ children }) {
|
|
|
1885
1886
|
function ModalFooter({ children }) {
|
|
1886
1887
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: Modal_module_default.footer, children });
|
|
1887
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
|
+
}
|
|
1888
2187
|
|
|
1889
2188
|
// mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/ConfirmDialog/ConfirmDialog.module.css?mds-scoped
|
|
1890
2189
|
var ConfirmDialog_module_default = { "description": "mds-ConfirmDialog__description", "error": "mds-ConfirmDialog__error" };
|
|
@@ -2430,7 +2729,7 @@ var distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
|
|
|
2430
2729
|
function Lightbox({ open, onClose, src, alt = "", caption, labels }) {
|
|
2431
2730
|
const [surface, setSurface] = react.useState(null);
|
|
2432
2731
|
const [scale, setScale] = react.useState(MIN_SCALE);
|
|
2433
|
-
const [
|
|
2732
|
+
const [offset2, setOffset] = react.useState(ORIGIN);
|
|
2434
2733
|
const points = react.useRef(/* @__PURE__ */ new Map());
|
|
2435
2734
|
const from = react.useRef({ spread: 0, scale: MIN_SCALE, x: 0, y: 0, offset: ORIGIN });
|
|
2436
2735
|
const [shown, setShown] = react.useState({ src, open });
|
|
@@ -2480,7 +2779,7 @@ function Lightbox({ open, onClose, src, alt = "", caption, labels }) {
|
|
|
2480
2779
|
from.current = { ...from.current, spread: distance(first, second), scale };
|
|
2481
2780
|
return;
|
|
2482
2781
|
}
|
|
2483
|
-
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 };
|
|
2484
2783
|
}
|
|
2485
2784
|
function onPointerMove(event) {
|
|
2486
2785
|
if (!points.current.has(event.pointerId)) return;
|
|
@@ -2507,12 +2806,12 @@ function Lightbox({ open, onClose, src, alt = "", caption, labels }) {
|
|
|
2507
2806
|
function onPointerUp(event) {
|
|
2508
2807
|
points.current.delete(event.pointerId);
|
|
2509
2808
|
const [rest] = [...points.current.values()];
|
|
2510
|
-
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 };
|
|
2511
2810
|
}
|
|
2512
2811
|
const vars = {
|
|
2513
2812
|
"--zoom": String(round(scale)),
|
|
2514
|
-
"--pan-x": `${round(
|
|
2515
|
-
"--pan-y": `${round(
|
|
2813
|
+
"--pan-x": `${round(offset2.x)}px`,
|
|
2814
|
+
"--pan-y": `${round(offset2.y)}px`
|
|
2516
2815
|
};
|
|
2517
2816
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2518
2817
|
Overlay,
|
|
@@ -2783,30 +3082,6 @@ function Breadcrumb({
|
|
|
2783
3082
|
] }, `${item.label}-${index}`);
|
|
2784
3083
|
}) }) });
|
|
2785
3084
|
}
|
|
2786
|
-
function useRovingGroup(ref, { selector, orientation = "horizontal" }) {
|
|
2787
|
-
return react.useCallback(
|
|
2788
|
-
(event) => {
|
|
2789
|
-
const horizontal = orientation !== "vertical";
|
|
2790
|
-
const vertical = orientation !== "horizontal";
|
|
2791
|
-
const forward = horizontal && event.key === "ArrowRight" || vertical && event.key === "ArrowDown";
|
|
2792
|
-
const backward = horizontal && event.key === "ArrowLeft" || vertical && event.key === "ArrowUp";
|
|
2793
|
-
const home = event.key === "Home";
|
|
2794
|
-
const end = event.key === "End";
|
|
2795
|
-
if (!forward && !backward && !home && !end) return;
|
|
2796
|
-
const container = ref.current;
|
|
2797
|
-
if (container === null) return;
|
|
2798
|
-
const items = [...container.querySelectorAll(selector)].filter(
|
|
2799
|
-
(item) => !item.hasAttribute("disabled")
|
|
2800
|
-
);
|
|
2801
|
-
const current = items.indexOf(document.activeElement);
|
|
2802
|
-
if (items.length === 0 || current === -1) return;
|
|
2803
|
-
event.preventDefault();
|
|
2804
|
-
const next = home ? 0 : end ? items.length - 1 : (current + (forward ? 1 : -1) + items.length) % items.length;
|
|
2805
|
-
items[next]?.focus();
|
|
2806
|
-
},
|
|
2807
|
-
[ref, selector, orientation]
|
|
2808
|
-
);
|
|
2809
|
-
}
|
|
2810
3085
|
|
|
2811
3086
|
exports.AppBar = AppBar;
|
|
2812
3087
|
exports.Avatar = Avatar;
|
|
@@ -2842,12 +3117,18 @@ exports.Link = Link;
|
|
|
2842
3117
|
exports.ListGroup = ListGroup;
|
|
2843
3118
|
exports.ListItem = ListItem;
|
|
2844
3119
|
exports.MediaPlaceholder = MediaPlaceholder;
|
|
3120
|
+
exports.Menu = Menu;
|
|
3121
|
+
exports.MenuItem = MenuItem;
|
|
2845
3122
|
exports.Modal = Modal;
|
|
2846
3123
|
exports.ModalBody = ModalBody;
|
|
2847
3124
|
exports.ModalFooter = ModalFooter;
|
|
2848
3125
|
exports.ModalHeader = ModalHeader;
|
|
2849
3126
|
exports.OverlayHistoryContext = OverlayHistoryContext;
|
|
2850
3127
|
exports.PasswordInput = PasswordInput;
|
|
3128
|
+
exports.Popover = Popover;
|
|
3129
|
+
exports.PopoverBody = PopoverBody;
|
|
3130
|
+
exports.PopoverFooter = PopoverFooter;
|
|
3131
|
+
exports.PopoverHeader = PopoverHeader;
|
|
2851
3132
|
exports.ProgressBar = ProgressBar;
|
|
2852
3133
|
exports.Radio = Radio;
|
|
2853
3134
|
exports.Screen = Screen;
|
|
@@ -2877,6 +3158,7 @@ exports.Tag = Tag;
|
|
|
2877
3158
|
exports.Text = Text;
|
|
2878
3159
|
exports.Textarea = Textarea;
|
|
2879
3160
|
exports.ToastProvider = ToastProvider;
|
|
3161
|
+
exports.Tooltip = Tooltip;
|
|
2880
3162
|
exports.UploadProgress = UploadProgress;
|
|
2881
3163
|
exports.VideoPlayer = VideoPlayer;
|
|
2882
3164
|
exports.VisuallyHidden = VisuallyHidden;
|