@dnanpm/styleguide 4.0.5 → 4.0.7

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.
@@ -36,7 +36,13 @@ interface Props {
36
36
  * Allows to pass a custom className
37
37
  */
38
38
  className?: string;
39
+ /**
40
+ * Allows the last breadcrumb item to be a link
41
+ *
42
+ * @default false
43
+ */
44
+ allowLastItemLink?: boolean;
39
45
  }
40
- declare const Breadcrumb: ({ "data-testid": dataTestId, ariaLabel, className, items, linkComponent: LinkComponent, linkProps, }: Props) => React.JSX.Element | null;
46
+ declare const Breadcrumb: ({ "data-testid": dataTestId, ariaLabel, className, items, linkComponent: LinkComponent, linkProps, allowLastItemLink, }: Props) => React.JSX.Element | null;
41
47
  /** @component */
42
48
  export default Breadcrumb;
@@ -60,20 +60,20 @@ const BreadcrumbListItem = styledComponents.styled.li `
60
60
  text-overflow: ellipsis;
61
61
  }
62
62
  `;
63
- const Breadcrumb = ({ 'data-testid': dataTestId, ariaLabel, className, items, linkComponent: LinkComponent, linkProps = {}, }) => {
63
+ const Breadcrumb = ({ 'data-testid': dataTestId, ariaLabel, className, items, linkComponent: LinkComponent, linkProps = {}, allowLastItemLink = false, }) => {
64
64
  if (!items || items.length === 0) {
65
65
  return null;
66
66
  }
67
67
  const renderItem = (item, index) => {
68
68
  const isLastItem = index === items.length - 1;
69
- if (isLastItem || !item.href) {
69
+ if ((isLastItem && !allowLastItemLink) || !item.href) {
70
70
  return React__default.default.createElement("span", { "aria-current": isLastItem ? 'page' : undefined }, item.label);
71
71
  }
72
72
  if (LinkComponent) {
73
- return (React__default.default.createElement(LinkComponent, Object.assign({ href: item.href, itemProp: "item", itemScope: true, itemType: "https://schema.org/WebPage" }, linkProps),
73
+ return (React__default.default.createElement(LinkComponent, Object.assign({ href: item.href, itemProp: "item", itemScope: true, itemType: "https://schema.org/WebPage", "aria-current": isLastItem ? 'page' : undefined }, linkProps),
74
74
  React__default.default.createElement("span", { itemProp: "name" }, item.label)));
75
75
  }
76
- return (React__default.default.createElement("a", { href: item.href, itemProp: "item", itemScope: true, itemType: "https://schema.org/WebPage" },
76
+ return (React__default.default.createElement("a", { href: item.href, itemProp: "item", itemScope: true, itemType: "https://schema.org/WebPage", "aria-current": isLastItem ? 'page' : undefined },
77
77
  React__default.default.createElement("span", { itemProp: "name" }, item.label)));
78
78
  };
79
79
  return (React__default.default.createElement(BreadcrumbNav, { "aria-label": ariaLabel, className: className, "data-testid": dataTestId },
@@ -1,40 +1,12 @@
1
- import type { ComponentType, MouseEvent, ReactNode } from 'react';
1
+ import type { AnchorHTMLAttributes, ButtonHTMLAttributes, ComponentType, MouseEvent, ReactNode } from 'react';
2
2
  import React from 'react';
3
3
  type ButtonType = 'submit' | 'button' | 'reset';
4
- export interface Props {
4
+ export type Props = ButtonProps & AnchorProps & CommonProps;
5
+ export interface CommonProps {
5
6
  /**
6
7
  * Unique ID for the component
7
8
  */
8
9
  id?: string;
9
- /**
10
- * Name of the button element
11
- */
12
- name?: string;
13
- /**
14
- * Allows to change the HTML type of button element. Ignored when `href` is defined
15
- *
16
- * @param {ButtonType} submit Button submits the form data
17
- * @param {ButtonType} button No functionality when pressed
18
- * @param {ButtonType} reset Button resets all the controls to their initial values
19
- *
20
- * @default 'submit'
21
- */
22
- type?: ButtonType;
23
- /**
24
- * Allows to change the type of resulting HTML element from button (`<button></button>`) to anchor (`<a href="..."></a>`)
25
- */
26
- href?: string;
27
- /**
28
- * Allows to use a custom link component instead of anchor element when `href` is defined
29
- */
30
- nextLink?: ComponentType<{
31
- href: string;
32
- children: ReactNode;
33
- }>;
34
- /**
35
- * Allows to set the target attribute for the link
36
- */
37
- target?: '_self' | '_blank' | '_parent' | '_top';
38
10
  /**
39
11
  * Content of Button component
40
12
  */
@@ -59,13 +31,6 @@ export interface Props {
59
31
  * Allows to change width of Button component to size of its wrapper
60
32
  */
61
33
  fullWidth?: boolean;
62
- /**
63
- * Allows disabling the component functionality.
64
- * When `href` is defined, disables the link functionality.
65
- *
66
- * @default false
67
- */
68
- disabled?: boolean;
69
34
  /**
70
35
  * Displays loading indicator (PixelLoader) instead of children
71
36
  *
@@ -96,11 +61,47 @@ export interface Props {
96
61
  * Allows to pass a screen reader label for the loading indicator
97
62
  */
98
63
  loadingLabel?: string;
64
+ }
65
+ type ButtonProps = CommonProps & Omit<ButtonHTMLAttributes<HTMLButtonElement>, keyof CommonProps | 'href' | 'nextLink' | 'target'> & {
99
66
  /**
100
- * Ref for the button element
67
+ * Name of the button element
101
68
  */
102
- ref?: React.Ref<HTMLButtonElement>;
103
- }
69
+ name?: string;
70
+ /**
71
+ * Allows to change the HTML type of button element. Ignored when `href` is defined
72
+ *
73
+ * @param {ButtonType} submit Button submits the form data
74
+ * @param {ButtonType} button No functionality when pressed
75
+ * @param {ButtonType} reset Button resets all the controls to their initial values
76
+ *
77
+ * @default 'button'
78
+ */
79
+ type?: ButtonType;
80
+ /**
81
+ * Allows disabling the component functionality.
82
+ * When `href` is defined, disables the link functionality.
83
+ *
84
+ * @default false
85
+ */
86
+ disabled?: boolean;
87
+ };
88
+ type AnchorProps = CommonProps & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof CommonProps | 'name' | 'disabled' | 'type'> & {
89
+ /**
90
+ * Allows to change the type of resulting HTML element from button (`<button></button>`) to anchor (`<a href="..."></a>`)
91
+ */
92
+ href?: string;
93
+ /**
94
+ * Allows to use a custom link component instead of anchor element when `href` is defined
95
+ */
96
+ nextLink?: ComponentType<{
97
+ href: string;
98
+ children: ReactNode;
99
+ }>;
100
+ /**
101
+ * Allows to set the target attribute for the link
102
+ */
103
+ target?: '_self' | '_blank' | '_parent' | '_top';
104
+ };
104
105
  export declare const shade: {
105
106
  pink: {
106
107
  darker: string;
@@ -118,6 +119,6 @@ export declare const shade: {
118
119
  };
119
120
  };
120
121
  /** @visibleName Button */
121
- declare const Button: ({ type, "data-testid": dataTestId, "data-track-value": dataTrackValue, "aria-label": ariaLabel, ...props }: Props) => React.JSX.Element;
122
+ declare const Button: React.ForwardRefExoticComponent<(ButtonProps | AnchorProps) & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
122
123
  /** @component */
123
124
  export default Button;
@@ -30,7 +30,7 @@ const shade = {
30
30
  },
31
31
  },
32
32
  };
33
- const Element = styledComponents.styled.button `
33
+ const Element = styledComponents.styled('button') `
34
34
  text-align: center;
35
35
  transition: all 0.2s ease-in-out;
36
36
  display: inline-block;
@@ -119,25 +119,46 @@ const Element = styledComponents.styled.button `
119
119
  `}
120
120
  `;
121
121
  /** @visibleName Button */
122
- const Button = (_a) => {
123
- var _b;
124
- var { type = 'submit', 'data-testid': dataTestId, 'data-track-value': dataTrackValue, 'aria-label': ariaLabel } = _a, props = tslib.__rest(_a, ["type", 'data-testid', 'data-track-value', 'aria-label']);
125
- const isDisabledAnchor = props.disabled && props.href;
122
+ const Button = React.forwardRef((props, ref) => {
123
+ const { 'data-testid': dataTestId, 'data-track-value': dataTrackValue, 'aria-label': ariaLabel, onClick, onMouseDown, id, small, darkBg, fullWidth, loading, children, loadingLabel, className } = props, rest = tslib.__rest(props, ['data-testid', 'data-track-value', 'aria-label', "onClick", "onMouseDown", "id", "small", "darkBg", "fullWidth", "loading", "children", "loadingLabel", "className"]);
124
+ const propHref = props.href;
125
+ const propNextLink = props.nextLink;
126
+ const propTarget = props.target;
127
+ const isDisabledAnchor = props.disabled && propHref;
126
128
  const handleClick = (event) => {
127
129
  if (isDisabledAnchor) {
128
130
  event.preventDefault();
129
131
  event.stopPropagation();
130
132
  return;
131
133
  }
132
- if (props.onClick) {
133
- props.onClick(event);
134
+ if (onClick) {
135
+ onClick(event);
134
136
  }
135
137
  };
136
- return (React__default.default.createElement(Element, Object.assign({ id: props.id, as: (_b = props.nextLink) !== null && _b !== void 0 ? _b : (props.href ? 'a' : undefined), type: props.href ? undefined : type, href: isDisabledAnchor ? undefined : props.href, target: props.href ? props.target : undefined, rel: props.target === '_blank' ? 'noopener noreferrer' : undefined, onClick: handleClick, onMouseDown: props.onMouseDown, "$small": props.small, "$darkBg": props.darkBg, "$fullWidth": props.fullWidth, "$loading": props.loading, tabIndex: props.loading || isDisabledAnchor ? -1 : 0, "data-loading": props.loading, className: props.className, "data-testid": dataTestId, "data-track-value": dataTrackValue, "aria-label": ariaLabel, "aria-disabled": isDisabledAnchor ? 'true' : undefined }, props.dataAttributes, (!props.href && {
137
- name: props.name,
138
- disabled: props.disabled,
139
- })), props.loading ? (React__default.default.createElement(PixelLoader.default, { color: props.darkBg ? theme.default.color.default.white : theme.default.color.default.plum, label: props.loadingLabel })) : (React__default.default.createElement("span", { "data-testid": dataTestId && `${dataTestId}-text` }, props.children))));
140
- };
138
+ const content = loading ? (React__default.default.createElement(PixelLoader.default, { color: darkBg ? theme.default.color.default.white : theme.default.color.default.plum, label: loadingLabel })) : (React__default.default.createElement("span", { "data-testid": dataTestId && `${dataTestId}-text` }, children));
139
+ const commonElementProps = {
140
+ id: id,
141
+ onClick: handleClick,
142
+ onMouseDown: onMouseDown,
143
+ $small: small,
144
+ $darkBg: darkBg,
145
+ $fullWidth: fullWidth,
146
+ $loading: loading,
147
+ 'data-loading': loading,
148
+ className: className,
149
+ 'data-testid': dataTestId,
150
+ 'data-track-value': dataTrackValue,
151
+ 'aria-label': ariaLabel,
152
+ };
153
+ if (propHref) {
154
+ return (React__default.default.createElement(Element, Object.assign({ as: propNextLink !== null && propNextLink !== void 0 ? propNextLink : (propHref ? 'a' : undefined),
155
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
156
+ ref: propNextLink ? ref : ref, href: isDisabledAnchor ? undefined : propHref, target: propTarget, rel: propHref && propTarget === '_blank' ? 'noopener noreferrer' : undefined, tabIndex: loading || isDisabledAnchor ? -1 : 0, "aria-disabled": isDisabledAnchor ? 'true' : undefined }, commonElementProps, rest.dataAttributes), content));
157
+ }
158
+ else {
159
+ return (React__default.default.createElement(Element, Object.assign({ as: "button", ref: ref, type: props.type || 'button', name: props.name, disabled: props.disabled, tabIndex: loading ? -1 : 0 }, commonElementProps, rest.dataAttributes), content));
160
+ }
161
+ });
141
162
 
142
163
  exports.default = Button;
143
164
  exports.shade = shade;
@@ -36,6 +36,6 @@ interface Props extends Omit<ButtonProps, 'fullWidth'> {
36
36
  isLinkStyle?: boolean;
37
37
  }
38
38
  /** @visibleName Button Icon */
39
- declare const ButtonIcon: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLButtonElement>>;
39
+ declare const ButtonIcon: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLButtonElement>>;
40
40
  /** @component */
41
41
  export default ButtonIcon;
@@ -40,6 +40,18 @@ interface Props {
40
40
  * @default '6.25rem'
41
41
  */
42
42
  height?: string;
43
+ /**
44
+ * Allows to pass a custom margin
45
+ *
46
+ * @default '0'
47
+ */
48
+ margin?: string;
49
+ /**
50
+ * Allows to pass a custom padding
51
+ *
52
+ * @default '0'
53
+ */
54
+ padding?: string;
43
55
  /**
44
56
  * Allows to pass testid string for testing purposes
45
57
  */
@@ -44,6 +44,8 @@ const SkeletonWrapper = styledComponents.styled.div `
44
44
  opacity: ${({ $opacity }) => ($opacity ? $opacity / 100 : 1)};
45
45
  width: ${({ $width }) => $width};
46
46
  height: ${({ $height }) => $height};
47
+ ${({ $margin }) => $margin && `margin: ${$margin}`};
48
+ ${({ $padding }) => $padding && `padding: ${$padding}`};
47
49
  border-radius: ${({ $borderRadius }) => theme.default.radius[$borderRadius || 's']};
48
50
 
49
51
  &::after {
@@ -67,7 +69,7 @@ const Skeleton = (_a) => {
67
69
  var { backgroundColor = 'sand', opacity = 100, width = '25rem', height = '6.25rem', borderRadius = 's', 'data-testid': dataTestId } = _a, props = tslib.__rest(_a, ["backgroundColor", "opacity", "width", "height", "borderRadius", 'data-testid']);
68
70
  return (React__default.default.createElement(React__default.default.Fragment, null,
69
71
  props.ariaLabel && (React__default.default.createElement("span", { id: props.id, "aria-label": props.ariaLabel, role: "status", "aria-atomic": "true", className: "visually-hidden" })),
70
- React__default.default.createElement(SkeletonWrapper, { className: props.className, "data-testid": dataTestId, "aria-hidden": "true", tabIndex: -1, "$backgroundColor": backgroundColor, "$opacity": opacity, "$width": width, "$height": height, "$carouselIndex": props.carouselIndex, "$borderRadius": borderRadius })));
72
+ React__default.default.createElement(SkeletonWrapper, { className: props.className, "data-testid": dataTestId, "aria-hidden": "true", tabIndex: -1, "$backgroundColor": backgroundColor, "$opacity": opacity, "$width": width, "$height": height, "$margin": props.margin, "$padding": props.padding, "$carouselIndex": props.carouselIndex, "$borderRadius": borderRadius })));
71
73
  };
72
74
 
73
75
  exports.default = Skeleton;
@@ -36,7 +36,13 @@ interface Props {
36
36
  * Allows to pass a custom className
37
37
  */
38
38
  className?: string;
39
+ /**
40
+ * Allows the last breadcrumb item to be a link
41
+ *
42
+ * @default false
43
+ */
44
+ allowLastItemLink?: boolean;
39
45
  }
40
- declare const Breadcrumb: ({ "data-testid": dataTestId, ariaLabel, className, items, linkComponent: LinkComponent, linkProps, }: Props) => React.JSX.Element | null;
46
+ declare const Breadcrumb: ({ "data-testid": dataTestId, ariaLabel, className, items, linkComponent: LinkComponent, linkProps, allowLastItemLink, }: Props) => React.JSX.Element | null;
41
47
  /** @component */
42
48
  export default Breadcrumb;
@@ -52,20 +52,20 @@ const BreadcrumbListItem = styled.li `
52
52
  text-overflow: ellipsis;
53
53
  }
54
54
  `;
55
- const Breadcrumb = ({ 'data-testid': dataTestId, ariaLabel, className, items, linkComponent: LinkComponent, linkProps = {}, }) => {
55
+ const Breadcrumb = ({ 'data-testid': dataTestId, ariaLabel, className, items, linkComponent: LinkComponent, linkProps = {}, allowLastItemLink = false, }) => {
56
56
  if (!items || items.length === 0) {
57
57
  return null;
58
58
  }
59
59
  const renderItem = (item, index) => {
60
60
  const isLastItem = index === items.length - 1;
61
- if (isLastItem || !item.href) {
61
+ if ((isLastItem && !allowLastItemLink) || !item.href) {
62
62
  return React__default.createElement("span", { "aria-current": isLastItem ? 'page' : undefined }, item.label);
63
63
  }
64
64
  if (LinkComponent) {
65
- return (React__default.createElement(LinkComponent, Object.assign({ href: item.href, itemProp: "item", itemScope: true, itemType: "https://schema.org/WebPage" }, linkProps),
65
+ return (React__default.createElement(LinkComponent, Object.assign({ href: item.href, itemProp: "item", itemScope: true, itemType: "https://schema.org/WebPage", "aria-current": isLastItem ? 'page' : undefined }, linkProps),
66
66
  React__default.createElement("span", { itemProp: "name" }, item.label)));
67
67
  }
68
- return (React__default.createElement("a", { href: item.href, itemProp: "item", itemScope: true, itemType: "https://schema.org/WebPage" },
68
+ return (React__default.createElement("a", { href: item.href, itemProp: "item", itemScope: true, itemType: "https://schema.org/WebPage", "aria-current": isLastItem ? 'page' : undefined },
69
69
  React__default.createElement("span", { itemProp: "name" }, item.label)));
70
70
  };
71
71
  return (React__default.createElement(BreadcrumbNav, { "aria-label": ariaLabel, className: className, "data-testid": dataTestId },
@@ -1,40 +1,12 @@
1
- import type { ComponentType, MouseEvent, ReactNode } from 'react';
1
+ import type { AnchorHTMLAttributes, ButtonHTMLAttributes, ComponentType, MouseEvent, ReactNode } from 'react';
2
2
  import React from 'react';
3
3
  type ButtonType = 'submit' | 'button' | 'reset';
4
- export interface Props {
4
+ export type Props = ButtonProps & AnchorProps & CommonProps;
5
+ export interface CommonProps {
5
6
  /**
6
7
  * Unique ID for the component
7
8
  */
8
9
  id?: string;
9
- /**
10
- * Name of the button element
11
- */
12
- name?: string;
13
- /**
14
- * Allows to change the HTML type of button element. Ignored when `href` is defined
15
- *
16
- * @param {ButtonType} submit Button submits the form data
17
- * @param {ButtonType} button No functionality when pressed
18
- * @param {ButtonType} reset Button resets all the controls to their initial values
19
- *
20
- * @default 'submit'
21
- */
22
- type?: ButtonType;
23
- /**
24
- * Allows to change the type of resulting HTML element from button (`<button></button>`) to anchor (`<a href="..."></a>`)
25
- */
26
- href?: string;
27
- /**
28
- * Allows to use a custom link component instead of anchor element when `href` is defined
29
- */
30
- nextLink?: ComponentType<{
31
- href: string;
32
- children: ReactNode;
33
- }>;
34
- /**
35
- * Allows to set the target attribute for the link
36
- */
37
- target?: '_self' | '_blank' | '_parent' | '_top';
38
10
  /**
39
11
  * Content of Button component
40
12
  */
@@ -59,13 +31,6 @@ export interface Props {
59
31
  * Allows to change width of Button component to size of its wrapper
60
32
  */
61
33
  fullWidth?: boolean;
62
- /**
63
- * Allows disabling the component functionality.
64
- * When `href` is defined, disables the link functionality.
65
- *
66
- * @default false
67
- */
68
- disabled?: boolean;
69
34
  /**
70
35
  * Displays loading indicator (PixelLoader) instead of children
71
36
  *
@@ -96,11 +61,47 @@ export interface Props {
96
61
  * Allows to pass a screen reader label for the loading indicator
97
62
  */
98
63
  loadingLabel?: string;
64
+ }
65
+ type ButtonProps = CommonProps & Omit<ButtonHTMLAttributes<HTMLButtonElement>, keyof CommonProps | 'href' | 'nextLink' | 'target'> & {
99
66
  /**
100
- * Ref for the button element
67
+ * Name of the button element
101
68
  */
102
- ref?: React.Ref<HTMLButtonElement>;
103
- }
69
+ name?: string;
70
+ /**
71
+ * Allows to change the HTML type of button element. Ignored when `href` is defined
72
+ *
73
+ * @param {ButtonType} submit Button submits the form data
74
+ * @param {ButtonType} button No functionality when pressed
75
+ * @param {ButtonType} reset Button resets all the controls to their initial values
76
+ *
77
+ * @default 'button'
78
+ */
79
+ type?: ButtonType;
80
+ /**
81
+ * Allows disabling the component functionality.
82
+ * When `href` is defined, disables the link functionality.
83
+ *
84
+ * @default false
85
+ */
86
+ disabled?: boolean;
87
+ };
88
+ type AnchorProps = CommonProps & Omit<AnchorHTMLAttributes<HTMLAnchorElement>, keyof CommonProps | 'name' | 'disabled' | 'type'> & {
89
+ /**
90
+ * Allows to change the type of resulting HTML element from button (`<button></button>`) to anchor (`<a href="..."></a>`)
91
+ */
92
+ href?: string;
93
+ /**
94
+ * Allows to use a custom link component instead of anchor element when `href` is defined
95
+ */
96
+ nextLink?: ComponentType<{
97
+ href: string;
98
+ children: ReactNode;
99
+ }>;
100
+ /**
101
+ * Allows to set the target attribute for the link
102
+ */
103
+ target?: '_self' | '_blank' | '_parent' | '_top';
104
+ };
104
105
  export declare const shade: {
105
106
  pink: {
106
107
  darker: string;
@@ -118,6 +119,6 @@ export declare const shade: {
118
119
  };
119
120
  };
120
121
  /** @visibleName Button */
121
- declare const Button: ({ type, "data-testid": dataTestId, "data-track-value": dataTrackValue, "aria-label": ariaLabel, ...props }: Props) => React.JSX.Element;
122
+ declare const Button: React.ForwardRefExoticComponent<(ButtonProps | AnchorProps) & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
122
123
  /** @component */
123
124
  export default Button;
@@ -1,5 +1,5 @@
1
1
  import { __rest } from 'tslib';
2
- import React__default from 'react';
2
+ import React__default, { forwardRef } from 'react';
3
3
  import { styled } from 'styled-components';
4
4
  import theme from '../../themes/theme.js';
5
5
  import { getMultipliedSize } from '../../utils/styledUtils.js';
@@ -22,7 +22,7 @@ const shade = {
22
22
  },
23
23
  },
24
24
  };
25
- const Element = styled.button `
25
+ const Element = styled('button') `
26
26
  text-align: center;
27
27
  transition: all 0.2s ease-in-out;
28
28
  display: inline-block;
@@ -111,24 +111,45 @@ const Element = styled.button `
111
111
  `}
112
112
  `;
113
113
  /** @visibleName Button */
114
- const Button = (_a) => {
115
- var _b;
116
- var { type = 'submit', 'data-testid': dataTestId, 'data-track-value': dataTrackValue, 'aria-label': ariaLabel } = _a, props = __rest(_a, ["type", 'data-testid', 'data-track-value', 'aria-label']);
117
- const isDisabledAnchor = props.disabled && props.href;
114
+ const Button = forwardRef((props, ref) => {
115
+ const { 'data-testid': dataTestId, 'data-track-value': dataTrackValue, 'aria-label': ariaLabel, onClick, onMouseDown, id, small, darkBg, fullWidth, loading, children, loadingLabel, className } = props, rest = __rest(props, ['data-testid', 'data-track-value', 'aria-label', "onClick", "onMouseDown", "id", "small", "darkBg", "fullWidth", "loading", "children", "loadingLabel", "className"]);
116
+ const propHref = props.href;
117
+ const propNextLink = props.nextLink;
118
+ const propTarget = props.target;
119
+ const isDisabledAnchor = props.disabled && propHref;
118
120
  const handleClick = (event) => {
119
121
  if (isDisabledAnchor) {
120
122
  event.preventDefault();
121
123
  event.stopPropagation();
122
124
  return;
123
125
  }
124
- if (props.onClick) {
125
- props.onClick(event);
126
+ if (onClick) {
127
+ onClick(event);
126
128
  }
127
129
  };
128
- return (React__default.createElement(Element, Object.assign({ id: props.id, as: (_b = props.nextLink) !== null && _b !== void 0 ? _b : (props.href ? 'a' : undefined), type: props.href ? undefined : type, href: isDisabledAnchor ? undefined : props.href, target: props.href ? props.target : undefined, rel: props.target === '_blank' ? 'noopener noreferrer' : undefined, onClick: handleClick, onMouseDown: props.onMouseDown, "$small": props.small, "$darkBg": props.darkBg, "$fullWidth": props.fullWidth, "$loading": props.loading, tabIndex: props.loading || isDisabledAnchor ? -1 : 0, "data-loading": props.loading, className: props.className, "data-testid": dataTestId, "data-track-value": dataTrackValue, "aria-label": ariaLabel, "aria-disabled": isDisabledAnchor ? 'true' : undefined }, props.dataAttributes, (!props.href && {
129
- name: props.name,
130
- disabled: props.disabled,
131
- })), props.loading ? (React__default.createElement(PixelLoader, { color: props.darkBg ? theme.color.default.white : theme.color.default.plum, label: props.loadingLabel })) : (React__default.createElement("span", { "data-testid": dataTestId && `${dataTestId}-text` }, props.children))));
132
- };
130
+ const content = loading ? (React__default.createElement(PixelLoader, { color: darkBg ? theme.color.default.white : theme.color.default.plum, label: loadingLabel })) : (React__default.createElement("span", { "data-testid": dataTestId && `${dataTestId}-text` }, children));
131
+ const commonElementProps = {
132
+ id: id,
133
+ onClick: handleClick,
134
+ onMouseDown: onMouseDown,
135
+ $small: small,
136
+ $darkBg: darkBg,
137
+ $fullWidth: fullWidth,
138
+ $loading: loading,
139
+ 'data-loading': loading,
140
+ className: className,
141
+ 'data-testid': dataTestId,
142
+ 'data-track-value': dataTrackValue,
143
+ 'aria-label': ariaLabel,
144
+ };
145
+ if (propHref) {
146
+ return (React__default.createElement(Element, Object.assign({ as: propNextLink !== null && propNextLink !== void 0 ? propNextLink : (propHref ? 'a' : undefined),
147
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any
148
+ ref: propNextLink ? ref : ref, href: isDisabledAnchor ? undefined : propHref, target: propTarget, rel: propHref && propTarget === '_blank' ? 'noopener noreferrer' : undefined, tabIndex: loading || isDisabledAnchor ? -1 : 0, "aria-disabled": isDisabledAnchor ? 'true' : undefined }, commonElementProps, rest.dataAttributes), content));
149
+ }
150
+ else {
151
+ return (React__default.createElement(Element, Object.assign({ as: "button", ref: ref, type: props.type || 'button', name: props.name, disabled: props.disabled, tabIndex: loading ? -1 : 0 }, commonElementProps, rest.dataAttributes), content));
152
+ }
153
+ });
133
154
 
134
155
  export { Button as default, shade };
@@ -36,6 +36,6 @@ interface Props extends Omit<ButtonProps, 'fullWidth'> {
36
36
  isLinkStyle?: boolean;
37
37
  }
38
38
  /** @visibleName Button Icon */
39
- declare const ButtonIcon: React.ForwardRefExoticComponent<Omit<Props, "ref"> & React.RefAttributes<HTMLButtonElement>>;
39
+ declare const ButtonIcon: React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLButtonElement>>;
40
40
  /** @component */
41
41
  export default ButtonIcon;
@@ -40,6 +40,18 @@ interface Props {
40
40
  * @default '6.25rem'
41
41
  */
42
42
  height?: string;
43
+ /**
44
+ * Allows to pass a custom margin
45
+ *
46
+ * @default '0'
47
+ */
48
+ margin?: string;
49
+ /**
50
+ * Allows to pass a custom padding
51
+ *
52
+ * @default '0'
53
+ */
54
+ padding?: string;
43
55
  /**
44
56
  * Allows to pass testid string for testing purposes
45
57
  */
@@ -36,6 +36,8 @@ const SkeletonWrapper = styled.div `
36
36
  opacity: ${({ $opacity }) => ($opacity ? $opacity / 100 : 1)};
37
37
  width: ${({ $width }) => $width};
38
38
  height: ${({ $height }) => $height};
39
+ ${({ $margin }) => $margin && `margin: ${$margin}`};
40
+ ${({ $padding }) => $padding && `padding: ${$padding}`};
39
41
  border-radius: ${({ $borderRadius }) => theme.radius[$borderRadius || 's']};
40
42
 
41
43
  &::after {
@@ -59,7 +61,7 @@ const Skeleton = (_a) => {
59
61
  var { backgroundColor = 'sand', opacity = 100, width = '25rem', height = '6.25rem', borderRadius = 's', 'data-testid': dataTestId } = _a, props = __rest(_a, ["backgroundColor", "opacity", "width", "height", "borderRadius", 'data-testid']);
60
62
  return (React__default.createElement(React__default.Fragment, null,
61
63
  props.ariaLabel && (React__default.createElement("span", { id: props.id, "aria-label": props.ariaLabel, role: "status", "aria-atomic": "true", className: "visually-hidden" })),
62
- React__default.createElement(SkeletonWrapper, { className: props.className, "data-testid": dataTestId, "aria-hidden": "true", tabIndex: -1, "$backgroundColor": backgroundColor, "$opacity": opacity, "$width": width, "$height": height, "$carouselIndex": props.carouselIndex, "$borderRadius": borderRadius })));
64
+ React__default.createElement(SkeletonWrapper, { className: props.className, "data-testid": dataTestId, "aria-hidden": "true", tabIndex: -1, "$backgroundColor": backgroundColor, "$opacity": opacity, "$width": width, "$height": height, "$margin": props.margin, "$padding": props.padding, "$carouselIndex": props.carouselIndex, "$borderRadius": borderRadius })));
63
65
  };
64
66
 
65
67
  export { Skeleton as default };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dnanpm/styleguide",
3
3
  "sideEffects": false,
4
- "version": "v4.0.5",
4
+ "version": "v4.0.7",
5
5
  "main": "build/cjs/index.js",
6
6
  "module": "build/es/index.js",
7
7
  "jsnext:main": "build/es/index.js",
@@ -44,7 +44,7 @@
44
44
  "not op_mini all"
45
45
  ],
46
46
  "devDependencies": {
47
- "@babel/core": "^7.26.10",
47
+ "@babel/core": "^7.28.6",
48
48
  "@babel/preset-env": "^7.26.0",
49
49
  "@babel/preset-react": "^7.26.3",
50
50
  "@babel/preset-typescript": "^7.28.5",
@@ -54,26 +54,26 @@
54
54
  "@rollup/plugin-commonjs": "^29.0.0",
55
55
  "@rollup/plugin-node-resolve": "^16.0.3",
56
56
  "@rollup/plugin-typescript": "^12.3.0",
57
- "@stylistic/eslint-plugin": "^5.5.0",
57
+ "@stylistic/eslint-plugin": "^5.7.0",
58
58
  "@testing-library/jest-dom": "^6.6.3",
59
- "@testing-library/react": "^16.3.1",
59
+ "@testing-library/react": "^16.3.2",
60
60
  "@testing-library/user-event": "^14.5.2",
61
61
  "@types/jest": "^30.0.0",
62
- "@types/node": "^25.0.3",
62
+ "@types/node": "^25.0.9",
63
63
  "@types/ramda": "^0.31.1",
64
64
  "@types/react": "^18.3.11",
65
65
  "@types/react-dom": "^18.3.1",
66
66
  "@types/react-modal": "^3.13.1",
67
67
  "@types/resize-observer-browser": "^0.1.8",
68
68
  "@typescript-eslint/eslint-plugin": "^8.46.4",
69
- "@typescript-eslint/parser": "^8.48.1",
69
+ "@typescript-eslint/parser": "^8.52.0",
70
70
  "babel-loader": "^9.2.1",
71
71
  "cross-env": "^10.0.0",
72
72
  "css-loader": "^6.11.0",
73
73
  "eslint": "^9.39.1",
74
74
  "eslint-config-prettier": "^10.1.8",
75
75
  "eslint-plugin-import": "^2.32.0",
76
- "eslint-plugin-jsdoc": "^61.4.2",
76
+ "eslint-plugin-jsdoc": "^62.0.1",
77
77
  "eslint-plugin-jsx-a11y": "^6.10.2",
78
78
  "eslint-plugin-react": "^7.37.5",
79
79
  "eslint-plugin-react-hooks": "^7.0.1",
@@ -81,7 +81,7 @@
81
81
  "jest": "^30.0.5",
82
82
  "jest-environment-jsdom": "^29.7.0",
83
83
  "jest-styled-components": "^7.2.0",
84
- "mini-css-extract-plugin": "^2.9.2",
84
+ "mini-css-extract-plugin": "^2.10.0",
85
85
  "prettier": "^3.6.2",
86
86
  "react": "^18.3.1",
87
87
  "react-docgen": "^5.4.3",
@@ -101,7 +101,7 @@
101
101
  "dependencies": {
102
102
  "date-fns-tz": "^3.2.0",
103
103
  "ramda": "^0.32.0",
104
- "react-datepicker": "9.0.0",
104
+ "react-datepicker": "9.1.0",
105
105
  "react-modal": "^3.16.1",
106
106
  "react-select": "^5.8.1",
107
107
  "react-spring": "^8.0.27",