@nice-digital/nds-core 4.0.1-alpha.0 → 4.0.2

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breakpoints.js","names":["breakpoints","xs","sm","md","lg","xl","matchesFrom","breakpointName","breakpointPx","Error","window","matchMedia","matches"],"sources":["../src/breakpoints.js"],"sourcesContent":["/**\n * @module Breakpoints\n */\n\n/**\n * The breakpoints, in pixel values.\n * These correspond with the breakpoints defined in SASS.\n * Often not used directly, but via matchesFrom.\n */\nexport const breakpoints = {\n\txs: 400,\n\tsm: 600,\n\tmd: 900,\n\tlg: 1200,\n\txl: 1600\n};\n\n/**\n * Determines if the device's width matches a min-width query from the given breakpoint.\n *\n * @param {string} breakpointName The breakpoint name\n * @return {Boolean} True if it matches, false otherwise.\n *\n * @example\n * \timport { matchesFrom } from \"./breakpoints\";\n * \t// Checks if the media query (min-width: 25em) matches\n * \tvar matches = matchesFrom(\"xs\");\n */\nexport const matchesFrom = (breakpointName) => {\n\tlet breakpointPx = breakpoints[breakpointName];\n\n\tif (!breakpointPx) {\n\t\tthrow new Error(`Breakpoint ${breakpointName} does not exist`);\n\t}\n\n\t// Assume matchMedia is polyfilled elsewhere\n\t// Convert to ems to match the media query if the browser's root font-size isn't 16\n\treturn window.matchMedia(`(min-width: ${breakpointPx / 16}em)`).matches;\n};\n"],"mappings":"AAAA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMA,WAAW,GAAG;EAC1BC,EAAE,EAAE,GADsB;EAE1BC,EAAE,EAAE,GAFsB;EAG1BC,EAAE,EAAE,GAHsB;EAI1BC,EAAE,EAAE,IAJsB;EAK1BC,EAAE,EAAE;AALsB,CAApB;AAQP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,WAAW,GAAG,SAAdA,WAAc,CAACC,cAAD,EAAoB;EAC9C,IAAIC,YAAY,GAAGR,WAAW,CAACO,cAAD,CAA9B;;EAEA,IAAI,CAACC,YAAL,EAAmB;IAClB,MAAM,IAAIC,KAAJ,iBAAwBF,cAAxB,qBAAN;EACA,CAL6C,CAO9C;EACA;;;EACA,OAAOG,MAAM,CAACC,UAAP,kBAAiCH,YAAY,GAAG,EAAhD,UAAyDI,OAAhE;AACA,CAVM"}
package/es/core.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","names":[],"sources":["../src/core.js"],"sourcesContent":["export * from \"./utils\";\nexport * from \"./breakpoints\";\n"],"mappings":"AAAA,cAAc,SAAd;AACA,cAAc,eAAd"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":["trim","str","replace","throttle","fn","threshhold","scope","last","deferTimer","throttled","context","now","Date","args","arguments","clearTimeout","setTimeout","apply","debounce","func","execAsap","threshold","timeout","debounced","delayed","slugify","toLowerCase","nextUniqueId","i","prefix","camelCase","split","join","letter","index","toUpperCase"],"sources":["../src/utils.js"],"sourcesContent":["/**\n * @module Utils\n * Utility functions\n */\n\n/**\n * Trims whitespace characters from the start and end of a string.\n * This utility method exists because String.prototype.trim is\n * not supported in IE8.\n *\n * @param {string} str The string to trim\n */\nexport const trim = function (str) {\n\treturn str.replace(/^[\\s\\uFEFF\\xA0]+|[\\s\\uFEFF\\xA0]+$/g, \"\");\n};\n\n/**\n * Throttle events\n * See https://remysharp.com/2010/07/21/throttling-function-calls\n *\n * @param {Function} func The function to throttle\n * @param {Integer} threshold The threshhold period, in milliseconds\n * @param {Object} scope The context of the throttled function\n * @return {Function} { The throttled function }\n */\nexport const throttle = function (fn, threshhold = 100, scope = null) {\n\tlet last, deferTimer;\n\n\treturn function throttled() {\n\t\tlet context = scope || this,\n\t\t\tnow = +new Date(),\n\t\t\targs = arguments;\n\n\t\tif (last && now < last + threshhold) {\n\t\t\t// hold on to it\n\t\t\tclearTimeout(deferTimer);\n\t\t\tdeferTimer = setTimeout(function () {\n\t\t\t\tlast = now;\n\t\t\t\tfn.apply(context, args);\n\t\t\t}, threshhold);\n\t\t} else {\n\t\t\tlast = now;\n\t\t\tfn.apply(context, args);\n\t\t}\n\t};\n};\n\n/**\n * Debounce\n * See http://unscriptable.com/2009/03/20/debouncing-javascript-methods/\n *\n * @param {Function} func The function to debounce\n * @param {Integer} execAsap Whether to execute the function now\n * @param {Integer} threshold The detection period, in milliseconds\n * @param {Object} scope The context for the debounced function\n * @return {Function} { The debounced function }\n */\nexport const debounce = function (\n\tfunc,\n\texecAsap = false,\n\tthreshold = 100,\n\tscope = null\n) {\n\tlet timeout;\n\n\treturn function debounced() {\n\t\tlet context = scope || this,\n\t\t\targs = arguments;\n\n\t\tfunction delayed() {\n\t\t\tif (!execAsap) func.apply(context, args);\n\t\t\ttimeout = null;\n\t\t}\n\n\t\tif (timeout) clearTimeout(timeout);\n\t\telse if (execAsap) func.apply(context, args);\n\n\t\ttimeout = setTimeout(delayed, threshold);\n\t};\n};\n\n/**\n * Turns a string into a slug.\n * See {@link https://gist.github.com/mathewbyrne/1280286#gistcomment-1606270|this gist}.\n *\n * @param {string} str { The string to slugify }\n * @returns {string} { The slugified string }\n *\n * @example <caption>Example slugifying</caption>\n * import { slugify } from \"./utils\";\n * // returns \"a-string-to-transform-and-slugify\"\n * slugify(\"A (string) to transform & slugify!\");\n */\nexport const slugify = (str) => {\n\treturn trim(str)\n\t\t.toLowerCase()\n\t\t.replace(/\\s+/g, \"-\") // Replace spaces with -\n\t\t.replace(/&/g, \"-and-\") // Replace & with 'and'\n\t\t.replace(/[^\\w-]+/g, \"\") // Remove all non-word chars\n\t\t.replace(/^-+/g, \"\") // Trim dashes from the start\n\t\t.replace(/-+$/g, \"\") // Trim dashes from the end\n\t\t.replace(/-{2,}/g, \"-\"); // Replace multiple - with single -\n};\n\n/**\n * Generates a unique id in the form prefix-n by incrementing a counter.\n * The first time this is called it will return \"uid-1\" then \"uid-2\" and so on.\n * See {@link http://stackoverflow.com/a/20302361|This StackOverflow answer}.\n *\n * @param {string} prefix { The prefix for the id to return. Defaults to \"uid\" }\n * @return {string} { The unique id }\n *\n * @example <caption>Simple example</caption>\n * import { nextUniqueId } from \"./utils\";\n * // returns \"uid-1\"\n * nextUniqueId();\n *\n * @example <caption>Prefix example</caption>\n * import utils from \"./utils\";\n * // returns \"prefix-1\"\n * utils.nextUniqueId(\"prefix\");\n */\nexport const nextUniqueId = (function (i) {\n\treturn function (prefix = \"uid\") {\n\t\treturn `${prefix}-${++i}`;\n\t};\n})(0);\n\n/**\n * CamelCases a string\n * @param {string} str The string to camel case\n */\nexport const camelCase = function (str) {\n\tstr = str.split(\"-\").join(\" \"); // To support kebab-case\n\t// See https://stackoverflow.com/a/2970667/486434\n\treturn str\n\t\t.replace(/(?:^\\w|[A-Z]|\\b\\w)/g, function (letter, index) {\n\t\t\treturn index === 0 ? letter.toLowerCase() : letter.toUpperCase();\n\t\t})\n\t\t.replace(/\\s+/g, \"\");\n};\n\nexport default {\n\tthrottle: throttle,\n\tdebounce: debounce,\n\tslugify: slugify,\n\tnextUniqueId: nextUniqueId,\n\tcamelCase: camelCase\n};\n"],"mappings":"AAAA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,IAAMA,IAAI,GAAG,SAAPA,IAAO,CAAUC,GAAV,EAAe;EAClC,OAAOA,GAAG,CAACC,OAAJ,CAAY,oCAAZ,EAAkD,EAAlD,CAAP;AACA,CAFM;AAIP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,IAAMC,QAAQ,GAAG,SAAXA,QAAW,CAAUC,EAAV,EAAcC,UAAd,EAAgCC,KAAhC,EAA8C;EAAA,IAAhCD,UAAgC;IAAhCA,UAAgC,GAAnB,GAAmB;EAAA;;EAAA,IAAdC,KAAc;IAAdA,KAAc,GAAN,IAAM;EAAA;;EACrE,IAAIC,IAAJ,EAAUC,UAAV;EAEA,OAAO,SAASC,SAAT,GAAqB;IAC3B,IAAIC,OAAO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EAILjC,OAJK,CAIG,MAJH,EAIW,EAJX,CAAP;AAKA,CARM;AAUP,eAAe;EACdC,QAAQ,EAAEA,QADI;EAEde,QAAQ,EAAEA,QAFI;EAGdO,OAAO,EAAEA,OAHK;EAIdE,YAAY,EAAEA,YAJA;EAKdG,SAAS,EAAEA;AALG,CAAf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-digital/nds-core",
3
- "version": "4.0.1-alpha.0",
3
+ "version": "4.0.2",
4
4
  "description": "Core code for the NICE Design System",
5
5
  "author": "Ian Routledge <ian.routledge@nice.org.uk>",
6
6
  "contributors": [
@@ -46,5 +46,5 @@
46
46
  "@types/node": "^18.11.9",
47
47
  "typescript": "^4.8.4"
48
48
  },
49
- "gitHead": "e75957040c9acfbd7eeb164cad724e3b48760679"
49
+ "gitHead": "d8feb7beba5fffa49da42d6a550cb8f67a50727d"
50
50
  }
@@ -105,9 +105,17 @@ $filter-option-text-before-border: global.$black-tint-1;
105
105
  $filter-input-controls-border: global.$custom-grey-2;
106
106
 
107
107
  // Full bleed
108
- $full-bleed-background: global.$white;
109
- $full-bleed-light-background: global.$nice-teal;
110
- $full-bleed-light-text: global.$white;
108
+ $full-bleed-background: global.$nice-teal;
109
+ $full-bleed-background-dark: global.$nice-blue;
110
+ $full-bleed-background-light: global.$nice-cream-1;
111
+ $full-bleed-background-image-dark: global.$nice-black;
112
+ $full-bleed-background-image-light: global.$white;
113
+ $full-bleed-text: global.$white;
114
+ $full-bleed-text-dark: global.$white;
115
+ $full-bleed-text-light: global.$nice-black;
116
+ $full-bleed-text-transparent: global.$nice-black;
117
+ $full-bleed-text-image-dark: global.$white;
118
+ $full-bleed-text-image-light: global.$nice-black;
111
119
 
112
120
  // Hero
113
121
  $hero-background: global.$nice-blue-tint-1;
@@ -1 +0,0 @@
1
- export {};
package/es/utils.test.js DELETED
@@ -1,64 +0,0 @@
1
- "use strict";
2
- /* eslint-env node, mocha, jquery */
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const utils_1 = require("./utils");
5
- describe("Utils", function () {
6
- describe("slugify", function () {
7
- it("lowercases the input", function () {
8
- let s = (0, utils_1.slugify)("DOGBONE");
9
- expect(s).toEqual("dogbone");
10
- });
11
- it("replaces space characters with dashes", function () {
12
- let s = (0, utils_1.slugify)("dog bone");
13
- expect(s).toEqual("dog-bone");
14
- });
15
- it("replaces multiple space characters with single dash", function () {
16
- let s = (0, utils_1.slugify)("dog bone");
17
- expect(s).toEqual("dog-bone");
18
- });
19
- it("replaces multiple dash characters with single dash", function () {
20
- let s = (0, utils_1.slugify)("dog--bone");
21
- expect(s).toEqual("dog-bone");
22
- });
23
- it("replaces ampersands with the word 'and'", function () {
24
- let s = (0, utils_1.slugify)("dog & bone");
25
- expect(s).toEqual("dog-and-bone");
26
- });
27
- it("replaces non word characters", function () {
28
- let s = (0, utils_1.slugify)("dog () & * bone 2");
29
- expect(s).toEqual("dog-and-bone-2");
30
- });
31
- it("removes dashes from the start", function () {
32
- let s = (0, utils_1.slugify)("* dog");
33
- expect(s).toEqual("dog");
34
- });
35
- it("removes dashes from the end", function () {
36
- let s = (0, utils_1.slugify)("dog *");
37
- expect(s).toEqual("dog");
38
- });
39
- });
40
- describe("nextUniqueId", function () {
41
- it("prefixes with 'uid' by default", function () {
42
- expect((0, utils_1.nextUniqueId)().indexOf("uid-")).toEqual(0);
43
- });
44
- it("prefixes with the given prefix", function () {
45
- expect((0, utils_1.nextUniqueId)("test").indexOf("test-")).toEqual(0);
46
- });
47
- it("increments counter on subsequent calls", function () {
48
- const idA = (0, utils_1.nextUniqueId)().match(/\d+/), idB = (0, utils_1.nextUniqueId)().match(/\d+/);
49
- let a = Number(idA ? idA[0] : null), b = Number(idB ? idB[0] : null);
50
- expect(b).toEqual(a + 1);
51
- });
52
- });
53
- describe("camelCase", function () {
54
- it("turns a Title Case string into a camelCase string", function () {
55
- expect((0, utils_1.camelCase)("Title Case")).toEqual("titleCase");
56
- });
57
- it("turns a Sentence case string into a camelCase string", function () {
58
- expect((0, utils_1.camelCase)("Sentence case")).toEqual("sentenceCase");
59
- });
60
- it("turns a kebab-case string into a camelCase string", function () {
61
- expect((0, utils_1.camelCase)("this-is-kebab-case")).toEqual("thisIsKebabCase");
62
- });
63
- });
64
- });