timvir 0.1.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 (142) hide show
  1. package/blocks/Arbitrary/Arbitrary.d.ts +11 -0
  2. package/blocks/Arbitrary/context.d.ts +7 -0
  3. package/blocks/Arbitrary/docs/index.mdx +36 -0
  4. package/blocks/Arbitrary/index.d.ts +2 -0
  5. package/blocks/Arbitrary/index.js +117 -0
  6. package/blocks/Arbitrary/samples/basic.d.ts +5 -0
  7. package/blocks/Arbitrary/styles.css +6 -0
  8. package/blocks/Code/Code.d.ts +35 -0
  9. package/blocks/Code/docs/api.mdx +76 -0
  10. package/blocks/Code/docs/index.mdx +39 -0
  11. package/blocks/Code/index.d.ts +1 -0
  12. package/blocks/Code/index.js +154 -0
  13. package/blocks/Code/samples/basic.d.ts +5 -0
  14. package/blocks/Code/samples/toggle.d.ts +2 -0
  15. package/blocks/Code/styles.css +14 -0
  16. package/blocks/Code/theme.d.ts +2 -0
  17. package/blocks/ColorBar/ColorBar.d.ts +18 -0
  18. package/blocks/ColorBar/docs/api.mdx +76 -0
  19. package/blocks/ColorBar/docs/index.mdx +128 -0
  20. package/blocks/ColorBar/index.d.ts +1 -0
  21. package/blocks/ColorBar/index.js +90 -0
  22. package/blocks/ColorBar/samples/basic.d.ts +2 -0
  23. package/blocks/ColorBar/styles.css +5 -0
  24. package/blocks/ColorBook/ColorBook.d.ts +16 -0
  25. package/blocks/ColorBook/docs/api.mdx +76 -0
  26. package/blocks/ColorBook/docs/index.mdx +12 -0
  27. package/blocks/ColorBook/index.d.ts +1 -0
  28. package/blocks/ColorBook/index.js +77 -0
  29. package/blocks/ColorBook/samples/basic.d.ts +2 -0
  30. package/blocks/ColorBook/styles.css +6 -0
  31. package/blocks/Cover/Cover.d.ts +20 -0
  32. package/blocks/Cover/docs/api.mdx +76 -0
  33. package/blocks/Cover/docs/index.mdx +20 -0
  34. package/blocks/Cover/index.d.ts +1 -0
  35. package/blocks/Cover/index.js +64 -0
  36. package/blocks/Cover/samples/basic.d.ts +2 -0
  37. package/blocks/Exhibit/Exhibit.d.ts +19 -0
  38. package/blocks/Exhibit/docs/api.mdx +76 -0
  39. package/blocks/Exhibit/docs/index.mdx +56 -0
  40. package/blocks/Exhibit/index.d.ts +1 -0
  41. package/blocks/Exhibit/index.js +83 -0
  42. package/blocks/Exhibit/samples/basic.d.ts +2 -0
  43. package/blocks/Exhibit/styles.css +3 -0
  44. package/blocks/Font/Font.d.ts +15 -0
  45. package/blocks/Font/docs/api.mdx +76 -0
  46. package/blocks/Font/docs/index.mdx +23 -0
  47. package/blocks/Font/index.d.ts +1 -0
  48. package/blocks/Font/index.js +131 -0
  49. package/blocks/Font/samples/basic.d.ts +5 -0
  50. package/blocks/Font/samples/system.d.ts +2 -0
  51. package/blocks/Font/styles.css +9 -0
  52. package/blocks/Grid/Grid.d.ts +9 -0
  53. package/blocks/Grid/docs/api.mdx +76 -0
  54. package/blocks/Grid/docs/index.mdx +82 -0
  55. package/blocks/Grid/index.d.ts +1 -0
  56. package/blocks/Grid/index.js +53 -0
  57. package/blocks/Grid/samples/basic.d.ts +2 -0
  58. package/blocks/Grid/styles.css +1 -0
  59. package/blocks/Icon/Icon.d.ts +11 -0
  60. package/blocks/Icon/docs/api.mdx +76 -0
  61. package/blocks/Icon/docs/index.mdx +218 -0
  62. package/blocks/Icon/index.d.ts +1 -0
  63. package/blocks/Icon/index.js +155 -0
  64. package/blocks/Icon/internal/Canvas.d.ts +9 -0
  65. package/blocks/Icon/internal/index.d.ts +1 -0
  66. package/blocks/Icon/samples/basic.d.ts +2 -0
  67. package/blocks/Icon/styles.css +5 -0
  68. package/blocks/Icon/types.d.ts +10 -0
  69. package/blocks/Message/Message.d.ts +10 -0
  70. package/blocks/Message/docs/api.mdx +76 -0
  71. package/blocks/Message/docs/index.mdx +63 -0
  72. package/blocks/Message/index.d.ts +1 -0
  73. package/blocks/Message/index.js +72 -0
  74. package/blocks/Message/samples/basic.d.ts +5 -0
  75. package/blocks/Message/styles.css +6 -0
  76. package/blocks/Swatch/Swatch.d.ts +33 -0
  77. package/blocks/Swatch/docs/api.mdx +76 -0
  78. package/blocks/Swatch/docs/index.mdx +39 -0
  79. package/blocks/Swatch/index.d.ts +1 -0
  80. package/blocks/Swatch/index.js +84 -0
  81. package/blocks/Swatch/samples/basic.d.ts +2 -0
  82. package/blocks/Swatch/styles.css +4 -0
  83. package/blocks/Viewport/Viewport.d.ts +17 -0
  84. package/blocks/Viewport/docs/api.mdx +76 -0
  85. package/blocks/Viewport/docs/index.mdx +34 -0
  86. package/blocks/Viewport/index.d.ts +1 -0
  87. package/blocks/Viewport/index.js +322 -0
  88. package/blocks/Viewport/internal/Caption.d.ts +8 -0
  89. package/blocks/Viewport/internal/Handle.d.ts +10 -0
  90. package/blocks/Viewport/internal/Ruler.d.ts +7 -0
  91. package/blocks/Viewport/internal/index.d.ts +3 -0
  92. package/blocks/Viewport/samples/basic.d.ts +2 -0
  93. package/blocks/Viewport/styles.css +14 -0
  94. package/blocks/WebLink/WebLink.d.ts +10 -0
  95. package/blocks/WebLink/docs/api.mdx +76 -0
  96. package/blocks/WebLink/docs/index.mdx +13 -0
  97. package/blocks/WebLink/index.d.ts +1 -0
  98. package/blocks/WebLink/index.js +97 -0
  99. package/blocks/WebLink/samples/basic.d.ts +5 -0
  100. package/blocks/WebLink/styles.css +8 -0
  101. package/blocks/index.d.ts +13 -0
  102. package/blocks/index.js +13 -0
  103. package/blocks/styles.css +81 -0
  104. package/bus/index.d.ts +12 -0
  105. package/bus/index.js +22 -0
  106. package/bus/messages.d.ts +15 -0
  107. package/context/index.d.ts +20 -0
  108. package/context/index.js +15 -0
  109. package/core/components/Footer/Footer.d.ts +16 -0
  110. package/core/components/Footer/docs/api.mdx +76 -0
  111. package/core/components/Footer/docs/index.mdx +27 -0
  112. package/core/components/Footer/index.d.ts +1 -0
  113. package/core/components/Footer/samples/basic.d.ts +5 -0
  114. package/core/components/NavigationFooter/NavigationFooter.d.ts +19 -0
  115. package/core/components/NavigationFooter/docs/api.mdx +76 -0
  116. package/core/components/NavigationFooter/docs/index.mdx +10 -0
  117. package/core/components/NavigationFooter/index.d.ts +1 -0
  118. package/core/components/NavigationFooter/samples/basic.d.ts +5 -0
  119. package/core/components/Page/Page.d.ts +60 -0
  120. package/core/components/Page/components.d.ts +46 -0
  121. package/core/components/Page/docs/api.mdx +76 -0
  122. package/core/components/Page/docs/index.mdx +37 -0
  123. package/core/components/Page/index.d.ts +2 -0
  124. package/core/components/Page/internal/Section.d.ts +7 -0
  125. package/core/components/Page/internal/Sidebar.d.ts +15 -0
  126. package/core/components/Page/internal/index.d.ts +2 -0
  127. package/core/components/Page/samples/basic.d.ts +2 -0
  128. package/core/components/Page/samples/layout.d.ts +2 -0
  129. package/core/components/Page/types.d.ts +5 -0
  130. package/core/index.d.ts +22 -0
  131. package/core/index.js +708 -0
  132. package/core/layout.d.ts +4 -0
  133. package/core/styles.css +47 -0
  134. package/core/theme/colors.d.ts +36 -0
  135. package/core/theme/index.d.ts +1 -0
  136. package/hooks/index.d.ts +1 -0
  137. package/hooks/index.js +72 -0
  138. package/hooks/useResizeObserver/index.d.ts +56 -0
  139. package/package.json +27 -0
  140. package/std/base58/index.d.ts +2 -0
  141. package/std/base58/index.js +71 -0
  142. package/styles.css +128 -0
package/core/index.js ADDED
@@ -0,0 +1,708 @@
1
+ import { pipe, filter, subscribe } from 'wonka';
2
+ import { useContext, Provider } from 'timvir/context';
3
+ export { useContext } from 'timvir/context';
4
+ import * as React from 'react';
5
+ import React__default from 'react';
6
+ import { useImmer } from 'use-immer';
7
+ import { MDXProvider } from '@mdx-js/react';
8
+ import { useHotkeys } from 'react-hotkeys-hook';
9
+ import { makeBus } from 'timvir/bus';
10
+ import { theme } from 'timvir/core/theme';
11
+ export { theme } from 'timvir/core/theme';
12
+
13
+ /**
14
+ * Takes a list of class names and filters for truthy ones, joining them into a single class name for convenience.
15
+ * eg.
16
+ * ```js
17
+ * cx('red', isBig && 'big') // returns 'red big' if `isBig` is true, otherwise returns 'red'
18
+ * ```
19
+ * If arguments provided are objects, these objects are merged together, and the values are taken as class names:
20
+ *
21
+ * ```js
22
+ * cx({ color: 'class1', textDecoration: 'class2'}, { color: 'class3' }) // returns `class3 class2`
23
+ * ```
24
+ *
25
+ * @returns the combined, space separated class names that can be applied directly to the class attribute
26
+ */
27
+ const cx = function cx() {
28
+ const presentClassNames = Array.prototype.slice.call(arguments).filter(Boolean); // In the basic case, `cx` is passed all strings, and we simply need to join them together with space separators
29
+
30
+ const classNamesResult = presentClassNames.filter(arg => typeof arg !== 'object'); // There might also be objects (eg. from the atomic API) such as cx('foo', {
31
+ // key1: 'bar', key2: 'fizz'}, { key1: 'buzz' }) the desired behavior is to
32
+ // deduplicate the values based on their properties. The object's values are
33
+ // the class names
34
+
35
+ const styleCollectionResult = Object.values(Object.assign({}, ...presentClassNames.filter(arg => typeof arg === 'object')));
36
+ return [...styleCollectionResult, ...classNamesResult].join(' ');
37
+ };
38
+
39
+ const noLayout = "nc2e9vn";
40
+ const grid = "g1et32pl";
41
+ const extendedWidth = cx(noLayout, "en6sn9p");
42
+ const fullWidth = cx(noLayout, "f3c539b");
43
+
44
+ /**
45
+ * The underlying DOM element which is rendered by this component.
46
+ */
47
+
48
+ const Root$2 = "footer";
49
+
50
+ function Footer(props, ref) {
51
+ const {
52
+ className,
53
+ links,
54
+ ...rest
55
+ } = props;
56
+ return /*#__PURE__*/React.createElement(Root$2, {
57
+ ref: ref,
58
+ className: cx(className, classes$2.root),
59
+ ...rest
60
+ }, links && /*#__PURE__*/React.createElement("div", {
61
+ className: grid
62
+ }, /*#__PURE__*/React.createElement("div", {
63
+ className: classes$2.linkGroups
64
+ }, links.map(({
65
+ group,
66
+ items
67
+ }, i) => /*#__PURE__*/React.createElement("div", {
68
+ key: i
69
+ }, /*#__PURE__*/React.createElement("div", {
70
+ className: classes$2.linkGroupTitle
71
+ }, group), /*#__PURE__*/React.createElement("div", null, items.map(({
72
+ label,
73
+ href
74
+ }, j) => /*#__PURE__*/React.createElement("a", {
75
+ key: j,
76
+ href: href,
77
+ className: classes$2.link
78
+ }, label))))))), /*#__PURE__*/React.createElement("div", {
79
+ className: cx(grid, classes$2.meta)
80
+ }, /*#__PURE__*/React.createElement("div", null, "Built with ", /*#__PURE__*/React.createElement("a", {
81
+ href: "https://timvir.vercel.app"
82
+ }, "Timvir"))));
83
+ }
84
+
85
+ var Footer$1 = /*#__PURE__*/React.forwardRef(Footer);
86
+ const classes$2 = {
87
+ root: "rwhrdvg",
88
+ linkGroups: "l1u1x7q7",
89
+ linkGroupTitle: "l1x5jo3a",
90
+ link: "l29wcr8",
91
+ meta: "m1ojti9g"
92
+ };
93
+
94
+ /**
95
+ * The underlying DOM element which is rendered by this component.
96
+ */
97
+
98
+ const Root$1 = "div";
99
+
100
+ function NavigationFooter(props, ref) {
101
+ const {
102
+ prev,
103
+ next,
104
+ className,
105
+ ...rest
106
+ } = props;
107
+ return /*#__PURE__*/React.createElement(Root$1, {
108
+ ref: ref,
109
+ ...rest,
110
+ className: cx(className, "re625n1")
111
+ }, /*#__PURE__*/React.createElement("div", {
112
+ className: "d19gj27w"
113
+ }, /*#__PURE__*/React.createElement("div", {
114
+ className: "d15ohs1l"
115
+ }, prev && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SecondaryLabel, null, prev.context || "/"), /*#__PURE__*/React.createElement(PrimaryLink, {
116
+ href: prev.href
117
+ }, prev.label))), /*#__PURE__*/React.createElement("div", {
118
+ className: "dczrd9z"
119
+ }, next && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SecondaryLabel, null, next.context || "/"), /*#__PURE__*/React.createElement(PrimaryLink, {
120
+ href: next.href
121
+ }, next.label)))));
122
+ }
123
+
124
+ var NavigationFooter$1 = /*#__PURE__*/React.forwardRef(NavigationFooter);
125
+
126
+ const PrimaryLink = ({
127
+ href,
128
+ children
129
+ }) => {
130
+ const {
131
+ Link
132
+ } = useContext();
133
+ return /*#__PURE__*/React.createElement(Link, {
134
+ href: href
135
+ }, /*#__PURE__*/React.createElement("a", {
136
+ className: "aifnzb8"
137
+ }, children));
138
+ };
139
+
140
+ const SecondaryLabel = ({
141
+ children
142
+ }) => /*#__PURE__*/React.createElement("div", {
143
+ className: "dymvrdu"
144
+ }, children);
145
+
146
+ function memoize(fn) {
147
+ var cache = {};
148
+ return function (arg) {
149
+ if (cache[arg] === undefined) cache[arg] = fn(arg);
150
+ return cache[arg];
151
+ };
152
+ }
153
+
154
+ var reactPropsRegex = /^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|inert|itemProp|itemScope|itemType|itemID|itemRef|on|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/; // https://esbench.com/bench/5bfee68a4cd7e6009ef61d23
155
+
156
+ var index = memoize(function (prop) {
157
+ return reactPropsRegex.test(prop) || prop.charCodeAt(0) === 111
158
+ /* o */
159
+ && prop.charCodeAt(1) === 110
160
+ /* n */
161
+ && prop.charCodeAt(2) < 91;
162
+ }
163
+ /* Z+1 */
164
+ );
165
+
166
+ /**
167
+ * This file contains an runtime version of `styled` component. Responsibilities of the component are:
168
+ * - returns ReactElement based on HTML tag used with `styled` or custom React Component
169
+ * - injects classNames for the returned component
170
+ * - injects CSS variables used to define dynamic styles based on props
171
+ */
172
+
173
+ const restOp = (obj, keysToExclude) => Object.keys(obj).filter(prop => keysToExclude.indexOf(prop) === -1).reduce((acc, curr) => {
174
+ acc[curr] = obj[curr];
175
+ return acc;
176
+ }, {}); // rest operator workaround
177
+
178
+
179
+ const warnIfInvalid = (value, componentName) => {
180
+ if (process.env.NODE_ENV !== 'production') {
181
+ if (typeof value === 'string' || // eslint-disable-next-line no-self-compare
182
+ typeof value === 'number' && isFinite(value)) {
183
+ return;
184
+ }
185
+
186
+ const stringified = typeof value === 'object' ? JSON.stringify(value) : String(value); // eslint-disable-next-line no-console
187
+
188
+ console.warn(`An interpolation evaluated to '${stringified}' in the component '${componentName}', which is probably a mistake. You should explicitly cast or transform the value to a string.`);
189
+ }
190
+ };
191
+
192
+ function styled(tag) {
193
+ return options => {
194
+ if (process.env.NODE_ENV !== 'production') {
195
+ if (Array.isArray(options)) {
196
+ // We received a strings array since it's used as a tag
197
+ throw new Error('Using the "styled" tag in runtime is not supported. Make sure you have set up the Babel plugin correctly. See https://github.com/callstack/linaria#setup');
198
+ }
199
+ }
200
+
201
+ const render = (props, ref) => {
202
+ const {
203
+ as: component = tag,
204
+ class: className
205
+ } = props;
206
+ const rest = restOp(props, ['as', 'class']);
207
+ let filteredProps; // Check if it's an HTML tag and not a custom element
208
+
209
+ if (typeof component === 'string' && component.indexOf('-') === -1) {
210
+ filteredProps = {}; // eslint-disable-next-line guard-for-in
211
+
212
+ for (const key in rest) {
213
+ if (key === 'as' || index(key)) {
214
+ // Don't pass through invalid attributes to HTML elements
215
+ filteredProps[key] = rest[key];
216
+ }
217
+ }
218
+ } else {
219
+ filteredProps = rest;
220
+ }
221
+
222
+ filteredProps.ref = ref;
223
+ filteredProps.className = cx(filteredProps.className || className, options.class);
224
+ const {
225
+ vars
226
+ } = options;
227
+
228
+ if (vars) {
229
+ const style = {}; // eslint-disable-next-line guard-for-in
230
+
231
+ for (const name in vars) {
232
+ const variable = vars[name];
233
+ const result = variable[0];
234
+ const unit = variable[1] || '';
235
+ const value = typeof result === 'function' ? result(props) : result;
236
+ warnIfInvalid(value, options.name);
237
+ style[`--${name}`] = `${value}${unit}`;
238
+ }
239
+
240
+ const ownStyle = filteredProps.style || {};
241
+ const keys = Object.keys(ownStyle);
242
+
243
+ if (keys.length > 0) {
244
+ keys.forEach(key => {
245
+ style[key] = ownStyle[key];
246
+ });
247
+ }
248
+
249
+ filteredProps.style = style;
250
+ }
251
+
252
+ if (tag.__linaria && tag !== component) {
253
+ // If the underlying tag is a styled component, forward the `as` prop
254
+ // Otherwise the styles from the underlying component will be ignored
255
+ filteredProps.as = component;
256
+ return /*#__PURE__*/React__default.createElement(tag, filteredProps);
257
+ }
258
+
259
+ return /*#__PURE__*/React__default.createElement(component, filteredProps);
260
+ };
261
+
262
+ const Result = React__default.forwardRef ? /*#__PURE__*/React__default.forwardRef(render) : // React.forwardRef won't available on older React versions and in Preact
263
+ // Fallback to a innerRef prop in that case
264
+ props => {
265
+ const rest = restOp(props, ['innerRef']);
266
+ return render(rest, props.innerRef);
267
+ };
268
+ Result.displayName = options.name; // These properties will be read by the babel plugin for interpolation
269
+
270
+ Result.__linaria = {
271
+ className: options.class,
272
+ extends: tag
273
+ };
274
+ return Result;
275
+ };
276
+ }
277
+
278
+ var styled$1 = process.env.NODE_ENV !== 'production' ? new Proxy(styled, {
279
+ get(o, prop) {
280
+ return o(prop);
281
+ }
282
+
283
+ }) : styled;
284
+
285
+ const anchorize = children => {
286
+ if (typeof children === "string") {
287
+ return children.toLowerCase().replace(/[ _]+/g, "-").replace(/[!:^*./\\]/g, "");
288
+ } else {
289
+ return undefined;
290
+ }
291
+ };
292
+
293
+ function Heading(Component) {
294
+ return function Heading(props) {
295
+ const id = anchorize(props.children);
296
+ return /*#__PURE__*/React.createElement(Component, {
297
+ id: id,
298
+ ...props
299
+ }, /*#__PURE__*/React.createElement("a", {
300
+ className: "a12hs2f7",
301
+ href: id && `#${id}`
302
+ }, "#"), props.children);
303
+ };
304
+ }
305
+
306
+ const h1 = /*#__PURE__*/styled$1("h1")({
307
+ name: "h1",
308
+ class: "h31avqb"
309
+ });
310
+ const h2 = Heading( /*#__PURE__*/styled$1("h2")({
311
+ name: "h2",
312
+ class: "h6ceq1b"
313
+ }));
314
+ const h3 = Heading( /*#__PURE__*/styled$1("h3")({
315
+ name: "h3",
316
+ class: "hj6166y"
317
+ }));
318
+ const h4 = Heading( /*#__PURE__*/styled$1("h4")({
319
+ name: "h4",
320
+ class: "h1f8mqks"
321
+ }));
322
+ const blockquote = /*#__PURE__*/styled$1("blockquote")({
323
+ name: "blockquote",
324
+ class: "b1hmga4"
325
+ });
326
+ const hr = /*#__PURE__*/styled$1("hr")({
327
+ name: "hr",
328
+ class: "hlrd6ep"
329
+ });
330
+ const table = /*#__PURE__*/styled$1("table")({
331
+ name: "table",
332
+ class: "t172su6f"
333
+ });
334
+ const thead = /*#__PURE__*/styled$1("thead")({
335
+ name: "thead",
336
+ class: "t1a7p0gg"
337
+ });
338
+ const tbody = /*#__PURE__*/styled$1("tbody")({
339
+ name: "tbody",
340
+ class: "t1fah8q4"
341
+ });
342
+ const tr = /*#__PURE__*/styled$1("tr")({
343
+ name: "tr",
344
+ class: "twrwqj6"
345
+ });
346
+ const th = /*#__PURE__*/styled$1("th")({
347
+ name: "th",
348
+ class: "t1fhygp",
349
+ vars: {
350
+ "t1fhygp-0": [props => props.align || "center"]
351
+ }
352
+ });
353
+ const td = /*#__PURE__*/styled$1("td")({
354
+ name: "td",
355
+ class: "t176v8uh",
356
+ vars: {
357
+ "t176v8uh-0": [props => props.align || "left"]
358
+ }
359
+ });
360
+ const code = /*#__PURE__*/styled$1("code")({
361
+ name: "code",
362
+ class: "cvhsmuz"
363
+ });
364
+ const a = /*#__PURE__*/styled$1("a")({
365
+ name: "a",
366
+ class: "a197eb99"
367
+ });
368
+ const p = /*#__PURE__*/styled$1("p")({
369
+ name: "p",
370
+ class: "p1d7vdmn"
371
+ });
372
+ const ul = /*#__PURE__*/styled$1("ul")({
373
+ name: "ul",
374
+ class: "ugfnift"
375
+ });
376
+ const ol = /*#__PURE__*/styled$1("ol")({
377
+ name: "ol",
378
+ class: "o3pt2dg"
379
+ });
380
+
381
+ var mdxComponentsBase = /*#__PURE__*/Object.freeze({
382
+ __proto__: null,
383
+ h1: h1,
384
+ h2: h2,
385
+ h3: h3,
386
+ h4: h4,
387
+ blockquote: blockquote,
388
+ hr: hr,
389
+ table: table,
390
+ thead: thead,
391
+ tbody: tbody,
392
+ tr: tr,
393
+ th: th,
394
+ td: td,
395
+ code: code,
396
+ a: a,
397
+ p: p,
398
+ ul: ul,
399
+ ol: ol
400
+ });
401
+
402
+ function Section(props) {
403
+ const {
404
+ depth,
405
+ label,
406
+ path,
407
+ children = []
408
+ } = props;
409
+ const {
410
+ location,
411
+ Link
412
+ } = useContext();
413
+ const [active, setActive] = React.useState(() => {
414
+ if (path) {
415
+ return location.asPath.startsWith(path);
416
+ } else if (children.length > 0) {
417
+ return children.some(({
418
+ path
419
+ }) => path && location.asPath.startsWith(path));
420
+ } else {
421
+ return false;
422
+ }
423
+ });
424
+ React.useEffect(() => {
425
+ if (path && location.asPath.startsWith(path)) {
426
+ setActive(true);
427
+ }
428
+ }, [path, location.asPath]);
429
+ return /*#__PURE__*/React.createElement("section", {
430
+ className: classes$1.root
431
+ }, /*#__PURE__*/React.createElement("div", {
432
+ className: classes$1.node,
433
+ "data-active": location.asPath === path
434
+ }, path ? /*#__PURE__*/React.createElement(Link, {
435
+ href: path
436
+ }, /*#__PURE__*/React.createElement("a", {
437
+ style: {
438
+ marginLeft: depth * 20
439
+ }
440
+ }, label)) : /*#__PURE__*/React.createElement("a", {
441
+ style: {
442
+ marginLeft: depth * 20
443
+ },
444
+ href: "#",
445
+ onClick: () => setActive(x => !x)
446
+ }, label)), active && children.map((c, i) => /*#__PURE__*/React.createElement(Section, {
447
+ key: i,
448
+ depth: depth + 1,
449
+ ...c
450
+ })));
451
+ }
452
+ const classes$1 = {
453
+ root: "ruyt2hq",
454
+ node: "njdy1am"
455
+ };
456
+
457
+ function Sidebar(props) {
458
+ const {
459
+ toc,
460
+ search
461
+ } = props;
462
+ const [state, mutate] = useImmer({
463
+ shadowVisible: false
464
+ });
465
+
466
+ const onScroll = ev => {
467
+ const shadowVisible = ev.currentTarget.scrollTop > 2;
468
+
469
+ if (state.shadowVisible !== shadowVisible) {
470
+ mutate(draft => {
471
+ draft.shadowVisible = shadowVisible;
472
+ });
473
+ }
474
+ };
475
+
476
+ return /*#__PURE__*/React.createElement("aside", {
477
+ className: cx(classes.root)
478
+ }, /*#__PURE__*/React.createElement("div", {
479
+ className: "d17eoe18"
480
+ }, search && /*#__PURE__*/React.createElement("div", {
481
+ className: cx("d1mgn6rc", state.shadowVisible && "d7bx8iu")
482
+ }, /*#__PURE__*/React.createElement(Search, { ...search
483
+ })), /*#__PURE__*/React.createElement("div", {
484
+ className: classes.sections,
485
+ onScroll: onScroll
486
+ }, /*#__PURE__*/React.createElement("nav", null, toc.map((c, i) => /*#__PURE__*/React.createElement(Section, {
487
+ key: i,
488
+ depth: 0,
489
+ ...c
490
+ }))))));
491
+ }
492
+ const classes = {
493
+ root: "r119ou0k",
494
+ sections: "s1f74255"
495
+ };
496
+
497
+ const Search = ({
498
+ open,
499
+ label
500
+ }) => {
501
+ return /*#__PURE__*/React.createElement("div", {
502
+ className: "d5l3c45"
503
+ }, /*#__PURE__*/React.createElement("div", {
504
+ role: "button",
505
+ className: "d15ju3pv",
506
+ onClick: open
507
+ }, /*#__PURE__*/React.createElement("svg", {
508
+ x: "0px",
509
+ y: "0px",
510
+ width: "12px",
511
+ height: "12px",
512
+ viewBox: "0 0 12 12"
513
+ }, /*#__PURE__*/React.createElement("path", {
514
+ d: "M11.707 10.293l-2.54-2.54a5.015 5.015 0 10-1.414 1.414l2.54 2.54a1 1 0 001.414-1.414zM2 5a3 3 0 113 3 3 3 0 01-3-3z",
515
+ fill: "currentColor"
516
+ })), label || "Quick Find"));
517
+ };
518
+
519
+ /**
520
+ * The underlying DOM element which is rendered by this component.
521
+ */
522
+ const Root = "div";
523
+
524
+ function Page(props, ref) {
525
+ const {
526
+ location,
527
+ toc,
528
+ Link,
529
+ className,
530
+ search,
531
+ mdxComponents,
532
+ Footer,
533
+ blocks,
534
+ children,
535
+ ...rest
536
+ } = props;
537
+ const [state, mutate] = useImmer({
538
+ search: {
539
+ open: false
540
+ }
541
+ });
542
+ const [bus] = React.useState(makeBus);
543
+ const context = React.useMemo(() => ({
544
+ bus,
545
+ location,
546
+ Link,
547
+ blocks
548
+ }), [bus, location, Link, blocks]);
549
+ useHotkeys("command+p,escape", (ev, handler) => {
550
+ switch (handler.key) {
551
+ case "command+p":
552
+ {
553
+ ev.preventDefault();
554
+ mutate(draft => {
555
+ draft.search.open = !draft.search.open;
556
+ });
557
+ return;
558
+ }
559
+
560
+ case "escape":
561
+ {
562
+ mutate(draft => {
563
+ draft.search.open = false;
564
+ });
565
+ return;
566
+ }
567
+ }
568
+ }, {
569
+ enableOnTags: ["BODY", "INPUT"]
570
+ });
571
+ return /*#__PURE__*/React.createElement(Provider, {
572
+ value: context
573
+ }, /*#__PURE__*/React.createElement(Root, {
574
+ ref: ref,
575
+ ...rest,
576
+ className: cx(className, theme, "rfhjyp1")
577
+ }, /*#__PURE__*/React.createElement("div", {
578
+ className: "d1pp8z35"
579
+ }, /*#__PURE__*/React.createElement(Sidebar, {
580
+ toc: toc,
581
+ search: search && {
582
+ open: () => {
583
+ mutate(draft => {
584
+ draft.search.open = true;
585
+ });
586
+ },
587
+ ...search
588
+ }
589
+ })), /*#__PURE__*/React.createElement("div", {
590
+ className: "dxk1fgw"
591
+ }, /*#__PURE__*/React.createElement("div", {
592
+ className: grid
593
+ }, /*#__PURE__*/React.createElement(MDXProvider, {
594
+ components: { ...mdxComponentsBase,
595
+ ...mdxComponents
596
+ }
597
+ }, children)), /*#__PURE__*/React.createElement("div", {
598
+ className: "d2srpki"
599
+ }, (() => {
600
+ function flatten(n, parents) {
601
+ let ret = [];
602
+
603
+ if (n.path) {
604
+ ret.push({
605
+ parents,
606
+ label: n.label,
607
+ path: n.path
608
+ });
609
+ }
610
+
611
+ if (n.children) {
612
+ ret = [...ret, ...n.children.flatMap(c => flatten(c, [...parents, n]))];
613
+ }
614
+
615
+ return ret;
616
+ }
617
+
618
+ const items = toc.flatMap(n => flatten(n, []));
619
+ const index = items.findIndex(v => v.path === location.asPath.replace(/#.*/, ""));
620
+
621
+ if (index === -1) {
622
+ return null;
623
+ }
624
+
625
+ function toLink(index) {
626
+ const item = items[index];
627
+
628
+ if (item === undefined) {
629
+ return undefined;
630
+ } else {
631
+ return {
632
+ href: item.path,
633
+ label: item.label,
634
+ context: item.parents.map(x => x.label).join(" / ")
635
+ };
636
+ }
637
+ }
638
+
639
+ return /*#__PURE__*/React.createElement("div", {
640
+ className: "d1hkiw6l"
641
+ }, /*#__PURE__*/React.createElement(NavigationFooter$1, {
642
+ prev: toLink(index - 1),
643
+ next: toLink(index + 1)
644
+ }));
645
+ })(), Footer && /*#__PURE__*/React.createElement(Footer, null))), search && /*#__PURE__*/React.createElement(search.Component, { ...state.search,
646
+ onClose: () => {
647
+ mutate(draft => {
648
+ draft.search.open = false;
649
+ });
650
+ }
651
+ })));
652
+ }
653
+
654
+ var Page$1 = /*#__PURE__*/React.forwardRef(Page);
655
+
656
+ /**
657
+ * A mailbox is a wonka source which receives messages for one specific block (identified by its id).
658
+ */
659
+
660
+ function useMailbox(id) {
661
+ const {
662
+ bus
663
+ } = useContext();
664
+ return React.useMemo(() => pipe(bus.source, filter(x => id ? x.path === `/dev/timvir/block/${id}` : false)), [bus, id]);
665
+ }
666
+ function useBlock(props) {
667
+ const {
668
+ bus
669
+ } = useContext();
670
+ const mailbox = useMailbox(props.id);
671
+ const [state, mutate] = useImmer({
672
+ overrides: undefined
673
+ });
674
+ React.useEffect(() => pipe(mailbox, subscribe(msg => {
675
+ if (msg.interface === "dev.timvir.Props") {
676
+ if (msg.member === "set") {
677
+ mutate(draft => {
678
+ draft.overrides = msg.body;
679
+ });
680
+ } else if (msg.member === "merge") {
681
+ mutate(draft => {
682
+ draft.overrides = { ...draft.overrides,
683
+ ...msg.body
684
+ };
685
+ });
686
+ } else if (msg.member === "reset") {
687
+ mutate(draft => {
688
+ draft.overrides = undefined;
689
+ });
690
+ }
691
+ }
692
+ })).unsubscribe, [mailbox, mutate]);
693
+ return {
694
+ bus,
695
+ mailbox,
696
+ props: { ...props,
697
+ ...state.overrides
698
+ },
699
+ hasOverrides: !!state.overrides,
700
+ reset: () => {
701
+ mutate(draft => {
702
+ draft.overrides = undefined;
703
+ });
704
+ }
705
+ };
706
+ }
707
+
708
+ export { Footer$1 as Footer, Page$1 as Page, extendedWidth, fullWidth, grid, useBlock, useMailbox };