@arbor-education/design-system.components 0.17.1 → 0.19.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 (57) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/components/combobox/useComboboxListboxKeyboard.d.ts.map +1 -1
  3. package/dist/components/combobox/useComboboxListboxKeyboard.js +2 -0
  4. package/dist/components/combobox/useComboboxListboxKeyboard.js.map +1 -1
  5. package/dist/components/combobox/useComboboxListboxKeyboard.test.js +1 -0
  6. package/dist/components/combobox/useComboboxListboxKeyboard.test.js.map +1 -1
  7. package/dist/components/table/Table.d.ts +11 -1
  8. package/dist/components/table/Table.d.ts.map +1 -1
  9. package/dist/components/table/Table.js +3 -0
  10. package/dist/components/table/Table.js.map +1 -1
  11. package/dist/components/table/Table.stories.d.ts +2 -0
  12. package/dist/components/table/Table.stories.d.ts.map +1 -1
  13. package/dist/components/table/Table.stories.js +148 -2
  14. package/dist/components/table/Table.stories.js.map +1 -1
  15. package/dist/components/table/cellRenderers/ComboboxCellRenderer.d.ts +13 -0
  16. package/dist/components/table/cellRenderers/ComboboxCellRenderer.d.ts.map +1 -0
  17. package/dist/components/table/cellRenderers/ComboboxCellRenderer.js +72 -0
  18. package/dist/components/table/cellRenderers/ComboboxCellRenderer.js.map +1 -0
  19. package/dist/components/table/cellRenderers/ComboboxCellRenderer.test.d.ts +2 -0
  20. package/dist/components/table/cellRenderers/ComboboxCellRenderer.test.d.ts.map +1 -0
  21. package/dist/components/table/cellRenderers/ComboboxCellRenderer.test.js +324 -0
  22. package/dist/components/table/cellRenderers/ComboboxCellRenderer.test.js.map +1 -0
  23. package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.d.ts +4 -1
  24. package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.d.ts.map +1 -1
  25. package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.js +13 -2
  26. package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.js.map +1 -1
  27. package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.stories.d.ts +31 -1
  28. package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.stories.d.ts.map +1 -1
  29. package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.stories.js +83 -0
  30. package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.stories.js.map +1 -1
  31. package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.test.d.ts +2 -0
  32. package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.test.d.ts.map +1 -0
  33. package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.test.js +84 -0
  34. package/dist/components/table/cellRenderers/SelectDropdownCellRenderer.test.js.map +1 -0
  35. package/dist/index.css +23 -0
  36. package/dist/index.css.map +1 -1
  37. package/dist/utils/getTextContrast.d.ts +4 -0
  38. package/dist/utils/getTextContrast.d.ts.map +1 -0
  39. package/dist/utils/getTextContrast.js +14 -0
  40. package/dist/utils/getTextContrast.js.map +1 -0
  41. package/dist/utils/getTextContrast.test.d.ts +2 -0
  42. package/dist/utils/getTextContrast.test.d.ts.map +1 -0
  43. package/dist/utils/getTextContrast.test.js +68 -0
  44. package/dist/utils/getTextContrast.test.js.map +1 -0
  45. package/package.json +1 -1
  46. package/src/components/combobox/useComboboxListboxKeyboard.test.tsx +1 -0
  47. package/src/components/combobox/useComboboxListboxKeyboard.ts +2 -0
  48. package/src/components/table/Table.stories.tsx +180 -2
  49. package/src/components/table/Table.tsx +3 -0
  50. package/src/components/table/cellRenderers/ComboboxCellRenderer.test.tsx +437 -0
  51. package/src/components/table/cellRenderers/ComboboxCellRenderer.tsx +135 -0
  52. package/src/components/table/cellRenderers/SelectDropdownCellRenderer.stories.tsx +139 -0
  53. package/src/components/table/cellRenderers/SelectDropdownCellRenderer.test.tsx +118 -0
  54. package/src/components/table/cellRenderers/SelectDropdownCellRenderer.tsx +22 -2
  55. package/src/components/table/table.scss +31 -0
  56. package/src/utils/getTextContrast.test.ts +82 -0
  57. package/src/utils/getTextContrast.ts +14 -0
@@ -0,0 +1,72 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useRef } from 'react';
3
+ import { Combobox } from '../../combobox/Combobox';
4
+ import { useComponentDidMount } from '../../../utils/hooks/useComponentDidMount';
5
+ export const ComboboxCellRenderer = (props) => {
6
+ const { value, node, column, api, options = [], multiple = false, placeholder, triggerVariant, disabled, hasError, searchType, highlightStringMatches, loading, onSearch, id, 'aria-describedby': ariaDescribedBy, 'aria-invalid': ariaInvalid, 'aria-label': ariaLabel, } = props;
7
+ const containerRef = useRef(null);
8
+ const normalizedValue = Array.isArray(value)
9
+ ? value.map(String)
10
+ : value != null && value !== ''
11
+ ? [String(value)]
12
+ : [];
13
+ useComponentDidMount(() => {
14
+ // open the combobox when the user presses Enter on the ag-grid cell
15
+ const handleCellKeyDown = (event) => {
16
+ const { key } = event.event;
17
+ if ('column' in event
18
+ && event.node === node
19
+ && event.column === column
20
+ && key === 'Enter') {
21
+ const trigger = containerRef.current?.querySelector('[role="combobox"], [role="button"][aria-haspopup="listbox"]');
22
+ if (!trigger)
23
+ return;
24
+ trigger.focus();
25
+ // button-style triggers (single-select) need an explicit click to open the popover
26
+ if (trigger.getAttribute('role') === 'button') {
27
+ trigger.click();
28
+ }
29
+ }
30
+ };
31
+ api.addEventListener('cellKeyDown', handleCellKeyDown);
32
+ // restore ag-grid cell focus when popover closes without focus leaving the cell
33
+ const container = containerRef.current;
34
+ let observer;
35
+ if (container) {
36
+ const trigger = container.querySelector('[role="combobox"], [role="button"][aria-haspopup="listbox"]');
37
+ if (trigger) {
38
+ observer = new MutationObserver(() => {
39
+ const isOpen = trigger.getAttribute('aria-expanded') === 'true';
40
+ if (isOpen || column == null || node.rowIndex == null)
41
+ return;
42
+ const active = document.activeElement;
43
+ const focusIsStillInCell = active == null || active === document.body || container.contains(active);
44
+ if (focusIsStillInCell) {
45
+ api.setFocusedCell(node.rowIndex, column);
46
+ }
47
+ });
48
+ observer.observe(trigger, { attributes: true, attributeFilter: ['aria-expanded'] });
49
+ }
50
+ }
51
+ return () => {
52
+ api.removeEventListener('cellKeyDown', handleCellKeyDown);
53
+ observer?.disconnect();
54
+ };
55
+ });
56
+ return (_jsx("div", { ref: containerRef, className: "ds-table__combobox", children: _jsx(Combobox, { options: options, value: normalizedValue, multiple: multiple, placeholder: placeholder, triggerVariant: triggerVariant, disabled: disabled, hasError: hasError, searchType: searchType, highlightStringMatches: highlightStringMatches, loading: loading, onSearch: onSearch, id: id, "aria-describedby": ariaDescribedBy, "aria-invalid": ariaInvalid, "aria-label": ariaLabel, onValueChange: (newValues) => {
57
+ if (column) {
58
+ node.setDataValue(column, multiple ? newValues : (newValues[0] ?? null));
59
+ }
60
+ } }) }));
61
+ };
62
+ ComboboxCellRenderer.colDefDefaults = {
63
+ autoHeight: true,
64
+ suppressKeyboardEvent: (params) => {
65
+ const cell = params.event.target?.closest('.ag-cell');
66
+ if (!cell)
67
+ return false;
68
+ const openTrigger = cell.querySelector('[role="combobox"][aria-expanded="true"], [role="button"][aria-expanded="true"]');
69
+ return !!openTrigger && ['ArrowUp', 'ArrowDown', 'Enter', 'Escape'].includes(params.event.key);
70
+ },
71
+ };
72
+ //# sourceMappingURL=ComboboxCellRenderer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComboboxCellRenderer.js","sourceRoot":"","sources":["../../../../src/components/table/cellRenderers/ComboboxCellRenderer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAO/B,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAExD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAIxE,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAgC,EAAE,EAAE;IACvE,MAAM,EACJ,KAAK,EACL,IAAI,EACJ,MAAM,EACN,GAAG,EACH,OAAO,GAAG,EAAE,EACZ,QAAQ,GAAG,KAAK,EAChB,WAAW,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AAW,EACxB,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAE,UAAU,EACtB,sBAAsB,EAAE,sBAAsB,EAC9C,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,EAAE,sBACY,eAAe,kBACnB,WAAW,gBACb,SAAS,EACrB,aAAa,EAAE,CAAC,SAAS,EAAE,EAAE;gBAC3B,IAAI,MAAM,EAAE,CAAC;oBACX,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC;gBAC3E,CAAC;YACH,CAAC,GACD,GACE,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,oBAAoB,CAAC,cAAc,GAAG;IACpC,UAAU,EAAE,IAAI;IAChB,qBAAqB,EAAE,CAAC,MAAmC,EAAE,EAAE;QAC7D,MAAM,IAAI,GAAI,MAAM,CAAC,KAAK,CAAC,MAAsB,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;QACvE,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAC;QACxB,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CACpC,gFAAgF,CACjF,CAAC;QACF,OAAO,CAAC,CAAC,WAAW,IAAI,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjG,CAAC;CACF,CAAC"}
@@ -0,0 +1,2 @@
1
+ import '@testing-library/jest-dom/vitest';
2
+ //# sourceMappingURL=ComboboxCellRenderer.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComboboxCellRenderer.test.d.ts","sourceRoot":"","sources":["../../../../src/components/table/cellRenderers/ComboboxCellRenderer.test.tsx"],"names":[],"mappings":"AAEA,OAAO,kCAAkC,CAAC"}
@@ -0,0 +1,324 @@
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { describe, expect, test, vi, afterEach } from 'vitest';
3
+ import { render, screen } from '@testing-library/react';
4
+ import '@testing-library/jest-dom/vitest';
5
+ import userEvent from '@testing-library/user-event';
6
+ import { ComboboxCellRenderer } from './ComboboxCellRenderer';
7
+ const options = [
8
+ { value: 'opt1', label: 'Option 1' },
9
+ { value: 'opt2', label: 'Option 2' },
10
+ { value: 'opt3', label: 'Option 3' },
11
+ ];
12
+ const createMockProps = (overrides = {}) => ({
13
+ value: null,
14
+ node: { setDataValue: vi.fn() },
15
+ column: 'testField',
16
+ api: {
17
+ addEventListener: vi.fn(),
18
+ removeEventListener: vi.fn(),
19
+ },
20
+ options,
21
+ ...overrides,
22
+ });
23
+ describe('ComboboxCellRenderer', () => {
24
+ test('renders a combobox input', () => {
25
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps() }));
26
+ expect(screen.getByRole('combobox')).toBeInTheDocument();
27
+ });
28
+ test('renders with placeholder', () => {
29
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps({ placeholder: 'Choose an option' }) }));
30
+ expect(screen.getByPlaceholderText('Choose an option')).toBeInTheDocument();
31
+ });
32
+ test('renders with default placeholder when none provided', () => {
33
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps() }));
34
+ expect(screen.getByPlaceholderText('Select...')).toBeInTheDocument();
35
+ });
36
+ test('opens listbox and shows options on input focus', async () => {
37
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps() }));
38
+ await userEvent.click(screen.getByRole('combobox'));
39
+ expect(screen.getByRole('listbox')).toBeInTheDocument();
40
+ expect(screen.getByText('Option 1')).toBeInTheDocument();
41
+ });
42
+ test('calls setDataValue with the selected value for single select', async () => {
43
+ const setDataValue = vi.fn();
44
+ const props = createMockProps({
45
+ node: { setDataValue },
46
+ column: 'testField',
47
+ });
48
+ render(_jsx(ComboboxCellRenderer, { ...props }));
49
+ await userEvent.click(screen.getByRole('combobox'));
50
+ await userEvent.click(screen.getByText('Option 1'));
51
+ expect(setDataValue).toHaveBeenCalledWith('testField', 'opt1');
52
+ });
53
+ test('calls setDataValue with array for multiple select', async () => {
54
+ const setDataValue = vi.fn();
55
+ const props = createMockProps({
56
+ multiple: true,
57
+ node: { setDataValue },
58
+ column: 'testField',
59
+ });
60
+ render(_jsx(ComboboxCellRenderer, { ...props }));
61
+ await userEvent.click(screen.getByRole('combobox'));
62
+ await userEvent.click(screen.getByText('Option 1'));
63
+ expect(setDataValue).toHaveBeenCalledWith('testField', ['opt1']);
64
+ });
65
+ test('does not call setDataValue when column is undefined', async () => {
66
+ const setDataValue = vi.fn();
67
+ const props = createMockProps({
68
+ node: { setDataValue },
69
+ column: undefined,
70
+ });
71
+ render(_jsx(ComboboxCellRenderer, { ...props }));
72
+ await userEvent.click(screen.getByRole('combobox'));
73
+ await userEvent.click(screen.getByText('Option 1'));
74
+ expect(setDataValue).not.toHaveBeenCalled();
75
+ });
76
+ test('normalizes a string cell value to an array for controlled combobox', () => {
77
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps({ value: 'opt1' }) }));
78
+ const input = screen.getByRole('combobox');
79
+ expect(input).toBeInTheDocument();
80
+ });
81
+ test('normalizes a string[] cell value to an array for controlled combobox', () => {
82
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps({ value: ['opt1', 'opt2'], multiple: true }) }));
83
+ expect(screen.getByRole('combobox')).toBeInTheDocument();
84
+ });
85
+ test('registers cellKeyDown listener on mount', () => {
86
+ const addEventListener = vi.fn();
87
+ const removeEventListener = vi.fn();
88
+ const props = createMockProps({
89
+ api: { addEventListener, removeEventListener },
90
+ });
91
+ render(_jsx(ComboboxCellRenderer, { ...props }));
92
+ expect(addEventListener).toHaveBeenCalledWith('cellKeyDown', expect.any(Function));
93
+ });
94
+ describe('value normalization edge cases', () => {
95
+ test('treats empty string value as no selection', () => {
96
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps({ value: '' }) }));
97
+ expect(screen.getByPlaceholderText('Select...')).toBeInTheDocument();
98
+ });
99
+ test('normalizes a numeric cell value to a string', () => {
100
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps({ value: 42 }) }));
101
+ expect(screen.getByRole('combobox')).toBeInTheDocument();
102
+ });
103
+ test('normalizes a numeric array cell value to strings', () => {
104
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps({ value: [1, 2], multiple: true }) }));
105
+ expect(screen.getByRole('combobox')).toBeInTheDocument();
106
+ });
107
+ });
108
+ describe('cellKeyDown handler', () => {
109
+ test('removes the cellKeyDown listener on unmount', () => {
110
+ const addEventListener = vi.fn();
111
+ const removeEventListener = vi.fn();
112
+ const { unmount } = render(_jsx(ComboboxCellRenderer, { ...createMockProps({
113
+ api: { addEventListener, removeEventListener },
114
+ }) }));
115
+ const listener = addEventListener.mock.calls[0][1];
116
+ unmount();
117
+ expect(removeEventListener).toHaveBeenCalledWith('cellKeyDown', listener);
118
+ });
119
+ test('focuses the combobox trigger on Enter for matching node and column', () => {
120
+ const addEventListener = vi.fn();
121
+ const mockNode = { setDataValue: vi.fn() };
122
+ const mockColumn = 'testField';
123
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps({
124
+ node: mockNode,
125
+ column: mockColumn,
126
+ api: { addEventListener, removeEventListener: vi.fn() },
127
+ }) }));
128
+ const trigger = screen.getByRole('combobox');
129
+ const focusSpy = vi.spyOn(trigger, 'focus');
130
+ const listener = addEventListener.mock.calls[0][1];
131
+ listener({ event: { key: 'Enter' }, node: mockNode, column: mockColumn });
132
+ expect(focusSpy).toHaveBeenCalled();
133
+ });
134
+ test('focuses and clicks the button trigger on Enter when triggerVariant is "button"', () => {
135
+ const addEventListener = vi.fn();
136
+ const mockNode = { setDataValue: vi.fn() };
137
+ const mockColumn = 'testField';
138
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps({
139
+ 'node': mockNode,
140
+ 'column': mockColumn,
141
+ 'api': { addEventListener, removeEventListener: vi.fn() },
142
+ 'triggerVariant': 'button',
143
+ 'aria-label': 'Choose option',
144
+ }) }));
145
+ const button = screen.getByRole('button', { name: 'Choose option' });
146
+ const focusSpy = vi.spyOn(button, 'focus');
147
+ const clickSpy = vi.spyOn(button, 'click');
148
+ const listener = addEventListener.mock.calls[0][1];
149
+ listener({ event: { key: 'Enter' }, node: mockNode, column: mockColumn });
150
+ expect(focusSpy).toHaveBeenCalled();
151
+ expect(clickSpy).toHaveBeenCalled();
152
+ });
153
+ test('does not focus trigger when the event node does not match', () => {
154
+ const addEventListener = vi.fn();
155
+ const mockNode = { setDataValue: vi.fn() };
156
+ const differentNode = { setDataValue: vi.fn() };
157
+ const mockColumn = 'testField';
158
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps({
159
+ node: mockNode,
160
+ column: mockColumn,
161
+ api: { addEventListener, removeEventListener: vi.fn() },
162
+ }) }));
163
+ const trigger = screen.getByRole('combobox');
164
+ const focusSpy = vi.spyOn(trigger, 'focus');
165
+ const listener = addEventListener.mock.calls[0][1];
166
+ listener({ event: { key: 'Enter' }, node: differentNode, column: mockColumn });
167
+ expect(focusSpy).not.toHaveBeenCalled();
168
+ });
169
+ test('does not focus trigger when the event column does not match', () => {
170
+ const addEventListener = vi.fn();
171
+ const mockNode = { setDataValue: vi.fn() };
172
+ const mockColumn = 'testField';
173
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps({
174
+ node: mockNode,
175
+ column: mockColumn,
176
+ api: { addEventListener, removeEventListener: vi.fn() },
177
+ }) }));
178
+ const trigger = screen.getByRole('combobox');
179
+ const focusSpy = vi.spyOn(trigger, 'focus');
180
+ const listener = addEventListener.mock.calls[0][1];
181
+ listener({ event: { key: 'Enter' }, node: mockNode, column: 'differentField' });
182
+ expect(focusSpy).not.toHaveBeenCalled();
183
+ });
184
+ test('does not focus trigger for non-Enter keys', () => {
185
+ const addEventListener = vi.fn();
186
+ const mockNode = { setDataValue: vi.fn() };
187
+ const mockColumn = 'testField';
188
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps({
189
+ node: mockNode,
190
+ column: mockColumn,
191
+ api: { addEventListener, removeEventListener: vi.fn() },
192
+ }) }));
193
+ const trigger = screen.getByRole('combobox');
194
+ const focusSpy = vi.spyOn(trigger, 'focus');
195
+ const listener = addEventListener.mock.calls[0][1];
196
+ listener({ event: { key: 'ArrowDown' }, node: mockNode, column: mockColumn });
197
+ expect(focusSpy).not.toHaveBeenCalled();
198
+ });
199
+ test('does not focus trigger for a FullWidthCellKeyDownEvent (no column property)', () => {
200
+ const addEventListener = vi.fn();
201
+ const mockNode = { setDataValue: vi.fn() };
202
+ const mockColumn = 'testField';
203
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps({
204
+ node: mockNode,
205
+ column: mockColumn,
206
+ api: { addEventListener, removeEventListener: vi.fn() },
207
+ }) }));
208
+ const trigger = screen.getByRole('combobox');
209
+ const focusSpy = vi.spyOn(trigger, 'focus');
210
+ const listener = addEventListener.mock.calls[0][1];
211
+ listener({ event: { key: 'Enter' }, node: mockNode });
212
+ expect(focusSpy).not.toHaveBeenCalled();
213
+ });
214
+ });
215
+ describe('focus restoration via MutationObserver', () => {
216
+ test('calls setFocusedCell when popover closes without focus leaving the cell', async () => {
217
+ const setFocusedCell = vi.fn();
218
+ const mockNode = { setDataValue: vi.fn(), rowIndex: 5 };
219
+ const mockColumn = 'testField';
220
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps({
221
+ node: mockNode,
222
+ column: mockColumn,
223
+ api: {
224
+ addEventListener: vi.fn(),
225
+ removeEventListener: vi.fn(),
226
+ setFocusedCell,
227
+ },
228
+ }) }));
229
+ await userEvent.click(screen.getByRole('combobox'));
230
+ await userEvent.keyboard('{Escape}');
231
+ expect(setFocusedCell).toHaveBeenCalledWith(5, mockColumn);
232
+ });
233
+ test('does not call setFocusedCell when focus moves outside the cell', async () => {
234
+ const setFocusedCell = vi.fn();
235
+ const mockNode = { setDataValue: vi.fn(), rowIndex: 5 };
236
+ const mockColumn = 'testField';
237
+ render(_jsxs(_Fragment, { children: [_jsx(ComboboxCellRenderer, { ...createMockProps({
238
+ node: mockNode,
239
+ column: mockColumn,
240
+ api: {
241
+ addEventListener: vi.fn(),
242
+ removeEventListener: vi.fn(),
243
+ setFocusedCell,
244
+ },
245
+ }) }), _jsx("button", { children: "Outside" })] }));
246
+ await userEvent.click(screen.getByRole('combobox'));
247
+ await userEvent.click(screen.getByRole('button', { name: 'Outside' }));
248
+ expect(setFocusedCell).not.toHaveBeenCalled();
249
+ });
250
+ test('does not call setFocusedCell when node.rowIndex is null', async () => {
251
+ const setFocusedCell = vi.fn();
252
+ const mockNode = { setDataValue: vi.fn(), rowIndex: null };
253
+ const mockColumn = 'testField';
254
+ render(_jsx(ComboboxCellRenderer, { ...createMockProps({
255
+ node: mockNode,
256
+ column: mockColumn,
257
+ api: {
258
+ addEventListener: vi.fn(),
259
+ removeEventListener: vi.fn(),
260
+ setFocusedCell,
261
+ },
262
+ }) }));
263
+ await userEvent.click(screen.getByRole('combobox'));
264
+ await userEvent.keyboard('{Escape}');
265
+ expect(setFocusedCell).not.toHaveBeenCalled();
266
+ });
267
+ test('disconnects the MutationObserver on unmount', () => {
268
+ const disconnect = vi.fn();
269
+ vi.stubGlobal('MutationObserver', vi.fn(() => ({ observe: vi.fn(), disconnect })));
270
+ try {
271
+ const { unmount } = render(_jsx(ComboboxCellRenderer, { ...createMockProps() }));
272
+ unmount();
273
+ expect(disconnect).toHaveBeenCalled();
274
+ }
275
+ finally {
276
+ vi.unstubAllGlobals();
277
+ }
278
+ });
279
+ });
280
+ describe('colDefDefaults', () => {
281
+ test('autoHeight is true', () => {
282
+ expect(ComboboxCellRenderer.colDefDefaults.autoHeight).toBe(true);
283
+ });
284
+ describe('suppressKeyboardEvent', () => {
285
+ const { suppressKeyboardEvent } = ComboboxCellRenderer.colDefDefaults;
286
+ const appendCell = (key, open) => {
287
+ const cell = document.createElement('div');
288
+ cell.className = 'ag-cell';
289
+ const trigger = document.createElement('input');
290
+ trigger.setAttribute('role', 'combobox');
291
+ trigger.setAttribute('aria-expanded', open ? 'true' : 'false');
292
+ cell.appendChild(trigger);
293
+ document.body.appendChild(cell);
294
+ return {
295
+ params: { event: { key, target: trigger } },
296
+ cleanup: () => cell.remove(),
297
+ };
298
+ };
299
+ afterEach(() => {
300
+ document.querySelectorAll('.ag-cell').forEach(el => el.remove());
301
+ });
302
+ test('returns false when the event target has no ag-cell ancestor', () => {
303
+ const target = document.createElement('input');
304
+ document.body.appendChild(target);
305
+ const params = { event: { key: 'ArrowDown', target } };
306
+ expect(suppressKeyboardEvent(params)).toBe(false);
307
+ target.remove();
308
+ });
309
+ test('returns false when the combobox is closed', () => {
310
+ const { params } = appendCell('ArrowDown', false);
311
+ expect(suppressKeyboardEvent(params)).toBe(false);
312
+ });
313
+ test.each(['ArrowUp', 'ArrowDown', 'Enter', 'Escape'])('suppresses %s when the combobox is open', (key) => {
314
+ const { params } = appendCell(key, true);
315
+ expect(suppressKeyboardEvent(params)).toBe(true);
316
+ });
317
+ test('does not suppress Tab when the combobox is open', () => {
318
+ const { params } = appendCell('Tab', true);
319
+ expect(suppressKeyboardEvent(params)).toBe(false);
320
+ });
321
+ });
322
+ });
323
+ });
324
+ //# sourceMappingURL=ComboboxCellRenderer.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ComboboxCellRenderer.test.js","sourceRoot":"","sources":["../../../../src/components/table/cellRenderers/ComboboxCellRenderer.test.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAC/D,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,kCAAkC,CAAC;AAC1C,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAGpD,OAAO,EAAE,oBAAoB,EAA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AC;YACpD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,6 +1,9 @@
1
1
  import type { CustomCellRendererProps } from 'ag-grid-react';
2
2
  import { type SelectDropdownInputProps } from '../../formField/inputs/selectDropdown/SelectDropdown';
3
- type SelectDropdownCellRendererProps = CustomCellRendererProps & SelectDropdownInputProps;
3
+ type SelectDropdownCellRendererProps = CustomCellRendererProps & SelectDropdownInputProps & {
4
+ backgroundColor?: string;
5
+ fillCell?: boolean;
6
+ };
4
7
  export declare const SelectDropdownCellRenderer: (props: SelectDropdownCellRendererProps) => import("react/jsx-runtime").JSX.Element;
5
8
  export {};
6
9
  //# sourceMappingURL=SelectDropdownCellRenderer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectDropdownCellRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components/table/cellRenderers/SelectDropdownCellRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,2DAA2D,CAAC;AAGnE,KAAK,+BAA+B,GAAG,uBAAuB,GAC1D,wBAAwB,CAAC;AAS7B,eAAO,MAAM,0BAA0B,GACrC,OAAO,+BAA+B,4CA0EvC,CAAC"}
1
+ {"version":3,"file":"SelectDropdownCellRenderer.d.ts","sourceRoot":"","sources":["../../../../src/components/table/cellRenderers/SelectDropdownCellRenderer.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,2DAA2D,CAAC;AAInE,KAAK,+BAA+B,GAAG,uBAAuB,GAC1D,wBAAwB,GACxB;IACA,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AASJ,eAAO,MAAM,0BAA0B,GACrC,OAAO,+BAA+B,4CAwFvC,CAAC"}
@@ -1,9 +1,20 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
+ import classNames from 'classnames';
3
4
  import { SelectDropdown, } from '../../formField/inputs/selectDropdown/SelectDropdown';
4
5
  import { useComponentDidMount } from '../../../utils/hooks/useComponentDidMount';
6
+ import { getTextContrast } from '../../../utils/getTextContrast';
5
7
  export const SelectDropdownCellRenderer = (props) => {
6
- const { value, placeholder = 'Select', node, column, api, options = [], disabled, hasError, id, 'aria-describedBy': ariaDescribedBy, 'aria-invalid': ariaInvalid, alwaysShowPlaceholder = false, } = props;
8
+ const { value, placeholder = 'Select', node, column, api, options = [], disabled, hasError, id, 'aria-describedBy': ariaDescribedBy, 'aria-invalid': ariaInvalid, alwaysShowPlaceholder = false, backgroundColor, fillCell = false, } = props;
9
+ const textContrast = backgroundColor ? getTextContrast(backgroundColor) : null;
10
+ const wrapperClassName = classNames('ds-table__select-dropdown', {
11
+ 'ds-table__select-dropdown--custom-bg': backgroundColor,
12
+ 'ds-table__select-dropdown--fill-cell': fillCell,
13
+ [`ds-table__select-dropdown--text-${textContrast}`]: textContrast,
14
+ });
15
+ const wrapperStyle = backgroundColor
16
+ ? { ['--ds-select-cell-bg']: backgroundColor }
17
+ : undefined;
7
18
  const rawOptions = options;
8
19
  const normalisedOptions = rawOptions.map(option => ({
9
20
  ...option,
@@ -26,7 +37,7 @@ export const SelectDropdownCellRenderer = (props) => {
26
37
  api.removeEventListener('cellKeyDown', handleCellKeyDown);
27
38
  };
28
39
  });
29
- return (_jsx("div", { className: "ds-table__select-dropdown", children: _jsx(SelectDropdown, { disabled: disabled, hasError: hasError, id: id, "aria-describedBy": ariaDescribedBy, "aria-invalid": ariaInvalid, alwaysShowPlaceholder: alwaysShowPlaceholder, options: normalisedOptions, placeholder: placeholder, initialSelectedValues: initialSelectedValues, open: isOpen, onOpenChange: setIsOpen, multiple: false, onSelectionChange: (newValue) => {
40
+ return (_jsx("div", { className: wrapperClassName, style: wrapperStyle, children: _jsx(SelectDropdown, { disabled: disabled, hasError: hasError, id: id, "aria-describedBy": ariaDescribedBy, "aria-invalid": ariaInvalid, alwaysShowPlaceholder: alwaysShowPlaceholder, options: normalisedOptions, placeholder: placeholder, initialSelectedValues: initialSelectedValues, open: isOpen, onOpenChange: setIsOpen, multiple: false, onSelectionChange: (newValue) => {
30
41
  if (column && newValue[0] != null) {
31
42
  const selectedOption = rawOptions.find(option => String(option.value) === newValue[0]);
32
43
  node.setDataValue(column, selectedOption?.value ?? newValue[0]);
@@ -1 +1 @@
1
- {"version":3,"file":"SelectDropdownCellRenderer.js","sourceRoot":"","sources":["../../../../src/components/table/cellRenderers/SelectDropdownCellRenderer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAMjC,OAAO,EACL,cAAc,GAEf,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAYxE,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,KAAsC,EACtC,EAAE;IACF,MAAM,EACJ,KAAK,EACL,WAAW,GAAG,QAAQ,EACtB,IAAI,EACJ,MAAM,EACN,GAAG,EACH,OAAO,GAAG,EAAE,EACZ,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,kBAAkB,EAAE,eAAe,EACnC,cAAc,EAAE,WAAW,EAC3B,qBAAqB,GAAG,KAAK,GAC9B,GAAG,KAAK,CAAC;IAEV,MAAM,UAAU,GAAuC,OAAO,CAAC;IAC/D,MAAM,iBAAiB,GAAwC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACvF,GAAG,MAAM;QACT,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;KAC5B,CAAC,CAAC,CAAC;IAEJ,MAAM,QAAQ,GAAG,KAAK,IAAI,IAAI,IAA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AI,IAAI,EAAE,CAAC;oBAClC,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,CACpC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAC/C,CAAC;oBACF,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClE,CAAC;YACH,CAAC,GACD,GACE,CACP,CAAC;AACJ,CAAC,CAAC"}
1
+ {"version":3,"file":"SelectDropdownCellRenderer.js","sourceRoot":"","sources":["../../../../src/components/table/cellRenderers/SelectDropdownCellRenderer.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,UAAU,MAAM,YAAY,CAAC;AAMpC,OAAO,EACL,cAAc,GAEf,MAAM,2DAA2D,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAgBxD,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,KAAsC,EACtC,EAAE;IACF,MAAM,EACJ,KAAK,EACL,WAAW,GAAG,QAAQ,EACtB,IAAI,EACJ,MAAM,EACN,GAAG,EACH,OAAO,GAAG,EAAE,EACZ,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,kBAAkB,EAAE,eAAe,EACnC,cAAc,EAAE,WAAW,EAC3B,qBAAqB,GAAG,KAAK,EAC7B,eAAe,EACf,QAAQ,GAAG,KAAK,GACjB,GAAG,KAAK,CAAC;IAEV,MAAM,YAAY,GAAG,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAE/E,MAAM,gBAAgB,GAAG,UAAU,CAAC,2BAA2B,EAAE;QAC/D,sCAAsC,EAAE,eAAe;QACvD,sCAA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C;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,cAAK,SAAS,EAAE,gBAAgB,EAAE,KAAK,EAAE,YAAY,YACnD,KAAC,cAAc,IACb,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,EAAE,sBACY,eAAe,kBACnB,WAAW,EACzB,qBAAqB,EAAE,qBAAqB,EAC5C,OAAO,EAAE,iBAAiB,EAC1B,WAAW,EAAE,WAAW,EACxB,qBAAqB,EAAE,qBAAqB,EAC5C,IAAI,EAAE,MAAM,EACZ,YAAY,EAAE,SAAS,EACvB,QAAQ,EAAE,KAAK,EACf,iBAAiB,EAAE,CAAC,QAAQ,EAAE,EAAE;gBAC9B,IAAI,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;oBAClC,MAAM,cAAc,GAAG,UAAU,CAAC,IAAI,CACpC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAC/C,CAAC;oBACF,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;gBAClE,CAAC;YACH,CAAC,GACD,GACE,CACP,CAAC;AACJ,CAAC,CAAC"}
@@ -4,7 +4,10 @@ import { SelectDropdownCellRenderer } from './SelectDropdownCellRenderer';
4
4
  declare function SelectDropdownCellRendererDocsPage(): import("react/jsx-runtime").JSX.Element;
5
5
  declare const meta: {
6
6
  title: string;
7
- component: (props: CustomCellRendererProps<any, any, any> & import("../../formField/inputs/selectDropdown/SelectDropdown").SelectDropdownInputProps) => import("react/jsx-runtime").JSX.Element;
7
+ component: (props: CustomCellRendererProps<any, any, any> & import("../../formField/inputs/selectDropdown/SelectDropdown").SelectDropdownInputProps & {
8
+ backgroundColor?: string;
9
+ fillCell?: boolean;
10
+ }) => import("react/jsx-runtime").JSX.Element;
8
11
  tags: string[];
9
12
  parameters: {
10
13
  layout: string;
@@ -64,6 +67,30 @@ declare const meta: {
64
67
  };
65
68
  };
66
69
  };
70
+ backgroundColor: {
71
+ control: "color";
72
+ description: string;
73
+ table: {
74
+ type: {
75
+ summary: string;
76
+ };
77
+ defaultValue: {
78
+ summary: string;
79
+ };
80
+ };
81
+ };
82
+ fillCell: {
83
+ control: "boolean";
84
+ description: string;
85
+ table: {
86
+ type: {
87
+ summary: string;
88
+ };
89
+ defaultValue: {
90
+ summary: string;
91
+ };
92
+ };
93
+ };
67
94
  };
68
95
  };
69
96
  export default meta;
@@ -71,5 +98,8 @@ type Story = StoryObj<typeof SelectDropdownCellRenderer>;
71
98
  export declare const Default: Story;
72
99
  export declare const WithSelection: Story;
73
100
  export declare const Disabled: Story;
101
+ export declare const WithBackgroundColor: Story;
102
+ export declare const FillCell: Story;
74
103
  export declare const InATable: Story;
104
+ export declare const ColoredCellsInATable: Story;
75
105
  //# sourceMappingURL=SelectDropdownCellRenderer.stories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SelectDropdownCellRenderer.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/table/cellRenderers/SelectDropdownCellRenderer.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAW5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAiG1E,iBAAS,kCAAkC,4CAmB1C;AAmBD,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CyC,CAAC;AAEpD,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAkBzD,eAAO,MAAM,OAAO,EAAE,KAgBrB,CAAC;AAEF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