selectic 3.0.21 → 3.1.0

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 (43) hide show
  1. package/dist/selectic.common.js +545 -67
  2. package/dist/selectic.esm.js +546 -69
  3. package/doc/changeIcons.md +118 -0
  4. package/doc/changeText.md +1 -1
  5. package/doc/domProperties.md +57 -19
  6. package/doc/extendedProperties.md +83 -72
  7. package/doc/main.md +2 -0
  8. package/doc/params.md +177 -112
  9. package/doc/properties.md +42 -0
  10. package/package.json +4 -4
  11. package/src/ExtendedList.tsx +53 -6
  12. package/src/Filter.tsx +11 -9
  13. package/src/Icon.tsx +199 -0
  14. package/src/List.tsx +12 -6
  15. package/src/MainInput.tsx +15 -11
  16. package/src/Store.tsx +290 -123
  17. package/src/css/selectic.css +24 -0
  18. package/src/icons/caret-down.tsx +21 -0
  19. package/src/icons/caret-up.tsx +21 -0
  20. package/src/icons/check.tsx +23 -0
  21. package/src/icons/question.tsx +21 -0
  22. package/src/icons/search.tsx +21 -0
  23. package/src/icons/spinner.tsx +21 -0
  24. package/src/icons/strikeThrough.tsx +21 -0
  25. package/src/icons/times.tsx +21 -0
  26. package/src/index.tsx +78 -37
  27. package/test/Store/Store_computed.spec.js +84 -0
  28. package/test/Store/changeIcons.spec.js +154 -0
  29. package/test/Store/selectGroup.spec.js +389 -0
  30. package/test/Store/selectItem.spec.js +100 -46
  31. package/test/helper.js +38 -34
  32. package/types/ExtendedList.d.ts +7 -2
  33. package/types/Icon.d.ts +25 -0
  34. package/types/Store.d.ts +142 -5
  35. package/types/icons/caret-down.d.ts +6 -0
  36. package/types/icons/caret-up.d.ts +6 -0
  37. package/types/icons/check.d.ts +6 -0
  38. package/types/icons/question.d.ts +6 -0
  39. package/types/icons/search.d.ts +6 -0
  40. package/types/icons/spinner.d.ts +6 -0
  41. package/types/icons/strikeThrough.d.ts +6 -0
  42. package/types/icons/times.d.ts +6 -0
  43. package/types/index.d.ts +74 -1
@@ -0,0 +1,118 @@
1
+ # Change icons
2
+
3
+ [Back to documentation index](main.md)
4
+
5
+ There are some icons in selectic. But sometimes it is useful to change them (because you want to use yours or the same of your favorite theme).
6
+
7
+ There are 3 ways to changes these icons:
8
+ * Call the static `changeIcons()` method. It changes icons for all selectic components.
9
+ * Change the `icons` property. It changes icons only for the component.
10
+ * Change the `iconFamily` property. It changes the icons origin only for the component.
11
+ * Call the `changeIcons()` method on the component. It changes icons only for the component.
12
+
13
+ _Changes made locally take precedence over changes made globally_.
14
+
15
+ Changing `icons` or `iconFamily` on the component with property or with `changeIcons()` are equivalent.
16
+
17
+ `icons` and the first argument of `changeIcons` accept the same kind of value: an object which contains icon keys and how to display them.
18
+
19
+ It is possible to replace only some icons.
20
+
21
+ `iconFamily` and the second argument of `changeIcons` accept a string describing how to display icons.
22
+
23
+ ## Icon family
24
+
25
+ * **selectic** _(default)_: use the internal icons
26
+
27
+ * **raw**: will create a span with the icon key as class (without any other prefix)
28
+
29
+ * **font-awesome-4**: will create a span with font-awesome (v4) class.
30
+ _Font-awesome is not include in Selectic, your project should have it_.
31
+
32
+ * **font-awesome-5**: will create a span with font-awesome (v5) class.
33
+ _Font-awesome is not include in Selectic, your project should have it_.
34
+
35
+ * **font-awesome-6**: will create a span with font-awesome (v6) class.
36
+ _Font-awesome is not include in Selectic, your project should have it_.
37
+
38
+ * **prefix:_[string]_**: will create a span and will add the given string as class before the icon key.
39
+
40
+ Example:
41
+ ```html
42
+ <Selectic iconFamily="prefix:my-icon-" />
43
+ ```
44
+ The icon `search` will be displayed like this:
45
+ ```html
46
+ <span class="my-icon-search"></span>
47
+ ```
48
+
49
+ ## Icon Keys
50
+
51
+ * **caret-down**: indicates that menu or panel could be extended down.
52
+ * **caret-up**: indicates that panel could be collapsed upward.
53
+ * **check**: indicates that the item is currently selected.
54
+ * **search**: indicates the search bar.
55
+ * **spinner**: indicates that we are fetching data.
56
+ * **strikethrough**: indicates that we are in reverse selection mode.
57
+ * **times**: used to clear the current selection.
58
+ * **question**: used when the icon key is not found. _It should be never displayed._
59
+
60
+ * **spin**: additional class added to rotate the current icon (used mainly with spinner).
61
+
62
+ The value indicates what should be used instead of the icon key.
63
+
64
+ It is possible to use `selectic:` prefix to display the original selectic icon, even if the icon family is configured differently.
65
+
66
+ It is possible to use `raw:` prefix to display an icon with a span and only the given class (with no prefix).
67
+
68
+ In some case, the prefix `current:` could be used to use the current icon family.
69
+
70
+
71
+ With `selectic:`, `raw:`, or `current:` prefix, it is also possible to add a `:spin` suffix in order to add the _spin_ on the icon.
72
+
73
+ Example:
74
+ ```javascript
75
+ {
76
+ spinner: 'selectic:spinner:spin', // it will use the Selectic's spinner icon with the spin effect
77
+ search: 'current:cogs:spin', // it will use "cogs" as key in the current icon family, and will adds the spin effect
78
+ }
79
+ ```
80
+
81
+ ## Example
82
+
83
+ ```javascript
84
+ // change icons for all selectic components
85
+ Selectic.changeIcons({
86
+ times: 'trash',
87
+ spinner: 'selectic:spinner',
88
+ }, 'font-awesome-6');
89
+
90
+ /* The icon 'times' will be displayed:
91
+ * <span class="fa-solid fa-trash"></span>
92
+ *
93
+ * The icon 'spinner' will use the selectic's spinner icon.
94
+ */
95
+
96
+ // change texts only for this instance
97
+ this.$refs.selectic.changeIcons({
98
+ 'caret-up': 'caret-down',
99
+ });
100
+ /* For this selectic instance,
101
+ * the caret-down icon will be displayed when it should be the caret-up.
102
+ * (caret-down will still be used for caret-down)
103
+ */
104
+
105
+ ```
106
+
107
+ ```html
108
+ <Selectic
109
+ :icons="{
110
+ check: 'thumbs-o-up',
111
+ }"
112
+ iconFamily="font-awesome-4"
113
+ />
114
+
115
+ /* For this selectic instance, the selected icon will be displayed:
116
+ * <span class="fa fa-thumbs-o-up"></span>
117
+ */
118
+ ```
package/doc/changeText.md CHANGED
@@ -9,7 +9,7 @@ There are 3 ways to changes these texts:
9
9
  * Change the `texts` property. It changes texts only for the component.
10
10
  * Call the `changeTexts()` method on the component. It changes texts only for the component.
11
11
 
12
- _Changes done locally are prioritary on changes done globally_.
12
+ _Changes made locally take precedence over changes made globally._.
13
13
 
14
14
  Changing texts on the component with property or with `changeTexts()` are equivalent.
15
15
 
@@ -2,50 +2,79 @@
2
2
 
3
3
  [Back to documentation index](main.md)
4
4
 
5
+ [List of all properties](properties.md)
6
+
5
7
  `<select>` has several properties which can be used in the same way in `selectic`.
6
8
 
7
- ## id
9
+ * [className](domProperties.md#classname) (instead of `class` in order to be
10
+ applied on main element and on the list element)
11
+ * [disabled](domProperties.md#disabled)
12
+ * [id](domProperties.md#id)
13
+ * [multiple](domProperties.md#multiple)
14
+ * [placeholder](domProperties.md#placeholder)
15
+ * [title](domProperties.md#title)
16
+ * [value](domProperties.md#value)
8
17
 
9
- It defines a unique identifier (ID) which must be unique in the whole document. It is applied on an `<input>` element which contains the current state.
18
+ [Not supported attributes](domProperties.md#not-supported-attributes)
19
+
20
+ ## className
21
+
22
+ Type: `string`
23
+
24
+ Default: `''`
25
+
26
+ The given string will be applied as class to the main element and also to the list element.
27
+ It can be used instead of class for when it is not possible to use the reserved keyword.
28
+ Note that it will be applied to the inner list element too.
10
29
 
11
30
  ```html
12
31
  <selectic
13
32
  :options="['item1', 'item2']"
14
33
  value="item2"
15
- id="example"
34
+ className="my-custom-class another-class"
16
35
  />
17
36
  ```
18
- ```javascript
19
- document.getElementById('example').value; // 'item2'
20
- ```
21
37
 
38
+ ## disabled
22
39
 
23
- ## value
40
+ Type: `boolean`
24
41
 
25
- The selected value. This is the initial value, and it can be altered to change the current selection.
42
+ Default: `false`
26
43
 
27
- This is the id of the selected option or an array of id (if `multiple` is set).
44
+ When disabled is set, `selectic` cannot be open nor changed.
28
45
 
29
46
  ```html
30
47
  <selectic
31
48
  :options="['item1', 'item2']"
32
- value="item2"
49
+ disabled
33
50
  />
34
51
  ```
35
52
 
36
- ## disabled
53
+ ## id
37
54
 
38
- When disabled is set, `selectic` cannot be open nor changed.
55
+ Type: `string`
56
+
57
+ Default: `''`
58
+
59
+ It defines a unique identifier (ID) which must be unique in the whole document. It is applied on an `<input>` element which contains the current state.
39
60
 
40
61
  ```html
41
62
  <selectic
42
63
  :options="['item1', 'item2']"
43
- disabled
64
+ value="item2"
65
+ id="example"
44
66
  />
45
67
  ```
68
+ ```javascript
69
+ document.getElementById('example').value; // 'item2'
70
+ ```
46
71
 
47
72
  ## multiple
48
73
 
74
+ Type: `boolean`
75
+
76
+ Default: `false`
77
+
49
78
  If set then several options can be selected.
50
79
 
51
80
  The `value` will be an array.
@@ -59,6 +88,10 @@ The `value` will be an array.
59
88
 
60
89
  ## placeholder
61
90
 
91
+ Type: `string`
92
+
93
+ Default: `''`
94
+
62
95
  `placeholder` is not really a DOM attribute as it doesn't exist on `<select>` element. But it behaves like placeholder on `<input>`.
63
96
 
64
97
  It displays the given text if no option is selected.
@@ -72,6 +105,10 @@ It displays the given text if no option is selected.
72
105
 
73
106
  ## title
74
107
 
108
+ Type: `string`
109
+
110
+ Default: `''`
111
+
75
112
  It is added to the main element, and it behaves like `title` attribute of any HTML element when mouse is over the selected area.
76
113
 
77
114
  ```html
@@ -81,19 +118,20 @@ It is added to the main element, and it behaves like `title` attribute of any HT
81
118
  />
82
119
  ```
83
120
 
84
- ## className
121
+ ## value
85
122
 
86
- Type: `string`
123
+ Type: `optionId` or `optionId[]`
87
124
 
88
- The given string will be applied as class to the main element and also to the list element.
89
- It can be used instead of class for when it is not possible to use the reserved keyword.
90
- Note that it will be applied to the inner list element too.
125
+ Default: `null` or `[]`
126
+
127
+ The selected value. This is the initial value, and it can be altered to change the current selection.
128
+
129
+ This is the id of the selected option or an array of id (if `multiple` is set).
91
130
 
92
131
  ```html
93
132
  <selectic
94
133
  :options="['item1', 'item2']"
95
134
  value="item2"
96
- className="my-custom-class another-class"
97
135
  />
98
136
  ```
99
137
 
@@ -2,56 +2,35 @@
2
2
 
3
3
  [Back to documentation index](main.md)
4
4
 
5
- Selectic supports common properties which are related to `<select>` element ([read dom properties document](domProperties.md)), but they are some more which are more related to the nature of selectic.
6
-
7
- ## value
8
-
9
- Type: `optionId` or `optionId[]`
10
-
11
- Default: `null` or `[]`
12
-
13
- The selected value. This is the initial value, and it can be altered to change the current selection.
14
-
15
- This is the id of the selected option or an array of id (if `multiple` is set).
16
-
17
- ```html
18
- <selectic
19
- :options="['item1', 'item2']"
20
- value="item2"
21
- />
22
- ```
23
-
24
- ## selectionIsExcluded
25
-
26
- Type: `boolean`
27
-
28
- Default: `false`
29
-
30
- It should be only used in _multiple_ mode.
31
-
32
- If it is set to `true`, it means that current `value` are options which are **not** selected.
33
-
34
- It is useful with _dynamic_ mode where it is not possible to fetch all options.
35
-
36
- This value can be changed automatically by selectic if all options are fetched.
5
+ [List of all properties](properties.md)
37
6
 
38
- ```html
39
- <selectic
40
- :options="['item1', 'item2']"
41
- value="item2"
42
- selectionIsExcluded
43
- />
44
- ```
45
-
46
- ## options
47
-
48
- Type: `Option[]`
49
-
50
- Default: `[]`
7
+ Selectic supports common properties which are related to `<select>` element ([read dom properties document](domProperties.md)), but they are some more which are more related to the nature of selectic.
51
8
 
52
- This property is to list all options available ([read how to build a list](list.md)).
9
+ * [groups](extendedProperties.md#groups)
10
+ * [noCache](extendedProperties.md#nocache)
11
+ * [open](extendedProperties.md#open)
12
+ * [options](extendedProperties.md#options)
13
+ * [selectionIsExcluded](extendedProperties.md#selectionisexcluded)
14
+ * [texts](extendedProperties.md#texts)
15
+ * [params](extendedProperties.md#params)
16
+ * [allowClearSelection](params.md#allowclearselection)
17
+ * [allowRevert](params.md#allowrevert)
18
+ * [autoDisabled](params.md#autodisabled)
19
+ * [autoSelect](params.md#autoselect)
20
+ * [emptyValue](params.md#emptyvalue)
21
+ * [fetchCallback](params.md#fetchcallback)
22
+ * [forceSelectAll](params.md#forceselectall)
23
+ * [formatOption](params.md#formatoption)
24
+ * [formatSelection](params.md#formatselection)
25
+ * [getItemsCallback](params.md#getitemscallback)
26
+ * [hideFilter](params.md#hidefilter)
27
+ * [keepOpenWithOtherSelectic](params.md#keepopenwithotherselectic)
28
+ * [listPosition](params.md#listposition)
29
+ * [optionBehavior](params.md#optionbehavior)
30
+ * [pageSize](params.md#pagesize)
31
+ * [selectionOverflow](params.md#selectionoverflow)
32
+ * [strictValue](params.md#strictvalue)
53
33
 
54
- This property can be omitted in dynamic mode ([read how to build dynamic list](dynamic.md)).
55
34
 
56
35
  ## groups
57
36
 
@@ -75,31 +54,6 @@ It is required to fill this property only in _dynamic_ mode in order to know to
75
54
  />
76
55
  ```
77
56
 
78
- ## texts
79
-
80
- Type: `Object`
81
-
82
- Default: `{}`
83
-
84
- The `texts` property is to change texts in the component.
85
-
86
- It is possible to change all texts or only some.
87
-
88
- It changes the texts only for this component. To change texts for all selectic components, you should use the static method `changeTexts()`.
89
-
90
- [Read the documentation about changing text](changeText.md).
91
-
92
- ```html
93
- <selectic
94
- :options="['Goldfish', 'Salmon', 'Trout', 'Tuna']"
95
- value="Tuna"
96
- :texts="{
97
- searchPlaceholder: 'Search for fish',
98
- noResult: 'No fish matched your search',
99
- }"
100
- />
101
- ```
102
-
103
57
  ## noCache
104
58
 
105
59
  Type: `Boolean`
@@ -146,6 +100,63 @@ It is also possible to change the "open" state with the method [toggleOpen](meth
146
100
  />
147
101
  ```
148
102
 
103
+ ## options
104
+
105
+ Type: `Option[]`
106
+
107
+ Default: `[]`
108
+
109
+ This property is to list all options available ([read how to build a list](list.md)).
110
+
111
+ This property can be omitted in dynamic mode ([read how to build dynamic list](dynamic.md)).
112
+
113
+ ## selectionIsExcluded
114
+
115
+ Type: `boolean`
116
+
117
+ Default: `false`
118
+
119
+ It should be only used in _multiple_ mode.
120
+
121
+ If it is set to `true`, it means that current `value` are options which are **not** selected.
122
+
123
+ It is useful with _dynamic_ mode where it is not possible to fetch all options.
124
+
125
+ This value can be changed automatically by selectic if all options are fetched.
126
+
127
+ ```html
128
+ <selectic
129
+ :options="['item1', 'item2']"
130
+ value="item2"
131
+ selectionIsExcluded
132
+ />
133
+ ```
134
+
135
+ ## texts
136
+
137
+ Type: `Object`
138
+
139
+ Default: `{}`
140
+
141
+ The `texts` property is to change texts in the component.
142
+
143
+ It is possible to change all texts or only some.
144
+
145
+ It changes the texts only for this component. To change texts for all selectic components, you should use the static method `changeTexts()`.
146
+
147
+ [Read the documentation about changing text](changeText.md).
148
+
149
+ ```html
150
+ <selectic
151
+ :options="['Goldfish', 'Salmon', 'Trout', 'Tuna']"
152
+ value="Tuna"
153
+ :texts="{
154
+ searchPlaceholder: 'Search for fish',
155
+ noResult: 'No fish matched your search',
156
+ }"
157
+ />
158
+ ```
159
+
149
160
  ## params
150
161
 
151
162
  Type: `Object`
package/doc/main.md CHANGED
@@ -3,6 +3,7 @@
3
3
  ## Configuration
4
4
 
5
5
  * Build a select from a list [(details)](./list.md)
6
+ * List all supported properties [(details)](./properties.md)
6
7
  * Support DOM attributes [(details)](./domProperties.md)
7
8
  * value
8
9
  * disabled
@@ -14,6 +15,7 @@
14
15
  * optgroup
15
16
  * Advanced configuration [(details)](./params.md)
16
17
  * Change texts [(details)](./changeText.md)
18
+ * Change icons [(details)](./changeIcons.md)
17
19
  * Change CSS style [(details)](./css.md)
18
20
 
19
21
  ## Events