@iplab/ngx-file-upload
Version:
> Angular module used for file upload.
1 lines • 208 kB
Source Map (JSON)
{"version":3,"file":"iplab-ngx-file-upload.mjs","sources":["../../../projects/iplab/ngx-file-upload/src/lib/helpers/file-types.class.ts","../../../projects/iplab/ngx-file-upload/src/lib/helpers/helpers.class.ts","../../../projects/iplab/ngx-file-upload/src/lib/services/file-upload.service.ts","../../../projects/iplab/ngx-file-upload/src/lib/helpers/control.class.ts","../../../projects/iplab/ngx-file-upload/src/lib/components/file-upload-abstract.component.ts","../../../projects/iplab/ngx-file-upload/src/lib/components/drop-zone/file-upload-drop-zone.component.ts","../../../projects/iplab/ngx-file-upload/src/lib/components/drop-zone/file-upload-drop-zone.component.html","../../../projects/iplab/ngx-file-upload/src/lib/components/file-list/file-upload-icon.component.ts","../../../projects/iplab/ngx-file-upload/src/lib/components/file-list/file-upload-icon.component.html","../../../projects/iplab/ngx-file-upload/src/lib/components/file-list/file-upload-list-item.component.ts","../../../projects/iplab/ngx-file-upload/src/lib/components/multiple-file-upload/file-upload.component.ts","../../../projects/iplab/ngx-file-upload/src/lib/components/multiple-file-upload/file-upload.component.html","../../../projects/iplab/ngx-file-upload/src/lib/components/attribute/file-upload-attr.component.ts","../../../projects/iplab/ngx-file-upload/src/lib/components/simple-file-upload/simple-file-upload.component.ts","../../../projects/iplab/ngx-file-upload/src/lib/components/simple-file-upload/simple-file-upload.component.html","../../../projects/iplab/ngx-file-upload/src/lib/helpers/validators.class.ts","../../../projects/iplab/ngx-file-upload/src/lib/directives/validators.directive.ts","../../../projects/iplab/ngx-file-upload/src/lib/directives/attribute.directive.ts","../../../projects/iplab/ngx-file-upload/src/lib/directives/discard.directive.ts","../../../projects/iplab/ngx-file-upload/src/lib/directives/native.directive.ts","../../../projects/iplab/ngx-file-upload/src/lib/file-upload.module.ts","../../../projects/iplab/ngx-file-upload/src/public_api.ts","../../../projects/iplab/ngx-file-upload/src/iplab-ngx-file-upload.ts"],"sourcesContent":["\r\n// -owner-group-others-\r\n// -rwxrwxrwx = 0777\r\nenum FileAccess {\r\n None,\r\n Read = 1 << 2,\r\n Write = 1 << 1,\r\n ReadWrite = Read | Write,\r\n Execute = 1 << 0,\r\n ReadWriteExecute = ReadWrite | Execute,\r\n ExecuteRead = Execute | Read,\r\n r = Read,\r\n w = Write,\r\n x = Execute,\r\n rw = ReadWrite,\r\n rwx = ReadWriteExecute,\r\n xr = ExecuteRead\r\n}\r\n\r\n/**\r\n * This table lists some important MIME types for the Web copied from\r\n * https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types\r\n * http://www.iana.org/assignments/media-types/media-types.xhtml\r\n */\r\nexport enum FileUploadTypes {\r\n arc = 'application/octet-stream',\r\n midi = 'audio/midi',\r\n ts = 'application/typescript',\r\n woff2 = 'font/woff2',\r\n evy = 'application/envoy',\r\n fif = 'application/fractals',\r\n hta = 'application/hta',\r\n acx = 'application/internet-property-stream',\r\n dot = 'application/msword',\r\n dms = 'application/octet-stream',\r\n eps = 'application/postscript',\r\n ps = 'application/postscript',\r\n xla = 'application/vnd.ms-excel',\r\n xlc = 'application/vnd.ms-excel',\r\n xlm = 'application/vnd.ms-excel',\r\n xlt = 'application/vnd.ms-excel',\r\n xlw = 'application/vnd.ms-excel',\r\n msg = 'application/vnd.ms-outlook',\r\n sst = 'application/vnd.ms-pkicertstore',\r\n pot = 'application/vnd.ms-powerpoint',\r\n pps = 'application/vnd.ms-powerpoint',\r\n wcm = 'application/vnd.ms-works',\r\n wdb = 'application/vnd.ms-works',\r\n wks = 'application/vnd.ms-works',\r\n cdf = 'application/x-cdf',\r\n tgz = 'application/x-compressed',\r\n dcr = 'application/x-director',\r\n dxr = 'application/x-director',\r\n gz = 'application/x-gzip',\r\n ins = 'application/x-internet-signup',\r\n isp = 'application/x-internet-signup',\r\n iii = 'application/x-iphone',\r\n dll = 'application/x-msdownload',\r\n m13 = 'application/x-msmediaview',\r\n m14 = 'application/x-msmediaview',\r\n pma = 'application/x-perfmon',\r\n pmc = 'application/x-perfmon',\r\n pmr = 'application/x-perfmon',\r\n pmw = 'application/x-perfmon',\r\n pfx = 'application/x-pkcs12',\r\n spc = 'application/x-pkcs7-certificates',\r\n p7c = 'application/x-pkcs7-mime',\r\n texi = 'application/x-texinfo',\r\n roff = 'application/x-troff',\r\n tr = 'application/x-troff',\r\n man = 'application/x-troff-man',\r\n me = 'application/x-troff-me',\r\n ms = 'application/x-troff-ms',\r\n crt = 'application/x-x509-ca-cert',\r\n pko = 'application/ynd.ms-pkipko',\r\n snd = 'audio/basic',\r\n rmi = 'audio/mid',\r\n mp3 = 'audio/mpeg',\r\n aifc = 'audio/x-aiff',\r\n aiff = 'audio/x-aiff',\r\n ra = 'audio/x-pn-realaudio',\r\n jpe = 'image/jpeg',\r\n jpeg = 'image/jpeg',\r\n jfif = 'image/pipeg',\r\n tif = 'image/tiff',\r\n mht = 'message/rfc822',\r\n mhtml = 'message/rfc822',\r\n nws = 'message/rfc822',\r\n htm = 'text/html',\r\n stm = 'text/html',\r\n uls = 'text/iuls',\r\n sct = 'text/scriptlet',\r\n htt = 'text/webviewhtml',\r\n htc = 'text/x-component',\r\n mp2 = 'video/mpeg',\r\n mpa = 'video/mpeg',\r\n mpe = 'video/mpeg',\r\n mpg = 'video/mpeg',\r\n mpv2 = 'video/mpeg',\r\n mov = 'video/quicktime',\r\n lsf = 'video/x-la-asf',\r\n lsx = 'video/x-la-asf',\r\n asr = 'video/x-ms-asf',\r\n asx = 'video/x-ms-asf',\r\n flr = 'x-world/x-vrml',\r\n vrml = 'x-world/x-vrml',\r\n wrz = 'x-world/x-vrml',\r\n xaf = 'x-world/x-vrml',\r\n xof = 'x-world/x-vrml',\r\n x3d = 'application/vnd.hzn-3d-crossword',\r\n '3gp' = 'video/3gpp',\r\n '3g2' = 'video/3gpp2',\r\n mseq = 'application/vnd.mseq',\r\n pwn = 'application/vnd.3m.post-it-notes',\r\n plb = 'application/vnd.3gpp.pic-bw-large',\r\n psb = 'application/vnd.3gpp.pic-bw-small',\r\n pvb = 'application/vnd.3gpp.pic-bw-var',\r\n tcap = 'application/vnd.3gpp2.tcap',\r\n '7z' = 'application/x-7z-compressed',\r\n abw = 'application/x-abiword',\r\n ace = 'application/x-ace-compressed',\r\n acc = 'application/vnd.americandynamics.acc',\r\n acu = 'application/vnd.acucobol',\r\n atc = 'application/vnd.acucorp',\r\n adp = 'audio/adpcm',\r\n aab = 'application/x-authorware-bin',\r\n aam = 'application/x-authorware-map',\r\n aas = 'application/x-authorware-seg',\r\n air = 'application/vnd.adobe.air-application-installer-package+zip',\r\n swf = 'application/x-shockwave-flash',\r\n fxp = 'application/vnd.adobe.fxp',\r\n pdf = 'application/pdf',\r\n ppd = 'application/vnd.cups-ppd',\r\n dir = 'application/x-director',\r\n xdp = 'application/vnd.adobe.xdp+xml',\r\n xfdf = 'application/vnd.adobe.xfdf',\r\n aac = 'audio/x-aac',\r\n ahead = 'application/vnd.ahead.space',\r\n azf = 'application/vnd.airzip.filesecure.azf',\r\n azs = 'application/vnd.airzip.filesecure.azs',\r\n azw = 'application/vnd.amazon.ebook',\r\n ami = 'application/vnd.amiga.ami',\r\n apk = 'application/vnd.android.package-archive',\r\n cii = 'application/vnd.anser-web-certificate-issue-initiation',\r\n fti = 'application/vnd.anser-web-funds-transfer-initiation',\r\n atx = 'application/vnd.antix.game-component',\r\n dmg = 'application/x-apple-diskimage',\r\n mpkg = 'application/vnd.apple.installer+xml',\r\n aw = 'application/applixware',\r\n les = 'application/vnd.hhe.lesson-player',\r\n swi = 'application/vnd.aristanetworks.swi',\r\n s = 'text/x-asm',\r\n atomcat = 'application/atomcat+xml',\r\n atomsvc = 'application/atomsvc+xml',\r\n atom = 'application/atom+xml',\r\n ac = 'application/pkix-attr-cert',\r\n aif = 'audio/x-aiff',\r\n avi = 'video/x-msvideo',\r\n aep = 'application/vnd.audiograph',\r\n dxf = 'image/vnd.dxf',\r\n dwf = 'model/vnd.dwf',\r\n par = 'text/plain-bas',\r\n bcpio = 'application/x-bcpio',\r\n bin = 'application/octet-stream',\r\n bmp = 'image/bmp',\r\n torrent = 'application/x-bittorrent',\r\n cod = 'application/vnd.rim.cod',\r\n mpm = 'application/vnd.blueice.multipass',\r\n bmi = 'application/vnd.bmi',\r\n sh = 'application/x-sh',\r\n btif = 'image/prs.btif',\r\n rep = 'application/vnd.businessobjects',\r\n bz = 'application/x-bzip',\r\n bz2 = 'application/x-bzip2',\r\n csh = 'application/x-csh',\r\n c = 'text/x-c',\r\n cdxml = 'application/vnd.chemdraw+xml',\r\n css = 'text/css',\r\n cdx = 'chemical/x-cdx',\r\n cml = 'chemical/x-cml',\r\n csml = 'chemical/x-csml',\r\n cdbcmsg = 'application/vnd.contact.cmsg',\r\n cla = 'application/vnd.claymore',\r\n c4g = 'application/vnd.clonk.c4group',\r\n sub = 'image/vnd.dvb.subtitle',\r\n cdmia = 'application/cdmi-capability',\r\n cdmic = 'application/cdmi-container',\r\n cdmid = 'application/cdmi-domain',\r\n cdmio = 'application/cdmi-object',\r\n cdmiq = 'application/cdmi-queue',\r\n c11amc = 'application/vnd.cluetrust.cartomobile-config',\r\n c11amz = 'application/vnd.cluetrust.cartomobile-config-pkg',\r\n ras = 'image/x-cmu-raster',\r\n dae = 'model/vnd.collada+xml',\r\n csv = 'text/csv',\r\n cpt = 'application/mac-compactpro',\r\n wmlc = 'application/vnd.wap.wmlc',\r\n cgm = 'image/cgm',\r\n ice = 'x-conference/x-cooltalk',\r\n cmx = 'image/x-cmx',\r\n xar = 'application/vnd.xara',\r\n cmc = 'application/vnd.cosmocaller',\r\n cpio = 'application/x-cpio',\r\n clkx = 'application/vnd.crick.clicker',\r\n clkk = 'application/vnd.crick.clicker.keyboard',\r\n clkp = 'application/vnd.crick.clicker.palette',\r\n clkt = 'application/vnd.crick.clicker.template',\r\n clkw = 'application/vnd.crick.clicker.wordbank',\r\n wbs = 'application/vnd.criticaltools.wbs+xml',\r\n cryptonote = 'application/vnd.rig.cryptonote',\r\n cif = 'chemical/x-cif',\r\n cmdf = 'chemical/x-cmdf',\r\n cu = 'application/cu-seeme',\r\n cww = 'application/prs.cww',\r\n curl = 'text/vnd.curl',\r\n dcurl = 'text/vnd.curl.dcurl',\r\n mcurl = 'text/vnd.curl.mcurl',\r\n scurl = 'text/vnd.curl.scurl',\r\n car = 'application/vnd.curl.car',\r\n pcurl = 'application/vnd.curl.pcurl',\r\n cmp = 'application/vnd.yellowriver-custom-menu',\r\n dssc = 'application/dssc+der',\r\n xdssc = 'application/dssc+xml',\r\n deb = 'application/x-debian-package',\r\n uva = 'audio/vnd.dece.audio',\r\n uvi = 'image/vnd.dece.graphic',\r\n uvh = 'video/vnd.dece.hd',\r\n uvm = 'video/vnd.dece.mobile',\r\n uvu = 'video/vnd.uvvu.mp4',\r\n uvp = 'video/vnd.dece.pd',\r\n uvs = 'video/vnd.dece.sd',\r\n uvv = 'video/vnd.dece.video',\r\n dvi = 'application/x-dvi',\r\n seed = 'application/vnd.fdsn.seed',\r\n dtb = 'application/x-dtbook+xml',\r\n res = 'application/x-dtbresource+xml',\r\n ait = 'application/vnd.dvb.ait',\r\n svc = 'application/vnd.dvb.service',\r\n eol = 'audio/vnd.digital-winds',\r\n djvu = 'image/vnd.djvu',\r\n dtd = 'application/xml-dtd',\r\n mlp = 'application/vnd.dolby.mlp',\r\n wad = 'application/x-doom',\r\n dpg = 'application/vnd.dpgraph',\r\n dra = 'audio/vnd.dra',\r\n dfac = 'application/vnd.dreamfactory',\r\n dts = 'audio/vnd.dts',\r\n dtshd = 'audio/vnd.dts.hd',\r\n dwg = 'image/vnd.dwg',\r\n geo = 'application/vnd.dynageo',\r\n es = 'application/ecmascript',\r\n mag = 'application/vnd.ecowin.chart',\r\n mmr = 'image/vnd.fujixerox.edmics-mmr',\r\n rlc = 'image/vnd.fujixerox.edmics-rlc',\r\n exi = 'application/exi',\r\n mgz = 'application/vnd.proteus.magazine',\r\n epub = 'application/epub+zip',\r\n eml = 'message/rfc822',\r\n nml = 'application/vnd.enliven',\r\n xpr = 'application/vnd.is-xpr',\r\n xif = 'image/vnd.xiff',\r\n xfdl = 'application/vnd.xfdl',\r\n emma = 'application/emma+xml',\r\n ez2 = 'application/vnd.ezpix-album',\r\n ez3 = 'application/vnd.ezpix-package',\r\n fst = 'image/vnd.fst',\r\n fvt = 'video/vnd.fvt',\r\n fbs = 'image/vnd.fastbidsheet',\r\n fe_launch = 'application/vnd.denovo.fcselayout-link',\r\n f4v = 'video/x-f4v',\r\n flv = 'video/x-flv',\r\n fpx = 'image/vnd.fpx',\r\n npx = 'image/vnd.net-fpx',\r\n flx = 'text/vnd.fmi.flexstor',\r\n fli = 'video/x-fli',\r\n ftc = 'application/vnd.fluxtime.clip',\r\n fdf = 'application/vnd.fdf',\r\n f = 'text/x-fortran',\r\n mif = 'application/vnd.mif',\r\n fm = 'application/vnd.framemaker',\r\n fh = 'image/x-freehand',\r\n fsc = 'application/vnd.fsc.weblaunch',\r\n fnc = 'application/vnd.frogans.fnc',\r\n ltf = 'application/vnd.frogans.ltf',\r\n ddd = 'application/vnd.fujixerox.ddd',\r\n xdw = 'application/vnd.fujixerox.docuworks',\r\n xbd = 'application/vnd.fujixerox.docuworks.binder',\r\n oas = 'application/vnd.fujitsu.oasys',\r\n oa2 = 'application/vnd.fujitsu.oasys2',\r\n oa3 = 'application/vnd.fujitsu.oasys3',\r\n fg5 = 'application/vnd.fujitsu.oasysgp',\r\n bh2 = 'application/vnd.fujitsu.oasysprs',\r\n spl = 'application/x-futuresplash',\r\n fzs = 'application/vnd.fuzzysheet',\r\n g3 = 'image/g3fax',\r\n gmx = 'application/vnd.gmx',\r\n gtw = 'model/vnd.gtw',\r\n txd = 'application/vnd.genomatix.tuxedo',\r\n ggb = 'application/vnd.geogebra.file',\r\n ggt = 'application/vnd.geogebra.tool',\r\n gdl = 'model/vnd.gdl',\r\n gex = 'application/vnd.geometry-explorer',\r\n gxt = 'application/vnd.geonext',\r\n g2w = 'application/vnd.geoplan',\r\n g3w = 'application/vnd.geospace',\r\n gsf = 'application/x-font-ghostscript',\r\n bdf = 'application/x-font-bdf',\r\n gtar = 'application/x-gtar',\r\n texinfo = 'application/x-texinfo',\r\n gnumeric = 'application/x-gnumeric',\r\n kml = 'application/vnd.google-earth.kml+xml',\r\n kmz = 'application/vnd.google-earth.kmz',\r\n gqf = 'application/vnd.grafeq',\r\n gif = 'image/gif',\r\n gv = 'text/vnd.graphviz',\r\n gac = 'application/vnd.groove-account',\r\n ghf = 'application/vnd.groove-help',\r\n gim = 'application/vnd.groove-identity-message',\r\n grv = 'application/vnd.groove-injector',\r\n gtm = 'application/vnd.groove-tool-message',\r\n tpl = 'application/vnd.groove-tool-template',\r\n vcg = 'application/vnd.groove-vcard',\r\n h261 = 'video/h261',\r\n h263 = 'video/h263',\r\n h264 = 'video/h264',\r\n hpid = 'application/vnd.hp-hpid',\r\n hps = 'application/vnd.hp-hps',\r\n hdf = 'application/x-hdf',\r\n rip = 'audio/vnd.rip',\r\n hbci = 'application/vnd.hbci',\r\n jlt = 'application/vnd.hp-jlyt',\r\n pcl = 'application/vnd.hp-pcl',\r\n hpgl = 'application/vnd.hp-hpgl',\r\n hvs = 'application/vnd.yamaha.hv-script',\r\n hvd = 'application/vnd.yamaha.hv-dic',\r\n hvp = 'application/vnd.yamaha.hv-voice',\r\n 'sfd-hdstx' = 'application/vnd.hydrostatix.sof-data',\r\n stk = 'application/hyperstudio',\r\n hal = 'application/vnd.hal+xml',\r\n html = 'text/html',\r\n irm = 'application/vnd.ibm.rights-management',\r\n sc = 'application/vnd.ibm.secure-container',\r\n ics = 'text/calendar',\r\n icc = 'application/vnd.iccprofile',\r\n ico = 'image/x-icon',\r\n igl = 'application/vnd.igloader',\r\n ief = 'image/ief',\r\n ivp = 'application/vnd.immervision-ivp',\r\n ivu = 'application/vnd.immervision-ivu',\r\n rif = 'application/reginfo+xml',\r\n '3dml' = 'text/vnd.in3d.3dml',\r\n spot = 'text/vnd.in3d.spot',\r\n igs = 'model/iges',\r\n i2g = 'application/vnd.intergeo',\r\n cdy = 'application/vnd.cinderella',\r\n xpw = 'application/vnd.intercon.formnet',\r\n fcs = 'application/vnd.isac.fcs',\r\n ipfix = 'application/ipfix',\r\n cer = 'application/pkix-cert',\r\n pki = 'application/pkixcmp',\r\n crl = 'application/pkix-crl',\r\n pkipath = 'application/pkix-pkipath',\r\n igm = 'application/vnd.insors.igm',\r\n rcprofile = 'application/vnd.ipunplugged.rcprofile',\r\n irp = 'application/vnd.irepository.package+xml',\r\n jad = 'text/vnd.sun.j2me.app-descriptor',\r\n jar = 'application/java-archive',\r\n class = 'application/java-vm',\r\n jnlp = 'application/x-java-jnlp-file',\r\n ser = 'application/java-serialized-object',\r\n java = 'text/x-java-source,java',\r\n js = 'application/javascript',\r\n json = 'application/json',\r\n joda = 'application/vnd.joost.joda-archive',\r\n jpm = 'video/jpm',\r\n jpg = 'image/jpeg',\r\n pjpeg = 'image/pjpeg',\r\n jpgv = 'video/jpeg',\r\n ktz = 'application/vnd.kahootz',\r\n mmd = 'application/vnd.chipnuts.karaoke-mmd',\r\n karbon = 'application/vnd.kde.karbon',\r\n chrt = 'application/vnd.kde.kchart',\r\n kfo = 'application/vnd.kde.kformula',\r\n flw = 'application/vnd.kde.kivio',\r\n kon = 'application/vnd.kde.kontour',\r\n kpr = 'application/vnd.kde.kpresenter',\r\n ksp = 'application/vnd.kde.kspread',\r\n kwd = 'application/vnd.kde.kword',\r\n htke = 'application/vnd.kenameaapp',\r\n kia = 'application/vnd.kidspiration',\r\n kne = 'application/vnd.kinar',\r\n sse = 'application/vnd.kodak-descriptor',\r\n lasxml = 'application/vnd.las.las+xml',\r\n latex = 'application/x-latex',\r\n lbd = 'application/vnd.llamagraphics.life-balance.desktop',\r\n lbe = 'application/vnd.llamagraphics.life-balance.exchange+xml',\r\n jam = 'application/vnd.jam',\r\n apr = 'application/vnd.lotus-approach',\r\n pre = 'application/vnd.lotus-freelance',\r\n nsf = 'application/vnd.lotus-notes',\r\n org = 'application/vnd.lotus-organizer',\r\n scm = 'application/vnd.lotus-screencam',\r\n lwp = 'application/vnd.lotus-wordpro',\r\n lvp = 'audio/vnd.lucent.voice',\r\n m3u = 'audio/x-mpegurl',\r\n m4v = 'video/x-m4v',\r\n hqx = 'application/mac-binhex40',\r\n portpkg = 'application/vnd.macports.portpkg',\r\n mgp = 'application/vnd.osgeo.mapguide.package',\r\n mrc = 'application/marc',\r\n mrcx = 'application/marcxml+xml',\r\n mxf = 'application/mxf',\r\n nbp = 'application/vnd.wolfram.player',\r\n ma = 'application/mathematica',\r\n mathml = 'application/mathml+xml',\r\n mbox = 'application/mbox',\r\n mc1 = 'application/vnd.medcalcdata',\r\n mscml = 'application/mediaservercontrol+xml',\r\n cdkey = 'application/vnd.mediastation.cdkey',\r\n mwf = 'application/vnd.mfer',\r\n mfm = 'application/vnd.mfmp',\r\n msh = 'model/mesh',\r\n mads = 'application/mads+xml',\r\n mets = 'application/mets+xml',\r\n mods = 'application/mods+xml',\r\n meta4 = 'application/metalink4+xml',\r\n mcd = 'application/vnd.mcd',\r\n flo = 'application/vnd.micrografx.flo',\r\n igx = 'application/vnd.micrografx.igx',\r\n es3 = 'application/vnd.eszigno3+xml',\r\n mdb = 'application/x-msaccess',\r\n asf = 'video/x-ms-asf',\r\n exe = 'application/x-msdownload',\r\n cil = 'application/vnd.ms-artgalry',\r\n cab = 'application/vnd.ms-cab-compressed',\r\n ims = 'application/vnd.ms-ims',\r\n application = 'application/x-ms-application',\r\n clp = 'application/x-msclip',\r\n mdi = 'image/vnd.ms-modi',\r\n eot = 'application/vnd.ms-fontobject',\r\n xls = 'application/vnd.ms-excel',\r\n xlam = 'application/vnd.ms-excel.addin.macroenabled.12',\r\n xlsb = 'application/vnd.ms-excel.sheet.binary.macroenabled.12',\r\n xltm = 'application/vnd.ms-excel.template.macroenabled.12',\r\n xlsm = 'application/vnd.ms-excel.sheet.macroenabled.12',\r\n chm = 'application/vnd.ms-htmlhelp',\r\n crd = 'application/x-mscardfile',\r\n lrm = 'application/vnd.ms-lrm',\r\n mvb = 'application/x-msmediaview',\r\n mny = 'application/x-msmoney',\r\n pptx = 'application/vnd.openxmlformats-officedocument.presentationml.presentation',\r\n sldx = 'application/vnd.openxmlformats-officedocument.presentationml.slide',\r\n ppsx = 'application/vnd.openxmlformats-officedocument.presentationml.slideshow',\r\n potx = 'application/vnd.openxmlformats-officedocument.presentationml.template',\r\n xlsx = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\r\n xltx = 'application/vnd.openxmlformats-officedocument.spreadsheetml.template',\r\n docx = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',\r\n dotx = 'application/vnd.openxmlformats-officedocument.wordprocessingml.template',\r\n obd = 'application/x-msbinder',\r\n thmx = 'application/vnd.ms-officetheme',\r\n onetoc = 'application/onenote',\r\n pya = 'audio/vnd.ms-playready.media.pya',\r\n pyv = 'video/vnd.ms-playready.media.pyv',\r\n ppt = 'application/vnd.ms-powerpoint',\r\n ppa = 'application/vnd.ms-powerpoint',\r\n ppam = 'application/vnd.ms-powerpoint.addin.macroenabled.12',\r\n sldm = 'application/vnd.ms-powerpoint.slide.macroenabled.12',\r\n pptm = 'application/vnd.ms-powerpoint.presentation.macroenabled.12',\r\n ppsm = 'application/vnd.ms-powerpoint.slideshow.macroenabled.12',\r\n potm = 'application/vnd.ms-powerpoint.template.macroenabled.12',\r\n mpp = 'application/vnd.ms-project',\r\n pub = 'application/x-mspublisher',\r\n scd = 'application/x-msschedule',\r\n xap = 'application/x-silverlight-app',\r\n stl = 'application/vnd.ms-pki.stl',\r\n cat = 'application/vnd.ms-pki.seccat',\r\n vsd = 'application/vnd.visio',\r\n vsdx = 'application/vnd.visio2013',\r\n wm = 'video/x-ms-wm',\r\n wma = 'audio/x-ms-wma',\r\n wax = 'audio/x-ms-wax',\r\n wmx = 'video/x-ms-wmx',\r\n wmd = 'application/x-ms-wmd',\r\n wpl = 'application/vnd.ms-wpl',\r\n wmz = 'application/x-ms-wmz',\r\n wmv = 'video/x-ms-wmv',\r\n wvx = 'video/x-ms-wvx',\r\n wmf = 'application/x-msmetafile',\r\n trm = 'application/x-msterminal',\r\n doc = 'application/msword',\r\n docm = 'application/vnd.ms-word.document.macroenabled.12',\r\n dotm = 'application/vnd.ms-word.template.macroenabled.12',\r\n wri = 'application/x-mswrite',\r\n wps = 'application/vnd.ms-works',\r\n xbap = 'application/x-ms-xbap',\r\n xps = 'application/vnd.ms-xpsdocument',\r\n mid = 'audio/midi',\r\n mpy = 'application/vnd.ibm.minipay',\r\n afp = 'application/vnd.ibm.modcap',\r\n rms = 'application/vnd.jcp.javame.midlet-rms',\r\n tmo = 'application/vnd.tmobile-livetv',\r\n prc = 'application/x-mobipocket-ebook',\r\n mbk = 'application/vnd.mobius.mbk',\r\n dis = 'application/vnd.mobius.dis',\r\n plc = 'application/vnd.mobius.plc',\r\n mqy = 'application/vnd.mobius.mqy',\r\n msl = 'application/vnd.mobius.msl',\r\n txf = 'application/vnd.mobius.txf',\r\n daf = 'application/vnd.mobius.daf',\r\n fly = 'text/vnd.fly',\r\n mpc = 'application/vnd.mophun.certificate',\r\n mpn = 'application/vnd.mophun.application',\r\n mj2 = 'video/mj2',\r\n mpga = 'audio/mpeg',\r\n mxu = 'video/vnd.mpegurl',\r\n mpeg = 'video/mpeg',\r\n m21 = 'application/mp21',\r\n mp4a = 'audio/mp4',\r\n 'mp4' = 'video/mp4',\r\n m3u8 = 'application/vnd.apple.mpegurl',\r\n mus = 'application/vnd.musician',\r\n msty = 'application/vnd.muvee.style',\r\n mxml = 'application/xv+xml',\r\n ngdat = 'application/vnd.nokia.n-gage.data',\r\n 'n-gage' = 'application/vnd.nokia.n-gage.symbian.install',\r\n ncx = 'application/x-dtbncx+xml',\r\n nc = 'application/x-netcdf',\r\n nlu = 'application/vnd.neurolanguage.nlu',\r\n dna = 'application/vnd.dna',\r\n nnd = 'application/vnd.noblenet-directory',\r\n nns = 'application/vnd.noblenet-sealer',\r\n nnw = 'application/vnd.noblenet-web',\r\n rpst = 'application/vnd.nokia.radio-preset',\r\n rpss = 'application/vnd.nokia.radio-presets',\r\n n3 = 'text/n3',\r\n edm = 'application/vnd.novadigm.edm',\r\n edx = 'application/vnd.novadigm.edx',\r\n ext = 'application/vnd.novadigm.ext',\r\n gph = 'application/vnd.flographit',\r\n ecelp4800 = 'audio/vnd.nuera.ecelp4800',\r\n ecelp7470 = 'audio/vnd.nuera.ecelp7470',\r\n ecelp9600 = 'audio/vnd.nuera.ecelp9600',\r\n oda = 'application/oda',\r\n ogx = 'application/ogg',\r\n oga = 'audio/ogg',\r\n ogv = 'video/ogg',\r\n dd2 = 'application/vnd.oma.dd2+xml',\r\n oth = 'application/vnd.oasis.opendocument.text-web',\r\n opf = 'application/oebps-package+xml',\r\n qbo = 'application/vnd.intu.qbo',\r\n oxt = 'application/vnd.openofficeorg.extension',\r\n osf = 'application/vnd.yamaha.openscoreformat',\r\n weba = 'audio/webm',\r\n webm = 'video/webm',\r\n odc = 'application/vnd.oasis.opendocument.chart',\r\n otc = 'application/vnd.oasis.opendocument.chart-template',\r\n odb = 'application/vnd.oasis.opendocument.database',\r\n odf = 'application/vnd.oasis.opendocument.formula',\r\n odft = 'application/vnd.oasis.opendocument.formula-template',\r\n odg = 'application/vnd.oasis.opendocument.graphics',\r\n otg = 'application/vnd.oasis.opendocument.graphics-template',\r\n odi = 'application/vnd.oasis.opendocument.image',\r\n oti = 'application/vnd.oasis.opendocument.image-template',\r\n odp = 'application/vnd.oasis.opendocument.presentation',\r\n otp = 'application/vnd.oasis.opendocument.presentation-template',\r\n ods = 'application/vnd.oasis.opendocument.spreadsheet',\r\n ots = 'application/vnd.oasis.opendocument.spreadsheet-template',\r\n odt = 'application/vnd.oasis.opendocument.text',\r\n odm = 'application/vnd.oasis.opendocument.text-master',\r\n ott = 'application/vnd.oasis.opendocument.text-template',\r\n ktx = 'image/ktx',\r\n sxc = 'application/vnd.sun.xml.calc',\r\n stc = 'application/vnd.sun.xml.calc.template',\r\n sxd = 'application/vnd.sun.xml.draw',\r\n std = 'application/vnd.sun.xml.draw.template',\r\n sxi = 'application/vnd.sun.xml.impress',\r\n sti = 'application/vnd.sun.xml.impress.template',\r\n sxm = 'application/vnd.sun.xml.math',\r\n sxw = 'application/vnd.sun.xml.writer',\r\n sxg = 'application/vnd.sun.xml.writer.global',\r\n stw = 'application/vnd.sun.xml.writer.template',\r\n otf = 'application/x-font-otf',\r\n osfpvg = 'application/vnd.yamaha.openscoreformat.osfpvg+xml',\r\n dp = 'application/vnd.osgi.dp',\r\n pdb = 'application/vnd.palm',\r\n p = 'text/x-pascal',\r\n paw = 'application/vnd.pawaafile',\r\n pclxl = 'application/vnd.hp-pclxl',\r\n efif = 'application/vnd.picsel',\r\n pcx = 'image/x-pcx',\r\n psd = 'image/vnd.adobe.photoshop',\r\n prf = 'application/pics-rules',\r\n pic = 'image/x-pict',\r\n chat = 'application/x-chat',\r\n p10 = 'application/pkcs10',\r\n p12 = 'application/x-pkcs12',\r\n p7m = 'application/pkcs7-mime',\r\n p7s = 'application/pkcs7-signature',\r\n p7r = 'application/x-pkcs7-certreqresp',\r\n p7b = 'application/x-pkcs7-certificates',\r\n p8 = 'application/pkcs8',\r\n plf = 'application/vnd.pocketlearn',\r\n pnm = 'image/x-portable-anymap',\r\n pbm = 'image/x-portable-bitmap',\r\n pcf = 'application/x-font-pcf',\r\n pfr = 'application/font-tdpfr',\r\n pgn = 'application/x-chess-pgn',\r\n pgm = 'image/x-portable-graymap',\r\n png = 'image/png',\r\n ppm = 'image/x-portable-pixmap',\r\n pskcxml = 'application/pskc+xml',\r\n pml = 'application/vnd.ctc-posml',\r\n ai = 'application/postscript',\r\n pfa = 'application/x-font-type1',\r\n pbd = 'application/vnd.powerbuilder6',\r\n pgp = 'application/pgp-encrypted',\r\n box = 'application/vnd.previewsystems.box',\r\n ptid = 'application/vnd.pvi.ptid1',\r\n pls = 'application/pls+xml',\r\n str = 'application/vnd.pg.format',\r\n ei6 = 'application/vnd.pg.osasli',\r\n dsc = 'text/prs.lines.tag',\r\n psf = 'application/x-font-linux-psf',\r\n qps = 'application/vnd.publishare-delta-tree',\r\n wg = 'application/vnd.pmi.widget',\r\n qxd = 'application/vnd.quark.quarkxpress',\r\n esf = 'application/vnd.epson.esf',\r\n msf = 'application/vnd.epson.msf',\r\n ssf = 'application/vnd.epson.ssf',\r\n qam = 'application/vnd.epson.quickanime',\r\n qfx = 'application/vnd.intu.qfx',\r\n qt = 'video/quicktime',\r\n rar = 'application/x-rar-compressed',\r\n ram = 'audio/x-pn-realaudio',\r\n rmp = 'audio/x-pn-realaudio-plugin',\r\n rsd = 'application/rsd+xml',\r\n rm = 'application/vnd.rn-realmedia',\r\n bed = 'application/vnd.realvnc.bed',\r\n mxl = 'application/vnd.recordare.musicxml',\r\n musicxml = 'application/vnd.recordare.musicxml+xml',\r\n rnc = 'application/relax-ng-compact-syntax',\r\n rdz = 'application/vnd.data-vision.rdz',\r\n rdf = 'application/rdf+xml',\r\n rp9 = 'application/vnd.cloanto.rp9',\r\n jisp = 'application/vnd.jisp',\r\n rtf = 'application/rtf',\r\n rtx = 'text/richtext',\r\n link66 = 'application/vnd.route66.link66+xml',\r\n rss = 'application/rss+xml,',\r\n shf = 'application/shf+xml',\r\n st = 'application/vnd.sailingtracker.track',\r\n svg = 'image/svg+xml',\r\n sus = 'application/vnd.sus-calendar',\r\n sru = 'application/sru+xml',\r\n setpay = 'application/set-payment-initiation',\r\n setreg = 'application/set-registration-initiation',\r\n sema = 'application/vnd.sema',\r\n semd = 'application/vnd.semd',\r\n semf = 'application/vnd.semf',\r\n see = 'application/vnd.seemail',\r\n snf = 'application/x-font-snf',\r\n spq = 'application/scvp-vp-request',\r\n spp = 'application/scvp-vp-response',\r\n scq = 'application/scvp-cv-request',\r\n scs = 'application/scvp-cv-response',\r\n sdp = 'application/sdp',\r\n etx = 'text/x-setext',\r\n movie = 'video/x-sgi-movie',\r\n ifm = 'application/vnd.shana.informed.formdata',\r\n itp = 'application/vnd.shana.informed.formtemplate',\r\n iif = 'application/vnd.shana.informed.interchange',\r\n ipk = 'application/vnd.shana.informed.package',\r\n tfi = 'application/thraud+xml',\r\n shar = 'application/x-shar',\r\n rgb = 'image/x-rgb',\r\n slt = 'application/vnd.epson.salt',\r\n aso = 'application/vnd.accpac.simply.aso',\r\n imp = 'application/vnd.accpac.simply.imp',\r\n twd = 'application/vnd.simtech-mindmapper',\r\n csp = 'application/vnd.commonspace',\r\n saf = 'application/vnd.yamaha.smaf-audio',\r\n mmf = 'application/vnd.smaf',\r\n spf = 'application/vnd.yamaha.smaf-phrase',\r\n teacher = 'application/vnd.smart.teacher',\r\n svd = 'application/vnd.svd',\r\n rq = 'application/sparql-query',\r\n srx = 'application/sparql-results+xml',\r\n gram = 'application/srgs',\r\n grxml = 'application/srgs+xml',\r\n ssml = 'application/ssml+xml',\r\n skp = 'application/vnd.koan',\r\n sgml = 'text/sgml',\r\n sdc = 'application/vnd.stardivision.calc',\r\n sda = 'application/vnd.stardivision.draw',\r\n sdd = 'application/vnd.stardivision.impress',\r\n smf = 'application/vnd.stardivision.math',\r\n sdw = 'application/vnd.stardivision.writer',\r\n sgl = 'application/vnd.stardivision.writer-global',\r\n sm = 'application/vnd.stepmania.stepchart',\r\n sit = 'application/x-stuffit',\r\n sitx = 'application/x-stuffitx',\r\n sdkm = 'application/vnd.solent.sdkm+xml',\r\n xo = 'application/vnd.olpc-sugar',\r\n au = 'audio/basic',\r\n wqd = 'application/vnd.wqd',\r\n sis = 'application/vnd.symbian.install',\r\n smi = 'application/smil+xml',\r\n xsm = 'application/vnd.syncml+xml',\r\n bdm = 'application/vnd.syncml.dm+wbxml',\r\n xdm = 'application/vnd.syncml.dm+xml',\r\n sv4cpio = 'application/x-sv4cpio',\r\n sv4crc = 'application/x-sv4crc',\r\n sbml = 'application/sbml+xml',\r\n tsv = 'text/tab-separated-values',\r\n tiff = 'image/tiff',\r\n tao = 'application/vnd.tao.intent-module-archive',\r\n tar = 'application/x-tar',\r\n tcl = 'application/x-tcl',\r\n tex = 'application/x-tex',\r\n tfm = 'application/x-tex-tfm',\r\n tei = 'application/tei+xml',\r\n txt = 'text/plain',\r\n dxp = 'application/vnd.spotfire.dxp',\r\n sfs = 'application/vnd.spotfire.sfs',\r\n tsd = 'application/timestamped-data',\r\n tpt = 'application/vnd.trid.tpt',\r\n mxs = 'application/vnd.triscape.mxs',\r\n t = 'text/troff',\r\n tra = 'application/vnd.trueapp',\r\n ttf = 'application/x-font-ttf',\r\n ttl = 'text/turtle',\r\n umj = 'application/vnd.umajin',\r\n uoml = 'application/vnd.uoml+xml',\r\n unityweb = 'application/vnd.unity',\r\n ufd = 'application/vnd.ufdl',\r\n uri = 'text/uri-list',\r\n utz = 'application/vnd.uiq.theme',\r\n ustar = 'application/x-ustar',\r\n uu = 'text/x-uuencode',\r\n vcs = 'text/x-vcalendar',\r\n vcf = 'text/x-vcard',\r\n vcd = 'application/x-cdlink',\r\n vsf = 'application/vnd.vsf',\r\n wrl = 'model/vrml',\r\n vcx = 'application/vnd.vcx',\r\n mts = 'model/vnd.mts',\r\n vtu = 'model/vnd.vtu',\r\n vis = 'application/vnd.visionary',\r\n viv = 'video/vnd.vivo',\r\n ccxml = 'application/ccxml+xml,',\r\n vxml = 'application/voicexml+xml',\r\n src = 'application/x-wais-source',\r\n wbxml = 'application/vnd.wap.wbxml',\r\n wbmp = 'image/vnd.wap.wbmp',\r\n wav = 'audio/x-wav',\r\n davmount = 'application/davmount+xml',\r\n woff = 'application/x-font-woff',\r\n wspolicy = 'application/wspolicy+xml',\r\n webp = 'image/webp',\r\n wtb = 'application/vnd.webturbo',\r\n wgt = 'application/widget',\r\n hlp = 'application/winhlp',\r\n wml = 'text/vnd.wap.wml',\r\n wmls = 'text/vnd.wap.wmlscript',\r\n wmlsc = 'application/vnd.wap.wmlscriptc',\r\n wpd = 'application/vnd.wordperfect',\r\n stf = 'application/vnd.wt.stf',\r\n wsdl = 'application/wsdl+xml',\r\n xbm = 'image/x-xbitmap',\r\n xpm = 'image/x-xpixmap',\r\n xwd = 'image/x-xwindowdump',\r\n der = 'application/x-x509-ca-cert',\r\n fig = 'application/x-xfig',\r\n xhtml = 'application/xhtml+xml',\r\n xml = 'application/xml',\r\n xdf = 'application/xcap-diff+xml',\r\n xenc = 'application/xenc+xml',\r\n xer = 'application/patch-ops-error+xml',\r\n rl = 'application/resource-lists+xml',\r\n rs = 'application/rls-services+xml',\r\n rld = 'application/resource-lists-diff+xml',\r\n xslt = 'application/xslt+xml',\r\n xop = 'application/xop+xml',\r\n xpi = 'application/x-xpinstall',\r\n xspf = 'application/xspf+xml',\r\n xul = 'application/vnd.mozilla.xul+xml',\r\n xyz = 'chemical/x-xyz',\r\n yaml = 'text/yaml',\r\n yang = 'application/yang',\r\n yin = 'application/yin+xml',\r\n zir = 'application/vnd.zul',\r\n zip = 'application/zip'\r\n}\r\n","export function IsNullOrEmpty(value: any): boolean {\r\n return value == null || value.length === 0;\r\n}\r\n","import { Injectable, Renderer2 } from '@angular/core';\r\nimport { FileUploadTypes } from './../helpers/file-types.class';\r\nimport { IsNullOrEmpty } from './../helpers/helpers.class';\r\n\r\nexport type ISize = 'B' | 'KB' | 'MB' | 'GB';\r\n\r\n@Injectable()\r\nexport class FileUploadService {\r\n\r\n private readonly extensions: Array<ISize> = ['B', 'KB', 'MB', 'GB'];\r\n\r\n private readonly sizeRegex = new RegExp(`^(\\\\d+)(?:\\\\s{0,1})(${this.extensions.join('|')})?$`, 'i');\r\n\r\n constructor(private renderer: Renderer2) {\r\n }\r\n\r\n public isFileDragDropAvailable(): boolean {\r\n const div = this.renderer.createElement('div');\r\n return (('draggable' in div) || ('ondragstart' in div && 'ondrop' in div));\r\n }\r\n\r\n public parseSize(value: string | number): number {\r\n if (IsNullOrEmpty(value)) {\r\n return 0;\r\n }\r\n\r\n if (typeof value === 'number') {\r\n return value;\r\n }\r\n\r\n const [, size, extension] = value.match(this.sizeRegex) || [null, '0', 'B'];\r\n const i = IsNullOrEmpty(extension) ? 0 : this.extensions.indexOf(extension.toUpperCase() as ISize);\r\n\r\n return parseInt(size, 10) * Math.pow(1024, i < 0 ? 0 : i);\r\n }\r\n\r\n public formatSize(size: number): string {\r\n return this.calculateSize(size);\r\n }\r\n\r\n private calculateSize(size: number, extensionIndex: number = 0): string {\r\n if (isNaN(size)) {\r\n size = 0;\r\n }\r\n\r\n if (size < 1024) {\r\n return `${Math.round(size * 100) / 100} ${this.extensions[extensionIndex]}`;\r\n }\r\n\r\n return this.calculateSize(size / 1024, extensionIndex + 1);\r\n }\r\n\r\n public getFileType(file: File): string {\r\n return Object.keys(FileUploadTypes).find((key) => FileUploadTypes[key] === file.type);\r\n }\r\n}\r\n","import { BehaviorSubject, Subject, Observable } from 'rxjs';\r\nimport { ValidatorFn, ValidationErrors, ValidationError } from './validators.class';\r\nimport { IsNullOrEmpty } from './helpers.class';\r\nimport { IFileUploadControlConfiguration } from './control.interface';\r\n\r\nexport enum STATUS {\r\n INVALID,\r\n VALID,\r\n DISABLED\r\n}\r\n\r\nexport enum FileEvent {\r\n click = 'click',\r\n focus = 'focus',\r\n blur = 'blur'\r\n}\r\n\r\nexport class FileUploadControl {\r\n\r\n private readonly files: Map<string, File> = new Map();\r\n\r\n private listVisible = true;\r\n\r\n private status: STATUS = STATUS.VALID;\r\n\r\n private errors: Array<{ [key: string]: any }> = [];\r\n\r\n private validators: Array<ValidatorFn> = [];\r\n\r\n private multipleEnabled: boolean = true;\r\n\r\n private nativeBehavior: boolean = false;\r\n\r\n private readonly multipleChanged: BehaviorSubject<boolean> = new BehaviorSubject(this.multipleEnabled);\r\n\r\n private readonly statusChanged: Subject<STATUS> = new Subject();\r\n\r\n private readonly eventsChanged: Subject<FileEvent> = new Subject();\r\n\r\n private readonly discardedValue: Subject<Array<ValidationError>> = new Subject();\r\n\r\n private accept: string | null = null;\r\n\r\n private discard: boolean = false;\r\n\r\n private readonly acceptChanged: BehaviorSubject<string> = new BehaviorSubject(this.accept);\r\n\r\n /**\r\n * track status `VALID`, `INVALID` or `DISABLED`\r\n */\r\n public readonly statusChanges: Observable<STATUS> = this.statusChanged.asObservable();\r\n\r\n /**\r\n * emit an event every time the value of the control\r\n * changes.\r\n * Initially returns last value\r\n */\r\n public readonly valueChanges: BehaviorSubject<Array<File>> = new BehaviorSubject([]);\r\n\r\n /**\r\n * @internal\r\n * used to trigger layout change for list visibility\r\n */\r\n public readonly listVisibilityChanges: BehaviorSubject<boolean> = new BehaviorSubject(this.listVisible);\r\n\r\n /**\r\n * track changed on accept attribute\r\n */\r\n public readonly acceptChanges: Observable<string> = this.acceptChanged.asObservable();\r\n\r\n /**\r\n * emit an event every time user programmatically ask for certain event\r\n */\r\n public readonly eventsChanges: Observable<FileEvent> = this.eventsChanged.asObservable();\r\n\r\n /**\r\n * track changed on multiple attribute\r\n */\r\n public readonly multipleChanges: Observable<boolean> = this.multipleChanged.asObservable();\r\n\r\n /**\r\n * track which files were discarded\r\n */\r\n public readonly discardedValueChanges: Observable<Array<ValidationError>> = this.discardedValue.asObservable();\r\n\r\n constructor(configuration?: IFileUploadControlConfiguration, validators?: ValidatorFn | Array<ValidatorFn>) {\r\n this.initialState(configuration);\r\n this.defineValidators(validators);\r\n }\r\n\r\n /**\r\n * set functions that determines the synchronous validity of this control.\r\n */\r\n public setValidators(newValidators: ValidatorFn | Array<ValidatorFn>): this {\r\n this.defineValidators(newValidators);\r\n this.validate();\r\n return this;\r\n }\r\n\r\n public addFile(file: File): this {\r\n return this.addMultipleFiles([file]);\r\n }\r\n\r\n public removeFile(file: File): this {\r\n if (IsNullOrEmpty(file)) {\r\n throw Error(`File has not been provided.`);\r\n }\r\n\r\n if (!this.disabled) {\r\n this.files.delete(file.name);\r\n this.validate();\r\n this.valueChanges.next(Array.from(this.files.values()));\r\n }\r\n return this;\r\n }\r\n\r\n public addFiles(files: FileList): this {\r\n return this.addMultipleFiles(Array.from(files));\r\n }\r\n\r\n public get valid(): boolean {\r\n return this.errors.length === 0 && this.status !== STATUS.DISABLED;\r\n }\r\n\r\n public get invalid(): boolean {\r\n return this.errors.length > 0;\r\n }\r\n\r\n public getError(): Array<ValidationErrors> {\r\n return this.errors;\r\n }\r\n\r\n /**\r\n * number of uploaded files\r\n */\r\n public get size(): number {\r\n return this.files.size;\r\n }\r\n\r\n /**\r\n * return list of Files\r\n */\r\n public get value(): Array<File> {\r\n return Array.from(this.files.values());\r\n }\r\n\r\n public setValue(files: Array<File>, opts: { emitEvent?: boolean } = {}): this {\r\n this.files.clear();\r\n\r\n if (files instanceof Array) {\r\n this.addMultipleFiles(files, opts);\r\n } else {\r\n throw Error(`FormControl.setValue was provided with wrong argument type, ${files} was provided instead Array<File>`);\r\n }\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * reset the control\r\n */\r\n public clear(): this {\r\n this.files.clear();\r\n this.validate();\r\n this.valueChanges.next(Array.from(this.files.values()));\r\n return this;\r\n }\r\n\r\n public get isListVisible(): boolean {\r\n return this.listVisible;\r\n }\r\n\r\n public setListVisibility(isVisible: boolean = true): this {\r\n this.listVisible = isVisible;\r\n this.listVisibilityChanges.next(this.listVisible);\r\n return this;\r\n }\r\n\r\n public get disabled() {\r\n return this.status === STATUS.DISABLED;\r\n }\r\n\r\n public enable(isEnabled: boolean = true): this {\r\n this.status = isEnabled ? STATUS.VALID : STATUS.DISABLED;\r\n this.validate();\r\n this.statusChanged.next(this.status);\r\n return this;\r\n }\r\n\r\n public disable(isDisabled: boolean = true): this {\r\n this.status = isDisabled ? STATUS.DISABLED : STATUS.VALID;\r\n this.validate();\r\n this.statusChanged.next(this.status);\r\n return this;\r\n }\r\n\r\n public click(): this {\r\n this.eventsChanged.next(FileEvent.click);\r\n return this;\r\n }\r\n\r\n public focus(): this {\r\n this.eventsChanged.next(FileEvent.focus);\r\n return this;\r\n }\r\n\r\n public blur(): this {\r\n this.eventsChanged.next(FileEvent.blur);\r\n return this;\r\n }\r\n\r\n /**\r\n * specifies the types of files that the server accepts\r\n *\r\n * ### Example\r\n *\r\n * ```\r\n * acceptFiles(\"file_extension|audio/*|video/*|image/*|media_type\")\r\n * ```\r\n *\r\n * To specify more than one value, separate the values with a comma (e.g. acceptFiles(\"audio/*,video/*,image/*\").\r\n *\r\n */\r\n public acceptFiles(accept: string): this {\r\n this.accept = accept;\r\n this.acceptChanged.next(this.accept);\r\n return this;\r\n }\r\n\r\n public acceptAll(): this {\r\n this.accept = null;\r\n this.acceptChanged.next(this.accept);\r\n return this;\r\n }\r\n\r\n public get isMultiple(): boolean {\r\n return this.multipleEnabled;\r\n }\r\n\r\n public multiple(isEnabled: boolean = true): this {\r\n this.multipleEnabled = isEnabled;\r\n this.multipleChanged.next(this.multipleEnabled);\r\n return this;\r\n }\r\n\r\n public native(isNativeBehaviorEnabled: boolean = true): this {\r\n this.nativeBehavior = isNativeBehaviorEnabled;\r\n return this;\r\n }\r\n\r\n public discardInvalid(discard: boolean = true): this {\r\n this.discard = discard;\r\n return this;\r\n }\r\n\r\n private initialState(configuration: IFileUploadControlConfiguration = {}): void {\r\n if (IsNullOrEmpty(configuration)) {\r\n return;\r\n }\r\n /**\r\n * Toggles discard of all invalid files\r\n * it depends to accept, limit, size once a file\r\n * dropped or selected it will be discarded if does not satisfy the constraint\r\n */\r\n this.discard = configuration.discardInvalid || this.discard;\r\n this.status = !!configuration.disabled ? STATUS.DISABLED : this.status;\r\n this.nativeBehavior = configuration.native != null ? configuration.native : this.nativeBehavior;\r\n\r\n if (!IsNullOrEmpty(configuration.multiple)) {\r\n this.multiple(configuration.multiple);\r\n }\r\n if (!IsNullOrEmpty(configuration.listVisible)) {\r\n this.setListVisibility(configuration.listVisible);\r\n }\r\n if (!IsNullOrEmpty(configuration.accept)) {\r\n this.acceptFiles(configuration.accept.join(','));\r\n }\r\n }\r\n\r\n private defineValidators(validators: ValidatorFn | Array<ValidatorFn>): void {\r\n if (!IsNullOrEmpty(validators)) {\r\n this.validators = Array.isArray(validators) ? [...validators] : [validators];\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n * used to prevent valueChanges emit more times\r\n * when multiple files are uploaded\r\n */\r\n private addMultipleFiles(files: Array<File>, { emitEvent }: { emitEvent?: boolean } = {}): this {\r\n if (IsNullOrEmpty(files)) {\r\n this.validate();\r\n if (emitEvent != false) {\r\n this.valueChanges.next(Array.from(this.files.values()));\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * native component deletes the list of files before adding new ones\r\n */\r\n if (this.nativeBehavior !== false) {\r\n this.files.clear();\r\n }\r\n\r\n if (!this.multipleEnabled) {\r\n /**\r\n * if multiple is disabled and one file exists\r\n * clear it and reupload a new one\r\n */\r\n if (this.files.size === 1) {\r\n this.files.clear();\r\n }\r\n // add only one file\r\n this.files.set(files[0].name, files[0]);\r\n } else {\r\n // replace files with same name\r\n files.forEach(file => this.files.set(file.name, file));\r\n }\r\n\r\n if (this.discard) {\r\n this.analyzeToDiscard();\r\n } else {\r\n this.validate();\r\n }\r\n\r\n if (emitEvent != false) {\r\n this.valueChanges.next(Array.from(this.files.values()));\r\n }\r\n return this;\r\n }\r\n\r\n /**\r\n * method used to discard invalid files\r\n */\r\n private analyzeToDiscard(): void {\r\n const deletedFiles: Array<ValidationError> = [];\r\n\r\n const validators = [...this.validators];\r\n\r\n while (validators.length) {\r\n const validator = validators.shift();\r\n const error = validator(this);\r\n\r\n if (error) {\r\n this.discardFile(error, deletedFiles);\r\n }\r\n }\r\n\r\n if (deletedFiles.length) {\r\n this.discardedValue.next(deletedFiles);\r\n }\r\n }\r\n\r\n private discardFile(error: ValidationErrors, deletedFiles: Array<ValidationError>) {\r\n const errorsKey = Object.keys(error)[0];\r\n const errors = error[errorsKey];\r\n\r\n (Array.isArray(errors) ? errors : [errors]).forEach(fileError => {\r\n if (fileError.file && this.files.has(fileError.file.name)) {\r\n deletedFiles.push(fileError);\r\n this.files.delete(fileError.file.name);\r\n } else {\r\n this.errors.push(error);\r\n }\r\n });\r\n }\r\n\r\n private validate(): void {\r\n if (this.status !== STATUS.DISABLED) {\r\n const currentState = this.valid;\r\n this.errors = this.validators.map((validator) => validator(this)).filter((isInvalid) => isInvalid);\r\n\r\n if (currentState !== this.valid) {\r\n this.statusChanged.next(this.valid ? STATUS.VALID : STATUS.INVALID);\r\n }\r\n } else {\r\n this.errors.length = 0;\r\n }\r\n }\r\n}\r\n","import { FileEvent, FileUploadControl } from './../helpers/control.class';\r\nimport {\r\n ElementRef,\r\n OnDestroy,\r\n Renderer2,\r\n ChangeDetectorRef,\r\n OnInit,\r\n Directive,\r\n inject,\r\n input,\r\n InputSignal,\r\n Signal,\r\n viewChild,\r\n InputSignalWithTransform,\r\n booleanAttribute\r\n} from '@angular/core';\r\nimport { Subscription, merge } from 'rxjs';\r\nimport { IsNullOrEmpty } from './../helpers/helpers.class';\r\n\r\nexport const HAS_FILES_CLASS_NAME = 'has-files';\r\nexport const IS_INVALID_CLASS_NAME = 'ng-invalid';\r\nexport const DR