@nice-digital/nds-core 4.0.2 → 4.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice-digital/nds-core",
3
- "version": "4.0.2",
3
+ "version": "4.0.4",
4
4
  "description": "Core code for the NICE Design System",
5
5
  "author": "Ian Routledge <ian.routledge@nice.org.uk>",
6
6
  "contributors": [
@@ -10,6 +10,7 @@
10
10
  "homepage": "https://design-system.nice.org.uk/",
11
11
  "license": "MIT",
12
12
  "main": "es/core.js",
13
+ "types": "es/core.d.ts",
13
14
  "style": "scss/core.scss",
14
15
  "directories": {
15
16
  "lib": "es"
@@ -31,7 +32,7 @@
31
32
  "url": "https://github.com/nice-digital/nice-design-system/issues"
32
33
  },
33
34
  "dependencies": {
34
- "@nice-digital/icons": "^6.0.0-alpha.0",
35
+ "@nice-digital/icons": "^6.0.0",
35
36
  "sass-mq": "^6.0.0"
36
37
  },
37
38
  "peerDependencies": {
@@ -46,5 +47,5 @@
46
47
  "@types/node": "^18.11.9",
47
48
  "typescript": "^4.8.4"
48
49
  },
49
- "gitHead": "d8feb7beba5fffa49da42d6a550cb8f67a50727d"
50
+ "gitHead": "c8db07e6492c3b18564bd4f46c2ab098f185109a"
50
51
  }
@@ -18,18 +18,6 @@ $base-line-height: 1.6;
18
18
  /// @since 3.0.0
19
19
  $link-hover-text-decoration-thickness: 0.1rem;
20
20
 
21
- /// Sans-serif font stack
22
- /// @since 2.0.0
23
- $font-family-sans: 'Inter, Roboto, "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif';
24
-
25
- /// Serif font stack
26
- /// @since 2.0.0
27
- $font-family-serif: 'Lora, Georgia, Times, serif';
28
-
29
- /// Mono font stack
30
- /// @since 0.2.0
31
- $font-family-mono: 'Monaco, Menlo, Consolas, "Courier New", monospace';
32
-
33
21
  /// The font families in use across NICE.
34
22
  /// @prop {Font stack} sans [Inter, Helvetica Neue, Helvetica, Arial, sans-serif] The sans-serif font stack
35
23
  /// @prop {Font stack} serif [Lora, Georgia, Times, serif] The serif font stack
@@ -37,9 +25,9 @@ $font-family-mono: 'Monaco, Menlo, Consolas, "Courier New", monospace';
37
25
  /// @see font-family
38
26
  /// @since 0.2.0
39
27
  $font-families: (
40
- sans: $font-family-sans,
41
- serif: $font-family-serif,
42
- mono: $font-family-mono
28
+ sans: var(--sans-font-family),
29
+ serif: var(--serif-font-family),
30
+ mono: var(--mono-font-family)
43
31
  );
44
32
 
45
33
  /// The modular scale ratio to use for typography
@@ -1 +0,0 @@
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 DELETED
@@ -1 +0,0 @@
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"}
package/es/utils.js.map DELETED
@@ -1 +0,0 @@
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,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