@panneau/field-resource-item 4.0.2 → 4.0.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.
Files changed (2) hide show
  1. package/es/index.js +108 -98
  2. package/package.json +12 -12
package/es/index.js CHANGED
@@ -18,8 +18,7 @@ import ResourceForm from '@panneau/form-resource';
18
18
  import { useResourceValues } from '@panneau/intl';
19
19
  import Dialog from '@panneau/modal-dialog';
20
20
  import ResourceItemsModal from '@panneau/modal-resource-items';
21
-
22
- // TODO: improve the modals (esc key) and switch to FormModal
21
+ import { jsxs, jsx } from 'react/jsx-runtime';
23
22
 
24
23
  function ResourceItemField(_ref) {
25
24
  var _ref$name = _ref.name,
@@ -285,109 +284,120 @@ function ResourceItemField(_ref) {
285
284
  if (reload) reload();
286
285
  }
287
286
  }, [onChange, paginated, defaultPage, reload]);
288
- var form = formOpen ? /*#__PURE__*/React.createElement(ResourceForm, {
287
+ var form = formOpen ? /*#__PURE__*/jsx(ResourceForm, {
289
288
  resource: resource,
290
289
  type: finalType,
291
290
  item: !multiple ? value : null,
292
291
  onSuccess: onFormSuccess,
293
292
  isModal: true
294
293
  }) : null;
295
- return /*#__PURE__*/React.createElement("div", {
296
- className: classNames(['position-relative', _defineProperty({}, className, className != null)])
297
- }, hasValue && !multiple ? /*#__PURE__*/React.createElement("div", {
298
- className: "row"
299
- }, /*#__PURE__*/React.createElement("div", {
300
- className: "col-10 flex-grow-1"
301
- }, /*#__PURE__*/React.createElement(ResourceCard, {
302
- className: "flex-grow-1",
303
- item: value,
304
- getItemLabel: initialGetItemLabel,
305
- getItemDescription: getItemDescription,
306
- getItemImage: getItemImage,
307
- itemLabelPath: itemLabelPath,
308
- itemDescriptionPath: itemDescriptionPath,
309
- itemImagePath: itemImagePath,
310
- itemLabelWithId: itemLabelWithId,
311
- disable: disabled,
312
- onClickEdit: canEdit && !multiple ? formOpen ? onCloseForm : onOpenForm : null,
313
- onClickRemove: onClickRemove,
314
- editButtonLabel: editButtonLabel
315
- }))) : /*#__PURE__*/React.createElement("div", {
316
- className: "row align-items-center"
317
- }, /*#__PURE__*/React.createElement("div", {
318
- className: "col-8 flex-grow-1"
319
- }, /*#__PURE__*/React.createElement(Select, {
320
- className: classNames(['py-1', 'shadow-none', _defineProperty(_defineProperty(_defineProperty({}, disabled, disabled), 'is-invalid', errors !== null), inputClassName, inputClassName !== null)]),
321
- disabled: disabled,
322
- name: name,
323
- value: finalValue,
324
- options: options,
325
- isClearable: true,
326
- isSearchable: true,
327
- placeholder: isMessage(placeholder) ? intl.formatMessage(placeholder) : /*#__PURE__*/React.createElement(FormattedMessage, {
328
- id: "oc3YLT",
329
- defaultMessage: [{
330
- "type": 0,
331
- "value": "Choose an item"
332
- }]
333
- }),
334
- onChange: onValueChange,
335
- onInputChange: onInputChange
336
- // onFocus={onFocus}
337
- ,
338
- onMenuScrollToBottom: onScrollEnd,
339
- multiple: multiple
340
- })), canFind ? /*#__PURE__*/React.createElement("div", {
341
- className: "col-auto"
342
- }, /*#__PURE__*/React.createElement(Button, {
343
- theme: "primary",
344
- icon: findButtonLabel === null ? 'search' : null,
345
- onClick: listOpen ? onCloseList : onOpenList,
346
- outline: true
347
- }, findButtonLabel)) : null, canCreate ? /*#__PURE__*/React.createElement("div", {
348
- className: "col-auto"
349
- }, /*#__PURE__*/React.createElement(Button, {
350
- theme: "primary",
351
- icon: createButtonLabel === null ? 'plus-lg' : null,
352
- onClick: formOpen ? onCloseForm : onOpenForm,
353
- outline: true
354
- }, createButtonLabel)) : null), formOpen ? withoutModal ? /*#__PURE__*/React.createElement("div", {
355
- className: "card mt-4 p-4"
356
- }, form) : /*#__PURE__*/React.createElement(Dialog, {
357
- id: resourceId,
358
- title: hasValue && !multiple ? /*#__PURE__*/React.createElement(FormattedMessage, {
359
- values: resourceValues,
360
- id: "mCfzkJ",
361
- defaultMessage: [{
362
- "type": 0,
363
- "value": "Edit "
364
- }, {
365
- "type": 1,
366
- "value": "a_singular"
367
- }]
368
- }) : /*#__PURE__*/React.createElement(FormattedMessage, {
369
- values: resourceValues,
370
- id: "6viUpq",
371
- defaultMessage: [{
372
- "type": 0,
373
- "value": "Create "
374
- }, {
375
- "type": 1,
376
- "value": "a_singular"
377
- }]
378
- }),
379
- size: "lg",
380
- onClose: onCloseForm
381
- }, form) : null, listOpen ? /*#__PURE__*/React.createElement(ResourceItemsModal, {
382
- resource: resourceId,
383
- onClose: onCloseList,
384
- listProps: {
385
- actions: ['select'],
386
- actionsProps: {
387
- onClickSelect: onSelectListItem
294
+ return /*#__PURE__*/jsxs("div", {
295
+ className: classNames(['position-relative', _defineProperty({}, className, className != null)]),
296
+ children: [hasValue && !multiple ? /*#__PURE__*/jsx("div", {
297
+ className: "row",
298
+ children: /*#__PURE__*/jsx("div", {
299
+ className: "col-10 flex-grow-1",
300
+ children: /*#__PURE__*/jsx(ResourceCard, {
301
+ className: "flex-grow-1",
302
+ item: value,
303
+ getItemLabel: initialGetItemLabel,
304
+ getItemDescription: getItemDescription,
305
+ getItemImage: getItemImage,
306
+ itemLabelPath: itemLabelPath,
307
+ itemDescriptionPath: itemDescriptionPath,
308
+ itemImagePath: itemImagePath,
309
+ itemLabelWithId: itemLabelWithId,
310
+ disable: disabled,
311
+ onClickEdit: canEdit && !multiple ? formOpen ? onCloseForm : onOpenForm : null,
312
+ onClickRemove: onClickRemove,
313
+ editButtonLabel: editButtonLabel
314
+ })
315
+ })
316
+ }) : /*#__PURE__*/jsxs("div", {
317
+ className: "row align-items-center",
318
+ children: [/*#__PURE__*/jsx("div", {
319
+ className: "col-8 flex-grow-1",
320
+ children: /*#__PURE__*/jsx(Select, {
321
+ className: classNames(['py-1', 'shadow-none', _defineProperty(_defineProperty(_defineProperty({}, disabled, disabled), 'is-invalid', errors !== null), inputClassName, inputClassName !== null)]),
322
+ disabled: disabled,
323
+ name: name,
324
+ value: finalValue,
325
+ options: options,
326
+ isClearable: true,
327
+ isSearchable: true,
328
+ placeholder: isMessage(placeholder) ? intl.formatMessage(placeholder) : /*#__PURE__*/jsx(FormattedMessage, {
329
+ id: "oc3YLT",
330
+ defaultMessage: [{
331
+ "type": 0,
332
+ "value": "Choose an item"
333
+ }]
334
+ }),
335
+ onChange: onValueChange,
336
+ onInputChange: onInputChange
337
+ // onFocus={onFocus}
338
+ ,
339
+ onMenuScrollToBottom: onScrollEnd,
340
+ multiple: multiple
341
+ })
342
+ }), canFind ? /*#__PURE__*/jsx("div", {
343
+ className: "col-auto",
344
+ children: /*#__PURE__*/jsx(Button, {
345
+ theme: "primary",
346
+ icon: findButtonLabel === null ? 'search' : null,
347
+ onClick: listOpen ? onCloseList : onOpenList,
348
+ outline: true,
349
+ children: findButtonLabel
350
+ })
351
+ }) : null, canCreate ? /*#__PURE__*/jsx("div", {
352
+ className: "col-auto",
353
+ children: /*#__PURE__*/jsx(Button, {
354
+ theme: "primary",
355
+ icon: createButtonLabel === null ? 'plus-lg' : null,
356
+ onClick: formOpen ? onCloseForm : onOpenForm,
357
+ outline: true,
358
+ children: createButtonLabel
359
+ })
360
+ }) : null]
361
+ }), formOpen ? withoutModal ? /*#__PURE__*/jsx("div", {
362
+ className: "card mt-4 p-4",
363
+ children: form
364
+ }) : /*#__PURE__*/jsx(Dialog, {
365
+ id: resourceId,
366
+ title: hasValue && !multiple ? /*#__PURE__*/jsx(FormattedMessage, {
367
+ values: resourceValues,
368
+ id: "mCfzkJ",
369
+ defaultMessage: [{
370
+ "type": 0,
371
+ "value": "Edit "
372
+ }, {
373
+ "type": 1,
374
+ "value": "a_singular"
375
+ }]
376
+ }) : /*#__PURE__*/jsx(FormattedMessage, {
377
+ values: resourceValues,
378
+ id: "6viUpq",
379
+ defaultMessage: [{
380
+ "type": 0,
381
+ "value": "Create "
382
+ }, {
383
+ "type": 1,
384
+ "value": "a_singular"
385
+ }]
386
+ }),
387
+ size: "lg",
388
+ onClose: onCloseForm,
389
+ children: form
390
+ }) : null, listOpen ? /*#__PURE__*/jsx(ResourceItemsModal, {
391
+ resource: resourceId,
392
+ onClose: onCloseList,
393
+ listProps: {
394
+ actions: ['select'],
395
+ actionsProps: {
396
+ onClickSelect: onSelectListItem
397
+ }
388
398
  }
389
- }
390
- }) : null);
399
+ }) : null]
400
+ });
391
401
  }
392
402
 
393
403
  var definition = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/field-resource-item",
3
- "version": "4.0.2",
3
+ "version": "4.0.4",
4
4
  "description": "An item mapping a resource",
5
5
  "keywords": [
6
6
  "javascript"
@@ -49,16 +49,16 @@
49
49
  },
50
50
  "dependencies": {
51
51
  "@babel/runtime": "^7.12.5",
52
- "@panneau/core": "^4.0.2",
53
- "@panneau/data": "^4.0.2",
54
- "@panneau/element-button": "^4.0.2",
55
- "@panneau/element-resource-card": "^4.0.2",
56
- "@panneau/element-select": "^4.0.2",
57
- "@panneau/form-resource": "^4.0.2",
58
- "@panneau/intl": "^4.0.2",
59
- "@panneau/modal-dialog": "^4.0.2",
60
- "@panneau/modal-resource-form": "^4.0.2",
61
- "@panneau/modal-resource-items": "^4.0.2",
52
+ "@panneau/core": "^4.0.4",
53
+ "@panneau/data": "^4.0.4",
54
+ "@panneau/element-button": "^4.0.4",
55
+ "@panneau/element-resource-card": "^4.0.4",
56
+ "@panneau/element-select": "^4.0.4",
57
+ "@panneau/form-resource": "^4.0.4",
58
+ "@panneau/intl": "^4.0.4",
59
+ "@panneau/modal-dialog": "^4.0.4",
60
+ "@panneau/modal-resource-form": "^4.0.4",
61
+ "@panneau/modal-resource-items": "^4.0.4",
62
62
  "classnames": "^2.5.1",
63
63
  "lodash-es": "^4.17.21",
64
64
  "prop-types": "^15.7.2",
@@ -67,5 +67,5 @@
67
67
  "publishConfig": {
68
68
  "access": "public"
69
69
  },
70
- "gitHead": "53ad0f27e467992c23158732e0f7d39d8615780b"
70
+ "gitHead": "e854451a718c6bc7dcde2b804c9913d8ac0297ff"
71
71
  }