@via-profit/ui-kit 0.10.1 → 0.12.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 (42) hide show
  1. package/Badge/BadgeBase.d.ts +8 -3
  2. package/Badge/BadgeBase.js +5 -6
  3. package/Badge/BadgeContainer.d.ts +8 -0
  4. package/Badge/BadgeContainer.js +148 -10
  5. package/Badge/BadgeDeleteButton.d.ts +4 -4
  6. package/Badge/BadgeDeleteButton.js +5 -4
  7. package/Badge/BadgeDeleteIcon.d.ts +4 -0
  8. package/Badge/BadgeDeleteIcon.js +9 -0
  9. package/Badge/BadgeOutlined.js +2 -2
  10. package/Badge/BadgeStandard.js +2 -2
  11. package/Badge/BadgeStyled.d.ts +2 -5
  12. package/Badge/BadgeStyled.js +4 -163
  13. package/Badge/index.d.ts +3 -4
  14. package/Badge/index.js +17 -3
  15. package/CHANGELOG.md +23 -0
  16. package/Popper/Popper.js +17 -12
  17. package/ThemeProvider/tokens.d.ts +1 -1
  18. package/ThemeProvider/tokens.js +1 -1
  19. package/Toast/ToastContainer.d.ts +5 -3
  20. package/Toast/ToastContainer.js +1 -1
  21. package/Toast/ToastItem.d.ts +2 -2
  22. package/Toast/ToastItem.js +11 -1
  23. package/Toast/index.d.ts +1 -1
  24. package/Toast/store.d.ts +15 -0
  25. package/Toast/store.js +5 -1
  26. package/Tooltip/index.d.ts +6 -0
  27. package/Tooltip/index.js +9 -6
  28. package/esm/Badge/BadgeBase.js +5 -6
  29. package/esm/Badge/BadgeContainer.js +148 -10
  30. package/esm/Badge/BadgeDeleteButton.js +5 -4
  31. package/esm/Badge/BadgeDeleteIcon.js +4 -0
  32. package/esm/Badge/BadgeOutlined.js +2 -2
  33. package/esm/Badge/BadgeStandard.js +2 -2
  34. package/esm/Badge/BadgeStyled.js +2 -163
  35. package/esm/Badge/index.js +17 -3
  36. package/esm/Popper/Popper.js +17 -12
  37. package/esm/ThemeProvider/tokens.js +1 -1
  38. package/esm/Toast/ToastContainer.js +2 -2
  39. package/esm/Toast/ToastItem.js +12 -2
  40. package/esm/Toast/store.js +4 -0
  41. package/esm/Tooltip/index.js +9 -6
  42. package/package.json +6 -1
@@ -4,6 +4,7 @@ import { BadgeTextWrapperProps } from './BadgeTextWrapper';
4
4
  import { BadgeContainerProps } from './BadgeContainer';
5
5
  import { BadgeDeleteButtonProps } from './BadgeDeleteButton';
6
6
  import { BadgeDotProps } from './BadgeDot';
7
+ import { BadgeDeleteIconProps } from './BadgeDeleteIcon';
7
8
  type BadgeNativeProps = React.HTMLAttributes<HTMLSpanElement>;
8
9
  export interface BadgeBaseProps extends Omit<BadgeNativeProps, 'color'> {
9
10
  /**
@@ -22,11 +23,11 @@ export interface BadgeBaseProps extends Omit<BadgeNativeProps, 'color'> {
22
23
  readonly dot?: boolean;
23
24
  /**
24
25
  * Badge style variant\
25
- * Allowed variants: `standard` or `outlined`\
26
+ * Allowed variants: `standard`, `outlined` or `soft`\
26
27
  * \
27
- * **Default**: `standard`
28
+ * `<Badge>` defaults to `standard`; the bare `<BadgeBase>` has no variant styles
28
29
  */
29
- readonly variant?: 'standard' | 'outlined' | 'soft';
30
+ readonly variant?: BadgeContainerProps['variant'];
30
31
  /**
31
32
  * You can pass the primary, default, secondary name of the colors or your specified color value
32
33
  */
@@ -63,6 +64,10 @@ export interface BadgeBaseOverrides {
63
64
  * Icon delete
64
65
  */
65
66
  readonly ButtonDelete?: React.ComponentType<BadgeDeleteButtonProps & React.RefAttributes<HTMLButtonElement>>;
67
+ /**
68
+ * The icon inside the delete button
69
+ */
70
+ readonly DeleteIcon?: React.ComponentType<BadgeDeleteIconProps & React.RefAttributes<SVGSVGElement>>;
66
71
  /**
67
72
  * The dot. Rendered only with `dot`
68
73
  */
@@ -20,6 +20,7 @@ const BadgeTextWrapper_1 = __importDefault(require("./BadgeTextWrapper"));
20
20
  const BadgeContainer_1 = __importDefault(require("./BadgeContainer"));
21
21
  const BadgeDeleteButton_1 = __importDefault(require("./BadgeDeleteButton"));
22
22
  const BadgeDot_1 = __importDefault(require("./BadgeDot"));
23
+ const BadgeDeleteIcon_1 = __importDefault(require("./BadgeDeleteIcon"));
23
24
  const BadgeBase = (props, ref) => {
24
25
  const { children, startIcon, dot = false, color, variant, overrides, onDelete, deleteButtonLabel = 'Delete', onClick, onKeyDown } = props, nativeProps = __rest(props, ["children", "startIcon", "dot", "color", "variant", "overrides", "onDelete", "deleteButtonLabel", "onClick", "onKeyDown"]);
25
26
  const clickable = typeof onClick === 'function';
@@ -28,6 +29,7 @@ const BadgeBase = (props, ref) => {
28
29
  IconWrapper: (overrides === null || overrides === void 0 ? void 0 : overrides.IconWrapper) || BadgeIconWrapper_1.default,
29
30
  Container: (overrides === null || overrides === void 0 ? void 0 : overrides.Container) || BadgeContainer_1.default,
30
31
  ButtonDelete: (overrides === null || overrides === void 0 ? void 0 : overrides.ButtonDelete) || BadgeDeleteButton_1.default,
32
+ DeleteIcon: (overrides === null || overrides === void 0 ? void 0 : overrides.DeleteIcon) || BadgeDeleteIcon_1.default,
31
33
  Dot: (overrides === null || overrides === void 0 ? void 0 : overrides.Dot) || BadgeDot_1.default,
32
34
  }), [overrides]);
33
35
  // A clickable badge acts as a button, so it is activated by Enter and Space too
@@ -47,14 +49,11 @@ const BadgeBase = (props, ref) => {
47
49
  event.stopPropagation();
48
50
  onDelete === null || onDelete === void 0 ? void 0 : onDelete(event);
49
51
  }, [onDelete]);
50
- return (react_1.default.createElement(overridesMap.Container, Object.assign({ role: clickable ? 'button' : undefined, tabIndex: clickable ? 0 : undefined }, nativeProps, { onClick: onClick, onKeyDown: handleKeyDown, color: color, ref: ref }),
52
+ return (react_1.default.createElement(overridesMap.Container, Object.assign({ role: clickable ? 'button' : undefined, tabIndex: clickable ? 0 : undefined }, nativeProps, { onClick: onClick, onKeyDown: handleKeyDown, color: color, variant: variant, ref: ref }),
51
53
  dot && react_1.default.createElement(overridesMap.Dot, null),
52
54
  typeof startIcon !== 'undefined' && startIcon !== null && (react_1.default.createElement(overridesMap.IconWrapper, null, startIcon)),
53
55
  react_1.default.createElement(overridesMap.TextWrapper, null, children),
54
- typeof onDelete === 'function' && (react_1.default.createElement(overridesMap.ButtonDelete
55
- // the pale soft badge has the colored icon, as the outlined one
56
- , {
57
- // the pale soft badge has the colored icon, as the outlined one
58
- variant: variant === 'soft' ? 'outlined' : variant, onClick: handleDelete, color: color, "aria-label": deleteButtonLabel }))));
56
+ typeof onDelete === 'function' && (react_1.default.createElement(overridesMap.ButtonDelete, { variant: variant, onClick: handleDelete, color: color, "aria-label": deleteButtonLabel },
57
+ react_1.default.createElement(overridesMap.DeleteIcon, null)))));
59
58
  };
60
59
  exports.default = react_1.default.forwardRef(BadgeBase);
@@ -4,11 +4,19 @@ export type BadgeContainerProps = React.HTMLAttributes<HTMLSpanElement> & {
4
4
  * You can pass the primary, default, secondary name of the colors or your specified color value
5
5
  */
6
6
  readonly color?: 'default' | 'primary' | 'secondary' | string;
7
+ /**
8
+ * Without a variant the container has only the base styles (the bare `BadgeBase`)
9
+ */
10
+ readonly variant?: 'standard' | 'outlined' | 'soft';
7
11
  };
8
12
  declare const _default: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLSpanElement> & {
9
13
  /**
10
14
  * You can pass the primary, default, secondary name of the colors or your specified color value
11
15
  */
12
16
  readonly color?: "default" | "primary" | "secondary" | string;
17
+ /**
18
+ * Without a variant the container has only the base styles (the bare `BadgeBase`)
19
+ */
20
+ readonly variant?: "standard" | "outlined" | "soft";
13
21
  } & React.RefAttributes<HTMLSpanElement>>;
14
22
  export default _default;
@@ -16,6 +16,76 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  const react_1 = __importDefault(require("react"));
18
18
  const styled_1 = __importDefault(require("@emotion/styled"));
19
+ const react_2 = require("@emotion/react");
20
+ const Color_1 = __importDefault(require("../Color"));
21
+ const tokens_1 = require("../ThemeProvider/tokens");
22
+ const parseColor = (color, fallback) => {
23
+ try {
24
+ return Color_1.default.fromString(color);
25
+ }
26
+ catch (err) {
27
+ console.error(`invalid color value «${color}»`);
28
+ return fallback;
29
+ }
30
+ };
31
+ const getStandardColors = (color, theme) => {
32
+ switch (true) {
33
+ case color === 'primary':
34
+ return { $color: theme.color.accentPrimaryContrast, $background: theme.color.accentPrimary };
35
+ case color === 'secondary':
36
+ return {
37
+ $color: theme.color.accentSecondaryContrast,
38
+ $background: theme.color.accentSecondary,
39
+ };
40
+ case typeof color === 'undefined':
41
+ case color === 'default':
42
+ return { $background: theme.color.surface.darken(10), $color: theme.color.textPrimary };
43
+ default: {
44
+ const $background = parseColor(String(color), theme.color.surface);
45
+ return {
46
+ $background,
47
+ $color: $background.getContrast(theme.color.textPrimary) > 5
48
+ ? theme.color.textPrimary
49
+ : theme.color.surface,
50
+ };
51
+ }
52
+ }
53
+ };
54
+ const getOutlinedColors = (color, theme) => {
55
+ switch (true) {
56
+ case color === 'primary':
57
+ return { $color: theme.color.accentPrimary, $background: theme.color.accentPrimary };
58
+ case color === 'secondary':
59
+ return { $color: theme.color.accentSecondary, $background: theme.color.accentSecondary };
60
+ case typeof color === 'undefined':
61
+ case color === 'default':
62
+ return {
63
+ $color: Color_1.default.fromString(theme.color.textPrimary.toString()),
64
+ $background: theme.color.textPrimary.lighten(100),
65
+ };
66
+ default: {
67
+ const c = parseColor(String(color), theme.color.textPrimary);
68
+ return { $color: c, $background: c };
69
+ }
70
+ }
71
+ };
72
+ /**
73
+ * The pale background of the color and the text of the same hue: dark on the light theme,
74
+ * light on the dark one. `$background` is the color itself
75
+ */
76
+ const getSoftColors = (color, theme) => {
77
+ const base = color === 'primary'
78
+ ? theme.color.accentPrimary
79
+ : color === 'secondary'
80
+ ? theme.color.accentSecondary
81
+ : typeof color === 'undefined' || color === 'default'
82
+ ? theme.color.textPrimary
83
+ : parseColor(String(color), theme.color.textPrimary);
84
+ return {
85
+ $background: base,
86
+ $color: theme.isDark ? base.lighten(60) : base.darken(60),
87
+ };
88
+ };
19
89
  const StyledBadge = styled_1.default.span `
20
90
  border-radius: ${({ theme }) => theme.shape.radiusFactor * 2}em;
21
91
  font-size: 1em;
@@ -27,17 +97,85 @@ const StyledBadge = styled_1.default.span `
27
97
  background: none;
28
98
  display: inline-flex;
29
99
  align-items: center;
30
- color: ${({ color, theme }) => {
31
- switch (true) {
32
- case typeof color === 'undefined':
33
- default:
34
- return theme.color.textPrimary.toString();
35
- }
36
- }};
100
+ color: ${({ theme }) => theme.color.textPrimary.toString()};
101
+
102
+ /* One styled element for all variants: switching them must not lose focus */
103
+ ${({ $variant, $color, $background, $clickable, theme }) => $variant &&
104
+ (0, react_2.css) `
105
+ border-style: solid;
106
+ border-width: ${tokens_1.BORDER_WIDTH};
107
+ border-color: ${$background.toString()};
108
+ --badge-dot-color: ${($variant === 'standard' ? $color : $background).toString()};
109
+
110
+ ${$variant === 'soft' &&
111
+ (0, react_2.css) `
112
+ color: ${$color.toString()};
113
+ background-color: ${$background.alpha(0.18).toString()};
114
+ border-color: transparent;
115
+
116
+ &:focus-visible {
117
+ outline-style: solid;
118
+ outline-width: 0.14em;
119
+ outline-color: ${$background.alpha(0.6).toString()};
120
+ }
121
+ `}
122
+
123
+ ${$variant === 'soft'
124
+ ? ''
125
+ : $variant === 'outlined'
126
+ ? (0, react_2.css) `
127
+ color: ${$color.darken(30).toString()};
128
+ background-color: transparent;
129
+
130
+ &:focus-visible {
131
+ outline-style: solid;
132
+ outline-width: 0.14em;
133
+ outline-color: ${$background.rgbString()};
134
+ }
135
+ `
136
+ : (0, react_2.css) `
137
+ color: ${$color.toString()};
138
+ background-color: ${$background.toString()};
139
+
140
+ &:focus-visible {
141
+ outline-color: ${$background.rgbString() === theme.color.accentPrimary.rgbString()
142
+ ? theme.color.textPrimary.toString()
143
+ : theme.color.accentPrimary.toString()};
144
+ }
145
+ `}
146
+
147
+ ${$clickable &&
148
+ (0, react_2.css) `
149
+ cursor: pointer;
150
+
151
+ &:hover {
152
+ ${$variant === 'soft'
153
+ ? (0, react_2.css) `
154
+ background-color: ${$background.alpha(0.3).toString()};
155
+ `
156
+ : $variant === 'outlined'
157
+ ? (0, react_2.css) `
158
+ background-color: ${$background.darken(20).alpha(0.1).toString()};
159
+ `
160
+ : (0, react_2.css) `
161
+ background-color: ${$background.darken(30).toString()};
162
+ border-color: ${$background.darken(30).toString()};
163
+ `}
164
+ }
165
+ `}
166
+ ${(0, tokens_1.themeFocusRing)(theme)}
167
+ `}
37
168
  `;
38
169
  const BadgeContainer = (props, ref) => {
39
- // The color is applied by the badge variant, it must not reach the DOM as an attribute
40
- const { children, color } = props, nativeProps = __rest(props, ["children", "color"]);
41
- return (react_1.default.createElement(StyledBadge, Object.assign({}, nativeProps, { ref: ref }), children));
170
+ const { children, color, variant, onClick } = props, nativeProps = __rest(props, ["children", "color", "variant", "onClick"]);
171
+ const theme = (0, react_2.useTheme)();
172
+ const { $background, $color } = react_1.default.useMemo(() => !variant
173
+ ? { $background: theme.color.surface, $color: theme.color.textPrimary }
174
+ : variant === 'soft'
175
+ ? getSoftColors(color, theme)
176
+ : variant === 'outlined'
177
+ ? getOutlinedColors(color, theme)
178
+ : getStandardColors(color, theme), [color, variant, theme]);
179
+ return (react_1.default.createElement(StyledBadge, Object.assign({}, nativeProps, { "$variant": variant, "$clickable": typeof onClick === 'function', "$color": $color, "$background": $background, onClick: onClick, ref: ref }), children));
42
180
  };
43
181
  exports.default = react_1.default.forwardRef(BadgeContainer);
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
- export type BadgeDeleteButtonProps = Omit<React.HTMLAttributes<HTMLButtonElement>, 'children'> & {
2
+ export type BadgeDeleteButtonProps = React.HTMLAttributes<HTMLButtonElement> & {
3
3
  readonly color?: 'primary' | 'secondary' | 'default' | string;
4
- readonly variant?: 'standard' | 'outlined';
4
+ readonly variant?: 'standard' | 'outlined' | 'soft';
5
5
  };
6
- declare const _default: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<HTMLButtonElement>, "children"> & {
6
+ declare const _default: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLButtonElement> & {
7
7
  readonly color?: "primary" | "secondary" | "default" | string;
8
- readonly variant?: "standard" | "outlined";
8
+ readonly variant?: "standard" | "outlined" | "soft";
9
9
  } & React.RefAttributes<HTMLButtonElement>>;
10
10
  export default _default;
@@ -19,6 +19,7 @@ const styled_1 = __importDefault(require("@emotion/styled"));
19
19
  const react_2 = require("@emotion/react");
20
20
  const ButtonBase_1 = __importDefault(require("../Button/ButtonBase"));
21
21
  const Color_1 = __importDefault(require("../Color"));
22
+ const BadgeDeleteIcon_1 = __importDefault(require("./BadgeDeleteIcon"));
22
23
  const StyledButton = (0, styled_1.default)(ButtonBase_1.default) `
23
24
  display: flex;
24
25
  padding: 0.3em;
@@ -32,7 +33,9 @@ const StyledButton = (0, styled_1.default)(ButtonBase_1.default) `
32
33
  position: relative;
33
34
  `;
34
35
  const BadgeDeleteButton = (props, ref) => {
35
- const { color = 'default', variant = 'standard' } = props, nativeProps = __rest(props, ["color", "variant"]);
36
+ const { children, color = 'default', variant: badgeVariant = 'standard' } = props, nativeProps = __rest(props, ["children", "color", "variant"]);
37
+ // The pale soft badge has the colored icon, as the outlined one
38
+ const variant = badgeVariant === 'soft' ? 'outlined' : badgeVariant;
36
39
  const theme = (0, react_2.useTheme)();
37
40
  const { $color, $background } = react_1.default.useMemo(() => {
38
41
  switch (true) {
@@ -85,8 +88,6 @@ const BadgeDeleteButton = (props, ref) => {
85
88
  };
86
89
  }
87
90
  }, [color, variant, theme.color]);
88
- return (react_1.default.createElement(StyledButton, Object.assign({}, nativeProps, { "$color": $color, "$background": $background, ref: ref }),
89
- react_1.default.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", version: "1.1", width: "1em", height: "1em", viewBox: "0 0 512 512" },
90
- react_1.default.createElement("path", { d: "m256 0c-141.11 0-256 114.89-256 256s114.89 256 256 256 256-114.89 256-256-114.89-256-256-256zm0 39.385c119.81 0 216.62 96.805 216.62 216.62s-96.805 216.62-216.62 216.62-216.62-96.805-216.62-216.62 96.805-216.62 216.62-216.62zm-78.769 118.15a19.692 19.692 0 0 0-5.0961 0.67068 19.692 19.692 0 0 0-8.8293 5.0961 19.692 19.692 0 0 0 0 27.851l64.844 64.844-64.844 64.844a19.692 19.692 0 0 0 0 27.851 19.692 19.692 0 0 0 27.851 0l64.844-64.844 64.844 64.844a19.692 19.692 0 0 0 27.851 0 19.692 19.692 0 0 0 0-27.851l-64.844-64.844 64.844-64.844a19.692 19.692 0 0 0 0-27.851 19.692 19.692 0 0 0-27.851 0l-64.844 64.844-64.844-64.844a19.692 19.692 0 0 0-13.925-5.7669z", fill: "currentColor" }))));
91
+ return (react_1.default.createElement(StyledButton, Object.assign({}, nativeProps, { "$color": $color, "$background": $background, ref: ref }), typeof children === 'undefined' ? react_1.default.createElement(BadgeDeleteIcon_1.default, null) : children));
91
92
  };
92
93
  exports.default = react_1.default.forwardRef(BadgeDeleteButton);
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export type BadgeDeleteIconProps = React.SVGProps<SVGSVGElement>;
3
+ declare const _default: React.ForwardRefExoticComponent<Omit<BadgeDeleteIconProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
4
+ export default _default;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = __importDefault(require("react"));
7
+ const BadgeDeleteIcon = (props, ref) => (react_1.default.createElement("svg", Object.assign({ xmlns: "http://www.w3.org/2000/svg", version: "1.1", width: "1em", height: "1em", viewBox: "0 0 512 512", "aria-hidden": true, focusable: "false" }, props, { ref: ref }),
8
+ react_1.default.createElement("path", { d: "m256 0c-141.11 0-256 114.89-256 256s114.89 256 256 256 256-114.89 256-256-114.89-256-256-256zm0 39.385c119.81 0 216.62 96.805 216.62 216.62s-96.805 216.62-216.62 216.62-216.62-96.805-216.62-216.62 96.805-216.62 216.62-216.62zm-78.769 118.15a19.692 19.692 0 0 0-5.0961 0.67068 19.692 19.692 0 0 0-8.8293 5.0961 19.692 19.692 0 0 0 0 27.851l64.844 64.844-64.844 64.844a19.692 19.692 0 0 0 0 27.851 19.692 19.692 0 0 0 27.851 0l64.844-64.844 64.844 64.844a19.692 19.692 0 0 0 27.851 0 19.692 19.692 0 0 0 0-27.851l-64.844-64.844 64.844-64.844a19.692 19.692 0 0 0 0-27.851 19.692 19.692 0 0 0-27.851 0l-64.844 64.844-64.844-64.844a19.692 19.692 0 0 0-13.925-5.7669z", fill: "currentColor" })));
9
+ exports.default = react_1.default.forwardRef(BadgeDeleteIcon);
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
- const BadgeStyled_1 = __importDefault(require("./BadgeStyled"));
7
+ const index_1 = __importDefault(require("./index"));
8
8
  /**
9
9
  * The badge with the `outlined` variant. Prefer `<Badge variant="outlined">`
10
10
  */
11
- const BadgeOutlined = (props, ref) => react_1.default.createElement(BadgeStyled_1.default, Object.assign({}, props, { variant: "outlined", ref: ref }));
11
+ const BadgeOutlined = (props, ref) => react_1.default.createElement(index_1.default, Object.assign({}, props, { variant: "outlined", ref: ref }));
12
12
  exports.default = react_1.default.forwardRef(BadgeOutlined);
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const react_1 = __importDefault(require("react"));
7
- const BadgeStyled_1 = __importDefault(require("./BadgeStyled"));
7
+ const index_1 = __importDefault(require("./index"));
8
8
  /**
9
9
  * The badge with the `standard` variant. Prefer `<Badge variant="standard">`
10
10
  */
11
- const BadgeStandard = (props, ref) => react_1.default.createElement(BadgeStyled_1.default, Object.assign({}, props, { variant: "standard", ref: ref }));
11
+ const BadgeStandard = (props, ref) => react_1.default.createElement(index_1.default, Object.assign({}, props, { variant: "standard", ref: ref }));
12
12
  exports.default = react_1.default.forwardRef(BadgeStandard);
@@ -1,5 +1,2 @@
1
- import React from 'react';
2
- import { BadgeBaseProps } from './BadgeBase';
3
- export type BadgeStyledProps = BadgeBaseProps;
4
- declare const _default: React.ForwardRefExoticComponent<BadgeBaseProps & React.RefAttributes<HTMLSpanElement>>;
5
- export default _default;
1
+ export { default } from './index';
2
+ export type { BadgeProps as BadgeStyledProps } from './index';
@@ -1,168 +1,9 @@
1
1
  "use strict";
2
- var __rest = (this && this.__rest) || function (s, e) {
3
- var t = {};
4
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
- t[p] = s[p];
6
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
- t[p[i]] = s[p[i]];
10
- }
11
- return t;
12
- };
13
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
14
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
4
  };
16
5
  Object.defineProperty(exports, "__esModule", { value: true });
17
- const react_1 = __importDefault(require("react"));
18
- const styled_1 = __importDefault(require("@emotion/styled"));
19
- const react_2 = require("@emotion/react");
20
- const Color_1 = __importDefault(require("../Color"));
21
- const BadgeBase_1 = __importDefault(require("./BadgeBase"));
22
- const tokens_1 = require("../ThemeProvider/tokens");
23
- const parseColor = (color, fallback) => {
24
- try {
25
- return Color_1.default.fromString(color);
26
- }
27
- catch (err) {
28
- console.error(`invalid color value «${color}»`);
29
- return fallback;
30
- }
31
- };
32
- const getStandardColors = (color, theme) => {
33
- switch (true) {
34
- case color === 'primary':
35
- return { $color: theme.color.accentPrimaryContrast, $background: theme.color.accentPrimary };
36
- case color === 'secondary':
37
- return {
38
- $color: theme.color.accentSecondaryContrast,
39
- $background: theme.color.accentSecondary,
40
- };
41
- case typeof color === 'undefined':
42
- case color === 'default':
43
- return { $background: theme.color.surface.darken(10), $color: theme.color.textPrimary };
44
- default: {
45
- const $background = parseColor(String(color), theme.color.surface);
46
- return {
47
- $background,
48
- $color: $background.getContrast(theme.color.textPrimary) > 5
49
- ? theme.color.textPrimary
50
- : theme.color.surface,
51
- };
52
- }
53
- }
54
- };
55
- const getOutlinedColors = (color, theme) => {
56
- switch (true) {
57
- case color === 'primary':
58
- return { $color: theme.color.accentPrimary, $background: theme.color.accentPrimary };
59
- case color === 'secondary':
60
- return { $color: theme.color.accentSecondary, $background: theme.color.accentSecondary };
61
- case typeof color === 'undefined':
62
- case color === 'default':
63
- return {
64
- $color: Color_1.default.fromString(theme.color.textPrimary.toString()),
65
- $background: theme.color.textPrimary.lighten(100),
66
- };
67
- default: {
68
- const c = parseColor(String(color), theme.color.textPrimary);
69
- return { $color: c, $background: c };
70
- }
71
- }
72
- };
73
- /**
74
- * The pale background of the color and the text of the same hue: dark on the light theme,
75
- * light on the dark one. `$background` is the color itself
76
- */
77
- const getSoftColors = (color, theme) => {
78
- const base = color === 'primary'
79
- ? theme.color.accentPrimary
80
- : color === 'secondary'
81
- ? theme.color.accentSecondary
82
- : typeof color === 'undefined' || color === 'default'
83
- ? theme.color.textPrimary
84
- : parseColor(String(color), theme.color.textPrimary);
85
- return {
86
- $background: base,
87
- $color: theme.isDark ? base.lighten(60) : base.darken(60),
88
- };
89
- };
90
- /**
91
- * Both variants are one styled component: switching the variant (e.g. a toggling filter badge)
92
- * must not remount the element, otherwise the focused badge loses the focus
93
- */
94
- const StyledBadge = (0, styled_1.default)(BadgeBase_1.default) `
95
- border-style: solid;
96
- border-width: ${tokens_1.BORDER_WIDTH};
97
- border-color: ${({ $background }) => $background.toString()};
98
- --badge-dot-color: ${({ $variant, $background, $color }) => ($variant === 'standard' ? $color : $background).toString()};
99
-
100
- ${({ $variant, $color, $background }) => $variant === 'soft' &&
101
- (0, react_2.css) `
102
- color: ${$color.toString()};
103
- background-color: ${$background.alpha(0.18).toString()};
104
- border-color: transparent;
105
-
106
- &:focus-visible {
107
- outline-style: solid;
108
- outline-width: 0.14em;
109
- outline-color: ${$background.alpha(0.6).toString()};
110
- }
111
- `}
112
-
113
- ${({ $variant, $color, $background, theme }) => $variant === 'soft'
114
- ? ''
115
- : $variant === 'outlined'
116
- ? (0, react_2.css) `
117
- color: ${$color.darken(30).toString()};
118
- background-color: transparent;
119
-
120
- &:focus-visible {
121
- outline-style: solid;
122
- outline-width: 0.14em;
123
- outline-color: ${$background.rgbString()};
124
- }
125
- `
126
- : (0, react_2.css) `
127
- color: ${$color.toString()};
128
- background-color: ${$background.toString()};
129
-
130
- &:focus-visible {
131
- outline-color: ${$background.rgbString() === theme.color.accentPrimary.rgbString()
132
- ? theme.color.textPrimary.toString()
133
- : theme.color.accentPrimary.toString()};
134
- }
135
- `}
136
-
137
- ${({ $clickable, $variant, $background }) => $clickable &&
138
- (0, react_2.css) `
139
- cursor: pointer;
140
-
141
- &:hover {
142
- ${$variant === 'soft'
143
- ? (0, react_2.css) `
144
- background-color: ${$background.alpha(0.3).toString()};
145
- `
146
- : $variant === 'outlined'
147
- ? (0, react_2.css) `
148
- background-color: ${$background.darken(20).alpha(0.1).toString()};
149
- `
150
- : (0, react_2.css) `
151
- background-color: ${$background.darken(30).toString()};
152
- border-color: ${$background.darken(30).toString()};
153
- `}
154
- }
155
- `}
156
- ${({ theme }) => (0, tokens_1.themeFocusRing)(theme)}
157
- `;
158
- const BadgeStyled = (props, ref) => {
159
- const { children, color, variant = 'standard', onClick } = props, restProps = __rest(props, ["children", "color", "variant", "onClick"]);
160
- const theme = (0, react_2.useTheme)();
161
- const { $background, $color } = react_1.default.useMemo(() => variant === 'soft'
162
- ? getSoftColors(color, theme)
163
- : variant === 'outlined'
164
- ? getOutlinedColors(color, theme)
165
- : getStandardColors(color, theme), [color, variant, theme]);
166
- return (react_1.default.createElement(StyledBadge, Object.assign({ "$variant": variant, "$clickable": typeof onClick === 'function', "$color": $color, "$background": $background, color: color, variant: variant, onClick: onClick }, restProps, { ref: ref }), children));
167
- };
168
- exports.default = react_1.default.forwardRef(BadgeStyled);
6
+ exports.default = void 0;
7
+ // Preserve the old import path without adding a wrapper around Badge
8
+ var index_1 = require("./index");
9
+ Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(index_1).default; } });
package/Badge/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
- import type { BadgeStandardProps } from './BadgeStandard';
3
- import type { BadgeOutlinedProps } from './BadgeOutlined';
4
- export type BadgeProps = (BadgeStandardProps | BadgeOutlinedProps) & {
2
+ import { BadgeBaseProps } from './BadgeBase';
3
+ export type BadgeProps = BadgeBaseProps & {
5
4
  /**
6
5
  * Badge style variant\
7
6
  * Allowed variants: `standard`, `outlined` or `soft` (the pale background of the color)\
@@ -10,7 +9,7 @@ export type BadgeProps = (BadgeStandardProps | BadgeOutlinedProps) & {
10
9
  */
11
10
  readonly variant?: 'standard' | 'outlined' | 'soft';
12
11
  };
13
- declare const _default: React.ForwardRefExoticComponent<import("./BadgeBase").BadgeBaseProps & {
12
+ declare const _default: React.ForwardRefExoticComponent<BadgeBaseProps & {
14
13
  /**
15
14
  * Badge style variant\
16
15
  * Allowed variants: `standard`, `outlined` or `soft` (the pale background of the color)\
package/Badge/index.js CHANGED
@@ -1,10 +1,24 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
15
  };
5
16
  Object.defineProperty(exports, "__esModule", { value: true });
6
17
  const react_1 = __importDefault(require("react"));
7
- const BadgeStyled_1 = __importDefault(require("./BadgeStyled"));
8
- // One component for both variants, so changing the variant does not remount the badge
9
- const Badge = (props, ref) => (react_1.default.createElement(BadgeStyled_1.default, Object.assign({}, props, { ref: ref })));
18
+ const BadgeBase_1 = __importDefault(require("./BadgeBase"));
19
+ // One component for all variants, so changing the variant does not remount the badge
20
+ const Badge = (_a, ref) => {
21
+ var { variant = 'standard' } = _a, props = __rest(_a, ["variant"]);
22
+ return react_1.default.createElement(BadgeBase_1.default, Object.assign({}, props, { variant: variant, ref: ref }));
23
+ };
10
24
  exports.default = react_1.default.forwardRef(Badge);
package/CHANGELOG.md CHANGED
@@ -4,6 +4,29 @@
4
4
 
5
5
  ## Не выпущено
6
6
 
7
+ ## 0.12.0 — 2026-11-05
8
+
9
+ ### Добавлено
10
+
11
+ - **Tooltip**: свойство `interactive` — указатель можно перевести на подсказку, чтобы выделить текст или нажать ссылку внутри. Без него подсказка не перехватывает указатель.
12
+
13
+ ### Изменено
14
+
15
+ - **Tooltip**: по умолчанию подсказка не получает события указателя. Раньше указатель, попавший на подсказку, удерживал её открытой: в плотном списке подсказка нижней кнопки перекрывала кнопку выше, и навести на неё было нельзя. Если подсказку нужно выделять или нажимать в ней, передайте `interactive`;
16
+ - **Popper**: явный `pointerEvents` в `style` больше не затирается — скрытый поппер по-прежнему не перехватывает указатель.
17
+
18
+ ## 0.11.0 — 2026-11-05
19
+
20
+ ### Добавлено
21
+
22
+ - **Toast**: `autoClose` у `ToastContainer` принимает время закрытия для каждого типа уведомления — `{ success: 2000, error: false }`. Тип, которого нет в объекте, берёт `default` (если задан), затем 5000 мс; собственный `autoClose` уведомления по-прежнему важнее;
23
+ - **Badge**: часть `DeleteIcon` (`Badge/BadgeDeleteIcon`) — замена иконки удаления отдельно от кнопки. `BadgeDeleteButton` принимает свою иконку через `children`.
24
+
25
+ ### Изменено
26
+
27
+ - **Badge**: логика `BadgeStyled` объединена с основным компонентом в `Badge/index`. Старый путь `Badge/BadgeStyled` сохранён как реэкспорт без дополнительной обёртки.
28
+ - **Badge**: стили вариантов, расчёт цветов и состояния наведения и фокуса перенесены в `BadgeContainer`. `overrides.Container` получает `variant`, а `styled(BadgeContainer)` перекрывает оформление без повышения специфичности. Внешний вид и поведение по умолчанию сохранены. Переопределение `ButtonDelete` теперь получает исходный `variant="soft"`, а не `outlined`; если оно разбирает варианты самостоятельно, добавьте обработку `soft`. Стандартный `BadgeDeleteButton` оформляет `soft` как прежде.
29
+
7
30
  ## 0.10.1 — 2026-10-23
8
31
 
9
32
  ### Исправлено