@cfast/ui 0.0.1 → 0.1.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/llms.txt +159 -0
- package/package.json +26 -18
- package/LICENSE +0 -21
- package/dist/chunk-755IRYDN.js +0 -941
- package/dist/chunk-7SNK37GF.js +0 -418
- package/dist/chunk-ASMYTWTR.js +0 -356
- package/dist/chunk-B2XXH5V4.js +0 -66
- package/dist/chunk-BQMXYYEV.js +0 -348
- package/dist/chunk-DTKBXCTU.js +0 -211
- package/dist/chunk-EYIBATYR.js +0 -33
- package/dist/chunk-FPZAQ2YQ.js +0 -474
- package/dist/chunk-G2OU4BYC.js +0 -205
- package/dist/chunk-JUNLQJ6H.js +0 -1013
- package/dist/chunk-NRGMW3JA.js +0 -906
- package/dist/chunk-Q6FPL2OJ.js +0 -1086
- package/dist/chunk-QHWAGKNW.js +0 -456
- package/dist/chunk-QZT62CGJ.js +0 -924
- package/dist/chunk-RESL4IJJ.js +0 -112
- package/dist/chunk-UDCWQUTR.js +0 -221
- package/dist/chunk-UE7PZOIJ.js +0 -11
- package/dist/chunk-UTZTHGNE.js +0 -84
- package/dist/chunk-UVRXMOX5.js +0 -439
- package/dist/chunk-XFD3N2D4.js +0 -161
- package/dist/client-CXIHCQtA.d.ts +0 -274
- package/dist/permission-gate-apt9T9Mu.d.ts +0 -1256
- package/dist/types-1bAiH2uK.d.ts +0 -392
- package/dist/types-BX6u5sAd.d.ts +0 -403
- package/dist/types-BpdY7w5l.d.ts +0 -403
- package/dist/types-BrepeVp8.d.ts +0 -403
- package/dist/types-BvAqMZhn.d.ts +0 -403
- package/dist/types-C74nSscq.d.ts +0 -403
- package/dist/types-DD1Cpx8F.d.ts +0 -403
- package/dist/types-DHUhQwJn.d.ts +0 -403
- package/dist/types-DZSJNt_M.d.ts +0 -392
- package/dist/types-DaaJiIjW.d.ts +0 -391
- package/dist/types-LUpWJwps.d.ts +0 -403
- package/dist/types-a7zVU6WE.d.ts +0 -394
- package/dist/types-biJTHMcH.d.ts +0 -403
- package/dist/types-ow_qSEYJ.d.ts +0 -392
- package/dist/types-wnLasZaB.d.ts +0 -1234
package/dist/chunk-QHWAGKNW.js
DELETED
|
@@ -1,456 +0,0 @@
|
|
|
1
|
-
// src/plugin.tsx
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
3
|
-
|
|
4
|
-
// src/headless-defaults.tsx
|
|
5
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
-
var headlessDefaults = {
|
|
7
|
-
// Actions
|
|
8
|
-
button: ({ children, onClick, disabled, loading, type }) => /* @__PURE__ */ jsx("button", { onClick, disabled: disabled || loading, type: type ?? "button", children: loading ? "Loading..." : children }),
|
|
9
|
-
tooltip: ({ children, title }) => /* @__PURE__ */ jsx("span", { title, children }),
|
|
10
|
-
confirmDialog: ({ open, onClose, onConfirm, title, description, confirmLabel, cancelLabel }) => open ? /* @__PURE__ */ jsxs("dialog", { open: true, children: [
|
|
11
|
-
/* @__PURE__ */ jsx("p", { children: /* @__PURE__ */ jsx("strong", { children: title }) }),
|
|
12
|
-
description ? /* @__PURE__ */ jsx("p", { children: description }) : null,
|
|
13
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
14
|
-
/* @__PURE__ */ jsx("button", { onClick: onClose, children: cancelLabel ?? "Cancel" }),
|
|
15
|
-
/* @__PURE__ */ jsx("button", { onClick: onConfirm, children: confirmLabel ?? "Confirm" })
|
|
16
|
-
] })
|
|
17
|
-
] }) : null,
|
|
18
|
-
// Data display
|
|
19
|
-
table: ({ children }) => /* @__PURE__ */ jsx("table", { children }),
|
|
20
|
-
tableHead: ({ children }) => /* @__PURE__ */ jsx("thead", { children }),
|
|
21
|
-
tableBody: ({ children }) => /* @__PURE__ */ jsx("tbody", { children }),
|
|
22
|
-
tableRow: ({ children, onClick }) => /* @__PURE__ */ jsx("tr", { onClick, children }),
|
|
23
|
-
tableCell: ({ children, header, sortable, sortDirection, onSort }) => {
|
|
24
|
-
const Tag = header ? "th" : "td";
|
|
25
|
-
return /* @__PURE__ */ jsxs(
|
|
26
|
-
Tag,
|
|
27
|
-
{
|
|
28
|
-
onClick: sortable ? onSort : void 0,
|
|
29
|
-
style: sortable ? { cursor: "pointer" } : void 0,
|
|
30
|
-
children: [
|
|
31
|
-
children,
|
|
32
|
-
sortable && sortDirection ? sortDirection === "asc" ? " \u2191" : " \u2193" : null
|
|
33
|
-
]
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
},
|
|
37
|
-
chip: ({ children, size }) => /* @__PURE__ */ jsx(
|
|
38
|
-
"span",
|
|
39
|
-
{
|
|
40
|
-
style: {
|
|
41
|
-
display: "inline-block",
|
|
42
|
-
padding: size === "sm" ? "1px 6px" : "2px 8px",
|
|
43
|
-
borderRadius: "12px",
|
|
44
|
-
fontSize: size === "sm" ? "12px" : "14px",
|
|
45
|
-
backgroundColor: "#eee"
|
|
46
|
-
},
|
|
47
|
-
children
|
|
48
|
-
}
|
|
49
|
-
),
|
|
50
|
-
// Layout
|
|
51
|
-
appShell: ({ children, sidebar, header }) => /* @__PURE__ */ jsxs("div", { style: { display: "flex", minHeight: "100vh" }, children: [
|
|
52
|
-
sidebar ? /* @__PURE__ */ jsx("nav", { children: sidebar }) : null,
|
|
53
|
-
/* @__PURE__ */ jsxs("div", { style: { flex: 1 }, children: [
|
|
54
|
-
header ?? null,
|
|
55
|
-
/* @__PURE__ */ jsx("main", { children })
|
|
56
|
-
] })
|
|
57
|
-
] }),
|
|
58
|
-
sidebar: ({ children }) => /* @__PURE__ */ jsx("aside", { style: { width: "240px", borderRight: "1px solid #ddd" }, children }),
|
|
59
|
-
pageContainer: ({ children, title, actions }) => /* @__PURE__ */ jsxs("div", { children: [
|
|
60
|
-
title || actions ? /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
|
|
61
|
-
title ? /* @__PURE__ */ jsx("h1", { children: title }) : null,
|
|
62
|
-
actions ?? null
|
|
63
|
-
] }) : null,
|
|
64
|
-
children
|
|
65
|
-
] }),
|
|
66
|
-
breadcrumb: ({ items }) => /* @__PURE__ */ jsx("nav", { "aria-label": "breadcrumb", children: items.map((item, i) => /* @__PURE__ */ jsxs("span", { children: [
|
|
67
|
-
i > 0 ? " / " : null,
|
|
68
|
-
item.to ? /* @__PURE__ */ jsx("a", { href: item.to, children: item.label }) : item.label
|
|
69
|
-
] }, i)) }),
|
|
70
|
-
// Feedback
|
|
71
|
-
toast: ({ children }) => /* @__PURE__ */ jsx("div", { children }),
|
|
72
|
-
alert: ({ children, color }) => /* @__PURE__ */ jsx(
|
|
73
|
-
"div",
|
|
74
|
-
{
|
|
75
|
-
role: "alert",
|
|
76
|
-
style: {
|
|
77
|
-
padding: "8px 12px",
|
|
78
|
-
borderRadius: "4px",
|
|
79
|
-
backgroundColor: color === "danger" ? "#fee" : color === "success" ? "#efe" : color === "warning" ? "#ffe" : "#f5f5f5"
|
|
80
|
-
},
|
|
81
|
-
children
|
|
82
|
-
}
|
|
83
|
-
),
|
|
84
|
-
// File
|
|
85
|
-
dropZone: ({ children, isDragOver, onClick, onDrop, onDragOver, onDragLeave }) => /* @__PURE__ */ jsx(
|
|
86
|
-
"div",
|
|
87
|
-
{
|
|
88
|
-
onClick,
|
|
89
|
-
onDrop: (e) => {
|
|
90
|
-
e.preventDefault();
|
|
91
|
-
onDrop(e.dataTransfer.files);
|
|
92
|
-
},
|
|
93
|
-
onDragOver: (e) => {
|
|
94
|
-
e.preventDefault();
|
|
95
|
-
onDragOver(e);
|
|
96
|
-
},
|
|
97
|
-
onDragLeave,
|
|
98
|
-
style: {
|
|
99
|
-
border: `2px dashed ${isDragOver ? "#4caf50" : "#ccc"}`,
|
|
100
|
-
borderRadius: "8px",
|
|
101
|
-
padding: "32px",
|
|
102
|
-
textAlign: "center",
|
|
103
|
-
cursor: "pointer"
|
|
104
|
-
},
|
|
105
|
-
children
|
|
106
|
-
}
|
|
107
|
-
)
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
// src/plugin.tsx
|
|
111
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
112
|
-
var UIPluginContext = createContext(null);
|
|
113
|
-
function createUIPlugin(config) {
|
|
114
|
-
return { components: config.components };
|
|
115
|
-
}
|
|
116
|
-
function UIPluginProvider({
|
|
117
|
-
plugin,
|
|
118
|
-
children
|
|
119
|
-
}) {
|
|
120
|
-
return /* @__PURE__ */ jsx2(UIPluginContext.Provider, { value: plugin, children });
|
|
121
|
-
}
|
|
122
|
-
function useUIPlugin() {
|
|
123
|
-
return useContext(UIPluginContext);
|
|
124
|
-
}
|
|
125
|
-
function useComponent(slot) {
|
|
126
|
-
const plugin = useUIPlugin();
|
|
127
|
-
const component = plugin?.components[slot];
|
|
128
|
-
if (component) {
|
|
129
|
-
return component;
|
|
130
|
-
}
|
|
131
|
-
return headlessDefaults[slot];
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
// src/hooks/use-toast.ts
|
|
135
|
-
import { createContext as createContext2, useContext as useContext2, useCallback } from "react";
|
|
136
|
-
var ToastContext = createContext2(null);
|
|
137
|
-
function useToast() {
|
|
138
|
-
const ctx = useContext2(ToastContext);
|
|
139
|
-
if (!ctx) {
|
|
140
|
-
throw new Error("useToast must be used within a <ToastProvider>");
|
|
141
|
-
}
|
|
142
|
-
const show = useCallback(
|
|
143
|
-
(options) => ctx.show(options),
|
|
144
|
-
[ctx]
|
|
145
|
-
);
|
|
146
|
-
const success = useCallback(
|
|
147
|
-
(message, description) => ctx.show({ message, type: "success", description }),
|
|
148
|
-
[ctx]
|
|
149
|
-
);
|
|
150
|
-
const error = useCallback(
|
|
151
|
-
(message, description) => ctx.show({ message, type: "error", description }),
|
|
152
|
-
[ctx]
|
|
153
|
-
);
|
|
154
|
-
const info = useCallback(
|
|
155
|
-
(message, description) => ctx.show({ message, type: "info", description }),
|
|
156
|
-
[ctx]
|
|
157
|
-
);
|
|
158
|
-
const warning = useCallback(
|
|
159
|
-
(message, description) => ctx.show({ message, type: "warning", description }),
|
|
160
|
-
[ctx]
|
|
161
|
-
);
|
|
162
|
-
return { show, success, error, info, warning };
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// src/components/permission-gate.tsx
|
|
166
|
-
import { Fragment, jsx as jsx3 } from "react/jsx-runtime";
|
|
167
|
-
function PermissionGate({
|
|
168
|
-
action,
|
|
169
|
-
children,
|
|
170
|
-
fallback
|
|
171
|
-
}) {
|
|
172
|
-
if (action.invisible) {
|
|
173
|
-
return null;
|
|
174
|
-
}
|
|
175
|
-
if (!action.permitted) {
|
|
176
|
-
return fallback ? /* @__PURE__ */ jsx3(Fragment, { children: fallback }) : null;
|
|
177
|
-
}
|
|
178
|
-
return /* @__PURE__ */ jsx3(Fragment, { children });
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
// src/components/avatar-with-initials.tsx
|
|
182
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
183
|
-
function getInitials(name) {
|
|
184
|
-
return name.split(" ").map((part) => part[0]).join("").toUpperCase().slice(0, 2);
|
|
185
|
-
}
|
|
186
|
-
var sizeMap = { sm: 32, md: 40, lg: 56 };
|
|
187
|
-
function AvatarWithInitials({
|
|
188
|
-
src,
|
|
189
|
-
name,
|
|
190
|
-
size = "md"
|
|
191
|
-
}) {
|
|
192
|
-
const px = sizeMap[size];
|
|
193
|
-
if (src) {
|
|
194
|
-
return /* @__PURE__ */ jsx4(
|
|
195
|
-
"img",
|
|
196
|
-
{
|
|
197
|
-
src,
|
|
198
|
-
alt: name,
|
|
199
|
-
style: {
|
|
200
|
-
width: px,
|
|
201
|
-
height: px,
|
|
202
|
-
borderRadius: "50%",
|
|
203
|
-
objectFit: "cover"
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
return /* @__PURE__ */ jsx4(
|
|
209
|
-
"span",
|
|
210
|
-
{
|
|
211
|
-
"aria-label": name,
|
|
212
|
-
style: {
|
|
213
|
-
display: "inline-flex",
|
|
214
|
-
alignItems: "center",
|
|
215
|
-
justifyContent: "center",
|
|
216
|
-
width: px,
|
|
217
|
-
height: px,
|
|
218
|
-
borderRadius: "50%",
|
|
219
|
-
backgroundColor: "#ddd",
|
|
220
|
-
fontSize: px * 0.4,
|
|
221
|
-
fontWeight: "bold"
|
|
222
|
-
},
|
|
223
|
-
children: getInitials(name)
|
|
224
|
-
}
|
|
225
|
-
);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// src/fields/date-field.tsx
|
|
229
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
230
|
-
var rtf = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
|
|
231
|
-
function getRelativeTime(date) {
|
|
232
|
-
const now = Date.now();
|
|
233
|
-
const diffMs = date.getTime() - now;
|
|
234
|
-
const diffSec = Math.round(diffMs / 1e3);
|
|
235
|
-
const diffMin = Math.round(diffSec / 60);
|
|
236
|
-
const diffHour = Math.round(diffMin / 60);
|
|
237
|
-
const diffDay = Math.round(diffHour / 24);
|
|
238
|
-
if (Math.abs(diffSec) < 60) return rtf.format(diffSec, "second");
|
|
239
|
-
if (Math.abs(diffMin) < 60) return rtf.format(diffMin, "minute");
|
|
240
|
-
if (Math.abs(diffHour) < 24) return rtf.format(diffHour, "hour");
|
|
241
|
-
if (Math.abs(diffDay) < 30) return rtf.format(diffDay, "day");
|
|
242
|
-
const diffMonth = Math.round(diffDay / 30);
|
|
243
|
-
if (Math.abs(diffMonth) < 12) return rtf.format(diffMonth, "month");
|
|
244
|
-
return rtf.format(Math.round(diffDay / 365), "year");
|
|
245
|
-
}
|
|
246
|
-
function formatDate(date, format, locale) {
|
|
247
|
-
switch (format) {
|
|
248
|
-
case "relative":
|
|
249
|
-
return getRelativeTime(date);
|
|
250
|
-
case "long":
|
|
251
|
-
return new Intl.DateTimeFormat(locale, {
|
|
252
|
-
dateStyle: "long"
|
|
253
|
-
}).format(date);
|
|
254
|
-
case "datetime":
|
|
255
|
-
return new Intl.DateTimeFormat(locale, {
|
|
256
|
-
dateStyle: "medium",
|
|
257
|
-
timeStyle: "short"
|
|
258
|
-
}).format(date);
|
|
259
|
-
case "short":
|
|
260
|
-
default:
|
|
261
|
-
return new Intl.DateTimeFormat(locale, {
|
|
262
|
-
dateStyle: "medium"
|
|
263
|
-
}).format(date);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
function DateField({
|
|
267
|
-
value,
|
|
268
|
-
format = "short",
|
|
269
|
-
locale = "en"
|
|
270
|
-
}) {
|
|
271
|
-
if (value == null) {
|
|
272
|
-
return /* @__PURE__ */ jsx5("span", { children: "\u2014" });
|
|
273
|
-
}
|
|
274
|
-
const date = value instanceof Date ? value : new Date(value);
|
|
275
|
-
if (Number.isNaN(date.getTime())) {
|
|
276
|
-
return /* @__PURE__ */ jsx5("span", { children: "Invalid date" });
|
|
277
|
-
}
|
|
278
|
-
return /* @__PURE__ */ jsx5("time", { dateTime: date.toISOString(), children: formatDate(date, format, locale) });
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// src/fields/boolean-field.tsx
|
|
282
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
283
|
-
function BooleanField({
|
|
284
|
-
value,
|
|
285
|
-
trueLabel = "Yes",
|
|
286
|
-
falseLabel = "No",
|
|
287
|
-
trueColor = "success",
|
|
288
|
-
falseColor = "neutral"
|
|
289
|
-
}) {
|
|
290
|
-
const Chip = useComponent("chip");
|
|
291
|
-
if (value == null) {
|
|
292
|
-
return /* @__PURE__ */ jsx6("span", { children: "\u2014" });
|
|
293
|
-
}
|
|
294
|
-
return /* @__PURE__ */ jsx6(
|
|
295
|
-
Chip,
|
|
296
|
-
{
|
|
297
|
-
color: value ? trueColor : falseColor,
|
|
298
|
-
variant: "soft",
|
|
299
|
-
size: "sm",
|
|
300
|
-
children: value ? trueLabel : falseLabel
|
|
301
|
-
}
|
|
302
|
-
);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
// src/fields/number-field.tsx
|
|
306
|
-
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
307
|
-
function NumberField({
|
|
308
|
-
value,
|
|
309
|
-
locale = "en",
|
|
310
|
-
currency,
|
|
311
|
-
decimals
|
|
312
|
-
}) {
|
|
313
|
-
if (value == null) {
|
|
314
|
-
return /* @__PURE__ */ jsx7("span", { children: "\u2014" });
|
|
315
|
-
}
|
|
316
|
-
const options = {};
|
|
317
|
-
if (currency) {
|
|
318
|
-
options.style = "currency";
|
|
319
|
-
options.currency = currency;
|
|
320
|
-
}
|
|
321
|
-
if (decimals !== void 0) {
|
|
322
|
-
options.minimumFractionDigits = decimals;
|
|
323
|
-
options.maximumFractionDigits = decimals;
|
|
324
|
-
}
|
|
325
|
-
const formatted = new Intl.NumberFormat(locale, options).format(value);
|
|
326
|
-
return /* @__PURE__ */ jsx7("span", { children: formatted });
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// src/fields/text-field.tsx
|
|
330
|
-
import { jsx as jsx8 } from "react/jsx-runtime";
|
|
331
|
-
function TextField({
|
|
332
|
-
value,
|
|
333
|
-
maxLength
|
|
334
|
-
}) {
|
|
335
|
-
if (value == null) {
|
|
336
|
-
return /* @__PURE__ */ jsx8("span", { children: "\u2014" });
|
|
337
|
-
}
|
|
338
|
-
const display = maxLength && value.length > maxLength ? `${value.slice(0, maxLength)}\u2026` : value;
|
|
339
|
-
if (maxLength && value.length > maxLength) {
|
|
340
|
-
return /* @__PURE__ */ jsx8("span", { title: value, children: display });
|
|
341
|
-
}
|
|
342
|
-
return /* @__PURE__ */ jsx8("span", { children: display });
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// src/fields/email-field.tsx
|
|
346
|
-
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
347
|
-
function EmailField({ value }) {
|
|
348
|
-
if (value == null) {
|
|
349
|
-
return /* @__PURE__ */ jsx9("span", { children: "\u2014" });
|
|
350
|
-
}
|
|
351
|
-
return /* @__PURE__ */ jsx9("a", { href: `mailto:${value}`, children: value });
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
// src/fields/json-field.tsx
|
|
355
|
-
import { useState } from "react";
|
|
356
|
-
import { jsx as jsx10, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
357
|
-
function JsonField({
|
|
358
|
-
value,
|
|
359
|
-
collapsed = false
|
|
360
|
-
}) {
|
|
361
|
-
const [isCollapsed, setIsCollapsed] = useState(collapsed);
|
|
362
|
-
if (value == null) {
|
|
363
|
-
return /* @__PURE__ */ jsx10("span", { children: "\u2014" });
|
|
364
|
-
}
|
|
365
|
-
const formatted = JSON.stringify(value, null, 2);
|
|
366
|
-
if (isCollapsed) {
|
|
367
|
-
const preview = JSON.stringify(value);
|
|
368
|
-
const short = preview.length > 60 ? `${preview.slice(0, 60)}\u2026` : preview;
|
|
369
|
-
return /* @__PURE__ */ jsxs2("span", { children: [
|
|
370
|
-
/* @__PURE__ */ jsx10("code", { children: short }),
|
|
371
|
-
" ",
|
|
372
|
-
/* @__PURE__ */ jsx10(
|
|
373
|
-
"button",
|
|
374
|
-
{
|
|
375
|
-
onClick: () => setIsCollapsed(false),
|
|
376
|
-
style: { border: "none", background: "none", cursor: "pointer", color: "#666", fontSize: "12px" },
|
|
377
|
-
children: "expand"
|
|
378
|
-
}
|
|
379
|
-
)
|
|
380
|
-
] });
|
|
381
|
-
}
|
|
382
|
-
return /* @__PURE__ */ jsx10(
|
|
383
|
-
"pre",
|
|
384
|
-
{
|
|
385
|
-
style: {
|
|
386
|
-
margin: 0,
|
|
387
|
-
fontSize: "13px",
|
|
388
|
-
backgroundColor: "#f5f5f5",
|
|
389
|
-
padding: "8px",
|
|
390
|
-
borderRadius: "4px",
|
|
391
|
-
overflow: "auto"
|
|
392
|
-
},
|
|
393
|
-
children: /* @__PURE__ */ jsx10("code", { children: formatted })
|
|
394
|
-
}
|
|
395
|
-
);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
// src/fields/field-for-column.ts
|
|
399
|
-
function fieldForColumn(column) {
|
|
400
|
-
const { dataType, name } = column;
|
|
401
|
-
const dt = dataType.toLowerCase();
|
|
402
|
-
if (dt === "boolean" || dt === "integer" && name.startsWith("is")) {
|
|
403
|
-
return BooleanField;
|
|
404
|
-
}
|
|
405
|
-
if (dt.includes("timestamp") || dt.includes("date") || dt.includes("datetime")) {
|
|
406
|
-
return DateField;
|
|
407
|
-
}
|
|
408
|
-
if (dt === "integer" || dt === "real" || dt === "numeric" || dt.includes("int") || dt.includes("float") || dt.includes("double") || dt.includes("decimal")) {
|
|
409
|
-
return NumberField;
|
|
410
|
-
}
|
|
411
|
-
if (name === "email" || name.endsWith("Email")) {
|
|
412
|
-
return EmailField;
|
|
413
|
-
}
|
|
414
|
-
if (dt === "json" || dt === "jsonb" || dt === "blob") {
|
|
415
|
-
return JsonField;
|
|
416
|
-
}
|
|
417
|
-
return TextField;
|
|
418
|
-
}
|
|
419
|
-
function fieldsForTable(table) {
|
|
420
|
-
const result = {};
|
|
421
|
-
for (const [key, col] of Object.entries(table)) {
|
|
422
|
-
if (col && typeof col === "object" && "dataType" in col && "name" in col) {
|
|
423
|
-
result[key] = fieldForColumn(col);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
return result;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
// src/hooks/use-action-status.ts
|
|
430
|
-
import { useActions } from "@cfast/actions/client";
|
|
431
|
-
function useActionStatus(descriptor) {
|
|
432
|
-
const actions = useActions(descriptor);
|
|
433
|
-
const name = descriptor.actionNames[0];
|
|
434
|
-
return actions[name]();
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
export {
|
|
438
|
-
createUIPlugin,
|
|
439
|
-
UIPluginProvider,
|
|
440
|
-
useUIPlugin,
|
|
441
|
-
useComponent,
|
|
442
|
-
ToastContext,
|
|
443
|
-
useToast,
|
|
444
|
-
PermissionGate,
|
|
445
|
-
getInitials,
|
|
446
|
-
AvatarWithInitials,
|
|
447
|
-
DateField,
|
|
448
|
-
BooleanField,
|
|
449
|
-
NumberField,
|
|
450
|
-
TextField,
|
|
451
|
-
EmailField,
|
|
452
|
-
JsonField,
|
|
453
|
-
fieldForColumn,
|
|
454
|
-
fieldsForTable,
|
|
455
|
-
useActionStatus
|
|
456
|
-
};
|