@admin-layout/gluestack-ui-mobile 11.0.4-alpha.4 → 12.0.16-alpha.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/CHANGELOG.md +63 -13
- package/lib/components/AuthWrapper.js +5 -3
- package/lib/components/AuthWrapper.js.map +1 -1
- package/lib/components/WithConfiguration.js +1 -1
- package/lib/components/WithConfiguration.js.map +1 -1
- package/lib/components/ui/accordion/index.web.d.ts +209 -0
- package/lib/components/ui/accordion/index.web.js +156 -0
- package/lib/components/ui/accordion/index.web.js.map +1 -0
- package/lib/components/ui/actionsheet/index.web.d.ts +872 -0
- package/lib/components/ui/actionsheet/index.web.js +286 -0
- package/lib/components/ui/actionsheet/index.web.js.map +1 -0
- package/lib/components/ui/alert/index.web.d.ts +135 -0
- package/lib/components/ui/alert/index.web.js +38 -0
- package/lib/components/ui/alert/index.web.js.map +1 -0
- package/lib/components/ui/alert-dialog/index.web.d.ts +64 -0
- package/lib/components/ui/alert-dialog/index.web.js +139 -0
- package/lib/components/ui/alert-dialog/index.web.js.map +1 -0
- package/lib/components/ui/avatar/index.web.d.ts +21 -0
- package/lib/components/ui/avatar/index.web.js +92 -0
- package/lib/components/ui/avatar/index.web.js.map +1 -0
- package/lib/components/ui/badge/index.web.d.ts +382 -0
- package/lib/components/ui/badge/index.web.js +138 -0
- package/lib/components/ui/badge/index.web.js.map +1 -0
- package/lib/components/ui/button/index.web.d.ts +247 -0
- package/lib/components/ui/button/index.web.js +57 -0
- package/lib/components/ui/button/index.web.js.map +1 -0
- package/lib/components/ui/checkbox/index.web.d.ts +265 -0
- package/lib/components/ui/checkbox/index.web.js +77 -0
- package/lib/components/ui/checkbox/index.web.js.map +1 -0
- package/lib/components/ui/divider/index.web.d.ts +53 -0
- package/lib/components/ui/divider/index.web.js +21 -0
- package/lib/components/ui/divider/index.web.js.map +1 -0
- package/lib/components/ui/drawer/index.web.d.ts +174 -0
- package/lib/components/ui/drawer/index.web.js +65 -0
- package/lib/components/ui/drawer/index.web.js.map +1 -0
- package/lib/components/ui/fab/index.web.d.ts +520 -0
- package/lib/components/ui/fab/index.web.js +146 -0
- package/lib/components/ui/fab/index.web.js.map +1 -0
- package/lib/components/ui/flat-list/index.web.d.ts +21 -0
- package/lib/components/ui/flat-list/index.web.js +41 -0
- package/lib/components/ui/flat-list/index.web.js.map +1 -0
- package/lib/components/ui/form-control/index.web.d.ts +2071 -0
- package/lib/components/ui/form-control/index.web.js +290 -0
- package/lib/components/ui/form-control/index.web.js.map +1 -0
- package/lib/components/ui/image/index.web.d.ts +142 -0
- package/lib/components/ui/image/index.web.js +29 -0
- package/lib/components/ui/image/index.web.js.map +1 -0
- package/lib/components/ui/image-background/index.web.d.ts +8 -0
- package/lib/components/ui/image-background/index.web.js +23 -0
- package/lib/components/ui/image-background/index.web.js.map +1 -0
- package/lib/components/ui/input/index.web.d.ts +163 -0
- package/lib/components/ui/input/index.web.js +50 -0
- package/lib/components/ui/input/index.web.js.map +1 -0
- package/lib/components/ui/input-accessory-view/index.web.d.ts +9 -0
- package/lib/components/ui/input-accessory-view/index.web.js +16 -0
- package/lib/components/ui/input-accessory-view/index.web.js.map +1 -0
- package/lib/components/ui/keyboard-avoiding-view/index.web.d.ts +9 -0
- package/lib/components/ui/keyboard-avoiding-view/index.web.js +8 -0
- package/lib/components/ui/keyboard-avoiding-view/index.web.js.map +1 -0
- package/lib/components/ui/link/index.web.d.ts +365 -0
- package/lib/components/ui/link/index.web.js +70 -0
- package/lib/components/ui/link/index.web.js.map +1 -0
- package/lib/components/ui/menu/index.web.d.ts +142 -0
- package/lib/components/ui/menu/index.web.js +83 -0
- package/lib/components/ui/menu/index.web.js.map +1 -0
- package/lib/components/ui/modal/index.web.d.ts +111 -0
- package/lib/components/ui/modal/index.web.js +58 -0
- package/lib/components/ui/modal/index.web.js.map +1 -0
- package/lib/components/ui/popover/index.web.d.ts +309 -0
- package/lib/components/ui/popover/index.web.js +184 -0
- package/lib/components/ui/popover/index.web.js.map +1 -0
- package/lib/components/ui/portal/index.web.d.ts +9 -0
- package/lib/components/ui/portal/index.web.js +16 -0
- package/lib/components/ui/portal/index.web.js.map +1 -0
- package/lib/components/ui/pressable/index.web.d.ts +8 -0
- package/lib/components/ui/pressable/index.web.js +44 -0
- package/lib/components/ui/pressable/index.web.js.map +1 -0
- package/lib/components/ui/progress/index.web.d.ts +237 -0
- package/lib/components/ui/progress/index.web.js +73 -0
- package/lib/components/ui/progress/index.web.js.map +1 -0
- package/lib/components/ui/radio/index.web.d.ts +224 -0
- package/lib/components/ui/radio/index.web.js +69 -0
- package/lib/components/ui/radio/index.web.js.map +1 -0
- package/lib/components/ui/refresh-control/index.web.d.ts +14 -0
- package/lib/components/ui/refresh-control/index.web.js +69 -0
- package/lib/components/ui/refresh-control/index.web.js.map +1 -0
- package/lib/components/ui/safe-area-view/index.web.d.ts +6 -0
- package/lib/components/ui/safe-area-view/index.web.js +10 -0
- package/lib/components/ui/safe-area-view/index.web.js.map +1 -0
- package/lib/components/ui/scroll-view/index.web.d.ts +44 -0
- package/lib/components/ui/scroll-view/index.web.js +41 -0
- package/lib/components/ui/scroll-view/index.web.js.map +1 -0
- package/lib/components/ui/section-list/index.web.d.ts +26 -0
- package/lib/components/ui/section-list/index.web.js +35 -0
- package/lib/components/ui/section-list/index.web.js.map +1 -0
- package/lib/components/ui/select/index.web.d.ts +162 -0
- package/lib/components/ui/select/index.web.js +51 -0
- package/lib/components/ui/select/index.web.js.map +1 -0
- package/lib/components/ui/slider/index.web.d.ts +223 -0
- package/lib/components/ui/slider/index.web.js +189 -0
- package/lib/components/ui/slider/index.web.js.map +1 -0
- package/lib/components/ui/spinner/index.web.d.ts +176 -0
- package/lib/components/ui/spinner/index.web.js +55 -0
- package/lib/components/ui/spinner/index.web.js.map +1 -0
- package/lib/components/ui/status-bar/index.web.d.ts +14 -0
- package/lib/components/ui/status-bar/index.web.js +7 -0
- package/lib/components/ui/status-bar/index.web.js.map +1 -0
- package/lib/components/ui/switch/index.web.d.ts +71 -0
- package/lib/components/ui/switch/index.web.js +27 -0
- package/lib/components/ui/switch/index.web.js.map +1 -0
- package/lib/components/ui/tabs/index.web.d.ts +351 -0
- package/lib/components/ui/tabs/index.web.js +120 -0
- package/lib/components/ui/tabs/index.web.js.map +1 -0
- package/lib/components/ui/textarea/index.web.d.ts +162 -0
- package/lib/components/ui/textarea/index.web.js +50 -0
- package/lib/components/ui/textarea/index.web.js.map +1 -0
- package/lib/components/ui/toast/index.web.d.ts +225 -0
- package/lib/components/ui/toast/index.web.js +80 -0
- package/lib/components/ui/toast/index.web.js.map +1 -0
- package/lib/components/ui/tooltip/index.web.d.ts +86 -0
- package/lib/components/ui/tooltip/index.web.js +110 -0
- package/lib/components/ui/tooltip/index.web.js.map +1 -0
- package/lib/components/ui/view/index.web.d.ts +2 -0
- package/lib/components/ui/view/index.web.js +7 -0
- package/lib/components/ui/view/index.web.js.map +1 -0
- package/lib/components/ui/virtualized-list/index.web.d.ts +19 -0
- package/lib/components/ui/virtualized-list/index.web.js +30 -0
- package/lib/components/ui/virtualized-list/index.web.js.map +1 -0
- package/lib/containers/layout/DrawerBottomNavigationConfig.d.ts +47 -47
- package/lib/containers/layout/DrawerConfig.d.ts +31 -31
- package/lib/interfaces/settings.d.ts +1 -0
- package/lib/redux/settings.d.ts +4 -9
- package/lib/utils/generateMobileNavigations.js +8 -8
- package/lib/utils/generateMobileNavigations.js.map +1 -1
- package/package.json +8 -4
- package/src/components/AuthWrapper.tsx +6 -3
- package/src/components/WithConfiguration.tsx +1 -1
- package/src/components/ui/accordion/index.web.tsx +294 -0
- package/src/components/ui/actionsheet/index.web.tsx +555 -0
- package/src/components/ui/alert/index.web.tsx +71 -0
- package/src/components/ui/alert-dialog/index.web.tsx +241 -0
- package/src/components/ui/avatar/index.web.tsx +150 -0
- package/src/components/ui/badge/index.web.tsx +188 -0
- package/src/components/ui/button/index.web.tsx +86 -0
- package/src/components/ui/checkbox/index.web.tsx +151 -0
- package/src/components/ui/divider/index.web.tsx +37 -0
- package/src/components/ui/drawer/index.web.tsx +144 -0
- package/src/components/ui/fab/index.web.tsx +201 -0
- package/src/components/ui/flat-list/index.web.tsx +89 -0
- package/src/components/ui/form-control/index.web.tsx +451 -0
- package/src/components/ui/image/index.web.tsx +43 -0
- package/src/components/ui/image-background/index.web.tsx +43 -0
- package/src/components/ui/input/index.web.tsx +80 -0
- package/src/components/ui/input-accessory-view/index.web.tsx +31 -0
- package/src/components/ui/keyboard-avoiding-view/index.web.tsx +23 -0
- package/src/components/ui/link/index.web.tsx +103 -0
- package/src/components/ui/menu/index.web.tsx +159 -0
- package/src/components/ui/modal/index.web.tsx +135 -0
- package/src/components/ui/popover/index.web.tsx +326 -0
- package/src/components/ui/portal/index.web.tsx +34 -0
- package/src/components/ui/pressable/index.web.tsx +73 -0
- package/src/components/ui/progress/index.web.tsx +123 -0
- package/src/components/ui/radio/index.web.tsx +130 -0
- package/src/components/ui/refresh-control/index.web.tsx +104 -0
- package/src/components/ui/safe-area-view/index.web.tsx +24 -0
- package/src/components/ui/scroll-view/index.web.tsx +142 -0
- package/src/components/ui/section-list/index.web.tsx +93 -0
- package/src/components/ui/select/index.web.tsx +83 -0
- package/src/components/ui/slider/index.web.tsx +283 -0
- package/src/components/ui/spinner/index.web.tsx +81 -0
- package/src/components/ui/status-bar/index.web.tsx +20 -0
- package/src/components/ui/switch/index.web.tsx +44 -0
- package/src/components/ui/tabs/index.web.tsx +205 -0
- package/src/components/ui/textarea/index.web.tsx +86 -0
- package/src/components/ui/toast/index.web.tsx +132 -0
- package/src/components/ui/tooltip/index.web.tsx +155 -0
- package/src/components/ui/view/index.web.tsx +15 -0
- package/src/components/ui/virtualized-list/index.web.tsx +84 -0
- package/src/interfaces/settings.ts +1 -0
- package/src/utils/generateMobileNavigations.ts +23 -23
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { forwardRef, createContext, useContext } from 'react';
|
|
3
|
+
import { tva } from '@gluestack-ui/nativewind-utils/tva';
|
|
4
|
+
import { withStyleContext } from '@gluestack-ui/nativewind-utils/withStyleContext';
|
|
5
|
+
import { cssInterop } from 'nativewind';
|
|
6
|
+
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
|
7
|
+
|
|
8
|
+
const SCOPE = 'CHECKBOX';
|
|
9
|
+
|
|
10
|
+
const checkboxStyle = tva({
|
|
11
|
+
base: 'form-checkbox rounded transition duration-150 ease-in-out',
|
|
12
|
+
variants: {
|
|
13
|
+
size: {
|
|
14
|
+
sm: 'h-3 w-3',
|
|
15
|
+
md: 'h-4 w-4',
|
|
16
|
+
lg: 'h-5 w-5',
|
|
17
|
+
},
|
|
18
|
+
variant: {
|
|
19
|
+
outline: 'border-2',
|
|
20
|
+
solid: 'bg-blue-600 border-transparent',
|
|
21
|
+
},
|
|
22
|
+
status: {
|
|
23
|
+
error: 'border-red-500 focus:border-red-500 focus:ring-red-500',
|
|
24
|
+
success: 'border-green-500 focus:border-green-500 focus:ring-green-500',
|
|
25
|
+
warning: 'border-yellow-500 focus:border-yellow-500 focus:ring-yellow-500',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
defaultVariants: {
|
|
29
|
+
size: 'md',
|
|
30
|
+
variant: 'outline',
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const labelStyle = tva({
|
|
35
|
+
base: 'ml-2 select-none',
|
|
36
|
+
variants: {
|
|
37
|
+
size: {
|
|
38
|
+
sm: 'text-sm',
|
|
39
|
+
md: 'text-base',
|
|
40
|
+
lg: 'text-lg',
|
|
41
|
+
},
|
|
42
|
+
disabled: {
|
|
43
|
+
true: 'opacity-50 cursor-not-allowed',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
defaultVariants: {
|
|
47
|
+
size: 'md',
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
type CheckboxGroupContextType = {
|
|
52
|
+
values?: string[];
|
|
53
|
+
onChange?: (values: string[]) => void;
|
|
54
|
+
size?: VariantProps<typeof checkboxStyle>['size'];
|
|
55
|
+
status?: VariantProps<typeof checkboxStyle>['status'];
|
|
56
|
+
variant?: VariantProps<typeof checkboxStyle>['variant'];
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const CheckboxGroupContext = createContext<CheckboxGroupContextType>({});
|
|
60
|
+
|
|
61
|
+
export const CheckboxGroup = forwardRef<HTMLDivElement, React.ComponentProps<'div'> & CheckboxGroupContextType>(
|
|
62
|
+
({ values, onChange, size, status, variant, ...props }, ref) => {
|
|
63
|
+
return (
|
|
64
|
+
<CheckboxGroupContext.Provider value={{ values, onChange, size, status, variant }}>
|
|
65
|
+
<div ref={ref} role="group" {...props} />
|
|
66
|
+
</CheckboxGroupContext.Provider>
|
|
67
|
+
);
|
|
68
|
+
},
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
CheckboxGroup.displayName = 'CheckboxGroup';
|
|
72
|
+
|
|
73
|
+
export const CheckboxLabel = forwardRef<
|
|
74
|
+
HTMLLabelElement,
|
|
75
|
+
React.ComponentProps<'label'> & {
|
|
76
|
+
size?: VariantProps<typeof labelStyle>['size'];
|
|
77
|
+
disabled?: boolean;
|
|
78
|
+
}
|
|
79
|
+
>(({ className, size, disabled, ...props }, ref) => {
|
|
80
|
+
return <label ref={ref} className={labelStyle({ size, disabled, class: className })} {...props} />;
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
CheckboxLabel.displayName = 'CheckboxLabel';
|
|
84
|
+
|
|
85
|
+
export const CheckboxIcon = forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(
|
|
86
|
+
({ className, children, ...props }, ref) => {
|
|
87
|
+
return (
|
|
88
|
+
<div ref={ref} className={`flex items-center justify-center ${className || ''}`} {...props}>
|
|
89
|
+
{children}
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
},
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
CheckboxIcon.displayName = 'CheckboxIcon';
|
|
96
|
+
|
|
97
|
+
type ICheckboxProps = Omit<React.ComponentProps<'input'>, 'size'> & {
|
|
98
|
+
value: string;
|
|
99
|
+
size?: VariantProps<typeof checkboxStyle>['size'];
|
|
100
|
+
status?: VariantProps<typeof checkboxStyle>['status'];
|
|
101
|
+
variant?: VariantProps<typeof checkboxStyle>['variant'];
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
const Checkbox = forwardRef<HTMLInputElement, ICheckboxProps>(
|
|
105
|
+
(
|
|
106
|
+
{
|
|
107
|
+
className,
|
|
108
|
+
value,
|
|
109
|
+
size: itemSize,
|
|
110
|
+
status: itemStatus,
|
|
111
|
+
variant: itemVariant,
|
|
112
|
+
onChange,
|
|
113
|
+
checked: controlledChecked,
|
|
114
|
+
...props
|
|
115
|
+
},
|
|
116
|
+
ref,
|
|
117
|
+
) => {
|
|
118
|
+
const group = useContext(CheckboxGroupContext);
|
|
119
|
+
const size = itemSize || group.size;
|
|
120
|
+
const status = itemStatus || group.status;
|
|
121
|
+
const variant = itemVariant || group.variant;
|
|
122
|
+
|
|
123
|
+
const isChecked = group.values ? group.values.includes(value) : controlledChecked;
|
|
124
|
+
|
|
125
|
+
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
126
|
+
if (onChange) {
|
|
127
|
+
onChange(e);
|
|
128
|
+
}
|
|
129
|
+
if (group.onChange && group.values) {
|
|
130
|
+
const newValues = e.target.checked ? [...group.values, value] : group.values.filter((v) => v !== value);
|
|
131
|
+
group.onChange(newValues);
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<input
|
|
137
|
+
ref={ref}
|
|
138
|
+
type="checkbox"
|
|
139
|
+
value={value}
|
|
140
|
+
checked={isChecked}
|
|
141
|
+
onChange={handleChange}
|
|
142
|
+
className={checkboxStyle({ size, status, variant, class: className })}
|
|
143
|
+
{...props}
|
|
144
|
+
/>
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
Checkbox.displayName = 'Checkbox';
|
|
150
|
+
|
|
151
|
+
export { Checkbox };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { tva } from '@gluestack-ui/nativewind-utils/tva';
|
|
4
|
+
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
|
5
|
+
|
|
6
|
+
const dividerStyle = tva({
|
|
7
|
+
base: 'bg-background-200',
|
|
8
|
+
variants: {
|
|
9
|
+
orientation: {
|
|
10
|
+
vertical: 'w-px h-full',
|
|
11
|
+
horizontal: 'h-px w-full',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
type IUIDividerProps = React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof dividerStyle>;
|
|
17
|
+
|
|
18
|
+
const Divider = React.forwardRef<HTMLDivElement, IUIDividerProps>(
|
|
19
|
+
({ className, orientation = 'horizontal', ...props }, ref) => {
|
|
20
|
+
return (
|
|
21
|
+
<div
|
|
22
|
+
ref={ref}
|
|
23
|
+
{...props}
|
|
24
|
+
aria-orientation={orientation}
|
|
25
|
+
role="separator"
|
|
26
|
+
className={dividerStyle({
|
|
27
|
+
orientation,
|
|
28
|
+
class: className,
|
|
29
|
+
})}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
Divider.displayName = 'Divider';
|
|
36
|
+
|
|
37
|
+
export { Divider };
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { forwardRef, useEffect, useRef } from 'react';
|
|
3
|
+
import { tva } from '@gluestack-ui/nativewind-utils/tva';
|
|
4
|
+
import { withStyleContext } from '@gluestack-ui/nativewind-utils/withStyleContext';
|
|
5
|
+
import { cssInterop } from 'nativewind';
|
|
6
|
+
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
|
7
|
+
import { createPortal } from 'react-dom';
|
|
8
|
+
|
|
9
|
+
const SCOPE = 'DRAWER';
|
|
10
|
+
|
|
11
|
+
interface DrawerOverlayProps {
|
|
12
|
+
onPress?: () => void;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const DrawerOverlay = ({ onPress, className }: DrawerOverlayProps) => (
|
|
17
|
+
<div
|
|
18
|
+
onClick={onPress}
|
|
19
|
+
className={`fixed inset-0 bg-black bg-opacity-40 transition-opacity ${className || ''}`}
|
|
20
|
+
aria-hidden="true"
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
const drawerStyle = tva({
|
|
25
|
+
base: 'fixed bg-white shadow-xl transition-transform duration-300 ease-in-out',
|
|
26
|
+
variants: {
|
|
27
|
+
placement: {
|
|
28
|
+
left: 'left-0 top-0 bottom-0 transform -translate-x-full',
|
|
29
|
+
right: 'right-0 top-0 bottom-0 transform translate-x-full',
|
|
30
|
+
top: 'top-0 left-0 right-0 transform -translate-y-full',
|
|
31
|
+
bottom: 'bottom-0 left-0 right-0 transform translate-y-full',
|
|
32
|
+
},
|
|
33
|
+
size: {
|
|
34
|
+
xs: 'w-[95%] max-w-xs',
|
|
35
|
+
sm: 'w-[95%] max-w-sm',
|
|
36
|
+
md: 'w-[95%] max-w-md',
|
|
37
|
+
lg: 'w-[95%] max-w-lg',
|
|
38
|
+
xl: 'w-[95%] max-w-xl',
|
|
39
|
+
full: 'w-full',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
defaultVariants: {
|
|
43
|
+
placement: 'right',
|
|
44
|
+
size: 'md',
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export const DrawerContent = forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(({ className, ...props }, ref) => (
|
|
49
|
+
<div ref={ref} className={`h-full flex flex-col ${className || ''}`} {...props} />
|
|
50
|
+
));
|
|
51
|
+
|
|
52
|
+
DrawerContent.displayName = 'DrawerContent';
|
|
53
|
+
|
|
54
|
+
export const DrawerHeader = forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(({ className, ...props }, ref) => (
|
|
55
|
+
<div ref={ref} className={`px-6 py-4 border-b border-gray-200 ${className || ''}`} {...props} />
|
|
56
|
+
));
|
|
57
|
+
|
|
58
|
+
DrawerHeader.displayName = 'DrawerHeader';
|
|
59
|
+
|
|
60
|
+
export const DrawerBody = forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(({ className, ...props }, ref) => (
|
|
61
|
+
<div ref={ref} className={`flex-1 p-6 overflow-y-auto ${className || ''}`} {...props} />
|
|
62
|
+
));
|
|
63
|
+
|
|
64
|
+
DrawerBody.displayName = 'DrawerBody';
|
|
65
|
+
|
|
66
|
+
export const DrawerFooter = forwardRef<HTMLDivElement, React.ComponentProps<'div'>>(({ className, ...props }, ref) => (
|
|
67
|
+
<div ref={ref} className={`px-6 py-4 border-t border-gray-200 ${className || ''}`} {...props} />
|
|
68
|
+
));
|
|
69
|
+
|
|
70
|
+
DrawerFooter.displayName = 'DrawerFooter';
|
|
71
|
+
|
|
72
|
+
export const DrawerCloseButton = forwardRef<HTMLButtonElement, React.ComponentProps<'button'>>(
|
|
73
|
+
({ className, onClick, ...props }, ref) => (
|
|
74
|
+
<button
|
|
75
|
+
ref={ref}
|
|
76
|
+
className={`absolute right-4 top-4 text-gray-400 hover:text-gray-600 ${className || ''}`}
|
|
77
|
+
onClick={onClick}
|
|
78
|
+
aria-label="Close drawer"
|
|
79
|
+
{...props}
|
|
80
|
+
>
|
|
81
|
+
×
|
|
82
|
+
</button>
|
|
83
|
+
),
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
DrawerCloseButton.displayName = 'DrawerCloseButton';
|
|
87
|
+
|
|
88
|
+
type IDrawerProps = {
|
|
89
|
+
isOpen?: boolean;
|
|
90
|
+
onClose?: () => void;
|
|
91
|
+
children?: React.ReactNode;
|
|
92
|
+
className?: string;
|
|
93
|
+
placement?: VariantProps<typeof drawerStyle>['placement'];
|
|
94
|
+
size?: VariantProps<typeof drawerStyle>['size'];
|
|
95
|
+
closeOnOverlayClick?: boolean;
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const Drawer = forwardRef<HTMLDivElement, IDrawerProps>(
|
|
99
|
+
({ isOpen, onClose, children, className, placement, size, closeOnOverlayClick = true, ...props }, ref) => {
|
|
100
|
+
const drawerRef = useRef<HTMLDivElement>(null);
|
|
101
|
+
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
const handleEscape = (event: KeyboardEvent) => {
|
|
104
|
+
if (event.key === 'Escape' && onClose) {
|
|
105
|
+
onClose();
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
if (isOpen) {
|
|
110
|
+
document.addEventListener('keydown', handleEscape);
|
|
111
|
+
document.body.style.overflow = 'hidden';
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
return () => {
|
|
115
|
+
document.removeEventListener('keydown', handleEscape);
|
|
116
|
+
document.body.style.overflow = '';
|
|
117
|
+
};
|
|
118
|
+
}, [isOpen, onClose]);
|
|
119
|
+
|
|
120
|
+
if (!isOpen) return null;
|
|
121
|
+
|
|
122
|
+
return createPortal(
|
|
123
|
+
<>
|
|
124
|
+
<DrawerOverlay onPress={closeOnOverlayClick ? onClose : undefined} />
|
|
125
|
+
<div
|
|
126
|
+
ref={ref}
|
|
127
|
+
className={`${drawerStyle({ placement, size, class: className })} ${
|
|
128
|
+
isOpen ? 'translate-x-0 translate-y-0' : ''
|
|
129
|
+
}`}
|
|
130
|
+
role="dialog"
|
|
131
|
+
aria-modal="true"
|
|
132
|
+
{...props}
|
|
133
|
+
>
|
|
134
|
+
{children}
|
|
135
|
+
</div>
|
|
136
|
+
</>,
|
|
137
|
+
document.body,
|
|
138
|
+
);
|
|
139
|
+
},
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
Drawer.displayName = 'Drawer';
|
|
143
|
+
|
|
144
|
+
export { Drawer };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { createFab } from '@gluestack-ui/fab';
|
|
4
|
+
import { tva } from '@gluestack-ui/nativewind-utils/tva';
|
|
5
|
+
import { withStyleContext, useStyleContext } from '@gluestack-ui/nativewind-utils/withStyleContext';
|
|
6
|
+
import { cssInterop } from 'nativewind';
|
|
7
|
+
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
|
8
|
+
import { PrimitiveIcon, UIIcon } from '@gluestack-ui/icon';
|
|
9
|
+
|
|
10
|
+
const SCOPE = 'FAB';
|
|
11
|
+
|
|
12
|
+
// Create styled components for web
|
|
13
|
+
const StyledButton = React.forwardRef<HTMLButtonElement, React.ButtonHTMLAttributes<HTMLButtonElement>>(
|
|
14
|
+
(props, ref) => <button ref={ref} {...props} />,
|
|
15
|
+
);
|
|
16
|
+
StyledButton.displayName = 'StyledButton';
|
|
17
|
+
|
|
18
|
+
const StyledSpan = React.forwardRef<HTMLSpanElement, React.HTMLAttributes<HTMLSpanElement>>((props, ref) => (
|
|
19
|
+
<span ref={ref} {...props} />
|
|
20
|
+
));
|
|
21
|
+
StyledSpan.displayName = 'StyledSpan';
|
|
22
|
+
|
|
23
|
+
const Root = withStyleContext(StyledButton, SCOPE);
|
|
24
|
+
const UIFab = createFab({
|
|
25
|
+
Root: Root,
|
|
26
|
+
Label: StyledSpan,
|
|
27
|
+
Icon: UIIcon,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
cssInterop(PrimitiveIcon, {
|
|
31
|
+
className: {
|
|
32
|
+
target: 'style',
|
|
33
|
+
nativeStyleToProp: {
|
|
34
|
+
height: true,
|
|
35
|
+
width: true,
|
|
36
|
+
fill: true,
|
|
37
|
+
color: 'classNameColor',
|
|
38
|
+
stroke: true,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const fabStyle = tva({
|
|
44
|
+
base: 'group/fab bg-primary-500 rounded-full z-20 p-4 flex-row items-center justify-center absolute hover:bg-primary-600 active:bg-primary-700 disabled:opacity-40 disabled:pointer-events-all disabled:cursor-not-allowed data-[focus=true]:web:outline-none data-[focus-visible=true]:web:ring-2 data-[focus-visible=true]:web:ring-indicator-info shadow-hard-2 border-0',
|
|
45
|
+
variants: {
|
|
46
|
+
size: {
|
|
47
|
+
sm: 'px-2.5 py-2.5',
|
|
48
|
+
md: 'px-3 py-3',
|
|
49
|
+
lg: 'px-4 py-4',
|
|
50
|
+
},
|
|
51
|
+
placement: {
|
|
52
|
+
'top right': 'top-4 right-4',
|
|
53
|
+
'top left': 'top-4 left-4',
|
|
54
|
+
'bottom right': 'bottom-4 right-4',
|
|
55
|
+
'bottom left': 'bottom-4 left-4',
|
|
56
|
+
'top center': 'top-4 self-center',
|
|
57
|
+
'bottom center': 'bottom-4 self-center',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
const fabLabelStyle = tva({
|
|
63
|
+
base: 'text-typography-50 font-normal font-body tracking-md text-left mx-2',
|
|
64
|
+
variants: {
|
|
65
|
+
isTruncated: {
|
|
66
|
+
true: 'truncate',
|
|
67
|
+
},
|
|
68
|
+
bold: {
|
|
69
|
+
true: 'font-bold',
|
|
70
|
+
},
|
|
71
|
+
underline: {
|
|
72
|
+
true: 'underline',
|
|
73
|
+
},
|
|
74
|
+
strikeThrough: {
|
|
75
|
+
true: 'line-through',
|
|
76
|
+
},
|
|
77
|
+
size: {
|
|
78
|
+
'2xs': 'text-2xs',
|
|
79
|
+
xs: 'text-xs',
|
|
80
|
+
sm: 'text-sm',
|
|
81
|
+
md: 'text-base',
|
|
82
|
+
lg: 'text-lg',
|
|
83
|
+
xl: 'text-xl',
|
|
84
|
+
'2xl': 'text-2xl',
|
|
85
|
+
'3xl': 'text-3xl',
|
|
86
|
+
'4xl': 'text-4xl',
|
|
87
|
+
'5xl': 'text-5xl',
|
|
88
|
+
'6xl': 'text-6xl',
|
|
89
|
+
},
|
|
90
|
+
sub: {
|
|
91
|
+
true: 'text-xs',
|
|
92
|
+
},
|
|
93
|
+
italic: {
|
|
94
|
+
true: 'italic',
|
|
95
|
+
},
|
|
96
|
+
highlight: {
|
|
97
|
+
true: 'bg-yellow-500',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
parentVariants: {
|
|
101
|
+
size: {
|
|
102
|
+
sm: 'text-sm',
|
|
103
|
+
md: 'text-base',
|
|
104
|
+
lg: 'text-lg',
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const fabIconStyle = tva({
|
|
110
|
+
base: 'text-typography-50 fill-none',
|
|
111
|
+
variants: {
|
|
112
|
+
size: {
|
|
113
|
+
'2xs': 'h-3 w-3',
|
|
114
|
+
xs: 'h-3.5 w-3.5',
|
|
115
|
+
sm: 'h-4 w-4',
|
|
116
|
+
md: 'w-[18px] h-[18px]',
|
|
117
|
+
lg: 'h-5 w-5',
|
|
118
|
+
xl: 'h-6 w-6',
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
type IFabProps = Omit<React.ComponentPropsWithoutRef<typeof UIFab>, 'context'> & VariantProps<typeof fabStyle>;
|
|
124
|
+
|
|
125
|
+
const Fab = React.forwardRef<React.ElementRef<typeof UIFab>, IFabProps>(
|
|
126
|
+
({ size = 'md', placement = 'bottom right', className, ...props }, ref) => {
|
|
127
|
+
return (
|
|
128
|
+
<UIFab
|
|
129
|
+
ref={ref}
|
|
130
|
+
{...props}
|
|
131
|
+
className={fabStyle({ size, placement, class: className })}
|
|
132
|
+
context={{ size }}
|
|
133
|
+
/>
|
|
134
|
+
);
|
|
135
|
+
},
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
type IFabLabelProps = React.ComponentPropsWithoutRef<typeof UIFab.Label> & VariantProps<typeof fabLabelStyle>;
|
|
139
|
+
|
|
140
|
+
const FabLabel = React.forwardRef<React.ElementRef<typeof UIFab.Label>, IFabLabelProps>(
|
|
141
|
+
(
|
|
142
|
+
{ size, isTruncated = false, bold = false, underline = false, strikeThrough = false, className, ...props },
|
|
143
|
+
ref,
|
|
144
|
+
) => {
|
|
145
|
+
const { size: parentSize } = useStyleContext(SCOPE);
|
|
146
|
+
return (
|
|
147
|
+
<UIFab.Label
|
|
148
|
+
ref={ref}
|
|
149
|
+
{...props}
|
|
150
|
+
className={fabLabelStyle({
|
|
151
|
+
parentVariants: {
|
|
152
|
+
size: parentSize,
|
|
153
|
+
},
|
|
154
|
+
size,
|
|
155
|
+
isTruncated,
|
|
156
|
+
bold,
|
|
157
|
+
underline,
|
|
158
|
+
strikeThrough,
|
|
159
|
+
class: className,
|
|
160
|
+
})}
|
|
161
|
+
/>
|
|
162
|
+
);
|
|
163
|
+
},
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
type IFabIconProps = React.ComponentPropsWithoutRef<typeof UIFab.Icon> &
|
|
167
|
+
VariantProps<typeof fabIconStyle> & {
|
|
168
|
+
height?: number;
|
|
169
|
+
width?: number;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const FabIcon = React.forwardRef<React.ElementRef<typeof UIFab.Icon>, IFabIconProps>(
|
|
173
|
+
({ size, className, ...props }, ref) => {
|
|
174
|
+
const { size: parentSize } = useStyleContext(SCOPE);
|
|
175
|
+
|
|
176
|
+
if (typeof size === 'number') {
|
|
177
|
+
return <UIFab.Icon ref={ref} {...props} className={fabIconStyle({ class: className })} size={size} />;
|
|
178
|
+
} else if ((props.height !== undefined || props.width !== undefined) && size === undefined) {
|
|
179
|
+
return <UIFab.Icon ref={ref} {...props} className={fabIconStyle({ class: className })} />;
|
|
180
|
+
}
|
|
181
|
+
return (
|
|
182
|
+
<UIFab.Icon
|
|
183
|
+
ref={ref}
|
|
184
|
+
{...props}
|
|
185
|
+
className={fabIconStyle({
|
|
186
|
+
parentVariants: {
|
|
187
|
+
size: parentSize,
|
|
188
|
+
},
|
|
189
|
+
size,
|
|
190
|
+
class: className,
|
|
191
|
+
})}
|
|
192
|
+
/>
|
|
193
|
+
);
|
|
194
|
+
},
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
Fab.displayName = 'Fab';
|
|
198
|
+
FabLabel.displayName = 'FabLabel';
|
|
199
|
+
FabIcon.displayName = 'FabIcon';
|
|
200
|
+
|
|
201
|
+
export { Fab, FabLabel, FabIcon };
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import React, { forwardRef } from 'react';
|
|
3
|
+
import { tva } from '@gluestack-ui/nativewind-utils/tva';
|
|
4
|
+
import { withStyleContext } from '@gluestack-ui/nativewind-utils/withStyleContext';
|
|
5
|
+
import { cssInterop } from 'nativewind';
|
|
6
|
+
import type { VariantProps } from '@gluestack-ui/nativewind-utils';
|
|
7
|
+
import { ScrollView } from '../scroll-view/index.web';
|
|
8
|
+
|
|
9
|
+
const flatListStyle = tva({
|
|
10
|
+
base: 'flex flex-col',
|
|
11
|
+
variants: {
|
|
12
|
+
horizontal: {
|
|
13
|
+
true: 'flex-row',
|
|
14
|
+
false: 'flex-col',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
defaultVariants: {
|
|
18
|
+
horizontal: false,
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
interface FlatListProps<T> {
|
|
23
|
+
data: ReadonlyArray<T>;
|
|
24
|
+
renderItem: ({ item, index }: { item: T; index: number }) => React.ReactElement;
|
|
25
|
+
keyExtractor?: (item: T, index: number) => string;
|
|
26
|
+
horizontal?: boolean;
|
|
27
|
+
className?: string;
|
|
28
|
+
contentContainerStyle?: React.CSSProperties;
|
|
29
|
+
ListHeaderComponent?: React.ReactElement | null;
|
|
30
|
+
ListFooterComponent?: React.ReactElement | null;
|
|
31
|
+
ListEmptyComponent?: React.ReactElement | null;
|
|
32
|
+
onEndReached?: () => void;
|
|
33
|
+
onEndReachedThreshold?: number;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function FlatListComponent<T>(
|
|
37
|
+
{
|
|
38
|
+
data,
|
|
39
|
+
renderItem,
|
|
40
|
+
keyExtractor,
|
|
41
|
+
horizontal = false,
|
|
42
|
+
className,
|
|
43
|
+
contentContainerStyle,
|
|
44
|
+
ListHeaderComponent,
|
|
45
|
+
ListFooterComponent,
|
|
46
|
+
ListEmptyComponent,
|
|
47
|
+
onEndReached,
|
|
48
|
+
onEndReachedThreshold = 0.5,
|
|
49
|
+
...props
|
|
50
|
+
}: FlatListProps<T>,
|
|
51
|
+
ref: React.Ref<HTMLDivElement>,
|
|
52
|
+
) {
|
|
53
|
+
const handleScroll = (event: React.UIEvent<HTMLDivElement>) => {
|
|
54
|
+
if (!onEndReached) return;
|
|
55
|
+
|
|
56
|
+
const target = event.target as HTMLDivElement;
|
|
57
|
+
const scrollPosition = horizontal
|
|
58
|
+
? target.scrollLeft + target.clientWidth
|
|
59
|
+
: target.scrollTop + target.clientHeight;
|
|
60
|
+
const scrollSize = horizontal ? target.scrollWidth : target.scrollHeight;
|
|
61
|
+
const threshold = scrollSize * onEndReachedThreshold;
|
|
62
|
+
|
|
63
|
+
if (scrollSize - scrollPosition <= threshold) {
|
|
64
|
+
onEndReached();
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<ScrollView ref={ref} horizontal={horizontal} className={className} onScroll={handleScroll} {...props}>
|
|
70
|
+
<div className={flatListStyle({ horizontal })} style={contentContainerStyle}>
|
|
71
|
+
{ListHeaderComponent}
|
|
72
|
+
{data.length === 0 && ListEmptyComponent
|
|
73
|
+
? ListEmptyComponent
|
|
74
|
+
: data.map((item, index) => (
|
|
75
|
+
<React.Fragment key={keyExtractor ? keyExtractor(item, index) : index}>
|
|
76
|
+
{renderItem({ item, index })}
|
|
77
|
+
</React.Fragment>
|
|
78
|
+
))}
|
|
79
|
+
{ListFooterComponent}
|
|
80
|
+
</div>
|
|
81
|
+
</ScrollView>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const FlatList = React.forwardRef(FlatListComponent) as <T>(
|
|
86
|
+
props: FlatListProps<T> & { ref?: React.Ref<HTMLDivElement> },
|
|
87
|
+
) => React.ReactElement;
|
|
88
|
+
|
|
89
|
+
export { FlatList };
|