Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Dev into Master v0.3.0 #3

Merged
merged 33 commits into from
Apr 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2b4e566
Update Screenshot
Apr 26, 2021
2a6002e
Update readme.md & changed file naming
Apr 26, 2021
3b954a8
Fixed some typos
Apr 26, 2021
8e0e15c
add version badge
Apr 26, 2021
ddec887
Update README.md
sidneywm Apr 26, 2021
b8e5252
update readme.md - added configuration
Apr 26, 2021
95d643a
add compulsory remark
Apr 26, 2021
19cee38
Update README.md
sidneywm Apr 26, 2021
0dbf592
test readme.md
Apr 26, 2021
38ffc1e
add description of options
Apr 26, 2021
71fea02
update
Apr 26, 2021
bb1f509
add contributing section & example to the config section
Apr 26, 2021
78ed87a
fix
Apr 26, 2021
d6b966f
fix formatting
Apr 26, 2021
b71c8d4
add missing type to script tag
Apr 26, 2021
ccbcc55
Update README.md
sidneywm Apr 26, 2021
9915e17
add methods section readme.md
Apr 27, 2021
2fa52b5
Update README.md
sidneywm Apr 27, 2021
1d4d8bc
Update README.md
sidneywm Apr 27, 2021
7a9fcc9
add anchor link configuration
Apr 27, 2021
a7dea89
Merge branch 'dev' of https://github.com/sidneywm/iconic-multiselect …
Apr 27, 2021
84b9f9f
typo
Apr 27, 2021
43c53d8
Update Readme.md
Apr 27, 2021
cd5ebd2
Update licence
Apr 27, 2021
0037d05
Update license
Apr 27, 2021
bf29460
Update readme.md
Apr 27, 2021
5fd8efc
update
Apr 27, 2021
3904482
handle arrows and enter
Apr 28, 2021
58fc8d8
fix bug when options were filtered and user wanted to remove option f…
Apr 28, 2021
45d662c
improve compatibility with ie11 & update gulpfile & polyfill file
Apr 28, 2021
026e5ff
styled arrow-selected & fix bug with remove()
Apr 28, 2021
9e712e8
version update
Apr 28, 2021
bb0a51e
version update package.json
Apr 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5533
}
File renamed without changes.
155 changes: 152 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,166 @@
# Iconic Multiselect

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) [![Version](https://img.shields.io/github/package-json/v/sidneywm/iconic-multiselect)](https://github.com/sidneywm/iconic-multiselect)

<p align="center">A multiselect component written in pure JavaScript - Also compatible with IE11</p>

<p align="center">
<img src="./assets/iconic-multiselect-screenshot.png">
<img src="./assets/iconic-multiselect.png">
</p>

## Getting Started

### 1. Link the required files

Firstly, the script needs to be included in your HTML file. If you would like to personalize the Iconic Multiselect component, you can additionally include a CSS stylesheet with your custom CSS properties which target the Iconic Multiselect component classes. Also, do not forget to set `customCss` to `true`. ([see configuration](#configuration))

```html
<head>

// Optional
<link rel="stylesheet" href="multi-select.css" type="text/css" />

</head>

<script src="multi-select.js" type="text/javascript"></script>
```

If you intend to use the Iconic Multiselect component with Internet Explorer 11, it is recommended to use the script with the polyfills included.

```html
<script src="multi-select-ie11-polyfills.js" type="text/javascript"></script>
```

### 2. Create a select tag

Secondly, within your HTML file, create a `<select>` tag which you want to turn into a multiselect. Do not forget to set an `id` on your `<select>` tag.

```html
<select id="foods">
<option value="bread">Bread</option>
<option value="cereal">Cereal</option>
<option value="pasta">Pasta</option>
<option value="rice">Rice</option>
<option value="meat">Meat</option>
<option value="fish">Fish</option>
</select>
```

### 3. Initialize the Iconic Multiselect component

Finally, target the `id` of your `<select>` tag in the options and initialize the component with the `.init()` method. You may also specify further options. ([see configuration](#configuration))

```html
<script type="text/javascript">

const multiSelect = new IconicMultiSelect({
select: "#foods",
});

multiSelect.init();

</script>
```
## Configuration

### 1. Overview

| Option | Default | Type |
| :--- | :---: | :---: |
| customCss | `false` | `boolean` |
| data | `[]` | `Object[]` |
| noData | `No data found.` | `string` |
| noResults | `No results found.` | `string` |
| placeholder | `Select...` | `string` |
| select* | `none` | `string` |
| textField | `null` | `string` |
| valueField | `null` | `string` |

\* This option is compulsory

#### `customCss`
If set to `true`, the component will not inject its own CSS in the `<head>` tag.

#### `data*`
The component can be configured with data set in the configuration fields. It must be an `Array` of `Objects`.

#### `noData`
Text to display if there is no data found in the `<select>` tag or in the data field.

#### `noResults`
Text to display if there is no results when the option list is filtered.

#### `placeholder`
Text to display in the input placeholder.

#### `select`
The `<select>` tag from which the component is initialized.

#### `textField`
The field of the data object that provides the text content.

#### `valueField`
The field of the data object that provides the value.

\* **IMPORTANT:** When `data` is provided, `valueField` and `textField` should also be set.

### 2. Example

```html
<script type="text/javascript">

const multiSelect = new IconicMultiSelect({
customCss: true,
data: [
{ valueName: "bread", itemName: 'Bread'},
{ valueName: "rice", itemName: 'Rice'},
{ valueName: "pasta", itemName: 'Pasta'}
],
noData: "No food item found.",
noResults: "No results found in this list.",
placeholder: "Select a food item...",
select: "#foods",
textField: 'itemName',
valueField: 'valueName',
});

</script>
```

## Methods

#### `.init()`
Initialize the component with all its settings.

#### `.subscribe()`
Listen for all events.

Example:

```javascript
JavaScript:

multiSelect.subscribe(function(event) {
console.log(event);
});

```

```console
Console:

Object : { action: "ADD_OPTION", value: "pasta", selection: (1) [...] }
```


## Contributing

Iconic Multiselect is an open-source project. Contributions of any kind are welcome and appreciated. Feel free to open an issue or request a feature. Pull requests are also welcome.

## Author

- [Sidney Wimart](https://github.com/sidneywm)

## License

This project is open source and available under the [MIT License](LICENSE).
This project is open source and available under the [MIT License](LICENSE).
Binary file removed assets/iconic-multiselect-screenshot.png
Binary file not shown.
Binary file added assets/iconic-multiselect.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ <h1>Iconic MultiSelect</h1>
<option>Boulouparis</option>
</select>
</body>
<script src="multi-select-ie11-polyfill.min.js" type="text/javascript"></script>
<script src="multi-select-ie11-polyfills.min.js" type="text/javascript"></script>

<script>
var multiSelect = new IconicMultiSelect({
Expand Down