@nice-digital/nds-button 4.0.0-alpha.0 → 4.0.2-alpha.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.
package/es/Button.d.ts CHANGED
@@ -13,5 +13,18 @@ interface ButtonProps extends React.HTMLProps<HTMLButtonElement | HTMLAnchorElem
13
13
  children: React.ReactNode;
14
14
  method?: string;
15
15
  }
16
- export declare const Button: React.FC<ButtonProps>;
16
+ export declare const Button: {
17
+ (props: ButtonProps): JSX.Element;
18
+ types: {
19
+ button: string;
20
+ submit: string;
21
+ reset: string;
22
+ };
23
+ variants: {
24
+ cta: string;
25
+ primary: string;
26
+ secondary: string;
27
+ inverse: string;
28
+ };
29
+ };
17
30
  export {};
package/es/Button.js CHANGED
@@ -18,20 +18,9 @@ exports.Button = void 0;
18
18
  const jsx_runtime_1 = require("react/jsx-runtime");
19
19
  const classnames_1 = __importDefault(require("classnames"));
20
20
  require("../scss/button.scss");
21
- const ButtonTypes = {
22
- button: "button",
23
- submit: "submit",
24
- reset: "reset"
25
- };
26
- const ButtonVariants = {
27
- cta: "cta",
28
- primary: "primary",
29
- secondary: "secondary",
30
- inverse: "inverse"
31
- };
32
21
  const Button = (props) => {
33
22
  const { variant = "primary", to, elementType, children, buttonType, className, method } = props, attributes = __rest(props, ["variant", "to", "elementType", "children", "buttonType", "className", "method"]);
34
- const possibleVariants = Object.keys(ButtonVariants);
23
+ const possibleVariants = Object.keys(exports.Button.variants);
35
24
  if (variant && !possibleVariants.some((m) => m === variant)) {
36
25
  throw new Error(`Expected variant to be one of '${possibleVariants.join("', '")}' but found '${variant}'`);
37
26
  }
@@ -41,13 +30,24 @@ const Button = (props) => {
41
30
  buttonProps[method || (ButtonTagType === "a" && "href") || "to"] = to;
42
31
  }
43
32
  else if (ButtonTagType === "button") {
44
- buttonProps.type = buttonType || ButtonTypes.button;
33
+ buttonProps.type = buttonType || exports.Button.types.button;
45
34
  }
46
35
  buttonProps.className = (0, classnames_1.default)({
47
36
  btn: true,
48
- [`btn--${variant}`]: variant !== ButtonVariants.primary,
37
+ [`btn--${variant}`]: variant !== exports.Button.variants.primary,
49
38
  [`${className}`]: !!className
50
39
  });
51
40
  return ((0, jsx_runtime_1.jsx)(ButtonTagType, Object.assign({}, buttonProps, attributes, { children: children })));
52
41
  };
53
42
  exports.Button = Button;
43
+ exports.Button.types = {
44
+ button: "button",
45
+ submit: "submit",
46
+ reset: "reset"
47
+ };
48
+ exports.Button.variants = {
49
+ cta: "cta",
50
+ primary: "primary",
51
+ secondary: "secondary",
52
+ inverse: "inverse"
53
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-digital/nds-button",
3
- "version": "4.0.0-alpha.0",
3
+ "version": "4.0.2-alpha.0",
4
4
  "description": "Button component for the NICE Design System",
5
5
  "author": "Ian Routledge <ian.routledge@nice.org.uk>",
6
6
  "homepage": "https://design-system.nice.org.uk/",
@@ -27,7 +27,7 @@
27
27
  "url": "https://github.com/nice-digital/nice-design-system/issues"
28
28
  },
29
29
  "dependencies": {
30
- "@nice-digital/nds-core": "^4.0.0-alpha.0",
30
+ "@nice-digital/nds-core": "^4.0.1-alpha.0",
31
31
  "classnames": "^2.2.6"
32
32
  },
33
33
  "peerDependencies": {
@@ -42,5 +42,5 @@
42
42
  "@types/node": "^18.11.9",
43
43
  "typescript": "^4.8.4"
44
44
  },
45
- "gitHead": "e225e0b15723013fb3df7309d197590a09cc2ea7"
45
+ "gitHead": "e75957040c9acfbd7eeb164cad724e3b48760679"
46
46
  }