@cryptlex/web-components 5.2.0 → 5.3.0-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 (166) hide show
  1. package/dist/components/data-table/data-table-filter.d.ts +27 -0
  2. package/dist/components/data-table/data-table-filter.js +2 -0
  3. package/dist/components/data-table/data-table-filter.js.map +1 -0
  4. package/dist/components/data-table/data-table.d.ts +72 -0
  5. package/dist/components/data-table/data-table.js +2 -0
  6. package/dist/components/data-table/data-table.js.map +1 -0
  7. package/dist/components/data-table/table-commons.d.ts +56 -0
  8. package/dist/components/data-table/table-commons.js +2 -0
  9. package/dist/components/data-table/table-commons.js.map +1 -0
  10. package/dist/components/inputs/checkbox.d.ts +8 -0
  11. package/dist/components/inputs/checkbox.js +2 -0
  12. package/dist/components/inputs/checkbox.js.map +1 -0
  13. package/dist/components/inputs/date-picker.d.ts +11 -0
  14. package/dist/components/inputs/date-picker.js +2 -0
  15. package/dist/components/inputs/date-picker.js.map +1 -0
  16. package/dist/components/inputs/datefield.d.ts +14 -0
  17. package/dist/components/inputs/datefield.js +2 -0
  18. package/dist/components/inputs/datefield.js.map +1 -0
  19. package/dist/components/inputs/field.d.ts +20 -0
  20. package/dist/components/inputs/field.js +2 -0
  21. package/dist/components/inputs/field.js.map +1 -0
  22. package/dist/components/inputs/id-search.d.ts +20 -0
  23. package/dist/components/inputs/id-search.js +2 -0
  24. package/dist/components/inputs/id-search.js.map +1 -0
  25. package/dist/components/inputs/input-otp.d.ts +7 -0
  26. package/dist/components/inputs/input-otp.js +2 -0
  27. package/dist/components/inputs/input-otp.js.map +1 -0
  28. package/dist/components/inputs/multi-select.d.ts +16 -0
  29. package/dist/components/inputs/multi-select.js +2 -0
  30. package/dist/components/inputs/multi-select.js.map +1 -0
  31. package/dist/components/inputs/numberfield.d.ts +6 -0
  32. package/dist/components/inputs/numberfield.js +2 -0
  33. package/dist/components/inputs/numberfield.js.map +1 -0
  34. package/dist/components/inputs/searchfield.d.ts +5 -0
  35. package/dist/components/inputs/searchfield.js +2 -0
  36. package/dist/components/inputs/searchfield.js.map +1 -0
  37. package/dist/components/inputs/select-options.d.ts +8 -0
  38. package/dist/components/inputs/select-options.js +2 -0
  39. package/dist/components/inputs/select-options.js.map +1 -0
  40. package/dist/components/inputs/select.d.ts +17 -0
  41. package/dist/components/inputs/select.js +2 -0
  42. package/dist/components/inputs/select.js.map +1 -0
  43. package/dist/components/inputs/textfield.d.ts +7 -0
  44. package/dist/components/inputs/textfield.js +2 -0
  45. package/dist/components/inputs/textfield.js.map +1 -0
  46. package/dist/components/key-value-card/key-value-card.d.ts +17 -0
  47. package/dist/components/key-value-card/key-value-card.js +2 -0
  48. package/dist/components/key-value-card/key-value-card.js.map +1 -0
  49. package/dist/components/ui/alert.d.ts +8 -0
  50. package/dist/components/ui/alert.js +2 -0
  51. package/dist/components/ui/alert.js.map +1 -0
  52. package/dist/components/ui/avatar.d.ts +7 -0
  53. package/dist/components/ui/avatar.js +2 -0
  54. package/dist/components/ui/avatar.js.map +1 -0
  55. package/dist/components/ui/badge.d.ts +1 -0
  56. package/dist/components/ui/badge.js +2 -0
  57. package/dist/components/ui/badge.js.map +1 -0
  58. package/dist/components/ui/breadcrumbs.d.ts +10 -0
  59. package/dist/components/ui/breadcrumbs.js +2 -0
  60. package/dist/components/ui/breadcrumbs.js.map +1 -0
  61. package/dist/components/ui/button.d.ts +11 -0
  62. package/dist/components/ui/button.js +2 -0
  63. package/dist/components/ui/button.js.map +1 -0
  64. package/dist/components/ui/calendar.d.ts +16 -0
  65. package/dist/components/ui/calendar.js +2 -0
  66. package/dist/components/ui/calendar.js.map +1 -0
  67. package/dist/components/ui/card.d.ts +7 -0
  68. package/dist/components/ui/card.js +2 -0
  69. package/dist/components/ui/card.js.map +1 -0
  70. package/dist/components/ui/dialog.d.ts +18 -0
  71. package/dist/components/ui/dialog.js +2 -0
  72. package/dist/components/ui/dialog.js.map +1 -0
  73. package/dist/components/ui/disclosure.d.ts +18 -0
  74. package/dist/components/ui/disclosure.js +2 -0
  75. package/dist/components/ui/disclosure.js.map +1 -0
  76. package/dist/components/ui/list-box.d.ts +5 -0
  77. package/dist/components/ui/list-box.js +2 -0
  78. package/dist/components/ui/list-box.js.map +1 -0
  79. package/dist/components/ui/loader.d.ts +5 -0
  80. package/dist/components/ui/loader.js +2 -0
  81. package/dist/components/ui/loader.js.map +1 -0
  82. package/dist/components/ui/menu.d.ts +24 -0
  83. package/dist/components/ui/menu.js +2 -0
  84. package/dist/components/ui/menu.js.map +1 -0
  85. package/dist/components/ui/popover.d.ts +4 -0
  86. package/dist/components/ui/popover.js +2 -0
  87. package/dist/components/ui/popover.js.map +1 -0
  88. package/dist/components/ui/sidebar.d.ts +52 -0
  89. package/dist/components/ui/sidebar.js +2 -0
  90. package/dist/components/ui/sidebar.js.map +1 -0
  91. package/dist/components/ui/skeleton.d.ts +1 -0
  92. package/dist/components/ui/skeleton.js +2 -0
  93. package/dist/components/ui/skeleton.js.map +1 -0
  94. package/dist/components/ui/sonner.d.ts +4 -0
  95. package/dist/components/ui/sonner.js +2 -0
  96. package/dist/components/ui/sonner.js.map +1 -0
  97. package/dist/components/ui/table.d.ts +8 -0
  98. package/dist/components/ui/table.js +2 -0
  99. package/dist/components/ui/table.js.map +1 -0
  100. package/dist/components/ui/tabs.d.ts +5 -0
  101. package/dist/components/ui/tabs.js +2 -0
  102. package/dist/components/ui/tabs.js.map +1 -0
  103. package/dist/components/ui/timeline.d.ts +15 -0
  104. package/dist/components/ui/timeline.js +2 -0
  105. package/dist/components/ui/timeline.js.map +1 -0
  106. package/dist/components/ui/tooltip.d.ts +4 -0
  107. package/dist/components/ui/tooltip.js +2 -0
  108. package/dist/components/ui/tooltip.js.map +1 -0
  109. package/dist/utils/form-context.d.ts +4 -0
  110. package/dist/utils/form-context.js +2 -0
  111. package/dist/utils/form-context.js.map +1 -0
  112. package/dist/utils/form-hook.d.ts +23 -0
  113. package/dist/utils/form-hook.js +2 -0
  114. package/dist/utils/form-hook.js.map +1 -0
  115. package/dist/utils/primitives.d.ts +44 -0
  116. package/dist/utils/primitives.js +2 -0
  117. package/dist/utils/primitives.js.map +1 -0
  118. package/dist/utils/resource-names.d.ts +11 -0
  119. package/dist/utils/resource-names.js +2 -0
  120. package/dist/utils/resource-names.js.map +1 -0
  121. package/dist/utils/use-mobile.d.ts +1 -0
  122. package/dist/utils/use-mobile.js +2 -0
  123. package/dist/utils/use-mobile.js.map +1 -0
  124. package/package.json +16 -8
  125. package/lib/components/data-table/data-table-filter.tsx +0 -220
  126. package/lib/components/data-table/data-table.tsx +0 -593
  127. package/lib/components/data-table/table-commons.tsx +0 -233
  128. package/lib/components/inputs/checkbox.tsx +0 -72
  129. package/lib/components/inputs/date-picker.tsx +0 -130
  130. package/lib/components/inputs/datefield.tsx +0 -109
  131. package/lib/components/inputs/field.tsx +0 -106
  132. package/lib/components/inputs/id-search.tsx +0 -83
  133. package/lib/components/inputs/input-otp.tsx +0 -63
  134. package/lib/components/inputs/multi-select.tsx +0 -62
  135. package/lib/components/inputs/numberfield.tsx +0 -110
  136. package/lib/components/inputs/searchfield.tsx +0 -87
  137. package/lib/components/inputs/select-options.tsx +0 -303
  138. package/lib/components/inputs/select.tsx +0 -140
  139. package/lib/components/inputs/textfield.tsx +0 -96
  140. package/lib/components/key-value-card/key-value-card.tsx +0 -115
  141. package/lib/components/ui/alert.tsx +0 -32
  142. package/lib/components/ui/avatar.tsx +0 -22
  143. package/lib/components/ui/badge.tsx +0 -19
  144. package/lib/components/ui/breadcrumbs.tsx +0 -104
  145. package/lib/components/ui/button.tsx +0 -66
  146. package/lib/components/ui/calendar.tsx +0 -220
  147. package/lib/components/ui/card.tsx +0 -58
  148. package/lib/components/ui/dialog.tsx +0 -172
  149. package/lib/components/ui/disclosure.tsx +0 -113
  150. package/lib/components/ui/list-box.tsx +0 -86
  151. package/lib/components/ui/loader.tsx +0 -10
  152. package/lib/components/ui/menu.tsx +0 -168
  153. package/lib/components/ui/popover.tsx +0 -37
  154. package/lib/components/ui/sidebar.tsx +0 -552
  155. package/lib/components/ui/skeleton.tsx +0 -7
  156. package/lib/components/ui/sonner.tsx +0 -26
  157. package/lib/components/ui/table.tsx +0 -79
  158. package/lib/components/ui/tabs.tsx +0 -82
  159. package/lib/components/ui/timeline.tsx +0 -52
  160. package/lib/components/ui/tooltip.tsx +0 -30
  161. package/lib/tokens.scss +0 -89
  162. package/lib/utils/form-context.tsx +0 -7
  163. package/lib/utils/form-hook.tsx +0 -33
  164. package/lib/utils/primitives.ts +0 -68
  165. package/lib/utils/resource-names.tsx +0 -245
  166. package/lib/utils/use-mobile.tsx +0 -21
@@ -1,82 +0,0 @@
1
- import {
2
- Tab as AriaTab,
3
- TabList as AriaTabList,
4
- TabListProps as AriaTabListProps,
5
- TabPanel as AriaTabPanel,
6
- TabPanelProps as AriaTabPanelProps,
7
- TabProps as AriaTabProps,
8
- Tabs as AriaTabs,
9
- TabsProps as AriaTabsProps,
10
- composeRenderProps,
11
- } from "react-aria-components"
12
-
13
- import { cn } from "lib/utils/primitives"
14
-
15
- export function Tabs({ className, ...props }: AriaTabsProps) {
16
- return (
17
- <AriaTabs
18
- className={composeRenderProps(className, (className) =>
19
- cn(
20
- "group flex flex-col gap-2",
21
- /* Orientation */
22
- "data-[orientation=vertical]:flex-row",
23
- className
24
- )
25
- )}
26
- {...props}
27
- />
28
- )
29
- }
30
-
31
- export function TabList<T extends object>({
32
- className,
33
- ...props
34
- }: AriaTabListProps<T>) {
35
- return (
36
- <AriaTabList
37
- className={composeRenderProps(className, (className) =>
38
- cn(
39
- "inline-flex items-center border-b text-muted-foreground",
40
- /* Orientation */
41
- "data-[orientation=vertical]:h-auto data-[orientation=vertical]:flex-col",
42
- className
43
- )
44
- )}
45
- {...props}
46
- />
47
- )
48
- }
49
-
50
- export function Tab({ className, ...props }: AriaTabProps) {
51
- return (
52
- <AriaTab
53
- className={composeRenderProps(className, (className) =>
54
- cn(
55
- "btn btn-ghost leading-none text-accent h-input truncate inline-flex items-center px-3 body font-medium transition-all",
56
- /* Selected */
57
- "data-[selected]:bg-primary/20 data-[selected]:text-primary",
58
- /* Orientation */
59
- "group-data-[orientation=vertical]:w-full",
60
- className
61
- )
62
- )}
63
- {...props}
64
- />
65
- )
66
- }
67
-
68
- export function TabPanel({ className, ...props }: AriaTabPanelProps) {
69
- return (
70
- <AriaTabPanel
71
- className={composeRenderProps(className, (className) =>
72
- cn(
73
- "ring-offset-background",
74
- /* Focus Visible */
75
- "focus-ring",
76
- className
77
- )
78
- )}
79
- {...props}
80
- />
81
- )
82
- }
@@ -1,52 +0,0 @@
1
- import { cva, type VariantProps } from "class-variance-authority";
2
- import { cn } from "lib/utils/primitives";
3
- import type { LucideIcon } from "lucide-react";
4
-
5
- export function Timeline({ className, ...props }: React.ComponentProps<'ol'>) {
6
- return <ol className={cn("grid grid-col-1 gap-icon", className)} {...props} />
7
- }
8
-
9
- export function TimelineItem({ className, ...props }: React.ComponentProps<'li'> & {}) {
10
- return (
11
- <li className={cn("grid grid-cols-[4rem_2rem_1fr] grid-rows-subgrid list-none gap-icon", className)} {...props} />
12
- )
13
- }
14
-
15
- export const timelineIconVariants = cva(
16
- `p-1 rounded-full`,
17
- {
18
- variants: {
19
- variant: {
20
- destructive: "text-destructive-foreground bg-destructive",
21
- success: "text-success-foreground bg-success",
22
- muted: "text-muted-foreground bg-muted",
23
- },
24
- },
25
- defaultVariants: {
26
- variant: "muted",
27
- },
28
- },
29
- );
30
-
31
- export function TimelineIcon({ icon: Icon, className, variant, ...props }: Omit<React.ComponentProps<'div'>, 'children'> & VariantProps<typeof timelineIconVariants> & {
32
- icon: LucideIcon
33
- }) {
34
- return <div {...props} className="flex flex-col items-center gap-2">
35
- <div className={cn(timelineIconVariants({ variant, className }))}>
36
- <Icon className="size-icon " />
37
- </div>
38
- <div className="h-full w-[1px]" />
39
- </div>
40
- }
41
-
42
- export function TimelineDate({ className, date, dateFormatter, ...props }: Omit<React.ComponentProps<'time'>, 'dateTime' | 'children'> & {
43
- date: Date
44
- dateFormatter?: (d: Date) => string;
45
- }) {
46
- const defaultDateDisplay = `${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getFullYear()}`;
47
- return <time {...props} dateTime={date.toISOString()} className={cn("font-mono leading-none text-muted", className)}>{dateFormatter ? dateFormatter(date) : defaultDateDisplay}</time>
48
- }
49
-
50
- export function TimelineContent({ className, ...props }: React.ComponentProps<'section'>) {
51
- return <section className={cn("", className)} {...props} />;
52
- }
@@ -1,30 +0,0 @@
1
- import {
2
- Tooltip as AriaTooltip,
3
- TooltipTrigger as AriaTooltipTrigger,
4
- composeRenderProps,
5
- type TooltipProps as AriaTooltipProps,
6
- } from "react-aria-components"
7
-
8
- import { cn } from "lib/utils/primitives"
9
-
10
- const TooltipTrigger = AriaTooltipTrigger
11
- const Tooltip = ({ className, offset = 4, ...props }: AriaTooltipProps) => (
12
- <AriaTooltip
13
- offset={offset}
14
- className={composeRenderProps(className, (className) =>
15
- cn(
16
- "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0",
17
- /* Entering */
18
- "data-[entering]:zoom-in-95",
19
- /* Exiting */
20
- "data-[exiting]:animate-out data-[exiting]:fade-out-0 data-[exiting]:zoom-out-95",
21
- /* Placement */
22
- "data-[placement=bottom]:slide-in-from-top-2 data-[placement=left]:slide-in-from-right-2 data-[placement=right]:slide-in-from-left-2 data-[placement=top]:slide-in-from-bottom-2",
23
- className
24
- )
25
- )}
26
- {...props}
27
- />
28
- )
29
-
30
- export { Tooltip, TooltipTrigger }
package/lib/tokens.scss DELETED
@@ -1,89 +0,0 @@
1
- /// This file is used to generate the tokens.css file in this project.
2
- /// Since a single variable is used to determine most swatches and the ramps formulae are repetitive, we use Sass to generate these tokens.
3
- @mixin generate-variables-for-hue($name, $value) {
4
- --#{$name}-hue: #{$value};
5
-
6
- --x#{$name}-1: oklch(0.99 0.01 var(--#{$name}-hue));
7
- --x#{$name}-2: oklch(0.97 0.03 var(--#{$name}-hue));
8
- --x#{$name}-3: oklch(0.9 0.04 var(--#{$name}-hue));
9
- --x#{$name}-4: oklch(0.72 0.13 var(--#{$name}-hue));
10
- --x#{$name}-5: oklch(0.67 0.13 var(--#{$name}-hue));
11
- --x#{$name}-6: oklch(0.5 0.13 var(--#{$name}-hue));
12
- --x#{$name}-7: oklch(0.35 0.13 var(--#{$name}-hue));
13
- --x#{$name}-8: oklch(0.25 0.13 var(--#{$name}-hue));
14
- --x#{$name}-9: oklch(0.2 0.09 var(--#{$name}-hue));
15
- --x#{$name}-10: oklch(0.1 0.03 var(--#{$name}-hue));
16
-
17
- --#{$name}-1: var(--x#{$name}-1);
18
- --#{$name}-2: var(--x#{$name}-2);
19
- --#{$name}-3: var(--x#{$name}-3);
20
- --#{$name}-4: var(--x#{$name}-4);
21
- --#{$name}-5: var(--x#{$name}-5);
22
- --#{$name}-6: var(--x#{$name}-6);
23
- --#{$name}-7: var(--x#{$name}-7);
24
- --#{$name}-8: var(--x#{$name}-8);
25
- --#{$name}-9: var(--x#{$name}-9);
26
- --#{$name}-10: var(--x#{$name}-10);
27
- }
28
-
29
- /// Generates CSS variables using OKLCH for a Neutral palette.
30
- @mixin generate-variables-for-neutral() {
31
- --neutral-hue: var(--primary-hue);
32
- --neutral-s: 0.0005;
33
-
34
- --xneutral-1: oklch(0.985 var(--neutral-s) var(--neutral-hue));
35
- --xneutral-2: oklch(0.97 var(--neutral-s) var(--neutral-hue));
36
- --xneutral-3: oklch(0.95 var(--neutral-s) var(--neutral-hue));
37
- --xneutral-4: oklch(0.87 var(--neutral-s) var(--neutral-hue));
38
- --xneutral-5: oklch(0.708 var(--neutral-s) var(--neutral-hue));
39
- --xneutral-6: oklch(0.556 var(--neutral-s) var(--neutral-hue));
40
- --xneutral-7: oklch(0.439 var(--neutral-s) var(--neutral-hue));
41
- --xneutral-8: oklch(0.29 var(--neutral-s) var(--neutral-hue));
42
- --xneutral-9: oklch(0.269 var(--neutral-s) var(--neutral-hue));
43
- --xneutral-10: oklch(0.205 var(--neutral-s) var(--neutral-hue));
44
-
45
- --neutral-1: var(--xneutral-1);
46
- --neutral-2: var(--xneutral-2);
47
- --neutral-3: var(--xneutral-3);
48
- --neutral-4: var(--xneutral-4);
49
- --neutral-5: var(--xneutral-5);
50
- --neutral-6: var(--xneutral-6);
51
- --neutral-7: var(--xneutral-7);
52
- --neutral-8: var(--xneutral-8);
53
- --neutral-9: var(--xneutral-9);
54
- --neutral-10: var(--xneutral-10);
55
- }
56
-
57
- /// Swap Swatch 1 & Swatch 10, Swatch 2 and Swatch 9, and so on.
58
- @mixin generate-dark-mode($name) {
59
- --#{$name}-1: var(--x#{$name}-10);
60
- --#{$name}-2: var(--x#{$name}-9);
61
- --#{$name}-3: var(--x#{$name}-8);
62
- --#{$name}-4: var(--x#{$name}-7);
63
- --#{$name}-5: var(--x#{$name}-6);
64
- --#{$name}-6: var(--x#{$name}-5);
65
- --#{$name}-7: var(--x#{$name}-4);
66
- --#{$name}-8: var(--x#{$name}-3);
67
- --#{$name}-9: var(--x#{$name}-2);
68
- --#{$name}-10: var(--x#{$name}-1);
69
- }
70
-
71
- /*!
72
- This CSS is generated by tokens.scss, do not modify directly.
73
- Instead, compile the SCSS file again to create modifications.
74
- */
75
- :root {
76
- @include generate-variables-for-hue(primary, 240);
77
- @include generate-variables-for-hue(secondary, calc(var(--primary-hue) + 30));
78
- @include generate-variables-for-hue(destructive, calc(var(--primary-hue) - 230));
79
- @include generate-variables-for-hue(success, calc(var(--primary-hue) - 90));
80
- @include generate-variables-for-neutral();
81
-
82
- @media (prefers-color-scheme: dark) {
83
- @include generate-dark-mode(primary);
84
- @include generate-dark-mode(secondary);
85
- @include generate-dark-mode(destructive);
86
- @include generate-dark-mode(success);
87
- @include generate-dark-mode(neutral);
88
- }
89
- }
@@ -1,7 +0,0 @@
1
- import { createFormHookContexts } from "@tanstack/react-form";
2
-
3
- /**
4
- * useFieldContext is used in custom components
5
- */
6
- export const { fieldContext, formContext, useFieldContext } =
7
- createFormHookContexts();
@@ -1,33 +0,0 @@
1
- import { createFormHook, type FieldApi } from "@tanstack/react-form";
2
- import { TfCheckbox } from "lib/components/inputs/checkbox";
3
- import { TfMultiSelect } from "lib/components/inputs/multi-select";
4
- import { TfNumberField } from "lib/components/inputs/numberfield";
5
- import { TfSingleSelect } from "lib/components/inputs/select";
6
- import { TfTextField } from "lib/components/inputs/textfield";
7
- import { Button } from "lib/components/ui/button";
8
- import { fieldContext, formContext } from "lib/utils/form-context";
9
-
10
- export function getFieldErrorMessage(field: FieldApi<any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any>): string {
11
- return field?.state.meta.errors.map((e) => e?.message).join(",")
12
- }
13
-
14
- /** Don't put this in the same file as form-context.tsx, this causes circular dependencies. */
15
-
16
- /** TODO, lazy loading when fieldComponents are large */
17
- /**
18
- * Builder for form logic and user interfaces
19
- */
20
- export const { useAppForm } = createFormHook({
21
- fieldComponents: {
22
- TfTextField,
23
- TfNumberField,
24
- TfMultiSelect,
25
- TfSingleSelect,
26
- TfCheckbox,
27
- },
28
- formComponents: {
29
- Button,
30
- },
31
- fieldContext,
32
- formContext,
33
- });
@@ -1,68 +0,0 @@
1
- import { clsx, type ClassValue } from "clsx";
2
-
3
- /** Classnames */
4
- export function cn(...inputs: ClassValue[]) {
5
- return clsx(inputs);
6
- }
7
-
8
- /**
9
- * This is the variable name representing the primary hue.
10
- * Referenced in tokens.scss -> token.css
11
- */
12
- const PRIMARY_HUE_PROPERTY = "--primary-hue";
13
-
14
- /**
15
- *
16
- * @returns
17
- */
18
- export function getThemeHue() {
19
- return document.documentElement.style.getPropertyValue(PRIMARY_HUE_PROPERTY);
20
- }
21
-
22
- /**
23
- * @param hue the hue value to set in the document style
24
- */
25
- export function setThemeHue(hue: number) {
26
- document.documentElement.style.setProperty(
27
- PRIMARY_HUE_PROPERTY,
28
- // In this case, it must be a number.
29
- hue as unknown as string,
30
- );
31
- }
32
-
33
- const ACCESS_TOKEN = "AT";
34
- const REFRESH_TOKEN = "RT";
35
- export function logout() {
36
- if (typeof window !== "undefined" && window.localStorage) {
37
- try {
38
- localStorage.removeItem(REFRESH_TOKEN);
39
- localStorage.removeItem(ACCESS_TOKEN);
40
- window.location.replace("/auth/login");
41
- } catch (error) {
42
- console.error("Logout failed:", error);
43
- }
44
- }
45
- }
46
-
47
- export type JwtDecode = {
48
- aud: string;
49
- email: string;
50
- exp: number;
51
- iat: number;
52
- jti: string;
53
- region: string;
54
- role: string;
55
- role_type: string;
56
- scope: string[];
57
- sub: string;
58
- teat: number;
59
- tenantid: string;
60
- token_usage: string;
61
- sadmin?: string;
62
- };
63
-
64
- export type CtxPortals =
65
- | "customer-portal"
66
- | "system-portal"
67
- | "reseller-portal"
68
- | "admin-portal";
@@ -1,245 +0,0 @@
1
- import type { CtxPortals } from "lib/utils/primitives";
2
- import { createContext, use } from "react";
3
-
4
- /**
5
- *
6
- * @param input camelCase
7
- * @returns title case for the camelCase string
8
- */
9
- export function convertToTitleCase(input: string): string {
10
- return input
11
- .replace(/([A-Z])/g, " $1") // Insert space before capital letters
12
- .trim() // Remove any leading/trailing spaces
13
- .split(" ") // Split into words
14
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()) // Capitalize each word
15
- .join(" "); // Join back into a single string
16
- }
17
-
18
- export function pluralizeTimes(resourceName: string, count: number) {
19
- if (count > 1) {
20
- if (/y$/.test(resourceName)) {
21
- if (resourceName === "Day") return "Days";
22
- return resourceName.replace(/y$/, "ies");
23
- }
24
- return resourceName.concat("s");
25
- }
26
- return resourceName;
27
- }
28
-
29
- /**
30
- * Converts a string from 'camelCase' to 'Title Case'
31
- * @param input String to convert to `Title Case`
32
- */
33
- export function convertCamelCaseToTitleCase(input: string) {
34
- if (input) {
35
- const spacedString = input.replace(/([A-Z])/g, " $1");
36
- return spacedString
37
- .charAt(0)
38
- .toUpperCase()
39
- .concat(spacedString.slice(1))
40
- .replace(/\.[a-z]/, (substr: string) => {
41
- return substr.replace(".", " ").toUpperCase();
42
- });
43
- }
44
- return input;
45
- }
46
-
47
- // Display names specific to customer and reseller portal
48
- const OTHER_PORTALS_DISPLAY_NAME: Record<string, string> = {
49
- "product.displayName": "Product",
50
- };
51
-
52
- /** Resource Name should ALWAYS be in singular form */
53
- export const RESOURCE_NAMES = [
54
- "access-token",
55
- "account",
56
- "activation",
57
- "activation-log",
58
- "admin-role",
59
- "audit-log",
60
- "automated-email",
61
- "automated-email-event-log",
62
- "card",
63
- "feature-flag",
64
- "invoice",
65
- "license",
66
- "license-template",
67
- "maintenance-policy",
68
- "organization",
69
- "plan",
70
- "product",
71
- "product-version",
72
- "profile",
73
- "release",
74
- "release-channel",
75
- "release-file",
76
- "release-platform",
77
- "report",
78
- "role",
79
- "role-claim",
80
- "saml-configuration",
81
- "segment",
82
- "sending-domain",
83
- "setting",
84
- "tag",
85
- "team-member",
86
- "trial",
87
- "trial-policy",
88
- "user",
89
- "user-group",
90
- "webhook",
91
- "webhook-event-log",
92
- "webhook-trigger",
93
- "reseller",
94
- "oidc-configuration",
95
- "organization-claim",
96
- "reseller-claim",
97
- ] as const;
98
- export type ResourceName = (typeof RESOURCE_NAMES)[number];
99
- export const RESOURCE_DEFINITIONS: Record<ResourceName, string> = {
100
- account: "Your organization account.",
101
- product: "Products are the software products you want to license",
102
- license:
103
- "Licenses represent a purchase of your software. These can be linked to customers, and the license key is required to use the product.",
104
- "access-token": "Access Tokens are used to authenticate your API requests.",
105
- activation:
106
- "Activations, also known as devices/machines/seats are the devices consuming licenses.",
107
- "activation-log":
108
- "Activation Log is a log entry of activation/deactivation of a particular license.",
109
- trial:
110
- "Trial/Trial Activation is a device that has activated a trial of your product.",
111
- "audit-log": "Audit logs contain all the changes made to your account.",
112
- "automated-email":
113
- "Automated Email allow you to send marketing emails based on events on the linked product.",
114
- "automated-email-event-log":
115
- "Automated email event log is the log of all the automated email events for your product.",
116
- card: "The payment card for your account.",
117
- "feature-flag":
118
- "Feature flags define features that make up tiers for your products.",
119
- invoice: "",
120
- "license-template":
121
- "License templates are a blueprint for the licenses you create for your customers and prevent repetition when creating licenses.",
122
- "maintenance-policy":
123
- "Maintenance policies represent support contracts and can be linked to licenses.",
124
- plan: "",
125
- "product-version":
126
- "Product Versions are sets of Feature Flags that define the tiers of your products.",
127
- "release-channel": "Release channel is the release channel for your product.",
128
- "release-file": "Release files are files within your created releases.",
129
- "release-platform":
130
- 'Release Platforms differentiate the target platform for your release. Common platforms include "Windows", "macOS", and "Linux".',
131
- release:
132
- "Releases help you to manage different versions of your app, and secure distribute it to licensed users.",
133
- report: "Analytics data for your account",
134
- "role-claim": "",
135
- role: "Roles define permissions for your team.",
136
- "saml-configuration": "",
137
- segment: "Sets of filters that can be saved to filter resources.",
138
- "trial-policy":
139
- "Trial policies are templates for creating trials for your products.",
140
- "webhook-event-log":
141
- "Webhook Event Logs are logs of events that have occured on webhooks.",
142
- "webhook-trigger": "",
143
- webhook:
144
- "Webhooks are HTTP callbacks which are triggered by specific events.",
145
- organization: "",
146
- profile: "",
147
- setting: "",
148
- tag: "Tags allow you to manage your licenses and customers on the dashboard.",
149
- "team-member": "Team members can access the account based on their roles.",
150
- user: "A user refers to your customer whom you want to license your product.",
151
- "sending-domain":
152
- "Allows Cryptlex to send emails on your behalf using your From Email address",
153
- "admin-role": "Roles that have type admin",
154
- "user-group": "Groups of users that you can assign licenses to.",
155
- reseller:
156
- "Resellers allow you to delegate user management to third parties or partners",
157
- "oidc-configuration": "",
158
- "organization-claim": "",
159
- "reseller-claim": "",
160
- };
161
-
162
- const RESOURCE_DISPLAY_NAMES: Record<string, string> = {
163
- id: "ID",
164
- createdAt: "Creation Date",
165
- scopes: "Permissions",
166
- updatedAt: "Last Updated",
167
- expiresAt: "Expiration Date",
168
- lastSeenAt: "Last Seen",
169
- os: "OS",
170
- osVersion: "OS Version",
171
- key: "License Key",
172
- vmName: "VM Name",
173
- container: "Container",
174
- allowedIpRange: "Allowed IP Range",
175
- allowedIpRanges: "Allowed IP Ranges",
176
- allowedIpAddresses: "Allowed IP Addresses",
177
- disallowedIpAddresses: "Disallowed IP Addresses",
178
- allowVmActivation: "Allow VM Activation",
179
- disableGeoLocation: "Disable Geolocation",
180
- "user.id": "User ID",
181
- userId: "User",
182
- productId: "Product",
183
- downloads: "Total Downloads",
184
- claims: "Permissions",
185
- googleSsoEnabled: "Google Login Enabled",
186
- lastAttemptedAt: "Last Attempt Date",
187
- url: "URL",
188
- "trialPolicy.name": "Trial Policy Name",
189
- "licensePolicy.name": "License Template Name",
190
- licensePolicy: "License Template",
191
- eventLog: "Audit Log",
192
- cc: "CC Recepients",
193
- bcc: "BCC Recepients",
194
- ipAddress: "IP Address",
195
- resellerId: "Reseller",
196
- productVersionId: "Product Version",
197
- releaseId: "Release",
198
- maintenancePolicyId: "Maintenance Policy",
199
- webhookId: "Webhook",
200
- automatedEmailId: "Automated Email",
201
- "location.countryName": "Country",
202
- "location.ipAddress": "IP Address",
203
- "location.countryCode": "Country",
204
- organizationId: "Organization",
205
- "address.country": "Country",
206
- "address.addressLine1": "Address Line 1",
207
- "address.addressLine2": "Address Line 2",
208
- responseStatusCode: "HTTP Status Code",
209
- resourceId: "Resource ID",
210
- Sso: "SAML SSO 2.0",
211
- "reseller.name": "Reseller",
212
- sendingDomain: "Email Sending Domain",
213
- };
214
-
215
- function getResourceDisplayName(
216
- resourceName: string,
217
- portal: CtxPortals,
218
- ) {
219
- if (portal !== "admin-portal" && resourceName in OTHER_PORTALS_DISPLAY_NAME) {
220
- return OTHER_PORTALS_DISPLAY_NAME[resourceName];
221
- } else if (resourceName in RESOURCE_DISPLAY_NAMES) {
222
- return RESOURCE_DISPLAY_NAMES[resourceName];
223
- } else {
224
- return convertCamelCaseToTitleCase(resourceName);
225
- }
226
- }
227
-
228
- const ProjectContext = createContext<CtxPortals>('admin-portal');
229
-
230
- export function ProjectProvider({ projectName, children }: { projectName: CtxPortals; children: React.ReactNode; }) {
231
- return (
232
- <ProjectContext.Provider value={projectName}>
233
- {children}
234
- </ProjectContext.Provider>
235
- );
236
- }
237
-
238
- export function useProjectName(): CtxPortals {
239
- return use(ProjectContext);
240
- }
241
-
242
- export function useResourceFormatter(): (resourceName: string) => string {
243
- const portal = useProjectName();
244
- return (resourceName: string) => getResourceDisplayName(resourceName, portal);
245
- }
@@ -1,21 +0,0 @@
1
- import { useEffect, useState } from "react";
2
-
3
- const MOBILE_BREAKPOINT = 768;
4
-
5
- export function useIsMobile() {
6
- const [isMobile, setIsMobile] = useState<boolean | undefined>(
7
- undefined,
8
- );
9
-
10
- useEffect(() => {
11
- const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
12
- const onChange = () => {
13
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
14
- };
15
- mql.addEventListener("change", onChange);
16
- setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
17
- return () => mql.removeEventListener("change", onChange);
18
- }, []);
19
-
20
- return !!isMobile;
21
- }