@riboseinc/paneron-registry-kit 2.2.52 → 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.
@@ -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,oBAAoB,CAAC,CAAC;IAClG,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;IAE9E,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,UAAU,WAA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AAE,aAAa,EAAE,YAAY,CAAC,CAAC,CAAC;IAE5F,MAAM,SAAS,GAAmD,OAAO,CAAC,CAAC,GAAG,EAAE,CAC9E,CAAC,YAAY,IAAI,kBAAkB,IAAI,gBAAgB;QACrD,CAAC,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,gBAAgB,CAAC,qBAAqB,EAAE,UAAU,CAAC,CAAC,KAAK,CAAC;QACvE,CAAC,CAAC,SAAS,CACd,EAAE,CAAC,UAAU,EAAE,YAAY,KAAK,SAAS,EAAE,kBAAkB,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAEnF,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,CAAC,KAAgB,EAAE,EAAE;;QACpB,OAAA,qCAAqC,CAAC,WAAW,EAAE,eAAe,EAAE;YAClE,cAAc,EAAE,MAAA,KAAK,CAAC,cAAc,mCAAI,SAAS;YACjD,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: RegisterItem<any> = {\n id: itemID,\n dateAccepted: new Date(),\n status: 'valid',\n data: initialItemData,\n };\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"]}
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,UAA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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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riboseinc/paneron-registry-kit",
3
- "version": "2.2.52",
3
+ "version": "2.2.54",
4
4
  "main": "index.js",
5
5
  "author": "Ribose Inc. <open.source@ribose.com>",
6
6
  "scripts": {
package/types/util.d.ts CHANGED
@@ -19,6 +19,7 @@ export interface Citation {
19
19
  isbn: string | null;
20
20
  issn: string | null;
21
21
  alternateTitles?: string[];
22
+ doi?: string;
22
23
  uri?: string;
23
24
  }
24
25
  export interface LocalizedAlternative<T> {
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;
@@ -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"]}
@@ -230,7 +230,11 @@ const GenericRelatedItemView = function ({
230
230
  `,
231
231
  leftElement: canJump ? (0, _react.jsx)("a", {
232
232
  onClick: jump,
233
- css: (0, _react.css)`display: flex; flex-flow: row nowrap; align-items: baseline;`
233
+ css: (0, _react.css)`
234
+ display: flex;
235
+ flex-flow: row nowrap;
236
+ align-items: baseline;
237
+ `
234
238
  }, itemView) : itemView,
235
239
  value: itemID !== null && itemID !== void 0 ? itemID : '',
236
240
  title: itemTitle
@@ -1 +1 @@
1
- {"version":3,"file":"GenericRelatedItemView.js","sourceRoot":"","sources":["../../src/views/GenericRelatedItemView.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAA4C,MAAM,mBAAmB,CAAC;AAC/G,OAAO,EAGL,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAGpD,MAAM,SAAS,GAAG;IAChB,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,EAAE;IACV,aAAa,EAAE,EAAE;CACT,CAAC;AAGX,MAAM,CAAC,MAAM,sBAAsB,GAE9B,UAAU,EACb,OAAO,EAAE,SAAS,EAClB,WAAW,EAAE,OAAO,EAAE,QAAQ,EAC9B,iBAAiB,EACjB,MAAM,EACN,QAAQ,EACR,iB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G,EAAE,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;SAwBP,EACD,WAAW,EAAE,OAAO;gBAClB,CAAC,CAAC,WAAG,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,CAAA,8DAA8D,IACrF,QAAQ,CACP;gBACN,CAAC,CAAC,QAAQ,EACZ,KAAK,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,EACnB,KAAK,EAAE,SAAS,GAChB;QAMD,WAAW,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAC9B,IAAC,MAAM,IAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,WAAK,KAAK,GAAI,CACzC;QAED,IAAC,gBAAgB,IACf,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,WAAW,CAClB,GAAG,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,EACjC,CAAC,oBAAoB,CAAC,CAAC,EACzB,YAAY,EAAE,QAAQ,EACtB,iBAAiB,EAAE,QAAQ,GAC3B;QAED,QAAQ;YACP,CAAC,CAAC,IAAC,iBAAiB,IAChB,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,kBAAkB,EAC3B,OAAO,EAAE,QAAQ,EACjB,eAAe,EAAE,MAAA,mBAAmB,CAAC,OAAO,mCAAI,SAAS,GACzD;YACJ,CAAC,CAAC,IAAI,CAEK,CAChB,CAAC;AACJ,CAAC,CAAC;AAGF,eAAe,sBAAsB,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport { jsx, css } from '@emotion/react';\nimport React, { useRef, useContext, useCallback, useMemo, useState } from 'react';\nimport { InputGroup, Button, ControlGroup, type ControlGroupProps, type ButtonProps } from '@blueprintjs/core';\nimport {\n type GenericRelatedItemViewProps,\n type RelatedItemClassConfiguration,\n isRegisterItem,\n} from '../types';\nimport { ChangeRequestContext } from '../proposals/ChangeRequestContext';\nimport { isDrafted } from '../proposals/types';\nimport { BrowserCtx } from './BrowserCtx';\nimport ItemSearchDrawer from './ItemSearchDrawer';\nimport ItemDetailsDrawer from './ItemDetailsDrawer';\n\n\nconst DUMMY_REF = {\n classID: '',\n itemID: '',\n subregisterID: '',\n} as const;\n\n\nexport const GenericRelatedItemView: React.FC<GenericRelatedItemViewProps & {\n controlGroupProps?: ControlGroupProps\n}> = function ({\n itemRef, className,\n onCreateNew, onClear, onChange,\n availableClassIDs,\n onJump,\n inputRef,\n controlGroupProps,\n hideItemClassTitle,\n // availableSubregisterIDs,\n // itemSorter,\n}) {\n const {\n useRegisterItemData,\n getRelatedItemClassConfiguration,\n jumpTo,\n } = useContext(BrowserCtx);\n const { changeRequest: activeChangeRequest } = useContext(ChangeRequestContext);\n const { classID, itemID, subregisterID } = itemRef ?? DUMMY_REF;\n\n const itemPathWithClass = `${classID}/${itemID}.yaml`;\n // If curretn register has subregisters, specify subregister-relative path\n const itemPathWithSubregister = subregisterID\n ? `subregisters/${subregisterID}/${itemPathWithClass}`\n : `${itemPathWithClass}`;\n // If a change request is active\n // and this item is among clarifications or additions\n // then use item path relative to the change request\n // TODO: make useRegisterItemData() handle active change request\n const affectedByActiveCR = (\n activeChangeRequest &&\n isDrafted(activeChangeRequest) &&\n activeChangeRequest.items[itemPathWithSubregister]\n );\n const itemPath = affectedByActiveCR\n ? `/proposals/${activeChangeRequest.id}/items/${itemPathWithSubregister}`\n : `/${itemPathWithSubregister}`;\n\n const [selectDialogState, setSelectDialogState] = useState(false);\n const [peekingDrawerState, setPeekingDrawerState] = useState(false);\n\n //log.debug(\"Rendering generic related item view\", itemRef);\n //const { jumpToItem } = useContext(BrowserCtx);\n\n const itemResult = useRegisterItemData({ itemPaths: [itemPath] });\n const item = (itemResult.value?.[itemPath] || null);\n\n const [classConfigured, cfg]: [boolean, RelatedItemClassConfiguration] = useMemo(() => {\n let classConfigured: boolean;\n let cfg: RelatedItemClassConfiguration;\n try {\n cfg = getRelatedItemClassConfiguration(classID);\n classConfigured = true;\n } catch (e) {\n cfg = {\n title: classID,\n itemView: () => <span>{itemID}</span>\n };\n classConfigured = false;\n }\n return [classConfigured, cfg];\n }, [itemID, classID, getRelatedItemClassConfiguration]);\n\n const Item = cfg.itemView;\n\n const classIDs = useMemo((() =>\n availableClassIDs ?? ((itemRef?.classID ?? '') !== '' ? [itemRef!.classID] : [])\n ), [availableClassIDs?.join(','), itemRef?.classID]);\n\n const itemClassTitle = cfg.title.trim() || null;\n\n const hasItem = item !== null && classConfigured && isRegisterItem(item);\n const itemIsMissing = itemID !== '' && (item === null && !itemResult.isUpdating);\n const willShowItemView = hasItem || itemIsMissing || !onChange;\n const canJump = (item !== null || itemIsMissing) && classConfigured && !itemResult.isUpdating && (onJump || jumpTo);\n\n const jump = useCallback(function jump() {\n return onJump\n ? onJump()\n : setPeekingDrawerState(true)\n }, [onJump, jumpTo]);\n\n const itemView: JSX.Element | null = useMemo(() => {\n const classView = <small css={css`letter-spacing: -.01em`}>\n {itemClassTitle\n ? itemClassTitle\n : <em>unknown class</em>}\n </small>;\n const itemView = hasItem\n ? <Item\n itemRef={{ classID, itemID, subregisterID }}\n itemData={item.data}\n css={css`overflow: hidden; text-overflow: ellipsis;`}\n />\n : itemIsMissing\n ? <span css={css`overflow: hidden; text-overflow: ellipsis;`}>\n Not found: {itemID ?? 'N/A'}\n </span>\n : <span>Not specified</span>;\n return <>{itemView}{!hideItemClassTitle ? <>&emsp;{classView}</> : null}</>;\n }, [itemID, classID, !hideItemClassTitle && itemClassTitle, subregisterID, item?.data, hasItem, itemIsMissing]);\n\n const itemButtons = useMemo(() => {\n const canAutoCreateRelatedItem = itemID === '' && onCreateNew && !itemResult.isUpdating;\n const canChangeRelatedItem = /*classIDs.length >= 1 && */onChange && !itemResult.isUpdating;\n const canClear = onClear && itemID !== '' && !itemResult.isUpdating;\n\n let itemButtons: (ButtonProps & { title: string })[] = [];\n\n async function handleCreateNew() {\n if (!onCreateNew) { return; }\n const itemRef = await onCreateNew();\n console.debug(\"Created new item\", itemRef);\n }\n\n if (!hasItem && canAutoCreateRelatedItem) {\n itemButtons.push({\n onClick: handleCreateNew,\n icon: 'add',\n text: 'Auto create',\n intent: 'primary',\n title: \"Automatically create new item\",\n });\n }\n if (canChangeRelatedItem) {\n itemButtons.push({\n onClick: () => setSelectDialogState(true),\n icon: 'edit',\n text: willShowItemView ? undefined : 'Specify',\n intent: 'primary',\n title: \"Select related item\",\n /*disabled: classIDs.length < 1,*/\n });\n }\n if (canClear) {\n itemButtons.push({\n onClick: onClear,\n icon: 'eraser',\n intent: 'danger',\n title: \"Clear related item selection\",\n });\n }\n\n return itemButtons;\n }, [itemID, itemResult.isUpdating, onCreateNew, onChange, onClear]);\n\n const itemTitle = hasItem\n ? `${itemClassTitle ?? 'unknown class'} item ${itemID ?? 'with unknown ID'}`\n : undefined;\n\n /** Input ref for using within this component */\n //const cbRef = useRef<HTMLDivElement | null>(null);\n const _drawerContainerRef = useRef<HTMLElement | null>(null);\n const closePeekingDrawer = useCallback(\n (() => setPeekingDrawerState(false)),\n [setPeekingDrawerState]);\n\n const _itemRef = useMemo(() => itemRef, [JSON.stringify(itemRef)]);\n\n //log.debug(\"Rendering generic related item view: got item\", item);\n return (\n <ControlGroup\n dir=\"ltr\"\n className={className}\n title={itemTitle}\n {...controlGroupProps}>\n\n {/*<div ref={cbRef} />*/}\n\n {/*\n It could technically be a div, since input is empty,\n but that input is useful\n if callers utilize inputRef for form validation API,\n for example.\n */}\n <InputGroup\n fill={hasItem}\n readOnly={!onChange && !onClear}\n inputRef={inputRef}\n onChange={useCallback(() => void 0, [])}\n css={css`\n flex-shrink: 1;\n\n /* leftElement which displays itemView */\n .bp4-input-left-container {\n /* Some obscure magic, since we augment bp4’s styling here. */\n top: unset;\n bottom: .42em;\n padding-left: 10px;\n padding-right: 5px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n\n display: block;\n\n max-width: 100%;\n }\n .bp4-input {\n /* Hide raw UUID */\n color: rgba(125, 125, 125, 0);\n font-family: monospace;\n padding-left: 0 !important;\n }\n `}\n leftElement={canJump\n ? <a onClick={jump} css={css`display: flex; flex-flow: row nowrap; align-items: baseline;`}>\n {itemView}\n </a>\n : itemView}\n value={itemID ?? ''}\n title={itemTitle}\n />\n\n {/*canJump\n ? <Button outlined onClick={jump} icon=\"maximize\" />\n : null*/}\n\n {itemButtons.map((props, idx) =>\n <Button key={idx} outlined {...props} />\n )}\n\n <ItemSearchDrawer\n isOpen={selectDialogState}\n onClose={useCallback(\n () => setSelectDialogState(false),\n [setSelectDialogState])}\n onChooseItem={onChange}\n availableClassIDs={classIDs}\n />\n\n {_itemRef\n ? <ItemDetailsDrawer\n isOpen={peekingDrawerState}\n onClose={closePeekingDrawer}\n itemRef={_itemRef}\n portalContainer={_drawerContainerRef.current ?? undefined}\n />\n : null}\n\n </ControlGroup>\n );\n};\n\n\nexport default GenericRelatedItemView;\n"]}
1
+ {"version":3,"file":"GenericRelatedItemView.js","sourceRoot":"","sources":["../../src/views/GenericRelatedItemView.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAA4C,MAAM,mBAAmB,CAAC;AAC/G,OAAO,EAGL,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AAGpD,MAAM,SAAS,GAAG;I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React, { useRef, useContext, useCallback, useMemo, useState } from 'react';\nimport { InputGroup, Button, ControlGroup, type ControlGroupProps, type ButtonProps } from '@blueprintjs/core';\nimport {\n type GenericRelatedItemViewProps,\n type RelatedItemClassConfiguration,\n isRegisterItem,\n} from '../types';\nimport { ChangeRequestContext } from '../proposals/ChangeRequestContext';\nimport { isDrafted } from '../proposals/types';\nimport { BrowserCtx } from './BrowserCtx';\nimport ItemSearchDrawer from './ItemSearchDrawer';\nimport ItemDetailsDrawer from './ItemDetailsDrawer';\n\n\nconst DUMMY_REF = {\n classID: '',\n itemID: '',\n subregisterID: '',\n} as const;\n\n\nexport const GenericRelatedItemView: React.FC<GenericRelatedItemViewProps & {\n controlGroupProps?: ControlGroupProps\n}> = function ({\n itemRef, className,\n onCreateNew, onClear, onChange,\n availableClassIDs,\n onJump,\n inputRef,\n controlGroupProps,\n hideItemClassTitle,\n // availableSubregisterIDs,\n // itemSorter,\n}) {\n const {\n useRegisterItemData,\n getRelatedItemClassConfiguration,\n jumpTo,\n } = useContext(BrowserCtx);\n const { changeRequest: activeChangeRequest } = useContext(ChangeRequestContext);\n const { classID, itemID, subregisterID } = itemRef ?? DUMMY_REF;\n\n const itemPathWithClass = `${classID}/${itemID}.yaml`;\n // If curretn register has subregisters, specify subregister-relative path\n const itemPathWithSubregister = subregisterID\n ? `subregisters/${subregisterID}/${itemPathWithClass}`\n : `${itemPathWithClass}`;\n // If a change request is active\n // and this item is among clarifications or additions\n // then use item path relative to the change request\n // TODO: make useRegisterItemData() handle active change request\n const affectedByActiveCR = (\n activeChangeRequest &&\n isDrafted(activeChangeRequest) &&\n activeChangeRequest.items[itemPathWithSubregister]\n );\n const itemPath = affectedByActiveCR\n ? `/proposals/${activeChangeRequest.id}/items/${itemPathWithSubregister}`\n : `/${itemPathWithSubregister}`;\n\n const [selectDialogState, setSelectDialogState] = useState(false);\n const [peekingDrawerState, setPeekingDrawerState] = useState(false);\n\n //log.debug(\"Rendering generic related item view\", itemRef);\n //const { jumpToItem } = useContext(BrowserCtx);\n\n const itemResult = useRegisterItemData({ itemPaths: [itemPath] });\n const item = (itemResult.value?.[itemPath] || null);\n\n const [classConfigured, cfg]: [boolean, RelatedItemClassConfiguration] = useMemo(() => {\n let classConfigured: boolean;\n let cfg: RelatedItemClassConfiguration;\n try {\n cfg = getRelatedItemClassConfiguration(classID);\n classConfigured = true;\n } catch (e) {\n cfg = {\n title: classID,\n itemView: () => <span>{itemID}</span>\n };\n classConfigured = false;\n }\n return [classConfigured, cfg];\n }, [itemID, classID, getRelatedItemClassConfiguration]);\n\n const Item = cfg.itemView;\n\n const classIDs = useMemo((() =>\n availableClassIDs ?? ((itemRef?.classID ?? '') !== '' ? [itemRef!.classID] : [])\n ), [availableClassIDs?.join(','), itemRef?.classID]);\n\n const itemClassTitle = cfg.title.trim() || null;\n\n const hasItem = item !== null && classConfigured && isRegisterItem(item);\n const itemIsMissing = itemID !== '' && (item === null && !itemResult.isUpdating);\n const willShowItemView = hasItem || itemIsMissing || !onChange;\n const canJump = (item !== null || itemIsMissing) && classConfigured && !itemResult.isUpdating && (onJump || jumpTo);\n\n const jump = useCallback(function jump() {\n return onJump\n ? onJump()\n : setPeekingDrawerState(true)\n }, [onJump, jumpTo]);\n\n const itemView: JSX.Element | null = useMemo(() => {\n const classView = <small css={css`letter-spacing: -.01em`}>\n {itemClassTitle\n ? itemClassTitle\n : <em>unknown class</em>}\n </small>;\n const itemView = hasItem\n ? <Item\n itemRef={{ classID, itemID, subregisterID }}\n itemData={item.data}\n css={css`overflow: hidden; text-overflow: ellipsis;`}\n />\n : itemIsMissing\n ? <span css={css`overflow: hidden; text-overflow: ellipsis;`}>\n Not found: {itemID ?? 'N/A'}\n </span>\n : <span>Not specified</span>;\n return <>{itemView}{!hideItemClassTitle ? <>&emsp;{classView}</> : null}</>;\n }, [itemID, classID, !hideItemClassTitle && itemClassTitle, subregisterID, item?.data, hasItem, itemIsMissing]);\n\n const itemButtons = useMemo(() => {\n const canAutoCreateRelatedItem = itemID === '' && onCreateNew && !itemResult.isUpdating;\n const canChangeRelatedItem = /*classIDs.length >= 1 && */onChange && !itemResult.isUpdating;\n const canClear = onClear && itemID !== '' && !itemResult.isUpdating;\n\n let itemButtons: (ButtonProps & { title: string })[] = [];\n\n async function handleCreateNew() {\n if (!onCreateNew) { return; }\n const itemRef = await onCreateNew();\n console.debug(\"Created new item\", itemRef);\n }\n\n if (!hasItem && canAutoCreateRelatedItem) {\n itemButtons.push({\n onClick: handleCreateNew,\n icon: 'add',\n text: 'Auto create',\n intent: 'primary',\n title: \"Automatically create new item\",\n });\n }\n if (canChangeRelatedItem) {\n itemButtons.push({\n onClick: () => setSelectDialogState(true),\n icon: 'edit',\n text: willShowItemView ? undefined : 'Specify',\n intent: 'primary',\n title: \"Select related item\",\n /*disabled: classIDs.length < 1,*/\n });\n }\n if (canClear) {\n itemButtons.push({\n onClick: onClear,\n icon: 'eraser',\n intent: 'danger',\n title: \"Clear related item selection\",\n });\n }\n\n return itemButtons;\n }, [itemID, itemResult.isUpdating, onCreateNew, onChange, onClear]);\n\n const itemTitle = hasItem\n ? `${itemClassTitle ?? 'unknown class'} item ${itemID ?? 'with unknown ID'}`\n : undefined;\n\n /** Input ref for using within this component */\n //const cbRef = useRef<HTMLDivElement | null>(null);\n const _drawerContainerRef = useRef<HTMLElement | null>(null);\n const closePeekingDrawer = useCallback(\n (() => setPeekingDrawerState(false)),\n [setPeekingDrawerState]);\n\n const _itemRef = useMemo(() => itemRef, [JSON.stringify(itemRef)]);\n\n //log.debug(\"Rendering generic related item view: got item\", item);\n return (\n <ControlGroup\n dir=\"ltr\"\n className={className}\n title={itemTitle}\n {...controlGroupProps}>\n\n {/*<div ref={cbRef} />*/}\n\n {/*\n It could technically be a div, since input is empty,\n but that input is useful\n if callers utilize inputRef for form validation API,\n for example.\n */}\n <InputGroup\n fill={hasItem}\n readOnly={!onChange && !onClear}\n inputRef={inputRef}\n onChange={useCallback(() => void 0, [])}\n css={css`\n flex-shrink: 1;\n\n /* leftElement which displays itemView */\n .bp4-input-left-container {\n /* Some obscure magic, since we augment bp4’s styling here. */\n top: unset;\n bottom: .42em;\n padding-left: 10px;\n padding-right: 5px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n\n display: block;\n\n max-width: 100%;\n }\n .bp4-input {\n /* Hide raw UUID */\n color: rgba(125, 125, 125, 0);\n font-family: monospace;\n padding-left: 0 !important;\n }\n `}\n leftElement={canJump\n ? <a\n onClick={jump}\n css={css`\n display: flex;\n flex-flow: row nowrap;\n align-items: baseline;\n `}>\n {itemView}\n </a>\n : itemView}\n value={itemID ?? ''}\n title={itemTitle}\n />\n\n {/*canJump\n ? <Button outlined onClick={jump} icon=\"maximize\" />\n : null*/}\n\n {itemButtons.map((props, idx) =>\n <Button key={idx} outlined {...props} />\n )}\n\n <ItemSearchDrawer\n isOpen={selectDialogState}\n onClose={useCallback(\n () => setSelectDialogState(false),\n [setSelectDialogState])}\n onChooseItem={onChange}\n availableClassIDs={classIDs}\n />\n\n {_itemRef\n ? <ItemDetailsDrawer\n isOpen={peekingDrawerState}\n onClose={closePeekingDrawer}\n itemRef={_itemRef}\n portalContainer={_drawerContainerRef.current ?? undefined}\n />\n : null}\n\n </ControlGroup>\n );\n};\n\n\nexport default GenericRelatedItemView;\n"]}
@@ -30,7 +30,15 @@ const ItemSearch = (0, _react.memo)(function () {
30
30
  return (0, _react2.jsx)(_util.TabContentsWithHeader, {
31
31
  title: (0, _react2.jsx)(_react.default.Fragment, null, "Search all items")
32
32
  }, (0, _react2.jsx)(_core.Card, {
33
- css: (0, _react2.css)`flex: 1; box-shadow: none !important; position: absolute; border-radius: 0; display: flex; flex-flow: column nowrap; padding: 10px;`
33
+ css: (0, _react2.css)`
34
+ flex: 1;
35
+ box-shadow: none !important;
36
+ position: absolute;
37
+ border-radius: 0;
38
+ display: flex;
39
+ flex-flow: column nowrap;
40
+ padding: 10px;
41
+ `
34
42
  }, (0, _react2.jsx)(_util.RegisterHelmet, null, (0, _react2.jsx)("title", null, "Search all items")), (0, _react2.jsx)(_Search.default, {
35
43
  css: (0, _react2.css)`flex: 1;`,
36
44
  //style={{ height: '100vh', width: '50vw', minWidth: '500px', maxWidth: '90vw' }}
@@ -1 +1 @@
1
- {"version":3,"file":"AllItems.js","sourceRoot":"","sources":["../../../src/views/detail/AllItems.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EACL,IAAI,GACL,MAAM,mBAAmB,CAAC;AAC3B,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,cAAc,IAAI,MAAM,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,MAAM,UAAU,GAChB,IAAI,CAAC;IACH,OAAO,CACL,IAAC,qBAAqB,IAClB,KAAK,EAAE,6CAAqB;QAC9B,IAAC,IAAI,IAAC,GAAG,EAAE,GAAG,CAAA,qIAAqI;YACjJ,IAAC,MAAM;gBAAC,sCAA+B,CAAS;YAChD,IAAC,MAAM,IACL,GAAG,EAAE,GAAG,CAAA,UAAU;gBAClB,iFAAiF;gBACjF,gBAAgB,EAAE,oBAAoB,EACtC,SAAS,EAAC,kBAAkB,GAE5B,CACG,CACe,CACzB,CAAC;AACJ,CAAC,CAAC,CAAC;AAGH,eAAe;IACb,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,WAAW;CACV,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport React, { memo } from 'react';\nimport { jsx, css } from '@emotion/react';\nimport {\n Card,\n} from '@blueprintjs/core';\nimport Search from '../sidebar/Search';\nimport { RegisterHelmet as Helmet } from '../util';\nimport { TabContentsWithHeader } from '../util';\nimport { MATCHES_ANY_CRITERIA } from '../FilterCriteria/models';\n\n\nconst ItemSearch: React.VoidFunctionComponent<Record<never, never>> =\nmemo(function () {\n return (\n <TabContentsWithHeader\n title={<>Search all items</>}>\n <Card css={css`flex: 1; box-shadow: none !important; position: absolute; border-radius: 0; display: flex; flex-flow: column nowrap; padding: 10px;`}>\n <Helmet><title>Search all items</title></Helmet>\n <Search\n css={css`flex: 1;`}\n //style={{ height: '100vh', width: '50vw', minWidth: '500px', maxWidth: '90vw' }}\n implicitCriteria={MATCHES_ANY_CRITERIA}\n stateName=\"all-items-search\"\n //onOpenItem={onChooseItem ? handleOpenItem : undefined}\n />\n </Card>\n </TabContentsWithHeader>\n );\n});\n\n\nexport default {\n main: ItemSearch,\n title: \"All items\",\n} as const;\n"]}
1
+ {"version":3,"file":"AllItems.js","sourceRoot":"","sources":["../../../src/views/detail/AllItems.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,MAAM,MAAM,mBAAmB,CAAC;AACvC,OAAO,EAAE,cAAc,IAAI,MAAM,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGhE,MAAM,UAAU,GAChB,IAAI,CAAC;IACH,OAAO,CACL,IAAC,qBAAqB,IAClB,KAAK,EAAE,6CAAqB;QAC9B,IAAC,IAAI,IAAC,GAAG,EAAE,GAAG,CAAA;;;;;;;;WAQT;YACH,IAAC,MAAM;gBAAC,sCAA+B,CAAS;YAChD,IAAC,MAAM,IACL,GAAG,EAAE,GAAG,CAAA,UAAU;gBAClB,iFAAiF;gBACjF,gBAAgB,EAAE,oBAAoB,EACtC,SAAS,EAAC,kBAAkB,GAE5B,CACG,CACe,CACzB,CAAC;AACJ,CAAC,CAAC,CAAC;AAGH,eAAe;IACb,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,WAAW;CACV,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport React, { memo } from 'react';\nimport { jsx, css } from '@emotion/react';\nimport { Card } from '@blueprintjs/core';\nimport Search from '../sidebar/Search';\nimport { RegisterHelmet as Helmet } from '../util';\nimport { TabContentsWithHeader } from '../util';\nimport { MATCHES_ANY_CRITERIA } from '../FilterCriteria/models';\n\n\nconst ItemSearch: React.VoidFunctionComponent<Record<never, never>> =\nmemo(function () {\n return (\n <TabContentsWithHeader\n title={<>Search all items</>}>\n <Card css={css`\n flex: 1;\n box-shadow: none !important;\n position: absolute;\n border-radius: 0;\n display: flex;\n flex-flow: column nowrap;\n padding: 10px;\n `}>\n <Helmet><title>Search all items</title></Helmet>\n <Search\n css={css`flex: 1;`}\n //style={{ height: '100vh', width: '50vw', minWidth: '500px', maxWidth: '90vw' }}\n implicitCriteria={MATCHES_ANY_CRITERIA}\n stateName=\"all-items-search\"\n //onOpenItem={onChooseItem ? handleOpenItem : undefined}\n />\n </Card>\n </TabContentsWithHeader>\n );\n});\n\n\nexport default {\n main: ItemSearch,\n title: \"All items\",\n} as const;\n"]}
@@ -73,7 +73,7 @@ const ProposalWork = (0, _react.memo)(function () {
73
73
  try {
74
74
  latestAcceptedProposal = (0, _useLatestAcceptedProposal.default)();
75
75
  } catch (e) {
76
- console.error("Failed to obtain latest accepted proposal");
76
+ console.error("Failed to obtain latest accepted proposal", e);
77
77
  latestAcceptedProposal = undefined;
78
78
  }
79
79
 
@@ -1 +1 @@
1
- {"version":3,"file":"ProposalWork.js","sourceRoot":"","sources":["../../../src/views/detail/ProposalWork.tsx"],"names":[],"mappings":"AAAA,eAAe;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QAAQ,IAAI,WAAW,IAAI,WAAW,CAAC,WAAW,CAAC,IAAI,sBAAsB,KAAK,SAAS;oBAC1F,CAAC,CAAC;wBACE,gCAAW;wBACX,IAAC,eAAe,IACd,GAAG,EAAE,GAAG,CAAA,gBAAgB,EACxB,eAAe,EACb,CAAA,sBAAsB,aAAtB,sBAAsB,uBAAtB,sBAAsB,CAAE,YAAY;gCAClC,CAAC,CAAC,UAAU,CACR,sBAAsB,CAAC,YAAY,EACnC,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;gCACrC,CAAC,CAAC,IAAI,EACV,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,QAAQ,GACvB,CACD;oBACL,CAAC,CAAC,IAAI,CACP,GACH,CAAC;KACJ;SAAM;QACL,OAAO,IAAC,WAAW,IACjB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,SAAS,EAC/C,YAAY,EAAE,wBAAwB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,SAAS,GACrE,CAAC;KACJ;AACH,CAAC,CAAC,CAAC;AAGH,MAAM,iBAAiB,GAAsD;IAC3E,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACrE,OAAO,0BAAG,QAAQ;QAChB,CAAC,CAAC,sCAAgC;QAClC,CAAC,CAAC,+CAAuB,CAAI,CAAC;AAClC,CAAC,CAAC;AAGF,eAAe;IACb,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,iBAAiB;CAChB,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport React, { useMemo, useContext, useCallback, memo } from 'react';\nimport { jsx, css } from '@emotion/react';\nimport { NonIdealState } from '@blueprintjs/core';\n\nimport { DatasetContext } from '@riboseinc/paneron-extension-kit/context';\nimport type { ObjectChangeset } from '@riboseinc/paneron-extension-kit/types/objects';\n\nimport { BrowserCtx } from '../BrowserCtx';\nimport { canImportCR, canCreateCR } from '../../types/stakeholder';\nimport { ChangeRequestContext } from '../../proposals/ChangeRequestContext';\nimport ProposalTab from '../../proposals/ProposalTab';\nimport NewProposalMenu from '../../proposals/NewProposalMenu';\nimport { isImportableCR } from '../../proposals/types';\nimport { itemPathToItemRef } from '../itemPathUtils';\nimport { formatDate } from '../util';\nimport useLatestAcceptedProposal from '../../views/hooks/useLatestAcceptedProposal';\nimport {\n newCRObjectChangeset,\n importedProposalToCRObjectChangeset,\n} from '../../proposals';\n\n\nconst ProposalWork: React.VoidFunctionComponent<Record<never, never>> =\nmemo(function () {\n const { changeRequest: activeCR, deleteCR } = useContext(ChangeRequestContext);\n const {\n registerMetadata: register,\n stakeholder,\n setActiveChangeRequestID,\n itemClasses,\n } = useContext(BrowserCtx);\n const {\n getMapReducedData,\n requestFileFromFilesystem,\n updateObjects,\n performOperation,\n getObjectData,\n isBusy,\n } = useContext(DatasetContext);\n\n const handleDeactivate = useCallback(\n (() => setActiveChangeRequestID?.(null)),\n [setActiveChangeRequestID]);\n\n const handleDelete = useCallback(async () => {\n if (deleteCR && activeCR && setActiveChangeRequestID) {\n await deleteCR();\n setActiveChangeRequestID(null);\n }\n }, [deleteCR, setActiveChangeRequestID]);\n\n let latestAcceptedProposal: ReturnType<typeof useLatestAcceptedProposal> | undefined;\n try {\n latestAcceptedProposal = useLatestAcceptedProposal();\n } catch (e) {\n console.error(\"Failed to obtain latest accepted proposal\");\n latestAcceptedProposal = undefined;\n }\n const getNewEmptyCRChangeset:\n undefined | ((idea: string) => Promise<[ObjectChangeset, string]>) =\n useMemo(() => {\n if (stakeholder && canCreateCR(stakeholder) && latestAcceptedProposal !== undefined) {\n return async function getNewEmptyCRChangeset (newIdea: string) {\n const crID = crypto.randomUUID();\n return [newCRObjectChangeset(\n crID,\n newIdea,\n latestAcceptedProposal?.id ?? 'initial',\n stakeholder!.gitServerUsername!,\n ), crID];\n };\n } else {\n return undefined;\n }\n }, [stakeholder, latestAcceptedProposal?.id]);\n\n const getImportedCRChangeset:\n undefined | (() => Promise<[ObjectChangeset, string]>) =\n useMemo(() => {\n if (requestFileFromFilesystem && stakeholder && canImportCR(stakeholder)) {\n return async function getImportedCRChangeset() {\n const data = await requestFileFromFilesystem({\n prompt: \"Select one register proposal JSON file\",\n filters: [\n { name: \"JSON files\", extensions: ['.json'] },\n ],\n });\n const fileData = Object.values(data)[0]!;\n if (!fileData) {\n throw new Error(\"No file was selected\");\n }\n if (isImportableCR(fileData)) {\n try {\n const [changeset, crID] = await importedProposalToCRObjectChangeset(\n fileData,\n itemClasses,\n stakeholder!.gitServerUsername!,\n getObjectData,\n async function resolvePredicates(predicates) {\n const mapReduceChains = [...predicates.values()].map(predicate => ({\n [predicate]: {\n mapFunc: `\n const data = value.data;\n if (!key.startsWith('/proposals/') && data && (${predicate})) {\n emit({ objectPath: key, objectData: value });\n }\n `,\n },\n })).reduce((prev, curr) => ({ ...prev, ...curr }), {});\n\n const result:\n Record<string, { objectPath: string, objectData: any }[] | {}> =\n await getMapReducedData({\n chains: mapReduceChains,\n });\n\n return Object.entries(result).map(([chainLabel, chainResult]) => {\n const objects =\n // Map returns an empty object if there’re no items,\n // but we promise to return a list.\n (Array.isArray(chainResult) ? chainResult : []);\n if (objects.length < 1) {\n throw new Error(`Unable to resolve predicate to item UUID: no item found matching predicate ${chainLabel}`);\n } else if (objects.length > 1) {\n const objectOverview = objects.map((o: any) => JSON.stringify(o)).join(', ')\n throw new Error(`Unable to resolve predicate to item UUID: more than one item matches predicate ${chainLabel}: ${objectOverview}`);\n } else {\n return {\n // There’s just one item anyway, hence `objects[0]`.\n [chainLabel]: itemPathToItemRef(false, objects[0].objectPath),\n };\n }\n }).reduce((prev, curr) => ({ ...prev, ...curr }), {});\n },\n );\n return [changeset, crID];\n } catch (e) {\n console.error(\"Error reading proposal data\", e);\n throw new Error(\"Error reading proposal data\");\n }\n } else {\n throw new Error(\"Invalid proposal format\");\n }\n }\n } else {\n return undefined;\n }\n }, [getMapReducedData, requestFileFromFilesystem, getObjectData, stakeholder]);\n\n const [importCR, createCR] = useMemo(() => {\n if (updateObjects && setActiveChangeRequestID && !isBusy) {\n return [\n getImportedCRChangeset\n ? performOperation('importing proposal', async function () {\n const [objectChangeset, crID] = await getImportedCRChangeset(); \n await updateObjects({\n commitMessage: 'import proposal',\n objectChangeset,\n });\n setActiveChangeRequestID(crID);\n })\n : undefined,\n getNewEmptyCRChangeset\n ? performOperation('creating blank proposal', async function (newIdea: string) {\n const [objectChangeset, crID] = await getNewEmptyCRChangeset(newIdea);\n await updateObjects({\n commitMessage: `start new empty proposal ${newIdea}`,\n objectChangeset,\n });\n setActiveChangeRequestID(crID);\n })\n : undefined,\n ];\n } else {\n return [undefined, undefined];\n }\n }, [isBusy, performOperation, updateObjects, getImportedCRChangeset, getNewEmptyCRChangeset]);\n\n if (!activeCR || !register || !stakeholder) {\n return <NonIdealState\n icon=\"clean\"\n title=\"Not working on any proposal\"\n description={<>\n <p>\n Choose an actionable proposal from the sidebar to the left\n and activate it by double-clicking\n </p>\n {register && stakeholder && canCreateCR(stakeholder) && latestAcceptedProposal !== undefined\n ? <>\n <p>—or—</p>\n <NewProposalMenu\n css={css`height: 200px;`}\n previousVersion={\n latestAcceptedProposal?.timeDisposed\n ? formatDate(\n latestAcceptedProposal.timeDisposed,\n { showTime: true, useUTC: true })\n : null}\n onImport={importCR}\n onCreateBlank={createCR}\n />\n </>\n : null}\n </>}\n />;\n } else {\n return <ProposalTab\n proposal={activeCR}\n register={register}\n stakeholder={stakeholder}\n onDelete={(deleteCR) ? handleDelete : undefined}\n onDeactivate={setActiveChangeRequestID ? handleDeactivate : undefined}\n />;\n }\n});\n\n\nconst ProposalWorkTitle: React.VoidFunctionComponent<Record<never, never>> = function () {\n const { changeRequest: activeCR } = useContext(ChangeRequestContext);\n return <>{activeCR\n ? <strong>Active proposal</strong>\n : <>Proposal dashboard</>}</>;\n};\n\n\nexport default {\n main: ProposalWork,\n title: ProposalWorkTitle,\n} as const;\n"]}
1
+ {"version":3,"file":"ProposalWork.js","sourceRoot":"","sources":["../../../src/views/detail/ProposalWork.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAO,KAAK,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AACtE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAG1E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,WAAW,MAAM,6BAA6B,CAAC;AACtD,OAAO,eAAe,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,yBAAyB,MAAM,6CAA6C,CAAC;AACpF,OAAO,EACL,oBAAoB,EACpB,mCAAmC,GACpC,MAAM,iBAAiB,CAAC;AAGzB,MAAM,YAAY,GAClB,IAAI,CAAC;IACH,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAC/E,MAAM,EACJ,gBAAgB,EAAE,QAAQ,EAC1B,WAAW,EACX,wBAAwB,EACxB,WAAW,GACZ,GAAG,UAAU,CAAC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AC;AAClC,CAAC,CAAC;AAGF,eAAe;IACb,IAAI,EAAE,YAAY;IAClB,KAAK,EAAE,iBAAiB;CAChB,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport React, { useMemo, useContext, useCallback, memo } from 'react';\nimport { jsx, css } from '@emotion/react';\nimport { NonIdealState } from '@blueprintjs/core';\n\nimport { DatasetContext } from '@riboseinc/paneron-extension-kit/context';\nimport type { ObjectChangeset } from '@riboseinc/paneron-extension-kit/types/objects';\n\nimport { BrowserCtx } from '../BrowserCtx';\nimport { canImportCR, canCreateCR } from '../../types/stakeholder';\nimport { ChangeRequestContext } from '../../proposals/ChangeRequestContext';\nimport ProposalTab from '../../proposals/ProposalTab';\nimport NewProposalMenu from '../../proposals/NewProposalMenu';\nimport { isImportableCR } from '../../proposals/types';\nimport { itemPathToItemRef } from '../itemPathUtils';\nimport { formatDate } from '../util';\nimport useLatestAcceptedProposal from '../../views/hooks/useLatestAcceptedProposal';\nimport {\n newCRObjectChangeset,\n importedProposalToCRObjectChangeset,\n} from '../../proposals';\n\n\nconst ProposalWork: React.VoidFunctionComponent<Record<never, never>> =\nmemo(function () {\n const { changeRequest: activeCR, deleteCR } = useContext(ChangeRequestContext);\n const {\n registerMetadata: register,\n stakeholder,\n setActiveChangeRequestID,\n itemClasses,\n } = useContext(BrowserCtx);\n const {\n getMapReducedData,\n requestFileFromFilesystem,\n updateObjects,\n performOperation,\n getObjectData,\n isBusy,\n } = useContext(DatasetContext);\n\n const handleDeactivate = useCallback(\n (() => setActiveChangeRequestID?.(null)),\n [setActiveChangeRequestID]);\n\n const handleDelete = useCallback(async () => {\n if (deleteCR && activeCR && setActiveChangeRequestID) {\n await deleteCR();\n setActiveChangeRequestID(null);\n }\n }, [deleteCR, setActiveChangeRequestID]);\n\n let latestAcceptedProposal: ReturnType<typeof useLatestAcceptedProposal> | undefined;\n try {\n latestAcceptedProposal = useLatestAcceptedProposal();\n } catch (e) {\n console.error(\"Failed to obtain latest accepted proposal\", e);\n latestAcceptedProposal = undefined;\n }\n const getNewEmptyCRChangeset:\n undefined | ((idea: string) => Promise<[ObjectChangeset, string]>) =\n useMemo(() => {\n if (stakeholder && canCreateCR(stakeholder) && latestAcceptedProposal !== undefined) {\n return async function getNewEmptyCRChangeset (newIdea: string) {\n const crID = crypto.randomUUID();\n return [newCRObjectChangeset(\n crID,\n newIdea,\n latestAcceptedProposal?.id ?? 'initial',\n stakeholder!.gitServerUsername!,\n ), crID];\n };\n } else {\n return undefined;\n }\n }, [stakeholder, latestAcceptedProposal?.id]);\n\n const getImportedCRChangeset:\n undefined | (() => Promise<[ObjectChangeset, string]>) =\n useMemo(() => {\n if (requestFileFromFilesystem && stakeholder && canImportCR(stakeholder)) {\n return async function getImportedCRChangeset() {\n const data = await requestFileFromFilesystem({\n prompt: \"Select one register proposal JSON file\",\n filters: [\n { name: \"JSON files\", extensions: ['.json'] },\n ],\n });\n const fileData = Object.values(data)[0]!;\n if (!fileData) {\n throw new Error(\"No file was selected\");\n }\n if (isImportableCR(fileData)) {\n try {\n const [changeset, crID] = await importedProposalToCRObjectChangeset(\n fileData,\n itemClasses,\n stakeholder!.gitServerUsername!,\n getObjectData,\n async function resolvePredicates(predicates) {\n const mapReduceChains = [...predicates.values()].map(predicate => ({\n [predicate]: {\n mapFunc: `\n const data = value.data;\n if (!key.startsWith('/proposals/') && data && (${predicate})) {\n emit({ objectPath: key, objectData: value });\n }\n `,\n },\n })).reduce((prev, curr) => ({ ...prev, ...curr }), {});\n\n const result:\n Record<string, { objectPath: string, objectData: any }[] | {}> =\n await getMapReducedData({\n chains: mapReduceChains,\n });\n\n return Object.entries(result).map(([chainLabel, chainResult]) => {\n const objects =\n // Map returns an empty object if there’re no items,\n // but we promise to return a list.\n (Array.isArray(chainResult) ? chainResult : []);\n if (objects.length < 1) {\n throw new Error(`Unable to resolve predicate to item UUID: no item found matching predicate ${chainLabel}`);\n } else if (objects.length > 1) {\n const objectOverview = objects.map((o: any) => JSON.stringify(o)).join(', ')\n throw new Error(`Unable to resolve predicate to item UUID: more than one item matches predicate ${chainLabel}: ${objectOverview}`);\n } else {\n return {\n // There’s just one item anyway, hence `objects[0]`.\n [chainLabel]: itemPathToItemRef(false, objects[0].objectPath),\n };\n }\n }).reduce((prev, curr) => ({ ...prev, ...curr }), {});\n },\n );\n return [changeset, crID];\n } catch (e) {\n console.error(\"Error reading proposal data\", e);\n throw new Error(\"Error reading proposal data\");\n }\n } else {\n throw new Error(\"Invalid proposal format\");\n }\n }\n } else {\n return undefined;\n }\n }, [getMapReducedData, requestFileFromFilesystem, getObjectData, stakeholder]);\n\n const [importCR, createCR] = useMemo(() => {\n if (updateObjects && setActiveChangeRequestID && !isBusy) {\n return [\n getImportedCRChangeset\n ? performOperation('importing proposal', async function () {\n const [objectChangeset, crID] = await getImportedCRChangeset(); \n await updateObjects({\n commitMessage: 'import proposal',\n objectChangeset,\n });\n setActiveChangeRequestID(crID);\n })\n : undefined,\n getNewEmptyCRChangeset\n ? performOperation('creating blank proposal', async function (newIdea: string) {\n const [objectChangeset, crID] = await getNewEmptyCRChangeset(newIdea);\n await updateObjects({\n commitMessage: `start new empty proposal ${newIdea}`,\n objectChangeset,\n });\n setActiveChangeRequestID(crID);\n })\n : undefined,\n ];\n } else {\n return [undefined, undefined];\n }\n }, [isBusy, performOperation, updateObjects, getImportedCRChangeset, getNewEmptyCRChangeset]);\n\n if (!activeCR || !register || !stakeholder) {\n return <NonIdealState\n icon=\"clean\"\n title=\"Not working on any proposal\"\n description={<>\n <p>\n Choose an actionable proposal from the sidebar to the left\n and activate it by double-clicking\n </p>\n {register && stakeholder && canCreateCR(stakeholder) && latestAcceptedProposal !== undefined\n ? <>\n <p>—or—</p>\n <NewProposalMenu\n css={css`height: 200px;`}\n previousVersion={\n latestAcceptedProposal?.timeDisposed\n ? formatDate(\n latestAcceptedProposal.timeDisposed,\n { showTime: true, useUTC: true })\n : null}\n onImport={importCR}\n onCreateBlank={createCR}\n />\n </>\n : null}\n </>}\n />;\n } else {\n return <ProposalTab\n proposal={activeCR}\n register={register}\n stakeholder={stakeholder}\n onDelete={(deleteCR) ? handleDelete : undefined}\n onDeactivate={setActiveChangeRequestID ? handleDeactivate : undefined}\n />;\n }\n});\n\n\nconst ProposalWorkTitle: React.VoidFunctionComponent<Record<never, never>> = function () {\n const { changeRequest: activeCR } = useContext(ChangeRequestContext);\n return <>{activeCR\n ? <strong>Active proposal</strong>\n : <>Proposal dashboard</>}</>;\n};\n\n\nexport default {\n main: ProposalWork,\n title: ProposalWorkTitle,\n} as const;\n"]}
@@ -42,7 +42,15 @@ const RegisterHome2 = function () {
42
42
  return (0, _react2.jsx)(_util.TabContentsWithHeader, {
43
43
  title: (0, _react2.jsx)(_react.default.Fragment, null, "Welcome to ", (_a = registerMetadata === null || registerMetadata === void 0 ? void 0 : registerMetadata.name) !== null && _a !== void 0 ? _a : 'this register')
44
44
  }, (0, _react2.jsx)(_core.Card, {
45
- css: (0, _react2.css)`flex: 1; box-shadow: none !important; position: absolute; border-radius: 0; display: flex; flex-flow: column nowrap; padding: 10px;`
45
+ css: (0, _react2.css)`
46
+ flex: 1;
47
+ box-shadow: none !important;
48
+ position: absolute;
49
+ border-radius: 0;
50
+ display: flex;
51
+ flex-flow: column nowrap;
52
+ padding: 10px;
53
+ `
46
54
  }, (0, _react2.jsx)("p", null, "Search all items:"), (0, _react2.jsx)(_Search.default, {
47
55
  css: (0, _react2.css)`flex: 1; overflow: hidden;`,
48
56
  //style={{ height: '100vh', width: '50vw', minWidth: '500px', maxWidth: '90vw' }}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/views/detail/RegisterHome2/index.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE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":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport React, { useContext } from 'react';\nimport { jsx, css } from '@emotion/react';\nimport { NonIdealState, Button, Card } from '@blueprintjs/core';\n\nimport { TabbedWorkspaceContext } from '@riboseinc/paneron-extension-kit/widgets/TabbedWorkspace/context';\n\nimport { TabContentsWithHeader } from '../../util';\nimport { BrowserCtx } from '../../BrowserCtx';\nimport Search from '../../sidebar/Search';\nimport { Protocols } from '../../protocolRegistry';\n\n\nconst RegisterHome2: React.VoidFunctionComponent<Record<never, never>> = function () {\n const { registerMetadata } = useContext(BrowserCtx);\n const { spawnTab } = useContext(TabbedWorkspaceContext);\n return (\n <TabContentsWithHeader title={<>Welcome to {registerMetadata?.name ?? 'this register'}</>}>\n <Card css={css`flex: 1; box-shadow: none !important; position: absolute; border-radius: 0; display: flex; flex-flow: column nowrap; padding: 10px;`}>\n <p>\n Search all items:\n </p>\n <Search\n css={css`flex: 1; overflow: hidden;`}\n //style={{ height: '100vh', width: '50vw', minWidth: '500px', maxWidth: '90vw' }}\n stateName=\"item-search-home\"\n initialView={<>\n <div dangerouslySetInnerHTML={{ __html:\n registerMetadata?.contentSummary\n ?? \"There is no content summary of this registry yet.\"\n }} />\n <Button\n css={css`vertical-align: baseline; margin-top: .5em;`}\n onClick={() => spawnTab(Protocols.REGISTER_META)}>\n View register metadata\n </Button>\n </>}\n zeroResultsView={\n <NonIdealState\n icon=\"clean\"\n title=\"No results matching query\"\n />}\n />\n </Card>\n </TabContentsWithHeader>\n );\n};\n\nexport default RegisterHome2;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/views/detail/RegisterHome2/index.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM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\n/** @jsxFrag React.Fragment */\n\nimport React, { useContext } from 'react';\nimport { jsx, css } from '@emotion/react';\nimport { NonIdealState, Button, Card } from '@blueprintjs/core';\n\nimport { TabbedWorkspaceContext } from '@riboseinc/paneron-extension-kit/widgets/TabbedWorkspace/context';\n\nimport { TabContentsWithHeader } from '../../util';\nimport { BrowserCtx } from '../../BrowserCtx';\nimport Search from '../../sidebar/Search';\nimport { Protocols } from '../../protocolRegistry';\n\n\nconst RegisterHome2: React.VoidFunctionComponent<Record<never, never>> = function () {\n const { registerMetadata } = useContext(BrowserCtx);\n const { spawnTab } = useContext(TabbedWorkspaceContext);\n return (\n <TabContentsWithHeader title={<>Welcome to {registerMetadata?.name ?? 'this register'}</>}>\n <Card css={css`\n flex: 1;\n box-shadow: none !important;\n position: absolute;\n border-radius: 0;\n display: flex;\n flex-flow: column nowrap;\n padding: 10px;\n `}>\n <p>\n Search all items:\n </p>\n <Search\n css={css`flex: 1; overflow: hidden;`}\n //style={{ height: '100vh', width: '50vw', minWidth: '500px', maxWidth: '90vw' }}\n stateName=\"item-search-home\"\n initialView={<>\n <div dangerouslySetInnerHTML={{ __html:\n registerMetadata?.contentSummary\n ?? \"There is no content summary of this registry yet.\"\n }} />\n <Button\n css={css`vertical-align: baseline; margin-top: .5em;`}\n onClick={() => spawnTab(Protocols.REGISTER_META)}>\n View register metadata\n </Button>\n </>}\n zeroResultsView={\n <NonIdealState\n icon=\"clean\"\n title=\"No results matching query\"\n />}\n />\n </Card>\n </TabContentsWithHeader>\n );\n};\n\nexport default RegisterHome2;\n"]}
@@ -7,6 +7,8 @@ exports.default = useLatestAcceptedProposal;
7
7
 
8
8
  var _react = require("react");
9
9
 
10
+ var _util = require("@riboseinc/paneron-extension-kit/util");
11
+
10
12
  var _context = require("@riboseinc/paneron-extension-kit/context");
11
13
 
12
14
  var _queries = require("../../proposals/queries");
@@ -36,7 +38,7 @@ function useLatestAcceptedProposal() {
36
38
  });
37
39
  const result = latestAcceptedProposalDisposedTimestamp.value.unnamedChain;
38
40
 
39
- if (result) {
41
+ if (result && (0, _util.isObject)(result) && Object.keys(result).length > 0) {
40
42
  if ((0, _types.isAccepted)(result) || (0, _types.isAcceptedOnAppeal)(result)) {
41
43
  return result;
42
44
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"useLatestAcceptedProposal.js","sourceRoot":"","sources":["../../../src/views/hooks/useLatestAcceptedProposal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EACL,KAAK,EACU,UAAU,EACF,kBAAkB,GAC1C,MAAM,uBAAuB,CAAC;AAG/B,MAAM,CAAC,OAAO,UAAU,yBAAyB;IAC/C,MAAM,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAEzD,MAAM,uCAAuC,GAAG,iBAAiB,CAAC;QAChE,MAAM,EAAE;YACN,YAAY,EAAE;gBACb,aAAa,EAAE;;oBAEF,aAAa,6BAA6B,KAAK,CAAC,QAAQ,OAAO,KAAK,CAAC,kBAAkB;EACzG;gBACD,OAAO,EAAE,iEAAiE;gBAC1E,UAAU,EAAE;;;;;EAKX;aACK;SACF;KACF,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,uCAAuC,CAAC,KAAK,CAAC,YAAY,CAAC;IAC1E,IAAI,MAAM,EAAE;QACV,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAAE;YACpD,OAAO,MAAM,CAAC;SACf;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAA;SACrF;KACF;SAAM;QACL,OAAO,IAAI,CAAC;QACZ,mFAAmF;KACpF;AACH,CAAC","sourcesContent":["import { useContext } from 'react';\nimport { DatasetContext } from '@riboseinc/paneron-extension-kit/context';\nimport { CR_BASE_QUERY } from '../../proposals/queries';\nimport {\n State,\n type Accepted, isAccepted,\n type AcceptedOnAppeal, isAcceptedOnAppeal,\n} from '../../proposals/types';\n\n\nexport default function useLatestAcceptedProposal(): Accepted | AcceptedOnAppeal | null {\n const { useMapReducedData } = useContext(DatasetContext);\n\n const latestAcceptedProposalDisposedTimestamp = useMapReducedData({\n chains: {\n unnamedChain: {\n \tpredicateFunc: `\n const objPath = key, obj = value;\n return (${CR_BASE_QUERY} && obj.timeDisposed && ['${State.ACCEPTED}', '${State.ACCEPTED_ON_APPEAL}'].indexOf(obj.state) >= 0);\n\t`,\n\tmapFunc: `emit({ ...value, timeDisposed: new Date(value.timeDisposed) });`,\n\treduceFunc: `\n\t if (!accumulator.timeDisposed || value.timeDisposed > accumulator.timeDisposed) {\n\t return value;\n\t }\n\t else { return accumulator; }\n\t`,\n },\n },\n });\n\n const result = latestAcceptedProposalDisposedTimestamp.value.unnamedChain;\n if (result) {\n if (isAccepted(result) || isAcceptedOnAppeal(result)) {\n return result;\n } else {\n throw new Error(\"Failed to obtain latest accepted proposal: invalid proposal shape\")\n }\n } else {\n return null;\n //throw new Error(\"Failed to obtain latest accepted proposal: possibly none exist\")\n }\n}\n"]}
1
+ {"version":3,"file":"useLatestAcceptedProposal.js","sourceRoot":"","sources":["../../../src/views/hooks/useLatestAcceptedProposal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,uCAAuC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EACL,KAAK,EACU,UAAU,EACF,kBAAkB,GAC1C,MAAM,uBAAuB,CAAC;AAG/B,MAAM,CAAC,OAAO,UAAU,yBAAyB;IAC/C,MAAM,EAAE,iBAAiB,EAAE,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAEzD,MAAM,uCAAuC,GAAG,iBAAiB,CAAC;QAChE,MAAM,EAAE;YACN,YAAY,EAAE;gBACb,aAAa,EAAE;;oBAEF,aAAa,6BAA6B,KAAK,CAAC,QAAQ,OAAO,KAAK,CAAC,kBAAkB;EACzG;gBACD,OAAO,EAAE,iEAAiE;gBAC1E,UAAU,EAAE;;;;;EAKX;aACK;SACF;KACF,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,uCAAuC,CAAC,KAAK,CAAC,YAAY,CAAC;IAC1E,IAAI,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE;QAChE,IAAI,UAAU,CAAC,MAAqC,CAAC,IAAI,kBAAkB,CAAC,MAAqC,CAAC,EAAE;YAClH,OAAO,MAAqC,CAAC;SAC9C;aAAM;YACL,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAA;SACrF;KACF;SAAM;QACL,OAAO,IAAI,CAAC;QACZ,mFAAmF;KACpF;AACH,CAAC","sourcesContent":["import { useContext } from 'react';\nimport { isObject } from '@riboseinc/paneron-extension-kit/util';\nimport { DatasetContext } from '@riboseinc/paneron-extension-kit/context';\nimport { CR_BASE_QUERY } from '../../proposals/queries';\nimport {\n State,\n type Accepted, isAccepted,\n type AcceptedOnAppeal, isAcceptedOnAppeal,\n} from '../../proposals/types';\n\n\nexport default function useLatestAcceptedProposal(): Accepted | AcceptedOnAppeal | null {\n const { useMapReducedData } = useContext(DatasetContext);\n\n const latestAcceptedProposalDisposedTimestamp = useMapReducedData({\n chains: {\n unnamedChain: {\n \tpredicateFunc: `\n const objPath = key, obj = value;\n return (${CR_BASE_QUERY} && obj.timeDisposed && ['${State.ACCEPTED}', '${State.ACCEPTED_ON_APPEAL}'].indexOf(obj.state) >= 0);\n\t`,\n\tmapFunc: `emit({ ...value, timeDisposed: new Date(value.timeDisposed) });`,\n\treduceFunc: `\n\t if (!accumulator.timeDisposed || value.timeDisposed > accumulator.timeDisposed) {\n\t return value;\n\t }\n\t else { return accumulator; }\n\t`,\n },\n },\n });\n\n const result = latestAcceptedProposalDisposedTimestamp.value.unnamedChain;\n if (result && isObject(result) && Object.keys(result).length > 0) {\n if (isAccepted(result as Accepted | AcceptedOnAppeal) || isAcceptedOnAppeal(result as Accepted | AcceptedOnAppeal)) {\n return result as Accepted | AcceptedOnAppeal;\n } else {\n throw new Error(\"Failed to obtain latest accepted proposal: invalid proposal shape\")\n }\n } else {\n return null;\n //throw new Error(\"Failed to obtain latest accepted proposal: possibly none exist\")\n }\n}\n"]}