@code0-tech/pictor 0.0.0-mvp.30 → 0.0.0-mvp.32

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 (134) hide show
  1. package/dist/components/avatar/Avatar.js +7 -7
  2. package/dist/components/breadcrumb/Breadcrumb.js +4 -4
  3. package/dist/components/button/Button.js +8 -8
  4. package/dist/components/context-menu/ContextMenu.js +131 -131
  5. package/dist/components/d-flow/DFlow.edges.hook.js +22 -22
  6. package/dist/components/d-flow/DFlow.js +32 -32
  7. package/dist/components/d-flow/DFlow.nodes.hook.js +8 -8
  8. package/dist/components/d-flow-file/DFlowTabDefault.js +16 -16
  9. package/dist/components/d-flow-folder/DFlowFolder.js +13 -13
  10. package/dist/components/d-flow-folder/DFlowFolderContextMenu.js +5 -5
  11. package/dist/components/d-flow-folder/DFlowFolderCreateDialog.js +13 -13
  12. package/dist/components/d-flow-folder/DFlowFolderDeleteDialog.js +5 -5
  13. package/dist/components/d-flow-folder/DFlowFolderRenameDialog.js +11 -11
  14. package/dist/components/d-flow-function/DFlowFunctionDefaultCard.js +7 -7
  15. package/dist/components/d-flow-function/DFlowFunctionSuggestionCard.js +9 -9
  16. package/dist/components/d-flow-function/DFlowFunctionTriggerCard.js +12 -12
  17. package/dist/components/d-flow-input/DFlowInputDataType.js +16 -16
  18. package/dist/components/d-flow-input/DFlowInputNodeBadge.js +8 -8
  19. package/dist/components/d-flow-input/DFlowInputReferenceBadge.js +4 -4
  20. package/dist/components/d-flow-panel/DFlowExport.js +5 -5
  21. package/dist/components/d-flow-panel/DFlowPanelControl.js +4 -4
  22. package/dist/components/d-flow-suggestion/DFlowFunctionSuggestions.hook.js +4 -4
  23. package/dist/components/d-flow-suggestion/DFlowSuggestion.hook.js +7 -7
  24. package/dist/components/d-flow-suggestion/DFlowSuggestionMenu.js +12 -12
  25. package/dist/components/d-flow-suggestion/DFlowSuggestionSearchInput.js +5 -5
  26. package/dist/components/d-flow-suggestion/DFlowValueSuggestions.hook.js +4 -4
  27. package/dist/components/d-flow-validation/DNodeValidation.hook.js +3 -3
  28. package/dist/components/d-fullscreen/DFullScreen.js +2 -2
  29. package/dist/components/d-member/DNamespaceMemberList.js +5 -5
  30. package/dist/components/d-organization/DOrganizationList.js +7 -7
  31. package/dist/components/d-organization/DOrganizationMenu.js +5 -5
  32. package/dist/components/d-organization/DOrganizatonContent.js +22 -22
  33. package/dist/components/d-project/DNamespaceProjectContent.js +6 -6
  34. package/dist/components/d-project/DNamespaceProjectList.js +5 -5
  35. package/dist/components/d-project/DNamespaceProjectMenu.js +2 -2
  36. package/dist/components/d-role/DNamespaceRolePermissions.js +5 -5
  37. package/dist/components/d-runtime/DRuntimeList.js +7 -7
  38. package/dist/components/d-user/DUser.session.hook.js +2 -2
  39. package/dist/components/d-user/DUserContent.js +13 -13
  40. package/dist/components/d-user/DUserList.js +9 -9
  41. package/dist/components/form/CheckboxInput.js +4 -4
  42. package/dist/components/form/EmailInput.js +9 -9
  43. package/dist/components/form/Input.js +311 -230
  44. package/dist/components/form/Input.utils.js +1 -1
  45. package/dist/components/form/InputContentEditable.hook.d.ts +14 -2
  46. package/dist/components/form/InputContentEditable.hook.js +296 -317
  47. package/dist/components/form/NumberInput.js +9 -9
  48. package/dist/components/form/PasswordInput.js +2 -2
  49. package/dist/components/form/SwitchInput.js +7 -7
  50. package/dist/components/form/TextInput.js +6 -6
  51. package/dist/node_modules/react/cjs/react-compiler-runtime.development.js +2 -2
  52. package/dist/node_modules/react/cjs/react-compiler-runtime.production.js +8 -8
  53. package/dist/utils/objectStore.js +15 -15
  54. package/dist/utils/reactiveArrayService.js +10 -10
  55. package/package.json +19 -19
  56. package/dist/_virtual/_commonjsHelpers.js +0 -6
  57. package/dist/_virtual/index.js +0 -4
  58. package/dist/_virtual/index2.js +0 -4
  59. package/dist/_virtual/react-contenteditable.js +0 -7
  60. package/dist/_virtual/react-contenteditable2.js +0 -4
  61. package/dist/_virtual/react-dom-server-legacy.browser.development.js +0 -4
  62. package/dist/_virtual/react-dom-server-legacy.browser.production.js +0 -4
  63. package/dist/_virtual/react-dom-server.browser.development.js +0 -4
  64. package/dist/_virtual/react-dom-server.browser.production.js +0 -4
  65. package/dist/_virtual/react-is.development.js +0 -4
  66. package/dist/_virtual/react-is.production.min.js +0 -4
  67. package/dist/_virtual/server.browser.js +0 -5
  68. package/dist/_virtual/server.browser2.js +0 -4
  69. package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +0 -527
  70. package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +0 -402
  71. package/dist/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +0 -208
  72. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +0 -136
  73. package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +0 -130
  74. package/dist/node_modules/@radix-ui/primitive/dist/index.js +0 -9
  75. package/dist/node_modules/@radix-ui/react-arrow/dist/index.js +0 -24
  76. package/dist/node_modules/@radix-ui/react-collection/dist/index.js +0 -48
  77. package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js +0 -29
  78. package/dist/node_modules/@radix-ui/react-context/dist/index.js +0 -53
  79. package/dist/node_modules/@radix-ui/react-context-menu/dist/index.js +0 -222
  80. package/dist/node_modules/@radix-ui/react-direction/dist/index.js +0 -10
  81. package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +0 -127
  82. package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +0 -17
  83. package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js +0 -136
  84. package/dist/node_modules/@radix-ui/react-id/dist/index.js +0 -13
  85. package/dist/node_modules/@radix-ui/react-menu/dist/index.js +0 -636
  86. package/dist/node_modules/@radix-ui/react-popper/dist/index.js +0 -219
  87. package/dist/node_modules/@radix-ui/react-portal/dist/index.js +0 -15
  88. package/dist/node_modules/@radix-ui/react-presence/dist/index.js +0 -70
  89. package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +0 -36
  90. package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.js +0 -183
  91. package/dist/node_modules/@radix-ui/react-slot/dist/index.js +0 -49
  92. package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +0 -10
  93. package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +0 -52
  94. package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +0 -14
  95. package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +0 -6
  96. package/dist/node_modules/@radix-ui/react-use-size/dist/index.js +0 -27
  97. package/dist/node_modules/aria-hidden/dist/es2015/index.js +0 -52
  98. package/dist/node_modules/fast-deep-equal/index.js +0 -31
  99. package/dist/node_modules/get-nonce/dist/es2015/index.js +0 -7
  100. package/dist/node_modules/object-assign/index.js +0 -49
  101. package/dist/node_modules/prop-types/checkPropTypes.js +0 -54
  102. package/dist/node_modules/prop-types/factoryWithThrowingShims.js +0 -52
  103. package/dist/node_modules/prop-types/factoryWithTypeCheckers.js +0 -329
  104. package/dist/node_modules/prop-types/index.js +0 -17
  105. package/dist/node_modules/prop-types/lib/ReactPropTypesSecret.js +0 -10
  106. package/dist/node_modules/prop-types/lib/has.js +0 -7
  107. package/dist/node_modules/prop-types/node_modules/react-is/cjs/react-is.development.js +0 -87
  108. package/dist/node_modules/prop-types/node_modules/react-is/cjs/react-is.production.min.js +0 -70
  109. package/dist/node_modules/prop-types/node_modules/react-is/index.js +0 -10
  110. package/dist/node_modules/react-contenteditable/lib/react-contenteditable.js +0 -132
  111. package/dist/node_modules/react-dom/cjs/react-dom-server-legacy.browser.development.js +0 -6235
  112. package/dist/node_modules/react-dom/cjs/react-dom-server-legacy.browser.production.js +0 -4096
  113. package/dist/node_modules/react-dom/cjs/react-dom-server.browser.development.js +0 -6753
  114. package/dist/node_modules/react-dom/cjs/react-dom-server.browser.production.js +0 -4645
  115. package/dist/node_modules/react-dom/server.browser.js +0 -15
  116. package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.js +0 -11
  117. package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +0 -112
  118. package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +0 -31
  119. package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +0 -16
  120. package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +0 -68
  121. package/dist/node_modules/react-remove-scroll/dist/es2015/medium.js +0 -5
  122. package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.js +0 -7
  123. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js +0 -71
  124. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +0 -7
  125. package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +0 -25
  126. package/dist/node_modules/react-style-singleton/dist/es2015/component.js +0 -11
  127. package/dist/node_modules/react-style-singleton/dist/es2015/hook.js +0 -15
  128. package/dist/node_modules/react-style-singleton/dist/es2015/singleton.js +0 -30
  129. package/dist/node_modules/tslib/tslib.es6.js +0 -27
  130. package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.js +0 -6
  131. package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +0 -26
  132. package/dist/node_modules/use-callback-ref/dist/es2015/useRef.js +0 -25
  133. package/dist/node_modules/use-sidecar/dist/es2015/exports.js +0 -18
  134. package/dist/node_modules/use-sidecar/dist/es2015/medium.js +0 -67
@@ -1,21 +1,21 @@
1
- import { jsx as f, jsxs as z } from "react/jsx-runtime";
2
- import i, { useRef as y, useState as K, useMemo as L, useEffect as x } from "react";
3
- import Qe from "../../_virtual/react-contenteditable.js";
1
+ import { jsxs as W, jsx as g } from "react/jsx-runtime";
2
+ import l, { useRef as S, useState as j, useMemo as D, useEffect as I, useLayoutEffect as Ze } from "react";
4
3
  import "../../utils/contextStore.js";
5
- import { mergeCode0Props as le } from "../../utils/utils.js";
4
+ import { mergeCode0Props as he } from "../../utils/utils.js";
6
5
  import '../../assets/components/form/Input.style.css';/* empty css */
7
- import { InputLabel as Xe } from "./InputLabel.js";
8
- import { InputDescription as Ye } from "./InputDescription.js";
9
- import { InputMessage as Ze } from "./InputMessage.js";
10
- import { Menu as _e, MenuTrigger as et, MenuPortal as tt } from "../menu/Menu.js";
11
- import { InputSuggestionMenuContent as nt, InputSuggestionMenuContentItems as rt } from "./InputSuggestion.js";
12
- import { getSelectionMetrics as ot, setElementKey as st, setSelectionRangeSafe as at } from "./Input.utils.js";
13
- import { Card as ut } from "../card/Card.js";
14
- import { useContentEditableController as it } from "./InputContentEditable.hook.js";
15
- const X = (u) => {
16
- const k = u ?? "";
17
- return typeof k == "string" ? k : String(k);
18
- }, $e = (u) => {
6
+ import { InputLabel as _e } from "./InputLabel.js";
7
+ import { InputDescription as et } from "./InputDescription.js";
8
+ import { InputMessage as tt } from "./InputMessage.js";
9
+ import { Menu as nt, MenuTrigger as rt, MenuPortal as ot } from "../menu/Menu.js";
10
+ import { InputSuggestionMenuContent as st, InputSuggestionMenuContentItems as at } from "./InputSuggestion.js";
11
+ import { buildDefaultSyntax as ut } from "./Input.syntax.hook.js";
12
+ import { getSelectionMetrics as it, setElementKey as lt, setSelectionRangeSafe as ct } from "./Input.utils.js";
13
+ import { Card as ft } from "../card/Card.js";
14
+ import { useContentEditableController as dt, setSelectionOffsetsInValue as pt } from "./InputContentEditable.hook.js";
15
+ const q = (u) => {
16
+ const x = u ?? "";
17
+ return typeof x == "string" ? x : String(x);
18
+ }, se = (u) => {
19
19
  if (u == null) return "";
20
20
  if (typeof u == "string") return u;
21
21
  try {
@@ -23,208 +23,220 @@ const X = (u) => {
23
23
  } catch {
24
24
  return String(u ?? "");
25
25
  }
26
- }, Fe = (u) => {
26
+ }, gt = (u) => {
27
+ if (u && typeof u == "object") {
28
+ const {
29
+ children: x,
30
+ __contentHtml: J,
31
+ ...U
32
+ } = u;
33
+ return U;
34
+ }
35
+ return {
36
+ value: u
37
+ };
38
+ }, Ke = (u) => {
27
39
  if (!u) return null;
28
- const k = u.value ?? "", Y = u.selectionStart ?? k.length, E = k.slice(0, Y).match(/\S+$/);
29
- if (!E || E.index === void 0) return null;
30
- const g = E[0], $ = E.index, N = $ + g.length;
40
+ const x = u.value ?? "", J = u.selectionStart ?? x.length, T = x.slice(0, J).match(/\S+$/);
41
+ if (!T || T.index === void 0) return null;
42
+ const C = T[0], H = T.index, Q = H + C.length;
31
43
  return {
32
- token: g,
33
- start: $,
34
- end: N
44
+ token: C,
45
+ start: H,
46
+ end: Q
35
47
  };
36
- }, lt = i.forwardRef((u, k) => {
48
+ }, ht = l.forwardRef((u, x) => {
37
49
  const {
38
- wrapperComponent: Y = {},
39
- title: Z,
40
- description: E,
41
- disabled: g = !1,
42
- left: $,
43
- right: N,
44
- leftType: Be = "icon",
45
- rightType: Ae = "action",
46
- formValidation: V = {
50
+ wrapperComponent: J = {},
51
+ title: U,
52
+ description: T,
53
+ disabled: C = !1,
54
+ left: H,
55
+ right: Q,
56
+ leftType: Ae = "icon",
57
+ rightType: Ne = "action",
58
+ formValidation: L = {
47
59
  valid: !0,
48
60
  notValidMessage: null,
49
61
  setValue: null
50
62
  },
51
- suggestions: l,
52
- suggestionsHeader: ce,
53
- suggestionsFooter: fe,
54
- onSuggestionSelect: de,
55
- disableOnValue: pe = () => !1,
56
- transformSyntax: P,
57
- validationUsesSyntax: j = !1,
58
- filterSuggestionsByLastToken: h = !1,
59
- enforceUniqueSuggestions: ge = !1,
60
- onLastTokenChange: he,
61
- suggestionsEmptyState: me,
63
+ suggestions: f,
64
+ suggestionsHeader: me,
65
+ suggestionsFooter: ye,
66
+ onSuggestionSelect: Se,
67
+ disableOnValue: Ce = () => !1,
68
+ transformSyntax: G,
69
+ validationUsesSyntax: ae = !1,
70
+ filterSuggestionsByLastToken: v = !1,
71
+ enforceUniqueSuggestions: ve = !1,
72
+ onLastTokenChange: be,
73
+ suggestionsEmptyState: ke,
62
74
  ...ze
63
75
  } = u, {
64
- onFocus: Se,
65
- onBlur: _,
66
- onKeyDown: q,
67
- onKeyDownCapture: ee,
68
- onChange: F,
69
- onInput: B,
70
- ...m
71
- } = ze, W = y(null), d = y(null), H = y(null), M = y(null), te = y(null), D = y(!1), Ne = y(0), Ce = y(null), ne = m.value ?? u.initialValue ?? u.defaultValue, [ye, je] = K(!1), R = y(!1), a = i.useCallback((e) => {
72
- R.current = e, je(e);
73
- }, []), [w, re] = K(ne), [ve, be] = K([]), [ke, oe] = K([]), [we, qe] = K(null), [xe, Ee] = K(null), o = !!P, I = L(() => pe(w), [pe, w]), v = L(() => o ? H : d, [o]);
74
- i.useImperativeHandle(k, () => v.current ?? null, [v]);
75
- const We = L(() => ({
76
- ...m,
77
- onChange: F,
78
- onInput: B
79
- }), [m, F, B]), He = L(() => {
76
+ onFocus: xe,
77
+ onBlur: X,
78
+ onKeyDown: Y,
79
+ onKeyDownCapture: ue,
80
+ onChange: P,
81
+ onInput: M,
82
+ ...b
83
+ } = ze, Z = S(null), y = S(null), $ = S(null), F = S(null), ie = S(null), w = S(!1), le = S(!1), We = S(0), we = S(null), ce = b.value ?? u.initialValue ?? u.defaultValue, [Ee, je] = j(!1), B = S(!1), i = l.useCallback((e) => {
84
+ B.current = e, je(e);
85
+ }, []), [h, Ve] = j(ce), [De, Ie] = j([]), [K, fe] = j([]), [Te, qe] = j(null), [A, Ue] = j(null), s = !!G, R = D(() => Ce(h), [Ce, h]), k = D(() => s ? $ : y, [s]);
86
+ l.useImperativeHandle(x, () => k.current ?? null);
87
+ const He = D(() => ({
88
+ ...b,
89
+ onChange: P,
90
+ onInput: M
91
+ }), [b, P, M]), Je = D(() => {
80
92
  const {
81
93
  value: e,
82
94
  defaultValue: t,
83
95
  ...n
84
- } = m;
85
- return le("input__control", n);
86
- }, [m]), U = i.useCallback(() => {
87
- const e = v.current;
88
- !e || g || I || e.focus({
96
+ } = b;
97
+ return he("input__control", n);
98
+ }, [b]), _ = l.useCallback(() => {
99
+ const e = k.current;
100
+ !e || C || R || e.focus({
89
101
  preventScroll: !0
90
102
  });
91
- }, [v, g, I]), T = i.useCallback(() => {
92
- l && a(!0);
93
- }, [l, a]), se = i.useCallback((e) => {
94
- h && (qe(e), e && a(!0), he?.(e));
95
- }, [h, he, a]), ae = i.useCallback((e, t) => {
96
- if (!V?.setValue) return;
97
- const n = m.type !== "checkbox" ? X(e) : e, r = j ? t : n;
98
- Object.is(Ce.current, r) || (Ce.current = r, V.setValue(r));
99
- }, [V?.setValue, m.type, j]), p = it({
100
- editorRef: H,
101
- transformSyntax: P,
102
- filterSuggestionsByLastToken: h,
103
- onLastTokenChange: se,
103
+ }, [k, C, R]), N = l.useCallback(() => {
104
+ f && i(!0);
105
+ }, [f, i]), de = l.useCallback((e) => {
106
+ v && (qe(e), e && i(!0), be?.(e));
107
+ }, [v, be, i]), pe = l.useCallback((e, t) => {
108
+ if (!L?.setValue) return;
109
+ const n = b.type !== "checkbox" ? q(e) : e, o = ae ? t : n;
110
+ Object.is(we.current, o) || (we.current = o, L.setValue(o));
111
+ }, [L?.setValue, b.type, ae]), p = dt({
112
+ editorRef: $,
113
+ transformSyntax: G,
114
+ filterSuggestionsByLastToken: v,
115
+ onLastTokenChange: de,
104
116
  onStateChange: ({
105
117
  value: e,
106
118
  tokens: t,
107
119
  segments: n
108
120
  }) => {
109
- re(e), oe(t), Ee(n ?? null), ae(e, n ?? null);
121
+ Ve(e), fe(t), Ue(n ?? null), pe(e, n ?? null);
110
122
  }
111
- }), Ve = y(!1);
112
- x(() => {
113
- if (!o || !P || Ve.current) return;
114
- const e = X(ne);
115
- re(e), p.initializeFromExternalValue(e), j && P && Ee(P(e, [])), Ve.current = !0;
116
- }, [o, P, ne, j, p]), x(() => {
117
- o || m.value !== void 0 && re(m.value);
118
- }, [m.value, o]), x(() => {
119
- ae(w, xe);
120
- }, [ae, xe, w]), x(() => {
121
- if (!l) return;
123
+ }), Le = S(!1);
124
+ I(() => {
125
+ if (!s || !G || Le.current) return;
126
+ const e = q(ce);
127
+ p.initializeFromExternalValue(e), Le.current = !0;
128
+ }, [s, G, ce, ae, p]), I(() => {
129
+ s || b.value !== void 0 && Ve(b.value);
130
+ }, [b.value, s]), I(() => {
131
+ pe(h, A);
132
+ }, [pe, A, h]), I(() => {
133
+ if (!f) return;
122
134
  const e = (t) => {
123
- const n = t.target, r = !!H.current?.contains(n), s = !!d.current?.contains(n), c = !!te.current?.contains(n), S = !!W.current?.contains(n), C = r || s || c || S;
124
- D.current = C, !C && R.current && a(!1);
135
+ const n = t.target, o = !!$.current?.contains(n), a = !!y.current?.contains(n), r = !!ie.current?.contains(n), m = !!Z.current?.contains(n), c = o || a || r || m;
136
+ w.current = c, !c && B.current && i(!1);
125
137
  };
126
138
  return document.addEventListener("pointerdown", e, !0), () => document.removeEventListener("pointerdown", e, !0);
127
- }, [l, a]), x(() => {
128
- const e = W.current;
139
+ }, [f, i]), I(() => {
140
+ const e = Z.current;
129
141
  if (!e) return;
130
- const t = () => T();
142
+ const t = () => N();
131
143
  return e.addEventListener("focusin", t), () => e.removeEventListener("focusin", t);
132
- }, [T]);
133
- const De = i.useCallback((e, t, n) => {
144
+ }, [N]);
145
+ const Pe = l.useCallback((e, t, n) => {
134
146
  if (e.length === 0) return t <= n.length ? t : null;
135
- let r = n.indexOf(e);
136
- if (r === -1) return null;
137
- let s = r;
138
- for (; s !== -1; )
139
- Math.abs(s - t) < Math.abs(r - t) && (r = s), s = n.indexOf(e, s + 1);
140
- return r;
141
- }, []), J = i.useCallback((e, t) => {
147
+ let o = n.indexOf(e);
148
+ if (o === -1) return null;
149
+ let a = o;
150
+ for (; a !== -1; )
151
+ Math.abs(a - t) < Math.abs(o - t) && (o = a), a = n.indexOf(e, a + 1);
152
+ return o;
153
+ }, []), ee = l.useCallback((e, t) => {
142
154
  const n = [];
143
- return e.forEach((r) => {
144
- const s = De(r.text, r.start, t);
145
- if (s === null) return;
146
- const c = s + r.text.length;
147
- t.slice(s, c) === r.text && n.push({
148
- ...r,
149
- start: s,
150
- end: c
155
+ return e.forEach((o) => {
156
+ const a = Pe(o.text, o.start, t);
157
+ if (a === null) return;
158
+ const r = a + o.text.length;
159
+ t.slice(a, r) === o.text && n.push({
160
+ ...o,
161
+ start: a,
162
+ end: r
151
163
  });
152
164
  }), n;
153
- }, [De]);
154
- x(() => {
155
- if (o) return;
156
- const e = X(d.current?.value ?? w);
157
- be((t) => {
158
- const n = J(t, e);
159
- return oe(n.map((r) => r.suggestion)), n;
165
+ }, [Pe]);
166
+ I(() => {
167
+ if (s) return;
168
+ const e = q(y.current?.value ?? h);
169
+ Ie((t) => {
170
+ const n = ee(t, e);
171
+ return fe(n.map((o) => o.suggestion)), n;
160
172
  });
161
- }, [o, J, w]), x(() => {
162
- if (!h || o) return;
163
- const e = d.current;
173
+ }, [s, ee, h]), I(() => {
174
+ if (!v || s) return;
175
+ const e = y.current;
164
176
  if (!e) return;
165
- const t = () => se(Fe(e)?.token ?? null);
177
+ const t = () => de(Ke(e)?.token ?? null);
166
178
  return e.addEventListener("input", t), e.addEventListener("keyup", t), e.addEventListener("mouseup", t), t(), () => {
167
179
  e.removeEventListener("input", t), e.removeEventListener("keyup", t), e.removeEventListener("mouseup", t);
168
180
  };
169
- }, [h, o, se]);
170
- const O = L(() => {
171
- if (!h || !l) return l;
172
- const e = we?.trim();
173
- return e?.length ? l.filter((t) => String(t?.value ?? "").toLowerCase().startsWith(e.toLowerCase())) : l;
174
- }, [h, we, l]), G = L(() => {
175
- if (!ge || !O) return O;
176
- if (o) {
177
- const t = new Set((ke ?? []).map((n) => $e(n?.value ?? n)));
178
- return O.filter((n) => !t.has($e(n?.value ?? n)));
181
+ }, [v, s, de]);
182
+ const z = D(() => {
183
+ if (!v || !f) return f;
184
+ const e = Te?.trim();
185
+ return e?.length ? f.filter((t) => String(t?.value ?? "").toLowerCase().startsWith(e.toLowerCase())) : f;
186
+ }, [v, Te, f]), te = D(() => {
187
+ if (!ve || !z) return z;
188
+ if (s) {
189
+ const t = new Set((K ?? []).map((n) => se(n?.value ?? n)));
190
+ return z.filter((n) => !t.has(se(n?.value ?? n)));
179
191
  }
180
- const e = new Set(ve.map((t) => t.suggestion));
181
- return O.filter((t) => !e.has(t));
182
- }, [ve, ke, ge, O, o]), Ie = i.useCallback((e) => {
183
- if (!d.current) return;
184
- const t = typeof w == "object" ? JSON.stringify(e.value) : e.value, n = t == null ? "" : String(t), r = e.insertMode ?? "replace", s = d.current.value ?? "";
185
- let c = s, S = null, C = 0;
186
- const A = h ? Fe(d.current) : null;
187
- if (h && A)
188
- c = `${s.slice(0, A.start)}${n}${s.slice(A.end)}`, S = A.start + n.length, C = A.start;
192
+ const e = new Set(De.map((t) => t.suggestion));
193
+ return z.filter((t) => !e.has(t));
194
+ }, [De, K, ve, z, s]), Me = l.useCallback((e) => {
195
+ if (!y.current) return;
196
+ const t = typeof h == "object" ? JSON.stringify(e.value) : e.value, n = t == null ? "" : String(t), o = e.insertMode ?? "replace", a = y.current.value ?? "";
197
+ let r = a, m = null, c = 0;
198
+ const E = v ? Ke(y.current) : null;
199
+ if (v && E)
200
+ r = `${a.slice(0, E.start)}${n}${a.slice(E.end)}`, m = E.start + n.length, c = E.start;
189
201
  else
190
- switch (r) {
202
+ switch (o) {
191
203
  case "append":
192
- c = `${s}${n}`, S = c.length, C = s.length;
204
+ r = `${a}${n}`, m = r.length, c = a.length;
193
205
  break;
194
206
  case "prepend":
195
- c = `${n}${s}`, S = n.length, C = 0;
207
+ r = `${n}${a}`, m = n.length, c = 0;
196
208
  break;
197
209
  case "insert": {
198
210
  const {
199
- rawStart: b,
200
- rawEnd: ie
201
- } = ot(d.current);
202
- c = `${s.slice(0, b)}${n}${s.slice(ie)}`, S = b + n.length, C = b;
211
+ rawStart: d,
212
+ rawEnd: O
213
+ } = it(y.current);
214
+ r = `${a.slice(0, d)}${n}${a.slice(O)}`, m = d + n.length, c = d;
203
215
  break;
204
216
  }
205
217
  case "replace":
206
218
  default:
207
- c = n, S = n.length, C = 0;
219
+ r = n, m = n.length, c = 0;
208
220
  break;
209
221
  }
210
- st(d.current, "value", c, "change"), be((b) => {
211
- const ie = X(c), Te = J(b, ie), Oe = n.length ? {
212
- id: Ne.current++,
222
+ lt(y.current, "value", r, "change"), Ie((d) => {
223
+ const O = q(r), re = ee(d, O), V = n.length ? {
224
+ id: We.current++,
213
225
  suggestion: e,
214
226
  text: n,
215
- start: C,
216
- end: C + n.length
217
- } : null, Ke = Oe ? [...Te, Oe] : Te;
218
- return oe(Ke.map((Ge) => Ge.suggestion)), Ke;
219
- }), S !== null && requestAnimationFrame(() => {
220
- const b = d.current;
221
- b && (b.focus({
227
+ start: c,
228
+ end: c + n.length
229
+ } : null, oe = V ? [...re, V] : re;
230
+ return fe(oe.map((Ye) => Ye.suggestion)), oe;
231
+ }), m !== null && requestAnimationFrame(() => {
232
+ const d = y.current;
233
+ d && (d.focus({
222
234
  preventScroll: !0
223
- }), at(b, S, S));
235
+ }), ct(d, m, m));
224
236
  });
225
- }, [h, J, w]), Le = i.useCallback((e) => {
226
- if (o ? p.applySuggestionValueSyntax(e) : Ie(e), de?.(e), o) {
227
- const t = v.current;
237
+ }, [v, ee, h]), Re = l.useCallback((e) => {
238
+ if (s ? p.applySuggestionValueSyntax(e) : Me(e), Se?.(e), s) {
239
+ const t = k.current;
228
240
  requestAnimationFrame(() => {
229
241
  if (!t) return;
230
242
  const n = {
@@ -234,114 +246,183 @@ const X = (u) => {
234
246
  };
235
247
  t.dispatchEvent(new Event("input", {
236
248
  bubbles: !0
237
- })), B?.(n), F?.(n);
249
+ })), M?.(n), P?.(n);
238
250
  });
239
251
  }
240
- a(!1), D.current = !1, requestAnimationFrame(() => {
241
- U();
252
+ i(!1), w.current = !1, requestAnimationFrame(() => {
253
+ _();
242
254
  });
243
- }, [v, Ie, p, U, o, de, a, F, B]), Pe = i.useCallback((e) => {
244
- T(), Se?.(e);
245
- }, [T, Se]), Q = i.useCallback((e) => {
246
- if (D.current) {
247
- _?.(e);
255
+ }, [k, Me, p, _, s, Se, i, P, M]), Oe = l.useCallback((e) => {
256
+ N(), xe?.(e);
257
+ }, [N, xe]), ne = l.useCallback((e) => {
258
+ if (le.current) {
259
+ le.current = !1, X?.(e);
248
260
  return;
249
261
  }
250
- a(!1), _?.(e);
251
- }, [_, a]), Me = i.useCallback((e) => {
252
- if (o) {
253
- p.handleKeyDownCapture(e), ee?.(e);
262
+ if (w.current) {
263
+ X?.(e);
254
264
  return;
255
265
  }
256
- (e.key === " " || e.code === "Space") && (e.stopPropagation(), e.nativeEvent?.stopImmediatePropagation?.()), ee?.(e);
257
- }, [p, o, ee]), Re = i.useCallback((e) => {
258
- if (l) {
266
+ i(!1), X?.(e);
267
+ }, [X, i]), $e = l.useCallback((e) => {
268
+ if (s) {
269
+ p.handleKeyDownCapture(e), ue?.(e);
270
+ return;
271
+ }
272
+ (e.key === " " || e.code === "Space") && (e.stopPropagation(), e.nativeEvent?.stopImmediatePropagation?.()), ue?.(e);
273
+ }, [p, s, ue]), Fe = l.useCallback((e) => {
274
+ if (f) {
259
275
  if (e.key === "ArrowDown") {
260
- e.preventDefault(), e.stopPropagation(), R.current ? M.current?.highlightNextItem?.() : (a(!0), setTimeout(() => M.current?.focusFirstItem?.(), 0));
276
+ e.preventDefault(), e.stopPropagation(), B.current ? F.current?.highlightNextItem?.() : (i(!0), setTimeout(() => F.current?.focusFirstItem?.(), 0));
261
277
  return;
262
278
  }
263
279
  if (e.key === "ArrowUp") {
264
- e.preventDefault(), e.stopPropagation(), R.current ? M.current?.highlightPreviousItem?.() : (a(!0), setTimeout(() => M.current?.focusLastItem?.(), 0));
280
+ e.preventDefault(), e.stopPropagation(), B.current ? F.current?.highlightPreviousItem?.() : (i(!0), setTimeout(() => F.current?.focusLastItem?.(), 0));
265
281
  return;
266
282
  }
267
- if (e.key === "Enter" && R.current) {
268
- e.preventDefault(), e.stopPropagation(), M.current?.selectActiveItem?.() && a(!1);
283
+ if (e.key === "Enter" && B.current) {
284
+ e.preventDefault(), e.stopPropagation(), F.current?.selectActiveItem?.() && i(!1);
269
285
  return;
270
286
  }
271
- if (e.key === "Escape" && R.current) {
272
- e.preventDefault(), e.stopPropagation(), a(!1);
287
+ if (e.key === "Escape" && B.current) {
288
+ e.preventDefault(), e.stopPropagation(), i(!1);
273
289
  return;
274
290
  }
275
291
  }
276
- if (o && p.handleKeyDown(e)) {
277
- q?.(e);
292
+ if (s && p.handleKeyDown(e)) {
293
+ if (e.key === "Backspace" || e.key === "Delete") {
294
+ const n = k.current;
295
+ if (n) {
296
+ const o = {
297
+ type: "change",
298
+ target: n,
299
+ currentTarget: n
300
+ };
301
+ M?.(o), P?.(o);
302
+ }
303
+ }
304
+ Y?.(e);
278
305
  return;
279
306
  }
280
- if (o && e.key === "Enter") {
281
- e.preventDefault(), q?.(e);
307
+ if (s && e.key === "Enter") {
308
+ e.preventDefault(), Y?.(e);
282
309
  return;
283
310
  }
284
- q?.(e);
285
- }, [p, o, l, a, q]), ue = o ? /* @__PURE__ */ f(Qe, { innerRef: H, html: p.editorHtml, ...He, disabled: g || I, onChange: (e) => {
286
- p.handleChange(e), F?.(e), B?.(e);
287
- }, onPaste: p.handlePaste, onFocus: Pe, onBlur: Q, onKeyDownCapture: Me, onKeyDown: Re, spellCheck: !1, contentEditable: !g && !I }) : /* @__PURE__ */ f("input", { ref: d, ...le("input__control", We), onFocus: Pe, onBlur: Q, onKeyDownCapture: Me, onKeyDown: Re, spellCheck: !1, disabled: g || I }), Ue = i.useCallback((e) => {
288
- if (g || I) return;
311
+ Y?.(e);
312
+ }, [k, p, s, f, i, P, M, Y]), Be = D(() => {
313
+ if (!s) return null;
314
+ const e = q(h), t = (A ?? []).filter(Boolean).filter((r) => r && (r.type === "text" || r.type === "block") && Number.isFinite(r.start) && Number.isFinite(r.end) && r.start <= r.end), n = t.length ? t : ut(e), o = (K ?? []).slice(), a = [];
315
+ return n.forEach((r, m) => {
316
+ const c = r.value ?? e.slice(r.start, r.end);
317
+ if (r.type === "text") {
318
+ const V = typeof r.content == "string" ? r.content : typeof c == "string" ? c : e.slice(r.start, r.end);
319
+ V?.length && a.push(V);
320
+ return;
321
+ }
322
+ const E = se(c);
323
+ let d;
324
+ if (o.length) {
325
+ const V = o[0], oe = se(V?.value ?? V);
326
+ (E === "" || oe === E) && (d = V, o.shift());
327
+ }
328
+ d || (d = {
329
+ value: c
330
+ });
331
+ const O = gt(d), re = r.content && typeof r.content != "string" || typeof r.content == "string" ? r.content : O?.label ?? O?.value ?? "";
332
+ a.push(/* @__PURE__ */ W(l.Fragment, { children: [
333
+ "​",
334
+ /* @__PURE__ */ g("span", { className: "input__token", contentEditable: !1, "aria-data": JSON.stringify(O), style: {
335
+ display: "inline-flex",
336
+ alignItems: "center",
337
+ verticalAlign: "middle",
338
+ userSelect: "text",
339
+ WebkitUserSelect: "text"
340
+ }, children: re }),
341
+ "​"
342
+ ] }, `${m}-${E}`));
343
+ }), a;
344
+ }, [K, s, A, h]);
345
+ Ze(() => {
346
+ if (!s) return;
347
+ const e = $.current;
348
+ if (!e) return;
349
+ const t = p.takePendingSelection();
350
+ t && pt(e, t.start, t.end);
351
+ }, [p, s, Be]);
352
+ const Qe = D(() => {
353
+ if (!s) return "plain";
354
+ const e = q(h), t = K?.length ?? 0, n = A?.length ?? 0;
355
+ return `${e}-${t}-${n}`;
356
+ }, [K, s, A, h]), ge = s ? /* @__PURE__ */ g("div", { ref: $, ...Je, contentEditable: !C && !R, suppressContentEditableWarning: !0, "aria-disabled": C || R, onInput: (e) => {
357
+ p.updateEditorState($.current), f && (w.current = !0, le.current = !0, i(!0), requestAnimationFrame(() => {
358
+ w.current = !1;
359
+ }));
360
+ const t = e.currentTarget, n = {
361
+ type: "change",
362
+ target: t,
363
+ currentTarget: t
364
+ };
365
+ M?.(n), P?.(n);
366
+ }, onChange: (e) => {
367
+ p.handleChange(e);
368
+ }, onPaste: p.handlePaste, onFocus: Oe, onBlur: ne, onKeyDownCapture: $e, onKeyDown: Fe, spellCheck: !1, children: Be }, Qe) : /* @__PURE__ */ g("input", { ref: y, ...he("input__control", He), onFocus: Oe, onBlur: ne, onKeyDownCapture: $e, onKeyDown: Fe, spellCheck: !1, disabled: C || R }), Ge = l.useCallback((e) => {
369
+ if (C || R) return;
289
370
  const t = e.target;
290
- te.current?.contains(t) || (D.current = !0, U(), T());
291
- }, [g, I, U, T]);
292
- x(() => {
293
- const e = W.current;
371
+ ie.current?.contains(t) || (w.current = !0, _(), N());
372
+ }, [C, R, _, N]);
373
+ I(() => {
374
+ const e = Z.current;
294
375
  if (!e) return;
295
376
  const t = (n) => {
296
- const r = n.relatedTarget;
297
- r && e.contains(r) || Q(n);
377
+ const o = n.relatedTarget;
378
+ o && e.contains(o) || ne(n);
298
379
  };
299
380
  return e.addEventListener("focusout", t), () => e.removeEventListener("focusout", t);
300
- }, [Q]);
301
- const Je = L(() => /* @__PURE__ */ z(_e, { open: ye, modal: !1, onOpenChange: (e) => {
302
- !e && D.current || a(e);
381
+ }, [ne]);
382
+ const Xe = D(() => /* @__PURE__ */ W(nt, { open: Ee, modal: !1, onOpenChange: (e) => {
383
+ !e && w.current || i(e);
303
384
  }, children: [
304
- /* @__PURE__ */ f(et, { asChild: !0, children: /* @__PURE__ */ f("button", { type: "button", tabIndex: -1, "aria-hidden": !0, style: {
385
+ /* @__PURE__ */ g(rt, { asChild: !0, children: /* @__PURE__ */ g("button", { type: "button", tabIndex: -1, "aria-hidden": !0, style: {
305
386
  position: "absolute",
306
387
  inset: 0,
307
388
  opacity: 0,
308
389
  pointerEvents: "none"
309
390
  }, onMouseDown: (e) => e.preventDefault() }) }),
310
- ue,
311
- /* @__PURE__ */ f(tt, { children: /* @__PURE__ */ f("div", { ref: te, onPointerDownCapture: () => {
312
- D.current = !0;
391
+ ge,
392
+ /* @__PURE__ */ g(ot, { children: /* @__PURE__ */ g("div", { ref: ie, onPointerDownCapture: () => {
393
+ w.current = !0;
313
394
  }, onMouseDownCapture: (e) => {
314
- e.preventDefault(), D.current = !0;
315
- }, children: /* @__PURE__ */ z(nt, { color: "secondary", inputRef: v, children: [
316
- ce,
317
- /* @__PURE__ */ z(ut, { paddingSize: "xxs", mt: -0.35, mx: -0.35, style: {
395
+ e.preventDefault(), w.current = !0;
396
+ }, children: /* @__PURE__ */ W(st, { color: "secondary", inputRef: k, children: [
397
+ me,
398
+ /* @__PURE__ */ W(ft, { paddingSize: "xxs", mt: -0.35, mx: -0.35, style: {
318
399
  borderWidth: "2px"
319
400
  }, children: [
320
- G?.length === 0 && me,
321
- !!G?.length && /* @__PURE__ */ f(
322
- rt,
401
+ te?.length === 0 && ke,
402
+ !!te?.length && /* @__PURE__ */ g(
403
+ at,
323
404
  {
324
- ref: M,
325
- inputRef: v,
326
- suggestions: G,
327
- onSuggestionSelect: Le
405
+ ref: F,
406
+ inputRef: k,
407
+ suggestions: te,
408
+ onSuggestionSelect: Re
328
409
  }
329
410
  )
330
411
  ] }),
331
- fe
412
+ ye
332
413
  ] }) }) })
333
- ] }), [ye, ue, o, G, ce, fe, me, Le, v, a]);
334
- return /* @__PURE__ */ z("div", { children: [
335
- Z && /* @__PURE__ */ f(Xe, { children: Z }),
336
- E && /* @__PURE__ */ f(Ye, { children: E }),
337
- /* @__PURE__ */ z("div", { ref: W, ...le(`input ${V?.valid ? "" : "input--not-valid"}`, Y), onPointerDown: Ue, children: [
338
- $ && /* @__PURE__ */ f("div", { className: `input__left input__left--${Be}`, children: $ }),
339
- l ? Je : ue,
340
- N && /* @__PURE__ */ f("div", { className: `input__right input__right--${Ae}`, children: N })
414
+ ] }), [Ee, ge, s, te, me, ye, ke, Re, k, i]);
415
+ return /* @__PURE__ */ W("div", { children: [
416
+ U && /* @__PURE__ */ g(_e, { children: U }),
417
+ T && /* @__PURE__ */ g(et, { children: T }),
418
+ /* @__PURE__ */ W("div", { ref: Z, ...he(`input ${L?.valid ? "" : "input--not-valid"}`, J), onPointerDown: Ge, children: [
419
+ H && /* @__PURE__ */ g("div", { className: `input__left input__left--${Ae}`, children: H }),
420
+ f ? Xe : ge,
421
+ Q && /* @__PURE__ */ g("div", { className: `input__right input__right--${Ne}`, children: Q })
341
422
  ] }),
342
- !V?.valid && V?.notValidMessage && /* @__PURE__ */ f(Ze, { children: V.notValidMessage })
423
+ !L?.valid && L?.notValidMessage && /* @__PURE__ */ g(tt, { children: L.notValidMessage })
343
424
  ] });
344
- }), xt = lt;
425
+ }), Lt = ht;
345
426
  export {
346
- xt as Input
427
+ Lt as Input
347
428
  };