@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.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createContext, createElement, useContext, Children, useId, useRef, useEffect, useState, useMemo, useCallback } from 'react';
|
|
2
2
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
|
+
import { autoUpdate, computePosition, offset, flip, size, shift } from '@floating-ui/dom';
|
|
4
5
|
|
|
5
6
|
// src/internal/cx.ts
|
|
6
7
|
function cx(...parts) {
|
|
@@ -78,15 +79,15 @@ function Heading({
|
|
|
78
79
|
// mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Spinner/Spinner.module.css?mds-scoped
|
|
79
80
|
var Spinner_module_default = { "spinner": "mds-Spinner__spinner"};
|
|
80
81
|
function Spinner({
|
|
81
|
-
size = 20,
|
|
82
|
+
size: size2 = 20,
|
|
82
83
|
label,
|
|
83
84
|
className,
|
|
84
85
|
style,
|
|
85
86
|
...rest
|
|
86
87
|
}) {
|
|
87
88
|
const vars = {
|
|
88
|
-
"--spinner-size": `${
|
|
89
|
-
"--spinner-border": `${Math.max(2, Math.round(
|
|
89
|
+
"--spinner-size": `${size2}px`,
|
|
90
|
+
"--spinner-border": `${Math.max(2, Math.round(size2 / 10))}px`
|
|
90
91
|
};
|
|
91
92
|
return /* @__PURE__ */ jsx(
|
|
92
93
|
"span",
|
|
@@ -108,7 +109,7 @@ function IconProvider({ render, children }) {
|
|
|
108
109
|
}
|
|
109
110
|
var SIZE_PX = { sm: 16, md: 20, lg: 24 };
|
|
110
111
|
var warned = /* @__PURE__ */ new Set();
|
|
111
|
-
function Icon({ name, size, label, className, ...rest }) {
|
|
112
|
+
function Icon({ name, size: size2, label, className, ...rest }) {
|
|
112
113
|
const render = useContext(IconContext);
|
|
113
114
|
if (render === null && !warned.has(name)) {
|
|
114
115
|
warned.add(name);
|
|
@@ -119,10 +120,10 @@ function Icon({ name, size, label, className, ...rest }) {
|
|
|
119
120
|
return /* @__PURE__ */ jsx(
|
|
120
121
|
"span",
|
|
121
122
|
{
|
|
122
|
-
className: cx(Icon_module_default.icon, Icon_module_default[`size-${
|
|
123
|
+
className: cx(Icon_module_default.icon, Icon_module_default[`size-${size2 ?? "slot"}`], className),
|
|
123
124
|
...label ? { role: "img", "aria-label": label } : { "aria-hidden": true },
|
|
124
125
|
...rest,
|
|
125
|
-
children: render?.(name, { size:
|
|
126
|
+
children: render?.(name, { size: size2 === void 0 ? void 0 : SIZE_PX[size2] })
|
|
126
127
|
}
|
|
127
128
|
);
|
|
128
129
|
}
|
|
@@ -132,7 +133,7 @@ var Button_module_default = { "button": "mds-Button__button", "size-sm": "mds-Bu
|
|
|
132
133
|
var ICON_PX = { sm: 16, md: 20, lg: 24 };
|
|
133
134
|
function Button({
|
|
134
135
|
variant = "primary",
|
|
135
|
-
size = "md",
|
|
136
|
+
size: size2 = "md",
|
|
136
137
|
shape,
|
|
137
138
|
onMedia = false,
|
|
138
139
|
iconLeft,
|
|
@@ -159,7 +160,7 @@ function Button({
|
|
|
159
160
|
className: cx(
|
|
160
161
|
Button_module_default.button,
|
|
161
162
|
Button_module_default[`variant-${variant}`],
|
|
162
|
-
Button_module_default[`size-${
|
|
163
|
+
Button_module_default[`size-${size2}`],
|
|
163
164
|
fullWidth && Button_module_default.fullWidth,
|
|
164
165
|
iconOnly && Button_module_default["icon-only"],
|
|
165
166
|
shape !== void 0 && Button_module_default[`shape-${shape}`],
|
|
@@ -170,7 +171,7 @@ function Button({
|
|
|
170
171
|
...own,
|
|
171
172
|
...rest,
|
|
172
173
|
children: [
|
|
173
|
-
loading ? /* @__PURE__ */ jsx("span", { className: Button_module_default.slot, children: /* @__PURE__ */ jsx(Spinner, { size: ICON_PX[
|
|
174
|
+
loading ? /* @__PURE__ */ jsx("span", { className: Button_module_default.slot, children: /* @__PURE__ */ jsx(Spinner, { size: ICON_PX[size2], label: "", "aria-hidden": "true" }) }) : iconLeft ? /* @__PURE__ */ jsx("span", { className: Button_module_default.slot, children: iconLeft }) : null,
|
|
174
175
|
body,
|
|
175
176
|
!loading && iconRight ? /* @__PURE__ */ jsx("span", { className: Button_module_default.slot, children: iconRight }) : null
|
|
176
177
|
]
|
|
@@ -182,7 +183,7 @@ function Button({
|
|
|
182
183
|
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" };
|
|
183
184
|
function Link({
|
|
184
185
|
variant = "inline",
|
|
185
|
-
size,
|
|
186
|
+
size: size2,
|
|
186
187
|
external = false,
|
|
187
188
|
as,
|
|
188
189
|
...rest
|
|
@@ -197,7 +198,7 @@ function Link({
|
|
|
197
198
|
className: cx(
|
|
198
199
|
Link_module_default.link,
|
|
199
200
|
Link_module_default[`variant-${variant}`],
|
|
200
|
-
|
|
201
|
+
size2 && Link_module_default[`size-${size2}`],
|
|
201
202
|
className
|
|
202
203
|
),
|
|
203
204
|
...externalProps,
|
|
@@ -218,7 +219,7 @@ function initials(name) {
|
|
|
218
219
|
function Avatar({
|
|
219
220
|
name,
|
|
220
221
|
src,
|
|
221
|
-
size = "md",
|
|
222
|
+
size: size2 = "md",
|
|
222
223
|
tone,
|
|
223
224
|
decorative = false,
|
|
224
225
|
className,
|
|
@@ -229,7 +230,7 @@ function Avatar({
|
|
|
229
230
|
{
|
|
230
231
|
className: cx(
|
|
231
232
|
Avatar_module_default.avatar,
|
|
232
|
-
Avatar_module_default[`size-${
|
|
233
|
+
Avatar_module_default[`size-${size2}`],
|
|
233
234
|
tone !== void 0 && Avatar_module_default[`tone-${tone}`],
|
|
234
235
|
className
|
|
235
236
|
),
|
|
@@ -253,7 +254,7 @@ var AvatarGroup_module_default = { "group": "mds-AvatarGroup__group", "item": "m
|
|
|
253
254
|
function AvatarGroup({
|
|
254
255
|
children,
|
|
255
256
|
max = 4,
|
|
256
|
-
size = "md",
|
|
257
|
+
size: size2 = "md",
|
|
257
258
|
overflowLabel,
|
|
258
259
|
className,
|
|
259
260
|
...rest
|
|
@@ -266,7 +267,7 @@ function AvatarGroup({
|
|
|
266
267
|
hidden > 0 && /* @__PURE__ */ jsxs(
|
|
267
268
|
"span",
|
|
268
269
|
{
|
|
269
|
-
className: cx(AvatarGroup_module_default.item, AvatarGroup_module_default.overflow, AvatarGroup_module_default[`size-${
|
|
270
|
+
className: cx(AvatarGroup_module_default.item, AvatarGroup_module_default.overflow, AvatarGroup_module_default[`size-${size2}`]),
|
|
270
271
|
"aria-label": overflowLabel(hidden),
|
|
271
272
|
children: [
|
|
272
273
|
"+",
|
|
@@ -517,7 +518,7 @@ function Field({ label, children, hint, error, required = false, className }) {
|
|
|
517
518
|
|
|
518
519
|
// mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Select/Select.module.css?mds-scoped
|
|
519
520
|
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" };
|
|
520
|
-
function Select({ size = "md", className, children, ...rest }) {
|
|
521
|
+
function Select({ size: size2 = "md", className, children, ...rest }) {
|
|
521
522
|
const field = useFieldContext();
|
|
522
523
|
return /* @__PURE__ */ jsxs("span", { className: Select_module_default.wrap, children: [
|
|
523
524
|
/* @__PURE__ */ jsx(
|
|
@@ -526,7 +527,7 @@ function Select({ size = "md", className, children, ...rest }) {
|
|
|
526
527
|
id: rest.id ?? field?.id,
|
|
527
528
|
"aria-describedby": rest["aria-describedby"] ?? field?.describedBy,
|
|
528
529
|
"aria-invalid": rest["aria-invalid"] ?? (field?.invalid || void 0),
|
|
529
|
-
className: cx(Select_module_default.select, Select_module_default[`size-${
|
|
530
|
+
className: cx(Select_module_default.select, Select_module_default[`size-${size2}`], className),
|
|
530
531
|
...rest,
|
|
531
532
|
children
|
|
532
533
|
}
|
|
@@ -540,7 +541,7 @@ var OverlayHistoryContext = createContext(null);
|
|
|
540
541
|
var FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
541
542
|
function useOverlay(options) {
|
|
542
543
|
const ref = useRef(null);
|
|
543
|
-
const { open, onClose } = options;
|
|
544
|
+
const { open, onClose, lockScroll = true } = options;
|
|
544
545
|
const close = useRef(onClose);
|
|
545
546
|
useEffect(() => {
|
|
546
547
|
close.current = onClose;
|
|
@@ -581,13 +582,13 @@ function useOverlay(options) {
|
|
|
581
582
|
};
|
|
582
583
|
document.addEventListener("keydown", onKeyDown);
|
|
583
584
|
const bodyOverflow = document.body.style.overflow;
|
|
584
|
-
document.body.style.overflow = "hidden";
|
|
585
|
+
if (lockScroll) document.body.style.overflow = "hidden";
|
|
585
586
|
return () => {
|
|
586
587
|
document.removeEventListener("keydown", onKeyDown);
|
|
587
|
-
document.body.style.overflow = bodyOverflow;
|
|
588
|
+
if (lockScroll) document.body.style.overflow = bodyOverflow;
|
|
588
589
|
previous?.focus();
|
|
589
590
|
};
|
|
590
|
-
}, [open]);
|
|
591
|
+
}, [open, lockScroll]);
|
|
591
592
|
return ref;
|
|
592
593
|
}
|
|
593
594
|
function usePresence(open, durationMs) {
|
|
@@ -1104,7 +1105,7 @@ function forkRef(own, given) {
|
|
|
1104
1105
|
// mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Input/Input.module.css?mds-scoped
|
|
1105
1106
|
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" };
|
|
1106
1107
|
function Input({
|
|
1107
|
-
size = "md",
|
|
1108
|
+
size: size2 = "md",
|
|
1108
1109
|
invalid,
|
|
1109
1110
|
iconLeft,
|
|
1110
1111
|
iconRight,
|
|
@@ -1138,7 +1139,7 @@ function Input({
|
|
|
1138
1139
|
"aria-invalid": rest["aria-invalid"] ?? ((invalid ?? field?.invalid) || void 0),
|
|
1139
1140
|
className: cx(
|
|
1140
1141
|
Input_module_default.input,
|
|
1141
|
-
Input_module_default[`size-${
|
|
1142
|
+
Input_module_default[`size-${size2}`],
|
|
1142
1143
|
iconLeft != null && Input_module_default["with-icon-left"],
|
|
1143
1144
|
(iconRight != null || showClear) && Input_module_default["with-icon-right"],
|
|
1144
1145
|
onClear != null && Input_module_default["own-clear"],
|
|
@@ -1149,7 +1150,7 @@ function Input({
|
|
|
1149
1150
|
}
|
|
1150
1151
|
);
|
|
1151
1152
|
if (iconLeft == null && iconRight == null && onClear == null) return input;
|
|
1152
|
-
return /* @__PURE__ */ jsxs("span", { className: cx(Input_module_default.iconWrap, Input_module_default[`slot-${
|
|
1153
|
+
return /* @__PURE__ */ jsxs("span", { className: cx(Input_module_default.iconWrap, Input_module_default[`slot-${size2}`]), children: [
|
|
1153
1154
|
input,
|
|
1154
1155
|
iconLeft != null && /* @__PURE__ */ jsx("span", { className: cx(Input_module_default.icon, Input_module_default.iconLeft), "aria-hidden": "true", children: iconLeft }),
|
|
1155
1156
|
iconRight != null && /* @__PURE__ */ jsx("span", { className: cx(Input_module_default.icon, Input_module_default.iconRight), "aria-hidden": "true", children: iconRight }),
|
|
@@ -1299,7 +1300,7 @@ function SegmentedControl({
|
|
|
1299
1300
|
onChange,
|
|
1300
1301
|
disabled = false,
|
|
1301
1302
|
fullWidth = false,
|
|
1302
|
-
size = "md",
|
|
1303
|
+
size: size2 = "md",
|
|
1303
1304
|
bare = false,
|
|
1304
1305
|
repick = false,
|
|
1305
1306
|
className
|
|
@@ -1312,7 +1313,7 @@ function SegmentedControl({
|
|
|
1312
1313
|
"aria-label": label,
|
|
1313
1314
|
className: cx(
|
|
1314
1315
|
SegmentedControl_module_default.group,
|
|
1315
|
-
SegmentedControl_module_default[`size-${
|
|
1316
|
+
SegmentedControl_module_default[`size-${size2}`],
|
|
1316
1317
|
fullWidth && SegmentedControl_module_default.fullWidth,
|
|
1317
1318
|
bare && SegmentedControl_module_default.bare,
|
|
1318
1319
|
className
|
|
@@ -1491,7 +1492,7 @@ function ListItem({
|
|
|
1491
1492
|
}
|
|
1492
1493
|
|
|
1493
1494
|
// mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/DataTable/DataTable.module.css?mds-scoped
|
|
1494
|
-
var DataTable_module_default = { "root": "mds-DataTable__root", "
|
|
1495
|
+
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" };
|
|
1495
1496
|
function DataTable({
|
|
1496
1497
|
label,
|
|
1497
1498
|
columns,
|
|
@@ -1526,13 +1527,19 @@ function DataTable({
|
|
|
1526
1527
|
return typeof first === "string" ? first : rowKey(row);
|
|
1527
1528
|
};
|
|
1528
1529
|
return /* @__PURE__ */ jsxs("div", { className: cx(DataTable_module_default.root, className), ref, ...rest, children: [
|
|
1529
|
-
/* @__PURE__ */ jsxs("table", { className: DataTable_module_default.table, "aria-label": label, children: [
|
|
1530
|
+
/* @__PURE__ */ jsx("div", { className: DataTable_module_default.scroll, role: "region", "aria-label": label, tabIndex: 0, children: /* @__PURE__ */ jsxs("table", { className: DataTable_module_default.table, "aria-label": label, children: [
|
|
1530
1531
|
/* @__PURE__ */ jsxs("colgroup", { children: [
|
|
1531
1532
|
selectable && /* @__PURE__ */ jsx("col", {}),
|
|
1532
|
-
columns.map((column) => /* @__PURE__ */ jsx(
|
|
1533
|
+
columns.map((column) => /* @__PURE__ */ jsx(
|
|
1534
|
+
"col",
|
|
1535
|
+
{
|
|
1536
|
+
style: column.width !== void 0 ? { width: column.width } : void 0
|
|
1537
|
+
},
|
|
1538
|
+
column.key
|
|
1539
|
+
)),
|
|
1533
1540
|
rowActions && /* @__PURE__ */ jsx("col", {})
|
|
1534
1541
|
] }),
|
|
1535
|
-
/* @__PURE__ */ jsx(
|
|
1542
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { className: DataTable_module_default.row, children: [
|
|
1536
1543
|
selectable && /* @__PURE__ */ jsx("th", { scope: "col", className: DataTable_module_default.select, children: /* @__PURE__ */ jsx(
|
|
1537
1544
|
Checkbox,
|
|
1538
1545
|
{
|
|
@@ -1552,7 +1559,11 @@ function DataTable({
|
|
|
1552
1559
|
return /* @__PURE__ */ jsxs(
|
|
1553
1560
|
"tr",
|
|
1554
1561
|
{
|
|
1555
|
-
className: cx(
|
|
1562
|
+
className: cx(
|
|
1563
|
+
DataTable_module_default.row,
|
|
1564
|
+
taken && DataTable_module_default.selected,
|
|
1565
|
+
rowMuted?.(row) === true && DataTable_module_default.muted
|
|
1566
|
+
),
|
|
1556
1567
|
children: [
|
|
1557
1568
|
selectable && /* @__PURE__ */ jsx("td", { className: DataTable_module_default.select, children: /* @__PURE__ */ jsx(
|
|
1558
1569
|
Checkbox,
|
|
@@ -1563,17 +1574,14 @@ function DataTable({
|
|
|
1563
1574
|
onChange: (event) => toggle(key, event.target.checked)
|
|
1564
1575
|
}
|
|
1565
1576
|
) }),
|
|
1566
|
-
columns.map((column
|
|
1567
|
-
index > 0 && /* @__PURE__ */ jsx("span", { className: DataTable_module_default.key, "aria-hidden": "true", children: column.header }),
|
|
1568
|
-
column.cell(row)
|
|
1569
|
-
] }, column.key)),
|
|
1577
|
+
columns.map((column) => /* @__PURE__ */ jsx("td", { className: DataTable_module_default.cell, children: column.cell(row) }, column.key)),
|
|
1570
1578
|
rowActions && /* @__PURE__ */ jsx("td", { className: DataTable_module_default.actions, children: rowActions(row) })
|
|
1571
1579
|
]
|
|
1572
1580
|
},
|
|
1573
1581
|
key
|
|
1574
1582
|
);
|
|
1575
1583
|
}) : empty !== void 0 && /* @__PURE__ */ jsx("tr", { className: DataTable_module_default.row, children: /* @__PURE__ */ jsx("td", { className: DataTable_module_default.empty, colSpan: span, children: /* @__PURE__ */ jsx(Text, { variant: "note", children: empty }) }) }) })
|
|
1576
|
-
] }),
|
|
1584
|
+
] }) }),
|
|
1577
1585
|
selectable && selected.length > 0 && bulkActions !== void 0 && /* @__PURE__ */ jsxs("div", { className: DataTable_module_default.bulk, role: "status", children: [
|
|
1578
1586
|
/* @__PURE__ */ jsx(Text, { variant: "meta", children: selectionLabels.count(selected.length) }),
|
|
1579
1587
|
/* @__PURE__ */ jsx("div", { className: DataTable_module_default.bulkActions, children: bulkActions })
|
|
@@ -1883,6 +1891,304 @@ function ModalBody({ children }) {
|
|
|
1883
1891
|
function ModalFooter({ children }) {
|
|
1884
1892
|
return /* @__PURE__ */ jsx("div", { className: Modal_module_default.footer, children });
|
|
1885
1893
|
}
|
|
1894
|
+
var VIEWPORT_PAD = 8;
|
|
1895
|
+
var MIN_HEIGHT = 120;
|
|
1896
|
+
function useAnchoredPosition({
|
|
1897
|
+
open,
|
|
1898
|
+
anchorRef,
|
|
1899
|
+
floatingRef,
|
|
1900
|
+
placement,
|
|
1901
|
+
gap
|
|
1902
|
+
}) {
|
|
1903
|
+
useEffect(() => {
|
|
1904
|
+
const anchor = anchorRef.current;
|
|
1905
|
+
const floating = floatingRef.current;
|
|
1906
|
+
if (!open || anchor === null || floating === null) return;
|
|
1907
|
+
const update = () => {
|
|
1908
|
+
void computePosition(anchor, floating, {
|
|
1909
|
+
placement,
|
|
1910
|
+
strategy: "fixed",
|
|
1911
|
+
middleware: [
|
|
1912
|
+
offset(gap),
|
|
1913
|
+
// Order is load-bearing: choose the side first, then cap the height
|
|
1914
|
+
// to what that side has, then slide along the cross axis. Sizing
|
|
1915
|
+
// before flipping caps against the side being abandoned.
|
|
1916
|
+
flip({ padding: VIEWPORT_PAD }),
|
|
1917
|
+
size({
|
|
1918
|
+
padding: VIEWPORT_PAD,
|
|
1919
|
+
apply({ availableHeight, elements }) {
|
|
1920
|
+
elements.floating.style.maxHeight = `${Math.max(availableHeight, MIN_HEIGHT)}px`;
|
|
1921
|
+
}
|
|
1922
|
+
}),
|
|
1923
|
+
shift({ padding: VIEWPORT_PAD })
|
|
1924
|
+
]
|
|
1925
|
+
}).then(({ x, y, placement: resolved }) => {
|
|
1926
|
+
floating.style.left = `${x}px`;
|
|
1927
|
+
floating.style.top = `${y}px`;
|
|
1928
|
+
floating.dataset.placement = resolved;
|
|
1929
|
+
});
|
|
1930
|
+
};
|
|
1931
|
+
return autoUpdate(anchor, floating, update);
|
|
1932
|
+
}, [open, anchorRef, floatingRef, placement, gap]);
|
|
1933
|
+
}
|
|
1934
|
+
function useDismissOnOutside(open, onDismiss, inside) {
|
|
1935
|
+
const latest = useRef({ onDismiss, inside });
|
|
1936
|
+
useEffect(() => {
|
|
1937
|
+
latest.current = { onDismiss, inside };
|
|
1938
|
+
});
|
|
1939
|
+
useEffect(() => {
|
|
1940
|
+
if (!open) return;
|
|
1941
|
+
const onPointerDown = (event) => {
|
|
1942
|
+
const target = event.target;
|
|
1943
|
+
if (!(target instanceof Node)) return;
|
|
1944
|
+
const { onDismiss: dismiss, inside: refs } = latest.current;
|
|
1945
|
+
if (refs.some((ref) => ref.current?.contains(target))) return;
|
|
1946
|
+
dismiss();
|
|
1947
|
+
};
|
|
1948
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
1949
|
+
return () => document.removeEventListener("pointerdown", onPointerDown);
|
|
1950
|
+
}, [open]);
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
// mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Popover/Popover.module.css?mds-scoped
|
|
1954
|
+
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" };
|
|
1955
|
+
var POPOVER_EXIT_MS = 120;
|
|
1956
|
+
var GAP = 8;
|
|
1957
|
+
function Popover({
|
|
1958
|
+
open,
|
|
1959
|
+
onClose,
|
|
1960
|
+
anchorRef,
|
|
1961
|
+
label,
|
|
1962
|
+
placement = "bottom-start",
|
|
1963
|
+
className,
|
|
1964
|
+
children
|
|
1965
|
+
}) {
|
|
1966
|
+
const { mounted, visible } = usePresence(open, POPOVER_EXIT_MS);
|
|
1967
|
+
const panelRef = useOverlay({ open, onClose, lockScroll: false });
|
|
1968
|
+
useAnchoredPosition({ open: mounted, anchorRef, floatingRef: panelRef, placement, gap: GAP });
|
|
1969
|
+
useDismissOnOutside(open, onClose, [panelRef, anchorRef]);
|
|
1970
|
+
if (!mounted) return null;
|
|
1971
|
+
return createPortal(
|
|
1972
|
+
/* @__PURE__ */ jsx(
|
|
1973
|
+
"div",
|
|
1974
|
+
{
|
|
1975
|
+
ref: panelRef,
|
|
1976
|
+
role: "dialog",
|
|
1977
|
+
"aria-label": label,
|
|
1978
|
+
tabIndex: -1,
|
|
1979
|
+
className: cx(Popover_module_default.panel, className),
|
|
1980
|
+
"data-open": visible || void 0,
|
|
1981
|
+
children
|
|
1982
|
+
}
|
|
1983
|
+
),
|
|
1984
|
+
document.body
|
|
1985
|
+
);
|
|
1986
|
+
}
|
|
1987
|
+
function PopoverHeader({ children, onClose, closeLabel }) {
|
|
1988
|
+
return /* @__PURE__ */ jsxs("div", { className: Popover_module_default.header, children: [
|
|
1989
|
+
/* @__PURE__ */ jsx("h2", { className: Popover_module_default.headerTitle, children }),
|
|
1990
|
+
onClose !== void 0 && /* @__PURE__ */ jsx("button", { type: "button", "aria-label": closeLabel, className: Popover_module_default.close, onClick: onClose, children: /* @__PURE__ */ jsx(CloseGlyph, { className: Popover_module_default.closeGlyph }) })
|
|
1991
|
+
] });
|
|
1992
|
+
}
|
|
1993
|
+
function PopoverBody({ children }) {
|
|
1994
|
+
return /* @__PURE__ */ jsx("div", { className: Popover_module_default.body, children });
|
|
1995
|
+
}
|
|
1996
|
+
function PopoverFooter({ children }) {
|
|
1997
|
+
return /* @__PURE__ */ jsx("div", { className: Popover_module_default.footer, children });
|
|
1998
|
+
}
|
|
1999
|
+
function useRovingGroup(ref, { selector, orientation = "horizontal" }) {
|
|
2000
|
+
return useCallback(
|
|
2001
|
+
(event) => {
|
|
2002
|
+
const horizontal = orientation !== "vertical";
|
|
2003
|
+
const vertical = orientation !== "horizontal";
|
|
2004
|
+
const forward = horizontal && event.key === "ArrowRight" || vertical && event.key === "ArrowDown";
|
|
2005
|
+
const backward = horizontal && event.key === "ArrowLeft" || vertical && event.key === "ArrowUp";
|
|
2006
|
+
const home = event.key === "Home";
|
|
2007
|
+
const end = event.key === "End";
|
|
2008
|
+
if (!forward && !backward && !home && !end) return;
|
|
2009
|
+
const container = ref.current;
|
|
2010
|
+
if (container === null) return;
|
|
2011
|
+
const items = [...container.querySelectorAll(selector)].filter(
|
|
2012
|
+
(item) => !item.hasAttribute("disabled")
|
|
2013
|
+
);
|
|
2014
|
+
const current = items.indexOf(document.activeElement);
|
|
2015
|
+
if (items.length === 0 || current === -1) return;
|
|
2016
|
+
event.preventDefault();
|
|
2017
|
+
const next = home ? 0 : end ? items.length - 1 : (current + (forward ? 1 : -1) + items.length) % items.length;
|
|
2018
|
+
items[next]?.focus();
|
|
2019
|
+
},
|
|
2020
|
+
[ref, selector, orientation]
|
|
2021
|
+
);
|
|
2022
|
+
}
|
|
2023
|
+
|
|
2024
|
+
// mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Menu/Menu.module.css?mds-scoped
|
|
2025
|
+
var Menu_module_default = { "panel": "mds-Menu__panel", "item": "mds-Menu__item", "tone-danger": "mds-Menu__tone-danger" };
|
|
2026
|
+
var MENU_EXIT_MS = 120;
|
|
2027
|
+
var GAP2 = 8;
|
|
2028
|
+
var ITEM_SELECTOR = '[role="menuitem"]';
|
|
2029
|
+
var MenuContext = createContext(null);
|
|
2030
|
+
function Menu({ label, trigger, placement = "bottom-end", className, children }) {
|
|
2031
|
+
const [open, setOpen] = useState(false);
|
|
2032
|
+
const { mounted, visible } = usePresence(open, MENU_EXIT_MS);
|
|
2033
|
+
const triggerRef = useRef(null);
|
|
2034
|
+
const panelRef = useRef(null);
|
|
2035
|
+
const close = () => {
|
|
2036
|
+
setOpen(false);
|
|
2037
|
+
triggerRef.current?.focus();
|
|
2038
|
+
};
|
|
2039
|
+
const dismiss = () => setOpen(false);
|
|
2040
|
+
useAnchoredPosition({ open: mounted, anchorRef: triggerRef, floatingRef: panelRef, placement, gap: GAP2 });
|
|
2041
|
+
useDismissOnOutside(open, dismiss, [panelRef, triggerRef]);
|
|
2042
|
+
const onArrowKeys = useRovingGroup(panelRef, {
|
|
2043
|
+
selector: ITEM_SELECTOR,
|
|
2044
|
+
orientation: "vertical"
|
|
2045
|
+
});
|
|
2046
|
+
useEffect(() => {
|
|
2047
|
+
if (!open) return;
|
|
2048
|
+
const first = panelRef.current?.querySelector(
|
|
2049
|
+
`${ITEM_SELECTOR}:not([disabled])`
|
|
2050
|
+
);
|
|
2051
|
+
first?.focus();
|
|
2052
|
+
}, [open]);
|
|
2053
|
+
const openWithKeyboard = (event) => {
|
|
2054
|
+
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
|
|
2055
|
+
event.preventDefault();
|
|
2056
|
+
setOpen(true);
|
|
2057
|
+
};
|
|
2058
|
+
const { type: Trigger, props: triggerProps } = trigger;
|
|
2059
|
+
return /* @__PURE__ */ jsxs(MenuContext.Provider, { value: { close }, children: [
|
|
2060
|
+
/* @__PURE__ */ jsx(
|
|
2061
|
+
Trigger,
|
|
2062
|
+
{
|
|
2063
|
+
...triggerProps,
|
|
2064
|
+
ref: forkRef(triggerRef, triggerProps.ref),
|
|
2065
|
+
"aria-haspopup": "menu",
|
|
2066
|
+
"aria-expanded": open,
|
|
2067
|
+
onClick: (event) => {
|
|
2068
|
+
triggerProps.onClick?.(event);
|
|
2069
|
+
setOpen((v) => !v);
|
|
2070
|
+
},
|
|
2071
|
+
onKeyDown: (event) => {
|
|
2072
|
+
triggerProps.onKeyDown?.(event);
|
|
2073
|
+
openWithKeyboard(event);
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
),
|
|
2077
|
+
mounted && createPortal(
|
|
2078
|
+
/* @__PURE__ */ jsx(
|
|
2079
|
+
"div",
|
|
2080
|
+
{
|
|
2081
|
+
ref: panelRef,
|
|
2082
|
+
role: "menu",
|
|
2083
|
+
"aria-label": label,
|
|
2084
|
+
className: cx(Menu_module_default.panel, className),
|
|
2085
|
+
"data-open": visible || void 0,
|
|
2086
|
+
onKeyDown: (event) => {
|
|
2087
|
+
if (event.key === "Escape") {
|
|
2088
|
+
event.stopPropagation();
|
|
2089
|
+
close();
|
|
2090
|
+
return;
|
|
2091
|
+
}
|
|
2092
|
+
if (event.key === "Tab") {
|
|
2093
|
+
event.preventDefault();
|
|
2094
|
+
close();
|
|
2095
|
+
return;
|
|
2096
|
+
}
|
|
2097
|
+
onArrowKeys(event);
|
|
2098
|
+
},
|
|
2099
|
+
children
|
|
2100
|
+
}
|
|
2101
|
+
),
|
|
2102
|
+
document.body
|
|
2103
|
+
)
|
|
2104
|
+
] });
|
|
2105
|
+
}
|
|
2106
|
+
function MenuItem({ onSelect, disabled = false, tone = "default", children }) {
|
|
2107
|
+
const menu = useContext(MenuContext);
|
|
2108
|
+
return /* @__PURE__ */ jsx(
|
|
2109
|
+
"button",
|
|
2110
|
+
{
|
|
2111
|
+
type: "button",
|
|
2112
|
+
role: "menuitem",
|
|
2113
|
+
tabIndex: -1,
|
|
2114
|
+
disabled,
|
|
2115
|
+
className: cx(Menu_module_default.item, Menu_module_default[`tone-${tone}`]),
|
|
2116
|
+
onClick: () => {
|
|
2117
|
+
onSelect();
|
|
2118
|
+
menu?.close();
|
|
2119
|
+
},
|
|
2120
|
+
children
|
|
2121
|
+
}
|
|
2122
|
+
);
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
// mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/Tooltip/Tooltip.module.css?mds-scoped
|
|
2126
|
+
var Tooltip_module_default = { "surface": "mds-Tooltip__surface" };
|
|
2127
|
+
var GAP3 = 8;
|
|
2128
|
+
var DEFAULT_DELAY_MS = 400;
|
|
2129
|
+
function Tooltip({
|
|
2130
|
+
content,
|
|
2131
|
+
placement = "top",
|
|
2132
|
+
delayMs = DEFAULT_DELAY_MS,
|
|
2133
|
+
children
|
|
2134
|
+
}) {
|
|
2135
|
+
const id = useId();
|
|
2136
|
+
const [open, setOpen] = useState(false);
|
|
2137
|
+
const anchorRef = useRef(null);
|
|
2138
|
+
const surfaceRef = useRef(null);
|
|
2139
|
+
const timer = useRef(void 0);
|
|
2140
|
+
const show = () => {
|
|
2141
|
+
clearTimeout(timer.current);
|
|
2142
|
+
setOpen(true);
|
|
2143
|
+
};
|
|
2144
|
+
const hide = () => {
|
|
2145
|
+
clearTimeout(timer.current);
|
|
2146
|
+
setOpen(false);
|
|
2147
|
+
};
|
|
2148
|
+
useEffect(() => clearTimeout(timer.current), []);
|
|
2149
|
+
useAnchoredPosition({ open, anchorRef, floatingRef: surfaceRef, placement, gap: GAP3 });
|
|
2150
|
+
useEffect(() => {
|
|
2151
|
+
if (!open) return;
|
|
2152
|
+
const onKeyDown = (event) => {
|
|
2153
|
+
if (event.key === "Escape") hide();
|
|
2154
|
+
};
|
|
2155
|
+
document.addEventListener("keydown", onKeyDown);
|
|
2156
|
+
return () => document.removeEventListener("keydown", onKeyDown);
|
|
2157
|
+
}, [open]);
|
|
2158
|
+
const { type: Trigger, props: triggerProps } = children;
|
|
2159
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2160
|
+
/* @__PURE__ */ jsx(
|
|
2161
|
+
Trigger,
|
|
2162
|
+
{
|
|
2163
|
+
...triggerProps,
|
|
2164
|
+
ref: forkRef(anchorRef, triggerProps.ref),
|
|
2165
|
+
"aria-describedby": open ? id : triggerProps["aria-describedby"],
|
|
2166
|
+
onPointerEnter: (event) => {
|
|
2167
|
+
triggerProps.onPointerEnter?.(event);
|
|
2168
|
+
if (event.pointerType === "touch") return;
|
|
2169
|
+
clearTimeout(timer.current);
|
|
2170
|
+
timer.current = setTimeout(show, delayMs);
|
|
2171
|
+
},
|
|
2172
|
+
onPointerLeave: (event) => {
|
|
2173
|
+
triggerProps.onPointerLeave?.(event);
|
|
2174
|
+
hide();
|
|
2175
|
+
},
|
|
2176
|
+
onFocus: (event) => {
|
|
2177
|
+
triggerProps.onFocus?.(event);
|
|
2178
|
+
show();
|
|
2179
|
+
},
|
|
2180
|
+
onBlur: (event) => {
|
|
2181
|
+
triggerProps.onBlur?.(event);
|
|
2182
|
+
hide();
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
),
|
|
2186
|
+
open && createPortal(
|
|
2187
|
+
/* @__PURE__ */ jsx("div", { ref: surfaceRef, id, role: "tooltip", className: Tooltip_module_default.surface, children: content }),
|
|
2188
|
+
document.body
|
|
2189
|
+
)
|
|
2190
|
+
] });
|
|
2191
|
+
}
|
|
1886
2192
|
|
|
1887
2193
|
// mds-cssmod:/home/runner/work/mond-design-system/mond-design-system/packages/react/src/components/ConfirmDialog/ConfirmDialog.module.css?mds-scoped
|
|
1888
2194
|
var ConfirmDialog_module_default = { "description": "mds-ConfirmDialog__description", "error": "mds-ConfirmDialog__error" };
|
|
@@ -2428,7 +2734,7 @@ var distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
|
|
|
2428
2734
|
function Lightbox({ open, onClose, src, alt = "", caption, labels }) {
|
|
2429
2735
|
const [surface, setSurface] = useState(null);
|
|
2430
2736
|
const [scale, setScale] = useState(MIN_SCALE);
|
|
2431
|
-
const [
|
|
2737
|
+
const [offset2, setOffset] = useState(ORIGIN);
|
|
2432
2738
|
const points = useRef(/* @__PURE__ */ new Map());
|
|
2433
2739
|
const from = useRef({ spread: 0, scale: MIN_SCALE, x: 0, y: 0, offset: ORIGIN });
|
|
2434
2740
|
const [shown, setShown] = useState({ src, open });
|
|
@@ -2478,7 +2784,7 @@ function Lightbox({ open, onClose, src, alt = "", caption, labels }) {
|
|
|
2478
2784
|
from.current = { ...from.current, spread: distance(first, second), scale };
|
|
2479
2785
|
return;
|
|
2480
2786
|
}
|
|
2481
|
-
if (first) from.current = { ...from.current, x: first.x, y: first.y, offset };
|
|
2787
|
+
if (first) from.current = { ...from.current, x: first.x, y: first.y, offset: offset2 };
|
|
2482
2788
|
}
|
|
2483
2789
|
function onPointerMove(event) {
|
|
2484
2790
|
if (!points.current.has(event.pointerId)) return;
|
|
@@ -2505,12 +2811,12 @@ function Lightbox({ open, onClose, src, alt = "", caption, labels }) {
|
|
|
2505
2811
|
function onPointerUp(event) {
|
|
2506
2812
|
points.current.delete(event.pointerId);
|
|
2507
2813
|
const [rest] = [...points.current.values()];
|
|
2508
|
-
if (rest) from.current = { ...from.current, x: rest.x, y: rest.y, offset };
|
|
2814
|
+
if (rest) from.current = { ...from.current, x: rest.x, y: rest.y, offset: offset2 };
|
|
2509
2815
|
}
|
|
2510
2816
|
const vars = {
|
|
2511
2817
|
"--zoom": String(round(scale)),
|
|
2512
|
-
"--pan-x": `${round(
|
|
2513
|
-
"--pan-y": `${round(
|
|
2818
|
+
"--pan-x": `${round(offset2.x)}px`,
|
|
2819
|
+
"--pan-y": `${round(offset2.y)}px`
|
|
2514
2820
|
};
|
|
2515
2821
|
return /* @__PURE__ */ jsxs(
|
|
2516
2822
|
Overlay,
|
|
@@ -2781,31 +3087,7 @@ function Breadcrumb({
|
|
|
2781
3087
|
] }, `${item.label}-${index}`);
|
|
2782
3088
|
}) }) });
|
|
2783
3089
|
}
|
|
2784
|
-
function useRovingGroup(ref, { selector, orientation = "horizontal" }) {
|
|
2785
|
-
return useCallback(
|
|
2786
|
-
(event) => {
|
|
2787
|
-
const horizontal = orientation !== "vertical";
|
|
2788
|
-
const vertical = orientation !== "horizontal";
|
|
2789
|
-
const forward = horizontal && event.key === "ArrowRight" || vertical && event.key === "ArrowDown";
|
|
2790
|
-
const backward = horizontal && event.key === "ArrowLeft" || vertical && event.key === "ArrowUp";
|
|
2791
|
-
const home = event.key === "Home";
|
|
2792
|
-
const end = event.key === "End";
|
|
2793
|
-
if (!forward && !backward && !home && !end) return;
|
|
2794
|
-
const container = ref.current;
|
|
2795
|
-
if (container === null) return;
|
|
2796
|
-
const items = [...container.querySelectorAll(selector)].filter(
|
|
2797
|
-
(item) => !item.hasAttribute("disabled")
|
|
2798
|
-
);
|
|
2799
|
-
const current = items.indexOf(document.activeElement);
|
|
2800
|
-
if (items.length === 0 || current === -1) return;
|
|
2801
|
-
event.preventDefault();
|
|
2802
|
-
const next = home ? 0 : end ? items.length - 1 : (current + (forward ? 1 : -1) + items.length) % items.length;
|
|
2803
|
-
items[next]?.focus();
|
|
2804
|
-
},
|
|
2805
|
-
[ref, selector, orientation]
|
|
2806
|
-
);
|
|
2807
|
-
}
|
|
2808
3090
|
|
|
2809
|
-
export { AppBar, Avatar, AvatarGroup, Badge, Breadcrumb, Button, Card, CardBody, CardFooter, CardHeader, Checkbox, Chip, ChipBar, ChipGroup, ConfirmDialog, Container, CountButton, DataTable, DateTimePicker, Divider, EmptyState, Field, FileDrop, Heading, Icon, IconProvider, ImageCarousel, Inline, Input, Lightbox, Link, ListGroup, ListItem, MediaPlaceholder, Modal, ModalBody, ModalFooter, ModalHeader, OverlayHistoryContext, PasswordInput, ProgressBar, Radio, Screen, ScreenContent, Scroller, SegmentedControl, Select, Sheet, SheetBody, SheetFooter, SheetHeader, SideNav, SideNavGroup, SideNavItem, Skeleton, Spinner, Stack, Switch, Tab, TabBar, TabBarAction, TabBarItem, TabList, TabPanel, Tabs, Tag, Text, Textarea, ToastProvider, UploadProgress, VideoPlayer, VisuallyHidden, cx, useFieldContext, useOverlay, usePresence, useRovingGroup, useToast };
|
|
3091
|
+
export { AppBar, Avatar, AvatarGroup, Badge, Breadcrumb, Button, Card, CardBody, CardFooter, CardHeader, Checkbox, Chip, ChipBar, ChipGroup, ConfirmDialog, Container, CountButton, DataTable, DateTimePicker, Divider, EmptyState, Field, FileDrop, Heading, Icon, IconProvider, ImageCarousel, Inline, Input, Lightbox, Link, ListGroup, ListItem, MediaPlaceholder, Menu, MenuItem, Modal, ModalBody, ModalFooter, ModalHeader, OverlayHistoryContext, PasswordInput, Popover, PopoverBody, PopoverFooter, PopoverHeader, ProgressBar, Radio, Screen, ScreenContent, Scroller, SegmentedControl, Select, Sheet, SheetBody, SheetFooter, SheetHeader, SideNav, SideNavGroup, SideNavItem, Skeleton, Spinner, Stack, Switch, Tab, TabBar, TabBarAction, TabBarItem, TabList, TabPanel, Tabs, Tag, Text, Textarea, ToastProvider, Tooltip, UploadProgress, VideoPlayer, VisuallyHidden, cx, useFieldContext, useOverlay, usePresence, useRovingGroup, useToast };
|
|
2810
3092
|
//# sourceMappingURL=index.js.map
|
|
2811
3093
|
//# sourceMappingURL=index.js.map
|