// // 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 SpaceHeader extends Class { header: AnyComponent } /** * @public */ export interface SpaceName extends Class { getName: Resource<(client: Client, space: Space) => Promise> } /** * @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 * * "Alt + K" =\> Alt and K should be pressed together * "J T" - J and then T shold be pressed. */ export type KeyBinding = string /** * @public */ export type ViewAction = Resource<(doc: Doc | Doc[] | undefined, evt: Event) => Promise> /** * @public */ export interface Action extends Doc, UXObject { keyBinding?: KeyBinding[] action: ViewAction // If specified, action could be used only with one item selected. // By default it is treated as false singleInput?: boolean } /** * Define action to 'object' mapping. * @public */ export interface ActionTarget extends Doc { target: Ref> action: Ref query?: DocumentQuery context: ViewContext // If specified, will be used instead of action from Action. override?: ViewAction } /** * @public * workbench - global actions per application or entire workbench. * browser - actions for list/table/kanban browsing. * editor - actions for selected editor context. * context - only for context menu actions. */ export type ViewContextType = 'context' | 'workbench' | 'browser' | 'editor' | 'panel' | 'popup' | 'context' /** * @public */ export interface ViewContext { mode: ViewContextType | ViewContextType[] // Active application application?: Ref // Optional groupping group?: string } /** * @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 interface PreviewPresenter extends Class { presenter: AnyComponent } /** * @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>, SpaceHeader: '' as Ref>, SpaceName: '' as Ref>, IgnoreActions: '' as Ref>, HTMLPresenter: '' as Ref>, TextPresenter: '' as Ref>, PreviewPresenter: '' 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, SpacePresenter: '' as AnyComponent }, icon: { Table: '' as Asset, Delete: '' as Asset, MoreH: '' as Asset, Move: '' as Asset, Archive: '' as Asset, Statuses: '' as Asset } }) export default view