mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00

Split type.class from CssTypeSelector to CssCompositeSelector, probably support type#id.class selectors Apply review comments, refactor css-selectors internally Applied refactoring, all tests pass, button does not notify changes Add tests for the css selectors parser. Added tests for css-selectors Added basic implementation of mayMatch and changeMap for css match state Implemented TKUnit.assertDeepEqual to check key and key/values in Map and Set Watch for property and pseudoClass changes Add one child group test Add typings for animations Added mechanism to enable/disable listeners for pseudo classes Count listeners instead of checking handlers, reverse subscription and unsubscription
73 lines
1.8 KiB
TypeScript
73 lines
1.8 KiB
TypeScript
declare module "ui/styling/css-selector" {
|
|
import * as parser from "css";
|
|
|
|
/**
|
|
* An interface describing the shape of a type on which the selectors may apply.
|
|
* Note, the ui/core/view.View implements Node.
|
|
*/
|
|
interface Node {
|
|
parent?: Node;
|
|
|
|
id?: string;
|
|
cssType?: string;
|
|
cssClasses?: Set<string>;
|
|
cssPseudoClasses?: Set<string>;
|
|
}
|
|
|
|
interface Declaration {
|
|
property: string;
|
|
value: string;
|
|
}
|
|
|
|
class SelectorCore {
|
|
/**
|
|
* Dynamic selectors depend on attributes and pseudo classes.
|
|
*/
|
|
dynamic: boolean;
|
|
match(node: Node): boolean;
|
|
ruleset: RuleSet;
|
|
}
|
|
|
|
class RuleSet {
|
|
/**
|
|
* Gets the selectors in this ruleset's selector group.
|
|
*/
|
|
selectors: SelectorCore[];
|
|
|
|
/**
|
|
* Gets the key-value list of declarations for the ruleset.
|
|
*/
|
|
declarations: Declaration[];
|
|
}
|
|
|
|
class SelectorsMap {
|
|
constructor(rules: RuleSet[]);
|
|
|
|
/**
|
|
* Get a list of selectors that are likely to match the node.
|
|
*/
|
|
query<T extends Node>(node: T): SelectorsMatch<T>;
|
|
}
|
|
|
|
type ChangeMap<T extends Node> = Map<T, Changes>;
|
|
|
|
interface Changes {
|
|
attributes?: Set<string>;
|
|
pseudoClasses?: Set<string>;
|
|
}
|
|
|
|
class SelectorsMatch<T extends Node> {
|
|
/**
|
|
* Gets the static selectors that match the queried node and the dynamic selectors that may potentially match the queried node.
|
|
*/
|
|
selectors: SelectorCore[];
|
|
|
|
/**
|
|
* Gets a map of nodes to attributes and pseudo classes, that may affect the state of the dynamic
|
|
*/
|
|
changeMap: ChangeMap<T>;
|
|
}
|
|
|
|
export function fromAstNodes(astRules: parser.Node[]): RuleSet[];
|
|
}
|