@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.
- package/lib/animationKeyframes.mjs +11 -0
- package/lib/animationKeyframes.mjs.map +1 -0
- package/lib/fixMediaQuery.mjs +43 -17
- package/lib/fixMediaQuery.mjs.map +1 -1
- package/lib/fixMediaText.mjs +16 -0
- package/lib/fixMediaText.mjs.map +1 -0
- package/lib/formatDate.mjs +1 -1
- package/lib/formatDate.mjs.map +1 -1
- package/lib/index.cjs +212 -100
- package/lib/index.cjs.map +1 -1
- package/lib/index.mjs +3 -1
- package/lib/index.mjs.map +1 -1
- package/lib/insertKeyframes.mjs +68 -0
- package/lib/insertKeyframes.mjs.map +1 -0
- package/lib/styled.mjs +22 -141
- package/lib/styled.mjs.map +1 -1
- package/lib/styledShared.mjs +125 -0
- package/lib/styledShared.mjs.map +1 -0
- package/lib/timerUtils.mjs +0 -1
- package/lib/timerUtils.mjs.map +1 -1
- package/lib/yakDomTag.mjs +44 -0
- package/lib/yakDomTag.mjs.map +1 -0
- package/lib-yak/ActionUtils.mjs +117 -0
- package/lib-yak/ActionUtils.mjs.map +1 -0
- package/lib-yak/FetchUtils.mjs +100 -0
- package/lib-yak/FetchUtils.mjs.map +1 -0
- package/lib-yak/animationKeyframes.mjs +31 -0
- package/lib-yak/animationKeyframes.mjs.map +1 -0
- package/lib-yak/createPressEvent.mjs +74 -0
- package/lib-yak/createPressEvent.mjs.map +1 -0
- package/lib-yak/fixMediaQuery.mjs +90 -0
- package/lib-yak/fixMediaQuery.mjs.map +1 -0
- package/lib-yak/fixMediaText.mjs +16 -0
- package/lib-yak/fixMediaText.mjs.map +1 -0
- package/lib-yak/formatDate.mjs +110 -0
- package/lib-yak/formatDate.mjs.map +1 -0
- package/lib-yak/formatUtils.mjs +64 -0
- package/lib-yak/formatUtils.mjs.map +1 -0
- package/lib-yak/getClosestOffsetScroll.mjs +15 -0
- package/lib-yak/getClosestOffsetScroll.mjs.map +1 -0
- package/lib-yak/hooks/useEventListener.mjs +27 -0
- package/lib-yak/hooks/useEventListener.mjs.map +1 -0
- package/lib-yak/index.mjs +21 -0
- package/lib-yak/index.mjs.map +1 -0
- package/lib-yak/insertKeyframes.mjs +68 -0
- package/lib-yak/insertKeyframes.mjs.map +1 -0
- package/lib-yak/lodashUtils.mjs +131 -0
- package/lib-yak/lodashUtils.mjs.map +1 -0
- package/lib-yak/promiseUtils.mjs +92 -0
- package/lib-yak/promiseUtils.mjs.map +1 -0
- package/lib-yak/reactUtils.mjs +12 -0
- package/lib-yak/reactUtils.mjs.map +1 -0
- package/lib-yak/reduceUtils.mjs +14 -0
- package/lib-yak/reduceUtils.mjs.map +1 -0
- package/lib-yak/smoothScroll.mjs +59 -0
- package/lib-yak/smoothScroll.mjs.map +1 -0
- package/lib-yak/styled.mjs +23 -0
- package/lib-yak/styled.mjs.map +1 -0
- package/lib-yak/styledShared.mjs +129 -0
- package/lib-yak/styledShared.mjs.map +1 -0
- package/lib-yak/timeUtils.mjs +81 -0
- package/lib-yak/timeUtils.mjs.map +1 -0
- package/lib-yak/timerUtils.mjs +10 -0
- package/lib-yak/timerUtils.mjs.map +1 -0
- package/lib-yak/utils.mjs +386 -0
- package/lib-yak/utils.mjs.map +1 -0
- package/lib-yak/wrapLazy.mjs +132 -0
- package/lib-yak/wrapLazy.mjs.map +1 -0
- package/lib-yak/yakDomTag.mjs +44 -0
- package/lib-yak/yakDomTag.mjs.map +1 -0
- package/package.json +14 -3
- package/src/animationKeyframes.js +10 -0
- package/src/animationKeyframes.test.mjs +75 -0
- package/src/animationKeyframes.yak.js +30 -0
- package/src/fixMediaQuery.js +40 -19
- package/src/fixMediaText.js +18 -0
- package/src/fixMediaText.test.mjs +60 -0
- package/src/formatDate.js +1 -1
- package/src/index.js +1 -0
- package/src/insertKeyframes.js +73 -0
- package/src/insertKeyframes.test.mjs +144 -0
- package/src/styled.js +5 -97
- package/src/styled.yak.js +30 -0
- package/src/styledShared.js +96 -0
- package/src/timerUtils.jsx +0 -2
- package/src/yakDomTag.jsx +42 -0
- package/src/yakDomTag.test.mjs +49 -0
package/lib/index.mjs
CHANGED
|
@@ -3,7 +3,8 @@ export { getClosestOffsetScroll } from './getClosestOffsetScroll.mjs';
|
|
|
3
3
|
export { smoothScroll } from './smoothScroll.mjs';
|
|
4
4
|
export { fixMediaQuery, scrollWidth } from './fixMediaQuery.mjs';
|
|
5
5
|
export { addQueryString, formFetch, formFetchWithResponse, getFetcher, getFetcherWithResponse, postFetcher, postFetcherWithResponse, queryStringToObj } from './FetchUtils.mjs';
|
|
6
|
-
export {
|
|
6
|
+
export { ifNotProp, ifProp, ifPropEquals, media, notPrinterMedia, printerMedia, styledExtend } from './styled.mjs';
|
|
7
|
+
export { insertKeyframes } from './insertKeyframes.mjs';
|
|
7
8
|
export { addZero, formatDate, formatDateToPattern, parseDate } from './formatDate.mjs';
|
|
8
9
|
export { _s } from './lodashUtils.mjs';
|
|
9
10
|
export { Action, COMPLETE_ACTION, FETCH, REDUCE, SKIPPED_ACTION, SKIP_DISPATCH, SKIP_FETCH, SkipAction, activateActions, concatSelectors, selectPath } from './ActionUtils.mjs';
|
|
@@ -16,4 +17,5 @@ export { wrapLazy } from './wrapLazy.mjs';
|
|
|
16
17
|
export { DAY, HOUR, MINUTE, MONTH, SECOND, WEEK, YEAR, blockDiffIntervals, diffIntervals, getStartOfDay, intervalsIntersect, intervalsIntersectExclusive, intervalsIntersection, isSameDay, startBlockDiffIntervals } from './timeUtils.mjs';
|
|
17
18
|
export { cancelableTimer, timerPromise } from './timerUtils.mjs';
|
|
18
19
|
export { asciify, formatJoin, formatJoinArr, normalizeText, normalizeTextUrl, parseDecimalToNumber, removeAccents, willFormatDecimal } from './formatUtils.mjs';
|
|
20
|
+
export { animationTiming, customTheme, getColor, getMargin, identityOpacityFrames, identityTranslateFrames, oneWayAnimation, prop, twoWayAnimation, vheight } from './styledShared.mjs';
|
|
19
21
|
//# sourceMappingURL=index.mjs.map
|
package/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Registra um @keyframes pelo CSSOM, sem criar <style> na página: funciona com CSP
|
|
2
|
+
// `style-src 'self'` sem nonce. Ordem de tentativa:
|
|
3
|
+
// 1. uma folha construída (new CSSStyleSheet) em document.adoptedStyleSheets;
|
|
4
|
+
// 2. browser sem folha construída: insertRule numa folha do próprio site já carregada
|
|
5
|
+
// (de preferência um <link>, que nenhum runtime de CSS-in-JS gerencia);
|
|
6
|
+
// 3. nenhuma das duas: <style> com o nonce do <meta property="csp-nonce">, se houver.
|
|
7
|
+
// Cada nome entra uma vez só; quem chama garante que nome igual é conteúdo igual.
|
|
8
|
+
const inserted = new Set();
|
|
9
|
+
let adoptedSheet = null;
|
|
10
|
+
let pageSheet = null;
|
|
11
|
+
const canAdoptSheets = () => typeof CSSStyleSheet !== 'undefined' && 'replaceSync' in CSSStyleSheet.prototype && 'adoptedStyleSheets' in document;
|
|
12
|
+
|
|
13
|
+
// Outro código pode reatribuir document.adoptedStyleSheets e tirar a folha da lista: recoloca.
|
|
14
|
+
const getAdoptedSheet = () => {
|
|
15
|
+
if (!adoptedSheet) adoptedSheet = new CSSStyleSheet();
|
|
16
|
+
if (document.adoptedStyleSheets.indexOf(adoptedSheet) < 0) {
|
|
17
|
+
document.adoptedStyleSheets = document.adoptedStyleSheets.concat(adoptedSheet);
|
|
18
|
+
}
|
|
19
|
+
return adoptedSheet;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// Folha que vale pra tela inteira e cujas regras dá pra ler (folha de outra origem lança erro).
|
|
23
|
+
const isWritable = sheet => {
|
|
24
|
+
if (sheet.disabled || !sheet.ownerNode || !sheet.ownerNode.isConnected) return false;
|
|
25
|
+
if (sheet.media && sheet.media.length && sheet.media.mediaText !== 'all') return false;
|
|
26
|
+
try {
|
|
27
|
+
return !!sheet.cssRules;
|
|
28
|
+
} catch (e) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const getPageSheet = () => {
|
|
33
|
+
if (pageSheet && isWritable(pageSheet)) return pageSheet;
|
|
34
|
+
const sheets = Array.prototype.slice.call(document.styleSheets).filter(isWritable);
|
|
35
|
+
pageSheet = sheets.filter(sheet => sheet.ownerNode.tagName === 'LINK')[0] || sheets[0] || null;
|
|
36
|
+
return pageSheet;
|
|
37
|
+
};
|
|
38
|
+
const appendRule = (sheet, rule) => {
|
|
39
|
+
try {
|
|
40
|
+
sheet.insertRule(rule, sheet.cssRules.length);
|
|
41
|
+
} catch (e) {
|
|
42
|
+
// regra que o browser não entende: igual a um <style> com ela, só não faz nada
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const appendStyleElement = (name, rule) => {
|
|
46
|
+
const style = document.createElement('style');
|
|
47
|
+
style.id = 'startlibs-keyframes-' + name;
|
|
48
|
+
const nonce = (document.querySelector('meta[property="csp-nonce"]') || {}).content;
|
|
49
|
+
if (nonce) style.nonce = nonce;
|
|
50
|
+
style.textContent = rule;
|
|
51
|
+
document.head.appendChild(style);
|
|
52
|
+
};
|
|
53
|
+
const insertKeyframes = (name, frames) => {
|
|
54
|
+
if (typeof document === 'undefined' || inserted.has(name)) return name;
|
|
55
|
+
inserted.add(name);
|
|
56
|
+
const rule = '@keyframes ' + name + ' {' + frames + '}';
|
|
57
|
+
if (canAdoptSheets()) {
|
|
58
|
+
appendRule(getAdoptedSheet(), rule);
|
|
59
|
+
} else if (getPageSheet()) {
|
|
60
|
+
appendRule(pageSheet, rule);
|
|
61
|
+
} else {
|
|
62
|
+
appendStyleElement(name, rule);
|
|
63
|
+
}
|
|
64
|
+
return name;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export { insertKeyframes };
|
|
68
|
+
//# sourceMappingURL=insertKeyframes.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insertKeyframes.mjs","sources":["../src/insertKeyframes.js"],"sourcesContent":["// Registra um @keyframes pelo CSSOM, sem criar <style> na página: funciona com CSP\n// `style-src 'self'` sem nonce. Ordem de tentativa:\n// 1. uma folha construída (new CSSStyleSheet) em document.adoptedStyleSheets;\n// 2. browser sem folha construída: insertRule numa folha do próprio site já carregada\n// (de preferência um <link>, que nenhum runtime de CSS-in-JS gerencia);\n// 3. nenhuma das duas: <style> com o nonce do <meta property=\"csp-nonce\">, se houver.\n// Cada nome entra uma vez só; quem chama garante que nome igual é conteúdo igual.\nconst inserted = new Set()\nlet adoptedSheet = null\nlet pageSheet = null\n\nconst canAdoptSheets = () =>\n typeof CSSStyleSheet !== 'undefined' &&\n 'replaceSync' in CSSStyleSheet.prototype &&\n 'adoptedStyleSheets' in document\n\n// Outro código pode reatribuir document.adoptedStyleSheets e tirar a folha da lista: recoloca.\nconst getAdoptedSheet = () => {\n if (!adoptedSheet) adoptedSheet = new CSSStyleSheet()\n if (document.adoptedStyleSheets.indexOf(adoptedSheet) < 0) {\n document.adoptedStyleSheets = document.adoptedStyleSheets.concat(adoptedSheet)\n }\n return adoptedSheet\n}\n\n// Folha que vale pra tela inteira e cujas regras dá pra ler (folha de outra origem lança erro).\nconst isWritable = (sheet) => {\n if (sheet.disabled || !sheet.ownerNode || !sheet.ownerNode.isConnected) return false\n if (sheet.media && sheet.media.length && sheet.media.mediaText !== 'all') return false\n try {\n return !!sheet.cssRules\n } catch (e) {\n return false\n }\n}\n\nconst getPageSheet = () => {\n if (pageSheet && isWritable(pageSheet)) return pageSheet\n const sheets = Array.prototype.slice.call(document.styleSheets).filter(isWritable)\n pageSheet = sheets.filter((sheet) => sheet.ownerNode.tagName === 'LINK')[0] || sheets[0] || null\n return pageSheet\n}\n\nconst appendRule = (sheet, rule) => {\n try {\n sheet.insertRule(rule, sheet.cssRules.length)\n } catch (e) {\n // regra que o browser não entende: igual a um <style> com ela, só não faz nada\n }\n}\n\nconst appendStyleElement = (name, rule) => {\n const style = document.createElement('style')\n style.id = 'startlibs-keyframes-' + name\n const nonce = (document.querySelector('meta[property=\"csp-nonce\"]') || {}).content\n if (nonce) style.nonce = nonce\n style.textContent = rule\n document.head.appendChild(style)\n}\n\nexport const insertKeyframes = (name, frames) => {\n if (typeof document === 'undefined' || inserted.has(name)) return name\n inserted.add(name)\n const rule = '@keyframes ' + name + ' {' + frames + '}'\n if (canAdoptSheets()) {\n appendRule(getAdoptedSheet(), rule)\n } else if (getPageSheet()) {\n appendRule(pageSheet, rule)\n } else {\n appendStyleElement(name, rule)\n }\n return name\n}\n"],"names":["inserted","Set","adoptedSheet","pageSheet","canAdoptSheets","CSSStyleSheet","prototype","document","getAdoptedSheet","adoptedStyleSheets","indexOf","concat","isWritable","sheet","disabled","ownerNode","isConnected","media","length","mediaText","cssRules","e","getPageSheet","sheets","Array","slice","call","styleSheets","filter","tagName","appendRule","rule","insertRule","appendStyleElement","name","style","createElement","id","nonce","querySelector","content","textContent","head","appendChild","insertKeyframes","frames","has","add"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,QAAQ,GAAG,IAAIC,GAAG,EAAE,CAAA;AAC1B,IAAIC,YAAY,GAAG,IAAI,CAAA;AACvB,IAAIC,SAAS,GAAG,IAAI,CAAA;AAEpB,MAAMC,cAAc,GAAGA,MACrB,OAAOC,aAAa,KAAK,WAAW,IACpC,aAAa,IAAIA,aAAa,CAACC,SAAS,IACxC,oBAAoB,IAAIC,QAAQ,CAAA;;AAElC;AACA,MAAMC,eAAe,GAAGA,MAAM;EAC5B,IAAI,CAACN,YAAY,EAAEA,YAAY,GAAG,IAAIG,aAAa,EAAE,CAAA;EACrD,IAAIE,QAAQ,CAACE,kBAAkB,CAACC,OAAO,CAACR,YAAY,CAAC,GAA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,EAAEH,IAAI,CAAC,CAAA;AAChC,GAAA;AACA,EAAA,OAAOG,IAAI,CAAA;AACb;;;;"}
|
package/lib/styled.mjs
CHANGED
|
@@ -1,79 +1,14 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from '@babel/runtime/helpers/taggedTemplateLiteral';
|
|
2
1
|
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
|
-
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
2
|
import _find from 'lodash/fp/find';
|
|
6
|
-
import _reverse from 'lodash/fp/reverse';
|
|
7
3
|
import _isEqual from 'lodash/fp/isEqual';
|
|
4
|
+
import _get from 'lodash/fp/get';
|
|
8
5
|
import _identity from 'lodash/fp/identity';
|
|
9
6
|
import _isFunction from 'lodash/fp/isFunction';
|
|
10
|
-
import _get from 'lodash/fp/get';
|
|
11
|
-
import _unset from 'lodash/fp/unset';
|
|
12
|
-
import { darken } from 'polished';
|
|
13
|
-
import 'react';
|
|
14
7
|
import styled, { css } from 'styled-components';
|
|
15
|
-
import createEmotion from 'create-emotion';
|
|
16
8
|
import { scrollWidth } from './fixMediaQuery.mjs';
|
|
17
|
-
import { _s } from './lodashUtils.mjs';
|
|
18
9
|
import { callIfFunction } from './utils.mjs';
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const _excluded = ["theme"];
|
|
22
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
23
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
24
|
-
const getColor = (propsOrColor, hover) => {
|
|
25
|
-
if (propsOrColor === undefined) {
|
|
26
|
-
return _ref => {
|
|
27
|
-
let theme = _ref.theme;
|
|
28
|
-
return theme.colors.gray150;
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
if (typeof propsOrColor === 'string') {
|
|
32
|
-
return _ref2 => {
|
|
33
|
-
let theme = _ref2.theme;
|
|
34
|
-
return theme.colors[propsOrColor] || propsOrColor;
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
const theme = propsOrColor.theme,
|
|
38
|
-
props = _objectWithoutProperties(propsOrColor, _excluded);
|
|
39
|
-
if (props.dark) {
|
|
40
|
-
return darken(0.1, getColor(_objectSpread({
|
|
41
|
-
theme
|
|
42
|
-
}, _unset('dark', props))));
|
|
43
|
-
} else if (hover && props.hover) {
|
|
44
|
-
return getColor({
|
|
45
|
-
theme,
|
|
46
|
-
color: props.hover
|
|
47
|
-
});
|
|
48
|
-
} else if (props.color) {
|
|
49
|
-
return theme.colors[props.color] || props.color;
|
|
50
|
-
} else if (props.highlight) {
|
|
51
|
-
return theme.colors.main;
|
|
52
|
-
} else if (props.alert) {
|
|
53
|
-
return theme.colors.alert;
|
|
54
|
-
} else if (props.success) {
|
|
55
|
-
return theme.colors.success;
|
|
56
|
-
} else {
|
|
57
|
-
return theme.colors.gray150;
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
const getMargin = enumeratedMargins => props => enumeratedMargins[props.margin] || props.margin || enumeratedMargins['default'] || 0;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Returns the value of `props[path]` or `defaultValue`
|
|
64
|
-
* @example
|
|
65
|
-
* const Button = styled.button`
|
|
66
|
-
* color: ${prop('color', 'red')};
|
|
67
|
-
* `
|
|
68
|
-
*/
|
|
69
|
-
const prop = (path, defaultValue) => function () {
|
|
70
|
-
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
71
|
-
return _get(path.trim(), props) || defaultValue;
|
|
72
|
-
};
|
|
73
|
-
const customTheme = type => function () {
|
|
74
|
-
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
75
|
-
return _get(["theme", "startlibs", type], props) || '';
|
|
76
|
-
};
|
|
10
|
+
import { ifPropValue } from './styledShared.mjs';
|
|
11
|
+
export { animationTiming, customTheme, getColor, getMargin, identityOpacityFrames, identityTranslateFrames, oneWayAnimation, prop, twoWayAnimation, vheight } from './styledShared.mjs';
|
|
77
12
|
|
|
78
13
|
/**
|
|
79
14
|
* Returns `pass` if prop is truthy. Otherwise returns `fail`
|
|
@@ -92,23 +27,7 @@ const customTheme = type => function () {
|
|
|
92
27
|
const ifProp = (path, pass, fail) => {
|
|
93
28
|
if (pass && !_isFunction(pass)) {
|
|
94
29
|
// old version
|
|
95
|
-
return
|
|
96
|
-
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
97
|
-
let result = false;
|
|
98
|
-
if (Array.isArray(path)) {
|
|
99
|
-
result = path.every(p => testSinglePath(props, p));
|
|
100
|
-
} else if (typeof path === 'object') {
|
|
101
|
-
result = !Object.entries(path).find(_ref3 => {
|
|
102
|
-
let _ref4 = _slicedToArray(_ref3, 2),
|
|
103
|
-
k = _ref4[0],
|
|
104
|
-
v = _ref4[1];
|
|
105
|
-
return props[k] !== v;
|
|
106
|
-
});
|
|
107
|
-
} else {
|
|
108
|
-
result = testSinglePath(props, path);
|
|
109
|
-
}
|
|
110
|
-
return result ? pass : fail;
|
|
111
|
-
};
|
|
30
|
+
return ifPropValue(path, pass, fail);
|
|
112
31
|
} else {
|
|
113
32
|
return function () {
|
|
114
33
|
for (var _len = arguments.length, argsTrue = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
@@ -130,10 +49,10 @@ const ifPropEquals = (path, str) => ifProp(path, _isEqual(str));
|
|
|
130
49
|
const ifNotProp = path => ifProp(path, v => !v);
|
|
131
50
|
const checkCustomScreenWidth = (sizeParis, customWidth) => {
|
|
132
51
|
const currentWidth = callIfFunction(customWidth);
|
|
133
|
-
return !sizeParis.find(
|
|
134
|
-
let
|
|
135
|
-
size =
|
|
136
|
-
type =
|
|
52
|
+
return !sizeParis.find(_ref => {
|
|
53
|
+
let _ref2 = _slicedToArray(_ref, 2),
|
|
54
|
+
size = _ref2[0],
|
|
55
|
+
type = _ref2[1];
|
|
137
56
|
if (type === "min-width") {
|
|
138
57
|
return currentWidth < size;
|
|
139
58
|
}
|
|
@@ -152,10 +71,10 @@ const media = function () {
|
|
|
152
71
|
}
|
|
153
72
|
return css(["", ""], props => {
|
|
154
73
|
var _props$theme, _props$theme2;
|
|
155
|
-
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) ? css(...args) : "" : css(["@media ", "{", "}"], sizePairs.map(
|
|
156
|
-
let
|
|
157
|
-
size =
|
|
158
|
-
type =
|
|
74
|
+
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) ? css(...args) : "" : css(["@media ", "{", "}"], sizePairs.map(_ref3 => {
|
|
75
|
+
let _ref4 = _slicedToArray(_ref3, 2),
|
|
76
|
+
size = _ref4[0],
|
|
77
|
+
type = _ref4[1];
|
|
159
78
|
return "(".concat(type, ": ").concat(size + scrollWidth, "px)");
|
|
160
79
|
}).join(' and '), css(...args));
|
|
161
80
|
});
|
|
@@ -166,51 +85,13 @@ media.between = (min, max) => media([min, 'min-width'], [max, 'max-width']);
|
|
|
166
85
|
media.max = n => media([n, 'max-width']);
|
|
167
86
|
media.min = n => media([n, 'min-width']);
|
|
168
87
|
media.desktop = media([601, 'min-width']);
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
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 ");
|
|
173
|
-
};
|
|
174
|
-
function testSinglePath(props, path) {
|
|
175
|
-
if (typeof path === 'string') {
|
|
176
|
-
return !!_s.get(path, props);
|
|
177
|
-
} else if (typeof path === 'number') {
|
|
178
|
-
return !!props[path];
|
|
179
|
-
} else {
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
const getFrameOffset = (i, total) => Math.round(i * 100 / (total - 1));
|
|
184
|
-
const emotion = createEmotion({
|
|
185
|
-
nonce: typeof document !== 'undefined' && (document.querySelector('meta[property="csp-nonce"]') || {}).content || 'animation_nonce'
|
|
186
|
-
});
|
|
187
|
-
const oneWayAnimation = function () {
|
|
188
|
-
for (var _len5 = arguments.length, frames = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
189
|
-
frames[_key5] = arguments[_key5];
|
|
190
|
-
}
|
|
191
|
-
return emotion.keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", ""])), frames.map((frame, i) => !frame ? '' : "".concat(getFrameOffset(i, frames.length), "% {\n ").concat(frame, "\n }")));
|
|
192
|
-
};
|
|
193
|
-
const twoWayAnimation = function () {
|
|
194
|
-
for (var _len6 = arguments.length, frames = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
195
|
-
frames[_key6] = arguments[_key6];
|
|
196
|
-
}
|
|
197
|
-
return [frames, _reverse(frames)].map(frames => oneWayAnimation(...frames));
|
|
198
|
-
};
|
|
199
|
-
const animationTiming = props => function () {
|
|
200
|
-
for (var _len7 = arguments.length, animations = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
201
|
-
animations[_key7] = arguments[_key7];
|
|
202
|
-
}
|
|
203
|
-
return animations.filter(_ => _).map(_ => _ + ' ' + props).join(',');
|
|
204
|
-
};
|
|
205
|
-
const identityTranslateFrames = oneWayAnimation('transform: translateY(0);', 'transform: translateY(0);');
|
|
206
|
-
const identityOpacityFrames = oneWayAnimation('opacity: 1;', 'opacity:1;');
|
|
207
|
-
const styledExtend = _ref9 => {
|
|
208
|
-
let target = _ref9.target,
|
|
209
|
-
componentStyle = _ref9.componentStyle;
|
|
88
|
+
const styledExtend = _ref5 => {
|
|
89
|
+
let target = _ref5.target,
|
|
90
|
+
componentStyle = _ref5.componentStyle;
|
|
210
91
|
return function () {
|
|
211
92
|
const wasStatic = !_find(_isFunction, componentStyle.rules);
|
|
212
|
-
for (var
|
|
213
|
-
template[
|
|
93
|
+
for (var _len5 = arguments.length, template = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
|
|
94
|
+
template[_key5] = arguments[_key5];
|
|
214
95
|
}
|
|
215
96
|
const v = /*#__PURE__*/styled(target)(...template, ...(wasStatic ? [] : [() => ""]));
|
|
216
97
|
v.componentStyle.rules = [...componentStyle.rules, ...v.componentStyle.rules];
|
|
@@ -218,17 +99,17 @@ const styledExtend = _ref9 => {
|
|
|
218
99
|
};
|
|
219
100
|
};
|
|
220
101
|
const printerMedia = function () {
|
|
221
|
-
for (var
|
|
222
|
-
args[
|
|
102
|
+
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
|
|
103
|
+
args[_key6] = arguments[_key6];
|
|
223
104
|
}
|
|
224
105
|
return props => props.theme.printMode ? css(...args) : css(["@media print{", "}"], css(...args));
|
|
225
106
|
};
|
|
226
107
|
const notPrinterMedia = function () {
|
|
227
|
-
for (var
|
|
228
|
-
args[
|
|
108
|
+
for (var _len7 = arguments.length, args = new Array(_len7), _key7 = 0; _key7 < _len7; _key7++) {
|
|
109
|
+
args[_key7] = arguments[_key7];
|
|
229
110
|
}
|
|
230
111
|
return props => props.theme.printMode ? '' : css(["@media screen{", "}"], css(...args));
|
|
231
112
|
};
|
|
232
113
|
|
|
233
|
-
export {
|
|
114
|
+
export { ifNotProp, ifProp, ifPropEquals, media, notPrinterMedia, printerMedia, styledExtend };
|
|
234
115
|
//# sourceMappingURL=styled.mjs.map
|
package/lib/styled.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"styled.mjs","sources":["../src/styled.js"],"sourcesContent":["// @flow\nimport _ from 'lodash/fp'\nimport {darken} from 'polished'\nimport React from 'react'\nimport styled, {css} from 'styled-components'\nimport createEmotion from 'create-emotion'\nimport {scrollWidth} from './fixMediaQuery'\nimport {_s} from './lodashUtils'\nimport {callIfFunction} from './utils'\n\nexport const getColor = (propsOrColor, hover) => {\n if (propsOrColor === undefined) {\n return ({theme})=>theme.colors.gray150\n }\n if (typeof propsOrColor==='string') {\n return ({theme})=>theme.colors[propsOrColor] || propsOrColor\n }\n const {theme,...props} = propsOrColor\n if (props.dark) {\n return darken(0.1, getColor({theme, ..._.unset( 'dark', props)}))\n } else if (hover && props.hover) {\n return getColor({theme, color: props.hover})\n } else if (props.color) {\n return theme.colors[props.color] || props.color\n } else if (props.highlight) {\n return theme.colors.main\n } else if (props.alert) {\n return theme.colors.alert\n } else if (props.success) {\n return theme.colors.success\n } else {\n return theme.colors.gray150\n }\n}\n\nexport const getMargin = (enumeratedMargins) => (props) => enumeratedMargins[props.margin] || props.margin || enumeratedMargins['default'] || 0\n\n/**\n * Returns the value of `props[path]` or `defaultValue`\n * @example\n * const Button = styled.button`\n * color: ${prop('color', 'red')};\n * `\n */\nexport const prop = (path,defaultValue) =>\n (props = {}) => _.get(path.trim(), props) || defaultValue\n\nexport const customTheme = (type) =>\n (props = {}) => _.get([\"theme\",\"startlibs\",type], props) || ''\n\n/**\n * Returns `pass` if prop is truthy. Otherwise returns `fail`\n * @example\n * // usage with styled-theme\n * import styled from 'styled-components'\n * import { ifProp } from 'styled-tools'\n * import { palette } from 'styled-theme'\n *\n * const Button = styled.button`\n * background-color: ${ifProp('transparent', 'transparent', palette(0))};\n * color: ${ifProp(['transparent', 'accent'], palette('secondary', 0))};\n * font-size: ${ifProp({ size: 'large' }, '20px', ifProp({ size: 'medium' }, '16px', '12px'))};\n *`\n */\nexport const ifProp = (path, pass, fail) => {\n if (pass && !_.isFunction(pass)) { // old version\n return (props = {}) => {\n let result = false\n if (Array.isArray(path)) {\n result = path.every(p=> testSinglePath(props,p))\n } else if (typeof path === 'object') {\n result = !Object.entries(path).find(([k,v])=>props[k]!==v)\n } else {\n result = testSinglePath(props,path)\n }\n return result ? pass : fail\n }\n } else {\n return (...argsTrue) => {\n const check = pass || _.identity\n const fn = props => check(_.get(path,props)) ? css(...argsTrue) : ''\n fn.orElse = (...argsFalse) => (props) => check(_.get(path,props)) ? css(...argsTrue) : css(...argsFalse)\n return fn\n }\n }\n}\nexport const ifPropEquals = (path,str) => ifProp(path,_.isEqual(str))\nexport const ifNotProp = (path) => ifProp(path,v => !v)\n\nconst checkCustomScreenWidth = (sizeParis,customWidth) => {\n const currentWidth = callIfFunction(customWidth)\n return !sizeParis.find(([size,type]) => {\n if (type === \"min-width\") {\n return currentWidth < size\n }\n if (type === \"max-width\") {\n return currentWidth > size\n }\n })\n}\n\nexport const media = (...sizePairs) => (...args) => {\n return css`\n ${props => \n props.theme?.overrideMediaWidth\n ? (checkCustomScreenWidth(sizePairs,props.theme?.overrideMediaWidth) ? css(...args) : \"\") \n : css`@media ${sizePairs.map(([size,type]) => `(${type}: ${size+scrollWidth}px)`).join(' and ')} {\n ${ css(...args) }\n }`\n }`\n}\n\nmedia.mobile = media([600,'max-width'])\nmedia.between = (min,max) => media([min,'min-width'],[max,'max-width'])\nmedia.max = (n) => media([n,'max-width'])\nmedia.min = (n) => media([n,'min-width'])\nmedia.desktop = media([601,'min-width'])\n\nexport const vheight = (strings,size) => {\n const propType = strings[0]\n const calc = (strings[1]||\"\").replace(\";\",\"\").trim()\n return `\n ${propType} ${calc ? `calc(${size}vh ${calc})` : `${size}vh`};\n ${propType} ${calc ? `calc(calc(var(--vh, 1vh) * ${size}) ${calc})` : `calc(var(--vh, 1vh) * ${size})`};\n `\n}\n\nfunction testSinglePath(props,path) {\n if (typeof path === 'string') {\n return !!_s.get(path, props)\n } else if (typeof path === 'number') {\n return !!props[path]\n } else {\n return false\n }\n}\n\nconst getFrameOffset = (i,total) => Math.round(i*100/(total-1))\n\n\nconst emotion = createEmotion({\n nonce: (typeof document !== 'undefined' &&\n (document.querySelector('meta[property=\"csp-nonce\"]') || {}).content) || 'animation_nonce'\n})\n\nexport const oneWayAnimation = (...frames) => {\n return emotion.keyframes`\n ${frames.map((frame,i) =>\n !frame ? '' : `${getFrameOffset(i,frames.length)}% {\n ${frame}\n }`\n )}`\n}\n\nexport const twoWayAnimation = (...frames) => [frames,_.reverse(frames)].map((frames)=>oneWayAnimation(...frames))\n\nexport const animationTiming = (props) => (...animations) => animations.filter(_=>_).map(_=>_+' '+props).join(',')\n\nexport const identityTranslateFrames = oneWayAnimation('transform: translateY(0);', 'transform: translateY(0);')\nexport const identityOpacityFrames = oneWayAnimation('opacity: 1;', 'opacity:1;')\n\nexport const styledExtend = ({target,componentStyle}) => (...template) => {\n const wasStatic = !_.find(_.isFunction,componentStyle.rules)\n const v = styled(target)(...template,...(wasStatic ? [] : [() => \"\"]))\n v.componentStyle.rules = [...componentStyle.rules,...v.componentStyle.rules]\n return v\n}\n\nexport const printerMedia = (...args) => (props) =>\n props.theme.printMode\n ? css(...args)\n : css`@media print { ${css(...args)} }`\n\nexport const notPrinterMedia = (...args) => (props) =>\n props.theme.printMode\n ? ''\n : css`@media screen { ${css(...args)} }`"],"names":["getColor","propsOrColor","hover","undefined","_ref","theme","colors","gray150","_ref2","props","_objectWithoutProperties","_excluded","dark","darken","_objectSpread","_unset","color","highlight","main","alert","success","getMargin","enumeratedMargins","margin","prop","path","defaultValue","arguments","length","_get","trim","customTheme","type","ifProp","pass","fail","_isFunction","result","Array","isArray","every","p","testSinglePath","Object","entries","find","_ref3","_ref4","_slicedToArray","k","v","_len","argsTrue","_key","check","_identity","fn","css","orElse","_len2","argsFalse","_key2","ifPropEquals","str","_isEqual","ifNotProp","checkCustomScreenWidth","sizeParis","customWidth","currentWidth","callIfFunction","_ref5","_ref6","size","media","_len3","sizePairs","_key3","_len4","args","_key4","_props$theme","_props$theme2","overrideMediaWidth","map","_ref7","_ref8","concat","scrollWidth","join","mobile","between","min","max","n","desktop","vheight","strings","propType","calc","replace","_s","get","getFrameOffset","i","total","Math","round","emotion","createEmotion","nonce","document","querySelector","content","oneWayAnimation","_len5","frames","_key5","keyframes","_templateObject","_taggedTemplateLiteral","frame","twoWayAnimation","_len6","_key6","_reverse","animationTiming","_len7","animations","_key7","filter","_","identityTranslateFrames","identityOpacityFrames","styledExtend","_ref9","target","componentStyle","wasStatic","_find","rules","_len8","template","_key8","styled","printerMedia","_len9","_key9","printMode","notPrinterMedia","_len0","_key0"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;MAUaA,QAAQ,GAAGA,CAACC,YAAY,EAAEC,KAAK,KAAK;EAC/C,IAAID,YAAY,KAAKE,SAAS,EAAE;AAC9B,IAAA,OAAOC,IAAA,IAAA;AAAA,MAAA,IAAEC,KAAK,GAAAD,IAAA,CAALC,KAAK,CAAA;AAAA,MAAA,OAAIA,KAAK,CAACC,MAAM,CAACC,OAAO,CAAA;AAAA,KAAA,CAAA;AACxC,GAAA;AACA,EAAA,IAAI,OAAON,YAAY,KAAG,QAAQ,EAAE;AAClC,IAAA,OAAOO,KAAA,IAAA;AAAA,MAAA,IAAEH,KAAK,GAAAG,KAAA,CAALH,KAAK,CAAA;AAAA,MAAA,OAAIA,KAAK,CAACC,MAAM,CAACL,YAAY,CAAC,IAAIA,YAAY,CAAA;AAAA,KAAA,CAAA;AAC9D,GAAA;AACA,EAAA,MAAOI,KAAK,GAAaJ,YA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AAAA,GAAG,CAAC,GAAGsB,IAAI,CAAC,CAAI,CAAA;AAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"styled.mjs","sources":["../src/styled.js"],"sourcesContent":["/* @startlibs-yak keep-styled-components */\n// @flow\n// Na lib-yak, este arquivo é trocado por styled.yak.js (sem styled-components).\nimport _ from 'lodash/fp'\nimport styled, {css} from 'styled-components'\nimport {scrollWidth} from './fixMediaQuery'\nimport {callIfFunction} from './utils'\nimport {ifPropValue} from './styledShared'\n\nexport {getColor, getMargin, prop, customTheme, vheight, oneWayAnimation, twoWayAnimation, animationTiming, identityTranslateFrames, identityOpacityFrames} from './styledShared'\n\n/**\n * Returns `pass` if prop is truthy. Otherwise returns `fail`\n * @example\n * // usage with styled-theme\n * import styled from 'styled-components'\n * import { ifProp } from 'styled-tools'\n * import { palette } from 'styled-theme'\n *\n * const Button = styled.button`\n * background-color: ${ifProp('transparent', 'transparent', palette(0))};\n * color: ${ifProp(['transparent', 'accent'], palette('secondary', 0))};\n * font-size: ${ifProp({ size: 'large' }, '20px', ifProp({ size: 'medium' }, '16px', '12px'))};\n *`\n */\nexport const ifProp = (path, pass, fail) => {\n if (pass && !_.isFunction(pass)) { // old version\n return ifPropValue(path, pass, fail)\n } else {\n return (...argsTrue) => {\n const check = pass || _.identity\n const fn = props => check(_.get(path,props)) ? css(...argsTrue) : ''\n fn.orElse = (...argsFalse) => (props) => check(_.get(path,props)) ? css(...argsTrue) : css(...argsFalse)\n return fn\n }\n }\n}\nexport const ifPropEquals = (path,str) => ifProp(path,_.isEqual(str))\nexport const ifNotProp = (path) => ifProp(path,v => !v)\n\nconst checkCustomScreenWidth = (sizeParis,customWidth) => {\n const currentWidth = callIfFunction(customWidth)\n return !sizeParis.find(([size,type]) => {\n if (type === \"min-width\") {\n return currentWidth < size\n }\n if (type === \"max-width\") {\n return currentWidth > size\n }\n })\n}\n\nexport const media = (...sizePairs) => (...args) => {\n return css`\n ${props => \n props.theme?.overrideMediaWidth\n ? (checkCustomScreenWidth(sizePairs,props.theme?.overrideMediaWidth) ? css(...args) : \"\") \n : css`@media ${sizePairs.map(([size,type]) => `(${type}: ${size+scrollWidth}px)`).join(' and ')} {\n ${ css(...args) }\n }`\n }`\n}\n\nmedia.mobile = media([600,'max-width'])\nmedia.between = (min,max) => media([min,'min-width'],[max,'max-width'])\nmedia.max = (n) => media([n,'max-width'])\nmedia.min = (n) => media([n,'min-width'])\nmedia.desktop = media([601,'min-width'])\n\nexport const styledExtend = ({target,componentStyle}) => (...template) => {\n const wasStatic = !_.find(_.isFunction,componentStyle.rules)\n const v = styled(target)(...template,...(wasStatic ? [] : [() => \"\"]))\n v.componentStyle.rules = [...componentStyle.rules,...v.componentStyle.rules]\n return v\n}\n\nexport const printerMedia = (...args) => (props) =>\n props.theme.printMode\n ? css(...args)\n : css`@media print { ${css(...args)} }`\n\nexport const notPrinterMedia = (...args) => (props) =>\n props.theme.printMode\n ? ''\n : css`@media screen { ${css(...args)} }`"],"names":["ifProp","path","pass","fail","_isFunction","ifPropValue","_len","arguments","length","argsTrue","Array","_key","check","_identity","fn","props","_get","css","orElse","_len2","argsFalse","_key2","ifPropEquals","str","_isEqual","ifNotProp","v","checkCustomScreenWidth","sizeParis","customWidth","currentWidth","callIfFunction","find","_ref","_ref2","_slicedToArray","size","type","media","_len3","sizePairs","_key3","_len4","args","_key4","_props$theme","_props$theme2","theme","overrideMediaWidth","map","_ref3","_ref4","concat","scrollWidth","join","mobile","between","min","max","n","desktop","styledExtend","_ref5","target","componentStyle","wasStatic","_find","rules","_len5","template","_key5","styled","printerMedia","_len6","_key6","printMode","notPrinterMedia","_len7","_key7"],"mappings":";;;;;;;;;;;;AAWA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,MAAM,GAAGA,CAACC,IAAI,EAAEC,IAAI,EAAEC,IAAI,KAAK;AAC1C,EAAA,IAAID,IAAI,IAAI,CAACE,WAAA,CAAaF,IAAI,CAAC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time/helpers/taggedTemplateLiteral';
|
|
3
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
|
+
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
5
|
+
import _reverse from 'lodash/fp/reverse';
|
|
6
|
+
import _get from 'lodash/fp/get';
|
|
7
|
+
import _unset from 'lodash/fp/unset';
|
|
8
|
+
import { darken } from 'polished';
|
|
9
|
+
import { animationKeyframes } from './animationKeyframes.mjs';
|
|
10
|
+
import { _s } from './lodashUtils.mjs';
|
|
11
|
+
|
|
12
|
+
var _templateObject;
|
|
13
|
+
const _excluded = ["theme"];
|
|
14
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
|
+
const getColor = (propsOrColor, hover) => {
|
|
17
|
+
if (propsOrColor === undefined) {
|
|
18
|
+
return _ref => {
|
|
19
|
+
let theme = _ref.theme;
|
|
20
|
+
return theme.colors.gray150;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
if (typeof propsOrColor === 'string') {
|
|
24
|
+
return _ref2 => {
|
|
25
|
+
let theme = _ref2.theme;
|
|
26
|
+
return theme.colors[propsOrColor] || propsOrColor;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const theme = propsOrColor.theme,
|
|
30
|
+
props = _objectWithoutProperties(propsOrColor, _excluded);
|
|
31
|
+
if (props.dark) {
|
|
32
|
+
return darken(0.1, getColor(_objectSpread({
|
|
33
|
+
theme
|
|
34
|
+
}, _unset('dark', props))));
|
|
35
|
+
} else if (hover && props.hover) {
|
|
36
|
+
return getColor({
|
|
37
|
+
theme,
|
|
38
|
+
color: props.hover
|
|
39
|
+
});
|
|
40
|
+
} else if (props.color) {
|
|
41
|
+
return theme.colors[props.color] || props.color;
|
|
42
|
+
} else if (props.highlight) {
|
|
43
|
+
return theme.colors.main;
|
|
44
|
+
} else if (props.alert) {
|
|
45
|
+
return theme.colors.alert;
|
|
46
|
+
} else if (props.success) {
|
|
47
|
+
return theme.colors.success;
|
|
48
|
+
} else {
|
|
49
|
+
return theme.colors.gray150;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const getMargin = enumeratedMargins => props => enumeratedMargins[props.margin] || props.margin || enumeratedMargins['default'] || 0;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Returns the value of `props[path]` or `defaultValue`
|
|
56
|
+
* @example
|
|
57
|
+
* const Button = styled.button`
|
|
58
|
+
* color: ${prop('color', 'red')};
|
|
59
|
+
* `
|
|
60
|
+
*/
|
|
61
|
+
const prop = (path, defaultValue) => function () {
|
|
62
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
63
|
+
return _get(path.trim(), props) || defaultValue;
|
|
64
|
+
};
|
|
65
|
+
const customTheme = type => function () {
|
|
66
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
67
|
+
return _get(["theme", "startlibs", type], props) || '';
|
|
68
|
+
};
|
|
69
|
+
const vheight = (strings, size) => {
|
|
70
|
+
const propType = strings[0];
|
|
71
|
+
const calc = (strings[1] || "").replace(";", "").trim();
|
|
72
|
+
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 ");
|
|
73
|
+
};
|
|
74
|
+
const getFrameOffset = (i, total) => Math.round(i * 100 / (total - 1));
|
|
75
|
+
const oneWayAnimation = function () {
|
|
76
|
+
for (var _len = arguments.length, frames = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
77
|
+
frames[_key] = arguments[_key];
|
|
78
|
+
}
|
|
79
|
+
return animationKeyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", ""])), frames.map((frame, i) => !frame ? '' : "".concat(getFrameOffset(i, frames.length), "% {\n ").concat(frame, "\n }")));
|
|
80
|
+
};
|
|
81
|
+
const twoWayAnimation = function () {
|
|
82
|
+
for (var _len2 = arguments.length, frames = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
83
|
+
frames[_key2] = arguments[_key2];
|
|
84
|
+
}
|
|
85
|
+
return [frames, _reverse(frames)].map(frames => oneWayAnimation(...frames));
|
|
86
|
+
};
|
|
87
|
+
const animationTiming = props => function () {
|
|
88
|
+
for (var _len3 = arguments.length, animations = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
|
|
89
|
+
animations[_key3] = arguments[_key3];
|
|
90
|
+
}
|
|
91
|
+
return animations.filter(_ => _).map(_ => _ + ' ' + props).join(',');
|
|
92
|
+
};
|
|
93
|
+
const identityTranslateFrames = oneWayAnimation('transform: translateY(0);', 'transform: translateY(0);');
|
|
94
|
+
const identityOpacityFrames = oneWayAnimation('opacity: 1;', 'opacity:1;');
|
|
95
|
+
function testSinglePath(props, path) {
|
|
96
|
+
if (typeof path === 'string') {
|
|
97
|
+
return !!_s.get(path, props);
|
|
98
|
+
} else if (typeof path === 'number') {
|
|
99
|
+
return !!props[path];
|
|
100
|
+
} else {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// ifProp na forma antiga (valor pronto, não template): devolve pass ou fail
|
|
106
|
+
const ifPropValue = (path, pass, fail) => function () {
|
|
107
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
108
|
+
let result = false;
|
|
109
|
+
if (Array.isArray(path)) {
|
|
110
|
+
result = path.every(p => testSinglePath(props, p));
|
|
111
|
+
} else if (typeof path === 'object') {
|
|
112
|
+
result = !Object.entries(path).find(_ref3 => {
|
|
113
|
+
let _ref4 = _slicedToArray(_ref3, 2),
|
|
114
|
+
k = _ref4[0],
|
|
115
|
+
v = _ref4[1];
|
|
116
|
+
return props[k] !== v;
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
result = testSinglePath(props, path);
|
|
120
|
+
}
|
|
121
|
+
return result ? pass : fail;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export { animationTiming, customTheme, getColor, getMargin, identityOpacityFrames, identityTranslateFrames, ifPropValue, oneWayAnimation, prop, twoWayAnimation, vheight };
|
|
125
|
+
//# sourceMappingURL=styledShared.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styledShared.mjs","sources":["../src/styledShared.js"],"sourcesContent":["// Helpers de estilo que não dependem de styled-components: valem na lib/ e na lib-yak/.\nimport _ from 'lodash/fp'\nimport {darken} from 'polished'\nimport {animationKeyframes} from './animationKeyframes'\nimport {_s} from './lodashUtils'\n\nexport const getColor = (propsOrColor, hover) => {\n if (propsOrColor === undefined) {\n return ({theme})=>theme.colors.gray150\n }\n if (typeof propsOrColor==='string') {\n return ({theme})=>theme.colors[propsOrColor] || propsOrColor\n }\n const {theme,...props} = propsOrColor\n if (props.dark) {\n return darken(0.1, getColor({theme, ..._.unset( 'dark', props)}))\n } else if (hover && props.hover) {\n return getColor({theme, color: props.hover})\n } else if (props.color) {\n return theme.colors[props.color] || props.color\n } else if (props.highlight) {\n return theme.colors.main\n } else if (props.alert) {\n return theme.colors.alert\n } else if (props.success) {\n return theme.colors.success\n } else {\n return theme.colors.gray150\n }\n}\n\nexport const getMargin = (enumeratedMargins) => (props) => enumeratedMargins[props.margin] || props.margin || enumeratedMargins['default'] || 0\n\n/**\n * Returns the value of `props[path]` or `defaultValue`\n * @example\n * const Button = styled.button`\n * color: ${prop('color', 'red')};\n * `\n */\nexport const prop = (path,defaultValue) =>\n (props = {}) => _.get(path.trim(), props) || defaultValue\n\nexport const customTheme = (type) =>\n (props = {}) => _.get([\"theme\",\"startlibs\",type], props) || ''\n\nexport const vheight = (strings,size) => {\n const propType = strings[0]\n const calc = (strings[1]||\"\").replace(\";\",\"\").trim()\n return `\n ${propType} ${calc ? `calc(${size}vh ${calc})` : `${size}vh`};\n ${propType} ${calc ? `calc(calc(var(--vh, 1vh) * ${size}) ${calc})` : `calc(var(--vh, 1vh) * ${size})`};\n `\n}\n\nconst getFrameOffset = (i,total) => Math.round(i*100/(total-1))\n\n\nexport const oneWayAnimation = (...frames) => {\n return animationKeyframes`\n ${frames.map((frame,i) =>\n !frame ? '' : `${getFrameOffset(i,frames.length)}% {\n ${frame}\n }`\n )}`\n}\n\nexport const twoWayAnimation = (...frames) => [frames,_.reverse(frames)].map((frames)=>oneWayAnimation(...frames))\n\nexport const animationTiming = (props) => (...animations) => animations.filter(_=>_).map(_=>_+' '+props).join(',')\n\nexport const identityTranslateFrames = oneWayAnimation('transform: translateY(0);', 'transform: translateY(0);')\nexport const identityOpacityFrames = oneWayAnimation('opacity: 1;', 'opacity:1;')\n\nfunction testSinglePath(props,path) {\n if (typeof path === 'string') {\n return !!_s.get(path, props)\n } else if (typeof path === 'number') {\n return !!props[path]\n } else {\n return false\n }\n}\n\n// ifProp na forma antiga (valor pronto, não template): devolve pass ou fail\nexport const ifPropValue = (path, pass, fail) => (props = {}) => {\n let result = false\n if (Array.isArray(path)) {\n result = path.every(p=> testSinglePath(props,p))\n } else if (typeof path === 'object') {\n result = !Object.entries(path).find(([k,v])=>props[k]!==v)\n } else {\n result = testSinglePath(props,path)\n }\n return result ? pass : fail\n}\n"],"names":["_templateObject","_excluded","ownKeys","e","r","t","Object","keys","getOwnPropertySymbols","o","filter","getOwnPropertyDescriptor","enumerable","push","apply","_objectSpread","arguments","length","forEach","_defineProperty","getOwnPropertyDescriptors","defineProperties","defineProperty","getColor","propsOrColor","hover","undefined","_ref","theme","colors","gray150","_ref2","props","_objectWithoutProperties","dark","darken","_unset","color","highlight","main","alert","success","getMargin","enumeratedMargins","margin","prop","path","defaultValue","_get","trim","customTheme","type","vheight","strings","size","propType","calc","replace","concat","getFrameOffset","i","total","Math","round","oneWayAnimation","_len","frames","Array","_key","animationKeyframes","_taggedTemplateLiteral","map","frame","twoWayAnimation","_len2","_key2","_reverse","animationTiming","_len3","animations","_key3","_","join","identityTranslateFrames","identityOpacityFrames","testSinglePath","_s","get","ifPropValue","pass","fail","result","isArray","every","p","entries","find","_ref3","_ref4","_slicedToArray","k","v"],"mappings":";;;;;;;;;;;AAAA,IAAAA,eAAA,CAAA;AAAA,MAAAC,SAAA,GAAA,CAAA,OAAA,CAAA,CAAA;AAAA,SAAAC,OAAAA,CAAAC,CAAA,EAAAC,CAAA,EAAA,EAAA,IAAAC,CAAA,GAAAC,MAAA,CAAAC,IAAA,CAAAJ,CAAA,OAAAG,MAAA,CAAAE,qBAAA,EAAA,EAAA,IAAAC,CAAA,GAAAH,MAAA,CAAAE,qBAAA,CAAAL,CAAA,CAAA,CAAA,CAAAC,CAAA,KAAAK,CAAA,GAAAA,CAAA,CAAAC,MAAA,CAAAN,UAAAA,CAAA,EAAAE,EAAAA,OAAAA,MAAA,CAAAK,wBAAA,CAAAR,CAAA,EAAAC,CAAA,EAAAQ,UAAA,CAAA,EAAA,CAAA,CAAA,EAAAP,CAAA,CAAAQ,IAAA,CAAAC,KAAA,CAAAT,CAAA,EAAAI,CAAA,CAAA,CAAA,EAAA,CAAA,OAAAJ,CAAA,CAAA,EAAA;AAAA,SAAAU,cAAAZ,CAAA,EAAA,EAAA,KAAA,IAAAC,CAAA,GAAAA,CAAAA,EAAAA,CAAA,GAAAY,SAAA,CAAAC,MAAA,EAAAb,CAAA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,GAAGA,CAAC1C,IAAI,EAAE2C,IAAI,EAAEC,IAAI,KAAK,YAAgB;AAAA,EAAA,IAAf1D,KAAK,GAAAhB,SAAA,CAAAC,MAAA,GAAA,CAAA,IAAAD,SAAA,CAAA,CAAA,CAAA,KAAAU,SAAA,GAAAV,SAAA,CAAA,CAAA,CAAA,GAAG,EAAE,CAAA;EAC1D,IAAI2E,MAAM,GAAG,KAAK,CAAA;AAClB,EAAA,IAAIxB,KAAK,CAACyB,OAAO,CAAC9C,IAAI,CAAC,EAAE;AACvB6C,IAAAA,MAAM,GAAG7C,IAAI,CAAC+C,KAAK,CAACC,CAAC,IAAGT,cAAc,CAACrD,KAAK,EAAC8D,CAAC,CAAC,CAAC,CAAA;AAClD,GAAC,MAAM,IAAI,OAAOhD,IAAI,KAAK,QAAQ,EAAE;IACnC6C,MAAM,GAAG,CAACrF,MAAM,CAACyF,OAAO,CAACjD,IAAI,CAAC,CAACkD,IAAI,CAACC,KAAA,IAAA;AAAA,MAAA,IAAAC,KAAA,GAAAC,cAAA,CAAAF,KAAA,EAAA,CAAA,CAAA;AAAEG,QAAAA,CAAC,GAAAF,KAAA,CAAA,CAAA,CAAA;AAACG,QAAAA,CAAC,GAAAH,KAAA,CAAA,CAAA,CAAA,CAAA;AAAA,MAAA,OAAIlE,KAAK,CAACoE,CAAC,CAAC,KAAGC,CAAC,CAAA;KAAC,CAAA,CAAA;AAC5D,GAAC,MAAM;AACLV,IAAAA,MAAM,GAAGN,cAAc,CAACrD,KAAK,EAACc,IAAI,CAAC,CAAA;AACrC,GAAA;AACA,EAAA,OAAO6C,MAAM,GAAGF,IAAI,GAAGC,IAAI,CAAA;AAC7B;;;;"}
|
package/lib/timerUtils.mjs
CHANGED
package/lib/timerUtils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timerUtils.mjs","sources":["../src/timerUtils.jsx"],"sourcesContent":["import React from 'react'\
|
|
1
|
+
{"version":3,"file":"timerUtils.mjs","sources":["../src/timerUtils.jsx"],"sourcesContent":["import React from 'react'\n\nexport const timerPromise = (time) => new Promise((res) => setTimeout(res,time))\n\nexport const cancelableTimer = (res,time) => {\n const v = setTimeout(res,time)\n return () => clearTimeout(v)\n}\n"],"names":["timerPromise","time","Promise","res","setTimeout","cancelableTimer","v","clearTimeout"],"mappings":";;MAEaA,YAAY,GAAIC,IAAI,IAAK,IAAIC,OAAO,CAAEC,GAAG,IAAKC,UAAU,CAACD,GAAG,EAACF,IAAI,CAAC,EAAC;MAEnEI,eAAe,GAAGA,CAACF,GAAG,EAACF,IAAI,KAAK;AAC3C,EAAA,MAAMK,CAAC,GAAGF,UAAU,CAACD,GAAG,EAACF,IAAI,CAAC,CAAA;AAC9B,EAAA,OAAO,MAAMM,YAAY,CAACD,CAAC,CAAC,CAAA;AAC9B;;;;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import isPropValid from '@emotion/is-prop-valid';
|
|
3
|
+
|
|
4
|
+
// Task 13c: @yak/react só filtra props `$`-prefixadas e `undefined` antes de repassar pro
|
|
5
|
+
// elemento real; qualquer prop custom (string, número, objeto) lida por um `styled.<tag>` no yak
|
|
6
|
+
// vaza como atributo no DOM. styled-components v5 evita isso sozinho pra tags string, usando
|
|
7
|
+
// @emotion/is-prop-valid. yakDomTag(tag) devolve um componente equivalente: filtra pelas mesmas
|
|
8
|
+
// regras antes de renderizar `tag`, pra o DOM do yak ficar idêntico ao do sc.
|
|
9
|
+
//
|
|
10
|
+
// Resolvido via `@startlibs/utils/yakDomTag` (exports["./*"] do package.json) — não passa pelo
|
|
11
|
+
// index: só existe nessa saída porque o babel-plugin-startlibs-to-yak importa explicitamente
|
|
12
|
+
// (ver tools/babel-plugin-startlibs-to-yak/domTag.cjs), nunca no fonte sc.
|
|
13
|
+
//
|
|
14
|
+
// Memoizado por nome de tag: `styled(yakDomTag('div'))` precisa devolver sempre o MESMO
|
|
15
|
+
// componente de DOM final pra identidade ficar estável entre `${X}` e composições
|
|
16
|
+
// (`styled(X)`/`styledExtend(X)`) de um mesmo `styled.div` — ver @yak/react runtime, que carrega
|
|
17
|
+
// esse componente até o fim da cadeia de composição.
|
|
18
|
+
//
|
|
19
|
+
// `as` (styled-components troca a tag renderizada com essa prop, ex.: components/src/containers/
|
|
20
|
+
// usePositioning.jsx's Placeholder as={placeholderAs}, form/src/TextInput.jsx's Input
|
|
21
|
+
// as={inputTag}) não é filtrada pelo @emotion/is-prop-valid (`isPropValid('as')` é false) — sem
|
|
22
|
+
// tratar à parte, o yak renderizaria sempre a tag original, ignorando a troca.
|
|
23
|
+
const cache = new Map();
|
|
24
|
+
const yakDomTag = tag => {
|
|
25
|
+
let Component = cache.get(tag);
|
|
26
|
+
if (!Component) {
|
|
27
|
+
Component = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
28
|
+
const domProps = {};
|
|
29
|
+
for (const key in props) {
|
|
30
|
+
// `as` troca a tag renderizada (como styled-components faz); não é uma prop do DOM.
|
|
31
|
+
if (key === 'as') continue;
|
|
32
|
+
if (key === 'className' || isPropValid(key)) domProps[key] = props[key];
|
|
33
|
+
}
|
|
34
|
+
domProps.ref = ref;
|
|
35
|
+
return /*#__PURE__*/React.createElement(props.as || tag, domProps);
|
|
36
|
+
});
|
|
37
|
+
Component.displayName = "yakDomTag(".concat(tag, ")");
|
|
38
|
+
cache.set(tag, Component);
|
|
39
|
+
}
|
|
40
|
+
return Component;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { yakDomTag };
|
|
44
|
+
//# sourceMappingURL=yakDomTag.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yakDomTag.mjs","sources":["../src/yakDomTag.jsx"],"sourcesContent":["import React from 'react'\nimport isPropValid from '@emotion/is-prop-valid'\n\n// Task 13c: @yak/react só filtra props `$`-prefixadas e `undefined` antes de repassar pro\n// elemento real; qualquer prop custom (string, número, objeto) lida por um `styled.<tag>` no yak\n// vaza como atributo no DOM. styled-components v5 evita isso sozinho pra tags string, usando\n// @emotion/is-prop-valid. yakDomTag(tag) devolve um componente equivalente: filtra pelas mesmas\n// regras antes de renderizar `tag`, pra o DOM do yak ficar idêntico ao do sc.\n//\n// Resolvido via `@startlibs/utils/yakDomTag` (exports[\"./*\"] do package.json) — não passa pelo\n// index: só existe nessa saída porque o babel-plugin-startlibs-to-yak importa explicitamente\n// (ver tools/babel-plugin-startlibs-to-yak/domTag.cjs), nunca no fonte sc.\n//\n// Memoizado por nome de tag: `styled(yakDomTag('div'))` precisa devolver sempre o MESMO\n// componente de DOM final pra identidade ficar estável entre `${X}` e composições\n// (`styled(X)`/`styledExtend(X)`) de um mesmo `styled.div` — ver @yak/react runtime, que carrega\n// esse componente até o fim da cadeia de composição.\n//\n// `as` (styled-components troca a tag renderizada com essa prop, ex.: components/src/containers/\n// usePositioning.jsx's Placeholder as={placeholderAs}, form/src/TextInput.jsx's Input\n// as={inputTag}) não é filtrada pelo @emotion/is-prop-valid (`isPropValid('as')` é false) — sem\n// tratar à parte, o yak renderizaria sempre a tag original, ignorando a troca.\nconst cache = new Map()\n\nexport const yakDomTag = (tag) => {\n let Component = cache.get(tag)\n if (!Component) {\n Component = React.forwardRef((props, ref) => {\n const domProps = {}\n for (const key in props) {\n // `as` troca a tag renderizada (como styled-components faz); não é uma prop do DOM.\n if (key === 'as') continue\n if (key === 'className' || isPropValid(key)) domProps[key] = props[key]\n }\n domProps.ref = ref\n return React.createElement(props.as || tag, domProps)\n })\n Component.displayName = `yakDomTag(${tag})`\n cache.set(tag, Component)\n }\n return Component\n}\n"],"names":["cache","Map","yakDomTag","tag","Component","get","React","forwardRef","props","ref","domProps","key","isPropValid","createElement","as","displayName","concat","set"],"mappings":";;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,KAAK,GAAG,IAAIC,GAAG,EAAE,CAAA;AAEVC,MAAAA,SAAS,GAAIC,GAAG,IAAK;AAChC,EAAA,IAAIC,SAAS,GAAGJ,KAAK,CAACK,GAAG,CAACF,GAAG,CAAC,CAAA;EAC9B,IAAI,CAACC,SAAS,EAAE;IACdA,SAAS,gBAAGE,KAAK,CAACC,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;MAC3C,MAAMC,QAAQ,GAAG,EAAE,CAAA;AACnB,MAAA,KAAK,MAAMC,GAAG,IAAIH,KAAK,EAAE;AACvB;QACA,IAAIG,GAAG,KAAK,IAAI,EAAE,SAAA;AAClB,QAAA,IAAIA,GAAG,KAAK,WAAW,IAAIC,WAAW,CAACD,GAAG,CAAC,EAAED,QAAQ,CAACC,GAAG,CAAC,GAAGH,KAAK,CAACG,GAAG,CAAC,CAAA;AACzE,OAAA;MACAD,QAAQ,CAACD,GAAG,GAAGA,GAAG,CAAA;MAClB,oBAAOH,KAAK,CAACO,aAAa,CAACL,KAAK,CAACM,EAAE,IAAIX,GAAG,EAAEO,QAAQ,CAAC,CAAA;AACvD,KAAC,CAAC,CAAA;AACFN,IAAAA,SAAS,CAACW,WAAW,GAAA,YAAA,CAAAC,MAAA,CAAgBb,GAAG,EAAG,GAAA,CAAA,CAAA;AAC3CH,IAAAA,KAAK,CAACiB,GAAG,CAACd,GAAG,EAAEC,SAAS,CAAC,CAAA;AAC3B,GAAA;AACA,EAAA,OAAOA,SAAS,CAAA;AAClB;;;;"}
|