jsuites 5.5.1 → 5.5.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/changelog.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 5.5.2
2
+
3
+ - Replace onbeforeinput to prompt;
4
+
1
5
  # 5.5.1
2
6
 
3
7
  - Add tracking.state to a second jsuites instance.
package/dist/jsuites.js CHANGED
@@ -6131,12 +6131,12 @@ function Dropdown() {
6131
6131
  onfocus: null,
6132
6132
  onblur: null,
6133
6133
  oninsert: null,
6134
- onbeforeinput: null,
6135
6134
  onbeforeinsert: null,
6136
6135
  onsearch: null,
6137
6136
  onbeforesearch: null,
6138
6137
  sortResults: false,
6139
6138
  autofocus: false,
6139
+ prompt: null,
6140
6140
  }
6141
6141
 
6142
6142
  // Loop through our object
@@ -6446,34 +6446,11 @@ function Dropdown() {
6446
6446
  }
6447
6447
  }
6448
6448
 
6449
- /**
6450
- * Add a new item
6451
- * @param {string} title - title of the new item
6452
- * @param {string} id - value/id of the new item
6453
- */
6454
- obj.add = async function (title, id) {
6455
- if (typeof (obj.options.onbeforeinput) == 'function') {
6456
- let ret = await obj.options.onbeforeinput(obj, title);
6457
- if (ret === false) {
6458
- return false;
6459
- } else if (ret) {
6460
- if (typeof(ret) === 'object') {
6461
- if (ret.title) {
6462
- title = ret.title;
6463
- }
6464
- if (ret.id) {
6465
- id = ret.id;
6466
- }
6467
- } else {
6468
- title = ret;
6469
- }
6470
- }
6471
- }
6472
-
6449
+ const add = function(title, id) {
6473
6450
  if (! title) {
6474
- var current = obj.options.autocomplete == true ? obj.header.value : '';
6475
- var title = prompt(dictionary.translate('Add A New Option'), current);
6476
- if (!title) {
6451
+ let current = obj.options.autocomplete == true ? obj.header.value : '';
6452
+ title = prompt(dictionary.translate('Add A New Option'), current);
6453
+ if (! title) {
6477
6454
  return false;
6478
6455
  }
6479
6456
  }
@@ -6533,6 +6510,18 @@ function Dropdown() {
6533
6510
  return item;
6534
6511
  }
6535
6512
 
6513
+ /**
6514
+ * Add a new item
6515
+ * @param {string} title - title of the new item
6516
+ * @param {string} id - value/id of the new item
6517
+ */
6518
+ obj.add = function (title, id) {
6519
+ if (typeof (obj.options.prompt) == 'function') {
6520
+ return obj.options.prompt.call(obj, add);
6521
+ }
6522
+ return add(title, id);
6523
+ }
6524
+
6536
6525
  /**
6537
6526
  * Create a new item
6538
6527
  */
@@ -12780,7 +12769,7 @@ var jSuites = {
12780
12769
  ...dictionary,
12781
12770
  ...helpers,
12782
12771
  /** Current version */
12783
- version: '5.5.1',
12772
+ version: '5.5.2',
12784
12773
  /** Bind new extensions to Jsuites */
12785
12774
  setExtensions: function(o) {
12786
12775
  if (typeof(o) == 'object') {
@@ -75,12 +75,12 @@ interface DropdownOptions {
75
75
  onbeforesearch?: (obj: Dropdown, ajaxRequest: object) => boolean | null;
76
76
  /** Event handler for processing search results */
77
77
  onsearch?: (obj: Dropdown, result: object) => void;
78
- /** Before adding a new element to the dropdown. This is async method */
79
- onbeforeinput?: (obj: Dropdown, title: string) => string | Item;
80
78
  /** Toggles the sorting of dropdown elements */
81
79
  sortResults?: boolean;
82
80
  /** Indicates if the dropdown should automatically receive focus upon creation */
83
81
  autofocus?: boolean;
82
+ /** Custom prompt on insert new items */
83
+ prompt?: (addNewRow: (title: string, id: any) => void) => boolean;
84
84
  }
85
85
 
86
86
  interface ItemContainer {
package/package.json CHANGED
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "main": "dist/jsuites.js",
28
28
  "types": "dist/jsuites.d.ts",
29
- "version": "5.5.1",
29
+ "version": "5.5.2",
30
30
  "bugs": "https://github.com/jsuites/jsuites/issues",
31
31
  "homepage": "https://github.com/jsuites/jsuites",
32
32
  "docs": "https://jsuites.net",