@true-engineering/true-react-common-ui-kit 4.0.0-alpha75 → 4.0.0-alpha76

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": "@true-engineering/true-react-common-ui-kit",
3
- "version": "4.0.0-alpha75",
3
+ "version": "4.0.0-alpha76",
4
4
  "description": "True Engineering React UI Kit with theming support",
5
5
  "author": "True Engineering (https://trueengineering.ru)",
6
6
  "keywords": [
@@ -28,7 +28,8 @@ export class ScrollIntoViewIfNeeded extends PureComponent<IScrollIntoViewIfNeede
28
28
  componentDidMount(): void {
29
29
  const { active } = this.props;
30
30
  if (active) {
31
- this.handleScrollIntoViewIfNeeded();
31
+ // requestAnimationFrame нужен для скролла элемента, который отрендерен в document.body через портал
32
+ requestAnimationFrame(this.handleScrollIntoViewIfNeeded);
32
33
  }
33
34
  }
34
35
 
@@ -8,11 +8,9 @@ import { TextButton } from '../TextButton';
8
8
  import { type ISelectProps, Select } from './Select';
9
9
 
10
10
  interface ISelectCustomProps<Option> extends ISelectProps<Option> {
11
- shouldUsePopper?: boolean;
12
11
  shouldRenderInBody?: boolean;
13
12
  shouldHideOnScroll?: boolean;
14
13
  canBeFlipped?: boolean;
15
- scrollParent?: 'document' | 'auto';
16
14
  }
17
15
 
18
16
  const useSelectStyles = createUseStyles({
@@ -138,11 +136,9 @@ function CustomListFooter({ onReset, onClear }: ICustomListFooterProps) {
138
136
 
139
137
  const Story: FC<ISelectCustomProps<string>> = ({
140
138
  noMatchesLabel,
141
- shouldUsePopper,
142
139
  shouldRenderInBody,
143
140
  shouldHideOnScroll,
144
141
  canBeFlipped,
145
- scrollParent,
146
142
  ...args
147
143
  }) => {
148
144
  const classes = useSelectStyles();
@@ -206,11 +202,9 @@ const Story: FC<ISelectCustomProps<string>> = ({
206
202
  },
207
203
  }}
208
204
  dropdownOptions={{
209
- shouldUsePopper,
210
205
  shouldRenderInBody,
211
206
  shouldHideOnScroll,
212
207
  canBeFlipped,
213
- scrollParent,
214
208
  }}
215
209
  />
216
210
  );
@@ -227,20 +221,12 @@ const meta: Meta<typeof Story> = {
227
221
  isDisabled: false,
228
222
  isRequired: false,
229
223
  isClearable: false,
230
- shouldUsePopper: false,
231
224
  shouldRenderInBody: false,
232
225
  shouldHideOnScroll: false,
233
226
  shouldScrollToList: true,
234
227
  canBeFlipped: false,
235
- scrollParent: 'document',
236
228
  size: undefined,
237
229
  },
238
- argTypes: {
239
- scrollParent: {
240
- options: ['document', 'auto'],
241
- control: { type: 'select' },
242
- },
243
- },
244
230
  };
245
231
 
246
232
  export default meta;
@@ -60,29 +60,29 @@ const icons = [undefined, ...Object.keys(iconsMap)];
60
60
  const getRandomInt = (min: number, max: number) =>
61
61
  Math.floor(Math.random() * (Math.floor(max) - Math.ceil(min))) + Math.ceil(min);
62
62
 
63
+ const handleOpen = () => console.log('isOpen');
64
+ const handleClose = () => console.log('isClose');
65
+ const handleBlur = () => console.log('blur');
66
+
63
67
  interface ISelectCustomProps<T> extends IMultipleSelectProps<T> {
64
68
  valuesType: 'strings' | 'objects';
65
69
  shouldUseReactNodes?: boolean;
66
- shouldUsePopper?: boolean;
67
70
  shouldRenderInBody?: boolean;
68
71
  shouldHideOnScroll?: boolean;
69
72
  shouldUseCustomIsDisabledFunction?: boolean;
70
73
  shouldRenderSearchInputInList?: boolean;
71
74
  canBeFlipped?: boolean;
72
- scrollParent?: 'document' | 'auto';
73
75
  }
74
76
 
75
77
  function Story<T>({
76
78
  valuesType,
77
79
  optionsMode,
78
80
  shouldUseReactNodes,
79
- shouldUsePopper,
80
81
  shouldRenderInBody,
81
82
  shouldHideOnScroll,
82
83
  shouldUseCustomIsDisabledFunction,
83
84
  shouldRenderSearchInputInList,
84
85
  canBeFlipped,
85
- scrollParent,
86
86
  noMatchesLabel,
87
87
  ...args
88
88
  }: ISelectCustomProps<T>): ReactElement {
@@ -122,14 +122,6 @@ function Story<T>({
122
122
 
123
123
  const [dynamicOptions, setDynamicOptions] = useState<Array<string | ObjectValue>>([]);
124
124
 
125
- const handleOpen = () => {
126
- console.log('isOpen');
127
- };
128
-
129
- const handleBlur = () => {
130
- console.log('blur');
131
- };
132
-
133
125
  useEffect(() => {
134
126
  const api = async () => {
135
127
  setDynamicOptions(await getOptions());
@@ -169,13 +161,12 @@ function Story<T>({
169
161
  optionsMode={optionsMode}
170
162
  onType={async () => setDynamicOptions(await getOptions())}
171
163
  onOpen={handleOpen}
164
+ onClose={handleClose}
172
165
  onBlur={handleBlur}
173
166
  dropdownOptions={{
174
- shouldUsePopper,
175
167
  shouldRenderInBody,
176
168
  shouldHideOnScroll,
177
169
  canBeFlipped,
178
- scrollParent,
179
170
  }}
180
171
  />
181
172
  );
@@ -201,14 +192,12 @@ const meta: Meta<typeof Story> = {
201
192
  shouldUseReactNodes: false,
202
193
  valuesType: 'strings',
203
194
  optionsMode: 'normal',
204
- shouldUsePopper: false,
205
195
  shouldRenderInBody: false,
206
196
  shouldHideOnScroll: false,
207
197
  shouldUseCustomIsDisabledFunction: false,
208
198
  shouldRenderSearchInputInList: false,
209
199
  shouldScrollToList: true,
210
200
  canBeFlipped: false,
211
- scrollParent: 'document',
212
201
  size: undefined,
213
202
  },
214
203
  argTypes: {
@@ -60,29 +60,29 @@ const icons = [undefined, ...Object.keys(iconsMap)];
60
60
  const getRandomInt = (min: number, max: number) =>
61
61
  Math.floor(Math.random() * (Math.floor(max) - Math.ceil(min))) + Math.ceil(min);
62
62
 
63
+ const handleOpen = () => console.log('isOpen');
64
+ const handleClose = () => console.log('isClose');
65
+ const handleBlur = () => console.log('blur');
66
+
63
67
  interface ISelectCustomProps<T> extends ISelectProps<T> {
64
68
  valuesType: 'strings' | 'objects';
65
69
  shouldUseReactNodes?: boolean;
66
- shouldUsePopper?: boolean;
67
70
  shouldRenderInBody?: boolean;
68
71
  shouldHideOnScroll?: boolean;
69
72
  shouldUseCustomIsDisabledFunction?: boolean;
70
73
  shouldRenderSearchInputInList?: boolean;
71
74
  canBeFlipped?: boolean;
72
- scrollParent?: 'document' | 'auto';
73
75
  }
74
76
 
75
77
  function Story<T>({
76
78
  valuesType,
77
79
  optionsMode,
78
80
  shouldUseReactNodes,
79
- shouldUsePopper,
80
81
  shouldRenderInBody,
81
82
  shouldHideOnScroll,
82
83
  shouldUseCustomIsDisabledFunction,
83
84
  shouldRenderSearchInputInList,
84
85
  canBeFlipped,
85
- scrollParent,
86
86
  noMatchesLabel,
87
87
  ...args
88
88
  }: ISelectCustomProps<T>): ReactElement {
@@ -120,14 +120,6 @@ function Story<T>({
120
120
 
121
121
  const [dynamicOptions, setDynamicOptions] = useState<Array<string | ObjectValue>>([]);
122
122
 
123
- const handleOpen = () => {
124
- console.log('isOpen');
125
- };
126
-
127
- const handleBlur = () => {
128
- console.log('blur');
129
- };
130
-
131
123
  useEffect(() => {
132
124
  const api = async () => {
133
125
  setDynamicOptions(await getOptions());
@@ -166,13 +158,12 @@ function Story<T>({
166
158
  optionsMode={optionsMode}
167
159
  onType={async () => setDynamicOptions(await getOptions())}
168
160
  onOpen={handleOpen}
161
+ onClose={handleClose}
169
162
  onBlur={handleBlur}
170
163
  dropdownOptions={{
171
- shouldUsePopper,
172
164
  shouldRenderInBody,
173
165
  shouldHideOnScroll,
174
166
  canBeFlipped,
175
- scrollParent,
176
167
  }}
177
168
  />
178
169
  );
@@ -199,14 +190,12 @@ const meta: Meta<typeof Story> = {
199
190
  shouldUseReactNodes: false,
200
191
  valuesType: 'strings',
201
192
  optionsMode: 'normal',
202
- shouldUsePopper: false,
203
193
  shouldRenderInBody: false,
204
194
  shouldHideOnScroll: false,
205
195
  shouldUseCustomIsDisabledFunction: false,
206
196
  shouldRenderSearchInputInList: false,
207
197
  shouldScrollToList: true,
208
198
  canBeFlipped: false,
209
- scrollParent: 'document',
210
199
  size: undefined,
211
200
  },
212
201
  argTypes: {
@@ -3,6 +3,7 @@ import { animations, createThemedStyles, dimensions, type ITweakStyles } from '.
3
3
  import { type IInputStyles } from '../Input';
4
4
  import { type ISearchInputStyles } from '../SearchInput';
5
5
  import { IWithMessagesStyles } from '../WithMessages';
6
+ import { IWithPopupStyles } from '../WithPopup';
6
7
  import { type ISelectListStyles } from './components';
7
8
 
8
9
  const { Z_INDEX } = dimensions;
@@ -19,25 +20,6 @@ export const useStyles = createThemedStyles('Select', {
19
20
  cursor: 'text',
20
21
  },
21
22
 
22
- listWrapper: {
23
- left: -1,
24
- zIndex: 3,
25
- width: 'fit-content',
26
- minWidth: 'calc(100% + 1px)',
27
- },
28
-
29
- withoutPopper: {
30
- position: 'absolute',
31
- top: '100%',
32
- paddingTop: 4,
33
- },
34
-
35
- listWrapperInBody: {
36
- minWidth: 'auto',
37
- width: 'auto',
38
- maxWidth: 'min-content',
39
- },
40
-
41
23
  arrow: {
42
24
  width: 'var(--icon-inner-size, 20px)',
43
25
  height: 'var(--icon-inner-size, 20px)',
@@ -93,6 +75,12 @@ export const getInputStyles = ({
93
75
  return baseInputStyles;
94
76
  };
95
77
 
78
+ export const withPopupStyles: IWithPopupStyles = {
79
+ popup: {
80
+ maxWidth: 'min-content',
81
+ },
82
+ };
83
+
96
84
  export type ISelectStyles = ITweakStyles<
97
85
  typeof useStyles,
98
86
  {
@@ -100,5 +88,6 @@ export type ISelectStyles = ITweakStyles<
100
88
  tweakInput: IInputStyles;
101
89
  tweakSelectList: ISelectListStyles;
102
90
  tweakSearchInput: ISearchInputStyles;
91
+ tweakWithPopup?: IWithPopupStyles;
103
92
  }
104
93
  >;