@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.
Files changed (107) hide show
  1. package/dist/assets/components/alert/Alert.style.css +1 -1
  2. package/dist/assets/components/badge/Badge.style.css +1 -1
  3. package/dist/assets/components/breadcrumb/Breadcrumb.style.css +1 -1
  4. package/dist/assets/components/button/Button.style.css +1 -1
  5. package/dist/assets/components/button-group/ButtonGroup.style.css +1 -1
  6. package/dist/assets/components/card/Card.style.css +1 -1
  7. package/dist/assets/components/command/Command.style.css +1 -1
  8. package/dist/assets/components/d-flow/folder/DFlowFolder.style.css +1 -1
  9. package/dist/assets/components/d-flow/function/DFlowFunctionDefaultCard.style.css +1 -1
  10. package/dist/assets/components/d-flow/input/DFlowInputDataType.style.css +1 -1
  11. package/dist/assets/components/d-layout/DLayout.style.css +1 -1
  12. package/dist/assets/components/dialog/Dialog.style.css +1 -1
  13. package/dist/assets/components/file-tabs/FileTabs.style.css +1 -1
  14. package/dist/assets/components/form/Input.style.css +1 -1
  15. package/dist/assets/components/menu/Menu.style.css +1 -1
  16. package/dist/assets/components/segmented-control/SegmentedControl.style.css +1 -1
  17. package/dist/assets/components/tab/Tab.style.css +1 -1
  18. package/dist/assets/components/text/Text.style.css +1 -1
  19. package/dist/assets/components/toast/Toast.style.css +1 -1
  20. package/dist/assets/components/tooltip/Tooltip.style.css +1 -1
  21. package/dist/components/badge/Badge.d.ts +1 -0
  22. package/dist/components/badge/Badge.js +12 -11
  23. package/dist/components/button/Button.d.ts +1 -1
  24. package/dist/components/d-flow/input/DFlowInputDataType.js +32 -32
  25. package/dist/components/d-flow/suggestion/DFlowSuggestionMenu.js +22 -22
  26. package/dist/components/d-flow/suggestion/DFlowSuggestionMenu.util.js +11 -11
  27. package/dist/components/d-flow/suggestion/DFlowSuggestionSearchInput.d.ts +1 -1
  28. package/dist/components/d-flow/suggestion/DFlowSuggestionSearchInput.js +29 -16
  29. package/dist/components/d-flow/tab/DFlowTabDefault.js +59 -53
  30. package/dist/components/d-member/DNamespaceMember.service.js +6 -4
  31. package/dist/components/d-member/DNamespaceMember.view.js +13 -11
  32. package/dist/components/d-member/DNamespaceMemberCard.d.ts +10 -0
  33. package/dist/components/d-member/DNamespaceMemberCard.js +16 -0
  34. package/dist/components/d-member/DNamespaceMemberContent.d.ts +10 -0
  35. package/dist/components/d-member/DNamespaceMemberContent.js +176 -0
  36. package/dist/components/d-member/DNamespaceMemberList.d.ts +12 -0
  37. package/dist/components/d-member/DNamespaceMemberList.js +23 -0
  38. package/dist/components/d-member/index.d.ts +2 -0
  39. package/dist/components/d-member/index.js +6 -2
  40. package/dist/components/d-organization/DOrganizationCard.d.ts +3 -2
  41. package/dist/components/d-organization/DOrganizationList.d.ts +3 -4
  42. package/dist/components/d-organization/DOrganizationList.js +7 -7
  43. package/dist/components/d-organization/DOrganizatonContent.d.ts +5 -4
  44. package/dist/components/d-organization/DOrganizatonContent.js +40 -25
  45. package/dist/components/d-organization/index.js +22 -7
  46. package/dist/components/d-project/DNamespaceProjectCard.d.ts +5 -5
  47. package/dist/components/d-project/DNamespaceProjectCard.js +13 -11
  48. package/dist/components/d-project/DNamespaceProjectContent.d.ts +2 -1
  49. package/dist/components/d-project/DNamespaceProjectContent.js +36 -42
  50. package/dist/components/d-project/DNamespaceProjectList.d.ts +3 -3
  51. package/dist/components/d-project/DNamespaceProjectList.js +1 -1
  52. package/dist/components/d-project/index.js +11 -17
  53. package/dist/components/d-role/DNamespaceRole.view.d.ts +4 -1
  54. package/dist/components/d-role/DNamespaceRole.view.js +6 -3
  55. package/dist/components/d-role/DNamespaceRoleCard.d.ts +11 -0
  56. package/dist/components/d-role/DNamespaceRoleCard.js +17 -0
  57. package/dist/components/d-role/DNamespaceRoleContent.d.ts +10 -0
  58. package/dist/components/d-role/DNamespaceRoleContent.js +156 -0
  59. package/dist/components/d-role/DNamespaceRoleList.d.ts +12 -0
  60. package/dist/components/d-role/DNamespaceRoleList.js +24 -0
  61. package/dist/components/d-role/DNamespaceRolePermissions.d.ts +5 -0
  62. package/dist/components/d-role/DNamespaceRolePermissions.js +129 -0
  63. package/dist/components/d-role/index.d.ts +2 -0
  64. package/dist/components/d-role/index.js +6 -2
  65. package/dist/components/d-runtime/DRuntimeCard.d.ts +3 -1
  66. package/dist/components/d-runtime/DRuntimeCard.js +13 -12
  67. package/dist/components/d-runtime/DRuntimeContent.d.ts +3 -1
  68. package/dist/components/d-runtime/DRuntimeContent.js +25 -20
  69. package/dist/components/d-runtime/DRuntimeList.d.ts +5 -3
  70. package/dist/components/d-runtime/DRuntimeList.js +21 -15
  71. package/dist/components/d-user/DUser.service.d.ts +1 -0
  72. package/dist/components/d-user/DUser.service.js +5 -2
  73. package/dist/components/d-user/DUserCard.d.ts +2 -1
  74. package/dist/components/d-user/DUserContent.d.ts +2 -1
  75. package/dist/components/d-user/DUserContent.js +45 -45
  76. package/dist/components/d-user/DUserInput.d.ts +5 -0
  77. package/dist/components/d-user/DUserInput.js +97 -0
  78. package/dist/components/d-user/DUserList.d.ts +2 -3
  79. package/dist/components/d-user/DUserList.js +4 -4
  80. package/dist/components/d-user/DUserMenu.js +7 -6
  81. package/dist/components/d-user/index.d.ts +1 -0
  82. package/dist/components/d-user/index.js +11 -9
  83. package/dist/components/dialog/Dialog.d.ts +2 -1
  84. package/dist/components/dialog/Dialog.js +67 -59
  85. package/dist/components/form/EmailInput.js +12 -11
  86. package/dist/components/form/Input.d.ts +17 -5
  87. package/dist/components/form/Input.js +420 -137
  88. package/dist/components/form/Input.selection.hook.d.ts +17 -0
  89. package/dist/components/form/Input.selection.hook.js +78 -0
  90. package/dist/components/form/Input.syntax.hook.d.ts +27 -0
  91. package/dist/components/form/Input.syntax.hook.js +80 -0
  92. package/dist/components/form/Input.utils.d.ts +11 -0
  93. package/dist/components/form/Input.utils.js +33 -0
  94. package/dist/components/form/InputSuggestion.d.ts +14 -6
  95. package/dist/components/form/InputSuggestion.js +126 -72
  96. package/dist/components/form/InputSyntax.d.ts +19 -0
  97. package/dist/components/form/InputSyntax.js +52 -0
  98. package/dist/components/form/PasswordInput.js +11 -10
  99. package/dist/components/form/TextInput.js +11 -10
  100. package/dist/components/form/index.js +26 -27
  101. package/dist/components/form/inputSyntaxMapping.d.ts +3 -0
  102. package/dist/components/form/inputSyntaxMapping.js +42 -0
  103. package/dist/components/menu/Menu.d.ts +7 -3
  104. package/dist/components/menu/Menu.js +22 -22
  105. package/dist/components/tooltip/Tooltip.js +33 -33
  106. package/dist/index.js +200 -189
  107. 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
- ref?: any;
7
- groupLabel?: string;
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: () => void;
16
- focusLastItem: () => void;
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 p, jsxs as d } from "react/jsx-runtime";
2
- import { c as I } from "../../_virtual/compiler-runtime.js";
3
- import { MenuContent as x, MenuLabel as M, MenuItem as w } from "../menu/Menu.js";
4
- import l from "react";
5
- import { ScrollArea as R, ScrollAreaViewport as G, ScrollAreaScrollbar as A, ScrollAreaThumb as D } from "../scroll-area/ScrollArea.js";
6
- import { IconChevronDown as E, IconChevronUp as y } from "@tabler/icons-react";
7
- const k = l.forwardRef((o, h) => {
8
- const e = I.c(6);
9
- let a, u;
10
- e[0] !== o ? ({
11
- children: a,
12
- ...u
13
- } = o, e[0] = o, e[1] = a, e[2] = u) : (a = e[1], u = e[2]);
14
- const i = l.useRef(null);
15
- let c;
16
- return e[3] !== a || e[4] !== u ? (c = /* @__PURE__ */ p(x, { ref: i, onContextMenuCapture: j, onInteractOutside: F, onCloseAutoFocus: O, align: "start", sideOffset: 8, ...u, children: a }), e[3] = a, e[4] = u, e[5] = c) : c = e[5], c;
17
- }), U = l.forwardRef((o, h) => {
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: e,
20
- onSuggestionSelect: a = () => {
28
+ suggestions: t,
29
+ onSuggestionSelect: i = () => {
21
30
  },
22
- ...u
23
- } = o, i = l.useRef([]), [c, m] = l.useState({});
24
- l.useEffect(() => {
25
- if (!e) {
26
- m({});
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
- m((r) => {
30
- const t = {};
31
- return e.forEach((n) => {
32
- n.groupLabel && (r.hasOwnProperty(n.groupLabel) ? t[n.groupLabel] = r[n.groupLabel] : t[n.groupLabel] = !1);
33
- }), t;
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
- }, [e]);
45
+ }, [t]);
36
46
  const {
37
- groupLabelCount: v,
38
- visibleSuggestionCount: S
39
- } = l.useMemo(() => {
40
- if (!e) return {
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 r = 0, t = 0;
45
- return e.forEach((n, s, b) => {
46
- const f = s > 0 ? b[s - 1]?.groupLabel : void 0;
47
- n.groupLabel && n.groupLabel !== f && (r += 1), (n.groupLabel ? c[n.groupLabel] : !1) || (t += 1);
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: r,
50
- visibleSuggestionCount: t
62
+ groupLabelCount: e,
63
+ visibleSuggestionCount: r,
64
+ visibleSuggestions: f
51
65
  };
52
- }, [c, e]), g = (r) => {
53
- m((t) => ({
54
- ...t,
55
- [r]: !t[r]
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
- return l.useImperativeHandle(h, () => ({
59
- focusFirstItem: () => i.current[0]?.focus(),
60
- // @ts-ignore
61
- focusLastItem: () => i.current.at(-1)?.focus()
62
- }), []), i.current = [], /* @__PURE__ */ d(R, { h: `${Math.max(S + v, 1) * 27}px`, mah: "calc(var(--radix-popper-available-height) - 3rem - 69px)", ...u, children: [
63
- /* @__PURE__ */ p(G, { children: e?.map((r, t, n) => {
64
- const s = t > 0 ? n[t - 1]?.groupLabel : void 0, b = r.groupLabel && r.groupLabel !== s, f = r.groupLabel ? c[r.groupLabel] : !1;
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__ */ p("span", { children: r.groupLabel }),
74
- f ? /* @__PURE__ */ p(E, { size: 16 }) : /* @__PURE__ */ p(y, { size: 16 })
120
+ /* @__PURE__ */ d("span", { children: e.groupBy }),
121
+ I ? /* @__PURE__ */ d(T, { size: 16 }) : /* @__PURE__ */ d(V, { size: 16 })
75
122
  ] }),
76
- !f && /* @__PURE__ */ p(
77
- w,
123
+ !I && /* @__PURE__ */ d(
124
+ G,
78
125
  {
79
126
  textValue: "",
80
- onSelect: () => setTimeout(() => a(r), 0),
81
- ref: (L) => i.current[C] = L,
82
- children: r.children
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
- ] }, t);
139
+ ] }, r);
86
140
  }) }),
87
- /* @__PURE__ */ p(A, { orientation: "vertical", children: /* @__PURE__ */ p(D, {}) })
141
+ /* @__PURE__ */ d(F, { orientation: "vertical", children: /* @__PURE__ */ d(O, {}) })
88
142
  ] });
89
143
  });
90
- function j(o) {
91
- return o.stopPropagation();
144
+ function j(l) {
145
+ return l.stopPropagation();
92
146
  }
93
- function F(o) {
94
- return o.target instanceof HTMLInputElement && o.preventDefault();
147
+ function k(l) {
148
+ return l.target instanceof HTMLInputElement && l.preventDefault();
95
149
  }
96
- function O(o) {
97
- return o.preventDefault();
150
+ function z(l) {
151
+ return l.preventDefault();
98
152
  }
99
153
  export {
100
- k as InputSuggestionMenuContent,
101
- U as InputSuggestionMenuContentItems
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 o from "react";
3
- import { Input as h, setElementKey as y } from "./Input.js";
4
- import { IconEye as d, IconX as g } from "@tabler/icons-react";
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
- const I = o.forwardRef((s, t) => {
7
- t = t || o.useRef(null);
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: a = !0,
10
- visible: p = !0,
10
+ clearable: p = !0,
11
+ visible: a = !0,
11
12
  right: c,
12
13
  ...u
13
- } = s, l = (r) => (t.current && y(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), n = [c];
14
- return p && n.push(/* @__PURE__ */ e(i, { variant: "none", onClick: (r) => m(r), children: /* @__PURE__ */ e(d, { size: 13 }) })), a && n.push(/* @__PURE__ */ e(i, { variant: "none", onClick: (r) => l(r), children: /* @__PURE__ */ e(g, { size: 13 }) })), /* @__PURE__ */ e(h, { right: n, rightType: "action", type: "password", ref: t, ...u });
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
- I as PasswordInput
18
+ C as PasswordInput
18
19
  };
@@ -1,19 +1,20 @@
1
- import { jsx as n } from "react/jsx-runtime";
1
+ import { jsx as o } from "react/jsx-runtime";
2
2
  import i from "react";
3
- import { Input as u, setElementKey as s } from "./Input.js";
4
- import { IconX as f } from "@tabler/icons-react";
5
- import { Button as h } from "../button/Button.js";
6
- const R = i.forwardRef((e, t) => {
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
- } = e, m = (r) => {
13
- t.current && s(t.current, "value", "", "change"), e.onClear && e.onClear(r);
14
- }, o = [c];
15
- return a && o.push(/* @__PURE__ */ n(h, { variant: "none", onClick: (r) => m(r), children: /* @__PURE__ */ n(f, { size: 13 }) })), /* @__PURE__ */ n(u, { right: o, type: "text", ref: t, ...l });
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
- R as TextInput
19
+ b as TextInput
19
20
  };
@@ -1,37 +1,36 @@
1
- import { CheckboxInput as e } from "./CheckboxInput.js";
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, setElementKey as i } from "./Input.js";
4
- import { InputDescription as I } from "./InputDescription.js";
5
- import { InputLabel as s } from "./InputLabel.js";
6
- import { InputMessage as d } from "./InputMessage.js";
7
- import { InputSuggestionMenuContent as g, InputSuggestionMenuContentItems as P } from "./InputSuggestion.js";
8
- import { NumberInput as c } from "./NumberInput.js";
9
- import { PasswordInput as F } from "./PasswordInput.js";
10
- import { PinInput as S, PinInputField as h, PinInputHiddenField as w } from "./PinInput.js";
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 y } from "./RadioInput.js";
12
+ import { RadioInput as D } from "./RadioInput.js";
13
13
  import { SwitchInput as G } from "./SwitchInput.js";
14
- import { TextInput as K } from "./TextInput.js";
15
- import { useForm as N } from "./useForm.js";
14
+ import { TextInput as L } from "./TextInput.js";
15
+ import { useForm as T } from "./useForm.js";
16
16
  export {
17
- e as CheckboxInput,
17
+ r as CheckboxInput,
18
18
  p as EmailInput,
19
19
  m as Input,
20
- I as InputDescription,
21
- s as InputLabel,
22
- d as InputMessage,
23
- g as InputSuggestionMenuContent,
24
- P as InputSuggestionMenuContentItems,
25
- c as NumberInput,
26
- F as PasswordInput,
27
- S as PinInput,
28
- h as PinInputField,
29
- w as PinInputHiddenField,
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
- y as RadioInput,
31
+ D as RadioInput,
32
32
  G as SwitchInput,
33
- K as TextInput,
33
+ L as TextInput,
34
34
  n as emailValidation,
35
- i as setElementKey,
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;