@yimingliao/cms 0.0.145 → 0.0.146

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 (97) hide show
  1. package/dist/export/client/index.js +1 -71
  2. package/dist/src/client/interfaces/components/shadcn/sidebar.js +1 -1
  3. package/dist/src/client/interfaces/styles/constants.js +1 -3
  4. package/dist/types/export/client/components/index.d.ts +2 -0
  5. package/dist/types/export/client/components/index.d.ts.map +1 -0
  6. package/dist/types/export/client/index.d.ts +1 -1
  7. package/dist/types/export/client/index.d.ts.map +1 -1
  8. package/dist/types/src/client/index.d.ts +1 -1
  9. package/dist/types/src/client/index.d.ts.map +1 -1
  10. package/dist/types/src/client/interfaces/index.d.ts +0 -2
  11. package/dist/types/src/client/interfaces/index.d.ts.map +1 -1
  12. package/package.json +6 -1
  13. package/dist/src/client/applications/ui/use-parent-pathname.js +0 -10
  14. package/dist/src/client/interfaces/components/admin-initializer.js +0 -29
  15. package/dist/src/client/interfaces/components/resources/file/file-card.js +0 -87
  16. package/dist/src/client/interfaces/components/resources/file/file-list.js +0 -159
  17. package/dist/src/client/interfaces/components/resources/file/is-locked-buttons.js +0 -71
  18. package/dist/src/client/interfaces/components/resources/file/type-buttons.js +0 -62
  19. package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/list-cards-container.js +0 -96
  20. package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/page-size-selector.js +0 -63
  21. package/dist/src/client/interfaces/components/ui/blocks/list-cards-container/pagination.js +0 -94
  22. package/dist/src/client/interfaces/components/ui/blocks/page-header/page-header-title.js +0 -26
  23. package/dist/src/client/interfaces/components/ui/blocks/page-header/page-header.js +0 -74
  24. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/batch-create.js +0 -33
  25. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/batch.js +0 -39
  26. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/create.js +0 -33
  27. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/edit.js +0 -33
  28. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/index.js +0 -48
  29. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/show.js +0 -61
  30. package/dist/src/client/interfaces/components/ui/blocks/page-header/presets/trash.js +0 -39
  31. package/dist/src/client/interfaces/components/ui/buttons/return-button.js +0 -61
  32. package/dist/src/client/interfaces/components/ui/cards/action-buttons-card.js +0 -82
  33. package/dist/src/client/interfaces/components/ui/cards/resource-card/card-status-bar.js +0 -51
  34. package/dist/src/client/interfaces/components/ui/cards/resource-card/card-text-content.js +0 -38
  35. package/dist/src/client/interfaces/components/ui/cards/resource-card/resource-card.js +0 -77
  36. package/dist/src/client/interfaces/components/ui/display/array-list.js +0 -69
  37. package/dist/src/client/interfaces/components/ui/display/badge.js +0 -41
  38. package/dist/src/client/interfaces/components/ui/display/html-display.js +0 -32
  39. package/dist/src/client/interfaces/components/ui/display/object-array-list.js +0 -75
  40. package/dist/src/client/interfaces/components/ui/features/accordion/accordion-container.js +0 -31
  41. package/dist/src/client/interfaces/components/ui/features/accordion/accordion-header.js +0 -34
  42. package/dist/src/client/interfaces/components/ui/features/accordion/accordion.js +0 -81
  43. package/dist/src/client/interfaces/components/ui/features/expandable-list/expand-bar.js +0 -39
  44. package/dist/src/client/interfaces/components/ui/features/expandable-list/expandable-list-content.js +0 -49
  45. package/dist/src/client/interfaces/components/ui/features/expandable-list/expandable-list.js +0 -53
  46. package/dist/src/client/interfaces/components/ui/features/external-link.js +0 -15
  47. package/dist/src/client/interfaces/components/ui/features/file/file-info/file-info.js +0 -118
  48. package/dist/src/client/interfaces/components/ui/features/file/file-info/file-name.js +0 -48
  49. package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker-container.js +0 -74
  50. package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker-placeholder.js +0 -48
  51. package/dist/src/client/interfaces/components/ui/features/file/file-picker/file-picker.js +0 -109
  52. package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview-list.js +0 -85
  53. package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview-meta.js +0 -40
  54. package/dist/src/client/interfaces/components/ui/features/file/file-preview/file-preview.js +0 -113
  55. package/dist/src/client/interfaces/components/ui/features/file/uploader.js +0 -101
  56. package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal-body.js +0 -112
  57. package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal-trigger.js +0 -97
  58. package/dist/src/client/interfaces/components/ui/features/pick-modal/pick-modal.js +0 -77
  59. package/dist/src/client/interfaces/components/ui/features/smart-image.js +0 -57
  60. package/dist/src/client/interfaces/components/ui/features/tick.js +0 -27
  61. package/dist/src/client/interfaces/components/ui/form/containers/fields-container.js +0 -24
  62. package/dist/src/client/interfaces/components/ui/form/containers/main-fields.js +0 -25
  63. package/dist/src/client/interfaces/components/ui/form/containers/side-fields.js +0 -24
  64. package/dist/src/client/interfaces/components/ui/form/control-fields/built-in-fields.js +0 -9
  65. package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields-display.js +0 -112
  66. package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields-input.js +0 -158
  67. package/dist/src/client/interfaces/components/ui/form/control-fields/control-fields.js +0 -59
  68. package/dist/src/client/interfaces/components/ui/form/field-body.js +0 -79
  69. package/dist/src/client/interfaces/components/ui/form/index-field.js +0 -87
  70. package/dist/src/client/interfaces/components/ui/form/slug-field.js +0 -82
  71. package/dist/src/client/interfaces/components/ui/inputs/array-input.js +0 -110
  72. package/dist/src/client/interfaces/components/ui/inputs/checkbox.js +0 -93
  73. package/dist/src/client/interfaces/components/ui/inputs/editor/base/base-editor.js +0 -143
  74. package/dist/src/client/interfaces/components/ui/inputs/editor/base/built-in-plugins.js +0 -71
  75. package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/heading.config.js +0 -41
  76. package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/image.config.js +0 -32
  77. package/dist/src/client/interfaces/components/ui/inputs/editor/base/configs/table.config.js +0 -15
  78. package/dist/src/client/interfaces/components/ui/inputs/editor/editor.js +0 -112
  79. package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/asset-manager.js +0 -24
  80. package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/asset-manager/use-control-asset-mamager.js +0 -26
  81. package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/file-repository/upload-adapter.js +0 -84
  82. package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/icons.js +0 -17
  83. package/dist/src/client/interfaces/components/ui/inputs/editor/plugins/word-count-display/word-count-display.js +0 -81
  84. package/dist/src/client/interfaces/components/ui/inputs/editor/use-init-editor/use-init-editor.js +0 -50
  85. package/dist/src/client/interfaces/components/ui/inputs/search-input.js +0 -61
  86. package/dist/src/client/interfaces/components/ui/inputs/select.js +0 -69
  87. package/dist/src/client/interfaces/components/ui/inputs/textarea.js +0 -62
  88. package/dist/src/client/interfaces/components/ui/layouts/content-container.js +0 -38
  89. package/dist/src/client/interfaces/components/ui/layouts/navbar/i18n-selector.js +0 -42
  90. package/dist/src/client/interfaces/components/ui/layouts/navbar/nav-user.js +0 -106
  91. package/dist/src/client/interfaces/components/ui/layouts/navbar/navbar.js +0 -84
  92. package/dist/src/client/interfaces/components/ui/layouts/navbar/sign-out-button.js +0 -58
  93. package/dist/src/client/interfaces/components/ui/layouts/navbar/theme-selector.js +0 -51
  94. package/dist/src/client/interfaces/components/ui/layouts/sidebar/nav-main.js +0 -99
  95. package/dist/src/constants/file.js +0 -27
  96. package/dist/src/shared/list-items.js +0 -3
  97. package/dist/src/shared/utils/debounce.js +0 -14
@@ -1,24 +0,0 @@
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 { FORM_SIDE_FIELDS_WIDTH } from '../../../../styles/constants.js';
7
-
8
- function SideFields({
9
- className,
10
- children,
11
- ...props
12
- }) {
13
- return /* @__PURE__ */ jsx(
14
- "div",
15
- {
16
- className: cn("relative", "min-h-full", className),
17
- style: { width: `${FORM_SIDE_FIELDS_WIDTH}px` },
18
- ...props,
19
- children: /* @__PURE__ */ jsx("div", { className: cn("sticky top-24", "flex flex-col gap-6"), children })
20
- }
21
- );
22
- }
23
-
24
- export { SideFields };
@@ -1,9 +0,0 @@
1
- const BUILT_IN_FIELDS = [
2
- { key: "isActive" },
3
- { key: "index" },
4
- { key: "slug" },
5
- { key: "isFeatured" },
6
- { key: "isShownOnHome" }
7
- ];
8
-
9
- export { BUILT_IN_FIELDS };
@@ -1,112 +0,0 @@
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 };
@@ -1,158 +0,0 @@
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 };
@@ -1,59 +0,0 @@
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 };
@@ -1,79 +0,0 @@
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 };
@@ -1,87 +0,0 @@
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 };
@@ -1,82 +0,0 @@
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 };