@broxus/react-uikit 0.9.2 → 0.11.0

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 (61) hide show
  1. package/dist/cjs/components/Accordion/Item.d.ts +2 -1
  2. package/dist/cjs/components/Alert/index.d.ts +2 -2
  3. package/dist/cjs/components/Align/Align.d.ts +2 -2
  4. package/dist/cjs/components/Article/context.js +1 -0
  5. package/dist/cjs/components/Card/Card.js +4 -4
  6. package/dist/cjs/components/Card/context.d.ts +2 -2
  7. package/dist/cjs/components/Card/context.js +1 -0
  8. package/dist/cjs/components/ConfigProvider/index.js +1 -0
  9. package/dist/cjs/components/Control/Checkbox/CheckboxGroupContext.js +1 -0
  10. package/dist/cjs/components/Control/Radio/RadioGroupContext.js +1 -0
  11. package/dist/cjs/components/Control/Select/index.d.ts +1 -1
  12. package/dist/cjs/components/Flex/Flex.d.ts +2 -2
  13. package/dist/cjs/components/Flex/Flex.js +2 -2
  14. package/dist/cjs/components/Flex/context.js +1 -0
  15. package/dist/cjs/components/Form/context.js +1 -0
  16. package/dist/cjs/components/Nav/context/IdContext.js +1 -0
  17. package/dist/cjs/components/Nav/context/NavContext.js +1 -0
  18. package/dist/cjs/components/Nav/context/PathContext.js +1 -0
  19. package/dist/cjs/components/Nav/context/PrivateContext.js +1 -0
  20. package/dist/cjs/components/Section/index.js +3 -3
  21. package/dist/cjs/components/Tabs/hooks/index.d.ts +0 -1
  22. package/dist/cjs/components/Tabs/hooks/index.js +0 -1
  23. package/dist/cjs/components/Tabs/hooks/useAnimateConfig.d.ts +1 -1
  24. package/dist/cjs/components/Tabs/index.d.ts +22 -5
  25. package/dist/cjs/components/Tabs/index.js +7 -3
  26. package/dist/cjs/components/Text/index.js +7 -7
  27. package/dist/cjs/components/Tile/index.js +3 -3
  28. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  29. package/dist/esm/components/Accordion/Item.d.ts +2 -1
  30. package/dist/esm/components/Alert/index.d.ts +2 -2
  31. package/dist/esm/components/Align/Align.d.ts +2 -2
  32. package/dist/esm/components/Article/context.js +1 -0
  33. package/dist/esm/components/Card/Card.js +4 -4
  34. package/dist/esm/components/Card/context.d.ts +2 -2
  35. package/dist/esm/components/Card/context.js +1 -0
  36. package/dist/esm/components/ConfigProvider/index.js +1 -0
  37. package/dist/esm/components/Control/Checkbox/CheckboxGroupContext.js +1 -0
  38. package/dist/esm/components/Control/Radio/RadioGroupContext.js +1 -0
  39. package/dist/esm/components/Control/Select/index.d.ts +1 -1
  40. package/dist/esm/components/Flex/Flex.d.ts +2 -2
  41. package/dist/esm/components/Flex/Flex.js +2 -2
  42. package/dist/esm/components/Flex/context.js +1 -0
  43. package/dist/esm/components/Form/context.js +1 -0
  44. package/dist/esm/components/Nav/context/IdContext.js +1 -0
  45. package/dist/esm/components/Nav/context/NavContext.js +1 -0
  46. package/dist/esm/components/Nav/context/PathContext.js +1 -0
  47. package/dist/esm/components/Nav/context/PrivateContext.js +1 -0
  48. package/dist/esm/components/Section/index.js +3 -3
  49. package/dist/esm/components/Tabs/hooks/index.d.ts +0 -1
  50. package/dist/esm/components/Tabs/hooks/index.js +0 -1
  51. package/dist/esm/components/Tabs/hooks/useAnimateConfig.d.ts +1 -1
  52. package/dist/esm/components/Tabs/index.d.ts +22 -5
  53. package/dist/esm/components/Tabs/index.js +8 -4
  54. package/dist/esm/components/Text/index.js +7 -7
  55. package/dist/esm/components/Tile/index.js +3 -3
  56. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  57. package/package.json +13 -13
  58. package/dist/cjs/components/Tabs/hooks/useLegacyItems.d.ts +0 -4
  59. package/dist/cjs/components/Tabs/hooks/useLegacyItems.js +0 -56
  60. package/dist/esm/components/Tabs/hooks/useLegacyItems.d.ts +0 -4
  61. package/dist/esm/components/Tabs/hooks/useLegacyItems.js +0 -26
@@ -1,6 +1,7 @@
1
1
  import { type CollapsePanelProps } from 'rc-collapse';
2
2
  import * as React from 'react';
3
- export type AccordionItemProps = React.PropsWithChildren<Omit<CollapsePanelProps, 'prefixCls'>>;
3
+ export interface AccordionItemProps extends React.PropsWithChildren<Omit<CollapsePanelProps, 'prefixCls'>> {
4
+ }
4
5
  /**
5
6
  * Use Accordion items props instead
6
7
  * @deprecated
@@ -9,7 +9,7 @@ export interface AlertProps extends React.HTMLAttributes<HTMLDivElement> {
9
9
  onClose?: VoidFunction;
10
10
  onClosed?: MotionEndEventHandler;
11
11
  }
12
- export type AlertRef = {
12
+ export interface AlertRef {
13
13
  close: VoidFunction;
14
- };
14
+ }
15
15
  export declare const Alert: React.ForwardRefExoticComponent<AlertProps & React.RefAttributes<AlertRef>>;
@@ -1,11 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import { type PolymorphicProps } from '../../components/Component';
3
3
  import { type Direction } from '../../types';
4
- export type AlignOwnProps = {
4
+ export interface AlignOwnProps {
5
5
  direction?: Direction;
6
6
  prefixCls?: string;
7
7
  side?: 'left' | 'right';
8
- };
8
+ }
9
9
  export type AlignProps<E extends React.ElementType = React.ElementType> = React.PropsWithChildren<AlignOwnProps & PolymorphicProps<E>> & PolymorphicProps<E, AlignOwnProps>;
10
10
  declare const defaultElement = "div";
11
11
  export declare function Align<E extends React.ElementType = typeof defaultElement>(props: AlignProps<E>): React.JSX.Element;
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from 'react';
2
3
  export const ArticleContext = React.createContext({
3
4
  getRootCls() {
@@ -7,7 +7,7 @@ import { useConfig } from '../../components/ConfigProvider';
7
7
  const defaultElement = 'div';
8
8
  export function Card(props) {
9
9
  const config = useConfig();
10
- const { asBody, className, kind, colorMode = kind !== 'default' && kind !== undefined
10
+ const { asBody, className, kind, colorMode = kind && kind !== 'default'
11
11
  // @ts-ignore
12
12
  ? config[`card${capitalizeFirstLetter(kind)}ColorMode`]
13
13
  : undefined, hoverable, prefixCls = config.prefixCls, size, ...restProps } = props;
@@ -19,11 +19,11 @@ export function Card(props) {
19
19
  }), [rootCls]);
20
20
  return (React.createElement(CardContext.Provider, { value: context },
21
21
  React.createElement(Component, { className: classNames(rootCls, {
22
- [`${rootCls}-${kind}`]: kind !== undefined,
23
- [`${rootCls}-${size}`]: size !== undefined,
22
+ [`${rootCls}-${kind}`]: kind && ['default', 'primary', 'secondary', 'tertiary'].includes(kind),
23
+ [`${rootCls}-${size}`]: size && ['small', 'large'].includes(size),
24
24
  [`${rootCls}-body`]: asBody,
25
25
  [`${rootCls}-hover`]: hoverable,
26
- [`${config.prefixCls}-${colorMode}`]: colorMode !== undefined,
26
+ [`${config.prefixCls}-${colorMode}`]: colorMode && ['dark', 'light'].includes(colorMode),
27
27
  }, className), component: defaultElement, ...restProps })));
28
28
  }
29
29
  if (process.env.NODE_ENV !== 'production') {
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- export type CardContextConsumerProps = {
2
+ export interface CardContextConsumerProps {
3
3
  getRootCls(): string | undefined;
4
- };
4
+ }
5
5
  export declare const CardContext: React.Context<CardContextConsumerProps>;
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from 'react';
2
3
  export const CardContext = React.createContext({
3
4
  getRootCls() {
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import { error } from '@broxus/js-utils';
2
3
  import * as React from 'react';
3
4
  export const ConfigContext = React.createContext({
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from 'react';
2
3
  export const CheckboxGroupContext = React.createContext(null);
3
4
  export function useCheckboxGroup() {
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from 'react';
2
3
  export const RadioGroupContext = React.createContext(null);
3
4
  export function useRadioGroup() {
@@ -15,7 +15,7 @@ export interface SelectProps<ValueType = any, OptionType extends BaseOptionType
15
15
  showArrow?: boolean;
16
16
  }
17
17
  export declare const Select: (<ValueType = any, OptionType extends BaseOptionType | DefaultOptionType = DefaultOptionType>(props: SelectProps<ValueType, OptionType> & {
18
- ref?: React.Ref<BaseSelectRef> | undefined;
18
+ ref?: React.Ref<BaseSelectRef>;
19
19
  }) => React.ReactElement) & {
20
20
  SECRET_COMBOBOX_MODE_DO_NOT_USE: string;
21
21
  Option: typeof Option;
@@ -1,8 +1,8 @@
1
1
  import * as React from 'react';
2
2
  import { type PolymorphicProps } from '../../components/Component';
3
3
  import { type BreakpointsConfig } from '../../types';
4
- export type FlexAlignContent = 'stretch' | 'between' | 'around' | 'start' | 'middle' | 'end';
5
- export type FlexAlignItems = 'stretch' | 'start' | 'middle' | 'end';
4
+ export type FlexAlignContent = 'stretch' | 'between' | 'around' | 'start' | 'center' | 'end';
5
+ export type FlexAlignItems = 'stretch' | 'start' | 'center' | 'end';
6
6
  export type FlexDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
7
7
  export type FlexWrap = 'wrap' | 'nowrap' | 'wrap-reverse';
8
8
  export type FlexJustifyContent = 'start' | 'center' | 'end' | 'between' | 'around';
@@ -9,13 +9,13 @@ const alignContentMap = new Map([
9
9
  ['around', 'around'],
10
10
  ['between', 'between'],
11
11
  ['end', 'right'],
12
- ['middle', 'middle'],
12
+ ['center', 'middle'],
13
13
  ['start', 'left'],
14
14
  ['stretch', 'stretch'],
15
15
  ]);
16
16
  const alignItemsMap = new Map([
17
17
  ['end', 'bottom'],
18
- ['middle', 'middle'],
18
+ ['center', 'middle'],
19
19
  ['start', 'top'],
20
20
  ['stretch', 'stretch'],
21
21
  ]);
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from 'react';
2
3
  export const FlexContext = React.createContext({
3
4
  getRootCls() {
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from 'react';
2
3
  export const FormContext = React.createContext({
3
4
  getRootCls() {
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from 'react';
2
3
  export const IdContext = React.createContext(undefined);
3
4
  export function getNavId(uuid, eventKey) {
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import useMemo from 'rc-util/lib/hooks/useMemo';
2
3
  import * as React from 'react';
3
4
  import shallowEqual from 'shallowequal';
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import * as React from 'react';
2
3
  const EmptyList = [];
3
4
  export const PathRegisterContext = React.createContext(null);
@@ -1,2 +1,3 @@
1
+ 'use client';
1
2
  import * as React from 'react';
2
3
  export const PrivateContext = React.createContext({});
@@ -6,11 +6,11 @@ import './index.scss';
6
6
  const defaultElement = 'section';
7
7
  export function Section(props) {
8
8
  const config = useConfig();
9
- const { className, prefixCls = config.prefixCls, preserveColor, size, kind, ...restProps } = props;
9
+ const { className, kind, prefixCls = config.prefixCls, preserveColor, size, ...restProps } = props;
10
10
  const rootCls = React.useMemo(() => config.getRootPrefixCls(prefixCls || config.prefixCls, 'section'), [config, prefixCls]);
11
11
  return (React.createElement(Component, { className: classNames(rootCls, {
12
- [`${rootCls}-${size}`]: size !== undefined,
13
- [`${rootCls}-${kind}`]: kind !== undefined,
12
+ [`${rootCls}-${size}`]: size && ['xsmall', 'small', 'large', 'xlarge'].includes(size),
13
+ [`${rootCls}-${kind}`]: kind && ['default', 'muted', 'primary', 'secondary', 'tertiary'].includes(kind),
14
14
  [`${prefixCls || config.prefixCls}-preserve-color`]: preserveColor,
15
15
  }, className), component: defaultElement, ...restProps }));
16
16
  }
@@ -1,2 +1 @@
1
1
  export * from '../../../components/Tabs/hooks/useAnimateConfig';
2
- export * from '../../../components/Tabs/hooks/useLegacyItems';
@@ -1,2 +1 @@
1
1
  export * from '../../../components/Tabs/hooks/useAnimateConfig';
2
- export * from '../../../components/Tabs/hooks/useLegacyItems';
@@ -1,3 +1,3 @@
1
- import { type AnimatedConfig } from 'rc-tabs/lib/interface';
1
+ import { type AnimatedConfig } from 'rc-tabs/es/interface';
2
2
  import { type TabsProps } from '../../../components/Tabs';
3
3
  export declare function useAnimateConfig(prefixCls: string, animated?: TabsProps['animated']): AnimatedConfig;
@@ -1,16 +1,33 @@
1
1
  import { type TabsProps as RcTabsProps } from 'rc-tabs';
2
- import { type Tab, type TabPosition as TabsPosition } from 'rc-tabs/lib/interface';
3
2
  import * as React from 'react';
4
3
  import './index.scss';
5
- export { type Tab };
4
+ export type TabsPosition = 'left' | 'right' | 'top' | 'bottom';
5
+ export interface Tab {
6
+ active?: boolean;
7
+ animated?: boolean;
8
+ children?: React.ReactNode;
9
+ className?: string;
10
+ closable?: boolean;
11
+ closeIcon?: React.ReactNode;
12
+ destroyInactiveTabPane?: boolean;
13
+ disabled?: boolean;
14
+ forceRender?: boolean;
15
+ icon?: React.ReactNode;
16
+ id?: string;
17
+ key: string;
18
+ label: React.ReactNode;
19
+ prefixCls?: string;
20
+ style?: React.CSSProperties;
21
+ tabKey?: string;
22
+ }
6
23
  export type TabType = 'line' | 'card' | 'editable-card';
7
- export { type TabsPosition };
8
- export interface TabsProps extends Exclude<RcTabsProps, 'editable'> {
24
+ export interface TabsProps extends Exclude<RcTabsProps, 'editable' | 'items' | 'tabPosition'> {
9
25
  addIcon?: React.ReactNode;
10
26
  centered?: boolean;
11
- children?: React.ReactNode;
12
27
  hideAdd?: boolean;
28
+ items?: Tab[];
13
29
  size?: 'medium' | 'large';
30
+ tabPosition?: TabsPosition;
14
31
  type?: TabType;
15
32
  onEdit?: (event: React.MouseEvent | React.KeyboardEvent | string, action: 'add' | 'remove') => void;
16
33
  }
@@ -3,12 +3,12 @@ import RcTabs from 'rc-tabs';
3
3
  import * as React from 'react';
4
4
  import { useConfig } from '../../components/ConfigProvider';
5
5
  import { Icon } from '../../components/Icon';
6
- import { useAnimateConfig, useLegacyItems } from '../../components/Tabs/hooks';
6
+ import { useAnimateConfig } from '../../components/Tabs/hooks';
7
7
  import { getMotionName } from '../../utils';
8
8
  import './index.scss';
9
9
  export function Tabs(props) {
10
10
  const config = useConfig();
11
- const { addIcon, animated, centered, children, className, direction, hideAdd, items, moreIcon = React.createElement(Icon, { icon: "more_horizontal" }), prefixCls = config.prefixCls, size, type, onEdit, ...restProps } = props;
11
+ const { addIcon, animated, centered, className, direction, hideAdd, items, more, prefixCls = config.prefixCls, size, type, onEdit, ...restProps } = props;
12
12
  const rootCls = React.useMemo(() => config.getRootPrefixCls(prefixCls || config.prefixCls, 'tabs'), [config, prefixCls]);
13
13
  const editable = React.useMemo(() => (type === 'editable-card'
14
14
  ? {
@@ -22,10 +22,14 @@ export function Tabs(props) {
22
22
  },
23
23
  }
24
24
  : undefined), [addIcon, hideAdd, onEdit, type]);
25
- return (React.createElement(RcTabs, { animated: useAnimateConfig(rootCls, animated), direction: direction, items: useLegacyItems(items, children), moreTransitionName: getMotionName(prefixCls || config.prefixCls, 'slide-bottom-small'), ...restProps, className: classNames({
25
+ return (React.createElement(RcTabs, { animated: useAnimateConfig(rootCls, animated), direction: direction, items: items, ...restProps, className: classNames({
26
26
  [`${rootCls}-${size}`]: size,
27
27
  [`${rootCls}-card`]: ['card', 'editable-card'].includes(type),
28
28
  [`${rootCls}-editable-card`]: type === 'editable-card',
29
29
  [`${rootCls}-centered`]: centered,
30
- }, className), editable: editable, moreIcon: moreIcon, prefixCls: rootCls }));
30
+ }, className), editable: editable, more: {
31
+ icon: React.createElement(Icon, { icon: "more_horizontal" }),
32
+ transitionName: getMotionName(prefixCls || config.prefixCls, 'slide-bottom-small'),
33
+ ...more,
34
+ }, prefixCls: rootCls }));
31
35
  }
@@ -16,13 +16,13 @@ export function Text(props) {
16
16
  : getBreakpointsConfigClasses(prefixCls || config.prefixCls, 'column-1', column)), [column, config.prefixCls, prefixCls]);
17
17
  return (React.createElement(Component, { className: classNames(columnClassName, alignClassName, {
18
18
  [`${prefixCls || config.prefixCls}-dropcap`]: dropcap,
19
- [`${rootCls}-${color}`]: color !== undefined,
20
- [`${rootCls}-${kind}`]: kind !== undefined,
21
- [`${rootCls}-${size}`]: size !== undefined,
22
- [`${rootCls}-${transform}`]: transform !== undefined,
23
- [`${rootCls}-${verticalAlign}`]: verticalAlign !== undefined,
24
- [`${rootCls}-${weight}`]: weight !== undefined,
25
- [`${rootCls}-${wrap}`]: wrap !== undefined,
19
+ [`${rootCls}-${color}`]: color && ['muted', 'emphasis', 'primary', 'secondary', 'tertiary', 'success', 'warning', 'danger'].includes(color),
20
+ [`${rootCls}-${kind}`]: kind && ['meta', 'lead', 'base'].includes(kind),
21
+ [`${rootCls}-${size}`]: size && ['xsmall', 'small', 'large'].includes(size),
22
+ [`${rootCls}-${transform}`]: transform && ['capitalize', 'uppercase', 'lowercase'].includes(transform),
23
+ [`${rootCls}-${verticalAlign}`]: verticalAlign && ['top', 'middle', 'bottom', 'baseline'].includes(verticalAlign),
24
+ [`${rootCls}-${weight}`]: weight && ['thin', 'light', 'normal', 'medium', 'semibold', 'bold', 'lighter', 'bolder'].includes(weight),
25
+ [`${rootCls}-${wrap}`]: wrap && ['truncate', 'break', 'nowrap'].includes(wrap),
26
26
  [`${rootCls}-decoration-none`]: decoration === 'none',
27
27
  [`${rootCls}-italic`]: italic,
28
28
  }, className), component: defaultElement, ...restProps }));
@@ -6,11 +6,11 @@ import './index.scss';
6
6
  const defaultElement = 'div';
7
7
  export function Tile(props) {
8
8
  const config = useConfig();
9
- const { className, prefixCls = config.prefixCls, preserveColor, size, kind, ...restProps } = props;
9
+ const { className, kind, prefixCls = config.prefixCls, preserveColor, size, ...restProps } = props;
10
10
  const rootCls = React.useMemo(() => config.getRootPrefixCls(prefixCls || config.prefixCls, 'tile'), [config, prefixCls]);
11
11
  return (React.createElement(Component, { className: classNames(rootCls, {
12
- [`${rootCls}-${size}`]: size !== undefined,
13
- [`${rootCls}-${kind}`]: kind !== undefined,
12
+ [`${rootCls}-${size}`]: size && ['xsmall', 'small', 'large', 'xlarge'].includes(size),
13
+ [`${rootCls}-${kind}`]: kind && ['default', 'muted', 'primary', 'secondary', 'tertiary'].includes(kind),
14
14
  [`${prefixCls || config.prefixCls}-preserve-color`]: preserveColor,
15
15
  }, className), component: defaultElement, ...restProps }));
16
16
  }