@gv-tech/ui-native 2.27.3 → 2.28.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gv-tech/ui-native",
3
- "version": "2.27.3",
3
+ "version": "2.28.0",
4
4
  "description": "React Native implementations of the GV Tech design system components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,9 +9,31 @@ import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } f
9
9
  import { cn } from './lib/utils';
10
10
  import { Text } from './text';
11
11
 
12
- const normalizeBaseUrl = (url: string) => {
12
+ const DEFAULT_SUPPORT_URL = 'https://www.buymeacoffee.com';
13
+ const ALLOWED_SUPPORT_DOMAINS = new Set(['buymeacoffee.com', 'www.buymeacoffee.com']);
14
+
15
+ const validateSupportUrl = (url: string) => {
13
16
  const trimmed = url.trim();
14
- return trimmed.endsWith('/') ? trimmed.slice(0, -1) : trimmed;
17
+
18
+ try {
19
+ const parsed = new URL(trimmed);
20
+ const hostname = parsed.hostname.toLowerCase();
21
+
22
+ if (parsed.protocol !== 'https:' || !ALLOWED_SUPPORT_DOMAINS.has(hostname)) {
23
+ console.warn(`Invalid supportUrl: ${url}. Falling back to default.`);
24
+ return DEFAULT_SUPPORT_URL;
25
+ }
26
+
27
+ return trimmed;
28
+ } catch {
29
+ console.warn(`Invalid supportUrl: ${url}. Falling back to default.`);
30
+ return DEFAULT_SUPPORT_URL;
31
+ }
32
+ };
33
+
34
+ const normalizeBaseUrl = (url: string) => {
35
+ const validated = validateSupportUrl(url);
36
+ return validated.endsWith('/') ? validated.slice(0, -1) : validated;
15
37
  };
16
38
 
17
39
  const sanitizeCreator = (creatorId: string) => creatorId.trim().replace(/^@+/, '');
@@ -36,7 +58,7 @@ export interface SupportFabProps extends Omit<React.ComponentPropsWithoutRef<typ
36
58
  }
37
59
 
38
60
  export function SupportFab({
39
- supportUrl = 'https://www.buymeacoffee.com',
61
+ supportUrl = DEFAULT_SUPPORT_URL,
40
62
  creatorId,
41
63
  title = 'Buy me a coffee',
42
64
  description = 'Support the project directly from this panel.',
package/src/switch.tsx CHANGED
@@ -1,72 +1,34 @@
1
1
  import { SwitchBaseProps } from '@gv-tech/ui-core';
2
- import * as SwitchPrimitive from '@rn-primitives/switch';
2
+ import * as SwitchPrimitives from '@rn-primitives/switch';
3
3
  import * as React from 'react';
4
- import { StyleSheet } from 'react-native';
5
4
 
6
5
  import { cn } from './lib/utils';
7
6
 
8
7
  export interface SwitchProps
9
8
  extends
10
- Omit<React.ComponentPropsWithoutRef<typeof SwitchPrimitive.Root>, 'checked' | 'onCheckedChange'>,
9
+ Omit<React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>, 'checked' | 'onCheckedChange'>,
11
10
  SwitchBaseProps {}
12
11
 
13
- const Switch = React.forwardRef<React.ComponentRef<typeof SwitchPrimitive.Root>, SwitchProps>(
14
- ({ className, checked = false, onCheckedChange, style, ...props }, ref) => {
15
- const isChecked = Boolean(checked);
16
-
17
- const resolvedStyle =
18
- typeof style === 'function'
19
- ? (state: unknown) => ({
20
- width: 44,
21
- height: 24,
22
- minWidth: 44,
23
- minHeight: 24,
24
- flexShrink: 0,
25
- padding: 2,
26
- ...(StyleSheet.flatten(style(state as never)) || {}),
27
- })
28
- : {
29
- width: 44,
30
- height: 24,
31
- minWidth: 44,
32
- minHeight: 24,
33
- flexShrink: 0,
34
- padding: 2,
35
- ...(StyleSheet.flatten(style) || {}),
36
- };
37
-
38
- return (
39
- <SwitchPrimitive.Root
40
- ref={ref}
41
- checked={isChecked}
42
- onCheckedChange={onCheckedChange || (() => {})}
12
+ const Switch = React.forwardRef<React.ComponentRef<typeof SwitchPrimitives.Root>, SwitchProps>(
13
+ ({ className, checked, onCheckedChange, ...props }, ref) => (
14
+ <SwitchPrimitives.Root
15
+ ref={ref}
16
+ checked={checked ?? false}
17
+ onCheckedChange={onCheckedChange || (() => {})}
18
+ className={cn(
19
+ 'peer focus-visible:ring-ring focus-visible:ring-offset-background data-[state=checked]:bg-primary data-[state=unchecked]:bg-input inline-flex h-6 w-11 shrink-0 cursor-pointer flex-row items-center rounded-full border-2 border-transparent transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50',
20
+ className,
21
+ )}
22
+ {...props}
23
+ >
24
+ <SwitchPrimitives.Thumb
43
25
  className={cn(
44
- 'peer focus-visible:ring-ring focus-visible:ring-offset-background inline-flex h-6 w-11 shrink-0 cursor-pointer flex-row items-center rounded-full transition-colors focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50',
45
- isChecked ? 'bg-primary data-[state=checked]:bg-primary' : 'bg-input data-[state=unchecked]:bg-input',
46
- className,
26
+ 'bg-background pointer-events-none block h-5 w-5 rounded-full shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-[18px] data-[state=unchecked]:translate-x-0',
47
27
  )}
48
- style={resolvedStyle as React.ComponentPropsWithoutRef<typeof SwitchPrimitive.Root>['style']}
49
- {...props}
50
- >
51
- <SwitchPrimitive.Thumb
52
- className={cn(
53
- 'bg-background pointer-events-none block h-5 w-5 rounded-full shadow-md transition-transform',
54
- isChecked
55
- ? 'translate-x-5 data-[state=checked]:translate-x-5'
56
- : 'translate-x-0 data-[state=unchecked]:translate-x-0',
57
- )}
58
- style={{
59
- width: 20,
60
- height: 20,
61
- flexShrink: 0,
62
- transform: isChecked ? 'translateX(20px)' : 'translateX(0px)',
63
- marginLeft: isChecked ? 20 : 0,
64
- }}
65
- />
66
- </SwitchPrimitive.Root>
67
- );
68
- },
28
+ />
29
+ </SwitchPrimitives.Root>
30
+ ),
69
31
  );
70
- Switch.displayName = SwitchPrimitive.Root?.displayName || 'Switch';
32
+ Switch.displayName = SwitchPrimitives.Root.displayName;
71
33
 
72
34
  export { Switch };