@riboseinc/paneron-registry-kit 2.2.53 → 2.2.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/item-classes/Tree.js.map +1 -1
- package/package.json +1 -1
- package/types/util.d.ts +1 -0
- package/types/util.js.map +1 -1
- package/types/views.d.ts +10 -0
- package/types/views.js.map +1 -1
package/item-classes/Tree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../src/item-classes/Tree.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAc,EAAE,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,kEAAkE,CAAC;AAE1G,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC7E,OAAO,mBAAgD,MAAM,uBAAuB,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAGtD,OAAO,EAAE,qCAAqC,EAAE,MAAM,aAAa,CAAC;AAGpE,MAAM,aAAa,GAAsD;IAEvE,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC7F,MAAM,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,sBAAsB,CAAC,CAAC;IACxD,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,kBAAkB,EAAE,GAAG,UAAU,CAAC,oBAAo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mBAAmB,EAAE,IAAI,GAAG,CAAC,KAAK,CAAC,eAAe,CAAC;YACnD,aAAa,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;SAC/C,CAAC,CAAA;KAAA,CAAC,EACL,CAAC,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,CAAC,CAClD,CAAC;IAEF,OAAO,IAAC,mBAAmB,IACzB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAC,cAAc,EACvB,iBAAiB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,SAAS,CAAC,UAAU,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC,GAC3E,CAAC;AACL,CAAC,CAAC;AAGF,eAAe,aAAa,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport React, { useContext, useMemo, useCallback } from 'react';\nimport { jsx } from '@emotion/react';\n\nimport { DatasetContext } from '@riboseinc/paneron-extension-kit/context';\nimport { TabbedWorkspaceContext } from '@riboseinc/paneron-extension-kit/widgets/TabbedWorkspace/context';\n\nimport { ChangeRequestContext, updateCRObjectChangeset } from '../proposals';\nimport GenericStatefulTree, { type State as TreeState } from '../views/StatefulTree';\nimport { BrowserCtx } from '../views/BrowserCtx';\nimport { itemRefToItemPath } from '../views/itemPathUtils';\nimport { Protocols } from '../views/protocolRegistry';\nimport type { RegisterItem, InternalItemReference } from '../types';\n\nimport { getMaybeGroupedItemClassesAsTreeNodes } from './treeNodes';\n\n\nconst ItemClassTree: React.VoidFunctionComponent<Record<never, never>> = function () {\n\n const { isBusy, performOperation, updateObjects, makeRandomID } = useContext(DatasetContext);\n const { spawnTab } = useContext(TabbedWorkspaceContext);\n const { changeRequest: activeCR, canEdit: activeCRIsEditable } = useContext(ChangeRequestContext);\n const { subregisters, itemClasses, itemClassGroups } = useContext(BrowserCtx);\n\n const createItem = useCallback(async function _createItem(classID: string, subregisterID?: string) {\n if (!updateObjects || !makeRandomID || !activeCRIsEditable || !activeCR) {\n throw new Error(\"Unable to create item: likely current proposal is not editable or dataset is read-only\");\n }\n if (subregisters && !subregisterID) {\n throw new Error(\"Unable to create item: register uses subregisters, but subregister ID was not provided\");\n }\n const clsConfig = itemClasses[classID];\n if (!clsConfig) {\n throw new Error(\"Unable to generate new item data: item class configuration is missing\");\n }\n const initialItemData = clsConfig?.defaults ?? {};\n const itemID = await makeRandomID();\n const ref: InternalItemReference = { classID, itemID, subregisterID };\n const registerItem: Readonly<RegisterItem<any>> = {\n id: itemID,\n dateAccepted: new Date(),\n status: 'valid',\n data: initialItemData,\n } as const;\n const itemPath = itemRefToItemPath(ref);\n await updateObjects({\n commitMessage: `propose to add new ${ref.classID}`,\n objectChangeset: updateCRObjectChangeset(\n activeCR as any,\n { [itemPath]: { type: 'addition' } },\n { [itemPath]: registerItem },\n ),\n _dangerouslySkipValidation: true,\n });\n spawnTab(Protocols.PROPOSAL_WORK);\n }, [activeCR, activeCRIsEditable, subregisters === undefined, updateObjects, makeRandomID]);\n\n const handleAdd: undefined | ((clsID: string) => Promise<void>) = useMemo((() =>\n !subregisters && activeCRIsEditable && performOperation\n ? (clsID) => performOperation('generating new item', createItem)(clsID)\n : undefined\n ), [createItem, subregisters === undefined, activeCRIsEditable, performOperation]);\n\n const getNodes = useCallback(\n ((state: TreeState) =>\n getMaybeGroupedItemClassesAsTreeNodes(itemClasses, itemClassGroups, {\n selectedItemID: state.selectedItemID ?? undefined,\n expandedGroupLabels: new Set(state.expandedItemIDs),\n onProposeItem: !isBusy ? handleAdd : undefined,\n })),\n [isBusy, itemClasses, itemClassGroups, handleAdd],\n );\n\n return <GenericStatefulTree\n getNodes={getNodes}\n stateKey=\"item-browser\"\n onItemDoubleClick={(node) => spawnTab(`${Protocols.ITEM_CLASS}:${node.id}`)}\n />;\n};\n\n\nexport default ItemClassTree;\n"]}
|
package/package.json
CHANGED
package/types/util.d.ts
CHANGED
package/types/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/types/util.ts"],"names":[],"mappings":"AAAA,YAAY","sourcesContent":["// Utilities\n\nexport interface Locale {\n name: string\n country: string\n languageCode: string // ISO 639-2\n characterEncoding: 'utf-8' // TODO: Support more encodings\n // TODO: citation?: CI_Citation\n}\n\n\nexport interface Citation {\n title: string\n\n author?: string | null\n publisher?: string | null\n publicationDate?: string | null\n revisionDate?: string | null\n\n seriesIssueID: string | null\n seriesName: string | null\n seriesPage: string | null\n\n edition: string | null\n editionDate: string | null\n\n otherDetails: string\n\n isbn: string | null\n issn: string | null\n\n alternateTitles?: string[]\n\n uri?: string\n\n //publicationDate: Date\n}\n\n\nexport interface LocalizedAlternative<T> {\n alternative: T\n locale: Locale\n}\n"]}
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/types/util.ts"],"names":[],"mappings":"AAAA,YAAY","sourcesContent":["// Utilities\n\nexport interface Locale {\n name: string\n country: string\n languageCode: string // ISO 639-2\n characterEncoding: 'utf-8' // TODO: Support more encodings\n // TODO: citation?: CI_Citation\n}\n\n\nexport interface Citation {\n title: string\n\n author?: string | null\n publisher?: string | null\n publicationDate?: string | null\n revisionDate?: string | null\n\n seriesIssueID: string | null\n seriesName: string | null\n seriesPage: string | null\n\n edition: string | null\n editionDate: string | null\n\n otherDetails: string\n\n isbn: string | null\n issn: string | null\n\n alternateTitles?: string[]\n\n doi?: string\n uri?: string\n\n //publicationDate: Date\n}\n\n\nexport interface LocalizedAlternative<T> {\n alternative: T\n locale: Locale\n}\n"]}
|
package/types/views.d.ts
CHANGED
|
@@ -41,6 +41,9 @@ export declare type Subregisters<Items extends ItemClassConfigurationSet = Recor
|
|
|
41
41
|
export declare type ItemClassConfigurationSet = {
|
|
42
42
|
[itemClassID: string]: ItemClassConfiguration<any>;
|
|
43
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* Other formats that item data can be represented in.
|
|
46
|
+
*/
|
|
44
47
|
export interface ExportFormatConfiguration<P extends Payload> {
|
|
45
48
|
/** The name of the export format. */
|
|
46
49
|
label: string;
|
|
@@ -63,6 +66,13 @@ export interface ExportFormatConfiguration<P extends Payload> {
|
|
|
63
66
|
debug: Console["debug"];
|
|
64
67
|
};
|
|
65
68
|
}) => Promise<Uint8Array>;
|
|
69
|
+
/**
|
|
70
|
+
* If true, then it will not be pre-generated in applicable environments
|
|
71
|
+
* (e.g., when rendering the register as a static site).
|
|
72
|
+
*
|
|
73
|
+
* Instead, it would be an export option that can be triggered by the user.
|
|
74
|
+
*/
|
|
75
|
+
defer?: boolean;
|
|
66
76
|
}
|
|
67
77
|
export interface ItemClassConfiguration<P extends Payload> {
|
|
68
78
|
meta: RegisterItemClass;
|
package/types/views.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"views.js","sourceRoot":"","sources":["../../src/types/views.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\nimport type { ButtonProps, MenuItemProps } from '@blueprintjs/core';\nimport type { ObjectDatasetRequest, ObjectDatasetResponse, ValueHook } from '@riboseinc/paneron-extension-kit/types';\nimport type { InternalItemReference, Payload, RegisterItem, RegisterItemClass } from './item';\nimport type { CriteriaGroup } from '../views/FilterCriteria/models';\nimport type { AlterApprovedCR } from '../proposals/types';\n\n\n// Hooks\n\n/**\n * Mostly a wrapper around useObjectData, but coerces value type\n * (TODO: validate!) and takes into account change request from any\n * wrapping change request context. If a change request is present,\n * will substitute proposed item data unless `ignoreActiveCR` is set.\n *\n * NOTE: Despite the name, returns the entire RegisterItem,\n * not just the `.data` property with item payload.\n */\nexport type RegisterItemDataHook<P extends Payload = Payload> =\n (opts: { itemPaths: string[], ignoreActiveCR?: true }) => ValueHook<Record<string, RegisterItem<P> | null>>;\n\n\n// Extension configuration\n\n// TODO: Obsolete?\n// export interface ExtensionContext {\n// getRelatedItemClassConfiguration: (classID: string) => RelatedItemClassConfiguration\n// useRegisterItemData: RegisterItemDataHook\n// onJump?: () => void\n// }\n\nexport interface RegisterConfiguration\n<Items extends ItemClassConfigurationSet = Record<string, ItemClassConfiguration<any>>> {\n /**\n * Configuration for all items in this register.\n * This includes items in subregisters.\n */\n itemClassConfiguration: Items\n\n /**\n * Default expression used to sort an item.\n * Passed to useFilteredIndex().\n */\n keyExpression?: string\n\n /** Subregister information. */\n subregisters?: Subregisters<Items>\n}\n\nexport type Subregisters\n<Items extends ItemClassConfigurationSet = Record<string, ItemClassConfiguration<any>>> = {\n [subregisterID: string]: {\n title: string\n\n /** Names of item classes that go in this subregister. */\n itemClasses: (keyof Items)[]\n }\n};\n\nexport type ItemClassConfigurationSet = {\n [itemClassID: string]: ItemClassConfiguration<any>\n};\n\n\n\nexport interface ExportFormatConfiguration<P extends Payload> {\n /** The name of the export format. */\n label: string\n\n /**\n * Trailing part of the filename to save export as;\n * must include at least extension (with separator),\n * must not include any path prefix.\n */\n filenameExtension: string\n\n /**\n * The function that takes register item data and some helper functions\n * and is expected to return a blob.\n */\n exportItem: (\n itemData: RegisterItem<P>,\n opts: {\n getObjectData: (opts: ObjectDatasetRequest) => Promise<ObjectDatasetResponse>,\n getBlob: (val: string) => Promise<Uint8Array>,\n logger?: { log: Console[\"log\"], error: Console[\"error\"], debug: Console[\"debug\"] },\n },\n ) => Promise<Uint8Array>\n}\n\n\nexport interface ItemClassConfiguration<P extends Payload/*, F extends Field*/> {\n meta: RegisterItemClass\n\n itemCanBeSuperseded?: boolean\n // If false, items of this class cannot be superseded, only retired.\n // Default is true.\n\n /** Used to pre-populate item data e.g. when a new item is created. */\n defaults?: RegistryItemPayloadDefaults<P>\n\n validatePayload?: (item: P) => Promise<boolean>\n sanitizePayload?: (item: P) => Promise<P>\n\n // XXX: Confirm if obsolete and remove\n itemSorter?: (a: P, b: P) => number\n\n /**\n * Expression used to sort an item of this class.\n * Passed to useFilteredIndex().\n */\n keyExpression?: string\n\n exportFormats?: Readonly<ExportFormatConfiguration<P>[]>\n\n views: {\n listItemView: ItemListView<P>\n editView: ItemEditView<P>\n detailView?: ItemDetailView<P>\n }\n}\n\n\nexport interface RegistryViewProps\n<Items extends ItemClassConfigurationSet = Record<string, ItemClassConfiguration<any>>>\nextends RegisterConfiguration<Items> {\n /**\n * When search is initially opened, have this query pre-defined.\n * Not very useful since there are also preset searches in the browser now.\n */\n // TODO: Obsoluete?\n defaultSearchCriteria?: CriteriaGroup\n\n /** Group item classes */\n itemClassGroups?: Record<string, readonly (keyof Items)[]>\n\n /** Overrides CustomSidebarConfig, obviously. */\n CustomWorkspace?: React.FC<Record<never, never>>\n\n /**\n * Default predicate for matching items\n * using quick search.\n *\n * Must return the search expression as text.\n *\n * Search expression must return a boolean and can access:\n *\n * - `obj`, which *should* be a RegisterItem instance\n * with `obj.data` being its class-specific payload.\n *\n * E.g., if all important item classes in your register\n * specify a `name` field:\n *\n * @example (searchQuery) => `obj.data?.name?.toLowerCase().indexOf(\"${searchQuery.toLowerCase()}\") >= 0`\n */\n getQuickSearchPredicate?: (quickSearchQuery: string) => string\n\n /**\n * Extension-provided additional views that don’t correspond\n * to entities like register item, change request, etc. handled by RegistryKit.\n */\n customViews?: CustomViewConfiguration[]\n\n /**\n * Allows to transform item data & proposals\n * after CB decision but before the changes are applied to the register.\n */\n alterApprovedCR?: AlterApprovedCR\n}\n\nexport interface CustomViewConfiguration {\n id: string\n label: string\n description: string\n view: React.FC<{\n /** View can support optional path for custom state/inner navigation (provisional). */\n path: string\n }>\n icon?: JSX.Element\n}\n\n\n// Item views\n\nexport interface ItemAction {\n getButtonProps:\n (item: RegisterItem<any>, itemClass: ItemClassConfiguration<any>, subregisterID?: string) =>\n ButtonProps | MenuItemProps\n}\n\nexport type RegistryView = React.FC<RegistryViewProps>\n\ntype RegistryItemPayloadDefaults<P extends Payload> =\n Partial<Omit<P, 'id'>>;\n\n/**\n * A small part of item class configuration,\n * useful e.g. for formatting related items.\n */\nexport type RelatedItemClassConfiguration = {\n title: string\n itemView: ItemListView<any>\n}\n\n\nexport interface RegistryItemViewProps<P extends Payload> {\n /**\n * Item reference.\n * Glossarist, for example, uses it to determine language subregister and set appropriate writing direction.\n */\n itemRef: Omit<InternalItemReference, 'itemID'> & { itemID?: InternalItemReference['itemID'] }\n\n /** Item data (payload). */\n itemData: P\n\n className?: string\n //subregisterID?: string\n\n /** Deprecated */\n useRegisterItemData?: any\n /** Deprecated */\n getRelatedItemClassConfiguration?: any\n}\n\nexport interface GenericRelatedItemViewProps {\n /** Currently selected item’s ref. */\n itemRef?: InternalItemReference\n\n /**\n * Allows to grab a ref of the input displaying the selected item.\n * Useful to, e.g., display validation.\n */\n inputRef?: React.Ref<HTMLInputElement>\n\n /**\n * If true, related item’s class title is NOT shown as part of item view.\n * Handy when displaying a related item of which item class\n * is already known.\n */\n hideItemClassTitle?: boolean\n\n /**\n * By default, clicking the item will spawn a tab via TabbedWorkspace context.\n * This prop can customize that behavior.\n */\n onJump?: () => void\n\n className?: string\n\n /**\n * Determines which item classes can be selected in the search dialog.\n * If undefined, *any* class can be chosen.\n * If empty list, no class can be chosen (weird).\n */\n availableClassIDs?: string[]\n\n // XXX: Check if obsolete, remove if unused\n itemSorter?: ItemClassConfiguration<any>[\"itemSorter\"]\n\n /** Called to auto-create an item (can’t auto-create if not provided) */\n onCreateNew?: () => Promise<InternalItemReference>\n\n /** Called when current item is cleared (can’t clear if not provided) */\n onClear?: () => void\n\n /** Called when a new item is selected (can’t change if not provided) */\n onChange?: (newRef: InternalItemReference) => void\n\n /** @deprecated subregisters no longer supported. */\n availableSubregisterIDs?: string[]\n\n /** @deprecated */\n useRegisterItemData?: any\n //useRegisterItemData: RegisterItemDataHook\n\n /** @deprecated */\n getRelatedItemClassConfiguration?: any\n //getRelatedItemClassConfiguration: ExtensionContext[\"getRelatedItemClassConfiguration\"]\n}\n\n\nexport type ItemEditView<P extends Payload> = React.FC<ItemEditViewProps<P>>;\n\nexport interface ItemEditViewProps<P extends Payload> extends RegistryItemViewProps<P> {\n onChange?: (newData: P) => void\n onCreateRelatedItem?:\n (classID: string, subregisterID?: string) => Promise<InternalItemReference>\n}\n\nexport interface ItemDetailViewProps<P extends Payload> extends RegistryItemViewProps<P> {\n //useRegisterItemData: RegisterItemDataHook\n}\n\nexport type ItemDetailView<P extends Payload> = React.FC<ItemDetailViewProps<P>>;\n\nexport interface ItemListViewProps<P extends Payload> extends RegistryItemViewProps<P> {\n}\n\nexport type ItemListView<P extends Payload> = React.FC<ItemListViewProps<P>>;\n\nexport type LazyItemView = React.FC<{ itemID: string }>;\n"]}
|
|
1
|
+
{"version":3,"file":"views.js","sourceRoot":"","sources":["../../src/types/views.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\nimport type { ButtonProps, MenuItemProps } from '@blueprintjs/core';\nimport type { ObjectDatasetRequest, ObjectDatasetResponse, ValueHook } from '@riboseinc/paneron-extension-kit/types';\nimport type { InternalItemReference, Payload, RegisterItem, RegisterItemClass } from './item';\nimport type { CriteriaGroup } from '../views/FilterCriteria/models';\nimport type { AlterApprovedCR } from '../proposals/types';\n\n\n// Hooks\n\n/**\n * Mostly a wrapper around useObjectData, but coerces value type\n * (TODO: validate!) and takes into account change request from any\n * wrapping change request context. If a change request is present,\n * will substitute proposed item data unless `ignoreActiveCR` is set.\n *\n * NOTE: Despite the name, returns the entire RegisterItem,\n * not just the `.data` property with item payload.\n */\nexport type RegisterItemDataHook<P extends Payload = Payload> =\n (opts: { itemPaths: string[], ignoreActiveCR?: true }) => ValueHook<Record<string, RegisterItem<P> | null>>;\n\n\n// Extension configuration\n\n// TODO: Obsolete?\n// export interface ExtensionContext {\n// getRelatedItemClassConfiguration: (classID: string) => RelatedItemClassConfiguration\n// useRegisterItemData: RegisterItemDataHook\n// onJump?: () => void\n// }\n\nexport interface RegisterConfiguration\n<Items extends ItemClassConfigurationSet = Record<string, ItemClassConfiguration<any>>> {\n /**\n * Configuration for all items in this register.\n * This includes items in subregisters.\n */\n itemClassConfiguration: Items\n\n /**\n * Default expression used to sort an item.\n * Passed to useFilteredIndex().\n */\n keyExpression?: string\n\n /** Subregister information. */\n subregisters?: Subregisters<Items>\n}\n\nexport type Subregisters\n<Items extends ItemClassConfigurationSet = Record<string, ItemClassConfiguration<any>>> = {\n [subregisterID: string]: {\n title: string\n\n /** Names of item classes that go in this subregister. */\n itemClasses: (keyof Items)[]\n }\n};\n\nexport type ItemClassConfigurationSet = {\n [itemClassID: string]: ItemClassConfiguration<any>\n};\n\n\n\n/**\n * Other formats that item data can be represented in.\n */\nexport interface ExportFormatConfiguration<P extends Payload> {\n /** The name of the export format. */\n label: string\n\n /**\n * Trailing part of the filename to save export as;\n * must include at least extension (with separator),\n * must not include any path prefix.\n */\n filenameExtension: string\n\n /**\n * The function that takes register item data and some helper functions\n * and is expected to return a blob.\n */\n exportItem: (\n itemData: RegisterItem<P>,\n opts: {\n getObjectData: (opts: ObjectDatasetRequest) => Promise<ObjectDatasetResponse>,\n getBlob: (val: string) => Promise<Uint8Array>,\n logger?: { log: Console[\"log\"], error: Console[\"error\"], debug: Console[\"debug\"] },\n },\n ) => Promise<Uint8Array>\n\n /**\n * If true, then it will not be pre-generated in applicable environments\n * (e.g., when rendering the register as a static site).\n *\n * Instead, it would be an export option that can be triggered by the user.\n */\n defer?: boolean\n}\n\n\nexport interface ItemClassConfiguration<P extends Payload/*, F extends Field*/> {\n meta: RegisterItemClass\n\n itemCanBeSuperseded?: boolean\n // If false, items of this class cannot be superseded, only retired.\n // Default is true.\n\n /** Used to pre-populate item data e.g. when a new item is created. */\n defaults?: RegistryItemPayloadDefaults<P>\n\n validatePayload?: (item: P) => Promise<boolean>\n sanitizePayload?: (item: P) => Promise<P>\n\n // XXX: Confirm if obsolete and remove\n itemSorter?: (a: P, b: P) => number\n\n /**\n * Expression used to sort an item of this class.\n * Passed to useFilteredIndex().\n */\n keyExpression?: string\n\n exportFormats?: Readonly<ExportFormatConfiguration<P>[]>\n\n views: {\n listItemView: ItemListView<P>\n editView: ItemEditView<P>\n detailView?: ItemDetailView<P>\n }\n}\n\n\nexport interface RegistryViewProps\n<Items extends ItemClassConfigurationSet = Record<string, ItemClassConfiguration<any>>>\nextends RegisterConfiguration<Items> {\n /**\n * When search is initially opened, have this query pre-defined.\n * Not very useful since there are also preset searches in the browser now.\n */\n // TODO: Obsoluete?\n defaultSearchCriteria?: CriteriaGroup\n\n /** Group item classes */\n itemClassGroups?: Record<string, readonly (keyof Items)[]>\n\n /** Overrides CustomSidebarConfig, obviously. */\n CustomWorkspace?: React.FC<Record<never, never>>\n\n /**\n * Default predicate for matching items\n * using quick search.\n *\n * Must return the search expression as text.\n *\n * Search expression must return a boolean and can access:\n *\n * - `obj`, which *should* be a RegisterItem instance\n * with `obj.data` being its class-specific payload.\n *\n * E.g., if all important item classes in your register\n * specify a `name` field:\n *\n * @example (searchQuery) => `obj.data?.name?.toLowerCase().indexOf(\"${searchQuery.toLowerCase()}\") >= 0`\n */\n getQuickSearchPredicate?: (quickSearchQuery: string) => string\n\n /**\n * Extension-provided additional views that don’t correspond\n * to entities like register item, change request, etc. handled by RegistryKit.\n */\n customViews?: CustomViewConfiguration[]\n\n /**\n * Allows to transform item data & proposals\n * after CB decision but before the changes are applied to the register.\n */\n alterApprovedCR?: AlterApprovedCR\n}\n\nexport interface CustomViewConfiguration {\n id: string\n label: string\n description: string\n view: React.FC<{\n /** View can support optional path for custom state/inner navigation (provisional). */\n path: string\n }>\n icon?: JSX.Element\n}\n\n\n// Item views\n\nexport interface ItemAction {\n getButtonProps:\n (item: RegisterItem<any>, itemClass: ItemClassConfiguration<any>, subregisterID?: string) =>\n ButtonProps | MenuItemProps\n}\n\nexport type RegistryView = React.FC<RegistryViewProps>\n\ntype RegistryItemPayloadDefaults<P extends Payload> =\n Partial<Omit<P, 'id'>>;\n\n/**\n * A small part of item class configuration,\n * useful e.g. for formatting related items.\n */\nexport type RelatedItemClassConfiguration = {\n title: string\n itemView: ItemListView<any>\n}\n\n\nexport interface RegistryItemViewProps<P extends Payload> {\n /**\n * Item reference.\n * Glossarist, for example, uses it to determine language subregister and set appropriate writing direction.\n */\n itemRef: Omit<InternalItemReference, 'itemID'> & { itemID?: InternalItemReference['itemID'] }\n\n /** Item data (payload). */\n itemData: P\n\n className?: string\n //subregisterID?: string\n\n /** Deprecated */\n useRegisterItemData?: any\n /** Deprecated */\n getRelatedItemClassConfiguration?: any\n}\n\nexport interface GenericRelatedItemViewProps {\n /** Currently selected item’s ref. */\n itemRef?: InternalItemReference\n\n /**\n * Allows to grab a ref of the input displaying the selected item.\n * Useful to, e.g., display validation.\n */\n inputRef?: React.Ref<HTMLInputElement>\n\n /**\n * If true, related item’s class title is NOT shown as part of item view.\n * Handy when displaying a related item of which item class\n * is already known.\n */\n hideItemClassTitle?: boolean\n\n /**\n * By default, clicking the item will spawn a tab via TabbedWorkspace context.\n * This prop can customize that behavior.\n */\n onJump?: () => void\n\n className?: string\n\n /**\n * Determines which item classes can be selected in the search dialog.\n * If undefined, *any* class can be chosen.\n * If empty list, no class can be chosen (weird).\n */\n availableClassIDs?: string[]\n\n // XXX: Check if obsolete, remove if unused\n itemSorter?: ItemClassConfiguration<any>[\"itemSorter\"]\n\n /** Called to auto-create an item (can’t auto-create if not provided) */\n onCreateNew?: () => Promise<InternalItemReference>\n\n /** Called when current item is cleared (can’t clear if not provided) */\n onClear?: () => void\n\n /** Called when a new item is selected (can’t change if not provided) */\n onChange?: (newRef: InternalItemReference) => void\n\n /** @deprecated subregisters no longer supported. */\n availableSubregisterIDs?: string[]\n\n /** @deprecated */\n useRegisterItemData?: any\n //useRegisterItemData: RegisterItemDataHook\n\n /** @deprecated */\n getRelatedItemClassConfiguration?: any\n //getRelatedItemClassConfiguration: ExtensionContext[\"getRelatedItemClassConfiguration\"]\n}\n\n\nexport type ItemEditView<P extends Payload> = React.FC<ItemEditViewProps<P>>;\n\nexport interface ItemEditViewProps<P extends Payload> extends RegistryItemViewProps<P> {\n onChange?: (newData: P) => void\n onCreateRelatedItem?:\n (classID: string, subregisterID?: string) => Promise<InternalItemReference>\n}\n\nexport interface ItemDetailViewProps<P extends Payload> extends RegistryItemViewProps<P> {\n //useRegisterItemData: RegisterItemDataHook\n}\n\nexport type ItemDetailView<P extends Payload> = React.FC<ItemDetailViewProps<P>>;\n\nexport interface ItemListViewProps<P extends Payload> extends RegistryItemViewProps<P> {\n}\n\nexport type ItemListView<P extends Payload> = React.FC<ItemListViewProps<P>>;\n\nexport type LazyItemView = React.FC<{ itemID: string }>;\n"]}
|