@salla.sa/twilight-components 2.11.2 → 2.11.4
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.
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/salla-button_37.cjs.entry.js +856 -346
- package/dist/cjs/salla-installment.cjs.entry.js +2 -2
- package/dist/cjs/twilight.cjs.js +1 -1
- package/dist/collection/components/salla-datetime-picker/salla-datetime-picker.js +48 -20
- package/dist/collection/components/salla-file-upload/salla-file-upload.js +278 -678
- package/dist/collection/components/salla-gifting/salla-gifting.js +24 -43
- package/dist/collection/components/salla-installment/salla-installment.js +2 -2
- package/dist/collection/components/salla-login-modal/salla-login-modal.js +21 -39
- package/dist/collection/components/salla-product-options/salla-product-options.js +27 -42
- package/dist/collection/components/salla-user-menu/salla-user-menu.js +1 -0
- package/dist/components/salla-datetime-picker2.js +8 -12
- package/dist/components/salla-file-upload2.js +783 -214
- package/dist/components/salla-gifting.js +22 -41
- package/dist/components/salla-installment.js +2 -2
- package/dist/components/salla-login-modal.js +21 -39
- package/dist/components/salla-product-options.js +26 -41
- package/dist/components/salla-user-menu.js +1 -0
- package/dist/esm/loader.js +1 -1
- package/dist/esm/salla-button_37.entry.js +856 -346
- package/dist/esm/salla-installment.entry.js +2 -2
- package/dist/esm/twilight.js +1 -1
- package/dist/esm-es5/loader.js +1 -1
- package/dist/esm-es5/salla-button_37.entry.js +11 -5
- package/dist/esm-es5/salla-installment.entry.js +1 -1
- package/dist/esm-es5/twilight.js +1 -1
- package/dist/twilight/p-0a16e246.system.js +1 -1
- package/dist/twilight/p-2e7701fe.entry.js +36 -0
- package/dist/twilight/{p-5ca2cbe3.system.entry.js → p-3db06115.system.entry.js} +11 -5
- package/dist/twilight/{p-82931e46.entry.js → p-7e9e675f.entry.js} +1 -1
- package/dist/twilight/{p-21aa165d.system.entry.js → p-a6821ab8.system.entry.js} +1 -1
- package/dist/twilight/twilight.esm.js +1 -1
- package/dist/types/components/salla-datetime-picker/salla-datetime-picker.d.ts +9 -3
- package/dist/types/components/salla-file-upload/salla-file-upload.d.ts +52 -104
- package/dist/types/components/salla-gifting/salla-gifting.d.ts +13 -13
- package/dist/types/components/salla-product-options/interfaces.d.ts +1 -0
- package/dist/types/components/salla-product-options/salla-product-options.d.ts +3 -4
- package/dist/types/components.d.ts +81 -217
- package/package.json +5 -4
- package/dist/twilight/p-cfe3a7ef.entry.js +0 -30
|
@@ -14477,6 +14477,632 @@ var filepondPluginFileValidateType = createCommonjsModule(function (module, expo
|
|
|
14477
14477
|
});
|
|
14478
14478
|
});
|
|
14479
14479
|
|
|
14480
|
+
var filepondPluginFilePoster = createCommonjsModule(function (module, exports) {
|
|
14481
|
+
/*!
|
|
14482
|
+
* FilePondPluginFilePoster 2.5.1
|
|
14483
|
+
* Licensed under MIT, https://opensource.org/licenses/MIT/
|
|
14484
|
+
* Please visit https://pqina.nl/filepond/ for details.
|
|
14485
|
+
*/
|
|
14486
|
+
|
|
14487
|
+
/* eslint-disable */
|
|
14488
|
+
|
|
14489
|
+
(function(global, factory) {
|
|
14490
|
+
(module.exports = factory())
|
|
14491
|
+
;
|
|
14492
|
+
})(commonjsGlobal, function() {
|
|
14493
|
+
|
|
14494
|
+
var IMAGE_SCALE_SPRING_PROPS = {
|
|
14495
|
+
type: 'spring',
|
|
14496
|
+
stiffness: 0.5,
|
|
14497
|
+
damping: 0.45,
|
|
14498
|
+
mass: 10
|
|
14499
|
+
};
|
|
14500
|
+
|
|
14501
|
+
var createPosterView = function createPosterView(_) {
|
|
14502
|
+
return _.utils.createView({
|
|
14503
|
+
name: 'file-poster',
|
|
14504
|
+
tag: 'div',
|
|
14505
|
+
ignoreRect: true,
|
|
14506
|
+
create: function create(_ref) {
|
|
14507
|
+
var root = _ref.root;
|
|
14508
|
+
root.ref.image = document.createElement('img');
|
|
14509
|
+
root.element.appendChild(root.ref.image);
|
|
14510
|
+
},
|
|
14511
|
+
write: _.utils.createRoute({
|
|
14512
|
+
DID_FILE_POSTER_LOAD: function DID_FILE_POSTER_LOAD(_ref2) {
|
|
14513
|
+
var root = _ref2.root,
|
|
14514
|
+
props = _ref2.props;
|
|
14515
|
+
var id = props.id;
|
|
14516
|
+
|
|
14517
|
+
// get item
|
|
14518
|
+
var item = root.query('GET_ITEM', { id: props.id });
|
|
14519
|
+
if (!item) return;
|
|
14520
|
+
|
|
14521
|
+
// get poster
|
|
14522
|
+
var poster = item.getMetadata('poster');
|
|
14523
|
+
root.ref.image.src = poster;
|
|
14524
|
+
|
|
14525
|
+
// let others know of our fabulous achievement (so the image can be faded in)
|
|
14526
|
+
root.dispatch('DID_FILE_POSTER_DRAW', { id: id });
|
|
14527
|
+
}
|
|
14528
|
+
}),
|
|
14529
|
+
|
|
14530
|
+
mixins: {
|
|
14531
|
+
styles: ['scaleX', 'scaleY', 'opacity'],
|
|
14532
|
+
animations: {
|
|
14533
|
+
scaleX: IMAGE_SCALE_SPRING_PROPS,
|
|
14534
|
+
scaleY: IMAGE_SCALE_SPRING_PROPS,
|
|
14535
|
+
opacity: { type: 'tween', duration: 750 }
|
|
14536
|
+
}
|
|
14537
|
+
}
|
|
14538
|
+
});
|
|
14539
|
+
};
|
|
14540
|
+
|
|
14541
|
+
var applyTemplate = function applyTemplate(source, target) {
|
|
14542
|
+
// copy width and height
|
|
14543
|
+
target.width = source.width;
|
|
14544
|
+
target.height = source.height;
|
|
14545
|
+
|
|
14546
|
+
// draw the template
|
|
14547
|
+
var ctx = target.getContext('2d');
|
|
14548
|
+
ctx.drawImage(source, 0, 0);
|
|
14549
|
+
};
|
|
14550
|
+
|
|
14551
|
+
var createPosterOverlayView = function createPosterOverlayView(fpAPI) {
|
|
14552
|
+
return fpAPI.utils.createView({
|
|
14553
|
+
name: 'file-poster-overlay',
|
|
14554
|
+
tag: 'canvas',
|
|
14555
|
+
ignoreRect: true,
|
|
14556
|
+
create: function create(_ref) {
|
|
14557
|
+
var root = _ref.root,
|
|
14558
|
+
props = _ref.props;
|
|
14559
|
+
applyTemplate(props.template, root.element);
|
|
14560
|
+
},
|
|
14561
|
+
mixins: {
|
|
14562
|
+
styles: ['opacity'],
|
|
14563
|
+
animations: {
|
|
14564
|
+
opacity: { type: 'spring', mass: 25 }
|
|
14565
|
+
}
|
|
14566
|
+
}
|
|
14567
|
+
});
|
|
14568
|
+
};
|
|
14569
|
+
|
|
14570
|
+
var getImageSize = function getImageSize(url, cb) {
|
|
14571
|
+
var image = new Image();
|
|
14572
|
+
image.onload = function() {
|
|
14573
|
+
var width = image.naturalWidth;
|
|
14574
|
+
var height = image.naturalHeight;
|
|
14575
|
+
image = null;
|
|
14576
|
+
cb(width, height);
|
|
14577
|
+
};
|
|
14578
|
+
image.src = url;
|
|
14579
|
+
};
|
|
14580
|
+
|
|
14581
|
+
var easeInOutSine = function easeInOutSine(t) {
|
|
14582
|
+
return -0.5 * (Math.cos(Math.PI * t) - 1);
|
|
14583
|
+
};
|
|
14584
|
+
|
|
14585
|
+
var addGradientSteps = function addGradientSteps(gradient, color) {
|
|
14586
|
+
var alpha =
|
|
14587
|
+
arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
14588
|
+
var easeFn =
|
|
14589
|
+
arguments.length > 3 && arguments[3] !== undefined
|
|
14590
|
+
? arguments[3]
|
|
14591
|
+
: easeInOutSine;
|
|
14592
|
+
var steps =
|
|
14593
|
+
arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 10;
|
|
14594
|
+
var offset =
|
|
14595
|
+
arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 0;
|
|
14596
|
+
var range = 1 - offset;
|
|
14597
|
+
var rgb = color.join(',');
|
|
14598
|
+
for (var i = 0; i <= steps; i++) {
|
|
14599
|
+
var p = i / steps;
|
|
14600
|
+
var stop = offset + range * p;
|
|
14601
|
+
gradient.addColorStop(
|
|
14602
|
+
stop,
|
|
14603
|
+
'rgba('.concat(rgb, ', ').concat(easeFn(p) * alpha, ')')
|
|
14604
|
+
);
|
|
14605
|
+
}
|
|
14606
|
+
};
|
|
14607
|
+
|
|
14608
|
+
var MAX_WIDTH = 10;
|
|
14609
|
+
var MAX_HEIGHT = 10;
|
|
14610
|
+
|
|
14611
|
+
var calculateAverageColor = function calculateAverageColor(image) {
|
|
14612
|
+
var scalar = Math.min(MAX_WIDTH / image.width, MAX_HEIGHT / image.height);
|
|
14613
|
+
|
|
14614
|
+
var canvas = document.createElement('canvas');
|
|
14615
|
+
var ctx = canvas.getContext('2d');
|
|
14616
|
+
var width = (canvas.width = Math.ceil(image.width * scalar));
|
|
14617
|
+
var height = (canvas.height = Math.ceil(image.height * scalar));
|
|
14618
|
+
ctx.drawImage(image, 0, 0, width, height);
|
|
14619
|
+
var data = null;
|
|
14620
|
+
try {
|
|
14621
|
+
data = ctx.getImageData(0, 0, width, height).data;
|
|
14622
|
+
} catch (e) {
|
|
14623
|
+
return null;
|
|
14624
|
+
}
|
|
14625
|
+
var l = data.length;
|
|
14626
|
+
|
|
14627
|
+
var r = 0;
|
|
14628
|
+
var g = 0;
|
|
14629
|
+
var b = 0;
|
|
14630
|
+
var i = 0;
|
|
14631
|
+
|
|
14632
|
+
for (; i < l; i += 4) {
|
|
14633
|
+
r += data[i] * data[i];
|
|
14634
|
+
g += data[i + 1] * data[i + 1];
|
|
14635
|
+
b += data[i + 2] * data[i + 2];
|
|
14636
|
+
}
|
|
14637
|
+
|
|
14638
|
+
r = averageColor(r, l);
|
|
14639
|
+
g = averageColor(g, l);
|
|
14640
|
+
b = averageColor(b, l);
|
|
14641
|
+
|
|
14642
|
+
return { r: r, g: g, b: b };
|
|
14643
|
+
};
|
|
14644
|
+
|
|
14645
|
+
var averageColor = function averageColor(c, l) {
|
|
14646
|
+
return Math.floor(Math.sqrt(c / (l / 4)));
|
|
14647
|
+
};
|
|
14648
|
+
|
|
14649
|
+
var drawTemplate = function drawTemplate(
|
|
14650
|
+
canvas,
|
|
14651
|
+
width,
|
|
14652
|
+
height,
|
|
14653
|
+
color,
|
|
14654
|
+
alphaTarget
|
|
14655
|
+
) {
|
|
14656
|
+
canvas.width = width;
|
|
14657
|
+
canvas.height = height;
|
|
14658
|
+
var ctx = canvas.getContext('2d');
|
|
14659
|
+
|
|
14660
|
+
var horizontalCenter = width * 0.5;
|
|
14661
|
+
|
|
14662
|
+
var grad = ctx.createRadialGradient(
|
|
14663
|
+
horizontalCenter,
|
|
14664
|
+
height + 110,
|
|
14665
|
+
height - 100,
|
|
14666
|
+
horizontalCenter,
|
|
14667
|
+
height + 110,
|
|
14668
|
+
height + 100
|
|
14669
|
+
);
|
|
14670
|
+
|
|
14671
|
+
addGradientSteps(grad, color, alphaTarget, undefined, 8, 0.4);
|
|
14672
|
+
|
|
14673
|
+
ctx.save();
|
|
14674
|
+
ctx.translate(-width * 0.5, 0);
|
|
14675
|
+
ctx.scale(2, 1);
|
|
14676
|
+
ctx.fillStyle = grad;
|
|
14677
|
+
ctx.fillRect(0, 0, width, height);
|
|
14678
|
+
ctx.restore();
|
|
14679
|
+
};
|
|
14680
|
+
|
|
14681
|
+
var hasNavigator = typeof navigator !== 'undefined';
|
|
14682
|
+
|
|
14683
|
+
var width = 500;
|
|
14684
|
+
var height = 200;
|
|
14685
|
+
|
|
14686
|
+
var overlayTemplateShadow = hasNavigator && document.createElement('canvas');
|
|
14687
|
+
var overlayTemplateError = hasNavigator && document.createElement('canvas');
|
|
14688
|
+
var overlayTemplateSuccess = hasNavigator && document.createElement('canvas');
|
|
14689
|
+
|
|
14690
|
+
var itemShadowColor = [40, 40, 40];
|
|
14691
|
+
var itemErrorColor = [196, 78, 71];
|
|
14692
|
+
var itemSuccessColor = [54, 151, 99];
|
|
14693
|
+
|
|
14694
|
+
if (hasNavigator) {
|
|
14695
|
+
drawTemplate(overlayTemplateShadow, width, height, itemShadowColor, 0.85);
|
|
14696
|
+
drawTemplate(overlayTemplateError, width, height, itemErrorColor, 1);
|
|
14697
|
+
drawTemplate(overlayTemplateSuccess, width, height, itemSuccessColor, 1);
|
|
14698
|
+
}
|
|
14699
|
+
|
|
14700
|
+
var loadImage = function loadImage(url, crossOriginValue) {
|
|
14701
|
+
return new Promise(function(resolve, reject) {
|
|
14702
|
+
var img = new Image();
|
|
14703
|
+
if (typeof crossOrigin === 'string') {
|
|
14704
|
+
img.crossOrigin = crossOriginValue;
|
|
14705
|
+
}
|
|
14706
|
+
img.onload = function() {
|
|
14707
|
+
resolve(img);
|
|
14708
|
+
};
|
|
14709
|
+
img.onerror = function(e) {
|
|
14710
|
+
reject(e);
|
|
14711
|
+
};
|
|
14712
|
+
img.src = url;
|
|
14713
|
+
});
|
|
14714
|
+
};
|
|
14715
|
+
|
|
14716
|
+
var createPosterWrapperView = function createPosterWrapperView(_) {
|
|
14717
|
+
// create overlay view
|
|
14718
|
+
var overlay = createPosterOverlayView(_);
|
|
14719
|
+
|
|
14720
|
+
/**
|
|
14721
|
+
* Write handler for when preview container has been created
|
|
14722
|
+
*/
|
|
14723
|
+
var didCreatePreviewContainer = function didCreatePreviewContainer(_ref) {
|
|
14724
|
+
var root = _ref.root,
|
|
14725
|
+
props = _ref.props;
|
|
14726
|
+
var id = props.id;
|
|
14727
|
+
|
|
14728
|
+
// we need to get the file data to determine the eventual image size
|
|
14729
|
+
var item = root.query('GET_ITEM', id);
|
|
14730
|
+
if (!item) return;
|
|
14731
|
+
|
|
14732
|
+
// get url to file
|
|
14733
|
+
var fileURL = item.getMetadata('poster');
|
|
14734
|
+
|
|
14735
|
+
// image is now ready
|
|
14736
|
+
var previewImageLoaded = function previewImageLoaded(data) {
|
|
14737
|
+
// calculate average image color, is in try catch to circumvent any cors errors
|
|
14738
|
+
var averageColor = root.query(
|
|
14739
|
+
'GET_FILE_POSTER_CALCULATE_AVERAGE_IMAGE_COLOR'
|
|
14740
|
+
)
|
|
14741
|
+
? calculateAverageColor(data)
|
|
14742
|
+
: null;
|
|
14743
|
+
item.setMetadata('color', averageColor, true);
|
|
14744
|
+
|
|
14745
|
+
// the preview is now ready to be drawn
|
|
14746
|
+
root.dispatch('DID_FILE_POSTER_LOAD', {
|
|
14747
|
+
id: id,
|
|
14748
|
+
data: data
|
|
14749
|
+
});
|
|
14750
|
+
};
|
|
14751
|
+
|
|
14752
|
+
// determine image size of this item
|
|
14753
|
+
getImageSize(fileURL, function(width, height) {
|
|
14754
|
+
// we can now scale the panel to the final size
|
|
14755
|
+
root.dispatch('DID_FILE_POSTER_CALCULATE_SIZE', {
|
|
14756
|
+
id: id,
|
|
14757
|
+
width: width,
|
|
14758
|
+
height: height
|
|
14759
|
+
});
|
|
14760
|
+
|
|
14761
|
+
// create fallback preview
|
|
14762
|
+
loadImage(
|
|
14763
|
+
fileURL,
|
|
14764
|
+
root.query('GET_FILE_POSTER_CROSS_ORIGIN_ATTRIBUTE_VALUE')
|
|
14765
|
+
).then(previewImageLoaded);
|
|
14766
|
+
});
|
|
14767
|
+
};
|
|
14768
|
+
|
|
14769
|
+
/**
|
|
14770
|
+
* Write handler for when the preview has been loaded
|
|
14771
|
+
*/
|
|
14772
|
+
var didLoadPreview = function didLoadPreview(_ref2) {
|
|
14773
|
+
var root = _ref2.root;
|
|
14774
|
+
root.ref.overlayShadow.opacity = 1;
|
|
14775
|
+
};
|
|
14776
|
+
|
|
14777
|
+
/**
|
|
14778
|
+
* Write handler for when the preview image is ready to be animated
|
|
14779
|
+
*/
|
|
14780
|
+
var didDrawPreview = function didDrawPreview(_ref3) {
|
|
14781
|
+
var root = _ref3.root;
|
|
14782
|
+
var image = root.ref.image;
|
|
14783
|
+
|
|
14784
|
+
// reveal image
|
|
14785
|
+
image.scaleX = 1.0;
|
|
14786
|
+
image.scaleY = 1.0;
|
|
14787
|
+
image.opacity = 1;
|
|
14788
|
+
};
|
|
14789
|
+
|
|
14790
|
+
/**
|
|
14791
|
+
* Write handler for when the preview has been loaded
|
|
14792
|
+
*/
|
|
14793
|
+
var restoreOverlay = function restoreOverlay(_ref4) {
|
|
14794
|
+
var root = _ref4.root;
|
|
14795
|
+
root.ref.overlayShadow.opacity = 1;
|
|
14796
|
+
root.ref.overlayError.opacity = 0;
|
|
14797
|
+
root.ref.overlaySuccess.opacity = 0;
|
|
14798
|
+
};
|
|
14799
|
+
|
|
14800
|
+
var didThrowError = function didThrowError(_ref5) {
|
|
14801
|
+
var root = _ref5.root;
|
|
14802
|
+
root.ref.overlayShadow.opacity = 0.25;
|
|
14803
|
+
root.ref.overlayError.opacity = 1;
|
|
14804
|
+
};
|
|
14805
|
+
|
|
14806
|
+
var didCompleteProcessing = function didCompleteProcessing(_ref6) {
|
|
14807
|
+
var root = _ref6.root;
|
|
14808
|
+
root.ref.overlayShadow.opacity = 0.25;
|
|
14809
|
+
root.ref.overlaySuccess.opacity = 1;
|
|
14810
|
+
};
|
|
14811
|
+
|
|
14812
|
+
/**
|
|
14813
|
+
* Constructor
|
|
14814
|
+
*/
|
|
14815
|
+
var create = function create(_ref7) {
|
|
14816
|
+
var root = _ref7.root,
|
|
14817
|
+
props = _ref7.props;
|
|
14818
|
+
// test if colors aren't default item overlay colors
|
|
14819
|
+
var itemShadowColorProp = root.query(
|
|
14820
|
+
'GET_FILE_POSTER_ITEM_OVERLAY_SHADOW_COLOR'
|
|
14821
|
+
);
|
|
14822
|
+
|
|
14823
|
+
var itemErrorColorProp = root.query(
|
|
14824
|
+
'GET_FILE_POSTER_ITEM_OVERLAY_ERROR_COLOR'
|
|
14825
|
+
);
|
|
14826
|
+
|
|
14827
|
+
var itemSuccessColorProp = root.query(
|
|
14828
|
+
'GET_FILE_POSTER_ITEM_OVERLAY_SUCCESS_COLOR'
|
|
14829
|
+
);
|
|
14830
|
+
|
|
14831
|
+
if (itemShadowColorProp && itemShadowColorProp !== itemShadowColor) {
|
|
14832
|
+
itemShadowColor = itemShadowColorProp;
|
|
14833
|
+
drawTemplate(
|
|
14834
|
+
overlayTemplateShadow,
|
|
14835
|
+
width,
|
|
14836
|
+
height,
|
|
14837
|
+
itemShadowColor,
|
|
14838
|
+
0.85
|
|
14839
|
+
);
|
|
14840
|
+
}
|
|
14841
|
+
if (itemErrorColorProp && itemErrorColorProp !== itemErrorColor) {
|
|
14842
|
+
itemErrorColor = itemErrorColorProp;
|
|
14843
|
+
drawTemplate(overlayTemplateError, width, height, itemErrorColor, 1);
|
|
14844
|
+
}
|
|
14845
|
+
if (itemSuccessColorProp && itemSuccessColorProp !== itemSuccessColor) {
|
|
14846
|
+
itemSuccessColor = itemSuccessColorProp;
|
|
14847
|
+
drawTemplate(
|
|
14848
|
+
overlayTemplateSuccess,
|
|
14849
|
+
width,
|
|
14850
|
+
height,
|
|
14851
|
+
itemSuccessColor,
|
|
14852
|
+
1
|
|
14853
|
+
);
|
|
14854
|
+
}
|
|
14855
|
+
|
|
14856
|
+
// image view
|
|
14857
|
+
var image = createPosterView(_);
|
|
14858
|
+
|
|
14859
|
+
// append image presenter
|
|
14860
|
+
root.ref.image = root.appendChildView(
|
|
14861
|
+
root.createChildView(image, {
|
|
14862
|
+
id: props.id,
|
|
14863
|
+
scaleX: 1.25,
|
|
14864
|
+
scaleY: 1.25,
|
|
14865
|
+
opacity: 0
|
|
14866
|
+
})
|
|
14867
|
+
);
|
|
14868
|
+
|
|
14869
|
+
// image overlays
|
|
14870
|
+
root.ref.overlayShadow = root.appendChildView(
|
|
14871
|
+
root.createChildView(overlay, {
|
|
14872
|
+
template: overlayTemplateShadow,
|
|
14873
|
+
opacity: 0
|
|
14874
|
+
})
|
|
14875
|
+
);
|
|
14876
|
+
|
|
14877
|
+
root.ref.overlaySuccess = root.appendChildView(
|
|
14878
|
+
root.createChildView(overlay, {
|
|
14879
|
+
template: overlayTemplateSuccess,
|
|
14880
|
+
opacity: 0
|
|
14881
|
+
})
|
|
14882
|
+
);
|
|
14883
|
+
|
|
14884
|
+
root.ref.overlayError = root.appendChildView(
|
|
14885
|
+
root.createChildView(overlay, {
|
|
14886
|
+
template: overlayTemplateError,
|
|
14887
|
+
opacity: 0
|
|
14888
|
+
})
|
|
14889
|
+
);
|
|
14890
|
+
};
|
|
14891
|
+
|
|
14892
|
+
return _.utils.createView({
|
|
14893
|
+
name: 'file-poster-wrapper',
|
|
14894
|
+
create: create,
|
|
14895
|
+
write: _.utils.createRoute({
|
|
14896
|
+
// image preview stated
|
|
14897
|
+
DID_FILE_POSTER_LOAD: didLoadPreview,
|
|
14898
|
+
DID_FILE_POSTER_DRAW: didDrawPreview,
|
|
14899
|
+
DID_FILE_POSTER_CONTAINER_CREATE: didCreatePreviewContainer,
|
|
14900
|
+
|
|
14901
|
+
// file states
|
|
14902
|
+
DID_THROW_ITEM_LOAD_ERROR: didThrowError,
|
|
14903
|
+
DID_THROW_ITEM_PROCESSING_ERROR: didThrowError,
|
|
14904
|
+
DID_THROW_ITEM_INVALID: didThrowError,
|
|
14905
|
+
DID_COMPLETE_ITEM_PROCESSING: didCompleteProcessing,
|
|
14906
|
+
DID_START_ITEM_PROCESSING: restoreOverlay,
|
|
14907
|
+
DID_REVERT_ITEM_PROCESSING: restoreOverlay
|
|
14908
|
+
})
|
|
14909
|
+
});
|
|
14910
|
+
};
|
|
14911
|
+
|
|
14912
|
+
/**
|
|
14913
|
+
* File Poster Plugin
|
|
14914
|
+
*/
|
|
14915
|
+
var plugin = function plugin(fpAPI) {
|
|
14916
|
+
var addFilter = fpAPI.addFilter,
|
|
14917
|
+
utils = fpAPI.utils;
|
|
14918
|
+
var Type = utils.Type,
|
|
14919
|
+
createRoute = utils.createRoute;
|
|
14920
|
+
|
|
14921
|
+
// filePosterView
|
|
14922
|
+
var filePosterView = createPosterWrapperView(fpAPI);
|
|
14923
|
+
|
|
14924
|
+
// called for each view that is created right after the 'create' method
|
|
14925
|
+
addFilter('CREATE_VIEW', function(viewAPI) {
|
|
14926
|
+
// get reference to created view
|
|
14927
|
+
var is = viewAPI.is,
|
|
14928
|
+
view = viewAPI.view,
|
|
14929
|
+
query = viewAPI.query;
|
|
14930
|
+
|
|
14931
|
+
// only hook up to item view and only if is enabled for this cropper
|
|
14932
|
+
if (!is('file') || !query('GET_ALLOW_FILE_POSTER')) return;
|
|
14933
|
+
|
|
14934
|
+
// create the file poster plugin, but only do so if the item is an image
|
|
14935
|
+
var didLoadItem = function didLoadItem(_ref) {
|
|
14936
|
+
var root = _ref.root,
|
|
14937
|
+
props = _ref.props;
|
|
14938
|
+
updateItemPoster(root, props);
|
|
14939
|
+
};
|
|
14940
|
+
|
|
14941
|
+
var didUpdateItemMetadata = function didUpdateItemMetadata(_ref2) {
|
|
14942
|
+
var root = _ref2.root,
|
|
14943
|
+
props = _ref2.props,
|
|
14944
|
+
action = _ref2.action;
|
|
14945
|
+
if (!/poster/.test(action.change.key)) return;
|
|
14946
|
+
updateItemPoster(root, props);
|
|
14947
|
+
};
|
|
14948
|
+
|
|
14949
|
+
var updateItemPoster = function updateItemPoster(root, props) {
|
|
14950
|
+
var id = props.id;
|
|
14951
|
+
var item = query('GET_ITEM', id);
|
|
14952
|
+
|
|
14953
|
+
// item could theoretically have been removed in the mean time
|
|
14954
|
+
if (!item || !item.getMetadata('poster') || item.archived) return;
|
|
14955
|
+
|
|
14956
|
+
// don't update if is the same poster
|
|
14957
|
+
if (root.ref.previousPoster === item.getMetadata('poster')) return;
|
|
14958
|
+
root.ref.previousPoster = item.getMetadata('poster');
|
|
14959
|
+
|
|
14960
|
+
// test if is filtered
|
|
14961
|
+
if (!query('GET_FILE_POSTER_FILTER_ITEM')(item)) return;
|
|
14962
|
+
|
|
14963
|
+
if (root.ref.filePoster) {
|
|
14964
|
+
view.removeChildView(root.ref.filePoster);
|
|
14965
|
+
}
|
|
14966
|
+
|
|
14967
|
+
// set preview view
|
|
14968
|
+
root.ref.filePoster = view.appendChildView(
|
|
14969
|
+
view.createChildView(filePosterView, { id: id })
|
|
14970
|
+
);
|
|
14971
|
+
|
|
14972
|
+
// now ready
|
|
14973
|
+
root.dispatch('DID_FILE_POSTER_CONTAINER_CREATE', { id: id });
|
|
14974
|
+
};
|
|
14975
|
+
|
|
14976
|
+
var didCalculatePreviewSize = function didCalculatePreviewSize(_ref3) {
|
|
14977
|
+
var root = _ref3.root,
|
|
14978
|
+
action = _ref3.action;
|
|
14979
|
+
// no poster set
|
|
14980
|
+
if (!root.ref.filePoster) return;
|
|
14981
|
+
|
|
14982
|
+
// remember dimensions
|
|
14983
|
+
root.ref.imageWidth = action.width;
|
|
14984
|
+
root.ref.imageHeight = action.height;
|
|
14985
|
+
|
|
14986
|
+
root.ref.shouldUpdatePanelHeight = true;
|
|
14987
|
+
|
|
14988
|
+
root.dispatch('KICK');
|
|
14989
|
+
};
|
|
14990
|
+
|
|
14991
|
+
var getPosterHeight = function getPosterHeight(_ref4) {
|
|
14992
|
+
var root = _ref4.root;
|
|
14993
|
+
var fixedPosterHeight = root.query('GET_FILE_POSTER_HEIGHT');
|
|
14994
|
+
|
|
14995
|
+
// if fixed height: return fixed immediately
|
|
14996
|
+
if (fixedPosterHeight) {
|
|
14997
|
+
return fixedPosterHeight;
|
|
14998
|
+
}
|
|
14999
|
+
|
|
15000
|
+
var minPosterHeight = root.query('GET_FILE_POSTER_MIN_HEIGHT');
|
|
15001
|
+
var maxPosterHeight = root.query('GET_FILE_POSTER_MAX_HEIGHT');
|
|
15002
|
+
|
|
15003
|
+
// if natural height is smaller than minHeight: return min height
|
|
15004
|
+
if (minPosterHeight && root.ref.imageHeight < minPosterHeight) {
|
|
15005
|
+
return minPosterHeight;
|
|
15006
|
+
}
|
|
15007
|
+
|
|
15008
|
+
var height =
|
|
15009
|
+
root.rect.element.width *
|
|
15010
|
+
(root.ref.imageHeight / root.ref.imageWidth);
|
|
15011
|
+
|
|
15012
|
+
if (minPosterHeight && height < minPosterHeight) {
|
|
15013
|
+
return minPosterHeight;
|
|
15014
|
+
}
|
|
15015
|
+
if (maxPosterHeight && height > maxPosterHeight) {
|
|
15016
|
+
return maxPosterHeight;
|
|
15017
|
+
}
|
|
15018
|
+
|
|
15019
|
+
return height;
|
|
15020
|
+
};
|
|
15021
|
+
|
|
15022
|
+
// start writing
|
|
15023
|
+
view.registerWriter(
|
|
15024
|
+
createRoute(
|
|
15025
|
+
{
|
|
15026
|
+
DID_LOAD_ITEM: didLoadItem,
|
|
15027
|
+
DID_FILE_POSTER_CALCULATE_SIZE: didCalculatePreviewSize,
|
|
15028
|
+
DID_UPDATE_ITEM_METADATA: didUpdateItemMetadata
|
|
15029
|
+
},
|
|
15030
|
+
|
|
15031
|
+
function(_ref5) {
|
|
15032
|
+
var root = _ref5.root,
|
|
15033
|
+
props = _ref5.props;
|
|
15034
|
+
// don't run without poster
|
|
15035
|
+
if (!root.ref.filePoster) return;
|
|
15036
|
+
|
|
15037
|
+
// don't do anything while hidden
|
|
15038
|
+
if (root.rect.element.hidden) return;
|
|
15039
|
+
|
|
15040
|
+
// should we redraw
|
|
15041
|
+
if (root.ref.shouldUpdatePanelHeight) {
|
|
15042
|
+
// time to resize the parent panel
|
|
15043
|
+
root.dispatch('DID_UPDATE_PANEL_HEIGHT', {
|
|
15044
|
+
id: props.id,
|
|
15045
|
+
height: getPosterHeight({ root: root })
|
|
15046
|
+
});
|
|
15047
|
+
|
|
15048
|
+
// done!
|
|
15049
|
+
root.ref.shouldUpdatePanelHeight = false;
|
|
15050
|
+
}
|
|
15051
|
+
}
|
|
15052
|
+
)
|
|
15053
|
+
);
|
|
15054
|
+
});
|
|
15055
|
+
|
|
15056
|
+
// expose plugin
|
|
15057
|
+
return {
|
|
15058
|
+
options: {
|
|
15059
|
+
// Enable or disable file poster
|
|
15060
|
+
allowFilePoster: [true, Type.BOOLEAN],
|
|
15061
|
+
|
|
15062
|
+
// Fixed preview height
|
|
15063
|
+
filePosterHeight: [null, Type.INT],
|
|
15064
|
+
|
|
15065
|
+
// Min image height
|
|
15066
|
+
filePosterMinHeight: [null, Type.INT],
|
|
15067
|
+
|
|
15068
|
+
// Max image height
|
|
15069
|
+
filePosterMaxHeight: [null, Type.INT],
|
|
15070
|
+
|
|
15071
|
+
// filters file items to determine which are shown as poster
|
|
15072
|
+
filePosterFilterItem: [
|
|
15073
|
+
function() {
|
|
15074
|
+
return true;
|
|
15075
|
+
},
|
|
15076
|
+
Type.FUNCTION
|
|
15077
|
+
],
|
|
15078
|
+
|
|
15079
|
+
// Enables or disables reading average image color
|
|
15080
|
+
filePosterCalculateAverageImageColor: [false, Type.BOOLEAN],
|
|
15081
|
+
|
|
15082
|
+
// Allows setting the value of the CORS attribute (null is don't set attribute)
|
|
15083
|
+
filePosterCrossOriginAttributeValue: ['Anonymous', Type.STRING],
|
|
15084
|
+
|
|
15085
|
+
// Colors used for item overlay gradient
|
|
15086
|
+
filePosterItemOverlayShadowColor: [null, Type.ARRAY],
|
|
15087
|
+
filePosterItemOverlayErrorColor: [null, Type.ARRAY],
|
|
15088
|
+
filePosterItemOverlaySuccessColor: [null, Type.ARRAY]
|
|
15089
|
+
}
|
|
15090
|
+
};
|
|
15091
|
+
};
|
|
15092
|
+
|
|
15093
|
+
// fire pluginloaded event if running in browser, this allows registering the plugin when using async script tags
|
|
15094
|
+
var isBrowser =
|
|
15095
|
+
typeof window !== 'undefined' && typeof window.document !== 'undefined';
|
|
15096
|
+
if (isBrowser) {
|
|
15097
|
+
document.dispatchEvent(
|
|
15098
|
+
new CustomEvent('FilePond:pluginloaded', { detail: plugin })
|
|
15099
|
+
);
|
|
15100
|
+
}
|
|
15101
|
+
|
|
15102
|
+
return plugin;
|
|
15103
|
+
});
|
|
15104
|
+
});
|
|
15105
|
+
|
|
14480
15106
|
const sallaFileUploadCss = "/*!\n * FilePond 4.30.4\n * Licensed under MIT, https://opensource.org/licenses/MIT/\n * Please visit https://pqina.nl/filepond/ for details.\n */.filepond--assistant{position:absolute;overflow:hidden;height:1px;width:1px;padding:0;border:0;clip:rect(1px,1px,1px,1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);white-space:nowrap}.filepond--browser.filepond--browser{position:absolute;margin:0;padding:0;left:1em;top:1.75em;width:calc(100% - 2em);opacity:0;font-size:0}.filepond--data{position:absolute;width:0;height:0;padding:0;margin:0;border:none;visibility:hidden;pointer-events:none;contain:strict}.filepond--drip{position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;opacity:.1;pointer-events:none;border-radius:.5em;background:rgba(0,0,0,.01)}.filepond--drip-blob{-webkit-transform-origin:center center;transform-origin:center center;width:8em;height:8em;margin-left:-4em;margin-top:-4em;background:#292625;border-radius:50%}.filepond--drip-blob,.filepond--drop-label{position:absolute;top:0;left:0;will-change:transform,opacity}.filepond--drop-label{right:0;margin:0;color:#4f4f4f;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;height:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.filepond--drop-label.filepond--drop-label label{display:block;margin:0;padding:.5em}.filepond--drop-label label{cursor:default;font-size:.875em;font-weight:400;text-align:center;line-height:1.5}.filepond--label-action{text-decoration:underline;-webkit-text-decoration-skip:ink;text-decoration-skip-ink:auto;-webkit-text-decoration-color:#a7a4a4;text-decoration-color:#a7a4a4;cursor:pointer}.filepond--root[data-disabled] .filepond--drop-label label{opacity:.5}.filepond--file-action-button.filepond--file-action-button{font-size:1em;width:1.625em;height:1.625em;font-family:inherit;line-height:inherit;margin:0;padding:0;border:none;outline:none;will-change:transform,opacity}.filepond--file-action-button.filepond--file-action-button span{position:absolute;overflow:hidden;height:1px;width:1px;padding:0;border:0;clip:rect(1px,1px,1px,1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);white-space:nowrap}.filepond--file-action-button.filepond--file-action-button svg{width:100%;height:100%}.filepond--file-action-button.filepond--file-action-button:after{position:absolute;left:-.75em;right:-.75em;top:-.75em;bottom:-.75em;content:\"\"}.filepond--file-action-button{cursor:auto;color:#fff;border-radius:50%;background-color:rgba(0,0,0,.5);background-image:none;-webkit-box-shadow:0 0 0 0 hsla(0,0%,100%,0);box-shadow:0 0 0 0 hsla(0,0%,100%,0);-webkit-transition:-webkit-box-shadow .25s ease-in;transition:-webkit-box-shadow .25s ease-in;transition:box-shadow .25s ease-in;transition:box-shadow .25s ease-in, -webkit-box-shadow .25s ease-in}.filepond--file-action-button:focus,.filepond--file-action-button:hover{-webkit-box-shadow:0 0 0 .125em hsla(0,0%,100%,.9);box-shadow:0 0 0 .125em hsla(0,0%,100%,.9)}.filepond--file-action-button[disabled]{color:hsla(0,0%,100%,.5);background-color:rgba(0,0,0,.25)}.filepond--file-action-button[hidden]{display:none}.filepond--action-edit-item.filepond--action-edit-item{width:2em;height:2em;padding:.1875em}.filepond--action-edit-item.filepond--action-edit-item[data-align*=center]{margin-left:-.1875em}.filepond--action-edit-item.filepond--action-edit-item[data-align*=bottom]{margin-bottom:-.1875em}.filepond--action-edit-item-alt{border:none;line-height:inherit;background:transparent;font-family:inherit;color:inherit;outline:none;padding:0;margin:0 0 0 .25em;pointer-events:all;position:absolute}.filepond--action-edit-item-alt svg{width:1.3125em;height:1.3125em}.filepond--action-edit-item-alt span{font-size:0;opacity:0}.filepond--file-info{position:static;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:start;align-items:flex-start;-ms-flex:1;flex:1;margin:0 .5em 0 0;min-width:0;will-change:transform,opacity;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.filepond--file-info *{margin:0}.filepond--file-info .filepond--file-info-main{font-size:.75em;line-height:1.2;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;width:100%}.filepond--file-info .filepond--file-info-sub{font-size:.625em;opacity:.5;-webkit-transition:opacity .25s ease-in-out;transition:opacity .25s ease-in-out;white-space:nowrap}.filepond--file-info .filepond--file-info-sub:empty{display:none}.filepond--file-status{position:static;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;-ms-flex-align:end;align-items:flex-end;-ms-flex-positive:0;flex-grow:0;-ms-flex-negative:0;flex-shrink:0;margin:0;min-width:2.25em;text-align:right;will-change:transform,opacity;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.filepond--file-status *{margin:0;white-space:nowrap}.filepond--file-status .filepond--file-status-main{font-size:.75em;line-height:1.2}.filepond--file-status .filepond--file-status-sub{font-size:.625em;opacity:.5;-webkit-transition:opacity .25s ease-in-out;transition:opacity .25s ease-in-out}.filepond--file-wrapper.filepond--file-wrapper{border:none;margin:0;padding:0;min-width:0;height:100%}.filepond--file-wrapper.filepond--file-wrapper>legend{position:absolute;overflow:hidden;height:1px;width:1px;padding:0;border:0;clip:rect(1px,1px,1px,1px);-webkit-clip-path:inset(50%);clip-path:inset(50%);white-space:nowrap}.filepond--file{position:static;display:-ms-flexbox;display:flex;height:100%;-ms-flex-align:start;align-items:flex-start;padding:.5625em;color:#fff;border-radius:.5em}.filepond--file .filepond--file-status{margin-left:auto;margin-right:2.25em}.filepond--file .filepond--processing-complete-indicator{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;z-index:3}.filepond--file .filepond--file-action-button,.filepond--file .filepond--processing-complete-indicator,.filepond--file .filepond--progress-indicator{position:absolute}.filepond--file [data-align*=left]{left:.5625em}.filepond--file [data-align*=right]{right:.5625em}.filepond--file [data-align*=center]{left:calc(50% - .8125em)}.filepond--file [data-align*=bottom]{bottom:1.125em}.filepond--file [data-align=center]{top:calc(50% - .8125em)}.filepond--file .filepond--progress-indicator{margin-top:.1875em}.filepond--file .filepond--progress-indicator[data-align*=right]{margin-right:.1875em}.filepond--file .filepond--progress-indicator[data-align*=left]{margin-left:.1875em}[data-filepond-item-state*=error] .filepond--file-info,[data-filepond-item-state*=invalid] .filepond--file-info,[data-filepond-item-state=cancelled] .filepond--file-info{margin-right:2.25em}[data-filepond-item-state~=processing] .filepond--file-status-sub{opacity:0}[data-filepond-item-state~=processing] .filepond--action-abort-item-processing~.filepond--file-status .filepond--file-status-sub{opacity:.5}[data-filepond-item-state=processing-error] .filepond--file-status-sub{opacity:0}[data-filepond-item-state=processing-error] .filepond--action-retry-item-processing~.filepond--file-status .filepond--file-status-sub{opacity:.5}[data-filepond-item-state=processing-complete] .filepond--action-revert-item-processing svg{-webkit-animation:fall .5s linear .125s both;animation:fall .5s linear .125s both}[data-filepond-item-state=processing-complete] .filepond--file-status-sub{opacity:.5}[data-filepond-item-state=processing-complete] .filepond--file-info-sub,[data-filepond-item-state=processing-complete] .filepond--processing-complete-indicator:not([style*=hidden])~.filepond--file-status .filepond--file-status-sub{opacity:0}[data-filepond-item-state=processing-complete] .filepond--action-revert-item-processing~.filepond--file-info .filepond--file-info-sub{opacity:.5}[data-filepond-item-state*=error] .filepond--file-wrapper,[data-filepond-item-state*=error] .filepond--panel,[data-filepond-item-state*=invalid] .filepond--file-wrapper,[data-filepond-item-state*=invalid] .filepond--panel{-webkit-animation:shake .65s linear both;animation:shake .65s linear both}[data-filepond-item-state*=busy] .filepond--progress-indicator svg{-webkit-animation:spin 1s linear infinite;animation:spin 1s linear infinite}@-webkit-keyframes spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@keyframes spin{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}@-webkit-keyframes shake{10%,90%{-webkit-transform:translateX(-.0625em);transform:translateX(-.0625em)}20%,80%{-webkit-transform:translateX(.125em);transform:translateX(.125em)}30%,50%,70%{-webkit-transform:translateX(-.25em);transform:translateX(-.25em)}40%,60%{-webkit-transform:translateX(.25em);transform:translateX(.25em)}}@keyframes shake{10%,90%{-webkit-transform:translateX(-.0625em);transform:translateX(-.0625em)}20%,80%{-webkit-transform:translateX(.125em);transform:translateX(.125em)}30%,50%,70%{-webkit-transform:translateX(-.25em);transform:translateX(-.25em)}40%,60%{-webkit-transform:translateX(.25em);transform:translateX(.25em)}}@-webkit-keyframes fall{0%{opacity:0;-webkit-transform:scale(.5);transform:scale(.5);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}70%{opacity:1;-webkit-transform:scale(1.1);transform:scale(1.1);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}to{-webkit-transform:scale(1);transform:scale(1);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}@keyframes fall{0%{opacity:0;-webkit-transform:scale(.5);transform:scale(.5);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}70%{opacity:1;-webkit-transform:scale(1.1);transform:scale(1.1);-webkit-animation-timing-function:ease-in-out;animation-timing-function:ease-in-out}to{-webkit-transform:scale(1);transform:scale(1);-webkit-animation-timing-function:ease-out;animation-timing-function:ease-out}}.filepond--hopper[data-hopper-state=drag-over]>*{pointer-events:none}.filepond--hopper[data-hopper-state=drag-over]:after{content:\"\";position:absolute;left:0;top:0;right:0;bottom:0;z-index:100}.filepond--progress-indicator{z-index:103}.filepond--file-action-button{z-index:102}.filepond--file-status{z-index:101}.filepond--file-info{z-index:100}.filepond--item{position:absolute;top:0;left:0;right:0;z-index:1;padding:0;margin:.25em;will-change:transform,opacity}.filepond--item>.filepond--panel{z-index:-1}.filepond--item>.filepond--panel .filepond--panel-bottom{-webkit-box-shadow:0 .0625em .125em -.0625em rgba(0,0,0,.25);box-shadow:0 .0625em .125em -.0625em rgba(0,0,0,.25)}.filepond--item>.filepond--file-wrapper,.filepond--item>.filepond--panel{-webkit-transition:opacity .15s ease-out;transition:opacity .15s ease-out}.filepond--item[data-drag-state]{cursor:-webkit-grab;cursor:grab}.filepond--item[data-drag-state]>.filepond--panel{-webkit-transition:-webkit-box-shadow .125s ease-in-out;transition:-webkit-box-shadow .125s ease-in-out;transition:box-shadow .125s ease-in-out;transition:box-shadow .125s ease-in-out, -webkit-box-shadow .125s ease-in-out;-webkit-box-shadow:0 0 0 transparent;box-shadow:0 0 0 transparent}.filepond--item[data-drag-state=drag]{cursor:-webkit-grabbing;cursor:grabbing}.filepond--item[data-drag-state=drag]>.filepond--panel{-webkit-box-shadow:0 .125em .3125em rgba(0,0,0,.325);box-shadow:0 .125em .3125em rgba(0,0,0,.325)}.filepond--item[data-drag-state]:not([data-drag-state=idle]){z-index:2}.filepond--item-panel{background-color:#64605e}[data-filepond-item-state=processing-complete] .filepond--item-panel{background-color:#369763}[data-filepond-item-state*=error] .filepond--item-panel,[data-filepond-item-state*=invalid] .filepond--item-panel{background-color:#c44e47}.filepond--item-panel{border-radius:.5em;-webkit-transition:background-color .25s;transition:background-color .25s}.filepond--list-scroller{position:absolute;top:0;left:0;right:0;margin:0;will-change:transform}.filepond--list-scroller[data-state=overflow] .filepond--list{bottom:0;right:0}.filepond--list-scroller[data-state=overflow]{overflow-y:scroll;overflow-x:hidden;-webkit-overflow-scrolling:touch;-webkit-mask:-webkit-gradient(linear,left top, left bottom,from(#000),to(transparent));-webkit-mask:linear-gradient(180deg,#000 calc(100% - .5em),transparent);mask:-webkit-gradient(linear,left top, left bottom,from(#000),to(transparent));mask:linear-gradient(180deg,#000 calc(100% - .5em),transparent)}.filepond--list-scroller::-webkit-scrollbar{background:transparent}.filepond--list-scroller::-webkit-scrollbar:vertical{width:1em}.filepond--list-scroller::-webkit-scrollbar:horizontal{height:0}.filepond--list-scroller::-webkit-scrollbar-thumb{background-color:rgba(0,0,0,.3);border-radius:99999px;border:.3125em solid transparent;background-clip:content-box}.filepond--list.filepond--list{position:absolute;top:0;margin:0;padding:0;list-style-type:none;will-change:transform}.filepond--list{left:.75em;right:.75em}.filepond--root[data-style-panel-layout~=integrated]{width:100%;height:100%;max-width:none;margin:0}.filepond--root[data-style-panel-layout~=circle] .filepond--panel-root,.filepond--root[data-style-panel-layout~=integrated] .filepond--panel-root{border-radius:0}.filepond--root[data-style-panel-layout~=circle] .filepond--panel-root>*,.filepond--root[data-style-panel-layout~=integrated] .filepond--panel-root>*{display:none}.filepond--root[data-style-panel-layout~=circle] .filepond--drop-label,.filepond--root[data-style-panel-layout~=integrated] .filepond--drop-label{bottom:0;height:auto;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center;z-index:7}.filepond--root[data-style-panel-layout~=circle] .filepond--item-panel,.filepond--root[data-style-panel-layout~=integrated] .filepond--item-panel{display:none}.filepond--root[data-style-panel-layout~=compact] .filepond--list-scroller,.filepond--root[data-style-panel-layout~=integrated] .filepond--list-scroller{overflow:hidden;height:100%;margin-top:0;margin-bottom:0}.filepond--root[data-style-panel-layout~=compact] .filepond--list,.filepond--root[data-style-panel-layout~=integrated] .filepond--list{left:0;right:0;height:100%}.filepond--root[data-style-panel-layout~=compact] .filepond--item,.filepond--root[data-style-panel-layout~=integrated] .filepond--item{margin:0}.filepond--root[data-style-panel-layout~=compact] .filepond--file-wrapper,.filepond--root[data-style-panel-layout~=integrated] .filepond--file-wrapper{height:100%}.filepond--root[data-style-panel-layout~=compact] .filepond--drop-label,.filepond--root[data-style-panel-layout~=integrated] .filepond--drop-label{z-index:7}.filepond--root[data-style-panel-layout~=circle]{border-radius:99999rem;overflow:hidden}.filepond--root[data-style-panel-layout~=circle]>.filepond--panel{border-radius:inherit}.filepond--root[data-style-panel-layout~=circle]>.filepond--panel>*{display:none}.filepond--root[data-style-panel-layout~=circle] .filepond--file-info,.filepond--root[data-style-panel-layout~=circle] .filepond--file-status{display:none}.filepond--root[data-style-panel-layout~=circle] .filepond--action-edit-item{opacity:1!important;visibility:visible!important}@media not all and (-webkit-min-device-pixel-ratio:0), not all and (min-resolution:0.001dpcm){@supports (-webkit-appearance:none) and (stroke-color:transparent){.filepond--root[data-style-panel-layout~=circle]{will-change:transform}}}.filepond--panel-root{border-radius:.5em;background-color:#f1f0ef}.filepond--panel{position:absolute;left:0;top:0;right:0;margin:0;height:100%!important;pointer-events:none}.filepond-panel:not([data-scalable=false]){height:auto!important}.filepond--panel[data-scalable=false]>div{display:none}.filepond--panel[data-scalable=true]{-webkit-transform-style:preserve-3d;transform-style:preserve-3d;background-color:transparent!important;border:none!important}.filepond--panel-bottom,.filepond--panel-center,.filepond--panel-top{position:absolute;left:0;top:0;right:0;margin:0;padding:0}.filepond--panel-bottom,.filepond--panel-top{height:.5em}.filepond--panel-top{border-bottom-left-radius:0!important;border-bottom-right-radius:0!important;border-bottom:none!important}.filepond--panel-top:after{content:\"\";position:absolute;height:2px;left:0;right:0;bottom:-1px;background-color:inherit}.filepond--panel-bottom,.filepond--panel-center{will-change:transform;-webkit-backface-visibility:hidden;backface-visibility:hidden;-webkit-transform-origin:left top;transform-origin:left top;-webkit-transform:translate3d(0,.5em,0);transform:translate3d(0,.5em,0)}.filepond--panel-bottom{border-top-left-radius:0!important;border-top-right-radius:0!important;border-top:none!important}.filepond--panel-bottom:before{content:\"\";position:absolute;height:2px;left:0;right:0;top:-1px;background-color:inherit}.filepond--panel-center{height:100px!important;border-top:none!important;border-bottom:none!important;border-radius:0!important}.filepond--panel-center:not([style]){visibility:hidden}.filepond--progress-indicator{position:static;width:1.25em;height:1.25em;color:#fff;margin:0;pointer-events:none;will-change:transform,opacity}.filepond--progress-indicator svg{width:100%;height:100%;vertical-align:top;transform-box:fill-box}.filepond--progress-indicator path{fill:none;stroke:currentColor}.filepond--list-scroller{z-index:6}.filepond--drop-label{z-index:5}.filepond--drip{z-index:3}.filepond--root>.filepond--panel{z-index:2}.filepond--browser{z-index:1}.filepond--root{-webkit-box-sizing:border-box;box-sizing:border-box;position:relative;margin-bottom:1em;font-size:1rem;line-height:normal;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol;font-weight:450;text-align:left;text-rendering:optimizeLegibility;direction:ltr;contain:layout style size}.filepond--root *{-webkit-box-sizing:inherit;box-sizing:inherit;line-height:inherit}.filepond--root :not(text){font-size:inherit}.filepond--root[data-disabled]{pointer-events:none}.filepond--root[data-disabled] .filepond--list-scroller{pointer-events:all}.filepond--root[data-disabled] .filepond--list{pointer-events:none}.filepond--root .filepond--drop-label{min-height:4.75em}.filepond--root .filepond--list-scroller{margin-top:1em;margin-bottom:1em}.filepond--root .filepond--credits{position:absolute;right:0;opacity:.175;line-height:.85;font-size:11px;color:inherit;text-decoration:none;z-index:3;bottom:-14px}.filepond--root .filepond--credits[style]{top:0;bottom:auto;margin-top:14px}/*!\n * FilePondPluginImagePreview 4.6.11\n * Licensed under MIT, https://opensource.org/licenses/MIT/\n * Please visit https://pqina.nl/filepond/ for details.\n */.filepond--image-preview-markup{position:absolute;left:0;top:0}.filepond--image-preview-wrapper{z-index:2}.filepond--image-preview-overlay{display:block;position:absolute;left:0;top:0;width:100%;min-height:5rem;max-height:7rem;margin:0;opacity:0;z-index:2;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.filepond--image-preview-overlay svg{width:100%;height:auto;color:inherit;max-height:inherit}.filepond--image-preview-overlay-idle{mix-blend-mode:multiply;color:rgba(40, 40, 40, 0.85)}.filepond--image-preview-overlay-success{mix-blend-mode:normal;color:rgba(54, 151, 99, 1)}.filepond--image-preview-overlay-failure{mix-blend-mode:normal;color:rgba(196, 78, 71, 1)}@supports (-webkit-marquee-repetition: infinite) and\n ((-o-object-fit: fill) or (object-fit: fill)){.filepond--image-preview-overlay-idle{mix-blend-mode:normal}}.filepond--image-preview-wrapper{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;position:absolute;left:0;top:0;right:0;height:100%;margin:0;border-radius:0.45em;overflow:hidden;background:rgba(0, 0, 0, 0.01)}.filepond--image-preview{position:absolute;left:0;top:0;z-index:1;display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;height:100%;width:100%;pointer-events:none;background:#222;will-change:transform, opacity}.filepond--image-clip{position:relative;overflow:hidden;margin:0 auto;}.filepond--image-clip[data-transparency-indicator='grid'] img,.filepond--image-clip[data-transparency-indicator='grid'] canvas{background-color:#fff;background-image:url(\"data:image/svg+xml,%3Csvg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg' fill='%23eee'%3E%3Cpath d='M0 0 H50 V50 H0'/%3E%3Cpath d='M50 50 H100 V100 H50'/%3E%3C/svg%3E\");background-size:1.25em 1.25em}.filepond--image-bitmap,.filepond--image-vector{position:absolute;left:0;top:0;will-change:transform}.filepond--root[data-style-panel-layout~='integrated'] .filepond--image-preview-wrapper{border-radius:0}.filepond--root[data-style-panel-layout~='integrated'] .filepond--image-preview{height:100%;display:-ms-flexbox;display:flex;-ms-flex-pack:center;justify-content:center;-ms-flex-align:center;align-items:center}.filepond--root[data-style-panel-layout~='circle'] .filepond--image-preview-wrapper{border-radius:99999rem}.filepond--root[data-style-panel-layout~='circle'] .filepond--image-preview-overlay{top:auto;bottom:0;-webkit-transform:scaleY(-1);transform:scaleY(-1)}.filepond--root[data-style-panel-layout~='circle'] .filepond--file .filepond--file-action-button[data-align*='bottom']:not([data-align*='center']){margin-bottom:0.325em}.filepond--root[data-style-panel-layout~='circle'] .filepond--file [data-align*='left']{left:calc(50% - 3em)}.filepond--root[data-style-panel-layout~='circle'] .filepond--file [data-align*='right']{right:calc(50% - 3em)}.filepond--root[data-style-panel-layout~='circle'] .filepond--progress-indicator[data-align*='bottom'][data-align*='left'],.filepond--root[data-style-panel-layout~='circle'] .filepond--progress-indicator[data-align*='bottom'][data-align*='right']{margin-bottom:calc(0.325em + 0.1875em)}.filepond--root[data-style-panel-layout~='circle'] .filepond--progress-indicator[data-align*='bottom'][data-align*='center']{margin-top:0;margin-bottom:0.1875em;margin-left:0.1875em}/*!\n * FilePondPluginImageEdit 1.6.3\n * Licensed under MIT, https://opensource.org/licenses/MIT/\n * Please visit https://pqina.nl/filepond/ for details.\n */.filepond--action-edit-item.filepond--action-edit-item{width:2em;height:2em;padding:0.1875em}.filepond--action-edit-item.filepond--action-edit-item[data-align*='center']{margin-left:-0.1875em}.filepond--action-edit-item.filepond--action-edit-item[data-align*='bottom']{margin-bottom:-0.1875em}.filepond--action-edit-item-alt{border:none;line-height:inherit;background:transparent;font-family:inherit;color:inherit;outline:none;padding:0;margin:0 0 0 0.25em;pointer-events:all;position:absolute}.filepond--action-edit-item-alt svg{width:1.3125em;height:1.3125em}.filepond--action-edit-item-alt span{font-size:0;opacity:0}.filepond--root[data-style-panel-layout~='circle'] .filepond--action-edit-item{opacity:1 !important;visibility:visible !important}";
|
|
14481
15107
|
|
|
14482
15108
|
const SallaFileUpload = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement$1 {
|
|
@@ -14484,19 +15110,19 @@ const SallaFileUpload = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
14484
15110
|
super();
|
|
14485
15111
|
this.__registerHost();
|
|
14486
15112
|
this.uploaded = createEvent(this, "uploaded", 7);
|
|
14487
|
-
this.
|
|
15113
|
+
this.removed = createEvent(this, "removed", 7);
|
|
14488
15114
|
/**
|
|
14489
|
-
*
|
|
15115
|
+
* File input name for the native formData
|
|
14490
15116
|
*/
|
|
14491
|
-
this.
|
|
15117
|
+
this.name = 'file';
|
|
14492
15118
|
/**
|
|
14493
|
-
*
|
|
15119
|
+
* The submit request method.
|
|
14494
15120
|
*/
|
|
14495
|
-
this.
|
|
15121
|
+
this.method = 'POST';
|
|
14496
15122
|
/**
|
|
14497
|
-
*
|
|
15123
|
+
* json formData to be injected in the submit request
|
|
14498
15124
|
*/
|
|
14499
|
-
this.
|
|
15125
|
+
this.formData = "{}";
|
|
14500
15126
|
/**
|
|
14501
15127
|
* Enable or disable drag n' drop
|
|
14502
15128
|
*/
|
|
@@ -14505,14 +15131,6 @@ const SallaFileUpload = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
14505
15131
|
* Enable or disable file browser
|
|
14506
15132
|
*/
|
|
14507
15133
|
this.allowBrowse = true;
|
|
14508
|
-
/**
|
|
14509
|
-
* Enable or disable pasting of files. Pasting files is not supported on all browesrs.
|
|
14510
|
-
*/
|
|
14511
|
-
this.allowPaste = true;
|
|
14512
|
-
/**
|
|
14513
|
-
* Enable or disable adding multiple files
|
|
14514
|
-
*/
|
|
14515
|
-
this.allowMultiple = false;
|
|
14516
15134
|
/**
|
|
14517
15135
|
* Allow drop to replace a file, only works when allowMultiple is false
|
|
14518
15136
|
*/
|
|
@@ -14525,26 +15143,6 @@ const SallaFileUpload = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
14525
15143
|
* When set to false the remove button is hidden and disabled
|
|
14526
15144
|
*/
|
|
14527
15145
|
this.allowRemove = true;
|
|
14528
|
-
/**
|
|
14529
|
-
* Enable or disable the process button
|
|
14530
|
-
*/
|
|
14531
|
-
this.allowProcess = true;
|
|
14532
|
-
/**
|
|
14533
|
-
* Allow users to reorder files with drag and drop interaction.
|
|
14534
|
-
* Note that this only works in single column mode.
|
|
14535
|
-
* It also only works on browsers that support pointer events.
|
|
14536
|
-
*/
|
|
14537
|
-
this.allowReorder = false;
|
|
14538
|
-
/**
|
|
14539
|
-
* Tells FilePond to store files in hidden file input elements so they can be posted along with normal form post.
|
|
14540
|
-
* This only works if the browser supports the DataTransfer constructor (https://caniuse.com/mdn-api_datatransfer_datatransfer),
|
|
14541
|
-
* this is the case on Firefox, Chrome, Chromium powered browsers and Safari version 14.1 and higher.
|
|
14542
|
-
*/
|
|
14543
|
-
this.storeAsFile = false;
|
|
14544
|
-
/**
|
|
14545
|
-
* Set to true to require the file to be successfully reverted before continuing.
|
|
14546
|
-
*/
|
|
14547
|
-
this.forceRevert = false;
|
|
14548
15146
|
/**
|
|
14549
15147
|
* The maximum number of files that the pond can handle
|
|
14550
15148
|
*/
|
|
@@ -14553,11 +15151,6 @@ const SallaFileUpload = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
14553
15151
|
* The maxmimum number of files that can be uploaded in parallel
|
|
14554
15152
|
*/
|
|
14555
15153
|
this.maxParallelUploads = 2;
|
|
14556
|
-
/**
|
|
14557
|
-
* Set to true to enable custom validity messages.
|
|
14558
|
-
* FilePond will throw an error when a parent form is submitted and it contains invalid files.
|
|
14559
|
-
*/
|
|
14560
|
-
this.checkValidity = false;
|
|
14561
15154
|
/**
|
|
14562
15155
|
* Set to 'after' to add files to end of list (when dropped at the top of the list or added using browse or paste),
|
|
14563
15156
|
* set to 'before' to add files at start of list.
|
|
@@ -14568,66 +15161,14 @@ const SallaFileUpload = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
14568
15161
|
* The interval to use before showing each item being added to the list
|
|
14569
15162
|
*/
|
|
14570
15163
|
this.itemInsertInterval = 75;
|
|
14571
|
-
/**
|
|
14572
|
-
* Show credits at the bottom of the upload element.
|
|
14573
|
-
* Structure is like [{label,url}]
|
|
14574
|
-
*/
|
|
14575
|
-
this.credits = false;
|
|
14576
|
-
/// DRAG and DROP Props
|
|
14577
|
-
/**
|
|
14578
|
-
* FilePond will catch all files dropped on the webpage
|
|
14579
|
-
*/
|
|
14580
|
-
this.dropOnPage = false;
|
|
14581
15164
|
/**
|
|
14582
15165
|
* Require drop on the FilePond element itself to catch the file.
|
|
14583
15166
|
*/
|
|
14584
15167
|
this.dropOnElement = true;
|
|
14585
|
-
/**
|
|
14586
|
-
* When enabled, files are validated before they are dropped. A file is not added when it's invalid.
|
|
14587
|
-
*/
|
|
14588
|
-
this.dropValidation = false;
|
|
14589
15168
|
/**
|
|
14590
15169
|
* Ignored file names when handling dropped directories. Dropping directories is not supported on all browsers.
|
|
14591
15170
|
*/
|
|
14592
15171
|
this.ignoredFiles = ['.ds_store', 'thumbs.db', 'desktop.ini'];
|
|
14593
|
-
/// SERVER Configuration props
|
|
14594
|
-
/**
|
|
14595
|
-
* A server configuration object describing how FilePond should interact with the server.
|
|
14596
|
-
*/
|
|
14597
|
-
this.serverConfig = {
|
|
14598
|
-
process: async (_fieldName, file, _metadata, load, error, _progress, abort, _transfer, _options) => {
|
|
14599
|
-
const formData = new FormData();
|
|
14600
|
-
formData.append("image_url", file, file.name);
|
|
14601
|
-
return await salla.product.uploadGiftImage(formData)
|
|
14602
|
-
.then((resp) => {
|
|
14603
|
-
this.uploadedImage = resp.data.url;
|
|
14604
|
-
this.uploaded.emit(resp.data.url);
|
|
14605
|
-
load('success');
|
|
14606
|
-
}).catch(e => {
|
|
14607
|
-
console.log(e);
|
|
14608
|
-
error('error');
|
|
14609
|
-
})
|
|
14610
|
-
.finally(() => {
|
|
14611
|
-
return {
|
|
14612
|
-
abort: () => {
|
|
14613
|
-
abort();
|
|
14614
|
-
},
|
|
14615
|
-
};
|
|
14616
|
-
});
|
|
14617
|
-
}
|
|
14618
|
-
};
|
|
14619
|
-
/**
|
|
14620
|
-
* Immediately upload new files to the server
|
|
14621
|
-
*/
|
|
14622
|
-
this.instantUpload = false;
|
|
14623
|
-
/**
|
|
14624
|
-
* Enable chunked uploads, when enabled will automatically cut up files in chunkSize chunks before upload.
|
|
14625
|
-
*/
|
|
14626
|
-
this.chunkUploads = false;
|
|
14627
|
-
/**
|
|
14628
|
-
* Force chunks even for files smaller than the set chunkSize
|
|
14629
|
-
*/
|
|
14630
|
-
this.chunkForce = false;
|
|
14631
15172
|
/**
|
|
14632
15173
|
* The size of a chunk in bytes
|
|
14633
15174
|
*/
|
|
@@ -14651,131 +15192,125 @@ const SallaFileUpload = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
14651
15192
|
* @default `${salla.lang.get('common.uploader.drag_and_drop')}<span class="filepond--label-action"> ${salla.lang.get('common.uploader.browse')} </span>`
|
|
14652
15193
|
*/
|
|
14653
15194
|
this.labelIdle = this.getLabel();
|
|
15195
|
+
/// SVG Icons
|
|
14654
15196
|
/**
|
|
14655
|
-
*
|
|
15197
|
+
* The icon used for remove actions
|
|
14656
15198
|
*/
|
|
14657
|
-
this.
|
|
15199
|
+
this.iconRemove = '<svg>...</svg>';
|
|
14658
15200
|
/**
|
|
14659
|
-
*
|
|
15201
|
+
* The icon used for process actions
|
|
14660
15202
|
*/
|
|
14661
|
-
this.
|
|
15203
|
+
this.iconProcess = '<svg>...</svg>';
|
|
14662
15204
|
/**
|
|
14663
|
-
*
|
|
15205
|
+
* The icon used for retry actions
|
|
14664
15206
|
*/
|
|
14665
|
-
this.
|
|
15207
|
+
this.iconRetry = '<svg>...</svg>';
|
|
14666
15208
|
/**
|
|
14667
|
-
*
|
|
15209
|
+
* The icon used for undo actions
|
|
14668
15210
|
*/
|
|
14669
|
-
this.
|
|
15211
|
+
this.iconUndo = '<svg>...</svg>';
|
|
15212
|
+
/// STATES
|
|
14670
15213
|
/**
|
|
14671
|
-
*
|
|
15214
|
+
* The array of file references
|
|
14672
15215
|
*/
|
|
14673
|
-
this.
|
|
15216
|
+
this.files = [];
|
|
14674
15217
|
/**
|
|
14675
|
-
*
|
|
15218
|
+
* Translations
|
|
14676
15219
|
*/
|
|
15220
|
+
this.labelInvalidField = salla.lang.get("common.uploader.invalid_field");
|
|
15221
|
+
this.labelFileWaitingForSize = salla.lang.get('common.uploader.waiting_file_info');
|
|
15222
|
+
this.labelFileSizeNotAvailable = salla.lang.get('common.uploader.size_not_available');
|
|
15223
|
+
this.labelFileLoading = salla.lang.get('common.elements.loading');
|
|
15224
|
+
this.labelFileLoadError = salla.lang.get('common.uploader.failed_to_load');
|
|
14677
15225
|
this.labelFileProcessing = salla.lang.get('common.uploader.uploading');
|
|
14678
|
-
/**
|
|
14679
|
-
* Label used when file upload has completed
|
|
14680
|
-
*/
|
|
14681
15226
|
this.labelFileProcessingComplete = salla.lang.get('common.uploader.upload_completed');
|
|
14682
|
-
/**
|
|
14683
|
-
* Label used when upload was cancelled
|
|
14684
|
-
*/
|
|
14685
15227
|
this.labelFileProcessingAborted = salla.lang.get('common.uploader.upload_cancelled');
|
|
14686
|
-
/**
|
|
14687
|
-
* Label used when something went wrong during file upload
|
|
14688
|
-
*/
|
|
14689
15228
|
this.labelFileProcessingError = salla.lang.get('common.uploader.error_uploading');
|
|
14690
|
-
/**
|
|
14691
|
-
* Label used when something went wrong during reverting the file upload
|
|
14692
|
-
*/
|
|
14693
15229
|
this.labelFileProcessingRevertError = salla.lang.get('common.uploader.error_reverting');
|
|
14694
|
-
/**
|
|
14695
|
-
* Label used to indicate something went wrong when removing the file
|
|
14696
|
-
*/
|
|
14697
15230
|
this.labelFileRemoveError = salla.lang.get('common.uploader.error_removing');
|
|
14698
|
-
/**
|
|
14699
|
-
* Label used to indicate to the user that an action can be cancelled.
|
|
14700
|
-
*/
|
|
14701
15231
|
this.labelTapToCancel = salla.lang.get("common.elements.cancel");
|
|
14702
|
-
/**
|
|
14703
|
-
* Label used to indicate to the user that an action can be retried.
|
|
14704
|
-
*/
|
|
14705
15232
|
this.labelTapToRetry = salla.lang.get("common.elements.retry");
|
|
14706
|
-
/**
|
|
14707
|
-
* Label used to indicate to the user that an action can be undone.
|
|
14708
|
-
*/
|
|
14709
15233
|
this.labelTapToUndo = salla.lang.get("common.uploader.revert");
|
|
14710
|
-
/**
|
|
14711
|
-
* Label used for remove button
|
|
14712
|
-
*/
|
|
14713
15234
|
this.labelButtonRemoveItem = salla.lang.get("common.elements.remove");
|
|
14714
|
-
/**
|
|
14715
|
-
* Label used for abort load button
|
|
14716
|
-
*/
|
|
14717
15235
|
this.labelButtonAbortItemLoad = salla.lang.get("common.elements.abort");
|
|
14718
|
-
/**
|
|
14719
|
-
* Label used for retry load button
|
|
14720
|
-
*/
|
|
14721
15236
|
this.labelButtonRetryItemLoad = salla.lang.get("common.elements.retry");
|
|
14722
|
-
/**
|
|
14723
|
-
* Label used for abort upload button
|
|
14724
|
-
*/
|
|
14725
15237
|
this.labelButtonAbortItemProcessing = salla.lang.get("common.uploader.abort_upload");
|
|
14726
|
-
/**
|
|
14727
|
-
* Label used for undo upload button
|
|
14728
|
-
*/
|
|
14729
15238
|
this.labelButtonUndoItemProcessing = salla.lang.get("common.elements.undo");
|
|
14730
|
-
/**
|
|
14731
|
-
* Label used for retry upload button
|
|
14732
|
-
*/
|
|
14733
15239
|
this.labelButtonRetryItemProcessing = `${salla.lang.get("common.elements.retry")} ${salla.lang.get("common.uploader.upload")}`;
|
|
14734
|
-
/**
|
|
14735
|
-
* Label used for upload button
|
|
14736
|
-
*/
|
|
14737
15240
|
this.labelButtonProcessItem = salla.lang.get("common.uploader.upload");
|
|
14738
|
-
|
|
14739
|
-
/**
|
|
14740
|
-
* The icon used for remove actions
|
|
14741
|
-
*/
|
|
14742
|
-
this.iconRemove = '<svg>...</svg>';
|
|
14743
|
-
/**
|
|
14744
|
-
* The icon used for process actions
|
|
14745
|
-
*/
|
|
14746
|
-
this.iconProcess = '<svg>...</svg>';
|
|
14747
|
-
/**
|
|
14748
|
-
* The icon used for retry actions
|
|
14749
|
-
*/
|
|
14750
|
-
this.iconRetry = '<svg>...</svg>';
|
|
14751
|
-
/**
|
|
14752
|
-
* The icon used for undo actions
|
|
14753
|
-
*/
|
|
14754
|
-
this.iconUndo = '<svg>...</svg>';
|
|
14755
|
-
/**
|
|
14756
|
-
* The array of file references
|
|
14757
|
-
*/
|
|
14758
|
-
this.files = [];
|
|
15241
|
+
filepond.registerPlugin(FilePondPluginImagePreview, filepondPluginImageExifOrientation, filepondPluginFileValidateSize, filepondPluginImageEdit, filepondPluginFileValidateType, filepondPluginFilePoster);
|
|
14759
15242
|
salla.lang.onLoaded(() => {
|
|
14760
15243
|
this.host.querySelectorAll('.filepond--drop-label>label').forEach(label => label.innerHTML = this.getLabel());
|
|
15244
|
+
this.labelInvalidField = salla.lang.get("common.uploader.invalid_field");
|
|
15245
|
+
this.labelFileWaitingForSize = salla.lang.get('common.uploader.waiting_file_info');
|
|
15246
|
+
this.labelFileSizeNotAvailable = salla.lang.get('common.uploader.size_not_available');
|
|
15247
|
+
this.labelFileLoading = salla.lang.get('common.elements.loading');
|
|
15248
|
+
this.labelFileLoadError = salla.lang.get('common.uploader.failed_to_load');
|
|
15249
|
+
this.labelFileProcessing = salla.lang.get('common.uploader.uploading');
|
|
15250
|
+
this.labelFileProcessingComplete = salla.lang.get('common.uploader.upload_completed');
|
|
15251
|
+
this.labelFileProcessingAborted = salla.lang.get('common.uploader.upload_cancelled');
|
|
15252
|
+
this.labelFileProcessingError = salla.lang.get('common.uploader.error_uploading');
|
|
15253
|
+
this.labelFileProcessingRevertError = salla.lang.get('common.uploader.error_reverting');
|
|
15254
|
+
this.labelFileRemoveError = salla.lang.get('common.uploader.error_removing');
|
|
15255
|
+
this.labelTapToCancel = salla.lang.get("common.elements.cancel");
|
|
15256
|
+
this.labelTapToRetry = salla.lang.get("common.elements.retry");
|
|
15257
|
+
this.labelTapToUndo = salla.lang.get("common.uploader.revert");
|
|
15258
|
+
this.labelButtonRemoveItem = salla.lang.get("common.elements.remove");
|
|
15259
|
+
this.labelButtonAbortItemLoad = salla.lang.get("common.elements.abort");
|
|
15260
|
+
this.labelButtonRetryItemLoad = salla.lang.get("common.elements.retry");
|
|
15261
|
+
this.labelButtonAbortItemProcessing = salla.lang.get("common.uploader.abort_upload");
|
|
15262
|
+
this.labelButtonUndoItemProcessing = salla.lang.get("common.elements.undo");
|
|
15263
|
+
this.labelButtonRetryItemProcessing = `${salla.lang.get("common.elements.retry")} ${salla.lang.get("common.uploader.upload")}`;
|
|
15264
|
+
this.labelButtonProcessItem = salla.lang.get("common.uploader.upload");
|
|
14761
15265
|
});
|
|
14762
15266
|
}
|
|
15267
|
+
getLabel() {
|
|
15268
|
+
return this.host.getAttribute('label-idle') || `${salla.lang.get('common.uploader.drag_and_drop')}<span class="filepond--label-action"> ${salla.lang.get('common.uploader.browse')} </span>`;
|
|
15269
|
+
}
|
|
14763
15270
|
/**
|
|
14764
|
-
*
|
|
15271
|
+
*
|
|
15272
|
+
* This method will fire head request to get the file size, it's head request,so it will be too fast.
|
|
14765
15273
|
*/
|
|
14766
|
-
|
|
14767
|
-
|
|
15274
|
+
getFileSize(url) {
|
|
15275
|
+
let http = new XMLHttpRequest();
|
|
15276
|
+
http.open('HEAD', url, false); // false = Synchronous
|
|
15277
|
+
http.send(null); // it will stop here until this http request is complete
|
|
15278
|
+
return http.status === 200 ? http.getResponseHeader('content-length') : '';
|
|
14768
15279
|
}
|
|
14769
|
-
|
|
14770
|
-
|
|
15280
|
+
getFiles() {
|
|
15281
|
+
if (!this.value) {
|
|
15282
|
+
return [];
|
|
15283
|
+
}
|
|
15284
|
+
try {
|
|
15285
|
+
let files = [this.value];
|
|
15286
|
+
return files.map(file => {
|
|
15287
|
+
let metadata = { poster: file, name: file };
|
|
15288
|
+
return {
|
|
15289
|
+
source: this.fileId ? `${this.fileId}` : this.value,
|
|
15290
|
+
options: {
|
|
15291
|
+
type: 'local',
|
|
15292
|
+
file: {
|
|
15293
|
+
name: this.value.substring(this.value.lastIndexOf('/') + 1),
|
|
15294
|
+
size: this.getFileSize(this.value)
|
|
15295
|
+
},
|
|
15296
|
+
metadata: metadata,
|
|
15297
|
+
},
|
|
15298
|
+
};
|
|
15299
|
+
});
|
|
15300
|
+
}
|
|
15301
|
+
catch (e) {
|
|
15302
|
+
salla.log('failed To get files from: ' + (this.value || this.fileId));
|
|
15303
|
+
}
|
|
15304
|
+
return [];
|
|
14771
15305
|
}
|
|
14772
|
-
|
|
14773
|
-
this.
|
|
15306
|
+
render() {
|
|
15307
|
+
return (h(Host, { class: "s-file-upload" }, h("input", { type: "file", name: this.name, value: this.value, ref: ele => this.fileUploader = ele, required: this.required, class: "s-file-upload-wrapper s-file-upload-input", accept: "image/png, image/jpeg, image/jpg, image/gif" })));
|
|
14774
15308
|
}
|
|
14775
|
-
|
|
14776
|
-
filepond.
|
|
14777
|
-
|
|
14778
|
-
|
|
15309
|
+
componentDidLoad() {
|
|
15310
|
+
this.pond = filepond.create(this.fileUploader, {
|
|
15311
|
+
name: this.payloadName || this.name,
|
|
15312
|
+
//@ts-ignore
|
|
15313
|
+
files: this.getFiles(),
|
|
14779
15314
|
required: this.required,
|
|
14780
15315
|
disabled: this.disabled,
|
|
14781
15316
|
allowDrop: this.allowDrop,
|
|
@@ -14798,7 +15333,43 @@ const SallaFileUpload = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
14798
15333
|
dropOnElement: this.dropOnElement,
|
|
14799
15334
|
dropValidation: this.dropValidation,
|
|
14800
15335
|
ignoredFiles: this.ignoredFiles,
|
|
14801
|
-
server:
|
|
15336
|
+
server: {
|
|
15337
|
+
url: this.url,
|
|
15338
|
+
method: this.method,
|
|
15339
|
+
// @ts-ignore
|
|
15340
|
+
process: {
|
|
15341
|
+
onload: response => {
|
|
15342
|
+
let url = JSON.parse(response).data;
|
|
15343
|
+
this.uploaded.emit(this.value = url.filePath || url.url);
|
|
15344
|
+
return this.value;
|
|
15345
|
+
},
|
|
15346
|
+
headers: salla.api.getHeaders(),
|
|
15347
|
+
onerror: response => {
|
|
15348
|
+
try {
|
|
15349
|
+
let field = JSON.parse(response).error.fields;
|
|
15350
|
+
field = field[this.payloadName || this.name];
|
|
15351
|
+
return (field && field[0]) || salla.lang.get('common.errors.error_occurred');
|
|
15352
|
+
}
|
|
15353
|
+
catch (e) {
|
|
15354
|
+
salla.log('FileUpload:: Error', e);
|
|
15355
|
+
return salla.lang.get('common.errors.error_occurred');
|
|
15356
|
+
}
|
|
15357
|
+
},
|
|
15358
|
+
ondata: formData => {
|
|
15359
|
+
if (this.payloadName && this.payloadName != this.name) {
|
|
15360
|
+
formData.append(this.payloadName, this.pond.getFile(0).file);
|
|
15361
|
+
formData.delete(this.name);
|
|
15362
|
+
}
|
|
15363
|
+
try {
|
|
15364
|
+
Object.entries(JSON.parse(this.formData)).forEach((value) => value[1] && formData.append(value[0], value[1]));
|
|
15365
|
+
}
|
|
15366
|
+
catch (e) {
|
|
15367
|
+
salla.log('Error to inject formData', e);
|
|
15368
|
+
}
|
|
15369
|
+
return formData;
|
|
15370
|
+
}
|
|
15371
|
+
},
|
|
15372
|
+
},
|
|
14802
15373
|
instantUpload: this.instantUpload,
|
|
14803
15374
|
chunkUploads: this.chunkUploads,
|
|
14804
15375
|
chunkForce: this.chunkForce,
|
|
@@ -14807,26 +15378,27 @@ const SallaFileUpload = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
14807
15378
|
labelDecimalSeparator: this.labelDecimalSeparator,
|
|
14808
15379
|
labelThousandsSeparator: this.labelThousandsSeparator,
|
|
14809
15380
|
labelIdle: this.labelIdle,
|
|
15381
|
+
//todo:: pass support types from props
|
|
14810
15382
|
acceptedFileTypes: ['image/jpg', 'image/png', 'image/jpeg', 'image/gif', 'video/*'],
|
|
14811
15383
|
labelInvalidField: this.labelInvalidField,
|
|
14812
15384
|
labelFileWaitingForSize: this.labelFileWaitingForSize,
|
|
15385
|
+
// onprocessfile: (error, file) =>salla.log(error, JSON.parse(file.serverId)),
|
|
14813
15386
|
beforeRemoveFile: (file_deleted) => new Promise((resolve) => {
|
|
14814
|
-
this.
|
|
14815
|
-
setTimeout(() => {
|
|
14816
|
-
// TODO: needs a better way
|
|
14817
|
-
this.host.style.height = '120px !important';
|
|
14818
|
-
}, 1000);
|
|
15387
|
+
this.removed.emit(file_deleted);
|
|
14819
15388
|
resolve(true);
|
|
14820
15389
|
}),
|
|
14821
15390
|
});
|
|
14822
15391
|
}
|
|
14823
|
-
render() {
|
|
14824
|
-
return (h(Host, { class: "s-file-upload" }, h("input", { type: "file", name: "filepond", ref: ele => this.fileUploader = ele, class: "s-file-upload-wrapper s-file-upload-input", accept: "image/png, image/jpeg, image/jpg, image/gif" })));
|
|
14825
|
-
}
|
|
14826
15392
|
get host() { return this; }
|
|
14827
15393
|
static get style() { return sallaFileUploadCss; }
|
|
14828
15394
|
}, [0, "salla-file-upload", {
|
|
14829
|
-
"
|
|
15395
|
+
"value": [1537],
|
|
15396
|
+
"name": [1],
|
|
15397
|
+
"payloadName": [1, "payload-name"],
|
|
15398
|
+
"fileId": [2, "file-id"],
|
|
15399
|
+
"url": [1],
|
|
15400
|
+
"method": [1],
|
|
15401
|
+
"formData": [1, "form-data"],
|
|
14830
15402
|
"required": [4],
|
|
14831
15403
|
"disabled": [4],
|
|
14832
15404
|
"allowDrop": [4, "allow-drop"],
|
|
@@ -14850,7 +15422,6 @@ const SallaFileUpload = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
14850
15422
|
"dropOnElement": [4, "drop-on-element"],
|
|
14851
15423
|
"dropValidation": [4, "drop-validation"],
|
|
14852
15424
|
"ignoredFiles": [16],
|
|
14853
|
-
"serverConfig": [1, "server-config"],
|
|
14854
15425
|
"instantUpload": [4, "instant-upload"],
|
|
14855
15426
|
"chunkUploads": [4, "chunk-uploads"],
|
|
14856
15427
|
"chunkForce": [4, "chunk-force"],
|
|
@@ -14859,34 +15430,32 @@ const SallaFileUpload = /*@__PURE__*/ proxyCustomElement(class extends HTMLEleme
|
|
|
14859
15430
|
"labelDecimalSeparator": [1, "label-decimal-separator"],
|
|
14860
15431
|
"labelThousandsSeparator": [1, "label-thousands-separator"],
|
|
14861
15432
|
"labelIdle": [1, "label-idle"],
|
|
14862
|
-
"labelInvalidField": [1, "label-invalid-field"],
|
|
14863
|
-
"labelFileWaitingForSize": [1, "label-file-waiting-for-size"],
|
|
14864
|
-
"labelFileSizeNotAvailable": [1, "label-file-size-not-available"],
|
|
14865
|
-
"labelFileLoading": [1, "label-file-loading"],
|
|
14866
|
-
"labelFileLoadError": [1, "label-file-load-error"],
|
|
14867
|
-
"labelFileProcessing": [1, "label-file-processing"],
|
|
14868
|
-
"labelFileProcessingComplete": [1, "label-file-processing-complete"],
|
|
14869
|
-
"labelFileProcessingAborted": [1, "label-file-processing-aborted"],
|
|
14870
|
-
"labelFileProcessingError": [1, "label-file-processing-error"],
|
|
14871
|
-
"labelFileProcessingRevertError": [1, "label-file-processing-revert-error"],
|
|
14872
|
-
"labelFileRemoveError": [1, "label-file-remove-error"],
|
|
14873
|
-
"labelTapToCancel": [1, "label-tap-to-cancel"],
|
|
14874
|
-
"labelTapToRetry": [1, "label-tap-to-retry"],
|
|
14875
|
-
"labelTapToUndo": [1, "label-tap-to-undo"],
|
|
14876
|
-
"labelButtonRemoveItem": [1, "label-button-remove-item"],
|
|
14877
|
-
"labelButtonAbortItemLoad": [1, "label-button-abort-item-load"],
|
|
14878
|
-
"labelButtonRetryItemLoad": [1, "label-button-retry-item-load"],
|
|
14879
|
-
"labelButtonAbortItemProcessing": [1, "label-button-abort-item-processing"],
|
|
14880
|
-
"labelButtonUndoItemProcessing": [1, "label-button-undo-item-processing"],
|
|
14881
|
-
"labelButtonRetryItemProcessing": [1, "label-button-retry-item-processing"],
|
|
14882
|
-
"labelButtonProcessItem": [1, "label-button-process-item"],
|
|
14883
15433
|
"iconRemove": [1, "icon-remove"],
|
|
14884
15434
|
"iconProcess": [1, "icon-process"],
|
|
14885
15435
|
"iconRetry": [1, "icon-retry"],
|
|
14886
15436
|
"iconUndo": [1, "icon-undo"],
|
|
14887
|
-
"pond": [32],
|
|
14888
15437
|
"files": [32],
|
|
14889
|
-
"
|
|
15438
|
+
"labelInvalidField": [32],
|
|
15439
|
+
"labelFileWaitingForSize": [32],
|
|
15440
|
+
"labelFileSizeNotAvailable": [32],
|
|
15441
|
+
"labelFileLoading": [32],
|
|
15442
|
+
"labelFileLoadError": [32],
|
|
15443
|
+
"labelFileProcessing": [32],
|
|
15444
|
+
"labelFileProcessingComplete": [32],
|
|
15445
|
+
"labelFileProcessingAborted": [32],
|
|
15446
|
+
"labelFileProcessingError": [32],
|
|
15447
|
+
"labelFileProcessingRevertError": [32],
|
|
15448
|
+
"labelFileRemoveError": [32],
|
|
15449
|
+
"labelTapToCancel": [32],
|
|
15450
|
+
"labelTapToRetry": [32],
|
|
15451
|
+
"labelTapToUndo": [32],
|
|
15452
|
+
"labelButtonRemoveItem": [32],
|
|
15453
|
+
"labelButtonAbortItemLoad": [32],
|
|
15454
|
+
"labelButtonRetryItemLoad": [32],
|
|
15455
|
+
"labelButtonAbortItemProcessing": [32],
|
|
15456
|
+
"labelButtonUndoItemProcessing": [32],
|
|
15457
|
+
"labelButtonRetryItemProcessing": [32],
|
|
15458
|
+
"labelButtonProcessItem": [32]
|
|
14890
15459
|
}]);
|
|
14891
15460
|
function defineCustomElement() {
|
|
14892
15461
|
if (typeof customElements === "undefined") {
|