@nice-digital/nds-button 4.0.17 → 4.0.19-alpha-node-update.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 +40 -40
- package/es/Button.js +56 -56
- package/package.json +5 -5
package/es/Button.d.ts
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import "../scss/button.scss";
|
|
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> {
|
|
15
|
-
[prop: string]: unknown;
|
|
16
|
-
/** The destination URL if this is an anchor */
|
|
17
|
-
to?: string;
|
|
18
|
-
variant?: keyof typeof buttonVariants;
|
|
19
|
-
buttonType?: keyof typeof buttonTypes;
|
|
20
|
-
/** A custom element type to be rendered as the tag, useful for custom routing */
|
|
21
|
-
elementType?: React.ElementType;
|
|
22
|
-
/** Additional classes e.g. margin modifiers like "mt--0" */
|
|
23
|
-
className?: string;
|
|
24
|
-
children: React.ReactNode;
|
|
25
|
-
method?: string;
|
|
26
|
-
}
|
|
27
|
-
export declare const Button: {
|
|
28
|
-
(props: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
-
types: {
|
|
30
|
-
readonly button: "button";
|
|
31
|
-
readonly submit: "submit";
|
|
32
|
-
readonly reset: "reset";
|
|
33
|
-
};
|
|
34
|
-
variants: {
|
|
35
|
-
readonly cta: "cta";
|
|
36
|
-
readonly primary: "primary";
|
|
37
|
-
readonly secondary: "secondary";
|
|
38
|
-
readonly inverse: "inverse";
|
|
39
|
-
};
|
|
40
|
-
};
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import "../scss/button.scss";
|
|
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> {
|
|
15
|
+
[prop: string]: unknown;
|
|
16
|
+
/** The destination URL if this is an anchor */
|
|
17
|
+
to?: string;
|
|
18
|
+
variant?: keyof typeof buttonVariants;
|
|
19
|
+
buttonType?: keyof typeof buttonTypes;
|
|
20
|
+
/** A custom element type to be rendered as the tag, useful for custom routing */
|
|
21
|
+
elementType?: React.ElementType;
|
|
22
|
+
/** Additional classes e.g. margin modifiers like "mt--0" */
|
|
23
|
+
className?: string;
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
method?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare const Button: {
|
|
28
|
+
(props: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
types: {
|
|
30
|
+
readonly button: "button";
|
|
31
|
+
readonly submit: "submit";
|
|
32
|
+
readonly reset: "reset";
|
|
33
|
+
};
|
|
34
|
+
variants: {
|
|
35
|
+
readonly cta: "cta";
|
|
36
|
+
readonly primary: "primary";
|
|
37
|
+
readonly secondary: "secondary";
|
|
38
|
+
readonly inverse: "inverse";
|
|
39
|
+
};
|
|
40
|
+
};
|
package/es/Button.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Button = exports.buttonTypes = exports.buttonVariants = void 0;
|
|
18
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
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
|
-
};
|
|
32
|
-
const Button = (props) => {
|
|
33
|
-
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(exports.buttonVariants);
|
|
35
|
-
if (variant && !possibleVariants.some((m) => m === variant)) {
|
|
36
|
-
throw new Error(`Expected variant to be one of '${possibleVariants.join("', '")}' but found '${variant}'`);
|
|
37
|
-
}
|
|
38
|
-
const ButtonTagType = elementType || (to ? "a" : "button");
|
|
39
|
-
const buttonProps = {};
|
|
40
|
-
if (to) {
|
|
41
|
-
buttonProps[method || (ButtonTagType === "a" && "href") || "to"] = to;
|
|
42
|
-
}
|
|
43
|
-
else if (ButtonTagType === "button") {
|
|
44
|
-
buttonProps.type = buttonType || exports.buttonTypes.button;
|
|
45
|
-
}
|
|
46
|
-
buttonProps.className = (0, classnames_1.default)({
|
|
47
|
-
btn: true,
|
|
48
|
-
[`btn--${variant}`]: variant !== exports.buttonVariants.primary,
|
|
49
|
-
[`${className}`]: !!className
|
|
50
|
-
});
|
|
51
|
-
return ((0, jsx_runtime_1.jsx)(ButtonTagType, Object.assign({}, buttonProps, attributes, { "data-component": `button${variant ? `--${variant}` : ""}${buttonType ? `--${buttonType}` : ""}
|
|
52
|
-
};
|
|
53
|
-
exports.Button = Button;
|
|
54
|
-
// Legacy references - deprecated!
|
|
55
|
-
exports.Button.types = exports.buttonTypes;
|
|
56
|
-
exports.Button.variants = exports.buttonVariants;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Button = exports.buttonTypes = exports.buttonVariants = void 0;
|
|
18
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
19
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
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
|
+
};
|
|
32
|
+
const Button = (props) => {
|
|
33
|
+
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(exports.buttonVariants);
|
|
35
|
+
if (variant && !possibleVariants.some((m) => m === variant)) {
|
|
36
|
+
throw new Error(`Expected variant to be one of '${possibleVariants.join("', '")}' but found '${variant}'`);
|
|
37
|
+
}
|
|
38
|
+
const ButtonTagType = elementType || (to ? "a" : "button");
|
|
39
|
+
const buttonProps = {};
|
|
40
|
+
if (to) {
|
|
41
|
+
buttonProps[method || (ButtonTagType === "a" && "href") || "to"] = to;
|
|
42
|
+
}
|
|
43
|
+
else if (ButtonTagType === "button") {
|
|
44
|
+
buttonProps.type = buttonType || exports.buttonTypes.button;
|
|
45
|
+
}
|
|
46
|
+
buttonProps.className = (0, classnames_1.default)({
|
|
47
|
+
btn: true,
|
|
48
|
+
[`btn--${variant}`]: variant !== exports.buttonVariants.primary,
|
|
49
|
+
[`${className}`]: !!className
|
|
50
|
+
});
|
|
51
|
+
return ((0, jsx_runtime_1.jsx)(ButtonTagType, Object.assign({}, buttonProps, attributes, { "data-component": `button${variant ? `--${variant}` : ""}${buttonType ? `--${buttonType}` : ""}`, children: children })));
|
|
52
|
+
};
|
|
53
|
+
exports.Button = Button;
|
|
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.
|
|
3
|
+
"version": "4.0.19-alpha-node-update.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/",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"url": "https://github.com/nice-digital/nice-design-system/issues"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@nice-digital/nds-core": "^4.0.
|
|
31
|
+
"@nice-digital/nds-core": "^4.0.17-alpha-node-update.0",
|
|
32
32
|
"classnames": "^2.2.6"
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"@testing-library/react": "^13.4.0",
|
|
41
41
|
"@testing-library/user-event": "^14.4.3",
|
|
42
42
|
"@types/jest": "^29.2.2",
|
|
43
|
-
"@types/node": "
|
|
44
|
-
"typescript": "^
|
|
43
|
+
"@types/node": "22.19.0",
|
|
44
|
+
"typescript": "^5.9.3"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "1b7a4a13183120071b022adecd2fcf4eebefbb6c"
|
|
47
47
|
}
|