jspreadsheet 12.4.5 → 12.5.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.
package/dist/index.d.ts CHANGED
@@ -570,8 +570,6 @@ declare namespace jspreadsheet {
570
570
  }
571
571
 
572
572
  interface Dropdown {
573
- /** Endpoint to fetch data from a remote server */
574
- url?: string;
575
573
  /** Preloaded data items for the dropdown */
576
574
  data?: DropdownItem[];
577
575
  /** Format type of the data, typically { id: name } or { value: text } */
@@ -580,73 +578,72 @@ declare namespace jspreadsheet {
580
578
  multiple?: boolean;
581
579
  /** Enables the autocomplete feature for user input */
582
580
  autocomplete?: boolean;
583
- /** Allows remote search for options */
584
- remoteSearch?: boolean;
585
- /** Enables the lazy loading feature for handling a large number of options */
586
- lazyLoading?: boolean;
587
- /** Rendering style of the dropdown: 'default', 'picker', or 'searchbar' */
588
- type?: 'default' | 'picker' | 'searchbar',
589
- /** Defines the dropdown's width */
581
+ /** Rendering style of the dropdown: 'default', 'picker', 'searchbar' or inline. auto will render picker or searchbar based on screensize */
582
+ type?: 'default' | 'auto' | 'picker' | 'searchbar' | 'inline',
583
+ /** Defines the dropdown width */
590
584
  width?: number;
591
- /** Sets the maximum width of the dropdown */
592
- maxWidth?: number;
593
- /** Determines if the dropdown is opened when initialized */
594
- opened?: boolean;
595
585
  /** The initial value of the dropdown */
596
- value?: string;
586
+ value?: string | string[] | number | number[];
597
587
  /** Placeholder text for the dropdown */
598
588
  placeholder?: string;
599
- /** Allows the user to add new options */
600
- newOptions?: boolean;
601
- /** Internal controller for the dropdown's position */
602
- position?: boolean;
589
+ /** Allow insert new items */
590
+ insert?: boolean;
591
+ /** Specifies the URL for fetching the data */
592
+ url?: string;
593
+ /** Item is disabled */
594
+ disabled?: boolean;
595
+ /** Enables another ways to option insert */
596
+ prompt?: boolean | string | (() => string);
597
+ /** Remote search */
598
+ remote?: boolean;
599
+ /** Allow empty in single dropdown options. Default: true */
600
+ allowEmpty?: boolean;
603
601
  /** Event handler for value changes */
604
- onchange?: (el: HTMLElement, obj: object, oldValue: string, newValue: string) => void;
602
+ onchange?: (self: object, newValue: string|number) => void;
605
603
  /** Event handler for when the dropdown is ready */
606
- onload?: (el: HTMLElement, obj: object, data: any, val: any) => void;
604
+ onload?: (self: object) => void;
607
605
  /** Event handler for when the dropdown opens */
608
- onopen?: (el: HTMLElement) => void;
606
+ onopen?: (self: object) => void;
609
607
  /** Event handler for when the dropdown closes */
610
- onclose?: (el: HTMLElement) => void;
611
- /** Event handler for when the dropdown receives focus */
612
- onfocus?: (el: HTMLElement) => void;
613
- /** Event handler for when the dropdown loses focus */
614
- onblur?: (el: HTMLElement) => void;
608
+ onclose?: (self: object) => void;
609
+ /**
610
+ * Event handler for just before a new option is added to the dropdown. This is an async function to handle ajax requests.
611
+ * Example:
612
+ * self.beforeInsert = async function(s, element) {
613
+ * let newId = await getTheNewItemIdFromDatabase(element.text);
614
+ * return {
615
+ * text: element.text,
616
+ * value: newId,
617
+ * };
618
+ * }
619
+ *
620
+ * */
621
+ onbeforeinsert?: (self: object, item: DropdownItem) => boolean | void;
615
622
  /** Event handler for when a new option is added to the dropdown */
616
- oninsert?: (obj: object, item: DropdownItem, newItem: DropdownItem) => void;
617
- /** Event handler for just before a new option is added to the dropdown */
618
- onbeforeinsert?: (obj: object, item: DropdownItem) => DropdownItem | false | undefined;
619
- /** Event handler for before a search on autocomplete is performed */
620
- onbeforesearch?: (obj: object, ajaxRequest: object) => object | false | undefined;
623
+ oninsert?: (self: object, item: DropdownItem) => void;
624
+ /** Before the search happens */
625
+ onbeforesearch?: (self: object, query: string, result: object[]) => boolean | null;
621
626
  /** Event handler for processing search results */
622
- onsearch?: (obj: object, result: object) => void;
623
- /** Toggles the sorting of dropdown elements */
624
- sortResults?: boolean;
625
- /** Indicates if the dropdown should automatically receive focus upon creation */
626
- autofocus?: boolean;
627
+ onsearch?: (self: object, query: string, result: object[]) => void;
627
628
  }
628
629
 
629
630
  interface DropdownItem {
630
631
  /** Value of the selected item. */
631
632
  value?: string | number;
632
- /** Label for the selected item. */
633
- text?: string;
634
633
  /** Description of the item */
635
- title?: string;
634
+ text?: string;
636
635
  /** Icon of the item */
637
636
  image?: string;
638
637
  /** Name of the group where the item belongs to */
639
638
  group?: string;
640
639
  /** Keywords to help finding one item */
641
- synonym?: string[];
640
+ synonym?: string | string[];
642
641
  /** Item is disabled */
643
642
  disabled?: boolean;
644
643
  /** Color for the item */
645
644
  color?: string;
646
- /** Deprecated */
647
- id?: string | number;
648
- /** Deprecated */
649
- name?: string;
645
+ // Keywords
646
+ keywords?: string | string[];
650
647
  }
651
648
 
652
649
  interface ContextmenuItem {