@riboseinc/paneron-registry-kit 2.0.5 → 2.0.6
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/package.json +2 -2
- package/types/views.d.ts +5 -0
- package/types/views.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@riboseinc/paneron-registry-kit",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.6",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"author": "Ribose Inc. <open.source@ribose.com>",
|
|
6
6
|
"scripts": {
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@emotion/react": "^11.10.6",
|
|
30
30
|
"@emotion/styled": "^11.10.6",
|
|
31
31
|
"@riboseinc/isogit-lfs": "0.1.6",
|
|
32
|
-
"@riboseinc/paneron-extension-kit": "2.0.
|
|
32
|
+
"@riboseinc/paneron-extension-kit": "2.0.3",
|
|
33
33
|
"@types/js-yaml": "^3.12.5",
|
|
34
34
|
"@types/node": "^16.11.7",
|
|
35
35
|
"@types/object-hash": "~3.0.2",
|
package/types/views.d.ts
CHANGED
|
@@ -50,6 +50,11 @@ export interface ExportFormatConfiguration<P extends Payload> {
|
|
|
50
50
|
exportItem: (itemData: RegisterItem<P>, opts: {
|
|
51
51
|
getObjectData: (opts: ObjectDatasetRequest) => Promise<ObjectDatasetResponse>;
|
|
52
52
|
getBlob: (val: string) => Promise<Uint8Array>;
|
|
53
|
+
logger?: {
|
|
54
|
+
log: Console["log"];
|
|
55
|
+
error: Console["error"];
|
|
56
|
+
debug: Console["debug"];
|
|
57
|
+
};
|
|
53
58
|
}) => Promise<Uint8Array>;
|
|
54
59
|
}
|
|
55
60
|
export interface ItemClassConfiguration<P extends Payload> {
|
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';\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 * 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 },\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 defaults?: RegistryItemPayloadDefaults<P>\n // Used to pre-populate item data e.g. when a new item is created.\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?: 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 customViews?: CustomViewConfiguration[]\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 * 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 //useRegisterItemData: RegisterItemDataHook\n //getRelatedItemClassConfiguration: ExtensionContext[\"getRelatedItemClassConfiguration\"]\n availableClassIDs?: string[]\n availableSubregisterIDs?: 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 */\n useRegisterItemData?: any\n /** Deprecated */\n getRelatedItemClassConfiguration?: any\n}\n\n\nexport type ItemEditView<P extends Payload> = React.FC<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';\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 * 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 defaults?: RegistryItemPayloadDefaults<P>\n // Used to pre-populate item data e.g. when a new item is created.\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?: 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 customViews?: CustomViewConfiguration[]\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 * 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 //useRegisterItemData: RegisterItemDataHook\n //getRelatedItemClassConfiguration: ExtensionContext[\"getRelatedItemClassConfiguration\"]\n availableClassIDs?: string[]\n availableSubregisterIDs?: 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 */\n useRegisterItemData?: any\n /** Deprecated */\n getRelatedItemClassConfiguration?: any\n}\n\n\nexport type ItemEditView<P extends Payload> = React.FC<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"]}
|