@pibit.ai/cure-design-system 0.6.52 → 0.6.54
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/_virtual/index.js +2 -3
- package/dist/_virtual/index2.js +3 -5
- package/dist/_virtual/index3.js +5 -2
- package/dist/node_modules/eventemitter3/index.js +1 -1
- package/dist/node_modules/react-is/index.js +1 -1
- package/dist/node_modules/recharts/es6/util/Events.js +1 -1
- package/dist/node_modules/recharts/es6/util/ReactUtils.js +1 -1
- package/dist/node_modules/use-sync-external-store/shim/index.js +1 -1
- package/dist/patterns/condition-builder/add-action-button.d.ts +2 -0
- package/dist/patterns/condition-builder/add-action-button.d.ts.map +1 -1
- package/dist/patterns/condition-builder/add-action-button.js +22 -18
- package/dist/patterns/condition-builder/condition-builder.d.ts +1 -1
- package/dist/patterns/condition-builder/condition-builder.d.ts.map +1 -1
- package/dist/patterns/condition-builder/condition-builder.js +58 -57
- package/dist/patterns/condition-builder/condition-group.d.ts +1 -1
- package/dist/patterns/condition-builder/condition-group.d.ts.map +1 -1
- package/dist/patterns/condition-builder/condition-group.js +238 -233
- package/dist/patterns/condition-builder/types.d.ts +10 -0
- package/dist/patterns/condition-builder/types.d.ts.map +1 -1
- package/dist/patterns/confirm-dialog/confirm-dialog.d.ts +8 -1
- package/dist/patterns/confirm-dialog/confirm-dialog.d.ts.map +1 -1
- package/dist/patterns/confirm-dialog/confirm-dialog.js +76 -71
- package/dist/patterns/filter-group/document-fields-to-tree.d.ts +1 -0
- package/dist/patterns/filter-group/document-fields-to-tree.d.ts.map +1 -1
- package/dist/patterns/filter-group/document-fields-to-tree.js +14 -13
- package/dist/patterns/filter-group/filter-condition-row.js +30 -30
- package/dist/patterns/filter-group/nested-field-select.d.ts.map +1 -1
- package/dist/patterns/filter-group/nested-field-select.js +175 -167
- package/dist/patterns/filter-group/types.d.ts +4 -0
- package/dist/patterns/filter-group/types.d.ts.map +1 -1
- package/dist/patterns/filter-group/types.js +27 -12
- package/dist/rich-text/token-input/index.d.ts +1 -1
- package/dist/rich-text/token-input/index.d.ts.map +1 -1
- package/dist/rich-text/token-input/token-input.d.ts +22 -5
- package/dist/rich-text/token-input/token-input.d.ts.map +1 -1
- package/dist/rich-text/token-input/token-input.js +242 -181
- package/dist/rich-text/token-input/token-node.d.ts +7 -0
- package/dist/rich-text/token-input/token-node.d.ts.map +1 -1
- package/dist/rich-text/token-input/token-node.js +20 -15
- package/dist/rich-text/token-input/token-suggestion.d.ts +33 -3
- package/dist/rich-text/token-input/token-suggestion.d.ts.map +1 -1
- package/dist/rich-text/token-input/token-suggestion.js +94 -63
- package/dist/styles/components.css +1 -1
- package/package.json +1 -1
|
@@ -1,100 +1,109 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
1
|
+
import { jsx as k, jsxs as me } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as xe, useRef as S, useState as te, useMemo as ye, useEffect as w, useImperativeHandle as be } from "react";
|
|
3
|
+
import { Extension as ke } from "@tiptap/core";
|
|
4
|
+
import { Slice as Te } from "@tiptap/pm/model";
|
|
5
|
+
import { Plugin as he, PluginKey as ge } from "@tiptap/pm/state";
|
|
6
|
+
import { Placeholder as Pe } from "@tiptap/extension-placeholder";
|
|
7
|
+
import { useEditor as _e, EditorContent as Me } from "@tiptap/react";
|
|
8
|
+
import { StarterKit as De } from "@tiptap/starter-kit";
|
|
9
|
+
import { cx as V } from "../../utils/cn.js";
|
|
10
|
+
import { segmentsToDoc as z, rangeToText as Ne, docToSegments as Se } from "./segments.js";
|
|
11
|
+
import { TokenNode as we, TokenRenderVersion as ze } from "./token-node.js";
|
|
12
|
+
import { createTokenSuggestionExtension as Ie } from "./token-suggestion.js";
|
|
13
|
+
const Re = {
|
|
11
14
|
neutral: "border-secondary bg-primary text-secondary",
|
|
12
15
|
brand: "border-utility-brand-200 bg-utility-brand-50 text-utility-brand-700",
|
|
13
16
|
error: "border-utility-error-200 bg-utility-error-50 text-utility-error-700"
|
|
14
17
|
};
|
|
15
|
-
function
|
|
16
|
-
label:
|
|
17
|
-
icon:
|
|
18
|
-
tone:
|
|
19
|
-
selected:
|
|
18
|
+
function Be({
|
|
19
|
+
label: g,
|
|
20
|
+
icon: u,
|
|
21
|
+
tone: P = "neutral",
|
|
22
|
+
selected: m
|
|
20
23
|
}) {
|
|
21
|
-
return /* @__PURE__ */
|
|
24
|
+
return /* @__PURE__ */ me(
|
|
22
25
|
"span",
|
|
23
26
|
{
|
|
24
|
-
className:
|
|
27
|
+
className: V(
|
|
25
28
|
"inline-flex max-w-60 items-center gap-1 rounded-md border px-1.5 py-px text-xs font-medium",
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
Re[P],
|
|
30
|
+
m && "ring-2 ring-brand"
|
|
28
31
|
),
|
|
29
32
|
children: [
|
|
30
|
-
|
|
31
|
-
/* @__PURE__ */
|
|
33
|
+
u && /* @__PURE__ */ k("span", { className: "flex size-3.5 shrink-0 items-center", children: u }),
|
|
34
|
+
/* @__PURE__ */ k("span", { className: "truncate", children: g })
|
|
32
35
|
]
|
|
33
36
|
}
|
|
34
37
|
);
|
|
35
38
|
}
|
|
36
|
-
const
|
|
39
|
+
const B = (g) => g.replace(/\r\n|\r|\n/g, ""), Oe = xe(
|
|
37
40
|
function({
|
|
38
|
-
value:
|
|
39
|
-
onChange:
|
|
40
|
-
parse:
|
|
41
|
-
serialize:
|
|
42
|
-
renderToken:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
41
|
+
value: u,
|
|
42
|
+
onChange: P,
|
|
43
|
+
parse: m,
|
|
44
|
+
serialize: K,
|
|
45
|
+
renderToken: U,
|
|
46
|
+
tokenWrapperClassName: v = "inline-flex align-middle",
|
|
47
|
+
autoTokenize: F,
|
|
48
|
+
getTokenDisplay: j,
|
|
49
|
+
suggestions: _,
|
|
50
|
+
placeholder: re,
|
|
51
|
+
readOnly: M = !1,
|
|
52
|
+
isInvalid: A = !1,
|
|
53
|
+
allowNewlines: D = !1,
|
|
54
|
+
preservePastedNewlines: J,
|
|
55
|
+
tokenPaste: L = !0,
|
|
56
|
+
filterTextInput: W,
|
|
57
|
+
onKeyDownCapture: q,
|
|
58
|
+
onKeyDown: H,
|
|
59
|
+
onFocus: O,
|
|
60
|
+
onBlur: G,
|
|
61
|
+
extensions: ne,
|
|
62
|
+
onEditorChange: x,
|
|
63
|
+
chrome: se = !0,
|
|
64
|
+
className: oe,
|
|
65
|
+
contentClassName: ae,
|
|
66
|
+
contentAttributes: ie
|
|
67
|
+
}, le) {
|
|
68
|
+
const o = S({
|
|
69
|
+
value: u,
|
|
70
|
+
onChange: P,
|
|
71
|
+
parse: m,
|
|
72
|
+
serialize: K,
|
|
73
|
+
renderToken: U,
|
|
74
|
+
tokenWrapperClassName: v,
|
|
75
|
+
autoTokenize: F,
|
|
76
|
+
getTokenDisplay: j,
|
|
77
|
+
allowNewlines: D,
|
|
78
|
+
preservePastedNewlines: J ?? D,
|
|
79
|
+
tokenPaste: L,
|
|
80
|
+
filterTextInput: W,
|
|
81
|
+
onKeyDownCapture: q,
|
|
82
|
+
onKeyDown: H,
|
|
83
|
+
onFocus: O,
|
|
84
|
+
onBlur: G
|
|
78
85
|
});
|
|
79
86
|
o.current = {
|
|
80
|
-
value:
|
|
81
|
-
onChange:
|
|
82
|
-
parse:
|
|
83
|
-
serialize:
|
|
84
|
-
renderToken:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
87
|
+
value: u,
|
|
88
|
+
onChange: P,
|
|
89
|
+
parse: m,
|
|
90
|
+
serialize: K,
|
|
91
|
+
renderToken: U,
|
|
92
|
+
tokenWrapperClassName: v,
|
|
93
|
+
autoTokenize: F,
|
|
94
|
+
getTokenDisplay: j,
|
|
95
|
+
allowNewlines: D,
|
|
96
|
+
preservePastedNewlines: J ?? D,
|
|
97
|
+
tokenPaste: L,
|
|
98
|
+
filterTextInput: W,
|
|
99
|
+
onKeyDownCapture: q,
|
|
100
|
+
onKeyDown: H,
|
|
101
|
+
onFocus: O,
|
|
102
|
+
onBlur: G
|
|
94
103
|
};
|
|
95
|
-
const
|
|
104
|
+
const I = S(!1), Q = S(!1), [ce, ue] = te(0), [X, Y] = te(!1), Z = (e) => o.current.serialize([{ type: "token", value: e }]), R = (e) => o.current.serialize(Se(e.getJSON())), fe = ye(
|
|
96
105
|
() => [
|
|
97
|
-
|
|
106
|
+
De.configure({
|
|
98
107
|
bold: !1,
|
|
99
108
|
blockquote: !1,
|
|
100
109
|
bulletList: !1,
|
|
@@ -110,177 +119,229 @@ const I = (x) => x.replace(/\r\n|\r|\n/g, ""), Re = le(
|
|
|
110
119
|
listItem: !1,
|
|
111
120
|
listKeymap: !1
|
|
112
121
|
}),
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
getRenderToken: () => o.current.renderToken ?? ((
|
|
116
|
-
var
|
|
117
|
-
return /* @__PURE__ */
|
|
118
|
-
|
|
122
|
+
Pe.configure({ placeholder: re ?? "" }),
|
|
123
|
+
we.configure({
|
|
124
|
+
getRenderToken: () => o.current.renderToken ?? ((e) => {
|
|
125
|
+
var s, r;
|
|
126
|
+
return /* @__PURE__ */ k(
|
|
127
|
+
Be,
|
|
119
128
|
{
|
|
120
|
-
...((r = (
|
|
121
|
-
label:
|
|
129
|
+
...((r = (s = o.current).getTokenDisplay) == null ? void 0 : r.call(s, e.value)) ?? {
|
|
130
|
+
label: e.value
|
|
122
131
|
},
|
|
123
|
-
selected:
|
|
132
|
+
selected: e.selected
|
|
124
133
|
}
|
|
125
134
|
);
|
|
126
135
|
}),
|
|
127
|
-
getTokenText: () =>
|
|
136
|
+
getTokenText: () => Z,
|
|
137
|
+
getWrapperClassName: () => o.current.tokenWrapperClassName
|
|
128
138
|
}),
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
139
|
+
ke.create({
|
|
140
|
+
name: "tokenAutoTokenize",
|
|
141
|
+
addProseMirrorPlugins() {
|
|
142
|
+
return [
|
|
143
|
+
new he({
|
|
144
|
+
key: new ge("tokenAutoTokenize"),
|
|
145
|
+
appendTransaction: (e, s, r) => {
|
|
146
|
+
const n = o.current.autoTokenize;
|
|
147
|
+
if (!n || !e.some((a) => a.docChanged))
|
|
148
|
+
return null;
|
|
149
|
+
const c = r.schema.nodes.token, f = [];
|
|
150
|
+
if (r.doc.descendants((a, T) => {
|
|
151
|
+
if (!(!a.isText || !a.text))
|
|
152
|
+
for (const p of n(a.text))
|
|
153
|
+
f.push({
|
|
154
|
+
from: T + p.start,
|
|
155
|
+
to: T + p.end,
|
|
156
|
+
value: p.value
|
|
157
|
+
});
|
|
158
|
+
}), !f.length) return null;
|
|
159
|
+
const y = r.tr;
|
|
160
|
+
for (const a of f.reverse())
|
|
161
|
+
y.replaceWith(
|
|
162
|
+
a.from,
|
|
163
|
+
a.to,
|
|
164
|
+
c.create({ value: a.value })
|
|
165
|
+
);
|
|
166
|
+
return y;
|
|
167
|
+
}
|
|
168
|
+
})
|
|
169
|
+
];
|
|
170
|
+
}
|
|
171
|
+
}),
|
|
172
|
+
..._ != null && _.length ? [
|
|
173
|
+
Ie(_, (e) => {
|
|
174
|
+
Q.current = e;
|
|
132
175
|
})
|
|
133
176
|
] : [],
|
|
134
|
-
...
|
|
177
|
+
...ne ?? []
|
|
135
178
|
],
|
|
136
179
|
// Extensions are fixed for the editor's lifetime, like the original inputs.
|
|
137
180
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
138
181
|
[]
|
|
139
|
-
),
|
|
182
|
+
), t = _e({
|
|
140
183
|
immediatelyRender: !1,
|
|
141
|
-
editable: !
|
|
142
|
-
extensions:
|
|
143
|
-
content:
|
|
184
|
+
editable: !M,
|
|
185
|
+
extensions: fe,
|
|
186
|
+
content: z(m(u)),
|
|
144
187
|
editorProps: {
|
|
145
|
-
attributes:
|
|
188
|
+
attributes: ie ?? {
|
|
146
189
|
class: "w-full outline-none text-sm text-primary"
|
|
147
190
|
},
|
|
148
191
|
handleDOMEvents: {
|
|
149
|
-
focus: (
|
|
150
|
-
var r,
|
|
151
|
-
return
|
|
192
|
+
focus: (e, s) => {
|
|
193
|
+
var r, n;
|
|
194
|
+
return Y(!0), (n = (r = o.current).onFocus) == null || n.call(r, s), !1;
|
|
152
195
|
},
|
|
153
|
-
blur: (
|
|
154
|
-
var r,
|
|
155
|
-
return
|
|
196
|
+
blur: (e, s) => {
|
|
197
|
+
var r, n;
|
|
198
|
+
return Y(!1), (n = (r = o.current).onBlur) == null || n.call(r, s), !1;
|
|
156
199
|
}
|
|
157
200
|
},
|
|
158
|
-
clipboardTextSerializer: (
|
|
159
|
-
const { from: r, to:
|
|
160
|
-
return
|
|
201
|
+
clipboardTextSerializer: (e, s) => {
|
|
202
|
+
const { from: r, to: n } = s.state.selection;
|
|
203
|
+
return Ne(s.state.doc, r, n, Z);
|
|
161
204
|
},
|
|
162
|
-
handlePaste: (
|
|
163
|
-
var
|
|
164
|
-
|
|
205
|
+
handlePaste: (e, s) => {
|
|
206
|
+
var E;
|
|
207
|
+
s.preventDefault();
|
|
165
208
|
const r = o.current;
|
|
166
|
-
let
|
|
167
|
-
if (!
|
|
209
|
+
let n = ((E = s.clipboardData) == null ? void 0 : E.getData("text/plain")) || "";
|
|
210
|
+
if (!n || !r.preservePastedNewlines && (n = B(n), !n))
|
|
168
211
|
return !0;
|
|
169
|
-
const { from:
|
|
170
|
-
docText:
|
|
212
|
+
const { from: c, to: f } = e.state.selection, y = {
|
|
213
|
+
docText: e.state.doc.textBetween(
|
|
171
214
|
0,
|
|
172
|
-
|
|
215
|
+
e.state.doc.content.size,
|
|
173
216
|
"",
|
|
174
217
|
""
|
|
175
218
|
),
|
|
176
|
-
textBefore:
|
|
177
|
-
raw:
|
|
178
|
-
},
|
|
179
|
-
if (
|
|
180
|
-
const
|
|
181
|
-
|
|
219
|
+
textBefore: e.state.doc.textBetween(0, c, "", ""),
|
|
220
|
+
raw: n
|
|
221
|
+
}, a = r.filterTextInput, T = $.current, p = r.tokenPaste ? r.parse(n) : [];
|
|
222
|
+
if (r.preservePastedNewlines) {
|
|
223
|
+
const h = (r.tokenPaste ? p : n.split(/\r\n|\r|\n/).flatMap(
|
|
224
|
+
(i, b) => b > 0 ? [{ type: "newline" }, { type: "text", text: i }] : [{ type: "text", text: i }]
|
|
225
|
+
)).flatMap((i) => i.type !== "text" ? [i] : (a ? a(i.text, y) : i.text).split(/\r\n|\r|\n/).flatMap(
|
|
226
|
+
(ee, pe) => pe > 0 ? [{ type: "newline" }, { type: "text", text: ee }] : [{ type: "text", text: ee }]
|
|
227
|
+
)), l = e.state.schema.nodeFromJSON(z(h));
|
|
228
|
+
return e.dispatch(
|
|
229
|
+
e.state.tr.replaceSelection(new Te(l.content, 1, 1)).scrollIntoView()
|
|
230
|
+
), !0;
|
|
231
|
+
}
|
|
232
|
+
if (T && p.some((d) => d.type === "token")) {
|
|
233
|
+
const d = [];
|
|
234
|
+
for (const l of p)
|
|
182
235
|
if (l.type === "token")
|
|
183
|
-
|
|
236
|
+
d.push({ token: l.value });
|
|
184
237
|
else {
|
|
185
|
-
const
|
|
186
|
-
` : l.text,
|
|
187
|
-
|
|
238
|
+
const i = l.type === "newline" ? `
|
|
239
|
+
` : l.text, b = d[d.length - 1];
|
|
240
|
+
b && "text" in b ? b.text += i : d.push({ text: i });
|
|
188
241
|
}
|
|
189
|
-
const
|
|
190
|
-
for (const l of
|
|
242
|
+
const h = T.chain().focus();
|
|
243
|
+
for (const l of d)
|
|
191
244
|
if ("token" in l)
|
|
192
|
-
|
|
245
|
+
h.insertToken(l.token);
|
|
193
246
|
else {
|
|
194
|
-
let
|
|
195
|
-
r.preservePastedNewlines || (
|
|
247
|
+
let i = a ? a(l.text, y) : l.text;
|
|
248
|
+
r.preservePastedNewlines || (i = B(i)), i && h.insertContent(i);
|
|
196
249
|
}
|
|
197
|
-
return
|
|
250
|
+
return h.run(), !0;
|
|
198
251
|
}
|
|
199
|
-
let
|
|
200
|
-
return r.preservePastedNewlines || (
|
|
252
|
+
let N = a ? a(n, y) : n;
|
|
253
|
+
return r.preservePastedNewlines || (N = B(N)), N && e.dispatch(e.state.tr.insertText(N, c, f)), !0;
|
|
201
254
|
},
|
|
202
|
-
handleTextInput: (
|
|
203
|
-
const
|
|
204
|
-
if (!
|
|
205
|
-
const
|
|
206
|
-
docText:
|
|
255
|
+
handleTextInput: (e, s, r, n) => {
|
|
256
|
+
const c = o.current.filterTextInput;
|
|
257
|
+
if (!c) return !1;
|
|
258
|
+
const f = c(n, {
|
|
259
|
+
docText: e.state.doc.textBetween(
|
|
207
260
|
0,
|
|
208
|
-
|
|
261
|
+
e.state.doc.content.size,
|
|
209
262
|
"",
|
|
210
263
|
""
|
|
211
264
|
),
|
|
212
|
-
textBefore:
|
|
213
|
-
raw:
|
|
265
|
+
textBefore: e.state.doc.textBetween(0, s, "", ""),
|
|
266
|
+
raw: n
|
|
214
267
|
});
|
|
215
|
-
return
|
|
268
|
+
return f === n ? !1 : (f && e.dispatch(e.state.tr.insertText(f, s, r)), !0);
|
|
216
269
|
},
|
|
217
|
-
handleKeyDown: (
|
|
218
|
-
var
|
|
270
|
+
handleKeyDown: (e, s) => {
|
|
271
|
+
var n, c;
|
|
219
272
|
const r = o.current;
|
|
220
|
-
return (
|
|
273
|
+
return (n = r.onKeyDownCapture) != null && n.call(r, e, s) ? !0 : Q.current ? !1 : !r.allowNewlines && s.key === "Enter" ? (s.preventDefault(), !0) : ((c = r.onKeyDown) == null ? void 0 : c.call(r, e, s)) ?? !1;
|
|
221
274
|
}
|
|
222
275
|
}
|
|
223
|
-
}),
|
|
224
|
-
|
|
225
|
-
!
|
|
276
|
+
}), $ = S(null);
|
|
277
|
+
$.current = t, w(() => (x == null || x(t), () => x == null ? void 0 : x(null)), [t]), w(() => {
|
|
278
|
+
!t || t.isDestroyed || (!I.current && R(t) !== u && t.commands.setContent(z(m(u)), {
|
|
226
279
|
emitUpdate: !1
|
|
227
|
-
}),
|
|
228
|
-
}, [
|
|
229
|
-
!
|
|
230
|
-
}, [
|
|
231
|
-
if (!
|
|
232
|
-
const
|
|
233
|
-
const
|
|
234
|
-
|
|
280
|
+
}), I.current = !1);
|
|
281
|
+
}, [u, t]), w(() => {
|
|
282
|
+
!t || t.isDestroyed || t.setEditable(!M);
|
|
283
|
+
}, [t, M]), w(() => {
|
|
284
|
+
if (!t || t.isDestroyed) return;
|
|
285
|
+
const e = () => {
|
|
286
|
+
const s = R(t);
|
|
287
|
+
s !== o.current.value && (I.current = !0, o.current.onChange(s));
|
|
235
288
|
};
|
|
236
|
-
return
|
|
237
|
-
|
|
289
|
+
return t.on("update", e), () => {
|
|
290
|
+
t.off("update", e);
|
|
238
291
|
};
|
|
239
|
-
}, [
|
|
240
|
-
|
|
292
|
+
}, [t]), be(
|
|
293
|
+
le,
|
|
241
294
|
() => ({
|
|
242
|
-
editor:
|
|
243
|
-
insertToken: (
|
|
244
|
-
|
|
295
|
+
editor: t,
|
|
296
|
+
insertToken: (e) => {
|
|
297
|
+
t == null || t.chain().focus().insertToken(e).run();
|
|
245
298
|
},
|
|
246
|
-
|
|
247
|
-
|
|
299
|
+
reload: () => {
|
|
300
|
+
!t || t.isDestroyed || (t.commands.setContent(
|
|
301
|
+
z(o.current.parse(o.current.value)),
|
|
302
|
+
{
|
|
303
|
+
emitUpdate: !1
|
|
304
|
+
}
|
|
305
|
+
), ue((e) => e + 1));
|
|
306
|
+
},
|
|
307
|
+
focus: () => t == null ? void 0 : t.commands.focus(),
|
|
308
|
+
getValue: () => t && !t.isDestroyed ? R(t) : ""
|
|
248
309
|
}),
|
|
249
310
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
250
|
-
[
|
|
311
|
+
[t]
|
|
251
312
|
);
|
|
252
|
-
const
|
|
253
|
-
|
|
313
|
+
const de = /* @__PURE__ */ k(
|
|
314
|
+
Me,
|
|
254
315
|
{
|
|
255
|
-
editor:
|
|
316
|
+
editor: t,
|
|
256
317
|
className: (
|
|
257
318
|
// A host's own surface classes replace the defaults wholesale: custom
|
|
258
319
|
// colour tokens can't be de-duplicated by tailwind-merge.
|
|
259
|
-
|
|
320
|
+
ae ?? V(
|
|
260
321
|
"[&_.ProseMirror_p]:m-0",
|
|
261
322
|
"[&_.ProseMirror_p.is-empty::before]:pointer-events-none [&_.ProseMirror_p.is-empty::before]:float-left [&_.ProseMirror_p.is-empty::before]:h-0 [&_.ProseMirror_p.is-empty::before]:text-placeholder [&_.ProseMirror_p.is-empty::before]:content-[attr(data-placeholder)]",
|
|
262
323
|
"[&_.ProseMirror-selectednode]:outline-none"
|
|
263
324
|
)
|
|
264
325
|
)
|
|
265
326
|
}
|
|
266
|
-
);
|
|
267
|
-
return
|
|
327
|
+
), C = /* @__PURE__ */ k(ze.Provider, { value: ce, children: de });
|
|
328
|
+
return se ? /* @__PURE__ */ k(
|
|
268
329
|
"div",
|
|
269
330
|
{
|
|
270
|
-
onClick: () =>
|
|
271
|
-
className:
|
|
331
|
+
onClick: () => t == null ? void 0 : t.commands.focus(),
|
|
332
|
+
className: V(
|
|
272
333
|
"w-full cursor-text rounded-lg bg-primary px-3 py-2 shadow-xs ring-1 ring-inset transition duration-100 ease-linear",
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
334
|
+
A ? "ring-error_subtle" : X ? "ring-2 ring-brand" : "ring-primary",
|
|
335
|
+
A && X && "ring-2 ring-error",
|
|
336
|
+
M && "cursor-default bg-disabled_subtle",
|
|
337
|
+
oe
|
|
277
338
|
),
|
|
278
|
-
children:
|
|
339
|
+
children: C
|
|
279
340
|
}
|
|
280
|
-
) :
|
|
341
|
+
) : C;
|
|
281
342
|
}
|
|
282
343
|
);
|
|
283
344
|
export {
|
|
284
|
-
|
|
285
|
-
|
|
345
|
+
Oe as TokenInput,
|
|
346
|
+
Be as TokenPill
|
|
286
347
|
};
|
|
@@ -16,6 +16,8 @@ export interface TokenNodeOptions {
|
|
|
16
16
|
getRenderToken: () => (props: TokenRenderProps) => ReactNode;
|
|
17
17
|
/** Plain-text form of a token, for copy and `editor.getText()`. */
|
|
18
18
|
getTokenText: () => (value: string) => string;
|
|
19
|
+
/** Classes for the inline wrapper around each rendered token. */
|
|
20
|
+
getWrapperClassName: () => string;
|
|
19
21
|
}
|
|
20
22
|
declare module "@tiptap/core" {
|
|
21
23
|
interface Commands<ReturnType> {
|
|
@@ -25,6 +27,11 @@ declare module "@tiptap/core" {
|
|
|
25
27
|
};
|
|
26
28
|
}
|
|
27
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Bumped by TokenInput's `reload()`: node views re-render when the data their
|
|
32
|
+
* renderer reads (labels, a catalog) changes, even though the node did not.
|
|
33
|
+
*/
|
|
34
|
+
export declare const TokenRenderVersion: import('react').Context<number>;
|
|
28
35
|
/** Inline atom node holding one token; deleted as a single unit. */
|
|
29
36
|
export declare const TokenNode: Node<TokenNodeOptions, any>;
|
|
30
37
|
//# sourceMappingURL=token-node.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-node.d.ts","sourceRoot":"","sources":["../../../src/rich-text/token-input/token-node.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AAMrD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"token-node.d.ts","sourceRoot":"","sources":["../../../src/rich-text/token-input/token-node.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AAMrD,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,MAAM,WAAW,gBAAgB;IAC/B,qEAAqE;IACrE,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,QAAQ,EAAE,OAAO,CAAC;IAClB,gDAAgD;IAChD,QAAQ,EAAE,OAAO,CAAC;IAClB,4CAA4C;IAC5C,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,gBAAgB;IAC/B,qEAAqE;IACrE,cAAc,EAAE,MAAM,CAAC,KAAK,EAAE,gBAAgB,KAAK,SAAS,CAAC;IAC7D,mEAAmE;IACnE,YAAY,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;IAC9C,iEAAiE;IACjE,mBAAmB,EAAE,MAAM,MAAM,CAAC;CACnC;AAED,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,CAAC,eAAe,CAAC,EAAE;YACjB,wCAAwC;YACxC,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,UAAU,CAAC;SAC5C,CAAC;KACH;CACF;AAED;;;GAGG;AACH,eAAO,MAAM,kBAAkB,iCAAmB,CAAC;AAsCnD,oEAAoE;AACpE,eAAO,MAAM,SAAS,6BAwEpB,CAAC"}
|
|
@@ -1,26 +1,29 @@
|
|
|
1
1
|
import { jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import { Node as p, mergeAttributes as m } from "@tiptap/core";
|
|
3
3
|
import { ReactNodeViewRenderer as c, NodeViewWrapper as f } from "@tiptap/react";
|
|
4
|
+
import { createContext as T, useContext as g } from "react";
|
|
4
5
|
import { TOKEN_NODE_NAME as a } from "./segments.js";
|
|
5
|
-
|
|
6
|
+
const N = T(0);
|
|
7
|
+
function v({
|
|
6
8
|
node: e,
|
|
7
9
|
editor: t,
|
|
8
|
-
getPos:
|
|
10
|
+
getPos: r,
|
|
9
11
|
selected: o,
|
|
10
|
-
extension:
|
|
12
|
+
extension: n
|
|
11
13
|
}) {
|
|
12
|
-
|
|
14
|
+
g(N);
|
|
15
|
+
const i = n.options, u = String(e.attrs.value ?? ""), d = () => {
|
|
13
16
|
if (!t.isEditable) return;
|
|
14
|
-
const
|
|
15
|
-
|
|
17
|
+
const s = typeof r == "function" ? r() : null;
|
|
18
|
+
s != null && t.chain().focus().deleteRange({ from: s, to: s + e.nodeSize }).run();
|
|
16
19
|
};
|
|
17
20
|
return /* @__PURE__ */ l(
|
|
18
21
|
f,
|
|
19
22
|
{
|
|
20
23
|
as: "span",
|
|
21
|
-
className:
|
|
24
|
+
className: i.getWrapperClassName(),
|
|
22
25
|
"data-type": a,
|
|
23
|
-
children:
|
|
26
|
+
children: i.getRenderToken()({
|
|
24
27
|
value: u,
|
|
25
28
|
readOnly: !t.isEditable,
|
|
26
29
|
selected: o,
|
|
@@ -29,7 +32,7 @@ function T({
|
|
|
29
32
|
}
|
|
30
33
|
);
|
|
31
34
|
}
|
|
32
|
-
const
|
|
35
|
+
const C = p.create({
|
|
33
36
|
name: a,
|
|
34
37
|
group: "inline",
|
|
35
38
|
inline: !0,
|
|
@@ -38,7 +41,8 @@ const k = p.create({
|
|
|
38
41
|
addOptions() {
|
|
39
42
|
return {
|
|
40
43
|
getRenderToken: () => () => null,
|
|
41
|
-
getTokenText: () => (e) => e
|
|
44
|
+
getTokenText: () => (e) => e,
|
|
45
|
+
getWrapperClassName: () => "inline-flex align-middle"
|
|
42
46
|
};
|
|
43
47
|
},
|
|
44
48
|
addAttributes() {
|
|
@@ -65,7 +69,7 @@ const k = p.create({
|
|
|
65
69
|
return t ? this.options.getTokenText()(t) : "";
|
|
66
70
|
},
|
|
67
71
|
addNodeView() {
|
|
68
|
-
return c(
|
|
72
|
+
return c(v);
|
|
69
73
|
},
|
|
70
74
|
addCommands() {
|
|
71
75
|
return {
|
|
@@ -76,14 +80,15 @@ const k = p.create({
|
|
|
76
80
|
return {
|
|
77
81
|
// Without this, the first Backspace only selects the atom.
|
|
78
82
|
Backspace: () => this.editor.commands.command(({ state: e, dispatch: t }) => {
|
|
79
|
-
const { $from:
|
|
83
|
+
const { $from: r, empty: o } = e.selection;
|
|
80
84
|
if (!o) return !1;
|
|
81
|
-
const
|
|
82
|
-
return !
|
|
85
|
+
const n = r.nodeBefore;
|
|
86
|
+
return !n || n.type.name !== this.name ? !1 : (t && t(e.tr.delete(r.pos - n.nodeSize, r.pos)), !0);
|
|
83
87
|
})
|
|
84
88
|
};
|
|
85
89
|
}
|
|
86
90
|
});
|
|
87
91
|
export {
|
|
88
|
-
|
|
92
|
+
C as TokenNode,
|
|
93
|
+
N as TokenRenderVersion
|
|
89
94
|
};
|