@tablecraft-app/plugin-etcd 1.20.0 → 1.21.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/index.js +21 -6
- package/package.json +1 -1
- package/table-craft-plugin.json +1 -1
package/index.js
CHANGED
|
@@ -5592,12 +5592,17 @@ var connectionFieldSchema = strictObject({
|
|
|
5592
5592
|
group: _enum(CONNECTION_FIELD_GROUPS).optional(),
|
|
5593
5593
|
secret: boolean().optional(),
|
|
5594
5594
|
/**
|
|
5595
|
-
* Draw the field only while the `select` or `checkbox` named by `key` holds `equals
|
|
5596
|
-
* a hidden field is neither checked
|
|
5595
|
+
* Draw the field only while the `select` or `checkbox` named by `key` holds `equals`, or one of
|
|
5596
|
+
* them when it is a list of a select's values (plans 058, 133); a hidden field is neither checked
|
|
5597
|
+
* nor required.
|
|
5597
5598
|
*/
|
|
5598
5599
|
visibleWhen: strictObject({
|
|
5599
5600
|
key: string().regex(FIELD_KEY),
|
|
5600
|
-
equals: union([
|
|
5601
|
+
equals: union([
|
|
5602
|
+
string(),
|
|
5603
|
+
boolean(),
|
|
5604
|
+
array(string()).min(1)
|
|
5605
|
+
])
|
|
5601
5606
|
}).optional()
|
|
5602
5607
|
});
|
|
5603
5608
|
/** `server`: `scheme://user:password@host:port/database?params`; `file`: a path, bare or as a URL. */
|
|
@@ -5709,13 +5714,23 @@ function tlsFieldsDeclared(connection) {
|
|
|
5709
5714
|
return field !== void 0 && tlsFieldFits(role, field, tls);
|
|
5710
5715
|
});
|
|
5711
5716
|
}
|
|
5712
|
-
|
|
5717
|
+
function visibleWhenFits(equals, source) {
|
|
5718
|
+
if (source.kind === "checkbox") return typeof equals === "boolean";
|
|
5719
|
+
if (source.kind !== "select" || typeof equals === "boolean") return false;
|
|
5720
|
+
if (typeof equals === "string") return true;
|
|
5721
|
+
const values = new Set((source.options ?? []).map((option) => option.value));
|
|
5722
|
+
return equals.every((value) => values.has(value));
|
|
5723
|
+
}
|
|
5724
|
+
/**
|
|
5725
|
+
* Every `visibleWhen` names another field of the form, a `select` or a `checkbox`; a list of values
|
|
5726
|
+
* names only a select's declared options.
|
|
5727
|
+
*/
|
|
5713
5728
|
function visibilityFieldsDeclared(connection) {
|
|
5714
5729
|
return connection.fields.every((field) => {
|
|
5715
5730
|
const condition = field.visibleWhen;
|
|
5716
5731
|
if (condition === void 0) return true;
|
|
5717
5732
|
const source = connection.fields.find((candidate) => candidate.key === condition.key);
|
|
5718
|
-
return source !== void 0 && source !== field && (
|
|
5733
|
+
return source !== void 0 && source !== field && visibleWhenFits(condition.equals, source);
|
|
5719
5734
|
});
|
|
5720
5735
|
}
|
|
5721
5736
|
/** Every scheme `url.sets` keys is one of `url.schemes`, and every value it sets is a declared field's. */
|
|
@@ -5758,7 +5773,7 @@ strictObject({
|
|
|
5758
5773
|
message: "tls names a field the form does not declare or one of the wrong kind: mode a select offering every verify mode, files of kind file, the passphrase a secret password",
|
|
5759
5774
|
path: ["tls"]
|
|
5760
5775
|
}).refine(visibilityFieldsDeclared, {
|
|
5761
|
-
message: "visibleWhen names a field the form does not declare, the field itself, or one that is not a select or checkbox, or compares it with a value of the wrong type",
|
|
5776
|
+
message: "visibleWhen names a field the form does not declare, the field itself, or one that is not a select or checkbox, or compares it with a value of the wrong type or a list holding a value the select does not offer",
|
|
5762
5777
|
path: ["fields"]
|
|
5763
5778
|
}).refine(urlSetsDeclared, {
|
|
5764
5779
|
message: "url.sets names a scheme the url does not list, or a field the form does not declare",
|
package/package.json
CHANGED