@fiestaboard/ui 3.1.0 → 3.2.0
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/editor/color-picker-content.d.ts +25 -0
- package/dist/components/editor/color-picker-content.js +118 -0
- package/dist/components/editor/color-picker-content.js.map +1 -0
- package/dist/components/editor/constants.d.ts +87 -0
- package/dist/components/editor/constants.js +29 -0
- package/dist/components/editor/constants.js.map +1 -0
- package/dist/components/editor/draw-char-picker-content.d.ts +22 -0
- package/dist/components/editor/draw-char-picker-content.js +79 -0
- package/dist/components/editor/draw-char-picker-content.js.map +1 -0
- package/dist/components/editor/extensions/color-tile-node.d.ts +10 -0
- package/dist/components/editor/extensions/color-tile-node.js +43 -0
- package/dist/components/editor/extensions/color-tile-node.js.map +1 -0
- package/dist/components/editor/extensions/fill-space-node.d.ts +10 -0
- package/dist/components/editor/extensions/fill-space-node.js +40 -0
- package/dist/components/editor/extensions/fill-space-node.js.map +1 -0
- package/dist/components/editor/extensions/formula-node.d.ts +6 -0
- package/dist/components/editor/extensions/formula-node.js +40 -0
- package/dist/components/editor/extensions/formula-node.js.map +1 -0
- package/dist/components/editor/extensions/line-navigation.d.ts +18 -0
- package/dist/components/editor/extensions/line-navigation.js +16 -0
- package/dist/components/editor/extensions/line-navigation.js.map +1 -0
- package/dist/components/editor/extensions/single-paragraph-doc.d.ts +15 -0
- package/dist/components/editor/extensions/single-paragraph-doc.js +11 -0
- package/dist/components/editor/extensions/single-paragraph-doc.js.map +1 -0
- package/dist/components/editor/extensions/trailing-newline.d.ts +13 -0
- package/dist/components/editor/extensions/trailing-newline.js +27 -0
- package/dist/components/editor/extensions/trailing-newline.js.map +1 -0
- package/dist/components/editor/extensions/variable-node.d.ts +15 -0
- package/dist/components/editor/extensions/variable-node.js +56 -0
- package/dist/components/editor/extensions/variable-node.js.map +1 -0
- package/dist/components/editor/extensions/wrapped-text-node.d.ts +9 -0
- package/dist/components/editor/extensions/wrapped-text-node.js +31 -0
- package/dist/components/editor/extensions/wrapped-text-node.js.map +1 -0
- package/dist/components/editor/filter-picker-content.d.ts +24 -0
- package/dist/components/editor/filter-picker-content.js +146 -0
- package/dist/components/editor/filter-picker-content.js.map +1 -0
- package/dist/components/editor/formatting-picker-content.d.ts +30 -0
- package/dist/components/editor/formatting-picker-content.js +154 -0
- package/dist/components/editor/formatting-picker-content.js.map +1 -0
- package/dist/components/editor/formula/formula-editor-panel.d.ts +102 -0
- package/dist/components/editor/formula/formula-editor-panel.js +527 -0
- package/dist/components/editor/formula/formula-editor-panel.js.map +1 -0
- package/dist/components/editor/node-views/color-tile-node-view.d.ts +21 -0
- package/dist/components/editor/node-views/color-tile-node-view.js +66 -0
- package/dist/components/editor/node-views/color-tile-node-view.js.map +1 -0
- package/dist/components/editor/node-views/fill-space-node-view.d.ts +16 -0
- package/dist/components/editor/node-views/fill-space-node-view.js +43 -0
- package/dist/components/editor/node-views/fill-space-node-view.js.map +1 -0
- package/dist/components/editor/node-views/formula-node-view.d.ts +39 -0
- package/dist/components/editor/node-views/formula-node-view.js +109 -0
- package/dist/components/editor/node-views/formula-node-view.js.map +1 -0
- package/dist/components/editor/node-views/node-view-context.d.ts +58 -0
- package/dist/components/editor/node-views/node-view-context.js +22 -0
- package/dist/components/editor/node-views/node-view-context.js.map +1 -0
- package/dist/components/editor/node-views/variable-node-view.d.ts +16 -0
- package/dist/components/editor/node-views/variable-node-view.js +63 -0
- package/dist/components/editor/node-views/variable-node-view.js.map +1 -0
- package/dist/components/editor/node-views/wrapped-text-view.d.ts +14 -0
- package/dist/components/editor/node-views/wrapped-text-view.js +46 -0
- package/dist/components/editor/node-views/wrapped-text-view.js.map +1 -0
- package/dist/components/editor/template-editor-toolbar.d.ts +146 -0
- package/dist/components/editor/template-editor-toolbar.js +434 -0
- package/dist/components/editor/template-editor-toolbar.js.map +1 -0
- package/dist/components/editor/template-editor.d.ts +109 -0
- package/dist/components/editor/template-editor.js +662 -0
- package/dist/components/editor/template-editor.js.map +1 -0
- package/dist/components/editor/toolbar-dropdown.d.ts +20 -0
- package/dist/components/editor/toolbar-dropdown.js +88 -0
- package/dist/components/editor/toolbar-dropdown.js.map +1 -0
- package/dist/components/editor/utils/draw-mode.d.ts +55 -0
- package/dist/components/editor/utils/draw-mode.js +79 -0
- package/dist/components/editor/utils/draw-mode.js.map +1 -0
- package/dist/components/editor/utils/insertion.d.ts +11 -0
- package/dist/components/editor/utils/insertion.js +26 -0
- package/dist/components/editor/utils/insertion.js.map +1 -0
- package/dist/components/editor/utils/length-calculator.d.ts +36 -0
- package/dist/components/editor/utils/length-calculator.js +32 -0
- package/dist/components/editor/utils/length-calculator.js.map +1 -0
- package/dist/components/editor/utils/serialization.d.ts +34 -0
- package/dist/components/editor/utils/serialization.js +184 -0
- package/dist/components/editor/utils/serialization.js.map +1 -0
- package/dist/components/editor/utils/stroke-transaction.d.ts +36 -0
- package/dist/components/editor/utils/stroke-transaction.js +57 -0
- package/dist/components/editor/utils/stroke-transaction.js.map +1 -0
- package/dist/components/editor/variable-picker-content.d.ts +130 -0
- package/dist/components/editor/variable-picker-content.js +422 -0
- package/dist/components/editor/variable-picker-content.js.map +1 -0
- package/dist/editor.css +164 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +41 -13
- package/dist/lib/board-colors.d.ts +16 -0
- package/dist/lib/board-colors.js +14 -14
- package/dist/lib/board-colors.js.map +1 -1
- package/dist/lib/use-deps-changed.d.ts +33 -0
- package/dist/lib/use-deps-changed.js +11 -0
- package/dist/lib/use-deps-changed.js.map +1 -0
- package/package.json +50 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import "../constants.js";
|
|
2
|
+
import { Plugin as e, PluginKey as t } from "@tiptap/pm/state";
|
|
3
|
+
import { Extension as n } from "@tiptap/core";
|
|
4
|
+
//#region src/components/editor/extensions/trailing-newline.ts
|
|
5
|
+
var r = n.create({
|
|
6
|
+
name: "trailingNewline",
|
|
7
|
+
addProseMirrorPlugins() {
|
|
8
|
+
return [new e({
|
|
9
|
+
key: new t("trailingNewline"),
|
|
10
|
+
appendTransaction(e, t, n) {
|
|
11
|
+
let { doc: r, tr: i } = n, a = !1;
|
|
12
|
+
return r.descendants((e, t) => {
|
|
13
|
+
if (e.type.name !== "paragraph") return;
|
|
14
|
+
let n = e.lastChild;
|
|
15
|
+
if (n && n.type.name === "hardBreak") {
|
|
16
|
+
let n = t + e.nodeSize - 1;
|
|
17
|
+
i.insertText("", n), a = !0;
|
|
18
|
+
}
|
|
19
|
+
}), a ? i : null;
|
|
20
|
+
}
|
|
21
|
+
})];
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
//#endregion
|
|
25
|
+
export { r as TrailingNewline };
|
|
26
|
+
|
|
27
|
+
//# sourceMappingURL=trailing-newline.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trailing-newline.js","names":[],"sources":["../../../../src/components/editor/extensions/trailing-newline.ts"],"mappings":";;;;AAgBA,IAAa,IAAkB,EAAU,OAAO;CAC9C,MAAM;CAEN,wBAAwB;EACtB,OAAO,CACL,IAAI,EAAO;GACT,KAAK,IAAI,EAAU,iBAAiB;GAEpC,kBAAkB,GAAe,GAAW,GAAU;IACpD,IAAM,EAAE,QAAK,UAAO,GAEhB,IAAW;IAef,OAbA,EAAI,aAAa,GAAM,MAAQ;KAC7B,IAAI,EAAK,KAAK,SAAS,aAAa;KAEpC,IAAM,IAAY,EAAK;KAClB,SAED,EAAU,KAAK,SAAS,aAAa;MACvC,IAAM,IAAY,IAAM,EAAK,WAAW;MAExC,AADA,EAAG,WAAA,KAA0B,CAAS,GACtC,IAAW;KACb;IACF,CAAC,GAEM,IAAW,IAAK;GACzB;EACF,CAAC,CACH;CACF;AACF,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VariableNode - Inline node for {{plugin.field}} variables
|
|
3
|
+
* Supports filters like |pad:3, |wrap, etc.
|
|
4
|
+
*/
|
|
5
|
+
import { Node } from "@tiptap/core";
|
|
6
|
+
export interface VariableAttrs {
|
|
7
|
+
pluginId: string;
|
|
8
|
+
field: string;
|
|
9
|
+
filters: Array<{
|
|
10
|
+
name: string;
|
|
11
|
+
arg?: string;
|
|
12
|
+
}>;
|
|
13
|
+
maxLength?: number;
|
|
14
|
+
}
|
|
15
|
+
export declare const VariableNode: Node<any, any>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { VariableNodeView as e } from "../node-views/variable-node-view.js";
|
|
3
|
+
import { ReactNodeViewRenderer as t } from "@tiptap/react";
|
|
4
|
+
import { Node as n, mergeAttributes as r } from "@tiptap/core";
|
|
5
|
+
//#region src/components/editor/extensions/variable-node.ts
|
|
6
|
+
var i = n.create({
|
|
7
|
+
name: "variable",
|
|
8
|
+
group: "inline",
|
|
9
|
+
inline: !0,
|
|
10
|
+
atom: !0,
|
|
11
|
+
selectable: !1,
|
|
12
|
+
draggable: !0,
|
|
13
|
+
addAttributes() {
|
|
14
|
+
return {
|
|
15
|
+
pluginId: {
|
|
16
|
+
default: "",
|
|
17
|
+
parseHTML: (e) => e.getAttribute("data-plugin-id"),
|
|
18
|
+
renderHTML: (e) => ({ "data-plugin-id": e.pluginId })
|
|
19
|
+
},
|
|
20
|
+
field: {
|
|
21
|
+
default: "",
|
|
22
|
+
parseHTML: (e) => e.getAttribute("data-field"),
|
|
23
|
+
renderHTML: (e) => ({ "data-field": e.field })
|
|
24
|
+
},
|
|
25
|
+
filters: {
|
|
26
|
+
default: [],
|
|
27
|
+
parseHTML: (e) => {
|
|
28
|
+
let t = e.getAttribute("data-filters");
|
|
29
|
+
return t ? JSON.parse(t) : [];
|
|
30
|
+
},
|
|
31
|
+
renderHTML: (e) => ({ "data-filters": JSON.stringify(e.filters || []) })
|
|
32
|
+
},
|
|
33
|
+
maxLength: {
|
|
34
|
+
default: 10,
|
|
35
|
+
parseHTML: (e) => {
|
|
36
|
+
let t = e.getAttribute("data-max-length");
|
|
37
|
+
return t ? parseInt(t, 10) : 10;
|
|
38
|
+
},
|
|
39
|
+
renderHTML: (e) => ({ "data-max-length": e.maxLength?.toString() || "10" })
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
parseHTML() {
|
|
44
|
+
return [{ tag: "span[data-type=\"variable\"]" }];
|
|
45
|
+
},
|
|
46
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
47
|
+
return ["span", r({ "data-type": "variable" }, e)];
|
|
48
|
+
},
|
|
49
|
+
addNodeView() {
|
|
50
|
+
return t(e);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
//#endregion
|
|
54
|
+
export { i as VariableNode };
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=variable-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"variable-node.js","names":[],"sources":["../../../../src/components/editor/extensions/variable-node.ts"],"mappings":";;;;;AAkBA,IAAa,IAAe,EAAK,OAAO;CACtC,MAAM;CAEN,OAAO;CAEP,QAAQ;CAER,MAAM;CAEN,YAAY;CAEZ,WAAW;CAEX,gBAAgB;EACd,OAAO;GACL,UAAU;IACR,SAAS;IACT,YAAY,MAAY,EAAQ,aAAa,gBAAgB;IAC7D,aAAa,OAAgB,EAC3B,kBAAkB,EAAW,SAC/B;GACF;GACA,OAAO;IACL,SAAS;IACT,YAAY,MAAY,EAAQ,aAAa,YAAY;IACzD,aAAa,OAAgB,EAC3B,cAAc,EAAW,MAC3B;GACF;GACA,SAAS;IACP,SAAS,CAAC;IACV,YAAY,MAAY;KACtB,IAAM,IAAa,EAAQ,aAAa,cAAc;KACtD,OAAO,IAAa,KAAK,MAAM,CAAU,IAAI,CAAC;IAChD;IACA,aAAa,OAAgB,EAC3B,gBAAgB,KAAK,UAAU,EAAW,WAAW,CAAC,CAAC,EACzD;GACF;GACA,WAAW;IACT,SAAS;IACT,YAAY,MAAY;KACtB,IAAM,IAAS,EAAQ,aAAa,iBAAiB;KACrD,OAAO,IAAS,SAAS,GAAQ,EAAE,IAAI;IACzC;IACA,aAAa,OAAgB,EAC3B,mBAAmB,EAAW,WAAW,SAAS,KAAK,KACzD;GACF;EACF;CACF;CAEA,YAAY;EACV,OAAO,CACL,EACE,KAAK,+BACP,CACF;CACF;CAEA,WAAW,EAAE,qBAAkB;EAC7B,OAAO,CAAC,QAAQ,EAAgB,EAAE,aAAa,WAAW,GAAG,CAAc,CAAC;CAC9E;CAEA,cAAc;EACZ,OAAO,EAAsB,CAAgB;CAC/C;AACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WrappedTextNode - Inline node for text that will be wrapped
|
|
3
|
+
* Created when user selects text and applies wrap filter
|
|
4
|
+
*/
|
|
5
|
+
import { Node } from "@tiptap/core";
|
|
6
|
+
export interface WrappedTextAttrs {
|
|
7
|
+
text: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const WrappedTextNode: Node<any, any>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { WrappedTextView as e } from "../node-views/wrapped-text-view.js";
|
|
3
|
+
import { ReactNodeViewRenderer as t } from "@tiptap/react";
|
|
4
|
+
import { Node as n, mergeAttributes as r } from "@tiptap/core";
|
|
5
|
+
//#region src/components/editor/extensions/wrapped-text-node.ts
|
|
6
|
+
var i = n.create({
|
|
7
|
+
name: "wrappedText",
|
|
8
|
+
group: "inline",
|
|
9
|
+
inline: !0,
|
|
10
|
+
atom: !1,
|
|
11
|
+
addAttributes() {
|
|
12
|
+
return { text: {
|
|
13
|
+
default: "",
|
|
14
|
+
parseHTML: (e) => e.getAttribute("data-text") || e.textContent || "",
|
|
15
|
+
renderHTML: (e) => ({ "data-text": e.text })
|
|
16
|
+
} };
|
|
17
|
+
},
|
|
18
|
+
parseHTML() {
|
|
19
|
+
return [{ tag: "span[data-type=\"wrapped-text\"]" }];
|
|
20
|
+
},
|
|
21
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
22
|
+
return ["span", r({ "data-type": "wrapped-text" }, e)];
|
|
23
|
+
},
|
|
24
|
+
addNodeView() {
|
|
25
|
+
return t(e);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
//#endregion
|
|
29
|
+
export { i as WrappedTextNode };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=wrapped-text-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wrapped-text-node.js","names":[],"sources":["../../../../src/components/editor/extensions/wrapped-text-node.ts"],"mappings":";;;;;AAeA,IAAa,IAAkB,EAAK,OAAO;CACzC,MAAM;CAEN,OAAO;CAEP,QAAQ;CAER,MAAM;CAEN,gBAAgB;EACd,OAAO,EACL,MAAM;GACJ,SAAS;GACT,YAAY,MAAY,EAAQ,aAAa,WAAW,KAAK,EAAQ,eAAe;GACpF,aAAa,OAAgB,EAC3B,aAAa,EAAW,KAC1B;EACF,EACF;CACF;CAEA,YAAY;EACV,OAAO,CACL,EACE,KAAK,mCACP,CACF;CACF;CAEA,WAAW,EAAE,qBAAkB;EAC7B,OAAO,CAAC,QAAQ,EAAgB,EAAE,aAAa,eAAe,GAAG,CAAc,CAAC;CAClF;CAEA,cAAc;EACZ,OAAO,EAAsB,CAAe;CAC9C;AACF,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Editor } from "@tiptap/react";
|
|
2
|
+
export interface FilterPickerLabels {
|
|
3
|
+
noFiltersAvailable: string;
|
|
4
|
+
selectVariableFirst: string;
|
|
5
|
+
filterDescWrap: string;
|
|
6
|
+
filterDescPad: string;
|
|
7
|
+
filterDescTruncate: string;
|
|
8
|
+
wrapInstruction: string;
|
|
9
|
+
/** The template snippet is syntax — it stays verbatim in every locale. */
|
|
10
|
+
exampleLabel: (example: string) => string;
|
|
11
|
+
}
|
|
12
|
+
export declare const DEFAULT_FILTER_PICKER_LABELS: FilterPickerLabels;
|
|
13
|
+
export interface FilterPickerContentProps {
|
|
14
|
+
/** Filter names as declared by the template engine, e.g. `["wrap", "pad:3"]`. */
|
|
15
|
+
filters: string[];
|
|
16
|
+
/**
|
|
17
|
+
* The live TipTap editor, so a picked filter can be applied to the variable
|
|
18
|
+
* under the caret. `null` degrades to plain text insertion via `onInsert`.
|
|
19
|
+
*/
|
|
20
|
+
editor: Editor | null;
|
|
21
|
+
onInsert?: (filter: string) => void;
|
|
22
|
+
labels?: Partial<FilterPickerLabels>;
|
|
23
|
+
}
|
|
24
|
+
export declare function FilterPickerContent({ filters, editor, onInsert, labels }: FilterPickerContentProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { Badge as t } from "../feedback/badge.js";
|
|
4
|
+
import { Box as n } from "../layout/box.js";
|
|
5
|
+
import { Flex as r } from "../layout/flex.js";
|
|
6
|
+
import { Code as i } from "../typography/code.js";
|
|
7
|
+
import { Text as a } from "../typography/text.js";
|
|
8
|
+
import { Stack as o } from "../layout/stack.js";
|
|
9
|
+
import { AlertCircle as s } from "lucide-react";
|
|
10
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
11
|
+
//#region src/components/editor/filter-picker-content.tsx
|
|
12
|
+
var u = {
|
|
13
|
+
noFiltersAvailable: "No filters available",
|
|
14
|
+
selectVariableFirst: "Select a variable first to apply a filter, or click to insert filter text.",
|
|
15
|
+
filterDescWrap: "Wraps long text across multiple lines",
|
|
16
|
+
filterDescPad: "Pads text to specified width",
|
|
17
|
+
filterDescTruncate: "Truncates text to specified length",
|
|
18
|
+
wrapInstruction: "Wraps long text. Leave empty lines below for text to flow into.",
|
|
19
|
+
exampleLabel: (e) => `Example: ${e}`
|
|
20
|
+
};
|
|
21
|
+
function d(e) {
|
|
22
|
+
let { state: t } = e, { selection: n } = t, { $from: r } = n;
|
|
23
|
+
for (let e = r.depth; e > 0; e--) {
|
|
24
|
+
let t = r.node(e);
|
|
25
|
+
if (t.type.name === "variable") return {
|
|
26
|
+
node: t,
|
|
27
|
+
pos: r.before(e)
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
let i = null;
|
|
31
|
+
return t.doc.nodesBetween(n.from, n.to, (e, t) => {
|
|
32
|
+
if (i) return !1;
|
|
33
|
+
if (e.type.name === "variable") return i = {
|
|
34
|
+
node: e,
|
|
35
|
+
pos: t
|
|
36
|
+
}, !1;
|
|
37
|
+
}), i;
|
|
38
|
+
}
|
|
39
|
+
function f(e, t) {
|
|
40
|
+
let { $from: n } = e.state.selection;
|
|
41
|
+
for (let e = n.depth; e > 0; e--) if (n.node(e).type.name === t) return !0;
|
|
42
|
+
return !1;
|
|
43
|
+
}
|
|
44
|
+
function p({ filters: p, editor: m, onInsert: h, labels: g }) {
|
|
45
|
+
let _ = {
|
|
46
|
+
...u,
|
|
47
|
+
...g
|
|
48
|
+
};
|
|
49
|
+
if (p.length === 0) return /* @__PURE__ */ c(a, {
|
|
50
|
+
tone: "muted",
|
|
51
|
+
className: "p-3",
|
|
52
|
+
children: _.noFiltersAvailable
|
|
53
|
+
});
|
|
54
|
+
let v = m !== null && d(m) !== null, y = (e) => {
|
|
55
|
+
if (!m) {
|
|
56
|
+
h?.(`|${e}`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
let { state: t } = m, { selection: n } = t, r = d(m);
|
|
60
|
+
if (r) {
|
|
61
|
+
let n = r.node.attrs.filters || [], i = e.split(":")[0];
|
|
62
|
+
if (!n.some((e) => e.name === i)) {
|
|
63
|
+
let i = e.split(":"), a = {
|
|
64
|
+
name: i[0],
|
|
65
|
+
arg: i[1] || void 0
|
|
66
|
+
}, o = [...n, a], s = t.tr;
|
|
67
|
+
s.setNodeMarkup(r.pos, void 0, {
|
|
68
|
+
...r.node.attrs,
|
|
69
|
+
filters: o
|
|
70
|
+
}), m.view.dispatch(s), m.chain().focus().run();
|
|
71
|
+
}
|
|
72
|
+
} else if (e === "wrap" && n.from !== n.to) {
|
|
73
|
+
let r = t.doc.textBetween(n.from, n.to);
|
|
74
|
+
r.trim().length > 0 ? f(m, "wrappedText") || m.chain().focus().deleteSelection().insertContent({
|
|
75
|
+
type: "wrappedText",
|
|
76
|
+
attrs: { text: r }
|
|
77
|
+
}).run() : h?.(`|${e}`);
|
|
78
|
+
} else h?.(`|${e}`);
|
|
79
|
+
};
|
|
80
|
+
return /* @__PURE__ */ l(n, {
|
|
81
|
+
className: "p-2 min-w-[250px]",
|
|
82
|
+
children: [
|
|
83
|
+
!v && m && /* @__PURE__ */ l(r, {
|
|
84
|
+
align: "start",
|
|
85
|
+
gap: "2",
|
|
86
|
+
className: "mb-2 p-2 bg-muted/50 rounded-md text-xs text-muted-foreground",
|
|
87
|
+
children: [/* @__PURE__ */ c(s, { className: "w-3.5 h-3.5 mt-0.5 flex-shrink-0" }), /* @__PURE__ */ c(a, {
|
|
88
|
+
as: "span",
|
|
89
|
+
size: "xs",
|
|
90
|
+
tone: "muted",
|
|
91
|
+
children: _.selectVariableFirst
|
|
92
|
+
})]
|
|
93
|
+
}),
|
|
94
|
+
/* @__PURE__ */ c(o, {
|
|
95
|
+
gap: "2",
|
|
96
|
+
children: p.map((n) => {
|
|
97
|
+
let r = n.split(":")[0];
|
|
98
|
+
return /* @__PURE__ */ l("button", {
|
|
99
|
+
type: "button",
|
|
100
|
+
onClick: () => y(n),
|
|
101
|
+
className: e("w-full text-left px-3 py-2 rounded-md text-sm", "hover:bg-accent hover:text-accent-foreground transition-colors", "flex items-center gap-2"),
|
|
102
|
+
children: [/* @__PURE__ */ l(t, {
|
|
103
|
+
variant: "secondary",
|
|
104
|
+
className: "font-mono text-xs",
|
|
105
|
+
children: ["|", n]
|
|
106
|
+
}), /* @__PURE__ */ l(a, {
|
|
107
|
+
as: "span",
|
|
108
|
+
size: "xs",
|
|
109
|
+
tone: "muted",
|
|
110
|
+
children: [
|
|
111
|
+
r === "wrap" && _.filterDescWrap,
|
|
112
|
+
r === "pad" && _.filterDescPad,
|
|
113
|
+
r === "truncate" && _.filterDescTruncate
|
|
114
|
+
]
|
|
115
|
+
})]
|
|
116
|
+
}, n);
|
|
117
|
+
})
|
|
118
|
+
}),
|
|
119
|
+
/* @__PURE__ */ l(o, {
|
|
120
|
+
gap: "1",
|
|
121
|
+
className: "mt-3 pt-3 border-t text-xs text-muted-foreground",
|
|
122
|
+
children: [/* @__PURE__ */ c(a, {
|
|
123
|
+
size: "xs",
|
|
124
|
+
tone: "muted",
|
|
125
|
+
children: _.exampleLabel("{{weather.temperature|pad:3}}")
|
|
126
|
+
}), /* @__PURE__ */ l(a, {
|
|
127
|
+
tone: "muted",
|
|
128
|
+
className: "text-[10px]",
|
|
129
|
+
children: [
|
|
130
|
+
/* @__PURE__ */ c(i, {
|
|
131
|
+
className: "bg-transparent px-0 py-0 text-[10px] font-semibold text-muted-foreground",
|
|
132
|
+
children: "|wrap"
|
|
133
|
+
}),
|
|
134
|
+
":",
|
|
135
|
+
" ",
|
|
136
|
+
_.wrapInstruction
|
|
137
|
+
]
|
|
138
|
+
})]
|
|
139
|
+
})
|
|
140
|
+
]
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
export { u as DEFAULT_FILTER_PICKER_LABELS, p as FilterPickerContent };
|
|
145
|
+
|
|
146
|
+
//# sourceMappingURL=filter-picker-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-picker-content.js","names":[],"sources":["../../../src/components/editor/filter-picker-content.tsx"],"mappings":";;;;;;;;;;;AA4BA,IAAa,IAAmD;CAC9D,oBAAoB;CACpB,qBAAqB;CACrB,gBAAgB;CAChB,eAAe;CACf,oBAAoB;CACpB,iBAAiB;CACjB,eAAe,MAAY,YAAY;AACzC;AA6BA,SAAS,EAAiB,GAAsC;CAC9D,IAAM,EAAE,aAAU,GACZ,EAAE,iBAAc,GAChB,EAAE,aAAU;CAGlB,KAAK,IAAI,IAAQ,E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,kBAAC,GAAD;OAAM,IAAG;OAAO,MAAK;OAAK,MAAK;OAA/B,UAAA;QACG,MAAe,UAAU,EAAE;QAC3B,MAAe,SAAS,EAAE;QAC1B,MAAe,cAAc,EAAE;OAC5B;MACA,CAAA,CAAA;KAjBD,GAAA,CAiBC;IAEZ,CAAC;GACI,CAAA;GACP,kBAAC,GAAD;IAAO,KAAI;IAAI,WAAU;IAAzB,UAAA,CACE,kBAAC,GAAD;KAAM,MAAK;KAAK,MAAK;KAClB,UAAA,EAAE,aAAa,+BAA+B;IAC3C,CAAA,GACN,kBAAC,GAAD;KAAM,MAAK;KAAQ,WAAU;KAA7B,UAAA;MAEE,kBAAC,GAAD;OAAM,WAAU;OAA2E,UAAA;MAAW,CAAA;MAAC;MAAE;MACxG,EAAE;KACC;IACD,CAAA,CAAA;;EACJ;;AAET"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type BoardColorName } from "../../lib/board-colors";
|
|
3
|
+
export interface FormattingPickerLabels {
|
|
4
|
+
noFormattingAvailable: string;
|
|
5
|
+
back: string;
|
|
6
|
+
selectColor: string;
|
|
7
|
+
orCustomPattern: string;
|
|
8
|
+
use: string;
|
|
9
|
+
/** Placeholder for the custom repeat-pattern field. Punctuation, but still on screen. */
|
|
10
|
+
customPatternPlaceholder: string;
|
|
11
|
+
/** Display name per board color, shown on and announced for each swatch. */
|
|
12
|
+
colorNames: Record<BoardColorName, string>;
|
|
13
|
+
/** Accessible name for one swatch, given its display name. */
|
|
14
|
+
colorOptionLabel: (colorName: string) => string;
|
|
15
|
+
}
|
|
16
|
+
export declare const DEFAULT_FORMATTING_PICKER_LABELS: FormattingPickerLabels;
|
|
17
|
+
export interface FormattingPickerContentProps {
|
|
18
|
+
/**
|
|
19
|
+
* Formatting options keyed by name, as declared by the template engine.
|
|
20
|
+
* Optional because the app's call site passes a possibly-absent
|
|
21
|
+
* `templateVars?.formatting`; an empty map renders the "none available" copy.
|
|
22
|
+
*/
|
|
23
|
+
formatting?: Record<string, {
|
|
24
|
+
syntax: string;
|
|
25
|
+
description?: string;
|
|
26
|
+
}>;
|
|
27
|
+
onInsert: (syntax: string) => void;
|
|
28
|
+
labels?: Partial<FormattingPickerLabels>;
|
|
29
|
+
}
|
|
30
|
+
export declare function FormattingPickerContent({ formatting, onInsert, labels }: FormattingPickerContentProps): React.JSX.Element;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn as e } from "../../lib/utils.js";
|
|
3
|
+
import { Badge as t } from "../feedback/badge.js";
|
|
4
|
+
import { Button as n } from "../forms/button.js";
|
|
5
|
+
import { Input as r } from "../forms/input.js";
|
|
6
|
+
import { Box as i } from "../layout/box.js";
|
|
7
|
+
import { Flex as a } from "../layout/flex.js";
|
|
8
|
+
import { Grid as o } from "../layout/grid.js";
|
|
9
|
+
import { Text as s } from "../typography/text.js";
|
|
10
|
+
import { Stack as c } from "../layout/stack.js";
|
|
11
|
+
import { Tooltip as l, TooltipContent as u, TooltipProvider as d, TooltipTrigger as f } from "../overlays/tooltip.js";
|
|
12
|
+
import { AVAILABLE_COLORS as p, COLOR_DISPLAY as m } from "../../lib/board-colors.js";
|
|
13
|
+
import { FILL_SPACE_REPEAT_VAR as h } from "./constants.js";
|
|
14
|
+
import { ChevronRight as g, ChevronsLeftRight as _ } from "lucide-react";
|
|
15
|
+
import v from "react";
|
|
16
|
+
import { jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
17
|
+
//#region src/components/editor/formatting-picker-content.tsx
|
|
18
|
+
var x = {
|
|
19
|
+
noFormattingAvailable: "No formatting options available",
|
|
20
|
+
back: "← Back",
|
|
21
|
+
selectColor: "Select color:",
|
|
22
|
+
orCustomPattern: "Or custom pattern:",
|
|
23
|
+
use: "Use",
|
|
24
|
+
customPatternPlaceholder: "e.g. - or =-",
|
|
25
|
+
colorNames: {
|
|
26
|
+
red: "Red",
|
|
27
|
+
orange: "Orange",
|
|
28
|
+
yellow: "Yellow",
|
|
29
|
+
green: "Green",
|
|
30
|
+
blue: "Blue",
|
|
31
|
+
violet: "Violet",
|
|
32
|
+
white: "White",
|
|
33
|
+
black: "Black"
|
|
34
|
+
},
|
|
35
|
+
colorOptionLabel: (e) => `${e} color`
|
|
36
|
+
};
|
|
37
|
+
function S({ formatting: S = {}, onInsert: C, labels: w }) {
|
|
38
|
+
let T = {
|
|
39
|
+
...x,
|
|
40
|
+
...w
|
|
41
|
+
}, [E, D] = v.useState(!1), [O, k] = v.useState(""), A = v.useId(), j = Object.entries(S).map(([e, t]) => ({
|
|
42
|
+
name: e.replace(/_/g, " "),
|
|
43
|
+
syntax: t.syntax,
|
|
44
|
+
description: t.description
|
|
45
|
+
}));
|
|
46
|
+
if (j.length === 0) return /* @__PURE__ */ y(s, {
|
|
47
|
+
tone: "muted",
|
|
48
|
+
className: "p-3",
|
|
49
|
+
children: T.noFormattingAvailable
|
|
50
|
+
});
|
|
51
|
+
let M = (e) => {
|
|
52
|
+
e.syntax.includes("fill_space_repeat") ? D(!0) : C(e.syntax);
|
|
53
|
+
}, N = (e) => {
|
|
54
|
+
C(`{{${h}:${e}}}`), D(!1), k("");
|
|
55
|
+
};
|
|
56
|
+
return E ? /* @__PURE__ */ y(d, { children: /* @__PURE__ */ b(i, {
|
|
57
|
+
className: "p-2 min-w-[240px] max-w-[280px]",
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ y("button", {
|
|
60
|
+
type: "button",
|
|
61
|
+
onClick: () => D(!1),
|
|
62
|
+
className: "text-xs text-muted-foreground hover:text-foreground mb-2 flex items-center gap-1",
|
|
63
|
+
children: T.back
|
|
64
|
+
}),
|
|
65
|
+
/* @__PURE__ */ y(s, {
|
|
66
|
+
size: "xs",
|
|
67
|
+
tone: "muted",
|
|
68
|
+
weight: "medium",
|
|
69
|
+
className: "mb-2",
|
|
70
|
+
children: T.selectColor
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ y(o, {
|
|
73
|
+
cols: "4",
|
|
74
|
+
gap: "2",
|
|
75
|
+
className: "mb-3",
|
|
76
|
+
children: p.map((t) => /* @__PURE__ */ b(l, { children: [/* @__PURE__ */ y(f, {
|
|
77
|
+
asChild: !0,
|
|
78
|
+
children: /* @__PURE__ */ y("button", {
|
|
79
|
+
type: "button",
|
|
80
|
+
onClick: () => N(t),
|
|
81
|
+
className: e("h-10 rounded-md text-xs font-medium transition-all hover:scale-105 hover:shadow-md", "flex items-center justify-center", m[t].bg, m[t].text),
|
|
82
|
+
"aria-label": T.colorOptionLabel(T.colorNames[t]),
|
|
83
|
+
children: T.colorNames[t]
|
|
84
|
+
})
|
|
85
|
+
}), /* @__PURE__ */ y(u, { children: /* @__PURE__ */ y(s, { children: T.colorNames[t] }) })] }, t))
|
|
86
|
+
}),
|
|
87
|
+
/* @__PURE__ */ b(i, {
|
|
88
|
+
className: "pt-2 border-t border-border",
|
|
89
|
+
children: [/* @__PURE__ */ y(s, {
|
|
90
|
+
size: "xs",
|
|
91
|
+
tone: "muted",
|
|
92
|
+
className: "mb-1.5",
|
|
93
|
+
id: A,
|
|
94
|
+
children: T.orCustomPattern
|
|
95
|
+
}), /* @__PURE__ */ b(i, {
|
|
96
|
+
as: "form",
|
|
97
|
+
onSubmit: (e) => {
|
|
98
|
+
e.preventDefault(), O && N(O);
|
|
99
|
+
},
|
|
100
|
+
className: "flex gap-1.5",
|
|
101
|
+
children: [/* @__PURE__ */ y(r, {
|
|
102
|
+
type: "text",
|
|
103
|
+
value: O,
|
|
104
|
+
onChange: (e) => k(e.target.value),
|
|
105
|
+
placeholder: T.customPatternPlaceholder,
|
|
106
|
+
maxLength: 10,
|
|
107
|
+
"aria-labelledby": A,
|
|
108
|
+
className: "flex-1 font-mono"
|
|
109
|
+
}), /* @__PURE__ */ y(n, {
|
|
110
|
+
type: "submit",
|
|
111
|
+
size: "sm",
|
|
112
|
+
disabled: !O,
|
|
113
|
+
children: T.use
|
|
114
|
+
})]
|
|
115
|
+
})]
|
|
116
|
+
})
|
|
117
|
+
]
|
|
118
|
+
}) }) : /* @__PURE__ */ y(d, { children: /* @__PURE__ */ y(i, {
|
|
119
|
+
className: "p-1.5 min-w-[240px] max-w-[280px]",
|
|
120
|
+
children: /* @__PURE__ */ y(c, {
|
|
121
|
+
gap: "0.5",
|
|
122
|
+
children: j.map((n) => {
|
|
123
|
+
let r = n.syntax.includes(h);
|
|
124
|
+
return /* @__PURE__ */ b(l, { children: [/* @__PURE__ */ y(f, {
|
|
125
|
+
asChild: !0,
|
|
126
|
+
children: /* @__PURE__ */ b("button", {
|
|
127
|
+
type: "button",
|
|
128
|
+
onClick: () => M(n),
|
|
129
|
+
className: e("w-full text-left px-2.5 py-1.5 rounded-md text-sm", "hover:bg-accent hover:text-accent-foreground transition-colors", "flex items-center justify-between gap-2 group"),
|
|
130
|
+
children: [/* @__PURE__ */ b(a, {
|
|
131
|
+
align: "center",
|
|
132
|
+
gap: "2",
|
|
133
|
+
className: "flex-1 min-w-0",
|
|
134
|
+
children: [/* @__PURE__ */ y(_, { className: "w-3.5 h-3.5 text-muted-foreground group-hover:text-accent-foreground flex-shrink-0" }), /* @__PURE__ */ y(s, {
|
|
135
|
+
as: "span",
|
|
136
|
+
weight: "medium",
|
|
137
|
+
className: "capitalize truncate group-hover:text-accent-foreground",
|
|
138
|
+
children: n.name
|
|
139
|
+
})]
|
|
140
|
+
}), r ? /* @__PURE__ */ y(g, { className: "w-3.5 h-3.5 text-muted-foreground group-hover:text-accent-foreground flex-shrink-0" }) : /* @__PURE__ */ y(t, {
|
|
141
|
+
variant: "secondary",
|
|
142
|
+
className: "font-mono text-[10px] px-1.5 py-0 flex-shrink-0",
|
|
143
|
+
children: n.syntax
|
|
144
|
+
})]
|
|
145
|
+
})
|
|
146
|
+
}), /* @__PURE__ */ y(u, { children: /* @__PURE__ */ y(s, { children: n.description ?? n.name }) })] }, n.syntax);
|
|
147
|
+
})
|
|
148
|
+
})
|
|
149
|
+
}) });
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
export { x as DEFAULT_FORMATTING_PICKER_LABELS, S as FormattingPickerContent };
|
|
153
|
+
|
|
154
|
+
//# sourceMappingURL=formatting-picker-content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatting-picker-content.js","names":[],"sources":["../../../src/components/editor/formatting-picker-content.tsx"],"mappings":";;;;;;;;;;;;;;;;;AAyCA,IAAa,IAA2D;CACtE,uBAAuB;CACvB,MAAM;CACN,aAAa;CACb,iBAAiB;CACjB,KAAK;CACL,0BAA0B;CAC1B,YAAY;EACV,KAAK;EACL,QAAQ;EACR,QAAQ;EACR,OAAO;EACP,MAAM;EACN,QAAQ;EACR,OAAO;EACP,OAAO;CACT;CACA,mBAAmB,MAAc,GAAG,EAAU;AAChD;AAaA,SAAgB,EAAwB,EAAE,gBAAa,CAAC,GAAG,aAAU,aAAwC;CAC3G,IAAM,IAAI;EAAE,GAAG;EAAkC,GAAG;CAAO,GACrD,CAAC,GAAuB,KAA4B,EAAM,SAAS,EAAK,GACxE,CAAC,GAAY,KAAiB,EAAM,SAAS,EAAE,GAI/C,IAAoB,EAAM,MAAM,GAEhC,IAA8B,OAAO,QAAQ,CAAU,CAAC,CAAC,KAAK,CAAC,GAAM,QAAW;EACpF,MAAM,EAAK,QAAQ,MAAM,GAAG;EAC5B,QAAQ,EAAK;EACb,aAAa,EAAK;CACpB,EAAE;CAEF,IAAI,EAAQ,WAAW,GACrB,OACE,kBAAC,GAAD;EAAM,MAAK;EAAQ,WAAU;EAC1B,UAAA,EAAE;CACC,CAAA;CAIV,IAAM,KAAqB,MAA6B;EAEtD,AAAI,EAAO,OAAO,SAAA,mBAA8B,IAC9C,EAAyB,EAAI,IAE7B,EAAS,EAAO,MAAM;CAE1B,GAEM,KAAqB,MAAsB;EAG/C,AAFA,EAAS,KAAK,EAAsB,GAAG,EAAU,GAAG,GACpD,EAAyB,EAAK,GAC9B,EAAc,EAAE;CAClB;CAiFA,OAvEI,I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AAU,CAAC;MACxC,UAAA,EAAE;KACG,CAAA,CACL;IACF,CAAA,CAAA;;EACF;CACU,CAAA,EAAA,CAAA,IAMnB,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;EAAK,WAAU;EACb,UAAA,kBAAC,GAAD;GAAO,KAAI;GACR,UAAA,EAAQ,KAAK,MAAW;IACvB,IAAM,IAAW,EAAO,OAAO,SAAS,CAAqB;IAE7D,OACE,kBAAC,GAAD,EAAA,UAAA,CACE,kBAAC,GAAD;KAAgB,SAAA;KACd,UAAA,kBAAC,UAAD;MACE,MAAK;MACL,eAAe,EAAkB,CAAM;MACvC,WAAW,EACT,qDACA,kEACA,+CACF;MAPF,UAAA,CASE,kBAAC,GAAD;OAAM,OAAM;OAAS,KAAI;OAAI,WAAU;OAAvC,UAAA,CACE,kBAAC,GAAD,EAAmB,WAAU,qFAAsF,CAAA,GACnH,kBAAC,GAAD;QACE,IAAG;QACH,QAAO;QACP,WAAU;QAET,UAAA,EAAO;OACJ,CAAA,CACF;MACL,CAAA,GAAA,IACC,kBAAC,GAAD,EAAc,WAAU,qFAAsF,CAAA,IAE9G,kBAAC,GAAD;OAAO,SAAQ;OAAY,WAAU;OAClC,UAAA,EAAO;MACH,CAAA,CAEH;;IACM,CAAA,GAChB,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD,EAAA,UAAO,EAAO,eAAe,EAAO,KAAW,CAAA,EACjC,CAAA,CACT,EAAA,GAjCK,EAAO,MAiCZ;GAEb,CAAC;EACI,CAAA;CACJ,CAAA,EACU,CAAA;AAErB"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* One built-in formula function, as the app's `getFormulaFunctions` describes
|
|
4
|
+
* it. Declared structurally here so a host can type-check its own payload
|
|
5
|
+
* without this package depending on the FiestaBoard API client.
|
|
6
|
+
*/
|
|
7
|
+
export interface FormulaFunction {
|
|
8
|
+
/** Uppercase call name, e.g. `IF`. */
|
|
9
|
+
name: string;
|
|
10
|
+
/** Grouping key. The five FiestaBoard categories get an icon and an accent
|
|
11
|
+
* colour; anything else still renders, in a neutral group after them. */
|
|
12
|
+
category: string;
|
|
13
|
+
/** Human-readable call shape, e.g. `IF(cond, then, else)`. */
|
|
14
|
+
signature: string;
|
|
15
|
+
/** One-line description, shown in the hover tooltip. */
|
|
16
|
+
summary: string;
|
|
17
|
+
}
|
|
18
|
+
/** Result of an injected expression validation round-trip. */
|
|
19
|
+
export interface FormulaValidationResult {
|
|
20
|
+
valid: boolean;
|
|
21
|
+
/** Message to show under the editor when `valid` is false. */
|
|
22
|
+
error?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface FormulaEditorLabels {
|
|
25
|
+
/** Tab that lists the built-in functions. */
|
|
26
|
+
functionsTab: string;
|
|
27
|
+
/** Tab that hosts the injected variable picker. */
|
|
28
|
+
variablesTab: string;
|
|
29
|
+
/** Accessible name for the function-list loading placeholder. */
|
|
30
|
+
loading: string;
|
|
31
|
+
/** Field label above the CodeMirror input. */
|
|
32
|
+
formulaExpression: string;
|
|
33
|
+
/** Confirm button, `mode="create"`. */
|
|
34
|
+
insert: string;
|
|
35
|
+
/** Confirm button, `mode="edit"`. */
|
|
36
|
+
done: string;
|
|
37
|
+
/** Dismiss button when the panel opened empty. */
|
|
38
|
+
cancel: string;
|
|
39
|
+
/** Dismiss button when the panel opened on an existing formula. */
|
|
40
|
+
close: string;
|
|
41
|
+
categoryLogic: string;
|
|
42
|
+
categoryMath: string;
|
|
43
|
+
categoryText: string;
|
|
44
|
+
categoryConversion: string;
|
|
45
|
+
categoryColor: string;
|
|
46
|
+
}
|
|
47
|
+
export declare const DEFAULT_FORMULA_EDITOR_LABELS: FormulaEditorLabels;
|
|
48
|
+
export interface FormulaEditorPanelProps {
|
|
49
|
+
/**
|
|
50
|
+
* Pre-populated expression body (no {{= }}). Used in edit mode.
|
|
51
|
+
*
|
|
52
|
+
* Read when the CodeMirror document is created, i.e. at mount: changing it
|
|
53
|
+
* afterwards does not rewrite what the user is editing. To reopen the panel
|
|
54
|
+
* on a different formula, give it a new `key`.
|
|
55
|
+
*/
|
|
56
|
+
initialExpr?: string;
|
|
57
|
+
/** "create" → Insert button; "edit" → Done button + Cancel */
|
|
58
|
+
mode: "create" | "edit";
|
|
59
|
+
/** Called with the bare expression when the user confirms. */
|
|
60
|
+
onConfirm: (expr: string) => void;
|
|
61
|
+
/** Called when the user cancels (edit mode only). */
|
|
62
|
+
onCancel?: () => void;
|
|
63
|
+
/**
|
|
64
|
+
* Built-in function reference, already resolved by the host. Grouped by
|
|
65
|
+
* `category` and sorted by name for display.
|
|
66
|
+
*/
|
|
67
|
+
formulaFunctions?: FormulaFunction[];
|
|
68
|
+
/** Show placeholders in the Functions tab while the host fetches. */
|
|
69
|
+
isLoadingFunctions?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Validates the **bare expression body** — no `{{=` / `}}` wrapper, already
|
|
72
|
+
* trimmed. A host backed by a whole-template validator wraps it itself:
|
|
73
|
+
* `validateExpression={(e) => api.validateTemplate(`{{= ${e} }}`)}`.
|
|
74
|
+
*
|
|
75
|
+
* Calls are debounced 300 ms and results for a stale expression are
|
|
76
|
+
* discarded, so an implementation only has to be idempotent, not cancelable.
|
|
77
|
+
*
|
|
78
|
+
* Omitting it turns validation off entirely: the state indicator stays
|
|
79
|
+
* blank and Confirm enables on any non-empty expression. That is deliberate
|
|
80
|
+
* — a panel with no validator must not present a permanently disabled
|
|
81
|
+
* Confirm button.
|
|
82
|
+
*/
|
|
83
|
+
validateExpression?: (expr: string) => Promise<FormulaValidationResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Renders the Variables tab. Omitted, the tab strip disappears and the panel
|
|
86
|
+
* shows only functions — never a placeholder.
|
|
87
|
+
*
|
|
88
|
+
* A slot rather than a direct import of the group's `VariablePickerContent`:
|
|
89
|
+
* that component pulls in lucide-react's full `icons` barrel, and injecting
|
|
90
|
+
* it lets the host hand over the *same* lazy chunk its toolbar already
|
|
91
|
+
* loaded instead of duplicating the barrel into this already
|
|
92
|
+
* CodeMirror-heavy panel (FiestaBoard #1575). This panel wraps the slot in
|
|
93
|
+
* its own `<Suspense>`, so a bare `lazy()` component can be passed straight
|
|
94
|
+
* in.
|
|
95
|
+
*/
|
|
96
|
+
renderVariablePicker?: (ctx: {
|
|
97
|
+
onInsert: (variable: string) => void;
|
|
98
|
+
}) => ReactNode;
|
|
99
|
+
labels?: Partial<FormulaEditorLabels>;
|
|
100
|
+
className?: string;
|
|
101
|
+
}
|
|
102
|
+
export declare function FormulaEditorPanel({ initialExpr, mode, onConfirm, onCancel, formulaFunctions, isLoadingFunctions, validateExpression, renderVariablePicker, labels, className, }: FormulaEditorPanelProps): import("react").JSX.Element;
|