@nice-digital/nds-button 4.0.2-alpha.0 → 4.0.4-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
@@ -1,11 +1,22 @@
1
1
  import * as React from "react";
2
2
  import "../scss/button.scss";
3
- interface ButtonProps extends React.HTMLProps<HTMLButtonElement | HTMLAnchorElement> {
3
+ export declare const buttonVariants: {
4
+ readonly cta: "cta";
5
+ readonly primary: "primary";
6
+ readonly secondary: "secondary";
7
+ readonly inverse: "inverse";
8
+ };
9
+ export declare const buttonTypes: {
10
+ readonly button: "button";
11
+ readonly submit: "submit";
12
+ readonly reset: "reset";
13
+ };
14
+ export interface ButtonProps extends React.HTMLProps<HTMLButtonElement | HTMLAnchorElement> {
4
15
  [prop: string]: unknown;
5
16
  /** The destination URL if this is an anchor */
6
17
  to?: string;
7
- variant?: "primary" | "cta" | "secondary" | "inverse";
8
- buttonType?: "button" | "submit" | "reset";
18
+ variant?: keyof typeof buttonVariants;
19
+ buttonType?: keyof typeof buttonTypes;
9
20
  /** A custom element type to be rendered as the tag, useful for custom routing */
10
21
  elementType?: React.ElementType;
11
22
  /** Additional classes e.g. margin modifiers like "mt--0" */
@@ -16,15 +27,14 @@ interface ButtonProps extends React.HTMLProps<HTMLButtonElement | HTMLAnchorElem
16
27
  export declare const Button: {
17
28
  (props: ButtonProps): JSX.Element;
18
29
  types: {
19
- button: string;
20
- submit: string;
21
- reset: string;
30
+ readonly button: "button";
31
+ readonly submit: "submit";
32
+ readonly reset: "reset";
22
33
  };
23
34
  variants: {
24
- cta: string;
25
- primary: string;
26
- secondary: string;
27
- inverse: string;
35
+ readonly cta: "cta";
36
+ readonly primary: "primary";
37
+ readonly secondary: "secondary";
38
+ readonly inverse: "inverse";
28
39
  };
29
40
  };
30
- export {};
package/es/Button.js CHANGED
@@ -14,13 +14,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  return (mod && mod.__esModule) ? mod : { "default": mod };
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.Button = void 0;
17
+ exports.Button = exports.buttonTypes = exports.buttonVariants = 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
+ exports.buttonVariants = {
22
+ cta: "cta",
23
+ primary: "primary",
24
+ secondary: "secondary",
25
+ inverse: "inverse"
26
+ };
27
+ exports.buttonTypes = {
28
+ button: "button",
29
+ submit: "submit",
30
+ reset: "reset"
31
+ };
21
32
  const Button = (props) => {
22
33
  const { variant = "primary", to, elementType, children, buttonType, className, method } = props, attributes = __rest(props, ["variant", "to", "elementType", "children", "buttonType", "className", "method"]);
23
- const possibleVariants = Object.keys(exports.Button.variants);
34
+ const possibleVariants = Object.keys(exports.buttonVariants);
24
35
  if (variant && !possibleVariants.some((m) => m === variant)) {
25
36
  throw new Error(`Expected variant to be one of '${possibleVariants.join("', '")}' but found '${variant}'`);
26
37
  }
@@ -30,24 +41,16 @@ const Button = (props) => {
30
41
  buttonProps[method || (ButtonTagType === "a" && "href") || "to"] = to;
31
42
  }
32
43
  else if (ButtonTagType === "button") {
33
- buttonProps.type = buttonType || exports.Button.types.button;
44
+ buttonProps.type = buttonType || exports.buttonTypes.button;
34
45
  }
35
46
  buttonProps.className = (0, classnames_1.default)({
36
47
  btn: true,
37
- [`btn--${variant}`]: variant !== exports.Button.variants.primary,
48
+ [`btn--${variant}`]: variant !== exports.buttonVariants.primary,
38
49
  [`${className}`]: !!className
39
50
  });
40
51
  return ((0, jsx_runtime_1.jsx)(ButtonTagType, Object.assign({}, buttonProps, attributes, { children: children })));
41
52
  };
42
53
  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
- };
54
+ // Legacy references - deprecated!
55
+ exports.Button.types = exports.buttonTypes;
56
+ exports.Button.variants = exports.buttonVariants;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-digital/nds-button",
3
- "version": "4.0.2-alpha.0",
3
+ "version": "4.0.4-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.1-alpha.0",
30
+ "@nice-digital/nds-core": "^4.0.2-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": "e75957040c9acfbd7eeb164cad724e3b48760679"
45
+ "gitHead": "0a6b742ccd11300f0586abf5dc3790e217f70c21"
46
46
  }