@code0-tech/pictor 0.0.0-mvp.31 → 0.0.0-mvp.33

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