@gv-tech/ui-native 2.27.2 → 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/dist/support-fab.d.ts.map +1 -1
- package/dist/switch.d.ts +2 -2
- package/dist/switch.d.ts.map +1 -1
- package/dist/ui-native.cjs +2 -2
- package/dist/ui-native.esm.js +234 -249
- package/package.json +1 -1
- package/src/support-fab.tsx +25 -3
- package/src/switch.tsx +20 -32
package/package.json
CHANGED
package/src/support-fab.tsx
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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 =
|
|
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,46 +1,34 @@
|
|
|
1
1
|
import { SwitchBaseProps } from '@gv-tech/ui-core';
|
|
2
|
-
import * as
|
|
2
|
+
import * as SwitchPrimitives from '@rn-primitives/switch';
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
|
|
5
5
|
import { cn } from './lib/utils';
|
|
6
6
|
|
|
7
7
|
export interface SwitchProps
|
|
8
8
|
extends
|
|
9
|
-
Omit<React.ComponentPropsWithoutRef<typeof
|
|
9
|
+
Omit<React.ComponentPropsWithoutRef<typeof SwitchPrimitives.Root>, 'checked' | 'onCheckedChange'>,
|
|
10
10
|
SwitchBaseProps {}
|
|
11
11
|
|
|
12
|
-
const Switch = React.forwardRef<React.ComponentRef<typeof
|
|
13
|
-
({ className, checked
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
checked=
|
|
20
|
-
|
|
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
|
|
21
25
|
className={cn(
|
|
22
|
-
'
|
|
23
|
-
isChecked ? 'bg-primary' : 'bg-input',
|
|
24
|
-
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',
|
|
25
27
|
)}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
: [{ width: 44, height: 24, minWidth: 44, minHeight: 24, flexShrink: 0 }, style]
|
|
30
|
-
}
|
|
31
|
-
{...props}
|
|
32
|
-
>
|
|
33
|
-
<SwitchPrimitive.Thumb
|
|
34
|
-
className={cn(
|
|
35
|
-
'bg-background pointer-events-none block h-5 w-5 rounded-full shadow-lg ring-0 transition-transform',
|
|
36
|
-
isChecked ? 'translate-x-5' : 'translate-x-0',
|
|
37
|
-
)}
|
|
38
|
-
style={{ width: 20, height: 20, flexShrink: 0 }}
|
|
39
|
-
/>
|
|
40
|
-
</SwitchPrimitive.Root>
|
|
41
|
-
);
|
|
42
|
-
},
|
|
28
|
+
/>
|
|
29
|
+
</SwitchPrimitives.Root>
|
|
30
|
+
),
|
|
43
31
|
);
|
|
44
|
-
Switch.displayName =
|
|
32
|
+
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
45
33
|
|
|
46
34
|
export { Switch };
|