@wavv/ui 2.4.13 → 2.4.15-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,6 +13,9 @@ const Audio = ({ src, title, width, infoPosition, centerAlignContent, small, tin
13
13
  const [displayCurrent, setDisplayCurrent] = useState('');
14
14
  const [displayDuration, setDisplayDuration] = useState('0:00');
15
15
  const audioRef = useRef(null);
16
+ const isSeekingRef = useRef(false);
17
+ const seekedTimeoutRef = useRef(null);
18
+ const END_EPSILON_SECONDS = 0.75;
16
19
  const { height = 30, showHoverTime = false, playedColor, unplayedColor } = 'object' == typeof waveform ? waveform : {};
17
20
  const play = ()=>{
18
21
  const { current: audio } = audioRef;
@@ -88,6 +91,9 @@ const Audio = ({ src, title, width, infoPosition, centerAlignContent, small, tin
88
91
  src,
89
92
  fallbackDuration
90
93
  ]);
94
+ useEffect(()=>()=>{
95
+ if (seekedTimeoutRef.current) clearTimeout(seekedTimeoutRef.current);
96
+ }, []);
91
97
  const formatTime = (time)=>{
92
98
  if (!Number.isFinite(time) || time < 0) return '0:00';
93
99
  const mins = Math.floor(time / 60);
@@ -95,6 +101,7 @@ const Audio = ({ src, title, width, infoPosition, centerAlignContent, small, tin
95
101
  return `${mins}:${secs.toString().padStart(2, '0')}`;
96
102
  };
97
103
  const updateProgress = ()=>{
104
+ if (isSeekingRef.current) return;
98
105
  const { current: audio } = audioRef;
99
106
  if (audio) {
100
107
  const { currentTime } = audio;
@@ -128,9 +135,27 @@ const Audio = ({ src, title, width, infoPosition, centerAlignContent, small, tin
128
135
  }, 100);
129
136
  }
130
137
  };
138
+ const handleSeeked = ()=>{
139
+ isSeekingRef.current = false;
140
+ if (seekedTimeoutRef.current) {
141
+ clearTimeout(seekedTimeoutRef.current);
142
+ seekedTimeoutRef.current = null;
143
+ }
144
+ };
131
145
  const handleControlGrab = (value)=>{
132
146
  const sliderPosition = Array.isArray(value) ? value[0] : value;
133
- if (audioRef?.current && Number.isFinite(sliderPosition) && Number.isFinite(totalDuration) && totalDuration > 0) audioRef.current.currentTime = Math.max(0, Math.min(sliderPosition, totalDuration));
147
+ if (!audioRef?.current || !Number.isFinite(sliderPosition) || !Number.isFinite(totalDuration) || totalDuration <= 0) return;
148
+ const maxSeekTarget = Math.max(0, totalDuration - END_EPSILON_SECONDS);
149
+ const clamped = Math.min(Math.max(sliderPosition, 0), maxSeekTarget);
150
+ isSeekingRef.current = true;
151
+ if (seekedTimeoutRef.current) clearTimeout(seekedTimeoutRef.current);
152
+ seekedTimeoutRef.current = setTimeout(()=>{
153
+ isSeekingRef.current = false;
154
+ seekedTimeoutRef.current = null;
155
+ }, 300);
156
+ setProgress(clamped);
157
+ setDisplayCurrent(formatTime(clamped));
158
+ audioRef.current.currentTime = clamped;
134
159
  };
135
160
  const hideSlider = isCleared && hideSliderOnStop;
136
161
  const hideTime = isCleared && hideTimeOnStop;
@@ -199,6 +224,7 @@ const Audio = ({ src, title, width, infoPosition, centerAlignContent, small, tin
199
224
  onEmptied: handleAudioStop,
200
225
  onEnded: handleAudioStop,
201
226
  onTimeUpdate: updateProgress,
227
+ onSeeked: handleSeeked,
202
228
  onDurationChange: handleLoad,
203
229
  onLoadedMetadata: handleLoad,
204
230
  onLoadedData: handleLoad,
@@ -84,7 +84,7 @@ const DraftEditor = ({ value, onChange, onEnterKey, onFocus, onBlur, mergeFields
84
84
  height: height,
85
85
  editorMaxHeight: editorMaxHeight,
86
86
  noPadding: noPadding || textOnly,
87
- readOnly: readOnly,
87
+ readOnly: readOnly || disabled,
88
88
  color: color,
89
89
  overflow: overflow,
90
90
  clampLines: clampLines,
@@ -106,7 +106,7 @@ const DraftEditor = ({ value, onChange, onEnterKey, onFocus, onBlur, mergeFields
106
106
  className: className,
107
107
  children: [
108
108
  /*#__PURE__*/ jsxs(InputWrapper, {
109
- readOnly: readOnly,
109
+ readOnly: readOnly || disabled,
110
110
  children: [
111
111
  label && /*#__PURE__*/ jsx(Label, {
112
112
  filled: isInputFilled(value),
@@ -119,7 +119,7 @@ const DraftEditor = ({ value, onChange, onEnterKey, onFocus, onBlur, mergeFields
119
119
  editorState: editorState,
120
120
  onChange: handleChange,
121
121
  placeholder: placeholder,
122
- readOnly: readOnly,
122
+ readOnly: readOnly || disabled,
123
123
  handleReturn: handleEditorReturn,
124
124
  handlePastedText: handlePaste,
125
125
  onFocus: handleFocus,
@@ -143,10 +143,10 @@ const EditorContainer = styled(InputContainer)(({ theme, height, noPadding, disa
143
143
  color: disabled ? theme.input.color.disabled : color || theme.input.color.default,
144
144
  cursor: readOnly ? 'inherit' : 'text',
145
145
  '&:hover': {
146
- backgroundColor: readOnly ? theme.input.background.default : void 0,
147
- borderBottom: readOnly ? `1px solid ${theme.input.borderColor.default}` : void 0,
146
+ backgroundColor: readOnly && !disabled ? theme.input.background.default : void 0,
147
+ borderBottom: readOnly && !disabled ? `1px solid ${theme.input.borderColor.default}` : void 0,
148
148
  Label: {
149
- color: readOnly ? theme.input.labelColor.filled : void 0
149
+ color: readOnly && !disabled ? theme.input.labelColor.filled : void 0
150
150
  }
151
151
  }
152
152
  }), ({ theme, height, hasLabel, editorMaxHeight, overflow, clampLines, hideEditor, fontSize, noPadding, filled })=>({
@@ -27,11 +27,11 @@ const Select_Select = ({ backgroundColor, menuBackground, children, fontSize, fo
27
27
  const [internalValue, setInternalValue] = useState(()=>{
28
28
  if (isMultiple) {
29
29
  const defaultValueArray = defaultValue;
30
- return Array.isArray(defaultValueArray) ? defaultValueArray.map(String) : defaultValueArray ? [
31
- String(defaultValueArray)
30
+ return Array.isArray(defaultValueArray) ? defaultValueArray : defaultValueArray ? [
31
+ defaultValueArray
32
32
  ] : [];
33
33
  }
34
- return defaultValue ? String(defaultValue) : '';
34
+ return defaultValue ?? '';
35
35
  });
36
36
  const isControlled = void 0 !== value;
37
37
  const currentValue = isControlled ? value : internalValue;
@@ -68,9 +68,9 @@ type SingleSelectInputProps = BaseSelectInputProps & {
68
68
  /** The selection mode for the select */
69
69
  selectionMode?: 'single';
70
70
  /** The controlled value of the input */
71
- value?: Key;
71
+ value?: string;
72
72
  /** The uncontrolled initial value of the input */
73
- defaultValue?: Key;
73
+ defaultValue?: string;
74
74
  /** The function to be called when an option is selected */
75
75
  onChange?: (key: string) => void;
76
76
  };
@@ -78,9 +78,9 @@ type MultipleSelectInputProps = BaseSelectInputProps & {
78
78
  /** The selection mode for the select */
79
79
  selectionMode: 'multiple';
80
80
  /** The controlled value of the input */
81
- value?: Key | Key[];
81
+ value?: string | string[];
82
82
  /** The uncontrolled initial value of the input */
83
- defaultValue?: Key | Key[];
83
+ defaultValue?: string | string[];
84
84
  onChange?: (keys: string | string[]) => void;
85
85
  };
86
86
  export type SelectInputProps = SingleSelectInputProps | MultipleSelectInputProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wavv/ui",
3
- "version": "2.4.13",
3
+ "version": "2.4.15-alpha.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {