@skyux/core 5.6.0 → 5.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/bundles/skyux-core.umd.js +63 -41
  2. package/documentation.json +499 -954
  3. package/esm2015/lib/modules/affix/affixer.js.map +1 -1
  4. package/esm2015/lib/modules/dock/dock.service.js +18 -15
  5. package/esm2015/lib/modules/dock/dock.service.js.map +1 -1
  6. package/esm2015/lib/modules/log/log.service.js +1 -0
  7. package/esm2015/lib/modules/log/log.service.js.map +1 -1
  8. package/esm2015/lib/modules/numeric/numeric.options.js +1 -1
  9. package/esm2015/lib/modules/numeric/numeric.options.js.map +1 -1
  10. package/esm2015/lib/modules/numeric/numeric.service.js +4 -3
  11. package/esm2015/lib/modules/numeric/numeric.service.js.map +1 -1
  12. package/esm2015/lib/modules/scrollable-host/scrollable-host.service.js +35 -14
  13. package/esm2015/lib/modules/scrollable-host/scrollable-host.service.js.map +1 -1
  14. package/esm2015/lib/modules/shared/number-format/number-format-utility.js +0 -2
  15. package/esm2015/lib/modules/shared/number-format/number-format-utility.js.map +1 -1
  16. package/esm2015/lib/modules/shared/sky-core-resources.module.js +1 -1
  17. package/esm2015/lib/modules/shared/sky-core-resources.module.js.map +1 -1
  18. package/esm2015/lib/modules/viewkeeper/viewkeeper.js +3 -6
  19. package/esm2015/lib/modules/viewkeeper/viewkeeper.js.map +1 -1
  20. package/fesm2015/skyux-core.js +63 -42
  21. package/fesm2015/skyux-core.js.map +1 -1
  22. package/lib/modules/dock/dock.service.d.ts +2 -2
  23. package/lib/modules/numeric/numeric.options.d.ts +1 -1
  24. package/lib/modules/scrollable-host/scrollable-host.service.d.ts +2 -1
  25. package/lib/modules/shared/number-format/number-format-utility.d.ts +0 -1
  26. package/lib/modules/shared/sky-core-resources.module.d.ts +1 -1
  27. package/package.json +11 -10
@@ -1 +1 @@
1
- {"version":3,"file":"affixer.js","sourceRoot":"","sources":["../../../../../../../../libs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AI,IAAI,CAAC,eAAe,EAAE;YACxB,sEAAsE;YACtE,wEAAwE;YACxE,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;YACvD,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;SAClC;IACH,CAAC;CACF","sourcesContent":["import { Renderer2 } from '@angular/core';\n\nimport { Observable, Subject, Subscription, fromEvent } from 'rxjs';\n\nimport { SkyAffixAutoFitContext } from './affix-auto-fit-context';\nimport { SkyAffixConfig } from './affix-config';\nimport { SkyAffixOffset } from './affix-offset';\nimport { SkyAffixOffsetChange } from './affix-offset-change';\nimport { SkyAffixPlacement } from './affix-placement';\nimport { SkyAffixPlacementChange } from './affix-placement-change';\nimport { getInversePlacement, getNextPlacement } from './affix-utils';\nimport {\n getElementOffset,\n getOverflowParents,\n isOffsetFullyVisibleWithinParent,\n isOffsetPartiallyVisibleWithinParent,\n} from './dom-utils';\n\nconst DEFAULT_AFFIX_CONFIG: SkyAffixConfig = {\n autoFitContext: SkyAffixAutoFitContext.OverflowParent,\n enableAutoFit: false,\n horizontalAlignment: 'center',\n isSticky: false,\n placement: 'above',\n};\n\nexport class SkyAffixer {\n /**\n * Fires when the affixed element's offset changes.\n */\n public get offsetChange(): Observable<SkyAffixOffsetChange> {\n return this._offsetChange.asObservable();\n }\n\n /**\n * Fires when the base element's nearest overflow parent is scrolling. This is useful if you need\n * to perform an additional action during the scroll event but don't want to generate another\n * event listener.\n */\n public get overflowScroll(): Observable<void> {\n return this._overflowScroll.asObservable();\n }\n\n /**\n * Fires when the placement value changes. A `null` value indicates that a suitable\n * placement could not be found.\n */\n public get placementChange(): Observable<SkyAffixPlacementChange> {\n return this._placementChange.asObservable();\n }\n\n private get config(): SkyAffixConfig {\n return this._config;\n }\n\n private set config(value: SkyAffixConfig) {\n const merged = { ...DEFAULT_AFFIX_CONFIG, ...value };\n\n // Make sure none of the values are undefined.\n Object.keys(merged).forEach((k: keyof SkyAffixConfig) => {\n if (merged[k] === undefined) {\n (merged as any)[k] = DEFAULT_AFFIX_CONFIG[k];\n }\n });\n\n this._config = merged;\n }\n\n private affixedRect: ClientRect;\n\n private baseElement: HTMLElement;\n\n private baseRect: ClientRect;\n\n private currentOffset: SkyAffixOffset;\n\n private currentPlacement: SkyAffixPlacement;\n\n private overflowParents: HTMLElement[];\n\n private resizeListener: Subscription;\n\n private scrollListeners: Function[];\n\n private _config: SkyAffixConfig;\n\n private _offsetChange = new Subject<SkyAffixOffsetChange>();\n\n private _overflowScroll = new Subject<void>();\n\n private _placementChange = new Subject<SkyAffixPlacementChange>();\n\n constructor(\n private affixedElement: HTMLElement,\n private renderer: Renderer2\n ) {}\n\n /**\n * Affixes an element to a base element.\n * @param baseElement The base element.\n * @param config Configuration for the affix action.\n */\n public affixTo(baseElement: HTMLElement, config?: SkyAffixConfig): void {\n this.reset();\n\n this.config = config;\n this.baseElement = baseElement;\n this.overflowParents = getOverflowParents(baseElement);\n\n this.affix();\n\n if (this.config.isSticky) {\n this.addScrollListeners();\n this.addResizeListener();\n }\n }\n\n /**\n * Re-runs the affix calculation.\n */\n public reaffix(): void {\n // Reset current placement to preferred placement.\n this.currentPlacement = this.config.placement;\n this.affix();\n }\n\n /**\n * Destroys the affixer.\n */\n public destroy(): void {\n this.reset();\n this._placementChange.complete();\n this._offsetChange.complete();\n this._overflowScroll.complete();\n\n this._offsetChange =\n this._placementChange =\n this._overflowScroll =\n undefined;\n }\n\n private affix(): void {\n this.baseRect = this.baseElement.getBoundingClientRect();\n this.affixedRect = this.affixedElement.getBoundingClientRect();\n\n const offset = this.getOffset();\n\n if (this.isNewOffset(offset)) {\n this.renderer.setStyle(this.affixedElement, 'top', `${offset.top}px`);\n this.renderer.setStyle(this.affixedElement, 'left', `${offset.left}px`);\n this._offsetChange.next({ offset });\n }\n }\n\n private getOffset(): SkyAffixOffset {\n const parent = this.getAutoFitContextParent();\n\n const maxAttempts = 4;\n let attempts = 0;\n\n let isAffixedElementFullyVisible = false;\n let offset: SkyAffixOffset;\n let placement = this.config.placement;\n\n do {\n offset = this.getPreferredOffset(placement);\n isAffixedElementFullyVisible = isOffsetFullyVisibleWithinParent(\n parent,\n offset,\n this.config.autoFitOverflowOffset\n );\n\n if (!this.config.enableAutoFit) {\n break;\n }\n\n if (!isAffixedElementFullyVisible) {\n placement =\n attempts % 2 === 0\n ? getInversePlacement(placement)\n : getNextPlacement(placement);\n }\n\n attempts++;\n } while (!isAffixedElementFullyVisible && attempts < maxAttempts);\n\n if (isAffixedElementFullyVisible) {\n if (this.isBaseElementVisible()) {\n this.notifyPlacementChange(placement);\n } else {\n /* tslint:disable-next-line:no-null-keyword */\n this.notifyPlacementChange(null);\n }\n\n return offset;\n }\n\n if (this.config.enableAutoFit) {\n /* tslint:disable-next-line:no-null-keyword */\n this.notifyPlacementChange(null);\n }\n\n // No suitable placement was found, so revert to preferred placement.\n return this.getPreferredOffset(this.config.placement);\n }\n\n private getPreferredOffset(placement: SkyAffixPlacement): SkyAffixOffset {\n const affixedRect = this.affixedRect;\n const baseRect = this.baseRect;\n\n const horizontalAlignment = this.config.horizontalAlignment;\n const verticalAlignment = this.config.verticalAlignment;\n const enableAutoFit = this.config.enableAutoFit;\n\n let top: number;\n let left: number;\n\n if (placement === 'above' || placement === 'below') {\n if (placement === 'above') {\n top = baseRect.top - affixedRect.height;\n\n switch (verticalAlignment) {\n case 'top':\n top = top + affixedRect.height;\n break;\n case 'middle':\n top = top + affixedRect.height / 2;\n break;\n case 'bottom':\n default:\n break;\n }\n } else {\n top = baseRect.bottom;\n\n switch (verticalAlignment) {\n case 'top':\n default:\n break;\n case 'middle':\n top = top - affixedRect.height / 2;\n break;\n case 'bottom':\n top = top - affixedRect.height;\n break;\n }\n }\n\n switch (horizontalAlignment) {\n case 'left':\n left = baseRect.left;\n break;\n\n case 'center':\n default:\n left = baseRect.left + baseRect.width / 2 - affixedRect.width / 2;\n break;\n\n case 'right':\n left = baseRect.right - affixedRect.width;\n break;\n }\n } else {\n if (placement === 'left') {\n left = baseRect.left - affixedRect.width;\n } else {\n left = baseRect.right;\n }\n\n switch (verticalAlignment) {\n case 'top':\n top = baseRect.top;\n break;\n\n case 'middle':\n default:\n top = baseRect.top + baseRect.height / 2 - affixedRect.height / 2;\n break;\n\n case 'bottom':\n top = baseRect.bottom - affixedRect.height;\n break;\n }\n }\n\n let offset: SkyAffixOffset = { left, top };\n if (enableAutoFit) {\n offset = this.adjustOffsetToOverflowParent({ ...offset }, placement);\n }\n\n offset.bottom = offset.top + affixedRect.height;\n offset.right = offset.left + affixedRect.width;\n\n return offset;\n }\n\n /**\n * Slightly adjust the offset to fit within the scroll parent's boundaries if\n * the affixed element would otherwise be clipped.\n */\n private adjustOffsetToOverflowParent(\n offset: SkyAffixOffset,\n placement: SkyAffixPlacement\n ): SkyAffixOffset {\n const parent = this.getAutoFitContextParent();\n const parentOffset = getElementOffset(\n parent,\n this.config.autoFitOverflowOffset\n );\n\n const affixedRect = this.affixedRect;\n const baseRect = this.baseRect;\n\n // A pixel value representing the leeway between the edge of the overflow parent and the edge\n // of the base element before it dissapears from view.\n // If the visible portion of the base element is less than this pixel value, the auto-fit\n // functionality attempts to find another placement.\n const defaultPixelTolerance = 40;\n let pixelTolerance: number;\n\n const originalOffsetTop = offset.top;\n const originalOffsetLeft = offset.left;\n\n /* tslint:disable-next-line:switch-default */\n switch (placement) {\n case 'above':\n case 'below':\n // Keep the affixed element within the overflow parent.\n if (offset.left < parentOffset.left) {\n offset.left = parentOffset.left;\n } else if (offset.left + affixedRect.width > parentOffset.right) {\n offset.left = parentOffset.right - affixedRect.width;\n }\n\n // Use a smaller pixel tolerance if the base element width is less than the default.\n pixelTolerance = Math.min(defaultPixelTolerance, baseRect.width);\n\n // Make sure the affixed element never detaches from the base element.\n if (\n offset.left + pixelTolerance > baseRect.right ||\n offset.left + affixedRect.width - pixelTolerance < baseRect.left\n ) {\n offset.left = originalOffsetLeft;\n }\n\n break;\n\n case 'left':\n case 'right':\n // Keep the affixed element within the overflow parent.\n if (offset.top < parentOffset.top) {\n offset.top = parentOffset.top;\n } else if (offset.top + affixedRect.height > parentOffset.bottom) {\n offset.top = parentOffset.bottom - affixedRect.height;\n }\n\n // Use a smaller pixel tolerance if the base element height is less than the default.\n pixelTolerance = Math.min(defaultPixelTolerance, baseRect.height);\n\n // Make sure the affixed element never detaches from the base element.\n if (\n offset.top + pixelTolerance > baseRect.bottom ||\n offset.top + affixedRect.height - pixelTolerance < baseRect.top\n ) {\n offset.top = originalOffsetTop;\n }\n\n break;\n }\n\n return offset;\n }\n\n private getImmediateOverflowParent(): HTMLElement {\n return this.overflowParents[this.overflowParents.length - 1];\n }\n\n private getAutoFitContextParent(): HTMLElement {\n const bodyElement = this.overflowParents[0];\n\n return this.config.autoFitContext === SkyAffixAutoFitContext.OverflowParent\n ? this.getImmediateOverflowParent()\n : bodyElement;\n }\n\n private notifyPlacementChange(placement: SkyAffixPlacement | null): void {\n if (this.currentPlacement !== placement) {\n this.currentPlacement = placement;\n this._placementChange.next({\n placement,\n });\n }\n }\n\n private reset(): void {\n this.removeScrollListeners();\n this.removeResizeListener();\n\n this._config =\n this.affixedRect =\n this.baseElement =\n this.baseRect =\n this.currentPlacement =\n this.currentOffset =\n this.overflowParents =\n undefined;\n }\n\n private isNewOffset(offset: SkyAffixOffset): boolean {\n if (this.currentOffset === undefined) {\n this.currentOffset = offset;\n return true;\n }\n\n if (\n this.currentOffset.top === offset.top &&\n this.currentOffset.left === offset.left\n ) {\n return false;\n }\n\n this.currentOffset = offset;\n\n return true;\n }\n\n private isBaseElementVisible(): boolean {\n return isOffsetPartiallyVisibleWithinParent(\n this.getImmediateOverflowParent(),\n {\n top: this.baseRect.top,\n left: this.baseRect.left,\n right: this.baseRect.right,\n bottom: this.baseRect.bottom,\n },\n this.config.autoFitOverflowOffset\n );\n }\n\n private addScrollListeners(): void {\n this.scrollListeners = this.overflowParents.map((parentElement) => {\n const overflow =\n parentElement === document.body ? 'window' : parentElement;\n return this.renderer.listen(overflow, 'scroll', () => {\n this.affix();\n this._overflowScroll.next();\n });\n });\n }\n\n private addResizeListener(): void {\n this.resizeListener = fromEvent(window, 'resize').subscribe(() =>\n this.affix()\n );\n }\n\n private removeResizeListener(): void {\n if (this.resizeListener) {\n this.resizeListener.unsubscribe();\n this.resizeListener = undefined;\n }\n }\n\n private removeScrollListeners(): void {\n if (this.scrollListeners) {\n // Remove renderer-generated listeners by calling the listener itself.\n // https://github.com/angular/angular/issues/9368#issuecomment-227199778\n this.scrollListeners.forEach((listener) => listener());\n this.scrollListeners = undefined;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"affixer.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/affix/affixer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAc,OAAO,EAAgB,SAAS,EAAE,MAAM,MAAM,CAAC;AAEpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAMlE,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,gCAAgC,EAChC,oCAAoC,GACrC,MAAM,aAAa,CAAC;AAErB,MAAM,oBAAoB,GAAmB;IAC3C,cAAc,EAAE,sBAAsB,CAAC,cAAc;IACrD,aAAa,EAAE,KAAK;IACpB,mBAAmB,EAAE,QAAQ;IAC7B,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,OAAO;CACnB,CAAC;AAEF,MAAM,OAAO,UAAU;IAkErB,YACU,cAA2B,EAC3B,QAAmB;QADnB,mBAAc,GAAd,cAAc,CAAa;QAC3B,aAAQ,GAAR,QAAQ,CAAW;QARrB,kBAAa,GAAG,IAAI,OAAO,EAAwB,CAAC;QAEpD,oBAAe,GAAG,IAAI,OAAO,EAAQ,CAAC;QAEtC,qBAAgB,GAAG,IAAI,OAAO,EAA2B,CAAC;IAK/D,CAAC;IApEJ;;OAEG;IACH,IA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C,eAAe,CAAC,IAAI,EAAE,CAAC;YAC9B,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;IAEO,iBAAiB;QACvB,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAC/D,IAAI,CAAC,KAAK,EAAE,CACb,CAAC;IACJ,CAAC;IAEO,oBAAoB;QAC1B,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,IAAI,CAAC,cAAc,CAAC,WAAW,EAAE,CAAC;YAClC,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;SACjC;IACH,CAAC;IAEO,qBAAqB;QAC3B,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,sEAAsE;YACtE,wEAAwE;YACxE,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;YACvD,IAAI,CAAC,eAAe,GAAG,SAAS,CAAC;SAClC;IACH,CAAC;CACF","sourcesContent":["import { Renderer2 } from '@angular/core';\n\nimport { Observable, Subject, Subscription, fromEvent } from 'rxjs';\n\nimport { SkyAffixAutoFitContext } from './affix-auto-fit-context';\nimport { SkyAffixConfig } from './affix-config';\nimport { SkyAffixOffset } from './affix-offset';\nimport { SkyAffixOffsetChange } from './affix-offset-change';\nimport { SkyAffixPlacement } from './affix-placement';\nimport { SkyAffixPlacementChange } from './affix-placement-change';\nimport { getInversePlacement, getNextPlacement } from './affix-utils';\nimport {\n getElementOffset,\n getOverflowParents,\n isOffsetFullyVisibleWithinParent,\n isOffsetPartiallyVisibleWithinParent,\n} from './dom-utils';\n\nconst DEFAULT_AFFIX_CONFIG: SkyAffixConfig = {\n autoFitContext: SkyAffixAutoFitContext.OverflowParent,\n enableAutoFit: false,\n horizontalAlignment: 'center',\n isSticky: false,\n placement: 'above',\n};\n\nexport class SkyAffixer {\n /**\n * Fires when the affixed element's offset changes.\n */\n public get offsetChange(): Observable<SkyAffixOffsetChange> {\n return this._offsetChange.asObservable();\n }\n\n /**\n * Fires when the base element's nearest overflow parent is scrolling. This is useful if you need\n * to perform an additional action during the scroll event but don't want to generate another\n * event listener.\n */\n public get overflowScroll(): Observable<void> {\n return this._overflowScroll.asObservable();\n }\n\n /**\n * Fires when the placement value changes. A `null` value indicates that a suitable\n * placement could not be found.\n */\n public get placementChange(): Observable<SkyAffixPlacementChange> {\n return this._placementChange.asObservable();\n }\n\n private get config(): SkyAffixConfig {\n return this._config;\n }\n\n private set config(value: SkyAffixConfig) {\n const merged = { ...DEFAULT_AFFIX_CONFIG, ...value };\n\n // Make sure none of the values are undefined.\n Object.keys(merged).forEach((k: keyof SkyAffixConfig) => {\n if (merged[k] === undefined) {\n (merged as any)[k] = DEFAULT_AFFIX_CONFIG[k];\n }\n });\n\n this._config = merged;\n }\n\n private affixedRect: ClientRect;\n\n private baseElement: HTMLElement;\n\n private baseRect: ClientRect;\n\n private currentOffset: SkyAffixOffset;\n\n private currentPlacement: SkyAffixPlacement;\n\n private overflowParents: HTMLElement[];\n\n private resizeListener: Subscription;\n\n private scrollListeners: (() => void)[];\n\n private _config: SkyAffixConfig;\n\n private _offsetChange = new Subject<SkyAffixOffsetChange>();\n\n private _overflowScroll = new Subject<void>();\n\n private _placementChange = new Subject<SkyAffixPlacementChange>();\n\n constructor(\n private affixedElement: HTMLElement,\n private renderer: Renderer2\n ) {}\n\n /**\n * Affixes an element to a base element.\n * @param baseElement The base element.\n * @param config Configuration for the affix action.\n */\n public affixTo(baseElement: HTMLElement, config?: SkyAffixConfig): void {\n this.reset();\n\n this.config = config;\n this.baseElement = baseElement;\n this.overflowParents = getOverflowParents(baseElement);\n\n this.affix();\n\n if (this.config.isSticky) {\n this.addScrollListeners();\n this.addResizeListener();\n }\n }\n\n /**\n * Re-runs the affix calculation.\n */\n public reaffix(): void {\n // Reset current placement to preferred placement.\n this.currentPlacement = this.config.placement;\n this.affix();\n }\n\n /**\n * Destroys the affixer.\n */\n public destroy(): void {\n this.reset();\n this._placementChange.complete();\n this._offsetChange.complete();\n this._overflowScroll.complete();\n\n this._offsetChange =\n this._placementChange =\n this._overflowScroll =\n undefined;\n }\n\n private affix(): void {\n this.baseRect = this.baseElement.getBoundingClientRect();\n this.affixedRect = this.affixedElement.getBoundingClientRect();\n\n const offset = this.getOffset();\n\n if (this.isNewOffset(offset)) {\n this.renderer.setStyle(this.affixedElement, 'top', `${offset.top}px`);\n this.renderer.setStyle(this.affixedElement, 'left', `${offset.left}px`);\n this._offsetChange.next({ offset });\n }\n }\n\n private getOffset(): SkyAffixOffset {\n const parent = this.getAutoFitContextParent();\n\n const maxAttempts = 4;\n let attempts = 0;\n\n let isAffixedElementFullyVisible = false;\n let offset: SkyAffixOffset;\n let placement = this.config.placement;\n\n do {\n offset = this.getPreferredOffset(placement);\n isAffixedElementFullyVisible = isOffsetFullyVisibleWithinParent(\n parent,\n offset,\n this.config.autoFitOverflowOffset\n );\n\n if (!this.config.enableAutoFit) {\n break;\n }\n\n if (!isAffixedElementFullyVisible) {\n placement =\n attempts % 2 === 0\n ? getInversePlacement(placement)\n : getNextPlacement(placement);\n }\n\n attempts++;\n } while (!isAffixedElementFullyVisible && attempts < maxAttempts);\n\n if (isAffixedElementFullyVisible) {\n if (this.isBaseElementVisible()) {\n this.notifyPlacementChange(placement);\n } else {\n /* tslint:disable-next-line:no-null-keyword */\n this.notifyPlacementChange(null);\n }\n\n return offset;\n }\n\n if (this.config.enableAutoFit) {\n /* tslint:disable-next-line:no-null-keyword */\n this.notifyPlacementChange(null);\n }\n\n // No suitable placement was found, so revert to preferred placement.\n return this.getPreferredOffset(this.config.placement);\n }\n\n private getPreferredOffset(placement: SkyAffixPlacement): SkyAffixOffset {\n const affixedRect = this.affixedRect;\n const baseRect = this.baseRect;\n\n const horizontalAlignment = this.config.horizontalAlignment;\n const verticalAlignment = this.config.verticalAlignment;\n const enableAutoFit = this.config.enableAutoFit;\n\n let top: number;\n let left: number;\n\n if (placement === 'above' || placement === 'below') {\n if (placement === 'above') {\n top = baseRect.top - affixedRect.height;\n\n switch (verticalAlignment) {\n case 'top':\n top = top + affixedRect.height;\n break;\n case 'middle':\n top = top + affixedRect.height / 2;\n break;\n case 'bottom':\n default:\n break;\n }\n } else {\n top = baseRect.bottom;\n\n switch (verticalAlignment) {\n case 'top':\n default:\n break;\n case 'middle':\n top = top - affixedRect.height / 2;\n break;\n case 'bottom':\n top = top - affixedRect.height;\n break;\n }\n }\n\n switch (horizontalAlignment) {\n case 'left':\n left = baseRect.left;\n break;\n\n case 'center':\n default:\n left = baseRect.left + baseRect.width / 2 - affixedRect.width / 2;\n break;\n\n case 'right':\n left = baseRect.right - affixedRect.width;\n break;\n }\n } else {\n if (placement === 'left') {\n left = baseRect.left - affixedRect.width;\n } else {\n left = baseRect.right;\n }\n\n switch (verticalAlignment) {\n case 'top':\n top = baseRect.top;\n break;\n\n case 'middle':\n default:\n top = baseRect.top + baseRect.height / 2 - affixedRect.height / 2;\n break;\n\n case 'bottom':\n top = baseRect.bottom - affixedRect.height;\n break;\n }\n }\n\n let offset: SkyAffixOffset = { left, top };\n if (enableAutoFit) {\n offset = this.adjustOffsetToOverflowParent({ ...offset }, placement);\n }\n\n offset.bottom = offset.top + affixedRect.height;\n offset.right = offset.left + affixedRect.width;\n\n return offset;\n }\n\n /**\n * Slightly adjust the offset to fit within the scroll parent's boundaries if\n * the affixed element would otherwise be clipped.\n */\n private adjustOffsetToOverflowParent(\n offset: SkyAffixOffset,\n placement: SkyAffixPlacement\n ): SkyAffixOffset {\n const parent = this.getAutoFitContextParent();\n const parentOffset = getElementOffset(\n parent,\n this.config.autoFitOverflowOffset\n );\n\n const affixedRect = this.affixedRect;\n const baseRect = this.baseRect;\n\n // A pixel value representing the leeway between the edge of the overflow parent and the edge\n // of the base element before it dissapears from view.\n // If the visible portion of the base element is less than this pixel value, the auto-fit\n // functionality attempts to find another placement.\n const defaultPixelTolerance = 40;\n let pixelTolerance: number;\n\n const originalOffsetTop = offset.top;\n const originalOffsetLeft = offset.left;\n\n /* tslint:disable-next-line:switch-default */\n switch (placement) {\n case 'above':\n case 'below':\n // Keep the affixed element within the overflow parent.\n if (offset.left < parentOffset.left) {\n offset.left = parentOffset.left;\n } else if (offset.left + affixedRect.width > parentOffset.right) {\n offset.left = parentOffset.right - affixedRect.width;\n }\n\n // Use a smaller pixel tolerance if the base element width is less than the default.\n pixelTolerance = Math.min(defaultPixelTolerance, baseRect.width);\n\n // Make sure the affixed element never detaches from the base element.\n if (\n offset.left + pixelTolerance > baseRect.right ||\n offset.left + affixedRect.width - pixelTolerance < baseRect.left\n ) {\n offset.left = originalOffsetLeft;\n }\n\n break;\n\n case 'left':\n case 'right':\n // Keep the affixed element within the overflow parent.\n if (offset.top < parentOffset.top) {\n offset.top = parentOffset.top;\n } else if (offset.top + affixedRect.height > parentOffset.bottom) {\n offset.top = parentOffset.bottom - affixedRect.height;\n }\n\n // Use a smaller pixel tolerance if the base element height is less than the default.\n pixelTolerance = Math.min(defaultPixelTolerance, baseRect.height);\n\n // Make sure the affixed element never detaches from the base element.\n if (\n offset.top + pixelTolerance > baseRect.bottom ||\n offset.top + affixedRect.height - pixelTolerance < baseRect.top\n ) {\n offset.top = originalOffsetTop;\n }\n\n break;\n }\n\n return offset;\n }\n\n private getImmediateOverflowParent(): HTMLElement {\n return this.overflowParents[this.overflowParents.length - 1];\n }\n\n private getAutoFitContextParent(): HTMLElement {\n const bodyElement = this.overflowParents[0];\n\n return this.config.autoFitContext === SkyAffixAutoFitContext.OverflowParent\n ? this.getImmediateOverflowParent()\n : bodyElement;\n }\n\n private notifyPlacementChange(placement: SkyAffixPlacement | null): void {\n if (this.currentPlacement !== placement) {\n this.currentPlacement = placement;\n this._placementChange.next({\n placement,\n });\n }\n }\n\n private reset(): void {\n this.removeScrollListeners();\n this.removeResizeListener();\n\n this._config =\n this.affixedRect =\n this.baseElement =\n this.baseRect =\n this.currentPlacement =\n this.currentOffset =\n this.overflowParents =\n undefined;\n }\n\n private isNewOffset(offset: SkyAffixOffset): boolean {\n if (this.currentOffset === undefined) {\n this.currentOffset = offset;\n return true;\n }\n\n if (\n this.currentOffset.top === offset.top &&\n this.currentOffset.left === offset.left\n ) {\n return false;\n }\n\n this.currentOffset = offset;\n\n return true;\n }\n\n private isBaseElementVisible(): boolean {\n return isOffsetPartiallyVisibleWithinParent(\n this.getImmediateOverflowParent(),\n {\n top: this.baseRect.top,\n left: this.baseRect.left,\n right: this.baseRect.right,\n bottom: this.baseRect.bottom,\n },\n this.config.autoFitOverflowOffset\n );\n }\n\n private addScrollListeners(): void {\n this.scrollListeners = this.overflowParents.map((parentElement) => {\n const overflow =\n parentElement === document.body ? 'window' : parentElement;\n return this.renderer.listen(overflow, 'scroll', () => {\n this.affix();\n this._overflowScroll.next();\n });\n });\n }\n\n private addResizeListener(): void {\n this.resizeListener = fromEvent(window, 'resize').subscribe(() =>\n this.affix()\n );\n }\n\n private removeResizeListener(): void {\n if (this.resizeListener) {\n this.resizeListener.unsubscribe();\n this.resizeListener = undefined;\n }\n }\n\n private removeScrollListeners(): void {\n if (this.scrollListeners) {\n // Remove renderer-generated listeners by calling the listener itself.\n // https://github.com/angular/angular/issues/9368#issuecomment-227199778\n this.scrollListeners.forEach((listener) => listener());\n this.scrollListeners = undefined;\n }\n }\n}\n"]}
@@ -13,13 +13,12 @@ import * as i1 from "../dynamic-component/dynamic-component.service";
13
13
  export class SkyDockService {
14
14
  constructor(dynamicComponentService) {
15
15
  this.dynamicComponentService = dynamicComponentService;
16
- this._items = [];
17
16
  }
18
17
  /**
19
18
  * Returns all docked items.
20
19
  */
21
20
  get items() {
22
- return this._items;
21
+ return SkyDockService._items;
23
22
  }
24
23
  /**
25
24
  * Docks a component to the bottom of the page.
@@ -27,20 +26,20 @@ export class SkyDockService {
27
26
  * @param config Options that affect the docking action.
28
27
  */
29
28
  insertComponent(component, config) {
30
- if (!this.dockRef) {
29
+ if (!SkyDockService.dockRef) {
31
30
  this.createDock();
32
31
  }
33
- const itemRef = this.dockRef.instance.insertComponent(component, config);
32
+ const itemRef = SkyDockService.dockRef.instance.insertComponent(component, config);
34
33
  const item = new SkyDockItem(itemRef.componentRef.instance, itemRef.stackOrder);
35
34
  item.destroyed.subscribe(() => {
36
- this.dockRef.instance.removeItem(itemRef);
37
- this._items.splice(this._items.indexOf(item), 1);
38
- if (this._items.length === 0) {
35
+ SkyDockService.dockRef.instance.removeItem(itemRef);
36
+ SkyDockService._items.splice(SkyDockService._items.indexOf(item), 1);
37
+ if (SkyDockService._items.length === 0) {
39
38
  this.destroyDock();
40
39
  }
41
40
  });
42
- this._items.push(item);
43
- this._items.sort(sortByStackOrder);
41
+ SkyDockService._items.push(item);
42
+ SkyDockService._items.sort(sortByStackOrder);
44
43
  return item;
45
44
  }
46
45
  /**
@@ -73,20 +72,24 @@ export class SkyDockService {
73
72
  referenceEl: this.options.referenceEl,
74
73
  };
75
74
  }
76
- this.dockRef = this.dynamicComponentService.createComponent(SkyDockComponent, dockOptions);
77
- this.dockRef.instance.setOptions(this.options);
75
+ SkyDockService.dockRef = this.dynamicComponentService.createComponent(SkyDockComponent, dockOptions);
76
+ SkyDockService.dockRef.instance.setOptions(this.options);
78
77
  }
79
78
  destroyDock() {
80
- this.dynamicComponentService.removeComponent(this.dockRef);
81
- this.dockRef = undefined;
79
+ this.dynamicComponentService.removeComponent(SkyDockService.dockRef);
80
+ SkyDockService.dockRef = undefined;
82
81
  }
83
82
  }
83
+ SkyDockService._items = [];
84
84
  SkyDockService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyDockService, deps: [{ token: i1.SkyDynamicComponentService }], target: i0.ɵɵFactoryTarget.Injectable });
85
- SkyDockService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyDockService, providedIn: 'root' });
85
+ SkyDockService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyDockService, providedIn: 'any' });
86
86
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyDockService, decorators: [{
87
87
  type: Injectable,
88
88
  args: [{
89
- providedIn: 'root',
89
+ // Must be 'any' so that the dock component is created in the context of its module's injector.
90
+ // If set to 'root', the component's dependency injections would only be derived from the root
91
+ // injector and may loose context if the dock was opened from within a lazy-loaded module.
92
+ providedIn: 'any',
90
93
  }]
91
94
  }], ctorParameters: function () { return [{ type: i1.SkyDynamicComponentService }]; } });
92
95
  //# sourceMappingURL=dock.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"dock.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/dock/dock.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAQ,MAAM,eAAe,CAAC;AAE/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,iDAAiD,CAAC;AAE9F,OAAO,EAAE,0BAA0B,EAAE,MAAM,gDAAgD,CAAC;AAG5F,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;;;AAEzD;;GAEG;AAIH,MAAM,OAAO,cAAc;IAczB,YAAoB,uBAAmD;QAAnD,4BAAuB,GAAvB,uBAAuB,CAA4B;QAF/D,WAAM,GAAuB,EAAE,CAAC;IAEkC,CAAC;IAb3E;;OAEG;IACH,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAUD;;;;OAIG;IACI,eAAe,CACpB,SAAkB,EAClB,MAAqC;QAErC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,UAAU,EAAE,CAAC;SAC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tD,MAAM;aACT;YAED,WAAW,GAAG;gBACZ,QAAQ,EAAE,eAAe;gBACzB,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,WAAW;aACtC,CAAC;SACH;QAED,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,uBAAuB,CAAC,eAAe,CACzD,gBAAgB,EAChB,WAAW,CACZ,CAAC;QACF,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACjD,CAAC;IAEO,WAAW;QACjB,IAAI,CAAC,uBAAuB,CAAC,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC3D,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;IAC3B,CAAC;;4GA7FU,cAAc;gHAAd,cAAc,cAFb,MAAM;4FAEP,cAAc;kBAH1B,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB","sourcesContent":["import { ComponentRef, Injectable, Type } from '@angular/core';\n\nimport { SkyDynamicComponentLocation } from '../dynamic-component/dynamic-component-location';\nimport { SkyDynamicComponentOptions } from '../dynamic-component/dynamic-component-options';\nimport { SkyDynamicComponentService } from '../dynamic-component/dynamic-component.service';\n\nimport { SkyDockInsertComponentConfig } from './dock-insert-component-config';\nimport { SkyDockItem } from './dock-item';\nimport { SkyDockLocation } from './dock-location';\nimport { SkyDockOptions } from './dock-options';\nimport { SkyDockComponent } from './dock.component';\nimport { sortByStackOrder } from './sort-by-stack-order';\n\n/**\n * This service docks components to specific areas on the page.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class SkyDockService {\n /**\n * Returns all docked items.\n */\n public get items(): SkyDockItem<any>[] {\n return this._items;\n }\n\n private dockRef: ComponentRef<SkyDockComponent>;\n\n private options: SkyDockOptions;\n\n private _items: SkyDockItem<any>[] = [];\n\n constructor(private dynamicComponentService: SkyDynamicComponentService) {}\n\n /**\n * Docks a component to the bottom of the page.\n * @param component The component to dock.\n * @param config Options that affect the docking action.\n */\n public insertComponent<T>(\n component: Type<T>,\n config?: SkyDockInsertComponentConfig\n ): SkyDockItem<T> {\n if (!this.dockRef) {\n this.createDock();\n }\n\n const itemRef = this.dockRef.instance.insertComponent(component, config);\n const item = new SkyDockItem(\n itemRef.componentRef.instance,\n itemRef.stackOrder\n );\n\n item.destroyed.subscribe(() => {\n this.dockRef.instance.removeItem(itemRef);\n this._items.splice(this._items.indexOf(item), 1);\n if (this._items.length === 0) {\n this.destroyDock();\n }\n });\n\n this._items.push(item);\n this._items.sort(sortByStackOrder);\n\n return item;\n }\n\n /**\n * Sets options for the positioning and styling of the dock component. Since the dock service is a\n * singleton instance, these options will be applied to all components inserted into the dock. In\n * order to create a seperate dock with different options, consumers should provide a different\n * instance of the dock service.\n * @param options The options for positioning and styling\n */\n public setDockOptions(options: SkyDockOptions): void {\n this.options = options;\n }\n\n private createDock(): void {\n let dockOptions: SkyDynamicComponentOptions;\n\n if (this.options) {\n let dynamicLocation: SkyDynamicComponentLocation;\n switch (this.options.location) {\n case SkyDockLocation.BeforeElement:\n dynamicLocation = SkyDynamicComponentLocation.BeforeElement;\n break;\n case SkyDockLocation.ElementBottom:\n dynamicLocation = SkyDynamicComponentLocation.ElementBottom;\n break;\n default:\n dynamicLocation = SkyDynamicComponentLocation.BodyTop;\n break;\n }\n\n dockOptions = {\n location: dynamicLocation,\n referenceEl: this.options.referenceEl,\n };\n }\n\n this.dockRef = this.dynamicComponentService.createComponent(\n SkyDockComponent,\n dockOptions\n );\n this.dockRef.instance.setOptions(this.options);\n }\n\n private destroyDock(): void {\n this.dynamicComponentService.removeComponent(this.dockRef);\n this.dockRef = undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"dock.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/dock/dock.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,UAAU,EAAQ,MAAM,eAAe,CAAC;AAE/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,iDAAiD,CAAC;AAE9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","sourcesContent":["import { ComponentRef, Injectable, Type } from '@angular/core';\n\nimport { SkyDynamicComponentLocation } from '../dynamic-component/dynamic-component-location';\nimport { SkyDynamicComponentOptions } from '../dynamic-component/dynamic-component-options';\nimport { SkyDynamicComponentService } from '../dynamic-component/dynamic-component.service';\n\nimport { SkyDockInsertComponentConfig } from './dock-insert-component-config';\nimport { SkyDockItem } from './dock-item';\nimport { SkyDockLocation } from './dock-location';\nimport { SkyDockOptions } from './dock-options';\nimport { SkyDockComponent } from './dock.component';\nimport { sortByStackOrder } from './sort-by-stack-order';\n\n/**\n * This service docks components to specific areas on the page.\n */\n@Injectable({\n // Must be 'any' so that the dock component is created in the context of its module's injector.\n // If set to 'root', the component's dependency injections would only be derived from the root\n // injector and may loose context if the dock was opened from within a lazy-loaded module.\n providedIn: 'any',\n})\nexport class SkyDockService {\n private static dockRef: ComponentRef<SkyDockComponent>;\n private static _items: SkyDockItem<any>[] = [];\n\n /**\n * Returns all docked items.\n */\n public get items(): SkyDockItem<any>[] {\n return SkyDockService._items;\n }\n\n private options: SkyDockOptions;\n\n constructor(private dynamicComponentService: SkyDynamicComponentService) {}\n\n /**\n * Docks a component to the bottom of the page.\n * @param component The component to dock.\n * @param config Options that affect the docking action.\n */\n public insertComponent<T>(\n component: Type<T>,\n config?: SkyDockInsertComponentConfig\n ): SkyDockItem<T> {\n if (!SkyDockService.dockRef) {\n this.createDock();\n }\n\n const itemRef = SkyDockService.dockRef.instance.insertComponent(\n component,\n config\n );\n const item = new SkyDockItem(\n itemRef.componentRef.instance,\n itemRef.stackOrder\n );\n\n item.destroyed.subscribe(() => {\n SkyDockService.dockRef.instance.removeItem(itemRef);\n SkyDockService._items.splice(SkyDockService._items.indexOf(item), 1);\n if (SkyDockService._items.length === 0) {\n this.destroyDock();\n }\n });\n\n SkyDockService._items.push(item);\n SkyDockService._items.sort(sortByStackOrder);\n\n return item;\n }\n\n /**\n * Sets options for the positioning and styling of the dock component. Since the dock service is a\n * singleton instance, these options will be applied to all components inserted into the dock. In\n * order to create a seperate dock with different options, consumers should provide a different\n * instance of the dock service.\n * @param options The options for positioning and styling\n */\n public setDockOptions(options: SkyDockOptions): void {\n this.options = options;\n }\n\n private createDock(): void {\n let dockOptions: SkyDynamicComponentOptions;\n\n if (this.options) {\n let dynamicLocation: SkyDynamicComponentLocation;\n switch (this.options.location) {\n case SkyDockLocation.BeforeElement:\n dynamicLocation = SkyDynamicComponentLocation.BeforeElement;\n break;\n case SkyDockLocation.ElementBottom:\n dynamicLocation = SkyDynamicComponentLocation.ElementBottom;\n break;\n default:\n dynamicLocation = SkyDynamicComponentLocation.BodyTop;\n break;\n }\n\n dockOptions = {\n location: dynamicLocation,\n referenceEl: this.options.referenceEl,\n };\n }\n\n SkyDockService.dockRef = this.dynamicComponentService.createComponent(\n SkyDockComponent,\n dockOptions\n );\n SkyDockService.dockRef.instance.setOptions(this.options);\n }\n\n private destroyDock(): void {\n this.dynamicComponentService.removeComponent(SkyDockService.dockRef);\n SkyDockService.dockRef = undefined;\n }\n}\n"]}
@@ -7,6 +7,7 @@ export class SkyLogService {
7
7
  warn(message, ...optionalParams) {
8
8
  /*istanbul ignore else */
9
9
  if (window.console) {
10
+ // eslint-disable-next-line prefer-spread,prefer-rest-params
10
11
  window.console.warn.apply(window.console, arguments);
11
12
  }
12
13
  }
@@ -1 +1 @@
1
- {"version":3,"file":"log.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/log/log.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;;AAE3C;;GAEG;AAIH,MAAM,OAAO,aAAa;IACjB,IAAI,CAAC,OAAa,EAAE,GAAG,cAAqB;QACjD,yBAAyB;QACzB,IAAI,MAAM,CAAC,OAAO,EAAE;YAClB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;SACtD;IACH,CAAC;;2GANU,aAAa;+GAAb,aAAa,cAFZ,MAAM;4FAEP,aAAa;kBAHzB,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB","sourcesContent":["import { Injectable } from '@angular/core';\n\n/**\n * @deprecated The `SkyLogService` will be removed in the next major version of `@skyux/core`.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class SkyLogService {\n public warn(message?: any, ...optionalParams: any[]): void {\n /*istanbul ignore else */\n if (window.console) {\n window.console.warn.apply(window.console, arguments);\n }\n }\n}\n"]}
1
+ {"version":3,"file":"log.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/log/log.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;;AAE3C;;GAEG;AAIH,MAAM,OAAO,aAAa;IACjB,IAAI,CAAC,OAAa,EAAE,GAAG,cAAqB;QACjD,yBAAyB;QACzB,IAAI,MAAM,CAAC,OAAO,EAAE;YAClB,4DAA4D;YAC5D,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;SACtD;IACH,CAAC;;2GAPU,aAAa;+GAAb,aAAa,cAFZ,MAAM;4FAEP,aAAa;kBAHzB,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB","sourcesContent":["import { Injectable } from '@angular/core';\n\n/**\n * @deprecated The `SkyLogService` will be removed in the next major version of `@skyux/core`.\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class SkyLogService {\n public warn(message?: any, ...optionalParams: any[]): void {\n /*istanbul ignore else */\n if (window.console) {\n // eslint-disable-next-line prefer-spread,prefer-rest-params\n window.console.warn.apply(window.console, arguments);\n }\n }\n}\n"]}
@@ -27,7 +27,7 @@ export class NumericOptions {
27
27
  this.iso = 'USD';
28
28
  /**
29
29
  * Indicates whether to shorten numbers to rounded numbers and abbreviation characters
30
- * such as K for thousands, M for millions, B for billions, and T for trillion.
30
+ * such as K for thousands, M for millions, B for billions, and T for trillions.
31
31
  */
32
32
  this.truncate = true;
33
33
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"numeric.options.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/numeric/numeric.options.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,cAAc;IAA3B;QACE;;;WAGG;QACI,WAAM,GAAY,CAAC,CAAC;QAE3B;;;WAGG;QACI,WAAM,GAAY,QAAQ,CAAC;QAElC;;;WAGG;QACI,iBAAY,GAA+B,UAAU,CAAC;QAE7D;;;;;WAKG;QACI,QAAG,GAAY,KAAK,CAAC;QAc5B;;;WAGG;QACI,aAAQ,GAAa,IAAI,CAAC;QAEjC;;;;WAIG;QACI,kBAAa,GAAY,CAAC,CAAC;IACpC,CAAC;CAAA","sourcesContent":["/**\n * Provides arguments for the number to format.\n */\nexport class NumericOptions {\n /**\n * Specifies the maximum number of digits after the decimal separator.\n * @default 1\n */\n public digits?: number = 1;\n\n /**\n * Specifies how to format the number. Options are `currency` or `number`.\n * @default \"number\"\n */\n public format?: string = 'number';\n\n /**\n * Specifies the format of the currency.\n * @default \"standard\"\n */\n public currencySign?: 'accounting' | 'standard' = 'standard';\n\n /**\n * Specifies the ISO4217 currency code to use for currency formatting. If you do not specify a\n * currency code, the component uses the browser's culture to determine the currency unless your\n * SPA provides a different culture with `SkyAppLocaleProvider`.\n * @default \"USD\"\n */\n public iso?: string = 'USD';\n\n /**\n * Specifies the locale code to use when formatting.\n */\n public locale?: string;\n\n /**\n * Specifies the minimum number of digits after the decimal separator. This property only applies\n * when the `truncate` property is set to `false`. If `digits` specifies a maximum number of\n * digits, then `minDigits` must be less than that value.\n */\n public minDigits?: number;\n\n /**\n * Indicates whether to shorten numbers to rounded numbers and abbreviation characters\n * such as K for thousands, M for millions, B for billions, and T for trillion.\n */\n public truncate?: boolean = true;\n\n /**\n * Specifies the starting point after which numbers are shortened to rounded numbers\n * and abbreviation characters.\n * @default 0\n */\n public truncateAfter?: number = 0;\n}\n"]}
1
+ {"version":3,"file":"numeric.options.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/numeric/numeric.options.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,cAAc;IAA3B;QACE;;;WAGG;QACI,WAAM,GAAY,CAAC,CAAC;QAE3B;;;WAGG;QACI,WAAM,GAAY,QAAQ,CAAC;QAElC;;;WAGG;QACI,iBAAY,GAA+B,UAAU,CAAC;QAE7D;;;;;WAKG;QACI,QAAG,GAAY,KAAK,CAAC;QAc5B;;;WAGG;QACI,aAAQ,GAAa,IAAI,CAAC;QAEjC;;;;WAIG;QACI,kBAAa,GAAY,CAAC,CAAC;IACpC,CAAC;CAAA","sourcesContent":["/**\n * Provides arguments for the number to format.\n */\nexport class NumericOptions {\n /**\n * Specifies the maximum number of digits after the decimal separator.\n * @default 1\n */\n public digits?: number = 1;\n\n /**\n * Specifies how to format the number. Options are `currency` or `number`.\n * @default \"number\"\n */\n public format?: string = 'number';\n\n /**\n * Specifies the format of the currency.\n * @default \"standard\"\n */\n public currencySign?: 'accounting' | 'standard' = 'standard';\n\n /**\n * Specifies the ISO4217 currency code to use for currency formatting. If you do not specify a\n * currency code, the component uses the browser's culture to determine the currency unless your\n * SPA provides a different culture with `SkyAppLocaleProvider`.\n * @default \"USD\"\n */\n public iso?: string = 'USD';\n\n /**\n * Specifies the locale code to use when formatting.\n */\n public locale?: string;\n\n /**\n * Specifies the minimum number of digits after the decimal separator. This property only applies\n * when the `truncate` property is set to `false`. If `digits` specifies a maximum number of\n * digits, then `minDigits` must be less than that value.\n */\n public minDigits?: number;\n\n /**\n * Indicates whether to shorten numbers to rounded numbers and abbreviation characters\n * such as K for thousands, M for millions, B for billions, and T for trillions.\n */\n public truncate?: boolean = true;\n\n /**\n * Specifies the starting point after which numbers are shortened to rounded numbers\n * and abbreviation characters.\n * @default 0\n */\n public truncateAfter?: number = 0;\n}\n"]}
@@ -59,6 +59,7 @@ export class SkyNumericService {
59
59
  this.storeShortenSymbol(output);
60
60
  const locale = options.locale || this.currentLocale;
61
61
  let digits;
62
+ let isDecimal;
62
63
  // Checks the string entered for format. Using toLowerCase to ignore case.
63
64
  switch ((_a = options.format) === null || _a === void 0 ? void 0 : _a.toLowerCase()) {
64
65
  // In a case where a decimal value was not shortened and
@@ -67,7 +68,7 @@ export class SkyNumericService {
67
68
  // Note: This will need to be reviewed if we support currencies with
68
69
  // three decimal digits.
69
70
  case 'currency':
70
- const isDecimal = value % 1 !== 0;
71
+ isDecimal = value % 1 !== 0;
71
72
  if (options.minDigits) {
72
73
  digits = `1.${options.minDigits}-${options.digits}`;
73
74
  }
@@ -77,12 +78,12 @@ export class SkyNumericService {
77
78
  else {
78
79
  digits = `1.0-${options.digits}`;
79
80
  }
81
+ output = SkyNumberFormatUtility.formatNumber(locale, parseFloat(output), SkyIntlNumberFormatStyle.Currency, digits, options.iso,
80
82
  // Angular 5+ needs a string for this parameter, but Angular 4 needs a boolean.
81
83
  // To support both versions we can supply 'symbol' which will evaluate truthy for Angular 4
82
84
  // and the appropriate string value for Angular 5+.
83
85
  // See: https://angular.io/api/common/CurrencyPipe#parameters
84
- const symbolDisplay = 'symbol';
85
- output = SkyNumberFormatUtility.formatNumber(locale, parseFloat(output), SkyIntlNumberFormatStyle.Currency, digits, options.iso, symbolDisplay, options.currencySign);
86
+ 'symbol', options.currencySign);
86
87
  break;
87
88
  // The following is a catch-all to ensure that if
88
89
  // anything but currency (or a future option) are entered,
@@ -1 +1 @@
1
- {"version":3,"file":"numeric.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/numeric/numeric.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,+CAA+C,CAAC;;;AAQvF,MAAM,OAAO,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kB,CAAC,KAAa;QACtC,MAAM,OAAO,GAAa,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC/D,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,CAAC;QACnD,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAClC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACnD,CAAC;IAED;;;;;;OAMG;IACK,oBAAoB,CAAC,KAAa;QACxC,MAAM,MAAM,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;QACzC,MAAM,MAAM,GACV,KAAK,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAEpE,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,SAAS,CAAC,GAAW;QAC3B,6EAA6E;QAC7E,OAAO,IAAI,CAAC,gBAAgB,CAAC,kBAAkB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,GAAG,CAAC,CAAC;IAC5E,CAAC;;+GAzOU,iBAAiB;mHAAjB,iBAAiB,cAFhB,KAAK;4FAEN,iBAAiB;kBAH7B,UAAU;mBAAC;oBACV,UAAU,EAAE,KAAK;iBAClB","sourcesContent":["import { Injectable } from '@angular/core';\nimport { SkyIntlNumberFormatStyle, SkyLibResourcesService } from '@skyux/i18n';\n\nimport { SkyNumberFormatUtility } from '../shared/number-format/number-format-utility';\n\nimport { SkyNumericSymbol } from './numeric-symbol';\nimport { NumericOptions } from './numeric.options';\n\n@Injectable({\n providedIn: 'any',\n})\nexport class SkyNumericService {\n /**\n * The browser's current locale.\n * @internal\n */\n public set currentLocale(value: string) {\n this._locale = value;\n }\n\n public get currentLocale(): string {\n return this._locale || 'en-US';\n }\n\n /**\n * @internal\n */\n public shortSymbol: string;\n\n private symbolIndex: SkyNumericSymbol[] = [\n { value: 1e12, label: this.getSymbol('skyux_numeric_trillions_symbol') },\n { value: 1e9, label: this.getSymbol('skyux_numeric_billions_symbol') },\n { value: 1e6, label: this.getSymbol('skyux_numeric_millions_symbol') },\n { value: 1e3, label: this.getSymbol('skyux_numeric_thousands_symbol') },\n ];\n\n private _locale: string;\n\n constructor(private resourcesService: SkyLibResourcesService) {}\n\n /**\n * Shortens with or without symbol (K/M/B/T) depending on value of number.\n * @param value The number to format.\n * @param options Format options.\n */\n public formatNumber(value: number, options: NumericOptions): string {\n /* tslint:disable-next-line:no-null-keyword */\n if (isNaN(value) || value === null) {\n return '';\n }\n\n const decimalPlaceRegExp = /\\.0+$|(\\.[0-9]*[1-9])0+$/;\n\n // Get the symbol for the number after rounding, since rounding could push the number\n // into a different symbol range.\n let roundedNumber = this.roundNumber(value, options.digits);\n const roundedNumberAbs = Math.abs(roundedNumber);\n\n let suffix = '';\n\n for (let i = 0; i < this.symbolIndex.length; i++) {\n let symbol = this.symbolIndex[i];\n\n if (\n options.truncate &&\n roundedNumberAbs >= options.truncateAfter &&\n roundedNumberAbs >= symbol.value\n ) {\n roundedNumber = this.roundNumber(value / symbol.value, options.digits);\n\n if (Math.abs(roundedNumber) === 1000 && i > 0) {\n // Rounding caused the number to cross into the range of the next symbol.\n symbol = this.symbolIndex[i - 1];\n roundedNumber /= 1000;\n }\n\n suffix = symbol.label;\n\n break;\n }\n }\n\n let output =\n roundedNumber.toString().replace(decimalPlaceRegExp, '$1') + suffix;\n\n this.storeShortenSymbol(output);\n\n const locale = options.locale || this.currentLocale;\n\n let digits: string;\n // Checks the string entered for format. Using toLowerCase to ignore case.\n switch (options.format?.toLowerCase()) {\n // In a case where a decimal value was not shortened and\n // the digit input is 2 or higher, it forces 2 digits.\n // For example, this prevents a value like $15.50 from displaying as $15.5.\n // Note: This will need to be reviewed if we support currencies with\n // three decimal digits.\n case 'currency':\n const isDecimal = value % 1 !== 0;\n\n if (options.minDigits) {\n digits = `1.${options.minDigits}-${options.digits}`;\n } else if (isDecimal && options.digits >= 2) {\n digits = `1.2-${options.digits}`;\n } else {\n digits = `1.0-${options.digits}`;\n }\n\n // Angular 5+ needs a string for this parameter, but Angular 4 needs a boolean.\n // To support both versions we can supply 'symbol' which will evaluate truthy for Angular 4\n // and the appropriate string value for Angular 5+.\n // See: https://angular.io/api/common/CurrencyPipe#parameters\n const symbolDisplay: any = 'symbol';\n\n output = SkyNumberFormatUtility.formatNumber(\n locale,\n parseFloat(output),\n SkyIntlNumberFormatStyle.Currency,\n digits,\n options.iso,\n symbolDisplay,\n options.currencySign\n );\n break;\n\n // The following is a catch-all to ensure that if\n // anything but currency (or a future option) are entered,\n // it will be treated like a number.\n default:\n // Ensures localization of the number to ensure comma and\n // decimal separator\n if (options.minDigits) {\n digits = `1.${options.minDigits}-${options.digits}`;\n } else if (options.truncate) {\n digits = `1.0-${options.digits}`;\n } else {\n digits = `1.${options.digits}-${options.digits}`;\n }\n\n output = SkyNumberFormatUtility.formatNumber(\n locale,\n parseFloat(output),\n SkyIntlNumberFormatStyle.Decimal,\n digits\n );\n break;\n }\n\n if (options.truncate) {\n output = this.replaceShortenSymbol(output);\n }\n\n return output;\n }\n\n /**\n * Rounds a given number\n *\n * JS's limitation - numbers bigger than Number.MIN_SAFE_INTEGER or Number.MAX_SAFE_INTEGER\n * are not guaranteed to be represented or rounded correctly\n * @param value - value to round\n * @param precision - what precision to round with, defaults to 0 decimal places\n */\n private roundNumber(value: number, precision: number = 0): number {\n if (precision < 0) {\n throw new Error('SkyInvalidArgument: precision must be >= 0');\n }\n\n /* tslint:disable-next-line:no-null-keyword */\n /* Sanity check - ignoring coverage but should not ignore if we make this method public */\n /* istanbul ignore next */\n if (isNaN(value) || value === null) {\n return 0;\n }\n\n const scaledValue: number = this.scaleNumberByPowerOfTen(\n value,\n precision,\n true\n );\n const scaledRoundedValue: number = Math.round(scaledValue);\n const unscaledRoundedValue: number = this.scaleNumberByPowerOfTen(\n scaledRoundedValue,\n precision,\n false\n );\n\n return unscaledRoundedValue;\n }\n\n /**\n * Scales a given number by a power of 10\n * @param value - value to scale\n * @param scalar - 10^scalar\n * @param scaleUp - whether to increase or decrease the value\n */\n private scaleNumberByPowerOfTen(\n value: number,\n scalar: number,\n scaleUp: boolean\n ): number {\n const valueStr: string = value.toString().toLowerCase();\n const isExponentFormat: boolean = valueStr.includes('e');\n\n if (isExponentFormat) {\n const [base, exp] = valueStr.split('e');\n const newExp = scaleUp ? Number(exp) + scalar : Number(exp) - scalar;\n return Number(`${base}e${newExp}`);\n } else {\n const e = scaleUp ? 'e' : 'e-';\n return Number(`${value}${e}${scalar}`);\n }\n }\n\n /**\n * Stores the symbol added from shortening to reapply later.\n * @param value The string to derive the shorten symbol from.\n */\n private storeShortenSymbol(value: string): void {\n const symbols: string[] = this.symbolIndex.map((s) => s.label);\n const regexp = new RegExp(symbols.join('|'), 'ig');\n const match = value.match(regexp);\n this.shortSymbol = match ? match.toString() : '';\n }\n\n /**\n * Must have previously called storeShortenSymbol to have something to replace.\n * Finds the last number in the formatted number, gets the index of the position\n * after that character and re-inserts the symbol.\n * Works regardless of currency symbol position.\n * @param value The string to modify.\n */\n private replaceShortenSymbol(value: string): string {\n const result = /(\\d)(?!.*\\d)/g.exec(value);\n const pos = result.index + result.length;\n const output =\n value.substring(0, pos) + this.shortSymbol + value.substring(pos);\n\n return output;\n }\n\n private getSymbol(key: string): string {\n // TODO: Need to implement the async `getString` method in a breaking change.\n return this.resourcesService.getStringForLocale({ locale: 'en_US' }, key);\n }\n}\n"]}
1
+ {"version":3,"file":"numeric.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/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UAAU;mBAAC;oBACV,UAAU,EAAE,KAAK;iBAClB","sourcesContent":["import { Injectable } from '@angular/core';\nimport { SkyIntlNumberFormatStyle, SkyLibResourcesService } from '@skyux/i18n';\n\nimport { SkyNumberFormatUtility } from '../shared/number-format/number-format-utility';\n\nimport { SkyNumericSymbol } from './numeric-symbol';\nimport { NumericOptions } from './numeric.options';\n\n@Injectable({\n providedIn: 'any',\n})\nexport class SkyNumericService {\n /**\n * The browser's current locale.\n * @internal\n */\n public set currentLocale(value: string) {\n this._locale = value;\n }\n\n public get currentLocale(): string {\n return this._locale || 'en-US';\n }\n\n /**\n * @internal\n */\n public shortSymbol: string;\n\n private symbolIndex: SkyNumericSymbol[] = [\n { value: 1e12, label: this.getSymbol('skyux_numeric_trillions_symbol') },\n { value: 1e9, label: this.getSymbol('skyux_numeric_billions_symbol') },\n { value: 1e6, label: this.getSymbol('skyux_numeric_millions_symbol') },\n { value: 1e3, label: this.getSymbol('skyux_numeric_thousands_symbol') },\n ];\n\n private _locale: string;\n\n constructor(private resourcesService: SkyLibResourcesService) {}\n\n /**\n * Shortens with or without symbol (K/M/B/T) depending on value of number.\n * @param value The number to format.\n * @param options Format options.\n */\n public formatNumber(value: number, options: NumericOptions): string {\n /* tslint:disable-next-line:no-null-keyword */\n if (isNaN(value) || value === null) {\n return '';\n }\n\n const decimalPlaceRegExp = /\\.0+$|(\\.[0-9]*[1-9])0+$/;\n\n // Get the symbol for the number after rounding, since rounding could push the number\n // into a different symbol range.\n let roundedNumber = this.roundNumber(value, options.digits);\n const roundedNumberAbs = Math.abs(roundedNumber);\n\n let suffix = '';\n\n for (let i = 0; i < this.symbolIndex.length; i++) {\n let symbol = this.symbolIndex[i];\n\n if (\n options.truncate &&\n roundedNumberAbs >= options.truncateAfter &&\n roundedNumberAbs >= symbol.value\n ) {\n roundedNumber = this.roundNumber(value / symbol.value, options.digits);\n\n if (Math.abs(roundedNumber) === 1000 && i > 0) {\n // Rounding caused the number to cross into the range of the next symbol.\n symbol = this.symbolIndex[i - 1];\n roundedNumber /= 1000;\n }\n\n suffix = symbol.label;\n\n break;\n }\n }\n\n let output =\n roundedNumber.toString().replace(decimalPlaceRegExp, '$1') + suffix;\n\n this.storeShortenSymbol(output);\n\n const locale = options.locale || this.currentLocale;\n\n let digits: string;\n let isDecimal: boolean;\n\n // Checks the string entered for format. Using toLowerCase to ignore case.\n switch (options.format?.toLowerCase()) {\n // In a case where a decimal value was not shortened and\n // the digit input is 2 or higher, it forces 2 digits.\n // For example, this prevents a value like $15.50 from displaying as $15.5.\n // Note: This will need to be reviewed if we support currencies with\n // three decimal digits.\n case 'currency':\n isDecimal = value % 1 !== 0;\n\n if (options.minDigits) {\n digits = `1.${options.minDigits}-${options.digits}`;\n } else if (isDecimal && options.digits >= 2) {\n digits = `1.2-${options.digits}`;\n } else {\n digits = `1.0-${options.digits}`;\n }\n\n output = SkyNumberFormatUtility.formatNumber(\n locale,\n parseFloat(output),\n SkyIntlNumberFormatStyle.Currency,\n digits,\n options.iso,\n // Angular 5+ needs a string for this parameter, but Angular 4 needs a boolean.\n // To support both versions we can supply 'symbol' which will evaluate truthy for Angular 4\n // and the appropriate string value for Angular 5+.\n // See: https://angular.io/api/common/CurrencyPipe#parameters\n 'symbol' as any,\n options.currencySign\n );\n break;\n\n // The following is a catch-all to ensure that if\n // anything but currency (or a future option) are entered,\n // it will be treated like a number.\n default:\n // Ensures localization of the number to ensure comma and\n // decimal separator\n if (options.minDigits) {\n digits = `1.${options.minDigits}-${options.digits}`;\n } else if (options.truncate) {\n digits = `1.0-${options.digits}`;\n } else {\n digits = `1.${options.digits}-${options.digits}`;\n }\n\n output = SkyNumberFormatUtility.formatNumber(\n locale,\n parseFloat(output),\n SkyIntlNumberFormatStyle.Decimal,\n digits\n );\n break;\n }\n\n if (options.truncate) {\n output = this.replaceShortenSymbol(output);\n }\n\n return output;\n }\n\n /**\n * Rounds a given number\n *\n * JS's limitation - numbers bigger than Number.MIN_SAFE_INTEGER or Number.MAX_SAFE_INTEGER\n * are not guaranteed to be represented or rounded correctly\n * @param value - value to round\n * @param precision - what precision to round with, defaults to 0 decimal places\n */\n private roundNumber(value: number, precision: number = 0): number {\n if (precision < 0) {\n throw new Error('SkyInvalidArgument: precision must be >= 0');\n }\n\n /* tslint:disable-next-line:no-null-keyword */\n /* Sanity check - ignoring coverage but should not ignore if we make this method public */\n /* istanbul ignore next */\n if (isNaN(value) || value === null) {\n return 0;\n }\n\n const scaledValue: number = this.scaleNumberByPowerOfTen(\n value,\n precision,\n true\n );\n const scaledRoundedValue: number = Math.round(scaledValue);\n const unscaledRoundedValue: number = this.scaleNumberByPowerOfTen(\n scaledRoundedValue,\n precision,\n false\n );\n\n return unscaledRoundedValue;\n }\n\n /**\n * Scales a given number by a power of 10\n * @param value - value to scale\n * @param scalar - 10^scalar\n * @param scaleUp - whether to increase or decrease the value\n */\n private scaleNumberByPowerOfTen(\n value: number,\n scalar: number,\n scaleUp: boolean\n ): number {\n const valueStr: string = value.toString().toLowerCase();\n const isExponentFormat: boolean = valueStr.includes('e');\n\n if (isExponentFormat) {\n const [base, exp] = valueStr.split('e');\n const newExp = scaleUp ? Number(exp) + scalar : Number(exp) - scalar;\n return Number(`${base}e${newExp}`);\n } else {\n const e = scaleUp ? 'e' : 'e-';\n return Number(`${value}${e}${scalar}`);\n }\n }\n\n /**\n * Stores the symbol added from shortening to reapply later.\n * @param value The string to derive the shorten symbol from.\n */\n private storeShortenSymbol(value: string): void {\n const symbols: string[] = this.symbolIndex.map((s) => s.label);\n const regexp = new RegExp(symbols.join('|'), 'ig');\n const match = value.match(regexp);\n this.shortSymbol = match ? match.toString() : '';\n }\n\n /**\n * Must have previously called storeShortenSymbol to have something to replace.\n * Finds the last number in the formatted number, gets the index of the position\n * after that character and re-inserts the symbol.\n * Works regardless of currency symbol position.\n * @param value The string to modify.\n */\n private replaceShortenSymbol(value: string): string {\n const result = /(\\d)(?!.*\\d)/g.exec(value);\n const pos = result.index + result.length;\n const output =\n value.substring(0, pos) + this.shortSymbol + value.substring(pos);\n\n return output;\n }\n\n private getSymbol(key: string): string {\n // TODO: Need to implement the async `getString` method in a breaking change.\n return this.resourcesService.getStringForLocale({ locale: 'en_US' }, key);\n }\n}\n"]}
@@ -33,20 +33,30 @@ export class SkyScrollableHostService {
33
33
  */
34
34
  watchScrollableHost(elementRef) {
35
35
  const subscribers = [];
36
- let mutationObserver;
36
+ let parentMutationObserver;
37
+ let documentHiddenElementMutationObserver;
37
38
  return new Observable((subscriber) => {
38
39
  subscribers.push(subscriber);
39
40
  let scrollableHost = this.findScrollableHost(elementRef.nativeElement);
40
41
  if (subscribers.length === 1) {
41
- mutationObserver = this.mutationObserverSvc.create(() => {
42
+ parentMutationObserver = this.mutationObserverSvc.create(() => {
42
43
  const newScrollableHost = this.findScrollableHost(elementRef.nativeElement);
43
- if (newScrollableHost !== scrollableHost) {
44
+ if (newScrollableHost !== scrollableHost &&
45
+ elementRef.nativeElement.offsetParent) {
44
46
  scrollableHost = newScrollableHost;
45
- this.observeForScrollableHostChanges(scrollableHost, mutationObserver);
47
+ this.observeForScrollableHostChanges(scrollableHost, parentMutationObserver);
46
48
  notifySubscribers(subscribers, scrollableHost);
47
49
  }
48
50
  });
49
- this.observeForScrollableHostChanges(scrollableHost, mutationObserver);
51
+ this.observeForScrollableHostChanges(scrollableHost, parentMutationObserver);
52
+ documentHiddenElementMutationObserver = this.mutationObserverSvc.create(() => {
53
+ if (!elementRef.nativeElement.offsetParent) {
54
+ scrollableHost = undefined;
55
+ this.observeForScrollableHostChanges(scrollableHost, parentMutationObserver);
56
+ notifySubscribers(subscribers, scrollableHost);
57
+ }
58
+ });
59
+ this.observeDocumentHiddenElementChanges(documentHiddenElementMutationObserver);
50
60
  }
51
61
  subscriber.next(scrollableHost);
52
62
  subscriber.add(() => {
@@ -57,7 +67,8 @@ export class SkyScrollableHostService {
57
67
  subscribers.splice(subIndex, 1);
58
68
  }
59
69
  if (subscribers.length === 0) {
60
- mutationObserver.disconnect();
70
+ documentHiddenElementMutationObserver.disconnect();
71
+ parentMutationObserver.disconnect();
61
72
  }
62
73
  });
63
74
  });
@@ -66,7 +77,7 @@ export class SkyScrollableHostService {
66
77
  * Returns an observable which emits whenever the element's scrollable host emits a scroll event. The observable will always emit the scroll events from the elements current scrollable host and will update based on any scrollable host changes. The observable will also emit once whenever the scrollable host changes.
67
78
  * @param elementRef The element whose scrollable host scroll events are being requested
68
79
  * @param completionObservable An observable which alerts the internal observers that they should complete
69
- * @returns An observable which emits the scroll events from the given element's scrollable host
80
+ * @returns An observable which emits when the elements scrollable host is scrolled or is changed
70
81
  */
71
82
  watchScrollableHostScrollEvents(elementRef) {
72
83
  const subscribers = [];
@@ -85,11 +96,13 @@ export class SkyScrollableHostService {
85
96
  }
86
97
  scrollableHost = newScrollableHost;
87
98
  newScrollableHostObservable = new Subject();
88
- scrollEventSubscription = fromEvent(newScrollableHost, 'scroll')
89
- .pipe(takeUntil(newScrollableHostObservable))
90
- .subscribe(() => {
91
- notifySubscribers(subscribers);
92
- });
99
+ if (newScrollableHost) {
100
+ scrollEventSubscription = fromEvent(newScrollableHost, 'scroll')
101
+ .pipe(takeUntil(newScrollableHostObservable))
102
+ .subscribe(() => {
103
+ notifySubscribers(subscribers);
104
+ });
105
+ }
93
106
  });
94
107
  }
95
108
  subscriber.add(() => {
@@ -132,12 +145,20 @@ export class SkyScrollableHostService {
132
145
  }
133
146
  return parent;
134
147
  }
148
+ observeDocumentHiddenElementChanges(mutationObserver) {
149
+ mutationObserver.observe(document.documentElement, {
150
+ attributes: true,
151
+ attributeFilter: ['class', 'style', 'hidden'],
152
+ childList: true,
153
+ subtree: true,
154
+ });
155
+ }
135
156
  observeForScrollableHostChanges(element, mutationObserver) {
136
157
  mutationObserver.disconnect();
137
158
  if (element instanceof HTMLElement) {
138
159
  mutationObserver.observe(element, {
139
160
  attributes: true,
140
- attributeFilter: ['class', 'style.overflow', 'style.overflow-y'],
161
+ attributeFilter: ['class', 'style'],
141
162
  childList: true,
142
163
  subtree: true,
143
164
  });
@@ -145,7 +166,7 @@ export class SkyScrollableHostService {
145
166
  else {
146
167
  mutationObserver.observe(document.documentElement, {
147
168
  attributes: true,
148
- attributeFilter: ['class', 'style.overflow', 'style.overflow-y'],
169
+ attributeFilter: ['class', 'style'],
149
170
  childList: true,
150
171
  subtree: true,
151
172
  });
@@ -1 +1 @@
1
- {"version":3,"file":"scrollable-host.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/scrollable-host/scrollable-host.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,OAAO,EAA4B,SAAS,EAAE,MAAM,MAAM,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;;;;AAEvD,SAAS,iBAAiB,CAAC,WAAkC,EAAE,IAAc;IAC3E,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE;QACpC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;KACvB;AACH,CAAC;AAKD,MAAM,OAAO,wBAAwB;IACnC,YACU,mBAA4C,EAC5C,SAA0B;QAD1B,wBAAmB,GAAnB,mBAAmB,CAAyB;QAC5C,cAAS,GAAT,SAAS,CAAiB;IACjC,CAAC;IAEJ;;;;OAIG;IACI,iBAAiB,CAAC,UAAsB;QAC7C,OAAO,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IAC3D,CAAC;IAED;;;;;;OAMG;IACI,mBAAmB,CACxB,UAAsB;QAEtB,MAAM,WAAW,GAAuC,EAAE,CAAC;QAC3D,IAAI,gBAAkC,CAAC;QAEvC,OAAO,IAAI,UAAU,CAAC,CAAC,UAAU,EAAE,EAAE;YACnC,WAAW,CAAC,IAAI,CAA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gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,EAAE;gBACjD,UAAU,EAAE,IAAI;gBAChB,eAAe,EAAE,CAAC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,CAAC;gBAChE,SAAS,EAAE,IAAI;gBACf,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;SACJ;IACH,CAAC;;sHAlLU,wBAAwB;0HAAxB,wBAAwB,cAFvB,MAAM;4FAEP,wBAAwB;kBAHpC,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB","sourcesContent":["import { ElementRef, Injectable } from '@angular/core';\n\nimport { Observable, Subject, Subscriber, Subscription, fromEvent } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\nimport { MutationObserverService } from '../mutation/mutation-observer-service';\nimport { SkyAppWindowRef } from '../window/window-ref';\n\nfunction notifySubscribers(subscribers: Subscriber<unknown>[], item?: unknown) {\n for (const subscriber of subscribers) {\n subscriber.next(item);\n }\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SkyScrollableHostService {\n constructor(\n private mutationObserverSvc: MutationObserverService,\n private windowRef: SkyAppWindowRef\n ) {}\n\n /**\n * Returns the given element's current scrollable host\n * @param elementRef The element whose scrollable host is being requested\n * @returns The current scrollable host\n */\n public getScrollableHost(elementRef: ElementRef): HTMLElement | Window {\n return this.findScrollableHost(elementRef.nativeElement);\n }\n\n /**\n * Returns an observable which emits the given element's current scrollable host\n * @param elementRef The element whose scrollable host is being requested\n * @param completionObservable An observable which alerts the internal observers that they should complete\n * @returns An observable which emits the current scrollable host\n * @internal\n */\n public watchScrollableHost(\n elementRef: ElementRef\n ): Observable<HTMLElement | Window> {\n const subscribers: Subscriber<HTMLElement | Window>[] = [];\n let mutationObserver: MutationObserver;\n\n return new Observable((subscriber) => {\n subscribers.push(subscriber);\n\n let scrollableHost = this.findScrollableHost(elementRef.nativeElement);\n if (subscribers.length === 1) {\n mutationObserver = this.mutationObserverSvc.create(() => {\n const newScrollableHost = this.findScrollableHost(\n elementRef.nativeElement\n );\n\n if (newScrollableHost !== scrollableHost) {\n scrollableHost = newScrollableHost;\n this.observeForScrollableHostChanges(\n scrollableHost,\n mutationObserver\n );\n\n notifySubscribers(subscribers, scrollableHost);\n }\n });\n this.observeForScrollableHostChanges(scrollableHost, mutationObserver);\n }\n subscriber.next(scrollableHost);\n\n subscriber.add(() => {\n const subIndex = subscribers.indexOf(subscriber);\n\n /* sanity check */\n /* istanbul ignore else */\n if (subIndex >= 0) {\n subscribers.splice(subIndex, 1);\n }\n\n if (subscribers.length === 0) {\n mutationObserver.disconnect();\n }\n });\n });\n }\n\n /**\n * Returns an observable which emits whenever the element's scrollable host emits a scroll event. The observable will always emit the scroll events from the elements current scrollable host and will update based on any scrollable host changes. The observable will also emit once whenever the scrollable host changes.\n * @param elementRef The element whose scrollable host scroll events are being requested\n * @param completionObservable An observable which alerts the internal observers that they should complete\n * @returns An observable which emits the scroll events from the given element's scrollable host\n */\n public watchScrollableHostScrollEvents(\n elementRef: ElementRef\n ): Observable<void> {\n const subscribers: Subscriber<void>[] = [];\n let scrollableHost: HTMLElement | Window;\n\n let newScrollableHostObservable = new Subject();\n let scrollableHostSubscription: Subscription;\n let scrollEventSubscription: Subscription;\n return new Observable((subscriber) => {\n subscribers.push(subscriber);\n\n if (subscribers.length === 1) {\n scrollableHostSubscription = this.watchScrollableHost(\n elementRef\n ).subscribe((newScrollableHost) => {\n newScrollableHostObservable.next();\n newScrollableHostObservable.complete();\n if (scrollableHost && scrollableHost !== newScrollableHost) {\n notifySubscribers(subscribers);\n }\n scrollableHost = newScrollableHost;\n newScrollableHostObservable = new Subject();\n scrollEventSubscription = fromEvent(newScrollableHost, 'scroll')\n .pipe(takeUntil(newScrollableHostObservable))\n .subscribe(() => {\n notifySubscribers(subscribers);\n });\n });\n }\n\n subscriber.add(() => {\n const subIndex = subscribers.indexOf(subscriber);\n\n /* sanity check */\n /* istanbul ignore else */\n if (subIndex >= 0) {\n subscribers.splice(subIndex, 1);\n }\n\n if (subscribers.length === 0) {\n scrollableHostSubscription.unsubscribe();\n scrollEventSubscription.unsubscribe();\n newScrollableHostObservable.complete();\n }\n });\n });\n }\n\n private findScrollableHost(element: HTMLElement): HTMLElement | Window {\n const regex = /(auto|scroll)/;\n const windowObj = this.windowRef.nativeWindow;\n const bodyObj = windowObj.document.body;\n\n /* Sanity check */\n if (!element) {\n return windowObj;\n }\n\n let style = windowObj.getComputedStyle(element);\n let parent: HTMLElement = element;\n\n do {\n parent = parent.parentNode as HTMLElement;\n\n /* Sanity check for if this function is called for an element which has been removed from the DOM */\n if (!(parent instanceof HTMLElement)) {\n return windowObj;\n }\n\n style = windowObj.getComputedStyle(parent);\n } while (\n !regex.test(style.overflow) &&\n !regex.test(style.overflowY) &&\n parent !== bodyObj\n );\n\n if (parent === bodyObj) {\n return windowObj;\n }\n\n return parent;\n }\n\n private observeForScrollableHostChanges(\n element: HTMLElement | Window,\n mutationObserver: MutationObserver\n ) {\n mutationObserver.disconnect();\n if (element instanceof HTMLElement) {\n mutationObserver.observe(element, {\n attributes: true,\n attributeFilter: ['class', 'style.overflow', 'style.overflow-y'],\n childList: true,\n subtree: true,\n });\n } else {\n mutationObserver.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['class', 'style.overflow', 'style.overflow-y'],\n childList: true,\n subtree: true,\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"scrollable-host.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/scrollable-host/scrollable-host.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,MAAM,eAAe,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,OAAO,EAA4B,SAAS,EAAE,MAAM,MAAM,CAAC;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,C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AAE,CAAC,OAAO,EAAE,OAAO,CAAC;gBACnC,SAAS,EAAE,IAAI;gBACf,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;SACJ;aAAM;YACL,gBAAgB,CAAC,OAAO,CAAC,QAAQ,CAAC,eAAe,EAAE;gBACjD,UAAU,EAAE,IAAI;gBAChB,eAAe,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC;gBACnC,SAAS,EAAE,IAAI;gBACf,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;SACJ;IACH,CAAC;;sHAzNU,wBAAwB;0HAAxB,wBAAwB,cAFvB,MAAM;4FAEP,wBAAwB;kBAHpC,UAAU;mBAAC;oBACV,UAAU,EAAE,MAAM;iBACnB","sourcesContent":["import { ElementRef, Injectable } from '@angular/core';\n\nimport { Observable, Subject, Subscriber, Subscription, fromEvent } from 'rxjs';\nimport { takeUntil } from 'rxjs/operators';\n\nimport { MutationObserverService } from '../mutation/mutation-observer-service';\nimport { SkyAppWindowRef } from '../window/window-ref';\n\nfunction notifySubscribers(subscribers: Subscriber<unknown>[], item?: unknown) {\n for (const subscriber of subscribers) {\n subscriber.next(item);\n }\n}\n\n@Injectable({\n providedIn: 'root',\n})\nexport class SkyScrollableHostService {\n constructor(\n private mutationObserverSvc: MutationObserverService,\n private windowRef: SkyAppWindowRef\n ) {}\n\n /**\n * Returns the given element's current scrollable host\n * @param elementRef The element whose scrollable host is being requested\n * @returns The current scrollable host\n */\n public getScrollableHost(elementRef: ElementRef): HTMLElement | Window {\n return this.findScrollableHost(elementRef.nativeElement);\n }\n\n /**\n * Returns an observable which emits the given element's current scrollable host\n * @param elementRef The element whose scrollable host is being requested\n * @param completionObservable An observable which alerts the internal observers that they should complete\n * @returns An observable which emits the current scrollable host\n * @internal\n */\n public watchScrollableHost(\n elementRef: ElementRef\n ): Observable<HTMLElement | Window> {\n const subscribers: Subscriber<HTMLElement | Window>[] = [];\n let parentMutationObserver: MutationObserver;\n let documentHiddenElementMutationObserver: MutationObserver;\n\n return new Observable((subscriber) => {\n subscribers.push(subscriber);\n\n let scrollableHost = this.findScrollableHost(elementRef.nativeElement);\n if (subscribers.length === 1) {\n parentMutationObserver = this.mutationObserverSvc.create(() => {\n const newScrollableHost = this.findScrollableHost(\n elementRef.nativeElement\n );\n\n if (\n newScrollableHost !== scrollableHost &&\n elementRef.nativeElement.offsetParent\n ) {\n scrollableHost = newScrollableHost;\n this.observeForScrollableHostChanges(\n scrollableHost,\n parentMutationObserver\n );\n\n notifySubscribers(subscribers, scrollableHost);\n }\n });\n this.observeForScrollableHostChanges(\n scrollableHost,\n parentMutationObserver\n );\n\n documentHiddenElementMutationObserver = this.mutationObserverSvc.create(\n () => {\n if (!elementRef.nativeElement.offsetParent) {\n scrollableHost = undefined;\n\n this.observeForScrollableHostChanges(\n scrollableHost,\n parentMutationObserver\n );\n\n notifySubscribers(subscribers, scrollableHost);\n }\n }\n );\n this.observeDocumentHiddenElementChanges(\n documentHiddenElementMutationObserver\n );\n }\n subscriber.next(scrollableHost);\n\n subscriber.add(() => {\n const subIndex = subscribers.indexOf(subscriber);\n\n /* sanity check */\n /* istanbul ignore else */\n if (subIndex >= 0) {\n subscribers.splice(subIndex, 1);\n }\n\n if (subscribers.length === 0) {\n documentHiddenElementMutationObserver.disconnect();\n parentMutationObserver.disconnect();\n }\n });\n });\n }\n\n /**\n * Returns an observable which emits whenever the element's scrollable host emits a scroll event. The observable will always emit the scroll events from the elements current scrollable host and will update based on any scrollable host changes. The observable will also emit once whenever the scrollable host changes.\n * @param elementRef The element whose scrollable host scroll events are being requested\n * @param completionObservable An observable which alerts the internal observers that they should complete\n * @returns An observable which emits when the elements scrollable host is scrolled or is changed\n */\n public watchScrollableHostScrollEvents(\n elementRef: ElementRef\n ): Observable<void> {\n const subscribers: Subscriber<void>[] = [];\n let scrollableHost: HTMLElement | Window;\n\n let newScrollableHostObservable = new Subject();\n let scrollableHostSubscription: Subscription;\n let scrollEventSubscription: Subscription;\n return new Observable((subscriber) => {\n subscribers.push(subscriber);\n\n if (subscribers.length === 1) {\n scrollableHostSubscription = this.watchScrollableHost(\n elementRef\n ).subscribe((newScrollableHost) => {\n newScrollableHostObservable.next();\n newScrollableHostObservable.complete();\n if (scrollableHost && scrollableHost !== newScrollableHost) {\n notifySubscribers(subscribers);\n }\n scrollableHost = newScrollableHost;\n newScrollableHostObservable = new Subject();\n if (newScrollableHost) {\n scrollEventSubscription = fromEvent(newScrollableHost, 'scroll')\n .pipe(takeUntil(newScrollableHostObservable))\n .subscribe(() => {\n notifySubscribers(subscribers);\n });\n }\n });\n }\n\n subscriber.add(() => {\n const subIndex = subscribers.indexOf(subscriber);\n\n /* sanity check */\n /* istanbul ignore else */\n if (subIndex >= 0) {\n subscribers.splice(subIndex, 1);\n }\n\n if (subscribers.length === 0) {\n scrollableHostSubscription.unsubscribe();\n scrollEventSubscription.unsubscribe();\n newScrollableHostObservable.complete();\n }\n });\n });\n }\n\n private findScrollableHost(element: HTMLElement): HTMLElement | Window {\n const regex = /(auto|scroll)/;\n const windowObj = this.windowRef.nativeWindow;\n const bodyObj = windowObj.document.body;\n\n /* Sanity check */\n if (!element) {\n return windowObj;\n }\n\n let style = windowObj.getComputedStyle(element);\n let parent: HTMLElement = element;\n\n do {\n parent = parent.parentNode as HTMLElement;\n\n /* Sanity check for if this function is called for an element which has been removed from the DOM */\n if (!(parent instanceof HTMLElement)) {\n return windowObj;\n }\n\n style = windowObj.getComputedStyle(parent);\n } while (\n !regex.test(style.overflow) &&\n !regex.test(style.overflowY) &&\n parent !== bodyObj\n );\n\n if (parent === bodyObj) {\n return windowObj;\n }\n\n return parent;\n }\n\n private observeDocumentHiddenElementChanges(\n mutationObserver: MutationObserver\n ) {\n mutationObserver.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['class', 'style', 'hidden'],\n childList: true,\n subtree: true,\n });\n }\n\n private observeForScrollableHostChanges(\n element: HTMLElement | Window,\n mutationObserver: MutationObserver\n ) {\n mutationObserver.disconnect();\n if (element instanceof HTMLElement) {\n mutationObserver.observe(element, {\n attributes: true,\n attributeFilter: ['class', 'style'],\n childList: true,\n subtree: true,\n });\n } else {\n mutationObserver.observe(document.documentElement, {\n attributes: true,\n attributeFilter: ['class', 'style'],\n childList: true,\n subtree: true,\n });\n }\n }\n}\n"]}
@@ -19,8 +19,6 @@ function parseIntAutoRadix(text) {
19
19
  // See: https://github.com/ng-packagr/ng-packagr/issues/641
20
20
  // @dynamic
21
21
  export class SkyNumberFormatUtility {
22
- /* istanbul ignore next */
23
- constructor() { }
24
22
  static formatNumber(locale, value, style, digits, currency = null, currencyAsSymbol = false, currencySign) {
25
23
  if (value == null) {
26
24
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"number-format-utility.js","sourceRoot":"","sources":["../../../../../../../../../libs/components/core/src/lib/modules/shared/number-format/number-format-utility.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,0FAA0F;AAC1F,+FAA+F;AAC/F,oBAAoB;AACpB,yFAAyF;AACzF,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE/E,SAAS,SAAS,CAAC,KAAU;IAC3B,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY;IACrC,MAAM,MAAM,GAAW,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAE1C,0BAA0B;IAC1B,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,uCAAuC,GAAG,IAAI,CAAC,CAAC;KACjE;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,qEAAqE;AACrE,2DAA2D;AAC3D,WAAW;AACX,MAAM,OAAO,sBAAsB;IAGjC,0BAA0B;IAC1B,gBAAe,CAAC;IAET,MAAM,CAAC,YAAY,CACxB,MAAc,EACd,KAAsB,EACtB,KAA+B,EAC/B,MAAsB,EACtB,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AI,EAAE;gBACpB,sBAAsB;gBACtB,WAAW,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;aAC3C;SACF;QAED,OAAO,sBAAsB,CAAC,MAAM,CAAC,KAAe,EAAE,MAAM,EAAE,KAAK,EAAE;YACnE,oBAAoB,EAAE,MAAM;YAC5B,qBAAqB,EAAE,WAAW;YAClC,qBAAqB,EAAE,WAAW;YAClC,QAAQ,EAAE,QAAQ;YAClB,gBAAgB,EAAE,gBAAgB;YAClC,YAAY,EAAE,YAAY;SAC3B,CAAC,CAAC;IACL,CAAC;;AApEc,4CAAqB,GAAG,6BAA6B,CAAC","sourcesContent":["/* tslint:disable:no-null-keyword */\n// This file is mostly ported from the Angular 4.x NumberPipe in order to maintain the old\n// behavior of using the `Intl` API for formatting numbers rather than having to register every\n// supported locale.\n// https://github.com/angular/angular/blob/4.4.x/packages/common/src/pipes/number_pipe.ts\nimport { SkyIntlNumberFormatStyle, SkyIntlNumberFormatter } from '@skyux/i18n';\n\nfunction isNumeric(value: any): boolean {\n return !isNaN(value - parseFloat(value));\n}\n\nfunction parseIntAutoRadix(text: string): number {\n const result: number = parseInt(text, 10);\n\n /* istanbul ignore next */\n if (isNaN(result)) {\n throw new Error('Invalid integer literal when parsing ' + text);\n }\n\n return result;\n}\n\n// Need to add the following to classes which contain static methods.\n// See: https://github.com/ng-packagr/ng-packagr/issues/641\n// @dynamic\nexport class SkyNumberFormatUtility {\n private static _NUMBER_FORMAT_REGEXP = /^(\\d+)?\\.((\\d+)(-(\\d+))?)?$/;\n\n /* istanbul ignore next */\n constructor() {}\n\n public static formatNumber(\n locale: string,\n value: number | string,\n style: SkyIntlNumberFormatStyle,\n digits?: string | null,\n currency: string | null = null,\n currencyAsSymbol: boolean = false,\n currencySign?: 'accounting' | 'standard'\n ): string | null {\n if (value == null) {\n return null;\n }\n\n // Convert strings to numbers\n value = typeof value === 'string' && isNumeric(value) ? +value : value;\n if (typeof value !== 'number') {\n throw Error(`SkyInvalidPipeArgument: '${value}'`);\n }\n\n let minInt: number | undefined = undefined;\n let minFraction: number | undefined = undefined;\n let maxFraction: number | undefined = undefined;\n if (style !== SkyIntlNumberFormatStyle.Currency) {\n // rely on Intl default for currency\n minInt = 1;\n minFraction = 0;\n maxFraction = 3;\n }\n\n if (digits) {\n const parts = digits.match(this._NUMBER_FORMAT_REGEXP);\n\n if (parts === null) {\n throw new Error(`${digits} is not a valid digit info for number pipes`);\n }\n\n /* istanbul ignore else */\n if (parts[1] != null) {\n // min integer digits\n minInt = parseIntAutoRadix(parts[1]);\n }\n\n /* istanbul ignore else */\n if (parts[3] != null) {\n // min fraction digits\n minFraction = parseIntAutoRadix(parts[3]);\n }\n\n /* istanbul ignore else */\n if (parts[5] != null) {\n // max fraction digits\n maxFraction = parseIntAutoRadix(parts[5]);\n }\n }\n\n return SkyIntlNumberFormatter.format(value as number, locale, style, {\n minimumIntegerDigits: minInt,\n minimumFractionDigits: minFraction,\n maximumFractionDigits: maxFraction,\n currency: currency,\n currencyAsSymbol: currencyAsSymbol,\n currencySign: currencySign,\n });\n }\n}\n"]}
1
+ {"version":3,"file":"number-format-utility.js","sourceRoot":"","sources":["../../../../../../../../../libs/components/core/src/lib/modules/shared/number-format/number-format-utility.ts"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,0FAA0F;AAC1F,+FAA+F;AAC/F,oBAAoB;AACpB,yFAAyF;AACzF,OAAO,EAAE,wBAAwB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE/E,SAAS,SAAS,CAAC,KAAU;IAC3B,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED,SAAS,iBAAiB,CAAC,IAAY;IACrC,MAAM,MAAM,GAAW,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;IAE1C,0BAA0B;IAC1B,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE;QACjB,MAAM,IAA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AAC,CAAC;aACtC;YAED,0BAA0B;YAC1B,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE;gBACpB,sBAAsB;gBACtB,WAAW,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;aAC3C;YAED,0BAA0B;YAC1B,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE;gBACpB,sBAAsB;gBACtB,WAAW,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;aAC3C;SACF;QAED,OAAO,sBAAsB,CAAC,MAAM,CAAC,KAAe,EAAE,MAAM,EAAE,KAAK,EAAE;YACnE,oBAAoB,EAAE,MAAM;YAC5B,qBAAqB,EAAE,WAAW;YAClC,qBAAqB,EAAE,WAAW;YAClC,QAAQ,EAAE,QAAQ;YAClB,gBAAgB,EAAE,gBAAgB;YAClC,YAAY,EAAE,YAAY;SAC3B,CAAC,CAAC;IACL,CAAC;;AAjEc,4CAAqB,GAAG,6BAA6B,CAAC","sourcesContent":["/* tslint:disable:no-null-keyword */\n// This file is mostly ported from the Angular 4.x NumberPipe in order to maintain the old\n// behavior of using the `Intl` API for formatting numbers rather than having to register every\n// supported locale.\n// https://github.com/angular/angular/blob/4.4.x/packages/common/src/pipes/number_pipe.ts\nimport { SkyIntlNumberFormatStyle, SkyIntlNumberFormatter } from '@skyux/i18n';\n\nfunction isNumeric(value: any): boolean {\n return !isNaN(value - parseFloat(value));\n}\n\nfunction parseIntAutoRadix(text: string): number {\n const result: number = parseInt(text, 10);\n\n /* istanbul ignore next */\n if (isNaN(result)) {\n throw new Error('Invalid integer literal when parsing ' + text);\n }\n\n return result;\n}\n\n// Need to add the following to classes which contain static methods.\n// See: https://github.com/ng-packagr/ng-packagr/issues/641\n// @dynamic\nexport class SkyNumberFormatUtility {\n private static _NUMBER_FORMAT_REGEXP = /^(\\d+)?\\.((\\d+)(-(\\d+))?)?$/;\n\n public static formatNumber(\n locale: string,\n value: number | string,\n style: SkyIntlNumberFormatStyle,\n digits?: string | null,\n currency: string | null = null,\n currencyAsSymbol: boolean = false,\n currencySign?: 'accounting' | 'standard'\n ): string | null {\n if (value == null) {\n return null;\n }\n\n // Convert strings to numbers\n value = typeof value === 'string' && isNumeric(value) ? +value : value;\n if (typeof value !== 'number') {\n throw Error(`SkyInvalidPipeArgument: '${value}'`);\n }\n\n let minInt: number | undefined = undefined;\n let minFraction: number | undefined = undefined;\n let maxFraction: number | undefined = undefined;\n if (style !== SkyIntlNumberFormatStyle.Currency) {\n // rely on Intl default for currency\n minInt = 1;\n minFraction = 0;\n maxFraction = 3;\n }\n\n if (digits) {\n const parts = digits.match(this._NUMBER_FORMAT_REGEXP);\n\n if (parts === null) {\n throw new Error(`${digits} is not a valid digit info for number pipes`);\n }\n\n /* istanbul ignore else */\n if (parts[1] != null) {\n // min integer digits\n minInt = parseIntAutoRadix(parts[1]);\n }\n\n /* istanbul ignore else */\n if (parts[3] != null) {\n // min fraction digits\n minFraction = parseIntAutoRadix(parts[3]);\n }\n\n /* istanbul ignore else */\n if (parts[5] != null) {\n // max fraction digits\n maxFraction = parseIntAutoRadix(parts[5]);\n }\n }\n\n return SkyIntlNumberFormatter.format(value as number, locale, style, {\n minimumIntegerDigits: minInt,\n minimumFractionDigits: minFraction,\n maximumFractionDigits: maxFraction,\n currency: currency,\n currencyAsSymbol: currencyAsSymbol,\n currencySign: currencySign,\n });\n }\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * NOTICE: DO NOT MODIFY THIS FILE!
3
3
  * The contents of this file were automatically generated by
4
- * the 'ng generate @skyux/i18n:lib-resources-module modules/shared/sky-core' schematic.
4
+ * the 'ng generate @skyux/i18n:lib-resources-module lib/modules/shared/sky-core' schematic.
5
5
  * To update this file, simply rerun the command.
6
6
  */
7
7
  import { NgModule } from '@angular/core';
@@ -1 +1 @@
1
- {"version":3,"file":"sky-core-resources.module.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/shared/sky-core-resources.module.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,2BAA2B,EAE3B,aAAa,EAGb,qBAAqB,GACtB,MAAM,aAAa,CAAC;;AAErB,MAAM,SAAS,GAA0C;IACvD,OAAO,EAAE;QACP,6BAA6B,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;QAC/C,6BAA6B,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;QAC/C,8BAA8B,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;QAChD,8BAA8B,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;KACjD;CACF,CAAC;AAEF,MAAM,OAAO,wBAAwB;IAC5B,SAAS,CAAC,UAA4B,EAAE,IAAY;QACzD,OAAO,qBAAqB,CAAC,SAAS,EAAE,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;CACF;AAED;;GAEG;AAWH,MAAM,OAAO,sBAAsB;;oHAAtB,sBAAsB;qHAAtB,sBAAsB,YATvB,aAAa;qHASZ,sBAAsB,aARtB;QACT;YACE,OAAO,EAAE,2BAA2B;YACpC,QAAQ,EAAE,wBAAwB;YAClC,KAAK,EAAE,IAAI;SACZ;KACF,YAPS,aAAa;4FASZ,sBAAsB;kBAVlC,QAAQ;mBAAC;oBACR,OAAO,EAAE,CAAC,aAAa,CAAC;oBACxB,SAAS,EAAE;wBACT;4BACE,OAAO,EAAE,2BAA2B;4BACpC,QAAQ,EAAE,wBAAwB;4BAClC,KAAK,EAAE,IAAI;yBACZ;qBACF;iBACF","sourcesContent":["/**\n * NOTICE: DO NOT MODIFY THIS FILE!\n * The contents of this file were automatically generated by\n * the 'ng generate @skyux/i18n:lib-resources-module modules/shared/sky-core' schematic.\n * To update this file, simply rerun the command.\n */\nimport { NgModule } from '@angular/core';\nimport {\n SKY_LIB_RESOURCES_PROVIDERS,\n SkyAppLocaleInfo,\n SkyI18nModule,\n SkyLibResources,\n SkyLibResourcesProvider,\n getLibStringForLocale,\n} from '@skyux/i18n';\n\nconst RESOURCES: { [locale: string]: SkyLibResources } = {\n 'EN-US': {\n skyux_numeric_billions_symbol: { message: 'B' },\n skyux_numeric_millions_symbol: { message: 'M' },\n skyux_numeric_thousands_symbol: { message: 'K' },\n skyux_numeric_trillions_symbol: { message: 'T' },\n },\n};\n\nexport class SkyCoreResourcesProvider implements SkyLibResourcesProvider {\n public getString(localeInfo: SkyAppLocaleInfo, name: string): string {\n return getLibStringForLocale(RESOURCES, localeInfo.locale, name);\n }\n}\n\n/**\n * Import into any component library module that needs to use resource strings.\n */\n@NgModule({\n exports: [SkyI18nModule],\n providers: [\n {\n provide: SKY_LIB_RESOURCES_PROVIDERS,\n useClass: SkyCoreResourcesProvider,\n multi: true,\n },\n ],\n})\nexport class SkyCoreResourcesModule {}\n"]}
1
+ {"version":3,"file":"sky-core-resources.module.js","sourceRoot":"","sources":["../../../../../../../../libs/components/core/src/lib/modules/shared/sky-core-resources.module.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EACL,2BAA2B,EAE3B,aAAa,EAGb,qBAAqB,GACtB,MAAM,aAAa,CAAC;;AAErB,MAAM,SAAS,GAA0C;IACvD,OAAO,EAAE;QACP,6BAA6B,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;QAC/C,6BAA6B,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;QAC/C,8BAA8B,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;QAChD,8BAA8B,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE;KACjD;CACF,CAAC;AAEF,MAAM,OAAO,wBAAwB;IAC5B,SAAS,CACd,UAA4B,EAC5B,IAAY;QAEZ,OAAO,qBAAqB,CAAC,SAAS,EAAE,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;CACF;AAED;;GAEG;AAWH,MAAM,OAAO,sBAAsB;;oHAAtB,sBAAsB;qHAAtB,sBAAsB,YATvB,aAAa;qHASZ,sBAAsB,aARtB;QACT;YACE,OAAO,EAAE,2BAA2B;YACpC,QAAQ,EAAE,wBAAwB;YAClC,KAAK,EAAE,IAAI;SACZ;KACF,YAPS,aAAa;4FASZ,sBAAsB;kBAVlC,QAAQ;mBAAC;oBACR,OAAO,EAAE,CAAC,aAAa,CAAC;oBACxB,SAAS,EAAE;wBACT;4BACE,OAAO,EAAE,2BAA2B;4BACpC,QAAQ,EAAE,wBAAwB;4BAClC,KAAK,EAAE,IAAI;yBACZ;qBACF;iBACF","sourcesContent":["/**\n * NOTICE: DO NOT MODIFY THIS FILE!\n * The contents of this file were automatically generated by\n * the 'ng generate @skyux/i18n:lib-resources-module lib/modules/shared/sky-core' schematic.\n * To update this file, simply rerun the command.\n */\nimport { NgModule } from '@angular/core';\nimport {\n SKY_LIB_RESOURCES_PROVIDERS,\n SkyAppLocaleInfo,\n SkyI18nModule,\n SkyLibResources,\n SkyLibResourcesProvider,\n getLibStringForLocale,\n} from '@skyux/i18n';\n\nconst RESOURCES: { [locale: string]: SkyLibResources } = {\n 'EN-US': {\n skyux_numeric_billions_symbol: { message: 'B' },\n skyux_numeric_millions_symbol: { message: 'M' },\n skyux_numeric_thousands_symbol: { message: 'K' },\n skyux_numeric_trillions_symbol: { message: 'T' },\n },\n};\n\nexport class SkyCoreResourcesProvider implements SkyLibResourcesProvider {\n public getString(\n localeInfo: SkyAppLocaleInfo,\n name: string\n ): string | undefined {\n return getLibStringForLocale(RESOURCES, localeInfo.locale, name);\n }\n}\n\n/**\n * Import into any component library module that needs to use resource strings.\n */\n@NgModule({\n exports: [SkyI18nModule],\n providers: [\n {\n provide: SKY_LIB_RESOURCES_PROVIDERS,\n useClass: SkyCoreResourcesProvider,\n multi: true,\n },\n ],\n})\nexport class SkyCoreResourcesModule {}\n"]}