@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.
Files changed (36) hide show
  1. package/dist/index.css +1 -1
  2. package/dist/index.js +53 -43
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +5363 -5291
  5. package/dist/index.mjs.map +1 -1
  6. package/dist/index.umd.js +55 -45
  7. package/dist/index.umd.js.map +1 -1
  8. package/dist/preset/src/styles/common.d.ts +1 -1
  9. package/dist/preset/src/styles/common.js +1 -1
  10. package/dist/src/components/core/tag.d.ts +9 -10
  11. package/dist/src/components/core/tag.d.ts.map +1 -1
  12. package/dist/src/components/core/tag.js +20 -18
  13. package/dist/src/components/display/shortcut.js +5 -3
  14. package/dist/src/components/floating/command-palette.d.ts +18 -6
  15. package/dist/src/components/floating/command-palette.d.ts.map +1 -1
  16. package/dist/src/components/floating/command-palette.js +94 -76
  17. package/dist/src/components/floating/menu.d.ts.map +1 -1
  18. package/dist/src/components/floating/menu.js +12 -15
  19. package/dist/src/config/default-translations.d.ts +38 -37
  20. package/dist/src/config/default-translations.d.ts.map +1 -1
  21. package/dist/src/config/default-translations.js +37 -36
  22. package/dist/src/constants.d.ts +1 -1
  23. package/dist/src/constants.js +1 -1
  24. package/dist/src/hooks/use-translations.d.ts +38 -37
  25. package/dist/src/hooks/use-translations.d.ts.map +1 -1
  26. package/dist/src/lib/combi-keys.d.ts +9 -6
  27. package/dist/src/lib/combi-keys.d.ts.map +1 -1
  28. package/dist/src/lib/combi-keys.js +15 -3
  29. package/dist/src/lib/dict.d.ts +1 -0
  30. package/dist/src/lib/dict.d.ts.map +1 -1
  31. package/dist/src/lib/dict.js +3 -0
  32. package/dist/src/lib/fzf.d.ts.map +1 -1
  33. package/dist/src/lib/fzf.js +11 -14
  34. package/dist/src/styles/common.d.ts +1 -1
  35. package/dist/src/styles/common.js +1 -1
  36. 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wCAgDQ;QAChC,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,KAAK,CAAC,SAAS,CAAA;KAC1B;;;;;;;;;;CAiBJ,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,OAAO,mBAAmB,CAAC"}
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
- autocompleteEmpty: "Nothing here...",
10
- tableGroupLabel: "Group",
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
- tableFilterTypeGreaterThan: "Greater than",
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
- tableFilterLabel: "Filters",
38
- tableFilterDropdownTitle: "Filters",
39
- tableFilterDropdownTitleUnique: "Filter by",
40
- tablePaginationPrevious: "Previous",
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
- tablePaginationFooter: (pagination) => (_jsxs(Fragment, { children: [pagination.current, " to ", pagination.pages, " of ", pagination.totalItems, " items.", Array.isArray(pagination.sizes) ? pagination.select : null, " per page."] })),
44
- calendarFromDate: "From",
45
- calendarToDate: "To",
46
- calendarToday: "Today",
47
- calendarBackMonth: "Back month",
48
- calendarNextMonth: "Next month",
49
- calendarMonthLabel: "Month",
50
- multiSelectSelectedLabel: "Selected",
51
- multiSelectInnerPlaceholder: "Search...",
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
  };
@@ -1,3 +1,3 @@
1
- export declare const FLOATING_DELAY = 300;
1
+ export declare const FLOATING_DELAY = 200;
2
2
  export declare const TYPEAHEAD_RESET_DELAY = 500;
3
3
  //# sourceMappingURL=constants.d.ts.map
@@ -1,2 +1,2 @@
1
- export const FLOATING_DELAY = 300;
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
- autocompleteEmpty: string;
8
- tableGroupLabel: string;
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
- tableFilterTypeGreaterThan: string;
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
- tableFilterLabel: string;
36
- tableFilterDropdownTitle: string;
37
- tableFilterDropdownTitleUnique: string;
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
- calendarFromDate: string;
49
- calendarToDate: string;
50
- calendarToday: string;
51
- calendarBackMonth: string;
52
- calendarNextMonth: string;
53
- calendarMonthLabel: string;
54
- multiSelectSelectedLabel: string;
55
- multiSelectInnerPlaceholder: string;
56
- commandPaletteEmpty: string;
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAKs+C,CAAC;;;;;;;;;;;;;CADlgD,CAAC"}
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
- export declare class CombiKeys {
4
- combinations: Array<{
5
- key: string;
6
- fn: Handler;
7
- }>;
8
- add<S extends string>(combi: S, fn: Handler): 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;
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":"AAEA,eAAO,MAAM,KAAK,eAAsC,CAAC;AAUzD,KAAK,OAAO,GAAG,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,CAAC;AAI1C,qBAAa,SAAS;IACX,YAAY,EAAE,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,OAAO,CAAA;KAAE,CAAC,CAAM;IAEvD,GAAG,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO;IAM3C,QAAQ;CAwBlB"}
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 osx = /Mac|iPod|iPhone|iPad/;
2
- export const isMac = () => osx.test(navigator.userAgent);
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
- activeKeys.add(event.shiftKey ? event.key.toUpperCase() : event.key);
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) {
@@ -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,EAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,EAAC,CAAC,CAAC;CAKnD"}
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"}
@@ -27,4 +27,7 @@ export class Dict extends Map {
27
27
  return fn(clone);
28
28
  return clone;
29
29
  }
30
+ static unique(items, selector) {
31
+ return Array.from(new Map(items.map((x) => [selector(x), x])).values());
32
+ }
30
33
  }
@@ -1 +1 @@
1
- {"version":3,"file":"fzf.d.ts","sourceRoot":"","sources":["../../../src/lib/fzf.ts"],"names":[],"mappings":"AAAA,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;AAwDzD,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,QAwB/F,CAAC"}
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"}
@@ -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
- value: Array.isArray(x.value) ? x.value.map(diacritics) : diacritics(`${x.value}`),
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
- else if (filter.ifNotMatch && filter.ifNotMatch(search, target)) {
115
- map.set(idVal, item);
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
  });
@@ -7,7 +7,7 @@ export declare const rounded: {
7
7
  };
8
8
  export declare const spacing: {
9
9
  readonly base: "1rem";
10
- readonly lg: "1.5rem";
10
+ readonly lg: "1.125rem";
11
11
  readonly sm: "0.75rem";
12
12
  readonly "field-height": "1.5rem";
13
13
  readonly "field-label": "1.875rem";
@@ -6,7 +6,7 @@ export const rounded = {
6
6
  };
7
7
  export const spacing = {
8
8
  base: "1rem",
9
- lg: "1.5rem",
9
+ lg: "1.125rem",
10
10
  sm: "0.75rem",
11
11
  "field-height": "1.5rem",
12
12
  "field-label": "1.875rem",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@g4rcez/components",
3
3
  "description": "Customizable react components.",
4
- "version": "0.3.0",
4
+ "version": "0.3.1",
5
5
  "sideEffects": false,
6
6
  "private": false,
7
7
  "packageManager": "pnpm@10.7.0",