@pibit.ai/cure-design-system 0.6.51 → 0.6.53
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/patterns/filters/status-filter-dropdown.d.ts.map +1 -1
- package/dist/patterns/filters/status-filter-dropdown.js +73 -65
- 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 +28 -3
- package/dist/rich-text/token-input/token-suggestion.d.ts.map +1 -1
- package/dist/rich-text/token-input/token-suggestion.js +86 -63
- package/dist/styles/components.css +1 -1
- package/package.json +1 -1
|
@@ -1,23 +1,48 @@
|
|
|
1
|
-
import { Extension } from '@tiptap/core';
|
|
1
|
+
import { Extension, Range } from '@tiptap/core';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
3
|
export interface TokenSuggestionItem {
|
|
4
4
|
/** Inserted as the token's value. */
|
|
5
5
|
value: string;
|
|
6
6
|
label: string;
|
|
7
|
+
/** Second line under the label. */
|
|
7
8
|
description?: string;
|
|
9
|
+
/** Muted text after the label on the same line, e.g. the stored token. */
|
|
10
|
+
hint?: string;
|
|
8
11
|
icon?: ReactNode;
|
|
9
12
|
}
|
|
13
|
+
/** What a headless trigger reports while its query is active. */
|
|
14
|
+
export interface TokenSuggestionState {
|
|
15
|
+
/** Text typed after the trigger. */
|
|
16
|
+
query: string;
|
|
17
|
+
/** Document range of the trigger plus query. */
|
|
18
|
+
range: Range;
|
|
19
|
+
/** The decorated trigger element, for anchoring a popover. */
|
|
20
|
+
decorationNode: Element | null;
|
|
21
|
+
clientRect: (() => DOMRect | null) | null;
|
|
22
|
+
/** Replaces the trigger and query with a token. */
|
|
23
|
+
insertToken: (value: string) => void;
|
|
24
|
+
}
|
|
10
25
|
export interface TokenSuggestionTrigger {
|
|
11
26
|
/** Character(s) that open the menu, e.g. "/", "{{" or "@". */
|
|
12
27
|
char: string;
|
|
13
28
|
/** Items for the text typed after the trigger; filter as you see fit. */
|
|
14
|
-
items
|
|
29
|
+
items?: (query: string) => TokenSuggestionItem[] | Promise<TokenSuggestionItem[]>;
|
|
15
30
|
/** Let the query contain spaces. @default false */
|
|
16
31
|
allowSpaces?: boolean;
|
|
17
32
|
/** Characters allowed right before the trigger. @default [" "] plus line start */
|
|
18
33
|
allowedPrefixes?: string[] | null;
|
|
19
34
|
/** Message when nothing matches. @default "No matches" */
|
|
20
35
|
emptyMessage?: string;
|
|
36
|
+
/** Text inserted after the chosen token, e.g. " ". */
|
|
37
|
+
appendText?: string;
|
|
38
|
+
/** Class on the decorated trigger + query while active. */
|
|
39
|
+
decorationClass?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Headless mode: the app renders its own picker. Called with the state while
|
|
42
|
+
* the trigger is active and with null when it ends. Handle the picker's
|
|
43
|
+
* keys in TokenInput's `onKeyDownCapture`; Escape still closes it.
|
|
44
|
+
*/
|
|
45
|
+
onStateChange?: (state: TokenSuggestionState | null) => void;
|
|
21
46
|
}
|
|
22
47
|
interface ListProps {
|
|
23
48
|
items: TokenSuggestionItem[];
|
|
@@ -30,7 +55,7 @@ export interface TokenSuggestionListHandle {
|
|
|
30
55
|
export declare const TokenSuggestionList: import('react').ForwardRefExoticComponent<ListProps & import('react').RefAttributes<TokenSuggestionListHandle>>;
|
|
31
56
|
/**
|
|
32
57
|
* One Suggestion plugin per trigger. `onOpenChange` reports whether any menu is
|
|
33
|
-
*
|
|
58
|
+
* active, so TokenInput lets Enter through to it in single-line fields.
|
|
34
59
|
*/
|
|
35
60
|
export declare function createTokenSuggestionExtension(triggers: TokenSuggestionTrigger[], onOpenChange: (open: boolean) => void): Extension<any, any>;
|
|
36
61
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-suggestion.d.ts","sourceRoot":"","sources":["../../../src/rich-text/token-input/token-suggestion.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"token-suggestion.d.ts","sourceRoot":"","sources":["../../../src/rich-text/token-input/token-suggestion.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAQrD,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,iEAAiE;AACjE,MAAM,WAAW,oBAAoB;IACnC,oCAAoC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,KAAK,EAAE,KAAK,CAAC;IACb,8DAA8D;IAC9D,cAAc,EAAE,OAAO,GAAG,IAAI,CAAC;IAC/B,UAAU,EAAE,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAC1C,mDAAmD;IACnD,WAAW,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACtC;AAED,MAAM,WAAW,sBAAsB;IACrC,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,KAAK,CAAC,EAAE,CACN,KAAK,EAAE,MAAM,KACV,mBAAmB,EAAE,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAC5D,mDAAmD;IACnD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kFAAkF;IAClF,eAAe,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAClC,0DAA0D;IAC1D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,sDAAsD;IACtD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2DAA2D;IAC3D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,KAAK,IAAI,CAAC;CAC9D;AAED,UAAU,SAAS;IACjB,KAAK,EAAE,mBAAmB,EAAE,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAC/C;AAED,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC;CAC9C;AAED,eAAO,MAAM,mBAAmB,iHA4E9B,CAAC;AAMH;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,sBAAsB,EAAE,EAClC,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,uBA8GtC"}
|
|
@@ -1,110 +1,133 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Extension as
|
|
3
|
-
import { PluginKey as
|
|
4
|
-
import { ReactRenderer as
|
|
5
|
-
import
|
|
6
|
-
import { forwardRef as
|
|
7
|
-
import
|
|
8
|
-
import { cx as
|
|
9
|
-
const
|
|
10
|
-
const [
|
|
11
|
-
return
|
|
12
|
-
onKeyDown: (
|
|
13
|
-
})), /* @__PURE__ */
|
|
1
|
+
import { jsx as r, jsxs as m } from "react/jsx-runtime";
|
|
2
|
+
import { Extension as x } from "@tiptap/core";
|
|
3
|
+
import { PluginKey as y } from "@tiptap/pm/state";
|
|
4
|
+
import { ReactRenderer as w } from "@tiptap/react";
|
|
5
|
+
import S, { exitSuggestion as k } from "@tiptap/suggestion";
|
|
6
|
+
import { forwardRef as N, useState as R, useEffect as C, useImperativeHandle as b } from "react";
|
|
7
|
+
import p from "tippy.js";
|
|
8
|
+
import { cx as D } from "../../utils/cn.js";
|
|
9
|
+
const h = N(({ items: s, emptyMessage: u, onSelect: n }, d) => {
|
|
10
|
+
const [c, a] = R(0);
|
|
11
|
+
return C(() => a(0), [s]), b(d, () => ({
|
|
12
|
+
onKeyDown: (e) => s.length ? e.key === "ArrowDown" ? (a((o) => (o + 1) % s.length), !0) : e.key === "ArrowUp" ? (a((o) => (o + s.length - 1) % s.length), !0) : e.key === "Enter" || e.key === "Tab" ? (n(s[c]), !0) : !1 : !1
|
|
13
|
+
})), /* @__PURE__ */ r(
|
|
14
14
|
"div",
|
|
15
15
|
{
|
|
16
16
|
role: "listbox",
|
|
17
17
|
"aria-label": "Suggestions",
|
|
18
18
|
className: "max-h-64 min-w-56 overflow-y-auto rounded-lg bg-primary p-1 shadow-lg ring-1 ring-secondary",
|
|
19
|
-
onMouseDown: (
|
|
20
|
-
children:
|
|
19
|
+
onMouseDown: (e) => e.preventDefault(),
|
|
20
|
+
children: s.length === 0 ? /* @__PURE__ */ r("div", { className: "px-2.5 py-2 text-sm text-tertiary", children: u }) : s.map((e, o) => /* @__PURE__ */ m(
|
|
21
21
|
"div",
|
|
22
22
|
{
|
|
23
23
|
role: "option",
|
|
24
|
-
"aria-selected":
|
|
25
|
-
onMouseEnter: () =>
|
|
26
|
-
onClick: () =>
|
|
27
|
-
className:
|
|
24
|
+
"aria-selected": o === c,
|
|
25
|
+
onMouseEnter: () => a(o),
|
|
26
|
+
onClick: () => n(e),
|
|
27
|
+
className: D(
|
|
28
28
|
"flex cursor-pointer items-center gap-2 rounded-md px-2.5 py-2 text-sm",
|
|
29
|
-
|
|
29
|
+
o === c ? "bg-primary_hover" : ""
|
|
30
30
|
),
|
|
31
31
|
children: [
|
|
32
|
-
|
|
33
|
-
/* @__PURE__ */
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
|
|
32
|
+
e.icon && /* @__PURE__ */ r("span", { className: "flex size-4 shrink-0 items-center text-fg-quaternary", children: e.icon }),
|
|
33
|
+
/* @__PURE__ */ m("span", { className: "min-w-0 flex-1", children: [
|
|
34
|
+
/* @__PURE__ */ m("span", { className: "flex min-w-0 items-baseline gap-2", children: [
|
|
35
|
+
/* @__PURE__ */ r("span", { className: "truncate font-medium text-secondary", children: e.label }),
|
|
36
|
+
e.hint && /* @__PURE__ */ r("span", { className: "truncate text-xs text-placeholder", children: e.hint })
|
|
37
|
+
] }),
|
|
38
|
+
e.description && /* @__PURE__ */ r("span", { className: "block truncate text-xs text-tertiary", children: e.description })
|
|
36
39
|
] })
|
|
37
40
|
]
|
|
38
41
|
},
|
|
39
|
-
`${
|
|
42
|
+
`${e.value}-${o}`
|
|
40
43
|
))
|
|
41
44
|
}
|
|
42
45
|
);
|
|
43
46
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
h.displayName = "TokenSuggestionList";
|
|
48
|
+
const E = 99999;
|
|
49
|
+
function I(s, u) {
|
|
50
|
+
return x.create({
|
|
47
51
|
name: "tokenSuggestion",
|
|
48
52
|
addProseMirrorPlugins() {
|
|
49
|
-
return
|
|
50
|
-
|
|
53
|
+
return s.map((n, d) => {
|
|
54
|
+
const c = new y(`tokenSuggestion${d}`);
|
|
55
|
+
return S({
|
|
51
56
|
editor: this.editor,
|
|
52
|
-
char:
|
|
53
|
-
pluginKey:
|
|
54
|
-
allowSpaces:
|
|
55
|
-
allowedPrefixes:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
char: n.char,
|
|
58
|
+
pluginKey: c,
|
|
59
|
+
allowSpaces: n.allowSpaces ?? !1,
|
|
60
|
+
allowedPrefixes: n.allowedPrefixes === void 0 ? [" "] : n.allowedPrefixes,
|
|
61
|
+
...n.decorationClass ? { decorationClass: n.decorationClass } : {},
|
|
62
|
+
items: ({ query: a }) => n.items ? n.items(a) : [],
|
|
63
|
+
command: ({ editor: a, range: e, props: o }) => {
|
|
64
|
+
const i = a.chain().focus().deleteRange(e).insertToken(o.value);
|
|
65
|
+
n.appendText && i.insertContent(n.appendText), i.run();
|
|
59
66
|
},
|
|
60
67
|
render: () => {
|
|
61
|
-
let
|
|
62
|
-
const
|
|
63
|
-
items:
|
|
64
|
-
emptyMessage:
|
|
65
|
-
onSelect: (
|
|
68
|
+
let a = null, e = null;
|
|
69
|
+
const o = (t) => ({
|
|
70
|
+
items: t.items,
|
|
71
|
+
emptyMessage: n.emptyMessage ?? "No matches",
|
|
72
|
+
onSelect: (l) => t.command(l)
|
|
73
|
+
}), i = (t) => ({
|
|
74
|
+
query: t.query,
|
|
75
|
+
range: t.range,
|
|
76
|
+
decorationNode: t.decorationNode,
|
|
77
|
+
clientRect: t.clientRect ?? null,
|
|
78
|
+
insertToken: (l) => t.command({ value: l, label: l })
|
|
66
79
|
});
|
|
67
80
|
return {
|
|
68
|
-
onStart: (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
81
|
+
onStart: (t) => {
|
|
82
|
+
if (u(!0), n.onStateChange) {
|
|
83
|
+
n.onStateChange(i(t));
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
a = new w(h, {
|
|
87
|
+
props: o(t),
|
|
88
|
+
editor: t.editor
|
|
89
|
+
}), t.clientRect && (e = p(document.body, {
|
|
73
90
|
getReferenceClientRect: () => {
|
|
74
|
-
var
|
|
75
|
-
return ((
|
|
91
|
+
var l;
|
|
92
|
+
return ((l = t.clientRect) == null ? void 0 : l.call(t)) ?? new DOMRect();
|
|
76
93
|
},
|
|
77
94
|
appendTo: () => document.body,
|
|
78
|
-
content:
|
|
95
|
+
content: a.element,
|
|
79
96
|
showOnCreate: !0,
|
|
80
97
|
interactive: !0,
|
|
81
98
|
trigger: "manual",
|
|
82
|
-
placement: "bottom-start"
|
|
99
|
+
placement: "bottom-start",
|
|
100
|
+
zIndex: E
|
|
83
101
|
}));
|
|
84
102
|
},
|
|
85
|
-
onUpdate: (
|
|
86
|
-
|
|
103
|
+
onUpdate: (t) => {
|
|
104
|
+
if (n.onStateChange) {
|
|
105
|
+
n.onStateChange(i(t));
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
a == null || a.updateProps(o(t)), e == null || e.setProps({
|
|
87
109
|
getReferenceClientRect: () => {
|
|
88
|
-
var
|
|
89
|
-
return ((
|
|
110
|
+
var l;
|
|
111
|
+
return ((l = t.clientRect) == null ? void 0 : l.call(t)) ?? new DOMRect();
|
|
90
112
|
}
|
|
91
113
|
});
|
|
92
114
|
},
|
|
93
|
-
onKeyDown: ({ event:
|
|
94
|
-
var
|
|
95
|
-
return
|
|
115
|
+
onKeyDown: ({ view: t, event: l }) => {
|
|
116
|
+
var f;
|
|
117
|
+
return l.key === "Escape" ? (k(t, c), !0) : n.onStateChange ? !1 : ((f = a == null ? void 0 : a.ref) == null ? void 0 : f.onKeyDown(l)) ?? !1;
|
|
96
118
|
},
|
|
97
119
|
onExit: () => {
|
|
98
|
-
|
|
120
|
+
var t;
|
|
121
|
+
u(!1), (t = n.onStateChange) == null || t.call(n, null), e == null || e.destroy(), a == null || a.destroy(), e = null, a = null;
|
|
99
122
|
}
|
|
100
123
|
};
|
|
101
124
|
}
|
|
102
|
-
})
|
|
103
|
-
);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
104
127
|
}
|
|
105
128
|
});
|
|
106
129
|
}
|
|
107
130
|
export {
|
|
108
|
-
|
|
109
|
-
|
|
131
|
+
h as TokenSuggestionList,
|
|
132
|
+
I as createTokenSuggestionExtension
|
|
110
133
|
};
|