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