tekivex-ui 2.5.11 → 2.5.12
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-1KDzoniV.cjs +12 -0
- package/dist/TkxForm-9-W3Nl6m.js +314 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.js +543 -507
- package/dist/chunk-Bmb41Sf3.cjs +1 -0
- package/dist/headless.cjs +1 -1
- package/dist/headless.js +428 -447
- package/dist/hooks-6pRsPOyG.js +58 -0
- package/dist/hooks-mivgRljH.cjs +1 -0
- package/dist/i18n.cjs +1 -1
- package/dist/i18n.js +728 -752
- package/dist/index.cjs +26 -26
- package/dist/index.js +16102 -16619
- package/dist/quantum.cjs +14 -16
- package/dist/quantum.js +2473 -2279
- package/dist/realtime.cjs +4 -10
- package/dist/realtime.js +804 -958
- package/dist/src/components/TkxClock.d.ts.map +1 -1
- package/dist/src/components/TkxForm.d.ts.map +1 -1
- package/dist/src/components/TkxLiveFeed.d.ts +1 -1
- package/dist/src/components/TkxLiveLog.d.ts +1 -1
- package/dist/src/components/TkxRealTimeChart.d.ts +1 -1
- package/dist/src/components/TkxTooltip.d.ts.map +1 -1
- package/dist/src/components/TkxTypography.d.ts +5 -5
- package/dist/src/components/TkxTypography.d.ts.map +1 -1
- package/dist/tekivex-ui.css +2 -0
- package/dist/themes-BbJanqiC.js +498 -0
- package/dist/themes-CMq2vWXj.cjs +2 -0
- package/dist/tkx-0oAwZqgL.cjs +4 -0
- package/dist/tkx-DQkvHdE5.js +1172 -0
- package/package.json +16 -16
- package/src/components/TkxClock.tsx +2 -2
- package/src/components/TkxForm.tsx +4 -2
- package/src/components/TkxTooltip.tsx +7 -5
- package/src/components/TkxTypography.tsx +2 -2
- package/dist/TkxForm-2tGLCPH6.js +0 -326
- package/dist/TkxForm-C2VqR2wC.cjs +0 -12
- package/dist/index-BgHMZe4Z.js +0 -66
- package/dist/index-Bt5y50Qa.cjs +0 -1
- package/dist/index-DnqXtpwV.cjs +0 -2
- package/dist/index-iUUHRxqJ.js +0 -515
- package/dist/security-C-ZPGoyG.js +0 -97
- package/dist/security-Uf0mjv8o.cjs +0 -1
- package/dist/style.css +0 -1
- package/dist/tkx-BtHzWKTl.js +0 -1112
- package/dist/tkx-C7GvVUE9.cjs +0 -4
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require(`./chunk-Bmb41Sf3.cjs`);const e=require(`./themes-CMq2vWXj.cjs`),t=require(`./tkx-0oAwZqgL.cjs`);let n=require(`react`),r=require(`react/jsx-runtime`);var i=(0,n.createContext)(null);function a(){let e=(0,n.useContext)(i);if(!e)throw Error(`TkxFormField must be used inside a <TkxForm>. Wrap your fields in a TkxForm component.`);return e}async function o(e,t){for(let n of t){if(n.required&&(e==null||e===``||Array.isArray(e)&&e.length===0))return n.message??`This field is required`;if(!(e==null||e===``)){if(n.min!==void 0){if(typeof e==`string`&&e.length<n.min)return n.message??`Must be at least ${n.min} characters`;if(typeof e==`number`&&e<n.min)return n.message??`Must be at least ${n.min}`}if(n.max!==void 0){if(typeof e==`string`&&e.length>n.max)return n.message??`Must be no more than ${n.max} characters`;if(typeof e==`number`&&e>n.max)return n.message??`Must be no more than ${n.max}`}if(n.pattern&&typeof e==`string`&&!n.pattern.test(e))return n.message??`Invalid format`;if(n.validator){let t=await n.validator(e);if(t)return t}}}return null}function s(e,t){let n=e?[...e]:[];return t&&!n.some(e=>e.required)&&n.unshift({required:!0,message:`This field is required`}),n}function c(e){return e.some(e=>e.required)}function l(){let e=(0,n.useContext)(i),t=(0,n.useRef)({}),r=(0,n.useRef)({}),a=(0,n.useRef)({}),o=(0,n.useMemo)(()=>({getFieldValue:e=>t.current[e],setFieldValue:(e,n)=>{t.current[e]=n},getFieldsValue:()=>({...t.current}),setFieldsValue:e=>{Object.assign(t.current,e)},validateFields:()=>Promise.resolve({...t.current}),validateField:e=>Promise.resolve(!0),resetFields:()=>{t.current={},r.current={},a.current={}},getFieldError:e=>r.current[e]??null,isFieldTouched:e=>a.current[e]??!1}),[]);return e?e.instance:o}function u({onSubmit:a,onValuesChange:s,initialValues:c={},layout:l=`vertical`,disabled:u=!1,children:d,className:f,style:p,form:m}){let h=e.f(),[g,_]=(0,n.useState)({values:{...c},errors:{},touched:{}}),v=(0,n.useRef)(c),y=(0,n.useRef)({}),b=(0,n.useRef)(g);b.current=g;let x=(0,n.useCallback)((e,t)=>{y.current[e]=t},[]),S=(0,n.useCallback)(e=>{delete y.current[e]},[]),C=(0,n.useCallback)((e,t)=>{_(n=>{let r={...n,values:{...n.values,[e]:t}};return s?.({[e]:t},r.values),r})},[s]),w=(0,n.useCallback)((e,t)=>{_(n=>({...n,errors:{...n.errors,[e]:t}}))},[]),T=(0,n.useCallback)(e=>{_(t=>({...t,touched:{...t.touched,[e]:!0}}))},[]),E=(0,n.useCallback)(async e=>{let t=y.current[e];if(!t)return!0;let n=b.current.values[e],r=await o(n,t.rules);return _(t=>({...t,errors:{...t.errors,[e]:r},touched:{...t.touched,[e]:!0}})),r===null},[]),D=(0,n.useCallback)(async()=>{let e=Object.keys(y.current),t=await Promise.all(e.map(async e=>{let t=y.current[e],n=b.current.values[e];return{name:e,error:await o(n,t.rules)}})),n={},r={},i=!1;for(let{name:e,error:a}of t)n[e]=a,r[e]=!0,a&&(i=!0);if(_(e=>({...e,errors:{...e.errors,...n},touched:{...e.touched,...r}})),i){let e=Object.fromEntries(t.filter(e=>e.error).map(e=>[e.name,e.error]));return Promise.reject(e)}return{...b.current.values}},[]),O=(0,n.useCallback)(()=>{_({values:{...v.current},errors:{},touched:{}})},[]),k=(0,n.useMemo)(()=>({getFieldValue:e=>b.current.values[e],setFieldValue:C,getFieldsValue:()=>({...b.current.values}),setFieldsValue:e=>{_(t=>{let n={...t.values,...e};return s?.(e,n),{...t,values:n}})},validateFields:D,validateField:E,resetFields:O,getFieldError:e=>b.current.errors[e]??null,isFieldTouched:e=>!!b.current.touched[e]}),[C,D,E,O,s]),A=(0,n.useCallback)(async e=>{e.preventDefault();try{let e=await D();await a?.(e)}catch{}},[D,a]),j=l===`inline`?t.a(`flex flex-row flex-wrap items-end gap-4`):t.a(`flex flex-col gap-5`),M=m??k,N=(0,n.useMemo)(()=>({state:g,initialValues:v.current,layout:l,disabled:u,fieldMeta:y,setFieldValue:C,setFieldError:w,setFieldTouched:T,registerField:x,unregisterField:S,validateField:E,instance:M}),[g,l,u,C,w,T,x,S,E,M]);return(0,r.jsx)(i.Provider,{value:N,children:(0,r.jsx)(`form`,{noValidate:!0,role:`form`,"aria-label":`Form`,onSubmit:A,className:t.t(j,f),style:{color:h.text,...p},children:d})})}u.displayName=`TkxForm`;function d({name:i,label:o,rules:l,help:u,required:d,children:f,className:p,style:m}){let h=e.f(),g=a(),{state:_,layout:v,disabled:y}=g,b=(0,n.useMemo)(()=>s(l,d),[l,d]),x=c(b),S=(0,n.useRef)({rules:b});S.current.rules=b;let C=(0,n.useRef)(!1);C.current||=(g.registerField(i,S.current),!0),(0,n.useMemo)(()=>{g.registerField(i,S.current)},[b,i,g]);let w=_.values[i],T=_.touched[i]?_.errors[i]??null:null,E=T?t.m(T):null,D=o?t.m(o):void 0,O=u?t.m(u):void 0,k=(0,n.useCallback)(e=>{let t;if(typeof e==`object`&&e&&`target`in e){let n=e.target;t=n.type===`checkbox`?n.checked:n.value}else t=e;g.setFieldValue(i,t)},[g,i]),A=(0,n.useCallback)(()=>{g.setFieldTouched(i),g.validateField(i)},[g,i]),j=f,M=(0,n.cloneElement)(j,{value:w??``,onChange:k,onBlur:A,error:E??void 0,isInvalid:!!E,isRequired:x,disabled:y||j.props.disabled,name:i}),N=v===`horizontal`,P=v===`inline`,F=(0,r.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 24 24`,fill:`currentColor`,"aria-hidden":`true`,children:(0,r.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`})}),I=D?(0,r.jsxs)(`label`,{className:t.a(`text-sm font-medium font-sans`,N?`min-w-[140px] pt-2.5`:``),style:{color:h.text},children:[D,x&&(0,r.jsx)(`span`,{"aria-hidden":`true`,className:t.a(`ml-1`),style:{color:h.danger},children:`*`})]}):null,L=(0,r.jsxs)(r.Fragment,{children:[O&&!E&&(0,r.jsx)(`span`,{className:t.a(`text-xs mt-0.5`),style:{color:h.textMuted},children:O}),E&&(0,r.jsxs)(`span`,{role:`alert`,className:t.a(`text-xs flex items-center gap-1 mt-0.5`),style:{color:h.danger,animation:`tkxFormErrorReveal 200ms ease-out`},children:[F,E]})]});return P?(0,r.jsxs)(`div`,{className:t.t(t.a(`flex flex-col gap-1`),p),style:m,children:[I,M,L]}):N?(0,r.jsxs)(`div`,{className:t.t(t.a(`flex flex-row gap-4 items-start`),p),style:m,children:[I,(0,r.jsxs)(`div`,{className:t.a(`flex flex-col gap-1 flex-1 min-w-0`),children:[M,L]})]}):(0,r.jsxs)(`div`,{className:t.t(t.a(`flex flex-col gap-1`),p),style:m,children:[I,M,L]})}d.displayName=`TkxFormField`;var f=!1;function p(){if(f||typeof document>`u`)return;f=!0;let e=document.createElement(`style`);e.setAttribute(`data-tkx-form`,``),e.textContent=`
|
|
2
|
+
@keyframes tkxFormErrorReveal {
|
|
3
|
+
from {
|
|
4
|
+
opacity: 0;
|
|
5
|
+
transform: translateY(-4px);
|
|
6
|
+
}
|
|
7
|
+
to {
|
|
8
|
+
opacity: 1;
|
|
9
|
+
transform: translateY(0);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
`,document.head.appendChild(e)}p(),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return u}});
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { f as e } from "./themes-BbJanqiC.js";
|
|
2
|
+
import { a as t, m as n, t as r } from "./tkx-DQkvHdE5.js";
|
|
3
|
+
import { cloneElement as i, createContext as a, useCallback as o, useContext as s, useMemo as c, useRef as l, useState as u } from "react";
|
|
4
|
+
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/TkxForm.tsx
|
|
6
|
+
var m = a(null);
|
|
7
|
+
function h() {
|
|
8
|
+
let e = s(m);
|
|
9
|
+
if (!e) throw Error("TkxFormField must be used inside a <TkxForm>. Wrap your fields in a TkxForm component.");
|
|
10
|
+
return e;
|
|
11
|
+
}
|
|
12
|
+
async function g(e, t) {
|
|
13
|
+
for (let n of t) {
|
|
14
|
+
if (n.required && (e == null || e === "" || Array.isArray(e) && e.length === 0)) return n.message ?? "This field is required";
|
|
15
|
+
if (!(e == null || e === "")) {
|
|
16
|
+
if (n.min !== void 0) {
|
|
17
|
+
if (typeof e == "string" && e.length < n.min) return n.message ?? `Must be at least ${n.min} characters`;
|
|
18
|
+
if (typeof e == "number" && e < n.min) return n.message ?? `Must be at least ${n.min}`;
|
|
19
|
+
}
|
|
20
|
+
if (n.max !== void 0) {
|
|
21
|
+
if (typeof e == "string" && e.length > n.max) return n.message ?? `Must be no more than ${n.max} characters`;
|
|
22
|
+
if (typeof e == "number" && e > n.max) return n.message ?? `Must be no more than ${n.max}`;
|
|
23
|
+
}
|
|
24
|
+
if (n.pattern && typeof e == "string" && !n.pattern.test(e)) return n.message ?? "Invalid format";
|
|
25
|
+
if (n.validator) {
|
|
26
|
+
let t = await n.validator(e);
|
|
27
|
+
if (t) return t;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
function _(e, t) {
|
|
34
|
+
let n = e ? [...e] : [];
|
|
35
|
+
return t && !n.some((e) => e.required) && n.unshift({
|
|
36
|
+
required: !0,
|
|
37
|
+
message: "This field is required"
|
|
38
|
+
}), n;
|
|
39
|
+
}
|
|
40
|
+
function v(e) {
|
|
41
|
+
return e.some((e) => e.required);
|
|
42
|
+
}
|
|
43
|
+
function y() {
|
|
44
|
+
let e = s(m), t = l({}), n = l({}), r = l({}), i = c(() => ({
|
|
45
|
+
getFieldValue: (e) => t.current[e],
|
|
46
|
+
setFieldValue: (e, n) => {
|
|
47
|
+
t.current[e] = n;
|
|
48
|
+
},
|
|
49
|
+
getFieldsValue: () => ({ ...t.current }),
|
|
50
|
+
setFieldsValue: (e) => {
|
|
51
|
+
Object.assign(t.current, e);
|
|
52
|
+
},
|
|
53
|
+
validateFields: () => Promise.resolve({ ...t.current }),
|
|
54
|
+
validateField: (e) => Promise.resolve(!0),
|
|
55
|
+
resetFields: () => {
|
|
56
|
+
t.current = {}, n.current = {}, r.current = {};
|
|
57
|
+
},
|
|
58
|
+
getFieldError: (e) => n.current[e] ?? null,
|
|
59
|
+
isFieldTouched: (e) => r.current[e] ?? !1
|
|
60
|
+
}), []);
|
|
61
|
+
return e ? e.instance : i;
|
|
62
|
+
}
|
|
63
|
+
function b({ onSubmit: n, onValuesChange: i, initialValues: a = {}, layout: s = "vertical", disabled: d = !1, children: p, className: h, style: _, form: v }) {
|
|
64
|
+
let y = e(), [b, x] = u({
|
|
65
|
+
values: { ...a },
|
|
66
|
+
errors: {},
|
|
67
|
+
touched: {}
|
|
68
|
+
}), S = l(a), C = l({}), w = l(b);
|
|
69
|
+
w.current = b;
|
|
70
|
+
let T = o((e, t) => {
|
|
71
|
+
C.current[e] = t;
|
|
72
|
+
}, []), E = o((e) => {
|
|
73
|
+
delete C.current[e];
|
|
74
|
+
}, []), D = o((e, t) => {
|
|
75
|
+
x((n) => {
|
|
76
|
+
let r = {
|
|
77
|
+
...n,
|
|
78
|
+
values: {
|
|
79
|
+
...n.values,
|
|
80
|
+
[e]: t
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return i?.({ [e]: t }, r.values), r;
|
|
84
|
+
});
|
|
85
|
+
}, [i]), O = o((e, t) => {
|
|
86
|
+
x((n) => ({
|
|
87
|
+
...n,
|
|
88
|
+
errors: {
|
|
89
|
+
...n.errors,
|
|
90
|
+
[e]: t
|
|
91
|
+
}
|
|
92
|
+
}));
|
|
93
|
+
}, []), k = o((e) => {
|
|
94
|
+
x((t) => ({
|
|
95
|
+
...t,
|
|
96
|
+
touched: {
|
|
97
|
+
...t.touched,
|
|
98
|
+
[e]: !0
|
|
99
|
+
}
|
|
100
|
+
}));
|
|
101
|
+
}, []), A = o(async (e) => {
|
|
102
|
+
let t = C.current[e];
|
|
103
|
+
if (!t) return !0;
|
|
104
|
+
let n = w.current.values[e], r = await g(n, t.rules);
|
|
105
|
+
return x((t) => ({
|
|
106
|
+
...t,
|
|
107
|
+
errors: {
|
|
108
|
+
...t.errors,
|
|
109
|
+
[e]: r
|
|
110
|
+
},
|
|
111
|
+
touched: {
|
|
112
|
+
...t.touched,
|
|
113
|
+
[e]: !0
|
|
114
|
+
}
|
|
115
|
+
})), r === null;
|
|
116
|
+
}, []), j = o(async () => {
|
|
117
|
+
let e = Object.keys(C.current), t = await Promise.all(e.map(async (e) => {
|
|
118
|
+
let t = C.current[e], n = w.current.values[e];
|
|
119
|
+
return {
|
|
120
|
+
name: e,
|
|
121
|
+
error: await g(n, t.rules)
|
|
122
|
+
};
|
|
123
|
+
})), n = {}, r = {}, i = !1;
|
|
124
|
+
for (let { name: e, error: a } of t) n[e] = a, r[e] = !0, a && (i = !0);
|
|
125
|
+
if (x((e) => ({
|
|
126
|
+
...e,
|
|
127
|
+
errors: {
|
|
128
|
+
...e.errors,
|
|
129
|
+
...n
|
|
130
|
+
},
|
|
131
|
+
touched: {
|
|
132
|
+
...e.touched,
|
|
133
|
+
...r
|
|
134
|
+
}
|
|
135
|
+
})), i) {
|
|
136
|
+
let e = Object.fromEntries(t.filter((e) => e.error).map((e) => [e.name, e.error]));
|
|
137
|
+
return Promise.reject(e);
|
|
138
|
+
}
|
|
139
|
+
return { ...w.current.values };
|
|
140
|
+
}, []), M = o(() => {
|
|
141
|
+
x({
|
|
142
|
+
values: { ...S.current },
|
|
143
|
+
errors: {},
|
|
144
|
+
touched: {}
|
|
145
|
+
});
|
|
146
|
+
}, []), N = c(() => ({
|
|
147
|
+
getFieldValue: (e) => w.current.values[e],
|
|
148
|
+
setFieldValue: D,
|
|
149
|
+
getFieldsValue: () => ({ ...w.current.values }),
|
|
150
|
+
setFieldsValue: (e) => {
|
|
151
|
+
x((t) => {
|
|
152
|
+
let n = {
|
|
153
|
+
...t.values,
|
|
154
|
+
...e
|
|
155
|
+
};
|
|
156
|
+
return i?.(e, n), {
|
|
157
|
+
...t,
|
|
158
|
+
values: n
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
},
|
|
162
|
+
validateFields: j,
|
|
163
|
+
validateField: A,
|
|
164
|
+
resetFields: M,
|
|
165
|
+
getFieldError: (e) => w.current.errors[e] ?? null,
|
|
166
|
+
isFieldTouched: (e) => !!w.current.touched[e]
|
|
167
|
+
}), [
|
|
168
|
+
D,
|
|
169
|
+
j,
|
|
170
|
+
A,
|
|
171
|
+
M,
|
|
172
|
+
i
|
|
173
|
+
]), P = o(async (e) => {
|
|
174
|
+
e.preventDefault();
|
|
175
|
+
try {
|
|
176
|
+
let e = await j();
|
|
177
|
+
await n?.(e);
|
|
178
|
+
} catch {}
|
|
179
|
+
}, [j, n]), F = t(s === "inline" ? "flex flex-row flex-wrap items-end gap-4" : "flex flex-col gap-5"), I = v ?? N, L = c(() => ({
|
|
180
|
+
state: b,
|
|
181
|
+
initialValues: S.current,
|
|
182
|
+
layout: s,
|
|
183
|
+
disabled: d,
|
|
184
|
+
fieldMeta: C,
|
|
185
|
+
setFieldValue: D,
|
|
186
|
+
setFieldError: O,
|
|
187
|
+
setFieldTouched: k,
|
|
188
|
+
registerField: T,
|
|
189
|
+
unregisterField: E,
|
|
190
|
+
validateField: A,
|
|
191
|
+
instance: I
|
|
192
|
+
}), [
|
|
193
|
+
b,
|
|
194
|
+
s,
|
|
195
|
+
d,
|
|
196
|
+
D,
|
|
197
|
+
O,
|
|
198
|
+
k,
|
|
199
|
+
T,
|
|
200
|
+
E,
|
|
201
|
+
A,
|
|
202
|
+
I
|
|
203
|
+
]);
|
|
204
|
+
return /* @__PURE__ */ f(m.Provider, {
|
|
205
|
+
value: L,
|
|
206
|
+
children: /* @__PURE__ */ f("form", {
|
|
207
|
+
noValidate: !0,
|
|
208
|
+
role: "form",
|
|
209
|
+
"aria-label": "Form",
|
|
210
|
+
onSubmit: P,
|
|
211
|
+
className: r(F, h),
|
|
212
|
+
style: {
|
|
213
|
+
color: y.text,
|
|
214
|
+
..._
|
|
215
|
+
},
|
|
216
|
+
children: p
|
|
217
|
+
})
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
b.displayName = "TkxForm";
|
|
221
|
+
function x({ name: a, label: s, rules: u, help: m, required: g, children: y, className: b, style: x }) {
|
|
222
|
+
let S = e(), C = h(), { state: w, layout: T, disabled: E } = C, D = c(() => _(u, g), [u, g]), O = v(D), k = l({ rules: D });
|
|
223
|
+
k.current.rules = D;
|
|
224
|
+
let A = l(!1);
|
|
225
|
+
A.current ||= (C.registerField(a, k.current), !0), c(() => {
|
|
226
|
+
C.registerField(a, k.current);
|
|
227
|
+
}, [
|
|
228
|
+
D,
|
|
229
|
+
a,
|
|
230
|
+
C
|
|
231
|
+
]);
|
|
232
|
+
let j = w.values[a], M = w.touched[a] ? w.errors[a] ?? null : null, N = M ? n(M) : null, P = s ? n(s) : void 0, F = m ? n(m) : void 0, I = o((e) => {
|
|
233
|
+
let t;
|
|
234
|
+
if (typeof e == "object" && e && "target" in e) {
|
|
235
|
+
let n = e.target;
|
|
236
|
+
t = n.type === "checkbox" ? n.checked : n.value;
|
|
237
|
+
} else t = e;
|
|
238
|
+
C.setFieldValue(a, t);
|
|
239
|
+
}, [C, a]), L = o(() => {
|
|
240
|
+
C.setFieldTouched(a), C.validateField(a);
|
|
241
|
+
}, [C, a]), R = y, z = i(R, {
|
|
242
|
+
value: j ?? "",
|
|
243
|
+
onChange: I,
|
|
244
|
+
onBlur: L,
|
|
245
|
+
error: N ?? void 0,
|
|
246
|
+
isInvalid: !!N,
|
|
247
|
+
isRequired: O,
|
|
248
|
+
disabled: E || R.props.disabled,
|
|
249
|
+
name: a
|
|
250
|
+
}), B = T === "horizontal", V = T === "inline", H = /* @__PURE__ */ f("svg", {
|
|
251
|
+
width: "12",
|
|
252
|
+
height: "12",
|
|
253
|
+
viewBox: "0 0 24 24",
|
|
254
|
+
fill: "currentColor",
|
|
255
|
+
"aria-hidden": "true",
|
|
256
|
+
children: /* @__PURE__ */ f("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" })
|
|
257
|
+
}), U = P ? /* @__PURE__ */ p("label", {
|
|
258
|
+
className: t("text-sm font-medium font-sans", B ? "min-w-[140px] pt-2.5" : ""),
|
|
259
|
+
style: { color: S.text },
|
|
260
|
+
children: [P, O && /* @__PURE__ */ f("span", {
|
|
261
|
+
"aria-hidden": "true",
|
|
262
|
+
className: t("ml-1"),
|
|
263
|
+
style: { color: S.danger },
|
|
264
|
+
children: "*"
|
|
265
|
+
})]
|
|
266
|
+
}) : null, W = /* @__PURE__ */ p(d, { children: [F && !N && /* @__PURE__ */ f("span", {
|
|
267
|
+
className: t("text-xs mt-0.5"),
|
|
268
|
+
style: { color: S.textMuted },
|
|
269
|
+
children: F
|
|
270
|
+
}), N && /* @__PURE__ */ p("span", {
|
|
271
|
+
role: "alert",
|
|
272
|
+
className: t("text-xs flex items-center gap-1 mt-0.5"),
|
|
273
|
+
style: {
|
|
274
|
+
color: S.danger,
|
|
275
|
+
animation: "tkxFormErrorReveal 200ms ease-out"
|
|
276
|
+
},
|
|
277
|
+
children: [H, N]
|
|
278
|
+
})] });
|
|
279
|
+
return V ? /* @__PURE__ */ p("div", {
|
|
280
|
+
className: r(t("flex flex-col gap-1"), b),
|
|
281
|
+
style: x,
|
|
282
|
+
children: [
|
|
283
|
+
U,
|
|
284
|
+
z,
|
|
285
|
+
W
|
|
286
|
+
]
|
|
287
|
+
}) : B ? /* @__PURE__ */ p("div", {
|
|
288
|
+
className: r(t("flex flex-row gap-4 items-start"), b),
|
|
289
|
+
style: x,
|
|
290
|
+
children: [U, /* @__PURE__ */ p("div", {
|
|
291
|
+
className: t("flex flex-col gap-1 flex-1 min-w-0"),
|
|
292
|
+
children: [z, W]
|
|
293
|
+
})]
|
|
294
|
+
}) : /* @__PURE__ */ p("div", {
|
|
295
|
+
className: r(t("flex flex-col gap-1"), b),
|
|
296
|
+
style: x,
|
|
297
|
+
children: [
|
|
298
|
+
U,
|
|
299
|
+
z,
|
|
300
|
+
W
|
|
301
|
+
]
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
x.displayName = "TkxFormField";
|
|
305
|
+
var S = !1;
|
|
306
|
+
function C() {
|
|
307
|
+
if (S || typeof document > "u") return;
|
|
308
|
+
S = !0;
|
|
309
|
+
let e = document.createElement("style");
|
|
310
|
+
e.setAttribute("data-tkx-form", ""), e.textContent = "\n @keyframes tkxFormErrorReveal {\n from {\n opacity: 0;\n transform: translateY(-4px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n ", document.head.appendChild(e);
|
|
311
|
+
}
|
|
312
|
+
C();
|
|
313
|
+
//#endregion
|
|
314
|
+
export { x as n, y as r, b as t };
|
package/dist/charts.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunk-Bmb41Sf3.cjs`);const e=require(`./themes-CMq2vWXj.cjs`),t=require(`./hooks-mivgRljH.cjs`);let n=require(`react`),r=require(`react/jsx-runtime`),i=require(`recharts`);function a(e){return[e.primary,e.secondary,e.info,e.success,e.warning,e.danger,e.primary+`aa`,e.secondary+`aa`,e.info+`aa`,e.success+`aa`]}var o={top:10,right:30,bottom:10,left:0};function s(e){return{contentStyle:{backgroundColor:e.surface,border:`1px solid ${e.border}`,borderRadius:8,boxShadow:`0 4px 12px rgba(0,0,0,0.15)`,color:e.text,fontSize:13},labelStyle:{color:e.textMuted,fontWeight:600,marginBottom:4},itemStyle:{color:e.text},cursor:{fill:`${e.primary}15`}}}function c({data:t,series:n,xKey:c,height:l=300,margin:u=o,showGrid:d=!0,showLegend:f=!0,showTooltip:p=!0,smooth:m=!0,xTickFormatter:h,yTickFormatter:g,yDomain:_,ariaLabel:v=`Area chart`}){let y=e.f(),b=a(y),x=s(y),S={fill:y.textMuted,fontSize:12};return(0,r.jsx)(`div`,{role:`img`,"aria-label":v,style:{width:`100%`,height:l},children:(0,r.jsx)(i.ResponsiveContainer,{width:`100%`,height:`100%`,children:(0,r.jsxs)(i.AreaChart,{data:t,margin:u,children:[d&&(0,r.jsx)(i.CartesianGrid,{strokeDasharray:`3 3`,stroke:y.border,vertical:!1}),(0,r.jsx)(i.XAxis,{dataKey:c,tick:S,axisLine:{stroke:y.border},tickLine:!1,tickFormatter:h}),(0,r.jsx)(i.YAxis,{tick:S,axisLine:!1,tickLine:!1,tickFormatter:g,domain:_}),p&&(0,r.jsx)(i.Tooltip,{contentStyle:x.contentStyle,labelStyle:x.labelStyle,itemStyle:x.itemStyle,cursor:x.cursor}),f&&(0,r.jsx)(i.Legend,{wrapperStyle:{fontSize:13,color:y.textMuted,paddingTop:8}}),n.map((e,t)=>{let n=e.color??b[t%b.length];return(0,r.jsx)(i.Area,{type:m?`monotone`:`linear`,dataKey:e.key,name:e.label??e.key,stroke:n,strokeWidth:2,fill:n,fillOpacity:e.fillOpacity??.2,stackId:e.stacked?`stack`:void 0,dot:!1,activeDot:{r:5,strokeWidth:0}},e.key)})]})})})}function l({data:t,series:n,xKey:c,height:l=300,margin:u=o,showGrid:d=!0,showLegend:f=!0,showTooltip:p=!0,layout:m=`horizontal`,barSize:h,xTickFormatter:g,yTickFormatter:_,ariaLabel:v=`Bar chart`}){let y=e.f(),b=a(y),x=s(y),S={fill:y.textMuted,fontSize:12},C=m===`vertical`;return(0,r.jsx)(`div`,{role:`img`,"aria-label":v,style:{width:`100%`,height:l},children:(0,r.jsx)(i.ResponsiveContainer,{width:`100%`,height:`100%`,children:(0,r.jsxs)(i.BarChart,{data:t,margin:u,layout:m,children:[d&&(0,r.jsx)(i.CartesianGrid,{strokeDasharray:`3 3`,stroke:y.border,vertical:C,horizontal:!C}),C?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.YAxis,{dataKey:c,type:`category`,tick:S,axisLine:!1,tickLine:!1,tickFormatter:g,width:100}),(0,r.jsx)(i.XAxis,{type:`number`,tick:S,axisLine:{stroke:y.border},tickLine:!1,tickFormatter:_})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.XAxis,{dataKey:c,tick:S,axisLine:{stroke:y.border},tickLine:!1,tickFormatter:g}),(0,r.jsx)(i.YAxis,{tick:S,axisLine:!1,tickLine:!1,tickFormatter:_})]}),p&&(0,r.jsx)(i.Tooltip,{contentStyle:x.contentStyle,labelStyle:x.labelStyle,itemStyle:x.itemStyle,cursor:{fill:`${y.surfaceAlt}`}}),f&&(0,r.jsx)(i.Legend,{wrapperStyle:{fontSize:13,color:y.textMuted,paddingTop:8}}),n.map((e,t)=>{let n=e.color??b[t%b.length];return(0,r.jsx)(i.Bar,{dataKey:e.key,name:e.label??e.key,fill:n,stackId:e.stackId,maxBarSize:h??40,radius:e.radius??[4,4,0,0]},e.key)})]})})})}function u({data:t,series:n,xKey:c,height:l=300,margin:u=o,showGrid:d=!0,showLegend:f=!0,showTooltip:p=!0,smooth:m=!0,referenceLines:h=[],xTickFormatter:g,yTickFormatter:_,yDomain:v,connectNulls:y=!1,ariaLabel:b=`Line chart`}){let x=e.f(),S=a(x),C=s(x),w={fill:x.textMuted,fontSize:12};return(0,r.jsx)(`div`,{role:`img`,"aria-label":b,style:{width:`100%`,height:l},children:(0,r.jsx)(i.ResponsiveContainer,{width:`100%`,height:`100%`,children:(0,r.jsxs)(i.LineChart,{data:t,margin:u,children:[d&&(0,r.jsx)(i.CartesianGrid,{strokeDasharray:`3 3`,stroke:x.border,vertical:!1}),(0,r.jsx)(i.XAxis,{dataKey:c,tick:w,axisLine:{stroke:x.border},tickLine:!1,tickFormatter:g}),(0,r.jsx)(i.YAxis,{tick:w,axisLine:!1,tickLine:!1,tickFormatter:_,domain:v}),p&&(0,r.jsx)(i.Tooltip,{contentStyle:C.contentStyle,labelStyle:C.labelStyle,itemStyle:C.itemStyle,cursor:{stroke:x.border,strokeWidth:1}}),f&&(0,r.jsx)(i.Legend,{wrapperStyle:{fontSize:13,color:x.textMuted,paddingTop:8}}),h.map((e,t)=>(0,r.jsx)(i.ReferenceLine,{y:e.y,x:e.x,label:e.label?{value:e.label,fill:x.textMuted,fontSize:11}:void 0,stroke:e.color??x.border,strokeDasharray:e.dashed?`4 4`:void 0},t)),n.map((e,t)=>{let n=e.color??S[t%S.length];return(0,r.jsx)(i.Line,{type:m?`monotone`:`linear`,dataKey:e.key,name:e.label??e.key,stroke:n,strokeWidth:e.strokeWidth??2,strokeDasharray:e.dashed?`6 3`:void 0,dot:e.dot??!1,activeDot:{r:5,strokeWidth:0,fill:n},connectNulls:y},e.key)})]})})})}function d({data:o,height:c=300,showLegend:l=!0,showTooltip:u=!0,showLabels:d=!1,outerRadius:f=`70%`,startAngle:p=90,ariaLabel:m=`Pie chart`}){let h=e.f(),g=t.o(),_=a(h),v=s(h),[y,b]=(0,n.useState)(g);return(0,n.useEffect)(()=>{if(g){b(!0);return}let e=requestAnimationFrame(()=>b(!0));return()=>cancelAnimationFrame(e)},[g]),(0,r.jsx)(`div`,{role:`img`,"aria-label":m,style:{width:`100%`,minWidth:240,height:c,position:`relative`},children:y&&(0,r.jsx)(i.ResponsiveContainer,{width:`100%`,height:`100%`,debounce:50,children:(0,r.jsxs)(i.PieChart,{children:[u&&(0,r.jsx)(i.Tooltip,{contentStyle:v.contentStyle,labelStyle:v.labelStyle,itemStyle:v.itemStyle}),l&&(0,r.jsx)(i.Legend,{wrapperStyle:{fontSize:13,color:h.textMuted}}),(0,r.jsx)(i.Pie,{data:o,dataKey:`value`,nameKey:`name`,outerRadius:f,startAngle:p,endAngle:p-360,label:d?({name:e,percent:t})=>`${e} (${(t*100).toFixed(0)}%)`:void 0,labelLine:d,strokeWidth:2,stroke:h.bg,children:o.map((e,t)=>(0,r.jsx)(i.Cell,{fill:e.color??_[t%_.length]},e.name))})]})})})}function f({data:o,height:c=300,showLegend:l=!0,showTooltip:u=!0,centerLabel:d,centerSublabel:f,innerRadius:p=`55%`,outerRadius:m=`75%`,startAngle:h=90,ariaLabel:g=`Donut chart`}){let _=e.f(),v=t.o(),y=a(_),b=s(_),[x,S]=(0,n.useState)(v);return(0,n.useEffect)(()=>{if(v){S(!0);return}let e=requestAnimationFrame(()=>S(!0));return()=>cancelAnimationFrame(e)},[v]),(0,r.jsxs)(`div`,{role:`img`,"aria-label":g,style:{width:`100%`,minWidth:240,height:c,position:`relative`},children:[x&&(0,r.jsx)(i.ResponsiveContainer,{width:`100%`,height:`100%`,debounce:50,children:(0,r.jsxs)(i.PieChart,{children:[u&&(0,r.jsx)(i.Tooltip,{contentStyle:b.contentStyle,labelStyle:b.labelStyle,itemStyle:b.itemStyle}),l&&(0,r.jsx)(i.Legend,{wrapperStyle:{fontSize:13,color:_.textMuted}}),(0,r.jsx)(i.Pie,{data:o,dataKey:`value`,nameKey:`name`,innerRadius:p,outerRadius:m,startAngle:h,endAngle:h-360,strokeWidth:3,stroke:_.bg,label:!1,labelLine:!1,children:o.map((e,t)=>(0,r.jsx)(i.Cell,{fill:e.color??y[t%y.length]},e.name))}),(d||f)&&(0,r.jsx)(`text`,{})]})}),(d||f)&&(0,r.jsxs)(`div`,{style:{position:`absolute`,inset:0,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,pointerEvents:`none`,marginTop:l?-24:0},children:[d&&(0,r.jsx)(`span`,{style:{fontSize:22,fontWeight:700,color:_.text,lineHeight:1},children:d}),f&&(0,r.jsx)(`span`,{style:{fontSize:13,color:_.textMuted,marginTop:4},children:f})]})]})}function p({series:t,height:n=300,margin:c=o,showGrid:l=!0,showLegend:u=!0,showTooltip:d=!0,xTickFormatter:f,yTickFormatter:p,zRange:m=[20,400],ariaLabel:h=`Scatter chart`}){let g=e.f(),_=a(g),v=s(g),y={fill:g.textMuted,fontSize:12};return(0,r.jsx)(`div`,{role:`img`,"aria-label":h,style:{width:`100%`,height:n},children:(0,r.jsx)(i.ResponsiveContainer,{width:`100%`,height:`100%`,children:(0,r.jsxs)(i.ScatterChart,{margin:c,children:[l&&(0,r.jsx)(i.CartesianGrid,{strokeDasharray:`3 3`,stroke:g.border}),(0,r.jsx)(i.XAxis,{type:`number`,dataKey:`x`,tick:y,axisLine:{stroke:g.border},tickLine:!1,tickFormatter:f}),(0,r.jsx)(i.YAxis,{type:`number`,dataKey:`y`,tick:y,axisLine:!1,tickLine:!1,tickFormatter:p}),(0,r.jsx)(i.ZAxis,{type:`number`,dataKey:`z`,range:m}),d&&(0,r.jsx)(i.Tooltip,{contentStyle:v.contentStyle,labelStyle:v.labelStyle,itemStyle:v.itemStyle,cursor:{strokeDasharray:`3 3`}}),u&&(0,r.jsx)(i.Legend,{wrapperStyle:{fontSize:13,color:g.textMuted,paddingTop:8}}),t.map((e,t)=>(0,r.jsx)(i.Scatter,{name:e.name,data:e.data,fill:e.color??_[t%_.length],fillOpacity:.8},e.name??t))]})})})}function m({data:t,series:n,angleKey:o,height:c=300,showLegend:l=!0,showTooltip:u=!0,outerRadius:d=`70%`,ariaLabel:f=`Radar chart`}){let p=e.f(),m=a(p),h=s(p);return(0,r.jsx)(`div`,{role:`img`,"aria-label":f,style:{width:`100%`,height:c},children:(0,r.jsx)(i.ResponsiveContainer,{width:`100%`,height:`100%`,children:(0,r.jsxs)(i.RadarChart,{data:t,outerRadius:d,children:[(0,r.jsx)(i.PolarGrid,{stroke:p.border}),(0,r.jsx)(i.PolarAngleAxis,{dataKey:o,tick:{fill:p.textMuted,fontSize:12}}),(0,r.jsx)(i.PolarRadiusAxis,{tick:{fill:p.textMuted,fontSize:10},axisLine:!1,tickLine:!1}),u&&(0,r.jsx)(i.Tooltip,{contentStyle:h.contentStyle,labelStyle:h.labelStyle,itemStyle:h.itemStyle}),l&&(0,r.jsx)(i.Legend,{wrapperStyle:{fontSize:13,color:p.textMuted}}),n.map((e,t)=>{let n=e.color??m[t%m.length];return(0,r.jsx)(i.Radar,{name:e.label??e.key,dataKey:e.key,stroke:n,fill:n,fillOpacity:e.fillOpacity??.2,strokeWidth:2},e.key)})]})})})}exports.TkxAreaChart=c,exports.TkxBarChart=l,exports.TkxDonutChart=f,exports.TkxLineChart=u,exports.TkxPieChart=d,exports.TkxRadarChart=m,exports.TkxScatterChart=p;
|