@g4rcez/components 5.0.1 → 5.0.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/components/core/button.d.ts +77 -0
- package/dist/components/core/button.d.ts.map +1 -0
- package/dist/components/core/button.jsx +79 -0
- package/dist/components/core/heading.d.ts +3 -0
- package/dist/components/core/heading.d.ts.map +1 -0
- package/dist/components/core/heading.jsx +4 -0
- package/dist/components/core/polymorph.d.ts +10 -0
- package/dist/components/core/polymorph.d.ts.map +1 -0
- package/dist/components/core/polymorph.jsx +5 -0
- package/dist/components/core/render-on-view.d.ts +7 -0
- package/dist/components/core/render-on-view.d.ts.map +1 -0
- package/dist/components/core/render-on-view.jsx +31 -0
- package/dist/components/core/resizable.d.ts +3 -0
- package/dist/components/core/resizable.d.ts.map +1 -0
- package/dist/components/core/resizable.jsx +51 -0
- package/dist/components/core/slot.d.ts +16 -0
- package/dist/components/core/slot.d.ts.map +1 -0
- package/dist/components/core/slot.jsx +156 -0
- package/dist/components/core/tag.d.ts +35 -0
- package/dist/components/core/tag.d.ts.map +1 -0
- package/dist/components/core/tag.jsx +53 -0
- package/dist/components/core/typography.d.ts +25 -0
- package/dist/components/core/typography.d.ts.map +1 -0
- package/dist/components/core/typography.jsx +20 -0
- package/dist/components/display/alert.d.ts +28 -0
- package/dist/components/display/alert.d.ts.map +1 -0
- package/dist/components/display/alert.jsx +61 -0
- package/dist/components/display/calendar.d.ts +42 -0
- package/dist/components/display/calendar.d.ts.map +1 -0
- package/dist/components/display/calendar.jsx +318 -0
- package/dist/components/display/card.d.ts +29 -0
- package/dist/components/display/card.d.ts.map +1 -0
- package/dist/components/display/card.jsx +43 -0
- package/dist/components/display/empty.d.ts +8 -0
- package/dist/components/display/empty.d.ts.map +1 -0
- package/dist/components/display/empty.jsx +11 -0
- package/dist/components/display/list.d.ts +16 -0
- package/dist/components/display/list.d.ts.map +1 -0
- package/dist/components/display/list.jsx +85 -0
- package/dist/components/display/notifications.d.ts +27 -0
- package/dist/components/display/notifications.d.ts.map +1 -0
- package/dist/components/display/notifications.jsx +130 -0
- package/dist/components/display/progress.d.ts +16 -0
- package/dist/components/display/progress.d.ts.map +1 -0
- package/dist/components/display/progress.jsx +21 -0
- package/dist/components/display/shortcut.d.ts +4 -0
- package/dist/components/display/shortcut.d.ts.map +1 -0
- package/dist/components/display/shortcut.jsx +23 -0
- package/dist/components/display/skeleton.d.ts +12 -0
- package/dist/components/display/skeleton.d.ts.map +1 -0
- package/dist/components/display/skeleton.jsx +19 -0
- package/dist/components/display/spinner.d.ts +5 -0
- package/dist/components/display/spinner.d.ts.map +1 -0
- package/dist/components/display/spinner.jsx +11 -0
- package/dist/components/display/stats.d.ts +12 -0
- package/dist/components/display/stats.d.ts.map +1 -0
- package/dist/components/display/stats.jsx +16 -0
- package/dist/components/display/step.d.ts +24 -0
- package/dist/components/display/step.d.ts.map +1 -0
- package/dist/components/display/step.jsx +145 -0
- package/dist/components/display/tabs.d.ts +24 -0
- package/dist/components/display/tabs.d.ts.map +1 -0
- package/dist/components/display/tabs.jsx +125 -0
- package/dist/components/display/timeline.d.ts +10 -0
- package/dist/components/display/timeline.d.ts.map +1 -0
- package/dist/components/display/timeline.jsx +25 -0
- package/dist/components/floating/command-palette.d.ts +49 -0
- package/dist/components/floating/command-palette.d.ts.map +1 -0
- package/dist/components/floating/command-palette.jsx +223 -0
- package/dist/components/floating/dropdown.d.ts +15 -0
- package/dist/components/floating/dropdown.d.ts.map +1 -0
- package/dist/components/floating/dropdown.jsx +56 -0
- package/dist/components/floating/expand.d.ts +11 -0
- package/dist/components/floating/expand.d.ts.map +1 -0
- package/dist/components/floating/expand.jsx +44 -0
- package/dist/components/floating/menu.d.ts +52 -0
- package/dist/components/floating/menu.d.ts.map +1 -0
- package/dist/components/floating/menu.jsx +165 -0
- package/dist/components/floating/modal.d.ts +60 -0
- package/dist/components/floating/modal.d.ts.map +1 -0
- package/dist/components/floating/modal.jsx +336 -0
- package/dist/components/floating/toolbar.d.ts +6 -0
- package/dist/components/floating/toolbar.d.ts.map +1 -0
- package/dist/components/floating/toolbar.jsx +5 -0
- package/dist/components/floating/tooltip.d.ts +17 -0
- package/dist/components/floating/tooltip.d.ts.map +1 -0
- package/dist/components/floating/tooltip.jsx +67 -0
- package/dist/components/floating/wizard.d.ts +26 -0
- package/dist/components/floating/wizard.d.ts.map +1 -0
- package/dist/components/floating/wizard.jsx +165 -0
- package/dist/components/form/autocomplete.d.ts +16 -0
- package/dist/components/form/autocomplete.d.ts.map +1 -0
- package/dist/components/form/autocomplete.jsx +290 -0
- package/dist/components/form/checkbox.d.ts +12 -0
- package/dist/components/form/checkbox.d.ts.map +1 -0
- package/dist/components/form/checkbox.jsx +12 -0
- package/dist/components/form/date-picker.d.ts +10 -0
- package/dist/components/form/date-picker.d.ts.map +1 -0
- package/dist/components/form/date-picker.jsx +115 -0
- package/dist/components/form/file-upload.d.ts +15 -0
- package/dist/components/form/file-upload.d.ts.map +1 -0
- package/dist/components/form/file-upload.jsx +138 -0
- package/dist/components/form/form.d.ts +3 -0
- package/dist/components/form/form.d.ts.map +1 -0
- package/dist/components/form/form.jsx +10 -0
- package/dist/components/form/formReset.d.ts +2 -0
- package/dist/components/form/formReset.d.ts.map +1 -0
- package/dist/components/form/formReset.jsx +17 -0
- package/dist/components/form/free-text.d.ts +11 -0
- package/dist/components/form/free-text.d.ts.map +1 -0
- package/dist/components/form/free-text.jsx +41 -0
- package/dist/components/form/input-field.d.ts +34 -0
- package/dist/components/form/input-field.d.ts.map +1 -0
- package/dist/components/form/input-field.jsx +58 -0
- package/dist/components/form/input.d.ts +52 -0
- package/dist/components/form/input.d.ts.map +1 -0
- package/dist/components/form/input.jsx +36 -0
- package/dist/components/form/multi-select.d.ts +19 -0
- package/dist/components/form/multi-select.d.ts.map +1 -0
- package/dist/components/form/multi-select.jsx +344 -0
- package/dist/components/form/radiobox.d.ts +7 -0
- package/dist/components/form/radiobox.d.ts.map +1 -0
- package/dist/components/form/radiobox.jsx +6 -0
- package/dist/components/form/select.d.ts +13 -0
- package/dist/components/form/select.d.ts.map +1 -0
- package/dist/components/form/select.jsx +44 -0
- package/dist/components/form/slider.d.ts +7 -0
- package/dist/components/form/slider.d.ts.map +1 -0
- package/dist/components/form/slider.jsx +45 -0
- package/dist/components/form/switch.d.ts +9 -0
- package/dist/components/form/switch.d.ts.map +1 -0
- package/dist/components/form/switch.jsx +46 -0
- package/dist/components/form/task-list.d.ts +3 -0
- package/dist/components/form/task-list.d.ts.map +1 -0
- package/dist/components/form/task-list.jsx +26 -0
- package/dist/components/form/textarea.d.ts +5 -0
- package/dist/components/form/textarea.d.ts.map +1 -0
- package/dist/components/form/textarea.jsx +26 -0
- package/dist/components/index.d.ts +45 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +44 -0
- package/dist/components/page-calendar/calendar-header.d.ts +16 -0
- package/dist/components/page-calendar/calendar-header.d.ts.map +1 -0
- package/dist/components/page-calendar/calendar-header.jsx +83 -0
- package/dist/components/page-calendar/day-view.d.ts +12 -0
- package/dist/components/page-calendar/day-view.d.ts.map +1 -0
- package/dist/components/page-calendar/day-view.jsx +89 -0
- package/dist/components/page-calendar/event-pill.d.ts +9 -0
- package/dist/components/page-calendar/event-pill.d.ts.map +1 -0
- package/dist/components/page-calendar/event-pill.jsx +25 -0
- package/dist/components/page-calendar/index.d.ts +4 -0
- package/dist/components/page-calendar/index.d.ts.map +1 -0
- package/dist/components/page-calendar/index.js +2 -0
- package/dist/components/page-calendar/month-view.d.ts +11 -0
- package/dist/components/page-calendar/month-view.d.ts.map +1 -0
- package/dist/components/page-calendar/month-view.jsx +46 -0
- package/dist/components/page-calendar/page-calendar.d.ts +18 -0
- package/dist/components/page-calendar/page-calendar.d.ts.map +1 -0
- package/dist/components/page-calendar/page-calendar.jsx +41 -0
- package/dist/components/page-calendar/page-calendar.types.d.ts +18 -0
- package/dist/components/page-calendar/page-calendar.types.d.ts.map +1 -0
- package/dist/components/page-calendar/page-calendar.types.js +1 -0
- package/dist/components/page-calendar/page-calendar.utils.d.ts +24 -0
- package/dist/components/page-calendar/page-calendar.utils.d.ts.map +1 -0
- package/dist/components/page-calendar/page-calendar.utils.js +93 -0
- package/dist/components/page-calendar/week-view.d.ts +11 -0
- package/dist/components/page-calendar/week-view.d.ts.map +1 -0
- package/dist/components/page-calendar/week-view.jsx +66 -0
- package/dist/components/table/filter.d.ts +42 -0
- package/dist/components/table/filter.d.ts.map +1 -0
- package/dist/components/table/filter.jsx +169 -0
- package/dist/components/table/group.d.ts +17 -0
- package/dist/components/table/group.d.ts.map +1 -0
- package/dist/components/table/group.jsx +75 -0
- package/dist/components/table/index.d.ts +19 -0
- package/dist/components/table/index.d.ts.map +1 -0
- package/dist/components/table/index.jsx +63 -0
- package/dist/components/table/inner-table.d.ts +29 -0
- package/dist/components/table/inner-table.d.ts.map +1 -0
- package/dist/components/table/inner-table.jsx +102 -0
- package/dist/components/table/metadata.d.ts +4 -0
- package/dist/components/table/metadata.d.ts.map +1 -0
- package/dist/components/table/metadata.jsx +36 -0
- package/dist/components/table/pagination.d.ts +5 -0
- package/dist/components/table/pagination.d.ts.map +1 -0
- package/dist/components/table/pagination.jsx +74 -0
- package/dist/components/table/row.d.ts +11 -0
- package/dist/components/table/row.d.ts.map +1 -0
- package/dist/components/table/row.jsx +49 -0
- package/dist/components/table/sort.d.ts +28 -0
- package/dist/components/table/sort.d.ts.map +1 -0
- package/dist/components/table/sort.jsx +109 -0
- package/dist/components/table/table-lib.d.ts +135 -0
- package/dist/components/table/table-lib.d.ts.map +1 -0
- package/dist/components/table/table-lib.js +83 -0
- package/dist/components/table/table.context.d.ts +10 -0
- package/dist/components/table/table.context.d.ts.map +1 -0
- package/dist/components/table/table.context.jsx +5 -0
- package/dist/components/table/thead.d.ts +9 -0
- package/dist/components/table/thead.d.ts.map +1 -0
- package/dist/components/table/thead.jsx +103 -0
- package/dist/config/context.d.ts +21 -0
- package/dist/config/context.d.ts.map +1 -0
- package/dist/config/context.js +12 -0
- package/dist/config/default-translations.d.ts +94 -0
- package/dist/config/default-translations.d.ts.map +1 -0
- package/dist/config/default-translations.jsx +87 -0
- package/dist/config/default-tweaks.d.ts +13 -0
- package/dist/config/default-tweaks.d.ts.map +1 -0
- package/dist/config/default-tweaks.js +4 -0
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +2 -0
- package/dist/hooks/use-click-outside.d.ts +3 -0
- package/dist/hooks/use-click-outside.d.ts.map +1 -0
- package/dist/hooks/use-click-outside.js +17 -0
- package/dist/hooks/use-color-parser.d.ts +2 -0
- package/dist/hooks/use-color-parser.d.ts.map +1 -0
- package/dist/hooks/use-color-parser.js +9 -0
- package/dist/hooks/use-components-provider.d.ts +15 -0
- package/dist/hooks/use-components-provider.d.ts.map +1 -0
- package/dist/hooks/use-components-provider.jsx +22 -0
- package/dist/hooks/use-debounce.d.ts +5 -0
- package/dist/hooks/use-debounce.d.ts.map +1 -0
- package/dist/hooks/use-debounce.js +12 -0
- package/dist/hooks/use-floating-ref.d.ts +2 -0
- package/dist/hooks/use-floating-ref.d.ts.map +1 -0
- package/dist/hooks/use-floating-ref.js +6 -0
- package/dist/hooks/use-form.d.ts +394 -0
- package/dist/hooks/use-form.d.ts.map +1 -0
- package/dist/hooks/use-form.js +563 -0
- package/dist/hooks/use-hover.d.ts +3 -0
- package/dist/hooks/use-hover.d.ts.map +1 -0
- package/dist/hooks/use-hover.js +18 -0
- package/dist/hooks/use-input-id.d.ts +4 -0
- package/dist/hooks/use-input-id.d.ts.map +1 -0
- package/dist/hooks/use-input-id.js +5 -0
- package/dist/hooks/use-is-coarse-device.d.ts +2 -0
- package/dist/hooks/use-is-coarse-device.d.ts.map +1 -0
- package/dist/hooks/use-is-coarse-device.js +12 -0
- package/dist/hooks/use-locale.d.ts +3 -0
- package/dist/hooks/use-locale.d.ts.map +1 -0
- package/dist/hooks/use-locale.js +10 -0
- package/dist/hooks/use-media-query.d.ts +2 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-media-query.js +25 -0
- package/dist/hooks/use-on-event.d.ts +4 -0
- package/dist/hooks/use-on-event.d.ts.map +1 -0
- package/dist/hooks/use-on-event.js +10 -0
- package/dist/hooks/use-parent.d.ts +3 -0
- package/dist/hooks/use-parent.d.ts.map +1 -0
- package/dist/hooks/use-parent.js +21 -0
- package/dist/hooks/use-preferences.d.ts +2 -0
- package/dist/hooks/use-preferences.d.ts.map +1 -0
- package/dist/hooks/use-preferences.js +23 -0
- package/dist/hooks/use-previous.d.ts +2 -0
- package/dist/hooks/use-previous.d.ts.map +1 -0
- package/dist/hooks/use-previous.js +9 -0
- package/dist/hooks/use-reactive.d.ts +2 -0
- package/dist/hooks/use-reactive.d.ts.map +1 -0
- package/dist/hooks/use-reactive.js +9 -0
- package/dist/hooks/use-remove-scroll.d.ts +4 -0
- package/dist/hooks/use-remove-scroll.d.ts.map +1 -0
- package/dist/hooks/use-remove-scroll.js +48 -0
- package/dist/hooks/use-resize-observer.d.ts +2 -0
- package/dist/hooks/use-resize-observer.d.ts.map +1 -0
- package/dist/hooks/use-resize-observer.js +17 -0
- package/dist/hooks/use-stable-ref.d.ts +2 -0
- package/dist/hooks/use-stable-ref.d.ts.map +1 -0
- package/dist/hooks/use-stable-ref.js +9 -0
- package/dist/hooks/use-swipe.d.ts +8 -0
- package/dist/hooks/use-swipe.d.ts.map +1 -0
- package/dist/hooks/use-swipe.js +17 -0
- package/dist/hooks/use-translations.d.ts +92 -0
- package/dist/hooks/use-translations.d.ts.map +1 -0
- package/dist/hooks/use-translations.js +9 -0
- package/dist/hooks/use-tweaks.d.ts +3 -0
- package/dist/hooks/use-tweaks.d.ts.map +1 -0
- package/dist/hooks/use-tweaks.js +9 -0
- package/dist/hooks/use-window-size.d.ts +5 -0
- package/dist/hooks/use-window-size.d.ts.map +1 -0
- package/dist/hooks/use-window-size.js +14 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -7932
- package/dist/lib/combi-keys.d.ts +15 -0
- package/dist/lib/combi-keys.d.ts.map +1 -0
- package/dist/lib/combi-keys.js +60 -0
- package/dist/lib/dict.d.ts +9 -0
- package/dist/lib/dict.d.ts.map +1 -0
- package/dist/lib/dict.js +28 -0
- package/dist/lib/dom.d.ts +20 -0
- package/dist/lib/dom.d.ts.map +1 -0
- package/dist/lib/dom.js +185 -0
- package/dist/lib/fns.d.ts +11 -0
- package/dist/lib/fns.d.ts.map +1 -0
- package/dist/lib/fns.js +46 -0
- package/dist/lib/fzf.d.ts +16 -0
- package/dist/lib/fzf.d.ts.map +1 -0
- package/dist/lib/fzf.js +115 -0
- package/dist/lib/keyboard-area.d.ts +16 -0
- package/dist/lib/keyboard-area.d.ts.map +1 -0
- package/dist/lib/keyboard-area.js +14 -0
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +1 -1
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare class Dict<K, V> extends Map<K, V> {
|
|
2
|
+
remove(key: K): this;
|
|
3
|
+
map<R>(callback: (v: V, i: number) => R): R[];
|
|
4
|
+
clone(fn?: (dict: Dict<K, V>) => Dict<K, V>): Dict<K, V>;
|
|
5
|
+
static from<T>(items: T[], selector: (t: T) => any): Dict<any, T>;
|
|
6
|
+
static unique<T>(items: T[], selector: (t: T) => any): T[];
|
|
7
|
+
toArray(): V[];
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=dict.d.ts.map
|
|
@@ -0,0 +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;IAC9B,MAAM,CAAC,GAAG,EAAE,CAAC;IAKb,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,EAAE;IAO7C,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;WAMpC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,GAAG;WAI3C,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,GAAG;IAIpD,OAAO;CAGjB"}
|
package/dist/lib/dict.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export class Dict extends Map {
|
|
2
|
+
remove(key) {
|
|
3
|
+
super.delete(key);
|
|
4
|
+
return this;
|
|
5
|
+
}
|
|
6
|
+
map(callback) {
|
|
7
|
+
let i = 0;
|
|
8
|
+
const out = [];
|
|
9
|
+
for (const v of this.values())
|
|
10
|
+
out.push(callback(v, i++));
|
|
11
|
+
return out;
|
|
12
|
+
}
|
|
13
|
+
clone(fn) {
|
|
14
|
+
const clone = new Dict(this);
|
|
15
|
+
if (fn)
|
|
16
|
+
return fn(clone);
|
|
17
|
+
return clone;
|
|
18
|
+
}
|
|
19
|
+
static from(items, selector) {
|
|
20
|
+
return new Dict(items.map((x) => [selector(x), x]));
|
|
21
|
+
}
|
|
22
|
+
static unique(items, selector) {
|
|
23
|
+
return Array.from(Dict.from(items, selector).values());
|
|
24
|
+
}
|
|
25
|
+
toArray() {
|
|
26
|
+
return Array.from(this.values());
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ClassValue } from "clsx";
|
|
2
|
+
import React, { Ref, RefCallback, RefObject } from "react";
|
|
3
|
+
export declare const mergeRefs: <T>(...refs: Array<RefObject<T> | Ref<T> | undefined | null>) => RefCallback<T>;
|
|
4
|
+
export declare const isReactComponent: (a: unknown) => a is React.ReactElement;
|
|
5
|
+
export declare const isReactFC: (a: unknown) => a is (...any: any[]) => any;
|
|
6
|
+
export declare const css: (...styles: ClassValue[]) => string;
|
|
7
|
+
export declare const synthesizeChangeEvent: (input: HTMLInputElement) => React.ChangeEvent<HTMLInputElement>;
|
|
8
|
+
export declare const dispatchInput: (input: HTMLInputElement | undefined | null) => Event & {
|
|
9
|
+
target: HTMLInputElement | null | undefined;
|
|
10
|
+
currentTarget: HTMLInputElement | null | undefined;
|
|
11
|
+
};
|
|
12
|
+
export declare const initializeInputDataset: (input: HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement) => () => void;
|
|
13
|
+
export declare const hasVerticalScroll: (htmlElement: HTMLElement) => boolean;
|
|
14
|
+
export declare const getRemainingSize: (element: HTMLElement, windowSize: number) => number;
|
|
15
|
+
export declare const getCoords: (elem: HTMLElement, docEl: HTMLElement) => {
|
|
16
|
+
top: number;
|
|
17
|
+
left: number;
|
|
18
|
+
};
|
|
19
|
+
export declare const isChildVisible: (container: HTMLElement, child: HTMLElement, partial?: boolean) => boolean;
|
|
20
|
+
//# sourceMappingURL=dom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/lib/dom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,MAAM,CAAC;AACxC,OAAO,KAAK,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAsI3D,eAAO,MAAM,SAAS,GACnB,CAAC,EACA,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,KACvD,WAAW,CAAC,CAAC,CASf,CAAC;AAEJ,eAAO,MAAM,gBAAgB,GAAI,GAAG,OAAO,KAAG,CAAC,IAAI,KAAK,CAAC,YAMxD,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,GAAG,OAAO,gCAAmB,CAAC;AAExD,eAAO,MAAM,GAAG,GAAI,GAAG,QAAQ,UAAU,EAAE,WAA0B,CAAC;AAEtE,eAAO,MAAM,qBAAqB,GAChC,OAAO,gBAAgB,KACtB,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAKpC,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAO,gBAAgB,GAAG,SAAS,GAAG,IAAI;;;CAIvE,CAAC;AAEF,eAAO,MAAM,sBAAsB,GACjC,OAAO,gBAAgB,GAAG,mBAAmB,GAAG,iBAAiB,eAKlE,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,aAAa,WAAW,YACL,CAAC;AAEtD,eAAO,MAAM,gBAAgB,GAAI,SAAS,WAAW,EAAE,YAAY,MAAM,WAMxE,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,MAAM,WAAW,EAAE,OAAO,WAAW;;;CAO9D,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,WAAW,WAAW,EACtB,OAAO,WAAW,EAClB,UAAS,OAAc,KACtB,OAgBF,CAAC"}
|
package/dist/lib/dom.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { clsx } from "clsx";
|
|
2
|
+
import { Is } from "sidekicker";
|
|
3
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
4
|
+
import { components } from "../styles/components";
|
|
5
|
+
const componentPrefixes = Object.keys(components);
|
|
6
|
+
const isFontSizeAttr = (attr) => attr === "text" || attr.endsWith("-text") || attr.startsWith("text-");
|
|
7
|
+
const isBorderWidthAttr = (attr) => attr === "border" || attr.endsWith("-border");
|
|
8
|
+
const isRadiusAttr = (attr) => attr === "radius" || attr.endsWith("-radius");
|
|
9
|
+
const fontSizeTokens = new Set();
|
|
10
|
+
const borderWidthTokens = new Set();
|
|
11
|
+
const radiusTokens = new Set();
|
|
12
|
+
const spacingTokens = new Set();
|
|
13
|
+
for (const [component, attrs] of Object.entries(components)) {
|
|
14
|
+
if (!attrs || typeof attrs !== "object")
|
|
15
|
+
continue;
|
|
16
|
+
if (component === "typography") {
|
|
17
|
+
for (const attr of Object.keys(attrs))
|
|
18
|
+
fontSizeTokens.add(attr);
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
for (const attr of Object.keys(attrs)) {
|
|
22
|
+
const key = `${component}-${attr}`;
|
|
23
|
+
if (isRadiusAttr(attr))
|
|
24
|
+
radiusTokens.add(key);
|
|
25
|
+
else if (isBorderWidthAttr(attr)) {
|
|
26
|
+
borderWidthTokens.add(key);
|
|
27
|
+
spacingTokens.add(key);
|
|
28
|
+
}
|
|
29
|
+
else if (isFontSizeAttr(attr)) {
|
|
30
|
+
fontSizeTokens.add(key);
|
|
31
|
+
spacingTokens.add(key);
|
|
32
|
+
}
|
|
33
|
+
else
|
|
34
|
+
spacingTokens.add(key);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const isComponentToken = (value) => componentPrefixes.some((p) => value === p || value.startsWith(`${p}-`));
|
|
38
|
+
const isSpacingValue = (value) => spacingTokens.has(value);
|
|
39
|
+
const isRadiusValue = (value) => radiusTokens.has(value);
|
|
40
|
+
const isFontSizeValue = (value) => {
|
|
41
|
+
if (fontSizeTokens.has(value))
|
|
42
|
+
return true;
|
|
43
|
+
if (value.startsWith("typography-"))
|
|
44
|
+
return fontSizeTokens.has(value.slice("typography-".length));
|
|
45
|
+
return false;
|
|
46
|
+
};
|
|
47
|
+
const isBorderWidthValue = (value) => borderWidthTokens.has(value);
|
|
48
|
+
const isTextColorValue = (value) => !isFontSizeValue(value) && isComponentToken(value);
|
|
49
|
+
const isBorderColorValue = (value) => !isBorderWidthValue(value) && isComponentToken(value);
|
|
50
|
+
const spacingGroupIds = [
|
|
51
|
+
"p",
|
|
52
|
+
"px",
|
|
53
|
+
"py",
|
|
54
|
+
"pt",
|
|
55
|
+
"pr",
|
|
56
|
+
"pb",
|
|
57
|
+
"pl",
|
|
58
|
+
"ps",
|
|
59
|
+
"pe",
|
|
60
|
+
"m",
|
|
61
|
+
"mx",
|
|
62
|
+
"my",
|
|
63
|
+
"mt",
|
|
64
|
+
"mr",
|
|
65
|
+
"mb",
|
|
66
|
+
"ml",
|
|
67
|
+
"ms",
|
|
68
|
+
"me",
|
|
69
|
+
"gap",
|
|
70
|
+
"gap-x",
|
|
71
|
+
"gap-y",
|
|
72
|
+
"h",
|
|
73
|
+
"w",
|
|
74
|
+
"size",
|
|
75
|
+
"min-h",
|
|
76
|
+
"min-w",
|
|
77
|
+
"max-h",
|
|
78
|
+
"max-w",
|
|
79
|
+
"top",
|
|
80
|
+
"right",
|
|
81
|
+
"bottom",
|
|
82
|
+
"left",
|
|
83
|
+
"inset",
|
|
84
|
+
"inset-x",
|
|
85
|
+
"inset-y",
|
|
86
|
+
];
|
|
87
|
+
const radiusGroupIds = [
|
|
88
|
+
"rounded",
|
|
89
|
+
"rounded-s",
|
|
90
|
+
"rounded-e",
|
|
91
|
+
"rounded-t",
|
|
92
|
+
"rounded-r",
|
|
93
|
+
"rounded-b",
|
|
94
|
+
"rounded-l",
|
|
95
|
+
"rounded-ss",
|
|
96
|
+
"rounded-se",
|
|
97
|
+
"rounded-ee",
|
|
98
|
+
"rounded-es",
|
|
99
|
+
"rounded-tl",
|
|
100
|
+
"rounded-tr",
|
|
101
|
+
"rounded-br",
|
|
102
|
+
"rounded-bl",
|
|
103
|
+
];
|
|
104
|
+
const wrap = (ids, match) => Object.fromEntries(ids.map((id) => [id, [{ [id]: [match] }]]));
|
|
105
|
+
const twMerge = extendTailwindMerge({
|
|
106
|
+
extend: {
|
|
107
|
+
classGroups: {
|
|
108
|
+
...wrap(spacingGroupIds, isSpacingValue),
|
|
109
|
+
...wrap(radiusGroupIds, isRadiusValue),
|
|
110
|
+
"font-size": [{ text: [isFontSizeValue] }],
|
|
111
|
+
"text-color": [{ text: [isTextColorValue] }],
|
|
112
|
+
"border-w": [{ border: [isBorderWidthValue] }],
|
|
113
|
+
"border-color": [{ border: [isBorderColorValue] }],
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
export const mergeRefs = (...refs) => (value) => {
|
|
118
|
+
refs.forEach((ref) => {
|
|
119
|
+
if (typeof ref === "function") {
|
|
120
|
+
ref(value);
|
|
121
|
+
}
|
|
122
|
+
else if (ref !== null) {
|
|
123
|
+
ref.current = value;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
};
|
|
127
|
+
export const isReactComponent = (a) => {
|
|
128
|
+
if (typeof a !== "object" || a === null)
|
|
129
|
+
return false;
|
|
130
|
+
const elem = a;
|
|
131
|
+
if (elem.$$typeof === Symbol.for("react.forward_ref"))
|
|
132
|
+
return true;
|
|
133
|
+
if (elem.$$typeof === Symbol.for("react.fragment"))
|
|
134
|
+
return true;
|
|
135
|
+
return elem.$$typeof === Symbol.for("react.element");
|
|
136
|
+
};
|
|
137
|
+
export const isReactFC = (a) => Is.function(a);
|
|
138
|
+
export const css = (...styles) => twMerge(clsx(styles));
|
|
139
|
+
export const synthesizeChangeEvent = (input) => {
|
|
140
|
+
return {
|
|
141
|
+
target: input,
|
|
142
|
+
currentTarget: input,
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
export const dispatchInput = (input) => {
|
|
146
|
+
const event = new Event("input", { bubbles: true, composed: true });
|
|
147
|
+
input?.dispatchEvent(event);
|
|
148
|
+
return Object.assign({}, event, { target: input, currentTarget: input });
|
|
149
|
+
};
|
|
150
|
+
export const initializeInputDataset = (input) => {
|
|
151
|
+
const focus = () => input.setAttribute("data-initialized", "true");
|
|
152
|
+
input.addEventListener("focus", focus);
|
|
153
|
+
return () => input.removeEventListener("focus", focus);
|
|
154
|
+
};
|
|
155
|
+
export const hasVerticalScroll = (htmlElement) => htmlElement.scrollHeight > htmlElement.clientHeight;
|
|
156
|
+
export const getRemainingSize = (element, windowSize) => {
|
|
157
|
+
if (element && element.getBoundingClientRect) {
|
|
158
|
+
const rect = element.getBoundingClientRect();
|
|
159
|
+
return Math.abs(windowSize - rect.bottom);
|
|
160
|
+
}
|
|
161
|
+
return 320;
|
|
162
|
+
};
|
|
163
|
+
export const getCoords = (elem, docEl) => {
|
|
164
|
+
const box = elem.getBoundingClientRect();
|
|
165
|
+
const parent = docEl.getBoundingClientRect();
|
|
166
|
+
return {
|
|
167
|
+
top: Math.round(box.top - parent.top),
|
|
168
|
+
left: Math.round(box.left - parent.left),
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
export const isChildVisible = (container, child, partial = true) => {
|
|
172
|
+
const containerRect = container.getBoundingClientRect();
|
|
173
|
+
const childRect = child.getBoundingClientRect();
|
|
174
|
+
const isWithinTop = childRect.top >= containerRect.top;
|
|
175
|
+
const isWithinBottom = childRect.bottom <= containerRect.bottom;
|
|
176
|
+
const isWithinLeft = childRect.left >= containerRect.left;
|
|
177
|
+
const isWithinRight = childRect.right <= containerRect.right;
|
|
178
|
+
if (partial) {
|
|
179
|
+
return (childRect.top < containerRect.bottom &&
|
|
180
|
+
childRect.bottom > containerRect.top &&
|
|
181
|
+
childRect.left < containerRect.right &&
|
|
182
|
+
childRect.right > containerRect.left);
|
|
183
|
+
}
|
|
184
|
+
return isWithinTop && isWithinBottom && isWithinLeft && isWithinRight;
|
|
185
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AllPaths } from "sidekicker";
|
|
2
|
+
import { Any } from "../types";
|
|
3
|
+
export declare const uuid: () => string;
|
|
4
|
+
export declare const path: <T extends Any, K extends AllPaths<T>>(obj: T, path: K) => Any | undefined;
|
|
5
|
+
export declare const isSsr: () => boolean;
|
|
6
|
+
export declare const safeRegex: (string: string) => string;
|
|
7
|
+
export declare const splitInto: <T>(array: T[], size: number) => T[][];
|
|
8
|
+
export declare const negate: (b: boolean) => boolean;
|
|
9
|
+
export declare const noop: () => void;
|
|
10
|
+
export declare const isMobile: () => boolean;
|
|
11
|
+
//# sourceMappingURL=fns.d.ts.map
|
|
@@ -0,0 +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;AAE/B,eAAO,MAAM,IAAI,QAAO,MAkBvB,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,YAAW,CAAC;AAE7B,eAAO,MAAM,QAAQ,eAGpB,CAAC"}
|
package/dist/lib/fns.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const uuid = () => {
|
|
2
|
+
const timestamp = Date.now();
|
|
3
|
+
const bytes = new Uint8Array(16);
|
|
4
|
+
bytes[0] = (timestamp / Math.pow(2, 40)) & 0xff;
|
|
5
|
+
bytes[1] = (timestamp / Math.pow(2, 32)) & 0xff;
|
|
6
|
+
bytes[2] = (timestamp / Math.pow(2, 24)) & 0xff;
|
|
7
|
+
bytes[3] = (timestamp / Math.pow(2, 16)) & 0xff;
|
|
8
|
+
bytes[4] = (timestamp / Math.pow(2, 8)) & 0xff;
|
|
9
|
+
bytes[5] = timestamp & 0xff;
|
|
10
|
+
const randomBytes = new Uint8Array(10);
|
|
11
|
+
crypto.getRandomValues(randomBytes);
|
|
12
|
+
bytes.set(randomBytes, 6);
|
|
13
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x70;
|
|
14
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80;
|
|
15
|
+
const hex = Array.from(bytes)
|
|
16
|
+
.map((b) => b.toString(16).padStart(2, "0"))
|
|
17
|
+
.join("");
|
|
18
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
19
|
+
};
|
|
20
|
+
const travel = (path, regexp, obj) => path
|
|
21
|
+
.split(regexp)
|
|
22
|
+
.filter(Boolean)
|
|
23
|
+
.reduce((res, key) => (res !== null && res !== undefined ? res[key] : res), obj);
|
|
24
|
+
const regexPaths = { basic: /[,[\]]+?/, extend: /[,[\].]+?/ };
|
|
25
|
+
export const path = (obj, path) => {
|
|
26
|
+
const result = travel(path, regexPaths.basic, obj) || travel(path, regexPaths.extend, obj);
|
|
27
|
+
return result === undefined || result === obj ? undefined : result;
|
|
28
|
+
};
|
|
29
|
+
export const isSsr = () => typeof window === "undefined";
|
|
30
|
+
export const safeRegex = (string) => string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
31
|
+
export const splitInto = (array, size) => {
|
|
32
|
+
const newArray = [];
|
|
33
|
+
for (let i = 0; i < size; i++) {
|
|
34
|
+
const init = i * size;
|
|
35
|
+
const result = array.slice(init, init + size);
|
|
36
|
+
if (result.length > 0)
|
|
37
|
+
newArray.push(result);
|
|
38
|
+
}
|
|
39
|
+
return newArray;
|
|
40
|
+
};
|
|
41
|
+
export const negate = (b) => !b;
|
|
42
|
+
export const noop = () => { };
|
|
43
|
+
export const isMobile = () => {
|
|
44
|
+
const userAgent = navigator.userAgent || navigator.vendor || window.opera;
|
|
45
|
+
return /android|iphone|ipad|ipod|opera mini|iemobile|wpdesktop/i.test(userAgent ?? "");
|
|
46
|
+
};
|
|
@@ -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,IAmClE,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,QA2B/F,CAAC"}
|
package/dist/lib/fzf.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Is } from "sidekicker";
|
|
2
|
+
export const fuzzyMatch = (text, search) => {
|
|
3
|
+
text = String(text).toLocaleLowerCase();
|
|
4
|
+
search = String(search).toLocaleLowerCase();
|
|
5
|
+
if (text === search)
|
|
6
|
+
return 1;
|
|
7
|
+
const firstChar = search[0];
|
|
8
|
+
if (!firstChar)
|
|
9
|
+
return null;
|
|
10
|
+
const matchedIndexes = [];
|
|
11
|
+
let cursor = 0;
|
|
12
|
+
while (cursor < text.length) {
|
|
13
|
+
const startIdx = text.indexOf(firstChar, cursor);
|
|
14
|
+
if (startIdx === -1)
|
|
15
|
+
break;
|
|
16
|
+
let pos = startIdx + 1;
|
|
17
|
+
const indexes = [startIdx];
|
|
18
|
+
let matched = true;
|
|
19
|
+
for (let i = 1; i < search.length; i++) {
|
|
20
|
+
const foundAt = text.indexOf(search[i], pos);
|
|
21
|
+
if (foundAt === -1) {
|
|
22
|
+
matched = false;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
indexes.push(foundAt);
|
|
26
|
+
pos = foundAt + 1;
|
|
27
|
+
}
|
|
28
|
+
if (matched)
|
|
29
|
+
matchedIndexes.push(indexes);
|
|
30
|
+
cursor = startIdx + 1;
|
|
31
|
+
}
|
|
32
|
+
if (matchedIndexes.length === 0)
|
|
33
|
+
return null;
|
|
34
|
+
const bestMatch = matchedIndexes.sort((a, b) => {
|
|
35
|
+
if (a.length === 1)
|
|
36
|
+
return a[0] - b[0];
|
|
37
|
+
return a[a.length - 1] - a[0] - (b[b.length - 1] - b[0]);
|
|
38
|
+
})[0];
|
|
39
|
+
if (bestMatch.length > 1)
|
|
40
|
+
return 2 + (bestMatch[bestMatch.length - 1] - bestMatch[0]);
|
|
41
|
+
return 2 + bestMatch[0];
|
|
42
|
+
};
|
|
43
|
+
const travel = (path, regexp, obj) => {
|
|
44
|
+
const keys = path.split(regexp).filter(Boolean);
|
|
45
|
+
let res = obj;
|
|
46
|
+
for (const key of keys) {
|
|
47
|
+
if (res === null || res === undefined) {
|
|
48
|
+
return res;
|
|
49
|
+
}
|
|
50
|
+
res = res[key];
|
|
51
|
+
}
|
|
52
|
+
return res;
|
|
53
|
+
};
|
|
54
|
+
const regexPaths = { basic: /[,[\]]+?/, extend: /[,[\].]+?/ };
|
|
55
|
+
const path = (obj, path) => {
|
|
56
|
+
const result = travel(path, regexPaths.basic, obj);
|
|
57
|
+
if (result !== undefined && result !== obj)
|
|
58
|
+
return result;
|
|
59
|
+
return travel(path, regexPaths.extend, obj);
|
|
60
|
+
};
|
|
61
|
+
const onlyNumbers = (str) => str.replace(/[^0-9]/g, "");
|
|
62
|
+
const diacritics = (input) => input.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
|
|
63
|
+
const strCompare = (text, value, _, match = "FUZZY") => {
|
|
64
|
+
if (match === "CONTAINS") {
|
|
65
|
+
return text.includes(value);
|
|
66
|
+
}
|
|
67
|
+
if (match === "EQUAL") {
|
|
68
|
+
return text === value;
|
|
69
|
+
}
|
|
70
|
+
if (match === "CONTAINS_NUMBERS") {
|
|
71
|
+
return onlyNumbers(text).includes(onlyNumbers(value));
|
|
72
|
+
}
|
|
73
|
+
if (match === "STARTS_WITH") {
|
|
74
|
+
return text.startsWith(value);
|
|
75
|
+
}
|
|
76
|
+
if (match === "ENDS_WITH") {
|
|
77
|
+
return text.endsWith(value);
|
|
78
|
+
}
|
|
79
|
+
if (match === "FUZZY") {
|
|
80
|
+
const r = fuzzyMatch(text, value);
|
|
81
|
+
return r !== null;
|
|
82
|
+
}
|
|
83
|
+
return false;
|
|
84
|
+
};
|
|
85
|
+
const compare = (search, value, defaultScore, match = "FUZZY") => Array.isArray(value) ? value.some((x) => strCompare(search, x, defaultScore, match)) : strCompare(search, value, defaultScore, match);
|
|
86
|
+
export const fzf = (items, id, keys) => {
|
|
87
|
+
if (keys.length === 0) {
|
|
88
|
+
return items;
|
|
89
|
+
}
|
|
90
|
+
const map = new Map();
|
|
91
|
+
const remap = keys.map((x) => {
|
|
92
|
+
const target = Is.array(x.value)
|
|
93
|
+
? x.value.map((v) => diacritics(`${v}`.toLocaleLowerCase()).trim())
|
|
94
|
+
: diacritics(`${x.value}`.toLocaleLowerCase()).trim();
|
|
95
|
+
return { ...x, target };
|
|
96
|
+
});
|
|
97
|
+
items.forEach((item) => {
|
|
98
|
+
const idVal = path(item, id);
|
|
99
|
+
remap.forEach((filter) => {
|
|
100
|
+
const searchValue = path(item, filter.key);
|
|
101
|
+
if (!searchValue)
|
|
102
|
+
return;
|
|
103
|
+
const search = diacritics(`${searchValue}`.toLocaleLowerCase()).trim();
|
|
104
|
+
if (compare(search, filter.target, filter.score, filter.match)) {
|
|
105
|
+
return void map.set(idVal, item);
|
|
106
|
+
}
|
|
107
|
+
if (Is.function(filter.ifNotMatch)) {
|
|
108
|
+
const result = filter.ifNotMatch(filter.target, search);
|
|
109
|
+
if (result)
|
|
110
|
+
map.set(idVal, item);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
return Array.from(map.values());
|
|
115
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type EventKey = "Backspace" | "Tab" | "Enter" | "Shift" | "Control" | "Alt" | "Pause" | "CapsLock" | "Escape" | "Space" | "PageUp" | "PageDown" | "End" | "Home" | "ArrowLeft" | "ArrowUp" | "ArrowRight" | "ArrowDown" | "PrintScreen" | "Insert" | "Delete" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "Meta" | "ContextMenu" | "F1" | "F2" | "F3" | "F4" | "F5" | "F6" | "F7" | "F8" | "F9" | "F10" | "F11" | "F12" | "NumLock" | "ScrollLock" | "AudioVolumeMute" | "AudioVolumeUp" | "AudioVolumeDown" | "MediaTrackNext" | "MediaTrackPrevious" | "MediaStop" | "MediaPlayPause" | "LaunchMail" | "LaunchMediaPlayer" | "LaunchApplication1" | "LaunchApplication2" | "Semicolon" | "Equal" | "Comma" | "Minus" | "Period" | "Slash" | "Backquote" | "BracketLeft" | "Backslash" | "BracketRight" | "Quote";
|
|
3
|
+
export declare const keyboardKeys: {
|
|
4
|
+
readonly ArrowUp: "ArrowUp";
|
|
5
|
+
readonly ArrowDown: "ArrowDown";
|
|
6
|
+
readonly ArrowLeft: "ArrowLeft";
|
|
7
|
+
readonly ArrowRight: "ArrowRight";
|
|
8
|
+
};
|
|
9
|
+
type Callback<T extends HTMLElement = HTMLElement> = (e: KeyboardEvent | React.KeyboardEvent<T>) => void;
|
|
10
|
+
export declare class KeyboardArea<T extends HTMLElement> {
|
|
11
|
+
private set;
|
|
12
|
+
key(key: EventKey, callback: Callback<T>): () => boolean;
|
|
13
|
+
onKeyDown(_: Callback<T>): void;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=keyboard-area.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyboard-area.d.ts","sourceRoot":"","sources":["../../src/lib/keyboard-area.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,KAAK,QAAQ,GACP,WAAW,GACX,KAAK,GACL,OAAO,GACP,OAAO,GACP,SAAS,GACT,KAAK,GACL,OAAO,GACP,UAAU,GACV,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,UAAU,GACV,KAAK,GACL,MAAM,GACN,WAAW,GACX,SAAS,GACT,YAAY,GACZ,WAAW,GACX,aAAa,GACb,QAAQ,GACR,QAAQ,GACR,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,GAAG,GACH,MAAM,GACN,aAAa,GACb,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,IAAI,GACJ,KAAK,GACL,KAAK,GACL,KAAK,GACL,SAAS,GACT,YAAY,GACZ,iBAAiB,GACjB,eAAe,GACf,iBAAiB,GACjB,gBAAgB,GAChB,oBAAoB,GACpB,WAAW,GACX,gBAAgB,GAChB,YAAY,GACZ,mBAAmB,GACnB,oBAAoB,GACpB,oBAAoB,GACpB,WAAW,GACX,OAAO,GACP,OAAO,GACP,OAAO,GACP,QAAQ,GACR,OAAO,GACP,WAAW,GACX,aAAa,GACb,WAAW,GACX,cAAc,GACd,OAAO,CAAC;AAEd,eAAO,MAAM,YAAY;;;;;CAKf,CAAC;AAEX,KAAK,QAAQ,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,IAAI,CAAC,CAAC,EAAE,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AAEzG,qBAAa,YAAY,CAAC,CAAC,SAAS,WAAW;IAC3C,OAAO,CAAC,GAAG,CAAa;IAEjB,GAAG,CAAC,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;IAKxC,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;CAClC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const keyboardKeys = {
|
|
2
|
+
ArrowUp: "ArrowUp",
|
|
3
|
+
ArrowDown: "ArrowDown",
|
|
4
|
+
ArrowLeft: "ArrowLeft",
|
|
5
|
+
ArrowRight: "ArrowRight",
|
|
6
|
+
};
|
|
7
|
+
export class KeyboardArea {
|
|
8
|
+
set = new Set();
|
|
9
|
+
key(key, callback) {
|
|
10
|
+
const fn = (e) => (e.key === key ? callback(e) : undefined);
|
|
11
|
+
return () => this.set.delete(fn);
|
|
12
|
+
}
|
|
13
|
+
onKeyDown(_) { }
|
|
14
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React, { Dispatch, JSX, ReactNode, SetStateAction } from "react";
|
|
2
|
+
export type Label = React.ReactNode | React.ReactElement | JSX.Element;
|
|
3
|
+
export type Merge<T> = {
|
|
4
|
+
[K in keyof T]: T[K];
|
|
5
|
+
} & {};
|
|
6
|
+
export type Override<Source, New> = Omit<Source, keyof New> & New;
|
|
7
|
+
export type SetState<T> = Dispatch<SetStateAction<T>>;
|
|
8
|
+
export type POJO = object;
|
|
9
|
+
export type ComponentLike = React.ElementType;
|
|
10
|
+
export type Any = Record<string, any>;
|
|
11
|
+
export type Never = Record<string, never>;
|
|
12
|
+
export type Nil<T> = T | null | undefined;
|
|
13
|
+
export interface ReactComponent<P = Any> {
|
|
14
|
+
propTypes?: unknown;
|
|
15
|
+
displayName?: string | undefined;
|
|
16
|
+
(props: P): ReactNode | Promise<ReactNode>;
|
|
17
|
+
}
|
|
18
|
+
export type CvaVariants<T extends object> = {
|
|
19
|
+
[K in keyof T]?: keyof T[K];
|
|
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 readonly unknown[] ? 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 {};
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +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,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC;AAE9C,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAEtC,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAE1C,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC;AAE1C,MAAM,WAAW,cAAc,CAAC,CAAC,GAAG,GAAG;IACnC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjC,CAAC,KAAK,EAAE,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;CAC9C;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,IAAI;KACvC,CAAC,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;CAC9B,CAAC;AAEF,KAAK,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,CAAC;AAEtE,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAChC;KACK,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,SAAS,OAAO,EAAE,GACzC,CAAC,GACD,CAAC,SAAS,WAAW,GACnB,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GACf,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GACjB,CAAC,GACD,GAAG,CAAC,GAAG,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,GAC1C,CAAC,GACL,KAAK;CAChB,CAAC,MAAM,CAAC,CAAC,GACV,KAAK,CAAC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|