@broxus/react-uikit 0.4.0 → 0.4.1

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.
@@ -9,8 +9,8 @@ export type ConfigContextConsumerProps = {
9
9
  direction?: string;
10
10
  getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
11
11
  getRootPrefixCls: (prefix?: string, component?: string) => string;
12
- getTooltipConfig: (props: string | TooltipOptions) => {
13
- 'data-uk-tooltip': string;
12
+ getTooltipConfig: (props: string | TooltipOptions | undefined) => {
13
+ 'data-uk-tooltip'?: string;
14
14
  };
15
15
  inverseGlobalColorMode?: ColorMode;
16
16
  prefixCls: string;
@@ -24,4 +24,4 @@ export type ConfigContextConsumerProps = {
24
24
  export type ConfigContextProviderProps = React.PropsWithChildren<ConfigContextConsumerProps>;
25
25
  export declare const ConfigContext: React.Context<ConfigContextConsumerProps>;
26
26
  export declare function useConfig(): ConfigContextConsumerProps;
27
- export declare function ConfigContextProvider(props: Partial<ConfigContextProviderProps>): JSX.Element;
27
+ export declare const ConfigContextProvider: React.MemoExoticComponent<(props: Partial<ConfigContextProviderProps>) => React.JSX.Element>;
@@ -1,6 +1,5 @@
1
1
  import { error } from '@broxus/js-utils';
2
2
  import * as React from 'react';
3
- import { useContext } from '../../hooks';
4
3
  export const ConfigContext = React.createContext({
5
4
  breakpoints: {
6
5
  l: 1200,
@@ -16,6 +15,9 @@ export const ConfigContext = React.createContext({
16
15
  return `${prefix ? `${prefix}-` : `${this.prefixCls}-`}${module ?? ''}`;
17
16
  },
18
17
  getTooltipConfig(props) {
18
+ if (props == null) {
19
+ return {};
20
+ }
19
21
  if (typeof props === 'string') {
20
22
  return { 'data-uk-tooltip': `title: ${props}` };
21
23
  }
@@ -41,10 +43,10 @@ export const ConfigContext = React.createContext({
41
43
  // tileTertiaryColorMode: 'light',
42
44
  });
43
45
  export function useConfig() {
44
- return useContext(ConfigContext);
46
+ return React.useContext(ConfigContext);
45
47
  }
46
- export function ConfigContextProvider(props) {
47
- const initialContext = React.useContext(ConfigContext);
48
+ export const ConfigContextProvider = React.memo((props) => {
49
+ const initialContext = useConfig();
48
50
  const { children, ...restProps } = props;
49
51
  const context = React.useMemo(() => {
50
52
  let direction = 'ltr';
@@ -57,7 +59,7 @@ export function ConfigContextProvider(props) {
57
59
  return { ...initialContext, direction, ...restProps };
58
60
  }, [initialContext, restProps]);
59
61
  return React.createElement(ConfigContext.Provider, { value: context }, children);
60
- }
62
+ });
61
63
  if (process.env.NODE_ENV !== 'production') {
62
64
  ConfigContext.displayName = 'ConfigContext';
63
65
  }