@ikas/bp-storefront 1.4.0-beta.125 → 1.4.0-beta.126
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var n=new RegExp(["[A-Z]?[a-z]+","[0-9]*(?:1ST|2ND|3RD|(?![123])[0-9]TH)(?=\\b|[a-z_])","[0-9]*(?:1st|2nd|3rd|(?![123])[0-9]th)(?=\\b|[A-Z_])","[A-Z]+(?![a-z])","[0-9]+","[A-Z]"].join("|"),"g");function e(e){return(String(e).match(n)||[]).map(function(n,e){var i=n.toLowerCase();return 0===e?i:i.charAt(0).toUpperCase()+i.slice(1)}).join("")}var i={settings:{},colors:[],typography:[],breakpoints:[],keyframes:[],colorSchemes:{schemes:[],values:[]}},r=function(n){return"var(--".concat(e(n),")")},l=function(n){return"_".concat(n)},t=function(n){return"bp(".concat(n,")")},u=function(n){return n.map(function(n){return{id:n.id,width:Number(n.width)||0}})},a=/\d*\.?\d+(?:e[+-]?\d+)?px|\d*\.?\d+(?:e[+-]?\d+)?|[()+\-*/]|\S/gi,o=function(n,e){var i=s(n,e);return i&&d(n,e,i)},d=function(n,e,i){var r=n[e.i];if("+"!==r&&"-"!==r)return i;e.i+=1;var l=s(n,e);return l&&l.isPx===i.isPx?d(n,e,{n:"+"===r?i.n+l.n:i.n-l.n,isPx:i.isPx}):null},s=function(n,e){var i=c(n,e);return i&&v(n,e,i)},v=function(n,e,i){var r=n[e.i];if("*"!==r&&"/"!==r)return i;e.i+=1;var l=c(n,e);return l?"*"===r?i.isPx&&l.isPx?null:v(n,e,{n:i.n*l.n,isPx:i.isPx||l.isPx}):l.isPx||0===l.n?null:v(n,e,{n:i.n/l.n,isPx:i.isPx}):null},c=function(n,e){var i,r=n[e.i];return"-"===r?(e.i+=1,(i=c(n,e))&&{n:-i.n,isPx:i.isPx}):"+"===r?(e.i+=1,c(n,e)):"("===r?(e.i+=1,(i=o(n,e))&&")"===n[e.i]?(e.i+=1,i):null):"object"==typeof r&&null!==r?(e.i+=1,r):null},f=function(n){var e=function(n){var e=(n.match(a)||[]).map(function(n){return/^\d*\.?\d+(?:e[+-]?\d+)?px$/i.test(n)?{n:parseFloat(n),isPx:!0}:/^\d*\.?\d+(?:e[+-]?\d+)?$/i.test(n)?{n:parseFloat(n),isPx:!1}:"()+-*/".includes(n)?n:null});return e.every(function(n){return null!==n})?e:null}(n.replace(/calc\(/gi,"("));if(!e)return null;var i={i:0},r=o(e,i);return r&&r.isPx&&i.i===e.length&&Number.isFinite(r.n)&&Math.abs(r.n)<1e8?r.n:null},m=function(n,e,i,r){if(e>=n.length||e>r)return-1;var l=n[e],t="("===l?i+1:")"===l?i-1:i;return 0===t?e:m(n,e+1,t,r)},p=function(n,e){return e.reduce(function(n,e){return n.split(t(e.id)).join("".concat(e.width,"px"))},n)},h=/^-(?:webkit|moz|ms|o)-$/i,y=/[-A-Za-z0-9_]+$/,x=function(n,e,i){var r=n.indexOf("bp(",i);if(-1===r)return n;var l=Math.max(i,r-512-5),t=n.slice(l,r+5).indexOf("calc("),u=-1===t?-1:l+t;if(-1===u||u>r)return x(n,e,r+3);var a=y.exec(n.slice(Math.max(0,u-12),u)),o=a?a[0]:"",d=h.test(o)&&!y.test(n.slice(u-o.length-1,u-o.length));if(o&&!d)return x(n,e,u+5);var s=d?u-o.length:u,v=u+4,c=m(n,v,0,v+512);if(-1===c)return x(n,e,u+5);if(c<r)return x(n,e,c+1);var g=p(n.slice(v+1,c),e),b=f(g);if(null===b)return x(n,e,u+5);var P="".concat(parseFloat(b.toFixed(4)),"px");return x(n.slice(0,s)+P+n.slice(c+1),e,s+P.length)};function g(n,e){if(!n||!n.includes("bp("))return n;var i=x(n,e,0);return i.includes("bp(")?p(i,e):i}var b=function(n){var e;if(n)return Array.isArray(n)?null===(e=n[0])||void 0===e?void 0:e.value:n},P=function(n){var e,i=n;if(!i)return null;if(i.patternValueId)return r(i.patternValueId);if(i.colorSchemeId)return r(i.colorSchemeId);if(i.keyframeValueId)return l(i.keyframeValueId);var t=i.value;return null==t?null:"object"==typeof t?"string"==typeof t.css?t.css:null!=t.value?"".concat(t.value).concat(null!==(e=t.unit)&&void 0!==e?e:""):null:String(t)},S=/^__.+__$/,N=function(n){return S.test(null!=n?n:"")};function A(n){var t,u,a,o,d,s,v,c,f,m,p,h,y,x,g,S;if(!n)return i;for(var A=null===(t=n.theme)||void 0===t?void 0:t.pattern,I={},k=0,V=null!==(o=null===(a=null===(u=n.globalsBlueprint)||void 0===u?void 0:u.module)||void 0===a?void 0:a.variables)&&void 0!==o?o:[];k<V.length;k++){var w=V[k];if(!1!==w.isGlobal&&w.variableName&&(!N(w.id)&&!N(w.variableName))){var _=null!==(d=w.variableType)&&void 0!==d?d:"TEXT";I[w.variableName]={name:w.variableName,displayName:null!==(s=w.displayName)&&void 0!==s?s:w.variableName,type:_,value:"BOOLEAN"===_?!!w.defaultValue:null!==(v=w.defaultValue)&&void 0!==v?v:null}}}var D=(null!==(c=null==A?void 0:A.values)&&void 0!==c?c:[]).map(function(n){var e,i;return{id:n.id,name:null!==(e=n.name)&&void 0!==e?e:n.id,resolved:P(b(null===(i=n.style)||void 0===i?void 0:i.value)),cssVar:r(n.id)}}),j=function(n){return(null!=n?n:[]).map(function(n){return{property:n.property,value:P(b(n.value))}}).filter(function(n){return null!=n.value})},z=(null!==(f=null==A?void 0:A.elements)&&void 0!==f?f:[]).map(function(n){for(var i,r={},t=0,u=j(n.styles);t<u.length;t++){var a=u[t],o=a.property,d=a.value;r[e(o)]=d}return{id:n.id,name:null!==(i=n.name)&&void 0!==i?i:n.id,resolved:r,className:l(n.id),isDefault:!!n.isDefault}}),F=(null!==(p=null===(m=n.theme)||void 0===m?void 0:m.breakpoints)&&void 0!==p?p:[]).map(function(n){var e,i;return{id:n.id,name:null!==(e=n.name)&&void 0!==e?e:n.id,width:null!==(i=n.width)&&void 0!==i?i:0}}),T=(null!==(y=null===(h=n.theme)||void 0===h?void 0:h.keyframes)&&void 0!==y?y:[]).map(function(n){var e,i,r;return{id:n.id,name:null!==(e=n.name)&&void 0!==e?e:n.id,type:null!==(i=n.type)&&void 0!==i?i:"keyframe",ref:l(n.id),settings:j(n.styles),points:(null!==(r=n.points)&&void 0!==r?r:[]).map(function(n){return{point:n.point,styles:j(n.styles)}})}}),Z=(null!==(x=null==A?void 0:A.colorSchemes)&&void 0!==x?x:[]).map(function(n){var e;return{id:n.id,name:null!==(e=n.name)&&void 0!==e?e:n.id}}),$=null!==(g=null==A?void 0:A.colorSchemes)&&void 0!==g?g:[],O=null!==(S=null==A?void 0:A.colorSchemeValues)&&void 0!==S?S:[],B=O.map(function(n){for(var e,i,t,u,a=function(n){var e,i;return null!==(i=null===(e=O.find(function(e){return e.isDefault&&(n?e.designAssetId===n:!e.designAssetId)}))||void 0===e?void 0:e.colors)&&void 0!==i?i:[]}(n.designAssetId),o={},d=function(l){var u=null===(e=n.colors)||void 0===e?void 0:e.find(function(n){return n.colorSchemeId===l.id}),d=u?void 0:a.find(function(n){return n.colorSchemeId===l.id});o[l.id]={resolved:null!==(t=P(null!==(i=null==u?void 0:u.style)&&void 0!==i?i:null==d?void 0:d.style))&&void 0!==t?t:"#ffffff",cssVar:r(l.id)}},s=0,v=$;s<v.length;s++){d(v[s])}return{id:n.id,name:null!==(u=n.name)&&void 0!==u?u:n.id,isDefault:!!n.isDefault,className:l(n.id),colorsByScheme:o}});return{settings:I,colors:D,typography:z,breakpoints:F,keyframes:T,colorSchemes:{schemes:Z,values:B}}}export{i as EMPTY_THEME_GLOBALS,t as breakpointCssToken,e as cssVarCamelCase,r as cssVarRef,N as isReservedVariableId,l as rawClassRef,g as resolveBreakpointMediaTokens,A as serializeThemeGlobals,u as toResolverBreakpoints};
|
|
@@ -271,6 +271,18 @@ export declare const toResolverBreakpoints: (breakpoints: {
|
|
|
271
271
|
* (code-generator, editor canvas). Unknown ids are left untouched (the partner dependency
|
|
272
272
|
* collector ships referenced breakpoints into the target theme, so a real token always resolves).
|
|
273
273
|
* The `bp(<id>)` literal carries its own `)` boundary, so one id is never matched inside another.
|
|
274
|
+
*
|
|
275
|
+
* A `calc()` containing a bp token (e.g. the documented exclusive boundary
|
|
276
|
+
* `calc(bp(<id>) + 1px)`, but any pure px arithmetic: `calc(bp(a) * 2 + 10px)`,
|
|
277
|
+
* `calc(bp(a) - bp(b))`, `-webkit-calc(...)`, …) is folded to a single computed `<width>px`
|
|
278
|
+
* literal, never emitted as `calc()`: csso — the code-generator's minifier for inline/base
|
|
279
|
+
* page styles — silently drops a media block whose condition contains `calc()`, and older
|
|
280
|
+
* browsers (e.g. Safari < 16.4) don't evaluate `calc()` in media conditions either.
|
|
281
|
+
*
|
|
282
|
+
* Folding limits (an out-of-limit calc degrades to plain token substitution, keeping its
|
|
283
|
+
* `calc()` form — which csso will still drop from a media condition): bodies longer than
|
|
284
|
+
* CALC_SCAN_LIMIT chars; an uppercase `CALC(` keyword (the scan is lowercase, matching every
|
|
285
|
+
* compiled-CSS emitter); `calc(` inside a string/comment can confuse the plain-text scan.
|
|
274
286
|
*/
|
|
275
287
|
export declare function resolveBreakpointMediaTokens(css: string, breakpoints: {
|
|
276
288
|
id: string;
|