@g4rcez/components 3.0.0 → 3.0.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/ai/SKILL.md +266 -0
- package/dist/ai/docs/Alert.md +167 -0
- package/dist/ai/docs/AnimatedList.md +205 -0
- package/dist/ai/docs/Autocomplete.md +225 -0
- package/dist/ai/docs/Button.md +182 -0
- package/dist/ai/docs/Calendar.md +219 -0
- package/dist/ai/docs/Card.md +174 -0
- package/dist/ai/docs/Checkbox.md +199 -0
- package/dist/ai/docs/CommandPalette.md +293 -0
- package/dist/ai/docs/DatePicker.md +171 -0
- package/dist/ai/docs/Dropdown.md +223 -0
- package/dist/ai/docs/Empty.md +163 -0
- package/dist/ai/docs/Expand.md +143 -0
- package/dist/ai/docs/FileUpload.md +225 -0
- package/dist/ai/docs/Form.md +107 -0
- package/dist/ai/docs/FormReset.md +117 -0
- package/dist/ai/docs/Heading.md +88 -0
- package/dist/ai/docs/Input.md +237 -0
- package/dist/ai/docs/InputField.md +170 -0
- package/dist/ai/docs/List.md +205 -0
- package/dist/ai/docs/Menu.md +166 -0
- package/dist/ai/docs/Modal.md +280 -0
- package/dist/ai/docs/MultiSelect.md +196 -0
- package/dist/ai/docs/Notifications.md +231 -0
- package/dist/ai/docs/PageCalendar.md +271 -0
- package/dist/ai/docs/Polymorph.md +159 -0
- package/dist/ai/docs/Progress.md +145 -0
- package/dist/ai/docs/Radiobox.md +128 -0
- package/dist/ai/docs/RenderOnView.md +138 -0
- package/dist/ai/docs/Resizable.md +159 -0
- package/dist/ai/docs/Select.md +284 -0
- package/dist/ai/docs/Shortcut.md +105 -0
- package/dist/ai/docs/Skeleton.md +166 -0
- package/dist/ai/docs/Slider.md +144 -0
- package/dist/ai/docs/Slot.md +173 -0
- package/dist/ai/docs/Spinner.md +118 -0
- package/dist/ai/docs/Stats.md +137 -0
- package/dist/ai/docs/Step.md +159 -0
- package/dist/ai/docs/Switch.md +167 -0
- package/dist/ai/docs/Table.md +298 -0
- package/dist/ai/docs/Tabs.md +191 -0
- package/dist/ai/docs/Tag.md +224 -0
- package/dist/ai/docs/TaskList.md +144 -0
- package/dist/ai/docs/Textarea.md +167 -0
- package/dist/ai/docs/Timeline.md +210 -0
- package/dist/ai/docs/Toolbar.md +132 -0
- package/dist/ai/docs/Tooltip.md +231 -0
- package/dist/ai/docs/TransferList.md +142 -0
- package/dist/ai/docs/Typography.md +187 -0
- package/dist/ai/docs/Wizard.md +213 -0
- package/dist/ai/docs/index.md +183 -0
- package/dist/components/core/tag.d.ts +1 -1
- package/dist/components/core/tag.d.ts.map +1 -1
- package/dist/components/display/list.d.ts.map +1 -1
- package/dist/components/floating/dropdown.d.ts +1 -0
- package/dist/components/floating/dropdown.d.ts.map +1 -1
- package/dist/components/floating/menu.d.ts.map +1 -1
- package/dist/config/default-translations.d.ts +4 -4
- package/dist/hooks/use-translations.d.ts +4 -4
- package/dist/hooks/use-translations.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +28 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2463 -2458
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +12 -12
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -4
- package/dist/components/core/button.jsx +0 -79
- package/dist/components/core/heading.jsx +0 -4
- package/dist/components/core/polymorph.jsx +0 -5
- package/dist/components/core/render-on-view.jsx +0 -31
- package/dist/components/core/resizable.jsx +0 -51
- package/dist/components/core/slot.jsx +0 -156
- package/dist/components/core/tag.jsx +0 -51
- package/dist/components/core/typography.jsx +0 -22
- package/dist/components/display/alert.jsx +0 -58
- package/dist/components/display/calendar.jsx +0 -299
- package/dist/components/display/card.jsx +0 -43
- package/dist/components/display/empty.jsx +0 -11
- package/dist/components/display/list.jsx +0 -81
- package/dist/components/display/notifications.jsx +0 -126
- package/dist/components/display/progress.jsx +0 -11
- package/dist/components/display/shortcut.jsx +0 -23
- package/dist/components/display/skeleton.jsx +0 -12
- package/dist/components/display/spinner.jsx +0 -7
- package/dist/components/display/stats.jsx +0 -20
- package/dist/components/display/step.jsx +0 -131
- package/dist/components/display/tabs.jsx +0 -98
- package/dist/components/display/timeline.jsx +0 -25
- package/dist/components/floating/command-palette.jsx +0 -194
- package/dist/components/floating/dropdown.jsx +0 -53
- package/dist/components/floating/expand.jsx +0 -44
- package/dist/components/floating/menu.jsx +0 -147
- package/dist/components/floating/modal.jsx +0 -299
- package/dist/components/floating/toolbar.jsx +0 -5
- package/dist/components/floating/tooltip.jsx +0 -58
- package/dist/components/floating/wizard.jsx +0 -161
- package/dist/components/form/autocomplete.jsx +0 -279
- package/dist/components/form/checkbox.jsx +0 -12
- package/dist/components/form/date-picker.jsx +0 -115
- package/dist/components/form/file-upload.jsx +0 -133
- package/dist/components/form/form.jsx +0 -10
- package/dist/components/form/formReset.jsx +0 -17
- package/dist/components/form/free-text.jsx +0 -41
- package/dist/components/form/input-field.jsx +0 -56
- package/dist/components/form/input.jsx +0 -36
- package/dist/components/form/multi-select.jsx +0 -328
- package/dist/components/form/radiobox.jsx +0 -6
- package/dist/components/form/select.jsx +0 -42
- package/dist/components/form/slider.jsx +0 -45
- package/dist/components/form/switch.jsx +0 -46
- package/dist/components/form/task-list.jsx +0 -26
- package/dist/components/form/textarea.jsx +0 -12
- package/dist/components/form/transfer-list.jsx +0 -39
- package/dist/components/index.js +0 -45
- package/dist/components/page-calendar/calendar-header.jsx +0 -81
- package/dist/components/page-calendar/day-view.jsx +0 -87
- package/dist/components/page-calendar/event-pill.jsx +0 -25
- package/dist/components/page-calendar/index.js +0 -2
- package/dist/components/page-calendar/month-view.jsx +0 -47
- package/dist/components/page-calendar/page-calendar.jsx +0 -41
- package/dist/components/page-calendar/page-calendar.types.js +0 -1
- package/dist/components/page-calendar/page-calendar.utils.js +0 -71
- package/dist/components/page-calendar/week-view.jsx +0 -64
- package/dist/components/table/filter.jsx +0 -141
- package/dist/components/table/group.jsx +0 -68
- package/dist/components/table/index.jsx +0 -60
- package/dist/components/table/inner-table.jsx +0 -104
- package/dist/components/table/metadata.jsx +0 -36
- package/dist/components/table/pagination.jsx +0 -73
- package/dist/components/table/row.jsx +0 -58
- package/dist/components/table/sort.jsx +0 -105
- package/dist/components/table/table-lib.js +0 -83
- package/dist/components/table/table.context.jsx +0 -4
- package/dist/components/table/thead.jsx +0 -103
- package/dist/config/context.js +0 -12
- package/dist/config/default-translations.jsx +0 -83
- package/dist/config/default-tweaks.js +0 -4
- package/dist/constants.js +0 -2
- package/dist/hooks/use-click-outside.js +0 -17
- package/dist/hooks/use-color-parser.js +0 -9
- package/dist/hooks/use-components-provider.jsx +0 -19
- package/dist/hooks/use-debounce.js +0 -12
- package/dist/hooks/use-floating-ref.js +0 -6
- package/dist/hooks/use-form.js +0 -550
- package/dist/hooks/use-hover.js +0 -18
- package/dist/hooks/use-input-id.js +0 -5
- package/dist/hooks/use-is-coarse-device.js +0 -12
- package/dist/hooks/use-locale.js +0 -10
- package/dist/hooks/use-media-query.js +0 -25
- package/dist/hooks/use-on-event.js +0 -7
- package/dist/hooks/use-parent.js +0 -21
- package/dist/hooks/use-preferences.js +0 -23
- package/dist/hooks/use-previous.js +0 -9
- package/dist/hooks/use-reactive.js +0 -9
- package/dist/hooks/use-remove-scroll.js +0 -61
- package/dist/hooks/use-resize-observer.js +0 -17
- package/dist/hooks/use-stable-ref.js +0 -9
- package/dist/hooks/use-swipe.js +0 -17
- package/dist/hooks/use-translations.js +0 -9
- package/dist/hooks/use-tweaks.js +0 -9
- package/dist/hooks/use-window-size.js +0 -14
- package/dist/lib/combi-keys.js +0 -60
- package/dist/lib/dict.js +0 -39
- package/dist/lib/dom.js +0 -62
- package/dist/lib/fns.js +0 -46
- package/dist/lib/fzf.js +0 -117
- package/dist/lib/keyboard-area.js +0 -14
- package/dist/styles/common.js +0 -29
- package/dist/styles/dark.js +0 -214
- package/dist/styles/design-tokens.js +0 -69
- package/dist/styles/light.js +0 -214
- package/dist/styles/theme.js +0 -4
- package/dist/styles/theme.types.js +0 -1
- package/dist/types.js +0 -1
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "react";
|
|
2
|
-
import { Is, onlyNumbers } from "sidekicker";
|
|
3
|
-
import { hasVerticalScroll } from "../lib/dom";
|
|
4
|
-
import { isMobile, isSsr } from "../lib/fns";
|
|
5
|
-
import { useIsCoarseDevice } from "./use-is-coarse-device";
|
|
6
|
-
export const useRemoveScroll = (remove, removeStyle = "overflow-hidden") => {
|
|
7
|
-
const ref = useRef(null);
|
|
8
|
-
const isCoarseDevice = useIsCoarseDevice();
|
|
9
|
-
const prev = useRef(isSsr() ? "" : document.documentElement.style.overflowY);
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
if (ref.current === null && !remove)
|
|
12
|
-
return;
|
|
13
|
-
if (removeStyle === "block-only")
|
|
14
|
-
return;
|
|
15
|
-
if (removeStyle === "overflow-hidden") {
|
|
16
|
-
if (remove) {
|
|
17
|
-
prev.current = document.documentElement.style.overflowY;
|
|
18
|
-
document.documentElement.style.overflowY = "hidden";
|
|
19
|
-
if (isCoarseDevice || isMobile())
|
|
20
|
-
return;
|
|
21
|
-
document.documentElement.style.padding = hasVerticalScroll(document.documentElement) ? "0 15px 0 0" : "";
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
document.documentElement.style.padding = "";
|
|
25
|
-
document.documentElement.style.overflowY = prev.current;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}, [remove, isCoarseDevice, removeStyle]);
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
if (!remove)
|
|
31
|
-
return;
|
|
32
|
-
const controller = new AbortController();
|
|
33
|
-
const html = document.documentElement;
|
|
34
|
-
const removeScroll = (e) => {
|
|
35
|
-
const el = ref.current;
|
|
36
|
-
if (el) {
|
|
37
|
-
if (el.contains(e.target)) {
|
|
38
|
-
const rect = el.getBoundingClientRect();
|
|
39
|
-
const realHeight = el.style.height ? Number(onlyNumbers(el.style.height)) : null;
|
|
40
|
-
const scrollable = Is.number(realHeight) ? realHeight : rect.height;
|
|
41
|
-
const hasScroll = el.scrollHeight <= scrollable;
|
|
42
|
-
if (scrollable === el.scrollHeight)
|
|
43
|
-
return remove ? e.preventDefault() : undefined;
|
|
44
|
-
if (hasScroll)
|
|
45
|
-
return;
|
|
46
|
-
return remove ? e.preventDefault() : undefined;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (e.currentTarget === document.documentElement) {
|
|
50
|
-
return remove ? e.preventDefault() : undefined;
|
|
51
|
-
}
|
|
52
|
-
return remove ? e.preventDefault() : undefined;
|
|
53
|
-
};
|
|
54
|
-
html.addEventListener("wheel", removeScroll, { signal: controller.signal, passive: false });
|
|
55
|
-
html.addEventListener("scroll", removeScroll, { signal: controller.signal, passive: false });
|
|
56
|
-
return () => {
|
|
57
|
-
controller.abort();
|
|
58
|
-
};
|
|
59
|
-
}, [remove]);
|
|
60
|
-
return ref;
|
|
61
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect, useRef } from "react";
|
|
3
|
-
export const useResizeObserver = (element, onResize) => {
|
|
4
|
-
const onResizeRef = useRef(onResize);
|
|
5
|
-
onResizeRef.current = onResize;
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
if (!element)
|
|
8
|
-
return;
|
|
9
|
-
const observer = new ResizeObserver((entries) => {
|
|
10
|
-
if (entries[0]) {
|
|
11
|
-
onResizeRef.current(entries[0]);
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
observer.observe(element);
|
|
15
|
-
return () => observer.disconnect();
|
|
16
|
-
}, [element]);
|
|
17
|
-
};
|
package/dist/hooks/use-swipe.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useRef } from "react";
|
|
3
|
-
export function useSwipe(onSwipe, threshold) {
|
|
4
|
-
const touchStartX = useRef(null);
|
|
5
|
-
const onTouchStart = (e) => (touchStartX.current = e.touches[0].clientX);
|
|
6
|
-
const onTouchEnd = (e) => {
|
|
7
|
-
if (touchStartX.current === null)
|
|
8
|
-
return;
|
|
9
|
-
const touchEndX = e.changedTouches[0].clientX;
|
|
10
|
-
const diff = touchEndX - touchStartX.current;
|
|
11
|
-
if (Math.abs(diff) > threshold) {
|
|
12
|
-
onSwipe(e, diff > 0 ? "right" : "left");
|
|
13
|
-
}
|
|
14
|
-
touchStartX.current = null;
|
|
15
|
-
};
|
|
16
|
-
return { onTouchStart, onTouchEnd };
|
|
17
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { Context } from "../config/context";
|
|
3
|
-
import { defaultTranslations } from "../config/default-translations";
|
|
4
|
-
export const useTranslations = () => {
|
|
5
|
-
const ctx = useContext(Context);
|
|
6
|
-
if (!ctx)
|
|
7
|
-
return defaultTranslations;
|
|
8
|
-
return ctx.map;
|
|
9
|
-
};
|
package/dist/hooks/use-tweaks.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { Context } from "../config/context";
|
|
3
|
-
import { defaultTweaks } from "../config/default-tweaks";
|
|
4
|
-
export const useTweaks = () => {
|
|
5
|
-
const ctx = useContext(Context);
|
|
6
|
-
if (!ctx)
|
|
7
|
-
return defaultTweaks;
|
|
8
|
-
return ctx.tweaks;
|
|
9
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
export const useWindowSize = () => {
|
|
4
|
-
const [size, setSize] = useState({ width: 0, height: 0 });
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
if (typeof window === "undefined")
|
|
7
|
-
return;
|
|
8
|
-
const update = () => setSize({ width: window.innerWidth, height: window.innerHeight });
|
|
9
|
-
update();
|
|
10
|
-
window.addEventListener("resize", update, { passive: true });
|
|
11
|
-
return () => window.removeEventListener("resize", update);
|
|
12
|
-
}, []);
|
|
13
|
-
return size;
|
|
14
|
-
};
|
package/dist/lib/combi-keys.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
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/lib/dict.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export class Dict extends Map {
|
|
2
|
-
list = [];
|
|
3
|
-
constructor(init) {
|
|
4
|
-
super(init);
|
|
5
|
-
this.list = [];
|
|
6
|
-
if (Array.isArray(init))
|
|
7
|
-
this.list = init;
|
|
8
|
-
if (init instanceof Dict)
|
|
9
|
-
this.list = Array.from(init.entries());
|
|
10
|
-
}
|
|
11
|
-
set(key, value) {
|
|
12
|
-
super.set(key, value);
|
|
13
|
-
this.list = (this.list ?? []).concat([[key, value]]);
|
|
14
|
-
return this;
|
|
15
|
-
}
|
|
16
|
-
remove(key) {
|
|
17
|
-
super.delete(key);
|
|
18
|
-
this.list = Array.from(this.entries()) ?? [];
|
|
19
|
-
return this;
|
|
20
|
-
}
|
|
21
|
-
map(callback) {
|
|
22
|
-
return this.list.map((x, i) => callback(x[1], i));
|
|
23
|
-
}
|
|
24
|
-
clone(fn) {
|
|
25
|
-
const clone = new Dict(this);
|
|
26
|
-
if (fn)
|
|
27
|
-
return fn(clone);
|
|
28
|
-
return clone;
|
|
29
|
-
}
|
|
30
|
-
static from(items, selector) {
|
|
31
|
-
return new Dict(items.map((x) => [selector(x), x]));
|
|
32
|
-
}
|
|
33
|
-
static unique(items, selector) {
|
|
34
|
-
return Array.from(Dict.from(items, selector).values());
|
|
35
|
-
}
|
|
36
|
-
toArray() {
|
|
37
|
-
return Array.from(this.values());
|
|
38
|
-
}
|
|
39
|
-
}
|
package/dist/lib/dom.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { clsx } from "clsx";
|
|
2
|
-
import { Is } from "sidekicker";
|
|
3
|
-
import { twMerge } from "tailwind-merge";
|
|
4
|
-
export const mergeRefs = (...refs) => (value) => {
|
|
5
|
-
refs.forEach((ref) => {
|
|
6
|
-
if (typeof ref === "function") {
|
|
7
|
-
ref(value);
|
|
8
|
-
}
|
|
9
|
-
else if (ref !== null) {
|
|
10
|
-
ref.current = value;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
export const isReactComponent = (a) => {
|
|
15
|
-
if (a.$$typeof === Symbol.for("react.forward_ref")) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
if (a.$$typeof === Symbol.for("react.fragment")) {
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
return a.$$typeof === Symbol.for("react.element");
|
|
22
|
-
};
|
|
23
|
-
export const isReactFC = (a) => Is.function(a);
|
|
24
|
-
export const css = (...styles) => twMerge(clsx(styles));
|
|
25
|
-
export const dispatchInput = (input) => {
|
|
26
|
-
const event = new Event("input", { bubbles: true, composed: true });
|
|
27
|
-
input?.dispatchEvent(event);
|
|
28
|
-
return Object.assign({}, event, { target: input, currentTarget: input });
|
|
29
|
-
};
|
|
30
|
-
export const initializeInputDataset = (input) => {
|
|
31
|
-
const focus = () => input.setAttribute("data-initialized", "true");
|
|
32
|
-
input.addEventListener("focus", focus);
|
|
33
|
-
return () => input.removeEventListener("focus", focus);
|
|
34
|
-
};
|
|
35
|
-
export const hasVerticalScroll = (htmlElement) => htmlElement.scrollHeight > htmlElement.clientHeight;
|
|
36
|
-
export const getRemainingSize = (element, windowSize) => {
|
|
37
|
-
if (element && element.getBoundingClientRect) {
|
|
38
|
-
const rect = element.getBoundingClientRect();
|
|
39
|
-
return Math.abs(windowSize - rect.bottom);
|
|
40
|
-
}
|
|
41
|
-
return 320;
|
|
42
|
-
};
|
|
43
|
-
export const getCoords = (elem, docEl) => {
|
|
44
|
-
const box = elem.getBoundingClientRect();
|
|
45
|
-
const parent = docEl.getBoundingClientRect();
|
|
46
|
-
return { top: Math.round(box.top - parent.top), left: Math.round(box.left - parent.left) };
|
|
47
|
-
};
|
|
48
|
-
export const isChildVisible = (container, child, partial = true) => {
|
|
49
|
-
const containerRect = container.getBoundingClientRect();
|
|
50
|
-
const childRect = child.getBoundingClientRect();
|
|
51
|
-
const isWithinTop = childRect.top >= containerRect.top;
|
|
52
|
-
const isWithinBottom = childRect.bottom <= containerRect.bottom;
|
|
53
|
-
const isWithinLeft = childRect.left >= containerRect.left;
|
|
54
|
-
const isWithinRight = childRect.right <= containerRect.right;
|
|
55
|
-
if (partial) {
|
|
56
|
-
return (childRect.top < containerRect.bottom &&
|
|
57
|
-
childRect.bottom > containerRect.top &&
|
|
58
|
-
childRect.left < containerRect.right &&
|
|
59
|
-
childRect.right > containerRect.left);
|
|
60
|
-
}
|
|
61
|
-
return isWithinTop && isWithinBottom && isWithinLeft && isWithinRight;
|
|
62
|
-
};
|
package/dist/lib/fns.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
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
|
-
};
|
package/dist/lib/fzf.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
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/styles/common.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export const rounded = {
|
|
2
|
-
button: "0.55rem",
|
|
3
|
-
pill: "2rem",
|
|
4
|
-
card: "0.75rem",
|
|
5
|
-
full: "9999px",
|
|
6
|
-
};
|
|
7
|
-
export const spacing = {
|
|
8
|
-
base: "1rem",
|
|
9
|
-
hairline: "0.0625rem",
|
|
10
|
-
lg: "1.125rem",
|
|
11
|
-
sm: "0.75rem",
|
|
12
|
-
dialog: "20rem",
|
|
13
|
-
"field-height": "1.5rem",
|
|
14
|
-
"field-label": "0.875rem",
|
|
15
|
-
"input-height": "2.5rem",
|
|
16
|
-
"input-x": "0.5rem",
|
|
17
|
-
"input-y": "0.25rem",
|
|
18
|
-
"input-inline": "0.25rem",
|
|
19
|
-
"input-gap": "0.3rem",
|
|
20
|
-
};
|
|
21
|
-
export const zIndex = {
|
|
22
|
-
wizard: "50",
|
|
23
|
-
normal: "1",
|
|
24
|
-
navbar: "22",
|
|
25
|
-
calendar: "2",
|
|
26
|
-
overlay: "21",
|
|
27
|
-
tooltip: "20",
|
|
28
|
-
floating: "22",
|
|
29
|
-
};
|