@xqmsg/ui-core 0.24.9 → 0.24.11

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.
Files changed (32) hide show
  1. package/dist/components/form/FormTypes.d.ts +2 -2
  2. package/dist/components/input/InputTypes.d.ts +0 -1
  3. package/dist/components/input/StackedMultiSelect/index.d.ts +2 -2
  4. package/dist/components/input/StackedRadio/StackedRadioGroup.d.ts +2 -2
  5. package/dist/components/input/StackedSelect/index.d.ts +4 -3
  6. package/dist/components/input/components/dropdown/index.d.ts +2 -2
  7. package/dist/components/input/index.d.ts +5 -4
  8. package/dist/components/select/index.d.ts +3 -3
  9. package/dist/components/toolbar/components/actions/sort/index.d.ts +2 -2
  10. package/dist/components/toolbar/components/dropdown/index.d.ts +2 -2
  11. package/dist/theme/components/menu.d.ts +55 -0
  12. package/dist/ui-core.cjs.development.js +109 -34
  13. package/dist/ui-core.cjs.development.js.map +1 -1
  14. package/dist/ui-core.cjs.production.min.js +1 -1
  15. package/dist/ui-core.cjs.production.min.js.map +1 -1
  16. package/dist/ui-core.esm.js +109 -34
  17. package/dist/ui-core.esm.js.map +1 -1
  18. package/package.json +1 -1
  19. package/src/components/form/FormTypes.ts +2 -2
  20. package/src/components/icons/workspace/index.tsx +1 -1
  21. package/src/components/input/Input.stories.tsx +1 -0
  22. package/src/components/input/InputTypes.ts +0 -2
  23. package/src/components/input/StackedMultiSelect/index.tsx +6 -9
  24. package/src/components/input/StackedRadio/StackedRadioGroup.tsx +2 -3
  25. package/src/components/input/StackedSelect/index.tsx +16 -12
  26. package/src/components/input/components/dropdown/index.tsx +2 -2
  27. package/src/components/input/index.tsx +9 -6
  28. package/src/components/select/index.tsx +3 -3
  29. package/src/components/toolbar/components/actions/sort/index.tsx +2 -2
  30. package/src/components/toolbar/components/dropdown/index.tsx +2 -2
  31. package/src/theme/components/menu.ts +78 -0
  32. package/src/theme/customXQChakraTheme.ts +2 -0
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.24.9",
2
+ "version": "0.24.11",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -1,11 +1,11 @@
1
- import { FieldOptions, InputType } from '../input/InputTypes';
1
+ import { FieldOption, InputType } from '../input/InputTypes';
2
2
 
3
3
  export interface FormInput {
4
4
  label: string;
5
5
  name: string;
6
6
  ariaLabel: string;
7
7
  inputType: InputType;
8
- options?: FieldOptions;
8
+ options?: FieldOption[];
9
9
  placeholder?: string;
10
10
  isRequired: boolean;
11
11
  maxLength?: number;
@@ -16,7 +16,7 @@ export const Workspace: React.FC<WorkspaceProps> = ({
16
16
  filled = false,
17
17
  }) => {
18
18
  if (filled) {
19
- return <WorkspaceIcon boxSize={boxSize} />;
19
+ return <WorkspaceIcon width={boxSize} height={boxSize} />;
20
20
  }
21
21
  return <Image src={path} boxSize={boxSize} />;
22
22
  };
@@ -221,6 +221,7 @@ const Template: Story<InputProps<StoryFormSchema>> = args => {
221
221
  setValue={form.setValue}
222
222
  name="prop4"
223
223
  defaultValue={'value1'}
224
+ searchable={false}
224
225
  tooltipText={
225
226
  <Box>
226
227
  <Text fontSize={13}>Explanation!</Text>
@@ -24,8 +24,6 @@ export type FieldOption = {
24
24
  sortValue: number;
25
25
  };
26
26
 
27
- export type FieldOptions = FieldOption[];
28
-
29
27
  export interface ValidationProps {
30
28
  isRequired: boolean;
31
29
  isInvalid?: boolean;
@@ -5,11 +5,7 @@ import React, {
5
5
  useState,
6
6
  } from 'react';
7
7
  import { Box, Flex, Text, Input } from '@chakra-ui/react';
8
- import {
9
- FieldOption,
10
- FieldOptions,
11
- ReactSelectFieldProps,
12
- } from '../InputTypes';
8
+ import { FieldOption, ReactSelectFieldProps } from '../InputTypes';
13
9
  import colors from '../../../theme/foundations/colors';
14
10
  import {
15
11
  Control,
@@ -25,7 +21,7 @@ import Token from '../components/token';
25
21
  import { useOnClickOutside } from '../../../hooks/useOnOutsideClick';
26
22
 
27
23
  export interface StackedMultiSelectProps extends ReactSelectFieldProps {
28
- options: FieldOptions;
24
+ options: FieldOption[];
29
25
  setValue: UseFormSetValue<FieldValues>;
30
26
  setError: UseFormSetError<FieldValues>;
31
27
  clearErrors: UseFormClearErrors<FieldValues>;
@@ -51,9 +47,9 @@ const StackedMultiSelect = React.forwardRef<
51
47
  const inputRef = useRef<HTMLInputElement>(null);
52
48
 
53
49
  const [isInit, setIsInit] = useState(false);
54
- const [localValues, setLocalValues] = useState<FieldOptions>([]);
55
- const [localOptions, setLocalOptions] = useState<FieldOptions>(options);
56
- const [filteredOptions, setFilteredOptions] = useState<FieldOptions>(
50
+ const [localValues, setLocalValues] = useState<FieldOption[]>([]);
51
+ const [localOptions, setLocalOptions] = useState<FieldOption[]>(options);
52
+ const [filteredOptions, setFilteredOptions] = useState<FieldOption[]>(
57
53
  localOptions
58
54
  );
59
55
  const [isFocussed, setIsFocussed] = useState(false);
@@ -357,6 +353,7 @@ const StackedMultiSelect = React.forwardRef<
357
353
  loading={loadingOptions}
358
354
  >
359
355
  <Input
356
+ autoFocus
360
357
  value={searchValue}
361
358
  onChange={handleInput}
362
359
  disabled={loadingOptions}
@@ -1,11 +1,10 @@
1
1
  import React from 'react';
2
2
  import { Flex, InputGroup, Radio, RadioGroup } from '@chakra-ui/react';
3
- import { FieldOptions, SelectFieldProps } from '../InputTypes';
3
+ import { FieldOption, SelectFieldProps } from '../InputTypes';
4
4
 
5
5
  export interface StackedRadioGroupProps extends SelectFieldProps {
6
6
  flexDirection?: 'row' | 'column';
7
-
8
- options: FieldOptions;
7
+ options: FieldOption[];
9
8
  }
10
9
 
11
10
  /**
@@ -5,7 +5,7 @@ import React, {
5
5
  useState,
6
6
  } from 'react';
7
7
  import { Box, Input, InputGroup, InputRightElement } from '@chakra-ui/react';
8
- import { FieldOptions } from '../InputTypes';
8
+ import { FieldOption } from '../InputTypes';
9
9
  import { StackedInputProps } from '../StackedInput/StackedInput';
10
10
  import { UseFormSetValue, FieldValues, Control } from 'react-hook-form';
11
11
  import { Dropdown } from '../components/dropdown';
@@ -13,12 +13,13 @@ import { useOnClickOutside } from '../../../hooks/useOnOutsideClick';
13
13
  import { Dropdown as DropdownIcon } from '../../icons/dropdown';
14
14
 
15
15
  export interface StackedSelectProps extends StackedInputProps {
16
- options: FieldOptions;
17
- fullOptions?: FieldOptions;
16
+ options: FieldOption[];
17
+ fullOptions?: FieldOption[];
18
18
  setValue: UseFormSetValue<FieldValues>;
19
19
  control: Control<FieldValues, any>;
20
20
  handleOnChange: (value?: string) => void;
21
21
  loadingOptions?: boolean;
22
+ searchable?: boolean;
22
23
  }
23
24
 
24
25
  /**
@@ -36,6 +37,7 @@ const StackedSelect = React.forwardRef<HTMLInputElement, StackedSelectProps>(
36
37
  value,
37
38
  fullOptions,
38
39
  loadingOptions,
40
+ searchable = true,
39
41
  ...props
40
42
  },
41
43
  _ref
@@ -50,7 +52,7 @@ const StackedSelect = React.forwardRef<HTMLInputElement, StackedSelectProps>(
50
52
  const [optionIndex, setOptionIndex] = useState<number | null>(null);
51
53
  const [position, setPosition] = useState<'top' | 'bottom'>('top');
52
54
  const [searchValue, setSearchValue] = useState('');
53
- const [filteredOptions, setFilteredOptions] = useState<FieldOptions>(
55
+ const [filteredOptions, setFilteredOptions] = useState<FieldOption[]>(
54
56
  options
55
57
  );
56
58
 
@@ -195,13 +197,16 @@ const StackedSelect = React.forwardRef<HTMLInputElement, StackedSelectProps>(
195
197
  }, [options, searchValue]);
196
198
 
197
199
  const handleInput = (e: React.ChangeEvent<HTMLInputElement>) => {
198
- const initialOptionIndex =
199
- filteredOptions.length && filteredOptions[0]?.value === 'section_header'
200
- ? 1
201
- : 0;
202
- setOptionIndex(initialOptionIndex);
203
- const { value } = e.target;
204
- setSearchValue(value);
200
+ if (searchable) {
201
+ const initialOptionIndex =
202
+ filteredOptions.length &&
203
+ filteredOptions[0]?.value === 'section_header'
204
+ ? 1
205
+ : 0;
206
+ setOptionIndex(initialOptionIndex);
207
+ const { value } = e.target;
208
+ setSearchValue(value);
209
+ }
205
210
  };
206
211
 
207
212
  return (
@@ -213,7 +218,6 @@ const StackedSelect = React.forwardRef<HTMLInputElement, StackedSelectProps>(
213
218
  ref={_ref}
214
219
  onClick={() => setIsFocussed(!isFocussed)}
215
220
  cursor={isFocussed ? 'default' : 'pointer'}
216
- color={loadingOptions ? 'transparent' : 'inital'}
217
221
  fontSize="13px"
218
222
  value={isFocussed ? searchValue : selectedOption}
219
223
  autoComplete="off"
@@ -1,11 +1,11 @@
1
1
  import React, { RefObject, useMemo } from 'react';
2
2
  import { Box, Flex, Spinner } from '@chakra-ui/react';
3
3
  import colors from '../../../../../src/theme/foundations/colors';
4
- import { FieldOption, FieldOptions } from '../../InputTypes';
4
+ import { FieldOption } from '../../InputTypes';
5
5
 
6
6
  export interface DropdownProps {
7
7
  onSelectItem: (option: FieldOption) => void;
8
- options: FieldOptions;
8
+ options: FieldOption[];
9
9
  dropdownRef: RefObject<HTMLDivElement>;
10
10
  position: 'top' | 'bottom';
11
11
  optionIndex?: number | null;
@@ -4,7 +4,7 @@ import StackedInput from './StackedInput/StackedInput';
4
4
  import StackedRadioGroup from './StackedRadio/StackedRadioGroup';
5
5
  import StackedSelect from './StackedSelect';
6
6
  import StackedTextarea from './StackedTextarea/StackedTextarea';
7
- import { FieldOptions, ValidationProps, InputType } from './InputTypes';
7
+ import { FieldOption, ValidationProps, InputType } from './InputTypes';
8
8
  import {
9
9
  FormControl,
10
10
  FormErrorMessage,
@@ -35,8 +35,8 @@ export interface InputProps<T extends FieldValues = FieldValues>
35
35
  defaultValue?: string;
36
36
  label?: string;
37
37
  className?: string;
38
- options?: FieldOptions;
39
- fullOptions?: FieldOptions;
38
+ options?: FieldOption[];
39
+ fullOptions?: FieldOption[];
40
40
  maxLength?: number;
41
41
  helperText?: React.ReactNode;
42
42
  control: Control<T, any>;
@@ -52,6 +52,7 @@ export interface InputProps<T extends FieldValues = FieldValues>
52
52
  separators?: string[];
53
53
  loadingOptions?: boolean;
54
54
  truncatePillLength?: number;
55
+ searchable?: boolean;
55
56
  }
56
57
 
57
58
  /**
@@ -86,6 +87,7 @@ export function Input<T extends FieldValues>({
86
87
  separators,
87
88
  loadingOptions = false,
88
89
  truncatePillLength,
90
+ searchable,
89
91
  }: InputProps<T>) {
90
92
  function selectedInputField<T extends Element = Element>(
91
93
  onChange: ((e: ChangeEvent<T>) => void) | ((v?: string) => void),
@@ -124,7 +126,7 @@ export function Input<T extends FieldValues>({
124
126
  name={name}
125
127
  id={name}
126
128
  isInvalid={isInvalid}
127
- options={options as FieldOptions}
129
+ options={options as FieldOption[]}
128
130
  onChange={onChange as (e: ChangeEvent) => void}
129
131
  onBlur={onBlur}
130
132
  ref={ref}
@@ -140,7 +142,7 @@ export function Input<T extends FieldValues>({
140
142
  id={name}
141
143
  isRequired={isRequired}
142
144
  isInvalid={isInvalid}
143
- options={options as FieldOptions}
145
+ options={options as FieldOption[]}
144
146
  handleOnChange={onChange as (v?: string) => void}
145
147
  onBlur={onBlur}
146
148
  setValue={setValue as UseFormSetValue<FieldValues>}
@@ -152,6 +154,7 @@ export function Input<T extends FieldValues>({
152
154
  placeholder={placeholder}
153
155
  fullOptions={fullOptions}
154
156
  loadingOptions={loadingOptions}
157
+ searchable={searchable}
155
158
  />
156
159
  );
157
160
  case 'textarea':
@@ -198,7 +201,7 @@ export function Input<T extends FieldValues>({
198
201
  name={name}
199
202
  id={name}
200
203
  isInvalid={isInvalid}
201
- options={options as FieldOptions}
204
+ options={options as FieldOption[]}
202
205
  onChange={onChange as (e: ChangeEvent) => void}
203
206
  onBlur={onBlur}
204
207
  ref={ref}
@@ -15,7 +15,7 @@ import {
15
15
  UseFormSetError,
16
16
  UseFormSetValue,
17
17
  } from 'react-hook-form';
18
- import { FieldOptions, ValidationProps } from 'src/components/input/InputTypes';
18
+ import { FieldOption, ValidationProps } from 'src/components/input/InputTypes';
19
19
 
20
20
  export interface SelectNativeProps<T extends FieldValues>
21
21
  extends ValidationProps,
@@ -28,8 +28,8 @@ export interface SelectNativeProps<T extends FieldValues>
28
28
  defaultValue?: string;
29
29
  label?: string;
30
30
  className?: string;
31
- options?: FieldOptions;
32
- fullOptions?: FieldOptions;
31
+ options?: FieldOption[];
32
+ fullOptions?: FieldOption[];
33
33
  helperText?: React.ReactNode;
34
34
  control: Control<T, unknown>;
35
35
  onChange?: (e: React.ChangeEvent<HTMLSelectElement>) => void;
@@ -2,11 +2,11 @@ import React, { useRef, useState } from 'react';
2
2
  import { Box, Flex, useOutsideClick } from '@chakra-ui/react';
3
3
  import { ChevronDown, TableOutline } from '../../../../icons';
4
4
  import { Dropdown } from '../../dropdown';
5
- import { FieldOption, FieldOptions } from '../../../../input/InputTypes';
5
+ import { FieldOption } from '../../../../input/InputTypes';
6
6
 
7
7
  export interface SortProps {
8
8
  onSelectItem: (option: FieldOption) => void;
9
- sortOptions: FieldOptions;
9
+ sortOptions: FieldOption[];
10
10
  }
11
11
 
12
12
  /**
@@ -1,12 +1,12 @@
1
1
  import React, { RefObject, useMemo } from 'react';
2
2
  import { Box, Flex } from '@chakra-ui/react';
3
3
  import colors from '../../../../theme/foundations/colors';
4
- import { FieldOption, FieldOptions } from '../../../input/InputTypes';
4
+ import { FieldOption } from '../../../input/InputTypes';
5
5
  import { Checkmark } from '../../../icons';
6
6
 
7
7
  export interface DropdownProps {
8
8
  onSelectItem: (option: FieldOption) => void;
9
- options: FieldOptions;
9
+ options: FieldOption[];
10
10
  dropdownRef: RefObject<HTMLDivElement>;
11
11
  position: 'top' | 'bottom';
12
12
  optionIndex: number | null;
@@ -0,0 +1,78 @@
1
+ import { mode } from '@chakra-ui/theme-tools';
2
+ import colors from '../foundations/colors';
3
+
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ type Dict = Record<string, any>;
6
+
7
+ const parts = ['item', 'command', 'list', 'button', 'groupTitle'];
8
+
9
+ function baseStyleList(props: Dict) {
10
+ return {
11
+ bg: colors.fill.light.quaternary,
12
+ boxShadow: mode(`2xl`, `dark-lg`)(props),
13
+ color: 'inherit',
14
+ minW: '3xs',
15
+ py: 4,
16
+ px: 2,
17
+ zIndex: 'docked',
18
+ borderWidth: 0,
19
+ overflow: 'hidden',
20
+ backdropFilter: 'auto',
21
+ backdropBlur: '64px',
22
+ borderRadius: '4px',
23
+ border: '0.25px solid',
24
+ borderColor: colors.fill.light.tertiary,
25
+ };
26
+ }
27
+
28
+ function baseStyleItem(props: Dict) {
29
+ return {
30
+ fontSize: '13px;',
31
+ fontWeight: 500,
32
+ lineHeight: '16px',
33
+ py: 3,
34
+ px: 4,
35
+ borderRadius: '4px',
36
+ width: '100%',
37
+ transition: 'background 50ms ease-in 0s',
38
+ _hover: {
39
+ color: colors.white,
40
+ background: colors.fill.action,
41
+ },
42
+ _active: {
43
+ bg: mode(`gray.200`, `whiteAlpha.200`)(props),
44
+ },
45
+ _expanded: {
46
+ bg: mode(`gray.100`, `whiteAlpha.100`)(props),
47
+ },
48
+ _disabled: {
49
+ opacity: 0.4,
50
+ cursor: 'not-allowed',
51
+ },
52
+ };
53
+ }
54
+
55
+ const baseStyleGroupTitle = {
56
+ mx: 4,
57
+ my: 2,
58
+ fontWeight: 'semibold',
59
+ fontSize: 'sm',
60
+ };
61
+
62
+ const baseStyleCommand = {
63
+ opacity: 0.6,
64
+ };
65
+
66
+ const baseStyle = (props: Dict) => {
67
+ return {
68
+ list: baseStyleList(props),
69
+ item: baseStyleItem(props),
70
+ groupTitle: baseStyleGroupTitle,
71
+ command: baseStyleCommand,
72
+ };
73
+ };
74
+
75
+ export default {
76
+ parts,
77
+ baseStyle,
78
+ };
@@ -13,6 +13,7 @@ import FormError from './components/form-error';
13
13
  import FormLabel from './components/form-label';
14
14
  import Input from './components/input';
15
15
  import Link from './components/link';
16
+ import Menu from './components/menu';
16
17
  import Modal from './components/modal';
17
18
  import Popover from './components/popover';
18
19
  import Select from './components/select';
@@ -39,6 +40,7 @@ const customXQChakraTheme = extendTheme({
39
40
  FormLabel,
40
41
  Input,
41
42
  Link,
43
+ Menu,
42
44
  Modal,
43
45
  Popover,
44
46
  Select,