@bolio-ui/core 1.0.0

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 (381) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -0
  3. package/dist/avatar/index.js +901 -0
  4. package/dist/badge/index.js +899 -0
  5. package/dist/bolio-ui-provider/index.js +1883 -0
  6. package/dist/breadcrumbs/index.js +985 -0
  7. package/dist/button/index.js +1358 -0
  8. package/dist/button-dropdown/index.js +1111 -0
  9. package/dist/button-group/index.js +782 -0
  10. package/dist/capacity/index.js +780 -0
  11. package/dist/card/index.js +1275 -0
  12. package/dist/checkbox/index.js +1042 -0
  13. package/dist/code/index.js +803 -0
  14. package/dist/col/index.js +90 -0
  15. package/dist/collapse/index.js +1158 -0
  16. package/dist/container/index.js +444 -0
  17. package/dist/css-baseline/index.js +348 -0
  18. package/dist/description/index.js +741 -0
  19. package/dist/display/index.js +745 -0
  20. package/dist/divider/index.js +767 -0
  21. package/dist/dot/index.js +755 -0
  22. package/dist/drawer/index.js +1513 -0
  23. package/dist/fieldset/index.js +1089 -0
  24. package/dist/grid/index.js +870 -0
  25. package/dist/image/index.js +1094 -0
  26. package/dist/index.js +9970 -0
  27. package/dist/input/index.js +1275 -0
  28. package/dist/keyboard/index.js +711 -0
  29. package/dist/link/index.js +863 -0
  30. package/dist/loading/index.js +765 -0
  31. package/dist/mdx-widgets/index.js +438 -0
  32. package/dist/modal/index.js +2220 -0
  33. package/dist/note/index.js +773 -0
  34. package/dist/page/index.js +928 -0
  35. package/dist/pagination/index.js +1201 -0
  36. package/dist/popover/index.js +1502 -0
  37. package/dist/progress/index.js +804 -0
  38. package/dist/radio/index.js +1028 -0
  39. package/dist/rating/index.js +912 -0
  40. package/dist/row/index.js +442 -0
  41. package/dist/section/index.js +733 -0
  42. package/dist/select/index.js +1865 -0
  43. package/dist/slider/index.js +1097 -0
  44. package/dist/snippet/index.js +1207 -0
  45. package/dist/spacer/index.js +692 -0
  46. package/dist/spinner/index.js +763 -0
  47. package/dist/styled-jsx.cjs.js +766 -0
  48. package/dist/tabs/index.js +1125 -0
  49. package/dist/tag/index.js +749 -0
  50. package/dist/text/index.js +830 -0
  51. package/dist/textarea/index.js +915 -0
  52. package/dist/themes/index.js +319 -0
  53. package/dist/toggle/index.js +852 -0
  54. package/dist/tooltip/index.js +1353 -0
  55. package/dist/use-all-themes/index.js +335 -0
  56. package/dist/use-body-scroll/index.js +173 -0
  57. package/dist/use-classes/index.js +55 -0
  58. package/dist/use-click-away/index.js +28 -0
  59. package/dist/use-clipboard/index.js +188 -0
  60. package/dist/use-current-state/index.js +90 -0
  61. package/dist/use-input/index.js +129 -0
  62. package/dist/use-keyboard/index.js +214 -0
  63. package/dist/use-media-query/index.js +495 -0
  64. package/dist/use-modal/index.js +114 -0
  65. package/dist/use-scale/index.js +673 -0
  66. package/dist/use-tabs/index.js +112 -0
  67. package/dist/use-theme/index.js +333 -0
  68. package/dist/use-toasts/index.js +236 -0
  69. package/esm/avatar/avatar-group.js +29 -0
  70. package/esm/avatar/avatar.js +107 -0
  71. package/esm/avatar/avatar.skeleton.js +21 -0
  72. package/esm/avatar/helpers.js +16 -0
  73. package/esm/avatar/index.js +4 -0
  74. package/esm/avatar/stories.js +113 -0
  75. package/esm/badge/badge-anchor.js +70 -0
  76. package/esm/badge/badge.js +58 -0
  77. package/esm/badge/index.js +4 -0
  78. package/esm/badge/stories.js +92 -0
  79. package/esm/bolio-ui-provider/bolio-ui-provider.js +62 -0
  80. package/esm/bolio-ui-provider/index.js +2 -0
  81. package/esm/bolio-ui-provider/theme-provider.js +47 -0
  82. package/esm/breadcrumbs/breadcrumbs-item.js +49 -0
  83. package/esm/breadcrumbs/breadcrumbs-separator.js +25 -0
  84. package/esm/breadcrumbs/breadcrumbs.js +47 -0
  85. package/esm/breadcrumbs/index.js +6 -0
  86. package/esm/breadcrumbs/stories.js +51 -0
  87. package/esm/button/button-icon.js +29 -0
  88. package/esm/button/button-loading.js +17 -0
  89. package/esm/button/button.drip.js +57 -0
  90. package/esm/button/button.js +146 -0
  91. package/esm/button/index.js +2 -0
  92. package/esm/button/stories.js +221 -0
  93. package/esm/button/styles.js +232 -0
  94. package/esm/button/utils.js +46 -0
  95. package/esm/button-dropdown/button-dropdown-context.js +11 -0
  96. package/esm/button-dropdown/button-dropdown-item.js +52 -0
  97. package/esm/button-dropdown/button-dropdown.js +111 -0
  98. package/esm/button-dropdown/icon.js +30 -0
  99. package/esm/button-dropdown/index.js +4 -0
  100. package/esm/button-dropdown/stories.js +92 -0
  101. package/esm/button-dropdown/styles.js +60 -0
  102. package/esm/button-group/button-group-context.js +9 -0
  103. package/esm/button-group/button-group.js +75 -0
  104. package/esm/button-group/index.js +2 -0
  105. package/esm/button-group/stories.js +66 -0
  106. package/esm/capacity/capacity.js +52 -0
  107. package/esm/capacity/index.js +2 -0
  108. package/esm/capacity/stories.js +55 -0
  109. package/esm/card/card-content.js +28 -0
  110. package/esm/card/card-footer.js +36 -0
  111. package/esm/card/card.js +68 -0
  112. package/esm/card/index.js +8 -0
  113. package/esm/card/stories.js +126 -0
  114. package/esm/card/styles.js +45 -0
  115. package/esm/checkbox/checkbox-context.js +10 -0
  116. package/esm/checkbox/checkbox-group.js +70 -0
  117. package/esm/checkbox/checkbox.icon.js +50 -0
  118. package/esm/checkbox/checkbox.js +114 -0
  119. package/esm/checkbox/index.js +4 -0
  120. package/esm/checkbox/stories.js +84 -0
  121. package/esm/checkbox/styles.js +34 -0
  122. package/esm/code/code.js +57 -0
  123. package/esm/code/index.js +2 -0
  124. package/esm/code/stories.js +53 -0
  125. package/esm/col/col.js +29 -0
  126. package/esm/col/index.js +2 -0
  127. package/esm/collapse/collapse-context.js +8 -0
  128. package/esm/collapse/collapse-group.js +75 -0
  129. package/esm/collapse/collapse-icon.js +28 -0
  130. package/esm/collapse/collapse.js +93 -0
  131. package/esm/collapse/index.js +4 -0
  132. package/esm/collapse/stories.js +48 -0
  133. package/esm/container/container.js +62 -0
  134. package/esm/container/index.js +2 -0
  135. package/esm/css-baseline/css-baseline.js +18 -0
  136. package/esm/css-baseline/index.js +1 -0
  137. package/esm/description/description.js +39 -0
  138. package/esm/description/index.js +2 -0
  139. package/esm/description/stories.js +23 -0
  140. package/esm/display/display.js +43 -0
  141. package/esm/display/index.js +2 -0
  142. package/esm/divider/divider.js +65 -0
  143. package/esm/divider/index.js +2 -0
  144. package/esm/divider/stories.js +41 -0
  145. package/esm/dot/dot.js +53 -0
  146. package/esm/dot/index.js +2 -0
  147. package/esm/dot/stories.js +40 -0
  148. package/esm/drawer/drawer-wrapper.js +86 -0
  149. package/esm/drawer/drawer.js +77 -0
  150. package/esm/drawer/helper.js +27 -0
  151. package/esm/drawer/index.js +8 -0
  152. package/esm/drawer/stories.js +79 -0
  153. package/esm/fieldset/fieldset-content.js +29 -0
  154. package/esm/fieldset/fieldset-context.js +9 -0
  155. package/esm/fieldset/fieldset-footer.js +30 -0
  156. package/esm/fieldset/fieldset-group.js +88 -0
  157. package/esm/fieldset/fieldset-subtitle.js +21 -0
  158. package/esm/fieldset/fieldset-title.js +23 -0
  159. package/esm/fieldset/fieldset.js +96 -0
  160. package/esm/fieldset/index.js +13 -0
  161. package/esm/fieldset/stories.js +72 -0
  162. package/esm/grid/basic-item.js +96 -0
  163. package/esm/grid/grid-container.js +46 -0
  164. package/esm/grid/grid-types.js +6 -0
  165. package/esm/grid/grid.js +37 -0
  166. package/esm/grid/index.js +4 -0
  167. package/esm/grid/stories.js +212 -0
  168. package/esm/icon/stories.js +36 -0
  169. package/esm/image/helpers.js +16 -0
  170. package/esm/image/image-browser-https-icon.js +23 -0
  171. package/esm/image/image-browser.js +86 -0
  172. package/esm/image/image.js +91 -0
  173. package/esm/image/image.skeleton.js +21 -0
  174. package/esm/image/index.js +4 -0
  175. package/esm/image/stories.js +73 -0
  176. package/esm/image/styles.js +15 -0
  177. package/esm/index.js +69 -0
  178. package/esm/input/index.js +6 -0
  179. package/esm/input/input-block-label.js +18 -0
  180. package/esm/input/input-icon-clear.js +47 -0
  181. package/esm/input/input-icon.js +19 -0
  182. package/esm/input/input-label.js +18 -0
  183. package/esm/input/input-props.js +12 -0
  184. package/esm/input/input.js +179 -0
  185. package/esm/input/password-icon.js +30 -0
  186. package/esm/input/password.js +66 -0
  187. package/esm/input/stories.js +113 -0
  188. package/esm/input/styles.js +41 -0
  189. package/esm/keyboard/index.js +2 -0
  190. package/esm/keyboard/keyboard.js +48 -0
  191. package/esm/keyboard/stories.js +43 -0
  192. package/esm/link/icon.js +30 -0
  193. package/esm/link/index.js +2 -0
  194. package/esm/link/link.js +50 -0
  195. package/esm/link/stories.js +59 -0
  196. package/esm/loading/index.js +2 -0
  197. package/esm/loading/loading.js +63 -0
  198. package/esm/loading/stories.js +75 -0
  199. package/esm/mdx-widgets/index.js +2 -0
  200. package/esm/mdx-widgets/mock-page.js +37 -0
  201. package/esm/mdx-widgets/parsed-codes/index.js +1 -0
  202. package/esm/mdx-widgets/parsed-codes/wait-time.js +13 -0
  203. package/esm/modal/index.js +10 -0
  204. package/esm/modal/modal-action.js +76 -0
  205. package/esm/modal/modal-actions.js +39 -0
  206. package/esm/modal/modal-content.js +28 -0
  207. package/esm/modal/modal-context.js +6 -0
  208. package/esm/modal/modal-subtitle.js +30 -0
  209. package/esm/modal/modal-title.js +30 -0
  210. package/esm/modal/modal-wrapper.js +80 -0
  211. package/esm/modal/modal.js +104 -0
  212. package/esm/modal/stories.js +165 -0
  213. package/esm/note/index.js +2 -0
  214. package/esm/note/note.js +71 -0
  215. package/esm/note/stories.js +68 -0
  216. package/esm/page/index.js +9 -0
  217. package/esm/page/page-content.js +26 -0
  218. package/esm/page/page-footer.js +25 -0
  219. package/esm/page/page-header.js +33 -0
  220. package/esm/page/page.js +88 -0
  221. package/esm/page/stories.js +54 -0
  222. package/esm/pagination/index.js +6 -0
  223. package/esm/pagination/pagination-context.js +8 -0
  224. package/esm/pagination/pagination-ellipsis.js +73 -0
  225. package/esm/pagination/pagination-item.js +50 -0
  226. package/esm/pagination/pagination-next.js +25 -0
  227. package/esm/pagination/pagination-pages.js +90 -0
  228. package/esm/pagination/pagination-previous.js +25 -0
  229. package/esm/pagination/pagination.js +105 -0
  230. package/esm/pagination/stories.js +49 -0
  231. package/esm/popover/index.js +5 -0
  232. package/esm/popover/popover-context.js +9 -0
  233. package/esm/popover/popover-item.js +65 -0
  234. package/esm/popover/popover.js +83 -0
  235. package/esm/popover/stories.js +84 -0
  236. package/esm/progress/index.js +2 -0
  237. package/esm/progress/progress.js +76 -0
  238. package/esm/progress/stories.js +114 -0
  239. package/esm/radio/index.js +7 -0
  240. package/esm/radio/radio-context.js +9 -0
  241. package/esm/radio/radio-description.js +30 -0
  242. package/esm/radio/radio-group.js +61 -0
  243. package/esm/radio/radio.js +123 -0
  244. package/esm/radio/stories.js +98 -0
  245. package/esm/radio/styles.js +41 -0
  246. package/esm/rating/index.js +2 -0
  247. package/esm/rating/rating-icon.js +20 -0
  248. package/esm/rating/rating.js +115 -0
  249. package/esm/rating/stories.js +72 -0
  250. package/esm/row/index.js +2 -0
  251. package/esm/row/row.js +60 -0
  252. package/esm/section/index.js +2 -0
  253. package/esm/section/section.js +30 -0
  254. package/esm/select/index.js +4 -0
  255. package/esm/select/select-context.js +9 -0
  256. package/esm/select/select-dropdown.js +41 -0
  257. package/esm/select/select-icon-clear.js +41 -0
  258. package/esm/select/select-icon.js +23 -0
  259. package/esm/select/select-input.js +34 -0
  260. package/esm/select/select-multiple-value.js +23 -0
  261. package/esm/select/select-option.js +100 -0
  262. package/esm/select/select.js +244 -0
  263. package/esm/select/stories.js +239 -0
  264. package/esm/select/styles.js +48 -0
  265. package/esm/shared/backdrop.js +77 -0
  266. package/esm/shared/css-transition.js +71 -0
  267. package/esm/shared/dropdown.js +109 -0
  268. package/esm/shared/ellipsis.js +15 -0
  269. package/esm/shared/expand.js +95 -0
  270. package/esm/shared/highlight.js +47 -0
  271. package/esm/slider/index.js +2 -0
  272. package/esm/slider/slider-dot.js +27 -0
  273. package/esm/slider/slider-mark.js +38 -0
  274. package/esm/slider/slider.js +163 -0
  275. package/esm/slider/stories.js +134 -0
  276. package/esm/slider/styles.js +27 -0
  277. package/esm/snippet/index.js +2 -0
  278. package/esm/snippet/snippet-icon.js +27 -0
  279. package/esm/snippet/snippet.js +100 -0
  280. package/esm/snippet/stories.js +133 -0
  281. package/esm/snippet/styles.js +58 -0
  282. package/esm/spacer/index.js +2 -0
  283. package/esm/spacer/spacer.js +28 -0
  284. package/esm/spacer/stories.js +54 -0
  285. package/esm/spinner/index.js +2 -0
  286. package/esm/spinner/spinner.js +46 -0
  287. package/esm/spinner/stories.js +13 -0
  288. package/esm/styled-jsx-server.es.js +5 -0
  289. package/esm/styled-jsx.es.js +757 -0
  290. package/esm/tabs/index.js +5 -0
  291. package/esm/tabs/stories.js +92 -0
  292. package/esm/tabs/tabs-context.js +8 -0
  293. package/esm/tabs/tabs-item.js +80 -0
  294. package/esm/tabs/tabs.js +151 -0
  295. package/esm/tag/index.js +2 -0
  296. package/esm/tag/stories.js +58 -0
  297. package/esm/tag/tag.js +86 -0
  298. package/esm/text/child.js +78 -0
  299. package/esm/text/index.js +2 -0
  300. package/esm/text/stories.js +104 -0
  301. package/esm/text/text.js +94 -0
  302. package/esm/textarea/index.js +2 -0
  303. package/esm/textarea/stories.js +104 -0
  304. package/esm/textarea/textarea.js +116 -0
  305. package/esm/themes/index.js +2 -0
  306. package/esm/themes/presets/dark.js +67 -0
  307. package/esm/themes/presets/default.js +67 -0
  308. package/esm/themes/presets/index.js +1 -0
  309. package/esm/themes/presets/shared.js +42 -0
  310. package/esm/themes/themes.js +89 -0
  311. package/esm/toggle/index.js +2 -0
  312. package/esm/toggle/stories.js +55 -0
  313. package/esm/toggle/styles.js +27 -0
  314. package/esm/toggle/toggle.js +82 -0
  315. package/esm/tooltip/helper.js +21 -0
  316. package/esm/tooltip/index.js +2 -0
  317. package/esm/tooltip/placement.js +160 -0
  318. package/esm/tooltip/stories.js +183 -0
  319. package/esm/tooltip/styles.js +18 -0
  320. package/esm/tooltip/tooltip-content.js +83 -0
  321. package/esm/tooltip/tooltip-icon.js +32 -0
  322. package/esm/tooltip/tooltip.js +132 -0
  323. package/esm/use-all-themes/all-themes-context.js +9 -0
  324. package/esm/use-all-themes/index.js +2 -0
  325. package/esm/use-body-scroll/index.js +2 -0
  326. package/esm/use-body-scroll/use-body-scroll.js +70 -0
  327. package/esm/use-classes/index.js +2 -0
  328. package/esm/use-classes/use-classes.js +41 -0
  329. package/esm/use-click-away/index.js +2 -0
  330. package/esm/use-click-away/use-click-away.js +22 -0
  331. package/esm/use-clipboard/index.js +2 -0
  332. package/esm/use-clipboard/use-clipboard.js +46 -0
  333. package/esm/use-current-state/index.js +2 -0
  334. package/esm/use-current-state/use-current-state.js +26 -0
  335. package/esm/use-input/index.js +2 -0
  336. package/esm/use-input/use-input.js +32 -0
  337. package/esm/use-keyboard/codes.js +97 -0
  338. package/esm/use-keyboard/helper.js +26 -0
  339. package/esm/use-keyboard/index.js +4 -0
  340. package/esm/use-keyboard/use-keyboard.js +79 -0
  341. package/esm/use-media-query/index.js +2 -0
  342. package/esm/use-media-query/use-media-query.js +90 -0
  343. package/esm/use-modal/index.js +2 -0
  344. package/esm/use-modal/use-modal.js +26 -0
  345. package/esm/use-scale/index.js +6 -0
  346. package/esm/use-scale/scale-context.js +37 -0
  347. package/esm/use-scale/utils.js +62 -0
  348. package/esm/use-scale/with-scale.js +114 -0
  349. package/esm/use-tabs/index.js +2 -0
  350. package/esm/use-tabs/use-tabs.js +24 -0
  351. package/esm/use-theme/index.js +2 -0
  352. package/esm/use-theme/theme-context.js +7 -0
  353. package/esm/use-toasts/helpers.js +72 -0
  354. package/esm/use-toasts/index.js +2 -0
  355. package/esm/use-toasts/toast-container.js +127 -0
  356. package/esm/use-toasts/toast-item.js +48 -0
  357. package/esm/use-toasts/use-toast.js +124 -0
  358. package/esm/utils/calculations.js +27 -0
  359. package/esm/utils/collections.js +138 -0
  360. package/esm/utils/color.js +43 -0
  361. package/esm/utils/layouts.js +82 -0
  362. package/esm/utils/prop-types.js +22 -0
  363. package/esm/utils/types.js +1 -0
  364. package/esm/utils/use-body-scroll.js +2 -0
  365. package/esm/utils/use-bolio-ui-context.js +27 -0
  366. package/esm/utils/use-click-anywhere.js +16 -0
  367. package/esm/utils/use-click-away.js +2 -0
  368. package/esm/utils/use-clipboard.js +2 -0
  369. package/esm/utils/use-context-state/create-bolio-ui-context.js +57 -0
  370. package/esm/utils/use-context-state/use-context-state.js +44 -0
  371. package/esm/utils/use-current-state.js +2 -0
  372. package/esm/utils/use-default-props.js +22 -0
  373. package/esm/utils/use-dom-observer.js +28 -0
  374. package/esm/utils/use-drag.js +75 -0
  375. package/esm/utils/use-portal.js +40 -0
  376. package/esm/utils/use-previous.js +11 -0
  377. package/esm/utils/use-real-shape.js +53 -0
  378. package/esm/utils/use-resize.js +21 -0
  379. package/esm/utils/use-ssr.js +20 -0
  380. package/esm/utils/use-warning.js +17 -0
  381. package/package.json +140 -0
@@ -0,0 +1,766 @@
1
+ 'use strict'
2
+
3
+ var React = require('react')
4
+
5
+ function _interopDefaultLegacy(e) {
6
+ return e && typeof e === 'object' && 'default' in e ? e : { default: e }
7
+ }
8
+
9
+ var React__default = /*#__PURE__*/ _interopDefaultLegacy(React)
10
+
11
+ var style$1 = {}
12
+
13
+ var stylesheetRegistry = {}
14
+
15
+ function hash(str) {
16
+ var hash = 5381,
17
+ i = str.length
18
+
19
+ while (i) {
20
+ hash = (hash * 33) ^ str.charCodeAt(--i)
21
+ }
22
+
23
+ /* JavaScript does bitwise operations (like XOR, above) on 32-bit signed
24
+ * integers. Since we want the results to be always positive, convert the
25
+ * signed int to an unsigned by doing an unsigned bitshift. */
26
+ return hash >>> 0
27
+ }
28
+
29
+ var stringHash = hash
30
+
31
+ var stylesheet = {}
32
+
33
+ ;(function (exports) {
34
+ exports.__esModule = true
35
+ exports['default'] = void 0
36
+
37
+ function _defineProperties(target, props) {
38
+ for (var i = 0; i < props.length; i++) {
39
+ var descriptor = props[i]
40
+ descriptor.enumerable = descriptor.enumerable || false
41
+ descriptor.configurable = true
42
+ if ('value' in descriptor) descriptor.writable = true
43
+ Object.defineProperty(target, descriptor.key, descriptor)
44
+ }
45
+ }
46
+
47
+ function _createClass(Constructor, protoProps, staticProps) {
48
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps)
49
+ if (staticProps) _defineProperties(Constructor, staticProps)
50
+ return Constructor
51
+ }
52
+
53
+ /*
54
+ Based on Glamor's sheet
55
+ https://github.com/threepointone/glamor/blob/667b480d31b3721a905021b26e1290ce92ca2879/src/sheet.js
56
+ */
57
+ var isProd =
58
+ typeof process !== 'undefined' &&
59
+ process.env &&
60
+ process.env.NODE_ENV === 'production'
61
+
62
+ var isString = function isString(o) {
63
+ return Object.prototype.toString.call(o) === '[object String]'
64
+ }
65
+
66
+ var StyleSheet = /*#__PURE__*/ (function () {
67
+ function StyleSheet(_temp) {
68
+ var _ref = _temp === void 0 ? {} : _temp,
69
+ _ref$name = _ref.name,
70
+ name = _ref$name === void 0 ? 'stylesheet' : _ref$name,
71
+ _ref$optimizeForSpeed = _ref.optimizeForSpeed,
72
+ optimizeForSpeed =
73
+ _ref$optimizeForSpeed === void 0 ? isProd : _ref$optimizeForSpeed,
74
+ _ref$isBrowser = _ref.isBrowser,
75
+ isBrowser =
76
+ _ref$isBrowser === void 0
77
+ ? typeof window !== 'undefined'
78
+ : _ref$isBrowser
79
+
80
+ invariant(isString(name), '`name` must be a string')
81
+ this._name = name
82
+ this._deletedRulePlaceholder = '#' + name + '-deleted-rule____{}'
83
+ invariant(
84
+ typeof optimizeForSpeed === 'boolean',
85
+ '`optimizeForSpeed` must be a boolean'
86
+ )
87
+ this._optimizeForSpeed = optimizeForSpeed
88
+ this._isBrowser = isBrowser
89
+ this._serverSheet = undefined
90
+ this._tags = []
91
+ this._injected = false
92
+ this._rulesCount = 0
93
+ var node =
94
+ this._isBrowser && document.querySelector('meta[property="csp-nonce"]')
95
+ this._nonce = node ? node.getAttribute('content') : null
96
+ }
97
+
98
+ var _proto = StyleSheet.prototype
99
+
100
+ _proto.setOptimizeForSpeed = function setOptimizeForSpeed(bool) {
101
+ invariant(
102
+ typeof bool === 'boolean',
103
+ '`setOptimizeForSpeed` accepts a boolean'
104
+ )
105
+ invariant(
106
+ this._rulesCount === 0,
107
+ 'optimizeForSpeed cannot be when rules have already been inserted'
108
+ )
109
+ this.flush()
110
+ this._optimizeForSpeed = bool
111
+ this.inject()
112
+ }
113
+
114
+ _proto.isOptimizeForSpeed = function isOptimizeForSpeed() {
115
+ return this._optimizeForSpeed
116
+ }
117
+
118
+ _proto.inject = function inject() {
119
+ var _this = this
120
+
121
+ invariant(!this._injected, 'sheet already injected')
122
+ this._injected = true
123
+
124
+ if (this._isBrowser && this._optimizeForSpeed) {
125
+ this._tags[0] = this.makeStyleTag(this._name)
126
+ this._optimizeForSpeed = 'insertRule' in this.getSheet()
127
+
128
+ if (!this._optimizeForSpeed) {
129
+ if (!isProd) {
130
+ console.warn(
131
+ 'StyleSheet: optimizeForSpeed mode not supported falling back to standard mode.'
132
+ )
133
+ }
134
+
135
+ this.flush()
136
+ this._injected = true
137
+ }
138
+
139
+ return
140
+ }
141
+
142
+ this._serverSheet = {
143
+ cssRules: [],
144
+ insertRule: function insertRule(rule, index) {
145
+ if (typeof index === 'number') {
146
+ _this._serverSheet.cssRules[index] = {
147
+ cssText: rule
148
+ }
149
+ } else {
150
+ _this._serverSheet.cssRules.push({
151
+ cssText: rule
152
+ })
153
+ }
154
+
155
+ return index
156
+ },
157
+ deleteRule: function deleteRule(index) {
158
+ _this._serverSheet.cssRules[index] = null
159
+ }
160
+ }
161
+ }
162
+
163
+ _proto.getSheetForTag = function getSheetForTag(tag) {
164
+ if (tag.sheet) {
165
+ return tag.sheet
166
+ } // this weirdness brought to you by firefox
167
+
168
+ for (var i = 0; i < document.styleSheets.length; i++) {
169
+ if (document.styleSheets[i].ownerNode === tag) {
170
+ return document.styleSheets[i]
171
+ }
172
+ }
173
+ }
174
+
175
+ _proto.getSheet = function getSheet() {
176
+ return this.getSheetForTag(this._tags[this._tags.length - 1])
177
+ }
178
+
179
+ _proto.insertRule = function insertRule(rule, index) {
180
+ invariant(isString(rule), '`insertRule` accepts only strings')
181
+
182
+ if (!this._isBrowser) {
183
+ if (typeof index !== 'number') {
184
+ index = this._serverSheet.cssRules.length
185
+ }
186
+
187
+ this._serverSheet.insertRule(rule, index)
188
+
189
+ return this._rulesCount++
190
+ }
191
+
192
+ if (this._optimizeForSpeed) {
193
+ var sheet = this.getSheet()
194
+
195
+ if (typeof index !== 'number') {
196
+ index = sheet.cssRules.length
197
+ } // this weirdness for perf, and chrome's weird bug
198
+ // https://stackoverflow.com/questions/20007992/chrome-suddenly-stopped-accepting-insertrule
199
+
200
+ try {
201
+ sheet.insertRule(rule, index)
202
+ } catch (error) {
203
+ if (!isProd) {
204
+ console.warn(
205
+ 'StyleSheet: illegal rule: \n\n' +
206
+ rule +
207
+ '\n\nSee https://stackoverflow.com/q/20007992 for more info'
208
+ )
209
+ }
210
+
211
+ return -1
212
+ }
213
+ } else {
214
+ var insertionPoint = this._tags[index]
215
+
216
+ this._tags.push(this.makeStyleTag(this._name, rule, insertionPoint))
217
+ }
218
+
219
+ return this._rulesCount++
220
+ }
221
+
222
+ _proto.replaceRule = function replaceRule(index, rule) {
223
+ if (this._optimizeForSpeed || !this._isBrowser) {
224
+ var sheet = this._isBrowser ? this.getSheet() : this._serverSheet
225
+
226
+ if (!rule.trim()) {
227
+ rule = this._deletedRulePlaceholder
228
+ }
229
+
230
+ if (!sheet.cssRules[index]) {
231
+ // @TBD Should we throw an error?
232
+ return index
233
+ }
234
+
235
+ sheet.deleteRule(index)
236
+
237
+ try {
238
+ sheet.insertRule(rule, index)
239
+ } catch (error) {
240
+ if (!isProd) {
241
+ console.warn(
242
+ 'StyleSheet: illegal rule: \n\n' +
243
+ rule +
244
+ '\n\nSee https://stackoverflow.com/q/20007992 for more info'
245
+ )
246
+ } // In order to preserve the indices we insert a deleteRulePlaceholder
247
+
248
+ sheet.insertRule(this._deletedRulePlaceholder, index)
249
+ }
250
+ } else {
251
+ var tag = this._tags[index]
252
+ invariant(tag, 'old rule at index `' + index + '` not found')
253
+ tag.textContent = rule
254
+ }
255
+
256
+ return index
257
+ }
258
+
259
+ _proto.deleteRule = function deleteRule(index) {
260
+ if (!this._isBrowser) {
261
+ this._serverSheet.deleteRule(index)
262
+
263
+ return
264
+ }
265
+
266
+ if (this._optimizeForSpeed) {
267
+ this.replaceRule(index, '')
268
+ } else {
269
+ var tag = this._tags[index]
270
+ invariant(tag, 'rule at index `' + index + '` not found')
271
+ tag.parentNode.removeChild(tag)
272
+ this._tags[index] = null
273
+ }
274
+ }
275
+
276
+ _proto.flush = function flush() {
277
+ this._injected = false
278
+ this._rulesCount = 0
279
+
280
+ if (this._isBrowser) {
281
+ this._tags.forEach(function (tag) {
282
+ return tag && tag.parentNode.removeChild(tag)
283
+ })
284
+
285
+ this._tags = []
286
+ } else {
287
+ // simpler on server
288
+ this._serverSheet.cssRules = []
289
+ }
290
+ }
291
+
292
+ _proto.cssRules = function cssRules() {
293
+ var _this2 = this
294
+
295
+ if (!this._isBrowser) {
296
+ return this._serverSheet.cssRules
297
+ }
298
+
299
+ return this._tags.reduce(function (rules, tag) {
300
+ if (tag) {
301
+ rules = rules.concat(
302
+ Array.prototype.map.call(
303
+ _this2.getSheetForTag(tag).cssRules,
304
+ function (rule) {
305
+ return rule.cssText === _this2._deletedRulePlaceholder
306
+ ? null
307
+ : rule
308
+ }
309
+ )
310
+ )
311
+ } else {
312
+ rules.push(null)
313
+ }
314
+
315
+ return rules
316
+ }, [])
317
+ }
318
+
319
+ _proto.makeStyleTag = function makeStyleTag(
320
+ name,
321
+ cssString,
322
+ relativeToTag
323
+ ) {
324
+ if (cssString) {
325
+ invariant(
326
+ isString(cssString),
327
+ 'makeStyleTag acceps only strings as second parameter'
328
+ )
329
+ }
330
+
331
+ var tag = document.createElement('style')
332
+ if (this._nonce) tag.setAttribute('nonce', this._nonce)
333
+ tag.type = 'text/css'
334
+ tag.setAttribute('data-' + name, '')
335
+
336
+ if (cssString) {
337
+ tag.appendChild(document.createTextNode(cssString))
338
+ }
339
+
340
+ var head = document.head || document.getElementsByTagName('head')[0]
341
+
342
+ if (relativeToTag) {
343
+ head.insertBefore(tag, relativeToTag)
344
+ } else {
345
+ head.appendChild(tag)
346
+ }
347
+
348
+ return tag
349
+ }
350
+
351
+ _createClass(StyleSheet, [
352
+ {
353
+ key: 'length',
354
+ get: function get() {
355
+ return this._rulesCount
356
+ }
357
+ }
358
+ ])
359
+
360
+ return StyleSheet
361
+ })()
362
+
363
+ exports['default'] = StyleSheet
364
+
365
+ function invariant(condition, message) {
366
+ if (!condition) {
367
+ throw new Error('StyleSheet: ' + message + '.')
368
+ }
369
+ }
370
+ })(stylesheet)
371
+ ;(function (exports) {
372
+ exports.__esModule = true
373
+ exports['default'] = void 0
374
+
375
+ var _stringHash = _interopRequireDefault(stringHash)
376
+
377
+ var _stylesheet = _interopRequireDefault(stylesheet)
378
+
379
+ function _interopRequireDefault(obj) {
380
+ return obj && obj.__esModule ? obj : { default: obj }
381
+ }
382
+
383
+ var sanitize = function sanitize(rule) {
384
+ return rule.replace(/\/style/gi, '\\/style')
385
+ }
386
+
387
+ var StyleSheetRegistry = /*#__PURE__*/ (function () {
388
+ function StyleSheetRegistry(_temp) {
389
+ var _ref = _temp === void 0 ? {} : _temp,
390
+ _ref$styleSheet = _ref.styleSheet,
391
+ styleSheet = _ref$styleSheet === void 0 ? null : _ref$styleSheet,
392
+ _ref$optimizeForSpeed = _ref.optimizeForSpeed,
393
+ optimizeForSpeed =
394
+ _ref$optimizeForSpeed === void 0 ? false : _ref$optimizeForSpeed,
395
+ _ref$isBrowser = _ref.isBrowser,
396
+ isBrowser =
397
+ _ref$isBrowser === void 0
398
+ ? typeof window !== 'undefined'
399
+ : _ref$isBrowser
400
+
401
+ this._sheet =
402
+ styleSheet ||
403
+ new _stylesheet['default']({
404
+ name: 'styled-jsx',
405
+ optimizeForSpeed: optimizeForSpeed
406
+ })
407
+
408
+ this._sheet.inject()
409
+
410
+ if (styleSheet && typeof optimizeForSpeed === 'boolean') {
411
+ this._sheet.setOptimizeForSpeed(optimizeForSpeed)
412
+
413
+ this._optimizeForSpeed = this._sheet.isOptimizeForSpeed()
414
+ }
415
+
416
+ this._isBrowser = isBrowser
417
+ this._fromServer = undefined
418
+ this._indices = {}
419
+ this._instancesCounts = {}
420
+ this.computeId = this.createComputeId()
421
+ this.computeSelector = this.createComputeSelector()
422
+ }
423
+
424
+ var _proto = StyleSheetRegistry.prototype
425
+
426
+ _proto.add = function add(props) {
427
+ var _this = this
428
+
429
+ if (undefined === this._optimizeForSpeed) {
430
+ this._optimizeForSpeed = Array.isArray(props.children)
431
+
432
+ this._sheet.setOptimizeForSpeed(this._optimizeForSpeed)
433
+
434
+ this._optimizeForSpeed = this._sheet.isOptimizeForSpeed()
435
+ }
436
+
437
+ if (this._isBrowser && !this._fromServer) {
438
+ this._fromServer = this.selectFromServer()
439
+ this._instancesCounts = Object.keys(this._fromServer).reduce(function (
440
+ acc,
441
+ tagName
442
+ ) {
443
+ acc[tagName] = 0
444
+ return acc
445
+ },
446
+ {})
447
+ }
448
+
449
+ var _this$getIdAndRules = this.getIdAndRules(props),
450
+ styleId = _this$getIdAndRules.styleId,
451
+ rules = _this$getIdAndRules.rules // Deduping: just increase the instances count.
452
+
453
+ if (styleId in this._instancesCounts) {
454
+ this._instancesCounts[styleId] += 1
455
+ return
456
+ }
457
+
458
+ var indices = rules
459
+ .map(function (rule) {
460
+ return _this._sheet.insertRule(rule)
461
+ }) // Filter out invalid rules
462
+ .filter(function (index) {
463
+ return index !== -1
464
+ })
465
+ this._indices[styleId] = indices
466
+ this._instancesCounts[styleId] = 1
467
+ }
468
+
469
+ _proto.remove = function remove(props) {
470
+ var _this2 = this
471
+
472
+ var _this$getIdAndRules2 = this.getIdAndRules(props),
473
+ styleId = _this$getIdAndRules2.styleId
474
+
475
+ invariant(
476
+ styleId in this._instancesCounts,
477
+ 'styleId: `' + styleId + '` not found'
478
+ )
479
+ this._instancesCounts[styleId] -= 1
480
+
481
+ if (this._instancesCounts[styleId] < 1) {
482
+ var tagFromServer = this._fromServer && this._fromServer[styleId]
483
+
484
+ if (tagFromServer) {
485
+ tagFromServer.parentNode.removeChild(tagFromServer)
486
+ delete this._fromServer[styleId]
487
+ } else {
488
+ this._indices[styleId].forEach(function (index) {
489
+ return _this2._sheet.deleteRule(index)
490
+ })
491
+
492
+ delete this._indices[styleId]
493
+ }
494
+
495
+ delete this._instancesCounts[styleId]
496
+ }
497
+ }
498
+
499
+ _proto.update = function update(props, nextProps) {
500
+ this.add(nextProps)
501
+ this.remove(props)
502
+ }
503
+
504
+ _proto.flush = function flush() {
505
+ this._sheet.flush()
506
+
507
+ this._sheet.inject()
508
+
509
+ this._fromServer = undefined
510
+ this._indices = {}
511
+ this._instancesCounts = {}
512
+ this.computeId = this.createComputeId()
513
+ this.computeSelector = this.createComputeSelector()
514
+ }
515
+
516
+ _proto.cssRules = function cssRules() {
517
+ var _this3 = this
518
+
519
+ var fromServer = this._fromServer
520
+ ? Object.keys(this._fromServer).map(function (styleId) {
521
+ return [styleId, _this3._fromServer[styleId]]
522
+ })
523
+ : []
524
+
525
+ var cssRules = this._sheet.cssRules()
526
+
527
+ return fromServer.concat(
528
+ Object.keys(this._indices)
529
+ .map(function (styleId) {
530
+ return [
531
+ styleId,
532
+ _this3._indices[styleId]
533
+ .map(function (index) {
534
+ return cssRules[index].cssText
535
+ })
536
+ .join(_this3._optimizeForSpeed ? '' : '\n')
537
+ ]
538
+ }) // filter out empty rules
539
+ .filter(function (rule) {
540
+ return Boolean(rule[1])
541
+ })
542
+ )
543
+ }
544
+ /**
545
+ * createComputeId
546
+ *
547
+ * Creates a function to compute and memoize a jsx id from a basedId and optionally props.
548
+ */
549
+
550
+ _proto.createComputeId = function createComputeId() {
551
+ var cache = {}
552
+ return function (baseId, props) {
553
+ if (!props) {
554
+ return 'jsx-' + baseId
555
+ }
556
+
557
+ var propsToString = String(props)
558
+ var key = baseId + propsToString // return `jsx-${hashString(`${baseId}-${propsToString}`)}`
559
+
560
+ if (!cache[key]) {
561
+ cache[key] =
562
+ 'jsx-' + (0, _stringHash['default'])(baseId + '-' + propsToString)
563
+ }
564
+
565
+ return cache[key]
566
+ }
567
+ }
568
+ /**
569
+ * createComputeSelector
570
+ *
571
+ * Creates a function to compute and memoize dynamic selectors.
572
+ */
573
+
574
+ _proto.createComputeSelector = function createComputeSelector(
575
+ selectoPlaceholderRegexp
576
+ ) {
577
+ if (selectoPlaceholderRegexp === void 0) {
578
+ selectoPlaceholderRegexp = /__jsx-style-dynamic-selector/g
579
+ }
580
+
581
+ var cache = {}
582
+ return function (id, css) {
583
+ // Sanitize SSR-ed CSS.
584
+ // Client side code doesn't need to be sanitized since we use
585
+ // document.createTextNode (dev) and the CSSOM api sheet.insertRule (prod).
586
+ if (!this._isBrowser) {
587
+ css = sanitize(css)
588
+ }
589
+
590
+ var idcss = id + css
591
+
592
+ if (!cache[idcss]) {
593
+ cache[idcss] = css.replace(selectoPlaceholderRegexp, id)
594
+ }
595
+
596
+ return cache[idcss]
597
+ }
598
+ }
599
+
600
+ _proto.getIdAndRules = function getIdAndRules(props) {
601
+ var _this4 = this
602
+
603
+ var css = props.children,
604
+ dynamic = props.dynamic,
605
+ id = props.id
606
+
607
+ if (dynamic) {
608
+ var styleId = this.computeId(id, dynamic)
609
+ return {
610
+ styleId: styleId,
611
+ rules: Array.isArray(css)
612
+ ? css.map(function (rule) {
613
+ return _this4.computeSelector(styleId, rule)
614
+ })
615
+ : [this.computeSelector(styleId, css)]
616
+ }
617
+ }
618
+
619
+ return {
620
+ styleId: this.computeId(id),
621
+ rules: Array.isArray(css) ? css : [css]
622
+ }
623
+ }
624
+ /**
625
+ * selectFromServer
626
+ *
627
+ * Collects style tags from the document with id __jsx-XXX
628
+ */
629
+
630
+ _proto.selectFromServer = function selectFromServer() {
631
+ var elements = Array.prototype.slice.call(
632
+ document.querySelectorAll('[id^="__jsx-"]')
633
+ )
634
+ return elements.reduce(function (acc, element) {
635
+ var id = element.id.slice(2)
636
+ acc[id] = element
637
+ return acc
638
+ }, {})
639
+ }
640
+
641
+ return StyleSheetRegistry
642
+ })()
643
+
644
+ exports['default'] = StyleSheetRegistry
645
+
646
+ function invariant(condition, message) {
647
+ if (!condition) {
648
+ throw new Error('StyleSheetRegistry: ' + message + '.')
649
+ }
650
+ }
651
+ })(stylesheetRegistry)
652
+ ;(function (exports) {
653
+ exports.__esModule = true
654
+ exports['default'] = JSXStyle
655
+ exports.flush = flush
656
+
657
+ var _react = React__default['default']
658
+
659
+ var _stylesheetRegistry = _interopRequireDefault(stylesheetRegistry)
660
+
661
+ function _interopRequireDefault(obj) {
662
+ return obj && obj.__esModule ? obj : { default: obj }
663
+ }
664
+
665
+ var styleSheetRegistry = new _stylesheetRegistry['default']()
666
+
667
+ function JSXStyle(props) {
668
+ if (typeof window === 'undefined') {
669
+ styleSheetRegistry.add(props)
670
+ return null
671
+ }
672
+
673
+ ;(0, _react.useLayoutEffect)(
674
+ function () {
675
+ styleSheetRegistry.add(props)
676
+ return function () {
677
+ styleSheetRegistry.remove(props)
678
+ } // props.children can be string[], will be striped since id is identical
679
+ },
680
+ [props.id, String(props.dynamic)]
681
+ )
682
+ return null
683
+ }
684
+
685
+ JSXStyle.dynamic = function (info) {
686
+ return info
687
+ .map(function (tagInfo) {
688
+ var baseId = tagInfo[0]
689
+ var props = tagInfo[1]
690
+ return styleSheetRegistry.computeId(baseId, props)
691
+ })
692
+ .join(' ')
693
+ }
694
+
695
+ function flush() {
696
+ var cssRules = styleSheetRegistry.cssRules()
697
+ styleSheetRegistry.flush()
698
+ return cssRules
699
+ }
700
+ })(style$1)
701
+
702
+ var style = style$1.default || style$1
703
+ style.flush = style$1.flush
704
+
705
+ var server$1 = {}
706
+
707
+ ;(function (exports) {
708
+ exports.__esModule = true
709
+ exports['default'] = flushToReact
710
+ exports.flushToHTML = flushToHTML
711
+
712
+ var _react = _interopRequireDefault(React__default['default'])
713
+
714
+ var _style = style$1.default || style$1
715
+ _style.flush = style$1.flush
716
+
717
+ function _interopRequireDefault(obj) {
718
+ return obj && obj.__esModule ? obj : { default: obj }
719
+ }
720
+
721
+ function flushToReact(options) {
722
+ if (options === void 0) {
723
+ options = {}
724
+ }
725
+
726
+ return (0, _style.flush)().map(function (args) {
727
+ var id = args[0]
728
+ var css = args[1]
729
+ return _react['default'].createElement('style', {
730
+ id: '__' + id,
731
+ // Avoid warnings upon render with a key
732
+ key: '__' + id,
733
+ nonce: options.nonce ? options.nonce : undefined,
734
+ dangerouslySetInnerHTML: {
735
+ __html: css
736
+ }
737
+ })
738
+ })
739
+ }
740
+
741
+ function flushToHTML(options) {
742
+ if (options === void 0) {
743
+ options = {}
744
+ }
745
+
746
+ return (0, _style.flush)().reduce(function (html, args) {
747
+ var id = args[0]
748
+ var css = args[1]
749
+ html +=
750
+ '<style id="__' +
751
+ id +
752
+ '"' +
753
+ (options.nonce ? ' nonce="' + options.nonce + '"' : '') +
754
+ '>' +
755
+ css +
756
+ '</style>'
757
+ return html
758
+ }, '')
759
+ }
760
+ })(server$1)
761
+
762
+ var server = server$1.default || server$1
763
+ server.flushToHTML = server$1.flushToHTML
764
+
765
+ exports.server = server
766
+ exports.style = style