@nubitio/ui 0.6.5 → 0.6.9
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 +452 -40
- package/dist/index.d.cts +351 -2
- package/dist/index.d.mts +351 -2
- package/dist/index.mjs +435 -41
- package/dist/style.css +740 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -133,7 +133,12 @@ const EN_UI_STRINGS = {
|
|
|
133
133
|
confirm: "Confirm",
|
|
134
134
|
back: "Back",
|
|
135
135
|
previousYears: "Previous years",
|
|
136
|
-
nextYears: "Next years"
|
|
136
|
+
nextYears: "Next years",
|
|
137
|
+
rowActions: "Actions",
|
|
138
|
+
view: "View",
|
|
139
|
+
pages: "Pages",
|
|
140
|
+
previousPage: "Previous page",
|
|
141
|
+
nextPage: "Next page"
|
|
137
142
|
};
|
|
138
143
|
const ES_UI_STRINGS = {
|
|
139
144
|
close: "Cerrar",
|
|
@@ -156,7 +161,12 @@ const ES_UI_STRINGS = {
|
|
|
156
161
|
confirm: "Confirmar",
|
|
157
162
|
back: "Volver",
|
|
158
163
|
previousYears: "Años anteriores",
|
|
159
|
-
nextYears: "Años siguientes"
|
|
164
|
+
nextYears: "Años siguientes",
|
|
165
|
+
rowActions: "Acciones",
|
|
166
|
+
view: "Ver",
|
|
167
|
+
pages: "Páginas",
|
|
168
|
+
previousPage: "Página anterior",
|
|
169
|
+
nextPage: "Página siguiente"
|
|
160
170
|
};
|
|
161
171
|
const UiStringsContext = (0, react.createContext)(EN_UI_STRINGS);
|
|
162
172
|
const UiStringsProvider = ({ strings, children }) => {
|
|
@@ -332,18 +342,35 @@ const AppToolbar = ({ title, additionalToolbarContent, showRefreshButton = true,
|
|
|
332
342
|
});
|
|
333
343
|
};
|
|
334
344
|
//#endregion
|
|
345
|
+
//#region packages/ui/layoutUtils.ts
|
|
346
|
+
function joinClasses(...parts) {
|
|
347
|
+
return parts.filter(Boolean).join(" ");
|
|
348
|
+
}
|
|
349
|
+
function gapClass(prefix, gap) {
|
|
350
|
+
return gap ? `${prefix}--gap-${gap}` : "";
|
|
351
|
+
}
|
|
352
|
+
function colSpanClasses(span, spanSm, spanMd, spanLg) {
|
|
353
|
+
const classes = ["nb-col"];
|
|
354
|
+
if (span != null) classes.push(`nb-col--span-${span}`);
|
|
355
|
+
if (spanSm != null) classes.push(`nb-col--span-sm-${spanSm}`);
|
|
356
|
+
if (spanMd != null) classes.push(`nb-col--span-md-${spanMd}`);
|
|
357
|
+
if (spanLg != null) classes.push(`nb-col--span-lg-${spanLg}`);
|
|
358
|
+
return classes;
|
|
359
|
+
}
|
|
360
|
+
//#endregion
|
|
335
361
|
//#region packages/ui/Card.tsx
|
|
336
|
-
const Card = ({ title, description, children }) => {
|
|
362
|
+
const Card = ({ title, description, variant = "auth", className, children }) => {
|
|
363
|
+
const showHeader = Boolean(title || description);
|
|
337
364
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
338
|
-
className: "nb-card",
|
|
365
|
+
className: joinClasses("nb-card", variant === "panel" && "nb-card--panel", className),
|
|
339
366
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
340
367
|
className: "nb-card__content content",
|
|
341
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
368
|
+
children: [showHeader && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
342
369
|
className: "header",
|
|
343
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
370
|
+
children: [title && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
344
371
|
className: "title",
|
|
345
372
|
children: title
|
|
346
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
373
|
+
}), description && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
347
374
|
className: "description",
|
|
348
375
|
children: description
|
|
349
376
|
})]
|
|
@@ -1366,6 +1393,39 @@ const Toggle = ({ checked, onChange, label, size = "md", disabled = false, "aria
|
|
|
1366
1393
|
};
|
|
1367
1394
|
//#endregion
|
|
1368
1395
|
//#region packages/ui/ContextMenu.tsx
|
|
1396
|
+
const MENU_MIN_WIDTH = 190;
|
|
1397
|
+
function getDropdownStyle(anchor, align) {
|
|
1398
|
+
if (!anchor) return {
|
|
1399
|
+
position: "fixed",
|
|
1400
|
+
visibility: "hidden",
|
|
1401
|
+
margin: 0
|
|
1402
|
+
};
|
|
1403
|
+
const rect = anchor.getBoundingClientRect();
|
|
1404
|
+
const menuWidth = MENU_MIN_WIDTH;
|
|
1405
|
+
const left = align === "right" ? Math.max(8, Math.min(rect.right - menuWidth, window.innerWidth - menuWidth - 8)) : Math.max(8, Math.min(rect.left, window.innerWidth - menuWidth - 8));
|
|
1406
|
+
const spaceBelow = window.innerHeight - rect.bottom;
|
|
1407
|
+
const spaceAbove = rect.top;
|
|
1408
|
+
if (spaceBelow < 200 && spaceAbove > spaceBelow) return {
|
|
1409
|
+
position: "fixed",
|
|
1410
|
+
left: `${left}px`,
|
|
1411
|
+
width: `${menuWidth}px`,
|
|
1412
|
+
bottom: `${window.innerHeight - rect.top + 4}px`,
|
|
1413
|
+
top: "auto",
|
|
1414
|
+
margin: 0,
|
|
1415
|
+
zIndex: 1600,
|
|
1416
|
+
visibility: "visible"
|
|
1417
|
+
};
|
|
1418
|
+
return {
|
|
1419
|
+
position: "fixed",
|
|
1420
|
+
left: `${left}px`,
|
|
1421
|
+
width: `${menuWidth}px`,
|
|
1422
|
+
top: `${rect.bottom + 4}px`,
|
|
1423
|
+
bottom: "auto",
|
|
1424
|
+
margin: 0,
|
|
1425
|
+
zIndex: 1600,
|
|
1426
|
+
visibility: "visible"
|
|
1427
|
+
};
|
|
1428
|
+
}
|
|
1369
1429
|
/**
|
|
1370
1430
|
* Three-dot overflow context menu.
|
|
1371
1431
|
* Replaces the legacy `shared/ui/library/card-menu/CardMenu` component.
|
|
@@ -1377,14 +1437,23 @@ const Toggle = ({ checked, onChange, label, size = "md", disabled = false, "aria
|
|
|
1377
1437
|
* - Custom trigger slot
|
|
1378
1438
|
* - Left/right alignment
|
|
1379
1439
|
* - Click-outside + Escape to close
|
|
1440
|
+
* - Portalled dropdown (avoids clip inside scrollable tables)
|
|
1380
1441
|
*/
|
|
1381
1442
|
const ContextMenu = ({ items, visible = true, trigger, triggerLabel = "Opciones", align = "right", className = "" }) => {
|
|
1382
1443
|
const [open, setOpen] = (0, react.useState)(false);
|
|
1383
1444
|
const containerRef = (0, react.useRef)(null);
|
|
1445
|
+
const menuRef = (0, react.useRef)(null);
|
|
1446
|
+
const [menuStyle, setMenuStyle] = (0, react.useState)({
|
|
1447
|
+
position: "fixed",
|
|
1448
|
+
visibility: "hidden",
|
|
1449
|
+
margin: 0
|
|
1450
|
+
});
|
|
1451
|
+
const computeMenuStyle = (0, react.useCallback)(() => getDropdownStyle(containerRef.current, align), [align]);
|
|
1384
1452
|
(0, react.useEffect)(() => {
|
|
1385
1453
|
if (!open) return;
|
|
1386
1454
|
const onMouseDown = (e) => {
|
|
1387
|
-
|
|
1455
|
+
const target = e.target;
|
|
1456
|
+
if (!containerRef.current?.contains(target) && !menuRef.current?.contains(target)) setOpen(false);
|
|
1388
1457
|
};
|
|
1389
1458
|
const onKeyDown = (e) => {
|
|
1390
1459
|
if (e.key === "Escape") setOpen(false);
|
|
@@ -1396,11 +1465,57 @@ const ContextMenu = ({ items, visible = true, trigger, triggerLabel = "Opciones"
|
|
|
1396
1465
|
document.removeEventListener("keydown", onKeyDown);
|
|
1397
1466
|
};
|
|
1398
1467
|
}, [open]);
|
|
1468
|
+
(0, react.useLayoutEffect)(() => {
|
|
1469
|
+
if (!open) return;
|
|
1470
|
+
const update = () => {
|
|
1471
|
+
if (!containerRef.current) return;
|
|
1472
|
+
const rect = containerRef.current.getBoundingClientRect();
|
|
1473
|
+
if ((rect.width > 0 || rect.height > 0) && (rect.top >= window.innerHeight || rect.bottom <= 0)) {
|
|
1474
|
+
setOpen(false);
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
setMenuStyle(computeMenuStyle());
|
|
1478
|
+
};
|
|
1479
|
+
update();
|
|
1480
|
+
window.addEventListener("resize", update);
|
|
1481
|
+
window.addEventListener("scroll", update, {
|
|
1482
|
+
capture: true,
|
|
1483
|
+
passive: true
|
|
1484
|
+
});
|
|
1485
|
+
return () => {
|
|
1486
|
+
window.removeEventListener("resize", update);
|
|
1487
|
+
window.removeEventListener("scroll", update, { capture: true });
|
|
1488
|
+
};
|
|
1489
|
+
}, [open, computeMenuStyle]);
|
|
1399
1490
|
if (!visible) return null;
|
|
1400
|
-
const
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1491
|
+
const dropdown = open ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
1492
|
+
ref: menuRef,
|
|
1493
|
+
className: "nb-context-menu__dropdown nb-context-menu__dropdown--portaled",
|
|
1494
|
+
role: "menu",
|
|
1495
|
+
style: menuStyle,
|
|
1496
|
+
children: items.map((item, idx) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.default.Fragment, { children: [item.separator && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
1497
|
+
role: "none",
|
|
1498
|
+
"aria-hidden": "true",
|
|
1499
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "nb-context-menu__separator" })
|
|
1500
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
1501
|
+
role: "none",
|
|
1502
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1503
|
+
type: "button",
|
|
1504
|
+
role: "menuitem",
|
|
1505
|
+
disabled: item.disabled,
|
|
1506
|
+
"aria-disabled": item.disabled,
|
|
1507
|
+
className: `nb-context-menu__item${item.danger ? " nb-context-menu__item--danger" : ""}`,
|
|
1508
|
+
onClick: () => {
|
|
1509
|
+
setOpen(false);
|
|
1510
|
+
item.onClick?.();
|
|
1511
|
+
},
|
|
1512
|
+
children: [item.icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
|
|
1513
|
+
className: item.icon,
|
|
1514
|
+
"aria-hidden": "true"
|
|
1515
|
+
}), item.label]
|
|
1516
|
+
})
|
|
1517
|
+
})] }, idx))
|
|
1518
|
+
}) : null;
|
|
1404
1519
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1405
1520
|
ref: containerRef,
|
|
1406
1521
|
className: `nb-context-menu${className ? ` ${className}` : ""}`,
|
|
@@ -1412,34 +1527,11 @@ const ContextMenu = ({ items, visible = true, trigger, triggerLabel = "Opciones"
|
|
|
1412
1527
|
label: triggerLabel,
|
|
1413
1528
|
"aria-haspopup": "menu",
|
|
1414
1529
|
"aria-expanded": open,
|
|
1415
|
-
onClick: () =>
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
children: items.map((item, idx) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react.default.Fragment, { children: [item.separator && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
1421
|
-
role: "none",
|
|
1422
|
-
"aria-hidden": "true",
|
|
1423
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: "nb-context-menu__separator" })
|
|
1424
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("li", {
|
|
1425
|
-
role: "none",
|
|
1426
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("button", {
|
|
1427
|
-
type: "button",
|
|
1428
|
-
role: "menuitem",
|
|
1429
|
-
disabled: item.disabled,
|
|
1430
|
-
"aria-disabled": item.disabled,
|
|
1431
|
-
className: `nb-context-menu__item${item.danger ? " nb-context-menu__item--danger" : ""}`,
|
|
1432
|
-
onClick: () => {
|
|
1433
|
-
setOpen(false);
|
|
1434
|
-
item.onClick?.();
|
|
1435
|
-
},
|
|
1436
|
-
children: [item.icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
|
|
1437
|
-
className: item.icon,
|
|
1438
|
-
"aria-hidden": "true"
|
|
1439
|
-
}), item.label]
|
|
1440
|
-
})
|
|
1441
|
-
})] }, idx))
|
|
1442
|
-
})]
|
|
1530
|
+
onClick: () => {
|
|
1531
|
+
if (!open) setMenuStyle(computeMenuStyle());
|
|
1532
|
+
setOpen((v) => !v);
|
|
1533
|
+
}
|
|
1534
|
+
}), dropdown && (0, react_dom.createPortal)(dropdown, document.body)]
|
|
1443
1535
|
});
|
|
1444
1536
|
};
|
|
1445
1537
|
//#endregion
|
|
@@ -3090,7 +3182,310 @@ function Timeline({ variant = "stepper", orientation = "vertical", title, descri
|
|
|
3090
3182
|
});
|
|
3091
3183
|
}
|
|
3092
3184
|
//#endregion
|
|
3185
|
+
//#region packages/ui/Page.tsx
|
|
3186
|
+
function Page({ children, fill, wide, narrow, gap = 5, className, ...props }) {
|
|
3187
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3188
|
+
className: joinClasses("nb-page", fill && "nb-page--fill", wide && "nb-page--wide", narrow && "nb-page--narrow", gapClass("nb-page", gap), className),
|
|
3189
|
+
...props,
|
|
3190
|
+
children
|
|
3191
|
+
});
|
|
3192
|
+
}
|
|
3193
|
+
//#endregion
|
|
3194
|
+
//#region packages/ui/PageHeader.tsx
|
|
3195
|
+
function PageHeader({ title, subtitle, breadcrumb, breadcrumbSlot, badge, actions, className }) {
|
|
3196
|
+
const breadcrumbNode = breadcrumbSlot ?? (breadcrumb ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("a", {
|
|
3197
|
+
href: breadcrumb.href,
|
|
3198
|
+
className: "nb-page-header__breadcrumb",
|
|
3199
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
|
|
3200
|
+
className: "ph ph-arrow-left",
|
|
3201
|
+
"aria-hidden": true
|
|
3202
|
+
}), breadcrumb.label]
|
|
3203
|
+
}) : null);
|
|
3204
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("header", {
|
|
3205
|
+
className: joinClasses("nb-page-header", className),
|
|
3206
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3207
|
+
className: "nb-page-header__main",
|
|
3208
|
+
children: [
|
|
3209
|
+
breadcrumbNode,
|
|
3210
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h1", {
|
|
3211
|
+
className: "nb-page-header__title",
|
|
3212
|
+
children: title
|
|
3213
|
+
}),
|
|
3214
|
+
subtitle && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", {
|
|
3215
|
+
className: "nb-page-header__subtitle",
|
|
3216
|
+
children: subtitle
|
|
3217
|
+
})
|
|
3218
|
+
]
|
|
3219
|
+
}), (badge || actions) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3220
|
+
className: "nb-page-header__aside",
|
|
3221
|
+
children: [badge && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Badge, {
|
|
3222
|
+
variant: badge.variant ?? "info",
|
|
3223
|
+
pill: true,
|
|
3224
|
+
children: badge.label
|
|
3225
|
+
}), actions]
|
|
3226
|
+
})]
|
|
3227
|
+
});
|
|
3228
|
+
}
|
|
3229
|
+
//#endregion
|
|
3230
|
+
//#region packages/ui/Stack.tsx
|
|
3231
|
+
function Stack({ children, gap = 4, align, justify, fill, className, ...props }) {
|
|
3232
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3233
|
+
className: joinClasses("nb-stack", gapClass("nb-stack", gap), align && `nb-stack--align-${align}`, justify && `nb-stack--justify-${justify}`, fill && "nb-stack--fill", className),
|
|
3234
|
+
...props,
|
|
3235
|
+
children
|
|
3236
|
+
});
|
|
3237
|
+
}
|
|
3238
|
+
//#endregion
|
|
3239
|
+
//#region packages/ui/Row.tsx
|
|
3240
|
+
function Row({ children, gap = 2, align, justify, wrap, fill, className, ...props }) {
|
|
3241
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3242
|
+
className: joinClasses("nb-row", gapClass("nb-row", gap), align && `nb-row--align-${align}`, justify && `nb-row--justify-${justify}`, wrap && "nb-row--wrap", fill && "nb-row--fill", className),
|
|
3243
|
+
...props,
|
|
3244
|
+
children
|
|
3245
|
+
});
|
|
3246
|
+
}
|
|
3247
|
+
//#endregion
|
|
3248
|
+
//#region packages/ui/Cluster.tsx
|
|
3249
|
+
/** Inline flex row that wraps — ideal for button groups and filter actions. */
|
|
3250
|
+
function Cluster({ children, gap = 2, className, ...props }) {
|
|
3251
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3252
|
+
className: joinClasses("nb-cluster", gapClass("nb-cluster", gap), className),
|
|
3253
|
+
...props,
|
|
3254
|
+
children
|
|
3255
|
+
});
|
|
3256
|
+
}
|
|
3257
|
+
//#endregion
|
|
3258
|
+
//#region packages/ui/Grid.tsx
|
|
3259
|
+
function Grid({ children, cols = 12, gap = 4, minColWidth, fill, className, style, ...props }) {
|
|
3260
|
+
const gridStyle = {
|
|
3261
|
+
...style,
|
|
3262
|
+
...minColWidth ? { "--nb-grid-min-col": minColWidth } : {}
|
|
3263
|
+
};
|
|
3264
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3265
|
+
className: joinClasses("nb-grid", cols === 12 ? "nb-grid--cols-12" : cols === "auto" ? "nb-grid--cols-auto" : `nb-grid--cols-${cols}`, gapClass("nb-grid", gap), fill && "nb-grid--fill", className),
|
|
3266
|
+
style: gridStyle,
|
|
3267
|
+
...props,
|
|
3268
|
+
children
|
|
3269
|
+
});
|
|
3270
|
+
}
|
|
3271
|
+
//#endregion
|
|
3272
|
+
//#region packages/ui/Col.tsx
|
|
3273
|
+
function Col({ children, span, spanSm, spanMd, spanLg, fullWidth, className, ...props }) {
|
|
3274
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3275
|
+
className: joinClasses(...colSpanClasses(span, spanSm, spanMd, spanLg), fullWidth && "nb-span-full", className),
|
|
3276
|
+
...props,
|
|
3277
|
+
children
|
|
3278
|
+
});
|
|
3279
|
+
}
|
|
3280
|
+
//#endregion
|
|
3281
|
+
//#region packages/ui/Section.tsx
|
|
3282
|
+
function Section({ title, children, className }) {
|
|
3283
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("section", {
|
|
3284
|
+
className: joinClasses("nb-section", className),
|
|
3285
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {
|
|
3286
|
+
className: "nb-section__title",
|
|
3287
|
+
children: title
|
|
3288
|
+
}), children]
|
|
3289
|
+
});
|
|
3290
|
+
}
|
|
3291
|
+
//#endregion
|
|
3292
|
+
//#region packages/ui/FormLayout.tsx
|
|
3293
|
+
function FormLayout({ children, variant = "stack", minColWidth, className, style, ...props }) {
|
|
3294
|
+
const formStyle = {
|
|
3295
|
+
...style,
|
|
3296
|
+
...minColWidth ? { "--nb-form-min-col": minColWidth } : {}
|
|
3297
|
+
};
|
|
3298
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("form", {
|
|
3299
|
+
className: joinClasses("nb-form-layout", variant !== "stack" && `nb-form-layout--${variant}`, className),
|
|
3300
|
+
style: formStyle,
|
|
3301
|
+
...props,
|
|
3302
|
+
children
|
|
3303
|
+
});
|
|
3304
|
+
}
|
|
3305
|
+
//#endregion
|
|
3306
|
+
//#region packages/ui/FormActions.tsx
|
|
3307
|
+
function FormActions({ children, className }) {
|
|
3308
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3309
|
+
className: joinClasses("nb-form-actions", className),
|
|
3310
|
+
children
|
|
3311
|
+
});
|
|
3312
|
+
}
|
|
3313
|
+
//#endregion
|
|
3314
|
+
//#region packages/ui/Alert.tsx
|
|
3315
|
+
const ICONS = {
|
|
3316
|
+
danger: "ph-warning-circle",
|
|
3317
|
+
warning: "ph-warning",
|
|
3318
|
+
info: "ph-info"
|
|
3319
|
+
};
|
|
3320
|
+
function Alert({ tone = "info", children, className }) {
|
|
3321
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3322
|
+
className: joinClasses("nb-alert", `nb-alert--${tone}`, className),
|
|
3323
|
+
role: "alert",
|
|
3324
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
|
|
3325
|
+
className: `ph ${ICONS[tone]}`,
|
|
3326
|
+
"aria-hidden": true
|
|
3327
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { children })]
|
|
3328
|
+
});
|
|
3329
|
+
}
|
|
3330
|
+
//#endregion
|
|
3331
|
+
//#region packages/ui/DescriptionList.tsx
|
|
3332
|
+
function DescriptionList({ items, className }) {
|
|
3333
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dl", {
|
|
3334
|
+
className: joinClasses("nb-description-list", className),
|
|
3335
|
+
children: items.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
3336
|
+
className: "nb-description-list__row",
|
|
3337
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("dt", { children: item.term }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("dd", { children: item.value })]
|
|
3338
|
+
}, item.term))
|
|
3339
|
+
});
|
|
3340
|
+
}
|
|
3341
|
+
//#endregion
|
|
3342
|
+
//#region packages/ui/Code.tsx
|
|
3343
|
+
function Code({ children, className }) {
|
|
3344
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
3345
|
+
className: joinClasses("nb-code", className),
|
|
3346
|
+
children
|
|
3347
|
+
});
|
|
3348
|
+
}
|
|
3349
|
+
//#endregion
|
|
3350
|
+
//#region packages/ui/Text.tsx
|
|
3351
|
+
function Text({ children, tone = "default", as: Tag = "span", className, ...props }) {
|
|
3352
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tag, {
|
|
3353
|
+
className: joinClasses(tone === "muted" && "nb-text-muted", className),
|
|
3354
|
+
...props,
|
|
3355
|
+
children
|
|
3356
|
+
});
|
|
3357
|
+
}
|
|
3358
|
+
//#endregion
|
|
3359
|
+
//#region packages/ui/Pagination.tsx
|
|
3360
|
+
function Pagination({ page, totalPages, onPageChange, ariaLabel, maxVisible = 7, className }) {
|
|
3361
|
+
const strings = useUiStrings();
|
|
3362
|
+
if (totalPages <= 1) return null;
|
|
3363
|
+
const windowSize = Math.min(maxVisible, totalPages);
|
|
3364
|
+
const start = Math.max(1, Math.min(page - Math.floor(windowSize / 2), totalPages - windowSize + 1));
|
|
3365
|
+
const pages = Array.from({ length: windowSize }, (_, index) => start + index).filter((value) => value <= totalPages);
|
|
3366
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("nav", {
|
|
3367
|
+
className: joinClasses("nb-pagination", className),
|
|
3368
|
+
"aria-label": ariaLabel ?? strings.pages,
|
|
3369
|
+
children: [
|
|
3370
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
3371
|
+
type: "button",
|
|
3372
|
+
variant: "ghost",
|
|
3373
|
+
size: "sm",
|
|
3374
|
+
disabled: page <= 1,
|
|
3375
|
+
"aria-label": strings.previousPage,
|
|
3376
|
+
onClick: () => onPageChange(page - 1),
|
|
3377
|
+
children: "←"
|
|
3378
|
+
}),
|
|
3379
|
+
pages.map((value) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
3380
|
+
type: "button",
|
|
3381
|
+
variant: value === page ? "primary" : "ghost",
|
|
3382
|
+
size: "sm",
|
|
3383
|
+
"aria-current": value === page ? "page" : void 0,
|
|
3384
|
+
onClick: () => onPageChange(value),
|
|
3385
|
+
children: value
|
|
3386
|
+
}, value)),
|
|
3387
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Button, {
|
|
3388
|
+
type: "button",
|
|
3389
|
+
variant: "ghost",
|
|
3390
|
+
size: "sm",
|
|
3391
|
+
disabled: page >= totalPages,
|
|
3392
|
+
"aria-label": strings.nextPage,
|
|
3393
|
+
onClick: () => onPageChange(page + 1),
|
|
3394
|
+
children: "→"
|
|
3395
|
+
})
|
|
3396
|
+
]
|
|
3397
|
+
});
|
|
3398
|
+
}
|
|
3399
|
+
//#endregion
|
|
3400
|
+
//#region packages/ui/RowActions.tsx
|
|
3401
|
+
/** Context menu preset for table row overflow actions. */
|
|
3402
|
+
function RowActions({ items, triggerLabel, align = "right", className }) {
|
|
3403
|
+
const strings = useUiStrings();
|
|
3404
|
+
if (items.length === 0) return null;
|
|
3405
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ContextMenu, {
|
|
3406
|
+
items,
|
|
3407
|
+
align,
|
|
3408
|
+
className,
|
|
3409
|
+
triggerLabel: triggerLabel ?? strings.rowActions,
|
|
3410
|
+
visible: true
|
|
3411
|
+
});
|
|
3412
|
+
}
|
|
3413
|
+
//#endregion
|
|
3414
|
+
//#region packages/ui/DataTable.tsx
|
|
3415
|
+
function alignClass(align) {
|
|
3416
|
+
if (align === "right") return "nb-data-table__cell--num";
|
|
3417
|
+
if (align === "center") return "nb-data-table__cell--center";
|
|
3418
|
+
}
|
|
3419
|
+
function cellClass(column) {
|
|
3420
|
+
return joinClasses(alignClass(column.align), column.muted && "nb-data-table__cell--muted", column.nowrap && "nb-data-table__cell--nowrap");
|
|
3421
|
+
}
|
|
3422
|
+
function renderCell(column, row, index) {
|
|
3423
|
+
if (column.render) return column.render(row, index);
|
|
3424
|
+
if (column.accessor) return column.accessor(row);
|
|
3425
|
+
return null;
|
|
3426
|
+
}
|
|
3427
|
+
function DataTable({ columns, rows, getRowKey, emptyMessage, fill, variant = "default", className, wrapClassName, testId, rowActions, rowActionsLabel, renderActions, pagination }) {
|
|
3428
|
+
const hasActions = Boolean(rowActions || renderActions);
|
|
3429
|
+
if (rows.length === 0) return emptyMessage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Text, {
|
|
3430
|
+
tone: "muted",
|
|
3431
|
+
children: emptyMessage
|
|
3432
|
+
}) : null;
|
|
3433
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
3434
|
+
className: joinClasses("nb-data-table-wrap", variant === "flush" && "nb-data-table-wrap--flush", fill && "nb-data-table-wrap--fill", wrapClassName),
|
|
3435
|
+
"data-testid": testId,
|
|
3436
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("table", {
|
|
3437
|
+
className: joinClasses("nb-data-table", hasActions && "nb-data-table--has-actions", className),
|
|
3438
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [columns.map((column) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3439
|
+
className: alignClass(column.align),
|
|
3440
|
+
children: column.header
|
|
3441
|
+
}, column.id)), hasActions && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("th", {
|
|
3442
|
+
scope: "col",
|
|
3443
|
+
className: "nb-data-table__actions-head",
|
|
3444
|
+
...rowActionsLabel ? { "aria-label": rowActionsLabel } : {}
|
|
3445
|
+
})] }) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("tbody", { children: rows.map((row, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("tr", { children: [columns.map((column) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3446
|
+
className: cellClass(column),
|
|
3447
|
+
children: renderCell(column, row, index)
|
|
3448
|
+
}, column.id)), hasActions && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("td", {
|
|
3449
|
+
className: "nb-data-table__actions",
|
|
3450
|
+
children: renderActions ? renderActions(row) : rowActions && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(RowActions, {
|
|
3451
|
+
items: rowActions(row),
|
|
3452
|
+
triggerLabel: rowActionsLabel
|
|
3453
|
+
})
|
|
3454
|
+
})] }, getRowKey(row))) })]
|
|
3455
|
+
})
|
|
3456
|
+
}), pagination && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Pagination, { ...pagination })] });
|
|
3457
|
+
}
|
|
3458
|
+
//#endregion
|
|
3459
|
+
//#region packages/ui/useConfirm.tsx
|
|
3460
|
+
function useConfirm() {
|
|
3461
|
+
const strings = useUiStrings();
|
|
3462
|
+
const [pending, setPending] = (0, react.useState)(null);
|
|
3463
|
+
const ask = (0, react.useCallback)((request) => {
|
|
3464
|
+
setPending(request);
|
|
3465
|
+
}, []);
|
|
3466
|
+
const dismiss = (0, react.useCallback)(() => setPending(null), []);
|
|
3467
|
+
const ConfirmHost = () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ConfirmDialog, {
|
|
3468
|
+
open: pending !== null,
|
|
3469
|
+
title: pending?.title ?? "",
|
|
3470
|
+
message: pending?.message ?? "",
|
|
3471
|
+
variant: pending?.variant,
|
|
3472
|
+
confirmLabel: pending?.confirmLabel ?? strings.confirm,
|
|
3473
|
+
cancelLabel: strings.cancel,
|
|
3474
|
+
onCancel: dismiss,
|
|
3475
|
+
onConfirm: () => {
|
|
3476
|
+
pending?.onConfirm();
|
|
3477
|
+
dismiss();
|
|
3478
|
+
}
|
|
3479
|
+
});
|
|
3480
|
+
return {
|
|
3481
|
+
ask,
|
|
3482
|
+
dismiss,
|
|
3483
|
+
ConfirmHost
|
|
3484
|
+
};
|
|
3485
|
+
}
|
|
3486
|
+
//#endregion
|
|
3093
3487
|
exports.ACCENT_PRESETS = ACCENT_PRESETS;
|
|
3488
|
+
exports.Alert = Alert;
|
|
3094
3489
|
exports.AppDialog = AppDialog;
|
|
3095
3490
|
exports.AppDropdown = AppDropdown;
|
|
3096
3491
|
exports.AppToolbar = AppToolbar;
|
|
@@ -3099,13 +3494,18 @@ exports.Badge = Badge;
|
|
|
3099
3494
|
exports.Button = Button;
|
|
3100
3495
|
exports.Card = Card;
|
|
3101
3496
|
exports.Chip = Chip;
|
|
3497
|
+
exports.Cluster = Cluster;
|
|
3498
|
+
exports.Code = Code;
|
|
3499
|
+
exports.Col = Col;
|
|
3102
3500
|
exports.CollapsibleSection = CollapsibleSection;
|
|
3103
3501
|
exports.ConfirmDialog = ConfirmDialog;
|
|
3104
3502
|
exports.ContextMenu = ContextMenu;
|
|
3503
|
+
exports.DataTable = DataTable;
|
|
3105
3504
|
exports.DatePicker = DatePicker;
|
|
3106
3505
|
exports.DateRangePicker = DateRangePicker;
|
|
3107
3506
|
exports.DensityContext = DensityContext;
|
|
3108
3507
|
exports.DensityProvider = DensityProvider;
|
|
3508
|
+
exports.DescriptionList = DescriptionList;
|
|
3109
3509
|
exports.Drawer = Drawer;
|
|
3110
3510
|
exports.EN_UI_STRINGS = EN_UI_STRINGS;
|
|
3111
3511
|
exports.ES_UI_STRINGS = ES_UI_STRINGS;
|
|
@@ -3113,19 +3513,30 @@ exports.EmptyState = EmptyState;
|
|
|
3113
3513
|
exports.FeatureGate = FeatureGate;
|
|
3114
3514
|
exports.FileDropzone = FileDropzone;
|
|
3115
3515
|
exports.FilterPanel = FilterPanel;
|
|
3516
|
+
exports.FormActions = FormActions;
|
|
3116
3517
|
exports.FormField = FormField;
|
|
3518
|
+
exports.FormLayout = FormLayout;
|
|
3519
|
+
exports.Grid = Grid;
|
|
3117
3520
|
exports.HubPanel = HubPanel;
|
|
3118
3521
|
exports.IconButton = IconButton;
|
|
3119
3522
|
exports.KpiMetricRow = KpiMetricRow;
|
|
3120
3523
|
exports.OperationCardGrid = OperationCardGrid;
|
|
3524
|
+
exports.Page = Page;
|
|
3525
|
+
exports.PageHeader = PageHeader;
|
|
3526
|
+
exports.Pagination = Pagination;
|
|
3121
3527
|
exports.Popover = Popover;
|
|
3528
|
+
exports.Row = Row;
|
|
3529
|
+
exports.RowActions = RowActions;
|
|
3122
3530
|
exports.ScopeTabs = ScopeTabs;
|
|
3123
3531
|
exports.SearchableAppDropdown = SearchableAppDropdown;
|
|
3532
|
+
exports.Section = Section;
|
|
3124
3533
|
exports.SegmentedControl = SegmentedControl;
|
|
3125
3534
|
exports.SelectField = SelectField;
|
|
3126
3535
|
exports.SettingsPanel = SettingsPanel;
|
|
3127
3536
|
exports.Skeleton = Skeleton;
|
|
3537
|
+
exports.Stack = Stack;
|
|
3128
3538
|
exports.StatCard = StatCard;
|
|
3539
|
+
exports.Text = Text;
|
|
3129
3540
|
exports.TextAreaField = TextAreaField;
|
|
3130
3541
|
exports.TextField = TextField;
|
|
3131
3542
|
exports.ThemeContext = ThemeContext;
|
|
@@ -3138,6 +3549,7 @@ exports.UiStringsProvider = UiStringsProvider;
|
|
|
3138
3549
|
exports.getAvatarHue = getAvatarHue;
|
|
3139
3550
|
exports.getAvatarInitials = getAvatarInitials;
|
|
3140
3551
|
exports.useAccentColor = useAccentColor;
|
|
3552
|
+
exports.useConfirm = useConfirm;
|
|
3141
3553
|
exports.useDensity = useDensity;
|
|
3142
3554
|
exports.useFloatingPanel = useFloatingPanel;
|
|
3143
3555
|
exports.useTheme = useTheme;
|