@questpie/admin 0.0.1 → 1.0.1
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/README.md +439 -424
- package/dist/auth-layout-M8K8_q5R.mjs +181 -0
- package/dist/auth-layout-M8K8_q5R.mjs.map +1 -0
- package/dist/bulk-upload-dialog-D7w7W1Hl.mjs +273 -0
- package/dist/bulk-upload-dialog-D7w7W1Hl.mjs.map +1 -0
- package/dist/{components/ui/card.mjs → card-BKHjBQfw.mjs} +8 -8
- package/dist/card-BKHjBQfw.mjs.map +1 -0
- package/dist/client/styles/index.css +434 -0
- package/dist/client-DbpZKSgH.d.mts +13585 -0
- package/dist/client-DbpZKSgH.d.mts.map +1 -0
- package/dist/client-njX1rZmi.mjs +22612 -0
- package/dist/client-njX1rZmi.mjs.map +1 -0
- package/dist/client.d.mts +3 -0
- package/dist/client.mjs +13 -0
- package/dist/content-locales-provider-BXvuIgfg.mjs +1650 -0
- package/dist/content-locales-provider-BXvuIgfg.mjs.map +1 -0
- package/dist/dashboard-page-B4PGEdc2.mjs +2500 -0
- package/dist/dashboard-page-B4PGEdc2.mjs.map +1 -0
- package/dist/dashboard-page-mCY0pgZv.mjs +3 -0
- package/dist/dropzone-Do3awXKd.mjs +634 -0
- package/dist/dropzone-Do3awXKd.mjs.map +1 -0
- package/dist/{views/auth/forgot-password-form.mjs → forgot-password-page-Bcp-An4Y.mjs} +87 -14
- package/dist/forgot-password-page-Bcp-An4Y.mjs.map +1 -0
- package/dist/forgot-password-page-CEwsdLwn.mjs +3 -0
- package/dist/index-B9Xwk4hi.d.mts +2753 -0
- package/dist/index-B9Xwk4hi.d.mts.map +1 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +13 -0
- package/dist/login-page-BUnpCbCa.mjs +3 -0
- package/dist/login-page-CP4gA-dl.mjs +298 -0
- package/dist/login-page-CP4gA-dl.mjs.map +1 -0
- package/dist/preview-utils-BKQ9-TMa.mjs +65 -0
- package/dist/preview-utils-BKQ9-TMa.mjs.map +1 -0
- package/dist/{views/auth/reset-password-form.mjs → reset-password-page-BqfDmLxA.mjs} +111 -14
- package/dist/reset-password-page-BqfDmLxA.mjs.map +1 -0
- package/dist/reset-password-page-CufHz3h3.mjs +3 -0
- package/dist/runtime-6VZM878K.mjs +69 -0
- package/dist/runtime-6VZM878K.mjs.map +1 -0
- package/dist/saved-views.types-BMsz5mCy.d.mts +42 -0
- package/dist/saved-views.types-BMsz5mCy.d.mts.map +1 -0
- package/dist/server.d.mts +250 -0
- package/dist/server.d.mts.map +1 -0
- package/dist/server.mjs +832 -0
- package/dist/server.mjs.map +1 -0
- package/dist/setup-page-BNNzt_Z6.mjs +3 -0
- package/dist/setup-page-YAP_fzqh.mjs +264 -0
- package/dist/setup-page-YAP_fzqh.mjs.map +1 -0
- package/dist/shared.d.mts +57 -0
- package/dist/shared.d.mts.map +1 -0
- package/dist/shared.mjs +3 -0
- package/dist/{hooks/use-auth.mjs → use-auth-BoLmWtmU.mjs} +42 -30
- package/dist/use-auth-BoLmWtmU.mjs.map +1 -0
- package/package.json +48 -198
- package/.turbo/turbo-build.log +0 -108
- package/CHANGELOG.md +0 -10
- package/STATUS.md +0 -917
- package/VALIDATION.md +0 -602
- package/components.json +0 -24
- package/dist/__tests__/setup.mjs +0 -38
- package/dist/__tests__/test-utils.mjs +0 -45
- package/dist/__tests__/vitest.d.mjs +0 -3
- package/dist/components/admin-app.mjs +0 -69
- package/dist/components/fields/array-field.mjs +0 -190
- package/dist/components/fields/checkbox-field.mjs +0 -34
- package/dist/components/fields/custom-field.mjs +0 -32
- package/dist/components/fields/date-field.mjs +0 -41
- package/dist/components/fields/datetime-field.mjs +0 -42
- package/dist/components/fields/email-field.mjs +0 -37
- package/dist/components/fields/embedded-collection.mjs +0 -253
- package/dist/components/fields/field-types.mjs +0 -1
- package/dist/components/fields/field-utils.mjs +0 -10
- package/dist/components/fields/field-wrapper.mjs +0 -34
- package/dist/components/fields/index.mjs +0 -23
- package/dist/components/fields/json-field.mjs +0 -243
- package/dist/components/fields/locale-badge.mjs +0 -16
- package/dist/components/fields/number-field.mjs +0 -39
- package/dist/components/fields/password-field.mjs +0 -37
- package/dist/components/fields/relation-field.mjs +0 -104
- package/dist/components/fields/relation-picker.mjs +0 -229
- package/dist/components/fields/relation-select.mjs +0 -188
- package/dist/components/fields/rich-text-editor/index.mjs +0 -897
- package/dist/components/fields/select-field.mjs +0 -41
- package/dist/components/fields/switch-field.mjs +0 -34
- package/dist/components/fields/text-field.mjs +0 -38
- package/dist/components/fields/textarea-field.mjs +0 -38
- package/dist/components/index.mjs +0 -59
- package/dist/components/primitives/checkbox-input.mjs +0 -127
- package/dist/components/primitives/date-input.mjs +0 -303
- package/dist/components/primitives/index.mjs +0 -12
- package/dist/components/primitives/number-input.mjs +0 -104
- package/dist/components/primitives/select-input.mjs +0 -177
- package/dist/components/primitives/tag-input.mjs +0 -135
- package/dist/components/primitives/text-input.mjs +0 -39
- package/dist/components/primitives/textarea-input.mjs +0 -37
- package/dist/components/primitives/toggle-input.mjs +0 -31
- package/dist/components/primitives/types.mjs +0 -12
- package/dist/components/ui/accordion.mjs +0 -55
- package/dist/components/ui/avatar.mjs +0 -54
- package/dist/components/ui/badge.mjs +0 -34
- package/dist/components/ui/button.mjs +0 -48
- package/dist/components/ui/checkbox.mjs +0 -21
- package/dist/components/ui/combobox.mjs +0 -163
- package/dist/components/ui/dialog.mjs +0 -95
- package/dist/components/ui/dropdown-menu.mjs +0 -138
- package/dist/components/ui/field.mjs +0 -113
- package/dist/components/ui/input-group.mjs +0 -82
- package/dist/components/ui/input.mjs +0 -17
- package/dist/components/ui/label.mjs +0 -15
- package/dist/components/ui/popover.mjs +0 -56
- package/dist/components/ui/scroll-area.mjs +0 -38
- package/dist/components/ui/select.mjs +0 -100
- package/dist/components/ui/separator.mjs +0 -16
- package/dist/components/ui/sheet.mjs +0 -90
- package/dist/components/ui/sidebar.mjs +0 -387
- package/dist/components/ui/skeleton.mjs +0 -14
- package/dist/components/ui/spinner.mjs +0 -16
- package/dist/components/ui/switch.mjs +0 -22
- package/dist/components/ui/table.mjs +0 -68
- package/dist/components/ui/tabs.mjs +0 -48
- package/dist/components/ui/textarea.mjs +0 -15
- package/dist/components/ui/tooltip.mjs +0 -44
- package/dist/config/component-registry.mjs +0 -38
- package/dist/config/index.mjs +0 -129
- package/dist/hooks/admin-provider.mjs +0 -70
- package/dist/hooks/index.mjs +0 -7
- package/dist/hooks/store.mjs +0 -178
- package/dist/hooks/use-collection-db.mjs +0 -146
- package/dist/hooks/use-collection.mjs +0 -112
- package/dist/hooks/use-global.mjs +0 -46
- package/dist/hooks/use-mobile.mjs +0 -20
- package/dist/lib/utils.mjs +0 -10
- package/dist/styles/index.css +0 -336
- package/dist/styles/index.mjs +0 -1
- package/dist/utils/index.mjs +0 -9
- package/dist/views/auth/auth-layout.mjs +0 -52
- package/dist/views/auth/index.mjs +0 -6
- package/dist/views/auth/login-form.mjs +0 -156
- package/dist/views/collection/auto-form-fields.mjs +0 -525
- package/dist/views/collection/collection-form.mjs +0 -91
- package/dist/views/collection/collection-list.mjs +0 -76
- package/dist/views/collection/form-field.mjs +0 -42
- package/dist/views/collection/index.mjs +0 -6
- package/dist/views/common/index.mjs +0 -4
- package/dist/views/common/locale-switcher.mjs +0 -39
- package/dist/views/common/version-history.mjs +0 -272
- package/dist/views/index.mjs +0 -9
- package/dist/views/layout/admin-layout.mjs +0 -40
- package/dist/views/layout/admin-router.mjs +0 -95
- package/dist/views/layout/admin-sidebar.mjs +0 -63
- package/dist/views/layout/index.mjs +0 -5
- package/src/__tests__/setup.ts +0 -44
- package/src/__tests__/test-utils.tsx +0 -49
- package/src/__tests__/vitest.d.ts +0 -9
- package/src/components/admin-app.tsx +0 -221
- package/src/components/fields/array-field.tsx +0 -237
- package/src/components/fields/checkbox-field.tsx +0 -47
- package/src/components/fields/custom-field.tsx +0 -50
- package/src/components/fields/date-field.tsx +0 -65
- package/src/components/fields/datetime-field.tsx +0 -67
- package/src/components/fields/email-field.tsx +0 -51
- package/src/components/fields/embedded-collection.tsx +0 -315
- package/src/components/fields/field-types.ts +0 -162
- package/src/components/fields/field-utils.ts +0 -6
- package/src/components/fields/field-wrapper.tsx +0 -52
- package/src/components/fields/index.ts +0 -66
- package/src/components/fields/json-field.tsx +0 -440
- package/src/components/fields/locale-badge.tsx +0 -15
- package/src/components/fields/number-field.tsx +0 -57
- package/src/components/fields/password-field.tsx +0 -51
- package/src/components/fields/relation-field.tsx +0 -243
- package/src/components/fields/relation-picker.tsx +0 -402
- package/src/components/fields/relation-select.tsx +0 -327
- package/src/components/fields/rich-text-editor/index.tsx +0 -1337
- package/src/components/fields/select-field.tsx +0 -61
- package/src/components/fields/switch-field.tsx +0 -47
- package/src/components/fields/text-field.tsx +0 -55
- package/src/components/fields/textarea-field.tsx +0 -55
- package/src/components/index.ts +0 -40
- package/src/components/primitives/checkbox-input.tsx +0 -193
- package/src/components/primitives/date-input.tsx +0 -401
- package/src/components/primitives/index.ts +0 -24
- package/src/components/primitives/number-input.tsx +0 -132
- package/src/components/primitives/select-input.tsx +0 -296
- package/src/components/primitives/tag-input.tsx +0 -200
- package/src/components/primitives/text-input.tsx +0 -49
- package/src/components/primitives/textarea-input.tsx +0 -46
- package/src/components/primitives/toggle-input.tsx +0 -36
- package/src/components/primitives/types.ts +0 -235
- package/src/components/ui/accordion.tsx +0 -72
- package/src/components/ui/avatar.tsx +0 -106
- package/src/components/ui/badge.tsx +0 -48
- package/src/components/ui/button.tsx +0 -53
- package/src/components/ui/card.tsx +0 -94
- package/src/components/ui/checkbox.tsx +0 -27
- package/src/components/ui/combobox.tsx +0 -290
- package/src/components/ui/dialog.tsx +0 -151
- package/src/components/ui/dropdown-menu.tsx +0 -254
- package/src/components/ui/field.tsx +0 -227
- package/src/components/ui/input-group.tsx +0 -149
- package/src/components/ui/input.tsx +0 -20
- package/src/components/ui/label.tsx +0 -18
- package/src/components/ui/popover.tsx +0 -88
- package/src/components/ui/scroll-area.tsx +0 -53
- package/src/components/ui/select.tsx +0 -192
- package/src/components/ui/separator.tsx +0 -23
- package/src/components/ui/sheet.tsx +0 -127
- package/src/components/ui/sidebar.tsx +0 -723
- package/src/components/ui/skeleton.tsx +0 -13
- package/src/components/ui/spinner.tsx +0 -10
- package/src/components/ui/switch.tsx +0 -32
- package/src/components/ui/table.tsx +0 -99
- package/src/components/ui/tabs.tsx +0 -82
- package/src/components/ui/textarea.tsx +0 -18
- package/src/components/ui/tooltip.tsx +0 -70
- package/src/config/component-registry.ts +0 -190
- package/src/config/index.ts +0 -1099
- package/src/hooks/README.md +0 -269
- package/src/hooks/admin-provider.tsx +0 -110
- package/src/hooks/index.ts +0 -41
- package/src/hooks/store.ts +0 -248
- package/src/hooks/use-auth.ts +0 -168
- package/src/hooks/use-collection-db.ts +0 -209
- package/src/hooks/use-collection.ts +0 -156
- package/src/hooks/use-global.ts +0 -69
- package/src/hooks/use-mobile.ts +0 -21
- package/src/lib/utils.ts +0 -6
- package/src/styles/index.css +0 -340
- package/src/utils/index.ts +0 -6
- package/src/views/auth/auth-layout.tsx +0 -77
- package/src/views/auth/forgot-password-form.tsx +0 -192
- package/src/views/auth/index.ts +0 -21
- package/src/views/auth/login-form.tsx +0 -229
- package/src/views/auth/reset-password-form.tsx +0 -232
- package/src/views/collection/auto-form-fields.tsx +0 -982
- package/src/views/collection/collection-form.tsx +0 -186
- package/src/views/collection/collection-list.tsx +0 -223
- package/src/views/collection/form-field.tsx +0 -52
- package/src/views/collection/index.ts +0 -15
- package/src/views/common/index.ts +0 -8
- package/src/views/common/locale-switcher.tsx +0 -45
- package/src/views/common/version-history.tsx +0 -406
- package/src/views/index.ts +0 -25
- package/src/views/layout/admin-layout.tsx +0 -117
- package/src/views/layout/admin-router.tsx +0 -206
- package/src/views/layout/admin-sidebar.tsx +0 -185
- package/src/views/layout/index.ts +0 -12
- package/tsconfig.json +0 -13
- package/tsconfig.tsbuildinfo +0 -1
- package/tsdown.config.ts +0 -13
- package/vitest.config.ts +0 -29
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import * as React$1 from "react";
|
|
2
|
-
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
3
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { AdminProvider } from "../hooks/admin-provider";
|
|
5
|
-
import { AdminLayout } from "../views/layout/admin-layout";
|
|
6
|
-
import { AdminRouter } from "../views/layout/admin-router";
|
|
7
|
-
import { mergeComponentRegistry } from "../config/component-registry";
|
|
8
|
-
|
|
9
|
-
//#region src/components/admin-app.tsx
|
|
10
|
-
/**
|
|
11
|
-
* AdminApp Component
|
|
12
|
-
*
|
|
13
|
-
* MAIN ENTRY POINT - Mount this and you have a complete admin!
|
|
14
|
-
*
|
|
15
|
-
* Minimal usage:
|
|
16
|
-
* <AdminApp client={cmsClient} />
|
|
17
|
-
*
|
|
18
|
-
* Everything else is OPTIONAL customization.
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* Default QueryClient configuration
|
|
22
|
-
*/
|
|
23
|
-
function createDefaultQueryClient() {
|
|
24
|
-
return new QueryClient({ defaultOptions: { queries: {
|
|
25
|
-
staleTime: 60 * 1e3,
|
|
26
|
-
refetchOnWindowFocus: false
|
|
27
|
-
} } });
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* AdminApp Component
|
|
31
|
-
*
|
|
32
|
-
* ONE COMPONENT TO RULE THEM ALL!
|
|
33
|
-
*/
|
|
34
|
-
function AdminApp({ client, config, registry, queryClient, router, basePath = "/admin", DashboardComponent, collectionComponents, renderFormFields }) {
|
|
35
|
-
const [defaultQueryClient] = React$1.useState(() => queryClient ?? createDefaultQueryClient());
|
|
36
|
-
const mergedRegistry = React$1.useMemo(() => mergeComponentRegistry(registry), [registry]);
|
|
37
|
-
const finalConfig = React$1.useMemo(() => {
|
|
38
|
-
if (config) return config;
|
|
39
|
-
return {
|
|
40
|
-
app: { brand: { name: "Admin" } },
|
|
41
|
-
collections: {}
|
|
42
|
-
};
|
|
43
|
-
}, [config]);
|
|
44
|
-
return /* @__PURE__ */ jsxs(QueryClientProvider, {
|
|
45
|
-
client: defaultQueryClient,
|
|
46
|
-
children: [/* @__PURE__ */ jsx(AdminProvider, {
|
|
47
|
-
client,
|
|
48
|
-
queryClient: defaultQueryClient,
|
|
49
|
-
locales: finalConfig.app?.locales,
|
|
50
|
-
children: /* @__PURE__ */ jsx(AdminLayout, {
|
|
51
|
-
config: finalConfig,
|
|
52
|
-
activeRoute: router.currentPath,
|
|
53
|
-
LinkComponent: router.LinkComponent,
|
|
54
|
-
children: /* @__PURE__ */ jsx(AdminRouter, {
|
|
55
|
-
config: finalConfig,
|
|
56
|
-
segments: router.segments,
|
|
57
|
-
navigate: router.navigate,
|
|
58
|
-
DashboardComponent,
|
|
59
|
-
collectionComponents,
|
|
60
|
-
renderFormFields,
|
|
61
|
-
registry: mergedRegistry
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
}), config?.app?.debug?.showQueryDevtools && /* @__PURE__ */ jsx("div", {})]
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
export { AdminApp };
|
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
import * as React$1 from "react";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Button } from "../ui/button";
|
|
4
|
-
import { Input } from "../ui/input";
|
|
5
|
-
import { Select, SelectContent, SelectItem, SelectTrigger } from "../ui/select";
|
|
6
|
-
import { Textarea } from "../ui/textarea";
|
|
7
|
-
import { CaretDown, CaretUp, Plus, Trash } from "@phosphor-icons/react";
|
|
8
|
-
import { useFieldArray, useFormContext, useWatch } from "react-hook-form";
|
|
9
|
-
import { LocaleBadge } from "./locale-badge";
|
|
10
|
-
|
|
11
|
-
//#region src/components/fields/array-field.tsx
|
|
12
|
-
/**
|
|
13
|
-
* ArrayField Component
|
|
14
|
-
*
|
|
15
|
-
* Handles arrays of primitive values with optional ordering.
|
|
16
|
-
*/
|
|
17
|
-
function ArrayField({ name, value, label, description, placeholder, required, disabled, readOnly, error, localized, locale, itemType = "text", options, orderable = false, minItems, maxItems }) {
|
|
18
|
-
const form = useFormContext();
|
|
19
|
-
const { control } = form;
|
|
20
|
-
const { fields, append, remove, move } = useFieldArray({
|
|
21
|
-
control,
|
|
22
|
-
name
|
|
23
|
-
});
|
|
24
|
-
const values = useWatch({
|
|
25
|
-
control,
|
|
26
|
-
name
|
|
27
|
-
}) ?? value;
|
|
28
|
-
const canAddMore = !maxItems || fields.length < maxItems;
|
|
29
|
-
const canRemove = !readOnly && (!minItems || fields.length > minItems);
|
|
30
|
-
const createEmptyItem = React$1.useCallback(() => {
|
|
31
|
-
if (itemType === "number") return void 0;
|
|
32
|
-
if (itemType === "select") return options?.[0]?.value ?? "";
|
|
33
|
-
return "";
|
|
34
|
-
}, [itemType, options]);
|
|
35
|
-
const handleAdd = () => {
|
|
36
|
-
if (disabled || readOnly || !canAddMore) return;
|
|
37
|
-
append(createEmptyItem());
|
|
38
|
-
};
|
|
39
|
-
const handleRemove = (index) => {
|
|
40
|
-
if (!canRemove) return;
|
|
41
|
-
remove(index);
|
|
42
|
-
};
|
|
43
|
-
const handleMove = (from, to) => {
|
|
44
|
-
if (to < 0 || to >= fields.length) return;
|
|
45
|
-
move(from, to);
|
|
46
|
-
};
|
|
47
|
-
const renderItemInput = (index) => {
|
|
48
|
-
const itemName = `${name}.${index}`;
|
|
49
|
-
const itemValue = values?.[index];
|
|
50
|
-
const itemPlaceholder = placeholder || `Item ${index + 1}`;
|
|
51
|
-
if (itemType === "textarea") return /* @__PURE__ */ jsx(Textarea, {
|
|
52
|
-
id: itemName,
|
|
53
|
-
placeholder: itemPlaceholder,
|
|
54
|
-
disabled: disabled || readOnly,
|
|
55
|
-
defaultValue: itemValue ?? "",
|
|
56
|
-
...form.register(itemName)
|
|
57
|
-
});
|
|
58
|
-
if (itemType === "select") return /* @__PURE__ */ jsxs(Select, {
|
|
59
|
-
value: itemValue ?? "",
|
|
60
|
-
onValueChange: (value$1) => form.setValue(itemName, value$1, {
|
|
61
|
-
shouldDirty: true,
|
|
62
|
-
shouldTouch: true
|
|
63
|
-
}),
|
|
64
|
-
disabled: disabled || readOnly,
|
|
65
|
-
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
66
|
-
id: itemName,
|
|
67
|
-
children: /* @__PURE__ */ jsx("span", {
|
|
68
|
-
className: "truncate",
|
|
69
|
-
children: options?.find((o) => o.value === itemValue)?.label || itemPlaceholder
|
|
70
|
-
})
|
|
71
|
-
}), /* @__PURE__ */ jsx(SelectContent, { children: options?.map((option) => /* @__PURE__ */ jsx(SelectItem, {
|
|
72
|
-
value: option.value,
|
|
73
|
-
children: option.label
|
|
74
|
-
}, option.value)) })]
|
|
75
|
-
});
|
|
76
|
-
return /* @__PURE__ */ jsx(Input, {
|
|
77
|
-
id: itemName,
|
|
78
|
-
type: itemType === "email" ? "email" : itemType,
|
|
79
|
-
placeholder: itemPlaceholder,
|
|
80
|
-
disabled: disabled || readOnly,
|
|
81
|
-
defaultValue: itemValue ?? "",
|
|
82
|
-
...form.register(itemName, itemType === "number" ? { valueAsNumber: true } : void 0)
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
86
|
-
className: "space-y-2",
|
|
87
|
-
children: [
|
|
88
|
-
label && /* @__PURE__ */ jsxs("div", {
|
|
89
|
-
className: "flex items-center gap-2",
|
|
90
|
-
children: [/* @__PURE__ */ jsxs("label", {
|
|
91
|
-
htmlFor: name,
|
|
92
|
-
className: "text-sm font-medium",
|
|
93
|
-
children: [
|
|
94
|
-
label,
|
|
95
|
-
required && /* @__PURE__ */ jsx("span", {
|
|
96
|
-
className: "text-destructive",
|
|
97
|
-
children: "*"
|
|
98
|
-
}),
|
|
99
|
-
maxItems && /* @__PURE__ */ jsxs("span", {
|
|
100
|
-
className: "ml-2 text-xs text-muted-foreground",
|
|
101
|
-
children: [
|
|
102
|
-
"(",
|
|
103
|
-
fields.length,
|
|
104
|
-
"/",
|
|
105
|
-
maxItems,
|
|
106
|
-
")"
|
|
107
|
-
]
|
|
108
|
-
})
|
|
109
|
-
]
|
|
110
|
-
}), localized && /* @__PURE__ */ jsx(LocaleBadge, { locale: locale || "i18n" })]
|
|
111
|
-
}),
|
|
112
|
-
description && /* @__PURE__ */ jsx("p", {
|
|
113
|
-
className: "text-sm text-muted-foreground",
|
|
114
|
-
children: description
|
|
115
|
-
}),
|
|
116
|
-
/* @__PURE__ */ jsx("div", {
|
|
117
|
-
className: "space-y-2",
|
|
118
|
-
children: fields.length === 0 ? /* @__PURE__ */ jsx("div", {
|
|
119
|
-
className: "rounded-lg border border-dashed p-4 text-center",
|
|
120
|
-
children: /* @__PURE__ */ jsx("p", {
|
|
121
|
-
className: "text-sm text-muted-foreground",
|
|
122
|
-
children: placeholder || `No ${label || "items"} added yet`
|
|
123
|
-
})
|
|
124
|
-
}) : fields.map((field, index) => {
|
|
125
|
-
const canMoveUp = orderable && index > 0;
|
|
126
|
-
const canMoveDown = orderable && index < fields.length - 1;
|
|
127
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
128
|
-
className: "flex items-start gap-2",
|
|
129
|
-
children: [
|
|
130
|
-
/* @__PURE__ */ jsx("div", {
|
|
131
|
-
className: "flex-1",
|
|
132
|
-
children: renderItemInput(index)
|
|
133
|
-
}),
|
|
134
|
-
orderable && !readOnly && /* @__PURE__ */ jsxs("div", {
|
|
135
|
-
className: "flex flex-col gap-1",
|
|
136
|
-
children: [/* @__PURE__ */ jsx(Button, {
|
|
137
|
-
type: "button",
|
|
138
|
-
variant: "ghost",
|
|
139
|
-
size: "icon",
|
|
140
|
-
className: "h-6 w-6",
|
|
141
|
-
onClick: () => handleMove(index, index - 1),
|
|
142
|
-
disabled: !canMoveUp || disabled,
|
|
143
|
-
title: "Move up",
|
|
144
|
-
children: /* @__PURE__ */ jsx(CaretUp, { className: "h-3 w-3" })
|
|
145
|
-
}), /* @__PURE__ */ jsx(Button, {
|
|
146
|
-
type: "button",
|
|
147
|
-
variant: "ghost",
|
|
148
|
-
size: "icon",
|
|
149
|
-
className: "h-6 w-6",
|
|
150
|
-
onClick: () => handleMove(index, index + 1),
|
|
151
|
-
disabled: !canMoveDown || disabled,
|
|
152
|
-
title: "Move down",
|
|
153
|
-
children: /* @__PURE__ */ jsx(CaretDown, { className: "h-3 w-3" })
|
|
154
|
-
})]
|
|
155
|
-
}),
|
|
156
|
-
!readOnly && canRemove && /* @__PURE__ */ jsx(Button, {
|
|
157
|
-
type: "button",
|
|
158
|
-
variant: "ghost",
|
|
159
|
-
size: "icon",
|
|
160
|
-
className: "h-6 w-6",
|
|
161
|
-
onClick: () => handleRemove(index),
|
|
162
|
-
disabled,
|
|
163
|
-
title: "Remove",
|
|
164
|
-
children: /* @__PURE__ */ jsx(Trash, { className: "h-3 w-3" })
|
|
165
|
-
})
|
|
166
|
-
]
|
|
167
|
-
}, field.id);
|
|
168
|
-
})
|
|
169
|
-
}),
|
|
170
|
-
!readOnly && canAddMore && /* @__PURE__ */ jsxs(Button, {
|
|
171
|
-
type: "button",
|
|
172
|
-
variant: "outline",
|
|
173
|
-
onClick: handleAdd,
|
|
174
|
-
disabled,
|
|
175
|
-
children: [
|
|
176
|
-
/* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
|
|
177
|
-
"Add ",
|
|
178
|
-
label || "item"
|
|
179
|
-
]
|
|
180
|
-
}),
|
|
181
|
-
error && /* @__PURE__ */ jsx("p", {
|
|
182
|
-
className: "text-sm text-destructive",
|
|
183
|
-
children: error
|
|
184
|
-
})
|
|
185
|
-
]
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
//#endregion
|
|
190
|
-
export { ArrayField };
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { CheckboxInput } from "../primitives/checkbox-input";
|
|
3
|
-
import { Controller } from "react-hook-form";
|
|
4
|
-
import { FieldWrapper } from "./field-wrapper";
|
|
5
|
-
import { useResolvedControl } from "./field-utils";
|
|
6
|
-
|
|
7
|
-
//#region src/components/fields/checkbox-field.tsx
|
|
8
|
-
function CheckboxField({ name, label, description, required, disabled, localized, locale, control, className }) {
|
|
9
|
-
return /* @__PURE__ */ jsx(Controller, {
|
|
10
|
-
name,
|
|
11
|
-
control: useResolvedControl(control),
|
|
12
|
-
render: ({ field, fieldState }) => /* @__PURE__ */ jsx(FieldWrapper, {
|
|
13
|
-
name,
|
|
14
|
-
label,
|
|
15
|
-
description,
|
|
16
|
-
required,
|
|
17
|
-
disabled,
|
|
18
|
-
localized,
|
|
19
|
-
locale,
|
|
20
|
-
error: fieldState.error?.message,
|
|
21
|
-
children: /* @__PURE__ */ jsx(CheckboxInput, {
|
|
22
|
-
id: name,
|
|
23
|
-
value: !!field.value,
|
|
24
|
-
onChange: field.onChange,
|
|
25
|
-
disabled,
|
|
26
|
-
"aria-invalid": !!fieldState.error,
|
|
27
|
-
className
|
|
28
|
-
})
|
|
29
|
-
})
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
//#endregion
|
|
34
|
-
export { CheckboxField };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import "react";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { Controller } from "react-hook-form";
|
|
4
|
-
import { FieldWrapper } from "./field-wrapper";
|
|
5
|
-
import { useResolvedControl } from "./field-utils";
|
|
6
|
-
|
|
7
|
-
//#region src/components/fields/custom-field.tsx
|
|
8
|
-
function CustomField({ name, label, description, placeholder, required, disabled, localized, locale, control, component: Component }) {
|
|
9
|
-
return /* @__PURE__ */ jsx(Controller, {
|
|
10
|
-
name,
|
|
11
|
-
control: useResolvedControl(control),
|
|
12
|
-
render: ({ field, fieldState }) => /* @__PURE__ */ jsx(FieldWrapper, {
|
|
13
|
-
name,
|
|
14
|
-
label,
|
|
15
|
-
description,
|
|
16
|
-
required,
|
|
17
|
-
disabled,
|
|
18
|
-
localized,
|
|
19
|
-
locale,
|
|
20
|
-
error: fieldState.error?.message,
|
|
21
|
-
children: /* @__PURE__ */ jsx(Component, {
|
|
22
|
-
...field,
|
|
23
|
-
id: name,
|
|
24
|
-
disabled,
|
|
25
|
-
placeholder
|
|
26
|
-
})
|
|
27
|
-
})
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
//#endregion
|
|
32
|
-
export { CustomField };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { DateInput } from "../primitives/date-input";
|
|
3
|
-
import { Controller } from "react-hook-form";
|
|
4
|
-
import { FieldWrapper } from "./field-wrapper";
|
|
5
|
-
import { useResolvedControl } from "./field-utils";
|
|
6
|
-
|
|
7
|
-
//#region src/components/fields/date-field.tsx
|
|
8
|
-
function DateField({ name, label, description, placeholder, required, disabled, localized, locale, control, className, minDate, maxDate, format }) {
|
|
9
|
-
return /* @__PURE__ */ jsx(Controller, {
|
|
10
|
-
name,
|
|
11
|
-
control: useResolvedControl(control),
|
|
12
|
-
render: ({ field, fieldState }) => {
|
|
13
|
-
const dateValue = field.value instanceof Date ? field.value : field.value ? new Date(field.value) : null;
|
|
14
|
-
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
15
|
-
name,
|
|
16
|
-
label,
|
|
17
|
-
description,
|
|
18
|
-
required,
|
|
19
|
-
disabled,
|
|
20
|
-
localized,
|
|
21
|
-
locale,
|
|
22
|
-
error: fieldState.error?.message,
|
|
23
|
-
children: /* @__PURE__ */ jsx(DateInput, {
|
|
24
|
-
id: name,
|
|
25
|
-
value: dateValue,
|
|
26
|
-
onChange: field.onChange,
|
|
27
|
-
minDate,
|
|
28
|
-
maxDate,
|
|
29
|
-
format,
|
|
30
|
-
placeholder,
|
|
31
|
-
disabled,
|
|
32
|
-
"aria-invalid": !!fieldState.error,
|
|
33
|
-
className
|
|
34
|
-
})
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
//#endregion
|
|
41
|
-
export { DateField };
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { DateTimeInput } from "../primitives/date-input";
|
|
3
|
-
import { Controller } from "react-hook-form";
|
|
4
|
-
import { FieldWrapper } from "./field-wrapper";
|
|
5
|
-
import { useResolvedControl } from "./field-utils";
|
|
6
|
-
|
|
7
|
-
//#region src/components/fields/datetime-field.tsx
|
|
8
|
-
function DatetimeField({ name, label, description, placeholder, required, disabled, localized, locale, control, className, minDate, maxDate, format, precision }) {
|
|
9
|
-
return /* @__PURE__ */ jsx(Controller, {
|
|
10
|
-
name,
|
|
11
|
-
control: useResolvedControl(control),
|
|
12
|
-
render: ({ field, fieldState }) => {
|
|
13
|
-
const dateValue = field.value instanceof Date ? field.value : field.value ? new Date(field.value) : null;
|
|
14
|
-
return /* @__PURE__ */ jsx(FieldWrapper, {
|
|
15
|
-
name,
|
|
16
|
-
label,
|
|
17
|
-
description,
|
|
18
|
-
required,
|
|
19
|
-
disabled,
|
|
20
|
-
localized,
|
|
21
|
-
locale,
|
|
22
|
-
error: fieldState.error?.message,
|
|
23
|
-
children: /* @__PURE__ */ jsx(DateTimeInput, {
|
|
24
|
-
id: name,
|
|
25
|
-
value: dateValue,
|
|
26
|
-
onChange: field.onChange,
|
|
27
|
-
minDate,
|
|
28
|
-
maxDate,
|
|
29
|
-
format,
|
|
30
|
-
precision,
|
|
31
|
-
placeholder,
|
|
32
|
-
disabled,
|
|
33
|
-
"aria-invalid": !!fieldState.error,
|
|
34
|
-
className
|
|
35
|
-
})
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
export { DatetimeField };
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import { TextInput } from "../primitives/text-input";
|
|
3
|
-
import { Controller } from "react-hook-form";
|
|
4
|
-
import { FieldWrapper } from "./field-wrapper";
|
|
5
|
-
import { useResolvedControl } from "./field-utils";
|
|
6
|
-
|
|
7
|
-
//#region src/components/fields/email-field.tsx
|
|
8
|
-
function EmailField({ name, label, description, placeholder, required, disabled, localized, locale, control, className }) {
|
|
9
|
-
return /* @__PURE__ */ jsx(Controller, {
|
|
10
|
-
name,
|
|
11
|
-
control: useResolvedControl(control),
|
|
12
|
-
render: ({ field, fieldState }) => /* @__PURE__ */ jsx(FieldWrapper, {
|
|
13
|
-
name,
|
|
14
|
-
label,
|
|
15
|
-
description,
|
|
16
|
-
required,
|
|
17
|
-
disabled,
|
|
18
|
-
localized,
|
|
19
|
-
locale,
|
|
20
|
-
error: fieldState.error?.message,
|
|
21
|
-
children: /* @__PURE__ */ jsx(TextInput, {
|
|
22
|
-
id: name,
|
|
23
|
-
value: field.value ?? "",
|
|
24
|
-
onChange: field.onChange,
|
|
25
|
-
type: "email",
|
|
26
|
-
placeholder,
|
|
27
|
-
disabled,
|
|
28
|
-
autoComplete: "email",
|
|
29
|
-
"aria-invalid": !!fieldState.error,
|
|
30
|
-
className
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//#endregion
|
|
37
|
-
export { EmailField };
|