Skip to content

Commit 1dc5dd6

Browse files
fix: Added support for SSR, typo fixes
1 parent 87ad2ba commit 1dc5dd6

File tree

6 files changed

+23
-19
lines changed

6 files changed

+23
-19
lines changed

Diff for: LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Francisco Hodge
3+
Copyright (c) 2023 KeyValue Software Systems
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

Diff for: README.md

+9-7
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ npm install @keyvaluesystems/react-multi-selection-ui-component
2222

2323
You’ll need to install React separately since it isn't included in the package.
2424

25+
Note for **Next.js** users, if you are using Next.js version 13 or later, you will have to use the `use client` feature to ensure proper compatibility.
26+
2527
## Usage
2628

2729
React Multi Selection UI can run in a very basic mode by just providing the `options` like given below:
@@ -276,9 +278,9 @@ To customize the style of various components, you can use the following prop nam
276278

277279
You can utilize the provided prop names to customize the style of individual items in the chip or each item in the menu. This can be achieved by passing a function that returns the desired style for each element.
278280

279-
- `ChipComponent` - overrides the chip style
280-
- `SelectedMenuItem` - overrides the selected menu item styles
281-
- `UnSelectedMenuItem` - overrides the non selected item styles
281+
- `ChipComponent` - Overrides the chip style
282+
- `SelectedMenuItem` - Overrides the selected menu item styles
283+
- `UnSelectedMenuItem` - Overrides the non selected item styles
282284

283285
## Icon Customizations
284286

@@ -297,7 +299,7 @@ The following code displays the icons that can be customized
297299
/>
298300
```
299301

300-
- `Arrow` - override the down arrow(right)
301-
- `ChipClose` - overrides the chip close icon
302-
- `Checked` - override the checkbox checked icon
303-
- `Search` - override the search icon
302+
- `Arrow` - Overrides the down arrow(right)
303+
- `ChipClose` - Overrides the chip close icon
304+
- `Checked` - Overrides the checkbox checked icon
305+
- `Search` - Overrides the search icon

Diff for: package-lock.json

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@
2424
"url": "https://github.com/KeyValueSoftwareSystems/react-multi-selection-ui"
2525
},
2626
"author": "Keyvalue",
27-
"license": "",
27+
"license": "MIT",
2828
"homepage": "https://github.com/KeyValueSoftwareSystems/react-multi-selection-ui",
2929
"keywords": [
3030
"library",
3131
"starter",
32-
"es6"
32+
"es6",
33+
"nextjs"
3334
],
3435
"devDependencies": {
3536
"@babel/cli": "^7.20.7",

Diff for: src/lib/multi-select/multiSelect.tsx

+7-8
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const MultiSelect = (props: MultiSelectPropType): JSX.Element => {
4444
//ref for the modal
4545
const modalRef = useRef<HTMLDivElement>(null);
4646
// ref for the container having chips,search bar and arrow
47-
const interactableAreaRef = useRef<HTMLDivElement>(null);
47+
const intractableAreaRef = useRef<HTMLDivElement>(null);
4848

4949
useEffect(() => {
5050
setList(options);
@@ -55,12 +55,11 @@ const MultiSelect = (props: MultiSelectPropType): JSX.Element => {
5555
}, [options]);
5656

5757
useEffect(() => {
58-
if (typeof document !== undefined) {
58+
if (typeof document!== undefined) {
5959
document.addEventListener("mouseup", onMouseUp);
60-
6160
return () => document.removeEventListener("mouseup", onMouseUp);
6261
}
63-
}, [document]);
62+
}, []);
6463

6564
const handleSearch = (value: string): void => {
6665
if (onSearch) {
@@ -114,12 +113,11 @@ const MultiSelect = (props: MultiSelectPropType): JSX.Element => {
114113
if (
115114
event.target instanceof Node &&
116115
!modalRef?.current?.contains(event.target) &&
117-
!interactableAreaRef?.current?.contains(event.target)
116+
!intractableAreaRef?.current?.contains(event.target)
118117
) {
119118
// to close the dropdown modal on clicking outside the modal and the search bar
120119
setIsModalVisible(false);
121120
setShowAllChips(false);
122-
return;
123121
}
124122
};
125123

@@ -137,11 +135,12 @@ const MultiSelect = (props: MultiSelectPropType): JSX.Element => {
137135
<div className={classes.container} style={styles[Elements.Container]}>
138136
<div
139137
className={`${classes.box} ${hasError && classes.errorBorder}`}
140-
ref={interactableAreaRef}
138+
ref={intractableAreaRef}
141139
style={styles[Elements.InputBox]}
142140
onClick={(): void => {
143141
setShowAllChips(true);
144142
}}
143+
role="presentation"
145144
>
146145
<div className={classes.headSection}>
147146
{showChips && (
@@ -176,7 +175,7 @@ const MultiSelect = (props: MultiSelectPropType): JSX.Element => {
176175
id="down-arrow"
177176
>
178177
<img
179-
src={Arrow || DownArrow}
178+
src={Arrow ?? DownArrow}
180179
className={classes.rotation}
181180
style={{
182181
transform: `rotate(${isModalVisible ? "180deg" : "0deg"})`,

Diff for: webpack.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ module.exports = {
3232
path: path.resolve(__dirname, 'build'),
3333
library: "Multi Select Component",
3434
libraryTarget: 'umd',
35-
clean: true
35+
clean: true,
36+
globalObject: 'this',
3637
},
3738
optimization: {
3839
minimize: true,

0 commit comments

Comments
 (0)