@panneau/medias 3.0.160 → 3.0.163

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 (3) hide show
  1. package/es/index.js +105 -65
  2. package/lib/index.js +105 -65
  3. package/package.json +17 -17
package/es/index.js CHANGED
@@ -275,9 +275,8 @@ var defaultFields = [{
275
275
  }]
276
276
  }),
277
277
  component: 'display',
278
- type: 'avatar',
279
- path: 'user',
280
- section: 'info'
278
+ display: 'avatar',
279
+ name: 'user'
281
280
  }, {
282
281
  id: 'created_at',
283
282
  label: /*#__PURE__*/React.createElement(FormattedMessage, {
@@ -288,56 +287,74 @@ var defaultFields = [{
288
287
  }]
289
288
  }),
290
289
  component: 'display',
291
- type: 'date',
292
- path: 'created_at',
293
- format: 'yyyy-MM-dd hh:ss',
294
- section: 'info'
290
+ display: 'date',
291
+ name: 'created_at',
292
+ format: 'yyyy-MM-dd hh:ss'
295
293
  }]
296
- }
297
- // {
298
- // id: 'technical',
299
- // component: 'fields',
300
- // title: <FormattedMessage defaultMessage="Technical details" description="Field title" />,
301
- // fields: [
302
- // {
303
- // id: 'format',
304
- // label: <FormattedMessage defaultMessage="Format" description="Field label" />,
305
- // type: 'display',
306
- // component: 'unit',
307
- // format: 'format',
308
- // path: 'format',
309
- // section: 'technical',
310
- // },
311
- // {
312
- // id: 'dimensions',
313
- // label: <FormattedMessage defaultMessage="Dimensions" description="Field label" />,
314
- // type: 'display',
315
- // component: 'unit',
316
- // format: 'dimensions',
317
- // path: 'metadata',
318
- // section: 'technical',
319
- // },
320
- // {
321
- // id: 'size',
322
- // label: <FormattedMessage defaultMessage="Size" description="Field label" />,
323
- // type: 'display',
324
- // component: 'unit',
325
- // format: 'bytes',
326
- // path: 'metadata.size',
327
- // section: 'technical',
328
- // },
329
- // {
330
- // id: 'duration',
331
- // label: <FormattedMessage defaultMessage="Duration" description="Field label" />,
332
- // type: 'display',
333
- // component: 'unit',
334
- // format: 'duration',
335
- // path: 'metadata.duration',
336
- // section: 'technical',
337
- // },
338
- // ],
339
- // },
340
- ];
294
+ }, {
295
+ id: 'technical',
296
+ component: 'fields',
297
+ title: /*#__PURE__*/React.createElement(FormattedMessage, {
298
+ id: "xKUOLG",
299
+ defaultMessage: [{
300
+ "type": 0,
301
+ "value": "Technical details"
302
+ }]
303
+ }),
304
+ fields: [{
305
+ id: 'format',
306
+ label: /*#__PURE__*/React.createElement(FormattedMessage, {
307
+ id: "JuxiUN",
308
+ defaultMessage: [{
309
+ "type": 0,
310
+ "value": "Format"
311
+ }]
312
+ }),
313
+ type: 'display',
314
+ display: 'unit',
315
+ format: 'format',
316
+ name: 'format'
317
+ }, {
318
+ id: 'dimensions',
319
+ label: /*#__PURE__*/React.createElement(FormattedMessage, {
320
+ id: "rmJBin",
321
+ defaultMessage: [{
322
+ "type": 0,
323
+ "value": "Dimensions"
324
+ }]
325
+ }),
326
+ type: 'display',
327
+ display: 'unit',
328
+ format: 'dimensions',
329
+ name: 'metadata'
330
+ }, {
331
+ id: 'size',
332
+ label: /*#__PURE__*/React.createElement(FormattedMessage, {
333
+ id: "g2CRt5",
334
+ defaultMessage: [{
335
+ "type": 0,
336
+ "value": "Size"
337
+ }]
338
+ }),
339
+ type: 'display',
340
+ display: 'unit',
341
+ format: 'bytes',
342
+ name: 'metadata.size'
343
+ }, {
344
+ id: 'duration',
345
+ label: /*#__PURE__*/React.createElement(FormattedMessage, {
346
+ id: "wU++NJ",
347
+ defaultMessage: [{
348
+ "type": 0,
349
+ "value": "Duration"
350
+ }]
351
+ }),
352
+ type: 'display',
353
+ display: 'unit',
354
+ format: 'duration',
355
+ name: 'metadata.duration'
356
+ }]
357
+ }];
341
358
 
342
359
  var propTypes$7 = {
343
360
  value: PropTypes.shape({
@@ -346,8 +363,8 @@ var propTypes$7 = {
346
363
  fields: PropTypes.arrayOf(PropTypes.shape({
347
364
  name: PropTypes.string
348
365
  })),
349
- onChange: PropTypes.func.isRequired,
350
- onSave: PropTypes.func.isRequired,
366
+ onChange: PropTypes.func,
367
+ onSave: PropTypes.func,
351
368
  onDelete: PropTypes.func,
352
369
  onClose: PropTypes.func,
353
370
  className: PropTypes.string,
@@ -356,8 +373,10 @@ var propTypes$7 = {
356
373
  var defaultProps$7 = {
357
374
  value: null,
358
375
  fields: defaultFields,
359
- onClose: null,
376
+ onChange: null,
377
+ onSave: null,
360
378
  onDelete: null,
379
+ onClose: null,
361
380
  className: null,
362
381
  children: null
363
382
  };
@@ -405,13 +424,13 @@ function MediaForm(_ref) {
405
424
  _ref3$id = _ref3.id,
406
425
  id = _ref3$id === void 0 ? null : _ref3$id;
407
426
  destroy(id, initialValue).then(function () {
408
- if (onClose !== null) {
409
- onClose();
410
- }
411
427
  if (onDelete !== null) {
412
428
  onDelete();
413
429
  }
414
430
  setChanged(false);
431
+ if (onClose !== null) {
432
+ onClose();
433
+ }
415
434
  });
416
435
  }, [initialValue, destroy, destroying, setChanged]);
417
436
  var postForm = useCallback(function (action, data) {
@@ -433,16 +452,16 @@ function MediaForm(_ref) {
433
452
  generalError = _useForm.generalError;
434
453
  return /*#__PURE__*/React.createElement("div", {
435
454
  className: classNames(['text-body', _defineProperty({}, className, className !== null)])
455
+ }, /*#__PURE__*/React.createElement("nav", {
456
+ className: "navbar d-flex w-100 align-items-end justify-content-between border-bottom mb-3"
436
457
  }, /*#__PURE__*/React.createElement("div", {
437
- className: "d-flex w-100 align-items-start justify-content-between mb-3 pb-2 border-bottom"
438
- }, /*#__PURE__*/React.createElement("div", {
439
- className: "d-flex align-items-end justify-content-end mb-0"
458
+ className: "d-flex align-items-end justify-content-end mb-1"
440
459
  }, /*#__PURE__*/React.createElement("h4", {
441
460
  className: "d-inline text-break mb-0"
442
461
  }, name), /*#__PURE__*/React.createElement("span", {
443
462
  className: "mx-2"
444
463
  }, type)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
445
- className: "me-2 mb-1",
464
+ className: "me-2 mb-1 mt-1",
446
465
  theme: "danger",
447
466
  onClick: onDeleteMedia,
448
467
  disabled: destroying
@@ -453,7 +472,7 @@ function MediaForm(_ref) {
453
472
  "value": "Delete"
454
473
  }]
455
474
  })), onSave !== null ? /*#__PURE__*/React.createElement(Button, {
456
- className: "mb-1",
475
+ className: "mb-1 mt-1",
457
476
  theme: "primary",
458
477
  onClick: onSubmit,
459
478
  disabled: !changed || updating || destroying
@@ -895,6 +914,10 @@ function MediasBrowser(_ref) {
895
914
  onSelectItems(media);
896
915
  onQueryReset();
897
916
  }, [setCurrentMedia, onQueryReset, onSelectItems]);
917
+ var onSaveMedia = useCallback(function () {
918
+ setCurrentMedia(null);
919
+ onQueryReset();
920
+ }, [setCurrentMedia, onQueryReset]);
898
921
  var pagination = /*#__PURE__*/React.createElement(Pagination, {
899
922
  page: page,
900
923
  lastPage: lastPage,
@@ -940,6 +963,8 @@ function MediasBrowser(_ref) {
940
963
  }))), /*#__PURE__*/React.createElement(MediaForm, {
941
964
  value: currentMedia,
942
965
  fields: fields,
966
+ onChange: setCurrentMedia,
967
+ onSave: onSaveMedia,
943
968
  onClose: onCloseMedia
944
969
  })) : /*#__PURE__*/React.createElement(React.Fragment, null, buttons !== null ? /*#__PURE__*/React.createElement(Buttons, {
945
970
  items: buttons,
@@ -1274,7 +1299,16 @@ function MediasResourcePicker(_ref) {
1274
1299
  var resourceId = _ref.resource,
1275
1300
  props = _objectWithoutProperties(_ref, _excluded);
1276
1301
  var resource = usePanneauResource(resourceId);
1277
- // console.log('resource', resource);
1302
+ var _ref2 = resource || {},
1303
+ _ref2$index = _ref2.index,
1304
+ index = _ref2$index === void 0 ? null : _ref2$index,
1305
+ _ref2$fields = _ref2.fields,
1306
+ fields = _ref2$fields === void 0 ? null : _ref2$fields;
1307
+ var _ref3 = index || {},
1308
+ _ref3$filters = _ref3.filters,
1309
+ filters = _ref3$filters === void 0 ? null : _ref3$filters,
1310
+ _ref3$columns = _ref3.columns,
1311
+ columns = _ref3$columns === void 0 ? null : _ref3$columns;
1278
1312
  var api = useApi();
1279
1313
  var mediasApi = useMemo(function () {
1280
1314
  return {
@@ -1317,7 +1351,13 @@ function MediasResourcePicker(_ref) {
1317
1351
  }, [api, resource]);
1318
1352
  return /*#__PURE__*/React.createElement(MediasPickerContainer, Object.assign({
1319
1353
  api: mediasApi
1320
- }, props));
1354
+ }, filters !== null ? {
1355
+ filters: filters
1356
+ } : null, fields !== null ? {
1357
+ fields: fields
1358
+ } : null, columns !== null ? {
1359
+ columns: columns
1360
+ } : null, props));
1321
1361
  }
1322
1362
  MediasResourcePicker.propTypes = propTypes;
1323
1363
  MediasResourcePicker.defaultProps = defaultProps;
package/lib/index.js CHANGED
@@ -277,9 +277,8 @@ var defaultFields = [{
277
277
  }]
278
278
  }),
279
279
  component: 'display',
280
- type: 'avatar',
281
- path: 'user',
282
- section: 'info'
280
+ display: 'avatar',
281
+ name: 'user'
283
282
  }, {
284
283
  id: 'created_at',
285
284
  label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
@@ -290,56 +289,74 @@ var defaultFields = [{
290
289
  }]
291
290
  }),
292
291
  component: 'display',
293
- type: 'date',
294
- path: 'created_at',
295
- format: 'yyyy-MM-dd hh:ss',
296
- section: 'info'
292
+ display: 'date',
293
+ name: 'created_at',
294
+ format: 'yyyy-MM-dd hh:ss'
297
295
  }]
298
- }
299
- // {
300
- // id: 'technical',
301
- // component: 'fields',
302
- // title: <FormattedMessage defaultMessage="Technical details" description="Field title" />,
303
- // fields: [
304
- // {
305
- // id: 'format',
306
- // label: <FormattedMessage defaultMessage="Format" description="Field label" />,
307
- // type: 'display',
308
- // component: 'unit',
309
- // format: 'format',
310
- // path: 'format',
311
- // section: 'technical',
312
- // },
313
- // {
314
- // id: 'dimensions',
315
- // label: <FormattedMessage defaultMessage="Dimensions" description="Field label" />,
316
- // type: 'display',
317
- // component: 'unit',
318
- // format: 'dimensions',
319
- // path: 'metadata',
320
- // section: 'technical',
321
- // },
322
- // {
323
- // id: 'size',
324
- // label: <FormattedMessage defaultMessage="Size" description="Field label" />,
325
- // type: 'display',
326
- // component: 'unit',
327
- // format: 'bytes',
328
- // path: 'metadata.size',
329
- // section: 'technical',
330
- // },
331
- // {
332
- // id: 'duration',
333
- // label: <FormattedMessage defaultMessage="Duration" description="Field label" />,
334
- // type: 'display',
335
- // component: 'unit',
336
- // format: 'duration',
337
- // path: 'metadata.duration',
338
- // section: 'technical',
339
- // },
340
- // ],
341
- // },
342
- ];
296
+ }, {
297
+ id: 'technical',
298
+ component: 'fields',
299
+ title: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
300
+ id: "xKUOLG",
301
+ defaultMessage: [{
302
+ "type": 0,
303
+ "value": "Technical details"
304
+ }]
305
+ }),
306
+ fields: [{
307
+ id: 'format',
308
+ label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
309
+ id: "JuxiUN",
310
+ defaultMessage: [{
311
+ "type": 0,
312
+ "value": "Format"
313
+ }]
314
+ }),
315
+ type: 'display',
316
+ display: 'unit',
317
+ format: 'format',
318
+ name: 'format'
319
+ }, {
320
+ id: 'dimensions',
321
+ label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
322
+ id: "rmJBin",
323
+ defaultMessage: [{
324
+ "type": 0,
325
+ "value": "Dimensions"
326
+ }]
327
+ }),
328
+ type: 'display',
329
+ display: 'unit',
330
+ format: 'dimensions',
331
+ name: 'metadata'
332
+ }, {
333
+ id: 'size',
334
+ label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
335
+ id: "g2CRt5",
336
+ defaultMessage: [{
337
+ "type": 0,
338
+ "value": "Size"
339
+ }]
340
+ }),
341
+ type: 'display',
342
+ display: 'unit',
343
+ format: 'bytes',
344
+ name: 'metadata.size'
345
+ }, {
346
+ id: 'duration',
347
+ label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
348
+ id: "wU++NJ",
349
+ defaultMessage: [{
350
+ "type": 0,
351
+ "value": "Duration"
352
+ }]
353
+ }),
354
+ type: 'display',
355
+ display: 'unit',
356
+ format: 'duration',
357
+ name: 'metadata.duration'
358
+ }]
359
+ }];
343
360
 
344
361
  var propTypes$7 = {
345
362
  value: PropTypes.shape({
@@ -348,8 +365,8 @@ var propTypes$7 = {
348
365
  fields: PropTypes.arrayOf(PropTypes.shape({
349
366
  name: PropTypes.string
350
367
  })),
351
- onChange: PropTypes.func.isRequired,
352
- onSave: PropTypes.func.isRequired,
368
+ onChange: PropTypes.func,
369
+ onSave: PropTypes.func,
353
370
  onDelete: PropTypes.func,
354
371
  onClose: PropTypes.func,
355
372
  className: PropTypes.string,
@@ -358,8 +375,10 @@ var propTypes$7 = {
358
375
  var defaultProps$7 = {
359
376
  value: null,
360
377
  fields: defaultFields,
361
- onClose: null,
378
+ onChange: null,
379
+ onSave: null,
362
380
  onDelete: null,
381
+ onClose: null,
363
382
  className: null,
364
383
  children: null
365
384
  };
@@ -407,13 +426,13 @@ function MediaForm(_ref) {
407
426
  _ref3$id = _ref3.id,
408
427
  id = _ref3$id === void 0 ? null : _ref3$id;
409
428
  destroy(id, initialValue).then(function () {
410
- if (onClose !== null) {
411
- onClose();
412
- }
413
429
  if (onDelete !== null) {
414
430
  onDelete();
415
431
  }
416
432
  setChanged(false);
433
+ if (onClose !== null) {
434
+ onClose();
435
+ }
417
436
  });
418
437
  }, [initialValue, destroy, destroying, setChanged]);
419
438
  var postForm = React.useCallback(function (action, data) {
@@ -435,16 +454,16 @@ function MediaForm(_ref) {
435
454
  generalError = _useForm.generalError;
436
455
  return /*#__PURE__*/React.createElement("div", {
437
456
  className: classNames(['text-body', _defineProperty({}, className, className !== null)])
457
+ }, /*#__PURE__*/React.createElement("nav", {
458
+ className: "navbar d-flex w-100 align-items-end justify-content-between border-bottom mb-3"
438
459
  }, /*#__PURE__*/React.createElement("div", {
439
- className: "d-flex w-100 align-items-start justify-content-between mb-3 pb-2 border-bottom"
440
- }, /*#__PURE__*/React.createElement("div", {
441
- className: "d-flex align-items-end justify-content-end mb-0"
460
+ className: "d-flex align-items-end justify-content-end mb-1"
442
461
  }, /*#__PURE__*/React.createElement("h4", {
443
462
  className: "d-inline text-break mb-0"
444
463
  }, name), /*#__PURE__*/React.createElement("span", {
445
464
  className: "mx-2"
446
465
  }, type)), /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Button, {
447
- className: "me-2 mb-1",
466
+ className: "me-2 mb-1 mt-1",
448
467
  theme: "danger",
449
468
  onClick: onDeleteMedia,
450
469
  disabled: destroying
@@ -455,7 +474,7 @@ function MediaForm(_ref) {
455
474
  "value": "Delete"
456
475
  }]
457
476
  })), onSave !== null ? /*#__PURE__*/React.createElement(Button, {
458
- className: "mb-1",
477
+ className: "mb-1 mt-1",
459
478
  theme: "primary",
460
479
  onClick: onSubmit,
461
480
  disabled: !changed || updating || destroying
@@ -897,6 +916,10 @@ function MediasBrowser(_ref) {
897
916
  onSelectItems(media);
898
917
  onQueryReset();
899
918
  }, [setCurrentMedia, onQueryReset, onSelectItems]);
919
+ var onSaveMedia = React.useCallback(function () {
920
+ setCurrentMedia(null);
921
+ onQueryReset();
922
+ }, [setCurrentMedia, onQueryReset]);
900
923
  var pagination = /*#__PURE__*/React.createElement(Pagination, {
901
924
  page: page,
902
925
  lastPage: lastPage,
@@ -942,6 +965,8 @@ function MediasBrowser(_ref) {
942
965
  }))), /*#__PURE__*/React.createElement(MediaForm, {
943
966
  value: currentMedia,
944
967
  fields: fields,
968
+ onChange: setCurrentMedia,
969
+ onSave: onSaveMedia,
945
970
  onClose: onCloseMedia
946
971
  })) : /*#__PURE__*/React.createElement(React.Fragment, null, buttons !== null ? /*#__PURE__*/React.createElement(Buttons, {
947
972
  items: buttons,
@@ -1276,7 +1301,16 @@ function MediasResourcePicker(_ref) {
1276
1301
  var resourceId = _ref.resource,
1277
1302
  props = _objectWithoutProperties(_ref, _excluded);
1278
1303
  var resource = contexts.usePanneauResource(resourceId);
1279
- // console.log('resource', resource);
1304
+ var _ref2 = resource || {},
1305
+ _ref2$index = _ref2.index,
1306
+ index = _ref2$index === void 0 ? null : _ref2$index,
1307
+ _ref2$fields = _ref2.fields,
1308
+ fields = _ref2$fields === void 0 ? null : _ref2$fields;
1309
+ var _ref3 = index || {},
1310
+ _ref3$filters = _ref3.filters,
1311
+ filters = _ref3$filters === void 0 ? null : _ref3$filters,
1312
+ _ref3$columns = _ref3.columns,
1313
+ columns = _ref3$columns === void 0 ? null : _ref3$columns;
1280
1314
  var api = data.useApi();
1281
1315
  var mediasApi = React.useMemo(function () {
1282
1316
  return {
@@ -1319,7 +1353,13 @@ function MediasResourcePicker(_ref) {
1319
1353
  }, [api, resource]);
1320
1354
  return /*#__PURE__*/React.createElement(MediasPickerContainer, Object.assign({
1321
1355
  api: mediasApi
1322
- }, props));
1356
+ }, filters !== null ? {
1357
+ filters: filters
1358
+ } : null, fields !== null ? {
1359
+ fields: fields
1360
+ } : null, columns !== null ? {
1361
+ columns: columns
1362
+ } : null, props));
1323
1363
  }
1324
1364
  MediasResourcePicker.propTypes = propTypes;
1325
1365
  MediasResourcePicker.defaultProps = defaultProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/medias",
3
- "version": "3.0.160",
3
+ "version": "3.0.163",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -46,21 +46,21 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@babel/runtime": "^7.12.5",
49
- "@panneau/core": "^3.0.160",
50
- "@panneau/data": "^3.0.160",
51
- "@panneau/element-button": "^3.0.160",
52
- "@panneau/element-buttons": "^3.0.160",
53
- "@panneau/element-form": "^3.0.160",
54
- "@panneau/element-form-status": "^3.0.160",
55
- "@panneau/element-grid": "^3.0.160",
56
- "@panneau/element-icon": "^3.0.160",
57
- "@panneau/element-media-card": "^3.0.160",
58
- "@panneau/element-media-player": "^3.0.160",
59
- "@panneau/element-media-preview": "^3.0.160",
60
- "@panneau/element-pagination": "^3.0.160",
61
- "@panneau/element-table": "^3.0.160",
62
- "@panneau/field-upload": "^3.0.160",
63
- "@panneau/filter-filters": "^3.0.160",
49
+ "@panneau/core": "^3.0.162",
50
+ "@panneau/data": "^3.0.162",
51
+ "@panneau/element-button": "^3.0.162",
52
+ "@panneau/element-buttons": "^3.0.162",
53
+ "@panneau/element-form": "^3.0.162",
54
+ "@panneau/element-form-status": "^3.0.162",
55
+ "@panneau/element-grid": "^3.0.163",
56
+ "@panneau/element-icon": "^3.0.162",
57
+ "@panneau/element-media-card": "^3.0.162",
58
+ "@panneau/element-media-player": "^3.0.162",
59
+ "@panneau/element-media-preview": "^3.0.162",
60
+ "@panneau/element-pagination": "^3.0.162",
61
+ "@panneau/element-table": "^3.0.162",
62
+ "@panneau/field-upload": "^3.0.163",
63
+ "@panneau/filter-filters": "^3.0.162",
64
64
  "classnames": "^2.5.1",
65
65
  "lodash": "^4.17.21",
66
66
  "prop-types": "^15.7.2",
@@ -69,5 +69,5 @@
69
69
  "publishConfig": {
70
70
  "access": "public"
71
71
  },
72
- "gitHead": "71a2a64cd2e0ed3cc921b0ec3b0a69449a4a978c"
72
+ "gitHead": "30b29ec9436fb6ead123625baa0bd1b32d69fcac"
73
73
  }