UNPKG

alinea

Version:

[![npm](https://img.shields.io/npm/v/alinea.svg)](https://npmjs.org/package/alinea) [![install size](https://packagephobia.com/badge?p=alinea)](https://packagephobia.com/result?p=alinea)

205 lines (203 loc) 5.24 kB
import "../../chunks/chunk-U5RRZUYZ.js"; // src/input/link/LinkConstructors.ts import { Media } from "alinea/backend/Media"; import { Entry } from "alinea/core/Entry"; import { Hint } from "alinea/core/Hint"; import { MediaFile } from "alinea/core/media/MediaSchema"; import { createLink, createLinks } from "alinea/input/link/LinkField"; import { entryFields, entryPicker, fileFields, imageFields } from "alinea/picker/entry"; import { urlPicker } from "alinea/picker/url"; var imageCondition = Entry.type.is("MediaFile").and(MediaFile.extension.isIn(Media.imageExtensions)); function imagePicker(multiple, options) { return entryPicker({ ...options, hint: Hint.Extern({ name: "ImageReference", package: "alinea/picker/entry" }), max: multiple ? void 0 : 1, label: "Image", title: multiple ? "Select images" : "Select an image", condition: imageCondition.or(Entry.type.is("MediaLibrary")), showMedia: true, defaultView: "thumb", selection: imageFields }); } var fileCondition = Entry.type.is("MediaFile").and(MediaFile.extension.isNotIn(Media.imageExtensions)); function filePicker(multiple, options) { return entryPicker({ ...options, hint: Hint.Extern({ name: "FileReference", package: "alinea/picker/entry" }), max: multiple ? void 0 : 1, label: "File", title: multiple ? "Select files" : "Select a file", condition: fileCondition.or(Entry.type.is("MediaLibrary")), showMedia: true, defaultView: "thumb", selection: fileFields }); } function link(label, options = {}) { return createLink(label, { ...options, pickers: { entry: entryPicker({ ...options, hint: Hint.Extern({ name: "EntryReference", package: "alinea/picker/entry" }), title: "Select a page", max: 1, selection: entryFields }), url: urlPicker(options), file: filePicker(false, options) } }); } ((link2) => { function multiple(label, options = {}) { return createLinks(label, { ...options, pickers: { entry: entryPicker({ ...options, hint: Hint.Extern({ name: "EntryReference", package: "alinea/picker/entry" }), title: "Select a page", selection: entryFields }), url: urlPicker(options), file: filePicker(true, options) } }); } link2.multiple = multiple; })(link || (link = {})); ((link2) => { function entry(label, options = {}) { return createLink(label, { ...options, pickers: { entry: entryPicker({ ...options, withNavigation: !options.condition, hint: Hint.Extern({ name: "EntryReference", package: "alinea/picker/entry" }), title: "Select a page", max: 1, selection: entryFields }) } }); } link2.entry = entry; })(link || (link = {})); ((link2) => { let entry; ((entry2) => { function multiple(label, options = {}) { return createLinks(label, { ...options, pickers: { entry: entryPicker({ ...options, withNavigation: !options.condition, hint: Hint.Extern({ name: "EntryReference", package: "alinea/picker/entry" }), title: "Select a page", selection: entryFields }) } }); } entry2.multiple = multiple; })(entry = link2.entry || (link2.entry = {})); })(link || (link = {})); ((link2) => { function url(label, options = {}) { return createLink(label, { ...options, pickers: { url: urlPicker(options) } }); } link2.url = url; })(link || (link = {})); ((link2) => { let url; ((url2) => { function multiple(label, options = {}) { return createLinks(label, { ...options, pickers: { url: urlPicker(options) } }); } url2.multiple = multiple; })(url = link2.url || (link2.url = {})); })(link || (link = {})); ((link2) => { function image(label, options = {}) { return createLink(label, { ...options, pickers: { image: imagePicker(false, options) } }); } link2.image = image; })(link || (link = {})); ((link2) => { let image; ((image2) => { function multiple(label, options = {}) { return createLinks(label, { ...options, pickers: { image: imagePicker(true, options) } }); } image2.multiple = multiple; })(image = link2.image || (link2.image = {})); })(link || (link = {})); ((link2) => { function file(label, options = {}) { return createLink(label, { ...options, pickers: { file: filePicker(false, options) } }); } link2.file = file; })(link || (link = {})); ((link2) => { let file; ((file2) => { function multiple(label, options = {}) { return createLinks(label, { ...options, pickers: { file: filePicker(true, options) } }); } file2.multiple = multiple; })(file = link2.file || (link2.file = {})); })(link || (link = {})); export { filePicker, imagePicker, link };