@lattice-php/lattice 0.17.0 → 0.17.2
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/chat/index.d.ts +1 -1
- package/dist/chat/index.js +3 -3
- package/dist/chat/index.js.map +1 -1
- package/dist/core/components/chart-view.d.ts +3 -0
- package/dist/core/components/chart-view.js +225 -0
- package/dist/core/components/chart-view.js.map +1 -0
- package/dist/core/components/chart.js +10 -220
- package/dist/core/components/chart.js.map +1 -1
- package/dist/core/components/index.js +3 -2
- package/dist/core/components/index.js.map +1 -1
- package/dist/core/renderer.js +42 -2
- package/dist/core/renderer.js.map +1 -1
- package/dist/create-app.js +3 -3
- package/dist/create-app.js.map +1 -1
- package/dist/form/components/fields/date-input.js +2 -2
- package/dist/form/components/fields/date-input.js.map +1 -1
- package/dist/form/components/fields/{date-picker-control.d.ts → date-picker-field.d.ts} +2 -2
- package/dist/form/components/fields/{date-picker-control.js → date-picker-field.js} +4 -4
- package/dist/form/components/fields/date-picker-field.js.map +1 -0
- package/dist/form/components/fields/date-picker.d.ts +2 -0
- package/dist/form/components/fields/date-picker.js +17 -0
- package/dist/form/components/fields/date-picker.js.map +1 -0
- package/dist/form/components/fields/date-time-input.js +2 -2
- package/dist/form/components/fields/date-time-input.js.map +1 -1
- package/dist/form/components/fields/rich-editor-field.d.ts +3 -0
- package/dist/form/components/fields/rich-editor-field.js +340 -0
- package/dist/form/components/fields/rich-editor-field.js.map +1 -0
- package/dist/form/components/fields/rich-editor.js +10 -335
- package/dist/form/components/fields/rich-editor.js.map +1 -1
- package/dist/form/components/fields/table-rows.js +2 -2
- package/dist/form/index.js +37 -29
- package/dist/form/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -4
- package/dist/notifications/index.d.ts +1 -1
- package/dist/notifications/index.js +2 -2
- package/dist/notifications/index.js.map +1 -1
- package/dist/provider.js +4 -4
- package/dist/provider.js.map +1 -1
- package/dist/registry.d.ts +1 -1
- package/dist/registry.js +15 -2
- package/dist/registry.js.map +1 -0
- package/dist/table/components/cells/money-cell.js +1 -1
- package/dist/table/components/cells/number-cell.js +1 -1
- package/dist/table/components/table.js +1 -1
- package/dist/table/index.js +3 -2
- package/dist/table/index.js.map +1 -1
- package/package.json +8 -11
- package/dist/core/components/eager.d.ts +0 -1
- package/dist/core/components/eager.js +0 -50
- package/dist/core/components/eager.js.map +0 -1
- package/dist/form/components/fields/date-picker-control.js.map +0 -1
- package/dist/form/components/fields/lazy-date-picker-control.d.ts +0 -2
- package/dist/form/components/fields/lazy-date-picker-control.js +0 -17
- package/dist/form/components/fields/lazy-date-picker-control.js.map +0 -1
- package/dist/form/eager.d.ts +0 -1
- package/dist/form/eager.js +0 -47
- package/dist/form/eager.js.map +0 -1
- package/dist/form/skeleton.d.ts +0 -2
- package/dist/form/skeleton.js +0 -22
- package/dist/form/skeleton.js.map +0 -1
- package/dist/registry/eager.d.ts +0 -1
- package/dist/registry/eager.js +0 -15
- package/dist/registry/eager.js.map +0 -1
- package/dist/registry/lazy.d.ts +0 -1
- package/dist/registry/lazy.js +0 -15
- package/dist/registry/lazy.js.map +0 -1
- package/dist/table/eager.d.ts +0 -1
- package/dist/table/eager.js +0 -11
- package/dist/table/eager.js.map +0 -1
|
@@ -1,339 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { useT } from "../../../i18n/instance.js";
|
|
4
|
-
import { useFormContext } from "../context.js";
|
|
5
|
-
import { useFieldScope } from "../field-scope.js";
|
|
6
|
-
import { useFormValue } from "../values.js";
|
|
7
|
-
import { FormFieldFrame } from "../base/field.js";
|
|
8
|
-
import { useDependentField } from "../use-dependent-field.js";
|
|
9
|
-
import { useFieldCommit } from "../use-field-commit.js";
|
|
10
|
-
import { useEffect, useState } from "react";
|
|
11
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
import { Details, DetailsContent, DetailsSummary } from "@tiptap/extension-details";
|
|
13
|
-
import { Highlight } from "@tiptap/extension-highlight";
|
|
14
|
-
import { Link } from "@tiptap/extension-link";
|
|
15
|
-
import { TableKit } from "@tiptap/extension-table";
|
|
16
|
-
import { TextAlign } from "@tiptap/extension-text-align";
|
|
17
|
-
import { EditorContent, useEditor } from "@tiptap/react";
|
|
18
|
-
import { StarterKit } from "@tiptap/starter-kit";
|
|
1
|
+
import { Suspense, lazy } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
19
3
|
//#region resources/js/form/components/fields/rich-editor.tsx
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{
|
|
29
|
-
icon: "italic",
|
|
30
|
-
key: "italic",
|
|
31
|
-
label: "Italic",
|
|
32
|
-
isActive: (e) => e.isActive("italic"),
|
|
33
|
-
run: (e) => e.chain().focus().toggleItalic().run()
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
icon: "strikethrough",
|
|
37
|
-
key: "strikethrough",
|
|
38
|
-
label: "Strikethrough",
|
|
39
|
-
isActive: (e) => e.isActive("strike"),
|
|
40
|
-
run: (e) => e.chain().focus().toggleStrike().run()
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
icon: "underline",
|
|
44
|
-
key: "underline",
|
|
45
|
-
label: "Underline",
|
|
46
|
-
isActive: (e) => e.isActive("underline"),
|
|
47
|
-
run: (e) => e.chain().focus().toggleUnderline().run()
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
icon: "highlighter",
|
|
51
|
-
key: "highlight",
|
|
52
|
-
label: "Highlight",
|
|
53
|
-
isActive: (e) => e.isActive("highlight"),
|
|
54
|
-
run: (e) => e.chain().focus().toggleHighlight().run()
|
|
55
|
-
},
|
|
56
|
-
"separator",
|
|
57
|
-
{
|
|
58
|
-
icon: "heading-1",
|
|
59
|
-
key: "heading-1",
|
|
60
|
-
label: "Heading 1",
|
|
61
|
-
isActive: (e) => e.isActive("heading", { level: 1 }),
|
|
62
|
-
run: (e) => e.chain().focus().toggleHeading({ level: 1 }).run()
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
icon: "heading-2",
|
|
66
|
-
key: "heading-2",
|
|
67
|
-
label: "Heading 2",
|
|
68
|
-
isActive: (e) => e.isActive("heading", { level: 2 }),
|
|
69
|
-
run: (e) => e.chain().focus().toggleHeading({ level: 2 }).run()
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
icon: "heading-3",
|
|
73
|
-
key: "heading-3",
|
|
74
|
-
label: "Heading 3",
|
|
75
|
-
isActive: (e) => e.isActive("heading", { level: 3 }),
|
|
76
|
-
run: (e) => e.chain().focus().toggleHeading({ level: 3 }).run()
|
|
77
|
-
},
|
|
78
|
-
"separator",
|
|
79
|
-
{
|
|
80
|
-
icon: "list",
|
|
81
|
-
key: "bullet-list",
|
|
82
|
-
label: "Bullet list",
|
|
83
|
-
isActive: (e) => e.isActive("bulletList"),
|
|
84
|
-
run: (e) => e.chain().focus().toggleBulletList().run()
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
icon: "list-ordered",
|
|
88
|
-
key: "ordered-list",
|
|
89
|
-
label: "Ordered list",
|
|
90
|
-
isActive: (e) => e.isActive("orderedList"),
|
|
91
|
-
run: (e) => e.chain().focus().toggleOrderedList().run()
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
icon: "quote",
|
|
95
|
-
key: "blockquote",
|
|
96
|
-
label: "Blockquote",
|
|
97
|
-
isActive: (e) => e.isActive("blockquote"),
|
|
98
|
-
run: (e) => e.chain().focus().toggleBlockquote().run()
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
icon: "code",
|
|
102
|
-
key: "code-block",
|
|
103
|
-
label: "Code block",
|
|
104
|
-
isActive: (e) => e.isActive("codeBlock"),
|
|
105
|
-
run: (e) => e.chain().focus().toggleCodeBlock().run()
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
icon: "minus",
|
|
109
|
-
key: "horizontal-rule",
|
|
110
|
-
label: "Horizontal rule",
|
|
111
|
-
isActive: () => false,
|
|
112
|
-
run: (e) => e.chain().focus().setHorizontalRule().run()
|
|
113
|
-
},
|
|
114
|
-
"separator",
|
|
115
|
-
{
|
|
116
|
-
icon: "align-left",
|
|
117
|
-
key: "align-left",
|
|
118
|
-
label: "Align left",
|
|
119
|
-
isActive: (e) => e.isActive({ textAlign: "left" }),
|
|
120
|
-
run: (e) => e.chain().focus().setTextAlign("left").run()
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
icon: "align-center",
|
|
124
|
-
key: "align-center",
|
|
125
|
-
label: "Align center",
|
|
126
|
-
isActive: (e) => e.isActive({ textAlign: "center" }),
|
|
127
|
-
run: (e) => e.chain().focus().setTextAlign("center").run()
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
icon: "align-right",
|
|
131
|
-
key: "align-right",
|
|
132
|
-
label: "Align right",
|
|
133
|
-
isActive: (e) => e.isActive({ textAlign: "right" }),
|
|
134
|
-
run: (e) => e.chain().focus().setTextAlign("right").run()
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
icon: "align-justify",
|
|
138
|
-
key: "justify",
|
|
139
|
-
label: "Justify",
|
|
140
|
-
isActive: (e) => e.isActive({ textAlign: "justify" }),
|
|
141
|
-
run: (e) => e.chain().focus().setTextAlign("justify").run()
|
|
142
|
-
},
|
|
143
|
-
"separator",
|
|
144
|
-
{
|
|
145
|
-
icon: "link",
|
|
146
|
-
key: "link",
|
|
147
|
-
label: "Link",
|
|
148
|
-
isActive: (e) => e.isActive("link"),
|
|
149
|
-
run: (e) => {
|
|
150
|
-
if (e.isActive("link")) {
|
|
151
|
-
e.chain().focus().unsetLink().run();
|
|
152
|
-
return;
|
|
153
|
-
}
|
|
154
|
-
const url = window.prompt("Link URL");
|
|
155
|
-
if (url) e.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
|
|
156
|
-
}
|
|
157
|
-
},
|
|
158
|
-
"separator",
|
|
159
|
-
{
|
|
160
|
-
icon: "table",
|
|
161
|
-
key: "insert-table",
|
|
162
|
-
label: "Insert table",
|
|
163
|
-
isActive: (e) => e.isActive("table"),
|
|
164
|
-
run: (e) => e.chain().focus().insertTable({
|
|
165
|
-
rows: 3,
|
|
166
|
-
cols: 3,
|
|
167
|
-
withHeaderRow: true
|
|
168
|
-
}).run()
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
icon: "columns-3",
|
|
172
|
-
key: "add-column",
|
|
173
|
-
label: "Add column",
|
|
174
|
-
isActive: () => false,
|
|
175
|
-
isDisabled: (e) => !e.can().addColumnAfter(),
|
|
176
|
-
run: (e) => e.chain().focus().addColumnAfter().run()
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
icon: "rows-3",
|
|
180
|
-
key: "add-row",
|
|
181
|
-
label: "Add row",
|
|
182
|
-
isActive: () => false,
|
|
183
|
-
isDisabled: (e) => !e.can().addRowAfter(),
|
|
184
|
-
run: (e) => e.chain().focus().addRowAfter().run()
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
icon: "trash-2",
|
|
188
|
-
key: "delete-table",
|
|
189
|
-
label: "Delete table",
|
|
190
|
-
isActive: () => false,
|
|
191
|
-
isDisabled: (e) => !e.can().deleteTable(),
|
|
192
|
-
run: (e) => e.chain().focus().deleteTable().run()
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
icon: "chevron-right",
|
|
196
|
-
key: "details",
|
|
197
|
-
label: "Details",
|
|
198
|
-
isActive: (e) => e.isActive("details"),
|
|
199
|
-
run: (e) => {
|
|
200
|
-
if (e.isActive("details")) {
|
|
201
|
-
e.chain().focus().unsetDetails().run();
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
e.chain().focus().setDetails().run();
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
];
|
|
208
|
-
var emojis = [
|
|
209
|
-
"😀",
|
|
210
|
-
"😅",
|
|
211
|
-
"😂",
|
|
212
|
-
"🥳",
|
|
213
|
-
"😎",
|
|
214
|
-
"🤔",
|
|
215
|
-
"👍",
|
|
216
|
-
"🙏",
|
|
217
|
-
"🔥",
|
|
218
|
-
"🎉",
|
|
219
|
-
"🚀",
|
|
220
|
-
"💡",
|
|
221
|
-
"✅",
|
|
222
|
-
"❌",
|
|
223
|
-
"⭐",
|
|
224
|
-
"❤️"
|
|
225
|
-
];
|
|
226
|
-
function EmojiPicker({ editor }) {
|
|
227
|
-
const { t } = useT("lattice");
|
|
228
|
-
const [open, setOpen] = useState(false);
|
|
229
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
230
|
-
className: "relative",
|
|
231
|
-
children: [/* @__PURE__ */ jsx("button", {
|
|
232
|
-
"aria-label": t("form.editor.insert-emoji", "Insert emoji"),
|
|
233
|
-
"data-test": "editor-emoji",
|
|
234
|
-
className: "inline-flex size-7 items-center justify-center rounded-lt-sm text-lt-muted-fg transition-colors hover:bg-lt-accent hover:text-lt-accent-fg [&_svg]:size-lt-icon-md",
|
|
235
|
-
onClick: () => setOpen((value) => !value),
|
|
236
|
-
onMouseDown: (event) => event.preventDefault(),
|
|
237
|
-
title: t("form.editor.insert-emoji", "Insert emoji"),
|
|
238
|
-
type: "button",
|
|
239
|
-
children: /* @__PURE__ */ jsx(Icon, { name: "smile" })
|
|
240
|
-
}), open && /* @__PURE__ */ jsx("div", {
|
|
241
|
-
className: "absolute z-lt-dropdown mt-1 grid grid-cols-8 gap-0.5 rounded-lt-sm border border-lt-border bg-lt-bg p-1 shadow-lt-md",
|
|
242
|
-
children: emojis.map((emoji) => /* @__PURE__ */ jsx("button", {
|
|
243
|
-
className: "inline-flex size-7 items-center justify-center rounded-lt-sm text-base hover:bg-lt-accent",
|
|
244
|
-
onClick: () => {
|
|
245
|
-
editor.chain().focus().insertContent(emoji).run();
|
|
246
|
-
setOpen(false);
|
|
247
|
-
},
|
|
248
|
-
onMouseDown: (event) => event.preventDefault(),
|
|
249
|
-
type: "button",
|
|
250
|
-
children: emoji
|
|
251
|
-
}, emoji))
|
|
252
|
-
})]
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
function Toolbar({ editor }) {
|
|
256
|
-
const { t } = useT("lattice");
|
|
257
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
258
|
-
className: "flex flex-wrap items-center gap-0.5 border-b border-lt-border p-1",
|
|
259
|
-
children: [
|
|
260
|
-
toolbar.map((item, index) => {
|
|
261
|
-
if (item === "separator") return /* @__PURE__ */ jsx("span", { className: "mx-1 h-5 w-px bg-lt-border" }, `sep-${index}`);
|
|
262
|
-
const label = t(`form.editor.${item.key}`, item.label);
|
|
263
|
-
return /* @__PURE__ */ jsx("button", {
|
|
264
|
-
"aria-label": label,
|
|
265
|
-
"aria-pressed": item.isActive(editor),
|
|
266
|
-
"data-test": `editor-${item.key}`,
|
|
267
|
-
className: cn("inline-flex size-7 items-center justify-center rounded-lt-sm text-lt-muted-fg transition-colors hover:bg-lt-accent hover:text-lt-accent-fg disabled:pointer-events-none disabled:opacity-40 [&_svg]:size-lt-icon-md", item.isActive(editor) && "bg-lt-accent text-lt-accent-fg"),
|
|
268
|
-
disabled: item.isDisabled?.(editor) ?? false,
|
|
269
|
-
onClick: () => item.run(editor),
|
|
270
|
-
onMouseDown: (event) => event.preventDefault(),
|
|
271
|
-
title: label,
|
|
272
|
-
type: "button",
|
|
273
|
-
children: /* @__PURE__ */ jsx(Icon, { name: item.icon })
|
|
274
|
-
}, item.key);
|
|
275
|
-
}),
|
|
276
|
-
/* @__PURE__ */ jsx("span", { className: "mx-1 h-5 w-px bg-lt-border" }),
|
|
277
|
-
/* @__PURE__ */ jsx(EmojiPicker, { editor })
|
|
278
|
-
]
|
|
279
|
-
});
|
|
280
|
-
}
|
|
281
|
-
var RichEditorComponent = ({ node }) => {
|
|
282
|
-
const { errors } = useFormContext();
|
|
283
|
-
const { hidden, required, readOnly, disabled } = useDependentField(node);
|
|
284
|
-
const { change, blur } = useFieldCommit();
|
|
285
|
-
const name = node.props.name;
|
|
286
|
-
const scope = useFieldScope();
|
|
287
|
-
const globalValue = useFormValue(name);
|
|
288
|
-
const storedValue = scope ? scope.getValue(name) : globalValue;
|
|
289
|
-
const domName = scope ? scope.scopedName(name) : name;
|
|
290
|
-
const errorKey = scope ? scope.errorKey(name) : name;
|
|
291
|
-
const locked = readOnly || disabled;
|
|
292
|
-
const initialContent = typeof storedValue === "object" && storedValue !== null ? storedValue : node.props.value ?? "";
|
|
293
|
-
const editor = useEditor({
|
|
294
|
-
extensions: [
|
|
295
|
-
StarterKit,
|
|
296
|
-
Highlight,
|
|
297
|
-
TextAlign.configure({ types: ["heading", "paragraph"] }),
|
|
298
|
-
Link.configure({ openOnClick: false }),
|
|
299
|
-
TableKit.configure({ table: { resizable: false } }),
|
|
300
|
-
Details,
|
|
301
|
-
DetailsSummary,
|
|
302
|
-
DetailsContent
|
|
303
|
-
],
|
|
304
|
-
content: initialContent,
|
|
305
|
-
editable: !locked,
|
|
306
|
-
immediatelyRender: false,
|
|
307
|
-
editorProps: { attributes: { class: "lattice-prose min-h-32 px-3 py-2 outline-none" } },
|
|
308
|
-
onUpdate: ({ editor: instance }) => {
|
|
309
|
-
change(name, instance.isEmpty ? null : instance.getJSON());
|
|
310
|
-
},
|
|
311
|
-
onBlur: () => {
|
|
312
|
-
blur(name);
|
|
313
|
-
}
|
|
314
|
-
});
|
|
315
|
-
useEffect(() => {
|
|
316
|
-
editor?.setEditable(!locked);
|
|
317
|
-
}, [editor, locked]);
|
|
318
|
-
if (hidden) return null;
|
|
319
|
-
const submittedValue = storedValue ? JSON.stringify(storedValue) : "";
|
|
320
|
-
return /* @__PURE__ */ jsxs(FormFieldFrame, {
|
|
321
|
-
error: errors[errorKey],
|
|
322
|
-
helperText: node.props.helperText ?? void 0,
|
|
323
|
-
tooltip: node.props.tooltip ?? void 0,
|
|
324
|
-
label: node.props.label ?? "",
|
|
325
|
-
name: domName,
|
|
326
|
-
required,
|
|
327
|
-
children: [/* @__PURE__ */ jsxs("div", {
|
|
328
|
-
className: cn("overflow-hidden rounded-lt-sm border border-lt-input bg-transparent shadow-lt-xs focus-within:border-lt-ring focus-within:ring-[3px] focus-within:ring-lt-ring/50", locked && "opacity-60"),
|
|
329
|
-
children: [editor && !locked && /* @__PURE__ */ jsx(Toolbar, { editor }), /* @__PURE__ */ jsx(EditorContent, { editor })]
|
|
330
|
-
}), /* @__PURE__ */ jsx("input", {
|
|
331
|
-
name: domName,
|
|
332
|
-
type: "hidden",
|
|
333
|
-
value: submittedValue
|
|
334
|
-
})]
|
|
335
|
-
});
|
|
336
|
-
};
|
|
4
|
+
var RichEditorField = lazy(() => import("./rich-editor-field.js"));
|
|
5
|
+
var RichEditorComponent = ({ children, node }) => /* @__PURE__ */ jsx(Suspense, {
|
|
6
|
+
fallback: null,
|
|
7
|
+
children: /* @__PURE__ */ jsx(RichEditorField, {
|
|
8
|
+
node,
|
|
9
|
+
children
|
|
10
|
+
})
|
|
11
|
+
});
|
|
337
12
|
//#endregion
|
|
338
13
|
export { RichEditorComponent };
|
|
339
14
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich-editor.js","names":[],"sources":["../../../../resources/js/form/components/fields/rich-editor.tsx"],"sourcesContent":["import { Icon } from \"@lattice-php/lattice/icons\";\nimport { Details, DetailsContent, DetailsSummary } from \"@tiptap/extension-details\";\nimport { Highlight } from \"@tiptap/extension-highlight\";\nimport { Link } from \"@tiptap/extension-link\";\nimport { TableKit } from \"@tiptap/extension-table\";\nimport { TextAlign } from \"@tiptap/extension-text-align\";\nimport { type Editor, EditorContent, useEditor } from \"@tiptap/react\";\nimport { StarterKit } from \"@tiptap/starter-kit\";\nimport { useEffect, useState } from \"react\";\nimport { cn } from \"@lattice-php/lattice/lib/utils\";\nimport { useT } from \"@lattice-php/lattice/i18n\";\nimport type { RendererComponent } from \"@lattice-php/lattice/core/types\";\nimport { FormFieldFrame } from \"../base/field\";\nimport { useFormContext } from \"../context\";\nimport { useFieldScope } from \"../field-scope\";\nimport { useDependentField } from \"../use-dependent-field\";\nimport { useFieldCommit } from \"../use-field-commit\";\nimport { useFormValue } from \"../values\";\n\ntype ToolbarItem =\n | \"separator\"\n | {\n icon: string;\n key: string;\n label: string;\n isActive: (editor: Editor) => boolean;\n isDisabled?: (editor: Editor) => boolean;\n run: (editor: Editor) => void;\n };\n\nconst toolbar: ToolbarItem[] = [\n {\n icon: \"bold\",\n key: \"bold\",\n label: \"Bold\",\n isActive: (e) => e.isActive(\"bold\"),\n run: (e) => e.chain().focus().toggleBold().run(),\n },\n {\n icon: \"italic\",\n key: \"italic\",\n label: \"Italic\",\n isActive: (e) => e.isActive(\"italic\"),\n run: (e) => e.chain().focus().toggleItalic().run(),\n },\n {\n icon: \"strikethrough\",\n key: \"strikethrough\",\n label: \"Strikethrough\",\n isActive: (e) => e.isActive(\"strike\"),\n run: (e) => e.chain().focus().toggleStrike().run(),\n },\n {\n icon: \"underline\",\n key: \"underline\",\n label: \"Underline\",\n isActive: (e) => e.isActive(\"underline\"),\n run: (e) => e.chain().focus().toggleUnderline().run(),\n },\n {\n icon: \"highlighter\",\n key: \"highlight\",\n label: \"Highlight\",\n isActive: (e) => e.isActive(\"highlight\"),\n run: (e) => e.chain().focus().toggleHighlight().run(),\n },\n \"separator\",\n {\n icon: \"heading-1\",\n key: \"heading-1\",\n label: \"Heading 1\",\n isActive: (e) => e.isActive(\"heading\", { level: 1 }),\n run: (e) => e.chain().focus().toggleHeading({ level: 1 }).run(),\n },\n {\n icon: \"heading-2\",\n key: \"heading-2\",\n label: \"Heading 2\",\n isActive: (e) => e.isActive(\"heading\", { level: 2 }),\n run: (e) => e.chain().focus().toggleHeading({ level: 2 }).run(),\n },\n {\n icon: \"heading-3\",\n key: \"heading-3\",\n label: \"Heading 3\",\n isActive: (e) => e.isActive(\"heading\", { level: 3 }),\n run: (e) => e.chain().focus().toggleHeading({ level: 3 }).run(),\n },\n \"separator\",\n {\n icon: \"list\",\n key: \"bullet-list\",\n label: \"Bullet list\",\n isActive: (e) => e.isActive(\"bulletList\"),\n run: (e) => e.chain().focus().toggleBulletList().run(),\n },\n {\n icon: \"list-ordered\",\n key: \"ordered-list\",\n label: \"Ordered list\",\n isActive: (e) => e.isActive(\"orderedList\"),\n run: (e) => e.chain().focus().toggleOrderedList().run(),\n },\n {\n icon: \"quote\",\n key: \"blockquote\",\n label: \"Blockquote\",\n isActive: (e) => e.isActive(\"blockquote\"),\n run: (e) => e.chain().focus().toggleBlockquote().run(),\n },\n {\n icon: \"code\",\n key: \"code-block\",\n label: \"Code block\",\n isActive: (e) => e.isActive(\"codeBlock\"),\n run: (e) => e.chain().focus().toggleCodeBlock().run(),\n },\n {\n icon: \"minus\",\n key: \"horizontal-rule\",\n label: \"Horizontal rule\",\n isActive: () => false,\n run: (e) => e.chain().focus().setHorizontalRule().run(),\n },\n \"separator\",\n {\n icon: \"align-left\",\n key: \"align-left\",\n label: \"Align left\",\n isActive: (e) => e.isActive({ textAlign: \"left\" }),\n run: (e) => e.chain().focus().setTextAlign(\"left\").run(),\n },\n {\n icon: \"align-center\",\n key: \"align-center\",\n label: \"Align center\",\n isActive: (e) => e.isActive({ textAlign: \"center\" }),\n run: (e) => e.chain().focus().setTextAlign(\"center\").run(),\n },\n {\n icon: \"align-right\",\n key: \"align-right\",\n label: \"Align right\",\n isActive: (e) => e.isActive({ textAlign: \"right\" }),\n run: (e) => e.chain().focus().setTextAlign(\"right\").run(),\n },\n {\n icon: \"align-justify\",\n key: \"justify\",\n label: \"Justify\",\n isActive: (e) => e.isActive({ textAlign: \"justify\" }),\n run: (e) => e.chain().focus().setTextAlign(\"justify\").run(),\n },\n \"separator\",\n {\n icon: \"link\",\n key: \"link\",\n label: \"Link\",\n isActive: (e) => e.isActive(\"link\"),\n run: (e) => {\n if (e.isActive(\"link\")) {\n e.chain().focus().unsetLink().run();\n return;\n }\n const url = window.prompt(\"Link URL\");\n if (url) {\n e.chain().focus().extendMarkRange(\"link\").setLink({ href: url }).run();\n }\n },\n },\n \"separator\",\n {\n icon: \"table\",\n key: \"insert-table\",\n label: \"Insert table\",\n isActive: (e) => e.isActive(\"table\"),\n run: (e) => e.chain().focus().insertTable({ rows: 3, cols: 3, withHeaderRow: true }).run(),\n },\n {\n icon: \"columns-3\",\n key: \"add-column\",\n label: \"Add column\",\n isActive: () => false,\n isDisabled: (e) => !e.can().addColumnAfter(),\n run: (e) => e.chain().focus().addColumnAfter().run(),\n },\n {\n icon: \"rows-3\",\n key: \"add-row\",\n label: \"Add row\",\n isActive: () => false,\n isDisabled: (e) => !e.can().addRowAfter(),\n run: (e) => e.chain().focus().addRowAfter().run(),\n },\n {\n icon: \"trash-2\",\n key: \"delete-table\",\n label: \"Delete table\",\n isActive: () => false,\n isDisabled: (e) => !e.can().deleteTable(),\n run: (e) => e.chain().focus().deleteTable().run(),\n },\n {\n icon: \"chevron-right\",\n key: \"details\",\n label: \"Details\",\n isActive: (e) => e.isActive(\"details\"),\n run: (e) => {\n if (e.isActive(\"details\")) {\n e.chain().focus().unsetDetails().run();\n return;\n }\n e.chain().focus().setDetails().run();\n },\n },\n];\n\nconst emojis = [\n \"😀\",\n \"😅\",\n \"😂\",\n \"🥳\",\n \"😎\",\n \"🤔\",\n \"👍\",\n \"🙏\",\n \"🔥\",\n \"🎉\",\n \"🚀\",\n \"💡\",\n \"✅\",\n \"❌\",\n \"⭐\",\n \"❤️\",\n];\n\nfunction EmojiPicker({ editor }: { editor: Editor }) {\n const { t } = useT(\"lattice\");\n const [open, setOpen] = useState(false);\n\n return (\n <div className=\"relative\">\n <button\n aria-label={t(\"form.editor.insert-emoji\", \"Insert emoji\")}\n data-test=\"editor-emoji\"\n className=\"inline-flex size-7 items-center justify-center rounded-lt-sm text-lt-muted-fg transition-colors hover:bg-lt-accent hover:text-lt-accent-fg [&_svg]:size-lt-icon-md\"\n onClick={() => setOpen((value) => !value)}\n onMouseDown={(event) => event.preventDefault()}\n title={t(\"form.editor.insert-emoji\", \"Insert emoji\")}\n type=\"button\"\n >\n <Icon name=\"smile\" />\n </button>\n {open && (\n <div className=\"absolute z-lt-dropdown mt-1 grid grid-cols-8 gap-0.5 rounded-lt-sm border border-lt-border bg-lt-bg p-1 shadow-lt-md\">\n {emojis.map((emoji) => (\n <button\n className=\"inline-flex size-7 items-center justify-center rounded-lt-sm text-base hover:bg-lt-accent\"\n key={emoji}\n onClick={() => {\n editor.chain().focus().insertContent(emoji).run();\n setOpen(false);\n }}\n onMouseDown={(event) => event.preventDefault()}\n type=\"button\"\n >\n {emoji}\n </button>\n ))}\n </div>\n )}\n </div>\n );\n}\n\nfunction Toolbar({ editor }: { editor: Editor }) {\n const { t } = useT(\"lattice\");\n\n return (\n <div className=\"flex flex-wrap items-center gap-0.5 border-b border-lt-border p-1\">\n {toolbar.map((item, index) => {\n if (item === \"separator\") {\n // eslint-disable-next-line react/no-array-index-key\n return <span key={`sep-${index}`} className=\"mx-1 h-5 w-px bg-lt-border\" />;\n }\n\n const label = t(`form.editor.${item.key}`, item.label);\n\n return (\n <button\n aria-label={label}\n aria-pressed={item.isActive(editor)}\n data-test={`editor-${item.key}`}\n className={cn(\n \"inline-flex size-7 items-center justify-center rounded-lt-sm text-lt-muted-fg transition-colors hover:bg-lt-accent hover:text-lt-accent-fg disabled:pointer-events-none disabled:opacity-40 [&_svg]:size-lt-icon-md\",\n item.isActive(editor) && \"bg-lt-accent text-lt-accent-fg\",\n )}\n disabled={item.isDisabled?.(editor) ?? false}\n key={item.key}\n // Keep focus in the editor so toolbar clicks don't blur it (which would\n // otherwise trigger a precognition request).\n onClick={() => item.run(editor)}\n onMouseDown={(event) => event.preventDefault()}\n title={label}\n type=\"button\"\n >\n <Icon name={item.icon} />\n </button>\n );\n })}\n <span className=\"mx-1 h-5 w-px bg-lt-border\" />\n <EmojiPicker editor={editor} />\n </div>\n );\n}\n\nexport const RichEditorComponent: RendererComponent<\"field.rich-editor\"> = ({ node }) => {\n const { errors } = useFormContext();\n const { hidden, required, readOnly, disabled } = useDependentField(node);\n const { change, blur } = useFieldCommit();\n const name = node.props.name;\n const scope = useFieldScope();\n const globalValue = useFormValue(name);\n const storedValue = scope ? scope.getValue(name) : globalValue;\n const domName = scope ? scope.scopedName(name) : name;\n const errorKey = scope ? scope.errorKey(name) : name;\n const locked = readOnly || disabled;\n const initialContent =\n typeof storedValue === \"object\" && storedValue !== null\n ? (storedValue as object)\n : ((node.props.value as object | undefined) ?? \"\");\n\n const editor = useEditor({\n extensions: [\n StarterKit,\n Highlight,\n TextAlign.configure({ types: [\"heading\", \"paragraph\"] }),\n Link.configure({ openOnClick: false }),\n TableKit.configure({ table: { resizable: false } }),\n Details,\n DetailsSummary,\n DetailsContent,\n ],\n content: initialContent,\n editable: !locked,\n immediatelyRender: false,\n editorProps: {\n attributes: {\n class: \"lattice-prose min-h-32 px-3 py-2 outline-none\",\n },\n },\n onUpdate: ({ editor: instance }) => {\n change(name, instance.isEmpty ? null : instance.getJSON());\n },\n onBlur: () => {\n blur(name);\n },\n });\n\n useEffect(() => {\n editor?.setEditable(!locked);\n }, [editor, locked]);\n\n if (hidden) {\n return null;\n }\n\n const submittedValue = storedValue ? JSON.stringify(storedValue) : \"\";\n\n return (\n <FormFieldFrame\n error={errors[errorKey]}\n helperText={node.props.helperText ?? undefined}\n tooltip={node.props.tooltip ?? undefined}\n label={node.props.label ?? \"\"}\n name={domName}\n required={required}\n >\n <div\n className={cn(\n \"overflow-hidden rounded-lt-sm border border-lt-input bg-transparent shadow-lt-xs focus-within:border-lt-ring focus-within:ring-[3px] focus-within:ring-lt-ring/50\",\n locked && \"opacity-60\",\n )}\n >\n {editor && !locked && <Toolbar editor={editor} />}\n <EditorContent editor={editor} />\n </div>\n <input name={domName} type=\"hidden\" value={submittedValue} />\n </FormFieldFrame>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8BA,IAAM,UAAyB;CAC7B;EACE,MAAM;EACN,KAAK;EACL,OAAO;EACP,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,OAAO,EAAE,WAAW,MAAM,EAAE,CAAC;GAClD;GACA;GACA;EACF;EACA,SAAS;EACT,UAAU,CAAC;EACX,mBAAmB;EACnB,aAAa,EACX,YAAY,EACV,OAAO,gDACT,EACF;EACA,WAAW,EAAE,QAAQ,eAAe;GAClC,OAAO,MAAM,SAAS,UAAU,OAAO,SAAS,QAAQ,CAAC;EAC3D;EACA,cAAc;GACZ,KAAK,IAAI;EACX;CACF,CAAC;CAED,gBAAgB;EACd,QAAQ,YAAY,CAAC,MAAM;CAC7B,GAAG,CAAC,QAAQ,MAAM,CAAC;CAEnB,IAAI,QACF,OAAO;CAGT,MAAM,iBAAiB,cAAc,KAAK,UAAU,WAAW,IAAI;CAEnE,OACE,qBAAC,gBAAD;EACE,OAAO,OAAO;EACd,YAAY,KAAK,MAAM,cAAc,KAAA;EACrC,SAAS,KAAK,MAAM,WAAW,KAAA;EAC/B,OAAO,KAAK,MAAM,SAAS;EAC3B,MAAM;EACI;YANZ,CAQE,qBAAC,OAAD;GACE,WAAW,GACT,qKACA,UAAU,YACZ;aAJF,CAMG,UAAU,CAAC,UAAU,oBAAC,SAAD,EAAiB,OAAS,CAAA,GAChD,oBAAC,eAAD,EAAuB,OAAS,CAAA,CAC7B;MACL,oBAAC,SAAD;GAAO,MAAM;GAAS,MAAK;GAAS,OAAO;EAAiB,CAAA,CAC9C;;AAEpB"}
|
|
1
|
+
{"version":3,"file":"rich-editor.js","names":[],"sources":["../../../../resources/js/form/components/fields/rich-editor.tsx"],"sourcesContent":["import { lazy, Suspense } from \"react\";\nimport type { RendererComponent, RendererComponentModule } from \"@lattice-php/lattice/core/types\";\n\nconst RichEditorField = lazy(\n () => import(\"./rich-editor-field\") as unknown as Promise<RendererComponentModule>,\n);\n\nexport const RichEditorComponent: RendererComponent<\"field.rich-editor\"> = ({ children, node }) => (\n <Suspense fallback={null}>\n <RichEditorField node={node}>{children}</RichEditorField>\n </Suspense>\n);\n"],"mappings":";;;AAGA,IAAM,kBAAkB,WAChB,OAAO,yBACf;AAEA,IAAa,uBAA+D,EAAE,UAAU,WACtF,oBAAC,UAAD;CAAU,UAAU;WAClB,oBAAC,iBAAD;EAAuB;EAAO;CAA0B,CAAA;AAChD,CAAA"}
|
|
@@ -2,12 +2,12 @@ import { Icon } from "../../../icons/sprite.js";
|
|
|
2
2
|
import { RenderNode } from "../../../core/renderer.js";
|
|
3
3
|
import { useT } from "../../../i18n/instance.js";
|
|
4
4
|
import { FieldScopeProvider } from "../field-scope.js";
|
|
5
|
-
import "../../../core/column-sizing.js";
|
|
6
|
-
import { useColumnResizing } from "../../../core/use-column-resizing.js";
|
|
7
5
|
import { TableCellProvider } from "../row-layout-context.js";
|
|
8
6
|
import { buildRowActions } from "./row-action-menu.js";
|
|
9
7
|
import { RowActions } from "./row-actions.js";
|
|
10
8
|
import { RowButton, RowItem } from "./row-item.js";
|
|
9
|
+
import "../../../core/column-sizing.js";
|
|
10
|
+
import { useColumnResizing } from "../../../core/use-column-resizing.js";
|
|
11
11
|
import { memo, useEffect, useMemo, useState } from "react";
|
|
12
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
//#region resources/js/form/components/fields/table-rows.tsx
|
package/dist/form/index.js
CHANGED
|
@@ -1,35 +1,43 @@
|
|
|
1
|
-
import { createPlugin,
|
|
2
|
-
import {
|
|
1
|
+
import { createPlugin, eagerComponent } from "../core/registry.js";
|
|
2
|
+
import { BuilderComponent } from "./components/fields/builder.js";
|
|
3
|
+
import { CheckboxComponent } from "./components/fields/checkbox.js";
|
|
4
|
+
import { ChoiceComponent } from "./components/fields/choice.js";
|
|
5
|
+
import { DateInputComponent } from "./components/fields/date-input.js";
|
|
6
|
+
import { DateTimeInputComponent } from "./components/fields/date-time-input.js";
|
|
7
|
+
import { FileUploadComponent } from "./components/fields/file-upload.js";
|
|
8
|
+
import { FormComponent } from "./components/form.js";
|
|
9
|
+
import { HiddenInputComponent } from "./components/fields/hidden-input.js";
|
|
10
|
+
import { NumberInputComponent } from "./components/fields/number-input.js";
|
|
11
|
+
import { OtpInputComponent } from "./components/fields/otp-input.js";
|
|
12
|
+
import { PasswordInputComponent } from "./components/fields/password-input.js";
|
|
13
|
+
import { RepeaterComponent } from "./components/fields/repeater.js";
|
|
14
|
+
import { SelectComponent } from "./components/fields/select.js";
|
|
15
|
+
import { TextareaComponent } from "./components/fields/textarea.js";
|
|
16
|
+
import { TextInputComponent } from "./components/fields/text-input.js";
|
|
17
|
+
import { TimeInputComponent } from "./components/fields/time-input.js";
|
|
18
|
+
import { ToggleComponent } from "./components/fields/toggle.js";
|
|
19
|
+
import { RichEditorComponent } from "./components/fields/rich-editor.js";
|
|
3
20
|
//#region resources/js/form/index.ts
|
|
4
|
-
var loadFormComponents = () => import("./components/index.js");
|
|
5
|
-
function loadFormComponent(name) {
|
|
6
|
-
return async () => {
|
|
7
|
-
return { default: (await loadFormComponents())[name] };
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
21
|
var formComponents = createPlugin({
|
|
11
22
|
components: {
|
|
12
|
-
form:
|
|
13
|
-
"field.builder":
|
|
14
|
-
"field.checkbox":
|
|
15
|
-
"field.choice":
|
|
16
|
-
"field.date-input":
|
|
17
|
-
"field.date-time-input":
|
|
18
|
-
"field.file-upload":
|
|
19
|
-
"field.hidden-input":
|
|
20
|
-
"field.number-input":
|
|
21
|
-
"field.otp":
|
|
22
|
-
"field.password-input":
|
|
23
|
-
"field.repeater":
|
|
24
|
-
"field.rich-editor":
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"field.
|
|
29
|
-
"field.
|
|
30
|
-
"field.text-input": lazyComponent(loadFormComponent("TextInputComponent")),
|
|
31
|
-
"field.time-input": lazyComponent(loadFormComponent("TimeInputComponent")),
|
|
32
|
-
"field.toggle": lazyComponent(loadFormComponent("ToggleComponent"))
|
|
23
|
+
form: eagerComponent(FormComponent),
|
|
24
|
+
"field.builder": eagerComponent(BuilderComponent),
|
|
25
|
+
"field.checkbox": eagerComponent(CheckboxComponent),
|
|
26
|
+
"field.choice": eagerComponent(ChoiceComponent),
|
|
27
|
+
"field.date-input": eagerComponent(DateInputComponent),
|
|
28
|
+
"field.date-time-input": eagerComponent(DateTimeInputComponent),
|
|
29
|
+
"field.file-upload": eagerComponent(FileUploadComponent),
|
|
30
|
+
"field.hidden-input": eagerComponent(HiddenInputComponent),
|
|
31
|
+
"field.number-input": eagerComponent(NumberInputComponent),
|
|
32
|
+
"field.otp": eagerComponent(OtpInputComponent),
|
|
33
|
+
"field.password-input": eagerComponent(PasswordInputComponent),
|
|
34
|
+
"field.repeater": eagerComponent(RepeaterComponent),
|
|
35
|
+
"field.rich-editor": eagerComponent(RichEditorComponent),
|
|
36
|
+
"field.select": eagerComponent(SelectComponent),
|
|
37
|
+
"field.textarea": eagerComponent(TextareaComponent),
|
|
38
|
+
"field.text-input": eagerComponent(TextInputComponent),
|
|
39
|
+
"field.time-input": eagerComponent(TimeInputComponent),
|
|
40
|
+
"field.toggle": eagerComponent(ToggleComponent)
|
|
33
41
|
},
|
|
34
42
|
name: "lattice/form"
|
|
35
43
|
});
|
package/dist/form/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../resources/js/form/index.ts"],"sourcesContent":["import { createPlugin,
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../resources/js/form/index.ts"],"sourcesContent":["import { createPlugin, eagerComponent } from \"@lattice-php/lattice/core/registry\";\nimport {\n BuilderComponent,\n CheckboxComponent,\n ChoiceComponent,\n DateInputComponent,\n DateTimeInputComponent,\n FileUploadComponent,\n FormComponent,\n HiddenInputComponent,\n NumberInputComponent,\n OtpInputComponent,\n PasswordInputComponent,\n RepeaterComponent,\n SelectComponent,\n TextareaComponent,\n TextInputComponent,\n TimeInputComponent,\n ToggleComponent,\n} from \"./components\";\nimport { RichEditorComponent } from \"./components/fields/rich-editor\";\n\nexport const formComponents = createPlugin({\n components: {\n form: eagerComponent(FormComponent),\n \"field.builder\": eagerComponent(BuilderComponent),\n \"field.checkbox\": eagerComponent(CheckboxComponent),\n \"field.choice\": eagerComponent(ChoiceComponent),\n \"field.date-input\": eagerComponent(DateInputComponent),\n \"field.date-time-input\": eagerComponent(DateTimeInputComponent),\n \"field.file-upload\": eagerComponent(FileUploadComponent),\n \"field.hidden-input\": eagerComponent(HiddenInputComponent),\n \"field.number-input\": eagerComponent(NumberInputComponent),\n \"field.otp\": eagerComponent(OtpInputComponent),\n \"field.password-input\": eagerComponent(PasswordInputComponent),\n \"field.repeater\": eagerComponent(RepeaterComponent),\n \"field.rich-editor\": eagerComponent(RichEditorComponent),\n \"field.select\": eagerComponent(SelectComponent),\n \"field.textarea\": eagerComponent(TextareaComponent),\n \"field.text-input\": eagerComponent(TextInputComponent),\n \"field.time-input\": eagerComponent(TimeInputComponent),\n \"field.toggle\": eagerComponent(ToggleComponent),\n },\n name: \"lattice/form\",\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsBA,IAAa,iBAAiB,aAAa;CACzC,YAAY;EACV,MAAM,eAAe,aAAa;EAClC,iBAAiB,eAAe,gBAAgB;EAChD,kBAAkB,eAAe,iBAAiB;EAClD,gBAAgB,eAAe,eAAe;EAC9C,oBAAoB,eAAe,kBAAkB;EACrD,yBAAyB,eAAe,sBAAsB;EAC9D,qBAAqB,eAAe,mBAAmB;EACvD,sBAAsB,eAAe,oBAAoB;EACzD,sBAAsB,eAAe,oBAAoB;EACzD,aAAa,eAAe,iBAAiB;EAC7C,wBAAwB,eAAe,sBAAsB;EAC7D,kBAAkB,eAAe,iBAAiB;EAClD,qBAAqB,eAAe,mBAAmB;EACvD,gBAAgB,eAAe,eAAe;EAC9C,kBAAkB,eAAe,iBAAiB;EAClD,oBAAoB,eAAe,kBAAkB;EACrD,oBAAoB,eAAe,kBAAkB;EACrD,gBAAgB,eAAe,eAAe;CAChD;CACA,MAAM;AACR,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { registry } from './registry';
|
|
2
2
|
export { useChat } from './chat/use-chat';
|
|
3
|
-
export {
|
|
3
|
+
export { chatComponents } from './chat';
|
|
4
4
|
export { getActionEffects, isActionEffect, dispatchEffects, dispatchActionError, } from './effects/dispatch';
|
|
5
5
|
export { useEffectDispatcher } from './effects/use-effect-dispatcher';
|
|
6
6
|
export { builtinEffectHandlers, effectHandler, mergeEffectHandlers } from './effects/registry';
|
package/dist/index.js
CHANGED
|
@@ -22,10 +22,10 @@ import { RealtimeListeners } from "./realtime/listeners.js";
|
|
|
22
22
|
import { createLayoutResolver, createPageResolver, pageComponentName, withVisitHeaders } from "./inertia.js";
|
|
23
23
|
import { Toaster } from "./toast/toaster.js";
|
|
24
24
|
import { useChat } from "./chat/use-chat.js";
|
|
25
|
-
import {
|
|
25
|
+
import { chatComponents } from "./chat/index.js";
|
|
26
26
|
import { copyToClipboard, useClipboard } from "./clipboard/index.js";
|
|
27
|
-
import {
|
|
27
|
+
import { columnCell } from "./table/registry.js";
|
|
28
|
+
import { registry } from "./registry.js";
|
|
28
29
|
import { createLatticeApp } from "./create-app.js";
|
|
29
30
|
import { Provider } from "./provider.js";
|
|
30
|
-
|
|
31
|
-
export { Callouts, EventBridge, Icon, IconRenderer, IconRendererProvider, LATTICE_EVENT, LATTICE_REF_HEADER, OutletContext, Provider, RealtimeListeners, Renderer, SchemaLayout, CollapsedContext as SidebarCollapsedContext, SpriteProvider, Toaster, builtinEffectHandlers, chatPlugin, columnCell, copyToClipboard, createLatticeApp, createLayoutResolver, createPageResolver, createPlugin, createRegistry, dispatchActionError, dispatchEffects, eagerComponent, effectHandler, extendRegistry, getActionEffects, initializeTheme, isActionEffect, layoutComponents, lazyComponent, lazyRegistry, mergeEffectHandlers, onCallout, onToast, pageComponentName, lazyRegistry as registry, showToast, updateAppearance, useAppearance, useChat, useClipboard, useColumnRegistry, useComponentRegistry, useEffectDispatcher, useCollapsed as useSidebarCollapsed, withHeaders, withRefHeader, withVisitHeaders };
|
|
31
|
+
export { Callouts, EventBridge, Icon, IconRenderer, IconRendererProvider, LATTICE_EVENT, LATTICE_REF_HEADER, OutletContext, Provider, RealtimeListeners, Renderer, SchemaLayout, CollapsedContext as SidebarCollapsedContext, SpriteProvider, Toaster, builtinEffectHandlers, chatComponents, columnCell, copyToClipboard, createLatticeApp, createLayoutResolver, createPageResolver, createPlugin, createRegistry, dispatchActionError, dispatchEffects, eagerComponent, effectHandler, extendRegistry, getActionEffects, initializeTheme, isActionEffect, layoutComponents, lazyComponent, mergeEffectHandlers, onCallout, onToast, pageComponentName, registry, showToast, updateAppearance, useAppearance, useChat, useClipboard, useColumnRegistry, useComponentRegistry, useEffectDispatcher, useCollapsed as useSidebarCollapsed, withHeaders, withRefHeader, withVisitHeaders };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const notificationsComponents: import('../core/registry').Plugin;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createPlugin, eagerComponent } from "../core/registry.js";
|
|
2
2
|
import NotificationsComponent from "./components/notifications.js";
|
|
3
3
|
//#region resources/js/notifications/index.ts
|
|
4
|
-
var
|
|
4
|
+
var notificationsComponents = createPlugin({
|
|
5
5
|
name: "lattice/notifications",
|
|
6
6
|
components: { notifications: eagerComponent(NotificationsComponent) }
|
|
7
7
|
});
|
|
8
8
|
//#endregion
|
|
9
|
-
export {
|
|
9
|
+
export { notificationsComponents };
|
|
10
10
|
|
|
11
11
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../resources/js/notifications/index.ts"],"sourcesContent":["import { createPlugin, eagerComponent } from \"@lattice-php/lattice/core/registry\";\nimport NotificationsComponent from \"./components/notifications\";\n\nexport const
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../resources/js/notifications/index.ts"],"sourcesContent":["import { createPlugin, eagerComponent } from \"@lattice-php/lattice/core/registry\";\nimport NotificationsComponent from \"./components/notifications\";\n\nexport const notificationsComponents = createPlugin({\n name: \"lattice/notifications\",\n components: {\n notifications: eagerComponent(NotificationsComponent),\n },\n});\n"],"mappings":";;;AAGA,IAAa,0BAA0B,aAAa;CAClD,MAAM;CACN,YAAY,EACV,eAAe,eAAe,sBAAsB,EACtD;AACF,CAAC"}
|
package/dist/provider.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { setDefaultRegistry, useColumnRegistry, useComponentRegistry, useEffectHandlerRegistry } from "./core/registry-context.js";
|
|
2
2
|
import { ProviderBase } from "./provider-base.js";
|
|
3
|
-
import {
|
|
3
|
+
import { registry } from "./registry.js";
|
|
4
4
|
import { jsx } from "react/jsx-runtime";
|
|
5
5
|
//#region resources/js/provider.tsx
|
|
6
|
-
setDefaultRegistry(
|
|
7
|
-
function Provider({ registry =
|
|
6
|
+
setDefaultRegistry(registry);
|
|
7
|
+
function Provider({ registry: registry$1 = registry, ...props }) {
|
|
8
8
|
return /* @__PURE__ */ jsx(ProviderBase, {
|
|
9
9
|
...props,
|
|
10
|
-
registry
|
|
10
|
+
registry: registry$1
|
|
11
11
|
});
|
|
12
12
|
}
|
|
13
13
|
//#endregion
|
package/dist/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","names":[],"sources":["../resources/js/provider.tsx"],"sourcesContent":["import { registry as defaultRegistry } from \"./registry\";\nimport type { Registry } from \"./core/registry\";\nimport { setDefaultRegistry } from \"./core/registry-context\";\nimport { ProviderBase, type ProviderBaseProps } from \"./provider-base\";\n\n// Register the default registry so selectors work outside <Provider>.\n// This module is always loaded after registry.ts finishes, so defaultRegistry\n// is guaranteed to be defined here.\nsetDefaultRegistry(defaultRegistry);\n\ntype ProviderProps = Omit<ProviderBaseProps, \"registry\"> & {\n registry?: Registry;\n};\n\nexport function Provider({ registry = defaultRegistry, ...props }: ProviderProps) {\n return <ProviderBase {...props} registry={registry} />;\n}\n\nexport {\n useComponentRegistry,\n useColumnRegistry,\n useEffectHandlerRegistry,\n} from \"./core/registry-context\";\n"],"mappings":";;;;;AAQA,mBAAmB,
|
|
1
|
+
{"version":3,"file":"provider.js","names":[],"sources":["../resources/js/provider.tsx"],"sourcesContent":["import { registry as defaultRegistry } from \"./registry\";\nimport type { Registry } from \"./core/registry\";\nimport { setDefaultRegistry } from \"./core/registry-context\";\nimport { ProviderBase, type ProviderBaseProps } from \"./provider-base\";\n\n// Register the default registry so selectors work outside <Provider>.\n// This module is always loaded after registry.ts finishes, so defaultRegistry\n// is guaranteed to be defined here.\nsetDefaultRegistry(defaultRegistry);\n\ntype ProviderProps = Omit<ProviderBaseProps, \"registry\"> & {\n registry?: Registry;\n};\n\nexport function Provider({ registry = defaultRegistry, ...props }: ProviderProps) {\n return <ProviderBase {...props} registry={registry} />;\n}\n\nexport {\n useComponentRegistry,\n useColumnRegistry,\n useEffectHandlerRegistry,\n} from \"./core/registry-context\";\n"],"mappings":";;;;;AAQA,mBAAmB,QAAe;AAMlC,SAAgB,SAAS,EAAE,UAAA,aAAW,UAAiB,GAAG,SAAwB;CAChF,OAAO,oBAAC,cAAD;EAAc,GAAI;EAAiB,UAAA;CAAW,CAAA;AACvD"}
|
package/dist/registry.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const registry: import('./core/registry').Registry;
|
package/dist/registry.js
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { createRegistry } from "./core/registry.js";
|
|
2
|
+
import { layoutComponents } from "./layout/components.js";
|
|
3
|
+
import { actionComponents } from "./action/index.js";
|
|
4
|
+
import { chatComponents } from "./chat/index.js";
|
|
5
|
+
import { coreComponents } from "./core/components/index.js";
|
|
6
|
+
import { formComponents } from "./form/index.js";
|
|
7
|
+
import { notificationsComponents } from "./notifications/index.js";
|
|
8
|
+
import { remoteComponents } from "./remote/index.js";
|
|
9
|
+
import { tableComponents } from "./table/index.js";
|
|
10
|
+
//#region resources/js/registry.ts
|
|
11
|
+
var registry = createRegistry(coreComponents, actionComponents, formComponents, layoutComponents, tableComponents, chatComponents, notificationsComponents, remoteComponents);
|
|
12
|
+
//#endregion
|
|
13
|
+
export { registry };
|
|
14
|
+
|
|
15
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","names":[],"sources":["../resources/js/registry.ts"],"sourcesContent":["import { createRegistry } from \"@lattice-php/lattice/core/registry\";\nimport { actionComponents } from \"./action\";\nimport { chatComponents } from \"./chat\";\nimport { coreComponents } from \"./core/components\";\nimport { formComponents } from \"./form\";\nimport { layoutComponents } from \"./layout\";\nimport { notificationsComponents } from \"./notifications\";\nimport { remoteComponents } from \"./remote\";\nimport { tableComponents } from \"./table\";\n\nexport const registry = createRegistry(\n coreComponents,\n actionComponents,\n formComponents,\n layoutComponents,\n tableComponents,\n chatComponents,\n notificationsComponents,\n remoteComponents,\n);\n"],"mappings":";;;;;;;;;;AAUA,IAAa,WAAW,eACtB,gBACA,kBACA,gBACA,kBACA,iBACA,gBACA,yBACA,gBACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useLocale } from "../../../i18n/locale.js";
|
|
2
|
+
import { formatCell } from "../../format.js";
|
|
2
3
|
import { numericValue } from "../../../format/numeric.js";
|
|
3
4
|
import { formatNumber } from "../../../format/number.js";
|
|
4
|
-
import { formatCell } from "../../format.js";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
//#region resources/js/table/components/cells/money-cell.tsx
|
|
7
7
|
var MoneyCell = ({ column, props, row, value }) => {
|