@g4rcez/components 0.2.6 → 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 +61 -46
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8676 -8415
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +61 -46
- package/dist/index.umd.js.map +1 -1
- package/dist/preset/preset.tailwind.d.ts +1 -1
- package/dist/preset/preset.tailwind.d.ts.map +1 -1
- package/dist/preset/preset.tailwind.js +1 -1
- package/dist/preset/src/styles/common.d.ts +1 -1
- package/dist/preset/src/styles/common.js +1 -1
- package/dist/preset/src/styles/dark.js +1 -1
- package/dist/preset/src/styles/light.js +1 -1
- package/dist/preset.tailwind.d.ts +1 -1
- package/dist/preset.tailwind.d.ts.map +1 -1
- package/dist/preset.tailwind.js +1 -1
- package/dist/src/components/core/polymorph.d.ts +1 -1
- package/dist/src/components/core/polymorph.d.ts.map +1 -1
- package/dist/src/components/core/tag.d.ts +20 -21
- 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.d.ts +4 -0
- package/dist/src/components/display/shortcut.d.ts.map +1 -0
- package/dist/src/components/display/shortcut.js +19 -0
- package/dist/src/components/floating/command-palette.d.ts +48 -0
- package/dist/src/components/floating/command-palette.d.ts.map +1 -0
- package/dist/src/components/floating/command-palette.js +157 -0
- package/dist/src/components/floating/menu.d.ts.map +1 -1
- package/dist/src/components/floating/menu.js +12 -15
- package/dist/src/components/floating/modal.d.ts +60 -3
- package/dist/src/components/floating/modal.d.ts.map +1 -1
- package/dist/src/components/floating/modal.js +18 -10
- package/dist/src/components/form/autocomplete.d.ts.map +1 -1
- package/dist/src/components/form/autocomplete.js +9 -5
- package/dist/src/components/form/multi-select.d.ts.map +1 -1
- package/dist/src/components/form/multi-select.js +7 -2
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/table/index.d.ts.map +1 -1
- package/dist/src/components/table/index.js +1 -1
- package/dist/src/config/context.d.ts.map +1 -1
- package/dist/src/config/default-translations.d.ts +38 -36
- package/dist/src/config/default-translations.d.ts.map +1 -1
- package/dist/src/config/default-translations.js +37 -35
- package/dist/src/constants.d.ts +1 -1
- package/dist/src/constants.js +1 -1
- package/dist/src/hooks/use-remove-scroll.js +5 -4
- package/dist/src/hooks/use-translations.d.ts +38 -36
- package/dist/src/hooks/use-translations.d.ts.map +1 -1
- package/dist/src/lib/combi-keys.d.ts +15 -0
- package/dist/src/lib/combi-keys.d.ts.map +1 -0
- package/dist/src/lib/combi-keys.js +60 -0
- 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/fns.d.ts.map +1 -1
- package/dist/src/lib/fzf.d.ts +16 -0
- package/dist/src/lib/fzf.d.ts.map +1 -0
- package/dist/src/lib/fzf.js +117 -0
- package/dist/src/styles/common.d.ts +1 -1
- package/dist/src/styles/common.js +1 -1
- package/dist/src/styles/dark.js +1 -1
- package/dist/src/styles/light.js +1 -1
- package/dist/src/types.d.ts +5 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +118 -120
|
@@ -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,13 +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
|
-
|
|
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;
|
|
56
58
|
};
|
|
57
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"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const osxRegex: RegExp;
|
|
2
|
+
export declare const isMac: () => boolean;
|
|
3
|
+
type Handler = (e: KeyboardEvent) => void;
|
|
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;
|
|
12
|
+
register(): () => void;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=combi-keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export const osxRegex = /Mac|iPod|iPhone|iPad/;
|
|
2
|
+
export const isMac = () => osxRegex.test(navigator.userAgent);
|
|
3
|
+
const parseCombination = (combination) => combination.split("+").map((k) => {
|
|
4
|
+
const key = k.trim();
|
|
5
|
+
if (key === "Mod")
|
|
6
|
+
return isMac() ? "Meta" : "Control";
|
|
7
|
+
if (key === "Hyper")
|
|
8
|
+
return isMac() ? "Meta+Shift+Alt" : "Control+Shift+Alt";
|
|
9
|
+
return key;
|
|
10
|
+
});
|
|
11
|
+
const combine = (keys) => keys.map((x) => x.trim()).join("+");
|
|
12
|
+
export class CombiKeys {
|
|
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
|
+
}
|
|
20
|
+
add(combi, fn) {
|
|
21
|
+
const key = combine(parseCombination(combi));
|
|
22
|
+
if (this.combinations.find((x) => x.key === key))
|
|
23
|
+
return;
|
|
24
|
+
this.combinations.push({ fn, key });
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
register() {
|
|
28
|
+
const controller = new AbortController();
|
|
29
|
+
const handler = (event) => {
|
|
30
|
+
const element = event.target;
|
|
31
|
+
if (element.tagName === "INPUT" || element.tagName === "TEXTAREA") {
|
|
32
|
+
const bypass = element.getAttribute("data-combikeysbypass");
|
|
33
|
+
if (bypass !== "true")
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const activeKeys = new Set();
|
|
37
|
+
if (event.metaKey)
|
|
38
|
+
activeKeys.add("Meta");
|
|
39
|
+
if (event.ctrlKey)
|
|
40
|
+
activeKeys.add("Control");
|
|
41
|
+
if (event.altKey)
|
|
42
|
+
activeKeys.add("Alt");
|
|
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);
|
|
49
|
+
const action = combine(Array.from(activeKeys));
|
|
50
|
+
this.combinations.forEach((bind) => {
|
|
51
|
+
if (bind.key === action) {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
return void bind.fn(event);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
window.addEventListener("keydown", handler, { signal: controller.signal });
|
|
58
|
+
return () => controller.abort();
|
|
59
|
+
}
|
|
60
|
+
}
|
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":"fns.d.ts","sourceRoot":"","sources":["../../../src/lib/fns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAI/B,eAAO,MAAM,IAAI,QAAO,MAUvB,CAAC;AAUF,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,oBAGzE,CAAC;AAEF,eAAO,MAAM,KAAK,eAAsC,CAAC;AAEzD,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,WAAkD,CAAC;AAE3F,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,MAAM,MAAM,UAQpD,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,GAAG,OAAO,YAAO,CAAC;AAEzC,eAAO,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"fns.d.ts","sourceRoot":"","sources":["../../../src/lib/fns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAI/B,eAAO,MAAM,IAAI,QAAO,MAUvB,CAAC;AAUF,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,GAAG,EAAE,CAAC,SAAS,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,oBAGzE,CAAC;AAEF,eAAO,MAAM,KAAK,eAAsC,CAAC;AAEzD,eAAO,MAAM,SAAS,GAAI,QAAQ,MAAM,WAAkD,CAAC;AAE3F,eAAO,MAAM,SAAS,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,EAAE,MAAM,MAAM,UAQpD,CAAC;AAEF,eAAO,MAAM,MAAM,GAAI,GAAG,OAAO,YAAO,CAAC;AAEzC,eAAO,MAAM,IAAI,YAAY,CAAC;AAE9B,eAAO,MAAM,QAAQ,eAGpB,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Any, Walk } from "../types";
|
|
2
|
+
export declare const fuzzyMatch: (text: string, search: string) => number | null;
|
|
3
|
+
export type Match = "EQUAL" | "CONTAINS" | "CONTAINS_NUMBERS" | "STARTS_WITH" | "ENDS_WITH" | "FUZZY";
|
|
4
|
+
export type MatchValue<T> = {
|
|
5
|
+
match?: Match;
|
|
6
|
+
score?: number;
|
|
7
|
+
key: Walk<T>;
|
|
8
|
+
value: string | string[];
|
|
9
|
+
ifNotMatch?: (value: string, source: string) => boolean;
|
|
10
|
+
};
|
|
11
|
+
export type Matcher<T> = {
|
|
12
|
+
match?: Match;
|
|
13
|
+
key: Walk<T>;
|
|
14
|
+
};
|
|
15
|
+
export declare const fzf: <T extends Any, ID extends Walk<T>>(items: T[], id: ID, keys: MatchValue<T>[]) => T[];
|
|
16
|
+
//# sourceMappingURL=fzf.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { Is } from "sidekicker";
|
|
2
|
+
export const fuzzyMatch = (text, search) => {
|
|
3
|
+
text = String(text).toLocaleLowerCase();
|
|
4
|
+
search = String(search).toLocaleLowerCase();
|
|
5
|
+
const firstChar = search[0];
|
|
6
|
+
const firstCharIndexes = text
|
|
7
|
+
.split("")
|
|
8
|
+
.map((char, index) => (char === firstChar ? index : false))
|
|
9
|
+
.filter((index) => index !== false);
|
|
10
|
+
if (firstCharIndexes.length === 0) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const matchedIndexes = [];
|
|
14
|
+
firstCharIndexes.forEach((startingIndex) => {
|
|
15
|
+
let index = startingIndex + 1;
|
|
16
|
+
const indexes = [startingIndex];
|
|
17
|
+
for (let i = 1; i < search.length; i++) {
|
|
18
|
+
const letter = search[i];
|
|
19
|
+
index = text.indexOf(letter, index);
|
|
20
|
+
if (index === -1) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
indexes.push(index);
|
|
24
|
+
index++;
|
|
25
|
+
}
|
|
26
|
+
matchedIndexes.push(indexes);
|
|
27
|
+
});
|
|
28
|
+
if (matchedIndexes.length === 0) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
const bestMatch = matchedIndexes.sort((a, b) => {
|
|
32
|
+
if (a.length === 1) {
|
|
33
|
+
return a[0] - b[0];
|
|
34
|
+
}
|
|
35
|
+
const aSpread = a[a.length - 1] - a[0];
|
|
36
|
+
const bSpread = b[b.length - 1] - b[0];
|
|
37
|
+
return aSpread - bSpread;
|
|
38
|
+
})[0];
|
|
39
|
+
if (text === search) {
|
|
40
|
+
return 1;
|
|
41
|
+
}
|
|
42
|
+
else if (bestMatch.length > 1) {
|
|
43
|
+
return 2 + (bestMatch[bestMatch.length - 1] - bestMatch[0]);
|
|
44
|
+
}
|
|
45
|
+
return 2 + bestMatch[0];
|
|
46
|
+
};
|
|
47
|
+
const travel = (path, regexp, obj) => {
|
|
48
|
+
const keys = path.split(regexp).filter(Boolean);
|
|
49
|
+
let res = obj;
|
|
50
|
+
for (const key of keys) {
|
|
51
|
+
if (res === null || res === undefined) {
|
|
52
|
+
return res;
|
|
53
|
+
}
|
|
54
|
+
res = res[key];
|
|
55
|
+
}
|
|
56
|
+
return res;
|
|
57
|
+
};
|
|
58
|
+
const regexPaths = { basic: /[,[\]]+?/, extend: /[,[\].]+?/ };
|
|
59
|
+
const path = (obj, path) => {
|
|
60
|
+
const result = travel(path, regexPaths.basic, obj);
|
|
61
|
+
if (result !== undefined && result !== obj)
|
|
62
|
+
return result;
|
|
63
|
+
return travel(path, regexPaths.extend, obj);
|
|
64
|
+
};
|
|
65
|
+
const onlyNumbers = (str) => str.replace(/[^0-9]/g, "");
|
|
66
|
+
const diacritics = (input) => input.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
67
|
+
const strCompare = (text, value, _, match = "FUZZY") => {
|
|
68
|
+
if (match === "CONTAINS") {
|
|
69
|
+
return text.includes(value);
|
|
70
|
+
}
|
|
71
|
+
if (match === "EQUAL") {
|
|
72
|
+
return text === value;
|
|
73
|
+
}
|
|
74
|
+
if (match === "CONTAINS_NUMBERS") {
|
|
75
|
+
return onlyNumbers(text).includes(onlyNumbers(value));
|
|
76
|
+
}
|
|
77
|
+
if (match === "STARTS_WITH") {
|
|
78
|
+
return text.startsWith(value);
|
|
79
|
+
}
|
|
80
|
+
if (match === "ENDS_WITH") {
|
|
81
|
+
return text.endsWith(value);
|
|
82
|
+
}
|
|
83
|
+
if (match === "FUZZY") {
|
|
84
|
+
const r = fuzzyMatch(text, value);
|
|
85
|
+
return r !== null;
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
};
|
|
89
|
+
const compare = (search, value, defaultScore, match = "FUZZY") => Array.isArray(value) ? value.some((x) => strCompare(search, x, defaultScore, match)) : strCompare(search, value, defaultScore, match);
|
|
90
|
+
export const fzf = (items, id, keys) => {
|
|
91
|
+
if (keys.length === 0) {
|
|
92
|
+
return items;
|
|
93
|
+
}
|
|
94
|
+
const map = new Map();
|
|
95
|
+
const remap = keys.map((x) => {
|
|
96
|
+
return { ...x, value: Is.array(x.value) ? x.value.map(diacritics) : diacritics(`${x.value}`) };
|
|
97
|
+
});
|
|
98
|
+
items.forEach((item) => {
|
|
99
|
+
const idVal = path(item, id);
|
|
100
|
+
remap.forEach((filter) => {
|
|
101
|
+
const searchValue = path(item, filter.key);
|
|
102
|
+
if (!searchValue)
|
|
103
|
+
return;
|
|
104
|
+
const target = diacritics(`${filter.value}`.toLocaleLowerCase()).trim();
|
|
105
|
+
const search = diacritics(`${searchValue}`.toLocaleLowerCase()).trim();
|
|
106
|
+
if (compare(search, target, filter.score, filter.match)) {
|
|
107
|
+
return void map.set(idVal, item);
|
|
108
|
+
}
|
|
109
|
+
if (Is.function(filter.ifNotMatch)) {
|
|
110
|
+
const result = filter.ifNotMatch(target, search);
|
|
111
|
+
if (result)
|
|
112
|
+
map.set(idVal, item);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
return Array.from(map.values());
|
|
117
|
+
};
|
package/dist/src/styles/dark.js
CHANGED
|
@@ -10,7 +10,7 @@ export const DARK_THEME = {
|
|
|
10
10
|
colors: {
|
|
11
11
|
foreground: "hsla(210, 50%, 98%)",
|
|
12
12
|
background: "hsla(0, 0%, 9%)",
|
|
13
|
-
muted: "hsla(
|
|
13
|
+
muted: "hsla(210, 10%, 40%)",
|
|
14
14
|
disabled: "hsla(240, 4%, 33%)",
|
|
15
15
|
emphasis: {
|
|
16
16
|
foreground: "hsla(251, 91%, 95%)",
|
package/dist/src/styles/light.js
CHANGED
|
@@ -26,7 +26,7 @@ export const LIGHT_THEME = {
|
|
|
26
26
|
},
|
|
27
27
|
secondary: {
|
|
28
28
|
background: "hsla(210, 25%, 35%)",
|
|
29
|
-
DEFAULT: "hsla(210, 25%,
|
|
29
|
+
DEFAULT: "hsla(210, 25%, 45%)",
|
|
30
30
|
subtle: "hsla(207, 29%, 39%)",
|
|
31
31
|
hover: "hsla(210, 21%, 67%)",
|
|
32
32
|
foreground: "hsla(210, 40%, 98%)",
|
package/dist/src/types.d.ts
CHANGED
|
@@ -18,4 +18,9 @@ export interface ReactComponent<P = Any> {
|
|
|
18
18
|
export type CvaVariants<T extends object> = {
|
|
19
19
|
[K in keyof T]?: keyof T[K];
|
|
20
20
|
};
|
|
21
|
+
type Irreducible = string | number | null | undefined | Date | symbol;
|
|
22
|
+
export type Walk<T> = T extends object ? {
|
|
23
|
+
[K in keyof T]: T[K] extends any[] ? K : K extends Irreducible ? T[K] extends object ? K | T[K] extends Date ? K : `${K & string}.${Walk<T[K]> & string}` : K : never;
|
|
24
|
+
}[keyof T] : never;
|
|
25
|
+
export {};
|
|
21
26
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAExE,MAAM,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,YAAY,GAAG,GAAG,CAAC,OAAO,CAAC;AAEvE,MAAM,MAAM,KAAK,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG,EAAE,CAAC;AAErD,MAAM,MAAM,QAAQ,CAAC,MAAM,EAAE,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,GAAG,GAAG,CAAC;AAElE,MAAM,MAAM,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtD,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAE1B,M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