@tunghtml/strapi-plugin-multiselect-checkbox 1.0.4 → 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/package.json +1 -1
- package/dist/_chunks/en-pkXKBXLR.js +0 -14
- package/dist/_chunks/en-tWwdhLO5.mjs +0 -14
- package/dist/_chunks/index-BnVwcKcR.mjs +0 -109
- package/dist/_chunks/index-D2_7xEii.js +0 -111
- package/dist/admin/index.js +0 -172
- package/dist/admin/index.mjs +0 -171
- package/dist/admin/src/components/Initializer/index.d.ts +0 -5
- package/dist/admin/src/components/Multiselect/index.d.ts +0 -12
- package/dist/admin/src/components/PluginIcon/index.d.ts +0 -2
- package/dist/admin/src/index.d.ts +0 -10
- package/dist/admin/src/pluginId.d.ts +0 -1
- package/dist/admin/src/utils/prefixKey.d.ts +0 -2
- package/dist/server/index.js +0 -53
- package/dist/server/index.mjs +0 -54
- package/dist/server/src/bootstrap.d.ts +0 -5
- package/dist/server/src/config/index.d.ts +0 -5
- package/dist/server/src/content-types/index.d.ts +0 -2
- package/dist/server/src/controllers/controller.d.ts +0 -5
- package/dist/server/src/controllers/index.d.ts +0 -6
- package/dist/server/src/destroy.d.ts +0 -5
- package/dist/server/src/index.d.ts +0 -35
- package/dist/server/src/middlewares/index.d.ts +0 -2
- package/dist/server/src/policies/index.d.ts +0 -2
- package/dist/server/src/register.d.ts +0 -5
- package/dist/server/src/routes/content-api.d.ts +0 -2
- package/dist/server/src/routes/index.d.ts +0 -7
- package/dist/server/src/services/index.d.ts +0 -6
- package/dist/server/src/services/service.d.ts +0 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tunghtml/strapi-plugin-multiselect-checkbox",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "A Strapi v5 custom field plugin with checkbox UI that stores selected values as an array of strings (JSON type) instead of comma-separated strings.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const en = {
|
|
4
|
-
"multiselect-field.label": "Multiselect",
|
|
5
|
-
"multiselect-field.description": "A custom field for Strapi that allows users to select multiple options from a predefined list.",
|
|
6
|
-
"multiselect-field.options.available-options.label": "Available Options",
|
|
7
|
-
"multiselect-field.options.available-options.description": "One option per line.",
|
|
8
|
-
"multiselect-field.options.available-options.placeholder": "Option 1\nOption 2\nOption 3",
|
|
9
|
-
"multiselect-field.options.delimiter.label": "Delimiter",
|
|
10
|
-
"multiselect-field.options.delimiter.description": "The delimiter to use when storing the selected options.",
|
|
11
|
-
"multiselect-field.options.delimiter.placeholder": ",",
|
|
12
|
-
"multiselect-field.empty-state.text": "⚠️ Please provide the available options in the content builder."
|
|
13
|
-
};
|
|
14
|
-
exports.default = en;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
const en = {
|
|
2
|
-
"multiselect-field.label": "Multiselect",
|
|
3
|
-
"multiselect-field.description": "A custom field for Strapi that allows users to select multiple options from a predefined list.",
|
|
4
|
-
"multiselect-field.options.available-options.label": "Available Options",
|
|
5
|
-
"multiselect-field.options.available-options.description": "One option per line.",
|
|
6
|
-
"multiselect-field.options.available-options.placeholder": "Option 1\nOption 2\nOption 3",
|
|
7
|
-
"multiselect-field.options.delimiter.label": "Delimiter",
|
|
8
|
-
"multiselect-field.options.delimiter.description": "The delimiter to use when storing the selected options.",
|
|
9
|
-
"multiselect-field.options.delimiter.placeholder": ",",
|
|
10
|
-
"multiselect-field.empty-state.text": "⚠️ Please provide the available options in the content builder."
|
|
11
|
-
};
|
|
12
|
-
export {
|
|
13
|
-
en as default
|
|
14
|
-
};
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Field, Flex, Typography, Box, Grid, Checkbox } from "@strapi/design-system";
|
|
3
|
-
import { useField } from "@strapi/strapi/admin";
|
|
4
|
-
import { useMemo } from "react";
|
|
5
|
-
import { useIntl } from "react-intl";
|
|
6
|
-
import styled from "styled-components";
|
|
7
|
-
const CapitalizedText = styled.p`
|
|
8
|
-
&::first-letter {
|
|
9
|
-
text-transform: uppercase;
|
|
10
|
-
}
|
|
11
|
-
`;
|
|
12
|
-
const MultiSelect = ({
|
|
13
|
-
hint,
|
|
14
|
-
label,
|
|
15
|
-
name,
|
|
16
|
-
intlLabel,
|
|
17
|
-
required,
|
|
18
|
-
attribute,
|
|
19
|
-
description,
|
|
20
|
-
placeholder,
|
|
21
|
-
disabled
|
|
22
|
-
}) => {
|
|
23
|
-
const { formatMessage } = useIntl();
|
|
24
|
-
const { onChange, value, error } = useField(name);
|
|
25
|
-
const possibleOptions = useMemo(() => {
|
|
26
|
-
return (attribute["options"] || []).map((option) => {
|
|
27
|
-
const [label2, value2] = [...option.split(/:(.*)/s), option];
|
|
28
|
-
if (!label2 || !value2) return null;
|
|
29
|
-
return { label: label2, value: value2 };
|
|
30
|
-
}).filter(Boolean);
|
|
31
|
-
}, [attribute]);
|
|
32
|
-
const sanitizedValue = useMemo(() => {
|
|
33
|
-
let parsedValue;
|
|
34
|
-
try {
|
|
35
|
-
parsedValue = typeof value !== "string" ? value || [] : JSON.parse(value || "[]");
|
|
36
|
-
} catch (e) {
|
|
37
|
-
parsedValue = [];
|
|
38
|
-
}
|
|
39
|
-
return Array.isArray(parsedValue) ? parsedValue.map(
|
|
40
|
-
(val) => possibleOptions.find((option) => option.value === val)
|
|
41
|
-
).filter((option) => !!option) : [];
|
|
42
|
-
}, [value, possibleOptions]);
|
|
43
|
-
const fieldError = useMemo(() => {
|
|
44
|
-
if (error) return error;
|
|
45
|
-
const { min, max } = attribute;
|
|
46
|
-
const hasNoOptions = required && !possibleOptions.length;
|
|
47
|
-
const belowMin = sanitizedValue.length < min && (required || sanitizedValue.length > 0);
|
|
48
|
-
const aboveMax = sanitizedValue.length > max;
|
|
49
|
-
if (hasNoOptions) {
|
|
50
|
-
return "No options, but field is required";
|
|
51
|
-
}
|
|
52
|
-
if (belowMin) {
|
|
53
|
-
return `Select at least ${min} options`;
|
|
54
|
-
}
|
|
55
|
-
if (aboveMax) {
|
|
56
|
-
return `Select at most ${max} options`;
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
59
|
-
}, [required, error, possibleOptions, sanitizedValue, attribute]);
|
|
60
|
-
const handleCheckboxChange = (optionValue, isChecked) => {
|
|
61
|
-
let newValues;
|
|
62
|
-
if (isChecked) {
|
|
63
|
-
newValues = [...sanitizedValue.map((v) => v.value), optionValue];
|
|
64
|
-
} else {
|
|
65
|
-
newValues = sanitizedValue.map((v) => v.value).filter((v) => v !== optionValue);
|
|
66
|
-
}
|
|
67
|
-
onChange({
|
|
68
|
-
target: {
|
|
69
|
-
name,
|
|
70
|
-
value: newValues.length ? JSON.stringify(newValues) : null,
|
|
71
|
-
type: attribute.type
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
const gridCol = Math.floor(12 / (attribute.columns || 1));
|
|
76
|
-
return /* @__PURE__ */ jsx(
|
|
77
|
-
Field.Root,
|
|
78
|
-
{
|
|
79
|
-
hint: description?.id ? formatMessage(description) : hint,
|
|
80
|
-
error: fieldError,
|
|
81
|
-
name,
|
|
82
|
-
required,
|
|
83
|
-
children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
|
|
84
|
-
/* @__PURE__ */ jsx(Field.Label, { children: intlLabel?.id ? formatMessage(intlLabel) : label }),
|
|
85
|
-
possibleOptions.length === 0 ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral400", children: "No options available. Please configure options in the field settings." }) : /* @__PURE__ */ jsx(Box, { padding: 2, children: /* @__PURE__ */ jsx(Grid.Root, { gap: 2, children: possibleOptions.map((option) => {
|
|
86
|
-
const isChecked = sanitizedValue.some((v) => v.value === option.value);
|
|
87
|
-
const isDisabled = disabled || sanitizedValue.length >= attribute["max"] && !isChecked;
|
|
88
|
-
return /* @__PURE__ */ jsx(Grid.Item, { col: gridCol, s: 6, xs: 12, children: /* @__PURE__ */ jsx(
|
|
89
|
-
Checkbox,
|
|
90
|
-
{
|
|
91
|
-
checked: isChecked,
|
|
92
|
-
disabled: isDisabled,
|
|
93
|
-
onCheckedChange: (checked) => handleCheckboxChange(option.value, checked),
|
|
94
|
-
children: /* @__PURE__ */ jsx(CapitalizedText, { children: formatMessage({
|
|
95
|
-
id: option.label,
|
|
96
|
-
defaultMessage: option.label
|
|
97
|
-
}) })
|
|
98
|
-
}
|
|
99
|
-
) }, option.value);
|
|
100
|
-
}) }) }),
|
|
101
|
-
/* @__PURE__ */ jsx(Field.Hint, {}),
|
|
102
|
-
/* @__PURE__ */ jsx(Field.Error, {})
|
|
103
|
-
] })
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
};
|
|
107
|
-
export {
|
|
108
|
-
MultiSelect as default
|
|
109
|
-
};
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const designSystem = require("@strapi/design-system");
|
|
5
|
-
const admin = require("@strapi/strapi/admin");
|
|
6
|
-
const react = require("react");
|
|
7
|
-
const reactIntl = require("react-intl");
|
|
8
|
-
const styled = require("styled-components");
|
|
9
|
-
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
10
|
-
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
11
|
-
const CapitalizedText = styled__default.default.p`
|
|
12
|
-
&::first-letter {
|
|
13
|
-
text-transform: uppercase;
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
const MultiSelect = ({
|
|
17
|
-
hint,
|
|
18
|
-
label,
|
|
19
|
-
name,
|
|
20
|
-
intlLabel,
|
|
21
|
-
required,
|
|
22
|
-
attribute,
|
|
23
|
-
description,
|
|
24
|
-
placeholder,
|
|
25
|
-
disabled
|
|
26
|
-
}) => {
|
|
27
|
-
const { formatMessage } = reactIntl.useIntl();
|
|
28
|
-
const { onChange, value, error } = admin.useField(name);
|
|
29
|
-
const possibleOptions = react.useMemo(() => {
|
|
30
|
-
return (attribute["options"] || []).map((option) => {
|
|
31
|
-
const [label2, value2] = [...option.split(/:(.*)/s), option];
|
|
32
|
-
if (!label2 || !value2) return null;
|
|
33
|
-
return { label: label2, value: value2 };
|
|
34
|
-
}).filter(Boolean);
|
|
35
|
-
}, [attribute]);
|
|
36
|
-
const sanitizedValue = react.useMemo(() => {
|
|
37
|
-
let parsedValue;
|
|
38
|
-
try {
|
|
39
|
-
parsedValue = typeof value !== "string" ? value || [] : JSON.parse(value || "[]");
|
|
40
|
-
} catch (e) {
|
|
41
|
-
parsedValue = [];
|
|
42
|
-
}
|
|
43
|
-
return Array.isArray(parsedValue) ? parsedValue.map(
|
|
44
|
-
(val) => possibleOptions.find((option) => option.value === val)
|
|
45
|
-
).filter((option) => !!option) : [];
|
|
46
|
-
}, [value, possibleOptions]);
|
|
47
|
-
const fieldError = react.useMemo(() => {
|
|
48
|
-
if (error) return error;
|
|
49
|
-
const { min, max } = attribute;
|
|
50
|
-
const hasNoOptions = required && !possibleOptions.length;
|
|
51
|
-
const belowMin = sanitizedValue.length < min && (required || sanitizedValue.length > 0);
|
|
52
|
-
const aboveMax = sanitizedValue.length > max;
|
|
53
|
-
if (hasNoOptions) {
|
|
54
|
-
return "No options, but field is required";
|
|
55
|
-
}
|
|
56
|
-
if (belowMin) {
|
|
57
|
-
return `Select at least ${min} options`;
|
|
58
|
-
}
|
|
59
|
-
if (aboveMax) {
|
|
60
|
-
return `Select at most ${max} options`;
|
|
61
|
-
}
|
|
62
|
-
return null;
|
|
63
|
-
}, [required, error, possibleOptions, sanitizedValue, attribute]);
|
|
64
|
-
const handleCheckboxChange = (optionValue, isChecked) => {
|
|
65
|
-
let newValues;
|
|
66
|
-
if (isChecked) {
|
|
67
|
-
newValues = [...sanitizedValue.map((v) => v.value), optionValue];
|
|
68
|
-
} else {
|
|
69
|
-
newValues = sanitizedValue.map((v) => v.value).filter((v) => v !== optionValue);
|
|
70
|
-
}
|
|
71
|
-
onChange({
|
|
72
|
-
target: {
|
|
73
|
-
name,
|
|
74
|
-
value: newValues.length ? JSON.stringify(newValues) : null,
|
|
75
|
-
type: attribute.type
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
const gridCol = Math.floor(12 / (attribute.columns || 1));
|
|
80
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
81
|
-
designSystem.Field.Root,
|
|
82
|
-
{
|
|
83
|
-
hint: description?.id ? formatMessage(description) : hint,
|
|
84
|
-
error: fieldError,
|
|
85
|
-
name,
|
|
86
|
-
required,
|
|
87
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", alignItems: "stretch", gap: 1, children: [
|
|
88
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Label, { children: intlLabel?.id ? formatMessage(intlLabel) : label }),
|
|
89
|
-
possibleOptions.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral400", children: "No options available. Please configure options in the field settings." }) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { gap: 2, children: possibleOptions.map((option) => {
|
|
90
|
-
const isChecked = sanitizedValue.some((v) => v.value === option.value);
|
|
91
|
-
const isDisabled = disabled || sanitizedValue.length >= attribute["max"] && !isChecked;
|
|
92
|
-
return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: gridCol, s: 6, xs: 12, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
93
|
-
designSystem.Checkbox,
|
|
94
|
-
{
|
|
95
|
-
checked: isChecked,
|
|
96
|
-
disabled: isDisabled,
|
|
97
|
-
onCheckedChange: (checked) => handleCheckboxChange(option.value, checked),
|
|
98
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(CapitalizedText, { children: formatMessage({
|
|
99
|
-
id: option.label,
|
|
100
|
-
defaultMessage: option.label
|
|
101
|
-
}) })
|
|
102
|
-
}
|
|
103
|
-
) }, option.value);
|
|
104
|
-
}) }) }),
|
|
105
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Hint, {}),
|
|
106
|
-
/* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Error, {})
|
|
107
|
-
] })
|
|
108
|
-
}
|
|
109
|
-
);
|
|
110
|
-
};
|
|
111
|
-
exports.default = MultiSelect;
|
package/dist/admin/index.js
DELETED
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const react = require("react");
|
|
3
|
-
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const designSystem = require("@strapi/design-system");
|
|
5
|
-
const icons = require("@strapi/icons");
|
|
6
|
-
const styled = require("styled-components");
|
|
7
|
-
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
8
|
-
const styled__default = /* @__PURE__ */ _interopDefault(styled);
|
|
9
|
-
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
10
|
-
const v = glob[path];
|
|
11
|
-
if (v) {
|
|
12
|
-
return typeof v === "function" ? v() : Promise.resolve(v);
|
|
13
|
-
}
|
|
14
|
-
return new Promise((_, reject) => {
|
|
15
|
-
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
|
16
|
-
reject.bind(
|
|
17
|
-
null,
|
|
18
|
-
new Error(
|
|
19
|
-
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
|
20
|
-
)
|
|
21
|
-
)
|
|
22
|
-
);
|
|
23
|
-
});
|
|
24
|
-
};
|
|
25
|
-
const PLUGIN_ID = "multiselect-checkbox";
|
|
26
|
-
const Initializer = ({ setPlugin }) => {
|
|
27
|
-
const ref = react.useRef(setPlugin);
|
|
28
|
-
react.useEffect(() => {
|
|
29
|
-
ref.current(PLUGIN_ID);
|
|
30
|
-
}, []);
|
|
31
|
-
return null;
|
|
32
|
-
};
|
|
33
|
-
const IconBox = styled__default.default(designSystem.Flex)`
|
|
34
|
-
background-color: #f0f0ff; /* primary100 */
|
|
35
|
-
border: 1px solid #d9d8ff; /* primary200 */
|
|
36
|
-
|
|
37
|
-
svg > path {
|
|
38
|
-
fill: #4945ff; /* primary600 */
|
|
39
|
-
}
|
|
40
|
-
`;
|
|
41
|
-
const PluginIcon = () => {
|
|
42
|
-
return /* @__PURE__ */ jsxRuntime.jsx(IconBox, { justifyContent: "center", alignItems: "center", width: 7, height: 6, hasRadius: true, "aria-hidden": true, children: /* @__PURE__ */ jsxRuntime.jsx(icons.Check, {}) });
|
|
43
|
-
};
|
|
44
|
-
const prefixKey = (key) => `${PLUGIN_ID}.${key}`;
|
|
45
|
-
const index = {
|
|
46
|
-
register(app) {
|
|
47
|
-
app.customFields.register({
|
|
48
|
-
name: "multiselect-checkbox",
|
|
49
|
-
pluginId: `${PLUGIN_ID}`,
|
|
50
|
-
type: "json",
|
|
51
|
-
icon: PluginIcon,
|
|
52
|
-
intlLabel: {
|
|
53
|
-
id: `${PLUGIN_ID}.label`,
|
|
54
|
-
defaultMessage: "Multiselect Checkbox"
|
|
55
|
-
},
|
|
56
|
-
intlDescription: {
|
|
57
|
-
id: `${PLUGIN_ID}.description`,
|
|
58
|
-
defaultMessage: "Select multiple options using checkboxes. Data stored as JSON array."
|
|
59
|
-
},
|
|
60
|
-
components: {
|
|
61
|
-
Input: async () => Promise.resolve().then(() => require("../_chunks/index-D2_7xEii.js"))
|
|
62
|
-
},
|
|
63
|
-
options: {
|
|
64
|
-
base: [
|
|
65
|
-
{
|
|
66
|
-
sectionTitle: null,
|
|
67
|
-
items: [
|
|
68
|
-
{
|
|
69
|
-
name: "options",
|
|
70
|
-
type: "textarea-enum",
|
|
71
|
-
intlLabel: {
|
|
72
|
-
id: prefixKey("options.available-options.label"),
|
|
73
|
-
defaultMessage: "Options (one per line)"
|
|
74
|
-
},
|
|
75
|
-
description: {
|
|
76
|
-
id: prefixKey("options.available-options.description"),
|
|
77
|
-
defaultMessage: "Enter one option per line."
|
|
78
|
-
},
|
|
79
|
-
placeholder: {
|
|
80
|
-
id: prefixKey("options.available-options.placeholder"),
|
|
81
|
-
defaultMessage: "Option 1\nOption 2\nOption 3"
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
name: "columns",
|
|
86
|
-
type: "number",
|
|
87
|
-
intlLabel: {
|
|
88
|
-
id: prefixKey("options.columns.label"),
|
|
89
|
-
defaultMessage: "Number of columns"
|
|
90
|
-
},
|
|
91
|
-
description: {
|
|
92
|
-
id: prefixKey("options.columns.description"),
|
|
93
|
-
defaultMessage: "Number of columns to display (e.g. 1, 2, 3, 4). Default is 1"
|
|
94
|
-
},
|
|
95
|
-
defaultValue: 1
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
name: "default",
|
|
99
|
-
type: "json",
|
|
100
|
-
intlLabel: {
|
|
101
|
-
id: prefixKey("options.default.label"),
|
|
102
|
-
defaultMessage: "Default value"
|
|
103
|
-
},
|
|
104
|
-
description: {
|
|
105
|
-
id: prefixKey("options.default.description"),
|
|
106
|
-
defaultMessage: 'Set the default value in JSON format, ex: ["Option 1", "Option 2"]'
|
|
107
|
-
},
|
|
108
|
-
defaultValue: "[]"
|
|
109
|
-
}
|
|
110
|
-
]
|
|
111
|
-
}
|
|
112
|
-
],
|
|
113
|
-
//
|
|
114
|
-
// Strapi default advanced options.
|
|
115
|
-
//
|
|
116
|
-
advanced: [
|
|
117
|
-
{
|
|
118
|
-
sectionTitle: {
|
|
119
|
-
id: "global.settings",
|
|
120
|
-
defaultMessage: "Settings"
|
|
121
|
-
},
|
|
122
|
-
items: [
|
|
123
|
-
{
|
|
124
|
-
name: "required",
|
|
125
|
-
type: "checkbox",
|
|
126
|
-
intlLabel: {
|
|
127
|
-
id: "content-type-builder.form.attribute.item.requiredField",
|
|
128
|
-
defaultMessage: "Required field"
|
|
129
|
-
},
|
|
130
|
-
description: {
|
|
131
|
-
id: "content-type-builder.form.attribute.item.requiredField.description",
|
|
132
|
-
defaultMessage: "You won't be able to create an entry if this field is empty"
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
name: "private",
|
|
137
|
-
type: "checkbox",
|
|
138
|
-
intlLabel: {
|
|
139
|
-
id: "content-type-builder.form.attribute.item.privateField",
|
|
140
|
-
defaultMessage: "Private field"
|
|
141
|
-
},
|
|
142
|
-
description: {
|
|
143
|
-
id: "content-type-builder.form.attribute.item.privateField.description",
|
|
144
|
-
defaultMessage: "This field will not show up in the API response"
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
]
|
|
148
|
-
}
|
|
149
|
-
]
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
app.registerPlugin({
|
|
153
|
-
id: PLUGIN_ID,
|
|
154
|
-
initializer: Initializer,
|
|
155
|
-
isReady: false,
|
|
156
|
-
name: PLUGIN_ID
|
|
157
|
-
});
|
|
158
|
-
},
|
|
159
|
-
async registerTrads({ locales }) {
|
|
160
|
-
return Promise.all(
|
|
161
|
-
locales.map(async (locale) => {
|
|
162
|
-
try {
|
|
163
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => Promise.resolve().then(() => require("../_chunks/en-pkXKBXLR.js")) }), `./translations/${locale}.json`, 3);
|
|
164
|
-
return { data, locale };
|
|
165
|
-
} catch {
|
|
166
|
-
return { data: {}, locale };
|
|
167
|
-
}
|
|
168
|
-
})
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
module.exports = index;
|
package/dist/admin/index.mjs
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { useRef, useEffect } from "react";
|
|
2
|
-
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { Flex } from "@strapi/design-system";
|
|
4
|
-
import { Check } from "@strapi/icons";
|
|
5
|
-
import styled from "styled-components";
|
|
6
|
-
const __variableDynamicImportRuntimeHelper = (glob, path, segs) => {
|
|
7
|
-
const v = glob[path];
|
|
8
|
-
if (v) {
|
|
9
|
-
return typeof v === "function" ? v() : Promise.resolve(v);
|
|
10
|
-
}
|
|
11
|
-
return new Promise((_, reject) => {
|
|
12
|
-
(typeof queueMicrotask === "function" ? queueMicrotask : setTimeout)(
|
|
13
|
-
reject.bind(
|
|
14
|
-
null,
|
|
15
|
-
new Error(
|
|
16
|
-
"Unknown variable dynamic import: " + path + (path.split("/").length !== segs ? ". Note that variables only represent file names one level deep." : "")
|
|
17
|
-
)
|
|
18
|
-
)
|
|
19
|
-
);
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
const PLUGIN_ID = "multiselect-checkbox";
|
|
23
|
-
const Initializer = ({ setPlugin }) => {
|
|
24
|
-
const ref = useRef(setPlugin);
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
ref.current(PLUGIN_ID);
|
|
27
|
-
}, []);
|
|
28
|
-
return null;
|
|
29
|
-
};
|
|
30
|
-
const IconBox = styled(Flex)`
|
|
31
|
-
background-color: #f0f0ff; /* primary100 */
|
|
32
|
-
border: 1px solid #d9d8ff; /* primary200 */
|
|
33
|
-
|
|
34
|
-
svg > path {
|
|
35
|
-
fill: #4945ff; /* primary600 */
|
|
36
|
-
}
|
|
37
|
-
`;
|
|
38
|
-
const PluginIcon = () => {
|
|
39
|
-
return /* @__PURE__ */ jsx(IconBox, { justifyContent: "center", alignItems: "center", width: 7, height: 6, hasRadius: true, "aria-hidden": true, children: /* @__PURE__ */ jsx(Check, {}) });
|
|
40
|
-
};
|
|
41
|
-
const prefixKey = (key) => `${PLUGIN_ID}.${key}`;
|
|
42
|
-
const index = {
|
|
43
|
-
register(app) {
|
|
44
|
-
app.customFields.register({
|
|
45
|
-
name: "multiselect-checkbox",
|
|
46
|
-
pluginId: `${PLUGIN_ID}`,
|
|
47
|
-
type: "json",
|
|
48
|
-
icon: PluginIcon,
|
|
49
|
-
intlLabel: {
|
|
50
|
-
id: `${PLUGIN_ID}.label`,
|
|
51
|
-
defaultMessage: "Multiselect Checkbox"
|
|
52
|
-
},
|
|
53
|
-
intlDescription: {
|
|
54
|
-
id: `${PLUGIN_ID}.description`,
|
|
55
|
-
defaultMessage: "Select multiple options using checkboxes. Data stored as JSON array."
|
|
56
|
-
},
|
|
57
|
-
components: {
|
|
58
|
-
Input: async () => import("../_chunks/index-BnVwcKcR.mjs")
|
|
59
|
-
},
|
|
60
|
-
options: {
|
|
61
|
-
base: [
|
|
62
|
-
{
|
|
63
|
-
sectionTitle: null,
|
|
64
|
-
items: [
|
|
65
|
-
{
|
|
66
|
-
name: "options",
|
|
67
|
-
type: "textarea-enum",
|
|
68
|
-
intlLabel: {
|
|
69
|
-
id: prefixKey("options.available-options.label"),
|
|
70
|
-
defaultMessage: "Options (one per line)"
|
|
71
|
-
},
|
|
72
|
-
description: {
|
|
73
|
-
id: prefixKey("options.available-options.description"),
|
|
74
|
-
defaultMessage: "Enter one option per line."
|
|
75
|
-
},
|
|
76
|
-
placeholder: {
|
|
77
|
-
id: prefixKey("options.available-options.placeholder"),
|
|
78
|
-
defaultMessage: "Option 1\nOption 2\nOption 3"
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
name: "columns",
|
|
83
|
-
type: "number",
|
|
84
|
-
intlLabel: {
|
|
85
|
-
id: prefixKey("options.columns.label"),
|
|
86
|
-
defaultMessage: "Number of columns"
|
|
87
|
-
},
|
|
88
|
-
description: {
|
|
89
|
-
id: prefixKey("options.columns.description"),
|
|
90
|
-
defaultMessage: "Number of columns to display (e.g. 1, 2, 3, 4). Default is 1"
|
|
91
|
-
},
|
|
92
|
-
defaultValue: 1
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: "default",
|
|
96
|
-
type: "json",
|
|
97
|
-
intlLabel: {
|
|
98
|
-
id: prefixKey("options.default.label"),
|
|
99
|
-
defaultMessage: "Default value"
|
|
100
|
-
},
|
|
101
|
-
description: {
|
|
102
|
-
id: prefixKey("options.default.description"),
|
|
103
|
-
defaultMessage: 'Set the default value in JSON format, ex: ["Option 1", "Option 2"]'
|
|
104
|
-
},
|
|
105
|
-
defaultValue: "[]"
|
|
106
|
-
}
|
|
107
|
-
]
|
|
108
|
-
}
|
|
109
|
-
],
|
|
110
|
-
//
|
|
111
|
-
// Strapi default advanced options.
|
|
112
|
-
//
|
|
113
|
-
advanced: [
|
|
114
|
-
{
|
|
115
|
-
sectionTitle: {
|
|
116
|
-
id: "global.settings",
|
|
117
|
-
defaultMessage: "Settings"
|
|
118
|
-
},
|
|
119
|
-
items: [
|
|
120
|
-
{
|
|
121
|
-
name: "required",
|
|
122
|
-
type: "checkbox",
|
|
123
|
-
intlLabel: {
|
|
124
|
-
id: "content-type-builder.form.attribute.item.requiredField",
|
|
125
|
-
defaultMessage: "Required field"
|
|
126
|
-
},
|
|
127
|
-
description: {
|
|
128
|
-
id: "content-type-builder.form.attribute.item.requiredField.description",
|
|
129
|
-
defaultMessage: "You won't be able to create an entry if this field is empty"
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
name: "private",
|
|
134
|
-
type: "checkbox",
|
|
135
|
-
intlLabel: {
|
|
136
|
-
id: "content-type-builder.form.attribute.item.privateField",
|
|
137
|
-
defaultMessage: "Private field"
|
|
138
|
-
},
|
|
139
|
-
description: {
|
|
140
|
-
id: "content-type-builder.form.attribute.item.privateField.description",
|
|
141
|
-
defaultMessage: "This field will not show up in the API response"
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
]
|
|
145
|
-
}
|
|
146
|
-
]
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
app.registerPlugin({
|
|
150
|
-
id: PLUGIN_ID,
|
|
151
|
-
initializer: Initializer,
|
|
152
|
-
isReady: false,
|
|
153
|
-
name: PLUGIN_ID
|
|
154
|
-
});
|
|
155
|
-
},
|
|
156
|
-
async registerTrads({ locales }) {
|
|
157
|
-
return Promise.all(
|
|
158
|
-
locales.map(async (locale) => {
|
|
159
|
-
try {
|
|
160
|
-
const { default: data } = await __variableDynamicImportRuntimeHelper(/* @__PURE__ */ Object.assign({ "./translations/en.json": () => import("../_chunks/en-tWwdhLO5.mjs") }), `./translations/${locale}.json`, 3);
|
|
161
|
-
return { data, locale };
|
|
162
|
-
} catch {
|
|
163
|
-
return { data: {}, locale };
|
|
164
|
-
}
|
|
165
|
-
})
|
|
166
|
-
);
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
export {
|
|
170
|
-
index as default
|
|
171
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
declare const MultiSelect: ({ hint, label, name, intlLabel, required, attribute, description, placeholder, disabled, }: {
|
|
2
|
-
hint: string;
|
|
3
|
-
label: string;
|
|
4
|
-
name: string;
|
|
5
|
-
intlLabel: any;
|
|
6
|
-
required: boolean;
|
|
7
|
-
attribute: any;
|
|
8
|
-
description: any;
|
|
9
|
-
placeholder: string;
|
|
10
|
-
disabled: boolean;
|
|
11
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
12
|
-
export default MultiSelect;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const PLUGIN_ID = "multiselect-checkbox";
|
package/dist/server/index.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
const bootstrap = ({ strapi }) => {
|
|
3
|
-
};
|
|
4
|
-
const config = {
|
|
5
|
-
default: {},
|
|
6
|
-
validator() {
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
const contentTypes = {};
|
|
10
|
-
const controller = ({ strapi }) => ({});
|
|
11
|
-
const controllers = {
|
|
12
|
-
controller
|
|
13
|
-
};
|
|
14
|
-
const destroy = ({ strapi }) => {
|
|
15
|
-
};
|
|
16
|
-
const middlewares = {};
|
|
17
|
-
const policies = {};
|
|
18
|
-
const register = ({ strapi }) => {
|
|
19
|
-
strapi.customFields.register({
|
|
20
|
-
name: "multiselect-checkbox",
|
|
21
|
-
plugin: "multiselect-checkbox",
|
|
22
|
-
// The data type stored in the database - JSON array
|
|
23
|
-
type: "json",
|
|
24
|
-
inputSize: {
|
|
25
|
-
default: 12,
|
|
26
|
-
isResizable: true
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
const contentAPIRoutes = [];
|
|
31
|
-
const routes = {
|
|
32
|
-
"content-api": {
|
|
33
|
-
type: "content-api",
|
|
34
|
-
routes: contentAPIRoutes
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
const service = ({ strapi }) => ({});
|
|
38
|
-
const services = {
|
|
39
|
-
service
|
|
40
|
-
};
|
|
41
|
-
const index = {
|
|
42
|
-
register,
|
|
43
|
-
bootstrap,
|
|
44
|
-
destroy,
|
|
45
|
-
config,
|
|
46
|
-
controllers,
|
|
47
|
-
routes,
|
|
48
|
-
services,
|
|
49
|
-
contentTypes,
|
|
50
|
-
policies,
|
|
51
|
-
middlewares
|
|
52
|
-
};
|
|
53
|
-
module.exports = index;
|
package/dist/server/index.mjs
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
const bootstrap = ({ strapi }) => {
|
|
2
|
-
};
|
|
3
|
-
const config = {
|
|
4
|
-
default: {},
|
|
5
|
-
validator() {
|
|
6
|
-
}
|
|
7
|
-
};
|
|
8
|
-
const contentTypes = {};
|
|
9
|
-
const controller = ({ strapi }) => ({});
|
|
10
|
-
const controllers = {
|
|
11
|
-
controller
|
|
12
|
-
};
|
|
13
|
-
const destroy = ({ strapi }) => {
|
|
14
|
-
};
|
|
15
|
-
const middlewares = {};
|
|
16
|
-
const policies = {};
|
|
17
|
-
const register = ({ strapi }) => {
|
|
18
|
-
strapi.customFields.register({
|
|
19
|
-
name: "multiselect-checkbox",
|
|
20
|
-
plugin: "multiselect-checkbox",
|
|
21
|
-
// The data type stored in the database - JSON array
|
|
22
|
-
type: "json",
|
|
23
|
-
inputSize: {
|
|
24
|
-
default: 12,
|
|
25
|
-
isResizable: true
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
const contentAPIRoutes = [];
|
|
30
|
-
const routes = {
|
|
31
|
-
"content-api": {
|
|
32
|
-
type: "content-api",
|
|
33
|
-
routes: contentAPIRoutes
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
const service = ({ strapi }) => ({});
|
|
37
|
-
const services = {
|
|
38
|
-
service
|
|
39
|
-
};
|
|
40
|
-
const index = {
|
|
41
|
-
register,
|
|
42
|
-
bootstrap,
|
|
43
|
-
destroy,
|
|
44
|
-
config,
|
|
45
|
-
controllers,
|
|
46
|
-
routes,
|
|
47
|
-
services,
|
|
48
|
-
contentTypes,
|
|
49
|
-
policies,
|
|
50
|
-
middlewares
|
|
51
|
-
};
|
|
52
|
-
export {
|
|
53
|
-
index as default
|
|
54
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
register: ({ strapi }: {
|
|
3
|
-
strapi: import("@strapi/types/dist/core").Strapi;
|
|
4
|
-
}) => void;
|
|
5
|
-
bootstrap: ({ strapi }: {
|
|
6
|
-
strapi: import("@strapi/types/dist/core").Strapi;
|
|
7
|
-
}) => void;
|
|
8
|
-
destroy: ({ strapi }: {
|
|
9
|
-
strapi: import("@strapi/types/dist/core").Strapi;
|
|
10
|
-
}) => void;
|
|
11
|
-
config: {
|
|
12
|
-
default: {};
|
|
13
|
-
validator(): void;
|
|
14
|
-
};
|
|
15
|
-
controllers: {
|
|
16
|
-
controller: ({ strapi }: {
|
|
17
|
-
strapi: import("@strapi/types/dist/core").Strapi;
|
|
18
|
-
}) => {};
|
|
19
|
-
};
|
|
20
|
-
routes: {
|
|
21
|
-
'content-api': {
|
|
22
|
-
type: string;
|
|
23
|
-
routes: any[];
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
services: {
|
|
27
|
-
service: ({ strapi }: {
|
|
28
|
-
strapi: import("@strapi/types/dist/core").Strapi;
|
|
29
|
-
}) => {};
|
|
30
|
-
};
|
|
31
|
-
contentTypes: {};
|
|
32
|
-
policies: {};
|
|
33
|
-
middlewares: {};
|
|
34
|
-
};
|
|
35
|
-
export default _default;
|