@shokirovr16/frontend-library 0.1.2

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 (58) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +98 -0
  3. package/bin/cmfrt.js +69 -0
  4. package/package.json +47 -0
  5. package/src/auth/README.md +193 -0
  6. package/src/auth/core/AuthEngine.js +623 -0
  7. package/src/auth/core/OidcClient.js +79 -0
  8. package/src/auth/core/OidcDiscovery.js +17 -0
  9. package/src/auth/core/Pkce.js +18 -0
  10. package/src/auth/events/AuthEventBus.js +22 -0
  11. package/src/auth/http/authFetch.js +32 -0
  12. package/src/auth/http/createAuthHttpClient.js +42 -0
  13. package/src/auth/index.js +90 -0
  14. package/src/auth/permissions/ClaimsNormalizer.js +69 -0
  15. package/src/auth/permissions/permissions.js +26 -0
  16. package/src/auth/react/AuthProvider.js +34 -0
  17. package/src/auth/react/guards/RequireAuth.js +35 -0
  18. package/src/auth/react/guards/RequirePermission.js +16 -0
  19. package/src/auth/react/guards/withAuthGuard.js +12 -0
  20. package/src/auth/react/hooks/useRequireAuth.js +24 -0
  21. package/src/auth/react/index.js +6 -0
  22. package/src/auth/react/useAuth.js +29 -0
  23. package/src/auth/silent/silentCallback.js +42 -0
  24. package/src/auth/singleton.js +22 -0
  25. package/src/auth/storage/InMemoryTokenStore.js +56 -0
  26. package/src/auth/storage/TransactionStore.js +51 -0
  27. package/src/auth/sync/BroadcastChannelSync.js +29 -0
  28. package/src/auth/tenancy/TenantResolver.js +39 -0
  29. package/src/auth/types.js +113 -0
  30. package/src/auth/utils/base64url.js +15 -0
  31. package/src/auth/utils/jwt.js +26 -0
  32. package/src/auth/utils/random.js +13 -0
  33. package/src/auth/utils/url.js +27 -0
  34. package/src/commands/add.js +80 -0
  35. package/src/commands/init.js +113 -0
  36. package/src/commands/list.js +92 -0
  37. package/src/commands/remove.js +150 -0
  38. package/src/commands/status.js +96 -0
  39. package/src/commands/theme.js +47 -0
  40. package/src/commands/uninstall.js +198 -0
  41. package/src/commands/update.js +151 -0
  42. package/src/lib/config.js +55 -0
  43. package/src/lib/fs.js +13 -0
  44. package/src/lib/packageManager.js +30 -0
  45. package/src/lib/paths.js +14 -0
  46. package/src/lib/registry.js +11 -0
  47. package/src/lib/styles.js +223 -0
  48. package/src/lib/targets.js +15 -0
  49. package/src/lib/theme.js +102 -0
  50. package/templates/docs/cmfrt-doc.md +82 -0
  51. package/templates/lib/utils.js +6 -0
  52. package/templates/registry.json +42 -0
  53. package/templates/styles/theme.cjs +832 -0
  54. package/templates/styles/type-utilities.css +136 -0
  55. package/templates/styles/type-utility-classes.css +138 -0
  56. package/templates/styles/variables.css +1560 -0
  57. package/templates/styles/variables.json +6870 -0
  58. package/templates/ui/button.jsx +117 -0
@@ -0,0 +1,117 @@
1
+ import React from "react";
2
+ import { cn } from "../../lib/utils";
3
+
4
+ const SIZE_CLASSES = {
5
+ "extra-small":
6
+ "px-[6px] py-[4px] gap-0.5 rounded-[6px] text-[14px] font-normal font-['Inter']",
7
+ small: "px-[12px] py-[8px] gap-0.5 text-[14px] font-semibold font-['Inter']",
8
+ medium: "px-[12px] py-[10px] gap-1 text-[16px] font-semibold font-['Inter']",
9
+ large: "px-[16px] py-[12px] gap-1 text-[16px] font-semibold font-['Inter']",
10
+ };
11
+
12
+ const ICON_SIZE_CLASSES = {
13
+ "extra-small": "h-4 w-4",
14
+ small: "h-4 w-4",
15
+ medium: "h-5 w-5",
16
+ large: "h-5 w-5",
17
+ };
18
+
19
+ const TONE_CLASSES = {
20
+ neutral: {
21
+ primary: {
22
+ filled:
23
+ "bg-colors-button-neutral-primary-active text-colors-texticons-on-accentdark hover:bg-colors-button-neutral-primary-on-hover active:bg-colors-button-neutral-primary-on-press",
24
+ ghost:
25
+ "bg-colors-button-neutral-ghost-active text-colors-texticons-primary hover:bg-colors-button-neutral-ghost-on-hover active:bg-colors-button-neutral-ghost-on-press",
26
+ },
27
+ secondary:
28
+ "bg-colors-button-neutral-secondary-active text-colors-texticons-primary hover:bg-colors-button-neutral-secondary-on-hover active:bg-colors-button-neutral-secondary-on-press",
29
+ },
30
+ negative: {
31
+ primary: {
32
+ filled:
33
+ "bg-colors-button-negative-primary-active text-colors-texticons-on-accentdark hover:bg-colors-button-negative-primary-on-hover active:bg-colors-button-negative-primary-on-press",
34
+ ghost:
35
+ "bg-colors-button-negative-ghost-active text-colors-texticons-negative hover:bg-colors-button-negative-ghost-on-hover active:bg-colors-button-negative-ghost-on-press",
36
+ },
37
+ secondary:
38
+ "bg-colors-button-negative-secondary-active text-colors-texticons-negative hover:bg-colors-button-negative-secondary-on-hover active:bg-colors-button-negative-secondary-on-press",
39
+ },
40
+ positive: {
41
+ primary: {
42
+ filled:
43
+ "bg-colors-button-positive-primary-active text-colors-texticons-on-accentdark hover:bg-colors-button-positive-primary-on-hover active:bg-colors-button-positive-primary-on-press",
44
+ ghost:
45
+ "bg-colors-button-positive-ghost-active text-colors-texticons-positive hover:bg-colors-button-positive-ghost-on-hover active:bg-colors-button-positive-ghost-on-press",
46
+ },
47
+ secondary:
48
+ "bg-colors-button-positive-secondary-active text-colors-texticons-positive hover:bg-colors-button-positive-secondary-on-hover active:bg-colors-button-positive-secondary-on-press",
49
+ },
50
+ accent: {
51
+ primary: {
52
+ filled:
53
+ "bg-colors-button-themed-primary-active text-colors-texticons-on-accentdark hover:bg-colors-button-themed-primary-on-hover active:bg-colors-button-themed-primary-on-press",
54
+ ghost:
55
+ "bg-colors-button-themed-ghost-active text-colors-texticons-accent hover:bg-colors-button-themed-ghost-on-hover active:bg-colors-button-themed-ghost-on-press",
56
+ },
57
+ secondary:
58
+ "bg-colors-button-themed-secondary-active text-colors-texticons-accent hover:bg-colors-button-themed-secondary-on-hover active:bg-colors-button-themed-secondary-on-press",
59
+ },
60
+ };
61
+
62
+ const DISABLED_CLASSES = {
63
+ filled:
64
+ "bg-colors-button-disabled-primarysecondary text-colors-texticons-tertiary",
65
+ ghost: "bg-colors-button-disabled-ghost text-colors-texticons-tertiary",
66
+ };
67
+
68
+ function withIconSize(icon, sizeClass) {
69
+ if (!icon) return null;
70
+ if (React.isValidElement(icon)) {
71
+ return React.cloneElement(icon, {
72
+ className: cn(icon.props.className, sizeClass, "shrink-0"),
73
+ });
74
+ }
75
+ return <span className={cn(sizeClass, "inline-flex shrink-0")}>{icon}</span>;
76
+ }
77
+
78
+ export function Button({
79
+ primary = true,
80
+ size = "medium",
81
+ tone = "neutral",
82
+ type = "filled",
83
+ leftIcon = null,
84
+ rightIcon = null,
85
+ disabled = false,
86
+ label,
87
+ className,
88
+ children,
89
+ ...props
90
+ }) {
91
+ const sizeClass = SIZE_CLASSES[size] ?? SIZE_CLASSES.medium;
92
+ const iconClass = ICON_SIZE_CLASSES[size] ?? ICON_SIZE_CLASSES.medium;
93
+ const normalizedType = type === "flled" ? "filled" : type;
94
+ const variantClass = disabled
95
+ ? (DISABLED_CLASSES[normalizedType] ?? DISABLED_CLASSES.filled)
96
+ : primary
97
+ ? TONE_CLASSES[tone]?.primary?.[normalizedType]
98
+ : TONE_CLASSES[tone]?.secondary;
99
+
100
+ return (
101
+ <button
102
+ className={cn(
103
+ "inline-flex items-center border-0 rounded-[10px] transition-colors duration-200 ease-in-out cursor-pointer",
104
+ "disabled:cursor-auto",
105
+ sizeClass,
106
+ variantClass,
107
+ className,
108
+ )}
109
+ disabled={disabled}
110
+ {...props}
111
+ >
112
+ {withIconSize(leftIcon, iconClass)}
113
+ {label || children}
114
+ {withIconSize(rightIcon, iconClass)}
115
+ </button>
116
+ );
117
+ }