@design-edito/tools 0.4.22 → 0.4.23

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 (61) hide show
  1. package/agnostic/colors/index.d.ts +4 -4
  2. package/agnostic/colors/index.js +4 -4
  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 +11 -11
  6. package/agnostic/html/hyper-json/smart-tags/coalesced/index.js +11 -11
  7. package/agnostic/html/hyper-json/smart-tags/isolated/index.d.ts +2 -2
  8. package/agnostic/html/hyper-json/smart-tags/isolated/index.js +2 -2
  9. package/agnostic/html/index.d.ts +3 -3
  10. package/agnostic/html/index.js +3 -3
  11. package/agnostic/misc/index.d.ts +5 -5
  12. package/agnostic/misc/index.js +5 -5
  13. package/agnostic/numbers/index.d.ts +1 -1
  14. package/agnostic/numbers/index.js +1 -1
  15. package/agnostic/objects/index.d.ts +3 -3
  16. package/agnostic/objects/index.js +3 -3
  17. package/agnostic/sanitization/index.d.ts +1 -1
  18. package/agnostic/sanitization/index.js +1 -1
  19. package/agnostic/strings/index.d.ts +2 -2
  20. package/agnostic/strings/index.js +2 -2
  21. package/agnostic/time/index.d.ts +2 -2
  22. package/agnostic/time/index.js +2 -2
  23. package/components/Button/index.d.ts +2 -7
  24. package/components/Button/index.js +2 -2
  25. package/components/Iframe/index.d.ts +16 -34
  26. package/components/Iframe/index.js +67 -27
  27. package/components/Input/index.controlled.d.ts +42 -0
  28. package/components/Input/index.controlled.js +53 -0
  29. package/components/Input/index.d.ts +21 -17
  30. package/components/Input/index.js +27 -18
  31. package/components/Select/index.controlled.d.ts +43 -0
  32. package/components/Select/index.controlled.js +53 -0
  33. package/components/Select/index.d.ts +22 -18
  34. package/components/Select/index.js +27 -18
  35. package/components/Textarea/index.controlled.d.ts +50 -0
  36. package/components/Textarea/index.controlled.js +74 -0
  37. package/components/Textarea/index.d.ts +22 -17
  38. package/components/Textarea/index.js +27 -18
  39. package/components/index.d.ts +1 -1
  40. package/components/index.js +1 -1
  41. package/node/@aws-s3/storage/directory/index.d.ts +1 -1
  42. package/node/@aws-s3/storage/directory/index.js +1 -1
  43. package/node/@aws-s3/storage/file/index.d.ts +1 -1
  44. package/node/@aws-s3/storage/file/index.js +1 -1
  45. package/node/@google-cloud/storage/directory/index.d.ts +1 -1
  46. package/node/@google-cloud/storage/directory/index.js +1 -1
  47. package/node/@google-cloud/storage/file/index.d.ts +2 -2
  48. package/node/@google-cloud/storage/file/index.js +2 -2
  49. package/node/@google-cloud/storage/index.d.ts +1 -1
  50. package/node/@google-cloud/storage/index.js +1 -1
  51. package/node/cloud-storage/operations/index.d.ts +1 -1
  52. package/node/cloud-storage/operations/index.js +1 -1
  53. package/node/images/transform/operations/index.d.ts +1 -1
  54. package/node/images/transform/operations/index.js +1 -1
  55. package/node/index.d.ts +1 -1
  56. package/node/index.js +1 -1
  57. package/node/process/index.d.ts +1 -1
  58. package/node/process/index.js +1 -1
  59. package/node/sftp/file/index.d.ts +1 -1
  60. package/node/sftp/file/index.js +1 -1
  61. package/package.json +1 -1
@@ -1,12 +1,12 @@
1
- export * as contrast from './contrast/index.js'
2
1
  export * as channels from './channels/index.js'
3
- export * as convert from './convert/index.js'
4
- export * as distance from './distance/index.js'
2
+ export * as contrast from './contrast/index.js'
5
3
  export * as grayscale from './grayscale/index.js'
6
- export * as invert from './invert/index.js'
4
+ export * as distance from './distance/index.js'
7
5
  export * as lerp from './lerp/index.js'
8
6
  export * as luminance from './luminance/index.js'
9
7
  export * as palette from './palette/index.js'
8
+ export * as convert from './convert/index.js'
10
9
  export * as rotate from './rotate/index.js'
11
10
  export * as tidy from './tidy/index.js'
12
11
  export * as typechecks from './typechecks/index.js'
12
+ export * as invert from './invert/index.js'
@@ -1,12 +1,12 @@
1
- export * as contrast from './contrast/index.js'
2
1
  export * as channels from './channels/index.js'
3
- export * as convert from './convert/index.js'
4
- export * as distance from './distance/index.js'
2
+ export * as contrast from './contrast/index.js'
5
3
  export * as grayscale from './grayscale/index.js'
6
- export * as invert from './invert/index.js'
4
+ export * as distance from './distance/index.js'
7
5
  export * as lerp from './lerp/index.js'
8
6
  export * as luminance from './luminance/index.js'
9
7
  export * as palette from './palette/index.js'
8
+ export * as convert from './convert/index.js'
10
9
  export * as rotate from './rotate/index.js'
11
10
  export * as tidy from './tidy/index.js'
12
11
  export * as typechecks from './typechecks/index.js'
12
+ export * as invert from './invert/index.js'
@@ -1,6 +1,6 @@
1
- export * as clss from './clss/index.js'
2
1
  export * as bem from './bem/index.js'
2
+ export * as clss from './clss/index.js'
3
3
  export * as generateNiceColor from './generate-nice-color/index.js'
4
4
  export * as isValidCssClassName from './is-valid-css-class-name/index.js'
5
- export * as scale from './scale/index.js'
6
5
  export * as stylesSet from './styles-set/index.js'
6
+ export * as scale from './scale/index.js'
@@ -1,6 +1,6 @@
1
- export * as clss from './clss/index.js'
2
1
  export * as bem from './bem/index.js'
2
+ export * as clss from './clss/index.js'
3
3
  export * as generateNiceColor from './generate-nice-color/index.js'
4
4
  export * as isValidCssClassName from './is-valid-css-class-name/index.js'
5
- export * as scale from './scale/index.js'
6
5
  export * as stylesSet from './styles-set/index.js'
6
+ export * as scale from './scale/index.js'
@@ -2,20 +2,19 @@ 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
4
  export * as append from './append/index.js'
5
- export * as at from './at/index.js'
6
5
  export * as call from './call/index.js'
6
+ export * as at from './at/index.js'
7
7
  export * as clone from './clone/index.js'
8
8
  export * as deleteproperties from './deleteproperties/index.js'
9
- export * as getattribute from './getattribute/index.js'
10
- export * as getproperties from './getproperties/index.js'
11
9
  export * as equals from './equals/index.js'
10
+ export * as getproperties from './getproperties/index.js'
12
11
  export * as getproperty from './getproperty/index.js'
13
12
  export * as hjparse from './hjparse/index.js'
14
13
  export * as hjstringify from './hjstringify/index.js'
15
14
  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 length from './length/index.js'
17
+ export * as getattribute from './getattribute/index.js'
19
18
  export * as map from './map/index.js'
20
19
  export * as negate from './negate/index.js'
21
20
  export * as notrailing from './notrailing/index.js'
@@ -23,30 +22,31 @@ export * as or from './or/index.js'
23
22
  export * as pickrandom from './pickrandom/index.js'
24
23
  export * as populate from './populate/index.js'
25
24
  export * as print from './print/index.js'
25
+ export * as length from './length/index.js'
26
26
  export * as push from './push/index.js'
27
27
  export * as pusheach from './pusheach/index.js'
28
28
  export * as recordtoarray from './recordtoarray/index.js'
29
29
  export * as removeattribute from './removeattribute/index.js'
30
- export * as removeclass from './removeclass/index.js'
31
30
  export * as renameproperty from './renameproperty/index.js'
32
- export * as select from './select/index.js'
31
+ export * as removeclass from './removeclass/index.js'
33
32
  export * as replace from './replace/index.js'
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
36
  export * as setproperty from './setproperty/index.js'
37
37
  export * as sorton from './sorton/index.js'
38
- export * as spread from './spread/index.js'
39
38
  export * as split from './split/index.js'
39
+ export * as spread from './spread/index.js'
40
40
  export * as toarray from './toarray/index.js'
41
41
  export * as toboolean from './toboolean/index.js'
42
42
  export * as toelement from './toelement/index.js'
43
- export * as toggleclass from './toggleclass/index.js'
44
43
  export * as tonodelist from './tonodelist/index.js'
45
44
  export * as tonull from './tonull/index.js'
45
+ export * as tonumber from './tonumber/index.js'
46
46
  export * as torecord from './torecord/index.js'
47
- export * as tostring from './tostring/index.js'
48
47
  export * as toref from './toref/index.js'
49
- export * as transformselected from './transformselected/index.js'
48
+ export * as tostring from './tostring/index.js'
50
49
  export * as totext from './totext/index.js'
50
+ export * as toggleclass from './toggleclass/index.js'
51
+ export * as transformselected from './transformselected/index.js'
51
52
  export * as trim from './trim/index.js'
52
- export * as tonumber from './tonumber/index.js'
@@ -2,20 +2,19 @@ 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
4
  export * as append from './append/index.js'
5
- export * as at from './at/index.js'
6
5
  export * as call from './call/index.js'
6
+ export * as at from './at/index.js'
7
7
  export * as clone from './clone/index.js'
8
8
  export * as deleteproperties from './deleteproperties/index.js'
9
- export * as getattribute from './getattribute/index.js'
10
- export * as getproperties from './getproperties/index.js'
11
9
  export * as equals from './equals/index.js'
10
+ export * as getproperties from './getproperties/index.js'
12
11
  export * as getproperty from './getproperty/index.js'
13
12
  export * as hjparse from './hjparse/index.js'
14
13
  export * as hjstringify from './hjstringify/index.js'
15
14
  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 length from './length/index.js'
17
+ export * as getattribute from './getattribute/index.js'
19
18
  export * as map from './map/index.js'
20
19
  export * as negate from './negate/index.js'
21
20
  export * as notrailing from './notrailing/index.js'
@@ -23,30 +22,31 @@ export * as or from './or/index.js'
23
22
  export * as pickrandom from './pickrandom/index.js'
24
23
  export * as populate from './populate/index.js'
25
24
  export * as print from './print/index.js'
25
+ export * as length from './length/index.js'
26
26
  export * as push from './push/index.js'
27
27
  export * as pusheach from './pusheach/index.js'
28
28
  export * as recordtoarray from './recordtoarray/index.js'
29
29
  export * as removeattribute from './removeattribute/index.js'
30
- export * as removeclass from './removeclass/index.js'
31
30
  export * as renameproperty from './renameproperty/index.js'
32
- export * as select from './select/index.js'
31
+ export * as removeclass from './removeclass/index.js'
33
32
  export * as replace from './replace/index.js'
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
36
  export * as setproperty from './setproperty/index.js'
37
37
  export * as sorton from './sorton/index.js'
38
- export * as spread from './spread/index.js'
39
38
  export * as split from './split/index.js'
39
+ export * as spread from './spread/index.js'
40
40
  export * as toarray from './toarray/index.js'
41
41
  export * as toboolean from './toboolean/index.js'
42
42
  export * as toelement from './toelement/index.js'
43
- export * as toggleclass from './toggleclass/index.js'
44
43
  export * as tonodelist from './tonodelist/index.js'
45
44
  export * as tonull from './tonull/index.js'
45
+ export * as tonumber from './tonumber/index.js'
46
46
  export * as torecord from './torecord/index.js'
47
- export * as tostring from './tostring/index.js'
48
47
  export * as toref from './toref/index.js'
49
- export * as transformselected from './transformselected/index.js'
48
+ export * as tostring from './tostring/index.js'
50
49
  export * as totext from './totext/index.js'
50
+ export * as toggleclass from './toggleclass/index.js'
51
+ export * as transformselected from './transformselected/index.js'
51
52
  export * as trim from './trim/index.js'
52
- export * as tonumber from './tonumber/index.js'
@@ -2,12 +2,12 @@ export * as any from './any/index.js'
2
2
  export * as array from './array/index.js'
3
3
  export * as boolean from './boolean/index.js'
4
4
  export * as element from './element/index.js'
5
- export * as get from './get/index.js'
6
5
  export * as guess from './guess/index.js'
6
+ export * as get from './get/index.js'
7
7
  export * as nodelist from './nodelist/index.js'
8
8
  export * as number from './number/index.js'
9
9
  export * as record from './record/index.js'
10
- export * as null from './null/index.js'
11
10
  export * as ref from './ref/index.js'
12
11
  export * as string from './string/index.js'
13
12
  export * as text from './text/index.js'
13
+ export * as null from './null/index.js'
@@ -2,12 +2,12 @@ export * as any from './any/index.js'
2
2
  export * as array from './array/index.js'
3
3
  export * as boolean from './boolean/index.js'
4
4
  export * as element from './element/index.js'
5
- export * as get from './get/index.js'
6
5
  export * as guess from './guess/index.js'
6
+ export * as get from './get/index.js'
7
7
  export * as nodelist from './nodelist/index.js'
8
8
  export * as number from './number/index.js'
9
9
  export * as record from './record/index.js'
10
- export * as null from './null/index.js'
11
10
  export * as ref from './ref/index.js'
12
11
  export * as string from './string/index.js'
13
12
  export * as text from './text/index.js'
13
+ export * as null from './null/index.js'
@@ -1,10 +1,10 @@
1
- export * as deepSelect from './deep-select/index.js'
2
1
  export * as getNodeAncestors from './get-node-ancestors/index.js'
3
2
  export * as getPositionInsideParent from './get-position-inside-parent/index.js'
3
+ export * as deepSelect from './deep-select/index.js'
4
4
  export * as hyperJson from './hyper-json/index.js'
5
- export * as insertNode from './insert-node/index.js'
6
5
  export * as placeholders from './placeholders/index.js'
7
- export * as replaceInElement from './replace-in-element/index.js'
8
6
  export * as selectorToElement from './selector-to-element/index.js'
9
7
  export * as stringToNodes from './string-to-nodes/index.js'
10
8
  export * as watchSelection from './watch-selection/index.js'
9
+ export * as insertNode from './insert-node/index.js'
10
+ export * as replaceInElement from './replace-in-element/index.js'
@@ -1,10 +1,10 @@
1
- export * as deepSelect from './deep-select/index.js'
2
1
  export * as getNodeAncestors from './get-node-ancestors/index.js'
3
2
  export * as getPositionInsideParent from './get-position-inside-parent/index.js'
3
+ export * as deepSelect from './deep-select/index.js'
4
4
  export * as hyperJson from './hyper-json/index.js'
5
- export * as insertNode from './insert-node/index.js'
6
5
  export * as placeholders from './placeholders/index.js'
7
- export * as replaceInElement from './replace-in-element/index.js'
8
6
  export * as selectorToElement from './selector-to-element/index.js'
9
7
  export * as stringToNodes from './string-to-nodes/index.js'
10
8
  export * as watchSelection from './watch-selection/index.js'
9
+ export * as insertNode from './insert-node/index.js'
10
+ export * as replaceInElement from './replace-in-element/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 isConstructorFunction from './is-constructor-function/index.js'
6
+ export * as dataSize from './data-size/index.js'
6
7
  export * as isNullish from './is-nullish/index.js'
7
- export * as logs from './logs/index.js'
8
+ export * as isConstructorFunction from './is-constructor-function/index.js'
8
9
  export * as loremIpsum from './lorem-ipsum/index.js'
9
- export * as connection from './connection/index.js'
10
- export * as dataSize from './data-size/index.js'
11
- export * as outcome from './outcome/index.js'
12
10
  export * as normalizeExtension from './normalize-extension/index.js'
11
+ export * as outcome from './outcome/index.js'
12
+ export * as logs from './logs/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 isConstructorFunction from './is-constructor-function/index.js'
6
+ export * as dataSize from './data-size/index.js'
6
7
  export * as isNullish from './is-nullish/index.js'
7
- export * as logs from './logs/index.js'
8
+ export * as isConstructorFunction from './is-constructor-function/index.js'
8
9
  export * as loremIpsum from './lorem-ipsum/index.js'
9
- export * as connection from './connection/index.js'
10
- export * as dataSize from './data-size/index.js'
11
- export * as outcome from './outcome/index.js'
12
10
  export * as normalizeExtension from './normalize-extension/index.js'
11
+ export * as outcome from './outcome/index.js'
12
+ export * as logs from './logs/index.js'
@@ -1,6 +1,6 @@
1
1
  export * as absoluteModulo from './absolute-modulo/index.js'
2
2
  export * as approximateRational from './approximate-rational/index.js'
3
3
  export * as clamp from './clamp/index.js'
4
+ export * as interpolate from './interpolate/index.js'
4
5
  export * as geometricProgressions from './geometric-progressions/index.js'
5
6
  export * as round from './round/index.js'
6
- export * as interpolate from './interpolate/index.js'
@@ -1,6 +1,6 @@
1
1
  export * as absoluteModulo from './absolute-modulo/index.js'
2
2
  export * as approximateRational from './approximate-rational/index.js'
3
3
  export * as clamp from './clamp/index.js'
4
+ export * as interpolate from './interpolate/index.js'
4
5
  export * as geometricProgressions from './geometric-progressions/index.js'
5
6
  export * as round from './round/index.js'
6
- export * as interpolate from './interpolate/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
- export * as flattenGetters from './flatten-getters/index.js'
3
+ export * as isObject from './is-object/index.js'
4
4
  export * as isRecord from './is-record/index.js'
5
5
  export * as recordFormat from './record-format/index.js'
6
- export * as recordMap from './record-map/index.js'
6
+ export * as flattenGetters from './flatten-getters/index.js'
7
7
  export * as sortKeys from './sort-keys/index.js'
8
+ export * as recordMap from './record-map/index.js'
8
9
  export * as validation from './validation/index.js'
9
- export * as isObject from './is-object/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
- export * as flattenGetters from './flatten-getters/index.js'
3
+ export * as isObject from './is-object/index.js'
4
4
  export * as isRecord from './is-record/index.js'
5
5
  export * as recordFormat from './record-format/index.js'
6
- export * as recordMap from './record-map/index.js'
6
+ export * as flattenGetters from './flatten-getters/index.js'
7
7
  export * as sortKeys from './sort-keys/index.js'
8
+ export * as recordMap from './record-map/index.js'
8
9
  export * as validation from './validation/index.js'
9
- export * as isObject from './is-object/index.js'
@@ -1,4 +1,4 @@
1
- export * as fileName from './file-name/index.js'
2
1
  export * as html from './html/index.js'
2
+ export * as fileName from './file-name/index.js'
3
3
  export * as path from './path/index.js'
4
4
  export * as userInput from './user-input/index.js'
@@ -1,4 +1,4 @@
1
- export * as fileName from './file-name/index.js'
2
1
  export * as html from './html/index.js'
2
+ export * as fileName from './file-name/index.js'
3
3
  export * as path from './path/index.js'
4
4
  export * as userInput from './user-input/index.js'
@@ -1,8 +1,8 @@
1
+ export * as charCodes from './char-codes/index.js'
1
2
  export * as matches from './matches/index.js'
2
3
  export * as normalizeIndent from './normalize-indent/index.js'
3
- export * as charCodes from './char-codes/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 splitTrim from './split-trim/index.js'
6
+ export * as parseTable from './parse-table/index.js'
7
7
  export * as toAlphanum from './to-alphanum/index.js'
8
8
  export * as trim from './trim/index.js'
@@ -1,8 +1,8 @@
1
+ export * as charCodes from './char-codes/index.js'
1
2
  export * as matches from './matches/index.js'
2
3
  export * as normalizeIndent from './normalize-indent/index.js'
3
- export * as charCodes from './char-codes/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 splitTrim from './split-trim/index.js'
6
+ export * as parseTable from './parse-table/index.js'
7
7
  export * as toAlphanum from './to-alphanum/index.js'
8
8
  export * as trim from './trim/index.js'
@@ -1,5 +1,5 @@
1
- export * as dates from './dates/index.js'
2
1
  export * as duration from './duration/index.js'
3
- export * as wait from './wait/index.js'
4
2
  export * as transitions from './transitions/index.js'
3
+ export * as wait from './wait/index.js'
5
4
  export * as timeout from './timeout/index.js'
5
+ export * as dates from './dates/index.js'
@@ -1,5 +1,5 @@
1
- export * as dates from './dates/index.js'
2
1
  export * as duration from './duration/index.js'
3
- export * as wait from './wait/index.js'
4
2
  export * as transitions from './transitions/index.js'
3
+ export * as wait from './wait/index.js'
5
4
  export * as timeout from './timeout/index.js'
5
+ export * as dates from './dates/index.js'
@@ -1,4 +1,4 @@
1
- import { type FunctionComponent, type ButtonHTMLAttributes, type ReactNode } from 'react';
1
+ import { type FunctionComponent, type ButtonHTMLAttributes } from 'react';
2
2
  import type { WithClassName } from '../utils/types.js';
3
3
  /**
4
4
  * Props for the {@link Button} component.
@@ -6,14 +6,9 @@ import type { WithClassName } from '../utils/types.js';
6
6
  * Extends all native {@link ButtonHTMLAttributes} and {@link WithClassName}
7
7
  * with optional label and error content.
8
8
  *
9
- * @property label - Content rendered as the button label.
10
- * @property error - Content rendered to convey an error state associated with the button.
11
9
  * @property className - Additional class name(s) applied to the root element.
12
10
  */
13
- export type Props = ButtonHTMLAttributes<HTMLButtonElement> & WithClassName<{
14
- label?: ReactNode;
15
- error?: ReactNode;
16
- }>;
11
+ export type Props = ButtonHTMLAttributes<HTMLButtonElement> & WithClassName<Record<string, unknown>>;
17
12
  /**
18
13
  * Base button component.
19
14
  *
@@ -13,8 +13,8 @@ import cssModule from './styles.module.css';
13
13
  * @see {@link Props}
14
14
  * @returns A styled native button element.
15
15
  */
16
- export const Button = ({ label, error, className, ...rest }) => {
16
+ export const Button = ({ className, ...rest }) => {
17
17
  const c = clss(publicClassName, { cssModule });
18
18
  const rootClss = mergeClassNames(c(null), className);
19
- return _jsx("button", { ...rest, className: c(rootClss) });
19
+ return _jsx("button", { ...rest, className: rootClss });
20
20
  };
@@ -1,48 +1,30 @@
1
- import { type FunctionComponent, type IframeHTMLAttributes, type PropsWithChildren } from 'react';
1
+ import { type FunctionComponent, type IframeHTMLAttributes } from 'react';
2
2
  import type { WithClassName } from '../utils/types.js';
3
3
  /**
4
4
  * Props for the {@link Iframe} component.
5
5
  *
6
- * Extends native {@link IframeHTMLAttributes} with optional class name support.
6
+ * Extends native {@link IframeHTMLAttributes} with class name support and
7
+ * automatic height adjustment.
7
8
  *
8
- * @property className - Additional class name(s) applied to the root element.
9
- * @property children - React content rendered as the iframe document body.
10
- * @property srcDoc - Raw HTML string used as iframe content when `children` is not provided.
11
- *
12
- * @remarks
13
- * This component behaves as a hybrid between a native `<iframe>` and a React renderer.
14
- *
15
- * Rendering priority:
16
- * - `children` takes precedence over `srcDoc` when provided.
17
- * - If `children` is `null` or `undefined`, `srcDoc` is used directly.
18
- *
19
- * When `children` is provided, it is converted to static HTML using
20
- * `renderToStaticMarkup` and injected into a complete HTML document:
21
- * `<!doctype html><html><body>...</body></html>`.
9
+ * @property autoHeight - Enables automatic iframe height adjustment based on
10
+ * document content size. Only supported with `srcDoc`.
11
+ * @property className - Optional additional class names applied to the iframe.
12
+ * @property style - Optional inline style applied to the iframe.
13
+ * @property srcDoc - Raw HTML string rendered inside the iframe.
22
14
  */
23
- export type Props = PropsWithChildren<WithClassName<Record<never, never>>> & Omit<IframeHTMLAttributes<HTMLIFrameElement>, 'children'>;
15
+ export type Props = WithClassName<{
16
+ autoHeight?: boolean;
17
+ }> & Omit<IframeHTMLAttributes<HTMLIFrameElement>, 'children'>;
24
18
  /**
25
- * Iframe component with React-to-HTML rendering support.
26
- *
27
- * Renders either:
28
- * - A raw HTML string via the `srcDoc` attribute, or
29
- * - A ReactNode rendered into static HTML via `renderToStaticMarkup`.
30
- *
31
- * ### Rendering strategy
32
- * 1. If `children` is defined (non-nullish), it is rendered to static HTML
33
- * and used as iframe content.
34
- * 2. Otherwise, `srcDoc` is used as-is.
19
+ * Iframe component with optional automatic height adjustment.
35
20
  *
36
- * The resulting content is wrapped in a minimal HTML document:
37
- * `<!doctype html><html><body>...</body></html>`.
21
+ * When `autoHeight` is enabled, the iframe injects a script that measures
22
+ * document height and sends updates to the parent via `postMessage`.
38
23
  *
39
- * ### Notes
40
- * - The iframe content is static (no hydration, no client-side React inside iframe).
41
- * - `children` overrides `srcDoc`.
42
- * - Useful for embedding server-rendered UI fragments or documentation blocks.
24
+ * The parent component updates the iframe height via React state and `style`
25
+ * prop (no direct DOM mutation).
43
26
  *
44
27
  * @param props - Component properties.
45
28
  * @see {@link Props}
46
- * @returns A styled iframe element with computed HTML document content.
47
29
  */
48
30
  export declare const Iframe: FunctionComponent<Props>;
@@ -1,43 +1,83 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
- import { useMemo } from 'react';
3
- import { renderToStaticMarkup } from 'react-dom/server';
2
+ import { useEffect, useMemo, useRef, useState } from 'react';
4
3
  import { clss } from '../../agnostic/css/clss/index.js';
4
+ import { randomHash } from '../../agnostic/random/uuid/index.js';
5
5
  import { mergeClassNames } from '../utils/index.js';
6
6
  import { iframe as publicClassName } from '../public-classnames.js';
7
7
  import cssModule from './styles.module.css';
8
- import { isNotNullish } from '../../agnostic/misc/is-nullish/index.js';
8
+ const innerAutoHeightNitifier = (messageType) => `<script>
9
+ (() => {
10
+ const notify = () => {
11
+ const height = Math.max(
12
+ document.body?.scrollHeight ?? 0,
13
+ document.documentElement?.scrollHeight ?? 0
14
+ )
15
+ window.parent.postMessage({
16
+ type: '${messageType}',
17
+ height
18
+ }, '*')
19
+ }
20
+ window.addEventListener('load', notify)
21
+ const observer = new ResizeObserver(notify)
22
+ observer.observe(document.body)
23
+ observer.observe(document.documentElement)
24
+ notify()
25
+ })()
26
+ </script>`;
9
27
  /**
10
- * Iframe component with React-to-HTML rendering support.
28
+ * Iframe component with optional automatic height adjustment.
11
29
  *
12
- * Renders either:
13
- * - A raw HTML string via the `srcDoc` attribute, or
14
- * - A ReactNode rendered into static HTML via `renderToStaticMarkup`.
30
+ * When `autoHeight` is enabled, the iframe injects a script that measures
31
+ * document height and sends updates to the parent via `postMessage`.
15
32
  *
16
- * ### Rendering strategy
17
- * 1. If `children` is defined (non-nullish), it is rendered to static HTML
18
- * and used as iframe content.
19
- * 2. Otherwise, `srcDoc` is used as-is.
20
- *
21
- * The resulting content is wrapped in a minimal HTML document:
22
- * `<!doctype html><html><body>...</body></html>`.
23
- *
24
- * ### Notes
25
- * - The iframe content is static (no hydration, no client-side React inside iframe).
26
- * - `children` overrides `srcDoc`.
27
- * - Useful for embedding server-rendered UI fragments or documentation blocks.
33
+ * The parent component updates the iframe height via React state and `style`
34
+ * prop (no direct DOM mutation).
28
35
  *
29
36
  * @param props - Component properties.
30
37
  * @see {@link Props}
31
- * @returns A styled iframe element with computed HTML document content.
32
38
  */
33
- export const Iframe = ({ className, children, srcDoc, ...iframeProps }) => {
39
+ export const Iframe = ({ autoHeight = false, className, srcDoc, style, ...iframeProps }) => {
40
+ const iframeRef = useRef(null);
41
+ const [height, setHeight] = useState(null);
42
+ const [innerMessageType] = useState(`_${randomHash(10)}`);
43
+ // Fx. dep. `autoHeight` - Handles messages from iframe content when autoHeight is enabled.
44
+ useEffect(() => {
45
+ if (!autoHeight)
46
+ return;
47
+ const handleMessage = (event) => {
48
+ const iframe = iframeRef.current;
49
+ if (iframe === null
50
+ || event.source !== iframe.contentWindow
51
+ || typeof event.data !== 'object'
52
+ || event.data === null
53
+ || event.data.type !== innerMessageType
54
+ || typeof event.data.height !== 'number')
55
+ return;
56
+ setHeight(event.data.height);
57
+ };
58
+ window.addEventListener('message', handleMessage);
59
+ return () => window.removeEventListener('message', handleMessage);
60
+ }, [autoHeight]);
61
+ const iframeStyle = useMemo(() => {
62
+ const base = style ?? {};
63
+ if (!autoHeight || height === null)
64
+ return base;
65
+ return { ...base, height: `${height}px` };
66
+ }, [style, autoHeight, height]);
34
67
  const c = clss(publicClassName, { cssModule });
35
68
  const rootClss = mergeClassNames(c(), className);
36
69
  const html = useMemo(() => {
37
- const body = isNotNullish(children)
38
- ? renderToStaticMarkup(children)
39
- : srcDoc;
40
- return `<!doctype html><html><body>${body}</body></html>`;
41
- }, [children, srcDoc]);
42
- return _jsx("iframe", { ...iframeProps, className: rootClss, srcDoc: html });
70
+ const autoHeightScript = autoHeight
71
+ ? innerAutoHeightNitifier(innerMessageType)
72
+ : '';
73
+ return `<!doctype html>
74
+ <html>
75
+ <body>
76
+ ${srcDoc ?? ''}
77
+ ${autoHeightScript}
78
+ </body>
79
+ </html>
80
+ `;
81
+ }, [srcDoc, autoHeight]);
82
+ return _jsx("iframe", { ...iframeProps, ref: iframeRef, className: rootClss, style: iframeStyle, srcDoc: html });
43
83
  };