diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-08-05 12:18:53 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-08-05 20:42:08 -0300 |
commit | 8b20b6d84ee9e296ee9107eda8831aa9a18b3589 (patch) | |
tree | 823a3cb7dc9c77dfaf29dd037c40b57ef430003c /src/data/composite/wiki-properties/thingList.js | |
parent | 515943d866f816db010983651b94b829bec11905 (diff) |
data: thingList
Diffstat (limited to 'src/data/composite/wiki-properties/thingList.js')
-rw-r--r-- | src/data/composite/wiki-properties/thingList.js | 44 |
1 files changed, 44 insertions, 0 deletions
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([]), + }), + ], +}); + |