@mozaic-ds/web-components 0.4.1-beta.0 → 0.5.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 (173) hide show
  1. package/package.json +1 -1
  2. package/public/ClickOutside-63071e7a.js +15 -1
  3. package/public/ClickOutside-63071e7a.js.map +1 -1
  4. package/public/DataTableDefaultAction.nested-4da4dc44.js +759 -1
  5. package/public/DataTableDefaultAction.nested-4da4dc44.js.map +1 -1
  6. package/public/DataTableUtilities-60220c78.js +370 -1
  7. package/public/DataTableUtilities-60220c78.js.map +1 -1
  8. package/public/EventForward-8492ff62.js +109 -1
  9. package/public/EventForward-8492ff62.js.map +1 -1
  10. package/public/EventHandler-02058705.js +15 -1
  11. package/public/EventHandler-02058705.js.map +1 -1
  12. package/public/array-5b770a93.js +13 -1
  13. package/public/array-5b770a93.js.map +1 -1
  14. package/public/axis-fbc0f7b5.js +174 -1
  15. package/public/axis-fbc0f7b5.js.map +1 -1
  16. package/public/band-d7a07d2c.js +186 -1
  17. package/public/band-d7a07d2c.js.map +1 -1
  18. package/public/components/accordion/Accordion.js +365 -1
  19. package/public/components/accordion/Accordion.js.map +1 -1
  20. package/public/components/autocomplete/Autocomplete.js +1515 -1
  21. package/public/components/autocomplete/Autocomplete.js.map +1 -1
  22. package/public/components/badge/Badge.js +155 -1
  23. package/public/components/badge/Badge.js.map +1 -1
  24. package/public/components/badge/Badge.nested.js +101 -1
  25. package/public/components/badge/Badge.nested.js.map +1 -1
  26. package/public/components/breadcrumb/Breadcrumb.js +372 -1
  27. package/public/components/breadcrumb/Breadcrumb.js.map +1 -1
  28. package/public/components/breadcrumb/Breadcrumb.nested.js +319 -1
  29. package/public/components/breadcrumb/Breadcrumb.nested.js.map +1 -1
  30. package/public/components/button/Button.js +1138 -1
  31. package/public/components/button/Button.js.map +1 -1
  32. package/public/components/card/Card.js +369 -1
  33. package/public/components/card/Card.js.map +1 -1
  34. package/public/components/chart/BarChart.js +582 -1
  35. package/public/components/chart/BarChart.js.map +1 -1
  36. package/public/components/chart/Donut.js +1189 -1
  37. package/public/components/chart/Donut.js.map +1 -1
  38. package/public/components/chart/GroupedBarChart.js +750 -1
  39. package/public/components/chart/GroupedBarChart.js.map +1 -1
  40. package/public/components/chart/LineChart.js +1731 -1
  41. package/public/components/chart/LineChart.js.map +1 -1
  42. package/public/components/chart/Radar.js +729 -1
  43. package/public/components/chart/Radar.js.map +1 -1
  44. package/public/components/chart/StackedBarChart.js +745 -1
  45. package/public/components/chart/StackedBarChart.js.map +1 -1
  46. package/public/components/checkbox/Checkbox.js +307 -1
  47. package/public/components/checkbox/Checkbox.js.map +1 -1
  48. package/public/components/checkboxgroup/checkboxGroup.js +404 -1
  49. package/public/components/checkboxgroup/checkboxGroup.js.map +1 -1
  50. package/public/components/datatable/DataTable.js +3064 -1
  51. package/public/components/datatable/DataTable.js.map +1 -1
  52. package/public/components/datatable/DataTableDefaultAction.nested.js +4 -1
  53. package/public/components/datatable/DataTableDefaultAction.nested.js.map +1 -1
  54. package/public/components/datatable/DataTableDefaultEdtion.nested.js +164 -1
  55. package/public/components/datatable/DataTableDefaultEdtion.nested.js.map +1 -1
  56. package/public/components/datatable/DataTableDefaultFilterTags.nested.js +380 -1
  57. package/public/components/datatable/DataTableDefaultFilterTags.nested.js.map +1 -1
  58. package/public/components/datatable/DataTableDefaultSelection.nested.js +424 -1
  59. package/public/components/datatable/DataTableDefaultSelection.nested.js.map +1 -1
  60. package/public/components/datatable/DataTableDefaultSelectionLabel.nested.js +263 -1
  61. package/public/components/datatable/DataTableDefaultSelectionLabel.nested.js.map +1 -1
  62. package/public/components/datatable/DataTableFooter.nested.js +637 -1
  63. package/public/components/datatable/DataTableFooter.nested.js.map +1 -1
  64. package/public/components/dropdown/Dropdown.js +1426 -1
  65. package/public/components/dropdown/Dropdown.js.map +1 -1
  66. package/public/components/field/Field.js +375 -1
  67. package/public/components/field/Field.js.map +1 -1
  68. package/public/components/fileuploader/FileUploader.js +555 -1
  69. package/public/components/fileuploader/FileUploader.js.map +1 -1
  70. package/public/components/fileuploader/ResultFile.nested.js +265 -1
  71. package/public/components/fileuploader/ResultFile.nested.js.map +1 -1
  72. package/public/components/flag/Flag.js +174 -1
  73. package/public/components/flag/Flag.js.map +1 -1
  74. package/public/components/header/Header.js +903 -1
  75. package/public/components/header/Header.js.map +1 -1
  76. package/public/components/hero/Hero.js +271 -1
  77. package/public/components/hero/Hero.js.map +1 -1
  78. package/public/components/layer/Layer.js +453 -1
  79. package/public/components/layer/Layer.js.map +1 -1
  80. package/public/components/link/Link.js +380 -1
  81. package/public/components/link/Link.js.map +1 -1
  82. package/public/components/listbox/Listbox.js +595 -1
  83. package/public/components/listbox/Listbox.js.map +1 -1
  84. package/public/components/listbox/Listbox.nested.js +629 -1
  85. package/public/components/listbox/Listbox.nested.js.map +1 -1
  86. package/public/components/loader/Loader.js +246 -1
  87. package/public/components/loader/Loader.js.map +1 -1
  88. package/public/components/loader/Loader.nested.js +176 -1
  89. package/public/components/loader/Loader.nested.js.map +1 -1
  90. package/public/components/modal/Modal.js +395 -1
  91. package/public/components/modal/Modal.js.map +1 -1
  92. package/public/components/notification/Notification.js +458 -1
  93. package/public/components/notification/Notification.js.map +1 -1
  94. package/public/components/optionbutton/OptionButton.js +316 -1
  95. package/public/components/optionbutton/OptionButton.js.map +1 -1
  96. package/public/components/overlay/Overlay.js +104 -1
  97. package/public/components/overlay/Overlay.js.map +1 -1
  98. package/public/components/overlay/OverlayLoader.js +151 -1
  99. package/public/components/overlay/OverlayLoader.js.map +1 -1
  100. package/public/components/pagination/Pagination.js +613 -1
  101. package/public/components/pagination/Pagination.js.map +1 -1
  102. package/public/components/passwordinput/PasswordInput.js +291 -1
  103. package/public/components/passwordinput/PasswordInput.js.map +1 -1
  104. package/public/components/phonenumber/PhoneNumber.js +6894 -1
  105. package/public/components/phonenumber/PhoneNumber.js.map +1 -1
  106. package/public/components/phonenumber/PhoneNumber.svelte +72 -9
  107. package/public/components/price/Price.js +768 -1
  108. package/public/components/price/Price.js.map +1 -1
  109. package/public/components/progressbar/ProgressBar.js +278 -1
  110. package/public/components/progressbar/ProgressBar.js.map +1 -1
  111. package/public/components/quantityselector/QuantitySelector.js +333 -1
  112. package/public/components/quantityselector/QuantitySelector.js.map +1 -1
  113. package/public/components/radio/Radio.js +273 -1
  114. package/public/components/radio/Radio.js.map +1 -1
  115. package/public/components/radiogroup/RadioGroup.js +414 -1
  116. package/public/components/radiogroup/RadioGroup.js.map +1 -1
  117. package/public/components/ratings/StarsInput.js +292 -1
  118. package/public/components/ratings/StarsInput.js.map +1 -1
  119. package/public/components/ratings/StarsResult.js +246 -1
  120. package/public/components/ratings/StarsResult.js.map +1 -1
  121. package/public/components/select/Select.js +451 -1
  122. package/public/components/select/Select.js.map +1 -1
  123. package/public/components/sidebar/Sidebar.js +784 -1
  124. package/public/components/sidebar/Sidebar.js.map +1 -1
  125. package/public/components/sidebar/sidebar-feature-group.nested.js +594 -1
  126. package/public/components/sidebar/sidebar-feature-group.nested.js.map +1 -1
  127. package/public/components/sidebar/sidebar-feature.nested.js +402 -1
  128. package/public/components/sidebar/sidebar-feature.nested.js.map +1 -1
  129. package/public/components/sidebar/sidebar-section.nested.js +394 -1
  130. package/public/components/sidebar/sidebar-section.nested.js.map +1 -1
  131. package/public/components/sidebar/sidebar-segment.nested.js +200 -1
  132. package/public/components/sidebar/sidebar-segment.nested.js.map +1 -1
  133. package/public/components/sidebar/sidebar-separator.nested.js +49 -1
  134. package/public/components/sidebar/sidebar-separator.nested.js.map +1 -1
  135. package/public/components/sidebar/sidebar-sub-features.nested.js +312 -1
  136. package/public/components/sidebar/sidebar-sub-features.nested.js.map +1 -1
  137. package/public/components/sidebar/sidebar-user.nested.js +733 -1
  138. package/public/components/sidebar/sidebar-user.nested.js.map +1 -1
  139. package/public/components/stepper/Stepper.js +371 -1
  140. package/public/components/stepper/Stepper.js.map +1 -1
  141. package/public/components/tabs/Tabs.js +615 -1
  142. package/public/components/tabs/Tabs.js.map +1 -1
  143. package/public/components/tabs/Tabs.nested.js +472 -1
  144. package/public/components/tabs/Tabs.nested.js.map +1 -1
  145. package/public/components/tag/Tag.js +665 -1
  146. package/public/components/tag/Tag.js.map +1 -1
  147. package/public/components/tag/Tag.nested.js +554 -1
  148. package/public/components/tag/Tag.nested.js.map +1 -1
  149. package/public/components/taglist/TagList.js +475 -1
  150. package/public/components/taglist/TagList.js.map +1 -1
  151. package/public/components/textarea/Textarea.js +303 -1
  152. package/public/components/textarea/Textarea.js.map +1 -1
  153. package/public/components/textinput/Textinput.js +497 -1
  154. package/public/components/textinput/Textinput.js.map +1 -1
  155. package/public/components/textinput/Textinput.nested.js +320 -1
  156. package/public/components/textinput/Textinput.nested.js.map +1 -1
  157. package/public/components/toggle/Toggle.js +278 -1
  158. package/public/components/toggle/Toggle.js.map +1 -1
  159. package/public/components/tooltip/Tooltip.js +173 -1
  160. package/public/components/tooltip/Tooltip.js.map +1 -1
  161. package/public/index-c33b3772.js +873 -1
  162. package/public/index-c33b3772.js.map +1 -1
  163. package/public/linear-f46d7e9e.js +700 -1
  164. package/public/linear-f46d7e9e.js.map +1 -1
  165. package/public/path-1b5da959.js +186 -1
  166. package/public/path-1b5da959.js.map +1 -1
  167. package/public/sidebar-service-275bf9ef.js +129 -1
  168. package/public/sidebar-service-275bf9ef.js.map +1 -1
  169. package/public/symbol-b05a6e2b.js +169 -1
  170. package/public/symbol-b05a6e2b.js.map +1 -1
  171. package/public/transform-15d69d5d.js +2743 -1
  172. package/public/transform-15d69d5d.js.map +1 -1
  173. package/public/utilities/stories/phonenumber/PhoneNumber.stories.d.ts.map +1 -1
@@ -1,2 +1,556 @@
1
- import{S as e,i,a as s,b as l,f as t,s as a,e as o,d as r,t as n,n as d,g as c,j as u,l as M,k as w,C as m,D as p,E as x,o as b,x as f,A as g,G as L,M as h,v as $}from"../../index-c33b3772.js";import{E as D}from"../../EventHandler-02058705.js";import S from"./ResultFile.nested.js";function y(e){let i,s;return i=new S({props:{files:e[7],allowedExtensions:e[10],disabled:e[5],maxSize:e[11],removelabel:e[6]}}),i.$on("file-removed",e[13]),{c(){f(i.$$.fragment)},m(e,l){g(i,e,l),s=!0},p(e,s){const l={};128&s&&(l.files=e[7]),1024&s&&(l.allowedExtensions=e[10]),32&s&&(l.disabled=e[5]),2048&s&&(l.maxSize=e[11]),64&s&&(l.removelabel=e[6]),i.$set(l)},i(e){s||(m(i.$$.fragment,e),s=!0)},o(e){p(i.$$.fragment,e),s=!1},d(e){L(i,e)}}}function N(e){let i,s;return i=new S({props:{files:e[9],allowedExtensions:e[10],disabled:e[5],maxSize:e[11],removelabel:e[6]}}),i.$on("file-removed",e[13]),{c(){f(i.$$.fragment)},m(e,l){g(i,e,l),s=!0},p(e,s){const l={};512&s&&(l.files=e[9]),1024&s&&(l.allowedExtensions=e[10]),32&s&&(l.disabled=e[5]),2048&s&&(l.maxSize=e[11]),64&s&&(l.removelabel=e[6]),i.$set(l)},i(e){s||(m(i.$$.fragment,e),s=!0)},o(e){p(i.$$.fragment,e),s=!1},d(e){L(i,e)}}}function T(e){let i,s,t,a,f,g,L,$,D,S,T,j=e[0]&&e[7].length>0&&y(e),v=e[9].length>0&&N(e);return{c(){i=o("div"),s=o("input"),t=r(),a=o("label"),f=o("span"),g=n(e[2]),L=r(),j&&j.c(),$=r(),v&&v.c(),this.c=d,c(s,"id",e[1]),c(s,"type","file"),c(s,"class","mc-fileuploader__input"),c(s,"accept",e[3]),s.multiple=e[4],s.disabled=e[5],c(f,"class","mc-fileuploader__label--center"),c(a,"for",e[1]),c(a,"class","mc-fileuploader__label"),c(i,"class","mc-fileuploader")},m(o,r){l(o,i,r),u(i,s),u(i,t),u(i,a),u(a,f),u(f,g),u(i,L),j&&j.m(i,null),u(i,$),v&&v.m(i,null),e[17](i),D=!0,S||(T=M(s,"change",e[12]),S=!0)},p(e,[l]){(!D||2&l)&&c(s,"id",e[1]),(!D||8&l)&&c(s,"accept",e[3]),(!D||16&l)&&(s.multiple=e[4]),(!D||32&l)&&(s.disabled=e[5]),(!D||4&l)&&w(g,e[2]),(!D||2&l)&&c(a,"for",e[1]),e[0]&&e[7].length>0?j?(j.p(e,l),129&l&&m(j,1)):(j=y(e),j.c(),m(j,1),j.m(i,$)):j&&(h(),p(j,1,1,(()=>{j=null})),x()),e[9].length>0?v?(v.p(e,l),512&l&&m(v,1)):(v=N(e),v.c(),m(v,1),v.m(i,null)):v&&(h(),p(v,1,1,(()=>{v=null})),x())},i(e){D||(m(j),m(v),D=!0)},o(e){p(j),p(v),D=!1},d(s){s&&b(i),j&&j.d(),v&&v.d(),e[17](null),S=!1,T()}}}function j(e,i,s){let l,t,a,o,r,{id:n}=i,{label:d}=i,{accept:c}=i,{multiple:u=!0}=i,{allowedextensions:M}=i,{maxsize:w}=i,{displayfileslist:m=!1}=i,{disabled:p=!1}=i,{removelabel:x="Remove"}=i,{uploadedfiles:b}=i,f=new D;return e.$$set=e=>{"id"in e&&s(1,n=e.id),"label"in e&&s(2,d=e.label),"accept"in e&&s(3,c=e.accept),"multiple"in e&&s(4,u=e.multiple),"allowedextensions"in e&&s(14,M=e.allowedextensions),"maxsize"in e&&s(15,w=e.maxsize),"displayfileslist"in e&&s(0,m=e.displayfileslist),"disabled"in e&&s(5,p=e.disabled),"removelabel"in e&&s(6,x=e.removelabel),"uploadedfiles"in e&&s(16,b=e.uploadedfiles)},e.$$.update=()=>{16384&e.$$.dirty&&s(10,l=M?JSON.parse(M):[]),65536&e.$$.dirty&&s(9,t=b?JSON.parse(b):[]),e.$$.dirty,32768&e.$$.dirty&&s(11,a=w||void 0)},[m,n,d,c,u,p,x,o,r,t,l,a,function(e){const i=e.target;s(7,o=i.files),s(0,m=!0);const t=[];[...o].forEach(((e,i)=>{const s=e.name,o=e.size,r=function(e){if(l&&l.length>0){const i=e.slice(2+(e.lastIndexOf(".")-1>>>0));if(l&&!l.includes(String(i)))return!1}return!0}(s),n=function(e){return!(a&&e/1024/1024>a)}(o);let d="";r||(d="invalid-extension"),n||(d="invalid-size"),r&&n||t.push({index:i,fileName:s,fileSize:o,errorType:d})})),t.length>0&&f.dispatch("invalid-files",t),f.dispatch("change",o)},function(e){s(7,o=[...t]),s(7,o=function(e,i){const s=Array.from(e),l=s.indexOf(i);return-1!==l&&s.splice(l,1),s}(o,e.detail)),r.querySelector(".mc-fileuploader__input").value="",s(9,t=o),f.dispatch("file-removed",e.detail)},M,w,b,function(e){$[e?"unshift":"push"]((()=>{r=e,s(8,r)}))}]}class v extends e{constructor(e){super();const o=document.createElement("style");o.textContent='.mc-fileuploader{position:relative;display:block}.mc-fileuploader__input{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0;visibility:visible;white-space:nowrap}.mc-fileuploader__label{font-family:"LeroyMerlin", sans-serif;font-weight:600;cursor:pointer;border-radius:4px;text-align:center;border:2px solid transparent;-webkit-transition:all ease 200ms;-o-transition:all ease 200ms;transition:all ease 200ms;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;vertical-align:middle;font-size:1rem;line-height:1.375;padding:0.6875rem 1.5rem;min-height:3rem;min-width:3rem;color:#188803;border-color:#188803;background-color:#ffffff;margin:0;-webkit-box-shadow:none;box-shadow:none;text-decoration:none;outline:none;-webkit-box-sizing:border-box;box-sizing:border-box}.mc-fileuploader__label:hover{background-color:#ebf5de;color:#006902}.mc-fileuploader__label:active{background-color:#c5e39e;color:#035010}.mc-fileuploader__label:active{background-color:#c5e39e;color:#035010}.mc-fileuploader__label:disabled{background-color:#cccccc;border-color:transparent;color:#666666;cursor:not-allowed}.mc-fileuploader__label::before{content:"";width:1.5rem;height:1.5rem;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background:transparent url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMS41cmVtIiB3aWR0aD0iMS41cmVtIiBmaWxsPSIjMTg4ODAzIiB2aWV3Qm94PSIwIDAgMjQgMjQiPjx0aXRsZT5NZWRpYV9VcGxvYWRfMjRweDwvdGl0bGU+PHBhdGggZD0iTTguNzEsNy43MSwxMSw1LjQxVjE2YTEsMSwwLDAsMCwyLDBWNS40MWwyLjI5LDIuM2ExLDEsMCwwLDAsMS40MiwwLDEsMSwwLDAsMCwwLTEuNDJsLTQtNGExLDEsMCwwLDAtMS40MiwwbC00LDRBMSwxLDAsMSwwLDguNzEsNy43MVoiLz48cGF0aCBkPSJNMTYuMjIsMTIuNDRhMSwxLDAsMCwwLTEuMi43NywxLDEsMCwwLDAsLjc2LDEuMTlDMTguNTUsMTUsMjAsMTYuMTcsMjAsMTdjMCwxLjIyLTMuMTIsMy04LDNzLTgtMS43OC04LTNjMC0uODMsMS40NS0yLDQuMjItMi42QTEsMSwwLDAsMCw5LDEzLjIxYTEsMSwwLDAsMC0xLjItLjc3QzQuMTYsMTMuMjUsMiwxNSwyLDE3YzAsMi44NSw0LjMsNSwxMCw1czEwLTIuMTUsMTAtNUMyMiwxNSwxOS44NCwxMy4yNSwxNi4yMiwxMi40NFoiLz48L3N2Zz4=") no-repeat;background-size:1.5rem;margin-right:0.5rem;margin-left:-0.5rem}:focus+.mc-fileuploader__label{-webkit-box-shadow:0 0 0 0.125rem #ffffff, 0 0 0 0.25rem #0b96cc;box-shadow:0 0 0 0.125rem #ffffff, 0 0 0 0.25rem #0b96cc}:hover+.mc-fileuploader__label{color:#006902;background-color:#ebf5de}:disabled+.mc-fileuploader__label{color:#666666;background-color:#cccccc;border-color:transparent;cursor:not-allowed}:disabled+.mc-fileuploader__label::before{background:transparent url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMS41cmVtIiB3aWR0aD0iMS41cmVtIiBmaWxsPSIjNjY2NjY2IiB2aWV3Qm94PSIwIDAgMjQgMjQiPjx0aXRsZT5NZWRpYV9VcGxvYWRfMjRweDwvdGl0bGU+PHBhdGggZD0iTTguNzEsNy43MSwxMSw1LjQxVjE2YTEsMSwwLDAsMCwyLDBWNS40MWwyLjI5LDIuM2ExLDEsMCwwLDAsMS40MiwwLDEsMSwwLDAsMCwwLTEuNDJsLTQtNGExLDEsMCwwLDAtMS40MiwwbC00LDRBMSwxLDAsMSwwLDguNzEsNy43MVoiLz48cGF0aCBkPSJNMTYuMjIsMTIuNDRhMSwxLDAsMCwwLTEuMi43NywxLDEsMCwwLDAsLjc2LDEuMTlDMTguNTUsMTUsMjAsMTYuMTcsMjAsMTdjMCwxLjIyLTMuMTIsMy04LDNzLTgtMS43OC04LTNjMC0uODMsMS40NS0yLDQuMjItMi42QTEsMSwwLDAsMCw5LDEzLjIxYTEsMSwwLDAsMC0xLjItLjc3QzQuMTYsMTMuMjUsMiwxNSwyLDE3YzAsMi44NSw0LjMsNSwxMCw1czEwLTIuMTUsMTAtNUMyMiwxNSwxOS44NCwxMy4yNSwxNi4yMiwxMi40NFoiLz48L3N2Zz4=") no-repeat}',this.shadowRoot.appendChild(o),i(this,{target:this.shadowRoot,props:s(this.attributes),customElement:!0},j,T,a,{id:1,label:2,accept:3,multiple:4,allowedextensions:14,maxsize:15,displayfileslist:0,disabled:5,removelabel:6,uploadedfiles:16},null),e&&(e.target&&l(e.target,this,e.anchor),e.props&&(this.$set(e.props),t()))}static get observedAttributes(){return["id","label","accept","multiple","allowedextensions","maxsize","displayfileslist","disabled","removelabel","uploadedfiles"]}get id(){return this.$$.ctx[1]}set id(e){this.$$set({id:e}),t()}get label(){return this.$$.ctx[2]}set label(e){this.$$set({label:e}),t()}get accept(){return this.$$.ctx[3]}set accept(e){this.$$set({accept:e}),t()}get multiple(){return this.$$.ctx[4]}set multiple(e){this.$$set({multiple:e}),t()}get allowedextensions(){return this.$$.ctx[14]}set allowedextensions(e){this.$$set({allowedextensions:e}),t()}get maxsize(){return this.$$.ctx[15]}set maxsize(e){this.$$set({maxsize:e}),t()}get displayfileslist(){return this.$$.ctx[0]}set displayfileslist(e){this.$$set({displayfileslist:e}),t()}get disabled(){return this.$$.ctx[5]}set disabled(e){this.$$set({disabled:e}),t()}get removelabel(){return this.$$.ctx[6]}set removelabel(e){this.$$set({removelabel:e}),t()}get uploadedfiles(){return this.$$.ctx[16]}set uploadedfiles(e){this.$$set({uploadedfiles:e}),t()}}export{v as default};
1
+ import { S as SvelteElement, i as init, a as attribute_to_object, b as insert, f as flush, s as safe_not_equal, e as element, d as space, t as text, n as noop, g as attr, j as append, l as listen, k as set_data, C as transition_in, D as transition_out, E as check_outros, o as detach, x as create_component, A as mount_component, G as destroy_component, M as group_outros, v as binding_callbacks } from '../../index-c33b3772.js';
2
+ import { E as EventHandler } from '../../EventHandler-02058705.js';
3
+ import ResultFile_nested from './ResultFile.nested.js';
4
+
5
+ /* src/components/fileuploader/FileUploader.svelte generated by Svelte v3.58.0 */
6
+
7
+ function create_if_block_1(ctx) {
8
+ let resultfile;
9
+ let current;
10
+
11
+ resultfile = new ResultFile_nested({
12
+ props: {
13
+ files: /*files*/ ctx[7],
14
+ allowedExtensions: /*allowedExtensions*/ ctx[10],
15
+ disabled: /*disabled*/ ctx[5],
16
+ maxSize: /*maxSize*/ ctx[11],
17
+ removelabel: /*removelabel*/ ctx[6]
18
+ }
19
+ });
20
+
21
+ resultfile.$on("file-removed", /*deleteFile*/ ctx[13]);
22
+
23
+ return {
24
+ c() {
25
+ create_component(resultfile.$$.fragment);
26
+ },
27
+ m(target, anchor) {
28
+ mount_component(resultfile, target, anchor);
29
+ current = true;
30
+ },
31
+ p(ctx, dirty) {
32
+ const resultfile_changes = {};
33
+ if (dirty & /*files*/ 128) resultfile_changes.files = /*files*/ ctx[7];
34
+ if (dirty & /*allowedExtensions*/ 1024) resultfile_changes.allowedExtensions = /*allowedExtensions*/ ctx[10];
35
+ if (dirty & /*disabled*/ 32) resultfile_changes.disabled = /*disabled*/ ctx[5];
36
+ if (dirty & /*maxSize*/ 2048) resultfile_changes.maxSize = /*maxSize*/ ctx[11];
37
+ if (dirty & /*removelabel*/ 64) resultfile_changes.removelabel = /*removelabel*/ ctx[6];
38
+ resultfile.$set(resultfile_changes);
39
+ },
40
+ i(local) {
41
+ if (current) return;
42
+ transition_in(resultfile.$$.fragment, local);
43
+ current = true;
44
+ },
45
+ o(local) {
46
+ transition_out(resultfile.$$.fragment, local);
47
+ current = false;
48
+ },
49
+ d(detaching) {
50
+ destroy_component(resultfile, detaching);
51
+ }
52
+ };
53
+ }
54
+
55
+ // (126:2) {#if uploadedFiles.length > 0}
56
+ function create_if_block(ctx) {
57
+ let resultfile;
58
+ let current;
59
+
60
+ resultfile = new ResultFile_nested({
61
+ props: {
62
+ files: /*uploadedFiles*/ ctx[9],
63
+ allowedExtensions: /*allowedExtensions*/ ctx[10],
64
+ disabled: /*disabled*/ ctx[5],
65
+ maxSize: /*maxSize*/ ctx[11],
66
+ removelabel: /*removelabel*/ ctx[6]
67
+ }
68
+ });
69
+
70
+ resultfile.$on("file-removed", /*deleteFile*/ ctx[13]);
71
+
72
+ return {
73
+ c() {
74
+ create_component(resultfile.$$.fragment);
75
+ },
76
+ m(target, anchor) {
77
+ mount_component(resultfile, target, anchor);
78
+ current = true;
79
+ },
80
+ p(ctx, dirty) {
81
+ const resultfile_changes = {};
82
+ if (dirty & /*uploadedFiles*/ 512) resultfile_changes.files = /*uploadedFiles*/ ctx[9];
83
+ if (dirty & /*allowedExtensions*/ 1024) resultfile_changes.allowedExtensions = /*allowedExtensions*/ ctx[10];
84
+ if (dirty & /*disabled*/ 32) resultfile_changes.disabled = /*disabled*/ ctx[5];
85
+ if (dirty & /*maxSize*/ 2048) resultfile_changes.maxSize = /*maxSize*/ ctx[11];
86
+ if (dirty & /*removelabel*/ 64) resultfile_changes.removelabel = /*removelabel*/ ctx[6];
87
+ resultfile.$set(resultfile_changes);
88
+ },
89
+ i(local) {
90
+ if (current) return;
91
+ transition_in(resultfile.$$.fragment, local);
92
+ current = true;
93
+ },
94
+ o(local) {
95
+ transition_out(resultfile.$$.fragment, local);
96
+ current = false;
97
+ },
98
+ d(detaching) {
99
+ destroy_component(resultfile, detaching);
100
+ }
101
+ };
102
+ }
103
+
104
+ function create_fragment(ctx) {
105
+ let div;
106
+ let input;
107
+ let t0;
108
+ let label_1;
109
+ let span;
110
+ let t1;
111
+ let t2;
112
+ let t3;
113
+ let current;
114
+ let mounted;
115
+ let dispose;
116
+ let if_block0 = /*displayfileslist*/ ctx[0] && /*files*/ ctx[7].length > 0 && create_if_block_1(ctx);
117
+ let if_block1 = /*uploadedFiles*/ ctx[9].length > 0 && create_if_block(ctx);
118
+
119
+ return {
120
+ c() {
121
+ div = element("div");
122
+ input = element("input");
123
+ t0 = space();
124
+ label_1 = element("label");
125
+ span = element("span");
126
+ t1 = text(/*label*/ ctx[2]);
127
+ t2 = space();
128
+ if (if_block0) if_block0.c();
129
+ t3 = space();
130
+ if (if_block1) if_block1.c();
131
+ this.c = noop;
132
+ attr(input, "id", /*id*/ ctx[1]);
133
+ attr(input, "type", "file");
134
+ attr(input, "class", "mc-fileuploader__input");
135
+ attr(input, "accept", /*accept*/ ctx[3]);
136
+ input.multiple = /*multiple*/ ctx[4];
137
+ input.disabled = /*disabled*/ ctx[5];
138
+ attr(span, "class", "mc-fileuploader__label--center");
139
+ attr(label_1, "for", /*id*/ ctx[1]);
140
+ attr(label_1, "class", "mc-fileuploader__label");
141
+ attr(div, "class", "mc-fileuploader");
142
+ },
143
+ m(target, anchor) {
144
+ insert(target, div, anchor);
145
+ append(div, input);
146
+ append(div, t0);
147
+ append(div, label_1);
148
+ append(label_1, span);
149
+ append(span, t1);
150
+ append(div, t2);
151
+ if (if_block0) if_block0.m(div, null);
152
+ append(div, t3);
153
+ if (if_block1) if_block1.m(div, null);
154
+ /*div_binding*/ ctx[17](div);
155
+ current = true;
156
+
157
+ if (!mounted) {
158
+ dispose = listen(input, "change", /*handleChange*/ ctx[12]);
159
+ mounted = true;
160
+ }
161
+ },
162
+ p(ctx, [dirty]) {
163
+ if (!current || dirty & /*id*/ 2) {
164
+ attr(input, "id", /*id*/ ctx[1]);
165
+ }
166
+
167
+ if (!current || dirty & /*accept*/ 8) {
168
+ attr(input, "accept", /*accept*/ ctx[3]);
169
+ }
170
+
171
+ if (!current || dirty & /*multiple*/ 16) {
172
+ input.multiple = /*multiple*/ ctx[4];
173
+ }
174
+
175
+ if (!current || dirty & /*disabled*/ 32) {
176
+ input.disabled = /*disabled*/ ctx[5];
177
+ }
178
+
179
+ if (!current || dirty & /*label*/ 4) set_data(t1, /*label*/ ctx[2]);
180
+
181
+ if (!current || dirty & /*id*/ 2) {
182
+ attr(label_1, "for", /*id*/ ctx[1]);
183
+ }
184
+
185
+ if (/*displayfileslist*/ ctx[0] && /*files*/ ctx[7].length > 0) {
186
+ if (if_block0) {
187
+ if_block0.p(ctx, dirty);
188
+
189
+ if (dirty & /*displayfileslist, files*/ 129) {
190
+ transition_in(if_block0, 1);
191
+ }
192
+ } else {
193
+ if_block0 = create_if_block_1(ctx);
194
+ if_block0.c();
195
+ transition_in(if_block0, 1);
196
+ if_block0.m(div, t3);
197
+ }
198
+ } else if (if_block0) {
199
+ group_outros();
200
+
201
+ transition_out(if_block0, 1, 1, () => {
202
+ if_block0 = null;
203
+ });
204
+
205
+ check_outros();
206
+ }
207
+
208
+ if (/*uploadedFiles*/ ctx[9].length > 0) {
209
+ if (if_block1) {
210
+ if_block1.p(ctx, dirty);
211
+
212
+ if (dirty & /*uploadedFiles*/ 512) {
213
+ transition_in(if_block1, 1);
214
+ }
215
+ } else {
216
+ if_block1 = create_if_block(ctx);
217
+ if_block1.c();
218
+ transition_in(if_block1, 1);
219
+ if_block1.m(div, null);
220
+ }
221
+ } else if (if_block1) {
222
+ group_outros();
223
+
224
+ transition_out(if_block1, 1, 1, () => {
225
+ if_block1 = null;
226
+ });
227
+
228
+ check_outros();
229
+ }
230
+ },
231
+ i(local) {
232
+ if (current) return;
233
+ transition_in(if_block0);
234
+ transition_in(if_block1);
235
+ current = true;
236
+ },
237
+ o(local) {
238
+ transition_out(if_block0);
239
+ transition_out(if_block1);
240
+ current = false;
241
+ },
242
+ d(detaching) {
243
+ if (detaching) detach(div);
244
+ if (if_block0) if_block0.d();
245
+ if (if_block1) if_block1.d();
246
+ /*div_binding*/ ctx[17](null);
247
+ mounted = false;
248
+ dispose();
249
+ }
250
+ };
251
+ }
252
+
253
+ function removeFromArray(fileList, value) {
254
+ const array = Array.from(fileList);
255
+ const idx = array.indexOf(value);
256
+
257
+ if (idx !== -1) {
258
+ array.splice(idx, 1);
259
+ }
260
+
261
+ return array;
262
+ }
263
+
264
+ function instance($$self, $$props, $$invalidate) {
265
+ let allowedExtensions;
266
+ let uploadedFiles;
267
+ let maxSize;
268
+ let { id } = $$props;
269
+ let { label } = $$props;
270
+ let { accept } = $$props;
271
+ let { multiple = true } = $$props;
272
+ let { allowedextensions } = $$props;
273
+ let { maxsize } = $$props;
274
+ let { displayfileslist = false } = $$props;
275
+ let { disabled = false } = $$props;
276
+ let { removelabel = 'Remove' } = $$props;
277
+ let { uploadedfiles } = $$props;
278
+ let files;
279
+ let root;
280
+ let eventHandler = new EventHandler();
281
+
282
+ function checkFileSize(fileSize) {
283
+ const fileSizeMB = fileSize / 1024 / 1024;
284
+
285
+ if (maxSize && fileSizeMB > maxSize) {
286
+ return false;
287
+ }
288
+
289
+ return true;
290
+ }
291
+
292
+ function checkFileExtension(fileName) {
293
+ if (allowedExtensions && allowedExtensions.length > 0) {
294
+ const extension = fileName.slice((fileName.lastIndexOf('.') - 1 >>> 0) + 2);
295
+
296
+ if (allowedExtensions && !allowedExtensions.includes(String(extension))) {
297
+ return false;
298
+ }
299
+ }
300
+
301
+ return true;
302
+ }
303
+
304
+ function handleChange(e) {
305
+ const target = e.target;
306
+ $$invalidate(7, files = target.files);
307
+ $$invalidate(0, displayfileslist = true);
308
+ const invalidFiles = [];
309
+ const fileList = [...files];
310
+
311
+ fileList.forEach((file, index) => {
312
+ const fileName = file.name;
313
+ const fileSize = file.size;
314
+ const validExtension = checkFileExtension(fileName);
315
+ const validSize = checkFileSize(fileSize);
316
+ let errorType = '';
317
+
318
+ if (!validExtension) {
319
+ errorType = 'invalid-extension';
320
+ }
321
+
322
+ if (!validSize) {
323
+ errorType = 'invalid-size';
324
+ }
325
+
326
+ if (!validExtension || !validSize) {
327
+ invalidFiles.push({ index, fileName, fileSize, errorType });
328
+ }
329
+ });
330
+
331
+ if (invalidFiles.length > 0) {
332
+ eventHandler.dispatch('invalid-files', invalidFiles);
333
+ }
334
+
335
+ eventHandler.dispatch('change', files);
336
+ }
337
+
338
+ function deleteFile(e) {
339
+ $$invalidate(7, files = [...uploadedFiles]);
340
+ $$invalidate(7, files = removeFromArray(files, e.detail));
341
+ const fileuploader = root.querySelector('.mc-fileuploader__input');
342
+ fileuploader.value = '';
343
+ $$invalidate(9, uploadedFiles = files);
344
+ eventHandler.dispatch('file-removed', e.detail);
345
+ }
346
+
347
+ function div_binding($$value) {
348
+ binding_callbacks[$$value ? 'unshift' : 'push'](() => {
349
+ root = $$value;
350
+ $$invalidate(8, root);
351
+ });
352
+ }
353
+
354
+ $$self.$$set = $$props => {
355
+ if ('id' in $$props) $$invalidate(1, id = $$props.id);
356
+ if ('label' in $$props) $$invalidate(2, label = $$props.label);
357
+ if ('accept' in $$props) $$invalidate(3, accept = $$props.accept);
358
+ if ('multiple' in $$props) $$invalidate(4, multiple = $$props.multiple);
359
+ if ('allowedextensions' in $$props) $$invalidate(14, allowedextensions = $$props.allowedextensions);
360
+ if ('maxsize' in $$props) $$invalidate(15, maxsize = $$props.maxsize);
361
+ if ('displayfileslist' in $$props) $$invalidate(0, displayfileslist = $$props.displayfileslist);
362
+ if ('disabled' in $$props) $$invalidate(5, disabled = $$props.disabled);
363
+ if ('removelabel' in $$props) $$invalidate(6, removelabel = $$props.removelabel);
364
+ if ('uploadedfiles' in $$props) $$invalidate(16, uploadedfiles = $$props.uploadedfiles);
365
+ };
366
+
367
+ $$self.$$.update = () => {
368
+ if ($$self.$$.dirty & /*allowedextensions*/ 16384) {
369
+ $$invalidate(10, allowedExtensions = allowedextensions ? JSON.parse(allowedextensions) : []);
370
+ }
371
+
372
+ if ($$self.$$.dirty & /*uploadedfiles*/ 65536) {
373
+ $$invalidate(9, uploadedFiles = uploadedfiles ? JSON.parse(uploadedfiles) : []);
374
+ }
375
+
376
+ if ($$self.$$.dirty & /*files*/ 128) ;
377
+
378
+ if ($$self.$$.dirty & /*maxsize*/ 32768) {
379
+ $$invalidate(11, maxSize = maxsize ? maxsize : undefined);
380
+ }
381
+ };
382
+
383
+ return [
384
+ displayfileslist,
385
+ id,
386
+ label,
387
+ accept,
388
+ multiple,
389
+ disabled,
390
+ removelabel,
391
+ files,
392
+ root,
393
+ uploadedFiles,
394
+ allowedExtensions,
395
+ maxSize,
396
+ handleChange,
397
+ deleteFile,
398
+ allowedextensions,
399
+ maxsize,
400
+ uploadedfiles,
401
+ div_binding
402
+ ];
403
+ }
404
+
405
+ class FileUploader extends SvelteElement {
406
+ constructor(options) {
407
+ super();
408
+ const style = document.createElement('style');
409
+ style.textContent = `.mc-fileuploader{position:relative;display:block}.mc-fileuploader__input{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0, 0, 0, 0);border:0;visibility:visible;white-space:nowrap}.mc-fileuploader__label{font-family:"LeroyMerlin", sans-serif;font-weight:600;cursor:pointer;border-radius:4px;text-align:center;border:2px solid transparent;-webkit-transition:all ease 200ms;-o-transition:all ease 200ms;transition:all ease 200ms;display:-webkit-inline-box;display:-ms-inline-flexbox;display:inline-flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center;vertical-align:middle;font-size:1rem;line-height:1.375;padding:0.6875rem 1.5rem;min-height:3rem;min-width:3rem;color:#188803;border-color:#188803;background-color:#ffffff;margin:0;-webkit-box-shadow:none;box-shadow:none;text-decoration:none;outline:none;-webkit-box-sizing:border-box;box-sizing:border-box}.mc-fileuploader__label:hover{background-color:#ebf5de;color:#006902}.mc-fileuploader__label:active{background-color:#c5e39e;color:#035010}.mc-fileuploader__label:active{background-color:#c5e39e;color:#035010}.mc-fileuploader__label:disabled{background-color:#cccccc;border-color:transparent;color:#666666;cursor:not-allowed}.mc-fileuploader__label::before{content:"";width:1.5rem;height:1.5rem;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;background:transparent url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMS41cmVtIiB3aWR0aD0iMS41cmVtIiBmaWxsPSIjMTg4ODAzIiB2aWV3Qm94PSIwIDAgMjQgMjQiPjx0aXRsZT5NZWRpYV9VcGxvYWRfMjRweDwvdGl0bGU+PHBhdGggZD0iTTguNzEsNy43MSwxMSw1LjQxVjE2YTEsMSwwLDAsMCwyLDBWNS40MWwyLjI5LDIuM2ExLDEsMCwwLDAsMS40MiwwLDEsMSwwLDAsMCwwLTEuNDJsLTQtNGExLDEsMCwwLDAtMS40MiwwbC00LDRBMSwxLDAsMSwwLDguNzEsNy43MVoiLz48cGF0aCBkPSJNMTYuMjIsMTIuNDRhMSwxLDAsMCwwLTEuMi43NywxLDEsMCwwLDAsLjc2LDEuMTlDMTguNTUsMTUsMjAsMTYuMTcsMjAsMTdjMCwxLjIyLTMuMTIsMy04LDNzLTgtMS43OC04LTNjMC0uODMsMS40NS0yLDQuMjItMi42QTEsMSwwLDAsMCw5LDEzLjIxYTEsMSwwLDAsMC0xLjItLjc3QzQuMTYsMTMuMjUsMiwxNSwyLDE3YzAsMi44NSw0LjMsNSwxMCw1czEwLTIuMTUsMTAtNUMyMiwxNSwxOS44NCwxMy4yNSwxNi4yMiwxMi40NFoiLz48L3N2Zz4=") no-repeat;background-size:1.5rem;margin-right:0.5rem;margin-left:-0.5rem}:focus+.mc-fileuploader__label{-webkit-box-shadow:0 0 0 0.125rem #ffffff, 0 0 0 0.25rem #0b96cc;box-shadow:0 0 0 0.125rem #ffffff, 0 0 0 0.25rem #0b96cc}:hover+.mc-fileuploader__label{color:#006902;background-color:#ebf5de}:disabled+.mc-fileuploader__label{color:#666666;background-color:#cccccc;border-color:transparent;cursor:not-allowed}:disabled+.mc-fileuploader__label::before{background:transparent url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMS41cmVtIiB3aWR0aD0iMS41cmVtIiBmaWxsPSIjNjY2NjY2IiB2aWV3Qm94PSIwIDAgMjQgMjQiPjx0aXRsZT5NZWRpYV9VcGxvYWRfMjRweDwvdGl0bGU+PHBhdGggZD0iTTguNzEsNy43MSwxMSw1LjQxVjE2YTEsMSwwLDAsMCwyLDBWNS40MWwyLjI5LDIuM2ExLDEsMCwwLDAsMS40MiwwLDEsMSwwLDAsMCwwLTEuNDJsLTQtNGExLDEsMCwwLDAtMS40MiwwbC00LDRBMSwxLDAsMSwwLDguNzEsNy43MVoiLz48cGF0aCBkPSJNMTYuMjIsMTIuNDRhMSwxLDAsMCwwLTEuMi43NywxLDEsMCwwLDAsLjc2LDEuMTlDMTguNTUsMTUsMjAsMTYuMTcsMjAsMTdjMCwxLjIyLTMuMTIsMy04LDNzLTgtMS43OC04LTNjMC0uODMsMS40NS0yLDQuMjItMi42QTEsMSwwLDAsMCw5LDEzLjIxYTEsMSwwLDAsMC0xLjItLjc3QzQuMTYsMTMuMjUsMiwxNSwyLDE3YzAsMi44NSw0LjMsNSwxMCw1czEwLTIuMTUsMTAtNUMyMiwxNSwxOS44NCwxMy4yNSwxNi4yMiwxMi40NFoiLz48L3N2Zz4=") no-repeat}`;
410
+ this.shadowRoot.appendChild(style);
411
+
412
+ init(
413
+ this,
414
+ {
415
+ target: this.shadowRoot,
416
+ props: attribute_to_object(this.attributes),
417
+ customElement: true
418
+ },
419
+ instance,
420
+ create_fragment,
421
+ safe_not_equal,
422
+ {
423
+ id: 1,
424
+ label: 2,
425
+ accept: 3,
426
+ multiple: 4,
427
+ allowedextensions: 14,
428
+ maxsize: 15,
429
+ displayfileslist: 0,
430
+ disabled: 5,
431
+ removelabel: 6,
432
+ uploadedfiles: 16
433
+ },
434
+ null
435
+ );
436
+
437
+ if (options) {
438
+ if (options.target) {
439
+ insert(options.target, this, options.anchor);
440
+ }
441
+
442
+ if (options.props) {
443
+ this.$set(options.props);
444
+ flush();
445
+ }
446
+ }
447
+ }
448
+
449
+ static get observedAttributes() {
450
+ return [
451
+ "id",
452
+ "label",
453
+ "accept",
454
+ "multiple",
455
+ "allowedextensions",
456
+ "maxsize",
457
+ "displayfileslist",
458
+ "disabled",
459
+ "removelabel",
460
+ "uploadedfiles"
461
+ ];
462
+ }
463
+
464
+ get id() {
465
+ return this.$$.ctx[1];
466
+ }
467
+
468
+ set id(id) {
469
+ this.$$set({ id });
470
+ flush();
471
+ }
472
+
473
+ get label() {
474
+ return this.$$.ctx[2];
475
+ }
476
+
477
+ set label(label) {
478
+ this.$$set({ label });
479
+ flush();
480
+ }
481
+
482
+ get accept() {
483
+ return this.$$.ctx[3];
484
+ }
485
+
486
+ set accept(accept) {
487
+ this.$$set({ accept });
488
+ flush();
489
+ }
490
+
491
+ get multiple() {
492
+ return this.$$.ctx[4];
493
+ }
494
+
495
+ set multiple(multiple) {
496
+ this.$$set({ multiple });
497
+ flush();
498
+ }
499
+
500
+ get allowedextensions() {
501
+ return this.$$.ctx[14];
502
+ }
503
+
504
+ set allowedextensions(allowedextensions) {
505
+ this.$$set({ allowedextensions });
506
+ flush();
507
+ }
508
+
509
+ get maxsize() {
510
+ return this.$$.ctx[15];
511
+ }
512
+
513
+ set maxsize(maxsize) {
514
+ this.$$set({ maxsize });
515
+ flush();
516
+ }
517
+
518
+ get displayfileslist() {
519
+ return this.$$.ctx[0];
520
+ }
521
+
522
+ set displayfileslist(displayfileslist) {
523
+ this.$$set({ displayfileslist });
524
+ flush();
525
+ }
526
+
527
+ get disabled() {
528
+ return this.$$.ctx[5];
529
+ }
530
+
531
+ set disabled(disabled) {
532
+ this.$$set({ disabled });
533
+ flush();
534
+ }
535
+
536
+ get removelabel() {
537
+ return this.$$.ctx[6];
538
+ }
539
+
540
+ set removelabel(removelabel) {
541
+ this.$$set({ removelabel });
542
+ flush();
543
+ }
544
+
545
+ get uploadedfiles() {
546
+ return this.$$.ctx[16];
547
+ }
548
+
549
+ set uploadedfiles(uploadedfiles) {
550
+ this.$$set({ uploadedfiles });
551
+ flush();
552
+ }
553
+ }
554
+
555
+ export { FileUploader as default };
2
556
  //# sourceMappingURL=FileUploader.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FileUploader.js","sources":["../../../src/components/fileuploader/FileUploader.svelte"],"sourcesContent":["<svelte:options tag={null} />\n\n<script lang=\"ts\">\n // @ts-nocheck\n import { EventHandler } from '../../utilities/EventHandler';\n import ResultFile from './ResultFile.nested.svelte';\n\n export let id: string;\n export let label: string;\n export let accept: string;\n export let multiple = true;\n export let allowedextensions: string;\n export let maxsize: number;\n export let displayfileslist = false;\n export let disabled = false;\n export let removelabel = 'Remove';\n export let uploadedfiles: string;\n\n let files: FileList;\n let root: HTMLElement;\n let eventHandler = new EventHandler();\n\n $: allowedExtensions = allowedextensions ? JSON.parse(allowedextensions) : [];\n $: uploadedFiles = uploadedfiles ? JSON.parse(uploadedfiles) : [];\n $: files;\n $: maxSize = maxsize ? maxsize : undefined;\n\n function checkFileSize(fileSize: number): boolean {\n const fileSizeMB = fileSize / 1024 / 1024; // in MB\n if (maxSize && fileSizeMB > maxSize) {\n return false; // invalid\n }\n\n return true; // valid\n }\n function checkFileExtension(fileName: string): boolean {\n if (allowedExtensions && allowedExtensions.length > 0) {\n const extension: string = fileName.slice(\n ((fileName.lastIndexOf('.') - 1) >>> 0) + 2,\n );\n if (allowedExtensions && !allowedExtensions.includes(String(extension))) {\n return false; // invalid\n }\n }\n\n return true; // valid\n }\n\n function checkFileStatus(file: File): boolean {\n const validExtension = allowedExtensions\n ? checkFileExtension(file.name)\n : true;\n const validSize = checkFileSize(file.size);\n\n if (!validExtension || !validSize) {\n return false; // invalid\n }\n\n return true; // valid\n }\n function handleChange(e: Event): void {\n const target = e.target as HTMLInputElement;\n files = target.files as FileList;\n displayfileslist = true;\n const invalidFiles: Array = [];\n const fileList = [...files];\n fileList.forEach((file, index) => {\n const fileName = file.name;\n const fileSize = file.size;\n const validExtension = checkFileExtension(fileName);\n const validSize = checkFileSize(fileSize);\n let errorType = '';\n\n if (!validExtension) {\n errorType = 'invalid-extension';\n }\n\n if (!validSize) {\n errorType = 'invalid-size';\n }\n\n if (!validExtension || !validSize) {\n invalidFiles.push({\n index: index,\n fileName: fileName,\n fileSize: fileSize,\n errorType: errorType,\n });\n }\n });\n\n if (invalidFiles.length > 0) {\n eventHandler.dispatch('invalid-files', invalidFiles);\n }\n eventHandler.dispatch('change', files);\n }\n\n function removeFromArray(fileList: FileList, value: File): FileList {\n const array = Array.from(fileList);\n const idx = array.indexOf(value);\n if (idx !== -1) {\n array.splice(idx, 1);\n }\n return array as FileList;\n }\n\n function deleteFile(e: CustomEvent): void {\n files = [...uploadedFiles];\n files = removeFromArray(files, e.detail);\n const fileuploader = root.querySelector(\n '.mc-fileuploader__input',\n ) as HTMLInputElement;\n fileuploader.value = '';\n uploadedFiles = files;\n eventHandler.dispatch('file-removed', e.detail);\n }\n\n function hasInvalidFiles(e: CustomEvent): void {\n eventHandler.dispatch('invalid-files', e.detail);\n }\n</script>\n\n<div class=\"mc-fileuploader\" bind:this={root}>\n <input\n {id}\n type=\"file\"\n class=\"mc-fileuploader__input\"\n {accept}\n {multiple}\n {disabled}\n on:change={handleChange}\n />\n <label for={id} class=\"mc-fileuploader__label\">\n <span class=\"mc-fileuploader__label--center\">\n {label}\n </span>\n </label>\n {#if displayfileslist && files.length > 0}\n <ResultFile\n {files}\n {allowedExtensions}\n {disabled}\n {maxSize}\n {removelabel}\n on:file-removed={deleteFile}\n />\n {/if}\n {#if uploadedFiles.length > 0}\n <ResultFile\n files={uploadedFiles}\n {allowedExtensions}\n {disabled}\n {maxSize}\n {removelabel}\n on:file-removed={deleteFile}\n />\n {/if}\n</div>\n\n<style lang=\"scss\">\n @import '@mozaic-ds/styles/settings-tools/all-settings';\n @import '@mozaic-ds/styles/components/c.file-uploader';\n</style>\n"],"names":["ctx","if_block0","length","create_if_block_1","create_if_block","insert","target","div","anchor","append","input","label_1","span","files","root","id","$$props","label","accept","multiple","allowedextensions","maxsize","displayfileslist","disabled","removelabel","uploadedfiles","eventHandler","EventHandler","$$invalidate","allowedExtensions","JSON","parse","uploadedFiles","maxSize","undefined","e","invalidFiles","forEach","file","index","fileName","name","fileSize","size","validExtension","extension","slice","lastIndexOf","includes","String","checkFileExtension","validSize","checkFileSize","errorType","push","dispatch","fileList","value","array","Array","from","idx","indexOf","splice","removeFromArray","detail","querySelector","$$value"],"mappings":"+aAgJuBA,EAAU,wVAKpBA,EAAa,gGAKHA,EAAU,oFALpBA,EAAa,uPAZnBC,EAAAD,EAAoB,IAAAA,EAAM,GAAAE,OAAS,GAACC,EAAAH,KAUpCA,EAAa,GAACE,OAAS,GAACE,EAAAJ,yEAbxBA,EAAK,8NAFEA,EAAE,iFAVhBK,EAmCKC,EAAAC,EAAAC,GAlCHC,EAQCF,EAAAG,UACDD,EAIOF,EAAAI,GAHLF,EAEME,EAAAC,uFALKZ,EAAY,wJAIpBA,EAAK,yBAFEA,EAAE,IAKTA,EAAoB,IAAAA,EAAM,GAAAE,OAAS,iGAUnCF,EAAa,GAACE,OAAS,sOAjIxBW,EACAC,MAZOC,GAAUC,SACVC,GAAaD,UACbE,GAAcF,GACdG,SAAAA,GAAW,GAAIH,qBACfI,GAAyBJ,WACzBK,GAAeL,GACfM,iBAAAA,GAAmB,GAAKN,GACxBO,SAAAA,GAAW,GAAKP,GAChBQ,YAAAA,EAAc,UAAQR,iBACtBS,GAAqBT,EAI5B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uploader/FileUploader.svelte"],"sourcesContent":["<svelte:options tag={null} />\n\n<script lang=\"ts\">\n // @ts-nocheck\n import { EventHandler } from '../../utilities/EventHandler';\n import ResultFile from './ResultFile.nested.svelte';\n\n export let id: string;\n export let label: string;\n export let accept: string;\n export let multiple = true;\n export let allowedextensions: string;\n export let maxsize: number;\n export let displayfileslist = false;\n export let disabled = false;\n export let removelabel = 'Remove';\n export let uploadedfiles: string;\n\n let files: FileList;\n let root: HTMLElement;\n let eventHandler = new EventHandler();\n\n $: allowedExtensions = allowedextensions ? JSON.parse(allowedextensions) : [];\n $: uploadedFiles = uploadedfiles ? JSON.parse(uploadedfiles) : [];\n $: files;\n $: maxSize = maxsize ? maxsize : undefined;\n\n function checkFileSize(fileSize: number): boolean {\n const fileSizeMB = fileSize / 1024 / 1024; // in MB\n if (maxSize && fileSizeMB > maxSize) {\n return false; // invalid\n }\n\n return true; // valid\n }\n function checkFileExtension(fileName: string): boolean {\n if (allowedExtensions && allowedExtensions.length > 0) {\n const extension: string = fileName.slice(\n ((fileName.lastIndexOf('.') - 1) >>> 0) + 2,\n );\n if (allowedExtensions && !allowedExtensions.includes(String(extension))) {\n return false; // invalid\n }\n }\n\n return true; // valid\n }\n\n function checkFileStatus(file: File): boolean {\n const validExtension = allowedExtensions\n ? checkFileExtension(file.name)\n : true;\n const validSize = checkFileSize(file.size);\n\n if (!validExtension || !validSize) {\n return false; // invalid\n }\n\n return true; // valid\n }\n function handleChange(e: Event): void {\n const target = e.target as HTMLInputElement;\n files = target.files as FileList;\n displayfileslist = true;\n const invalidFiles: Array = [];\n const fileList = [...files];\n fileList.forEach((file, index) => {\n const fileName = file.name;\n const fileSize = file.size;\n const validExtension = checkFileExtension(fileName);\n const validSize = checkFileSize(fileSize);\n let errorType = '';\n\n if (!validExtension) {\n errorType = 'invalid-extension';\n }\n\n if (!validSize) {\n errorType = 'invalid-size';\n }\n\n if (!validExtension || !validSize) {\n invalidFiles.push({\n index: index,\n fileName: fileName,\n fileSize: fileSize,\n errorType: errorType,\n });\n }\n });\n\n if (invalidFiles.length > 0) {\n eventHandler.dispatch('invalid-files', invalidFiles);\n }\n eventHandler.dispatch('change', files);\n }\n\n function removeFromArray(fileList: FileList, value: File): FileList {\n const array = Array.from(fileList);\n const idx = array.indexOf(value);\n if (idx !== -1) {\n array.splice(idx, 1);\n }\n return array as FileList;\n }\n\n function deleteFile(e: CustomEvent): void {\n files = [...uploadedFiles];\n files = removeFromArray(files, e.detail);\n const fileuploader = root.querySelector(\n '.mc-fileuploader__input',\n ) as HTMLInputElement;\n fileuploader.value = '';\n uploadedFiles = files;\n eventHandler.dispatch('file-removed', e.detail);\n }\n\n function hasInvalidFiles(e: CustomEvent): void {\n eventHandler.dispatch('invalid-files', e.detail);\n }\n</script>\n\n<div class=\"mc-fileuploader\" bind:this={root}>\n <input\n {id}\n type=\"file\"\n class=\"mc-fileuploader__input\"\n {accept}\n {multiple}\n {disabled}\n on:change={handleChange}\n />\n <label for={id} class=\"mc-fileuploader__label\">\n <span class=\"mc-fileuploader__label--center\">\n {label}\n </span>\n </label>\n {#if displayfileslist && files.length > 0}\n <ResultFile\n {files}\n {allowedExtensions}\n {disabled}\n {maxSize}\n {removelabel}\n on:file-removed={deleteFile}\n />\n {/if}\n {#if uploadedFiles.length > 0}\n <ResultFile\n files={uploadedFiles}\n {allowedExtensions}\n {disabled}\n {maxSize}\n {removelabel}\n on:file-removed={deleteFile}\n />\n {/if}\n</div>\n\n<style lang=\"scss\">\n @import '@mozaic-ds/styles/settings-tools/all-settings';\n @import '@mozaic-ds/styles/components/c.file-uploader';\n</style>\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;+CAgJuB,GAAU,CAAA,EAAA,CAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAKpB,GAAa,CAAA,CAAA,CAAA;;;;;;;;+CAKH,GAAU,CAAA,EAAA,CAAA,CAAA,CAAA;;;;;;;;;;;;mFALpB,GAAa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