@micromag/media-gallery 0.3.563 → 0.3.565

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 +145 -143
  2. package/package.json +2 -2
package/es/index.js CHANGED
@@ -141,166 +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: 'item',
182
- requestUrl: '/api/medias/tags',
183
- itemLabelPath: 'name',
184
- itemDescriptionPath: null,
185
- itemValuePath: 'id',
186
- // Uses taggable so change the logic here
187
- valueIsOption: true,
188
- multiple: true,
189
- paginated: false,
190
- creatable: true
191
- // formatCreateLabel: (lab) => `Create ${lab}`,
192
- // onCreate...
193
- }]
194
- }, {
195
- id: 'info',
196
- component: 'fields',
197
- label: /*#__PURE__*/React.createElement(FormattedMessage, {
198
- id: "3RT69u",
199
- defaultMessage: [{
200
- "type": 0,
201
- "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
202
193
  }]
203
- }),
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
194
  }, {
220
- id: 'created_at',
195
+ id: 'info',
196
+ component: 'fields',
221
197
  label: /*#__PURE__*/React.createElement(FormattedMessage, {
222
- id: "PN+75e",
198
+ id: "3RT69u",
223
199
  defaultMessage: [{
224
200
  "type": 0,
225
- "value": "Created at"
201
+ "value": "Informations"
226
202
  }]
227
203
  }),
228
- type: 'display',
229
- display: 'date',
230
- name: 'created_at',
231
- format: 'yyyy-MM-dd hh:ss',
232
- horizontal: true
233
- }]
234
- }, {
235
- id: 'technical',
236
- component: 'fields',
237
- label: /*#__PURE__*/React.createElement(FormattedMessage, {
238
- id: "xKUOLG",
239
- defaultMessage: [{
240
- "type": 0,
241
- "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
242
233
  }]
243
- }),
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
234
  }, {
275
- id: 'size',
235
+ id: 'technical',
236
+ component: 'fields',
276
237
  label: /*#__PURE__*/React.createElement(FormattedMessage, {
277
- id: "g2CRt5",
238
+ id: "xKUOLG",
278
239
  defaultMessage: [{
279
240
  "type": 0,
280
- "value": "Size"
241
+ "value": "Technical details"
281
242
  }]
282
243
  }),
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
- }];
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
+ }
304
305
 
305
306
  function filters() {
306
307
  var route = useUrlGenerator();
@@ -387,7 +388,7 @@ function filters() {
387
388
  }),
388
389
  requestUrl: route('medias.tags') || '/medias/tags',
389
390
  itemLabelPath: 'name',
390
- itemValuePath: 'id',
391
+ itemValuePath: 'name',
391
392
  multiple: true,
392
393
  paginated: false
393
394
  }, {
@@ -437,7 +438,7 @@ var defaultProps = {
437
438
  types: null,
438
439
  source: 'all',
439
440
  filters: null,
440
- fields: defaultFields,
441
+ fields: null,
441
442
  columns: defaultColumns,
442
443
  isPicker: false,
443
444
  multiple: false,
@@ -452,7 +453,7 @@ function MediaGallery(_ref) {
452
453
  types = _ref.types,
453
454
  source = _ref.source,
454
455
  filters$1 = _ref.filters,
455
- fields = _ref.fields,
456
+ providedFields = _ref.fields,
456
457
  columns = _ref.columns,
457
458
  isPicker = _ref.isPicker,
458
459
  multiple = _ref.multiple,
@@ -466,6 +467,7 @@ function MediaGallery(_ref) {
466
467
  var _ref2 = story || {},
467
468
  _ref2$id = _ref2.id,
468
469
  storyId = _ref2$id === void 0 ? null : _ref2$id;
470
+ var fields$1 = providedFields === null ? fields() : providedFields;
469
471
  var mediasApi = useMemo(function () {
470
472
  return {
471
473
  get: function get() {
@@ -601,7 +603,7 @@ function MediaGallery(_ref) {
601
603
  query: finalQuery,
602
604
  items: initialMedias,
603
605
  filters: finalFilters,
604
- fields: fields,
606
+ fields: fields$1,
605
607
  columns: columns,
606
608
  multiple: multiple,
607
609
  onChange: onChange,
@@ -620,7 +622,7 @@ function MediaGallery(_ref) {
620
622
  query: finalQuery,
621
623
  items: initialMedias,
622
624
  filters: finalFilters,
623
- fields: fields,
625
+ fields: fields$1,
624
626
  columns: columns,
625
627
  uppyConfig: uppyConfig,
626
628
  onMediaUploaded: onMediaUploaded,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/media-gallery",
3
- "version": "0.3.563",
3
+ "version": "0.3.565",
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": "08ca89365db5acdc31beedfc5d4ffb06487265b1"
89
+ "gitHead": "a20c8832c82503f5ccd17edb0cb2681c48fccd04"
90
90
  }