@seeqdev/qomponents 0.0.41 → 0.0.43
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 +135 -135
- package/dist/Button/Button.js +86 -86
- package/dist/Button/Button.stories.js +76 -76
- package/dist/Button/Button.test.js +48 -48
- package/dist/Button/Button.types.js +3 -3
- package/dist/Button/index.js +1 -1
- package/dist/Checkbox/Checkbox.js +23 -23
- package/dist/Checkbox/Checkbox.stories.js +31 -31
- package/dist/Checkbox/Checkbox.test.js +93 -93
- package/dist/Checkbox/Checkbox.types.js +1 -1
- package/dist/Checkbox/index.js +1 -1
- package/dist/FontCustom.woff +0 -0
- package/dist/FontCustom.woff2 +0 -0
- package/dist/Icon/Icon.js +62 -62
- package/dist/Icon/Icon.stories.js +39 -39
- package/dist/Icon/Icon.test.js +54 -54
- package/dist/Icon/Icon.types.js +15 -15
- package/dist/Icon/index.js +1 -1
- package/dist/Select/Select.js +167 -167
- package/dist/Select/Select.stories.js +71 -71
- package/dist/Select/Select.test.js +160 -160
- package/dist/Select/Select.types.js +1 -1
- package/dist/Select/index.js +1 -1
- package/dist/Tabs/Tabs.d.ts +4 -0
- package/dist/Tabs/Tabs.js +23 -0
- package/dist/Tabs/Tabs.js.map +1 -0
- package/dist/Tabs/Tabs.stories.d.ts +5 -0
- package/dist/Tabs/Tabs.stories.js +63 -0
- package/dist/Tabs/Tabs.stories.js.map +1 -0
- package/dist/Tabs/Tabs.test.d.ts +1 -0
- package/dist/Tabs/Tabs.test.js +91 -0
- package/dist/Tabs/Tabs.test.js.map +1 -0
- package/dist/Tabs/Tabs.types.d.ts +18 -0
- package/dist/Tabs/Tabs.types.js +2 -0
- package/dist/Tabs/Tabs.types.js.map +1 -0
- package/dist/Tabs/index.d.ts +1 -0
- package/dist/Tabs/index.js +2 -0
- package/dist/Tabs/index.js.map +1 -0
- package/dist/TextArea/TextArea.js +22 -22
- package/dist/TextArea/TextArea.stories.js +38 -38
- package/dist/TextArea/TextArea.test.js +67 -67
- package/dist/TextArea/TextArea.types.js +1 -1
- package/dist/TextArea/index.js +1 -1
- package/dist/TextField/TextField.js +63 -63
- package/dist/TextField/TextField.stories.js +40 -40
- package/dist/TextField/TextField.test.js +34 -34
- package/dist/TextField/TextField.types.js +1 -1
- package/dist/TextField/index.js +1 -1
- package/dist/ToolbarButton/ToolbarButton.js +73 -73
- package/dist/ToolbarButton/ToolbarButton.stories.js +78 -78
- package/dist/ToolbarButton/ToolbarButton.test.js +92 -92
- package/dist/ToolbarButton/ToolbarButton.types.js +1 -1
- package/dist/ToolbarButton/index.js +1 -1
- package/dist/Tooltip/QTip.stories.js +39 -39
- package/dist/Tooltip/QTip.types.js +1 -1
- package/dist/Tooltip/QTipPerformance.stories.js +29 -29
- package/dist/Tooltip/Qtip.js +147 -147
- package/dist/Tooltip/Tooltip.js +35 -35
- package/dist/Tooltip/Tooltip.stories.js +31 -31
- package/dist/Tooltip/Tooltip.types.js +2 -2
- package/dist/Tooltip/TooltipPerformance.stories.js +29 -29
- package/dist/Tooltip/index.js +2 -2
- package/dist/example/.eslintrc.cjs +14 -14
- package/dist/example/README.md +33 -33
- package/dist/example/index.html +13 -13
- package/dist/example/package.json +30 -30
- package/dist/example/src/ComplexSelectExample.tsx +81 -81
- package/dist/example/src/Example.tsx +167 -167
- package/dist/example/src/index.css +102 -102
- package/dist/example/src/main.tsx +10 -10
- package/dist/example/src/vite-env.d.ts +1 -1
- package/dist/example/tsconfig.json +33 -33
- package/dist/example/tsconfig.node.json +12 -12
- package/dist/example/vite.config.ts +12 -12
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +486 -7
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +486 -6
- package/dist/index.js.map +1 -1
- package/dist/styles.css +2730 -2644
- package/dist/types.js +1 -1
- package/dist/utils/browserId.js +28 -28
- package/package.json +80 -79
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import '@testing-library/jest-dom';
|
|
3
|
-
import { render, screen } from '@testing-library/react';
|
|
4
|
-
import userEvent from '@testing-library/user-event';
|
|
5
|
-
import Button from './Button';
|
|
6
|
-
describe('Button', () => {
|
|
7
|
-
class Context {
|
|
8
|
-
testId = 'buttonTestId';
|
|
9
|
-
label = 'button label';
|
|
10
|
-
props = {
|
|
11
|
-
label: this.label,
|
|
12
|
-
onClick: jest.fn(),
|
|
13
|
-
testId: this.testId,
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
let tc;
|
|
17
|
-
beforeEach(() => {
|
|
18
|
-
tc = new Context();
|
|
19
|
-
});
|
|
20
|
-
const renderButton = (props) => render(React.createElement(Button, { ...props }));
|
|
21
|
-
it('renders button label', () => {
|
|
22
|
-
renderButton(tc.props);
|
|
23
|
-
expect(screen.getByText(tc.label)).toBeInTheDocument();
|
|
24
|
-
});
|
|
25
|
-
it('calls on click', async () => {
|
|
26
|
-
renderButton(tc.props);
|
|
27
|
-
await userEvent.click(screen.getByTestId(tc.testId));
|
|
28
|
-
expect(tc.props.onClick).toHaveBeenCalled();
|
|
29
|
-
});
|
|
30
|
-
it('renders disabled button', () => {
|
|
31
|
-
renderButton({ ...tc.props, disabled: true });
|
|
32
|
-
expect(screen.getByText(tc.label)).toBeDisabled();
|
|
33
|
-
});
|
|
34
|
-
it('respects stopPropagation default', async () => {
|
|
35
|
-
const callOnPropagation = jest.fn();
|
|
36
|
-
render(React.createElement("div", { onClick: callOnPropagation },
|
|
37
|
-
React.createElement(Button, { ...tc.props })));
|
|
38
|
-
await userEvent.click(screen.getByTestId(tc.testId));
|
|
39
|
-
expect(callOnPropagation).not.toHaveBeenCalled();
|
|
40
|
-
});
|
|
41
|
-
it('propagates click event if not told not to', async () => {
|
|
42
|
-
const callOnPropagation = jest.fn();
|
|
43
|
-
render(React.createElement("div", { onClick: callOnPropagation },
|
|
44
|
-
React.createElement(Button, { ...{ ...tc.props, stopPropagation: false } })));
|
|
45
|
-
await userEvent.click(screen.getByTestId(tc.testId));
|
|
46
|
-
expect(callOnPropagation).toHaveBeenCalled();
|
|
47
|
-
});
|
|
48
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
import Button from './Button';
|
|
6
|
+
describe('Button', () => {
|
|
7
|
+
class Context {
|
|
8
|
+
testId = 'buttonTestId';
|
|
9
|
+
label = 'button label';
|
|
10
|
+
props = {
|
|
11
|
+
label: this.label,
|
|
12
|
+
onClick: jest.fn(),
|
|
13
|
+
testId: this.testId,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
let tc;
|
|
17
|
+
beforeEach(() => {
|
|
18
|
+
tc = new Context();
|
|
19
|
+
});
|
|
20
|
+
const renderButton = (props) => render(React.createElement(Button, { ...props }));
|
|
21
|
+
it('renders button label', () => {
|
|
22
|
+
renderButton(tc.props);
|
|
23
|
+
expect(screen.getByText(tc.label)).toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
it('calls on click', async () => {
|
|
26
|
+
renderButton(tc.props);
|
|
27
|
+
await userEvent.click(screen.getByTestId(tc.testId));
|
|
28
|
+
expect(tc.props.onClick).toHaveBeenCalled();
|
|
29
|
+
});
|
|
30
|
+
it('renders disabled button', () => {
|
|
31
|
+
renderButton({ ...tc.props, disabled: true });
|
|
32
|
+
expect(screen.getByText(tc.label)).toBeDisabled();
|
|
33
|
+
});
|
|
34
|
+
it('respects stopPropagation default', async () => {
|
|
35
|
+
const callOnPropagation = jest.fn();
|
|
36
|
+
render(React.createElement("div", { onClick: callOnPropagation },
|
|
37
|
+
React.createElement(Button, { ...tc.props })));
|
|
38
|
+
await userEvent.click(screen.getByTestId(tc.testId));
|
|
39
|
+
expect(callOnPropagation).not.toHaveBeenCalled();
|
|
40
|
+
});
|
|
41
|
+
it('propagates click event if not told not to', async () => {
|
|
42
|
+
const callOnPropagation = jest.fn();
|
|
43
|
+
render(React.createElement("div", { onClick: callOnPropagation },
|
|
44
|
+
React.createElement(Button, { ...{ ...tc.props, stopPropagation: false } })));
|
|
45
|
+
await userEvent.click(screen.getByTestId(tc.testId));
|
|
46
|
+
expect(callOnPropagation).toHaveBeenCalled();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
49
|
//# sourceMappingURL=Button.test.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const buttonTypes = ['button', 'reset', 'submit', 'link'];
|
|
2
|
-
export const buttonSizes = ['sm', 'lg'];
|
|
3
|
-
export const buttonVariants = ['outline', 'theme', 'theme-light', 'warning', 'danger', 'no-border'];
|
|
1
|
+
export const buttonTypes = ['button', 'reset', 'submit', 'link'];
|
|
2
|
+
export const buttonSizes = ['sm', 'lg'];
|
|
3
|
+
export const buttonVariants = ['outline', 'theme', 'theme-light', 'warning', 'danger', 'no-border'];
|
|
4
4
|
//# sourceMappingURL=Button.types.js.map
|
package/dist/Button/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from "./Button";
|
|
1
|
+
export { default } from "./Button";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import '../styles.css';
|
|
3
|
-
const alignment = 'tw-flex';
|
|
4
|
-
const labelClasses = 'tw-ml-1.5 tw-text-sm tw--mt-0.5';
|
|
5
|
-
const baseClasses = 'tw-border-1 tw-h-3.5 tw-w-3.5 focus:tw-ring-0 focus:tw-ring-offset-0 tw-outline-none focus:tw-outline-none' +
|
|
6
|
-
' dark:tw-bg-sq-dark-background dark:tw-border-sq-dark-text dark:hover:tw-bg-sq-dark-background' +
|
|
7
|
-
' checked:tw-text-white checked:tw-border-sq-text-color checked:hover:tw-border-sq-color-dark' +
|
|
8
|
-
' checked:active:tw-border-sq-color-dark checked:focus:tw-border-sq-color-dark disabled:tw-border-sq-disabled-gray' +
|
|
9
|
-
' dark:disabled:tw-border-sq-fairly-dark-gray dark:checked:focus:tw-bg-sq-dark-background';
|
|
10
|
-
const checkboxClasses = `tw-form-checkbox tw-rounded ${baseClasses}`;
|
|
11
|
-
const radioClasses = `tw-form-radio ${baseClasses}`;
|
|
12
|
-
/**
|
|
13
|
-
* Checkbox and Radio Box Component.
|
|
14
|
-
*/
|
|
15
|
-
export const Checkbox = (props) => {
|
|
16
|
-
const { type = 'checkbox', value, disabled = false, label, onChange, onClick, onKeyDown, checked, defaultChecked, id, name, extraClassNames, extraLabelClassNames, testId, } = props;
|
|
17
|
-
const assignedId = id ?? 'checkbox_' + Math.random();
|
|
18
|
-
return (React.createElement("span", { className: `${alignment} ${extraClassNames}` },
|
|
19
|
-
React.createElement("input", { value: value, type: type, "data-testid": testId, name: name, id: assignedId, checked: checked, defaultChecked: defaultChecked, className: `${type === 'checkbox' ? checkboxClasses : radioClasses} ${disabled ? 'tw-cursor-not-allowed' : 'tw-cursor-pointer'}`, disabled: disabled, onClick: onClick, onChange: onChange, onKeyDown: onKeyDown }),
|
|
20
|
-
React.createElement("label", { htmlFor: assignedId, className: `${labelClasses} ${extraLabelClassNames} ${disabled
|
|
21
|
-
? 'tw-cursor-not-allowed dark:tw-text-sq-fairly-dark-gray tw-text-sq-fairly-dark-gray'
|
|
22
|
-
: 'tw-cursor-pointer tw-text-sq-text-color dark:tw-text-sq-dark-text'}` }, label)));
|
|
23
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '../styles.css';
|
|
3
|
+
const alignment = 'tw-flex';
|
|
4
|
+
const labelClasses = 'tw-ml-1.5 tw-text-sm tw--mt-0.5';
|
|
5
|
+
const baseClasses = 'tw-border-1 tw-h-3.5 tw-w-3.5 focus:tw-ring-0 focus:tw-ring-offset-0 tw-outline-none focus:tw-outline-none' +
|
|
6
|
+
' dark:tw-bg-sq-dark-background dark:tw-border-sq-dark-text dark:hover:tw-bg-sq-dark-background' +
|
|
7
|
+
' checked:tw-text-white checked:tw-border-sq-text-color checked:hover:tw-border-sq-color-dark' +
|
|
8
|
+
' checked:active:tw-border-sq-color-dark checked:focus:tw-border-sq-color-dark disabled:tw-border-sq-disabled-gray' +
|
|
9
|
+
' dark:disabled:tw-border-sq-fairly-dark-gray dark:checked:focus:tw-bg-sq-dark-background';
|
|
10
|
+
const checkboxClasses = `tw-form-checkbox tw-rounded ${baseClasses}`;
|
|
11
|
+
const radioClasses = `tw-form-radio ${baseClasses}`;
|
|
12
|
+
/**
|
|
13
|
+
* Checkbox and Radio Box Component.
|
|
14
|
+
*/
|
|
15
|
+
export const Checkbox = (props) => {
|
|
16
|
+
const { type = 'checkbox', value, disabled = false, label, onChange, onClick, onKeyDown, checked, defaultChecked, id, name, extraClassNames, extraLabelClassNames, testId, } = props;
|
|
17
|
+
const assignedId = id ?? 'checkbox_' + Math.random();
|
|
18
|
+
return (React.createElement("span", { className: `${alignment} ${extraClassNames}` },
|
|
19
|
+
React.createElement("input", { value: value, type: type, "data-testid": testId, name: name, id: assignedId, checked: checked, defaultChecked: defaultChecked, className: `${type === 'checkbox' ? checkboxClasses : radioClasses} ${disabled ? 'tw-cursor-not-allowed' : 'tw-cursor-pointer'}`, disabled: disabled, onClick: onClick, onChange: onChange, onKeyDown: onKeyDown }),
|
|
20
|
+
React.createElement("label", { htmlFor: assignedId, className: `${labelClasses} ${extraLabelClassNames} ${disabled
|
|
21
|
+
? 'tw-cursor-not-allowed dark:tw-text-sq-fairly-dark-gray tw-text-sq-fairly-dark-gray'
|
|
22
|
+
: 'tw-cursor-pointer tw-text-sq-text-color dark:tw-text-sq-dark-text'}` }, label)));
|
|
23
|
+
};
|
|
24
24
|
//# sourceMappingURL=Checkbox.js.map
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Checkbox } from './Checkbox';
|
|
3
|
-
export default {
|
|
4
|
-
title: 'Checkbox',
|
|
5
|
-
};
|
|
6
|
-
export const AllCheckboxes = () => {
|
|
7
|
-
const getDisplay = (type) => (React.createElement(React.Fragment, null,
|
|
8
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
9
|
-
React.createElement(Checkbox, { value: "a", type: type, checked: true, label: 'with Label' })),
|
|
10
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
11
|
-
React.createElement(Checkbox, { value: "d", type: type, checked: false, disabled: true, label: React.createElement("div", null,
|
|
12
|
-
"Disabled",
|
|
13
|
-
React.createElement("br", null),
|
|
14
|
-
"multi-Line") })),
|
|
15
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
16
|
-
React.createElement(Checkbox, { value: "d", type: type, checked: true, disabled: true, label: "Disabled" })),
|
|
17
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
18
|
-
React.createElement(Checkbox, { value: "b", type: type, checked: true })),
|
|
19
|
-
React.createElement("div", { className: "tw-p-4" },
|
|
20
|
-
React.createElement(Checkbox, { value: "c", type: type, checked: false }))));
|
|
21
|
-
const renderAllVariations = (type) => (React.createElement(React.Fragment, null,
|
|
22
|
-
React.createElement("div", { className: "tw-p-4 light" }, getDisplay(type)),
|
|
23
|
-
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" }, getDisplay(type))));
|
|
24
|
-
return (React.createElement("div", { className: "tw-grid tw-grid-cols-2 tw-gap-4" },
|
|
25
|
-
React.createElement("div", null,
|
|
26
|
-
React.createElement("b", null, "Checkbox"),
|
|
27
|
-
renderAllVariations('checkbox')),
|
|
28
|
-
React.createElement("div", null,
|
|
29
|
-
React.createElement("b", null, "Radios"),
|
|
30
|
-
renderAllVariations('radio'))));
|
|
31
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Checkbox } from './Checkbox';
|
|
3
|
+
export default {
|
|
4
|
+
title: 'Checkbox',
|
|
5
|
+
};
|
|
6
|
+
export const AllCheckboxes = () => {
|
|
7
|
+
const getDisplay = (type) => (React.createElement(React.Fragment, null,
|
|
8
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
9
|
+
React.createElement(Checkbox, { value: "a", type: type, checked: true, label: 'with Label' })),
|
|
10
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
11
|
+
React.createElement(Checkbox, { value: "d", type: type, checked: false, disabled: true, label: React.createElement("div", null,
|
|
12
|
+
"Disabled",
|
|
13
|
+
React.createElement("br", null),
|
|
14
|
+
"multi-Line") })),
|
|
15
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
16
|
+
React.createElement(Checkbox, { value: "d", type: type, checked: true, disabled: true, label: "Disabled" })),
|
|
17
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
18
|
+
React.createElement(Checkbox, { value: "b", type: type, checked: true })),
|
|
19
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
20
|
+
React.createElement(Checkbox, { value: "c", type: type, checked: false }))));
|
|
21
|
+
const renderAllVariations = (type) => (React.createElement(React.Fragment, null,
|
|
22
|
+
React.createElement("div", { className: "tw-p-4 light" }, getDisplay(type)),
|
|
23
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" }, getDisplay(type))));
|
|
24
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-2 tw-gap-4" },
|
|
25
|
+
React.createElement("div", null,
|
|
26
|
+
React.createElement("b", null, "Checkbox"),
|
|
27
|
+
renderAllVariations('checkbox')),
|
|
28
|
+
React.createElement("div", null,
|
|
29
|
+
React.createElement("b", null, "Radios"),
|
|
30
|
+
renderAllVariations('radio'))));
|
|
31
|
+
};
|
|
32
32
|
//# sourceMappingURL=Checkbox.stories.js.map
|
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import '@testing-library/jest-dom';
|
|
3
|
-
import { render, screen } from '@testing-library/react';
|
|
4
|
-
import { Checkbox } from './Checkbox';
|
|
5
|
-
import userEvent from '@testing-library/user-event';
|
|
6
|
-
describe('Checkbox', () => {
|
|
7
|
-
class Context {
|
|
8
|
-
testId = 'checkboxTestId';
|
|
9
|
-
props = {
|
|
10
|
-
onChange: jest.fn(),
|
|
11
|
-
checked: false,
|
|
12
|
-
testId: this.testId,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
let tc;
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
tc = new Context();
|
|
18
|
-
});
|
|
19
|
-
const renderCheckbox = (props) => render(React.createElement(Checkbox, { ...props }));
|
|
20
|
-
it('renders checkbox', () => {
|
|
21
|
-
renderCheckbox(tc.props);
|
|
22
|
-
expect(screen.getByTestId(tc.testId)).toBeInTheDocument();
|
|
23
|
-
});
|
|
24
|
-
it('renders radio', () => {
|
|
25
|
-
renderCheckbox({ ...tc.props, type: 'radio' });
|
|
26
|
-
expect(screen.getByTestId(tc.testId)).toHaveProperty('type', 'radio');
|
|
27
|
-
});
|
|
28
|
-
it('renders label', () => {
|
|
29
|
-
const label = 'look at this checkbox!';
|
|
30
|
-
renderCheckbox({ ...tc.props, label });
|
|
31
|
-
expect(screen.getByText(label)).toBeInTheDocument();
|
|
32
|
-
});
|
|
33
|
-
it('respects checked', () => {
|
|
34
|
-
renderCheckbox({ ...tc.props, checked: true });
|
|
35
|
-
expect(screen.getByTestId(tc.testId)).toBeChecked();
|
|
36
|
-
});
|
|
37
|
-
it('calls onChange handler', async () => {
|
|
38
|
-
const onChange = jest.fn();
|
|
39
|
-
renderCheckbox({ ...tc.props, onChange });
|
|
40
|
-
await userEvent.click(screen.getByTestId(tc.testId));
|
|
41
|
-
expect(onChange).toHaveBeenCalled();
|
|
42
|
-
});
|
|
43
|
-
it('calls onKeyDown handler', async () => {
|
|
44
|
-
const onKeyDown = jest.fn();
|
|
45
|
-
renderCheckbox({ ...tc.props, onKeyDown });
|
|
46
|
-
await userEvent.type(screen.getByTestId(tc.testId), 'a');
|
|
47
|
-
expect(onKeyDown).toHaveBeenCalled();
|
|
48
|
-
});
|
|
49
|
-
it('calls onClickHandler handler', async () => {
|
|
50
|
-
const onClick = jest.fn();
|
|
51
|
-
renderCheckbox({ ...tc.props, onClick });
|
|
52
|
-
await userEvent.click(screen.getByTestId(tc.testId));
|
|
53
|
-
expect(onClick).toHaveBeenCalled();
|
|
54
|
-
});
|
|
55
|
-
it('respects disabled', () => {
|
|
56
|
-
renderCheckbox({ ...tc.props, disabled: true });
|
|
57
|
-
expect(screen.getByTestId(tc.testId)).not.toBeEnabled();
|
|
58
|
-
});
|
|
59
|
-
it('renders label clickable', async () => {
|
|
60
|
-
const label = 'amazing checkbox';
|
|
61
|
-
const onClick = jest.fn();
|
|
62
|
-
renderCheckbox({ ...tc.props, label, onClick });
|
|
63
|
-
expect(screen.getByTestId(tc.testId)).not.toBeChecked();
|
|
64
|
-
await userEvent.click(screen.getByText(label));
|
|
65
|
-
expect(onClick).toHaveBeenCalled();
|
|
66
|
-
});
|
|
67
|
-
it('respects id', () => {
|
|
68
|
-
const id = 'checkboxId';
|
|
69
|
-
renderCheckbox({ ...tc.props, id });
|
|
70
|
-
expect(screen.getByTestId(tc.testId)).toHaveProperty('id', id);
|
|
71
|
-
});
|
|
72
|
-
it('respects name', () => {
|
|
73
|
-
const name = 'checkboxName';
|
|
74
|
-
renderCheckbox({ ...tc.props, name });
|
|
75
|
-
expect(screen.getByTestId(tc.testId)).toHaveProperty('name', name);
|
|
76
|
-
});
|
|
77
|
-
it('respects name', () => {
|
|
78
|
-
const value = 'priceless';
|
|
79
|
-
renderCheckbox({ ...tc.props, value });
|
|
80
|
-
expect(screen.getByTestId(tc.testId)).toHaveProperty('value', value);
|
|
81
|
-
});
|
|
82
|
-
it('applies extraClassNames', () => {
|
|
83
|
-
const extraClassNames = 'extra styling so fancy';
|
|
84
|
-
renderCheckbox({ ...tc.props, extraClassNames });
|
|
85
|
-
expect(screen.getByTestId(tc.testId).parentNode).toHaveClass(extraClassNames);
|
|
86
|
-
});
|
|
87
|
-
it('applies extraLabelClassNames', () => {
|
|
88
|
-
const extraLabelClassNames = 'special label';
|
|
89
|
-
const label = 'amazing checkbox';
|
|
90
|
-
renderCheckbox({ ...tc.props, extraLabelClassNames, label });
|
|
91
|
-
expect(screen.getByText(label)).toHaveClass(extraLabelClassNames);
|
|
92
|
-
});
|
|
93
|
-
});
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
import { render, screen } from '@testing-library/react';
|
|
4
|
+
import { Checkbox } from './Checkbox';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
6
|
+
describe('Checkbox', () => {
|
|
7
|
+
class Context {
|
|
8
|
+
testId = 'checkboxTestId';
|
|
9
|
+
props = {
|
|
10
|
+
onChange: jest.fn(),
|
|
11
|
+
checked: false,
|
|
12
|
+
testId: this.testId,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
let tc;
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
tc = new Context();
|
|
18
|
+
});
|
|
19
|
+
const renderCheckbox = (props) => render(React.createElement(Checkbox, { ...props }));
|
|
20
|
+
it('renders checkbox', () => {
|
|
21
|
+
renderCheckbox(tc.props);
|
|
22
|
+
expect(screen.getByTestId(tc.testId)).toBeInTheDocument();
|
|
23
|
+
});
|
|
24
|
+
it('renders radio', () => {
|
|
25
|
+
renderCheckbox({ ...tc.props, type: 'radio' });
|
|
26
|
+
expect(screen.getByTestId(tc.testId)).toHaveProperty('type', 'radio');
|
|
27
|
+
});
|
|
28
|
+
it('renders label', () => {
|
|
29
|
+
const label = 'look at this checkbox!';
|
|
30
|
+
renderCheckbox({ ...tc.props, label });
|
|
31
|
+
expect(screen.getByText(label)).toBeInTheDocument();
|
|
32
|
+
});
|
|
33
|
+
it('respects checked', () => {
|
|
34
|
+
renderCheckbox({ ...tc.props, checked: true });
|
|
35
|
+
expect(screen.getByTestId(tc.testId)).toBeChecked();
|
|
36
|
+
});
|
|
37
|
+
it('calls onChange handler', async () => {
|
|
38
|
+
const onChange = jest.fn();
|
|
39
|
+
renderCheckbox({ ...tc.props, onChange });
|
|
40
|
+
await userEvent.click(screen.getByTestId(tc.testId));
|
|
41
|
+
expect(onChange).toHaveBeenCalled();
|
|
42
|
+
});
|
|
43
|
+
it('calls onKeyDown handler', async () => {
|
|
44
|
+
const onKeyDown = jest.fn();
|
|
45
|
+
renderCheckbox({ ...tc.props, onKeyDown });
|
|
46
|
+
await userEvent.type(screen.getByTestId(tc.testId), 'a');
|
|
47
|
+
expect(onKeyDown).toHaveBeenCalled();
|
|
48
|
+
});
|
|
49
|
+
it('calls onClickHandler handler', async () => {
|
|
50
|
+
const onClick = jest.fn();
|
|
51
|
+
renderCheckbox({ ...tc.props, onClick });
|
|
52
|
+
await userEvent.click(screen.getByTestId(tc.testId));
|
|
53
|
+
expect(onClick).toHaveBeenCalled();
|
|
54
|
+
});
|
|
55
|
+
it('respects disabled', () => {
|
|
56
|
+
renderCheckbox({ ...tc.props, disabled: true });
|
|
57
|
+
expect(screen.getByTestId(tc.testId)).not.toBeEnabled();
|
|
58
|
+
});
|
|
59
|
+
it('renders label clickable', async () => {
|
|
60
|
+
const label = 'amazing checkbox';
|
|
61
|
+
const onClick = jest.fn();
|
|
62
|
+
renderCheckbox({ ...tc.props, label, onClick });
|
|
63
|
+
expect(screen.getByTestId(tc.testId)).not.toBeChecked();
|
|
64
|
+
await userEvent.click(screen.getByText(label));
|
|
65
|
+
expect(onClick).toHaveBeenCalled();
|
|
66
|
+
});
|
|
67
|
+
it('respects id', () => {
|
|
68
|
+
const id = 'checkboxId';
|
|
69
|
+
renderCheckbox({ ...tc.props, id });
|
|
70
|
+
expect(screen.getByTestId(tc.testId)).toHaveProperty('id', id);
|
|
71
|
+
});
|
|
72
|
+
it('respects name', () => {
|
|
73
|
+
const name = 'checkboxName';
|
|
74
|
+
renderCheckbox({ ...tc.props, name });
|
|
75
|
+
expect(screen.getByTestId(tc.testId)).toHaveProperty('name', name);
|
|
76
|
+
});
|
|
77
|
+
it('respects name', () => {
|
|
78
|
+
const value = 'priceless';
|
|
79
|
+
renderCheckbox({ ...tc.props, value });
|
|
80
|
+
expect(screen.getByTestId(tc.testId)).toHaveProperty('value', value);
|
|
81
|
+
});
|
|
82
|
+
it('applies extraClassNames', () => {
|
|
83
|
+
const extraClassNames = 'extra styling so fancy';
|
|
84
|
+
renderCheckbox({ ...tc.props, extraClassNames });
|
|
85
|
+
expect(screen.getByTestId(tc.testId).parentNode).toHaveClass(extraClassNames);
|
|
86
|
+
});
|
|
87
|
+
it('applies extraLabelClassNames', () => {
|
|
88
|
+
const extraLabelClassNames = 'special label';
|
|
89
|
+
const label = 'amazing checkbox';
|
|
90
|
+
renderCheckbox({ ...tc.props, extraLabelClassNames, label });
|
|
91
|
+
expect(screen.getByText(label)).toHaveClass(extraLabelClassNames);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
94
|
//# sourceMappingURL=Checkbox.test.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=Checkbox.types.js.map
|
package/dist/Checkbox/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Checkbox as default } from './Checkbox';
|
|
1
|
+
export { Checkbox as default } from './Checkbox';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/FontCustom.woff
CHANGED
|
Binary file
|
package/dist/FontCustom.woff2
CHANGED
|
Binary file
|
package/dist/Icon/Icon.js
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import '../styles.css';
|
|
3
|
-
import { DEFAULT_TOOL_TIP_DELAY } from '../Tooltip/Tooltip.types';
|
|
4
|
-
const colorClassesThemeLight = {
|
|
5
|
-
'theme': 'tw-text-sq-color-dark',
|
|
6
|
-
'white': 'tw-text-white',
|
|
7
|
-
'dark-gray': 'tw-text-sq-fairly-dark-gray',
|
|
8
|
-
'warning': 'tw-text-sq-warning-color',
|
|
9
|
-
'darkish-gray': 'tw-text-sq-darkish-gray',
|
|
10
|
-
'gray': 'tw-text-sq-disabled-gray',
|
|
11
|
-
'color': '',
|
|
12
|
-
'info': 'tw-text-sq-link',
|
|
13
|
-
'text': 'tw-text-sq-text-color',
|
|
14
|
-
'inherit': '',
|
|
15
|
-
'danger': 'tw-text-sq-danger-color',
|
|
16
|
-
'theme-light': 'tw-text-sq-color-light',
|
|
17
|
-
'success': 'tw-text-sq-success-color',
|
|
18
|
-
};
|
|
19
|
-
const colorClassesThemeDark = {
|
|
20
|
-
'theme': 'dark:tw-text-sq-color-dark-dark',
|
|
21
|
-
'white': '',
|
|
22
|
-
'dark-gray': 'tw-text-sq-fairly-dark-gray',
|
|
23
|
-
'warning': '',
|
|
24
|
-
'darkish-gray': 'tw-text-sq-darkish-gray',
|
|
25
|
-
'gray': 'dark:tw-text-sq-dark-disabled-gray',
|
|
26
|
-
'color': '',
|
|
27
|
-
'info': 'dark:tw-text-sq-link-dark',
|
|
28
|
-
'text': 'dark:tw-text-sq-dark-text',
|
|
29
|
-
'inherit': '',
|
|
30
|
-
'danger': 'tw-text-sq-danger-color',
|
|
31
|
-
'theme-light': 'tw-text-sq-color-light',
|
|
32
|
-
'success': 'tw-text-sq-success-color',
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Icon:
|
|
36
|
-
* - access to Seeq custom icons by providing the desired icon
|
|
37
|
-
* - leverage "type" to style your icon
|
|
38
|
-
*/
|
|
39
|
-
const Icon = ({ onClick, icon, iconPrefix = undefined, type = 'theme', extraClassNames, id, large, small, color, testId, customId, tooltip, tooltipPlacement, number, isHtmlTooltip = false, tooltipTestId, tooltipDelay = DEFAULT_TOOL_TIP_DELAY, }) => {
|
|
40
|
-
if ((type === 'color' && (color === undefined || color === '')) || (color && type !== 'color')) {
|
|
41
|
-
const errorMessage = color === undefined || color === ''
|
|
42
|
-
? 'Icon with type="color" must have prop color specified.'
|
|
43
|
-
: 'Icon with prop color must have type="color".';
|
|
44
|
-
return React.createElement("div", { className: "tw-text-sq-danger-color" }, errorMessage);
|
|
45
|
-
}
|
|
46
|
-
const fontAwesomePrefix = iconPrefix ? iconPrefix : 'fa-sharp fa-regular';
|
|
47
|
-
const iconPrefixString = icon.startsWith('fc') ? 'fc' : fontAwesomePrefix;
|
|
48
|
-
const style = type === 'color' && color ? { color } : {};
|
|
49
|
-
const appliedClassNames = `${iconPrefixString} ${icon} ${small ? 'fa-sm' : ''} ${large ? 'fa-lg' : ''}
|
|
50
|
-
${colorClassesThemeLight[type]} ${colorClassesThemeDark[type]} ${onClick ? 'cursor-pointer' : ''} ${extraClassNames}`;
|
|
51
|
-
const tooltipData = tooltip
|
|
52
|
-
? {
|
|
53
|
-
'data-qtip-text': tooltip,
|
|
54
|
-
'data-qtip-placement': tooltipPlacement,
|
|
55
|
-
'data-qtip-is-html': isHtmlTooltip,
|
|
56
|
-
'data-qtip-testid': tooltipTestId,
|
|
57
|
-
'data-qtip-delay': tooltipDelay,
|
|
58
|
-
}
|
|
59
|
-
: undefined;
|
|
60
|
-
return (React.createElement("i", { className: appliedClassNames, style: style, onClick: onClick, "data-testid": testId, "data-customid": customId, id: id, "data-number": number, ...tooltipData }));
|
|
61
|
-
};
|
|
62
|
-
export default Icon;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '../styles.css';
|
|
3
|
+
import { DEFAULT_TOOL_TIP_DELAY } from '../Tooltip/Tooltip.types';
|
|
4
|
+
const colorClassesThemeLight = {
|
|
5
|
+
'theme': 'tw-text-sq-color-dark',
|
|
6
|
+
'white': 'tw-text-white',
|
|
7
|
+
'dark-gray': 'tw-text-sq-fairly-dark-gray',
|
|
8
|
+
'warning': 'tw-text-sq-warning-color',
|
|
9
|
+
'darkish-gray': 'tw-text-sq-darkish-gray',
|
|
10
|
+
'gray': 'tw-text-sq-disabled-gray',
|
|
11
|
+
'color': '',
|
|
12
|
+
'info': 'tw-text-sq-link',
|
|
13
|
+
'text': 'tw-text-sq-text-color',
|
|
14
|
+
'inherit': '',
|
|
15
|
+
'danger': 'tw-text-sq-danger-color',
|
|
16
|
+
'theme-light': 'tw-text-sq-color-light',
|
|
17
|
+
'success': 'tw-text-sq-success-color',
|
|
18
|
+
};
|
|
19
|
+
const colorClassesThemeDark = {
|
|
20
|
+
'theme': 'dark:tw-text-sq-color-dark-dark',
|
|
21
|
+
'white': '',
|
|
22
|
+
'dark-gray': 'tw-text-sq-fairly-dark-gray',
|
|
23
|
+
'warning': '',
|
|
24
|
+
'darkish-gray': 'tw-text-sq-darkish-gray',
|
|
25
|
+
'gray': 'dark:tw-text-sq-dark-disabled-gray',
|
|
26
|
+
'color': '',
|
|
27
|
+
'info': 'dark:tw-text-sq-link-dark',
|
|
28
|
+
'text': 'dark:tw-text-sq-dark-text',
|
|
29
|
+
'inherit': '',
|
|
30
|
+
'danger': 'tw-text-sq-danger-color',
|
|
31
|
+
'theme-light': 'tw-text-sq-color-light',
|
|
32
|
+
'success': 'tw-text-sq-success-color',
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Icon:
|
|
36
|
+
* - access to Seeq custom icons by providing the desired icon
|
|
37
|
+
* - leverage "type" to style your icon
|
|
38
|
+
*/
|
|
39
|
+
const Icon = ({ onClick, icon, iconPrefix = undefined, type = 'theme', extraClassNames, id, large, small, color, testId, customId, tooltip, tooltipPlacement, number, isHtmlTooltip = false, tooltipTestId, tooltipDelay = DEFAULT_TOOL_TIP_DELAY, }) => {
|
|
40
|
+
if ((type === 'color' && (color === undefined || color === '')) || (color && type !== 'color')) {
|
|
41
|
+
const errorMessage = color === undefined || color === ''
|
|
42
|
+
? 'Icon with type="color" must have prop color specified.'
|
|
43
|
+
: 'Icon with prop color must have type="color".';
|
|
44
|
+
return React.createElement("div", { className: "tw-text-sq-danger-color" }, errorMessage);
|
|
45
|
+
}
|
|
46
|
+
const fontAwesomePrefix = iconPrefix ? iconPrefix : 'fa-sharp fa-regular';
|
|
47
|
+
const iconPrefixString = icon.startsWith('fc') ? 'fc' : fontAwesomePrefix;
|
|
48
|
+
const style = type === 'color' && color ? { color } : {};
|
|
49
|
+
const appliedClassNames = `${iconPrefixString} ${icon} ${small ? 'fa-sm' : ''} ${large ? 'fa-lg' : ''}
|
|
50
|
+
${colorClassesThemeLight[type]} ${colorClassesThemeDark[type]} ${onClick ? 'cursor-pointer' : ''} ${extraClassNames}`;
|
|
51
|
+
const tooltipData = tooltip
|
|
52
|
+
? {
|
|
53
|
+
'data-qtip-text': tooltip,
|
|
54
|
+
'data-qtip-placement': tooltipPlacement,
|
|
55
|
+
'data-qtip-is-html': isHtmlTooltip,
|
|
56
|
+
'data-qtip-testid': tooltipTestId,
|
|
57
|
+
'data-qtip-delay': tooltipDelay,
|
|
58
|
+
}
|
|
59
|
+
: undefined;
|
|
60
|
+
return (React.createElement("i", { className: appliedClassNames, style: style, onClick: onClick, "data-testid": testId, "data-customid": customId, id: id, "data-number": number, ...tooltipData }));
|
|
61
|
+
};
|
|
62
|
+
export default Icon;
|
|
63
63
|
//# sourceMappingURL=Icon.js.map
|