@design-edito/tools 0.4.6 → 0.4.12
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.
- package/agnostic/arrays/index.d.ts +1 -1
- package/agnostic/arrays/index.js +1 -1
- package/agnostic/arrays/make/index.d.ts +1 -1
- package/agnostic/css/index.d.ts +2 -2
- package/agnostic/css/index.js +2 -2
- package/agnostic/css/scale/index.d.ts +46 -16
- package/agnostic/css/scale/index.js +67 -38
- package/agnostic/css/scale/index.test.js +81 -64
- package/agnostic/html/deep-select/index.d.ts +31 -0
- package/agnostic/html/deep-select/index.js +52 -0
- package/agnostic/html/hyper-json/smart-tags/coalesced/index.d.ts +13 -13
- package/agnostic/html/hyper-json/smart-tags/coalesced/index.js +13 -13
- package/agnostic/html/hyper-json/smart-tags/isolated/index.d.ts +1 -1
- package/agnostic/html/hyper-json/smart-tags/isolated/index.js +1 -1
- package/agnostic/html/index.d.ts +4 -2
- package/agnostic/html/index.js +4 -2
- package/agnostic/html/watch-selection/index.d.ts +41 -0
- package/agnostic/html/watch-selection/index.js +50 -0
- package/agnostic/index.d.ts +3 -3
- package/agnostic/index.js +3 -3
- package/agnostic/misc/index.d.ts +1 -1
- package/agnostic/misc/index.js +1 -1
- package/agnostic/numbers/index.d.ts +3 -3
- package/agnostic/numbers/index.js +3 -3
- package/agnostic/objects/index.d.ts +2 -2
- package/agnostic/objects/index.js +2 -2
- package/agnostic/optim/index.d.ts +1 -1
- package/agnostic/optim/index.js +1 -1
- package/agnostic/strings/index.d.ts +2 -1
- package/agnostic/strings/index.js +2 -1
- package/agnostic/strings/split-trim/index.d.ts +27 -0
- package/agnostic/strings/split-trim/index.js +36 -0
- package/components/Video/index.controlled.d.ts +153 -0
- package/components/Video/index.controlled.js +255 -0
- package/components/Video/index.d.ts +10 -114
- package/components/Video/index.js +140 -265
- package/components/Video/utils.d.ts +11 -10
- package/components/Video/utils.js +30 -37
- package/components/index.d.ts +2 -2
- package/components/index.js +2 -2
- package/components/public-classnames.d.ts +1 -0
- package/components/public-classnames.js +1 -0
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/node/@aws-s3/storage/directory/index.d.ts +1 -1
- package/node/@aws-s3/storage/directory/index.js +1 -1
- package/node/@aws-s3/storage/file/index.d.ts +1 -1
- package/node/@aws-s3/storage/file/index.js +1 -1
- package/node/@google-cloud/storage/file/index.d.ts +1 -1
- package/node/@google-cloud/storage/file/index.js +1 -1
- package/node/ftps/file/index.d.ts +1 -1
- package/node/ftps/file/index.js +1 -1
- package/node/images/transform/operations/index.d.ts +2 -2
- package/node/images/transform/operations/index.js +2 -2
- package/node/index.d.ts +3 -3
- package/node/index.js +3 -3
- package/node/sftp/file/index.d.ts +2 -2
- package/node/sftp/file/index.js +2 -2
- package/package.json +22 -1
package/agnostic/html/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * as getNodeAncestors from './get-node-ancestors/index.js'
|
|
2
|
-
export * as hyperJson from './hyper-json/index.js'
|
|
3
2
|
export * as getPositionInsideParent from './get-position-inside-parent/index.js'
|
|
3
|
+
export * as hyperJson from './hyper-json/index.js'
|
|
4
4
|
export * as insertNode from './insert-node/index.js'
|
|
5
5
|
export * as placeholders from './placeholders/index.js'
|
|
6
6
|
export * as replaceInElement from './replace-in-element/index.js'
|
|
7
|
-
export * as stringToNodes from './string-to-nodes/index.js'
|
|
8
7
|
export * as selectorToElement from './selector-to-element/index.js'
|
|
8
|
+
export * as deepSelect from './deep-select/index.js'
|
|
9
|
+
export * as stringToNodes from './string-to-nodes/index.js'
|
|
10
|
+
export * as watchSelection from './watch-selection/index.js'
|
package/agnostic/html/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
export * as getNodeAncestors from './get-node-ancestors/index.js'
|
|
2
|
-
export * as hyperJson from './hyper-json/index.js'
|
|
3
2
|
export * as getPositionInsideParent from './get-position-inside-parent/index.js'
|
|
3
|
+
export * as hyperJson from './hyper-json/index.js'
|
|
4
4
|
export * as insertNode from './insert-node/index.js'
|
|
5
5
|
export * as placeholders from './placeholders/index.js'
|
|
6
6
|
export * as replaceInElement from './replace-in-element/index.js'
|
|
7
|
-
export * as stringToNodes from './string-to-nodes/index.js'
|
|
8
7
|
export * as selectorToElement from './selector-to-element/index.js'
|
|
8
|
+
export * as deepSelect from './deep-select/index.js'
|
|
9
|
+
export * as stringToNodes from './string-to-nodes/index.js'
|
|
10
|
+
export * as watchSelection from './watch-selection/index.js'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** Options for `watchSelection`. */
|
|
2
|
+
type Options = {
|
|
3
|
+
/** Called when a matching element newly appears in the selection. Defaults to a no-op. */
|
|
4
|
+
watch?: (elt: Element) => void;
|
|
5
|
+
/** Called when a matching element is no longer in the selection. Defaults to a no-op. */
|
|
6
|
+
unwatch?: (elt: Element) => void;
|
|
7
|
+
/** Interval in milliseconds between selection polls. Defaults to `100`. */
|
|
8
|
+
selectIntervalMs?: number;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Watches a CSS selector over time and invokes callbacks when the matching set changes.
|
|
12
|
+
*
|
|
13
|
+
* Performs an initial `deepSelect`, calls `watch` on every match, then polls on a fixed interval.
|
|
14
|
+
* On each poll, newly matched elements trigger `watch` and elements that disappeared trigger
|
|
15
|
+
* `unwatch`. Comparison uses element identity (`===`), not structural equality.
|
|
16
|
+
*
|
|
17
|
+
* Requires a browser environment with `window` and `document`.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} selector - CSS selector passed to `deepSelect`.
|
|
20
|
+
* @param {Options} options - Callbacks and polling configuration:
|
|
21
|
+
* - `watch`: Handler for elements that enter the selection.
|
|
22
|
+
* - `unwatch`: Handler for elements that leave the selection.
|
|
23
|
+
* - `selectIntervalMs`: Delay between polls in milliseconds.
|
|
24
|
+
* @returns {Promise<{ kill: () => void }>}
|
|
25
|
+
* Resolves after the initial selection is processed. `kill` stops polling and calls `unwatch`
|
|
26
|
+
* on every element still watched.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* const { kill } = await watchSelection('.widget', {
|
|
30
|
+
* watch: elt => elt.classList.add('is-active'),
|
|
31
|
+
* unwatch: elt => elt.classList.remove('is-active'),
|
|
32
|
+
* })
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* // later, when tearing down:
|
|
36
|
+
* kill()
|
|
37
|
+
*/
|
|
38
|
+
export declare const watchSelection: (selector: string, options: Options) => Promise<{
|
|
39
|
+
kill: () => void;
|
|
40
|
+
}>;
|
|
41
|
+
export {};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { deepSelect } from '../deep-select/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Watches a CSS selector over time and invokes callbacks when the matching set changes.
|
|
4
|
+
*
|
|
5
|
+
* Performs an initial `deepSelect`, calls `watch` on every match, then polls on a fixed interval.
|
|
6
|
+
* On each poll, newly matched elements trigger `watch` and elements that disappeared trigger
|
|
7
|
+
* `unwatch`. Comparison uses element identity (`===`), not structural equality.
|
|
8
|
+
*
|
|
9
|
+
* Requires a browser environment with `window` and `document`.
|
|
10
|
+
*
|
|
11
|
+
* @param {string} selector - CSS selector passed to `deepSelect`.
|
|
12
|
+
* @param {Options} options - Callbacks and polling configuration:
|
|
13
|
+
* - `watch`: Handler for elements that enter the selection.
|
|
14
|
+
* - `unwatch`: Handler for elements that leave the selection.
|
|
15
|
+
* - `selectIntervalMs`: Delay between polls in milliseconds.
|
|
16
|
+
* @returns {Promise<{ kill: () => void }>}
|
|
17
|
+
* Resolves after the initial selection is processed. `kill` stops polling and calls `unwatch`
|
|
18
|
+
* on every element still watched.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const { kill } = await watchSelection('.widget', {
|
|
22
|
+
* watch: elt => elt.classList.add('is-active'),
|
|
23
|
+
* unwatch: elt => elt.classList.remove('is-active'),
|
|
24
|
+
* })
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // later, when tearing down:
|
|
28
|
+
* kill()
|
|
29
|
+
*/
|
|
30
|
+
export const watchSelection = async (selector, options) => {
|
|
31
|
+
const watch = options?.watch ?? (() => { });
|
|
32
|
+
const unwatch = options?.unwatch ?? (() => { });
|
|
33
|
+
let watched = await deepSelect(selector);
|
|
34
|
+
watched.forEach(watch);
|
|
35
|
+
const selectIntervalMs = options?.selectIntervalMs ?? 100;
|
|
36
|
+
const interval = window.setInterval(() => {
|
|
37
|
+
void deepSelect(selector).then(watchedNow => {
|
|
38
|
+
const staleWatched = watched.filter(elt => !watchedNow.includes(elt));
|
|
39
|
+
const newWatched = watchedNow.filter(elt => !watched.includes(elt));
|
|
40
|
+
staleWatched.forEach(unwatch);
|
|
41
|
+
newWatched.forEach(watch);
|
|
42
|
+
watched = watchedNow;
|
|
43
|
+
});
|
|
44
|
+
}, selectIntervalMs);
|
|
45
|
+
const kill = () => {
|
|
46
|
+
window.clearInterval(interval);
|
|
47
|
+
watched.forEach(unwatch);
|
|
48
|
+
};
|
|
49
|
+
return { kill };
|
|
50
|
+
};
|
package/agnostic/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export * as arrays from './arrays/index.js'
|
|
2
|
-
export * as booleans from './booleans/index.js'
|
|
3
2
|
export * as colors from './colors/index.js'
|
|
4
3
|
export * as css from './css/index.js'
|
|
5
4
|
export * as errors from './errors/index.js'
|
|
6
|
-
export * as html from './html/index.js'
|
|
7
5
|
export * as misc from './misc/index.js'
|
|
6
|
+
export * as html from './html/index.js'
|
|
8
7
|
export * as numbers from './numbers/index.js'
|
|
9
8
|
export * as objects from './objects/index.js'
|
|
9
|
+
export * as booleans from './booleans/index.js'
|
|
10
10
|
export * as optim from './optim/index.js'
|
|
11
11
|
export * as random from './random/index.js'
|
|
12
|
+
export * as regexps from './regexps/index.js'
|
|
12
13
|
export * as sanitization from './sanitization/index.js'
|
|
13
14
|
export * as strings from './strings/index.js'
|
|
14
15
|
export * as time from './time/index.js'
|
|
15
|
-
export * as regexps from './regexps/index.js'
|
|
16
16
|
export * as typescript from './typescript/index.js'
|
package/agnostic/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export * as arrays from './arrays/index.js'
|
|
2
|
-
export * as booleans from './booleans/index.js'
|
|
3
2
|
export * as colors from './colors/index.js'
|
|
4
3
|
export * as css from './css/index.js'
|
|
5
4
|
export * as errors from './errors/index.js'
|
|
6
|
-
export * as html from './html/index.js'
|
|
7
5
|
export * as misc from './misc/index.js'
|
|
6
|
+
export * as html from './html/index.js'
|
|
8
7
|
export * as numbers from './numbers/index.js'
|
|
9
8
|
export * as objects from './objects/index.js'
|
|
9
|
+
export * as booleans from './booleans/index.js'
|
|
10
10
|
export * as optim from './optim/index.js'
|
|
11
11
|
export * as random from './random/index.js'
|
|
12
|
+
export * as regexps from './regexps/index.js'
|
|
12
13
|
export * as sanitization from './sanitization/index.js'
|
|
13
14
|
export * as strings from './strings/index.js'
|
|
14
15
|
export * as time from './time/index.js'
|
|
15
|
-
export * as regexps from './regexps/index.js'
|
|
16
16
|
export * as typescript from './typescript/index.js'
|
package/agnostic/misc/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ export * as crawler from './crawler/index.js'
|
|
|
5
5
|
export * as crossenv from './crossenv/index.js'
|
|
6
6
|
export * as dataSize from './data-size/index.js'
|
|
7
7
|
export * as isConstructorFunction from './is-constructor-function/index.js'
|
|
8
|
-
export * as logs from './logs/index.js'
|
|
9
8
|
export * as isNullish from './is-nullish/index.js'
|
|
9
|
+
export * as logs from './logs/index.js'
|
|
10
10
|
export * as loremIpsum from './lorem-ipsum/index.js'
|
|
11
11
|
export * as normalizeExtension from './normalize-extension/index.js'
|
|
12
12
|
export * as outcome from './outcome/index.js'
|
package/agnostic/misc/index.js
CHANGED
|
@@ -5,8 +5,8 @@ export * as crawler from './crawler/index.js'
|
|
|
5
5
|
export * as crossenv from './crossenv/index.js'
|
|
6
6
|
export * as dataSize from './data-size/index.js'
|
|
7
7
|
export * as isConstructorFunction from './is-constructor-function/index.js'
|
|
8
|
-
export * as logs from './logs/index.js'
|
|
9
8
|
export * as isNullish from './is-nullish/index.js'
|
|
9
|
+
export * as logs from './logs/index.js'
|
|
10
10
|
export * as loremIpsum from './lorem-ipsum/index.js'
|
|
11
11
|
export * as normalizeExtension from './normalize-extension/index.js'
|
|
12
12
|
export * as outcome from './outcome/index.js'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * as absoluteModulo from './absolute-modulo/index.js'
|
|
2
1
|
export * as approximateRational from './approximate-rational/index.js'
|
|
2
|
+
export * as absoluteModulo from './absolute-modulo/index.js'
|
|
3
|
+
export * as geometricProgressions from './geometric-progressions/index.js'
|
|
3
4
|
export * as clamp from './clamp/index.js'
|
|
4
|
-
export * as interpolate from './interpolate/index.js'
|
|
5
5
|
export * as round from './round/index.js'
|
|
6
|
-
export * as
|
|
6
|
+
export * as interpolate from './interpolate/index.js'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * as absoluteModulo from './absolute-modulo/index.js'
|
|
2
1
|
export * as approximateRational from './approximate-rational/index.js'
|
|
2
|
+
export * as absoluteModulo from './absolute-modulo/index.js'
|
|
3
|
+
export * as geometricProgressions from './geometric-progressions/index.js'
|
|
3
4
|
export * as clamp from './clamp/index.js'
|
|
4
|
-
export * as interpolate from './interpolate/index.js'
|
|
5
5
|
export * as round from './round/index.js'
|
|
6
|
-
export * as
|
|
6
|
+
export * as interpolate from './interpolate/index.js'
|
|
@@ -2,8 +2,8 @@ export * as deepGetProperty from './deep-get-property/index.js'
|
|
|
2
2
|
export * as enums from './enums/index.js'
|
|
3
3
|
export * as flattenGetters from './flatten-getters/index.js'
|
|
4
4
|
export * as isObject from './is-object/index.js'
|
|
5
|
-
export * as isRecord from './is-record/index.js'
|
|
6
5
|
export * as recordFormat from './record-format/index.js'
|
|
7
|
-
export * as
|
|
6
|
+
export * as isRecord from './is-record/index.js'
|
|
8
7
|
export * as recordMap from './record-map/index.js'
|
|
8
|
+
export * as sortKeys from './sort-keys/index.js'
|
|
9
9
|
export * as validation from './validation/index.js'
|
|
@@ -2,8 +2,8 @@ export * as deepGetProperty from './deep-get-property/index.js'
|
|
|
2
2
|
export * as enums from './enums/index.js'
|
|
3
3
|
export * as flattenGetters from './flatten-getters/index.js'
|
|
4
4
|
export * as isObject from './is-object/index.js'
|
|
5
|
-
export * as isRecord from './is-record/index.js'
|
|
6
5
|
export * as recordFormat from './record-format/index.js'
|
|
7
|
-
export * as
|
|
6
|
+
export * as isRecord from './is-record/index.js'
|
|
8
7
|
export * as recordMap from './record-map/index.js'
|
|
8
|
+
export * as sortKeys from './sort-keys/index.js'
|
|
9
9
|
export * as validation from './validation/index.js'
|
package/agnostic/optim/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * as charCodes from './char-codes/index.js'
|
|
2
2
|
export * as matches from './matches/index.js'
|
|
3
3
|
export * as normalizeIndent from './normalize-indent/index.js'
|
|
4
|
-
export * as parseTable from './parse-table/index.js'
|
|
5
4
|
export * as replaceAll from './replace-all/index.js'
|
|
6
5
|
export * as toAlphanum from './to-alphanum/index.js'
|
|
6
|
+
export * as parseTable from './parse-table/index.js'
|
|
7
|
+
export * as splitTrim from './split-trim/index.js'
|
|
7
8
|
export * as trim from './trim/index.js'
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export * as charCodes from './char-codes/index.js'
|
|
2
2
|
export * as matches from './matches/index.js'
|
|
3
3
|
export * as normalizeIndent from './normalize-indent/index.js'
|
|
4
|
-
export * as parseTable from './parse-table/index.js'
|
|
5
4
|
export * as replaceAll from './replace-all/index.js'
|
|
6
5
|
export * as toAlphanum from './to-alphanum/index.js'
|
|
6
|
+
export * as parseTable from './parse-table/index.js'
|
|
7
|
+
export * as splitTrim from './split-trim/index.js'
|
|
7
8
|
export * as trim from './trim/index.js'
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits a string into segments, trims whitespace from each part, and optionally removes empty segments.
|
|
3
|
+
*
|
|
4
|
+
* Each segment is trimmed with `String.prototype.trim`. When `removeEmpty` is `true`, segments that
|
|
5
|
+
* become empty after trimming are filtered out.
|
|
6
|
+
*
|
|
7
|
+
* When `splitter` is an array, each separator is applied in order: every current segment is split
|
|
8
|
+
* with the next separator before moving on to the following one.
|
|
9
|
+
*
|
|
10
|
+
* @param toSplit - The string to split.
|
|
11
|
+
* @param splitter - A single separator, or an ordered list of separators passed to `String.prototype.split`.
|
|
12
|
+
* @param removeEmpty - When `true`, drops segments that are empty after trimming. Defaults to `false`.
|
|
13
|
+
* @returns An array of trimmed string segments.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* splitTrim(' foo , bar , baz ', ',')
|
|
17
|
+
* // => ['foo', 'bar', 'baz']
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* splitTrim('foo,,bar', ',', true)
|
|
21
|
+
* // => ['foo', 'bar']
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* splitTrim('foo bar,baz', [' ', ','])
|
|
25
|
+
* // => ['foo', 'bar', 'baz']
|
|
26
|
+
*/
|
|
27
|
+
export declare const splitTrim: (toSplit: string, splitter: string | RegExp | Array<string | RegExp>, removeEmpty?: boolean) => string[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Splits a string into segments, trims whitespace from each part, and optionally removes empty segments.
|
|
3
|
+
*
|
|
4
|
+
* Each segment is trimmed with `String.prototype.trim`. When `removeEmpty` is `true`, segments that
|
|
5
|
+
* become empty after trimming are filtered out.
|
|
6
|
+
*
|
|
7
|
+
* When `splitter` is an array, each separator is applied in order: every current segment is split
|
|
8
|
+
* with the next separator before moving on to the following one.
|
|
9
|
+
*
|
|
10
|
+
* @param toSplit - The string to split.
|
|
11
|
+
* @param splitter - A single separator, or an ordered list of separators passed to `String.prototype.split`.
|
|
12
|
+
* @param removeEmpty - When `true`, drops segments that are empty after trimming. Defaults to `false`.
|
|
13
|
+
* @returns An array of trimmed string segments.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* splitTrim(' foo , bar , baz ', ',')
|
|
17
|
+
* // => ['foo', 'bar', 'baz']
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* splitTrim('foo,,bar', ',', true)
|
|
21
|
+
* // => ['foo', 'bar']
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* splitTrim('foo bar,baz', [' ', ','])
|
|
25
|
+
* // => ['foo', 'bar', 'baz']
|
|
26
|
+
*/
|
|
27
|
+
export const splitTrim = (toSplit, splitter, removeEmpty = false) => {
|
|
28
|
+
const splitters = Array.isArray(splitter) ? splitter : [splitter];
|
|
29
|
+
let returned = [toSplit];
|
|
30
|
+
for (const s of splitters) {
|
|
31
|
+
returned = returned.flatMap(e => e.split(s));
|
|
32
|
+
}
|
|
33
|
+
return returned
|
|
34
|
+
.map(e => e.trim())
|
|
35
|
+
.filter(e => !removeEmpty || e !== '');
|
|
36
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { type FunctionComponent, type PropsWithChildren, type VideoHTMLAttributes, type ReactEventHandler } from 'react';
|
|
2
|
+
import { type WithClassName } from '../utils/types.js';
|
|
3
|
+
import { type Props as SubsProps } from '../Subtitles/index.js';
|
|
4
|
+
/**
|
|
5
|
+
* Describes a single video source.
|
|
6
|
+
*
|
|
7
|
+
* @property src - URL of the video file.
|
|
8
|
+
* @property type - MIME type of the source (e.g. `'video/mp4'`).
|
|
9
|
+
*/
|
|
10
|
+
type SourceData = {
|
|
11
|
+
src?: string;
|
|
12
|
+
type?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Describes a single text track (subtitles, captions, chapters, etc.).
|
|
16
|
+
*
|
|
17
|
+
* @property src - URL of the track file.
|
|
18
|
+
* @property kind - Track type, maps directly to the `<track>` `kind` attribute.
|
|
19
|
+
* @property srclang - Language of the track content (e.g. `'fr'`, `'en'`).
|
|
20
|
+
* @property label - Human-readable label shown in the browser's track selector.
|
|
21
|
+
* @property default - When `true`, marks this track as the default selection.
|
|
22
|
+
*/
|
|
23
|
+
type TrackData = {
|
|
24
|
+
src?: string;
|
|
25
|
+
kind?: 'subtitles' | 'captions' | 'descriptions' | 'chapters' | 'metadata';
|
|
26
|
+
srclang?: string;
|
|
27
|
+
label?: string;
|
|
28
|
+
default?: boolean;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Callbacks for user actions on the video player controls.
|
|
32
|
+
* Allows you to intercept user actions on the player's buttons and sliders.
|
|
33
|
+
*
|
|
34
|
+
* @property playButtonClick - Called when the play button is clicked. Receives the event, isPlaying state and HTMLVideoElement before any change happens. If the time is not controlled by parent (no currentTime given as props), the component will play to the target time right after.
|
|
35
|
+
* @property pauseButtonClick - Called when the pause button is clicked. Receives the event, isPlaying state and HTMLVideoElement before any change happens. If the time is not controlled by parent (no currentTime given as props), the component will pause to the target time right after.
|
|
36
|
+
* @property loudButtonClick - Called when the "loud" (unmute) button is clicked. Receives the event, isLoud state and HTMLVideoElement before any change happens.
|
|
37
|
+
* @property muteButtonClick - Called when the mute button is clicked. Receives the event, isLoud state and HTMLVideoElement before any change happens.
|
|
38
|
+
* @property volumeRangeChange - Called when the volume slider is changed. Receives the event, target volume (0 to 1), current volume (0 to 1) and HTMLVideoElement before any change happens.
|
|
39
|
+
* @property fullscreenButtonClick - Called when the fullscreen button is clicked. Receives the event, isFullscreen state and HTMLVideoElement before any change happens.
|
|
40
|
+
* @property rateRangeChange - Called when the playback rate slider is changed. Receives the event, target rate, current rate and HTMLVideoElement before any change happens.
|
|
41
|
+
* @property timelineClick - Called when the timeline is clicked. Receives the event, target time (in seconds), current time (in seconds) and HTMLVideoElement before any change happens. If the time is not controlled by parent (no currentTime given as props), the component will update the video current time to the target time right after.
|
|
42
|
+
*/
|
|
43
|
+
export type ActionHandlersProps = {
|
|
44
|
+
playButtonClick?: (e: React.MouseEvent<HTMLButtonElement>, isPlaying: boolean, video: HTMLVideoElement | null) => void;
|
|
45
|
+
pauseButtonClick?: (e: React.MouseEvent<HTMLButtonElement>, isPlaying: boolean, video: HTMLVideoElement | null) => void;
|
|
46
|
+
loudButtonClick?: (e: React.MouseEvent<HTMLButtonElement>, isLoud: boolean, video: HTMLVideoElement | null) => void;
|
|
47
|
+
muteButtonClick?: (e: React.MouseEvent<HTMLButtonElement>, isLoud: boolean, video: HTMLVideoElement | null) => void;
|
|
48
|
+
volumeRangeChange?: (e: React.ChangeEvent<HTMLInputElement>, targetVolumePercent: number, currentVolumePercent: number, video: HTMLVideoElement | null) => void;
|
|
49
|
+
fullscreenButtonClick?: (e: React.MouseEvent<HTMLButtonElement>, isFullscreen: boolean, video: HTMLVideoElement | null) => void;
|
|
50
|
+
rateRangeChange?: (e: React.ChangeEvent<HTMLInputElement>, targetRate: number, rate: number, video: HTMLVideoElement | null) => void;
|
|
51
|
+
timelineClick?: (e: React.MouseEvent<HTMLDivElement>, time: number, currentTime: number, video: HTMLVideoElement | null) => void;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Callbacks to synchronize the internal player state with the outside.
|
|
55
|
+
*
|
|
56
|
+
* @property isPlaying - Called whenever the play/pause state changes.
|
|
57
|
+
* @property isFullscreen - Called whenever the fullscreen state changes.
|
|
58
|
+
* @property isLoud - Called whenever the mute/unmute state changes (true = unmuted, false = muted).
|
|
59
|
+
* @property volume - Called whenever the volume changes (value between 0 and 1).
|
|
60
|
+
* @property playbackRate - Called whenever the playback speed changes.
|
|
61
|
+
* @property currentTime - Called on every change of the current time (in seconds).
|
|
62
|
+
*/
|
|
63
|
+
export type StateHandlersProps = {
|
|
64
|
+
isPlaying?: (isPlaying: boolean) => void;
|
|
65
|
+
isFullscreen?: (isFullscreen: boolean) => void;
|
|
66
|
+
isLoud?: (isLoud: boolean) => void;
|
|
67
|
+
volume?: (volume: number) => void;
|
|
68
|
+
playbackRate?: (rate: number) => void;
|
|
69
|
+
currentTime?: (currentTime: number) => void;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Props for the ControlledVideo component.
|
|
73
|
+
*
|
|
74
|
+
* @property sources - List of video sources (string, array of strings, or SourceData objects).
|
|
75
|
+
* @property tracks - List of tracks (subtitles, captions, etc.), string, array of strings, or TrackData objects.
|
|
76
|
+
* @property subtitles - Props for the Subtitles component.
|
|
77
|
+
* @property playBtnContent - React content for the play button.
|
|
78
|
+
* @property pauseBtnContent - React content for the pause button.
|
|
79
|
+
* @property loudBtnContent - React content for the "loud" (unmute) button.
|
|
80
|
+
* @property muteBtnContent - React content for the mute button.
|
|
81
|
+
* @property fullscreenBtnContent - React content for the fullscreen button.
|
|
82
|
+
* @property play - External control of play state (true = play, false = pause).
|
|
83
|
+
* @property fullscreen - External control of fullscreen mode.
|
|
84
|
+
* @property volume - External control of volume (0 to 1).
|
|
85
|
+
* @property mute - External control of mute (true = muted).
|
|
86
|
+
* @property playbackRate - External control of playback speed.
|
|
87
|
+
* @property currentTimeMs - External control of current time (in ms). If given, the component considers the current time to be controlled by the parent, and will not attempt to update it internally on user interactions (play, timeline click, etc.), leaving it up to the parent to update this prop accordingly.
|
|
88
|
+
* @property actionHandlers - Callbacks for user actions on the controls.
|
|
89
|
+
* @property stateHandlers - Callbacks to synchronize internal state with the outside.
|
|
90
|
+
* @property onFullscreenChange - Callback for native fullscreen mode changes.
|
|
91
|
+
* @property _modifiers - Optional CSS modifiers for the root element.
|
|
92
|
+
* @property className - Additional CSS class for the root element.
|
|
93
|
+
* @property children - React content inserted into the <video> tag (fallback, etc).
|
|
94
|
+
*
|
|
95
|
+
* Also inherits all standard HTML props for a <video> element.
|
|
96
|
+
*/
|
|
97
|
+
export type Props = PropsWithChildren<WithClassName<{
|
|
98
|
+
sources?: string | string[] | SourceData[];
|
|
99
|
+
tracks?: string | string[] | TrackData[];
|
|
100
|
+
subtitles?: SubsProps;
|
|
101
|
+
playBtnContent?: React.ReactNode;
|
|
102
|
+
pauseBtnContent?: React.ReactNode;
|
|
103
|
+
loudBtnContent?: React.ReactNode;
|
|
104
|
+
muteBtnContent?: React.ReactNode;
|
|
105
|
+
fullscreenBtnContent?: React.ReactNode;
|
|
106
|
+
play?: boolean;
|
|
107
|
+
fullscreen?: boolean;
|
|
108
|
+
volume?: number;
|
|
109
|
+
mute?: boolean;
|
|
110
|
+
playbackRate?: number;
|
|
111
|
+
currentTimeMs?: number;
|
|
112
|
+
onFullscreenChange?: ReactEventHandler<HTMLVideoElement>;
|
|
113
|
+
actionHandlers?: ActionHandlersProps;
|
|
114
|
+
stateHandlers?: StateHandlersProps;
|
|
115
|
+
_modifiers?: Record<string, boolean>;
|
|
116
|
+
}> & VideoHTMLAttributes<HTMLVideoElement>>;
|
|
117
|
+
/**
|
|
118
|
+
* Full-featured video player component. Wraps a native `<video>` element with
|
|
119
|
+
* playback controls, volume, playback rate, a timeline, optional subtitles
|
|
120
|
+
* and viewport-driven auto-play/mute behaviours.
|
|
121
|
+
*
|
|
122
|
+
* ### Root element modifiers
|
|
123
|
+
* The root `<figure>` receives the public class name defined by `video` and
|
|
124
|
+
* the following BEM-style modifier classes:
|
|
125
|
+
* - `--play-on` / `--play-off` — reflects current playback state.
|
|
126
|
+
* - `--fullscreen-on` / `--fullscreen-off` — reflects fullscreen state.
|
|
127
|
+
* - `--loud` / `--muted` — reflects mute state.
|
|
128
|
+
*
|
|
129
|
+
* ### Data attributes on the root element
|
|
130
|
+
* - `data-play-on` — present (empty string) when playing.
|
|
131
|
+
* - `data-play-off` — present (empty string) when paused.
|
|
132
|
+
* - `data-fullscreen-on` — present (empty string) when in fullscreen.
|
|
133
|
+
* - `data-fullscreen-off` — present (empty string) when not in fullscreen.
|
|
134
|
+
* - `data-loud` — present (empty string) when unmuted.
|
|
135
|
+
* - `data-muted` — present (empty string) when muted.
|
|
136
|
+
* - `data-volume` — current volume as a `0–1` float.
|
|
137
|
+
* - `data-volume-percent` — current volume as a `0–100` float.
|
|
138
|
+
* - `data-playback-rate` — current playback rate (e.g. `1`, `1.5`).
|
|
139
|
+
* - `data-current-time-ms` — current time in milliseconds, fixed to 2 decimals.
|
|
140
|
+
* - `data-current-time-ratio` — current / total ratio, fixed to 8 decimals.
|
|
141
|
+
* - `data-total-time-ms` — total duration in milliseconds.
|
|
142
|
+
*
|
|
143
|
+
* ### CSS custom properties on the root element
|
|
144
|
+
* - `--video-current-time-ratio` — current / total ratio, fixed to 8 decimals.
|
|
145
|
+
* Useful for driving progress-bar animations purely in CSS.
|
|
146
|
+
*
|
|
147
|
+
* @param props - Component properties.
|
|
148
|
+
* @see {@link Props}
|
|
149
|
+
* @returns A `<figure>` element containing the video, its controls, optional
|
|
150
|
+
* subtitles.
|
|
151
|
+
*/
|
|
152
|
+
export declare const ControlledVideo: FunctionComponent<Props>;
|
|
153
|
+
export {};
|