@elliemae/ds-dropdownmenu-v2 3.46.0-rc.0 → 3.46.0-rc.10

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 (31) hide show
  1. package/dist/cjs/exported-related/conversion-utils/conversionHelpers.js +139 -0
  2. package/dist/cjs/exported-related/conversion-utils/conversionHelpers.js.map +7 -0
  3. package/dist/cjs/exported-related/conversion-utils/getHumanReadableWarnings.js +59 -0
  4. package/dist/cjs/exported-related/conversion-utils/getHumanReadableWarnings.js.map +7 -0
  5. package/dist/cjs/exported-related/conversion-utils/index.js +109 -0
  6. package/dist/cjs/exported-related/conversion-utils/index.js.map +7 -0
  7. package/dist/cjs/exported-related/conversion-utils/reportMutableUpdatesHelpers.js +99 -0
  8. package/dist/cjs/exported-related/conversion-utils/reportMutableUpdatesHelpers.js.map +7 -0
  9. package/dist/cjs/exported-related/conversion-utils/types.js +28 -0
  10. package/dist/cjs/exported-related/conversion-utils/types.js.map +7 -0
  11. package/dist/cjs/index.js +5 -1
  12. package/dist/cjs/index.js.map +2 -2
  13. package/dist/esm/exported-related/conversion-utils/conversionHelpers.js +109 -0
  14. package/dist/esm/exported-related/conversion-utils/conversionHelpers.js.map +7 -0
  15. package/dist/esm/exported-related/conversion-utils/getHumanReadableWarnings.js +29 -0
  16. package/dist/esm/exported-related/conversion-utils/getHumanReadableWarnings.js.map +7 -0
  17. package/dist/esm/exported-related/conversion-utils/index.js +84 -0
  18. package/dist/esm/exported-related/conversion-utils/index.js.map +7 -0
  19. package/dist/esm/exported-related/conversion-utils/reportMutableUpdatesHelpers.js +69 -0
  20. package/dist/esm/exported-related/conversion-utils/reportMutableUpdatesHelpers.js.map +7 -0
  21. package/dist/esm/exported-related/conversion-utils/types.js +2 -0
  22. package/dist/esm/exported-related/conversion-utils/types.js.map +7 -0
  23. package/dist/esm/index.js +13 -7
  24. package/dist/esm/index.js.map +2 -2
  25. package/dist/types/exported-related/conversion-utils/conversionHelpers.d.ts +76 -0
  26. package/dist/types/exported-related/conversion-utils/getHumanReadableWarnings.d.ts +7 -0
  27. package/dist/types/exported-related/conversion-utils/index.d.ts +9 -0
  28. package/dist/types/exported-related/conversion-utils/reportMutableUpdatesHelpers.d.ts +13 -0
  29. package/dist/types/exported-related/conversion-utils/types.d.ts +37 -0
  30. package/dist/types/index.d.ts +4 -3
  31. package/package.json +10 -9
@@ -0,0 +1,109 @@
1
+ import * as React from "react";
2
+ import { MENU_ITEMS_TYPES } from "@elliemae/ds-menu-button";
3
+ const isItemSingleOptions = (option) => option.type === "single";
4
+ const isItemActionOptions = (option) => option.type === "action";
5
+ const isItemSingleWithSubmenuOptions = (option) => option.type === "singleWithSubmenu";
6
+ const isItemCheckboxOptions = (option) => option.type === "checkbox";
7
+ const isItemSubmenuOptions = (option) => option.type === "submenu";
8
+ const isItemSeparatorOptions = (option) => option.type === "separator";
9
+ const isItemSectionOptions = (option) => option.type === "section";
10
+ const isItemSkeletonOptions = (option) => option.type === "skeleton";
11
+ const convertActionOptToMenuButtonItem = (option) => ({
12
+ type: MENU_ITEMS_TYPES.ACTIVABLE_ITEM,
13
+ label: option.label,
14
+ // DSDropdownMenuT common items properties
15
+ dsId: option.dsId,
16
+ minWidth: option?.minWidth,
17
+ disabled: option.disabled || option.applyAriaDisabled,
18
+ onClick: option.onClick,
19
+ onKeyDown: option.onKeyDown
20
+ });
21
+ const convertSingleSelectionOptToMenuButtonItem = (option) => ({
22
+ type: MENU_ITEMS_TYPES.SINGLE_SELECT_ITEM,
23
+ label: option.label,
24
+ // DSDropdownMenuT common items properties
25
+ dsId: option.dsId,
26
+ minWidth: option?.minWidth,
27
+ disabled: option.disabled || option.applyAriaDisabled,
28
+ onClick: option.onClick,
29
+ onKeyDown: option.onKeyDown
30
+ });
31
+ const convertCheckboxOptToMenuButtonItem = (option) => ({
32
+ type: MENU_ITEMS_TYPES.MULTIPLE_SELECT_ITEM,
33
+ label: option.label,
34
+ // DSDropdownMenuT common items properties
35
+ dsId: option.dsId,
36
+ minWidth: option?.minWidth,
37
+ disabled: option.disabled || option.applyAriaDisabled,
38
+ onClick: option.onClick,
39
+ onKeyDown: option.onKeyDown
40
+ });
41
+ const convertSeparatorOptToMenuButtonItem = (option) => ({
42
+ type: MENU_ITEMS_TYPES.SEPARATOR,
43
+ // DSDropdownMenuT common items properties
44
+ dsId: option.dsId
45
+ });
46
+ const convertSectionOptToMenuButtonItem = (option) => ({
47
+ type: MENU_ITEMS_TYPES.GROUP,
48
+ label: option.label,
49
+ // DSDropdownMenuT common items properties
50
+ dsId: option.dsId,
51
+ minWidth: option?.minWidth
52
+ });
53
+ const convertSkeletonOptToMenuButtonItem = (option) => ({
54
+ type: MENU_ITEMS_TYPES.SKELETON_ITEM,
55
+ dsId: option.dsId,
56
+ minWidth: option?.minWidth
57
+ });
58
+ const convertSingleWithSubmenuOptToMenuButtonItem = (option, convFn) => ({
59
+ type: MENU_ITEMS_TYPES.SINGLE_SELECT_WITH_SUBMENU_ITEM,
60
+ label: option.label,
61
+ subitems: option.options.map(convFn),
62
+ maxHeight: option.maxHeight,
63
+ // DSDropdownMenuT common items properties
64
+ dsId: option.dsId,
65
+ minWidth: option?.minWidth,
66
+ disabled: option.disabled || option.applyAriaDisabled,
67
+ onClick: option.onClick,
68
+ onKeyDown: option.onKeyDown
69
+ });
70
+ const convertSubmenuOptToMenuButtonItem = (option, convFn) => ({
71
+ type: MENU_ITEMS_TYPES.WITH_SUBMENU_ITEM,
72
+ label: option.label,
73
+ subitems: option.options.map(convFn),
74
+ maxHeight: option.maxHeight,
75
+ // DSDropdownMenuT common items properties
76
+ dsId: option.dsId,
77
+ minWidth: option?.minWidth,
78
+ disabled: option.disabled || option.applyAriaDisabled,
79
+ onClick: option.onClick,
80
+ onKeyDown: option.onKeyDown
81
+ });
82
+ const convertDropdownItemToMenuButtonItem = (option) => {
83
+ if (isItemActionOptions(option)) return convertActionOptToMenuButtonItem(option);
84
+ if (isItemSingleOptions(option)) return convertSingleSelectionOptToMenuButtonItem(option);
85
+ if (isItemSingleWithSubmenuOptions(option))
86
+ return convertSingleWithSubmenuOptToMenuButtonItem(option, convertDropdownItemToMenuButtonItem);
87
+ if (isItemCheckboxOptions(option)) return convertCheckboxOptToMenuButtonItem(option);
88
+ if (isItemSubmenuOptions(option))
89
+ return convertSubmenuOptToMenuButtonItem(option, convertDropdownItemToMenuButtonItem);
90
+ if (isItemSeparatorOptions(option)) return convertSeparatorOptToMenuButtonItem(option);
91
+ if (isItemSectionOptions(option)) return convertSectionOptToMenuButtonItem(option);
92
+ if (isItemSkeletonOptions(option)) return convertSkeletonOptToMenuButtonItem(option);
93
+ throw new Error("Unknown item type");
94
+ };
95
+ export {
96
+ convertActionOptToMenuButtonItem,
97
+ convertCheckboxOptToMenuButtonItem,
98
+ convertDropdownItemToMenuButtonItem,
99
+ convertSectionOptToMenuButtonItem,
100
+ convertSeparatorOptToMenuButtonItem,
101
+ convertSingleSelectionOptToMenuButtonItem,
102
+ convertSingleWithSubmenuOptToMenuButtonItem,
103
+ convertSkeletonOptToMenuButtonItem,
104
+ convertSubmenuOptToMenuButtonItem,
105
+ isItemSectionOptions,
106
+ isItemSingleWithSubmenuOptions,
107
+ isItemSubmenuOptions
108
+ };
109
+ //# sourceMappingURL=conversionHelpers.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/exported-related/conversion-utils/conversionHelpers.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { type DSMenuButtonT, MENU_ITEMS_TYPES } from '@elliemae/ds-menu-button';\nimport { type DSDropdownMenuT } from '../../react-desc-prop-types.js';\n\n/**\n * Type guard to check if the option is of type ItemSingleOptions.\n * @param option - The option to check.\n * @returns True if the option is of type ItemSingleOptions, false otherwise.\n */\nconst isItemSingleOptions = (option: DSDropdownMenuT.Item): option is DSDropdownMenuT.ItemSingleOptions =>\n option.type === 'single';\n\n/**\n * Type guard to check if the option is of type ItemActionOptions.\n * @param option - The option to check.\n * @returns True if the option is of type ItemActionOptions, false otherwise.\n */\nconst isItemActionOptions = (option: DSDropdownMenuT.Item): option is DSDropdownMenuT.ItemActionOptions =>\n option.type === 'action';\n\n/**\n * Type guard to check if the option is of type ItemSingleWithSubmenuOptions.\n * @param option - The option to check.\n * @returns True if the option is of type ItemSingleWithSubmenuOptions, false otherwise.\n */\nexport const isItemSingleWithSubmenuOptions = (\n option: DSDropdownMenuT.Item,\n): option is DSDropdownMenuT.ItemSingleWithSubmenuOptions => option.type === 'singleWithSubmenu';\n\n/**\n * Type guard to check if the option is of type ItemCheckboxOptions.\n * @param option - The option to check.\n * @returns True if the option is of type ItemCheckboxOptions, false otherwise.\n */\nconst isItemCheckboxOptions = (option: DSDropdownMenuT.Item): option is DSDropdownMenuT.ItemCheckboxOptions =>\n option.type === 'checkbox';\n\n/**\n * Type guard to check if the option is of type ItemSubmenuOptions.\n * @param option - The option to check.\n * @returns True if the option is of type ItemSubmenuOptions, false otherwise.\n */\nexport const isItemSubmenuOptions = (option: DSDropdownMenuT.Item): option is DSDropdownMenuT.ItemSubmenuOptions =>\n option.type === 'submenu';\n\n/**\n * Type guard to check if the option is of type ItemSeparatorOptions.\n * @param option - The option to check.\n * @returns True if the option is of type ItemSeparatorOptions, false otherwise.\n */\nconst isItemSeparatorOptions = (option: DSDropdownMenuT.Item): option is DSDropdownMenuT.ItemSeparatorOptions =>\n option.type === 'separator';\n\n/**\n * Type guard to check if the option is of type ItemSectionOptions.\n * @param option - The option to check.\n * @returns True if the option is of type ItemSectionOptions, false otherwise.\n */\nexport const isItemSectionOptions = (option: DSDropdownMenuT.Item): option is DSDropdownMenuT.ItemSectionOptions =>\n option.type === 'section';\n\n/**\n * Type guard to check if the option is of type ItemSkeletonOptions.\n * @param option - The option to check.\n * @returns True if the option is of type ItemSkeletonOptions, false otherwise.\n */\nconst isItemSkeletonOptions = (option: DSDropdownMenuT.Item): option is DSDropdownMenuT.ItemSkeletonOptions =>\n option.type === 'skeleton';\n\n/**\n * Converts ItemActionOptions to DSMenuButtonT.ActivableItem.\n * @param option - The ItemActionOptions to convert.\n * @returns The converted ActivableItem.\n */\nexport const convertActionOptToMenuButtonItem = (\n option: DSDropdownMenuT.ItemActionOptions,\n): DSMenuButtonT.ActivableItem => ({\n type: MENU_ITEMS_TYPES.ACTIVABLE_ITEM,\n label: option.label,\n // DSDropdownMenuT common items properties\n dsId: option.dsId,\n minWidth: option?.minWidth as DSMenuButtonT.ActivableItem['minWidth'],\n disabled: option.disabled || option.applyAriaDisabled,\n onClick: option.onClick,\n onKeyDown: option.onKeyDown,\n});\n\n/**\n * Converts ItemSingleOptions to DSMenuButtonT.SingleSelectItem.\n * @param option - The ItemSingleWithSubmenuOptions to convert.\n * @returns The converted SingleSelectWithSubmenuItem.\n */\nexport const convertSingleSelectionOptToMenuButtonItem = (\n option: DSDropdownMenuT.ItemSingleOptions,\n): DSMenuButtonT.SingleSelectItem => ({\n type: MENU_ITEMS_TYPES.SINGLE_SELECT_ITEM,\n label: option.label,\n // DSDropdownMenuT common items properties\n dsId: option.dsId,\n minWidth: option?.minWidth as DSMenuButtonT.ActivableItem['minWidth'],\n disabled: option.disabled || option.applyAriaDisabled,\n onClick: option.onClick,\n onKeyDown: option.onKeyDown,\n});\n\n/**\n * Converts ItemCheckboxOptions to DSMenuButtonT.MultipleSelectItem.\n * @param option - The ItemCheckboxOptions to convert.\n * @returns The converted MultipleSelectItem.\n */\nexport const convertCheckboxOptToMenuButtonItem = (\n option: DSDropdownMenuT.ItemCheckboxOptions,\n): DSMenuButtonT.MultipleSelectItem => ({\n type: MENU_ITEMS_TYPES.MULTIPLE_SELECT_ITEM,\n label: option.label,\n // DSDropdownMenuT common items properties\n dsId: option.dsId,\n minWidth: option?.minWidth as DSMenuButtonT.ActivableItem['minWidth'],\n disabled: option.disabled || option.applyAriaDisabled,\n onClick: option.onClick,\n onKeyDown: option.onKeyDown,\n});\n\n/**\n * Converts ItemSeparatorOptions to DSMenuButtonT.SeparatorItem.\n * @param option - The ItemSeparatorOptions to convert.\n * @returns The converted SeparatorItem.\n */\nexport const convertSeparatorOptToMenuButtonItem = (\n option: DSDropdownMenuT.ItemSeparatorOptions,\n): DSMenuButtonT.SeparatorItem => ({\n type: MENU_ITEMS_TYPES.SEPARATOR,\n // DSDropdownMenuT common items properties\n dsId: option.dsId,\n});\n\n/**\n * Converts ItemSectionOptions to DSMenuButtonT.GroupItem.\n * @param option - The ItemSectionOptions to convert.\n * @returns The converted GroupItem.\n */\nexport const convertSectionOptToMenuButtonItem = (\n option: DSDropdownMenuT.ItemSectionOptions,\n): DSMenuButtonT.GroupItem => ({\n type: MENU_ITEMS_TYPES.GROUP,\n label: option.label,\n // DSDropdownMenuT common items properties\n dsId: option.dsId,\n minWidth: option?.minWidth as DSMenuButtonT.ActivableItem['minWidth'],\n});\n\n/**\n * Converts ItemSkeletonOptions to DSMenuButtonT.SkeletonItem.\n * @param option - The ItemSkeletonOptions to convert.\n * @returns The converted SkeletonItem.\n */\nexport const convertSkeletonOptToMenuButtonItem = (\n option: DSDropdownMenuT.ItemSkeletonOptions,\n): DSMenuButtonT.SkeletonItem => ({\n type: MENU_ITEMS_TYPES.SKELETON_ITEM,\n dsId: option.dsId,\n minWidth: option?.minWidth as DSMenuButtonT.ActivableItem['minWidth'],\n});\n\n// ========================================================================================\n// WithSubmenu conversion requires iterating nested options\n// to avoid \"cannot use before defined\", we inject the conversion as second parameter\n// ========================================================================================\n/**\n * Converts ItemSingleWithSubmenuOptions to DSMenuButtonT.SingleSelectWithSubmenuItem.\n * @param option - The ItemSingleWithSubmenuOptions to convert.\n * @param convFn - The conversion function to convert nested options - required to avoid circular dependencies.\n * @returns The converted SingleSelectWithSubmenuItem.\n */\nexport const convertSingleWithSubmenuOptToMenuButtonItem = (\n option: DSDropdownMenuT.ItemSingleWithSubmenuOptions,\n convFn: (option: DSDropdownMenuT.Item) => DSMenuButtonT.MenuItemInterface,\n): DSMenuButtonT.SingleSelectWithSubmenuItem => ({\n type: MENU_ITEMS_TYPES.SINGLE_SELECT_WITH_SUBMENU_ITEM,\n label: option.label,\n subitems: option.options.map(convFn),\n maxHeight: option.maxHeight as DSMenuButtonT.SingleSelectWithSubmenuItem['maxHeight'],\n // DSDropdownMenuT common items properties\n dsId: option.dsId,\n minWidth: option?.minWidth as DSMenuButtonT.ActivableItem['minWidth'],\n disabled: option.disabled || option.applyAriaDisabled,\n onClick: option.onClick,\n onKeyDown: option.onKeyDown,\n});\n/**\n * Converts ItemSubmenuOptions to DSMenuButtonT.WithSubmenuItem.\n * @param option - The ItemSubmenuOptions to convert.\n * @param convFn - The conversion function to convert nested options - required to avoid circular dependencies.\n * @returns The converted WithSubmenuItem.\n */\nexport const convertSubmenuOptToMenuButtonItem = (\n option: DSDropdownMenuT.ItemSubmenuOptions,\n convFn: (option: DSDropdownMenuT.Item) => DSMenuButtonT.MenuItemInterface,\n): DSMenuButtonT.WithSubmenuItem => ({\n type: MENU_ITEMS_TYPES.WITH_SUBMENU_ITEM,\n label: option.label,\n subitems: option.options.map(convFn),\n maxHeight: option.maxHeight as DSMenuButtonT.WithSubmenuItem['maxHeight'],\n // DSDropdownMenuT common items properties\n dsId: option.dsId,\n minWidth: option?.minWidth as DSMenuButtonT.ActivableItem['minWidth'],\n disabled: option.disabled || option.applyAriaDisabled,\n onClick: option.onClick,\n onKeyDown: option.onKeyDown,\n});\n\n/**\n * Converts a DSDropdownMenuT.Item to a DSMenuButtonT.MenuItemInterface.\n * @param option - The DSDropdownMenuT.Item to convert.\n * @returns The converted MenuItemInterface.\n */\nexport const convertDropdownItemToMenuButtonItem = (option: DSDropdownMenuT.Item): DSMenuButtonT.MenuItemInterface => {\n if (isItemActionOptions(option)) return convertActionOptToMenuButtonItem(option);\n // single selections\n if (isItemSingleOptions(option)) return convertSingleSelectionOptToMenuButtonItem(option);\n if (isItemSingleWithSubmenuOptions(option))\n return convertSingleWithSubmenuOptToMenuButtonItem(option, convertDropdownItemToMenuButtonItem);\n // multiple selections\n if (isItemCheckboxOptions(option)) return convertCheckboxOptToMenuButtonItem(option);\n // DDV2 didn't support multiple selections with submenu so we don't need to handle it\n // only submenu\n if (isItemSubmenuOptions(option))\n return convertSubmenuOptToMenuButtonItem(option, convertDropdownItemToMenuButtonItem);\n // separators, groups and skeletons\n if (isItemSeparatorOptions(option)) return convertSeparatorOptToMenuButtonItem(option);\n if (isItemSectionOptions(option)) return convertSectionOptToMenuButtonItem(option);\n if (isItemSkeletonOptions(option)) return convertSkeletonOptToMenuButtonItem(option);\n\n throw new Error('Unknown item type');\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACAvB,SAA6B,wBAAwB;AAQrD,MAAM,sBAAsB,CAAC,WAC3B,OAAO,SAAS;AAOlB,MAAM,sBAAsB,CAAC,WAC3B,OAAO,SAAS;AAOX,MAAM,iCAAiC,CAC5C,WAC2D,OAAO,SAAS;AAO7E,MAAM,wBAAwB,CAAC,WAC7B,OAAO,SAAS;AAOX,MAAM,uBAAuB,CAAC,WACnC,OAAO,SAAS;AAOlB,MAAM,yBAAyB,CAAC,WAC9B,OAAO,SAAS;AAOX,MAAM,uBAAuB,CAAC,WACnC,OAAO,SAAS;AAOlB,MAAM,wBAAwB,CAAC,WAC7B,OAAO,SAAS;AAOX,MAAM,mCAAmC,CAC9C,YACiC;AAAA,EACjC,MAAM,iBAAiB;AAAA,EACvB,OAAO,OAAO;AAAA;AAAA,EAEd,MAAM,OAAO;AAAA,EACb,UAAU,QAAQ;AAAA,EAClB,UAAU,OAAO,YAAY,OAAO;AAAA,EACpC,SAAS,OAAO;AAAA,EAChB,WAAW,OAAO;AACpB;AAOO,MAAM,4CAA4C,CACvD,YACoC;AAAA,EACpC,MAAM,iBAAiB;AAAA,EACvB,OAAO,OAAO;AAAA;AAAA,EAEd,MAAM,OAAO;AAAA,EACb,UAAU,QAAQ;AAAA,EAClB,UAAU,OAAO,YAAY,OAAO;AAAA,EACpC,SAAS,OAAO;AAA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AC,WAAkE;AACpH,MAAI,oBAAoB,MAAM,EAAG,QAAO,iCAAiC,MAAM;AAE/E,MAAI,oBAAoB,MAAM,EAAG,QAAO,0CAA0C,MAAM;AACxF,MAAI,+BAA+B,MAAM;AACvC,WAAO,4CAA4C,QAAQ,mCAAmC;AAEhG,MAAI,sBAAsB,MAAM,EAAG,QAAO,mCAAmC,MAAM;AAGnF,MAAI,qBAAqB,MAAM;AAC7B,WAAO,kCAAkC,QAAQ,mCAAmC;AAEtF,MAAI,uBAAuB,MAAM,EAAG,QAAO,oCAAoC,MAAM;AACrF,MAAI,qBAAqB,MAAM,EAAG,QAAO,kCAAkC,MAAM;AACjF,MAAI,sBAAsB,MAAM,EAAG,QAAO,mCAAmC,MAAM;AAEnF,QAAM,IAAI,MAAM,mBAAmB;AACrC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,29 @@
1
+ import * as React from "react";
2
+ const getHumanReadableWarnings = (report) => {
3
+ const warnings = [];
4
+ if (report.detectedLostsOnConversion.render) {
5
+ warnings.push(
6
+ `- Encountered "render" in one or more options - the menu-button component is stricter on underlying html structure due to required accessibility, the conversion will ignore the "render", if you need it and you are sure it's a11y compliant you can implement it with the item "ItemRenderer" menu-button property instead`
7
+ );
8
+ }
9
+ if (report.detectedLostsOnConversion.ellipsis) {
10
+ warnings.push(
11
+ `- Encountered "ellipsis" right addon in one or more options - new designs doesn't support "ellipsis" config and instead provide exclusively "chevron"`
12
+ );
13
+ }
14
+ if (report.didFillGroupForSingleSelection) {
15
+ warnings.push(
16
+ `- Single select without a "section" BUT there is no mixing with "multi select" - the conversion filled a placeholder group`
17
+ );
18
+ }
19
+ if (report.wasFilledWithSkeletonDueToEmptyArrays) {
20
+ warnings.push(
21
+ `- some options/sub-options were empty - the conversion filled them with skeleton items (no empty options are allowed, at most loading skeletons)`
22
+ );
23
+ }
24
+ return warnings;
25
+ };
26
+ export {
27
+ getHumanReadableWarnings
28
+ };
29
+ //# sourceMappingURL=getHumanReadableWarnings.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/exported-related/conversion-utils/getHumanReadableWarnings.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { type DSDropdownV2BridgeT } from './types.js';\n\n/**\n * given the report, it will return a human readable list of warnings\n * @param report - The report to get the warnings from.\n * @returns A list of human readable warnings.\n */\nexport const getHumanReadableWarnings = (report: DSDropdownV2BridgeT.ReportMutableT): string[] => {\n const warnings: string[] = [];\n if (report.detectedLostsOnConversion.render) {\n warnings.push(\n `- Encountered \"render\" in one or more options - the menu-button component is stricter on underlying html structure due to required accessibility, the conversion will ignore the \"render\", if you need it and you are sure it's a11y compliant you can implement it with the item \"ItemRenderer\" menu-button property instead`,\n );\n }\n if (report.detectedLostsOnConversion.ellipsis) {\n warnings.push(\n `- Encountered \"ellipsis\" right addon in one or more options - new designs doesn't support \"ellipsis\" config and instead provide exclusively \"chevron\"`,\n );\n }\n if (report.didFillGroupForSingleSelection) {\n warnings.push(\n `- Single select without a \"section\" BUT there is no mixing with \"multi select\" - the conversion filled a placeholder group`,\n );\n }\n if (report.wasFilledWithSkeletonDueToEmptyArrays) {\n warnings.push(\n `- some options/sub-options were empty - the conversion filled them with skeleton items (no empty options are allowed, at most loading skeletons)`,\n );\n }\n return warnings;\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACOhB,MAAM,2BAA2B,CAAC,WAAyD;AAChG,QAAM,WAAqB,CAAC;AAC5B,MAAI,OAAO,0BAA0B,QAAQ;AAC3C,aAAS;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACA,MAAI,OAAO,0BAA0B,UAAU;AAC7C,aAAS;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACA,MAAI,OAAO,gCAAgC;AACzC,aAAS;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACA,MAAI,OAAO,uCAAuC;AAChD,aAAS;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;",
6
+ "names": []
7
+ }
@@ -0,0 +1,84 @@
1
+ import * as React from "react";
2
+ import {
3
+ convertDropdownItemToMenuButtonItem,
4
+ isItemSectionOptions,
5
+ isItemSingleWithSubmenuOptions,
6
+ isItemSubmenuOptions
7
+ } from "./conversionHelpers.js";
8
+ import { getHumanReadableWarnings } from "./getHumanReadableWarnings.js";
9
+ import { mutableUpdateReportPerIteration, mutableUpdateReportPostIteration } from "./reportMutableUpdatesHelpers.js";
10
+ const checkIfOptionsCanBeConverted = (options) => {
11
+ const mutableReport = {
12
+ unrecoverableConversion: false,
13
+ needsGracefullRecovery: false,
14
+ wasFilledWithSkeletonDueToEmptyArrays: false,
15
+ didFillGroupForSingleSelection: false,
16
+ detectedLostsOnConversion: {
17
+ ellipsis: false,
18
+ render: false
19
+ },
20
+ mutableReportsPerParentMap: {
21
+ "__first-level-root": {
22
+ lastSectionIndex: void 0,
23
+ adjacentGroupsReport: [],
24
+ hasMultipleSelections: false,
25
+ hasSingleSelections: false,
26
+ hasGrouplessSingleSelections: false,
27
+ isSingleWithoutMultipleAtAll: false,
28
+ hasEmptyOptions: false,
29
+ requiresHierarchicalGrouping: false,
30
+ gracefullRecoveries: { fillGroupForSingleSelection: false, fillLoading: false }
31
+ }
32
+ },
33
+ humanReadableWarnings: []
34
+ };
35
+ options.every((option, index) => {
36
+ mutableUpdateReportPerIteration({ mutableReport, option, index, parentDsId: "__first-level-root" });
37
+ if (mutableReport.unrecoverableConversion) return false;
38
+ return true;
39
+ });
40
+ mutableUpdateReportPostIteration({ mutableReport, options });
41
+ mutableReport.humanReadableWarnings = getHumanReadableWarnings(mutableReport);
42
+ return mutableReport;
43
+ };
44
+ const convertOptionsRecursive = (options) => {
45
+ const convertedOptions = [];
46
+ const groups = [];
47
+ options.forEach((option) => {
48
+ const convertedOption = convertDropdownItemToMenuButtonItem(option);
49
+ if (isItemSingleWithSubmenuOptions(option) || isItemSubmenuOptions(option)) {
50
+ const subitems = convertOptionsRecursive(option.options);
51
+ const typecastedOption = convertedOption;
52
+ typecastedOption.subitems = subitems;
53
+ }
54
+ if (isItemSectionOptions(option)) {
55
+ const typecastedOption = convertedOption;
56
+ const subitems = [...typecastedOption.subitems ?? []];
57
+ groups.push({ ...typecastedOption, subitems });
58
+ return;
59
+ }
60
+ if (groups.length > 0) {
61
+ const lastGroup = groups[groups.length - 1];
62
+ lastGroup.subitems.push(convertedOption);
63
+ return;
64
+ }
65
+ if (option.type === "single" || option.type === "singleWithSubmenu") {
66
+ groups.push({ type: "group", subitems: [convertedOption], dsId: `filled-group-starting-from-${option.dsId}` });
67
+ return;
68
+ }
69
+ convertedOptions.push(convertedOption);
70
+ });
71
+ convertedOptions.push(...groups);
72
+ return convertedOptions;
73
+ };
74
+ const checkAndConvertOptions = (options) => {
75
+ const report = checkIfOptionsCanBeConverted(options);
76
+ if (report.unrecoverableConversion) throw new Error("DSDropdownV2Bridge - critical configuration issues");
77
+ const convertedOptions = convertOptionsRecursive(options);
78
+ return { convertedOptions, report };
79
+ };
80
+ export {
81
+ checkAndConvertOptions,
82
+ checkIfOptionsCanBeConverted
83
+ };
84
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/exported-related/conversion-utils/index.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { type DSMenuButtonT } from '@elliemae/ds-menu-button';\nimport { type DSDropdownMenuT } from '../../react-desc-prop-types.js';\nimport { type DSDropdownV2BridgeT } from './types.js';\nimport {\n convertDropdownItemToMenuButtonItem,\n isItemSectionOptions,\n isItemSingleWithSubmenuOptions,\n isItemSubmenuOptions,\n} from './conversionHelpers.js';\nimport { getHumanReadableWarnings } from './getHumanReadableWarnings.js';\nimport { mutableUpdateReportPerIteration, mutableUpdateReportPostIteration } from './reportMutableUpdatesHelpers.js';\n\nexport const checkIfOptionsCanBeConverted = (\n options: DSDropdownV2BridgeT.InternalProps['options'],\n): DSDropdownV2BridgeT.ReportMutableT => {\n // this bridge component is not able to automatically bridge some configurations\n // in scenario where the component is not able to bridge the configuration we:\n // A - throw an error if it's a critical configuration\n // B - warn the configuration will be ignored if it's not critical\n // we are going to have to iterate over the options (and the tree-like but not really a DSTree) `options`\n // we should iterate only once and track all the potential violation in one go for performance reasons\n\n const mutableReport: DSDropdownV2BridgeT.ReportMutableT = {\n unrecoverableConversion: false,\n needsGracefullRecovery: false,\n wasFilledWithSkeletonDueToEmptyArrays: false,\n didFillGroupForSingleSelection: false,\n detectedLostsOnConversion: {\n ellipsis: false,\n render: false,\n },\n mutableReportsPerParentMap: {\n '__first-level-root': {\n lastSectionIndex: undefined,\n adjacentGroupsReport: [],\n hasMultipleSelections: false,\n hasSingleSelections: false,\n hasGrouplessSingleSelections: false,\n isSingleWithoutMultipleAtAll: false,\n hasEmptyOptions: false,\n requiresHierarchicalGrouping: false,\n gracefullRecoveries: { fillGroupForSingleSelection: false, fillLoading: false },\n },\n },\n humanReadableWarnings: [],\n };\n // *******************************************************************************************\n // \"options\" iteration\n // *******************************************************************************************\n // using \"every\" to short-circuit the iteration if we detect an unrecoverable issue\n options.every((option, index) => {\n mutableUpdateReportPerIteration({ mutableReport, option, index, parentDsId: '__first-level-root' });\n if (mutableReport.unrecoverableConversion) return false;\n return true;\n });\n mutableUpdateReportPostIteration({ mutableReport, options });\n mutableReport.humanReadableWarnings = getHumanReadableWarnings(mutableReport);\n return mutableReport;\n};\n\ntype CheckAndConvertOptionsRT = {\n convertedOptions: DSMenuButtonT.MenuItemInterface[];\n report: DSDropdownV2BridgeT.ReportMutableT;\n};\ntype GroupItemWithSubItems = DSMenuButtonT.GroupItem & { subitems: DSMenuButtonT.MenuItemInterface[] };\n\n/**\n * Converts dropdown menu items to menu button items, handling nested structures and grouping (including filling for missing groups if single selections are present).\n * @param options - The dropdown menu items to convert.\n * @returns The converted menu button items.\n */\nconst convertOptionsRecursive = (\n options: DSDropdownMenuT.Item[] | readonly DSDropdownMenuT.Item[],\n): DSMenuButtonT.MenuItemInterface[] => {\n const convertedOptions: DSMenuButtonT.MenuItemInterface[] = [];\n const groups: GroupItemWithSubItems[] = [];\n options.forEach((option) => {\n const convertedOption = convertDropdownItemToMenuButtonItem(option);\n if (isItemSingleWithSubmenuOptions(option) || isItemSubmenuOptions(option)) {\n // we need to iterate over the subitems found at option.options\n const subitems = convertOptionsRecursive(option.options);\n const typecastedOption = convertedOption as\n | DSMenuButtonT.WithSubmenuItem\n | DSMenuButtonT.SingleSelectWithSubmenuItem;\n typecastedOption.subitems = subitems;\n }\n // we need to unwind the sections\n // step 1 - if we encounter a new section, we start tracking a new group\n if (isItemSectionOptions(option)) {\n const typecastedOption = convertedOption as DSMenuButtonT.GroupItem;\n // step 2 - we assure subitems property is present as an array (per new API contract)\n const subitems = [...((typecastedOption as GroupItemWithSubItems).subitems ?? [])];\n // step 3 - we add the group to the groups array\n groups.push({ ...typecastedOption, subitems });\n return;\n }\n // here we can be in three scenarios:\n // A - a \"section\" is present and we are adding items to it\n if (groups.length > 0) {\n const lastGroup = groups[groups.length - 1];\n lastGroup.subitems.push(convertedOption);\n return;\n }\n // B - we encountered a single select without a \"section\" BUT there is no mixing with \"multi select\" and we need to fill a placeholder group\n if (option.type === 'single' || option.type === 'singleWithSubmenu') {\n groups.push({ type: 'group', subitems: [convertedOption], dsId: `filled-group-starting-from-${option.dsId}` });\n return;\n }\n // C - we are adding items to the root level\n convertedOptions.push(convertedOption);\n });\n convertedOptions.push(...groups);\n return convertedOptions;\n};\n\nexport const checkAndConvertOptions = (\n options: DSDropdownV2BridgeT.InternalProps['options'],\n): CheckAndConvertOptionsRT => {\n const report = checkIfOptionsCanBeConverted(options);\n if (report.unrecoverableConversion) throw new Error('DSDropdownV2Bridge - critical configuration issues');\n\n const convertedOptions: DSMenuButtonT.MenuItemInterface[] = convertOptionsRecursive(options);\n\n return { convertedOptions, report };\n};\n"],
5
+ "mappings": "AA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AAqB,MAAM,GAAG;AAChC,YAAM,mBAAmB;AAEzB,YAAM,WAAW,CAAC,GAAK,iBAA2C,YAAY,CAAC,CAAE;AAEjF,aAAO,KAAK,EAAE,GAAG,kBAAkB,SAAS,CAAC;AAC7C;AAAA,IACF;AAGA,QAAI,OAAO,SAAS,GAAG;AACrB,YAAM,YAAY,OAAO,OAAO,SAAS,CAAC;AAC1C,gBAAU,SAAS,KAAK,eAAe;AACvC;AAAA,IACF;AAEA,QAAI,OAAO,SAAS,YAAY,OAAO,SAAS,qBAAqB;AACnE,aAAO,KAAK,EAAE,MAAM,SAAS,UAAU,CAAC,eAAe,GAAG,MAAM,8BAA8B,OAAO,IAAI,GAAG,CAAC;AAC7G;AAAA,IACF;AAEA,qBAAiB,KAAK,eAAe;AAAA,EACvC,CAAC;AACD,mBAAiB,KAAK,GAAG,MAAM;AAC/B,SAAO;AACT;AAEO,MAAM,yBAAyB,CACpC,YAC6B;AAC7B,QAAM,SAAS,6BAA6B,OAAO;AACnD,MAAI,OAAO,wBAAyB,OAAM,IAAI,MAAM,oDAAoD;AAExG,QAAM,mBAAsD,wBAAwB,OAAO;AAE3F,SAAO,EAAE,kBAAkB,OAAO;AACpC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,69 @@
1
+ import * as React from "react";
2
+ const mutableUpdateReportPostIteration = (args) => {
3
+ const { mutableReport, option, options } = args;
4
+ let currentLevelReport = mutableReport.mutableReportsPerParentMap["__first-level-root"];
5
+ if (option !== void 0) {
6
+ currentLevelReport = mutableReport.mutableReportsPerParentMap[option.dsId];
7
+ currentLevelReport.hasEmptyOptions = (option.type === "submenu" || option.type === "singleWithSubmenu") && option.options.length === 0;
8
+ } else {
9
+ currentLevelReport.hasEmptyOptions = options?.length === 0;
10
+ }
11
+ currentLevelReport.isSingleWithoutMultipleAtAll = currentLevelReport.hasSingleSelections && !currentLevelReport.hasMultipleSelections;
12
+ currentLevelReport.requiresHierarchicalGrouping = Object.keys(currentLevelReport.adjacentGroupsReport).length > 0;
13
+ mutableReport.unrecoverableConversion = currentLevelReport.requiresHierarchicalGrouping;
14
+ currentLevelReport.gracefullRecoveries = {
15
+ fillGroupForSingleSelection: currentLevelReport.hasGrouplessSingleSelections && currentLevelReport.isSingleWithoutMultipleAtAll,
16
+ fillLoading: currentLevelReport.hasEmptyOptions
17
+ };
18
+ mutableReport.needsGracefullRecovery = Object.values(currentLevelReport.gracefullRecoveries).some((v) => v === true);
19
+ mutableReport.didFillGroupForSingleSelection = mutableReport.didFillGroupForSingleSelection || currentLevelReport.gracefullRecoveries.fillGroupForSingleSelection;
20
+ mutableReport.wasFilledWithSkeletonDueToEmptyArrays = mutableReport.wasFilledWithSkeletonDueToEmptyArrays || currentLevelReport.gracefullRecoveries.fillLoading;
21
+ };
22
+ const mutableUpdateReportPerIteration = (iteration) => {
23
+ const { mutableReport, option, index, parentDsId } = iteration;
24
+ if (option.type === "singleWithSubmenu" || option.type === "submenu") {
25
+ mutableReport.mutableReportsPerParentMap[option.dsId] = {
26
+ lastSectionIndex: void 0,
27
+ adjacentGroupsReport: [],
28
+ hasMultipleSelections: false,
29
+ hasSingleSelections: false,
30
+ hasGrouplessSingleSelections: false,
31
+ isSingleWithoutMultipleAtAll: false,
32
+ hasEmptyOptions: false,
33
+ requiresHierarchicalGrouping: false,
34
+ gracefullRecoveries: { fillGroupForSingleSelection: false, fillLoading: false }
35
+ };
36
+ option.options.every((subOption, subIndex) => {
37
+ mutableUpdateReportPerIteration({
38
+ mutableReport,
39
+ option: subOption,
40
+ index: subIndex,
41
+ parentDsId: option.dsId
42
+ });
43
+ if (mutableReport.unrecoverableConversion) return false;
44
+ return true;
45
+ });
46
+ mutableUpdateReportPostIteration({ mutableReport, option });
47
+ }
48
+ const currentLevelReport = mutableReport.mutableReportsPerParentMap[parentDsId];
49
+ if (option?.rightAddon === "ellipsis") mutableReport.detectedLostsOnConversion.ellipsis = true;
50
+ if (option?.render) mutableReport.detectedLostsOnConversion.render = true;
51
+ if (option.type === "section") {
52
+ if (currentLevelReport?.lastSectionIndex === index - 1) {
53
+ currentLevelReport.adjacentGroupsReport.push(option.dsId);
54
+ }
55
+ currentLevelReport.lastSectionIndex = index;
56
+ }
57
+ if (option.type === "single" || option.type === "singleWithSubmenu") {
58
+ currentLevelReport.hasSingleSelections = true;
59
+ if (currentLevelReport?.lastSectionIndex === void 0) {
60
+ currentLevelReport.hasGrouplessSingleSelections = true;
61
+ }
62
+ }
63
+ if (option.type === "checkbox") currentLevelReport.hasMultipleSelections = true;
64
+ };
65
+ export {
66
+ mutableUpdateReportPerIteration,
67
+ mutableUpdateReportPostIteration
68
+ };
69
+ //# sourceMappingURL=reportMutableUpdatesHelpers.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/exported-related/conversion-utils/reportMutableUpdatesHelpers.ts"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nimport { type DSDropdownMenuT } from '../../react-desc-prop-types.js';\nimport { type DSDropdownV2BridgeT } from './types.js';\n\n// *******************************************************************************************\n// other props related potential issues\n// *******************************************************************************************\n// Critical failure:\n// 1 - props.HeaderComp - We support text only as \"groups\" for A11y limitations,\n// it's a critical failure in the sense that we can't bridge it automatically\n// but developers should be able to recover manually\n// Potentially gracefully recoverables\n// 2 - props.isLoading - We can fill some skeletons items?\n// this function should be called after the \"options\" iteration and takes care of the post iteration report updates\nexport const mutableUpdateReportPostIteration = (args: {\n mutableReport: DSDropdownV2BridgeT.ReportMutableT;\n option?: DSDropdownMenuT.Item;\n options?: DSDropdownV2BridgeT.InternalProps['options'];\n}): void => {\n const { mutableReport, option, options } = args;\n // root level\n let currentLevelReport = mutableReport.mutableReportsPerParentMap['__first-level-root'];\n if (option !== undefined) {\n currentLevelReport = mutableReport.mutableReportsPerParentMap[option.dsId];\n currentLevelReport.hasEmptyOptions =\n (option.type === 'submenu' || option.type === 'singleWithSubmenu') && option.options.length === 0;\n } else {\n currentLevelReport.hasEmptyOptions = options?.length === 0;\n }\n\n currentLevelReport.isSingleWithoutMultipleAtAll =\n currentLevelReport.hasSingleSelections && !currentLevelReport.hasMultipleSelections;\n\n currentLevelReport.requiresHierarchicalGrouping = Object.keys(currentLevelReport.adjacentGroupsReport).length > 0;\n mutableReport.unrecoverableConversion = currentLevelReport.requiresHierarchicalGrouping;\n\n currentLevelReport.gracefullRecoveries = {\n fillGroupForSingleSelection:\n currentLevelReport.hasGrouplessSingleSelections && currentLevelReport.isSingleWithoutMultipleAtAll,\n fillLoading: currentLevelReport.hasEmptyOptions,\n };\n mutableReport.needsGracefullRecovery = Object.values(currentLevelReport.gracefullRecoveries).some((v) => v === true);\n mutableReport.didFillGroupForSingleSelection =\n mutableReport.didFillGroupForSingleSelection || currentLevelReport.gracefullRecoveries.fillGroupForSingleSelection;\n mutableReport.wasFilledWithSkeletonDueToEmptyArrays =\n mutableReport.wasFilledWithSkeletonDueToEmptyArrays || currentLevelReport.gracefullRecoveries.fillLoading;\n};\n\n// *******************************************************************************************\n// \"options\" related potential issues\n// *******************************************************************************************\n// Critical failure:\n// 1 - Two \"groups\" in a row\n// 2 - \"single select\" not preeceded by a \"group\"\n\n// Potentially gracefully recoverables:\n// 3 - single select without a \"group\" BUT there is no mix/match with \"multi select\"\n// - We can:\n// 1 - fill a placeholder group\n// 2 - move the single select to the top level (opinionated but options within a group should to be adjacent)\n// 4 - empty options - We can fill some skeletons items?\nexport const mutableUpdateReportPerIteration = (iteration: {\n mutableReport: DSDropdownV2BridgeT.ReportMutableT;\n option: DSDropdownMenuT.Item;\n index: number;\n parentDsId: string;\n}): void => {\n const { mutableReport, option, index, parentDsId } = iteration;\n // if we detect a single select with submenus OR a submenu, we need to generate a nested mutable report for it\n if (option.type === 'singleWithSubmenu' || option.type === 'submenu') {\n mutableReport.mutableReportsPerParentMap[option.dsId] = {\n lastSectionIndex: undefined,\n adjacentGroupsReport: [],\n hasMultipleSelections: false,\n hasSingleSelections: false,\n hasGrouplessSingleSelections: false,\n isSingleWithoutMultipleAtAll: false,\n hasEmptyOptions: false,\n requiresHierarchicalGrouping: false,\n gracefullRecoveries: { fillGroupForSingleSelection: false, fillLoading: false },\n };\n option.options.every((subOption, subIndex) => {\n mutableUpdateReportPerIteration({\n mutableReport,\n option: subOption,\n index: subIndex,\n parentDsId: option.dsId,\n });\n if (mutableReport.unrecoverableConversion) return false;\n\n return true;\n });\n mutableUpdateReportPostIteration({ mutableReport, option });\n }\n const currentLevelReport = mutableReport.mutableReportsPerParentMap[parentDsId];\n // @ts-expect-error - DDV2 doesn't offer typeguards and it's not the bridge's responsibility to enforce it\n if (option?.rightAddon === 'ellipsis') mutableReport.detectedLostsOnConversion.ellipsis = true;\n if (option?.render) mutableReport.detectedLostsOnConversion.render = true;\n if (option.type === 'section') {\n // Two \"groups\" in a row\n if (currentLevelReport?.lastSectionIndex === index - 1) {\n currentLevelReport.adjacentGroupsReport.push(option.dsId);\n }\n currentLevelReport.lastSectionIndex = index;\n }\n\n if (option.type === 'single' || option.type === 'singleWithSubmenu') {\n // single select without a \"section\" BUT there is no mixing with \"multi select\" - We can fill a placeholder section?\n currentLevelReport.hasSingleSelections = true;\n if (currentLevelReport?.lastSectionIndex === undefined) {\n currentLevelReport.hasGrouplessSingleSelections = true;\n }\n }\n if (option.type === 'checkbox') currentLevelReport.hasMultipleSelections = true;\n};\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACchB,MAAM,mCAAmC,CAAC,SAIrC;AACV,QAAM,EAAE,eAAe,QAAQ,QAAQ,IAAI;AAE3C,MAAI,qBAAqB,cAAc,2BAA2B,oBAAoB;AACtF,MAAI,WAAW,QAAW;AACxB,yBAAqB,cAAc,2BAA2B,OAAO,IAAI;AACzE,uBAAmB,mBAChB,OAAO,SAAS,aAAa,OAAO,SAAS,wBAAwB,OAAO,QAAQ,WAAW;AAAA,EACpG,OAAO;AACL,uBAAmB,kBAAkB,SAAS,WAAW;AAAA,EAC3D;A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Q,eAAc,0BAA0B,SAAS;AACrE,MAAI,OAAO,SAAS,WAAW;AAE7B,QAAI,oBAAoB,qBAAqB,QAAQ,GAAG;AACtD,yBAAmB,qBAAqB,KAAK,OAAO,IAAI;AAAA,IAC1D;AACA,uBAAmB,mBAAmB;AAAA,EACxC;AAEA,MAAI,OAAO,SAAS,YAAY,OAAO,SAAS,qBAAqB;AAEnE,uBAAmB,sBAAsB;AACzC,QAAI,oBAAoB,qBAAqB,QAAW;AACtD,yBAAmB,+BAA+B;AAAA,IACpD;AAAA,EACF;AACA,MAAI,OAAO,SAAS,WAAY,oBAAmB,wBAAwB;AAC7E;",
6
+ "names": []
7
+ }
@@ -0,0 +1,2 @@
1
+ import * as React from "react";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../../../scripts/build/transpile/react-shim.js"],
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;",
6
+ "names": []
7
+ }
package/dist/esm/index.js CHANGED
@@ -1,25 +1,31 @@
1
1
  import * as React from "react";
2
+ import { checkAndConvertOptions } from "./exported-related/conversion-utils/index.js";
2
3
  import { DSDropdownMenuV2, DSDropdownMenuV2WithSchema } from "./DSDropdownMenu.js";
3
- import { DSDropdownMenuName, DSDropdownMenuSlots, DSDropdownMenuPlacements } from "./exported-related/index.js";
4
+ import { DropdownMenuDataTestId } from "./DropdownMenuDataTestId.js";
5
+ import { DSDropdownMenuName, DSDropdownMenuPlacements, DSDropdownMenuSlots } from "./exported-related/index.js";
4
6
  import {
7
+ defaultProps,
8
+ DSDropdownMenuV2PropTypes,
5
9
  actionOptionSchema,
6
- singleOptionSchema,
7
10
  checkboxOptionSchema,
8
- submenuOptionSchema,
9
- singleWithSubmenuOptionSchema,
10
- separatorOptionSchema,
11
+ optionTypesSchemas,
11
12
  sectionOptionSchema,
12
- optionTypesSchemas
13
+ separatorOptionSchema,
14
+ singleOptionSchema,
15
+ singleWithSubmenuOptionSchema,
16
+ submenuOptionSchema
13
17
  } from "./react-desc-prop-types.js";
14
- import { DropdownMenuDataTestId } from "./DropdownMenuDataTestId.js";
15
18
  export {
16
19
  DSDropdownMenuName,
17
20
  DSDropdownMenuPlacements,
18
21
  DSDropdownMenuSlots,
19
22
  DSDropdownMenuV2,
23
+ defaultProps as DSDropdownMenuV2DefaultProps,
24
+ DSDropdownMenuV2PropTypes,
20
25
  DSDropdownMenuV2WithSchema,
21
26
  DropdownMenuDataTestId,
22
27
  actionOptionSchema,
28
+ checkAndConvertOptions,
23
29
  checkboxOptionSchema,
24
30
  optionTypesSchemas,
25
31
  sectionOptionSchema,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../scripts/build/transpile/react-shim.js", "../../src/index.tsx"],
4
- "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type {} from '@xstyled/system';\n\nexport { DSDropdownMenuV2, DSDropdownMenuV2WithSchema } from './DSDropdownMenu.js';\nexport { DSDropdownMenuName, DSDropdownMenuSlots, DSDropdownMenuPlacements } from './exported-related/index.js';\nexport {\n actionOptionSchema,\n singleOptionSchema,\n checkboxOptionSchema,\n submenuOptionSchema,\n singleWithSubmenuOptionSchema,\n separatorOptionSchema,\n sectionOptionSchema,\n optionTypesSchemas,\n} from './react-desc-prop-types.js';\nexport type { DSDropdownMenuT } from './react-desc-prop-types.js';\nexport { DropdownMenuDataTestId } from './DropdownMenuDataTestId.js';\n"],
5
- "mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,kBAAkB,kCAAkC;AAC7D,SAAS,oBAAoB,qBAAqB,gCAAgC;AAClF;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,8BAA8B;",
4
+ "sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import type {} from '@xstyled/system';\n\nexport { checkAndConvertOptions } from './exported-related/conversion-utils/index.js';\nexport { DSDropdownMenuV2, DSDropdownMenuV2WithSchema } from './DSDropdownMenu.js';\nexport { DropdownMenuDataTestId } from './DropdownMenuDataTestId.js';\nexport { DSDropdownMenuName, DSDropdownMenuPlacements, DSDropdownMenuSlots } from './exported-related/index.js';\nexport {\n defaultProps as DSDropdownMenuV2DefaultProps,\n DSDropdownMenuV2PropTypes,\n actionOptionSchema,\n checkboxOptionSchema,\n optionTypesSchemas,\n sectionOptionSchema,\n separatorOptionSchema,\n singleOptionSchema,\n singleWithSubmenuOptionSchema,\n submenuOptionSchema,\n} from './react-desc-prop-types.js';\nexport type { DSDropdownMenuT } from './react-desc-prop-types.js';\n"],
5
+ "mappings": "AAAA,YAAY,WAAW;ACEvB,SAAS,8BAA8B;AACvC,SAAS,kBAAkB,kCAAkC;AAC7D,SAAS,8BAA8B;AACvC,SAAS,oBAAoB,0BAA0B,2BAA2B;AAClF;AAAA,EACkB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,76 @@
1
+ import { type DSMenuButtonT } from '@elliemae/ds-menu-button';
2
+ import { type DSDropdownMenuT } from '../../react-desc-prop-types.js';
3
+ /**
4
+ * Type guard to check if the option is of type ItemSingleWithSubmenuOptions.
5
+ * @param option - The option to check.
6
+ * @returns True if the option is of type ItemSingleWithSubmenuOptions, false otherwise.
7
+ */
8
+ export declare const isItemSingleWithSubmenuOptions: (option: DSDropdownMenuT.Item) => option is DSDropdownMenuT.ItemSingleWithSubmenuOptions;
9
+ /**
10
+ * Type guard to check if the option is of type ItemSubmenuOptions.
11
+ * @param option - The option to check.
12
+ * @returns True if the option is of type ItemSubmenuOptions, false otherwise.
13
+ */
14
+ export declare const isItemSubmenuOptions: (option: DSDropdownMenuT.Item) => option is DSDropdownMenuT.ItemSubmenuOptions;
15
+ /**
16
+ * Type guard to check if the option is of type ItemSectionOptions.
17
+ * @param option - The option to check.
18
+ * @returns True if the option is of type ItemSectionOptions, false otherwise.
19
+ */
20
+ export declare const isItemSectionOptions: (option: DSDropdownMenuT.Item) => option is DSDropdownMenuT.ItemSectionOptions;
21
+ /**
22
+ * Converts ItemActionOptions to DSMenuButtonT.ActivableItem.
23
+ * @param option - The ItemActionOptions to convert.
24
+ * @returns The converted ActivableItem.
25
+ */
26
+ export declare const convertActionOptToMenuButtonItem: (option: DSDropdownMenuT.ItemActionOptions) => DSMenuButtonT.ActivableItem;
27
+ /**
28
+ * Converts ItemSingleOptions to DSMenuButtonT.SingleSelectItem.
29
+ * @param option - The ItemSingleWithSubmenuOptions to convert.
30
+ * @returns The converted SingleSelectWithSubmenuItem.
31
+ */
32
+ export declare const convertSingleSelectionOptToMenuButtonItem: (option: DSDropdownMenuT.ItemSingleOptions) => DSMenuButtonT.SingleSelectItem;
33
+ /**
34
+ * Converts ItemCheckboxOptions to DSMenuButtonT.MultipleSelectItem.
35
+ * @param option - The ItemCheckboxOptions to convert.
36
+ * @returns The converted MultipleSelectItem.
37
+ */
38
+ export declare const convertCheckboxOptToMenuButtonItem: (option: DSDropdownMenuT.ItemCheckboxOptions) => DSMenuButtonT.MultipleSelectItem;
39
+ /**
40
+ * Converts ItemSeparatorOptions to DSMenuButtonT.SeparatorItem.
41
+ * @param option - The ItemSeparatorOptions to convert.
42
+ * @returns The converted SeparatorItem.
43
+ */
44
+ export declare const convertSeparatorOptToMenuButtonItem: (option: DSDropdownMenuT.ItemSeparatorOptions) => DSMenuButtonT.SeparatorItem;
45
+ /**
46
+ * Converts ItemSectionOptions to DSMenuButtonT.GroupItem.
47
+ * @param option - The ItemSectionOptions to convert.
48
+ * @returns The converted GroupItem.
49
+ */
50
+ export declare const convertSectionOptToMenuButtonItem: (option: DSDropdownMenuT.ItemSectionOptions) => DSMenuButtonT.GroupItem;
51
+ /**
52
+ * Converts ItemSkeletonOptions to DSMenuButtonT.SkeletonItem.
53
+ * @param option - The ItemSkeletonOptions to convert.
54
+ * @returns The converted SkeletonItem.
55
+ */
56
+ export declare const convertSkeletonOptToMenuButtonItem: (option: DSDropdownMenuT.ItemSkeletonOptions) => DSMenuButtonT.SkeletonItem;
57
+ /**
58
+ * Converts ItemSingleWithSubmenuOptions to DSMenuButtonT.SingleSelectWithSubmenuItem.
59
+ * @param option - The ItemSingleWithSubmenuOptions to convert.
60
+ * @param convFn - The conversion function to convert nested options - required to avoid circular dependencies.
61
+ * @returns The converted SingleSelectWithSubmenuItem.
62
+ */
63
+ export declare const convertSingleWithSubmenuOptToMenuButtonItem: (option: DSDropdownMenuT.ItemSingleWithSubmenuOptions, convFn: (option: DSDropdownMenuT.Item) => DSMenuButtonT.MenuItemInterface) => DSMenuButtonT.SingleSelectWithSubmenuItem;
64
+ /**
65
+ * Converts ItemSubmenuOptions to DSMenuButtonT.WithSubmenuItem.
66
+ * @param option - The ItemSubmenuOptions to convert.
67
+ * @param convFn - The conversion function to convert nested options - required to avoid circular dependencies.
68
+ * @returns The converted WithSubmenuItem.
69
+ */
70
+ export declare const convertSubmenuOptToMenuButtonItem: (option: DSDropdownMenuT.ItemSubmenuOptions, convFn: (option: DSDropdownMenuT.Item) => DSMenuButtonT.MenuItemInterface) => DSMenuButtonT.WithSubmenuItem;
71
+ /**
72
+ * Converts a DSDropdownMenuT.Item to a DSMenuButtonT.MenuItemInterface.
73
+ * @param option - The DSDropdownMenuT.Item to convert.
74
+ * @returns The converted MenuItemInterface.
75
+ */
76
+ export declare const convertDropdownItemToMenuButtonItem: (option: DSDropdownMenuT.Item) => DSMenuButtonT.MenuItemInterface;
@@ -0,0 +1,7 @@
1
+ import { type DSDropdownV2BridgeT } from './types.js';
2
+ /**
3
+ * given the report, it will return a human readable list of warnings
4
+ * @param report - The report to get the warnings from.
5
+ * @returns A list of human readable warnings.
6
+ */
7
+ export declare const getHumanReadableWarnings: (report: DSDropdownV2BridgeT.ReportMutableT) => string[];
@@ -0,0 +1,9 @@
1
+ import { type DSMenuButtonT } from '@elliemae/ds-menu-button';
2
+ import { type DSDropdownV2BridgeT } from './types.js';
3
+ export declare const checkIfOptionsCanBeConverted: (options: DSDropdownV2BridgeT.InternalProps['options']) => DSDropdownV2BridgeT.ReportMutableT;
4
+ type CheckAndConvertOptionsRT = {
5
+ convertedOptions: DSMenuButtonT.MenuItemInterface[];
6
+ report: DSDropdownV2BridgeT.ReportMutableT;
7
+ };
8
+ export declare const checkAndConvertOptions: (options: DSDropdownV2BridgeT.InternalProps['options']) => CheckAndConvertOptionsRT;
9
+ export {};
@@ -0,0 +1,13 @@
1
+ import { type DSDropdownMenuT } from '../../react-desc-prop-types.js';
2
+ import { type DSDropdownV2BridgeT } from './types.js';
3
+ export declare const mutableUpdateReportPostIteration: (args: {
4
+ mutableReport: DSDropdownV2BridgeT.ReportMutableT;
5
+ option?: DSDropdownMenuT.Item;
6
+ options?: DSDropdownV2BridgeT.InternalProps['options'];
7
+ }) => void;
8
+ export declare const mutableUpdateReportPerIteration: (iteration: {
9
+ mutableReport: DSDropdownV2BridgeT.ReportMutableT;
10
+ option: DSDropdownMenuT.Item;
11
+ index: number;
12
+ parentDsId: string;
13
+ }) => void;
@@ -0,0 +1,37 @@
1
+ import type { DSDropdownMenuT } from '../../react-desc-prop-types.js';
2
+ export declare namespace DSDropdownV2BridgeT {
3
+ type AdjacentGroupsReportT = string[];
4
+ type GracefullRecoveriesT = {
5
+ fillGroupForSingleSelection: boolean;
6
+ fillLoading: boolean;
7
+ };
8
+ type DsIdToValueMapT = Record<string, unknown>;
9
+ type ReportPerLevelT = {
10
+ lastSectionIndex?: number;
11
+ adjacentGroupsReport: AdjacentGroupsReportT;
12
+ hasMultipleSelections: boolean;
13
+ hasSingleSelections: boolean;
14
+ hasGrouplessSingleSelections: boolean;
15
+ isSingleWithoutMultipleAtAll: boolean;
16
+ hasEmptyOptions: boolean;
17
+ requiresHierarchicalGrouping: boolean;
18
+ gracefullRecoveries: GracefullRecoveriesT;
19
+ };
20
+ type ReportMutableT = {
21
+ unrecoverableConversion: boolean;
22
+ needsGracefullRecovery: boolean;
23
+ wasFilledWithSkeletonDueToEmptyArrays: boolean;
24
+ didFillGroupForSingleSelection: boolean;
25
+ detectedLostsOnConversion: {
26
+ ellipsis: boolean;
27
+ render: boolean;
28
+ };
29
+ mutableReportsPerParentMap: Record<string, ReportPerLevelT>;
30
+ humanReadableWarnings: string[];
31
+ };
32
+ type RequiredProps = DSDropdownMenuT.RequiredProps;
33
+ type DefaultProps = DSDropdownMenuT.DefaultProps;
34
+ type OptionalProps = DSDropdownMenuT.OptionalProps;
35
+ type Props = DSDropdownMenuT.Props;
36
+ type InternalProps = DSDropdownMenuT.InternalProps;
37
+ }
@@ -1,5 +1,6 @@
1
+ export { checkAndConvertOptions } from './exported-related/conversion-utils/index.js';
1
2
  export { DSDropdownMenuV2, DSDropdownMenuV2WithSchema } from './DSDropdownMenu.js';
2
- export { DSDropdownMenuName, DSDropdownMenuSlots, DSDropdownMenuPlacements } from './exported-related/index.js';
3
- export { actionOptionSchema, singleOptionSchema, checkboxOptionSchema, submenuOptionSchema, singleWithSubmenuOptionSchema, separatorOptionSchema, sectionOptionSchema, optionTypesSchemas, } from './react-desc-prop-types.js';
4
- export type { DSDropdownMenuT } from './react-desc-prop-types.js';
5
3
  export { DropdownMenuDataTestId } from './DropdownMenuDataTestId.js';
4
+ export { DSDropdownMenuName, DSDropdownMenuPlacements, DSDropdownMenuSlots } from './exported-related/index.js';
5
+ export { defaultProps as DSDropdownMenuV2DefaultProps, DSDropdownMenuV2PropTypes, actionOptionSchema, checkboxOptionSchema, optionTypesSchemas, sectionOptionSchema, separatorOptionSchema, singleOptionSchema, singleWithSubmenuOptionSchema, submenuOptionSchema, } from './react-desc-prop-types.js';
6
+ export type { DSDropdownMenuT } from './react-desc-prop-types.js';