@defra/forms-model 3.0.214 → 3.0.216
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.
@@ -1,4 +1,3 @@
|
|
1
|
-
import { customAlphabet } from 'nanoid';
|
2
1
|
import slug from 'slug';
|
3
2
|
export const serialiseAndDeserialise = obj => {
|
4
3
|
if (typeof obj === 'object' && obj !== null) {
|
@@ -35,5 +34,4 @@ export function slugify(input = '') {
|
|
35
34
|
lower: true
|
36
35
|
});
|
37
36
|
}
|
38
|
-
export const nanoid = customAlphabet('0123456789_abcdefghijklmnopqrstuvwxyz', 6);
|
39
37
|
//# sourceMappingURL=helpers.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.js","names":["
|
1
|
+
{"version":3,"file":"helpers.js","names":["slug","serialiseAndDeserialise","obj","JSON","parse","stringify","clone","filter","predicate","result","key","value","Object","entries","slugify","input","string","trim","replace","lower"],"sources":["../../../src/utils/helpers.ts"],"sourcesContent":["import slug from 'slug'\n\nexport const serialiseAndDeserialise = <T>(obj: T): T => {\n if (typeof obj === 'object' && obj !== null) {\n return JSON.parse(JSON.stringify(obj))\n }\n\n return obj\n}\n\nexport const clone = <T>(obj: T & { clone?: () => T }): T => {\n if (obj) {\n if (typeof obj.clone === 'function') {\n return obj.clone()\n }\n\n return serialiseAndDeserialise<T>(obj)\n }\n return obj\n}\n\nexport function filter<T extends Record<string, unknown>>(\n obj: T,\n predicate: (value: any) => boolean\n): Partial<T> {\n const result = {}\n\n for (const [key, value] of Object.entries(obj)) {\n if (value && predicate(value)) {\n result[key] = value\n }\n }\n\n return result\n}\n\n/**\n * Replace spaces, en-dashes and em-dashes with hyphens\n * before running through the slug package\n */\nexport function slugify(input = '') {\n const string = input.trim().replace(/[\\s–—]/g, '-')\n return slug(string, { lower: true })\n}\n"],"mappings":"AAAA,OAAOA,IAAI,MAAM,MAAM;AAEvB,OAAO,MAAMC,uBAAuB,GAAOC,GAAM,IAAQ;EACvD,IAAI,OAAOA,GAAG,KAAK,QAAQ,IAAIA,GAAG,KAAK,IAAI,EAAE;IAC3C,OAAOC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,SAAS,CAACH,GAAG,CAAC,CAAC;EACxC;EAEA,OAAOA,GAAG;AACZ,CAAC;AAED,OAAO,MAAMI,KAAK,GAAOJ,GAA4B,IAAQ;EAC3D,IAAIA,GAAG,EAAE;IACP,IAAI,OAAOA,GAAG,CAACI,KAAK,KAAK,UAAU,EAAE;MACnC,OAAOJ,GAAG,CAACI,KAAK,CAAC,CAAC;IACpB;IAEA,OAAOL,uBAAuB,CAAIC,GAAG,CAAC;EACxC;EACA,OAAOA,GAAG;AACZ,CAAC;AAED,OAAO,SAASK,MAAMA,CACpBL,GAAM,EACNM,SAAkC,EACtB;EACZ,MAAMC,MAAM,GAAG,CAAC,CAAC;EAEjB,KAAK,MAAM,CAACC,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACX,GAAG,CAAC,EAAE;IAC9C,IAAIS,KAAK,IAAIH,SAAS,CAACG,KAAK,CAAC,EAAE;MAC7BF,MAAM,CAACC,GAAG,CAAC,GAAGC,KAAK;IACrB;EACF;EAEA,OAAOF,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACA,OAAO,SAASK,OAAOA,CAACC,KAAK,GAAG,EAAE,EAAE;EAClC,MAAMC,MAAM,GAAGD,KAAK,CAACE,IAAI,CAAC,CAAC,CAACC,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;EACnD,OAAOlB,IAAI,CAACgB,MAAM,EAAE;IAAEG,KAAK,EAAE;EAAK,CAAC,CAAC;AACtC","ignoreList":[]}
|
@@ -8,5 +8,4 @@ export declare function filter<T extends Record<string, unknown>>(obj: T, predic
|
|
8
8
|
* before running through the slug package
|
9
9
|
*/
|
10
10
|
export declare function slugify(input?: string): string;
|
11
|
-
export declare const nanoid: (size?: number | undefined) => string;
|
12
11
|
//# sourceMappingURL=helpers.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/helpers.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/helpers.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,uBAAuB,GAAI,CAAC,OAAO,CAAC,KAAG,CAMnD,CAAA;AAED,eAAO,MAAM,KAAK,GAAI,CAAC,OAAO,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC,CAAA;CAAE,KAAG,CASvD,CAAA;AAED,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtD,GAAG,EAAE,CAAC,EACN,SAAS,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,OAAO,GACjC,OAAO,CAAC,CAAC,CAAC,CAUZ;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,SAAK,UAGjC"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@defra/forms-model",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.216",
|
4
4
|
"description": "A hapi plugin providing the model for Defra forms",
|
5
5
|
"homepage": "https://github.com/DEFRA/forms-designer/tree/main/model#readme",
|
6
6
|
"repository": {
|
@@ -24,12 +24,10 @@
|
|
24
24
|
"slug": "^9.1.0"
|
25
25
|
},
|
26
26
|
"devDependencies": {
|
27
|
-
"joi": "^17.13.3"
|
28
|
-
"nanoid": "^3.3.7"
|
27
|
+
"joi": "^17.13.3"
|
29
28
|
},
|
30
29
|
"peerDependencies": {
|
31
|
-
"joi": "^17.0.0"
|
32
|
-
"nanoid": "^3.0.0"
|
30
|
+
"joi": "^17.0.0"
|
33
31
|
},
|
34
32
|
"engines": {
|
35
33
|
"node": "^20.9.0",
|
package/src/utils/helpers.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { customAlphabet } from 'nanoid'
|
2
1
|
import slug from 'slug'
|
3
2
|
|
4
3
|
export const serialiseAndDeserialise = <T>(obj: T): T => {
|
@@ -43,5 +42,3 @@ export function slugify(input = '') {
|
|
43
42
|
const string = input.trim().replace(/[\s–—]/g, '-')
|
44
43
|
return slug(string, { lower: true })
|
45
44
|
}
|
46
|
-
|
47
|
-
export const nanoid = customAlphabet('0123456789_abcdefghijklmnopqrstuvwxyz', 6)
|