@azrico/reactgrid 1.4.0 → 1.5.1

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/README.md CHANGED
@@ -1,198 +1,164 @@
1
- **DISCLAIMER :**
2
- DO NOT USE THIS PACKAGE FOR ANY REASON
3
- THIS IS A PRIVATE PACKAGE
4
-
5
- ## Grid themes
6
-
7
- `AzGrid` always uses Inovua's `default-light` base for layout and icons. Its
8
- token stylesheet is optional and shipped in `dist/src/themes`. Import it once
9
- in your host's entry point to enable the variable theme; without it the grid
10
- uses Inovua's default-light appearance. The old dark/amber theme stylesheets
11
- are no longer imported by the package.
12
- Use `theme="light"` (default), `theme="dark"`, or any custom name such as
13
- `theme="deco"`. The actual grid root and its surrounding scope receive
14
- `azgrid-theme-<name>`. `theme` takes precedence over the deprecated `dark` boolean;
15
- `dark={true}` still selects dark and `dark={false}` selects light.
16
- `gridOptions.theme` is ignored to keep one consistent base for layout.
17
-
18
- Set public `--azgrid-*` variables on `:root`, a wrapper, or the theme class.
19
- Different wrappers can theme multiple grids independently. Neutral light/dark
20
- presets set only internal `--azgrid-preset-*` fallbacks, so grid defaults
21
- never mask variables inherited from your wrapper. Custom names use light
22
- fallbacks for unspecified tokens; set the complete palette for a custom dark theme.
23
- No daisyUI dependency or variables are required.
24
-
25
- ```tsx
26
- import { AzGrid } from '@azrico/reactgrid';
27
- import '@azrico/reactgrid/dist/src/themes/azgrid-theme.css';
28
-
29
- <div className="my-grid">
30
- <AzGrid theme="light" columns={columns} dataSource={rows} />
31
- </div>
32
- ```
33
-
34
- ```css
35
- .my-grid {
36
- --azgrid-accent: #345b93;
37
- --azgrid-header-bg: #edf2f8;
38
- --azgrid-row-bg-hover: #e4ecf7;
39
- }
40
- ```
41
-
42
- ### Public variables
43
-
44
- Every use has a neutral preset fallback. Values can be any valid CSS value for
45
- the indicated property. Fallbacks expressed using another token follow host
46
- overrides of that token. `--azgrid-preset-*` variables are internal implementation
47
- details and should not be overridden.
48
-
49
- <!-- azgrid-tokens -->
50
- | Variable | Controls | Light / dark fallback |
51
- | --- | --- | --- |
52
- | `--azgrid-bg` | Grid background | `#fff` / `#313943` |
53
- | `--azgrid-fg` | Grid text | `#555e68` / `#c5cae9` |
54
- | `--azgrid-border` | Grid border and separators | `#e4e3e2` / `#4f575f` |
55
- | `--azgrid-font-family` | Grid and control font family | `'Nunito Sans', 'Iran Sans', sans-serif` |
56
- | `--azgrid-radius` | Grid, input and menu corner radius | `0` |
57
- | `--azgrid-accent` | Focus indicators, sort arrows, checkboxes and selection handles | `#7986cb` / `#caae53` |
58
- | `--azgrid-transparent` | Transparent structural surfaces | `transparent` |
59
- | `--azgrid-muted-fg` | Disabled text and secondary icons | `#99a1aa` / `#9ca6b0` |
60
- | `--azgrid-shadow-color` | Menu and input shadow colour | `rgba(0, 0, 0, .2)` / `rgba(0, 0, 0, .4)` |
61
- | `--azgrid-header-bg` | Header and grouped header background | `#fff` / `#3b444f` |
62
- | `--azgrid-header-fg` | Header text | `var(--azgrid-fg, var(--azgrid-preset-fg))` |
63
- | `--azgrid-header-border` | Header separators | `var(--azgrid-border, var(--azgrid-preset-border))` |
64
- | `--azgrid-header-font-size` | Header font size | `14px` |
65
- | `--azgrid-header-text-transform` | Header text transform | `none` |
66
- | `--azgrid-header-letter-spacing` | Header letter spacing | `normal` |
67
- | `--azgrid-header-font-weight` | Header font weight | `500` |
68
- | `--azgrid-row-bg-even` | Even and non-zebra rows | `var(--azgrid-bg, var(--azgrid-preset-bg))` |
69
- | `--azgrid-row-bg-odd` | Odd rows | `#fafafa` / `#353e48` |
70
- | `--azgrid-row-bg-hover` | Hovered rows and cells | `#ebedf7` / `#454f5b` |
71
- | `--azgrid-row-fg-hover` | Hovered row text | `var(--azgrid-fg, var(--azgrid-preset-fg))` / `#ececec` |
72
- | `--azgrid-row-bg-selected` | Selected rows and cells | `#dce0f2` / `#655c3e` |
73
- | `--azgrid-row-fg-selected` | Selected row text | `var(--azgrid-fg, var(--azgrid-preset-fg))` / `#fff` |
74
- | `--azgrid-row-bg-active` | Active rows | `#ebedf7` / `#4f575f` |
75
- | `--azgrid-cell-border` | Cell borders | `rgba(1, 1, 1, .1)` / `#4f575f` |
76
- | `--azgrid-cell-border-width` | Cell border width | `0.1px` |
77
- | `--azgrid-cell-padding` | Ordinary data cell padding; expand/reorder tools keep their layout | `0 8px` |
78
- | `--azgrid-filter-bg` | Filter row and input background, also editors and search | `var(--azgrid-bg, var(--azgrid-preset-bg))` |
79
- | `--azgrid-filter-fg` | Filter input and editor text | `var(--azgrid-fg, var(--azgrid-preset-fg))` |
80
- | `--azgrid-filter-border` | Filter input borders | `var(--azgrid-border, var(--azgrid-preset-border))` |
81
- | `--azgrid-filter-placeholder` | Input placeholder text | `var(--azgrid-muted-fg, var(--azgrid-preset-muted-fg))` |
82
- | `--azgrid-filter-focus-ring` | Focused input border and ring | `var(--azgrid-accent, var(--azgrid-preset-accent))` |
83
- | `--azgrid-pagination-bg` | Pagination toolbar, page number and page size controls | `var(--azgrid-bg, var(--azgrid-preset-bg))` |
84
- | `--azgrid-pagination-fg` | Pagination text and icons | `var(--azgrid-fg, var(--azgrid-preset-fg))` |
85
- | `--azgrid-pagination-border` | Pagination control borders | `var(--azgrid-border, var(--azgrid-preset-border))` |
86
- | `--azgrid-menu-bg` | Column, filter, context, select menus and date pickers | `var(--azgrid-bg, var(--azgrid-preset-bg))` |
87
- | `--azgrid-menu-fg` | Menu text and icons | `var(--azgrid-fg, var(--azgrid-preset-fg))` |
88
- | `--azgrid-menu-border` | Menu borders and separators | `var(--azgrid-border, var(--azgrid-preset-border))` |
89
- | `--azgrid-menu-bg-hover` | Hovered/focused menu entries | `var(--azgrid-row-bg-hover, var(--azgrid-preset-row-bg-hover))` |
90
- | `--azgrid-scrollbar-track` | Native and Inovua scrollbar tracks | `#f1f1f1` / `#313943` |
91
- | `--azgrid-scrollbar-thumb` | Native and Inovua scrollbar thumbs | `#b5b5b5` / `#697582` |
92
- | `--azgrid-empty-bg` | Empty state background | `var(--azgrid-bg, var(--azgrid-preset-bg))` |
93
- | `--azgrid-empty-fg` | No records text | `var(--azgrid-fg, var(--azgrid-preset-fg))` |
94
- | `--azgrid-loading-bg` | Loading overlay background | `rgba(255, 255, 255, .8)` / `rgba(49, 57, 67, .8)` |
95
- | `--azgrid-loading-fg` | Loading text and spinner | `var(--azgrid-fg, var(--azgrid-preset-fg))` |
96
- | `--azgrid-tree-bg` | Tree/group row background | `var(--azgrid-row-bg-even, var(--azgrid-preset-row-bg-even))` |
97
- | `--azgrid-tree-fg` | Tree/group text and expand icons | `var(--azgrid-fg, var(--azgrid-preset-fg))` |
98
- | `--azgrid-details-bg` | Row details background | `var(--azgrid-bg, var(--azgrid-preset-bg))` |
99
- | `--azgrid-locked-column-shadow` | Locked column separator shadow (complete CSS box-shadow value) | `0 0 5px rgba(0, 0, 0, .2)` / `0 0 5px rgba(0, 0, 0, .5)` |
100
- <!-- /azgrid-tokens -->
101
-
102
- ### Dark Art Deco host preset
103
-
104
- Square corners, obsidian surfaces, gold accents and uppercase widely spaced
105
- headers are host choices, separate from the neutral theme. Set variables on
106
- `.azgrid-theme-deco` to support `theme="deco"`, or on a host wrapper.
107
-
108
- ```tsx
109
- <AzGrid theme="deco" columns={columns} dataSource={rows} />
110
- ```
111
-
112
- <!-- azgrid-deco -->
1
+ # @azrico/reactgrid
2
+
3
+ Private React data grid package for Azrideus' projects.
4
+
5
+ ## Usage
6
+
7
+ ```tsx
8
+ import { AzGrid } from '@azrico/reactgrid';
9
+ import '@azrico/reactgrid/dist/src/themes/azgrid-theme.css';
10
+
11
+ const columns = [{ name: 'name', header: 'Name', defaultFlex: 1 }];
12
+ const rows = [{ __table_id: '1', name: 'Alice' }];
13
+
14
+ <AzGrid theme="light" columns={columns} dataSource={rows} />;
15
+ ```
16
+
17
+ The token stylesheet is optional. Without it, the grid uses Inovua's default-light appearance.
18
+
19
+ ## Accessibility
20
+
21
+ The grid exposes ARIA grid semantics, so screen readers and automation tools can read it from the accessibility tree.
22
+
23
+ | Element | Attributes |
24
+ | --- | --- |
25
+ | Grid root | `role="grid"`, `aria-rowcount` (total rows incl. header; the full data count when paginated), `aria-colcount` (visible columns), `aria-label`, `aria-readonly="true"` when the grid isn't editable |
26
+ | Header row | `role="row"`, `aria-rowindex="1"` |
27
+ | Header cells | `role="columnheader"`, `aria-colindex`, `aria-sort` (`ascending` / `descending` / `none`, sortable columns only) |
28
+ | Rows | `role="row"`, `aria-rowindex` (1-based, header is 1, includes the page offset), `aria-selected` when selection is enabled, `data-row-id` |
29
+ | Body cells | `role="gridcell"`, `aria-colindex`, `data-column="<column name>"`, `aria-readonly="true"` when the cell can't be edited |
30
+ | Row-number cells | `role="rowheader"` |
31
+
32
+ New props:
33
+
34
+ - `ariaLabel?: string` on the grid sets the accessible name of the grid.
35
+ - `ariaLabel?: (value, data) => string` on a column sets `aria-label` on its cells. Use it for icons, badges or values whose visible text isn't descriptive.
36
+
37
+ ```tsx
38
+ const columns = [{ name: 'status', header: 'Status', ariaLabel: (value) => `Status: ${value}` }];
39
+
40
+ <AzGrid ariaLabel="Orders" columns={columns} dataSource={rows} />;
41
+ ```
42
+
43
+ Override any cell attribute with the column's `cellDOMProps` / `headerDOMProps`. Values you set there are kept.
44
+ A `gridOptions.onRenderRow` runs after the grid's own row attributes are set, so it can change them too.
45
+
46
+ ## Themes
47
+
48
+ Use `theme="light"` (default), `theme="dark"`, or a custom name. Custom names apply
49
+ `azgrid-theme-<name>` to the grid and use light defaults for unspecified variables.
50
+
51
+ `dark` remains a deprecated alias. `theme` takes precedence; `gridOptions.theme` is ignored.
52
+
53
+ Set `--azgrid-*` variables on a wrapper, `:root`, or a theme class. Each grid can use a different palette.
54
+
55
+ ```tsx
56
+ <div className="my-grid">
57
+ <AzGrid theme="light" columns={columns} dataSource={rows} />
58
+ </div>
59
+ ```
60
+
113
61
  ```css
114
- /* Example host preset; separate from the neutral grid theme. */
115
- .azgrid-example-deco, .azgrid-theme-deco {
116
- --azgrid-bg: #0A0A0A;
117
- --azgrid-fg: #eee7d6;
118
- --azgrid-border: #6b5824;
119
- --azgrid-accent: #D4AF37;
120
- --azgrid-muted-fg: #9b8a5b;
121
- --azgrid-radius: 0;
122
- --azgrid-font-family: Georgia, serif;
123
- --azgrid-header-bg: #0A0A0A;
124
- --azgrid-header-fg: #D4AF37;
125
- --azgrid-header-border: #6b5824;
126
- --azgrid-header-text-transform: uppercase;
127
- --azgrid-header-letter-spacing: .1em;
128
- --azgrid-header-font-weight: 600;
129
- --azgrid-row-bg-even: #0A0A0A;
130
- --azgrid-row-bg-odd: #12110e;
131
- --azgrid-row-bg-hover: #282211;
132
- --azgrid-row-fg-hover: #fff6dc;
133
- --azgrid-row-bg-selected: #423619;
134
- --azgrid-row-fg-selected: #fff6dc;
135
- --azgrid-row-bg-active: #332a15;
136
- --azgrid-cell-border: #6b5824;
137
- --azgrid-cell-border-width: 1px;
138
- --azgrid-cell-padding: 0 10px;
139
- --azgrid-filter-bg: #12110e;
140
- --azgrid-filter-fg: #eee7d6;
141
- --azgrid-filter-border: #6b5824;
142
- --azgrid-filter-placeholder: #9b8a5b;
143
- --azgrid-filter-focus-ring: #D4AF37;
144
- --azgrid-pagination-bg: #0A0A0A;
145
- --azgrid-pagination-fg: #D4AF37;
146
- --azgrid-pagination-border: #6b5824;
147
- --azgrid-menu-bg: #12110e;
148
- --azgrid-menu-fg: #eee7d6;
149
- --azgrid-menu-border: #6b5824;
150
- --azgrid-menu-bg-hover: #282211;
151
- --azgrid-scrollbar-track: #0A0A0A;
152
- --azgrid-scrollbar-thumb: #6b5824;
153
- --azgrid-empty-bg: #0A0A0A;
154
- --azgrid-empty-fg: #9b8a5b;
155
- --azgrid-loading-bg: rgba(10, 10, 10, .85);
156
- --azgrid-loading-fg: #D4AF37;
157
- --azgrid-tree-bg: #12110e;
158
- --azgrid-tree-fg: #D4AF37;
159
- --azgrid-details-bg: #12110e;
160
- --azgrid-shadow-color: rgba(0, 0, 0, .6);
161
- --azgrid-locked-column-shadow: 0 0 5px #6b5824;
62
+ .my-grid {
63
+ --azgrid-accent: #345b93;
64
+ --azgrid-header-bg: #edf2f8;
65
+ --azgrid-row-bg-hover: #e4ecf7;
162
66
  }
67
+ ```
68
+
69
+ ## CSS variables
70
+
71
+ All variables have light/dark defaults. Use valid CSS values for the named property.
72
+ `--azgrid-locked-column-shadow` accepts a complete `box-shadow` value.
73
+
74
+ <!-- azgrid-tokens -->
75
+ | Variable | Controls |
76
+ | --- | --- |
77
+ | `--azgrid-bg` | Grid background |
78
+ | `--azgrid-fg` | Grid text |
79
+ | `--azgrid-border` | Grid border and separators |
80
+ | `--azgrid-font-family` | Grid and control fonts |
81
+ | `--azgrid-radius` | Grid, input and menu corner radius; default `0` |
82
+ | `--azgrid-accent` | Focus, sort arrows, checkboxes and selection handles |
83
+ | `--azgrid-transparent` | Transparent structural surfaces |
84
+ | `--azgrid-muted-fg` | Disabled text and secondary icons |
85
+ | `--azgrid-shadow-color` | Menu and input shadow colour |
86
+ | `--azgrid-header-bg` | Header background |
87
+ | `--azgrid-header-fg` | Header text |
88
+ | `--azgrid-header-border` | Header separators |
89
+ | `--azgrid-header-font-size` | Header font size |
90
+ | `--azgrid-header-text-transform` | Header text transform |
91
+ | `--azgrid-header-letter-spacing` | Header letter spacing |
92
+ | `--azgrid-header-font-weight` | Header font weight |
93
+ | `--azgrid-row-bg-even` | Even and non-zebra rows |
94
+ | `--azgrid-row-bg-odd` | Odd rows |
95
+ | `--azgrid-row-bg-hover` | Hovered rows and cells |
96
+ | `--azgrid-row-fg-hover` | Hovered row text |
97
+ | `--azgrid-row-bg-selected` | Selected rows and cells |
98
+ | `--azgrid-row-fg-selected` | Selected row text |
99
+ | `--azgrid-row-bg-active` | Active rows |
100
+ | `--azgrid-cell-border` | Cell border colour |
101
+ | `--azgrid-cell-border-width` | Cell border width |
102
+ | `--azgrid-cell-padding` | Data cell padding |
103
+ | `--azgrid-filter-bg` | Filter row, input, editor and search background |
104
+ | `--azgrid-filter-fg` | Filter input and editor text |
105
+ | `--azgrid-filter-border` | Filter input borders |
106
+ | `--azgrid-filter-placeholder` | Input placeholder text |
107
+ | `--azgrid-filter-focus-ring` | Focused input border and ring |
108
+ | `--azgrid-pagination-bg` | Pagination toolbar and control background |
109
+ | `--azgrid-pagination-fg` | Pagination text and icons |
110
+ | `--azgrid-pagination-border` | Pagination control borders |
111
+ | `--azgrid-menu-bg` | Menu, select dropdown and date picker background |
112
+ | `--azgrid-menu-fg` | Menu text and icons |
113
+ | `--azgrid-menu-border` | Menu borders and separators |
114
+ | `--azgrid-menu-bg-hover` | Hovered and focused menu entries |
115
+ | `--azgrid-scrollbar-track` | Scrollbar tracks |
116
+ | `--azgrid-scrollbar-thumb` | Scrollbar thumbs |
117
+ | `--azgrid-empty-bg` | Empty state background |
118
+ | `--azgrid-empty-fg` | Empty state text |
119
+ | `--azgrid-loading-bg` | Loading overlay background |
120
+ | `--azgrid-loading-fg` | Loading text and spinner |
121
+ | `--azgrid-tree-bg` | Tree and group row background |
122
+ | `--azgrid-tree-fg` | Tree and group text and expand icons |
123
+ | `--azgrid-details-bg` | Row details background |
124
+ | `--azgrid-locked-column-shadow` | Locked column shadow |
125
+ <!-- /azgrid-tokens -->
126
+
127
+ ## Art Deco example
128
+
129
+ Use dark defaults with an obsidian background, gold accents, square corners and uppercase headers.
163
130
 
131
+ ```tsx
132
+ <div className="deco-grid">
133
+ <AzGrid theme="dark" columns={columns} dataSource={rows} />
134
+ </div>
164
135
  ```
165
- <!-- /azgrid-deco -->
166
-
167
- `src/example.tsx` renders light, dark and this host palette together, with
168
- filter inputs, editable cells, tree rows, selection, context menus and pagination.
169
-
170
- ### Scope and maintenance
171
-
172
- The wrapper's MUI context menu portal stays inside the owning theme scope.
173
- Inovua's default column/filter menus and page-size dropdown render in
174
- the grid. If you explicitly use `gridOptions.menuPortalContainer` or
175
- `gridOptions.renderInPortal` to move UI elsewhere, that external container must
176
- also carry `azgrid-scope`, the owning `azgrid-theme-<name>` class and host
177
- variables. Arbitrary custom cell,
178
- editor, menu and row-detail content must use these variables in its own CSS;
179
- the package cannot replace colours deliberately supplied by a host renderer or
180
- inline `gridOptions.style`/column styles.
181
-
182
- Inovua's base layout, animations, icon geometry and state selectors remain
183
- intact. `config/generate-theme.cjs` extracts only colour/font declarations and
184
- adds scope specificity. Run `node config/generate-theme.cjs` after an Inovua
185
- upgrade and inspect selector changes. Run `yarn check:theme` to audit upstream
186
- colour coverage, token defaults/documentation and commented important rules.
187
- `config/theme-extras.css` handles surfaces
188
- without upstream colour declarations. The only colour-related upstream
189
- `!important` rules are footer cell border colour and first-row cell top border;
190
- our matching overrides explain each use. Native scrollbar presentation remains
191
- subject to browser/OS support.
192
-
193
- ### Styling dependencies
194
-
195
- `@azrico/controls` 1.6.1 provides the context menu. MUI's default styled engine
196
- uses `@emotion/react` and `@emotion/styled` for those components; the grid does
197
- not use Emotion to implement its CSS variable theme. Removing Emotion requires
198
- replacing the MUI menu or configuring another supported MUI styling engine.
136
+
137
+ ```css
138
+ .deco-grid {
139
+ --azgrid-bg: #0A0A0A;
140
+ --azgrid-fg: #eee7d6;
141
+ --azgrid-border: #6b5824;
142
+ --azgrid-accent: #D4AF37;
143
+ --azgrid-radius: 0;
144
+ --azgrid-header-bg: var(--azgrid-bg);
145
+ --azgrid-header-fg: var(--azgrid-accent);
146
+ --azgrid-header-text-transform: uppercase;
147
+ --azgrid-header-letter-spacing: .1em;
148
+ --azgrid-header-font-weight: 600;
149
+ --azgrid-cell-border: var(--azgrid-border);
150
+ --azgrid-cell-border-width: 1px;
151
+ --azgrid-row-bg-odd: #12110e;
152
+ --azgrid-row-bg-hover: #282211;
153
+ --azgrid-row-bg-selected: #423619;
154
+ --azgrid-row-bg-active: #332a15;
155
+ --azgrid-scrollbar-track: var(--azgrid-bg);
156
+ --azgrid-scrollbar-thumb: var(--azgrid-border);
157
+ --azgrid-loading-bg: rgba(10, 10, 10, .85);
158
+ }
159
+ ```
160
+
161
+ See [src/example.tsx](src/example.tsx) for light, dark and a complete custom `deco` palette.
162
+
163
+ Custom renderers must style their own content. External menu portal containers need
164
+ `azgrid-scope`, the matching `azgrid-theme-<name>` class and the host variables.
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
- export * from './src';
2
- import { AzGrid } from './src';
1
+ export * from './src/views/DataGrid';
2
+ export * from './src/types/types';
3
+ export { get_row_id, set_row_id, get_col_name, get_col_header } from './src/func/func_grid';
4
+ import { AzGrid } from './src/views/DataGrid';
3
5
  export default AzGrid;
package/dist/index.js CHANGED
@@ -3,18 +3,60 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _exportNames = {};
6
+ var _exportNames = {
7
+ get_row_id: true,
8
+ set_row_id: true,
9
+ get_col_name: true,
10
+ get_col_header: true
11
+ };
7
12
  exports.default = void 0;
8
- var _src = require("./src");
9
- Object.keys(_src).forEach(function (key) {
13
+ Object.defineProperty(exports, "get_col_header", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _func_grid.get_col_header;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "get_col_name", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _func_grid.get_col_name;
23
+ }
24
+ });
25
+ Object.defineProperty(exports, "get_row_id", {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _func_grid.get_row_id;
29
+ }
30
+ });
31
+ Object.defineProperty(exports, "set_row_id", {
32
+ enumerable: true,
33
+ get: function () {
34
+ return _func_grid.set_row_id;
35
+ }
36
+ });
37
+ var _DataGrid = require("./src/views/DataGrid");
38
+ Object.keys(_DataGrid).forEach(function (key) {
39
+ if (key === "default" || key === "__esModule") return;
40
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
41
+ if (key in exports && exports[key] === _DataGrid[key]) return;
42
+ Object.defineProperty(exports, key, {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _DataGrid[key];
46
+ }
47
+ });
48
+ });
49
+ var _types = require("./src/types/types");
50
+ Object.keys(_types).forEach(function (key) {
10
51
  if (key === "default" || key === "__esModule") return;
11
52
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
12
- if (key in exports && exports[key] === _src[key]) return;
53
+ if (key in exports && exports[key] === _types[key]) return;
13
54
  Object.defineProperty(exports, key, {
14
55
  enumerable: true,
15
56
  get: function () {
16
- return _src[key];
57
+ return _types[key];
17
58
  }
18
59
  });
19
60
  });
20
- var _default = exports.default = _src.AzGrid;
61
+ var _func_grid = require("./src/func/func_grid");
62
+ var _default = exports.default = _DataGrid.AzGrid;
@@ -39,7 +39,8 @@ const columns = [{
39
39
  name: 'age',
40
40
  title: 'Age',
41
41
  type: 'number',
42
- defaultFlex: 1
42
+ defaultFlex: 1,
43
+ ariaLabel: value => `${value} years`
43
44
  }];
44
45
  const editableColumns = ['job', 'age'];
45
46
  function getData(delta, max = 200) {
@@ -157,6 +158,7 @@ function ExampleGrid() {
157
158
  }
158
159
  }, _react.default.createElement("h3", null, theme === 'deco' ? 'Art Deco (host variables)' : `Default ${theme}`), _react.default.createElement(_DataGrid.default, {
159
160
  theme: theme,
161
+ ariaLabel: `Users (${theme})`,
160
162
  delayedSize: true,
161
163
  // details_dataSource={details_dataSource}
162
164
  dataSource: dataSource,
@@ -185,7 +187,11 @@ function ExampleGrid() {
185
187
  defaultLimit: 10,
186
188
  pageSizes: [10, 25, 50],
187
189
  checkboxColumn: true,
188
- multiSelect: true
190
+ multiSelect: true,
191
+ // consumer onRenderRow runs after the internal one
192
+ onRenderRow: rowProps => {
193
+ rowProps['data-example-row'] = 'true';
194
+ }
189
195
  // defaultFilterValue: filterValue,
190
196
  // remoteFilter: false,
191
197
  // multiSelect: true,
@@ -0,0 +1,52 @@
1
+ import { GridType } from '../types/types';
2
+ export type ColumnA11yOptions = {
3
+ /** role of body cells, e.g. 'gridcell' or 'rowheader' */
4
+ role?: string;
5
+ /** grid level editable flag, columns are readonly when the grid isn't editable */
6
+ gridEditable?: boolean;
7
+ /** false skips aria-readonly (for interactive special columns like the checkbox column) */
8
+ markReadonly?: boolean;
9
+ };
10
+ /**
11
+ * wraps column dom props to add ARIA attributes,
12
+ * consumer's cellDOMProps/headerDOMProps run first and win over ours
13
+ * @param col
14
+ * @param options
15
+ * @returns a new column object
16
+ */
17
+ export declare function apply_column_a11y<T extends Record<string, any>>(col: T, options?: ColumnA11yOptions): T;
18
+ /**
19
+ * adds ARIA attributes to a row, called from onRenderRow
20
+ * @param rowProps
21
+ * @param selectionEnabled
22
+ */
23
+ export declare function apply_row_a11y(rowProps: any, selectionEnabled: boolean): void;
24
+ /**
25
+ * total number of data rows, uses the datasource count when paginated
26
+ * so the real size is reported, not just the visible page
27
+ * @param grid
28
+ */
29
+ export declare function get_grid_row_count(grid: GridType): number;
30
+ export type RootA11yOptions = {
31
+ ariaLabel?: string;
32
+ editable?: boolean;
33
+ };
34
+ /**
35
+ * root element of the grid, null when it isn't mounted
36
+ * @param grid computed props of the grid
37
+ */
38
+ export declare function get_grid_root(grid: GridType | null | undefined): Element | null;
39
+ /**
40
+ * key of the values apply_root_a11y writes, used to skip applying when nothing changed
41
+ * @param grid computed props of the grid
42
+ * @param options
43
+ */
44
+ export declare function get_root_a11y_key(grid: GridType | null | undefined, options: RootA11yOptions): string;
45
+ /**
46
+ * sets ARIA attributes on the grid root element
47
+ * inovua doesn't forward props to its root, so this is applied on the DOM node
48
+ * @param grid computed props of the grid
49
+ * @param options
50
+ * @returns the element the attributes were applied to, null when the grid isn't mounted
51
+ */
52
+ export declare function apply_root_a11y(grid: GridType | null | undefined, options: RootA11yOptions): Element | null;
@@ -0,0 +1,139 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.apply_column_a11y = apply_column_a11y;
7
+ exports.apply_root_a11y = apply_root_a11y;
8
+ exports.apply_row_a11y = apply_row_a11y;
9
+ exports.get_grid_root = get_grid_root;
10
+ exports.get_grid_row_count = get_grid_row_count;
11
+ exports.get_root_a11y_key = get_root_a11y_key;
12
+ function set_default(target, key, value) {
13
+ if (target[key] === undefined && value !== undefined && value !== null) target[key] = value;
14
+ }
15
+ function resolve_dom_props(src, cellProps) {
16
+ const res = typeof src === 'function' ? src(cellProps) : src;
17
+ return res ? {
18
+ ...res
19
+ } : {};
20
+ }
21
+ function get_sort_dir(sortInfo) {
22
+ if (!sortInfo || !sortInfo.dir) return 'none';
23
+ return sortInfo.dir > 0 ? 'ascending' : 'descending';
24
+ }
25
+ function is_cell_readonly(cellProps, gridEditable) {
26
+ if (!gridEditable) return true;
27
+ const editable = cellProps.computedEditable;
28
+ //function editables are decided per edit, we can't know it here
29
+ if (typeof editable === 'function') return false;
30
+ return !editable;
31
+ }
32
+ /**
33
+ * wraps column dom props to add ARIA attributes,
34
+ * consumer's cellDOMProps/headerDOMProps run first and win over ours
35
+ * @param col
36
+ * @param options
37
+ * @returns a new column object
38
+ */
39
+ function apply_column_a11y(col, options = {}) {
40
+ const {
41
+ role = 'gridcell',
42
+ gridEditable = false,
43
+ markReadonly = true
44
+ } = options;
45
+ const consumerCellDOMProps = col.cellDOMProps;
46
+ const consumerHeaderDOMProps = col.headerDOMProps;
47
+ const ariaLabel = col.ariaLabel;
48
+ return {
49
+ ...col,
50
+ cellDOMProps: cellProps => {
51
+ const res = resolve_dom_props(consumerCellDOMProps, cellProps);
52
+ set_default(res, 'role', role);
53
+ set_default(res, 'aria-colindex', cellProps.computedVisibleIndex + 1);
54
+ set_default(res, 'data-column', cellProps.name || cellProps.id);
55
+ if (markReadonly && is_cell_readonly(cellProps, gridEditable)) set_default(res, 'aria-readonly', 'true');
56
+ const data = cellProps.data;
57
+ if (typeof ariaLabel === 'function' && data && !data.__group && !data.__summary) set_default(res, 'aria-label', ariaLabel(cellProps.value, data));
58
+ return res;
59
+ },
60
+ headerDOMProps: cellProps => {
61
+ const res = resolve_dom_props(consumerHeaderDOMProps, cellProps);
62
+ set_default(res, 'role', 'columnheader');
63
+ set_default(res, 'aria-colindex', cellProps.computedVisibleIndex + 1);
64
+ if (cellProps.computedSortable) set_default(res, 'aria-sort', get_sort_dir(cellProps.computedSortInfo));
65
+ return res;
66
+ }
67
+ };
68
+ }
69
+ /**
70
+ * adds ARIA attributes to a row, called from onRenderRow
71
+ * @param rowProps
72
+ * @param selectionEnabled
73
+ */
74
+ function apply_row_a11y(rowProps, selectionEnabled) {
75
+ var _ref, _rowProps$remoteRowIn;
76
+ //filler rows (showEmptyRows) are not data rows
77
+ if (rowProps.empty) return;
78
+ const index = (_ref = (_rowProps$remoteRowIn = rowProps.remoteRowIndex) !== null && _rowProps$remoteRowIn !== void 0 ? _rowProps$remoteRowIn : rowProps.realIndex) !== null && _ref !== void 0 ? _ref : 0;
79
+ rowProps['role'] = 'row';
80
+ rowProps['aria-rowindex'] = index + 2; // 1-based, header row is 1
81
+ if (selectionEnabled) rowProps['aria-selected'] = rowProps.selected ? 'true' : 'false';
82
+ }
83
+ function set_attr(el, key, value) {
84
+ if (value === undefined || value === null || value === '') {
85
+ if (el.hasAttribute(key)) el.removeAttribute(key);
86
+ return;
87
+ }
88
+ const str = String(value);
89
+ if (el.getAttribute(key) !== str) el.setAttribute(key, str);
90
+ }
91
+ /**
92
+ * total number of data rows, uses the datasource count when paginated
93
+ * so the real size is reported, not just the visible page
94
+ * @param grid
95
+ */
96
+ function get_grid_row_count(grid) {
97
+ const g = grid;
98
+ const rendered = Array.isArray(g.data) ? g.data.length : 0;
99
+ if (!g.computedPagination) return rendered;
100
+ const offset = g.computedLivePagination ? 0 : g.computedSkip || 0;
101
+ return Math.max(g.paginationCount || 0, offset + rendered);
102
+ }
103
+ /**
104
+ * root element of the grid, null when it isn't mounted
105
+ * @param grid computed props of the grid
106
+ */
107
+ function get_grid_root(grid) {
108
+ var _grid$getDOMNode;
109
+ return (grid === null || grid === void 0 || (_grid$getDOMNode = grid.getDOMNode) === null || _grid$getDOMNode === void 0 ? void 0 : _grid$getDOMNode.call(grid)) || null;
110
+ }
111
+ /**
112
+ * key of the values apply_root_a11y writes, used to skip applying when nothing changed
113
+ * @param grid computed props of the grid
114
+ * @param options
115
+ */
116
+ function get_root_a11y_key(grid, options) {
117
+ var _options$ariaLabel;
118
+ const g = grid;
119
+ if (!g) return '';
120
+ return [get_grid_row_count(g), (g.visibleColumns || []).length, (_options$ariaLabel = options.ariaLabel) !== null && _options$ariaLabel !== void 0 ? _options$ariaLabel : '', options.editable ? 1 : 0].join('|');
121
+ }
122
+ /**
123
+ * sets ARIA attributes on the grid root element
124
+ * inovua doesn't forward props to its root, so this is applied on the DOM node
125
+ * @param grid computed props of the grid
126
+ * @param options
127
+ * @returns the element the attributes were applied to, null when the grid isn't mounted
128
+ */
129
+ function apply_root_a11y(grid, options) {
130
+ const g = grid;
131
+ const el = get_grid_root(g);
132
+ if (!el) return null;
133
+ set_attr(el, 'role', 'grid');
134
+ set_attr(el, 'aria-rowcount', get_grid_row_count(g) + 1);
135
+ set_attr(el, 'aria-colcount', (g.visibleColumns || []).length);
136
+ set_attr(el, 'aria-label', options.ariaLabel);
137
+ set_attr(el, 'aria-readonly', options.editable ? undefined : 'true');
138
+ return el;
139
+ }