@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.
- package/dist/components/avatar/Avatar.js +7 -7
- package/dist/components/breadcrumb/Breadcrumb.js +4 -4
- package/dist/components/button/Button.js +8 -8
- package/dist/components/context-menu/ContextMenu.js +131 -131
- package/dist/components/d-flow/DFlow.edges.hook.js +22 -22
- package/dist/components/d-flow/DFlow.js +32 -32
- package/dist/components/d-flow/DFlow.nodes.hook.js +8 -8
- package/dist/components/d-flow-file/DFlowTabDefault.js +16 -16
- package/dist/components/d-flow-folder/DFlowFolder.js +13 -13
- package/dist/components/d-flow-folder/DFlowFolderContextMenu.js +5 -5
- package/dist/components/d-flow-folder/DFlowFolderCreateDialog.js +13 -13
- package/dist/components/d-flow-folder/DFlowFolderDeleteDialog.js +5 -5
- package/dist/components/d-flow-folder/DFlowFolderRenameDialog.js +11 -11
- package/dist/components/d-flow-function/DFlowFunctionDefaultCard.js +7 -7
- package/dist/components/d-flow-function/DFlowFunctionSuggestionCard.js +9 -9
- package/dist/components/d-flow-function/DFlowFunctionTriggerCard.js +12 -12
- package/dist/components/d-flow-input/DFlowInputDataType.js +16 -16
- package/dist/components/d-flow-input/DFlowInputNodeBadge.js +8 -8
- package/dist/components/d-flow-input/DFlowInputReferenceBadge.js +4 -4
- package/dist/components/d-flow-panel/DFlowExport.js +5 -5
- package/dist/components/d-flow-panel/DFlowPanelControl.js +4 -4
- package/dist/components/d-flow-suggestion/DFlowFunctionSuggestions.hook.js +4 -4
- package/dist/components/d-flow-suggestion/DFlowSuggestion.hook.js +7 -7
- package/dist/components/d-flow-suggestion/DFlowSuggestionMenu.js +12 -12
- package/dist/components/d-flow-suggestion/DFlowSuggestionSearchInput.js +5 -5
- package/dist/components/d-flow-suggestion/DFlowValueSuggestions.hook.js +4 -4
- package/dist/components/d-flow-validation/DNodeValidation.hook.js +3 -3
- package/dist/components/d-fullscreen/DFullScreen.js +2 -2
- package/dist/components/d-member/DNamespaceMemberList.js +5 -5
- package/dist/components/d-organization/DOrganizationList.js +7 -7
- package/dist/components/d-organization/DOrganizationMenu.js +5 -5
- package/dist/components/d-organization/DOrganizatonContent.js +22 -22
- package/dist/components/d-project/DNamespaceProjectContent.js +6 -6
- package/dist/components/d-project/DNamespaceProjectList.js +5 -5
- package/dist/components/d-project/DNamespaceProjectMenu.js +2 -2
- package/dist/components/d-role/DNamespaceRolePermissions.js +5 -5
- package/dist/components/d-runtime/DRuntimeList.js +7 -7
- package/dist/components/d-user/DUser.session.hook.js +2 -2
- package/dist/components/d-user/DUserContent.js +13 -13
- package/dist/components/d-user/DUserList.js +9 -9
- package/dist/components/form/CheckboxInput.js +4 -4
- package/dist/components/form/EmailInput.js +9 -9
- package/dist/components/form/Input.js +311 -230
- package/dist/components/form/Input.utils.js +1 -1
- package/dist/components/form/InputContentEditable.hook.d.ts +14 -2
- package/dist/components/form/InputContentEditable.hook.js +296 -317
- package/dist/components/form/NumberInput.js +9 -9
- package/dist/components/form/PasswordInput.js +2 -2
- package/dist/components/form/SwitchInput.js +7 -7
- package/dist/components/form/TextInput.js +6 -6
- package/dist/node_modules/react/cjs/react-compiler-runtime.development.js +2 -2
- package/dist/node_modules/react/cjs/react-compiler-runtime.production.js +8 -8
- package/dist/utils/objectStore.js +15 -15
- package/dist/utils/reactiveArrayService.js +10 -10
- package/package.json +19 -19
- package/dist/_virtual/_commonjsHelpers.js +0 -6
- package/dist/_virtual/index.js +0 -4
- package/dist/_virtual/index2.js +0 -4
- package/dist/_virtual/react-contenteditable.js +0 -7
- package/dist/_virtual/react-contenteditable2.js +0 -4
- package/dist/_virtual/react-dom-server-legacy.browser.development.js +0 -4
- package/dist/_virtual/react-dom-server-legacy.browser.production.js +0 -4
- package/dist/_virtual/react-dom-server.browser.development.js +0 -4
- package/dist/_virtual/react-dom-server.browser.production.js +0 -4
- package/dist/_virtual/react-is.development.js +0 -4
- package/dist/_virtual/react-is.production.min.js +0 -4
- package/dist/_virtual/server.browser.js +0 -5
- package/dist/_virtual/server.browser2.js +0 -4
- package/dist/node_modules/@floating-ui/core/dist/floating-ui.core.js +0 -527
- package/dist/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +0 -402
- package/dist/node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.js +0 -208
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.js +0 -136
- package/dist/node_modules/@floating-ui/utils/dist/floating-ui.utils.js +0 -130
- package/dist/node_modules/@radix-ui/primitive/dist/index.js +0 -9
- package/dist/node_modules/@radix-ui/react-arrow/dist/index.js +0 -24
- package/dist/node_modules/@radix-ui/react-collection/dist/index.js +0 -48
- package/dist/node_modules/@radix-ui/react-compose-refs/dist/index.js +0 -29
- package/dist/node_modules/@radix-ui/react-context/dist/index.js +0 -53
- package/dist/node_modules/@radix-ui/react-context-menu/dist/index.js +0 -222
- package/dist/node_modules/@radix-ui/react-direction/dist/index.js +0 -10
- package/dist/node_modules/@radix-ui/react-dismissable-layer/dist/index.js +0 -127
- package/dist/node_modules/@radix-ui/react-focus-guards/dist/index.js +0 -17
- package/dist/node_modules/@radix-ui/react-focus-scope/dist/index.js +0 -136
- package/dist/node_modules/@radix-ui/react-id/dist/index.js +0 -13
- package/dist/node_modules/@radix-ui/react-menu/dist/index.js +0 -636
- package/dist/node_modules/@radix-ui/react-popper/dist/index.js +0 -219
- package/dist/node_modules/@radix-ui/react-portal/dist/index.js +0 -15
- package/dist/node_modules/@radix-ui/react-presence/dist/index.js +0 -70
- package/dist/node_modules/@radix-ui/react-primitive/dist/index.js +0 -36
- package/dist/node_modules/@radix-ui/react-roving-focus/dist/index.js +0 -183
- package/dist/node_modules/@radix-ui/react-slot/dist/index.js +0 -49
- package/dist/node_modules/@radix-ui/react-use-callback-ref/dist/index.js +0 -10
- package/dist/node_modules/@radix-ui/react-use-controllable-state/dist/index.js +0 -52
- package/dist/node_modules/@radix-ui/react-use-escape-keydown/dist/index.js +0 -14
- package/dist/node_modules/@radix-ui/react-use-layout-effect/dist/index.js +0 -6
- package/dist/node_modules/@radix-ui/react-use-size/dist/index.js +0 -27
- package/dist/node_modules/aria-hidden/dist/es2015/index.js +0 -52
- package/dist/node_modules/fast-deep-equal/index.js +0 -31
- package/dist/node_modules/get-nonce/dist/es2015/index.js +0 -7
- package/dist/node_modules/object-assign/index.js +0 -49
- package/dist/node_modules/prop-types/checkPropTypes.js +0 -54
- package/dist/node_modules/prop-types/factoryWithThrowingShims.js +0 -52
- package/dist/node_modules/prop-types/factoryWithTypeCheckers.js +0 -329
- package/dist/node_modules/prop-types/index.js +0 -17
- package/dist/node_modules/prop-types/lib/ReactPropTypesSecret.js +0 -10
- package/dist/node_modules/prop-types/lib/has.js +0 -7
- package/dist/node_modules/prop-types/node_modules/react-is/cjs/react-is.development.js +0 -87
- package/dist/node_modules/prop-types/node_modules/react-is/cjs/react-is.production.min.js +0 -70
- package/dist/node_modules/prop-types/node_modules/react-is/index.js +0 -10
- package/dist/node_modules/react-contenteditable/lib/react-contenteditable.js +0 -132
- package/dist/node_modules/react-dom/cjs/react-dom-server-legacy.browser.development.js +0 -6235
- package/dist/node_modules/react-dom/cjs/react-dom-server-legacy.browser.production.js +0 -4096
- package/dist/node_modules/react-dom/cjs/react-dom-server.browser.development.js +0 -6753
- package/dist/node_modules/react-dom/cjs/react-dom-server.browser.production.js +0 -4645
- package/dist/node_modules/react-dom/server.browser.js +0 -15
- package/dist/node_modules/react-remove-scroll/dist/es2015/Combination.js +0 -11
- package/dist/node_modules/react-remove-scroll/dist/es2015/SideEffect.js +0 -112
- package/dist/node_modules/react-remove-scroll/dist/es2015/UI.js +0 -31
- package/dist/node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js +0 -16
- package/dist/node_modules/react-remove-scroll/dist/es2015/handleScroll.js +0 -68
- package/dist/node_modules/react-remove-scroll/dist/es2015/medium.js +0 -5
- package/dist/node_modules/react-remove-scroll/dist/es2015/sidecar.js +0 -7
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/component.js +0 -71
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/constants.js +0 -7
- package/dist/node_modules/react-remove-scroll-bar/dist/es2015/utils.js +0 -25
- package/dist/node_modules/react-style-singleton/dist/es2015/component.js +0 -11
- package/dist/node_modules/react-style-singleton/dist/es2015/hook.js +0 -15
- package/dist/node_modules/react-style-singleton/dist/es2015/singleton.js +0 -30
- package/dist/node_modules/tslib/tslib.es6.js +0 -27
- package/dist/node_modules/use-callback-ref/dist/es2015/assignRef.js +0 -6
- package/dist/node_modules/use-callback-ref/dist/es2015/useMergeRef.js +0 -26
- package/dist/node_modules/use-callback-ref/dist/es2015/useRef.js +0 -25
- package/dist/node_modules/use-sidecar/dist/es2015/exports.js +0 -18
- package/dist/node_modules/use-sidecar/dist/es2015/medium.js +0 -67
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
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
|
|
4
|
+
import { mergeCode0Props as he } from "../../utils/utils.js";
|
|
6
5
|
import '../../assets/components/form/Input.style.css';/* empty css */
|
|
7
|
-
import { InputLabel as
|
|
8
|
-
import { InputDescription as
|
|
9
|
-
import { InputMessage as
|
|
10
|
-
import { Menu as
|
|
11
|
-
import { InputSuggestionMenuContent as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
},
|
|
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
|
|
29
|
-
if (!
|
|
30
|
-
const
|
|
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:
|
|
33
|
-
start:
|
|
34
|
-
end:
|
|
44
|
+
token: C,
|
|
45
|
+
start: H,
|
|
46
|
+
end: Q
|
|
35
47
|
};
|
|
36
|
-
},
|
|
48
|
+
}, ht = l.forwardRef((u, x) => {
|
|
37
49
|
const {
|
|
38
|
-
wrapperComponent:
|
|
39
|
-
title:
|
|
40
|
-
description:
|
|
41
|
-
disabled:
|
|
42
|
-
left:
|
|
43
|
-
right:
|
|
44
|
-
leftType:
|
|
45
|
-
rightType:
|
|
46
|
-
formValidation:
|
|
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:
|
|
52
|
-
suggestionsHeader:
|
|
53
|
-
suggestionsFooter:
|
|
54
|
-
onSuggestionSelect:
|
|
55
|
-
disableOnValue:
|
|
56
|
-
transformSyntax:
|
|
57
|
-
validationUsesSyntax:
|
|
58
|
-
filterSuggestionsByLastToken:
|
|
59
|
-
enforceUniqueSuggestions:
|
|
60
|
-
onLastTokenChange:
|
|
61
|
-
suggestionsEmptyState:
|
|
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:
|
|
65
|
-
onBlur:
|
|
66
|
-
onKeyDown:
|
|
67
|
-
onKeyDownCapture:
|
|
68
|
-
onChange:
|
|
69
|
-
onInput:
|
|
70
|
-
...
|
|
71
|
-
} = ze,
|
|
72
|
-
|
|
73
|
-
}, []), [
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
...
|
|
77
|
-
onChange:
|
|
78
|
-
onInput:
|
|
79
|
-
}), [
|
|
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
|
-
} =
|
|
85
|
-
return
|
|
86
|
-
}, [
|
|
87
|
-
const e =
|
|
88
|
-
!e ||
|
|
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
|
-
}, [
|
|
92
|
-
|
|
93
|
-
}, [
|
|
94
|
-
|
|
95
|
-
}, [
|
|
96
|
-
if (!
|
|
97
|
-
const n =
|
|
98
|
-
Object.is(
|
|
99
|
-
}, [
|
|
100
|
-
editorRef:
|
|
101
|
-
transformSyntax:
|
|
102
|
-
filterSuggestionsByLastToken:
|
|
103
|
-
onLastTokenChange:
|
|
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
|
-
|
|
121
|
+
Ve(e), fe(t), Ue(n ?? null), pe(e, n ?? null);
|
|
110
122
|
}
|
|
111
|
-
}),
|
|
112
|
-
|
|
113
|
-
if (!
|
|
114
|
-
const e =
|
|
115
|
-
|
|
116
|
-
}, [
|
|
117
|
-
|
|
118
|
-
}, [
|
|
119
|
-
|
|
120
|
-
}, [
|
|
121
|
-
if (!
|
|
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,
|
|
124
|
-
|
|
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
|
-
}, [
|
|
128
|
-
const e =
|
|
139
|
+
}, [f, i]), I(() => {
|
|
140
|
+
const e = Z.current;
|
|
129
141
|
if (!e) return;
|
|
130
|
-
const t = () =>
|
|
142
|
+
const t = () => N();
|
|
131
143
|
return e.addEventListener("focusin", t), () => e.removeEventListener("focusin", t);
|
|
132
|
-
}, [
|
|
133
|
-
const
|
|
144
|
+
}, [N]);
|
|
145
|
+
const Pe = l.useCallback((e, t, n) => {
|
|
134
146
|
if (e.length === 0) return t <= n.length ? t : null;
|
|
135
|
-
let
|
|
136
|
-
if (
|
|
137
|
-
let
|
|
138
|
-
for (;
|
|
139
|
-
Math.abs(
|
|
140
|
-
return
|
|
141
|
-
}, []),
|
|
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((
|
|
144
|
-
const
|
|
145
|
-
if (
|
|
146
|
-
const
|
|
147
|
-
t.slice(
|
|
148
|
-
...
|
|
149
|
-
start:
|
|
150
|
-
end:
|
|
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
|
-
}, [
|
|
154
|
-
|
|
155
|
-
if (
|
|
156
|
-
const e =
|
|
157
|
-
|
|
158
|
-
const n =
|
|
159
|
-
return
|
|
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
|
-
}, [
|
|
162
|
-
if (!
|
|
163
|
-
const e =
|
|
173
|
+
}, [s, ee, h]), I(() => {
|
|
174
|
+
if (!v || s) return;
|
|
175
|
+
const e = y.current;
|
|
164
176
|
if (!e) return;
|
|
165
|
-
const t = () =>
|
|
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
|
-
}, [
|
|
170
|
-
const
|
|
171
|
-
if (!
|
|
172
|
-
const e =
|
|
173
|
-
return e?.length ?
|
|
174
|
-
}, [
|
|
175
|
-
if (!
|
|
176
|
-
if (
|
|
177
|
-
const t = new Set((
|
|
178
|
-
return
|
|
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(
|
|
181
|
-
return
|
|
182
|
-
}, [
|
|
183
|
-
if (!
|
|
184
|
-
const t = typeof
|
|
185
|
-
let
|
|
186
|
-
const
|
|
187
|
-
if (
|
|
188
|
-
|
|
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 (
|
|
202
|
+
switch (o) {
|
|
191
203
|
case "append":
|
|
192
|
-
|
|
204
|
+
r = `${a}${n}`, m = r.length, c = a.length;
|
|
193
205
|
break;
|
|
194
206
|
case "prepend":
|
|
195
|
-
|
|
207
|
+
r = `${n}${a}`, m = n.length, c = 0;
|
|
196
208
|
break;
|
|
197
209
|
case "insert": {
|
|
198
210
|
const {
|
|
199
|
-
rawStart:
|
|
200
|
-
rawEnd:
|
|
201
|
-
} =
|
|
202
|
-
|
|
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
|
-
|
|
219
|
+
r = n, m = n.length, c = 0;
|
|
208
220
|
break;
|
|
209
221
|
}
|
|
210
|
-
|
|
211
|
-
const
|
|
212
|
-
id:
|
|
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:
|
|
216
|
-
end:
|
|
217
|
-
} : null,
|
|
218
|
-
return oe
|
|
219
|
-
}),
|
|
220
|
-
const
|
|
221
|
-
|
|
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
|
-
}),
|
|
235
|
+
}), ct(d, m, m));
|
|
224
236
|
});
|
|
225
|
-
}, [
|
|
226
|
-
if (
|
|
227
|
-
const t =
|
|
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
|
-
})),
|
|
249
|
+
})), M?.(n), P?.(n);
|
|
238
250
|
});
|
|
239
251
|
}
|
|
240
|
-
|
|
241
|
-
|
|
252
|
+
i(!1), w.current = !1, requestAnimationFrame(() => {
|
|
253
|
+
_();
|
|
242
254
|
});
|
|
243
|
-
}, [
|
|
244
|
-
|
|
245
|
-
}, [
|
|
246
|
-
if (
|
|
247
|
-
|
|
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
|
-
|
|
251
|
-
|
|
252
|
-
if (o) {
|
|
253
|
-
p.handleKeyDownCapture(e), ee?.(e);
|
|
262
|
+
if (w.current) {
|
|
263
|
+
X?.(e);
|
|
254
264
|
return;
|
|
255
265
|
}
|
|
256
|
-
(
|
|
257
|
-
}, [
|
|
258
|
-
if (
|
|
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(),
|
|
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(),
|
|
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" &&
|
|
268
|
-
e.preventDefault(), e.stopPropagation(),
|
|
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" &&
|
|
272
|
-
e.preventDefault(), e.stopPropagation(),
|
|
287
|
+
if (e.key === "Escape" && B.current) {
|
|
288
|
+
e.preventDefault(), e.stopPropagation(), i(!1);
|
|
273
289
|
return;
|
|
274
290
|
}
|
|
275
291
|
}
|
|
276
|
-
if (
|
|
277
|
-
|
|
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 (
|
|
281
|
-
e.preventDefault(),
|
|
307
|
+
if (s && e.key === "Enter") {
|
|
308
|
+
e.preventDefault(), Y?.(e);
|
|
282
309
|
return;
|
|
283
310
|
}
|
|
284
|
-
|
|
285
|
-
}, [
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
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
|
-
|
|
291
|
-
}, [
|
|
292
|
-
|
|
293
|
-
const e =
|
|
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
|
|
297
|
-
|
|
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
|
-
}, [
|
|
301
|
-
const
|
|
302
|
-
!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__ */
|
|
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
|
-
|
|
311
|
-
/* @__PURE__ */
|
|
312
|
-
|
|
391
|
+
ge,
|
|
392
|
+
/* @__PURE__ */ g(ot, { children: /* @__PURE__ */ g("div", { ref: ie, onPointerDownCapture: () => {
|
|
393
|
+
w.current = !0;
|
|
313
394
|
}, onMouseDownCapture: (e) => {
|
|
314
|
-
e.preventDefault(),
|
|
315
|
-
}, children: /* @__PURE__ */
|
|
316
|
-
|
|
317
|
-
/* @__PURE__ */
|
|
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
|
-
|
|
321
|
-
!!
|
|
322
|
-
|
|
401
|
+
te?.length === 0 && ke,
|
|
402
|
+
!!te?.length && /* @__PURE__ */ g(
|
|
403
|
+
at,
|
|
323
404
|
{
|
|
324
|
-
ref:
|
|
325
|
-
inputRef:
|
|
326
|
-
suggestions:
|
|
327
|
-
onSuggestionSelect:
|
|
405
|
+
ref: F,
|
|
406
|
+
inputRef: k,
|
|
407
|
+
suggestions: te,
|
|
408
|
+
onSuggestionSelect: Re
|
|
328
409
|
}
|
|
329
410
|
)
|
|
330
411
|
] }),
|
|
331
|
-
|
|
412
|
+
ye
|
|
332
413
|
] }) }) })
|
|
333
|
-
] }), [
|
|
334
|
-
return /* @__PURE__ */
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
/* @__PURE__ */
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
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
|
-
!
|
|
423
|
+
!L?.valid && L?.notValidMessage && /* @__PURE__ */ g(tt, { children: L.notValidMessage })
|
|
343
424
|
] });
|
|
344
|
-
}),
|
|
425
|
+
}), Lt = ht;
|
|
345
426
|
export {
|
|
346
|
-
|
|
427
|
+
Lt as Input
|
|
347
428
|
};
|