@seeqdev/qomponents 0.0.3 → 0.0.5
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/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.d.ts +3 -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 +130 -0
- package/dist/Select/Select.js.map +1 -0
- package/dist/Select/Select.stories.js +67 -0
- package/dist/Select/Select.stories.js.map +1 -0
- package/dist/Select/Select.test.js +23 -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.d.ts +2 -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 +47 -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.d.ts +2 -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/index.esm.js +2 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/sharedTypes.js +1 -0
- package/dist/sharedTypes.js.map +1 -0
- 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
- package/dist/sharedTypes.d.ts +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Icon/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '../styles.css';
|
|
3
|
+
import { createFilter, default as ReactSelect } from 'react-select';
|
|
4
|
+
import CreatableSelect from 'react-select/creatable';
|
|
5
|
+
/**
|
|
6
|
+
* Select Component
|
|
7
|
+
* - based on react-select (https://react-select.com/)
|
|
8
|
+
*/
|
|
9
|
+
const Select = ({ options, value, placeholder = 'select', noOptionsMessage = 'no matching options', isSearchable = false, creatable = false, isMulti = false, isClearable = false, closeMenuOnSelect = true, id, inputId, menuPortalTarget, getOptionLabel, getSelectedValueLabel, getOptionValue, onChange, menuIsOpen, menuPlacement = 'auto', extraClassNames, inputGroup, filterConfig, filterOption, small = false, isDisabled = false, showError = false, isLoading = false, formatGroupLabel, onRemove, defaultValue, }) => {
|
|
10
|
+
const baseClasses = ['tw-px-2.5', 'focus:tw-ring-0', 'disabled:tw-cursor-not-allowed'].join(' ');
|
|
11
|
+
const errorClasses = 'tw-border-sq-danger-color';
|
|
12
|
+
const borderColorClasses = ['tw-border-sq-disabled-gray', 'dark:tw-border-sq-dark-disabled-gray'].join(' ');
|
|
13
|
+
const borderStyles = [
|
|
14
|
+
'tw-border-solid',
|
|
15
|
+
'tw-border',
|
|
16
|
+
'hover:tw-border-sq-color-dark',
|
|
17
|
+
'focus:tw-border-sq-color-dark',
|
|
18
|
+
'active:tw-border-sq-color-dark',
|
|
19
|
+
'dark:hover:tw-border-sq-color-dark-dark',
|
|
20
|
+
'dark:focus:tw-border-sq-color-dark-dark',
|
|
21
|
+
'dark:active:tw-border-sq-color-dark-dark',
|
|
22
|
+
].join(' ');
|
|
23
|
+
const textStyles = ['tw-text-sq-text-color', 'dark:tw-text-sq-dark-text', 'tw-text-sm'].join(' ');
|
|
24
|
+
const textActiveStyles = [
|
|
25
|
+
'hover:tw-text-sq-color-dark',
|
|
26
|
+
'focus:tw-text-sq-color-dark',
|
|
27
|
+
'active:tw-text-sq-color-dark',
|
|
28
|
+
'dark:tw-text-sq-dark-disabled-gray',
|
|
29
|
+
'dark:hover:tw-text-sq-color-dark-dark',
|
|
30
|
+
'dark:focus:tw-text-sq-color-dark-dark',
|
|
31
|
+
'dark:active:tw-text-sq-color-dark-dark',
|
|
32
|
+
].join(' ');
|
|
33
|
+
const menuStyles = [
|
|
34
|
+
'tw-border-solid',
|
|
35
|
+
'tw-border-x',
|
|
36
|
+
'tw-border-b',
|
|
37
|
+
'tw-rounded-b',
|
|
38
|
+
'tw-border-sq-disabled-gray',
|
|
39
|
+
'dark:tw-border-sq-dark-disabled-gray',
|
|
40
|
+
'tw-whitespace-nowrap',
|
|
41
|
+
'tw-min-w-fit',
|
|
42
|
+
].join(' ');
|
|
43
|
+
const disabledClasses = ['tw-bg-sq-field-disabled-gray', 'tw-cursor-not-allowed'].join(' ');
|
|
44
|
+
const dropDownIndicatorStyles = `${textStyles} ${textActiveStyles}`;
|
|
45
|
+
const getOptionOrSelectedLabel = (option, { context }) => {
|
|
46
|
+
const getSelectedOptionLabel = getSelectedValueLabel ? getSelectedValueLabel : getOptionLabel;
|
|
47
|
+
if (getOptionLabel || getSelectedValueLabel) {
|
|
48
|
+
if (context === 'value') {
|
|
49
|
+
return getSelectedOptionLabel ? getSelectedOptionLabel(option) : option.label;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return getOptionLabel ? getOptionLabel(option) : option.label;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return option.label;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
const interceptOnChange = (newValue, actionMeta) => {
|
|
60
|
+
if (isMulti && onRemove && actionMeta.action === 'remove-value') {
|
|
61
|
+
onRemove({ id: actionMeta.removedValue });
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
onChange(newValue);
|
|
65
|
+
};
|
|
66
|
+
const props = {
|
|
67
|
+
id,
|
|
68
|
+
value,
|
|
69
|
+
inputId,
|
|
70
|
+
placeholder,
|
|
71
|
+
closeMenuOnSelect,
|
|
72
|
+
isSearchable: creatable ? true : isSearchable,
|
|
73
|
+
isMulti,
|
|
74
|
+
isClearable,
|
|
75
|
+
isLoading,
|
|
76
|
+
defaultValue,
|
|
77
|
+
noOptionsMessage: () => noOptionsMessage,
|
|
78
|
+
menuPortalTarget,
|
|
79
|
+
menuIsOpen,
|
|
80
|
+
onChange: interceptOnChange,
|
|
81
|
+
unstyled: true,
|
|
82
|
+
menuPlacement,
|
|
83
|
+
formatOptionLabel: getOptionOrSelectedLabel,
|
|
84
|
+
formatGroupLabel,
|
|
85
|
+
getOptionValue,
|
|
86
|
+
options,
|
|
87
|
+
isDisabled,
|
|
88
|
+
hideSelectedOptions: isMulti,
|
|
89
|
+
filterOption: filterOption ? filterOption : filterConfig ? createFilter(filterConfig) : undefined,
|
|
90
|
+
classNames: {
|
|
91
|
+
control: ({ menuIsOpen }) => {
|
|
92
|
+
let border = menuIsOpen ? 'tw-rounded-t-sm' : 'tw-rounded-sm';
|
|
93
|
+
// if it's on the left side of the input group make sure the right side is straight and not curved
|
|
94
|
+
if (inputGroup === 'left') {
|
|
95
|
+
border = menuIsOpen ? 'tw-rounded-tl-sm' : 'tw-rounded-l-sm';
|
|
96
|
+
}
|
|
97
|
+
else if (inputGroup === 'right') {
|
|
98
|
+
border = menuIsOpen ? 'tw-rounded-tr-sm' : 'tw-rounded-r-sm';
|
|
99
|
+
}
|
|
100
|
+
const appliedClasses = `${borderStyles} ${border} ${showError ? errorClasses : borderColorClasses} ${small ? 'reactSelectMinHeightSmall' : 'reactSelectMinHeight'} `;
|
|
101
|
+
return `${appliedClasses} ${baseClasses} specSelectControl ${isDisabled ? disabledClasses : ''}`;
|
|
102
|
+
},
|
|
103
|
+
placeholder: () => 'tw-text-gray-400 dark:tw-text-sq-dark-text-lighter specOpenSelect',
|
|
104
|
+
container: () => `${textStyles} ${extraClassNames}`,
|
|
105
|
+
input: () => textStyles + ' specSelectInput',
|
|
106
|
+
menuList: () => `tw-rounded-b tw-bg-white dark:tw-bg-sq-dark-background tw-min-w-fit specSelectMenu tw-z-[9999]`,
|
|
107
|
+
menu: () => menuStyles,
|
|
108
|
+
menuPortal: () => '!tw-z-[9000]',
|
|
109
|
+
dropdownIndicator: () => `${dropDownIndicatorStyles} specOpenIt`,
|
|
110
|
+
option: ({ isSelected, isDisabled }) => {
|
|
111
|
+
let classes = 'hover:tw-bg-sq-gray-highlight dark:hover:tw-bg-sq-gray-highlight-dark tw-py-1 tw-px-2.5' +
|
|
112
|
+
' specSelectOption ';
|
|
113
|
+
if (isDisabled) {
|
|
114
|
+
classes += 'specDisabledOption ';
|
|
115
|
+
}
|
|
116
|
+
return isSelected ? classes + 'tw-bg-sq-colored-hover dark:tw-bg-sq-colored-hover-dark' : classes;
|
|
117
|
+
},
|
|
118
|
+
singleValue: () => 'specOpenSelect',
|
|
119
|
+
multiValue: () => 'tw-bg-sq-disabled-gray dark:tw-bg-sq-multi-gray-dark tw-text-sm tw-py-0.5 tw-px-1 tw-m-0.5 tw-rounded-sm specOpenSelect',
|
|
120
|
+
multiValueRemove: () => 'hover:tw-text-sq-danger-color specSelectMultiValueRemove',
|
|
121
|
+
clearIndicator: () => 'hover:tw-text-sq-danger-color specClearSelect',
|
|
122
|
+
group: () => 'specSelectGroup',
|
|
123
|
+
groupHeading: () => 'tw-bg-sq-light-gray dark:tw-bg-sq-dark-disabled-gray tw-text-sq-darkish-gray tw-py-1 tw-px-2.5' +
|
|
124
|
+
' specSelectGroupHeading',
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
return creatable ? React.createElement(CreatableSelect, { ...props }) : React.createElement(ReactSelect, { ...props });
|
|
128
|
+
};
|
|
129
|
+
export default Select;
|
|
130
|
+
//# sourceMappingURL=Select.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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AEF,OAAO,SAAS,CAAC,CAAC,CAAC,oBAAC,eAAe,OAAM,KAAa,GAAI,CAAC,CAAC,CAAC,oBAAC,WAAW,OAAM,KAAa,GAAI,CAAC;AACnG,CAAC,CAAC;AACF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Select from './Select';
|
|
3
|
+
import TextField from '../TextField';
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Select',
|
|
6
|
+
};
|
|
7
|
+
export const AllSelectVariants = () => {
|
|
8
|
+
const options = [
|
|
9
|
+
{ value: 'a', label: 'Chocolate' },
|
|
10
|
+
{ value: 'b', label: 'Strawberry' },
|
|
11
|
+
{ value: 'c', label: 'Vanilla' },
|
|
12
|
+
{ value: 'd', label: 'Rocky Road' },
|
|
13
|
+
{ value: 'e', label: 'Crazy Cow' },
|
|
14
|
+
{ value: 'f', label: 'Almond Joy' },
|
|
15
|
+
{ value: 'g', label: 'All of the above' },
|
|
16
|
+
];
|
|
17
|
+
const colorOptions = [
|
|
18
|
+
{ value: 'h', label: 'pink' },
|
|
19
|
+
{ value: 'i', label: 'purple' },
|
|
20
|
+
{ value: 'j', label: 'green' },
|
|
21
|
+
{ value: 'k', label: 'red' },
|
|
22
|
+
];
|
|
23
|
+
const groupedOptions = [
|
|
24
|
+
{
|
|
25
|
+
label: 'Ice Cream Flavors',
|
|
26
|
+
options: options,
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
label: 'Colors',
|
|
30
|
+
options: colorOptions,
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
const allSelects = () => (React.createElement(React.Fragment, null,
|
|
34
|
+
React.createElement("div", { className: "tw-p-10" },
|
|
35
|
+
React.createElement(Select, { id: "hello", onChange: () => { }, options: options, placeholder: "single value" }),
|
|
36
|
+
React.createElement(Select, { id: "hello", onChange: () => { }, options: options, placeholder: "single value", small: true }),
|
|
37
|
+
React.createElement(Select, { id: "disabled", onChange: () => { }, options: options, placeholder: "disabled", isDisabled: true }),
|
|
38
|
+
React.createElement(Select, { id: "error", onChange: () => { }, options: options, placeholder: "error", showError: true })),
|
|
39
|
+
React.createElement("div", { className: "tw-p-10" },
|
|
40
|
+
React.createElement(Select, { onChange: () => { }, options: options, placeholder: "stays open", closeMenuOnSelect: false, creatable: true })),
|
|
41
|
+
React.createElement("div", { className: "tw-p-10" },
|
|
42
|
+
React.createElement(Select, { onChange: () => { }, options: groupedOptions, placeholder: "grouped" })),
|
|
43
|
+
React.createElement("div", { className: "tw-p-10" },
|
|
44
|
+
React.createElement(Select, { onChange: () => { }, options: options, creatable: true, placeholder: "create option" })),
|
|
45
|
+
React.createElement("div", { className: "tw-p-10" },
|
|
46
|
+
React.createElement(Select, { onChange: () => { }, options: options, placeholder: "multi-select", isMulti: true, isSearchable: false })),
|
|
47
|
+
React.createElement("div", { className: "tw-p-10" },
|
|
48
|
+
React.createElement(Select, { onChange: () => { }, placeholder: "type to search", options: options, isSearchable: true })),
|
|
49
|
+
React.createElement("div", { className: "tw-p-10 tw-flex tw-flex-row" },
|
|
50
|
+
React.createElement(Select, { onChange: () => { }, placeholder: "type to search", options: options, inputGroup: "left", extraClassNames: "tw-w-[200px]" }),
|
|
51
|
+
React.createElement(TextField, { onChange: () => { }, placeholder: "text goes here", inputGroup: "right" }))));
|
|
52
|
+
const renderAllVariations = () => (React.createElement(React.Fragment, null,
|
|
53
|
+
React.createElement("div", { className: "tw-grid tw-gap-4" },
|
|
54
|
+
allSelects(),
|
|
55
|
+
React.createElement("div", { className: "tw-dark tw-bg-sq-dark-background" }, allSelects()))));
|
|
56
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-3 tw-gap-4" },
|
|
57
|
+
React.createElement("div", { className: "color_topic" },
|
|
58
|
+
React.createElement("b", null, "Topic Colors"),
|
|
59
|
+
renderAllVariations()),
|
|
60
|
+
React.createElement("div", { className: "color_analysis" },
|
|
61
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
62
|
+
renderAllVariations()),
|
|
63
|
+
React.createElement("div", { className: "color_datalab" },
|
|
64
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
65
|
+
renderAllVariations())));
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=Select.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.stories.js","sourceRoot":"","sources":["../../src/Select/Select.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,eAAe;IACb,KAAK,EAAE,QAAQ;CAChB,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,MAAM,OAAO,GAAG;QACd,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE;QAClC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE;QACnC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE;QAChC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE;QACnC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,WAAW,EAAE;QAClC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,YAAY,EAAE;QACnC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,kBAAkB,EAAE;KAC1C,CAAC;IAEF,MAAM,YAAY,GAAG;QACnB,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE;QAC7B,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE;QAC/B,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE;QAC9B,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE;KAC7B,CAAC;I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B;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,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@testing-library/jest-dom';
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
|
+
import Select from './Select';
|
|
5
|
+
describe('Button', () => {
|
|
6
|
+
class Context {
|
|
7
|
+
testId = 'buttonTestId';
|
|
8
|
+
label = 'button label';
|
|
9
|
+
props = {
|
|
10
|
+
onChange: jest.fn(),
|
|
11
|
+
options: [],
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
let tc;
|
|
15
|
+
beforeEach(() => {
|
|
16
|
+
tc = new Context();
|
|
17
|
+
});
|
|
18
|
+
const renderSelect = (props) => render(React.createElement(Select, { ...props }));
|
|
19
|
+
it('TODO', () => {
|
|
20
|
+
expect(true).toBeTruthy();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=Select.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.test.js","sourceRoot":"","sources":["../../src/Select/Select.test.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,OAAO,MAAM,MAAM,UAAU,CAAC;AAG9B,QAAQ,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,MAAM,OAAO;QACX,MAAM,GAAG,cAAc,CAAC;QACxB,KAAK,GAAG,cAAc,CAAC;QACvB,KAAK,GAAgB;YACnB,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;YACnB,OAAO,EAAE,EAAE;SACZ,CAAC;KACH;IAED,IAAI,EAAW,CAAC;IAChB,UAAU,CAAC,GAAG,EAAE;QACd,EAAE,GAAG,IAAI,OAAO,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,MAAM,YAAY,GAAG,CAAC,KAAkB,EAAE,EAAE,CAAC,MAAM,CAAC,oBAAC,MAAM,OAAK,KAAK,GAAI,CAAC,CAAC;IAE3E,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;QACd,MAAM,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.types.js","sourceRoot":"","sources":["../../src/Select/Select.types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/Select/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '../styles.css';
|
|
3
|
+
const baseClasses = 'tw-leading-normal tw-outline-none tw-py-1 tw-px-3 tw-rounded-sm' +
|
|
4
|
+
' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border';
|
|
5
|
+
const darkTheme = 'dark:tw-border-sq-dark-disabled-gray dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text' +
|
|
6
|
+
' dark:focus:tw-border-sq-color-dark-dark dark:active:tw-border-sq-color-dark-dark';
|
|
7
|
+
const lightTheme = 'tw-border-sq-disabled-gray tw-text-sq-text-color focus:tw-border-sq-color-dark active:tw-border-sq-color-dark';
|
|
8
|
+
/**
|
|
9
|
+
* TextArea.
|
|
10
|
+
*/
|
|
11
|
+
export const TextArea = ({ readonly = false, onChange, onKeyUp, id, name, rows = 3, cols = undefined, value, placeholder, extraClassNames, testId, autofocus = false, }) => {
|
|
12
|
+
const appliedClasses = `${baseClasses} ${extraClassNames} ${lightTheme} ${darkTheme}`;
|
|
13
|
+
return (React.createElement("textarea", { "data-testid": testId, name: name, id: id, value: value, className: appliedClasses, placeholder: placeholder, disabled: readonly, onChange: onChange, onKeyUp: onKeyUp, rows: rows, cols: cols, autoFocus: autofocus }));
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=TextArea.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextArea.js","sourceRoot":"","sources":["../../src/TextArea/TextArea.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,eAAe,CAAC;AAEvB,MAAM,WAAW,GACf,iEAAiE;IACjE,kEAAkE,CAAC;AAErE,MAAM,SAAS,GACb,8FAA8F;IAC9F,mFAAmF,CAAC;AACtF,MAAM,UAAU,GACd,+GAA+G,CAAC;AAElH;;GAEG;AACH,MAAM,CAAC,MAAM,QAAQ,GAA2C,CAAC,EAC/D,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,OAAO,EACP,EAAE,EACF,IAAI,EACJ,IAAI,GAAG,CAAC,EACR,IAAI,GAAG,SAAS,EAChB,KAAK,EACL,WAAW,EACX,eAAe,EACf,MAAM,EACN,SAAS,GAAG,KAAK,GAClB,EAAE,EAAE;IACH,MAAM,cAAc,GAAG,GAAG,WAAW,IAAI,eAAe,IAAI,UAAU,IAAI,SAAS,EAAE,CAAC;IAEtF,OAAO,CACL,iDACe,MAAM,EACnB,IAAI,EAAE,IAAI,EACV,EAAE,EAAE,EAAE,EACN,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE,cAAc,EACzB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,GACpB,CACH,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextArea } from './TextArea';
|
|
3
|
+
export default {
|
|
4
|
+
title: 'TextArea',
|
|
5
|
+
};
|
|
6
|
+
export const AllTextAreas = () => {
|
|
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(TextArea, { value: "Short text provided." })),
|
|
11
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
12
|
+
React.createElement(TextArea, { value: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Odio morbi quis commodo odio aenean. Lectus sit amet est placerat in egestas erat. Dui nunc mattis enim ut tellus. Dictumst vestibulum rhoncus est pellentesque elit ullamcorper. Nibh mauris cursus mattis molestie a. Aenean vel elit scelerisque mauris pellentesque. Nunc sed id semper risus in hendrerit gravida rutrum quisque. Tortor dignissim convallis aenean et tortor at risus. Vitae congue mauris rhoncus aenean vel elit scelerisque. Tellus id interdum velit laoreet id donec ultrices. Ac turpis egestas maecenas pharetra. Commodo odio aenean sed adipiscing diam donec adipiscing tristique risus. Consequat interdum varius sit amet mattis. Lacus laoreet non curabitur gravida arcu ac tortor. Vulputate sapien nec sagittis aliquam malesuada bibendum arcu vitae elementum. Odio ut enim blandit volutpat maecenas volutpat." })),
|
|
13
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
14
|
+
React.createElement(TextArea, { placeholder: "placeholder text" })),
|
|
15
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
16
|
+
React.createElement(TextArea, { value: "read-only", readonly: true }))),
|
|
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(TextArea, { value: "value provided" })),
|
|
20
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
21
|
+
React.createElement(TextArea, { placeholder: "placeholder text" })),
|
|
22
|
+
React.createElement("div", { className: "tw-p-4" },
|
|
23
|
+
React.createElement(TextArea, { value: "read-only", readonly: true })))));
|
|
24
|
+
return (React.createElement("div", { className: "tw-grid tw-grid-cols-3 tw-gap-4" },
|
|
25
|
+
React.createElement("div", { className: "color_topic" },
|
|
26
|
+
React.createElement("b", null, "Topic Colors"),
|
|
27
|
+
renderAllVariations()),
|
|
28
|
+
React.createElement("div", { className: "color_analysis" },
|
|
29
|
+
React.createElement("b", null, "Analysis Colors"),
|
|
30
|
+
renderAllVariations()),
|
|
31
|
+
React.createElement("div", { className: "color_datalab" },
|
|
32
|
+
React.createElement("b", null, "Datalab Colors"),
|
|
33
|
+
renderAllVariations())));
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=TextArea.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextArea.stories.js","sourceRoot":"","sources":["../../src/TextArea/TextArea.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,eAAe;IACb,KAAK,EAAE,UAAU;CAClB,CAAC;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,GAAG,EAAE;IAC/B,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,CAChC;QACE,6BAAK,SAAS,EAAC,cAAc;YAC3B,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,QAAQ,IAAC,KAAK,EAAC,sBAAsB,GAAG,CACrC;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,QAAQ,IAAC,KAAK,EAAC,q7BAAq7B,GAAG,CACp8B;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,QAAQ,IAAC,WAAW,EAAC,kBAAkB,GAAG,CACvC;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,QAAQ,IAAC,KAAK,EAAC,WAAW,EAAC,QAAQ,EAAE,IAAI,GAAI,CAC1C,CACF;QAEN,6BAAK,SAAS,EAAC,yCAAyC;YACtD,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,QAAQ,IAAC,KAAK,EAAC,gBAAgB,GAAG,CAC/B;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,QAAQ,IAAC,WAAW,EAAC,kBAAkB,GAAG,CACvC;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,QAAQ,IAAC,KAAK,EAAC,WAAW,EAAC,QAAQ,EAAE,IAAI,GAAI,CAC1C,CACF,CACL,CACJ,CAAC;IACF,OAAO,CACL,6BAAK,SAAS,EAAC,iCAAiC;QAC9C,6BAAK,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,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,CAAC;AAEtC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,MAAM,OAAO;QACX,MAAM,GAAG,gBAAgB,CAAC;QAC1B,KAAK,GAAkB;YACrB,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;YACnB,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE;YAClB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;KACH;IAED,IAAI,EAAW,CAAC;IAChB,UAAU,CAAC,GAAG,EAAE;QACd,EAAE,GAAG,IAAI,OAAO,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IACH,MAAM,cAAc,GAAG,CAAC,KAAoB,EAAE,EAAE,CAAC,MAAM,CAAC,oBAAC,QAAQ,OAAK,KAAK,GAAI,CAAC,CAAC;IAEjF,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,KAAK,GAAG,sCAA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C,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"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
type FormControlElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
|
1
2
|
export interface TextAreaProps {
|
|
2
3
|
/** extra class names to be placed on the TextArea component */
|
|
3
4
|
extraClassNames?: string;
|
|
@@ -24,3 +25,4 @@ export interface TextAreaProps {
|
|
|
24
25
|
/** value of the TextArea */
|
|
25
26
|
value?: string | string[] | number;
|
|
26
27
|
}
|
|
28
|
+
export {};
|
|
@@ -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,47 @@
|
|
|
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', } = 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)
|
|
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-height-34 tw-leading-normal tw-outline-none tw-py-1 tw-px-3 tw-rounded-sm disabled:tw-pointer-events-none' +
|
|
36
|
+
' disabled:tw-cursor-not-allowed tw-p-1 tw-border-solid tw-border';
|
|
37
|
+
const darkTheme = 'dark:tw-border-sq-dark-disabled-gray dark:tw-bg-sq-dark-background dark:tw-text-sq-dark-text' +
|
|
38
|
+
' dark:focus:tw-border-sq-color-dark-dark dark:active:tw-border-sq-color-dark-dark';
|
|
39
|
+
const lightTheme = 'tw-border-sq-disabled-gray tw-text-sq-text-color focus:tw-border-sq-color-dark active:tw-border-sq-color-dark';
|
|
40
|
+
const sizeClasses = {
|
|
41
|
+
sm: 'tw-text-sm',
|
|
42
|
+
lg: 'tw-text-xl',
|
|
43
|
+
};
|
|
44
|
+
const appliedClasses = `${baseClasses} ${sizeClasses[size]} ${extraClassNames} ${lightTheme} ${darkTheme}`;
|
|
45
|
+
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 }));
|
|
46
|
+
});
|
|
47
|
+
//# 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,KAAK,CAAC,UAAU,CAChF,CAAC,KAAK,EAAE,GAAQ,EAAE,EAAE;IAClB,MAAM,EACJ,QAAQ,GAAG,KAAK,EAChB,QAAQ,EACR,OAAO,EACP,EAAE,EACF,IAAI,EACJ,IAAI,GAAG,IAAI,EACX,KAAK,EACL,WAAW,EACX,eAAe,EACf,MAAM,EACN,IAAI,GAAG,MAAM,GACd,GAAG,KAAK,CAAC;IAEV,MAAM,WAAW,GAAG,MAAM,CAA0B,IAAI,CAAC,CAAC;IAC1D,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAE3C,MAAM,UAAU,GAAG,CAAC,WAAgB,EAAE,EAAE;QACtC,IAAI,GAAG;YAAE,GAAG,CAAC,OAAO,GAAG,WAAW,CAAC;QACnC,WAAW,CAAC,OAAO,GAAG,WAAW,CAAC;IACpC,CAAC,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,KAAK,GAAG,WAAW,CAAC,OAA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EAClB,YAAY,EAAC,MAAM,EACnB,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,OAAO,GAChB,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":"","sources":["../../src/TextField/TextField.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,eAAe;IACb,KAAK,EAAE,WAAW;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,GAAG,EAAE;IAChC,MAAM,mBAAmB,GAAG,GAAG,EAAE,CAAC,CAChC;QACE,6BAAK,SAAS,EAAC,cAAc;YAC3B,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,KAAK,EAAC,gBAAgB,GAAG,CAChC;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,WAAW,EAAC,kBAAkB,GAAG,CACxC;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,KAAK,EAAC,WAAW,EAAC,QAAQ,EAAE,IAAI,GAAI,CAC3C;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,GAAG,CACjC,CACF;QAEN,6BAAK,SAAS,EAAC,yCAAyC;YACtD,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,KAAK,EAAC,gBAAgB,GAAG,CAChC;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,WAAW,EAAC,kBAAkB,GAAG,CACxC;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,KAAK,EAAC,WAAW,EAAC,QAAQ,EAAE,IAAI,GAAI,CAC3C;YACN,6BAAK,SAAS,EAAC,QAAQ;gBACrB,oBAAC,SAAS,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,EAAC,IAAI,GAAG,CACjC,CACF,CACL,CACJ,CAAC;IACF,OAAO,CACL,6BAAK,SAAS,EAAC,iCAAiC;QAC9C,6BAAK,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=TextField.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextField.test.js","sourceRoot":"","sources":["../../src/TextField/TextField.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;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,MAAM,OAAO;QACX,MAAM,GAAG,iBAAiB,CAAC;QAC3B,KAAK,GAAmB;YACtB,QAAQ,EAAE,IAAI,CAAC,EAAE,EAAE;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;KACH;IAED,IAAI,EAAW,CAAC;IAChB,UAAU,CAAC,GAAG,EAAE;QACd,EAAE,GAAG,IAAI,OAAO,EAAE,CAAC;IACrB,CAAC,CAAC,CAAC;IACH,MAAM,eAAe,GAAG,CAAC,KAAqB,EAAE,EAAE,CAAC,MAAM,CAAC,oBAAC,SAAS,OAAK,KAAK,GAAI,CAAC,CAAC;IAEpF,EAAE,CAAC,4BAA4B,EAAE,GAAG,EAAE;QACpC,MAAM,KAAK,GAAG,OAAO,CAAC;QACtB,eAAe,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;QACxC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,WAAW,GAAG,iBAAiB,CAAC;QACtC,eAAe,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,WAAW,EAAE,CAAC,CAAC;QAC9C,MAAM,CAAC,MAAM,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"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
type FormControlElement = HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement;
|
|
1
2
|
export interface TextFieldProps {
|
|
2
3
|
readonly?: boolean;
|
|
3
4
|
onChange?: React.ChangeEventHandler<FormControlElement>;
|
|
@@ -12,3 +13,4 @@ export interface TextFieldProps {
|
|
|
12
13
|
testId?: string;
|
|
13
14
|
ref?: any;
|
|
14
15
|
}
|
|
16
|
+
export {};
|
|
@@ -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"}
|