@riboseinc/paneron-registry-kit 2.2.5 → 2.2.7

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.
@@ -17,15 +17,19 @@ var _select = require("@blueprintjs/select");
17
17
 
18
18
  var _HelpTooltip = _interopRequireDefault(require("@riboseinc/paneron-extension-kit/widgets/HelpTooltip"));
19
19
 
20
+ var _ErrorBoundary = _interopRequireDefault(require("@riboseinc/paneron-extension-kit/widgets/ErrorBoundary"));
21
+
20
22
  var _protocolRegistry = require("../protocolRegistry");
21
23
 
22
24
  var _BrowserCtx = require("../BrowserCtx");
23
25
 
24
26
  var _itemPathUtils = require("../itemPathUtils");
25
27
 
28
+ var _useItemClassConfig = _interopRequireDefault(require("../hooks/useItemClassConfig"));
29
+
26
30
  var _StructuredDiff = _interopRequireDefault(require("../diffing/StructuredDiff"));
27
31
 
28
- var _RegisterItem = _interopRequireDefault(require("../detail/RegisterItem"));
32
+ var _RegisterItem = require("../detail/RegisterItem");
29
33
 
30
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
35
 
@@ -36,6 +40,10 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
36
40
  /** @jsx jsx */
37
41
 
38
42
  /** @jsxFrag React.Fragment */
43
+ function stringifiedJSONEqual(i1, i2) {
44
+ return JSON.stringify(i1) === JSON.stringify(i2);
45
+ }
46
+
39
47
  const Proposals = function ({
40
48
  proposals,
41
49
  className
@@ -67,9 +75,9 @@ const Proposals = function ({
67
75
  }
68
76
  }
69
77
  }, [Object.keys(proposals), jumpTo]);
70
- const proposalBrowserCtx = { ...outerBrowserCtx,
78
+ const proposalBrowserCtx = (0, _react.useMemo)(() => ({ ...outerBrowserCtx,
71
79
  jumpTo: handleCRJump
72
- };
80
+ }), [handleCRJump, outerBrowserCtx]);
73
81
  const firstProposal = Object.keys(proposals)[0]; // Effective selected proposal
74
82
 
75
83
  const selectedProposal = (_b = (_a = _selectedProposal && proposals[_selectedProposal] ? _selectedProposal : null) !== null && _a !== void 0 ? _a : firstProposal) !== null && _b !== void 0 ? _b : undefined; // Force select available proposal
@@ -78,8 +86,8 @@ const Proposals = function ({
78
86
  if (firstProposal && (_selectedProposal === null || !proposals[_selectedProposal])) {
79
87
  selectProposal(firstProposal !== null && firstProposal !== void 0 ? firstProposal : null);
80
88
  }
81
- }, [firstProposal, _selectedProposal, JSON.stringify(proposals)]);
82
- const selectedItemRef = selectedProposal ? (0, _itemPathUtils.itemPathToItemRef)(subregisters !== undefined, selectedProposal) : null; // Data for proposed items
89
+ }, [firstProposal, _selectedProposal, proposals]);
90
+ const selectedItemRef = (0, _itemPathUtils.useItemRef)(subregisters !== undefined, selectedProposal); // Data for proposed items
83
91
 
84
92
  const proposedItemPaths = Object.entries(proposals).map(([itemPath, proposal]) => {
85
93
  if (proposal.type === 'clarification' || proposal.type === 'addition') {
@@ -96,116 +104,101 @@ const Proposals = function ({
96
104
  itemPaths: Object.keys(proposals),
97
105
  ignoreActiveCR: true
98
106
  });
99
-
100
- const getCurrentItemData = itemPath => {
107
+ const getCurrentItem = (0, _react.useCallback)(itemPath => {
108
+ var _a;
109
+
110
+ return (_a = currentItemDataReq.value[itemPath]) !== null && _a !== void 0 ? _a : null;
111
+ }, [currentItemDataReq.value]);
112
+ const getProposedItem = (0, _react.useCallback)(itemPath => {
113
+ var _a;
114
+
115
+ return (_a = proposedItemDataReq.value[itemPath]) !== null && _a !== void 0 ? _a : null;
116
+ }, [proposedItemDataReq.value]);
117
+ const selectedItemCurrent = getCurrentItem(selectedProposal);
118
+ const selectedItemProposed = getProposedItem(selectedProposal);
119
+ const handleItemSelect = (0, _react.useCallback)(item => selectProposal(item.itemPath), [selectProposal]);
120
+ const activeItem = (0, _react.useMemo)(() => selectedProposal ? {
121
+ itemPath: selectedProposal,
122
+ proposal: proposals[selectedProposal],
123
+ item: selectedItemProposed !== null && selectedItemProposed !== void 0 ? selectedItemProposed : selectedItemCurrent,
124
+ itemBefore: selectedItemCurrent !== null && selectedItemCurrent !== void 0 ? selectedItemCurrent : undefined,
125
+ itemRef: (0, _itemPathUtils.itemPathToItemRef)(subregisters !== undefined, selectedProposal)
126
+ } : null, [selectedProposal, proposals, subregisters]);
127
+ const allItems = (0, _react.useMemo)(() => Object.entries(proposals).map(([itemPath, proposal]) => {
101
128
  var _a, _b;
102
129
 
103
- return (_b = (_a = currentItemDataReq.value[itemPath]) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : null;
104
- };
105
-
106
- const getProposedItemData = itemPath => {
107
- var _a, _b;
108
-
109
- return (_b = (_a = proposedItemDataReq.value[itemPath]) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : null;
110
- };
111
-
112
- const selectedItemCurrentData = getCurrentItemData(selectedProposal);
113
- const selectedItemProposedData = getProposedItemData(selectedProposal);
130
+ return {
131
+ itemPath,
132
+ proposal,
133
+ item: (_b = (_a = getProposedItem(itemPath)) !== null && _a !== void 0 ? _a : getCurrentItem(itemPath)) !== null && _b !== void 0 ? _b : null,
134
+ itemBefore: undefined,
135
+ itemRef: (0, _itemPathUtils.itemPathToItemRef)(subregisters !== undefined, itemPath)
136
+ };
137
+ }).filter(cpi => cpi.item !== null), [proposals, getCurrentItem, getProposedItem]);
114
138
 
115
139
  if (selectedProposal && selectedItemRef && proposals[selectedProposal] && !currentItemDataReq.isUpdating && !proposedItemDataReq.isUpdating) {
116
- if (selectedItemCurrentData || selectedItemProposedData || true) {
117
- const selectedItemSummary = (0, _react2.jsx)(ProposalSummary, {
118
- itemRef: selectedItemRef,
119
- itemData: selectedItemProposedData !== null && selectedItemProposedData !== void 0 ? selectedItemProposedData : selectedItemCurrentData,
120
- itemDataBefore: selectedItemCurrentData !== null && selectedItemCurrentData !== void 0 ? selectedItemCurrentData : undefined,
121
- proposal: proposals[selectedProposal]
122
- });
123
- return (0, _react2.jsx)("div", {
124
- css: (0, _react2.css)`display: flex; flex-flow: column nowrap;`,
125
- className: className
126
- }, (0, _react2.jsx)("div", null, (0, _react2.jsx)(_core.ControlGroup, null, (0, _react2.jsx)(_core.Switch, {
127
- checked: showDiff,
128
- onChange: evt => setShowDiff(evt.currentTarget.checked),
129
- label: "View source",
130
- css: (0, _react2.css)`margin-right: 1em !important`
131
- }), (0, _react2.jsx)(_core.Switch, {
132
- checked: showDiff && showOnlyChanged,
133
- disabled: !showDiff,
134
- onChange: evt => setShowOnlyChanged(evt.currentTarget.checked),
135
- label: "Show clarified properties only"
136
- })), (0, _react2.jsx)(_core.ButtonGroup, null, (0, _react2.jsx)(_core.Button, {
137
- disabled: !jumpTo || ((_c = proposals[selectedProposal]) === null || _c === void 0 ? void 0 : _c.type) === 'addition',
138
- icon: 'locate',
139
- onClick: () => jumpTo === null || jumpTo === void 0 ? void 0 : jumpTo(`${_protocolRegistry.Protocols.ITEM_DETAILS}:${selectedProposal}`),
140
- title: "Open selected item in a new tab (not applicable to proposed additions)"
141
- }, "Reveal in registry"), Object.keys(proposals).length > 1 ? (0, _react2.jsx)(_react2.ClassNames, null, ({
142
- css: css2
143
- }) => (0, _react2.jsx)(_select.Select2, {
144
- filterable: false,
145
- itemsEqual: (i1, i2) => JSON.stringify(i1) === JSON.stringify(i2),
146
- menuProps: {
147
- className: css2(`height: 50vh; overflow-y: auto;`)
148
- },
149
- activeItem: {
150
- itemPath: selectedProposal,
151
- proposal: proposals[selectedProposal],
152
- itemData: selectedItemProposedData !== null && selectedItemProposedData !== void 0 ? selectedItemProposedData : selectedItemCurrentData,
153
- itemDataBefore: selectedItemCurrentData !== null && selectedItemCurrentData !== void 0 ? selectedItemCurrentData : undefined,
154
- itemRef: (0, _itemPathUtils.itemPathToItemRef)(subregisters !== undefined, selectedProposal)
155
- },
156
- items: Object.entries(proposals).map(([itemPath, proposal]) => {
157
- var _a, _b;
158
-
159
- return {
160
- itemPath,
161
- proposal,
162
- itemData: (_b = (_a = getProposedItemData(itemPath)) !== null && _a !== void 0 ? _a : getCurrentItemData(itemPath)) !== null && _b !== void 0 ? _b : null,
163
- itemDataBefore: undefined,
164
- itemRef: (0, _itemPathUtils.itemPathToItemRef)(subregisters !== undefined, itemPath)
165
- };
166
- }).filter(item => item.itemData !== null),
167
- popoverProps: {
168
- minimal: true
169
- },
170
- fill: true,
171
- itemRenderer: ChangeProposalItemView,
172
- onItemSelect: item => selectProposal(item.itemPath)
173
- }, (0, _react2.jsx)(_core.Button, {
174
- rightIcon: "chevron-down",
175
- icon: getProposalIcon(proposals[selectedProposal])
176
- }, selectedItemSummary))) : (0, _react2.jsx)(_core.Button, {
177
- fill: true,
178
- alignText: "left",
179
- icon: getProposalIcon(proposals[selectedProposal]),
180
- rightIcon: "chevron-down"
181
- }, selectedItemSummary))), (0, _react2.jsx)("div", {
182
- css: (0, _react2.css)`position: relative; flex: 1;`
183
- }, (0, _react2.jsx)(_BrowserCtx.BrowserCtx.Provider, {
184
- value: proposalBrowserCtx
185
- }, (0, _react2.jsx)(ProposalDetail, {
186
- itemRef: selectedItemRef,
187
- showDiff: showDiff,
188
- showOnlyChanged: showOnlyChanged,
189
- itemData: selectedItemProposedData !== null && selectedItemProposedData !== void 0 ? selectedItemProposedData : selectedItemCurrentData,
190
- itemDataBefore: selectedItemCurrentData !== null && selectedItemCurrentData !== void 0 ? selectedItemCurrentData : undefined,
191
- proposal: proposals[selectedProposal]
192
- }))));
193
- } else {
194
- return (0, _react2.jsx)(_core.NonIdealState, {
195
- icon: 'warning-sign',
196
- className: className,
197
- title: "Unable to retrieve proposed item data",
198
- description: (0, _react2.jsx)("div", {
199
- css: (0, _react2.css)`text-align: left;`
200
- }, "Attempted to retrieve data for ", (0, _react2.jsx)("code", null, selectedProposal), ", but failed.", (0, _react2.jsx)("br", null), "Perhaps selected item was removed, or there is a data integrity issue.", (0, _react2.jsx)("br", null), "This might be caused by a problem in the application, or repository contents having been edited outside of the application.", (0, _react2.jsx)("br", null), "The data should be recoverable by inspecting version control system commit history.", (0, _react2.jsx)("br", null), (0, _react2.jsx)("br", null), (0, _react2.jsx)(_core.ButtonGroup, null, (0, _react2.jsx)(_core.Button, {
201
- onClick: () => selectProposal(firstProposal !== null && firstProposal !== void 0 ? firstProposal : null)
202
- }, firstProposal ? "Go to first proposed item" : "Unselect proposal"), (0, _react2.jsx)(_core.Button, {
203
- intent: "danger",
204
- onClick: () => selectProposal(firstProposal !== null && firstProposal !== void 0 ? firstProposal : null),
205
- title: "This should help if there\u2019s an addition or clarification proposal with missing proposed item data. NOTE: It removes the proposal, so you may need to create it again."
206
- }, "Delete phantom proposal item")))
207
- });
208
- }
140
+ const selectedItemSummary = (0, _react2.jsx)(ProposalSummary, {
141
+ itemRef: selectedItemRef,
142
+ item: selectedItemProposed !== null && selectedItemProposed !== void 0 ? selectedItemProposed : selectedItemCurrent,
143
+ itemBefore: selectedItemCurrent !== null && selectedItemCurrent !== void 0 ? selectedItemCurrent : undefined,
144
+ proposal: proposals[selectedProposal]
145
+ });
146
+ return (0, _react2.jsx)("div", {
147
+ css: (0, _react2.css)`display: flex; flex-flow: column nowrap;`,
148
+ className: className
149
+ }, (0, _react2.jsx)("div", null, (0, _react2.jsx)(_core.ControlGroup, null, (0, _react2.jsx)(_core.Switch, {
150
+ checked: showDiff,
151
+ onChange: evt => setShowDiff(evt.currentTarget.checked),
152
+ label: "View source",
153
+ css: (0, _react2.css)`margin-right: 1em !important`
154
+ }), (0, _react2.jsx)(_core.Switch, {
155
+ checked: showDiff && showOnlyChanged,
156
+ disabled: !showDiff,
157
+ onChange: evt => setShowOnlyChanged(evt.currentTarget.checked),
158
+ label: "Show clarified properties only"
159
+ })), (0, _react2.jsx)(_core.ButtonGroup, null, (0, _react2.jsx)(_core.Button, {
160
+ disabled: !jumpTo || ((_c = proposals[selectedProposal]) === null || _c === void 0 ? void 0 : _c.type) === 'addition',
161
+ icon: 'locate',
162
+ onClick: () => jumpTo === null || jumpTo === void 0 ? void 0 : jumpTo(`${_protocolRegistry.Protocols.ITEM_DETAILS}:${selectedProposal}`),
163
+ title: "Open selected item in a new tab (not applicable to proposed additions)"
164
+ }, "Reveal in registry"), Object.keys(proposals).length > 1 ? (0, _react2.jsx)(_react2.ClassNames, null, ({
165
+ css: css2
166
+ }) => (0, _react2.jsx)(_select.Select2, {
167
+ filterable: false,
168
+ itemsEqual: stringifiedJSONEqual,
169
+ menuProps: {
170
+ className: css2(`height: 50vh; overflow-y: auto;`)
171
+ },
172
+ activeItem: activeItem,
173
+ items: allItems,
174
+ popoverProps: {
175
+ minimal: true
176
+ },
177
+ fill: true,
178
+ itemRenderer: ChangeProposalItemView,
179
+ onItemSelect: handleItemSelect
180
+ }, (0, _react2.jsx)(_core.Button, {
181
+ rightIcon: "chevron-down",
182
+ icon: getProposalIcon(proposals[selectedProposal])
183
+ }, selectedItemSummary))) : (0, _react2.jsx)(_core.Button, {
184
+ fill: true,
185
+ alignText: "left",
186
+ icon: getProposalIcon(proposals[selectedProposal]),
187
+ rightIcon: "chevron-down"
188
+ }, selectedItemSummary))), (0, _react2.jsx)("div", {
189
+ css: (0, _react2.css)`position: relative; flex: 1;`
190
+ }, (0, _react2.jsx)(_BrowserCtx.BrowserCtx.Provider, {
191
+ value: proposalBrowserCtx
192
+ }, (0, _react2.jsx)(_ErrorBoundary.default, {
193
+ viewName: "Proposal detail"
194
+ }, (0, _react2.jsx)(ProposalDetail, {
195
+ itemRef: selectedItemRef,
196
+ showDiff: showDiff,
197
+ showOnlyChanged: showOnlyChanged,
198
+ item: selectedItemProposed !== null && selectedItemProposed !== void 0 ? selectedItemProposed : selectedItemCurrent,
199
+ itemBefore: selectedItemCurrent !== null && selectedItemCurrent !== void 0 ? selectedItemCurrent : undefined,
200
+ proposal: proposals[selectedProposal]
201
+ })))));
209
202
  } else {
210
203
  return (0, _react2.jsx)(_core.NonIdealState, {
211
204
  icon: 'clean',
@@ -237,38 +230,46 @@ const ChangeProposalItemView = (item, {
237
230
  });
238
231
  };
239
232
 
240
- const ProposalDetail = function ({
233
+ const ProposalDetail = (0, _react.memo)(function ({
241
234
  proposal,
242
235
  showDiff,
243
236
  showOnlyChanged,
244
237
  itemRef,
245
- itemData,
246
- itemDataBefore,
238
+ item,
239
+ itemBefore,
247
240
  onChange
248
241
  }) {
249
- const ItemView = _RegisterItem.default.main;
242
+ var _a, _b;
243
+
244
+ const itemClass = (0, _useItemClassConfig.default)((_a = itemRef.classID) !== null && _a !== void 0 ? _a : 'NONEXISTENT_CLASS_ID');
245
+
246
+ if (!itemClass) {
247
+ throw new Error(`Unknown item class “${itemRef.classID}”!`);
248
+ }
249
+
250
250
  const view = showDiff ? (0, _react2.jsx)(MaximizedStructuredDiff, {
251
- item1: itemDataBefore !== null && itemDataBefore !== void 0 ? itemDataBefore : {},
252
- item2: itemData,
251
+ item1: (_b = itemBefore === null || itemBefore === void 0 ? void 0 : itemBefore.data) !== null && _b !== void 0 ? _b : ITEM_DATA_PLACEHOLDER,
252
+ item2: item.data,
253
253
  showUnchanged: !showOnlyChanged,
254
254
  css: (0, _react2.css)`background: white; border-radius: 2.5px; padding: 10px 0; margin: 10px 0;`,
255
255
  className: _core.Classes.ELEVATION_2
256
- }) : (0, _react2.jsx)(ItemView, {
257
- uri: (0, _itemPathUtils.itemRefToItemPath)(itemRef),
256
+ }) : (0, _react2.jsx)(_RegisterItem.ItemDetail, {
257
+ itemRef: itemRef,
258
+ item: item,
259
+ itemClass: itemClass,
258
260
  key: JSON.stringify(itemRef)
259
261
  });
260
262
  return (0, _react2.jsx)("div", {
261
263
  css: (0, _react2.css)`position: absolute; inset: 0; display: flex; flex-flow: column;`
262
264
  }, view);
263
- };
264
-
265
+ });
265
266
  exports.ProposalDetail = ProposalDetail;
266
267
 
267
268
  const ProposalSummary = function ({
268
269
  proposal,
269
270
  itemRef,
270
- itemData,
271
- itemDataBefore,
271
+ item,
272
+ itemBefore,
272
273
  onChange
273
274
  }) {
274
275
  const {
@@ -280,50 +281,50 @@ const ProposalSummary = function ({
280
281
  const ListItemView = itemClasses[classID].views.listItemView;
281
282
  return (0, _react2.jsx)(ListItemView, {
282
283
  itemRef: itemRef,
283
- itemData: itemData
284
+ itemData: item.data
284
285
  });
285
286
  };
286
287
 
287
288
  exports.ProposalSummary = ProposalSummary;
288
289
  const clarification = {
289
290
  hint: (0, _react2.jsx)(_react.default.Fragment, null, "altered to represent the same concept more clearly."),
290
- summary: ({
291
+ summary: (0, _react.memo)(({
291
292
  proposal,
292
- itemData,
293
+ item,
293
294
  itemRef
294
- }) => (0, _react2.jsx)(_react.default.Fragment, null, "Clarification")
295
+ }) => (0, _react2.jsx)(_react.default.Fragment, null, "Clarification"), () => true)
295
296
  };
296
297
  const addition = {
297
298
  hint: (0, _react2.jsx)(_react.default.Fragment, null, "added to this register."),
298
- summary: ({
299
+ summary: (0, _react.memo)(({
299
300
  proposal,
300
- itemData,
301
+ item,
301
302
  itemRef
302
- }) => (0, _react2.jsx)(_react.default.Fragment, null, "Addition")
303
+ }) => (0, _react2.jsx)(_react.default.Fragment, null, "Addition"), () => true)
303
304
  };
304
305
  const retirement = {
305
306
  hint: (0, _react2.jsx)(_react.default.Fragment, null, "marked as no longer current. (Note that this register is append-only, so the item cannot be removed altogether.)"),
306
- summary: ({
307
+ summary: (0, _react.memo)(({
307
308
  proposal,
308
309
  itemRef,
309
- itemData
310
- }) => (0, _react2.jsx)(_react.default.Fragment, null, "Retirement")
310
+ item
311
+ }) => (0, _react2.jsx)(_react.default.Fragment, null, "Retirement"), () => true)
311
312
  };
312
313
  const supersession = {
313
314
  hint: (0, _react2.jsx)(_react.default.Fragment, null, "removed from the register with another item recommended for use in its place. A relation between the superseding and superseded item will be created, though the exact semantics of that relation depend on the register."),
314
- summary: ({
315
+ summary: (0, _react.memo)(({
315
316
  proposal,
316
317
  itemRef,
317
- itemData
318
- }) => (0, _react2.jsx)(_react.default.Fragment, null, "Supersession")
318
+ item
319
+ }) => (0, _react2.jsx)(_react.default.Fragment, null, "Supersession"), () => true)
319
320
  };
320
321
  const invalidation = {
321
322
  hint: (0, _react2.jsx)(_react.default.Fragment, null, "marked as invalid. The exact semantics of invalidation depend on the register."),
322
- summary: ({
323
+ summary: (0, _react.memo)(({
323
324
  proposal,
324
325
  itemRef,
325
- itemData
326
- }) => (0, _react2.jsx)(_react.default.Fragment, null, "Invalidation")
326
+ item
327
+ }) => (0, _react2.jsx)(_react.default.Fragment, null, "Invalidation"), () => true)
327
328
  };
328
329
  const MaximizedStructuredDiff = (0, _styled.default)(_StructuredDiff.default)`
329
330
  position: absolute;
@@ -342,4 +343,5 @@ function getProposalIcon(proposal) {
342
343
  }
343
344
 
344
345
  var _default = Proposals;
345
- exports.default = _default;
346
+ exports.default = _default;
347
+ const ITEM_DATA_PLACEHOLDER = {};
@@ -1 +1 @@
1
- {"version":3,"file":"Proposals.js","sourceRoot":"","sources":["../../../src/views/change-request/Proposals.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,EACL,YAAY,EACZ,WAAW,EACX,MAAM,EACN,MAAM,EACN,OAAO,EACP,QAAQ,EACR,aAAa,GAEd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAgB,OAAO,IAAI,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,WAAW,MAAM,sDAAsD,CAAC;AAY/E,OAAO,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAE/D,OAAO,EAAE,UAAU,EAAqC,MAAM,eAAe,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,sBAAsB,MAAM,wBAAwB,CAAC;A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AAC,cAAc,CAAC,CAAA;;;CAGrD,CAAC;AAQF,MAAM,cAAc,GAAmE;IACrF,aAAa;IACb,QAAQ;IACR,UAAU;IACV,YAAY;IACZ,YAAY;CACb,CAAC;AAGF,SAAS,eAAe,CAAC,QAAwB;IAC/C,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU;QAC/B,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,eAAe;YACjC,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,YAAY,CAAA;AACtB,CAAC;AAGD,eAAe,SAAS,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport React, { useContext, useEffect, useState, useCallback } from 'react';\nimport { ClassNames, jsx, css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport {\n ControlGroup,\n ButtonGroup,\n Switch,\n Button,\n Classes,\n MenuItem,\n NonIdealState,\n IconName,\n} from '@blueprintjs/core';\nimport { ItemRenderer, Select2 as Select } from '@blueprintjs/select';\nimport HelpTooltip from '@riboseinc/paneron-extension-kit/widgets/HelpTooltip';\nimport type {\n Addition,\n ChangeProposal,\n Clarification,\n InternalItemReference,\n Retirement,\n Supersession,\n Invalidation,\n Payload,\n} from '../../types';\nimport type { Drafted } from '../../types/cr';\nimport { Protocols, type Protocol } from '../protocolRegistry';\nimport { PROPOSAL_TYPES, AMENDMENT_TYPES } from '../../types/proposal';\nimport { BrowserCtx, type BrowserCtx as BrowserCtxType } from '../BrowserCtx';\nimport { itemPathToItemRef, itemRefToItemPath } from '../itemPathUtils';\nimport StructuredDiff from '../diffing/StructuredDiff';\nimport registerItemDetailView from '../detail/RegisterItem';\n\n\ninterface ChangeProposalItem {\n itemPath: string\n itemRef: InternalItemReference\n proposal: ChangeProposal\n itemData: Payload\n itemDataBefore: Payload | undefined\n}\n\n\nconst Proposals: React.FC<{\n proposals: Drafted['items']\n className?: string\n}> = function ({ proposals, className }) {\n const [ _selectedProposal, selectProposal ] = useState<string | null>(null);\n const [ showDiff, setShowDiff ] = useState(false);\n const [ showOnlyChanged, setShowOnlyChanged ] = useState(true);\n\n const outerBrowserCtx = useContext(BrowserCtx);\n const { jumpTo, subregisters, useRegisterItemData } = outerBrowserCtx;\n\n /**\n * When jumping to an item affected by current CR,\n * jump in-CR instead of spawning tab.\n */\n const handleCRJump = useCallback(function _handleCRJump(uri: `${Protocol}:${string}`): void {\n if (uri.startsWith(Protocols.ITEM_DETAILS)) {\n const itemPath = uri.split(':')[1];\n if (proposals[itemPath]) {\n selectProposal(itemPath);\n } else {\n jumpTo?.(uri);\n }\n }\n }, [Object.keys(proposals), jumpTo]);\n\n const proposalBrowserCtx: BrowserCtxType = {\n ...outerBrowserCtx,\n jumpTo: handleCRJump,\n };\n\n const firstProposal: string | undefined = Object.keys(proposals)[0];\n\n // Effective selected proposal\n const selectedProposal: string | undefined =\n ((_selectedProposal && proposals[_selectedProposal]) ? _selectedProposal : null)\n ?? firstProposal\n ?? undefined;\n\n // Force select available proposal\n useEffect(() => {\n if (firstProposal && (_selectedProposal === null || !proposals[_selectedProposal])) {\n selectProposal(firstProposal ?? null);\n }\n }, [firstProposal, _selectedProposal, JSON.stringify(proposals)]);\n\n const selectedItemRef = selectedProposal\n ? itemPathToItemRef(subregisters !== undefined, selectedProposal)\n : null;\n\n\n // Data for proposed items\n const proposedItemPaths = Object.entries(proposals).map(([itemPath, proposal]) => {\n if (proposal.type === 'clarification' || proposal.type === 'addition') {\n return itemPath;\n } else {\n return undefined;\n }\n }).filter(s => s !== undefined) as string[];\n const proposedItemDataReq = useRegisterItemData({\n itemPaths: proposedItemPaths,\n });\n\n // Data for pre-existing items\n const currentItemDataReq = useRegisterItemData({\n itemPaths: Object.keys(proposals),\n ignoreActiveCR: true,\n });\n\n const getCurrentItemData = (itemPath: string) => currentItemDataReq.value[itemPath]?.data ?? null;\n const getProposedItemData = (itemPath: string) => proposedItemDataReq.value[itemPath]?.data ?? null;\n\n const selectedItemCurrentData = getCurrentItemData(selectedProposal);\n const selectedItemProposedData = getProposedItemData(selectedProposal);\n\n if (\n selectedProposal\n && selectedItemRef\n && proposals[selectedProposal]\n && !currentItemDataReq.isUpdating\n && !proposedItemDataReq.isUpdating\n ) {\n if (selectedItemCurrentData || selectedItemProposedData || true) {\n const selectedItemSummary = <ProposalSummary\n itemRef={selectedItemRef}\n itemData={(selectedItemProposedData ?? selectedItemCurrentData)!}\n itemDataBefore={selectedItemCurrentData ?? undefined}\n proposal={proposals[selectedProposal]}\n />\n\n return (\n <div css={css`display: flex; flex-flow: column nowrap;`} className={className}>\n <div>\n <ControlGroup>\n <Switch\n checked={showDiff}\n onChange={evt => setShowDiff(evt.currentTarget.checked)}\n label=\"View source\"\n css={css`margin-right: 1em !important`}\n />\n <Switch\n checked={showDiff && showOnlyChanged}\n disabled={!showDiff}\n onChange={evt => setShowOnlyChanged(evt.currentTarget.checked)}\n label=\"Show clarified properties only\"\n />\n </ControlGroup>\n <ButtonGroup>\n <Button\n disabled={!jumpTo || proposals[selectedProposal]?.type === 'addition'}\n icon='locate'\n onClick={() => jumpTo?.(`${Protocols.ITEM_DETAILS}:${selectedProposal}`)}\n title=\"Open selected item in a new tab (not applicable to proposed additions)\">\n Reveal in registry\n </Button>\n {Object.keys(proposals).length > 1\n ? <ClassNames>\n {(({ css: css2 }) =>\n <Select<ChangeProposalItem>\n filterable={false}\n itemsEqual={(i1, i2) => JSON.stringify(i1) === JSON.stringify(i2)}\n menuProps={{ className: css2(`height: 50vh; overflow-y: auto;`) }}\n activeItem={{\n itemPath: selectedProposal,\n proposal: proposals[selectedProposal],\n itemData: (selectedItemProposedData ?? selectedItemCurrentData)!,\n itemDataBefore: selectedItemCurrentData ?? undefined,\n itemRef: itemPathToItemRef(subregisters !== undefined, selectedProposal),\n }} // TODO: First time selection is broken\n items={\n Object.entries(proposals).map(([itemPath, proposal]) => ({\n itemPath,\n proposal,\n itemData: (getProposedItemData(itemPath) ?? getCurrentItemData(itemPath))! ?? null,\n itemDataBefore: undefined,\n itemRef: itemPathToItemRef(subregisters !== undefined, itemPath),\n })).filter(item => item.itemData !== null)}\n popoverProps={{ minimal: true }}\n fill\n itemRenderer={ChangeProposalItemView}\n onItemSelect={(item) => selectProposal(item.itemPath)}>\n <Button rightIcon=\"chevron-down\" icon={getProposalIcon(proposals[selectedProposal])}>\n {selectedItemSummary}\n </Button>\n </Select>\n )}\n </ClassNames>\n : <Button\n fill\n alignText=\"left\"\n icon={getProposalIcon(proposals[selectedProposal])}\n rightIcon=\"chevron-down\">\n {selectedItemSummary}\n </Button>}\n </ButtonGroup>\n </div>\n <div css={css`position: relative; flex: 1;`}>\n <BrowserCtx.Provider value={proposalBrowserCtx}>\n <ProposalDetail\n itemRef={selectedItemRef}\n showDiff={showDiff}\n showOnlyChanged={showOnlyChanged}\n itemData={(selectedItemProposedData ?? selectedItemCurrentData)!}\n itemDataBefore={selectedItemCurrentData ?? undefined}\n proposal={proposals[selectedProposal]}\n />\n </BrowserCtx.Provider>\n </div>\n </div>\n );\n } else {\n return <NonIdealState\n icon='warning-sign'\n className={className}\n title=\"Unable to retrieve proposed item data\"\n description={<div css={css`text-align: left;`}>\n Attempted to retrieve data for <code>{selectedProposal}</code>,\n but failed.\n <br />\n Perhaps selected item was removed, or there is a data integrity issue.\n <br />\n This might be caused by a problem in the application, or repository contents having been edited outside of the application.\n <br />\n The data should be recoverable by inspecting version control system commit history.\n <br />\n <br />\n <ButtonGroup>\n <Button onClick={() => selectProposal(firstProposal ?? null)}>\n {firstProposal\n ? \"Go to first proposed item\"\n : \"Unselect proposal\"}\n </Button>\n <Button\n intent=\"danger\"\n onClick={() => selectProposal(firstProposal ?? null)}\n title=\"This should help if there’s an addition or clarification proposal with missing proposed item data. NOTE: It removes the proposal, so you may need to create it again.\">\n Delete phantom proposal item\n </Button>\n </ButtonGroup>\n </div>}\n />;\n }\n } else {\n return <NonIdealState\n icon='clean'\n className={className}\n title=\"Nothing is proposed here yet.\"\n />;\n }\n};\n\n\nconst ChangeProposalItemView: ItemRenderer<ChangeProposalItem> =\n(item, { handleClick, modifiers, query }) => {\n const proposalConfig = \n item.proposal.type === 'amendment'\n ? PROPOSAL_VIEWS[item.proposal.amendmentType]\n : PROPOSAL_VIEWS[item.proposal.type];\n const ProposalTypeLabel: React.FC<ProposalProps<any>> = proposalConfig.summary;\n return (\n <MenuItem\n active={modifiers.active}\n disabled={modifiers.disabled}\n labelElement={<>\n <ProposalTypeLabel {...item} />\n {\" \"}\n <HelpTooltip content={<>Proposed to be {proposalConfig.hint}</>} />\n </>}\n key={item.itemPath}\n onClick={handleClick}\n icon={getProposalIcon(item.proposal)}\n text={<ProposalSummary {...item} />} />\n );\n}\n\n\ninterface ProposalProps<P extends ChangeProposal> {\n proposal: P\n showDiff?: boolean\n showOnlyChanged?: boolean\n itemRef: InternalItemReference\n itemData: Payload\n itemDataBefore: P extends Clarification ? Payload : undefined\n onChange?: (newProposal: P) => void\n}\nexport const ProposalDetail: React.FC<ProposalProps<ChangeProposal>> =\nfunction ({ proposal, showDiff, showOnlyChanged, itemRef, itemData, itemDataBefore, onChange }) {\n const ItemView = registerItemDetailView.main;\n\n const view: JSX.Element = showDiff\n ? <MaximizedStructuredDiff\n item1={itemDataBefore ?? {}}\n item2={itemData}\n showUnchanged={!showOnlyChanged}\n css={css`background: white; border-radius: 2.5px; padding: 10px 0; margin: 10px 0;`}\n className={Classes.ELEVATION_2}\n />\n : <ItemView uri={itemRefToItemPath(itemRef)} key={JSON.stringify(itemRef)} />\n\n return <div css={css`position: absolute; inset: 0; display: flex; flex-flow: column;`}>\n {view}\n </div>;\n};\nexport const ProposalSummary: React.FC<ProposalProps<ChangeProposal>> =\nfunction ({ proposal, itemRef, itemData, itemDataBefore, onChange }) {\n const { itemClasses } = useContext(BrowserCtx);\n const { classID } = itemRef;\n const ListItemView = itemClasses[classID].views.listItemView;\n\n return <ListItemView\n itemRef={itemRef}\n itemData={itemData}\n />;\n};\n\n\ninterface ProposalViewConfig<P extends ChangeProposal> {\n summary: React.FC<ProposalProps<P>>\n hint: JSX.Element | string\n}\n\n\nconst clarification: ProposalViewConfig<Clarification> = {\n hint: <>\n altered to represent the same concept more clearly.\n </>,\n summary: ({ proposal, itemData, itemRef }) => <>Clarification</>,\n};\n\n\nconst addition: ProposalViewConfig<Addition> = {\n hint: <>added to this register.</>,\n summary: ({ proposal, itemData, itemRef }) => <>Addition</>,\n};\n\n\nconst retirement: ProposalViewConfig<Retirement> = {\n hint: <>\n marked as no longer current.\n (Note that this register is append-only, so the item cannot be removed altogether.)\n </>,\n summary: ({ proposal, itemRef, itemData }) => <>Retirement</>,\n};\n\n\nconst supersession: ProposalViewConfig<Supersession> = {\n hint: <>\n removed from the register with another item recommended for use in its place.\n A relation between the superseding and superseded item will be created,\n though the exact semantics of that relation depend on the register.\n </>,\n summary: ({ proposal, itemRef, itemData }) => <>Supersession</>,\n};\n\n\nconst invalidation: ProposalViewConfig<Invalidation> = {\n hint: <>\n marked as invalid. The exact semantics of invalidation depend on the register.\n </>,\n summary: ({ proposal, itemRef, itemData }) => <>Invalidation</>,\n}\n\n\nconst MaximizedStructuredDiff = styled(StructuredDiff)`\n position: absolute;\n inset: 0;\n`;\n\n\ntype ProposalOrAmendmentType =\n | Exclude<typeof PROPOSAL_TYPES[number], 'amendment'>\n | typeof AMENDMENT_TYPES[number];\n\n\nconst PROPOSAL_VIEWS: { [type in ProposalOrAmendmentType]: ProposalViewConfig<any> } = {\n clarification,\n addition,\n retirement,\n supersession,\n invalidation,\n};\n\n\nfunction getProposalIcon(proposal: ChangeProposal): IconName {\n return proposal.type === 'addition'\n ? 'add'\n : proposal.type === 'clarification'\n ? 'edit'\n : 'ban-circle'\n}\n\n\nexport default Proposals;\n"]}
1
+ {"version":3,"file":"Proposals.js","sourceRoot":"","sources":["../../../src/views/change-request/Proposals.tsx"],"names":[],"mappings":"AAAA,eAAe;AACf,8BAA8B;AAE9B,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAA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C,QAAwB;IAC/C,OAAO,QAAQ,CAAC,IAAI,KAAK,UAAU;QAC/B,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,QAAQ,CAAC,IAAI,KAAK,eAAe;YACjC,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,YAAY,CAAC;AACvB,CAAC;AAGD,eAAe,SAAS,CAAC;AAGzB,MAAM,qBAAqB,GAAG,EAAW,CAAC","sourcesContent":["/** @jsx jsx */\n/** @jsxFrag React.Fragment */\n\nimport React, { useContext, useEffect, useState, useCallback, memo, useMemo } from 'react';\nimport { ClassNames, jsx, css } from '@emotion/react';\nimport styled from '@emotion/styled';\nimport {\n ControlGroup,\n ButtonGroup,\n Switch,\n Button,\n Classes,\n MenuItem,\n NonIdealState,\n IconName,\n} from '@blueprintjs/core';\nimport { ItemRenderer, Select2 as Select } from '@blueprintjs/select';\nimport HelpTooltip from '@riboseinc/paneron-extension-kit/widgets/HelpTooltip';\nimport type {\n Addition,\n ChangeProposal,\n Clarification,\n InternalItemReference,\n Retirement,\n Supersession,\n Invalidation,\n Payload,\n RegisterItem,\n} from '../../types';\nimport ErrorBoundary from '@riboseinc/paneron-extension-kit/widgets/ErrorBoundary';\nimport type { Drafted } from '../../types/cr';\nimport { Protocols, type Protocol } from '../protocolRegistry';\nimport { PROPOSAL_TYPES, AMENDMENT_TYPES } from '../../types/proposal';\nimport { BrowserCtx, type BrowserCtx as BrowserCtxType } from '../BrowserCtx';\nimport { useItemRef, itemPathToItemRef } from '../itemPathUtils';\nimport useItemClassConfig from '../hooks/useItemClassConfig';\nimport StructuredDiff from '../diffing/StructuredDiff';\nimport { ItemDetail } from '../detail/RegisterItem';\n\n\ninterface ChangeProposalItem {\n itemPath: string\n itemRef: InternalItemReference\n proposal: ChangeProposal\n item: RegisterItem<Payload>\n itemBefore: RegisterItem<Payload> | undefined\n}\nfunction stringifiedJSONEqual(i1: any, i2: any): boolean {\n return JSON.stringify(i1) === JSON.stringify(i2);\n}\n\n\nconst Proposals: React.FC<{\n proposals: Drafted['items']\n className?: string\n}> = function ({ proposals, className }) {\n const [ _selectedProposal, selectProposal ] = useState<string | null>(null);\n const [ showDiff, setShowDiff ] = useState(false);\n const [ showOnlyChanged, setShowOnlyChanged ] = useState(true);\n\n const outerBrowserCtx = useContext(BrowserCtx);\n const { jumpTo, subregisters, useRegisterItemData } = outerBrowserCtx;\n\n /**\n * When jumping to an item affected by current CR,\n * jump in-CR instead of spawning tab.\n */\n const handleCRJump = useCallback(function _handleCRJump(uri: `${Protocol}:${string}`): void {\n if (uri.startsWith(Protocols.ITEM_DETAILS)) {\n const itemPath = uri.split(':')[1];\n if (proposals[itemPath]) {\n selectProposal(itemPath);\n } else {\n jumpTo?.(uri);\n }\n }\n }, [Object.keys(proposals), jumpTo]);\n\n const proposalBrowserCtx: BrowserCtxType = useMemo((() => ({\n ...outerBrowserCtx,\n jumpTo: handleCRJump,\n })), [handleCRJump, outerBrowserCtx]);\n\n const firstProposal: string | undefined = Object.keys(proposals)[0];\n\n // Effective selected proposal\n const selectedProposal: string | undefined =\n ((_selectedProposal && proposals[_selectedProposal]) ? _selectedProposal : null)\n ?? firstProposal\n ?? undefined;\n\n // Force select available proposal\n useEffect(() => {\n if (firstProposal && (_selectedProposal === null || !proposals[_selectedProposal])) {\n selectProposal(firstProposal ?? null);\n }\n }, [firstProposal, _selectedProposal, proposals]);\n\n const selectedItemRef = useItemRef(subregisters !== undefined, selectedProposal);\n\n // Data for proposed items\n const proposedItemPaths = Object.entries(proposals).map(([itemPath, proposal]) => {\n if (proposal.type === 'clarification' || proposal.type === 'addition') {\n return itemPath;\n } else {\n return undefined;\n }\n }).filter(s => s !== undefined) as string[];\n const proposedItemDataReq = useRegisterItemData({\n itemPaths: proposedItemPaths,\n });\n\n // Data for pre-existing items\n const currentItemDataReq = useRegisterItemData({\n itemPaths: Object.keys(proposals),\n ignoreActiveCR: true,\n });\n\n const getCurrentItem = useCallback(\n ((itemPath: string) => currentItemDataReq.value[itemPath] ?? null),\n [currentItemDataReq.value]);\n const getProposedItem = useCallback(\n ((itemPath: string) => proposedItemDataReq.value[itemPath] ?? null),\n [proposedItemDataReq.value]);\n\n const selectedItemCurrent = getCurrentItem(selectedProposal);\n const selectedItemProposed = getProposedItem(selectedProposal);\n\n const handleItemSelect = useCallback(\n ((item: ChangeProposalItem) => selectProposal(item.itemPath)),\n [selectProposal]);\n\n const activeItem: ChangeProposalItem | null = useMemo((() =>\n selectedProposal\n ? ({\n itemPath: selectedProposal,\n proposal: proposals[selectedProposal],\n item: (selectedItemProposed ?? selectedItemCurrent)!,\n itemBefore: selectedItemCurrent ?? undefined,\n itemRef: itemPathToItemRef(subregisters !== undefined, selectedProposal),\n })\n : null\n ), [selectedProposal, proposals, subregisters]);\n\n const allItems: ChangeProposalItem[] = useMemo((() =>\n Object.entries(proposals).map(([itemPath, proposal]) => ({\n itemPath,\n proposal,\n item: (getProposedItem(itemPath) ?? getCurrentItem(itemPath))! ?? null,\n itemBefore: undefined,\n itemRef: itemPathToItemRef(subregisters !== undefined, itemPath),\n })).filter(cpi => cpi.item !== null)\n ), [proposals, getCurrentItem, getProposedItem]);\n\n if (\n selectedProposal\n && selectedItemRef\n && proposals[selectedProposal]\n && !currentItemDataReq.isUpdating\n && !proposedItemDataReq.isUpdating\n ) {\n const selectedItemSummary = <ProposalSummary\n itemRef={selectedItemRef}\n item={(selectedItemProposed ?? selectedItemCurrent)!}\n itemBefore={selectedItemCurrent ?? undefined}\n proposal={proposals[selectedProposal]}\n />;\n\n return (\n <div css={css`display: flex; flex-flow: column nowrap;`} className={className}>\n <div>\n <ControlGroup>\n <Switch\n checked={showDiff}\n onChange={evt => setShowDiff(evt.currentTarget.checked)}\n label=\"View source\"\n css={css`margin-right: 1em !important`}\n />\n <Switch\n checked={showDiff && showOnlyChanged}\n disabled={!showDiff}\n onChange={evt => setShowOnlyChanged(evt.currentTarget.checked)}\n label=\"Show clarified properties only\"\n />\n </ControlGroup>\n <ButtonGroup>\n <Button\n disabled={!jumpTo || proposals[selectedProposal]?.type === 'addition'}\n icon='locate'\n onClick={() => jumpTo?.(`${Protocols.ITEM_DETAILS}:${selectedProposal}`)}\n title=\"Open selected item in a new tab (not applicable to proposed additions)\">\n Reveal in registry\n </Button>\n {Object.keys(proposals).length > 1\n ? <ClassNames>\n {(({ css: css2 }) =>\n <Select<ChangeProposalItem>\n filterable={false}\n itemsEqual={stringifiedJSONEqual}\n menuProps={{ className: css2(`height: 50vh; overflow-y: auto;`) }}\n activeItem={activeItem}\n items={allItems}\n popoverProps={{ minimal: true }}\n fill\n itemRenderer={ChangeProposalItemView}\n onItemSelect={handleItemSelect}>\n <Button rightIcon=\"chevron-down\" icon={getProposalIcon(proposals[selectedProposal])}>\n {selectedItemSummary}\n </Button>\n </Select>\n )}\n </ClassNames>\n : <Button\n fill\n alignText=\"left\"\n icon={getProposalIcon(proposals[selectedProposal])}\n rightIcon=\"chevron-down\">\n {selectedItemSummary}\n </Button>}\n </ButtonGroup>\n </div>\n <div css={css`position: relative; flex: 1;`}>\n <BrowserCtx.Provider value={proposalBrowserCtx}>\n <ErrorBoundary viewName=\"Proposal detail\">\n <ProposalDetail\n itemRef={selectedItemRef}\n showDiff={showDiff}\n showOnlyChanged={showOnlyChanged}\n item={(selectedItemProposed ?? selectedItemCurrent)!}\n itemBefore={selectedItemCurrent ?? undefined}\n proposal={proposals[selectedProposal]}\n />\n </ErrorBoundary>\n </BrowserCtx.Provider>\n </div>\n </div>\n );\n } else {\n return <NonIdealState\n icon='clean'\n className={className}\n title=\"Nothing is proposed here yet.\"\n />;\n }\n};\n\n\nconst ChangeProposalItemView: ItemRenderer<ChangeProposalItem> =\n(item, { handleClick, modifiers, query }) => {\n const proposalConfig = \n item.proposal.type === 'amendment'\n ? PROPOSAL_VIEWS[item.proposal.amendmentType]\n : PROPOSAL_VIEWS[item.proposal.type];\n const ProposalTypeLabel: React.FC<ProposalProps<any>> = proposalConfig.summary;\n return (\n <MenuItem\n active={modifiers.active}\n disabled={modifiers.disabled}\n labelElement={<>\n <ProposalTypeLabel {...item} />\n {\" \"}\n <HelpTooltip content={<>Proposed to be {proposalConfig.hint}</>} />\n </>}\n key={item.itemPath}\n onClick={handleClick}\n icon={getProposalIcon(item.proposal)}\n text={<ProposalSummary {...item} />} />\n );\n};\n\n\ninterface ProposalProps<P extends ChangeProposal> {\n proposal: P\n showDiff?: boolean\n showOnlyChanged?: boolean\n itemRef: InternalItemReference\n item: RegisterItem<Payload>\n itemBefore: P extends Clarification ? RegisterItem<Payload> : undefined\n onChange?: (newProposal: P) => void\n}\nexport const ProposalDetail: React.FC<ProposalProps<ChangeProposal>> =\nmemo(function ({ proposal, showDiff, showOnlyChanged, itemRef, item, itemBefore, onChange }) {\n const itemClass = useItemClassConfig(itemRef.classID ?? 'NONEXISTENT_CLASS_ID');\n\n if (!itemClass) {\n throw new Error(`Unknown item class “${itemRef.classID}”!`);\n }\n\n const view: JSX.Element = showDiff\n ? <MaximizedStructuredDiff\n item1={itemBefore?.data ?? ITEM_DATA_PLACEHOLDER}\n item2={item.data}\n showUnchanged={!showOnlyChanged}\n css={css`background: white; border-radius: 2.5px; padding: 10px 0; margin: 10px 0;`}\n className={Classes.ELEVATION_2}\n />\n : <ItemDetail\n itemRef={itemRef}\n item={item}\n itemClass={itemClass}\n key={JSON.stringify(itemRef)}\n />\n\n return <div css={css`position: absolute; inset: 0; display: flex; flex-flow: column;`}>\n {view}\n </div>;\n});\nexport const ProposalSummary: React.FC<ProposalProps<ChangeProposal>> =\nfunction ({ proposal, itemRef, item, itemBefore, onChange }) {\n const { itemClasses } = useContext(BrowserCtx);\n const { classID } = itemRef;\n const ListItemView = itemClasses[classID].views.listItemView;\n\n return <ListItemView\n itemRef={itemRef}\n itemData={item.data}\n />;\n};\n\n\ninterface ProposalViewConfig<P extends ChangeProposal> {\n summary: React.FC<ProposalProps<P>>\n hint: JSX.Element | string\n}\n\n\nconst clarification: ProposalViewConfig<Clarification> = {\n hint: <>\n altered to represent the same concept more clearly.\n </>,\n summary: memo(({ proposal, item, itemRef }) => <>Clarification</>, () => true),\n};\n\n\nconst addition: ProposalViewConfig<Addition> = {\n hint: <>added to this register.</>,\n summary: memo(({ proposal, item, itemRef }) => <>Addition</>, () => true),\n};\n\n\nconst retirement: ProposalViewConfig<Retirement> = {\n hint: <>\n marked as no longer current.\n (Note that this register is append-only, so the item cannot be removed altogether.)\n </>,\n summary: memo(({ proposal, itemRef, item }) => <>Retirement</>, () => true),\n};\n\n\nconst supersession: ProposalViewConfig<Supersession> = {\n hint: <>\n removed from the register with another item recommended for use in its place.\n A relation between the superseding and superseded item will be created,\n though the exact semantics of that relation depend on the register.\n </>,\n summary: memo(({ proposal, itemRef, item }) => <>Supersession</>, () => true),\n};\n\n\nconst invalidation: ProposalViewConfig<Invalidation> = {\n hint: <>\n marked as invalid. The exact semantics of invalidation depend on the register.\n </>,\n summary: memo(({ proposal, itemRef, item }) => <>Invalidation</>, () => true),\n}\n\n\nconst MaximizedStructuredDiff = styled(StructuredDiff)`\n position: absolute;\n inset: 0;\n`;\n\n\ntype ProposalOrAmendmentType =\n | Exclude<typeof PROPOSAL_TYPES[number], 'amendment'>\n | typeof AMENDMENT_TYPES[number];\n\n\nconst PROPOSAL_VIEWS: { [type in ProposalOrAmendmentType]: ProposalViewConfig<any> } = {\n clarification,\n addition,\n retirement,\n supersession,\n invalidation,\n} as const;\n\n\nfunction getProposalIcon(proposal: ChangeProposal): IconName {\n return proposal.type === 'addition'\n ? 'add'\n : proposal.type === 'clarification'\n ? 'edit'\n : 'ban-circle';\n}\n\n\nexport default Proposals;\n\n\nconst ITEM_DATA_PLACEHOLDER = {} as const;\n"]}
@@ -2,7 +2,7 @@
2
2
  /** @jsxFrag React.Fragment */
3
3
  import React from 'react';
4
4
  declare const _default: {
5
- main: React.FC<{
5
+ main: React.VoidFunctionComponent<{
6
6
  uri: string;
7
7
  }>;
8
8
  title: React.FC<{