@irontec/ivoz-ui 1.7.8 → 1.7.10

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.
@@ -1,22 +1,38 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import MenuIcon from '@mui/icons-material/Menu';
3
- import { Box, MenuItem, Typography, useMediaQuery, useTheme, } from '@mui/material';
4
- import { LightButton } from '../../../components/shared/Button/Button.styles';
5
- import { useStoreActions } from '../../../store';
3
+ import { Box, Dialog, DialogActions, DialogContent, MenuItem, Typography, useMediaQuery, useTheme, } from '@mui/material';
4
+ import CloseRoundedIcon from '@mui/icons-material/CloseRounded';
5
+ import { LightButton, SolidButton, } from '../../../components/shared/Button/Button.styles';
6
+ import { useStoreActions, useStoreState } from '../../../store';
6
7
  import Avatar from './Avatar';
7
8
  import Breadcrumbs from './Breadcrumbs';
8
9
  import Settings from './Settings/Settings';
9
10
  import _ from '../../../services/translations/translate';
11
+ import { useState } from 'react';
12
+ import Logo from '../Menu/Logo';
10
13
  export default function Header(props) {
11
14
  const { routeMap, className } = props;
15
+ const [open, setOpen] = useState(false);
12
16
  const resetAuth = useStoreActions((actions) => actions.auth.resetAll);
13
17
  const toggleVisibility = useStoreActions((actions) => actions.menu.toggleVisibility);
18
+ const logo = useStoreState((state) => state.theme.logo);
19
+ const version = useStoreState((state) => state.aboutInfo.version);
20
+ const lastUpdated = useStoreState((state) => state.aboutInfo.lastUpdated);
21
+ const commit = useStoreState((state) => state.aboutInfo.commit);
14
22
  const handleLogout = () => {
15
23
  resetAuth();
16
24
  };
17
25
  const theme = useTheme();
18
26
  const desktop = useMediaQuery(theme.breakpoints.up('md'));
19
- return (_jsxs(Box, Object.assign({ className: className }, { children: [_jsx(Box, Object.assign({ className: 'start' }, { children: _jsx(Breadcrumbs, { desktop: desktop, routeMap: routeMap }) })), _jsxs(Box, Object.assign({ className: 'end' }, { children: [desktop && (_jsxs(_Fragment, { children: [_jsx(Settings, {}), _jsx(Avatar, { children: _jsx(MenuItem, Object.assign({ onClick: handleLogout }, { children: _jsx(Typography, Object.assign({ textAlign: 'center' }, { children: _('Logout') })) }), 'logout') })] })), !desktop && (_jsx(LightButton, Object.assign({ onClick: () => {
27
+ const handleModal = () => {
28
+ setOpen(!open);
29
+ };
30
+ return (_jsxs(Box, Object.assign({ className: className }, { children: [_jsx(Box, Object.assign({ className: 'start' }, { children: _jsx(Breadcrumbs, { desktop: desktop, routeMap: routeMap }) })), _jsxs(Box, Object.assign({ className: 'end' }, { children: [desktop && (_jsxs(_Fragment, { children: [_jsx(Settings, {}), _jsxs(Avatar, { children: [_jsx(MenuItem, Object.assign({ onClick: handleModal }, { children: _jsx(Typography, Object.assign({ textAlign: 'center' }, { children: _('About') })) }), 'about'), _jsx(MenuItem, Object.assign({ onClick: handleLogout }, { children: _jsx(Typography, Object.assign({ textAlign: 'center' }, { children: _('Logout') })) }), 'logout')] })] })), !desktop && (_jsx(LightButton, Object.assign({ onClick: () => {
20
31
  toggleVisibility();
21
- } }, { children: _jsx(MenuIcon, {}) })))] }))] })));
32
+ } }, { children: _jsx(MenuIcon, {}) }))), open && (_jsxs(Dialog, Object.assign({ open: open, onClose: handleModal, keepMounted: true, "aria-labelledby": 'dialog-about', "aria-describedby": 'dialog-about' }, { children: [_jsx(CloseRoundedIcon, { className: 'close-icon', onClick: handleModal }), _jsxs(DialogContent, Object.assign({ className: 'dialog-about' }, { children: [_jsx("img", { src: logo || './logo.svg', className: 'logo' }), _jsxs("p", { children: [_('Version'), ": ", version, " (", commit, ") ", _jsx("br", {}), _('Last update'), ": ", lastUpdated] }), _jsxs(Box, Object.assign({ sx: {
33
+ display: 'flex',
34
+ alignItems: 'center',
35
+ justifyContent: 'center',
36
+ gap: 1,
37
+ }, className: 'logo' }, { children: ["Powered by ", _jsx(Logo, {})] })), _jsx("p", { children: "\u00A92025 Irontec | All rights reserved" })] })), _jsx(DialogActions, { children: _jsx(SolidButton, Object.assign({ onClick: handleModal, sx: { width: '100%' } }, { children: _('ACCEPT') })) })] })))] }))] })));
22
38
  }
@@ -10,8 +10,8 @@ export declare const StyledDialogContentText: import("@emotion/styled").StyledCo
10
10
  noWrap?: boolean | undefined;
11
11
  paragraph?: boolean | undefined;
12
12
  sx?: import("@mui/material").SxProps<import("@mui/material").Theme> | undefined;
13
- variant?: "button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "overline" | "subtitle1" | "subtitle2" | "body1" | "body2" | undefined;
14
- variantMapping?: Partial<Record<"button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "overline" | "subtitle1" | "subtitle2" | "body1" | "body2", string>> | undefined;
13
+ variant?: "button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "subtitle1" | "subtitle2" | "body1" | "body2" | "overline" | undefined;
14
+ variantMapping?: Partial<Record<"button" | "caption" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "inherit" | "subtitle1" | "subtitle2" | "body1" | "body2" | "overline", string>> | undefined;
15
15
  }, "classes"> & import("@mui/material/OverridableComponent").CommonProps & Omit<Pick<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof import("react").HTMLAttributes<HTMLSpanElement>> & {
16
16
  ref?: ((instance: HTMLSpanElement | null) => void) | import("react").RefObject<HTMLSpanElement> | null | undefined;
17
17
  }, "children" | keyof import("@mui/material/OverridableComponent").CommonProps | "sx" | "variant" | "align" | ("color" | "p" | "alignContent" | "alignItems" | "alignSelf" | "bottom" | "boxShadow" | "boxSizing" | "columnGap" | "display" | "flexBasis" | "flexDirection" | "flexGrow" | "flexShrink" | "flexWrap" | "fontFamily" | "fontSize" | "fontStyle" | "fontWeight" | "gridAutoColumns" | "gridAutoFlow" | "gridAutoRows" | "gridTemplateAreas" | "gridTemplateColumns" | "gridTemplateRows" | "height" | "justifyContent" | "justifyItems" | "justifySelf" | "left" | "letterSpacing" | "lineHeight" | "marginBottom" | "marginLeft" | "marginRight" | "marginTop" | "maxHeight" | "maxWidth" | "minHeight" | "minWidth" | "order" | "paddingBottom" | "paddingLeft" | "paddingRight" | "paddingTop" | "position" | "right" | "rowGap" | "textAlign" | "textOverflow" | "textTransform" | "top" | "visibility" | "whiteSpace" | "width" | "zIndex" | "border" | "borderBottom" | "borderColor" | "borderLeft" | "borderRadius" | "borderRight" | "borderTop" | "flex" | "gap" | "gridArea" | "gridColumn" | "gridRow" | "margin" | "overflow" | "padding" | "bgcolor" | "m" | "mt" | "mr" | "mb" | "ml" | "mx" | "marginX" | "my" | "marginY" | "pt" | "pr" | "pb" | "pl" | "px" | "paddingX" | "py" | "paddingY" | "typography" | "displayPrint") | "noWrap" | "gutterBottom" | "paragraph" | "variantMapping"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
package/css/main.css CHANGED
@@ -323,6 +323,12 @@ code {
323
323
  .MuiDialog-paper .MuiDialogActions-root button {
324
324
  flex-grow: 1;
325
325
  }
326
+ .MuiDialog-paper .logo svg {
327
+ height: 12px;
328
+ }
329
+ .MuiDialog-paper img.logo {
330
+ height: 50px;
331
+ }
326
332
 
327
333
  :root {
328
334
  /** COLORS **/
@@ -0,0 +1,12 @@
1
+ import { Language } from 'store/i18n';
2
+ import { useFormikType } from 'services';
3
+ import { FormOnChangeEvent } from 'entities';
4
+ declare type Params = {
5
+ formik?: useFormikType;
6
+ languages: Array<Language>;
7
+ changeHandler: (e: FormOnChangeEvent) => void;
8
+ };
9
+ export declare const useMultilangSync: ({ formik, languages, changeHandler, }: Params) => {
10
+ handleChange: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
11
+ };
12
+ export {};
@@ -0,0 +1,32 @@
1
+ import { useRef } from 'react';
2
+ export const useMultilangSync = ({ formik, languages, changeHandler, }) => {
3
+ const propagateTimeoutRef = useRef(null);
4
+ const latestTypingRef = useRef(null);
5
+ const handleChange = (e) => {
6
+ changeHandler(e);
7
+ const [fieldKey, currentLang] = e.target.name.split('.');
8
+ const currentValue = e.target.value;
9
+ latestTypingRef.current = { lang: currentLang, value: currentValue };
10
+ if (propagateTimeoutRef.current) {
11
+ clearTimeout(propagateTimeoutRef.current);
12
+ }
13
+ propagateTimeoutRef.current = setTimeout(() => {
14
+ if (!latestTypingRef.current) {
15
+ return;
16
+ }
17
+ const { lang: typingLang, value: typingValue } = latestTypingRef.current;
18
+ const updatedValues = {};
19
+ languages.forEach((lng) => {
20
+ var _a, _b, _c;
21
+ const locale = (_b = (_a = lng.locale) === null || _a === void 0 ? void 0 : _a.split('-')[0]) !== null && _b !== void 0 ? _b : 'en';
22
+ const existingVal = (_c = formik === null || formik === void 0 ? void 0 : formik.values[fieldKey]) === null || _c === void 0 ? void 0 : _c[locale];
23
+ updatedValues[locale] =
24
+ locale === typingLang || !(existingVal === null || existingVal === void 0 ? void 0 : existingVal.trim())
25
+ ? typingValue
26
+ : existingVal;
27
+ });
28
+ formik === null || formik === void 0 ? void 0 : formik.setFieldValue(fieldKey, updatedValues);
29
+ }, 1800);
30
+ };
31
+ return { handleChange };
32
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@irontec/ivoz-ui",
3
- "version": "1.7.8",
3
+ "version": "1.7.10",
4
4
  "description": "UI library used in ivozprovider",
5
5
  "license": "GPL-3.0",
6
6
  "main": "index.js",
@@ -3,12 +3,18 @@ import { Box } from '@mui/material';
3
3
  import { useStoreState } from 'store';
4
4
  import { StyledFieldset, StyledFieldsetRoot, } from './CustomComponentWrapper.styles';
5
5
  import { StyledMultilangTextField } from './TextField/TextField.styles';
6
+ import { useMultilangSync } from '../../../entities/DefaultEntityBehavior/Form/useMultilangSync';
6
7
  const Multilang = (props) => {
7
8
  const { _columnName, disabled, properties, formik, inputProps, onBlur, changeHandler, } = props;
8
9
  let { InputProps } = props;
9
10
  const languages = useStoreState((state) => state.i18n.languages);
10
11
  const mlValue = (formik === null || formik === void 0 ? void 0 : formik.values[_columnName]) || {};
11
12
  const rootProperty = properties[_columnName];
13
+ const { handleChange } = useMultilangSync({
14
+ formik,
15
+ languages,
16
+ changeHandler,
17
+ });
12
18
  return (_jsx(StyledFieldsetRoot, Object.assign({ label: rootProperty.label, hasChanged: false, required: rootProperty.required, disabled: disabled, className: 'multilang' }, { children: _jsx(StyledFieldset, { children: _jsx(Box, { children: languages === null || languages === void 0 ? void 0 : languages.map((lng) => {
13
19
  var _a, _b, _c;
14
20
  const locale = (_a = lng.locale.split('-').shift()) !== null && _a !== void 0 ? _a : 'en';
@@ -22,7 +28,7 @@ const Multilang = (props) => {
22
28
  const error = formik === null || formik === void 0 ? void 0 : formik.errors[name];
23
29
  InputProps = InputProps !== null && InputProps !== void 0 ? InputProps : {};
24
30
  InputProps.startAdornment = (_jsx("span", Object.assign({ className: 'preffix' }, { children: lng.name.substring(0, 3).toUpperCase() })));
25
- return (_jsx(StyledMultilangTextField, { name: name, type: 'text', multiline: multiline, value: value, disabled: disabled, label: undefined, required: required, onChange: changeHandler, onBlur: onBlur, error: touched && Boolean(error), errorMsg: touched && error, helperText: property.helpText, InputProps: Object.assign({}, InputProps), inputProps: inputProps, hasChanged: false, margin: 'dense', size: 'small' }, name));
31
+ return (_jsx(StyledMultilangTextField, { name: name, type: 'text', multiline: multiline, value: value, disabled: disabled, label: undefined, required: required, onChange: handleChange, onBlur: onBlur, error: touched && Boolean(error), errorMsg: touched && error, helperText: property.helpText, InputProps: Object.assign({}, InputProps), inputProps: inputProps, hasChanged: false, margin: 'dense', size: 'small' }, name));
26
32
  }) }) }) })));
27
33
  };
28
34
  export default Multilang;
@@ -0,0 +1,14 @@
1
+ import { Action } from 'easy-peasy';
2
+ interface AboutInfoState {
3
+ version: string;
4
+ commit: string;
5
+ lastUpdated: string;
6
+ }
7
+ interface AboutInfoActions {
8
+ setVersion: Action<AboutInfoState, string>;
9
+ setCommit: Action<AboutInfoState, string>;
10
+ setLastUpdated: Action<AboutInfoState, string>;
11
+ }
12
+ export declare type AboutInfoStore = AboutInfoActions & AboutInfoState;
13
+ declare const aboutInfo: AboutInfoStore;
14
+ export default aboutInfo;
@@ -0,0 +1,16 @@
1
+ import { action } from 'easy-peasy';
2
+ const aboutInfo = {
3
+ version: 'development',
4
+ commit: 'HEAD',
5
+ lastUpdated: 'now',
6
+ setVersion: action((state, version) => {
7
+ state.version = version;
8
+ }),
9
+ setCommit: action((state, commit) => {
10
+ state.commit = commit;
11
+ }),
12
+ setLastUpdated: action((state, lastUpdated) => {
13
+ state.lastUpdated = lastUpdated;
14
+ }),
15
+ };
16
+ export default aboutInfo;
package/store/index.d.ts CHANGED
@@ -12,6 +12,7 @@ import { MenuStore } from './menu';
12
12
  import { ThemeStore } from './theme';
13
13
  import { EntitiesStore } from './entities';
14
14
  import { LanguagesStore } from './i18n';
15
+ import { AboutInfoStore } from './aboutInfo';
15
16
  export interface IvozStore {
16
17
  auth: AuthStore;
17
18
  spec: SpecStore;
@@ -25,6 +26,7 @@ export interface IvozStore {
25
26
  entities: EntitiesStore;
26
27
  i18n: LanguagesStore;
27
28
  theme: ThemeStore;
29
+ aboutInfo: AboutInfoStore;
28
30
  }
29
31
  export declare type IvozStoreState = StateMapper<FilterActionTypes<IvozStore>>;
30
32
  export declare const storeModel: IvozStore;
package/store/index.js CHANGED
@@ -12,6 +12,7 @@ import menu from './menu';
12
12
  import theme from './theme';
13
13
  import entities from './entities';
14
14
  import i18n from './i18n';
15
+ import aboutInfo from './aboutInfo';
15
16
  export const storeModel = {
16
17
  auth,
17
18
  spec,
@@ -25,6 +26,7 @@ export const storeModel = {
25
26
  entities,
26
27
  i18n,
27
28
  theme,
29
+ aboutInfo,
28
30
  };
29
31
  StoreContainer.store = createStore(storeModel);
30
32
  const { useStoreActions, useStoreState, useStoreDispatch, useStore } = createTypedHooks();