@gobolt/genesis 0.2.19 → 0.2.20

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  var _commonjsHelpers = require("./_commonjsHelpers.cjs");
3
- var index = require("../node_modules/copy-to-clipboard/index.cjs");
4
- var copyToClipboardExports = index.__require();
5
- var copy = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(copyToClipboardExports);
6
- module.exports = copy;
3
+ var index = require("../node_modules/debounce/index.cjs");
4
+ var debounceExports = /* @__PURE__ */ index.__require();
5
+ var debounce = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(debounceExports);
6
+ module.exports = debounce;
@@ -1,7 +1,7 @@
1
1
  import { getDefaultExportFromCjs } from "./_commonjsHelpers.js";
2
- import { __require as requireCopyToClipboard } from "../node_modules/copy-to-clipboard/index.js";
3
- var copyToClipboardExports = requireCopyToClipboard();
4
- var copy = /* @__PURE__ */ getDefaultExportFromCjs(copyToClipboardExports);
2
+ import { __require as requireDebounce } from "../node_modules/debounce/index.js";
3
+ var debounceExports = /* @__PURE__ */ requireDebounce();
4
+ var debounce = /* @__PURE__ */ getDefaultExportFromCjs(debounceExports);
5
5
  export {
6
- copy as default
6
+ debounce as default
7
7
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  var _commonjsHelpers = require("./_commonjsHelpers.cjs");
3
- var index = require("../node_modules/debounce/index.cjs");
4
- var debounceExports = /* @__PURE__ */ index.__require();
5
- var debounce = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(debounceExports);
6
- module.exports = debounce;
3
+ var index = require("../node_modules/copy-to-clipboard/index.cjs");
4
+ var copyToClipboardExports = index.__require();
5
+ var copy = /* @__PURE__ */ _commonjsHelpers.getDefaultExportFromCjs(copyToClipboardExports);
6
+ module.exports = copy;
@@ -1,7 +1,7 @@
1
1
  import { getDefaultExportFromCjs } from "./_commonjsHelpers.js";
2
- import { __require as requireDebounce } from "../node_modules/debounce/index.js";
3
- var debounceExports = /* @__PURE__ */ requireDebounce();
4
- var debounce = /* @__PURE__ */ getDefaultExportFromCjs(debounceExports);
2
+ import { __require as requireCopyToClipboard } from "../node_modules/copy-to-clipboard/index.js";
3
+ var copyToClipboardExports = requireCopyToClipboard();
4
+ var copy = /* @__PURE__ */ getDefaultExportFromCjs(copyToClipboardExports);
5
5
  export {
6
- debounce as default
6
+ copy as default
7
7
  };
@@ -11,8 +11,14 @@ const Badge = ({
11
11
  state = "info",
12
12
  isDisabled,
13
13
  hasClose = false,
14
- onClick,
14
+ onClick = () => {
15
+ },
15
16
  size = "normal",
17
+ hasIcon = true,
18
+ customIcon = null,
19
+ backgroundColor = null,
20
+ textColor = null,
21
+ hasHover = true,
16
22
  ...rest
17
23
  }) => {
18
24
  const { theme } = useGenesis.useGenesis();
@@ -28,6 +34,7 @@ const Badge = ({
28
34
  style: {
29
35
  padding: "4px 4px"
30
36
  },
37
+ hasHover,
31
38
  ...rest,
32
39
  children: /* @__PURE__ */ jsxRuntime.jsx(
33
40
  "div",
@@ -39,8 +46,10 @@ const Badge = ({
39
46
  },
40
47
  children: iconUtil.getBadgeStateIcon(
41
48
  state,
42
- theme.colors.status[state].onsurface,
43
- isBadgeIconFilled
49
+ backgroundColor || theme.colors.status[state].onsurface,
50
+ isBadgeIconFilled,
51
+ hasIcon,
52
+ customIcon
44
53
  )
45
54
  }
46
55
  )
@@ -56,18 +65,22 @@ const Badge = ({
56
65
  state,
57
66
  disabled: isDisabled,
58
67
  style: { cursor: role === "button" ? "pointer" : "default" },
68
+ backgroundColor,
69
+ hasHover,
59
70
  ...rest,
60
71
  children: [
61
72
  iconUtil.getBadgeStateIcon(
62
73
  state,
63
- theme.colors.status[state].onsurface,
64
- isBadgeIconFilled
74
+ backgroundColor || theme.colors.status[state].onsurface,
75
+ isBadgeIconFilled,
76
+ hasIcon,
77
+ customIcon
65
78
  ),
66
79
  /* @__PURE__ */ jsxRuntime.jsx(
67
80
  Typography,
68
81
  {
69
82
  variant: size === "small" ? "label3" : "label2",
70
- color: isDisabled ? theme.colors.status.disabled.default : theme.colors.status[state].onsurface,
83
+ color: isDisabled ? theme.colors.status.disabled.default : textColor || theme.colors.status[state].onsurface,
71
84
  isDisabled,
72
85
  children: label
73
86
  }
@@ -4,8 +4,13 @@ export interface BadgeProps {
4
4
  isDisabled?: boolean;
5
5
  state?: State;
6
6
  hasClose?: boolean;
7
+ hasIcon?: boolean;
8
+ customIcon?: React.ReactNode | null;
7
9
  size?: "small" | "normal" | "large";
8
- onClick?: () => void;
10
+ backgroundColor?: string;
11
+ textColor?: string;
12
+ onClick?: () => void | null;
13
+ hasHover?: boolean;
9
14
  }
10
- declare const Badge: ({ label, state, isDisabled, hasClose, onClick, size, ...rest }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
15
+ declare const Badge: ({ label, state, isDisabled, hasClose, onClick, size, hasIcon, customIcon, backgroundColor, textColor, hasHover, ...rest }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
11
16
  export default Badge;
@@ -10,8 +10,14 @@ const Badge = ({
10
10
  state = "info",
11
11
  isDisabled,
12
12
  hasClose = false,
13
- onClick,
13
+ onClick = () => {
14
+ },
14
15
  size = "normal",
16
+ hasIcon = true,
17
+ customIcon = null,
18
+ backgroundColor = null,
19
+ textColor = null,
20
+ hasHover = true,
15
21
  ...rest
16
22
  }) => {
17
23
  const { theme } = useGenesis();
@@ -27,6 +33,7 @@ const Badge = ({
27
33
  style: {
28
34
  padding: "4px 4px"
29
35
  },
36
+ hasHover,
30
37
  ...rest,
31
38
  children: /* @__PURE__ */ jsx(
32
39
  "div",
@@ -38,8 +45,10 @@ const Badge = ({
38
45
  },
39
46
  children: getBadgeStateIcon(
40
47
  state,
41
- theme.colors.status[state].onsurface,
42
- isBadgeIconFilled
48
+ backgroundColor || theme.colors.status[state].onsurface,
49
+ isBadgeIconFilled,
50
+ hasIcon,
51
+ customIcon
43
52
  )
44
53
  }
45
54
  )
@@ -55,18 +64,22 @@ const Badge = ({
55
64
  state,
56
65
  disabled: isDisabled,
57
66
  style: { cursor: role === "button" ? "pointer" : "default" },
67
+ backgroundColor,
68
+ hasHover,
58
69
  ...rest,
59
70
  children: [
60
71
  getBadgeStateIcon(
61
72
  state,
62
- theme.colors.status[state].onsurface,
63
- isBadgeIconFilled
73
+ backgroundColor || theme.colors.status[state].onsurface,
74
+ isBadgeIconFilled,
75
+ hasIcon,
76
+ customIcon
64
77
  ),
65
78
  /* @__PURE__ */ jsx(
66
79
  Typography,
67
80
  {
68
81
  variant: size === "small" ? "label3" : "label2",
69
- color: isDisabled ? theme.colors.status.disabled.default : theme.colors.status[state].onsurface,
82
+ color: isDisabled ? theme.colors.status.disabled.default : textColor || theme.colors.status[state].onsurface,
70
83
  isDisabled,
71
84
  children: label
72
85
  }
@@ -12,3 +12,5 @@ export declare const Hollow: Story;
12
12
  export declare const Disabled: Story;
13
13
  export declare const Icon: Story;
14
14
  export declare const WithClose: Story;
15
+ export declare const NoIconNoCloseNoHover: Story;
16
+ export declare const Custom: Story;
@@ -6,7 +6,7 @@ const getBorderColor = (theme, state) => {
6
6
  }
7
7
  return theme.colors.status[state].surface;
8
8
  };
9
- const getGenesisClass = (theme, state, label, disabled) => `
9
+ const getGenesisClass = (theme, state, label, disabled, backgroundColor, textColor, hasHover) => `
10
10
  display: flex;
11
11
  gap: 4px;
12
12
  justify-content: center;
@@ -18,10 +18,10 @@ const getGenesisClass = (theme, state, label, disabled) => `
18
18
  padding-right: ${theme.components.badge["right-padding"]}px;
19
19
  border-radius: ${theme.components.badge.radius}px;
20
20
  border: 1px solid ${getBorderColor(theme, state)};
21
- background-color: ${theme.colors.status[state].surface};
21
+ background-color: ${backgroundColor || theme.colors.status[state].surface};
22
22
 
23
23
  &:not(:disabled):hover {
24
- background-color: ${theme.colors.status[state]["surface-hover"]};
24
+ ${hasHover ? `background-color: ${theme.colors.status[state]["surface-hover"]};` : ""}
25
25
  }
26
26
 
27
27
  ${disabled ? `
@@ -36,8 +36,24 @@ const getGenesisClass = (theme, state, label, disabled) => `
36
36
  ` : ""}
37
37
  `;
38
38
  const Badge = styled.div`
39
- ${({ theme, state, label, disabled }) => {
40
- return getGenesisClass(theme, state, label, disabled);
39
+ ${({
40
+ theme,
41
+ state,
42
+ label,
43
+ disabled,
44
+ backgroundColor,
45
+ textColor,
46
+ hasHover
47
+ }) => {
48
+ return getGenesisClass(
49
+ theme,
50
+ state,
51
+ label,
52
+ disabled,
53
+ backgroundColor,
54
+ textColor,
55
+ hasHover
56
+ );
41
57
  }}
42
58
  `;
43
59
  exports.Badge = Badge;
@@ -5,7 +5,10 @@ interface StyledBadgeProps {
5
5
  state?: State;
6
6
  label?: string;
7
7
  disabled?: boolean;
8
+ backgroundColor?: string;
9
+ textColor?: string;
10
+ hasHover?: boolean;
8
11
  }
9
- export declare const getGenesisClass: (theme: GenesisTheme, state: State, label?: string, disabled?: boolean) => string;
12
+ export declare const getGenesisClass: (theme: GenesisTheme, state: State, label?: string, disabled?: boolean, backgroundColor?: string, textColor?: string, hasHover?: boolean) => string;
10
13
  export declare const Badge: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components/dist/types').Substitute<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, StyledBadgeProps>> & string;
11
14
  export {};
@@ -5,7 +5,7 @@ const getBorderColor = (theme, state) => {
5
5
  }
6
6
  return theme.colors.status[state].surface;
7
7
  };
8
- const getGenesisClass = (theme, state, label, disabled) => `
8
+ const getGenesisClass = (theme, state, label, disabled, backgroundColor, textColor, hasHover) => `
9
9
  display: flex;
10
10
  gap: 4px;
11
11
  justify-content: center;
@@ -17,10 +17,10 @@ const getGenesisClass = (theme, state, label, disabled) => `
17
17
  padding-right: ${theme.components.badge["right-padding"]}px;
18
18
  border-radius: ${theme.components.badge.radius}px;
19
19
  border: 1px solid ${getBorderColor(theme, state)};
20
- background-color: ${theme.colors.status[state].surface};
20
+ background-color: ${backgroundColor || theme.colors.status[state].surface};
21
21
 
22
22
  &:not(:disabled):hover {
23
- background-color: ${theme.colors.status[state]["surface-hover"]};
23
+ ${hasHover ? `background-color: ${theme.colors.status[state]["surface-hover"]};` : ""}
24
24
  }
25
25
 
26
26
  ${disabled ? `
@@ -35,8 +35,24 @@ const getGenesisClass = (theme, state, label, disabled) => `
35
35
  ` : ""}
36
36
  `;
37
37
  const Badge = styled.div`
38
- ${({ theme, state, label, disabled }) => {
39
- return getGenesisClass(theme, state, label, disabled);
38
+ ${({
39
+ theme,
40
+ state,
41
+ label,
42
+ disabled,
43
+ backgroundColor,
44
+ textColor,
45
+ hasHover
46
+ }) => {
47
+ return getGenesisClass(
48
+ theme,
49
+ state,
50
+ label,
51
+ disabled,
52
+ backgroundColor,
53
+ textColor,
54
+ hasHover
55
+ );
40
56
  }}
41
57
  `;
42
58
  export {
@@ -3,7 +3,7 @@ var jsxRuntime = require("react/jsx-runtime");
3
3
  var index$1 = require("../../../node_modules/react-icons/hi2/index.cjs");
4
4
  var index = require("../../../node_modules/react-icons/hi/index.cjs");
5
5
  var index$2 = require("../../../node_modules/react-icons/fi/index.cjs");
6
- var index$3 = require("../../../_virtual/index6.cjs");
6
+ var index$3 = require("../../../_virtual/index5.cjs");
7
7
  var Input = require("../../Input/Input.cjs");
8
8
  var UtilityButton = require("../../Button/UtilityButton.cjs");
9
9
  var Typography = require("../../Typography/Typography.cjs");
@@ -2,7 +2,7 @@ import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { HiMiniAdjustmentsVertical } from "../../../node_modules/react-icons/hi2/index.js";
3
3
  import { HiSearch, HiOutlineSortDescending, HiOutlineSortAscending } from "../../../node_modules/react-icons/hi/index.js";
4
4
  import { FiSettings } from "../../../node_modules/react-icons/fi/index.js";
5
- import debounce from "../../../_virtual/index6.js";
5
+ import debounce from "../../../_virtual/index5.js";
6
6
  import Input from "../../Input/Input.js";
7
7
  import UtilityButton from "../../Button/UtilityButton.js";
8
8
  import Typography from "../../Typography/Typography.js";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  var React = require("react");
3
- var index = require("../../../../../_virtual/index5.cjs");
3
+ var index = require("../../../../../_virtual/index6.cjs");
4
4
  var useEvent = require("../../../../rc-util/es/hooks/useEvent.cjs");
5
5
  var toList = require("../../_util/toList.cjs");
6
6
  function _interopNamespaceDefault(e) {
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import copy from "../../../../../_virtual/index5.js";
2
+ import copy from "../../../../../_virtual/index6.js";
3
3
  import useEvent from "../../../../rc-util/es/hooks/useEvent.js";
4
4
  import toList from "../../_util/toList.js";
5
5
  var __awaiter = function(thisArg, _arguments, P, generator) {
@@ -44,10 +44,13 @@ const getIconColor = (state, theme) => {
44
44
  return theme.colors.status.info.onsurface;
45
45
  }
46
46
  };
47
- const getBadgeStateIcon = (state, color, isFilled = true) => {
48
- if (!state) {
47
+ const getBadgeStateIcon = (state, color, isFilled = true, hasIcon = true, customIcon = null) => {
48
+ if (!state || !hasIcon) {
49
49
  return null;
50
50
  }
51
+ if (customIcon) {
52
+ return customIcon;
53
+ }
51
54
  if (!isFilled) {
52
55
  switch (state) {
53
56
  // isFilled is false
@@ -1,3 +1,3 @@
1
1
  export declare const getIcon: (name: string) => import("react/jsx-runtime").JSX.Element;
2
2
  export declare const getIconColor: (state: any, theme: any) => any;
3
- export declare const getBadgeStateIcon: (state: any, color: any, isFilled?: boolean) => import("react/jsx-runtime").JSX.Element;
3
+ export declare const getBadgeStateIcon: (state: any, color: any, isFilled?: boolean, hasIcon?: boolean, customIcon?: any) => any;
@@ -43,10 +43,13 @@ const getIconColor = (state, theme) => {
43
43
  return theme.colors.status.info.onsurface;
44
44
  }
45
45
  };
46
- const getBadgeStateIcon = (state, color, isFilled = true) => {
47
- if (!state) {
46
+ const getBadgeStateIcon = (state, color, isFilled = true, hasIcon = true, customIcon = null) => {
47
+ if (!state || !hasIcon) {
48
48
  return null;
49
49
  }
50
+ if (customIcon) {
51
+ return customIcon;
52
+ }
50
53
  if (!isFilled) {
51
54
  switch (state) {
52
55
  // isFilled is false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gobolt/genesis",
3
- "version": "0.2.19",
3
+ "version": "0.2.20",
4
4
  "description": "genesis design system",
5
5
  "author": "gobolt",
6
6
  "license": "MIT",