@selfcommunity/react-ui 0.9.0-alpha.9 → 0.9.1-alpha.0

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 (40) hide show
  1. package/lib/cjs/assets/onBoarding/android.d.ts +1 -1
  2. package/lib/cjs/assets/onBoarding/android.js +1 -1
  3. package/lib/cjs/components/EventHeader/EventHeader.js +5 -40
  4. package/lib/cjs/components/EventMembersWidget/TabContentComponent.js +1 -1
  5. package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.d.ts +2 -2
  6. package/lib/cjs/components/EventSubscribeButton/EventSubscribeButton.js +14 -16
  7. package/lib/cjs/components/Events/Events.js +3 -5
  8. package/lib/cjs/components/NavigationSettingsIconButton/NavigationSettingsIconButton.js +35 -2
  9. package/lib/cjs/components/NavigationToolbar/NavigationToolbar.js +1 -1
  10. package/lib/cjs/components/OnBoardingWidget/ActionsButton.d.ts +7 -0
  11. package/lib/cjs/components/OnBoardingWidget/ActionsButton.js +84 -0
  12. package/lib/cjs/components/OnBoardingWidget/OnBoardingWidget.js +44 -19
  13. package/lib/cjs/components/OnBoardingWidget/Steps/App/App.js +2 -1
  14. package/lib/cjs/components/UserProfileEdit/Section/PublicInfo.js +2 -1
  15. package/lib/cjs/shared/CopyTextArea/index.d.ts +10 -0
  16. package/lib/cjs/shared/CopyTextArea/index.js +71 -0
  17. package/lib/cjs/shared/EventActionsMenu/index.js +11 -15
  18. package/lib/cjs/utils/events.d.ts +2 -0
  19. package/lib/cjs/utils/events.js +10 -0
  20. package/lib/esm/assets/onBoarding/android.d.ts +1 -1
  21. package/lib/esm/assets/onBoarding/android.js +1 -1
  22. package/lib/esm/components/EventHeader/EventHeader.js +6 -41
  23. package/lib/esm/components/EventMembersWidget/TabContentComponent.js +1 -1
  24. package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.d.ts +2 -2
  25. package/lib/esm/components/EventSubscribeButton/EventSubscribeButton.js +16 -18
  26. package/lib/esm/components/Events/Events.js +3 -5
  27. package/lib/esm/components/NavigationSettingsIconButton/NavigationSettingsIconButton.js +38 -5
  28. package/lib/esm/components/NavigationToolbar/NavigationToolbar.js +1 -1
  29. package/lib/esm/components/OnBoardingWidget/ActionsButton.d.ts +7 -0
  30. package/lib/esm/components/OnBoardingWidget/ActionsButton.js +81 -0
  31. package/lib/esm/components/OnBoardingWidget/OnBoardingWidget.js +46 -21
  32. package/lib/esm/components/OnBoardingWidget/Steps/App/App.js +2 -1
  33. package/lib/esm/components/UserProfileEdit/Section/PublicInfo.js +2 -1
  34. package/lib/esm/shared/CopyTextArea/index.d.ts +10 -0
  35. package/lib/esm/shared/CopyTextArea/index.js +68 -0
  36. package/lib/esm/shared/EventActionsMenu/index.js +11 -15
  37. package/lib/esm/utils/events.d.ts +2 -0
  38. package/lib/esm/utils/events.js +6 -0
  39. package/lib/umd/react-ui.js +1 -1
  40. package/package.json +7 -7
@@ -154,6 +154,7 @@ function PublicInfo(props) {
154
154
  }
155
155
  };
156
156
  let content = null;
157
+ console.log(metadataDefinitions);
157
158
  switch (field) {
158
159
  case types_1.SCUserProfileFields.USERNAME:
159
160
  component.element = UsernameTextField_1.default;
@@ -222,7 +223,7 @@ function PublicInfo(props) {
222
223
  return null;
223
224
  default:
224
225
  if (metadataDefinitions && metadataDefinitions[field]) {
225
- return ((0, jsx_runtime_1.jsx)(MetadataField_1.default, Object.assign({ id: field, className: classes.field, name: field, fullWidth: true, label: label, value: user[field] || '', onChange: handleChange(field), disabled: isSaving, error: Boolean(_error), helperText: _error && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.userInfo.metadata.error.${_error}`, defaultMessage: `ui.userInfo.metadata.error.${_error}` }), metadata: metadataDefinitions[field] }, props), field));
226
+ return ((0, jsx_runtime_1.jsx)(MetadataField_1.default, Object.assign({ id: field, className: classes.field, name: field, fullWidth: true, label: label, value: user[field] || '', onChange: handleChange(field), disabled: isSaving || (user[field] && 'editable' in metadataDefinitions[field] && !metadataDefinitions[field].editable), error: Boolean(_error), helperText: _error && (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: `ui.userInfo.metadata.error.${_error}`, defaultMessage: `ui.userInfo.metadata.error.${_error}` }), metadata: metadataDefinitions[field] }, props), field));
226
227
  }
227
228
  break;
228
229
  }
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { BaseTextFieldProps } from '@mui/material/TextField/TextField';
3
+ export interface CopyTextFieldProps extends BaseTextFieldProps {
4
+ className?: string;
5
+ onChange: (value: string) => void;
6
+ onCopy: (value: string) => void;
7
+ value: string;
8
+ label?: string | React.ReactElement;
9
+ }
10
+ export default function CopyTextField(inProps: CopyTextFieldProps): JSX.Element;
@@ -0,0 +1,71 @@
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 react_1 = require("react");
6
+ const styles_1 = require("@mui/material/styles");
7
+ const material_1 = require("@mui/material");
8
+ const system_1 = require("@mui/system");
9
+ const react_intl_1 = require("react-intl");
10
+ const classnames_1 = tslib_1.__importDefault(require("classnames"));
11
+ const PREFIX = 'SCCopyTextField';
12
+ const classes = {
13
+ root: `${PREFIX}-root`,
14
+ btnCopy: `${PREFIX}-btn-copy`
15
+ };
16
+ const Root = (0, styles_1.styled)(material_1.TextField, {
17
+ name: PREFIX,
18
+ slot: 'Root',
19
+ overridesResolver: (props, styles) => styles.root
20
+ })(({ theme }) => ({
21
+ [`& .${classes.btnCopy}`]: {
22
+ color: theme.palette.secondary.main
23
+ }
24
+ }));
25
+ function CopyTextField(inProps) {
26
+ // PROPS
27
+ const props = (0, system_1.useThemeProps)({
28
+ props: inProps,
29
+ name: PREFIX
30
+ });
31
+ const { className, label, onCopy, onChange } = props, rest = tslib_1.__rest(props, ["className", "label", "onCopy", "onChange"]);
32
+ // STATE
33
+ const [value, setValue] = (0, react_1.useState)('https://www.google.com');
34
+ const [openConfirm, setOpenConfirm] = (0, react_1.useState)(false);
35
+ // REF
36
+ const timeout = (0, react_1.useRef)(null);
37
+ // HANDLERS
38
+ const handleChange = (event) => {
39
+ setValue(event.target.value);
40
+ onChange && onChange(event.target.value);
41
+ };
42
+ const handleCopy = (value) => {
43
+ navigator.clipboard.writeText(value).then(function () {
44
+ /* clipboard successfully set */
45
+ hanldeCopySuccess();
46
+ }, function () {
47
+ /* clipboard write failed */
48
+ console.log('Failed to opy text!');
49
+ });
50
+ };
51
+ const hanldeCopySuccess = () => {
52
+ setOpenConfirm(true);
53
+ if (timeout) {
54
+ clearTimeout(timeout.current);
55
+ timeout.current = null;
56
+ }
57
+ timeout.current = setTimeout(() => {
58
+ setOpenConfirm(false);
59
+ onCopy && onCopy(value);
60
+ }, 1500);
61
+ };
62
+ const button = ((0, jsx_runtime_1.jsx)(material_1.IconButton, Object.assign({ "aria-label": "Copy text", edge: "end", onClick: () => handleCopy(value), className: classes.btnCopy }, { children: (0, jsx_runtime_1.jsx)(material_1.Icon, { children: "insert_link" }) })));
63
+ // RENDER
64
+ return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ className: (0, classnames_1.default)(classes.root, className), label: label ? label : (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.shared.copyTextField.textToCopy", defaultMessage: "ui.shared.copyTextField.textToCopy" }), margin: "normal", variant: "outlined", disabled: true, fullWidth: true, value: value, multiline: true, onChange: handleChange, InputProps: {
65
+ disableUnderline: true,
66
+ endAdornment: ((0, jsx_runtime_1.jsx)(material_1.InputAdornment, Object.assign({ position: "end" }, { children: openConfirm ? ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ open: openConfirm, PopperProps: { open: true }, title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.shared.copyTextField.textCopied", defaultMessage: "ui.shared.copyTextField.textCopied" }) }, { children: button }))) : ((0, jsx_runtime_1.jsx)(material_1.Tooltip, Object.assign({ title: (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.shared.copyTextField.textToCopy", defaultMessage: "ui.shared.copyTextField.textToCopy" }) }, { children: button }))) })))
67
+ }, InputLabelProps: {
68
+ shrink: true
69
+ } }, rest)));
70
+ }
71
+ exports.default = CopyTextField;
@@ -2,22 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
- const react_1 = require("react");
6
- const styles_1 = require("@mui/material/styles");
7
5
  const material_1 = require("@mui/material");
8
- const react_intl_1 = require("react-intl");
9
6
  const Icon_1 = tslib_1.__importDefault(require("@mui/material/Icon"));
10
- const classnames_1 = tslib_1.__importDefault(require("classnames"));
7
+ const styles_1 = require("@mui/material/styles");
11
8
  const system_1 = require("@mui/system");
12
- const react_core_1 = require("@selfcommunity/react-core");
13
- const ConfirmDialog_1 = tslib_1.__importDefault(require("../../shared/ConfirmDialog/ConfirmDialog"));
14
9
  const api_services_1 = require("@selfcommunity/api-services");
15
- const EventActionsMenu_1 = require("../../constants/EventActionsMenu");
10
+ const react_core_1 = require("@selfcommunity/react-core");
16
11
  const utils_1 = require("@selfcommunity/utils");
12
+ const classnames_1 = tslib_1.__importDefault(require("classnames"));
17
13
  const notistack_1 = require("notistack");
18
14
  const pubsub_js_1 = tslib_1.__importDefault(require("pubsub-js"));
19
- const PubSub_1 = require("../../constants/PubSub");
15
+ const react_1 = require("react");
16
+ const react_intl_1 = require("react-intl");
20
17
  const EventForm_1 = tslib_1.__importDefault(require("../../components/EventForm"));
18
+ const EventActionsMenu_1 = require("../../constants/EventActionsMenu");
19
+ const PubSub_1 = require("../../constants/PubSub");
20
+ const ConfirmDialog_1 = tslib_1.__importDefault(require("../../shared/ConfirmDialog/ConfirmDialog"));
21
+ const events_1 = require("../../utils/events");
21
22
  const PREFIX = 'SCEventActionsMenu';
22
23
  const classes = {
23
24
  root: `${PREFIX}-root`,
@@ -84,12 +85,7 @@ function EventActionsMenu(inProps) {
84
85
  const scUserContext = (0, react_core_1.useSCUser)();
85
86
  const { scEvent, setSCEvent } = (0, react_core_1.useSCFetchEvent)({ id: eventId, event });
86
87
  const isEventAdmin = (0, react_1.useMemo)(() => { var _a; return scUserContext.user && ((_a = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _a === void 0 ? void 0 : _a.id) === scUserContext.user.id; }, [scUserContext.user, (_a = scEvent === null || scEvent === void 0 ? void 0 : scEvent.managed_by) === null || _a === void 0 ? void 0 : _a.id]);
87
- const isEventFinished = (0, react_1.useMemo)(() => {
88
- if (scEvent && !scEvent.running) {
89
- return new Date().getTime() > new Date(scEvent.end_date || scEvent.start_date).getTime();
90
- }
91
- return false;
92
- }, [scEvent]);
88
+ const isEventFinished = (0, react_1.useMemo)(() => (0, events_1.checkEventFinished)(scEvent), [scEvent]);
93
89
  // HANDLERS
94
90
  const handleOpen = (event) => {
95
91
  setAnchorEl(event.currentTarget);
@@ -155,7 +151,7 @@ function EventActionsMenu(inProps) {
155
151
  const renderList = () => {
156
152
  return [
157
153
  (0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.item, onClick: () => handleAction(EventActionsMenu_1.GET_EVENT_LINK) }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "link" }) }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.shared.eventActionsMenu.item.link", defaultMessage: "ui.shared.eventActionsMenu.item.link" })] }), "link"),
158
- (0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.item, onClick: () => handleAction(EventActionsMenu_1.ADD_EVENT_TO_CALENDAR) }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "CalendarIcon" }) }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.shared.eventActionsMenu.item.calendar", defaultMessage: "ui.shared.eventActionsMenu.item.calendar" })] }), "calendar"),
154
+ !isEventFinished && ((0, jsx_runtime_1.jsxs)(material_1.MenuItem, Object.assign({ className: classes.item, onClick: () => handleAction(EventActionsMenu_1.ADD_EVENT_TO_CALENDAR) }, { children: [(0, jsx_runtime_1.jsx)(material_1.ListItemIcon, { children: (0, jsx_runtime_1.jsx)(Icon_1.default, { children: "CalendarIcon" }) }), (0, jsx_runtime_1.jsx)(react_intl_1.FormattedMessage, { id: "ui.shared.eventActionsMenu.item.calendar", defaultMessage: "ui.shared.eventActionsMenu.item.calendar" })] }), "calendar")),
159
155
  isEventAdmin &&
160
156
  !isEventFinished && [
161
157
  (0, jsx_runtime_1.jsx)(material_1.Divider, {}, "divider"),
@@ -0,0 +1,2 @@
1
+ import { SCEventType } from '@selfcommunity/types';
2
+ export declare function checkEventFinished(event: SCEventType | null): boolean;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkEventFinished = void 0;
4
+ function checkEventFinished(event) {
5
+ if (event && !event.running) {
6
+ return new Date().getTime() > new Date(event.end_date || event.start_date).getTime();
7
+ }
8
+ return false;
9
+ }
10
+ exports.checkEventFinished = checkEventFinished;