@riboseinc/paneron-registry-kit 2.2.19 → 2.2.21

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/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import React from 'react';
2
1
  import type { Extension } from '@riboseinc/paneron-extension-kit/types';
3
2
  import type { ExtensionMakerProps } from '@riboseinc/paneron-extension-kit/types/extension-maker';
4
3
  import type { RegistryViewProps } from './types';
@@ -7,18 +6,8 @@ export declare type RegistryExtensionMaker = (opts: RegistryExtensionMakerProps)
7
6
  export declare const makeRegistryExtension: RegistryExtensionMaker;
8
7
  import { BrowserCtx } from './views/BrowserCtx';
9
8
  import { itemRefToItemPath, incompleteItemRefToItemPathPrefix } from './views/itemPathUtils';
10
- declare const _default: {
11
- makeRegistryExtension: RegistryExtensionMaker;
12
- itemRefToItemPath: typeof itemRefToItemPath;
13
- incompleteItemRefToItemPathPrefix: typeof incompleteItemRefToItemPathPrefix;
14
- BrowserCtx: React.Context<BrowserCtx>;
15
- CRITERIA_CONFIGURATION: import("./views/FilterCriteria/models").CriteriaConfiguration;
16
- GenericRelatedItemView: React.FC<import("./types").GenericRelatedItemViewProps & {
17
- controlGroupProps?: import("@blueprintjs/core").IControlGroupProps | undefined;
18
- }>;
19
- PropertyDetailView: React.FC<import("@blueprintjs/core").IFormGroupProps & {
20
- title?: React.ReactNode;
21
- secondaryTitle?: React.ReactNode;
22
- }>;
23
- };
24
- export default _default;
9
+ import GenericRelatedItemView from './views/GenericRelatedItemView';
10
+ import { PropertyDetailView } from './views/util';
11
+ import CRITERIA_CONFIGURATION from './views/FilterCriteria/CRITERIA_CONFIGURATION';
12
+ import useSingleRegisterItemData from './views/hooks/useSingleRegisterItemData';
13
+ export { itemRefToItemPath, incompleteItemRefToItemPathPrefix, BrowserCtx, CRITERIA_CONFIGURATION, GenericRelatedItemView, PropertyDetailView, useSingleRegisterItemData, };
package/index.js CHANGED
@@ -3,7 +3,49 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = exports.makeRegistryExtension = void 0;
6
+ Object.defineProperty(exports, "BrowserCtx", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _BrowserCtx.BrowserCtx;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "itemRefToItemPath", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _itemPathUtils.itemRefToItemPath;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "incompleteItemRefToItemPathPrefix", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _itemPathUtils.incompleteItemRefToItemPathPrefix;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "GenericRelatedItemView", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _GenericRelatedItemView.default;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "PropertyDetailView", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _util.PropertyDetailView;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "CRITERIA_CONFIGURATION", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _CRITERIA_CONFIGURATION.default;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "useSingleRegisterItemData", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _useSingleRegisterItemData.default;
46
+ }
47
+ });
48
+ exports.makeRegistryExtension = void 0;
7
49
 
8
50
  var _react = _interopRequireDefault(require("react"));
9
51
 
@@ -25,6 +67,8 @@ var _util = require("./views/util");
25
67
 
26
68
  var _CRITERIA_CONFIGURATION = _interopRequireDefault(require("./views/FilterCriteria/CRITERIA_CONFIGURATION"));
27
69
 
70
+ var _useSingleRegisterItemData = _interopRequireDefault(require("./views/hooks/useSingleRegisterItemData"));
71
+
28
72
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
29
73
 
30
74
  const makeRegistryExtension = function (opts) {
@@ -51,7 +95,10 @@ const makeRegistryExtension = function (opts) {
51
95
  const mainView = function _RegistryView() {
52
96
  return _react.default.createElement(_views.RegistryView, {
53
97
  itemClassConfiguration: opts.itemClassConfiguration,
54
- subregisters: opts.subregisters
98
+ subregisters: opts.subregisters,
99
+ defaultSearchCriteria: opts.defaultSearchCriteria,
100
+ keyExpression: opts.keyExpression,
101
+ getQuickSearchPredicate: opts.getQuickSearchPredicate
55
102
  });
56
103
  };
57
104
 
@@ -64,14 +111,4 @@ const makeRegistryExtension = function (opts) {
64
111
  });
65
112
  };
66
113
 
67
- exports.makeRegistryExtension = makeRegistryExtension;
68
- var _default = {
69
- makeRegistryExtension,
70
- itemRefToItemPath: _itemPathUtils.itemRefToItemPath,
71
- incompleteItemRefToItemPathPrefix: _itemPathUtils.incompleteItemRefToItemPathPrefix,
72
- BrowserCtx: _BrowserCtx.BrowserCtx,
73
- CRITERIA_CONFIGURATION: _CRITERIA_CONFIGURATION.default,
74
- GenericRelatedItemView: _GenericRelatedItemView.default,
75
- PropertyDetailView: _util.PropertyDetailView
76
- };
77
- exports.default = _default;
114
+ exports.makeRegistryExtension = makeRegistryExtension;
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,OAAO,aAAa,MAAM,wDAAwD,CAAC;AAInF,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAQvC,MAAM,CAAC,MAAM,qBAAqB,GAA2B,UAAU,IAAI;IACzE,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAEtB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,CAAC,EAAE;QAC5D,KAAK,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;YACtD,MAAM,IAAI,GAAG,IAAW,CAAC;YACzB,IAAI,IAAI,EAAE;gBACR,GAAG,CAAC,KAAK,CAAC,MAAoD,CAAC,GAAG,SAAS,uBAAuB,CAAC,KAAK;oBACtG,OAAO,CACL,oBAAC,aAAa,IACV,QAAQ,EAAE,mBAAmB,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,EAC7C,MAAM,EAAE,MAAM,KAAK,cAAc;wBACnC,oBAAC,IAAI,OAAK,KAAK,GAAI,CACL,CACjB,CAAC;gBACJ,CAAC,CAAC;aACH;SACF;KACF;IAED,MAAM,QAAQ,GAAoC,SAAS,aAAa;QACtE,OAAO,CACL,oBAAC,YAAY,IACX,sBAAsB,EAAE,IAAI,CAAC,sBAAsB,EACnD,YAAY,EAAE,IAAI,CAAC,YAAY,GAC/B,CACH,CAAC;IACJ,CAAC,CAAC;IAEF,OAAO,aAAa,CAAC;QACnB,QAAQ;QACR,IAAI;QACJ,sBAAsB,EAAE,OAAO;QAC/B,iBAAiB,EAAE,EAAE;QACrB,kBAAkB;KACnB,CAAC,CAAC;AACL,CAAC,CAAC;AAGF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,iCAAiC,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,sBAAsB,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,sBAAsB,MAAM,+CAA+C,CAAC;AAEnF,eAAe;IACb,qBAAqB;IACrB,iBAAiB;IACjB,iCAAiC;IACjC,UAAU;IACV,sBAAsB;IACtB,sBAAsB;IACtB,kBAAkB;CACnB,CAAC","sourcesContent":["import React from 'react';\nimport { makeExtension } from '@riboseinc/paneron-extension-kit';\nimport type { Extension } from '@riboseinc/paneron-extension-kit/types';\nimport ErrorBoundary from '@riboseinc/paneron-extension-kit/widgets/ErrorBoundary';\nimport type { ExtensionMakerProps } from '@riboseinc/paneron-extension-kit/types/extension-maker';\nimport type { RegistryViewProps } from './types';\nimport type { ItemClassConfiguration } from './types/views';\nimport datasetInitializer from './migrations/initial';\nimport { RegistryView } from './views';\n\nexport type RegistryExtensionMakerProps =\n Pick<ExtensionMakerProps, 'name'> & RegistryViewProps\n\nexport type RegistryExtensionMaker =\n (opts: RegistryExtensionMakerProps) => Promise<Extension>;\n\nexport const makeRegistryExtension: RegistryExtensionMaker = function (opts) {\n const { name } = opts;\n\n for (const cls of Object.values(opts.itemClassConfiguration)) {\n for (const [viewID, view] of Object.entries(cls.views)) {\n const View = view as any;\n if (View) {\n cls.views[viewID as keyof ItemClassConfiguration<any>[\"views\"]] = function WrappedRegisterItemView(props) {\n return (\n <ErrorBoundary\n viewName={`Detail view for ${cls.meta.title}`}\n inline={viewID === 'listItemView'}>\n <View {...props} />\n </ErrorBoundary>\n );\n };\n }\n }\n }\n\n const mainView: ExtensionMakerProps[\"mainView\"] = function _RegistryView () {\n return (\n <RegistryView\n itemClassConfiguration={opts.itemClassConfiguration}\n subregisters={opts.subregisters}\n />\n );\n };\n\n return makeExtension({\n mainView,\n name,\n requiredHostAppVersion: '2.0.0',\n datasetMigrations: {},\n datasetInitializer,\n });\n};\n\n\nimport { BrowserCtx } from './views/BrowserCtx';\nimport { itemRefToItemPath, incompleteItemRefToItemPathPrefix } from './views/itemPathUtils';\nimport GenericRelatedItemView from './views/GenericRelatedItemView';\nimport { PropertyDetailView } from './views/util';\nimport CRITERIA_CONFIGURATION from './views/FilterCriteria/CRITERIA_CONFIGURATION';\n\nexport default {\n makeRegistryExtension,\n itemRefToItemPath,\n incompleteItemRefToItemPathPrefix,\n BrowserCtx,\n CRITERIA_CONFIGURATION,\n GenericRelatedItemView,\n PropertyDetailView,\n};\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;A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;QACrB,kBAAkB;KACnB,CAAC,CAAC;AACL,CAAC,CAAC;AAGF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,iCAAiC,EAAE,MAAM,uBAAuB,CAAC;AAC7F,OAAO,sBAAsB,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,sBAAsB,MAAM,+CAA+C,CAAC;AACnF,OAAO,yBAAyB,MAAM,yCAAyC,CAAC;AAEhF,OAAO,EACL,iBAAiB,EACjB,iCAAiC,EACjC,UAAU,EACV,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,yBAAyB,GAC1B,CAAC","sourcesContent":["import React from 'react';\nimport { makeExtension } from '@riboseinc/paneron-extension-kit';\nimport type { Extension } from '@riboseinc/paneron-extension-kit/types';\nimport ErrorBoundary from '@riboseinc/paneron-extension-kit/widgets/ErrorBoundary';\nimport type { ExtensionMakerProps } from '@riboseinc/paneron-extension-kit/types/extension-maker';\nimport type { RegistryViewProps } from './types';\nimport type { ItemClassConfiguration } from './types/views';\nimport datasetInitializer from './migrations/initial';\nimport { RegistryView } from './views';\n\nexport type RegistryExtensionMakerProps =\n Pick<ExtensionMakerProps, 'name'> & RegistryViewProps\n\nexport type RegistryExtensionMaker =\n (opts: RegistryExtensionMakerProps) => Promise<Extension>;\n\nexport const makeRegistryExtension: RegistryExtensionMaker = function (opts) {\n const { name } = opts;\n\n for (const cls of Object.values(opts.itemClassConfiguration)) {\n for (const [viewID, view] of Object.entries(cls.views)) {\n const View = view as any;\n if (View) {\n cls.views[viewID as keyof ItemClassConfiguration<any>[\"views\"]] = function WrappedRegisterItemView(props) {\n return (\n <ErrorBoundary\n viewName={`Detail view for ${cls.meta.title}`}\n inline={viewID === 'listItemView'}>\n <View {...props} />\n </ErrorBoundary>\n );\n };\n }\n }\n }\n\n const mainView: ExtensionMakerProps[\"mainView\"] = function _RegistryView () {\n return (\n <RegistryView\n itemClassConfiguration={opts.itemClassConfiguration}\n subregisters={opts.subregisters}\n defaultSearchCriteria={opts.defaultSearchCriteria}\n keyExpression={opts.keyExpression}\n getQuickSearchPredicate={opts.getQuickSearchPredicate}\n />\n );\n };\n\n return makeExtension({\n mainView,\n name,\n requiredHostAppVersion: '2.0.0',\n datasetMigrations: {},\n datasetInitializer,\n });\n};\n\n\nimport { BrowserCtx } from './views/BrowserCtx';\nimport { itemRefToItemPath, incompleteItemRefToItemPathPrefix } from './views/itemPathUtils';\nimport GenericRelatedItemView from './views/GenericRelatedItemView';\nimport { PropertyDetailView } from './views/util';\nimport CRITERIA_CONFIGURATION from './views/FilterCriteria/CRITERIA_CONFIGURATION';\nimport useSingleRegisterItemData from './views/hooks/useSingleRegisterItemData';\n\nexport {\n itemRefToItemPath,\n incompleteItemRefToItemPathPrefix,\n BrowserCtx,\n CRITERIA_CONFIGURATION,\n GenericRelatedItemView,\n PropertyDetailView,\n useSingleRegisterItemData,\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riboseinc/paneron-registry-kit",
3
- "version": "2.2.19",
3
+ "version": "2.2.21",
4
4
  "main": "index.js",
5
5
  "author": "Ribose Inc. <open.source@ribose.com>",
6
6
  "scripts": {
@@ -28,7 +28,7 @@
28
28
  "@blueprintjs/select": "~4.9.10",
29
29
  "@emotion/react": "^11.10.6",
30
30
  "@emotion/styled": "^11.10.6",
31
- "@riboseinc/paneron-extension-kit": "2.2.11",
31
+ "@riboseinc/paneron-extension-kit": "2.2.14",
32
32
  "@types/react": "17.0.53",
33
33
  "@types/react-dom": "^17.0.2",
34
34
  "@types/react-helmet": "^6.1.2",
@@ -38,6 +38,11 @@ export interface ChangeRequest {
38
38
  * (`controlBodyNotes` is in question.)
39
39
  */
40
40
  export declare type DraftChangeRequest = Pick<ChangeRequest, 'proposals' | 'justification' | 'controlBodyNotes' | 'sponsor'>;
41
+ export declare const ChangeProposalType: {
42
+ readonly ADDITION: "addition";
43
+ readonly CLARIFICATION: "clarification";
44
+ readonly AMENDMENT: "amendment";
45
+ };
41
46
  export declare const PROPOSAL_TYPES: readonly ["addition", "clarification", "amendment"];
42
47
  interface BaseProposal {
43
48
  disposition?: 'accepted' | 'notAccepted';
@@ -45,26 +50,41 @@ interface BaseProposal {
45
50
  sources?: Citation[];
46
51
  }
47
52
  export interface Addition extends BaseProposal {
48
- type: 'addition';
53
+ type: typeof ChangeProposalType.ADDITION;
49
54
  }
50
55
  export interface Clarification extends BaseProposal {
51
- type: 'clarification';
56
+ type: typeof ChangeProposalType.CLARIFICATION;
52
57
  }
58
+ export declare const AmendmentType: {
59
+ readonly SUPERSESSION: "supersession";
60
+ readonly RETIREMENT: "retirement";
61
+ readonly INVALIDATION: "invalidation";
62
+ };
63
+ export declare type AmendmentTypeType = typeof AmendmentType[keyof typeof AmendmentType];
53
64
  export declare const AMENDMENT_TYPES: readonly ["supersession", "retirement", "invalidation"];
54
65
  interface BaseAmendment extends BaseProposal {
55
- type: 'amendment';
56
- amendmentType: typeof AMENDMENT_TYPES[number];
66
+ type: typeof ChangeProposalType.AMENDMENT;
67
+ amendmentType: AmendmentTypeType;
57
68
  }
58
69
  export interface Retirement extends BaseAmendment {
59
- amendmentType: 'retirement';
70
+ amendmentType: typeof AmendmentType.RETIREMENT;
60
71
  }
61
72
  export interface Supersession extends BaseAmendment {
62
- amendmentType: 'supersession';
73
+ amendmentType: typeof AmendmentType.SUPERSESSION;
63
74
  supersedingItemIDs: string[];
64
75
  }
65
76
  export interface Invalidation extends BaseAmendment {
66
- amendmentType: 'invalidation';
77
+ amendmentType: typeof AmendmentType.INVALIDATION;
67
78
  }
68
79
  export declare type Amendment = Supersession | Retirement | Invalidation;
69
80
  export declare type ChangeProposal = Amendment | Clarification | Addition;
81
+ export declare function isBaseProposal(val: any): val is BaseProposal;
82
+ export declare function isProposal(val: any): val is ChangeProposal;
83
+ export declare function isAddition(val: BaseProposal): val is Addition;
84
+ export declare function isClarification(val: BaseProposal): val is Clarification;
85
+ export declare function isBaseAmendment(val: BaseProposal): val is BaseAmendment;
86
+ export declare function isAmendment(val: any): val is Amendment;
87
+ export declare function isRetirement(val: BaseAmendment): val is Retirement;
88
+ export declare function isSupersession(val: BaseAmendment): val is Supersession;
89
+ export declare function isInvalidation(val: BaseAmendment): val is Invalidation;
70
90
  export {};
package/types/proposal.js CHANGED
@@ -3,12 +3,69 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.AMENDMENT_TYPES = exports.PROPOSAL_TYPES = exports.DISPOSITION_OPTIONS = exports.DECISION_STATUSES = void 0;
6
+ exports.isBaseProposal = isBaseProposal;
7
+ exports.isProposal = isProposal;
8
+ exports.isAddition = isAddition;
9
+ exports.isClarification = isClarification;
10
+ exports.isBaseAmendment = isBaseAmendment;
11
+ exports.isAmendment = isAmendment;
12
+ exports.isRetirement = isRetirement;
13
+ exports.isSupersession = isSupersession;
14
+ exports.isInvalidation = isInvalidation;
15
+ exports.AMENDMENT_TYPES = exports.AmendmentType = exports.PROPOSAL_TYPES = exports.ChangeProposalType = exports.DISPOSITION_OPTIONS = exports.DECISION_STATUSES = void 0;
7
16
  const DECISION_STATUSES = ['pending', 'tentative', 'final'];
8
17
  exports.DECISION_STATUSES = DECISION_STATUSES;
9
18
  const DISPOSITION_OPTIONS = ['withdrawn', 'accepted', 'notAccepted'];
10
19
  exports.DISPOSITION_OPTIONS = DISPOSITION_OPTIONS;
11
- const PROPOSAL_TYPES = ['addition', 'clarification', 'amendment'];
20
+ const ChangeProposalType = {
21
+ ADDITION: 'addition',
22
+ CLARIFICATION: 'clarification',
23
+ AMENDMENT: 'amendment'
24
+ };
25
+ exports.ChangeProposalType = ChangeProposalType;
26
+ const PROPOSAL_TYPES = [ChangeProposalType.ADDITION, ChangeProposalType.CLARIFICATION, ChangeProposalType.AMENDMENT];
12
27
  exports.PROPOSAL_TYPES = PROPOSAL_TYPES;
13
- const AMENDMENT_TYPES = ['supersession', 'retirement', 'invalidation'];
14
- exports.AMENDMENT_TYPES = AMENDMENT_TYPES;
28
+ const AmendmentType = {
29
+ SUPERSESSION: 'supersession',
30
+ RETIREMENT: 'retirement',
31
+ INVALIDATION: 'invalidation'
32
+ };
33
+ exports.AmendmentType = AmendmentType;
34
+ const AMENDMENT_TYPES = [AmendmentType.SUPERSESSION, AmendmentType.RETIREMENT, AmendmentType.INVALIDATION];
35
+ exports.AMENDMENT_TYPES = AMENDMENT_TYPES;
36
+
37
+ function isBaseProposal(val) {
38
+ return PROPOSAL_TYPES.indexOf(val === null || val === void 0 ? void 0 : val.type) >= 0;
39
+ }
40
+
41
+ function isProposal(val) {
42
+ return isBaseProposal(val) && (isAddition(val) || isClarification(val) || isAmendment(val));
43
+ }
44
+
45
+ function isAddition(val) {
46
+ return val.type === ChangeProposalType.ADDITION;
47
+ }
48
+
49
+ function isClarification(val) {
50
+ return val.type === ChangeProposalType.CLARIFICATION;
51
+ }
52
+
53
+ function isBaseAmendment(val) {
54
+ return val.type === ChangeProposalType.AMENDMENT && AMENDMENT_TYPES.indexOf(val.amendmentType) >= 0;
55
+ }
56
+
57
+ function isAmendment(val) {
58
+ return isBaseAmendment(val) && (isRetirement(val) || isSupersession(val) || isInvalidation(val));
59
+ }
60
+
61
+ function isRetirement(val) {
62
+ return val.amendmentType === AmendmentType.RETIREMENT;
63
+ }
64
+
65
+ function isSupersession(val) {
66
+ return val.amendmentType === AmendmentType.SUPERSESSION;
67
+ }
68
+
69
+ function isInvalidation(val) {
70
+ return val.amendmentType === AmendmentType.INVALIDATION;
71
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"proposal.js","sourceRoot":"","sources":["../../src/types/proposal.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,SAAS;IACT,WAAW;IACX,OAAO;CACC,CAAC;AAEX,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,WAAW;IACX,UAAU;IACV,aAAa;CACL,CAAC;AAiDX,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,UAAU;IACV,eAAe;IACf,WAAW;CACH,CAAC;AAqBX,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,cAAc;IACd,YAAY;IACZ,cAAc;CACN,CAAC","sourcesContent":["import type { RegisterStakeholder } from './stakeholder';\nimport type { Citation } from './util';\n\n\nexport const DECISION_STATUSES = [\n 'pending',\n 'tentative',\n 'final',\n] as const;\n\nexport const DISPOSITION_OPTIONS = [\n 'withdrawn',\n 'accepted',\n 'notAccepted',\n] as const;\n\n/**\n * Item paths in proposal set must start with a slash\n * and will be treated relative to dataset root.\n * Object paths should conform to registry item path shape\n * of `/<classID>/<itemID>.yaml`.\n * (the `[/subregisterID]/<classID>/<itemID>.yaml` is acceptable\n * but deprecated, as subregisters are deprecated).\n */\nexport type ProposalSet = {\n [objectPath: string]: ChangeProposal\n}\n\n/**\n * A change request, per ISO 19135-1 model.\n *\n * @deprecated use cr.Base (or a more specific type) instead\n */\nexport interface ChangeRequest {\n // Supplied by sponsor\n /** Justification for the change */\n justification: string\n\n proposals: ProposalSet\n\n // Enforced by the system\n id: string\n timeStarted: Date\n timeProposed?: Date\n timeDisposed?: Date\n sponsor: RegisterStakeholder\n\n // Supplied by register manager\n status: typeof DECISION_STATUSES[number] // Default filled in by the system but changeable\n disposition?: typeof DISPOSITION_OPTIONS[number]\n controlBodyDecisionEvent?: string\n controlBodyNotes?: string\n registerManagerNotes?: string\n}\n\n\n/**\n * Change request properties for the purposes of drafting.\n * (`controlBodyNotes` is in question.)\n */\nexport type DraftChangeRequest =\n Pick<ChangeRequest, 'proposals' | 'justification' | 'controlBodyNotes' | 'sponsor'>;\n\nexport const PROPOSAL_TYPES = [\n 'addition',\n 'clarification',\n 'amendment',\n] as const;\n\ninterface BaseProposal {\n //itemID: RegisterItemID\n disposition?: 'accepted' | 'notAccepted'\n type: typeof PROPOSAL_TYPES[number]\n sources?: Citation[]\n}\n\nexport interface Addition extends BaseProposal {\n type: 'addition'\n ///** New item data. */\n //payload: Payload\n}\n\nexport interface Clarification extends BaseProposal {\n type: 'clarification'\n ///** Updated item data */\n //payload: Payload\n}\n\nexport const AMENDMENT_TYPES = [\n 'supersession',\n 'retirement',\n 'invalidation',\n] as const;\ninterface BaseAmendment extends BaseProposal {\n type: 'amendment'\n amendmentType: typeof AMENDMENT_TYPES[number]\n}\nexport interface Retirement extends BaseAmendment {\n amendmentType: 'retirement'\n}\nexport interface Supersession extends BaseAmendment {\n amendmentType: 'supersession'\n supersedingItemIDs: string[]\n}\nexport interface Invalidation extends BaseAmendment {\n amendmentType: 'invalidation'\n}\nexport type Amendment = Supersession | Retirement | Invalidation\n\nexport type ChangeProposal = Amendment | Clarification | Addition\n"]}
1
+ {"version":3,"file":"proposal.js","sourceRoot":"","sources":["../../src/types/proposal.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,SAAS;IACT,WAAW;IACX,OAAO;CACC,CAAC;AAEX,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,WAAW;IACX,UAAU;IACV,aAAa;CACL,CAAC;AAiDX,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,QAAQ,EAAE,UAAU;IACpB,aAAa,EAAE,eAAe;IAC9B,SAAS,EAAE,WAAW;CACd,CAAC;AACX,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,kBAAkB,CAAC,QAAQ;IAC3B,kBAAkB,CAAC,aAAa;IAChC,kBAAkB,CAAC,SAAS;CACpB,CAAC;AAqBX,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,YAAY,EAAE,cAAc;IAC5B,UAAU,EAAE,YAAY;IACxB,YAAY,EAAE,cAAc;CACpB,CAAC;AAEX,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,aAAa,CAAC,YAAY;IAC1B,aAAa,CAAC,UAAU;IACxB,aAAa,CAAC,YAAY;CAClB,CAAC;AAoBX,MAAM,UA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,CAAC,GAAkB;IAC/C,OAAO,GAAG,CAAC,aAAa,KAAK,aAAa,CAAC,YAAY,CAAC;AAC1D,CAAC","sourcesContent":["import type { RegisterStakeholder } from './stakeholder';\nimport type { Citation } from './util';\n\n\nexport const DECISION_STATUSES = [\n 'pending',\n 'tentative',\n 'final',\n] as const;\n\nexport const DISPOSITION_OPTIONS = [\n 'withdrawn',\n 'accepted',\n 'notAccepted',\n] as const;\n\n/**\n * Item paths in proposal set must start with a slash\n * and will be treated relative to dataset root.\n * Object paths should conform to registry item path shape\n * of `/<classID>/<itemID>.yaml`.\n * (the `[/subregisterID]/<classID>/<itemID>.yaml` is acceptable\n * but deprecated, as subregisters are deprecated).\n */\nexport type ProposalSet = {\n [objectPath: string]: ChangeProposal\n}\n\n/**\n * A change request, per ISO 19135-1 model.\n *\n * @deprecated use cr.Base (or a more specific type) instead\n */\nexport interface ChangeRequest {\n // Supplied by sponsor\n /** Justification for the change */\n justification: string\n\n proposals: ProposalSet\n\n // Enforced by the system\n id: string\n timeStarted: Date\n timeProposed?: Date\n timeDisposed?: Date\n sponsor: RegisterStakeholder\n\n // Supplied by register manager\n status: typeof DECISION_STATUSES[number] // Default filled in by the system but changeable\n disposition?: typeof DISPOSITION_OPTIONS[number]\n controlBodyDecisionEvent?: string\n controlBodyNotes?: string\n registerManagerNotes?: string\n}\n\n\n/**\n * Change request properties for the purposes of drafting.\n * (`controlBodyNotes` is in question.)\n */\nexport type DraftChangeRequest =\n Pick<ChangeRequest, 'proposals' | 'justification' | 'controlBodyNotes' | 'sponsor'>;\n\nexport const ChangeProposalType = {\n ADDITION: 'addition',\n CLARIFICATION: 'clarification',\n AMENDMENT: 'amendment',\n} as const;\nexport const PROPOSAL_TYPES = [\n ChangeProposalType.ADDITION,\n ChangeProposalType.CLARIFICATION,\n ChangeProposalType.AMENDMENT,\n] as const;\n\ninterface BaseProposal {\n //itemID: RegisterItemID\n disposition?: 'accepted' | 'notAccepted'\n type: typeof PROPOSAL_TYPES[number]\n sources?: Citation[]\n}\n\nexport interface Addition extends BaseProposal {\n type: typeof ChangeProposalType.ADDITION\n ///** New item data. */\n //payload: Payload\n}\n\nexport interface Clarification extends BaseProposal {\n type: typeof ChangeProposalType.CLARIFICATION\n ///** Updated item data */\n //payload: Payload\n}\n\nexport const AmendmentType = {\n SUPERSESSION: 'supersession',\n RETIREMENT: 'retirement',\n INVALIDATION: 'invalidation',\n} as const;\nexport type AmendmentTypeType = typeof AmendmentType[keyof typeof AmendmentType];\nexport const AMENDMENT_TYPES = [\n AmendmentType.SUPERSESSION,\n AmendmentType.RETIREMENT,\n AmendmentType.INVALIDATION,\n] as const;\n\ninterface BaseAmendment extends BaseProposal {\n type: typeof ChangeProposalType.AMENDMENT\n amendmentType: AmendmentTypeType\n}\nexport interface Retirement extends BaseAmendment {\n amendmentType: typeof AmendmentType.RETIREMENT\n}\nexport interface Supersession extends BaseAmendment {\n amendmentType: typeof AmendmentType.SUPERSESSION\n supersedingItemIDs: string[]\n}\nexport interface Invalidation extends BaseAmendment {\n amendmentType: typeof AmendmentType.INVALIDATION\n}\nexport type Amendment = Supersession | Retirement | Invalidation\n\nexport type ChangeProposal = Amendment | Clarification | Addition\n\nexport function isBaseProposal(val: any): val is BaseProposal {\n return PROPOSAL_TYPES.indexOf(val?.type) >= 0;\n}\nexport function isProposal(val: any): val is ChangeProposal {\n return (isBaseProposal(val) && (\n isAddition(val)\n || isClarification(val)\n || isAmendment(val)));\n}\nexport function isAddition(val: BaseProposal): val is Addition {\n return (val.type === ChangeProposalType.ADDITION);\n}\nexport function isClarification(val: BaseProposal): val is Clarification {\n return (val.type === ChangeProposalType.CLARIFICATION);\n}\nexport function isBaseAmendment(val: BaseProposal): val is BaseAmendment {\n return (\n val.type === ChangeProposalType.AMENDMENT\n && AMENDMENT_TYPES.indexOf((val as Amendment).amendmentType) >= 0);\n}\nexport function isAmendment(val: any): val is Amendment {\n return (isBaseAmendment(val) && (\n isRetirement(val)\n || isSupersession(val)\n || isInvalidation(val)));\n}\nexport function isRetirement(val: BaseAmendment): val is Retirement {\n return val.amendmentType === AmendmentType.RETIREMENT;\n}\nexport function isSupersession(val: BaseAmendment): val is Supersession {\n return val.amendmentType === AmendmentType.SUPERSESSION;\n}\nexport function isInvalidation(val: BaseAmendment): val is Invalidation {\n return val.amendmentType === AmendmentType.INVALIDATION;\n}\n"]}
@@ -16,8 +16,12 @@ function isCriteriaKey(val) {
16
16
  return CRITERIA_KEYS.indexOf(val) >= 0;
17
17
  }
18
18
 
19
+ function isCriterion(val) {
20
+ return val && typeof val.query === 'string' && isCriteriaKey(val.key);
21
+ }
22
+
19
23
  function isCriteriaGroup(val) {
20
- return val && val.hasOwnProperty('require') && val.hasOwnProperty('criteria');
24
+ return val && val.hasOwnProperty('require') && ['all', 'any', 'none'].indexOf(val.require) >= 0 && val.hasOwnProperty('criteria') && val.criteria && typeof val.criteria.find === 'function' && val.criteria.find(c => !isCriterion(c) && !isCriteriaGroup(c)) === undefined;
21
25
  } // TODO: Deprecate in favour of `BLANK_CRITERIA`?
22
26
 
23
27
 
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/views/FilterCriteria/models.ts"],"names":[],"mappings":"AA4CA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,KAAK;IACL,KAAK;IACL,MAAM;CACE,CAAC;AAGX,iFAAiF;AACjF,MAAM,aAAa,GAAG;IACpB,YAAY;IACZ,aAAa;IACb,QAAQ;IACR,eAAe;CACP,CAAC;AAGX,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO,aAAa,CAAC,OAAO,CAAC,GAAmB,CAAC,IAAI,CAAC,CAAC;AACzD,CAAC;AA+BD,MAAM,UAAU,eAAe,CAAC,GAAQ;IACtC,OAAO,GAAG,IAAI,GAAG,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,GAAG,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;AAChF,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,iBAAiB;IAC/B,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,kEAAkE;AAClE,MAAM,CAAC,MAAM,cAAc,GAAkB;IAC3C,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,EAAE;CACb,CAAC","sourcesContent":["import type React from 'react';\nimport type { IconName } from '@blueprintjs/core';\nimport type { ItemClassConfigurationSet, Subregisters } from '../../types';\n\n\n/**\n * Defines how to display a search criterion.\n * T: criteria data structure.\n */\nexport interface CriterionConfiguration<T extends Record<string, any>> {\n icon?: IconName\n label: string;\n\n /**\n * Widget that displays and optionally allows editing\n * criteria data structure.\n */\n widget: CriteriaWidget<T>;\n\n /**\n * Determines whether to enable this search criteria based on \n * registry configuration.\n */\n isEnabled?: (opts: CommonOpts) => boolean\n\n /** Summarizes criteria in a human-readable way. */\n toSummary: (data: T, opts: CommonOpts) => string | JSX.Element;\n\n /**\n * Coverts criteria structure to a string\n * that can be passed to filtering backend.\n */\n toQuery: (data: T, opts: CommonOpts) => string;\n\n /** Converts a query string to criteria structure. */\n fromQuery: (query: string, opts: CommonOpts) => T;\n}\n\nexport type CriteriaConfiguration = {\n [key in CriterionKey]: CriterionConfiguration<Record<string, unknown>>;\n};\n\nexport type CriteriaTransformer = (existing: CriteriaGroup) => CriteriaGroup;\n\nexport const COMPOSITION_OPERATORS = [\n 'all',\n 'any',\n 'none',\n] as const;\nexport type CompositionOperator = typeof COMPOSITION_OPERATORS[number];\n\n// TODO: Can we not hard-code keys here? Would require some smart generic typing.\nconst CRITERIA_KEYS = [\n 'item-class',\n 'subregister',\n 'custom',\n 'raw-substring',\n] as const;\ntype CriterionKey = typeof CRITERIA_KEYS[number];\n\nexport function isCriteriaKey(val: string): val is CriterionKey {\n return CRITERIA_KEYS.indexOf(val as CriterionKey) >= 0;\n}\n\ntype CriteriaWidget<T extends Record<string, any>> = React.FC<{\n data: T;\n onChange?: (newData: T) => void;\n availableClassIDs: string[];\n itemClasses: ItemClassConfigurationSet;\n subregisters?: Subregisters;\n className?: string;\n style?: React.CSSProperties;\n}>;\n\nexport interface Criterion {\n /** Specific criterion as a string. */\n query: string;\n\n /** Key in criteria configuration that defines how to work with this criterion. */\n key: CriterionKey;\n}\n\n/** Register metadata that may be needed to display filter criteria. */\nexport interface CommonOpts {\n subregisters?: Subregisters;\n itemClasses: ItemClassConfigurationSet;\n}\n\nexport interface CriteriaGroup {\n require: 'all' | 'any' | 'none';\n criteria: (CriteriaGroup | Criterion)[];\n}\n\nexport function isCriteriaGroup(val: any): val is CriteriaGroup {\n return val && val.hasOwnProperty('require') && val.hasOwnProperty('criteria');\n}\n\n// TODO: Deprecate in favour of `BLANK_CRITERIA`?\nexport function makeBlankCriteria(): CriteriaGroup {\n return BLANK_CRITERIA;\n}\n\n/** Useful as no-op default where a valid criteria is required. */\nexport const BLANK_CRITERIA: CriteriaGroup = {\n require: 'all',\n criteria: [],\n};\n"]}
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/views/FilterCriteria/models.ts"],"names":[],"mappings":"AA4CA,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC,KAAK;IACL,KAAK;IACL,MAAM;CACE,CAAC;AAGX,iFAAiF;AACjF,MAAM,aAAa,GAAG;IACpB,YAAY;IACZ,aAAa;IACb,QAAQ;IACR,eAAe;CACP,CAAC;AAGX,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,OAAO,aAAa,CAAC,OAAO,CAAC,GAAmB,CAAC,IAAI,CAAC,CAAC;AACzD,CAAC;AAmBD,SAAS,WAAW,CAAC,GAAQ;IAC3B,OAAO,GAAG,IAAI,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,IAAI,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACxE,CAAC;AAaD,MAAM,UAAU,eAAe,CAAC,GAAQ;IACtC,OAAO,GAAG;WACL,GAAG,CAAC,cAAc,CAAC,SAAS,CAAC;WAC7B,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;WAChD,GAAG,CAAC,cAAc,CAAC,UAAU,CAAC;WAC9B,GAAG,CAAC,QAAQ;WACZ,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAI,KAAK,UAAU;WACvC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC;AAC3F,CAAC;AAED,iDAAiD;AACjD,MAAM,UAAU,iBAAiB;IAC/B,OAAO,cAAc,CAAC;AACxB,CAAC;AAED,kEAAkE;AAClE,MAAM,CAAC,MAAM,cAAc,GAAkB;IAC3C,OAAO,EAAE,KAAK;IACd,QAAQ,EAAE,EAAE;CACb,CAAC","sourcesContent":["import type React from 'react';\nimport type { IconName } from '@blueprintjs/core';\nimport type { ItemClassConfigurationSet, Subregisters } from '../../types';\n\n\n/**\n * Defines how to display a search criterion.\n * T: criteria data structure.\n */\nexport interface CriterionConfiguration<T extends Record<string, any>> {\n icon?: IconName\n label: string;\n\n /**\n * Widget that displays and optionally allows editing\n * criteria data structure.\n */\n widget: CriteriaWidget<T>;\n\n /**\n * Determines whether to enable this search criteria based on \n * registry configuration.\n */\n isEnabled?: (opts: CommonOpts) => boolean\n\n /** Summarizes criteria in a human-readable way. */\n toSummary: (data: T, opts: CommonOpts) => string | JSX.Element;\n\n /**\n * Coverts criteria structure to a string\n * that can be passed to filtering backend.\n */\n toQuery: (data: T, opts: CommonOpts) => string;\n\n /** Converts a query string to criteria structure. */\n fromQuery: (query: string, opts: CommonOpts) => T;\n}\n\nexport type CriteriaConfiguration = {\n [key in CriterionKey]: CriterionConfiguration<Record<string, unknown>>;\n};\n\nexport type CriteriaTransformer = (existing: CriteriaGroup) => CriteriaGroup;\n\nexport const COMPOSITION_OPERATORS = [\n 'all',\n 'any',\n 'none',\n] as const;\nexport type CompositionOperator = typeof COMPOSITION_OPERATORS[number];\n\n// TODO: Can we not hard-code keys here? Would require some smart generic typing.\nconst CRITERIA_KEYS = [\n 'item-class',\n 'subregister',\n 'custom',\n 'raw-substring',\n] as const;\ntype CriterionKey = typeof CRITERIA_KEYS[number];\n\nexport function isCriteriaKey(val: string): val is CriterionKey {\n return CRITERIA_KEYS.indexOf(val as CriterionKey) >= 0;\n}\n\ntype CriteriaWidget<T extends Record<string, any>> = React.FC<{\n data: T;\n onChange?: (newData: T) => void;\n availableClassIDs: string[];\n itemClasses: ItemClassConfigurationSet;\n subregisters?: Subregisters;\n className?: string;\n style?: React.CSSProperties;\n}>;\n\nexport interface Criterion {\n /** Specific criterion as a string. */\n query: string;\n\n /** Key in criteria configuration that defines how to work with this criterion. */\n key: CriterionKey;\n}\nfunction isCriterion(val: any): val is Criterion {\n return val && typeof val.query === 'string' && isCriteriaKey(val.key);\n}\n\n/** Register metadata that may be needed to display filter criteria. */\nexport interface CommonOpts {\n subregisters?: Subregisters;\n itemClasses: ItemClassConfigurationSet;\n}\n\nexport interface CriteriaGroup {\n require: 'all' | 'any' | 'none';\n criteria: (CriteriaGroup | Criterion)[];\n}\n\nexport function isCriteriaGroup(val: any): val is CriteriaGroup {\n return val\n && val.hasOwnProperty('require')\n && ['all', 'any', 'none'].indexOf(val.require) >= 0\n && val.hasOwnProperty('criteria')\n && val.criteria\n && typeof val.criteria.find === 'function'\n && val.criteria.find((c: any) => !isCriterion(c) && !isCriteriaGroup(c)) === undefined;\n}\n\n// TODO: Deprecate in favour of `BLANK_CRITERIA`?\nexport function makeBlankCriteria(): CriteriaGroup {\n return BLANK_CRITERIA;\n}\n\n/** Useful as no-op default where a valid criteria is required. */\nexport const BLANK_CRITERIA: CriteriaGroup = {\n require: 'all',\n criteria: [],\n};\n"]}
@@ -51,7 +51,7 @@ const GenericRelatedItemView = function ({
51
51
  // itemSorter,
52
52
 
53
53
  }) {
54
- var _a, _b, _c;
54
+ var _a;
55
55
 
56
56
  const {
57
57
  useRegisterItemData,
@@ -105,6 +105,7 @@ const GenericRelatedItemView = function ({
105
105
 
106
106
  return availableClassIDs !== null && availableClassIDs !== void 0 ? availableClassIDs : ((_a = itemRef === null || itemRef === void 0 ? void 0 : itemRef.classID) !== null && _a !== void 0 ? _a : '') !== '' ? [itemRef.classID] : [];
107
107
  }, [availableClassIDs === null || availableClassIDs === void 0 ? void 0 : availableClassIDs.join(','), itemRef === null || itemRef === void 0 ? void 0 : itemRef.classID]);
108
+ const itemClassTitle = cfg.title.trim() || null;
108
109
  const hasItem = item !== null && classConfigured && (0, _types.isRegisterItem)(item);
109
110
  const itemIsMissing = itemID !== '' && item === null && !itemResult.isUpdating;
110
111
  const willShowItemView = hasItem || itemIsMissing || !onChange;
@@ -113,29 +114,21 @@ const GenericRelatedItemView = function ({
113
114
  return onJump ? onJump() : setPeekingDrawerState(true);
114
115
  }, [onJump, jumpTo]);
115
116
  const itemView = (0, _react2.useMemo)(() => {
116
- var _a;
117
-
118
- let itemView;
119
-
120
- if (hasItem) {
121
- itemView = (0, _react.jsx)(_react2.default.Fragment, null, (0, _react.jsx)(Item, {
122
- itemRef: {
123
- classID,
124
- itemID,
125
- subregisterID
126
- },
127
- itemData: item.data
128
- }), "\u2003", (0, _react.jsx)("small", null, (_a = cfg.title) !== null && _a !== void 0 ? _a : 'unknown class'));
129
- } else {
130
- if (itemIsMissing) {
131
- itemView = (0, _react.jsx)("span", null, "Item not found: ", itemID !== null && itemID !== void 0 ? itemID : 'N/A');
132
- } else {
133
- itemView = (0, _react.jsx)("span", null, "Item not specified");
134
- }
135
- }
136
-
137
- return itemView;
138
- }, [itemID, classID, subregisterID, item, hasItem, itemIsMissing]);
117
+ const classView = (0, _react.jsx)("small", {
118
+ css: (0, _react.css)`letter-spacing: -.01em`
119
+ }, itemClassTitle ? itemClassTitle : (0, _react.jsx)("em", null, "unknown class"));
120
+ const itemView = hasItem ? (0, _react.jsx)(Item, {
121
+ itemRef: {
122
+ classID,
123
+ itemID,
124
+ subregisterID
125
+ },
126
+ itemData: item.data
127
+ }) : itemIsMissing ? (0, _react.jsx)("span", {
128
+ css: (0, _react.css)`overflow: hidden; text-overflow: ellipsis;`
129
+ }, "Not found: ", itemID !== null && itemID !== void 0 ? itemID : 'N/A') : (0, _react.jsx)("span", null, "Not specified");
130
+ return (0, _react.jsx)(_react2.default.Fragment, null, itemView, "\u2003", classView);
131
+ }, [itemID, classID, itemClassTitle, subregisterID, item === null || item === void 0 ? void 0 : item.data, hasItem, itemIsMissing]);
139
132
  const itemButtons = (0, _react2.useMemo)(() => {
140
133
  const canAutoCreateRelatedItem = itemID === '' && onCreateNew && !itemResult.isUpdating;
141
134
  const canChangeRelatedItem =
@@ -185,12 +178,13 @@ const GenericRelatedItemView = function ({
185
178
  }
186
179
 
187
180
  return itemButtons;
188
- }, [itemID, itemResult.isUpdating, onCreateNew, onChange, onClear]); //log.debug("Rendering generic related item view: got item", item);
181
+ }, [itemID, itemResult.isUpdating, onCreateNew, onChange, onClear]);
182
+ const itemTitle = hasItem ? `${itemClassTitle !== null && itemClassTitle !== void 0 ? itemClassTitle : 'unknown class'} item ${itemID !== null && itemID !== void 0 ? itemID : 'with unknown ID'}` : undefined; //log.debug("Rendering generic related item view: got item", item);
189
183
 
190
184
  return (0, _react.jsx)(_core.ControlGroup, {
191
185
  dir: "ltr",
192
186
  className: className,
193
- title: hasItem ? `${(_b = cfg.title) !== null && _b !== void 0 ? _b : 'unknown class'} item ${itemID !== null && itemID !== void 0 ? itemID : 'with unknown ID'}` : undefined,
187
+ title: itemTitle,
194
188
  ...controlGroupProps
195
189
  }, (0, _react.jsx)(_core.InputGroup, {
196
190
  fill: hasItem,
@@ -201,7 +195,7 @@ const GenericRelatedItemView = function ({
201
195
  /* leftElement which displays itemView */
202
196
  .bp4-input-left-container {
203
197
  top: unset;
204
- bottom: .45em;
198
+ bottom: .42em;
205
199
  padding-left: 10px;
206
200
  padding-right: 5px;
207
201
  white-space: nowrap;
@@ -210,14 +204,14 @@ const GenericRelatedItemView = function ({
210
204
 
211
205
  display: inline-flex;
212
206
  flex-flow: row nowrap;
213
- align-items: flex-end;
207
+ align-items: baseline;
214
208
 
215
209
  max-width: 70%;
216
210
  }
217
211
  `,
218
212
  leftElement: itemView,
219
213
  value: itemID !== null && itemID !== void 0 ? itemID : '',
220
- title: hasItem ? `${(_c = cfg.title) !== null && _c !== void 0 ? _c : 'unknown class'} item ${itemID !== null && itemID !== void 0 ? itemID : 'with unknown ID'}` : undefined
214
+ title: itemTitle
221
215
  }), canJump ? (0, _react.jsx)(_core.Button, {
222
216
  outlined: true,
223
217
  onClick: jump,
@@ -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,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAA4C,MAAM,mBAAmB,CAAC;AAC/G,OAAO,EAGL,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,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,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EAAE,QAAQ,EACtB,iBAAiB,EAAE,QAAQ,GAC3B;QAED,OAAO;YACN,CAAC,CAAC,IAAC,iBAAiB,IAChB,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,GAAG,EAAE,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAC3C,OAAO,EAAE,OAAO,GAChB;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, { 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 { BrowserCtx } from './BrowserCtx';\nimport { ChangeRequestContext } from './change-request/ChangeRequestContext';\nimport { isDrafted } from '../types/cr';\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 // 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 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 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 let itemView: JSX.Element | null;\n\n if (hasItem) {\n itemView = <>\n <Item\n itemRef={{ classID, itemID, subregisterID }}\n itemData={item.data}\n />&emsp;<small>{cfg.title ?? 'unknown class'}</small>\n </>;\n } else {\n if (itemIsMissing) {\n itemView = <span>Item not found: {itemID ?? 'N/A'}</span>;\n } else {\n itemView = <span>Item not specified</span>;\n }\n }\n return itemView;\n }, [itemID, classID, subregisterID, item, 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 //log.debug(\"Rendering generic related item view: got item\", item);\n return (\n <ControlGroup\n dir=\"ltr\"\n className={className}\n title={hasItem\n ? `${cfg.title ?? 'unknown class'} item ${itemID ?? 'with unknown ID'}`\n : undefined}\n {...controlGroupProps}>\n\n <InputGroup\n fill={hasItem}\n readOnly={!onChange && !onClear}\n onChange={() => void 0}\n inputRef={inputRef}\n css={css`\n /* leftElement which displays itemView */\n .bp4-input-left-container {\n top: unset;\n bottom: .45em;\n padding-left: 10px;\n padding-right: 5px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n\n display: inline-flex;\n flex-flow: row nowrap;\n align-items: flex-end;\n\n max-width: 70%;\n }\n `}\n leftElement={itemView}\n value={itemID ?? ''}\n title={hasItem\n ? `${cfg.title ?? 'unknown class'} item ${itemID ?? 'with unknown ID'}`\n : undefined}\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={() => setSelectDialogState(false)}\n onChooseItem={onChange}\n availableClassIDs={classIDs}\n />\n\n {itemRef\n ? <ItemDetailsDrawer\n isOpen={peekingDrawerState}\n onClose={() => setPeekingDrawerState(false)}\n itemRef={itemRef}\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,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAA4C,MAAM,mBAAmB,CAAC;AAC/G,OAAO,EAGL,cAAc,GACf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,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,CAA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,EAAE,QAAQ,WAAK,KAAK,GAAI,CACzC;QAED,IAAC,gBAAgB,IACf,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,KAAK,CAAC,EAC1C,YAAY,EAAE,QAAQ,EACtB,iBAAiB,EAAE,QAAQ,GAC3B;QAED,OAAO;YACN,CAAC,CAAC,IAAC,iBAAiB,IAChB,MAAM,EAAE,kBAAkB,EAC1B,OAAO,EAAE,GAAG,EAAE,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAC3C,OAAO,EAAE,OAAO,GAChB;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, { 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 { BrowserCtx } from './BrowserCtx';\nimport { ChangeRequestContext } from './change-request/ChangeRequestContext';\nimport { isDrafted } from '../types/cr';\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 // 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 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 />\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}&emsp;{classView}</>;\n }, [itemID, classID, 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 //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 <InputGroup\n fill={hasItem}\n readOnly={!onChange && !onClear}\n onChange={() => void 0}\n inputRef={inputRef}\n css={css`\n /* leftElement which displays itemView */\n .bp4-input-left-container {\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: inline-flex;\n flex-flow: row nowrap;\n align-items: baseline;\n\n max-width: 70%;\n }\n `}\n leftElement={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={() => setSelectDialogState(false)}\n onChooseItem={onChange}\n availableClassIDs={classIDs}\n />\n\n {itemRef\n ? <ItemDetailsDrawer\n isOpen={peekingDrawerState}\n onClose={() => setPeekingDrawerState(false)}\n itemRef={itemRef}\n />\n : null}\n\n </ControlGroup>\n );\n};\n\n\nexport default GenericRelatedItemView;\n"]}
@@ -0,0 +1,12 @@
1
+ /** @jsx jsx */
2
+ /** @jsxFrag React.Fragment */
3
+ import React from 'react';
4
+ import type { InternalItemReference } from '../types';
5
+ /** History of changes affecting given item. */
6
+ declare const ProposalHistoryDrawer: React.FC<{
7
+ itemPath: string;
8
+ isOpen: boolean;
9
+ onClose: () => void;
10
+ onChooseItem?: (itemRef: InternalItemReference) => void;
11
+ }>;
12
+ export default ProposalHistoryDrawer;