@mond-design-system/react 5.0.0 → 6.0.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 +354 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +204 -103
- package/dist/index.css.map +1 -1
- package/dist/index.d.cts +156 -10
- package/dist/index.d.ts +156 -10
- package/dist/index.js +348 -66
- 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
|
|
@@ -1493,7 +1494,7 @@ function ListItem({
|
|
|
1493
1494
|
}
|
|
1494
1495
|
|
|
1495
1496
|
// mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/DataTable/DataTable.module.css?mds-scoped
|
|
1496
|
-
var DataTable_module_default = { "root": "mds-DataTable__root", "
|
|
1497
|
+
var DataTable_module_default = { "root": "mds-DataTable__root", "scroll": "mds-DataTable__scroll", "table": "mds-DataTable__table", "row": "mds-DataTable__row", "body": "mds-DataTable__body", "selected": "mds-DataTable__selected", "cell": "mds-DataTable__cell", "select": "mds-DataTable__select", "actions": "mds-DataTable__actions", "muted": "mds-DataTable__muted", "empty": "mds-DataTable__empty", "bulk": "mds-DataTable__bulk", "bulkActions": "mds-DataTable__bulkActions" };
|
|
1497
1498
|
function DataTable({
|
|
1498
1499
|
label,
|
|
1499
1500
|
columns,
|
|
@@ -1528,13 +1529,19 @@ function DataTable({
|
|
|
1528
1529
|
return typeof first === "string" ? first : rowKey(row);
|
|
1529
1530
|
};
|
|
1530
1531
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cx(DataTable_module_default.root, className), ref, ...rest, children: [
|
|
1531
|
-
/* @__PURE__ */ jsxRuntime.jsxs("table", { className: DataTable_module_default.table, "aria-label": label, children: [
|
|
1532
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: DataTable_module_default.scroll, role: "region", "aria-label": label, tabIndex: 0, children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: DataTable_module_default.table, "aria-label": label, children: [
|
|
1532
1533
|
/* @__PURE__ */ jsxRuntime.jsxs("colgroup", { children: [
|
|
1533
1534
|
selectable && /* @__PURE__ */ jsxRuntime.jsx("col", {}),
|
|
1534
|
-
columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1535
|
+
columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1536
|
+
"col",
|
|
1537
|
+
{
|
|
1538
|
+
style: column.width !== void 0 ? { width: column.width } : void 0
|
|
1539
|
+
},
|
|
1540
|
+
column.key
|
|
1541
|
+
)),
|
|
1535
1542
|
rowActions && /* @__PURE__ */ jsxRuntime.jsx("col", {})
|
|
1536
1543
|
] }),
|
|
1537
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1544
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: DataTable_module_default.row, children: [
|
|
1538
1545
|
selectable && /* @__PURE__ */ jsxRuntime.jsx("th", { scope: "col", className: DataTable_module_default.select, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1539
1546
|
Checkbox,
|
|
1540
1547
|
{
|
|
@@ -1554,7 +1561,11 @@ function DataTable({
|
|
|
1554
1561
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1555
1562
|
"tr",
|
|
1556
1563
|
{
|
|
1557
|
-
className: cx(
|
|
1564
|
+
className: cx(
|
|
1565
|
+
DataTable_module_default.row,
|
|
1566
|
+
taken && DataTable_module_default.selected,
|
|
1567
|
+
rowMuted?.(row) === true && DataTable_module_default.muted
|
|
1568
|
+
),
|
|
1558
1569
|
children: [
|
|
1559
1570
|
selectable && /* @__PURE__ */ jsxRuntime.jsx("td", { className: DataTable_module_default.select, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1560
1571
|
Checkbox,
|
|
@@ -1565,17 +1576,14 @@ function DataTable({
|
|
|
1565
1576
|
onChange: (event) => toggle(key, event.target.checked)
|
|
1566
1577
|
}
|
|
1567
1578
|
) }),
|
|
1568
|
-
columns.map((column
|
|
1569
|
-
index > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: DataTable_module_default.key, "aria-hidden": "true", children: column.header }),
|
|
1570
|
-
column.cell(row)
|
|
1571
|
-
] }, column.key)),
|
|
1579
|
+
columns.map((column) => /* @__PURE__ */ jsxRuntime.jsx("td", { className: DataTable_module_default.cell, children: column.cell(row) }, column.key)),
|
|
1572
1580
|
rowActions && /* @__PURE__ */ jsxRuntime.jsx("td", { className: DataTable_module_default.actions, children: rowActions(row) })
|
|
1573
1581
|
]
|
|
1574
1582
|
},
|
|
1575
1583
|
key
|
|
1576
1584
|
);
|
|
1577
1585
|
}) : empty !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("tr", { className: DataTable_module_default.row, children: /* @__PURE__ */ jsxRuntime.jsx("td", { className: DataTable_module_default.empty, colSpan: span, children: /* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "note", children: empty }) }) }) })
|
|
1578
|
-
] }),
|
|
1586
|
+
] }) }),
|
|
1579
1587
|
selectable && selected.length > 0 && bulkActions !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: DataTable_module_default.bulk, role: "status", children: [
|
|
1580
1588
|
/* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "meta", children: selectionLabels.count(selected.length) }),
|
|
1581
1589
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: DataTable_module_default.bulkActions, children: bulkActions })
|
|
@@ -1885,6 +1893,304 @@ function ModalBody({ children }) {
|
|
|
1885
1893
|
function ModalFooter({ children }) {
|
|
1886
1894
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: Modal_module_default.footer, children });
|
|
1887
1895
|
}
|
|
1896
|
+
var VIEWPORT_PAD = 8;
|
|
1897
|
+
var MIN_HEIGHT = 120;
|
|
1898
|
+
function useAnchoredPosition({
|
|
1899
|
+
open,
|
|
1900
|
+
anchorRef,
|
|
1901
|
+
floatingRef,
|
|
1902
|
+
placement,
|
|
1903
|
+
gap
|
|
1904
|
+
}) {
|
|
1905
|
+
react.useEffect(() => {
|
|
1906
|
+
const anchor = anchorRef.current;
|
|
1907
|
+
const floating = floatingRef.current;
|
|
1908
|
+
if (!open || anchor === null || floating === null) return;
|
|
1909
|
+
const update = () => {
|
|
1910
|
+
void dom.computePosition(anchor, floating, {
|
|
1911
|
+
placement,
|
|
1912
|
+
strategy: "fixed",
|
|
1913
|
+
middleware: [
|
|
1914
|
+
dom.offset(gap),
|
|
1915
|
+
// Order is load-bearing: choose the side first, then cap the height
|
|
1916
|
+
// to what that side has, then slide along the cross axis. Sizing
|
|
1917
|
+
// before flipping caps against the side being abandoned.
|
|
1918
|
+
dom.flip({ padding: VIEWPORT_PAD }),
|
|
1919
|
+
dom.size({
|
|
1920
|
+
padding: VIEWPORT_PAD,
|
|
1921
|
+
apply({ availableHeight, elements }) {
|
|
1922
|
+
elements.floating.style.maxHeight = `${Math.max(availableHeight, MIN_HEIGHT)}px`;
|
|
1923
|
+
}
|
|
1924
|
+
}),
|
|
1925
|
+
dom.shift({ padding: VIEWPORT_PAD })
|
|
1926
|
+
]
|
|
1927
|
+
}).then(({ x, y, placement: resolved }) => {
|
|
1928
|
+
floating.style.left = `${x}px`;
|
|
1929
|
+
floating.style.top = `${y}px`;
|
|
1930
|
+
floating.dataset.placement = resolved;
|
|
1931
|
+
});
|
|
1932
|
+
};
|
|
1933
|
+
return dom.autoUpdate(anchor, floating, update);
|
|
1934
|
+
}, [open, anchorRef, floatingRef, placement, gap]);
|
|
1935
|
+
}
|
|
1936
|
+
function useDismissOnOutside(open, onDismiss, inside) {
|
|
1937
|
+
const latest = react.useRef({ onDismiss, inside });
|
|
1938
|
+
react.useEffect(() => {
|
|
1939
|
+
latest.current = { onDismiss, inside };
|
|
1940
|
+
});
|
|
1941
|
+
react.useEffect(() => {
|
|
1942
|
+
if (!open) return;
|
|
1943
|
+
const onPointerDown = (event) => {
|
|
1944
|
+
const target = event.target;
|
|
1945
|
+
if (!(target instanceof Node)) return;
|
|
1946
|
+
const { onDismiss: dismiss, inside: refs } = latest.current;
|
|
1947
|
+
if (refs.some((ref) => ref.current?.contains(target))) return;
|
|
1948
|
+
dismiss();
|
|
1949
|
+
};
|
|
1950
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
1951
|
+
return () => document.removeEventListener("pointerdown", onPointerDown);
|
|
1952
|
+
}, [open]);
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
// mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Popover/Popover.module.css?mds-scoped
|
|
1956
|
+
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" };
|
|
1957
|
+
var POPOVER_EXIT_MS = 120;
|
|
1958
|
+
var GAP = 8;
|
|
1959
|
+
function Popover({
|
|
1960
|
+
open,
|
|
1961
|
+
onClose,
|
|
1962
|
+
anchorRef,
|
|
1963
|
+
label,
|
|
1964
|
+
placement = "bottom-start",
|
|
1965
|
+
className,
|
|
1966
|
+
children
|
|
1967
|
+
}) {
|
|
1968
|
+
const { mounted, visible } = usePresence(open, POPOVER_EXIT_MS);
|
|
1969
|
+
const panelRef = useOverlay({ open, onClose, lockScroll: false });
|
|
1970
|
+
useAnchoredPosition({ open: mounted, anchorRef, floatingRef: panelRef, placement, gap: GAP });
|
|
1971
|
+
useDismissOnOutside(open, onClose, [panelRef, anchorRef]);
|
|
1972
|
+
if (!mounted) return null;
|
|
1973
|
+
return reactDom.createPortal(
|
|
1974
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1975
|
+
"div",
|
|
1976
|
+
{
|
|
1977
|
+
ref: panelRef,
|
|
1978
|
+
role: "dialog",
|
|
1979
|
+
"aria-label": label,
|
|
1980
|
+
tabIndex: -1,
|
|
1981
|
+
className: cx(Popover_module_default.panel, className),
|
|
1982
|
+
"data-open": visible || void 0,
|
|
1983
|
+
children
|
|
1984
|
+
}
|
|
1985
|
+
),
|
|
1986
|
+
document.body
|
|
1987
|
+
);
|
|
1988
|
+
}
|
|
1989
|
+
function PopoverHeader({ children, onClose, closeLabel }) {
|
|
1990
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: Popover_module_default.header, children: [
|
|
1991
|
+
/* @__PURE__ */ jsxRuntime.jsx("h2", { className: Popover_module_default.headerTitle, children }),
|
|
1992
|
+
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 }) })
|
|
1993
|
+
] });
|
|
1994
|
+
}
|
|
1995
|
+
function PopoverBody({ children }) {
|
|
1996
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: Popover_module_default.body, children });
|
|
1997
|
+
}
|
|
1998
|
+
function PopoverFooter({ children }) {
|
|
1999
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: Popover_module_default.footer, children });
|
|
2000
|
+
}
|
|
2001
|
+
function useRovingGroup(ref, { selector, orientation = "horizontal" }) {
|
|
2002
|
+
return react.useCallback(
|
|
2003
|
+
(event) => {
|
|
2004
|
+
const horizontal = orientation !== "vertical";
|
|
2005
|
+
const vertical = orientation !== "horizontal";
|
|
2006
|
+
const forward = horizontal && event.key === "ArrowRight" || vertical && event.key === "ArrowDown";
|
|
2007
|
+
const backward = horizontal && event.key === "ArrowLeft" || vertical && event.key === "ArrowUp";
|
|
2008
|
+
const home = event.key === "Home";
|
|
2009
|
+
const end = event.key === "End";
|
|
2010
|
+
if (!forward && !backward && !home && !end) return;
|
|
2011
|
+
const container = ref.current;
|
|
2012
|
+
if (container === null) return;
|
|
2013
|
+
const items = [...container.querySelectorAll(selector)].filter(
|
|
2014
|
+
(item) => !item.hasAttribute("disabled")
|
|
2015
|
+
);
|
|
2016
|
+
const current = items.indexOf(document.activeElement);
|
|
2017
|
+
if (items.length === 0 || current === -1) return;
|
|
2018
|
+
event.preventDefault();
|
|
2019
|
+
const next = home ? 0 : end ? items.length - 1 : (current + (forward ? 1 : -1) + items.length) % items.length;
|
|
2020
|
+
items[next]?.focus();
|
|
2021
|
+
},
|
|
2022
|
+
[ref, selector, orientation]
|
|
2023
|
+
);
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
// mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Menu/Menu.module.css?mds-scoped
|
|
2027
|
+
var Menu_module_default = { "panel": "mds-Menu__panel", "item": "mds-Menu__item", "tone-danger": "mds-Menu__tone-danger" };
|
|
2028
|
+
var MENU_EXIT_MS = 120;
|
|
2029
|
+
var GAP2 = 8;
|
|
2030
|
+
var ITEM_SELECTOR = '[role="menuitem"]';
|
|
2031
|
+
var MenuContext = react.createContext(null);
|
|
2032
|
+
function Menu({ label, trigger, placement = "bottom-end", className, children }) {
|
|
2033
|
+
const [open, setOpen] = react.useState(false);
|
|
2034
|
+
const { mounted, visible } = usePresence(open, MENU_EXIT_MS);
|
|
2035
|
+
const triggerRef = react.useRef(null);
|
|
2036
|
+
const panelRef = react.useRef(null);
|
|
2037
|
+
const close = () => {
|
|
2038
|
+
setOpen(false);
|
|
2039
|
+
triggerRef.current?.focus();
|
|
2040
|
+
};
|
|
2041
|
+
const dismiss = () => setOpen(false);
|
|
2042
|
+
useAnchoredPosition({ open: mounted, anchorRef: triggerRef, floatingRef: panelRef, placement, gap: GAP2 });
|
|
2043
|
+
useDismissOnOutside(open, dismiss, [panelRef, triggerRef]);
|
|
2044
|
+
const onArrowKeys = useRovingGroup(panelRef, {
|
|
2045
|
+
selector: ITEM_SELECTOR,
|
|
2046
|
+
orientation: "vertical"
|
|
2047
|
+
});
|
|
2048
|
+
react.useEffect(() => {
|
|
2049
|
+
if (!open) return;
|
|
2050
|
+
const first = panelRef.current?.querySelector(
|
|
2051
|
+
`${ITEM_SELECTOR}:not([disabled])`
|
|
2052
|
+
);
|
|
2053
|
+
first?.focus();
|
|
2054
|
+
}, [open]);
|
|
2055
|
+
const openWithKeyboard = (event) => {
|
|
2056
|
+
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
|
|
2057
|
+
event.preventDefault();
|
|
2058
|
+
setOpen(true);
|
|
2059
|
+
};
|
|
2060
|
+
const { type: Trigger, props: triggerProps } = trigger;
|
|
2061
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(MenuContext.Provider, { value: { close }, children: [
|
|
2062
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2063
|
+
Trigger,
|
|
2064
|
+
{
|
|
2065
|
+
...triggerProps,
|
|
2066
|
+
ref: forkRef(triggerRef, triggerProps.ref),
|
|
2067
|
+
"aria-haspopup": "menu",
|
|
2068
|
+
"aria-expanded": open,
|
|
2069
|
+
onClick: (event) => {
|
|
2070
|
+
triggerProps.onClick?.(event);
|
|
2071
|
+
setOpen((v) => !v);
|
|
2072
|
+
},
|
|
2073
|
+
onKeyDown: (event) => {
|
|
2074
|
+
triggerProps.onKeyDown?.(event);
|
|
2075
|
+
openWithKeyboard(event);
|
|
2076
|
+
}
|
|
2077
|
+
}
|
|
2078
|
+
),
|
|
2079
|
+
mounted && reactDom.createPortal(
|
|
2080
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2081
|
+
"div",
|
|
2082
|
+
{
|
|
2083
|
+
ref: panelRef,
|
|
2084
|
+
role: "menu",
|
|
2085
|
+
"aria-label": label,
|
|
2086
|
+
className: cx(Menu_module_default.panel, className),
|
|
2087
|
+
"data-open": visible || void 0,
|
|
2088
|
+
onKeyDown: (event) => {
|
|
2089
|
+
if (event.key === "Escape") {
|
|
2090
|
+
event.stopPropagation();
|
|
2091
|
+
close();
|
|
2092
|
+
return;
|
|
2093
|
+
}
|
|
2094
|
+
if (event.key === "Tab") {
|
|
2095
|
+
event.preventDefault();
|
|
2096
|
+
close();
|
|
2097
|
+
return;
|
|
2098
|
+
}
|
|
2099
|
+
onArrowKeys(event);
|
|
2100
|
+
},
|
|
2101
|
+
children
|
|
2102
|
+
}
|
|
2103
|
+
),
|
|
2104
|
+
document.body
|
|
2105
|
+
)
|
|
2106
|
+
] });
|
|
2107
|
+
}
|
|
2108
|
+
function MenuItem({ onSelect, disabled = false, tone = "default", children }) {
|
|
2109
|
+
const menu = react.useContext(MenuContext);
|
|
2110
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2111
|
+
"button",
|
|
2112
|
+
{
|
|
2113
|
+
type: "button",
|
|
2114
|
+
role: "menuitem",
|
|
2115
|
+
tabIndex: -1,
|
|
2116
|
+
disabled,
|
|
2117
|
+
className: cx(Menu_module_default.item, Menu_module_default[`tone-${tone}`]),
|
|
2118
|
+
onClick: () => {
|
|
2119
|
+
onSelect();
|
|
2120
|
+
menu?.close();
|
|
2121
|
+
},
|
|
2122
|
+
children
|
|
2123
|
+
}
|
|
2124
|
+
);
|
|
2125
|
+
}
|
|
2126
|
+
|
|
2127
|
+
// mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Tooltip/Tooltip.module.css?mds-scoped
|
|
2128
|
+
var Tooltip_module_default = { "surface": "mds-Tooltip__surface" };
|
|
2129
|
+
var GAP3 = 8;
|
|
2130
|
+
var DEFAULT_DELAY_MS = 400;
|
|
2131
|
+
function Tooltip({
|
|
2132
|
+
content,
|
|
2133
|
+
placement = "top",
|
|
2134
|
+
delayMs = DEFAULT_DELAY_MS,
|
|
2135
|
+
children
|
|
2136
|
+
}) {
|
|
2137
|
+
const id = react.useId();
|
|
2138
|
+
const [open, setOpen] = react.useState(false);
|
|
2139
|
+
const anchorRef = react.useRef(null);
|
|
2140
|
+
const surfaceRef = react.useRef(null);
|
|
2141
|
+
const timer = react.useRef(void 0);
|
|
2142
|
+
const show = () => {
|
|
2143
|
+
clearTimeout(timer.current);
|
|
2144
|
+
setOpen(true);
|
|
2145
|
+
};
|
|
2146
|
+
const hide = () => {
|
|
2147
|
+
clearTimeout(timer.current);
|
|
2148
|
+
setOpen(false);
|
|
2149
|
+
};
|
|
2150
|
+
react.useEffect(() => clearTimeout(timer.current), []);
|
|
2151
|
+
useAnchoredPosition({ open, anchorRef, floatingRef: surfaceRef, placement, gap: GAP3 });
|
|
2152
|
+
react.useEffect(() => {
|
|
2153
|
+
if (!open) return;
|
|
2154
|
+
const onKeyDown = (event) => {
|
|
2155
|
+
if (event.key === "Escape") hide();
|
|
2156
|
+
};
|
|
2157
|
+
document.addEventListener("keydown", onKeyDown);
|
|
2158
|
+
return () => document.removeEventListener("keydown", onKeyDown);
|
|
2159
|
+
}, [open]);
|
|
2160
|
+
const { type: Trigger, props: triggerProps } = children;
|
|
2161
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2162
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2163
|
+
Trigger,
|
|
2164
|
+
{
|
|
2165
|
+
...triggerProps,
|
|
2166
|
+
ref: forkRef(anchorRef, triggerProps.ref),
|
|
2167
|
+
"aria-describedby": open ? id : triggerProps["aria-describedby"],
|
|
2168
|
+
onPointerEnter: (event) => {
|
|
2169
|
+
triggerProps.onPointerEnter?.(event);
|
|
2170
|
+
if (event.pointerType === "touch") return;
|
|
2171
|
+
clearTimeout(timer.current);
|
|
2172
|
+
timer.current = setTimeout(show, delayMs);
|
|
2173
|
+
},
|
|
2174
|
+
onPointerLeave: (event) => {
|
|
2175
|
+
triggerProps.onPointerLeave?.(event);
|
|
2176
|
+
hide();
|
|
2177
|
+
},
|
|
2178
|
+
onFocus: (event) => {
|
|
2179
|
+
triggerProps.onFocus?.(event);
|
|
2180
|
+
show();
|
|
2181
|
+
},
|
|
2182
|
+
onBlur: (event) => {
|
|
2183
|
+
triggerProps.onBlur?.(event);
|
|
2184
|
+
hide();
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
),
|
|
2188
|
+
open && reactDom.createPortal(
|
|
2189
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: surfaceRef, id, role: "tooltip", className: Tooltip_module_default.surface, children: content }),
|
|
2190
|
+
document.body
|
|
2191
|
+
)
|
|
2192
|
+
] });
|
|
2193
|
+
}
|
|
1888
2194
|
|
|
1889
2195
|
// mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/ConfirmDialog/ConfirmDialog.module.css?mds-scoped
|
|
1890
2196
|
var ConfirmDialog_module_default = { "description": "mds-ConfirmDialog__description", "error": "mds-ConfirmDialog__error" };
|
|
@@ -2430,7 +2736,7 @@ var distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
|
|
|
2430
2736
|
function Lightbox({ open, onClose, src, alt = "", caption, labels }) {
|
|
2431
2737
|
const [surface, setSurface] = react.useState(null);
|
|
2432
2738
|
const [scale, setScale] = react.useState(MIN_SCALE);
|
|
2433
|
-
const [
|
|
2739
|
+
const [offset2, setOffset] = react.useState(ORIGIN);
|
|
2434
2740
|
const points = react.useRef(/* @__PURE__ */ new Map());
|
|
2435
2741
|
const from = react.useRef({ spread: 0, scale: MIN_SCALE, x: 0, y: 0, offset: ORIGIN });
|
|
2436
2742
|
const [shown, setShown] = react.useState({ src, open });
|
|
@@ -2480,7 +2786,7 @@ function Lightbox({ open, onClose, src, alt = "", caption, labels }) {
|
|
|
2480
2786
|
from.current = { ...from.current, spread: distance(first, second), scale };
|
|
2481
2787
|
return;
|
|
2482
2788
|
}
|
|
2483
|
-
if (first) from.current = { ...from.current, x: first.x, y: first.y, offset };
|
|
2789
|
+
if (first) from.current = { ...from.current, x: first.x, y: first.y, offset: offset2 };
|
|
2484
2790
|
}
|
|
2485
2791
|
function onPointerMove(event) {
|
|
2486
2792
|
if (!points.current.has(event.pointerId)) return;
|
|
@@ -2507,12 +2813,12 @@ function Lightbox({ open, onClose, src, alt = "", caption, labels }) {
|
|
|
2507
2813
|
function onPointerUp(event) {
|
|
2508
2814
|
points.current.delete(event.pointerId);
|
|
2509
2815
|
const [rest] = [...points.current.values()];
|
|
2510
|
-
if (rest) from.current = { ...from.current, x: rest.x, y: rest.y, offset };
|
|
2816
|
+
if (rest) from.current = { ...from.current, x: rest.x, y: rest.y, offset: offset2 };
|
|
2511
2817
|
}
|
|
2512
2818
|
const vars = {
|
|
2513
2819
|
"--zoom": String(round(scale)),
|
|
2514
|
-
"--pan-x": `${round(
|
|
2515
|
-
"--pan-y": `${round(
|
|
2820
|
+
"--pan-x": `${round(offset2.x)}px`,
|
|
2821
|
+
"--pan-y": `${round(offset2.y)}px`
|
|
2516
2822
|
};
|
|
2517
2823
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2518
2824
|
Overlay,
|
|
@@ -2783,30 +3089,6 @@ function Breadcrumb({
|
|
|
2783
3089
|
] }, `${item.label}-${index}`);
|
|
2784
3090
|
}) }) });
|
|
2785
3091
|
}
|
|
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
3092
|
|
|
2811
3093
|
exports.AppBar = AppBar;
|
|
2812
3094
|
exports.Avatar = Avatar;
|
|
@@ -2842,12 +3124,18 @@ exports.Link = Link;
|
|
|
2842
3124
|
exports.ListGroup = ListGroup;
|
|
2843
3125
|
exports.ListItem = ListItem;
|
|
2844
3126
|
exports.MediaPlaceholder = MediaPlaceholder;
|
|
3127
|
+
exports.Menu = Menu;
|
|
3128
|
+
exports.MenuItem = MenuItem;
|
|
2845
3129
|
exports.Modal = Modal;
|
|
2846
3130
|
exports.ModalBody = ModalBody;
|
|
2847
3131
|
exports.ModalFooter = ModalFooter;
|
|
2848
3132
|
exports.ModalHeader = ModalHeader;
|
|
2849
3133
|
exports.OverlayHistoryContext = OverlayHistoryContext;
|
|
2850
3134
|
exports.PasswordInput = PasswordInput;
|
|
3135
|
+
exports.Popover = Popover;
|
|
3136
|
+
exports.PopoverBody = PopoverBody;
|
|
3137
|
+
exports.PopoverFooter = PopoverFooter;
|
|
3138
|
+
exports.PopoverHeader = PopoverHeader;
|
|
2851
3139
|
exports.ProgressBar = ProgressBar;
|
|
2852
3140
|
exports.Radio = Radio;
|
|
2853
3141
|
exports.Screen = Screen;
|
|
@@ -2877,6 +3165,7 @@ exports.Tag = Tag;
|
|
|
2877
3165
|
exports.Text = Text;
|
|
2878
3166
|
exports.Textarea = Textarea;
|
|
2879
3167
|
exports.ToastProvider = ToastProvider;
|
|
3168
|
+
exports.Tooltip = Tooltip;
|
|
2880
3169
|
exports.UploadProgress = UploadProgress;
|
|
2881
3170
|
exports.VideoPlayer = VideoPlayer;
|
|
2882
3171
|
exports.VisuallyHidden = VisuallyHidden;
|