@onesy/ui-react 1.0.28 → 1.0.29

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/Accordion/Accordion.d.ts +1 -1
  2. package/Append/Append.d.ts +1 -1
  3. package/AudioRecorder/AudioRecorder.js +23 -9
  4. package/AutoComplete/AutoComplete.d.ts +2 -2
  5. package/Calendar/Calendar.d.ts +2 -2
  6. package/CalendarMonth/CalendarMonth.d.ts +3 -3
  7. package/CalendarViews/CalendarViews.d.ts +1 -1
  8. package/Carousel/Carousel.d.ts +2 -2
  9. package/Chart/Chart.d.ts +1 -1
  10. package/Clock/Clock.d.ts +4 -4
  11. package/DateTimePicker/DateTimePicker.d.ts +1 -1
  12. package/Drawing/Drawing.d.ts +1 -1
  13. package/FileChoose/FileChoose.d.ts +1 -1
  14. package/Grid/Grid.d.ts +1 -1
  15. package/ImageCrop/ImageCrop.d.ts +1 -1
  16. package/ImageEdit/ImageEdit.d.ts +1 -1
  17. package/Interaction/Interaction.d.ts +1 -1
  18. package/Keyframes/Keyframes.d.ts +1 -1
  19. package/Line/Line.d.ts +5 -5
  20. package/Medias/Medias.d.ts +1 -1
  21. package/MenuDesktop/MenuDesktop.d.ts +2 -2
  22. package/NavigationBar/NavigationBar.d.ts +1 -1
  23. package/NavigationItem/NavigationItem.d.ts +1 -1
  24. package/Parallax/Parallax.d.ts +1 -1
  25. package/ScreenCapture/ScreenCapture.d.ts +1 -1
  26. package/Section/Section.d.ts +1 -1
  27. package/Slider/Slider.d.ts +1 -1
  28. package/TableCell/TableCell.d.ts +1 -1
  29. package/TimePicker/TimePicker.d.ts +2 -2
  30. package/Transition/Transition.d.ts +1 -1
  31. package/Transitions/Transitions.d.ts +1 -1
  32. package/Weather/Weather.d.ts +3 -3
  33. package/Whiteboard/Whiteboard.d.ts +2 -2
  34. package/esm/AudioRecorder/AudioRecorder.js +26 -12
  35. package/esm/index.js +1 -1
  36. package/esm/utils.js +1 -43
  37. package/package.json +3 -2
  38. package/types.d.ts +23 -28
  39. package/useForm/validate.d.ts +6 -6
  40. package/useScroll/useScroll.d.ts +1 -1
  41. package/utils.d.ts +1 -2
  42. package/utils.js +1 -39
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ISurface } from '../Surface/Surface';
3
3
  import { IColor, IElement, IElementReference, IElevation, IPropsAny, ITonal } from '../types';
4
- type TPadding = 'start' | 'end' | 'both' | 'none';
4
+ declare type TPadding = 'start' | 'end' | 'both' | 'none';
5
5
  export interface IAccordion extends ISurface {
6
6
  tonal?: ITonal;
7
7
  color?: IColor;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { IChildren, IHTMLElement, IStyle } from '../types';
3
- export type TAppendPadding = Array<number>;
3
+ export declare type TAppendPadding = Array<number>;
4
4
  export interface IAppendValue {
5
5
  x?: number;
6
6
  y?: number;
@@ -16,6 +16,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  const jsx_runtime_1 = require("react/jsx-runtime");
18
18
  const react_1 = __importDefault(require("react"));
19
+ const webm_duration_fix_1 = __importDefault(require("webm-duration-fix"));
19
20
  const utils_1 = require("@onesy/utils");
20
21
  const style_react_1 = require("@onesy/style-react");
21
22
  const date_1 = require("@onesy/date");
@@ -91,6 +92,7 @@ const AudioRecorder = react_1.default.forwardRef((props_, ref) => {
91
92
  value: react_1.default.useRef(null),
92
93
  animationFrame: react_1.default.useRef(null),
93
94
  onData: react_1.default.useRef(null),
95
+ previousAction: react_1.default.useRef('start'),
94
96
  // fallback to duration calculation on desktop
95
97
  // ie. for mobile where we can't easily determine duration
96
98
  duration: react_1.default.useRef(0)
@@ -148,6 +150,8 @@ const AudioRecorder = react_1.default.forwardRef((props_, ref) => {
148
150
  setStatus('running');
149
151
  if ((0, utils_1.is)('function', onStart_))
150
152
  onStart_(event);
153
+ // previous action
154
+ refs.previousAction.current = 'start';
151
155
  }, [onStart_, onError]);
152
156
  const onPause = react_1.default.useCallback((event) => {
153
157
  // media recorder
@@ -161,6 +165,8 @@ const AudioRecorder = react_1.default.forwardRef((props_, ref) => {
161
165
  setStatus('paused');
162
166
  if ((0, utils_1.is)('function', onPause_))
163
167
  onPause_(event);
168
+ // previous action
169
+ refs.previousAction.current = 'pause';
164
170
  }, [onPause_]);
165
171
  const onStop = react_1.default.useCallback((event) => {
166
172
  // media recorder
@@ -178,21 +184,27 @@ const AudioRecorder = react_1.default.forwardRef((props_, ref) => {
178
184
  var _a;
179
185
  // Stop
180
186
  onStop(event);
181
- // add so far to duration
182
- refs.duration.current += date_1.OnesyDate.milliseconds - refs.startedAt.current;
187
+ // duration
188
+ if (refs.previousAction.current === 'resume') {
189
+ // add so far to duration
190
+ refs.duration.current += date_1.OnesyDate.milliseconds - refs.startedAt.current;
191
+ }
192
+ const meta = {
193
+ // duration in seconds
194
+ duration: refs.duration.current / 1e3
195
+ };
183
196
  await (0, utils_1.wait)(40);
184
197
  // Get the blob
185
198
  const mimeType = (_a = refs.mediaRecorder.current) === null || _a === void 0 ? void 0 : _a.mimeType;
186
199
  let blob = new Blob(refs.mediaRecorderBytes.current, { type: mimeType });
200
+ try {
201
+ blob = await (0, webm_duration_fix_1.default)(blob);
202
+ }
203
+ catch (error) {
204
+ console.log('AudioRecorder onConfirm error', error);
205
+ }
187
206
  // clean up
188
207
  refs.mediaRecorderBytes.current = [];
189
- const meta = {
190
- // duration in seconds
191
- duration: refs.duration.current / 1e3
192
- };
193
- const { blob: blobAudioFix, error } = await (0, utils_2.audioFix)(blob, meta.duration);
194
- if (!error)
195
- blob = blobAudioFix;
196
208
  if ((0, utils_1.is)('function', onConfirm_))
197
209
  onConfirm_(blob, meta);
198
210
  }, [onStop, onConfirm_]);
@@ -207,6 +219,8 @@ const AudioRecorder = react_1.default.forwardRef((props_, ref) => {
207
219
  setStatus('running');
208
220
  if ((0, utils_1.is)('function', onResume_))
209
221
  onResume_(event);
222
+ // previous action
223
+ refs.previousAction.current = 'resume';
210
224
  }, [onResume_]);
211
225
  const valueFormat = (valueNew_) => {
212
226
  let valueNew = '';
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import { ITextField } from '../TextField/TextField';
3
3
  import { IElement, IElementReference, IPropsAny } from '../types';
4
- export type TAutoCompleteValue = string | Array<string>;
5
- export type TAutoCompleteOption = {
4
+ export declare type TAutoCompleteValue = string | Array<string>;
5
+ export declare type TAutoCompleteOption = {
6
6
  label?: string;
7
7
  version?: 'text' | 'subheader';
8
8
  noOptions?: boolean;
@@ -3,10 +3,10 @@ import { OnesyDate } from '@onesy/date';
3
3
  import { ICalenarDays, TCalendarMonthCalendar, TCalendarMonthValue } from '../CalendarMonth/CalendarMonth';
4
4
  import { ISurface } from '../Surface/Surface';
5
5
  import { IColor, IElementReference, IPropsAny, ISize, ITonal } from '../types';
6
- export type TGetOnesyDates = (value: TCalendarMonthValue, calendar: TCalendarMonthCalendar, props: IPropsAny) => Array<{
6
+ export declare type TGetOnesyDates = (value: TCalendarMonthValue, calendar: TCalendarMonthCalendar, props: IPropsAny) => Array<{
7
7
  value: OnesyDate;
8
8
  }>;
9
- export type TCalendarUnit = 'day' | 'month' | 'year';
9
+ export declare type TCalendarUnit = 'day' | 'month' | 'year';
10
10
  export interface ICalendar extends Omit<ISurface, 'version'> {
11
11
  tonal?: ITonal;
12
12
  color?: IColor;
@@ -3,8 +3,8 @@ import { OnesyDate } from '@onesy/date';
3
3
  import { ILine } from '../Line/Line';
4
4
  import { IColor, IPropsAny, ISize, ITonal } from '../types';
5
5
  import { ICalendarViewsView } from '../CalendarViews/CalendarViews';
6
- export type TCalendarMonthValue = OnesyDate | [OnesyDate, OnesyDate];
7
- export type TCalendarMonthCalendar = OnesyDate;
6
+ export declare type TCalendarMonthValue = OnesyDate | [OnesyDate, OnesyDate];
7
+ export declare type TCalendarMonthCalendar = OnesyDate;
8
8
  export interface ICalendarMonthValuesValue {
9
9
  day: string;
10
10
  month: string;
@@ -16,7 +16,7 @@ export interface ICalendarMonthValuesValue {
16
16
  previous: OnesyDate;
17
17
  move: 'previous' | 'next';
18
18
  }
19
- export type TCalendarMonthValues = [ICalendarMonthValuesValue, ICalendarMonthValuesValue];
19
+ export declare type TCalendarMonthValues = [ICalendarMonthValuesValue, ICalendarMonthValuesValue];
20
20
  export interface ICalenarDays extends ILine {
21
21
  tonal?: ITonal;
22
22
  color?: IColor;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { OnesyDate } from '@onesy/date';
3
3
  import { ICalendar } from '../Calendar/Calendar';
4
4
  import { ICalendarEvent } from '../CalendarAvailability/CalendarAvailability';
5
- export type ICalendarViewsView = 'day' | 'week' | 'month';
5
+ export declare type ICalendarViewsView = 'day' | 'week' | 'month';
6
6
  export interface ICalendarViews extends ICalendar {
7
7
  viewDefault?: ICalendarViewsView;
8
8
  dateDefault?: OnesyDate;
@@ -8,10 +8,10 @@ export interface ICarouselValue {
8
8
  x?: number;
9
9
  y?: number;
10
10
  }
11
- export type TCarouselItem = string | null | IElement | {
11
+ export declare type TCarouselItem = string | null | IElement | {
12
12
  element: IElement;
13
13
  };
14
- export type TCarouseOnUpdate = (to: string | number, values: TCarouselItem[]) => any;
14
+ export declare type TCarouseOnUpdate = (to: string | number, values: TCarouselItem[]) => any;
15
15
  export interface ICarousel extends Omit<ISurface, 'version'> {
16
16
  version?: 'regular' | 'transition' | Partial<Record<IValueBreakpoints, 'regular' | 'transition'>>;
17
17
  valueDefault?: ICarouselValue;
package/Chart/Chart.d.ts CHANGED
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { TColorValues } from '@onesy/style-react';
3
3
  import { ISurface } from '../Surface/Surface';
4
4
  import { IColor, IStyle, ITonal, IElementAny, IElement, IValueBreakpoints, IPropsAny } from '../types';
5
- export type IChartValueValues = Array<any>;
5
+ export declare type IChartValueValues = Array<any>;
6
6
  export interface IItemValue {
7
7
  value: number;
8
8
  label: number;
package/Clock/Clock.d.ts CHANGED
@@ -2,10 +2,10 @@ import React from 'react';
2
2
  import { OnesyDate } from '@onesy/date';
3
3
  import { IRoundMeter } from '../RoundMeter/RoundMeter';
4
4
  import { ITonal, IColor, ISize } from '../types';
5
- export type TClockValue = OnesyDate;
6
- export type TClockFormat = '12' | '24';
7
- export type TClockUnit = 'hour' | 'minute' | 'second';
8
- export type TClockDayTime = 'am' | 'pm';
5
+ export declare type TClockValue = OnesyDate;
6
+ export declare type TClockFormat = '12' | '24';
7
+ export declare type TClockUnit = 'hour' | 'minute' | 'second';
8
+ export declare type TClockDayTime = 'am' | 'pm';
9
9
  export interface IClock extends IRoundMeter {
10
10
  tonal?: ITonal;
11
11
  color?: IColor;
@@ -5,7 +5,7 @@ import { TCalendarMonthValue } from '../CalendarMonth/CalendarMonth';
5
5
  import { TCalendarUnit } from '../Calendar/Calendar';
6
6
  import { TClockUnit } from '../Clock/Clock';
7
7
  import { ITonal, IColor, IValueBreakpoints, IElementReference, IPropsAny } from '../types';
8
- export type TDateTimePicker = OnesyDate;
8
+ export declare type TDateTimePicker = OnesyDate;
9
9
  export interface IDateTimePicker extends Omit<IAdvancedTextField, 'version'> {
10
10
  tonal?: ITonal;
11
11
  color?: IColor;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ISurface } from '../Surface/Surface';
3
3
  import { IElement, IElementReference, IPropsAny, IRef } from '../types';
4
- export type TDrawingValue = Array<{
4
+ export declare type TDrawingValue = Array<{
5
5
  d?: string;
6
6
  stroke?: string;
7
7
  strokeWidth?: number;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ILine } from '../Line/Line';
3
3
  import { ITonal, IColor, IRef, IElementReference, IPropsAny, ISize } from '../types';
4
- export type TFileChooseValue = File | Array<File>;
4
+ export declare type TFileChooseValue = File | Array<File>;
5
5
  export interface IFileChoose extends ILine {
6
6
  tonal?: ITonal;
7
7
  color?: IColor;
package/Grid/Grid.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ILine } from '../Line/Line';
3
3
  import { IValueBreakpoints, IPropsAny } from '../types';
4
- export type IGridValues = Partial<Record<IValueBreakpoints, number>>;
4
+ export declare type IGridValues = Partial<Record<IValueBreakpoints, number>>;
5
5
  export interface IGrid extends ILine {
6
6
  auto?: boolean;
7
7
  columns?: number | IGridValues;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { IBaseElement, IPropsAny } from '../types';
3
- export type TImageCrop = {
3
+ export declare type TImageCrop = {
4
4
  x?: number;
5
5
  y?: number;
6
6
  width?: number;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { TMethod } from '@onesy/models';
3
3
  import { ILine } from '../Line/Line';
4
4
  import { IElementReference, IElement, ITonal, IColor, IPropsAny } from '../types';
5
- export type TImageEditFilter = {
5
+ export declare type TImageEditFilter = {
6
6
  label?: string;
7
7
  Icon?: IElementReference;
8
8
  value?: string;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import OnesySubscription from '@onesy/subscription/OnesySubscription';
3
3
  import { IBaseElement } from '../types';
4
- export type TMethodsVersion = 'add' | 'pulse' | 'remove';
4
+ export declare type TMethodsVersion = 'add' | 'pulse' | 'remove';
5
5
  export interface IInteraction extends IBaseElement {
6
6
  wave?: boolean;
7
7
  background?: boolean;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { TTransitionsDurationProperties } from '@onesy/style-react';
3
3
  import { IBaseElement, IRef } from '../types';
4
- export type TKeyframesStatus = 'appended' | 'add' | 'adding' | 'added' | 'removed';
4
+ export declare type TKeyframesStatus = 'appended' | 'add' | 'adding' | 'added' | 'removed';
5
5
  export interface IKeyframe {
6
6
  name: string;
7
7
  timeout: number;
package/Line/Line.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import { IBaseElement, IPropsAny, IValueBreakpoints } from '../types';
3
- export type TLineAlign = 'inherit' | 'initial' | 'flex-start' | 'center' | 'flex-end' | 'baseline' | 'stretch' | 'unset';
4
- export type TLineJustify = 'inherit' | 'initial' | 'flex-start' | 'center' | 'flex-end' | 'space-around' | 'space-between' | 'space-evenly' | 'unset';
5
- export type TLineDirection = 'inherit' | 'row' | 'row-reverse' | 'column' | 'column-reverse';
6
- export type TLineWrap = 'inherit' | 'wrap' | 'nowrap' | 'wrap-reverse';
7
- export type TLineDisplay = 'inherit' | 'flex' | 'inline-flex';
3
+ export declare type TLineAlign = 'inherit' | 'initial' | 'flex-start' | 'center' | 'flex-end' | 'baseline' | 'stretch' | 'unset';
4
+ export declare type TLineJustify = 'inherit' | 'initial' | 'flex-start' | 'center' | 'flex-end' | 'space-around' | 'space-between' | 'space-evenly' | 'unset';
5
+ export declare type TLineDirection = 'inherit' | 'row' | 'row-reverse' | 'column' | 'column-reverse';
6
+ export declare type TLineWrap = 'inherit' | 'wrap' | 'nowrap' | 'wrap-reverse';
7
+ export declare type TLineDisplay = 'inherit' | 'flex' | 'inline-flex';
8
8
  export interface ILine extends IBaseElement {
9
9
  display?: TLineDisplay | Partial<Record<IValueBreakpoints, TLineDisplay>>;
10
10
  direction?: TLineDirection | Partial<Record<IValueBreakpoints, TLineDirection>>;
@@ -5,7 +5,7 @@ export interface IMediasItem {
5
5
  value: IMediaObject;
6
6
  props?: any;
7
7
  }
8
- export type IMediasMediaVersion = 'embed' | 'image' | 'audio' | 'video' | 'other';
8
+ export declare type IMediasMediaVersion = 'embed' | 'image' | 'audio' | 'video' | 'other';
9
9
  export interface IMedias extends ILine {
10
10
  size?: 'small' | 'regular' | 'large';
11
11
  values?: IMediasItem | IMediasItem[];
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import { TTransitionStatus } from '../Transition';
3
3
  import { ILine } from '../Line/Line';
4
4
  import { IElement, ITonal, IStyle, IElementReference, IPropsAny, IVersion, IColor } from '../types';
5
- export type TMenuDesktopValue = string | number;
6
- export type TMenuDesktopItem = {
5
+ export declare type TMenuDesktopValue = string | number;
6
+ export declare type TMenuDesktopItem = {
7
7
  value?: TMenuDesktopValue;
8
8
  label?: IElement;
9
9
  name?: IElement;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ISurface } from '../Surface/Surface';
3
3
  import { INavigationItemVersion } from '../NavigationItem/NavigationItem';
4
- export type TNavigationBarValue = Array<string>;
4
+ export declare type TNavigationBarValue = Array<string>;
5
5
  export interface INavigationBar extends Omit<ISurface, 'version'> {
6
6
  value?: TNavigationBarValue;
7
7
  valueDefault?: TNavigationBarValue;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ITooltip } from '../Tooltip/Tooltip';
3
3
  import { ITonal, IColor, IElement, IElementReference, IPropsAny } from '../types';
4
- export type INavigationItemVersion = 'regular' | 'auto';
4
+ export declare type INavigationItemVersion = 'regular' | 'auto';
5
5
  export interface INavigationItem extends ITooltip {
6
6
  tonal?: ITonal;
7
7
  color?: IColor;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { IBaseElement, IPropsAny, IStyle, IValueBreakpoints } from '../types';
3
- export type TParallaxDirection = 'vertical' | 'horizontal';
3
+ export declare type TParallaxDirection = 'vertical' | 'horizontal';
4
4
  export interface IParallax extends IBaseElement {
5
5
  value?: number;
6
6
  root?: Element | DocumentFragment;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { ISurface } from '../Surface/Surface';
3
3
  import { IElementReference, IPropsAny } from '../types';
4
- export type TTrackValueVersion = 'image' | 'canvas';
4
+ export declare type TTrackValueVersion = 'image' | 'canvas';
5
5
  export interface IScreenCapture extends ISurface {
6
6
  nameDefault?: string;
7
7
  name?: string;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { TPaletteVersion } from '@onesy/style-react';
3
3
  import { ILine } from '../Line/Line';
4
4
  import { IValueBreakpoints, IMediaObject, IPropsAny } from '../types';
5
- export type ISize = 'extra_small' | 'small' | 'regular' | 'large' | 'extra_large' | 'extra_extra_large';
5
+ export declare type ISize = 'extra_small' | 'small' | 'regular' | 'large' | 'extra_large' | 'extra_extra_large';
6
6
  export interface ISection extends ILine {
7
7
  themed?: boolean;
8
8
  title?: string | Partial<Record<IValueBreakpoints, string>>;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { IBaseElement, ITonal, IColor, ISize, IElement, IPropsAny } from '../types';
3
- export type TSliderValue = number | Array<number>;
3
+ export declare type TSliderValue = number | Array<number>;
4
4
  export interface ISlider extends IBaseElement {
5
5
  tonal?: ITonal;
6
6
  color?: IColor;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { TLineAlign, TLineJustify } from '../Line/Line';
3
3
  import { IBaseElement, ITonal, IColor, ISize, IPropsAny } from '../types';
4
- export type ITableCellSort = 'asc' | 'desc';
4
+ export declare type ITableCellSort = 'asc' | 'desc';
5
5
  export interface ITableCell extends IBaseElement {
6
6
  tonal?: ITonal;
7
7
  color?: IColor;
@@ -3,8 +3,8 @@ import { OnesyDate } from '@onesy/date';
3
3
  import { TClockUnit } from '../Clock/Clock';
4
4
  import { IAdvancedTextField } from '../AdvancedTextField/AdvancedTextField';
5
5
  import { ISize, IValueBreakpoints, IElementReference, IPropsAny } from '../types';
6
- export type TTimePickerValue = OnesyDate | [OnesyDate, OnesyDate];
7
- export type TTimePickerSelecting = TClockUnit | [TClockUnit, TClockUnit];
6
+ export declare type TTimePickerValue = OnesyDate | [OnesyDate, OnesyDate];
7
+ export declare type TTimePickerSelecting = TClockUnit | [TClockUnit, TClockUnit];
8
8
  export interface ITimePicker extends Omit<IAdvancedTextField, 'version'> {
9
9
  version?: 'auto' | 'mobile' | 'desktop';
10
10
  value?: TTimePickerValue;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { TTransitionsDurationProperties } from '@onesy/style-react';
3
3
  import { IBaseElement } from '../types';
4
- export type TTransitionStatus = 'appended' | 'add' | 'adding' | 'added' | 'enter' | 'entering' | 'entered' | 'exit' | 'exiting' | 'exited' | 'removed';
4
+ export declare type TTransitionStatus = 'appended' | 'add' | 'adding' | 'added' | 'enter' | 'entering' | 'entered' | 'exit' | 'exiting' | 'exited' | 'removed';
5
5
  export declare const STATUS: Record<TTransitionStatus, TTransitionStatus>;
6
6
  export interface ITransitionDelay {
7
7
  default?: number;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { IPropsAny } from '../types';
3
- export type TTransitionsMode = 'in-out' | 'in-out-follow' | 'out-in';
3
+ export declare type TTransitionsMode = 'in-out' | 'in-out-follow' | 'out-in';
4
4
  export interface ITransitions {
5
5
  id?: string;
6
6
  mode?: TTransitionsMode;
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import { ISurface } from '../Surface/Surface';
3
3
  import { ISize, IElementReference, IPropsAny } from '../types';
4
- export type TWeatherDayTime = 'day' | 'night';
5
- export type TWeather = 'clear' | 'partly clear' | 'rainy' | 'partly rainy' | 'snowy' | 'partly snowy';
6
- export type TTemperature = number;
4
+ export declare type TWeatherDayTime = 'day' | 'night';
5
+ export declare type TWeather = 'clear' | 'partly clear' | 'rainy' | 'partly rainy' | 'snowy' | 'partly snowy';
6
+ export declare type TTemperature = number;
7
7
  export interface IWeather extends ISurface {
8
8
  size?: ISize;
9
9
  shadow?: boolean;
@@ -4,8 +4,8 @@ export interface IWhiteboardAction {
4
4
  v: 'a' | 'r';
5
5
  i: IWhiteboardItem | IWhiteboardItem[];
6
6
  }
7
- export type IWhiteboardTool = 'pen' | 'eraser' | 'pan' | 'zoom' | 'select' | 'circle' | 'rectangle' | 'triangle' | 'line' | 'line-arrow' | 'text' | 'image';
8
- export type IWhiteboardValue = IWhiteboardItem[];
7
+ export declare type IWhiteboardTool = 'pen' | 'eraser' | 'pan' | 'zoom' | 'select' | 'circle' | 'rectangle' | 'triangle' | 'line' | 'line-arrow' | 'text' | 'image';
8
+ export declare type IWhiteboardValue = IWhiteboardItem[];
9
9
  export interface IWhiteboard extends IBaseElement {
10
10
  valueDefault?: IWhiteboardValue;
11
11
  onChange?: (value: IWhiteboardValue) => any;
@@ -5,6 +5,7 @@ const _excluded = ["size", "pause", "renderMain", "renderTime", "loading", "disa
5
5
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
6
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
7
7
  import React from 'react';
8
+ import audioFix from 'webm-duration-fix';
8
9
  import { getLeadingZerosNumber, is, isEnvironment, wait } from '@onesy/utils';
9
10
  import { classNames, style as styleMethod, useOnesyTheme } from '@onesy/style-react';
10
11
  import { OnesyDate, duration } from '@onesy/date';
@@ -18,7 +19,7 @@ import FadeElement from '../Fade';
18
19
  import TypeElement from '../Type';
19
20
  import TooltipElement from '../Tooltip';
20
21
  import IconButtonElement from '../IconButton';
21
- import { audioFix, staticClassName } from '../utils';
22
+ import { staticClassName } from '../utils';
22
23
  const useStyle = styleMethod(theme => ({
23
24
  '@keyframes pulse': {
24
25
  '0%': {
@@ -108,6 +109,7 @@ const AudioRecorder = /*#__PURE__*/React.forwardRef((props_, ref) => {
108
109
  value: React.useRef(null),
109
110
  animationFrame: React.useRef(null),
110
111
  onData: React.useRef(null),
112
+ previousAction: React.useRef('start'),
111
113
  // fallback to duration calculation on desktop
112
114
  // ie. for mobile where we can't easily determine duration
113
115
  duration: React.useRef(0)
@@ -171,6 +173,9 @@ const AudioRecorder = /*#__PURE__*/React.forwardRef((props_, ref) => {
171
173
  refs.animationFrame.current = requestAnimationFrame(update);
172
174
  setStatus('running');
173
175
  if (is('function', onStart_)) onStart_(event);
176
+
177
+ // previous action
178
+ refs.previousAction.current = 'start';
174
179
  }, [onStart_, onError]);
175
180
  const onPause = React.useCallback(event => {
176
181
  // media recorder
@@ -184,6 +189,9 @@ const AudioRecorder = /*#__PURE__*/React.forwardRef((props_, ref) => {
184
189
  refs.valuePaused.current = refs.value.current;
185
190
  setStatus('paused');
186
191
  if (is('function', onPause_)) onPause_(event);
192
+
193
+ // previous action
194
+ refs.previousAction.current = 'pause';
187
195
  }, [onPause_]);
188
196
  const onStop = React.useCallback(event => {
189
197
  // media recorder
@@ -199,8 +207,15 @@ const AudioRecorder = /*#__PURE__*/React.forwardRef((props_, ref) => {
199
207
  // Stop
200
208
  onStop(event);
201
209
 
202
- // add so far to duration
203
- refs.duration.current += OnesyDate.milliseconds - refs.startedAt.current;
210
+ // duration
211
+ if (refs.previousAction.current === 'resume') {
212
+ // add so far to duration
213
+ refs.duration.current += OnesyDate.milliseconds - refs.startedAt.current;
214
+ }
215
+ const meta = {
216
+ // duration in seconds
217
+ duration: refs.duration.current / 1e3
218
+ };
204
219
  await wait(40);
205
220
 
206
221
  // Get the blob
@@ -208,18 +223,14 @@ const AudioRecorder = /*#__PURE__*/React.forwardRef((props_, ref) => {
208
223
  let blob = new Blob(refs.mediaRecorderBytes.current, {
209
224
  type: mimeType
210
225
  });
226
+ try {
227
+ blob = await audioFix(blob);
228
+ } catch (error) {
229
+ console.log('AudioRecorder onConfirm error', error);
230
+ }
211
231
 
212
232
  // clean up
213
233
  refs.mediaRecorderBytes.current = [];
214
- const meta = {
215
- // duration in seconds
216
- duration: refs.duration.current / 1e3
217
- };
218
- const {
219
- blob: blobAudioFix,
220
- error
221
- } = await audioFix(blob, meta.duration);
222
- if (!error) blob = blobAudioFix;
223
234
  if (is('function', onConfirm_)) onConfirm_(blob, meta);
224
235
  }, [onStop, onConfirm_]);
225
236
  const onResume = React.useCallback(event => {
@@ -233,6 +244,9 @@ const AudioRecorder = /*#__PURE__*/React.forwardRef((props_, ref) => {
233
244
  refs.animationFrame.current = requestAnimationFrame(update);
234
245
  setStatus('running');
235
246
  if (is('function', onResume_)) onResume_(event);
247
+
248
+ // previous action
249
+ refs.previousAction.current = 'resume';
236
250
  }, [onResume_]);
237
251
  const valueFormat = valueNew_ => {
238
252
  let valueNew = '';
package/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license UiReact v1.0.28
1
+ /** @license UiReact v1.0.29
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
package/esm/utils.js CHANGED
@@ -1253,46 +1253,4 @@ export const currencies = [{
1253
1253
  rounding: 0,
1254
1254
  code: 'ZMK',
1255
1255
  name_plural: 'Zambian kwachas'
1256
- }];
1257
- export const audioFix = async (blob, duration) => {
1258
- try {
1259
- const arrayBuffer = await blob.arrayBuffer();
1260
- const uint8Array = new Uint8Array(arrayBuffer);
1261
-
1262
- // Function to find an EBML element by its ID
1263
- function findElement(idHex) {
1264
- const idBytes = new Uint8Array(idHex.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
1265
- for (let i = 0; i < uint8Array.length - idBytes.length; i++) {
1266
- if (uint8Array.slice(i, i + idBytes.length).toString() === idBytes.toString()) return i + idBytes.length; // Return position after the ID
1267
- }
1268
- return -1;
1269
- }
1270
-
1271
- // WebM duration EBML ID: 0x4489 (Segment Information -> Duration)
1272
- const durationPos = findElement('4489');
1273
- if (durationPos === -1) {
1274
- throw new Error('Duration element not found in the WebM file.');
1275
- }
1276
-
1277
- // Encode new duration in IEEE 754 Float64 (Big Endian, 8 bytes)
1278
- const durationBytes = new Uint8Array(new Float64Array([duration]).buffer).reverse();
1279
-
1280
- // Overwrite duration bytes in the WebM file
1281
- uint8Array.set(durationBytes, durationPos);
1282
-
1283
- // Convert back to Blob
1284
- const blobUpdated = new Blob([uint8Array], {
1285
- type: 'audio/webm'
1286
- });
1287
- return {
1288
- blob: blobUpdated,
1289
- duration
1290
- };
1291
- } catch (error) {
1292
- return {
1293
- blob,
1294
- duration,
1295
- error
1296
- };
1297
- }
1298
- };
1256
+ }];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onesy/ui-react",
3
- "version": "1.0.28",
3
+ "version": "1.0.29",
4
4
  "description": "UI for React",
5
5
  "repository": "https://github.com/onesy-me/onesy.git",
6
6
  "author": "Lazar <lazareric2@gmail.com>",
@@ -41,7 +41,8 @@
41
41
  "@onesy/icons-material-rounded-react": "^1.0.2",
42
42
  "@onesy/log": "^1.0.0",
43
43
  "@onesy/subscription": "^1.0.0",
44
- "@onesy/utils": "^1.0.2"
44
+ "@onesy/utils": "^1.0.2",
45
+ "webm-duration-fix": "^1.0.4"
45
46
  },
46
47
  "publishConfig": {
47
48
  "access": "public",
package/types.d.ts CHANGED
@@ -1,26 +1,26 @@
1
1
  /// <reference types="react" />
2
2
  import { IBreakpoint, TPaletteVersion } from '@onesy/style-react';
3
- export type IPoint = [number, number];
4
- export type ITonal = true | false | 'secondary';
5
- type RGB = `rgb(${number}, ${number}, ${number})`;
6
- type RGBA = `rgba(${number}, ${number}, ${number}, ${number})`;
7
- type HSL = `hsl(${number}, ${number}, ${number})`;
8
- type HSLA = `hsla(${number}, ${number}, ${number}, ${number})`;
9
- type HEX = `#${string}`;
10
- type Color = RGB | RGBA | HSL | HSLA | HEX;
11
- export type IColor = 'default' | 'themed' | 'inverted' | 'inherit' | TPaletteVersion | Color;
12
- export type IVersion = 'filled' | 'outlined' | 'outlined-without-background' | 'text';
13
- export type ISize = 'small' | 'regular' | 'large';
14
- export type ISizeAny = ISize | number;
15
- export type IElevation = 0 | 1 | 2 | 3 | 4 | 6 | 8 | 9 | 12 | 16 | 24;
16
- export type IElementReference = string | React.FC<any> | (React.ForwardRefExoticComponent<any>);
17
- export type IElement = React.ReactNode | React.ReactNode[] | React.ReactElement<any, string | React.JSXElementConstructor<any>>;
18
- export type IElementAny = IElement | string | number | boolean | null | undefined;
19
- export type IHTMLElement = Element | HTMLElement;
20
- export type IPropsAny = Record<string, any>;
21
- export type IStyle = React.CSSProperties | undefined;
22
- export type IChildren = React.ReactNode | React.ReactNode[];
23
- export type IRef = React.MutableRefObject<any>;
3
+ export declare type IPoint = [number, number];
4
+ export declare type ITonal = true | false | 'secondary';
5
+ declare type RGB = `rgb(${number}, ${number}, ${number})`;
6
+ declare type RGBA = `rgba(${number}, ${number}, ${number}, ${number})`;
7
+ declare type HSL = `hsl(${number}, ${number}, ${number})`;
8
+ declare type HSLA = `hsla(${number}, ${number}, ${number}, ${number})`;
9
+ declare type HEX = `#${string}`;
10
+ declare type Color = RGB | RGBA | HSL | HSLA | HEX;
11
+ export declare type IColor = 'default' | 'themed' | 'inverted' | 'inherit' | TPaletteVersion | Color;
12
+ export declare type IVersion = 'filled' | 'outlined' | 'outlined-without-background' | 'text';
13
+ export declare type ISize = 'small' | 'regular' | 'large';
14
+ export declare type ISizeAny = ISize | number;
15
+ export declare type IElevation = 0 | 1 | 2 | 3 | 4 | 6 | 8 | 9 | 12 | 16 | 24;
16
+ export declare type IElementReference = string | React.FC<any> | (React.ForwardRefExoticComponent<any>);
17
+ export declare type IElement = React.ReactNode | React.ReactNode[] | React.ReactElement<any, string | React.JSXElementConstructor<any>>;
18
+ export declare type IElementAny = IElement | string | number | boolean | null | undefined;
19
+ export declare type IHTMLElement = Element | HTMLElement;
20
+ export declare type IPropsAny = Record<string, any>;
21
+ export declare type IStyle = React.CSSProperties | undefined;
22
+ export declare type IChildren = React.ReactNode | React.ReactNode[];
23
+ export declare type IRef = React.MutableRefObject<any>;
24
24
  export interface IBaseElement {
25
25
  Component?: any;
26
26
  className?: string;
@@ -28,8 +28,8 @@ export interface IBaseElement {
28
28
  children?: IChildren;
29
29
  [property: string]: any;
30
30
  }
31
- export type IMethodTransition = (element?: IHTMLElement) => any;
32
- export type IValueBreakpoints = IBreakpoint | 'default';
31
+ export declare type IMethodTransition = (element?: IHTMLElement) => any;
32
+ export declare type IValueBreakpoints = IBreakpoint | 'default';
33
33
  export interface IMediaObject {
34
34
  id?: string;
35
35
  name?: string;
@@ -38,9 +38,4 @@ export interface IMediaObject {
38
38
  urlSmall?: string;
39
39
  urlEmbed?: string;
40
40
  }
41
- export interface IAudioFix {
42
- blob: Blob;
43
- duration?: number;
44
- error?: any;
45
- }
46
41
  export {};
@@ -19,9 +19,9 @@ export interface IValidateModelValueMethodOptions {
19
19
  object: IValidateModelValue;
20
20
  options: IValidateOptions;
21
21
  }
22
- export type IValidateModelValueMethod = (value: any, options: IValidateModelValueMethodOptions) => Promise<any> | any;
23
- export type IValidateModelValueValidations = 'required' | 'is' | 'isValid' | 'of' | 'ofValid' | 'equal' | 'notEqual' | 'equalDeep' | 'notEqualDeep' | 'some' | 'in' | 'every' | 'properties' | 'notProperties' | 'min' | 'max' | 'length' | 'method';
24
- export type IValidateModelMessages = {
22
+ export declare type IValidateModelValueMethod = (value: any, options: IValidateModelValueMethodOptions) => Promise<any> | any;
23
+ export declare type IValidateModelValueValidations = 'required' | 'is' | 'isValid' | 'of' | 'ofValid' | 'equal' | 'notEqual' | 'equalDeep' | 'notEqualDeep' | 'some' | 'in' | 'every' | 'properties' | 'notProperties' | 'min' | 'max' | 'length' | 'method';
24
+ export declare type IValidateModelMessages = {
25
25
  [p in IValidateModelValueValidations]?: string;
26
26
  };
27
27
  export interface IValidateModelValue {
@@ -52,14 +52,14 @@ export interface IValidateModelValue {
52
52
  capitalize?: boolean;
53
53
  propertyNameUpdate?: (value: any) => string;
54
54
  }
55
- export type IUseFormValues = Record<string, IValidateModelValue>;
55
+ export declare type IUseFormValues = Record<string, IValidateModelValue>;
56
56
  export interface IForm {
57
57
  value: any;
58
58
  values: IUseFormValues;
59
59
  valid: boolean;
60
60
  }
61
- export type IValidateValidation = (property: IValidateModelValue, form: IForm) => void | Error | Promise<void | Error>;
62
- export type IValidateVales = Record<string, IValidateModelValue>;
61
+ export declare type IValidateValidation = (property: IValidateModelValue, form: IForm) => void | Error | Promise<void | Error>;
62
+ export declare type IValidateVales = Record<string, IValidateModelValue>;
63
63
  export declare const onValidateError: (options: IValidateOptions, model: IValidateModelValue, message?: any) => never;
64
64
  declare const validate: (model: IValidateModelValue, property: string, form: IForm, options_?: IValidateOptions) => Promise<void>;
65
65
  export default validate;
@@ -1,4 +1,4 @@
1
- export type TUseScrollDirection = 'up' | 'down';
1
+ export declare type TUseScrollDirection = 'up' | 'down';
2
2
  export interface IUseScroll {
3
3
  offset?: number;
4
4
  direction?: TUseScrollDirection;
package/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { IAudioFix, IPoint } from './types';
1
+ import { IPoint } from './types';
2
2
  export declare function reflow(element: HTMLElement): void;
3
3
  export declare const staticClassName: (name: string, theme: any) => any;
4
4
  export declare const iconSizeToFontSize: (value: string | number) => any;
@@ -46,4 +46,3 @@ export declare const currencies: {
46
46
  code: string;
47
47
  name_plural: string;
48
48
  }[];
49
- export declare const audioFix: (blob: Blob, duration: number) => Promise<IAudioFix>;
package/utils.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.audioFix = exports.currencies = exports.iconFontSize = exports.formats = exports.toNumber = exports.caret = exports.keyboardStyleCommands = exports.keyboardStandardCommands = exports.getOverflowParent = exports.importIframeStyles = exports.replace = exports.sanitize = exports.minMaxBetweenNumbers = exports.controlPoint = exports.line = exports.angleToCoordinates = exports.matches = exports.save = exports.print = exports.canvasOldPhoto = exports.canvasInvert = exports.canvasFade = exports.canvasSaturation = exports.canvasContrast = exports.canvasBrightness = exports.image = exports.valueBreakpoints = exports.iconSizeToFontSize = exports.staticClassName = exports.reflow = void 0;
3
+ exports.currencies = exports.iconFontSize = exports.formats = exports.toNumber = exports.caret = exports.keyboardStyleCommands = exports.keyboardStandardCommands = exports.getOverflowParent = exports.importIframeStyles = exports.replace = exports.sanitize = exports.minMaxBetweenNumbers = exports.controlPoint = exports.line = exports.angleToCoordinates = exports.matches = exports.save = exports.print = exports.canvasOldPhoto = exports.canvasInvert = exports.canvasFade = exports.canvasSaturation = exports.canvasContrast = exports.canvasBrightness = exports.image = exports.valueBreakpoints = exports.iconSizeToFontSize = exports.staticClassName = exports.reflow = void 0;
4
4
  const utils_1 = require("@onesy/utils");
5
5
  function reflow(element) {
6
6
  element === null || element === void 0 ? void 0 : element.offsetHeight;
@@ -1420,41 +1420,3 @@ exports.currencies = [
1420
1420
  name_plural: 'Zambian kwachas'
1421
1421
  }
1422
1422
  ];
1423
- const audioFix = async (blob, duration) => {
1424
- try {
1425
- const arrayBuffer = await blob.arrayBuffer();
1426
- const uint8Array = new Uint8Array(arrayBuffer);
1427
- // Function to find an EBML element by its ID
1428
- function findElement(idHex) {
1429
- const idBytes = new Uint8Array(idHex.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
1430
- for (let i = 0; i < uint8Array.length - idBytes.length; i++) {
1431
- if (uint8Array.slice(i, i + idBytes.length).toString() === idBytes.toString())
1432
- return i + idBytes.length; // Return position after the ID
1433
- }
1434
- return -1;
1435
- }
1436
- // WebM duration EBML ID: 0x4489 (Segment Information -> Duration)
1437
- const durationPos = findElement('4489');
1438
- if (durationPos === -1) {
1439
- throw new Error('Duration element not found in the WebM file.');
1440
- }
1441
- // Encode new duration in IEEE 754 Float64 (Big Endian, 8 bytes)
1442
- const durationBytes = new Uint8Array(new Float64Array([duration]).buffer).reverse();
1443
- // Overwrite duration bytes in the WebM file
1444
- uint8Array.set(durationBytes, durationPos);
1445
- // Convert back to Blob
1446
- const blobUpdated = new Blob([uint8Array], { type: 'audio/webm' });
1447
- return {
1448
- blob: blobUpdated,
1449
- duration
1450
- };
1451
- }
1452
- catch (error) {
1453
- return {
1454
- blob,
1455
- duration,
1456
- error
1457
- };
1458
- }
1459
- };
1460
- exports.audioFix = audioFix;