powerpagestoolkit
Version:
Reference, manipulate, and engage with Power Pages sites through the nodes in the DOM; use a variety of custom methods that allow customizing your power pages site quicker and easier.
47 lines (46 loc) • 2.13 kB
TypeScript
/// <reference path="../globals.d.ts" />
/**
* Centralizes all PowerPages platform-specific DOM conventions.
*
* When Microsoft changes how PowerPages renders controls, this is the only
* file that needs to be updated. Consumers can also import these to write
* their own selectors that stay in sync with the library's assumptions.
*/
/** CSS selector strings for locating PowerPages-rendered DOM elements */
export declare const Selectors: {
/** Label element for a given field: `#${elementId}_label` */
label: (elementId: string) => string;
/** Attribute selector for the date value node inside a date control */
dateFormatNode: string;
/** Attribute selector for a section or tab by logical name */
sectionOrTab: (name: string) => string;
/** ID selector for a control by its logical name */
controlById: (id: string) => string;
/**
* Selector for detecting boolean radio direct children of a container.
* Used during init to determine if a field is a boolean radio group.
*/
booleanRadioChildren: (parentId: string) => string;
/** Selector for the truthy (Yes) radio option in a boolean radio group */
truthyRadio: string;
/** Selector for the falsy (No) radio option in a boolean radio group */
falsyRadio: string;
};
/** Predicate functions for detecting PowerPages-specific DOM characteristics */
export declare const Detect: {
/**
* Returns true if an element ID matches the PCF control container naming convention.
* PowerPages prefixes PCF wrapper element IDs with "pcfcontrol" (case-insensitive).
*/
isPCFControl: (id: string | undefined) => boolean;
/**
* Returns true if the element is a date input in a PowerPages form.
* PowerPages sets `data-type="date"` on date input elements.
*/
isDateInput: (element: HTMLElement) => boolean;
/**
* Returns true if the element's parent hosts a PCF-based multiselect control.
* PowerPages renders multiselect option sets via a PCF whose container class includes "multiselect".
*/
isMultiSelect: (element: HTMLElement) => boolean;
};