@xqmsg/ui-core 0.8.0
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/LICENSE +21 -0
- package/README.md +181 -0
- package/dist/components/banner/Banner.stories.d.ts +5 -0
- package/dist/components/banner/index.d.ts +12 -0
- package/dist/components/breadcrumbs/Breadcrumbs.stories.d.ts +5 -0
- package/dist/components/breadcrumbs/components/icon/index.d.ts +9 -0
- package/dist/components/breadcrumbs/components/label/index.d.ts +8 -0
- package/dist/components/breadcrumbs/index.d.ts +14 -0
- package/dist/components/button/Button.stories.d.ts +5 -0
- package/dist/components/button/google/GoogleButton.stories.d.ts +5 -0
- package/dist/components/button/google/index.d.ts +8 -0
- package/dist/components/button/index.d.ts +20 -0
- package/dist/components/button/spinner/SpinnerButton.stories.d.ts +5 -0
- package/dist/components/button/spinner/index.d.ts +9 -0
- package/dist/components/form/Form.stories.d.ts +8 -0
- package/dist/components/form/FormTypes.d.ts +16 -0
- package/dist/components/form/hooks/useFormHandler.d.ts +10 -0
- package/dist/components/form/index.d.ts +12 -0
- package/dist/components/form/section/FormSection.stories.d.ts +9 -0
- package/dist/components/form/section/index.d.ts +28 -0
- package/dist/components/form/utils/formErrors.d.ts +6 -0
- package/dist/components/input/Input.stories.d.ts +8 -0
- package/dist/components/input/InputTypes.d.ts +27 -0
- package/dist/components/input/StackedCheckbox/StackedCheckboxGroup.d.ts +10 -0
- package/dist/components/input/StackedInput/StackedInput.d.ts +13 -0
- package/dist/components/input/StackedMultiSelect/components/MultiValue/index.d.ts +10 -0
- package/dist/components/input/StackedMultiSelect/index.d.ts +13 -0
- package/dist/components/input/StackedPilledInput/index.d.ts +12 -0
- package/dist/components/input/StackedRadio/StackedRadioGroup.d.ts +11 -0
- package/dist/components/input/StackedSelect/StackedSelect.d.ts +10 -0
- package/dist/components/input/StackedSwitch/index.d.ts +9 -0
- package/dist/components/input/StackedTextarea/StackedTextarea.d.ts +9 -0
- package/dist/components/input/components/InputTag/index.d.ts +7 -0
- package/dist/components/input/index.d.ts +26 -0
- package/dist/components/layout/BorderedBox/index.d.ts +9 -0
- package/dist/components/layout/Layout.stories.d.ts +5 -0
- package/dist/components/layout/index.d.ts +11 -0
- package/dist/components/loading/LoadingIndicator.stories.d.ts +5 -0
- package/dist/components/loading/index.d.ts +12 -0
- package/dist/components/table/Table.stories.d.ts +6 -0
- package/dist/components/table/TableTypes.d.ts +11 -0
- package/dist/components/table/index.d.ts +17 -0
- package/dist/components/table/loading/index.d.ts +10 -0
- package/dist/components/table/utils/generateTableColumns.d.ts +6 -0
- package/dist/components/tabs/TabsWrapper.stories.d.ts +6 -0
- package/dist/components/tabs/index.d.ts +10 -0
- package/dist/components/text/Text.stories.d.ts +5 -0
- package/dist/components/text/index.d.ts +19 -0
- package/dist/hooks/useDeepEffect.d.ts +5 -0
- package/dist/hooks/useDidMountEffect.d.ts +2 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +8 -0
- package/dist/theme/components/alert.d.ts +46 -0
- package/dist/theme/components/badge.d.ts +32 -0
- package/dist/theme/components/button.d.ts +231 -0
- package/dist/theme/components/code.d.ts +27 -0
- package/dist/theme/components/form-error.d.ts +16 -0
- package/dist/theme/components/form-label.d.ts +15 -0
- package/dist/theme/components/form.d.ts +16 -0
- package/dist/theme/components/input.d.ts +182 -0
- package/dist/theme/components/link.d.ts +97 -0
- package/dist/theme/components/menu.d.ts +48 -0
- package/dist/theme/components/modal.d.ts +242 -0
- package/dist/theme/components/select.d.ts +191 -0
- package/dist/theme/components/switch.d.ts +76 -0
- package/dist/theme/components/tabs.d.ts +219 -0
- package/dist/theme/components/text.d.ts +1373 -0
- package/dist/theme/components/textarea.d.ts +137 -0
- package/dist/theme/customXQChakraTheme.d.ts +3 -0
- package/dist/theme/foundations/breakpoints.d.ts +3 -0
- package/dist/theme/foundations/colors.d.ts +126 -0
- package/dist/theme/foundations/shadows.d.ts +17 -0
- package/dist/theme/foundations/typography.d.ts +56 -0
- package/dist/theme/provider/index.d.ts +6 -0
- package/dist/theme/styles.d.ts +20 -0
- package/dist/ui-core.cjs.development.js +3034 -0
- package/dist/ui-core.cjs.development.js.map +1 -0
- package/dist/ui-core.cjs.production.min.js +2 -0
- package/dist/ui-core.cjs.production.min.js.map +1 -0
- package/dist/ui-core.esm.js +3013 -0
- package/dist/ui-core.esm.js.map +1 -0
- package/package.json +113 -0
- package/src/components/banner/Banner.stories.tsx +68 -0
- package/src/components/banner/assets/svg/error.svg +3 -0
- package/src/components/banner/assets/svg/neutral.svg +3 -0
- package/src/components/banner/assets/svg/positive.svg +3 -0
- package/src/components/banner/assets/svg/warning.svg +3 -0
- package/src/components/banner/index.tsx +63 -0
- package/src/components/breadcrumbs/Breadcrumbs.stories.tsx +66 -0
- package/src/components/breadcrumbs/components/icon/index.tsx +40 -0
- package/src/components/breadcrumbs/components/label/index.tsx +20 -0
- package/src/components/breadcrumbs/index.tsx +47 -0
- package/src/components/button/Button.stories.tsx +46 -0
- package/src/components/button/google/GoogleButton.stories.tsx +23 -0
- package/src/components/button/google/assets/GoogleLogo.svg +13 -0
- package/src/components/button/google/index.tsx +32 -0
- package/src/components/button/index.tsx +54 -0
- package/src/components/button/spinner/SpinnerButton.stories.tsx +60 -0
- package/src/components/button/spinner/index.tsx +42 -0
- package/src/components/form/Form.stories.tsx +62 -0
- package/src/components/form/FormTypes.ts +18 -0
- package/src/components/form/hooks/useFormHandler.tsx +74 -0
- package/src/components/form/index.tsx +25 -0
- package/src/components/form/section/FormSection.stories.tsx +109 -0
- package/src/components/form/section/index.tsx +81 -0
- package/src/components/form/utils/formErrors.ts +34 -0
- package/src/components/input/Input.stories.tsx +171 -0
- package/src/components/input/InputTypes.ts +71 -0
- package/src/components/input/StackedCheckbox/StackedCheckboxGroup.tsx +29 -0
- package/src/components/input/StackedInput/StackedInput.tsx +30 -0
- package/src/components/input/StackedMultiSelect/components/MultiValue/index.tsx +21 -0
- package/src/components/input/StackedMultiSelect/index.tsx +145 -0
- package/src/components/input/StackedPilledInput/index.tsx +169 -0
- package/src/components/input/StackedRadio/StackedRadioGroup.tsx +38 -0
- package/src/components/input/StackedSelect/StackedSelect.tsx +33 -0
- package/src/components/input/StackedSwitch/index.tsx +28 -0
- package/src/components/input/StackedTextarea/StackedTextarea.tsx +17 -0
- package/src/components/input/components/InputTag/index.tsx +24 -0
- package/src/components/input/index.tsx +271 -0
- package/src/components/layout/BorderedBox/index.tsx +30 -0
- package/src/components/layout/Layout.stories.tsx +40 -0
- package/src/components/layout/index.tsx +100 -0
- package/src/components/loading/LoadingIndicator.stories.tsx +45 -0
- package/src/components/loading/index.tsx +45 -0
- package/src/components/table/Table.stories.tsx +73 -0
- package/src/components/table/TableTypes.ts +35 -0
- package/src/components/table/index.tsx +88 -0
- package/src/components/table/loading/index.tsx +42 -0
- package/src/components/table/utils/generateTableColumns.ts +9 -0
- package/src/components/tabs/TabsWrapper.stories.tsx +85 -0
- package/src/components/tabs/index.tsx +39 -0
- package/src/components/text/Text.stories.tsx +59 -0
- package/src/components/text/index.tsx +45 -0
- package/src/hooks/useDeepEffect.tsx +22 -0
- package/src/hooks/useDidMountEffect.tsx +13 -0
- package/src/index.tsx +48 -0
- package/src/theme/components/alert.ts +60 -0
- package/src/theme/components/badge.ts +59 -0
- package/src/theme/components/button.ts +211 -0
- package/src/theme/components/code.ts +16 -0
- package/src/theme/components/form-error.ts +32 -0
- package/src/theme/components/form-label.ts +16 -0
- package/src/theme/components/form.ts +32 -0
- package/src/theme/components/input.ts +213 -0
- package/src/theme/components/link.ts +117 -0
- package/src/theme/components/menu.ts +70 -0
- package/src/theme/components/modal.ts +216 -0
- package/src/theme/components/select.ts +41 -0
- package/src/theme/components/switch.ts +89 -0
- package/src/theme/components/tabs.ts +255 -0
- package/src/theme/components/text.ts +46 -0
- package/src/theme/components/textarea.ts +54 -0
- package/src/theme/customXQChakraTheme.ts +52 -0
- package/src/theme/foundations/breakpoints.ts +18 -0
- package/src/theme/foundations/colors.ts +136 -0
- package/src/theme/foundations/shadows.ts +23 -0
- package/src/theme/foundations/typography.ts +62 -0
- package/src/theme/provider/index.tsx +16 -0
- package/src/theme/styles.ts +19 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { Flex } from '@chakra-ui/react';
|
|
3
|
+
import { FieldOptions, ReactSelectFieldProps } from '../InputTypes';
|
|
4
|
+
import ReactSelect from 'react-select';
|
|
5
|
+
import colors from '../../../theme/foundations/colors';
|
|
6
|
+
import MultiValue from './components/MultiValue';
|
|
7
|
+
import {
|
|
8
|
+
Control,
|
|
9
|
+
FieldValues,
|
|
10
|
+
UseFormSetValue,
|
|
11
|
+
useWatch,
|
|
12
|
+
} from 'react-hook-form';
|
|
13
|
+
|
|
14
|
+
export interface StackedMultiSelectProps extends ReactSelectFieldProps {
|
|
15
|
+
options: FieldOptions;
|
|
16
|
+
setValue: UseFormSetValue<FieldValues>;
|
|
17
|
+
control: Control<FieldValues, any>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* A functional React component utilized to render the `StackedMultiSelect` component.
|
|
22
|
+
*/
|
|
23
|
+
const StackedMultiSelect = React.forwardRef<
|
|
24
|
+
HTMLSelectElement,
|
|
25
|
+
StackedMultiSelectProps
|
|
26
|
+
>(({ options, setValue, control, name }, _ref) => {
|
|
27
|
+
const watchedValue = useWatch({ control, name: name as string });
|
|
28
|
+
|
|
29
|
+
const [inputValue, setInputValue] = useState('');
|
|
30
|
+
const [localValue, setLocalValue] = useState([]);
|
|
31
|
+
|
|
32
|
+
// gets latest watched form value (common delimited) from RHF state and creates a list
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (watchedValue !== undefined && !watchedValue.length) {
|
|
35
|
+
setLocalValue([]);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (watchedValue !== undefined && watchedValue?.length) {
|
|
39
|
+
setLocalValue(
|
|
40
|
+
watchedValue
|
|
41
|
+
.split(',')
|
|
42
|
+
.filter(Boolean)
|
|
43
|
+
.map((value: string) =>
|
|
44
|
+
options.find(option => option.value === value)
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
}, [options, watchedValue]);
|
|
49
|
+
|
|
50
|
+
const component = {
|
|
51
|
+
DropdownIndicator: null,
|
|
52
|
+
MultiValue: (props: any) => (
|
|
53
|
+
<MultiValue
|
|
54
|
+
clearValue={() => {
|
|
55
|
+
const arrayValue = watchedValue
|
|
56
|
+
.split(',')
|
|
57
|
+
.filter((_: string, index: number) => index !== props.index);
|
|
58
|
+
|
|
59
|
+
setLocalValue(
|
|
60
|
+
arrayValue.map((value: string) =>
|
|
61
|
+
options.find(option => option.value === value)
|
|
62
|
+
)
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
setValue(name as string, arrayValue.join(','), {
|
|
66
|
+
shouldValidate: true,
|
|
67
|
+
shouldDirty: true,
|
|
68
|
+
});
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
{props.children}
|
|
72
|
+
</MultiValue>
|
|
73
|
+
),
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const handleChange = (values: any) => {
|
|
77
|
+
setValue(
|
|
78
|
+
name as string,
|
|
79
|
+
values.map(({ value }: { value: string }) => value).join(','),
|
|
80
|
+
{
|
|
81
|
+
shouldValidate: true,
|
|
82
|
+
shouldDirty: true,
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const handleInputChange = (value: string, action: any) => {
|
|
88
|
+
if (action.action === 'input-change' && action !== 'set-value') {
|
|
89
|
+
return setInputValue(value);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// reset on select of an option
|
|
93
|
+
return setInputValue('');
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const formatGroupLabel = (data: any) => {
|
|
97
|
+
return (
|
|
98
|
+
<Flex alignItems="center" justifyContent="space-between">
|
|
99
|
+
<span>{data.label}</span>
|
|
100
|
+
</Flex>
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const customStyles = {
|
|
105
|
+
control: () => ({
|
|
106
|
+
borderRadius: '6px',
|
|
107
|
+
fontSize: '16px',
|
|
108
|
+
color: '#202020',
|
|
109
|
+
backgroundColor: '#FFFFFF',
|
|
110
|
+
border: '1px solid',
|
|
111
|
+
borderColor: colors.gray[200],
|
|
112
|
+
minHeight: '48px',
|
|
113
|
+
display: 'flex',
|
|
114
|
+
padding: '2px 6px',
|
|
115
|
+
}),
|
|
116
|
+
menu: () => ({
|
|
117
|
+
boxShadow: '0 5px 5px 0 rgba(16, 27, 79, 0.15)',
|
|
118
|
+
borderRadius: '6px',
|
|
119
|
+
backgroundColor: 'white',
|
|
120
|
+
}),
|
|
121
|
+
indicatorsContainer: () => ({ display: 'none' }),
|
|
122
|
+
placeholder: () => ({ color: '#CBCDCF', fontSize: '16px' }),
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
return (
|
|
126
|
+
<ReactSelect
|
|
127
|
+
components={component}
|
|
128
|
+
inputValue={inputValue}
|
|
129
|
+
value={localValue}
|
|
130
|
+
isClearable
|
|
131
|
+
isSearchable
|
|
132
|
+
isMulti
|
|
133
|
+
menuPortalTarget={document.body}
|
|
134
|
+
menuPosition={'fixed'}
|
|
135
|
+
onChange={handleChange}
|
|
136
|
+
onInputChange={handleInputChange}
|
|
137
|
+
styles={customStyles}
|
|
138
|
+
options={options}
|
|
139
|
+
placeholder={false}
|
|
140
|
+
formatGroupLabel={formatGroupLabel}
|
|
141
|
+
/>
|
|
142
|
+
);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
export default StackedMultiSelect;
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Box, Flex, Input } from '@chakra-ui/react';
|
|
3
|
+
import { InputFieldProps } from '../InputTypes';
|
|
4
|
+
import {
|
|
5
|
+
Control,
|
|
6
|
+
FieldValues,
|
|
7
|
+
UseFormSetValue,
|
|
8
|
+
useWatch,
|
|
9
|
+
} from 'react-hook-form';
|
|
10
|
+
import colors from '../../../theme/foundations/colors';
|
|
11
|
+
import InputTag from '../components/InputTag';
|
|
12
|
+
|
|
13
|
+
export interface StackedPilledInputProps extends InputFieldProps {
|
|
14
|
+
setValue: UseFormSetValue<FieldValues>;
|
|
15
|
+
control: Control<FieldValues, any>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* A functional React component utilized to render the `StackedPilledInput` component.
|
|
20
|
+
*/
|
|
21
|
+
const StackedPilledInput = React.forwardRef<
|
|
22
|
+
HTMLInputElement,
|
|
23
|
+
StackedPilledInputProps
|
|
24
|
+
>(({ name, setValue, control }, _ref) => {
|
|
25
|
+
const watchedValue = useWatch({ control, name: name as string });
|
|
26
|
+
const [lastestFormValueToArray, setLatestFormValueToArray] = useState<
|
|
27
|
+
string[]
|
|
28
|
+
>([]);
|
|
29
|
+
|
|
30
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
31
|
+
|
|
32
|
+
const [isInputFocused, setInputFocused] = useState(false);
|
|
33
|
+
|
|
34
|
+
const [localValue, setLocalValue] = useState('');
|
|
35
|
+
|
|
36
|
+
// gets latest watched form value (common delimited) from RHF state and creates a list
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (watchedValue !== undefined && !watchedValue.length) {
|
|
39
|
+
setLatestFormValueToArray([]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (watchedValue !== undefined && watchedValue?.length) {
|
|
43
|
+
setLatestFormValueToArray(watchedValue.split(',').filter(Boolean));
|
|
44
|
+
}
|
|
45
|
+
}, [watchedValue]);
|
|
46
|
+
|
|
47
|
+
// ensures after value addition that the input field is wiped
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (localValue === ' ' || localValue.trim() === ',') {
|
|
50
|
+
setLocalValue('');
|
|
51
|
+
}
|
|
52
|
+
}, [localValue]);
|
|
53
|
+
|
|
54
|
+
const onHandleKeyDown = (e: React.KeyboardEvent) => {
|
|
55
|
+
if (e.key === ' ' || e.key === 'Enter' || e.key === ',') {
|
|
56
|
+
if (!localValue.trim() || localValue.trim() === ',')
|
|
57
|
+
return setLocalValue('');
|
|
58
|
+
|
|
59
|
+
const filteredUniqueValues = Array.from(
|
|
60
|
+
new Set([...lastestFormValueToArray, ...localValue.trim().split(',')])
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
setLocalValue('');
|
|
64
|
+
|
|
65
|
+
return setValue(
|
|
66
|
+
name as string,
|
|
67
|
+
filteredUniqueValues.toString().replace(/\s/g, ''),
|
|
68
|
+
{
|
|
69
|
+
shouldValidate: true,
|
|
70
|
+
shouldDirty: true,
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const onRemoveTag = (index: number) => {
|
|
77
|
+
const filteredUniqueValues = lastestFormValueToArray.filter(
|
|
78
|
+
(_, i) => i !== index
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
setLatestFormValueToArray(filteredUniqueValues);
|
|
82
|
+
|
|
83
|
+
setValue(
|
|
84
|
+
name as string,
|
|
85
|
+
filteredUniqueValues.toString().replace(/\s/g, ''),
|
|
86
|
+
{
|
|
87
|
+
shouldValidate: true,
|
|
88
|
+
shouldDirty: true,
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const onBlur = () => {
|
|
94
|
+
if (localValue.trim()) {
|
|
95
|
+
const filteredUniqueValues = Array.from(
|
|
96
|
+
new Set([...lastestFormValueToArray, ...localValue.trim().split(',')])
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
setValue(
|
|
100
|
+
name as string,
|
|
101
|
+
filteredUniqueValues.toString().replace(/\s/g, ''),
|
|
102
|
+
{
|
|
103
|
+
shouldValidate: true,
|
|
104
|
+
shouldDirty: true,
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
setLocalValue('');
|
|
108
|
+
}
|
|
109
|
+
setInputFocused(false);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<Flex position="relative" width="100%">
|
|
114
|
+
<Box
|
|
115
|
+
outline={isInputFocused ? '2px solid rgba(0, 122, 255, 255)' : ''}
|
|
116
|
+
borderRadius={isInputFocused ? 'md' : ''}
|
|
117
|
+
width="100%"
|
|
118
|
+
>
|
|
119
|
+
<Flex
|
|
120
|
+
background="rgba(255, 255, 255, 0.8)"
|
|
121
|
+
border="1px solid"
|
|
122
|
+
borderColor={colors.gray[200]}
|
|
123
|
+
borderRadius="6px"
|
|
124
|
+
fontWeight="400"
|
|
125
|
+
fontSize="12px"
|
|
126
|
+
lineHeight="12px"
|
|
127
|
+
minHeight="48px"
|
|
128
|
+
letterSpacing="0.02em"
|
|
129
|
+
padding="0 12px"
|
|
130
|
+
pt={lastestFormValueToArray.length ? '12px' : '0px'}
|
|
131
|
+
alignItems="center"
|
|
132
|
+
flexWrap="wrap"
|
|
133
|
+
gap="0.5em"
|
|
134
|
+
width="100%"
|
|
135
|
+
onClick={() => inputRef.current?.focus()}
|
|
136
|
+
>
|
|
137
|
+
{lastestFormValueToArray.map((tag, index) => (
|
|
138
|
+
<InputTag
|
|
139
|
+
value={tag}
|
|
140
|
+
key={tag}
|
|
141
|
+
onDelete={(e: any) => {
|
|
142
|
+
e.stopPropagation();
|
|
143
|
+
e.preventDefault();
|
|
144
|
+
onRemoveTag(index);
|
|
145
|
+
}}
|
|
146
|
+
/>
|
|
147
|
+
))}
|
|
148
|
+
|
|
149
|
+
<Input
|
|
150
|
+
onKeyDown={onHandleKeyDown}
|
|
151
|
+
type="text"
|
|
152
|
+
padding={isInputFocused ? '0.5em 0' : '0px'}
|
|
153
|
+
height={isInputFocused ? '46px' : '0px'}
|
|
154
|
+
width="100%"
|
|
155
|
+
border="none"
|
|
156
|
+
_focus={{ boxShadow: 'none !important' }}
|
|
157
|
+
value={localValue}
|
|
158
|
+
onBlur={onBlur}
|
|
159
|
+
onChange={e => setLocalValue(e.target.value)}
|
|
160
|
+
ref={inputRef}
|
|
161
|
+
onFocus={() => setInputFocused(true)}
|
|
162
|
+
/>
|
|
163
|
+
</Flex>
|
|
164
|
+
</Box>
|
|
165
|
+
</Flex>
|
|
166
|
+
);
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
export default StackedPilledInput;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Flex, InputGroup, Radio, RadioGroup } from '@chakra-ui/react';
|
|
3
|
+
import { FieldOptions, SelectFieldProps } from '../InputTypes';
|
|
4
|
+
|
|
5
|
+
export interface StackedRadioGroupProps extends SelectFieldProps {
|
|
6
|
+
flexDirection?: 'row' | 'column';
|
|
7
|
+
|
|
8
|
+
options: FieldOptions;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A functional React component utilized to render the `StackedRadio` component.
|
|
13
|
+
*/
|
|
14
|
+
const StackedRadioGroup = React.forwardRef<
|
|
15
|
+
HTMLInputElement,
|
|
16
|
+
StackedRadioGroupProps
|
|
17
|
+
>(({ id, flexDirection = 'row', options }, _ref) => {
|
|
18
|
+
return (
|
|
19
|
+
<InputGroup>
|
|
20
|
+
<RadioGroup name={id}>
|
|
21
|
+
{options.map(option => (
|
|
22
|
+
<Flex
|
|
23
|
+
mr="30px"
|
|
24
|
+
alignItems="center"
|
|
25
|
+
key={option.value}
|
|
26
|
+
flexDirection={flexDirection}
|
|
27
|
+
>
|
|
28
|
+
<Radio ref={_ref} value={option.value}>
|
|
29
|
+
{option.label}
|
|
30
|
+
</Radio>
|
|
31
|
+
</Flex>
|
|
32
|
+
))}
|
|
33
|
+
</RadioGroup>
|
|
34
|
+
</InputGroup>
|
|
35
|
+
);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
export default StackedRadioGroup;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { InputGroup, Select } from '@chakra-ui/react';
|
|
3
|
+
import { FieldOptions, SelectFieldProps } from '../InputTypes';
|
|
4
|
+
|
|
5
|
+
export interface StackedSelectProps extends SelectFieldProps {
|
|
6
|
+
options: FieldOptions;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* A functional React component utilized to render the `StackedSelect` component.
|
|
11
|
+
*/
|
|
12
|
+
const StackedSelect = React.forwardRef<HTMLSelectElement, StackedSelectProps>(
|
|
13
|
+
({ isRequired, options, onChange, ...props }, _ref) => {
|
|
14
|
+
return (
|
|
15
|
+
<InputGroup>
|
|
16
|
+
<Select
|
|
17
|
+
ref={_ref}
|
|
18
|
+
isRequired={isRequired}
|
|
19
|
+
onChange={onChange}
|
|
20
|
+
{...props}
|
|
21
|
+
>
|
|
22
|
+
{options.map(option => (
|
|
23
|
+
<option value={option.value} key={option.value}>
|
|
24
|
+
{option.label}
|
|
25
|
+
</option>
|
|
26
|
+
))}
|
|
27
|
+
</Select>
|
|
28
|
+
</InputGroup>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
export default StackedSelect;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Switch, SwitchProps } from '@chakra-ui/react';
|
|
3
|
+
|
|
4
|
+
export interface StackedSwitchProps extends SwitchProps {}
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A functional React component utilized to render the `StackedSwitch` component.
|
|
8
|
+
*/
|
|
9
|
+
const StackedSwitch = React.forwardRef<HTMLInputElement, StackedSwitchProps>(
|
|
10
|
+
({ isRequired, onChange, value }, _ref) => {
|
|
11
|
+
if (value === undefined) return null;
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<Switch
|
|
15
|
+
size="lg"
|
|
16
|
+
ref={_ref}
|
|
17
|
+
isRequired={isRequired}
|
|
18
|
+
value={String(value)}
|
|
19
|
+
defaultChecked={Boolean(value)}
|
|
20
|
+
onChange={e => {
|
|
21
|
+
if (onChange) return onChange(e.target.checked as any);
|
|
22
|
+
}}
|
|
23
|
+
/>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export default StackedSwitch;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Textarea } from '@chakra-ui/react';
|
|
3
|
+
import { TextareaFieldProps } from '../InputTypes';
|
|
4
|
+
|
|
5
|
+
export interface StackedTextareaProps extends TextareaFieldProps {}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A functional React component utilized to render the `StackedTextarea` component.
|
|
9
|
+
*/
|
|
10
|
+
const StackedTextarea = React.forwardRef<
|
|
11
|
+
HTMLTextAreaElement,
|
|
12
|
+
StackedTextareaProps
|
|
13
|
+
>(({ ...props }, _ref) => {
|
|
14
|
+
return <Textarea ref={_ref} {...props} />;
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export default StackedTextarea;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Tag, TagCloseButton, TagLabel } from '@chakra-ui/react';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
interface InputTagProps {
|
|
5
|
+
value: any;
|
|
6
|
+
onDelete?: any;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const InputTag: React.FC<InputTagProps> = ({ value, onDelete }) => {
|
|
10
|
+
return (
|
|
11
|
+
<Tag
|
|
12
|
+
size={'md'}
|
|
13
|
+
key={value}
|
|
14
|
+
borderRadius="full"
|
|
15
|
+
variant="solid"
|
|
16
|
+
backgroundColor="#eeeeee"
|
|
17
|
+
>
|
|
18
|
+
<TagLabel color={'gray.700'}>{value}</TagLabel>
|
|
19
|
+
{onDelete && <TagCloseButton color={'gray.700'} onClick={onDelete} />}
|
|
20
|
+
</Tag>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default InputTag;
|