@xqmsg/ui-core 0.22.4 → 0.23.1-rc.1
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/components/form/FormTypes.d.ts +2 -0
- package/dist/components/input/StackedCheckbox/StackedCheckbox.d.ts +3 -2
- package/dist/components/input/StackedInput/StackedInput.d.ts +2 -0
- package/dist/components/input/StackedPilledInput/index.d.ts +3 -0
- package/dist/components/input/StackedTextarea/StackedTextarea.d.ts +4 -0
- package/dist/components/input/components/token/index.d.ts +1 -0
- package/dist/components/input/index.d.ts +3 -2
- package/dist/components/select/index.d.ts +27 -0
- package/dist/index.d.ts +1 -0
- package/dist/theme/components/button.d.ts +113 -0
- package/dist/theme/components/checkbox.d.ts +29 -0
- package/dist/theme/components/input.d.ts +23 -0
- package/dist/theme/components/select.d.ts +23 -0
- package/dist/theme/components/textarea.d.ts +78 -0
- package/dist/ui-core.cjs.development.js +336 -54
- package/dist/ui-core.cjs.development.js.map +1 -1
- package/dist/ui-core.cjs.production.min.js +1 -1
- package/dist/ui-core.cjs.production.min.js.map +1 -1
- package/dist/ui-core.esm.js +338 -57
- package/dist/ui-core.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/button/Button.stories.tsx +92 -27
- package/src/components/form/FormTypes.ts +2 -0
- package/src/components/form/section/index.tsx +2 -0
- package/src/components/input/Input.stories.tsx +67 -0
- package/src/components/input/StackedCheckbox/StackedCheckbox.tsx +12 -4
- package/src/components/input/StackedInput/StackedInput.tsx +11 -1
- package/src/components/input/StackedPilledInput/index.tsx +310 -266
- package/src/components/input/StackedTextarea/StackedTextarea.tsx +30 -4
- package/src/components/input/components/dropdown/index.tsx +1 -1
- package/src/components/input/components/token/index.tsx +6 -5
- package/src/components/input/index.tsx +25 -9
- package/src/components/select/index.tsx +140 -0
- package/src/components/tabs/TabsWrapper.stories.tsx +1 -1
- package/src/index.tsx +3 -0
- package/src/theme/components/button.ts +67 -0
- package/src/theme/components/checkbox.ts +28 -0
- package/src/theme/components/input.ts +23 -1
- package/src/theme/components/textarea.ts +21 -0
- package/src/theme/customXQChakraTheme.ts +2 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Meta, Story } from '@storybook/react';
|
|
3
3
|
import { Button, ButtonProps } from '.';
|
|
4
|
-
import { Flex } from '@chakra-ui/react';
|
|
4
|
+
import { Box, Flex } from '@chakra-ui/react';
|
|
5
5
|
|
|
6
6
|
const meta: Meta<ButtonProps> = {
|
|
7
7
|
title: 'Button example',
|
|
@@ -38,32 +38,97 @@ const meta: Meta<ButtonProps> = {
|
|
|
38
38
|
export default meta;
|
|
39
39
|
const Template: Story<ButtonProps> = args => (
|
|
40
40
|
<Flex flexDir="column" height="150px" justifyContent="space-between">
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
41
|
+
<Box p={5}>
|
|
42
|
+
<Button {...args} text="Primary Fixed" variant="primary" width="fixed" />
|
|
43
|
+
</Box>
|
|
44
|
+
<Box p={5}>
|
|
45
|
+
<Button
|
|
46
|
+
{...args}
|
|
47
|
+
text="Secondary Fixed"
|
|
48
|
+
variant="secondary"
|
|
49
|
+
width="fixed"
|
|
50
|
+
/>
|
|
51
|
+
</Box>
|
|
52
|
+
<Box p={5}>
|
|
53
|
+
<Button
|
|
54
|
+
{...args}
|
|
55
|
+
text="Tertiary Fixed"
|
|
56
|
+
variant="tertiary"
|
|
57
|
+
width="fixed"
|
|
58
|
+
/>
|
|
59
|
+
</Box>
|
|
60
|
+
<Box p={5}>
|
|
61
|
+
<Button
|
|
62
|
+
{...args}
|
|
63
|
+
text="Primary Variable"
|
|
64
|
+
variant="primary"
|
|
65
|
+
width="variable"
|
|
66
|
+
/>
|
|
67
|
+
</Box>
|
|
68
|
+
<Box p={5}>
|
|
69
|
+
<Button
|
|
70
|
+
{...args}
|
|
71
|
+
text="Secondary Variable"
|
|
72
|
+
variant="secondary"
|
|
73
|
+
width="variable"
|
|
74
|
+
/>
|
|
75
|
+
</Box>
|
|
76
|
+
<Box p={5}>
|
|
77
|
+
<Button
|
|
78
|
+
{...args}
|
|
79
|
+
text="Tertiary Variable"
|
|
80
|
+
variant="tertiary"
|
|
81
|
+
width="variable"
|
|
82
|
+
/>
|
|
83
|
+
</Box>
|
|
84
|
+
<Box p={5}>
|
|
85
|
+
<Button
|
|
86
|
+
{...args}
|
|
87
|
+
text="Primary Variable Flat"
|
|
88
|
+
variant="flat-primary"
|
|
89
|
+
width="variable"
|
|
90
|
+
/>
|
|
91
|
+
</Box>
|
|
92
|
+
<Box p={5}>
|
|
93
|
+
<Button
|
|
94
|
+
{...args}
|
|
95
|
+
text="Secondary Variable Flat"
|
|
96
|
+
variant="flat-secondary"
|
|
97
|
+
width="variable"
|
|
98
|
+
/>
|
|
99
|
+
</Box>
|
|
100
|
+
<Box p={5}>
|
|
101
|
+
<Button
|
|
102
|
+
{...args}
|
|
103
|
+
text="Tertiary Variable Flat"
|
|
104
|
+
variant="flat-tertiary"
|
|
105
|
+
width="variable"
|
|
106
|
+
/>
|
|
107
|
+
</Box>
|
|
108
|
+
<Box p={5}>
|
|
109
|
+
<Button
|
|
110
|
+
{...args}
|
|
111
|
+
text="Primary Fixed Flat"
|
|
112
|
+
variant="flat-primary"
|
|
113
|
+
width="fixed"
|
|
114
|
+
/>
|
|
115
|
+
</Box>
|
|
116
|
+
<Box p={5}>
|
|
117
|
+
<Button
|
|
118
|
+
{...args}
|
|
119
|
+
text="Secondary Fixed Flat"
|
|
120
|
+
variant="flat-secondary"
|
|
121
|
+
width="fixed"
|
|
122
|
+
/>
|
|
123
|
+
</Box>
|
|
124
|
+
<Box p={5}>
|
|
125
|
+
<Button
|
|
126
|
+
{...args}
|
|
127
|
+
text="Tertiary Fixed Flat"
|
|
128
|
+
variant="flat-tertiary"
|
|
129
|
+
width="fixed"
|
|
130
|
+
/>
|
|
131
|
+
</Box>
|
|
67
132
|
</Flex>
|
|
68
133
|
);
|
|
69
134
|
|
|
@@ -60,6 +60,7 @@ export function FormSection<
|
|
|
60
60
|
ariaLabel,
|
|
61
61
|
disabled,
|
|
62
62
|
defaultValue,
|
|
63
|
+
variant,
|
|
63
64
|
}: FormInput) => (
|
|
64
65
|
<Input<U>
|
|
65
66
|
key={name}
|
|
@@ -77,6 +78,7 @@ export function FormSection<
|
|
|
77
78
|
setValue={form.setValue}
|
|
78
79
|
setError={form.setError}
|
|
79
80
|
clearErrors={form.clearErrors}
|
|
81
|
+
variant={variant ? variant : ''}
|
|
80
82
|
/>
|
|
81
83
|
)
|
|
82
84
|
)}
|
|
@@ -5,6 +5,7 @@ import { Input, InputProps } from '.';
|
|
|
5
5
|
import { useFormHandler } from '../form/hooks/useFormHandler';
|
|
6
6
|
import * as Yup from 'yup';
|
|
7
7
|
import { Form } from '../form';
|
|
8
|
+
import { SelectNative } from '../select';
|
|
8
9
|
|
|
9
10
|
const meta: Meta<InputProps<StoryFormSchema>> = {
|
|
10
11
|
title: 'Input example',
|
|
@@ -108,9 +109,27 @@ const Template: Story<InputProps<StoryFormSchema>> = args => {
|
|
|
108
109
|
errorText={form.formState.errors['prop5']?.message}
|
|
109
110
|
name="prop5"
|
|
110
111
|
/>
|
|
112
|
+
<Input
|
|
113
|
+
{...args}
|
|
114
|
+
inputType="multi-select"
|
|
115
|
+
variant="mobile"
|
|
116
|
+
setValue={form.setValue}
|
|
117
|
+
setError={form.setError}
|
|
118
|
+
clearErrors={form.clearErrors}
|
|
119
|
+
isInvalid={!!form.formState.errors['prop5']?.message}
|
|
120
|
+
errorText={form.formState.errors['prop5']?.message}
|
|
121
|
+
name="prop5"
|
|
122
|
+
/>
|
|
123
|
+
<Input
|
|
124
|
+
{...args}
|
|
125
|
+
inputType="text"
|
|
126
|
+
name="prop3"
|
|
127
|
+
onChange={e => form.setValue('prop3', e.target.value)}
|
|
128
|
+
/>
|
|
111
129
|
<Input
|
|
112
130
|
{...args}
|
|
113
131
|
inputType="text"
|
|
132
|
+
variant="mobile"
|
|
114
133
|
name="prop3"
|
|
115
134
|
onChange={e => form.setValue('prop3', e.target.value)}
|
|
116
135
|
/>
|
|
@@ -120,9 +139,27 @@ const Template: Story<InputProps<StoryFormSchema>> = args => {
|
|
|
120
139
|
name="prop2"
|
|
121
140
|
onChange={e => form.setValue('prop2', e.target.value)}
|
|
122
141
|
/>
|
|
142
|
+
<Input
|
|
143
|
+
{...args}
|
|
144
|
+
inputType="textarea"
|
|
145
|
+
variant="mobile"
|
|
146
|
+
name="prop2"
|
|
147
|
+
onChange={e => form.setValue('prop2', e.target.value)}
|
|
148
|
+
/>
|
|
149
|
+
<Input
|
|
150
|
+
{...args}
|
|
151
|
+
name="prop"
|
|
152
|
+
inputType="pilled-text"
|
|
153
|
+
setValue={form.setValue}
|
|
154
|
+
setError={form.setError}
|
|
155
|
+
clearErrors={form.clearErrors}
|
|
156
|
+
isInvalid={!!form.formState.errors['prop']?.message}
|
|
157
|
+
errorText={form.formState.errors['prop']?.message}
|
|
158
|
+
/>
|
|
123
159
|
<Input
|
|
124
160
|
{...args}
|
|
125
161
|
name="prop"
|
|
162
|
+
variant="mobile"
|
|
126
163
|
inputType="pilled-text"
|
|
127
164
|
setValue={form.setValue}
|
|
128
165
|
setError={form.setError}
|
|
@@ -135,10 +172,33 @@ const Template: Story<InputProps<StoryFormSchema>> = args => {
|
|
|
135
172
|
inputType="select"
|
|
136
173
|
setValue={form.setValue}
|
|
137
174
|
name="prop4"
|
|
175
|
+
defaultValue={'value1'}
|
|
176
|
+
/>
|
|
177
|
+
<SelectNative
|
|
178
|
+
{...args}
|
|
179
|
+
setValue={form.setValue}
|
|
180
|
+
name="prop4"
|
|
181
|
+
setError={form.setError}
|
|
182
|
+
clearErrors={form.clearErrors}
|
|
183
|
+
isInvalid={!!form.formState.errors['prop']?.message}
|
|
184
|
+
errorText={form.formState.errors['prop']?.message}
|
|
185
|
+
disabled={false}
|
|
186
|
+
isRequired
|
|
187
|
+
control={form.control}
|
|
188
|
+
ariaLabel="expires in input"
|
|
189
|
+
defaultValue={'value1'}
|
|
190
|
+
variant="mobile"
|
|
191
|
+
/>
|
|
192
|
+
<Input
|
|
193
|
+
{...args}
|
|
194
|
+
name="prop6"
|
|
195
|
+
inputType="switch"
|
|
196
|
+
setValue={form.setValue}
|
|
138
197
|
/>
|
|
139
198
|
<Input
|
|
140
199
|
{...args}
|
|
141
200
|
name="prop6"
|
|
201
|
+
variant="mobile"
|
|
142
202
|
inputType="switch"
|
|
143
203
|
setValue={form.setValue}
|
|
144
204
|
/>
|
|
@@ -148,6 +208,13 @@ const Template: Story<InputProps<StoryFormSchema>> = args => {
|
|
|
148
208
|
inputType="checkbox"
|
|
149
209
|
setValue={form.setValue}
|
|
150
210
|
/>
|
|
211
|
+
<Input
|
|
212
|
+
{...args}
|
|
213
|
+
name="prop6"
|
|
214
|
+
inputType="checkbox"
|
|
215
|
+
variant="mobile"
|
|
216
|
+
setValue={form.setValue}
|
|
217
|
+
/>
|
|
151
218
|
</Form>
|
|
152
219
|
);
|
|
153
220
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Checkbox, Text } from '@chakra-ui/react';
|
|
3
|
-
import {
|
|
3
|
+
import { InputFieldProps } from '../InputTypes';
|
|
4
4
|
|
|
5
|
-
export interface StackedCheckboxProps extends
|
|
5
|
+
export interface StackedCheckboxProps extends InputFieldProps {
|
|
6
6
|
label: string;
|
|
7
|
+
variant: string;
|
|
7
8
|
}
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -12,7 +13,7 @@ export interface StackedCheckboxProps extends SelectFieldProps {
|
|
|
12
13
|
const StackedCheckbox = React.forwardRef<
|
|
13
14
|
HTMLInputElement,
|
|
14
15
|
StackedCheckboxProps
|
|
15
|
-
>(({ value, label, onChange, disabled }, _ref) => {
|
|
16
|
+
>(({ value, label, onChange, disabled, variant }, _ref) => {
|
|
16
17
|
if (value === null) return null;
|
|
17
18
|
|
|
18
19
|
return (
|
|
@@ -25,10 +26,17 @@ const StackedCheckbox = React.forwardRef<
|
|
|
25
26
|
}}
|
|
26
27
|
isChecked={Boolean(value)}
|
|
27
28
|
disabled={disabled}
|
|
29
|
+
variant={variant}
|
|
28
30
|
>
|
|
29
|
-
|
|
31
|
+
{/* solved like this because of bug in chakra
|
|
32
|
+
https://github.com/chakra-ui/chakra-ui/issues/7328 */}
|
|
33
|
+
<Text
|
|
34
|
+
fontSize={variant === 'mobile' ? '17px' : '13px'}
|
|
35
|
+
alignSelf="center"
|
|
36
|
+
>
|
|
30
37
|
{label}
|
|
31
38
|
</Text>
|
|
39
|
+
{/* {label} */}
|
|
32
40
|
</Checkbox>
|
|
33
41
|
);
|
|
34
42
|
});
|
|
@@ -7,6 +7,8 @@ export interface StackedInputProps extends InputFieldProps {
|
|
|
7
7
|
allowDefault?: boolean;
|
|
8
8
|
leftElement?: React.ReactNode;
|
|
9
9
|
rightElement?: React.ReactNode;
|
|
10
|
+
variant?: string;
|
|
11
|
+
label?: string;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
/**
|
|
@@ -21,19 +23,27 @@ const StackedInput = React.forwardRef<HTMLInputElement, StackedInputProps>(
|
|
|
21
23
|
leftElement,
|
|
22
24
|
defaultValue,
|
|
23
25
|
allowDefault,
|
|
26
|
+
variant,
|
|
27
|
+
label,
|
|
24
28
|
...props
|
|
25
29
|
},
|
|
26
30
|
_ref
|
|
27
31
|
) => {
|
|
32
|
+
const isMobile = variant === 'mobile';
|
|
33
|
+
const placeholder = isMobile && label ? label : undefined;
|
|
28
34
|
return (
|
|
29
35
|
<InputGroup>
|
|
30
36
|
{leftElement && leftElement}
|
|
37
|
+
{label}
|
|
31
38
|
<Input
|
|
39
|
+
{...props}
|
|
40
|
+
placeholder={placeholder}
|
|
32
41
|
type={type}
|
|
33
42
|
isRequired={isRequired}
|
|
34
|
-
{...props}
|
|
35
43
|
ref={_ref}
|
|
36
44
|
defaultValue={defaultValue}
|
|
45
|
+
fontSize={isMobile ? '17px' : '13px'}
|
|
46
|
+
variant={variant}
|
|
37
47
|
onKeyDown={e => {
|
|
38
48
|
if (e.key === 'Enter' && !allowDefault) {
|
|
39
49
|
e.stopPropagation();
|