@yimingliao/cms 0.0.146 → 0.0.148

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.
Files changed (109) hide show
  1. package/dist/export/client/components/editor/index.js +2 -0
  2. package/dist/export/client/components/index.js +67 -0
  3. package/dist/src/client/applications/ui/use-parent-pathname.js +10 -0
  4. package/dist/src/client/interfaces/components/admin-initializer.js +29 -0
  5. package/dist/src/client/interfaces/components/resources/file/file-card.js +84 -0
  6. package/dist/src/client/interfaces/components/resources/file/file-list.js +156 -0
  7. package/dist/src/client/interfaces/components/resources/file/is-locked-buttons.js +68 -0
  8. package/dist/src/client/interfaces/components/resources/file/type-buttons.js +59 -0
  9. package/dist/src/client/interfaces/components/shadcn/sidebar.js +1 -1
  10. package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/list-cards-container.js +84 -0
  11. package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/page-size-selector.js +51 -0
  12. package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/pagination.js +94 -0
  13. package/dist/src/client/interfaces/components/ui/blocks/page-header/page-header-title.js +26 -0
  14. package/dist/src/client/interfaces/components/ui/blocks/page-header/page-header.js +74 -0
  15. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/batch-create.js +33 -0
  16. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/batch.js +39 -0
  17. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/create.js +33 -0
  18. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/edit.js +33 -0
  19. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/index.js +48 -0
  20. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/show.js +61 -0
  21. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/trash.js +39 -0
  22. package/dist/src/client/interfaces/components/ui/buttons/return-button.js +61 -0
  23. package/dist/src/client/interfaces/components/ui/cards/action-buttons-card.js +82 -0
  24. package/dist/src/client/interfaces/components/ui/cards/resource-card/card-status-bar.js +51 -0
  25. package/dist/src/client/interfaces/components/ui/cards/resource-card/card-text-content.js +38 -0
  26. package/dist/src/client/interfaces/components/ui/cards/resource-card/resource-card.js +77 -0
  27. package/dist/src/client/interfaces/components/ui/display/array-list.js +69 -0
  28. package/dist/src/client/interfaces/components/ui/display/badge.js +41 -0
  29. package/dist/src/client/interfaces/components/ui/display/html-display.js +32 -0
  30. package/dist/src/client/interfaces/components/ui/display/object-array-list.js +75 -0
  31. package/dist/src/client/interfaces/components/ui/features/accordion/accordion-container.js +31 -0
  32. package/dist/src/client/interfaces/components/ui/features/accordion/accordion-header.js +34 -0
  33. package/dist/src/client/interfaces/components/ui/features/accordion/accordion.js +81 -0
  34. package/dist/src/client/interfaces/components/ui/features/expandable-list/expand-bar.js +39 -0
  35. package/dist/src/client/interfaces/components/ui/features/expandable-list/expandable-list-content.js +49 -0
  36. package/dist/src/client/interfaces/components/ui/features/expandable-list/expandable-list.js +53 -0
  37. package/dist/src/client/interfaces/components/ui/features/external-link.js +15 -0
  38. package/dist/src/client/interfaces/components/ui/features/file/file-info/file-info.js +118 -0
  39. package/dist/src/client/interfaces/components/ui/features/file/file-info/file-name.js +48 -0
  40. package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker-container.js +74 -0
  41. package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker-placeholder.js +48 -0
  42. package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker.js +109 -0
  43. package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview-list.js +85 -0
  44. package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview-meta.js +40 -0
  45. package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview.js +113 -0
  46. package/dist/src/client/interfaces/components/ui/features/file/uploader.js +101 -0
  47. package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal-body.js +112 -0
  48. package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal-trigger.js +97 -0
  49. package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal.js +77 -0
  50. package/dist/src/client/interfaces/components/ui/features/smart-image.js +57 -0
  51. package/dist/src/client/interfaces/components/ui/features/tick.js +27 -0
  52. package/dist/src/client/interfaces/components/ui/form/containers/fields-container.js +24 -0
  53. package/dist/src/client/interfaces/components/ui/form/containers/main-fields.js +25 -0
  54. package/dist/src/client/interfaces/components/ui/form/containers/side-fields.js +24 -0
  55. package/dist/src/client/interfaces/components/ui/form/control-fields/built-in-fields.js +9 -0
  56. package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields-display.js +112 -0
  57. package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields-input.js +158 -0
  58. package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields.js +59 -0
  59. package/dist/src/client/interfaces/components/ui/form/field-body.js +79 -0
  60. package/dist/src/client/interfaces/components/ui/form/index-field.js +87 -0
  61. package/dist/src/client/interfaces/components/ui/form/slug-field.js +82 -0
  62. package/dist/src/client/interfaces/components/ui/inputs/array-input.js +110 -0
  63. package/dist/src/client/interfaces/components/ui/inputs/checkbox.js +93 -0
  64. package/dist/src/client/interfaces/components/ui/inputs/editor/base/base-editor.js +144 -0
  65. package/dist/src/client/interfaces/components/ui/inputs/editor/base/built-in-plugins.js +71 -0
  66. package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/heading.config.js +41 -0
  67. package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/image.config.js +32 -0
  68. package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/table.config.js +15 -0
  69. package/dist/src/client/interfaces/components/ui/inputs/editor/editor.js +112 -0
  70. package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/asset-manager.js +24 -0
  71. package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/use-control-asset-mamager.js +26 -0
  72. package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/file-repository/upload-adapter.js +84 -0
  73. package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/icons.js +17 -0
  74. package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/word-count-display.js +81 -0
  75. package/dist/src/client/interfaces/components/ui/inputs/editor/use-init-editor/use-init-editor.js +51 -0
  76. package/dist/src/client/interfaces/components/ui/inputs/search-input.js +61 -0
  77. package/dist/src/client/interfaces/components/ui/inputs/select.js +69 -0
  78. package/dist/src/client/interfaces/components/ui/inputs/textarea.js +62 -0
  79. package/dist/src/client/interfaces/components/ui/layouts/content-container.js +38 -0
  80. package/dist/src/client/interfaces/components/ui/layouts/navbar/i18n-selector.js +42 -0
  81. package/dist/src/client/interfaces/components/ui/layouts/navbar/nav-user.js +106 -0
  82. package/dist/src/client/interfaces/components/ui/layouts/navbar/navbar.js +84 -0
  83. package/dist/src/client/interfaces/components/ui/layouts/navbar/sign-out-button.js +58 -0
  84. package/dist/src/client/interfaces/components/ui/layouts/navbar/theme-selector.js +51 -0
  85. package/dist/src/client/interfaces/components/ui/layouts/sidebar/nav-main.js +99 -0
  86. package/dist/src/client/interfaces/pages/auth/change-password/page.js +3 -6
  87. package/dist/src/client/interfaces/pages/auth/email-unverified/page.js +0 -3
  88. package/dist/src/client/interfaces/pages/auth/forgot-password/page.js +3 -6
  89. package/dist/src/client/interfaces/pages/auth/layout.js +0 -3
  90. package/dist/src/client/interfaces/pages/auth/reset-password/page.js +3 -6
  91. package/dist/src/client/interfaces/pages/auth/sign-in/page.js +2 -5
  92. package/dist/src/client/interfaces/pages/dashboard/layout.js +0 -3
  93. package/dist/src/client/interfaces/styles/constants.js +3 -1
  94. package/dist/src/constants/file.js +27 -0
  95. package/dist/src/shared/list-items.js +3 -0
  96. package/dist/src/shared/utils/debounce.js +14 -0
  97. package/dist/types/export/client/components/editor/index.d.ts +2 -0
  98. package/dist/types/export/client/components/editor/index.d.ts.map +1 -0
  99. package/dist/types/export/client/components/index.d.ts +1 -1
  100. package/dist/types/export/client/components/index.d.ts.map +1 -1
  101. package/dist/types/src/client/interfaces/components/index.d.ts +1 -1
  102. package/dist/types/src/client/interfaces/components/index.d.ts.map +1 -1
  103. package/dist/types/src/client/interfaces/components/ui/index.d.ts +1 -1
  104. package/dist/types/src/client/interfaces/components/ui/index.d.ts.map +1 -1
  105. package/dist/types/src/client/interfaces/components/ui/inputs/editor/base/base-editor.d.ts.map +1 -1
  106. package/dist/types/src/client/interfaces/components/ui/inputs/editor/use-init-editor/use-init-editor.d.ts.map +1 -1
  107. package/dist/types/src/client/interfaces/components/ui/inputs/index.d.ts +0 -1
  108. package/dist/types/src/client/interfaces/components/ui/inputs/index.d.ts.map +1 -1
  109. package/package.json +6 -1
@@ -0,0 +1,112 @@
1
+ "use client";
2
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
+ import { useTranslator } from 'intor/react';
4
+ import { Eye, Binary, MapPinCheckInside, Star, House } from 'lucide-react';
5
+ import { Checkbox } from '../../inputs/checkbox.js';
6
+ import { Field } from '../field.js';
7
+ import { IndexField } from '../index-field.js';
8
+ import { SlugField } from '../slug-field.js';
9
+ import { BUILT_IN_FIELDS } from './built-in-fields.js';
10
+
11
+ function ControlFieldsDisplay({
12
+ fields,
13
+ // form context
14
+ formData,
15
+ // ui states
16
+ isLoading = false
17
+ }) {
18
+ const { t } = useTranslator();
19
+ if (!formData) return null;
20
+ const notBuiltInFields = fields.filter(
21
+ ({ key }) => !BUILT_IN_FIELDS.some((b) => b.key == key)
22
+ );
23
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
24
+ fields.find((f) => f.key === "isActive") && /* @__PURE__ */ jsx(
25
+ Field,
26
+ {
27
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
28
+ /* @__PURE__ */ jsx(Eye, { className: "size-5" }),
29
+ t("ui.field.control-fields.is-active.text")
30
+ ] }),
31
+ children: /* @__PURE__ */ jsx(
32
+ Checkbox,
33
+ {
34
+ fieldName: "isActive",
35
+ formData,
36
+ isLoading,
37
+ isDisplay: true
38
+ }
39
+ )
40
+ }
41
+ ),
42
+ fields.find((f) => f.key === "index") && /* @__PURE__ */ jsx(
43
+ Field,
44
+ {
45
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
46
+ /* @__PURE__ */ jsx(Binary, { className: "size-5" }),
47
+ t("ui.field.control-fields.index.text")
48
+ ] }),
49
+ children: /* @__PURE__ */ jsx(IndexField, { formData, isLoading, isDisplay: true })
50
+ }
51
+ ),
52
+ fields.find((f) => f.key === "slug") && /* @__PURE__ */ jsx(
53
+ Field,
54
+ {
55
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
56
+ /* @__PURE__ */ jsx(MapPinCheckInside, { className: "size-5" }),
57
+ t("ui.field.control-fields.slug.text")
58
+ ] }),
59
+ children: /* @__PURE__ */ jsx(SlugField, { formData, isLoading, isDisplay: true })
60
+ }
61
+ ),
62
+ fields.find((f) => f.key === "isFeatured") && /* @__PURE__ */ jsx(
63
+ Field,
64
+ {
65
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
66
+ /* @__PURE__ */ jsx(Star, { className: "size-5" }),
67
+ t("ui.field.control-fields.is-featured.text")
68
+ ] }),
69
+ children: /* @__PURE__ */ jsx(
70
+ Checkbox,
71
+ {
72
+ fieldName: "isFeatured",
73
+ formData,
74
+ isLoading,
75
+ isDisplay: true
76
+ }
77
+ )
78
+ }
79
+ ),
80
+ fields.find((f) => f.key === "isShownOnHome") && /* @__PURE__ */ jsx(
81
+ Field,
82
+ {
83
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
84
+ /* @__PURE__ */ jsx(House, { className: "size-5" }),
85
+ t("ui.field.control-fields.is-shown-on-home.text")
86
+ ] }),
87
+ children: /* @__PURE__ */ jsx(
88
+ Checkbox,
89
+ {
90
+ fieldName: "isShownOnHome",
91
+ formData,
92
+ isLoading,
93
+ isDisplay: true
94
+ }
95
+ )
96
+ }
97
+ ),
98
+ notBuiltInFields.map(({ key, label }) => {
99
+ return /* @__PURE__ */ jsx(Field, { label, children: /* @__PURE__ */ jsx(
100
+ Checkbox,
101
+ {
102
+ fieldName: key,
103
+ formData,
104
+ isLoading,
105
+ isDisplay: true
106
+ }
107
+ ) }, key);
108
+ })
109
+ ] });
110
+ }
111
+
112
+ export { ControlFieldsDisplay };
@@ -0,0 +1,158 @@
1
+ "use client";
2
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
3
+ import { useTranslator } from 'intor/react';
4
+ import { Eye, EyeOff, Binary, MapPinCheckInside, Star, House } from 'lucide-react';
5
+ import { Checkbox } from '../../inputs/checkbox.js';
6
+ import { Field } from '../field.js';
7
+ import { IndexField } from '../index-field.js';
8
+ import { SlugField } from '../slug-field.js';
9
+ import { BUILT_IN_FIELDS } from './built-in-fields.js';
10
+
11
+ function ControlFieldsInput({
12
+ fields = [],
13
+ // meta
14
+ controlMeta = {},
15
+ // form context
16
+ formData,
17
+ setFormData,
18
+ // ui states
19
+ isLoading = false,
20
+ isDisabled = false,
21
+ errors
22
+ }) {
23
+ const { t } = useTranslator();
24
+ if (!(formData && setFormData)) return null;
25
+ const {
26
+ existingIndexes = [],
27
+ availableIndex = 1,
28
+ existingSlugs = []
29
+ } = controlMeta;
30
+ const notBuiltInFields = fields.filter(
31
+ ({ key }) => !BUILT_IN_FIELDS.some((b) => b.key == key)
32
+ );
33
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
34
+ fields.find((f) => f.key === "isActive") && /* @__PURE__ */ jsx(
35
+ Field,
36
+ {
37
+ htmlFor: "isActive",
38
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
39
+ formData["isActive"] ? /* @__PURE__ */ jsx(Eye, { className: "size-5" }) : /* @__PURE__ */ jsx(EyeOff, { className: "size-5" }),
40
+ t("ui.field.control-fields.is-active.text")
41
+ ] }),
42
+ children: /* @__PURE__ */ jsx(
43
+ Checkbox,
44
+ {
45
+ id: "isActive",
46
+ fieldName: "isActive",
47
+ formData,
48
+ setFormData,
49
+ isLoading,
50
+ isDisabled
51
+ }
52
+ )
53
+ }
54
+ ),
55
+ fields.find((f) => f.key === "index") && /* @__PURE__ */ jsx(
56
+ Field,
57
+ {
58
+ htmlFor: "index",
59
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
60
+ /* @__PURE__ */ jsx(Binary, { className: "size-5" }),
61
+ t("ui.field.control-fields.index.text")
62
+ ] }),
63
+ children: /* @__PURE__ */ jsx(
64
+ IndexField,
65
+ {
66
+ id: "index",
67
+ formData,
68
+ setFormData,
69
+ isLoading,
70
+ isDisabled,
71
+ existingIndexes,
72
+ availableIndex,
73
+ isError: errors?.includes("index")
74
+ }
75
+ )
76
+ }
77
+ ),
78
+ fields.find((f) => f.key === "slug") && /* @__PURE__ */ jsx(
79
+ Field,
80
+ {
81
+ htmlFor: "slug",
82
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
83
+ /* @__PURE__ */ jsx(MapPinCheckInside, { className: "size-5" }),
84
+ t("ui.field.control-fields.slug.text")
85
+ ] }),
86
+ children: /* @__PURE__ */ jsx(
87
+ SlugField,
88
+ {
89
+ id: "slug",
90
+ formData,
91
+ setFormData,
92
+ isLoading,
93
+ isDisabled,
94
+ existingSlugs,
95
+ isError: errors?.includes("slug")
96
+ }
97
+ )
98
+ }
99
+ ),
100
+ fields.find((f) => f.key === "isFeatured") && /* @__PURE__ */ jsx(
101
+ Field,
102
+ {
103
+ htmlFor: "isFeatured",
104
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
105
+ /* @__PURE__ */ jsx(Star, { className: "size-5" }),
106
+ t("ui.field.control-fields.is-featured.text")
107
+ ] }),
108
+ children: /* @__PURE__ */ jsx(
109
+ Checkbox,
110
+ {
111
+ id: "isFeatured",
112
+ fieldName: "isFeatured",
113
+ formData,
114
+ setFormData,
115
+ isLoading,
116
+ isDisabled
117
+ }
118
+ )
119
+ }
120
+ ),
121
+ fields.find((f) => f.key === "isShownOnHome") && /* @__PURE__ */ jsx(
122
+ Field,
123
+ {
124
+ htmlFor: "isShownOnHome",
125
+ label: /* @__PURE__ */ jsxs("span", { className: "flex-center gap-2", children: [
126
+ /* @__PURE__ */ jsx(House, { className: "size-5" }),
127
+ t("ui.field.control-fields.is-shown-on-home.text")
128
+ ] }),
129
+ children: /* @__PURE__ */ jsx(
130
+ Checkbox,
131
+ {
132
+ id: "isShownOnHome",
133
+ fieldName: "isShownOnHome",
134
+ formData,
135
+ setFormData,
136
+ isLoading,
137
+ isDisabled
138
+ }
139
+ )
140
+ }
141
+ ),
142
+ notBuiltInFields.map(({ key, label }) => {
143
+ return /* @__PURE__ */ jsx(Field, { htmlFor: key, label, children: /* @__PURE__ */ jsx(
144
+ Checkbox,
145
+ {
146
+ id: key,
147
+ fieldName: key,
148
+ formData,
149
+ setFormData,
150
+ isLoading,
151
+ isDisabled
152
+ }
153
+ ) }, key);
154
+ })
155
+ ] });
156
+ }
157
+
158
+ export { ControlFieldsInput };
@@ -0,0 +1,59 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import 'react';
3
+ import 'ua-parser-js';
4
+ import { cn } from '../../../../../applications/shadcn/utils.js';
5
+ import 'next/navigation';
6
+ import '@radix-ui/react-avatar';
7
+ import '../../../shadcn/badge.js';
8
+ import '../../../shadcn/button.js';
9
+ import { Card } from '../../../shadcn/card.js';
10
+ import '@radix-ui/react-collapsible';
11
+ import '@radix-ui/react-dialog';
12
+ import 'lucide-react';
13
+ import '@radix-ui/react-dropdown-menu';
14
+ import '../../../shadcn/input-group.js';
15
+ import '@radix-ui/react-label';
16
+ import '@radix-ui/react-select';
17
+ import '@radix-ui/react-separator';
18
+ import '../../../shadcn/sidebar.js';
19
+ import '@radix-ui/react-tooltip';
20
+ import { ControlFieldsDisplay } from './control-fields-display.js';
21
+ import { ControlFieldsInput } from './control-fields-input.js';
22
+
23
+ function ControlFields({
24
+ fields = [],
25
+ // meta
26
+ controlMeta,
27
+ // form context
28
+ formData,
29
+ setFormData,
30
+ // ui states
31
+ isLoading = false,
32
+ isDisabled = false,
33
+ isDisplay = false,
34
+ errors,
35
+ ...props
36
+ }) {
37
+ if (fields.length === 0) return null;
38
+ return /* @__PURE__ */ jsx(Card, { className: cn("flex flex-col gap-6", "bg-base-100 p-4"), ...props, children: !isDisplay ? /* @__PURE__ */ jsx(
39
+ ControlFieldsInput,
40
+ {
41
+ fields,
42
+ formData,
43
+ setFormData,
44
+ controlMeta,
45
+ isLoading,
46
+ isDisabled,
47
+ errors
48
+ }
49
+ ) : /* @__PURE__ */ jsx(
50
+ ControlFieldsDisplay,
51
+ {
52
+ fields,
53
+ formData,
54
+ isLoading
55
+ }
56
+ ) });
57
+ }
58
+
59
+ export { ControlFields };
@@ -0,0 +1,79 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import { useTranslator } from 'intor/react';
4
+ import 'react';
5
+ import 'ua-parser-js';
6
+ import { cn } from '../../../../applications/shadcn/utils.js';
7
+ import 'next/navigation';
8
+ import '@radix-ui/react-avatar';
9
+ import '../../shadcn/badge.js';
10
+ import '../../shadcn/button.js';
11
+ import '@radix-ui/react-collapsible';
12
+ import '@radix-ui/react-dialog';
13
+ import 'lucide-react';
14
+ import '@radix-ui/react-dropdown-menu';
15
+ import '../../shadcn/input-group.js';
16
+ import '@radix-ui/react-label';
17
+ import '@radix-ui/react-select';
18
+ import '@radix-ui/react-separator';
19
+ import '../../shadcn/sidebar.js';
20
+ import { Spinner } from '../../shadcn/spinner.js';
21
+ import '@radix-ui/react-tooltip';
22
+
23
+ function FieldBody({
24
+ // ui states
25
+ isLoading = false,
26
+ isDisabled = false,
27
+ isEmpty = false,
28
+ // base
29
+ className,
30
+ backgroundClassName,
31
+ childrenClassName,
32
+ children,
33
+ ...props
34
+ }) {
35
+ const { t } = useTranslator();
36
+ return /* @__PURE__ */ jsxs(
37
+ "div",
38
+ {
39
+ className: cn(
40
+ className,
41
+ "relative",
42
+ "min-h-9 w-full min-w-0",
43
+ "flex items-center",
44
+ "text-sm"
45
+ ),
46
+ ...props,
47
+ children: [
48
+ /* @__PURE__ */ jsx(
49
+ "div",
50
+ {
51
+ className: cn(
52
+ "absolute size-full",
53
+ "dark:bg-input/30 bg-foreground/2 rounded-md",
54
+ backgroundClassName
55
+ )
56
+ }
57
+ ),
58
+ isLoading && /* @__PURE__ */ jsx("div", { className: "px-3", children: /* @__PURE__ */ jsx(Spinner, {}) }),
59
+ !isLoading && (!children || isEmpty) && /* @__PURE__ */ jsx("div", { className: "flex-center h-9 px-3 opacity-50", children: /* @__PURE__ */ jsx("p", { className: "opacity-50", children: t("ui.no-data.text") }) }),
60
+ !isLoading && children && !isEmpty && /* @__PURE__ */ jsx(
61
+ "div",
62
+ {
63
+ className: cn(
64
+ "relative size-full",
65
+ "flex items-center gap-3",
66
+ "px-3 py-2",
67
+ "break-all",
68
+ (isDisabled || isLoading) && "opacity-50",
69
+ childrenClassName
70
+ ),
71
+ children
72
+ }
73
+ )
74
+ ]
75
+ }
76
+ );
77
+ }
78
+
79
+ export { FieldBody };
@@ -0,0 +1,87 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import 'mime-types';
4
+ import { ensureArray } from '../../../../../shared/utils/ensure-array.js';
5
+ import 'react';
6
+ import 'ua-parser-js';
7
+ import { cn } from '../../../../applications/shadcn/utils.js';
8
+ import 'next/navigation';
9
+ import { ExpandableList } from '../features/expandable-list/expandable-list.js';
10
+ import { Checkbox } from '../inputs/checkbox.js';
11
+ import { Input } from '../inputs/input.js';
12
+ import { FieldBody } from './field-body.js';
13
+
14
+ function IndexField({
15
+ existingIndexes,
16
+ availableIndex = 1,
17
+ // Min available index
18
+ // form context
19
+ formData,
20
+ setFormData,
21
+ // ui states
22
+ isLoading = false,
23
+ isDisabled = false,
24
+ isError = false,
25
+ isDisplay = false,
26
+ // base
27
+ id
28
+ }) {
29
+ isDisabled = isDisabled || isLoading || isDisplay;
30
+ const index = formData?.["index"];
31
+ const isIndexActive = !!formData?.["isIndexActive"];
32
+ const toggleCheckbox = () => {
33
+ if (!setFormData) return;
34
+ setFormData((p) => ({ ...p, index: availableIndex }));
35
+ };
36
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
37
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
38
+ /* @__PURE__ */ jsx(
39
+ Checkbox,
40
+ {
41
+ id: isIndexActive ? void 0 : id,
42
+ fieldName: "isIndexActive",
43
+ formData,
44
+ setFormData,
45
+ isLoading,
46
+ isDisabled,
47
+ onClick: toggleCheckbox
48
+ }
49
+ ),
50
+ !isDisplay ? /* @__PURE__ */ jsx(
51
+ Input,
52
+ {
53
+ id: isIndexActive ? id : void 0,
54
+ fieldName: "index",
55
+ value: index || 1,
56
+ setFormData,
57
+ type: "number",
58
+ min: 1,
59
+ required: isIndexActive,
60
+ isDisabled: !isIndexActive || isDisabled,
61
+ className: cn(!isIndexActive && "text-transparent"),
62
+ inputGroupClassName: cn(
63
+ isIndexActive ? "opacity-100" : "opacity-50 cursor-not-allowed"
64
+ ),
65
+ isError
66
+ }
67
+ ) : /* @__PURE__ */ jsx(
68
+ FieldBody,
69
+ {
70
+ isEmpty: !isIndexActive,
71
+ backgroundClassName: "!bg-base-200",
72
+ children: index
73
+ }
74
+ )
75
+ ] }),
76
+ !isDisplay && /* @__PURE__ */ jsx("div", { className: "mx-2", children: /* @__PURE__ */ jsx(
77
+ ExpandableList,
78
+ {
79
+ isDisabled: !isIndexActive,
80
+ item: index,
81
+ items: ensureArray(existingIndexes)
82
+ }
83
+ ) })
84
+ ] });
85
+ }
86
+
87
+ export { IndexField };
@@ -0,0 +1,82 @@
1
+ "use client";
2
+ import { jsxs, jsx } from 'react/jsx-runtime';
3
+ import 'mime-types';
4
+ import { ensureArray } from '../../../../../shared/utils/ensure-array.js';
5
+ import 'react';
6
+ import 'ua-parser-js';
7
+ import { cn } from '../../../../applications/shadcn/utils.js';
8
+ import 'next/navigation';
9
+ import { ExpandableList } from '../features/expandable-list/expandable-list.js';
10
+ import { Checkbox } from '../inputs/checkbox.js';
11
+ import { Textarea } from '../inputs/textarea.js';
12
+ import { FieldBody } from './field-body.js';
13
+
14
+ function SlugField({
15
+ existingSlugs,
16
+ // form context
17
+ formData,
18
+ setFormData,
19
+ // ui states
20
+ isLoading = false,
21
+ isDisabled = false,
22
+ isError = false,
23
+ isDisplay = false,
24
+ // base
25
+ id
26
+ }) {
27
+ isDisabled = isDisabled || isLoading || isDisplay;
28
+ const slug = formData?.["slug"] || "";
29
+ const isSlugActive = !!formData?.["isSlugActive"];
30
+ const isUnavailable = !!existingSlugs?.includes(slug);
31
+ const toggleCheckbox = () => {
32
+ if (!setFormData) return;
33
+ setFormData((p) => ({ ...p, slug: null }));
34
+ };
35
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
36
+ /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3", children: [
37
+ /* @__PURE__ */ jsx(
38
+ Checkbox,
39
+ {
40
+ id: isSlugActive ? void 0 : id,
41
+ fieldName: "isSlugActive",
42
+ formData,
43
+ setFormData,
44
+ isLoading,
45
+ isDisabled,
46
+ onClick: toggleCheckbox,
47
+ className: "mt-2"
48
+ }
49
+ ),
50
+ !isDisplay ? /* @__PURE__ */ jsx(
51
+ Textarea,
52
+ {
53
+ id: isSlugActive ? id : void 0,
54
+ fieldName: "slug",
55
+ value: slug,
56
+ setFormData,
57
+ required: isSlugActive,
58
+ isDisabled: !isSlugActive || isDisabled,
59
+ onKeyDown: (e) => {
60
+ if (e.key === "Enter") return e.preventDefault();
61
+ },
62
+ className: cn(
63
+ "resize-none break-all",
64
+ !isSlugActive && "text-transparent"
65
+ ),
66
+ isError: isUnavailable || isError
67
+ }
68
+ ) : /* @__PURE__ */ jsx(FieldBody, { isEmpty: !isSlugActive, backgroundClassName: "!bg-base-200", children: slug })
69
+ ] }),
70
+ !isDisplay && /* @__PURE__ */ jsx("div", { className: "mx-2", children: /* @__PURE__ */ jsx(
71
+ ExpandableList,
72
+ {
73
+ isDisabled: !isSlugActive,
74
+ isUnique: true,
75
+ item: slug,
76
+ items: ensureArray(existingSlugs)
77
+ }
78
+ ) })
79
+ ] });
80
+ }
81
+
82
+ export { SlugField };
@@ -0,0 +1,110 @@
1
+ "use client";
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import { CircleX, CirclePlus } from 'lucide-react';
4
+ import 'react';
5
+ import 'ua-parser-js';
6
+ import { cn } from '../../../../applications/shadcn/utils.js';
7
+ import 'next/navigation';
8
+ import '@radix-ui/react-avatar';
9
+ import '../../shadcn/badge.js';
10
+ import '../../shadcn/button.js';
11
+ import '@radix-ui/react-collapsible';
12
+ import '@radix-ui/react-dialog';
13
+ import '@radix-ui/react-dropdown-menu';
14
+ import '../../shadcn/input-group.js';
15
+ import '@radix-ui/react-label';
16
+ import '@radix-ui/react-select';
17
+ import { Separator } from '../../shadcn/separator.js';
18
+ import '../../shadcn/sidebar.js';
19
+ import '@radix-ui/react-tooltip';
20
+ import { Button } from '../buttons/button.js';
21
+ import 'intor/react';
22
+ import { Textarea } from './textarea.js';
23
+
24
+ function ArrayInput({
25
+ // form context
26
+ formData,
27
+ fieldName,
28
+ setFormData,
29
+ // ui states
30
+ isLoading = false,
31
+ isDisabled = false,
32
+ isResizable = false,
33
+ errors,
34
+ // base
35
+ placeholder = "",
36
+ ...props
37
+ }) {
38
+ isDisabled = isDisabled || isLoading;
39
+ const rawValue = formData?.[fieldName ?? ""];
40
+ const values = Array.isArray(rawValue) && rawValue.length > 0 ? rawValue.map(String) : [""];
41
+ const errorIndexes = new Set(
42
+ errors.filter((e) => e.startsWith(fieldName ?? "")).map((e) => e.split(".").pop()).map(Number)
43
+ );
44
+ return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: values.map((value, index) => {
45
+ const isError = errorIndexes.has(index);
46
+ return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
47
+ /* @__PURE__ */ jsxs("div", { className: "flex-center absolute top-0 left-0 z-10 h-full", children: [
48
+ /* @__PURE__ */ jsx("span", { className: "min-w-10 pl-0.5 text-center text-sm opacity-50", children: Array.isArray(rawValue) && rawValue.length === 0 ? "0" : index + 1 }),
49
+ /* @__PURE__ */ jsx(Separator, { orientation: "vertical" })
50
+ ] }),
51
+ /* @__PURE__ */ jsx(
52
+ Textarea,
53
+ {
54
+ disabled: isDisabled,
55
+ placeholder: isLoading ? "" : placeholder,
56
+ value,
57
+ onChange: (e) => {
58
+ if (!setFormData || !fieldName) return;
59
+ const copy = [...values];
60
+ copy[index] = e.target.value;
61
+ setFormData((p) => ({ ...p, [fieldName]: copy }));
62
+ },
63
+ onKeyDown: (e) => {
64
+ if (e.key === "Enter" && !isResizable) {
65
+ e.preventDefault();
66
+ }
67
+ },
68
+ isError,
69
+ className: cn("pr-20 pl-13", !isResizable && "resize-none"),
70
+ ...props
71
+ }
72
+ ),
73
+ /* @__PURE__ */ jsxs("div", { className: "flex-center absolute top-1 right-1 gap-1", children: [
74
+ /* @__PURE__ */ jsx(
75
+ Button,
76
+ {
77
+ variant: "outline",
78
+ type: "button",
79
+ size: "icon-sm",
80
+ className: "rounded-sm",
81
+ onClick: () => {
82
+ if (!setFormData || !fieldName) return;
83
+ const copy = values.filter((_, i) => i !== index);
84
+ setFormData((p) => ({ ...p, [fieldName]: copy }));
85
+ },
86
+ children: /* @__PURE__ */ jsx(CircleX, { className: "text-destructive" })
87
+ }
88
+ ),
89
+ /* @__PURE__ */ jsx(
90
+ Button,
91
+ {
92
+ variant: "outline",
93
+ type: "button",
94
+ size: "icon-sm",
95
+ className: "rounded-sm",
96
+ onClick: () => {
97
+ if (!setFormData || !fieldName) return;
98
+ const copy = [...values];
99
+ copy.splice(index + 1, 0, "");
100
+ setFormData((p) => ({ ...p, [fieldName]: copy }));
101
+ },
102
+ children: /* @__PURE__ */ jsx(CirclePlus, { className: "text-success" })
103
+ }
104
+ )
105
+ ] })
106
+ ] }, index);
107
+ }) });
108
+ }
109
+
110
+ export { ArrayInput };