@alaarab/ogrid-react-fluent 2.3.0 → 2.4.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.
Files changed (2) hide show
  1. package/dist/esm/index.js +95 -112
  2. package/package.json +2 -2
package/dist/esm/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import './index.css';
2
- import { useColumnHeaderFilterState, getColumnHeaderFilterStateParams, DateFilterContent, renderFilterContent, areGridRowPropsEqual, usePaginationControls, createOGrid, useListVirtualizer, STOP_PROPAGATION, useDataGridTableOrchestration, useColumnMeta, getCellRenderDescriptor, buildInlineEditorProps, buildPopoverEditorProps, POPOVER_ANCHOR_STYLE, resolveCellDisplayContent, resolveCellStyle, getCellInteractionProps, CURSOR_CELL_STYLE, CellErrorBoundary, GRID_ROOT_STYLE, PREVENT_DEFAULT, indexToColumnLetter, getHeaderFilterConfig, MarchingAntsOverlay, NOOP, useColumnChooserState, BaseInlineCellEditor, partitionColumnsForVirtualization, BaseDropIndicator, BaseEmptyState, GridContextMenu as GridContextMenu$1, BaseColumnHeaderMenu, StatusBar as StatusBar$1, BaseLoadingOverlay } from '@alaarab/ogrid-react';
2
+ import { useColumnHeaderFilterState, getColumnHeaderFilterStateParams, DateFilterContent, renderFilterContent, areGridRowPropsEqual, PaginationControlsBase, createOGrid, useListVirtualizer, STOP_PROPAGATION, useDataGridTableOrchestration, useColumnMeta, getCellRenderDescriptor, buildInlineEditorProps, buildPopoverEditorProps, POPOVER_ANCHOR_STYLE, resolveCellDisplayContent, resolveCellStyle, getCellInteractionProps, CURSOR_CELL_STYLE, CellErrorBoundary, GRID_ROOT_STYLE, PREVENT_DEFAULT, indexToColumnLetter, getHeaderFilterConfig, MarchingAntsOverlay, FormulaRefOverlay, NOOP, getColumnHeaderMenuProps, useColumnChooserState, ColumnChooserContent, BaseInlineCellEditor, partitionColumnsForVirtualization, BaseDropIndicator, BaseEmptyState, GridContextMenu as GridContextMenu$1, BaseColumnHeaderMenu, StatusBar as StatusBar$1, BaseLoadingOverlay } from '@alaarab/ogrid-react';
3
3
  export { BaseColumnHeaderMenu, BaseDropIndicator, BaseEmptyState, BaseInlineCellEditor, BaseLoadingOverlay, CELL_PADDING, CHECKBOX_COLUMN_WIDTH, COLUMN_HEADER_MENU_ITEMS, CURSOR_CELL_STYLE, CellErrorBoundary, DEFAULT_MIN_COLUMN_WIDTH, DateFilterContent, EmptyState, GRID_BORDER_RADIUS, GRID_CONTEXT_MENU_ITEMS, GRID_ROOT_STYLE, GridContextMenu, MAX_PAGE_BUTTONS, MarchingAntsOverlay, NOOP, OGridLayout, PAGE_SIZE_OPTIONS, POPOVER_ANCHOR_STYLE, PREVENT_DEFAULT, ROW_NUMBER_COLUMN_WIDTH, STOP_PROPAGATION, SideBar, StatusBar, UndoRedoStack, areGridRowPropsEqual, booleanParser, buildCsvHeader, buildCsvRows, buildHeaderRows, buildInlineEditorProps, buildPopoverEditorProps, clampSelectionToBounds, computeAggregations, computeAutoScrollSpeed, computeTabNavigation, createOGrid, currencyParser, dateParser, deriveFilterOptionsFromData, editorInputStyle, editorWrapperStyle, emailParser, escapeCsvValue, exportToCsv, findCtrlArrowTarget, flattenColumns, formatCellValueForTsv, formatSelectionAsTsv, formatShortcut, getCellInteractionProps, getCellRenderDescriptor, getCellValue, getColumnHeaderFilterStateParams, getColumnHeaderMenuItems, getContextMenuHandlers, getDataGridStatusBarConfig, getDateFilterContentProps, getFilterField, getHeaderFilterConfig, getMultiSelectFilterFields, getPaginationViewModel, getStatusBarParts, isInSelectionRange, isRowInRange, mergeFilter, normalizeSelectionRange, numberParser, parseTsvClipboard, parseValue, processClientSideData, rangesEqual, renderFilterContent, resolveCellDisplayContent, resolveCellStyle, richSelectDropdownStyle, richSelectNoMatchesStyle, richSelectOptionHighlightedStyle, richSelectOptionStyle, richSelectWrapperStyle, selectChevronStyle, selectDisplayStyle, selectEditorStyle, toUserLike, triggerCsvDownload, useActiveCell, useCellEditing, useCellSelection, useClipboard, useColumnChooserState, useColumnHeaderFilterState, useColumnMeta, useColumnReorder, useColumnResize, useContextMenu, useDataGridState, useDataGridTableOrchestration, useDateFilterState, useDebounce, useFillHandle, useFilterOptions, useInlineCellEditorState, useKeyboardNavigation, useLatestRef, useListVirtualizer, useMultiSelectFilterState, useOGrid, usePaginationControls, usePeopleFilterState, useRichSelectState, useRowSelection, useSelectState, useSideBarState, useTableLayout, useTextFilterState, useUndoRedo, useVirtualScroll } from '@alaarab/ogrid-react';
4
4
  import * as React2 from 'react';
5
5
  import { useCallback, useRef, useEffect } from 'react';
6
6
  import { createPortal } from 'react-dom';
7
- import { Popover, PopoverSurface, Button, Select, TableRow, TableCell, Checkbox, Table, TableHeader, TableHeaderCell, TableBody } from '@fluentui/react-components';
8
- import { FilterRegular, ChevronDoubleLeftRegular, ChevronLeftRegular, ChevronRightRegular, ChevronDoubleRightRegular, SearchRegular, ChevronUpRegular, ChevronDownRegular, TableSettingsRegular } from '@fluentui/react-icons';
7
+ import { Popover, PopoverSurface, TableRow, TableCell, Checkbox, Table, TableHeader, TableHeaderCell, Select, Button, TableBody } from '@fluentui/react-components';
8
+ import { FilterRegular, SearchRegular, ChevronUpRegular, ChevronDownRegular, TableSettingsRegular, ChevronDoubleRightRegular, ChevronRightRegular, ChevronLeftRegular, ChevronDoubleLeftRegular } from '@fluentui/react-icons';
9
9
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
10
 
11
11
  // src/ColumnHeaderFilter/ColumnHeaderFilter.module.scss
@@ -1020,6 +1020,14 @@ function DataGridTableInner(props) {
1020
1020
  isDragging
1021
1021
  }
1022
1022
  ),
1023
+ props.formulaReferences && props.formulaReferences.length > 0 && /* @__PURE__ */ jsx(
1024
+ FormulaRefOverlay,
1025
+ {
1026
+ containerRef: tableContainerRef,
1027
+ references: props.formulaReferences,
1028
+ colOffset
1029
+ }
1030
+ ),
1023
1031
  showEmptyInGrid && emptyState && /* @__PURE__ */ jsx(EmptyState, { emptyState })
1024
1032
  ] }) }) }),
1025
1033
  menuPosition && createPortal(
@@ -1042,28 +1050,7 @@ function DataGridTableInner(props) {
1042
1050
  ),
1043
1051
  wrapperRef.current?.closest(".fui-FluentProvider") ?? document.body
1044
1052
  ),
1045
- /* @__PURE__ */ jsx(
1046
- ColumnHeaderMenu,
1047
- {
1048
- isOpen: headerMenu.isOpen,
1049
- anchorElement: headerMenu.anchorElement,
1050
- onClose: headerMenu.close,
1051
- onPinLeft: headerMenu.handlePinLeft,
1052
- onPinRight: headerMenu.handlePinRight,
1053
- onUnpin: headerMenu.handleUnpin,
1054
- onSortAsc: headerMenu.handleSortAsc,
1055
- onSortDesc: headerMenu.handleSortDesc,
1056
- onClearSort: headerMenu.handleClearSort,
1057
- onAutosizeThis: headerMenu.handleAutosizeThis,
1058
- onAutosizeAll: headerMenu.handleAutosizeAll,
1059
- canPinLeft: headerMenu.canPinLeft,
1060
- canPinRight: headerMenu.canPinRight,
1061
- canUnpin: headerMenu.canUnpin,
1062
- currentSort: headerMenu.currentSort,
1063
- isSortable: headerMenu.isSortable,
1064
- isResizable: headerMenu.isResizable
1065
- }
1066
- )
1053
+ /* @__PURE__ */ jsx(ColumnHeaderMenu, { ...getColumnHeaderMenuProps(headerMenu) })
1067
1054
  ]
1068
1055
  }
1069
1056
  ),
@@ -1092,6 +1079,25 @@ var ColumnChooser_module_default = {
1092
1079
  "optionItem": "ogrid-fluent__ColumnChooser-module__optionItem",
1093
1080
  "actions": "ogrid-fluent__ColumnChooser-module__actions"
1094
1081
  };
1082
+ var CheckboxItem = ({ columnId, columnName, checked, disabled, onChange }) => /* @__PURE__ */ jsx(
1083
+ Checkbox,
1084
+ {
1085
+ id: `col-${columnId}`,
1086
+ label: columnName,
1087
+ checked,
1088
+ onChange: (_ev, data) => onChange(data.checked === true),
1089
+ disabled
1090
+ }
1091
+ );
1092
+ var Actions = ({ onClearAll, onSelectAll }) => /* @__PURE__ */ jsxs("div", { className: ColumnChooser_module_default.actions, children: [
1093
+ /* @__PURE__ */ jsx(Button, { appearance: "subtle", size: "small", onClick: onClearAll, children: "Clear All" }),
1094
+ /* @__PURE__ */ jsx(Button, { appearance: "primary", size: "small", onClick: onSelectAll, children: "Select All" })
1095
+ ] });
1096
+ var CLASS_NAMES = {
1097
+ header: ColumnChooser_module_default.header,
1098
+ optionsList: ColumnChooser_module_default.optionsList,
1099
+ optionItem: ColumnChooser_module_default.optionItem
1100
+ };
1095
1101
  var ColumnChooser = (props) => {
1096
1102
  const { columns, visibleColumns, onVisibilityChange, onSetVisibleColumns, className } = props;
1097
1103
  const buttonRef = useRef(null);
@@ -1122,9 +1128,7 @@ var ColumnChooser = (props) => {
1122
1128
  document.removeEventListener("mousedown", handleClickOutside);
1123
1129
  };
1124
1130
  }, [open, handleClose]);
1125
- const handleCheckboxChange = (columnKey) => (_ev, data) => {
1126
- setColumnVisible(columnKey)(data.checked === true);
1127
- };
1131
+ const handleCheckboxChange = (columnKey) => (checked) => setColumnVisible(columnKey)(checked);
1128
1132
  return /* @__PURE__ */ jsxs("div", { className: `${ColumnChooser_module_default.container} ${className || ""}`, children: [
1129
1133
  /* @__PURE__ */ jsxs(
1130
1134
  Button,
@@ -1145,28 +1149,21 @@ var ColumnChooser = (props) => {
1145
1149
  ]
1146
1150
  }
1147
1151
  ),
1148
- open && /* @__PURE__ */ jsxs("div", { ref: dropdownRef, className: ColumnChooser_module_default.dropdown, children: [
1149
- /* @__PURE__ */ jsxs("div", { className: ColumnChooser_module_default.header, children: [
1150
- "Select Columns (",
1152
+ open && /* @__PURE__ */ jsx("div", { ref: dropdownRef, className: ColumnChooser_module_default.dropdown, children: /* @__PURE__ */ jsx(
1153
+ ColumnChooserContent,
1154
+ {
1155
+ columns,
1156
+ visibleColumns,
1151
1157
  visibleCount,
1152
- " of ",
1153
1158
  totalCount,
1154
- ")"
1155
- ] }),
1156
- /* @__PURE__ */ jsx("div", { className: ColumnChooser_module_default.optionsList, children: columns.map((column) => /* @__PURE__ */ jsx("div", { className: ColumnChooser_module_default.optionItem, children: /* @__PURE__ */ jsx(
1157
- Checkbox,
1158
- {
1159
- label: column.name,
1160
- checked: visibleColumns.has(column.columnId),
1161
- onChange: handleCheckboxChange(column.columnId),
1162
- disabled: column.required === true
1163
- }
1164
- ) }, column.columnId)) }),
1165
- /* @__PURE__ */ jsxs("div", { className: ColumnChooser_module_default.actions, children: [
1166
- /* @__PURE__ */ jsx(Button, { appearance: "subtle", size: "small", onClick: handleClearAll, children: "Clear All" }),
1167
- /* @__PURE__ */ jsx(Button, { appearance: "primary", size: "small", onClick: handleSelectAll, children: "Select All" })
1168
- ] })
1169
- ] })
1159
+ handleSelectAll,
1160
+ handleClearAll,
1161
+ handleCheckboxChange,
1162
+ CheckboxItem,
1163
+ classNames: CLASS_NAMES,
1164
+ Actions
1165
+ }
1166
+ ) })
1170
1167
  ] });
1171
1168
  };
1172
1169
 
@@ -1183,71 +1180,57 @@ var PaginationControls_module_default = {
1183
1180
  "pageSizeLabel": "ogrid-fluent__PaginationControls-module__pageSizeLabel",
1184
1181
  "pageSizeSelect": "ogrid-fluent__PaginationControls-module__pageSizeSelect"
1185
1182
  };
1186
- var PaginationControls = React2.memo((props) => {
1187
- const { currentPage, pageSize, totalCount, onPageChange, onPageSizeChange, pageSizeOptions, entityLabelPlural, className } = props;
1188
- const { labelPlural, vm, handlePageSizeChange } = usePaginationControls({
1189
- currentPage,
1190
- pageSize,
1191
- totalCount,
1192
- onPageChange,
1193
- onPageSizeChange,
1194
- pageSizeOptions,
1195
- entityLabelPlural
1196
- });
1197
- const handlePageSizeChangeEvent = (_e, data) => {
1198
- handlePageSizeChange(Number(data.value));
1199
- };
1200
- if (!vm) {
1201
- return null;
1183
+ var FLUENT_NAV_ICONS = {
1184
+ first: /* @__PURE__ */ jsx(ChevronDoubleLeftRegular, {}),
1185
+ prev: /* @__PURE__ */ jsx(ChevronLeftRegular, {}),
1186
+ next: /* @__PURE__ */ jsx(ChevronRightRegular, {}),
1187
+ last: /* @__PURE__ */ jsx(ChevronDoubleRightRegular, {})
1188
+ };
1189
+ var NavButton = ({ variant, onClick, disabled, "aria-label": ariaLabel, className }) => /* @__PURE__ */ jsx(
1190
+ Button,
1191
+ {
1192
+ appearance: "outline",
1193
+ shape: "circular",
1194
+ size: "small",
1195
+ icon: FLUENT_NAV_ICONS[variant],
1196
+ onClick,
1197
+ disabled,
1198
+ "aria-label": ariaLabel,
1199
+ className
1202
1200
  }
1203
- const { pageNumbers, showStartEllipsis, showEndEllipsis, totalPages, startItem, endItem } = vm;
1204
- return /* @__PURE__ */ jsxs("div", { className: `${PaginationControls_module_default.pagination} ${className || ""}`, role: "navigation", "aria-label": "Pagination", children: [
1205
- /* @__PURE__ */ jsxs("div", { className: PaginationControls_module_default.paginationInfo, children: [
1206
- "Showing ",
1207
- startItem,
1208
- " to ",
1209
- endItem,
1210
- " of ",
1211
- totalCount.toLocaleString(),
1212
- " ",
1213
- labelPlural
1214
- ] }),
1215
- /* @__PURE__ */ jsxs("div", { className: PaginationControls_module_default.paginationControls, children: [
1216
- /* @__PURE__ */ jsx(Button, { appearance: "outline", shape: "circular", size: "small", icon: /* @__PURE__ */ jsx(ChevronDoubleLeftRegular, {}), onClick: () => onPageChange(1), disabled: currentPage === 1, "aria-label": "First page", className: PaginationControls_module_default.navBtn }),
1217
- /* @__PURE__ */ jsx(Button, { appearance: "outline", shape: "circular", size: "small", icon: /* @__PURE__ */ jsx(ChevronLeftRegular, {}), onClick: () => onPageChange(currentPage - 1), disabled: currentPage === 1, "aria-label": "Previous page", className: PaginationControls_module_default.navBtn }),
1218
- /* @__PURE__ */ jsxs("div", { className: PaginationControls_module_default.pageNumbers, children: [
1219
- showStartEllipsis && /* @__PURE__ */ jsxs(Fragment, { children: [
1220
- /* @__PURE__ */ jsx(Button, { appearance: "outline", size: "small", shape: "rounded", onClick: () => onPageChange(1), "aria-label": "Page 1", className: PaginationControls_module_default.pageBtn, children: "1" }),
1221
- /* @__PURE__ */ jsx("span", { className: PaginationControls_module_default.ellipsis, "aria-hidden": true, children: "\u2026" })
1222
- ] }),
1223
- pageNumbers.map((pageNum) => /* @__PURE__ */ jsx(
1224
- Button,
1225
- {
1226
- appearance: currentPage === pageNum ? "primary" : "outline",
1227
- size: "small",
1228
- shape: "rounded",
1229
- onClick: () => onPageChange(pageNum),
1230
- "aria-label": `Page ${pageNum}`,
1231
- "aria-current": currentPage === pageNum ? "page" : void 0,
1232
- className: PaginationControls_module_default.pageBtn,
1233
- children: pageNum
1234
- },
1235
- pageNum
1236
- )),
1237
- showEndEllipsis && /* @__PURE__ */ jsxs(Fragment, { children: [
1238
- /* @__PURE__ */ jsx("span", { className: PaginationControls_module_default.ellipsis, "aria-hidden": true, children: "\u2026" }),
1239
- /* @__PURE__ */ jsx(Button, { appearance: "outline", size: "small", shape: "rounded", onClick: () => onPageChange(totalPages), "aria-label": `Page ${totalPages}`, className: PaginationControls_module_default.pageBtn, children: totalPages })
1240
- ] })
1241
- ] }),
1242
- /* @__PURE__ */ jsx(Button, { appearance: "outline", shape: "circular", size: "small", icon: /* @__PURE__ */ jsx(ChevronRightRegular, {}), onClick: () => onPageChange(currentPage + 1), disabled: currentPage >= totalPages, "aria-label": "Next page", className: PaginationControls_module_default.navBtn }),
1243
- /* @__PURE__ */ jsx(Button, { appearance: "outline", shape: "circular", size: "small", icon: /* @__PURE__ */ jsx(ChevronDoubleRightRegular, {}), onClick: () => onPageChange(totalPages), disabled: currentPage >= totalPages, "aria-label": "Last page", className: PaginationControls_module_default.navBtn })
1244
- ] }),
1245
- /* @__PURE__ */ jsxs("div", { className: PaginationControls_module_default.pageSizeSelector, children: [
1246
- /* @__PURE__ */ jsx("span", { className: PaginationControls_module_default.pageSizeLabel, children: "Rows" }),
1247
- /* @__PURE__ */ jsx(Select, { value: String(pageSize), onChange: handlePageSizeChangeEvent, size: "small", appearance: "outline", "aria-label": "Rows per page", className: PaginationControls_module_default.pageSizeSelect, children: vm.pageSizeOptions.map((n) => /* @__PURE__ */ jsx("option", { value: n, children: n }, n)) })
1248
- ] })
1249
- ] });
1250
- });
1201
+ );
1202
+ var PageButton = ({ onClick, active, "aria-label": ariaLabel, "aria-current": ariaCurrent, children, className }) => /* @__PURE__ */ jsx(
1203
+ Button,
1204
+ {
1205
+ appearance: active ? "primary" : "outline",
1206
+ size: "small",
1207
+ shape: "rounded",
1208
+ onClick,
1209
+ "aria-label": ariaLabel,
1210
+ "aria-current": ariaCurrent,
1211
+ className,
1212
+ children
1213
+ }
1214
+ );
1215
+ var PageSizeSelect = ({ value, options, onChange, "aria-label": ariaLabel, className }) => {
1216
+ const handleChange = (_e, data) => onChange(Number(data.value));
1217
+ return /* @__PURE__ */ jsx(Select, { value: String(value), onChange: handleChange, size: "small", appearance: "outline", "aria-label": ariaLabel, className, children: options.map((n) => /* @__PURE__ */ jsx("option", { value: n, children: n }, n)) });
1218
+ };
1219
+ var SLOTS = { NavButton, PageButton, PageSizeSelect };
1220
+ var CLASS_NAMES2 = {
1221
+ pagination: PaginationControls_module_default.pagination,
1222
+ paginationInfo: PaginationControls_module_default.paginationInfo,
1223
+ paginationControls: PaginationControls_module_default.paginationControls,
1224
+ pageNumbers: PaginationControls_module_default.pageNumbers,
1225
+ ellipsis: PaginationControls_module_default.ellipsis,
1226
+ navBtn: PaginationControls_module_default.navBtn,
1227
+ pageBtn: PaginationControls_module_default.pageBtn,
1228
+ pageSizeSelector: PaginationControls_module_default.pageSizeSelector,
1229
+ pageSizeLabel: PaginationControls_module_default.pageSizeLabel,
1230
+ pageSizeSelect: PaginationControls_module_default.pageSizeSelect
1231
+ };
1232
+ var PaginationControls = React2.memo((props) => /* @__PURE__ */ jsx(PaginationControlsBase, { ...props, slots: SLOTS, classNames: CLASS_NAMES2 }));
1233
+ PaginationControls.displayName = "PaginationControls";
1251
1234
 
1252
1235
  // src/OGrid/OGrid.tsx
1253
1236
  var OGrid = createOGrid({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alaarab/ogrid-react-fluent",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "OGrid React Fluent implementation – DataGrid-powered data table with sorting, filtering, pagination, column chooser, and CSV export.",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -41,7 +41,7 @@
41
41
  "node": ">=18"
42
42
  },
43
43
  "dependencies": {
44
- "@alaarab/ogrid-react": "2.3.0"
44
+ "@alaarab/ogrid-react": "2.4.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "@fluentui/react-components": "^9.0.0",