@elliemae/ds-left-navigation 3.80.0-next.58 → 3.80.0-next.60

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.
Files changed (51) hide show
  1. package/dist/cjs/exported-related/conversion-utils/conversionConstants.js +64 -0
  2. package/dist/cjs/exported-related/conversion-utils/conversionConstants.js.map +7 -0
  3. package/dist/cjs/exported-related/conversion-utils/conversionHelpers.js +192 -0
  4. package/dist/cjs/exported-related/conversion-utils/conversionHelpers.js.map +7 -0
  5. package/dist/cjs/exported-related/conversion-utils/convertItemOpts.js +187 -0
  6. package/dist/cjs/exported-related/conversion-utils/convertItemOpts.js.map +7 -0
  7. package/dist/cjs/exported-related/conversion-utils/getHumanReadableWarnings.js +37 -0
  8. package/dist/cjs/exported-related/conversion-utils/getHumanReadableWarnings.js.map +7 -0
  9. package/dist/cjs/exported-related/conversion-utils/index.js +95 -0
  10. package/dist/cjs/exported-related/conversion-utils/index.js.map +7 -0
  11. package/dist/cjs/exported-related/conversion-utils/lostCodes.js +55 -0
  12. package/dist/cjs/exported-related/conversion-utils/lostCodes.js.map +7 -0
  13. package/dist/cjs/exported-related/conversion-utils/report.js +48 -0
  14. package/dist/cjs/exported-related/conversion-utils/report.js.map +7 -0
  15. package/dist/cjs/exported-related/conversion-utils/types.js +28 -0
  16. package/dist/cjs/exported-related/conversion-utils/types.js.map +7 -0
  17. package/dist/cjs/exported-related/conversion-utils/validateIds.js +58 -0
  18. package/dist/cjs/exported-related/conversion-utils/validateIds.js.map +7 -0
  19. package/dist/cjs/index.js +2 -0
  20. package/dist/cjs/index.js.map +2 -2
  21. package/dist/esm/exported-related/conversion-utils/conversionConstants.js +34 -0
  22. package/dist/esm/exported-related/conversion-utils/conversionConstants.js.map +7 -0
  23. package/dist/esm/exported-related/conversion-utils/conversionHelpers.js +172 -0
  24. package/dist/esm/exported-related/conversion-utils/conversionHelpers.js.map +7 -0
  25. package/dist/esm/exported-related/conversion-utils/convertItemOpts.js +157 -0
  26. package/dist/esm/exported-related/conversion-utils/convertItemOpts.js.map +7 -0
  27. package/dist/esm/exported-related/conversion-utils/getHumanReadableWarnings.js +7 -0
  28. package/dist/esm/exported-related/conversion-utils/getHumanReadableWarnings.js.map +7 -0
  29. package/dist/esm/exported-related/conversion-utils/index.js +65 -0
  30. package/dist/esm/exported-related/conversion-utils/index.js.map +7 -0
  31. package/dist/esm/exported-related/conversion-utils/lostCodes.js +25 -0
  32. package/dist/esm/exported-related/conversion-utils/lostCodes.js.map +7 -0
  33. package/dist/esm/exported-related/conversion-utils/report.js +18 -0
  34. package/dist/esm/exported-related/conversion-utils/report.js.map +7 -0
  35. package/dist/esm/exported-related/conversion-utils/types.js +2 -0
  36. package/dist/esm/exported-related/conversion-utils/types.js.map +7 -0
  37. package/dist/esm/exported-related/conversion-utils/validateIds.js +28 -0
  38. package/dist/esm/exported-related/conversion-utils/validateIds.js.map +7 -0
  39. package/dist/esm/index.js +2 -0
  40. package/dist/esm/index.js.map +2 -2
  41. package/dist/types/exported-related/conversion-utils/conversionConstants.d.ts +20 -0
  42. package/dist/types/exported-related/conversion-utils/conversionHelpers.d.ts +25 -0
  43. package/dist/types/exported-related/conversion-utils/convertItemOpts.d.ts +22 -0
  44. package/dist/types/exported-related/conversion-utils/getHumanReadableWarnings.d.ts +7 -0
  45. package/dist/types/exported-related/conversion-utils/index.d.ts +12 -0
  46. package/dist/types/exported-related/conversion-utils/lostCodes.d.ts +23 -0
  47. package/dist/types/exported-related/conversion-utils/report.d.ts +3 -0
  48. package/dist/types/exported-related/conversion-utils/types.d.ts +37 -0
  49. package/dist/types/exported-related/conversion-utils/validateIds.d.ts +9 -0
  50. package/dist/types/index.d.ts +2 -0
  51. package/package.json +13 -12
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var conversion_utils_exports = {};
30
+ __export(conversion_utils_exports, {
31
+ checkAndConvertItems: () => checkAndConvertItems
32
+ });
33
+ module.exports = __toCommonJS(conversion_utils_exports);
34
+ var React = __toESM(require("react"));
35
+ var import_conversionConstants = require("./conversionConstants.js");
36
+ var import_conversionHelpers = require("./conversionHelpers.js");
37
+ var import_validateIds = require("./validateIds.js");
38
+ var import_getHumanReadableWarnings = require("./getHumanReadableWarnings.js");
39
+ var import_report = require("./report.js");
40
+ const reportIgnoredHeaderContent = (dsId, childrenByParentId, report) => {
41
+ if (!dsId || !(0, import_conversionConstants.getOwn)(childrenByParentId, dsId)) return;
42
+ (0, import_report.markLost)(report, {
43
+ code: "header-content-dropped",
44
+ dsId,
45
+ message: "The header is the first leaf, so its list in childrenByParentId was ignored"
46
+ });
47
+ };
48
+ const convertHeaderPart = (args) => {
49
+ const { HeaderComponent, headerAsFirstLeaf, convertedItems, report, childrenByParentId } = args;
50
+ const result = {};
51
+ const header = HeaderComponent ? (0, import_conversionHelpers.convertHeader)(HeaderComponent, report) : null;
52
+ if (!HeaderComponent || !header) return result;
53
+ if (headerAsFirstLeaf) {
54
+ convertedItems.unshift(header);
55
+ reportIgnoredHeaderContent(HeaderComponent.dsId, childrenByParentId, report);
56
+ return result;
57
+ }
58
+ const headerContent = HeaderComponent.dsId ? (0, import_conversionConstants.getOwn)(childrenByParentId, HeaderComponent.dsId) : void 0;
59
+ if (!headerContent) {
60
+ (0, import_report.markLost)(report, {
61
+ code: "header-without-content",
62
+ dsId: HeaderComponent.dsId ?? "",
63
+ message: "No entry in childrenByParentId for the header, it is a disclosure with nothing to open"
64
+ });
65
+ }
66
+ return {
67
+ convertedHeader: header,
68
+ convertedHeaderItems: headerContent ? (0, import_conversionHelpers.convertList)({ list: headerContent, isRoot: true, report, childrenByParentId }) : []
69
+ };
70
+ };
71
+ const checkAndConvertItems = (items, options = {}) => {
72
+ const { childrenByParentId = {}, HeaderComponent, BodyHeaderComponent, headerAsFirstLeaf = false } = options;
73
+ const report = (0, import_report.createEmptyReport)();
74
+ const convertedItems = (0, import_conversionHelpers.convertList)({ list: items, isRoot: true, report, childrenByParentId });
75
+ const { convertedHeader, convertedHeaderItems } = convertHeaderPart({
76
+ HeaderComponent,
77
+ headerAsFirstLeaf,
78
+ convertedItems,
79
+ report,
80
+ childrenByParentId
81
+ });
82
+ (0, import_validateIds.reportIdProblems)(convertedItems, report, convertedHeader ? [convertedHeader.dsId] : []);
83
+ if (convertedHeaderItems)
84
+ (0, import_validateIds.reportIdProblems)(convertedHeaderItems, report, convertedHeader?.dsId ? [convertedHeader.dsId] : []);
85
+ if (BodyHeaderComponent) {
86
+ (0, import_report.markLost)(report, {
87
+ code: "body-header-dropped",
88
+ dsId: BodyHeaderComponent.dsId ?? "",
89
+ message: "BodyHeaderComponent is not supported, the submenu is the parent of its children"
90
+ });
91
+ }
92
+ report.humanReadableWarnings = (0, import_getHumanReadableWarnings.getHumanReadableWarnings)(report);
93
+ return { convertedItems, convertedHeader, convertedHeaderItems, report };
94
+ };
95
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/exported-related/conversion-utils/index.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import { getOwn } from './conversionConstants.js';\nimport { convertHeader, convertList } from './conversionHelpers.js';\nimport { reportIdProblems } from './validateIds.js';\nimport { getHumanReadableWarnings } from './getHumanReadableWarnings.js';\nimport { createEmptyReport, markLost } from './report.js';\nimport type { DSLeftNavBridgeT } from './types.js';\nimport type { DSLeftNavigationT } from '../../react-desc-prop-types.js';\n\ntype ConvertHeaderPartArgsT = {\n HeaderComponent?: DSLeftNavBridgeT.OptionsT['HeaderComponent'];\n headerAsFirstLeaf: boolean;\n convertedItems: DSLeftNavBridgeT.ResultT['convertedItems'];\n report: DSLeftNavBridgeT.ReportMutableT;\n childrenByParentId: DSLeftNavBridgeT.ChildrenByParentIdT;\n};\n\nconst reportIgnoredHeaderContent = (\n dsId: string | undefined,\n childrenByParentId: DSLeftNavBridgeT.ChildrenByParentIdT,\n report: DSLeftNavBridgeT.ReportMutableT,\n) => {\n if (!dsId || !getOwn(childrenByParentId, dsId)) return;\n markLost(report, {\n code: 'header-content-dropped',\n dsId,\n message: 'The header is the first leaf, so its list in childrenByParentId was ignored',\n });\n};\n\nconst convertHeaderPart = (args: ConvertHeaderPartArgsT) => {\n const { HeaderComponent, headerAsFirstLeaf, convertedItems, report, childrenByParentId } = args;\n const result: Pick<DSLeftNavBridgeT.ResultT, 'convertedHeader' | 'convertedHeaderItems'> = {};\n const header = HeaderComponent ? convertHeader(HeaderComponent, report) : null;\n if (!HeaderComponent || !header) return result;\n if (headerAsFirstLeaf) {\n convertedItems.unshift(header);\n reportIgnoredHeaderContent(HeaderComponent.dsId, childrenByParentId, report);\n return result;\n }\n const headerContent = HeaderComponent.dsId ? getOwn(childrenByParentId, HeaderComponent.dsId) : undefined;\n if (!headerContent) {\n markLost(report, {\n code: 'header-without-content',\n dsId: HeaderComponent.dsId ?? '',\n message: 'No entry in childrenByParentId for the header, it is a disclosure with nothing to open',\n });\n }\n return {\n convertedHeader: header,\n convertedHeaderItems: headerContent\n ? convertList({ list: headerContent, isRoot: true, report, childrenByParentId })\n : [],\n };\n};\n\n/**\n * Converts LeftNavigation items to DSLeftNavigationTree items and reports what the tree cannot carry over.\n * It is a migration aid, not a drop-in replacement: read `report.humanReadableWarnings` and `report.lostEntries`.\n * @param items - The LeftNavigation items (the flat list shown by the body).\n * @param options - Children of the submenus (`childrenByParentId`), and the `HeaderComponent` and `BodyHeaderComponent` props.\n * @returns The converted items and the report. `HeaderComponent` becomes `convertedHeader`, a disclosure, and\n * `convertedHeaderItems` is its content (the list under the header `dsId` in `childrenByParentId`) to pass as `items`\n * while it is open. A header that is only a link goes to the front of `convertedItems` with `headerAsFirstLeaf`.\n */\nexport const checkAndConvertItems = (\n items: readonly DSLeftNavigationT.GenericItemItemProps[],\n options: DSLeftNavBridgeT.OptionsT = {},\n): DSLeftNavBridgeT.ResultT => {\n const { childrenByParentId = {}, HeaderComponent, BodyHeaderComponent, headerAsFirstLeaf = false } = options;\n const report = createEmptyReport();\n const convertedItems = convertList({ list: items, isRoot: true, report, childrenByParentId });\n const { convertedHeader, convertedHeaderItems } = convertHeaderPart({\n HeaderComponent,\n headerAsFirstLeaf,\n convertedItems,\n report,\n childrenByParentId,\n });\n /** The header and each list the consumer passes as `items` are one hierarchy for the tree, so each is validated with the header. */\n reportIdProblems(convertedItems, report, convertedHeader ? [convertedHeader.dsId] : []);\n if (convertedHeaderItems)\n reportIdProblems(convertedHeaderItems, report, convertedHeader?.dsId ? [convertedHeader.dsId] : []);\n if (BodyHeaderComponent) {\n markLost(report, {\n code: 'body-header-dropped',\n dsId: BodyHeaderComponent.dsId ?? '',\n message: 'BodyHeaderComponent is not supported, the submenu is the parent of its children',\n });\n }\n report.humanReadableWarnings = getHumanReadableWarnings(report);\n return { convertedItems, convertedHeader, convertedHeaderItems, report };\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,iCAAuB;AACvB,+BAA2C;AAC3C,yBAAiC;AACjC,sCAAyC;AACzC,oBAA4C;AAY5C,MAAM,6BAA6B,CACjC,MACA,oBACA,WACG;AACH,MAAI,CAAC,QAAQ,KAAC,mCAAO,oBAAoB,IAAI,EAAG;AAChD,8BAAS,QAAQ;AAAA,IACf,MAAM;AAAA,IACN;AAAA,IACA,SAAS;AAAA,EACX,CAAC;AACH;AAEA,MAAM,oBAAoB,CAAC,SAAiC;AAC1D,QAAM,EAAE,iBAAiB,mBAAmB,gBAAgB,QAAQ,mBAAmB,IAAI;AAC3F,QAAM,SAAqF,CAAC;AAC5F,QAAM,SAAS,sBAAkB,wCAAc,iBAAiB,MAAM,IAAI;AAC1E,MAAI,CAAC,mBAAmB,CAAC,OAAQ,QAAO;AACxC,MAAI,mBAAmB;AACrB,mBAAe,QAAQ,MAAM;AAC7B,+BAA2B,gBAAgB,MAAM,oBAAoB,MAAM;AAC3E,WAAO;AAAA,EACT;AACA,QAAM,gBAAgB,gBAAgB,WAAO,mCAAO,oBAAoB,gBAAgB,IAAI,IAAI;AAChG,MAAI,CAAC,eAAe;AAClB,gCAAS,QAAQ;AAAA,MACf,MAAM;AAAA,MACN,MAAM,gBAAgB,QAAQ;AAAA,MAC9B,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACA,SAAO;AAAA,IACL,iBAAiB;AAAA,IACjB,sBAAsB,oBAClB,sCAAY,EAAE,MAAM,eAAe,QAAQ,MAAM,QAAQ,mBAAmB,CAAC,IAC7E,CAAC;AAAA,EACP;AACF;AAWO,MAAM,uBAAuB,CAClC,OACA,UAAqC,CAAC,MACT;AAC7B,QAAM,EAAE,qBAAqB,CAAC,GAAG,iBAAiB,qBAAqB,oBAAoB,MAAM,IAAI;AACrG,QAAM,aAAS,iCAAkB;AACjC,QAAM,qBAAiB,sCAAY,EAAE,MAAM,OAAO,QAAQ,MAAM,QAAQ,mBAAmB,CAAC;AAC5F,QAAM,EAAE,iBAAiB,qBAAqB,IAAI,kBAAkB;AAAA,IAClE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,CAAC;AAED,2CAAiB,gBAAgB,QAAQ,kBAAkB,CAAC,gBAAgB,IAAI,IAAI,CAAC,CAAC;AACtF,MAAI;AACF,6CAAiB,sBAAsB,QAAQ,iBAAiB,OAAO,CAAC,gBAAgB,IAAI,IAAI,CAAC,CAAC;AACpG,MAAI,qBAAqB;AACvB,gCAAS,QAAQ;AAAA,MACf,MAAM;AAAA,MACN,MAAM,oBAAoB,QAAQ;AAAA,MAClC,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AACA,SAAO,4BAAwB,0DAAyB,MAAM;AAC9D,SAAO,EAAE,gBAAgB,iBAAiB,sBAAsB,OAAO;AACzE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var lostCodes_exports = {};
30
+ __export(lostCodes_exports, {
31
+ WARNING_PER_LOST_CODE: () => WARNING_PER_LOST_CODE
32
+ });
33
+ module.exports = __toCommonJS(lostCodes_exports);
34
+ var React = __toESM(require("react"));
35
+ const WARNING_PER_LOST_CODE = {
36
+ "submenu-without-children": `- Encountered submenu items without an entry in "childrenByParentId" - the tree needs the children in the data, the conversion created an empty parent`,
37
+ "custom-component-dropped": `- Encountered items with a custom "Component" - a treeitem cannot hold arbitrary interactive content (WCAG 4.1.2), the conversion dropped them`,
38
+ "skeleton-dropped": `- Encountered skeleton items - loading states are not part of the tree, the conversion dropped them`,
39
+ "header-item-dropped": `- Encountered an item of type header inside "items" - the tree has one header disclosure, passed as "HeaderComponent", the conversion dropped it from the list`,
40
+ "header-content-dropped": `- Encountered "headerAsFirstLeaf" together with a list for the header in "childrenByParentId" - a header that is the first item of the list has nothing to open, the conversion ignored that list. Drop "headerAsFirstLeaf" to keep the header as a disclosure with its content`,
41
+ "header-without-content": `- Encountered a "HeaderComponent" without an entry in "childrenByParentId" - the tree header is a disclosure with nothing to open. If the header is only a link, pass "headerAsFirstLeaf" to make it the first item of the list`,
42
+ "right-component-ctx": `- Encountered "RightComponent" on a leaf, drilldown or header, or a "labelRightSection" that is not text - the conversion kept it, but the tree only gives it "{ item }" and an empty "ctx", so it must not read "ctx". The "item" it receives is the converted tree item (another type, with only the options the tree keeps), so it must not read legacy fields either. The conversion does not inspect what it draws: remove buttons, menus or any other control inside it before rendering the converted data, a treeitem cannot hold them`,
43
+ "body-header-dropped": `- Encountered "BodyHeaderComponent" - the tree shows the opened submenu as the parent of its children, the conversion ignored it`,
44
+ "component-with-ctx-dropped": `- Encountered "LeftComponent" or "BottomComponent", or a "RightComponent" on a submenu or section - the tree has no place for them (parents draw their own arrow), the conversion dropped them`,
45
+ "collapsed-component-ctx": `- Encountered "CollapsedComponent" - the conversion kept it as is, but the tree only gives it "{ item }" with the converted tree item (another type, with only the options the tree keeps), so it must not read "ctx" or legacy fields of the item`,
46
+ "label-style-dropped": `- Encountered "labelBold" or "labelColor" - state conveyed only by weight or color fails WCAG 1.3.1 and 1.4.1, the conversion dropped them`,
47
+ "label-truncate-to-wrap": `- Encountered "labelOverflow: truncate" - truncated labels need a hover tooltip (1.4.13) and hide text from users who zoom (1.4.10), the conversion uses "wrap"`,
48
+ "aria-overrides-dropped": `- Encountered "ariaLabel", "ariaRole", "ariaLive", "ariaExpanded" or "ariaDescribedBy" - the tree computes its own names and states, the conversion dropped them`,
49
+ "item-options-dropped": `- Encountered item options the tree does not have (selectable on a drilldown, focuseable, openable, closable, indent, skeletonVariant, labelDataTestId, any other key of itemOpts, or a non-text labelRightSection where it cannot be shown) - the conversion dropped them, see lostEntries for the list per item`,
50
+ "section-in-nested-list-dropped": `- Encountered a section or separator inside a submenu or drilldown - the tree supports them only at the root level, the conversion dropped them`,
51
+ "missing-id": `- Encountered items without a "dsId" - the tree finds every item by its "dsId", so each one needs its own; set it before using the converted items`,
52
+ "duplicate-id": `- Encountered the same "dsId" on more than one item of the converted hierarchy - the tree finds items by "dsId" across all levels, so a repeated one overwrites the other's label and parent; give each item a unique "dsId" (LeftNavigation only needed it unique inside the list that is shown)`,
53
+ "unknown-type-dropped": `- Encountered items with a type that is not out of the box, or a "HeaderComponent" that is not a header, link, text-label or with-date - the conversion dropped them`
54
+ };
55
+ //# sourceMappingURL=lostCodes.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/exported-related/conversion-utils/lostCodes.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["/**\n * Single source of truth for the codes of what the conversion cannot carry over: the type, the empty report and the warnings derive from it.\n */\nexport const WARNING_PER_LOST_CODE = {\n 'submenu-without-children': `- Encountered submenu items without an entry in \"childrenByParentId\" - the tree needs the children in the data, the conversion created an empty parent`,\n 'custom-component-dropped': `- Encountered items with a custom \"Component\" - a treeitem cannot hold arbitrary interactive content (WCAG 4.1.2), the conversion dropped them`,\n 'skeleton-dropped': `- Encountered skeleton items - loading states are not part of the tree, the conversion dropped them`,\n 'header-item-dropped': `- Encountered an item of type header inside \"items\" - the tree has one header disclosure, passed as \"HeaderComponent\", the conversion dropped it from the list`,\n 'header-content-dropped': `- Encountered \"headerAsFirstLeaf\" together with a list for the header in \"childrenByParentId\" - a header that is the first item of the list has nothing to open, the conversion ignored that list. Drop \"headerAsFirstLeaf\" to keep the header as a disclosure with its content`,\n 'header-without-content': `- Encountered a \"HeaderComponent\" without an entry in \"childrenByParentId\" - the tree header is a disclosure with nothing to open. If the header is only a link, pass \"headerAsFirstLeaf\" to make it the first item of the list`,\n 'right-component-ctx': `- Encountered \"RightComponent\" on a leaf, drilldown or header, or a \"labelRightSection\" that is not text - the conversion kept it, but the tree only gives it \"{ item }\" and an empty \"ctx\", so it must not read \"ctx\". The \"item\" it receives is the converted tree item (another type, with only the options the tree keeps), so it must not read legacy fields either. The conversion does not inspect what it draws: remove buttons, menus or any other control inside it before rendering the converted data, a treeitem cannot hold them`,\n 'body-header-dropped': `- Encountered \"BodyHeaderComponent\" - the tree shows the opened submenu as the parent of its children, the conversion ignored it`,\n 'component-with-ctx-dropped': `- Encountered \"LeftComponent\" or \"BottomComponent\", or a \"RightComponent\" on a submenu or section - the tree has no place for them (parents draw their own arrow), the conversion dropped them`,\n 'collapsed-component-ctx': `- Encountered \"CollapsedComponent\" - the conversion kept it as is, but the tree only gives it \"{ item }\" with the converted tree item (another type, with only the options the tree keeps), so it must not read \"ctx\" or legacy fields of the item`,\n 'label-style-dropped': `- Encountered \"labelBold\" or \"labelColor\" - state conveyed only by weight or color fails WCAG 1.3.1 and 1.4.1, the conversion dropped them`,\n 'label-truncate-to-wrap': `- Encountered \"labelOverflow: truncate\" - truncated labels need a hover tooltip (1.4.13) and hide text from users who zoom (1.4.10), the conversion uses \"wrap\"`,\n 'aria-overrides-dropped': `- Encountered \"ariaLabel\", \"ariaRole\", \"ariaLive\", \"ariaExpanded\" or \"ariaDescribedBy\" - the tree computes its own names and states, the conversion dropped them`,\n 'item-options-dropped': `- Encountered item options the tree does not have (selectable on a drilldown, focuseable, openable, closable, indent, skeletonVariant, labelDataTestId, any other key of itemOpts, or a non-text labelRightSection where it cannot be shown) - the conversion dropped them, see lostEntries for the list per item`,\n 'section-in-nested-list-dropped': `- Encountered a section or separator inside a submenu or drilldown - the tree supports them only at the root level, the conversion dropped them`,\n 'missing-id': `- Encountered items without a \"dsId\" - the tree finds every item by its \"dsId\", so each one needs its own; set it before using the converted items`,\n 'duplicate-id': `- Encountered the same \"dsId\" on more than one item of the converted hierarchy - the tree finds items by \"dsId\" across all levels, so a repeated one overwrites the other's label and parent; give each item a unique \"dsId\" (LeftNavigation only needed it unique inside the list that is shown)`,\n 'unknown-type-dropped': `- Encountered items with a type that is not out of the box, or a \"HeaderComponent\" that is not a header, link, text-label or with-date - the conversion dropped them`,\n} as const;\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADGhB,MAAM,wBAAwB;AAAA,EACnC,4BAA4B;AAAA,EAC5B,4BAA4B;AAAA,EAC5B,oBAAoB;AAAA,EACpB,uBAAuB;AAAA,EACvB,0BAA0B;AAAA,EAC1B,0BAA0B;AAAA,EAC1B,uBAAuB;AAAA,EACvB,uBAAuB;AAAA,EACvB,8BAA8B;AAAA,EAC9B,2BAA2B;AAAA,EAC3B,uBAAuB;AAAA,EACvB,0BAA0B;AAAA,EAC1B,0BAA0B;AAAA,EAC1B,wBAAwB;AAAA,EACxB,kCAAkC;AAAA,EAClC,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,wBAAwB;AAC1B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var report_exports = {};
30
+ __export(report_exports, {
31
+ createEmptyReport: () => createEmptyReport,
32
+ markLost: () => markLost
33
+ });
34
+ module.exports = __toCommonJS(report_exports);
35
+ var React = __toESM(require("react"));
36
+ var import_lostCodes = require("./lostCodes.js");
37
+ const createEmptyReport = () => ({
38
+ detectedLostsOnConversion: Object.fromEntries(
39
+ Object.keys(import_lostCodes.WARNING_PER_LOST_CODE).map((code) => [code, false])
40
+ ),
41
+ lostEntries: [],
42
+ humanReadableWarnings: []
43
+ });
44
+ const markLost = (report, entry) => {
45
+ report.detectedLostsOnConversion[entry.code] = true;
46
+ report.lostEntries.push(entry);
47
+ };
48
+ //# sourceMappingURL=report.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/exported-related/conversion-utils/report.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import { WARNING_PER_LOST_CODE } from './lostCodes.js';\nimport type { DSLeftNavBridgeT } from './types.js';\n\nexport const createEmptyReport = (): DSLeftNavBridgeT.ReportMutableT => ({\n detectedLostsOnConversion: Object.fromEntries(\n Object.keys(WARNING_PER_LOST_CODE).map((code) => [code, false]),\n ) as DSLeftNavBridgeT.ReportMutableT['detectedLostsOnConversion'],\n lostEntries: [],\n humanReadableWarnings: [],\n});\n\nexport const markLost = (report: DSLeftNavBridgeT.ReportMutableT, entry: DSLeftNavBridgeT.LostEntryT) => {\n // eslint-disable-next-line no-param-reassign\n report.detectedLostsOnConversion[entry.code] = true;\n report.lostEntries.push(entry);\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,uBAAsC;AAG/B,MAAM,oBAAoB,OAAwC;AAAA,EACvE,2BAA2B,OAAO;AAAA,IAChC,OAAO,KAAK,sCAAqB,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;AAAA,EAChE;AAAA,EACA,aAAa,CAAC;AAAA,EACd,uBAAuB,CAAC;AAC1B;AAEO,MAAM,WAAW,CAAC,QAAyC,UAAuC;AAEvG,SAAO,0BAA0B,MAAM,IAAI,IAAI;AAC/C,SAAO,YAAY,KAAK,KAAK;AAC/B;",
6
+ "names": []
7
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") {
10
+ for (let key of __getOwnPropNames(from))
11
+ if (!__hasOwnProp.call(to, key) && key !== except)
12
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
+ }
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
+ mod
23
+ ));
24
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
+ var types_exports = {};
26
+ module.exports = __toCommonJS(types_exports);
27
+ var React = __toESM(require("react"));
28
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/exported-related/conversion-utils/types.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import type { DSLeftNavigationTreeT } from '@elliemae/ds-left-navigation-tree';\nimport type { WARNING_PER_LOST_CODE } from './lostCodes.js';\nimport type { DSLeftNavigationT } from '../../react-desc-prop-types.js';\n\nexport declare namespace DSLeftNavBridgeT {\n /**\n * Each code is something LeftNavigation could do that the tree cannot carry over.\n */\n export type LostCodeT = keyof typeof WARNING_PER_LOST_CODE;\n\n export type LostEntryT = {\n code: LostCodeT;\n dsId: string;\n message: string;\n };\n\n export type ReportMutableT = {\n detectedLostsOnConversion: Record<LostCodeT, boolean>;\n lostEntries: LostEntryT[];\n humanReadableWarnings: string[];\n };\n\n /**\n * LeftNavigation keeps the hierarchy outside of the data: a submenu has no children in its item, the consumer swaps `items` when the submenu is opened.\n * This map gives the bridge the lists the consumer swaps in, keyed by the submenu dsId.\n */\n export type ChildrenByParentIdT = Record<string, readonly DSLeftNavigationT.GenericItemItemProps[]>;\n\n export type OptionsT = {\n childrenByParentId?: ChildrenByParentIdT;\n HeaderComponent?: DSLeftNavigationT.GenericItemItemProps;\n BodyHeaderComponent?: DSLeftNavigationT.GenericItemItemProps;\n /** The header is only a link, with nothing to open: it becomes the first item of the list instead of a disclosure. */\n headerAsFirstLeaf?: boolean;\n };\n\n export type ResultT = {\n convertedItems: DSLeftNavigationTreeT.Item[];\n convertedHeader?: DSLeftNavigationTreeT.Item;\n convertedHeaderItems?: DSLeftNavigationTreeT.Item[];\n report: ReportMutableT;\n };\n}\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;ACAA,YAAuB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var validateIds_exports = {};
30
+ __export(validateIds_exports, {
31
+ reportIdProblems: () => reportIdProblems
32
+ });
33
+ module.exports = __toCommonJS(validateIds_exports);
34
+ var React = __toESM(require("react"));
35
+ var import_report = require("./report.js");
36
+ const collectIds = (items, ids = []) => {
37
+ items.forEach((item) => {
38
+ ids.push(item.dsId);
39
+ collectIds(item.itemOpts?.items ?? [], ids);
40
+ });
41
+ return ids;
42
+ };
43
+ const reportIdProblems = (items, report, extraIds = []) => {
44
+ const seen = /* @__PURE__ */ new Set();
45
+ const reported = /* @__PURE__ */ new Set();
46
+ [...extraIds, ...collectIds(items)].forEach((dsId) => {
47
+ if (!dsId) {
48
+ (0, import_report.markLost)(report, { code: "missing-id", dsId: "", message: "An item has no dsId" });
49
+ return;
50
+ }
51
+ if (seen.has(dsId) && !reported.has(dsId)) {
52
+ reported.add(dsId);
53
+ (0, import_report.markLost)(report, { code: "duplicate-id", dsId, message: "The dsId is used by more than one item" });
54
+ }
55
+ seen.add(dsId);
56
+ });
57
+ };
58
+ //# sourceMappingURL=validateIds.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/exported-related/conversion-utils/validateIds.ts", "../../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import type { DSLeftNavigationTreeT } from '@elliemae/ds-left-navigation-tree';\nimport { markLost } from './report.js';\nimport type { DSLeftNavBridgeT } from './types.js';\n\ntype NewItemT = DSLeftNavigationTreeT.Item;\n\nconst collectIds = (items: readonly NewItemT[], ids: string[] = []): string[] => {\n items.forEach((item) => {\n ids.push(item.dsId);\n collectIds(item.itemOpts?.items ?? [], ids);\n });\n return ids;\n};\n\n/**\n * The tree finds items by `dsId` across every level of the list it receives, LeftNavigation only needed them unique inside each list it showed.\n * Reports the items without one and the ids that repeat, once per repeated id.\n */\nexport const reportIdProblems = (\n items: readonly NewItemT[],\n report: DSLeftNavBridgeT.ReportMutableT,\n extraIds: readonly string[] = [],\n) => {\n const seen = new Set<string>();\n const reported = new Set<string>();\n [...extraIds, ...collectIds(items)].forEach((dsId) => {\n if (!dsId) {\n markLost(report, { code: 'missing-id', dsId: '', message: 'An item has no dsId' });\n return;\n }\n if (seen.has(dsId) && !reported.has(dsId)) {\n reported.add(dsId);\n markLost(report, { code: 'duplicate-id', dsId, message: 'The dsId is used by more than one item' });\n }\n seen.add(dsId);\n });\n};\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADCvB,oBAAyB;AAKzB,MAAM,aAAa,CAAC,OAA4B,MAAgB,CAAC,MAAgB;AAC/E,QAAM,QAAQ,CAAC,SAAS;AACtB,QAAI,KAAK,KAAK,IAAI;AAClB,eAAW,KAAK,UAAU,SAAS,CAAC,GAAG,GAAG;AAAA,EAC5C,CAAC;AACD,SAAO;AACT;AAMO,MAAM,mBAAmB,CAC9B,OACA,QACA,WAA8B,CAAC,MAC5B;AACH,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,WAAW,oBAAI,IAAY;AACjC,GAAC,GAAG,UAAU,GAAG,WAAW,KAAK,CAAC,EAAE,QAAQ,CAAC,SAAS;AACpD,QAAI,CAAC,MAAM;AACT,kCAAS,QAAQ,EAAE,MAAM,cAAc,MAAM,IAAI,SAAS,sBAAsB,CAAC;AACjF;AAAA,IACF;AACA,QAAI,KAAK,IAAI,IAAI,KAAK,CAAC,SAAS,IAAI,IAAI,GAAG;AACzC,eAAS,IAAI,IAAI;AACjB,kCAAS,QAAQ,EAAE,MAAM,gBAAgB,MAAM,SAAS,yCAAyC,CAAC;AAAA,IACpG;AACA,SAAK,IAAI,IAAI;AAAA,EACf,CAAC;AACH;",
6
+ "names": []
7
+ }
package/dist/cjs/index.js CHANGED
@@ -50,12 +50,14 @@ __export(index_exports, {
50
50
  MAP_ITEMS_TO_SKELETON: () => import_constants.MAP_ITEMS_TO_SKELETON,
51
51
  Notifications: () => import_exported_related.Notifications,
52
52
  OpenWindow: () => import_exported_related.OpenWindow,
53
+ checkAndConvertItems: () => import_conversion_utils.checkAndConvertItems,
53
54
  default: () => index_default
54
55
  });
55
56
  module.exports = __toCommonJS(index_exports);
56
57
  var React = __toESM(require("react"));
57
58
  var import_LeftNavigation = require("./LeftNavigation.js");
58
59
  var import_constants = require("./constants/index.js");
60
+ var import_conversion_utils = require("./exported-related/conversion-utils/index.js");
59
61
  var import_exported_related = require("./exported-related/index.js");
60
62
  var import_LeftNavigation2 = require("./LeftNavigation.js");
61
63
  var import_react_desc_prop_types = require("./react-desc-prop-types.js");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.tsx", "../../../../../scripts/build/transpile/react-shim.js"],
4
- "sourcesContent": ["import { LeftNavigation } from './LeftNavigation.js';\n\nexport default LeftNavigation;\nexport {\n CHEVRON_BACK_DS_ID,\n DSLeftNavigationName,\n DSLeftNavigationSlots,\n FOOTER_DS_ID,\n FOOTER_MENU_CLOSE_DS_ID,\n ITEM_TYPES,\n LABEL_OVERFLOW,\n LEFT_NAVIGATION_DATA_TESTID,\n LEFT_NAVIGATION_REGION_FOCUSES,\n LEFT_NAVIGATION_SLOTS,\n MAP_ITEMS_TO_SKELETON,\n} from './constants/index.js';\nexport { ChevronItem, Icon, ItemRenderer, Notifications, OpenWindow } from './exported-related/index.js';\nexport { LeftNavigation, LeftNavigationWithSchema } from './LeftNavigation.js';\nexport {\n DSLeftNavigationItemPropTypesSchema,\n DSLeftNavigationPropTypesSchema,\n LeftNavItemOptionsSchema,\n LeftNavItemPropsSchema,\n type DSLeftNavigationT,\n} from './react-desc-prop-types.js';\n", "import * as React from 'react';\nexport { React };\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,4BAA+B;AAG/B,uBAYO;AACP,8BAA2E;AAC3E,IAAAA,yBAAyD;AACzD,mCAMO;AAtBP,IAAO,gBAAQ;",
4
+ "sourcesContent": ["import { LeftNavigation } from './LeftNavigation.js';\n\nexport default LeftNavigation;\nexport {\n CHEVRON_BACK_DS_ID,\n DSLeftNavigationName,\n DSLeftNavigationSlots,\n FOOTER_DS_ID,\n FOOTER_MENU_CLOSE_DS_ID,\n ITEM_TYPES,\n LABEL_OVERFLOW,\n LEFT_NAVIGATION_DATA_TESTID,\n LEFT_NAVIGATION_REGION_FOCUSES,\n LEFT_NAVIGATION_SLOTS,\n MAP_ITEMS_TO_SKELETON,\n} from './constants/index.js';\nexport { checkAndConvertItems } from './exported-related/conversion-utils/index.js';\nexport type { DSLeftNavBridgeT } from './exported-related/conversion-utils/types.js';\nexport { ChevronItem, Icon, ItemRenderer, Notifications, OpenWindow } from './exported-related/index.js';\nexport { LeftNavigation, LeftNavigationWithSchema } from './LeftNavigation.js';\nexport {\n DSLeftNavigationItemPropTypesSchema,\n DSLeftNavigationPropTypesSchema,\n LeftNavItemOptionsSchema,\n LeftNavItemPropsSchema,\n type DSLeftNavigationT,\n} from './react-desc-prop-types.js';\n", "import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ACAA,YAAuB;ADAvB,4BAA+B;AAG/B,uBAYO;AACP,8BAAqC;AAErC,8BAA2E;AAC3E,IAAAA,yBAAyD;AACzD,mCAMO;AAxBP,IAAO,gBAAQ;",
6
6
  "names": ["import_LeftNavigation"]
7
7
  }
@@ -0,0 +1,34 @@
1
+ import * as React from "react";
2
+ import { ITEM_TYPES } from "../../constants/index.js";
3
+ const DRILLDOWN_TYPES = [
4
+ ITEM_TYPES.LEFT_NAV_ITEM_CONTROLLED_DRILLDOWN,
5
+ ITEM_TYPES.LEFT_NAV_ITEM_UNCONTROLLED_DRILLDOWN
6
+ ];
7
+ const LEAF_TYPES = [
8
+ ITEM_TYPES.LEFT_NAV_ITEM_LINK,
9
+ ITEM_TYPES.LEFT_NAV_ITEM_TEXT_LABEL,
10
+ ITEM_TYPES.LEFT_NAV_ITEM_WITH_DATE
11
+ ];
12
+ const getOwn = (map, key) => Object.prototype.hasOwnProperty.call(map, key) ? map[key] : void 0;
13
+ const HEADER_TYPES = [ITEM_TYPES.LEFT_NAV_ITEM_HEADER, ...LEAF_TYPES];
14
+ const OUT_OF_THE_BOX_TYPES = Object.values(ITEM_TYPES);
15
+ const NO_RAIL_TYPES = [
16
+ ITEM_TYPES.LEFT_NAV_ITEM_TEXT_LABEL,
17
+ ITEM_TYPES.LEFT_NAV_ITEM_WITH_DATE,
18
+ ITEM_TYPES.LEFT_NAV_ITEM_CONTROLLED_DRILLDOWN,
19
+ ITEM_TYPES.LEFT_NAV_ITEM_UNCONTROLLED_DRILLDOWN
20
+ ];
21
+ const DROPPED_TYPE_CODES = {
22
+ [ITEM_TYPES.LEFT_NAV_ITEM_HEADER]: ["header-item-dropped", "Header items are not part of the list"],
23
+ [ITEM_TYPES.LEFT_NAV_ITEM_SKELETON]: ["skeleton-dropped", "Skeleton items are not supported"]
24
+ };
25
+ export {
26
+ DRILLDOWN_TYPES,
27
+ DROPPED_TYPE_CODES,
28
+ HEADER_TYPES,
29
+ LEAF_TYPES,
30
+ NO_RAIL_TYPES,
31
+ OUT_OF_THE_BOX_TYPES,
32
+ getOwn
33
+ };
34
+ //# sourceMappingURL=conversionConstants.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/exported-related/conversion-utils/conversionConstants.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { ITEM_TYPES } from '../../constants/index.js';\n\nexport const DRILLDOWN_TYPES: string[] = [\n ITEM_TYPES.LEFT_NAV_ITEM_CONTROLLED_DRILLDOWN,\n ITEM_TYPES.LEFT_NAV_ITEM_UNCONTROLLED_DRILLDOWN,\n];\nexport const LEAF_TYPES: string[] = [\n ITEM_TYPES.LEFT_NAV_ITEM_LINK,\n ITEM_TYPES.LEFT_NAV_ITEM_TEXT_LABEL,\n ITEM_TYPES.LEFT_NAV_ITEM_WITH_DATE,\n];\n\n/**\n * Reads only own entries, so ids and types like \"constructor\" or \"toString\" do not resolve to inherited members.\n */\nexport const getOwn = <T>(map: Record<string, T>, key: string): T | undefined =>\n Object.prototype.hasOwnProperty.call(map, key) ? map[key] : undefined;\n\n/**\n * The types a `HeaderComponent` can have and still be the tree header: a header, or a leaf when the header is only a link.\n */\nexport const HEADER_TYPES: string[] = [ITEM_TYPES.LEFT_NAV_ITEM_HEADER, ...LEAF_TYPES];\n\nexport const OUT_OF_THE_BOX_TYPES: string[] = Object.values(ITEM_TYPES);\n\n/**\n * LeftNavigation renders no `CollapsedComponent` for these types (it forces it to null), so they were never in its rail.\n */\nexport const NO_RAIL_TYPES: string[] = [\n ITEM_TYPES.LEFT_NAV_ITEM_TEXT_LABEL,\n ITEM_TYPES.LEFT_NAV_ITEM_WITH_DATE,\n ITEM_TYPES.LEFT_NAV_ITEM_CONTROLLED_DRILLDOWN,\n ITEM_TYPES.LEFT_NAV_ITEM_UNCONTROLLED_DRILLDOWN,\n];\n\nexport const DROPPED_TYPE_CODES = {\n [ITEM_TYPES.LEFT_NAV_ITEM_HEADER]: ['header-item-dropped', 'Header items are not part of the list'],\n [ITEM_TYPES.LEFT_NAV_ITEM_SKELETON]: ['skeleton-dropped', 'Skeleton items are not supported'],\n} as const;\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,SAAS,kBAAkB;AAEpB,MAAM,kBAA4B;AAAA,EACvC,WAAW;AAAA,EACX,WAAW;AACb;AACO,MAAM,aAAuB;AAAA,EAClC,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AACb;AAKO,MAAM,SAAS,CAAI,KAAwB,QAChD,OAAO,UAAU,eAAe,KAAK,KAAK,GAAG,IAAI,IAAI,GAAG,IAAI;AAKvD,MAAM,eAAyB,CAAC,WAAW,sBAAsB,GAAG,UAAU;AAE9E,MAAM,uBAAiC,OAAO,OAAO,UAAU;AAK/D,MAAM,gBAA0B;AAAA,EACrC,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AAAA,EACX,WAAW;AACb;AAEO,MAAM,qBAAqB;AAAA,EAChC,CAAC,WAAW,oBAAoB,GAAG,CAAC,uBAAuB,uCAAuC;AAAA,EAClG,CAAC,WAAW,sBAAsB,GAAG,CAAC,oBAAoB,kCAAkC;AAC9F;",
6
+ "names": []
7
+ }
@@ -0,0 +1,172 @@
1
+ import * as React from "react";
2
+ import {
3
+ LEFT_NAVIGATION_TREE_ITEM_TYPES as TREE_TYPES
4
+ } from "@elliemae/ds-left-navigation-tree";
5
+ import { ITEM_TYPES } from "../../constants/index.js";
6
+ import {
7
+ DRILLDOWN_TYPES,
8
+ DROPPED_TYPE_CODES,
9
+ HEADER_TYPES,
10
+ LEAF_TYPES,
11
+ NO_RAIL_TYPES,
12
+ OUT_OF_THE_BOX_TYPES,
13
+ getOwn
14
+ } from "./conversionConstants.js";
15
+ import { convertItemOpts } from "./convertItemOpts.js";
16
+ import { markLost } from "./report.js";
17
+ const convertCollapsed = (item, report) => {
18
+ if (!item.CollapsedComponent || NO_RAIL_TYPES.includes(item.type ?? "")) return {};
19
+ markLost(report, {
20
+ code: "collapsed-component-ctx",
21
+ dsId: item.dsId ?? "",
22
+ message: "CollapsedComponent is kept, it only receives { item }"
23
+ });
24
+ return { CollapsedComponent: item.CollapsedComponent };
25
+ };
26
+ const joinSectionLabel = (label, rightSection) => typeof label === "string" && typeof rightSection === "string" ? `${label}, ${rightSection}` : label;
27
+ const convertSubmenu = (item, args) => {
28
+ const { report, childrenByParentId, recurse } = args;
29
+ const dsId = item.dsId ?? "";
30
+ const children = getOwn(childrenByParentId, dsId);
31
+ if (!children)
32
+ markLost(report, { code: "submenu-without-children", dsId, message: "No entry in childrenByParentId" });
33
+ return {
34
+ dsId,
35
+ type: TREE_TYPES.PARENT,
36
+ ...convertCollapsed(item, report),
37
+ itemOpts: { ...convertItemOpts({ item, report, kind: "submenu" }), items: recurse(children ?? []) }
38
+ };
39
+ };
40
+ const convertDrilldown = (item, args) => {
41
+ const { report, recurse } = args;
42
+ const dsId = item.dsId ?? "";
43
+ const { startOpened, isOpened, items = [] } = item.itemOpts ?? {};
44
+ const opts = convertItemOpts({ item, report, kind: "drilldown" });
45
+ const isControlled = item.type === ITEM_TYPES.LEFT_NAV_ITEM_CONTROLLED_DRILLDOWN;
46
+ return {
47
+ dsId,
48
+ type: TREE_TYPES.PARENT,
49
+ ...convertCollapsed(item, report),
50
+ itemOpts: {
51
+ ...opts,
52
+ ...isControlled && { isOpened: !!isOpened },
53
+ ...!isControlled && startOpened !== void 0 && { startOpened },
54
+ items: recurse(items)
55
+ }
56
+ };
57
+ };
58
+ const convertOne = (item, args) => {
59
+ const { report } = args;
60
+ const dsId = item.dsId ?? "";
61
+ const { type } = item;
62
+ if (typeof type !== "string") {
63
+ markLost(report, {
64
+ code: "custom-component-dropped",
65
+ dsId,
66
+ message: "Items with a custom Component are not supported"
67
+ });
68
+ return null;
69
+ }
70
+ if (LEAF_TYPES.includes(type)) {
71
+ return {
72
+ dsId,
73
+ type: TREE_TYPES.LEAF,
74
+ ...convertCollapsed(item, report),
75
+ itemOpts: convertItemOpts({ item, report, kind: "leaf" })
76
+ };
77
+ }
78
+ if (type === ITEM_TYPES.LEFT_NAV_ITEM_SUBMENU) return convertSubmenu(item, args);
79
+ if (DRILLDOWN_TYPES.includes(type)) return convertDrilldown(item, args);
80
+ const [code, message] = getOwn(DROPPED_TYPE_CODES, type) ?? [
81
+ "unknown-type-dropped",
82
+ `Type "${type}" is not out of the box`
83
+ ];
84
+ markLost(report, { code, dsId, message });
85
+ return null;
86
+ };
87
+ const convertSection = (item, report, items) => {
88
+ const { label, labelRightSection } = item.itemOpts ?? {};
89
+ const joinable = typeof label === "string" && typeof labelRightSection === "string";
90
+ const opts = convertItemOpts({ item, report, kind: "section", joinable });
91
+ return {
92
+ dsId: item.dsId ?? "",
93
+ type: TREE_TYPES.SECTION,
94
+ itemOpts: {
95
+ ...opts,
96
+ label: joinSectionLabel(label, labelRightSection),
97
+ items
98
+ }
99
+ };
100
+ };
101
+ const convertList = (args) => {
102
+ const { list, isRoot, report, ancestors = [] } = args;
103
+ const converted = [];
104
+ let sectionItems = null;
105
+ list.forEach((item) => {
106
+ const { type, dsId = "" } = item;
107
+ const isSection = type === ITEM_TYPES.LEFT_NAV_ITEM_SECTION;
108
+ if (isSection || type === ITEM_TYPES.LEFT_NAV_ITEM_SEPARATOR) {
109
+ if (!isRoot) {
110
+ markLost(report, {
111
+ code: "section-in-nested-list-dropped",
112
+ dsId,
113
+ message: "Sections and separators are only supported at the root level"
114
+ });
115
+ return;
116
+ }
117
+ sectionItems = isSection ? [] : null;
118
+ converted.push(sectionItems ? convertSection(item, report, sectionItems) : { dsId, type: TREE_TYPES.SEPARATOR });
119
+ return;
120
+ }
121
+ const ancestorKey = dsId || item;
122
+ const isOwnAncestor = ancestors.includes(ancestorKey);
123
+ const convertedItem = convertOne(item, {
124
+ report,
125
+ childrenByParentId: args.childrenByParentId,
126
+ recurse: (children) => isOwnAncestor ? [] : convertList({ ...args, list: children, isRoot: false, ancestors: [...ancestors, ancestorKey] })
127
+ });
128
+ if (!convertedItem) return;
129
+ if (sectionItems) sectionItems.push(convertedItem);
130
+ else converted.push(convertedItem);
131
+ });
132
+ return converted;
133
+ };
134
+ const convertHeader = (header, report) => {
135
+ if (header.type === ITEM_TYPES.LEFT_NAV_ITEM_SKELETON) {
136
+ const [code, message] = DROPPED_TYPE_CODES[ITEM_TYPES.LEFT_NAV_ITEM_SKELETON];
137
+ markLost(report, { code, dsId: header.dsId ?? "", message });
138
+ return null;
139
+ }
140
+ if (typeof header.type !== "string" || !OUT_OF_THE_BOX_TYPES.includes(header.type)) {
141
+ markLost(report, {
142
+ code: "custom-component-dropped",
143
+ dsId: header.dsId ?? "",
144
+ message: "A HeaderComponent with a custom Component is not supported"
145
+ });
146
+ return null;
147
+ }
148
+ if (!HEADER_TYPES.includes(header.type)) {
149
+ markLost(report, {
150
+ code: "unknown-type-dropped",
151
+ dsId: header.dsId ?? "",
152
+ message: `A HeaderComponent of type "${header.type}" is not supported, use a header or a leaf type`
153
+ });
154
+ return null;
155
+ }
156
+ return {
157
+ dsId: header.dsId ?? "",
158
+ type: TREE_TYPES.LEAF,
159
+ ...convertCollapsed(header, report),
160
+ /** A header of a leaf type is drawn by LeftNavigation as that leaf (a with-date header shows its date), so it converts as one. */
161
+ itemOpts: convertItemOpts({
162
+ item: header,
163
+ report,
164
+ kind: header.type === ITEM_TYPES.LEFT_NAV_ITEM_HEADER ? "header" : "leaf"
165
+ })
166
+ };
167
+ };
168
+ export {
169
+ convertHeader,
170
+ convertList
171
+ };
172
+ //# sourceMappingURL=conversionHelpers.js.map