@chromatic-com/storybook 5.0.2 → 5.1.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -105,8 +105,12 @@ interface ChromaticParameters {
105
105
  viewports?: number[];
106
106
  };
107
107
  }
108
+ interface ChromaticGlobals {
109
+ ignoredRegions?: boolean;
110
+ }
108
111
  interface ChromaticTypes {
109
112
  parameters: ChromaticParameters;
113
+ globals: ChromaticGlobals;
110
114
  }
111
115
 
112
116
  declare const _default: () => storybook_internal_csf.PreviewAddon<ChromaticTypes>;
package/dist/index.js CHANGED
@@ -1,7 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var csf = require('storybook/internal/csf');
4
+ var highlight = require('storybook/highlight');
5
+ var previewApi = require('storybook/preview-api');
4
6
 
5
- var r=()=>csf.definePreviewAddon({});
7
+ var T=Object.defineProperty;var x=(o,n)=>{for(var r in n)T(o,r,{get:n[r],enumerable:!0});};var h={};x(h,{decorators:()=>b,initialGlobals:()=>F});process.env;var t="chromaui/addon-visual-tests";var p="highlightIgnored",c=`${t}/highlightIgnored`,d=`${t}/highlightIgnored/count`,_=`${t}/highlightIgnored/select`,E=['[data-chromatic="ignore"]','[class~="chromatic-ignore"]'];var G={backgroundColor:"rgba(255, 173, 51, 0.2)",outline:"1px solid rgba(255, 173, 51, 0.7)",outlineOffset:"-1px"},R={backgroundColor:"rgba(255, 173, 51, 0.1)",outlineWidth:"2px"},S={backgroundColor:"transparent",outlineWidth:"2px"},L=o=>{if(!o)return !1;if(typeof document>"u")return !0;try{return document.createDocumentFragment().querySelector(o),!0}catch{return console.warn(`Invalid ignoreSelector: ${o}`),!1}},u=o=>{let n=o?.ignoreSelectors??[],r=Array.from(new Set(E.concat(n.filter(L))));return {id:c,selectors:r,styles:G,hoverStyles:R,focusStyles:S,menu:r.map(e=>{let l=E.includes(e);return [{id:`${e}-info`,title:"Element ignored in visual tests",description:l?`${e} will be ignored by Chromatic`:`${e} matches an ignored selector`,selectors:[e]},{id:`${e}-link`,iconLeft:"info",iconRight:"shareAlt",title:"Learn how to configure ignored elements",clickEvent:_,selectors:[e]}]})}};var N=(o,{globals:n,parameters:r,id:e})=>{let l=!!n[p],s=previewApi.useChannel({}),i=u(r.chromatic),O=i?.selectors.join(`
8
+ `)??"";return previewApi.useEffect(()=>{if(s(highlight.REMOVE_HIGHLIGHT,c),!i?.selectors.length){s(d,0);return}l&&s(highlight.HIGHLIGHT,i);let H=document.getElementById("storybook-root"),C=i.selectors.reduce((a,g)=>(document.querySelectorAll(`:is(${g}):not([id^="storybook-"], [id^="storybook-"] *, [class^="sb-"], [class^="sb-"] *)`).forEach(I=>a.add(I)),(H?.querySelectorAll(g)??[]).forEach(I=>a.add(I)),a),new Set);return s(d,C.size),()=>s(highlight.REMOVE_HIGHLIGHT,c)},[s,i,e,O,l]),o()},b=[N],F={[p]:!1};var gt=()=>csf.definePreviewAddon(h);
6
9
 
7
- module.exports = r;
10
+ module.exports = gt;
package/dist/index.mjs CHANGED
@@ -1,5 +1,8 @@
1
1
  import { definePreviewAddon } from 'storybook/internal/csf';
2
+ import { REMOVE_HIGHLIGHT, HIGHLIGHT } from 'storybook/highlight';
3
+ import { useChannel, useEffect } from 'storybook/preview-api';
2
4
 
3
- var r=()=>definePreviewAddon({});
5
+ var T=Object.defineProperty;var x=(o,n)=>{for(var r in n)T(o,r,{get:n[r],enumerable:!0});};var h={};x(h,{decorators:()=>b,initialGlobals:()=>F});process.env;var t="chromaui/addon-visual-tests";var p="highlightIgnored",c=`${t}/highlightIgnored`,d=`${t}/highlightIgnored/count`,_=`${t}/highlightIgnored/select`,E=['[data-chromatic="ignore"]','[class~="chromatic-ignore"]'];var G={backgroundColor:"rgba(255, 173, 51, 0.2)",outline:"1px solid rgba(255, 173, 51, 0.7)",outlineOffset:"-1px"},R={backgroundColor:"rgba(255, 173, 51, 0.1)",outlineWidth:"2px"},S={backgroundColor:"transparent",outlineWidth:"2px"},L=o=>{if(!o)return !1;if(typeof document>"u")return !0;try{return document.createDocumentFragment().querySelector(o),!0}catch{return console.warn(`Invalid ignoreSelector: ${o}`),!1}},u=o=>{let n=o?.ignoreSelectors??[],r=Array.from(new Set(E.concat(n.filter(L))));return {id:c,selectors:r,styles:G,hoverStyles:R,focusStyles:S,menu:r.map(e=>{let l=E.includes(e);return [{id:`${e}-info`,title:"Element ignored in visual tests",description:l?`${e} will be ignored by Chromatic`:`${e} matches an ignored selector`,selectors:[e]},{id:`${e}-link`,iconLeft:"info",iconRight:"shareAlt",title:"Learn how to configure ignored elements",clickEvent:_,selectors:[e]}]})}};var N=(o,{globals:n,parameters:r,id:e})=>{let l=!!n[p],s=useChannel({}),i=u(r.chromatic),O=i?.selectors.join(`
6
+ `)??"";return useEffect(()=>{if(s(REMOVE_HIGHLIGHT,c),!i?.selectors.length){s(d,0);return}l&&s(HIGHLIGHT,i);let H=document.getElementById("storybook-root"),C=i.selectors.reduce((a,g)=>(document.querySelectorAll(`:is(${g}):not([id^="storybook-"], [id^="storybook-"] *, [class^="sb-"], [class^="sb-"] *)`).forEach(I=>a.add(I)),(H?.querySelectorAll(g)??[]).forEach(I=>a.add(I)),a),new Set);return s(d,C.size),()=>s(REMOVE_HIGHLIGHT,c)},[s,i,e,O,l]),o()},b=[N],F={[p]:!1};var gt=()=>definePreviewAddon(h);
4
7
 
5
- export { r as default };
8
+ export { gt as default };