@micromag/element-audio 0.4.49 → 0.4.50

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 (2) hide show
  1. package/es/index.js +98 -93
  2. package/package.json +4 -4
package/es/index.js CHANGED
@@ -1,14 +1,16 @@
1
+ import _objectSpread from '@babel/runtime/helpers/objectSpread2';
1
2
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
2
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
4
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
5
  import classNames from 'classnames';
5
6
  import isFunction from 'lodash/isFunction';
6
7
  import isNumber from 'lodash/isNumber';
7
- import React, { useState, useMemo, useCallback, useRef, useEffect } from 'react';
8
+ import { useState, useMemo, useCallback, useRef, useEffect } from 'react';
8
9
  import { useDimensionObserver, useMediaCurrentTime, useMediaReady, useMediaDuration, useMediaLoad, useProgressSteps, useDevicePixelRatio } from '@micromag/core/hooks';
9
10
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
10
11
  import { useGesture } from '@use-gesture/react';
11
12
  import { useIntl } from 'react-intl';
13
+ import { jsxs, jsx } from 'react/jsx-runtime';
12
14
  import { useSpringRef, useSpring } from '@react-spring/core';
13
15
  import { animated } from '@react-spring/web';
14
16
  import { getContrastingColor } from '@micromag/core/utils';
@@ -112,52 +114,53 @@ function AudioBars(_ref) {
112
114
  filterTaps: true
113
115
  }
114
116
  });
115
- return /*#__PURE__*/React.createElement("div", {
117
+ return /*#__PURE__*/jsxs("div", {
116
118
  className: classNames([styles$2.container, className]),
117
- ref: elRef
118
- }, /*#__PURE__*/React.createElement("svg", {
119
- version: "1.1",
120
- xmlns: "http://www.w3.org/2000/svg",
121
- xmlnsXlink: "http://www.w3.org/1999/xlink",
122
- x: "0",
123
- y: "0",
124
- width: "".concat(elWidth, "px"),
125
- height: "".concat(elHeight, "px"),
126
- viewBox: "0 0 ".concat(elWidth, " ").concat(elHeight),
127
- className: className,
128
- xmlSpace: "preserve"
129
- }, items.map(function (size, i) {
130
- return /*#__PURE__*/React.createElement("rect", {
131
- key: "bar-".concat(i + 1),
132
- width: barWidth,
133
- height: size,
134
- x: i * barSize,
135
- y: elHeight / 2 - size / 2,
136
- fill: (currentSeek || current) > i * barSize ? 'white' : 'gray',
137
- stroke: "black",
138
- strokeWidth: "0px",
139
- strokeLinejoin: "round",
140
- strokeLinecap: "round"
141
- });
142
- })), /*#__PURE__*/React.createElement("button", Object.assign({}, bind(), {
143
- onClick: onClick,
144
- type: "button",
145
- className: styles$2.seekButton,
146
- title: intl.formatMessage({
147
- id: "G1Gyjn",
148
- defaultMessage: [{
149
- "type": 0,
150
- "value": "Seek"
151
- }]
152
- }),
153
- "aria-label": intl.formatMessage({
154
- id: "G1Gyjn",
155
- defaultMessage: [{
156
- "type": 0,
157
- "value": "Seek"
158
- }]
159
- })
160
- })));
119
+ ref: elRef,
120
+ children: [/*#__PURE__*/jsx("svg", {
121
+ version: "1.1",
122
+ xmlns: "http://www.w3.org/2000/svg",
123
+ xmlnsXlink: "http://www.w3.org/1999/xlink",
124
+ x: "0",
125
+ y: "0",
126
+ width: "".concat(elWidth, "px"),
127
+ height: "".concat(elHeight, "px"),
128
+ viewBox: "0 0 ".concat(elWidth, " ").concat(elHeight),
129
+ className: className,
130
+ xmlSpace: "preserve",
131
+ children: items.map(function (size, i) {
132
+ return /*#__PURE__*/jsx("rect", {
133
+ width: barWidth,
134
+ height: size,
135
+ x: i * barSize,
136
+ y: elHeight / 2 - size / 2,
137
+ fill: (currentSeek || current) > i * barSize ? 'white' : 'gray',
138
+ stroke: "black",
139
+ strokeWidth: "0px",
140
+ strokeLinejoin: "round",
141
+ strokeLinecap: "round"
142
+ }, "bar-".concat(i + 1));
143
+ })
144
+ }), /*#__PURE__*/jsx("button", _objectSpread(_objectSpread({}, bind()), {}, {
145
+ onClick: onClick,
146
+ type: "button",
147
+ className: styles$2.seekButton,
148
+ title: intl.formatMessage({
149
+ id: "G1Gyjn",
150
+ defaultMessage: [{
151
+ "type": 0,
152
+ "value": "Seek"
153
+ }]
154
+ }),
155
+ "aria-label": intl.formatMessage({
156
+ id: "G1Gyjn",
157
+ defaultMessage: [{
158
+ "type": 0,
159
+ "value": "Seek"
160
+ }]
161
+ })
162
+ }))]
163
+ });
161
164
  }
162
165
 
163
166
  var styles$1 = {"container":"micromag-element-audio-container","wave":"micromag-element-audio-wave","withAutoHeight":"micromag-element-audio-withAutoHeight"};
@@ -319,45 +322,45 @@ function Audio(_ref) {
319
322
  onStep: onProgressStep
320
323
  });
321
324
  var progress = currentTime !== null && duration > 0 ? currentTime / duration : 0;
322
- return /*#__PURE__*/React.createElement("div", {
323
- className: classNames([styles$1.container, className])
324
- }, /*#__PURE__*/React.createElement("audio", {
325
- key: srcUrl,
326
- ref: function ref(newRef) {
327
- _ref7.current = newRef;
328
- if (mediaRef !== null && isFunction(mediaRef)) {
329
- mediaRef(newRef);
330
- } else if (mediaRef !== null) {
331
- mediaRef.current = newRef;
332
- }
333
- },
334
- src: srcUrl,
335
- autoPlay: autoPlay && !paused,
336
- muted: muted,
337
- loop: loop,
338
- crossOrigin: "anonymous",
339
- preload: preload,
340
- onPlay: onPlay,
341
- onPause: onPause,
342
- onEnded: onEnded,
343
- onSeeked: onSeeked,
344
- onTimeUpdate: onTimeUpdate,
345
- onVolumeChange: onVolumeChange
346
- }), withWave ? /*#__PURE__*/React.createElement(AudioBars, {
347
- className: classNames([styles$1.wave, _defineProperty({}, styles$1.withAutoHeight, autoWaveHeight)]),
348
- progress: progress
349
- // {...waveProps}
350
- ,
351
- duration: duration,
352
- playing: !paused,
353
- seek: !withoutSeek ? onWaveSeek : null,
354
- play: onWavePlay
355
- }) : null);
325
+ return /*#__PURE__*/jsxs("div", {
326
+ className: classNames([styles$1.container, className]),
327
+ children: [/*#__PURE__*/jsx("audio", {
328
+ ref: function ref(newRef) {
329
+ _ref7.current = newRef;
330
+ if (mediaRef !== null && isFunction(mediaRef)) {
331
+ mediaRef(newRef);
332
+ } else if (mediaRef !== null) {
333
+ mediaRef.current = newRef;
334
+ }
335
+ },
336
+ src: srcUrl,
337
+ autoPlay: autoPlay && !paused,
338
+ muted: muted,
339
+ loop: loop,
340
+ crossOrigin: "anonymous",
341
+ preload: preload,
342
+ onPlay: onPlay,
343
+ onPause: onPause,
344
+ onEnded: onEnded,
345
+ onSeeked: onSeeked,
346
+ onTimeUpdate: onTimeUpdate,
347
+ onVolumeChange: onVolumeChange
348
+ }, srcUrl), withWave ? /*#__PURE__*/jsx(AudioBars, {
349
+ className: classNames([styles$1.wave, _defineProperty({}, styles$1.withAutoHeight, autoWaveHeight)]),
350
+ progress: progress
351
+ // {...waveProps}
352
+ ,
353
+ duration: duration,
354
+ playing: !paused,
355
+ seek: !withoutSeek ? onWaveSeek : null,
356
+ play: onWavePlay
357
+ }) : null]
358
+ });
356
359
  }
357
360
  var Audio_default = (function (_ref9) {
358
361
  var ref = _ref9.ref,
359
362
  props = _objectWithoutProperties(_ref9, _excluded);
360
- return /*#__PURE__*/React.createElement(Audio, Object.assign({
363
+ return /*#__PURE__*/jsx(Audio, _objectSpread({
361
364
  mediaRef: ref
362
365
  }, props));
363
366
  });
@@ -554,20 +557,22 @@ function AudioWave(_ref) {
554
557
  filterTaps: true
555
558
  }
556
559
  });
557
- return /*#__PURE__*/React.createElement("div", Object.assign({
560
+ return /*#__PURE__*/jsxs("div", _objectSpread(_objectSpread({
558
561
  className: classNames([styles.container, className]),
559
562
  ref: elRef
560
- }, bind()), /*#__PURE__*/React.createElement("canvas", {
561
- ref: canvasBackgroundRef,
562
- className: styles.canvasBackground
563
- }), /*#__PURE__*/React.createElement(animated.canvas, {
564
- ref: canvasProgressRef,
565
- className: styles.canvasProgress,
566
- style: {
567
- clipPath: springProps.x.to(function (x) {
568
- return "polygon(0 0, ".concat(x * 100, "% 0, ").concat(x * 100, "% 100%, 0 100%)");
569
- })
570
- }
563
+ }, bind()), {}, {
564
+ children: [/*#__PURE__*/jsx("canvas", {
565
+ ref: canvasBackgroundRef,
566
+ className: styles.canvasBackground
567
+ }), /*#__PURE__*/jsx(animated.canvas, {
568
+ ref: canvasProgressRef,
569
+ className: styles.canvasProgress,
570
+ style: {
571
+ clipPath: springProps.x.to(function (x) {
572
+ return "polygon(0 0, ".concat(x * 100, "% 0, ").concat(x * 100, "% 100%, 0 100%)");
573
+ })
574
+ }
575
+ })]
571
576
  }));
572
577
  }
573
578
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/element-audio",
3
- "version": "0.4.49",
3
+ "version": "0.4.50",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -61,8 +61,8 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "@babel/runtime": "^7.28.6",
64
- "@micromag/core": "^0.4.49",
65
- "@micromag/element-closed-captions": "^0.4.49",
64
+ "@micromag/core": "^0.4.50",
65
+ "@micromag/element-closed-captions": "^0.4.50",
66
66
  "@react-spring/core": "^10.0.3",
67
67
  "@react-spring/web": "^10.0.3",
68
68
  "@use-gesture/react": "^10.3.0",
@@ -75,5 +75,5 @@
75
75
  "access": "public",
76
76
  "registry": "https://registry.npmjs.org/"
77
77
  },
78
- "gitHead": "0a225ff29387217cccb0fcc5a731e23c74bd202e"
78
+ "gitHead": "940d5ca98f8f448b79eaa3e2fa685c3ee95185b8"
79
79
  }