@seeqdev/qomponents 0.0.15 → 0.0.17
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 +13 -2
- package/dist/Button/Button.stories.d.ts +1 -0
- package/dist/Button/Button.types.d.ts +2 -0
- package/dist/example/package-lock.json +3369 -0
- package/dist/example/package.json +1 -1
- package/dist/example/src/ComplexSelectExample.tsx +81 -0
- package/dist/example/src/Example.tsx +11 -2
- package/dist/example/src/index.css +20 -0
- package/dist/example/src/main.tsx +1 -1
- package/dist/example/tsconfig.node.json +4 -2
- package/dist/index.esm.js +9 -6
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +9 -6
- package/dist/index.js.map +1 -1
- package/dist/styles.css +8 -4
- package/package.json +2 -2
- package/dist/Button/Button.js +0 -71
- package/dist/Button/Button.js.map +0 -1
- package/dist/Button/Button.stories.js +0 -58
- package/dist/Button/Button.stories.js.map +0 -1
- package/dist/Button/Button.test.js +0 -49
- package/dist/Button/Button.test.js.map +0 -1
- package/dist/Button/Button.types.js +0 -4
- package/dist/Button/Button.types.js.map +0 -1
- package/dist/Button/index.js +0 -2
- package/dist/Button/index.js.map +0 -1
- package/dist/Checkbox/Checkbox.js +0 -23
- package/dist/Checkbox/Checkbox.js.map +0 -1
- package/dist/Checkbox/Checkbox.stories.js +0 -29
- package/dist/Checkbox/Checkbox.stories.js.map +0 -1
- package/dist/Checkbox/Checkbox.test.js +0 -94
- package/dist/Checkbox/Checkbox.test.js.map +0 -1
- package/dist/Checkbox/Checkbox.types.js +0 -2
- package/dist/Checkbox/Checkbox.types.js.map +0 -1
- package/dist/Checkbox/index.js +0 -2
- package/dist/Checkbox/index.js.map +0 -1
- package/dist/Icon/Icon.js +0 -54
- package/dist/Icon/Icon.js.map +0 -1
- package/dist/Icon/Icon.stories.js +0 -40
- package/dist/Icon/Icon.stories.js.map +0 -1
- package/dist/Icon/Icon.test.js +0 -55
- package/dist/Icon/Icon.test.js.map +0 -1
- package/dist/Icon/Icon.types.js +0 -16
- package/dist/Icon/Icon.types.js.map +0 -1
- package/dist/Icon/index.js +0 -2
- package/dist/Icon/index.js.map +0 -1
- package/dist/Select/Select.js +0 -168
- package/dist/Select/Select.js.map +0 -1
- package/dist/Select/Select.stories.js +0 -72
- package/dist/Select/Select.stories.js.map +0 -1
- package/dist/Select/Select.test.js +0 -161
- package/dist/Select/Select.test.js.map +0 -1
- package/dist/Select/Select.types.js +0 -2
- package/dist/Select/Select.types.js.map +0 -1
- package/dist/Select/index.js +0 -2
- package/dist/Select/index.js.map +0 -1
- package/dist/TextArea/TextArea.js +0 -15
- package/dist/TextArea/TextArea.js.map +0 -1
- package/dist/TextArea/TextArea.stories.js +0 -35
- package/dist/TextArea/TextArea.stories.js.map +0 -1
- package/dist/TextArea/TextArea.test.js +0 -68
- package/dist/TextArea/TextArea.test.js.map +0 -1
- package/dist/TextArea/TextArea.types.js +0 -2
- package/dist/TextArea/TextArea.types.js.map +0 -1
- package/dist/TextArea/index.js +0 -2
- package/dist/TextArea/index.js.map +0 -1
- package/dist/TextField/TextField.js +0 -56
- package/dist/TextField/TextField.js.map +0 -1
- package/dist/TextField/TextField.stories.js +0 -37
- package/dist/TextField/TextField.stories.js.map +0 -1
- package/dist/TextField/TextField.test.js +0 -35
- package/dist/TextField/TextField.test.js.map +0 -1
- package/dist/TextField/TextField.types.js +0 -2
- package/dist/TextField/TextField.types.js.map +0 -1
- package/dist/TextField/index.js +0 -2
- package/dist/TextField/index.js.map +0 -1
- package/dist/Tooltip/Tooltip.js +0 -30
- package/dist/Tooltip/Tooltip.js.map +0 -1
- package/dist/Tooltip/Tooltip.stories.js +0 -32
- package/dist/Tooltip/Tooltip.stories.js.map +0 -1
- package/dist/Tooltip/Tooltip.types.js +0 -3
- package/dist/Tooltip/Tooltip.types.js.map +0 -1
- package/dist/Tooltip/index.js +0 -2
- package/dist/Tooltip/index.js.map +0 -1
- package/dist/types.js +0 -2
- package/dist/types.js.map +0 -1
- package/dist/utils/browserId.js +0 -29
- package/dist/utils/browserId.js.map +0 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon, Select } from '@seeqdev/qomponents';
|
|
3
|
+
|
|
4
|
+
export interface SelectOption {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
color: string;
|
|
8
|
+
asset: string;
|
|
9
|
+
type: 'SCALAR' | 'STRING' | 'NUMERIC';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const options: SelectOption[] = [
|
|
13
|
+
{ id: '1', label: 'Label for the first entry', color: 'pink', asset: 'Asset 1', type: 'NUMERIC' },
|
|
14
|
+
{ id: '2', label: 'Label for the second entry', color: 'green', asset: 'Asset 2', type: 'SCALAR' },
|
|
15
|
+
{ id: '3', label: 'Label for the third entry', color: 'orange', asset: 'Asset 3', type: 'STRING' },
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
interface ComplexSelectExampleProps {
|
|
19
|
+
onChange: (selectedOption: SelectOption) => void;
|
|
20
|
+
value: SelectOption | undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function ComplexSelectExample({ onChange, value }: ComplexSelectExampleProps) {
|
|
24
|
+
const getIcon = (type: string) => {
|
|
25
|
+
switch (type) {
|
|
26
|
+
case 'STRING':
|
|
27
|
+
return 'fa fa-font';
|
|
28
|
+
case 'SCALAR':
|
|
29
|
+
return 'fc-scalar';
|
|
30
|
+
default:
|
|
31
|
+
return 'fc-series';
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* This function formats the select option as desired. You can apply css styling here or use additional qomponents
|
|
36
|
+
* to style the select option display.
|
|
37
|
+
*
|
|
38
|
+
* You can use the same function to format the selected value or use a different one (sometimes having a separate
|
|
39
|
+
* function is helpful if you want to limit the space that is taken up by the selected option).
|
|
40
|
+
*
|
|
41
|
+
* This example shows how to use an additional Icon component (styled in color based on the select option) as well
|
|
42
|
+
* as how to display the properties of the select option
|
|
43
|
+
*/
|
|
44
|
+
const getOptionLabel = (optionValue: SelectOption): React.ReactNode => {
|
|
45
|
+
return (
|
|
46
|
+
<div className="selectOptionWrapperDiv">
|
|
47
|
+
<Icon icon={getIcon(optionValue.type)} type="color" color={optionValue.color} extraClassNames="mr-10" />
|
|
48
|
+
<div className="selectOptionDiv">
|
|
49
|
+
<div className="selectOption">
|
|
50
|
+
<strong>{optionValue.label}</strong>
|
|
51
|
+
</div>
|
|
52
|
+
<div className="selectOptionSubText">{optionValue.asset}</div>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
const getOptionValue = (option: SelectOption) => {
|
|
58
|
+
return option.id;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
// use the getOptionLabel function to provide a custom render function that determines how the select options
|
|
63
|
+
// are displayed
|
|
64
|
+
// use the getSelectedValueLabel function to provide a custom render function that determines how the selected
|
|
65
|
+
// option is displayed
|
|
66
|
+
<Select
|
|
67
|
+
placeholder="formatted select options"
|
|
68
|
+
extraClassNames="formElementWidth"
|
|
69
|
+
options={options}
|
|
70
|
+
value={value}
|
|
71
|
+
getOptionLabel={getOptionLabel}
|
|
72
|
+
getOptionValue={getOptionValue}
|
|
73
|
+
getSelectedValueLabel={getOptionLabel}
|
|
74
|
+
onChange={(selectedOption: SelectOption) => {
|
|
75
|
+
onChange(selectedOption);
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export default ComplexSelectExample;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Button, Checkbox, Icon, Select, TextArea, TextField, Tooltip } from '@seeqdev/qomponents';
|
|
3
|
+
import ComplexSelectExample, { SelectOption } from './ComplexSelectExample';
|
|
3
4
|
|
|
4
5
|
const availableThemes = [
|
|
5
6
|
{ display: 'Analysis', value: 'color_analysis' },
|
|
@@ -23,7 +24,7 @@ function Example() {
|
|
|
23
24
|
*/
|
|
24
25
|
const [theme, setTheme] = React.useState('color_analysis');
|
|
25
26
|
/**
|
|
26
|
-
* qomponents also support dark-mode. To
|
|
27
|
+
* qomponents also support dark-mode. To render qomponents using dark-mode wrap your addOn in a div and assign the
|
|
27
28
|
* class "tw-dark" for dark-mode or "tw-light" for light mode.
|
|
28
29
|
*/
|
|
29
30
|
const [mode, setMode] = React.useState('tw-light');
|
|
@@ -34,6 +35,7 @@ function Example() {
|
|
|
34
35
|
const [textFieldValue, setTextFieldValue] = React.useState('');
|
|
35
36
|
const [textAreaValue, setTextAreaValue] = React.useState('');
|
|
36
37
|
const [selectValue, setSelectValue] = React.useState();
|
|
38
|
+
const [complexSelectedValue, setComplexSelectedValue] = React.useState<SelectOption>();
|
|
37
39
|
const [display, setDisplay] = React.useState('');
|
|
38
40
|
const [easeOfUse, setEaseOfUse] = React.useState(false);
|
|
39
41
|
const [lookAndFeel, setLookAndFeel] = React.useState(false);
|
|
@@ -91,7 +93,7 @@ function Example() {
|
|
|
91
93
|
<div className="labelWidth">Description</div>
|
|
92
94
|
<TextArea
|
|
93
95
|
value={textAreaValue}
|
|
94
|
-
onChange={(e) => setTextAreaValue(e.target.value)}
|
|
96
|
+
onChange={(e: React.ChangeEvent<HTMLInputElement>) => setTextAreaValue(e.target.value)}
|
|
95
97
|
extraClassNames="formElementWidth"
|
|
96
98
|
placeholder="provide some text here"
|
|
97
99
|
/>
|
|
@@ -120,6 +122,13 @@ function Example() {
|
|
|
120
122
|
placeholder="please choose"
|
|
121
123
|
/>
|
|
122
124
|
</div>
|
|
125
|
+
<div className="formRow">
|
|
126
|
+
<div className="labelWidth">Advanced</div>
|
|
127
|
+
<ComplexSelectExample
|
|
128
|
+
value={complexSelectedValue}
|
|
129
|
+
onChange={(selectedOption: SelectOption) => setComplexSelectedValue(selectedOption)}
|
|
130
|
+
/>
|
|
131
|
+
</div>
|
|
123
132
|
<div className="buttonRow">
|
|
124
133
|
<Button
|
|
125
134
|
label="Cancel"
|
|
@@ -71,3 +71,23 @@
|
|
|
71
71
|
margin-left: 10px;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
/* styles for complexSelect*/
|
|
75
|
+
.selectOptionWrapperDiv {
|
|
76
|
+
display: flex;
|
|
77
|
+
flex-direction: row;
|
|
78
|
+
align-items: center;
|
|
79
|
+
height: 34px;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.selectOptionDiv {
|
|
83
|
+
display: flex;
|
|
84
|
+
flex-direction: column;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.selectOptionSubText {
|
|
88
|
+
font-size: smaller;
|
|
89
|
+
padding: 0;
|
|
90
|
+
margin-top: -6px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* end styles for complexSelect*/
|
package/dist/index.esm.js
CHANGED
|
@@ -114,13 +114,13 @@ const Icon = ({ onClick, icon, type = 'theme', extraClassNames, id, large, small
|
|
|
114
114
|
* - use "variant" to achieve the desired style
|
|
115
115
|
* - include tooltips and/or icons
|
|
116
116
|
*/
|
|
117
|
-
const Button = ({ onClick, label, variant = 'outline', type = 'button', size = 'sm', disabled, extraClassNames, id, testId, stopPropagation = true, tooltip, tooltipOptions, iconStyle = 'text', icon, iconColor, }) => {
|
|
117
|
+
const Button = ({ onClick, label, variant = 'outline', type = 'button', size = 'sm', disabled, extraClassNames, id, testId, stopPropagation = true, tooltip, tooltipOptions, iconStyle = 'text', icon, iconColor, preventBlur = false, }) => {
|
|
118
118
|
const baseClasses = 'tw-py-1 tw-px-2.5 tw-rounded-sm focus:tw-ring-0 disabled:tw-pointer-events-none';
|
|
119
119
|
const baseClassesByVariant = {
|
|
120
120
|
'outline': 'tw-border-solid tw-border',
|
|
121
|
-
'theme': 'disabled:tw-
|
|
122
|
-
'danger': 'tw-bg-sq-danger-color hover:tw-bg-sq-danger-color-hover disabled:tw-
|
|
123
|
-
'theme-light': 'disabled:tw-
|
|
121
|
+
'theme': 'disabled:tw-opacity-50',
|
|
122
|
+
'danger': 'tw-bg-sq-danger-color hover:tw-bg-sq-danger-color-hover disabled:tw-opacity-50',
|
|
123
|
+
'theme-light': 'disabled:tw-opacity-50',
|
|
124
124
|
'no-border': '',
|
|
125
125
|
'warning': 'tw-bg-sq-warning-color',
|
|
126
126
|
};
|
|
@@ -167,9 +167,12 @@ const Button = ({ onClick, label, variant = 'outline', type = 'button', size = '
|
|
|
167
167
|
const button = (React__default.createElement("button", { id: id, disabled: disabled, "data-testid": testId, type: type === 'link' || (type === 'submit' && browserIsFirefox) ? 'button' : type, onClick: (e) => {
|
|
168
168
|
stopPropagation && e.stopPropagation();
|
|
169
169
|
onClick && onClick();
|
|
170
|
+
}, onMouseDown: (e) => {
|
|
171
|
+
if (preventBlur) {
|
|
172
|
+
e.preventDefault();
|
|
173
|
+
}
|
|
170
174
|
}, className: appliedClasses },
|
|
171
|
-
icon && (React__default.createElement(Icon, { icon: icon, type: iconStyle, color: iconColor, extraClassNames: label ?
|
|
172
|
-
`tw-mr-1 ${textClassesByVariantLightTheme[variant]} ${textClassesByVariantDarkTheme[variant]}` : '', testId: `${id}_spinner` })),
|
|
175
|
+
icon && (React__default.createElement(Icon, { icon: icon, type: iconStyle, color: iconColor, extraClassNames: label ? `tw-mr-1 ${textClassesByVariantLightTheme[variant]} ${textClassesByVariantDarkTheme[variant]}` : '', testId: `${id}_spinner` })),
|
|
173
176
|
label));
|
|
174
177
|
return tooltip ? (React__default.createElement(Tooltip, { text: tooltip, ...tooltipOptions }, button)) : (button);
|
|
175
178
|
};
|