@pelatform/ui 1.6.0 → 2.1.0

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 (126) hide show
  1. package/README.md +360 -5
  2. package/dist/animation.d.ts +6 -379
  3. package/dist/animation.js +2 -1750
  4. package/dist/base.d.ts +1 -651
  5. package/dist/base.js +2 -5554
  6. package/dist/components.d.ts +1 -2944
  7. package/dist/components.js +2 -2719
  8. package/dist/css/color/gray.css +105 -0
  9. package/dist/css/color/neutral.css +105 -0
  10. package/dist/css/color/slate.css +105 -0
  11. package/dist/css/color/stone.css +105 -0
  12. package/dist/css/color/zinc.css +105 -0
  13. package/dist/css/styles/style-lyra.css +1335 -0
  14. package/dist/css/styles/style-maia.css +1360 -0
  15. package/dist/css/styles/style-mira.css +1362 -0
  16. package/dist/css/styles/style-nova.css +1360 -0
  17. package/dist/css/styles/style-vega.css +1356 -0
  18. package/dist/hooks.d.ts +1 -1172
  19. package/dist/hooks.js +2 -664
  20. package/dist/index.d.ts +1 -318
  21. package/dist/index.js +3 -229
  22. package/dist/radix.d.ts +1 -0
  23. package/dist/radix.js +4 -0
  24. package/dist/style.css +2 -0
  25. package/package.json +82 -136
  26. package/LICENSE +0 -21
  27. package/css/components/apexcharts.css +0 -101
  28. package/css/components/book.css +0 -19
  29. package/css/components/extra.css +0 -12
  30. package/css/components/image-input.css +0 -51
  31. package/css/components/leaflet.css +0 -25
  32. package/css/components/patterns.css +0 -34
  33. package/css/components/rating.css +0 -89
  34. package/css/components/scrollable.css +0 -118
  35. package/css/components/theme-transition.css +0 -51
  36. package/css/theme.css +0 -238
  37. package/dist/animation.cjs +0 -1752
  38. package/dist/animation.d.cts +0 -379
  39. package/dist/aria.cjs +0 -139
  40. package/dist/aria.d.cts +0 -31
  41. package/dist/aria.d.ts +0 -31
  42. package/dist/aria.js +0 -139
  43. package/dist/badge-BtI4BMea.d.cts +0 -33
  44. package/dist/badge-BtI4BMea.d.ts +0 -33
  45. package/dist/base.cjs +0 -5556
  46. package/dist/base.d.cts +0 -651
  47. package/dist/chunk-3N75YA6Q.cjs +0 -60
  48. package/dist/chunk-7472NIIL.cjs +0 -40
  49. package/dist/chunk-BXUKTDPN.cjs +0 -576
  50. package/dist/chunk-CD2BCCQU.js +0 -180
  51. package/dist/chunk-CJXIPSTG.cjs +0 -10
  52. package/dist/chunk-CTHRAJQZ.js +0 -1522
  53. package/dist/chunk-D373YKDA.js +0 -196
  54. package/dist/chunk-EZW5GNS4.js +0 -6
  55. package/dist/chunk-HILACSFA.cjs +0 -1522
  56. package/dist/chunk-HR3R6KKM.js +0 -40
  57. package/dist/chunk-HW52LCWN.js +0 -22
  58. package/dist/chunk-I46SELBA.cjs +0 -22
  59. package/dist/chunk-J4JGE3U5.cjs +0 -180
  60. package/dist/chunk-RQHJBTEU.js +0 -10
  61. package/dist/chunk-SK6SSJHC.js +0 -9
  62. package/dist/chunk-T74DBLYY.js +0 -60
  63. package/dist/chunk-TB6DU23O.js +0 -576
  64. package/dist/chunk-UP53DCYH.cjs +0 -6
  65. package/dist/chunk-ZBO5IAMA.cjs +0 -196
  66. package/dist/chunk-ZDR3OZ7Z.cjs +0 -9
  67. package/dist/colors-CUDWvz1g.d.cts +0 -42
  68. package/dist/colors-CUDWvz1g.d.ts +0 -42
  69. package/dist/components-CidsRcc3.d.cts +0 -46
  70. package/dist/components-CidsRcc3.d.ts +0 -46
  71. package/dist/components.cjs +0 -2721
  72. package/dist/components.d.cts +0 -2944
  73. package/dist/default.cjs +0 -8931
  74. package/dist/default.d.cts +0 -1322
  75. package/dist/default.d.ts +0 -1322
  76. package/dist/default.js +0 -8931
  77. package/dist/hooks.cjs +0 -666
  78. package/dist/hooks.d.cts +0 -1172
  79. package/dist/index.cjs +0 -230
  80. package/dist/index.d.cts +0 -318
  81. package/dist/input-AwYIskrX.d.cts +0 -22
  82. package/dist/input-AwYIskrX.d.ts +0 -22
  83. package/dist/menu-GmSRfRGB.d.cts +0 -43
  84. package/dist/menu-GmSRfRGB.d.ts +0 -43
  85. package/dist/metafile-cjs.json +0 -1
  86. package/dist/metafile-esm.json +0 -1
  87. package/dist/re-export/cva.cjs +0 -6
  88. package/dist/re-export/cva.d.cts +0 -10
  89. package/dist/re-export/cva.d.ts +0 -10
  90. package/dist/re-export/cva.js +0 -6
  91. package/dist/re-export/motion.cjs +0 -2
  92. package/dist/re-export/motion.d.cts +0 -1
  93. package/dist/re-export/motion.d.ts +0 -1
  94. package/dist/re-export/motion.js +0 -2
  95. package/dist/re-export/next-themes.cjs +0 -2
  96. package/dist/re-export/next-themes.d.cts +0 -1
  97. package/dist/re-export/next-themes.d.ts +0 -1
  98. package/dist/re-export/next-themes.js +0 -2
  99. package/dist/re-export/react-day-picker.cjs +0 -2
  100. package/dist/re-export/react-day-picker.d.cts +0 -1
  101. package/dist/re-export/react-day-picker.d.ts +0 -1
  102. package/dist/re-export/react-day-picker.js +0 -2
  103. package/dist/re-export/react-hook-form.cjs +0 -2
  104. package/dist/re-export/react-hook-form.d.cts +0 -1
  105. package/dist/re-export/react-hook-form.d.ts +0 -1
  106. package/dist/re-export/react-hook-form.js +0 -2
  107. package/dist/re-export/resolver.cjs +0 -2
  108. package/dist/re-export/resolver.d.cts +0 -1
  109. package/dist/re-export/resolver.d.ts +0 -1
  110. package/dist/re-export/resolver.js +0 -2
  111. package/dist/re-export/sonner.cjs +0 -2
  112. package/dist/re-export/sonner.d.cts +0 -1
  113. package/dist/re-export/sonner.d.ts +0 -1
  114. package/dist/re-export/sonner.js +0 -2
  115. package/dist/re-export/tanstack-query.cjs +0 -2
  116. package/dist/re-export/tanstack-query.d.cts +0 -1
  117. package/dist/re-export/tanstack-query.d.ts +0 -1
  118. package/dist/re-export/tanstack-query.js +0 -2
  119. package/dist/re-export/tanstack-table.cjs +0 -2
  120. package/dist/re-export/tanstack-table.d.cts +0 -1
  121. package/dist/re-export/tanstack-table.d.ts +0 -1
  122. package/dist/re-export/tanstack-table.js +0 -2
  123. package/dist/re-export/zod.cjs +0 -2
  124. package/dist/re-export/zod.d.cts +0 -1
  125. package/dist/re-export/zod.d.ts +0 -1
  126. package/dist/re-export/zod.js +0 -2
package/dist/index.cjs DELETED
@@ -1,230 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
-
4
-
5
- var _chunk7472NIILcjs = require('./chunk-7472NIIL.cjs');
6
-
7
-
8
- var _chunkCJXIPSTGcjs = require('./chunk-CJXIPSTG.cjs');
9
-
10
-
11
-
12
-
13
- var _chunkI46SELBAcjs = require('./chunk-I46SELBA.cjs');
14
-
15
-
16
- var _chunkUP53DCYHcjs = require('./chunk-UP53DCYH.cjs');
17
-
18
- // src/lib/ohimg.ts
19
- var isValidHex = (color) => {
20
- const hexPattern = /^#[0-9A-Fa-f]{6}$/;
21
- return hexPattern.test(color);
22
- };
23
- var hexToRgba = (color, opacity) => {
24
- const defaultColor = "#000000";
25
- let normalizedColor = _optionalChain([color, 'optionalAccess', _ => _.startsWith, 'call', _2 => _2("#")]) ? color : `#${color}`;
26
- if (!isValidHex(normalizedColor)) {
27
- console.warn(`Invalid hex color: ${color}, using default black`);
28
- normalizedColor = defaultColor;
29
- }
30
- const r = parseInt(normalizedColor.slice(1, 3), 16);
31
- const g = parseInt(normalizedColor.slice(3, 5), 16);
32
- const b = parseInt(normalizedColor.slice(5, 7), 16);
33
- const safeOpacity = Math.max(0, Math.min(1, _nullishCoalesce(opacity, () => ( 1))));
34
- return `rgba(${r}, ${g}, ${b}, ${safeOpacity})`;
35
- };
36
- var getMask = ({ direction = "circle at center", visibleRadius = 30, fadeWidth = 20 }) => {
37
- const outerRadius = visibleRadius + fadeWidth;
38
- return {
39
- maskImage: `radial-gradient(${direction}, black ${visibleRadius}%, transparent ${outerRadius}%)`,
40
- WebkitMaskImage: `radial-gradient(${direction}, black ${visibleRadius}%, transparent ${outerRadius}%)`
41
- };
42
- };
43
- var getDotPattern = ({
44
- color = "#000000",
45
- opacity = 0.5,
46
- size = 25,
47
- backgroundSize = 20
48
- }) => {
49
- const dotColor = hexToRgba(color, opacity);
50
- return {
51
- backgroundImage: `radial-gradient(${dotColor} ${size}%, transparent ${size + 1}%), radial-gradient(${dotColor} ${size - 0.5}%, transparent ${size + 0.5}%)`,
52
- backgroundSize: `${backgroundSize}px ${backgroundSize}px, ${backgroundSize}px ${backgroundSize}px`,
53
- backgroundPosition: `0 0, ${backgroundSize / 2}px ${backgroundSize / 2}px`
54
- };
55
- };
56
- var getGridPattern = ({
57
- color = "#000000",
58
- opacity = 0.5,
59
- size = 20,
60
- lineThickness = 1
61
- }) => {
62
- const colorWithOpacity = hexToRgba(color, opacity);
63
- return {
64
- backgroundImage: `
65
- linear-gradient(to right, ${colorWithOpacity} ${lineThickness}px, transparent ${lineThickness}px),
66
- linear-gradient(to bottom, ${colorWithOpacity} ${lineThickness}px, transparent ${lineThickness}px)
67
- `,
68
- backgroundSize: `${size}px ${size}px`
69
- };
70
- };
71
- var getPatternStyle = (props) => {
72
- switch (props.type) {
73
- case "dots":
74
- return {
75
- ...getDotPattern({
76
- color: props.color,
77
- opacity: props.opacity,
78
- size: props.size,
79
- backgroundSize: props.backgroundSize
80
- }),
81
- ...props.mask && props.mask.enabled === true && getMask({
82
- direction: props.mask.direction,
83
- visibleRadius: props.mask.visibleRadius,
84
- fadeWidth: props.mask.fadeWidth
85
- })
86
- };
87
- case "grid":
88
- return {
89
- ...getGridPattern({
90
- color: props.color,
91
- opacity: props.opacity,
92
- size: props.size,
93
- lineThickness: props.lineThickness
94
- }),
95
- ...props.mask && props.mask.enabled === true && getMask({
96
- direction: props.mask.direction,
97
- visibleRadius: props.mask.visibleRadius,
98
- fadeWidth: props.mask.fadeWidth
99
- })
100
- };
101
- default:
102
- return {};
103
- }
104
- };
105
- var getGradientStyle = (props) => {
106
- if (!props.direction || props.direction === "none") {
107
- return {};
108
- }
109
- const baseGradient = {
110
- background: `linear-gradient(${props.direction || "to bottom"}, ${props.startColor || "#000000"}, ${props.endColor || "#000000"})`,
111
- opacity: _nullishCoalesce(props.opacity, () => ( 0.7))
112
- };
113
- return {
114
- ...baseGradient,
115
- ...props.mask && props.mask.enabled === true && getMask({
116
- direction: props.mask.direction,
117
- visibleRadius: props.mask.visibleRadius,
118
- fadeWidth: props.mask.fadeWidth
119
- })
120
- };
121
- };
122
- function calculateMaxWidth(paddingX) {
123
- const baseWidth = 1200;
124
- if (!paddingX) {
125
- return baseWidth;
126
- }
127
- const paddingValue = parseInt(paddingX.replace("px", ""), 10);
128
- if (Number.isNaN(paddingValue)) {
129
- return baseWidth;
130
- }
131
- const adjustedWidth = baseWidth - 2 * paddingValue;
132
- const finalWidth = Math.min(adjustedWidth, baseWidth);
133
- return finalWidth;
134
- }
135
- function getPositionClasses(element, maxWidth) {
136
- return _chunkCJXIPSTGcjs.cn.call(void 0, element.customClasses && element.customClasses, `max-w-[${maxWidth}px]`);
137
- }
138
-
139
- // src/utils/ip.ts
140
- async function getIPAddress() {
141
- if (typeof window === "undefined") {
142
- return "unknown";
143
- }
144
- try {
145
- const services = [
146
- "https://api.ipify.org?format=json",
147
- "https://ipapi.co/json/",
148
- "https://api.ip.sb/jsonip"
149
- ];
150
- for (const service of services) {
151
- try {
152
- const response = await fetch(service, {
153
- method: "GET",
154
- headers: {
155
- Accept: "application/json"
156
- }
157
- });
158
- if (response.ok) {
159
- const data = await response.json();
160
- const ip = data.ip || data.query || data.ipAddress;
161
- if (ip && typeof ip === "string") {
162
- return ip;
163
- }
164
- }
165
- } catch (serviceError) {
166
- console.warn(`IP service ${service} failed:`, serviceError);
167
- }
168
- }
169
- return "unknown";
170
- } catch (error) {
171
- console.error("Failed to get client IP:", error);
172
- return "unknown";
173
- }
174
- }
175
-
176
- // src/utils/parse.ts
177
- function normalizePath(input) {
178
- if (!input) return "/";
179
- let p = input.trim();
180
- if (!p.startsWith("/")) p = `/${p}`;
181
- p = p.replace(/\/{2,}/g, "/");
182
- if (p.length > 1 && p.endsWith("/")) p = p.slice(0, -1);
183
- return p;
184
- }
185
- var parse = (
186
- // biome-ignore lint/suspicious/noExplicitAny: disable
187
- (req) => {
188
- let domain = req.headers.get("host");
189
- domain = domain.replace(/^www\./, "").toLowerCase();
190
- const path = req.nextUrl.pathname;
191
- const searchParams = req.nextUrl.searchParams.toString();
192
- const searchParamsObj = Object.fromEntries(req.nextUrl.searchParams);
193
- const searchParamsString = searchParams.length > 0 ? `?${searchParams}` : "";
194
- const fullPath = `${path}${searchParamsString}`;
195
- const pathSegments = path.split("/").filter(Boolean);
196
- const key = pathSegments.length > 0 ? decodeURIComponent(pathSegments[0]) : "";
197
- const fullKey = path.length > 1 ? decodeURIComponent(path.slice(1)) : "";
198
- return {
199
- domain,
200
- path,
201
- fullPath,
202
- key,
203
- fullKey,
204
- searchParamsObj,
205
- searchParamsString
206
- };
207
- }
208
- );
209
-
210
-
211
-
212
-
213
-
214
-
215
-
216
-
217
-
218
-
219
-
220
-
221
-
222
-
223
-
224
-
225
-
226
-
227
-
228
-
229
-
230
- exports.DEFAULT_THEME_MODE = _chunkI46SELBAcjs.DEFAULT_THEME_MODE; exports.META_THEME_COLORS = _chunkI46SELBAcjs.META_THEME_COLORS; exports.THEME_MODES = _chunkI46SELBAcjs.THEME_MODES; exports.calculateMaxWidth = calculateMaxWidth; exports.cn = _chunkCJXIPSTGcjs.cn; exports.cva = _chunkUP53DCYHcjs.cva; exports.getAssetsUrl = _chunk7472NIILcjs.getAssetsUrl; exports.getDotPattern = getDotPattern; exports.getFlagUrl = _chunk7472NIILcjs.getFlagUrl; exports.getGradientStyle = getGradientStyle; exports.getGridPattern = getGridPattern; exports.getIPAddress = getIPAddress; exports.getMask = getMask; exports.getPatternStyle = getPatternStyle; exports.getPositionClasses = getPositionClasses; exports.googleTrackEvent = _chunk7472NIILcjs.googleTrackEvent; exports.hexToRgba = hexToRgba; exports.isValidHex = isValidHex; exports.normalizePath = normalizePath; exports.parse = parse;
package/dist/index.d.cts DELETED
@@ -1,318 +0,0 @@
1
- export { D as DEFAULT_THEME_MODE, M as META_THEME_COLORS, T as THEME_MODES, a as ThemeMode } from './colors-CUDWvz1g.cjs';
2
- import { ClassValue } from 'clsx';
3
- export { cva } from 'class-variance-authority';
4
- export { B as BaseProps, I as Image, L as Link } from './components-CidsRcc3.cjs';
5
- export { a as MenuConfig, M as MenuItem } from './menu-GmSRfRGB.cjs';
6
- import 'react';
7
-
8
- /**
9
- * Interface for event tracking parameters
10
- * Defines the structure for tracking events in Google Analytics
11
- */
12
- interface EventProps {
13
- /** Event name to be tracked (required, non-empty string) */
14
- name: string;
15
- /** Optional properties/attributes for the event */
16
- properties?: Record<string, string | number | boolean>;
17
- }
18
- /**
19
- * Global declaration for Google Analytics gtag function
20
- * This extends the Window interface to include the gtag function
21
- * that's injected by the Google Analytics script
22
- */
23
- declare global {
24
- interface Window {
25
- gtag?: (command: 'event' | 'config' | 'set', targetId: string, config?: Record<string, string | number | boolean | object | null | undefined>) => void;
26
- }
27
- }
28
- /**
29
- * Tracks an event in Google Analytics with proper error handling and validation.
30
- *
31
- * @param params - Event parameters
32
- * @param params.name - Event name (required, non-empty string)
33
- * @param params.properties - Optional event properties
34
- */
35
- declare const googleTrackEvent: ({ name, properties }: EventProps) => void;
36
-
37
- type PatternType = 'none' | 'grid' | 'dots';
38
- type GradientDirection = 'none' | 'to right' | 'to left' | 'to bottom' | 'to top' | 'to bottom right' | 'to bottom left' | 'to top right' | 'to top left';
39
- type MaskDirection = 'none' | 'circle at center' | 'circle at center top' | 'circle at top right' | 'circle at center right' | 'circle at bottom right' | 'circle at center bottom' | 'circle at bottom left' | 'circle at center left' | 'circle at top left';
40
- type PositionOption = 'start' | 'center' | 'end';
41
- type AlignmentOption = 'left' | 'center' | 'right';
42
- interface BackgroundImageLayer {
43
- imageSrc?: string;
44
- }
45
- interface MaskLayer {
46
- enabled?: boolean;
47
- direction?: MaskDirection;
48
- visibleRadius?: number;
49
- fadeWidth?: number;
50
- }
51
- interface PatternLayer {
52
- type?: PatternType;
53
- color?: string;
54
- opacity?: number;
55
- size?: number;
56
- backgroundSize?: number;
57
- lineThickness?: number;
58
- mask?: MaskLayer;
59
- }
60
- interface GradientLayer {
61
- startColor?: string;
62
- endColor?: string;
63
- opacity?: number;
64
- direction?: GradientDirection;
65
- mask?: MaskLayer;
66
- }
67
- interface PositionedElement {
68
- customClasses?: string;
69
- textColor?: string;
70
- bgColor?: string;
71
- fontSize?: string;
72
- fontWeight?: string;
73
- width?: string;
74
- height?: string;
75
- hPosition?: PositionOption;
76
- vPosition?: PositionOption;
77
- alignment?: AlignmentOption;
78
- autoMargin?: boolean;
79
- }
80
- interface ContentLayout {
81
- layoutContainer?: string;
82
- logoContainer?: string;
83
- logo?: string;
84
- tagContainer?: string;
85
- contentContainer?: string;
86
- tag?: string;
87
- title?: string;
88
- description?: string;
89
- website?: string;
90
- }
91
- interface OhImgBaseTemplateProps {
92
- content: {
93
- title: string;
94
- description?: string;
95
- tags?: string[];
96
- website?: string;
97
- logoSrc?: string;
98
- };
99
- background?: BackgroundImageLayer;
100
- pattern?: PatternLayer;
101
- gradient?: GradientLayer;
102
- layout?: ContentLayout;
103
- }
104
-
105
- /**
106
- * Converts hex color to rgba format with specified opacity
107
- */
108
- declare const isValidHex: (color: string) => boolean;
109
- declare const hexToRgba: (color: string, opacity: number) => string;
110
- declare const getMask: ({ direction, visibleRadius, fadeWidth }: {
111
- direction?: string | undefined;
112
- visibleRadius?: number | undefined;
113
- fadeWidth?: number | undefined;
114
- }) => {
115
- maskImage: string;
116
- WebkitMaskImage: string;
117
- };
118
- declare const getDotPattern: ({ color, opacity, size, backgroundSize, }: {
119
- color?: string | undefined;
120
- opacity?: number | undefined;
121
- size?: number | undefined;
122
- backgroundSize?: number | undefined;
123
- }) => {
124
- backgroundImage: string;
125
- backgroundSize: string;
126
- backgroundPosition: string;
127
- };
128
- declare const getGridPattern: ({ color, opacity, size, lineThickness, }: {
129
- color?: string;
130
- opacity?: number;
131
- size?: number;
132
- lineThickness?: number;
133
- }) => {
134
- backgroundImage: string;
135
- backgroundSize: string;
136
- };
137
- declare const getPatternStyle: (props: PatternLayer) => {};
138
- declare const getGradientStyle: (props: GradientLayer) => {};
139
- declare function calculateMaxWidth(paddingX: string | undefined): number;
140
- declare function getPositionClasses(element: PositionedElement, maxWidth: number): string;
141
-
142
- /**
143
- * Utility functions for CSS class name management
144
- * Provides optimized class name merging with Tailwind CSS conflict resolution
145
- * Essential for component styling and conditional class application
146
- */
147
-
148
- /**
149
- * Merges Tailwind class names, resolving any conflicts.
150
- * This utility combines clsx for conditional classes with tailwind-merge
151
- * to properly handle Tailwind CSS class conflicts.
152
- *
153
- * @param inputs - An array of class names, objects, or arrays to merge
154
- * @returns A string of merged and optimized class names
155
- */
156
- declare function cn(...inputs: ClassValue[]): string;
157
-
158
- /**
159
- * Assets URL Utility
160
- * Builds a fully-qualified CDN URL for a given assets path.
161
- * Useful for referencing illustrations and media from the Pelatform assets CDN.
162
- */
163
- /**
164
- * Build a full CDN URL for a given assets path.
165
- *
166
- * @param path - Relative path to the asset (e.g., "media/illustrations/29.svg")
167
- * @returns A fully-qualified CDN URL string
168
- *
169
- * @example
170
- * ```ts
171
- * import { getAssetsUrl } from "@pelatform/ui/utils/assets-url";
172
- *
173
- * const url = getAssetsUrl("media/illustrations/29.svg");
174
- * // "https://assets.pelatform.com/media/illustrations/29.svg"
175
- * ```
176
- */
177
- declare function getAssetsUrl(path: string): string;
178
- /**
179
- * Build a CDN URL for a country flag SVG.
180
- *
181
- * The function lowercases the given ISO country code and returns a
182
- * fully-qualified URL pointing to the SVG flag hosted on the Pelatform
183
- * assets CDN.
184
- *
185
- * @param flag - ISO 3166-1 alpha-2 country code (e.g., "US", "ID", "GB")
186
- * @returns A URL string to the SVG flag on the CDN
187
- *
188
- * @example
189
- * ```ts
190
- * import { getFlagUrl } from "@pelatform/ui/utils/flag-url";
191
- *
192
- * const urlUs = getFlagUrl("US");
193
- * // "https://assets.pelatform.com/media/flags/us.svg"
194
- *
195
- * const urlId = getFlagUrl("id");
196
- * // "https://assets.pelatform.com/media/flags/id.svg"
197
- *
198
- * // Can be used directly in an <img /> or <Image /> component
199
- * // <img src={getFlagUrl("GB")} alt="United Kingdom flag" />
200
- * ```
201
- */
202
- declare function getFlagUrl(flag: string): string;
203
-
204
- /**
205
- * Get the client's public IP address using external services.
206
- *
207
- * This utility is intended for client-side usage only (it checks for `window`).
208
- * It attempts multiple providers for resiliency and normalizes the response
209
- * to a simple string. If all providers fail or the environment is not a
210
- * browser, it resolves to `'unknown'`.
211
- *
212
- * Providers queried (in order):
213
- * - `https://api.ipify.org?format=json`
214
- * - `https://ipapi.co/json/`
215
- * - `https://api.ip.sb/jsonip`
216
- *
217
- * @returns Promise that resolves to an IP address string or `'unknown'` if not available
218
- *
219
- * @example
220
- * ```ts
221
- * import { getIPAddress } from "@pelatform/ui/utils/ip";
222
- *
223
- * const ip = await getIPAddress();
224
- * // e.g., "203.0.113.42" or "unknown"
225
- *
226
- * // Example in a React component
227
- * // useEffect(() => {
228
- * // getIPAddress().then(setIp);
229
- * // }, []);
230
- * ```
231
- */
232
- declare function getIPAddress(): Promise<string>;
233
-
234
- /**
235
- * Normalize a pathname string.
236
- *
237
- * - Ensures it always starts with '/'
238
- * - Collapses multiple slashes (e.g., `'//a///b'` becomes `'/a/b'`)
239
- * - Removes trailing slash except for root path (e.g., `'/login/'` becomes `'/login'`)
240
- *
241
- * @param input - Any path-like string
242
- * @returns A normalized path beginning with '/'
243
- *
244
- * @example
245
- * ```ts
246
- * import { normalizePath } from "@pelatform/ui/utils/parse";
247
- *
248
- * normalizePath("dashboard"); // "/dashboard"
249
- * normalizePath("//a///b"); // "/a/b"
250
- * normalizePath("/login/"); // "/login"
251
- * normalizePath(""); // "/"
252
- * ```
253
- */
254
- declare function normalizePath(input: string): string;
255
- /**
256
- * Interface for parsed request data
257
- */
258
- interface ParsedRequest {
259
- /** Normalized domain name (lowercase, without www) */
260
- domain: string;
261
- /** URL pathname (e.g., '/dashboard/users') */
262
- path: string;
263
- /** Full path including query parameters (e.g., '/dashboard/users?page=1') */
264
- fullPath: string;
265
- /** First path segment (e.g., 'dashboard' from '/dashboard/users') */
266
- key: string;
267
- /** Full path without leading slash (e.g., 'dashboard/users') */
268
- fullKey: string;
269
- /** Query parameters as object */
270
- searchParamsObj: Record<string, string>;
271
- /** Query parameters as string (e.g., '?page=1&limit=10') */
272
- searchParamsString: string;
273
- }
274
- /**
275
- * Parse and normalize a Next.js `NextRequest`.
276
- *
277
- * Extracts domain, normalized path, first segment key, full path, and
278
- * query parameters (both as object and as string). Handles international
279
- * characters via `decodeURIComponent` and normalizes the host by removing
280
- * a leading `www.`.
281
- *
282
- * @param req - The incoming Next.js `NextRequest`
283
- * @returns Parsed request data with normalized components
284
- *
285
- * @example
286
- * ```ts
287
- * import type { NextRequest } from "next/server";
288
- * import { parse } from "@pelatform/ui/utils/parse";
289
- *
290
- * export function middleware(req: NextRequest) {
291
- * const { domain, path, fullPath, key } = parse(req);
292
- *
293
- * console.log(domain); // e.g., "api.pelatform.com"
294
- * console.log(path); // e.g., "/v1/users"
295
- * console.log(fullPath); // e.g., "/v1/users?page=1"
296
- * console.log(key); // e.g., "v1"
297
- * }
298
- * ```
299
- *
300
- * @example
301
- * ```ts
302
- * // Handling international URLs
303
- * const { key, fullKey } = parse(req);
304
- * console.log(key); // Decoded first path segment
305
- * console.log(fullKey); // Decoded full path
306
- * ```
307
- *
308
- * @example
309
- * ```ts
310
- * // Working with query parameters
311
- * const { searchParamsObj, searchParamsString } = parse(req);
312
- * // searchParamsObj -> { page: "1", limit: "10" }
313
- * // searchParamsString -> "?page=1&limit=10"
314
- * ```
315
- */
316
- declare const parse: (req: any) => ParsedRequest;
317
-
318
- export { type AlignmentOption, type BackgroundImageLayer, type ContentLayout, type GradientDirection, type GradientLayer, type MaskDirection, type MaskLayer, type OhImgBaseTemplateProps, type ParsedRequest, type PatternLayer, type PatternType, type PositionOption, type PositionedElement, calculateMaxWidth, cn, getAssetsUrl, getDotPattern, getFlagUrl, getGradientStyle, getGridPattern, getIPAddress, getMask, getPatternStyle, getPositionClasses, googleTrackEvent, hexToRgba, isValidHex, normalizePath, parse };
@@ -1,22 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as class_variance_authority_types from 'class-variance-authority/types';
3
- import * as React from 'react';
4
- import { VariantProps } from 'class-variance-authority';
5
-
6
- declare const inputVariants: (props?: ({
7
- variant?: "lg" | "md" | "sm" | null | undefined;
8
- } & class_variance_authority_types.ClassProp) | undefined) => string;
9
- declare const inputAddonVariants: (props?: ({
10
- variant?: "lg" | "md" | "sm" | null | undefined;
11
- mode?: "default" | "icon" | null | undefined;
12
- } & class_variance_authority_types.ClassProp) | undefined) => string;
13
- declare const inputGroupVariants: (props?: ({} & class_variance_authority_types.ClassProp) | undefined) => string;
14
- declare const inputWrapperVariants: (props?: ({
15
- variant?: "lg" | "md" | "sm" | null | undefined;
16
- } & class_variance_authority_types.ClassProp) | undefined) => string;
17
- declare function Input({ className, type, variant, ...props }: React.ComponentProps<'input'> & VariantProps<typeof inputVariants>): react_jsx_runtime.JSX.Element;
18
- declare function InputAddon({ className, variant, mode, ...props }: React.ComponentProps<'div'> & VariantProps<typeof inputAddonVariants>): react_jsx_runtime.JSX.Element;
19
- declare function InputGroup({ className, ...props }: React.ComponentProps<'div'> & VariantProps<typeof inputGroupVariants>): react_jsx_runtime.JSX.Element;
20
- declare function InputWrapper({ className, variant, ...props }: React.ComponentProps<'div'> & VariantProps<typeof inputWrapperVariants>): react_jsx_runtime.JSX.Element;
21
-
22
- export { Input as I, InputAddon as a, InputGroup as b, InputWrapper as c, inputAddonVariants as d, inputVariants as i };
@@ -1,22 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as class_variance_authority_types from 'class-variance-authority/types';
3
- import * as React from 'react';
4
- import { VariantProps } from 'class-variance-authority';
5
-
6
- declare const inputVariants: (props?: ({
7
- variant?: "lg" | "md" | "sm" | null | undefined;
8
- } & class_variance_authority_types.ClassProp) | undefined) => string;
9
- declare const inputAddonVariants: (props?: ({
10
- variant?: "lg" | "md" | "sm" | null | undefined;
11
- mode?: "default" | "icon" | null | undefined;
12
- } & class_variance_authority_types.ClassProp) | undefined) => string;
13
- declare const inputGroupVariants: (props?: ({} & class_variance_authority_types.ClassProp) | undefined) => string;
14
- declare const inputWrapperVariants: (props?: ({
15
- variant?: "lg" | "md" | "sm" | null | undefined;
16
- } & class_variance_authority_types.ClassProp) | undefined) => string;
17
- declare function Input({ className, type, variant, ...props }: React.ComponentProps<'input'> & VariantProps<typeof inputVariants>): react_jsx_runtime.JSX.Element;
18
- declare function InputAddon({ className, variant, mode, ...props }: React.ComponentProps<'div'> & VariantProps<typeof inputAddonVariants>): react_jsx_runtime.JSX.Element;
19
- declare function InputGroup({ className, ...props }: React.ComponentProps<'div'> & VariantProps<typeof inputGroupVariants>): react_jsx_runtime.JSX.Element;
20
- declare function InputWrapper({ className, variant, ...props }: React.ComponentProps<'div'> & VariantProps<typeof inputWrapperVariants>): react_jsx_runtime.JSX.Element;
21
-
22
- export { Input as I, InputAddon as a, InputGroup as b, InputWrapper as c, inputAddonVariants as d, inputVariants as i };
@@ -1,43 +0,0 @@
1
- /**
2
- * Menu item interface
3
- */
4
- interface MenuItem {
5
- /** Heading text */
6
- heading?: string;
7
- /** Menu item title */
8
- title?: string;
9
- /** Navigation path */
10
- path?: string;
11
- /** Menu item icon component */
12
- icon?: React.ComponentType<React.SVGProps<SVGSVGElement>>;
13
- /** Whether to show separator */
14
- separator?: boolean;
15
- /** Root path for active state matching */
16
- rootPath?: string;
17
- /** Child menu items */
18
- children?: MenuConfig;
19
- /** Children index for nested items */
20
- childrenIndex?: number;
21
- /** Whether the item is external */
22
- external?: boolean;
23
- /** Whether the item is disabled */
24
- disabled?: boolean;
25
- /** Disable text */
26
- disabledText?: string;
27
- /** Badge text */
28
- badge?: string;
29
- /** Badge variant */
30
- badgeVariant?: 'primary' | 'destructive' | 'success' | 'info' | 'warning' | 'secondary' | 'outline';
31
- /** Collapse configuration */
32
- collapse?: boolean;
33
- /** Title when collapsed */
34
- collapseTitle?: string;
35
- /** Title when expanded */
36
- expandTitle?: string;
37
- }
38
- /**
39
- * Type aliases for backward compatibility
40
- */
41
- type MenuConfig = MenuItem[];
42
-
43
- export type { MenuItem as M, MenuConfig as a };
@@ -1,43 +0,0 @@
1
- /**
2
- * Menu item interface
3
- */
4
- interface MenuItem {
5
- /** Heading text */
6
- heading?: string;
7
- /** Menu item title */
8
- title?: string;
9
- /** Navigation path */
10
- path?: string;
11
- /** Menu item icon component */
12
- icon?: React.ComponentType<React.SVGProps<SVGSVGElement>>;
13
- /** Whether to show separator */
14
- separator?: boolean;
15
- /** Root path for active state matching */
16
- rootPath?: string;
17
- /** Child menu items */
18
- children?: MenuConfig;
19
- /** Children index for nested items */
20
- childrenIndex?: number;
21
- /** Whether the item is external */
22
- external?: boolean;
23
- /** Whether the item is disabled */
24
- disabled?: boolean;
25
- /** Disable text */
26
- disabledText?: string;
27
- /** Badge text */
28
- badge?: string;
29
- /** Badge variant */
30
- badgeVariant?: 'primary' | 'destructive' | 'success' | 'info' | 'warning' | 'secondary' | 'outline';
31
- /** Collapse configuration */
32
- collapse?: boolean;
33
- /** Title when collapsed */
34
- collapseTitle?: string;
35
- /** Title when expanded */
36
- expandTitle?: string;
37
- }
38
- /**
39
- * Type aliases for backward compatibility
40
- */
41
- type MenuConfig = MenuItem[];
42
-
43
- export type { MenuItem as M, MenuConfig as a };