@seeqdev/qomponents 0.0.14 → 0.0.15
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 +76 -2
- package/dist/Button/Button.js +71 -0
- package/dist/Button/Button.js.map +1 -0
- package/dist/Button/Button.stories.js +58 -0
- package/dist/Button/Button.stories.js.map +1 -0
- package/dist/Button/Button.test.js +49 -0
- package/dist/Button/Button.test.js.map +1 -0
- package/dist/Button/Button.types.js +4 -0
- package/dist/Button/Button.types.js.map +1 -0
- package/dist/Button/index.js +2 -0
- package/dist/Button/index.js.map +1 -0
- package/dist/Checkbox/Checkbox.js +23 -0
- package/dist/Checkbox/Checkbox.js.map +1 -0
- package/dist/Checkbox/Checkbox.stories.js +29 -0
- package/dist/Checkbox/Checkbox.stories.js.map +1 -0
- package/dist/Checkbox/Checkbox.test.js +94 -0
- package/dist/Checkbox/Checkbox.test.js.map +1 -0
- package/dist/Checkbox/Checkbox.types.js +2 -0
- package/dist/Checkbox/Checkbox.types.js.map +1 -0
- package/dist/Checkbox/index.js +2 -0
- package/dist/Checkbox/index.js.map +1 -0
- package/dist/Icon/Icon.js +54 -0
- package/dist/Icon/Icon.js.map +1 -0
- package/dist/Icon/Icon.stories.js +40 -0
- package/dist/Icon/Icon.stories.js.map +1 -0
- package/dist/Icon/Icon.test.js +55 -0
- package/dist/Icon/Icon.test.js.map +1 -0
- package/dist/Icon/Icon.types.js +16 -0
- package/dist/Icon/Icon.types.js.map +1 -0
- package/dist/Icon/index.js +2 -0
- package/dist/Icon/index.js.map +1 -0
- package/dist/Select/Select.js +168 -0
- package/dist/Select/Select.js.map +1 -0
- package/dist/Select/Select.stories.js +72 -0
- package/dist/Select/Select.stories.js.map +1 -0
- package/dist/Select/Select.test.js +161 -0
- package/dist/Select/Select.test.js.map +1 -0
- package/dist/Select/Select.types.js +2 -0
- package/dist/Select/Select.types.js.map +1 -0
- package/dist/Select/index.js +2 -0
- package/dist/Select/index.js.map +1 -0
- package/dist/TextArea/TextArea.js +15 -0
- package/dist/TextArea/TextArea.js.map +1 -0
- package/dist/TextArea/TextArea.stories.js +35 -0
- package/dist/TextArea/TextArea.stories.js.map +1 -0
- package/dist/TextArea/TextArea.test.js +68 -0
- package/dist/TextArea/TextArea.test.js.map +1 -0
- package/dist/TextArea/TextArea.types.js +2 -0
- package/dist/TextArea/TextArea.types.js.map +1 -0
- package/dist/TextArea/index.js +2 -0
- package/dist/TextArea/index.js.map +1 -0
- package/dist/TextField/TextField.js +56 -0
- package/dist/TextField/TextField.js.map +1 -0
- package/dist/TextField/TextField.stories.js +37 -0
- package/dist/TextField/TextField.stories.js.map +1 -0
- package/dist/TextField/TextField.test.js +35 -0
- package/dist/TextField/TextField.test.js.map +1 -0
- package/dist/TextField/TextField.types.js +2 -0
- package/dist/TextField/TextField.types.js.map +1 -0
- package/dist/TextField/index.js +2 -0
- package/dist/TextField/index.js.map +1 -0
- package/dist/Tooltip/Tooltip.js +30 -0
- package/dist/Tooltip/Tooltip.js.map +1 -0
- package/dist/Tooltip/Tooltip.stories.js +32 -0
- package/dist/Tooltip/Tooltip.stories.js.map +1 -0
- package/dist/Tooltip/Tooltip.types.js +3 -0
- package/dist/Tooltip/Tooltip.types.js.map +1 -0
- package/dist/Tooltip/index.js +2 -0
- package/dist/Tooltip/index.js.map +1 -0
- package/dist/example/.eslintrc.cjs +14 -0
- package/dist/example/README.md +33 -0
- package/dist/example/index.html +13 -0
- package/dist/example/package.json +30 -0
- package/dist/example/src/Example.tsx +146 -0
- package/dist/example/src/index.css +73 -0
- package/dist/example/src/main.tsx +10 -0
- package/dist/example/src/vite-env.d.ts +1 -0
- package/dist/example/tsconfig.json +33 -0
- package/dist/example/tsconfig.node.json +10 -0
- package/dist/example/vite.config.ts +12 -0
- package/dist/index.esm.js +3 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/browserId.js +29 -0
- package/dist/utils/browserId.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,68 @@
|
|
|
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 { TextArea } from './TextArea';
|
|
6
|
+
describe('TextArea', () => {
|
|
7
|
+
class Context {
|
|
8
|
+
testId = 'textAreaTestId';
|
|
9
|
+
props = {
|
|
10
|
+
onChange: jest.fn(),
|
|
11
|
+
onKeyUp: jest.fn(),
|
|
12
|
+
testId: this.testId,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
let tc;
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
tc = new Context();
|
|
18
|
+
});
|
|
19
|
+
const renderTextArea = (props) => render(React.createElement(TextArea, { ...props }));
|
|
20
|
+
it('renders the provided value', () => {
|
|
21
|
+
const value = 'hello, this is text for a text area.';
|
|
22
|
+
renderTextArea({ ...tc.props, value });
|
|
23
|
+
expect(screen.getByDisplayValue(value)).toBeInTheDocument();
|
|
24
|
+
});
|
|
25
|
+
it('renders the provided placeholder', () => {
|
|
26
|
+
const placeholder = 'Prompt to enter';
|
|
27
|
+
renderTextArea({ ...tc.props, placeholder });
|
|
28
|
+
expect(screen.getByPlaceholderText(placeholder)).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
it('calls onChange handler', async () => {
|
|
31
|
+
renderTextArea({ ...tc.props });
|
|
32
|
+
await userEvent.type(screen.getByTestId(tc.testId), 'trigger');
|
|
33
|
+
expect(tc.props.onChange).toHaveBeenCalled();
|
|
34
|
+
});
|
|
35
|
+
it('calls the onKeyUp handler', async () => {
|
|
36
|
+
renderTextArea({ ...tc.props });
|
|
37
|
+
await userEvent.type(screen.getByTestId(tc.testId), 'trigger');
|
|
38
|
+
expect(tc.props.onKeyUp).toHaveBeenCalled();
|
|
39
|
+
});
|
|
40
|
+
it('respects readOnly', async () => {
|
|
41
|
+
renderTextArea({ ...tc.props, readonly: true });
|
|
42
|
+
expect(screen.getByTestId(tc.testId)).not.toBeEnabled();
|
|
43
|
+
});
|
|
44
|
+
it('provides rows', async () => {
|
|
45
|
+
renderTextArea({ ...tc.props, rows: 7 });
|
|
46
|
+
expect(screen.getByTestId(tc.testId)).toHaveProperty('rows', 7);
|
|
47
|
+
});
|
|
48
|
+
it('provides cols', async () => {
|
|
49
|
+
renderTextArea({ ...tc.props, cols: 8 });
|
|
50
|
+
expect(screen.getByTestId(tc.testId)).toHaveProperty('cols', 8);
|
|
51
|
+
});
|
|
52
|
+
it('provides name', async () => {
|
|
53
|
+
const name = 'myTextArea';
|
|
54
|
+
renderTextArea({ ...tc.props, name });
|
|
55
|
+
expect(screen.getByTestId(tc.testId)).toHaveProperty('name', name);
|
|
56
|
+
});
|
|
57
|
+
it('provides id', async () => {
|
|
58
|
+
const id = 'myTextId';
|
|
59
|
+
renderTextArea({ ...tc.props, id });
|
|
60
|
+
expect(screen.getByTestId(tc.testId)).toHaveProperty('id', id);
|
|
61
|
+
});
|
|
62
|
+
it('provides extraClassNames', async () => {
|
|
63
|
+
const extraClassNames = 'extra css';
|
|
64
|
+
renderTextArea({ ...tc.props, extraClassNames });
|
|
65
|
+
expect(screen.getByTestId(tc.testId)).toHaveClass(extraClassNames);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=TextArea.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextArea.test.js","sourceRoot":"","sources":["../../src/TextArea/TextArea.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,SAAS,MAAM,6BAA6B,CAAC;AAGpD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,C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CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,eAAe,EAAE,KAAK,IAAI,EAAE;QAC7B,MAAM,IAAI,GAAG,YAAY,CAAC;QAC1B,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACtC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,aAAa,EAAE,KAAK,IAAI,EAAE;QAC3B,MAAM,EAAE,GAAG,UAAU,CAAC;QACtB,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;QACpC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,0BAA0B,EAAE,KAAK,IAAI,EAAE;QACxC,MAAM,eAAe,GAAG,WAAW,CAAC;QACpC,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,CAAC,CAAC;QACjD,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;IACrE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextArea.types.js","sourceRoot":"","sources":["../../src/TextArea/TextArea.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/TextArea/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import '../styles.css';
|
|
3
|
+
/**
|
|
4
|
+
* Textfield.
|
|
5
|
+
*/
|
|
6
|
+
export const TextField = React.forwardRef((props, ref) => {
|
|
7
|
+
const { readonly = false, onChange, onKeyUp, id, name, size = 'sm', value, placeholder, extraClassNames, testId, type = 'text', inputGroup, step, } = props;
|
|
8
|
+
const internalRef = useRef(null);
|
|
9
|
+
const [cursor, setCursor] = useState(null);
|
|
10
|
+
const setAllRefs = (receivedRef) => {
|
|
11
|
+
if (ref)
|
|
12
|
+
ref.current = receivedRef;
|
|
13
|
+
internalRef.current = receivedRef;
|
|
14
|
+
};
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
const input = internalRef.current;
|
|
17
|
+
if (input && type !== 'number')
|
|
18
|
+
input.setSelectionRange(cursor, cursor);
|
|
19
|
+
}, [ref, cursor, value]);
|
|
20
|
+
const handleChange = (e) => {
|
|
21
|
+
setCursor(e.target.selectionStart);
|
|
22
|
+
onChange && onChange(e);
|
|
23
|
+
};
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
/**
|
|
26
|
+
* we need to change the value only if it's different since the internal state of "input" will change it anyway
|
|
27
|
+
* this will only be the case when the value has been changed externally via store (undo / redo)
|
|
28
|
+
*/
|
|
29
|
+
if (value !== null && value !== undefined && value !== internalRef.current?.value && internalRef.current) {
|
|
30
|
+
// we need to use this method because using the value props directly will switch the input to a "controlled"
|
|
31
|
+
// component
|
|
32
|
+
internalRef.current.value = `${value}`;
|
|
33
|
+
}
|
|
34
|
+
}, [value]);
|
|
35
|
+
const baseClasses = 'tw-h-inputs tw-leading-normal tw-outline-none tw-py-1 tw-px-3' +
|
|
36
|
+
' disabled:tw-pointer-events-none' +
|
|
37
|
+
' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border tw-placeholder-gray-400' +
|
|
38
|
+
' dark:tw-placeholder-sq-dark-text-lighter specTextField';
|
|
39
|
+
const darkTheme = 'dark:tw-border-sq-dark-disabled-gray dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text' +
|
|
40
|
+
' dark:focus:tw-border-sq-color-dark-dark dark:active:tw-border-sq-color-dark-dark';
|
|
41
|
+
const lightTheme = 'tw-border-sq-disabled-gray tw-text-sq-text-color focus:tw-border-sq-color-dark active:tw-border-sq-color-dark';
|
|
42
|
+
const sizeClasses = {
|
|
43
|
+
sm: 'tw-text-sm',
|
|
44
|
+
lg: 'tw-text-xl',
|
|
45
|
+
};
|
|
46
|
+
let borderRadius = 'tw-rounded-sm';
|
|
47
|
+
if (inputGroup === 'left') {
|
|
48
|
+
borderRadius = 'tw-rounded-l-sm tw-border-r-0 focus:tw-border-r' + ' active:tw-border-r';
|
|
49
|
+
}
|
|
50
|
+
else if (inputGroup === 'right') {
|
|
51
|
+
borderRadius = 'tw-rounded-r-sm tw-border-l-0 focus:tw-border-l active:tw-border-l';
|
|
52
|
+
}
|
|
53
|
+
const appliedClasses = `${baseClasses} ${sizeClasses[size]} ${extraClassNames} ${lightTheme} ${darkTheme} ${borderRadius}`;
|
|
54
|
+
return (React.createElement("input", { ref: setAllRefs, "data-testid": testId, name: name, id: id, type: type, value: value, className: appliedClasses, placeholder: placeholder, disabled: readonly, autoComplete: "none", onChange: handleChange, onKeyUp: onKeyUp, step: step }));
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=TextField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.js","sourceRoot":"","sources":["../../src/TextField/TextField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE3D,OAAO,eAAe,CAAC;AAEvB;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAA4C,KA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AW,CAAC,OAAO,CAAC,KAAK,GAAG,GAAG,KAAK,EAAE,CAAC;SACxC;IACH,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,MAAM,WAAW,GACf,+DAA+D;QAC/D,kCAAkC;QAClC,0FAA0F;QAC1F,0DAA0D,CAAC;IAE7D,MAAM,SAAS,GACb,8FAA8F;QAC9F,mFAAmF,CAAC;IACtF,MAAM,UAAU,GACd,+GAA+G,CAAC;IAElH,MAAM,WAAW,GAAG;QAClB,EAAE,EAAE,YAAY;QAChB,EAAE,EAAE,YAAY;KACjB,CAAC;IACF,IAAI,YAAY,GAAG,eAAe,CAAC;IACnC,IAAI,UAAU,KAAK,MAAM,EAAE;QACzB,YAAY,GAAG,iDAAiD,GAAG,qBAAqB,CAAC;KAC1F;SAAM,IAAI,UAAU,KAAK,OAAO,EAAE;QACjC,YAAY,GAAG,oEAAoE,CAAC;KACrF;IAED,MAAM,cAAc,GAAG,GAAG,WAAW,IAAI,WAAW,CAAC,IAAI,CAAC,IAAI,eAAe,IAAI,UAAU,IAAI,SAAS,IAAI,YAAY,EAAE,CAAC;IAE3H,OAAO,CACL,+BACE,GAAG,EAAE,UAAU,iBACF,MAAM,EACnB,IAAI,EAAE,IAAI,EACV,EAAE,EAAE,EAAE,EACN,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,cAAc,EACzB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAC,MAAM,EACnB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,GACV,CACH,CAAC;AACJ,CAAC,CACF,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextField } from './TextField';
|
|
3
|
+
export default {
|
|
4
|
+
title: 'TextField',
|
|
5
|
+
};
|
|
6
|
+
export const AllTextFields = () => {
|
|
7
|
+
const renderAllVariations = () => (React.createElement(React.Fragment, null,
|
|
8
|
+
React.createElement("div", { className: "tw-p-4 light" },
|
|
9
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
10
|
+
React.createElement(TextField, { value: "value provided" })),
|
|
11
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
12
|
+
React.createElement(TextField, { placeholder: "placeholder text" })),
|
|
13
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
14
|
+
React.createElement(TextField, { value: "read-only", readonly: true })),
|
|
15
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
16
|
+
React.createElement(TextField, { value: "large", size: "lg" }))),
|
|
17
|
+
React.createElement("div", { className: "tw-p-4 tw-dark tw-bg-sq-dark-background" },
|
|
18
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
19
|
+
React.createElement(TextField, { value: "value provided" })),
|
|
20
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
21
|
+
React.createElement(TextField, { placeholder: "placeholder text" })),
|
|
22
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
23
|
+
React.createElement(TextField, { value: "read-only", readonly: true })),
|
|
24
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
25
|
+
React.createElement(TextField, { value: "large", size: "lg" })))));
|
|
26
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-3 tw-gap-4" },
|
|
27
|
+
React.createElement("div", { className: "color_topic" },
|
|
28
|
+
React.createElement("b", null, "Topic Colors"),
|
|
29
|
+
renderAllVariations()),
|
|
30
|
+
React.createElement("div", { className: "color_analysis" },
|
|
31
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
32
|
+
renderAllVariations()),
|
|
33
|
+
React.createElement("div", { className: "color_datalab" },
|
|
34
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
35
|
+
renderAllVariations())));
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=TextField.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.stories.js","sourceRoot":"","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BAAK,SAAS,EAAC,aAAa;YAC1B,8CAAmB;YAClB,mBAAmB,EAAE,CAClB;QAEN,6BAAK,SAAS,EAAC,gBAAgB;YAC7B,iDAAsB;YACrB,mBAAmB,EAAE,CAClB;QAEN,6BAAK,SAAS,EAAC,eAAe;YAC5B,gDAAqB;YACpB,mBAAmB,EAAE,CAClB,CACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 { TextField } from './TextField';
|
|
6
|
+
describe('TextField', () => {
|
|
7
|
+
class Context {
|
|
8
|
+
testId = 'textFieldTestId';
|
|
9
|
+
props = {
|
|
10
|
+
onChange: jest.fn(),
|
|
11
|
+
testId: this.testId,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
let tc;
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
tc = new Context();
|
|
17
|
+
});
|
|
18
|
+
const renderTextField = (props) => render(React.createElement(TextField, { ...props }));
|
|
19
|
+
it('renders the provided value', () => {
|
|
20
|
+
const value = 'hello';
|
|
21
|
+
renderTextField({ ...tc.props, value });
|
|
22
|
+
expect(screen.getByDisplayValue(value)).toBeInTheDocument();
|
|
23
|
+
});
|
|
24
|
+
it('renders the provided placeholder', () => {
|
|
25
|
+
const placeholder = 'Prompt to enter';
|
|
26
|
+
renderTextField({ ...tc.props, placeholder });
|
|
27
|
+
expect(screen.getByPlaceholderText(placeholder)).toBeInTheDocument();
|
|
28
|
+
});
|
|
29
|
+
it('calls onChange handler', async () => {
|
|
30
|
+
renderTextField({ ...tc.props });
|
|
31
|
+
await userEvent.type(screen.getByTestId(tc.testId), 'trigger');
|
|
32
|
+
expect(tc.props.onChange).toHaveBeenCalled();
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=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AM,CAAC,oBAAoB,CAAC,WAAW,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;IACvE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wBAAwB,EAAE,KAAK,IAAI,EAAE;QACtC,eAAe,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC;QACjC,MAAM,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,MAAM,CAAC,EAAE,SAAS,CAAC,CAAC;QAC/D,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,gBAAgB,EAAE,CAAC;IAC/C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.types.js","sourceRoot":"","sources":["../../src/TextField/TextField.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/TextField/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,OAAO,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '../styles.css';
|
|
3
|
+
import { DEFAULT_TOOL_TIP_DELAY } from './Tooltip.types';
|
|
4
|
+
/**
|
|
5
|
+
* This component displays a Tooltip for the provided children.
|
|
6
|
+
*/
|
|
7
|
+
export const Tooltip = ({ position = 'bottom', children, text, delay = DEFAULT_TOOL_TIP_DELAY, }) => {
|
|
8
|
+
const arrowBaseClasses = "before:tw-content-[''] before:tw-absolute before:tw-border-8";
|
|
9
|
+
const centerArrowVertically = 'before:tw-top-1/2 before:-tw-translate-y-1/2';
|
|
10
|
+
const centerArrowHorizontally = 'before:tw-left-1/2 before:-tw-translate-x-1/2';
|
|
11
|
+
const arrowRight = `${arrowBaseClasses} ${centerArrowVertically} before:tw-right-[100%] before:tw-border-y-transparent
|
|
12
|
+
before:tw-border-l-transparent before:tw-border-r-black`;
|
|
13
|
+
const arrowLeft = `${arrowBaseClasses} ${centerArrowVertically} before:tw-left-[100%] before:tw-border-y-transparent
|
|
14
|
+
before:tw-border-l-black before:tw-border-r-transparent`;
|
|
15
|
+
const arrowBottom = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-top-4 before:tw-border-b-black
|
|
16
|
+
before:tw-border-r-transparent before:tw-border-l-transparent before:tw-border-t-transparent`;
|
|
17
|
+
const arrowTop = `${arrowBaseClasses} ${centerArrowHorizontally} before:-tw-bottom-4 before:tw-border-b-transparent
|
|
18
|
+
before:tw-border-t-black before:tw-border-l-transparent before:tw-border-r-transparent`;
|
|
19
|
+
const placements = {
|
|
20
|
+
top: `-tw-top-2 -tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowTop}`,
|
|
21
|
+
left: `-tw-translate-x-full -tw-left-3 -tw-translate-y-1/2 tw-top-1/2 ${arrowLeft}`,
|
|
22
|
+
right: `tw-translate-x-full -tw-right-3 -tw-translate-y-1/2 tw-top-1/2 ${arrowRight}`,
|
|
23
|
+
bottom: `-tw-bottom-2 tw-translate-y-full tw-left-1/2 -tw-translate-x-1/2 ${arrowBottom}`,
|
|
24
|
+
};
|
|
25
|
+
return (React.createElement("div", { className: "tw-group tw-relative tw-inline-block" },
|
|
26
|
+
children,
|
|
27
|
+
React.createElement("div", { className: `tw-z-50 tw-whitespace-nowrap tw-hidden group-hover:tw-inline-block group-hover:tw-delay-[${delay}ms]
|
|
28
|
+
tw-absolute tw-opacity-0 group-hover:tw-opacity-100 tw-rounded tw-bg-black tw-p-2 tw-text-xs tw-text-white ${placements[position]}` }, text)));
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../src/Tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,eAAe,CAAC;AACvB,OAAO,EAAE,sBAAsB,EAAgB,MAAM,iBAAiB,CAAC;AAEvE;;GAEG;AACH,MAAM,CAAC,MAAM,OAAO,GAA0C,CAAC,EAC7D,QAAQ,GAAG,QAAQ,EACnB,QAAQ,EACR,IAAI,EACJ,KAAK,GAAG,sBAAsB,GAC/B,EAAE,EAAE;IACH,MAAM,gBAAgB,GAAG,8DAA8D,CAAC;IACxF,MAAM,qBAAqB,GAAG,8CAA8C,CAAC;IAC7E,MAAM,uBAAuB,GAAG,+CAA+C,CAAC;IAChF,MAAM,UAAU,GAAG,GAAG,gBAAgB,IAAI,qBAAqB;0DACP,CAAC;IAEzD,MAAM,SAAS,GAAG,GAAG,gBAAgB,IAAI,qBAAqB;2DACL,CAAC;IAE1D,MAAM,WAAW,GAAG,GAAG,gBAAgB,IAAI,uBAAuB;+FAC2B,CAAC;IAC9F,MAAM,QAAQ,GAAG,GAAG,gBAAgB,IAAI,uBAAuB;yFACwB,CAAC;IAExF,MAAM,UAAU,GAAG;QACjB,GAAG,EAAE,kEAAkE,QAAQ,EAAE;QACjF,IAAI,EAAE,kEAAkE,SAAS,EAAE;QACnF,KAAK,EAAE,kEAAkE,UAAU,EAAE;QACrF,MAAM,EAAE,oEAAoE,WAAW,EAAE;KAC1F,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAC,sCAAsC;QAClD,QAAQ;QACT,6BACE,SAAS,EAAE,4FAA4F,KAAK;qHACC,UAAU,CAAC,QAAQ,CAAC,EAAE,IAClI,IAAI,CACD,CACF,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Tooltip } from './Tooltip';
|
|
3
|
+
import Icon from '../Icon';
|
|
4
|
+
import Button from '../Button';
|
|
5
|
+
import { tooltipPositions } from './Tooltip.types';
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Tooltip',
|
|
8
|
+
};
|
|
9
|
+
export const AllTooltips = () => {
|
|
10
|
+
const renderButtonsWithTooltip = () => tooltipPositions.map((position) => (React.createElement("div", { key: `${position}_button` },
|
|
11
|
+
React.createElement(Tooltip, { text: `Tooltip on the ${position}`, position: position },
|
|
12
|
+
React.createElement(Button, { label: position })))));
|
|
13
|
+
const renderIconsWithHtmlTooltip = () => tooltipPositions.map((position) => (React.createElement("div", { key: `${position}_icon` },
|
|
14
|
+
React.createElement(Tooltip, { text: React.createElement("div", null,
|
|
15
|
+
React.createElement("h2", null, "Fancy Tooltip"),
|
|
16
|
+
" This is a special tooltip. Why?",
|
|
17
|
+
React.createElement("br", null),
|
|
18
|
+
"Because it supports ",
|
|
19
|
+
React.createElement("b", null, "HTML!")), position: position },
|
|
20
|
+
React.createElement(Icon, { icon: "fc-sun" })))));
|
|
21
|
+
const renderTextTooltipOnText = () => tooltipPositions.map((position) => (React.createElement("div", { key: `${position}_text` },
|
|
22
|
+
React.createElement(Tooltip, { text: "Helpful information provided here", position: position },
|
|
23
|
+
React.createElement("span", null,
|
|
24
|
+
"Hover for Tooltip (on the ",
|
|
25
|
+
position,
|
|
26
|
+
")")))));
|
|
27
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-4 tw-gap-4 tw-text-center" },
|
|
28
|
+
renderButtonsWithTooltip(),
|
|
29
|
+
renderIconsWithHtmlTooltip(),
|
|
30
|
+
renderTextTooltipOnText()));
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=Tooltip.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.stories.js","sourceRoot":"","sources":["../../src/Tooltip/Tooltip.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,MAAM,MAAM,WAAW,CAAC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
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.types.js","sourceRoot":"","sources":["../../src/Tooltip/Tooltip.types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAC3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Tooltip/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
env: { browser: true, es2020: true },
|
|
3
|
+
extends: [
|
|
4
|
+
'eslint:recommended',
|
|
5
|
+
'plugin:@typescript-eslint/recommended',
|
|
6
|
+
'plugin:react-hooks/recommended',
|
|
7
|
+
],
|
|
8
|
+
parser: '@typescript-eslint/parser',
|
|
9
|
+
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
|
|
10
|
+
plugins: ['react-refresh'],
|
|
11
|
+
rules: {
|
|
12
|
+
'react-refresh/only-export-components': 'warn',
|
|
13
|
+
},
|
|
14
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!-- markdownlint-disable-next-line -->
|
|
2
|
+
<p align="center">
|
|
3
|
+
<img width="150" src="https://seeq.com/sites/default/files/seeq-content/seeq-logo-blue-web-33h.svg" alt="Seeq logo">
|
|
4
|
+
</p>
|
|
5
|
+
<h1 align="center">qomponents-form example</h1>
|
|
6
|
+
|
|
7
|
+
Time to see qomponents in action!
|
|
8
|
+
|
|
9
|
+
This is a simple form example that showcases Seeq's qomponents library.
|
|
10
|
+
|
|
11
|
+
This application is built using [vite](https://vitejs.dev/).
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
First, be sure to install all dependencies (React, and qomponents):
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm install
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Once you've installed all dependencies you can start up a dev server and observer any changes you make in real-time:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
npm run dev
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Tip
|
|
28
|
+
|
|
29
|
+
All application code can be found in Example.tsx. Check out the source code to learn how to ensure your
|
|
30
|
+
components display using the correct theme (green, blue, orange) as well as the correct mode (light or dark).
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>qomponents form example</title>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "example",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "tsc && vite build",
|
|
9
|
+
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
10
|
+
"preview": "vite preview"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@fortawesome/fontawesome-free": "^6.4.0",
|
|
14
|
+
"@seeqdev/qomponents": "latest",
|
|
15
|
+
"react": "^18.2.0",
|
|
16
|
+
"react-dom": "^18.2.0"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/react": "^18.0.37",
|
|
20
|
+
"@types/react-dom": "^18.0.11",
|
|
21
|
+
"@typescript-eslint/eslint-plugin": "^5.59.0",
|
|
22
|
+
"@typescript-eslint/parser": "^5.59.0",
|
|
23
|
+
"@vitejs/plugin-react": "^4.0.0",
|
|
24
|
+
"eslint": "^8.38.0",
|
|
25
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
26
|
+
"eslint-plugin-react-refresh": "^0.3.4",
|
|
27
|
+
"typescript": "^5.0.2",
|
|
28
|
+
"vite": "^4.3.9"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, Checkbox, Icon, Select, TextArea, TextField, Tooltip } from '@seeqdev/qomponents';
|
|
3
|
+
|
|
4
|
+
const availableThemes = [
|
|
5
|
+
{ display: 'Analysis', value: 'color_analysis' },
|
|
6
|
+
{ display: 'Topic', value: 'color_topic' },
|
|
7
|
+
{ display: 'DataLab', value: 'color_datalab' },
|
|
8
|
+
];
|
|
9
|
+
|
|
10
|
+
const options = [
|
|
11
|
+
{ value: '1', label: 'Beginner' },
|
|
12
|
+
{ value: '2', label: 'Advanced' },
|
|
13
|
+
{ value: '3', label: 'Expert' },
|
|
14
|
+
];
|
|
15
|
+
|
|
16
|
+
function Example() {
|
|
17
|
+
/**
|
|
18
|
+
* Theming is supported "out of the box". To apply a theme wrap your addOn in a div and assign the class that
|
|
19
|
+
* matched the desired theme:
|
|
20
|
+
* - color_analysis for Analysis styled qomponents (green)
|
|
21
|
+
* - color_topic for Topic styled qomponents (blue)
|
|
22
|
+
* - DataLab for DataLab styled qomponents (orange)
|
|
23
|
+
*/
|
|
24
|
+
const [theme, setTheme] = React.useState('color_analysis');
|
|
25
|
+
/**
|
|
26
|
+
* qomponents also support dark-mode. To reder qomponents using dark-mode wrap your addOn in a div and assign the
|
|
27
|
+
* class "tw-dark" for dark-mode or "tw-light" for light mode.
|
|
28
|
+
*/
|
|
29
|
+
const [mode, setMode] = React.useState('tw-light');
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* This example uses controlled inputs (https://blog.logrocket.com/controlled-vs-uncontrolled-components-in-react/)
|
|
33
|
+
*/
|
|
34
|
+
const [textFieldValue, setTextFieldValue] = React.useState('');
|
|
35
|
+
const [textAreaValue, setTextAreaValue] = React.useState('');
|
|
36
|
+
const [selectValue, setSelectValue] = React.useState();
|
|
37
|
+
const [display, setDisplay] = React.useState('');
|
|
38
|
+
const [easeOfUse, setEaseOfUse] = React.useState(false);
|
|
39
|
+
const [lookAndFeel, setLookAndFeel] = React.useState(false);
|
|
40
|
+
const [speed, setSpeed] = React.useState(false);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
// outer-wrapper div that assigns the mode (dark-mode or light) as well as the theme
|
|
44
|
+
<div className={`backdrop ${mode} ${theme}`}>
|
|
45
|
+
<div className="container">
|
|
46
|
+
<div className="header">qomponents - form example</div>
|
|
47
|
+
<div>Use this example to see qomponents in actions.</div>
|
|
48
|
+
No libraries other than Seeq's qomponents (and of course React) are used to create this example, however minimal
|
|
49
|
+
CSS is used to create an appealing form - you can find all that CSS in index.css.
|
|
50
|
+
<p>
|
|
51
|
+
<b>A note on CSS:</b> Seeq's qomponents come fully styled and ready to use. While it is tempting to use the
|
|
52
|
+
available <i>extraClassNames</i> property to provide yet additional styling we strongly advise you to use this
|
|
53
|
+
property to provide only width, margins and padding. This will ensure for a smooth upgrade experience when
|
|
54
|
+
Seeq's look and feel changes.
|
|
55
|
+
</p>
|
|
56
|
+
<p>
|
|
57
|
+
Using FontAwesome? You can pass FontAwesome Icons to the qomponent Icon component
|
|
58
|
+
<Icon icon="fa-regular fa-face-smile" extraClassNames="ml-10" />
|
|
59
|
+
</p>
|
|
60
|
+
<div>
|
|
61
|
+
<Tooltip text="Toggle Dark/Light Mode." position="bottom">
|
|
62
|
+
<a href="#" onClick={() => setMode(mode === 'tw-light' ? 'tw-dark' : 'tw-light')}>
|
|
63
|
+
<Icon icon="fc-sun" extraClassNames="mr-10" />
|
|
64
|
+
Click to toggle to {mode === 'tw-light' ? 'Dark Mode' : 'Light Mode'}
|
|
65
|
+
</a>
|
|
66
|
+
</Tooltip>
|
|
67
|
+
</div>
|
|
68
|
+
<div className="formRow">
|
|
69
|
+
<div className="labelWidth">Select theme:</div>
|
|
70
|
+
{availableThemes.map((t) => (
|
|
71
|
+
<Checkbox
|
|
72
|
+
type="radio"
|
|
73
|
+
checked={theme === t.value}
|
|
74
|
+
value={t.value}
|
|
75
|
+
label={t.display}
|
|
76
|
+
onChange={(e) => setTheme(e.target.value)}
|
|
77
|
+
extraClassNames="mr-10"
|
|
78
|
+
/>
|
|
79
|
+
))}
|
|
80
|
+
</div>
|
|
81
|
+
<div className="formRow">
|
|
82
|
+
<div className="labelWidth">AddOn Name</div>
|
|
83
|
+
<TextField
|
|
84
|
+
placeholder="provide a name"
|
|
85
|
+
extraClassNames="formElementWidth"
|
|
86
|
+
value={textFieldValue}
|
|
87
|
+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setTextFieldValue(e.target.value)}
|
|
88
|
+
/>
|
|
89
|
+
</div>
|
|
90
|
+
<div className="formRow">
|
|
91
|
+
<div className="labelWidth">Description</div>
|
|
92
|
+
<TextArea
|
|
93
|
+
value={textAreaValue}
|
|
94
|
+
onChange={(e) => setTextAreaValue(e.target.value)}
|
|
95
|
+
extraClassNames="formElementWidth"
|
|
96
|
+
placeholder="provide some text here"
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
99
|
+
<div className="formRow">
|
|
100
|
+
<div className="labelWidth">Goals</div>
|
|
101
|
+
<div className="formColumn">
|
|
102
|
+
<div>
|
|
103
|
+
<Checkbox checked={easeOfUse} label="Ease of Use" onChange={() => setEaseOfUse(!easeOfUse)} />
|
|
104
|
+
<Checkbox
|
|
105
|
+
checked={lookAndFeel}
|
|
106
|
+
label="Improved Look & Feel"
|
|
107
|
+
onChange={() => setLookAndFeel(!lookAndFeel)}
|
|
108
|
+
/>
|
|
109
|
+
<Checkbox checked={speed} label="Speedy Development" onChange={() => setSpeed(!speed)} />
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
<div className="formRow">
|
|
114
|
+
<div className="labelWidth">Level</div>
|
|
115
|
+
<Select
|
|
116
|
+
value={selectValue}
|
|
117
|
+
extraClassNames="formElementWidth"
|
|
118
|
+
onChange={(selectValue) => setSelectValue(selectValue)}
|
|
119
|
+
options={options}
|
|
120
|
+
placeholder="please choose"
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
<div className="buttonRow">
|
|
124
|
+
<Button
|
|
125
|
+
label="Cancel"
|
|
126
|
+
onClick={() => {
|
|
127
|
+
setDisplay('cancel');
|
|
128
|
+
}}
|
|
129
|
+
extraClassNames="mr-10"
|
|
130
|
+
/>
|
|
131
|
+
<Button
|
|
132
|
+
label="Submit"
|
|
133
|
+
onClick={() => {
|
|
134
|
+
setDisplay('success');
|
|
135
|
+
}}
|
|
136
|
+
variant="theme"
|
|
137
|
+
/>
|
|
138
|
+
</div>
|
|
139
|
+
{display === 'success' && <div>submit button onClick function was called</div>}
|
|
140
|
+
{display === 'cancel' && <div>cancel button onClick function was called</div>}
|
|
141
|
+
</div>
|
|
142
|
+
</div>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export default Example;
|