// // Copyright © 2020, 2021 Anticrm Platform Contributors. // Copyright © 2021 Hardcore Engineering Inc. // // Licensed under the Eclipse Public License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. You may // obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // // See the License for the specific language governing permissions and // limitations under the License. // import type { AnyAttribute, Class, Client, Doc, DocumentQuery, FindOptions, Mixin, Obj, Ref, Space, UXObject } from '@anticrm/core' import type { Asset, IntlString, Plugin, Resource, Status } from '@anticrm/platform' import { plugin } from '@anticrm/platform' import type { AnyComponent, AnySvelteComponent } from '@anticrm/ui' /** * @public */ export interface AttributeEditor extends Class { editor: AnyComponent } /** * @public */ export interface AttributePresenter extends Class { presenter: AnyComponent } /** * @public */ export interface ObjectEditor extends Class { editor: AnyComponent } /** * @public */ export interface ObjectEditorHeader extends Class { editor: AnyComponent } /** * @public */ export interface ObjectValidator extends Class { validator: Resource<(doc: T, client: Client) => Promise> } /** * @public */ export interface ViewletDescriptor extends Doc, UXObject { component: AnyComponent } /** * @public */ export interface Viewlet extends Doc { attachTo: Ref> descriptor: Ref options?: FindOptions config: any } /** * @public */ export interface Action extends Doc, UXObject { action: Resource<(doc: Doc) => Promise> } /** * @public */ export interface ActionTarget extends Doc { target: Ref> action: Ref query?: DocumentQuery } /** * @public */ export interface IgnoreActions extends Class { actions: Ref[] } /** * @public */ export interface HTMLPresenter extends Class { presenter: Resource<(doc: Doc) => string> } /** * @public */ export interface TextPresenter extends Class { presenter: Resource<(doc: Doc) => string> } /** * @public */ export const viewId = 'view' as Plugin /** * @public */ export interface BuildModelKey { key: string presenter?: AnyComponent // A set of extra props passed to presenter. props?: Record label?: IntlString sortingKey?: string // On client sorting function sortingFunction?: (a: Doc, b: Doc) => number } /** * @public */ export interface AttributeModel { key: string label: IntlString _class: Ref> presenter: AnySvelteComponent // Extra properties for component props?: Record sortingKey: string // Extra icon if applicable icon?: Asset attribute?: AnyAttribute } /** * @public */ export interface BuildModelOptions { client: Client _class: Ref> keys: (BuildModelKey | string)[] options?: FindOptions ignoreMissing?: boolean } /** * Define document create popup widget * * @public * */ export interface ObjectFactory extends Class { component: AnyComponent } /** * @public */ const view = plugin(viewId, { mixin: { AttributeEditor: '' as Ref>, AttributePresenter: '' as Ref>, ObjectEditor: '' as Ref>, ObjectEditorHeader: '' as Ref>, ObjectValidator: '' as Ref>, ObjectFactory: '' as Ref>, IgnoreActions: '' as Ref>, HTMLPresenter: '' as Ref>, TextPresenter: '' as Ref> }, class: { ViewletDescriptor: '' as Ref>, Viewlet: '' as Ref>, Action: '' as Ref>, ActionTarget: '' as Ref> }, viewlet: { Table: '' as Ref }, component: { ObjectPresenter: '' as AnyComponent, EditDoc: '' as AnyComponent }, icon: { Table: '' as Asset, Delete: '' as Asset, MoreH: '' as Asset, Move: '' as Asset, Archive: '' as Asset, Statuses: '' as Asset } }) export default view