filepond 4.29.1 → 4.30.3

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/filepond.css CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * FilePond 4.29.1
2
+ * FilePond 4.30.3
3
3
  * Licensed under MIT, https://opensource.org/licenses/MIT/
4
4
  * Please visit https://pqina.nl/filepond/ for details.
5
5
  */
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * FilePond 4.29.1
2
+ * FilePond 4.30.3
3
3
  * Licensed under MIT, https://opensource.org/licenses/MIT/
4
4
  * Please visit https://pqina.nl/filepond/ for details.
5
5
  */
@@ -1872,6 +1872,11 @@ const defaultOptions = {
1872
1872
  fileSizeBase: [1000, Type.INT],
1873
1873
 
1874
1874
  // Labels and status messages
1875
+ labelFileSizeBytes: ['bytes', Type.STRING],
1876
+ labelFileSizeKilobytes: ['KB', Type.STRING],
1877
+ labelFileSizeMegabytes: ['MB', Type.STRING],
1878
+ labelFileSizeGigabytes: ['GB', Type.STRING],
1879
+
1875
1880
  labelDecimalSeparator: [getDecimalSeparator(), Type.STRING], // Default is locale separator
1876
1881
  labelThousandsSeparator: [getThousandsSeparator(), Type.STRING], // Default is locale separator
1877
1882
 
@@ -2113,6 +2118,13 @@ const queries = state => ({
2113
2118
  state.options.storeAsFile && canUpdateFileInput() && !isAsync(state),
2114
2119
 
2115
2120
  IS_ASYNC: () => isAsync(state),
2121
+
2122
+ GET_FILE_SIZE_LABELS: query => ({
2123
+ labelBytes: query('GET_LABEL_FILE_SIZE_BYTES') || undefined,
2124
+ labelKilobytes: query('GET_LABEL_FILE_SIZE_KILOBYTES') || undefined,
2125
+ labelMegabytes: query('GET_LABEL_FILE_SIZE_MEGABYTES') || undefined,
2126
+ labelGigabytes: query('GET_LABEL_FILE_SIZE_GIGABYTES') || undefined,
2127
+ }),
2116
2128
  });
2117
2129
 
2118
2130
  const hasRoomForItem = state => {
@@ -4980,12 +4992,34 @@ const actions = (dispatch, query, state) => ({
4980
4992
  }),
4981
4993
 
4982
4994
  SET_OPTIONS: ({ options }) => {
4983
- forin(options, (key, value) => {
4984
- dispatch(`SET_${fromCamels(key, '_').toUpperCase()}`, { value });
4995
+ // get all keys passed
4996
+ const optionKeys = Object.keys(options);
4997
+
4998
+ // get prioritized keyed to include (remove once not in options object)
4999
+ const prioritizedOptionKeys = PrioritizedOptions.filter(key => optionKeys.includes(key));
5000
+
5001
+ // order the keys, prioritized first, then rest
5002
+ const orderedOptionKeys = [
5003
+ // add prioritized first if passed to options, else remove
5004
+ ...prioritizedOptionKeys,
5005
+
5006
+ // prevent duplicate keys
5007
+ ...Object.keys(options).filter(key => !prioritizedOptionKeys.includes(key)),
5008
+ ];
5009
+
5010
+ // dispatch set event for each option
5011
+ orderedOptionKeys.forEach(key => {
5012
+ dispatch(`SET_${fromCamels(key, '_').toUpperCase()}`, {
5013
+ value: options[key],
5014
+ });
4985
5015
  });
4986
5016
  },
4987
5017
  });
4988
5018
 
5019
+ const PrioritizedOptions = [
5020
+ 'server', // must be processed before "files"
5021
+ ];
5022
+
4989
5023
  const formatFilename = name => name;
4990
5024
 
4991
5025
  const createElement$1 = tagName => {
@@ -5156,7 +5190,14 @@ const fileActionButton = createView({
5156
5190
  write: write$1,
5157
5191
  });
5158
5192
 
5159
- const toNaturalFileSize = (bytes, decimalSeparator = '.', base = 1000) => {
5193
+ const toNaturalFileSize = (bytes, decimalSeparator = '.', base = 1000, options = {}) => {
5194
+ const {
5195
+ labelBytes = 'bytes',
5196
+ labelKilobytes = 'KB',
5197
+ labelMegabytes = 'MB',
5198
+ labelGigabytes = 'GB',
5199
+ } = options;
5200
+
5160
5201
  // no negative byte sizes
5161
5202
  bytes = Math.round(Math.abs(bytes));
5162
5203
 
@@ -5166,21 +5207,21 @@ const toNaturalFileSize = (bytes, decimalSeparator = '.', base = 1000) => {
5166
5207
 
5167
5208
  // just bytes
5168
5209
  if (bytes < KB) {
5169
- return `${bytes} bytes`;
5210
+ return `${bytes} ${labelBytes}`;
5170
5211
  }
5171
5212
 
5172
5213
  // kilobytes
5173
5214
  if (bytes < MB) {
5174
- return `${Math.floor(bytes / KB)} KB`;
5215
+ return `${Math.floor(bytes / KB)} ${labelKilobytes}`;
5175
5216
  }
5176
5217
 
5177
5218
  // megabytes
5178
5219
  if (bytes < GB) {
5179
- return `${removeDecimalsWhenZero(bytes / MB, 1, decimalSeparator)} MB`;
5220
+ return `${removeDecimalsWhenZero(bytes / MB, 1, decimalSeparator)} ${labelMegabytes}`;
5180
5221
  }
5181
5222
 
5182
5223
  // gigabytes
5183
- return `${removeDecimalsWhenZero(bytes / GB, 2, decimalSeparator)} GB`;
5224
+ return `${removeDecimalsWhenZero(bytes / GB, 2, decimalSeparator)} ${labelGigabytes}`;
5184
5225
  };
5185
5226
 
5186
5227
  const removeDecimalsWhenZero = (value, decimalCount, separator) => {
@@ -5219,7 +5260,8 @@ const updateFile = ({ root, props }) => {
5219
5260
  toNaturalFileSize(
5220
5261
  root.query('GET_ITEM_SIZE', props.id),
5221
5262
  '.',
5222
- root.query('GET_FILE_SIZE_BASE')
5263
+ root.query('GET_FILE_SIZE_BASE'),
5264
+ root.query('GET_FILE_SIZE_LABELS', root.query)
5223
5265
  )
5224
5266
  );
5225
5267
  text(root.ref.fileName, formatFilename(root.query('GET_ITEM_NAME', props.id)));