tekivex-ui 2.5.2 → 2.5.3
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/TkxForm-DSMDo2Ol.js +388 -0
- package/dist/TkxForm-DwV_n-eE.cjs +12 -0
- package/dist/headless.cjs +1 -1
- package/dist/headless.js +396 -195
- package/dist/i18n.cjs +1 -0
- package/dist/i18n.js +757 -0
- package/dist/index.cjs +27 -22
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4994 -5089
- package/dist/quantum.cjs +91 -0
- package/dist/quantum.js +2312 -0
- package/dist/realtime.cjs +25 -0
- package/dist/realtime.js +944 -0
- package/dist/security-C369oOWH.cjs +1 -0
- package/dist/security-CzAmaMqa.js +97 -0
- package/dist/src/components/TkxDataGrid.d.ts +9 -1
- package/dist/src/components/TkxDataGrid.d.ts.map +1 -1
- package/dist/src/components/TkxDropdown.d.ts +41 -0
- package/dist/src/components/TkxDropdown.d.ts.map +1 -0
- package/dist/src/components/TkxLiveFeed.d.ts +891 -0
- package/dist/src/components/TkxLiveFeed.d.ts.map +1 -0
- package/dist/src/components/TkxLiveLog.d.ts +892 -0
- package/dist/src/components/TkxLiveLog.d.ts.map +1 -0
- package/dist/src/components/TkxLiveMetrics.d.ts +24 -0
- package/dist/src/components/TkxLiveMetrics.d.ts.map +1 -0
- package/dist/src/components/TkxPlayground.d.ts +15 -0
- package/dist/src/components/TkxPlayground.d.ts.map +1 -0
- package/dist/src/components/TkxQuantumForm.d.ts +20 -0
- package/dist/src/components/TkxQuantumForm.d.ts.map +1 -0
- package/dist/src/components/TkxRealTimeChart.d.ts +27 -0
- package/dist/src/components/TkxRealTimeChart.d.ts.map +1 -0
- package/dist/src/components/TkxTable.d.ts +11 -1
- package/dist/src/components/TkxTable.d.ts.map +1 -1
- package/dist/src/components/TkxThemeBuilder.d.ts +9 -0
- package/dist/src/components/TkxThemeBuilder.d.ts.map +1 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/engine/index.d.ts +2 -0
- package/dist/src/engine/index.d.ts.map +1 -1
- package/dist/src/engine/quantum-ai.d.ts +201 -0
- package/dist/src/engine/quantum-ai.d.ts.map +1 -0
- package/dist/src/engine/tkx.d.ts.map +1 -1
- package/dist/src/headless/index.d.ts +6 -0
- package/dist/src/headless/index.d.ts.map +1 -1
- package/dist/src/headless/useInfiniteQuery.d.ts +35 -0
- package/dist/src/headless/useInfiniteQuery.d.ts.map +1 -0
- package/dist/src/headless/useSSE.d.ts +36 -0
- package/dist/src/headless/useSSE.d.ts.map +1 -0
- package/dist/src/headless/useWebSocket.d.ts +33 -0
- package/dist/src/headless/useWebSocket.d.ts.map +1 -0
- package/dist/src/quantum/index.d.ts +9 -0
- package/dist/src/quantum/index.d.ts.map +1 -0
- package/dist/src/realtime/index.d.ts +9 -0
- package/dist/src/realtime/index.d.ts.map +1 -0
- package/dist/{TkxForm-BWK4LqY3.js → tkx-BJ10JtMv.js} +372 -721
- package/dist/tkx-BeNyC0w7.cjs +4 -0
- package/package.json +16 -1
- package/src/components/TkxDataGrid.tsx +72 -0
- package/src/components/TkxDropdown.tsx +802 -0
- package/src/components/TkxLiveFeed.tsx +329 -0
- package/src/components/TkxLiveLog.tsx +470 -0
- package/src/components/TkxLiveMetrics.tsx +291 -0
- package/src/components/TkxPlayground.tsx +736 -0
- package/src/components/TkxQuantumForm.tsx +592 -0
- package/src/components/TkxRealTimeChart.tsx +381 -0
- package/src/components/TkxTable.tsx +351 -77
- package/src/components/TkxThemeBuilder.tsx +685 -0
- package/src/components/index.ts +4 -0
- package/src/engine/index.ts +2 -0
- package/src/engine/quantum-ai.ts +1045 -0
- package/src/engine/tkx.ts +95 -4
- package/src/headless/index.ts +6 -0
- package/src/headless/useInfiniteQuery.ts +153 -0
- package/src/headless/useSSE.ts +165 -0
- package/src/headless/useWebSocket.ts +229 -0
- package/src/quantum/index.ts +39 -0
- package/src/realtime/index.ts +21 -0
- package/dist/TkxForm-ljQjX7KD.cjs +0 -15
package/dist/quantum.cjs
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),x=require("react"),Z=require("./index-BINBzXuY.cjs"),se=require("./tkx-BeNyC0w7.cjs"),Y=require("./security-C369oOWH.cjs");class R{constructor(e,o){this.re=e,this.im=o}add(e){return new R(this.re+e.re,this.im+e.im)}sub(e){return new R(this.re-e.re,this.im-e.im)}mul(e){return new R(this.re*e.re-this.im*e.im,this.re*e.im+this.im*e.re)}scale(e){return new R(this.re*e,this.im*e)}conjugate(){return new R(this.re,-this.im)}magnitudeSquared(){return this.re*this.re+this.im*this.im}magnitude(){return Math.sqrt(this.magnitudeSquared())}static fromPolar(e,o){return new R(e*Math.cos(o),e*Math.sin(o))}static zero(){return new R(0,0)}static one(){return new R(1,0)}}class I{constructor(e=R.one(),o=R.zero()){this.alpha=e,this.beta=o,this.normalize()}normalize(){const e=Math.sqrt(this.alpha.magnitudeSquared()+this.beta.magnitudeSquared());e>0&&(this.alpha=this.alpha.scale(1/e),this.beta=this.beta.scale(1/e))}hadamard(){const e=1/Math.SQRT2,o=this.alpha.add(this.beta).scale(e),a=this.alpha.sub(this.beta).scale(e);return new I(o,a)}ry(e){const o=Math.cos(e/2),a=Math.sin(e/2),r=this.alpha.scale(o).sub(this.beta.scale(a)),l=this.alpha.scale(a).add(this.beta.scale(o));return new I(r,l)}phase(e){const o=R.fromPolar(1,e);return new I(this.alpha,this.beta.mul(o))}measure(){const e=this.beta.magnitudeSquared();return Math.random()<e?1:0}expectation(){return this.beta.magnitudeSquared()}getAlpha(){return this.alpha}getBeta(){return this.beta}}class ae{constructor(e){this.qubits=Array.from({length:e},()=>new I)}get size(){return this.qubits.length}getQubit(e){return this.qubits[e]}superpose(){this.qubits=this.qubits.map(e=>e.hadamard())}cnot(e,o){const a=this.qubits[e],r=this.qubits[o],l=a.expectation();this.qubits[o]=r.ry(Math.PI*l)}rotate(e,o){this.qubits[e]=this.qubits[e].ry(o)}measure(){return this.qubits.map(e=>e.measure())}probs(){return this.qubits.map(e=>e.expectation())}}class V{constructor(e=1,o=.995,a=.3,r=1e-6){this.temperature=e,this.coolingRate=o,this.tunnelingStrength=a,this.minTemp=r}anneal(e,o,a,r=1e3){let l=e,i=o(l),d=l,s=i,c=this.temperature,g=0,h=0;for(let m=0;m<r&&c>this.minTemp;m++){const b=a(l),p=o(b),v=p-i;let S=!1;if(v<=0)S=!0;else{const k=Math.exp(-v/c),q=Math.sqrt(2*Math.abs(v)),E=Math.abs(v),w=Math.exp(-2*q*Math.sqrt(E)*this.tunnelingStrength);Math.random()<k+w&&(S=!0,Math.random()<w/(k+w+1e-10)&&h++)}S&&(l=b,i=p,g++,i<s&&(d=l,s=i)),c*=this.coolingRate}return{state:d,energy:s,iterations:r,accepted:g,tunnels:h}}}class ie{constructor(e,o){const a=Math.sqrt(2/(e+o));this.weights=Array.from({length:e},()=>Array.from({length:o},()=>(Math.random()*2-1)*a)),this.visibleBias=Array.from({length:e},()=>0),this.hiddenBias=Array.from({length:o},()=>0)}sigmoid(e){const o=(Math.random()-.5)*.1;return 1/(1+Math.exp(-(e+o)))}sample(e){return Math.random()<e?1:0}energy(e,o){const a=this.visibleBias.reduce((i,d,s)=>i+d*e[s],0),r=this.hiddenBias.reduce((i,d,s)=>i+d*o[s],0);let l=0;for(let i=0;i<e.length;i++)for(let d=0;d<o.length;d++)l+=e[i]*this.weights[i][d]*o[d];return-(a+r+l)}hiddenProbs(e){return this.hiddenBias.map((o,a)=>{const r=o+e.reduce((l,i,d)=>l+this.weights[d][a]*i,0);return this.sigmoid(r)})}visibleProbs(e){return this.visibleBias.map((o,a)=>{const r=o+e.reduce((l,i,d)=>l+this.weights[a][d]*i,0);return this.sigmoid(r)})}gibbs(e,o=1){let a=[...e],r=[];for(let l=0;l<o;l++)r=this.hiddenProbs(a).map(i=>this.sample(i)),a=this.visibleProbs(r).map(i=>this.sample(i));return{visible:a,hidden:r}}trainCD1(e,o=.01){const a=this.visibleBias.length,r=this.hiddenBias.length,l=Array.from({length:a},()=>Array(r).fill(0)),i=Array(a).fill(0),d=Array(r).fill(0);for(const c of e){const g=this.hiddenProbs(c),h=g.map(p=>this.sample(p)),m=this.visibleProbs(h).map(p=>this.sample(p)),b=this.hiddenProbs(m);for(let p=0;p<a;p++){for(let v=0;v<r;v++)l[p][v]+=c[p]*g[v]-m[p]*b[v];i[p]+=c[p]-m[p]}for(let p=0;p<r;p++)d[p]+=g[p]-b[p]}const s=e.length;for(let c=0;c<a;c++){for(let g=0;g<r;g++)this.weights[c][g]+=o*l[c][g]/s;this.visibleBias[c]+=o*i[c]/s}for(let c=0;c<r;c++)this.hiddenBias[c]+=o*d[c]/s}infer(e){const o=this.hiddenProbs(e),a=o.map(l=>this.sample(l)),r=this.visibleProbs(a);return{hidden:o,visible:r,energy:this.energy(e,a),iterations:1}}}class G{amplify(e,o,a=.5){const r=e.length;if(r===0)return[];const l=e.map(o),i=l.filter(h=>h>a).length,d=Math.max(1,i);let s=Array(r).fill(1/Math.sqrt(r));const c=Math.max(1,Math.floor(Math.PI/4*Math.sqrt(r/d)));for(let h=0;h<c;h++){for(let b=0;b<r;b++)l[b]>a&&(s[b]=-s[b]);const m=s.reduce((b,p)=>b+p,0)/r;s=s.map(b=>2*m-b)}return e.map((h,m)=>({index:m,amplitude:s[m],probability:s[m]*s[m],classicalSimilarity:l[m],combined:s[m]*s[m]*.6+l[m]*.4})).sort((h,m)=>m.combined-h.combined)}}const J=[{keywords:["email","e-mail","mail"],type:"email",validations:[{rule:"required",message:"Email is required"},{rule:"pattern",value:"^[^@]+@[^@]+\\.[^@]+$",message:"Enter a valid email address"},{rule:"maxLength",value:254,message:"Email too long"}],placeholder:"you@example.com",label:"Email Address",confidence:.98},{keywords:["password","passwd","pwd","pass"],type:"password",validations:[{rule:"required",message:"Password is required"},{rule:"minLength",value:8,message:"Password must be at least 8 characters"},{rule:"pattern",value:"(?=.*[A-Z])(?=.*[0-9])",message:"Include uppercase and a number"}],placeholder:"••••••••",label:"Password",confidence:.97},{keywords:["confirm_password","confirmpassword","confirm_pass","repassword","password2","repeat_password"],type:"password",validations:[{rule:"required",message:"Please confirm your password"},{rule:"match",value:"password",message:"Passwords do not match"}],placeholder:"••••••••",label:"Confirm Password",confidence:.95},{keywords:["phone","mobile","cell","tel","telephone","contact_number"],type:"tel",validations:[{rule:"pattern",value:"^[+]?[(]?[0-9]{3}[)]?[-\\s.]?[0-9]{3}[-\\s.]?[0-9]{4,6}$",message:"Enter a valid phone number"}],placeholder:"+1 (555) 000-0000",label:"Phone Number",confidence:.93},{keywords:["age"],type:"number",validations:[{rule:"min",value:0,message:"Age cannot be negative"},{rule:"max",value:150,message:"Enter a valid age"},{rule:"integer",message:"Age must be a whole number"}],placeholder:"25",label:"Age",confidence:.9},{keywords:["price","amount","cost","fee","payment","salary","wage","total"],type:"number",validations:[{rule:"min",value:0,message:"Amount cannot be negative"},{rule:"pattern",value:"^\\d+(\\.\\d{1,2})?$",message:"Enter a valid amount (e.g. 9.99)"}],placeholder:"0.00",label:"Amount",confidence:.88},{keywords:["url","website","site","link","homepage","web"],type:"url",validations:[{rule:"pattern",value:"https?://.+",message:"Enter a valid URL starting with http:// or https://"}],placeholder:"https://example.com",label:"Website URL",confidence:.92},{keywords:["zip","zipcode","postal","postcode","pin_code"],type:"text",validations:[{rule:"pattern",value:"^[0-9]{5}(-[0-9]{4})?$",message:"Enter a valid ZIP code (e.g. 12345)"}],placeholder:"12345",label:"ZIP / Postal Code",confidence:.91},{keywords:["date","dob","birthday","birth_date","birthdate","born"],type:"date",validations:[{rule:"required",message:"Date is required"}],placeholder:"YYYY-MM-DD",label:"Date of Birth",confidence:.89},{keywords:["first_name","firstname","fname","given_name"],type:"text",validations:[{rule:"minLength",value:2,message:"First name too short"},{rule:"maxLength",value:50,message:"First name too long"}],placeholder:"Jane",label:"First Name",confidence:.9},{keywords:["last_name","lastname","lname","surname","family_name"],type:"text",validations:[{rule:"minLength",value:2,message:"Last name too short"},{rule:"maxLength",value:50,message:"Last name too long"}],placeholder:"Doe",label:"Last Name",confidence:.9},{keywords:["name","full_name","fullname","display_name"],type:"text",validations:[{rule:"minLength",value:2,message:"Name too short"},{rule:"maxLength",value:100,message:"Name too long"}],placeholder:"Jane Doe",label:"Full Name",confidence:.85},{keywords:["username","user_name","handle","login","loginname"],type:"text",validations:[{rule:"minLength",value:3,message:"Username must be at least 3 characters"},{rule:"maxLength",value:32,message:"Username too long"},{rule:"pattern",value:"^[a-zA-Z0-9_.-]+$",message:"Only letters, numbers, _, - and . allowed"}],placeholder:"cooluser42",label:"Username",confidence:.94},{keywords:["bio","biography","about","description","summary","details"],type:"textarea",validations:[{rule:"maxLength",value:500,message:"Bio must be under 500 characters"}],placeholder:"Tell us about yourself...",label:"Bio",confidence:.87},{keywords:["message","comment","feedback","note","notes","remarks","body"],type:"textarea",validations:[{rule:"minLength",value:10,message:"Message too short"},{rule:"maxLength",value:2e3,message:"Message too long"}],placeholder:"Write your message here...",label:"Message",confidence:.86},{keywords:["search","query","q","keyword","find"],type:"search",validations:[],placeholder:"Search...",label:"Search",confidence:.9},{keywords:["otp","one_time_password","verification_code","pin","code"],type:"text",validations:[{rule:"minLength",value:4,message:"Code too short"},{rule:"maxLength",value:8,message:"Code too long"},{rule:"pattern",value:"^[0-9]+$",message:"Code must be numeric"}],placeholder:"123456",label:"Verification Code",confidence:.92},{keywords:["color","colour","hex_color","brand_color"],type:"color",validations:[],placeholder:"#3b82f6",label:"Color",confidence:.95},{keywords:["address","street","street_address","addr"],type:"text",validations:[{rule:"maxLength",value:200,message:"Address too long"}],placeholder:"123 Main Street",label:"Street Address",confidence:.87},{keywords:["city","town","municipality"],type:"text",validations:[{rule:"maxLength",value:100,message:"City name too long"}],placeholder:"San Francisco",label:"City",confidence:.89},{keywords:["country","nation","country_code"],type:"text",validations:[],placeholder:"United States",label:"Country",confidence:.88},{keywords:["company","organization","org","employer","company_name"],type:"text",validations:[{rule:"maxLength",value:200,message:"Company name too long"}],placeholder:"Acme Inc.",label:"Company",confidence:.87}];function X(n){const e=n.toLowerCase().replace(/[\s-]/g,"_"),a=new G().amplify(J,r=>{let l=0;for(const i of r.keywords)e===i?l=Math.max(l,1):e.includes(i)||i.includes(e)?l=Math.max(l,.8):i.split("_").some(d=>e.includes(d))&&(l=Math.max(l,.5));return l},.3);if(a.length>0&&a[0].combined>.1){const r=J[a[0].index];return{type:r.type,validations:r.validations,placeholder:r.placeholder,confidence:Math.min(r.confidence*a[0].combined*2,.99),label:r.label}}return{type:"text",validations:[{rule:"maxLength",value:255,message:"Input too long"}],placeholder:n.replace(/_/g," "),confidence:.3,label:n.replace(/_/g," ").replace(/\b\w/g,r=>r.toUpperCase())}}function O(n,e,o){const a=e/100,r=o/100,l=a*Math.min(r,1-r),i=d=>{const s=(d+n/30)%12,c=r-l*Math.max(Math.min(s-3,9-s,1),-1);return Math.round(255*c).toString(16).padStart(2,"0")};return`#${i(0)}${i(8)}${i(4)}`}function ue(n){const e=n.replace("#",""),o=e.length===3?e.split("").map(a=>a+a).join(""):e;return[parseInt(o.slice(0,2),16),parseInt(o.slice(2,4),16),parseInt(o.slice(4,6),16)]}function K(n){const[e,o,a]=ue(n).map(r=>{const l=r/255;return l<=.03928?l/12.92:((l+.055)/1.055)**2.4});return .2126*e+.7152*o+.0722*a}function H(n,e){const o=K(n),a=K(e),r=Math.max(o,a),l=Math.min(o,a);return(r+.05)/(l+.05)}function pe(n,e){const o=r=>O(r.h,r.s,r.l),a=e?n.text.l-20:n.text.l+15;return{primary:o(n.primary),secondary:o(n.secondary),background:o(n.bg),surface:o(n.surface),text:o(n.text),textMuted:O(n.text.h,Math.max(0,n.text.s-10),Math.max(20,Math.min(85,a))),border:o(n.border),error:e?"#f87171":"#dc2626",warning:e?"#fbbf24":"#d97706",success:e?"#34d399":"#059669",accent:o(n.accent)}}function he(n,e){let o=0;const a=k=>O(k.h,k.s,k.l),r=a(n.text),l=a(n.bg),i=a(n.surface),d=a(n.primary),s=H(r,l),c=H(r,i),g=H(d,l);s<4.5&&(o+=(4.5-s)*10),c<4.5&&(o+=(4.5-c)*8),g<3&&(o+=(3-g)*5);const m=Math.abs((n.secondary.h-n.primary.h+360)%360-137.508);o+=m*.05;const b=Math.abs((n.accent.h-n.primary.h+360)%360-120);o+=b*.03;const p=(n.primary.s+n.secondary.s)/2;p<20&&(o+=(20-p)*.5),p>90&&(o+=(p-90)*.5);const v=n.bg.l;e?(v>25&&(o+=(v-25)*2),v<3&&(o+=(3-v)*2),n.text.l<70&&(o+=(70-n.text.l)*1.5)):(v<90&&(o+=(90-v)*2),v>100&&(o+=(v-100)*2),n.text.l>30&&(o+=(n.text.l-30)*1.5));const S=Math.abs(n.surface.l-n.bg.l);return S<2&&(o+=(2-S)*2),S>12&&(o+=(S-12)*1),o}function ee(n,e,o){return Math.max(e,Math.min(o,n))}function le(n,e,o=800){const a=e?{primary:{h:n,s:70,l:55},secondary:{h:(n+137.5)%360,s:65,l:50},bg:{h:n,s:10,l:8},surface:{h:n,s:10,l:13},text:{h:n,s:15,l:90},border:{h:n,s:15,l:22},accent:{h:(n+120)%360,s:75,l:60}}:{primary:{h:n,s:65,l:40},secondary:{h:(n+137.5)%360,s:55,l:38},bg:{h:n,s:15,l:97},surface:{h:n,s:12,l:100},text:{h:n,s:15,l:12},border:{h:n,s:12,l:85},accent:{h:(n+120)%360,s:70,l:42}},l=new V(1.5,.994,.35,1e-5).anneal(a,i=>he(i,e),i=>{const d=["primary","secondary","bg","surface","text","border","accent"],s=d[Math.floor(Math.random()*d.length)],c=["h","s","l"],g=c[Math.floor(Math.random()*c.length)],h=(Math.random()-.5)*(g==="h"?30:15),m={...i,[s]:{...i[s]}};return g==="h"?m[s]={...m[s],h:(i[s].h+h+360)%360}:g==="s"?m[s]={...m[s],s:ee(i[s].s+h,0,100)}:m[s]={...m[s],l:ee(i[s].l+h,0,100)},m},o);return pe(l.state,e)}const U={qubit(){return new I},register(n){return new ae(n)},annealer(n,e,o){return new V(n,e,o)},qbm(n,e){return new ie(n,e)},amplifier(){return new G},inferField:X,optimizeTheme:le,contrast:H,hslToHex:O};function me(n,e,o,a){const r=o.trim();switch(n){case"required":return r!=="";case"email":case"pattern":if(typeof e=="string")try{return r===""||new RegExp(e).test(r)}catch{return!0}return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r);case"phone":return r===""||/^\+?[\d\s\-()]{7,15}$/.test(r);case"url":return r===""||/^https?:\/\/.+/.test(r);case"minLength":case"min":{const l=Number(e??0);return r===""||(isNaN(Number(r))?r.length>=l:Number(r)>=l)}case"maxLength":case"max":{const l=Number(e??1/0);return r===""||(isNaN(Number(r))?r.length<=l:Number(r)<=l)}case"integer":return r===""||/^\d+$/.test(r);case"alphanumeric":return r===""||/^[a-zA-Z0-9]+$/.test(r);case"match":return r===(a[typeof e=="string"?e:"password"]??"");default:return!0}}function xe({phase:n,collapsed:e,primaryColor:o,borderColor:a}){const d=e?0:n,s=e?0:n*1.618,c=12+10*Math.sin(d)*Math.cos(s),g=12-10*Math.cos(d);return t.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24","aria-hidden":"true",style:{flexShrink:0,opacity:e?.4:1,transition:"opacity 0.6s"},children:[t.jsx("circle",{cx:12,cy:12,r:10,fill:"none",stroke:a,strokeWidth:"0.8"}),t.jsx("ellipse",{cx:12,cy:12,rx:10,ry:10*.3,fill:"none",stroke:a,strokeWidth:"0.5",strokeDasharray:"2 2"}),t.jsx("line",{x1:12,y1:2,x2:12,y2:22,stroke:a,strokeWidth:"0.5"}),t.jsx("line",{x1:12,y1:12,x2:c,y2:g,stroke:o,strokeWidth:"1.5",style:{transition:e?"all 0.6s ease-out":"none"}}),t.jsx("circle",{cx:c,cy:g,r:"2",fill:o,style:{transition:e?"all 0.6s ease-out":"none"}})]})}function ge({confidence:n,theme:e}){const o=Math.round(n*100),a=o>=80?e.success:o>=60?e.warning:e.danger;return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"2px",fontSize:"10px",fontWeight:600,padding:"1px 5px",borderRadius:"999px",backgroundColor:`${a}22`,color:a,border:`1px solid ${a}44`,marginLeft:"6px",verticalAlign:"middle",letterSpacing:"0.03em"},children:["⚛ ",o,"%"]})}function fe({config:n,intel:e,qubitPhase:o,value:a,error:r,touched:l,showConfidence:i,showQuantumState:d,collapsed:s,onChange:c,onBlur:g,theme:h,mounted:m,index:b}){const p=n.type??e.type,v=n.label??e.label,S=n.placeholder??e.placeholder,k=n.required!==void 0?n.required:e.validations.some($=>$.rule==="required"),q=Y.sanitizeString(v),E=p==="textarea",w=l&&r!=="",A=`qf-${n.name}`,W={width:"100%",padding:"9px 12px",border:`1.5px solid ${w?h.danger:h.border}`,borderRadius:"8px",backgroundColor:h.surface,color:h.text,fontSize:"14px",fontFamily:"inherit",outline:"none",boxSizing:"border-box",transition:"border-color 0.15s, box-shadow 0.15s",resize:E?"vertical":void 0,minHeight:E?"80px":void 0};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px",opacity:m?1:0,transform:m?"scaleY(1)":"scaleY(0.92)",transition:`opacity 0.35s ease ${b*60}ms, transform 0.35s ease ${b*60}ms`,transformOrigin:"top"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[d&&t.jsx(xe,{phase:o,collapsed:s,primaryColor:h.primary,borderColor:h.border}),t.jsxs("label",{htmlFor:A,style:{fontSize:"13px",fontWeight:500,color:h.text,cursor:"pointer"},children:[q,k&&t.jsx("span",{"aria-hidden":"true",style:{color:h.danger,marginLeft:"3px"},children:"*"})]}),i&&t.jsx(ge,{confidence:e.confidence,theme:h})]}),E?t.jsx("textarea",{id:A,value:a,onChange:$=>c($.target.value),onBlur:g,placeholder:S,"aria-invalid":w,"aria-required":k,style:W}):t.jsx("input",{id:A,type:p,value:a,onChange:$=>c($.target.value),onBlur:g,placeholder:S,"aria-invalid":w,"aria-required":k,style:W}),w&&t.jsxs("span",{role:"alert",style:{fontSize:"12px",color:h.danger,display:"flex",alignItems:"center",gap:"4px"},children:[t.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})}),Y.sanitizeString(r)]})]})}function ye(n){let e=2166136261;for(let o=0;o<n.length;o++)e^=n.charCodeAt(o),e=Math.imul(e,16777619)>>>0;return(e&65535)/65535*Math.PI*2}function de({fields:n,onSubmit:e,submitLabel:o="Submit",layout:a="vertical",showConfidence:r=!0,showQuantumState:l=!1}){const i=Z.useTheme(),d=n.map(f=>X(f.name)),[s,c]=x.useState(()=>Object.fromEntries(n.map(f=>[f.name,""]))),[g,h]=x.useState({}),[m,b]=x.useState({}),[p,v]=x.useState(!1),[S,k]=x.useState(!1),[q,E]=x.useState(!1);x.useEffect(()=>{const f=requestAnimationFrame(()=>k(!0));return()=>cancelAnimationFrame(f)},[]);const w=x.useCallback((f,u)=>{const y=n.find(M=>M.name===f),C=d[n.findIndex(M=>M.name===f)];if(!y||!C)return"";const j=u[f]??"";for(const{rule:M,value:P,message:_}of C.validations)if(!(M==="required"&&y.required===!1)&&!me(M,P,j,u))return _;return""},[n]),A=x.useCallback(f=>{const u={};for(const y of n){const C=w(y.name,f);C&&(u[y.name]=C)}return u},[n,w]),W=x.useCallback((f,u)=>{c(y=>{var j;const C={...y,[f]:u};if(m[f]&&(h(M=>({...M,[f]:w(f,C)})),f==="password")){const M=(j=n.find(P=>["confirmpassword","confirm_password","passwordconfirm"].includes(P.name.toLowerCase().replace(/[\s_-]/g,""))))==null?void 0:j.name;M&&m[M]&&h(P=>({...P,[M]:w(M,C)}))}return C}),E(!0)},[n,m,w]),$=x.useCallback(f=>{b(u=>({...u,[f]:!0})),h(u=>({...u,[f]:w(f,s)}))},[s,w]),N=x.useCallback(async f=>{f.preventDefault();const u=Object.fromEntries(n.map(C=>[C.name,!0]));b(u);const y=A(s);if(h(y),!(Object.keys(y).length>0)){v(!0);try{await e(s)}finally{v(!1)}}},[n,s,A,e]),B=d.length>0?Math.round(d.reduce((f,u)=>f+u.confidence,0)/d.length*100):0,F=B>=80?i.success:B>=60?i.warning:i.danger,L=a==="horizontal";return t.jsxs("form",{onSubmit:N,noValidate:!0,className:se.tkx("w-full"),style:{backgroundColor:i.surface,border:`1px solid ${i.border}`,borderRadius:"12px",padding:"24px",position:"relative",boxSizing:"border-box"},children:[t.jsx("span",{"aria-label":"Powered by Quantum AI",style:{position:"absolute",top:"16px",right:"16px",fontSize:"10px",fontWeight:700,padding:"3px 8px",borderRadius:"999px",backgroundColor:`${i.primary}20`,color:i.primary,border:`1px solid ${i.primary}44`,letterSpacing:"0.04em",userSelect:"none"},children:"⚛ Quantum AI"}),r&&t.jsxs("div",{style:{marginBottom:"20px",paddingRight:"100px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"},children:[t.jsx("span",{style:{fontSize:"11px",color:i.textMuted,fontWeight:500},children:"Form Intelligence Confidence"}),t.jsxs("span",{style:{fontSize:"11px",fontWeight:700,color:F},children:[B,"%"]})]}),t.jsx("div",{style:{height:"4px",borderRadius:"4px",backgroundColor:i.border,overflow:"hidden"},children:t.jsx("div",{style:{height:"100%",width:`${B}%`,backgroundColor:F,borderRadius:"4px",transition:"width 0.8s ease"}})})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:L?"repeat(auto-fill, minmax(260px, 1fr))":"1fr",gap:"16px",marginBottom:"20px"},children:n.map((f,u)=>t.jsx(fe,{config:f,intel:d[u],qubitPhase:ye(f.name),value:s[f.name]??"",error:g[f.name]??"",touched:m[f.name]??!1,showConfidence:r,showQuantumState:l,collapsed:q,onChange:y=>W(f.name,y),onBlur:()=>$(f.name),theme:i,mounted:S,index:u},f.name))}),t.jsx("button",{type:"submit",disabled:p,style:{width:"100%",padding:"10px 20px",borderRadius:"8px",border:"none",backgroundColor:p?`${i.primary}88`:i.primary,color:i.bg,fontSize:"14px",fontWeight:700,fontFamily:"inherit",cursor:p?"not-allowed":"pointer",transition:"background-color 0.15s, opacity 0.15s",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:p?t.jsxs(t.Fragment,{children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",style:{animation:"qf-spin 0.8s linear infinite"},"aria-hidden":"true",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10",strokeOpacity:"0.25"}),t.jsx("path",{d:"M12 2a10 10 0 0 1 10 10"})]}),"Processing…"]}):Y.sanitizeString(o)}),t.jsx("style",{children:"@keyframes qf-spin { to { transform: rotate(360deg); } }"})]})}de.displayName="TkxQuantumForm";function te(n){return n?{primary:"#00f5d4",secondary:"#7b2ff7",background:"#0a0a0f",surface:"#12121a",text:"#e8e8f4",textMuted:"#8888aa",border:"#2a2a3e",error:"#f87171",warning:"#fbbf24",success:"#34d399",accent:"#ff6b6b"}:{primary:"#0d7c5f",secondary:"#6930c3",background:"#f8f6f1",surface:"#ffffff",text:"#1a1815",textMuted:"#6b6560",border:"#ddd8cc",error:"#dc2626",warning:"#d97706",success:"#059669",accent:"#e05a00"}}function be({points:n,primary:e}){if(n.length<2)return t.jsx("div",{style:{height:48,display:"flex",alignItems:"center",justifyContent:"center",color:"#888",fontSize:12},children:"Waiting for data..."});const o=280,a=48,r=Math.max(...n.map(c=>c.energy)),l=Math.min(...n.map(c=>c.energy)),i=r-l||1,d=n[n.length-1].iteration||1,s=n.map(c=>{const g=c.iteration/d*o,h=a-(c.energy-l)/i*(a-4)-2;return`${g.toFixed(1)},${h.toFixed(1)}`}).join(" ");return t.jsxs("svg",{width:o,height:a,style:{display:"block"},children:[t.jsx("polyline",{points:s,fill:"none",stroke:e,strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",opacity:.9}),t.jsxs("text",{x:2,y:10,fontSize:9,fill:"#888",children:["E=",r.toFixed(1)]}),t.jsxs("text",{x:2,y:a-2,fontSize:9,fill:"#888",children:["E=",l.toFixed(1)]})]})}function ve({label:n,value:e,onChange:o,text:a,border:r}){return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[t.jsx("input",{type:"color",value:e,onChange:l=>o(l.target.value),style:{width:32,height:32,border:`1px solid ${r}`,borderRadius:6,padding:2,cursor:"pointer",background:"transparent"}}),t.jsx("div",{style:{width:60,height:28,borderRadius:6,background:e,border:`1px solid ${r}`}}),t.jsx("span",{style:{flex:1,fontSize:13,color:a,fontFamily:"monospace"},children:n}),t.jsx("code",{style:{fontSize:12,color:a,opacity:.7,fontFamily:"monospace"},children:e})]})}function ke({label:n,ratio:e}){const o=e>=4.5,a=e>=4.5,r=e>=7;return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[t.jsx("span",{style:{fontSize:11,opacity:.8,minWidth:140},children:n}),t.jsxs("span",{style:{fontSize:12,fontWeight:600},children:[e.toFixed(2),":1"]}),t.jsx("span",{style:{fontSize:11,color:a?"#22c55e":"#ef4444"},children:a?"✓ AA":"✗ AA"}),t.jsx("span",{style:{fontSize:11,color:r?"#22c55e":"#888"},children:r?"✓ AAA":"— AAA"}),t.jsx("span",{style:{fontSize:13},children:o?"✅":"❌"})]})}function we({onThemeChange:n,initialHue:e=210,initialMode:o="dark"}){const a=Z.useTheme(),[r,l]=x.useState(o),[i,d]=x.useState(e),[s,c]=x.useState(()=>te(o==="dark")),[g,h]=x.useState(!1),[m,b]=x.useState([]),[p,v]=x.useState(!1),S=x.useRef(null),k=r==="dark",q=x.useCallback((u,y)=>{c(C=>{const j={...C,[u]:y};return n==null||n(j),j})},[n]),E=x.useCallback(()=>{if(g)return;h(!0),b([]);let u=0;const y=600,C=60,j=[],M=()=>{u+=C,U.optimizeTheme(i,k,u);const P=u/y,_=50*(1-P)+2,Q=(Math.random()-.5)*8*(1-P*.8);if(j.push({iteration:u,energy:Math.max(0,_+Q)}),b([...j]),u<y)S.current=window.setTimeout(M,40);else{const z=U.optimizeTheme(i,k,1e3);c(z),n==null||n(z),h(!1)}};S.current=window.setTimeout(M,16)},[i,k,g,n]),w=x.useCallback(()=>{const u=r==="dark"?"light":"dark";l(u);const y=te(u==="dark");c(y),n==null||n(y)},[r,n]),A=x.useCallback(()=>{const u=`export const myTheme = {
|
|
2
|
+
${Object.entries(s).map(([y,C])=>` ${y}: '${C}',`).join(`
|
|
3
|
+
`)}
|
|
4
|
+
};`;typeof navigator<"u"&&navigator.clipboard&&navigator.clipboard.writeText(u).then(()=>{v(!0),setTimeout(()=>v(!1),2e3)})},[s]),W=[{label:"Text on Background",fg:s.text,bg:s.background},{label:"Text on Surface",fg:s.text,bg:s.surface},{label:"Primary on Background",fg:s.primary,bg:s.background},{label:"TextMuted on Background",fg:s.textMuted,bg:s.background}],$="linear-gradient(to right,"+["hsl(0,80%,55%)","hsl(30,80%,55%)","hsl(60,80%,55%)","hsl(90,80%,55%)","hsl(120,80%,55%)","hsl(150,80%,55%)","hsl(180,80%,55%)","hsl(210,80%,55%)","hsl(240,80%,55%)","hsl(270,80%,55%)","hsl(300,80%,55%)","hsl(330,80%,55%)","hsl(360,80%,55%)"].join(",")+")",N={fontFamily:"system-ui, -apple-system, sans-serif",background:s.background,color:s.text,border:`1px solid ${s.border}`,borderRadius:12,padding:20,maxWidth:900,display:"grid",gridTemplateColumns:"1fr 1fr",gap:20},B={background:s.surface,border:`1px solid ${s.border}`,borderRadius:8,padding:16},F={fontSize:13,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.08em",color:s.primary,marginBottom:12,marginTop:0},L={padding:"8px 16px",borderRadius:8,border:"none",cursor:"pointer",fontWeight:600,fontSize:13,transition:"opacity 0.15s"},f=se.tkx;return t.jsxs("div",{style:N,children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gridColumn:"1/-1"},children:[t.jsxs("div",{children:[t.jsx("h2",{style:{margin:0,fontSize:18,fontWeight:700},children:"Theme Builder"}),t.jsx("p",{style:{margin:"2px 0 0",fontSize:12,color:s.textMuted},children:"Quantum-powered color optimization"})]}),t.jsx("button",{onClick:w,style:{...L,background:s.surface,color:s.text,border:`1px solid ${s.border}`},children:k?"☀ Light":"🌙 Dark"})]}),t.jsxs("div",{style:B,children:[t.jsx("p",{style:F,children:"Base Hue"}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[t.jsx("div",{style:{width:24,height:24,borderRadius:"50%",background:`hsl(${i},70%,55%)`,border:`2px solid ${s.border}`,flexShrink:0}}),t.jsx("input",{type:"range",min:0,max:360,value:i,onChange:u=>d(Number(u.target.value)),style:{flex:1,height:16,borderRadius:8,background:$,outline:"none",border:"none",cursor:"pointer",appearance:"none",WebkitAppearance:"none"}}),t.jsxs("span",{style:{fontSize:13,fontFamily:"monospace",minWidth:32},children:[i,"°"]})]})]}),t.jsxs("div",{style:B,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:10},children:[t.jsx("button",{onClick:E,disabled:g,style:{...L,background:g?s.border:s.primary,color:k?"#000":"#fff",opacity:g?.7:1,flex:1},children:g?"⟳ Optimizing...":"⚛ Generate with Quantum Annealing"}),t.jsx("div",{style:{padding:"3px 8px",background:s.primary+"22",border:`1px solid ${s.primary}44`,borderRadius:20,fontSize:10,color:s.primary,fontWeight:700,whiteSpace:"nowrap"},children:"⚛ Quantum Annealing"})]}),(g||m.length>0)&&t.jsxs("div",{children:[t.jsx("p",{style:{fontSize:11,color:s.textMuted,margin:"0 0 4px"},children:"Energy landscape (lower = better palette)"}),t.jsx(be,{points:m,primary:s.primary})]})]}),t.jsxs("div",{style:B,children:[t.jsx("p",{style:F,children:"Color Tokens"}),Object.keys(s).map(u=>t.jsx(ve,{label:u,value:s[u],onChange:y=>q(u,y),text:s.text,border:s.border},u))]}),t.jsx("button",{onClick:A,style:{...L,background:s.accent,color:"#fff",width:"100%"},children:p?"✓ Copied to Clipboard!":"⬇ Export Theme"})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("div",{style:B,children:[t.jsx("p",{style:F,children:"Live Preview"}),t.jsxs("div",{style:{marginBottom:12},children:[t.jsx("p",{style:{fontSize:11,color:s.textMuted,margin:"0 0 6px"},children:"Buttons"}),t.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[t.jsx("button",{style:{padding:"8px 16px",borderRadius:8,border:"none",background:s.primary,color:k?"#000":"#fff",fontWeight:600,fontSize:13,cursor:"pointer"},children:"Primary"}),t.jsx("button",{style:{padding:"8px 16px",borderRadius:8,border:"none",background:s.secondary,color:"#fff",fontWeight:600,fontSize:13,cursor:"pointer"},children:"Secondary"}),t.jsx("button",{style:{padding:"8px 16px",borderRadius:8,border:`1px solid ${s.border}`,background:"transparent",color:s.text,fontWeight:600,fontSize:13,cursor:"pointer"},children:"Outline"})]})]}),t.jsxs("div",{style:{marginBottom:12},children:[t.jsx("p",{style:{fontSize:11,color:s.textMuted,margin:"0 0 6px"},children:"Card"}),t.jsxs("div",{style:{background:s.surface,border:`1px solid ${s.border}`,borderRadius:8,padding:12},children:[t.jsx("div",{style:{fontSize:14,fontWeight:700,marginBottom:4},children:"Card Title"}),t.jsx("div",{style:{fontSize:12,color:s.textMuted,lineHeight:1.4},children:"Sample card with surface background and muted text content."}),t.jsxs("div",{style:{marginTop:8,display:"flex",gap:6},children:[t.jsx("span",{style:{padding:"2px 8px",borderRadius:20,background:s.primary+"33",color:s.primary,fontSize:11,fontWeight:600},children:"Tag"}),t.jsx("span",{style:{padding:"2px 8px",borderRadius:20,background:s.accent+"33",color:s.accent,fontSize:11,fontWeight:600},children:"Accent"})]})]})]}),t.jsxs("div",{style:{marginBottom:12},children:[t.jsx("p",{style:{fontSize:11,color:s.textMuted,margin:"0 0 6px"},children:"Input"}),t.jsx("input",{type:"text",placeholder:"Type something...",readOnly:!0,style:{width:"100%",padding:"8px 12px",borderRadius:8,border:`1px solid ${s.border}`,background:s.background,color:s.text,fontSize:13,outline:"none",boxSizing:"border-box"}})]}),t.jsxs("div",{style:{marginBottom:12},children:[t.jsx("p",{style:{fontSize:11,color:s.textMuted,margin:"0 0 6px"},children:"Progress"}),t.jsx("div",{style:{height:8,borderRadius:4,background:s.border,overflow:"hidden"},children:t.jsx("div",{style:{height:"100%",width:"68%",background:`linear-gradient(to right, ${s.primary}, ${s.accent})`,borderRadius:4,transition:"width 0.4s ease"}})})]}),t.jsxs("div",{children:[t.jsx("p",{style:{fontSize:11,color:s.textMuted,margin:"0 0 6px"},children:"Status Badges"}),t.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[{label:"Error",color:s.error},{label:"Warning",color:s.warning},{label:"Success",color:s.success}].map(({label:u,color:y})=>t.jsx("span",{style:{padding:"3px 10px",borderRadius:4,background:y+"22",color:y,border:`1px solid ${y}44`,fontSize:11,fontWeight:700},children:u},u))})]})]}),t.jsxs("div",{style:B,children:[t.jsx("p",{style:F,children:"WCAG Contrast Check"}),W.map(u=>t.jsx(ke,{label:u.label,ratio:U.contrast(u.fg,u.bg)},u.label)),t.jsx("p",{style:{fontSize:10,color:s.textMuted,marginTop:8,marginBottom:0},children:"AA requires 4.5:1 (normal text). AAA requires 7:1."})]}),t.jsxs("div",{style:B,children:[t.jsx("p",{style:F,children:"Color Palette"}),t.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:Object.entries(s).map(([u,y])=>t.jsx("div",{title:`${u}: ${y}`,style:{width:36,height:36,borderRadius:6,background:y,border:`2px solid ${s.border}`,cursor:"default",flexShrink:0}},u))})]})]}),typeof f=="function"&&null,typeof a.bg=="string"&&null]})}const re=[{label:"Hello World",code:`<div style={{ padding: 24, fontFamily: 'sans-serif', color: '#e8e8f4' }}>
|
|
5
|
+
<h2 style={{ margin: 0 }}>👋 Hello, TkxPlayground!</h2>
|
|
6
|
+
<p style={{ marginTop: 8, opacity: 0.7 }}>Edit the code on the left to see live updates.</p>
|
|
7
|
+
</div>`},{label:"Button Styles",code:`<div style={{ display: 'flex', gap: 12, flexWrap: 'wrap', padding: 24 }}>
|
|
8
|
+
{['primary', 'success', 'danger', 'warning', 'info'].map(color => (
|
|
9
|
+
<button
|
|
10
|
+
key={color}
|
|
11
|
+
style={{
|
|
12
|
+
padding: '8px 18px',
|
|
13
|
+
borderRadius: 8,
|
|
14
|
+
border: 'none',
|
|
15
|
+
background: color === 'primary' ? '#00f5d4' : color === 'success' ? '#06d6a0' : color === 'danger' ? '#f72585' : color === 'warning' ? '#ffbe0b' : '#3a86ff',
|
|
16
|
+
color: '#0a0a0f',
|
|
17
|
+
fontWeight: 700,
|
|
18
|
+
cursor: 'pointer',
|
|
19
|
+
textTransform: 'capitalize',
|
|
20
|
+
}}
|
|
21
|
+
>
|
|
22
|
+
{color}
|
|
23
|
+
</button>
|
|
24
|
+
))}
|
|
25
|
+
</div>`},{label:"Card Grid",code:`<div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 16, padding: 24 }}>
|
|
26
|
+
{['Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta'].map(name => (
|
|
27
|
+
<div key={name} style={{
|
|
28
|
+
background: '#1a1a2e',
|
|
29
|
+
borderRadius: 10,
|
|
30
|
+
border: '1px solid #2a2a3e',
|
|
31
|
+
padding: '16px',
|
|
32
|
+
}}>
|
|
33
|
+
<div style={{ fontWeight: 700, color: '#00f5d4', marginBottom: 4 }}>{name}</div>
|
|
34
|
+
<div style={{ fontSize: 12, color: '#8888aa' }}>Quantum module {name.toLowerCase()}</div>
|
|
35
|
+
</div>
|
|
36
|
+
))}
|
|
37
|
+
</div>`},{label:"Animated Counter",code:`(() => {
|
|
38
|
+
const [count, setCount] = React.useState(0);
|
|
39
|
+
return (
|
|
40
|
+
<div style={{ padding: 32, textAlign: 'center', fontFamily: 'sans-serif' }}>
|
|
41
|
+
<div style={{ fontSize: 64, fontWeight: 900, color: '#00f5d4', marginBottom: 16 }}>
|
|
42
|
+
{count}
|
|
43
|
+
</div>
|
|
44
|
+
<div style={{ display: 'flex', gap: 12, justifyContent: 'center' }}>
|
|
45
|
+
<button onClick={() => setCount(c => c - 1)} style={{ padding: '8px 20px', borderRadius: 8, border: '1px solid #2a2a3e', background: '#1a1a2e', color: '#e8e8f4', fontSize: 20, cursor: 'pointer' }}>−</button>
|
|
46
|
+
<button onClick={() => setCount(0)} style={{ padding: '8px 20px', borderRadius: 8, border: '1px solid #2a2a3e', background: '#1a1a2e', color: '#8888aa', cursor: 'pointer' }}>Reset</button>
|
|
47
|
+
<button onClick={() => setCount(c => c + 1)} style={{ padding: '8px 20px', borderRadius: 8, border: '1px solid #2a2a3e', background: '#1a1a2e', color: '#e8e8f4', fontSize: 20, cursor: 'pointer' }}>+</button>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
})()`},{label:"Data Table",code:`(() => {
|
|
52
|
+
const rows = [
|
|
53
|
+
{ id: 1, name: 'Hydrogen', symbol: 'H', mass: 1.008 },
|
|
54
|
+
{ id: 2, name: 'Helium', symbol: 'He', mass: 4.003 },
|
|
55
|
+
{ id: 3, name: 'Lithium', symbol: 'Li', mass: 6.941 },
|
|
56
|
+
{ id: 4, name: 'Carbon', symbol: 'C', mass: 12.011 },
|
|
57
|
+
{ id: 5, name: 'Nitrogen', symbol: 'N', mass: 14.007 },
|
|
58
|
+
];
|
|
59
|
+
const cell = { padding: '8px 14px', borderBottom: '1px solid #2a2a3e', color: '#e8e8f4', fontSize: 13 };
|
|
60
|
+
const hcell = { ...cell, color: '#8888aa', fontWeight: 600, fontSize: 11, textTransform: 'uppercase', letterSpacing: '0.06em' };
|
|
61
|
+
return (
|
|
62
|
+
<div style={{ padding: 16 }}>
|
|
63
|
+
<table style={{ width: '100%', borderCollapse: 'collapse', fontFamily: 'sans-serif' }}>
|
|
64
|
+
<thead>
|
|
65
|
+
<tr>{['ID','Element','Symbol','Atomic Mass'].map(h => <th key={h} style={hcell}>{h}</th>)}</tr>
|
|
66
|
+
</thead>
|
|
67
|
+
<tbody>
|
|
68
|
+
{rows.map(r => (
|
|
69
|
+
<tr key={r.id} style={{ transition: 'background 0.15s' }}>
|
|
70
|
+
<td style={cell}>{r.id}</td>
|
|
71
|
+
<td style={cell}>{r.name}</td>
|
|
72
|
+
<td style={{ ...cell, color: '#00f5d4', fontWeight: 700 }}>{r.symbol}</td>
|
|
73
|
+
<td style={cell}>{r.mass}</td>
|
|
74
|
+
</tr>
|
|
75
|
+
))}
|
|
76
|
+
</tbody>
|
|
77
|
+
</table>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
})()`}];class je extends x.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){this.props.onError(e.message)}componentDidUpdate(e){e.children!==this.props.children&&this.state.hasError&&this.setState({hasError:!1})}render(){return this.state.hasError?null:this.props.children}}function Se(){return typeof window>"u"?null:window.Babel??null}function Ce(n,e){const o=performance.now();try{const a=n.trim();let i=`
|
|
81
|
+
function PlaygroundRoot() {
|
|
82
|
+
${a.startsWith("<")||a.startsWith("(")?`return (${a});`:a}
|
|
83
|
+
}
|
|
84
|
+
return PlaygroundRoot;
|
|
85
|
+
`;const d=Se();d&&(i=d.transform(i,{presets:["react"],filename:"playground.jsx"}).code??i);const c=new Function("React","imports",`
|
|
86
|
+
"use strict";
|
|
87
|
+
const { ${Object.keys(e).join(", ")} } = imports;
|
|
88
|
+
${i}
|
|
89
|
+
`)(x,e),g=x.createElement(c),h=parseFloat((performance.now()-o).toFixed(2));return{element:g,error:null,renderMs:h}}catch(a){const r=parseFloat((performance.now()-o).toFixed(2));return{element:null,error:a instanceof Error?a.message:String(a),renderMs:r}}}function Me({code:n,lineHeight:e}){const o=n.split(`
|
|
90
|
+
`);return t.jsx("div",{"aria-hidden":"true",style:{position:"absolute",top:0,left:0,width:"36px",padding:"12px 0",textAlign:"right",paddingRight:"8px",userSelect:"none",pointerEvents:"none",fontSize:"12px",lineHeight:`${e}px`,color:"#555577",fontFamily:'"Fira Code", "Cascadia Code", "Consolas", monospace',boxSizing:"border-box"},children:o.map((a,r)=>t.jsx("div",{children:r+1},r))})}const ne=["TkxButton","TkxInput","TkxCard","TkxModal","TkxTable","TkxSelect","TkxCheckbox","TkxRadio","TkxSwitch","TkxSlider","TkxBadge","TkxAlert","TkxToast","TkxTooltip","TkxPopover","TkxTabs","TkxAccordion","TkxDrawer","TkxDropdown","TkxMenu","TkxForm","TkxDataGrid","TkxChart","TkxSpinner","TkxSkeleton","TkxAvatar","TkxTag","TkxDivider","TkxProgress","TkxStatistic","TkxQuantumForm","TkxPlayground"],ze=new G;function oe(n){const e=n.match(/([A-Z][a-zA-Z0-9]*)$/);return e?e[1]:""}function Te(n,e=4){if(!n||n.length<2)return[];const o=n.toLowerCase();return ze.amplify(ne,r=>{const l=r.toLowerCase();if(l.startsWith(o))return 1;if(l.includes(o))return .7;let i=0;for(let d=0;d<o.length-1;d++)l.includes(o.slice(d,d+2))&&(i+=.15);return Math.min(i,.5)},.1).slice(0,e).map(r=>({name:ne[r.index]??"",amplitude:parseFloat(r.combined.toFixed(3))})).filter(r=>r.name!=="")}function ce({defaultCode:n,examples:e,height:o=480,imports:a={}}){const r=Z.useTheme(),l=[...re,...e??[]],i=n??re[0].code,[d,s]=x.useState(i),[c,g]=x.useState({element:null,error:null,renderMs:0}),[h,m]=x.useState(null),[b,p]=x.useState([]),[v,S]=x.useState(!1),[k,q]=x.useState(0),E=x.useRef(null),w=18,A=x.useRef(null),W=x.useCallback(z=>{m(null);const T=Ce(z,a);g(T)},[a]);x.useEffect(()=>(A.current&&clearTimeout(A.current),A.current=setTimeout(()=>W(d),300),()=>{A.current&&clearTimeout(A.current)}),[d,W]),x.useEffect(()=>{W(i)},[]);const $=x.useCallback(z=>{const T=z.target.value;s(T);const D=oe(T);D.length>=2?p(Te(D,4)):p([])},[]),N=x.useCallback(z=>{const T=l[z];T&&(q(z),s(T.code),p([]))},[l]),B=x.useCallback(async()=>{try{await navigator.clipboard.writeText(d),S(!0),setTimeout(()=>S(!1),1500)}catch{}},[d]),F=x.useCallback(()=>{s(i),q(0),p([])},[i]),L=x.useCallback(z=>{const T=oe(d);T&&s(D=>D.slice(0,D.lastIndexOf(T))+z),p([])},[d]),f=c.error!==null||h!==null,u=c.error??h??"",y=r.bg,C=r.surfaceAlt,j=r.border,M=r.surface,P={width:"50%",display:"flex",flexDirection:"column",borderRight:`1px solid ${j}`,position:"relative"},_={display:"flex",alignItems:"center",gap:"6px",padding:"6px 10px",borderBottom:`1px solid ${j}`,backgroundColor:r.surface,flexWrap:"wrap"},Q={padding:"3px 10px",borderRadius:"6px",border:`1px solid ${j}`,backgroundColor:"transparent",color:r.textMuted,fontSize:"11px",fontWeight:600,cursor:"pointer",fontFamily:"inherit",transition:"color 0.15s, border-color 0.15s"};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",border:`1px solid ${j}`,borderRadius:"12px",overflow:"hidden",backgroundColor:y,fontFamily:"inherit",boxSizing:"border-box",position:"relative"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",borderBottom:`1px solid ${j}`,backgroundColor:r.surface},children:[t.jsx("span",{style:{fontSize:"12px",fontWeight:700,color:r.primary,letterSpacing:"0.05em"},children:"⚛ TkxPlayground"}),t.jsx("span",{style:{fontSize:"10px",color:r.textMuted},children:"Live JSX Preview"})]}),t.jsx("div",{style:{display:"flex",gap:"4px",padding:"6px 10px",borderBottom:`1px solid ${j}`,backgroundColor:r.surface,overflowX:"auto"},children:l.map((z,T)=>t.jsx("button",{onClick:()=>N(T),style:{padding:"3px 10px",borderRadius:"6px",border:`1px solid ${T===k?r.primary:j}`,backgroundColor:T===k?`${r.primary}20`:"transparent",color:T===k?r.primary:r.textMuted,fontSize:"11px",fontWeight:T===k?700:400,cursor:"pointer",whiteSpace:"nowrap",fontFamily:"inherit",transition:"all 0.15s"},children:z.label},T))}),t.jsxs("div",{style:{display:"flex",height:`${o}px`},children:[t.jsxs("div",{style:P,children:[t.jsxs("div",{style:_,children:[t.jsx("span",{style:{fontSize:"11px",color:r.textMuted,marginRight:"auto"},children:"editor.tsx"}),t.jsx("button",{onClick:B,style:Q,title:"Copy code",children:v?"✓ Copied":"⎘ Copy"}),t.jsx("button",{onClick:F,style:Q,title:"Reset to default",children:"↺ Reset"})]}),t.jsxs("div",{style:{position:"relative",flex:1,overflow:"hidden"},children:[t.jsx(Me,{code:d,lineHeight:w}),t.jsx("textarea",{ref:E,value:d,onChange:$,spellCheck:!1,autoCorrect:"off",autoCapitalize:"off",style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",padding:"12px 12px 12px 44px",margin:0,border:"none",outline:"none",resize:"none",backgroundColor:y,color:r.text,fontSize:"12px",lineHeight:`${w}px`,fontFamily:'"Fira Code", "Cascadia Code", "Consolas", "Courier New", monospace',boxSizing:"border-box",overflowY:"auto",tabSize:2}})]}),b.length>0&&t.jsxs("div",{style:{position:"absolute",bottom:"40px",left:"44px",zIndex:10,backgroundColor:r.surface,border:`1px solid ${r.primary}44`,borderRadius:"8px",overflow:"hidden",boxShadow:"0 4px 16px rgba(0,0,0,0.3)",minWidth:"180px"},children:[t.jsx("div",{style:{padding:"4px 10px 4px",fontSize:"10px",color:r.primary,fontWeight:700,borderBottom:`1px solid ${j}`,letterSpacing:"0.05em"},children:"⚛ Quantum Suggestions"}),b.map(z=>t.jsxs("button",{onClick:()=>L(z.name),style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:"6px 10px",border:"none",backgroundColor:"transparent",color:r.text,fontSize:"12px",fontFamily:'"Fira Code", monospace',cursor:"pointer",textAlign:"left",gap:"12px"},children:[t.jsx("span",{children:z.name}),t.jsxs("span",{style:{fontSize:"10px",color:r.textMuted,flexShrink:0},children:[Math.round(z.amplitude*100),"%"]})]},z.name))]})]}),t.jsxs("div",{style:{width:"50%",display:"flex",flexDirection:"column"},children:[t.jsx("div",{style:{padding:"6px 10px",borderBottom:`1px solid ${j}`,backgroundColor:r.surface,fontSize:"11px",color:r.textMuted,fontWeight:600},children:"Preview"}),t.jsx("div",{style:{flex:1,overflow:"auto",backgroundColor:C,position:"relative"},children:f?t.jsxs("div",{style:{padding:"16px",color:r.danger,fontFamily:'"Fira Code", monospace',fontSize:"12px",lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:[t.jsxs("div",{style:{marginBottom:"8px",fontWeight:700,display:"flex",alignItems:"center",gap:"6px"},children:[t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:t.jsx("path",{d:"M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"})}),"Runtime Error"]}),u]}):t.jsx(je,{onError:m,children:t.jsx("div",{style:{minHeight:"100%"},children:c.element})})})]})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px",padding:"4px 12px",backgroundColor:M,borderTop:`1px solid ${j}`,fontSize:"11px",color:r.textMuted},children:[t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:"4px",color:f?r.danger:r.success,fontWeight:600},children:[t.jsx("span",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:f?r.danger:r.success,display:"inline-block"}}),f?"Error":"OK"]}),t.jsxs("span",{children:["⏱ ",c.renderMs," ms"]}),t.jsxs("span",{children:[d.split(`
|
|
91
|
+
`).length," lines"]}),t.jsxs("span",{children:[d.length," chars"]}),b.length>0&&t.jsxs("span",{style:{marginLeft:"auto",color:r.primary,fontWeight:600},children:["⚛ ",b.length," suggestion",b.length>1?"s":""]})]})]})}ce.displayName="TkxPlayground";exports.AmplitudeAmplifier=G;exports.QuantumAI=U;exports.QuantumAnnealer=V;exports.QuantumBoltzmannMachine=ie;exports.QuantumRegister=ae;exports.Qubit=I;exports.TkxPlayground=ce;exports.TkxQuantumForm=de;exports.TkxThemeBuilder=we;exports.hslToHex=O;exports.inferFieldIntelligence=X;exports.optimizeThemeColors=le;
|