@drivy/cobalt 2.7.0 → 2.8.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.
@@ -0,0 +1,22 @@
1
+ import React, { forwardRef } from 'react';
2
+ import '../../Icon/index.js';
3
+ import LoadingIcon from '../../Icon/__generated__/LoadingIcon.js';
4
+
5
+ const InnerButton = ({ children, loading, }) => (React.createElement(React.Fragment, null,
6
+ loading && React.createElement(LoadingIcon, { className: "cobalt-button__loading-icon" }),
7
+ children));
8
+ const ButtonBase = forwardRef((props, ref) => {
9
+ const { disabled, loading, children, ...restProps } = props;
10
+ return (React.createElement("button", { ref: ref, "aria-disabled": disabled || loading, "aria-busy": loading, disabled: disabled || loading, ...restProps },
11
+ React.createElement(InnerButton, { loading: loading }, children)));
12
+ });
13
+ ButtonBase.displayName = "ButtonBase";
14
+ const ButtonLinkBase = forwardRef((props, ref) => {
15
+ const { disabled, target, rel, loading, children, ...restProps } = props;
16
+ return (React.createElement("a", { ref: ref, "aria-disabled": disabled || loading, "aria-busy": loading, "data-disabled": disabled || loading, target: target, rel: target === "_blank" && !rel ? "noopener noreferrer" : rel, ...restProps },
17
+ React.createElement(InnerButton, { loading: loading }, children)));
18
+ });
19
+ ButtonLinkBase.displayName = "ButtonLinkBase";
20
+
21
+ export { ButtonBase, ButtonLinkBase };
22
+ //# sourceMappingURL=ButtonComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ButtonComponent.js","sources":["../../../../src/components/Buttons/Button/ButtonComponent.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\"\nimport { LoadingIcon } from \"../../Icon\"\nimport { ButtonComponentProps, ButtonLinkComponentProps } from \"./type\"\n\nconst InnerButton = ({\n children,\n loading,\n}: {\n children:\n | ButtonComponentProps[\"children\"]\n | ButtonLinkComponentProps[\"children\"]\n loading: ButtonComponentProps[\"loading\"] | ButtonLinkComponentProps[\"loading\"]\n}) => (\n <>\n {loading && <LoadingIcon className=\"cobalt-button__loading-icon\" />}\n {children}\n </>\n)\n\nexport const ButtonBase = forwardRef<HTMLButtonElement, ButtonComponentProps>(\n (props: ButtonComponentProps, ref) => {\n const { disabled, loading, children, ...restProps } = props\n return (\n <button\n ref={ref}\n aria-disabled={disabled || loading}\n aria-busy={loading}\n disabled={disabled || loading}\n {...restProps}\n >\n <InnerButton loading={loading}>{children}</InnerButton>\n </button>\n )\n }\n)\nButtonBase.displayName = \"ButtonBase\"\n\nexport const ButtonLinkBase = forwardRef<\n HTMLAnchorElement,\n ButtonLinkComponentProps\n>((props: ButtonLinkComponentProps, ref) => {\n const { disabled, target, rel, loading, children, ...restProps } = props\n return (\n <a\n ref={ref}\n aria-disabled={disabled || loading}\n aria-busy={loading}\n data-disabled={disabled || loading}\n target={target}\n rel={target === \"_blank\" && !rel ? \"noopener noreferrer\" : rel}\n {...restProps}\n >\n <InnerButton loading={loading}>{children}</InnerButton>\n </a>\n )\n})\nButtonLinkBase.displayName = \"ButtonLinkBase\"\n"],"names":[],"mappings":";;;;AAIA,MAAM,WAAW,GAAG,CAAC,EACnB,QAAQ,EACR,OAAO,GAMR,MACC,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA;AACG,IAAA,OAAO,IAAI,KAAC,CAAA,aAAA,CAAA,WAAW,IAAC,SAAS,EAAC,6BAA6B,EAAG,CAAA;IAClE,QAAQ,CACR,CACJ,CAAA;AAEY,MAAA,UAAU,GAAG,UAAU,CAClC,CAAC,KAA2B,EAAE,GAAG,KAAI;AACnC,IAAA,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAA;AAC3D,IAAA,QACE,KACE,CAAA,aAAA,CAAA,QAAA,EAAA,EAAA,GAAG,EAAE,GAAG,EAAA,eAAA,EACO,QAAQ,IAAI,OAAO,EACvB,WAAA,EAAA,OAAO,EAClB,QAAQ,EAAE,QAAQ,IAAI,OAAO,KACzB,SAAS,EAAA;QAEb,KAAC,CAAA,aAAA,CAAA,WAAW,EAAC,EAAA,OAAO,EAAE,OAAO,IAAG,QAAQ,CAAe,CAChD,EACV;AACH,CAAC,EACF;AACD,UAAU,CAAC,WAAW,GAAG,YAAY,CAAA;AAExB,MAAA,cAAc,GAAG,UAAU,CAGtC,CAAC,KAA+B,EAAE,GAAG,KAAI;AACzC,IAAA,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK,CAAA;AACxE,IAAA,QACE,KACE,CAAA,aAAA,CAAA,GAAA,EAAA,EAAA,GAAG,EAAE,GAAG,mBACO,QAAQ,IAAI,OAAO,EAAA,WAAA,EACvB,OAAO,EACH,eAAA,EAAA,QAAQ,IAAI,OAAO,EAClC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,KAAK,QAAQ,IAAI,CAAC,GAAG,GAAG,qBAAqB,GAAG,GAAG,KAC1D,SAAS,EAAA;QAEb,KAAC,CAAA,aAAA,CAAA,WAAW,EAAC,EAAA,OAAO,EAAE,OAAO,IAAG,QAAQ,CAAe,CACrD,EACL;AACH,CAAC,EAAC;AACF,cAAc,CAAC,WAAW,GAAG,gBAAgB;;;;"}
@@ -0,0 +1,49 @@
1
+ import React, { forwardRef } from 'react';
2
+ import cx from 'classnames';
3
+ import { isLinkProps } from './type.js';
4
+ import { ButtonLinkBase, ButtonBase } from './ButtonComponent.js';
5
+ import '../../Icon/index.js';
6
+ import ChevronRightIcon from '../../Icon/__generated__/ChevronRightIcon.js';
7
+
8
+ const getComputedClassName = ({ className, variant, size, destructive, primary, text, isIconOnly, fullWidth, }) => {
9
+ return cx(className, "cobalt-button", {
10
+ "cobalt-button--primary": primary,
11
+ "cobalt-button--destructive": destructive,
12
+ "cobalt-button--text": text,
13
+ "cobalt-button--icon-only": isIconOnly,
14
+ "cobalt-button--small": size === "small",
15
+ "cobalt-button--large": size === "large",
16
+ "cobalt-button--warning": variant === "warning",
17
+ "cobalt-button--secondary": variant === "secondary",
18
+ "cobalt-button--tertiary": variant === "tertiary",
19
+ "cobalt-button--business": variant === "business",
20
+ "cobalt-button--success": variant === "success",
21
+ "cobalt-button--neutral": variant === "neutral",
22
+ "c-w-full": fullWidth,
23
+ });
24
+ };
25
+ const Button = forwardRef((props, ref) => {
26
+ const { children, className, variant, size, destructive, primary, text, icon, fullWidth, ...restProps } = props;
27
+ const computedClassName = getComputedClassName({
28
+ className,
29
+ variant,
30
+ size,
31
+ destructive,
32
+ primary,
33
+ text,
34
+ fullWidth,
35
+ isIconOnly: !!icon && !children,
36
+ });
37
+ const content = (React.createElement(React.Fragment, null,
38
+ icon,
39
+ children && React.createElement("span", null, children),
40
+ text && children ? React.createElement(ChevronRightIcon, null) : null));
41
+ if (isLinkProps(restProps)) {
42
+ return (React.createElement(ButtonLinkBase, { ...restProps, className: computedClassName, ref: ref }, content));
43
+ }
44
+ return (React.createElement(ButtonBase, { ...restProps, className: computedClassName, ref: ref }, content));
45
+ });
46
+ Button.displayName = "Button";
47
+
48
+ export { Button as default };
49
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/Buttons/Button/index.tsx"],"sourcesContent":["import React, { forwardRef } from \"react\"\nimport cx from \"classnames\"\nimport {\n ButtonComponentProps,\n ButtonLinkComponentProps,\n ButtonProps,\n isLinkProps,\n} from \"./type\"\nimport { ButtonLinkBase, ButtonBase } from \"./ButtonComponent\"\nimport { ChevronRightIcon } from \"../../Icon\"\n\nconst getComputedClassName = ({\n className,\n variant,\n size,\n destructive,\n primary,\n text,\n isIconOnly,\n fullWidth,\n}: {\n className?: ButtonProps[\"className\"]\n variant?: ButtonProps[\"variant\"]\n size?: ButtonProps[\"size\"]\n destructive?: ButtonProps[\"destructive\"]\n primary?: ButtonProps[\"primary\"]\n text?: ButtonProps[\"text\"]\n isIconOnly?: boolean\n fullWidth?: ButtonProps[\"fullWidth\"]\n}) => {\n return cx(className, \"cobalt-button\", {\n \"cobalt-button--primary\": primary,\n \"cobalt-button--destructive\": destructive,\n \"cobalt-button--text\": text,\n \"cobalt-button--icon-only\": isIconOnly,\n \"cobalt-button--small\": size === \"small\",\n \"cobalt-button--large\": size === \"large\",\n \"cobalt-button--warning\": variant === \"warning\",\n \"cobalt-button--secondary\": variant === \"secondary\",\n \"cobalt-button--tertiary\": variant === \"tertiary\",\n \"cobalt-button--business\": variant === \"business\",\n \"cobalt-button--success\": variant === \"success\",\n \"cobalt-button--neutral\": variant === \"neutral\",\n \"c-w-full\": fullWidth,\n })\n}\n\ninterface ButtonOverloads {\n (\n props: Exclude<ButtonProps, ButtonComponentProps> &\n React.RefAttributes<HTMLAnchorElement>\n ): React.ReactElement\n (\n props: Exclude<ButtonProps, ButtonLinkComponentProps> &\n React.RefAttributes<HTMLButtonElement>\n ): React.ReactElement\n displayName?: string\n}\n\nconst Button = forwardRef<HTMLButtonElement | HTMLAnchorElement, ButtonProps>(\n (props, ref) => {\n const {\n children,\n className,\n variant,\n size,\n destructive,\n primary,\n text,\n icon,\n fullWidth,\n ...restProps\n } = props\n\n const computedClassName = getComputedClassName({\n className,\n variant,\n size,\n destructive,\n primary,\n text,\n fullWidth,\n isIconOnly: !!icon && !children,\n })\n\n const content = (\n <>\n {icon}\n {children && <span>{children}</span>}\n {text && children ? <ChevronRightIcon /> : null}\n </>\n )\n\n if (isLinkProps(restProps)) {\n return (\n <ButtonLinkBase\n {...(restProps as ButtonLinkComponentProps)}\n className={computedClassName}\n ref={ref as React.ForwardedRef<HTMLAnchorElement>}\n >\n {content}\n </ButtonLinkBase>\n )\n }\n\n return (\n <ButtonBase\n {...(restProps as ButtonComponentProps)}\n className={computedClassName}\n ref={ref as React.ForwardedRef<HTMLButtonElement>}\n >\n {content}\n </ButtonBase>\n )\n }\n) as ButtonOverloads\n\nButton.displayName = \"Button\"\n\nexport default Button\n"],"names":[],"mappings":";;;;;;;AAWA,MAAM,oBAAoB,GAAG,CAAC,EAC5B,SAAS,EACT,OAAO,EACP,IAAI,EACJ,WAAW,EACX,OAAO,EACP,IAAI,EACJ,UAAU,EACV,SAAS,GAUV,KAAI;AACH,IAAA,OAAO,EAAE,CAAC,SAAS,EAAE,eAAe,EAAE;AACpC,QAAA,wBAAwB,EAAE,OAAO;AACjC,QAAA,4BAA4B,EAAE,WAAW;AACzC,QAAA,qBAAqB,EAAE,IAAI;AAC3B,QAAA,0BAA0B,EAAE,UAAU;QACtC,sBAAsB,EAAE,IAAI,KAAK,OAAO;QACxC,sBAAsB,EAAE,IAAI,KAAK,OAAO;QACxC,wBAAwB,EAAE,OAAO,KAAK,SAAS;QAC/C,0BAA0B,EAAE,OAAO,KAAK,WAAW;QACnD,yBAAyB,EAAE,OAAO,KAAK,UAAU;QACjD,yBAAyB,EAAE,OAAO,KAAK,UAAU;QACjD,wBAAwB,EAAE,OAAO,KAAK,SAAS;QAC/C,wBAAwB,EAAE,OAAO,KAAK,SAAS;AAC/C,QAAA,UAAU,EAAE,SAAS;AACtB,KAAA,CAAC,CAAA;AACJ,CAAC,CAAA;AAcK,MAAA,MAAM,GAAG,UAAU,CACvB,CAAC,KAAK,EAAE,GAAG,KAAI;IACb,MAAM,EACJ,QAAQ,EACR,SAAS,EACT,OAAO,EACP,IAAI,EACJ,WAAW,EACX,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,GAAG,SAAS,EACb,GAAG,KAAK,CAAA;IAET,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;QAC7C,SAAS;QACT,OAAO;QACP,IAAI;QACJ,WAAW;QACX,OAAO;QACP,IAAI;QACJ,SAAS;AACT,QAAA,UAAU,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,QAAQ;AAChC,KAAA,CAAC,CAAA;IAEF,MAAM,OAAO,IACX,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA;QACG,IAAI;QACJ,QAAQ,IAAI,KAAO,CAAA,aAAA,CAAA,MAAA,EAAA,IAAA,EAAA,QAAQ,CAAQ;AACnC,QAAA,IAAI,IAAI,QAAQ,GAAG,KAAC,CAAA,aAAA,CAAA,gBAAgB,EAAG,IAAA,CAAA,GAAG,IAAI,CAC9C,CACJ,CAAA;AAED,IAAA,IAAI,WAAW,CAAC,SAAS,CAAC,EAAE;AAC1B,QAAA,QACE,KAAC,CAAA,aAAA,CAAA,cAAc,EACR,EAAA,GAAA,SAAsC,EAC3C,SAAS,EAAE,iBAAiB,EAC5B,GAAG,EAAE,GAA4C,IAEhD,OAAO,CACO,EAClB;KACF;AAED,IAAA,QACE,KAAC,CAAA,aAAA,CAAA,UAAU,EACJ,EAAA,GAAA,SAAkC,EACvC,SAAS,EAAE,iBAAiB,EAC5B,GAAG,EAAE,GAA4C,IAEhD,OAAO,CACG,EACd;AACH,CAAC,EACiB;AAEpB,MAAM,CAAC,WAAW,GAAG,QAAQ;;;;"}
@@ -0,0 +1,4 @@
1
+ const isLinkProps = (props) => "href" in props && !!props.href;
2
+
3
+ export { isLinkProps };
4
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sources":["../../../../src/components/Buttons/Button/type.ts"],"sourcesContent":["type SharedButtonApiProps = {\n loading?: boolean\n disabled?: boolean\n primary?: boolean\n destructive?: boolean\n icon?: React.ReactNode\n text?: boolean\n fullWidth?: boolean\n // React.HTMLAttributes allows color to be passed in, but we don't want to allow it\n color?: never\n}\n\ntype SharedConditionalTextProps =\n | {\n text: true\n icon: React.ReactNode\n children?: never | false | undefined | null\n fullWidth?: never | false\n }\n | {\n text: true\n icon?: never\n fullWidth?: never | false\n }\n | {\n text?: false\n }\n\ntype SharedConditionalVariantProps =\n | {\n size?: \"large\"\n variant?: never\n }\n | {\n size: \"small\"\n destructive?: false\n primary?: false\n // Those variants are only available for small buttons\n variant:\n | \"warning\"\n | \"secondary\"\n | \"tertiary\"\n | \"business\"\n | \"success\"\n | \"neutral\"\n }\n | {\n size: \"small\"\n variant?: never\n }\n\n// Button props\nexport type ButtonComponentProps =\n React.ButtonHTMLAttributes<HTMLButtonElement> & {\n loading?: SharedButtonApiProps[\"loading\"]\n disabled?: SharedButtonApiProps[\"disabled\"]\n href?: never\n }\n\n// Link props\nexport type ButtonLinkComponentProps =\n React.AnchorHTMLAttributes<HTMLAnchorElement> & {\n loading?: SharedButtonApiProps[\"loading\"]\n disabled?: SharedButtonApiProps[\"disabled\"]\n href?: string\n }\n\nexport const isLinkProps = (\n props: ButtonComponentProps | ButtonLinkComponentProps\n): props is ButtonLinkComponentProps => \"href\" in props && !!props.href\n\nexport type ButtonProps = (ButtonComponentProps | ButtonLinkComponentProps) &\n SharedButtonApiProps &\n SharedConditionalVariantProps &\n SharedConditionalTextProps\n"],"names":[],"mappings":"AAmEa,MAAA,WAAW,GAAG,CACzB,KAAsD,KAChB,MAAM,IAAI,KAAK,IAAI,CAAC,CAAC,KAAK,CAAC;;;;"}
@@ -3,6 +3,7 @@ import cx from 'classnames';
3
3
  import GhostButton from './GhostButton/index.js';
4
4
  import InversedButton from './InversedButton/index.js';
5
5
  import DefaultButton from './DefaultButton/index.js';
6
+ import Button from './Button/index.js';
6
7
 
7
8
  const isButton = (component) => React.isValidElement(component) &&
8
9
  (component.type === GhostButton ||
@@ -10,7 +11,8 @@ const isButton = (component) => React.isValidElement(component) &&
10
11
  component.type === InversedButton ||
11
12
  component.type === InversedButton.Link ||
12
13
  component.type === DefaultButton ||
13
- component.type === DefaultButton.Link);
14
+ component.type === DefaultButton.Link ||
15
+ component.type === Button);
14
16
  const ButtonsGroup = ({ className, children, align }) => (React.createElement("div", { className: cx(className, "cobalt-buttons-group", {
15
17
  "cobalt-buttons-group--right": align === "right",
16
18
  "cobalt-buttons-group--center": align === "center",
@@ -1 +1 @@
1
- {"version":3,"file":"ButtonsGroup.js","sources":["../../../src/components/Buttons/ButtonsGroup.tsx"],"sourcesContent":["import React, { Children } from \"react\"\nimport cx from \"classnames\"\n\nimport GhostButton from \"./GhostButton\"\nimport InversedButton from \"./InversedButton\"\nimport DefaultButton from \"./DefaultButton\"\nimport { AllButtonsPropsType } from \"./\"\n\nexport interface ButtonsGroupProps {\n className?: string\n children: React.ReactNode\n align?: \"fullWidth\" | \"right\" | \"center\"\n}\n\nconst isButton = (\n component: React.ReactNode\n): component is React.ReactElement<AllButtonsPropsType> =>\n React.isValidElement(component) &&\n (component.type === GhostButton ||\n component.type === GhostButton.Link ||\n component.type === InversedButton ||\n component.type === InversedButton.Link ||\n component.type === DefaultButton ||\n component.type === DefaultButton.Link)\n\nconst ButtonsGroup = ({ className, children, align }: ButtonsGroupProps) => (\n <div\n className={cx(className, \"cobalt-buttons-group\", {\n \"cobalt-buttons-group--right\": align === \"right\",\n \"cobalt-buttons-group--center\": align === \"center\",\n })}\n >\n {Children.toArray(children).map((child, index) =>\n isButton(child)\n ? React.cloneElement(child, {\n key: index,\n className: cx(\"cobalt-buttons-group__item\", {\n \"cobalt-buttons-group__item--fullWidth\": align === \"fullWidth\",\n }),\n fullWidth: align === \"fullWidth\",\n })\n : child\n )}\n </div>\n)\n\nexport default ButtonsGroup\n"],"names":[],"mappings":";;;;;;AAcA,MAAM,QAAQ,GAAG,CACf,SAA0B,KAE1B,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC;AAC/B,KAAC,SAAS,CAAC,IAAI,KAAK,WAAW;AAC7B,QAAA,SAAS,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI;QACnC,SAAS,CAAC,IAAI,KAAK,cAAc;AACjC,QAAA,SAAS,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI;QACtC,SAAS,CAAC,IAAI,KAAK,aAAa;AAChC,QAAA,SAAS,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,CAAC,CAAA;AAEpC,MAAA,YAAY,GAAG,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAqB,MACrE,6BACE,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,sBAAsB,EAAE;QAC/C,6BAA6B,EAAE,KAAK,KAAK,OAAO;QAChD,8BAA8B,EAAE,KAAK,KAAK,QAAQ;KACnD,CAAC,EAAA,EAED,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,KAC3C,QAAQ,CAAC,KAAK,CAAC;AACb,MAAE,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE;AACxB,QAAA,GAAG,EAAE,KAAK;AACV,QAAA,SAAS,EAAE,EAAE,CAAC,4BAA4B,EAAE;YAC1C,uCAAuC,EAAE,KAAK,KAAK,WAAW;SAC/D,CAAC;QACF,SAAS,EAAE,KAAK,KAAK,WAAW;KACjC,CAAC;AACJ,MAAE,KAAK,CACV,CACG;;;;"}
1
+ {"version":3,"file":"ButtonsGroup.js","sources":["../../../src/components/Buttons/ButtonsGroup.tsx"],"sourcesContent":["import React, { Children } from \"react\"\nimport cx from \"classnames\"\n\nimport GhostButton from \"./GhostButton\"\nimport InversedButton from \"./InversedButton\"\nimport DefaultButton from \"./DefaultButton\"\nimport { AllButtonsPropsType } from \"./\"\nimport Button from \"./Button\"\n\nexport interface ButtonsGroupProps {\n className?: string\n children: React.ReactNode\n align?: \"fullWidth\" | \"right\" | \"center\"\n}\n\nconst isButton = (\n component: React.ReactNode\n): component is React.ReactElement<AllButtonsPropsType> =>\n React.isValidElement(component) &&\n (component.type === GhostButton ||\n component.type === GhostButton.Link ||\n component.type === InversedButton ||\n component.type === InversedButton.Link ||\n component.type === DefaultButton ||\n component.type === DefaultButton.Link ||\n component.type === Button)\n\nconst ButtonsGroup = ({ className, children, align }: ButtonsGroupProps) => (\n <div\n className={cx(className, \"cobalt-buttons-group\", {\n \"cobalt-buttons-group--right\": align === \"right\",\n \"cobalt-buttons-group--center\": align === \"center\",\n })}\n >\n {Children.toArray(children).map((child, index) =>\n isButton(child)\n ? React.cloneElement(child, {\n key: index,\n className: cx(\"cobalt-buttons-group__item\", {\n \"cobalt-buttons-group__item--fullWidth\": align === \"fullWidth\",\n }),\n fullWidth: align === \"fullWidth\",\n })\n : child\n )}\n </div>\n)\n\nexport default ButtonsGroup\n"],"names":[],"mappings":";;;;;;;AAeA,MAAM,QAAQ,GAAG,CACf,SAA0B,KAE1B,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC;AAC/B,KAAC,SAAS,CAAC,IAAI,KAAK,WAAW;AAC7B,QAAA,SAAS,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI;QACnC,SAAS,CAAC,IAAI,KAAK,cAAc;AACjC,QAAA,SAAS,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI;QACtC,SAAS,CAAC,IAAI,KAAK,aAAa;AAChC,QAAA,SAAS,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI;AACrC,QAAA,SAAS,CAAC,IAAI,KAAK,MAAM,CAAC,CAAA;AAExB,MAAA,YAAY,GAAG,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAqB,MACrE,6BACE,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,sBAAsB,EAAE;QAC/C,6BAA6B,EAAE,KAAK,KAAK,OAAO;QAChD,8BAA8B,EAAE,KAAK,KAAK,QAAQ;KACnD,CAAC,EAAA,EAED,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,KAC3C,QAAQ,CAAC,KAAK,CAAC;AACb,MAAE,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE;AACxB,QAAA,GAAG,EAAE,KAAK;AACV,QAAA,SAAS,EAAE,EAAE,CAAC,4BAA4B,EAAE;YAC1C,uCAAuC,EAAE,KAAK,KAAK,WAAW;SAC/D,CAAC;QACF,SAAS,EAAE,KAAK,KAAK,WAAW;KACjC,CAAC;AACJ,MAAE,KAAK,CACV,CACG;;;;"}
package/index.js CHANGED
@@ -121,7 +121,6 @@ export { default as CheckCircleIcon } from './components/Icon/__generated__/Chec
121
121
  export { default as ChecklistIcon } from './components/Icon/__generated__/ChecklistIcon.js';
122
122
  export { default as ChevronDownIcon } from './components/Icon/__generated__/ChevronDownIcon.js';
123
123
  export { default as ChevronLeftIcon } from './components/Icon/__generated__/ChevronLeftIcon.js';
124
- export { default as ChevronRightIcon } from './components/Icon/__generated__/ChevronRightIcon.js';
125
124
  export { default as ChevronUpIcon } from './components/Icon/__generated__/ChevronUpIcon.js';
126
125
  export { default as CircledArrowLeftIcon } from './components/Icon/__generated__/CircledArrowLeftIcon.js';
127
126
  export { default as CircledArrowRightIcon } from './components/Icon/__generated__/CircledArrowRightIcon.js';
@@ -366,6 +365,7 @@ export { default as YingyangIcon } from './components/Icon/__generated__/Yingyan
366
365
  export { default as RatingLabel } from './components/Rating/RatingLabel.js';
367
366
  export { useAccordionItemContext } from '@ark-ui/react';
368
367
  export { default as CheckIcon } from './components/Icon/__generated__/CheckIcon.js';
368
+ export { default as ChevronRightIcon } from './components/Icon/__generated__/ChevronRightIcon.js';
369
369
  export { default as LoadingIcon } from './components/Icon/__generated__/LoadingIcon.js';
370
370
  export { default as StarIcon } from './components/Icon/__generated__/StarIcon.js';
371
371
  export { RatingInput } from './components/Rating/RatingInput.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drivy/cobalt",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "Opinionated design system for Drivy's projects.",
5
5
  "main": "src/index.js",
6
6
  "types": "types/src/index.d.ts",
@@ -37,7 +37,7 @@
37
37
  "react-dom": "^18.3.1"
38
38
  },
39
39
  "devDependencies": {
40
- "@getaround-eu/babel-preset-app": "1.4.5",
40
+ "@getaround-eu/babel-preset-app": "1.4.6",
41
41
  "@getaround-eu/eslint-config": "3.1.0",
42
42
  "@getaround-eu/prettier-config": "1.2.1",
43
43
  "@getaround-eu/stylelint-config": "3.0.1",
@@ -61,8 +61,8 @@
61
61
  "@types/node": "22.14.1",
62
62
  "@types/react": "18.3.24",
63
63
  "@types/react-dom": "18.3.7",
64
- "autoprefixer": "10.4.21",
65
- "core-js": "3.46.0",
64
+ "autoprefixer": "10.4.22",
65
+ "core-js": "3.47.0",
66
66
  "css-loader": "7.1.2",
67
67
  "eslint": "8.57.1",
68
68
  "eslint-plugin-storybook": "^0.12.0",
@@ -88,7 +88,7 @@
88
88
  "rollup-plugin-copy": "3.5.0",
89
89
  "rollup-plugin-svgo": "2.0.0",
90
90
  "rollup-plugin-typescript2": "0.36.0",
91
- "sass": "1.93.2",
91
+ "sass": "1.95.0",
92
92
  "sass-loader": "13.3.3",
93
93
  "sharp-cli": "5.2.0",
94
94
  "storybook": "7.6.20",
@@ -96,8 +96,8 @@
96
96
  "stylelint": "15.11.0",
97
97
  "svg2vectordrawable": "2.9.1",
98
98
  "svgo": "3.3.2",
99
- "ts-jest": "29.4.5",
100
- "tsx": "4.20.6",
99
+ "ts-jest": "29.4.6",
100
+ "tsx": "4.21.0",
101
101
  "typescript": "5.4.5"
102
102
  },
103
103
  "keywords": [
@@ -0,0 +1,140 @@
1
+ .cobalt-button {
2
+ @apply c-state-interactive c-transition c-px-[20px] c-border c-border-outline c-rounded-lg c-bg-surface c-text-primary c-text-body-md c-font-bold c-gap-2xs hover:c-drop-shadow-lg;
3
+ display: inline-flex;
4
+ box-sizing: border-box;
5
+ align-items: center;
6
+ justify-content: center;
7
+ min-width: 44px;
8
+ min-height: 44px;
9
+
10
+ text-align: center;
11
+ text-decoration: none;
12
+ vertical-align: middle;
13
+
14
+ cursor: pointer;
15
+
16
+ transform: scale(1);
17
+ user-select: none;
18
+ appearance: none;
19
+
20
+ &:active {
21
+ transform: scale(0.97);
22
+ }
23
+
24
+ .cobalt-Icon {
25
+ width: 24px;
26
+ height: 24px;
27
+
28
+ flex-shrink: 0;
29
+ }
30
+
31
+ &.cobalt-button--large {
32
+ @apply c-px-md;
33
+ min-height: 48px;
34
+ min-width: 48px;
35
+ }
36
+
37
+ &.cobalt-button--small {
38
+ @apply c-px-[12px] hover:c-drop-shadow-md;
39
+ min-width: 32px;
40
+ min-height: 32px;
41
+
42
+ font-size: 14px;
43
+
44
+ .cobalt-Icon {
45
+ width: 20px;
46
+ height: 20px;
47
+ }
48
+
49
+ &.cobalt-button--warning {
50
+ @apply c-bg-warning c-border-warning c-text-onWarning;
51
+ }
52
+
53
+ &.cobalt-button--tertiary {
54
+ @apply c-bg-tertiary c-border-tertiary c-text-onTertiary;
55
+ }
56
+
57
+ &.cobalt-button--secondary {
58
+ @apply c-bg-secondary c-border-secondary c-text-onSecondary;
59
+ }
60
+
61
+ &.cobalt-button--business {
62
+ @apply c-bg-businessContainer c-border-businessContainer c-text-onBusinessContainer;
63
+ }
64
+
65
+ &.cobalt-button--success {
66
+ @apply c-bg-success c-border-success c-text-onSuccess;
67
+ }
68
+
69
+ &.cobalt-button--neutral {
70
+ @apply c-bg-neutral c-border-neutral c-text-onNeutral;
71
+ }
72
+ }
73
+
74
+ &.cobalt-button--primary {
75
+ @apply c-bg-primary c-border-primary c-text-onPrimary;
76
+
77
+ &.cobalt-button--destructive {
78
+ @apply c-bg-error c-border-error c-text-onError;
79
+ }
80
+ }
81
+
82
+ &.cobalt-button--icon-only {
83
+ @apply c-p-none c-rounded-full;
84
+ }
85
+
86
+ &.cobalt-button--text {
87
+ @apply c-state-none c-transform-none hover:c-underline c-px-none c-bg-transparent c-border-transparent c-text-current c-drop-shadow-none c-gap-none;
88
+ transition: text-underline-offset 0.25s ease;
89
+
90
+ text-underline-offset: 2px;
91
+
92
+ &:active {
93
+ text-underline-offset: 1px;
94
+ }
95
+
96
+ &.cobalt-button--icon-only {
97
+ @apply c-state-interactive;
98
+ }
99
+ }
100
+
101
+ &.cobalt-button--destructive {
102
+ @apply c-text-error;
103
+ }
104
+
105
+ &[disabled][aria-disabled]:not([aria-disabled="false"]):not(
106
+ [aria-busy="true"]
107
+ ) {
108
+ @apply c-state-none c-text-onSurfaceDisabled c-drop-shadow-none hover:c-no-underline;
109
+ opacity: 1;
110
+ cursor: not-allowed;
111
+
112
+ &:not(.cobalt-button--text) {
113
+ @apply c-bg-disabled c-border-transparent;
114
+ }
115
+ }
116
+
117
+ &[aria-busy="true"] {
118
+ @apply c-state-none c-drop-shadow-none hover:c-no-underline;
119
+ --c-state-interactive-color: var(--c-press);
120
+ cursor: not-allowed;
121
+
122
+ &:focus,
123
+ &:hover,
124
+ &:active {
125
+ --c-state-interactive-color: var(--c-press);
126
+
127
+ transform: scale(1);
128
+ }
129
+ }
130
+
131
+ .cobalt-button__loading-icon {
132
+ position: absolute;
133
+
134
+ margin: auto;
135
+ }
136
+
137
+ &[aria-busy="true"] > *:not(.cobalt-button__loading-icon) {
138
+ color: transparent;
139
+ }
140
+ }
@@ -133,7 +133,7 @@
133
133
  }
134
134
 
135
135
  .cobalt-buttons-group {
136
- @apply c--mt-sm;
136
+ @apply c--mt-xs c-gap-x-sm;
137
137
  display: flex;
138
138
  flex-wrap: wrap;
139
139
  align-items: center;
@@ -147,13 +147,7 @@
147
147
  }
148
148
 
149
149
  &__item {
150
- @apply c-mt-sm;
151
-
152
- &:not(.cobalt-buttons-group__item--fullWidth):not(
153
- .cobalt-buttons-group__item--xs\:fullWidth
154
- ) {
155
- @apply c-mr-sm;
156
- }
150
+ @apply c-mt-xs;
157
151
 
158
152
  &--fullWidth {
159
153
  flex: 1 1 auto;
@@ -168,6 +162,7 @@
168
162
  }
169
163
  }
170
164
 
165
+ @import "./Button/index.scss";
171
166
  @import "./InversedButton/index.scss";
172
167
  @import "./GhostButton/index.scss";
173
168
  @import "./DefaultButton/index.scss";
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ export declare const ButtonBase: React.ForwardRefExoticComponent<React.ButtonHTMLAttributes<HTMLButtonElement> & {
3
+ loading?: boolean | undefined;
4
+ disabled?: boolean | undefined;
5
+ href?: undefined;
6
+ } & React.RefAttributes<HTMLButtonElement>>;
7
+ export declare const ButtonLinkBase: React.ForwardRefExoticComponent<React.AnchorHTMLAttributes<HTMLAnchorElement> & {
8
+ loading?: boolean | undefined;
9
+ disabled?: boolean | undefined;
10
+ href?: string | undefined;
11
+ } & React.RefAttributes<HTMLAnchorElement>>;
@@ -0,0 +1,9 @@
1
+ import React from "react";
2
+ import { ButtonComponentProps, ButtonLinkComponentProps, ButtonProps } from "./type";
3
+ interface ButtonOverloads {
4
+ (props: Exclude<ButtonProps, ButtonComponentProps> & React.RefAttributes<HTMLAnchorElement>): React.ReactElement;
5
+ (props: Exclude<ButtonProps, ButtonLinkComponentProps> & React.RefAttributes<HTMLButtonElement>): React.ReactElement;
6
+ displayName?: string;
7
+ }
8
+ declare const Button: ButtonOverloads;
9
+ export default Button;
@@ -0,0 +1,48 @@
1
+ /// <reference types="react" />
2
+ type SharedButtonApiProps = {
3
+ loading?: boolean;
4
+ disabled?: boolean;
5
+ primary?: boolean;
6
+ destructive?: boolean;
7
+ icon?: React.ReactNode;
8
+ text?: boolean;
9
+ fullWidth?: boolean;
10
+ color?: never;
11
+ };
12
+ type SharedConditionalTextProps = {
13
+ text: true;
14
+ icon: React.ReactNode;
15
+ children?: never | false | undefined | null;
16
+ fullWidth?: never | false;
17
+ } | {
18
+ text: true;
19
+ icon?: never;
20
+ fullWidth?: never | false;
21
+ } | {
22
+ text?: false;
23
+ };
24
+ type SharedConditionalVariantProps = {
25
+ size?: "large";
26
+ variant?: never;
27
+ } | {
28
+ size: "small";
29
+ destructive?: false;
30
+ primary?: false;
31
+ variant: "warning" | "secondary" | "tertiary" | "business" | "success" | "neutral";
32
+ } | {
33
+ size: "small";
34
+ variant?: never;
35
+ };
36
+ export type ButtonComponentProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
37
+ loading?: SharedButtonApiProps["loading"];
38
+ disabled?: SharedButtonApiProps["disabled"];
39
+ href?: never;
40
+ };
41
+ export type ButtonLinkComponentProps = React.AnchorHTMLAttributes<HTMLAnchorElement> & {
42
+ loading?: SharedButtonApiProps["loading"];
43
+ disabled?: SharedButtonApiProps["disabled"];
44
+ href?: string;
45
+ };
46
+ export declare const isLinkProps: (props: ButtonComponentProps | ButtonLinkComponentProps) => props is ButtonLinkComponentProps;
47
+ export type ButtonProps = (ButtonComponentProps | ButtonLinkComponentProps) & SharedButtonApiProps & SharedConditionalVariantProps & SharedConditionalTextProps;
48
+ export {};