@previewcn/devtools 0.1.0-alpha.4 → 0.1.0-alpha.5
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.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/styles.css +0 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var pe=Object.defineProperty;var p=(e,o)=>()=>(e&&(o=e(e=0)),o);var me=(e,o)=>{for(var r in o)pe(e,r,{get:o[r],enumerable:true});};var U,_=p(()=>{U=[{name:"neutral",label:"Neutral",primary:{light:"oklch(0.556 0 0)",dark:"oklch(0.708 0 0)"},primaryForeground:{light:"oklch(0.985 0 0)",dark:"oklch(0.205 0 0)"}},{name:"red",label:"Red",primary:{light:"oklch(0.577 0.245 27.325)",dark:"oklch(0.637 0.237 25.331)"},primaryForeground:{light:"oklch(0.971 0.013 17.38)",dark:"oklch(0.971 0.013 17.38)"},destructive:{light:"oklch(0.505 0.213 27.518)"}},{name:"orange",label:"Orange",primary:{light:"oklch(0.646 0.222 41.116)",dark:"oklch(0.705 0.213 47.604)"},primaryForeground:{light:"oklch(0.98 0.016 73.684)",dark:"oklch(0.98 0.016 73.684)"}},{name:"amber",label:"Amber",primary:{light:"oklch(0.67 0.16 58)",dark:"oklch(0.77 0.16 70)"},primaryForeground:{light:"oklch(0.99 0.02 95)",dark:"oklch(0.28 0.07 46)"}},{name:"yellow",label:"Yellow",primary:{light:"oklch(0.852 0.199 91.936)",dark:"oklch(0.795 0.184 86.047)"},primaryForeground:{light:"oklch(0.421 0.095 57.708)",dark:"oklch(0.421 0.095 57.708)"}},{name:"lime",label:"Lime",primary:{light:"oklch(0.65 0.18 132)",dark:"oklch(0.77 0.20 131)"},primaryForeground:{light:"oklch(0.99 0.03 121)",dark:"oklch(0.27 0.07 132)"}},{name:"green",label:"Green",primary:{light:"oklch(0.648 0.2 131.684)",dark:"oklch(0.648 0.2 131.684)"},primaryForeground:{light:"oklch(0.986 0.031 120.757)",dark:"oklch(0.986 0.031 120.757)"}},{name:"emerald",label:"Emerald",primary:{light:"oklch(0.60 0.13 163)",dark:"oklch(0.70 0.15 162)"},primaryForeground:{light:"oklch(0.98 0.02 166)",dark:"oklch(0.26 0.05 173)"}},{name:"teal",label:"Teal",primary:{light:"oklch(0.60 0.10 185)",dark:"oklch(0.70 0.12 183)"},primaryForeground:{light:"oklch(0.98 0.01 181)",dark:"oklch(0.28 0.04 193)"}},{name:"cyan",label:"Cyan",primary:{light:"oklch(0.61 0.11 222)",dark:"oklch(0.71 0.13 215)"},primaryForeground:{light:"oklch(0.98 0.02 201)",dark:"oklch(0.30 0.05 230)"}},{name:"sky",label:"Sky",primary:{light:"oklch(0.59 0.14 242)",dark:"oklch(0.68 0.15 237)"},primaryForeground:{light:"oklch(0.98 0.01 237)",dark:"oklch(0.29 0.06 243)"}},{name:"blue",label:"Blue",primary:{light:"oklch(0.488 0.243 264.376)",dark:"oklch(0.42 0.18 266)"},primaryForeground:{light:"oklch(0.97 0.014 254.604)",dark:"oklch(0.97 0.014 254.604)"}},{name:"indigo",label:"Indigo",primary:{light:"oklch(0.51 0.23 277)",dark:"oklch(0.59 0.20 277)"},primaryForeground:{light:"oklch(0.96 0.02 272)",dark:"oklch(0.96 0.02 272)"}},{name:"violet",label:"Violet",primary:{light:"oklch(0.541 0.281 293.009)",dark:"oklch(0.606 0.25 292.717)"},primaryForeground:{light:"oklch(0.969 0.016 293.756)",dark:"oklch(0.969 0.016 293.756)"}},{name:"purple",label:"Purple",primary:{light:"oklch(0.56 0.25 302)",dark:"oklch(0.63 0.23 304)"},primaryForeground:{light:"oklch(0.98 0.01 308)",dark:"oklch(0.98 0.01 308)"}},{name:"fuchsia",label:"Fuchsia",primary:{light:"oklch(0.59 0.26 323)",dark:"oklch(0.67 0.26 322)"},primaryForeground:{light:"oklch(0.98 0.02 320)",dark:"oklch(0.98 0.02 320)"}},{name:"pink",label:"Pink",primary:{light:"oklch(0.59 0.22 1)",dark:"oklch(0.66 0.21 354)"},primaryForeground:{light:"oklch(0.97 0.01 343)",dark:"oklch(0.97 0.01 343)"}},{name:"rose",label:"Rose",primary:{light:"oklch(0.586 0.253 17.585)",dark:"oklch(0.645 0.246 16.439)"},primaryForeground:{light:"oklch(0.969 0.015 12.422)",dark:"oklch(0.969 0.015 12.422)"}}];});function he(e){return {name:e.name,label:e.label,colors:{light:{...W.light,primary:e.primary.light,"primary-foreground":e.primaryForeground?.light??J.light,destructive:e.destructive?.light??H.light},dark:{...W.dark,primary:e.primary.dark,"primary-foreground":e.primaryForeground?.dark??J.dark,destructive:e.destructive?.dark??H.dark}}}}function V(e){return E.find(o=>o.name===e)}var W,H,J,E,T=p(()=>{_();W={light:{background:"oklch(1 0 0)",foreground:"oklch(0.145 0 0)",card:"oklch(1 0 0)","card-foreground":"oklch(0.145 0 0)",popover:"oklch(1 0 0)","popover-foreground":"oklch(0.145 0 0)",secondary:"oklch(0.97 0 0)","secondary-foreground":"oklch(0.205 0 0)",muted:"oklch(0.97 0 0)","muted-foreground":"oklch(0.556 0 0)",accent:"oklch(0.97 0 0)","accent-foreground":"oklch(0.205 0 0)",border:"oklch(0.922 0 0)",input:"oklch(0.922 0 0)",ring:"oklch(0.708 0 0)"},dark:{background:"oklch(0.145 0 0)",foreground:"oklch(0.985 0 0)",card:"oklch(0.205 0 0)","card-foreground":"oklch(0.985 0 0)",popover:"oklch(0.205 0 0)","popover-foreground":"oklch(0.985 0 0)",secondary:"oklch(0.269 0 0)","secondary-foreground":"oklch(0.985 0 0)",muted:"oklch(0.269 0 0)","muted-foreground":"oklch(0.708 0 0)",accent:"oklch(0.269 0 0)","accent-foreground":"oklch(0.985 0 0)",border:"oklch(1 0 0 / 10%)",input:"oklch(1 0 0 / 15%)",ring:"oklch(0.556 0 0)"}},H={light:"oklch(0.577 0.245 27.325)",dark:"oklch(0.704 0.191 22.216)"},J={light:"oklch(0.985 0 0)",dark:"oklch(0.985 0 0)"};E=U.map(he);});function Y(e){return y.find(o=>o.value===e)}var y,M=p(()=>{y=[{label:"Inter",value:"inter",fontFamily:'"Inter", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"},{label:"Noto Sans",value:"noto-sans",fontFamily:'"Noto Sans", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;500;600;700&display=swap"},{label:"Nunito Sans",value:"nunito-sans",fontFamily:'"Nunito Sans", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;500;600;700&display=swap"},{label:"Figtree",value:"figtree",fontFamily:'"Figtree", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&display=swap"},{label:"Roboto",value:"roboto",fontFamily:'"Roboto", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap"},{label:"Raleway",value:"raleway",fontFamily:'"Raleway", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Raleway:wght@400;500;600;700&display=swap"},{label:"DM Sans",value:"dm-sans",fontFamily:'"DM Sans", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap"},{label:"Public Sans",value:"public-sans",fontFamily:'"Public Sans", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Public+Sans:wght@400;500;600;700&display=swap"},{label:"Outfit",value:"outfit",fontFamily:'"Outfit", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap"},{label:"JetBrains Mono",value:"jetbrains-mono",fontFamily:'"JetBrains Mono", monospace',googleFontsUrl:"https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap"}];});function ke(){let e=document.getElementById(L);if(e instanceof HTMLStyleElement)return e;e&&e.remove();let o=document.createElement("style");return o.id=L,document.head.appendChild(o),o}function z(e){return Object.entries(e).map(([o,r])=>`--${o}: ${r};`).join(" ")}function w(e){let o=document.documentElement;e?(o.classList.remove("light"),o.classList.add("dark")):(o.classList.remove("dark"),o.classList.add("light")),o.style.colorScheme=e?"dark":"light";}function b(e){document.documentElement.style.setProperty("--radius",e);}function C(e){let o=V(e);if(!o)return;let r=ke(),
|
|
2
|
+
'use strict';var react=require('react'),jsxRuntime=require('react/jsx-runtime');var pe=Object.defineProperty;var p=(e,o)=>()=>(e&&(o=e(e=0)),o);var me=(e,o)=>{for(var r in o)pe(e,r,{get:o[r],enumerable:true});};var U,_=p(()=>{U=[{name:"neutral",label:"Neutral",primary:{light:"oklch(0.556 0 0)",dark:"oklch(0.708 0 0)"},primaryForeground:{light:"oklch(0.985 0 0)",dark:"oklch(0.205 0 0)"}},{name:"red",label:"Red",primary:{light:"oklch(0.577 0.245 27.325)",dark:"oklch(0.637 0.237 25.331)"},primaryForeground:{light:"oklch(0.971 0.013 17.38)",dark:"oklch(0.971 0.013 17.38)"},destructive:{light:"oklch(0.505 0.213 27.518)"}},{name:"orange",label:"Orange",primary:{light:"oklch(0.646 0.222 41.116)",dark:"oklch(0.705 0.213 47.604)"},primaryForeground:{light:"oklch(0.98 0.016 73.684)",dark:"oklch(0.98 0.016 73.684)"}},{name:"amber",label:"Amber",primary:{light:"oklch(0.67 0.16 58)",dark:"oklch(0.77 0.16 70)"},primaryForeground:{light:"oklch(0.99 0.02 95)",dark:"oklch(0.28 0.07 46)"}},{name:"yellow",label:"Yellow",primary:{light:"oklch(0.852 0.199 91.936)",dark:"oklch(0.795 0.184 86.047)"},primaryForeground:{light:"oklch(0.421 0.095 57.708)",dark:"oklch(0.421 0.095 57.708)"}},{name:"lime",label:"Lime",primary:{light:"oklch(0.65 0.18 132)",dark:"oklch(0.77 0.20 131)"},primaryForeground:{light:"oklch(0.99 0.03 121)",dark:"oklch(0.27 0.07 132)"}},{name:"green",label:"Green",primary:{light:"oklch(0.648 0.2 131.684)",dark:"oklch(0.648 0.2 131.684)"},primaryForeground:{light:"oklch(0.986 0.031 120.757)",dark:"oklch(0.986 0.031 120.757)"}},{name:"emerald",label:"Emerald",primary:{light:"oklch(0.60 0.13 163)",dark:"oklch(0.70 0.15 162)"},primaryForeground:{light:"oklch(0.98 0.02 166)",dark:"oklch(0.26 0.05 173)"}},{name:"teal",label:"Teal",primary:{light:"oklch(0.60 0.10 185)",dark:"oklch(0.70 0.12 183)"},primaryForeground:{light:"oklch(0.98 0.01 181)",dark:"oklch(0.28 0.04 193)"}},{name:"cyan",label:"Cyan",primary:{light:"oklch(0.61 0.11 222)",dark:"oklch(0.71 0.13 215)"},primaryForeground:{light:"oklch(0.98 0.02 201)",dark:"oklch(0.30 0.05 230)"}},{name:"sky",label:"Sky",primary:{light:"oklch(0.59 0.14 242)",dark:"oklch(0.68 0.15 237)"},primaryForeground:{light:"oklch(0.98 0.01 237)",dark:"oklch(0.29 0.06 243)"}},{name:"blue",label:"Blue",primary:{light:"oklch(0.488 0.243 264.376)",dark:"oklch(0.42 0.18 266)"},primaryForeground:{light:"oklch(0.97 0.014 254.604)",dark:"oklch(0.97 0.014 254.604)"}},{name:"indigo",label:"Indigo",primary:{light:"oklch(0.51 0.23 277)",dark:"oklch(0.59 0.20 277)"},primaryForeground:{light:"oklch(0.96 0.02 272)",dark:"oklch(0.96 0.02 272)"}},{name:"violet",label:"Violet",primary:{light:"oklch(0.541 0.281 293.009)",dark:"oklch(0.606 0.25 292.717)"},primaryForeground:{light:"oklch(0.969 0.016 293.756)",dark:"oklch(0.969 0.016 293.756)"}},{name:"purple",label:"Purple",primary:{light:"oklch(0.56 0.25 302)",dark:"oklch(0.63 0.23 304)"},primaryForeground:{light:"oklch(0.98 0.01 308)",dark:"oklch(0.98 0.01 308)"}},{name:"fuchsia",label:"Fuchsia",primary:{light:"oklch(0.59 0.26 323)",dark:"oklch(0.67 0.26 322)"},primaryForeground:{light:"oklch(0.98 0.02 320)",dark:"oklch(0.98 0.02 320)"}},{name:"pink",label:"Pink",primary:{light:"oklch(0.59 0.22 1)",dark:"oklch(0.66 0.21 354)"},primaryForeground:{light:"oklch(0.97 0.01 343)",dark:"oklch(0.97 0.01 343)"}},{name:"rose",label:"Rose",primary:{light:"oklch(0.586 0.253 17.585)",dark:"oklch(0.645 0.246 16.439)"},primaryForeground:{light:"oklch(0.969 0.015 12.422)",dark:"oklch(0.969 0.015 12.422)"}}];});function he(e){return {name:e.name,label:e.label,colors:{light:{...W.light,primary:e.primary.light,"primary-foreground":e.primaryForeground?.light??J.light,destructive:e.destructive?.light??H.light},dark:{...W.dark,primary:e.primary.dark,"primary-foreground":e.primaryForeground?.dark??J.dark,destructive:e.destructive?.dark??H.dark}}}}function V(e){return E.find(o=>o.name===e)}var W,H,J,E,T=p(()=>{_();W={light:{background:"oklch(1 0 0)",foreground:"oklch(0.145 0 0)",card:"oklch(1 0 0)","card-foreground":"oklch(0.145 0 0)",popover:"oklch(1 0 0)","popover-foreground":"oklch(0.145 0 0)",secondary:"oklch(0.97 0 0)","secondary-foreground":"oklch(0.205 0 0)",muted:"oklch(0.97 0 0)","muted-foreground":"oklch(0.556 0 0)",accent:"oklch(0.97 0 0)","accent-foreground":"oklch(0.205 0 0)",border:"oklch(0.922 0 0)",input:"oklch(0.922 0 0)",ring:"oklch(0.708 0 0)"},dark:{background:"oklch(0.145 0 0)",foreground:"oklch(0.985 0 0)",card:"oklch(0.205 0 0)","card-foreground":"oklch(0.985 0 0)",popover:"oklch(0.205 0 0)","popover-foreground":"oklch(0.985 0 0)",secondary:"oklch(0.269 0 0)","secondary-foreground":"oklch(0.985 0 0)",muted:"oklch(0.269 0 0)","muted-foreground":"oklch(0.708 0 0)",accent:"oklch(0.269 0 0)","accent-foreground":"oklch(0.985 0 0)",border:"oklch(1 0 0 / 10%)",input:"oklch(1 0 0 / 15%)",ring:"oklch(0.556 0 0)"}},H={light:"oklch(0.577 0.245 27.325)",dark:"oklch(0.704 0.191 22.216)"},J={light:"oklch(0.985 0 0)",dark:"oklch(0.985 0 0)"};E=U.map(he);});function Y(e){return y.find(o=>o.value===e)}var y,M=p(()=>{y=[{label:"Inter",value:"inter",fontFamily:'"Inter", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"},{label:"Noto Sans",value:"noto-sans",fontFamily:'"Noto Sans", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;500;600;700&display=swap"},{label:"Nunito Sans",value:"nunito-sans",fontFamily:'"Nunito Sans", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;500;600;700&display=swap"},{label:"Figtree",value:"figtree",fontFamily:'"Figtree", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&display=swap"},{label:"Roboto",value:"roboto",fontFamily:'"Roboto", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap"},{label:"Raleway",value:"raleway",fontFamily:'"Raleway", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Raleway:wght@400;500;600;700&display=swap"},{label:"DM Sans",value:"dm-sans",fontFamily:'"DM Sans", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap"},{label:"Public Sans",value:"public-sans",fontFamily:'"Public Sans", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Public+Sans:wght@400;500;600;700&display=swap"},{label:"Outfit",value:"outfit",fontFamily:'"Outfit", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap"},{label:"JetBrains Mono",value:"jetbrains-mono",fontFamily:'"JetBrains Mono", monospace',googleFontsUrl:"https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap"}];});function ke(){let e=document.getElementById(L);if(e instanceof HTMLStyleElement)return e;e&&e.remove();let o=document.createElement("style");return o.id=L,document.head.appendChild(o),o}function z(e){return Object.entries(e).map(([o,r])=>`--${o}: ${r};`).join(" ")}function w(e){let o=document.documentElement;e?(o.classList.remove("light"),o.classList.add("dark")):(o.classList.remove("dark"),o.classList.add("light")),o.style.colorScheme=e?"dark":"light";}function b(e){document.documentElement.style.setProperty("--radius",e);}function C(e){let o=V(e);if(!o)return;let r=ke(),n=z(o.colors.light),c=z(o.colors.dark);r.textContent=`:root { ${n} } .dark { ${c} }`;}function fe(){let e=document.getElementById(R);if(e instanceof HTMLStyleElement)return e;e&&e.remove();let o=document.createElement("style");return o.id=R,document.head.appendChild(o),o}function P(e){let o=Y(e);if(!o)return;let{fontFamily:r,googleFontsUrl:n}=o;if(!n.startsWith("https://fonts.googleapis.com/")){console.warn("[PreviewCN] Invalid font URL");return}let c=`previewcn-font-${e}`;if(!document.getElementById(c)){let a=document.createElement("link");a.id=c,a.rel="stylesheet",a.href=n,document.head.appendChild(a);}let m=fe();m.textContent=`
|
|
3
3
|
:root {
|
|
4
4
|
--font-sans: ${r} !important;
|
|
5
5
|
--font-sans-override: ${r} !important;
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
html, body, .font-sans {
|
|
9
9
|
font-family: ${r} !important;
|
|
10
10
|
}
|
|
11
|
-
`;}function I(e){e.colorPreset!==null&&C(e.colorPreset),e.radius!==null&&b(e.radius),e.darkMode!==null&&w(e.darkMode),e.font!==null&&P(e.font);}function A(){let e=document.getElementById(L);e&&e.remove();let o=document.getElementById(R);o&&o.remove();let r=document.documentElement;r.style.removeProperty("--radius"),r.style.removeProperty("color-scheme"),r.classList.remove("light","dark");}var L,R,F=p(()=>{T();M();L="previewcn-devtools-theme-colors",R="previewcn-devtools-theme-font";});function ye(){if(typeof window>"u")return {};try{let e=localStorage.getItem(D);if(e)return JSON.parse(e)}catch{}return {}}function S(e){if(!(typeof window>"u"))try{localStorage.setItem(D,JSON.stringify(e));}catch{}}function K(){let[e,o]=react.useState(()=>({...G,...ye()})),r=react.useCallback(i=>{o(d=>{let s={...d,colorPreset:i};return S(s),s}),C(i);},[]),
|
|
11
|
+
`;}function I(e){e.colorPreset!==null&&C(e.colorPreset),e.radius!==null&&b(e.radius),e.darkMode!==null&&w(e.darkMode),e.font!==null&&P(e.font);}function A(){let e=document.getElementById(L);e&&e.remove();let o=document.getElementById(R);o&&o.remove();let r=document.documentElement;r.style.removeProperty("--radius"),r.style.removeProperty("color-scheme"),r.classList.remove("light","dark");}var L,R,F=p(()=>{T();M();L="previewcn-devtools-theme-colors",R="previewcn-devtools-theme-font";});function ye(){if(typeof window>"u")return {};try{let e=localStorage.getItem(D);if(e)return JSON.parse(e)}catch{}return {}}function S(e){if(!(typeof window>"u"))try{localStorage.setItem(D,JSON.stringify(e));}catch{}}function K(){let[e,o]=react.useState(()=>({...G,...ye()})),r=react.useCallback(i=>{o(d=>{let s={...d,colorPreset:i};return S(s),s}),C(i);},[]),n=react.useCallback(i=>{o(d=>{let s={...d,radius:i};return S(s),s}),b(i);},[]),c=react.useCallback(i=>{o(d=>{let s={...d,darkMode:i};return S(s),s}),w(i);},[]),m=react.useCallback(i=>{o(d=>{let s={...d,font:i};return S(s),s}),P(i);},[]),a=react.useCallback(()=>{typeof window<"u"&&localStorage.removeItem(D),A(),o(G);},[]);return {config:e,setColorPreset:r,setRadius:n,setDarkMode:c,setFont:m,resetTheme:a}}var D,G,j=p(()=>{"use client";F();D="previewcn-devtools-theme";G={colorPreset:null,radius:null,darkMode:null,font:null};});function X({value:e,onChange:o}){return jsxRuntime.jsxs("div",{className:"previewcn-section",children:[jsxRuntime.jsx("label",{className:"previewcn-label",children:"Color"}),jsxRuntime.jsx("div",{className:"previewcn-color-grid",children:E.map(r=>{let n=e===r.name,c=r.colors.light.primary;return jsxRuntime.jsx("button",{onClick:()=>o(r.name),className:`previewcn-color-swatch ${n?"previewcn-color-swatch--selected":""}`,style:{backgroundColor:c},"aria-label":r.label,title:r.label},r.name)})})]})}var Z=p(()=>{"use client";T();});function Ce(){return jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"m6 9 6 6 6-6"})})}function q({value:e,onChange:o}){let[r,n]=react.useState(false),m=y.find(a=>a.value===e)?.label??"Select font...";return jsxRuntime.jsxs("div",{className:"previewcn-section",children:[jsxRuntime.jsx("label",{className:"previewcn-label",children:"Font"}),jsxRuntime.jsxs("div",{className:"previewcn-select-wrapper",children:[jsxRuntime.jsxs("button",{onClick:()=>n(!r),className:"previewcn-select-trigger","aria-expanded":r,children:[jsxRuntime.jsx("span",{children:m}),jsxRuntime.jsx(Ce,{})]}),r&&jsxRuntime.jsx("div",{className:"previewcn-select-dropdown",children:y.map(a=>jsxRuntime.jsx("button",{onClick:()=>{o(a.value),n(false);},className:`previewcn-select-option ${e===a.value?"previewcn-select-option--selected":""}`,children:a.label},a.value))})]})]})}var Q=p(()=>{"use client";M();});function Pe(){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"12",cy:"12",r:"4"}),jsxRuntime.jsx("path",{d:"M12 2v2"}),jsxRuntime.jsx("path",{d:"M12 20v2"}),jsxRuntime.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),jsxRuntime.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),jsxRuntime.jsx("path",{d:"M2 12h2"}),jsxRuntime.jsx("path",{d:"M20 12h2"}),jsxRuntime.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),jsxRuntime.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})}function Fe(){return jsxRuntime.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsxRuntime.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function ee({value:e,onChange:o}){let r=e??false;return jsxRuntime.jsxs("div",{className:"previewcn-section",children:[jsxRuntime.jsx("label",{className:"previewcn-label",children:"Mode"}),jsxRuntime.jsxs("div",{className:"previewcn-mode-toggle",children:[jsxRuntime.jsxs("button",{onClick:()=>o(false),className:`previewcn-mode-btn ${r?"":"previewcn-mode-btn--selected"}`,"aria-label":"Light mode",children:[jsxRuntime.jsx(Pe,{}),jsxRuntime.jsx("span",{children:"Light"})]}),jsxRuntime.jsxs("button",{onClick:()=>o(true),className:`previewcn-mode-btn ${r?"previewcn-mode-btn--selected":""}`,"aria-label":"Dark mode",children:[jsxRuntime.jsx(Fe,{}),jsxRuntime.jsx("span",{children:"Dark"})]})]})]})}var oe=p(()=>{"use client";});var re,te=p(()=>{re=[{name:"none",label:"None",value:"0rem"},{name:"sm",label:"SM",value:"0.3rem"},{name:"md",label:"MD",value:"0.5rem"},{name:"lg",label:"LG",value:"0.625rem"},{name:"xl",label:"XL",value:"0.75rem"},{name:"full",label:"Full",value:"1rem"}];});function ne({value:e,onChange:o}){return jsxRuntime.jsxs("div",{className:"previewcn-section",children:[jsxRuntime.jsx("label",{className:"previewcn-label",children:"Radius"}),jsxRuntime.jsx("div",{className:"previewcn-radius-grid",children:re.map(r=>{let n=e===r.value;return jsxRuntime.jsxs("button",{onClick:()=>o(r.value),className:`previewcn-radius-btn ${n?"previewcn-radius-btn--selected":""}`,title:r.label,children:[jsxRuntime.jsx("span",{className:"previewcn-radius-preview",style:{borderRadius:r.value}}),jsxRuntime.jsx("span",{className:"previewcn-radius-label",children:r.label})]},r.name)})})]})}var ae=p(()=>{"use client";te();});var ce={};me(ce,{default:()=>se});function Ne(){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M18 6 6 18"}),jsxRuntime.jsx("path",{d:"m6 6 12 12"})]})}function Ee(){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),jsxRuntime.jsx("path",{d:"M3 3v5h5"})]})}function se({onClose:e}){let{config:o,setColorPreset:r,setRadius:n,setDarkMode:c,setFont:m,resetTheme:a}=K(),i=react.useRef(false);react.useEffect(()=>{i.current||(i.current=true,I(o));},[o]);let d=react.useCallback(v=>{v.key==="Escape"&&e();},[e]);return react.useEffect(()=>(window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)),[d]),jsxRuntime.jsx("div",{className:"previewcn-backdrop",onClick:v=>{v.target===v.currentTarget&&e();},children:jsxRuntime.jsxs("div",{className:"previewcn-panel",children:[jsxRuntime.jsxs("div",{className:"previewcn-header",children:[jsxRuntime.jsxs("div",{className:"previewcn-title",children:[jsxRuntime.jsx("span",{className:"previewcn-logo",children:"PreviewCN"}),jsxRuntime.jsx("span",{className:"previewcn-badge",children:"DEV"})]}),jsxRuntime.jsx("button",{onClick:e,className:"previewcn-close-btn","aria-label":"Close",children:jsxRuntime.jsx(Ne,{})})]}),jsxRuntime.jsxs("div",{className:"previewcn-content",children:[jsxRuntime.jsx(X,{value:o.colorPreset,onChange:r}),jsxRuntime.jsx(ne,{value:o.radius,onChange:n}),jsxRuntime.jsx(q,{value:o.font,onChange:m}),jsxRuntime.jsx(ee,{value:o.darkMode,onChange:c})]}),jsxRuntime.jsx("div",{className:"previewcn-footer",children:jsxRuntime.jsxs("button",{onClick:a,className:"previewcn-reset-btn",children:[jsxRuntime.jsx(Ee,{}),jsxRuntime.jsx("span",{children:"Reset"})]})})]})})}var de=p(()=>{"use client";j();F();Z();Q();oe();ae();});function ue(){return jsxRuntime.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsxRuntime.jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),jsxRuntime.jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),jsxRuntime.jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"}),jsxRuntime.jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),jsxRuntime.jsx("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.555C21.965 6.012 17.461 2 12 2z"})]})}function $({onClick:e}){return jsxRuntime.jsx("button",{onClick:e,className:"previewcn-trigger","aria-label":"Open PreviewCN theme editor",title:"PreviewCN Theme Editor",children:jsxRuntime.jsx(ue,{})})}var Re=react.lazy(()=>Promise.resolve().then(()=>(de(),ce))),Ie=process.env.NODE_ENV==="development";function De(){let[e,o]=react.useState(false);return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx($,{onClick:()=>o(true)}),e&&jsxRuntime.jsx(react.Suspense,{fallback:null,children:jsxRuntime.jsx(Re,{onClose:()=>o(false)})})]})}function Oe(){return Ie?jsxRuntime.jsx(De,{}):null}F();
|
|
12
12
|
exports.PreviewcnDevtools=Oe;exports.applyColors=C;exports.applyDarkMode=w;exports.applyFont=P;exports.applyRadius=b;exports.applyTheme=I;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {lazy,useRef,useEffect,useCallback,useState,Suspense}from'react';import {jsxs,
|
|
2
|
+
import {lazy,useRef,useEffect,useCallback,useState,Suspense}from'react';import {jsx,jsxs,Fragment}from'react/jsx-runtime';var pe=Object.defineProperty;var p=(e,o)=>()=>(e&&(o=e(e=0)),o);var me=(e,o)=>{for(var r in o)pe(e,r,{get:o[r],enumerable:true});};var U,_=p(()=>{U=[{name:"neutral",label:"Neutral",primary:{light:"oklch(0.556 0 0)",dark:"oklch(0.708 0 0)"},primaryForeground:{light:"oklch(0.985 0 0)",dark:"oklch(0.205 0 0)"}},{name:"red",label:"Red",primary:{light:"oklch(0.577 0.245 27.325)",dark:"oklch(0.637 0.237 25.331)"},primaryForeground:{light:"oklch(0.971 0.013 17.38)",dark:"oklch(0.971 0.013 17.38)"},destructive:{light:"oklch(0.505 0.213 27.518)"}},{name:"orange",label:"Orange",primary:{light:"oklch(0.646 0.222 41.116)",dark:"oklch(0.705 0.213 47.604)"},primaryForeground:{light:"oklch(0.98 0.016 73.684)",dark:"oklch(0.98 0.016 73.684)"}},{name:"amber",label:"Amber",primary:{light:"oklch(0.67 0.16 58)",dark:"oklch(0.77 0.16 70)"},primaryForeground:{light:"oklch(0.99 0.02 95)",dark:"oklch(0.28 0.07 46)"}},{name:"yellow",label:"Yellow",primary:{light:"oklch(0.852 0.199 91.936)",dark:"oklch(0.795 0.184 86.047)"},primaryForeground:{light:"oklch(0.421 0.095 57.708)",dark:"oklch(0.421 0.095 57.708)"}},{name:"lime",label:"Lime",primary:{light:"oklch(0.65 0.18 132)",dark:"oklch(0.77 0.20 131)"},primaryForeground:{light:"oklch(0.99 0.03 121)",dark:"oklch(0.27 0.07 132)"}},{name:"green",label:"Green",primary:{light:"oklch(0.648 0.2 131.684)",dark:"oklch(0.648 0.2 131.684)"},primaryForeground:{light:"oklch(0.986 0.031 120.757)",dark:"oklch(0.986 0.031 120.757)"}},{name:"emerald",label:"Emerald",primary:{light:"oklch(0.60 0.13 163)",dark:"oklch(0.70 0.15 162)"},primaryForeground:{light:"oklch(0.98 0.02 166)",dark:"oklch(0.26 0.05 173)"}},{name:"teal",label:"Teal",primary:{light:"oklch(0.60 0.10 185)",dark:"oklch(0.70 0.12 183)"},primaryForeground:{light:"oklch(0.98 0.01 181)",dark:"oklch(0.28 0.04 193)"}},{name:"cyan",label:"Cyan",primary:{light:"oklch(0.61 0.11 222)",dark:"oklch(0.71 0.13 215)"},primaryForeground:{light:"oklch(0.98 0.02 201)",dark:"oklch(0.30 0.05 230)"}},{name:"sky",label:"Sky",primary:{light:"oklch(0.59 0.14 242)",dark:"oklch(0.68 0.15 237)"},primaryForeground:{light:"oklch(0.98 0.01 237)",dark:"oklch(0.29 0.06 243)"}},{name:"blue",label:"Blue",primary:{light:"oklch(0.488 0.243 264.376)",dark:"oklch(0.42 0.18 266)"},primaryForeground:{light:"oklch(0.97 0.014 254.604)",dark:"oklch(0.97 0.014 254.604)"}},{name:"indigo",label:"Indigo",primary:{light:"oklch(0.51 0.23 277)",dark:"oklch(0.59 0.20 277)"},primaryForeground:{light:"oklch(0.96 0.02 272)",dark:"oklch(0.96 0.02 272)"}},{name:"violet",label:"Violet",primary:{light:"oklch(0.541 0.281 293.009)",dark:"oklch(0.606 0.25 292.717)"},primaryForeground:{light:"oklch(0.969 0.016 293.756)",dark:"oklch(0.969 0.016 293.756)"}},{name:"purple",label:"Purple",primary:{light:"oklch(0.56 0.25 302)",dark:"oklch(0.63 0.23 304)"},primaryForeground:{light:"oklch(0.98 0.01 308)",dark:"oklch(0.98 0.01 308)"}},{name:"fuchsia",label:"Fuchsia",primary:{light:"oklch(0.59 0.26 323)",dark:"oklch(0.67 0.26 322)"},primaryForeground:{light:"oklch(0.98 0.02 320)",dark:"oklch(0.98 0.02 320)"}},{name:"pink",label:"Pink",primary:{light:"oklch(0.59 0.22 1)",dark:"oklch(0.66 0.21 354)"},primaryForeground:{light:"oklch(0.97 0.01 343)",dark:"oklch(0.97 0.01 343)"}},{name:"rose",label:"Rose",primary:{light:"oklch(0.586 0.253 17.585)",dark:"oklch(0.645 0.246 16.439)"},primaryForeground:{light:"oklch(0.969 0.015 12.422)",dark:"oklch(0.969 0.015 12.422)"}}];});function he(e){return {name:e.name,label:e.label,colors:{light:{...W.light,primary:e.primary.light,"primary-foreground":e.primaryForeground?.light??J.light,destructive:e.destructive?.light??H.light},dark:{...W.dark,primary:e.primary.dark,"primary-foreground":e.primaryForeground?.dark??J.dark,destructive:e.destructive?.dark??H.dark}}}}function V(e){return E.find(o=>o.name===e)}var W,H,J,E,T=p(()=>{_();W={light:{background:"oklch(1 0 0)",foreground:"oklch(0.145 0 0)",card:"oklch(1 0 0)","card-foreground":"oklch(0.145 0 0)",popover:"oklch(1 0 0)","popover-foreground":"oklch(0.145 0 0)",secondary:"oklch(0.97 0 0)","secondary-foreground":"oklch(0.205 0 0)",muted:"oklch(0.97 0 0)","muted-foreground":"oklch(0.556 0 0)",accent:"oklch(0.97 0 0)","accent-foreground":"oklch(0.205 0 0)",border:"oklch(0.922 0 0)",input:"oklch(0.922 0 0)",ring:"oklch(0.708 0 0)"},dark:{background:"oklch(0.145 0 0)",foreground:"oklch(0.985 0 0)",card:"oklch(0.205 0 0)","card-foreground":"oklch(0.985 0 0)",popover:"oklch(0.205 0 0)","popover-foreground":"oklch(0.985 0 0)",secondary:"oklch(0.269 0 0)","secondary-foreground":"oklch(0.985 0 0)",muted:"oklch(0.269 0 0)","muted-foreground":"oklch(0.708 0 0)",accent:"oklch(0.269 0 0)","accent-foreground":"oklch(0.985 0 0)",border:"oklch(1 0 0 / 10%)",input:"oklch(1 0 0 / 15%)",ring:"oklch(0.556 0 0)"}},H={light:"oklch(0.577 0.245 27.325)",dark:"oklch(0.704 0.191 22.216)"},J={light:"oklch(0.985 0 0)",dark:"oklch(0.985 0 0)"};E=U.map(he);});function Y(e){return y.find(o=>o.value===e)}var y,M=p(()=>{y=[{label:"Inter",value:"inter",fontFamily:'"Inter", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap"},{label:"Noto Sans",value:"noto-sans",fontFamily:'"Noto Sans", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Noto+Sans:wght@400;500;600;700&display=swap"},{label:"Nunito Sans",value:"nunito-sans",fontFamily:'"Nunito Sans", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;500;600;700&display=swap"},{label:"Figtree",value:"figtree",fontFamily:'"Figtree", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&display=swap"},{label:"Roboto",value:"roboto",fontFamily:'"Roboto", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap"},{label:"Raleway",value:"raleway",fontFamily:'"Raleway", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Raleway:wght@400;500;600;700&display=swap"},{label:"DM Sans",value:"dm-sans",fontFamily:'"DM Sans", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap"},{label:"Public Sans",value:"public-sans",fontFamily:'"Public Sans", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Public+Sans:wght@400;500;600;700&display=swap"},{label:"Outfit",value:"outfit",fontFamily:'"Outfit", sans-serif',googleFontsUrl:"https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap"},{label:"JetBrains Mono",value:"jetbrains-mono",fontFamily:'"JetBrains Mono", monospace',googleFontsUrl:"https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&display=swap"}];});function ke(){let e=document.getElementById(L);if(e instanceof HTMLStyleElement)return e;e&&e.remove();let o=document.createElement("style");return o.id=L,document.head.appendChild(o),o}function z(e){return Object.entries(e).map(([o,r])=>`--${o}: ${r};`).join(" ")}function w(e){let o=document.documentElement;e?(o.classList.remove("light"),o.classList.add("dark")):(o.classList.remove("dark"),o.classList.add("light")),o.style.colorScheme=e?"dark":"light";}function b(e){document.documentElement.style.setProperty("--radius",e);}function C(e){let o=V(e);if(!o)return;let r=ke(),n=z(o.colors.light),c=z(o.colors.dark);r.textContent=`:root { ${n} } .dark { ${c} }`;}function fe(){let e=document.getElementById(R);if(e instanceof HTMLStyleElement)return e;e&&e.remove();let o=document.createElement("style");return o.id=R,document.head.appendChild(o),o}function P(e){let o=Y(e);if(!o)return;let{fontFamily:r,googleFontsUrl:n}=o;if(!n.startsWith("https://fonts.googleapis.com/")){console.warn("[PreviewCN] Invalid font URL");return}let c=`previewcn-font-${e}`;if(!document.getElementById(c)){let a=document.createElement("link");a.id=c,a.rel="stylesheet",a.href=n,document.head.appendChild(a);}let m=fe();m.textContent=`
|
|
3
3
|
:root {
|
|
4
4
|
--font-sans: ${r} !important;
|
|
5
5
|
--font-sans-override: ${r} !important;
|
|
@@ -8,5 +8,5 @@ import {lazy,useRef,useEffect,useCallback,useState,Suspense}from'react';import {
|
|
|
8
8
|
html, body, .font-sans {
|
|
9
9
|
font-family: ${r} !important;
|
|
10
10
|
}
|
|
11
|
-
`;}function I(e){e.colorPreset!==null&&C(e.colorPreset),e.radius!==null&&b(e.radius),e.darkMode!==null&&w(e.darkMode),e.font!==null&&P(e.font);}function A(){let e=document.getElementById(L);e&&e.remove();let o=document.getElementById(R);o&&o.remove();let r=document.documentElement;r.style.removeProperty("--radius"),r.style.removeProperty("color-scheme"),r.classList.remove("light","dark");}var L,R,F=p(()=>{T();M();L="previewcn-devtools-theme-colors",R="previewcn-devtools-theme-font";});function ye(){if(typeof window>"u")return {};try{let e=localStorage.getItem(D);if(e)return JSON.parse(e)}catch{}return {}}function S(e){if(!(typeof window>"u"))try{localStorage.setItem(D,JSON.stringify(e));}catch{}}function K(){let[e,o]=useState(()=>({...G,...ye()})),r=useCallback(i=>{o(d=>{let s={...d,colorPreset:i};return S(s),s}),C(i);},[]),
|
|
11
|
+
`;}function I(e){e.colorPreset!==null&&C(e.colorPreset),e.radius!==null&&b(e.radius),e.darkMode!==null&&w(e.darkMode),e.font!==null&&P(e.font);}function A(){let e=document.getElementById(L);e&&e.remove();let o=document.getElementById(R);o&&o.remove();let r=document.documentElement;r.style.removeProperty("--radius"),r.style.removeProperty("color-scheme"),r.classList.remove("light","dark");}var L,R,F=p(()=>{T();M();L="previewcn-devtools-theme-colors",R="previewcn-devtools-theme-font";});function ye(){if(typeof window>"u")return {};try{let e=localStorage.getItem(D);if(e)return JSON.parse(e)}catch{}return {}}function S(e){if(!(typeof window>"u"))try{localStorage.setItem(D,JSON.stringify(e));}catch{}}function K(){let[e,o]=useState(()=>({...G,...ye()})),r=useCallback(i=>{o(d=>{let s={...d,colorPreset:i};return S(s),s}),C(i);},[]),n=useCallback(i=>{o(d=>{let s={...d,radius:i};return S(s),s}),b(i);},[]),c=useCallback(i=>{o(d=>{let s={...d,darkMode:i};return S(s),s}),w(i);},[]),m=useCallback(i=>{o(d=>{let s={...d,font:i};return S(s),s}),P(i);},[]),a=useCallback(()=>{typeof window<"u"&&localStorage.removeItem(D),A(),o(G);},[]);return {config:e,setColorPreset:r,setRadius:n,setDarkMode:c,setFont:m,resetTheme:a}}var D,G,j=p(()=>{"use client";F();D="previewcn-devtools-theme";G={colorPreset:null,radius:null,darkMode:null,font:null};});function X({value:e,onChange:o}){return jsxs("div",{className:"previewcn-section",children:[jsx("label",{className:"previewcn-label",children:"Color"}),jsx("div",{className:"previewcn-color-grid",children:E.map(r=>{let n=e===r.name,c=r.colors.light.primary;return jsx("button",{onClick:()=>o(r.name),className:`previewcn-color-swatch ${n?"previewcn-color-swatch--selected":""}`,style:{backgroundColor:c},"aria-label":r.label,title:r.label},r.name)})})]})}var Z=p(()=>{"use client";T();});function Ce(){return jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"m6 9 6 6 6-6"})})}function q({value:e,onChange:o}){let[r,n]=useState(false),m=y.find(a=>a.value===e)?.label??"Select font...";return jsxs("div",{className:"previewcn-section",children:[jsx("label",{className:"previewcn-label",children:"Font"}),jsxs("div",{className:"previewcn-select-wrapper",children:[jsxs("button",{onClick:()=>n(!r),className:"previewcn-select-trigger","aria-expanded":r,children:[jsx("span",{children:m}),jsx(Ce,{})]}),r&&jsx("div",{className:"previewcn-select-dropdown",children:y.map(a=>jsx("button",{onClick:()=>{o(a.value),n(false);},className:`previewcn-select-option ${e===a.value?"previewcn-select-option--selected":""}`,children:a.label},a.value))})]})]})}var Q=p(()=>{"use client";M();});function Pe(){return jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"12",cy:"12",r:"4"}),jsx("path",{d:"M12 2v2"}),jsx("path",{d:"M12 20v2"}),jsx("path",{d:"m4.93 4.93 1.41 1.41"}),jsx("path",{d:"m17.66 17.66 1.41 1.41"}),jsx("path",{d:"M2 12h2"}),jsx("path",{d:"M20 12h2"}),jsx("path",{d:"m6.34 17.66-1.41 1.41"}),jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})}function Fe(){return jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z"})})}function ee({value:e,onChange:o}){let r=e??false;return jsxs("div",{className:"previewcn-section",children:[jsx("label",{className:"previewcn-label",children:"Mode"}),jsxs("div",{className:"previewcn-mode-toggle",children:[jsxs("button",{onClick:()=>o(false),className:`previewcn-mode-btn ${r?"":"previewcn-mode-btn--selected"}`,"aria-label":"Light mode",children:[jsx(Pe,{}),jsx("span",{children:"Light"})]}),jsxs("button",{onClick:()=>o(true),className:`previewcn-mode-btn ${r?"previewcn-mode-btn--selected":""}`,"aria-label":"Dark mode",children:[jsx(Fe,{}),jsx("span",{children:"Dark"})]})]})]})}var oe=p(()=>{"use client";});var re,te=p(()=>{re=[{name:"none",label:"None",value:"0rem"},{name:"sm",label:"SM",value:"0.3rem"},{name:"md",label:"MD",value:"0.5rem"},{name:"lg",label:"LG",value:"0.625rem"},{name:"xl",label:"XL",value:"0.75rem"},{name:"full",label:"Full",value:"1rem"}];});function ne({value:e,onChange:o}){return jsxs("div",{className:"previewcn-section",children:[jsx("label",{className:"previewcn-label",children:"Radius"}),jsx("div",{className:"previewcn-radius-grid",children:re.map(r=>{let n=e===r.value;return jsxs("button",{onClick:()=>o(r.value),className:`previewcn-radius-btn ${n?"previewcn-radius-btn--selected":""}`,title:r.label,children:[jsx("span",{className:"previewcn-radius-preview",style:{borderRadius:r.value}}),jsx("span",{className:"previewcn-radius-label",children:r.label})]},r.name)})})]})}var ae=p(()=>{"use client";te();});var ce={};me(ce,{default:()=>se});function Ne(){return jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M18 6 6 18"}),jsx("path",{d:"m6 6 12 12"})]})}function Ee(){return jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),jsx("path",{d:"M3 3v5h5"})]})}function se({onClose:e}){let{config:o,setColorPreset:r,setRadius:n,setDarkMode:c,setFont:m,resetTheme:a}=K(),i=useRef(false);useEffect(()=>{i.current||(i.current=true,I(o));},[o]);let d=useCallback(v=>{v.key==="Escape"&&e();},[e]);return useEffect(()=>(window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)),[d]),jsx("div",{className:"previewcn-backdrop",onClick:v=>{v.target===v.currentTarget&&e();},children:jsxs("div",{className:"previewcn-panel",children:[jsxs("div",{className:"previewcn-header",children:[jsxs("div",{className:"previewcn-title",children:[jsx("span",{className:"previewcn-logo",children:"PreviewCN"}),jsx("span",{className:"previewcn-badge",children:"DEV"})]}),jsx("button",{onClick:e,className:"previewcn-close-btn","aria-label":"Close",children:jsx(Ne,{})})]}),jsxs("div",{className:"previewcn-content",children:[jsx(X,{value:o.colorPreset,onChange:r}),jsx(ne,{value:o.radius,onChange:n}),jsx(q,{value:o.font,onChange:m}),jsx(ee,{value:o.darkMode,onChange:c})]}),jsx("div",{className:"previewcn-footer",children:jsxs("button",{onClick:a,className:"previewcn-reset-btn",children:[jsx(Ee,{}),jsx("span",{children:"Reset"})]})})]})})}var de=p(()=>{"use client";j();F();Z();Q();oe();ae();});function ue(){return jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[jsx("circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor"}),jsx("circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor"}),jsx("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.555C21.965 6.012 17.461 2 12 2z"})]})}function $({onClick:e}){return jsx("button",{onClick:e,className:"previewcn-trigger","aria-label":"Open PreviewCN theme editor",title:"PreviewCN Theme Editor",children:jsx(ue,{})})}var Re=lazy(()=>Promise.resolve().then(()=>(de(),ce))),Ie=process.env.NODE_ENV==="development";function De(){let[e,o]=useState(false);return jsxs(Fragment,{children:[jsx($,{onClick:()=>o(true)}),e&&jsx(Suspense,{fallback:null,children:jsx(Re,{onClose:()=>o(false)})})]})}function Oe(){return Ie?jsx(De,{}):null}F();
|
|
12
12
|
export{Oe as PreviewcnDevtools,C as applyColors,w as applyDarkMode,P as applyFont,b as applyRadius,I as applyTheme};
|
package/dist/styles.css
CHANGED
|
@@ -238,9 +238,6 @@
|
|
|
238
238
|
align-items: flex-end;
|
|
239
239
|
justify-content: flex-end;
|
|
240
240
|
padding: calc(var(--spacing) * 4);
|
|
241
|
-
background: oklch(0 0 0 / 30%);
|
|
242
|
-
backdrop-filter: blur(2px);
|
|
243
|
-
animation: previewcn-fade-in 0.15s ease-out;
|
|
244
241
|
}
|
|
245
242
|
.previewcn-panel {
|
|
246
243
|
display: flex;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@previewcn/devtools",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"description": "Embedded devtools for PreviewCN - real-time shadcn/ui theme preview inside your app",
|
|
5
5
|
"keywords": ["shadcn", "shadcn-ui", "theme", "preview", "devtools", "react", "tailwind"],
|
|
6
6
|
"license": "MIT",
|