@xqmsg/ui-core 0.16.5 → 0.16.7

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.16.5",
2
+ "version": "0.16.7",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -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 { Flex, Grid, GridItem } from '@chakra-ui/react';
8
9
 
9
10
  const meta: Meta<InputProps<StoryFormSchema>> = {
10
11
  title: 'Input example',
@@ -98,7 +99,7 @@ const Template: Story<InputProps<StoryFormSchema>> = args => {
98
99
 
99
100
  return (
100
101
  <Form formHandler={formHandler}>
101
- <Input
102
+ {/* <Input
102
103
  {...args}
103
104
  inputType="multi-select"
104
105
  setValue={form.setValue}
@@ -141,7 +142,57 @@ const Template: Story<InputProps<StoryFormSchema>> = args => {
141
142
  name="prop6"
142
143
  inputType="switch"
143
144
  setValue={form.setValue}
144
- />
145
+ /> */}
146
+ <Flex
147
+ flexDirection="row"
148
+ alignItems="center"
149
+ justifyContent="space-between"
150
+ >
151
+ <Grid templateColumns="repeat(8, 1fr)">
152
+ <GridItem colSpan={1} pr="10px">
153
+ <Input
154
+ label="Long example label"
155
+ inputType="text"
156
+ isRequired
157
+ name={`actions`}
158
+ ariaLabel="{actionInput.ariaLabel}"
159
+ control={form.control}
160
+ setValue={form.setValue}
161
+ defaultValue="{actionInput.defaultValue}"
162
+ setError={form.setError}
163
+ clearErrors={form.clearErrors}
164
+ />
165
+ </GridItem>
166
+ <GridItem colSpan={1} pr="10px">
167
+ <Input
168
+ label="hi"
169
+ inputType="text"
170
+ isRequired
171
+ setValue={form.setValue}
172
+ name={`actions.`}
173
+ ariaLabel="{adminInput.ariaLabel}"
174
+ control={form.control}
175
+ defaultValue="{adminInput.defaultValue}"
176
+ setError={form.setError}
177
+ clearErrors={form.clearErrors}
178
+ />
179
+ </GridItem>
180
+ <GridItem colSpan={6} pr="10px">
181
+ <Input
182
+ inputType="text"
183
+ isRequired
184
+ setValue={form.setValue}
185
+ name={`action`}
186
+ ariaLabel="{messageInput.ariaLabel}"
187
+ control={form.control}
188
+ defaultValue="{messageInput.defaultValue}"
189
+ setError={form.setError}
190
+ clearErrors={form.clearErrors}
191
+ maxLength={140}
192
+ />
193
+ </GridItem>
194
+ </Grid>
195
+ </Flex>
145
196
  </Form>
146
197
  );
147
198
  };
@@ -150,6 +201,9 @@ export const Default = Template.bind({});
150
201
  Default.args = {
151
202
  label: 'Input Label',
152
203
  inputType: 'text',
204
+ helperText:
205
+ ' M1 4.33325H15.1667M11 7.66659H16M11 10.9999H16M8.08333 7.66659H8.5M8.08333 10.9999H8.5',
206
+
153
207
  options: [
154
208
  { value: 'section_header', label: 'Section 1', sortValue: 0 },
155
209
  {
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { Checkbox } from '@chakra-ui/react';
2
+ import { Checkbox, Text } from '@chakra-ui/react';
3
3
  import { SelectFieldProps } from '../InputTypes';
4
4
 
5
5
  export interface StackedCheckboxProps extends SelectFieldProps {
@@ -12,14 +12,22 @@ export interface StackedCheckboxProps extends SelectFieldProps {
12
12
  const StackedCheckbox = React.forwardRef<
13
13
  HTMLInputElement,
14
14
  StackedCheckboxProps
15
- >(({ value, label, defaultValue }, _ref) => {
15
+ >(({ value, label, onChange }, _ref) => {
16
+ if (value === null) return null;
17
+
16
18
  return (
17
19
  <Checkbox
18
20
  ref={_ref}
19
21
  value={String(value)}
20
- defaultChecked={Boolean(defaultValue)}
22
+ defaultChecked={Boolean(value)}
23
+ defaultValue={value}
24
+ onChange={e => {
25
+ if (onChange) return onChange(e.target.checked as any);
26
+ }}
21
27
  >
22
- {label}
28
+ <Text fontSize="13px" alignSelf="center">
29
+ {label}
30
+ </Text>
23
31
  </Checkbox>
24
32
  );
25
33
  });
@@ -18,7 +18,7 @@ export const Label: React.FC<LabelProps> = ({
18
18
  label,
19
19
  }) => {
20
20
  return (
21
- <FormLabel display="flex" alignItems="center">
21
+ <FormLabel display="flex">
22
22
  {label}
23
23
  {isRequired && (
24
24
  <Box ml={1} color={colors.label.error}>
@@ -166,7 +166,6 @@ export function Input<T extends FieldValues>({
166
166
  onChange={onChange}
167
167
  onBlur={onBlur}
168
168
  ref={ref}
169
- disabled={disabled}
170
169
  value={value}
171
170
  defaultValue={defaultValue}
172
171
  label={label as string}
@@ -244,9 +243,13 @@ export function Input<T extends FieldValues>({
244
243
  id={name}
245
244
  isInvalid={isInvalid}
246
245
  position="relative"
247
- py={label || helperText || isInvalid ? 6 : 0}
246
+ py={
247
+ (label || helperText || isInvalid) && inputType !== 'checkbox'
248
+ ? 6
249
+ : 0
250
+ }
248
251
  >
249
- {label && (
252
+ {label && inputType !== 'checkbox' && (
250
253
  <Label
251
254
  tooltipText={tooltipText}
252
255
  label={label}
@@ -11,11 +11,9 @@ function baseStyleRequiredIndicator() {
11
11
 
12
12
  function baseStyleHelperText() {
13
13
  return {
14
- position: 'absolute',
15
- color: colors.label.secondary.light,
16
14
  mt: 1,
17
15
  ml: 1,
18
- bottom: 0,
16
+ color: colors.label.secondary.light,
19
17
  fontSize: '13px',
20
18
  };
21
19
  }