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
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// ── @tekivex/ui/quantum ──────────────────────────────────────────────────────
|
|
2
|
+
// Quantum-inspired AI components: form inference (Boltzmann machines),
|
|
3
|
+
// theme optimization (quantum annealing), and live JSX playground (Grover's
|
|
4
|
+
// amplitude amplification for component suggestions).
|
|
5
|
+
//
|
|
6
|
+
// This entry point is split out so consumers who don't use quantum AI features
|
|
7
|
+
// don't pay for the ~100 KB of math + components in their bundle.
|
|
8
|
+
//
|
|
9
|
+
// Import from '@tekivex/ui/quantum'.
|
|
10
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
11
|
+
|
|
12
|
+
export { TkxQuantumForm } from '../components/TkxQuantumForm';
|
|
13
|
+
export type { TkxQuantumFormProps, QuantumFieldConfig } from '../components/TkxQuantumForm';
|
|
14
|
+
|
|
15
|
+
export { TkxThemeBuilder } from '../components/TkxThemeBuilder';
|
|
16
|
+
export type { TkxThemeBuilderProps } from '../components/TkxThemeBuilder';
|
|
17
|
+
|
|
18
|
+
export { TkxPlayground } from '../components/TkxPlayground';
|
|
19
|
+
export type { TkxPlaygroundProps, PlaygroundExample } from '../components/TkxPlayground';
|
|
20
|
+
|
|
21
|
+
export {
|
|
22
|
+
QuantumAI,
|
|
23
|
+
inferFieldIntelligence,
|
|
24
|
+
optimizeThemeColors,
|
|
25
|
+
hslToHex,
|
|
26
|
+
Qubit,
|
|
27
|
+
QuantumRegister,
|
|
28
|
+
QuantumAnnealer,
|
|
29
|
+
QuantumBoltzmannMachine,
|
|
30
|
+
AmplitudeAmplifier,
|
|
31
|
+
} from '../engine/quantum-ai';
|
|
32
|
+
export type {
|
|
33
|
+
FieldIntelligence,
|
|
34
|
+
ValidationSuggestion,
|
|
35
|
+
ThemeColorState,
|
|
36
|
+
AnnealerResult,
|
|
37
|
+
QBMInference,
|
|
38
|
+
AmplifiedResult,
|
|
39
|
+
} from '../engine/quantum-ai';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// ── @tekivex/ui/realtime ─────────────────────────────────────────────────────
|
|
2
|
+
// Real-time visualization components: live activity feeds, metrics
|
|
3
|
+
// dashboards, streaming charts, and virtualized log viewers.
|
|
4
|
+
//
|
|
5
|
+
// Split out as a separate entry point so apps that don't need real-time UI
|
|
6
|
+
// don't pay for the ~50 KB of streaming/animation code in their bundle.
|
|
7
|
+
//
|
|
8
|
+
// Import from '@tekivex/ui/realtime'.
|
|
9
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
10
|
+
|
|
11
|
+
export { TkxLiveFeed } from '../components/TkxLiveFeed';
|
|
12
|
+
export type { TkxLiveFeedProps, FeedItem } from '../components/TkxLiveFeed';
|
|
13
|
+
|
|
14
|
+
export { TkxLiveMetrics } from '../components/TkxLiveMetrics';
|
|
15
|
+
export type { TkxLiveMetricsProps, MetricItem } from '../components/TkxLiveMetrics';
|
|
16
|
+
|
|
17
|
+
export { TkxRealTimeChart } from '../components/TkxRealTimeChart';
|
|
18
|
+
export type { TkxRealTimeChartProps, ChartDataPoint } from '../components/TkxRealTimeChart';
|
|
19
|
+
|
|
20
|
+
export { TkxLiveLog } from '../components/TkxLiveLog';
|
|
21
|
+
export type { TkxLiveLogProps, LogEntry, LogLevel } from '../components/TkxLiveLog';
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";const l=require("react"),R=require("./index-BINBzXuY.cjs"),y=require("react/jsx-runtime"),we={"<":"<",">":">","&":"&","'":"'",'"':"""};function U(e){return String(e).replace(/[<>&'"]/g,i=>we[i]??i)}function Q(e){const i={};for(const o of Object.keys(e))i[o]=ae(e[o]);return i}function ae(e){return typeof e=="string"?U(e):Array.isArray(e)?e.map(ae):e!==null&&typeof e=="object"&&!ye(e)?Q(e):e}function ye(e){return typeof e=="object"&&e!==null&&"$$typeof"in e}function ce(e,i){const o=[];for(const[s,a]of Object.entries(i)){const f=e[s],b=f==null;if(a.required&&b){o.push(`prop '${s}' is required`);continue}if(!b){if(typeof f!==a.type){o.push(`prop '${s}' must be of type ${a.type}, got ${typeof f}`);continue}a.type==="number"&&typeof f=="number"&&(a.min!==void 0&&f<a.min&&o.push(`prop '${s}' must be >= ${a.min}`),a.max!==void 0&&f>a.max&&o.push(`prop '${s}' must be <= ${a.max}`)),a.type==="string"&&typeof f=="string"&&a.pattern&&!a.pattern.test(f)&&o.push(`prop '${s}' does not match pattern ${a.pattern}`),a.enum&&!a.enum.includes(f)&&o.push(`prop '${s}' must be one of: ${a.enum.join(", ")}`)}}return{valid:o.length===0,errors:o}}const le=new Map;function $e(e,i){const o={"default-src":["'self'"],"style-src":i.allowInlineStyles?["'self'","'unsafe-inline'"]:["'self'"],"img-src":i.allowDataUrls?["'self'","data:"]:i.allowExternalSrc?["'self'","*"]:["'self'"],"script-src":i.allowScripts?["'self'"]:["'none'"]},s={componentId:e,permissions:i,directives:o};return le.set(e,s),s}function ke(e,i){const o=le.get(e);return(o==null?void 0:o.permissions[i])===!0}let D=[];function fe(e,i,o){const s=R.fnv1aHash(JSON.stringify(o??{})),a=D.length>0?D[D.length-1].chainHash:"00000000",f=R.fnv1aHash(a+s+i+e),b=Object.freeze({timestamp:Date.now(),component:i,action:e,propsHash:s,chainHash:f});return D=Object.freeze([...D,b]),b}function de(e){let i=D;return e!=null&&e.component&&(i=i.filter(o=>o.component===e.component)),e!=null&&e.action&&(i=i.filter(o=>o.action===e.action)),e!=null&&e.limit&&(i=i.slice(-e.limit)),i}function ue(){let e="00000000";for(const i of D){if(R.fnv1aHash(e+i.propsHash+i.component+i.action)!==i.chainHash)return!1;e=i.chainHash}return!0}const Se={sanitize:U,sanitizeProps:Q,validateProps:ce,createCSP:$e,hasPermission:ke,audit:fe,getAuditLog:de,verifyAuditIntegrity:ue};function je(){const[e,i]=l.useState(()=>typeof window>"u"?!1:R.prefersReducedMotion());return l.useEffect(()=>{if(typeof window>"u")return;const o=window.matchMedia("(prefers-reduced-motion: reduce)"),s=a=>i(a.matches);return o.addEventListener("change",s),()=>o.removeEventListener("change",s)},[]),e}function Fe(){const[e,i]=l.useState(()=>typeof window>"u"?!1:R.prefersHighContrast());return l.useEffect(()=>{if(typeof window>"u")return;const o=window.matchMedia("(forced-colors: active)"),s=a=>i(a.matches);return o.addEventListener("change",s),()=>o.removeEventListener("change",s)},[]),e}function Me(e){const i=l.useRef(null);return l.useEffect(()=>{if(!e||!i.current)return;const o=R.createFocusTrap(i.current);return o.activate(),()=>o.deactivate()},[e]),i}function Ee(){const e=l.useRef(null);return l.useEffect(()=>{if(!(typeof document>"u"))return e.current=R.createAnnouncer(),()=>{var i;(i=e.current)==null||i.destroy()}},[]),l.useCallback((i,o="polite")=>{var s;(s=e.current)==null||s.announce(i,o)},[])}function Re(e,i=!0){const o=l.useRef(e);o.current=e,l.useEffect(()=>{if(!i||typeof document>"u")return;const s=a=>{a.key==="Escape"&&o.current()};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[i])}function Ce(e,i){const o=l.useRef(i);o.current=i,l.useEffect(()=>{const s=a=>{!e.current||e.current.contains(a.target)||o.current()};return document.addEventListener("pointerdown",s),()=>document.removeEventListener("pointerdown",s)},[e])}const u={0:"0",px:"1px","0.5":"2px",1:"4px","1.5":"6px",2:"8px","2.5":"10px",3:"12px","3.5":"14px",4:"16px",5:"20px",6:"24px",7:"28px",8:"32px",9:"36px",10:"40px",11:"44px",12:"48px",14:"56px",16:"64px",20:"80px",24:"96px",28:"112px",32:"128px",36:"144px",40:"160px",44:"176px",48:"192px",52:"208px",56:"224px",60:"240px",64:"256px",72:"288px",80:"320px",96:"384px",auto:"auto",full:"100%",screen:"100vw",svh:"100svh",dvh:"100dvh",fit:"fit-content",max:"max-content",min:"min-content"},te={...u,screen:"100vh"},A={"1/2":"50%","1/3":"33.333333%","2/3":"66.666667%","1/4":"25%","2/4":"50%","3/4":"75%","1/5":"20%","2/5":"40%","3/5":"60%","4/5":"80%","1/6":"16.666667%","5/6":"83.333333%","1/12":"8.333333%","5/12":"41.666667%","7/12":"58.333333%","11/12":"91.666667%"},G={none:"0",sm:"2px","":"4px",md:"6px",lg:"8px",xl:"12px","2xl":"16px","3xl":"24px",full:"9999px"},re={sm:"0 1px 2px 0 rgba(0,0,0,.05)","":"0 1px 3px 0 rgba(0,0,0,.1),0 1px 2px -1px rgba(0,0,0,.1)",md:"0 4px 6px -1px rgba(0,0,0,.1),0 2px 4px -2px rgba(0,0,0,.1)",lg:"0 10px 15px -3px rgba(0,0,0,.1),0 4px 6px -4px rgba(0,0,0,.1)",xl:"0 20px 25px -5px rgba(0,0,0,.1),0 8px 10px -6px rgba(0,0,0,.1)","2xl":"0 25px 50px -12px rgba(0,0,0,.25)",inner:"inset 0 2px 4px 0 rgba(0,0,0,.05)",none:"none"},ze={xs:["0.75rem","1rem"],sm:["0.875rem","1.25rem"],base:["1rem","1.5rem"],lg:["1.125rem","1.75rem"],xl:["1.25rem","1.75rem"],"2xl":["1.5rem","2rem"],"3xl":["1.875rem","2.25rem"],"4xl":["2.25rem","2.5rem"],"5xl":["3rem","1"],"6xl":["3.75rem","1"],"7xl":["4.5rem","1"],"8xl":["6rem","1"],"9xl":["8rem","1"]},Te={thin:"100",extralight:"200",light:"300",normal:"400",medium:"500",semibold:"600",bold:"700",extrabold:"800",black:"900"},Ae={none:"1",tight:"1.25",snug:"1.375",normal:"1.5",relaxed:"1.625",loose:"2",3:"0.75rem",4:"1rem",5:"1.25rem",6:"1.5rem",7:"1.75rem",8:"2rem",9:"2.25rem",10:"2.5rem"},He={tighter:"-0.05em",tight:"-0.025em",normal:"0em",wide:"0.025em",wider:"0.05em",widest:"0.1em"},X={none:"0",sm:"4px","":"8px",md:"12px",lg:"16px",xl:"24px","2xl":"40px","3xl":"64px"},Ie=Object.fromEntries([0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100].map(e=>[String(e),String(e/100)])),pe=new Set(["bg","surface","surfaceAlt","border","text","textMuted","primary","secondary","danger","warning","success","info"]),Pe={sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px"};function c(e){const i=e.match(/^\[(.+)]$/);return i?i[1]:null}function E(e){if(pe.has(e))return`var(--tkx-${e})`;if(e==="transparent")return"transparent";if(e==="current")return"currentColor";if(e==="white")return"#ffffff";if(e==="black")return"#000000";if(e==="inherit")return"inherit";const i=c(e);return i||e}function We(e){const i=e.match(/^\[([a-zA-Z-]+):(.+)]$/);if(i)return{[i[1]]:i[2]};const o={flex:"flex","inline-flex":"inline-flex",grid:"grid","inline-grid":"inline-grid",block:"block","inline-block":"inline-block",inline:"inline",hidden:"none",contents:"contents","flow-root":"flow-root",table:"table","table-row":"table-row","table-cell":"table-cell","table-caption":"table-caption","list-item":"list-item"};if(o[e])return{display:o[e]};const s={"flex-row":"row","flex-col":"column","flex-row-reverse":"row-reverse","flex-col-reverse":"column-reverse"};if(s[e])return{"flex-direction":s[e]};const a={"flex-wrap":"wrap","flex-nowrap":"nowrap","flex-wrap-reverse":"wrap-reverse"};if(a[e])return{"flex-wrap":a[e]};const f={"flex-1":"1 1 0%","flex-auto":"1 1 auto","flex-none":"none","flex-initial":"0 1 auto"};if(f[e])return{flex:f[e]};if(e==="grow"||e==="flex-grow")return{"flex-grow":"1"};if(e==="grow-0")return{"flex-grow":"0"};if(e==="shrink"||e==="flex-shrink")return{"flex-shrink":"1"};if(e==="shrink-0"||e==="flex-shrink-0")return{"flex-shrink":"0"};const b={"items-start":"flex-start","items-end":"flex-end","items-center":"center","items-stretch":"stretch","items-baseline":"baseline"};if(b[e])return{"align-items":b[e]};const x={"justify-start":"flex-start","justify-end":"flex-end","justify-center":"center","justify-between":"space-between","justify-around":"space-around","justify-evenly":"space-evenly","justify-stretch":"stretch","justify-normal":"normal"};if(x[e])return{"justify-content":x[e]};const p={"self-auto":"auto","self-start":"flex-start","self-end":"flex-end","self-center":"center","self-stretch":"stretch","self-baseline":"baseline"};if(p[e])return{"align-self":p[e]};const h={"content-start":"flex-start","content-end":"flex-end","content-center":"center","content-between":"space-between","content-around":"space-around","content-evenly":"space-evenly","content-stretch":"stretch"};if(h[e])return{"align-content":h[e]};let t;if(t=e.match(/^grid-cols-(\d+|none|subgrid)$/))return{"grid-template-columns":t[1]==="none"?"none":t[1]==="subgrid"?"subgrid":`repeat(${t[1]},minmax(0,1fr))`};if(t=e.match(/^grid-rows-(\d+|none|subgrid)$/))return{"grid-template-rows":t[1]==="none"?"none":t[1]==="subgrid"?"subgrid":`repeat(${t[1]},minmax(0,1fr))`};if(t=e.match(/^col-span-(full|\d+)$/))return{"grid-column":t[1]==="full"?"1 / -1":`span ${t[1]} / span ${t[1]}`};if(t=e.match(/^col-start-(\d+|auto)$/))return{"grid-column-start":t[1]};if(t=e.match(/^col-end-(\d+|auto)$/))return{"grid-column-end":t[1]};if(t=e.match(/^row-span-(full|\d+)$/))return{"grid-row":t[1]==="full"?"1 / -1":`span ${t[1]} / span ${t[1]}`};if(t=e.match(/^row-start-(\d+|auto)$/))return{"grid-row-start":t[1]};if(t=e.match(/^row-end-(\d+|auto)$/))return{"grid-row-end":t[1]};if(e==="grid-flow-row")return{"grid-auto-flow":"row"};if(e==="grid-flow-col")return{"grid-auto-flow":"column"};if(e==="grid-flow-dense")return{"grid-auto-flow":"dense"};if(e==="grid-flow-row-dense")return{"grid-auto-flow":"row dense"};if(e==="grid-flow-col-dense")return{"grid-auto-flow":"column dense"};if(t=e.match(/^p-(.+)$/)){const r=u[t[1]]??c(t[1]);if(r)return{padding:r}}if(t=e.match(/^px-(.+)$/)){const r=u[t[1]]??c(t[1]);if(r)return{"padding-left":r,"padding-right":r}}if(t=e.match(/^py-(.+)$/)){const r=u[t[1]]??c(t[1]);if(r)return{"padding-top":r,"padding-bottom":r}}if(t=e.match(/^pt-(.+)$/)){const r=u[t[1]]??c(t[1]);if(r)return{"padding-top":r}}if(t=e.match(/^pr-(.+)$/)){const r=u[t[1]]??c(t[1]);if(r)return{"padding-right":r}}if(t=e.match(/^pb-(.+)$/)){const r=u[t[1]]??c(t[1]);if(r)return{"padding-bottom":r}}if(t=e.match(/^pl-(.+)$/)){const r=u[t[1]]??c(t[1]);if(r)return{"padding-left":r}}if(t=e.match(/^-?m-(.+)$/)){const r=e.startsWith("-"),n=u[t[1]]??c(t[1]);if(n)return{margin:r&&n!=="0"?`-${n}`:n}}if(t=e.match(/^-?mx-(.+)$/)){const r=e.startsWith("-"),n=u[t[1]]??c(t[1]);if(n){const m=r&&n!=="0"?`-${n}`:n;return{"margin-left":m,"margin-right":m}}}if(t=e.match(/^-?my-(.+)$/)){const r=e.startsWith("-"),n=u[t[1]]??c(t[1]);if(n){const m=r&&n!=="0"?`-${n}`:n;return{"margin-top":m,"margin-bottom":m}}}if(t=e.match(/^-?mt-(.+)$/)){const r=e.startsWith("-"),n=u[t[1]]??c(t[1]);if(n)return{"margin-top":r&&n!=="0"?`-${n}`:n}}if(t=e.match(/^-?mr-(.+)$/)){const r=e.startsWith("-"),n=u[t[1]]??c(t[1]);if(n)return{"margin-right":r&&n!=="0"?`-${n}`:n}}if(t=e.match(/^-?mb-(.+)$/)){const r=e.startsWith("-"),n=u[t[1]]??c(t[1]);if(n)return{"margin-bottom":r&&n!=="0"?`-${n}`:n}}if(t=e.match(/^-?ml-(.+)$/)){const r=e.startsWith("-"),n=u[t[1]]??c(t[1]);if(n)return{"margin-left":r&&n!=="0"?`-${n}`:n}}if(e==="mx-auto")return{"margin-left":"auto","margin-right":"auto"};if(e==="my-auto")return{"margin-top":"auto","margin-bottom":"auto"};if(t=e.match(/^gap-(.+)$/)){const r=u[t[1]]??c(t[1]);if(r)return{gap:r}}if(t=e.match(/^gap-x-(.+)$/)){const r=u[t[1]]??c(t[1]);if(r)return{"column-gap":r}}if(t=e.match(/^gap-y-(.+)$/)){const r=u[t[1]]??c(t[1]);if(r)return{"row-gap":r}}if(t=e.match(/^w-(.+)$/)){const r=t[1],n=u[r]??A[r]??c(r);if(n)return{width:n}}if(t=e.match(/^min-w-(.+)$/)){const r=u[t[1]]??c(t[1]);if(r)return{"min-width":r}}if(t=e.match(/^max-w-(.+)$/)){const n={none:"none",xs:"20rem",sm:"24rem",md:"28rem",lg:"32rem",xl:"36rem","2xl":"42rem","3xl":"48rem","4xl":"56rem","5xl":"64rem","6xl":"72rem","7xl":"80rem",full:"100%",screen:"100vw",min:"min-content",max:"max-content",fit:"fit-content"}[t[1]]??u[t[1]]??c(t[1]);if(n)return{"max-width":n}}if(t=e.match(/^h-(.+)$/)){const r=t[1],n=te[r]??A[r]??c(r);if(n)return{height:n}}if(t=e.match(/^min-h-(.+)$/)){const n={0:"0",full:"100%",screen:"100vh",svh:"100svh",dvh:"100dvh"}[t[1]]??u[t[1]]??c(t[1]);if(n)return{"min-height":n}}if(t=e.match(/^max-h-(.+)$/)){const r=te[t[1]]??c(t[1]);if(r)return{"max-height":r}}if(t=e.match(/^size-(.+)$/)){const r=u[t[1]]??A[t[1]]??c(t[1]);if(r)return{width:r,height:r}}if(t=e.match(/^text-(xs|sm|base|lg|[2-9]xl|\d+xl)$/)){const[r,n]=ze[t[1]]??["1rem","1.5rem"];return{"font-size":r,"line-height":n}}if(t=e.match(/^font-(thin|extralight|light|normal|medium|semibold|bold|extrabold|black|\d+)$/))return{"font-weight":Te[t[1]]??t[1]};if(t=e.match(/^leading-(.+)$/)){const r=Ae[t[1]]??c(t[1]);if(r)return{"line-height":r}}if(t=e.match(/^tracking-(.+)$/)){const r=He[t[1]]??c(t[1]);if(r)return{"letter-spacing":r}}const g={"text-left":"left","text-center":"center","text-right":"right","text-justify":"justify","text-start":"start","text-end":"end"};if(g[e])return{"text-align":g[e]};if(e==="italic")return{"font-style":"italic"};if(e==="not-italic")return{"font-style":"normal"};if(e==="uppercase")return{"text-transform":"uppercase"};if(e==="lowercase")return{"text-transform":"lowercase"};if(e==="capitalize")return{"text-transform":"capitalize"};if(e==="normal-case")return{"text-transform":"none"};if(e==="underline")return{"text-decoration-line":"underline"};if(e==="overline")return{"text-decoration-line":"overline"};if(e==="line-through")return{"text-decoration-line":"line-through"};if(e==="no-underline")return{"text-decoration-line":"none"};if(e==="truncate")return{overflow:"hidden","text-overflow":"ellipsis","white-space":"nowrap"};if(e==="text-ellipsis")return{"text-overflow":"ellipsis"};if(e==="text-clip")return{"text-overflow":"clip"};if(e==="whitespace-normal")return{"white-space":"normal"};if(e==="whitespace-nowrap")return{"white-space":"nowrap"};if(e==="whitespace-pre")return{"white-space":"pre"};if(e==="whitespace-pre-wrap")return{"white-space":"pre-wrap"};if(e==="whitespace-pre-line")return{"white-space":"pre-line"};if(e==="break-words")return{"overflow-wrap":"break-word"};if(e==="break-all")return{"word-break":"break-all"};if(e==="break-keep")return{"word-break":"keep-all"};if(e==="font-mono")return{"font-family":"var(--tkx-font-mono,monospace)"};if(e==="font-sans")return{"font-family":"var(--tkx-font-family,system-ui,sans-serif)"};if(e==="font-serif")return{"font-family":"ui-serif,Georgia,serif"};if(e==="antialiased")return{"-webkit-font-smoothing":"antialiased","-moz-osx-font-smoothing":"grayscale"};if(t=e.match(/^indent-(.+)$/)){const r=u[t[1]]??c(t[1]);if(r)return{"text-indent":r}}if(t=e.match(/^line-clamp-(\d+)$/))return{overflow:"hidden",display:"-webkit-box","-webkit-line-clamp":t[1],"-webkit-box-orient":"vertical"};if(t=e.match(/^text-(.+)$/)){const[r,n]=t[1].split("/"),m=E(r);if(!["left","center","right","justify","start","end","xs","sm","base","lg","xl","2xl","3xl","4xl","5xl","6xl","7xl","8xl","9xl"].includes(r)){if(n){const k=parseInt(n)/100;return{color:m,opacity:String(k)}}return{color:m}}}if(t=e.match(/^bg-(.+)$/)){const[r,n]=t[1].split("/"),m=E(r);return n?{"background-color":m,opacity:String(parseInt(n)/100)}:r==="none"?{background:"none"}:{"background-color":m}}if(t=e.match(/^border-color-(.+)$/))return{"border-color":E(t[1])};if(t=e.match(/^fill-(.+)$/))return{fill:E(t[1])};if(t=e.match(/^stroke-(.+)$/))return{stroke:E(t[1])};if(t=e.match(/^shadow-color-(.+)$/))return{"--tkx-shadow-color":E(t[1])};if(t=e.match(/^ring-color-(.+)$/))return{"--tkx-ring-color":E(t[1])};if(t=e.match(/^accent-(.+)$/))return{"accent-color":E(t[1])};if(t=e.match(/^caret-(.+)$/))return{"caret-color":E(t[1])};if(t=e.match(/^outline-color-(.+)$/))return{"outline-color":E(t[1])};if(e==="border")return{"border-width":"1px"};if(t=e.match(/^border-(\d+)$/))return{"border-width":`${t[1]}px`};if(e==="border-t")return{"border-top-width":"1px"};if(t=e.match(/^border-t-(\d+)$/))return{"border-top-width":`${t[1]}px`};if(e==="border-r")return{"border-right-width":"1px"};if(t=e.match(/^border-r-(\d+)$/))return{"border-right-width":`${t[1]}px`};if(e==="border-b")return{"border-bottom-width":"1px"};if(t=e.match(/^border-b-(\d+)$/))return{"border-bottom-width":`${t[1]}px`};if(e==="border-l")return{"border-left-width":"1px"};if(t=e.match(/^border-l-(\d+)$/))return{"border-left-width":`${t[1]}px`};if(e==="border-x")return{"border-left-width":"1px","border-right-width":"1px"};if(e==="border-y")return{"border-top-width":"1px","border-bottom-width":"1px"};if(e==="border-none")return{"border-style":"none"};if(e==="border-solid")return{"border-style":"solid"};if(e==="border-dashed")return{"border-style":"dashed"};if(e==="border-dotted")return{"border-style":"dotted"};if(e==="border-double")return{"border-style":"double"};if((t=e.match(/^border-([a-zA-Z].*)$/))&&pe.has(t[1]))return{"border-color":`var(--tkx-${t[1]})`};if(t=e.match(/^border-\[(.+)]$/))return{"border-color":t[1]};if(e==="border-0")return{"border-width":"0"};if(e==="rounded")return{"border-radius":G[""]};if(t=e.match(/^rounded-(none|sm|md|lg|xl|2xl|3xl|full|\[.+])$/))return{"border-radius":G[t[1]]??c(t[1])??t[1]};if(t=e.match(/^rounded-(t|r|b|l|tl|tr|br|bl)(?:-(none|sm|md|lg|xl|2xl|3xl|full))?$/)){const r=t[1],n=G[t[2]??""]??G[""];return{t:{"border-top-left-radius":n,"border-top-right-radius":n},r:{"border-top-right-radius":n,"border-bottom-right-radius":n},b:{"border-bottom-left-radius":n,"border-bottom-right-radius":n},l:{"border-top-left-radius":n,"border-bottom-left-radius":n},tl:{"border-top-left-radius":n},tr:{"border-top-right-radius":n},br:{"border-bottom-right-radius":n},bl:{"border-bottom-left-radius":n}}[r]??{}}const $={0:"0",1:"1px",2:"2px",ring:"3px",4:"4px",8:"8px"};if(e==="ring")return{"box-shadow":"0 0 0 3px var(--tkx-ring-color,var(--tkx-primary))"};if((t=e.match(/^ring-(\d+)$/))&&$[t[1]])return{"box-shadow":`0 0 0 ${$[t[1]]} var(--tkx-ring-color,var(--tkx-primary))`};if(e==="ring-inset")return{"--tkx-ring-offset":"inset"};if(t=e.match(/^ring-offset-(\d+)$/))return{"--tkx-ring-offset-width":`${t[1]}px`,"box-shadow":`0 0 0 ${t[1]}px var(--tkx-bg)`};if(e==="shadow")return{"box-shadow":re[""]};if(t=e.match(/^shadow-(sm|md|lg|xl|2xl|inner|none)$/))return{"box-shadow":re[t[1]]};if(t=e.match(/^opacity-(\d+)$/)){const r=Ie[t[1]];if(r!==void 0)return{opacity:r}}if(e==="bg-none")return{background:"none"};const v={"bg-auto":"auto","bg-cover":"cover","bg-contain":"contain"};if(v[e])return{"background-size":v[e]};const w={"bg-center":"center","bg-top":"top","bg-bottom":"bottom","bg-left":"left","bg-right":"right"};if(w[e])return{"background-position":w[e]};const C={"bg-repeat":"repeat","bg-no-repeat":"no-repeat","bg-repeat-x":"repeat-x","bg-repeat-y":"repeat-y"};if(C[e])return{"background-repeat":C[e]};if(e==="backdrop-blur")return{"backdrop-filter":`blur(${X[""]})`};if(t=e.match(/^backdrop-blur-(none|sm|md|lg|xl|2xl|3xl)$/))return{"backdrop-filter":`blur(${X[t[1]]})`};if(e==="blur")return{filter:`blur(${X[""]})`};if(t=e.match(/^blur-(none|sm|md|lg|xl|2xl|3xl)$/))return{filter:`blur(${X[t[1]]})`};if(e==="grayscale")return{filter:"grayscale(100%)"};if(e==="grayscale-0")return{filter:"grayscale(0)"};if(e==="invert")return{filter:"invert(100%)"};if(e==="invert-0")return{filter:"invert(0)"};const I={static:"static",relative:"relative",absolute:"absolute",fixed:"fixed",sticky:"sticky"};if(I[e])return{position:I[e]};if(e==="inset-0")return{top:"0",right:"0",bottom:"0",left:"0"};if(e==="inset-auto")return{top:"auto",right:"auto",bottom:"auto",left:"auto"};if(e==="inset-full")return{top:"100%",right:"100%",bottom:"100%",left:"100%"};if(e==="inset-x-0")return{left:"0",right:"0"};if(e==="inset-y-0")return{top:"0",bottom:"0"};if(t=e.match(/^-?top-(.+)$/)){const r=e.startsWith("-"),n=u[t[1]]??A[t[1]]??c(t[1]);if(n)return{top:r&&n!=="0"?`-${n}`:n}}if(t=e.match(/^-?right-(.+)$/)){const r=e.startsWith("-"),n=u[t[1]]??A[t[1]]??c(t[1]);if(n)return{right:r&&n!=="0"?`-${n}`:n}}if(t=e.match(/^-?bottom-(.+)$/)){const r=e.startsWith("-"),n=u[t[1]]??A[t[1]]??c(t[1]);if(n)return{bottom:r&&n!=="0"?`-${n}`:n}}if(t=e.match(/^-?left-(.+)$/)){const r=e.startsWith("-"),n=u[t[1]]??A[t[1]]??c(t[1]);if(n)return{left:r&&n!=="0"?`-${n}`:n}}const P={0:"0",10:"10",20:"20",30:"30",40:"40",50:"50",100:"100",1e3:"1000",9e3:"9000",auto:"auto"};if(t=e.match(/^z-(.+)$/)){const r=P[t[1]]??c(t[1]);if(r)return{"z-index":r}}const W={"overflow-auto":"auto","overflow-hidden":"hidden","overflow-visible":"visible","overflow-scroll":"scroll","overflow-clip":"clip"};if(W[e])return{overflow:W[e]};if(t=e.match(/^overflow-(x|y)-(auto|hidden|visible|scroll|clip)$/))return{[`overflow-${t[1]}`]:t[2]};if(e==="scrollbar-hide")return{"-ms-overflow-style":"none","scrollbar-width":"none"};if(e==="visible")return{visibility:"visible"};if(e==="invisible")return{visibility:"hidden"};if(e==="collapse")return{visibility:"collapse"};const F={"cursor-auto":"auto","cursor-default":"default","cursor-pointer":"pointer","cursor-wait":"wait","cursor-text":"text","cursor-move":"move","cursor-help":"help","cursor-not-allowed":"not-allowed","cursor-none":"none","cursor-grab":"grab","cursor-grabbing":"grabbing","cursor-zoom-in":"zoom-in","cursor-zoom-out":"zoom-out","cursor-crosshair":"crosshair"};if(F[e])return{cursor:F[e]};if(e==="select-none")return{"user-select":"none"};if(e==="select-text")return{"user-select":"text"};if(e==="select-all")return{"user-select":"all"};if(e==="select-auto")return{"user-select":"auto"};if(e==="pointer-events-none")return{"pointer-events":"none"};if(e==="pointer-events-auto")return{"pointer-events":"auto"};const M={0:"0",50:".5",75:".75",90:".9",95:".95",100:"1",105:"1.05",110:"1.1",125:"1.25",150:"1.5"};if(t=e.match(/^scale-(.+)$/)){const r=M[t[1]]??c(t[1]);if(r)return{transform:`scale(${r})`}}if(t=e.match(/^scale-x-(.+)$/)){const r=M[t[1]]??c(t[1]);if(r)return{transform:`scaleX(${r})`}}if(t=e.match(/^scale-y-(.+)$/)){const r=M[t[1]]??c(t[1]);if(r)return{transform:`scaleY(${r})`}}const z={0:"0deg",1:"1deg",2:"2deg",3:"3deg",6:"6deg",12:"12deg",45:"45deg",90:"90deg",180:"180deg"};if(t=e.match(/^-?rotate-(.+)$/)){const r=e.startsWith("-"),n=z[t[1]]??c(t[1]);if(n)return{transform:r?`rotate(-${n})`:`rotate(${n})`}}if(t=e.match(/^-?translate-x-(.+)$/)){const r=e.startsWith("-"),n=u[t[1]]??A[t[1]]??c(t[1]);if(n)return{transform:`translateX(${r&&n!=="0"?`-${n}`:n})`}}if(t=e.match(/^-?translate-y-(.+)$/)){const r=e.startsWith("-"),n=u[t[1]]??A[t[1]]??c(t[1]);if(n)return{transform:`translateY(${r&&n!=="0"?`-${n}`:n})`}}if(t=e.match(/^-?skew-x-(.+)$/)){const r=e.startsWith("-"),n=c(t[1])??`${t[1]}deg`;return{transform:r?`skewX(-${n})`:`skewX(${n})`}}if(t=e.match(/^-?skew-y-(.+)$/)){const r=e.startsWith("-"),n=c(t[1])??`${t[1]}deg`;return{transform:r?`skewY(-${n})`:`skewY(${n})`}}const q={"origin-center":"center","origin-top":"top","origin-top-right":"top right","origin-right":"right","origin-bottom-right":"bottom right","origin-bottom":"bottom","origin-bottom-left":"bottom left","origin-left":"left","origin-top-left":"top left"};if(q[e])return{"transform-origin":q[e]};const B={transition:"color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter","transition-all":"all","transition-colors":"color,background-color,border-color,text-decoration-color,fill,stroke","transition-opacity":"opacity","transition-shadow":"box-shadow","transition-transform":"transform","transition-none":"none"};if(B[e])return{"transition-property":B[e],"transition-timing-function":"cubic-bezier(0.4,0,0.2,1)","transition-duration":"150ms"};const O={75:"75ms",100:"100ms",150:"150ms",200:"200ms",300:"300ms",500:"500ms",700:"700ms",1e3:"1000ms"};if(t=e.match(/^duration-(.+)$/)){const r=O[t[1]]??c(t[1]);if(r)return{"transition-duration":r}}if(t=e.match(/^delay-(.+)$/)){const r=O[t[1]]??c(t[1]);if(r)return{"transition-delay":r}}const N={"ease-linear":"linear","ease-in":"cubic-bezier(0.4,0,1,1)","ease-out":"cubic-bezier(0,0,0.2,1)","ease-in-out":"cubic-bezier(0.4,0,0.2,1)"};if(N[e])return{"transition-timing-function":N[e]};const L={"animate-none":"none","animate-spin":"tkx-spin 1s linear infinite","animate-ping":"tkx-ping 1s cubic-bezier(0,0,0.2,1) infinite","animate-pulse":"tkx-pulse 2s cubic-bezier(0.4,0,0.6,1) infinite","animate-bounce":"tkx-bounce 1s infinite","animate-fade-in":"tkx-fade-in 200ms ease both","animate-slide-up":"tkx-slide-up 200ms ease both","animate-shimmer":"tkx-shimmer 1.5s infinite"};if(L[e])return{animation:L[e]};const Y={"object-contain":"contain","object-cover":"cover","object-fill":"fill","object-none":"none","object-scale-down":"scale-down"};if(Y[e])return{"object-fit":Y[e]};if(e==="aspect-square")return{"aspect-ratio":"1 / 1"};if(e==="aspect-video")return{"aspect-ratio":"16 / 9"};if(e==="aspect-auto")return{"aspect-ratio":"auto"};if(t=e.match(/^aspect-\[(.+)]$/))return{"aspect-ratio":t[1]};if(e==="list-none")return{"list-style-type":"none"};if(e==="list-disc")return{"list-style-type":"disc"};if(e==="list-decimal")return{"list-style-type":"decimal"};if(e==="list-inside")return{"list-style-position":"inside"};if(e==="list-outside")return{"list-style-position":"outside"};if(t=e.match(/^columns-(\d+)$/))return{columns:t[1]};if(e==="resize")return{resize:"both"};if(e==="resize-none")return{resize:"none"};if(e==="resize-x")return{resize:"horizontal"};if(e==="resize-y")return{resize:"vertical"};if(e==="sr-only")return{position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0,0,0,0)","white-space":"nowrap",border:"0"};if(e==="not-sr-only")return{position:"static",width:"auto",height:"auto",padding:"0",margin:"0",overflow:"visible",clip:"auto","white-space":"normal"};if(e==="focus-ring")return{outline:"2px solid var(--tkx-primary)","outline-offset":"2px","border-radius":"2px"};if(e==="appearance-none")return{appearance:"none"};if(e==="outline-none")return{outline:"none"};if(e==="outline")return{outline:"2px solid currentColor","outline-offset":"2px"};if(e==="float-left")return{float:"left"};if(e==="float-right")return{float:"right"};if(e==="float-none")return{float:"none"};if(e==="clear-both")return{clear:"both"};if(e==="isolate")return{isolation:"isolate"};if(e==="isolation-auto")return{isolation:"auto"};if(t=e.match(/^will-change-(.+)$/))return{"will-change":t[1]};if(e==="touch-manipulation")return{"touch-action":"manipulation"};if(e==="touch-none")return{"touch-action":"none"};if(e==="touch-pan-x")return{"touch-action":"pan-x"};if(e==="touch-pan-y")return{"touch-action":"pan-y"};if(e==="scroll-smooth")return{"scroll-behavior":"smooth"};if(e==="scroll-auto")return{"scroll-behavior":"auto"};if(t=e.match(/^\[(--[a-zA-Z0-9-]+):(.+)]$/))return{[t[1]]:t[2]};const d=he(e);return d||null}function Oe(e){let i=0,o=-1;for(let s=0;s<e.length;s++)if(e[s]==="[")i++;else if(e[s]==="]")i--;else if(e[s]===":"&&i===0){o=s;break}return o===-1?{variant:null,utility:e}:{variant:e.slice(0,o),utility:e.slice(o+1)}}function ne(e,i){for(const[o,s]of Object.entries(i))e[o]=s}function V(e){return Object.entries(e).map(([i,o])=>`${i}:${o}`).join(";")}const Z=new Map;let H=null,_=null;function ie(){return(!H||!H.isConnected)&&(H=document.getElementById("tkx-atomic"),H||(H=document.createElement("style"),H.id="tkx-atomic",document.head.appendChild(H))),H}function qe(){if(_)return _;try{const e=new CSSStyleSheet;return document.adoptedStyleSheets=[...document.adoptedStyleSheets,e],_=e,e}catch{return null}}function Ne(e,i){if(Z.has(e)||(Z.set(e,i),typeof document>"u"))return;const o=qe();if(o){const s=Le(i);for(const a of s)try{o.insertRule(a,o.cssRules.length)}catch{ie().textContent+=a+`
|
|
2
|
-
`}}else ie().textContent+=i+`
|
|
3
|
-
`}function Le(e){const i=[];let o=0,s=0;for(let a=0;a<e.length;a++)if(e[a]==="{")o++;else if(e[a]==="}"&&(o--,o===0)){const f=e.slice(s,a+1).trim();f&&i.push(f),s=a+1}return i}function me(e){const i=[];for(const o of e)if(o){if(typeof o=="string")i.push(...o.split(/\s+/).filter(Boolean));else if(Array.isArray(o))i.push(...me(o));else if(typeof o=="object")for(const[s,a]of Object.entries(o))a&&i.push(s)}return i}function j(...e){const i=me(e);if(i.length===0)return"";const o={base:{},variants:{}};for(const p of i){const{variant:h,utility:t}=Oe(p),g=We(t);g&&(h?(o.variants[h]||(o.variants[h]={}),ne(o.variants[h],g)):ne(o.base,g))}const s=[],a=V(o.base),f=[a,...Object.entries(o.variants).map(([p,h])=>`${p}{${V(h)}}`)].join("|"),b=R.fnv1aHash(f),x=`tkx-${b}`;a&&s.push(`.${x}{${a}}`);for(const[p,h]of Object.entries(o.variants)){const t=V(h);if(t)if(p.startsWith("@")){const g=p.slice(1),$=Pe[g];$&&s.push(`@media(min-width:${$}){.${x}{${t}}}`)}else if(p==="motion-safe")s.push(`@media(prefers-reduced-motion:no-preference){.${x}{${t}}}`);else if(p==="motion-reduce")s.push(`@media(prefers-reduced-motion:reduce){.${x}{${t}}}`);else if(p==="contrast-more")s.push(`@media(prefers-contrast:more){.${x}{${t}}}`);else if(p==="forced-colors")s.push(`@media(forced-colors:active){.${x}{${t}}}`);else if(p==="dark")s.push(`@media(prefers-color-scheme:dark){.${x}{${t}}}`);else if(p==="print")s.push(`@media print{.${x}{${t}}}`);else if(p==="group-hover")s.push(`.group:hover .${x}{${t}}`);else if(p==="group-focus")s.push(`.group:focus-within .${x}{${t}}`);else if(p==="peer-hover")s.push(`.peer:hover~.${x}{${t}}`);else{const $={hover:":hover",focus:":focus","focus-visible":":focus-visible","focus-within":":focus-within",active:":active",disabled:":disabled",checked:":checked",required:":required",valid:":valid",invalid:":invalid",first:":first-child",last:":last-child",odd:":nth-child(odd)",even:":nth-child(even)","first-of-type":":first-of-type","last-of-type":":last-of-type","only-child":":only-child","only-of-type":":only-of-type",empty:":empty",visited:":visited",target:":target","placeholder-shown":":placeholder-shown","read-only":":read-only",before:"::before",after:"::after",placeholder:"::placeholder",selection:"::selection","file-selector":"::file-selector-button",marker:"::marker"}[p]??`:${p}`;s.push(`.${x}${$}{${t}}`)}}return s.length>0&&Ne(b,s.join("")),x}const De=j;function Be(){return Array.from(Z.values()).join(`
|
|
4
|
-
`)}function Ye(){Z.clear(),H=null,_&&typeof document<"u"&&(document.adoptedStyleSheets=document.adoptedStyleSheets.filter(e=>e!==_),_=null)}function K(...e){return e.filter(Boolean).join(" ")}const J=new Map;function Ue(e){J.set(e.name,e.utilities)}function _e(e){J.delete(e)}function Ke(){return Array.from(J.keys())}function he(e){for(const i of J.values())if(i[e])return i[e];return null}const ee=l.createContext(null);function Ge(){const e=l.useContext(ee);if(!e)throw new Error("TkxFormField must be used inside a <TkxForm>. Wrap your fields in a TkxForm component.");return e}async function oe(e,i){for(const o of i){if(o.required&&(e==null||e===""||Array.isArray(e)&&e.length===0))return o.message??"This field is required";if(!(e==null||e==="")){if(o.min!==void 0){if(typeof e=="string"&&e.length<o.min)return o.message??`Must be at least ${o.min} characters`;if(typeof e=="number"&&e<o.min)return o.message??`Must be at least ${o.min}`}if(o.max!==void 0){if(typeof e=="string"&&e.length>o.max)return o.message??`Must be no more than ${o.max} characters`;if(typeof e=="number"&&e>o.max)return o.message??`Must be no more than ${o.max}`}if(o.pattern&&typeof e=="string"&&!o.pattern.test(e))return o.message??"Invalid format";if(o.validator){const s=await o.validator(e);if(s)return s}}}return null}function Xe(e,i){const o=e?[...e]:[];return i&&!o.some(s=>s.required)&&o.unshift({required:!0,message:"This field is required"}),o}function Ze(e){return e.some(i=>i.required)}function Je(){const e=l.useContext(ee),i=l.useRef({}),o=l.useRef({}),s=l.useRef({}),a=l.useMemo(()=>({getFieldValue:f=>i.current[f],setFieldValue:(f,b)=>{i.current[f]=b},getFieldsValue:()=>({...i.current}),setFieldsValue:f=>{Object.assign(i.current,f)},validateFields:()=>Promise.resolve({...i.current}),validateField:f=>Promise.resolve(!0),resetFields:()=>{i.current={},o.current={},s.current={}},getFieldError:f=>o.current[f]??null,isFieldTouched:f=>s.current[f]??!1}),[]);return e?e.instance:a}function xe({onSubmit:e,onValuesChange:i,initialValues:o={},layout:s="vertical",disabled:a=!1,children:f,className:b,style:x,form:p}){const h=R.useTheme(),[t,g]=l.useState({values:{...o},errors:{},touched:{}}),$=l.useRef(o),v=l.useRef({}),w=l.useRef(t);w.current=t;const C=l.useCallback((d,r)=>{v.current[d]=r},[]),I=l.useCallback(d=>{delete v.current[d]},[]),P=l.useCallback((d,r)=>{g(n=>{const m={...n,values:{...n.values,[d]:r}};return i==null||i({[d]:r},m.values),m})},[i]),W=l.useCallback((d,r)=>{g(n=>({...n,errors:{...n.errors,[d]:r}}))},[]),F=l.useCallback(d=>{g(r=>({...r,touched:{...r.touched,[d]:!0}}))},[]),M=l.useCallback(async d=>{const r=v.current[d];if(!r)return!0;const n=w.current.values[d],m=await oe(n,r.rules);return g(k=>({...k,errors:{...k.errors,[d]:m},touched:{...k.touched,[d]:!0}})),m===null},[]),z=l.useCallback(async()=>{const d=Object.keys(v.current),r=await Promise.all(d.map(async S=>{const T=v.current[S],be=w.current.values[S],ve=await oe(be,T.rules);return{name:S,error:ve}})),n={},m={};let k=!1;for(const{name:S,error:T}of r)n[S]=T,m[S]=!0,T&&(k=!0);if(g(S=>({...S,errors:{...S.errors,...n},touched:{...S.touched,...m}})),k){const S=Object.fromEntries(r.filter(T=>T.error).map(T=>[T.name,T.error]));return Promise.reject(S)}return{...w.current.values}},[]),q=l.useCallback(()=>{g({values:{...$.current},errors:{},touched:{}})},[]),B=l.useMemo(()=>({getFieldValue:d=>w.current.values[d],setFieldValue:P,getFieldsValue:()=>({...w.current.values}),setFieldsValue:d=>{g(r=>{const n={...r.values,...d};return i==null||i(d,n),{...r,values:n}})},validateFields:z,validateField:M,resetFields:q,getFieldError:d=>w.current.errors[d]??null,isFieldTouched:d=>!!w.current.touched[d]}),[P,z,M,q,i]),O=l.useCallback(async d=>{d.preventDefault();try{const r=await z();await(e==null?void 0:e(r))}catch{}},[z,e]),N=j(s==="inline"?"flex flex-row flex-wrap items-end gap-4":"flex flex-col gap-5"),L=p??B,Y=l.useMemo(()=>({state:t,initialValues:$.current,layout:s,disabled:a,fieldMeta:v,setFieldValue:P,setFieldError:W,setFieldTouched:F,registerField:C,unregisterField:I,validateField:M,instance:L}),[t,s,a,P,W,F,C,I,M,L]);return y.jsx(ee.Provider,{value:Y,children:y.jsx("form",{noValidate:!0,role:"form","aria-label":"Form",onSubmit:O,className:K(N,b),style:{color:h.text,...x},children:f})})}xe.displayName="TkxForm";function ge({name:e,label:i,rules:o,help:s,required:a,children:f,className:b,style:x}){const p=R.useTheme(),h=Ge(),{state:t,layout:g,disabled:$}=h,v=l.useMemo(()=>Xe(o,a),[o,a]),w=Ze(v),C=l.useRef({rules:v});C.current.rules=v;const I=l.useRef(!1);I.current||(h.registerField(e,C.current),I.current=!0),l.useMemo(()=>{h.registerField(e,C.current)},[v,e,h]);const P=t.values[e],W=t.touched[e]?t.errors[e]??null:null,F=W?U(W):null,M=i?U(i):void 0,z=s?U(s):void 0,q=l.useCallback(n=>{let m;if(n!==null&&typeof n=="object"&&"target"in n){const k=n.target;m=k.type==="checkbox"?k.checked:k.value}else m=n;h.setFieldValue(e,m)},[h,e]),B=l.useCallback(()=>{h.setFieldTouched(e),h.validateField(e)},[h,e]),O=l.cloneElement(f,{value:P??"",onChange:q,onBlur:B,error:F??void 0,isInvalid:!!F,isRequired:w,disabled:$||f.props.disabled,name:e}),N=g==="horizontal",L=g==="inline",Y=y.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:y.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"})}),d=M?y.jsxs("label",{className:j("text-sm font-medium font-sans",N?"min-w-[140px] pt-2.5":""),style:{color:p.text},children:[M,w&&y.jsx("span",{"aria-hidden":"true",className:j("ml-1"),style:{color:p.danger},children:"*"})]}):null,r=y.jsxs(y.Fragment,{children:[z&&!F&&y.jsx("span",{className:j("text-xs mt-0.5"),style:{color:p.textMuted},children:z}),F&&y.jsxs("span",{role:"alert",className:j("text-xs flex items-center gap-1 mt-0.5"),style:{color:p.danger,animation:"tkxFormErrorReveal 200ms ease-out"},children:[Y,F]})]});return L?y.jsxs("div",{className:K(j("flex flex-col gap-1"),b),style:x,children:[d,O,r]}):N?y.jsxs("div",{className:K(j("flex flex-row gap-4 items-start"),b),style:x,children:[d,y.jsxs("div",{className:j("flex flex-col gap-1 flex-1 min-w-0"),children:[O,r]})]}):y.jsxs("div",{className:K(j("flex flex-col gap-1"),b),style:x,children:[d,O,r]})}ge.displayName="TkxFormField";let se=!1;function Ve(){if(se||typeof document>"u")return;se=!0;const e=document.createElement("style");e.setAttribute("data-tkx-form",""),e.textContent=`
|
|
5
|
-
@keyframes tkxFormErrorReveal {
|
|
6
|
-
from {
|
|
7
|
-
opacity: 0;
|
|
8
|
-
transform: translateY(-4px);
|
|
9
|
-
}
|
|
10
|
-
to {
|
|
11
|
-
opacity: 1;
|
|
12
|
-
transform: translateY(0);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
`,document.head.appendChild(e)}Ve();exports.Shield=Se;exports.TkxForm=xe;exports.TkxFormField=ge;exports.audit=fe;exports.cx=K;exports.extractAtomicCSS=Be;exports.getAuditLog=de;exports.resetAtomicCSS=Ye;exports.resolvePluginUtility=he;exports.sanitizeProps=Q;exports.sanitizeString=U;exports.tkx=j;exports.tkxListPlugins=Ke;exports.tkxPlugin=Ue;exports.tkxRemovePlugin=_e;exports.tx=De;exports.useAnnounce=Ee;exports.useClickOutside=Ce;exports.useEscapeKey=Re;exports.useFocusTrap=Me;exports.useHighContrast=Fe;exports.useReducedMotion=je;exports.useTkxForm=Je;exports.validateProps=ce;exports.verifyAuditIntegrity=ue;
|