@g4rcez/components 0.3.0 → 0.3.1
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/index.css +1 -1
- package/dist/index.js +53 -43
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5363 -5291
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +55 -45
- package/dist/index.umd.js.map +1 -1
- package/dist/preset/src/styles/common.d.ts +1 -1
- package/dist/preset/src/styles/common.js +1 -1
- package/dist/src/components/core/tag.d.ts +9 -10
- package/dist/src/components/core/tag.d.ts.map +1 -1
- package/dist/src/components/core/tag.js +20 -18
- package/dist/src/components/display/shortcut.js +5 -3
- package/dist/src/components/floating/command-palette.d.ts +18 -6
- package/dist/src/components/floating/command-palette.d.ts.map +1 -1
- package/dist/src/components/floating/command-palette.js +94 -76
- package/dist/src/components/floating/menu.d.ts.map +1 -1
- package/dist/src/components/floating/menu.js +12 -15
- package/dist/src/config/default-translations.d.ts +38 -37
- package/dist/src/config/default-translations.d.ts.map +1 -1
- package/dist/src/config/default-translations.js +37 -36
- package/dist/src/constants.d.ts +1 -1
- package/dist/src/constants.js +1 -1
- package/dist/src/hooks/use-translations.d.ts +38 -37
- package/dist/src/hooks/use-translations.d.ts.map +1 -1
- package/dist/src/lib/combi-keys.d.ts +9 -6
- package/dist/src/lib/combi-keys.d.ts.map +1 -1
- package/dist/src/lib/combi-keys.js +15 -3
- package/dist/src/lib/dict.d.ts +1 -0
- package/dist/src/lib/dict.d.ts.map +1 -1
- package/dist/src/lib/dict.js +3 -0
- package/dist/src/lib/fzf.d.ts.map +1 -1
- package/dist/src/lib/fzf.js +11 -14
- package/dist/src/styles/common.d.ts +1 -1
- package/dist/src/styles/common.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-translations.d.ts","sourceRoot":"","sources":["../../../src/config/default-translations.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,eAAO,MAAM,mBAAmB
|
|
1
|
+
{"version":3,"file":"default-translations.d.ts","sourceRoot":"","sources":["../../../src/config/default-translations.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AAExC,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAsCQ;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAA;KAAE;;;;;;;;;;;;;CAkBxI,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,mBAAmB,CAAC"}
|
|
@@ -1,53 +1,54 @@
|
|
|
1
1
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment } from "react";
|
|
3
3
|
export const defaultTranslations = {
|
|
4
|
+
autocompleteEmpty: "Nothing here...",
|
|
5
|
+
calendarBackMonth: "Back month",
|
|
6
|
+
calendarFromDate: "From",
|
|
7
|
+
calendarMonthLabel: "Month",
|
|
8
|
+
calendarNextMonth: "Next month",
|
|
9
|
+
calendarToDate: "To",
|
|
10
|
+
calendarToday: "Today",
|
|
11
|
+
commandPaletteEmpty: "Nothing here...",
|
|
12
|
+
commandPaletteLoading: "Loading...",
|
|
13
|
+
datePickerCalendarButtonLabel: "Click to open a date picker",
|
|
4
14
|
emptyDataMessage: "No data",
|
|
5
15
|
inputCaretDown: "Click to see all options",
|
|
6
16
|
inputCloseValue: "Click to clear the value",
|
|
7
|
-
datePickerCalendarButtonLabel: "Click to open a date picker",
|
|
8
17
|
inputOptionalLabel: "Optional",
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
tableGroupLabelWithCount: "Group",
|
|
12
|
-
tableSortAsc: "Ascending",
|
|
13
|
-
tableSortOrderByLabel: "Order by",
|
|
14
|
-
tableSortOrderInputPlaceholder: "Order by",
|
|
15
|
-
tableSortOrderInputTitle: "Order by",
|
|
16
|
-
tableSortTypeInputPlaceholder: "Ascending",
|
|
17
|
-
tableSortTypeInputTitle: "Sort type",
|
|
18
|
-
tableSortAddButton: "Add sort",
|
|
19
|
-
tableSortDropdownTitle: "Order by",
|
|
20
|
-
tableSortDesc: "Descending",
|
|
18
|
+
multiSelectInnerPlaceholder: "Search...",
|
|
19
|
+
multiSelectSelectedLabel: "Selected",
|
|
21
20
|
tableColumnResizer: "Resize column",
|
|
21
|
+
tableFilterColumnPlaceholder: "Filter by",
|
|
22
|
+
tableFilterColumnTitle: "Filter by",
|
|
23
|
+
tableFilterDropdownTitle: "Filters",
|
|
24
|
+
tableFilterDropdownTitleUnique: "Filter by",
|
|
25
|
+
tableFilterLabel: "Filters",
|
|
26
|
+
tableFilterNewFilter: "New filter",
|
|
27
|
+
tableFilterOperatorPlaceholder: "Equals to...",
|
|
28
|
+
tableFilterOperatorTitle: "Operation",
|
|
22
29
|
tableFilterTypeContains: "Contains",
|
|
30
|
+
tableFilterTypeEndsWith: "Ends with",
|
|
31
|
+
tableFilterTypeGreaterThan: "Greater than",
|
|
23
32
|
tableFilterTypeIs: "Is",
|
|
24
33
|
tableFilterTypeIsNot: "Is not",
|
|
25
|
-
tableFilterTypeNotContains: "Not contains",
|
|
26
34
|
tableFilterTypeLessThan: "Less than",
|
|
27
|
-
|
|
35
|
+
tableFilterTypeNotContains: "Not contains",
|
|
28
36
|
tableFilterTypeStartsWith: "Starts with",
|
|
29
|
-
tableFilterTypeEndsWith: "Ends with",
|
|
30
|
-
tableFilterNewFilter: "New filter",
|
|
31
|
-
tableFilterColumnTitle: "Filter by",
|
|
32
|
-
tableFilterColumnPlaceholder: "Filter by",
|
|
33
|
-
tableFilterOperatorTitle: "Operation",
|
|
34
|
-
tableFilterOperatorPlaceholder: "Equals to...",
|
|
35
|
-
tableFilterValueTitle: "Value",
|
|
36
37
|
tableFilterValuePlaceholder: "Something...",
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
tableFilterValueTitle: "Value",
|
|
39
|
+
tableGroupLabel: "Group",
|
|
40
|
+
tableGroupLabelWithCount: "Group",
|
|
41
|
+
tablePaginationFooter: (pagination) => (_jsxs(Fragment, { children: [pagination.current, " to ", pagination.pages, " of ", pagination.totalItems, " items.", Array.isArray(pagination.sizes) ? pagination.select : null, " ", "per page."] })),
|
|
41
42
|
tablePaginationNext: "Next",
|
|
43
|
+
tablePaginationPrevious: "Previous",
|
|
42
44
|
tablePaginationSelectLabel: "Select the size of page",
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
commandPaletteEmpty: "Nothing here...",
|
|
45
|
+
tableSortAddButton: "Add sort",
|
|
46
|
+
tableSortAsc: "Ascending",
|
|
47
|
+
tableSortDesc: "Descending",
|
|
48
|
+
tableSortDropdownTitle: "Order by",
|
|
49
|
+
tableSortOrderByLabel: "Order by",
|
|
50
|
+
tableSortOrderInputPlaceholder: "Order by",
|
|
51
|
+
tableSortOrderInputTitle: "Order by",
|
|
52
|
+
tableSortTypeInputPlaceholder: "Ascending",
|
|
53
|
+
tableSortTypeInputTitle: "Sort type",
|
|
53
54
|
};
|
package/dist/src/constants.d.ts
CHANGED
package/dist/src/constants.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const FLOATING_DELAY =
|
|
1
|
+
export const FLOATING_DELAY = 200;
|
|
2
2
|
export const TYPEAHEAD_RESET_DELAY = 500;
|
|
@@ -1,43 +1,41 @@
|
|
|
1
1
|
export declare const useTranslations: () => {
|
|
2
|
+
autocompleteEmpty: string;
|
|
3
|
+
calendarBackMonth: string;
|
|
4
|
+
calendarFromDate: string;
|
|
5
|
+
calendarMonthLabel: string;
|
|
6
|
+
calendarNextMonth: string;
|
|
7
|
+
calendarToDate: string;
|
|
8
|
+
calendarToday: string;
|
|
9
|
+
commandPaletteEmpty: string;
|
|
10
|
+
commandPaletteLoading: string;
|
|
11
|
+
datePickerCalendarButtonLabel: string;
|
|
2
12
|
emptyDataMessage: string;
|
|
3
13
|
inputCaretDown: string;
|
|
4
14
|
inputCloseValue: string;
|
|
5
|
-
datePickerCalendarButtonLabel: string;
|
|
6
15
|
inputOptionalLabel: string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
tableGroupLabelWithCount: string;
|
|
10
|
-
tableSortAsc: string;
|
|
11
|
-
tableSortOrderByLabel: string;
|
|
12
|
-
tableSortOrderInputPlaceholder: string;
|
|
13
|
-
tableSortOrderInputTitle: string;
|
|
14
|
-
tableSortTypeInputPlaceholder: string;
|
|
15
|
-
tableSortTypeInputTitle: string;
|
|
16
|
-
tableSortAddButton: string;
|
|
17
|
-
tableSortDropdownTitle: string;
|
|
18
|
-
tableSortDesc: string;
|
|
16
|
+
multiSelectInnerPlaceholder: string;
|
|
17
|
+
multiSelectSelectedLabel: string;
|
|
19
18
|
tableColumnResizer: string;
|
|
19
|
+
tableFilterColumnPlaceholder: string;
|
|
20
|
+
tableFilterColumnTitle: string;
|
|
21
|
+
tableFilterDropdownTitle: string;
|
|
22
|
+
tableFilterDropdownTitleUnique: string;
|
|
23
|
+
tableFilterLabel: string;
|
|
24
|
+
tableFilterNewFilter: string;
|
|
25
|
+
tableFilterOperatorPlaceholder: string;
|
|
26
|
+
tableFilterOperatorTitle: string;
|
|
20
27
|
tableFilterTypeContains: string;
|
|
28
|
+
tableFilterTypeEndsWith: string;
|
|
29
|
+
tableFilterTypeGreaterThan: string;
|
|
21
30
|
tableFilterTypeIs: string;
|
|
22
31
|
tableFilterTypeIsNot: string;
|
|
23
|
-
tableFilterTypeNotContains: string;
|
|
24
32
|
tableFilterTypeLessThan: string;
|
|
25
|
-
|
|
33
|
+
tableFilterTypeNotContains: string;
|
|
26
34
|
tableFilterTypeStartsWith: string;
|
|
27
|
-
tableFilterTypeEndsWith: string;
|
|
28
|
-
tableFilterNewFilter: string;
|
|
29
|
-
tableFilterColumnTitle: string;
|
|
30
|
-
tableFilterColumnPlaceholder: string;
|
|
31
|
-
tableFilterOperatorTitle: string;
|
|
32
|
-
tableFilterOperatorPlaceholder: string;
|
|
33
|
-
tableFilterValueTitle: string;
|
|
34
35
|
tableFilterValuePlaceholder: string;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
tablePaginationPrevious: string;
|
|
39
|
-
tablePaginationNext: string;
|
|
40
|
-
tablePaginationSelectLabel: string;
|
|
36
|
+
tableFilterValueTitle: string;
|
|
37
|
+
tableGroupLabel: string;
|
|
38
|
+
tableGroupLabelWithCount: string;
|
|
41
39
|
tablePaginationFooter: (pagination: {
|
|
42
40
|
pages: number;
|
|
43
41
|
totalItems: number;
|
|
@@ -45,14 +43,17 @@ export declare const useTranslations: () => {
|
|
|
45
43
|
current: number;
|
|
46
44
|
select: React.ReactNode;
|
|
47
45
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
46
|
+
tablePaginationNext: string;
|
|
47
|
+
tablePaginationPrevious: string;
|
|
48
|
+
tablePaginationSelectLabel: string;
|
|
49
|
+
tableSortAddButton: string;
|
|
50
|
+
tableSortAsc: string;
|
|
51
|
+
tableSortDesc: string;
|
|
52
|
+
tableSortDropdownTitle: string;
|
|
53
|
+
tableSortOrderByLabel: string;
|
|
54
|
+
tableSortOrderInputPlaceholder: string;
|
|
55
|
+
tableSortOrderInputTitle: string;
|
|
56
|
+
tableSortTypeInputPlaceholder: string;
|
|
57
|
+
tableSortTypeInputTitle: string;
|
|
57
58
|
};
|
|
58
59
|
//# sourceMappingURL=use-translations.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-translations.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-translations.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"use-translations.d.ts","sourceRoot":"","sources":["../../../src/hooks/use-translations.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAKs0C,CAAC;;;;;;;;;;;;;;;;CADl2C,CAAC"}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
export declare const osxRegex: RegExp;
|
|
1
2
|
export declare const isMac: () => boolean;
|
|
2
3
|
type Handler = (e: KeyboardEvent) => void;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
type Combi = {
|
|
5
|
+
key: string;
|
|
6
|
+
fn: Handler;
|
|
7
|
+
};
|
|
8
|
+
export declare class CombiKeys<T extends Combi> {
|
|
9
|
+
combinations: Combi[];
|
|
10
|
+
constructor(combi?: T[]);
|
|
11
|
+
add<S extends string, H extends Handler>(combi: S, fn: H): this | undefined;
|
|
9
12
|
register(): () => void;
|
|
10
13
|
}
|
|
11
14
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combi-keys.d.ts","sourceRoot":"","sources":["../../../src/lib/combi-keys.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"combi-keys.d.ts","sourceRoot":"","sources":["../../../src/lib/combi-keys.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ,QAAyB,CAAC;AAE/C,eAAO,MAAM,KAAK,eAA2C,CAAC;AAU9D,KAAK,OAAO,GAAG,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;AAI1C,KAAK,KAAK,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,OAAO,CAAA;CAAE,CAAC;AAE1C,qBAAa,SAAS,CAAC,CAAC,SAAS,KAAK;IAC3B,YAAY,EAAE,KAAK,EAAE,CAAM;gBAEf,KAAK,GAAE,CAAC,EAAO;IAO3B,GAAG,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;IAOxD,QAAQ;CA2BlB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const
|
|
2
|
-
export const isMac = () =>
|
|
1
|
+
export const osxRegex = /Mac|iPod|iPhone|iPad/;
|
|
2
|
+
export const isMac = () => osxRegex.test(navigator.userAgent);
|
|
3
3
|
const parseCombination = (combination) => combination.split("+").map((k) => {
|
|
4
4
|
const key = k.trim();
|
|
5
5
|
if (key === "Mod")
|
|
@@ -11,11 +11,18 @@ const parseCombination = (combination) => combination.split("+").map((k) => {
|
|
|
11
11
|
const combine = (keys) => keys.map((x) => x.trim()).join("+");
|
|
12
12
|
export class CombiKeys {
|
|
13
13
|
combinations = [];
|
|
14
|
+
constructor(combi = []) {
|
|
15
|
+
this.combinations = this.combinations.concat(combi);
|
|
16
|
+
this.combinations.forEach((x) => {
|
|
17
|
+
this.add(x.key, x.fn);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
14
20
|
add(combi, fn) {
|
|
15
21
|
const key = combine(parseCombination(combi));
|
|
16
22
|
if (this.combinations.find((x) => x.key === key))
|
|
17
23
|
return;
|
|
18
24
|
this.combinations.push({ fn, key });
|
|
25
|
+
return this;
|
|
19
26
|
}
|
|
20
27
|
register() {
|
|
21
28
|
const controller = new AbortController();
|
|
@@ -33,7 +40,12 @@ export class CombiKeys {
|
|
|
33
40
|
activeKeys.add("Control");
|
|
34
41
|
if (event.altKey)
|
|
35
42
|
activeKeys.add("Alt");
|
|
36
|
-
|
|
43
|
+
if (event.key.charCodeAt(0) > 127) {
|
|
44
|
+
const char = event.code.replace(/^Digit/, "").replace(/^Key/, "");
|
|
45
|
+
activeKeys.add(event.shiftKey ? char.toUpperCase() : char.toLowerCase());
|
|
46
|
+
}
|
|
47
|
+
else
|
|
48
|
+
activeKeys.add(event.shiftKey ? event.key.toUpperCase() : event.key);
|
|
37
49
|
const action = combine(Array.from(activeKeys));
|
|
38
50
|
this.combinations.forEach((bind) => {
|
|
39
51
|
if (bind.key === action) {
|
package/dist/src/lib/dict.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export declare class Dict<K, V> extends Map<K, V> {
|
|
|
5
5
|
remove(key: K): this;
|
|
6
6
|
map(callback: (v: V, i: number) => any): any[];
|
|
7
7
|
clone(fn?: (dict: Dict<K, V>) => Dict<K, V>): Dict<K, V>;
|
|
8
|
+
static unique<T>(items: T[], selector: (t: T) => any): T[];
|
|
8
9
|
}
|
|
9
10
|
//# sourceMappingURL=dict.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dict.d.ts","sourceRoot":"","sources":["../../../src/lib/dict.ts"],"names":[],"mappings":"AAAA,qBAAa,IAAI,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAgB;gBAET,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IAOxC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAM3B,MAAM,CAAC,GAAG,EAAE,CAAC;IAMb,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,GAAG;IAItC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"dict.d.ts","sourceRoot":"","sources":["../../../src/lib/dict.ts"],"names":[],"mappings":"AAAA,qBAAa,IAAI,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAgB;gBAET,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;IAOxC,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI;IAM3B,MAAM,CAAC,GAAG,EAAE,CAAC;IAMb,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,GAAG;IAItC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;WAMpC,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,GAAG;CAG9D"}
|
package/dist/src/lib/dict.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fzf.d.ts","sourceRoot":"","sources":["../../../src/lib/fzf.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fzf.d.ts","sourceRoot":"","sources":["../../../src/lib/fzf.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,EAAE,QAAQ,MAAM,KAAG,MAAM,GAAG,IA+ClE,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG,OAAO,GAAG,UAAU,GAAG,kBAAkB,GAAG,aAAa,GAAG,WAAW,GAAG,OAAO,CAAC;AAEtG,MAAM,MAAM,UAAU,CAAC,CAAC,IAAI;IACxB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACb,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC;CAC3D,CAAC;AAEF,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI;IAAE,KAAK,CAAC,EAAE,KAAK,CAAC;IAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC;AAoDzD,eAAO,MAAM,GAAG,GAAI,CAAC,SAAS,GAAG,EAAE,EAAE,SAAS,IAAI,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,MAAM,UAAU,CAAC,CAAC,CAAC,EAAE,QAyB/F,CAAC"}
|
package/dist/src/lib/fzf.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Is } from "sidekicker";
|
|
1
2
|
export const fuzzyMatch = (text, search) => {
|
|
2
3
|
text = String(text).toLocaleLowerCase();
|
|
3
4
|
search = String(search).toLocaleLowerCase();
|
|
@@ -85,34 +86,30 @@ const strCompare = (text, value, _, match = "FUZZY") => {
|
|
|
85
86
|
}
|
|
86
87
|
return false;
|
|
87
88
|
};
|
|
88
|
-
const compare = (search, value, defaultScore, match = "FUZZY") =>
|
|
89
|
-
if (Array.isArray(value)) {
|
|
90
|
-
return value.some((x) => strCompare(search, x, defaultScore, match));
|
|
91
|
-
}
|
|
92
|
-
return strCompare(search, value, defaultScore, match);
|
|
93
|
-
};
|
|
89
|
+
const compare = (search, value, defaultScore, match = "FUZZY") => Array.isArray(value) ? value.some((x) => strCompare(search, x, defaultScore, match)) : strCompare(search, value, defaultScore, match);
|
|
94
90
|
export const fzf = (items, id, keys) => {
|
|
95
91
|
if (keys.length === 0) {
|
|
96
92
|
return items;
|
|
97
93
|
}
|
|
98
94
|
const map = new Map();
|
|
99
|
-
const remap = keys.map((x) =>
|
|
100
|
-
...x,
|
|
101
|
-
|
|
102
|
-
}));
|
|
95
|
+
const remap = keys.map((x) => {
|
|
96
|
+
return { ...x, value: Is.array(x.value) ? x.value.map(diacritics) : diacritics(`${x.value}`) };
|
|
97
|
+
});
|
|
103
98
|
items.forEach((item) => {
|
|
104
99
|
const idVal = path(item, id);
|
|
105
100
|
remap.forEach((filter) => {
|
|
106
101
|
const searchValue = path(item, filter.key);
|
|
107
102
|
if (!searchValue)
|
|
108
103
|
return;
|
|
109
|
-
const search = diacritics(`${searchValue}`.toLocaleLowerCase()).trim();
|
|
110
104
|
const target = diacritics(`${filter.value}`.toLocaleLowerCase()).trim();
|
|
105
|
+
const search = diacritics(`${searchValue}`.toLocaleLowerCase()).trim();
|
|
111
106
|
if (compare(search, target, filter.score, filter.match)) {
|
|
112
|
-
map.set(idVal, item);
|
|
107
|
+
return void map.set(idVal, item);
|
|
113
108
|
}
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
if (Is.function(filter.ifNotMatch)) {
|
|
110
|
+
const result = filter.ifNotMatch(target, search);
|
|
111
|
+
if (result)
|
|
112
|
+
map.set(idVal, item);
|
|
116
113
|
}
|
|
117
114
|
});
|
|
118
115
|
});
|