@natoora-libs/core 0.2.26 → 0.2.27-dev-doug-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-3UDYWCV6.js +67 -0
- package/dist/chunk-3UDYWCV6.js.map +1 -0
- package/dist/components/index.cjs +63 -1
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.js +19 -3
- package/dist/components/index.js.map +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/index.cjs +49 -2
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +13 -1
- package/dist/utils/index.d.ts +13 -1
- package/dist/utils/index.js +5 -3
- package/package.json +3 -3
- package/dist/chunk-N3IUZVB7.js +0 -21
- package/dist/chunk-N3IUZVB7.js.map +0 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// src/utils/getSelectOptionFromKeyPress/getSelectOptionFromKeyPress.ts
|
|
2
|
+
var getNextCircularIndex = ({
|
|
3
|
+
isArrowUp,
|
|
4
|
+
currentIndex,
|
|
5
|
+
numOptions,
|
|
6
|
+
iteration
|
|
7
|
+
}) => {
|
|
8
|
+
const step = isArrowUp ? -iteration : iteration;
|
|
9
|
+
return (currentIndex + step + numOptions) % numOptions;
|
|
10
|
+
};
|
|
11
|
+
var getSelectOptionFromKeyPress = ({
|
|
12
|
+
key,
|
|
13
|
+
options,
|
|
14
|
+
currentValue
|
|
15
|
+
}) => {
|
|
16
|
+
const numOptions = options.length;
|
|
17
|
+
const isArrowUp = key === "ArrowUp";
|
|
18
|
+
const isArrowDown = key === "ArrowDown";
|
|
19
|
+
const isArrow = isArrowUp || isArrowDown;
|
|
20
|
+
const searchKey = key.toLowerCase();
|
|
21
|
+
if (!isArrow && searchKey.length !== 1) {
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
if (!numOptions) {
|
|
25
|
+
return void 0;
|
|
26
|
+
}
|
|
27
|
+
const currentIndex = options.findIndex((o) => o.value === currentValue);
|
|
28
|
+
const indicesToCheck = Array.from({ length: numOptions }).map(
|
|
29
|
+
(_, i) => getNextCircularIndex({
|
|
30
|
+
isArrowUp,
|
|
31
|
+
currentIndex,
|
|
32
|
+
numOptions,
|
|
33
|
+
iteration: i + 1
|
|
34
|
+
})
|
|
35
|
+
);
|
|
36
|
+
const nextMatchIndex = indicesToCheck.find((indexToCheck) => {
|
|
37
|
+
const option = options[indexToCheck];
|
|
38
|
+
return !option.disabled && (isArrow || option.label?.toLowerCase().startsWith(searchKey));
|
|
39
|
+
});
|
|
40
|
+
if (nextMatchIndex !== void 0 && nextMatchIndex !== currentIndex) {
|
|
41
|
+
return options[nextMatchIndex];
|
|
42
|
+
}
|
|
43
|
+
return void 0;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// src/utils/flattenTableFilters/flattenTableFilters.ts
|
|
47
|
+
var getFlattenedFiltersLabels = (filters, fieldName) => {
|
|
48
|
+
return filters.map((value) => {
|
|
49
|
+
if (typeof value === "object") {
|
|
50
|
+
return value[fieldName] ?? "";
|
|
51
|
+
}
|
|
52
|
+
return value;
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
var getFlattenedFiltersIds = (filters) => Object.fromEntries(
|
|
56
|
+
Object.entries(filters).map(([id, values]) => [
|
|
57
|
+
id,
|
|
58
|
+
values.map((value) => typeof value === "object" ? value.id : value)
|
|
59
|
+
])
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
export {
|
|
63
|
+
getSelectOptionFromKeyPress,
|
|
64
|
+
getFlattenedFiltersLabels,
|
|
65
|
+
getFlattenedFiltersIds
|
|
66
|
+
};
|
|
67
|
+
//# sourceMappingURL=chunk-3UDYWCV6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils/getSelectOptionFromKeyPress/getSelectOptionFromKeyPress.ts","../src/utils/flattenTableFilters/flattenTableFilters.ts"],"sourcesContent":["export interface NavigableOption {\n value?: string | number | null;\n label?: string;\n disabled?: boolean;\n}\n\nexport interface GetSelectOptionFromKeyPressParams<T extends NavigableOption> {\n key: string;\n options: T[];\n currentValue?: string | number | null;\n}\n\nconst getNextCircularIndex = ({\n isArrowUp,\n currentIndex,\n numOptions,\n iteration,\n}: {\n isArrowUp: boolean;\n currentIndex: number;\n numOptions: number;\n iteration: number;\n}) => {\n const step = isArrowUp ? -iteration : iteration;\n return (currentIndex + step + numOptions) % numOptions;\n};\n\nexport const getSelectOptionFromKeyPress = <T extends NavigableOption>({\n key,\n options,\n currentValue,\n}: GetSelectOptionFromKeyPressParams<T>): T | undefined => {\n const numOptions = options.length;\n const isArrowUp = key === 'ArrowUp';\n const isArrowDown = key === 'ArrowDown';\n const isArrow = isArrowUp || isArrowDown;\n const searchKey = key.toLowerCase();\n\n // Ignores any input that is not ArrowUp, ArrowDown or a single character.\n if (!isArrow && searchKey.length !== 1) {\n return undefined;\n }\n\n if (!numOptions) {\n return undefined;\n }\n\n const currentIndex = options.findIndex((o) => o.value === currentValue);\n\n // Generates a circular sequence of indices starting from the next item.\n // This ensures that pressing the same key repeatedly cycles through all matching options.\n const indicesToCheck = Array.from({ length: numOptions }).map((_, i) =>\n getNextCircularIndex({\n isArrowUp,\n currentIndex,\n numOptions,\n iteration: i + 1,\n }),\n );\n\n const nextMatchIndex = indicesToCheck.find((indexToCheck) => {\n const option = options[indexToCheck];\n return (\n !option.disabled &&\n (isArrow || option.label?.toLowerCase().startsWith(searchKey))\n );\n });\n\n if (nextMatchIndex !== undefined && nextMatchIndex !== currentIndex) {\n return options[nextMatchIndex];\n }\n\n return undefined;\n};\n","import {\n HeaderFilterObject,\n HeaderFilters,\n} from '@/components/TableDesktop/TableDesktop';\n\nexport type FlattenedFilterIds = {\n [key: string]: (string | number)[];\n};\n\nexport const getFlattenedFiltersLabels = (\n filters: string[] | HeaderFilterObject[],\n fieldName: string,\n): (string | number)[] => {\n return filters.map((value: string | HeaderFilterObject) => {\n if (typeof value === 'object') {\n return value[fieldName] ?? '';\n }\n return value;\n });\n};\n\nexport const getFlattenedFiltersIds = (\n filters: HeaderFilters,\n): FlattenedFilterIds =>\n Object.fromEntries(\n Object.entries(filters).map(([id, values]) => [\n id,\n values.map((value) => (typeof value === 'object' ? value.id : value)),\n ]),\n );\n"],"mappings":";AAYA,IAAM,uBAAuB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAKM;AACJ,QAAM,OAAO,YAAY,CAAC,YAAY;AACtC,UAAQ,eAAe,OAAO,cAAc;AAC9C;AAEO,IAAM,8BAA8B,CAA4B;AAAA,EACrE;AAAA,EACA;AAAA,EACA;AACF,MAA2D;AACzD,QAAM,aAAa,QAAQ;AAC3B,QAAM,YAAY,QAAQ;AAC1B,QAAM,cAAc,QAAQ;AAC5B,QAAM,UAAU,aAAa;AAC7B,QAAM,YAAY,IAAI,YAAY;AAGlC,MAAI,CAAC,WAAW,UAAU,WAAW,GAAG;AACtC,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,YAAY;AACf,WAAO;AAAA,EACT;AAEA,QAAM,eAAe,QAAQ,UAAU,CAAC,MAAM,EAAE,UAAU,YAAY;AAItE,QAAM,iBAAiB,MAAM,KAAK,EAAE,QAAQ,WAAW,CAAC,EAAE;AAAA,IAAI,CAAC,GAAG,MAChE,qBAAqB;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,MACA,WAAW,IAAI;AAAA,IACjB,CAAC;AAAA,EACH;AAEA,QAAM,iBAAiB,eAAe,KAAK,CAAC,iBAAiB;AAC3D,UAAM,SAAS,QAAQ,YAAY;AACnC,WACE,CAAC,OAAO,aACP,WAAW,OAAO,OAAO,YAAY,EAAE,WAAW,SAAS;AAAA,EAEhE,CAAC;AAED,MAAI,mBAAmB,UAAa,mBAAmB,cAAc;AACnE,WAAO,QAAQ,cAAc;AAAA,EAC/B;AAEA,SAAO;AACT;;;AChEO,IAAM,4BAA4B,CACvC,SACA,cACwB;AACxB,SAAO,QAAQ,IAAI,CAAC,UAAuC;AACzD,QAAI,OAAO,UAAU,UAAU;AAC7B,aAAO,MAAM,SAAS,KAAK;AAAA,IAC7B;AACA,WAAO;AAAA,EACT,CAAC;AACH;AAEO,IAAM,yBAAyB,CACpC,YAEA,OAAO;AAAA,EACL,OAAO,QAAQ,OAAO,EAAE,IAAI,CAAC,CAAC,IAAI,MAAM,MAAM;AAAA,IAC5C;AAAA,IACA,OAAO,IAAI,CAAC,UAAW,OAAO,UAAU,WAAW,MAAM,KAAK,KAAM;AAAA,EACtE,CAAC;AACH;","names":[]}
|
|
@@ -972,6 +972,53 @@ var PhoneInput = ({
|
|
|
972
972
|
// src/components/SmartSelect/SmartSelect.tsx
|
|
973
973
|
var import_react3 = require("react");
|
|
974
974
|
var import_material5 = require("@mui/material");
|
|
975
|
+
|
|
976
|
+
// src/utils/getSelectOptionFromKeyPress/getSelectOptionFromKeyPress.ts
|
|
977
|
+
var getNextCircularIndex = ({
|
|
978
|
+
isArrowUp,
|
|
979
|
+
currentIndex,
|
|
980
|
+
numOptions,
|
|
981
|
+
iteration
|
|
982
|
+
}) => {
|
|
983
|
+
const step = isArrowUp ? -iteration : iteration;
|
|
984
|
+
return (currentIndex + step + numOptions) % numOptions;
|
|
985
|
+
};
|
|
986
|
+
var getSelectOptionFromKeyPress = ({
|
|
987
|
+
key,
|
|
988
|
+
options,
|
|
989
|
+
currentValue
|
|
990
|
+
}) => {
|
|
991
|
+
const numOptions = options.length;
|
|
992
|
+
const isArrowUp = key === "ArrowUp";
|
|
993
|
+
const isArrowDown = key === "ArrowDown";
|
|
994
|
+
const isArrow = isArrowUp || isArrowDown;
|
|
995
|
+
const searchKey = key.toLowerCase();
|
|
996
|
+
if (!isArrow && searchKey.length !== 1) {
|
|
997
|
+
return void 0;
|
|
998
|
+
}
|
|
999
|
+
if (!numOptions) {
|
|
1000
|
+
return void 0;
|
|
1001
|
+
}
|
|
1002
|
+
const currentIndex = options.findIndex((o) => o.value === currentValue);
|
|
1003
|
+
const indicesToCheck = Array.from({ length: numOptions }).map(
|
|
1004
|
+
(_, i) => getNextCircularIndex({
|
|
1005
|
+
isArrowUp,
|
|
1006
|
+
currentIndex,
|
|
1007
|
+
numOptions,
|
|
1008
|
+
iteration: i + 1
|
|
1009
|
+
})
|
|
1010
|
+
);
|
|
1011
|
+
const nextMatchIndex = indicesToCheck.find((indexToCheck) => {
|
|
1012
|
+
const option = options[indexToCheck];
|
|
1013
|
+
return !option.disabled && (isArrow || option.label?.toLowerCase().startsWith(searchKey));
|
|
1014
|
+
});
|
|
1015
|
+
if (nextMatchIndex !== void 0 && nextMatchIndex !== currentIndex) {
|
|
1016
|
+
return options[nextMatchIndex];
|
|
1017
|
+
}
|
|
1018
|
+
return void 0;
|
|
1019
|
+
};
|
|
1020
|
+
|
|
1021
|
+
// src/components/SmartSelect/SmartSelect.tsx
|
|
975
1022
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
976
1023
|
var SmartSelect = (0, import_react3.forwardRef)(
|
|
977
1024
|
({
|
|
@@ -1017,6 +1064,20 @@ var SmartSelect = (0, import_react3.forwardRef)(
|
|
|
1017
1064
|
onChange(selectedOption);
|
|
1018
1065
|
}
|
|
1019
1066
|
};
|
|
1067
|
+
const handleKeyDown = (event) => {
|
|
1068
|
+
if (event.ctrlKey || event.altKey || event.metaKey) {
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
const nextOption = getSelectOptionFromKeyPress({
|
|
1072
|
+
key: event.key,
|
|
1073
|
+
options: visibleOptions,
|
|
1074
|
+
currentValue: value
|
|
1075
|
+
});
|
|
1076
|
+
if (nextOption) {
|
|
1077
|
+
event.preventDefault();
|
|
1078
|
+
onChange(nextOption);
|
|
1079
|
+
}
|
|
1080
|
+
};
|
|
1020
1081
|
const renderMenuContent = () => {
|
|
1021
1082
|
if (isFetching) {
|
|
1022
1083
|
return [
|
|
@@ -1089,6 +1150,7 @@ var SmartSelect = (0, import_react3.forwardRef)(
|
|
|
1089
1150
|
value: value ?? "",
|
|
1090
1151
|
onChange: handleChange,
|
|
1091
1152
|
onOpen: handleOpen,
|
|
1153
|
+
onKeyDown: handleKeyDown,
|
|
1092
1154
|
label: inputLabel,
|
|
1093
1155
|
MenuProps: menuProps,
|
|
1094
1156
|
children: renderMenuContent()
|
|
@@ -1701,7 +1763,7 @@ var AppliedTableFiltersDisplay = ({
|
|
|
1701
1763
|
var import_Check2 = __toESM(require("@mui/icons-material/Check"), 1);
|
|
1702
1764
|
var import_material15 = require("@mui/material");
|
|
1703
1765
|
|
|
1704
|
-
// src/utils/resolveObjectType.ts
|
|
1766
|
+
// src/utils/resolveObjectType/resolveObjectType.ts
|
|
1705
1767
|
var resolveObjectType = (object, fieldName) => {
|
|
1706
1768
|
if (!object || typeof object !== "object") {
|
|
1707
1769
|
return object;
|