@panneau/modal-medias-picker 4.0.39 → 4.0.40-alpha.1

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,16 +1,17 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { Media, Resource } from '@panneau/core';
2
3
 
3
4
  interface MediasPickerModalProps {
4
- id: string | number;
5
- value?: Record<string, unknown> | null;
6
- resource?: string | null;
5
+ id: string;
6
+ value?: Media | Media[] | null;
7
+ resource?: Resource | string | null;
7
8
  title?: string | null;
8
9
  multiple?: boolean;
9
- onChange?: ((items: unknown) => void) | null;
10
- onClose?: (() => void) | null;
10
+ onChange?: ((items: Media[]) => void) | null;
11
+ onClosed?: (() => void) | null;
11
12
  confirmButton?: Record<string, unknown> | null;
12
13
  cancelButton?: Record<string, unknown> | null;
13
14
  }
14
- declare function MediasPickerModal({ id, value, resource, title, onChange, onClose, confirmButton, cancelButton, multiple, ...props }: MediasPickerModalProps): react_jsx_runtime.JSX.Element;
15
+ declare function MediasPickerModal({ id, value, resource, title, onChange, onClosed, confirmButton, cancelButton, multiple, ...props }: MediasPickerModalProps): react_jsx_runtime.JSX.Element;
15
16
 
16
17
  export { MediasPickerModal as default };
package/dist/index.js CHANGED
@@ -1,104 +1,203 @@
1
- import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
3
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
4
- import { useState, useCallback } from 'react';
1
+ import { c } from 'react/compiler-runtime';
2
+ import { useState } from 'react';
5
3
  import { FormattedMessage } from 'react-intl';
6
4
  import { MediasResourcePicker, MediasPickerContainer } from '@panneau/medias';
7
5
  import Dialog from '@panneau/modal-dialog';
8
6
  import { jsx } from 'react/jsx-runtime';
9
7
 
10
- var _excluded = ["id", "value", "resource", "title", "onChange", "onClose", "confirmButton", "cancelButton", "multiple"];
11
- function MediasPickerModal(_ref) {
12
- var id = _ref.id,
13
- _ref$value = _ref.value,
14
- value = _ref$value === void 0 ? null : _ref$value,
15
- _ref$resource = _ref.resource,
16
- resource = _ref$resource === void 0 ? null : _ref$resource,
17
- _ref$title = _ref.title,
18
- title = _ref$title === void 0 ? null : _ref$title,
19
- _ref$onChange = _ref.onChange,
20
- onChange = _ref$onChange === void 0 ? null : _ref$onChange,
21
- _ref$onClose = _ref.onClose,
22
- onClose = _ref$onClose === void 0 ? null : _ref$onClose,
23
- _ref$confirmButton = _ref.confirmButton,
24
- confirmButton = _ref$confirmButton === void 0 ? null : _ref$confirmButton,
25
- _ref$cancelButton = _ref.cancelButton,
26
- cancelButton = _ref$cancelButton === void 0 ? null : _ref$cancelButton,
27
- _ref$multiple = _ref.multiple,
28
- multiple = _ref$multiple === void 0 ? false : _ref$multiple,
29
- props = _objectWithoutProperties(_ref, _excluded);
30
- var _useState = useState(value),
31
- _useState2 = _slicedToArray(_useState, 2),
32
- selectedItems = _useState2[0],
33
- setSelectedItems = _useState2[1];
34
- var onConfirm = useCallback(function () {
35
- if (onChange !== null) {
36
- onChange(selectedItems);
37
- }
38
- if (onClose !== null) {
39
- onClose();
40
- }
41
- }, [onChange, onClose, selectedItems]);
42
- var onSelectionChange = useCallback(function (items) {
43
- setSelectedItems(items);
44
- }, [setSelectedItems]);
45
- var _useState3 = useState(false),
46
- _useState4 = _slicedToArray(_useState3, 2),
47
- mediaFormOpen = _useState4[0],
48
- setMediaFormOpen = _useState4[1];
49
- var onMediaFormOpen = useCallback(function () {
50
- setMediaFormOpen(true);
51
- }, [setMediaFormOpen]);
52
- var onMediaFormClose = useCallback(function () {
53
- setMediaFormOpen(false);
54
- }, [setMediaFormOpen]);
55
- return /*#__PURE__*/jsx(Dialog, {
56
- id: id || 'picker',
57
- size: "xl",
58
- onClose: onClose,
59
- title: title,
60
- buttons: !mediaFormOpen ? [_objectSpread({
61
- id: 'cancel',
62
- name: 'cancel',
8
+ function MediasPickerModal(t0) {
9
+ const $ = c(35);
10
+ let id;
11
+ let props;
12
+ let t1;
13
+ let t2;
14
+ let t3;
15
+ let t4;
16
+ let t5;
17
+ let t6;
18
+ let t7;
19
+ let t8;
20
+ if ($[0] !== t0) {
21
+ ({
22
+ id,
23
+ value: t1,
24
+ resource: t2,
25
+ title: t3,
26
+ onChange: t4,
27
+ onClosed: t5,
28
+ confirmButton: t6,
29
+ cancelButton: t7,
30
+ multiple: t8,
31
+ ...props
32
+ } = t0);
33
+ $[0] = t0;
34
+ $[1] = id;
35
+ $[2] = props;
36
+ $[3] = t1;
37
+ $[4] = t2;
38
+ $[5] = t3;
39
+ $[6] = t4;
40
+ $[7] = t5;
41
+ $[8] = t6;
42
+ $[9] = t7;
43
+ $[10] = t8;
44
+ } else {
45
+ id = $[1];
46
+ props = $[2];
47
+ t1 = $[3];
48
+ t2 = $[4];
49
+ t3 = $[5];
50
+ t4 = $[6];
51
+ t5 = $[7];
52
+ t6 = $[8];
53
+ t7 = $[9];
54
+ t8 = $[10];
55
+ }
56
+ const value = t1 === undefined ? null : t1;
57
+ const resource = t2 === undefined ? null : t2;
58
+ const title = t3 === undefined ? null : t3;
59
+ const onChange = t4 === undefined ? null : t4;
60
+ const onClosed = t5 === undefined ? null : t5;
61
+ const confirmButton = t6 === undefined ? null : t6;
62
+ const cancelButton = t7 === undefined ? null : t7;
63
+ const multiple = t8 === undefined ? false : t8;
64
+ const [opened, setOpened] = useState(true);
65
+ let t9;
66
+ if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
67
+ t9 = () => {
68
+ setOpened(false);
69
+ };
70
+ $[11] = t9;
71
+ } else {
72
+ t9 = $[11];
73
+ }
74
+ const requestClose = t9;
75
+ const [selectedItems, setSelectedItems] = useState(value);
76
+ let t10;
77
+ if ($[12] !== onChange || $[13] !== selectedItems) {
78
+ t10 = () => {
79
+ if (onChange !== null) {
80
+ onChange(selectedItems);
81
+ }
82
+ requestClose();
83
+ };
84
+ $[12] = onChange;
85
+ $[13] = selectedItems;
86
+ $[14] = t10;
87
+ } else {
88
+ t10 = $[14];
89
+ }
90
+ const onConfirm = t10;
91
+ let t11;
92
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
93
+ t11 = items => {
94
+ setSelectedItems(items);
95
+ };
96
+ $[15] = t11;
97
+ } else {
98
+ t11 = $[15];
99
+ }
100
+ const onSelectionChange = t11;
101
+ const [mediaFormOpen, setMediaFormOpen] = useState(false);
102
+ let t12;
103
+ if ($[16] === Symbol.for("react.memo_cache_sentinel")) {
104
+ t12 = () => {
105
+ setMediaFormOpen(true);
106
+ };
107
+ $[16] = t12;
108
+ } else {
109
+ t12 = $[16];
110
+ }
111
+ const onMediaFormOpen = t12;
112
+ let t13;
113
+ if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
114
+ t13 = () => {
115
+ setMediaFormOpen(false);
116
+ };
117
+ $[17] = t13;
118
+ } else {
119
+ t13 = $[17];
120
+ }
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",
63
127
  label: /*#__PURE__*/jsx(FormattedMessage, {
64
- id: "PyxZY2",
65
- defaultMessage: [{
66
- "type": 0,
67
- "value": "Cancel"
68
- }]
128
+ id: "PyxZY2"
69
129
  }),
70
- theme: 'secondary',
71
- onClick: onClose
72
- }, cancelButton), _objectSpread({
73
- id: 'confirm',
74
- name: 'confirm',
130
+ theme: "secondary",
131
+ onClick: requestClose,
132
+ ...cancelButton
133
+ }, {
134
+ id: "confirm",
75
135
  label: /*#__PURE__*/jsx(FormattedMessage, {
76
- id: "rvOVCV",
77
- defaultMessage: [{
78
- "type": 0,
79
- "value": "Confirm selection"
80
- }]
136
+ id: "rvOVCV"
81
137
  }),
82
- theme: 'primary',
83
- onClick: onConfirm
84
- }, confirmButton)] : null,
85
- children: resource !== null ? /*#__PURE__*/jsx(MediasResourcePicker, _objectSpread(_objectSpread({}, props), {}, {
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;
147
+ } else {
148
+ t15 = $[22];
149
+ }
150
+ let t16;
151
+ if ($[23] !== multiple || $[24] !== props || $[25] !== resource || $[26] !== selectedItems) {
152
+ t16 = resource !== null ? /*#__PURE__*/jsx(MediasResourcePicker, {
153
+ ...props,
86
154
  value: selectedItems,
87
155
  resource: resource,
88
156
  onChange: onSelectionChange,
89
- onClose: onClose,
157
+ onClose: requestClose,
90
158
  multiple: multiple,
91
159
  onMediaFormOpen: onMediaFormOpen,
92
160
  onMediaFormClose: onMediaFormClose
93
- })) : /*#__PURE__*/jsx(MediasPickerContainer, _objectSpread(_objectSpread({}, props), {}, {
161
+ }) : /*#__PURE__*/jsx(MediasPickerContainer, {
162
+ ...props,
94
163
  value: selectedItems,
95
164
  onChange: onSelectionChange,
96
- onClose: onClose,
165
+ onClose: requestClose,
97
166
  multiple: multiple,
98
167
  onMediaFormOpen: onMediaFormOpen,
99
168
  onMediaFormClose: onMediaFormClose
100
- }))
101
- });
169
+ });
170
+ $[23] = multiple;
171
+ $[24] = props;
172
+ $[25] = resource;
173
+ $[26] = selectedItems;
174
+ $[27] = t16;
175
+ } else {
176
+ t16 = $[27];
177
+ }
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,
182
+ size: "xl",
183
+ visible: opened,
184
+ requestClose: requestClose,
185
+ onClosed: onClosed,
186
+ title: title,
187
+ buttons: t15,
188
+ children: t16
189
+ });
190
+ $[28] = onClosed;
191
+ $[29] = opened;
192
+ $[30] = t14;
193
+ $[31] = t15;
194
+ $[32] = t16;
195
+ $[33] = title;
196
+ $[34] = t17;
197
+ } else {
198
+ t17 = $[34];
199
+ }
200
+ return t17;
102
201
  }
103
202
 
104
203
  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.39",
3
+ "version": "4.0.40-alpha.1",
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.38",
56
- "@panneau/medias": "^4.0.39",
57
- "@panneau/modal-dialog": "^4.0.39",
55
+ "@panneau/core": "^4.0.40-alpha.1",
56
+ "@panneau/medias": "^4.0.40-alpha.1",
57
+ "@panneau/modal-dialog": "^4.0.40-alpha.1",
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": "621c5233f083c1ba95cd46cd427c38361723d5d6"
68
+ "gitHead": "66520f92373b3aa371222b354d60ed3cf3d20c96"
69
69
  }