@design-edito/tools 0.5.15 → 0.5.17

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 (55) hide show
  1. package/agnostic/colors/index.d.ts +3 -3
  2. package/agnostic/colors/index.js +3 -3
  3. package/agnostic/css/index.d.ts +2 -2
  4. package/agnostic/css/index.js +2 -2
  5. package/agnostic/html/hyper-json/smart-tags/coalesced/index.d.ts +14 -14
  6. package/agnostic/html/hyper-json/smart-tags/coalesced/index.js +14 -14
  7. package/agnostic/html/hyper-json/smart-tags/isolated/index.d.ts +5 -5
  8. package/agnostic/html/hyper-json/smart-tags/isolated/index.js +5 -5
  9. package/agnostic/html/index.d.ts +4 -4
  10. package/agnostic/html/index.js +4 -4
  11. package/agnostic/index.d.ts +2 -2
  12. package/agnostic/index.js +2 -2
  13. package/agnostic/misc/index.d.ts +5 -5
  14. package/agnostic/misc/index.js +5 -5
  15. package/agnostic/numbers/index.d.ts +2 -2
  16. package/agnostic/numbers/index.js +2 -2
  17. package/agnostic/objects/index.d.ts +3 -3
  18. package/agnostic/objects/index.js +3 -3
  19. package/agnostic/strings/index.d.ts +3 -3
  20. package/agnostic/strings/index.js +3 -3
  21. package/agnostic/time/index.d.ts +3 -3
  22. package/agnostic/time/index.js +3 -3
  23. package/components/IntersectionObserver/index.d.ts +28 -3
  24. package/components/IntersectionObserver/index.js +51 -20
  25. package/components/Video/index.controlled.d.ts +17 -1
  26. package/components/Video/index.controlled.js +20 -5
  27. package/components/Video/index.d.ts +13 -3
  28. package/components/Video/index.js +31 -12
  29. package/components/index.d.ts +3 -3
  30. package/components/index.js +3 -3
  31. package/components/public-classnames.d.ts +0 -1
  32. package/components/public-classnames.js +0 -1
  33. package/node/@aws-s3/storage/directory/index.d.ts +1 -1
  34. package/node/@aws-s3/storage/directory/index.js +1 -1
  35. package/node/@aws-s3/storage/file/index.d.ts +1 -1
  36. package/node/@aws-s3/storage/file/index.js +1 -1
  37. package/node/@aws-s3/storage/index.d.ts +1 -1
  38. package/node/@aws-s3/storage/index.js +1 -1
  39. package/node/@google-cloud/storage/file/index.d.ts +3 -3
  40. package/node/@google-cloud/storage/file/index.js +3 -3
  41. package/node/cloud-storage/operations/index.d.ts +2 -2
  42. package/node/cloud-storage/operations/index.js +2 -2
  43. package/node/files/index.d.ts +1 -1
  44. package/node/files/index.js +1 -1
  45. package/node/ftps/directory/index.d.ts +1 -1
  46. package/node/ftps/directory/index.js +1 -1
  47. package/node/ftps/file/index.d.ts +2 -2
  48. package/node/ftps/file/index.js +2 -2
  49. package/node/images/transform/operations/index.d.ts +4 -4
  50. package/node/images/transform/operations/index.js +4 -4
  51. package/node/index.d.ts +1 -1
  52. package/node/index.js +1 -1
  53. package/node/sftp/directory/index.d.ts +1 -1
  54. package/node/sftp/directory/index.js +1 -1
  55. package/package.json +1 -1
@@ -3,10 +3,10 @@ export * as contrast from './contrast/index.js'
3
3
  export * as convert from './convert/index.js'
4
4
  export * as distance from './distance/index.js'
5
5
  export * as grayscale from './grayscale/index.js'
6
- export * as invert from './invert/index.js'
7
6
  export * as lerp from './lerp/index.js'
8
- export * as luminance from './luminance/index.js'
7
+ export * as invert from './invert/index.js'
9
8
  export * as palette from './palette/index.js'
10
- export * as tidy from './tidy/index.js'
11
9
  export * as rotate from './rotate/index.js'
10
+ export * as tidy from './tidy/index.js'
12
11
  export * as typechecks from './typechecks/index.js'
12
+ export * as luminance from './luminance/index.js'
@@ -3,10 +3,10 @@ export * as contrast from './contrast/index.js'
3
3
  export * as convert from './convert/index.js'
4
4
  export * as distance from './distance/index.js'
5
5
  export * as grayscale from './grayscale/index.js'
6
- export * as invert from './invert/index.js'
7
6
  export * as lerp from './lerp/index.js'
8
- export * as luminance from './luminance/index.js'
7
+ export * as invert from './invert/index.js'
9
8
  export * as palette from './palette/index.js'
10
- export * as tidy from './tidy/index.js'
11
9
  export * as rotate from './rotate/index.js'
10
+ export * as tidy from './tidy/index.js'
12
11
  export * as typechecks from './typechecks/index.js'
12
+ export * as luminance from './luminance/index.js'
@@ -1,6 +1,6 @@
1
- export * as clss from './clss/index.js'
2
1
  export * as bem from './bem/index.js'
3
- export * as isValidCssClassName from './is-valid-css-class-name/index.js'
2
+ export * as clss from './clss/index.js'
4
3
  export * as generateNiceColor from './generate-nice-color/index.js'
4
+ export * as isValidCssClassName from './is-valid-css-class-name/index.js'
5
5
  export * as scale from './scale/index.js'
6
6
  export * as stylesSet from './styles-set/index.js'
@@ -1,6 +1,6 @@
1
- export * as clss from './clss/index.js'
2
1
  export * as bem from './bem/index.js'
3
- export * as isValidCssClassName from './is-valid-css-class-name/index.js'
2
+ export * as clss from './clss/index.js'
4
3
  export * as generateNiceColor from './generate-nice-color/index.js'
4
+ export * as isValidCssClassName from './is-valid-css-class-name/index.js'
5
5
  export * as scale from './scale/index.js'
6
6
  export * as stylesSet from './styles-set/index.js'
@@ -1,52 +1,52 @@
1
1
  export * as add from './add/index.js'
2
2
  export * as addclass from './addclass/index.js'
3
3
  export * as and from './and/index.js'
4
- export * as call from './call/index.js'
5
- export * as append from './append/index.js'
6
4
  export * as at from './at/index.js'
5
+ export * as append from './append/index.js'
7
6
  export * as clone from './clone/index.js'
7
+ export * as call from './call/index.js'
8
8
  export * as deleteproperties from './deleteproperties/index.js'
9
9
  export * as equals from './equals/index.js'
10
10
  export * as getattribute from './getattribute/index.js'
11
11
  export * as getproperties from './getproperties/index.js'
12
+ export * as getproperty from './getproperty/index.js'
12
13
  export * as hjparse from './hjparse/index.js'
13
14
  export * as hjstringify from './hjstringify/index.js'
14
- export * as getproperty from './getproperty/index.js'
15
- export * as if from './if/index.js'
16
15
  export * as initialize from './initialize/index.js'
17
16
  export * as join from './join/index.js'
18
- export * as map from './map/index.js'
19
17
  export * as length from './length/index.js'
18
+ export * as if from './if/index.js'
19
+ export * as map from './map/index.js'
20
20
  export * as negate from './negate/index.js'
21
21
  export * as notrailing from './notrailing/index.js'
22
22
  export * as or from './or/index.js'
23
23
  export * as pickrandom from './pickrandom/index.js'
24
24
  export * as populate from './populate/index.js'
25
25
  export * as print from './print/index.js'
26
- export * as push from './push/index.js'
27
26
  export * as pusheach from './pusheach/index.js'
28
27
  export * as recordtoarray from './recordtoarray/index.js'
29
- export * as removeattribute from './removeattribute/index.js'
28
+ export * as removeclass from './removeclass/index.js'
30
29
  export * as renameproperty from './renameproperty/index.js'
31
30
  export * as replace from './replace/index.js'
32
- export * as removeclass from './removeclass/index.js'
31
+ export * as removeattribute from './removeattribute/index.js'
32
+ export * as push from './push/index.js'
33
33
  export * as select from './select/index.js'
34
34
  export * as set from './set/index.js'
35
35
  export * as setattribute from './setattribute/index.js'
36
- export * as sorton from './sorton/index.js'
37
36
  export * as setproperty from './setproperty/index.js'
38
- export * as split from './split/index.js'
37
+ export * as sorton from './sorton/index.js'
39
38
  export * as spread from './spread/index.js'
39
+ export * as split from './split/index.js'
40
40
  export * as toarray from './toarray/index.js'
41
- export * as toboolean from './toboolean/index.js'
42
41
  export * as toelement from './toelement/index.js'
43
- export * as toggleclass from './toggleclass/index.js'
44
42
  export * as tonodelist from './tonodelist/index.js'
45
43
  export * as tonull from './tonull/index.js'
44
+ export * as toboolean from './toboolean/index.js'
46
45
  export * as tonumber from './tonumber/index.js'
47
46
  export * as torecord from './torecord/index.js'
48
47
  export * as toref from './toref/index.js'
49
- export * as totext from './totext/index.js'
50
48
  export * as tostring from './tostring/index.js'
51
- export * as trim from './trim/index.js'
49
+ export * as toggleclass from './toggleclass/index.js'
52
50
  export * as transformselected from './transformselected/index.js'
51
+ export * as totext from './totext/index.js'
52
+ export * as trim from './trim/index.js'
@@ -1,52 +1,52 @@
1
1
  export * as add from './add/index.js'
2
2
  export * as addclass from './addclass/index.js'
3
3
  export * as and from './and/index.js'
4
- export * as call from './call/index.js'
5
- export * as append from './append/index.js'
6
4
  export * as at from './at/index.js'
5
+ export * as append from './append/index.js'
7
6
  export * as clone from './clone/index.js'
7
+ export * as call from './call/index.js'
8
8
  export * as deleteproperties from './deleteproperties/index.js'
9
9
  export * as equals from './equals/index.js'
10
10
  export * as getattribute from './getattribute/index.js'
11
11
  export * as getproperties from './getproperties/index.js'
12
+ export * as getproperty from './getproperty/index.js'
12
13
  export * as hjparse from './hjparse/index.js'
13
14
  export * as hjstringify from './hjstringify/index.js'
14
- export * as getproperty from './getproperty/index.js'
15
- export * as if from './if/index.js'
16
15
  export * as initialize from './initialize/index.js'
17
16
  export * as join from './join/index.js'
18
- export * as map from './map/index.js'
19
17
  export * as length from './length/index.js'
18
+ export * as if from './if/index.js'
19
+ export * as map from './map/index.js'
20
20
  export * as negate from './negate/index.js'
21
21
  export * as notrailing from './notrailing/index.js'
22
22
  export * as or from './or/index.js'
23
23
  export * as pickrandom from './pickrandom/index.js'
24
24
  export * as populate from './populate/index.js'
25
25
  export * as print from './print/index.js'
26
- export * as push from './push/index.js'
27
26
  export * as pusheach from './pusheach/index.js'
28
27
  export * as recordtoarray from './recordtoarray/index.js'
29
- export * as removeattribute from './removeattribute/index.js'
28
+ export * as removeclass from './removeclass/index.js'
30
29
  export * as renameproperty from './renameproperty/index.js'
31
30
  export * as replace from './replace/index.js'
32
- export * as removeclass from './removeclass/index.js'
31
+ export * as removeattribute from './removeattribute/index.js'
32
+ export * as push from './push/index.js'
33
33
  export * as select from './select/index.js'
34
34
  export * as set from './set/index.js'
35
35
  export * as setattribute from './setattribute/index.js'
36
- export * as sorton from './sorton/index.js'
37
36
  export * as setproperty from './setproperty/index.js'
38
- export * as split from './split/index.js'
37
+ export * as sorton from './sorton/index.js'
39
38
  export * as spread from './spread/index.js'
39
+ export * as split from './split/index.js'
40
40
  export * as toarray from './toarray/index.js'
41
- export * as toboolean from './toboolean/index.js'
42
41
  export * as toelement from './toelement/index.js'
43
- export * as toggleclass from './toggleclass/index.js'
44
42
  export * as tonodelist from './tonodelist/index.js'
45
43
  export * as tonull from './tonull/index.js'
44
+ export * as toboolean from './toboolean/index.js'
46
45
  export * as tonumber from './tonumber/index.js'
47
46
  export * as torecord from './torecord/index.js'
48
47
  export * as toref from './toref/index.js'
49
- export * as totext from './totext/index.js'
50
48
  export * as tostring from './tostring/index.js'
51
- export * as trim from './trim/index.js'
49
+ export * as toggleclass from './toggleclass/index.js'
52
50
  export * as transformselected from './transformselected/index.js'
51
+ export * as totext from './totext/index.js'
52
+ export * as trim from './trim/index.js'
@@ -1,13 +1,13 @@
1
+ export * as any from './any/index.js'
1
2
  export * as array from './array/index.js'
2
3
  export * as boolean from './boolean/index.js'
3
- export * as any from './any/index.js'
4
4
  export * as element from './element/index.js'
5
- export * as get from './get/index.js'
6
- export * as nodelist from './nodelist/index.js'
7
5
  export * as guess from './guess/index.js'
6
+ export * as nodelist from './nodelist/index.js'
7
+ export * as get from './get/index.js'
8
8
  export * as null from './null/index.js'
9
- export * as number from './number/index.js'
10
9
  export * as record from './record/index.js'
11
- export * as ref from './ref/index.js'
12
10
  export * as string from './string/index.js'
13
11
  export * as text from './text/index.js'
12
+ export * as ref from './ref/index.js'
13
+ export * as number from './number/index.js'
@@ -1,13 +1,13 @@
1
+ export * as any from './any/index.js'
1
2
  export * as array from './array/index.js'
2
3
  export * as boolean from './boolean/index.js'
3
- export * as any from './any/index.js'
4
4
  export * as element from './element/index.js'
5
- export * as get from './get/index.js'
6
- export * as nodelist from './nodelist/index.js'
7
5
  export * as guess from './guess/index.js'
6
+ export * as nodelist from './nodelist/index.js'
7
+ export * as get from './get/index.js'
8
8
  export * as null from './null/index.js'
9
- export * as number from './number/index.js'
10
9
  export * as record from './record/index.js'
11
- export * as ref from './ref/index.js'
12
10
  export * as string from './string/index.js'
13
11
  export * as text from './text/index.js'
12
+ export * as ref from './ref/index.js'
13
+ export * as number from './number/index.js'
@@ -1,10 +1,10 @@
1
1
  export * as deepSelect from './deep-select/index.js'
2
2
  export * as getNodeAncestors from './get-node-ancestors/index.js'
3
3
  export * as getPositionInsideParent from './get-position-inside-parent/index.js'
4
- export * as hyperJson from './hyper-json/index.js'
5
- export * as insertNode from './insert-node/index.js'
6
4
  export * as placeholders from './placeholders/index.js'
5
+ export * as insertNode from './insert-node/index.js'
7
6
  export * as replaceInElement from './replace-in-element/index.js'
8
- export * as watchSelection from './watch-selection/index.js'
9
- export * as stringToNodes from './string-to-nodes/index.js'
10
7
  export * as selectorToElement from './selector-to-element/index.js'
8
+ export * as stringToNodes from './string-to-nodes/index.js'
9
+ export * as watchSelection from './watch-selection/index.js'
10
+ export * as hyperJson from './hyper-json/index.js'
@@ -1,10 +1,10 @@
1
1
  export * as deepSelect from './deep-select/index.js'
2
2
  export * as getNodeAncestors from './get-node-ancestors/index.js'
3
3
  export * as getPositionInsideParent from './get-position-inside-parent/index.js'
4
- export * as hyperJson from './hyper-json/index.js'
5
- export * as insertNode from './insert-node/index.js'
6
4
  export * as placeholders from './placeholders/index.js'
5
+ export * as insertNode from './insert-node/index.js'
7
6
  export * as replaceInElement from './replace-in-element/index.js'
8
- export * as watchSelection from './watch-selection/index.js'
9
- export * as stringToNodes from './string-to-nodes/index.js'
10
7
  export * as selectorToElement from './selector-to-element/index.js'
8
+ export * as stringToNodes from './string-to-nodes/index.js'
9
+ export * as watchSelection from './watch-selection/index.js'
10
+ export * as hyperJson from './hyper-json/index.js'
@@ -3,14 +3,14 @@ export * as booleans from './booleans/index.js'
3
3
  export * as colors from './colors/index.js'
4
4
  export * as css from './css/index.js'
5
5
  export * as errors from './errors/index.js'
6
+ export * as html from './html/index.js'
6
7
  export * as misc from './misc/index.js'
7
- export * as numbers from './numbers/index.js'
8
8
  export * as objects from './objects/index.js'
9
9
  export * as optim from './optim/index.js'
10
+ export * as numbers from './numbers/index.js'
10
11
  export * as random from './random/index.js'
11
12
  export * as regexps from './regexps/index.js'
12
13
  export * as sanitization from './sanitization/index.js'
13
- export * as html from './html/index.js'
14
14
  export * as strings from './strings/index.js'
15
15
  export * as subtitles from './subtitles/index.js'
16
16
  export * as time from './time/index.js'
package/agnostic/index.js CHANGED
@@ -3,14 +3,14 @@ export * as booleans from './booleans/index.js'
3
3
  export * as colors from './colors/index.js'
4
4
  export * as css from './css/index.js'
5
5
  export * as errors from './errors/index.js'
6
+ export * as html from './html/index.js'
6
7
  export * as misc from './misc/index.js'
7
- export * as numbers from './numbers/index.js'
8
8
  export * as objects from './objects/index.js'
9
9
  export * as optim from './optim/index.js'
10
+ export * as numbers from './numbers/index.js'
10
11
  export * as random from './random/index.js'
11
12
  export * as regexps from './regexps/index.js'
12
13
  export * as sanitization from './sanitization/index.js'
13
- export * as html from './html/index.js'
14
14
  export * as strings from './strings/index.js'
15
15
  export * as subtitles from './subtitles/index.js'
16
16
  export * as time from './time/index.js'
@@ -1,12 +1,12 @@
1
1
  export * as assert from './assert/index.js'
2
2
  export * as cast from './cast/index.js'
3
+ export * as connection from './connection/index.js'
3
4
  export * as crawler from './crawler/index.js'
4
5
  export * as crossenv from './crossenv/index.js'
5
- export * as connection from './connection/index.js'
6
- export * as dataSize from './data-size/index.js'
7
- export * as isNullish from './is-nullish/index.js'
8
- export * as logs from './logs/index.js'
9
6
  export * as isConstructorFunction from './is-constructor-function/index.js'
10
- export * as normalizeExtension from './normalize-extension/index.js'
7
+ export * as logs from './logs/index.js'
11
8
  export * as loremIpsum from './lorem-ipsum/index.js'
9
+ export * as normalizeExtension from './normalize-extension/index.js'
12
10
  export * as outcome from './outcome/index.js'
11
+ export * as dataSize from './data-size/index.js'
12
+ export * as isNullish from './is-nullish/index.js'
@@ -1,12 +1,12 @@
1
1
  export * as assert from './assert/index.js'
2
2
  export * as cast from './cast/index.js'
3
+ export * as connection from './connection/index.js'
3
4
  export * as crawler from './crawler/index.js'
4
5
  export * as crossenv from './crossenv/index.js'
5
- export * as connection from './connection/index.js'
6
- export * as dataSize from './data-size/index.js'
7
- export * as isNullish from './is-nullish/index.js'
8
- export * as logs from './logs/index.js'
9
6
  export * as isConstructorFunction from './is-constructor-function/index.js'
10
- export * as normalizeExtension from './normalize-extension/index.js'
7
+ export * as logs from './logs/index.js'
11
8
  export * as loremIpsum from './lorem-ipsum/index.js'
9
+ export * as normalizeExtension from './normalize-extension/index.js'
12
10
  export * as outcome from './outcome/index.js'
11
+ export * as dataSize from './data-size/index.js'
12
+ export * as isNullish from './is-nullish/index.js'
@@ -1,6 +1,6 @@
1
1
  export * as clamp from './clamp/index.js'
2
- export * as approximateRational from './approximate-rational/index.js'
2
+ export * as absoluteModulo from './absolute-modulo/index.js'
3
3
  export * as geometricProgressions from './geometric-progressions/index.js'
4
+ export * as approximateRational from './approximate-rational/index.js'
4
5
  export * as round from './round/index.js'
5
6
  export * as interpolate from './interpolate/index.js'
6
- export * as absoluteModulo from './absolute-modulo/index.js'
@@ -1,6 +1,6 @@
1
1
  export * as clamp from './clamp/index.js'
2
- export * as approximateRational from './approximate-rational/index.js'
2
+ export * as absoluteModulo from './absolute-modulo/index.js'
3
3
  export * as geometricProgressions from './geometric-progressions/index.js'
4
+ export * as approximateRational from './approximate-rational/index.js'
4
5
  export * as round from './round/index.js'
5
6
  export * as interpolate from './interpolate/index.js'
6
- export * as absoluteModulo from './absolute-modulo/index.js'
@@ -1,9 +1,9 @@
1
1
  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
- export * as isObject from './is-object/index.js'
5
- export * as recordFormat from './record-format/index.js'
6
4
  export * as isRecord from './is-record/index.js'
7
- export * as recordMap from './record-map/index.js'
5
+ export * as recordFormat from './record-format/index.js'
6
+ export * as isObject from './is-object/index.js'
8
7
  export * as sortKeys from './sort-keys/index.js'
9
8
  export * as validation from './validation/index.js'
9
+ export * as recordMap from './record-map/index.js'
@@ -1,9 +1,9 @@
1
1
  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
- export * as isObject from './is-object/index.js'
5
- export * as recordFormat from './record-format/index.js'
6
4
  export * as isRecord from './is-record/index.js'
7
- export * as recordMap from './record-map/index.js'
5
+ export * as recordFormat from './record-format/index.js'
6
+ export * as isObject from './is-object/index.js'
8
7
  export * as sortKeys from './sort-keys/index.js'
9
8
  export * as validation from './validation/index.js'
9
+ export * as recordMap from './record-map/index.js'
@@ -1,8 +1,8 @@
1
1
  export * as matches from './matches/index.js'
2
- export * as charCodes from './char-codes/index.js'
3
- export * as parseTable from './parse-table/index.js'
4
2
  export * as normalizeIndent from './normalize-indent/index.js'
3
+ export * as parseTable from './parse-table/index.js'
4
+ export * as splitTrim from './split-trim/index.js'
5
5
  export * as replaceAll from './replace-all/index.js'
6
+ export * as charCodes from './char-codes/index.js'
6
7
  export * as toAlphanum from './to-alphanum/index.js'
7
8
  export * as trim from './trim/index.js'
8
- export * as splitTrim from './split-trim/index.js'
@@ -1,8 +1,8 @@
1
1
  export * as matches from './matches/index.js'
2
- export * as charCodes from './char-codes/index.js'
3
- export * as parseTable from './parse-table/index.js'
4
2
  export * as normalizeIndent from './normalize-indent/index.js'
3
+ export * as parseTable from './parse-table/index.js'
4
+ export * as splitTrim from './split-trim/index.js'
5
5
  export * as replaceAll from './replace-all/index.js'
6
+ export * as charCodes from './char-codes/index.js'
6
7
  export * as toAlphanum from './to-alphanum/index.js'
7
8
  export * as trim from './trim/index.js'
8
- export * as splitTrim from './split-trim/index.js'
@@ -1,5 +1,5 @@
1
- export * as timeout from './timeout/index.js'
2
- export * as dates from './dates/index.js'
3
1
  export * as duration from './duration/index.js'
4
- export * as transitions from './transitions/index.js'
2
+ export * as dates from './dates/index.js'
3
+ export * as timeout from './timeout/index.js'
5
4
  export * as wait from './wait/index.js'
5
+ export * as transitions from './transitions/index.js'
@@ -1,5 +1,5 @@
1
- export * as timeout from './timeout/index.js'
2
- export * as dates from './dates/index.js'
3
1
  export * as duration from './duration/index.js'
4
- export * as transitions from './transitions/index.js'
2
+ export * as dates from './dates/index.js'
3
+ export * as timeout from './timeout/index.js'
5
4
  export * as wait from './wait/index.js'
5
+ export * as transitions from './transitions/index.js'
@@ -1,4 +1,4 @@
1
- import { type PropsWithChildren, type FunctionComponent } from 'react';
1
+ import { type PropsWithChildren, type FunctionComponent, type RefObject } from 'react';
2
2
  import type { WithClassName } from '../utils/types.js';
3
3
  /** Alias for the native IntersectionObserver interface. */
4
4
  export type IO = IntersectionObserver;
@@ -40,18 +40,43 @@ export type Props = PropsWithChildren<WithClassName<{
40
40
  observer: IO;
41
41
  }) => void;
42
42
  } & ObserverOptions>>;
43
+ /**
44
+ * Observes an element a caller already renders, rather than one wrapped in a div of
45
+ * our own.
46
+ *
47
+ * This is the whole of the behaviour; {@link IntersectionObserverComponent} is this
48
+ * hook plus a div to hang it on. Reach for the hook when the element to watch is
49
+ * already in the tree — a component's own root, typically — and for the component
50
+ * when there is nothing to watch yet and a box has to be created.
51
+ *
52
+ * @param targetRef - The element to observe. Nothing happens until it is attached.
53
+ * @param options - See {@link ObserverOptions}.
54
+ * @param onIntersected - Called on every intersection change.
55
+ * @param enabled - `false` skips the observer entirely, for a caller whose need for
56
+ * it depends on its own props. A hook cannot be called conditionally; this is how
57
+ * the condition is expressed.
58
+ *
59
+ * @returns The latest {@link IntersectionObserverEntry}, or `null` before the first.
60
+ *
61
+ * @remarks
62
+ * - Automatically creates and disconnects the {@link IntersectionObserver} instance.
63
+ * - Re-observes the element shortly after mount to handle late layout changes.
64
+ */
65
+ export declare function useIntersectionObserver(targetRef: RefObject<Element | null>, { root, rootMargin, threshold }: ObserverOptions, onIntersected?: Props['onIntersected'], enabled?: boolean): IOE | null;
43
66
  /**
44
67
  * Component that observes its root element using the IntersectionObserver API
45
68
  * and notifies consumers about visibility changes.
46
69
  *
70
+ * A div and {@link useIntersectionObserver}, and nothing else. A component that
71
+ * already renders the element it wants watched should use the hook and keep its own
72
+ * root, rather than gain a wrapper it has no other use for.
73
+ *
47
74
  * @param props - Component properties.
48
75
  * @see {@link Props}
49
76
  *
50
77
  * @returns A div element wrapping `children`, observed for intersection changes.
51
78
  *
52
79
  * @remarks
53
- * - Automatically creates and disconnects the {@link IntersectionObserver} instance.
54
- * - Re-observes the element shortly after mount to handle late layout changes.
55
80
  * - Adds an `is-intersecting` modifier class when the element is intersecting.
56
81
  */
57
82
  export declare const IntersectionObserverComponent: FunctionComponent<Props>;
@@ -5,23 +5,29 @@ import { mergeClassNames } from '../utils/index.js';
5
5
  import { intersectionObserver as publicClassName } from '../public-classnames.js';
6
6
  import cssModule from './styles.module.css';
7
7
  /**
8
- * Component that observes its root element using the IntersectionObserver API
9
- * and notifies consumers about visibility changes.
8
+ * Observes an element a caller already renders, rather than one wrapped in a div of
9
+ * our own.
10
10
  *
11
- * @param props - Component properties.
12
- * @see {@link Props}
11
+ * This is the whole of the behaviour; {@link IntersectionObserverComponent} is this
12
+ * hook plus a div to hang it on. Reach for the hook when the element to watch is
13
+ * already in the tree — a component's own root, typically — and for the component
14
+ * when there is nothing to watch yet and a box has to be created.
13
15
  *
14
- * @returns A div element wrapping `children`, observed for intersection changes.
16
+ * @param targetRef - The element to observe. Nothing happens until it is attached.
17
+ * @param options - See {@link ObserverOptions}.
18
+ * @param onIntersected - Called on every intersection change.
19
+ * @param enabled - `false` skips the observer entirely, for a caller whose need for
20
+ * it depends on its own props. A hook cannot be called conditionally; this is how
21
+ * the condition is expressed.
22
+ *
23
+ * @returns The latest {@link IntersectionObserverEntry}, or `null` before the first.
15
24
  *
16
25
  * @remarks
17
26
  * - Automatically creates and disconnects the {@link IntersectionObserver} instance.
18
27
  * - Re-observes the element shortly after mount to handle late layout changes.
19
- * - Adds an `is-intersecting` modifier class when the element is intersecting.
20
28
  */
21
- export const IntersectionObserverComponent = ({ onIntersected, root, rootMargin, threshold, className, children }) => {
22
- // Refs, handlers and effects
29
+ export function useIntersectionObserver(targetRef, { root, rootMargin, threshold }, onIntersected, enabled = true) {
23
30
  const [ioEntry, setIoEntry] = useState(null);
24
- const rootRef = useRef(null);
25
31
  const observerRef = useRef(null);
26
32
  const observation = useCallback((entries, observer) => {
27
33
  const thisEntry = entries[0];
@@ -31,33 +37,58 @@ export const IntersectionObserverComponent = ({ onIntersected, root, rootMargin,
31
37
  setIoEntry(thisEntry);
32
38
  }, [onIntersected]);
33
39
  const forceObservation = useCallback(() => {
34
- const rootEl = rootRef.current;
40
+ const targetEl = targetRef.current;
35
41
  const observer = observerRef.current;
36
- if (rootEl === null || observer === null)
42
+ if (targetEl === null || observer === null)
37
43
  return;
38
- observer.unobserve(rootEl);
39
- observer.observe(rootEl);
40
- }, []);
44
+ observer.unobserve(targetEl);
45
+ observer.observe(targetEl);
46
+ }, [targetRef]);
41
47
  useEffect(() => {
42
- const rootEl = rootRef.current;
43
- if (rootEl === null) {
48
+ if (!enabled)
49
+ return;
50
+ const targetEl = targetRef.current;
51
+ if (targetEl === null) {
44
52
  // eslint-disable-next-line no-console
45
- console.warn('rootRef.current should not be null');
53
+ console.warn('targetRef.current should not be null');
46
54
  return;
47
55
  }
48
56
  const observer = new IntersectionObserver(observation, { root, rootMargin, threshold });
49
57
  observerRef.current = observer;
50
- observer.observe(rootEl);
58
+ observer.observe(targetEl);
51
59
  return () => observer.disconnect();
52
- }, [root, rootMargin, threshold, observation]);
60
+ }, [enabled, targetRef, root, rootMargin, threshold, observation]);
53
61
  useEffect(() => {
62
+ if (!enabled)
63
+ return;
54
64
  const timeout1 = window.setTimeout(forceObservation, 100);
55
65
  const timeout2 = window.setTimeout(forceObservation, 500);
56
66
  return () => {
57
67
  window.clearTimeout(timeout1);
58
68
  window.clearTimeout(timeout2);
59
69
  };
60
- }, [forceObservation]);
70
+ }, [enabled, forceObservation]);
71
+ return ioEntry;
72
+ }
73
+ /**
74
+ * Component that observes its root element using the IntersectionObserver API
75
+ * and notifies consumers about visibility changes.
76
+ *
77
+ * A div and {@link useIntersectionObserver}, and nothing else. A component that
78
+ * already renders the element it wants watched should use the hook and keep its own
79
+ * root, rather than gain a wrapper it has no other use for.
80
+ *
81
+ * @param props - Component properties.
82
+ * @see {@link Props}
83
+ *
84
+ * @returns A div element wrapping `children`, observed for intersection changes.
85
+ *
86
+ * @remarks
87
+ * - Adds an `is-intersecting` modifier class when the element is intersecting.
88
+ */
89
+ export const IntersectionObserverComponent = ({ onIntersected, root, rootMargin, threshold, className, children }) => {
90
+ const rootRef = useRef(null);
91
+ const ioEntry = useIntersectionObserver(rootRef, { root, rootMargin, threshold }, onIntersected);
61
92
  // Rendering
62
93
  const c = clss(publicClassName, { cssModule });
63
94
  const isIntersecting = ioEntry?.isIntersecting ?? false;