@code0-tech/pictor 0.0.0-mvp.21 → 0.0.0-mvp.23
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/assets/components/alert/Alert.style.css +1 -1
- package/dist/assets/components/badge/Badge.style.css +1 -1
- package/dist/assets/components/breadcrumb/Breadcrumb.style.css +1 -1
- package/dist/assets/components/button/Button.style.css +1 -1
- package/dist/assets/components/button-group/ButtonGroup.style.css +1 -1
- package/dist/assets/components/card/Card.style.css +1 -1
- package/dist/assets/components/command/Command.style.css +1 -1
- package/dist/assets/components/d-flow/folder/DFlowFolder.style.css +1 -1
- package/dist/assets/components/d-flow/function/DFlowFunctionDefaultCard.style.css +1 -1
- package/dist/assets/components/d-flow/input/DFlowInputDataType.style.css +1 -1
- package/dist/assets/components/d-layout/DLayout.style.css +1 -1
- package/dist/assets/components/dialog/Dialog.style.css +1 -1
- package/dist/assets/components/file-tabs/FileTabs.style.css +1 -1
- package/dist/assets/components/form/Input.style.css +1 -1
- package/dist/assets/components/menu/Menu.style.css +1 -1
- package/dist/assets/components/segmented-control/SegmentedControl.style.css +1 -1
- package/dist/assets/components/tab/Tab.style.css +1 -1
- package/dist/assets/components/text/Text.style.css +1 -1
- package/dist/assets/components/toast/Toast.style.css +1 -1
- package/dist/assets/components/tooltip/Tooltip.style.css +1 -1
- package/dist/components/badge/Badge.d.ts +1 -0
- package/dist/components/badge/Badge.js +12 -11
- package/dist/components/button/Button.d.ts +1 -1
- package/dist/components/d-flow/input/DFlowInputDataType.js +32 -32
- package/dist/components/d-flow/suggestion/DFlowSuggestionMenu.js +22 -22
- package/dist/components/d-flow/suggestion/DFlowSuggestionMenu.util.js +11 -11
- package/dist/components/d-flow/suggestion/DFlowSuggestionSearchInput.d.ts +1 -1
- package/dist/components/d-flow/suggestion/DFlowSuggestionSearchInput.js +29 -16
- package/dist/components/d-flow/tab/DFlowTabDefault.js +59 -53
- package/dist/components/d-member/DNamespaceMember.service.js +6 -4
- package/dist/components/d-member/DNamespaceMember.view.js +13 -11
- package/dist/components/d-member/DNamespaceMemberCard.d.ts +10 -0
- package/dist/components/d-member/DNamespaceMemberCard.js +16 -0
- package/dist/components/d-member/DNamespaceMemberContent.d.ts +10 -0
- package/dist/components/d-member/DNamespaceMemberContent.js +176 -0
- package/dist/components/d-member/DNamespaceMemberList.d.ts +12 -0
- package/dist/components/d-member/DNamespaceMemberList.js +23 -0
- package/dist/components/d-member/index.d.ts +2 -0
- package/dist/components/d-member/index.js +6 -2
- package/dist/components/d-organization/DOrganizationCard.d.ts +3 -2
- package/dist/components/d-organization/DOrganizationList.d.ts +3 -4
- package/dist/components/d-organization/DOrganizationList.js +7 -7
- package/dist/components/d-organization/DOrganizatonContent.d.ts +5 -4
- package/dist/components/d-organization/DOrganizatonContent.js +40 -25
- package/dist/components/d-organization/index.js +22 -7
- package/dist/components/d-project/DNamespaceProjectCard.d.ts +5 -5
- package/dist/components/d-project/DNamespaceProjectCard.js +13 -11
- package/dist/components/d-project/DNamespaceProjectContent.d.ts +2 -1
- package/dist/components/d-project/DNamespaceProjectContent.js +36 -42
- package/dist/components/d-project/DNamespaceProjectList.d.ts +3 -3
- package/dist/components/d-project/DNamespaceProjectList.js +1 -1
- package/dist/components/d-project/index.js +11 -17
- package/dist/components/d-role/DNamespaceRole.view.d.ts +4 -1
- package/dist/components/d-role/DNamespaceRole.view.js +6 -3
- package/dist/components/d-role/DNamespaceRoleCard.d.ts +11 -0
- package/dist/components/d-role/DNamespaceRoleCard.js +17 -0
- package/dist/components/d-role/DNamespaceRoleContent.d.ts +10 -0
- package/dist/components/d-role/DNamespaceRoleContent.js +156 -0
- package/dist/components/d-role/DNamespaceRoleList.d.ts +12 -0
- package/dist/components/d-role/DNamespaceRoleList.js +24 -0
- package/dist/components/d-role/DNamespaceRolePermissions.d.ts +5 -0
- package/dist/components/d-role/DNamespaceRolePermissions.js +129 -0
- package/dist/components/d-role/index.d.ts +2 -0
- package/dist/components/d-role/index.js +6 -2
- package/dist/components/d-runtime/DRuntimeCard.d.ts +3 -1
- package/dist/components/d-runtime/DRuntimeCard.js +13 -12
- package/dist/components/d-runtime/DRuntimeContent.d.ts +3 -1
- package/dist/components/d-runtime/DRuntimeContent.js +25 -20
- package/dist/components/d-runtime/DRuntimeList.d.ts +5 -3
- package/dist/components/d-runtime/DRuntimeList.js +21 -15
- package/dist/components/d-user/DUser.service.d.ts +1 -0
- package/dist/components/d-user/DUser.service.js +5 -2
- package/dist/components/d-user/DUserCard.d.ts +2 -1
- package/dist/components/d-user/DUserContent.d.ts +2 -1
- package/dist/components/d-user/DUserContent.js +45 -45
- package/dist/components/d-user/DUserInput.d.ts +5 -0
- package/dist/components/d-user/DUserInput.js +97 -0
- package/dist/components/d-user/DUserList.d.ts +2 -3
- package/dist/components/d-user/DUserList.js +4 -4
- package/dist/components/d-user/DUserMenu.js +7 -6
- package/dist/components/d-user/index.d.ts +1 -0
- package/dist/components/d-user/index.js +11 -9
- package/dist/components/dialog/Dialog.d.ts +2 -1
- package/dist/components/dialog/Dialog.js +67 -59
- package/dist/components/form/EmailInput.js +12 -11
- package/dist/components/form/Input.d.ts +17 -5
- package/dist/components/form/Input.js +420 -137
- package/dist/components/form/Input.selection.hook.d.ts +17 -0
- package/dist/components/form/Input.selection.hook.js +78 -0
- package/dist/components/form/Input.syntax.hook.d.ts +27 -0
- package/dist/components/form/Input.syntax.hook.js +80 -0
- package/dist/components/form/Input.utils.d.ts +11 -0
- package/dist/components/form/Input.utils.js +33 -0
- package/dist/components/form/InputSuggestion.d.ts +14 -6
- package/dist/components/form/InputSuggestion.js +126 -72
- package/dist/components/form/InputSyntax.d.ts +19 -0
- package/dist/components/form/InputSyntax.js +52 -0
- package/dist/components/form/PasswordInput.js +11 -10
- package/dist/components/form/TextInput.js +11 -10
- package/dist/components/form/index.js +26 -27
- package/dist/components/form/inputSyntaxMapping.d.ts +3 -0
- package/dist/components/form/inputSyntaxMapping.js +42 -0
- package/dist/components/menu/Menu.d.ts +7 -3
- package/dist/components/menu/Menu.js +22 -22
- package/dist/components/tooltip/Tooltip.js +33 -33
- package/dist/index.js +200 -189
- package/package.json +16 -16
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { InputSuggestion } from './InputSuggestion';
|
|
3
|
+
export type InputSyntaxSegment = {
|
|
4
|
+
type: "text" | "block";
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
visualLength?: number;
|
|
8
|
+
content?: string | React.ReactNode;
|
|
9
|
+
};
|
|
10
|
+
export type VisualizedInputSyntaxSegment = InputSyntaxSegment & {
|
|
11
|
+
visualStart: number;
|
|
12
|
+
visualEnd: number;
|
|
13
|
+
};
|
|
14
|
+
export declare const buildDefaultSyntax: (value: any) => InputSyntaxSegment[];
|
|
15
|
+
export declare const visualizeSyntaxSegments: (syntaxSegments: InputSyntaxSegment[]) => VisualizedInputSyntaxSegment[];
|
|
16
|
+
export declare const useSyntaxModel: (value: any, transformSyntax: ((value: any, appliedSyntaxParts?: (InputSuggestion | any)[]) => InputSyntaxSegment[]) | undefined, inputRef: React.RefObject<HTMLInputElement>, appliedSyntaxParts?: (InputSuggestion | any)[]) => {
|
|
17
|
+
syntaxSegments: InputSyntaxSegment[];
|
|
18
|
+
visualizedSyntaxSegments: VisualizedInputSyntaxSegment[];
|
|
19
|
+
expandSelectionRangeToBlockBoundaries: (rawStart: number, rawEnd: number) => {
|
|
20
|
+
start: number;
|
|
21
|
+
end: number;
|
|
22
|
+
hasBlockOverlap: boolean;
|
|
23
|
+
};
|
|
24
|
+
mapVisualIndexToRawIndex: (visualIndex: number) => number;
|
|
25
|
+
mapRawIndexToVisualIndex: (rawIndex: number) => number;
|
|
26
|
+
totalVisualLength: number;
|
|
27
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import c from "react";
|
|
2
|
+
const f = (i) => {
|
|
3
|
+
const a = i ?? "", s = typeof a == "string" ? a : String(a);
|
|
4
|
+
return [{
|
|
5
|
+
type: "text",
|
|
6
|
+
start: 0,
|
|
7
|
+
end: s.length,
|
|
8
|
+
visualLength: s.length,
|
|
9
|
+
content: s
|
|
10
|
+
}];
|
|
11
|
+
}, p = (i) => {
|
|
12
|
+
let a = 0;
|
|
13
|
+
return i.map((s) => {
|
|
14
|
+
const h = {
|
|
15
|
+
...s,
|
|
16
|
+
visualStart: a,
|
|
17
|
+
visualEnd: a + (s?.visualLength ?? 0)
|
|
18
|
+
};
|
|
19
|
+
return a = h.visualEnd, h;
|
|
20
|
+
});
|
|
21
|
+
}, d = (i, a, s) => Math.max(a, Math.min(i, s)), y = (i, a, s, h) => {
|
|
22
|
+
const g = c.useMemo(() => {
|
|
23
|
+
if (a) {
|
|
24
|
+
const n = a(i, h);
|
|
25
|
+
if (n?.length) return n;
|
|
26
|
+
}
|
|
27
|
+
return f(i);
|
|
28
|
+
}, [h, a, i]), u = c.useMemo(() => p(g), [g]), v = c.useCallback((n, t) => {
|
|
29
|
+
let r = Math.min(n, t), l = Math.max(n, t), o = !1;
|
|
30
|
+
return u.forEach((e) => {
|
|
31
|
+
e.type !== "block" || !(r < e.end && l > e.start) || (r = Math.min(r, e.start), l = Math.max(l, e.end), o = !0);
|
|
32
|
+
}), {
|
|
33
|
+
start: r,
|
|
34
|
+
end: l,
|
|
35
|
+
hasBlockOverlap: o
|
|
36
|
+
};
|
|
37
|
+
}, [u]), m = c.useCallback((n) => {
|
|
38
|
+
const t = u.find((e) => n >= e.visualStart && n <= e.visualEnd);
|
|
39
|
+
if (!t) {
|
|
40
|
+
const e = s.current?.value.length ?? 0;
|
|
41
|
+
return d(n, 0, e);
|
|
42
|
+
}
|
|
43
|
+
const r = t.end - t.start, l = d(n - t.visualStart, 0, t?.visualLength ?? 0);
|
|
44
|
+
if (r <= 0) return t.start;
|
|
45
|
+
if (t.type === "text")
|
|
46
|
+
return Math.min(t.start + Math.round(l), t.end);
|
|
47
|
+
if ((t?.visualLength ?? 0) <= 0) return t.start;
|
|
48
|
+
const o = l / (t?.visualLength ?? 0);
|
|
49
|
+
return Math.round(t.start + o * r);
|
|
50
|
+
}, [s, u]), M = c.useCallback((n) => {
|
|
51
|
+
const t = u.find((e) => n >= e.start && n <= e.end);
|
|
52
|
+
if (!t) {
|
|
53
|
+
const e = s.current?.value.length ?? 0;
|
|
54
|
+
return d(n, 0, e);
|
|
55
|
+
}
|
|
56
|
+
const r = t.end - t.start, l = d(n - t.start, 0, r);
|
|
57
|
+
if (r <= 0) return t.visualStart;
|
|
58
|
+
if (t.type === "text")
|
|
59
|
+
return Math.min(t.visualStart + l, t.visualEnd);
|
|
60
|
+
if ((t?.visualLength ?? 0) <= 0) return t.visualStart;
|
|
61
|
+
const o = l / r;
|
|
62
|
+
return Math.min(t.visualStart + o * (t?.visualLength ?? 0), t.visualEnd);
|
|
63
|
+
}, [s, u]), S = c.useMemo(() => {
|
|
64
|
+
const n = u[u.length - 1];
|
|
65
|
+
return n ? n.visualEnd : 0;
|
|
66
|
+
}, [u]);
|
|
67
|
+
return {
|
|
68
|
+
syntaxSegments: g,
|
|
69
|
+
visualizedSyntaxSegments: u,
|
|
70
|
+
expandSelectionRangeToBlockBoundaries: v,
|
|
71
|
+
mapVisualIndexToRawIndex: m,
|
|
72
|
+
mapRawIndexToVisualIndex: M,
|
|
73
|
+
totalVisualLength: S
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export {
|
|
77
|
+
f as buildDefaultSyntax,
|
|
78
|
+
y as useSyntaxModel,
|
|
79
|
+
p as visualizeSyntaxSegments
|
|
80
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
export declare const setElementKey: (element: HTMLElement, key: string, value: any, event: string) => void;
|
|
3
|
+
export declare const setSelectionRangeSafe: (target: HTMLInputElement, start: number, end: number, direction?: "forward" | "backward" | "none") => void;
|
|
4
|
+
export declare const getSelectionMetrics: (target: HTMLInputElement) => {
|
|
5
|
+
selectionStart: number;
|
|
6
|
+
selectionEnd: number;
|
|
7
|
+
rawStart: number;
|
|
8
|
+
rawEnd: number;
|
|
9
|
+
direction: string;
|
|
10
|
+
};
|
|
11
|
+
export declare const useSyncSyntaxScroll: (inputRef: React.RefObject<HTMLInputElement | null>, syntaxRef: React.RefObject<HTMLDivElement | null>) => () => void;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { c as l } from "../../_virtual/compiler-runtime.js";
|
|
2
|
+
const a = (t, r, e, c) => {
|
|
3
|
+
const o = Object.getOwnPropertyDescriptor(t, r)?.set, s = Object.getPrototypeOf(t), n = Object.getOwnPropertyDescriptor(s, r)?.set;
|
|
4
|
+
o && o !== n ? n?.call(t, e) : o?.call(t, e), t.dispatchEvent(new Event(c, {
|
|
5
|
+
bubbles: !0
|
|
6
|
+
}));
|
|
7
|
+
}, S = (t, r, e, c) => {
|
|
8
|
+
try {
|
|
9
|
+
t.setSelectionRange(r, e, c);
|
|
10
|
+
} catch {
|
|
11
|
+
}
|
|
12
|
+
}, p = (t) => {
|
|
13
|
+
const r = t.selectionStart ?? 0, e = t.selectionEnd ?? r;
|
|
14
|
+
return {
|
|
15
|
+
selectionStart: r,
|
|
16
|
+
selectionEnd: e,
|
|
17
|
+
rawStart: Math.min(r, e),
|
|
18
|
+
rawEnd: Math.max(r, e),
|
|
19
|
+
direction: t.selectionDirection === "backward" ? "backward" : "forward"
|
|
20
|
+
};
|
|
21
|
+
}, u = (t, r) => {
|
|
22
|
+
const e = l.c(3);
|
|
23
|
+
let c;
|
|
24
|
+
return e[0] !== t || e[1] !== r ? (c = () => {
|
|
25
|
+
!t.current || !r.current || (r.current.scrollLeft = t.current.scrollLeft);
|
|
26
|
+
}, e[0] = t, e[1] = r, e[2] = c) : c = e[2], c;
|
|
27
|
+
};
|
|
28
|
+
export {
|
|
29
|
+
p as getSelectionMetrics,
|
|
30
|
+
a as setElementKey,
|
|
31
|
+
S as setSelectionRangeSafe,
|
|
32
|
+
u as useSyncSyntaxScroll
|
|
33
|
+
};
|
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
import { MenuContentProps } from '../menu/Menu';
|
|
2
|
-
import { default as React } from 'react';
|
|
2
|
+
import { default as React, RefObject } from 'react';
|
|
3
3
|
export interface InputSuggestion {
|
|
4
4
|
children: React.ReactNode;
|
|
5
5
|
value: any;
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
valueData?: any;
|
|
7
|
+
groupBy?: string;
|
|
8
|
+
insertMode?: "replace" | "append" | "prepend" | "insert";
|
|
8
9
|
}
|
|
9
|
-
export type InputSuggestionMenuContentProps = MenuContentProps
|
|
10
|
+
export type InputSuggestionMenuContentProps = MenuContentProps & {
|
|
11
|
+
inputRef?: RefObject<HTMLInputElement>;
|
|
12
|
+
};
|
|
10
13
|
export interface InputSuggestionMenuContentItemsProps {
|
|
11
14
|
suggestions?: InputSuggestion[];
|
|
12
15
|
onSuggestionSelect?: (suggestion: InputSuggestion) => void;
|
|
16
|
+
inputRef?: RefObject<HTMLInputElement>;
|
|
13
17
|
}
|
|
14
18
|
export interface InputSuggestionMenuContentItemsHandle {
|
|
15
|
-
focusFirstItem: () =>
|
|
16
|
-
focusLastItem: () =>
|
|
19
|
+
focusFirstItem: () => InputSuggestion | undefined;
|
|
20
|
+
focusLastItem: () => InputSuggestion | undefined;
|
|
21
|
+
highlightNextItem: () => InputSuggestion | undefined;
|
|
22
|
+
highlightPreviousItem: () => InputSuggestion | undefined;
|
|
23
|
+
selectActiveItem: () => InputSuggestion | undefined;
|
|
24
|
+
clearActiveItem: () => void;
|
|
17
25
|
}
|
|
18
26
|
export declare const InputSuggestionMenuContent: React.FC<InputSuggestionMenuContentProps>;
|
|
19
27
|
export declare const InputSuggestionMenuContentItems: React.FC<InputSuggestionMenuContentItemsProps>;
|
|
@@ -1,102 +1,156 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { c as
|
|
3
|
-
import { MenuContent as
|
|
4
|
-
import
|
|
5
|
-
import { ScrollArea as
|
|
6
|
-
import { IconChevronDown as
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
let
|
|
10
|
-
|
|
11
|
-
children:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { jsx as d, jsxs as C } from "react/jsx-runtime";
|
|
2
|
+
import { c as R } from "../../_virtual/compiler-runtime.js";
|
|
3
|
+
import { MenuContent as D, MenuLabel as E, MenuItem as G } from "../menu/Menu.js";
|
|
4
|
+
import u from "react";
|
|
5
|
+
import { ScrollArea as L, ScrollAreaViewport as P, ScrollAreaScrollbar as F, ScrollAreaThumb as O } from "../scroll-area/ScrollArea.js";
|
|
6
|
+
import { IconChevronDown as T, IconChevronUp as V } from "@tabler/icons-react";
|
|
7
|
+
const K = u.forwardRef((l, S) => {
|
|
8
|
+
const t = R.c(12);
|
|
9
|
+
let i, h, m;
|
|
10
|
+
t[0] !== l ? ({
|
|
11
|
+
children: i,
|
|
12
|
+
inputRef: h,
|
|
13
|
+
...m
|
|
14
|
+
} = l, t[0] = l, t[1] = i, t[2] = h, t[3] = m) : (i = t[1], h = t[2], m = t[3]);
|
|
15
|
+
const v = u.useRef(null);
|
|
16
|
+
let c, s;
|
|
17
|
+
t[4] !== h ? (c = (a) => {
|
|
18
|
+
a.preventDefault(), h?.current?.focus({
|
|
19
|
+
preventScroll: !0
|
|
20
|
+
});
|
|
21
|
+
}, s = () => h?.current?.focus({
|
|
22
|
+
preventScroll: !0
|
|
23
|
+
}), t[4] = h, t[5] = c, t[6] = s) : (c = t[5], s = t[6]);
|
|
24
|
+
let o;
|
|
25
|
+
return t[7] !== i || t[8] !== m || t[9] !== c || t[10] !== s ? (o = /* @__PURE__ */ d(D, { ref: v, onContextMenuCapture: j, onInteractOutside: k, onCloseAutoFocus: z, onOpenAutoFocus: c, onFocusCapture: s, align: "start", sideOffset: 8, ...m, children: i }), t[7] = i, t[8] = m, t[9] = c, t[10] = s, t[11] = o) : o = t[11], o;
|
|
26
|
+
}), Q = u.forwardRef((l, S) => {
|
|
18
27
|
const {
|
|
19
|
-
suggestions:
|
|
20
|
-
onSuggestionSelect:
|
|
28
|
+
suggestions: t,
|
|
29
|
+
onSuggestionSelect: i = () => {
|
|
21
30
|
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
l.
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
inputRef: h,
|
|
32
|
+
...m
|
|
33
|
+
} = l, v = u.useRef([]), [c, s] = u.useState({}), [o, a] = u.useState(null);
|
|
34
|
+
u.useEffect(() => {
|
|
35
|
+
if (!t) {
|
|
36
|
+
s({});
|
|
27
37
|
return;
|
|
28
38
|
}
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
}),
|
|
39
|
+
s((e) => {
|
|
40
|
+
const r = {};
|
|
41
|
+
return t.forEach((f) => {
|
|
42
|
+
f.groupBy && (e.hasOwnProperty(f.groupBy) ? r[f.groupBy] = e[f.groupBy] : r[f.groupBy] = !1);
|
|
43
|
+
}), r;
|
|
34
44
|
});
|
|
35
|
-
}, [
|
|
45
|
+
}, [t]);
|
|
36
46
|
const {
|
|
37
|
-
groupLabelCount:
|
|
38
|
-
visibleSuggestionCount:
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
groupLabelCount: B,
|
|
48
|
+
visibleSuggestionCount: M,
|
|
49
|
+
visibleSuggestions: n
|
|
50
|
+
} = u.useMemo(() => {
|
|
51
|
+
if (!t) return {
|
|
41
52
|
groupLabelCount: 0,
|
|
42
|
-
visibleSuggestionCount: 0
|
|
53
|
+
visibleSuggestionCount: 0,
|
|
54
|
+
visibleSuggestions: []
|
|
43
55
|
};
|
|
44
|
-
let
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
56
|
+
let e = 0, r = 0;
|
|
57
|
+
const f = [];
|
|
58
|
+
return t.forEach((g, y, I) => {
|
|
59
|
+
const p = y > 0 ? I[y - 1]?.groupBy : void 0;
|
|
60
|
+
g.groupBy && g.groupBy !== p && (e += 1), (g.groupBy ? c[g.groupBy] : !1) || (r += 1, f.push(g));
|
|
48
61
|
}), {
|
|
49
|
-
groupLabelCount:
|
|
50
|
-
visibleSuggestionCount:
|
|
62
|
+
groupLabelCount: e,
|
|
63
|
+
visibleSuggestionCount: r,
|
|
64
|
+
visibleSuggestions: f
|
|
51
65
|
};
|
|
52
|
-
}, [c,
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
}, [c, t]);
|
|
67
|
+
u.useEffect(() => {
|
|
68
|
+
a((e) => e === null ? e : e > n.length - 1 ? n.length ? n.length - 1 : null : e);
|
|
69
|
+
}, [n]), u.useEffect(() => {
|
|
70
|
+
o !== null && v.current[o]?.scrollIntoView({
|
|
71
|
+
block: "nearest"
|
|
72
|
+
});
|
|
73
|
+
}, [o]), u.useImperativeHandle(S, () => ({
|
|
74
|
+
focusFirstItem: () => {
|
|
75
|
+
if (n.length)
|
|
76
|
+
return a(0), n[0];
|
|
77
|
+
},
|
|
78
|
+
focusLastItem: () => {
|
|
79
|
+
if (!n.length) return;
|
|
80
|
+
const e = n.length - 1;
|
|
81
|
+
return a(e), n[e];
|
|
82
|
+
},
|
|
83
|
+
highlightNextItem: () => {
|
|
84
|
+
if (!n.length) return;
|
|
85
|
+
a((r) => r === null ? 0 : Math.min(r + 1, n.length - 1));
|
|
86
|
+
const e = o === null ? 0 : Math.min(o + 1, n.length - 1);
|
|
87
|
+
return n[e];
|
|
88
|
+
},
|
|
89
|
+
highlightPreviousItem: () => {
|
|
90
|
+
if (!n.length) return;
|
|
91
|
+
a((r) => r === null ? n.length - 1 : Math.max(r - 1, 0));
|
|
92
|
+
const e = o === null ? n.length - 1 : Math.max(o - 1, 0);
|
|
93
|
+
return n[e];
|
|
94
|
+
},
|
|
95
|
+
selectActiveItem: () => {
|
|
96
|
+
if (o === null || !n[o]) return;
|
|
97
|
+
const e = n[o];
|
|
98
|
+
return setTimeout(() => i(e), 0), e;
|
|
99
|
+
},
|
|
100
|
+
clearActiveItem: () => a(null)
|
|
101
|
+
}), [o, i, n]);
|
|
102
|
+
const w = (e) => {
|
|
103
|
+
s((r) => ({
|
|
104
|
+
...r,
|
|
105
|
+
[e]: !r[e]
|
|
56
106
|
}));
|
|
57
107
|
};
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
let C = i.current.length;
|
|
66
|
-
return /* @__PURE__ */ d(l.Fragment, { children: [
|
|
67
|
-
b && r.groupLabel && /* @__PURE__ */ d(M, { onPointerDown: (L) => L.preventDefault(), onClick: () => g(r.groupLabel), style: {
|
|
108
|
+
v.current = [];
|
|
109
|
+
let A = -1;
|
|
110
|
+
return /* @__PURE__ */ C(L, { h: `${Math.max(M + B, 1) * 27}px`, mah: "calc(var(--radix-popper-available-height) - 3rem - 69px)", ...m, children: [
|
|
111
|
+
/* @__PURE__ */ d(P, { children: t?.map((e, r, f) => {
|
|
112
|
+
const g = r > 0 ? f[r - 1]?.groupBy : void 0, y = e.groupBy && e.groupBy !== g, I = e.groupBy ? c[e.groupBy] : !1, p = I ? null : ++A, b = p !== null && o === p;
|
|
113
|
+
return /* @__PURE__ */ C(u.Fragment, { children: [
|
|
114
|
+
y && e.groupBy && /* @__PURE__ */ C(E, { onPointerDown: (x) => x.preventDefault(), onClick: () => w(e.groupBy), style: {
|
|
68
115
|
display: "flex",
|
|
69
116
|
alignItems: "center",
|
|
70
117
|
justifyContent: "space-between",
|
|
71
118
|
cursor: "pointer"
|
|
72
119
|
}, children: [
|
|
73
|
-
/* @__PURE__ */
|
|
74
|
-
|
|
120
|
+
/* @__PURE__ */ d("span", { children: e.groupBy }),
|
|
121
|
+
I ? /* @__PURE__ */ d(T, { size: 16 }) : /* @__PURE__ */ d(V, { size: 16 })
|
|
75
122
|
] }),
|
|
76
|
-
!
|
|
77
|
-
|
|
123
|
+
!I && /* @__PURE__ */ d(
|
|
124
|
+
G,
|
|
78
125
|
{
|
|
79
126
|
textValue: "",
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
127
|
+
onPointerDown: (x) => {
|
|
128
|
+
x.preventDefault(), h?.current?.focus({
|
|
129
|
+
preventScroll: !0
|
|
130
|
+
}), p !== null && a(p);
|
|
131
|
+
},
|
|
132
|
+
onPointerMove: () => p !== null && a(p),
|
|
133
|
+
onSelect: () => setTimeout(() => i(e), 0),
|
|
134
|
+
"data-focus": b,
|
|
135
|
+
ref: (x) => p !== null && (v.current[p] = x),
|
|
136
|
+
children: e.children
|
|
83
137
|
}
|
|
84
138
|
)
|
|
85
|
-
] },
|
|
139
|
+
] }, r);
|
|
86
140
|
}) }),
|
|
87
|
-
/* @__PURE__ */
|
|
141
|
+
/* @__PURE__ */ d(F, { orientation: "vertical", children: /* @__PURE__ */ d(O, {}) })
|
|
88
142
|
] });
|
|
89
143
|
});
|
|
90
|
-
function j(
|
|
91
|
-
return
|
|
144
|
+
function j(l) {
|
|
145
|
+
return l.stopPropagation();
|
|
92
146
|
}
|
|
93
|
-
function
|
|
94
|
-
return
|
|
147
|
+
function k(l) {
|
|
148
|
+
return l.target instanceof HTMLInputElement && l.preventDefault();
|
|
95
149
|
}
|
|
96
|
-
function
|
|
97
|
-
return
|
|
150
|
+
function z(l) {
|
|
151
|
+
return l.preventDefault();
|
|
98
152
|
}
|
|
99
153
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
154
|
+
K as InputSuggestionMenuContent,
|
|
155
|
+
Q as InputSuggestionMenuContentItems
|
|
102
156
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { VisualizedInputSyntaxSegment } from './Input.syntax.hook';
|
|
3
|
+
import { InputSuggestion } from './InputSuggestion';
|
|
4
|
+
export type ResolvedVisualSelectionRange = {
|
|
5
|
+
start: number;
|
|
6
|
+
end: number;
|
|
7
|
+
} | null;
|
|
8
|
+
export interface InputSyntaxProps {
|
|
9
|
+
transformSyntax?: ((value: any, appliedSyntaxParts?: (InputSuggestion | any)[]) => any);
|
|
10
|
+
syntaxRef: React.RefObject<HTMLDivElement | null>;
|
|
11
|
+
visualizedSyntaxSegments: VisualizedInputSyntaxSegment[];
|
|
12
|
+
resolvedVisualSelectionRange: ResolvedVisualSelectionRange;
|
|
13
|
+
visualCaretIndex: number | null;
|
|
14
|
+
isFocused: boolean;
|
|
15
|
+
onPointerDown: (event: React.PointerEvent<HTMLDivElement>) => void;
|
|
16
|
+
onPointerMove: (event: React.PointerEvent<HTMLDivElement>) => void;
|
|
17
|
+
onPointerUp: (event: React.PointerEvent<HTMLDivElement>) => void;
|
|
18
|
+
}
|
|
19
|
+
export declare const InputSyntax: React.FC<InputSyntaxProps>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { jsx as x, jsxs as $ } from "react/jsx-runtime";
|
|
2
|
+
import { c as b } from "../../_virtual/compiler-runtime.js";
|
|
3
|
+
const k = (v, a, l, o) => {
|
|
4
|
+
let d = !1;
|
|
5
|
+
const c = (t, n) => l ? l.start < n && l.end > t : !1, i = (t) => {
|
|
6
|
+
if (!a || l || o === null || d) return !1;
|
|
7
|
+
const n = Math.round(o) === Math.round(t);
|
|
8
|
+
return n && (d = !0), n;
|
|
9
|
+
}, s = (t) => /* @__PURE__ */ x("span", { className: "input__syntax-caret", "data-visual-index": t, "aria-hidden": !0 }, `caret-${t}`);
|
|
10
|
+
return v.map((t, n) => {
|
|
11
|
+
const e = `${t.start}-${t.end}-${n}`, r = typeof t.content == "string" ? t.content : t.content ?? null, u = [t.type === "block" ? "input__syntax-block" : "input__syntax-text", t.type === "block" && c(t.visualStart, t.visualEnd) ? "input__syntax-block--selected" : ""].filter(Boolean).join(" "), y = {
|
|
12
|
+
"data-visual-start": t.visualStart,
|
|
13
|
+
"data-visual-end": t.visualEnd,
|
|
14
|
+
"data-visual-length": t.visualLength,
|
|
15
|
+
"data-raw-start": t.start,
|
|
16
|
+
"data-raw-end": t.end
|
|
17
|
+
};
|
|
18
|
+
if (typeof r == "string" && t.type === "text") {
|
|
19
|
+
const p = [];
|
|
20
|
+
return r.split("").forEach((_, h) => {
|
|
21
|
+
const f = t.visualStart + h, S = t.start + h, E = c(f, f + 1);
|
|
22
|
+
i(f) && p.push(s(f)), p.push(/* @__PURE__ */ x("span", { "data-visual-index": f, "data-raw-index": S, className: E ? "input__syntax-char--selected" : "", "aria-hidden": !0, children: _ === " " ? " " : _ }, `${e}-char-${h}`));
|
|
23
|
+
}), i(t.visualEnd) && p.push(s(t.visualEnd)), /* @__PURE__ */ x("span", { className: u, "aria-hidden": !0, ...y, children: p }, e);
|
|
24
|
+
}
|
|
25
|
+
return /* @__PURE__ */ $("span", { className: u, "aria-hidden": !0, ...y, children: [
|
|
26
|
+
i(t.visualStart) && s(t.visualStart),
|
|
27
|
+
r,
|
|
28
|
+
i(t.visualEnd) && s(t.visualEnd)
|
|
29
|
+
] }, e);
|
|
30
|
+
});
|
|
31
|
+
}, j = (v) => {
|
|
32
|
+
const a = b.c(11), {
|
|
33
|
+
transformSyntax: l,
|
|
34
|
+
syntaxRef: o,
|
|
35
|
+
visualizedSyntaxSegments: d,
|
|
36
|
+
resolvedVisualSelectionRange: c,
|
|
37
|
+
visualCaretIndex: i,
|
|
38
|
+
isFocused: s,
|
|
39
|
+
onPointerDown: t,
|
|
40
|
+
onPointerMove: n,
|
|
41
|
+
onPointerUp: e
|
|
42
|
+
} = v;
|
|
43
|
+
if (!l)
|
|
44
|
+
return null;
|
|
45
|
+
let r;
|
|
46
|
+
a[0] !== s || a[1] !== c || a[2] !== i || a[3] !== d ? (r = k(d, s, c, i), a[0] = s, a[1] = c, a[2] = i, a[3] = d, a[4] = r) : r = a[4];
|
|
47
|
+
let u;
|
|
48
|
+
return a[5] !== t || a[6] !== n || a[7] !== e || a[8] !== o || a[9] !== r ? (u = /* @__PURE__ */ x("div", { className: "input__syntax", ref: o, onPointerDown: t, onPointerMove: n, onPointerUp: e, children: r }), a[5] = t, a[6] = n, a[7] = e, a[8] = o, a[9] = r, a[10] = u) : u = a[10], u;
|
|
49
|
+
};
|
|
50
|
+
export {
|
|
51
|
+
j as InputSyntax
|
|
52
|
+
};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { Input as h
|
|
4
|
-
import { IconEye as
|
|
2
|
+
import n from "react";
|
|
3
|
+
import { Input as h } from "./Input.js";
|
|
4
|
+
import { IconEye as y, IconX as d } from "@tabler/icons-react";
|
|
5
5
|
import { Button as i } from "../button/Button.js";
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import { setElementKey as g } from "./Input.utils.js";
|
|
7
|
+
const C = n.forwardRef((s, t) => {
|
|
8
|
+
t = t || n.useRef(null);
|
|
8
9
|
const {
|
|
9
|
-
clearable:
|
|
10
|
-
visible:
|
|
10
|
+
clearable: p = !0,
|
|
11
|
+
visible: a = !0,
|
|
11
12
|
right: c,
|
|
12
13
|
...u
|
|
13
|
-
} = s, l = (r) => (t.current &&
|
|
14
|
-
return
|
|
14
|
+
} = s, l = (r) => (t.current && g(t.current, "value", "", "change"), r.stopPropagation(), r.preventDefault(), !1), m = (r) => (t.current && t.current.type == "password" ? t.current.type = "text" : t.current && t.current.type == "text" && (t.current.type = "password"), r.stopPropagation(), r.preventDefault(), !1), o = [c];
|
|
15
|
+
return a && o.push(/* @__PURE__ */ e(i, { variant: "none", onClick: (r) => m(r), children: /* @__PURE__ */ e(y, { size: 13 }) })), p && o.push(/* @__PURE__ */ e(i, { variant: "none", onClick: (r) => l(r), children: /* @__PURE__ */ e(d, { size: 13 }) })), /* @__PURE__ */ e(h, { right: o, rightType: "action", type: "password", ref: t, ...u });
|
|
15
16
|
});
|
|
16
17
|
export {
|
|
17
|
-
|
|
18
|
+
C as PasswordInput
|
|
18
19
|
};
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import i from "react";
|
|
3
|
-
import { Input as u
|
|
4
|
-
import { IconX as
|
|
5
|
-
import { Button as
|
|
6
|
-
|
|
3
|
+
import { Input as u } from "./Input.js";
|
|
4
|
+
import { IconX as s } from "@tabler/icons-react";
|
|
5
|
+
import { Button as f } from "../button/Button.js";
|
|
6
|
+
import { setElementKey as p } from "./Input.utils.js";
|
|
7
|
+
const b = i.forwardRef((r, t) => {
|
|
7
8
|
t = t || i.useRef(null);
|
|
8
9
|
const {
|
|
9
10
|
clearable: a = !1,
|
|
10
11
|
right: c,
|
|
11
12
|
...l
|
|
12
|
-
} =
|
|
13
|
-
t.current &&
|
|
14
|
-
},
|
|
15
|
-
return a &&
|
|
13
|
+
} = r, m = (e) => {
|
|
14
|
+
t.current && p(t.current, "value", "", "change"), r.onClear && r.onClear(e);
|
|
15
|
+
}, n = [c];
|
|
16
|
+
return a && n.push(/* @__PURE__ */ o(f, { variant: "none", onClick: (e) => m(e), children: /* @__PURE__ */ o(s, { size: 13 }) })), /* @__PURE__ */ o(u, { right: n, type: "text", ref: t, ...l });
|
|
16
17
|
});
|
|
17
18
|
export {
|
|
18
|
-
|
|
19
|
+
b as TextInput
|
|
19
20
|
};
|
|
@@ -1,37 +1,36 @@
|
|
|
1
|
-
import { CheckboxInput as
|
|
1
|
+
import { CheckboxInput as r } from "./CheckboxInput.js";
|
|
2
2
|
import { EmailInput as p, emailValidation as n } from "./EmailInput.js";
|
|
3
|
-
import { Input as m
|
|
4
|
-
import { InputDescription as
|
|
5
|
-
import { InputLabel as
|
|
6
|
-
import { InputMessage as
|
|
7
|
-
import { InputSuggestionMenuContent as
|
|
8
|
-
import { NumberInput as
|
|
9
|
-
import { PasswordInput as
|
|
10
|
-
import { PinInput as
|
|
3
|
+
import { Input as m } from "./Input.js";
|
|
4
|
+
import { InputDescription as x } from "./InputDescription.js";
|
|
5
|
+
import { InputLabel as f } from "./InputLabel.js";
|
|
6
|
+
import { InputMessage as s } from "./InputMessage.js";
|
|
7
|
+
import { InputSuggestionMenuContent as l, InputSuggestionMenuContentItems as g } from "./InputSuggestion.js";
|
|
8
|
+
import { NumberInput as b } from "./NumberInput.js";
|
|
9
|
+
import { PasswordInput as C } from "./PasswordInput.js";
|
|
10
|
+
import { PinInput as M, PinInputField as S, PinInputHiddenField as h } from "./PinInput.js";
|
|
11
11
|
import { RadioGroup as R } from "./RadioGroup.js";
|
|
12
|
-
import { RadioInput as
|
|
12
|
+
import { RadioInput as D } from "./RadioInput.js";
|
|
13
13
|
import { SwitchInput as G } from "./SwitchInput.js";
|
|
14
|
-
import { TextInput as
|
|
15
|
-
import { useForm as
|
|
14
|
+
import { TextInput as L } from "./TextInput.js";
|
|
15
|
+
import { useForm as T } from "./useForm.js";
|
|
16
16
|
export {
|
|
17
|
-
|
|
17
|
+
r as CheckboxInput,
|
|
18
18
|
p as EmailInput,
|
|
19
19
|
m as Input,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
x as InputDescription,
|
|
21
|
+
f as InputLabel,
|
|
22
|
+
s as InputMessage,
|
|
23
|
+
l as InputSuggestionMenuContent,
|
|
24
|
+
g as InputSuggestionMenuContentItems,
|
|
25
|
+
b as NumberInput,
|
|
26
|
+
C as PasswordInput,
|
|
27
|
+
M as PinInput,
|
|
28
|
+
S as PinInputField,
|
|
29
|
+
h as PinInputHiddenField,
|
|
30
30
|
R as RadioGroup,
|
|
31
|
-
|
|
31
|
+
D as RadioInput,
|
|
32
32
|
G as SwitchInput,
|
|
33
|
-
|
|
33
|
+
L as TextInput,
|
|
34
34
|
n as emailValidation,
|
|
35
|
-
|
|
36
|
-
N as useForm
|
|
35
|
+
T as useForm
|
|
37
36
|
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { InputSyntaxSegment } from './Input.syntax.hook';
|
|
2
|
+
export declare const visualIndexToRawIndex: (visualIndex: number, segments: InputSyntaxSegment[]) => number;
|
|
3
|
+
export declare const rawIndexToVisualIndex: (rawIndex: number, segments: InputSyntaxSegment[]) => number;
|