@via-profit/ui-kit 0.1.0-rc.45 → 0.1.0-rc.47

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.
@@ -21,33 +21,45 @@ const Color_1 = __importDefault(require("../Color"));
21
21
  const BadgeBase_1 = __importDefault(require("./BadgeBase"));
22
22
  const StyledOutlinedBadge = (0, styled_1.default)(BadgeBase_1.default) `
23
23
  color: ${({ $color }) => $color.darken(30).toString()};
24
- border-color: ${({ $color }) => $color.toString()};
24
+ border-color: ${({ $background }) => $background.toString()};
25
25
  background-color: transparent;
26
26
  border-style: solid;
27
27
  border-width: 0.14em;
28
28
  &:hover {
29
- background-color: ${({ $color }) => $color.darken(20).alpha(0.1).toString()};
29
+ background-color: ${({ $background }) => $background.darken(20).alpha(0.1).toString()};
30
30
  }
31
31
  &:focus-visible {
32
32
  outline-style: solid;
33
33
  outline-width: 0.14em;
34
- outline-color: ${({ $color, theme }) => $color.rgbString() === theme.color.accentPrimary.rgbString()
35
- ? theme.color.textPrimary.toString()
36
- : theme.color.accentPrimary.toString()};
34
+ outline-color: ${({ $background }) => $background.rgbString()};
37
35
  }
36
+ ${({ $clickable }) => $clickable &&
37
+ (0, react_2.css) `
38
+ cursor: pointer;
39
+ `}
38
40
  `;
39
41
  const BadgeOutlined = (props, ref) => {
40
- const { children, color } = props, restProps = __rest(props, ["children", "color"]);
42
+ const { children, color, onClick } = props, restProps = __rest(props, ["children", "color", "onClick"]);
41
43
  const theme = (0, react_2.useTheme)();
42
- const $color = react_1.default.useMemo(() => {
44
+ const clickable = react_1.default.useMemo(() => typeof onClick === 'function', [onClick]);
45
+ const { $background, $color } = react_1.default.useMemo(() => {
43
46
  switch (true) {
44
47
  case color === 'primary':
45
- return theme.color.accentPrimary;
48
+ return {
49
+ $color: theme.color.accentPrimary,
50
+ $background: theme.color.accentPrimary,
51
+ };
46
52
  case color === 'secondary':
47
- return theme.color.accentSecondary;
53
+ return {
54
+ $color: theme.color.accentSecondary,
55
+ $background: theme.color.accentSecondary,
56
+ };
48
57
  case typeof color === 'undefined':
49
58
  case color === 'default':
50
- return theme.color.textPrimary.lighten(30);
59
+ return {
60
+ $color: new Color_1.default(theme.color.textPrimary),
61
+ $background: theme.color.textPrimary.lighten(100),
62
+ };
51
63
  case typeof color === 'string': {
52
64
  let c = theme.color.textPrimary;
53
65
  try {
@@ -58,12 +70,18 @@ const BadgeOutlined = (props, ref) => {
58
70
  catch (err) {
59
71
  console.error(`invalid color value «${color}»`);
60
72
  }
61
- return c;
73
+ return {
74
+ $color: c,
75
+ $background: c,
76
+ };
62
77
  }
63
78
  default:
64
- return theme.color.textPrimary;
79
+ return {
80
+ $color: theme.color.textPrimary,
81
+ $background: theme.color.textPrimary,
82
+ };
65
83
  }
66
84
  }, [color, theme.color]);
67
- return (react_1.default.createElement(StyledOutlinedBadge, Object.assign({ "$color": $color, color: color, variant: "outlined" }, restProps, { ref: ref }), children));
85
+ return (react_1.default.createElement(StyledOutlinedBadge, Object.assign({ "$color": $color, "$background": $background, "$clickable": clickable, color: color, variant: "outlined" }, restProps, { tabIndex: clickable ? 0 : -1, ref: ref }), children));
68
86
  };
69
87
  exports.default = react_1.default.forwardRef(BadgeOutlined);
@@ -38,10 +38,15 @@ const StyledStandardBadge = (0, styled_1.default)(BadgeBase_1.default) `
38
38
  ? theme.color.textPrimary.toString()
39
39
  : theme.color.accentPrimary.toString()};
40
40
  }
41
+ ${({ $clickable }) => $clickable &&
42
+ (0, react_2.css) `
43
+ cursor: pointer;
44
+ `}
41
45
  `;
42
46
  const BadgeStandard = (props, ref) => {
43
- const { children, color } = props, restProps = __rest(props, ["children", "color"]);
47
+ const { children, color, onClick } = props, restProps = __rest(props, ["children", "color", "onClick"]);
44
48
  const theme = (0, react_2.useTheme)();
49
+ const clickable = react_1.default.useMemo(() => typeof onClick === 'function', [onClick]);
45
50
  const { $background, $color } = react_1.default.useMemo(() => {
46
51
  switch (true) {
47
52
  case color === 'primary':
@@ -84,6 +89,6 @@ const BadgeStandard = (props, ref) => {
84
89
  };
85
90
  }
86
91
  }, [color, theme.color]);
87
- return (react_1.default.createElement(StyledStandardBadge, Object.assign({ variant: "standard", "$color": $color, "$background": $background, color: color }, restProps, { ref: ref }), children));
92
+ return (react_1.default.createElement(StyledStandardBadge, Object.assign({ variant: "standard", "$clickable": clickable, "$color": $color, "$background": $background, color: color }, restProps, { tabIndex: clickable ? 0 : -1, ref: ref }), children));
88
93
  };
89
94
  exports.default = react_1.default.forwardRef(BadgeStandard);
@@ -81,7 +81,7 @@ const ModalWrapper = props => {
81
81
  }
82
82
  }, []);
83
83
  react_1.default.useEffect(() => {
84
- if (containerRef.current) {
84
+ if (isOpenProp && containerRef.current) {
85
85
  containerRef.current.focus();
86
86
  }
87
87
  const keydown = (event) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@via-profit/ui-kit",
3
- "version": "0.1.0-rc.45",
3
+ "version": "0.1.0-rc.47",
4
4
  "description": "UI Kit",
5
5
  "repository": {
6
6
  "type": "git",