@irontec/ivoz-ui 1.7.19 → 1.8.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.
@@ -26,7 +26,7 @@ export const Empty = (props) => {
26
26
  const globalActions = Object.values(entity.customActions).filter((action) => action.global);
27
27
  return (_jsx(Fade, Object.assign({ in: true, style: {
28
28
  transitionDelay: '750ms',
29
- }, unmountOnExit: true }, { children: _jsxs("section", Object.assign({ className: className }, { children: [_jsx("img", { src: 'assets/img/empty.svg', alt: '' }), _jsx("h3", { children: _('No {{entity}} yet', { entity: pluralTitle }) }), _jsx("p", { children: _('You havent created any {{entity}} yet.', {
29
+ }, unmountOnExit: true }, { children: _jsxs("section", Object.assign({ className: className }, { children: [_jsx("img", { src: 'assets/img/empty.svg', alt: '' }), _jsx("h3", { children: _('No {{entity}} yet', { entity: pluralTitle }) }), _jsx("p", { children: _("You haven't created any {{entity}} yet.", {
30
30
  entity: singularTitle,
31
31
  }) }), create && (_jsxs(Box, Object.assign({ className: 'empty-actions' }, { children: [globalActions &&
32
32
  globalActions.length < 2 &&
@@ -58,7 +58,7 @@ const ListContentValue = (props) => {
58
58
  response = _jsx(StyledCheckBoxOutlineBlankIcon, {});
59
59
  }
60
60
  else {
61
- response = _jsx(ListDecorator, { field: columnName, row: row, property: column, entityPath: entityService.getEntity().path });
61
+ response = (_jsx(ListDecorator, { field: columnName, row: row, property: column, entityPath: entityService.getEntity().path }));
62
62
  }
63
63
  if (isDownloadable && isFileType) {
64
64
  response = (_jsx(DownloadFile, { row: row, path: entityService.getEntity().path, fileType: columnName }));
@@ -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
- }, "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>, {}, {}>;
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") | "gutterBottom" | "noWrap" | "paragraph" | "variantMapping"> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme>, {}, {}>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@irontec/ivoz-ui",
3
- "version": "1.7.19",
3
+ "version": "1.8.1",
4
4
  "description": "UI library used in ivozprovider",
5
5
  "license": "GPL-3.0",
6
6
  "main": "index.js",
@@ -57,7 +57,6 @@
57
57
  "i18next-browser-languagedetector": "^7.2.0",
58
58
  "i18next-sprintf-postprocessor": "^0.2.2",
59
59
  "query-string": "^7.0.0",
60
- "react-audio-player": "^0.17.0",
61
60
  "react-color": "^2.19.3",
62
61
  "react-i18next": "^13.0.0",
63
62
  "sync-request": "^6.1.0",
@@ -26,6 +26,11 @@ const DynamicAutocomplete = (props) => {
26
26
  const [currentOption, setCurrentOption] = useState(nullOptionObject);
27
27
  const debounceTimeoutRef = useRef();
28
28
  const loadedValuesRef = useRef(new Set());
29
+ const currentOptionRef = useRef(nullOptionObject);
30
+ const updateCurrentOption = useCallback((option) => {
31
+ currentOptionRef.current = option;
32
+ setCurrentOption(option);
33
+ }, []);
29
34
  useEffect(() => {
30
35
  if (selectOptions && Object.keys(choices).length === 0) {
31
36
  return;
@@ -54,30 +59,30 @@ const DynamicAutocomplete = (props) => {
54
59
  loadedValuesRef.current.add(value);
55
60
  selectOptions({
56
61
  callback: (options) => {
57
- const option = options[0];
62
+ var _a;
63
+ const allChoices = options;
64
+ const option = (_a = allChoices.find((item) => item.id == value)) !== null && _a !== void 0 ? _a : allChoices[0];
58
65
  if (option) {
66
+ updateCurrentOption(option);
59
67
  setArrayChoices((prev) => {
60
68
  const exists = prev.some((item) => item.id == option.id);
61
69
  return exists ? prev : [...prev, option];
62
70
  });
63
71
  }
64
72
  },
65
- }, {
66
- id: value,
67
- });
73
+ }, { id: value });
68
74
  }, [value, selectOptions]);
69
75
  const setOptions = useCallback((options) => {
70
- const isCurrentOptionIncluded = options.some((option) => option.id == (currentOption === null || currentOption === void 0 ? void 0 : currentOption.id));
71
- if (!isCurrentOptionIncluded &&
72
- currentOption &&
73
- currentOption.id !== '__null__') {
74
- options.unshift(currentOption);
76
+ const co = currentOptionRef.current;
77
+ const isCurrentOptionIncluded = options.some((option) => option.id == (co === null || co === void 0 ? void 0 : co.id));
78
+ if (!isCurrentOptionIncluded && co && co.id !== '__null__') {
79
+ options.unshift(co);
75
80
  }
76
81
  if (nullOptionObject) {
77
82
  options.unshift(nullOptionObject);
78
83
  }
79
84
  setArrayChoices(options);
80
- }, [nullOptionObject, currentOption]);
85
+ }, [nullOptionObject]);
81
86
  const clearSearch = useCallback(() => {
82
87
  if (debounceTimeoutRef.current) {
83
88
  clearTimeout(debounceTimeoutRef.current);
@@ -96,14 +101,12 @@ const DynamicAutocomplete = (props) => {
96
101
  setLoading(false);
97
102
  setOptions(options);
98
103
  },
99
- }, {
100
- searchTerm: searchValue,
101
- });
104
+ }, { searchTerm: searchValue });
102
105
  }, 500);
103
- }, [searchTerm, selectOptions]);
106
+ }, [selectOptions, setOptions]);
104
107
  useEffect(() => {
105
108
  clearSearch();
106
- const searchTermMatchNullOption = getOptionLabel(nullOptionObject) === searchTerm;
109
+ const searchTermMatchNullOption = searchTerm !== '' && getOptionLabel(nullOptionObject) === searchTerm;
107
110
  if (searchTermMatchNullOption) {
108
111
  return;
109
112
  }
@@ -144,7 +147,7 @@ const DynamicAutocomplete = (props) => {
144
147
  ? '__null__'
145
148
  : null;
146
149
  }
147
- setCurrentOption(option);
150
+ updateCurrentOption(option);
148
151
  onChange({
149
152
  target: {
150
153
  name: name,
@@ -11,14 +11,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import DownloadRoundedIcon from '@mui/icons-material/DownloadRounded';
12
12
  import UploadFileRoundedIcon from '@mui/icons-material/UploadFileRounded';
13
13
  import { useEffect, useState } from 'react';
14
- import ReactAudioPlayerSrc from 'react-audio-player';
15
14
  import { useStoreActions } from 'store';
16
15
  import { StyledFileNameContainer, StyledFileUploaderContainer, StyledUploadButtonLabel, } from '../FileUploader.styles';
17
16
  import { Box } from '@mui/material';
18
- // see https://github.com/justinmc/react-audio-player/issues/164
19
- const ReactAudioPlayer = process.env.NODE_ENV === 'production'
20
- ? ReactAudioPlayerSrc.default
21
- : ReactAudioPlayerSrc;
17
+ import AudioPlayer from './AudioPlayer';
22
18
  export const AudioFileUploader = (props) => {
23
19
  var _a, _b;
24
20
  const { _columnName, accept, values, disabled, downloadPath, handleDownload, changeHandler, onBlur, } = props;
@@ -63,5 +59,5 @@ export const AudioFileUploader = (props) => {
63
59
  display: 'flex',
64
60
  justifyContent: 'space-between',
65
61
  marginBottom: 'var(--spacing-sm)',
66
- } }, { children: [fileName && (_jsxs(StyledFileNameContainer, Object.assign({ className: disabled ? 'disabled' : '' }, { children: [values.id && _jsx(DownloadRoundedIcon, { onClick: handleDownload }), fileName, " (", fileSizeMb, "MB)"] }))), !disabled && (_jsx(StyledUploadButtonLabel, Object.assign({ htmlFor: id, className: 'upload-icon' }, { children: _jsx(UploadFileRoundedIcon, {}) })))] })), _jsx(ReactAudioPlayer, { src: audioSrc, controls: true })] }), _jsx("div", Object.assign({ className: 'uploader-backdrop' }, { children: "Audio" }))] }));
62
+ } }, { children: [fileName && (_jsxs(StyledFileNameContainer, Object.assign({ className: disabled ? 'disabled' : '' }, { children: [values.id && _jsx(DownloadRoundedIcon, { onClick: handleDownload }), fileName, " (", fileSizeMb, "MB)"] }))), !disabled && (_jsx(StyledUploadButtonLabel, Object.assign({ htmlFor: id, className: 'upload-icon' }, { children: _jsx(UploadFileRoundedIcon, {}) })))] })), _jsx(AudioPlayer, { src: audioSrc })] }), _jsx("div", Object.assign({ className: 'uploader-backdrop' }, { children: "Audio" }))] }));
67
63
  };
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ interface AudioPlayerProps {
3
+ src: string;
4
+ }
5
+ export default function AudioPlayer({ src }: AudioPlayerProps): JSX.Element;
6
+ export {};
@@ -0,0 +1,89 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import PauseRoundedIcon from '@mui/icons-material/PauseRounded';
3
+ import PlayArrowRoundedIcon from '@mui/icons-material/PlayArrowRounded';
4
+ import VolumeUpRoundedIcon from '@mui/icons-material/VolumeUpRounded';
5
+ import VolumeOffRoundedIcon from '@mui/icons-material/VolumeOffRounded';
6
+ import { Box, IconButton, Slider, Typography } from '@mui/material';
7
+ import { useRef, useState, useEffect, useCallback } from 'react';
8
+ function formatTime(seconds) {
9
+ const m = Math.floor(seconds / 60);
10
+ const s = Math.floor(seconds % 60);
11
+ return `${m}:${s.toString().padStart(2, '0')}`;
12
+ }
13
+ export default function AudioPlayer({ src }) {
14
+ const audioRef = useRef(null);
15
+ const [playing, setPlaying] = useState(false);
16
+ const [currentTime, setCurrentTime] = useState(0);
17
+ const [duration, setDuration] = useState(0);
18
+ const [volume, setVolume] = useState(1);
19
+ const [muted, setMuted] = useState(false);
20
+ const [showVolume, setShowVolume] = useState(false);
21
+ const toggle = useCallback(() => {
22
+ const audio = audioRef.current;
23
+ if (!audio)
24
+ return;
25
+ if (playing) {
26
+ audio.pause();
27
+ }
28
+ else {
29
+ audio.play();
30
+ }
31
+ setPlaying(!playing);
32
+ }, [playing]);
33
+ useEffect(() => {
34
+ const audio = audioRef.current;
35
+ if (!audio)
36
+ return;
37
+ const onTime = () => setCurrentTime(audio.currentTime);
38
+ const onMeta = () => setDuration(audio.duration);
39
+ const onEnded = () => setPlaying(false);
40
+ audio.addEventListener('timeupdate', onTime);
41
+ audio.addEventListener('loadedmetadata', onMeta);
42
+ audio.addEventListener('ended', onEnded);
43
+ return () => {
44
+ audio.removeEventListener('timeupdate', onTime);
45
+ audio.removeEventListener('loadedmetadata', onMeta);
46
+ audio.removeEventListener('ended', onEnded);
47
+ };
48
+ }, []);
49
+ const seek = (_, value) => {
50
+ const audio = audioRef.current;
51
+ if (!audio)
52
+ return;
53
+ const t = value;
54
+ audio.currentTime = t;
55
+ setCurrentTime(t);
56
+ };
57
+ return (_jsxs(Box, Object.assign({ sx: {
58
+ display: 'flex',
59
+ alignItems: 'center',
60
+ gap: 1,
61
+ bgcolor: 'grey.100',
62
+ borderRadius: '24px',
63
+ px: 1,
64
+ py: 0.5,
65
+ } }, { children: [_jsx("audio", { ref: audioRef, src: src, preload: 'metadata' }), _jsx(IconButton, Object.assign({ size: 'small', onClick: toggle }, { children: playing ? (_jsx(PauseRoundedIcon, { fontSize: 'small' })) : (_jsx(PlayArrowRoundedIcon, { fontSize: 'small' })) })), _jsxs(Typography, Object.assign({ variant: 'caption', sx: { whiteSpace: 'nowrap', minWidth: 70 } }, { children: [formatTime(currentTime), " / ", formatTime(duration || 0)] })), _jsx(Slider, { size: 'small', min: 0, max: duration || 1, value: currentTime, onChange: seek, sx: { mx: 1, flex: 1, minWidth: 60 } }), _jsxs(Box, Object.assign({ sx: { position: 'relative', display: 'flex', alignItems: 'center' }, onMouseEnter: () => setShowVolume(true), onMouseLeave: () => setShowVolume(false) }, { children: [_jsx(IconButton, Object.assign({ size: 'small', onClick: () => {
66
+ const next = !muted;
67
+ if (audioRef.current) {
68
+ audioRef.current.muted = next;
69
+ }
70
+ setMuted(next);
71
+ } }, { children: muted || volume === 0 ? (_jsx(VolumeOffRoundedIcon, { fontSize: 'small' })) : (_jsx(VolumeUpRoundedIcon, { fontSize: 'small' })) })), showVolume && (_jsx(Box, Object.assign({ sx: {
72
+ position: 'absolute',
73
+ left: '100%',
74
+ display: 'flex',
75
+ alignItems: 'center',
76
+ bgcolor: 'grey.100',
77
+ borderRadius: '12px',
78
+ px: 1,
79
+ width: 80,
80
+ } }, { children: _jsx(Slider, { size: 'small', min: 0, max: 1, step: 0.01, value: muted ? 0 : volume, onChange: (_, v) => {
81
+ const val = v;
82
+ setVolume(val);
83
+ setMuted(val === 0);
84
+ if (audioRef.current) {
85
+ audioRef.current.volume = val;
86
+ audioRef.current.muted = val === 0;
87
+ }
88
+ } }) })))] }))] })));
89
+ }
@@ -50,7 +50,7 @@
50
50
  "Yes, delete it": "Si, eliminar",
51
51
  "You are about to remove": "Esteu a punt d'eliminar-lo",
52
52
  "You are about to update": "Estàs a punt d'actualitzar",
53
- "You havent created any {{entity}} yet.": "Aún no has creado ningún {{entity}}",
53
+ "You haven't created any {{entity}} yet.": "Aún no has creado ningún {{entity}}",
54
54
  "entities": "entitats",
55
55
  "invalid pattern": "Patrón invalido",
56
56
  "required value": "valor requerido",
@@ -50,7 +50,7 @@
50
50
  "Yes, delete it": "Yes, delete it",
51
51
  "You are about to remove": "Stai per rimuovere",
52
52
  "You are about to update": "Stai per aggiornare ",
53
- "You havent created any {{entity}} yet.": "You havent created any {{entity}} yet.",
53
+ "You haven't created any {{entity}} yet.": "You haven't created any {{entity}} yet.",
54
54
  "entities": "entità",
55
55
  "invalid pattern": "invalid pattern",
56
56
  "required value": "required value",