jsuites 5.0.15 → 5.0.17
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.
- package/dist/jsuites.js +25 -5
- package/dist/types/calendar.d.ts +3 -1
- package/dist/types/dropdown.d.ts +67 -63
- package/dist/types/validations.d.ts +20 -11
- package/package.json +1 -1
package/dist/jsuites.js
CHANGED
|
@@ -5998,6 +5998,8 @@ function Dropdown() {
|
|
|
5998
5998
|
onblur: null,
|
|
5999
5999
|
oninsert: null,
|
|
6000
6000
|
onbeforeinsert: null,
|
|
6001
|
+
onsearch: null,
|
|
6002
|
+
onbeforesearch: null,
|
|
6001
6003
|
sortResults: false,
|
|
6002
6004
|
autofocus: false,
|
|
6003
6005
|
}
|
|
@@ -6808,11 +6810,13 @@ function Dropdown() {
|
|
|
6808
6810
|
// Reset results
|
|
6809
6811
|
obj.results = null;
|
|
6810
6812
|
// URL
|
|
6811
|
-
var url = obj.options.url
|
|
6812
|
-
|
|
6813
|
-
|
|
6813
|
+
var url = obj.options.url;
|
|
6814
|
+
|
|
6815
|
+
// Ajax call
|
|
6816
|
+
let o = {
|
|
6814
6817
|
url: url,
|
|
6815
6818
|
method: 'GET',
|
|
6819
|
+
data: { q: str },
|
|
6816
6820
|
dataType: 'json',
|
|
6817
6821
|
success: function (result) {
|
|
6818
6822
|
// Reset items
|
|
@@ -6839,8 +6843,24 @@ function Dropdown() {
|
|
|
6839
6843
|
} else {
|
|
6840
6844
|
content.style.display = '';
|
|
6841
6845
|
}
|
|
6846
|
+
|
|
6847
|
+
if (typeof(obj.options.onsearch) === 'function') {
|
|
6848
|
+
obj.options.onsearch(obj, result);
|
|
6849
|
+
}
|
|
6842
6850
|
}
|
|
6843
|
-
}
|
|
6851
|
+
}
|
|
6852
|
+
|
|
6853
|
+
if (typeof(obj.options.onbeforesearch) === 'function') {
|
|
6854
|
+
let ret = obj.options.onbeforesearch(obj, o);
|
|
6855
|
+
if (ret === false) {
|
|
6856
|
+
return;
|
|
6857
|
+
} else if (typeof(ret) === 'object') {
|
|
6858
|
+
o = ret;
|
|
6859
|
+
}
|
|
6860
|
+
}
|
|
6861
|
+
|
|
6862
|
+
// Remote search
|
|
6863
|
+
ajax(o);
|
|
6844
6864
|
} else {
|
|
6845
6865
|
// Search terms
|
|
6846
6866
|
str = new RegExp(str, 'gi');
|
|
@@ -12529,7 +12549,7 @@ var sha512_default = /*#__PURE__*/__webpack_require__.n(sha512);
|
|
|
12529
12549
|
|
|
12530
12550
|
var jSuites = {
|
|
12531
12551
|
/** Current version */
|
|
12532
|
-
version: '5.0.
|
|
12552
|
+
version: '5.0.17',
|
|
12533
12553
|
/** Bind new extensions to Jsuites */
|
|
12534
12554
|
setExtensions: function(o) {
|
|
12535
12555
|
if (typeof(o) == 'object') {
|
package/dist/types/calendar.d.ts
CHANGED
package/dist/types/dropdown.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface
|
|
1
|
+
interface DropdownItem {
|
|
2
2
|
/** Value of the selected item. */
|
|
3
3
|
id?: string | number;
|
|
4
4
|
/** Label for the selected item. */
|
|
@@ -17,62 +17,66 @@ interface Item {
|
|
|
17
17
|
color?: string;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
interface
|
|
21
|
-
/**
|
|
22
|
-
url
|
|
23
|
-
/**
|
|
24
|
-
data
|
|
25
|
-
/**
|
|
26
|
-
format
|
|
27
|
-
/**
|
|
28
|
-
multiple
|
|
29
|
-
/**
|
|
30
|
-
autocomplete
|
|
31
|
-
/**
|
|
32
|
-
remoteSearch
|
|
33
|
-
/**
|
|
34
|
-
lazyLoading
|
|
35
|
-
/**
|
|
36
|
-
type
|
|
37
|
-
/**
|
|
38
|
-
width
|
|
39
|
-
/**
|
|
40
|
-
maxWidth
|
|
41
|
-
/**
|
|
42
|
-
opened
|
|
43
|
-
/**
|
|
44
|
-
value
|
|
45
|
-
/**
|
|
46
|
-
placeholder
|
|
47
|
-
/**
|
|
48
|
-
newOptions
|
|
49
|
-
/** Internal position
|
|
50
|
-
position
|
|
51
|
-
/**
|
|
52
|
-
onchange:
|
|
53
|
-
/**
|
|
54
|
-
onload:
|
|
55
|
-
/**
|
|
56
|
-
onopen:
|
|
57
|
-
/**
|
|
58
|
-
onclose:
|
|
59
|
-
/**
|
|
60
|
-
onfocus:
|
|
61
|
-
/**
|
|
62
|
-
onblur:
|
|
63
|
-
/**
|
|
64
|
-
oninsert:
|
|
65
|
-
/**
|
|
66
|
-
onbeforeinsert:
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
|
|
20
|
+
interface DropdownOptions {
|
|
21
|
+
/** Endpoint to fetch data from a remote server */
|
|
22
|
+
url?: string;
|
|
23
|
+
/** Preloaded data items for the dropdown */
|
|
24
|
+
data?: DropdownItem[];
|
|
25
|
+
/** Format type of the data, typically { id: name } or { value: text } */
|
|
26
|
+
format?: number;
|
|
27
|
+
/** Indicates if multiple item selection is allowed */
|
|
28
|
+
multiple?: boolean;
|
|
29
|
+
/** Enables the autocomplete feature for user input */
|
|
30
|
+
autocomplete?: boolean;
|
|
31
|
+
/** Allows remote search for options */
|
|
32
|
+
remoteSearch?: boolean;
|
|
33
|
+
/** Enables the lazy loading feature for handling a large number of options */
|
|
34
|
+
lazyLoading?: boolean;
|
|
35
|
+
/** Rendering style of the dropdown: 'default', 'picker', or 'searchbar' */
|
|
36
|
+
type?: 'default' | 'picker' | 'searchbar',
|
|
37
|
+
/** Defines the dropdown's width */
|
|
38
|
+
width?: number;
|
|
39
|
+
/** Sets the maximum width of the dropdown */
|
|
40
|
+
maxWidth?: number;
|
|
41
|
+
/** Determines if the dropdown is opened when initialized */
|
|
42
|
+
opened?: boolean;
|
|
43
|
+
/** The initial value of the dropdown */
|
|
44
|
+
value?: string;
|
|
45
|
+
/** Placeholder text for the dropdown */
|
|
46
|
+
placeholder?: string;
|
|
47
|
+
/** Allows the user to add new options */
|
|
48
|
+
newOptions?: boolean;
|
|
49
|
+
/** Internal controller for the dropdown's position */
|
|
50
|
+
position?: boolean;
|
|
51
|
+
/** Event handler for value changes */
|
|
52
|
+
onchange?: (el: HTMLElement, obj: Dropdown, oldValue: string, newValue: string) => void;
|
|
53
|
+
/** Event handler for when the dropdown is ready */
|
|
54
|
+
onload?: (el: HTMLElement, obj: Dropdown, data: any, val: any) => void;
|
|
55
|
+
/** Event handler for when the dropdown opens */
|
|
56
|
+
onopen?: (el: HTMLElement) => void;
|
|
57
|
+
/** Event handler for when the dropdown closes */
|
|
58
|
+
onclose?: (el: HTMLElement) => void;
|
|
59
|
+
/** Event handler for when the dropdown receives focus */
|
|
60
|
+
onfocus?: (el: HTMLElement) => void;
|
|
61
|
+
/** Event handler for when the dropdown loses focus */
|
|
62
|
+
onblur?: (el: HTMLElement) => void;
|
|
63
|
+
/** Event handler for when a new option is added to the dropdown */
|
|
64
|
+
oninsert?: (obj: Dropdown, item: DropdownItem, newItem: DropdownItem) => void;
|
|
65
|
+
/** Event handler for just before a new option is added to the dropdown */
|
|
66
|
+
onbeforeinsert?: (obj: Dropdown, item: DropdownItem) => void;
|
|
67
|
+
/** Event handler for before a search on autocomplete is performed */
|
|
68
|
+
onbeforesearch?: (obj: Dropdown, ajaxRequest: object) => boolean | null;
|
|
69
|
+
/** Event handler for processing search results */
|
|
70
|
+
onsearch?: (obj: Dropdown, result: object) => void;
|
|
71
|
+
/** Toggles the sorting of dropdown elements */
|
|
72
|
+
sortResults?: boolean;
|
|
73
|
+
/** Indicates if the dropdown should automatically receive focus upon creation */
|
|
74
|
+
autofocus?: boolean;
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
interface ItemContainer {
|
|
74
78
|
/** Data for the item */
|
|
75
|
-
data:
|
|
79
|
+
data: DropdownItem;
|
|
76
80
|
/** HTML container for the element */
|
|
77
81
|
element: HTMLElement;
|
|
78
82
|
/** HTML container for the group */
|
|
@@ -80,11 +84,11 @@ interface ItemContainer {
|
|
|
80
84
|
}
|
|
81
85
|
|
|
82
86
|
/** Toast Plugin */
|
|
83
|
-
export type Dropdown = (el: HTMLElement, options:
|
|
87
|
+
export type Dropdown = (el: HTMLElement, options: DropdownOptions) => {
|
|
84
88
|
/** Add a new item to the dropdown */
|
|
85
|
-
add: (title: string, id: string|number) =>
|
|
89
|
+
add: (title: string, id: string|number) => DropdownItem;
|
|
86
90
|
/** Append new data to the dropdown */
|
|
87
|
-
appendData: (data:
|
|
91
|
+
appendData: (data: DropdownItem[]) => void
|
|
88
92
|
/** Close the dropdown picker */
|
|
89
93
|
closeItem: (ignoreEvents?: boolean) => void
|
|
90
94
|
/** Current selectIndex */
|
|
@@ -94,7 +98,7 @@ export type Dropdown = (el: HTMLElement, options: Options) => {
|
|
|
94
98
|
/** Select the first item */
|
|
95
99
|
first: () => void;
|
|
96
100
|
/** Get all data */
|
|
97
|
-
getData: () =>
|
|
101
|
+
getData: () => DropdownItem[];
|
|
98
102
|
/** Get the index position of a item by its value */
|
|
99
103
|
getPosition: (value: string) => number | boolean;
|
|
100
104
|
/** Get the text from the selected options */
|
|
@@ -124,7 +128,7 @@ export type Dropdown = (el: HTMLElement, options: Options) => {
|
|
|
124
128
|
/** Open the dropdown */
|
|
125
129
|
open: () => void;
|
|
126
130
|
/** Dropdown configuration */
|
|
127
|
-
options:
|
|
131
|
+
options: DropdownOptions;
|
|
128
132
|
/** Move index to the previous element in the dropdown */
|
|
129
133
|
prev: () => void;
|
|
130
134
|
/** Reset the value of the dropdown */
|
|
@@ -134,21 +138,21 @@ export type Dropdown = (el: HTMLElement, options: Options) => {
|
|
|
134
138
|
/** Set the value to null */
|
|
135
139
|
resetSelected: () => void;
|
|
136
140
|
/** Array of results when filtering */
|
|
137
|
-
results:
|
|
141
|
+
results: DropdownItem[];
|
|
138
142
|
/** Search term */
|
|
139
143
|
search: string;
|
|
140
144
|
/** Select an index */
|
|
141
145
|
selectIndex: (index: number, force?: boolean) => void
|
|
142
146
|
/** Select an item */
|
|
143
|
-
selectItem: (item:
|
|
147
|
+
selectItem: (item: DropdownItem) => void;
|
|
144
148
|
/** Set the cursor to a specified element index */
|
|
145
149
|
setCursor: (index: number, setPosition?: boolean) => void
|
|
146
150
|
/** Set new data for the dropdown */
|
|
147
|
-
setData: (items:
|
|
151
|
+
setData: (items: DropdownItem[]) => void;
|
|
148
152
|
/** Set the id or value for one item */
|
|
149
|
-
setId: (item: number|
|
|
153
|
+
setId: (item: number|DropdownItem, newId: number) => void;
|
|
150
154
|
/** Change the dropdown options */
|
|
151
|
-
setOptions: (newOptions:
|
|
155
|
+
setOptions: (newOptions: DropdownOptions, reset?: boolean) => void;
|
|
152
156
|
/** Change the dropdown data from a URL */
|
|
153
157
|
setUrl: (newUrl: string, callback?: Function) => void;
|
|
154
158
|
/** Set the value for a dropdown */
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
interface Options {
|
|
2
|
-
|
|
3
|
-
type: '
|
|
2
|
+
/** Validation type */
|
|
3
|
+
type: 'number' | 'text' | 'date' | 'list' | 'textLength' | 'empty' | 'notEmpty';
|
|
4
4
|
// Ignore the validation when is blank
|
|
5
5
|
allowBlank?: boolean;
|
|
6
|
-
|
|
7
|
-
criteria:
|
|
6
|
+
/** Criteria to be match */
|
|
7
|
+
criteria:
|
|
8
|
+
| '='
|
|
9
|
+
| '!='
|
|
10
|
+
| '>='
|
|
11
|
+
| '>'
|
|
12
|
+
| '<='
|
|
13
|
+
| '<'
|
|
14
|
+
| 'between'
|
|
15
|
+
| 'not between'
|
|
16
|
+
| 'valid date'
|
|
17
|
+
| 'valid email'
|
|
18
|
+
| 'valid url'
|
|
19
|
+
| 'contains'
|
|
20
|
+
| 'not contains'
|
|
21
|
+
| 'begins with'
|
|
22
|
+
| 'ends with'
|
|
8
23
|
}
|
|
9
24
|
|
|
10
|
-
|
|
11
|
-
criteria: 'between' | 'not between' | '<' | '<=' | '>' | '>=' | '=' | '!='
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type Validations = (value: string | number, options) => {
|
|
15
|
-
|
|
16
|
-
}
|
|
25
|
+
export type Validations = (value: string | number, options: Options) => boolean;
|
package/package.json
CHANGED