@g4rcez/components 4.0.2 → 4.1.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/ai/SKILL.md +120 -153
- package/ai/docs/Alert.md +47 -48
- package/ai/docs/AnimatedList.md +88 -87
- package/ai/docs/Autocomplete.md +102 -106
- package/ai/docs/Button.md +33 -33
- package/ai/docs/Calendar.md +67 -101
- package/ai/docs/Card.md +59 -55
- package/ai/docs/Checkbox.md +77 -82
- package/ai/docs/CommandPalette.md +154 -172
- package/ai/docs/DatePicker.md +45 -64
- package/ai/docs/Dropdown.md +98 -126
- package/ai/docs/Empty.md +41 -44
- package/ai/docs/Expand.md +40 -54
- package/ai/docs/FileUpload.md +102 -109
- package/ai/docs/Form.md +35 -29
- package/ai/docs/FormReset.md +37 -37
- package/ai/docs/Heading.md +4 -6
- package/ai/docs/Input.md +73 -98
- package/ai/docs/InputField.md +67 -67
- package/ai/docs/List.md +88 -85
- package/ai/docs/Menu.md +62 -60
- package/ai/docs/Modal.md +129 -136
- package/ai/docs/MultiSelect.md +65 -84
- package/ai/docs/Notifications.md +96 -96
- package/ai/docs/PageCalendar.md +88 -97
- package/ai/docs/Polymorph.md +25 -41
- package/ai/docs/Progress.md +55 -51
- package/ai/docs/Radiobox.md +49 -41
- package/ai/docs/RenderOnView.md +26 -32
- package/ai/docs/Resizable.md +60 -65
- package/ai/docs/Select.md +158 -158
- package/ai/docs/Shortcut.md +14 -14
- package/ai/docs/Skeleton.md +56 -60
- package/ai/docs/Slider.md +26 -49
- package/ai/docs/Slot.md +15 -17
- package/ai/docs/Spinner.md +17 -15
- package/ai/docs/Stats.md +44 -42
- package/ai/docs/Step.md +60 -60
- package/ai/docs/Switch.md +44 -54
- package/ai/docs/Table.md +124 -136
- package/ai/docs/Tabs.md +90 -90
- package/ai/docs/Tag.md +63 -65
- package/ai/docs/TaskList.md +40 -50
- package/ai/docs/Textarea.md +47 -70
- package/ai/docs/Timeline.md +98 -96
- package/ai/docs/Toolbar.md +46 -46
- package/ai/docs/Tooltip.md +103 -103
- package/ai/docs/Typography.md +55 -55
- package/ai/docs/Wizard.md +104 -109
- package/ai/docs/index.md +116 -116
- package/dist/autocomplete-DcTNOwyg.js +393 -0
- package/dist/autocomplete-DcTNOwyg.js.map +1 -0
- package/dist/{calendar-B5lSd0ID.js → calendar-BJMHRoy2.js} +104 -105
- package/dist/calendar-BJMHRoy2.js.map +1 -0
- package/dist/components/core/button.d.ts.map +1 -1
- package/dist/components/core/button.js +10 -10
- package/dist/components/core/button.js.map +1 -1
- package/dist/components/core/button.jsx +79 -0
- package/dist/components/core/heading.jsx +4 -0
- package/dist/components/core/polymorph.d.ts +1 -1
- package/dist/components/core/polymorph.d.ts.map +1 -1
- package/dist/components/core/polymorph.jsx +5 -0
- package/dist/components/core/render-on-view.jsx +31 -0
- package/dist/components/core/resizable.jsx +51 -0
- package/dist/components/core/slot.d.ts.map +1 -1
- package/dist/components/core/slot.jsx +156 -0
- package/dist/components/core/tag.d.ts +1 -1
- package/dist/components/core/tag.d.ts.map +1 -1
- package/dist/components/core/tag.js +4 -4
- package/dist/components/core/tag.js.map +1 -1
- package/dist/components/core/tag.jsx +51 -0
- package/dist/components/core/typography.jsx +18 -0
- package/dist/components/display/alert.d.ts +1 -1
- package/dist/components/display/alert.d.ts.map +1 -1
- package/dist/components/display/alert.js +48 -46
- package/dist/components/display/alert.js.map +1 -1
- package/dist/components/display/alert.jsx +61 -0
- package/dist/components/display/calendar.js +6 -6
- package/dist/components/display/calendar.jsx +299 -0
- package/dist/components/display/card.js +2 -2
- package/dist/components/display/card.js.map +1 -1
- package/dist/components/display/card.jsx +43 -0
- package/dist/components/display/empty.jsx +11 -0
- package/dist/components/display/list.js +1 -1
- package/dist/components/display/list.js.map +1 -1
- package/dist/components/display/list.jsx +81 -0
- package/dist/components/display/notifications.d.ts +1 -1
- package/dist/components/display/notifications.d.ts.map +1 -1
- package/dist/components/display/notifications.js +3 -3
- package/dist/components/display/notifications.jsx +126 -0
- package/dist/components/display/progress.jsx +11 -0
- package/dist/components/display/shortcut.jsx +23 -0
- package/dist/components/display/skeleton.d.ts.map +1 -1
- package/dist/components/display/skeleton.jsx +19 -0
- package/dist/components/display/spinner.d.ts.map +1 -1
- package/dist/components/display/spinner.jsx +11 -0
- package/dist/components/display/stats.js +1 -1
- package/dist/components/display/stats.jsx +20 -0
- package/dist/components/display/step.jsx +131 -0
- package/dist/components/display/tabs.d.ts +1 -1
- package/dist/components/display/tabs.d.ts.map +1 -1
- package/dist/components/display/tabs.js +2 -2
- package/dist/components/display/tabs.jsx +125 -0
- package/dist/components/display/timeline.js +1 -1
- package/dist/components/display/timeline.jsx +25 -0
- package/dist/components/floating/command-palette.d.ts.map +1 -1
- package/dist/components/floating/command-palette.jsx +197 -0
- package/dist/components/floating/dropdown.d.ts.map +1 -1
- package/dist/components/floating/dropdown.js +25 -17
- package/dist/components/floating/dropdown.js.map +1 -1
- package/dist/components/floating/dropdown.jsx +56 -0
- package/dist/components/floating/expand.js +7 -7
- package/dist/components/floating/expand.js.map +1 -1
- package/dist/components/floating/expand.jsx +44 -0
- package/dist/components/floating/menu.js +10 -10
- package/dist/components/floating/menu.js.map +1 -1
- package/dist/components/floating/menu.jsx +147 -0
- package/dist/components/floating/modal.d.ts +4 -4
- package/dist/components/floating/modal.d.ts.map +1 -1
- package/dist/components/floating/modal.js +106 -102
- package/dist/components/floating/modal.js.map +1 -1
- package/dist/components/floating/modal.jsx +301 -0
- package/dist/components/floating/toolbar.jsx +5 -0
- package/dist/components/floating/tooltip.d.ts.map +1 -1
- package/dist/components/floating/tooltip.js +14 -14
- package/dist/components/floating/tooltip.js.map +1 -1
- package/dist/components/floating/tooltip.jsx +58 -0
- package/dist/components/floating/wizard.jsx +161 -0
- package/dist/components/form/autocomplete.d.ts.map +1 -1
- package/dist/components/form/autocomplete.js +6 -6
- package/dist/components/form/autocomplete.jsx +278 -0
- package/dist/components/form/checkbox.js +1 -1
- package/dist/components/form/checkbox.jsx +12 -0
- package/dist/components/form/date-picker.d.ts.map +1 -1
- package/dist/components/form/date-picker.js +5 -5
- package/dist/components/form/date-picker.jsx +115 -0
- package/dist/components/form/file-upload.d.ts.map +1 -1
- package/dist/components/form/file-upload.js +2 -2
- package/dist/components/form/file-upload.jsx +134 -0
- package/dist/components/form/form.js.map +1 -1
- package/dist/components/form/form.jsx +10 -0
- package/dist/components/form/formReset.jsx +17 -0
- package/dist/components/form/free-text.d.ts.map +1 -1
- package/dist/components/form/free-text.jsx +41 -0
- package/dist/components/form/input-field.d.ts +11 -11
- package/dist/components/form/input-field.d.ts.map +1 -1
- package/dist/components/form/input-field.jsx +58 -0
- package/dist/components/form/input.js +1 -1
- package/dist/components/form/input.jsx +36 -0
- package/dist/components/form/multi-select.d.ts.map +1 -1
- package/dist/components/form/multi-select.jsx +336 -0
- package/dist/components/form/radiobox.js +1 -1
- package/dist/components/form/radiobox.jsx +6 -0
- package/dist/components/form/select.js +3 -3
- package/dist/components/form/select.jsx +42 -0
- package/dist/components/form/slider.jsx +45 -0
- package/dist/components/form/switch.js +2 -2
- package/dist/components/form/switch.js.map +1 -1
- package/dist/components/form/switch.jsx +46 -0
- package/dist/components/form/task-list.jsx +26 -0
- package/dist/components/form/textarea.jsx +12 -0
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +44 -0
- package/dist/components/page-calendar/calendar-header.jsx +83 -0
- package/dist/components/page-calendar/day-view.jsx +94 -0
- package/dist/components/page-calendar/event-pill.d.ts.map +1 -1
- package/dist/components/page-calendar/event-pill.jsx +25 -0
- package/dist/components/page-calendar/index.js +2 -0
- package/dist/components/page-calendar/month-view.jsx +46 -0
- package/dist/components/page-calendar/page-calendar.jsx +41 -0
- package/dist/components/page-calendar/page-calendar.types.js +1 -0
- package/dist/components/page-calendar/page-calendar.utils.js +93 -0
- package/dist/components/page-calendar/week-view.jsx +71 -0
- package/dist/components/table/filter.jsx +141 -0
- package/dist/components/table/group.jsx +68 -0
- package/dist/components/table/index.d.ts +2 -3
- package/dist/components/table/index.d.ts.map +1 -1
- package/dist/components/table/index.jsx +60 -0
- package/dist/components/table/inner-table.d.ts +2 -3
- package/dist/components/table/inner-table.d.ts.map +1 -1
- package/dist/components/table/inner-table.jsx +102 -0
- package/dist/components/table/metadata.jsx +36 -0
- package/dist/components/table/pagination.d.ts +3 -1
- package/dist/components/table/pagination.d.ts.map +1 -1
- package/dist/components/table/pagination.jsx +74 -0
- package/dist/components/table/row.d.ts +4 -5
- package/dist/components/table/row.d.ts.map +1 -1
- package/dist/components/table/row.jsx +49 -0
- package/dist/components/table/sort.d.ts.map +1 -1
- package/dist/components/table/sort.jsx +109 -0
- package/dist/components/table/table-lib.d.ts +1 -1
- package/dist/components/table/table-lib.d.ts.map +1 -1
- package/dist/components/table/table-lib.js +83 -0
- package/dist/components/table/table.context.jsx +4 -0
- package/dist/components/table/table.js +3 -3
- package/dist/components/table/thead.jsx +103 -0
- package/dist/config/context.js +12 -0
- package/dist/config/default-translations.d.ts +4 -0
- package/dist/config/default-translations.d.ts.map +1 -1
- package/dist/config/default-translations.jsx +87 -0
- package/dist/config/default-tweaks.js +4 -0
- package/dist/constants.js +2 -0
- package/dist/{date-picker-DwNo22lx.js → date-picker-Bnl07nd8.js} +8 -6
- package/dist/date-picker-Bnl07nd8.js.map +1 -0
- package/dist/{dom-Dl8XH0CK.js → dom-CyQHY7ID.js} +66 -61
- package/dist/dom-CyQHY7ID.js.map +1 -0
- package/dist/{file-upload-Brf2NkLr.js → file-upload-93d5DR4q.js} +139 -129
- package/dist/file-upload-93d5DR4q.js.map +1 -0
- package/dist/{floating-ui.react-QNHG9W4N.js → floating-ui.react-M2PGXLDp.js} +8 -8
- package/dist/floating-ui.react-M2PGXLDp.js.map +1 -0
- package/dist/{fns-D2eyJKd5.js → fns-C7Dt27Qd.js} +2 -2
- package/dist/fns-C7Dt27Qd.js.map +1 -0
- package/dist/hooks/use-click-outside.js +17 -0
- package/dist/hooks/use-color-parser.js +9 -0
- package/dist/hooks/use-components-provider.jsx +22 -0
- package/dist/hooks/use-debounce.d.ts +3 -3
- package/dist/hooks/use-debounce.d.ts.map +1 -1
- package/dist/hooks/use-debounce.js +12 -0
- package/dist/hooks/use-floating-ref.js +6 -0
- package/dist/hooks/use-form.d.ts +14 -13
- package/dist/hooks/use-form.d.ts.map +1 -1
- package/dist/hooks/use-form.js +563 -0
- package/dist/hooks/use-hover.js +18 -0
- package/dist/hooks/use-input-id.js +5 -0
- package/dist/hooks/use-is-coarse-device.js +12 -0
- package/dist/hooks/use-locale.js +10 -0
- package/dist/hooks/use-media-query.js +25 -0
- package/dist/hooks/use-on-event.js +7 -0
- package/dist/hooks/use-parent.js +21 -0
- package/dist/hooks/use-preferences.js +23 -0
- package/dist/hooks/use-previous.js +9 -0
- package/dist/hooks/use-reactive.js +9 -0
- package/dist/hooks/use-remove-scroll.d.ts.map +1 -1
- package/dist/hooks/use-remove-scroll.js +48 -0
- package/dist/hooks/use-resize-observer.js +17 -0
- package/dist/hooks/use-stable-ref.js +9 -0
- package/dist/hooks/use-swipe.js +17 -0
- package/dist/hooks/use-translations.d.ts +4 -0
- package/dist/hooks/use-translations.d.ts.map +1 -1
- package/dist/hooks/use-translations.js +9 -0
- package/dist/hooks/use-tweaks.js +9 -0
- package/dist/hooks/use-window-size.js +14 -0
- package/dist/index-BJ1ayTam.js +126 -0
- package/dist/index-BJ1ayTam.js.map +1 -0
- package/dist/index-C-PuFUZi.js.map +1 -1
- package/dist/{index-BelDtX5M.js → index-DDeQW0JW.js} +399 -404
- package/dist/index-DDeQW0JW.js.map +1 -0
- package/dist/index-DE4shK8D.js +215 -0
- package/dist/index-DE4shK8D.js.map +1 -0
- package/dist/{index-DJSMaZR4.js → index-DlJ_2RBL.js} +2 -2
- package/dist/index-DlJ_2RBL.js.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.esm-BaIwleSE.js.map +1 -1
- package/dist/index.js +20 -8177
- package/dist/index.js.map +1 -1
- package/dist/{input-CrGrSnUt.js → input-_MVxmIpu.js} +116 -114
- package/dist/input-_MVxmIpu.js.map +1 -0
- package/dist/{input-field-5vYcz5tT.js → input-field-CDCOODOl.js} +63 -47
- package/dist/input-field-CDCOODOl.js.map +1 -0
- package/dist/lib/combi-keys.js +60 -0
- package/dist/lib/dict.d.ts +1 -4
- package/dist/lib/dict.d.ts.map +1 -1
- package/dist/lib/dict.js +28 -0
- package/dist/lib/dom.d.ts +3 -2
- package/dist/lib/dom.d.ts.map +1 -1
- package/dist/lib/dom.js +66 -0
- package/dist/lib/fns.js +46 -0
- package/dist/lib/fzf.d.ts.map +1 -1
- package/dist/lib/fzf.js +115 -0
- package/dist/lib/keyboard-area.js +14 -0
- package/dist/notifications-Dp0ydKJS.js +2576 -0
- package/dist/notifications-Dp0ydKJS.js.map +1 -0
- package/dist/polymorph-B5n9fs_K.js.map +1 -1
- package/dist/preset/plugin.tailwind.d.ts.map +1 -1
- package/dist/preset/plugin.tailwind.js +20 -18
- package/dist/preset/preset.tailwind.js +24 -25
- package/dist/preset/src/styles/common.js +6 -3
- package/dist/preset/src/styles/dark.d.ts.map +1 -1
- package/dist/preset/src/styles/dark.js +9 -5
- package/dist/preset/src/styles/design-tokens.js +68 -89
- package/dist/preset/src/styles/light.d.ts.map +1 -1
- package/dist/preset/src/styles/light.js +9 -5
- package/dist/preset/src/styles/theme.js +7 -4
- package/dist/preset/src/styles/theme.types.d.ts +2 -1
- package/dist/preset/src/styles/theme.types.d.ts.map +1 -1
- package/dist/preset/src/styles/theme.types.js +2 -1
- package/dist/skeleton-BjJobYYf.js +24 -0
- package/dist/skeleton-BjJobYYf.js.map +1 -0
- package/dist/slot-CRyweuj0.js.map +1 -1
- package/dist/styles/common.js +6 -3
- package/dist/styles/dark.d.ts.map +1 -1
- package/dist/styles/dark.js +9 -5
- package/dist/styles/design-tokens.js +68 -89
- package/dist/styles/light.d.ts.map +1 -1
- package/dist/styles/light.js +9 -5
- package/dist/styles/theme.js +7 -4
- package/dist/styles/theme.types.d.ts +2 -1
- package/dist/styles/theme.types.d.ts.map +1 -1
- package/dist/styles/theme.types.js +2 -1
- package/dist/tabs-B0g7YtQv.js +123 -0
- package/dist/tabs-B0g7YtQv.js.map +1 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -0
- package/dist/{context-BFXNJVn2.js → use-translations-DSltA7H_.js} +38 -30
- package/dist/use-translations-DSltA7H_.js.map +1 -0
- package/package.json +99 -86
- package/ai/docs/TransferList.md +0 -142
- package/dist/autocomplete-Cn9Z2hLq.js +0 -375
- package/dist/autocomplete-Cn9Z2hLq.js.map +0 -1
- package/dist/calendar-B5lSd0ID.js.map +0 -1
- package/dist/components/form/transfer-list.d.ts +0 -14
- package/dist/components/form/transfer-list.d.ts.map +0 -1
- package/dist/components/form/transfer-list.js +0 -55
- package/dist/components/form/transfer-list.js.map +0 -1
- package/dist/context-BFXNJVn2.js.map +0 -1
- package/dist/date-picker-DwNo22lx.js.map +0 -1
- package/dist/dom-Dl8XH0CK.js.map +0 -1
- package/dist/file-upload-Brf2NkLr.js.map +0 -1
- package/dist/floating-ui.react-QNHG9W4N.js.map +0 -1
- package/dist/fns-D2eyJKd5.js.map +0 -1
- package/dist/index-BelDtX5M.js.map +0 -1
- package/dist/index-DJSMaZR4.js.map +0 -1
- package/dist/index-Z-fZHxfJ.js +0 -335
- package/dist/index-Z-fZHxfJ.js.map +0 -1
- package/dist/input-CrGrSnUt.js.map +0 -1
- package/dist/input-field-5vYcz5tT.js.map +0 -1
- package/dist/notifications-cUdVPs-B.js +0 -2786
- package/dist/notifications-cUdVPs-B.js.map +0 -1
- package/dist/skeleton-D75GFBV6.js +0 -10
- package/dist/skeleton-D75GFBV6.js.map +0 -1
- package/dist/tabs-S00a8qq8.js +0 -106
- package/dist/tabs-S00a8qq8.js.map +0 -1
- package/dist/use-translations-BwLKTrZv.js +0 -10
- package/dist/use-translations-BwLKTrZv.js.map +0 -1
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsxs as n, jsx as a } from "react/jsx-runtime";
|
|
2
2
|
import { c as C } from "./CheckCircle.es-C6QWLfk_.js";
|
|
3
|
-
import { e as
|
|
3
|
+
import { e as q } from "./Info.es-CrZKs4q4.js";
|
|
4
4
|
import * as e from "react";
|
|
5
|
-
import { useContext as
|
|
6
|
-
import { p as
|
|
7
|
-
import { u as
|
|
8
|
-
import {
|
|
9
|
-
import { c as x } from "./dom-Dl8XH0CK.js";
|
|
5
|
+
import { useContext as D, forwardRef as R, Fragment as N } from "react";
|
|
6
|
+
import { p as O } from "./IconBase.es-DJ1oCtpo.js";
|
|
7
|
+
import { C as S, a as X, u as B } from "./use-translations-DSltA7H_.js";
|
|
8
|
+
import { c as L } from "./dom-CyQHY7ID.js";
|
|
10
9
|
import { Tooltip as G } from "./components/floating/tooltip.js";
|
|
11
10
|
const H = /* @__PURE__ */ new Map([
|
|
12
11
|
[
|
|
@@ -33,12 +32,12 @@ const H = /* @__PURE__ */ new Map([
|
|
|
33
32
|
"thin",
|
|
34
33
|
/* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("path", { d: "M162.83,98.83,133.66,128l29.17,29.17a4,4,0,0,1-5.66,5.66L128,133.66,98.83,162.83a4,4,0,0,1-5.66-5.66L122.34,128,93.17,98.83a4,4,0,0,1,5.66-5.66L128,122.34l29.17-29.17a4,4,0,1,1,5.66,5.66ZM228,128A100,100,0,1,1,128,28,100.11,100.11,0,0,1,228,128Zm-8,0a92,92,0,1,0-92,92A92.1,92.1,0,0,0,220,128Z" }))
|
|
35
34
|
]
|
|
36
|
-
]),
|
|
37
|
-
|
|
35
|
+
]), v = e.forwardRef((t, r) => /* @__PURE__ */ e.createElement(O, { ref: r, ...t, weights: H }));
|
|
36
|
+
v.displayName = "XCircleIcon";
|
|
38
37
|
const J = () => {
|
|
39
|
-
const t =
|
|
40
|
-
return t ? t.tweaks :
|
|
41
|
-
},
|
|
38
|
+
const t = D(S);
|
|
39
|
+
return t ? t.tweaks : X;
|
|
40
|
+
}, Z = ({ reportStatus: t, id: r, hideLeft: s = !1, className: p, info: l, children: o, title: i }) => /* @__PURE__ */ n("span", { className: L("w-full justify-between", s && o === null ? "hidden" : "flex", p), children: [
|
|
42
41
|
s ? null : /* @__PURE__ */ n("span", { className: "flex items-center gap-1 transition-colors group-focus-within:text-primary group-hover:text-primary group-disabled:text-disabled group-error:text-danger", children: [
|
|
43
42
|
i,
|
|
44
43
|
t || l ? /* @__PURE__ */ n("span", { className: "flex items-center justify-center gap-1", children: [
|
|
@@ -49,7 +48,7 @@ const J = () => {
|
|
|
49
48
|
type: "button",
|
|
50
49
|
"aria-label": typeof l == "string" ? l : void 0,
|
|
51
50
|
"aria-describedby": typeof l == "string" ? void 0 : r ? `tooltip-info-content-${r}` : void 0,
|
|
52
|
-
title: /* @__PURE__ */ a("span", { className: "cursor-help", children: /* @__PURE__ */ a(
|
|
51
|
+
title: /* @__PURE__ */ a("span", { className: "cursor-help", children: /* @__PURE__ */ a(q, { className: "aspect-square size-3", "aria-hidden": "true", size: 16 }) }),
|
|
53
52
|
children: /* @__PURE__ */ a(
|
|
54
53
|
"div",
|
|
55
54
|
{
|
|
@@ -70,7 +69,7 @@ const J = () => {
|
|
|
70
69
|
}
|
|
71
70
|
),
|
|
72
71
|
/* @__PURE__ */ a(
|
|
73
|
-
|
|
72
|
+
v,
|
|
74
73
|
{
|
|
75
74
|
className: "hidden aspect-square size-3 opacity-0 transition-opacity group-error:block group-error:opacity-100",
|
|
76
75
|
"aria-hidden": "true",
|
|
@@ -81,7 +80,7 @@ const J = () => {
|
|
|
81
80
|
] }) : null
|
|
82
81
|
] }),
|
|
83
82
|
o
|
|
84
|
-
] }),
|
|
83
|
+
] }), e1 = R(
|
|
85
84
|
({
|
|
86
85
|
optionalText: t,
|
|
87
86
|
left: r,
|
|
@@ -90,60 +89,69 @@ const J = () => {
|
|
|
90
89
|
feedback: l,
|
|
91
90
|
interactive: o,
|
|
92
91
|
right: i,
|
|
93
|
-
info:
|
|
94
|
-
children:
|
|
95
|
-
error:
|
|
96
|
-
form:
|
|
97
|
-
id:
|
|
98
|
-
labelClassName:
|
|
99
|
-
name:
|
|
100
|
-
title:
|
|
101
|
-
componentName:
|
|
102
|
-
placeholder:
|
|
103
|
-
hideLeft:
|
|
104
|
-
required:
|
|
92
|
+
info: d,
|
|
93
|
+
children: E,
|
|
94
|
+
error: m,
|
|
95
|
+
form: u,
|
|
96
|
+
id: M,
|
|
97
|
+
labelClassName: k = "",
|
|
98
|
+
name: A,
|
|
99
|
+
title: x,
|
|
100
|
+
componentName: F,
|
|
101
|
+
placeholder: h,
|
|
102
|
+
hideLeft: f = !1,
|
|
103
|
+
required: z,
|
|
105
104
|
disabled: c,
|
|
106
|
-
reportStatus:
|
|
107
|
-
hiddenLabel:
|
|
108
|
-
},
|
|
109
|
-
const
|
|
105
|
+
reportStatus: g,
|
|
106
|
+
hiddenLabel: T
|
|
107
|
+
}, j) => {
|
|
108
|
+
const I = J(), w = g !== void 0 ? g : I.input.iconFeedback, b = M ?? A, $ = B(), y = t ?? $.inputOptionalLabel;
|
|
110
109
|
return /* @__PURE__ */ n(
|
|
111
110
|
"fieldset",
|
|
112
111
|
{
|
|
113
|
-
ref:
|
|
114
|
-
form:
|
|
112
|
+
ref: j,
|
|
113
|
+
form: u,
|
|
115
114
|
disabled: c,
|
|
116
|
-
"data-error": !!
|
|
115
|
+
"data-error": !!m,
|
|
117
116
|
"aria-disabled": c,
|
|
118
|
-
"data-component":
|
|
117
|
+
"data-component": F,
|
|
119
118
|
"data-interactive": !!o,
|
|
120
|
-
className:
|
|
119
|
+
className: L("group flex min-h-0 min-w-0 max-w-full flex-col items-start", p),
|
|
121
120
|
children: [
|
|
122
121
|
/* @__PURE__ */ n(
|
|
123
122
|
"label",
|
|
124
123
|
{
|
|
125
|
-
form:
|
|
126
|
-
htmlFor:
|
|
124
|
+
form: u,
|
|
125
|
+
htmlFor: b,
|
|
127
126
|
className: "relative inline-flex w-full max-w-full cursor-text flex-row flex-wrap justify-between gap-1 text-field-label text-sm transition-colors empty:hidden group-disabled:cursor-not-allowed group-error:text-danger",
|
|
128
127
|
children: [
|
|
129
|
-
|
|
130
|
-
|
|
128
|
+
T ? /* @__PURE__ */ a("span", { className: "sr-only", children: /* @__PURE__ */ a(
|
|
129
|
+
Z,
|
|
130
|
+
{
|
|
131
|
+
info: d,
|
|
132
|
+
hideLeft: f,
|
|
133
|
+
reportStatus: w,
|
|
134
|
+
title: x,
|
|
135
|
+
placeholder: h
|
|
136
|
+
}
|
|
137
|
+
) }) : /* @__PURE__ */ a(Z, { info: d, hideLeft: f, reportStatus: w, title: x, placeholder: h, children: y || s ? /* @__PURE__ */ n(N, { children: [
|
|
138
|
+
z ? null : /* @__PURE__ */ a(
|
|
131
139
|
"span",
|
|
132
140
|
{
|
|
133
141
|
"aria-disabled": c,
|
|
134
142
|
className: "text-opacity-70 transition-colors group-focus-within:text-primary group-hover:text-primary aria-disabled:text-disabled",
|
|
135
|
-
children:
|
|
143
|
+
children: y
|
|
136
144
|
}
|
|
137
145
|
),
|
|
138
|
-
s ? /* @__PURE__ */ a(
|
|
146
|
+
s ? /* @__PURE__ */ a(N, { children: s }) : null
|
|
139
147
|
] }) : null }),
|
|
140
148
|
/* @__PURE__ */ n(
|
|
141
149
|
"div",
|
|
142
150
|
{
|
|
143
|
-
className: `group relative flex w-full flex-row flex-nowrap items-center gap-x-2 gap-y-1 rounded-md border border-input-border bg-transparent transition-colors group-hover:border-primary group-disabled:border-disabled group-error:border-danger ${
|
|
151
|
+
className: `group relative flex w-full flex-row flex-nowrap items-center gap-x-2 gap-y-1 rounded-md border border-input-border bg-transparent transition-colors group-hover:border-primary group-disabled:border-disabled group-error:border-danger ${k}`,
|
|
144
152
|
children: [
|
|
145
153
|
r ? /* @__PURE__ */ a("span", { className: "flex flex-nowrap gap-1 whitespace-nowrap pl-2", children: r }) : null,
|
|
146
|
-
|
|
154
|
+
E,
|
|
147
155
|
i ? /* @__PURE__ */ a("span", { className: "flex flex-nowrap gap-2 whitespace-nowrap pr-2", children: i }) : null
|
|
148
156
|
]
|
|
149
157
|
}
|
|
@@ -151,7 +159,15 @@ const J = () => {
|
|
|
151
159
|
]
|
|
152
160
|
}
|
|
153
161
|
),
|
|
154
|
-
/* @__PURE__ */ a(
|
|
162
|
+
/* @__PURE__ */ a(
|
|
163
|
+
"p",
|
|
164
|
+
{
|
|
165
|
+
id: `${b}-error`,
|
|
166
|
+
role: "alert",
|
|
167
|
+
className: "mt-input-gap hidden whitespace-pre-wrap text-wrap text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):invalid[data-initialized=true]]:flex group-error:flex group-error:text-danger",
|
|
168
|
+
children: m
|
|
169
|
+
}
|
|
170
|
+
),
|
|
155
171
|
/* @__PURE__ */ a("p", { className: "mt-input-gap text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):valid[data-initialized=true]]:block group-assert:block group-error:hidden", children: l })
|
|
156
172
|
]
|
|
157
173
|
}
|
|
@@ -159,8 +175,8 @@ const J = () => {
|
|
|
159
175
|
}
|
|
160
176
|
);
|
|
161
177
|
export {
|
|
162
|
-
|
|
163
|
-
|
|
178
|
+
e1 as I,
|
|
179
|
+
Z as a,
|
|
164
180
|
J as u
|
|
165
181
|
};
|
|
166
|
-
//# sourceMappingURL=input-field-
|
|
182
|
+
//# sourceMappingURL=input-field-CDCOODOl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"input-field-CDCOODOl.js","sources":["../../../node_modules/@phosphor-icons/react/dist/defs/XCircle.es.js","../../../node_modules/@phosphor-icons/react/dist/csr/XCircle.es.js","../src/hooks/use-tweaks.ts","../src/components/form/input-field.tsx"],"sourcesContent":["import * as e from \"react\";\nconst a = /* @__PURE__ */ new Map([\n [\n \"bold\",\n /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(\"path\", { d: \"M168.49,104.49,145,128l23.52,23.51a12,12,0,0,1-17,17L128,145l-23.51,23.52a12,12,0,0,1-17-17L111,128,87.51,104.49a12,12,0,0,1,17-17L128,111l23.51-23.52a12,12,0,0,1,17,17ZM236,128A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128Z\" }))\n ],\n [\n \"duotone\",\n /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(\"path\", { d: \"M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z\", opacity: \"0.2\" }), /* @__PURE__ */ e.createElement(\"path\", { d: \"M165.66,101.66,139.31,128l26.35,26.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z\" }))\n ],\n [\n \"fill\",\n /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(\"path\", { d: \"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm37.66,130.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32L139.31,128Z\" }))\n ],\n [\n \"light\",\n /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(\"path\", { d: \"M164.24,100.24,136.48,128l27.76,27.76a6,6,0,1,1-8.48,8.48L128,136.48l-27.76,27.76a6,6,0,0,1-8.48-8.48L119.52,128,91.76,100.24a6,6,0,0,1,8.48-8.48L128,119.52l27.76-27.76a6,6,0,0,1,8.48,8.48ZM230,128A102,102,0,1,1,128,26,102.12,102.12,0,0,1,230,128Zm-12,0a90,90,0,1,0-90,90A90.1,90.1,0,0,0,218,128Z\" }))\n ],\n [\n \"regular\",\n /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(\"path\", { d: \"M165.66,101.66,139.31,128l26.35,26.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z\" }))\n ],\n [\n \"thin\",\n /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(\"path\", { d: \"M162.83,98.83,133.66,128l29.17,29.17a4,4,0,0,1-5.66,5.66L128,133.66,98.83,162.83a4,4,0,0,1-5.66-5.66L122.34,128,93.17,98.83a4,4,0,0,1,5.66-5.66L128,122.34l29.17-29.17a4,4,0,1,1,5.66,5.66ZM228,128A100,100,0,1,1,128,28,100.11,100.11,0,0,1,228,128Zm-8,0a92,92,0,1,0-92,92A92.1,92.1,0,0,0,220,128Z\" }))\n ]\n]);\nexport {\n a as default\n};\n","import * as e from \"react\";\nimport t from \"../lib/IconBase.es.js\";\nimport a from \"../defs/XCircle.es.js\";\nconst o = e.forwardRef((r, c) => /* @__PURE__ */ e.createElement(t, { ref: c, ...r, weights: a }));\no.displayName = \"XCircleIcon\";\nconst s = o;\nexport {\n s as XCircle,\n o as XCircleIcon\n};\n","import { useContext } from \"react\";\nimport { Context } from \"../config/context\";\nimport { defaultTweaks, Tweaks } from \"../config/default-tweaks\";\n\nexport const useTweaks = (): Tweaks => {\n const ctx = useContext(Context);\n if (!ctx) return defaultTweaks;\n return ctx.tweaks!;\n};\n","\"use client\";\nimport { CheckCircleIcon, InfoIcon, XCircleIcon } from \"@phosphor-icons/react\";\nimport React, { forwardRef, Fragment, type PropsWithChildren } from \"react\";\nimport { useTranslations } from \"../../hooks/use-translations\";\nimport { useTweaks } from \"../../hooks/use-tweaks\";\nimport { css } from \"../../lib/dom\";\nimport { type Label, Override } from \"../../types\";\nimport { type PolymorphicProps } from \"../core/polymorph\";\nimport { Tooltip } from \"../floating/tooltip\";\n\nexport type FeedbackProps = React.PropsWithChildren<\n Partial<{\n id: string;\n info: Label;\n title: Label;\n hideLeft: boolean;\n className: string;\n placeholder: string;\n reportStatus: boolean;\n hiddenLabel: boolean;\n }>\n>;\n\nexport const InputFeedback = ({ reportStatus, id, hideLeft = false, className, info, children, title }: FeedbackProps) => (\n <span className={css(\"w-full justify-between\", hideLeft && children === null ? \"hidden\" : \"flex\", className)}>\n {hideLeft ? null : (\n <span className=\"flex items-center gap-1 transition-colors group-focus-within:text-primary group-hover:text-primary group-disabled:text-disabled group-error:text-danger\">\n {title}\n {reportStatus || info ? (\n <span className=\"flex items-center justify-center gap-1\">\n {info ? (\n <Tooltip\n as=\"button\"\n type=\"button\"\n aria-label={typeof info === \"string\" ? info : undefined}\n aria-describedby={typeof info === \"string\" ? undefined : id ? `tooltip-info-content-${id}` : undefined}\n title={\n <span className=\"cursor-help\">\n <InfoIcon className=\"aspect-square size-3\" aria-hidden=\"true\" size={16} />\n </span>\n }\n >\n <div\n id={id ? `tooltip-info-content-${id}` : undefined}\n className=\"w-full max-w-48 whitespace-break-spaces break-words\"\n >\n {info}\n </div>\n </Tooltip>\n ) : null}\n {reportStatus ? (\n <span className=\"flex h-3 min-w-6 items-center\">\n <CheckCircleIcon\n className=\"hidden aspect-square size-3 opacity-0 transition-opacity group-assert:block group-assert:text-success group-assert:opacity-100\"\n aria-hidden=\"true\"\n size={16}\n />\n <XCircleIcon\n className=\"hidden aspect-square size-3 opacity-0 transition-opacity group-error:block group-error:opacity-100\"\n aria-hidden=\"true\"\n size={16}\n />\n </span>\n ) : null}\n </span>\n ) : null}\n </span>\n )}\n {children}\n </span>\n);\n\nexport type InputFieldProps<T extends \"input\" | \"select\" | \"textarea\"> = PolymorphicProps<\n Partial<\n Override<\n FeedbackProps,\n {\n id: string;\n info: Label;\n left: Label;\n name: string;\n right: Label;\n error: string;\n feedback: Label;\n loading: boolean;\n container: string;\n hideLeft: boolean;\n rightLabel: Label;\n placeholder: string;\n interactive: boolean;\n optionalText: string;\n componentName: string;\n labelClassName: string;\n }\n >\n >,\n T\n>;\n\nexport const InputField: <T extends \"input\" | \"select\" | \"textarea\">(props: PropsWithChildren<InputFieldProps<T>>) => React.ReactElement = forwardRef(\n <T extends \"input\" | \"select\" | \"textarea\">(\n {\n optionalText: _optionalText,\n left,\n rightLabel,\n container,\n feedback,\n interactive,\n right,\n info,\n children,\n error,\n form,\n id,\n labelClassName = \"\",\n name,\n title,\n componentName,\n placeholder,\n hideLeft = false,\n required,\n disabled,\n reportStatus,\n hiddenLabel,\n }: PropsWithChildren<InputFieldProps<T>>,\n ref: React.Ref<HTMLFieldSetElement>\n ) => {\n const tweaks = useTweaks();\n const reportStatusDefault = reportStatus !== undefined ? reportStatus : tweaks.input.iconFeedback;\n const ID = id ?? name;\n const translation = useTranslations();\n const optionalText = _optionalText ?? translation.inputOptionalLabel;\n return (\n <fieldset\n ref={ref}\n form={form}\n disabled={disabled}\n data-error={!!error}\n aria-disabled={disabled}\n data-component={componentName}\n data-interactive={!!interactive}\n className={css(\"group flex min-h-0 min-w-0 max-w-full flex-col items-start\", container)}\n >\n <label\n form={form}\n htmlFor={ID}\n className=\"relative inline-flex w-full max-w-full cursor-text flex-row flex-wrap justify-between gap-1 text-field-label text-sm transition-colors empty:hidden group-disabled:cursor-not-allowed group-error:text-danger\"\n >\n {hiddenLabel ? (\n <span className=\"sr-only\">\n <InputFeedback\n info={info}\n hideLeft={hideLeft}\n reportStatus={reportStatusDefault}\n title={title}\n placeholder={placeholder}\n />\n </span>\n ) : (\n <InputFeedback info={info} hideLeft={hideLeft} reportStatus={reportStatusDefault} title={title} placeholder={placeholder}>\n {optionalText || rightLabel ? (\n <Fragment>\n {!required ? (\n <span\n aria-disabled={disabled}\n className=\"text-opacity-70 transition-colors group-focus-within:text-primary group-hover:text-primary aria-disabled:text-disabled\"\n >\n {optionalText}\n </span>\n ) : null}\n {rightLabel ? <Fragment>{rightLabel}</Fragment> : null}\n </Fragment>\n ) : null}\n </InputFeedback>\n )}\n <div\n className={`group relative flex w-full flex-row flex-nowrap items-center gap-x-2 gap-y-1 rounded-md border border-input-border bg-transparent transition-colors group-hover:border-primary group-disabled:border-disabled group-error:border-danger ${labelClassName}`}\n >\n {left ? <span className=\"flex flex-nowrap gap-1 whitespace-nowrap pl-2\">{left}</span> : null}\n {children}\n {right ? <span className=\"flex flex-nowrap gap-2 whitespace-nowrap pr-2\">{right}</span> : null}\n </div>\n </label>\n <p\n id={`${ID}-error`}\n role=\"alert\"\n className=\"mt-input-gap hidden whitespace-pre-wrap text-wrap text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):invalid[data-initialized=true]]:flex group-error:flex group-error:text-danger\"\n >\n {error}\n </p>\n <p className=\"mt-input-gap text-xs empty:mt-0 empty:hidden group-has-[input:not(:focus):valid[data-initialized=true]]:block group-assert:block group-error:hidden\">\n {feedback}\n </p>\n </fieldset>\n );\n }\n) as unknown as <T extends \"input\" | \"select\" | \"textarea\">(props: PropsWithChildren<InputFieldProps<T>>) => React.ReactElement; // forwardRef return is non-generic; cast restores the polymorphic signature\n"],"names":["a","e","o","r","c","t","useTweaks","ctx","useContext","Context","defaultTweaks","InputFeedback","reportStatus","id","hideLeft","className","info","children","title","jsxs","css","jsx","Tooltip","InfoIcon","CheckCircleIcon","XCircleIcon","InputField","forwardRef","_optionalText","left","rightLabel","container","feedback","interactive","right","error","form","labelClassName","name","componentName","placeholder","required","disabled","hiddenLabel","ref","tweaks","reportStatusDefault","ID","translation","useTranslations","optionalText","Fragment"],"mappings":";;;;;;;;;AACA,MAAMA,IAAoB,oBAAI,IAAI;A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
|
+
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.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
export declare class Dict<K, V> extends Map<K, V> {
|
|
2
|
-
private list;
|
|
3
|
-
constructor(init?: [K, V][] | Dict<K, V>);
|
|
4
|
-
set(key: K, value: V): this;
|
|
5
2
|
remove(key: K): this;
|
|
6
|
-
map(callback: (v: V, i: number) =>
|
|
3
|
+
map<R>(callback: (v: V, i: number) => R): R[];
|
|
7
4
|
clone(fn?: (dict: Dict<K, V>) => Dict<K, V>): Dict<K, V>;
|
|
8
5
|
static from<T>(items: T[], selector: (t: T) => any): Dict<any, T>;
|
|
9
6
|
static unique<T>(items: T[], selector: (t: T) => any): T[];
|
package/dist/lib/dict.d.ts.map
CHANGED
|
@@ -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;
|
|
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
|
+
}
|
package/dist/lib/dom.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ClassValue } from "clsx";
|
|
2
2
|
import React, { Ref, RefCallback, RefObject } from "react";
|
|
3
3
|
export declare const mergeRefs: <T>(...refs: Array<RefObject<T> | Ref<T> | undefined | null>) => RefCallback<T>;
|
|
4
|
-
export declare const isReactComponent: (a:
|
|
5
|
-
export declare const isReactFC: (a:
|
|
4
|
+
export declare const isReactComponent: (a: unknown) => a is React.ReactElement;
|
|
5
|
+
export declare const isReactFC: (a: unknown) => a is (...any: any[]) => any;
|
|
6
6
|
export declare const css: (...styles: ClassValue[]) => string;
|
|
7
|
+
export declare const synthesizeChangeEvent: (input: HTMLInputElement) => React.ChangeEvent<HTMLInputElement>;
|
|
7
8
|
export declare const dispatchInput: (input: HTMLInputElement | undefined | null) => Event & {
|
|
8
9
|
target: HTMLInputElement | null | undefined;
|
|
9
10
|
currentTarget: HTMLInputElement | null | undefined;
|
package/dist/lib/dom.d.ts.map
CHANGED
|
@@ -1 +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;AAI3D,eAAO,MAAM,SAAS,GACjB,CAAC,EAAE,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,KAAG,WAAW,CAAC,CAAC,CAS3E,CAAC;AAEN,eAAO,MAAM,gBAAgB,GAAI,GAAG,
|
|
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;AAI3D,eAAO,MAAM,SAAS,GACjB,CAAC,EAAE,GAAG,MAAM,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC,KAAG,WAAW,CAAC,CAAC,CAS3E,CAAC;AAEN,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,GAAI,OAAO,gBAAgB,KAAG,KAAK,CAAC,WAAW,CAAC,gBAAgB,CAEjG,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,OAAO,gBAAgB,GAAG,SAAS,GAAG,IAAI;;;CAIvE,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,OAAO,gBAAgB,GAAG,mBAAmB,GAAG,iBAAiB,eAIvG,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,aAAa,WAAW,YAAwD,CAAC;AAEnH,eAAO,MAAM,gBAAgB,GAAI,SAAS,WAAW,EAAE,YAAY,MAAM,WAMxE,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,MAAM,WAAW,EAAE,OAAO,WAAW;;;CAI9D,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,WAAW,WAAW,EAAE,OAAO,WAAW,EAAE,UAAS,OAAc,KAAG,OAgBpG,CAAC"}
|
package/dist/lib/dom.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
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 (typeof a !== "object" || a === null)
|
|
16
|
+
return false;
|
|
17
|
+
const elem = a;
|
|
18
|
+
if (elem.$$typeof === Symbol.for("react.forward_ref"))
|
|
19
|
+
return true;
|
|
20
|
+
if (elem.$$typeof === Symbol.for("react.fragment"))
|
|
21
|
+
return true;
|
|
22
|
+
return elem.$$typeof === Symbol.for("react.element");
|
|
23
|
+
};
|
|
24
|
+
export const isReactFC = (a) => Is.function(a);
|
|
25
|
+
export const css = (...styles) => twMerge(clsx(styles));
|
|
26
|
+
export const synthesizeChangeEvent = (input) => {
|
|
27
|
+
return { target: input, currentTarget: input };
|
|
28
|
+
};
|
|
29
|
+
export const dispatchInput = (input) => {
|
|
30
|
+
const event = new Event("input", { bubbles: true, composed: true });
|
|
31
|
+
input?.dispatchEvent(event);
|
|
32
|
+
return Object.assign({}, event, { target: input, currentTarget: input });
|
|
33
|
+
};
|
|
34
|
+
export const initializeInputDataset = (input) => {
|
|
35
|
+
const focus = () => input.setAttribute("data-initialized", "true");
|
|
36
|
+
input.addEventListener("focus", focus);
|
|
37
|
+
return () => input.removeEventListener("focus", focus);
|
|
38
|
+
};
|
|
39
|
+
export const hasVerticalScroll = (htmlElement) => htmlElement.scrollHeight > htmlElement.clientHeight;
|
|
40
|
+
export const getRemainingSize = (element, windowSize) => {
|
|
41
|
+
if (element && element.getBoundingClientRect) {
|
|
42
|
+
const rect = element.getBoundingClientRect();
|
|
43
|
+
return Math.abs(windowSize - rect.bottom);
|
|
44
|
+
}
|
|
45
|
+
return 320;
|
|
46
|
+
};
|
|
47
|
+
export const getCoords = (elem, docEl) => {
|
|
48
|
+
const box = elem.getBoundingClientRect();
|
|
49
|
+
const parent = docEl.getBoundingClientRect();
|
|
50
|
+
return { top: Math.round(box.top - parent.top), left: Math.round(box.left - parent.left) };
|
|
51
|
+
};
|
|
52
|
+
export const isChildVisible = (container, child, partial = true) => {
|
|
53
|
+
const containerRect = container.getBoundingClientRect();
|
|
54
|
+
const childRect = child.getBoundingClientRect();
|
|
55
|
+
const isWithinTop = childRect.top >= containerRect.top;
|
|
56
|
+
const isWithinBottom = childRect.bottom <= containerRect.bottom;
|
|
57
|
+
const isWithinLeft = childRect.left >= containerRect.left;
|
|
58
|
+
const isWithinRight = childRect.right <= containerRect.right;
|
|
59
|
+
if (partial) {
|
|
60
|
+
return (childRect.top < containerRect.bottom &&
|
|
61
|
+
childRect.bottom > containerRect.top &&
|
|
62
|
+
childRect.left < containerRect.right &&
|
|
63
|
+
childRect.right > containerRect.left);
|
|
64
|
+
}
|
|
65
|
+
return isWithinTop && isWithinBottom && isWithinLeft && isWithinRight;
|
|
66
|
+
};
|
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
|
+
};
|
package/dist/lib/fzf.d.ts.map
CHANGED
|
@@ -1 +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,
|
|
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,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
|
+
}
|