@storybook/addon-highlight 7.0.0-alpha.38 → 7.0.0-alpha.40
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/chunk-TYHA7QJZ.mjs +1 -0
- package/dist/highlight.d.ts +9 -0
- package/dist/highlight.js +7 -0
- package/dist/highlight.mjs +7 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +27 -8
- package/preview.js +1 -1
- package/dist/cjs/constants.js +0 -14
- package/dist/cjs/highlight.js +0 -69
- package/dist/cjs/index.js +0 -28
- package/dist/esm/constants.js +0 -4
- package/dist/esm/highlight.js +0 -50
- package/dist/esm/index.js +0 -8
- package/dist/types/constants.d.ts +0 -4
- package/dist/types/highlight.d.ts +0 -8
- package/dist/types/index.d.ts +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var o="storybook/highlight",H="storybookHighlight",I=`${o}/add`,r=`${o}/reset`;export{H as a,I as b,r as c};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare type OutlineStyle = 'dotted' | 'dashed' | 'solid' | 'double';
|
|
2
|
+
declare const highlightStyle: (color?: string, style?: OutlineStyle) => string;
|
|
3
|
+
declare const highlightObject: (color: string) => {
|
|
4
|
+
outline: string;
|
|
5
|
+
outlineOffset: number;
|
|
6
|
+
boxShadow: string;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { highlightObject, highlightStyle };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
var x=Object.create;var i=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var f=Object.getPrototypeOf,y=Object.prototype.hasOwnProperty;var S=(e,t)=>{for(var o in t)i(e,o,{get:t[o],enumerable:!0})},c=(e,t,o,l)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of T(t))!y.call(e,n)&&n!==o&&i(e,n,{get:()=>t[n],enumerable:!(l=G(t,n))||l.enumerable});return e};var b=(e,t,o)=>(o=e!=null?x(f(e)):{},c(t||!e||!e.__esModule?i(o,"default",{value:e,enumerable:!0}):o,e)),E=e=>c(i({},"__esModule",{value:!0}),e);var O={};S(O,{highlightObject:()=>L,highlightStyle:()=>u});module.exports=E(O);var p=b(require("global")),a=require("@storybook/addons"),I=require("@storybook/core-events");var g="storybook/highlight",s="storybookHighlight",H=`${g}/add`,m=`${g}/reset`;var{document:h}=p.default,u=(e="#FF4785",t="dashed")=>`
|
|
2
|
+
outline: 2px ${t} ${e};
|
|
3
|
+
outline-offset: 2px;
|
|
4
|
+
box-shadow: 0 0 0 6px rgba(255,255,255,0.6);
|
|
5
|
+
`,L=e=>({outline:`2px dashed ${e}`,outlineOffset:2,boxShadow:"0 0 0 6px rgba(255,255,255,0.6)"});module&&module.hot&&module.hot.decline&&module.hot.decline();var r=a.addons.getChannel(),_=e=>{let t=s;d();let o=Array.from(new Set(e.elements)),l=h.createElement("style");l.setAttribute("id",t),l.innerHTML=o.map(n=>`${n}{
|
|
6
|
+
${u(e.color,e.style)}
|
|
7
|
+
}`).join(" "),h.head.appendChild(l)},d=()=>{let e=s,t=h.getElementById(e);t&&t.parentNode.removeChild(t)};r.on(I.STORY_CHANGED,d);r.on(m,d);r.on(H,_);0&&(module.exports={highlightObject,highlightStyle});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{a as n,b as h,c as s}from"./chunk-TYHA7QJZ.mjs";import c from"global";import{addons as g}from"@storybook/addons";import{STORY_CHANGED as a}from"@storybook/core-events";var{document:l}=c,p=(e="#FF4785",t="dashed")=>`
|
|
2
|
+
outline: 2px ${t} ${e};
|
|
3
|
+
outline-offset: 2px;
|
|
4
|
+
box-shadow: 0 0 0 6px rgba(255,255,255,0.6);
|
|
5
|
+
`,S=e=>({outline:`2px dashed ${e}`,outlineOffset:2,boxShadow:"0 0 0 6px rgba(255,255,255,0.6)"});module&&module.hot&&module.hot.decline&&module.hot.decline();var i=g.getChannel(),u=e=>{let t=n;d();let r=Array.from(new Set(e.elements)),o=l.createElement("style");o.setAttribute("id",t),o.innerHTML=r.map(m=>`${m}{
|
|
6
|
+
${p(e.color,e.style)}
|
|
7
|
+
}`).join(" "),l.head.appendChild(o)},d=()=>{let e=n,t=l.getElementById(e);t&&t.parentNode.removeChild(t)};i.on(a,d);i.on(s,d);i.on(h,u);export{S as highlightObject,p as highlightStyle};
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var I=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var s=(t,o)=>{for(var H in o)I(t,H,{get:o[H],enumerable:!0})},c=(t,o,H,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of T(o))!i.call(t,e)&&e!==H&&I(t,e,{get:()=>o[e],enumerable:!(r=h(o,e))||r.enumerable});return t};var n=t=>c(I({},"__esModule",{value:!0}),t);var x={};s(x,{HIGHLIGHT:()=>d,RESET_HIGHLIGHT:()=>l,default:()=>p});module.exports=n(x);var G="storybook/highlight";var d=`${G}/add`,l=`${G}/reset`;module&&module.hot&&module.hot.decline&&module.hot.decline();var p={};0&&(module.exports={HIGHLIGHT,RESET_HIGHLIGHT});
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as e,c as o}from"./chunk-TYHA7QJZ.mjs";module&&module.hot&&module.hot.decline&&module.hot.decline();var l={};export{e as HIGHLIGHT,o as RESET_HIGHLIGHT,l as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/addon-highlight",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.40",
|
|
4
4
|
"description": "Highlight DOM nodes within your stories",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook-addons",
|
|
@@ -23,9 +23,22 @@
|
|
|
23
23
|
},
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"author": "winkerVSbecks",
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"require": "./dist/index.js",
|
|
29
|
+
"import": "./dist/index.mjs",
|
|
30
|
+
"types": "./dist/index.d.ts"
|
|
31
|
+
},
|
|
32
|
+
"./preview": {
|
|
33
|
+
"require": "./dist/highlight.js",
|
|
34
|
+
"import": "./dist/highlight.mjs",
|
|
35
|
+
"types": "./dist/highlight.d.ts"
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
"main": "dist/index.js",
|
|
40
|
+
"module": "dist/index.mjs",
|
|
41
|
+
"types": "dist/index.d.ts",
|
|
29
42
|
"files": [
|
|
30
43
|
"dist/**/*",
|
|
31
44
|
"README.md",
|
|
@@ -34,11 +47,11 @@
|
|
|
34
47
|
],
|
|
35
48
|
"scripts": {
|
|
36
49
|
"check": "../../../scripts/node_modules/.bin/tsc --noEmit",
|
|
37
|
-
"prep": "
|
|
50
|
+
"prep": "../../../scripts/prepare/bundle.ts"
|
|
38
51
|
},
|
|
39
52
|
"dependencies": {
|
|
40
|
-
"@storybook/addons": "7.0.0-alpha.
|
|
41
|
-
"@storybook/core-events": "7.0.0-alpha.
|
|
53
|
+
"@storybook/addons": "7.0.0-alpha.40",
|
|
54
|
+
"@storybook/core-events": "7.0.0-alpha.40",
|
|
42
55
|
"global": "^4.4.0"
|
|
43
56
|
},
|
|
44
57
|
"devDependencies": {
|
|
@@ -48,7 +61,13 @@
|
|
|
48
61
|
"publishConfig": {
|
|
49
62
|
"access": "public"
|
|
50
63
|
},
|
|
51
|
-
"
|
|
64
|
+
"bundler": {
|
|
65
|
+
"entries": [
|
|
66
|
+
"./src/index.ts",
|
|
67
|
+
"./src/highlight.ts"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
"gitHead": "8f6d8629f1ad7e776c39e2c7621f4a0d538aa93c",
|
|
52
71
|
"sbmodern": "dist/modern/index.js",
|
|
53
72
|
"storybook": {
|
|
54
73
|
"displayName": "Highlight",
|
package/preview.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './dist/
|
|
1
|
+
export * from './dist/highlight';
|
package/dist/cjs/constants.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.RESET_HIGHLIGHT = exports.HIGHLIGHT_STYLE_ID = exports.HIGHLIGHT = exports.ADDON_ID = void 0;
|
|
7
|
-
const ADDON_ID = 'storybook/highlight';
|
|
8
|
-
exports.ADDON_ID = ADDON_ID;
|
|
9
|
-
const HIGHLIGHT_STYLE_ID = 'storybookHighlight';
|
|
10
|
-
exports.HIGHLIGHT_STYLE_ID = HIGHLIGHT_STYLE_ID;
|
|
11
|
-
const HIGHLIGHT = `${ADDON_ID}/add`;
|
|
12
|
-
exports.HIGHLIGHT = HIGHLIGHT;
|
|
13
|
-
const RESET_HIGHLIGHT = `${ADDON_ID}/reset`;
|
|
14
|
-
exports.RESET_HIGHLIGHT = RESET_HIGHLIGHT;
|
package/dist/cjs/highlight.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.highlightStyle = exports.highlightObject = void 0;
|
|
7
|
-
|
|
8
|
-
var _global = _interopRequireDefault(require("global"));
|
|
9
|
-
|
|
10
|
-
var _addons = require("@storybook/addons");
|
|
11
|
-
|
|
12
|
-
var _coreEvents = require("@storybook/core-events");
|
|
13
|
-
|
|
14
|
-
var _constants = require("./constants");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
/* eslint-env browser */
|
|
19
|
-
const {
|
|
20
|
-
document
|
|
21
|
-
} = _global.default;
|
|
22
|
-
|
|
23
|
-
const highlightStyle = (color = '#FF4785', style = 'dashed') => `
|
|
24
|
-
outline: 2px ${style} ${color};
|
|
25
|
-
outline-offset: 2px;
|
|
26
|
-
box-shadow: 0 0 0 6px rgba(255,255,255,0.6);
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
|
-
exports.highlightStyle = highlightStyle;
|
|
30
|
-
|
|
31
|
-
const highlightObject = color => ({
|
|
32
|
-
outline: `2px dashed ${color}`,
|
|
33
|
-
outlineOffset: 2,
|
|
34
|
-
boxShadow: '0 0 0 6px rgba(255,255,255,0.6)'
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
exports.highlightObject = highlightObject;
|
|
38
|
-
|
|
39
|
-
if (module && module.hot && module.hot.decline) {
|
|
40
|
-
module.hot.decline();
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const channel = _addons.addons.getChannel();
|
|
44
|
-
|
|
45
|
-
const highlight = infos => {
|
|
46
|
-
const id = _constants.HIGHLIGHT_STYLE_ID;
|
|
47
|
-
resetHighlight(); // Make sure there are no duplicated selectors
|
|
48
|
-
|
|
49
|
-
const elements = Array.from(new Set(infos.elements));
|
|
50
|
-
const sheet = document.createElement('style');
|
|
51
|
-
sheet.setAttribute('id', id);
|
|
52
|
-
sheet.innerHTML = elements.map(target => `${target}{
|
|
53
|
-
${highlightStyle(infos.color, infos.style)}
|
|
54
|
-
}`).join(' ');
|
|
55
|
-
document.head.appendChild(sheet);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const resetHighlight = () => {
|
|
59
|
-
const id = _constants.HIGHLIGHT_STYLE_ID;
|
|
60
|
-
const sheetToBeRemoved = document.getElementById(id);
|
|
61
|
-
|
|
62
|
-
if (sheetToBeRemoved) {
|
|
63
|
-
sheetToBeRemoved.parentNode.removeChild(sheetToBeRemoved);
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
channel.on(_coreEvents.STORY_CHANGED, resetHighlight);
|
|
68
|
-
channel.on(_constants.RESET_HIGHLIGHT, resetHighlight);
|
|
69
|
-
channel.on(_constants.HIGHLIGHT, highlight);
|
package/dist/cjs/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "HIGHLIGHT", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function () {
|
|
9
|
-
return _constants.HIGHLIGHT;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
Object.defineProperty(exports, "RESET_HIGHLIGHT", {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function () {
|
|
15
|
-
return _constants.RESET_HIGHLIGHT;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
exports.default = void 0;
|
|
19
|
-
|
|
20
|
-
var _constants = require("./constants");
|
|
21
|
-
|
|
22
|
-
if (module && module.hot && module.hot.decline) {
|
|
23
|
-
module.hot.decline();
|
|
24
|
-
} // make it work with --isolatedModules
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
var _default = {};
|
|
28
|
-
exports.default = _default;
|
package/dist/esm/constants.js
DELETED
package/dist/esm/highlight.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/* eslint-env browser */
|
|
2
|
-
import global from 'global';
|
|
3
|
-
import { addons } from '@storybook/addons';
|
|
4
|
-
import { STORY_CHANGED } from '@storybook/core-events';
|
|
5
|
-
import { HIGHLIGHT, RESET_HIGHLIGHT, HIGHLIGHT_STYLE_ID } from './constants';
|
|
6
|
-
const {
|
|
7
|
-
document
|
|
8
|
-
} = global;
|
|
9
|
-
export const highlightStyle = (color = '#FF4785', style = 'dashed') => `
|
|
10
|
-
outline: 2px ${style} ${color};
|
|
11
|
-
outline-offset: 2px;
|
|
12
|
-
box-shadow: 0 0 0 6px rgba(255,255,255,0.6);
|
|
13
|
-
`;
|
|
14
|
-
export const highlightObject = color => ({
|
|
15
|
-
outline: `2px dashed ${color}`,
|
|
16
|
-
outlineOffset: 2,
|
|
17
|
-
boxShadow: '0 0 0 6px rgba(255,255,255,0.6)'
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
if (module && module.hot && module.hot.decline) {
|
|
21
|
-
module.hot.decline();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const channel = addons.getChannel();
|
|
25
|
-
|
|
26
|
-
const highlight = infos => {
|
|
27
|
-
const id = HIGHLIGHT_STYLE_ID;
|
|
28
|
-
resetHighlight(); // Make sure there are no duplicated selectors
|
|
29
|
-
|
|
30
|
-
const elements = Array.from(new Set(infos.elements));
|
|
31
|
-
const sheet = document.createElement('style');
|
|
32
|
-
sheet.setAttribute('id', id);
|
|
33
|
-
sheet.innerHTML = elements.map(target => `${target}{
|
|
34
|
-
${highlightStyle(infos.color, infos.style)}
|
|
35
|
-
}`).join(' ');
|
|
36
|
-
document.head.appendChild(sheet);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const resetHighlight = () => {
|
|
40
|
-
const id = HIGHLIGHT_STYLE_ID;
|
|
41
|
-
const sheetToBeRemoved = document.getElementById(id);
|
|
42
|
-
|
|
43
|
-
if (sheetToBeRemoved) {
|
|
44
|
-
sheetToBeRemoved.parentNode.removeChild(sheetToBeRemoved);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
channel.on(STORY_CHANGED, resetHighlight);
|
|
49
|
-
channel.on(RESET_HIGHLIGHT, resetHighlight);
|
|
50
|
-
channel.on(HIGHLIGHT, highlight);
|
package/dist/esm/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
declare type OutlineStyle = 'dotted' | 'dashed' | 'solid' | 'double';
|
|
2
|
-
export declare const highlightStyle: (color?: string, style?: OutlineStyle) => string;
|
|
3
|
-
export declare const highlightObject: (color: string) => {
|
|
4
|
-
outline: string;
|
|
5
|
-
outlineOffset: number;
|
|
6
|
-
boxShadow: string;
|
|
7
|
-
};
|
|
8
|
-
export {};
|
package/dist/types/index.d.ts
DELETED