@pactor-app/ui 0.1.0 → 1.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/dist/chunk-6B5ZX7L3.js +3537 -0
- package/dist/chunk-6JNCDPGS.js +257 -0
- package/dist/chunk-BVHAP22U.js +3085 -0
- package/dist/{chunk-OH3U6PCM.js → chunk-BZSRLTQQ.js} +60 -66
- package/dist/chunk-F3H23KYG.js +330 -0
- package/dist/{chunk-SNFDI77B.js → chunk-GL7IO22L.js} +94 -5
- package/dist/{chunk-DMK6RSTK.js → chunk-GV5R6TUT.js} +18 -11
- package/dist/components/index.cjs +6134 -471
- package/dist/components/index.d.cts +1561 -30
- package/dist/components/index.d.ts +1561 -30
- package/dist/components/index.js +130 -6
- package/dist/index.cjs +6410 -979
- package/dist/index.d.cts +6 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +132 -10
- package/dist/interaction/index.cjs +152 -77
- package/dist/interaction/index.d.cts +7 -5
- package/dist/interaction/index.d.ts +7 -5
- package/dist/interaction/index.js +2 -3
- package/dist/layout/index.cjs +229 -71
- package/dist/layout/index.js +3 -3
- package/dist/typography-DsGdDBc2.d.cts +24 -0
- package/dist/typography-DsGdDBc2.d.ts +24 -0
- package/dist/ui/index.cjs +2969 -172
- package/dist/ui/index.d.cts +416 -14
- package/dist/ui/index.d.ts +416 -14
- package/dist/ui/index.js +330 -126
- package/package.json +13 -5
- package/styles.css +1202 -6
- package/dist/chunk-57NRUZ5G.js +0 -95
- package/dist/chunk-OUTSIJMO.js +0 -442
- package/dist/chunk-QDTVOJ5P.js +0 -147
- package/dist/chunk-QWZ23QLS.js +0 -68
- package/dist/chunk-XGOTHOI6.js +0 -619
package/dist/chunk-QWZ23QLS.js
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
cn
|
|
3
|
-
} from "./chunk-RQHJBTEU.js";
|
|
4
|
-
|
|
5
|
-
// src/ui/button.tsx
|
|
6
|
-
import { Button as ButtonPrimitive } from "@base-ui/react/button";
|
|
7
|
-
import { cva } from "class-variance-authority";
|
|
8
|
-
import * as React from "react";
|
|
9
|
-
import { jsx } from "react/jsx-runtime";
|
|
10
|
-
var buttonVariants = cva(
|
|
11
|
-
"inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium outline-none transition-colors focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
12
|
-
{
|
|
13
|
-
variants: {
|
|
14
|
-
variant: {
|
|
15
|
-
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
16
|
-
destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90 focus-visible:ring-destructive/20",
|
|
17
|
-
outline: "border border-border bg-background hover:bg-accent hover:text-accent-foreground",
|
|
18
|
-
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
|
|
19
|
-
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
20
|
-
link: "text-primary underline-offset-4 hover:underline"
|
|
21
|
-
},
|
|
22
|
-
size: {
|
|
23
|
-
default: "h-9 px-4 py-2",
|
|
24
|
-
sm: "h-8 gap-1.5 rounded-md px-3 text-xs",
|
|
25
|
-
lg: "h-10 rounded-md px-6",
|
|
26
|
-
icon: "size-9"
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
defaultVariants: {
|
|
30
|
-
variant: "default",
|
|
31
|
-
size: "default"
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
);
|
|
35
|
-
function Button({
|
|
36
|
-
className,
|
|
37
|
-
variant,
|
|
38
|
-
size,
|
|
39
|
-
asChild = false,
|
|
40
|
-
children,
|
|
41
|
-
...props
|
|
42
|
-
}) {
|
|
43
|
-
if (asChild && React.isValidElement(children)) {
|
|
44
|
-
return /* @__PURE__ */ jsx(
|
|
45
|
-
ButtonPrimitive,
|
|
46
|
-
{
|
|
47
|
-
"data-slot": "button",
|
|
48
|
-
className: cn(buttonVariants({ variant, size, className })),
|
|
49
|
-
render: children,
|
|
50
|
-
...props
|
|
51
|
-
}
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
return /* @__PURE__ */ jsx(
|
|
55
|
-
ButtonPrimitive,
|
|
56
|
-
{
|
|
57
|
-
"data-slot": "button",
|
|
58
|
-
className: cn(buttonVariants({ variant, size, className })),
|
|
59
|
-
...props,
|
|
60
|
-
children
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export {
|
|
66
|
-
buttonVariants,
|
|
67
|
-
Button
|
|
68
|
-
};
|
package/dist/chunk-XGOTHOI6.js
DELETED
|
@@ -1,619 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Alert,
|
|
3
|
-
AlertDescription,
|
|
4
|
-
AlertTitle,
|
|
5
|
-
Input,
|
|
6
|
-
Select,
|
|
7
|
-
SelectContent,
|
|
8
|
-
SelectItem,
|
|
9
|
-
SelectTrigger,
|
|
10
|
-
SelectValue,
|
|
11
|
-
Table,
|
|
12
|
-
TableBody,
|
|
13
|
-
TableCell,
|
|
14
|
-
TableHead,
|
|
15
|
-
TableHeader,
|
|
16
|
-
TableRow,
|
|
17
|
-
Tabs,
|
|
18
|
-
TabsContent,
|
|
19
|
-
TabsList,
|
|
20
|
-
TabsTrigger
|
|
21
|
-
} from "./chunk-OUTSIJMO.js";
|
|
22
|
-
import {
|
|
23
|
-
Button
|
|
24
|
-
} from "./chunk-QWZ23QLS.js";
|
|
25
|
-
import {
|
|
26
|
-
Card,
|
|
27
|
-
CardContent,
|
|
28
|
-
CardHeader,
|
|
29
|
-
CardTitle
|
|
30
|
-
} from "./chunk-57NRUZ5G.js";
|
|
31
|
-
import {
|
|
32
|
-
cn
|
|
33
|
-
} from "./chunk-RQHJBTEU.js";
|
|
34
|
-
|
|
35
|
-
// src/components/register.ts
|
|
36
|
-
import { Registry } from "@pactor-app/core";
|
|
37
|
-
|
|
38
|
-
// src/components/components/Alert/index.tsx
|
|
39
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
40
|
-
var variantMap = {
|
|
41
|
-
success: "success",
|
|
42
|
-
info: "info",
|
|
43
|
-
warning: "warning",
|
|
44
|
-
error: "destructive"
|
|
45
|
-
};
|
|
46
|
-
function Alert2({ message, description, variant = "info" }) {
|
|
47
|
-
return /* @__PURE__ */ jsxs(Alert, { variant: variantMap[variant], children: [
|
|
48
|
-
message ? /* @__PURE__ */ jsx(AlertTitle, { children: message }) : null,
|
|
49
|
-
description ? /* @__PURE__ */ jsx(AlertDescription, { children: description }) : null
|
|
50
|
-
] });
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// src/components/components/Button/index.tsx
|
|
54
|
-
import { Loader2 } from "lucide-react";
|
|
55
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
56
|
-
var variantMap2 = {
|
|
57
|
-
default: "outline",
|
|
58
|
-
primary: "default",
|
|
59
|
-
dashed: "outline",
|
|
60
|
-
link: "link",
|
|
61
|
-
text: "ghost"
|
|
62
|
-
};
|
|
63
|
-
var sizeMap = {
|
|
64
|
-
small: "sm",
|
|
65
|
-
middle: "default",
|
|
66
|
-
large: "lg"
|
|
67
|
-
};
|
|
68
|
-
function Button2({
|
|
69
|
-
text,
|
|
70
|
-
variant = "default",
|
|
71
|
-
danger,
|
|
72
|
-
size = "middle",
|
|
73
|
-
loading,
|
|
74
|
-
disabled,
|
|
75
|
-
submit,
|
|
76
|
-
onClick,
|
|
77
|
-
children
|
|
78
|
-
}) {
|
|
79
|
-
const textual = variant === "link" || variant === "text";
|
|
80
|
-
return /* @__PURE__ */ jsxs2(
|
|
81
|
-
Button,
|
|
82
|
-
{
|
|
83
|
-
type: submit ? "submit" : "button",
|
|
84
|
-
variant: danger && !textual ? "destructive" : variantMap2[variant],
|
|
85
|
-
size: sizeMap[size],
|
|
86
|
-
disabled: disabled ?? loading,
|
|
87
|
-
"aria-busy": loading || void 0,
|
|
88
|
-
onClick: () => onClick?.(),
|
|
89
|
-
className: cn(
|
|
90
|
-
variant === "dashed" && "border-dashed",
|
|
91
|
-
danger && textual && "text-destructive hover:text-destructive"
|
|
92
|
-
),
|
|
93
|
-
children: [
|
|
94
|
-
loading ? /* @__PURE__ */ jsx2(Loader2, { "aria-hidden": true, className: "animate-spin" }) : null,
|
|
95
|
-
text ?? children
|
|
96
|
-
]
|
|
97
|
-
}
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// src/components/components/Card/index.tsx
|
|
102
|
-
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
103
|
-
function Card2({ title, bordered = true, children }) {
|
|
104
|
-
return /* @__PURE__ */ jsxs3(
|
|
105
|
-
Card,
|
|
106
|
-
{
|
|
107
|
-
className: cn("gap-4 py-4", !bordered && "border-transparent shadow-none"),
|
|
108
|
-
children: [
|
|
109
|
-
title ? /* @__PURE__ */ jsx3(CardHeader, { className: "px-4", children: /* @__PURE__ */ jsx3(CardTitle, { children: title }) }) : null,
|
|
110
|
-
/* @__PURE__ */ jsx3(CardContent, { className: "px-4", children })
|
|
111
|
-
]
|
|
112
|
-
}
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// src/components/components/Flex/index.tsx
|
|
117
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
118
|
-
var gapClass = {
|
|
119
|
-
small: "gap-2",
|
|
120
|
-
middle: "gap-4",
|
|
121
|
-
large: "gap-6"
|
|
122
|
-
};
|
|
123
|
-
var justifyClass = {
|
|
124
|
-
start: "justify-start",
|
|
125
|
-
center: "justify-center",
|
|
126
|
-
end: "justify-end",
|
|
127
|
-
"space-between": "justify-between",
|
|
128
|
-
"space-around": "justify-around",
|
|
129
|
-
"space-evenly": "justify-evenly"
|
|
130
|
-
};
|
|
131
|
-
var alignClass = {
|
|
132
|
-
start: "items-start",
|
|
133
|
-
center: "items-center",
|
|
134
|
-
end: "items-end",
|
|
135
|
-
baseline: "items-baseline",
|
|
136
|
-
stretch: "items-stretch"
|
|
137
|
-
};
|
|
138
|
-
function Flex({
|
|
139
|
-
direction = "horizontal",
|
|
140
|
-
gap,
|
|
141
|
-
justify,
|
|
142
|
-
align,
|
|
143
|
-
children
|
|
144
|
-
}) {
|
|
145
|
-
return /* @__PURE__ */ jsx4(
|
|
146
|
-
"div",
|
|
147
|
-
{
|
|
148
|
-
"data-slot": "flex",
|
|
149
|
-
className: cn(
|
|
150
|
-
"flex",
|
|
151
|
-
direction === "vertical" && "flex-col",
|
|
152
|
-
typeof gap === "string" && gapClass[gap],
|
|
153
|
-
justify && justifyClass[justify],
|
|
154
|
-
align && alignClass[align]
|
|
155
|
-
),
|
|
156
|
-
style: typeof gap === "number" ? { gap } : void 0,
|
|
157
|
-
children
|
|
158
|
-
}
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// src/components/components/Form/index.tsx
|
|
163
|
-
import { useRenderer } from "@pactor-app/runtime";
|
|
164
|
-
import {
|
|
165
|
-
useCallback,
|
|
166
|
-
useEffect,
|
|
167
|
-
useMemo,
|
|
168
|
-
useRef,
|
|
169
|
-
useState
|
|
170
|
-
} from "react";
|
|
171
|
-
|
|
172
|
-
// src/components/components/Form/context.ts
|
|
173
|
-
import { createContext, useContext } from "react";
|
|
174
|
-
var FormReactContext = createContext(null);
|
|
175
|
-
var FormContextProvider = FormReactContext.Provider;
|
|
176
|
-
function useFormContext() {
|
|
177
|
-
return useContext(FormReactContext);
|
|
178
|
-
}
|
|
179
|
-
function formItemClass(layout) {
|
|
180
|
-
switch (layout) {
|
|
181
|
-
case "horizontal":
|
|
182
|
-
return "mb-4 flex items-baseline gap-2";
|
|
183
|
-
case "inline":
|
|
184
|
-
return "flex items-center gap-2";
|
|
185
|
-
default:
|
|
186
|
-
return "mb-4 flex flex-col gap-1.5";
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// src/components/components/Form/index.tsx
|
|
191
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
192
|
-
function isEmpty(value) {
|
|
193
|
-
return value === void 0 || value === null || value === "";
|
|
194
|
-
}
|
|
195
|
-
function Form({
|
|
196
|
-
name = "default",
|
|
197
|
-
layout = "vertical",
|
|
198
|
-
initialValues,
|
|
199
|
-
children,
|
|
200
|
-
onSubmit,
|
|
201
|
-
onValuesChange
|
|
202
|
-
}) {
|
|
203
|
-
const { context } = useRenderer();
|
|
204
|
-
const [values, setValues] = useState(() => ({
|
|
205
|
-
...initialValues
|
|
206
|
-
}));
|
|
207
|
-
const [errors, setErrors] = useState({});
|
|
208
|
-
const fieldRulesRef = useRef(/* @__PURE__ */ new Map());
|
|
209
|
-
const mergedInitialFieldsRef = useRef(/* @__PURE__ */ new Set());
|
|
210
|
-
const setValuesBatch = useCallback((partial) => {
|
|
211
|
-
setValues((prev) => ({ ...prev, ...partial }));
|
|
212
|
-
}, []);
|
|
213
|
-
useEffect(() => {
|
|
214
|
-
context.forms.register(name, { setValues: setValuesBatch });
|
|
215
|
-
return () => {
|
|
216
|
-
context.forms.unregister(name);
|
|
217
|
-
};
|
|
218
|
-
}, [context, name, setValuesBatch]);
|
|
219
|
-
const formContext = useMemo(
|
|
220
|
-
() => ({
|
|
221
|
-
inForm: true,
|
|
222
|
-
layout,
|
|
223
|
-
values,
|
|
224
|
-
errors,
|
|
225
|
-
setValue(name2, value) {
|
|
226
|
-
const next = { ...values, [name2]: value };
|
|
227
|
-
setValues(next);
|
|
228
|
-
setErrors((prev) => {
|
|
229
|
-
if (!(name2 in prev)) {
|
|
230
|
-
return prev;
|
|
231
|
-
}
|
|
232
|
-
const rest = { ...prev };
|
|
233
|
-
delete rest[name2];
|
|
234
|
-
return rest;
|
|
235
|
-
});
|
|
236
|
-
onValuesChange?.({ [name2]: value }, next);
|
|
237
|
-
},
|
|
238
|
-
setValues: setValuesBatch,
|
|
239
|
-
registerField(name2, rules, initialValue) {
|
|
240
|
-
fieldRulesRef.current.set(name2, rules);
|
|
241
|
-
if (initialValue !== void 0 && !mergedInitialFieldsRef.current.has(name2)) {
|
|
242
|
-
mergedInitialFieldsRef.current.add(name2);
|
|
243
|
-
setValues((prev) => ({ ...prev, [name2]: initialValue }));
|
|
244
|
-
}
|
|
245
|
-
},
|
|
246
|
-
unregisterField(name2) {
|
|
247
|
-
fieldRulesRef.current.delete(name2);
|
|
248
|
-
}
|
|
249
|
-
}),
|
|
250
|
-
[layout, values, errors, onValuesChange, setValuesBatch]
|
|
251
|
-
);
|
|
252
|
-
const handleSubmit = (event) => {
|
|
253
|
-
event.preventDefault();
|
|
254
|
-
const nextErrors = {};
|
|
255
|
-
for (const [name2, rules] of fieldRulesRef.current) {
|
|
256
|
-
for (const rule of rules ?? []) {
|
|
257
|
-
if (rule.required && isEmpty(values[name2])) {
|
|
258
|
-
nextErrors[name2] = rule.message ?? context.i18n.t("pactor.form.required");
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
setErrors(nextErrors);
|
|
264
|
-
if (Object.keys(nextErrors).length > 0) {
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
|
-
context.state.set("form", values);
|
|
268
|
-
onSubmit?.(values);
|
|
269
|
-
};
|
|
270
|
-
return /* @__PURE__ */ jsx5(FormContextProvider, { value: formContext, children: /* @__PURE__ */ jsx5(
|
|
271
|
-
"form",
|
|
272
|
-
{
|
|
273
|
-
"data-slot": "form",
|
|
274
|
-
className: cn(layout === "inline" && "flex flex-wrap items-center gap-3"),
|
|
275
|
-
onSubmit: handleSubmit,
|
|
276
|
-
children
|
|
277
|
-
}
|
|
278
|
-
) });
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
// src/components/components/Grid/index.tsx
|
|
282
|
-
import { Children } from "react";
|
|
283
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
284
|
-
function Grid({ columns = 1, gap, children }) {
|
|
285
|
-
const cols = Math.max(1, columns);
|
|
286
|
-
return /* @__PURE__ */ jsx6(
|
|
287
|
-
"div",
|
|
288
|
-
{
|
|
289
|
-
"data-slot": "grid",
|
|
290
|
-
"data-columns": cols,
|
|
291
|
-
className: "grid",
|
|
292
|
-
style: {
|
|
293
|
-
gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))`,
|
|
294
|
-
...gap !== void 0 ? { gap } : {}
|
|
295
|
-
},
|
|
296
|
-
children: Children.map(children, (child, index) => /* @__PURE__ */ jsx6("div", { "data-slot": "grid-item", children: child }, index))
|
|
297
|
-
}
|
|
298
|
-
);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// src/components/components/Input/index.tsx
|
|
302
|
-
import { useEffect as useEffect2, useId } from "react";
|
|
303
|
-
import { jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
304
|
-
function Input2({
|
|
305
|
-
name,
|
|
306
|
-
label,
|
|
307
|
-
rules,
|
|
308
|
-
value,
|
|
309
|
-
type = "text",
|
|
310
|
-
placeholder,
|
|
311
|
-
disabled,
|
|
312
|
-
onChange
|
|
313
|
-
}) {
|
|
314
|
-
const form = useFormContext();
|
|
315
|
-
const controlId = useId();
|
|
316
|
-
const inForm = form?.inForm === true && typeof name === "string" && name !== "";
|
|
317
|
-
useEffect2(() => {
|
|
318
|
-
if (inForm && form && name) {
|
|
319
|
-
form.registerField(name, rules, value);
|
|
320
|
-
return () => form.unregisterField(name);
|
|
321
|
-
}
|
|
322
|
-
return void 0;
|
|
323
|
-
});
|
|
324
|
-
if (inForm && form && name) {
|
|
325
|
-
const fieldValue = form.values[name];
|
|
326
|
-
const error = form.errors[name];
|
|
327
|
-
return /* @__PURE__ */ jsxs4("div", { "data-slot": "form-item", className: formItemClass(form.layout), children: [
|
|
328
|
-
label ? /* @__PURE__ */ jsx7(
|
|
329
|
-
"label",
|
|
330
|
-
{
|
|
331
|
-
htmlFor: controlId,
|
|
332
|
-
className: "shrink-0 text-sm leading-none font-medium whitespace-nowrap",
|
|
333
|
-
children: label
|
|
334
|
-
}
|
|
335
|
-
) : null,
|
|
336
|
-
/* @__PURE__ */ jsx7(
|
|
337
|
-
Input,
|
|
338
|
-
{
|
|
339
|
-
id: controlId,
|
|
340
|
-
type,
|
|
341
|
-
value: typeof fieldValue === "string" ? fieldValue : "",
|
|
342
|
-
placeholder,
|
|
343
|
-
disabled,
|
|
344
|
-
onChange: (event) => {
|
|
345
|
-
form.setValue(name, event.target.value);
|
|
346
|
-
onChange?.(event.target.value);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
),
|
|
350
|
-
error ? /* @__PURE__ */ jsx7("div", { "data-slot": "form-error", className: "text-sm text-destructive", children: error }) : null
|
|
351
|
-
] });
|
|
352
|
-
}
|
|
353
|
-
return /* @__PURE__ */ jsx7(
|
|
354
|
-
Input,
|
|
355
|
-
{
|
|
356
|
-
type,
|
|
357
|
-
value: value ?? "",
|
|
358
|
-
placeholder,
|
|
359
|
-
disabled,
|
|
360
|
-
onChange: (event) => onChange?.(event.target.value)
|
|
361
|
-
}
|
|
362
|
-
);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// src/components/components/Page/index.tsx
|
|
366
|
-
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
367
|
-
function Page({ title, children }) {
|
|
368
|
-
return /* @__PURE__ */ jsxs5("div", { "data-slot": "page", className: "p-6", children: [
|
|
369
|
-
title ? /* @__PURE__ */ jsx8("h2", { "data-slot": "page-title", className: "mb-5 text-xl font-semibold", children: title }) : null,
|
|
370
|
-
/* @__PURE__ */ jsx8("div", { "data-slot": "page-content", className: "space-y-5", children })
|
|
371
|
-
] });
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
// src/components/components/Select/index.tsx
|
|
375
|
-
import { useI18n } from "@pactor-app/runtime";
|
|
376
|
-
import { useEffect as useEffect3, useId as useId2 } from "react";
|
|
377
|
-
import { jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
378
|
-
function Select2({
|
|
379
|
-
name,
|
|
380
|
-
label,
|
|
381
|
-
rules,
|
|
382
|
-
options = [],
|
|
383
|
-
value,
|
|
384
|
-
placeholder,
|
|
385
|
-
disabled,
|
|
386
|
-
allowClear,
|
|
387
|
-
onChange
|
|
388
|
-
}) {
|
|
389
|
-
const form = useFormContext();
|
|
390
|
-
const { t } = useI18n();
|
|
391
|
-
const controlId = useId2();
|
|
392
|
-
const inForm = form?.inForm === true && typeof name === "string" && name !== "";
|
|
393
|
-
useEffect3(() => {
|
|
394
|
-
if (inForm && form && name) {
|
|
395
|
-
form.registerField(name, rules, value);
|
|
396
|
-
return () => form.unregisterField(name);
|
|
397
|
-
}
|
|
398
|
-
return void 0;
|
|
399
|
-
});
|
|
400
|
-
const current = inForm && form && name ? form.values[name] : value;
|
|
401
|
-
const selectedValue = current === void 0 || current === null || current === "" ? null : current;
|
|
402
|
-
const handleChange = (next) => {
|
|
403
|
-
if (inForm && form && name) {
|
|
404
|
-
form.setValue(name, next ?? void 0);
|
|
405
|
-
}
|
|
406
|
-
onChange?.(next ?? void 0);
|
|
407
|
-
};
|
|
408
|
-
const select = /* @__PURE__ */ jsxs6("span", { className: "inline-flex items-center gap-1", children: [
|
|
409
|
-
/* @__PURE__ */ jsxs6(
|
|
410
|
-
Select,
|
|
411
|
-
{
|
|
412
|
-
items: options,
|
|
413
|
-
value: selectedValue,
|
|
414
|
-
onValueChange: handleChange,
|
|
415
|
-
disabled,
|
|
416
|
-
name: inForm ? name : void 0,
|
|
417
|
-
children: [
|
|
418
|
-
/* @__PURE__ */ jsx9(SelectTrigger, { id: controlId, children: /* @__PURE__ */ jsx9(SelectValue, { placeholder }) }),
|
|
419
|
-
/* @__PURE__ */ jsx9(SelectContent, { children: options.map((option) => /* @__PURE__ */ jsx9(SelectItem, { value: option.value, children: option.label }, String(option.value))) })
|
|
420
|
-
]
|
|
421
|
-
}
|
|
422
|
-
),
|
|
423
|
-
allowClear && selectedValue !== null && !disabled ? /* @__PURE__ */ jsx9(
|
|
424
|
-
"button",
|
|
425
|
-
{
|
|
426
|
-
type: "button",
|
|
427
|
-
"aria-label": t("pactor.select.clear"),
|
|
428
|
-
className: "cursor-pointer text-muted-foreground hover:text-foreground",
|
|
429
|
-
onClick: () => {
|
|
430
|
-
if (inForm && form && name) {
|
|
431
|
-
form.setValue(name, void 0);
|
|
432
|
-
}
|
|
433
|
-
onChange?.(void 0);
|
|
434
|
-
},
|
|
435
|
-
children: "\xD7"
|
|
436
|
-
}
|
|
437
|
-
) : null
|
|
438
|
-
] });
|
|
439
|
-
if (inForm && form && name) {
|
|
440
|
-
const error = form.errors[name];
|
|
441
|
-
return /* @__PURE__ */ jsxs6("div", { "data-slot": "form-item", className: formItemClass(form.layout), children: [
|
|
442
|
-
label ? /* @__PURE__ */ jsx9(
|
|
443
|
-
"label",
|
|
444
|
-
{
|
|
445
|
-
htmlFor: controlId,
|
|
446
|
-
className: "shrink-0 text-sm leading-none font-medium whitespace-nowrap",
|
|
447
|
-
children: label
|
|
448
|
-
}
|
|
449
|
-
) : null,
|
|
450
|
-
select,
|
|
451
|
-
error ? /* @__PURE__ */ jsx9("div", { "data-slot": "form-error", className: "text-sm text-destructive", children: error }) : null
|
|
452
|
-
] });
|
|
453
|
-
}
|
|
454
|
-
return select;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
// src/components/components/Statistic/index.tsx
|
|
458
|
-
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
459
|
-
function Statistic({ title, value, precision, suffix }) {
|
|
460
|
-
const display = typeof value === "number" && precision !== void 0 ? value.toFixed(precision) : value;
|
|
461
|
-
return /* @__PURE__ */ jsxs7("div", { "data-slot": "statistic", children: [
|
|
462
|
-
title ? /* @__PURE__ */ jsx10("div", { "data-slot": "statistic-title", className: "text-sm text-muted-foreground", children: title }) : null,
|
|
463
|
-
/* @__PURE__ */ jsxs7("div", { "data-slot": "statistic-value", className: "text-2xl font-bold tabular-nums", children: [
|
|
464
|
-
display,
|
|
465
|
-
suffix ? /* @__PURE__ */ jsx10("span", { className: "ml-1 text-sm font-normal text-muted-foreground", children: suffix }) : null
|
|
466
|
-
] })
|
|
467
|
-
] });
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
// src/components/components/Table/index.tsx
|
|
471
|
-
import { useI18n as useI18n2, useRenderer as useRenderer2 } from "@pactor-app/runtime";
|
|
472
|
-
import { useState as useState2 } from "react";
|
|
473
|
-
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
474
|
-
function renderCellValue(value) {
|
|
475
|
-
if (value === void 0 || value === null) {
|
|
476
|
-
return "";
|
|
477
|
-
}
|
|
478
|
-
if (typeof value === "object") {
|
|
479
|
-
return JSON.stringify(value);
|
|
480
|
-
}
|
|
481
|
-
return String(value);
|
|
482
|
-
}
|
|
483
|
-
function Table2({
|
|
484
|
-
columns = [],
|
|
485
|
-
dataSource = [],
|
|
486
|
-
rowKey = "id",
|
|
487
|
-
loading,
|
|
488
|
-
pagination,
|
|
489
|
-
onChange
|
|
490
|
-
}) {
|
|
491
|
-
const { renderChildren } = useRenderer2();
|
|
492
|
-
const { t } = useI18n2();
|
|
493
|
-
const [current, setCurrent] = useState2(1);
|
|
494
|
-
const pageSize = pagination === false ? void 0 : pagination?.pageSize;
|
|
495
|
-
const total = dataSource.length;
|
|
496
|
-
const pageCount = pageSize !== void 0 && pageSize > 0 ? Math.max(1, Math.ceil(total / pageSize)) : 1;
|
|
497
|
-
const pageRows = pageSize !== void 0 && pageSize > 0 ? dataSource.slice((current - 1) * pageSize, current * pageSize) : dataSource;
|
|
498
|
-
const goToPage = (page) => {
|
|
499
|
-
setCurrent(page);
|
|
500
|
-
onChange?.({ current: page, pageSize, total });
|
|
501
|
-
};
|
|
502
|
-
return /* @__PURE__ */ jsxs8("div", { "data-slot": "dsl-table", className: "relative", children: [
|
|
503
|
-
loading ? /* @__PURE__ */ jsx11(
|
|
504
|
-
"div",
|
|
505
|
-
{
|
|
506
|
-
"data-slot": "table-loading",
|
|
507
|
-
className: "absolute inset-0 z-10 flex items-center justify-center bg-background/60 text-sm text-muted-foreground",
|
|
508
|
-
children: t("pactor.table.loading")
|
|
509
|
-
}
|
|
510
|
-
) : null,
|
|
511
|
-
/* @__PURE__ */ jsxs8(Table, { children: [
|
|
512
|
-
/* @__PURE__ */ jsx11(TableHeader, { children: /* @__PURE__ */ jsx11(TableRow, { className: "hover:bg-transparent", children: columns.map((column, index) => /* @__PURE__ */ jsx11(
|
|
513
|
-
TableHead,
|
|
514
|
-
{
|
|
515
|
-
style: column.width !== void 0 ? { width: column.width } : void 0,
|
|
516
|
-
children: column.title
|
|
517
|
-
},
|
|
518
|
-
column.dataIndex ?? String(index)
|
|
519
|
-
)) }) }),
|
|
520
|
-
/* @__PURE__ */ jsx11(TableBody, { children: pageRows.length === 0 ? /* @__PURE__ */ jsx11(TableRow, { className: "hover:bg-transparent", children: /* @__PURE__ */ jsx11(TableCell, { colSpan: Math.max(1, columns.length), children: /* @__PURE__ */ jsx11(
|
|
521
|
-
"div",
|
|
522
|
-
{
|
|
523
|
-
"data-slot": "table-empty",
|
|
524
|
-
className: "py-8 text-center text-muted-foreground",
|
|
525
|
-
children: t("pactor.table.empty")
|
|
526
|
-
}
|
|
527
|
-
) }) }) : pageRows.map((row, rowIndex) => {
|
|
528
|
-
const key = row[rowKey];
|
|
529
|
-
return /* @__PURE__ */ jsx11(
|
|
530
|
-
TableRow,
|
|
531
|
-
{
|
|
532
|
-
children: columns.map((column, columnIndex) => /* @__PURE__ */ jsx11(TableCell, { children: column.cell ? renderChildren([column.cell], { row, rowIndex }) : renderCellValue(
|
|
533
|
-
column.dataIndex === void 0 ? void 0 : row[column.dataIndex]
|
|
534
|
-
) }, column.dataIndex ?? String(columnIndex)))
|
|
535
|
-
},
|
|
536
|
-
key === void 0 || key === null ? rowIndex : String(key)
|
|
537
|
-
);
|
|
538
|
-
}) })
|
|
539
|
-
] }),
|
|
540
|
-
pageSize !== void 0 && pageSize > 0 ? /* @__PURE__ */ jsx11("div", { "data-slot": "table-pagination", className: "mt-3 flex justify-end gap-1", children: Array.from({ length: pageCount }, (_, index) => index + 1).map(
|
|
541
|
-
(page) => /* @__PURE__ */ jsx11(
|
|
542
|
-
Button,
|
|
543
|
-
{
|
|
544
|
-
type: "button",
|
|
545
|
-
size: "sm",
|
|
546
|
-
variant: page === current ? "default" : "outline",
|
|
547
|
-
"aria-current": page === current ? "page" : void 0,
|
|
548
|
-
onClick: () => goToPage(page),
|
|
549
|
-
children: page
|
|
550
|
-
},
|
|
551
|
-
page
|
|
552
|
-
)
|
|
553
|
-
) }) : null
|
|
554
|
-
] });
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
// src/components/components/Tabs/index.tsx
|
|
558
|
-
import { useRenderer as useRenderer3 } from "@pactor-app/runtime";
|
|
559
|
-
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
560
|
-
function Tabs2({ items = [], activeKey, onChange }) {
|
|
561
|
-
const { renderChildren } = useRenderer3();
|
|
562
|
-
return /* @__PURE__ */ jsxs9(
|
|
563
|
-
Tabs,
|
|
564
|
-
{
|
|
565
|
-
value: activeKey,
|
|
566
|
-
defaultValue: activeKey === void 0 ? items[0]?.key : void 0,
|
|
567
|
-
onValueChange: (key) => onChange?.(key),
|
|
568
|
-
children: [
|
|
569
|
-
/* @__PURE__ */ jsx12(TabsList, { children: items.map((item) => /* @__PURE__ */ jsx12(TabsTrigger, { value: item.key, children: item.label }, item.key)) }),
|
|
570
|
-
items.map((item) => /* @__PURE__ */ jsx12(TabsContent, { value: item.key, children: renderChildren(item.children) }, item.key))
|
|
571
|
-
]
|
|
572
|
-
}
|
|
573
|
-
);
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
// src/components/register.ts
|
|
577
|
-
var shadcnComponents = {
|
|
578
|
-
Page,
|
|
579
|
-
Grid,
|
|
580
|
-
Flex,
|
|
581
|
-
Card: Card2,
|
|
582
|
-
Button: Button2,
|
|
583
|
-
Alert: Alert2,
|
|
584
|
-
Statistic,
|
|
585
|
-
Tabs: Tabs2,
|
|
586
|
-
Table: Table2,
|
|
587
|
-
Form,
|
|
588
|
-
Input: Input2,
|
|
589
|
-
Select: Select2
|
|
590
|
-
};
|
|
591
|
-
function registerShadcnComponents(registry) {
|
|
592
|
-
for (const [type, component] of Object.entries(shadcnComponents)) {
|
|
593
|
-
registry.register(type, component);
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
function createShadcnComponentRegistry() {
|
|
597
|
-
const registry = new Registry("ComponentRegistry");
|
|
598
|
-
registerShadcnComponents(registry);
|
|
599
|
-
return registry;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
export {
|
|
603
|
-
Alert2 as Alert,
|
|
604
|
-
Button2 as Button,
|
|
605
|
-
Card2 as Card,
|
|
606
|
-
Flex,
|
|
607
|
-
useFormContext,
|
|
608
|
-
Form,
|
|
609
|
-
Grid,
|
|
610
|
-
Input2 as Input,
|
|
611
|
-
Page,
|
|
612
|
-
Select2 as Select,
|
|
613
|
-
Statistic,
|
|
614
|
-
Table2 as Table,
|
|
615
|
-
Tabs2 as Tabs,
|
|
616
|
-
shadcnComponents,
|
|
617
|
-
registerShadcnComponents,
|
|
618
|
-
createShadcnComponentRegistry
|
|
619
|
-
};
|