timvir 0.2.38 → 0.2.42

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 (113) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/blocks/Arbitrary/Arbitrary.d.ts +1 -1
  3. package/blocks/Arbitrary/index.js +232 -78
  4. package/blocks/Arbitrary/samples/basic.d.ts +1 -1
  5. package/blocks/Arbitrary/styles.css +166 -6
  6. package/blocks/Code/Code.d.ts +0 -6
  7. package/blocks/Code/docs/index.mdx +0 -11
  8. package/blocks/Code/index.js +213 -112
  9. package/blocks/Code/samples/basic.d.ts +1 -1
  10. package/blocks/Code/samples/toggle.d.ts +1 -2
  11. package/blocks/Code/styles.css +100 -15
  12. package/blocks/ColorBar/docs/index.mdx +8 -2
  13. package/blocks/ColorBar/index.js +223 -68
  14. package/blocks/ColorBar/samples/basic.d.ts +1 -2
  15. package/blocks/ColorBar/styles.css +103 -4
  16. package/blocks/ColorBook/docs/index.mdx +1 -1
  17. package/blocks/ColorBook/index.js +222 -60
  18. package/blocks/ColorBook/samples/basic.d.ts +1 -2
  19. package/blocks/ColorBook/styles.css +166 -6
  20. package/blocks/Cover/index.js +177 -48
  21. package/blocks/Cover/samples/basic.d.ts +1 -2
  22. package/blocks/Cover/styles.css +18 -0
  23. package/blocks/Exhibit/index.js +205 -50
  24. package/blocks/Exhibit/samples/basic.d.ts +1 -2
  25. package/blocks/Exhibit/samples/bleed.d.ts +1 -1
  26. package/blocks/Exhibit/samples/usage.d.ts +1 -2
  27. package/blocks/Exhibit/styles.css +66 -3
  28. package/blocks/Font/index.js +239 -98
  29. package/blocks/Font/samples/basic.d.ts +1 -1
  30. package/blocks/Font/samples/timvir/body1.d.ts +1 -1
  31. package/blocks/Font/samples/timvir/caption.d.ts +1 -1
  32. package/blocks/Font/samples/timvir/h1.d.ts +1 -1
  33. package/blocks/Font/samples/timvir/h2.d.ts +1 -1
  34. package/blocks/Font/samples/timvir/h3.d.ts +1 -1
  35. package/blocks/Font/samples/timvir/h4.d.ts +1 -1
  36. package/blocks/Font/styles.css +82 -8
  37. package/blocks/Grid/docs/index.mdx +4 -4
  38. package/blocks/Grid/index.js +181 -36
  39. package/blocks/Grid/samples/basic.d.ts +1 -2
  40. package/blocks/Grid/styles.css +20 -1
  41. package/blocks/Icon/docs/index.mdx +13 -13
  42. package/blocks/Icon/index.js +93 -100
  43. package/blocks/Icon/internal/Canvas.d.ts +1 -1
  44. package/blocks/Icon/samples/basic.d.ts +1 -2
  45. package/blocks/Icon/styles.css +117 -5
  46. package/blocks/Icon/types.d.ts +3 -2
  47. package/blocks/Message/docs/index.mdx +5 -8
  48. package/blocks/Message/index.js +238 -55
  49. package/blocks/Message/samples/basic.d.ts +1 -1
  50. package/blocks/Message/styles.css +94 -6
  51. package/blocks/Swatch/docs/index.mdx +16 -16
  52. package/blocks/Swatch/index.js +199 -45
  53. package/blocks/Swatch/samples/basic.d.ts +1 -2
  54. package/blocks/Swatch/styles.css +82 -4
  55. package/blocks/Viewport/index.js +360 -237
  56. package/blocks/Viewport/internal/Caption.d.ts +1 -1
  57. package/blocks/Viewport/internal/Handle.d.ts +1 -1
  58. package/blocks/Viewport/internal/Ruler.d.ts +1 -2
  59. package/blocks/Viewport/samples/basic.d.ts +1 -2
  60. package/blocks/Viewport/styles.css +259 -14
  61. package/blocks/WebLink/index.js +217 -62
  62. package/blocks/WebLink/samples/basic.d.ts +1 -1
  63. package/blocks/WebLink/styles.css +170 -8
  64. package/blocks/styles.css +1460 -97
  65. package/builtins/components.d.ts +2 -2
  66. package/builtins/index.js +306 -239
  67. package/builtins/styles.css +267 -14
  68. package/context/index.d.ts +6 -1
  69. package/core/components/Commands/Commands.d.ts +2 -0
  70. package/core/components/Commands/internal/Action.d.ts +1 -1
  71. package/core/components/Commands/internal/Dialog.d.ts +1 -2
  72. package/core/components/Commands/internal/index.d.ts +0 -1
  73. package/core/components/Footer/samples/basic.d.ts +1 -1
  74. package/core/components/NavigationFooter/NavigationFooter.d.ts +4 -2
  75. package/core/components/NavigationFooter/samples/basic.d.ts +1 -1
  76. package/core/components/Page/Page.d.ts +12 -3
  77. package/core/components/Page/docs/index.mdx +44 -11
  78. package/core/components/Page/internal/Section.d.ts +1 -2
  79. package/core/components/Page/internal/Sidebar.d.ts +1 -1
  80. package/core/components/Page/internal/SidebarItem.d.ts +1 -2
  81. package/core/components/Page/internal/index.d.ts +0 -1
  82. package/core/components/Page/samples/basic.d.ts +1 -2
  83. package/core/components/Page/samples/layout.d.ts +1 -2
  84. package/core/index.d.ts +191 -2
  85. package/core/index.js +674 -449
  86. package/core/layout.d.ts +40 -0
  87. package/core/styles.css +857 -88
  88. package/core/theme/detector.js +1 -1
  89. package/global.css +79 -0
  90. package/internal/cx.d.ts +1 -0
  91. package/knip.config.d.ts +5 -0
  92. package/package.json +1 -2
  93. package/search/Search/samples/basic.d.ts +1 -2
  94. package/search/index.js +2 -208
  95. package/styles.css +2670 -222
  96. package/blocks/Code/theme.d.ts +0 -2
  97. package/bus/styles.css +0 -1
  98. package/context/styles.css +0 -1
  99. package/core/theme/index.d.ts +0 -1
  100. package/hooks/styles.css +0 -1
  101. package/search/Search/internal/Dialog.d.ts +0 -20
  102. package/search/Search/internal/index.d.ts +0 -1
  103. package/search/SearchBoxInput/SearchBoxInput.d.ts +0 -11
  104. package/search/SearchBoxInput/docs/api.mdx +0 -76
  105. package/search/SearchBoxInput/docs/index.mdx +0 -6
  106. package/search/SearchBoxInput/index.d.ts +0 -1
  107. package/search/SearchBoxInput/samples/basic.d.ts +0 -2
  108. package/search/SearchBoxListItem/SearchBoxListItem.d.ts +0 -13
  109. package/search/SearchBoxListItem/docs/api.mdx +0 -76
  110. package/search/SearchBoxListItem/docs/index.mdx +0 -30
  111. package/search/SearchBoxListItem/index.d.ts +0 -1
  112. package/search/SearchBoxListItem/samples/basic.d.ts +0 -2
  113. package/search/styles.css +0 -16
@@ -1,84 +1,220 @@
1
1
  'use client';
2
- import { useBlock, fullWidth } from 'timvir/core';
3
- import { useResizeObserverEntry, useResizeObserver } from 'timvir/hooks';
4
2
  import * as React from 'react';
5
- import { useMDXComponents } from '@mdx-js/react';
6
- import * as builtins from 'timvir/builtins';
7
- import { Code } from 'timvir/blocks';
3
+ import { useArticleComponents, useBlock, layoutStyles } from 'timvir/core';
4
+ import { useResizeObserverEntry, useResizeObserver } from 'timvir/hooks';
5
+ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
8
6
  import * as Icons from 'react-feather';
7
+ import { Code } from 'timvir/blocks';
9
8
 
10
- // src/css.ts
9
+ function cx(...args) {
10
+ let str = "";
11
+ for (let i = 0; i < args.length; i++) {
12
+ const arg = args[i];
13
+ if (typeof arg === "string") {
14
+ str += (str && " ") + arg;
15
+ }
16
+ }
17
+ return str;
18
+ }
11
19
 
12
- // src/cx.ts
13
- var cx = function cx2() {
14
- const presentClassNames = Array.prototype.slice.call(arguments).filter(Boolean);
15
- const atomicClasses = {};
16
- const nonAtomicClasses = [];
17
- presentClassNames.forEach((arg) => {
18
- const individualClassNames = arg ? arg.split(" ") : [];
19
- individualClassNames.forEach((className) => {
20
- if (className.startsWith("atm_")) {
21
- const [, keyHash] = className.split("_");
22
- atomicClasses[keyHash] = className;
23
- } else {
24
- nonAtomicClasses.push(className);
25
- }
20
+ var styleq = {};
21
+ var hasRequiredStyleq;
22
+ function requireStyleq() {
23
+ if (hasRequiredStyleq) return styleq;
24
+ hasRequiredStyleq = 1;
25
+ Object.defineProperty(styleq, "__esModule", {
26
+ value: true
26
27
  });
27
- });
28
- const result = [];
29
- for (const keyHash in atomicClasses) {
30
- if (Object.prototype.hasOwnProperty.call(atomicClasses, keyHash)) {
31
- result.push(atomicClasses[keyHash]);
28
+ styleq.styleq = void 0;
29
+ var cache = new WeakMap();
30
+ var compiledKey = '$$css';
31
+ function createStyleq(options) {
32
+ var disableCache;
33
+ var disableMix;
34
+ var transform;
35
+ if (options != null) {
36
+ disableCache = options.disableCache === true;
37
+ disableMix = options.disableMix === true;
38
+ transform = options.transform;
39
+ }
40
+ return function styleq() {
41
+ var definedProperties = [];
42
+ var className = '';
43
+ var inlineStyle = null;
44
+ var debugString = '';
45
+ var nextCache = disableCache ? null : cache;
46
+ var styles = new Array(arguments.length);
47
+ for(var i = 0; i < arguments.length; i++){
48
+ styles[i] = arguments[i];
49
+ }
50
+ while(styles.length > 0){
51
+ var possibleStyle = styles.pop();
52
+ if (possibleStyle == null || possibleStyle === false) {
53
+ continue;
54
+ }
55
+ if (Array.isArray(possibleStyle)) {
56
+ for(var _i = 0; _i < possibleStyle.length; _i++){
57
+ styles.push(possibleStyle[_i]);
58
+ }
59
+ continue;
60
+ }
61
+ var style = transform != null ? transform(possibleStyle) : possibleStyle;
62
+ if (style.$$css != null) {
63
+ var classNameChunk = '';
64
+ if (nextCache != null && nextCache.has(style)) {
65
+ var cacheEntry = nextCache.get(style);
66
+ if (cacheEntry != null) {
67
+ classNameChunk = cacheEntry[0];
68
+ debugString = cacheEntry[2];
69
+ definedProperties.push.apply(definedProperties, cacheEntry[1]);
70
+ nextCache = cacheEntry[3];
71
+ }
72
+ } else {
73
+ var definedPropertiesChunk = [];
74
+ for(var prop in style){
75
+ var value = style[prop];
76
+ if (prop === compiledKey) {
77
+ var compiledKeyValue = style[prop];
78
+ if (compiledKeyValue !== true) {
79
+ debugString = debugString ? compiledKeyValue + '; ' + debugString : compiledKeyValue;
80
+ }
81
+ continue;
82
+ }
83
+ if (typeof value === 'string' || value === null) {
84
+ if (!definedProperties.includes(prop)) {
85
+ definedProperties.push(prop);
86
+ if (nextCache != null) {
87
+ definedPropertiesChunk.push(prop);
88
+ }
89
+ if (typeof value === 'string') {
90
+ classNameChunk += classNameChunk ? ' ' + value : value;
91
+ }
92
+ }
93
+ } else {
94
+ console.error("styleq: ".concat(prop, " typeof ").concat(String(value), " is not \"string\" or \"null\"."));
95
+ }
96
+ }
97
+ if (nextCache != null) {
98
+ var weakMap = new WeakMap();
99
+ nextCache.set(style, [
100
+ classNameChunk,
101
+ definedPropertiesChunk,
102
+ debugString,
103
+ weakMap
104
+ ]);
105
+ nextCache = weakMap;
106
+ }
107
+ }
108
+ if (classNameChunk) {
109
+ className = className ? classNameChunk + ' ' + className : classNameChunk;
110
+ }
111
+ } else {
112
+ if (disableMix) {
113
+ if (inlineStyle == null) {
114
+ inlineStyle = {};
115
+ }
116
+ inlineStyle = Object.assign({}, style, inlineStyle);
117
+ } else {
118
+ var subStyle = null;
119
+ for(var _prop in style){
120
+ var _value = style[_prop];
121
+ if (_value !== undefined) {
122
+ if (!definedProperties.includes(_prop)) {
123
+ if (_value != null) {
124
+ if (inlineStyle == null) {
125
+ inlineStyle = {};
126
+ }
127
+ if (subStyle == null) {
128
+ subStyle = {};
129
+ }
130
+ subStyle[_prop] = _value;
131
+ }
132
+ definedProperties.push(_prop);
133
+ nextCache = null;
134
+ }
135
+ }
136
+ }
137
+ if (subStyle != null) {
138
+ inlineStyle = Object.assign(subStyle, inlineStyle);
139
+ }
140
+ }
141
+ }
142
+ }
143
+ var styleProps = [
144
+ className,
145
+ inlineStyle,
146
+ debugString
147
+ ];
148
+ return styleProps;
149
+ };
32
150
  }
33
- }
34
- result.push(...nonAtomicClasses);
35
- return result.join(" ");
36
- };
37
- var cx_default = cx;
151
+ var styleq$1 = styleq.styleq = createStyleq();
152
+ styleq$1.factory = createStyleq;
153
+ return styleq;
154
+ }
155
+ var styleqExports = requireStyleq();
156
+ function props(...styles) {
157
+ const [className, style, dataStyleSrc] = styleqExports.styleq(styles);
158
+ const result = {};
159
+ if (className != null && className !== '') {
160
+ result.className = className;
161
+ }
162
+ if (style != null && Object.keys(style).length > 0) {
163
+ result.style = style;
164
+ }
165
+ if (dataStyleSrc != null && dataStyleSrc !== '') {
166
+ result['data-style-src'] = dataStyleSrc;
167
+ }
168
+ return result;
169
+ }
38
170
 
39
171
  function Caption(props) {
40
- const components = {
41
- ...builtins,
42
- ...useMDXComponents()
43
- };
172
+ const components = useArticleComponents();
44
173
  const {
45
174
  src,
46
175
  code
47
176
  } = props;
48
177
  const [codeRef, setCodeRef] = React.useState(null);
49
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("figcaption", {
50
- className: "fgdj0yb"
51
- }, /*#__PURE__*/React.createElement("div", null, "Source:", " ", /*#__PURE__*/React.createElement(components.a, {
52
- href: src,
53
- target: "_blank"
54
- }, src)), code && /*#__PURE__*/React.createElement("div", {
55
- className: "d1rc4zjh",
56
- onClick: () => {
57
- if (codeRef) {
58
- const infoParent = codeRef.parentElement;
59
- if (infoParent.style.height === "0px") {
60
- infoParent.style.height = `${codeRef.getBoundingClientRect().height}px`;
61
- infoParent.style.opacity = "1";
62
- } else {
63
- infoParent.style.height = "0px";
64
- infoParent.style.opacity = "0";
65
- }
66
- }
67
- }
68
- }, /*#__PURE__*/React.createElement(Icons.Code, {
69
- size: "1.6em"
70
- }))), code && /*#__PURE__*/React.createElement("div", {
71
- className: cx_default("d1enfo6"),
72
- style: {
73
- height: 0,
74
- opacity: 0
75
- }
76
- }, /*#__PURE__*/React.createElement("div", {
77
- ref: setCodeRef,
78
- className: cx_default("d1watfn6")
79
- }, /*#__PURE__*/React.createElement(Code, {
80
- language: "jsx"
81
- }, code))));
178
+ return /*#__PURE__*/jsxs(Fragment, {
179
+ children: [/*#__PURE__*/jsxs("figcaption", {
180
+ className: "timvir-s-1dcheo9 timvir-s-jkpybl timvir-s-vgvpxu timvir-s-uxw1ft timvir-s-78zum5 timvir-s-1qughib timvir-s-6s0dn4",
181
+ children: [/*#__PURE__*/jsxs("div", {
182
+ children: ["Source:", " ", /*#__PURE__*/jsx(components.a, {
183
+ href: src,
184
+ target: "_blank",
185
+ children: src
186
+ })]
187
+ }), code && /*#__PURE__*/jsx("div", {
188
+ className: "timvir-s-1ypdohk timvir-s-gmrl4 timvir-s-1o7uuvo",
189
+ onClick: () => {
190
+ if (codeRef) {
191
+ const infoParent = codeRef.parentElement;
192
+ if (infoParent.style.height === "0px") {
193
+ infoParent.style.height = `${codeRef.getBoundingClientRect().height}px`;
194
+ infoParent.style.opacity = "1";
195
+ } else {
196
+ infoParent.style.height = "0px";
197
+ infoParent.style.opacity = "0";
198
+ }
199
+ }
200
+ },
201
+ children: /*#__PURE__*/jsx(Icons.Code, {
202
+ size: "1.6em",
203
+ className: "timvir-s-1lliihq"
204
+ })
205
+ })]
206
+ }), code && /*#__PURE__*/jsx("div", {
207
+ className: "timvir-s-b3r6kr timvir-s-104cjix timvir-s-qtp20y timvir-s-g01cxk",
208
+ children: /*#__PURE__*/jsx("div", {
209
+ ref: setCodeRef,
210
+ className: "timvir-s-14vqqas",
211
+ children: /*#__PURE__*/jsx(Code, {
212
+ language: "jsx",
213
+ children: code
214
+ })
215
+ })
216
+ })]
217
+ });
82
218
  }
83
219
  var Caption$1 = /*#__PURE__*/React.memo(Caption);
84
220
 
@@ -89,8 +225,8 @@ function Handle(props) {
89
225
  edge,
90
226
  iframeRef
91
227
  } = props;
92
- return /*#__PURE__*/React.createElement("div", {
93
- className: "d1mmz2b6",
228
+ return /*#__PURE__*/jsx("div", {
229
+ className: "timvir-s-diuk5s timvir-s-1ypdohk timvir-s-78zum5 timvir-s-6s0dn4 timvir-s-l56j7k timvir-s-byyjgo timvir-s-1cdhzux timvir-s-1cum3z5 timvir-s-blhjk6 timvir-s-1o7uuvo timvir-s-10xrfx7 timvir-s-1kpm4h4",
94
230
  onMouseDown: () => {
95
231
  lock.current = edge;
96
232
  if (iframeRef.current) {
@@ -100,15 +236,17 @@ function Handle(props) {
100
236
  },
101
237
  style: {
102
238
  gridColumn
103
- }
104
- }, /*#__PURE__*/React.createElement("svg", {
105
- width: "56",
106
- height: "56",
107
- viewBox: "0 0 56 56"
108
- }, /*#__PURE__*/React.createElement("path", {
109
- fill: "currentColor",
110
- d: "M27 18h2v20h-2V18zm-6 0h2v20h-2V18zm12 0h2v20h-2V18z"
111
- })));
239
+ },
240
+ children: /*#__PURE__*/jsx("svg", {
241
+ width: "56",
242
+ height: "56",
243
+ viewBox: "0 0 56 56",
244
+ children: /*#__PURE__*/jsx("path", {
245
+ fill: "currentColor",
246
+ d: "M27 18h2v20h-2V18zm-6 0h2v20h-2V18zm12 0h2v20h-2V18z"
247
+ })
248
+ })
249
+ });
112
250
  }
113
251
  var Handle$1 = /*#__PURE__*/React.memo(Handle);
114
252
 
@@ -118,38 +256,36 @@ function Ruler(props) {
118
256
  containerWidth = 0,
119
257
  viewportWidth = 0
120
258
  } = props;
121
- return /*#__PURE__*/React.createElement("svg", {
122
- viewBox: `-${containerWidth / 2} ${ -16 / 2} ${containerWidth} ${height}`,
123
- className: "ssl4j8q"
124
- }, /*#__PURE__*/React.createElement("rect", {
125
- x: -containerWidth / 2,
126
- y: -16 / 2,
127
- width: containerWidth,
128
- height: height,
129
- fill: "var(--timvir-secondary-background-color)"
130
- }), /*#__PURE__*/React.createElement("line", {
131
- x1: -viewportWidth / 2,
132
- x2: -viewportWidth / 2,
133
- y1: -16 / 2,
134
- y2: height / 2,
135
- strokeWidth: 2,
136
- stroke: "var(--timvir-text-color)"
137
- }), /*#__PURE__*/React.createElement("line", {
138
- x1: viewportWidth / 2,
139
- x2: viewportWidth / 2,
140
- y1: -16 / 2,
141
- y2: height / 2,
142
- strokeWidth: 2,
143
- stroke: "var(--timvir-text-color)"
144
- }));
259
+ return /*#__PURE__*/jsxs("svg", {
260
+ viewBox: `-${containerWidth / 2} ${-height / 2} ${containerWidth} ${height}`,
261
+ className: "timvir-s-h8yej3 timvir-s-1lliihq timvir-s-lup9mm timvir-s-14kudrl",
262
+ children: [/*#__PURE__*/jsx("rect", {
263
+ x: -containerWidth / 2,
264
+ y: -height / 2,
265
+ width: containerWidth,
266
+ height: height,
267
+ fill: "var(--timvir-secondary-background-color)"
268
+ }), /*#__PURE__*/jsx("line", {
269
+ x1: -viewportWidth / 2,
270
+ x2: -viewportWidth / 2,
271
+ y1: -height / 2,
272
+ y2: height / 2,
273
+ strokeWidth: 2,
274
+ stroke: "var(--timvir-text-color)"
275
+ }), /*#__PURE__*/jsx("line", {
276
+ x1: viewportWidth / 2,
277
+ x2: viewportWidth / 2,
278
+ y1: -height / 2,
279
+ y2: height / 2,
280
+ strokeWidth: 2,
281
+ stroke: "var(--timvir-text-color)"
282
+ })]
283
+ });
145
284
  }
146
285
 
147
- /**
148
- * The underlying DOM element which is rendered by this component.
149
- */
150
286
  const Root = "div";
151
- function Viewport(props, ref) {
152
- const block = useBlock(props);
287
+ function Viewport(props$1, ref) {
288
+ const block = useBlock(props$1);
153
289
  const {
154
290
  src,
155
291
  code,
@@ -159,16 +295,6 @@ function Viewport(props, ref) {
159
295
  const [state, setState] = React.useState({
160
296
  settled: false
161
297
  });
162
-
163
- /*
164
- * The container measures the width of the main column. It is used to initialize
165
- * the default width.
166
- */
167
- const [containerRef, containerROE] = useResizeObserverEntry();
168
-
169
- /*
170
- * The SVG spans across the full width. It is used to restrict the max width.
171
- */
172
298
  const [svgRef, svgROE] = useResizeObserverEntry();
173
299
  const [height, setHeight] = React.useState(undefined);
174
300
  const [maxHeight, setMaxHeight] = React.useState(undefined);
@@ -182,7 +308,7 @@ function Viewport(props, ref) {
182
308
  setWidth(max);
183
309
  }
184
310
  }
185
- }, [containerROE, svgROE, setWidth, width]);
311
+ }, [svgROE, width]);
186
312
  const lock = React.useRef("");
187
313
  const iframeRef = React.useRef(null);
188
314
  React.useEffect(() => {
@@ -217,127 +343,124 @@ function Viewport(props, ref) {
217
343
  setHeight(height);
218
344
  setMaxHeight(Math.max(height, maxHeight ?? 0));
219
345
  });
220
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
221
- ref: containerRef
222
- }), /*#__PURE__*/React.createElement(Root, {
223
- ref: ref,
224
- ...rest,
225
- className: cx_default("timvir-b-Viewport", !state.settled && "timvir-unsettled", className, fullWidth, "r1ouu0bc")
226
- }, /*#__PURE__*/React.createElement("div", {
227
- ref: svgRef,
228
- className: "d1uj09ka"
229
- }, /*#__PURE__*/React.createElement(Ruler, {
230
- containerWidth: svgROE?.contentRect.width,
231
- viewportWidth: width
232
- }), /*#__PURE__*/React.createElement("div", {
233
- className: "d2uawyc"
234
- }, width, "px")), /*#__PURE__*/React.createElement("div", {
235
- className: "d8ms9m9"
236
- }, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
237
- className: "d17q9rbm"
238
- }, /*#__PURE__*/React.createElement("div", {
239
- className: cx_default("daubpa6", height === undefined && "d1d22s19"),
240
- style: {
241
- width,
242
- height
243
- }
244
- }, /*#__PURE__*/React.createElement("iframe", {
245
- ref: iframeRef,
246
- frameBorder: "0",
247
- src: src,
248
- onLoad: ev => {
249
- const document = ev.currentTarget.contentDocument;
250
- if (!document) {
251
- console.warn(`Viewport: iframe has no contentDocument`);
252
- return;
346
+ const rootStyleProps = props(layoutStyles.block, layoutStyles.fullWidth, styles.root);
347
+ return /*#__PURE__*/jsxs(Fragment, {
348
+ children: [/*#__PURE__*/jsxs(Root, {
349
+ ref: ref,
350
+ ...rest,
351
+ className: cx("timvir-b-Viewport", !state.settled && "timvir-unsettled", className, rootStyleProps.className),
352
+ style: {
353
+ ...rootStyleProps.style,
354
+ ...rest.style
355
+ },
356
+ children: [/*#__PURE__*/jsxs("div", {
357
+ ref: svgRef,
358
+ className: "timvir-s-1n2onr6",
359
+ children: [/*#__PURE__*/jsx(Ruler, {
360
+ containerWidth: svgROE?.contentRect.width,
361
+ viewportWidth: width
362
+ }), /*#__PURE__*/jsxs("div", {
363
+ className: "timvir-s-10l6tqk timvir-s-wa60dl timvir-s-1nrll8i timvir-s-11lhmoz timvir-s-ss6m8b",
364
+ children: [width, "px"]
365
+ })]
366
+ }), /*#__PURE__*/jsx("div", {
367
+ className: "timvir-s-78zum5 timvir-s-1qjc9v5 timvir-s-l56j7k",
368
+ children: /*#__PURE__*/jsx("div", {
369
+ children: /*#__PURE__*/jsxs("div", {
370
+ className: "timvir-s-18zih8k timvir-s-rvj5dj timvir-s-7tmw4v timvir-s-yy29n5 timvir-s-jv0b96",
371
+ children: [/*#__PURE__*/jsx("div", {
372
+ ...{
373
+ 0: {
374
+ className: "timvir-s-wonfvy timvir-s-w75i6v timvir-s-1n2onr6 timvir-s-98rzlu timvir-s-pyat2d timvir-s-1h3vnj2 timvir-s-10r4kp7 timvir-s-b3r6kr"
375
+ },
376
+ 1: {
377
+ className: "timvir-s-wonfvy timvir-s-w75i6v timvir-s-1n2onr6 timvir-s-98rzlu timvir-s-pyat2d timvir-s-10r4kp7 timvir-s-b3r6kr timvir-s-1c74tu6 timvir-s-10e4vud timvir-s-a4qsjk timvir-s-1bx2yh timvir-s-1esw782 timvir-s-dftl3q timvir-s-9ncquh timvir-s-1w911z timvir-s-1nj7uno"
378
+ }
379
+ }[!!(height === undefined) << 0],
380
+ style: {
381
+ width,
382
+ height
383
+ },
384
+ children: /*#__PURE__*/jsx("iframe", {
385
+ ref: iframeRef,
386
+ frameBorder: "0",
387
+ src: src,
388
+ onLoad: ev => {
389
+ const document = ev.currentTarget.contentDocument;
390
+ if (!document) {
391
+ console.warn("Viewport: iframe has no contentDocument");
392
+ return;
393
+ }
394
+ const initializeDocument = () => {
395
+ if (document.readyState === "complete") {
396
+ {
397
+ const style = document.createElement("style");
398
+ style.id = "timvir-viewport-style";
399
+ style.innerHTML = "body { margin: 0 }";
400
+ document.head.appendChild(style);
401
+ }
402
+ {
403
+ const {
404
+ height
405
+ } = document.body.getBoundingClientRect();
406
+ setHeight(height);
407
+ setMaxHeight(height);
408
+ }
409
+ iframeRO.observe(document.body);
410
+ setTimeout(() => {
411
+ setState({
412
+ settled: true
413
+ });
414
+ }, 50);
415
+ } else {
416
+ document?.addEventListener("readystatechange", initializeDocument, {
417
+ once: true
418
+ });
419
+ }
420
+ };
421
+ initializeDocument();
422
+ },
423
+ className: "timvir-s-1lliihq timvir-s-10l6tqk timvir-s-13vifvy timvir-s-u96u03 timvir-s-h8yej3 timvir-s-5yr21d timvir-s-1pl5831",
424
+ style: {
425
+ opacity: height === undefined ? 0 : 1,
426
+ pointerEvents: height === undefined ? "none" : undefined
427
+ }
428
+ })
429
+ }), /*#__PURE__*/jsx(Handle$1, {
430
+ gridColumn: "1",
431
+ lock: lock,
432
+ edge: "left",
433
+ iframeRef: iframeRef
434
+ }), /*#__PURE__*/jsx(Handle$1, {
435
+ gridColumn: "3",
436
+ lock: lock,
437
+ edge: "right",
438
+ iframeRef: iframeRef
439
+ })]
440
+ })
441
+ })
442
+ }), /*#__PURE__*/jsx(Ruler, {
443
+ containerWidth: svgROE?.contentRect.width,
444
+ viewportWidth: width
445
+ })]
446
+ }), /*#__PURE__*/jsx(Caption$1, {
447
+ src: src,
448
+ code: code
449
+ }), /*#__PURE__*/jsx("div", {
450
+ style: {
451
+ height: (maxHeight ?? 0) - (height ?? 0),
452
+ transition: "height 0.16s"
253
453
  }
254
-
255
- /*
256
- * Some browsers (notably Firefox) don't always fully initialize the <iframe>
257
- * element (see https://bugzilla.mozilla.org/show_bug.cgi?id=1191683). The
258
- * 'head' and 'body' properties in Document (which we access below) may be null
259
- * when this onLoad callback runs.
260
- *
261
- * We use the Document readyState to decide if we can interact and observe the
262
- * DOM.
263
- */
264
-
265
- const initializeDocument = () => {
266
- if (document.readyState === "complete") {
267
- /*
268
- * Inject a simple style reset into the document.
269
- */
270
- {
271
- const style = document.createElement("style");
272
- style.id = "timvir-viewport-style";
273
- style.innerHTML = "body { margin: 0 }";
274
- document.head.appendChild(style);
275
- }
276
- {
277
- const {
278
- height
279
- } = document.body.getBoundingClientRect();
280
- setHeight(height);
281
- setMaxHeight(height);
282
- }
283
-
284
- /*
285
- * The <body> element of the iframe document is the one which we observe and
286
- * measure. It should not have any margins (we remove them by injecting a simple
287
- * style reset into the iframe document).
288
- */
289
- iframeRO.observe(document.body);
290
-
291
- /*
292
- * 50ms after the iframe document is complete, we consider the Viewport block
293
- * settled. This time includes the 16ms CSS transition time, and a tiny bit more
294
- * to allow for the content in the iframe itself to finish rendering.
295
- *
296
- * This time is not quite enough if the iframe loads additional code or needs to
297
- * load data from a remote source. But should be enough for statically rendered
298
- * content.
299
- */
300
- setTimeout(() => {
301
- setState({
302
- settled: true
303
- });
304
- }, 50);
305
- } else {
306
- document?.addEventListener("readystatechange", initializeDocument, {
307
- once: true
308
- });
309
- }
310
- };
311
- initializeDocument();
312
- },
313
- className: "i11uos8q",
314
- style: {
315
- opacity: height === undefined ? 0 : 1,
316
- pointerEvents: height === undefined ? "none" : undefined
317
- }
318
- })), /*#__PURE__*/React.createElement(Handle$1, {
319
- gridColumn: "1",
320
- lock: lock,
321
- edge: "left",
322
- iframeRef: iframeRef
323
- }), /*#__PURE__*/React.createElement(Handle$1, {
324
- gridColumn: "3",
325
- lock: lock,
326
- edge: "right",
327
- iframeRef: iframeRef
328
- })))), /*#__PURE__*/React.createElement(Ruler, {
329
- containerWidth: svgROE?.contentRect.width,
330
- viewportWidth: width
331
- })), /*#__PURE__*/React.createElement(Caption$1, {
332
- src: src,
333
- code: code
334
- }), /*#__PURE__*/React.createElement("div", {
335
- style: {
336
- height: (maxHeight ?? 0) - (height ?? 0),
337
- transition: "height 0.16s"
338
- }
339
- }));
454
+ })]
455
+ });
340
456
  }
341
457
  var Viewport$1 = /*#__PURE__*/React.forwardRef(Viewport);
458
+ const styles = {
459
+ root: {
460
+ ktR8K2: "timvir-s-1vjgj0v",
461
+ k1K539: "timvir-s-at24cr",
462
+ $$css: true
463
+ }
464
+ };
342
465
 
343
466
  export { Viewport$1 as Viewport };
@@ -3,6 +3,6 @@ interface Props {
3
3
  src: string;
4
4
  code?: string;
5
5
  }
6
- declare function Caption(props: Props): React.JSX.Element;
6
+ declare function Caption(props: Props): import("react/jsx-runtime").JSX.Element;
7
7
  declare const _default: React.MemoExoticComponent<typeof Caption>;
8
8
  export default _default;