Skip to content

Commit febcc41

Browse files
committed
feat(select): added environment support via config
1 parent 985c28c commit febcc41

5 files changed

Lines changed: 20 additions & 3 deletions

File tree

.changeset/bright-dingos-arrive.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@alfalab/core-components-select': minor
3+
'@alfalab/core-components': minor
4+
---
5+
6+
##### Select:
7+
8+
- Добавлена поддержка `environment` через `CoreConfigContext`

packages/select/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"tslib": "^2.4.0"
3737
},
3838
"peerDependencies": {
39+
"@alfalab/core-components-config": "^1.0.0",
3940
"react": "^16.9.0 || ^17.0.1 || ^18.0.0",
4041
"react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0"
4142
},

packages/select/src/components/base-select/Component.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ import {
2222
type UseMultipleSelectionState,
2323
} from 'downshift';
2424

25-
import { fnUtils, getDataTestId, isClient } from '@alfalab/core-components-shared';
25+
import { useCoreConfig } from '@alfalab/core-components-config';
26+
import { fnUtils, getDataTestId } from '@alfalab/core-components-shared';
2627
import { useLayoutEffect_SAFE_FOR_SSR } from '@alfalab/hooks';
2728

2829
import { SIZE_TO_CLASSNAME_MAP } from '../../consts';
@@ -123,7 +124,7 @@ export const BaseSelect = forwardRef<unknown, ComponentProps>(
123124
ModalMobile,
124125
BottomSheet,
125126
limitDynamicOptionGroupSize,
126-
environment = isClient() ? window : undefined,
127+
environment: environmentFromProps,
127128
} = props;
128129
const shouldSearchBlurRef = useRef(true);
129130
const rootRef = useRef<HTMLDivElement>(null);
@@ -133,7 +134,8 @@ export const BaseSelect = forwardRef<unknown, ComponentProps>(
133134
const searchRef = useRef<HTMLInputElement>(null);
134135
const scrollableContainerRef = useRef<HTMLDivElement>(null);
135136
const onOpenRef = useRef(onOpen);
136-
137+
const { environment: environmentFromConfig } = useCoreConfig();
138+
const environment = environmentFromProps ?? environmentFromConfig;
137139
const [searchState, setSearchState] = React.useState('');
138140

139141
const [search, setSearch] =

packages/select/tsconfig.build.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
"@alfalab/core-components-button/*": ["../button/src/*"],
1818
"@alfalab/core-components-checkbox": ["../checkbox/src"],
1919
"@alfalab/core-components-checkbox/*": ["../checkbox/src/*"],
20+
"@alfalab/core-components-config": ["../config/src"],
21+
"@alfalab/core-components-config/*": ["../config/src/*"],
2022
"@alfalab/core-components-form-control": ["../form-control/src"],
2123
"@alfalab/core-components-form-control/*": ["../form-control/src/*"],
2224
"@alfalab/core-components-input": ["../input/src"],
@@ -43,6 +45,7 @@
4345
{ "path": "../bottom-sheet/tsconfig.build.json" },
4446
{ "path": "../button/tsconfig.build.json" },
4547
{ "path": "../checkbox/tsconfig.build.json" },
48+
{ "path": "../config/tsconfig.build.json" },
4649
{ "path": "../form-control/tsconfig.build.json" },
4750
{ "path": "../input/tsconfig.build.json" },
4851
{ "path": "../modal/tsconfig.build.json" },

packages/select/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
"@alfalab/core-components-button/*": ["../button/src/*"],
1717
"@alfalab/core-components-checkbox": ["../checkbox/src"],
1818
"@alfalab/core-components-checkbox/*": ["../checkbox/src/*"],
19+
"@alfalab/core-components-config": ["../config/src"],
20+
"@alfalab/core-components-config/*": ["../config/src/*"],
1921
"@alfalab/core-components-form-control": ["../form-control/src"],
2022
"@alfalab/core-components-form-control/*": ["../form-control/src/*"],
2123
"@alfalab/core-components-input": ["../input/src"],
@@ -46,6 +48,7 @@
4648
{ "path": "../bottom-sheet/tsconfig.build.json" },
4749
{ "path": "../button/tsconfig.build.json" },
4850
{ "path": "../checkbox/tsconfig.build.json" },
51+
{ "path": "../config/tsconfig.build.json" },
4952
{ "path": "../form-control/tsconfig.build.json" },
5053
{ "path": "../input/tsconfig.build.json" },
5154
{ "path": "../modal/tsconfig.build.json" },

0 commit comments

Comments
 (0)