@selfcommunity/react-ui 0.9.0-alpha.0 → 0.9.0-alpha.2

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 (42) hide show
  1. package/lib/cjs/components/CreateEventButton/CreateEventButton.d.ts +2 -2
  2. package/lib/cjs/components/CreateEventButton/CreateEventButton.js +4 -4
  3. package/lib/cjs/components/EditEventButton/EditEventButton.js +1 -1
  4. package/lib/cjs/components/EventForm/EventForm.d.ts +7 -12
  5. package/lib/cjs/components/EventForm/EventForm.js +55 -55
  6. package/lib/cjs/components/EventFormDialog/EventFormDialog.d.ts +48 -0
  7. package/lib/cjs/components/EventFormDialog/EventFormDialog.js +56 -0
  8. package/lib/cjs/components/EventFormDialog/constants.d.ts +1 -0
  9. package/lib/cjs/components/EventFormDialog/constants.js +4 -0
  10. package/lib/cjs/components/EventFormDialog/index.d.ts +3 -0
  11. package/lib/cjs/components/EventFormDialog/index.js +5 -0
  12. package/lib/cjs/components/EventMediaWidget/EventMediaWidget.d.ts +4 -0
  13. package/lib/cjs/components/EventMediaWidget/EventMediaWidget.js +19 -11
  14. package/lib/cjs/components/EventMediaWidget/TriggerButton.d.ts +3 -1
  15. package/lib/cjs/components/EventMediaWidget/TriggerButton.js +6 -3
  16. package/lib/cjs/components/EventMembersWidget/EventMembersWidget.js +27 -3
  17. package/lib/cjs/index.d.ts +3 -1
  18. package/lib/cjs/index.js +9 -5
  19. package/lib/cjs/utils/widget.d.ts +1 -0
  20. package/lib/cjs/utils/widget.js +4 -0
  21. package/lib/esm/components/CreateEventButton/CreateEventButton.d.ts +2 -2
  22. package/lib/esm/components/CreateEventButton/CreateEventButton.js +4 -4
  23. package/lib/esm/components/EditEventButton/EditEventButton.js +1 -1
  24. package/lib/esm/components/EventForm/EventForm.d.ts +7 -12
  25. package/lib/esm/components/EventForm/EventForm.js +56 -56
  26. package/lib/esm/components/EventFormDialog/EventFormDialog.d.ts +48 -0
  27. package/lib/esm/components/EventFormDialog/EventFormDialog.js +53 -0
  28. package/lib/esm/components/EventFormDialog/constants.d.ts +1 -0
  29. package/lib/esm/components/EventFormDialog/constants.js +1 -0
  30. package/lib/esm/components/EventFormDialog/index.d.ts +3 -0
  31. package/lib/esm/components/EventFormDialog/index.js +2 -0
  32. package/lib/esm/components/EventMediaWidget/EventMediaWidget.d.ts +4 -0
  33. package/lib/esm/components/EventMediaWidget/EventMediaWidget.js +20 -12
  34. package/lib/esm/components/EventMediaWidget/TriggerButton.d.ts +3 -1
  35. package/lib/esm/components/EventMediaWidget/TriggerButton.js +6 -2
  36. package/lib/esm/components/EventMembersWidget/EventMembersWidget.js +27 -3
  37. package/lib/esm/index.d.ts +3 -1
  38. package/lib/esm/index.js +3 -1
  39. package/lib/esm/utils/widget.d.ts +1 -0
  40. package/lib/esm/utils/widget.js +4 -0
  41. package/lib/umd/react-ui.js +1 -1
  42. package/package.json +3 -3
@@ -1,5 +1,5 @@
1
1
  import { ButtonProps } from '@mui/material/Button/Button';
2
- import { EventFormProps } from '../EventForm';
2
+ import { EventFormDialogProps } from '../EventFormDialog';
3
3
  export interface CreateEventButtonProps extends ButtonProps {
4
4
  /**
5
5
  * Overrides or extends the styles applied to the component.
@@ -10,7 +10,7 @@ export interface CreateEventButtonProps extends ButtonProps {
10
10
  * Props to spread to CreateGroup component
11
11
  * @default empty object
12
12
  */
13
- EventFormProps?: EventFormProps;
13
+ EventFormDialogComponentProps?: EventFormDialogProps;
14
14
  /**
15
15
  * Any other properties
16
16
  */
@@ -9,7 +9,7 @@ const react_core_1 = require("@selfcommunity/react-core");
9
9
  const classnames_1 = tslib_1.__importDefault(require("classnames"));
10
10
  const react_1 = tslib_1.__importStar(require("react"));
11
11
  const react_intl_1 = require("react-intl");
12
- const EventForm_1 = tslib_1.__importDefault(require("../EventForm"));
12
+ const EventFormDialog_1 = tslib_1.__importDefault(require("../EventFormDialog"));
13
13
  const types_1 = require("@selfcommunity/types");
14
14
  const PREFIX = 'SCCreateEventButton';
15
15
  const classes = {
@@ -40,13 +40,13 @@ const Root = (0, styles_1.styled)(material_1.Button, {
40
40
  * @param inProps
41
41
  */
42
42
  function CreateEventButton(inProps) {
43
- var _a;
43
+ var _a, _b;
44
44
  //PROPS
45
45
  const props = (0, system_1.useThemeProps)({
46
46
  props: inProps,
47
47
  name: PREFIX
48
48
  });
49
- const { className, EventFormProps = {}, children } = props, rest = tslib_1.__rest(props, ["className", "EventFormProps", "children"]);
49
+ const { className, EventFormDialogComponentProps = {}, children } = props, rest = tslib_1.__rest(props, ["className", "EventFormDialogComponentProps", "children"]);
50
50
  // CONTEXT
51
51
  const scUserContext = (0, react_1.useContext)(react_core_1.SCUserContext);
52
52
  // STATE
@@ -78,6 +78,6 @@ function CreateEventButton(inProps) {
78
78
  /**
79
79
  * Renders root object
80
80
  */
81
- return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), onClick: handleClick, variant: "contained", color: "secondary", startIcon: !EventFormProps.event && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "add" })) }, rest, { children: children !== null && children !== void 0 ? children : (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.createEventButton", defaultMessage: "ui.createEventButton" }) })), open && (0, jsx_runtime_1.jsx)(EventForm_1.default, Object.assign({}, EventFormProps, { open: true, onClose: handleClick }))] }));
81
+ return ((0, jsx_runtime_1.jsxs)(react_1.default.Fragment, { children: [(0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), onClick: handleClick, variant: "contained", color: "secondary", startIcon: !((_b = EventFormDialogComponentProps.EventFormComponentProps) === null || _b === void 0 ? void 0 : _b.event) && (0, jsx_runtime_1.jsx)(material_1.Icon, Object.assign({ fontSize: "small" }, { children: "add" })) }, rest, { children: children !== null && children !== void 0 ? children : (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.createEventButton", defaultMessage: "ui.createEventButton" }) })), open && (0, jsx_runtime_1.jsx)(EventFormDialog_1.default, Object.assign({}, EventFormDialogComponentProps, { open: true, onClose: handleClick }))] }));
82
82
  }
83
83
  exports.default = CreateEventButton;
@@ -55,6 +55,6 @@ function EditEventButton(inProps) {
55
55
  /**
56
56
  * Renders root object
57
57
  */
58
- return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ variant: "outlined", className: (0, classnames_1.default)(classes.root, className), EventFormProps: { event: scEvent, onSuccess: handleSuccess } }, rest, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.editEventButton", defaultMessage: "ui.editEventButton" }) })));
58
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ variant: "outlined", className: (0, classnames_1.default)(classes.root, className), EventFormDialogComponentProps: { EventFormComponentProps: { event: scEvent, onSuccess: handleSuccess } } }, rest, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.editEventButton", defaultMessage: "ui.editEventButton" }) })));
59
59
  }
60
60
  exports.default = EditEventButton;
@@ -1,21 +1,11 @@
1
+ import { BoxProps } from '@mui/material';
1
2
  import { SCEventType } from '@selfcommunity/types';
2
- import { BaseDialogProps } from '../../shared/BaseDialog';
3
- export interface EventFormProps extends BaseDialogProps {
3
+ export interface EventFormProps extends BoxProps {
4
4
  /**
5
5
  * Overrides or extends the styles applied to the component.
6
6
  * @default null
7
7
  */
8
8
  className?: string;
9
- /**
10
- * Open dialog
11
- * @default true
12
- */
13
- open?: boolean;
14
- /**
15
- * On dialog close callback function
16
- * @default null
17
- */
18
- onClose?: () => void;
19
9
  /**
20
10
  * Event Object
21
11
  * @default null
@@ -26,6 +16,11 @@ export interface EventFormProps extends BaseDialogProps {
26
16
  * @default null
27
17
  */
28
18
  onSuccess?: (data: SCEventType) => void;
19
+ /**
20
+ * On error callback function
21
+ * @default null
22
+ */
23
+ onError?: (error: any) => void;
29
24
  /**
30
25
  * Any other properties
31
26
  */
@@ -21,7 +21,6 @@ const react_intl_1 = require("react-intl");
21
21
  const Errors_1 = require("../../constants/Errors");
22
22
  const Event_1 = require("../../constants/Event");
23
23
  const PubSub_1 = require("../../constants/PubSub");
24
- const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"));
25
24
  const constants_1 = require("./constants");
26
25
  const EventAddress_1 = tslib_1.__importDefault(require("./EventAddress"));
27
26
  const UploadEventCover_1 = tslib_1.__importDefault(require("./UploadEventCover"));
@@ -74,11 +73,12 @@ const classes = {
74
73
  name: `${constants_1.PREFIX}-name`,
75
74
  description: `${constants_1.PREFIX}-description`,
76
75
  content: `${constants_1.PREFIX}-content`,
76
+ actions: `${constants_1.PREFIX}-actions`,
77
77
  privacySection: `${constants_1.PREFIX}-privacy-section`,
78
78
  privacySectionInfo: `${constants_1.PREFIX}-privacy-section-info`,
79
79
  error: `${constants_1.PREFIX}-error`
80
80
  };
81
- const Root = (0, styles_1.styled)(BaseDialog_1.default, {
81
+ const Root = (0, styles_1.styled)(material_1.Box, {
82
82
  name: constants_1.PREFIX,
83
83
  slot: 'Root'
84
84
  })(() => ({}));
@@ -120,7 +120,7 @@ function EventForm(inProps) {
120
120
  props: inProps,
121
121
  name: constants_1.PREFIX
122
122
  });
123
- const { className, open = true, onClose, onSuccess, event = null } = props, rest = tslib_1.__rest(props, ["className", "open", "onClose", "onSuccess", "event"]);
123
+ const { className, onSuccess, onError, event = null } = props, rest = tslib_1.__rest(props, ["className", "onSuccess", "onError", "event"]);
124
124
  // CONTEXT
125
125
  const scContext = (0, react_core_1.useSCContext)();
126
126
  // INTL
@@ -221,10 +221,9 @@ function EventForm(inProps) {
221
221
  }
222
222
  eventService
223
223
  .then((data) => {
224
- onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
225
224
  notifyChanges(data);
226
- onClose === null || onClose === void 0 ? void 0 : onClose();
227
225
  setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
226
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(data);
228
227
  })
229
228
  .catch((e) => {
230
229
  const _error = (0, api_services_1.formatHttpErrorCode)(e);
@@ -238,8 +237,9 @@ function EventForm(inProps) {
238
237
  }
239
238
  setField((prev) => (Object.assign(Object.assign({}, prev), { ['isSubmitting']: false })));
240
239
  utils_1.Logger.error(Errors_1.SCOPE_SC_UI, e);
240
+ onError === null || onError === void 0 ? void 0 : onError(e);
241
241
  });
242
- }, [field, privateEnabled, visibilityEnabled]);
242
+ }, [field, privateEnabled, visibilityEnabled, onSuccess, onError]);
243
243
  const handleChange = (0, react_1.useCallback)((event) => {
244
244
  const { name, value } = event.target;
245
245
  setField((prev) => (Object.assign(Object.assign({}, prev), { [name]: value })));
@@ -284,56 +284,56 @@ function EventForm(inProps) {
284
284
  /**
285
285
  * Renders root object
286
286
  */
287
- return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ DialogContentProps: { dividers: false }, title: event ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.title.edit", defaultMessage: "ui.eventForm.title.edit" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.title", defaultMessage: "ui.eventForm.title" })), open: open, onClose: onClose, className: (0, classnames_1.default)(classes.root, className), actions: (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ loading: field.isSubmitting, disabled: !field.name ||
288
- !field.startDate ||
289
- !field.startTime ||
290
- !field.endDate ||
291
- !field.endTime ||
292
- (field.location === types_1.SCEventLocationType.ONLINE && !field.link) ||
293
- (field.location === types_1.SCEventLocationType.PERSON && !field.geolocation) ||
294
- (field.recurring !== types_1.SCEventRecurrenceType.NEVER && !field.endDate && !field.endTime) ||
295
- Object.keys(error).length !== 0 ||
296
- field.name.length > Event_1.EVENT_TITLE_MAX_LENGTH ||
297
- field.description.length > Event_1.EVENT_DESCRIPTION_MAX_LENGTH, variant: "contained", onClick: handleSubmit, color: "secondary" }, { children: event ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.button.edit", defaultMessage: "ui.eventForm.button.edit" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.button.create", defaultMessage: "ui.eventForm.button.create" })) })) }, rest, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(material_1.Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: (0, jsx_runtime_1.jsx)(UploadEventCover_1.default, { isCreationMode: true, onChange: handleChangeCover }) })), (0, jsx_runtime_1.jsxs)(material_1.FormGroup, Object.assign({ className: classes.form }, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, InputProps: {
298
- endAdornment: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: Event_1.EVENT_TITLE_MAX_LENGTH - field.name.length }))
299
- }, error: Boolean(field.name.length > Event_1.EVENT_TITLE_MAX_LENGTH) || Boolean(error['nameError']), helperText: field.name.length > Event_1.EVENT_TITLE_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.name.error.maxLength", defaultMessage: "ui.eventForm.name.error.maxLength" })) : error['nameError'] ? (error['nameError']) : null }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.dateTime }, { children: (0, jsx_runtime_1.jsxs)(x_date_pickers_1.LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it_1.default : en_US_1.default }, { children: [(0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDatePicker, { className: classes.picker, disablePast: true, label: field.startDate && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.placeholder", defaultMessage: "ui.eventForm.date.placeholder" }), value: field.startDate, slots: {
300
- textField: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.startDate)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "CalendarIcon" }) }) }))) }) })))
301
- }, slotProps: {
302
- toolbar: {
303
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
304
- // @ts-ignore
305
- toolbarTitle: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.title", defaultMessage: "ui.eventForm.date.title" })
306
- }
307
- }, onChange: (value) => handleChangeDateTime(value, 'startDate') }), (0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileTimePicker, { className: classes.picker, disablePast: disablePastStartTime, label: field.startTime && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.placeholder", defaultMessage: "ui.eventForm.time.placeholder" }), value: field.startTime, slots: {
308
- textField: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.startTime)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "access_time" }) }) }))) }) })))
309
- }, slotProps: {
310
- toolbar: {
311
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
312
- // @ts-ignore
313
- toolbarTitle: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.title", defaultMessage: "ui.eventForm.time.title" })
314
- }
315
- }, onChange: (value) => handleChangeDateTime(value, 'startTime') })] })) })), (0, jsx_runtime_1.jsxs)(material_1.FormControl, Object.assign({ className: classes.frequency }, { children: [field.recurring !== types_1.SCEventRecurrenceType.NEVER && (0, jsx_runtime_1.jsx)(material_1.InputLabel, Object.assign({ id: "recurring" }, { children: `${intl.formatMessage(messages.frequency)}` })), (0, jsx_runtime_1.jsx)(material_1.Select, Object.assign({ name: "recurring", label: field.recurring !== types_1.SCEventRecurrenceType.NEVER && `${intl.formatMessage(messages.frequency)}`, labelId: "recurring", value: field.recurring, onChange: handleChange, displayEmpty: true, renderValue: (selected) => {
316
- if (!selected) {
317
- return (0, jsx_runtime_1.jsx)("em", { children: `${intl.formatMessage(messages.frequencyPlaceholder)}` });
318
- }
319
- return ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventForm.frequency.${selected}.placeholder`, defaultMessage: `ui.eventForm.frequency.${selected}.placeholder` }));
320
- }, startAdornment: (0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "frequency" }) }) })) }, { children: Object.values(types_1.SCEventRecurrenceType).map((f) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ value: f }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventForm.frequency.${f}.placeholder`, defaultMessage: `ui.eventForm.frequency.${f}.placeholder` }) }), f))) }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.dateTime }, { children: (0, jsx_runtime_1.jsxs)(x_date_pickers_1.LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it_1.default : en_US_1.default }, { children: [(0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDatePicker, { className: classes.picker, disablePast: true, minDate: field.startDate, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.end.placeholder", defaultMessage: "ui.eventForm.date.end.placeholder" }), value: field.endDate, slots: {
321
- textField: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endDate)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "calendar_off" }) }) }))) }) })))
322
- }, onChange: (value) => handleChangeDateTime(value, 'endDate'), shouldDisableDate: shouldDisabledDate }), (0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileTimePicker, { className: classes.picker, disablePast: disablePastEndTime, label: field.endTime && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.end.placeholder", defaultMessage: "ui.eventForm.time.end.placeholder" }), value: field.endTime, slots: {
323
- textField: (params) => {
324
- var _a;
325
- return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endTime)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "access_time" }) }) }))) }), error: Boolean(error['endDateError']), helperText: ((_a = error['endDateError']) === null || _a === void 0 ? void 0 : _a.error) ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.end.error.invalid", defaultMessage: "ui.eventForm.time.end.error.invalid" })) : null })));
326
- }
327
- }, onChange: (value) => handleChangeDateTime(value, 'endTime'), shouldDisableTime: shouldDisabledTime })] })) })), (0, jsx_runtime_1.jsx)(EventAddress_1.default, { forwardGeolocationData: handleGeoData, event: event !== null && event !== void 0 ? event : null }), privateEnabled && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.privacySection }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), (0, jsx_runtime_1.jsx)(material_1.Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: event && !field.isPublic }), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public", defaultMessage: "ui.eventForm.privacy.public" })] }))] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", textAlign: "center", className: classes.privacySectionInfo }, { children: field.isPublic ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public.info", defaultMessage: "ui.eventForm.privacy.public.info", values: {
328
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
287
+ return ((0, jsx_runtime_1.jsxs)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className) }, rest, { children: [(0, jsx_runtime_1.jsx)(material_1.Paper, Object.assign({ style: _backgroundCover, classes: { root: classes.cover } }, { children: (0, jsx_runtime_1.jsx)(UploadEventCover_1.default, { isCreationMode: true, onChange: handleChangeCover }) })), (0, jsx_runtime_1.jsxs)(material_1.FormGroup, Object.assign({ className: classes.form }, { children: [(0, jsx_runtime_1.jsx)(material_1.TextField, { required: true, className: classes.name, placeholder: `${intl.formatMessage(messages.name)}`, margin: "normal", value: field.name, name: "name", onChange: handleChange, InputProps: {
288
+ endAdornment: (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: Event_1.EVENT_TITLE_MAX_LENGTH - field.name.length }))
289
+ }, error: Boolean(field.name.length > Event_1.EVENT_TITLE_MAX_LENGTH) || Boolean(error['nameError']), helperText: field.name.length > Event_1.EVENT_TITLE_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.name.error.maxLength", defaultMessage: "ui.eventForm.name.error.maxLength" })) : error['nameError'] ? (error['nameError']) : null }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.dateTime }, { children: (0, jsx_runtime_1.jsxs)(x_date_pickers_1.LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it_1.default : en_US_1.default }, { children: [(0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDatePicker, { className: classes.picker, disablePast: true, label: field.startDate && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.placeholder", defaultMessage: "ui.eventForm.date.placeholder" }), value: field.startDate, slots: {
290
+ textField: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.startDate)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "CalendarIcon" }) }) }))) }) })))
291
+ }, slotProps: {
292
+ toolbar: {
293
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
329
294
  // @ts-ignore
330
- b: (chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks })
331
- } })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private.info", defaultMessage: "ui.eventForm.private.public.info", values: {
332
- // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
295
+ toolbarTitle: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.title", defaultMessage: "ui.eventForm.date.title" })
296
+ }
297
+ }, onChange: (value) => handleChangeDateTime(value, 'startDate') }), (0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileTimePicker, { className: classes.picker, disablePast: disablePastStartTime, label: field.startTime && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.placeholder", defaultMessage: "ui.eventForm.time.placeholder" }), value: field.startTime, slots: {
298
+ textField: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.startTime)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "access_time" }) }) }))) }) })))
299
+ }, slotProps: {
300
+ toolbar: {
301
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore,@typescript-eslint/ban-ts-comment
333
302
  // @ts-ignore
334
- b: (chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks })
335
- } })) }))] }))), (0, jsx_runtime_1.jsx)(material_1.TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
336
- endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((_b = field.description) === null || _b === void 0 ? void 0 : _b.length) ? Event_1.EVENT_DESCRIPTION_MAX_LENGTH - field.description.length : Event_1.EVENT_DESCRIPTION_MAX_LENGTH })))
337
- }, error: Boolean(((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) > Event_1.EVENT_DESCRIPTION_MAX_LENGTH), helperText: ((_d = field.description) === null || _d === void 0 ? void 0 : _d.length) > Event_1.EVENT_DESCRIPTION_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.description.error.maxLength", defaultMessage: "ui.eventForm.description.error.maxLength" })) : null })] }))] }) })));
303
+ toolbarTitle: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.title", defaultMessage: "ui.eventForm.time.title" })
304
+ }
305
+ }, onChange: (value) => handleChangeDateTime(value, 'startTime') })] })) })), (0, jsx_runtime_1.jsxs)(material_1.FormControl, Object.assign({ className: classes.frequency }, { children: [field.recurring !== types_1.SCEventRecurrenceType.NEVER && (0, jsx_runtime_1.jsx)(material_1.InputLabel, Object.assign({ id: "recurring" }, { children: `${intl.formatMessage(messages.frequency)}` })), (0, jsx_runtime_1.jsx)(material_1.Select, Object.assign({ name: "recurring", label: field.recurring !== types_1.SCEventRecurrenceType.NEVER && `${intl.formatMessage(messages.frequency)}`, labelId: "recurring", value: field.recurring, onChange: handleChange, displayEmpty: true, renderValue: (selected) => {
306
+ if (!selected) {
307
+ return (0, jsx_runtime_1.jsx)("em", { children: `${intl.formatMessage(messages.frequencyPlaceholder)}` });
308
+ }
309
+ return ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventForm.frequency.${selected}.placeholder`, defaultMessage: `ui.eventForm.frequency.${selected}.placeholder` }));
310
+ }, startAdornment: (0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "frequency" }) }) })) }, { children: Object.values(types_1.SCEventRecurrenceType).map((f) => ((0, jsx_runtime_1.jsx)(material_1.MenuItem, Object.assign({ value: f }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.eventForm.frequency.${f}.placeholder`, defaultMessage: `ui.eventForm.frequency.${f}.placeholder` }) }), f))) }))] })), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.dateTime }, { children: (0, jsx_runtime_1.jsxs)(x_date_pickers_1.LocalizationProvider, Object.assign({ dateAdapter: AdapterDateFns_1.AdapterDateFns, adapterLocale: scContext.settings.locale.default === 'it' ? it_1.default : en_US_1.default }, { children: [(0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileDatePicker, { className: classes.picker, disablePast: true, minDate: field.startDate, label: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.date.end.placeholder", defaultMessage: "ui.eventForm.date.end.placeholder" }), value: field.endDate, slots: {
311
+ textField: (params) => ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endDate)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "calendar_off" }) }) }))) }) })))
312
+ }, onChange: (value) => handleChangeDateTime(value, 'endDate'), shouldDisableDate: shouldDisabledDate }), (0, jsx_runtime_1.jsx)(x_date_pickers_1.MobileTimePicker, { className: classes.picker, disablePast: disablePastEndTime, label: field.endTime && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.end.placeholder", defaultMessage: "ui.eventForm.time.end.placeholder" }), value: field.endTime, slots: {
313
+ textField: (params) => {
314
+ var _a;
315
+ return ((0, jsx_runtime_1.jsx)(material_1.TextField, Object.assign({}, params, { InputProps: Object.assign(Object.assign({}, params.InputProps), { placeholder: `${intl.formatMessage(messages.endTime)}`, startAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "start" }, { children: (0, jsx_runtime_1.jsx)(material_1.IconButton, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "access_time" }) }) }))) }), error: Boolean(error['endDateError']), helperText: ((_a = error['endDateError']) === null || _a === void 0 ? void 0 : _a.error) ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.time.end.error.invalid", defaultMessage: "ui.eventForm.time.end.error.invalid" })) : null })));
316
+ }
317
+ }, onChange: (value) => handleChangeDateTime(value, 'endTime'), shouldDisableTime: shouldDisabledTime })] })) })), (0, jsx_runtime_1.jsx)(EventAddress_1.default, { forwardGeolocationData: handleGeoData, event: event !== null && event !== void 0 ? event : null }), privateEnabled && ((0, jsx_runtime_1.jsxs)(material_1.Box, Object.assign({ className: classes.privacySection }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Stack, Object.assign({ direction: "row", spacing: 1, alignItems: "center", justifyContent: "center" }, { children: [(0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: !field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "private" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private", defaultMessage: "ui.eventForm.privacy.private" })] })), (0, jsx_runtime_1.jsx)(material_1.Switch, { className: classes.switch, checked: field.isPublic, onChange: () => setField((prev) => (Object.assign(Object.assign({}, prev), { ['isPublic']: !field.isPublic }))), disabled: event && !field.isPublic }), (0, jsx_runtime_1.jsxs)(material_1.Typography, Object.assign({ className: (0, classnames_1.default)(classes.switchLabel, { [classes.active]: field.isPublic }) }, { children: [(0, jsx_runtime_1.jsx)(material_1.Icon, { children: "public" }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public", defaultMessage: "ui.eventForm.privacy.public" })] }))] })), (0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2", textAlign: "center", className: classes.privacySectionInfo }, { children: field.isPublic ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.public.info", defaultMessage: "ui.eventForm.privacy.public.info", values: {
318
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
319
+ // @ts-ignore
320
+ b: (chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks })
321
+ } })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.privacy.private.info", defaultMessage: "ui.eventForm.private.public.info", values: {
322
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
323
+ // @ts-ignore
324
+ b: (chunks) => (0, jsx_runtime_1.jsx)("strong", { children: chunks })
325
+ } })) }))] }))), (0, jsx_runtime_1.jsx)(material_1.TextField, { multiline: true, className: classes.description, placeholder: `${intl.formatMessage(messages.description)}`, margin: "normal", value: field.description, name: "description", onChange: handleChange, InputProps: {
326
+ endAdornment: ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "body2" }, { children: ((_b = field.description) === null || _b === void 0 ? void 0 : _b.length) ? Event_1.EVENT_DESCRIPTION_MAX_LENGTH - field.description.length : Event_1.EVENT_DESCRIPTION_MAX_LENGTH })))
327
+ }, error: Boolean(((_c = field.description) === null || _c === void 0 ? void 0 : _c.length) > Event_1.EVENT_DESCRIPTION_MAX_LENGTH), helperText: ((_d = field.description) === null || _d === void 0 ? void 0 : _d.length) > Event_1.EVENT_DESCRIPTION_MAX_LENGTH ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.description.error.maxLength", defaultMessage: "ui.eventForm.description.error.maxLength" })) : null }), (0, jsx_runtime_1.jsx)(material_1.Box, Object.assign({ className: classes.actions }, { children: (0, jsx_runtime_1.jsx)(lab_1.LoadingButton, Object.assign({ loading: field.isSubmitting, disabled: !field.name ||
328
+ !field.startDate ||
329
+ !field.startTime ||
330
+ !field.endDate ||
331
+ !field.endTime ||
332
+ (field.location === types_1.SCEventLocationType.ONLINE && !field.link) ||
333
+ (field.location === types_1.SCEventLocationType.PERSON && !field.geolocation) ||
334
+ (field.recurring !== types_1.SCEventRecurrenceType.NEVER && !field.endDate && !field.endTime) ||
335
+ Object.keys(error).length !== 0 ||
336
+ field.name.length > Event_1.EVENT_TITLE_MAX_LENGTH ||
337
+ field.description.length > Event_1.EVENT_DESCRIPTION_MAX_LENGTH, variant: "contained", onClick: handleSubmit, color: "secondary" }, { children: event ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.button.edit", defaultMessage: "ui.eventForm.button.edit" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.button.create", defaultMessage: "ui.eventForm.button.create" })) })) }))] }))] })));
338
338
  }
339
339
  exports.default = EventForm;
@@ -0,0 +1,48 @@
1
+ import { BaseDialogProps } from '../../shared/BaseDialog';
2
+ import { EventFormProps } from '../EventForm';
3
+ export interface EventFormDialogProps extends BaseDialogProps {
4
+ /**
5
+ * Overrides or extends the styles applied to the component.
6
+ * @default null
7
+ */
8
+ className?: string;
9
+ /**
10
+ * Open dialog
11
+ * @default true
12
+ */
13
+ open?: boolean;
14
+ /**
15
+ * On dialog close callback function
16
+ * @default null
17
+ */
18
+ onClose?: () => void;
19
+ /**
20
+ * Props to spread to EventForm component
21
+ * @default {}
22
+ */
23
+ EventFormComponentProps?: EventFormProps;
24
+ /**
25
+ * Any other properties
26
+ */
27
+ [p: string]: any;
28
+ }
29
+ /**
30
+ *> API documentation for the Community-JS EventFormDialog component. Learn about the available props and the CSS API.
31
+ *
32
+ #### Import
33
+ ```jsx
34
+ import {EventFormDialog} from '@selfcommunity/react-ui';
35
+ ```
36
+
37
+ #### Component Name
38
+ The name `SCEventFormDialog` can be used when providing style overrides in the theme.
39
+
40
+ #### CSS
41
+
42
+ |Rule Name|Global class|Description|
43
+ |---|---|---|
44
+ |root|.SCEventFormDialog-root|Styles applied to the root element.|
45
+
46
+ * @param inProps
47
+ */
48
+ export default function EventFormDialog(inProps: EventFormDialogProps): JSX.Element;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const styles_1 = require("@mui/material/styles");
6
+ const system_1 = require("@mui/system");
7
+ const classnames_1 = tslib_1.__importDefault(require("classnames"));
8
+ const react_intl_1 = require("react-intl");
9
+ const BaseDialog_1 = tslib_1.__importDefault(require("../../shared/BaseDialog"));
10
+ const constants_1 = require("./constants");
11
+ const EventForm_1 = tslib_1.__importDefault(require("../EventForm"));
12
+ const react_1 = require("react");
13
+ const classes = {
14
+ root: `${constants_1.PREFIX}-root`
15
+ };
16
+ const Root = (0, styles_1.styled)(BaseDialog_1.default, {
17
+ name: constants_1.PREFIX,
18
+ slot: 'Root'
19
+ })(() => ({}));
20
+ /**
21
+ *> API documentation for the Community-JS EventFormDialog component. Learn about the available props and the CSS API.
22
+ *
23
+ #### Import
24
+ ```jsx
25
+ import {EventFormDialog} from '@selfcommunity/react-ui';
26
+ ```
27
+
28
+ #### Component Name
29
+ The name `SCEventFormDialog` can be used when providing style overrides in the theme.
30
+
31
+ #### CSS
32
+
33
+ |Rule Name|Global class|Description|
34
+ |---|---|---|
35
+ |root|.SCEventFormDialog-root|Styles applied to the root element.|
36
+
37
+ * @param inProps
38
+ */
39
+ function EventFormDialog(inProps) {
40
+ //PROPS
41
+ const props = (0, system_1.useThemeProps)({
42
+ props: inProps,
43
+ name: constants_1.PREFIX
44
+ });
45
+ const { className, open = true, onClose, EventFormComponentProps = {} } = props, rest = tslib_1.__rest(props, ["className", "open", "onClose", "EventFormComponentProps"]);
46
+ const handleSuccess = (0, react_1.useCallback)((event) => {
47
+ var _a;
48
+ (_a = EventFormComponentProps.onSuccess) === null || _a === void 0 ? void 0 : _a.call(EventFormComponentProps, event);
49
+ onClose === null || onClose === void 0 ? void 0 : onClose();
50
+ }, [onClose, EventFormComponentProps]);
51
+ /**
52
+ * Renders root object
53
+ */
54
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ DialogContentProps: { dividers: false }, title: (EventFormComponentProps === null || EventFormComponentProps === void 0 ? void 0 : EventFormComponentProps.event) ? ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.title.edit", defaultMessage: "ui.eventForm.title.edit" })) : ((0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventForm.title", defaultMessage: "ui.eventForm.title" })), open: open, onClose: onClose, className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsx)(EventForm_1.default, Object.assign({}, EventFormComponentProps, { onSuccess: handleSuccess })) })));
55
+ }
56
+ exports.default = EventFormDialog;
@@ -0,0 +1 @@
1
+ export declare const PREFIX = "SCEventFormDialog";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PREFIX = void 0;
4
+ exports.PREFIX = 'SCEventFormDialog';
@@ -0,0 +1,3 @@
1
+ import EventFormDialog, { EventFormDialogProps } from './EventFormDialog';
2
+ export default EventFormDialog;
3
+ export { EventFormDialogProps };
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const EventFormDialog_1 = tslib_1.__importDefault(require("./EventFormDialog"));
5
+ exports.default = EventFormDialog_1.default;
@@ -28,6 +28,10 @@ export interface EventMediaWidgetProps extends WidgetProps {
28
28
  * @default {}
29
29
  */
30
30
  dialogProps?: BaseDialogProps;
31
+ /**
32
+ * Limit results
33
+ * @default 10
34
+ */
31
35
  limit?: number;
32
36
  /**
33
37
  * Other props
@@ -69,12 +69,17 @@ function EventMediaWidget(inProps) {
69
69
  const { event, eventId, limit = Pagination_1.DEFAULT_PAGINATION_LIMIT, endpointQueryParams = {
70
70
  limit,
71
71
  offset: Pagination_1.DEFAULT_PAGINATION_OFFSET
72
- }, cacheStrategy, dialogProps } = props, rest = tslib_1.__rest(props, ["event", "eventId", "limit", "endpointQueryParams", "cacheStrategy", "dialogProps"]);
72
+ }, cacheStrategy = utils_1.CacheStrategies.CACHE_FIRST, dialogProps } = props, rest = tslib_1.__rest(props, ["event", "eventId", "limit", "endpointQueryParams", "cacheStrategy", "dialogProps"]);
73
+ // HOOKS
74
+ const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
75
+ const intl = (0, react_intl_1.useIntl)();
76
+ const theme = (0, material_1.useTheme)();
77
+ const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
73
78
  // STATE
74
79
  const [state, dispatch] = (0, react_1.useReducer)(widget_1.dataWidgetReducer, {
75
80
  isLoadingNext: false,
76
81
  next: null,
77
- cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.EVENT_MEDIA_STATE_CACHE_PREFIX_KEY),
82
+ cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.EVENT_MEDIA_STATE_CACHE_PREFIX_KEY, event ? event.id : eventId),
78
83
  cacheStrategy,
79
84
  visibleItems: limit
80
85
  }, widget_1.stateWidgetInitializer);
@@ -88,11 +93,6 @@ function EventMediaWidget(inProps) {
88
93
  const [showSkeleton, setShowSkeleton] = (0, react_1.useState)(null);
89
94
  // CONTEXT
90
95
  const scUserContext = (0, react_core_1.useSCUser)();
91
- // HOOKS
92
- const { scEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
93
- const intl = (0, react_intl_1.useIntl)();
94
- const theme = (0, material_1.useTheme)();
95
- const isMobile = (0, material_1.useMediaQuery)(theme.breakpoints.down('md'));
96
96
  // CONSTS
97
97
  const hasAllow = (0, react_1.useMemo)(() => { var _a; return ((_a = scUserContext.user) === null || _a === void 0 ? void 0 : _a.id) === (scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by.id); }, [scUserContext, scEvent]);
98
98
  const countHiddenMedia = (0, react_1.useMemo)(() => mediasCount - MEDIAS_TO_SHOW, [mediasCount]);
@@ -114,7 +114,7 @@ function EventMediaWidget(inProps) {
114
114
  utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
115
115
  });
116
116
  }
117
- }, [state.isLoadingNext, state.initialized, scEvent]);
117
+ }, [state.isLoadingNext, scEvent, dispatch, setMedias, setMediasCount]);
118
118
  const _fetchNext = (0, react_1.useCallback)((index) => {
119
119
  if (mediasCount > medias.length && index >= 6 && !state.isLoadingNext && state.next) {
120
120
  setPreview(index);
@@ -134,7 +134,7 @@ function EventMediaWidget(inProps) {
134
134
  utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
135
135
  });
136
136
  }
137
- }, [state.next, state.isLoadingNext, medias.length]);
137
+ }, [state.next, state.isLoadingNext, medias, mediasCount, dispatch, setPreview]);
138
138
  const handleOpenLightbox = (0, react_1.useCallback)((index) => {
139
139
  setPreview(index);
140
140
  }, [setPreview]);
@@ -187,7 +187,7 @@ function EventMediaWidget(inProps) {
187
187
  .catch((error) => {
188
188
  utils_1.Logger.error(Errors_1.SCOPE_SC_UI, error);
189
189
  });
190
- }, [scEvent, mediaId, setMedias, setLoading, setOpenDialogConfirm, dispatch]);
190
+ }, [scEvent, mediaId, setMedias, setLoading, setOpenDialogConfirm, dispatch, setMediasCount]);
191
191
  const handleCloseAction = (0, react_1.useCallback)(() => {
192
192
  setMediaId(null);
193
193
  setOpenDialogConfirm(false);
@@ -216,9 +216,17 @@ function EventMediaWidget(inProps) {
216
216
  _t = setTimeout(_initComponent);
217
217
  return () => {
218
218
  clearTimeout(_t);
219
+ if (state.initialized) {
220
+ dispatch({
221
+ type: widget_1.actionWidgetTypes.INITIALIZE,
222
+ payload: {
223
+ cacheKey: react_core_1.SCCache.getWidgetStateCacheKey(react_core_1.SCCache.EVENT_MEDIA_STATE_CACHE_PREFIX_KEY, scEvent.id)
224
+ }
225
+ });
226
+ }
219
227
  };
220
228
  }
221
- }, [scUserContext.user, scEvent]);
229
+ }, [scUserContext.user, scEvent, state.initialized]);
222
230
  (0, react_1.useEffect)(() => {
223
231
  if (isMobile && openDialog && state.next) {
224
232
  handleNext();
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { LoadingButtonProps } from '@mui/lab';
2
3
  import { SCMediaType } from '@selfcommunity/types';
3
4
  export interface TriggerIconButtonProps extends LoadingButtonProps {
@@ -12,4 +13,5 @@ export interface TriggerIconButtonProps extends LoadingButtonProps {
12
13
  */
13
14
  isSquare?: boolean;
14
15
  }
15
- export default function TriggerButton(props: TriggerIconButtonProps): JSX.Element;
16
+ declare const _default: import("react").ForwardRefExoticComponent<Pick<TriggerIconButtonProps, "id" | "role" | "className" | "style" | "classes" | "form" | "slot" | "title" | "key" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "contentEditable" | "contextMenu" | "dir" | "draggable" | "hidden" | "lang" | "placeholder" | "spellCheck" | "tabIndex" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "color" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-controls" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-expanded" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "children" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDown" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClick" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEnd" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "sx" | "variant" | "name" | "type" | "href" | "autoFocus" | "disabled" | "formAction" | "formEncType" | "formMethod" | "formNoValidate" | "formTarget" | "value" | "action" | "loading" | "size" | "centerRipple" | "disableRipple" | "disableTouchRipple" | "focusRipple" | "focusVisibleClassName" | "LinkComponent" | "onFocusVisible" | "TouchRippleProps" | "touchRippleRef" | "disableElevation" | "disableFocusRipple" | "endIcon" | "fullWidth" | "startIcon" | "loadingIndicator" | "loadingPosition" | "onAdd" | "isSquare"> & import("react").RefAttributes<HTMLButtonElement>>;
17
+ export default _default;
@@ -27,7 +27,7 @@ const Root = (0, styles_1.styled)(lab_1.LoadingButton, {
27
27
  shouldForwardProp: (prop) => prop !== 'isSquare'
28
28
  })(() => ({}));
29
29
  const GalleryUploadStack = (0, asUploadButton_1.default)((0, react_1.forwardRef)((props, ref) => (0, jsx_runtime_1.jsx)(material_1.Stack, Object.assign({}, props, { "aria-label": "upload", ref: ref }))), { accept: 'image/*' });
30
- function TriggerButton(props) {
30
+ function TriggerButton(props, ref) {
31
31
  // PROPS
32
32
  const { className, onAdd = null, isSquare = false } = props, rest = tslib_1.__rest(props, ["className", "onAdd", "isSquare"]);
33
33
  // STATE
@@ -58,6 +58,9 @@ function TriggerButton(props) {
58
58
  return ((0, jsx_runtime_1.jsxs)(chunked_uploady_1.default, Object.assign({ destination: {
59
59
  url: api_services_1.Endpoints.ComposerChunkUploadMedia.url(),
60
60
  method: api_services_1.Endpoints.ComposerChunkUploadMedia.method
61
- }, fileFilter: handleFilterByMime, chunkSize: 204800 }, { children: [(0, jsx_runtime_1.jsx)(MediaChunkUploader_1.default, { onSuccess: handleSuccess, onProgress: handleProgress, onError: handleError, type: "image" }), (0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.triggerRoot) }, rest, { "aria-label": "add media", loading: isUploading, isSquare: isSquare }, { children: (0, jsx_runtime_1.jsxs)(GalleryUploadStack, Object.assign({ className: classes.triggerContent }, { children: [!isSquare && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "caption", component: "p" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMediaWidget.add", defaultMessage: "ui.eventMediaWidget.add" }) }))), (0, jsx_runtime_1.jsx)(Icon_1.default, Object.assign({ className: classes.triggerIcon }, { children: "add" }))] })) }))] })));
61
+ }, fileFilter: handleFilterByMime, chunkSize: 204800 }, { children: [(0, jsx_runtime_1.jsx)(MediaChunkUploader_1.default, { onSuccess: handleSuccess, onProgress: handleProgress, onError: handleError, type: "image" }), (0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(className, classes.triggerRoot), ref: ref }, rest, { "aria-label": "add media", loading: isUploading,
62
+ // eslint-disable-next-line @typescript-eslint/ban-ts-ignore
63
+ // @ts-ignore
64
+ isSquare: isSquare }, { children: (0, jsx_runtime_1.jsxs)(GalleryUploadStack, Object.assign({ className: classes.triggerContent }, { children: [!isSquare && ((0, jsx_runtime_1.jsx)(material_1.Typography, Object.assign({ variant: "caption", component: "p" }, { children: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.eventMediaWidget.add", defaultMessage: "ui.eventMediaWidget.add" }) }))), (0, jsx_runtime_1.jsx)(Icon_1.default, Object.assign({ className: classes.triggerIcon }, { children: "add" }))] })) }))] })));
62
65
  }
63
- exports.default = TriggerButton;
66
+ exports.default = (0, react_1.forwardRef)(TriggerButton);