@arbor-education/design-system.components 0.1.5 → 0.2.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/.github/workflows/release.yml +1 -1
- package/CHANGELOG.md +12 -0
- package/dist/components/formField/fieldset/Fieldset.d.ts +6 -0
- package/dist/components/formField/fieldset/Fieldset.d.ts.map +1 -0
- package/dist/components/formField/fieldset/Fieldset.js +7 -0
- package/dist/components/formField/fieldset/Fieldset.js.map +1 -0
- package/dist/components/formField/fieldset/Fieldset.stories.d.ts +28 -0
- package/dist/components/formField/fieldset/Fieldset.stories.d.ts.map +1 -0
- package/dist/components/formField/fieldset/Fieldset.stories.js +51 -0
- package/dist/components/formField/fieldset/Fieldset.stories.js.map +1 -0
- package/dist/components/formField/fieldset/Fieldset.test.d.ts +2 -0
- package/dist/components/formField/fieldset/Fieldset.test.d.ts.map +1 -0
- package/dist/components/formField/fieldset/Fieldset.test.js +62 -0
- package/dist/components/formField/fieldset/Fieldset.test.js.map +1 -0
- package/dist/components/formField/inputs/checkbox/CheckboxGroup.d.ts +8 -0
- package/dist/components/formField/inputs/checkbox/CheckboxGroup.d.ts.map +1 -0
- package/dist/components/formField/inputs/checkbox/CheckboxGroup.js +8 -0
- package/dist/components/formField/inputs/checkbox/CheckboxGroup.js.map +1 -0
- package/dist/components/formField/inputs/checkbox/CheckboxGroup.test.d.ts +2 -0
- package/dist/components/formField/inputs/checkbox/CheckboxGroup.test.d.ts.map +1 -0
- package/dist/components/formField/inputs/checkbox/CheckboxGroup.test.js +86 -0
- package/dist/components/formField/inputs/checkbox/CheckboxGroup.test.js.map +1 -0
- package/dist/components/formField/inputs/checkbox/CheckboxInput.stories.d.ts +3 -1
- package/dist/components/formField/inputs/checkbox/CheckboxInput.stories.d.ts.map +1 -1
- package/dist/components/formField/inputs/checkbox/CheckboxInput.stories.js +7 -0
- package/dist/components/formField/inputs/checkbox/CheckboxInput.stories.js.map +1 -1
- package/dist/components/formField/inputs/radio/RadioButtonGroup.d.ts +11 -0
- package/dist/components/formField/inputs/radio/RadioButtonGroup.d.ts.map +1 -0
- package/dist/components/formField/inputs/radio/RadioButtonGroup.js +8 -0
- package/dist/components/formField/inputs/radio/RadioButtonGroup.js.map +1 -0
- package/dist/components/formField/inputs/radio/RadioButtonGroup.test.d.ts +2 -0
- package/dist/components/formField/inputs/radio/RadioButtonGroup.test.d.ts.map +1 -0
- package/dist/components/formField/inputs/radio/RadioButtonGroup.test.js +86 -0
- package/dist/components/formField/inputs/radio/RadioButtonGroup.test.js.map +1 -0
- package/dist/components/formField/inputs/radio/RadioButtonInput.stories.d.ts.map +1 -1
- package/dist/components/formField/inputs/radio/RadioButtonInput.stories.js +8 -2
- package/dist/components/formField/inputs/radio/RadioButtonInput.stories.js.map +1 -1
- package/dist/components/modal/Modal.d.ts +25 -0
- package/dist/components/modal/Modal.d.ts.map +1 -0
- package/dist/components/modal/Modal.js +22 -0
- package/dist/components/modal/Modal.js.map +1 -0
- package/dist/components/modal/Modal.stories.d.ts +13 -0
- package/dist/components/modal/Modal.stories.d.ts.map +1 -0
- package/dist/components/modal/Modal.stories.js +23 -0
- package/dist/components/modal/Modal.stories.js.map +1 -0
- package/dist/components/modal/Modal.test.d.ts +2 -0
- package/dist/components/modal/Modal.test.d.ts.map +1 -0
- package/dist/components/modal/Modal.test.js +131 -0
- package/dist/components/modal/Modal.test.js.map +1 -0
- package/dist/components/modal/ModalBody.d.ts +7 -0
- package/dist/components/modal/ModalBody.d.ts.map +1 -0
- package/dist/components/modal/ModalBody.js +7 -0
- package/dist/components/modal/ModalBody.js.map +1 -0
- package/dist/components/modal/ModalCloseButton.d.ts +3 -0
- package/dist/components/modal/ModalCloseButton.d.ts.map +1 -0
- package/dist/components/modal/ModalCloseButton.js +25 -0
- package/dist/components/modal/ModalCloseButton.js.map +1 -0
- package/dist/components/modal/ModalFooter.d.ts +7 -0
- package/dist/components/modal/ModalFooter.d.ts.map +1 -0
- package/dist/components/modal/ModalFooter.js +7 -0
- package/dist/components/modal/ModalFooter.js.map +1 -0
- package/dist/components/modal/ModalHeader.d.ts +7 -0
- package/dist/components/modal/ModalHeader.d.ts.map +1 -0
- package/dist/components/modal/ModalHeader.js +8 -0
- package/dist/components/modal/ModalHeader.js.map +1 -0
- package/dist/components/modal/ModalTitle.d.ts +3 -0
- package/dist/components/modal/ModalTitle.d.ts.map +1 -0
- package/dist/components/modal/ModalTitle.js +8 -0
- package/dist/components/modal/ModalTitle.js.map +1 -0
- package/dist/components/modal/modalManager/ModalManager.d.ts +7 -0
- package/dist/components/modal/modalManager/ModalManager.d.ts.map +1 -0
- package/dist/components/modal/modalManager/ModalManager.js +22 -0
- package/dist/components/modal/modalManager/ModalManager.js.map +1 -0
- package/dist/components/modal/modalManager/ModalManager.stories.d.ts +13 -0
- package/dist/components/modal/modalManager/ModalManager.stories.d.ts.map +1 -0
- package/dist/components/modal/modalManager/ModalManager.stories.js +110 -0
- package/dist/components/modal/modalManager/ModalManager.stories.js.map +1 -0
- package/dist/components/modal/modalManager/ModalManager.test.d.ts +2 -0
- package/dist/components/modal/modalManager/ModalManager.test.d.ts.map +1 -0
- package/dist/components/modal/modalManager/ModalManager.test.js +191 -0
- package/dist/components/modal/modalManager/ModalManager.test.js.map +1 -0
- package/dist/components/separator/Separator.d.ts +7 -0
- package/dist/components/separator/Separator.d.ts.map +1 -0
- package/dist/components/separator/Separator.js +8 -0
- package/dist/components/separator/Separator.js.map +1 -0
- package/dist/components/separator/Separator.stories.d.ts +10 -0
- package/dist/components/separator/Separator.stories.d.ts.map +1 -0
- package/dist/components/separator/Separator.stories.js +12 -0
- package/dist/components/separator/Separator.stories.js.map +1 -0
- package/dist/components/separator/Separator.test.d.ts +2 -0
- package/dist/components/separator/Separator.test.d.ts.map +1 -0
- package/dist/components/separator/Separator.test.js +10 -0
- package/dist/components/separator/Separator.test.js.map +1 -0
- package/dist/components/table/Table.d.ts +20 -0
- package/dist/components/table/Table.d.ts.map +1 -1
- package/dist/components/table/Table.js +45 -7
- package/dist/components/table/Table.js.map +1 -1
- package/dist/components/table/Table.stories.d.ts.map +1 -1
- package/dist/components/table/Table.stories.js +14 -1
- package/dist/components/table/Table.stories.js.map +1 -1
- package/dist/components/table/Table.test.js +315 -2
- package/dist/components/table/Table.test.js.map +1 -1
- package/dist/components/table/pagination/TableSettingsDropdown.d.ts +2 -0
- package/dist/components/table/pagination/TableSettingsDropdown.d.ts.map +1 -0
- package/dist/components/table/pagination/TableSettingsDropdown.js +43 -0
- package/dist/components/table/pagination/TableSettingsDropdown.js.map +1 -0
- package/dist/components/table/useTableSettings.d.ts +22 -0
- package/dist/components/table/useTableSettings.d.ts.map +1 -0
- package/dist/components/table/useTableSettings.js +36 -0
- package/dist/components/table/useTableSettings.js.map +1 -0
- package/dist/index.css +102 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/Constants.d.ts +5 -0
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +5 -0
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/ModalUtils.d.ts +7 -0
- package/dist/utils/ModalUtils.d.ts.map +1 -0
- package/dist/utils/ModalUtils.js +14 -0
- package/dist/utils/ModalUtils.js.map +1 -0
- package/dist/utils/hooks/useComponentDidUpdate.d.ts +7 -0
- package/dist/utils/hooks/useComponentDidUpdate.d.ts.map +1 -0
- package/dist/utils/hooks/useComponentDidUpdate.js +18 -0
- package/dist/utils/hooks/useComponentDidUpdate.js.map +1 -0
- package/dist/utils/hooks/useComponentDidUpdate.test.d.ts +2 -0
- package/dist/utils/hooks/useComponentDidUpdate.test.d.ts.map +1 -0
- package/dist/utils/hooks/useComponentDidUpdate.test.js +69 -0
- package/dist/utils/hooks/useComponentDidUpdate.test.js.map +1 -0
- package/package.json +1 -1
- package/src/components/formField/fieldset/Fieldset.stories.tsx +89 -0
- package/src/components/formField/fieldset/Fieldset.test.tsx +85 -0
- package/src/components/formField/fieldset/Fieldset.tsx +17 -0
- package/src/components/formField/fieldset/fieldset.scss +19 -0
- package/src/components/formField/inputs/checkbox/CheckboxGroup.test.tsx +127 -0
- package/src/components/formField/inputs/checkbox/CheckboxGroup.tsx +17 -0
- package/src/components/formField/inputs/checkbox/CheckboxInput.stories.tsx +12 -1
- package/src/components/formField/inputs/radio/RadioButtonGroup.test.tsx +190 -0
- package/src/components/formField/inputs/radio/RadioButtonGroup.tsx +22 -0
- package/src/components/formField/inputs/radio/RadioButtonInput.stories.tsx +16 -7
- package/src/components/formField/label/label.scss +1 -1
- package/src/components/modal/Modal.stories.tsx +37 -0
- package/src/components/modal/Modal.test.tsx +244 -0
- package/src/components/modal/Modal.tsx +65 -0
- package/src/components/modal/ModalBody.tsx +16 -0
- package/src/components/modal/ModalCloseButton.tsx +39 -0
- package/src/components/modal/ModalFooter.tsx +14 -0
- package/src/components/modal/ModalHeader.tsx +20 -0
- package/src/components/modal/ModalTitle.tsx +12 -0
- package/src/components/modal/modal.scss +74 -0
- package/src/components/modal/modalManager/ModalManager.stories.tsx +497 -0
- package/src/components/modal/modalManager/ModalManager.test.tsx +255 -0
- package/src/components/modal/modalManager/ModalManager.tsx +40 -0
- package/src/components/modal/modalManager/modalManager.scss +4 -0
- package/src/components/separator/Separator.stories.tsx +15 -0
- package/src/components/separator/Separator.test.tsx +10 -0
- package/src/components/separator/Separator.tsx +15 -0
- package/src/components/separator/separator.scss +6 -0
- package/src/components/table/Table.stories.tsx +14 -1
- package/src/components/table/Table.test.tsx +553 -1
- package/src/components/table/Table.tsx +80 -24
- package/src/components/table/pagination/TableSettingsDropdown.tsx +90 -0
- package/src/components/table/table.scss +8 -0
- package/src/components/table/useTableSettings.ts +59 -0
- package/src/index.scss +4 -0
- package/src/index.ts +4 -0
- package/src/tokens.scss +1 -0
- package/src/utils/Constants.ts +6 -0
- package/src/utils/ModalUtils.ts +17 -0
- package/src/utils/hooks/useComponentDidUpdate.test.ts +107 -0
- package/src/utils/hooks/useComponentDidUpdate.ts +19 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
3
|
+
import { ModalManager } from './ModalManager';
|
|
4
|
+
import { ModalUtils } from 'Utils/ModalUtils';
|
|
5
|
+
import PubSub from 'Utils/PubSub';
|
|
6
|
+
import { MODAL } from 'Utils/Constants';
|
|
7
|
+
import '@testing-library/jest-dom/vitest';
|
|
8
|
+
|
|
9
|
+
describe('ModalManager', () => {
|
|
10
|
+
test('renders without crashing', () => {
|
|
11
|
+
render(<ModalManager />);
|
|
12
|
+
const manager = document.querySelector('.ds-modal-manager');
|
|
13
|
+
expect(manager).toBeInTheDocument();
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
test('renders with initial modal prop', () => {
|
|
17
|
+
const modal = {
|
|
18
|
+
children: <div>Initial modal content</div>,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
render(<ModalManager modal={modal} />);
|
|
22
|
+
expect(screen.getByText('Initial modal content')).toBeInTheDocument();
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test('shows modal when ModalUtils.addModal is called', async () => {
|
|
26
|
+
render(<ModalManager />);
|
|
27
|
+
|
|
28
|
+
ModalUtils.addModal({
|
|
29
|
+
children: <div>Dynamic modal content</div>,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
await waitFor(() => {
|
|
33
|
+
expect(screen.getByText('Dynamic modal content')).toBeInTheDocument();
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('removes modal when ModalUtils.removeModal is called', async () => {
|
|
38
|
+
render(<ModalManager />);
|
|
39
|
+
|
|
40
|
+
ModalUtils.addModal({
|
|
41
|
+
children: <div>Modal to remove</div>,
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
await waitFor(() => {
|
|
45
|
+
expect(screen.getByText('Modal to remove')).toBeInTheDocument();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
ModalUtils.removeModal();
|
|
49
|
+
|
|
50
|
+
await waitFor(() => {
|
|
51
|
+
expect(screen.queryByText('Modal to remove')).not.toBeInTheDocument();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('updates modal when ADD_MODAL event is published', async () => {
|
|
56
|
+
render(<ModalManager />);
|
|
57
|
+
|
|
58
|
+
PubSub.publish(MODAL.ADD_MODAL, {
|
|
59
|
+
children: <div>Published modal</div>,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
await waitFor(() => {
|
|
63
|
+
expect(screen.getByText('Published modal')).toBeInTheDocument();
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('removes modal when REMOVE_MODAL event is published', async () => {
|
|
68
|
+
render(<ModalManager />);
|
|
69
|
+
|
|
70
|
+
PubSub.publish(MODAL.ADD_MODAL, {
|
|
71
|
+
children: <div>Modal to be removed</div>,
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
await waitFor(() => {
|
|
75
|
+
expect(screen.getByText('Modal to be removed')).toBeInTheDocument();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
PubSub.publish(MODAL.REMOVE_MODAL);
|
|
79
|
+
|
|
80
|
+
await waitFor(() => {
|
|
81
|
+
expect(screen.queryByText('Modal to be removed')).not.toBeInTheDocument();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
test('replaces modal when multiple ADD_MODAL events are published', async () => {
|
|
86
|
+
render(<ModalManager />);
|
|
87
|
+
|
|
88
|
+
PubSub.publish(MODAL.ADD_MODAL, {
|
|
89
|
+
children: <div>First modal</div>,
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
await waitFor(() => {
|
|
93
|
+
expect(screen.getByText('First modal')).toBeInTheDocument();
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
PubSub.publish(MODAL.ADD_MODAL, {
|
|
97
|
+
children: <div>Second modal</div>,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
await waitFor(() => {
|
|
101
|
+
expect(screen.getByText('Second modal')).toBeInTheDocument();
|
|
102
|
+
expect(screen.queryByText('First modal')).not.toBeInTheDocument();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('no modal is rendered when no modal is set', () => {
|
|
107
|
+
render(<ModalManager />);
|
|
108
|
+
|
|
109
|
+
const overlay = document.querySelector('.ds-modal__overlay');
|
|
110
|
+
expect(overlay).not.toBeInTheDocument();
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
test('closeHandler removes the modal', async () => {
|
|
114
|
+
render(<ModalManager />);
|
|
115
|
+
|
|
116
|
+
ModalUtils.addModal({
|
|
117
|
+
children: <div>Modal with close</div>,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
await waitFor(() => {
|
|
121
|
+
expect(screen.getByText('Modal with close')).toBeInTheDocument();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// The close button should be present
|
|
125
|
+
const closeButton = screen.getByRole('button');
|
|
126
|
+
closeButton.click();
|
|
127
|
+
|
|
128
|
+
await waitFor(() => {
|
|
129
|
+
expect(screen.queryByText('Modal with close')).not.toBeInTheDocument();
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('passes modal props to Modal component', async () => {
|
|
134
|
+
render(<ModalManager />);
|
|
135
|
+
|
|
136
|
+
ModalUtils.addModal({
|
|
137
|
+
title: 'Test Title',
|
|
138
|
+
className: 'custom-modal-class',
|
|
139
|
+
children: <div>Modal content</div>,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
await waitFor(() => {
|
|
143
|
+
expect(screen.getByText('Test Title')).toBeInTheDocument();
|
|
144
|
+
const modalContainer = document.querySelector('.custom-modal-class');
|
|
145
|
+
expect(modalContainer).toBeInTheDocument();
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
test('updates when modal prop changes', async () => {
|
|
150
|
+
const { rerender } = render(
|
|
151
|
+
<ModalManager modal={{ children: <div>First modal</div> }} />,
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
expect(screen.getByText('First modal')).toBeInTheDocument();
|
|
155
|
+
|
|
156
|
+
rerender(<ModalManager modal={{ children: <div>Second modal</div> }} />);
|
|
157
|
+
|
|
158
|
+
await waitFor(() => {
|
|
159
|
+
expect(screen.getByText('Second modal')).toBeInTheDocument();
|
|
160
|
+
expect(screen.queryByText('First modal')).not.toBeInTheDocument();
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test('clears modal when modal prop is set to undefined', async () => {
|
|
165
|
+
const { rerender } = render(
|
|
166
|
+
<ModalManager modal={{ children: <div>Modal content</div> }} />,
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
expect(screen.getByText('Modal content')).toBeInTheDocument();
|
|
170
|
+
|
|
171
|
+
rerender(<ModalManager modal={undefined} />);
|
|
172
|
+
|
|
173
|
+
await waitFor(() => {
|
|
174
|
+
expect(screen.queryByText('Modal content')).not.toBeInTheDocument();
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test('renders portal target as modalManagerContainerRef', async () => {
|
|
179
|
+
render(<ModalManager />);
|
|
180
|
+
|
|
181
|
+
const container = document.querySelector('.ds-modal-manager');
|
|
182
|
+
expect(container).toBeInTheDocument();
|
|
183
|
+
|
|
184
|
+
ModalUtils.addModal({
|
|
185
|
+
children: <div>Portal modal</div>,
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
await waitFor(() => {
|
|
189
|
+
const overlay = container!.querySelector('.ds-modal__overlay');
|
|
190
|
+
expect(overlay).toBeInTheDocument();
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
test('handles multiple sequential modal operations', async () => {
|
|
195
|
+
render(<ModalManager />);
|
|
196
|
+
|
|
197
|
+
// Add first modal
|
|
198
|
+
ModalUtils.addModal({ children: <div>Modal 1</div> });
|
|
199
|
+
await waitFor(() => {
|
|
200
|
+
expect(screen.getByText('Modal 1')).toBeInTheDocument();
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
// Remove it
|
|
204
|
+
ModalUtils.removeModal();
|
|
205
|
+
await waitFor(() => {
|
|
206
|
+
expect(screen.queryByText('Modal 1')).not.toBeInTheDocument();
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// Add second modal
|
|
210
|
+
ModalUtils.addModal({ children: <div>Modal 2</div> });
|
|
211
|
+
await waitFor(() => {
|
|
212
|
+
expect(screen.getByText('Modal 2')).toBeInTheDocument();
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
// Add third modal (replaces second)
|
|
216
|
+
ModalUtils.addModal({ children: <div>Modal 3</div> });
|
|
217
|
+
await waitFor(() => {
|
|
218
|
+
expect(screen.getByText('Modal 3')).toBeInTheDocument();
|
|
219
|
+
expect(screen.queryByText('Modal 2')).not.toBeInTheDocument();
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
test('modal inherits all props from ModalUtils.addModal call', async () => {
|
|
224
|
+
render(<ModalManager />);
|
|
225
|
+
|
|
226
|
+
ModalUtils.addModal({
|
|
227
|
+
title: 'Custom Title',
|
|
228
|
+
hideCloseButton: true,
|
|
229
|
+
className: 'test-class',
|
|
230
|
+
overlayClassName: 'test-overlay',
|
|
231
|
+
children: (
|
|
232
|
+
<>
|
|
233
|
+
<div>Header content</div>
|
|
234
|
+
<div>Body content</div>
|
|
235
|
+
</>
|
|
236
|
+
),
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
await waitFor(() => {
|
|
240
|
+
expect(screen.getByText('Custom Title')).toBeInTheDocument();
|
|
241
|
+
expect(screen.getByText('Header content')).toBeInTheDocument();
|
|
242
|
+
expect(screen.getByText('Body content')).toBeInTheDocument();
|
|
243
|
+
|
|
244
|
+
const modalContainer = document.querySelector('.test-class');
|
|
245
|
+
expect(modalContainer).toBeInTheDocument();
|
|
246
|
+
|
|
247
|
+
const overlay = document.querySelector('.test-overlay');
|
|
248
|
+
expect(overlay).toBeInTheDocument();
|
|
249
|
+
|
|
250
|
+
// Close button should be hidden
|
|
251
|
+
const closeButton = screen.queryByRole('button');
|
|
252
|
+
expect(closeButton).not.toBeInTheDocument();
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Modal, type ModalProps } from 'Components/modal/Modal';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { MODAL } from 'Utils/Constants';
|
|
4
|
+
import { usePubSub } from 'Utils/hooks/usePubSub';
|
|
5
|
+
|
|
6
|
+
type ModalManagerProps = {
|
|
7
|
+
modal?: ModalProps;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const ModalManager = (props: ModalManagerProps) => {
|
|
11
|
+
const { modal: initialModal } = props;
|
|
12
|
+
const [modal, setModal] = useState<ModalProps | undefined>(() => initialModal);
|
|
13
|
+
|
|
14
|
+
const modalManagerContainerRef = useRef<HTMLDivElement>(null);
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
setModal(initialModal);
|
|
18
|
+
}, [initialModal]);
|
|
19
|
+
|
|
20
|
+
const hasModal = !!modal;
|
|
21
|
+
|
|
22
|
+
usePubSub(MODAL.ADD_MODAL, (newModal: ModalProps) => {
|
|
23
|
+
setModal(newModal);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
usePubSub(MODAL.REMOVE_MODAL, () => {
|
|
27
|
+
setModal(undefined);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<div ref={modalManagerContainerRef} className="ds-modal-manager">
|
|
32
|
+
<Modal
|
|
33
|
+
{...modal}
|
|
34
|
+
open={hasModal}
|
|
35
|
+
portalTarget={modalManagerContainerRef.current}
|
|
36
|
+
closeHandler={() => setModal(undefined)}
|
|
37
|
+
/>
|
|
38
|
+
</div>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Meta } from '@storybook/react-vite';
|
|
2
|
+
import { Separator } from './Separator';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Separator> = {
|
|
5
|
+
title: 'Components/Separator',
|
|
6
|
+
component: Separator,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Default = {
|
|
10
|
+
args: {
|
|
11
|
+
title: 'titleValue',
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default meta;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { expect, test } from 'vitest';
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { Separator } from './Separator';
|
|
4
|
+
import '@testing-library/jest-dom/vitest';
|
|
5
|
+
|
|
6
|
+
test('Separator says hello', () => {
|
|
7
|
+
render(<Separator />);
|
|
8
|
+
|
|
9
|
+
expect(screen.getByRole('separator')).toBeInTheDocument();
|
|
10
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import classNames from 'classnames';
|
|
2
|
+
import { Separator as RadixSeparator } from 'radix-ui';
|
|
3
|
+
|
|
4
|
+
type SeparatorProps = {
|
|
5
|
+
className?: string;
|
|
6
|
+
} & RadixSeparator.SeparatorProps;
|
|
7
|
+
|
|
8
|
+
export const Separator = (props: SeparatorProps) => {
|
|
9
|
+
const {
|
|
10
|
+
className,
|
|
11
|
+
...rest
|
|
12
|
+
} = props;
|
|
13
|
+
|
|
14
|
+
return <RadixSeparator.Root className={classNames('ds-separator', className)} {...rest} />;
|
|
15
|
+
};
|
|
@@ -9,6 +9,7 @@ import { useState, type ComponentProps } from 'react';
|
|
|
9
9
|
import { RowCountInfo } from './pagination/RowCountInfo';
|
|
10
10
|
import { PaginationPanel } from './pagination/PaginationPanel';
|
|
11
11
|
import { HideColumnsDropdown } from './HideColumnsDropdown';
|
|
12
|
+
import { TableSettingsDropdown } from './pagination/TableSettingsDropdown';
|
|
12
13
|
|
|
13
14
|
type TableProps = ComponentProps<typeof Table>;
|
|
14
15
|
|
|
@@ -64,7 +65,7 @@ const HeaderContent = [
|
|
|
64
65
|
</div>,
|
|
65
66
|
<div key={1} style={{ display: 'flex', gap: '1rem' }}>
|
|
66
67
|
<Icon name="download" />
|
|
67
|
-
<
|
|
68
|
+
<TableSettingsDropdown />
|
|
68
69
|
<Icon name="circle-help" />
|
|
69
70
|
<Icon name="expand" />
|
|
70
71
|
</div>,
|
|
@@ -102,6 +103,18 @@ export const WithHeader: Story = {
|
|
|
102
103
|
defaultColDef: defaultColDef,
|
|
103
104
|
domLayout: 'autoHeight',
|
|
104
105
|
headerContent: HeaderContent,
|
|
106
|
+
onTableSettingsChanged: (newSettings) => {
|
|
107
|
+
console.log('Settings changed', newSettings);
|
|
108
|
+
},
|
|
109
|
+
onTableSpacingChanged: (newSpacing) => {
|
|
110
|
+
console.log('Spacing changed', newSpacing);
|
|
111
|
+
},
|
|
112
|
+
onColumnBordersChanged: (newBorders) => {
|
|
113
|
+
console.log('Column borders changed', newBorders);
|
|
114
|
+
},
|
|
115
|
+
onTableSettingsReset: () => {
|
|
116
|
+
console.log('Settings reset');
|
|
117
|
+
},
|
|
105
118
|
},
|
|
106
119
|
};
|
|
107
120
|
|