first commit

This commit is contained in:
Stefan Hacker
2026-04-03 09:38:48 +02:00
commit 37ad745546
47450 changed files with 3120798 additions and 0 deletions
@@ -0,0 +1,22 @@
import { KeyCodes } from '../../Utilities';
export type KeytipTransitionModifier = typeof KeyCodes.shift | typeof KeyCodes.ctrl | typeof KeyCodes.alt | typeof KeyCodes.leftWindow;
export interface IKeytipTransitionKey {
key: string;
modifierKeys?: KeytipTransitionModifier[];
}
/**
* Tests for equality between two IKeytipTransitionKeys.
*
* @param key1 - First IKeytipTransitionKey.
* @param key2 - Second IKeytipTransitionKey.
* @returns T/F if the transition keys are equal.
*/
export declare function transitionKeysAreEqual(key1: IKeytipTransitionKey, key2: IKeytipTransitionKey): boolean;
/**
* Tests if 'key' is present in 'keys'.
*
* @param keys - Array of IKeytipTransitionKey.
* @param key - IKeytipTransitionKey to find in 'keys'.
* @returns T/F if 'keys' contains 'key'.
*/
export declare function transitionKeysContain(keys: IKeytipTransitionKey[], key: IKeytipTransitionKey): boolean;
@@ -0,0 +1,46 @@
import { find } from '../../Utilities';
/**
* Tests for equality between two IKeytipTransitionKeys.
*
* @param key1 - First IKeytipTransitionKey.
* @param key2 - Second IKeytipTransitionKey.
* @returns T/F if the transition keys are equal.
*/
export function transitionKeysAreEqual(key1, key2) {
if (key1.key !== key2.key) {
return false;
}
var mod1 = key1.modifierKeys;
var mod2 = key2.modifierKeys;
if ((!mod1 && mod2) || (mod1 && !mod2)) {
// Not equal if one modifier is defined and the other isn't
return false;
}
if (mod1 && mod2) {
if (mod1.length !== mod2.length) {
return false;
}
// Sort both arrays
mod1 = mod1.sort();
mod2 = mod2.sort();
for (var i = 0; i < mod1.length; i++) {
if (mod1[i] !== mod2[i]) {
return false;
}
}
}
return true;
}
/**
* Tests if 'key' is present in 'keys'.
*
* @param keys - Array of IKeytipTransitionKey.
* @param key - IKeytipTransitionKey to find in 'keys'.
* @returns T/F if 'keys' contains 'key'.
*/
export function transitionKeysContain(keys, key) {
return !!find(keys, function (transitionKey) {
return transitionKeysAreEqual(transitionKey, key);
});
}
//# sourceMappingURL=IKeytipTransitionKey.js.map
@@ -0,0 +1 @@
{"version":3,"file":"IKeytipTransitionKey.js","sourceRoot":"../src/","sources":["utilities/keytips/IKeytipTransitionKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,iBAAiB,CAAC;AAajD;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAA0B,EAAE,IAA0B;IAC3F,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,GAAG,EAAE,CAAC;QAC1B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC;IAC7B,IAAI,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC;IAE7B,IAAI,CAAC,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,2DAA2D;QAC3D,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,IAAI,IAAI,IAAI,EAAE,CAAC;QACjB,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;YAChC,OAAO,KAAK,CAAC;QACf,CAAC;QAED,mBAAmB;QACnB,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,IAAI,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACrC,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxB,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,IAA4B,EAAE,GAAyB;IAC3F,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,UAAC,aAAmC;QACtD,OAAO,sBAAsB,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { find, KeyCodes } from '../../Utilities';\n\nexport type KeytipTransitionModifier =\n | typeof KeyCodes.shift\n | typeof KeyCodes.ctrl\n | typeof KeyCodes.alt\n | typeof KeyCodes.leftWindow;\n\nexport interface IKeytipTransitionKey {\n key: string;\n modifierKeys?: KeytipTransitionModifier[];\n}\n\n/**\n * Tests for equality between two IKeytipTransitionKeys.\n *\n * @param key1 - First IKeytipTransitionKey.\n * @param key2 - Second IKeytipTransitionKey.\n * @returns T/F if the transition keys are equal.\n */\nexport function transitionKeysAreEqual(key1: IKeytipTransitionKey, key2: IKeytipTransitionKey): boolean {\n if (key1.key !== key2.key) {\n return false;\n }\n\n let mod1 = key1.modifierKeys;\n let mod2 = key2.modifierKeys;\n\n if ((!mod1 && mod2) || (mod1 && !mod2)) {\n // Not equal if one modifier is defined and the other isn't\n return false;\n }\n\n if (mod1 && mod2) {\n if (mod1.length !== mod2.length) {\n return false;\n }\n\n // Sort both arrays\n mod1 = mod1.sort();\n mod2 = mod2.sort();\n for (let i = 0; i < mod1.length; i++) {\n if (mod1[i] !== mod2[i]) {\n return false;\n }\n }\n }\n\n return true;\n}\n\n/**\n * Tests if 'key' is present in 'keys'.\n *\n * @param keys - Array of IKeytipTransitionKey.\n * @param key - IKeytipTransitionKey to find in 'keys'.\n * @returns T/F if 'keys' contains 'key'.\n */\nexport function transitionKeysContain(keys: IKeytipTransitionKey[], key: IKeytipTransitionKey): boolean {\n return !!find(keys, (transitionKey: IKeytipTransitionKey) => {\n return transitionKeysAreEqual(transitionKey, key);\n });\n}\n"]}
+45
View File
@@ -0,0 +1,45 @@
import type { IKeytipProps } from '../../Keytip';
export interface IKeytipConfig {
keytips: IKeytipConfigItem[];
}
export interface IKeytipConfigItem {
/**
* Key Sequence for this keytip only
* If sequence is not defined it will be derived from the content string
*/
sequence?: string;
/**
* Content for the keytip
*/
content: string;
/**
* Identifier for the keytip, to be used to access in the configMap
*/
id: string;
/**
* Optional props in IKeytipProps
*/
optionalProps?: Partial<IKeytipProps>;
/**
* Children keytips of this keytip
*/
children?: IKeytipConfigItem[];
}
export interface IKeytipConfigMap {
[id: string]: IKeytipProps;
}
/**
* Builds a map of ID to IKeytipProps
*
* @param config - IKeytipConfig object
* @returns Config map
*/
export declare function buildKeytipConfigMap(config: IKeytipConfig): IKeytipConfigMap;
/**
* Constructs a keytip from an IKeytipConfigItem and puts it in the configMap
*
* @param configMap - IKeytipConfigMap to store the keytip in
* @param parentSequence - string of the parent keytip
* @param keytip - IKeytipConfigItem data
*/
export declare function constructKeytip(configMap: IKeytipConfigMap, parentSequence: string[], keytip: IKeytipConfigItem): void;
+38
View File
@@ -0,0 +1,38 @@
import { __assign } from "tslib";
/**
* Builds a map of ID to IKeytipProps
*
* @param config - IKeytipConfig object
* @returns Config map
*/
export function buildKeytipConfigMap(config) {
var configMap = {};
for (var _i = 0, _a = config.keytips; _i < _a.length; _i++) {
var keytip = _a[_i];
constructKeytip(configMap, [], keytip);
}
return configMap;
}
/**
* Constructs a keytip from an IKeytipConfigItem and puts it in the configMap
*
* @param configMap - IKeytipConfigMap to store the keytip in
* @param parentSequence - string of the parent keytip
* @param keytip - IKeytipConfigItem data
*/
export function constructKeytip(configMap, parentSequence, keytip) {
// Compute full key sequence
var sequence = keytip.sequence ? keytip.sequence : keytip.content.toLocaleLowerCase();
var keytipSequence = parentSequence.concat(sequence);
// Save props in configMap
var keytipProps = __assign(__assign({}, keytip.optionalProps), { keySequences: keytipSequence, content: keytip.content });
configMap[keytip.id] = keytipProps;
if (keytip.children) {
for (var _i = 0, _a = keytip.children; _i < _a.length; _i++) {
var child = _a[_i];
// Create keytips for all children
constructKeytip(configMap, keytipSequence, child);
}
}
}
//# sourceMappingURL=KeytipConfig.js.map
@@ -0,0 +1 @@
{"version":3,"file":"KeytipConfig.js","sourceRoot":"../src/","sources":["utilities/keytips/KeytipConfig.ts"],"names":[],"mappings":";AAsCA;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAqB;IACxD,IAAM,SAAS,GAAqB,EAAE,CAAC;IAEvC,KAAqB,UAAc,EAAd,KAAA,MAAM,CAAC,OAAO,EAAd,cAAc,EAAd,IAAc,EAAE,CAAC;QAAjC,IAAM,MAAM,SAAA;QACf,eAAe,CAAC,SAAS,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,SAA2B,EAC3B,cAAwB,EACxB,MAAyB;IAEzB,4BAA4B;IAC5B,IAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;IACxF,IAAM,cAAc,GAAG,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEvD,0BAA0B;IAC1B,IAAM,WAAW,yBAAsB,MAAM,CAAC,aAAa,KAAE,YAAY,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,GAAE,CAAC;IACrH,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC;IAEnC,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,KAAoB,UAAe,EAAf,KAAA,MAAM,CAAC,QAAQ,EAAf,cAAe,EAAf,IAAe,EAAE,CAAC;YAAjC,IAAM,KAAK,SAAA;YACd,kCAAkC;YAClC,eAAe,CAAC,SAAS,EAAE,cAAc,EAAE,KAAK,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import type { IKeytipProps } from '../../Keytip';\n\nexport interface IKeytipConfig {\n keytips: IKeytipConfigItem[];\n}\n\nexport interface IKeytipConfigItem {\n /**\n * Key Sequence for this keytip only\n * If sequence is not defined it will be derived from the content string\n */\n sequence?: string;\n\n /**\n * Content for the keytip\n */\n content: string;\n\n /**\n * Identifier for the keytip, to be used to access in the configMap\n */\n id: string;\n\n /**\n * Optional props in IKeytipProps\n */\n optionalProps?: Partial<IKeytipProps>;\n\n /**\n * Children keytips of this keytip\n */\n children?: IKeytipConfigItem[];\n}\n\nexport interface IKeytipConfigMap {\n [id: string]: IKeytipProps;\n}\n\n/**\n * Builds a map of ID to IKeytipProps\n *\n * @param config - IKeytipConfig object\n * @returns Config map\n */\nexport function buildKeytipConfigMap(config: IKeytipConfig): IKeytipConfigMap {\n const configMap: IKeytipConfigMap = {};\n\n for (const keytip of config.keytips) {\n constructKeytip(configMap, [], keytip);\n }\n\n return configMap;\n}\n\n/**\n * Constructs a keytip from an IKeytipConfigItem and puts it in the configMap\n *\n * @param configMap - IKeytipConfigMap to store the keytip in\n * @param parentSequence - string of the parent keytip\n * @param keytip - IKeytipConfigItem data\n */\nexport function constructKeytip(\n configMap: IKeytipConfigMap,\n parentSequence: string[],\n keytip: IKeytipConfigItem,\n): void {\n // Compute full key sequence\n const sequence = keytip.sequence ? keytip.sequence : keytip.content.toLocaleLowerCase();\n const keytipSequence = parentSequence.concat(sequence);\n\n // Save props in configMap\n const keytipProps: IKeytipProps = { ...keytip.optionalProps, keySequences: keytipSequence, content: keytip.content };\n configMap[keytip.id] = keytipProps;\n\n if (keytip.children) {\n for (const child of keytip.children) {\n // Create keytips for all children\n constructKeytip(configMap, keytipSequence, child);\n }\n }\n}\n"]}
@@ -0,0 +1,18 @@
export declare const KTP_PREFIX = "ktp";
export declare const KTP_SEPARATOR = "-";
export declare const KTP_FULL_PREFIX: string;
export declare const DATAKTP_TARGET = "data-ktp-target";
export declare const DATAKTP_EXECUTE_TARGET = "data-ktp-execute-target";
export declare const DATAKTP_ARIA_TARGET = "data-ktp-aria-target";
export declare const KTP_LAYER_ID = "ktp-layer-id";
export declare const KTP_ARIA_SEPARATOR = ", ";
export declare namespace KeytipEvents {
const KEYTIP_ADDED = "keytipAdded";
const KEYTIP_REMOVED = "keytipRemoved";
const KEYTIP_UPDATED = "keytipUpdated";
const PERSISTED_KEYTIP_ADDED = "persistedKeytipAdded";
const PERSISTED_KEYTIP_REMOVED = "persistedKeytipRemoved";
const PERSISTED_KEYTIP_EXECUTE = "persistedKeytipExecute";
const ENTER_KEYTIP_MODE = "enterKeytipMode";
const EXIT_KEYTIP_MODE = "exitKeytipMode";
}
+21
View File
@@ -0,0 +1,21 @@
export var KTP_PREFIX = 'ktp';
export var KTP_SEPARATOR = '-';
export var KTP_FULL_PREFIX = KTP_PREFIX + KTP_SEPARATOR;
export var DATAKTP_TARGET = 'data-ktp-target';
export var DATAKTP_EXECUTE_TARGET = 'data-ktp-execute-target';
export var DATAKTP_ARIA_TARGET = 'data-ktp-aria-target';
export var KTP_LAYER_ID = 'ktp-layer-id';
export var KTP_ARIA_SEPARATOR = ', ';
// Events
export var KeytipEvents;
(function (KeytipEvents) {
KeytipEvents.KEYTIP_ADDED = 'keytipAdded';
KeytipEvents.KEYTIP_REMOVED = 'keytipRemoved';
KeytipEvents.KEYTIP_UPDATED = 'keytipUpdated';
KeytipEvents.PERSISTED_KEYTIP_ADDED = 'persistedKeytipAdded';
KeytipEvents.PERSISTED_KEYTIP_REMOVED = 'persistedKeytipRemoved';
KeytipEvents.PERSISTED_KEYTIP_EXECUTE = 'persistedKeytipExecute';
KeytipEvents.ENTER_KEYTIP_MODE = 'enterKeytipMode';
KeytipEvents.EXIT_KEYTIP_MODE = 'exitKeytipMode';
})(KeytipEvents || (KeytipEvents = {}));
//# sourceMappingURL=KeytipConstants.js.map
@@ -0,0 +1 @@
{"version":3,"file":"KeytipConstants.js","sourceRoot":"../src/","sources":["utilities/keytips/KeytipConstants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,UAAU,GAAG,KAAK,CAAC;AAChC,MAAM,CAAC,IAAM,aAAa,GAAG,GAAG,CAAC;AACjC,MAAM,CAAC,IAAM,eAAe,GAAG,UAAU,GAAG,aAAa,CAAC;AAC1D,MAAM,CAAC,IAAM,cAAc,GAAG,iBAAiB,CAAC;AAChD,MAAM,CAAC,IAAM,sBAAsB,GAAG,yBAAyB,CAAC;AAChE,MAAM,CAAC,IAAM,mBAAmB,GAAG,sBAAsB,CAAC;AAC1D,MAAM,CAAC,IAAM,YAAY,GAAG,cAAc,CAAC;AAC3C,MAAM,CAAC,IAAM,kBAAkB,GAAG,IAAI,CAAC;AAEvC,SAAS;AACT,MAAM,KAAW,YAAY,CAS5B;AATD,WAAiB,YAAY;IACd,yBAAY,GAAG,aAAa,CAAC;IAC7B,2BAAc,GAAG,eAAe,CAAC;IACjC,2BAAc,GAAG,eAAe,CAAC;IACjC,mCAAsB,GAAG,sBAAsB,CAAC;IAChD,qCAAwB,GAAG,wBAAwB,CAAC;IACpD,qCAAwB,GAAG,wBAAwB,CAAC;IACpD,8BAAiB,GAAG,iBAAiB,CAAC;IACtC,6BAAgB,GAAG,gBAAgB,CAAC;AACnD,CAAC,EATgB,YAAY,KAAZ,YAAY,QAS5B","sourcesContent":["export const KTP_PREFIX = 'ktp';\nexport const KTP_SEPARATOR = '-';\nexport const KTP_FULL_PREFIX = KTP_PREFIX + KTP_SEPARATOR;\nexport const DATAKTP_TARGET = 'data-ktp-target';\nexport const DATAKTP_EXECUTE_TARGET = 'data-ktp-execute-target';\nexport const DATAKTP_ARIA_TARGET = 'data-ktp-aria-target';\nexport const KTP_LAYER_ID = 'ktp-layer-id';\nexport const KTP_ARIA_SEPARATOR = ', ';\n\n// Events\nexport namespace KeytipEvents {\n export const KEYTIP_ADDED = 'keytipAdded';\n export const KEYTIP_REMOVED = 'keytipRemoved';\n export const KEYTIP_UPDATED = 'keytipUpdated';\n export const PERSISTED_KEYTIP_ADDED = 'persistedKeytipAdded';\n export const PERSISTED_KEYTIP_REMOVED = 'persistedKeytipRemoved';\n export const PERSISTED_KEYTIP_EXECUTE = 'persistedKeytipExecute';\n export const ENTER_KEYTIP_MODE = 'enterKeytipMode';\n export const EXIT_KEYTIP_MODE = 'exitKeytipMode';\n}\n"]}
+93
View File
@@ -0,0 +1,93 @@
import type { IKeytipProps } from '../../Keytip';
export interface IUniqueKeytip {
uniqueID: string;
keytip: IKeytipProps;
}
/**
* This class is responsible for handling registering, updating, and unregistering of keytips
*/
export declare class KeytipManager {
private static _instance;
keytips: {
[key: string]: IUniqueKeytip;
};
persistedKeytips: {
[key: string]: IUniqueKeytip;
};
sequenceMapping: {
[key: string]: IKeytipProps;
};
inKeytipMode: boolean;
shouldEnterKeytipMode: boolean;
delayUpdatingKeytipChange: boolean;
/**
* Static function to get singleton KeytipManager instance
*
* @returns Singleton KeytipManager instance
*/
static getInstance(): KeytipManager;
/**
* Initialization code to set set parameters to define
* how the KeytipManager handles keytip data.
*
* @param delayUpdatingKeytipChange - T/F if we should delay notifiying keytip subscribers
* of keytip changes
*/
init(delayUpdatingKeytipChange: boolean): void;
/**
* Registers a keytip
*
* @param keytipProps - Keytip to register
* @param persisted - T/F if this keytip should be persisted, default is false
* @returns Unique ID for this keytip
*/
register(keytipProps: IKeytipProps, persisted?: boolean): string;
/**
* Update a keytip
*
* @param keytipProps - Keytip to update
* @param uniqueID - Unique ID of this keytip
*/
update(keytipProps: IKeytipProps, uniqueID: string): void;
/**
* Unregisters a keytip
*
* @param keytipToRemove - IKeytipProps of the keytip to remove
* @param uniqueID - Unique ID of this keytip
* @param persisted - T/F if this keytip should be persisted, default is false
*/
unregister(keytipToRemove: IKeytipProps, uniqueID: string, persisted?: boolean): void;
/**
* Manual call to enter keytip mode
*/
enterKeytipMode(): void;
/**
* Manual call to exit keytip mode
*/
exitKeytipMode(): void;
/**
* Gets all IKeytipProps from this.keytips
*
* @returns All keytips stored in the manager
*/
getKeytips(): IKeytipProps[];
/**
* Adds the overflowSetSequence to the keytipProps if its parent keytip also has it
*
* @param keytipProps - Keytip props to add overflowSetSequence to if necessary
* @returns - Modified keytip props, if needed to be modified
*/
addParentOverflow(keytipProps: IKeytipProps): IKeytipProps;
/**
* Public function to bind for overflow items that have a submenu
*/
menuExecute(overflowButtonSequences: string[], keytipSequences: string[]): void;
/**
* Creates an IUniqueKeytip object
*
* @param keytipProps - IKeytipProps
* @param uniqueID - Unique ID, will default to the next unique ID if not passed
* @returns IUniqueKeytip object
*/
private _getUniqueKtp;
}
+180
View File
@@ -0,0 +1,180 @@
import { __assign, __spreadArray } from "tslib";
import { EventGroup, getId } from '../../Utilities';
import { KeytipEvents } from '../../utilities/keytips/KeytipConstants';
/**
* This class is responsible for handling registering, updating, and unregistering of keytips
*/
var KeytipManager = /** @class */ (function () {
function KeytipManager() {
this.keytips = {};
this.persistedKeytips = {};
this.sequenceMapping = {};
// This is (and should be) updated and kept in sync
// with the inKeytipMode in KeytipLayer.
this.inKeytipMode = false;
// Boolean that gets checked before entering keytip mode by the KeytipLayer
// Used for an override in special cases (e.g. Disable entering keytip mode when a modal is shown)
this.shouldEnterKeytipMode = true;
// Boolean to indicate whether to delay firing an event to update subscribers of
// keytip data changed.
this.delayUpdatingKeytipChange = false;
}
/**
* Static function to get singleton KeytipManager instance
*
* @returns Singleton KeytipManager instance
*/
KeytipManager.getInstance = function () {
return this._instance;
};
/**
* Initialization code to set set parameters to define
* how the KeytipManager handles keytip data.
*
* @param delayUpdatingKeytipChange - T/F if we should delay notifiying keytip subscribers
* of keytip changes
*/
KeytipManager.prototype.init = function (delayUpdatingKeytipChange) {
this.delayUpdatingKeytipChange = delayUpdatingKeytipChange;
};
/**
* Registers a keytip
*
* @param keytipProps - Keytip to register
* @param persisted - T/F if this keytip should be persisted, default is false
* @returns Unique ID for this keytip
*/
KeytipManager.prototype.register = function (keytipProps, persisted) {
if (persisted === void 0) { persisted = false; }
var props = keytipProps;
if (!persisted) {
// Add the overflowSetSequence if necessary
props = this.addParentOverflow(keytipProps);
this.sequenceMapping[props.keySequences.toString()] = props;
}
// Create a unique keytip
var uniqueKeytip = this._getUniqueKtp(props);
// Add to dictionary
persisted
? (this.persistedKeytips[uniqueKeytip.uniqueID] = uniqueKeytip)
: (this.keytips[uniqueKeytip.uniqueID] = uniqueKeytip);
// We only want to add something new if we are currently showing keytip mode
if (this.inKeytipMode || !this.delayUpdatingKeytipChange) {
var event_1 = persisted ? KeytipEvents.PERSISTED_KEYTIP_ADDED : KeytipEvents.KEYTIP_ADDED;
EventGroup.raise(this, event_1, {
keytip: props,
uniqueID: uniqueKeytip.uniqueID,
});
}
return uniqueKeytip.uniqueID;
};
/**
* Update a keytip
*
* @param keytipProps - Keytip to update
* @param uniqueID - Unique ID of this keytip
*/
KeytipManager.prototype.update = function (keytipProps, uniqueID) {
var newKeytipProps = this.addParentOverflow(keytipProps);
var uniqueKeytip = this._getUniqueKtp(newKeytipProps, uniqueID);
var oldKeyTip = this.keytips[uniqueID];
if (oldKeyTip) {
// Update everything except 'visible'
uniqueKeytip.keytip.visible = oldKeyTip.keytip.visible;
// Update keytip in this.keytips
this.keytips[uniqueID] = uniqueKeytip;
// Update the sequence to be up to date
delete this.sequenceMapping[oldKeyTip.keytip.keySequences.toString()];
this.sequenceMapping[uniqueKeytip.keytip.keySequences.toString()] = uniqueKeytip.keytip;
// Raise event only if we are currently in keytip mode
if (this.inKeytipMode || !this.delayUpdatingKeytipChange) {
EventGroup.raise(this, KeytipEvents.KEYTIP_UPDATED, {
keytip: uniqueKeytip.keytip,
uniqueID: uniqueKeytip.uniqueID,
});
}
}
};
/**
* Unregisters a keytip
*
* @param keytipToRemove - IKeytipProps of the keytip to remove
* @param uniqueID - Unique ID of this keytip
* @param persisted - T/F if this keytip should be persisted, default is false
*/
KeytipManager.prototype.unregister = function (keytipToRemove, uniqueID, persisted) {
if (persisted === void 0) { persisted = false; }
persisted ? delete this.persistedKeytips[uniqueID] : delete this.keytips[uniqueID];
!persisted && delete this.sequenceMapping[keytipToRemove.keySequences.toString()];
var event = persisted ? KeytipEvents.PERSISTED_KEYTIP_REMOVED : KeytipEvents.KEYTIP_REMOVED;
// Update keytips only if we're in keytip mode
if (this.inKeytipMode || !this.delayUpdatingKeytipChange) {
EventGroup.raise(this, event, {
keytip: keytipToRemove,
uniqueID: uniqueID,
});
}
};
/**
* Manual call to enter keytip mode
*/
KeytipManager.prototype.enterKeytipMode = function () {
EventGroup.raise(this, KeytipEvents.ENTER_KEYTIP_MODE);
};
/**
* Manual call to exit keytip mode
*/
KeytipManager.prototype.exitKeytipMode = function () {
EventGroup.raise(this, KeytipEvents.EXIT_KEYTIP_MODE);
};
/**
* Gets all IKeytipProps from this.keytips
*
* @returns All keytips stored in the manager
*/
KeytipManager.prototype.getKeytips = function () {
var _this = this;
return Object.keys(this.keytips).map(function (key) { return _this.keytips[key].keytip; });
};
/**
* Adds the overflowSetSequence to the keytipProps if its parent keytip also has it
*
* @param keytipProps - Keytip props to add overflowSetSequence to if necessary
* @returns - Modified keytip props, if needed to be modified
*/
KeytipManager.prototype.addParentOverflow = function (keytipProps) {
var fullSequence = __spreadArray([], keytipProps.keySequences, true);
fullSequence.pop();
if (fullSequence.length !== 0) {
var parentKeytip = this.sequenceMapping[fullSequence.toString()];
if (parentKeytip && parentKeytip.overflowSetSequence) {
return __assign(__assign({}, keytipProps), { overflowSetSequence: parentKeytip.overflowSetSequence });
}
}
return keytipProps;
};
/**
* Public function to bind for overflow items that have a submenu
*/
KeytipManager.prototype.menuExecute = function (overflowButtonSequences, keytipSequences) {
EventGroup.raise(this, KeytipEvents.PERSISTED_KEYTIP_EXECUTE, {
overflowButtonSequences: overflowButtonSequences,
keytipSequences: keytipSequences,
});
};
/**
* Creates an IUniqueKeytip object
*
* @param keytipProps - IKeytipProps
* @param uniqueID - Unique ID, will default to the next unique ID if not passed
* @returns IUniqueKeytip object
*/
KeytipManager.prototype._getUniqueKtp = function (keytipProps, uniqueID) {
if (uniqueID === void 0) { uniqueID = getId(); }
return { keytip: __assign({}, keytipProps), uniqueID: uniqueID };
};
KeytipManager._instance = new KeytipManager();
return KeytipManager;
}());
export { KeytipManager };
//# sourceMappingURL=KeytipManager.js.map
File diff suppressed because one or more lines are too long
+37
View File
@@ -0,0 +1,37 @@
/**
* Converts a whole set of KeySequences into one keytip ID, which will be the ID for the last keytip sequence specified
* keySequences should not include the initial keytip 'start' sequence.
*
* @param keySequences - Full path of IKeySequences for one keytip.
* @returns String to use for the keytip ID.
*/
export declare function sequencesToID(keySequences: string[]): string;
/**
* Merges an overflow sequence with a key sequence.
*
* @param keySequences - Full sequence for one keytip.
* @param overflowKeySequences - Full overflow keytip sequence.
* @returns Sequence that will be used by the keytip when in the overflow.
*/
export declare function mergeOverflows(keySequences: string[], overflowKeySequences: string[]): string[];
/**
* Constructs the data-ktp-target attribute selector from a full key sequence.
*
* @param keySequences - Full string[] for a Keytip.
* @returns String selector to use to query for the keytip target.
*/
export declare function ktpTargetFromSequences(keySequences: string[]): string;
/**
* Constructs the data-ktp-execute-target attribute selector from a keytip ID.
*
* @param keytipId - ID of the Keytip.
* @returns String selector to use to query for the keytip execute target.
*/
export declare function ktpTargetFromId(keytipId: string): string;
/**
* Gets the aria-describedby value to put on the component with this keytip.
*
* @param keySequences - KeySequences of the keytip.
* @returns The aria-describedby value to set on the component with this keytip.
*/
export declare function getAriaDescribedBy(keySequences: string[]): string;
+61
View File
@@ -0,0 +1,61 @@
import { __spreadArray } from "tslib";
import { KTP_SEPARATOR, KTP_PREFIX, DATAKTP_TARGET, DATAKTP_EXECUTE_TARGET, KTP_LAYER_ID } from './KeytipConstants';
import { addElementAtIndex } from '../../Utilities';
/**
* Converts a whole set of KeySequences into one keytip ID, which will be the ID for the last keytip sequence specified
* keySequences should not include the initial keytip 'start' sequence.
*
* @param keySequences - Full path of IKeySequences for one keytip.
* @returns String to use for the keytip ID.
*/
export function sequencesToID(keySequences) {
return keySequences.reduce(function (prevValue, keySequence) {
return prevValue + KTP_SEPARATOR + keySequence.split('').join(KTP_SEPARATOR);
}, KTP_PREFIX);
}
/**
* Merges an overflow sequence with a key sequence.
*
* @param keySequences - Full sequence for one keytip.
* @param overflowKeySequences - Full overflow keytip sequence.
* @returns Sequence that will be used by the keytip when in the overflow.
*/
export function mergeOverflows(keySequences, overflowKeySequences) {
var overflowSequenceLen = overflowKeySequences.length;
var overflowSequence = __spreadArray([], overflowKeySequences, true).pop();
var newKeySequences = __spreadArray([], keySequences, true);
return addElementAtIndex(newKeySequences, overflowSequenceLen - 1, overflowSequence);
}
/**
* Constructs the data-ktp-target attribute selector from a full key sequence.
*
* @param keySequences - Full string[] for a Keytip.
* @returns String selector to use to query for the keytip target.
*/
export function ktpTargetFromSequences(keySequences) {
return '[' + DATAKTP_TARGET + '="' + sequencesToID(keySequences) + '"]';
}
/**
* Constructs the data-ktp-execute-target attribute selector from a keytip ID.
*
* @param keytipId - ID of the Keytip.
* @returns String selector to use to query for the keytip execute target.
*/
export function ktpTargetFromId(keytipId) {
return '[' + DATAKTP_EXECUTE_TARGET + '="' + keytipId + '"]';
}
/**
* Gets the aria-describedby value to put on the component with this keytip.
*
* @param keySequences - KeySequences of the keytip.
* @returns The aria-describedby value to set on the component with this keytip.
*/
export function getAriaDescribedBy(keySequences) {
var describedby = ' ' + KTP_LAYER_ID;
if (!keySequences.length) {
// Return just the layer ID
return describedby;
}
return describedby + ' ' + sequencesToID(keySequences);
}
//# sourceMappingURL=KeytipUtils.js.map
@@ -0,0 +1 @@
{"version":3,"file":"KeytipUtils.js","sourceRoot":"../src/","sources":["utilities/keytips/KeytipUtils.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,cAAc,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACpH,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,YAAsB;IAClD,OAAO,YAAY,CAAC,MAAM,CAAC,UAAC,SAAiB,EAAE,WAAmB;QAChE,OAAO,SAAS,GAAG,aAAa,GAAG,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAC/E,CAAC,EAAE,UAAU,CAAC,CAAC;AACjB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,YAAsB,EAAE,oBAA8B;IACnF,IAAM,mBAAmB,GAAG,oBAAoB,CAAC,MAAM,CAAC;IACxD,IAAM,gBAAgB,GAAG,kBAAI,oBAAoB,QAAE,GAAG,EAAE,CAAC;IACzD,IAAM,eAAe,qBAAO,YAAY,OAAC,CAAC;IAC1C,OAAO,iBAAiB,CAAC,eAAe,EAAE,mBAAmB,GAAG,CAAC,EAAE,gBAAiB,CAAC,CAAC;AACxF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,YAAsB;IAC3D,OAAO,GAAG,GAAG,cAAc,GAAG,IAAI,GAAG,aAAa,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;AAC1E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,QAAgB;IAC9C,OAAO,GAAG,GAAG,sBAAsB,GAAG,IAAI,GAAG,QAAQ,GAAG,IAAI,CAAC;AAC/D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,YAAsB;IACvD,IAAM,WAAW,GAAG,GAAG,GAAG,YAAY,CAAC;IACvC,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;QACzB,2BAA2B;QAC3B,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,OAAO,WAAW,GAAG,GAAG,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC;AACzD,CAAC","sourcesContent":["import { KTP_SEPARATOR, KTP_PREFIX, DATAKTP_TARGET, DATAKTP_EXECUTE_TARGET, KTP_LAYER_ID } from './KeytipConstants';\nimport { addElementAtIndex } from '../../Utilities';\n\n/**\n * Converts a whole set of KeySequences into one keytip ID, which will be the ID for the last keytip sequence specified\n * keySequences should not include the initial keytip 'start' sequence.\n *\n * @param keySequences - Full path of IKeySequences for one keytip.\n * @returns String to use for the keytip ID.\n */\nexport function sequencesToID(keySequences: string[]): string {\n return keySequences.reduce((prevValue: string, keySequence: string): string => {\n return prevValue + KTP_SEPARATOR + keySequence.split('').join(KTP_SEPARATOR);\n }, KTP_PREFIX);\n}\n\n/**\n * Merges an overflow sequence with a key sequence.\n *\n * @param keySequences - Full sequence for one keytip.\n * @param overflowKeySequences - Full overflow keytip sequence.\n * @returns Sequence that will be used by the keytip when in the overflow.\n */\nexport function mergeOverflows(keySequences: string[], overflowKeySequences: string[]): string[] {\n const overflowSequenceLen = overflowKeySequences.length;\n const overflowSequence = [...overflowKeySequences].pop();\n const newKeySequences = [...keySequences];\n return addElementAtIndex(newKeySequences, overflowSequenceLen - 1, overflowSequence!);\n}\n\n/**\n * Constructs the data-ktp-target attribute selector from a full key sequence.\n *\n * @param keySequences - Full string[] for a Keytip.\n * @returns String selector to use to query for the keytip target.\n */\nexport function ktpTargetFromSequences(keySequences: string[]): string {\n return '[' + DATAKTP_TARGET + '=\"' + sequencesToID(keySequences) + '\"]';\n}\n\n/**\n * Constructs the data-ktp-execute-target attribute selector from a keytip ID.\n *\n * @param keytipId - ID of the Keytip.\n * @returns String selector to use to query for the keytip execute target.\n */\nexport function ktpTargetFromId(keytipId: string): string {\n return '[' + DATAKTP_EXECUTE_TARGET + '=\"' + keytipId + '\"]';\n}\n\n/**\n * Gets the aria-describedby value to put on the component with this keytip.\n *\n * @param keySequences - KeySequences of the keytip.\n * @returns The aria-describedby value to set on the component with this keytip.\n */\nexport function getAriaDescribedBy(keySequences: string[]): string {\n const describedby = ' ' + KTP_LAYER_ID;\n if (!keySequences.length) {\n // Return just the layer ID\n return describedby;\n }\n\n return describedby + ' ' + sequencesToID(keySequences);\n}\n"]}
+5
View File
@@ -0,0 +1,5 @@
export * from './IKeytipTransitionKey';
export * from './KeytipConfig';
export * from './KeytipConstants';
export * from './KeytipManager';
export * from './KeytipUtils';
+6
View File
@@ -0,0 +1,6 @@
export * from './IKeytipTransitionKey';
export * from './KeytipConfig';
export * from './KeytipConstants';
export * from './KeytipManager';
export * from './KeytipUtils';
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["utilities/keytips/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC","sourcesContent":["export * from './IKeytipTransitionKey';\nexport * from './KeytipConfig';\nexport * from './KeytipConstants';\nexport * from './KeytipManager';\nexport * from './KeytipUtils';\n"]}