@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.
Files changed (44) hide show
  1. package/dist/_virtual/index.js +2 -3
  2. package/dist/_virtual/index2.js +3 -5
  3. package/dist/_virtual/index3.js +5 -2
  4. package/dist/node_modules/eventemitter3/index.js +1 -1
  5. package/dist/node_modules/react-is/index.js +1 -1
  6. package/dist/node_modules/recharts/es6/util/Events.js +1 -1
  7. package/dist/node_modules/recharts/es6/util/ReactUtils.js +1 -1
  8. package/dist/node_modules/use-sync-external-store/shim/index.js +1 -1
  9. package/dist/patterns/condition-builder/add-action-button.d.ts +2 -0
  10. package/dist/patterns/condition-builder/add-action-button.d.ts.map +1 -1
  11. package/dist/patterns/condition-builder/add-action-button.js +22 -18
  12. package/dist/patterns/condition-builder/condition-builder.d.ts +1 -1
  13. package/dist/patterns/condition-builder/condition-builder.d.ts.map +1 -1
  14. package/dist/patterns/condition-builder/condition-builder.js +58 -57
  15. package/dist/patterns/condition-builder/condition-group.d.ts +1 -1
  16. package/dist/patterns/condition-builder/condition-group.d.ts.map +1 -1
  17. package/dist/patterns/condition-builder/condition-group.js +238 -233
  18. package/dist/patterns/condition-builder/types.d.ts +10 -0
  19. package/dist/patterns/condition-builder/types.d.ts.map +1 -1
  20. package/dist/patterns/confirm-dialog/confirm-dialog.d.ts +8 -1
  21. package/dist/patterns/confirm-dialog/confirm-dialog.d.ts.map +1 -1
  22. package/dist/patterns/confirm-dialog/confirm-dialog.js +76 -71
  23. package/dist/patterns/filter-group/document-fields-to-tree.d.ts +1 -0
  24. package/dist/patterns/filter-group/document-fields-to-tree.d.ts.map +1 -1
  25. package/dist/patterns/filter-group/document-fields-to-tree.js +14 -13
  26. package/dist/patterns/filter-group/filter-condition-row.js +30 -30
  27. package/dist/patterns/filter-group/nested-field-select.d.ts.map +1 -1
  28. package/dist/patterns/filter-group/nested-field-select.js +175 -167
  29. package/dist/patterns/filter-group/types.d.ts +4 -0
  30. package/dist/patterns/filter-group/types.d.ts.map +1 -1
  31. package/dist/patterns/filter-group/types.js +27 -12
  32. package/dist/rich-text/token-input/index.d.ts +1 -1
  33. package/dist/rich-text/token-input/index.d.ts.map +1 -1
  34. package/dist/rich-text/token-input/token-input.d.ts +22 -5
  35. package/dist/rich-text/token-input/token-input.d.ts.map +1 -1
  36. package/dist/rich-text/token-input/token-input.js +242 -181
  37. package/dist/rich-text/token-input/token-node.d.ts +7 -0
  38. package/dist/rich-text/token-input/token-node.d.ts.map +1 -1
  39. package/dist/rich-text/token-input/token-node.js +20 -15
  40. package/dist/rich-text/token-input/token-suggestion.d.ts +33 -3
  41. package/dist/rich-text/token-input/token-suggestion.d.ts.map +1 -1
  42. package/dist/rich-text/token-input/token-suggestion.js +94 -63
  43. package/dist/styles/components.css +1 -1
  44. package/package.json +1 -1
@@ -1,23 +1,53 @@
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: (query: string) => TokenSuggestionItem[] | Promise<TokenSuggestionItem[]>;
29
+ items?: (query: string) => TokenSuggestionItem[] | Promise<TokenSuggestionItem[]>;
15
30
  /** Let the query contain spaces. @default false */
16
31
  allowSpaces?: boolean;
32
+ /**
33
+ * Whether the text typed after the trigger keeps the menu open. With
34
+ * `allowSpaces`, this decides when prose takes over. @default always
35
+ */
36
+ allowQuery?: (query: string) => boolean;
17
37
  /** Characters allowed right before the trigger. @default [" "] plus line start */
18
38
  allowedPrefixes?: string[] | null;
19
39
  /** Message when nothing matches. @default "No matches" */
20
40
  emptyMessage?: string;
41
+ /** Text inserted after the chosen token, e.g. " ". */
42
+ appendText?: string;
43
+ /** Class on the decorated trigger + query while active. */
44
+ decorationClass?: string;
45
+ /**
46
+ * Headless mode: the app renders its own picker. Called with the state while
47
+ * the trigger is active and with null when it ends. Handle the picker's
48
+ * keys in TokenInput's `onKeyDownCapture`; Escape still closes it.
49
+ */
50
+ onStateChange?: (state: TokenSuggestionState | null) => void;
21
51
  }
22
52
  interface ListProps {
23
53
  items: TokenSuggestionItem[];
@@ -30,7 +60,7 @@ export interface TokenSuggestionListHandle {
30
60
  export declare const TokenSuggestionList: import('react').ForwardRefExoticComponent<ListProps & import('react').RefAttributes<TokenSuggestionListHandle>>;
31
61
  /**
32
62
  * One Suggestion plugin per trigger. `onOpenChange` reports whether any menu is
33
- * showing, so TokenInput lets Enter through to the menu in single-line fields.
63
+ * active, so TokenInput lets Enter through to it in single-line fields.
34
64
  */
35
65
  export declare function createTokenSuggestionExtension(triggers: TokenSuggestionTrigger[], onOpenChange: (open: boolean) => void): Extension<any, any>;
36
66
  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;AAOzC,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,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,SAAS,CAAC;CAClB;AAED,MAAM,WAAW,sBAAsB;IACrC,8DAA8D;IAC9D,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,KAAK,EAAE,CACL,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;CACvB;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,iHAqE9B,CAAC;AAGH;;;GAGG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,sBAAsB,EAAE,EAClC,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,uBAmFtC"}
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,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ACrB,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,uBAyHtC"}
@@ -1,110 +1,141 @@
1
- import { jsx as i, jsxs as u } from "react/jsx-runtime";
2
- import { Extension as d } from "@tiptap/core";
3
- import { PluginKey as f } from "@tiptap/pm/state";
4
- import { ReactRenderer as y } from "@tiptap/react";
5
- import g from "@tiptap/suggestion";
6
- import { forwardRef as h, useState as w, useEffect as x, useImperativeHandle as k } from "react";
7
- import R from "tippy.js";
8
- import { cx as b } from "../../utils/cn.js";
9
- const m = h(({ items: o, emptyMessage: s, onSelect: l }, c) => {
10
- const [t, r] = w(0);
11
- return x(() => r(0), [o]), k(c, () => ({
12
- onKeyDown: (n) => o.length ? n.key === "ArrowDown" ? (r((e) => (e + 1) % o.length), !0) : n.key === "ArrowUp" ? (r((e) => (e + o.length - 1) % o.length), !0) : n.key === "Enter" || n.key === "Tab" ? (l(o[t]), !0) : !1 : !1
13
- })), /* @__PURE__ */ i(
1
+ import { jsx as r, jsxs as m } from "react/jsx-runtime";
2
+ import { Extension as y } from "@tiptap/core";
3
+ import { PluginKey as x } 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: (n) => n.preventDefault(),
20
- children: o.length === 0 ? /* @__PURE__ */ i("div", { className: "px-2.5 py-2 text-sm text-tertiary", children: s }) : o.map((n, e) => /* @__PURE__ */ u(
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": e === t,
25
- onMouseEnter: () => r(e),
26
- onClick: () => l(n),
27
- className: b(
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
- e === t ? "bg-primary_hover" : ""
29
+ o === c ? "bg-primary_hover" : ""
30
30
  ),
31
31
  children: [
32
- n.icon && /* @__PURE__ */ i("span", { className: "flex size-4 shrink-0 items-center text-fg-quaternary", children: n.icon }),
33
- /* @__PURE__ */ u("span", { className: "min-w-0 flex-1", children: [
34
- /* @__PURE__ */ i("span", { className: "block truncate font-medium text-secondary", children: n.label }),
35
- n.description && /* @__PURE__ */ i("span", { className: "block truncate text-xs text-tertiary", children: n.description })
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
- `${n.value}-${e}`
42
+ `${e.value}-${o}`
40
43
  ))
41
44
  }
42
45
  );
43
46
  });
44
- m.displayName = "TokenSuggestionList";
45
- function T(o, s) {
46
- return d.create({
47
+ h.displayName = "TokenSuggestionList";
48
+ const E = 99999;
49
+ function U(s, u) {
50
+ return y.create({
47
51
  name: "tokenSuggestion",
48
52
  addProseMirrorPlugins() {
49
- return o.map(
50
- (l, c) => g({
53
+ return s.map((n, d) => {
54
+ const c = new x(`tokenSuggestion${d}`);
55
+ return S({
51
56
  editor: this.editor,
52
- char: l.char,
53
- pluginKey: new f(`tokenSuggestion${c}`),
54
- allowSpaces: l.allowSpaces ?? !1,
55
- allowedPrefixes: l.allowedPrefixes === void 0 ? [" "] : l.allowedPrefixes,
56
- items: ({ query: t }) => l.items(t),
57
- command: ({ editor: t, range: r, props: n }) => {
58
- t.chain().focus().deleteRange(r).insertToken(n.value).run();
57
+ char: n.char,
58
+ pluginKey: c,
59
+ allowSpaces: n.allowSpaces ?? !1,
60
+ ...n.allowQuery ? {
61
+ allow: ({ state: a, range: e }) => n.allowQuery(
62
+ a.doc.textBetween(
63
+ e.from + n.char.length,
64
+ e.to
65
+ )
66
+ )
67
+ } : {},
68
+ allowedPrefixes: n.allowedPrefixes === void 0 ? [" "] : n.allowedPrefixes,
69
+ ...n.decorationClass ? { decorationClass: n.decorationClass } : {},
70
+ items: ({ query: a }) => n.items ? n.items(a) : [],
71
+ command: ({ editor: a, range: e, props: o }) => {
72
+ const i = a.chain().focus().deleteRange(e).insertToken(o.value);
73
+ n.appendText && i.insertContent(n.appendText), i.run();
59
74
  },
60
75
  render: () => {
61
- let t = null, r = null;
62
- const n = (e) => ({
63
- items: e.items,
64
- emptyMessage: l.emptyMessage ?? "No matches",
65
- onSelect: (a) => e.command(a)
76
+ let a = null, e = null;
77
+ const o = (t) => ({
78
+ items: t.items,
79
+ emptyMessage: n.emptyMessage ?? "No matches",
80
+ onSelect: (l) => t.command(l)
81
+ }), i = (t) => ({
82
+ query: t.query,
83
+ range: t.range,
84
+ decorationNode: t.decorationNode,
85
+ clientRect: t.clientRect ?? null,
86
+ insertToken: (l) => t.command({ value: l, label: l })
66
87
  });
67
88
  return {
68
- onStart: (e) => {
69
- s(!0), t = new y(m, {
70
- props: n(e),
71
- editor: e.editor
72
- }), e.clientRect && (r = R(document.body, {
89
+ onStart: (t) => {
90
+ if (u(!0), n.onStateChange) {
91
+ n.onStateChange(i(t));
92
+ return;
93
+ }
94
+ a = new w(h, {
95
+ props: o(t),
96
+ editor: t.editor
97
+ }), t.clientRect && (e = p(document.body, {
73
98
  getReferenceClientRect: () => {
74
- var a;
75
- return ((a = e.clientRect) == null ? void 0 : a.call(e)) ?? new DOMRect();
99
+ var l;
100
+ return ((l = t.clientRect) == null ? void 0 : l.call(t)) ?? new DOMRect();
76
101
  },
77
102
  appendTo: () => document.body,
78
- content: t.element,
103
+ content: a.element,
79
104
  showOnCreate: !0,
80
105
  interactive: !0,
81
106
  trigger: "manual",
82
- placement: "bottom-start"
107
+ placement: "bottom-start",
108
+ zIndex: E
83
109
  }));
84
110
  },
85
- onUpdate: (e) => {
86
- t == null || t.updateProps(n(e)), r == null || r.setProps({
111
+ onUpdate: (t) => {
112
+ if (n.onStateChange) {
113
+ n.onStateChange(i(t));
114
+ return;
115
+ }
116
+ a == null || a.updateProps(o(t)), e == null || e.setProps({
87
117
  getReferenceClientRect: () => {
88
- var a;
89
- return ((a = e.clientRect) == null ? void 0 : a.call(e)) ?? new DOMRect();
118
+ var l;
119
+ return ((l = t.clientRect) == null ? void 0 : l.call(t)) ?? new DOMRect();
90
120
  }
91
121
  });
92
122
  },
93
- onKeyDown: ({ event: e }) => {
94
- var a;
95
- return e.key === "Escape" ? (r == null || r.hide(), !0) : ((a = t == null ? void 0 : t.ref) == null ? void 0 : a.onKeyDown(e)) ?? !1;
123
+ onKeyDown: ({ view: t, event: l }) => {
124
+ var f;
125
+ 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
126
  },
97
127
  onExit: () => {
98
- s(!1), r == null || r.destroy(), t == null || t.destroy(), r = null, t = null;
128
+ var t;
129
+ u(!1), (t = n.onStateChange) == null || t.call(n, null), e == null || e.destroy(), a == null || a.destroy(), e = null, a = null;
99
130
  }
100
131
  };
101
132
  }
102
- })
103
- );
133
+ });
134
+ });
104
135
  }
105
136
  });
106
137
  }
107
138
  export {
108
- m as TokenSuggestionList,
109
- T as createTokenSuggestionExtension
139
+ h as TokenSuggestionList,
140
+ U as createTokenSuggestionExtension
110
141
  };