@pibit.ai/cure-design-system 0.6.50 → 0.6.52
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 +3 -2
- package/dist/_virtual/index2.js +5 -3
- package/dist/_virtual/index3.js +2 -5
- 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/filters/status-filter-dropdown.d.ts.map +1 -1
- package/dist/patterns/filters/status-filter-dropdown.js +73 -65
- package/dist/rich-text/index.d.ts +1 -0
- package/dist/rich-text/index.d.ts.map +1 -1
- package/dist/rich-text/index.js +34 -26
- package/dist/rich-text/token-input/index.d.ts +5 -0
- package/dist/rich-text/token-input/index.d.ts.map +1 -0
- package/dist/rich-text/token-input/segments.d.ts +27 -0
- package/dist/rich-text/token-input/segments.d.ts.map +1 -0
- package/dist/rich-text/token-input/segments.js +48 -0
- package/dist/rich-text/token-input/token-input.d.ts +96 -0
- package/dist/rich-text/token-input/token-input.d.ts.map +1 -0
- package/dist/rich-text/token-input/token-input.js +286 -0
- package/dist/rich-text/token-input/token-node.d.ts +30 -0
- package/dist/rich-text/token-input/token-node.d.ts.map +1 -0
- package/dist/rich-text/token-input/token-node.js +89 -0
- package/dist/rich-text/token-input/token-suggestion.d.ts +37 -0
- package/dist/rich-text/token-input/token-suggestion.d.ts.map +1 -0
- package/dist/rich-text/token-input/token-suggestion.js +110 -0
- package/dist/styles/components.css +1 -1
- package/package.json +1 -1
package/dist/_virtual/index.js
CHANGED
package/dist/_virtual/index2.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { getDefaultExportFromCjs as t } from "./_commonjsHelpers.js";
|
|
2
|
+
import { __require as e } from "../node_modules/eventemitter3/index2.js";
|
|
3
|
+
var r = e();
|
|
4
|
+
const i = /* @__PURE__ */ t(r);
|
|
3
5
|
export {
|
|
4
|
-
|
|
6
|
+
i as default
|
|
5
7
|
};
|
package/dist/_virtual/index3.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import { __require as e } from "../node_modules/eventemitter3/index2.js";
|
|
3
|
-
var r = e();
|
|
4
|
-
const i = /* @__PURE__ */ t(r);
|
|
1
|
+
var e = { exports: {} };
|
|
5
2
|
export {
|
|
6
|
-
|
|
3
|
+
e as __module
|
|
7
4
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Children as p } from "react";
|
|
2
|
-
import { r as y } from "../../../../_virtual/
|
|
2
|
+
import { r as y } from "../../../../_virtual/index.js";
|
|
3
3
|
import { isNullish as m } from "./DataUtils.js";
|
|
4
4
|
import { get as f } from "../../../es-toolkit/dist/compat/object/get.js";
|
|
5
5
|
var u = (r) => typeof r == "string" ? r : r ? r.displayName || r.name || "Component" : "", l = null, n = null, o = (r) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __module as r } from "../../../_virtual/
|
|
1
|
+
import { __module as r } from "../../../_virtual/index4.js";
|
|
2
2
|
import { __require as o } from "../cjs/use-sync-external-store-shim.production.js";
|
|
3
3
|
import { __require as i } from "../cjs/use-sync-external-store-shim.development.js";
|
|
4
4
|
var e;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"status-filter-dropdown.d.ts","sourceRoot":"","sources":["../../../src/patterns/filters/status-filter-dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"status-filter-dropdown.d.ts","sourceRoot":"","sources":["../../../src/patterns/filters/status-filter-dropdown.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAqC,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AAiBnE,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,OAAO,CAAC;IACb,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,KAAK,uBAAuB,GAAG;IAC7B,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;IACxC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,yFAAyF;IACzF,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,yFAAyF;IACzF,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,KAAK,iCAAiC,GAAG,uBAAuB,GAAG;IACjE,aAAa,CAAC,EAAE,UAAU,CAAC;IAC3B,aAAa,EAAE,aAAa,CAAC;IAC7B,oBAAoB,EAAE,aAAa,CAAC;IACpC,cAAc,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,aAAa,EAAE,kBAAkB,EAAE,CAAC;IACpC,2GAA2G;IAC3G,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,KAAK,+BAA+B,GAAG,uBAAuB,GAAG;IAC/D,aAAa,EAAE,QAAQ,CAAC;IACxB,OAAO,EAAE,kBAAkB,EAAE,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,iGAAiG;IACjG,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GACjC,iCAAiC,GACjC,+BAA+B,CAAC;AAqBpC,eAAO,MAAM,oBAAoB,EAAE,EAAE,CAAC,yBAAyB,CA0Q9D,CAAC"}
|
|
@@ -1,72 +1,80 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { ChevronDown as
|
|
4
|
-
import { cx as
|
|
1
|
+
import { jsx as n, jsxs as s, Fragment as q } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as S, useState as I, useLayoutEffect as D } from "react";
|
|
3
|
+
import { ChevronDown as P, MinusSquare as $ } from "@untitledui/icons";
|
|
4
|
+
import { cx as U } from "../../utils/cn.js";
|
|
5
5
|
import { Dropdown as p } from "../../primitives/dropdown/dropdown.js";
|
|
6
6
|
import { Button as y } from "../../primitives/button/button.js";
|
|
7
|
-
import { RadioButtonBase as
|
|
8
|
-
import {
|
|
9
|
-
|
|
7
|
+
import { RadioButtonBase as W } from "../../primitives/radio/radio.js";
|
|
8
|
+
import { EllipsisContentWithTooltip as G } from "../../primitives/tooltip/ellipsis-content.js";
|
|
9
|
+
import { CheckboxBase as J } from "../../primitives/checkbox/checkbox.js";
|
|
10
|
+
const N = ({ isSelected: t }) => /* @__PURE__ */ n("div", { className: "pointer-events-none", "aria-hidden": !0, children: /* @__PURE__ */ n(J, { isSelected: t }) }), A = ({ label: t }) => /* @__PURE__ */ n(
|
|
11
|
+
G,
|
|
12
|
+
{
|
|
13
|
+
content: t,
|
|
14
|
+
className: "min-w-0 flex-1",
|
|
15
|
+
tooltipClassName: "z-[100001]"
|
|
16
|
+
}
|
|
17
|
+
), oe = (t) => {
|
|
10
18
|
const {
|
|
11
19
|
isOpen: u,
|
|
12
|
-
onOpenChange:
|
|
13
|
-
onApply:
|
|
14
|
-
onReset:
|
|
15
|
-
className:
|
|
20
|
+
onOpenChange: F,
|
|
21
|
+
onApply: R,
|
|
22
|
+
onReset: V,
|
|
23
|
+
className: z,
|
|
16
24
|
buttonLabel: d = "Status",
|
|
17
25
|
isDisabled: M = !1,
|
|
18
|
-
isApplyDisabled:
|
|
19
|
-
isResetDisabled:
|
|
26
|
+
isApplyDisabled: T,
|
|
27
|
+
isResetDisabled: E
|
|
20
28
|
} = t, i = t.selectionMode === "single", o = i ? t.options : t.statusOptions, a = (o == null ? void 0 : o.length) ?? 0, f = i ? 0 : Object.entries(t.appliedStatusFilters).filter(
|
|
21
|
-
([e,
|
|
22
|
-
).length,
|
|
29
|
+
([e, l]) => e !== "all" && l
|
|
30
|
+
).length, L = !i && t.defaultSelectAll === !0, H = (() => {
|
|
23
31
|
if (i) {
|
|
24
32
|
const e = t.defaultValue ?? "all";
|
|
25
33
|
return t.value !== e;
|
|
26
34
|
}
|
|
27
|
-
return a === 0 ? !1 :
|
|
35
|
+
return a === 0 ? !1 : L ? f < a : f > 0;
|
|
28
36
|
})(), m = i ? 0 : Object.entries(t.statusFilters).filter(
|
|
29
|
-
([e,
|
|
30
|
-
).length,
|
|
31
|
-
var
|
|
37
|
+
([e, l]) => e !== "all" && l
|
|
38
|
+
).length, b = m === a && a > 0, g = m > 0 && m < a, O = (() => {
|
|
39
|
+
var l;
|
|
32
40
|
if (!i)
|
|
33
41
|
return !(f === a && a > 0) && f > 0 ? `${d} ${f} selected` : d;
|
|
34
42
|
const e = t.defaultValue ?? "all";
|
|
35
|
-
return t.value === e ? d : ((
|
|
36
|
-
})(), h =
|
|
43
|
+
return t.value === e ? d : ((l = o.find((c) => c.key === t.value)) == null ? void 0 : l.label) ?? d;
|
|
44
|
+
})(), h = S(null), v = S(0), [j, B] = I(
|
|
37
45
|
() => typeof window > "u" ? 400 : Math.round(window.innerHeight * 0.5)
|
|
38
|
-
),
|
|
46
|
+
), K = i ? t.pendingValue : t.statusFilters;
|
|
39
47
|
return D(() => {
|
|
40
48
|
if (!u) return;
|
|
41
49
|
const e = () => {
|
|
42
|
-
|
|
50
|
+
B(Math.round(window.innerHeight * 0.5));
|
|
43
51
|
};
|
|
44
52
|
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
45
53
|
}, [u]), D(() => {
|
|
46
54
|
const e = () => {
|
|
47
|
-
h.current && (h.current.scrollTop =
|
|
55
|
+
h.current && (h.current.scrollTop = v.current);
|
|
48
56
|
};
|
|
49
57
|
e();
|
|
50
|
-
const
|
|
51
|
-
return () => cancelAnimationFrame(
|
|
52
|
-
}, [
|
|
53
|
-
/* @__PURE__ */
|
|
58
|
+
const l = requestAnimationFrame(e);
|
|
59
|
+
return () => cancelAnimationFrame(l);
|
|
60
|
+
}, [K]), /* @__PURE__ */ n("div", { className: "relative", children: /* @__PURE__ */ s(p.Root, { isOpen: u, onOpenChange: F, children: [
|
|
61
|
+
/* @__PURE__ */ n(
|
|
54
62
|
y,
|
|
55
63
|
{
|
|
56
64
|
size: "xs",
|
|
57
65
|
color: "secondary",
|
|
58
|
-
iconTrailing: /* @__PURE__ */
|
|
59
|
-
className:
|
|
66
|
+
iconTrailing: /* @__PURE__ */ n(P, { size: 12 }),
|
|
67
|
+
className: U(
|
|
60
68
|
"relative",
|
|
61
69
|
H && !u && "ring-1 ring-brand-600 bg-brand-primary text-brand-600 hover:bg-brand-primary hover:text-brand-600",
|
|
62
|
-
|
|
70
|
+
z,
|
|
63
71
|
u && "shadow-[0_0_0_4px_rgba(102,112,133,0.14)]"
|
|
64
72
|
),
|
|
65
73
|
isDisabled: M,
|
|
66
|
-
children:
|
|
74
|
+
children: O
|
|
67
75
|
}
|
|
68
76
|
),
|
|
69
|
-
/* @__PURE__ */
|
|
77
|
+
/* @__PURE__ */ n(
|
|
70
78
|
p.Popover,
|
|
71
79
|
{
|
|
72
80
|
className: "overflow-hidden",
|
|
@@ -74,59 +82,59 @@ const N = ({ isSelected: t }) => /* @__PURE__ */ l("div", { className: "pointer-
|
|
|
74
82
|
maxHeight: j,
|
|
75
83
|
scrollRef: h,
|
|
76
84
|
children: /* @__PURE__ */ s("div", { className: "flex max-h-[50vh] flex-col overflow-hidden text-secondary text-xs", children: [
|
|
77
|
-
/* @__PURE__ */
|
|
85
|
+
/* @__PURE__ */ n(
|
|
78
86
|
"div",
|
|
79
87
|
{
|
|
80
88
|
ref: h,
|
|
81
|
-
className: "min-h-0 flex-1 space-y-3 overflow-y-auto p-3",
|
|
89
|
+
className: "min-h-0 flex-1 space-y-3 overflow-x-hidden overflow-y-auto p-3",
|
|
82
90
|
role: i ? "radiogroup" : void 0,
|
|
83
91
|
"aria-label": i ? d : void 0,
|
|
84
92
|
onScroll: (e) => {
|
|
85
|
-
|
|
93
|
+
v.current = e.currentTarget.scrollTop;
|
|
86
94
|
},
|
|
87
|
-
children: i ? o.map((e,
|
|
88
|
-
const c = t.pendingValue === e.key,
|
|
95
|
+
children: i ? o.map((e, l) => {
|
|
96
|
+
const c = t.pendingValue === e.key, _ = o.some((r) => r.key === t.pendingValue);
|
|
89
97
|
return /* @__PURE__ */ s(
|
|
90
98
|
"div",
|
|
91
99
|
{
|
|
92
100
|
role: "radio",
|
|
93
101
|
"aria-checked": c,
|
|
94
|
-
tabIndex: c || !
|
|
102
|
+
tabIndex: c || !_ && l === 0 ? 0 : -1,
|
|
95
103
|
className: "flex cursor-pointer items-center gap-3 rounded-sm outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring",
|
|
96
104
|
onMouseDownCapture: (r) => r.preventDefault(),
|
|
97
105
|
onClick: () => t.onValueChange(e.key),
|
|
98
106
|
onKeyDown: (r) => {
|
|
99
|
-
var w,
|
|
107
|
+
var w, C;
|
|
100
108
|
if (r.key === "Enter" || r.key === " ") {
|
|
101
109
|
r.preventDefault(), t.onValueChange(e.key);
|
|
102
110
|
return;
|
|
103
111
|
}
|
|
104
|
-
const
|
|
105
|
-
if (!
|
|
112
|
+
const k = r.key === "ArrowDown" || r.key === "ArrowRight" ? 1 : r.key === "ArrowUp" || r.key === "ArrowLeft" ? -1 : 0;
|
|
113
|
+
if (!k) return;
|
|
106
114
|
r.preventDefault();
|
|
107
|
-
const x = (
|
|
108
|
-
t.onValueChange(o[x].key), (
|
|
115
|
+
const x = (l + k + o.length) % o.length;
|
|
116
|
+
t.onValueChange(o[x].key), (C = (w = h.current) == null ? void 0 : w.querySelectorAll('[role="radio"]')[x]) == null || C.focus();
|
|
109
117
|
},
|
|
110
118
|
children: [
|
|
111
|
-
/* @__PURE__ */
|
|
112
|
-
|
|
119
|
+
/* @__PURE__ */ n("div", { className: "pointer-events-none", children: /* @__PURE__ */ n(
|
|
120
|
+
W,
|
|
113
121
|
{
|
|
114
122
|
size: "sm",
|
|
115
123
|
isSelected: c,
|
|
116
124
|
"aria-hidden": !0
|
|
117
125
|
}
|
|
118
126
|
) }),
|
|
119
|
-
/* @__PURE__ */
|
|
127
|
+
/* @__PURE__ */ n(A, { label: e.label })
|
|
120
128
|
]
|
|
121
129
|
},
|
|
122
130
|
e.key
|
|
123
131
|
);
|
|
124
|
-
}) : /* @__PURE__ */ s(
|
|
132
|
+
}) : /* @__PURE__ */ s(q, { children: [
|
|
125
133
|
/* @__PURE__ */ s(
|
|
126
134
|
"div",
|
|
127
135
|
{
|
|
128
136
|
role: "checkbox",
|
|
129
|
-
"aria-checked":
|
|
137
|
+
"aria-checked": g ? "mixed" : b,
|
|
130
138
|
tabIndex: 0,
|
|
131
139
|
className: "flex cursor-pointer items-center gap-3 rounded-sm outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring",
|
|
132
140
|
onMouseDownCapture: (e) => e.preventDefault(),
|
|
@@ -135,15 +143,15 @@ const N = ({ isSelected: t }) => /* @__PURE__ */ l("div", { className: "pointer-
|
|
|
135
143
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), t.onStatusChange("all"));
|
|
136
144
|
},
|
|
137
145
|
children: [
|
|
138
|
-
|
|
139
|
-
|
|
146
|
+
g ? /* @__PURE__ */ n(
|
|
147
|
+
$,
|
|
140
148
|
{
|
|
141
149
|
size: 18,
|
|
142
150
|
className: "text-utility-brand-600",
|
|
143
151
|
"aria-hidden": !0
|
|
144
152
|
}
|
|
145
|
-
) : /* @__PURE__ */
|
|
146
|
-
/* @__PURE__ */
|
|
153
|
+
) : /* @__PURE__ */ n(N, { isSelected: b }),
|
|
154
|
+
/* @__PURE__ */ n("span", { children: "All" })
|
|
147
155
|
]
|
|
148
156
|
}
|
|
149
157
|
),
|
|
@@ -154,19 +162,19 @@ const N = ({ isSelected: t }) => /* @__PURE__ */ l("div", { className: "pointer-
|
|
|
154
162
|
"aria-checked": t.statusFilters[e.key],
|
|
155
163
|
tabIndex: 0,
|
|
156
164
|
className: "flex cursor-pointer items-center gap-3 rounded-sm outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-ring",
|
|
157
|
-
onMouseDownCapture: (
|
|
165
|
+
onMouseDownCapture: (l) => l.preventDefault(),
|
|
158
166
|
onClick: () => t.onStatusChange(e.key),
|
|
159
|
-
onKeyDown: (
|
|
160
|
-
(
|
|
167
|
+
onKeyDown: (l) => {
|
|
168
|
+
(l.key === "Enter" || l.key === " ") && (l.preventDefault(), t.onStatusChange(e.key));
|
|
161
169
|
},
|
|
162
170
|
children: [
|
|
163
|
-
/* @__PURE__ */
|
|
171
|
+
/* @__PURE__ */ n(
|
|
164
172
|
N,
|
|
165
173
|
{
|
|
166
174
|
isSelected: t.statusFilters[e.key]
|
|
167
175
|
}
|
|
168
176
|
),
|
|
169
|
-
/* @__PURE__ */
|
|
177
|
+
/* @__PURE__ */ n(A, { label: e.label })
|
|
170
178
|
]
|
|
171
179
|
},
|
|
172
180
|
e.key
|
|
@@ -175,25 +183,25 @@ const N = ({ isSelected: t }) => /* @__PURE__ */ l("div", { className: "pointer-
|
|
|
175
183
|
}
|
|
176
184
|
),
|
|
177
185
|
/* @__PURE__ */ s("div", { className: "flex shrink-0 justify-end gap-2 bg-primary p-3", children: [
|
|
178
|
-
/* @__PURE__ */
|
|
186
|
+
/* @__PURE__ */ n(
|
|
179
187
|
y,
|
|
180
188
|
{
|
|
181
189
|
size: "xs",
|
|
182
190
|
color: "secondary",
|
|
183
191
|
className: "flex-1 p-2",
|
|
184
|
-
onClick:
|
|
185
|
-
isDisabled:
|
|
192
|
+
onClick: V,
|
|
193
|
+
isDisabled: E,
|
|
186
194
|
children: "Reset"
|
|
187
195
|
}
|
|
188
196
|
),
|
|
189
|
-
/* @__PURE__ */
|
|
197
|
+
/* @__PURE__ */ n(
|
|
190
198
|
y,
|
|
191
199
|
{
|
|
192
200
|
size: "xs",
|
|
193
201
|
color: "primary",
|
|
194
202
|
className: "flex-1 p-2",
|
|
195
|
-
onClick:
|
|
196
|
-
isDisabled:
|
|
203
|
+
onClick: R,
|
|
204
|
+
isDisabled: T,
|
|
197
205
|
children: "Apply"
|
|
198
206
|
}
|
|
199
207
|
)
|
|
@@ -204,5 +212,5 @@ const N = ({ isSelected: t }) => /* @__PURE__ */ l("div", { className: "pointer-
|
|
|
204
212
|
] }) });
|
|
205
213
|
};
|
|
206
214
|
export {
|
|
207
|
-
|
|
215
|
+
oe as StatusFilterDropdown
|
|
208
216
|
};
|
|
@@ -14,4 +14,5 @@ export { MentionList, createMentionSuggestion, type MentionUser, } from './text-
|
|
|
14
14
|
export { CharacterCount } from './text-editor-character-count';
|
|
15
15
|
export { isStrikethroughShortcut } from './text-editor-shortcuts';
|
|
16
16
|
export { getPlatformShortcutLabel, isMacPlatform } from './platform';
|
|
17
|
+
export * from './token-input';
|
|
17
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rich-text/index.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,mBAAmB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,EAClB,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,KAAK,WAAW,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rich-text/index.ts"],"names":[],"mappings":"AASA;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,mBAAmB,CAAC;AAExD,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,GAChC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,wBAAwB,EACxB,kBAAkB,EAClB,wBAAwB,EACxB,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,EAC3B,uBAAuB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,KAAK,WAAW,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACrE,cAAc,eAAe,CAAC"}
|
package/dist/rich-text/index.js
CHANGED
|
@@ -1,40 +1,48 @@
|
|
|
1
|
-
import { RichTextEditor as r, useRichTextEditorContext as
|
|
1
|
+
import { RichTextEditor as r, useRichTextEditorContext as i } from "./text-editor.js";
|
|
2
2
|
import { RichTextEditorToolbar as c } from "./text-editor-toolbar.js";
|
|
3
|
-
import { RichTextEditorTooltip as
|
|
4
|
-
import { RichTextEditorAlignCenter as
|
|
5
|
-
import { EditorButton as
|
|
6
|
-
import { MentionList as M, createMentionSuggestion as
|
|
7
|
-
import { CharacterCount as
|
|
8
|
-
import { isStrikethroughShortcut as
|
|
3
|
+
import { RichTextEditorTooltip as h } from "./text-editor-tooltip.js";
|
|
4
|
+
import { RichTextEditorAlignCenter as n, RichTextEditorAlignLeft as E, RichTextEditorBlockquote as R, RichTextEditorBold as m, RichTextEditorBulletList as l, RichTextEditorColor as f, RichTextEditorFontFamily as p, RichTextEditorFontSize as a, RichTextEditorGenerate as g, RichTextEditorHeading as s, RichTextEditorImage as u, RichTextEditorItalic as S, RichTextEditorLink as C, RichTextEditorOrderedList as L, RichTextEditorStrikethrough as k, RichTextEditorUnderline as B } from "./text-editor-extensions.js";
|
|
5
|
+
import { EditorButton as A } from "./text-editor-button.js";
|
|
6
|
+
import { MentionList as M, createMentionSuggestion as P } from "./text-editor-mention.js";
|
|
7
|
+
import { CharacterCount as b } from "./text-editor-character-count.js";
|
|
8
|
+
import { isStrikethroughShortcut as N } from "./text-editor-shortcuts.js";
|
|
9
9
|
import { getPlatformShortcutLabel as q, isMacPlatform as y } from "./platform.js";
|
|
10
|
+
import { TokenInput as D, TokenPill as G } from "./token-input/token-input.js";
|
|
11
|
+
import { TokenSuggestionList as X } from "./token-input/token-suggestion.js";
|
|
12
|
+
import { docToSegments as v, segmentsToDoc as w } from "./token-input/segments.js";
|
|
10
13
|
const t = "cure-rich-text";
|
|
11
14
|
export {
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
b as CharacterCount,
|
|
16
|
+
A as EditorButton,
|
|
14
17
|
M as MentionList,
|
|
15
18
|
t as RICH_TEXT_CONTENT_CLASS,
|
|
16
19
|
r as RichTextEditor,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
n as RichTextEditorAlignCenter,
|
|
21
|
+
E as RichTextEditorAlignLeft,
|
|
22
|
+
R as RichTextEditorBlockquote,
|
|
23
|
+
m as RichTextEditorBold,
|
|
24
|
+
l as RichTextEditorBulletList,
|
|
25
|
+
f as RichTextEditorColor,
|
|
26
|
+
p as RichTextEditorFontFamily,
|
|
27
|
+
a as RichTextEditorFontSize,
|
|
28
|
+
g as RichTextEditorGenerate,
|
|
29
|
+
s as RichTextEditorHeading,
|
|
30
|
+
u as RichTextEditorImage,
|
|
31
|
+
S as RichTextEditorItalic,
|
|
32
|
+
C as RichTextEditorLink,
|
|
30
33
|
L as RichTextEditorOrderedList,
|
|
31
34
|
k as RichTextEditorStrikethrough,
|
|
32
35
|
c as RichTextEditorToolbar,
|
|
33
|
-
|
|
36
|
+
h as RichTextEditorTooltip,
|
|
34
37
|
B as RichTextEditorUnderline,
|
|
35
|
-
|
|
38
|
+
D as TokenInput,
|
|
39
|
+
G as TokenPill,
|
|
40
|
+
X as TokenSuggestionList,
|
|
41
|
+
P as createMentionSuggestion,
|
|
42
|
+
v as docToSegments,
|
|
36
43
|
q as getPlatformShortcutLabel,
|
|
37
44
|
y as isMacPlatform,
|
|
38
|
-
|
|
39
|
-
|
|
45
|
+
N as isStrikethroughShortcut,
|
|
46
|
+
w as segmentsToDoc,
|
|
47
|
+
i as useRichTextEditorContext
|
|
40
48
|
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { TokenInput, TokenPill, type TokenDisplay, type TokenInputHandle, type TokenInputProps, type TokenTextContext, } from './token-input';
|
|
2
|
+
export type { TokenRenderProps } from './token-node';
|
|
3
|
+
export { TokenSuggestionList, type TokenSuggestionItem, type TokenSuggestionTrigger, } from './token-suggestion';
|
|
4
|
+
export { docToSegments, segmentsToDoc, type TokenInputSegment, } from './segments';
|
|
5
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/rich-text/token-input/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EACL,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,sBAAsB,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,aAAa,EACb,aAAa,EACb,KAAK,iBAAiB,GACvB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { JSONContent } from '@tiptap/core';
|
|
2
|
+
import { Node as ProseMirrorNode } from '@tiptap/pm/model';
|
|
3
|
+
/**
|
|
4
|
+
* The app-facing shape of a TokenInput value. Consumers map their stored
|
|
5
|
+
* format (formula, `{{field}}` reference, `{variable}` …) to and from these
|
|
6
|
+
* segments with `parse` / `serialize`; the editor never sees the raw format.
|
|
7
|
+
*/
|
|
8
|
+
export type TokenInputSegment = {
|
|
9
|
+
type: "text";
|
|
10
|
+
text: string;
|
|
11
|
+
} | {
|
|
12
|
+
type: "token";
|
|
13
|
+
value: string;
|
|
14
|
+
} | {
|
|
15
|
+
type: "newline";
|
|
16
|
+
};
|
|
17
|
+
export declare const TOKEN_NODE_NAME = "token";
|
|
18
|
+
/** Segments → editor document: each newline segment starts a new paragraph. */
|
|
19
|
+
export declare function segmentsToDoc(segments: TokenInputSegment[]): JSONContent;
|
|
20
|
+
/** Editor document → segments: paragraphs are joined by newline segments. */
|
|
21
|
+
export declare function docToSegments(doc: JSONContent): TokenInputSegment[];
|
|
22
|
+
/**
|
|
23
|
+
* Plain text for a document range, tokens rendered with `tokenText` — used for
|
|
24
|
+
* copy/cut so a paste can rebuild the tokens.
|
|
25
|
+
*/
|
|
26
|
+
export declare function rangeToText(doc: ProseMirrorNode, from: number, to: number, tokenText: (value: string) => string): string;
|
|
27
|
+
//# sourceMappingURL=segments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segments.d.ts","sourceRoot":"","sources":["../../../src/rich-text/token-input/segments.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEhE;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,GACzB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAChC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAC;AAExB,eAAO,MAAM,eAAe,UAAU,CAAC;AAEvC,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,QAAQ,EAAE,iBAAiB,EAAE,GAAG,WAAW,CA0BxE;AAcD,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,GAAG,EAAE,WAAW,GAAG,iBAAiB,EAAE,CAQnE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,eAAe,EACpB,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,GACnC,MAAM,CAQR"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const a = "token";
|
|
2
|
+
function i(t) {
|
|
3
|
+
const e = [[]];
|
|
4
|
+
for (const n of t)
|
|
5
|
+
n.type === "newline" ? e.push([]) : n.type === "text" ? n.text && e[e.length - 1].push({
|
|
6
|
+
type: "text",
|
|
7
|
+
text: n.text
|
|
8
|
+
}) : n.value && e[e.length - 1].push({
|
|
9
|
+
type: a,
|
|
10
|
+
attrs: { value: n.value }
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
type: "doc",
|
|
14
|
+
content: e.map((n) => ({
|
|
15
|
+
type: "paragraph",
|
|
16
|
+
content: n.length ? n : void 0
|
|
17
|
+
}))
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function s(t, e) {
|
|
21
|
+
var n;
|
|
22
|
+
if (t.type === "text" && t.text)
|
|
23
|
+
e.push({ type: "text", text: t.text });
|
|
24
|
+
else if (t.type === a && ((n = t.attrs) != null && n.value))
|
|
25
|
+
e.push({ type: "token", value: String(t.attrs.value) });
|
|
26
|
+
else if (t.type === "hardBreak")
|
|
27
|
+
e.push({ type: "newline" });
|
|
28
|
+
else if (t.content)
|
|
29
|
+
for (const r of t.content) s(r, e);
|
|
30
|
+
}
|
|
31
|
+
function u(t) {
|
|
32
|
+
if (!t || t.type !== "doc" || !t.content) return [];
|
|
33
|
+
const e = [];
|
|
34
|
+
return t.content.forEach((n, r) => {
|
|
35
|
+
r > 0 && e.push({ type: "newline" }), s(n, e);
|
|
36
|
+
}), e;
|
|
37
|
+
}
|
|
38
|
+
function f(t, e, n, r) {
|
|
39
|
+
return t.textBetween(e, n, `
|
|
40
|
+
`, (p) => p.type.name === a && p.attrs.value ? r(String(p.attrs.value)) : p.type.name === "hardBreak" ? `
|
|
41
|
+
` : "");
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
a as TOKEN_NODE_NAME,
|
|
45
|
+
u as docToSegments,
|
|
46
|
+
f as rangeToText,
|
|
47
|
+
i as segmentsToDoc
|
|
48
|
+
};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { AnyExtension } from '@tiptap/core';
|
|
3
|
+
import { EditorView } from '@tiptap/pm/view';
|
|
4
|
+
import { Editor } from '@tiptap/react';
|
|
5
|
+
import { TokenInputSegment } from './segments';
|
|
6
|
+
import { TokenRenderProps } from './token-node';
|
|
7
|
+
import { TokenSuggestionTrigger } from './token-suggestion';
|
|
8
|
+
export interface TokenDisplay {
|
|
9
|
+
label: string;
|
|
10
|
+
icon?: ReactNode;
|
|
11
|
+
/** @default "neutral" */
|
|
12
|
+
tone?: "neutral" | "brand" | "error";
|
|
13
|
+
}
|
|
14
|
+
export interface TokenTextContext {
|
|
15
|
+
/** Whole document text, tokens excluded. */
|
|
16
|
+
docText: string;
|
|
17
|
+
/** Document text before the insertion point, tokens excluded. */
|
|
18
|
+
textBefore: string;
|
|
19
|
+
/** The full typed or pasted chunk this text came from. */
|
|
20
|
+
raw: string;
|
|
21
|
+
}
|
|
22
|
+
export interface TokenInputHandle {
|
|
23
|
+
/** The Tiptap editor, once mounted. */
|
|
24
|
+
editor: Editor | null;
|
|
25
|
+
/** Inserts a token at the selection and focuses the editor. */
|
|
26
|
+
insertToken: (value: string) => void;
|
|
27
|
+
focus: () => void;
|
|
28
|
+
/** The current value in the app's stored format. */
|
|
29
|
+
getValue: () => string;
|
|
30
|
+
}
|
|
31
|
+
export interface TokenInputProps {
|
|
32
|
+
value: string;
|
|
33
|
+
onChange: (value: string) => void;
|
|
34
|
+
/** Stored value → segments. */
|
|
35
|
+
parse: (value: string) => TokenInputSegment[];
|
|
36
|
+
/** Segments → stored value. Must round-trip `parse`. */
|
|
37
|
+
serialize: (segments: TokenInputSegment[]) => string;
|
|
38
|
+
/** Renders a token. Defaults to a DS pill built from `getTokenDisplay`. */
|
|
39
|
+
renderToken?: (props: TokenRenderProps) => ReactNode;
|
|
40
|
+
/** Label, icon and tone for the default pill. @default the raw value */
|
|
41
|
+
getTokenDisplay?: (value: string) => TokenDisplay;
|
|
42
|
+
/** Menus opened by trigger characters such as "/", "{{" or "@". */
|
|
43
|
+
suggestions?: TokenSuggestionTrigger[];
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
readOnly?: boolean;
|
|
46
|
+
isInvalid?: boolean;
|
|
47
|
+
/** Enter inserts a new line. Off: single-line, Enter is ignored. */
|
|
48
|
+
allowNewlines?: boolean;
|
|
49
|
+
/** Keep line breaks in pasted text. @default allowNewlines */
|
|
50
|
+
preservePastedNewlines?: boolean;
|
|
51
|
+
/** Rebuild tokens from pasted text via `parse`. @default true */
|
|
52
|
+
tokenPaste?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Filters typed and pasted text before it enters the document; return ""
|
|
55
|
+
* to drop the input. Tokens are never filtered.
|
|
56
|
+
*/
|
|
57
|
+
filterTextInput?: (text: string, context: TokenTextContext) => string;
|
|
58
|
+
/** Runs before TokenInput's own key handling; return true to stop it. */
|
|
59
|
+
onKeyDownCapture?: (view: EditorView, event: KeyboardEvent) => boolean;
|
|
60
|
+
/** Runs after TokenInput's own key handling; return true when handled. */
|
|
61
|
+
onKeyDown?: (view: EditorView, event: KeyboardEvent) => boolean;
|
|
62
|
+
onFocus?: (event: FocusEvent) => void;
|
|
63
|
+
onBlur?: (event: FocusEvent) => void;
|
|
64
|
+
/** Extra Tiptap extensions. Read once, when the editor is created. */
|
|
65
|
+
extensions?: AnyExtension[];
|
|
66
|
+
/** Called once the editor exists (and with null on unmount). */
|
|
67
|
+
onEditorChange?: (editor: Editor | null) => void;
|
|
68
|
+
/**
|
|
69
|
+
* Render the DS input frame (border, focus ring, invalid state). Off: only
|
|
70
|
+
* the editable surface, for hosts that draw their own frame.
|
|
71
|
+
* @default true
|
|
72
|
+
*/
|
|
73
|
+
chrome?: boolean;
|
|
74
|
+
/** Frame classes (with `chrome`). */
|
|
75
|
+
className?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Classes for the editor surface (Tiptap's EditorContent). Replaces the
|
|
78
|
+
* default surface classes (paragraph margin, placeholder) entirely.
|
|
79
|
+
*/
|
|
80
|
+
contentClassName?: string;
|
|
81
|
+
/** Attributes for the ProseMirror element. Read once, at creation. */
|
|
82
|
+
contentAttributes?: {
|
|
83
|
+
class?: string;
|
|
84
|
+
style?: string;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export declare function TokenPill({ label, icon, tone, selected, }: TokenDisplay & {
|
|
88
|
+
selected?: boolean;
|
|
89
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
90
|
+
/**
|
|
91
|
+
* Text input where some content is an inline token rendered as a pill, with
|
|
92
|
+
* tokens inserted from a trigger-character menu or by the host (`insertToken`).
|
|
93
|
+
* The stored format belongs to the app through `parse` / `serialize`.
|
|
94
|
+
*/
|
|
95
|
+
export declare const TokenInput: import('react').ForwardRefExoticComponent<TokenInputProps & import('react').RefAttributes<TokenInputHandle>>;
|
|
96
|
+
//# sourceMappingURL=token-input.d.ts.map
|