@tunghtml/strapi-plugin-dynamic-enum 1.0.0 → 1.0.2
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.
|
@@ -29,9 +29,22 @@ const DynamicEnumInput = ({
|
|
|
29
29
|
let opts = [];
|
|
30
30
|
if (typeof initialOptions === 'string') {
|
|
31
31
|
try {
|
|
32
|
-
|
|
32
|
+
const parsed = JSON.parse(initialOptions);
|
|
33
|
+
if (Array.isArray(parsed)) {
|
|
34
|
+
opts = parsed;
|
|
35
|
+
} else {
|
|
36
|
+
// If valid JSON but not an array (e.g. string/number), treat as text
|
|
37
|
+
opts = initialOptions
|
|
38
|
+
.split('\n')
|
|
39
|
+
.map((o) => o.trim())
|
|
40
|
+
.filter(Boolean);
|
|
41
|
+
}
|
|
33
42
|
} catch {
|
|
34
|
-
|
|
43
|
+
// Not valid JSON, treat as newline-separated text
|
|
44
|
+
opts = initialOptions
|
|
45
|
+
.split('\n')
|
|
46
|
+
.map((o) => o.trim())
|
|
47
|
+
.filter(Boolean);
|
|
35
48
|
}
|
|
36
49
|
} else {
|
|
37
50
|
opts = Array.isArray(initialOptions) ? initialOptions : [];
|
|
@@ -1,5 +1,34 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Flex } from '@strapi/design-system';
|
|
2
|
+
import { ListPlus } from '@strapi/icons';
|
|
3
|
+
import styled from 'styled-components';
|
|
2
4
|
|
|
3
|
-
const
|
|
5
|
+
const IconBox = styled(Flex)`
|
|
6
|
+
background-color: #fffbeb; /* light yellow background */
|
|
7
|
+
border: 1px solid #fbbf24; /* yellow border */
|
|
8
|
+
|
|
9
|
+
svg {
|
|
10
|
+
width: 15px;
|
|
11
|
+
height: 15px;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
svg > path {
|
|
15
|
+
fill: #f59e0b; /* amber/orange-yellow icon */
|
|
16
|
+
}
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const PluginIcon = () => {
|
|
20
|
+
return (
|
|
21
|
+
<IconBox
|
|
22
|
+
justifyContent="center"
|
|
23
|
+
alignItems="center"
|
|
24
|
+
width={7}
|
|
25
|
+
height={6}
|
|
26
|
+
hasRadius={true}
|
|
27
|
+
aria-hidden={true}
|
|
28
|
+
>
|
|
29
|
+
<ListPlus />
|
|
30
|
+
</IconBox>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
4
33
|
|
|
5
34
|
export default PluginIcon;
|
package/package.json
CHANGED
package/strapi-admin.js
CHANGED
|
@@ -28,19 +28,18 @@ export default {
|
|
|
28
28
|
items: [
|
|
29
29
|
{
|
|
30
30
|
name: 'options',
|
|
31
|
-
type: '
|
|
31
|
+
type: 'textarea',
|
|
32
32
|
intlLabel: {
|
|
33
33
|
id: 'dynamic-enum.options.enum',
|
|
34
34
|
defaultMessage: 'Initial Options',
|
|
35
35
|
},
|
|
36
36
|
description: {
|
|
37
37
|
id: 'dynamic-enum.options.enum.description',
|
|
38
|
-
defaultMessage:
|
|
39
|
-
'Enter initial enum values as JSON array: ["Option 1", "Option 2"]',
|
|
38
|
+
defaultMessage: 'Enter initial enum values, one per line',
|
|
40
39
|
},
|
|
41
40
|
placeholder: {
|
|
42
41
|
id: 'dynamic-enum.options.enum.placeholder',
|
|
43
|
-
defaultMessage: '
|
|
42
|
+
defaultMessage: 'Option 1\nOption 2\nOption 3',
|
|
44
43
|
},
|
|
45
44
|
},
|
|
46
45
|
{
|