@syscore/ui-library 2.0.0-beta-publish-workflow-beta.11 → 2.0.0-beta-publish-workflow-beta.12

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.d.ts CHANGED
@@ -190,6 +190,11 @@ import { ContextMenuSubTrigger } from '../client/components/ui/context-menu';
190
190
  import { ContextMenuTrigger } from '../client/components/ui/context-menu';
191
191
  import { Copy } from '../client/components/ui/copy';
192
192
  import { CreditCardPreview } from '../client/components/ui/credit-card-preview';
193
+ import { DataGrid } from '../client/components/ui/data-grid';
194
+ import { DataGridAlign } from '../client/components/ui/data-grid';
195
+ import { DataGridColumn } from '../client/components/ui/data-grid';
196
+ import { DataGridProps } from '../client/components/ui/data-grid';
197
+ import { DataGridSort } from '../client/components/ui/data-grid';
193
198
  import { DatePicker } from '../client/components/ui/date-picker';
194
199
  import { DatePickerProps } from '../client/components/ui/date-picker';
195
200
  import { DateRange } from '../client/components/ui/date-picker';
@@ -477,6 +482,8 @@ import { SidebarMenuSubItem } from '../client/components/ui/sidebar';
477
482
  import { SidebarProvider } from '../client/components/ui/sidebar';
478
483
  import { SidebarTrigger } from '../client/components/ui/sidebar';
479
484
  import { SideNav } from '../client/components/ui/side-nav';
485
+ import { SideNavBranch } from '../client/components/ui/side-nav';
486
+ import { SideNavBranchProps } from '../client/components/ui/side-nav';
480
487
  import { SideNavGroup } from '../client/components/ui/side-nav';
481
488
  import { SideNavGroupProps } from '../client/components/ui/side-nav';
482
489
  import { SideNavItem } from '../client/components/ui/side-nav';
@@ -1015,6 +1022,16 @@ export { Copy }
1015
1022
 
1016
1023
  export { CreditCardPreview }
1017
1024
 
1025
+ export { DataGrid }
1026
+
1027
+ export { DataGridAlign }
1028
+
1029
+ export { DataGridColumn }
1030
+
1031
+ export { DataGridProps }
1032
+
1033
+ export { DataGridSort }
1034
+
1018
1035
  export { DatePicker }
1019
1036
 
1020
1037
  export { DatePickerProps }
@@ -1589,6 +1606,10 @@ export { SidebarTrigger }
1589
1606
 
1590
1607
  export { SideNav }
1591
1608
 
1609
+ export { SideNavBranch }
1610
+
1611
+ export { SideNavBranchProps }
1612
+
1592
1613
  export { SideNavGroup }
1593
1614
 
1594
1615
  export { SideNavGroupProps }
package/dist/index.es.js CHANGED
@@ -39,6 +39,8 @@ import * as ToastPrimitives from "@radix-ui/react-toast";
39
39
  import * as RechartsPrimitive from "recharts";
40
40
  import { format } from "date-fns";
41
41
  import { Text as Text$1 } from "@syscore/ui-library";
42
+ import { AgGridReact } from "ag-grid-react";
43
+ import { ModuleRegistry, AllCommunityModule, themeQuartz } from "ag-grid-community";
42
44
  function cn(...inputs) {
43
45
  return twMerge(clsx(inputs));
44
46
  }
@@ -712,6 +714,9 @@ const buttonVariants = cva(
712
714
  "general-primary": "button--general-primary",
713
715
  "general-secondary": "button--general-secondary",
714
716
  "general-tertiary": "button--general-tertiary",
717
+ // Destructive actions: delete, remove, deactivate, void. `primary` confirms, `secondary` starts the action.
718
+ "danger-primary": "button--danger-primary",
719
+ "danger-secondary": "button--danger-secondary",
715
720
  "transparent-tertiary": "button--transparent-tertiary",
716
721
  "tooltip-primary": "button--tooltip-primary",
717
722
  "tooltip-secondary": "button--tooltip-secondary",
@@ -1147,6 +1152,7 @@ const Text = React.forwardRef(
1147
1152
  strong = false,
1148
1153
  align,
1149
1154
  leading = "default",
1155
+ family = "default",
1150
1156
  ...props
1151
1157
  }, ref) => {
1152
1158
  const Component = as || defaultElementMap[variant];
@@ -1160,6 +1166,7 @@ const Text = React.forwardRef(
1160
1166
  strong && "typo--strong",
1161
1167
  align === "center" && "typo--center",
1162
1168
  leading === "relaxed" && "typo--relaxed",
1169
+ family === "sans" && "typo--sans",
1163
1170
  className
1164
1171
  ),
1165
1172
  ...props
@@ -17976,9 +17983,47 @@ const SideNav = React.forwardRef(
17976
17983
  ) })
17977
17984
  );
17978
17985
  SideNav.displayName = "SideNav";
17986
+ function useDisclosure(open, defaultOpen, onOpenChange) {
17987
+ const [inner, setInner] = React.useState(defaultOpen);
17988
+ const isOpen = open ?? inner;
17989
+ const setOpen = (next) => {
17990
+ if (open === void 0) setInner(next);
17991
+ onOpenChange == null ? void 0 : onOpenChange(next);
17992
+ };
17993
+ return [isOpen, setOpen];
17994
+ }
17979
17995
  const SideNavGroup = React.forwardRef(
17980
- ({ className, label, children, ...props }, ref) => {
17996
+ ({
17997
+ className,
17998
+ label,
17999
+ collapsible = false,
18000
+ open,
18001
+ defaultOpen = true,
18002
+ onOpenChange,
18003
+ children,
18004
+ ...props
18005
+ }, ref) => {
18006
+ const { collapsed } = React.useContext(SideNavContext);
17981
18007
  const headingId = React.useId();
18008
+ const itemsId = React.useId();
18009
+ const [isOpen, setOpen] = useDisclosure(open, defaultOpen, onOpenChange);
18010
+ if (!collapsible) {
18011
+ return /* @__PURE__ */ jsxs(
18012
+ "div",
18013
+ {
18014
+ ref,
18015
+ role: "group",
18016
+ "aria-labelledby": label ? headingId : void 0,
18017
+ className: cn("side-nav__group", className),
18018
+ ...props,
18019
+ children: [
18020
+ label ? /* @__PURE__ */ jsx("span", { id: headingId, className: "side-nav__heading", children: label }) : null,
18021
+ children
18022
+ ]
18023
+ }
18024
+ );
18025
+ }
18026
+ const shown = collapsed || isOpen;
17982
18027
  return /* @__PURE__ */ jsxs(
17983
18028
  "div",
17984
18029
  {
@@ -17988,8 +18033,22 @@ const SideNavGroup = React.forwardRef(
17988
18033
  className: cn("side-nav__group", className),
17989
18034
  ...props,
17990
18035
  children: [
17991
- label ? /* @__PURE__ */ jsx("span", { id: headingId, className: "side-nav__heading", children: label }) : null,
17992
- children
18036
+ label ? /* @__PURE__ */ jsxs(
18037
+ "button",
18038
+ {
18039
+ type: "button",
18040
+ id: headingId,
18041
+ className: "side-nav__heading side-nav__heading--toggle",
18042
+ "aria-expanded": shown,
18043
+ "aria-controls": itemsId,
18044
+ onClick: () => setOpen(!isOpen),
18045
+ children: [
18046
+ /* @__PURE__ */ jsx("span", { children: label }),
18047
+ /* @__PURE__ */ jsx(ChevronDown, { className: "side-nav__chevron", "aria-hidden": "true" })
18048
+ ]
18049
+ }
18050
+ ) : null,
18051
+ /* @__PURE__ */ jsx("div", { id: itemsId, className: "side-nav__items", hidden: !shown, children })
17993
18052
  ]
17994
18053
  }
17995
18054
  );
@@ -18024,6 +18083,52 @@ const SideNavItem = React.forwardRef(
18024
18083
  }
18025
18084
  );
18026
18085
  SideNavItem.displayName = "SideNavItem";
18086
+ const SideNavBranch = React.forwardRef(
18087
+ ({
18088
+ className,
18089
+ icon,
18090
+ label,
18091
+ active = false,
18092
+ open,
18093
+ defaultOpen = false,
18094
+ onOpenChange,
18095
+ onClick,
18096
+ children,
18097
+ ...props
18098
+ }, ref) => {
18099
+ const { collapsed } = React.useContext(SideNavContext);
18100
+ const subId = React.useId();
18101
+ const [isOpen, setOpen] = useDisclosure(open, defaultOpen, onOpenChange);
18102
+ return /* @__PURE__ */ jsxs("div", { ref, className: cn("side-nav__branch", className), ...props, children: [
18103
+ /* @__PURE__ */ jsxs(
18104
+ "button",
18105
+ {
18106
+ type: "button",
18107
+ className: cn(
18108
+ "side-nav__item",
18109
+ "side-nav__item--branch",
18110
+ active && "side-nav__item--branch-active"
18111
+ ),
18112
+ "aria-expanded": collapsed ? void 0 : isOpen,
18113
+ "aria-controls": subId,
18114
+ "aria-label": collapsed ? label : void 0,
18115
+ title: collapsed ? label : void 0,
18116
+ onClick: (event) => {
18117
+ if (collapsed) onClick == null ? void 0 : onClick(event);
18118
+ else setOpen(!isOpen);
18119
+ },
18120
+ children: [
18121
+ icon ? /* @__PURE__ */ jsx("span", { className: "side-nav__icon", "aria-hidden": "true", children: icon }) : null,
18122
+ /* @__PURE__ */ jsx("span", { className: "side-nav__label", children: label }),
18123
+ /* @__PURE__ */ jsx(ChevronDown, { className: "side-nav__chevron", "aria-hidden": "true" })
18124
+ ]
18125
+ }
18126
+ ),
18127
+ /* @__PURE__ */ jsx("div", { id: subId, className: "side-nav__sub", hidden: collapsed || !isOpen, children })
18128
+ ] });
18129
+ }
18130
+ );
18131
+ SideNavBranch.displayName = "SideNavBranch";
18027
18132
  const RadioCardGroup = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
18028
18133
  RadioGroupPrimitive.Root,
18029
18134
  {
@@ -18114,6 +18219,154 @@ const CenteredPage = React.forwardRef(
18114
18219
  ({ as: Component = "main", className, children, ...props }, ref) => /* @__PURE__ */ jsx(Component, { ref, className: cn("centered-page", className), ...props, children: /* @__PURE__ */ jsx("div", { className: "centered-page__body", children }) })
18115
18220
  );
18116
18221
  CenteredPage.displayName = "CenteredPage";
18222
+ ModuleRegistry.registerModules([AllCommunityModule]);
18223
+ const dataGridTheme = themeQuartz.withParams({
18224
+ fontFamily: "var(--font-mazzard, 'Mazzard Soft M'), sans-serif",
18225
+ fontSize: 14,
18226
+ foregroundColor: "#1f2430",
18227
+ backgroundColor: "#ffffff",
18228
+ accentColor: "#0f748a",
18229
+ borderColor: "#e3e8ef",
18230
+ wrapperBorderRadius: 16,
18231
+ headerBackgroundColor: "#f6f8fb",
18232
+ headerTextColor: "#6b7280",
18233
+ headerFontSize: 12,
18234
+ headerFontWeight: 600,
18235
+ // The pinned (action) column joins the rest of the row; no divider line.
18236
+ pinnedColumnBorder: false,
18237
+ rowHoverColor: "#f4f9fd",
18238
+ columnBorder: false,
18239
+ headerColumnBorder: false,
18240
+ // The resize handle stays (the column still drags) but is drawn as a faint tick, not a separator line.
18241
+ headerColumnResizeHandleColor: "transparent",
18242
+ spacing: 8
18243
+ });
18244
+ const ALIGN_CLASS = {
18245
+ left: void 0,
18246
+ center: "data-grid__cell--center",
18247
+ right: "data-grid__cell--right"
18248
+ };
18249
+ function shapeOf(columns) {
18250
+ return JSON.stringify(
18251
+ columns.map((c) => [
18252
+ c.key,
18253
+ c.header,
18254
+ c.sortable ?? false,
18255
+ c.filter ?? false,
18256
+ c.resizable ?? true,
18257
+ c.width ?? null,
18258
+ c.minWidth ?? null,
18259
+ c.flex ?? null,
18260
+ c.align ?? null,
18261
+ c.pinned ?? null,
18262
+ c.wrap ?? false,
18263
+ Boolean(c.value),
18264
+ Boolean(c.cell)
18265
+ ])
18266
+ );
18267
+ }
18268
+ function DataGrid({
18269
+ columns,
18270
+ rows,
18271
+ getRowId,
18272
+ loading = false,
18273
+ emptyText = "Nothing to show.",
18274
+ quickFilter,
18275
+ sort,
18276
+ onSortChange,
18277
+ onRowClick,
18278
+ className,
18279
+ "aria-label": ariaLabel
18280
+ }) {
18281
+ const serverSorted = onSortChange !== void 0;
18282
+ const latest = React.useRef(columns);
18283
+ latest.current = columns;
18284
+ const shape = shapeOf(columns);
18285
+ const sortKey = (sort == null ? void 0 : sort.key) ?? null;
18286
+ const sortDirection = (sort == null ? void 0 : sort.direction) ?? null;
18287
+ const columnDefs = React.useMemo(
18288
+ () => latest.current.map((column) => {
18289
+ const fixed = column.width !== void 0;
18290
+ const find = () => latest.current.find((c) => c.key === column.key);
18291
+ return {
18292
+ colId: column.key,
18293
+ headerName: column.header,
18294
+ valueGetter: column.value ? (params) => {
18295
+ var _a, _b;
18296
+ return params.data ? (_b = (_a = find()) == null ? void 0 : _a.value) == null ? void 0 : _b.call(_a, params.data) : void 0;
18297
+ } : void 0,
18298
+ cellRenderer: column.cell ? (params) => {
18299
+ var _a, _b;
18300
+ return params.data ? (_b = (_a = find()) == null ? void 0 : _a.cell) == null ? void 0 : _b.call(_a, params.data) : null;
18301
+ } : void 0,
18302
+ sortable: column.sortable ?? false,
18303
+ filter: column.filter ?? false,
18304
+ resizable: column.resizable ?? true,
18305
+ suppressMovable: true,
18306
+ width: column.width,
18307
+ minWidth: column.minWidth ?? (fixed ? column.width : 96),
18308
+ flex: fixed ? void 0 : column.flex ?? 1,
18309
+ pinned: column.pinned,
18310
+ wrapText: column.wrap ?? false,
18311
+ autoHeight: column.wrap ?? false,
18312
+ cellClass: column.align ? ALIGN_CLASS[column.align] : void 0,
18313
+ headerClass: column.align ? ALIGN_CLASS[column.align] : void 0,
18314
+ // Server-sorted data keeps the order it arrived in; the grid only draws the indicator.
18315
+ ...serverSorted ? {
18316
+ comparator: () => 0,
18317
+ // Server-side sort has no "no sort": clicking again flips the direction.
18318
+ sortingOrder: ["asc", "desc"],
18319
+ sort: sortKey === column.key ? sortDirection : null
18320
+ } : {}
18321
+ };
18322
+ }),
18323
+ // `shape` stands for the column list; the list itself is a new array on most renders.
18324
+ // eslint-disable-next-line react-hooks/exhaustive-deps
18325
+ [shape, serverSorted, sortKey, sortDirection]
18326
+ );
18327
+ const handleSortChanged = React.useCallback(
18328
+ (event) => {
18329
+ if (!serverSorted) return;
18330
+ const active = event.api.getColumnState().find((state) => state.sort);
18331
+ const next = (active == null ? void 0 : active.colId) ? { key: active.colId, direction: active.sort === "desc" ? "desc" : "asc" } : null;
18332
+ if ((next == null ? void 0 : next.key) === (sort == null ? void 0 : sort.key) && (next == null ? void 0 : next.direction) === (sort == null ? void 0 : sort.direction)) return;
18333
+ if (!next && !sort) return;
18334
+ onSortChange == null ? void 0 : onSortChange(next);
18335
+ },
18336
+ [serverSorted, sort, onSortChange]
18337
+ );
18338
+ return /* @__PURE__ */ jsx(
18339
+ "div",
18340
+ {
18341
+ role: "region",
18342
+ "aria-label": ariaLabel,
18343
+ className: cn(
18344
+ "data-grid",
18345
+ rows.length === 0 && "data-grid--empty",
18346
+ onRowClick && "data-grid--clickable",
18347
+ className
18348
+ ),
18349
+ children: /* @__PURE__ */ jsx(
18350
+ AgGridReact,
18351
+ {
18352
+ theme: dataGridTheme,
18353
+ rowData: rows,
18354
+ columnDefs,
18355
+ domLayout: "autoHeight",
18356
+ rowHeight: 64,
18357
+ headerHeight: 48,
18358
+ loading,
18359
+ quickFilterText: quickFilter,
18360
+ getRowId: getRowId ? (params) => getRowId(params.data) : void 0,
18361
+ onSortChanged: handleSortChanged,
18362
+ onRowClicked: onRowClick ? (event) => event.data && onRowClick(event.data) : void 0,
18363
+ suppressCellFocus: true,
18364
+ localeText: { noRowsToShow: emptyText }
18365
+ }
18366
+ )
18367
+ }
18368
+ );
18369
+ }
18117
18370
  const iconButtonVariants = cva("icon-button", {
18118
18371
  variants: {
18119
18372
  size: {
@@ -18283,6 +18536,7 @@ export {
18283
18536
  ContextMenuTrigger,
18284
18537
  Copy,
18285
18538
  CreditCardPreview,
18539
+ DataGrid,
18286
18540
  DatePicker,
18287
18541
  DateRangePicker,
18288
18542
  Dialog,
@@ -18523,6 +18777,7 @@ export {
18523
18777
  SheetTrigger,
18524
18778
  Show,
18525
18779
  SideNav,
18780
+ SideNavBranch,
18526
18781
  SideNavGroup,
18527
18782
  SideNavItem,
18528
18783
  Sidebar,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syscore/ui-library",
3
- "version": "2.0.0-beta-publish-workflow-beta.11",
3
+ "version": "2.0.0-beta-publish-workflow-beta.12",
4
4
  "description": "A comprehensive React component library built with Radix UI, Tailwind CSS, and TypeScript",
5
5
  "private": false,
6
6
  "type": "module",
@@ -70,6 +70,8 @@
70
70
  "@radix-ui/react-toggle": "^1.1.9",
71
71
  "@radix-ui/react-toggle-group": "^1.1.10",
72
72
  "@radix-ui/react-tooltip": "^1.2.8",
73
+ "ag-grid-community": "35.3.0",
74
+ "ag-grid-react": "35.3.0",
73
75
  "class-variance-authority": "^0.7.1",
74
76
  "clsx": "^2.1.1",
75
77
  "cmdk": "^1.1.1",