UNPKG

carbon-components-angular

Version:
1 lines 14 kB
"use strict";(self.webpackChunkcarbon_components_angular=self.webpackChunkcarbon_components_angular||[]).push([[9115],{"./src/i18n/index.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{oc:()=>I18n,LU:()=>I18nModule});var tslib_es6=__webpack_require__("./node_modules/tslib/tslib.es6.js"),core=__webpack_require__("./node_modules/@angular/core/fesm2020/core.mjs"),BehaviorSubject=__webpack_require__("./node_modules/rxjs/dist/esm5/internal/BehaviorSubject.js"),iif=__webpack_require__("./node_modules/rxjs/dist/esm5/internal/observable/iif.js"),isObservable=__webpack_require__("./node_modules/rxjs/dist/esm5/internal/util/isObservable.js"),map=__webpack_require__("./node_modules/rxjs/dist/esm5/internal/operators/map.js"),utils=__webpack_require__("./src/utils/index.ts");const en={BREADCRUMB:{LABEL:"Breadcrumb"},CODE_SNIPPET:{CODE_SNIPPET_TEXT:"Code Snippet Text",SHOW_MORE:"Show more",SHOW_LESS:"Show less",SHOW_MORE_ICON:"Show more icon",COPY_CODE:"Copy code",COPIED:"Copied!"},COMBOBOX:{PLACEHOLDER:"Filter...",CLEAR_SELECTIONS:"Clear all selected items",CLEAR_SELECTED:"Clear selected item",A11Y:{OPEN_MENU:"Open menu",CLOSE_MENU:"Close menu",CLEAR_SELECTIONS:"Clear all selected items",CLEAR_SELECTED:"Clear Selection"}},DROPDOWN:{OPEN:"Open menu",SELECTED:"Selected",CLEAR:"Clear all selected items",FILTER:{SELECTED_ONLY:"Show selected only",SEARCH:"Search",NO_RESULTS:"No search results",RESET_SEARCH:"Reset search"}},DROPDOWN_LIST:{LABEL:"Listbox"},FILE_UPLOADER:{CHECKMARK:"Checkmark",OPEN:"Add file",REMOVE_BUTTON:"Close button"},LOADING:{TITLE:"Loading"},MODAL:{CLOSE:"Close modal"},NOTIFICATION:{CLOSE_BUTTON:"Close alert notification"},NUMBER:{INCREMENT:"Increment value",DECREMENT:"Decrement value"},OVERFLOW_MENU:{OVERFLOW:"Overflow"},SEARCH:{LABEL:"Search",PLACEHOLDER:"Search",CLEAR_BUTTON:"Clear search input"},PAGINATION:{ITEMS_PER_PAGE:"Items per page:",OPEN_LIST_OF_OPTIONS:"Open list of options",BACKWARD:"Backward",FORWARD:"Forward",TOTAL_ITEMS_UNKNOWN:"{{start}}-{{end}} items",TOTAL_ITEMS:"{{start}}-{{end}} of {{total}} items",TOTAL_ITEM:"{{start}}-{{end}} of {{total}} item",PAGE:"page",OF_LAST_PAGES:"of {{last}} pages",OF_LAST_PAGE:"of {{last}} page",NEXT:"Next",PREVIOUS:"Previous",SELECT_ARIA:"Select page number"},PROGRESS_INDICATOR:{CURRENT:"Current",INCOMPLETE:"Incomplete",COMPLETE:"Complete",INVALID:"Invalid"},TABLE:{FILTER:"Filter",END_OF_DATA:"You've reached the end of your content",SCROLL_TOP:"Scroll to top",CHECKBOX_HEADER:"Select all rows",CHECKBOX_ROW:"Select {{value}}",EXPAND_BUTTON:"Expand row",SORT_DESCENDING:"Sort rows by this header in descending order",SORT_ASCENDING:"Sort rows by this header in ascending order",ROW:"row"},TABLE_TOOLBAR:{ACTION_BAR:"Table action bar",BATCH_TEXT:"",BATCH_TEXT_SINGLE:"1 item selected",BATCH_TEXT_MULTIPLE:"{{count}} items selected",CANCEL:"Cancel"},TABS:{BUTTON_ARIA_LEFT:"Go to the previous tab",BUTTON_ARIA_RIGHT:"Go to the next tab",HEADER_ARIA_LABEL:"List of tabs"},TILES:{TILE:"tile",EXPAND:"Expand",COLLAPSE:"Collapse"},TOGGLE:{OFF:"Off",ON:"On"},UI_SHELL:{SKIP_TO:"Skip to content",HEADER:{OPEN_MENU:"Open menu",CLOSE_MENU:"Close menu"},SIDE_NAV:{TOGGLE_OPEN:"Open",TOGGLE_CLOSE:"Close"}}},replace=(subject,variables)=>subject.pipe((0,map.U)((str=>{const keys=Object.keys(variables);for(const key of keys){const value=variables[key];str=str.replace(new RegExp(`{{\\s*${key}\\s*}}`,"g"),value)}return str})));class Overridable{constructor(path,i18n){this.path=path,this.i18n=i18n,this.baseTranslation=this.i18n.get(this.path),this.isOverridden=!1;const value=this.i18n.getValueFromPath(this.path);this.$override=new BehaviorSubject.X(value),this._value=value}get value(){return this._value}set value(v){this.override(v)}get subject(){return(0,iif.s)((()=>this.isOverridden),this.$override,this.baseTranslation)}override(value){this.isOverridden=!0,this.subscription&&(this.subscription.unsubscribe(),this.subscription=null),this._value=value,(0,isObservable.b)(value)?this.subscription=value.subscribe((v=>{this.$override.next(v)})):this.$override.next(value)}}let I18n=class I18n{constructor(){this.translationStrings=en,this.translations=new Map,this.locale=new BehaviorSubject.X("en")}setLocale(language,strings){this.locale.next(language),strings&&this.set(strings)}getLocale(){return this.locale.value}getLocaleObservable(){return this.locale.asObservable()}set(strings){this.translationStrings=(0,utils.TS)({},en,strings);const translations=Array.from(this.translations);for(const[path,subject]of translations)subject.next(this.getValueFromPath(path))}get(path){return path?this.getSubject(path):this.translationStrings}getMultiple(partialPath){const values=this.getValueFromPath(partialPath),subjects={};for(const key of Object.keys(values))values[key]===Object(values[key])?subjects[key]=this.getMultiple(`${partialPath}.${key}`):subjects[key]=this.getSubject(`${partialPath}.${key}`);return subjects}getOverridable(path){return new Overridable(path,this)}replace(subject,variables){return replace(subject,variables)}getValueFromPath(path){let value=this.translationStrings;for(const segment of path.split(".")){if(void 0===value[segment]||null===value[segment])throw new Error(`no key ${segment} at ${path}`);value=value[segment]}return value}getSubject(path){try{const value=this.getValueFromPath(path);if(this.translations.has(path))return this.translations.get(path);const translation=new BehaviorSubject.X(value);return this.translations.set(path,translation),translation}catch(error){console.error(error)}}};I18n=(0,tslib_es6.gn)([(0,core.Injectable)()],I18n);let ReplacePipe=class ReplacePipe{transform(value,variables){return replace(value,variables)}};ReplacePipe=(0,tslib_es6.gn)([(0,core.Pipe)({name:"i18nReplace"})],ReplacePipe);const I18N_SERVICE_PROVIDER={provide:I18n,deps:[[new core.Optional,new core.SkipSelf,I18n]],useFactory:function I18N_SERVICE_PROVIDER_FACTORY(parentService){return parentService||new I18n}};let I18nModule=class I18nModule{};I18nModule=(0,tslib_es6.gn)([(0,core.NgModule)({declarations:[ReplacePipe],exports:[ReplacePipe],providers:[I18n,I18N_SERVICE_PROVIDER]})],I18nModule)},"./src/utils/index.ts":(__unused_webpack_module,__webpack_exports__,__webpack_require__)=>{__webpack_require__.d(__webpack_exports__,{NV:()=>AnimationFrameService,d2:()=>ElementService,PO:()=>EventService,As:()=>UtilsModule,d9:()=>clone,_K:()=>closestAttr,O3:()=>getScrollableParents,np:()=>getScrollbarWidth,OQ:()=>hasScrollableParents,TS:()=>object_merge});var tslib_es6=__webpack_require__("./node_modules/tslib/tslib.es6.js"),core=__webpack_require__("./node_modules/@angular/core/fesm2020/core.mjs"),Subject=__webpack_require__("./node_modules/rxjs/dist/esm5/internal/Subject.js"),from=__webpack_require__("./node_modules/rxjs/dist/esm5/internal/observable/from.js");let AnimationFrameServiceSingleton=class AnimationFrameServiceSingleton{constructor(ngZone){this.ngZone=ngZone,this.frameSource=new Subject.x,this.tick=this.frameSource.asObservable(),this.ngZone.runOutsideAngular((()=>{this.animationFrameId=requestAnimationFrame(this.doTick.bind(this))}))}ngOnDestroy(){cancelAnimationFrame(this.animationFrameId)}doTick(frame){this.frameSource.next(frame),this.ngZone.runOutsideAngular((()=>{requestAnimationFrame(this.doTick.bind(this))}))}};AnimationFrameServiceSingleton.ctorParameters=()=>[{type:core.NgZone}],AnimationFrameServiceSingleton=(0,tslib_es6.gn)([(0,core.Injectable)()],AnimationFrameServiceSingleton);let AnimationFrameService=class AnimationFrameService{constructor(singleton){this.singleton=singleton,this.tick=(0,from.D)(this.singleton.tick)}};AnimationFrameService.ctorParameters=()=>[{type:AnimationFrameServiceSingleton}],AnimationFrameService=(0,tslib_es6.gn)([(0,core.Injectable)()],AnimationFrameService);const object_merge=(target,...objects)=>{for(const object of objects)for(const key in object)object.hasOwnProperty(key)&&(object[key]instanceof Object?(target[key]||(target[key]={}),target[key]=object_merge(target[key],object[key])):target[key]=object[key]);return target};__webpack_require__("./node_modules/@carbon/utils-position/index.js");const isScrollableElement=element=>{const computedStyle=getComputedStyle(element);return"auto"===computedStyle.overflow||"scroll"===computedStyle.overflow||"auto"===computedStyle["overflow-y"]||"scroll"===computedStyle["overflow-y"]||"auto"===computedStyle["overflow-x"]||"scroll"===computedStyle["overflow-x"]},isVisibleInContainer=(element,container)=>{const elementRect=element.getBoundingClientRect(),containerRect=container.getBoundingClientRect();if("BODY"===container.tagName||"HTML"===container.tagName){const isAboveViewport=elementRect.top<0&&elementRect.top+element.clientHeight<0,isLeftOfViewport=elementRect.left<0,isBelowViewport=elementRect.bottom-element.clientHeight>(window.innerHeight||document.documentElement.clientHeight),isRightOfViewport=elementRect.right>(window.innerWidth||document.documentElement.clientWidth);return!(isAboveViewport||isBelowViewport||isLeftOfViewport||isRightOfViewport)}return elementRect.bottom-element.clientHeight<=containerRect.bottom+(container.offsetHeight-container.clientHeight)/2&&elementRect.top>=-element.clientHeight},getScrollableParents=node=>{const elements=[document.body];for(;node.parentElement&&node!==document.body;)isScrollableElement(node)&&elements.push(node),node=node.parentElement;return elements},hasScrollableParents=node=>{for(;node.parentElement&&node!==document.body;){if(isScrollableElement(node))return!0;node=node.parentElement}return!1};function clone(obj){return JSON.parse(JSON.stringify(obj))}function matchesAttr(el,attr,val){const styles=window.getComputedStyle(el);return val.includes(styles[attr])}function closestAttr(s,t,element){let el=element;if(!element)return null;do{if(matchesAttr(el,s,t))return el;el=el.parentElement||el.parentNode}while(null!==el&&1===el.nodeType);return null}var operators_map=__webpack_require__("./node_modules/rxjs/dist/esm5/internal/operators/map.js");let ElementService=class ElementService{constructor(singleton){this.singleton=singleton,this.tick=(0,from.D)(this.singleton.tick)}visibility(target,parentElement=target){const scrollableParents=getScrollableParents(parentElement);return this.tick.pipe((0,operators_map.U)((()=>{for(const parent of scrollableParents)if(!isVisibleInContainer(target,parent))return{visible:!1};return{visible:!0}})))}};ElementService.ctorParameters=()=>[{type:AnimationFrameServiceSingleton}],ElementService=(0,tslib_es6.gn)([(0,core.Injectable)()],ElementService);var Subscription=__webpack_require__("./node_modules/rxjs/dist/esm5/internal/Subscription.js"),Observable=__webpack_require__("./node_modules/rxjs/dist/esm5/internal/Observable.js"),observable_fromEvent=__webpack_require__("./node_modules/rxjs/dist/esm5/internal/observable/fromEvent.js");const getEventObservable=(targetElement,eventType)=>{switch(eventType){case"scroll":case"resize":case"touchstart":case"touchmove":case"touchend":return(0,observable_fromEvent.R)(targetElement,eventType,{passive:!0});default:return(0,observable_fromEvent.R)(targetElement,eventType)}};let DocumentService=class DocumentService{constructor(){this.globalEvents=new Map,this.documentRef=document,this.subscriptions=new Subscription.w0}handleEvent(eventType,callback){this.globalEvents.has(eventType)||(this.documentRef?this.globalEvents.set(eventType,getEventObservable(this.documentRef,eventType)):this.globalEvents.set(eventType,new Observable.y));const observable=this.globalEvents.get(eventType);this.subscriptions.add(observable.subscribe(callback))}handleClick(callback){this.handleEvent("click",callback)}ngOnDestroy(){this.subscriptions.unsubscribe(),this.globalEvents=null}};DocumentService=(0,tslib_es6.gn)([(0,core.Injectable)()],DocumentService);let EventService=class EventService{constructor(documentService){this.documentService=documentService,this.subscriptions=new Subscription.w0,this.targets=new WeakMap}on(targetElement,eventType,callback){this.targets.has(targetElement)||this.targets.set(targetElement,new Map);const eventMap=this.targets.get(targetElement);eventMap.has(eventType)||eventMap.set(eventType,getEventObservable(targetElement,eventType));const subscription=eventMap.get(eventType).subscribe(callback);this.subscriptions.add(subscription)}onDocument(eventType,callback){this.documentService.handleEvent(eventType,callback)}ngOnDestroy(){this.subscriptions.unsubscribe()}};EventService.ctorParameters=()=>[{type:DocumentService}],EventService=(0,tslib_es6.gn)([(0,core.Injectable)()],EventService);const DOCUMENT_SERVICE_PROVIDER={provide:DocumentService,deps:[[new core.Optional,new core.SkipSelf,DocumentService]],useFactory:function DOCUMENT_SERVICE_PROVIDER_FACTORY(parentService){return parentService||new DocumentService}};const ANIMATION_FRAME_SERVICE_SINGLETON_PROVIDER={provide:AnimationFrameServiceSingleton,deps:[[new core.Optional,new core.SkipSelf,AnimationFrameServiceSingleton],core.NgZone],useFactory:function ANIMATION_FRAME_SERVICE_SINGLETON_PROVIDER_FACTORY(parentService,ngZone){return parentService||new AnimationFrameServiceSingleton(ngZone)}};let UtilsModule=class UtilsModule{};UtilsModule=(0,tslib_es6.gn)([(0,core.NgModule)({providers:[DOCUMENT_SERVICE_PROVIDER,ANIMATION_FRAME_SERVICE_SINGLETON_PROVIDER,AnimationFrameServiceSingleton,DocumentService,AnimationFrameService,ElementService,EventService]})],UtilsModule);let _scrollbarWidth=-1;function getScrollbarWidth(){if(_scrollbarWidth>=0)return _scrollbarWidth;const outer=document.createElement("div");outer.style.visibility="hidden",outer.style.width="100px",outer.style.msOverflowStyle="scrollbar",document.body.appendChild(outer);const widthNoScroll=outer.offsetWidth;outer.style.overflow="scroll";const inner=document.createElement("div");inner.style.width="100%",outer.appendChild(inner);const widthWithScroll=inner.offsetWidth;return outer.parentNode.removeChild(outer),_scrollbarWidth=widthNoScroll-widthWithScroll,_scrollbarWidth}}}]);