forstok-ui-lib 5.2.13 → 5.2.19

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,6 +1,6 @@
1
1
  {
2
2
  "name": "forstok-ui-lib",
3
- "version": "5.2.13",
3
+ "version": "5.2.19",
4
4
  "description": "Forstok UI Components Library",
5
5
  "path": "dist",
6
6
  "main": "dist/index.js",
@@ -42,7 +42,6 @@
42
42
  "react-dom": "^19.0.0",
43
43
  "react-router-dom": "^7.1.1",
44
44
  "react-select": "^5.10.0",
45
- "react-select-async-paginate": "^0.7.9",
46
45
  "rollup-plugin-dts": "^6.1.1",
47
46
  "rollup-plugin-peer-deps-external": "^2.2.4",
48
47
  "rollup-plugin-postcss": "^4.0.2",
@@ -14,6 +14,7 @@ export { default as PopupComponent } from './popup';
14
14
  export { default as ReactPortalComponent } from './portal';
15
15
  export { default as ImageComponent } from './image';
16
16
  export { default as SelectComponent } from './select';
17
+ export { default as MenuList } from './select/menulist';
17
18
  export { default as ErrorComponent } from './error';
18
19
  export { default as UploadComponent } from './upload';
19
20
  export { default as UploadDragDropComponent } from './upload/drag_drop';
@@ -23,4 +24,4 @@ export * from './message/typed';
23
24
  export * from './popup/typed';
24
25
  export * from './select/typed';
25
26
 
26
- export * from './form/styles';
27
+ export * from './form/styles';
@@ -0,0 +1,11 @@
1
+ import { JSX } from 'react';
2
+ import { components } from 'react-select';
3
+ import type { GroupBase, MenuListProps } from 'react-select';
4
+
5
+ const MenuList = (props: JSX.IntrinsicAttributes & MenuListProps<unknown, boolean, GroupBase<unknown>>) => {
6
+ return (
7
+ <components.MenuList {...props}>{props.children}</components.MenuList>
8
+ )
9
+ }
10
+
11
+ export default MenuList;
@@ -1,5 +1,8 @@
1
1
  import type { ActionMeta, OnChangeValue } from 'react-select';
2
+ import type { OptionProps, GroupBase, StylesConfig, CSSObjectWithLabel, ControlProps } from 'react-select';
3
+ import { CSSObject } from '@emotion/serialize'
2
4
  import type { TChannel } from '../../typeds/shares.typed';
5
+ import type { TState } from '../../typeds';
3
6
 
4
7
  export type TOption = {
5
8
  readonly value: any
@@ -33,4 +36,37 @@ export type TLoadOption = (search: string, callback: () => void, { endCursor }:
33
36
 
34
37
  export type TOnChangeValue = OnChangeValue<TOption, boolean>
35
38
 
36
- export type TActionMeta = ActionMeta<TOption>
39
+ export type TOnChangeValueFalse = OnChangeValue<TOption, false>
40
+
41
+ export type TActionMeta = ActionMeta<TOption>
42
+
43
+ export type TSelectAsyncPaginate = {
44
+ customOption?: (arg0: OptionProps) => void
45
+ MenuList?: any
46
+ evChange?: (newValue: OnChangeValue<TOption, false>, actionMeta?: ActionMeta<TOption>) => void
47
+ defaultValue?: OnChangeValue<TOption, boolean>
48
+ // loadOptions: TLoadOption | LoadOptions<unknown, GroupBase<unknown>, unknown>
49
+ loadOptionsOnMenuOpen?: boolean
50
+ noOptionsMessage?: ((obj: {
51
+ inputValue: string;
52
+ }) => React.ReactNode)
53
+ isSearchable?: boolean
54
+ isClearable?: boolean
55
+ placeholder?: string
56
+ isMenuOpen?: boolean
57
+ setMenuIsOpen: TState<boolean|undefined>
58
+ isForceUpdate: boolean
59
+ setForceUpdate: TState<boolean>
60
+ }
61
+
62
+ export type TCustomStyles = StylesConfig<TOption, boolean>
63
+
64
+ export type TCSSObject = CSSObject
65
+
66
+ export type TCSSObjectWithLabel = CSSObjectWithLabel
67
+
68
+ export type TControlProps = ControlProps<TOption, boolean>
69
+
70
+ export type TOptionProps = OptionProps<TOption, boolean>
71
+
72
+ export type TGroupBase = GroupBase<TOption>
@@ -1,126 +0,0 @@
1
- import { useCallback, useEffect, useState } from 'react'
2
- import type { OnChangeValue, OptionProps, GroupBase, ActionMeta, StylesConfig, CSSObjectWithLabel, ControlProps } from 'react-select'
3
- import { AsyncPaginate } from 'react-select-async-paginate'
4
- import type { LoadOptions } from 'react-select-async-paginate'
5
- import { CSSObject } from '@emotion/serialize'
6
- import type { TLoadOption, TOption } from './typed'
7
- import { TState } from '../../typeds'
8
-
9
- type TSelect = {
10
- customOption?: (arg0: OptionProps) => void
11
- MenuList?: any
12
- evChange?: (newValue: OnChangeValue<TOption, false>, actionMeta?: ActionMeta<TOption>) => void
13
- defaultValue?: OnChangeValue<TOption, boolean>
14
- loadOptions: TLoadOption | LoadOptions<unknown, GroupBase<unknown>, unknown>
15
- loadOptionsOnMenuOpen?: boolean
16
- noOptionsMessage?: ((obj: {
17
- inputValue: string;
18
- }) => React.ReactNode)
19
- isSearchable?: boolean
20
- isClearable?: boolean
21
- placeholder?: string
22
- isMenuOpen?: boolean
23
- setMenuIsOpen: TState<boolean|undefined>
24
- isForceUpdate: boolean
25
- setForceUpdate: TState<boolean>
26
- }
27
-
28
- const SelectAsyncPaginate = ({ loadOptions, isForceUpdate, setForceUpdate, ...props }:TSelect) => {
29
- const { customOption, MenuList, defaultValue, evChange, loadOptionsOnMenuOpen, noOptionsMessage, isSearchable, placeholder, isMenuOpen, setMenuIsOpen } = props;
30
- const [valueSelect, setValueSelect] = useState<typeof defaultValue>(defaultValue || null);
31
-
32
- useEffect(() => {
33
- if (isForceUpdate) {
34
- setValueSelect(defaultValue || null);
35
- setForceUpdate(false);
36
- }
37
- }, [defaultValue, isForceUpdate, setForceUpdate, setValueSelect]);
38
-
39
- const handleChange = (value: OnChangeValue<TOption, boolean>, actionMeta?: ActionMeta<TOption>) => {
40
- const newValue = value as OnChangeValue<TOption, false>;
41
- setValueSelect(newValue ? { value: newValue.value, label : newValue.label } : newValue);
42
- evChange && evChange(newValue, actionMeta);
43
- }
44
-
45
- const customStyles: StylesConfig<TOption, boolean> = {
46
- container: (provided: CSSObject) => ({
47
- ...provided,
48
- display: 'inline-block',
49
- width: '100%',
50
- minHeight: '1px',
51
- textAlign: 'left',
52
- border: 'none',
53
- } as CSSObjectWithLabel),
54
- control: (provided: CSSObject, state:ControlProps<TOption, boolean>) => ({
55
- ...provided,
56
- borderRadius: '4px',
57
- minHeight: '1px',
58
- cursor: 'pointer',
59
- borderWidth: '1px' ,
60
- boxShadow: 'none',
61
- } as CSSObjectWithLabel),
62
- input: (provided: CSSObject) => ({
63
- ...provided,
64
- minHeight: '1px',
65
- margin: '0 2px',
66
- padding: '0',
67
- 'input': {
68
- boxShadow: 'none !important'
69
- }
70
- } as CSSObjectWithLabel),
71
- singleValue: (provided: CSSObject) => ({
72
- ...provided,
73
- minHeight: '1px',
74
- paddingBottom: '2px',
75
- color: 'initial',
76
- } as CSSObjectWithLabel),
77
- option: (provided: CSSObject, state: OptionProps<TOption, boolean>) => ({
78
- ...provided,
79
- color: state.isSelected ? '#ffffff' : '#000000',
80
- backgroundColor: state.isSelected || state.isFocused ? '#fc5c64' : 'transparent',
81
- cursor: 'pointer',
82
- '&:hover': {
83
- backgroundColor: '#ec5b62',
84
- color: '#ffffff'
85
- }
86
- } as CSSObjectWithLabel),
87
- menuPortal: (provided: CSSObject) => ({
88
- ...provided,
89
- zIndex: 9999,
90
- letterSpacing: 'normal',
91
- lineHeight: 'normal',
92
- } as CSSObjectWithLabel)
93
- }
94
-
95
- const onMenuOpen = useCallback(() => {
96
- setMenuIsOpen(true);
97
- }, [setMenuIsOpen]);
98
-
99
- const onMenuClose = useCallback(() => {
100
- setMenuIsOpen(false);
101
- }, [setMenuIsOpen]);
102
-
103
- return <div className='_refContainer'>
104
- <AsyncPaginate
105
- isSearchable={isSearchable}
106
- placeholder={placeholder}
107
- debounceTimeout={500}
108
- styles={customStyles}
109
- loadOptions={loadOptions}
110
- menuPortalTarget={document.body}
111
- menuPosition='fixed'
112
- menuPlacement='auto'
113
- value={valueSelect}
114
- onChange={handleChange}
115
- loadOptionsOnMenuOpen={loadOptionsOnMenuOpen}
116
- noOptionsMessage={noOptionsMessage}
117
- menuIsOpen={isMenuOpen}
118
- onMenuOpen={onMenuOpen}
119
- onMenuClose={onMenuClose}
120
- {...customOption && { components: { Option: customOption } }}
121
- {...MenuList && { components: { MenuList } }}
122
- {...props} />
123
- </div>
124
- }
125
-
126
- export default SelectAsyncPaginate