@panneau/modal-medias-picker 4.0.50 → 4.0.55

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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { Media, Resource } from '@panneau/core';
2
+ import { Media, Resource, Button } from '@panneau/core';
3
3
 
4
4
  interface MediasPickerModalProps {
5
5
  id: string;
@@ -7,11 +7,11 @@ interface MediasPickerModalProps {
7
7
  resource?: Resource | string | null;
8
8
  title?: string | null;
9
9
  multiple?: boolean;
10
- onChange?: ((items: Media[]) => void) | null;
10
+ onChange?: ((items: Media | Media[] | null) => void) | null;
11
11
  onClosed?: (() => void) | null;
12
- confirmButton?: Record<string, unknown> | null;
13
- cancelButton?: Record<string, unknown> | null;
12
+ confirmButton?: Button | null;
13
+ cancelButton?: Button | null;
14
14
  }
15
- declare function MediasPickerModal({ id, value, resource, title, onChange, onClosed, confirmButton, cancelButton, multiple, ...props }: MediasPickerModalProps): react_jsx_runtime.JSX.Element;
15
+ declare function MediasPickerModal({ id, value: initialValue, resource, title, onChange, onClosed, confirmButton, cancelButton, multiple, ...props }: MediasPickerModalProps): react_jsx_runtime.JSX.Element;
16
16
 
17
17
  export { MediasPickerModal as default };
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  import { c } from 'react/compiler-runtime';
2
+ import isArray from 'lodash/isArray';
3
+ import isObject from 'lodash/isObject';
2
4
  import { useState } from 'react';
3
5
  import { FormattedMessage } from 'react-intl';
4
6
  import { MediasResourcePicker, MediasPickerContainer } from '@panneau/medias';
@@ -6,7 +8,7 @@ import Dialog from '@panneau/modal-dialog';
6
8
  import { jsx } from 'react/jsx-runtime';
7
9
 
8
10
  function MediasPickerModal(t0) {
9
- const $ = c(35);
11
+ const $ = c(43);
10
12
  let id;
11
13
  let props;
12
14
  let t1;
@@ -53,7 +55,7 @@ function MediasPickerModal(t0) {
53
55
  t7 = $[9];
54
56
  t8 = $[10];
55
57
  }
56
- const value = t1 === undefined ? null : t1;
58
+ const initialValue = t1 === undefined ? null : t1;
57
59
  const resource = t2 === undefined ? null : t2;
58
60
  const title = t3 === undefined ? null : t3;
59
61
  const onChange = t4 === undefined ? null : t4;
@@ -72,89 +74,104 @@ function MediasPickerModal(t0) {
72
74
  t9 = $[11];
73
75
  }
74
76
  const requestClose = t9;
75
- const [selectedItems, setSelectedItems] = useState(value);
76
77
  let t10;
77
- if ($[12] !== onChange || $[13] !== selectedItems) {
78
- t10 = () => {
78
+ if ($[12] !== initialValue) {
79
+ t10 = () => isObject(initialValue) && !isArray(initialValue) ? [initialValue] : initialValue;
80
+ $[12] = initialValue;
81
+ $[13] = t10;
82
+ } else {
83
+ t10 = $[13];
84
+ }
85
+ const [selectedItems, setSelectedItems] = useState(t10);
86
+ let t11;
87
+ if ($[14] !== multiple || $[15] !== onChange || $[16] !== selectedItems) {
88
+ t11 = () => {
79
89
  if (onChange !== null) {
80
- onChange(selectedItems);
90
+ onChange(!multiple ? selectedItems?.[0] || null : selectedItems);
81
91
  }
82
92
  requestClose();
83
93
  };
84
- $[12] = onChange;
85
- $[13] = selectedItems;
86
- $[14] = t10;
94
+ $[14] = multiple;
95
+ $[15] = onChange;
96
+ $[16] = selectedItems;
97
+ $[17] = t11;
87
98
  } else {
88
- t10 = $[14];
99
+ t11 = $[17];
89
100
  }
90
- const onConfirm = t10;
91
- let t11;
92
- if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
93
- t11 = items => {
101
+ const onConfirm = t11;
102
+ let t12;
103
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
104
+ t12 = items => {
94
105
  setSelectedItems(items);
95
106
  };
96
- $[15] = t11;
107
+ $[18] = t12;
97
108
  } else {
98
- t11 = $[15];
109
+ t12 = $[18];
99
110
  }
100
- const onSelectionChange = t11;
111
+ const onSelectionChange = t12;
101
112
  const [mediaFormOpen, setMediaFormOpen] = useState(false);
102
- let t12;
103
- if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
104
- t12 = () => {
113
+ let t13;
114
+ if ($[19] === Symbol.for("react.memo_cache_sentinel")) {
115
+ t13 = () => {
105
116
  setMediaFormOpen(true);
106
117
  };
107
- $[16] = t12;
118
+ $[19] = t13;
108
119
  } else {
109
- t12 = $[16];
120
+ t13 = $[19];
110
121
  }
111
- const onMediaFormOpen = t12;
112
- let t13;
113
- if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
114
- t13 = () => {
122
+ const onMediaFormOpen = t13;
123
+ let t14;
124
+ if ($[20] === Symbol.for("react.memo_cache_sentinel")) {
125
+ t14 = () => {
115
126
  setMediaFormOpen(false);
116
127
  };
117
- $[17] = t13;
128
+ $[20] = t14;
118
129
  } else {
119
- t13 = $[17];
130
+ t14 = $[20];
120
131
  }
121
- const onMediaFormClose = t13;
122
- const t14 = id || "medias-picker";
123
- let t15;
124
- if ($[18] !== cancelButton || $[19] !== confirmButton || $[20] !== mediaFormOpen || $[21] !== onConfirm) {
125
- t15 = !mediaFormOpen ? [{
126
- id: "cancel",
127
- label: /*#__PURE__*/jsx(FormattedMessage, {
128
- id: "PyxZY2"
129
- }),
130
- theme: "secondary",
131
- onClick: requestClose,
132
- ...cancelButton
133
- }, {
134
- id: "confirm",
135
- label: /*#__PURE__*/jsx(FormattedMessage, {
136
- id: "rvOVCV"
137
- }),
138
- theme: "primary",
139
- onClick: onConfirm,
140
- ...confirmButton
141
- }] : null;
142
- $[18] = cancelButton;
143
- $[19] = confirmButton;
144
- $[20] = mediaFormOpen;
145
- $[21] = onConfirm;
146
- $[22] = t15;
132
+ const onMediaFormClose = t14;
133
+ const t15 = id || "medias-picker";
134
+ let t16;
135
+ if ($[21] !== title) {
136
+ t16 = title ?? /*#__PURE__*/jsx(FormattedMessage, {
137
+ id: "DV8/HU"
138
+ });
139
+ $[21] = title;
140
+ $[22] = t16;
147
141
  } else {
148
- t15 = $[22];
142
+ t16 = $[22];
149
143
  }
150
- let t16;
151
- if ($[23] !== multiple || $[24] !== props || $[25] !== resource || $[26] !== selectedItems) {
152
- t16 = resource !== null ? /*#__PURE__*/jsx(MediasResourcePicker, {
144
+ const t17 = !mediaFormOpen;
145
+ const t18 = !mediaFormOpen;
146
+ let t19;
147
+ if ($[23] === Symbol.for("react.memo_cache_sentinel")) {
148
+ t19 = /*#__PURE__*/jsx(FormattedMessage, {
149
+ id: "rvOVCV"
150
+ });
151
+ $[23] = t19;
152
+ } else {
153
+ t19 = $[23];
154
+ }
155
+ const t20 = selectedItems === null || selectedItems.length === 0;
156
+ let t21;
157
+ if ($[24] !== confirmButton || $[25] !== t20) {
158
+ t21 = {
159
+ ...confirmButton,
160
+ disabled: t20
161
+ };
162
+ $[24] = confirmButton;
163
+ $[25] = t20;
164
+ $[26] = t21;
165
+ } else {
166
+ t21 = $[26];
167
+ }
168
+ let t22;
169
+ if ($[27] !== multiple || $[28] !== props || $[29] !== resource || $[30] !== selectedItems) {
170
+ t22 = resource !== null ? /*#__PURE__*/jsx(MediasResourcePicker, {
153
171
  ...props,
154
172
  value: selectedItems,
155
173
  resource: resource,
156
174
  onChange: onSelectionChange,
157
- onClose: requestClose,
158
175
  multiple: multiple,
159
176
  onMediaFormOpen: onMediaFormOpen,
160
177
  onMediaFormClose: onMediaFormClose
@@ -162,42 +179,51 @@ function MediasPickerModal(t0) {
162
179
  ...props,
163
180
  value: selectedItems,
164
181
  onChange: onSelectionChange,
165
- onClose: requestClose,
166
182
  multiple: multiple,
167
183
  onMediaFormOpen: onMediaFormOpen,
168
184
  onMediaFormClose: onMediaFormClose
169
185
  });
170
- $[23] = multiple;
171
- $[24] = props;
172
- $[25] = resource;
173
- $[26] = selectedItems;
174
- $[27] = t16;
186
+ $[27] = multiple;
187
+ $[28] = props;
188
+ $[29] = resource;
189
+ $[30] = selectedItems;
190
+ $[31] = t22;
175
191
  } else {
176
- t16 = $[27];
192
+ t22 = $[31];
177
193
  }
178
- let t17;
179
- if ($[28] !== onClosed || $[29] !== opened || $[30] !== t14 || $[31] !== t15 || $[32] !== t16 || $[33] !== title) {
180
- t17 = /*#__PURE__*/jsx(Dialog, {
181
- id: t14,
194
+ let t23;
195
+ if ($[32] !== cancelButton || $[33] !== onClosed || $[34] !== onConfirm || $[35] !== opened || $[36] !== t15 || $[37] !== t16 || $[38] !== t17 || $[39] !== t18 || $[40] !== t21 || $[41] !== t22) {
196
+ t23 = /*#__PURE__*/jsx(Dialog, {
197
+ id: t15,
182
198
  size: "xl",
183
199
  visible: opened,
184
200
  requestClose: requestClose,
185
201
  onClosed: onClosed,
186
- title: title,
187
- buttons: t15,
188
- children: t16
202
+ title: t16,
203
+ withCancelButton: t17,
204
+ withSubmitButton: t18,
205
+ submitButtonLabel: t19,
206
+ submitButton: t21,
207
+ className: "modal-fullscreen-lg-down",
208
+ cancelButton: cancelButton,
209
+ onClickSubmit: onConfirm,
210
+ children: t22
189
211
  });
190
- $[28] = onClosed;
191
- $[29] = opened;
192
- $[30] = t14;
193
- $[31] = t15;
194
- $[32] = t16;
195
- $[33] = title;
196
- $[34] = t17;
212
+ $[32] = cancelButton;
213
+ $[33] = onClosed;
214
+ $[34] = onConfirm;
215
+ $[35] = opened;
216
+ $[36] = t15;
217
+ $[37] = t16;
218
+ $[38] = t17;
219
+ $[39] = t18;
220
+ $[40] = t21;
221
+ $[41] = t22;
222
+ $[42] = t23;
197
223
  } else {
198
- t17 = $[34];
224
+ t23 = $[42];
199
225
  }
200
- return t17;
226
+ return t23;
201
227
  }
202
228
 
203
229
  export { MediasPickerModal as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/modal-medias-picker",
3
- "version": "4.0.50",
3
+ "version": "4.0.55",
4
4
  "description": "Medias picker modal",
5
5
  "keywords": [
6
6
  "javascript"
@@ -52,9 +52,9 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@babel/runtime": "^7.28.6",
55
- "@panneau/core": "^4.0.50",
56
- "@panneau/medias": "^4.0.50",
57
- "@panneau/modal-dialog": "^4.0.50",
55
+ "@panneau/core": "^4.0.55",
56
+ "@panneau/medias": "^4.0.55",
57
+ "@panneau/modal-dialog": "^4.0.55",
58
58
  "@uppy/core": "^5.1.1",
59
59
  "@uppy/dashboard": "^5.0.4",
60
60
  "@uppy/react": "^5.1.1",
@@ -65,5 +65,5 @@
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  },
68
- "gitHead": "c5d4004686dae5529035f8eac83571739e24340d"
68
+ "gitHead": "1c9183567fc5bf98ba10fa57c63cf2ed2ae4a054"
69
69
  }