@panneau/core 5.0.0-alpha.15 → 5.0.0-alpha.16
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/form/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/form/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAmCrD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAE9D"}
|
package/dist/form/messages.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
//#region src/form/messages.ts
|
|
2
|
+
/** `YouTube, Vimeo or Spotify`. */
|
|
3
|
+
function orList(items) {
|
|
4
|
+
return items.length > 1 ? `${items.slice(0, -1).join(", ")} or ${String(items.at(-1))}` : items[0] ?? "";
|
|
5
|
+
}
|
|
2
6
|
var MESSAGES = {
|
|
3
7
|
required: () => "This field is required.",
|
|
4
8
|
min: (failure) => `This value must be at least ${String(failure.value)}.`,
|
|
@@ -8,11 +12,15 @@ var MESSAGES = {
|
|
|
8
12
|
url: () => "This value must be a URL.",
|
|
9
13
|
json: () => "This value must be valid JSON: an object or an array.",
|
|
10
14
|
tel: () => "This value must be a complete phone number.",
|
|
15
|
+
postalCode: () => "This value must be a postal code of its country.",
|
|
16
|
+
daterange: (failure) => failure.value === "start" ? "Give the start of this range." : failure.value === "end" ? "Give the end of this range." : "The end can’t be before the start.",
|
|
17
|
+
money: () => "This value must be an amount in one of the allowed currencies.",
|
|
11
18
|
in: () => "This value is not one of the choices.",
|
|
12
19
|
accept: () => "This file type is not accepted.",
|
|
13
20
|
maxSize: () => "This file is too large.",
|
|
14
21
|
before: () => "This date is too late.",
|
|
15
|
-
after: () => "This date is too early."
|
|
22
|
+
after: () => "This date is too early.",
|
|
23
|
+
providers: (failure) => `This embed must come from ${orList(Array.isArray(failure.value) ? failure.value.map(String) : [])}.`
|
|
16
24
|
};
|
|
17
25
|
/**
|
|
18
26
|
* The message of a failed rule: the rule's own `message`, or a default English message. Forms
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.js","names":["RuleFailure","MESSAGES","Record","failure","required","min","
|
|
1
|
+
{"version":3,"file":"messages.js","names":["RuleFailure","orList","items","length","slice","join","String","at","MESSAGES","Record","failure","required","min","value","max","pattern","email","url","json","tel","postalCode","daterange","money","in","accept","maxSize","before","after","providers","Array","isArray","map","formatRuleFailure","message","rule"],"sources":["../../src/form/messages.ts"],"sourcesContent":["import type { RuleFailure } from '@panneau/protocol';\n\n/** `YouTube, Vimeo or Spotify`. */\nfunction orList(items: readonly string[]): string {\n return items.length > 1\n ? `${items.slice(0, -1).join(', ')} or ${String(items.at(-1))}`\n : (items[0] ?? '');\n}\n\nconst MESSAGES: Record<string, (failure: RuleFailure) => string> = {\n required: () => 'This field is required.',\n min: (failure) => `This value must be at least ${String(failure.value)}.`,\n max: (failure) => `This value must be at most ${String(failure.value)}.`,\n pattern: () => 'This value has an invalid format.',\n email: () => 'This value must be an email address.',\n url: () => 'This value must be a URL.',\n json: () => 'This value must be valid JSON: an object or an array.',\n tel: () => 'This value must be a complete phone number.',\n postalCode: () => 'This value must be a postal code of its country.',\n daterange: (failure) =>\n failure.value === 'start'\n ? 'Give the start of this range.'\n : failure.value === 'end'\n ? 'Give the end of this range.'\n : 'The end can’t be before the start.',\n money: () => 'This value must be an amount in one of the allowed currencies.',\n in: () => 'This value is not one of the choices.',\n accept: () => 'This file type is not accepted.',\n maxSize: () => 'This file is too large.',\n before: () => 'This date is too late.',\n after: () => 'This date is too early.',\n providers: (failure) =>\n `This embed must come from ${orList(Array.isArray(failure.value) ? failure.value.map(String) : [])}.`,\n};\n\n/**\n * The message of a failed rule: the rule's own `message`, or a default English message. Forms\n * take a `formatError` option to translate them.\n */\nexport function formatRuleFailure(failure: RuleFailure): string {\n return failure.message ?? MESSAGES[failure.rule]?.(failure) ?? 'This value is invalid.';\n}\n"],"mappings":";;AAGA,SAASC,OAAOC,OAAkC;CAC9C,OAAOA,MAAMC,SAAS,IAChB,GAAGD,MAAME,MAAM,GAAG,EAAE,CAAC,CAACC,KAAK,IAAI,EAAC,MAAOC,OAAOJ,MAAMK,GAAG,EAAE,CAAC,MACzDL,MAAM,MAAM;AACvB;AAEA,IAAMM,WAA6D;CAC/DG,gBAAgB;CAChBC,MAAMF,YAAY,+BAA+BJ,OAAOI,QAAQG,KAAK,EAAC;CACtEC,MAAMJ,YAAY,8BAA8BJ,OAAOI,QAAQG,KAAK,EAAC;CACrEE,eAAe;CACfC,aAAa;CACbC,WAAW;CACXC,YAAY;CACZC,WAAW;CACXC,kBAAkB;CAClBC,YAAYX,YACRA,QAAQG,UAAU,UACZ,kCACAH,QAAQG,UAAU,QAChB,gCACA;CACZS,aAAa;CACbC,UAAU;CACVC,cAAc;CACdC,eAAe;CACfC,cAAc;CACdC,aAAa;CACbC,YAAYlB,YACR,6BAA6BT,OAAO4B,MAAMC,QAAQpB,QAAQG,KAAK,IAAIH,QAAQG,MAAMkB,IAAIzB,MAAM,IAAI,CAAA,CAAE,EAAC;AAC1G;;;;;AAMA,SAAgB0B,kBAAkBtB,SAA8B;CAC5D,OAAOA,QAAQuB,WAAWzB,SAASE,QAAQwB,KAAK,GAAGxB,OAAO,KAAK;AACnE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/core",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.16",
|
|
4
4
|
"description": "The engine of Panneau: plugin registry, definition to forms and lists, form and list state, with React hooks. No UI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -33,6 +33,6 @@
|
|
|
33
33
|
"react": "^19.2.0"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@panneau/protocol": "5.0.0-alpha.
|
|
36
|
+
"@panneau/protocol": "5.0.0-alpha.16"
|
|
37
37
|
}
|
|
38
38
|
}
|