Skip to content

Commit fde8ca4

Browse files
committed
Migrated to typescript, and new v5 plugin structure
1 parent d6e5279 commit fde8ca4

31 files changed

+20353
-30095
lines changed

.gitignore

+136
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,138 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
############################
4+
# OS X
5+
############################
6+
17
.DS_Store
8+
.AppleDouble
9+
.LSOverride
10+
Icon
11+
.Spotlight-V100
12+
.Trashes
13+
._*
14+
15+
16+
############################
17+
# Linux
18+
############################
19+
20+
*~
21+
22+
23+
############################
24+
# Windows
25+
############################
26+
27+
Thumbs.db
28+
ehthumbs.db
29+
Desktop.ini
30+
$RECYCLE.BIN/
31+
*.cab
32+
*.msi
33+
*.msm
34+
*.msp
35+
36+
37+
############################
38+
# Packages
39+
############################
40+
41+
*.7z
42+
*.csv
43+
*.dat
44+
*.dmg
45+
*.gz
46+
*.iso
47+
*.jar
48+
*.rar
49+
*.tar
50+
*.zip
51+
*.com
52+
*.class
53+
*.dll
54+
*.exe
55+
*.o
56+
*.seed
57+
*.so
58+
*.swo
59+
*.swp
60+
*.swn
61+
*.swm
62+
*.out
63+
*.pid
64+
65+
66+
############################
67+
# Logs and databases
68+
############################
69+
70+
.tmp
71+
*.log
72+
*.sql
73+
*.sqlite
74+
*.sqlite3
75+
76+
77+
############################
78+
# Misc.
79+
############################
80+
81+
*#
82+
ssl
83+
.idea
84+
nbproject
85+
.tsbuildinfo
86+
.eslintcache
87+
.env
88+
89+
90+
############################
91+
# Strapi
92+
############################
93+
94+
public/uploads/*
95+
!public/uploads/.gitkeep
96+
97+
98+
############################
99+
# Build
100+
############################
101+
102+
dist
103+
build
104+
105+
106+
############################
107+
# Node.js
108+
############################
109+
110+
lib-cov
111+
lcov.info
112+
pids
113+
logs
114+
results
2115
node_modules
116+
.node_history
117+
118+
119+
############################
120+
# Package managers
121+
############################
122+
123+
.yarn/*
124+
!.yarn/cache
125+
!.yarn/unplugged
126+
!.yarn/patches
127+
!.yarn/releases
128+
!.yarn/sdks
129+
!.yarn/versions
130+
.pnp.*
131+
yarn-error.log
132+
133+
134+
############################
135+
# Tests
136+
############################
137+
138+
coverage

.prettierignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
dist
2+
coverage

.prettierrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"endOfLine": "lf",
3+
"tabWidth": 2,
4+
"printWidth": 100,
5+
"singleQuote": true,
6+
"trailingComma": "es5"
7+
}

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
A strapi custom field for selecting multiple options from a provided list of items.
44

55
### CHANGELOG
6+
**2.0.0**
7+
- Migrated to Strapi v5, and the new plugin structure
8+
- Now using @strapi/sdk-plugin
9+
- Migrated to TypeScript
610

711
**1.2.2** Support colons in option values, only first colon is used as separator
812

admin/custom.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare module '@strapi/design-system/*';
2+
declare module '@strapi/design-system';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Tag } from '@strapi/design-system';
2+
import { Cross } from '@strapi/icons';
3+
4+
export default ({
5+
selectProps,
6+
data,
7+
}: {
8+
selectProps: any;
9+
data: {
10+
value: string;
11+
label: string;
12+
};
13+
}) => {
14+
const handleTagClick = (data: { value: string; label: string }) => (e: React.UIEvent<any>) => {
15+
e.preventDefault();
16+
selectProps.onChange(selectProps.value.filter((v: any) => v !== data));
17+
};
18+
return (
19+
<Tag tabIndex={-1} icon={<Cross />} onClick={handleTagClick(data)}>
20+
{data.label}
21+
</Tag>
22+
);
23+
};

admin/src/components/MultiSelect/ReactSelect.jsx

-64
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import Select from 'react-select';
2+
import styled from 'styled-components';
3+
4+
const ReactSelect = ({ components, styles, error, ariaErrorMessage, ...props }: any) => {
5+
return (
6+
<Select
7+
menuPosition="fixed"
8+
components={{
9+
IndicatorSeparator: () => null,
10+
LoadingIndicator: () => null,
11+
...components,
12+
}}
13+
aria-errormessage={error && ariaErrorMessage}
14+
aria-invalid={!!error}
15+
styles={{ ...styles }}
16+
{...props}
17+
/>
18+
);
19+
};
20+
21+
const StyledReactSelect = styled(ReactSelect)`
22+
.select-control {
23+
height: auto;
24+
background: ${({ theme }) => theme.colors.neutral0};
25+
border: 1px solid ${({ theme }) => theme.colors.neutral200};
26+
27+
& > div:first-child {
28+
padding: 4px;
29+
gap: 4px;
30+
31+
& > div {
32+
padding-left: 8px;
33+
}
34+
}
35+
36+
.select-multi-value-container {
37+
margin-right: -8px;
38+
}
39+
}
40+
.select-menu {
41+
background: ${({ theme }) => theme.colors.neutral0};
42+
43+
.option-focused {
44+
background: ${({ theme }) => theme.colors.neutral200};
45+
}
46+
}
47+
`;
48+
49+
export default StyledReactSelect;

0 commit comments

Comments
 (0)