@xqmsg/ui-core 0.23.1-rc.0 → 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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.23.1-rc.0",
2
+ "version": "0.23.1-rc.1",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -187,6 +187,7 @@ const Template: Story<InputProps<StoryFormSchema>> = args => {
187
187
  control={form.control}
188
188
  ariaLabel="expires in input"
189
189
  defaultValue={'value1'}
190
+ variant="mobile"
190
191
  />
191
192
  <Input
192
193
  {...args}
@@ -8,6 +8,7 @@ export interface StackedInputProps extends InputFieldProps {
8
8
  leftElement?: React.ReactNode;
9
9
  rightElement?: React.ReactNode;
10
10
  variant?: string;
11
+ label?: string;
11
12
  }
12
13
 
13
14
  /**
@@ -23,21 +24,25 @@ const StackedInput = React.forwardRef<HTMLInputElement, StackedInputProps>(
23
24
  defaultValue,
24
25
  allowDefault,
25
26
  variant,
27
+ label,
26
28
  ...props
27
29
  },
28
30
  _ref
29
31
  ) => {
32
+ const isMobile = variant === 'mobile';
33
+ const placeholder = isMobile && label ? label : undefined;
30
34
  return (
31
35
  <InputGroup>
32
36
  {leftElement && leftElement}
33
- {variant}
37
+ {label}
34
38
  <Input
39
+ {...props}
40
+ placeholder={placeholder}
35
41
  type={type}
36
42
  isRequired={isRequired}
37
- {...props}
38
43
  ref={_ref}
39
44
  defaultValue={defaultValue}
40
- fontSize={variant === 'mobile' ? '17px' : '13px'}
45
+ fontSize={isMobile ? '17px' : '13px'}
41
46
  variant={variant}
42
47
  onKeyDown={e => {
43
48
  if (e.key === 'Enter' && !allowDefault) {
@@ -19,6 +19,7 @@ export interface StackedPilledInputProps extends InputFieldProps {
19
19
  control: Control<FieldValues, any>;
20
20
  separators?: string[];
21
21
  variant?: string;
22
+ label?: string;
22
23
  }
23
24
 
24
25
  /**
@@ -37,6 +38,7 @@ const StackedPilledInput = React.forwardRef<
37
38
  disabled,
38
39
  separators = ['Enter', ' ', ',', ';', 'Tab'],
39
40
  variant,
41
+ label,
40
42
  },
41
43
  _ref
42
44
  ) => {
@@ -258,6 +260,22 @@ const StackedPilledInput = React.forwardRef<
258
260
  borderRadius={isMobile ? '0' : '4px'}
259
261
  alignItems="center"
260
262
  justifyContent="space-between"
263
+ style={
264
+ isMobile
265
+ ? {
266
+ cursor: 'pointer',
267
+ height: '48px',
268
+ fontSize: '17px',
269
+ lineHeight: '20px',
270
+ fontWeight: 400,
271
+ padding: '12px 16px 12px 0px',
272
+ borderRadius: 0,
273
+ border: '0.5px solid rgba(153, 153, 153, 0.1)',
274
+ borderLeft: 'none',
275
+ borderRight: 'none',
276
+ }
277
+ : undefined
278
+ }
261
279
  onClick={() => {
262
280
  if (isFocussed && tokenIndex !== null) {
263
281
  setTokenIndex(null);
@@ -349,7 +367,13 @@ const StackedPilledInput = React.forwardRef<
349
367
  setIsFocussed(false);
350
368
  return setTokenIndex(null);
351
369
  }}
370
+ placeholder={
371
+ isMobile && label && lastestFormValueToArray.length === 0
372
+ ? (label as string)
373
+ : ''
374
+ }
352
375
  variant={variant}
376
+ style={isMobile ? { border: 'none' } : undefined}
353
377
  />
354
378
  </Flex>
355
379
  )}
@@ -6,6 +6,7 @@ export interface StackedTextareaProps extends TextareaFieldProps {
6
6
  isRequired?: boolean;
7
7
  allowDefault?: boolean;
8
8
  variant: string;
9
+ label?: string;
9
10
  }
10
11
 
11
12
  /**
@@ -14,16 +15,17 @@ export interface StackedTextareaProps extends TextareaFieldProps {
14
15
  const StackedTextarea = React.forwardRef<
15
16
  HTMLTextAreaElement,
16
17
  StackedTextareaProps
17
- >(({ isRequired, allowDefault, variant, ...props }, _ref) => {
18
- if (variant === 'mobile') {
18
+ >(({ isRequired, allowDefault, variant, label, ...props }, _ref) => {
19
+ const isMobile = variant === 'mobile';
20
+ if (isMobile) {
19
21
  return (
20
22
  <Flex>
21
- {allowDefault}
22
23
  <Textarea
23
24
  ref={_ref}
24
25
  {...props}
25
26
  variant={variant}
26
27
  fontSize="17px"
28
+ placeholder={label ?? ''}
27
29
  onKeyDown={e => {
28
30
  if (e.key === 'Enter' && !allowDefault) {
29
31
  e.stopPropagation();
@@ -39,7 +41,7 @@ const StackedTextarea = React.forwardRef<
39
41
  ref={_ref}
40
42
  {...props}
41
43
  variant={variant}
42
- fontSize={variant === '' ? '13px' : '17px'}
44
+ fontSize="13px"
43
45
  onKeyDown={e => {
44
46
  if (e.key === 'Enter' && !allowDefault) {
45
47
  e.stopPropagation();
@@ -110,6 +110,7 @@ export function Input<T extends FieldValues>({
110
110
  value={value}
111
111
  allowDefault={allowDefault}
112
112
  variant={variant}
113
+ label={label as string}
113
114
  />
114
115
  );
115
116
  case 'radio':
@@ -165,6 +166,7 @@ export function Input<T extends FieldValues>({
165
166
  disabled={disabled}
166
167
  value={value}
167
168
  variant={variant}
169
+ label={label as string}
168
170
  />
169
171
  );
170
172
  case 'checkbox':
@@ -224,6 +226,7 @@ export function Input<T extends FieldValues>({
224
226
  control={control as Control<FieldValues, any>}
225
227
  maxLength={maxLength}
226
228
  variant={variant}
229
+ label={label}
227
230
  />
228
231
  );
229
232
  case 'switch':
@@ -1,5 +1,5 @@
1
- import React, { useEffect, useState } from 'react';
2
- import { Box, Flex, Select } from '@chakra-ui/react';
1
+ import React, { useEffect } from 'react';
2
+ import { Select } from '@chakra-ui/react';
3
3
  import {
4
4
  FormControl,
5
5
  FormErrorMessage,
@@ -64,41 +64,37 @@ export const SelectNative: React.FC<SelectNativeProps<HTMLSelectElement>> = ({
64
64
  ...props
65
65
  }) => {
66
66
  // const [selectedOption, setSelectedOption] = useState(
67
- // options.find(option => option.value === value)?.label ?? ''
67
+ // options ? options[0] ?? '' : ''
68
68
  // );
69
69
 
70
- const [selectedOption, setSelectedOption] = useState(
71
- options ? options[0] ?? '' : ''
72
- );
73
-
74
- //const [selectedOption, setSelectedOption] = useState(null);
75
-
76
- // useEffect(() => {
77
- // if (defaultValue) {
78
- // setSelectedOption(defaultValue);
79
- // }
80
- // setSelectedOption(
81
- // (fullOptions || options).find(option => option.value === value)?.label ??
82
- // ''
83
- // );
84
- // }, [fullOptions, value]);
70
+ const style = {
71
+ cursor: 'pointer',
72
+ color: 'var(--chakra-colors-blue-500)',
73
+ height: '48px',
74
+ fontSize: '17px',
75
+ lineHeight: '20px',
76
+ fontWeight: 400,
77
+ padding: '12px 16px 12px 0px',
78
+ borderRadius: 0,
79
+ border: '0.5px solid rgba(153, 153, 153, 0.1)',
80
+ borderLeft: 'none',
81
+ borderRight: 'none',
82
+ };
85
83
 
86
84
  const handleOnSelectItem = (selectedValue: string) => {
87
- console.log(selectedValue);
88
85
  const selectedOption = options?.find(
89
86
  ({ value: val }) => selectedValue === val
90
87
  );
91
- console.log(selectedValue);
92
- setValue(name as string, selectedValue);
88
+
93
89
  if (selectedOption) {
94
90
  if (onChange) {
95
91
  onChange(selectedOption.value);
96
92
  }
97
- setSelectedOption(selectedOption);
98
93
  setValue(name as string, selectedOption.value);
94
+ } else {
95
+ setValue(name as string, selectedValue);
99
96
  }
100
97
  };
101
- console.log(selectedOption);
102
98
 
103
99
  useEffect(() => {
104
100
  if (defaultValue) {
@@ -110,68 +106,28 @@ export const SelectNative: React.FC<SelectNativeProps<HTMLSelectElement>> = ({
110
106
  <Controller
111
107
  control={control}
112
108
  name={name}
113
- // defaultValue={defaultValue as PathValue<T, Path<T>>}
114
109
  rules={{ required: isRequired }}
115
110
  /** @ts-ignore: issues with implicit */
116
111
  render={({ field: { onBlur, onChange: fieldOnChange, ref, value } }) => (
117
112
  <FormControl id={name} isInvalid={isInvalid} position="relative" py={0}>
118
- {/* {label &&
119
- !nonLabeledInputs.includes(inputType) &&
120
- variant !== 'mobile' && (
121
- <Label
122
- tooltipText={tooltipText}
123
- label={label}
124
- isRequired={isRequired}
125
- />
126
- )} */}
127
- <Box //ref={dropdownRef}
128
- position="relative"
113
+ <Select
114
+ {...props}
115
+ required={isRequired}
116
+ ref={ref}
117
+ value={value}
118
+ disabled={disabled ?? false}
119
+ onChange={e => handleOnSelectItem(e.target.value)}
120
+ style={style}
129
121
  >
130
- <Flex
131
- flexDirection="column"
132
- //ref={dropdownRef}
133
- //scrollMargin="15px"
134
- border="0"
135
- mt="3px"
136
- //maxH="240px"
137
- overflowY="auto"
138
- width="fit-content"
139
- minWidth="100%"
140
- zIndex={100}
141
- tabIndex={-2000}
142
- borderTop="0.5px solid #9999991A"
143
- >
144
- <Select
145
- {...props}
146
- required={isRequired}
147
- ref={ref}
148
- //value={selectedOption?.value ?? value}
149
- // textShadow={`0 0 0 ${colors.label.primary.light}`}
150
- disabled={disabled ?? false}
151
- onChange={e => handleOnSelectItem(e.target.value)}
152
- // onKeyDown={handleOnKeyDown}
153
- style={{
154
- cursor: 'pointer',
155
- color: 'var(--chakra-colors-blue-500)',
156
- height: '48px',
157
- fontSize: '17px',
158
- lineHeight: '20px',
159
- fontWeight: 400,
160
- padding: '12px 16px 12px 0px',
161
- borderRadius: 0,
162
- }}
163
- >
164
- {options &&
165
- options.map(i => {
166
- return (
167
- <option value={i.value} key={i.sortValue}>
168
- {i.label}
169
- </option>
170
- );
171
- })}
172
- </Select>
173
- </Flex>
174
- </Box>
122
+ {options &&
123
+ options.map(i => {
124
+ return (
125
+ <option value={i.value} key={i.sortValue}>
126
+ {i.label}
127
+ </option>
128
+ );
129
+ })}
130
+ </Select>
175
131
  {isInvalid ? (
176
132
  <FormErrorMessage>{errorText}</FormErrorMessage>
177
133
  ) : (
@@ -90,7 +90,7 @@ const variantPrimaryFlat = () => {
90
90
  border: '0.5px',
91
91
  gap: '8px',
92
92
  height: '44px',
93
- margin: '8px',
93
+ // margin: '8px',
94
94
  fontSize: '17px',
95
95
  fontWeight: '500',
96
96
  lineHeight: '24px',
@@ -8,12 +8,15 @@ const {
8
8
 
9
9
  const roundedCheckbox = definePartsStyle({
10
10
  control: {
11
- borderRadius: 50,
12
- padding: 3,
11
+ //borderRadius: 50,
13
12
  },
14
13
  label: {
15
14
  fontSize: '17px',
15
+ fontWeight: 400,
16
+ lineHeight: '20px',
17
+ padding: '12px 16px 12px 0px',
16
18
  },
19
+ height: '44px',
17
20
  });
18
21
 
19
22
  const variants = {
@@ -26,6 +26,9 @@ const baseStyle = {
26
26
  border: '2px solid',
27
27
  borderColor: colors.border.focus,
28
28
  },
29
+ _placeholder: {
30
+ color: colors.label.secondary.light,
31
+ },
29
32
  },
30
33
  };
31
34
 
@@ -33,13 +36,18 @@ const mobileInputs = {
33
36
  ...baseStyle,
34
37
  field: {
35
38
  fontSize: '17px',
36
- border: 'none',
37
39
  py: '14px',
38
40
  px: '16px',
39
41
  cursor: 'pointer',
40
42
  lineHeight: '21px',
41
43
  fontWeight: 400,
42
44
  borderRadius: 0,
45
+ height: '48px',
46
+ padding: '12px 16px 12px 0px',
47
+ border: '0.5px solid rgba(153, 153, 153, 0.1)',
48
+ borderColor: 'rgba(153, 153, 153, 0.1)',
49
+ borderLeft: 'none',
50
+ borderRight: 'none',
43
51
  },
44
52
  };
45
53
 
@@ -17,15 +17,16 @@ const mobileInputs = defineStyle({
17
17
  ...Input.variants.mobile.field,
18
18
  border: 'none',
19
19
  borderRadius: 0,
20
- paddingY: '14px',
21
- paddingX: '16px',
22
- padding: '14px 16px',
20
+ paddingY: '16px',
21
+ paddingX: '0',
22
+ // padding: '16px 16px',
23
23
  cursor: 'pointer',
24
24
  lineHeight: '21px',
25
25
  fontWeight: 400,
26
26
  resize: 'none',
27
27
  overflowY: 'auto',
28
28
  fontSize: '17px',
29
+ minHeight: '208px',
29
30
  });
30
31
 
31
32
  const variants = { default: baseStyle, mobile: mobileInputs };