@startlibs/utils 1.1.1 → 1.2.0-rc.1

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 (87) hide show
  1. package/lib/animationKeyframes.mjs +11 -0
  2. package/lib/animationKeyframes.mjs.map +1 -0
  3. package/lib/fixMediaQuery.mjs +43 -17
  4. package/lib/fixMediaQuery.mjs.map +1 -1
  5. package/lib/fixMediaText.mjs +16 -0
  6. package/lib/fixMediaText.mjs.map +1 -0
  7. package/lib/formatDate.mjs +1 -1
  8. package/lib/formatDate.mjs.map +1 -1
  9. package/lib/index.cjs +212 -100
  10. package/lib/index.cjs.map +1 -1
  11. package/lib/index.mjs +3 -1
  12. package/lib/index.mjs.map +1 -1
  13. package/lib/insertKeyframes.mjs +68 -0
  14. package/lib/insertKeyframes.mjs.map +1 -0
  15. package/lib/styled.mjs +22 -141
  16. package/lib/styled.mjs.map +1 -1
  17. package/lib/styledShared.mjs +125 -0
  18. package/lib/styledShared.mjs.map +1 -0
  19. package/lib/timerUtils.mjs +0 -1
  20. package/lib/timerUtils.mjs.map +1 -1
  21. package/lib/yakDomTag.mjs +44 -0
  22. package/lib/yakDomTag.mjs.map +1 -0
  23. package/lib-yak/ActionUtils.mjs +117 -0
  24. package/lib-yak/ActionUtils.mjs.map +1 -0
  25. package/lib-yak/FetchUtils.mjs +100 -0
  26. package/lib-yak/FetchUtils.mjs.map +1 -0
  27. package/lib-yak/animationKeyframes.mjs +31 -0
  28. package/lib-yak/animationKeyframes.mjs.map +1 -0
  29. package/lib-yak/createPressEvent.mjs +74 -0
  30. package/lib-yak/createPressEvent.mjs.map +1 -0
  31. package/lib-yak/fixMediaQuery.mjs +90 -0
  32. package/lib-yak/fixMediaQuery.mjs.map +1 -0
  33. package/lib-yak/fixMediaText.mjs +16 -0
  34. package/lib-yak/fixMediaText.mjs.map +1 -0
  35. package/lib-yak/formatDate.mjs +110 -0
  36. package/lib-yak/formatDate.mjs.map +1 -0
  37. package/lib-yak/formatUtils.mjs +64 -0
  38. package/lib-yak/formatUtils.mjs.map +1 -0
  39. package/lib-yak/getClosestOffsetScroll.mjs +15 -0
  40. package/lib-yak/getClosestOffsetScroll.mjs.map +1 -0
  41. package/lib-yak/hooks/useEventListener.mjs +27 -0
  42. package/lib-yak/hooks/useEventListener.mjs.map +1 -0
  43. package/lib-yak/index.mjs +21 -0
  44. package/lib-yak/index.mjs.map +1 -0
  45. package/lib-yak/insertKeyframes.mjs +68 -0
  46. package/lib-yak/insertKeyframes.mjs.map +1 -0
  47. package/lib-yak/lodashUtils.mjs +131 -0
  48. package/lib-yak/lodashUtils.mjs.map +1 -0
  49. package/lib-yak/promiseUtils.mjs +92 -0
  50. package/lib-yak/promiseUtils.mjs.map +1 -0
  51. package/lib-yak/reactUtils.mjs +12 -0
  52. package/lib-yak/reactUtils.mjs.map +1 -0
  53. package/lib-yak/reduceUtils.mjs +14 -0
  54. package/lib-yak/reduceUtils.mjs.map +1 -0
  55. package/lib-yak/smoothScroll.mjs +59 -0
  56. package/lib-yak/smoothScroll.mjs.map +1 -0
  57. package/lib-yak/styled.mjs +23 -0
  58. package/lib-yak/styled.mjs.map +1 -0
  59. package/lib-yak/styledShared.mjs +129 -0
  60. package/lib-yak/styledShared.mjs.map +1 -0
  61. package/lib-yak/timeUtils.mjs +81 -0
  62. package/lib-yak/timeUtils.mjs.map +1 -0
  63. package/lib-yak/timerUtils.mjs +10 -0
  64. package/lib-yak/timerUtils.mjs.map +1 -0
  65. package/lib-yak/utils.mjs +386 -0
  66. package/lib-yak/utils.mjs.map +1 -0
  67. package/lib-yak/wrapLazy.mjs +132 -0
  68. package/lib-yak/wrapLazy.mjs.map +1 -0
  69. package/lib-yak/yakDomTag.mjs +44 -0
  70. package/lib-yak/yakDomTag.mjs.map +1 -0
  71. package/package.json +14 -3
  72. package/src/animationKeyframes.js +10 -0
  73. package/src/animationKeyframes.test.mjs +75 -0
  74. package/src/animationKeyframes.yak.js +30 -0
  75. package/src/fixMediaQuery.js +40 -19
  76. package/src/fixMediaText.js +18 -0
  77. package/src/fixMediaText.test.mjs +60 -0
  78. package/src/formatDate.js +1 -1
  79. package/src/index.js +1 -0
  80. package/src/insertKeyframes.js +73 -0
  81. package/src/insertKeyframes.test.mjs +144 -0
  82. package/src/styled.js +5 -97
  83. package/src/styled.yak.js +30 -0
  84. package/src/styledShared.js +96 -0
  85. package/src/timerUtils.jsx +0 -2
  86. package/src/yakDomTag.jsx +42 -0
  87. package/src/yakDomTag.test.mjs +49 -0
package/lib/index.cjs CHANGED
@@ -12,16 +12,16 @@ var _defineProperty = require('@babel/runtime/helpers/defineProperty');
12
12
  var _isPlainObject = require('lodash/fp/isPlainObject');
13
13
  var _fromPairs = require('lodash/fp/fromPairs');
14
14
  var _isFinite = require('lodash/fp/isFinite');
15
- var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
16
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
17
15
  var _find = require('lodash/fp/find');
18
- var _reverse = require('lodash/fp/reverse');
19
16
  var _isEqual = require('lodash/fp/isEqual');
20
- var _isFunction = require('lodash/fp/isFunction');
21
17
  var _get = require('lodash/fp/get');
18
+ var _isFunction = require('lodash/fp/isFunction');
19
+ var styled = require('styled-components');
20
+ var _taggedTemplateLiteral = require('@babel/runtime/helpers/taggedTemplateLiteral');
21
+ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
22
+ var _reverse = require('lodash/fp/reverse');
22
23
  var _unset = require('lodash/fp/unset');
23
24
  var polished = require('polished');
24
- var styled = require('styled-components');
25
25
  var createEmotion = require('create-emotion');
26
26
  var _flow = require('lodash/fp/flow');
27
27
  var _without = require('lodash/fp/without');
@@ -55,15 +55,15 @@ var _defineProperty__default = /*#__PURE__*/_interopDefault(_defineProperty);
55
55
  var _isPlainObject__default = /*#__PURE__*/_interopDefault(_isPlainObject);
56
56
  var _fromPairs__default = /*#__PURE__*/_interopDefault(_fromPairs);
57
57
  var _isFinite__default = /*#__PURE__*/_interopDefault(_isFinite);
58
- var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefault(_taggedTemplateLiteral);
59
- var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWithoutProperties);
60
58
  var _find__default = /*#__PURE__*/_interopDefault(_find);
61
- var _reverse__default = /*#__PURE__*/_interopDefault(_reverse);
62
59
  var _isEqual__default = /*#__PURE__*/_interopDefault(_isEqual);
63
- var _isFunction__default = /*#__PURE__*/_interopDefault(_isFunction);
64
60
  var _get__default = /*#__PURE__*/_interopDefault(_get);
65
- var _unset__default = /*#__PURE__*/_interopDefault(_unset);
61
+ var _isFunction__default = /*#__PURE__*/_interopDefault(_isFunction);
66
62
  var styled__default = /*#__PURE__*/_interopDefault(styled);
63
+ var _taggedTemplateLiteral__default = /*#__PURE__*/_interopDefault(_taggedTemplateLiteral);
64
+ var _objectWithoutProperties__default = /*#__PURE__*/_interopDefault(_objectWithoutProperties);
65
+ var _reverse__default = /*#__PURE__*/_interopDefault(_reverse);
66
+ var _unset__default = /*#__PURE__*/_interopDefault(_unset);
67
67
  var createEmotion__default = /*#__PURE__*/_interopDefault(createEmotion);
68
68
  var _flow__default = /*#__PURE__*/_interopDefault(_flow);
69
69
  var _without__default = /*#__PURE__*/_interopDefault(_without);
@@ -239,7 +239,23 @@ const smoothScroll = function (el) {
239
239
  step();
240
240
  };
241
241
 
242
+ // Soma a largura da scrollbar aos limites de largura de um mediaText.
243
+ // Reconhece a forma antiga (`max-width: 600px`, `min-width: 37.5em`, que o sc emite) e a
244
+ // sintaxe de intervalo (`width <= 600px`, `width < 600px`, `600px <= width`,
245
+ // `400px < width < 600px`), que o Chromium devolve para o CSS estático do yak.
246
+ // Sem lookbehind de propósito: é erro de sintaxe no Safari < 16.4, e o browserslist do pacote
247
+ // ainda promete Safari 11. O caractere antes de `width` é capturado e devolvido igual, só pra
248
+ // não casar o `width` de `device-width`.
249
+ const LEGACY_OR_WIDTH_FIRST = /(m(?:in|ax)-width\s*:\s*|(?:^|[^-\w])width\s*[<>]=?\s*)([\d.]+)(px|em)/gi;
250
+ const VALUE_FIRST = /([\d.]+)(px|em)(\s*[<>]=?\s*width)(?![-\w])/gi;
251
+ function fixMediaText(mediaText, scrollWidth, fontSize) {
252
+ const grow = (value, unit) => unit.toLowerCase() === 'px' ? parseFloat(value) + scrollWidth + unit : (parseFloat(value) * fontSize + scrollWidth) / fontSize + unit;
253
+ return mediaText.replace(LEGACY_OR_WIDTH_FIRST, (match, prefix, value, unit) => prefix + grow(value, unit)).replace(VALUE_FIRST, (match, value, unit, suffix) => grow(value, unit) + suffix);
254
+ }
255
+
242
256
  let fixed = false;
257
+ // Each rule may only get the scrollbar width added once, even if its sheet is seen again.
258
+ const patched = new WeakSet();
243
259
  const scrollWidth = function () {
244
260
  if (!window.document) return 0;
245
261
  const html = document.documentElement;
@@ -252,25 +268,47 @@ const scrollWidth = function () {
252
268
  const fixMediaQueryFn = function () {
253
269
  const fontSize = parseFloat(window.getComputedStyle(document.body).getPropertyValue('font-size'));
254
270
  if (scrollWidth > 0) {
255
- [].slice.call(document.styleSheets).filter(styleSheet => isValidExternal(styleSheet) || isInline(styleSheet)).forEach(stylesheet => {
256
- try {
257
- [].slice.call(stylesheet.cssRules || stylesheet.media).filter(rule => rule.constructor === window.CSSMediaRule).forEach(rule => {
258
- rule.media.mediaText = rule.media.mediaText.replace(/m(in|ax)-width:\s*(\d|\.)+(px|em)/gi, function (strA) {
259
- if (strA.match('px')) {
260
- return strA.replace(/\d+px/gi, function (strB) {
261
- return parseInt(strB, 10) + scrollWidth + 'px';
262
- });
263
- } else {
264
- return strA.replace(/\d.+?em/gi, function (strB) {
265
- return (parseFloat(strB) * fontSize + scrollWidth) / fontSize + 'em';
266
- });
267
- }
268
- });
269
- });
270
- } catch (e) {}
271
- });
271
+ [].slice.call(document.styleSheets).forEach(fixStylesheet);
272
+ watchLateStylesheets();
272
273
  }
273
274
  fixed = true;
275
+ function fixStylesheet(stylesheet) {
276
+ if (!stylesheet || patched.has(stylesheet) || !(isValidExternal(stylesheet) || isInline(stylesheet))) {
277
+ return;
278
+ }
279
+ try {
280
+ [].slice.call(stylesheet.cssRules).filter(rule => rule.constructor === window.CSSMediaRule).forEach(rule => {
281
+ rule.media.mediaText = fixMediaText(rule.media.mediaText, scrollWidth, fontSize);
282
+ });
283
+ patched.add(stylesheet);
284
+ } catch (e) {}
285
+ }
286
+
287
+ // Lazy routes add <link>s, and Vite dev and HMR add or rewrite <style>s, after the first pass.
288
+ function watchLateStylesheets() {
289
+ new MutationObserver(mutations => mutations.forEach(_ref => {
290
+ let target = _ref.target,
291
+ addedNodes = _ref.addedNodes;
292
+ const owner = target.nodeType === Node.TEXT_NODE ? target.parentNode : target;
293
+ if (owner && owner.nodeName === 'STYLE') {
294
+ fixStylesheet(owner.sheet);
295
+ }
296
+ [].slice.call(addedNodes).forEach(node => {
297
+ if (node.nodeName === 'STYLE') {
298
+ fixStylesheet(node.sheet);
299
+ }
300
+ if (node.nodeName === 'LINK' && node.rel === 'stylesheet') {
301
+ // Not parsed yet when added; `load` also fires again if its href changes.
302
+ node.addEventListener('load', () => fixStylesheet(node.sheet));
303
+ fixStylesheet(node.sheet);
304
+ }
305
+ });
306
+ })).observe(document.head, {
307
+ childList: true,
308
+ subtree: true,
309
+ characterData: true
310
+ });
311
+ }
274
312
  function sameOrigin(url) {
275
313
  const loc = window.location,
276
314
  a = document.createElement('a');
@@ -773,6 +811,13 @@ let getFetcher = async (url, json, options) => getFetcherWithResponse(url, json,
773
811
  const formFetchWithResponse = (url, options) => (values, meta) => postFetcherWithResponse(callIfFunction(url, meta, values), values, callIfFunction(options, meta, values));
774
812
  const formFetch = (url, options) => (values, meta) => postFetcher(callIfFunction(url, meta, values), values, callIfFunction(options, meta, values));
775
813
 
814
+ // Saída sc (lib/): o keyframes do emotion, como sempre foi. A saída yak (lib-yak/) usa
815
+ // animationKeyframes.yak.js no lugar deste arquivo (ver tools/rollup.base.mjs).
816
+ const emotion = createEmotion__default["default"]({
817
+ nonce: typeof document !== 'undefined' && (document.querySelector('meta[property="csp-nonce"]') || {}).content || 'animation_nonce'
818
+ });
819
+ const animationKeyframes = emotion.keyframes;
820
+
776
821
  const moveElement = _curry__default["default"]((from, to, list) => {
777
822
  const el = list[from];
778
823
  const without = _pullAt__default["default"](from, list);
@@ -936,6 +981,60 @@ const customTheme = type => function () {
936
981
  let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
937
982
  return _get__default["default"](["theme", "startlibs", type], props) || '';
938
983
  };
984
+ const vheight = (strings, size) => {
985
+ const propType = strings[0];
986
+ const calc = (strings[1] || "").replace(";", "").trim();
987
+ return "\n ".concat(propType, " ").concat(calc ? "calc(".concat(size, "vh ").concat(calc, ")") : "".concat(size, "vh"), ";\n ").concat(propType, " ").concat(calc ? "calc(calc(var(--vh, 1vh) * ".concat(size, ") ").concat(calc, ")") : "calc(var(--vh, 1vh) * ".concat(size, ")"), ";\n ");
988
+ };
989
+ const getFrameOffset = (i, total) => Math.round(i * 100 / (total - 1));
990
+ const oneWayAnimation = function () {
991
+ for (var _len = arguments.length, frames = new Array(_len), _key = 0; _key < _len; _key++) {
992
+ frames[_key] = arguments[_key];
993
+ }
994
+ return animationKeyframes(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n ", ""])), frames.map((frame, i) => !frame ? '' : "".concat(getFrameOffset(i, frames.length), "% {\n ").concat(frame, "\n }")));
995
+ };
996
+ const twoWayAnimation = function () {
997
+ for (var _len2 = arguments.length, frames = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
998
+ frames[_key2] = arguments[_key2];
999
+ }
1000
+ return [frames, _reverse__default["default"](frames)].map(frames => oneWayAnimation(...frames));
1001
+ };
1002
+ const animationTiming = props => function () {
1003
+ for (var _len3 = arguments.length, animations = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
1004
+ animations[_key3] = arguments[_key3];
1005
+ }
1006
+ return animations.filter(_ => _).map(_ => _ + ' ' + props).join(',');
1007
+ };
1008
+ const identityTranslateFrames = oneWayAnimation('transform: translateY(0);', 'transform: translateY(0);');
1009
+ const identityOpacityFrames = oneWayAnimation('opacity: 1;', 'opacity:1;');
1010
+ function testSinglePath(props, path) {
1011
+ if (typeof path === 'string') {
1012
+ return !!_s.get(path, props);
1013
+ } else if (typeof path === 'number') {
1014
+ return !!props[path];
1015
+ } else {
1016
+ return false;
1017
+ }
1018
+ }
1019
+
1020
+ // ifProp na forma antiga (valor pronto, não template): devolve pass ou fail
1021
+ const ifPropValue = (path, pass, fail) => function () {
1022
+ let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1023
+ let result = false;
1024
+ if (Array.isArray(path)) {
1025
+ result = path.every(p => testSinglePath(props, p));
1026
+ } else if (typeof path === 'object') {
1027
+ result = !Object.entries(path).find(_ref3 => {
1028
+ let _ref4 = _slicedToArray__default["default"](_ref3, 2),
1029
+ k = _ref4[0],
1030
+ v = _ref4[1];
1031
+ return props[k] !== v;
1032
+ });
1033
+ } else {
1034
+ result = testSinglePath(props, path);
1035
+ }
1036
+ return result ? pass : fail;
1037
+ };
939
1038
 
940
1039
  /**
941
1040
  * Returns `pass` if prop is truthy. Otherwise returns `fail`
@@ -954,23 +1053,7 @@ const customTheme = type => function () {
954
1053
  const ifProp = (path, pass, fail) => {
955
1054
  if (pass && !_isFunction__default["default"](pass)) {
956
1055
  // old version
957
- return function () {
958
- let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
959
- let result = false;
960
- if (Array.isArray(path)) {
961
- result = path.every(p => testSinglePath(props, p));
962
- } else if (typeof path === 'object') {
963
- result = !Object.entries(path).find(_ref3 => {
964
- let _ref4 = _slicedToArray__default["default"](_ref3, 2),
965
- k = _ref4[0],
966
- v = _ref4[1];
967
- return props[k] !== v;
968
- });
969
- } else {
970
- result = testSinglePath(props, path);
971
- }
972
- return result ? pass : fail;
973
- };
1056
+ return ifPropValue(path, pass, fail);
974
1057
  } else {
975
1058
  return function () {
976
1059
  for (var _len = arguments.length, argsTrue = new Array(_len), _key = 0; _key < _len; _key++) {
@@ -992,10 +1075,10 @@ const ifPropEquals = (path, str) => ifProp(path, _isEqual__default["default"](st
992
1075
  const ifNotProp = path => ifProp(path, v => !v);
993
1076
  const checkCustomScreenWidth = (sizeParis, customWidth) => {
994
1077
  const currentWidth = callIfFunction(customWidth);
995
- return !sizeParis.find(_ref5 => {
996
- let _ref6 = _slicedToArray__default["default"](_ref5, 2),
997
- size = _ref6[0],
998
- type = _ref6[1];
1078
+ return !sizeParis.find(_ref => {
1079
+ let _ref2 = _slicedToArray__default["default"](_ref, 2),
1080
+ size = _ref2[0],
1081
+ type = _ref2[1];
999
1082
  if (type === "min-width") {
1000
1083
  return currentWidth < size;
1001
1084
  }
@@ -1014,10 +1097,10 @@ const media = function () {
1014
1097
  }
1015
1098
  return styled.css(["", ""], props => {
1016
1099
  var _props$theme, _props$theme2;
1017
- return (_props$theme = props.theme) !== null && _props$theme !== void 0 && _props$theme.overrideMediaWidth ? checkCustomScreenWidth(sizePairs, (_props$theme2 = props.theme) === null || _props$theme2 === void 0 ? void 0 : _props$theme2.overrideMediaWidth) ? styled.css(...args) : "" : styled.css(["@media ", "{", "}"], sizePairs.map(_ref7 => {
1018
- let _ref8 = _slicedToArray__default["default"](_ref7, 2),
1019
- size = _ref8[0],
1020
- type = _ref8[1];
1100
+ return (_props$theme = props.theme) !== null && _props$theme !== void 0 && _props$theme.overrideMediaWidth ? checkCustomScreenWidth(sizePairs, (_props$theme2 = props.theme) === null || _props$theme2 === void 0 ? void 0 : _props$theme2.overrideMediaWidth) ? styled.css(...args) : "" : styled.css(["@media ", "{", "}"], sizePairs.map(_ref3 => {
1101
+ let _ref4 = _slicedToArray__default["default"](_ref3, 2),
1102
+ size = _ref4[0],
1103
+ type = _ref4[1];
1021
1104
  return "(".concat(type, ": ").concat(size + scrollWidth, "px)");
1022
1105
  }).join(' and '), styled.css(...args));
1023
1106
  });
@@ -1028,51 +1111,13 @@ media.between = (min, max) => media([min, 'min-width'], [max, 'max-width']);
1028
1111
  media.max = n => media([n, 'max-width']);
1029
1112
  media.min = n => media([n, 'min-width']);
1030
1113
  media.desktop = media([601, 'min-width']);
1031
- const vheight = (strings, size) => {
1032
- const propType = strings[0];
1033
- const calc = (strings[1] || "").replace(";", "").trim();
1034
- return "\n ".concat(propType, " ").concat(calc ? "calc(".concat(size, "vh ").concat(calc, ")") : "".concat(size, "vh"), ";\n ").concat(propType, " ").concat(calc ? "calc(calc(var(--vh, 1vh) * ".concat(size, ") ").concat(calc, ")") : "calc(var(--vh, 1vh) * ".concat(size, ")"), ";\n ");
1035
- };
1036
- function testSinglePath(props, path) {
1037
- if (typeof path === 'string') {
1038
- return !!_s.get(path, props);
1039
- } else if (typeof path === 'number') {
1040
- return !!props[path];
1041
- } else {
1042
- return false;
1043
- }
1044
- }
1045
- const getFrameOffset = (i, total) => Math.round(i * 100 / (total - 1));
1046
- const emotion = createEmotion__default["default"]({
1047
- nonce: typeof document !== 'undefined' && (document.querySelector('meta[property="csp-nonce"]') || {}).content || 'animation_nonce'
1048
- });
1049
- const oneWayAnimation = function () {
1050
- for (var _len5 = arguments.length, frames = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
1051
- frames[_key5] = arguments[_key5];
1052
- }
1053
- return emotion.keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral__default["default"](["\n ", ""])), frames.map((frame, i) => !frame ? '' : "".concat(getFrameOffset(i, frames.length), "% {\n ").concat(frame, "\n }")));
1054
- };
1055
- const twoWayAnimation = function () {
1056
- for (var _len6 = arguments.length, frames = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
1057
- frames[_key6] = arguments[_key6];
1058
- }
1059
- return [frames, _reverse__default["default"](frames)].map(frames => oneWayAnimation(...frames));
1060
- };
1061
- const animationTiming = props => function () {
1062
- for (var _len7 = arguments.length, animations = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
1063
- animations[_key7] = arguments[_key7];
1064
- }
1065
- return animations.filter(_ => _).map(_ => _ + ' ' + props).join(',');
1066
- };
1067
- const identityTranslateFrames = oneWayAnimation('transform: translateY(0);', 'transform: translateY(0);');
1068
- const identityOpacityFrames = oneWayAnimation('opacity: 1;', 'opacity:1;');
1069
- const styledExtend = _ref9 => {
1070
- let target = _ref9.target,
1071
- componentStyle = _ref9.componentStyle;
1114
+ const styledExtend = _ref5 => {
1115
+ let target = _ref5.target,
1116
+ componentStyle = _ref5.componentStyle;
1072
1117
  return function () {
1073
1118
  const wasStatic = !_find__default["default"](_isFunction__default["default"], componentStyle.rules);
1074
- for (var _len8 = arguments.length, template = new Array(_len8), _key8 = 0; _key8 < _len8; _key8++) {
1075
- template[_key8] = arguments[_key8];
1119
+ for (var _len5 = arguments.length, template = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
1120
+ template[_key5] = arguments[_key5];
1076
1121
  }
1077
1122
  const v = /*#__PURE__*/styled__default["default"](target)(...template, ...(wasStatic ? [] : [() => ""]));
1078
1123
  v.componentStyle.rules = [...componentStyle.rules, ...v.componentStyle.rules];
@@ -1080,18 +1125,84 @@ const styledExtend = _ref9 => {
1080
1125
  };
1081
1126
  };
1082
1127
  const printerMedia = function () {
1083
- for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
1084
- args[_key9] = arguments[_key9];
1128
+ for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
1129
+ args[_key6] = arguments[_key6];
1085
1130
  }
1086
1131
  return props => props.theme.printMode ? styled.css(...args) : styled.css(["@media print{", "}"], styled.css(...args));
1087
1132
  };
1088
1133
  const notPrinterMedia = function () {
1089
- for (var _len0 = arguments.length, args = new Array(_len0), _key0 = 0; _key0 < _len0; _key0++) {
1090
- args[_key0] = arguments[_key0];
1134
+ for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
1135
+ args[_key7] = arguments[_key7];
1091
1136
  }
1092
1137
  return props => props.theme.printMode ? '' : styled.css(["@media screen{", "}"], styled.css(...args));
1093
1138
  };
1094
1139
 
1140
+ // Registra um @keyframes pelo CSSOM, sem criar <style> na página: funciona com CSP
1141
+ // `style-src 'self'` sem nonce. Ordem de tentativa:
1142
+ // 1. uma folha construída (new CSSStyleSheet) em document.adoptedStyleSheets;
1143
+ // 2. browser sem folha construída: insertRule numa folha do próprio site já carregada
1144
+ // (de preferência um <link>, que nenhum runtime de CSS-in-JS gerencia);
1145
+ // 3. nenhuma das duas: <style> com o nonce do <meta property="csp-nonce">, se houver.
1146
+ // Cada nome entra uma vez só; quem chama garante que nome igual é conteúdo igual.
1147
+ const inserted = new Set();
1148
+ let adoptedSheet = null;
1149
+ let pageSheet = null;
1150
+ const canAdoptSheets = () => typeof CSSStyleSheet !== 'undefined' && 'replaceSync' in CSSStyleSheet.prototype && 'adoptedStyleSheets' in document;
1151
+
1152
+ // Outro código pode reatribuir document.adoptedStyleSheets e tirar a folha da lista: recoloca.
1153
+ const getAdoptedSheet = () => {
1154
+ if (!adoptedSheet) adoptedSheet = new CSSStyleSheet();
1155
+ if (document.adoptedStyleSheets.indexOf(adoptedSheet) < 0) {
1156
+ document.adoptedStyleSheets = document.adoptedStyleSheets.concat(adoptedSheet);
1157
+ }
1158
+ return adoptedSheet;
1159
+ };
1160
+
1161
+ // Folha que vale pra tela inteira e cujas regras dá pra ler (folha de outra origem lança erro).
1162
+ const isWritable = sheet => {
1163
+ if (sheet.disabled || !sheet.ownerNode || !sheet.ownerNode.isConnected) return false;
1164
+ if (sheet.media && sheet.media.length && sheet.media.mediaText !== 'all') return false;
1165
+ try {
1166
+ return !!sheet.cssRules;
1167
+ } catch (e) {
1168
+ return false;
1169
+ }
1170
+ };
1171
+ const getPageSheet = () => {
1172
+ if (pageSheet && isWritable(pageSheet)) return pageSheet;
1173
+ const sheets = Array.prototype.slice.call(document.styleSheets).filter(isWritable);
1174
+ pageSheet = sheets.filter(sheet => sheet.ownerNode.tagName === 'LINK')[0] || sheets[0] || null;
1175
+ return pageSheet;
1176
+ };
1177
+ const appendRule = (sheet, rule) => {
1178
+ try {
1179
+ sheet.insertRule(rule, sheet.cssRules.length);
1180
+ } catch (e) {
1181
+ // regra que o browser não entende: igual a um <style> com ela, só não faz nada
1182
+ }
1183
+ };
1184
+ const appendStyleElement = (name, rule) => {
1185
+ const style = document.createElement('style');
1186
+ style.id = 'startlibs-keyframes-' + name;
1187
+ const nonce = (document.querySelector('meta[property="csp-nonce"]') || {}).content;
1188
+ if (nonce) style.nonce = nonce;
1189
+ style.textContent = rule;
1190
+ document.head.appendChild(style);
1191
+ };
1192
+ const insertKeyframes = (name, frames) => {
1193
+ if (typeof document === 'undefined' || inserted.has(name)) return name;
1194
+ inserted.add(name);
1195
+ const rule = '@keyframes ' + name + ' {' + frames + '}';
1196
+ if (canAdoptSheets()) {
1197
+ appendRule(getAdoptedSheet(), rule);
1198
+ } else if (getPageSheet()) {
1199
+ appendRule(pageSheet, rule);
1200
+ } else {
1201
+ appendStyleElement(name, rule);
1202
+ }
1203
+ return name;
1204
+ };
1205
+
1095
1206
  const escapedValidParts = /(^|[^\\])(dd?|DD?|mm?|LL?|hh?|MM?|ss|SSS|yy(?:yy)?)/g;
1096
1207
  const validParts = /(dd?|DD?|mm?|LL?|hh?|MM?|yy(?:yy)|yy|ss|SSS)$/;
1097
1208
  const addZero = v => (v < 10 ? '0' : '') + v;
@@ -1163,7 +1274,7 @@ function formatDateToPattern(format) {
1163
1274
  return format.replace(escapedValidParts, (_, _1, _2) => _1 + (_2 === 'yy' ? '##' : _2 === 'yyyy' ? '####' : '0#'));
1164
1275
  }
1165
1276
  function formatDate(date, format, messages, noUTC) {
1166
- if (!date) return '';
1277
+ if (!date && date !== 0) return '';
1167
1278
  const separators = format.replace(escapedValidParts, '\0').split('\0');
1168
1279
  const parts = format.match(escapedValidParts);
1169
1280
  const formattedDate = parts.reduce((acc, part) => acc.concat(separators.length ? [separators.shift()] : [], part.replace(validParts, ''), val[part.match(validParts)[0]][0](date, messages, noUTC)), []);
@@ -1744,6 +1855,7 @@ exports.ifNotProp = ifNotProp;
1744
1855
  exports.ifProp = ifProp;
1745
1856
  exports.ifPropEquals = ifPropEquals;
1746
1857
  exports.ifUndefined = ifUndefined;
1858
+ exports.insertKeyframes = insertKeyframes;
1747
1859
  exports.intToHour = intToHour;
1748
1860
  exports.intervalsIntersect = intervalsIntersect;
1749
1861
  exports.intervalsIntersectExclusive = intervalsIntersectExclusive;