@pie-lib/config-ui 13.0.21 → 13.0.22-beta.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +0 -76
  2. package/lib/choice-configuration/index.js +28 -30
  3. package/lib/choice-configuration/index.js.map +1 -1
  4. package/lib/feedback-config/feedback-selector.js +2 -5
  5. package/lib/feedback-config/feedback-selector.js.map +1 -1
  6. package/lib/help.js +10 -13
  7. package/lib/help.js.map +1 -1
  8. package/lib/layout/settings-box.js +4 -11
  9. package/lib/layout/settings-box.js.map +1 -1
  10. package/package.json +5 -5
  11. package/src/choice-configuration/index.jsx +3 -5
  12. package/src/feedback-config/feedback-selector.jsx +3 -5
  13. package/src/help.jsx +2 -6
  14. package/src/layout/settings-box.jsx +3 -11
  15. package/LICENSE.md +0 -5
  16. package/src/__tests__/alert-dialog.test.jsx +0 -183
  17. package/src/__tests__/checkbox.test.jsx +0 -152
  18. package/src/__tests__/choice-utils.test.js +0 -12
  19. package/src/__tests__/form-section.test.jsx +0 -328
  20. package/src/__tests__/help.test.jsx +0 -184
  21. package/src/__tests__/input.test.jsx +0 -156
  22. package/src/__tests__/langs.test.jsx +0 -376
  23. package/src/__tests__/number-text-field-custom.test.jsx +0 -255
  24. package/src/__tests__/number-text-field.test.jsx +0 -263
  25. package/src/__tests__/radio-with-label.test.jsx +0 -155
  26. package/src/__tests__/settings-panel.test.js +0 -187
  27. package/src/__tests__/settings.test.jsx +0 -452
  28. package/src/__tests__/tabs.test.jsx +0 -188
  29. package/src/__tests__/two-choice.test.js +0 -110
  30. package/src/__tests__/with-stateful-model.test.jsx +0 -139
  31. package/src/choice-configuration/__tests__/feedback-menu.test.jsx +0 -151
  32. package/src/choice-configuration/__tests__/index.test.jsx +0 -234
  33. package/src/feedback-config/__tests__/feedback-config.test.jsx +0 -141
  34. package/src/feedback-config/__tests__/feedback-selector.test.jsx +0 -97
  35. package/src/layout/__tests__/config.layout.test.jsx +0 -59
  36. package/src/layout/__tests__/layout-content.test.jsx +0 -3
  37. package/src/tags-input/__tests__/index.test.jsx +0 -113
@@ -1,5 +1,5 @@
1
1
  import EditableHtml from '@pie-lib/editable-html-tip-tap';
2
- import { InputContainer, color } from '@pie-lib/render-ui';
2
+ import { InputContainer } from '@pie-lib/render-ui';
3
3
  import PropTypes from 'prop-types';
4
4
  import React from 'react';
5
5
  import { styled } from '@mui/material/styles';
@@ -24,11 +24,9 @@ const StyledInputContainer = styled(InputContainer)(() => ({
24
24
  paddingBottom: 0,
25
25
  }));
26
26
 
27
- // A fill is meant to sit close to the page, so `--pie-background-dark` rather
28
- // than a stroke token; MUI's grey[300] held #e0e0e0 under every scheme.
29
27
  const StyledCustomHolder = styled('div')(({ theme }) => ({
30
28
  marginTop: '0px',
31
- background: color.backgroundDark(),
29
+ background: theme.palette.grey[300],
32
30
  padding: 0,
33
31
  marginBottom: theme.spacing(2),
34
32
  borderRadius: '4px',
@@ -36,7 +34,7 @@ const StyledCustomHolder = styled('div')(({ theme }) => ({
36
34
 
37
35
  const StyledDefaultHolder = styled('div')(({ theme }) => ({
38
36
  marginTop: '0px',
39
- background: color.backgroundDark(),
37
+ background: theme.palette.grey[300],
40
38
  padding: theme.spacing(2),
41
39
  marginBottom: theme.spacing(2),
42
40
  borderRadius: '4px',
package/src/help.jsx CHANGED
@@ -10,14 +10,10 @@ import HelpIcon from '@mui/icons-material/Help';
10
10
  import IconButton from '@mui/material/IconButton';
11
11
  import React from 'react';
12
12
  import { styled } from '@mui/material/styles';
13
- import { color } from '@pie-lib/render-ui';
14
13
 
15
- const StyledIconButton = styled(IconButton)(() => ({
14
+ const StyledIconButton = styled(IconButton)(({ theme }) => ({
16
15
  '&:hover': {
17
- // A decorative de-emphasis on hover -- the icon's resting state carries the
18
- // affordance, so this does not need the 3:1 non-text minimum. MUI's grey[300]
19
- // did not follow `--pie-*`, so it stayed #e0e0e0 on a dark scheme's surface.
20
- color: color.borderLight(),
16
+ color: theme.palette.grey[300],
21
17
  },
22
18
  }));
23
19
 
@@ -1,18 +1,10 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { styled } from '@mui/material/styles';
4
- import { color } from '@pie-lib/render-ui';
5
4
 
6
- const StyledSettingsBox = styled('div')(() => ({
7
- /*
8
- * Surface and stroke have to move together. `background.paper` is MUI's #fff
9
- * regardless of scheme, so tokenising the stroke alone would put a scheme's
10
- * border colour on a fixed white panel -- under white-on-black that is a white
11
- * stroke on white. `--pie-white` inverts with the scheme, which is what the
12
- * panel wanted from `background.paper` in the first place.
13
- */
14
- backgroundColor: color.white(),
15
- border: `2px solid ${color.border()}`,
5
+ const StyledSettingsBox = styled('div')(({ theme }) => ({
6
+ backgroundColor: theme.palette.background.paper,
7
+ border: `2px solid ${theme.palette.grey[200]}`,
16
8
  display: 'flex',
17
9
  flexDirection: 'column',
18
10
  justifyContent: 'flex-start',
package/LICENSE.md DELETED
@@ -1,5 +0,0 @@
1
- Copyright 2019 CoreSpring Inc
2
-
3
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
4
-
5
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -1,183 +0,0 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import userEvent from '@testing-library/user-event';
4
- import AlertDialog from '../alert-dialog';
5
-
6
- describe('AlertDialog Component', () => {
7
- const onClose = jest.fn();
8
- const onConfirm = jest.fn();
9
-
10
- beforeEach(() => {
11
- onClose.mockClear();
12
- onConfirm.mockClear();
13
- });
14
-
15
- describe('Rendering when open', () => {
16
- it('should render dialog when open is true', () => {
17
- render(<AlertDialog open={true} title="Confirm" text="Are you sure?" onClose={onClose} onConfirm={onConfirm} />);
18
-
19
- expect(screen.getByText('Confirm')).toBeInTheDocument();
20
- expect(screen.getByText('Are you sure?')).toBeInTheDocument();
21
- });
22
-
23
- it('should not render dialog when open is false', () => {
24
- const { container } = render(
25
- <AlertDialog open={false} title="Confirm" text="Are you sure?" onClose={onClose} onConfirm={onConfirm} />,
26
- );
27
-
28
- const dialogs = container.querySelectorAll('[role="dialog"]');
29
- expect(dialogs.length).toBe(0);
30
- });
31
- });
32
-
33
- describe('Title and Text', () => {
34
- it('should handle both title and text', () => {
35
- render(
36
- <AlertDialog
37
- open={true}
38
- title="Important"
39
- text="This is an important message"
40
- onClose={onClose}
41
- onConfirm={onConfirm}
42
- />,
43
- );
44
-
45
- expect(screen.getByText('Important')).toBeInTheDocument();
46
- expect(screen.getByText('This is an important message')).toBeInTheDocument();
47
- });
48
-
49
- it('should handle text as object', () => {
50
- const textObj = <div>Rich text content</div>;
51
- render(<AlertDialog open={true} title="Rich Content" text={textObj} onClose={onClose} onConfirm={onConfirm} />);
52
-
53
- expect(screen.getByText('Rich text content')).toBeInTheDocument();
54
- });
55
- });
56
-
57
- describe('Buttons', () => {
58
- it('should render close button when onClose is provided', () => {
59
- render(<AlertDialog open={true} title="Dialog" text="Content" onClose={onClose} onConfirm={onConfirm} />);
60
-
61
- expect(screen.getByRole('button', { name: 'CANCEL' })).toBeInTheDocument();
62
- });
63
-
64
- it('should render confirm button when onConfirm is provided', () => {
65
- render(<AlertDialog open={true} title="Dialog" text="Content" onClose={onClose} onConfirm={onConfirm} />);
66
-
67
- expect(screen.getByRole('button', { name: 'OK' })).toBeInTheDocument();
68
- });
69
-
70
- it('should have default button text', () => {
71
- render(<AlertDialog open={true} title="Dialog" text="Content" onClose={onClose} onConfirm={onConfirm} />);
72
-
73
- expect(screen.getByRole('button', { name: 'CANCEL' })).toBeInTheDocument();
74
- expect(screen.getByRole('button', { name: 'OK' })).toBeInTheDocument();
75
- });
76
- });
77
-
78
- describe('User interactions', () => {
79
- it('should call onClose when close button is clicked', async () => {
80
- const user = userEvent.setup();
81
- render(<AlertDialog open={true} title="Dialog" text="Content" onClose={onClose} onConfirm={onConfirm} />);
82
-
83
- const closeButton = screen.getByRole('button', { name: 'CANCEL' });
84
- await user.click(closeButton);
85
-
86
- expect(onClose).toHaveBeenCalled();
87
- });
88
-
89
- it('should call onConfirm when confirm button is clicked', async () => {
90
- const user = userEvent.setup();
91
- render(<AlertDialog open={true} title="Dialog" text="Content" onClose={onClose} onConfirm={onConfirm} />);
92
-
93
- const confirmButton = screen.getByRole('button', { name: 'OK' });
94
- await user.click(confirmButton);
95
-
96
- expect(onConfirm).toHaveBeenCalled();
97
- });
98
- });
99
-
100
- describe('Focus management', () => {
101
- it('should have autoFocus on confirm button by default', () => {
102
- render(<AlertDialog open={true} title="Dialog" text="Content" onClose={onClose} onConfirm={onConfirm} />);
103
-
104
- const confirmButton = screen.getByRole('button', { name: 'OK' });
105
- expect(confirmButton).toBeInTheDocument();
106
- });
107
-
108
- it('should disable auto focus when disableAutoFocus is true', () => {
109
- render(
110
- <AlertDialog
111
- open={true}
112
- title="Dialog"
113
- text="Content"
114
- onClose={onClose}
115
- onConfirm={onConfirm}
116
- disableAutoFocus={true}
117
- />,
118
- );
119
-
120
- expect(screen.getByText('Dialog')).toBeInTheDocument();
121
- });
122
-
123
- it('should disable enforce focus when disableEnforceFocus is true', () => {
124
- render(
125
- <AlertDialog
126
- open={true}
127
- title="Dialog"
128
- text="Content"
129
- onClose={onClose}
130
- onConfirm={onConfirm}
131
- disableEnforceFocus={true}
132
- />,
133
- );
134
-
135
- expect(screen.getByText('Dialog')).toBeInTheDocument();
136
- });
137
-
138
- it('should disable restore focus when disableRestoreFocus is true', () => {
139
- render(
140
- <AlertDialog
141
- open={true}
142
- title="Dialog"
143
- text="Content"
144
- onClose={onClose}
145
- onConfirm={onConfirm}
146
- disableRestoreFocus={true}
147
- />,
148
- );
149
-
150
- expect(screen.getByText('Dialog')).toBeInTheDocument();
151
- });
152
- });
153
-
154
- describe('Edge cases', () => {
155
- it('should handle very long title', () => {
156
- const longTitle = 'This is a very long title that should wrap properly in the dialog';
157
- render(<AlertDialog open={true} title={longTitle} text="Content" onClose={onClose} onConfirm={onConfirm} />);
158
-
159
- expect(screen.getByText(longTitle)).toBeInTheDocument();
160
- });
161
-
162
- it('should handle very long text', () => {
163
- const longText = 'This is a very long text that should wrap properly in the dialog. '.repeat(10);
164
- render(<AlertDialog open={true} title="Dialog" text={longText} onClose={onClose} onConfirm={onConfirm} />);
165
-
166
- expect(screen.getByText(new RegExp(longText.slice(0, 50)))).toBeInTheDocument();
167
- });
168
-
169
- it('should handle only close callback', () => {
170
- render(<AlertDialog open={true} title="Close Only" text="Content" onClose={onClose} />);
171
-
172
- expect(screen.getByRole('button', { name: 'CANCEL' })).toBeInTheDocument();
173
- expect(screen.queryByRole('button', { name: 'OK' })).not.toBeInTheDocument();
174
- });
175
-
176
- it('should handle only confirm callback', () => {
177
- render(<AlertDialog open={true} title="Confirm Only" text="Content" onConfirm={onConfirm} />);
178
-
179
- expect(screen.getByRole('button', { name: 'OK' })).toBeInTheDocument();
180
- expect(screen.queryByRole('button', { name: 'CANCEL' })).not.toBeInTheDocument();
181
- });
182
- });
183
- });
@@ -1,152 +0,0 @@
1
- import React from 'react';
2
- import { render, screen } from '@testing-library/react';
3
- import userEvent from '@testing-library/user-event';
4
- import Checkbox from '../checkbox';
5
-
6
- describe('Checkbox Component', () => {
7
- const onChange = jest.fn();
8
-
9
- beforeEach(() => {
10
- onChange.mockClear();
11
- });
12
-
13
- describe('Rendering', () => {
14
- it('should render checkbox with label', () => {
15
- render(<Checkbox checked={false} onChange={onChange} label="Accept terms" />);
16
-
17
- expect(screen.getByText('Accept terms')).toBeInTheDocument();
18
- expect(screen.getByRole('checkbox')).toBeInTheDocument();
19
- });
20
-
21
- it('should render checkbox in checked state', () => {
22
- render(<Checkbox checked={true} onChange={onChange} label="Accept terms" />);
23
-
24
- expect(screen.getByRole('checkbox')).toBeChecked();
25
- });
26
-
27
- it('should render checkbox in unchecked state', () => {
28
- render(<Checkbox checked={false} onChange={onChange} label="Accept terms" />);
29
-
30
- expect(screen.getByRole('checkbox')).not.toBeChecked();
31
- });
32
-
33
- it('should render mini checkbox with reduced styling', () => {
34
- render(<Checkbox checked={false} onChange={onChange} label="Mini" mini={true} />);
35
-
36
- expect(screen.getByRole('checkbox')).toBeInTheDocument();
37
- expect(screen.getByText('Mini')).toBeInTheDocument();
38
- });
39
- });
40
-
41
- describe('User interaction', () => {
42
- it('should call onChange when checkbox is clicked', async () => {
43
- const user = userEvent.setup();
44
- render(<Checkbox checked={false} onChange={onChange} label="Accept" />);
45
-
46
- const checkbox = screen.getByRole('checkbox');
47
- await user.click(checkbox);
48
-
49
- expect(onChange).toHaveBeenCalled();
50
- });
51
-
52
- it('should call onChange when label is clicked', async () => {
53
- const user = userEvent.setup();
54
- render(<Checkbox checked={false} onChange={onChange} label="Click label" />);
55
-
56
- const label = screen.getByText('Click label');
57
- await user.click(label);
58
-
59
- expect(onChange).toHaveBeenCalled();
60
- });
61
- });
62
-
63
- describe('Props', () => {
64
- it('should handle value prop', () => {
65
- render(<Checkbox checked={true} onChange={onChange} label="With value" value="option1" />);
66
-
67
- expect(screen.getByRole('checkbox')).toBeInTheDocument();
68
- });
69
-
70
- it('should display error styling when error is true', () => {
71
- render(<Checkbox checked={false} onChange={onChange} label="Error state" error={true} />);
72
-
73
- expect(screen.getByRole('checkbox')).toBeInTheDocument();
74
- expect(screen.getByText('Error state')).toBeInTheDocument();
75
- });
76
- });
77
-
78
- describe('Default props', () => {
79
- it('should have mini default to false', () => {
80
- const { container } = render(<Checkbox checked={true} onChange={onChange} label="Test" />);
81
-
82
- expect(screen.getByRole('checkbox')).toBeInTheDocument();
83
- });
84
-
85
- it('should have error default to false', () => {
86
- const { container } = render(<Checkbox checked={true} onChange={onChange} label="Test" />);
87
-
88
- expect(screen.getByRole('checkbox')).toBeInTheDocument();
89
- });
90
-
91
- it('should have value default to empty string', () => {
92
- render(<Checkbox checked={true} onChange={onChange} label="Test" />);
93
-
94
- expect(screen.getByRole('checkbox')).toBeInTheDocument();
95
- });
96
- });
97
-
98
- describe('Accessibility', () => {
99
- it('should have proper label association', () => {
100
- render(<Checkbox checked={false} onChange={onChange} label="Accessible label" />);
101
-
102
- expect(screen.getByLabelText('Accessible label')).toBeInTheDocument();
103
- });
104
-
105
- it('should be keyboard accessible', async () => {
106
- const user = userEvent.setup();
107
- render(<Checkbox checked={false} onChange={onChange} label="Keyboard test" />);
108
-
109
- const checkbox = screen.getByRole('checkbox');
110
- checkbox.focus();
111
- expect(checkbox).toHaveFocus();
112
-
113
- await user.keyboard(' ');
114
- expect(onChange).toHaveBeenCalled();
115
- });
116
- });
117
-
118
- describe('Multiple checkboxes', () => {
119
- it('should render multiple independent checkboxes', () => {
120
- const onChange1 = jest.fn();
121
- const onChange2 = jest.fn();
122
-
123
- render(
124
- <>
125
- <Checkbox checked={true} onChange={onChange1} label="Option 1" />
126
- <Checkbox checked={false} onChange={onChange2} label="Option 2" />
127
- </>,
128
- );
129
-
130
- expect(screen.getByLabelText('Option 1')).toBeChecked();
131
- expect(screen.getByLabelText('Option 2')).not.toBeChecked();
132
- });
133
-
134
- it('should handle independent onChange callbacks', async () => {
135
- const user = userEvent.setup();
136
- const onChange1 = jest.fn();
137
- const onChange2 = jest.fn();
138
-
139
- render(
140
- <>
141
- <Checkbox checked={true} onChange={onChange1} label="Option 1" />
142
- <Checkbox checked={false} onChange={onChange2} label="Option 2" />
143
- </>,
144
- );
145
-
146
- await user.click(screen.getByLabelText('Option 2'));
147
-
148
- expect(onChange2).toHaveBeenCalled();
149
- expect(onChange1).not.toHaveBeenCalled();
150
- });
151
- });
152
- });
@@ -1,12 +0,0 @@
1
- import { firstAvailableIndex } from '../choice-utils';
2
-
3
- describe('firstAvailableIndex', () => {
4
- const assert = (values, index, expected) => {
5
- it(`[${values.join(',')}], ${index} ==> ${expected}`, () => {
6
- expect(firstAvailableIndex(['0'], 0)).toEqual('1');
7
- });
8
- };
9
- assert(['0'], 0, '1');
10
- assert(['0', '1', '2'], 0, '3');
11
- assert(['0', '1', '2'], 100, '100');
12
- });