@night-owl-elite/vue-select 1.3.1 → 1.3.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.
Files changed (2) hide show
  1. package/README.md +76 -95
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,121 +1,102 @@
1
- Vue 3 Tree Select Component
1
+ # Vue 3 Tree Select Component
2
+
3
+ [![npm](https://img.shields.io/npm/v/@night-owl-elite/vue-select.svg)](https://www.npmjs.com/package/@night-owl-elite/vue-select)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
2
6
  A feature-rich, accessible, and customizable tree-select component for Vue 3.
3
7
 
4
8
  This component provides a powerful and flexible way to select single or multiple items from a hierarchical (tree) data structure. It includes searching, custom item rendering, "select all" functionality, and is styled with Bootstrap 5 and uses Font Awesome for icons.
5
9
 
6
- Features
7
- ✅ Single & Multiple Selection: Easily switch between modes with the multiple prop.
10
+ ---
11
+
12
+ ### Features
13
+
14
+ ✅ **Single & Multiple Selection**: Easily switch between modes with the `multiple` prop.
15
+
16
+ ✅ **Two Selection UIs**: Choose between `checkbox` or `highlight` styles for selection.
17
+
18
+ ✅ **Search & Filtering**: A built-in search bar to filter tree nodes in real-time.
8
19
 
9
- Two Selection UIs: Choose between checkbox or highlight styles.
20
+ **"Select All" Children**: In `multiple` mode, click a parent to select/deselect all its descendants.
10
21
 
11
- Search & Filtering: A built-in search bar to filter tree nodes in real-time.
22
+ **Customizable Data Keys**: Specify which properties in your data objects to use for labels, values, and disabled states.
12
23
 
13
- "Select All" Children: In multiple mode, click a parent to select/deselect all its descendants.
24
+ **Customizable Items**: Use scoped slots to take full control over how each tree item is rendered.
14
25
 
15
- Customizable Data Keys: Specify which properties in your data objects to use for labels, values, and disabled states.
26
+ **Built with Bootstrap 5**: Seamlessly integrates with projects using the Bootstrap 5 framework.
16
27
 
17
- ✅ Customizable Items: Use scoped slots to take full control over how each tree item is rendered.
28
+ ---
18
29
 
19
- Built with Bootstrap 5: Seamlessly integrates with projects using the Bootstrap 5 framework.
30
+ ### Installation
20
31
 
32
+ 1. **Install the package from npm:**
33
+ ```bash
34
+ npm install @night-owl-elite/vue-select
35
+ ```
21
36
 
22
- Installation
23
- - First, install the package from npm:
24
- npm install @night-owl-elite/vue-select
25
- - Install Peer Dependencies
26
- npm install bootstrap @popperjs/core
37
+ 2. **Install Peer Dependencies:**
38
+ This component relies on Bootstrap for styling and dropdown functionality.
39
+ ```bash
40
+ npm install bootstrap @popperjs/core
41
+ ```
27
42
 
28
- Usage Example
43
+ 3. **Import CSS & JS:**
44
+ Make sure to import Bootstrap's CSS and JS in your main entry file (e.g., `main.js` or `main.ts`):
45
+ ```javascript
46
+ // main.js or main.ts
47
+ import 'bootstrap/dist/css/bootstrap.min.css';
48
+ import 'bootstrap/dist/js/bootstrap.bundle.min.js';
49
+ ```
50
+
51
+ ---
52
+
53
+ ### Usage
54
+
55
+ Here is a basic example of how to use the `TreeSelect` component.
56
+
57
+ ```vue
58
+ <template>
59
+ <div class="container mt-5">
60
+ <TreeSelect
61
+ v-model="selectedValue"
62
+ :items="treeData"
63
+ :multiple="true"
64
+ :select-all="true"
65
+ :searchable="true"
66
+ placeholder="Select categories..."
67
+ option-label="value"
68
+ option-value="code"
69
+ disabled-key="isDisabled"
70
+ exclude-from-selected-list-key="excludeFromSelectedList"
71
+ />
72
+ <p class="mt-3"><strong>Selected:</strong> {{ selectedValue }}</p>
73
+ </div>
74
+ </template>
29
75
 
30
76
  <script setup>
31
77
  import { ref } from 'vue';
32
- import {VSelect} from '@night-owl-elite/vue-select';
33
-
34
- const selectedItem = ref(null);
78
+ import TreeSelect from '@night-owl-elite/vue-select';
35
79
 
36
- // For multiple selection
37
- const selectedItems = ref(['APPLE']); // Pre-select an item
80
+ const selectedValue = ref([]);
38
81
 
39
- const treeData = ref([
82
+ const treeData = [
40
83
  {
41
- code: 'FRUIT',
42
- value: 'Fruits',
43
- // Parent nodes can be excluded from the final v-model value
44
- excludeFromList: true,
84
+ code: 'electronics',
85
+ value: 'Electronics',
86
+ // This node won't be added to the modelValue, useful for grouping
87
+ excludeFromSelectedList: true,
45
88
  children: [
46
- { code: 'APPLE', value: 'Apple', icon: 'apple-alt' }, // Custom icon example
47
- { code: 'ORANGE', value: 'Orange' },
48
- {
49
- code: 'BERRY',
50
- value: 'Berries',
51
- excludeFromList: true,
52
- children: [
53
- { code: 'STRAWBERRY', value: 'Strawberry' },
54
- { code: 'RASPBERRY', value: 'Raspberry', isDisabled: true }, // Disabled item
55
- ]
56
- },
89
+ { code: 'smartphones', value: 'Smartphones' },
90
+ { code: 'laptops', value: 'Laptops' },
57
91
  ],
58
92
  },
59
93
  {
60
- code: 'VEG',
61
- value: 'Vegetables',
94
+ code: 'furniture',
95
+ value: 'Furniture',
62
96
  children: [
63
- { code: 'CARROT', value: 'Carrot' },
64
- { code: 'BROCCOLI', value: 'Broccoli' },
97
+ { code: 'tables', value: 'Tables' },
98
+ { code: 'chairs', value: 'Chairs', isDisabled: true },
65
99
  ],
66
100
  },
67
- ]);
68
- </script>
69
-
70
- <template>
71
- <div class="container py-5">
72
- <div class="row justify-content-center">
73
- <div class="col-md-6">
74
- <h3>Multiple Selection with Checkboxes</h3>
75
- <VSelect
76
- v-model="selectedItems"
77
- :items="treeData"
78
- :multiple="true"
79
- :select-all="true"
80
- select-mode="checkbox"
81
- placeholder="Select multiple items..."
82
- disabled-key="isDisabled"
83
- exclude-from-selected-list-key="excludeFromList"
84
- />
85
- <pre class="mt-2 bg-light p-2 rounded">v-model: {{ selectedItems }}</pre>
86
-
87
- <h3 class="mt-5">Single Selection with Highlight</h3>
88
- <VSelect
89
- v-model="selectedItem"
90
- :items="treeData"
91
- :multiple="false"
92
- select-mode="highlight"
93
- placeholder="Select a single item..."
94
- />
95
- <pre class="mt-2 bg-light p-2 rounded">v-model: {{ selectedItem }}</pre>
96
- </div>
97
- </div>
98
- </div>
99
- </template>
100
-
101
-
102
- API Reference
103
- Prop Type Default Description
104
- modelValue [String, Number, Array] null The selected value(s). Use v-model to bind.
105
- items Array [] The array of hierarchical data to display. Each item is an object.
106
- multiple Boolean false If true, allows multiple items to be selected.
107
- selectMode String 'checkbox' The UI style for selection. Can be 'checkbox' or 'highlight'.
108
- placeholder String 'Select item...' The text displayed when no items are selected.
109
- isInvalid Boolean false If true, applies a red border for validation feedback.
110
- disabled Boolean false If true, disables the entire component.
111
- searchable Boolean true If true, shows a search input in the dropdown.
112
- isLoading Boolean false If true, shows a loading spinner and disables the component.
113
- showClearButton Boolean true If true, shows a button to clear the current selection.
114
- selectAll Boolean false When multiple is true, enables selecting a parent to automatically select all its enabled children.
115
- optionLabel String 'value' The key in your item objects that holds the display text.
116
- optionValue String 'code' The key in your item objects that holds the unique value for v-model.
117
- disabledKey String null The key in your item objects that, if present and not null, disables that item.
118
- excludeFromSelectedListKey String null If an item object has this key set to true, its value won't be included in the final emitted modelValue. Useful for parent group labels.
119
-
120
-
121
-
101
+ ];
102
+ </script>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@night-owl-elite/vue-select",
3
3
  "private": false,
4
- "version": "1.3.1",
4
+ "version": "1.3.2",
5
5
  "type": "module",
6
6
  "main": "./dist/vue-select.umd.js",
7
7
  "module": "./dist/vue-select.es.js",