From 8b20b6d84ee9e296ee9107eda8831aa9a18b3589 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 5 Aug 2024 12:18:53 -0300 Subject: data: thingList --- src/data/composite/wiki-properties/thingList.js | 44 +++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/data/composite/wiki-properties/thingList.js (limited to 'src/data/composite/wiki-properties/thingList.js') diff --git a/src/data/composite/wiki-properties/thingList.js b/src/data/composite/wiki-properties/thingList.js new file mode 100644 index 00000000..f4c00e06 --- /dev/null +++ b/src/data/composite/wiki-properties/thingList.js @@ -0,0 +1,44 @@ +// A list of Things, provided directly rather than by reference. +// +// Essentially the same as wikiData, but exposes the list of things, +// instead of keeping it private. + +import {input, templateCompositeFrom} from '#composite'; +import {isThingClass, validateWikiData} from '#validators'; + +import {exposeConstant, exposeUpdateValueOrContinue} + from '#composite/control-flow'; + +export default templateCompositeFrom({ + annotation: `wikiData`, + + compose: false, + + inputs: { + class: input.staticValue({ + validate: isThingClass, + defaultValue: null, + }), + }, + + update: ({ + [input.staticValue('class')]: thingClass, + }) => ({ + validate: + validateWikiData({ + referenceType: + (thingClass + ? thingClass[Symbol.for('Thing.referenceType')] + : ''), + }), + }), + + steps: () => [ + exposeUpdateValueOrContinue(), + + exposeConstant({ + value: input.value([]), + }), + ], +}); + -- cgit 1.3.0-6-gf8a5