fluig-types
Version:
Totvs Fluig Types for Typescript
785 lines (775 loc) • 19.9 kB
TypeScript
/** @format */
type FilterItem = Record<string, any>;
type FilterCallback = (data: Record<string, any>) => void;
type FilterEvents = 'fluig.filter.load.complete' | 'fluig.filter.item.added' | 'fluig.filter.beforeItemAdd' | 'fluig.filter.selected' | 'fluig.filter.beforeItemRemove' | 'fluig.filter.itemRemoved' | 'fluig.filter.blur' | 'fluig.filter.closed' | 'fluig.filter.focus' | 'fluig.filter.opened';
/**
* Defines the structure of a table header.
*/
type TableHeader = {
/**
* Title for the table header
*/
title?: string;
/**
* Value sent to the server for ordering
*/
dataorder?: string;
/**
* Default ordering
*/
standard?: boolean;
/**
* CSS class for column width
*/
size?: string;
/**
* Determines if the column is visible
*/
display?: boolean;
};
/**
* Defines the settings for the rendered table.
*/
type TableSettings = {
header: TableHeader[];
/**
* Function to process and format data before rendering
*/
formatData?: (data: any) => any;
/**
* Array with object keys or CSS class for Mustache template
*/
renderContent?: string[] | string;
};
/**
* Defines the settings for the source of the data.
*/
type SourceSettings = {
/**
* API endpoint URL
*/
url: string;
/**
* Resource file type (e.g., application/json)
*/
contentType: string;
/**
* Primary property in API response where data is located
*/
root: string;
/**
* Value used for filtering in the API
*/
pattern: string;
/**
* Number of items returned per request
*/
limit: number;
/**
* Starting index for search results
*/
offset: number;
/**
* Key name for filtering in API
*/
patternKey: string;
/**
* Key name for limiting results in API
*/
limitKey: string;
/**
* Key name for pagination offset in API
*/
offsetKey: string;
};
/**
* Defines the styling options for the component.
*/
type StyleSettings = {
/**
* Selector for autocomplete tag template
*/
templateTag?: string;
/**
* Selector for autocomplete suggestion template
*/
templateSuggestion?: string;
/**
* Selector for autocomplete tip message template
*/
templateTipMessage?: string;
/**
* Class name for tags
*/
autocompleteTagClass?: string;
/**
* CSS class for selected table rows
*/
tableSelectedLineClass?: string;
/**
* Additional styling for the table
*/
tableStyle?: string;
/**
* CSS class for the filter icon
*/
filterIconClass?: string;
};
/**
* Defines the overall filter settings for the component.
*/
type FilterSettings = {
/**
* Key or function to determine displayed value of a suggestion
*/
displayKey: string;
/**
* Height of the table container
*/
tableHeight?: string;
/**
* Enables multi-selection
*/
multiSelect?: boolean;
/**
* Delay before sending search request
*/
searchTimeout?: number;
/**
* Minimum character length to trigger suggestions
*/
minLength?: number;
/**
* Maximum width of a tag
*/
tagMaxWidth?: string | number;
/**
* Source of data (API settings or local array)
*/
source: SourceSettings | any[];
/**
* Table configuration
*/
table: TableSettings;
/**
* Styling options
*/
style?: StyleSettings;
};
declare namespace Filter {
/**
* Add an item.
*
* @param {FilterItem} item The tag to add.
* @returns {void}
*/
function add(item: FilterItem): void;
/**
* Removes all items.
*
* @returns {void}
*/
function removeAll(): void;
/**
* Return selected items.
*
* @returns {FilterItem | FilterItem[]} The selected tags.
*/
function getSelectedItems(): FilterItem | FilterItem[];
/**
* Reload the filter component with new settings.
*
* @returns {void}
*/
function reload(settings: FilterSettings): void;
/**
* Applies the focus event to the component by opening the list of suggestions for searching.
*
* @returns {void}
*/
function focus(): void;
/**
* Disables the filter component, not allowing the tags to be edited.
*
* @param {boolean} disable `true` to disable the filter, `false` to enable it.
* @returns {void}
*/
function disable(disable: boolean): void;
/**
* Open the list of suggestions for searching.
*/
function open(): void;
/**
* Close the list of suggestions for searching.
*/
function close(): void;
/**
* Listens to filter events.
*
* WARN: Avoid two filters in the same parent.
* Do not place more than one filter under the same parent,
* as events will be listened to by all sibling filters.
*
* ```markdown
* # Filter Events
* 1. **fluig.filter.load.complete**
* - Triggered just after the filter component is ready.
* 2. **fluig.filter.item.added**
* - Triggered just after an item is added to the filter.
* 3. **fluig.filter.beforeItemAdd**
* - Triggered just before an item is added, allowing pre-validation or modification.
* 4. **fluig.filter.selected**
* - Triggered just after an item is selected from the list.
* 5. **fluig.filter.beforeItemRemove**
* - Triggered just before an item is removed from the filter, allowing pre-validation.
* 6. **fluig.filter.itemRemoved**
* - Triggered just after an item is removed from the filter.
* 7. **fluig.filter.blur**
* - Triggered when the filter component loses focus.
* 8. **fluig.filter.closed**
* - Triggered just after the filter component is closed.
* 9. **fluig.filter.focus**
* - Triggered when the filter component gains focus (e.g., clicked or opened).
* 10. **fluig.filter.opened**
* - Triggered just after the filter component is opened.
* ```
*
* @param {String} event Event name
* @param {FilterCallback} callback Function to be called when the event is triggered
*/
function on(event: FilterEvents, callback: FilterCallback): void;
}
declare function reloadZoomFilterValues(inputName: string, filterValues: any): void; // TODO: Add arguments
declare function removedZoomItem(): void; // TODO: Add arguments
/**
* Get the record selected by the user
* @param {Object} selectedItem The dataset value selected by the user in the zoom screen
*
*/
declare function setSelectedZoomItem<T extends Record<string, any>>(selectedItem: { type: string } & T): void;
/**
* The FLUIGC object provides a set of functions to create and manipulate
* components and elements in the DOM.
*/
declare namespace FLUIGC {
// ajax: function ajax(c, d)
// autocomplete: function autocomplete(c, d, e)
// backToBottom: function backToBottom(a)
// backToTop: function backToTop(a)
// calendar: function calendar(a, d)
// copy: function copy(c, d, e)
// datatable: function datatable(e, f, g)
// editable: function editable(a, e)
// icons: function icons()
// function loading(a, d);
// message: Object { alert: i(d, e), confirm: j(d, e), error: k(d, e) }
// messagePage: function messagePage(a, d)
// modal: function modal(f, g)
// notification: function notification(d)
// password: function password(a, c)
// periodicalExecutor: function periodicalExecutor(a, c)
// popover: function popover(a, c)
// rightbar: function rightbar(a)
/**
* The Storage provides mechanisms by which browsers can securely store
* key/value pairs, in a much more intuitive fashion than using cookies.
*
* `sessionStorage` maintains a separate storage area for each given origin
* that's available for the duration of the page session
* (as long as the browser is open, including page reloads and restores).
*/
namespace sessionStorage {
/**
* Stores an item.
*/
function setItem(key: string, value: any): void;
/**
* Remove any items.
*/
function removeItem(key: string): void;
/**
* Returns an item.
*/
/* eslint-disable-next-line @definitelytyped/no-unnecessary-generics */
function getItem<T>(key: string): T;
/**
* Clears all stored data.
*/
function clear(): void;
}
/**
* The Storage provides mechanisms by which browsers can securely store
* key/value pairs, in a much more intuitive fashion than using cookies.
*
* `localStorage` maintains a separate storage area for each given origin
* that persists even when the browser is closed and reopened.
*/
namespace localStorage {
/**
* Stores an item.
*/
function setItem(key: string, value: any): void;
/**
* Remove any items.
*/
function removeItem(key: string): void;
/**
* Returns an item.
*/
/* eslint-disable-next-line @definitelytyped/no-unnecessary-generics */
function getItem<T>(key: string): T;
/**
* Clears all stored data.
*/
function clear(): void;
}
// slider: Object { init: a(a, c), getValue: c(a), setValue: d(a, c, d) , … }
// switcher: Object { init: c(a), getState: d(a), setTrue: e(a) , … }
// tagscloud: function tagscloud(a, c, d)
// timeInteraction: Object { init: init(f), destroy: destroy() }
// toast: function toast(a)
// utilities: Object { ctrlIsPressed: ctrlIsPressed(a), parseBoolean: parseBoolean(a), randomUUID: randomUUID(), … }
/**
* Create a new filter.
*
* If you want to create forms using the style guide and add the filter
* component, you'll need to import the minified CSS and JavaScript files:
*
* ```html
* <link rel="stylesheet" type="text/css" href="/style-guide/css/fluig-style-guide-filter.min.css">
* <script src="/style-guide/js/fluig-style-guide-filter.min.js"></script>
* ```
* To use filter in widgets, you must inform the following line in the application.info file of your widget:
*
* ```properties
* application.resource.component.1=fluigfilter
* ```
*
* @param {HTMLElement | String} target The target element or selector.
* @param {FilterSettings} settings The filter settings.
* @returns {Filter} The filter object.
*/
function filter(target: HTMLElement | string, settings: FilterSettings): typeof Filter;
}
/**
* The WCMAPI object provides information about the current environment.
*/
declare namespace WCMAPI {
/**
* Check if the browser is an Apple mobile device.
* @returns {boolean} `true` if the browser is an Apple mobile device, `false` otherwise.
*/
function _isAppleMobile(): boolean;
/**
* Check if the browser is a mobile device.
* @returns {boolean} `true` if the browser is a mobile device, `false` otherwise.
*/
function _isMobile(): boolean;
/**
* get the browser name
* @returns {string} The browser's name
*/
function getBrowserName(): string;
/**
* get the browser version
* @returns {number} The browser's version
*/
function getBrowserVersion(): number;
/**
* get the default delays
* @returns {number} The default delays
*/
function getDefaltDelays(): number;
/**
* Check if the browser is a mobile device.
* @returns {boolean} `true` if the browser is a mobile device, `false` otherwise.
*/
function isMobileAppMode(): boolean;
/**
* Set the default delays
* @param {number} delay The default delays
* @returns {void}
*/
function setDefaltDelays(delay: number): void;
/**
* Aplication code
* @type {String}
*/
const applicationCode: string;
/**
* Browser name
* @type {String}
*/
const browserName: string;
/**
* Browser version
* @type {Number}
*/
const browserVersion: number;
/**
* Backgroud color (CSS)
* @type {String}
*/
const colorBackground: string;
/**
* Menu color (CSS)
* @type {String}
*/
const colorMenu: string;
/**
* Context path
* @type {String}
*/
const contextPath: string;
/**
* Debug mode
* @type {Boolean}
*/
const debug: boolean;
/**
* Default delays
* @type {Number}
*/
const defaltDelays: number;
/**
* Enabled features
* @type {unknown[]}
*/
const enabledFeatures: unknown[];
/**
* Environment type
* @type {String}
*/
const envType: string;
/**
* Fluig version name
* @type {String}
*/
const fluigInstanceVersionName: string;
/**
* If the environment is a PaaS
* @type {Boolean}
*/
const fluigPaas: boolean;
/**
* Fluig version number
* @type {String}
*/
const fluigVersion: string;
/**
* Fluig version build
* @type {String}
*/
const fluigVersionBuild: string;
/**
* Fluig version status
* @type {String}
*/
const fluigVersionStatus: string;
/**
* Fluig version status info
* @type {String}
*/
const fluigVersionStatusInfo: string;
/**
* Friendly URL
* @type {String}
*/
const friendlyURL: string;
/**
* Google analytics account
* @type {String}
*/
const googleAnalyticsAccount: string;
/**
* Google analytics enabled
* @type {Boolean}
*/
const googleAnalyticsEnabled: boolean;
/**
* Home page code
* @type {String}
*/
const homePageCode: string;
/**
* Image background
* @type {'false' | 'true'}
*/
const imageBackground: 'false' | 'true';
/**
* Image logo
* @type {'false' | 'true'}
*/
const imageLogo: 'false' | 'true';
/**
* Page is being edited
* @type {'false' | 'true'}
*/
const isEditMode: 'false' | 'true';
/**
* Feature server enabled
* @type {Boolean}
*/
const isFeatureServerEnabled: boolean;
/**
* Legacy apps enabled
* @type {Boolean}
*/
const isLegacyAppsEnabled: boolean;
/**
* Legacy LMS enabled
* @type {Boolean}
*/
const isLegacyLMSEnabled: boolean;
/**
* Is new builder
* @type {Boolean}
*/
const isNewBuilder: boolean;
/**
* Is preview mode
* @type {'false' | 'true'}
*/
const isPreviewMode: 'false' | 'true';
/**
* Is responsive layout
* @type {Boolean}
*/
const isResponsiveLayout: boolean;
/**
* Is SAML enabled
* @type {Boolean}
*/
const isSAMLEnabled: boolean;
/**
* List of listeners
* @type {Object}
*/
const listeners: {
'change-system-properties': Record<string, unknown>[];
'keep-theme-responsive': Record<string, unknown>[];
'switch-to-old-theme': Record<string, unknown>[];
'toggle-main-menu': Record<string, unknown>[];
closePopoverNotify: Record<string, unknown>[];
closePopoverProfile: Record<string, unknown>[];
countunreadalerts: Record<string, unknown>[];
documentCheckOut: Record<string, unknown>[];
logoff: Record<string, unknown>[];
refreshNotificationList: Record<string, unknown>[];
undefined: unknown[];
};
/**
* Locale
* @type {'es' | 'pt_BR' | 'en_US'}
*/
const locale: 'es' | 'pt_BR' | 'en_US';
/**
* Locale display name
* @type {'português (Brasil)' | 'string' | 'string'}
*/
const localeDisplayName: 'português (Brasil)' | 'string' | 'string';
/**
* Locale language
* @type {'pt' | 'es' | 'en'}
*/
const noCode: boolean;
/**
* Nocode active
* @type {Boolean}
*/
const nocodeActive: boolean;
/**
* Organization code
* @type {String}
*/
const organizationId: string;
/**
* Page auth type
* @type {String}
*/
const pageAuthType: string;
/**
* Page code
* @type {String}
*/
const pageCode: string;
/**
* Page id
* @type {String}
*/
const pageId: string;
/**
* Page is internal
* @type {Boolean}
*/
const pageIsInternal: boolean;
/**
* Page layout
* @type {String}
*/
const pageLayout: string;
/**
* Page title
* @type {String}
*/
const pageTitle: string;
/**
* Page type
* @type {String}
*/
const pageType: string;
/**
* Parent page code
* @type {String}
*/
const parentPageCode: string;
/**
* Process context path
* @type {String}
*/
const protectedContextPath: string;
/**
* Replication server centralized
* @type {Boolean}
*/
const replicationServerCentralized: boolean;
/**
* Replication server enabled
* @type {Boolean}
*/
const replicationServerEnabled: boolean;
/**
* Search timerj
* @type {unknown | null}
*/
const searchTimer: unknown | null;
/**
* Server context URL
* @type {String}
*/
const serverContextURL: string;
/**
* Server URL
* @type {String}
*/
const serverURL: string;
/**
* Session expired
* @type {Boolean}
*/
const sessExpired: boolean;
/**
* Session timeout
* @type {boolean}
*/
const sessTimeoutExpInt: boolean;
/**
* Session timeout message
* @type {Boolean}
*/
const sessTimeoutMsg: boolean;
/**
* Space ID
* @type {Boolean}
*/
const spaceId: string;
/**
* Tenant code
* @type {String}
*/
const tenantCode: string;
/**
* Tenant path
* @type {String}
*/
const tenantPATH: string;
/**
* Tenant URI
* @type {String}
*/
const tenantURI: string;
/**
* Tenant URL
* @type {String}
*/
const tenantURL: string;
/**
* Theme ID
* @type {String}
*/
const themeId: string;
/**
* Timezone
* @type {String}
*/
const timezone: string;
/**
* Upload URL
* @type {String}
*/
const uploadURL: string;
/**
* User full name
* @type {String}
*/
const user: string;
/**
* User bar
* @type {uknown | null}
*/
const userBar: unknown | null;
/**
* User Code
* @type {String}
*/
const userCode: string;
/**
* User email
* @type {String}
*/
const userEmail: string;
/**
* User ID
* @type {String}
*/
const userId: string;
/**
* User is logged
* @type {Boolean}
*/
const userIsLogged: boolean;
/**
* User location code
* @type {String}
*/
const userLocationCode: string;
/**
* User location ID
* @type {String}
*/
const userLocationId: string;
/**
* User location URL
* @type {String}
*/
const userLocationUrl: string;
/**
* User login
* @type {String}
*/
const userLogin: string;
/**
* User type
* @type {String}
*/
const userType: string;
/**
* Version
* @type {String}
*/
const version: string;
}
interface Window {
FLUIGC: typeof FLUIGC;
WCMAPI: typeof WCMAPI;
}