1 | {"version":3,"file":"getId.js","sourceRoot":"../src/","sources":["getId.ts"],"names":[],"mappings":";;AAAA,6CAA4C;AAC5C,uDAAoD;AAEpD,+BAA+B;AAC/B,IAAM,mBAAmB,GAAG,eAAe,CAAC;AAC5C,IAAM,iBAAiB,GAAG,MAAM,CAAC;AAEjC,8DAA8D;AAC9D,IAAI,OAAO,GAAQ,qBAAS,EAAE,IAAI,EAAE,CAAC;AAErC,IAAI,OAAO,CAAC,mBAAmB,CAAC,KAAK,SAAS,EAAE;IAC9C,OAAO,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;CAClC;AAED,IAAI,4BAA4B,GAAG,KAAK,CAAC;AAEzC;;;;GAIG;AACH,SAAgB,KAAK,CAAC,MAAe;IACnC,IAAI,CAAC,4BAA4B,EAAE;QACjC,+CAA+C;QAC/C,IAAM,UAAU,GAAG,yBAAU,CAAC,WAAW,EAAE,CAAC;QAE5C,IAAI,UAAU,IAAI,UAAU,CAAC,OAAO,EAAE;YACpC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;SAC9B;QACD,4BAA4B,GAAG,IAAI,CAAC;KACrC;IAED,IAAI,KAAK,GAAG,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC;IAE3C,OAAO,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;AACrE,CAAC;AAdD,sBAcC;AAED;;;;GAIG;AACH,SAAgB,QAAQ,CAAC,OAAmB;IAAnB,wBAAA,EAAA,WAAmB;IAC1C,OAAO,CAAC,mBAAmB,CAAC,GAAG,OAAO,CAAC;AACzC,CAAC;AAFD,4BAEC","sourcesContent":["import { getWindow } from './dom/getWindow';\nimport { Stylesheet } from '@uifabric/merge-styles';\n\n// Initialize global window id.\nconst CURRENT_ID_PROPERTY = '__currentId__';\nconst DEFAULT_ID_STRING = 'id__';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nlet _global: any = getWindow() || {};\n\nif (_global[CURRENT_ID_PROPERTY] === undefined) {\n _global[CURRENT_ID_PROPERTY] = 0;\n}\n\nlet _initializedStylesheetResets = false;\n\n/**\n * Generates a unique id in the global scope (this spans across duplicate copies of the same library.)\n *\n * @public\n */\nexport function getId(prefix?: string): string {\n if (!_initializedStylesheetResets) {\n // Configure ids to reset on stylesheet resets.\n const stylesheet = Stylesheet.getInstance();\n\n if (stylesheet && stylesheet.onReset) {\n stylesheet.onReset(resetIds);\n }\n _initializedStylesheetResets = true;\n }\n\n let index = _global[CURRENT_ID_PROPERTY]++;\n\n return (prefix === undefined ? DEFAULT_ID_STRING : prefix) + index;\n}\n\n/**\n * Resets id counter to an (optional) number.\n *\n * @public\n */\nexport function resetIds(counter: number = 0): void {\n _global[CURRENT_ID_PROPERTY] = counter;\n}\n"]} |