jsuites 5.1.1 → 5.1.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.
- package/dist/jsuites.css +2 -5
- package/dist/jsuites.js +2 -1
- package/jest.config.js +11 -0
- package/package.json +8 -3
- package/react/calendar/index.d.ts +105 -0
- package/react/calendar/index.js +29 -0
- package/react/color/index.d.ts +84 -0
- package/react/color/index.js +29 -0
- package/react/contextmenu/index.d.ts +61 -0
- package/react/contextmenu/index.js +25 -0
- package/react/dropdown/index.d.ts +184 -0
- package/react/dropdown/index.js +26 -0
- package/react/editor/index.d.ts +114 -0
- package/react/{calendar.js → editor/index.js} +5 -6
- package/react/index.d.ts +0 -0
- package/react/index.js +27 -0
- package/react/modal/index.d.ts +53 -0
- package/react/modal/index.js +31 -0
- package/react/picker/index.d.ts +64 -0
- package/react/picker/index.js +29 -0
- package/react/rating/index.d.ts +37 -0
- package/react/rating/index.js +29 -0
- package/react/slider/index.d.ts +49 -0
- package/react/slider/index.js +31 -0
- package/react/tabs/index.d.ts +97 -0
- package/react/tabs/index.js +30 -0
- package/react/tags/index.d.ts +121 -0
- package/react/tags/index.js +25 -0
- package/react/toolbar/index.d.ts +88 -0
- package/react/toolbar/index.js +25 -0
- package/vue/calendar/index.d.ts +105 -0
- package/vue/calendar/index.js +37 -0
- package/vue/color/index.d.ts +84 -0
- package/vue/color/index.js +37 -0
- package/vue/contextmenu/index.d.ts +61 -0
- package/vue/contextmenu/index.js +22 -0
- package/vue/dropdown/index.d.ts +184 -0
- package/vue/dropdown/index.js +26 -0
- package/vue/editor/index.d.ts +114 -0
- package/vue/editor/index.js +41 -0
- package/vue/index.d.ts +0 -0
- package/vue/index.js +41 -0
- package/vue/modal/index.d.ts +53 -0
- package/vue/modal/index.js +42 -0
- package/vue/picker/index.d.ts +64 -0
- package/vue/picker/index.js +37 -0
- package/vue/rating/index.d.ts +37 -0
- package/vue/rating/index.js +37 -0
- package/vue/slider/index.d.ts +49 -0
- package/vue/slider/index.js +34 -0
- package/vue/tabs/index.d.ts +97 -0
- package/vue/tabs/index.js +29 -0
- package/vue/tags/index.d.ts +121 -0
- package/vue/tags/index.js +22 -0
- package/vue/toolbar/index.d.ts +88 -0
- package/vue/toolbar/index.js +22 -0
- package/react/calendar.d.ts +0 -14
package/dist/jsuites.css
CHANGED
|
@@ -2087,6 +2087,7 @@ div[data-before]:before {
|
|
|
2087
2087
|
user-select: none;
|
|
2088
2088
|
outline: none;
|
|
2089
2089
|
position: relative;
|
|
2090
|
+
min-height: 26px;
|
|
2090
2091
|
}
|
|
2091
2092
|
|
|
2092
2093
|
.jpicker-header {
|
|
@@ -2098,12 +2099,8 @@ div[data-before]:before {
|
|
|
2098
2099
|
box-sizing: border-box;
|
|
2099
2100
|
text-align: left;
|
|
2100
2101
|
outline: none;
|
|
2101
|
-
|
|
2102
2102
|
line-height: 24px;
|
|
2103
|
-
padding: 2px;
|
|
2104
|
-
padding-left: 12px;
|
|
2105
|
-
padding-right: 35px;
|
|
2106
|
-
outline: none;
|
|
2103
|
+
padding: 2px 35px 2px 12px;
|
|
2107
2104
|
border-radius: 4px;
|
|
2108
2105
|
}
|
|
2109
2106
|
|
package/dist/jsuites.js
CHANGED
|
@@ -2500,6 +2500,7 @@ function Mask() {
|
|
|
2500
2500
|
d[0] = d[0].replace('*', '\t');
|
|
2501
2501
|
d[0] = d[0].replace(new RegExp(/_-/g), '');
|
|
2502
2502
|
d[0] = d[0].replace(new RegExp(/_/g), '');
|
|
2503
|
+
d[0] = d[0].replace(new RegExp(/"/g), '');
|
|
2503
2504
|
d[0] = d[0].replace('##0.###','##0.000');
|
|
2504
2505
|
d[0] = d[0].replace('##0.##','##0.00');
|
|
2505
2506
|
d[0] = d[0].replace('##0.#','##0.0');
|
|
@@ -12702,7 +12703,7 @@ var jSuites = {
|
|
|
12702
12703
|
...dictionary,
|
|
12703
12704
|
...helpers,
|
|
12704
12705
|
/** Current version */
|
|
12705
|
-
version: '5.1.
|
|
12706
|
+
version: '5.1.1',
|
|
12706
12707
|
/** Bind new extensions to Jsuites */
|
|
12707
12708
|
setExtensions: function(o) {
|
|
12708
12709
|
if (typeof(o) == 'object') {
|
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -20,26 +20,31 @@
|
|
|
20
20
|
],
|
|
21
21
|
"scripts": {
|
|
22
22
|
"test": "jest",
|
|
23
|
+
"test:watch": "jest --watchAll",
|
|
23
24
|
"build": "npx webpack --config webpack.config.js",
|
|
24
25
|
"start": "npx webpack serve --history-api-fallback"
|
|
25
26
|
},
|
|
26
27
|
"main": "dist/jsuites.js",
|
|
27
28
|
"types": "dist/jsuites.d.ts",
|
|
28
|
-
"version": "5.1.
|
|
29
|
+
"version": "5.1.2",
|
|
29
30
|
"bugs": "https://github.com/jsuites/jsuites/issues",
|
|
30
31
|
"homepage": "https://github.com/jsuites/jsuites",
|
|
31
32
|
"docs": "https://jsuites.net",
|
|
32
33
|
"download": "https://github.com/jsuites/jsuites/archive/master.zip",
|
|
33
34
|
"devDependencies": {
|
|
35
|
+
"@testing-library/dom": "^9.3.4",
|
|
34
36
|
"copy-webpack-plugin": "^11.0.0",
|
|
35
37
|
"css-loader": "^6.7.2",
|
|
36
38
|
"css-minimizer-webpack-plugin": "^3.4.1",
|
|
37
|
-
"jest": "^28.1.
|
|
39
|
+
"jest": "^28.1.3",
|
|
40
|
+
"jest-canvas-mock": "^2.5.2",
|
|
41
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
42
|
+
"jsdom": "^24.0.0",
|
|
38
43
|
"mini-css-extract-plugin": "^2.7.0",
|
|
39
44
|
"style-loader": "^3.3.1",
|
|
40
|
-
"url-loader": "^4.1.1",
|
|
41
45
|
"ts-loader": "^9.4.1",
|
|
42
46
|
"typescript": "^4.9.3",
|
|
47
|
+
"url-loader": "^4.1.1",
|
|
43
48
|
"webpack": "^5.88.2",
|
|
44
49
|
"webpack-cli": "^5.1.4",
|
|
45
50
|
"webpack-dev-server": "^4.15.1"
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Official Type definitions for LemonadeJS plugins
|
|
3
|
+
* https://lemonadejs.net
|
|
4
|
+
* Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
declare function Component(el: HTMLElement, options?: Component.Options): Component.Instance;
|
|
8
|
+
|
|
9
|
+
declare namespace Component {
|
|
10
|
+
interface Options {
|
|
11
|
+
// Render type: [ default | year-month-picker ]. Default: default
|
|
12
|
+
type?: 'default' | 'year-month-picker';
|
|
13
|
+
// Range restriction [dateStart, dateEnd]
|
|
14
|
+
validRange?: [string|null, string|null];
|
|
15
|
+
// Starting weekday - 0 for sunday, 6 for saturday
|
|
16
|
+
startingDay?: number,
|
|
17
|
+
// Date format. Default 'DD/MM/YYYY'
|
|
18
|
+
format?: string,
|
|
19
|
+
// Allow keyboard date entry
|
|
20
|
+
readonly?: boolean,
|
|
21
|
+
// Today is default
|
|
22
|
+
today?: boolean,
|
|
23
|
+
// Show timepicker
|
|
24
|
+
time?: boolean,
|
|
25
|
+
// Show the reset button
|
|
26
|
+
resetButton?: boolean,
|
|
27
|
+
// Placeholder
|
|
28
|
+
placeholder?: string,
|
|
29
|
+
// Translations can be done here
|
|
30
|
+
months?: string[],
|
|
31
|
+
monthsFull?: string[],
|
|
32
|
+
weekdays?: string[],
|
|
33
|
+
textDone?: string[],
|
|
34
|
+
textReset?: string[],
|
|
35
|
+
textUpdate?: string[],
|
|
36
|
+
// Start with the value
|
|
37
|
+
value?: string,
|
|
38
|
+
// Fullscreen (this is automatic set for screen size < 800)
|
|
39
|
+
fullscreen: boolean,
|
|
40
|
+
// Create the calendar closed as default
|
|
41
|
+
opened: boolean,
|
|
42
|
+
// Events
|
|
43
|
+
onopen: () => void,
|
|
44
|
+
onclose: () => void,
|
|
45
|
+
onchange: () => void,
|
|
46
|
+
onupdate: () => void,
|
|
47
|
+
// Internal mode controller
|
|
48
|
+
mode: null,
|
|
49
|
+
position: null,
|
|
50
|
+
// Data type
|
|
51
|
+
dataType: null,
|
|
52
|
+
// Controls
|
|
53
|
+
controls: boolean,
|
|
54
|
+
/** Auto select confirms the current date as the new value onblur. Default: true */
|
|
55
|
+
autoSelect: boolean;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface Instance {
|
|
59
|
+
/** Close the calendar picker */
|
|
60
|
+
close: () => void;
|
|
61
|
+
/** Internal date value */
|
|
62
|
+
date: number[];
|
|
63
|
+
/** Convert a formatted string to a valid raw date */
|
|
64
|
+
fromFormatted: string;
|
|
65
|
+
/** Show the calendar in day picker mode */
|
|
66
|
+
getDays: () => void;
|
|
67
|
+
/** Show the calendar in month picker mode */
|
|
68
|
+
getMonths: () => void;
|
|
69
|
+
/** Show the calendar in year picker mode */
|
|
70
|
+
getYears: () => void;
|
|
71
|
+
/** Get the current date */
|
|
72
|
+
getValue: () => string;
|
|
73
|
+
/** Advance to the next month, year or group of years depending on the current view mode */
|
|
74
|
+
next: () => void;
|
|
75
|
+
/** Previous month, year or group of years depending on the current view mode */
|
|
76
|
+
prev: () => void;
|
|
77
|
+
/** Open the calendar picker */
|
|
78
|
+
open: () => void;
|
|
79
|
+
/** Initial settings */
|
|
80
|
+
options: Options;
|
|
81
|
+
/** Reset date */
|
|
82
|
+
reset: () => void;
|
|
83
|
+
/** Change the configurations */
|
|
84
|
+
setOptions
|
|
85
|
+
/** Change the date for today */
|
|
86
|
+
setToday: () => void;
|
|
87
|
+
/** Change the value for a given date */
|
|
88
|
+
setValue: (newDate: string) => void;
|
|
89
|
+
/** Type calendar */
|
|
90
|
+
type: 'calendar';
|
|
91
|
+
/** Alias for setValue */
|
|
92
|
+
update: () => void;
|
|
93
|
+
/** Auto select confirms the current date as the new value onblur. Default: true */
|
|
94
|
+
autoSelect: boolean;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
interface Calendar {
|
|
100
|
+
(): any
|
|
101
|
+
[key: string]: any
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare function Calendar<Calendar>(props: Component.Options): any;
|
|
105
|
+
export default Calendar;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import React, { useRef, useEffect } from "react";
|
|
3
|
+
import jSuites from '../../dist/jsuites';
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
export default React.forwardRef((props, mainReference) => {
|
|
7
|
+
// Dom element
|
|
8
|
+
const Ref = useRef(null);
|
|
9
|
+
|
|
10
|
+
// Get the properties for the spreadsheet
|
|
11
|
+
let options = { ...props };
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
if (!Ref.current.innerHTML) {
|
|
16
|
+
mainReference.current = jSuites.calendar(Ref.current, options);
|
|
17
|
+
}
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
mainReference.current.setValue(props.value)
|
|
22
|
+
}, [props.value])
|
|
23
|
+
|
|
24
|
+
let prop = {
|
|
25
|
+
ref: Ref,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return React.createElement("input", prop);
|
|
29
|
+
})
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Official Type definitions for LemonadeJS plugins
|
|
3
|
+
* https://lemonadejs.net
|
|
4
|
+
* Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
declare function Component(el: HTMLElement, options?: Component.Options): Component.Instance;
|
|
8
|
+
|
|
9
|
+
declare namespace Component {
|
|
10
|
+
interface Options {
|
|
11
|
+
/** Color picker input place holder */
|
|
12
|
+
placeholder: string;
|
|
13
|
+
/** Initial value */
|
|
14
|
+
value: string;
|
|
15
|
+
/** When the color picker is opened */
|
|
16
|
+
onopen: (el: HTMLElement, instance: Color) => void;
|
|
17
|
+
/** When the color picker is closed */
|
|
18
|
+
onclose: (el: HTMLElement, instance: Color) => void;
|
|
19
|
+
/** When the color is changed */
|
|
20
|
+
onchange: (el: HTMLElement, value: string, instance: Color) => void;
|
|
21
|
+
/** Automatically close the color picker when a new color is clicked */
|
|
22
|
+
closeOnChange: boolean;
|
|
23
|
+
/** Color palette options */
|
|
24
|
+
palette: string[];
|
|
25
|
+
/** Fixed or normal */
|
|
26
|
+
position: 'absolute' | null;
|
|
27
|
+
/** Button label */
|
|
28
|
+
doneLabel: string;
|
|
29
|
+
/** Button label */
|
|
30
|
+
resetLabel: string;
|
|
31
|
+
/** Fullscreen mode */
|
|
32
|
+
fullscreen: boolean;
|
|
33
|
+
/** Start the picker opened */
|
|
34
|
+
opened: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface Instance {
|
|
38
|
+
/** Close the calendar picker */
|
|
39
|
+
close: () => void;
|
|
40
|
+
/** Internal date value */
|
|
41
|
+
date: number[];
|
|
42
|
+
/** Convert a formatted string to a valid raw date */
|
|
43
|
+
fromFormatted: string;
|
|
44
|
+
/** Show the calendar in day picker mode */
|
|
45
|
+
getDays: () => void;
|
|
46
|
+
/** Show the calendar in month picker mode */
|
|
47
|
+
getMonths: () => void;
|
|
48
|
+
/** Show the calendar in year picker mode */
|
|
49
|
+
getYears: () => void;
|
|
50
|
+
/** Get the current date */
|
|
51
|
+
getValue: () => string;
|
|
52
|
+
/** Advance to the next month, year or group of years depending on the current view mode */
|
|
53
|
+
next: () => void;
|
|
54
|
+
/** Previous month, year or group of years depending on the current view mode */
|
|
55
|
+
prev: () => void;
|
|
56
|
+
/** Open the calendar picker */
|
|
57
|
+
open: () => void;
|
|
58
|
+
/** Initial settings */
|
|
59
|
+
options: Options;
|
|
60
|
+
/** Reset date */
|
|
61
|
+
reset: () => void;
|
|
62
|
+
/** Change the configurations */
|
|
63
|
+
setOptions
|
|
64
|
+
/** Change the date for today */
|
|
65
|
+
setToday: () => void;
|
|
66
|
+
/** Change the value for a given date */
|
|
67
|
+
setValue: (newDate: string) => void;
|
|
68
|
+
/** Type calendar */
|
|
69
|
+
type: 'calendar';
|
|
70
|
+
/** Alias for setValue */
|
|
71
|
+
update: () => void;
|
|
72
|
+
/** Auto select confirms the current date as the new value onblur. Default: true */
|
|
73
|
+
autoSelect: boolean;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
interface Color {
|
|
79
|
+
(): any
|
|
80
|
+
[key: string]: any
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare function Color<Color>(props: Component.Options): any;
|
|
84
|
+
export default Color;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import React, { useRef, useEffect } from "react";
|
|
3
|
+
import jSuites from '../../dist/jsuites';
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
export default React.forwardRef((props, mainReference) => {
|
|
7
|
+
// Dom element
|
|
8
|
+
const Ref = useRef(null);
|
|
9
|
+
|
|
10
|
+
// Get the properties for the spreadsheet
|
|
11
|
+
let options = { ...props };
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
if (!Ref.current.innerHTML) {
|
|
16
|
+
mainReference.current = jSuites.color(Ref.current, options);
|
|
17
|
+
}
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
mainReference.current.setValue(props.value)
|
|
22
|
+
}, [props.value])
|
|
23
|
+
|
|
24
|
+
let prop = {
|
|
25
|
+
ref: Ref,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
return React.createElement("input", prop);
|
|
29
|
+
})
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Official Type definitions for LemonadeJS plugins
|
|
3
|
+
* https://lemonadejs.net
|
|
4
|
+
* Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
declare function Component(el: HTMLElement, options?: Component.Options): Component.Instance;
|
|
8
|
+
|
|
9
|
+
interface Items {
|
|
10
|
+
/** Context menu item type: line | divisor | default */
|
|
11
|
+
type?: 'line' | 'divisor' | 'default';
|
|
12
|
+
/** Context menu item title */
|
|
13
|
+
title: string;
|
|
14
|
+
/** Context menu icon key. (Material icon key icon identification) */
|
|
15
|
+
icon?: string;
|
|
16
|
+
/** HTML id property of the item DOM element */
|
|
17
|
+
id?: string;
|
|
18
|
+
/** Item is disabled */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** Onclick event for the contextmenu item */
|
|
21
|
+
onclick?: (instance: object, e: MouseEvent) => void;
|
|
22
|
+
/** A short description or instruction for the item. Normally a shortcut. Ex. CTRL + C */
|
|
23
|
+
shortcut?: string;
|
|
24
|
+
/** Show this text when the user mouse over the element */
|
|
25
|
+
tooltip?: string;
|
|
26
|
+
/** Submenu */
|
|
27
|
+
submenu?: Array<Items>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare namespace Component {
|
|
31
|
+
interface Options {
|
|
32
|
+
/** Items for the contextmenu */
|
|
33
|
+
items: Items[],
|
|
34
|
+
/** General onclick handler */
|
|
35
|
+
onclick: null,
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface Instance {
|
|
39
|
+
/** Close the color picker */
|
|
40
|
+
close: () => void;
|
|
41
|
+
/** Get the current color in hex */
|
|
42
|
+
create: (items: Items[]) => void;
|
|
43
|
+
/** Open the contextmenu. You can overwrite the items each time the menu is opened */
|
|
44
|
+
open: (event: MouseEvent, items?: Items[]) => void;
|
|
45
|
+
/** Open the contextmenu. You can overwrite the items each time the menu is opened */
|
|
46
|
+
options: Options;
|
|
47
|
+
/** Initial settings */
|
|
48
|
+
isOpened: () => boolean;
|
|
49
|
+
/** Internal type */
|
|
50
|
+
type: 'contextmenu';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
interface Contextmenu {
|
|
56
|
+
(): any
|
|
57
|
+
[key: string]: any
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
declare function Contextmenu<Contextmenu>(props: Component.Options): any;
|
|
61
|
+
export default Contextmenu;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import React, { useRef, useEffect } from "react";
|
|
3
|
+
import jSuites from '../../dist/jsuites';
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
export default React.forwardRef((props, mainReference) => {
|
|
7
|
+
// Dom element
|
|
8
|
+
const Ref = useRef(null);
|
|
9
|
+
|
|
10
|
+
// Get the properties for the spreadsheet
|
|
11
|
+
let options = { ...props };
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
if (!Ref.current.innerHTML) {
|
|
16
|
+
mainReference.current = jSuites.contextmenu(Ref.current, options);
|
|
17
|
+
}
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
let prop = {
|
|
21
|
+
ref: Ref,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return React.createElement("div", prop);
|
|
25
|
+
})
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Official Type definitions for LemonadeJS plugins
|
|
3
|
+
* https://lemonadejs.net
|
|
4
|
+
* Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
declare function Component(el: HTMLElement, options?: Component.Options): Component.Instance;
|
|
8
|
+
|
|
9
|
+
interface DropdownItem {
|
|
10
|
+
/** Value of the selected item. */
|
|
11
|
+
id?: string | number;
|
|
12
|
+
/** Label for the selected item. */
|
|
13
|
+
name?: string;
|
|
14
|
+
/** Description of the item */
|
|
15
|
+
title?: string;
|
|
16
|
+
/** Icon of the item */
|
|
17
|
+
image?: string;
|
|
18
|
+
/** Name of the group where the item belongs to */
|
|
19
|
+
group?: string;
|
|
20
|
+
/** Keywords to help finding one item */
|
|
21
|
+
synonym?: string[];
|
|
22
|
+
/** Item is disabled */
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
/** Color for the item */
|
|
25
|
+
color?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface ItemContainer {
|
|
29
|
+
/** Data for the item */
|
|
30
|
+
data: DropdownItem;
|
|
31
|
+
/** HTML container for the element */
|
|
32
|
+
element: HTMLElement;
|
|
33
|
+
/** HTML container for the group */
|
|
34
|
+
group: HTMLElement;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare namespace Component {
|
|
38
|
+
interface Options {
|
|
39
|
+
/** Endpoint to fetch data from a remote server */
|
|
40
|
+
url?: string;
|
|
41
|
+
/** Preloaded data items for the dropdown */
|
|
42
|
+
data?: DropdownItem[];
|
|
43
|
+
/** Format type of the data, typically { id: name } or { value: text } */
|
|
44
|
+
format?: number;
|
|
45
|
+
/** Indicates if multiple item selection is allowed */
|
|
46
|
+
multiple?: boolean;
|
|
47
|
+
/** Enables the autocomplete feature for user input */
|
|
48
|
+
autocomplete?: boolean;
|
|
49
|
+
/** Allows remote search for options */
|
|
50
|
+
remoteSearch?: boolean;
|
|
51
|
+
/** Enables the lazy loading feature for handling a large number of options */
|
|
52
|
+
lazyLoading?: boolean;
|
|
53
|
+
/** Rendering style of the dropdown: 'default', 'picker', or 'searchbar' */
|
|
54
|
+
type?: 'default' | 'picker' | 'searchbar',
|
|
55
|
+
/** Defines the dropdown's width */
|
|
56
|
+
width?: number;
|
|
57
|
+
/** Sets the maximum width of the dropdown */
|
|
58
|
+
maxWidth?: number;
|
|
59
|
+
/** Determines if the dropdown is opened when initialized */
|
|
60
|
+
opened?: boolean;
|
|
61
|
+
/** The initial value of the dropdown */
|
|
62
|
+
value?: string;
|
|
63
|
+
/** Placeholder text for the dropdown */
|
|
64
|
+
placeholder?: string;
|
|
65
|
+
/** Allows the user to add new options */
|
|
66
|
+
newOptions?: boolean;
|
|
67
|
+
/** Internal controller for the dropdown's position */
|
|
68
|
+
position?: boolean;
|
|
69
|
+
/** Event handler for value changes */
|
|
70
|
+
onchange?: (el: HTMLElement, obj: Dropdown, oldValue: string, newValue: string) => void;
|
|
71
|
+
/** Event handler for when the dropdown is ready */
|
|
72
|
+
onload?: (el: HTMLElement, obj: Dropdown, data: any, val: any) => void;
|
|
73
|
+
/** Event handler for when the dropdown opens */
|
|
74
|
+
onopen?: (el: HTMLElement) => void;
|
|
75
|
+
/** Event handler for when the dropdown closes */
|
|
76
|
+
onclose?: (el: HTMLElement) => void;
|
|
77
|
+
/** Event handler for when the dropdown receives focus */
|
|
78
|
+
onfocus?: (el: HTMLElement) => void;
|
|
79
|
+
/** Event handler for when the dropdown loses focus */
|
|
80
|
+
onblur?: (el: HTMLElement) => void;
|
|
81
|
+
/** Event handler for when a new option is added to the dropdown */
|
|
82
|
+
oninsert?: (obj: Dropdown, item: DropdownItem, newItem: DropdownItem) => void;
|
|
83
|
+
/** Event handler for just before a new option is added to the dropdown */
|
|
84
|
+
onbeforeinsert?: (obj: Dropdown, item: DropdownItem) => void;
|
|
85
|
+
/** Event handler for before a search on autocomplete is performed */
|
|
86
|
+
onbeforesearch?: (obj: Dropdown, ajaxRequest: object) => boolean | null;
|
|
87
|
+
/** Event handler for processing search results */
|
|
88
|
+
onsearch?: (obj: Dropdown, result: object) => void;
|
|
89
|
+
/** Toggles the sorting of dropdown elements */
|
|
90
|
+
sortResults?: boolean;
|
|
91
|
+
/** Indicates if the dropdown should automatically receive focus upon creation */
|
|
92
|
+
autofocus?: boolean;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
interface Instance {
|
|
96
|
+
/** Add a new item to the dropdown */
|
|
97
|
+
add: (title: string, id: string|number) => DropdownItem;
|
|
98
|
+
/** Append new data to the dropdown */
|
|
99
|
+
appendData: (data: DropdownItem[]) => void
|
|
100
|
+
/** Close the dropdown picker */
|
|
101
|
+
closeItem: (ignoreEvents?: boolean) => void
|
|
102
|
+
/** Current selectIndex */
|
|
103
|
+
currentIndex: number;
|
|
104
|
+
/** Find the items with the keyword */
|
|
105
|
+
find: (str: string) => void;
|
|
106
|
+
/** Select the first item */
|
|
107
|
+
first: () => void;
|
|
108
|
+
/** Get all data */
|
|
109
|
+
getData: () => DropdownItem[];
|
|
110
|
+
/** Get the index position of a item by its value */
|
|
111
|
+
getPosition: (value: string) => number | boolean;
|
|
112
|
+
/** Get the text from the selected options */
|
|
113
|
+
getText: (asArray?: boolean) => string | string[];
|
|
114
|
+
/** Get the URL source for the data if defined */
|
|
115
|
+
getUrl: () => string;
|
|
116
|
+
/** Get the value from the selected options */
|
|
117
|
+
getValue: (asArray?: boolean) => string | string[];
|
|
118
|
+
/** DOM Elements for the groups */
|
|
119
|
+
groups: HTMLElement[];
|
|
120
|
+
/** DOM Element for the header */
|
|
121
|
+
header: HTMLElement;
|
|
122
|
+
/** Items */
|
|
123
|
+
items: ItemContainer[];
|
|
124
|
+
/** Move index to the last element in the dropdown */
|
|
125
|
+
last: () => void;
|
|
126
|
+
/** Internal lazy loading method */
|
|
127
|
+
loadDown: () => void;
|
|
128
|
+
/** Internal lazy loading method */
|
|
129
|
+
loadFirst: () => void;
|
|
130
|
+
/** Internal lazy loading method */
|
|
131
|
+
loadLast: () => void;
|
|
132
|
+
/** Internal lazy loading method */
|
|
133
|
+
loadUp: () => void;
|
|
134
|
+
/** Move index to the next element in the dropdown */
|
|
135
|
+
next: () => void;
|
|
136
|
+
/** Open the dropdown */
|
|
137
|
+
open: () => void;
|
|
138
|
+
/** Dropdown configuration */
|
|
139
|
+
options: Component.Options;
|
|
140
|
+
/** Move index to the previous element in the dropdown */
|
|
141
|
+
prev: () => void;
|
|
142
|
+
/** Reset the value of the dropdown */
|
|
143
|
+
reset: () => void;
|
|
144
|
+
/** Alias for setCursor */
|
|
145
|
+
resetCursor: (index: number, setPosition?: boolean) => void
|
|
146
|
+
/** Set the value to null */
|
|
147
|
+
resetSelected: () => void;
|
|
148
|
+
/** Array of results when filtering */
|
|
149
|
+
results: DropdownItem[];
|
|
150
|
+
/** Search term */
|
|
151
|
+
search: string;
|
|
152
|
+
/** Select an index */
|
|
153
|
+
selectIndex: (index: number, force?: boolean) => void
|
|
154
|
+
/** Select an item */
|
|
155
|
+
selectItem: (item: DropdownItem) => void;
|
|
156
|
+
/** Set the cursor to a specified element index */
|
|
157
|
+
setCursor: (index: number, setPosition?: boolean) => void
|
|
158
|
+
/** Set new data for the dropdown */
|
|
159
|
+
setData: (items: DropdownItem[]) => void;
|
|
160
|
+
/** Set the id or value for one item */
|
|
161
|
+
setId: (item: number|DropdownItem, newId: number) => void;
|
|
162
|
+
/** Change the dropdown options */
|
|
163
|
+
setOptions: (newOptions: Component.Options, reset?: boolean) => void;
|
|
164
|
+
/** Change the dropdown data from a URL */
|
|
165
|
+
setUrl: (newUrl: string, callback?: Function) => void;
|
|
166
|
+
/** Set the value for a dropdown */
|
|
167
|
+
setValue: (newValue: string | string[]) => void;
|
|
168
|
+
/** Internal type */
|
|
169
|
+
type: 'dropdown';
|
|
170
|
+
/** Alias for setCursor */
|
|
171
|
+
updateCursor: (index: number, setPosition?: boolean) => void;
|
|
172
|
+
/** Current internal value */
|
|
173
|
+
value: Record<number, string>;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
interface Dropdown {
|
|
179
|
+
(): any
|
|
180
|
+
[key: string]: any
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
declare function Dropdown<Dropdown>(props: Component.Options): any;
|
|
184
|
+
export default Dropdown;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import React, { useRef, useEffect } from "react";
|
|
3
|
+
import jSuites from '../../dist/jsuites';
|
|
4
|
+
|
|
5
|
+
// @ts-ignore
|
|
6
|
+
export default React.forwardRef((props, mainReference) => {
|
|
7
|
+
// Dom element
|
|
8
|
+
const Ref = useRef(null);
|
|
9
|
+
|
|
10
|
+
// Get the properties for the spreadsheet
|
|
11
|
+
let options = { ...props };
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
if (!Ref.current.innerHTML) {
|
|
16
|
+
mainReference.current = jSuites.dropdown(Ref.current, options);
|
|
17
|
+
}
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
let prop = {
|
|
21
|
+
ref: Ref,
|
|
22
|
+
style: { height: '100%', width: '100%' }
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return React.createElement("div", prop);
|
|
26
|
+
})
|