@alaarab/ogrid 1.2.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 (32) hide show
  1. package/README.md +56 -0
  2. package/dist/esm/ColumnChooser/ColumnChooser.js +22 -0
  3. package/dist/esm/ColumnChooser/ColumnChooser.module.css +139 -0
  4. package/dist/esm/ColumnHeaderFilter/ColumnHeaderFilter.js +50 -0
  5. package/dist/esm/ColumnHeaderFilter/ColumnHeaderFilter.module.css +332 -0
  6. package/dist/esm/ColumnHeaderFilter/MultiSelectFilterPopover.js +5 -0
  7. package/dist/esm/ColumnHeaderFilter/PeopleFilterPopover.js +19 -0
  8. package/dist/esm/ColumnHeaderFilter/TextFilterPopover.js +4 -0
  9. package/dist/esm/ColumnHeaderFilter/index.js +1 -0
  10. package/dist/esm/DataGridTable/DataGridTable.js +123 -0
  11. package/dist/esm/DataGridTable/DataGridTable.module.css +421 -0
  12. package/dist/esm/DataGridTable/GridContextMenu.js +26 -0
  13. package/dist/esm/DataGridTable/InlineCellEditor.js +22 -0
  14. package/dist/esm/DataGridTable/StatusBar.js +7 -0
  15. package/dist/esm/OGrid/OGrid.js +16 -0
  16. package/dist/esm/PaginationControls/PaginationControls.js +31 -0
  17. package/dist/esm/PaginationControls/PaginationControls.module.css +112 -0
  18. package/dist/esm/index.js +8 -0
  19. package/dist/types/ColumnChooser/ColumnChooser.d.ts +10 -0
  20. package/dist/types/ColumnHeaderFilter/ColumnHeaderFilter.d.ts +20 -0
  21. package/dist/types/ColumnHeaderFilter/MultiSelectFilterPopover.d.ts +14 -0
  22. package/dist/types/ColumnHeaderFilter/PeopleFilterPopover.d.ts +13 -0
  23. package/dist/types/ColumnHeaderFilter/TextFilterPopover.d.ts +8 -0
  24. package/dist/types/ColumnHeaderFilter/index.d.ts +1 -0
  25. package/dist/types/DataGridTable/DataGridTable.d.ts +7 -0
  26. package/dist/types/DataGridTable/GridContextMenu.d.ts +8 -0
  27. package/dist/types/DataGridTable/InlineCellEditor.d.ts +12 -0
  28. package/dist/types/DataGridTable/StatusBar.d.ts +8 -0
  29. package/dist/types/OGrid/OGrid.d.ts +5 -0
  30. package/dist/types/PaginationControls/PaginationControls.d.ts +11 -0
  31. package/dist/types/index.d.ts +6 -0
  32. package/package.json +56 -0
@@ -0,0 +1,112 @@
1
+ .pagination {
2
+ display: flex;
3
+ flex-wrap: wrap;
4
+ align-items: center;
5
+ justify-content: space-between;
6
+ gap: 14px 24px;
7
+ width: 100%;
8
+ min-width: 0;
9
+ box-sizing: border-box;
10
+ padding: 14px 0;
11
+ margin-top: 16px;
12
+ border-top: 1px solid var(--ogrid-border, #e5e5e5);
13
+ }
14
+
15
+ .paginationInfo {
16
+ font-size: 13px;
17
+ color: var(--ogrid-muted, #606060);
18
+ flex-shrink: 0;
19
+ font-variant-numeric: tabular-nums;
20
+ }
21
+
22
+ .paginationControls {
23
+ display: flex;
24
+ align-items: center;
25
+ gap: 4px;
26
+ flex-wrap: wrap;
27
+ flex: 1 1 auto;
28
+ justify-content: center;
29
+ min-width: 0;
30
+ }
31
+
32
+ .navBtn {
33
+ min-width: 28px;
34
+ min-height: 28px;
35
+ padding: 4px;
36
+ border: 1px solid var(--ogrid-border, #ccc);
37
+ border-radius: 50%;
38
+ background: var(--ogrid-bg, #fff);
39
+ color: var(--ogrid-fg, #333);
40
+ cursor: pointer;
41
+ display: inline-flex;
42
+ align-items: center;
43
+ justify-content: center;
44
+ font-size: 14px;
45
+ }
46
+ .navBtn:hover:not(:disabled) {
47
+ background: var(--ogrid-bg-hover, #f5f5f5);
48
+ border-color: var(--ogrid-border-hover, #999);
49
+ }
50
+ .navBtn:disabled {
51
+ opacity: 0.5;
52
+ cursor: not-allowed;
53
+ }
54
+
55
+ .pageNumbers {
56
+ display: inline-flex;
57
+ align-items: center;
58
+ gap: 4px;
59
+ margin: 0 8px;
60
+ }
61
+
62
+ .pageBtn {
63
+ min-width: 28px;
64
+ min-height: 28px;
65
+ padding: 4px 8px;
66
+ border: 1px solid var(--ogrid-border, #ccc);
67
+ border-radius: 4px;
68
+ background: var(--ogrid-bg, #fff);
69
+ color: var(--ogrid-fg, #333);
70
+ cursor: pointer;
71
+ font-size: 13px;
72
+ font-variant-numeric: tabular-nums;
73
+ }
74
+ .pageBtn:hover {
75
+ background: var(--ogrid-bg-hover, #f5f5f5);
76
+ }
77
+ .pageBtn.active {
78
+ background: var(--ogrid-primary, #0066cc);
79
+ border-color: var(--ogrid-primary, #0066cc);
80
+ color: var(--ogrid-primary-fg, #fff);
81
+ }
82
+
83
+ .ellipsis {
84
+ display: inline-flex;
85
+ align-items: center;
86
+ justify-content: center;
87
+ min-width: 24px;
88
+ font-size: 12px;
89
+ color: var(--ogrid-muted, #888);
90
+ user-select: none;
91
+ }
92
+
93
+ .pageSizeSelector {
94
+ display: inline-flex;
95
+ align-items: center;
96
+ gap: 8px;
97
+ flex-shrink: 0;
98
+ }
99
+ .pageSizeSelector .pageSizeLabel {
100
+ font-size: 13px;
101
+ color: var(--ogrid-muted, #606060);
102
+ user-select: none;
103
+ white-space: nowrap;
104
+ }
105
+ .pageSizeSelector .pageSizeSelect {
106
+ min-width: 72px;
107
+ padding: 4px 8px;
108
+ border: 1px solid var(--ogrid-border, #ccc);
109
+ border-radius: 4px;
110
+ background: var(--ogrid-bg, #fff);
111
+ font-size: 13px;
112
+ }
@@ -0,0 +1,8 @@
1
+ // Components
2
+ export { OGrid } from './OGrid/OGrid';
3
+ export { DataGridTable } from './DataGridTable/DataGridTable';
4
+ export { ColumnChooser } from './ColumnChooser/ColumnChooser';
5
+ export { ColumnHeaderFilter } from './ColumnHeaderFilter/ColumnHeaderFilter';
6
+ export { PaginationControls } from './PaginationControls/PaginationControls';
7
+ // Re-export from core
8
+ export { toUserLike, isInSelectionRange, normalizeSelectionRange, toDataGridFilterProps, useFilterOptions, getCellValue, flattenColumns, escapeCsvValue, buildCsvHeader, buildCsvRows, exportToCsv, triggerCsvDownload, } from '@alaarab/ogrid-core';
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import type { IColumnDefinition } from '@alaarab/ogrid-core';
3
+ export type { IColumnDefinition };
4
+ export interface IColumnChooserProps {
5
+ columns: IColumnDefinition[];
6
+ visibleColumns: Set<string>;
7
+ onVisibilityChange: (columnKey: string, visible: boolean) => void;
8
+ className?: string;
9
+ }
10
+ export declare const ColumnChooser: React.FC<IColumnChooserProps>;
@@ -0,0 +1,20 @@
1
+ import * as React from 'react';
2
+ import type { UserLike, ColumnFilterType } from '@alaarab/ogrid-core';
3
+ export interface IColumnHeaderFilterProps {
4
+ columnKey: string;
5
+ columnName: string;
6
+ filterType: ColumnFilterType;
7
+ isSorted?: boolean;
8
+ isSortedDescending?: boolean;
9
+ onSort?: () => void;
10
+ selectedValues?: string[];
11
+ onFilterChange?: (values: string[]) => void;
12
+ options?: string[];
13
+ isLoadingOptions?: boolean;
14
+ textValue?: string;
15
+ onTextChange?: (value: string) => void;
16
+ selectedUser?: UserLike;
17
+ onUserChange?: (user: UserLike | undefined) => void;
18
+ peopleSearch?: (query: string) => Promise<UserLike[]>;
19
+ }
20
+ export declare const ColumnHeaderFilter: React.FC<IColumnHeaderFilterProps>;
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+ export interface MultiSelectFilterPopoverProps {
3
+ searchText: string;
4
+ onSearchChange: (value: string) => void;
5
+ options: string[];
6
+ filteredOptions: string[];
7
+ selected: Set<string>;
8
+ onOptionToggle: (option: string, checked: boolean) => void;
9
+ onSelectAll: () => void;
10
+ onClearSelection: () => void;
11
+ onApply: () => void;
12
+ isLoading: boolean;
13
+ }
14
+ export declare const MultiSelectFilterPopover: React.FC<MultiSelectFilterPopoverProps>;
@@ -0,0 +1,13 @@
1
+ import * as React from 'react';
2
+ import type { UserLike } from '@alaarab/ogrid-core';
3
+ export interface PeopleFilterPopoverProps {
4
+ selectedUser: UserLike | undefined;
5
+ searchText: string;
6
+ onSearchChange: (value: string) => void;
7
+ suggestions: UserLike[];
8
+ isLoading: boolean;
9
+ onUserSelect: (user: UserLike) => void;
10
+ onClearUser: () => void;
11
+ inputRef?: React.RefObject<HTMLInputElement | null>;
12
+ }
13
+ export declare const PeopleFilterPopover: React.FC<PeopleFilterPopoverProps>;
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ export interface TextFilterPopoverProps {
3
+ value: string;
4
+ onValueChange: (value: string) => void;
5
+ onApply: () => void;
6
+ onClear: () => void;
7
+ }
8
+ export declare const TextFilterPopover: React.FC<TextFilterPopoverProps>;
@@ -0,0 +1 @@
1
+ export { ColumnHeaderFilter, type IColumnHeaderFilterProps } from './ColumnHeaderFilter';
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ import type { IOGridDataGridProps } from '@alaarab/ogrid-core';
3
+ /** @deprecated Use IOGridDataGridProps from @alaarab/ogrid-core for new code. */
4
+ export type IDataGridTableProps<T> = IOGridDataGridProps<T>;
5
+ declare function DataGridTableInner<T>(props: IOGridDataGridProps<T>): React.ReactElement;
6
+ export declare const DataGridTable: typeof DataGridTableInner;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ import type { GridContextMenuHandlerProps } from '@alaarab/ogrid-core';
3
+ export interface GridContextMenuProps extends GridContextMenuHandlerProps {
4
+ x: number;
5
+ y: number;
6
+ hasSelection: boolean;
7
+ }
8
+ export declare function GridContextMenu(props: GridContextMenuProps): React.ReactElement;
@@ -0,0 +1,12 @@
1
+ import * as React from 'react';
2
+ import type { IColumnDef } from '@alaarab/ogrid-core';
3
+ export interface InlineCellEditorProps<T> {
4
+ value: unknown;
5
+ item: T;
6
+ column: IColumnDef<T>;
7
+ rowIndex: number;
8
+ editorType: 'text' | 'select' | 'checkbox';
9
+ onCommit: (value: unknown) => void;
10
+ onCancel: () => void;
11
+ }
12
+ export declare function InlineCellEditor<T>(props: InlineCellEditorProps<T>): React.ReactElement;
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ export interface StatusBarProps {
3
+ totalCount: number;
4
+ filteredCount?: number;
5
+ selectedCount?: number;
6
+ selectedCellCount?: number;
7
+ }
8
+ export declare function StatusBar(props: StatusBarProps): React.ReactElement;
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ import { type IOGridProps, type IOGridApi } from '@alaarab/ogrid-core';
3
+ export type { IOGridProps } from '@alaarab/ogrid-core';
4
+ declare const OGridInner: React.ForwardRefExoticComponent<IOGridProps<unknown> & React.RefAttributes<IOGridApi<unknown>>>;
5
+ export declare const OGrid: typeof OGridInner;
@@ -0,0 +1,11 @@
1
+ import * as React from 'react';
2
+ export interface IPaginationControlsProps {
3
+ currentPage: number;
4
+ pageSize: number;
5
+ totalCount: number;
6
+ onPageChange: (page: number) => void;
7
+ onPageSizeChange: (pageSize: number) => void;
8
+ entityLabelPlural?: string;
9
+ className?: string;
10
+ }
11
+ export declare const PaginationControls: React.FC<IPaginationControlsProps>;
@@ -0,0 +1,6 @@
1
+ export { OGrid, type IOGridProps } from './OGrid/OGrid';
2
+ export { DataGridTable, type IDataGridTableProps } from './DataGridTable/DataGridTable';
3
+ export { ColumnChooser, type IColumnChooserProps } from './ColumnChooser/ColumnChooser';
4
+ export { ColumnHeaderFilter, type IColumnHeaderFilterProps } from './ColumnHeaderFilter/ColumnHeaderFilter';
5
+ export { PaginationControls, type IPaginationControlsProps } from './PaginationControls/PaginationControls';
6
+ export { type ColumnFilterType, type IColumnFilterDef, type IColumnMeta, type IColumnDef, type IColumnGroupDef, type IColumnDefinition, type ICellValueChangedEvent, type ICellEditorProps, type UserLike, type IFilters, type IFetchParams, type IPageResult, type IDataSource, type IGridColumnState, type IOGridApi, type RowSelectionMode, type IRowSelectionChangeEvent, type StatusBarPanel, type IStatusBarProps, type IActiveCell, type ISelectionRange, toUserLike, isInSelectionRange, normalizeSelectionRange, toDataGridFilterProps, useFilterOptions, type UseFilterOptionsResult, getCellValue, flattenColumns, escapeCsvValue, buildCsvHeader, buildCsvRows, exportToCsv, triggerCsvDownload, type CsvColumn, } from '@alaarab/ogrid-core';
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@alaarab/ogrid",
3
+ "version": "1.2.0",
4
+ "description": "OGrid default (Radix) – Data grid with sorting, filtering, pagination, column chooser, and CSV export. Packed with Radix UI; no Fluent or Material required.",
5
+ "main": "dist/esm/index.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/types/index.d.ts",
11
+ "import": "./dist/esm/index.js",
12
+ "require": "./dist/esm/index.js"
13
+ }
14
+ },
15
+ "scripts": {
16
+ "build": "rimraf dist && tsc -p tsconfig.build.json && node scripts/compile-styles.js",
17
+ "test": "jest",
18
+ "storybook": "storybook dev -p 6008 --no-open",
19
+ "build-storybook": "storybook build"
20
+ },
21
+ "keywords": ["ogrid", "radix", "datatable", "react", "typescript", "grid", "headless"],
22
+ "author": "Ala Arab",
23
+ "license": "MIT",
24
+ "files": ["dist", "README.md", "LICENSE"],
25
+ "sideEffects": ["**/*.css"],
26
+ "engines": { "node": ">=18" },
27
+ "dependencies": {
28
+ "@alaarab/ogrid-core": "^1.2.0",
29
+ "@radix-ui/react-checkbox": "^1.1.2",
30
+ "@radix-ui/react-popover": "^1.1.2"
31
+ },
32
+ "peerDependencies": {
33
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
34
+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "@testing-library/jest-dom": "^6.6.3",
38
+ "@testing-library/react": "^16.0.1",
39
+ "identity-obj-proxy": "^3.0.0",
40
+ "ts-jest": "^29.2.5",
41
+ "sass": "^1.83.4",
42
+ "@storybook/react": "^8.5.3",
43
+ "@storybook/react-vite": "^8.5.3",
44
+ "@types/react": "^18.3.18",
45
+ "@types/react-dom": "^18.3.5",
46
+ "jest": "^29.7.0",
47
+ "jest-environment-jsdom": "^29.7.0",
48
+ "react": "^18.3.1",
49
+ "react-dom": "^18.3.1",
50
+ "rimraf": "^6.0.1",
51
+ "storybook": "^8.5.3",
52
+ "typescript": "^5.7.3",
53
+ "vite": "^6.1.0"
54
+ },
55
+ "publishConfig": { "access": "public" }
56
+ }