@nice-digital/nds-alphabet 3.0.16 → 3.0.18-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/Alphabet.d.ts CHANGED
@@ -1,26 +1,26 @@
1
- import React from "react";
2
- import "../scss/alphabet.scss";
3
- export interface AlphabetProps {
4
- id?: string;
5
- children: React.ReactElement<LetterProps>[];
6
- chunky?: boolean;
7
- className?: string;
8
- [key: string]: unknown;
9
- }
10
- export interface LetterProps {
11
- children: React.ReactNode;
12
- label?: string;
13
- chunky?: boolean;
14
- elementType?: React.ElementType;
15
- to?: string | false;
16
- [key: string]: unknown;
17
- }
18
- export interface LinkProps {
19
- text: React.ReactNode;
20
- destination: string;
21
- elementType?: React.ElementType;
22
- method?: string;
23
- ariaLabel?: string;
24
- }
25
- export declare const Alphabet: React.FC<AlphabetProps>;
26
- export declare const Letter: React.FC<LetterProps>;
1
+ import React from "react";
2
+ import "../scss/alphabet.scss";
3
+ export interface AlphabetProps {
4
+ id?: string;
5
+ children: React.ReactElement<LetterProps>[];
6
+ chunky?: boolean;
7
+ className?: string;
8
+ [key: string]: unknown;
9
+ }
10
+ export interface LetterProps {
11
+ children: React.ReactNode;
12
+ label?: string;
13
+ chunky?: boolean;
14
+ elementType?: React.ElementType;
15
+ to?: string | false;
16
+ [key: string]: unknown;
17
+ }
18
+ export interface LinkProps {
19
+ text: React.ReactNode;
20
+ destination: string;
21
+ elementType?: React.ElementType;
22
+ method?: string;
23
+ ariaLabel?: string;
24
+ }
25
+ export declare const Alphabet: React.FC<AlphabetProps>;
26
+ export declare const Letter: React.FC<LetterProps>;
package/es/Alphabet.js CHANGED
@@ -1,57 +1,57 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.Letter = exports.Alphabet = void 0;
15
- const jsx_runtime_1 = require("react/jsx-runtime");
16
- const react_1 = require("react");
17
- require("../scss/alphabet.scss");
18
- const Alphabet = (props) => {
19
- const { children, className, id, chunky } = props, attrs = __rest(props, ["children", "className", "id", "chunky"]);
20
- const chunkyChild = (child) => {
21
- return (0, react_1.isValidElement)(child)
22
- ? (0, react_1.cloneElement)(child, { chunky: true })
23
- : child;
24
- };
25
- return ((0, jsx_runtime_1.jsx)("ol", Object.assign({ className: [
26
- `alphabet ${chunky ? "alphabet--chunky" : ""}`,
27
- className
28
- ].join(" "), id: id || "a-to-z" }, attrs, { children: chunky
29
- ? react_1.Children.map(children, (child) => chunkyChild(child))
30
- : children })));
31
- };
32
- exports.Alphabet = Alphabet;
33
- const Letter = (props) => {
34
- const { children, label, to, chunky, elementType } = props, attrs = __rest(props, ["children", "label", "to", "chunky", "elementType"]);
35
- let body;
36
- if (!to) {
37
- // No link
38
- body = (0, jsx_runtime_1.jsx)("span", Object.assign({ "aria-label": label }, { children: children }));
39
- }
40
- else if (to[0] === "#") {
41
- // Link to an id on the same page
42
- body = ((0, jsx_runtime_1.jsx)("a", Object.assign({ href: to, "aria-label": label }, { children: children })));
43
- }
44
- else {
45
- // Link to somewhere else!
46
- body = ((0, jsx_runtime_1.jsx)(Link, { elementType: elementType, ariaLabel: label, destination: to, text: children }));
47
- }
48
- return ((0, jsx_runtime_1.jsx)("li", Object.assign({ className: `alphabet__letter ${chunky ? "alphabet__letter--chunky" : ""}`, "data-component": `alphabet-letter${chunky ? `--chunky` : ""}` }, attrs, { children: body })));
49
- };
50
- exports.Letter = Letter;
51
- const Link = ({ text, destination, elementType: ElementType = "a", method, ariaLabel }) => {
52
- let linkProps = {
53
- className: "alphabet__link",
54
- [method || (ElementType === "a" && "href") || "to"]: destination
55
- };
56
- return ((0, jsx_runtime_1.jsx)(ElementType, Object.assign({ "aria-label": ariaLabel, "data-component": `alphabet` }, linkProps, { children: text })));
57
- };
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
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.Letter = exports.Alphabet = void 0;
15
+ const jsx_runtime_1 = require("react/jsx-runtime");
16
+ const react_1 = require("react");
17
+ require("../scss/alphabet.scss");
18
+ const Alphabet = (props) => {
19
+ const { children, className, id, chunky } = props, attrs = __rest(props, ["children", "className", "id", "chunky"]);
20
+ const chunkyChild = (child) => {
21
+ return (0, react_1.isValidElement)(child)
22
+ ? (0, react_1.cloneElement)(child, { chunky: true })
23
+ : child;
24
+ };
25
+ return ((0, jsx_runtime_1.jsx)("ol", Object.assign({ className: [
26
+ `alphabet ${chunky ? "alphabet--chunky" : ""}`,
27
+ className
28
+ ].join(" "), id: id || "a-to-z" }, attrs, { children: chunky
29
+ ? react_1.Children.map(children, (child) => chunkyChild(child))
30
+ : children })));
31
+ };
32
+ exports.Alphabet = Alphabet;
33
+ const Letter = (props) => {
34
+ const { children, label, to, chunky, elementType } = props, attrs = __rest(props, ["children", "label", "to", "chunky", "elementType"]);
35
+ let body;
36
+ if (!to) {
37
+ // No link
38
+ body = (0, jsx_runtime_1.jsx)("span", { "aria-label": label, children: children });
39
+ }
40
+ else if (to[0] === "#") {
41
+ // Link to an id on the same page
42
+ body = ((0, jsx_runtime_1.jsx)("a", { href: to, "aria-label": label, children: children }));
43
+ }
44
+ else {
45
+ // Link to somewhere else!
46
+ body = ((0, jsx_runtime_1.jsx)(Link, { elementType: elementType, ariaLabel: label, destination: to, text: children }));
47
+ }
48
+ return ((0, jsx_runtime_1.jsx)("li", Object.assign({ className: `alphabet__letter ${chunky ? "alphabet__letter--chunky" : ""}`, "data-component": `alphabet-letter${chunky ? `--chunky` : ""}` }, attrs, { children: body })));
49
+ };
50
+ exports.Letter = Letter;
51
+ const Link = ({ text, destination, elementType: ElementType = "a", method, ariaLabel }) => {
52
+ let linkProps = {
53
+ className: "alphabet__link",
54
+ [method || (ElementType === "a" && "href") || "to"]: destination
55
+ };
56
+ return ((0, jsx_runtime_1.jsx)(ElementType, Object.assign({ "aria-label": ariaLabel, "data-component": `alphabet` }, linkProps, { children: text })));
57
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-digital/nds-alphabet",
3
- "version": "3.0.16",
3
+ "version": "3.0.18-alpha.0",
4
4
  "description": "Alphabet component for the NICE Design System",
5
5
  "main": "es/Alphabet.js",
6
6
  "types": "es/Alphabet.d.ts",
@@ -32,15 +32,15 @@
32
32
  "homepage": "https://design-system.nice.org.uk/",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
- "@nice-digital/nds-core": "^4.0.16"
35
+ "@nice-digital/nds-core": "^4.0.18-alpha.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@testing-library/jest-dom": "^5.16.5",
39
39
  "@testing-library/react": "^13.4.0",
40
40
  "@testing-library/user-event": "^14.4.3",
41
41
  "@types/jest": "^29.2.2",
42
- "@types/node": "^18.11.9",
43
- "typescript": "^4.8.4"
42
+ "@types/node": "22.19.0",
43
+ "typescript": "^5.9.3"
44
44
  },
45
- "gitHead": "7f069b2855600345c7366e8dc965a5d839a20c17"
45
+ "gitHead": "d1bac6f89a952c97aeaf5d9d0ee9d99ee35a3ed3"
46
46
  }