@pega/lists-core 9.28.0 → 9.29.0
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/lib/src/core/actions/actionConstants.d.ts +2 -0
- package/lib/src/core/actions/actionConstants.d.ts.map +1 -1
- package/lib/src/core/actions/actionConstants.js +3 -1
- package/lib/src/core/actions/actionConstants.js.map +1 -1
- package/lib/src/core/actions/actions.d.ts +8 -1
- package/lib/src/core/actions/actions.d.ts.map +1 -1
- package/lib/src/core/actions/actions.js +11 -0
- package/lib/src/core/actions/actions.js.map +1 -1
- package/lib/src/core/actions/actions.types.d.ts +10 -0
- package/lib/src/core/actions/actions.types.d.ts.map +1 -1
- package/lib/src/core/actions/actions.types.js.map +1 -1
- package/lib/src/core/features/featureFactory.d.ts.map +1 -1
- package/lib/src/core/features/featureFactory.js +2 -0
- package/lib/src/core/features/featureFactory.js.map +1 -1
- package/lib/src/core/features/uIFeatures/beforeRender/changeTemplate.d.ts.map +1 -1
- package/lib/src/core/features/uIFeatures/beforeRender/changeTemplate.js +5 -2
- package/lib/src/core/features/uIFeatures/beforeRender/changeTemplate.js.map +1 -1
- package/lib/src/core/features/uIFeatures/beforeRender/masterDetail.d.ts +11 -0
- package/lib/src/core/features/uIFeatures/beforeRender/masterDetail.d.ts.map +1 -0
- package/lib/src/core/features/uIFeatures/beforeRender/masterDetail.js +97 -0
- package/lib/src/core/features/uIFeatures/beforeRender/masterDetail.js.map +1 -0
- package/lib/src/core/features/uIFeatures/beforeRender/prepareRows.d.ts.map +1 -1
- package/lib/src/core/features/uIFeatures/beforeRender/prepareRows.js +1 -0
- package/lib/src/core/features/uIFeatures/beforeRender/prepareRows.js.map +1 -1
- package/lib/src/core/features/uIFeatures/beforeRender/refresh.d.ts.map +1 -1
- package/lib/src/core/features/uIFeatures/beforeRender/refresh.js +2 -0
- package/lib/src/core/features/uIFeatures/beforeRender/refresh.js.map +1 -1
- package/lib/src/core/features/uIFeatures/index.d.ts +2 -0
- package/lib/src/core/features/uIFeatures/index.d.ts.map +1 -1
- package/lib/src/core/features/uIFeatures/index.js +2 -0
- package/lib/src/core/features/uIFeatures/index.js.map +1 -1
- package/lib/src/core/generators/RowGenerator.d.ts +11 -1
- package/lib/src/core/generators/RowGenerator.d.ts.map +1 -1
- package/lib/src/core/generators/RowGenerator.js +36 -2
- package/lib/src/core/generators/RowGenerator.js.map +1 -1
- package/lib/src/core/generators/RowGenerator.types.d.ts +13 -1
- package/lib/src/core/generators/RowGenerator.types.d.ts.map +1 -1
- package/lib/src/core/generators/RowGenerator.types.js.map +1 -1
- package/lib/src/core/generators/ViewGenerator.d.ts +3 -1
- package/lib/src/core/generators/ViewGenerator.d.ts.map +1 -1
- package/lib/src/core/generators/ViewGenerator.js +7 -1
- package/lib/src/core/generators/ViewGenerator.js.map +1 -1
- package/lib/src/core/generators/ViewGenerator.types.d.ts +21 -1
- package/lib/src/core/generators/ViewGenerator.types.d.ts.map +1 -1
- package/lib/src/core/generators/ViewGenerator.types.js.map +1 -1
- package/lib/src/core/generators/__tests__/viewUtilityMockSetup.d.ts +5 -0
- package/lib/src/core/generators/__tests__/viewUtilityMockSetup.d.ts.map +1 -1
- package/lib/src/core/generators/viewUtilityMethods.d.ts +18 -0
- package/lib/src/core/generators/viewUtilityMethods.d.ts.map +1 -1
- package/lib/src/core/generators/viewUtilityMethods.js +91 -0
- package/lib/src/core/generators/viewUtilityMethods.js.map +1 -1
- package/lib/src/core/reducers/error.d.ts +1 -0
- package/lib/src/core/reducers/error.d.ts.map +1 -1
- package/lib/src/core/reducers/index.d.ts +1 -0
- package/lib/src/core/reducers/index.d.ts.map +1 -1
- package/lib/src/core/reducers/index.js +3 -1
- package/lib/src/core/reducers/index.js.map +1 -1
- package/lib/src/core/reducers/masterDetail.d.ts +4 -0
- package/lib/src/core/reducers/masterDetail.d.ts.map +1 -0
- package/lib/src/core/reducers/masterDetail.js +23 -0
- package/lib/src/core/reducers/masterDetail.js.map +1 -0
- package/lib/src/core/reducers/personalizationReducer.d.ts +1 -1
- package/lib/src/core/utils/masterDetail.d.ts +8 -0
- package/lib/src/core/utils/masterDetail.d.ts.map +1 -0
- package/lib/src/core/utils/masterDetail.js +25 -0
- package/lib/src/core/utils/masterDetail.js.map +1 -0
- package/lib/src/core/utils/util.d.ts.map +1 -1
- package/lib/src/core/utils/util.js +3 -0
- package/lib/src/core/utils/util.js.map +1 -1
- package/lib/types/Meta.types.d.ts +21 -3
- package/lib/types/Meta.types.d.ts.map +1 -1
- package/lib/types/Meta.types.js.map +1 -1
- package/lib/types/State.types.d.ts +9 -0
- package/lib/types/State.types.d.ts.map +1 -1
- package/lib/types/State.types.js.map +1 -1
- package/lib/types.d.ts +9 -4
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { AFTER_FETCH } from '../../../pubSub/events';
|
|
2
|
+
import { actionCloseMasterDetail } from '../../../actions/actions';
|
|
3
|
+
import { deepEqual, withMemoization } from '../../../utils/util';
|
|
4
|
+
import getMasterDetailSelection, { isMasterDetailSupported } from '../../../utils/masterDetail';
|
|
5
|
+
/** Returns whether two selections have the same derived row and navigation state. */
|
|
6
|
+
function hasSameSelection(previous, next) {
|
|
7
|
+
return (previous?.rowKey === next.rowKey &&
|
|
8
|
+
previous?.row === next.row &&
|
|
9
|
+
previous?.hasPrevious === next.hasPrevious &&
|
|
10
|
+
previous?.hasNext === next.hasNext &&
|
|
11
|
+
previous?.nestedTarget === next.nestedTarget &&
|
|
12
|
+
previous?.viewName === next.viewName);
|
|
13
|
+
}
|
|
14
|
+
/** Moves the Master Detail active marker from the previous row to the selected row. */
|
|
15
|
+
function updateActiveRow(view, selectedRow) {
|
|
16
|
+
const activeRow = view.rows?.find(row => row.masterDetailActive);
|
|
17
|
+
if (activeRow && activeRow !== selectedRow) {
|
|
18
|
+
activeRow.setProp({ masterDetailActive: false });
|
|
19
|
+
}
|
|
20
|
+
if (selectedRow && !selectedRow.masterDetailActive) {
|
|
21
|
+
selectedRow.setProp({ masterDetailActive: true });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Clears the Master Detail selection from Row and View generators */
|
|
25
|
+
function clearMasterDetail(view) {
|
|
26
|
+
updateActiveRow(view, undefined);
|
|
27
|
+
if (view.masterDetail) {
|
|
28
|
+
view.setProp({ masterDetail: undefined });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** Apply master detail information to Row and View generators. */
|
|
32
|
+
function applySelection(view, selection) {
|
|
33
|
+
updateActiveRow(view, selection.row);
|
|
34
|
+
// Navigation metadata is stored only on the View and must survive selection reconciliation.
|
|
35
|
+
const { nestedTarget, viewName } = view.masterDetail ?? {};
|
|
36
|
+
const nextSelection = { ...selection, nestedTarget, viewName };
|
|
37
|
+
// refreshKey is intentionally omitted from this comparison so a refresh signal is retained.
|
|
38
|
+
if (!hasSameSelection(view.masterDetail, nextSelection)) {
|
|
39
|
+
view.setProp({ masterDetail: nextSelection });
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Synchronizes Master Detail state with the View and Row generators. */
|
|
43
|
+
function syncMasterDetail([featureProps]) {
|
|
44
|
+
const state = featureProps.getState();
|
|
45
|
+
if (!isMasterDetailSupported(featureProps.getView()) || !state.masterDetail) {
|
|
46
|
+
clearMasterDetail(featureProps.getView());
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const selection = getMasterDetailSelection(featureProps.getView(), state);
|
|
50
|
+
if (selection) {
|
|
51
|
+
applySelection(featureProps.getView(), selection);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* 1. Synchronizes Master Detail selection from {@link State.masterDetail} into the generated
|
|
56
|
+
* {@link View.masterDetail View} and active Row when the state.masterDetail or meta.masterDetail changes.
|
|
57
|
+
* 2. Clears the generated selection when Master Detail configuration or state is absent.
|
|
58
|
+
* 3. Clears {@link State.masterDetail} after {@link AFTER_FETCH} when the selected Row is no
|
|
59
|
+
* longer generated.
|
|
60
|
+
*/
|
|
61
|
+
export default function masterDetail(rsInternal) {
|
|
62
|
+
/** Creates the complete feature context required by the after-fetch reconciliation. */
|
|
63
|
+
const getFeatureProps = () => ({
|
|
64
|
+
getState: rsInternal.getRsStateResolver().getState,
|
|
65
|
+
getView: rsInternal.getView,
|
|
66
|
+
getRsStore: rsInternal.getRsStore,
|
|
67
|
+
getRsProps: rsInternal.getRsProps,
|
|
68
|
+
getOriginalState: rsInternal.getRsStateResolver().getOriginalState,
|
|
69
|
+
dispatch: rsInternal.getRsStateResolver().dispatch,
|
|
70
|
+
queuedActions: [],
|
|
71
|
+
browserContext: rsInternal.getBrowserContext()
|
|
72
|
+
});
|
|
73
|
+
const memoizedSync = withMemoization(syncMasterDetail);
|
|
74
|
+
rsInternal.getPubSubUtils().subscribe(AFTER_FETCH, () => {
|
|
75
|
+
const featureProps = getFeatureProps();
|
|
76
|
+
const state = featureProps.getState();
|
|
77
|
+
if (!isMasterDetailSupported(featureProps.getView()) || !state.masterDetail) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const masterDetailRow = featureProps.getView().rows?.find(row => row.key === state.masterDetail?.rowKey &&
|
|
81
|
+
featureProps.getView().masterDetail?.rowKey === state.masterDetail?.rowKey &&
|
|
82
|
+
// Compare row data because index-based item keys can be reused after a row is removed.
|
|
83
|
+
deepEqual(row.data, featureProps.getView().masterDetail?.row.data));
|
|
84
|
+
// Clear Master Detail when its selected record is no longer in the generated rows.
|
|
85
|
+
if (!masterDetailRow) {
|
|
86
|
+
featureProps.dispatch(actionCloseMasterDetail());
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
// If row is still present then call sync again to update any stale context if present(like hasNext/hasPrevious)
|
|
90
|
+
syncMasterDetail([featureProps]);
|
|
91
|
+
});
|
|
92
|
+
return function execute(featureProps) {
|
|
93
|
+
const state = featureProps.getState();
|
|
94
|
+
memoizedSync([featureProps], [state.masterDetail, featureProps.getView().meta.masterDetail]);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=masterDetail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"masterDetail.js","sourceRoot":"","sources":["../../../../../../src/core/features/uIFeatures/beforeRender/masterDetail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,wBAAwB,EAAE,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAMhG,qFAAqF;AACrF,SAAS,gBAAgB,CACvB,QAA2C,EAC3C,IAA2B;IAE3B,OAAO,CACL,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC,MAAM;QAChC,QAAQ,EAAE,GAAG,KAAK,IAAI,CAAC,GAAG;QAC1B,QAAQ,EAAE,WAAW,KAAK,IAAI,CAAC,WAAW;QAC1C,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC,OAAO;QAClC,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAC,YAAY;QAC5C,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC,QAAQ,CACrC,CAAC;AACJ,CAAC;AAED,uFAAuF;AACvF,SAAS,eAAe,CAAC,IAAU,EAAE,WAAqD;IACxF,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAEjE,IAAI,SAAS,IAAI,SAAS,KAAK,WAAW,EAAE,CAAC;QAC3C,SAAS,CAAC,OAAO,CAAC,EAAE,kBAAkB,EAAE,KAAK,EAAE,CAAC,CAAC;IACnD,CAAC;IACD,IAAI,WAAW,IAAI,CAAC,WAAW,CAAC,kBAAkB,EAAE,C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,CAAC,GAAG,CAAC,IAAI,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC,YAAY,EAAE,GAAG,CAAC,IAAI,CAAC,CACrE,CAAC;QAEF,mFAAmF;QACnF,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,YAAY,CAAC,QAAQ,CAAC,uBAAuB,EAAE,CAAC,CAAC;YACjD,OAAO;QACT,CAAC;QAED,gHAAgH;QAChH,gBAAgB,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;IACnC,CAAC,CAAC,CAAC;IAEH,OAAO,SAAS,OAAO,CAAC,YAAsC;QAC5D,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;QACtC,YAAY,CAAC,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,CAAC,YAAY,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;IAC/F,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { AFTER_FETCH } from '../../../pubSub/events';\nimport { actionCloseMasterDetail } from '../../../actions/actions';\nimport { deepEqual, withMemoization } from '../../../utils/util';\nimport getMasterDetailSelection, { isMasterDetailSupported } from '../../../utils/masterDetail';\nimport type RsInternal from '../../../RsInternal';\nimport type { BeforeRenderFeatureProps } from '../../featureFactory';\nimport type View from '../../../generators/ViewGenerator';\nimport type { MasterDetailSelection } from '../../../generators/ViewGenerator.types';\n\n/** Returns whether two selections have the same derived row and navigation state. */\nfunction hasSameSelection(\n previous: MasterDetailSelection | undefined,\n next: MasterDetailSelection\n): boolean {\n return (\n previous?.rowKey === next.rowKey &&\n previous?.row === next.row &&\n previous?.hasPrevious === next.hasPrevious &&\n previous?.hasNext === next.hasNext &&\n previous?.nestedTarget === next.nestedTarget &&\n previous?.viewName === next.viewName\n );\n}\n\n/** Moves the Master Detail active marker from the previous row to the selected row. */\nfunction updateActiveRow(view: View, selectedRow: MasterDetailSelection['row'] | undefined): void {\n const activeRow = view.rows?.find(row => row.masterDetailActive);\n\n if (activeRow && activeRow !== selectedRow) {\n activeRow.setProp({ masterDetailActive: false });\n }\n if (selectedRow && !selectedRow.masterDetailActive) {\n selectedRow.setProp({ masterDetailActive: true });\n }\n}\n\n/** Clears the Master Detail selection from Row and View generators */\nfunction clearMasterDetail(view: View): void {\n updateActiveRow(view, undefined);\n if (view.masterDetail) {\n view.setProp({ masterDetail: undefined });\n }\n}\n\n/** Apply master detail information to Row and View generators. */\nfunction applySelection(view: View, selection: MasterDetailSelection): void {\n updateActiveRow(view, selection.row);\n\n // Navigation metadata is stored only on the View and must survive selection reconciliation.\n const { nestedTarget, viewName } = view.masterDetail ?? {};\n const nextSelection = { ...selection, nestedTarget, viewName };\n\n // refreshKey is intentionally omitted from this comparison so a refresh signal is retained.\n if (!hasSameSelection(view.masterDetail, nextSelection)) {\n view.setProp({ masterDetail: nextSelection });\n }\n}\n\n/** Synchronizes Master Detail state with the View and Row generators. */\nfunction syncMasterDetail([featureProps]: [\n Pick<BeforeRenderFeatureProps, 'getState' | 'getView' | 'dispatch'>\n]): void {\n const state = featureProps.getState();\n\n if (!isMasterDetailSupported(featureProps.getView()) || !state.masterDetail) {\n clearMasterDetail(featureProps.getView());\n return;\n }\n\n const selection = getMasterDetailSelection(featureProps.getView(), state);\n if (selection) {\n applySelection(featureProps.getView(), selection);\n }\n}\n\n/**\n * 1. Synchronizes Master Detail selection from {@link State.masterDetail} into the generated\n * {@link View.masterDetail View} and active Row when the state.masterDetail or meta.masterDetail changes.\n * 2. Clears the generated selection when Master Detail configuration or state is absent.\n * 3. Clears {@link State.masterDetail} after {@link AFTER_FETCH} when the selected Row is no\n * longer generated.\n */\nexport default function masterDetail(rsInternal: RsInternal) {\n /** Creates the complete feature context required by the after-fetch reconciliation. */\n const getFeatureProps = (): BeforeRenderFeatureProps => ({\n getState: rsInternal.getRsStateResolver().getState,\n getView: rsInternal.getView,\n getRsStore: rsInternal.getRsStore,\n getRsProps: rsInternal.getRsProps,\n getOriginalState: rsInternal.getRsStateResolver().getOriginalState,\n dispatch: rsInternal.getRsStateResolver().dispatch,\n queuedActions: [],\n browserContext: rsInternal.getBrowserContext()\n });\n\n const memoizedSync = withMemoization(syncMasterDetail);\n\n rsInternal.getPubSubUtils().subscribe(AFTER_FETCH, () => {\n const featureProps = getFeatureProps();\n const state = featureProps.getState();\n if (!isMasterDetailSupported(featureProps.getView()) || !state.masterDetail) {\n return;\n }\n\n const masterDetailRow = featureProps.getView().rows?.find(\n row =>\n row.key === state.masterDetail?.rowKey &&\n featureProps.getView().masterDetail?.rowKey === state.masterDetail?.rowKey &&\n // Compare row data because index-based item keys can be reused after a row is removed.\n deepEqual(row.data, featureProps.getView().masterDetail?.row.data)\n );\n\n // Clear Master Detail when its selected record is no longer in the generated rows.\n if (!masterDetailRow) {\n featureProps.dispatch(actionCloseMasterDetail());\n return;\n }\n\n // If row is still present then call sync again to update any stale context if present(like hasNext/hasPrevious)\n syncMasterDetail([featureProps]);\n });\n\n return function execute(featureProps: BeforeRenderFeatureProps) {\n const state = featureProps.getState();\n memoizedSync([featureProps], [state.masterDetail, featureProps.getView().meta.masterDetail]);\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareRows.d.ts","sourceRoot":"","sources":["../../../../../../src/core/features/uIFeatures/beforeRender/prepareRows.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"prepareRows.d.ts","sourceRoot":"","sources":["../../../../../../src/core/features/uIFeatures/beforeRender/prepareRows.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAuBlD;;GAEG;yBACa,YAAY,UAAU;AAAtC,wBAKE"}
|
|
@@ -10,6 +10,7 @@ function prepareRows([rsInternal]) {
|
|
|
10
10
|
const key = String(itemKey ?? index);
|
|
11
11
|
// If the row already existed in the previous data and we have a row object for that, don't create new row.
|
|
12
12
|
// This will help in memoization and thus improving performance.
|
|
13
|
+
// In case of duplicate keys or empty itemKey, this optimization will never work since reactKey will be uniqueID and it will never match with key.
|
|
13
14
|
const existingRow = getView().rows?.find(r => r.reactKey === key && deepEqual(r.data, d));
|
|
14
15
|
if (existingRow)
|
|
15
16
|
return existingRow;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareRows.js","sourceRoot":"","sources":["../../../../../../src/core/features/uIFeatures/beforeRender/prepareRows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,GAAG,MAAM,kCAAkC,CAAC;AAKnD,SAAS,WAAW,CAAC,CAAC,UAAU,CAA2B;IACzD,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;IAC/B,MAAM,QAAQ,GAAG,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC;IACvF,MAAM,gBAAgB,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;QAC5C,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;QACrC,2GAA2G;QAC3G,gEAAgE;QAChE,MAAM,WAAW,GAAG,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1F,IAAI,WAAW;YAAE,OAAO,WAAW,CAAC;QAEpC,MAAM,QAAQ,GAAG,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACnF,OAAO,IAAI,GAAG,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,eAAe,CAAC,UAAsB,EAAE,EAAE;IACxC,MAAM,mBAAmB,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IACzD,UAAU,CAAC,cAAc,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,GAAG,EAAE;QACtD,mBAAmB,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { withMemoization, hasDuplicates, deepEqual, isEmpty } from '../../../utils/util';\nimport { AFTER_FETCH } from '../../../pubSub/events';\nimport Row from '../../../generators/RowGenerator';\nimport type RsInternal from '../../../RsInternal';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type View from '../../../generators/ViewGenerator';\n\nfunction prepareRows([rsInternal]: [rsInternal: RsInternal]) {\n const { getView } = rsInternal;\n const itemKeys = getView().data?.map((d, index) => d[getView().meta.itemKey] ?? index);\n const hasDuplicateKeys = hasDuplicates(itemKeys);\n const rows = getView().data?.map((d, index) => {\n const itemKey = d[getView().meta.itemKey];\n const key = String(itemKey ?? index);\n // If the row already existed in the previous data and we have a row object for that, don't create new row.\n // This will help in memoization and thus improving performance.\n const existingRow = getView().rows?.find(r => r.reactKey === key && deepEqual(r.data, d));\n if (existingRow) return existingRow;\n\n const uniqueId = hasDuplicateKeys || isEmpty(itemKey) ? crypto.randomUUID() : null;\n return new Row({ key, rowData: d, uniqueId }, rsInternal);\n });\n getView().rows = rows;\n}\n\n/**\n * Prepare {@link View.rows rows} for the view from view {@link View.data data}. This is triggered on publish of `AFTER_FETCH` event.\n */\nexport default (rsInternal: RsInternal) => {\n const memoizedPrepareRows = withMemoization(prepareRows);\n rsInternal.getPubSubUtils().subscribe(AFTER_FETCH, () => {\n memoizedPrepareRows([rsInternal], [rsInternal, rsInternal.getView().data]);\n });\n};\n"]}
|
|
1
|
+
{"version":3,"file":"prepareRows.js","sourceRoot":"","sources":["../../../../../../src/core/features/uIFeatures/beforeRender/prepareRows.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,GAAG,MAAM,kCAAkC,CAAC;AAKnD,SAAS,WAAW,CAAC,CAAC,UAAU,CAA2B;IACzD,MAAM,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC;IAC/B,MAAM,QAAQ,GAAG,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC;IACvF,MAAM,gBAAgB,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC;IACjD,MAAM,IAAI,GAAG,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE;QAC5C,MAAM,OAAO,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1C,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;QACrC,2GAA2G;QAC3G,gEAAgE;QAChE,kJAAkJ;QAClJ,MAAM,WAAW,GAAG,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,GAAG,IAAI,SAAS,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1F,IAAI,WAAW;YAAE,OAAO,WAAW,CAAC;QAEpC,MAAM,QAAQ,GAAG,gBAAgB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QACnF,OAAO,IAAI,GAAG,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,EAAE,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC;AACxB,CAAC;AAED;;GAEG;AACH,eAAe,CAAC,UAAsB,EAAE,EAAE;IACxC,MAAM,mBAAmB,GAAG,eAAe,CAAC,WAAW,CAAC,CAAC;IACzD,UAAU,CAAC,cAAc,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,GAAG,EAAE;QACtD,mBAAmB,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC","sourcesContent":["import { withMemoization, hasDuplicates, deepEqual, isEmpty } from '../../../utils/util';\nimport { AFTER_FETCH } from '../../../pubSub/events';\nimport Row from '../../../generators/RowGenerator';\nimport type RsInternal from '../../../RsInternal';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type View from '../../../generators/ViewGenerator';\n\nfunction prepareRows([rsInternal]: [rsInternal: RsInternal]) {\n const { getView } = rsInternal;\n const itemKeys = getView().data?.map((d, index) => d[getView().meta.itemKey] ?? index);\n const hasDuplicateKeys = hasDuplicates(itemKeys);\n const rows = getView().data?.map((d, index) => {\n const itemKey = d[getView().meta.itemKey];\n const key = String(itemKey ?? index);\n // If the row already existed in the previous data and we have a row object for that, don't create new row.\n // This will help in memoization and thus improving performance.\n // In case of duplicate keys or empty itemKey, this optimization will never work since reactKey will be uniqueID and it will never match with key.\n const existingRow = getView().rows?.find(r => r.reactKey === key && deepEqual(r.data, d));\n if (existingRow) return existingRow;\n\n const uniqueId = hasDuplicateKeys || isEmpty(itemKey) ? crypto.randomUUID() : null;\n return new Row({ key, rowData: d, uniqueId }, rsInternal);\n });\n getView().rows = rows;\n}\n\n/**\n * Prepare {@link View.rows rows} for the view from view {@link View.data data}. This is triggered on publish of `AFTER_FETCH` event.\n */\nexport default (rsInternal: RsInternal) => {\n const memoizedPrepareRows = withMemoization(prepareRows);\n rsInternal.getPubSubUtils().subscribe(AFTER_FETCH, () => {\n memoizedPrepareRows([rsInternal], [rsInternal, rsInternal.getView().data]);\n });\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../../../../src/core/features/uIFeatures/beforeRender/refresh.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAMrE,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../../../../src/core/features/uIFeatures/beforeRender/refresh.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAMrE,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AA6BlD;;;;;;;;;;;GAWG;yBACa,YAAY,UAAU,MAIZ,cAAc,wBAAwB;AAJhE,wBAmBE"}
|
|
@@ -16,6 +16,8 @@ const resetRefresh = ({ getRsStore, getView }) => {
|
|
|
16
16
|
if (getRsStore().refreshInProgress) {
|
|
17
17
|
getRsStore().refreshInProgress = false;
|
|
18
18
|
getRsStore().refreshToken = undefined;
|
|
19
|
+
// A full refresh may change data rendered in Master Detail even if RS data is not changed.
|
|
20
|
+
getView().type.refreshMasterDetail();
|
|
19
21
|
}
|
|
20
22
|
};
|
|
21
23
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.js","sourceRoot":"","sources":["../../../../../../src/core/features/uIFeatures/beforeRender/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAQtD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,SAAS,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,CAA2C,EAAE,EAAE;IAC5E,MAAM,EACJ,IAAI,EAAE,EAAE,YAAY,EAAE,EACtB,mBAAmB,EACpB,GAAG,OAAO,EAAE,CAAC;IACd,IAAI,mBAAmB,EAAE,EAAE,EAAE,CAAC;QAC5B,YAAY,EAAE,CAAC;IACjB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,EAAE,UAAU,EAAE,OAAO,EAAc,EAAE,EAAE;IAC3D,gEAAgE;IAChE,IAAI,OAAO,EAAE,CAAC,mBAAmB,EAAE,EAAE,IAAI,UAAU,EAAE,CAAC,iBAAiB,EAAE,CAAC;QACxE,OAAO,EAAE,CAAC,OAAO,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;QACpD,OAAO,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,yDAAyD;IACzD,IAAI,UAAU,EAAE,CAAC,iBAAiB,EAAE,CAAC;QACnC,UAAU,EAAE,CAAC,iBAAiB,GAAG,KAAK,CAAC;QACvC,UAAU,EAAE,CAAC,YAAY,GAAG,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"refresh.js","sourceRoot":"","sources":["../../../../../../src/core/features/uIFeatures/beforeRender/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAQtD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAErD,MAAM,SAAS,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,CAA2C,EAAE,EAAE;IAC5E,MAAM,EACJ,IAAI,EAAE,EAAE,YAAY,EAAE,EACtB,mBAAmB,EACpB,GAAG,OAAO,EAAE,CAAC;IACd,IAAI,mBAAmB,EAAE,EAAE,EAAE,CAAC;QAC5B,YAAY,EAAE,CAAC;IACjB,CAAC;AACH,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,EAAE,UAAU,EAAE,OAAO,EAAc,EAAE,EAAE;IAC3D,gEAAgE;IAChE,IAAI,OAAO,EAAE,CAAC,mBAAmB,EAAE,EAAE,IAAI,UAAU,EAAE,CAAC,iBAAiB,EAAE,CAAC;QACxE,OAAO,EAAE,CAAC,OAAO,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;QACpD,OAAO,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;IAED,yDAAyD;IACzD,IAAI,UAAU,EAAE,CAAC,iBAAiB,EAAE,CAAC;QACnC,UAAU,EAAE,CAAC,iBAAiB,GAAG,KAAK,CAAC;QACvC,UAAU,EAAE,CAAC,YAAY,GAAG,SAAS,CAAC;QACtC,2FAA2F;QAC3F,OAAO,EAAE,CAAC,IAAI,CAAC,mBAAmB,EAAE,CAAC;IACvC,CAAC;AACH,CAAC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAe,CAAC,UAAsB,EAAE,EAAE;IACxC,UAAU,CAAC,cAAc,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;IACnF,MAAM,iBAAiB,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;IAErD,OAAO,SAAS,OAAO,CAAC,YAAsC;QAC5D,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,EAAE,CAAC;QACtC,iBAAiB,CACf,CAAC,YAAY,CAAC,EACd;YACE,KAAK,CAAC,gBAAgB;YACtB,KAAK,CAAC,MAAM,EAAE,KAAK;YACnB,KAAK,EAAE,YAAY;YACnB,KAAK,CAAC,WAAW;YACjB,KAAK,CAAC,iBAAiB;YACvB,KAAK,CAAC,eAAe;YACrB,KAAK,CAAC,MAAM;SACb,CACF,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import { withMemoization } from '../../../utils/util';\nimport type { BeforeRenderFeatureProps } from '../../featureFactory';\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type View from '../../../generators/ViewGenerator';\nimport type { State } from '../../../../../types/State.types';\nimport type { UtilityFunctions } from '../../../generators/viewUtilityMethods';\n/* eslint-enable @typescript-eslint/no-unused-vars */\nimport type RsInternal from '../../../RsInternal';\nimport { AFTER_FETCH } from '../../../pubSub/events';\n\nconst onRefresh = ([{ getView }]: [featureProps: BeforeRenderFeatureProps]) => {\n const {\n type: { forceRefresh },\n refreshNotification\n } = getView();\n if (refreshNotification?.id) {\n forceRefresh();\n }\n};\n\nconst resetRefresh = ({ getRsStore, getView }: RsInternal) => {\n // Clear the refresh notification once the refresh is completed.\n if (getView().refreshNotification?.id && getRsStore().refreshInProgress) {\n getView().setProp('refreshNotification', undefined);\n getView().type.forceUpdate(false);\n }\n\n // Reset the refresh flags once the refresh is completed.\n if (getRsStore().refreshInProgress) {\n getRsStore().refreshInProgress = false;\n getRsStore().refreshToken = undefined;\n // A full refresh may change data rendered in Master Detail even if RS data is not changed.\n getView().type.refreshMasterDetail();\n }\n};\n\n/**\n * 1. Triggers {@link UtilityFunctions.forceRefresh forceRefresh} if {@link View.refreshNotification refresh notification} is on and any of the following state properties are changed:\n * - {@link State.filterExpression}\n * - `query` in {@link State.search}\n * - {@link State.sortingOrder}\n * - {@link State.groupToggle}\n * - {@link State.allGroupsExpanded}\n * - {@link State.aggregationInfo}\n * - {@link State.groups}\n * 2. Reset the refresh notification once the refresh is completed by subscribing to {@link AFTER_FETCH} event.\n * 3. Reset the `refreshInProgress` and `refreshToken` in {@link RsStore} once the refresh is completed.\n */\nexport default (rsInternal: RsInternal) => {\n rsInternal.getPubSubUtils().subscribe(AFTER_FETCH, () => resetRefresh(rsInternal));\n const memoizedOnRefresh = withMemoization(onRefresh);\n\n return function execute(featureProps: BeforeRenderFeatureProps) {\n const state = featureProps.getState();\n memoizedOnRefresh(\n [featureProps],\n [\n state.filterExpression,\n state.search?.query,\n state?.sortingOrder,\n state.groupToggle,\n state.allGroupsExpanded,\n state.aggregationInfo,\n state.groups\n ]\n );\n };\n};\n"]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import scrollToTop from './beforeRender/scrollToTop';
|
|
2
|
+
import masterDetail from './beforeRender/masterDetail';
|
|
2
3
|
declare const _default: {
|
|
3
4
|
beforeRender: {
|
|
4
5
|
busyIndicator: (rsInternal: import("../../RsInternal").default) => (featureProps: import("../featureFactory").BeforeRenderFeatureProps) => void;
|
|
@@ -22,6 +23,7 @@ declare const _default: {
|
|
|
22
23
|
aggregation: () => (featureProps: import("../featureFactory").BeforeRenderFeatureProps) => Promise<void>;
|
|
23
24
|
stateSanitization: () => (featureProps: import("../featureFactory").BeforeRenderFeatureProps) => void;
|
|
24
25
|
prepareRows: (rsInternal: import("../../RsInternal").default) => void;
|
|
26
|
+
masterDetail: typeof masterDetail;
|
|
25
27
|
prepareColumns: (rsInternal: import("../../RsInternal").default) => (featureProps: import("../featureFactory").BeforeRenderFeatureProps) => void;
|
|
26
28
|
columnFormatter: () => (featureProps: import("../featureFactory").BeforeRenderFeatureProps) => void;
|
|
27
29
|
ColumnDisplayMode: () => (featureProps: import("../featureFactory").BeforeRenderFeatureProps) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/features/uIFeatures/index.ts"],"names":[],"mappings":"AAsCA,OAAO,WAAW,MAAM,4BAA4B,CAAC;;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/features/uIFeatures/index.ts"],"names":[],"mappings":"AAsCA,OAAO,WAAW,MAAM,4BAA4B,CAAC;AAErD,OAAO,YAAY,MAAM,6BAA6B,CAAC;;;4EANd,kEAClB;6BAnBlB,kEAAsC;6BAyEgxG,kEAAsC;uBAbp1G,kEAGT;;0BAzDgD,kEAChB;;uBAYF,kEACR;6BAqDiiC,kEAAsC;;4BA3D7iC,kEACpC;8BA0DksM,kEAAsC;kCA7B1uM,kEAEZ;6BArC+B,kEAChB;2BAGgB,kEAC5B;2EA2D6vD,kEAAsC;yCAjDxxD,kEAAsC;+BAiDikL,kEAAsC;4BArD3nL,kEACd;kCAoDq0T,kEAAsC;;;6EAA/1L,kEAAsC;gCA/DpiI,kEACpB;kCAR2C,kEAC1C;4BAqES,kEAAsC;kCApEvC,kEAAsC;sCAQ/B,kEAC7B;+BAE2B,kEACZ;0EAwDmxP,kEAAsC;wEAA78I,kEAAsC;4BAVt5G,kEAEI;6BAtE8C,kEAC5B;sEA2BZ,kEAAsC;2BAkDlB,kEAAsC;4BA/DzD,kEACpB;;uCA8Do2B,kEAAsC;;;0BAAotD,sDAA0B;iCAAi8C,sDAA0B;yCA7D9iI,sDAC5B;;;AAaZ,wBA8CE"}
|
|
@@ -38,6 +38,7 @@ import resetFetch from './beforeRender/resetFetch';
|
|
|
38
38
|
import errorColumn from './beforeRender/errorColumn';
|
|
39
39
|
import scrollToTop from './beforeRender/scrollToTop';
|
|
40
40
|
import conditionalStyleFormat from './beforeRender/conditionalStyleFormat';
|
|
41
|
+
import masterDetail from './beforeRender/masterDetail';
|
|
41
42
|
export default {
|
|
42
43
|
beforeRender: {
|
|
43
44
|
busyIndicator,
|
|
@@ -61,6 +62,7 @@ export default {
|
|
|
61
62
|
aggregation,
|
|
62
63
|
stateSanitization,
|
|
63
64
|
prepareRows,
|
|
65
|
+
masterDetail,
|
|
64
66
|
prepareColumns,
|
|
65
67
|
columnFormatter,
|
|
66
68
|
ColumnDisplayMode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/features/uIFeatures/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAC3C,OAAO,YAAY,MAAM,0BAA0B,CAAC;AACpD,OAAO,SAAS,MAAM,0BAA0B,CAAC;AACjD,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;AACjE,OAAO,aAAa,MAAM,8BAA8B,CAAC;AACzD,OAAO,eAAe,MAAM,gCAAgC,CAAC;AAC7D,OAAO,YAAY,MAAM,6BAA6B,CAAC;AACvD,OAAO,YAAY,MAAM,6BAA6B,CAAC;AACvD,OAAO,UAAU,MAAM,2BAA2B,CAAC;AACnD,OAAO,eAAe,MAAM,gCAAgC,CAAC;AAC7D,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;AACjE,OAAO,aAAa,MAAM,yBAAyB,CAAC;AACpD,OAAO,wBAAwB,MAAM,wCAAwC,CAAC;AAC9E,OAAO,YAAY,MAAM,6BAA6B,CAAC;AACvD,OAAO,YAAY,MAAM,oCAAoC,CAAC;AAC9D,OAAO,QAAQ,MAAM,yBAAyB,CAAC;AAC/C,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAC3C,OAAO,YAAY,MAAM,6BAA6B,CAAC;AACvD,OAAO,wBAAwB,MAAM,yCAAyC,CAAC;AAC/E,OAAO,cAAc,MAAM,+BAA+B,CAAC;AAC3D,OAAO,iBAAiB,MAAM,kCAAkC,CAAC;AACjE,OAAO,WAAW,MAAM,4BAA4B,CAA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,EAAE,YAAY;QACvB,SAAS;QACT,QAAQ;QACR,MAAM;QACN,YAAY;QACZ,eAAe;QACf,WAAW;QACX,aAAa;QACb,iBAAiB;QACjB,YAAY;QACZ,UAAU;QACV,YAAY;QACZ,wBAAwB;QACxB,cAAc;QACd,WAAW;QACX,iBAAiB;QACjB,WAAW;QACX,YAAY;QACZ,cAAc;QACd,eAAe;QACf,iBAAiB;QACjB,WAAW;QACX,iBAAiB;QACjB,qBAAqB;QACrB,cAAc;QACd,WAAW;QACX,SAAS;QACT,WAAW;QACX,YAAY;QACZ,OAAO;QACP,UAAU;QACV,WAAW;QACX,WAAW;QACX,sBAAsB;KACvB;IACD,WAAW,EAAE;QACX,SAAS,EAAE,aAAa;QACxB,gBAAgB;QAChB,wBAAwB;KACzB;CACF,CAAC","sourcesContent":["import freeze from './beforeRender/freeze';\nimport preAnimation from './beforeRender/animation';\nimport rowHeight from './beforeRender/rowHeight';\nimport columnOrder from './beforeRender/columnOrder';\nimport columnVisualOrder from './beforeRender/columnVisualOrder';\nimport columnReOrder from './beforeRender/columnReOrder';\nimport personalization from './beforeRender/personalization';\nimport customColumn from './beforeRender/customColumn';\nimport columnToggle from './beforeRender/columnToggle';\nimport columnSort from './beforeRender/columnSort';\nimport columnFormatter from './beforeRender/columnFormatter';\nimport ColumnDisplayMode from './beforeRender/columnDisplayMode';\nimport postAnimation from './afterRender/animation';\nimport customizeParentContainer from './afterRender/customizeParentContainer';\nimport columnSizing from './beforeRender/columnSizing';\nimport columnResize from './beforeRender/columnSizing/resize';\nimport grouping from './beforeRender/grouping';\nimport filter from './beforeRender/filter';\nimport adjustHeight from './beforeRender/adjustHeight';\nimport adjustHeightToFitRecords from './beforeRender/adjustHeightToFitRecords';\nimport stateHydration from './beforeRender/stateHydration';\nimport stateSanitization from './beforeRender/stateSanitization';\nimport aggregation from './beforeRender/aggregation';\nimport prepareRows from './beforeRender/prepareRows';\nimport prepareColumns from './beforeRender/prepareColumns';\nimport columnAlias from './beforeRender/columnAlias';\nimport busyIndicator from './beforeRender/busyIndicator';\nimport columnAutoSizing from './afterRender/columnSizing';\nimport rowDragDrop from './beforeRender/rowDragDrop';\nimport toggleHeaderIcons from './beforeRender/toggleHeaderIcons';\nimport changePersonalisation from './beforeRender/changePersonalisation';\nimport changeTemplate from './beforeRender/changeTemplate';\nimport rowSelect from './beforeRender/rowSelect';\nimport moveRecords from './beforeRender/moveListRecords';\nimport renderHeader from './beforeRender/renderHeader';\nimport refresh from './beforeRender/refresh';\nimport resetFetch from './beforeRender/resetFetch';\nimport errorColumn from './beforeRender/errorColumn';\nimport scrollToTop from './beforeRender/scrollToTop';\nimport conditionalStyleFormat from './beforeRender/conditionalStyleFormat';\nimport masterDetail from './beforeRender/masterDetail';\n\nexport default {\n beforeRender: {\n busyIndicator,\n columnSizing,\n columnResize,\n freeze,\n animation: preAnimation,\n rowHeight,\n grouping,\n filter,\n customColumn,\n personalization,\n columnOrder,\n columnReOrder,\n columnVisualOrder,\n columnToggle,\n columnSort,\n adjustHeight,\n adjustHeightToFitRecords,\n stateHydration,\n aggregation,\n stateSanitization,\n prepareRows,\n masterDetail,\n prepareColumns,\n columnFormatter,\n ColumnDisplayMode,\n columnAlias,\n toggleHeaderIcons,\n changePersonalisation,\n changeTemplate,\n rowDragDrop,\n rowSelect,\n moveRecords,\n renderHeader,\n refresh,\n resetFetch,\n errorColumn,\n scrollToTop,\n conditionalStyleFormat\n },\n afterRender: {\n animation: postAnimation,\n columnAutoSizing,\n customizeParentContainer\n }\n};\n"]}
|
|
@@ -23,6 +23,8 @@ export default class Row {
|
|
|
23
23
|
rowData: RowData;
|
|
24
24
|
/** A unique key to identify a row object in case {@link key} is duplicate. This can be used in the dom to uniquely identify a row. */
|
|
25
25
|
uniqueId?: string | null;
|
|
26
|
+
/** Generic interaction marker used by template renderers. */
|
|
27
|
+
masterDetailActive?: boolean;
|
|
26
28
|
/**
|
|
27
29
|
* Creates an instance of Row object for a repeating structure.
|
|
28
30
|
* @param args Constructor arguments
|
|
@@ -35,7 +37,7 @@ export default class Row {
|
|
|
35
37
|
* @param args.uniqueId A unique key to identify a row object in case {@link key} is duplicate.
|
|
36
38
|
* @param rsInternal A reference to {@link RsInternal} object.
|
|
37
39
|
*/
|
|
38
|
-
constructor({ key, role, tabIndex, dragProps, dropProps, rowData, uniqueId }: RowOptions, rsInternal: RsInternal);
|
|
40
|
+
constructor({ key, role, tabIndex, dragProps, dropProps, rowData, uniqueId, masterDetailActive }: RowOptions, rsInternal: RsInternal);
|
|
39
41
|
/** A reference to {@link View} object. */
|
|
40
42
|
get parent(): View;
|
|
41
43
|
/**
|
|
@@ -69,6 +71,14 @@ export default class Row {
|
|
|
69
71
|
* @param selected Flag to indicate the row is selected or not.
|
|
70
72
|
*/
|
|
71
73
|
selectRow(selected?: boolean): void;
|
|
74
|
+
/** Opens Master Detail for this row. */
|
|
75
|
+
openMasterDetail(nestedTarget?: Record<string, unknown>, viewName?: string): void;
|
|
76
|
+
/** Closes the active Master Detail item. */
|
|
77
|
+
closeMasterDetail(): void;
|
|
78
|
+
/** Clears the nested target set on this row's active Master Detail selection, without closing it. */
|
|
79
|
+
clearMasterDetailNestedTarget(): void;
|
|
80
|
+
/** Navigates from the active Master Detail item. */
|
|
81
|
+
navigateMasterDetail(direction: 'previous' | 'next'): void;
|
|
72
82
|
/**
|
|
73
83
|
* Returns the ui props for the {@link Row} that can be used to build a row in DOM.
|
|
74
84
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RowGenerator.d.ts","sourceRoot":"","sources":["../../../../src/core/generators/RowGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sDAAsD,CAAC;AAKtF,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"RowGenerator.d.ts","sourceRoot":"","sources":["../../../../src/core/generators/RowGenerator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MA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,UAAU,CAAC,GAAG,MAAM,UAAU,EAC5C,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS;IAyBlE;;;OAGG;IACG,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAiDhC;;;OAGG;IACH,SAAS,CAAC,QAAQ,UAAO,GAAG,IAAI;IAgBhC,wCAAwC;IACxC,gBAAgB,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI;IAIjF,4CAA4C;IAC5C,iBAAiB,IAAI,IAAI;IAIzB,qGAAqG;IACrG,6BAA6B,IAAI,IAAI;IAIrC,oDAAoD;IACpD,oBAAoB,CAAC,SAAS,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI;IAI1D;;;OAGG;IACH,UAAU,IAAI,OAAO;IAiBrB;;;OAGG;IACH,WAAW,IAAI,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,SAAS;IAIrD;;;;;OAKG;IACH,YAAY,IAAI,SAAS,GAAG,SAAS;IAqBrC;;;;;OAKG;IACH,UAAU,IAAI,UAAU;CA8BzB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { STATE, SELECTION_MODES } from '../constants';
|
|
2
2
|
import { compareObjects, deepCopy, isRowReorderFieldEnabled } from '../utils/util';
|
|
3
3
|
import { actionForceUpdate, actionRowSelectionUpdate } from '../actions/actions';
|
|
4
|
+
import { isMasterDetailSupported } from '../utils/masterDetail';
|
|
4
5
|
import { dataKey } from './RowGenerator.types';
|
|
5
6
|
/** A row model that represents row of a repeating structure component. */
|
|
6
7
|
export default class Row {
|
|
@@ -22,6 +23,8 @@ export default class Row {
|
|
|
22
23
|
rowData;
|
|
23
24
|
/** A unique key to identify a row object in case {@link key} is duplicate. This can be used in the dom to uniquely identify a row. */
|
|
24
25
|
uniqueId;
|
|
26
|
+
/** Generic interaction marker used by template renderers. */
|
|
27
|
+
masterDetailActive;
|
|
25
28
|
/** A reference to {@link RsInternal} object. */
|
|
26
29
|
#rsInternal;
|
|
27
30
|
/**
|
|
@@ -36,7 +39,7 @@ export default class Row {
|
|
|
36
39
|
* @param args.uniqueId A unique key to identify a row object in case {@link key} is duplicate.
|
|
37
40
|
* @param rsInternal A reference to {@link RsInternal} object.
|
|
38
41
|
*/
|
|
39
|
-
constructor({ key, role = 'row', tabIndex = 0, dragProps, dropProps, rowData, uniqueId }, rsInternal) {
|
|
42
|
+
constructor({ key, role = 'row', tabIndex = 0, dragProps, dropProps, rowData, uniqueId, masterDetailActive }, rsInternal) {
|
|
40
43
|
this.key = key;
|
|
41
44
|
this.role = role;
|
|
42
45
|
this.tabIndex = tabIndex;
|
|
@@ -44,6 +47,7 @@ export default class Row {
|
|
|
44
47
|
this.dropProps = dropProps;
|
|
45
48
|
this.rowData = rowData;
|
|
46
49
|
this.uniqueId = uniqueId;
|
|
50
|
+
this.masterDetailActive = masterDetailActive;
|
|
47
51
|
this.#rsInternal = rsInternal;
|
|
48
52
|
/** IMP: For generator methods use traditional function syntax
|
|
49
53
|
* rather than arrow function for memory efficiency
|
|
@@ -52,6 +56,10 @@ export default class Row {
|
|
|
52
56
|
this.getContext = this.getContext.bind(this);
|
|
53
57
|
this.updateRow = this.updateRow.bind(this);
|
|
54
58
|
this.selectRow = this.selectRow.bind(this);
|
|
59
|
+
this.openMasterDetail = this.openMasterDetail.bind(this);
|
|
60
|
+
this.closeMasterDetail = this.closeMasterDetail.bind(this);
|
|
61
|
+
this.clearMasterDetailNestedTarget = this.clearMasterDetailNestedTarget.bind(this);
|
|
62
|
+
this.navigateMasterDetail = this.navigateMasterDetail.bind(this);
|
|
55
63
|
this.setProp = this.setProp.bind(this);
|
|
56
64
|
this.getRowError = this.getRowError.bind(this);
|
|
57
65
|
this.getRowHeader = this.getRowHeader.bind(this);
|
|
@@ -73,7 +81,8 @@ export default class Row {
|
|
|
73
81
|
dragProps: this.dragProps,
|
|
74
82
|
dropProps: this.dropProps,
|
|
75
83
|
rowData: this.rowData,
|
|
76
|
-
uniqueId: this.uniqueId
|
|
84
|
+
uniqueId: this.uniqueId,
|
|
85
|
+
masterDetailActive: this.masterDetailActive
|
|
77
86
|
};
|
|
78
87
|
}
|
|
79
88
|
/**
|
|
@@ -190,6 +199,8 @@ export default class Row {
|
|
|
190
199
|
...getView().rows.slice(rowIndex + 1)
|
|
191
200
|
]
|
|
192
201
|
});
|
|
202
|
+
// Refresh the active detail as it may be stale even when the refreshed table row data is unchanged.
|
|
203
|
+
getView().type.refreshMasterDetail([this.key]);
|
|
193
204
|
dispatch(actionForceUpdate());
|
|
194
205
|
}
|
|
195
206
|
}
|
|
@@ -209,6 +220,22 @@ export default class Row {
|
|
|
209
220
|
mode: this.parent.meta.selectionMode
|
|
210
221
|
}));
|
|
211
222
|
}
|
|
223
|
+
/** Opens Master Detail for this row. */
|
|
224
|
+
openMasterDetail(nestedTarget, viewName) {
|
|
225
|
+
this.parent.type.openMasterDetail(this.key, nestedTarget, viewName);
|
|
226
|
+
}
|
|
227
|
+
/** Closes the active Master Detail item. */
|
|
228
|
+
closeMasterDetail() {
|
|
229
|
+
this.parent.type.closeMasterDetail();
|
|
230
|
+
}
|
|
231
|
+
/** Clears the nested target set on this row's active Master Detail selection, without closing it. */
|
|
232
|
+
clearMasterDetailNestedTarget() {
|
|
233
|
+
this.parent.type.clearMasterDetailNestedTarget(this.key);
|
|
234
|
+
}
|
|
235
|
+
/** Navigates from the active Master Detail item. */
|
|
236
|
+
navigateMasterDetail(direction) {
|
|
237
|
+
this.parent.type.navigateMasterDetail(direction);
|
|
238
|
+
}
|
|
212
239
|
/**
|
|
213
240
|
* Returns the ui props for the {@link Row} that can be used to build a row in DOM.
|
|
214
241
|
*
|
|
@@ -273,6 +300,7 @@ export default class Row {
|
|
|
273
300
|
const rsProps = getRsProps();
|
|
274
301
|
return {
|
|
275
302
|
name: 'row',
|
|
303
|
+
getRowKey: () => this.key,
|
|
276
304
|
getValue: () => this.data,
|
|
277
305
|
getParentContext: this.parent.getContext,
|
|
278
306
|
getRowActionDetails: (rowContext) => {
|
|
@@ -281,6 +309,12 @@ export default class Row {
|
|
|
281
309
|
getDragProps: () => this.dragProps,
|
|
282
310
|
selectRow: this.selectRow,
|
|
283
311
|
refreshRow: this.updateRow,
|
|
312
|
+
...(isMasterDetailSupported(getView()) && {
|
|
313
|
+
openMasterDetail: this.openMasterDetail,
|
|
314
|
+
closeMasterDetail: this.closeMasterDetail,
|
|
315
|
+
clearMasterDetailNestedTarget: this.clearMasterDetailNestedTarget,
|
|
316
|
+
navigateMasterDetail: this.navigateMasterDetail
|
|
317
|
+
}),
|
|
284
318
|
$selected: this.$selected,
|
|
285
319
|
getRowError: this.getRowError,
|
|
286
320
|
getRowHeader: this.getRowHeader
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RowGenerator.js","sourceRoot":"","sources":["../../../../src/core/generators/RowGenerator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAOjF,OAAO,EACL,OAAO,EAQR,MAAM,sBAAsB,CAAC;AAE9B,0EAA0E;AAC1E,MAAM,CAAC,OAAO,OAAO,GAAG;IACtB,sHAAsH;IAC/G,GAAG,CAAS;IACnB;;OAEG;IACH,IAAI,CAAS;IACb;;OAEG;IACH,QAAQ,CAAS;IACjB,+CAA+C;IACxC,SAAS,CAAa;IAC7B,+CAA+C;IACxC,SAAS,CAAa;IAC7B,oCAAoC;IACpC,OAAO,CAAU;IACjB,sIAAsI;IACtI,QAAQ,CAAiB;IACzB,gDAAgD;IAChD,WAAW,CAAa;IACxB;;;;;;;;;;;OAWG;IACH,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E,IAAI,CAAC,MAAM,CAAC,UAAU;YACxC,mBAAmB,EAAE,CAAC,UAAmB,EAAE,EAAE;gBAC3C,OAAO,CACL,OAAO,CAAC,UAAU,CAAC,qBAAqB,EAAE,CACxC,UAAU,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,CAAW,EAC5C,UAAU,CACX,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CACzB,CAAC;YACJ,CAAC;YACD,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS;YAClC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { DataError } from 'pega-repeating-structures-core/lib/types/State.types';\n\nimport { STATE, SELECTION_MODES } from '../constants';\nimport { compareObjects, deepCopy, isRowReorderFieldEnabled } from '../utils/util';\nimport { actionForceUpdate, actionRowSelectionUpdate } from '../actions/actions';\nimport type RsInternal from '../RsInternal';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { Meta } from '../../../types/Meta.types';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type View from './ViewGenerator';\nimport {\n dataKey,\n type DragProps,\n type DropProps,\n type RowContext,\n type RowData,\n type RowHeader,\n type RowOptions,\n type UIProps\n} from './RowGenerator.types';\nimport type Column from './ColumnGenerator';\n/** A row model that represents row of a repeating structure component. */\nexport default class Row {\n /** A unique key to identify a row object. The value of this must be derived from one of the key of {@link rowData} */\n public key: string;\n /** Value for Html attribute 'role'.\n * @default 'row'\n */\n role: string;\n /** Value of Html attribute 'tabindex'.\n * @default 0\n */\n tabIndex: number;\n /** Properties related to dragging behavior. */\n public dragProps?: DragProps;\n /** Properties related to dropping behavior. */\n public dropProps?: DropProps;\n /** Represents the data of a row. */\n rowData: RowData;\n /** A unique key to identify a row object in case {@link key} is duplicate. This can be used in the dom to uniquely identify a row. */\n uniqueId?: string | null;\n /** A reference to {@link RsInternal} object. */\n #rsInternal: RsInternal;\n /**\n * Creates an instance of Row object for a repeating structure.\n * @param args Constructor arguments\n * @param args.key A unique key to identify a row object.\n * @param args.role Value for Html attribute 'role'. Default is 'row'\n * @param args.tabIndex Value of Html attribute 'tabindex'. Default is 0.\n * @param args.dragProps Properties related to dragging behavior.\n * @param args.dropProps Properties related to dropping behavior.\n * @param args.rowData Represents the data of a row.\n * @param args.uniqueId A unique key to identify a row object in case {@link key} is duplicate.\n * @param rsInternal A reference to {@link RsInternal} object.\n */\n constructor(\n { key, role = 'row', tabIndex = 0, dragProps, dropProps, rowData, uniqueId }: RowOptions,\n rsInternal: RsInternal\n ) {\n this.key = key;\n this.role = role;\n this.tabIndex = tabIndex;\n this.dragProps = dragProps;\n this.dropProps = dropProps;\n this.rowData = rowData;\n this.uniqueId = uniqueId;\n this.#rsInternal = rsInternal;\n\n /** IMP: For generator methods use traditional function syntax\n * rather than arrow function for memory efficiency\n * and bind 'this' to the methods which requires 'this' context. */\n this.getUIProps = this.getUIProps.bind(this);\n this.getContext = this.getContext.bind(this);\n this.updateRow = this.updateRow.bind(this);\n this.selectRow = this.selectRow.bind(this);\n\n this.setProp = this.setProp.bind(this);\n this.getRowError = this.getRowError.bind(this);\n this.getRowHeader = this.getRowHeader.bind(this);\n }\n\n /** A reference to {@link View} object. */\n get parent() {\n return this.#rsInternal.getView();\n }\n\n /**\n * This is majorly used by {@link setprop} function to create a new row object from existing row object.\n * @returns the row instance properties.\n */\n #get(): RowOptions & { className: string } {\n return {\n key: this.key,\n role: this.role,\n tabIndex: this.tabIndex,\n className: this.className,\n dragProps: this.dragProps,\n dropProps: this.dropProps,\n rowData: this.rowData,\n uniqueId: this.uniqueId\n };\n }\n\n /**\n * This property serves to uniquely identify a row's DOM element within a DOM hierarchy.\n * It plays a vital role in modern JavaScript frameworks such as React, where optimizing DOM manipulation requires unique keys.\n * The value is derived from either {@link key} or {@link uniqueId} if {@link key} is duplicate.\n */\n get reactKey() {\n return this.uniqueId || this.key;\n }\n\n /** The data for the row. */\n get data() {\n return this.rowData;\n }\n\n /** Value of HTMl attribute data-key. The value is derived from\n * either the value of {@link Meta.itemKey itemkey} in {@link data} or {@link key} */\n get [dataKey](): string {\n const keyData = this.data?.[this.parent.meta.itemKey];\n if (keyData) return keyData as string;\n return this.key;\n }\n\n /** A set of CSS class names for Row element. */\n get className() {\n const baseRowClass = this.getRowError()?.message ? 'row row-error' : 'row';\n if (this.parent.meta.selectionMode === SELECTION_MODES.multi_on_hover)\n return this.$selected ? `${baseRowClass} selected-row` : `${baseRowClass} row-on-hover`;\n\n return baseRowClass;\n }\n\n /** A transient value to signifies if a row is selected or not if selection mode is on. */\n get $selected(): RowContext['$selected'] {\n const temporaryChangeSetValue = this.parent.state.rowSelectionChangeSet?.[this.key]?.selected;\n const committedValue = this.parent.state.selectedRows?.includes(this.key);\n if (\n (temporaryChangeSetValue ?? committedValue) &&\n this.parent.meta.selectionMode === SELECTION_MODES.single &&\n this.uniqueId\n ) {\n /**\n * temporaryChangeSetValue ?? committedValue - Is current row selected\n * this.parent.meta.selectionMode === SELECTION_MODES.single - Is single select mode\n * this.uniqueId - unique id is present only in case of duplicate rows\n */\n if (this.parent.getSingleSelectionRowKey()) {\n // This block is to avoid duplicate radio button selection on user selection\n return this.parent.getSingleSelectionRowKey() === this.uniqueId;\n }\n for (let i = 0; i < this.parent.rows!.length; i += 1) {\n // This block is to avoid duplicate radio button selection onload / remount\n const row = this.parent.rows![i];\n const rowTemporaryChangeSetValue =\n this.parent.state.rowSelectionChangeSet?.[row.key]?.selected;\n const rowCommittedValue =\n this.parent.state.selectedRows && this.parent.state.selectedRows?.includes(row.key);\n if (rowTemporaryChangeSetValue ?? rowCommittedValue) {\n // 'row' - first selected row in this.parent.rows\n return this.uniqueId === row.uniqueId; // If 'row' is same as current object return true otherwise return false\n }\n }\n }\n return temporaryChangeSetValue ?? committedValue;\n }\n\n /**\n * This is used to create immutable objects of {@link Row} instance. Always call setProp if updating any properties of Row to make it immutable.\n * @param prop Either partial of row object or individual properties of row object.\n * @param value An optional parameter to provide value for {@link prop} in case prop is not of type {@link Row}\n */\n setProp(\n prop: Partial<RowOptions> | keyof RowOptions,\n value?: string | number | Date | boolean | DragProps | DropProps\n ) {\n const { getView } = this.#rsInternal;\n const index = getView().rows!.findIndex(r => r === this);\n let pObject = prop;\n if (typeof prop !== 'object') {\n pObject = { [prop]: value };\n }\n\n // Change object if any value changes actually.\n // @ts-expect-error utils should be converted to TS in order to resolve this.\n if (!compareObjects(this, pObject, Object.keys(pObject))) {\n const newRow = new Row(\n {\n ...this.#get(),\n ...(pObject as RowOptions)\n },\n this.#rsInternal\n );\n const cloned = [...getView().rows!];\n cloned.splice(index, 1, newRow);\n getView().rows = cloned;\n }\n }\n\n /** This fetches the latest data of the row using\n * {@link rsProps.apiContext.fetchRowData fetchRowData} and updates the same in the {@link View} and {@link Row}\n * @returns void\n */\n async updateRow(): Promise<void> {\n const { getView, getRsProps, getRsStateResolver, getRsStore } = this.#rsInternal;\n const rsProps = getRsProps();\n const { dispatch } = getRsStateResolver();\n const state = getRsStateResolver().getState();\n // TODO: Check if fetchRowData api is really needed? In case of grouped tables updating single row may cause issues. It is better to refresh whole view.\n const [rowData] =\n (await rsProps.apiContext.fetchRowData?.(\n deepCopy(state),\n getView().meta,\n getView().meta.itemKey,\n this[dataKey],\n this.data,\n {\n ...(getRsStore().refreshInProgress && {\n invalidateCache: true,\n invalidateCacheToken: getRsStore().refreshToken\n })\n }\n )) || [];\n const dataIndex = getView().data!.findIndex(\n row => row[getView().meta.itemKey] === rowData[getView().meta.itemKey]\n );\n const rowIndex = getView().rows!.findIndex(row => row.key === rowData[getView().meta.itemKey]);\n if (dataIndex > -1) {\n getView().setProp({\n data: [\n ...getView().data!.slice(0, dataIndex),\n rowData,\n ...getView().data!.slice(dataIndex + 1)\n ],\n rows: [\n ...getView().rows!.slice(0, rowIndex),\n new Row(\n {\n key: rowData[getView().meta.itemKey] as string,\n rowData\n },\n this.#rsInternal\n ),\n ...getView().rows!.slice(rowIndex + 1)\n ]\n });\n dispatch(actionForceUpdate());\n }\n }\n\n /**\n * Used to select/deselect a {@link Row}.\n * @param selected Flag to indicate the row is selected or not.\n */\n selectRow(selected = true): void {\n const { getRsStateResolver } = this.#rsInternal;\n const { dispatch } = getRsStateResolver();\n this.parent.setSingleSelectionRowKey(this.uniqueId ?? (this.key as string));\n\n dispatch(\n actionRowSelectionUpdate({\n key: this.key as string,\n selected,\n data: this.data,\n status: STATE.NOT_STARTED,\n mode: this.parent.meta.selectionMode\n })\n );\n }\n\n /**\n * Returns the ui props for the {@link Row} that can be used to build a row in DOM.\n *\n */\n getUIProps(): UIProps {\n const { getView } = this.#rsInternal;\n return {\n className: this.className,\n 'data-error-message': this.getRowError()?.message,\n [dataKey]: this[dataKey],\n role: this.role,\n 'aria-rowindex':\n // eslint-disable-next-line no-unsafe-optional-chaining\n this.parent.state.paginationOptions?.rootVirtualiser?.startIndex! +\n this.parent.rows!.findIndex(r => r === this)! +\n 1,\n ...(!isRowReorderFieldEnabled(getView().meta) ? this.dragProps : {}),\n ...this.dropProps\n };\n }\n\n /**\n *\n * @returns the errors on the row.\n */\n getRowError(): DataError[string | number] | undefined {\n return this.parent.state.errors?.dataErrors?.[this.key as string | number];\n }\n\n /**\n * Returns the current row Header field and value.\n * This api is exposed to the consumers of Repeating structures to access the row header information of the current row.\n *\n * @public\n */\n getRowHeader(): RowHeader | undefined {\n let rowHeaderColumn: Column | undefined;\n const columns = this.parent.getContext().getColumns();\n for (const column of columns!) {\n if (column.field.isRowHeader) {\n rowHeaderColumn = column;\n break;\n }\n if (column.isFirstDataColumn) {\n rowHeaderColumn = column;\n }\n }\n if (!rowHeaderColumn) {\n return undefined;\n }\n return {\n field: rowHeaderColumn as Column,\n getValue: () => rowHeaderColumn!.getContext().getValue()\n };\n }\n\n /**\n * Returns the current row context.\n * This api can be exposed to the consumers of Repeating structures to access the basic info regarding Row.\n *\n * @public\n */\n getContext(): RowContext {\n const { getRsProps, getView } = this.#rsInternal;\n const rsProps = getRsProps();\n return {\n name: 'row',\n getValue: () => this.data,\n getParentContext: this.parent.getContext,\n getRowActionDetails: (rowContext: RowData) => {\n return (\n rsProps.apiContext.fetchRowActionDetails?.(\n rowContext[getView().meta.itemKey] as string,\n rowContext\n ) ?? Promise.resolve([])\n );\n },\n getDragProps: () => this.dragProps,\n selectRow: this.selectRow,\n refreshRow: this.updateRow,\n $selected: this.$selected,\n getRowError: this.getRowError,\n getRowHeader: this.getRowHeader\n };\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"RowGenerator.js","sourceRoot":"","sources":["../../../../src/core/generators/RowGenerator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAEjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAMhE,OAAO,EACL,OAAO,EAQR,MAAM,sBAAsB,CAAC;AAE9B,0EAA0E;AAC1E,MAAM,CAAC,OAAO,OAAO,GAAG;IACtB,sHAAsH;IAC/G,GAAG,CAAS;IACnB;;OAEG;IACH,IAAI,CAAS;IACb;;OAEG;IACH,QAAQ,CAAS;IACjB,+CAA+C;IACxC,SAAS,CAAa;IAC7B,+CAA+C;IACxC,SAAS,CAAa;IAC7B,oCAAoC;IACpC,OAAO,CAAU;IACjB,sIAAsI;IACtI,QAAQ,CAAiB;IACzB,6DAA6D;IAC7D,kBAAkB,CAAW;IAC7B,gDAAgD;IAChD,WAAW,CAAa;IACxB;;;;;;;;;;;OAWG;IACH,YACE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3C,OAAO,CACL,OAAO,CAAC,UAAU,CAAC,qBAAqB,EAAE,CACxC,UAAU,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,CAAW,EAC5C,UAAU,CACX,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CACzB,CAAC;YACJ,CAAC;YACD,YAAY,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,SAAS;YAClC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,UAAU,EAAE,IAAI,CAAC,SAAS;YAC1B,GAAG,CAAC,uBAAuB,CAAC,OAAO,EAAE,CAAC,IAAI;gBACxC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;gBACvC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;gBACzC,6BAA6B,EAAE,IAAI,CAAC,6BAA6B;gBACjE,oBAAoB,EAAE,IAAI,CAAC,oBAAoB;aAChD,CAAC;YACF,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { DataError } from 'pega-repeating-structures-core/lib/types/State.types';\n\nimport { STATE, SELECTION_MODES } from '../constants';\nimport { compareObjects, deepCopy, isRowReorderFieldEnabled } from '../utils/util';\nimport { actionForceUpdate, actionRowSelectionUpdate } from '../actions/actions';\nimport type RsInternal from '../RsInternal';\nimport { isMasterDetailSupported } from '../utils/masterDetail';\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type { Meta } from '../../../types/Meta.types';\n\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nimport type View from './ViewGenerator';\nimport {\n dataKey,\n type DragProps,\n type DropProps,\n type RowContext,\n type RowData,\n type RowHeader,\n type RowOptions,\n type UIProps\n} from './RowGenerator.types';\nimport type Column from './ColumnGenerator';\n/** A row model that represents row of a repeating structure component. */\nexport default class Row {\n /** A unique key to identify a row object. The value of this must be derived from one of the key of {@link rowData} */\n public key: string;\n /** Value for Html attribute 'role'.\n * @default 'row'\n */\n role: string;\n /** Value of Html attribute 'tabindex'.\n * @default 0\n */\n tabIndex: number;\n /** Properties related to dragging behavior. */\n public dragProps?: DragProps;\n /** Properties related to dropping behavior. */\n public dropProps?: DropProps;\n /** Represents the data of a row. */\n rowData: RowData;\n /** A unique key to identify a row object in case {@link key} is duplicate. This can be used in the dom to uniquely identify a row. */\n uniqueId?: string | null;\n /** Generic interaction marker used by template renderers. */\n masterDetailActive?: boolean;\n /** A reference to {@link RsInternal} object. */\n #rsInternal: RsInternal;\n /**\n * Creates an instance of Row object for a repeating structure.\n * @param args Constructor arguments\n * @param args.key A unique key to identify a row object.\n * @param args.role Value for Html attribute 'role'. Default is 'row'\n * @param args.tabIndex Value of Html attribute 'tabindex'. Default is 0.\n * @param args.dragProps Properties related to dragging behavior.\n * @param args.dropProps Properties related to dropping behavior.\n * @param args.rowData Represents the data of a row.\n * @param args.uniqueId A unique key to identify a row object in case {@link key} is duplicate.\n * @param rsInternal A reference to {@link RsInternal} object.\n */\n constructor(\n {\n key,\n role = 'row',\n tabIndex = 0,\n dragProps,\n dropProps,\n rowData,\n uniqueId,\n masterDetailActive\n }: RowOptions,\n rsInternal: RsInternal\n ) {\n this.key = key;\n this.role = role;\n this.tabIndex = tabIndex;\n this.dragProps = dragProps;\n this.dropProps = dropProps;\n this.rowData = rowData;\n this.uniqueId = uniqueId;\n this.masterDetailActive = masterDetailActive;\n this.#rsInternal = rsInternal;\n\n /** IMP: For generator methods use traditional function syntax\n * rather than arrow function for memory efficiency\n * and bind 'this' to the methods which requires 'this' context. */\n this.getUIProps = this.getUIProps.bind(this);\n this.getContext = this.getContext.bind(this);\n this.updateRow = this.updateRow.bind(this);\n this.selectRow = this.selectRow.bind(this);\n this.openMasterDetail = this.openMasterDetail.bind(this);\n this.closeMasterDetail = this.closeMasterDetail.bind(this);\n this.clearMasterDetailNestedTarget = this.clearMasterDetailNestedTarget.bind(this);\n this.navigateMasterDetail = this.navigateMasterDetail.bind(this);\n\n this.setProp = this.setProp.bind(this);\n this.getRowError = this.getRowError.bind(this);\n this.getRowHeader = this.getRowHeader.bind(this);\n }\n\n /** A reference to {@link View} object. */\n get parent() {\n return this.#rsInternal.getView();\n }\n\n /**\n * This is majorly used by {@link setprop} function to create a new row object from existing row object.\n * @returns the row instance properties.\n */\n #get(): RowOptions & { className: string } {\n return {\n key: this.key,\n role: this.role,\n tabIndex: this.tabIndex,\n className: this.className,\n dragProps: this.dragProps,\n dropProps: this.dropProps,\n rowData: this.rowData,\n uniqueId: this.uniqueId,\n masterDetailActive: this.masterDetailActive\n };\n }\n\n /**\n * This property serves to uniquely identify a row's DOM element within a DOM hierarchy.\n * It plays a vital role in modern JavaScript frameworks such as React, where optimizing DOM manipulation requires unique keys.\n * The value is derived from either {@link key} or {@link uniqueId} if {@link key} is duplicate.\n */\n get reactKey() {\n return this.uniqueId || this.key;\n }\n\n /** The data for the row. */\n get data() {\n return this.rowData;\n }\n\n /** Value of HTMl attribute data-key. The value is derived from\n * either the value of {@link Meta.itemKey itemkey} in {@link data} or {@link key} */\n get [dataKey](): string {\n const keyData = this.data?.[this.parent.meta.itemKey];\n if (keyData) return keyData as string;\n return this.key;\n }\n\n /** A set of CSS class names for Row element. */\n get className() {\n const baseRowClass = this.getRowError()?.message ? 'row row-error' : 'row';\n if (this.parent.meta.selectionMode === SELECTION_MODES.multi_on_hover)\n return this.$selected ? `${baseRowClass} selected-row` : `${baseRowClass} row-on-hover`;\n\n return baseRowClass;\n }\n\n /** A transient value to signifies if a row is selected or not if selection mode is on. */\n get $selected(): RowContext['$selected'] {\n const temporaryChangeSetValue = this.parent.state.rowSelectionChangeSet?.[this.key]?.selected;\n const committedValue = this.parent.state.selectedRows?.includes(this.key);\n if (\n (temporaryChangeSetValue ?? committedValue) &&\n this.parent.meta.selectionMode === SELECTION_MODES.single &&\n this.uniqueId\n ) {\n /**\n * temporaryChangeSetValue ?? committedValue - Is current row selected\n * this.parent.meta.selectionMode === SELECTION_MODES.single - Is single select mode\n * this.uniqueId - unique id is present only in case of duplicate rows\n */\n if (this.parent.getSingleSelectionRowKey()) {\n // This block is to avoid duplicate radio button selection on user selection\n return this.parent.getSingleSelectionRowKey() === this.uniqueId;\n }\n for (let i = 0; i < this.parent.rows!.length; i += 1) {\n // This block is to avoid duplicate radio button selection onload / remount\n const row = this.parent.rows![i];\n const rowTemporaryChangeSetValue =\n this.parent.state.rowSelectionChangeSet?.[row.key]?.selected;\n const rowCommittedValue =\n this.parent.state.selectedRows && this.parent.state.selectedRows?.includes(row.key);\n if (rowTemporaryChangeSetValue ?? rowCommittedValue) {\n // 'row' - first selected row in this.parent.rows\n return this.uniqueId === row.uniqueId; // If 'row' is same as current object return true otherwise return false\n }\n }\n }\n return temporaryChangeSetValue ?? committedValue;\n }\n\n /**\n * This is used to create immutable objects of {@link Row} instance. Always call setProp if updating any properties of Row to make it immutable.\n * @param prop Either partial of row object or individual properties of row object.\n * @param value An optional parameter to provide value for {@link prop} in case prop is not of type {@link Row}\n */\n setProp(\n prop: Partial<RowOptions> | keyof RowOptions,\n value?: string | number | Date | boolean | DragProps | DropProps\n ) {\n const { getView } = this.#rsInternal;\n const index = getView().rows!.findIndex(r => r === this);\n let pObject = prop;\n if (typeof prop !== 'object') {\n pObject = { [prop]: value };\n }\n\n // Change object if any value changes actually.\n // @ts-expect-error utils should be converted to TS in order to resolve this.\n if (!compareObjects(this, pObject, Object.keys(pObject))) {\n const newRow = new Row(\n {\n ...this.#get(),\n ...(pObject as RowOptions)\n },\n this.#rsInternal\n );\n const cloned = [...getView().rows!];\n cloned.splice(index, 1, newRow);\n getView().rows = cloned;\n }\n }\n\n /** This fetches the latest data of the row using\n * {@link rsProps.apiContext.fetchRowData fetchRowData} and updates the same in the {@link View} and {@link Row}\n * @returns void\n */\n async updateRow(): Promise<void> {\n const { getView, getRsProps, getRsStateResolver, getRsStore } = this.#rsInternal;\n const rsProps = getRsProps();\n const { dispatch } = getRsStateResolver();\n const state = getRsStateResolver().getState();\n // TODO: Check if fetchRowData api is really needed? In case of grouped tables updating single row may cause issues. It is better to refresh whole view.\n const [rowData] =\n (await rsProps.apiContext.fetchRowData?.(\n deepCopy(state),\n getView().meta,\n getView().meta.itemKey,\n this[dataKey],\n this.data,\n {\n ...(getRsStore().refreshInProgress && {\n invalidateCache: true,\n invalidateCacheToken: getRsStore().refreshToken\n })\n }\n )) || [];\n const dataIndex = getView().data!.findIndex(\n row => row[getView().meta.itemKey] === rowData[getView().meta.itemKey]\n );\n const rowIndex = getView().rows!.findIndex(row => row.key === rowData[getView().meta.itemKey]);\n if (dataIndex > -1) {\n getView().setProp({\n data: [\n ...getView().data!.slice(0, dataIndex),\n rowData,\n ...getView().data!.slice(dataIndex + 1)\n ],\n rows: [\n ...getView().rows!.slice(0, rowIndex),\n new Row(\n {\n key: rowData[getView().meta.itemKey] as string,\n rowData\n },\n this.#rsInternal\n ),\n ...getView().rows!.slice(rowIndex + 1)\n ]\n });\n // Refresh the active detail as it may be stale even when the refreshed table row data is unchanged.\n getView().type.refreshMasterDetail([this.key]);\n dispatch(actionForceUpdate());\n }\n }\n\n /**\n * Used to select/deselect a {@link Row}.\n * @param selected Flag to indicate the row is selected or not.\n */\n selectRow(selected = true): void {\n const { getRsStateResolver } = this.#rsInternal;\n const { dispatch } = getRsStateResolver();\n this.parent.setSingleSelectionRowKey(this.uniqueId ?? (this.key as string));\n\n dispatch(\n actionRowSelectionUpdate({\n key: this.key as string,\n selected,\n data: this.data,\n status: STATE.NOT_STARTED,\n mode: this.parent.meta.selectionMode\n })\n );\n }\n\n /** Opens Master Detail for this row. */\n openMasterDetail(nestedTarget?: Record<string, unknown>, viewName?: string): void {\n this.parent.type.openMasterDetail(this.key, nestedTarget, viewName);\n }\n\n /** Closes the active Master Detail item. */\n closeMasterDetail(): void {\n this.parent.type.closeMasterDetail();\n }\n\n /** Clears the nested target set on this row's active Master Detail selection, without closing it. */\n clearMasterDetailNestedTarget(): void {\n this.parent.type.clearMasterDetailNestedTarget(this.key);\n }\n\n /** Navigates from the active Master Detail item. */\n navigateMasterDetail(direction: 'previous' | 'next'): void {\n this.parent.type.navigateMasterDetail(direction);\n }\n\n /**\n * Returns the ui props for the {@link Row} that can be used to build a row in DOM.\n *\n */\n getUIProps(): UIProps {\n const { getView } = this.#rsInternal;\n return {\n className: this.className,\n 'data-error-message': this.getRowError()?.message,\n [dataKey]: this[dataKey],\n role: this.role,\n 'aria-rowindex':\n // eslint-disable-next-line no-unsafe-optional-chaining\n this.parent.state.paginationOptions?.rootVirtualiser?.startIndex! +\n this.parent.rows!.findIndex(r => r === this)! +\n 1,\n ...(!isRowReorderFieldEnabled(getView().meta) ? this.dragProps : {}),\n ...this.dropProps\n };\n }\n\n /**\n *\n * @returns the errors on the row.\n */\n getRowError(): DataError[string | number] | undefined {\n return this.parent.state.errors?.dataErrors?.[this.key as string | number];\n }\n\n /**\n * Returns the current row Header field and value.\n * This api is exposed to the consumers of Repeating structures to access the row header information of the current row.\n *\n * @public\n */\n getRowHeader(): RowHeader | undefined {\n let rowHeaderColumn: Column | undefined;\n const columns = this.parent.getContext().getColumns();\n for (const column of columns!) {\n if (column.field.isRowHeader) {\n rowHeaderColumn = column;\n break;\n }\n if (column.isFirstDataColumn) {\n rowHeaderColumn = column;\n }\n }\n if (!rowHeaderColumn) {\n return undefined;\n }\n return {\n field: rowHeaderColumn as Column,\n getValue: () => rowHeaderColumn!.getContext().getValue()\n };\n }\n\n /**\n * Returns the current row context.\n * This api can be exposed to the consumers of Repeating structures to access the basic info regarding Row.\n *\n * @public\n */\n getContext(): RowContext {\n const { getRsProps, getView } = this.#rsInternal;\n const rsProps = getRsProps();\n return {\n name: 'row',\n getRowKey: () => this.key,\n getValue: () => this.data,\n getParentContext: this.parent.getContext,\n getRowActionDetails: (rowContext: RowData) => {\n return (\n rsProps.apiContext.fetchRowActionDetails?.(\n rowContext[getView().meta.itemKey] as string,\n rowContext\n ) ?? Promise.resolve([])\n );\n },\n getDragProps: () => this.dragProps,\n selectRow: this.selectRow,\n refreshRow: this.updateRow,\n ...(isMasterDetailSupported(getView()) && {\n openMasterDetail: this.openMasterDetail,\n closeMasterDetail: this.closeMasterDetail,\n clearMasterDetailNestedTarget: this.clearMasterDetailNestedTarget,\n navigateMasterDetail: this.navigateMasterDetail\n }),\n $selected: this.$selected,\n getRowError: this.getRowError,\n getRowHeader: this.getRowHeader\n };\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ApiContext } from '../../../types/ApiContext.types';
|
|
2
|
-
import type { DataError } from '../../../types/State.types';
|
|
2
|
+
import type { DataError, MasterDetailNavigationDirection } from '../../../types/State.types';
|
|
3
3
|
import type Column from './ColumnGenerator';
|
|
4
4
|
import type Row from './RowGenerator';
|
|
5
5
|
import type { ViewContext } from './ViewGenerator.types';
|
|
@@ -48,6 +48,8 @@ export interface DropProps {
|
|
|
48
48
|
export interface RowContext {
|
|
49
49
|
/** Name of the the context object - row */
|
|
50
50
|
name: string;
|
|
51
|
+
/** Returns the row key. */
|
|
52
|
+
getRowKey: () => string;
|
|
51
53
|
/** Returns the data of the entire row */
|
|
52
54
|
getValue: () => RowData;
|
|
53
55
|
/** Returns the context of the parent(view) */
|
|
@@ -66,6 +68,14 @@ export interface RowContext {
|
|
|
66
68
|
* @returns void
|
|
67
69
|
*/
|
|
68
70
|
refreshRow: () => Promise<void>;
|
|
71
|
+
/** Opens Master Detail for this row. Omitted from the execution context when Master Detail is disabled for the view. */
|
|
72
|
+
openMasterDetail?: (nestedTarget?: Record<string, unknown>, viewName?: string) => void;
|
|
73
|
+
/** Closes the active Master Detail item when Master Detail is enabled for the view. */
|
|
74
|
+
closeMasterDetail?: () => void;
|
|
75
|
+
/** Clears the nested target set on this row's active Master Detail selection without closing it. */
|
|
76
|
+
clearMasterDetailNestedTarget?: () => void;
|
|
77
|
+
/** Navigates from the active Master Detail item when Master Detail is enabled for the view. */
|
|
78
|
+
navigateMasterDetail?: (direction: MasterDetailNavigationDirection) => void;
|
|
69
79
|
/** Boolean denoting if a row is selected */
|
|
70
80
|
$selected?: boolean;
|
|
71
81
|
/**
|
|
@@ -87,6 +97,8 @@ export type RowOptions = {
|
|
|
87
97
|
dropProps?: DropProps;
|
|
88
98
|
rowData: RowData;
|
|
89
99
|
uniqueId?: string | null;
|
|
100
|
+
/** Generic interaction marker used by template renderers. */
|
|
101
|
+
masterDetailActive?: boolean;
|
|
90
102
|
};
|
|
91
103
|
export interface RowHeader {
|
|
92
104
|
field: Column;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RowGenerator.types.d.ts","sourceRoot":"","sources":["../../../../src/core/generators/RowGenerator.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"RowGenerator.types.d.ts","sourceRoot":"","sources":["../../../../src/core/generators/RowGenerator.types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAE7F,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAC7D,qDAAqD;AACrD,MAAM,WAAW,OAAO;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,aAAa,GAAG,OAAO,GAAG,OAAO,EAAE,CAAC;CAC3D;AAED,4BAA4B;AAC5B,MAAM,WAAW,OAAO;IACtB,4BAA4B;IAC5B,SAAS,EAAE,M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AC,MAAM,OAAO,CAAC,GAAG,SAAS,CAAC;CACpD;AAED,eAAO,MAAM,OAAO,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RowGenerator.types.js","sourceRoot":"","sources":["../../../../src/core/generators/RowGenerator.types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RowGenerator.types.js","sourceRoot":"","sources":["../../../../src/core/generators/RowGenerator.types.ts"],"names":[],"mappings":"AAqIA,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAAC","sourcesContent":["import type { ApiContext } from '../../../types/ApiContext.types';\nimport type { DataError, MasterDetailNavigationDirection } from '../../../types/State.types';\n\nimport type Column from './ColumnGenerator';\nimport type Row from './RowGenerator';\nimport type { ViewContext } from './ViewGenerator.types';\n\nexport type ScalarRowData = string | number | boolean | Date;\n/** Interface for expressing data present in a row */\nexport interface RowData {\n [key: string]: null | ScalarRowData | RowData | RowData[];\n}\n\n/** UI Props set on a row */\nexport interface UIProps {\n /** Class name of the row */\n className: string;\n /** Role to be set on row for A11y purpose */\n role: string;\n\n /** aria-rowindex attribute is set on row and is used by screen readers */\n 'aria-rowindex': number;\n\n /** On click handler exposed */\n onClick?: (data: Row) => void;\n\n /** Drag props exposed on row for drag and drop operation */\n dragProps?: DragProps;\n\n /** Drop props exposed on row for drag and drop operation */\n dropProps?: DropProps;\n /** The error message for a row. */\n 'data-error-message'?: string;\n /** A key to uniquely identify a row. */\n 'data-key': string;\n}\n\nexport interface DragProps {\n /** Boolean denoting if a row is draggable */\n draggable: boolean;\n\n /** Event handler attached on the row for drag start event */\n onDragStart: (e: DragEvent) => void;\n\n /** Event handler attached on the row for drag end event */\n onDragEnd: (e: DragEvent) => void;\n}\n\n/** Drop props exposed on row for drag and drop operation */\nexport interface DropProps {\n /** Event handler attached on the row for drag enter event */\n onDragEnter: (e: DragEvent) => void;\n\n /** Event handler attached on the row for drag leave event */\n onDragLeave: (e: DragEvent) => void;\n\n /** Selector exposed for dropping a row */\n 'data-drop': string;\n}\n/** Context object exposed on the row */\nexport interface RowContext {\n /** Name of the the context object - row */\n name: string;\n\n /** Returns the row key. */\n getRowKey: () => string;\n\n /** Returns the data of the entire row */\n getValue: () => RowData;\n\n /** Returns the context of the parent(view) */\n getParentContext: () => ViewContext;\n\n /** Calls fetchRowActionDetails function of the API context and returns the row actions */\n getRowActionDetails: (\n rowContext: RowData\n ) => ReturnType<Required<ApiContext>['fetchRowActionDetails']>;\n\n /** Returns the drag props set on a row */\n getDragProps: () => DragProps | undefined;\n\n /**\n * Used to select/deselect a {@link Row}.\n * @param selected Flag to indicate the row is selected or not.\n */\n selectRow: (selected: boolean) => void;\n\n /** This fetches the latest data of the row using\n * {@link ApiContext.fetchRowData fetchRowData} and updates the same in the {@link View} and {@link Row}\n * @returns void\n */\n refreshRow: () => Promise<void>;\n\n /** Opens Master Detail for this row. Omitted from the execution context when Master Detail is disabled for the view. */\n openMasterDetail?: (nestedTarget?: Record<string, unknown>, viewName?: string) => void;\n /** Closes the active Master Detail item when Master Detail is enabled for the view. */\n closeMasterDetail?: () => void;\n /** Clears the nested target set on this row's active Master Detail selection without closing it. */\n clearMasterDetailNestedTarget?: () => void;\n /** Navigates from the active Master Detail item when Master Detail is enabled for the view. */\n navigateMasterDetail?: (direction: MasterDetailNavigationDirection) => void;\n\n /** Boolean denoting if a row is selected */\n $selected?: boolean;\n /**\n *\n * @returns the errors on the row.\n */\n getRowError: () => DataError[string | number] | undefined;\n /**\n *\n * @returns the current row Header field and value.\n */\n getRowHeader: () => RowHeader | undefined;\n}\n\nexport type RowOptions = {\n key: string;\n role?: string;\n tabIndex?: number;\n dragProps?: DragProps;\n dropProps?: DropProps;\n rowData: RowData;\n uniqueId?: string | null;\n /** Generic interaction marker used by template renderers. */\n masterDetailActive?: boolean;\n};\n\nexport interface RowHeader {\n field: Column;\n getValue: () => RowData[keyof RowData] | undefined;\n}\n\nexport const dataKey = 'data-key';\n"]}
|