@micromag/media-gallery 0.3.561 → 0.3.564

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 (2) hide show
  1. package/es/index.js +144 -140
  2. package/package.json +2 -2
package/es/index.js CHANGED
@@ -141,164 +141,167 @@ var defaultColumns = [{
141
141
  // },
142
142
  ];
143
143
 
144
- var defaultFields = [{
145
- name: 'name',
146
- label: /*#__PURE__*/React.createElement(FormattedMessage, {
147
- id: "WX83V9",
148
- defaultMessage: [{
149
- "type": 0,
150
- "value": "File name"
151
- }]
152
- }),
153
- type: 'text',
154
- component: 'text'
155
- }, {
156
- id: 'metadata',
157
- component: 'fields',
158
- name: 'metadata',
159
- fields: [{
160
- name: 'description',
144
+ function fields() {
145
+ var route = useUrlGenerator();
146
+ return [{
147
+ name: 'name',
161
148
  label: /*#__PURE__*/React.createElement(FormattedMessage, {
162
- id: "ygNvmz",
149
+ id: "WX83V9",
163
150
  defaultMessage: [{
164
151
  "type": 0,
165
- "value": "Description"
152
+ "value": "File name"
166
153
  }]
167
154
  }),
168
155
  type: 'text',
169
156
  component: 'text'
170
157
  }, {
171
- name: 'tags',
172
- label: /*#__PURE__*/React.createElement(FormattedMessage, {
173
- id: "IOVper",
174
- defaultMessage: [{
175
- "type": 0,
176
- "value": "Tags"
177
- }]
178
- }),
179
- createPrefix: 'Create',
180
- type: 'array',
181
- component: 'select',
182
- requestUrl: '/api/medias/tags',
183
- optionLabelPath: 'name',
184
- optionValuePath: 'id',
185
- // Uses taggable so change the logic here
186
- valueIsOption: true,
187
- multiple: true,
188
- paginated: false,
189
- creatable: true
190
- // onCreate...
191
- }]
192
- }, {
193
- id: 'info',
194
- component: 'fields',
195
- label: /*#__PURE__*/React.createElement(FormattedMessage, {
196
- id: "3RT69u",
197
- defaultMessage: [{
198
- "type": 0,
199
- "value": "Informations"
158
+ id: 'metadata',
159
+ component: 'fields',
160
+ name: 'metadata',
161
+ fields: [{
162
+ name: 'description',
163
+ label: /*#__PURE__*/React.createElement(FormattedMessage, {
164
+ id: "ygNvmz",
165
+ defaultMessage: [{
166
+ "type": 0,
167
+ "value": "Description"
168
+ }]
169
+ }),
170
+ type: 'text',
171
+ component: 'text'
172
+ }, {
173
+ name: 'tags',
174
+ label: /*#__PURE__*/React.createElement(FormattedMessage, {
175
+ id: "IOVper",
176
+ defaultMessage: [{
177
+ "type": 0,
178
+ "value": "Tags"
179
+ }]
180
+ }),
181
+ createPrefix: 'Create',
182
+ type: 'array',
183
+ component: 'item',
184
+ requestUrl: route('medias.tags') || '/medias/tags',
185
+ itemLabelPath: 'name',
186
+ itemDescriptionPath: null,
187
+ itemValuePath: 'id',
188
+ // Uses taggable so change the logic here
189
+ valueIsOption: true,
190
+ multiple: true,
191
+ paginated: false,
192
+ creatable: true
200
193
  }]
201
- }),
202
- isList: true,
203
- hideWithoutValue: true,
204
- fields: [{
205
- id: 'user',
206
- label: /*#__PURE__*/React.createElement(FormattedMessage, {
207
- id: "yByaBh",
208
- defaultMessage: [{
209
- "type": 0,
210
- "value": "Added by"
211
- }]
212
- }),
213
- type: 'display',
214
- display: 'avatar',
215
- name: 'user',
216
- horizontal: true
217
194
  }, {
218
- id: 'created_at',
195
+ id: 'info',
196
+ component: 'fields',
219
197
  label: /*#__PURE__*/React.createElement(FormattedMessage, {
220
- id: "PN+75e",
198
+ id: "3RT69u",
221
199
  defaultMessage: [{
222
200
  "type": 0,
223
- "value": "Created at"
201
+ "value": "Informations"
224
202
  }]
225
203
  }),
226
- type: 'display',
227
- display: 'date',
228
- name: 'created_at',
229
- format: 'yyyy-MM-dd hh:ss',
230
- horizontal: true
231
- }]
232
- }, {
233
- id: 'technical',
234
- component: 'fields',
235
- label: /*#__PURE__*/React.createElement(FormattedMessage, {
236
- id: "xKUOLG",
237
- defaultMessage: [{
238
- "type": 0,
239
- "value": "Technical details"
204
+ isList: true,
205
+ hideWithoutValue: true,
206
+ fields: [{
207
+ id: 'user',
208
+ label: /*#__PURE__*/React.createElement(FormattedMessage, {
209
+ id: "yByaBh",
210
+ defaultMessage: [{
211
+ "type": 0,
212
+ "value": "Added by"
213
+ }]
214
+ }),
215
+ type: 'display',
216
+ display: 'avatar',
217
+ name: 'user',
218
+ horizontal: true
219
+ }, {
220
+ id: 'created_at',
221
+ label: /*#__PURE__*/React.createElement(FormattedMessage, {
222
+ id: "PN+75e",
223
+ defaultMessage: [{
224
+ "type": 0,
225
+ "value": "Created at"
226
+ }]
227
+ }),
228
+ type: 'display',
229
+ display: 'date',
230
+ name: 'created_at',
231
+ format: 'yyyy-MM-dd hh:ss',
232
+ horizontal: true
240
233
  }]
241
- }),
242
- isList: true,
243
- hideWithoutValue: true,
244
- fields: [{
245
- id: 'format',
246
- label: /*#__PURE__*/React.createElement(FormattedMessage, {
247
- id: "JuxiUN",
248
- defaultMessage: [{
249
- "type": 0,
250
- "value": "Format"
251
- }]
252
- }),
253
- type: 'display',
254
- display: 'unit',
255
- format: 'format',
256
- name: 'format',
257
- horizontal: true
258
234
  }, {
259
- id: 'dimensions',
235
+ id: 'technical',
236
+ component: 'fields',
260
237
  label: /*#__PURE__*/React.createElement(FormattedMessage, {
261
- id: "rmJBin",
238
+ id: "xKUOLG",
262
239
  defaultMessage: [{
263
240
  "type": 0,
264
- "value": "Dimensions"
241
+ "value": "Technical details"
265
242
  }]
266
243
  }),
267
- type: 'display',
268
- display: 'unit',
269
- format: 'dimensions',
270
- name: 'metadata',
271
- horizontal: true
272
- }, {
273
- id: 'size',
274
- label: /*#__PURE__*/React.createElement(FormattedMessage, {
275
- id: "g2CRt5",
276
- defaultMessage: [{
277
- "type": 0,
278
- "value": "Size"
279
- }]
280
- }),
281
- type: 'display',
282
- display: 'unit',
283
- format: 'bytes',
284
- name: 'metadata.size',
285
- horizontal: true
286
- }, {
287
- id: 'duration',
288
- label: /*#__PURE__*/React.createElement(FormattedMessage, {
289
- id: "wU++NJ",
290
- defaultMessage: [{
291
- "type": 0,
292
- "value": "Duration"
293
- }]
294
- }),
295
- type: 'display',
296
- display: 'unit',
297
- format: 'duration',
298
- name: 'metadata.duration',
299
- horizontal: true
300
- }]
301
- }];
244
+ isList: true,
245
+ hideWithoutValue: true,
246
+ fields: [{
247
+ id: 'format',
248
+ label: /*#__PURE__*/React.createElement(FormattedMessage, {
249
+ id: "JuxiUN",
250
+ defaultMessage: [{
251
+ "type": 0,
252
+ "value": "Format"
253
+ }]
254
+ }),
255
+ type: 'display',
256
+ display: 'unit',
257
+ format: 'format',
258
+ name: 'format',
259
+ horizontal: true
260
+ }, {
261
+ id: 'dimensions',
262
+ label: /*#__PURE__*/React.createElement(FormattedMessage, {
263
+ id: "rmJBin",
264
+ defaultMessage: [{
265
+ "type": 0,
266
+ "value": "Dimensions"
267
+ }]
268
+ }),
269
+ type: 'display',
270
+ display: 'unit',
271
+ format: 'dimensions',
272
+ name: 'metadata',
273
+ horizontal: true
274
+ }, {
275
+ id: 'size',
276
+ label: /*#__PURE__*/React.createElement(FormattedMessage, {
277
+ id: "g2CRt5",
278
+ defaultMessage: [{
279
+ "type": 0,
280
+ "value": "Size"
281
+ }]
282
+ }),
283
+ type: 'display',
284
+ display: 'unit',
285
+ format: 'bytes',
286
+ name: 'metadata.size',
287
+ horizontal: true
288
+ }, {
289
+ id: 'duration',
290
+ label: /*#__PURE__*/React.createElement(FormattedMessage, {
291
+ id: "wU++NJ",
292
+ defaultMessage: [{
293
+ "type": 0,
294
+ "value": "Duration"
295
+ }]
296
+ }),
297
+ type: 'display',
298
+ display: 'unit',
299
+ format: 'duration',
300
+ name: 'metadata.duration',
301
+ horizontal: true
302
+ }]
303
+ }];
304
+ }
302
305
 
303
306
  function filters() {
304
307
  var route = useUrlGenerator();
@@ -435,7 +438,7 @@ var defaultProps = {
435
438
  types: null,
436
439
  source: 'all',
437
440
  filters: null,
438
- fields: defaultFields,
441
+ fields: null,
439
442
  columns: defaultColumns,
440
443
  isPicker: false,
441
444
  multiple: false,
@@ -450,7 +453,7 @@ function MediaGallery(_ref) {
450
453
  types = _ref.types,
451
454
  source = _ref.source,
452
455
  filters$1 = _ref.filters,
453
- fields = _ref.fields,
456
+ providedFields = _ref.fields,
454
457
  columns = _ref.columns,
455
458
  isPicker = _ref.isPicker,
456
459
  multiple = _ref.multiple,
@@ -464,6 +467,7 @@ function MediaGallery(_ref) {
464
467
  var _ref2 = story || {},
465
468
  _ref2$id = _ref2.id,
466
469
  storyId = _ref2$id === void 0 ? null : _ref2$id;
470
+ var fields$1 = providedFields === null ? fields() : providedFields;
467
471
  var mediasApi = useMemo(function () {
468
472
  return {
469
473
  get: function get() {
@@ -599,7 +603,7 @@ function MediaGallery(_ref) {
599
603
  query: finalQuery,
600
604
  items: initialMedias,
601
605
  filters: finalFilters,
602
- fields: fields,
606
+ fields: fields$1,
603
607
  columns: columns,
604
608
  multiple: multiple,
605
609
  onChange: onChange,
@@ -618,7 +622,7 @@ function MediaGallery(_ref) {
618
622
  query: finalQuery,
619
623
  items: initialMedias,
620
624
  filters: finalFilters,
621
- fields: fields,
625
+ fields: fields$1,
622
626
  columns: columns,
623
627
  uppyConfig: uppyConfig,
624
628
  onMediaUploaded: onMediaUploaded,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/media-gallery",
3
- "version": "0.3.561",
3
+ "version": "0.3.564",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -86,5 +86,5 @@
86
86
  "access": "public",
87
87
  "registry": "https://registry.npmjs.org/"
88
88
  },
89
- "gitHead": "da01f5d13a1930f52a7e921fcfc320c94fed7d0a"
89
+ "gitHead": "e8f28bbbfe6ffc35d31de6fb33786e073e3980ca"
90
90
  }