@seidhr/sanity-plugin-muna-schemas
Version:
Muna or ᛗᚢᚾᚨ means remember in norse. Muna is a schema for the Sanity Studio that enables detailed descriptions of cultural heritage objects and knowledge about their contexts as well as pages about them (or anything else really.)
357 lines (339 loc) • 10.1 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _jsonata = _interopRequireDefault(require("jsonata"));
var _fa = require("react-icons/fa");
var _coalesceLabel = require("../../../../helpers/coalesceLabel");
var _datatype = require("../../../properties/datatype");
var _object = require("../../../properties/object");
var _sanityPluginHotspotArray = _interopRequireDefault(require("sanity-plugin-hotspot-array"));
var _hotspotPreview = _interopRequireDefault(require("../../../../previews/hotspotPreview"));
var _depictsFunctional = require("../../../properties/object/depictsFunctional");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
var _default = {
name: 'HumanMadeObject',
type: 'document',
title: 'Objekt',
titleEN: 'Made Object',
description: 'Menneskapte objekt',
initialValue: {
editorialState: 'review',
accessState: 'secret'
},
icon: _fa.FaBookDead,
fieldsets: [{
name: 'state',
title: 'Status',
options: {
collapsible: true,
collapsed: false,
columns: 2
}
}, {
name: 'core',
title: 'Basic metadata',
options: {
collapsible: true,
collapsed: false
}
}, {
name: 'mainImage',
title: 'Hovedbilde',
options: {
collapsible: true,
collapsed: false
}
}, {
name: 'representation',
title: 'Alle bilder',
options: {
collapsible: true,
collapsed: false
}
}, {
name: 'relations',
title: 'Relations to other stuff',
options: {
collapsible: true,
collapsed: false
}
}, {
name: 'partsAndContent',
title: 'Felt relatert til deler eller innhold',
options: {
collapsible: true,
collapsed: false
}
}, {
name: 'physicalDescription',
title: 'Felt relatert til fysisk beskrivelse',
options: {
collapsible: true,
collapsed: false
}
}, {
name: 'ownership',
title: 'Felt relatert til eierskap',
options: {
collapsible: true,
collapsed: false
}
}],
groups: [{
name: 'core',
title: 'Core',
default: true
}, {
name: 'relations',
title: 'Relations'
}, {
name: 'partsAndContent',
title: 'Parts'
}, {
name: 'images',
title: 'Images'
}, {
name: 'physical',
title: 'Physical'
}, {
name: 'ownership',
title: 'Ownership'
}],
fields: [_objectSpread(_objectSpread({}, _datatype.editorialState), {}, {
group: 'core'
}), _objectSpread(_objectSpread({}, _datatype.accessState), {}, {
group: 'core'
}), _objectSpread(_objectSpread({}, _datatype.preferredIdentifier), {}, {
group: 'core'
}), _objectSpread(_objectSpread({}, _datatype.label), {}, {
group: 'core'
}), _objectSpread(_objectSpread({}, _datatype.homepage), {}, {
group: 'core'
}), {
name: 'hasType',
type: 'array',
title: 'Klassifisert som',
titleEN: 'Classified as',
fieldset: 'core',
group: 'core',
of: [{
type: 'reference',
to: [{
type: 'ObjectType'
}]
}],
validation: Rule => Rule.required(),
options: {
semanticSanity: {
'@container': '@set',
'@type': '@id'
}
}
}, _objectSpread(_objectSpread({}, _object.identifiedBy), {}, {
fieldset: 'core',
group: 'core'
}), _objectSpread(_objectSpread({}, _object.referredToBy), {}, {
fieldset: 'core',
group: 'core'
}), {
name: 'activityStream',
title: 'Aktivitetsstrøm',
titleEN: 'Activity stream',
description: 'Hendelser og aktiviteter knyttet til dette objektet.',
descriptionEN: 'Events and activities connected to this object',
fieldset: 'core',
group: 'core',
type: 'array',
of: [{
type: 'BeginningOfExistence'
}, {
type: 'Production'
}, {
type: 'Transformation'
}, {
type: 'reference',
to: [{
type: 'Acquisition'
}]
}, {
type: 'Move'
}, {
type: 'Activity'
}, {
type: 'Destruction'
}],
options: {
semanticSanity: {
'@container': '@list',
'@type': '@id'
}
}
}, _objectSpread(_objectSpread({}, _object.subject), {}, {
fieldset: 'core',
group: 'core'
}), _objectSpread(_objectSpread({}, _object.subjectOf), {}, {
fieldset: 'core',
group: 'core'
}), _objectSpread(_objectSpread({}, _datatype.license), {}, {
fieldset: 'core',
group: 'core'
}), _objectSpread(_objectSpread({}, _object.image), {}, {
fieldset: 'mainImage',
group: 'images'
}), {
name: "mainImageAnnotations",
type: "array",
fieldset: 'mainImage',
group: 'images',
inputComponent: _sanityPluginHotspotArray.default,
of: [{
name: 'point',
type: 'object',
fieldsets: [{
name: 'position',
options: {
columns: 2
}
}],
fields: [{
name: 'label',
type: 'text',
rows: 2
}, _depictsFunctional.depictsFunctional, {
name: 'x',
type: 'number',
readOnly: true,
fieldset: 'position',
initialValue: 50,
validation: Rule => Rule.required().min(0).max(100)
}, {
name: 'y',
type: 'number',
readOnly: true,
fieldset: 'position',
initialValue: 50,
validation: Rule => Rule.required().min(0).max(100)
}],
preview: {
select: {
title: 'label',
x: 'x',
y: 'y'
},
prepare(_ref) {
var title = _ref.title,
x = _ref.x,
y = _ref.y;
return {
title,
subtitle: x && y ? "".concat(x, "% x ").concat(y, "%") : "No position set"
};
}
}
}],
options: {
hotspotImagePath: "image",
hotspotDescriptionPath: "label",
hotspotTooltip: _hotspotPreview.default
}
}, _objectSpread(_objectSpread({}, _object.digitallyShownBy), {}, {
fieldset: 'representation',
group: 'images'
}), _objectSpread(_objectSpread({}, _object.subjectOfManifest), {}, {
fieldset: 'representation',
group: 'images'
}), _objectSpread(_objectSpread({}, _object.relation), {}, {
fieldset: 'relations',
group: 'relations'
}), _objectSpread(_objectSpread({}, _object.presentAt), {}, {
fieldset: 'relations',
group: 'relations'
}), _objectSpread(_objectSpread({}, _object.depicts), {}, {
fieldset: 'partsAndContent',
group: 'partsAndContent'
}), _objectSpread(_objectSpread({}, _object.showsVisualObject), {}, {
fieldset: 'partsAndContent',
group: 'partsAndContent'
}), _objectSpread(_objectSpread({}, _object.carries), {}, {
fieldset: 'partsAndContent',
group: 'partsAndContent'
}), _objectSpread(_objectSpread({}, _object.composedOf), {}, {
fieldset: 'partsAndContent',
group: 'partsAndContent'
}), _objectSpread(_objectSpread({}, _object.measuredBy), {}, {
fieldset: 'physicalDescription',
group: 'physical'
}), _objectSpread(_objectSpread({}, _object.consistsOf), {}, {
fieldset: 'physicalDescription',
group: 'physical'
}), _objectSpread(_objectSpread({}, _object.hasCurrentOwner), {}, {
fieldset: 'ownership',
group: 'ownership'
}), _objectSpread(_objectSpread({}, _object.hasFormerOrCurrentOwner), {}, {
fieldset: 'ownership',
group: 'ownership'
}), _object.wasOutputOf],
preview: {
select: {
title: 'label',
id: 'preferredIdentifier',
type: 'hasType.0.label',
blocks: 'description',
media: 'image',
published: 'accessState'
},
prepare(selection) {
var title = selection.title,
id = selection.id,
type = selection.type,
blocks = selection.blocks,
media = selection.media,
published = selection.published;
var expression = (0, _jsonata.default)('nor[0]');
var block = expression.evaluate(blocks);
var secret = published === 'secret' ? '🔒' : '';
return {
title: (0, _coalesceLabel.coalesceLabel)(title),
subtitle: secret + (id ? "".concat(id, ", ") : '') + (0, _coalesceLabel.coalesceLabel)(type),
description: block ? block.children.filter(child => child._type === 'span').map(span => span.text).join('') : '',
media: media
};
}
},
orderings: [{
title: 'Tittel, A-Å',
name: 'label',
by: [{
field: 'label',
direction: 'asc'
}]
}, {
title: 'Tittel, Å-A',
name: 'label',
by: [{
field: 'label',
direction: 'desc'
}]
}, {
title: 'Foretrukket id, Synkende',
name: 'preferredIdentifier',
by: [{
field: 'preferredIdentifier',
direction: 'desc'
}]
}, {
title: 'Foretrukket id, Stigende',
name: 'preferredIdentifier',
by: [{
field: 'preferredIdentifier',
direction: 'asc'
}]
}]
};
exports.default = _default;
//# sourceMappingURL=HumanMadeObject.js.map