@cryptlex/web-components 6.6.2 → 6.6.6-alpha01

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.
Files changed (112) hide show
  1. package/dist/components/alert.js +1 -1
  2. package/dist/components/alert.js.map +1 -1
  3. package/dist/components/avatar.js +1 -1
  4. package/dist/components/avatar.js.map +1 -1
  5. package/dist/components/badge.js +1 -1
  6. package/dist/components/badge.js.map +1 -1
  7. package/dist/components/breadcrumbs.js +1 -1
  8. package/dist/components/breadcrumbs.js.map +1 -1
  9. package/dist/components/button.js +1 -1
  10. package/dist/components/button.js.map +1 -1
  11. package/dist/components/calendar.js +1 -1
  12. package/dist/components/calendar.js.map +1 -1
  13. package/dist/components/card.js +1 -1
  14. package/dist/components/card.js.map +1 -1
  15. package/dist/components/checkbox.js +1 -1
  16. package/dist/components/checkbox.js.map +1 -1
  17. package/dist/components/data-table-filter.d.ts +7 -5
  18. package/dist/components/data-table-filter.js +1 -1
  19. package/dist/components/data-table.d.ts +7 -7
  20. package/dist/components/data-table.js +1 -1
  21. package/dist/components/data-table.js.map +1 -1
  22. package/dist/components/date-picker.js +1 -1
  23. package/dist/components/date-picker.js.map +1 -1
  24. package/dist/components/datefield.js +1 -1
  25. package/dist/components/datefield.js.map +1 -1
  26. package/dist/components/dialog.d.ts +93 -0
  27. package/dist/components/dialog.js +1 -1
  28. package/dist/components/dialog.js.map +1 -1
  29. package/dist/components/disclosure.js +1 -1
  30. package/dist/components/disclosure.js.map +1 -1
  31. package/dist/components/field.d.ts +2 -1
  32. package/dist/components/field.js +1 -1
  33. package/dist/components/field.js.map +1 -1
  34. package/dist/components/icons.js.map +1 -1
  35. package/dist/components/id-search.js +1 -1
  36. package/dist/components/id-search.js.map +1 -1
  37. package/dist/components/list-box.js +1 -1
  38. package/dist/components/list-box.js.map +1 -1
  39. package/dist/components/loader.js +1 -1
  40. package/dist/components/loader.js.map +1 -1
  41. package/dist/components/menu.js +1 -1
  42. package/dist/components/menu.js.map +1 -1
  43. package/dist/components/multi-select.js +1 -1
  44. package/dist/components/multi-select.js.map +1 -1
  45. package/dist/components/numberfield.js +1 -1
  46. package/dist/components/numberfield.js.map +1 -1
  47. package/dist/components/{key-value-card.d.ts → object-table.d.ts} +2 -2
  48. package/dist/components/object-table.js +2 -0
  49. package/dist/components/object-table.js.map +1 -0
  50. package/dist/components/otpfield.d.ts +2 -0
  51. package/dist/components/otpfield.js +2 -0
  52. package/dist/components/otpfield.js.map +1 -0
  53. package/dist/components/popover.js +1 -1
  54. package/dist/components/popover.js.map +1 -1
  55. package/dist/components/searchfield.js +1 -1
  56. package/dist/components/searchfield.js.map +1 -1
  57. package/dist/components/select.js +1 -1
  58. package/dist/components/select.js.map +1 -1
  59. package/dist/components/sidebar.js +1 -1
  60. package/dist/components/sidebar.js.map +1 -1
  61. package/dist/components/skeleton.js +1 -1
  62. package/dist/components/skeleton.js.map +1 -1
  63. package/dist/components/sonner.js +1 -1
  64. package/dist/components/sonner.js.map +1 -1
  65. package/dist/components/table-of-contents.js +1 -1
  66. package/dist/components/table-of-contents.js.map +1 -1
  67. package/dist/components/table.js +1 -1
  68. package/dist/components/table.js.map +1 -1
  69. package/dist/components/tabs.js +1 -1
  70. package/dist/components/tabs.js.map +1 -1
  71. package/dist/components/textfield.d.ts +2 -1
  72. package/dist/components/textfield.js +1 -1
  73. package/dist/components/textfield.js.map +1 -1
  74. package/dist/components/timeline.js +1 -1
  75. package/dist/components/timeline.js.map +1 -1
  76. package/dist/components/tooltip.js +1 -1
  77. package/dist/components/tooltip.js.map +1 -1
  78. package/dist/utilities/auth.d.ts +17 -0
  79. package/dist/utilities/auth.js +2 -0
  80. package/dist/utilities/auth.js.map +1 -0
  81. package/dist/utilities/date.d.ts +0 -1
  82. package/dist/utilities/date.js +1 -1
  83. package/dist/utilities/date.js.map +1 -1
  84. package/dist/utilities/form-hook.js +1 -1
  85. package/dist/utilities/form-hook.js.map +1 -1
  86. package/dist/utilities/{form-utils.d.ts → form.d.ts} +3 -2
  87. package/dist/utilities/form.js +2 -0
  88. package/dist/utilities/form.js.map +1 -0
  89. package/dist/utilities/resources.d.ts +6 -2
  90. package/dist/utilities/resources.js +1 -1
  91. package/dist/utilities/resources.js.map +1 -1
  92. package/dist/utilities/string.d.ts +5 -0
  93. package/dist/utilities/string.js +2 -0
  94. package/dist/utilities/string.js.map +1 -0
  95. package/dist/utilities/theme.d.ts +12 -0
  96. package/dist/utilities/theme.js +2 -0
  97. package/dist/utilities/theme.js.map +1 -0
  98. package/lib/theme.css +4 -1
  99. package/package.json +15 -9
  100. package/dist/components/data-table-commons.d.ts +0 -13
  101. package/dist/components/data-table-commons.js +0 -2
  102. package/dist/components/data-table-commons.js.map +0 -1
  103. package/dist/components/input-otp.d.ts +0 -7
  104. package/dist/components/input-otp.js +0 -2
  105. package/dist/components/input-otp.js.map +0 -1
  106. package/dist/components/key-value-card.js +0 -2
  107. package/dist/components/key-value-card.js.map +0 -1
  108. package/dist/utilities/form-utils.js +0 -2
  109. package/dist/utilities/form-utils.js.map +0 -1
  110. package/dist/utilities/primitives.d.ts +0 -37
  111. package/dist/utilities/primitives.js +0 -2
  112. package/dist/utilities/primitives.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cryptlex/web-components",
3
- "version": "6.6.2",
3
+ "version": "6.6.6-alpha01",
4
4
  "description": "React component library for Cryptlex web applications",
5
5
  "author": "Cryptlex",
6
6
  "type": "module",
@@ -51,37 +51,42 @@
51
51
  "@tanstack/react-form": "1.6.3",
52
52
  "@tanstack/react-query": "5.62.3",
53
53
  "@tanstack/react-table": "8.20.5",
54
+ "@types/lodash-es": "4.17.12",
54
55
  "@uidotdev/usehooks": "2.4.1",
55
56
  "class-variance-authority": "0.7.1",
56
57
  "clsx": "2.1.1",
57
58
  "date-fns": "3.0.0",
58
- "input-otp": "1.4.1",
59
59
  "lodash-es": "4.17.21",
60
- "@types/lodash-es": "4.17.12",
61
60
  "openapi-fetch": "0.14.0",
62
61
  "react": "^19.1.0",
63
62
  "react-aria-components": "1.11.0",
64
63
  "react-dom": "^19.1.0",
65
64
  "recharts": "2.15.3",
66
65
  "sonner": "1.7.0",
67
- "tailwindcss": "^4.0.6",
66
+ "tailwindcss": "4.1.12",
68
67
  "tw-animate-css": "1.3.0",
69
- "tw-type-css": "0.0.1"
68
+ "tw-type-css": "0.0.1",
69
+ "zod": "4.1.1"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@rollup/plugin-node-resolve": "16.0.1",
73
+ "@storybook/addon-a11y": "9.1.3",
73
74
  "@storybook/addon-docs": "9.1.3",
74
75
  "@storybook/addon-links": "9.1.3",
75
76
  "@storybook/addon-onboarding": "9.1.3",
77
+ "@storybook/addon-vitest": "9.1.3",
76
78
  "@storybook/react-vite": "9.1.3",
77
- "@tailwindcss/vite": "^4.1.11",
79
+ "@tailwindcss/vite": "4.1.12",
78
80
  "@types/node": "^22.7.8",
79
81
  "@types/react": "^19.1.0",
80
82
  "@types/react-dom": "^19.1.0",
81
- "@vitejs/plugin-react": "4.7.0",
83
+ "@vitejs/plugin-react": "5.0.1",
84
+ "@vitest/browser": "^3.2.4",
85
+ "@vitest/coverage-v8": "^3.2.4",
82
86
  "husky": "^9.1.7",
83
87
  "lint-staged": "^16.1.4",
84
88
  "lucide-react": "0.453.0",
89
+ "playwright": "^1.55.0",
85
90
  "prettier": "3.6.2",
86
91
  "rollup-preserve-directives": "1.1.3",
87
92
  "sass": "1.80.6",
@@ -91,13 +96,14 @@
91
96
  "vite": "7.0.6",
92
97
  "vite-plugin-dts": "4.5.4",
93
98
  "vite-tsconfig-paths": "5.1.4",
94
- "zod": "3.25.20"
99
+ "vitest": "^3.2.4"
95
100
  },
96
101
  "scripts": {
97
102
  "build": "tsc && vite build",
98
103
  "lint": "eslint .",
99
104
  "storybook": "storybook dev -p 6006 --no-open",
100
105
  "build:storybook": "storybook build",
101
- "build:tokens": "sass --no-source-map ./lib/tokens.scss ./lib/tokens.css"
106
+ "build:tokens": "sass --no-source-map ./lib/tokens.scss ./lib/tokens.css",
107
+ "test": "vitest --project=storybook"
102
108
  }
103
109
  }
@@ -1,13 +0,0 @@
1
- import { components, operations, paths } from '@cryptlex/web-api-types';
2
- import { default as createClient } from 'openapi-fetch';
3
- export type _CtxClient = ReturnType<typeof createClient<paths>>;
4
- export type ApiSchema<T extends keyof components['schemas']> = components['schemas'][T];
5
- export type ApiQuery<T extends keyof operations> = NonNullable<operations[T]['parameters']['query']>;
6
- export type ApiGetAllParameters = {
7
- page: number;
8
- limit: number;
9
- search?: string;
10
- sort?: string;
11
- };
12
- export type ApiFilter<T extends keyof operations> = Omit<ApiQuery<T>, 'page' | 'limit' | 'sort' | 'search'>;
13
- export type ApiFilters<T extends keyof operations> = NonNullable<Omit<ApiQuery<T>, 'page' | 'limit' | 'sort' | 'search'>>;
@@ -1,2 +0,0 @@
1
-
2
- //# sourceMappingURL=data-table-commons.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"data-table-commons.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,7 +0,0 @@
1
- import { OTPInput } from 'input-otp';
2
- export declare function InputOTP({ className, containerClassName, ...props }: React.ComponentProps<typeof OTPInput>): import("react/jsx-runtime").JSX.Element;
3
- export declare function InputOTPGroup({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
4
- export declare function InputOTPSlot({ index, className, ...props }: React.ComponentProps<'div'> & {
5
- index: number;
6
- }): import("react/jsx-runtime").JSX.Element;
7
- export declare function InputOTPSeparator({ ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +0,0 @@
1
- import{jsx as t,jsxs as l}from"react/jsx-runtime";import{OTPInput as m,OTPInputContext as u}from"input-otp";import{use as p}from"react";import{classNames as n}from"../utilities/primitives.js";import{IcMinus as d}from"./icons.js";import"clsx";import"lodash-es";function O({className:e,containerClassName:r,...i}){return t(m,{containerClassName:n("flex items-center gap-2 has-disabled:opacity-50",r),className:n("disabled:cursor-not-allowed",e),...i})}function P({className:e,...r}){return t("div",{className:n("flex items-center",e),...r})}function T({index:e,className:r,...i}){const o=p(u),{char:s,hasFakeCaret:a,isActive:c}=o.slots[e];return l("div",{className:n("relative flex h-input w-9 items-center justify-center border-2 border-input body-sm transition-all",c?"z-10 border-2 border-primary":"",r),...i,children:[s,a&&t("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center",children:t("div",{className:"h-icon w-px animate-caret-blink bg-foreground duration-1000"})})]})}function y({...e}){return t("div",{role:"separator",...e,children:t(d,{})})}export{O as InputOTP,P as InputOTPGroup,y as InputOTPSeparator,T as InputOTPSlot};
2
- //# sourceMappingURL=input-otp.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"input-otp.js","sources":["../../lib/components/input-otp.tsx"],"sourcesContent":["import { OTPInput, OTPInputContext } from 'input-otp';\nimport { use } from 'react';\nimport { classNames } from '../utilities/primitives';\nimport { IcMinus } from './icons';\n\nexport function InputOTP({ className, containerClassName, ...props }: React.ComponentProps<typeof OTPInput>) {\n return (\n <OTPInput\n containerClassName={classNames('flex items-center gap-2 has-disabled:opacity-50', containerClassName)}\n className={classNames('disabled:cursor-not-allowed', className)}\n {...props}\n />\n );\n}\n\nexport function InputOTPGroup({ className, ...props }: React.ComponentProps<'div'>) {\n return <div className={classNames('flex items-center', className)} {...props} />;\n}\n\nexport function InputOTPSlot({ index, className, ...props }: React.ComponentProps<'div'> & { index: number }) {\n const inputOTPContext = use(OTPInputContext);\n const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index];\n\n return (\n <div\n className={classNames(\n 'relative flex h-input w-9 items-center justify-center border-2 border-input body-sm transition-all',\n isActive ? 'z-10 border-2 border-primary' : '',\n className\n )}\n {...props}\n >\n {char}\n {hasFakeCaret && (\n <div className=\"pointer-events-none absolute inset-0 flex items-center justify-center\">\n <div className=\"h-icon w-px animate-caret-blink bg-foreground duration-1000\" />\n </div>\n )}\n </div>\n );\n}\n\nexport function InputOTPSeparator({ ...props }: React.ComponentProps<'div'>) {\n return (\n <div role=\"separator\" {...props}>\n <IcMinus />\n </div>\n );\n}\n"],"names":["InputOTP","className","containerClassName","props","jsx","OTPInput","classNames","InputOTPGroup","InputOTPSlot","index","inputOTPContext","use","OTPInputContext","char","hasFakeCaret","isActive","jsxs","InputOTPSeparator","IcMinus"],"mappings":"oQAKO,SAASA,EAAS,CAAE,UAAAC,EAAW,mBAAAC,EAAoB,GAAGC,GAAgD,CACzG,OACIC,EAACC,EAAA,CACG,mBAAoBC,EAAW,kDAAmDJ,CAAkB,EACpG,UAAWI,EAAW,8BAA+BL,CAAS,EAC7D,GAAGE,CAAA,CAAA,CAGhB,CAEO,SAASI,EAAc,CAAE,UAAAN,EAAW,GAAGE,GAAsC,CAChF,OAAOC,EAAC,OAAI,UAAWE,EAAW,oBAAqBL,CAAS,EAAI,GAAGE,EAAO,CAClF,CAEO,SAASK,EAAa,CAAE,MAAAC,EAAO,UAAAR,EAAW,GAAGE,GAA0D,CAC1G,MAAMO,EAAkBC,EAAIC,CAAe,EACrC,CAAE,KAAAC,EAAM,aAAAC,EAAc,SAAAC,GAAaL,EAAgB,MAAMD,CAAK,EAEpE,OACIO,EAAC,MAAA,CACG,UAAWV,EACP,qGACAS,EAAW,gCAAkC,GAC7Cd,CAAA,EAEH,GAAGE,EAEH,SAAA,CAAAU,EACAC,KACI,MAAA,CAAI,UAAU,wEACX,SAAAV,EAAC,MAAA,CAAI,UAAU,6DAAA,CAA8D,CAAA,CACjF,CAAA,CAAA,CAAA,CAIhB,CAEO,SAASa,EAAkB,CAAE,GAAGd,GAAsC,CACzE,OACIC,EAAC,OAAI,KAAK,YAAa,GAAGD,EACtB,SAAAC,EAACc,IAAQ,CAAA,CACb,CAER"}
@@ -1,2 +0,0 @@
1
- import{jsxs as c,jsx as e}from"react/jsx-runtime";import{Badge as d}from"./badge.js";import{Card as p,CardHeader as m,CardTitle as f,CardContent as h}from"./card.js";import{Skeleton as u}from"./skeleton.js";import{formatDate as x}from"../utilities/date.js";import"../utilities/primitives.js";import"clsx";import"lodash-es";const S=({data:n,label:o,fields:l})=>{const i=(a,r)=>{if(a.transform)return a.transform(r);if(r==null)return"-";switch(a.type){case"date":return e("span",{children:x(r)});case"yesno":return e("span",{children:r?"Yes":"No"});case"badge":return e("div",{className:"flex flex-wrap gap-1",children:Array.isArray(r)?r.map((t,s)=>e(d,{children:typeof t=="object"?t?.name||t?.id:t},s)):r});case"boolean":return e("span",{children:r.toString()});default:return e("span",{children:r})}};return c(p,{children:[e(m,{children:e(f,{children:o})}),e(h,{children:e("div",{className:"flex flex-col gap-2",children:n?l.map(a=>{const r=a.accessor?a.accessor.split(".").reduce((t,s)=>t&&s in t?t[s]:void 0,n):null;return c("div",{className:"flex w-full flex-col md:flex-row justify-between first:pt-0 last:pb-0",children:[e("p",{className:"body flex w-full justify-start col-span-1",children:a.display}),e("div",{className:"body flex w-full justify-start text-wrap break-all",children:i(a,r)})]},a.display)}):l.map((a,r)=>e(u,{className:"h-12 w-full"},r))})})]})};export{S as KeyValueCard};
2
- //# sourceMappingURL=key-value-card.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"key-value-card.js","sources":["../../lib/components/key-value-card.tsx"],"sourcesContent":["import { Badge } from '../components/badge';\nimport { Card, CardContent, CardHeader, CardTitle } from '../components/card';\nimport { Skeleton } from '../components/skeleton';\nimport { formatDate } from '../utilities/date';\n\n// Utility type to handle nested keys (dot notation) in any object\ntype NestedKeyOf<T> = T extends object\n ? {\n [K in keyof T]: K extends string | number ? `${K & string}` | `${K & string}.${NestedKeyOf<T[K]>}` : never;\n }[keyof T]\n : never;\n\n// DisplayField type that works with nested keys\nexport type DisplayField<T> = {\n display: string;\n accessor: NestedKeyOf<T>;\n type?: 'text' | 'badge' | 'boolean' | 'date' | 'yesno' | 'copyButton' | 'link'; // Field types\n transform?: (value: any) => React.ReactNode;\n};\n\nexport interface KeyValueCardProps<T> {\n data: T; // Ensure data is of type T\n label: string;\n fields: DisplayField<T>[];\n className?: string;\n}\n\nexport const KeyValueCard = <T extends {}>({ data, label, fields }: KeyValueCardProps<T>) => {\n const renderValue = (field: DisplayField<T>, value: any) => {\n if (field.transform) {\n return field.transform(value);\n }\n if (value === undefined || value === null) {\n return '-';\n }\n switch (field.type) {\n case 'date':\n return <span>{formatDate(value)}</span>;\n case 'yesno':\n return <span>{value ? 'Yes' : 'No'}</span>;\n case 'badge':\n return (\n <div className=\"flex flex-wrap gap-1\">\n {Array.isArray(value)\n ? value.map((item, index) => (\n <Badge key={index}>{typeof item === 'object' ? item?.name || item?.id : item}</Badge>\n ))\n : value}\n </div>\n );\n\n case 'boolean':\n return <span>{value.toString()}</span>;\n default:\n return <span>{value}</span>;\n }\n };\n\n return (\n <Card>\n <CardHeader>\n <CardTitle>{label}</CardTitle>\n </CardHeader>\n <CardContent>\n <div className=\"flex flex-col gap-2\">\n {data\n ? fields.map(field => {\n // TODO: improve this\n const value = field.accessor\n ? field.accessor\n .split('.')\n .reduce(\n (obj, key) => (obj && key in obj ? obj[key] : undefined),\n data as Record<string, any>\n )\n : null;\n\n return (\n <div\n key={field.display}\n className=\"flex w-full flex-col md:flex-row justify-between first:pt-0 last:pb-0\"\n >\n <p className=\"body flex w-full justify-start col-span-1\">{field.display}</p>\n <div className=\"body flex w-full justify-start text-wrap break-all\">\n {renderValue(field, value)}\n </div>\n </div>\n );\n })\n : fields.map((_, index) => <Skeleton key={index} className=\"h-12 w-full\" />)}\n </div>\n </CardContent>\n </Card>\n );\n};\n"],"names":["KeyValueCard","data","label","fields","renderValue","field","value","jsx","formatDate","item","index","Badge","Card","CardHeader","CardTitle","CardContent","obj","key","jsxs","_","Skeleton"],"mappings":"mUA2BO,MAAMA,EAAe,CAAe,CAAE,KAAAC,EAAM,MAAAC,EAAO,OAAAC,KAAmC,CACzF,MAAMC,EAAc,CAACC,EAAwBC,IAAe,CACxD,GAAID,EAAM,UACN,OAAOA,EAAM,UAAUC,CAAK,EAEhC,GAA2BA,GAAU,KACjC,MAAO,IAEX,OAAQD,EAAM,KAAA,CACV,IAAK,OACD,OAAOE,EAAC,OAAA,CAAM,SAAAC,EAAWF,CAAK,EAAE,EACpC,IAAK,QACD,OAAOC,EAAC,OAAA,CAAM,SAAAD,EAAQ,MAAQ,KAAK,EACvC,IAAK,QACD,OACIC,EAAC,MAAA,CAAI,UAAU,uBACV,SAAA,MAAM,QAAQD,CAAK,EACdA,EAAM,IAAI,CAACG,EAAMC,MACZC,EAAA,CAAmB,SAAA,OAAOF,GAAS,SAAWA,GAAM,MAAQA,GAAM,GAAKA,CAAA,EAA5DC,CAAiE,CAChF,EACDJ,CAAA,CACV,EAGR,IAAK,UACD,OAAOC,EAAC,OAAA,CAAM,SAAAD,EAAM,SAAA,EAAW,EACnC,QACI,OAAOC,EAAC,QAAM,SAAAD,CAAA,CAAM,CAAA,CAEhC,EAEA,SACKM,EAAA,CACG,SAAA,CAAAL,EAACM,EAAA,CACG,SAAAN,EAACO,EAAA,CAAW,SAAAZ,CAAA,CAAM,EACtB,EACAK,EAACQ,GACG,SAAAR,EAAC,MAAA,CAAI,UAAU,sBACV,SAAAN,EACKE,EAAO,IAAIE,GAAS,CAEhB,MAAMC,EAAQD,EAAM,SACdA,EAAM,SACD,MAAM,GAAG,EACT,OACG,CAACW,EAAKC,IAASD,GAAOC,KAAOD,EAAMA,EAAIC,CAAG,EAAI,OAC9ChB,CAAA,EAER,KAEN,OACIiB,EAAC,MAAA,CAEG,UAAU,wEAEV,SAAA,CAAAX,EAAC,IAAA,CAAE,UAAU,4CAA6C,SAAAF,EAAM,QAAQ,IACvE,MAAA,CAAI,UAAU,qDACV,SAAAD,EAAYC,EAAOC,CAAK,CAAA,CAC7B,CAAA,CAAA,EANKD,EAAM,OAAA,CASvB,CAAC,EACDF,EAAO,IAAI,CAACgB,EAAGT,IAAUH,EAACa,EAAA,CAAqB,UAAU,aAAA,EAAjBV,CAA+B,CAAE,EACnF,CAAA,CACJ,CAAA,EACJ,CAER"}
@@ -1,2 +0,0 @@
1
- import o from"react";import{useFieldContext as i}from"./form-context.js";import"@tanstack/react-form";const l=({disabled:e})=>{const t=i();return o.useEffect(()=>{t.setMeta(n=>({...n,disabled:!!e}))},[e,t]),t};function d(e){return async({formApi:t})=>{const n=c(t.state.values,t);await e({values:n,formApi:t})}}function c(e,t){const n={};for(const s in e)t.getFieldMeta(s)?.disabled||(n[s]=e[s]);return n}export{d as tfOnSubmit,l as useTfFieldContext};
2
- //# sourceMappingURL=form-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"form-utils.js","sources":["../../lib/utilities/form-utils.tsx"],"sourcesContent":["import { type AnyFieldMeta, type FormApi } from '@tanstack/react-form';\nimport React from 'react';\nimport { useFieldContext } from './form-context';\n\ntype FieldContextProps = {\n disabled?: boolean;\n};\n\n/**\n * Custom hook to handle disabled state for form fields\n * @param {boolean} disabled - The disabled prop passed to the component\n * @returns The field context with disabled state properly managed\n */\nexport const useTfFieldContext = <T,>({ disabled }: FieldContextProps) => {\n const field = useFieldContext<T>();\n\n React.useEffect(() => {\n field.setMeta(meta => ({\n ...meta,\n disabled: !!disabled,\n }));\n }, [disabled, field]);\n\n return field;\n};\n\n/** Utility type to simplify FormApi usage */\nexport type AppFormApi<TValues> = FormApi<TValues, any, any, any, any, any, any, any, any, any>;\n\n/**\n * Utility function to submit a form with a handler that receives the values and the formApi.\n * @param onSubmit - The handler function to call with the values and the formApi.\n * @returns A function that can be used to submit the form. It will filter out disabled fields from the values.\n */\nexport function tfOnSubmit<TValues>(\n onSubmit: ({ values, formApi }: { values: TValues; formApi: AppFormApi<TValues> }) => Promise<any> | any\n) {\n return async ({ formApi }: { formApi: AppFormApi<TValues> }): Promise<any> => {\n const values = pickEnabledFields(formApi.state.values, formApi);\n\n await onSubmit({ values, formApi });\n };\n}\nfunction pickEnabledFields<TValues>(rawValues: TValues, formApi: AppFormApi<TValues>): TValues {\n const result: TValues = {} as TValues;\n\n //TODO: Nested objects are not supported yet\n for (const key in rawValues) {\n const meta = formApi.getFieldMeta(key) as AnyFieldMeta & {\n disabled?: boolean;\n };\n if (!meta?.disabled) {\n result[key] = rawValues[key];\n }\n }\n\n return result;\n}\n"],"names":["useTfFieldContext","disabled","field","useFieldContext","React","meta","tfOnSubmit","onSubmit","formApi","values","pickEnabledFields","rawValues","result","key"],"mappings":"sGAaO,MAAMA,EAAoB,CAAK,CAAE,SAAAC,KAAkC,CACtE,MAAMC,EAAQC,EAAA,EAEd,OAAAC,EAAM,UAAU,IAAM,CAClBF,EAAM,QAAQG,IAAS,CACnB,GAAGA,EACH,SAAU,CAAC,CAACJ,CAAA,EACd,CACN,EAAG,CAACA,EAAUC,CAAK,CAAC,EAEbA,CACX,EAUO,SAASI,EACZC,EACF,CACE,MAAO,OAAO,CAAE,QAAAC,KAA8D,CAC1E,MAAMC,EAASC,EAAkBF,EAAQ,MAAM,OAAQA,CAAO,EAE9D,MAAMD,EAAS,CAAE,OAAAE,EAAQ,QAAAD,EAAS,CACtC,CACJ,CACA,SAASE,EAA2BC,EAAoBH,EAAuC,CAC3F,MAAMI,EAAkB,CAAA,EAGxB,UAAWC,KAAOF,EACDH,EAAQ,aAAaK,CAAG,GAG1B,WACPD,EAAOC,CAAG,EAAIF,EAAUE,CAAG,GAInC,OAAOD,CACX"}
@@ -1,37 +0,0 @@
1
- import { FieldApi } from '@tanstack/react-form';
2
- import { ClassValue } from 'clsx';
3
- /** Classnames */
4
- export declare function classNames(...inputs: ClassValue[]): string;
5
- /**
6
- *
7
- * @returns
8
- */
9
- export declare function getThemeHue(): string;
10
- /**
11
- * @param hue the hue value to set in the document style
12
- */
13
- export declare function setThemeHue(hue: number): void;
14
- export declare function logout(): void;
15
- export type JwtDecode = {
16
- aud: string;
17
- email: string;
18
- exp: number;
19
- iat: number;
20
- jti: string;
21
- region: string;
22
- role: string;
23
- role_type: string;
24
- scope: string[];
25
- sub: string;
26
- teat: number;
27
- tenantid: string;
28
- token_usage: string;
29
- sadmin?: string;
30
- };
31
- export type CtxPortals = 'customer-portal' | 'system-portal' | 'reseller-portal' | 'admin-portal';
32
- /**
33
- *
34
- */
35
- export declare function toTitleCase(input?: string): string;
36
- export declare function pluralizeTimes(resourceName: string, count: number): string;
37
- export declare function getFieldErrorMessage(field: FieldApi<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any>): string;
@@ -1,2 +0,0 @@
1
- import{clsx as n}from"clsx";import{startCase as r}from"lodash-es";function c(...e){return n(e)}const o="--primary-hue";function s(){return document.documentElement.style.getPropertyValue(o)}function m(e){document.documentElement.style.setProperty(o,e)}const i="AT",a="RT";function f(){if(typeof window<"u"&&window.localStorage)try{localStorage.removeItem(a),localStorage.removeItem(i),window.location.replace("/auth/login")}catch(e){console.error("Logout failed:",e)}}function d(e){return r(e)}function g(e,t){return t>1?/y$/.test(e)?e==="Day"?"Days":e.replace(/y$/,"ies"):e.concat("s"):e}function p(e){return e?.state.meta.errors.map(t=>t?.message).join(",")}export{c as classNames,p as getFieldErrorMessage,s as getThemeHue,f as logout,g as pluralizeTimes,m as setThemeHue,d as toTitleCase};
2
- //# sourceMappingURL=primitives.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"primitives.js","sources":["../../lib/utilities/primitives.ts"],"sourcesContent":["import type { FieldApi } from '@tanstack/react-form';\nimport { clsx, type ClassValue } from 'clsx';\nimport { startCase } from 'lodash-es';\n\n/** Classnames */\nexport function classNames(...inputs: ClassValue[]) {\n return clsx(inputs);\n}\n\n/**\n * This is the variable name representing the primary hue.\n * Referenced in tokens.scss -> token.css\n */\nconst PRIMARY_HUE_PROPERTY = '--primary-hue';\n\n/**\n *\n * @returns\n */\nexport function getThemeHue() {\n return document.documentElement.style.getPropertyValue(PRIMARY_HUE_PROPERTY);\n}\n\n/**\n * @param hue the hue value to set in the document style\n */\nexport function setThemeHue(hue: number) {\n document.documentElement.style.setProperty(\n PRIMARY_HUE_PROPERTY,\n // In this case, it must be a number.\n hue as unknown as string\n );\n}\n\nconst ACCESS_TOKEN = 'AT';\nconst REFRESH_TOKEN = 'RT';\nexport function logout() {\n if (typeof window !== 'undefined' && window.localStorage) {\n try {\n localStorage.removeItem(REFRESH_TOKEN);\n localStorage.removeItem(ACCESS_TOKEN);\n window.location.replace('/auth/login');\n } catch (error) {\n console.error('Logout failed:', error);\n }\n }\n}\n\nexport type JwtDecode = {\n aud: string;\n email: string;\n exp: number;\n iat: number;\n jti: string;\n region: string;\n role: string;\n role_type: string;\n scope: string[];\n sub: string;\n teat: number;\n tenantid: string;\n token_usage: string;\n sadmin?: string;\n};\n\nexport type CtxPortals = 'customer-portal' | 'system-portal' | 'reseller-portal' | 'admin-portal';\n\n/**\n *\n */\nexport function toTitleCase(input?: string): string {\n return startCase(input);\n}\n\nexport function pluralizeTimes(resourceName: string, count: number) {\n if (count > 1) {\n if (/y$/.test(resourceName)) {\n if (resourceName === 'Day') return 'Days';\n return resourceName.replace(/y$/, 'ies');\n }\n return resourceName.concat('s');\n }\n return resourceName;\n}\n\nexport function getFieldErrorMessage(\n field: FieldApi<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any>\n): string {\n return field?.state.meta.errors.map(e => e?.message).join(',');\n}\n"],"names":["classNames","inputs","clsx","PRIMARY_HUE_PROPERTY","getThemeHue","setThemeHue","hue","ACCESS_TOKEN","REFRESH_TOKEN","logout","error","toTitleCase","input","startCase","pluralizeTimes","resourceName","count","getFieldErrorMessage","field","e"],"mappings":"kEAKO,SAASA,KAAcC,EAAsB,CAChD,OAAOC,EAAKD,CAAM,CACtB,CAMA,MAAME,EAAuB,gBAMtB,SAASC,GAAc,CAC1B,OAAO,SAAS,gBAAgB,MAAM,iBAAiBD,CAAoB,CAC/E,CAKO,SAASE,EAAYC,EAAa,CACrC,SAAS,gBAAgB,MAAM,YAC3BH,EAEAG,CAAA,CAER,CAEA,MAAMC,EAAe,KACfC,EAAgB,KACf,SAASC,GAAS,CACrB,GAAI,OAAO,OAAW,KAAe,OAAO,aACxC,GAAI,CACA,aAAa,WAAWD,CAAa,EACrC,aAAa,WAAWD,CAAY,EACpC,OAAO,SAAS,QAAQ,aAAa,CACzC,OAASG,EAAO,CACZ,QAAQ,MAAM,iBAAkBA,CAAK,CACzC,CAER,CAwBO,SAASC,EAAYC,EAAwB,CAChD,OAAOC,EAAUD,CAAK,CAC1B,CAEO,SAASE,EAAeC,EAAsBC,EAAe,CAChE,OAAIA,EAAQ,EACJ,KAAK,KAAKD,CAAY,EAClBA,IAAiB,MAAc,OAC5BA,EAAa,QAAQ,KAAM,KAAK,EAEpCA,EAAa,OAAO,GAAG,EAE3BA,CACX,CAEO,SAASE,EACZC,EACM,CACN,OAAOA,GAAO,MAAM,KAAK,OAAO,OAASC,GAAG,OAAO,EAAE,KAAK,GAAG,CACjE"}