Skip to content

Instantly share code, notes, and snippets.

@DaveyJake
Last active November 5, 2023 02:54
Show Gist options
  • Save DaveyJake/a7009c82ed3f4fbd278b814d62009631 to your computer and use it in GitHub Desktop.
Save DaveyJake/a7009c82ed3f4fbd278b814d62009631 to your computer and use it in GitHub Desktop.
Typed YADCF
// Type definitions for Yet Another DataTables Column Filter 0.94.beta.46
// Project: yadcf
// Definitions by: Davey Jacobson <https://daveyjake.dev>
import DataTables, { type Api, type ColumnIdx as ColumnNumber, type ColumnSelector as ColSelector, type Config } from 'datatables.net';
import 'yadcf';
//
// Column Parameters
//
/**
* Append data `before` or along with the value retrieved from the table.
*
* @since 0.0.1
*
* @remarks `sorted` only works on array of primitives.
*/
type AppendDataToTableData = 'before' | 'sorted';
/**
* Enable case-insensitive filtering.
*
* @since 0.0.1
*
* @remarks Use with `select`, `auto_complete`, `text`.
*
* @typeParam `T` Generic type placeholder.
*/
type CaseInsensitive<T> = T extends FilterTypeMatchMode ? boolean : never;
/**
* Add checkboxes `exclude` and `regex` after input text column.
*
* @since 0.0.1
*
* @remarks Use with `text` filter.
*
* @typeParam `T` Generic type placeholder.
*/
type CheckboxPositionAfter<T> = T extends 'text' ? boolean : never;
/**
* The number of the column to which the filter will be applied.
*
* @since 0.0.1
*/
type ColumnIdx = ColumnNumber;
/**
* Helper function to identify `text` present in any cell.
*
* @since 0.0.1
*/
type ColumnDataRender = ( data: Record<string, any> ) => any;
/**
* Type of data in column.
*
* @since 0.0.1
*
* @remarks Use `rendered_html` when using `render()` on `columnDefs` or similar.
*/
type ColumnDataType = 'text' | 'html' | 'rendered_html' | 'html5_data_complex';
/**
* Custom filter function applied to the columns.
*
* @since 0.0.1
*
* @remarks Required when **filter_type** is set to a value in {@link FilterTypeCustomFunc}.
*
* @privateremarks When using **multi_select_custom_func** as {@link FilterType},
* **filterVal** will hold an array of selected values from the multi select element.
*
* @typeParam `T` Generic type placeholder.
*
* @param filterVal Value from a select drop-down.
* @param columnVal Value from the relevant row column.
* @param rowValues Array of values from the entire row.
* @param stateVal Holds the current state of the table row DOM.
*/
type CustomFunc<T> = T extends FilterTypeCustomFunc ? (( filterVal: string, columnVal: unknown, rowValues: Array<any>, stateVal: Node ) => boolean) : never;
/**
* Delimiter that separates min and max values for number range filter type.
*
* @since 0.0.1
*/
type CustomRangeDelimeter = string;
/**
* The {@link https://datatables.net/reference/type/column-selector `column-selector`}
* of the column to which the filter will be applied.
*
* @since 0.0.1
*/
type ColumnSelector = ColSelector;
/**
* Predefined data for filter.
*
* @since 0.0.1
*
* @remarks When **filter_type** is set to `custom_func` or `multi_select_custom_func`, this will populate the custom
* select filter element.
*/
type Data = Array<string | Record<string, any>>;
/**
* Feed data to filter as is. Use when you want to define your own `<option></option>` for the filter.
*
* @since 0.0.1
*
* @remarks Only use when **filter_type** is set to `select` or `multi_select`.
*
* @typeParam `T` Generic type placeholder.
*/
type DataAsIs<T> = T extends FilterTypeDataAsIs ? boolean : never;
/**
* Delimiter that separates text in table column.
*
* @since 0.0.1
*/
type DataTextDelimeter = string;
/**
* Defines the format in which the date values are parsed in `Date` object.
*
* @since 0.0.1
*/
type DateFormat = 'mm/dd/yyyy' | 'mm-dd-yyyy' | 'dd/mm/yyyy' | 'dd-mm-yyyy' | 'yyyy-mm-dd' | 'hh:mm';
/**
* Defines the format in which the date values are being parsed in Date object by `moment.js` library.
*
* @since 0.0.1
* @link https://momentjs.com/docs/#/displaying/
*/
type DateFormatMoment = 'MMMM Do YYYY' | 'MMM D YYYY' | 'MM/DD/YYYY' | 'DD/MM/YYYY' | 'YYYY-MM-DD' | 'HH:mm';
/**
* Specify the `datepicker` library to use.
*
* @since 0.0.1
*
* @remarks This feature depends on `moment.js` library.
*/
type DatepickerType = 'jquery-ui' | 'bootstrap-datetimepicker' | 'bootstrap-datepicker' | 'daterangepicker' | 'dt-datetime';
/**
* Add checkbox next to filter to enable `not/exclude` filtering.
*
* @since 0.0.1
*
* @remarks Use with `text`, `select`, and `number_range`.
*
* @typeParam `T` Generic type placeholder.
*/
type ExcludeCheckbox<T> = T extends FilterTypeExclude ? boolean : never;
/**
* Label above the exclude checkbox.
*
* @since 0.0.1
*/
type ExcludeLabel = string;
/**
* Adds external checkboxes button and hides `exclude`, `null`, `regex` checkboxes.
*
* @since 0.0.1
*/
type ExtTriggeredCheckboxesText = boolean | string;
/**
* Add `onclick` function to external checkboxes button using `event` parameter.
*
* @since 0.0.1
*/
type ExtTriggeredCheckboxesFunction = ( event: Event ) => any;
/**
* Add additional classes to external checkboxes filter button.
*
* @since 0.0.1
*/
type ExtTriggeredCheckboxesButtonStyleClass = string;
/**
* Use in lieu of placing filter in column header.
*
* @since 0.0.1
*
* @remarks Pass the ID of the desired container for the column filter.
*/
type FilterContainerID = string;
/**
* Use in lieu of placing filter in column header.
*
* @since 0.0.1
*
* @remarks Pass the jQuery selector of the desired container for the column filter.
*/
type FilterContainerSelector = string;
/**
* Label that will appear in the select menu filter when no value is selected.
*
* @since 0.0.1
*
* @typeParam `T` Generic type placeholder.
*/
type FilterDefaultLabel<T> = T extends 'range_number' ? Array<string> : string;
/**
* Delay filter execution for this many milliseconds.
*
* @since 0.0.1
*
* @remarks Use with `text`, `range_number`, `range_date`, `range_number_slider`.
*/
type FilterDelay<T> = T extends FilterTypeFilterDelay ? number : never;
/**
* Allows to control the matching mode of the filter.
*
* @since 0.0.1
*
* @remarks Only use with `select`, `auto_complete`, `text`.
*
* @typeParam `T` Generic type placeholder.
*/
type FilterMatchMode<T> = T extends FilterTypeMatchMode ? 'contains' | 'exact' | 'startsWith' | 'regex' : never;
/**
* Parameter to pass to jQuery Autocomplete, jQuery Slider and/or Bootstrap Datetimepicker.
*
* @since 0.0.1
*/
type FilterPluginOptions = Record<string, any>;
/**
* The text that will appear inside the reset button next to the select drop down.
*
* @since 0.0.1
*
* @remarks Set to `false` to hide from that specific column filter.
*/
type FilterResetButtonText = boolean | string;
/**
* The `custom_func` setting is required when `filter_type` is one of these.
*
* @since 0.0.1
*/
type FilterTypeCustomFunc = 'custom_func' | 'multi_select_custom_func' | 'date_custom_func';
/**
* When using `data_as_is`, it is only supported with **filter_type** is set to `select` or `multi_select`.
*
* @since 0.0.1
*/
type FilterTypeDataAsIs = 'select' | 'multi_select';
/**
* The `exclude` option is only supported by...
*
* - `range_number`
* - `select`
* - `text`
*
* @since 0.0.1
*/
type FilterTypeExclude = Exclude<FilterTypeRemaining, 'date' | 'range_date'> | Extract<FilterTypeDataAsIs, 'select'>;
/**
* The `filter_delay` setting is only supported by...
*
* - `text`
* - `range_date`
* - `range_number`
* - `range_number_slider`
*
* @since 0.0.1
*/
type FilterTypeFilterDelay = Exclude<FilterTypeRemaining, 'date'> | Extract<FilterTypeHTMLDataSelector, 'range_number_slider'>;
/**
* The `html_data_selector` setting is only supported when `filter_type` is...
*
* - `auto_complete`
* - `range_number_slider`
* - `select`
*
* @since 0.0.1
*/
type FilterTypeHTMLDataSelector = 'auto_complete' | 'range_number_slider' | Exclude<FilterTypeDataAsIs, 'multi_select'>;
/**
* The `filter_match_mode` option only works when `filter_type` is set to...
*
* - `auto_complete`
* - `select`
* - `text`
*
* @since 0.0.1
*
* @typeParam `T` Generic type placeholder.
*/
type FilterTypeMatchMode = Exclude<FilterTypeHTMLDataSelector, 'range_number_slider'> | Extract<FilterTypeRemaining, 'text'>;
/**
* The `omit_default_label` depends on the following `filter_type` values:
*
* - `select`
* - `multi_select`
* - `custom_func`
* - `multi_select_custom_func`
*
* @since 0.0.1
*
* @typeParam `T` Generic type placeholder.
*/
type FilterTypeOmitDefaultLabel = FilterTypeDataAsIs | Exclude<FilterTypeCustomFunc, 'date_custom_func'>;
/**
* Range filters:
*
* - `range_date`
* - `range_number`
* - `range_number_slider`
*
* @since 0.0.1
*/
type FilterTypeRange = Exclude<FilterTypeFilterDelay, 'text'>;
/**
* The type of the filter to be used in the column.
*
* @since 0.0.1
*/
type FilterTypeRemaining = 'text' | 'date' | 'range_number' | 'range_date';
/**
* The `style_class` option is only supported by...
*
* - `select`
* - `multi_select`
* - `text`
* - `custom_func`
* - `multi_select_custom_func`
* - `range_number`
* - `range_number_slider`
* - `range_date`
*
* @since 0.0.1
*/
type FilterTypeStyleClass = FilterTypeOmitDefaultLabel | Exclude<FilterTypeRemaining, 'date'> | Extract<FilterTypeHTMLDataSelector, 'range_number_slider'>;
/**
* The complete filter types.
*
* @since 0.0.1
*/
type FilterType = FilterTypeCustomFunc | FilterTypeDataAsIs | FilterTypeHTMLDataSelector | FilterTypeRemaining;
/**
* Allows for advanced text value selection within HTML inside table cell (ex: `li:eq(1)`).
*
* @since 0.0.1
*
* @remarks Selector string is searched from the first element inside the table cell.
* Only use with `range_number_slider`, `select`, `auto_complete`.
*
* @typeParam `T` Generic type placeholder.
*/
type HTMLDataSelector<T> = T extends FilterTypeHTMLDataSelector ? string : never;
/**
* How your data is parsed.
*
* @since 0.0.1
*/
type HTMLDataType = 'text' | 'value' | 'id' | 'selector';
/**
* Allows to filter based on HTML5 `data-{(sort | order) | (filter | search)}` attributes.
*
* @since 0.0.1
* @link https://www.datatables.net/examples/advanced_init/html5-data-attributes.html
*/
type HTML5Data = 'data-filter' | 'data-search' | 'data-sort' | 'data-order';
/**
* Tells the `range_number` and `range_number_slider` to ignore specific characters while filtering.
*
* @since 0.0.1
*/
type IgnoreChar = string;
/**
* Labels that will appear in the select menu filter when no value is selected.
*
* @since 0.0.1
*
* @property `select`
* @property `select_multi`
* @property `filter`
* @property `range`
* @property `date`
*/
type Language = {
select: string;
select_multi: string;
filter: string;
range: [ string, string ];
date: string;
};
/**
* Add checkbox next to filter to search for null values.
*
* @since 0.0.1
*
* @remarks Use with `text` and `range_number` filters.
*/
type NullCheckBox<T> = T extends Exclude<FilterTypeRemaining, 'date' | 'range_date'> ? boolean : never;
/**
* Label above the null checkbox.
*
* @since 0.0.1
*/
type NullLabel = string;
/**
* Prevent yadcf from adding 'default_label'.
*
* @since 0.0.1
*
* @remarks Only use with 'select', 'multi_select', 'custom_func', 'multi_select_custom_func'.
*
* @typeParam `T` Generic type placeholder.
*/
type OmitDefaultLabel<T> = T extends FilterTypeOmitDefaultLabel ? boolean : never;
/**
* Add checkbox next to filter to switch `regex`, `filter_match_mode` on the fly.
*
* @since 0.0.1
*
* @remarks Only use with `text` filter.
*
* @typeParam `T` Generic type placeholder.
*/
type RegexCheckBox<T> = T extends 'text' ? boolean : never;
/**
* Label above the regex checkbox.
*
* @since 0.0.1
*/
type RegexLabel = string;
/**
* String value which internally represents `null` option in select filters.
*
* @since 0.0.1
*
* @remarks Use with `exclude`.
*/
type SelectNullOption = string | 'null';
/**
* Turn basic `select` element into `Chose` or `Select2` drop down.
*
* @since 0.0.1
*
* @remarks When using `custom_select`, call `initSelectPluginCustomTriggers` before calling yadcf constructor / init.
*/
type SelectType = 'chosen' | 'select2' | 'custom_select';
/**
* Parameter to pass as is to `Chosen/Select` plugin.
*
* @since 0.0.1
*/
type SelectTypeOptions = Record<string, any>;
/**
* Defines how the values in the filter will be sorted.
*
* @since 0.0.1
*
* @remarks Use `none` to preserve the order of the data attribute as is.
*/
type SortAs = 'alpha' | 'num' | 'alphaNum' | 'custom' | 'none';
/**
* Allows user to provide a custom sorting function for the filtered elements.
*
* @since 0.0.1
*/
type SortAsCustomFunc = ( args?: any ) => boolean;
/**
* Defines the order in which the filtered values are sorted.
*
* @since 0.0.1
*/
type SortOrder = 'asc' | 'desc';
/**
* Range data type.
*
* @since 0.0.1
*
* @remarks Only use with `range_number`, `range_number_slider`, or `range_date`.
*
* @typeParam `T` Generic type placeholder.
*/
type RangeDataType<T> = T extends Exclude<FilterTypeFilterDelay, 'text'> ? 'single' | 'range' | 'delimeter' : never;
/**
* Range data type delimeter.
*
* @since 0.0.1
*
* @remarks Only use with `range_number`, `range_number_slider`, or `range_date`.
*/
type RangeDataTypeDelimeter<T> = T extends Exclude<FilterTypeFilterDelay, 'text'> ? string : never;
/**
* Add additional classes to filter reset button.
*
* @since 0.0.1
*/
type ResetButtonStyleClass = string;
/**
* Add additional classes to filter.
*
* @since 0.0.1
*
* @remarks Use with `select`, `multi_select`, `text`, `custom_func`, `multi_select_custom_func`, `range_number`,
* `range_number_slider`, `range_date`.
*
* @typeParam `T` Generic type placeholder.
*/
type StyleClass<T> = T extends FilterTypeStyleClass ? string : never;
//
// Table Parameters
//
/**
* Only filter when yadcf.exFilterExternallyTriggered(table_arg) is called.
*
* @since 0.0.1
*
* @remarks Useful when you want to trigger a filter when clicking on or selecting from an input.
*/
type ExternallyTriggered = boolean;
/**
* Populate options from filtered rows (aka only use the data that remains after filtering).
*
* @since 0.0.1
*/
type CumulativeFiltering = boolean;
/**
* Filters placed in the header `thead` or footer `tfoot`.
*
* @since 0.0.1
*/
type FiltersPosition = 'header' | 'footer';
/**
* Enable control of the `tr` index inside the table header `thead`.
*
* @since 0.0.1
*
* @remarks Useful when one `tr` is used for headers/sort and another is used for filters.
*/
type FiltersTrIdx = number;
/**
* Calls the provided callback function in the end of the `yadcf.init()` method.
*
* @since 0.0.1
*
* @remarks This callback function will run before datatables fires its event (i.e. draw/xhr/etc).
* Useful for initializing third parties and/or loading code.
*/
type OnInitComplete = ( args?: any ) => any;
/**
* ISO-2 locale countries.
*
* @since 0.0.1
*/
type ISO2Locales = 'af' | 'ar-DZ' | 'ar' | 'az' | 'be' | 'bg' | 'bs' | 'ca' | 'cs' | 'cy-GB' |
'da' | 'de' | 'el' | 'en-AU' | 'en-GB' | 'en-NZ' | 'eo' | 'es' | 'et' | 'eu' |
'fa' | 'fi' | 'fo' | 'fr-CA' | 'fr-CH' | 'fr' | 'gl' | 'he' | 'hi' | 'hr' |
'hu' | 'hy' | 'id' | 'is' | 'it-CH' | 'it' | 'ja' | 'ka' | 'kk' | 'km' |
'ko' | 'ky' | 'lb' | 'lt' | 'lv' | 'mk' | 'ml' | 'ms' | 'nb' | 'nl-BE' |
'nl' | 'nn' | 'no' | 'pl' | 'pt-BR' | 'pt' | 'rm' | 'ro' | 'ru' | 'sk' |
'sl' | 'sq' | 'sr-SR' | 'sr' | 'sv' | 'ta' | 'th' | 'tj' | 'tr' | 'uk' |
'vi' | 'zh-CN' | 'zh-HK' | 'zh-TW';
/**
* Load localized jQuery UI `datepicker`.
*
* @since 0.0.1
*
* @remarks Requires `jquery-ui-i18n` library.
*/
type JQueryUIDatepickerLocale = '' | ISO2Locales;
/**
* Value represents ***null***, used as argument for `fnFilter` and sent to server.
*
* @since 0.0.1
*
* @remarks Use when `null_check_box` is true.
*/
type NullApiCallValue = string | 'null';
/**
* Value represents ***not null***, used as argument for `fnFilter` and sent to server.
*
* @since 0.0.1
*
* @remarks Use when `null_check_box` is true.
*/
type NotNullApiCallValue = string | '!^@';
//
// Export the YADCF module.
//
export module yadcf {
/**
* Default options.
*
* @since 0.0.1
*
* @property `case_insensitive`
* @property `checkbox_position_after`
* @property `column_data_type`
* @property `custom_range_delimiter`
* @property `date_format`
* @property `datepicker_type`
* @property `exclude_label`
* @property `externally_triggered_checkboxes_button_style_class`
* @property `externally_triggered_checkboxes_function`
* @property `externally_triggered_checkboxes_text`
* @property `filter_match_mode`
* @property `filter_type`
* @property `html_data_type`
* @property `ignore_char`
* @property `language`
* @property `null_label`
* @property `omit_default_label`
* @property `range_data_type`
* @property `range_data_type_delim`
* @property `regex_label`
* @property `reset_button_style_class`
* @property `select_null_option`
* @property `select_type`
* @property `select_type_options`
* @property `sort_as`
* @property `sort_order`
* @property `style_class`
*/
interface DefaultOptions {
case_insensitive?: CaseInsensitive<DefaultOptions['filter_type']>;
checkbox_position_after?: CheckboxPositionAfter<DefaultOptions['filter_type']>;
column_data_type?: ColumnDataType;
custom_range_delimiter?: CustomRangeDelimeter;
date_format?: DateFormat;
datepicker_type?: DatepickerType;
exclude_label?: ExcludeLabel;
externally_triggered_checkboxes_button_style_class?: ExtTriggeredCheckboxesButtonStyleClass;
externally_triggered_checkboxes_function?: ExtTriggeredCheckboxesFunction;
externally_triggered_checkboxes_text?: ExtTriggeredCheckboxesText;
filter_match_mode?: FilterMatchMode<DefaultOptions['filter_type']>;
filter_type?: FilterType;
html_data_type?: HTMLDataType;
ignore_char?: IgnoreChar;
language?: Language;
null_label?: NullLabel;
omit_default_label?: OmitDefaultLabel<DefaultOptions['filter_type']>;
range_data_type?: RangeDataType<DefaultOptions['filter_type']>;
range_data_type_delim?: RangeDataTypeDelimeter<DefaultOptions['filter_type']>;
regex_label?: RegexLabel;
reset_button_style_class?: ResetButtonStyleClass;
select_null_option?: SelectNullOption;
select_type?: SelectType;
select_type_options?: SelectTypeOptions;
sort_as?: SortAs;
sort_order?: SortOrder;
style_class?: StyleClass<DefaultOptions['filter_type']>;
}
/**
* The remaining missing default options.
*
* @since 0.0.1
*
* @property `append_data_to_table_data`
* @property `column_data_render`
* @property `custom_func`
* @property `data`
* @property `data_as_is`
* @property `exclude`
* @property `filter_container_id`
* @property `filter_container_selector`
* @property `filter_default_label`
* @property `filter_delay`
* @property `filter_plugin_options`
* @property `filter_reset_button_text`
* @property `html_data_selector`
* @property `html5_data`
* @property `moment_date_format`
* @property `null_check_box`
* @property `regex_check_box`
* @property `sort_as_custom_func`
* @property `text_data_delimiter`
*/
interface MissingDefaults {
append_data_to_table_data?: AppendDataToTableData;
column_data_render?: ColumnDataRender;
custom_func?: CustomFunc<DefaultOptions['filter_type']>;
data?: Data;
data_as_is?: DataAsIs<DefaultOptions['filter_type']>;
exclude?: ExcludeCheckbox<DefaultOptions['filter_type']>;
filter_container_id?: FilterContainerID;
filter_container_selector?: FilterContainerSelector;
filter_default_label?: FilterDefaultLabel<DefaultOptions['filter_type']>;
filter_delay?: FilterDelay<DefaultOptions['filter_type']>;
filter_plugin_options?: FilterPluginOptions;
filter_reset_button_text?: FilterResetButtonText;
html_data_selector?: HTMLDataSelector<DefaultOptions['filter_type']>;
html5_data?: HTML5Data;
moment_date_format?: DateFormatMoment;
null_check_box?: NullCheckBox<DefaultOptions['filter_type']>;
regex_check_box?: RegexCheckBox<DefaultOptions['filter_type']>;
sort_as_custom_func?: SortAsCustomFunc;
text_data_delimiter?: DataTextDelimeter;
}
/**
* All column parameters together.
*
* @since 0.0.1
*/
type ColumnParameters = ({ 'column_number': ColumnIdx; } | { 'column_selector': ColumnSelector }) & DefaultOptions & MissingDefaults;
/**
* Table parameters.
*
* @since 0.0.1
*
* @property `externally_triggered` — See {@link ExternallyTriggered} for details.
* @property `cumulative_filtering` — See {@link CumulativeFiltering} for details.
* @property `filters_position` — See {@link FiltersPosition} for details.
* @property `filters_tr_index` — See {@link FiltersTrIdx} for details.
* @property `onInitComplete` — See {@link OnInitComplete} for details.
* @property `jquery_ui_datepicker_locale` — See {@link JQueryUIDatepickerLocale} for details.
* @property `null_api_call_value` — See {@link NullApiCallValue} for details.
* @property `not_null_api_call_value` — See {@link NotNullApiCallValue} for details.
*/
interface TableParameters {
externally_triggered?: ExternallyTriggered;
cumulative_filtering?: CumulativeFiltering;
filters_position?: FiltersPosition;
filters_tr_index?: FiltersTrIdx;
onInitComplete?: OnInitComplete;
jquery_ui_datepicker_locale?: JQueryUIDatepickerLocale;
null_api_call_value?: NullApiCallValue;
not_null_api_call_value?: NotNullApiCallValue;
}
/**
* Multiple table filter parameters.
*
* @since 0.0.1
*
* @property `column_number`
* @property `filter_container_id`
*
*/
type MultiTableFilterParams = {
column_number?: [ number ] | Array<number>;
filter_container_id: string;
filter_type: Extract<FilterTypeStyleClass, 'text' | 'select' | 'multi_select'>;
} & ColumnParameters;
/**
* The `exFilterColumn` function accepts an array of tuples for arguments.
*
* @since 0.0.1
*/
type ExFilterColArgs<T = number | string> = [ number, string ] | [ number, string, string ] | [ number, { from: T, to: T }];
/**
* Primary initialization method.
*
* @since 0.0.1
* @static
*
* @param oTable DataTables instance.
* @param options_arg Array of objects found in {@link ColumnParameters}.
* @param params Optional. Global {@link TableParameters}.
*/
function init( oTable: DataTables<any>, options_arg: Array<ColumnParameters>, params?: TableParameters | string ): void;
function autocompleteKeyUP( table_selector_jq_friendly: string, event: Event ): void;
/**
* Reset all filters.
*
* @since 0.0.1
*
* @param table_arg DataTable variable instance.
* @param noRedraw True if you don't want your table reloaded after resetting filter. Otherwise false.
*/
function dateKeyUP( table_selector_jq_friendly: string, date_format: DateFormat, event: Event ): void;
function dateSelectSingle( pDate: Record<string, any> | string, pEvent: Event | string, clear?: 'clear' ): void;
function doFilter( arg: 'clear' | 'exclude', table_selector_jq_friendly: string, column_number: ColumnIdx, filter_match_mode: FilterMatchMode<DefaultOptions['filter_type']> ): void;
function doFilterAutocomplete( arg: 'clear' | Record<string, any>, table_selector_jq_friendly: string, column_number: ColumnIdx, filter_match_mode: FilterMatchMode<DefaultOptions['filter_type']> ): void;
function doFilterCustomDateFunc( arg: 'clear' | Record<string, any>, table_selector_jq_friendly: string , column_number: ColumnIdx ): void;
function doFilterMultiSelect( arg: string, table_selector_jq_friendly: string, column_number: ColumnIdx, filter_match_mode: FilterMatchMode<DefaultOptions['filter_type']> ): void;
function doFilterMultiTables( tablesSelectors: string, event: Event, column_number_str: string, clear?: 'clear' ): void;
function doFilterMultiTablesMultiSelect( tablesSelectors: string, event: Event, column_number_str: string, clear?: 'clear' ): void;
function eventTargetFixUp( pEvent: Event ): void;
/**
* Trigger filters externally and/or programmatically.
*
* @since 0.0.1
*
* @remarks Use to show table with pre-filtered columns.
*
* @param table_arg DataTable variable instance.
* @param col_filter_arr Array of tuples contain column index and what to filter by.
* @param ajaxSource True if using AJAX-sourced data. False if not.
*/
function exFilterColumn( table_arg: DataTables<any>, col_filter_arr: Array<ExFilterColArgs>, ajaxSource: boolean ): void;
/**
* Trigger all available filters.
*
* @since 0.0.1
*
* @remarks Use only when `externally_triggered` is set to true.
*
* @param table_arg DataTable variable instance.
*/
function exFilterExternallyTriggered( table_arg: DataTables<any> ): void;
/**
* Retrieve current column's filtered value.
*
* @since 0.0.1
*
* @param table_arg DataTable variable instance.
* @param column_number Column index number.
*/
function exGetColumnFilterVal<T = FilterTypeRange | 'multi_select'>( table_arg: DataTables<any>, column_number: ColumnIdx ): T extends FilterTypeRange ? object : T extends 'multi_select' ? Array<string> : string;
/**
* Update column filter with new data.
*
* @since 0.0.1
*
* @param table_arg DataTable variable instance.
* @param column_num Column index number.
* @param updatedData Same-structured data to use as update.
*/
function exRefreshColumnFilterWithDataProp( table_arg: DataTables<any>, column_num: ColumnIdx, updatedData: Array<Record<string, any> | string> ): void;
/**
* Reset all filters.
*
* @since 0.0.1
*
* @param table_arg DataTable variable instance.
* @param noRedraw True if you don't your table reloaded after resetting filter. Otherwise false.
*/
function exResetAllFilters( table_arg: DataTables<any>, noRedraw: boolean ): void;
/**
* Reset specific filters.
*
* @since 0.0.1
*
* @param table_arg DataTable variable instance.
* @param columns Column index numbers to target.
* @param noRedraw True if you don't your table reloaded after resetting filter. Otherwise false.
*/
function exResetFilters( table_arg: DataTables<any>, columns: Array<ColumnIdx>, noRedraw: boolean ): void;
function generateTableSelectorJQFriendlyNew( tmpStr: string ): string;
function generateTableSelectorJQFriendly2( obj: Api<any> ): void;
function getOptions<T = ColumnParameters>( table_selector_jq_friendly: string ): Record<keyof T, T[ keyof T ]>;
/**
* Initialize global defaults for all `yadcf` instances.
*
* @since 0.0.1
*
* @param params See {@link DefaultOptions} for details.
*/
function initDefaults<T = DefaultOptions>( params: T ): Record<keyof T, T[ keyof T ]>;
/**
* Creates a filter that will affect multiple tables and/or multiple columns in multiple tables.
*
* @since 0.0.1
*
* @remarks Each array **_must_** have the same length of items.
*
* @example
* // Notice there are 2 tables in the first array AND 2 filter objects in the second.
* yadcf.initMultipleTables( [ oTable1, oTable2 ], [ { ...filter1ArgsForTable1 }, { ...filter2ArgsForTable2 } ] );
*
* @param tablesArray
* @param filtersOptions
*/
function initMultipleTables<T = MultiTableFilterParams>( tablesArray: Array<DataTables<any>>, filtersOptions: Array<Record<keyof T, T[ keyof T ]>> ): void;
/**
* Creates a filter that will affect multiple tables and/or multiple columns in multiple tables.
*
* @since 0.0.1
*
* @param tables DataTables instance.
* @param filtersOptions Array of {@link ColumnParameters}.
*/
function initMultipleColumns<T = ColumnParameters>( table: DataTables<any>, filtersOptions: Array<Record<keyof T, T[ keyof T ]>> ): void;
/**
* Callback function to be fired after `dt.xhr` event finishes.
*
* @since 0.0.1
*/
function initOnDtXhrComplete(): any;
/**
* Set, initialize and refresh any jQuery select plugin with functions.
*
* @since 0.0.1
*
* @remarks jQuery selector will be passed to the user defined function to initialize and refresh the plugin.
*
* @param initFunc Function to initialize plugin.
* @param refreshFunc Function to refresh plugin.
* @param destroyFunc Function to destroy plugin instance.
*/
function initSelectPluginCustomTriggers( initFunc: ( $filterSelector: JQuery ) => any, refreshFunc: ( $filterSelector: JQuery ) => any, destroyFunc: ( $filterSelector: JQuery ) => any ): void;
function nullChecked( ev: Event, table_selector_jq_friendly: string, column_number: ColumnIdx ): void;
function preventDefaultForEnter( evt: Event ): void;
function rangeClear( table_selector_jq_friendly: string, event: Event, column_number: ColumnIdx ): void;
function rangeDateKeyUP( table_selector_jq_friendly: string, date_format: DateFormat, event: Event ): void;
function rangeNumberKeyUP( table_selector_jq_friendly: string, event: Event ): void;
function rangeNumberSliderClear( table_selector_jq_friendly: string, event: Event ): void;
function stopPropagation( evt: Event ): void;
function textKeyUP( ev: Event, table_selector_jq_friendly: string, column_number: ColumnIdx, clear?: 'clear' ): void;
function textKeyUpMultiTables( tablesSelectors: string, event: Event, column_number_str: string, clear?: 'clear' ): void;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment