panelui-native 0.113.1 → 0.115.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/lib/module/components/camera/camera-model.js +142 -0
- package/lib/module/components/camera/camera-model.js.map +1 -0
- package/lib/module/components/camera/index.js +1546 -0
- package/lib/module/components/camera/index.js.map +1 -0
- package/lib/module/components/image-viewer/image-viewer-geometry.js +15 -0
- package/lib/module/components/image-viewer/image-viewer-geometry.js.map +1 -1
- package/lib/module/components/image-viewer/index.js +101 -37
- package/lib/module/components/image-viewer/index.js.map +1 -1
- package/lib/module/components/tabs/index.js +19 -7
- package/lib/module/components/tabs/index.js.map +1 -1
- package/lib/module/icons/index.js +20 -0
- package/lib/module/icons/index.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/components/camera/camera-model.d.ts +79 -0
- package/lib/typescript/src/components/camera/camera-model.d.ts.map +1 -0
- package/lib/typescript/src/components/camera/index.d.ts +481 -0
- package/lib/typescript/src/components/camera/index.d.ts.map +1 -0
- package/lib/typescript/src/components/image-viewer/image-viewer-geometry.d.ts +9 -0
- package/lib/typescript/src/components/image-viewer/image-viewer-geometry.d.ts.map +1 -1
- package/lib/typescript/src/components/image-viewer/index.d.ts +10 -3
- package/lib/typescript/src/components/image-viewer/index.d.ts.map +1 -1
- package/lib/typescript/src/components/tabs/index.d.ts +24 -2
- package/lib/typescript/src/components/tabs/index.d.ts.map +1 -1
- package/lib/typescript/src/icons/index.d.ts +4 -0
- package/lib/typescript/src/icons/index.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +2 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/components/camera/camera-model.ts +140 -0
- package/src/components/camera/index.tsx +1880 -0
- package/src/components/image-viewer/image-viewer-geometry.ts +15 -0
- package/src/components/image-viewer/index.tsx +122 -43
- package/src/components/tabs/index.tsx +48 -8
- package/src/icons/index.tsx +8 -0
- package/src/index.ts +36 -0
|
@@ -151,6 +151,21 @@ export function snapPage(
|
|
|
151
151
|
return clamp(clamp(target, current - 1, current + 1), 0, count - 1);
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
+
/** What a one-finger drag on a picture at its fitted size is for. */
|
|
155
|
+
export type DragIntent = 'undecided' | 'page' | 'dismiss';
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Sideways across a gallery turns the page; anything else drags the picture
|
|
159
|
+
* away. A drag that has not moved yet is `undecided`: some gesture-handler
|
|
160
|
+
* versions report the activating event with no translation at all, and
|
|
161
|
+
* comparing zero with zero would take every swipe as a dismiss.
|
|
162
|
+
*/
|
|
163
|
+
export function dragIntent(translationX: number, translationY: number, count: number): DragIntent {
|
|
164
|
+
'worklet';
|
|
165
|
+
if (translationX === 0 && translationY === 0) return 'undecided';
|
|
166
|
+
return count > 1 && Math.abs(translationX) > Math.abs(translationY) ? 'page' : 'dismiss';
|
|
167
|
+
}
|
|
168
|
+
|
|
154
169
|
/** How far a drag has to travel, counting where it was flung, to close the viewer. */
|
|
155
170
|
export const DISMISS_DISTANCE = 110;
|
|
156
171
|
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
* ## One gesture surface, decided at the start
|
|
45
45
|
*
|
|
46
46
|
* Pinching, panning a zoomed image, turning the page and dragging to dismiss all
|
|
47
|
-
* begin as a one- or two-finger drag, and which one it is gets decided
|
|
48
|
-
*
|
|
47
|
+
* begin as a one- or two-finger drag, and which one it is gets decided as
|
|
48
|
+
* soon as it moves: two fingers zoom, one finger on a zoomed image pans it, one
|
|
49
49
|
* finger moving sideways across a gallery turns the page, and anything else
|
|
50
50
|
* drags the image away. Deciding once keeps a drag from changing its mind
|
|
51
51
|
* halfway, which is what makes a viewer feel loose.
|
|
@@ -105,6 +105,7 @@ import {
|
|
|
105
105
|
clamp,
|
|
106
106
|
coverSize,
|
|
107
107
|
dragFade,
|
|
108
|
+
dragIntent,
|
|
108
109
|
dragScale,
|
|
109
110
|
fitWithin,
|
|
110
111
|
focalTranslation,
|
|
@@ -155,10 +156,15 @@ const PHASE_OPENING = 0;
|
|
|
155
156
|
const PHASE_OPEN = 1;
|
|
156
157
|
const PHASE_CLOSING = 2;
|
|
157
158
|
|
|
159
|
+
/** Pins a subtree's `left` to the screen's left under a right-to-left layout. */
|
|
160
|
+
const PHYSICAL = { direction: 'ltr' } as const;
|
|
161
|
+
|
|
158
162
|
const MODE_NONE = 0;
|
|
159
163
|
const MODE_PAN = 1;
|
|
160
164
|
const MODE_PAGE = 2;
|
|
161
165
|
const MODE_DISMISS = 3;
|
|
166
|
+
/** The pan has started but not yet moved, so there is no direction to decide on. */
|
|
167
|
+
const MODE_UNDECIDED = 4;
|
|
162
168
|
|
|
163
169
|
/* -------------------------------------------------------------------------- */
|
|
164
170
|
/* Registry */
|
|
@@ -280,6 +286,13 @@ export interface ImageViewerProps {
|
|
|
280
286
|
* screen while the picture is zoomed or dragged. `0` squares them.
|
|
281
287
|
*/
|
|
282
288
|
cornerRadius?: number;
|
|
289
|
+
/**
|
|
290
|
+
* Which way the gallery runs. In `rtl` the next page sits to the left and a
|
|
291
|
+
* swipe to the right turns to it. Page numbers, `index` and the screen
|
|
292
|
+
* reader's next and previous stay in page order either way. To follow the
|
|
293
|
+
* reading direction, pass `useDirection()`.
|
|
294
|
+
*/
|
|
295
|
+
dir?: 'ltr' | 'rtl';
|
|
283
296
|
}
|
|
284
297
|
|
|
285
298
|
function ImageViewerRoot({
|
|
@@ -298,6 +311,7 @@ function ImageViewerRoot({
|
|
|
298
311
|
closeLabel = 'Close',
|
|
299
312
|
inset = DEFAULT_INSET,
|
|
300
313
|
cornerRadius = DEFAULT_CORNER_RADIUS,
|
|
314
|
+
dir = 'ltr',
|
|
301
315
|
}: ImageViewerProps) {
|
|
302
316
|
const storeRef = useRef<ViewerStore | null>(null);
|
|
303
317
|
storeRef.current ??= new ViewerStore();
|
|
@@ -364,6 +378,7 @@ function ImageViewerRoot({
|
|
|
364
378
|
closeLabel={closeLabel}
|
|
365
379
|
inset={inset}
|
|
366
380
|
cornerRadius={cornerRadius}
|
|
381
|
+
sign={dir === 'rtl' ? -1 : 1}
|
|
367
382
|
/>
|
|
368
383
|
</ModalPortal>
|
|
369
384
|
) : null}
|
|
@@ -584,6 +599,8 @@ interface ViewerOverlayProps {
|
|
|
584
599
|
closeLabel: string;
|
|
585
600
|
inset: number;
|
|
586
601
|
cornerRadius: number;
|
|
602
|
+
/** `-1` when the pages run right to left. */
|
|
603
|
+
sign: 1 | -1;
|
|
587
604
|
}
|
|
588
605
|
|
|
589
606
|
function ViewerOverlay({
|
|
@@ -602,6 +619,7 @@ function ViewerOverlay({
|
|
|
602
619
|
closeLabel,
|
|
603
620
|
inset,
|
|
604
621
|
cornerRadius,
|
|
622
|
+
sign,
|
|
605
623
|
}: ViewerOverlayProps) {
|
|
606
624
|
const version = useSyncExternalStore(store.subscribe, store.getSnapshot);
|
|
607
625
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -662,7 +680,7 @@ function ViewerOverlay({
|
|
|
662
680
|
const shrink = useSharedValue(1);
|
|
663
681
|
const fade = useSharedValue(1);
|
|
664
682
|
|
|
665
|
-
// The gallery.
|
|
683
|
+
// The gallery, in page order: `sign` mirrors it on the way to the screen.
|
|
666
684
|
const pagerX = useSharedValue(-page * pageWidth);
|
|
667
685
|
const pagerStart = useSharedValue(0);
|
|
668
686
|
const activePage = useSharedValue(page);
|
|
@@ -730,6 +748,19 @@ function ViewerOverlay({
|
|
|
730
748
|
[chrome, dragX, dragY, gestureMode, onExited, phase, reduced, scale, shrink, t, tx, ty]
|
|
731
749
|
);
|
|
732
750
|
|
|
751
|
+
/**
|
|
752
|
+
* A drag or a tap outside closing the viewer. Measured again first, like a
|
|
753
|
+
* close from `open`: the measure taken when the page turned can predate the
|
|
754
|
+
* owner scrolling the new page's thumbnail into place.
|
|
755
|
+
*/
|
|
756
|
+
const closeFromGesture = useCallback(
|
|
757
|
+
(velocityX: number, velocityY: number) => {
|
|
758
|
+
measureCurrent(() => runOnUI(startClose)(velocityX, velocityY));
|
|
759
|
+
onRequestClose();
|
|
760
|
+
},
|
|
761
|
+
[measureCurrent, onRequestClose, startClose]
|
|
762
|
+
);
|
|
763
|
+
|
|
733
764
|
const settleOpen = useCallback(() => {
|
|
734
765
|
phase.value = PHASE_OPENING;
|
|
735
766
|
const done = (finished?: boolean) => {
|
|
@@ -880,6 +911,62 @@ function ViewerOverlay({
|
|
|
880
911
|
settleZoom();
|
|
881
912
|
});
|
|
882
913
|
|
|
914
|
+
const decide = (translationX: number, translationY: number) => {
|
|
915
|
+
'worklet';
|
|
916
|
+
const intent = dragIntent(translationX, translationY, count);
|
|
917
|
+
if (intent === 'undecided') {
|
|
918
|
+
gestureMode.value = MODE_UNDECIDED;
|
|
919
|
+
return;
|
|
920
|
+
}
|
|
921
|
+
if (intent === 'page') {
|
|
922
|
+
gestureMode.value = MODE_PAGE;
|
|
923
|
+
cancelAnimation(pagerX);
|
|
924
|
+
pagerStart.value = pagerX.value;
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
gestureMode.value = MODE_DISMISS;
|
|
928
|
+
chrome.value = withTiming(0, { duration: 120 });
|
|
929
|
+
if (haptics) runOnJS(selectionTick)();
|
|
930
|
+
};
|
|
931
|
+
|
|
932
|
+
/**
|
|
933
|
+
* Decides a pan that activated without moving, from the first event that
|
|
934
|
+
* has. Only while the viewer is still open and no pinch has started since:
|
|
935
|
+
* a close or a second finger arriving first leaves the drag doing nothing.
|
|
936
|
+
*/
|
|
937
|
+
const resolve = (translationX: number, translationY: number) => {
|
|
938
|
+
'worklet';
|
|
939
|
+
if (gestureMode.value !== MODE_UNDECIDED) return;
|
|
940
|
+
if (phase.value !== PHASE_OPEN || pinching.value) {
|
|
941
|
+
gestureMode.value = MODE_NONE;
|
|
942
|
+
return;
|
|
943
|
+
}
|
|
944
|
+
decide(translationX, translationY);
|
|
945
|
+
};
|
|
946
|
+
|
|
947
|
+
/** Moves whatever the drag was decided to move. */
|
|
948
|
+
const follow = (translationX: number, translationY: number) => {
|
|
949
|
+
'worklet';
|
|
950
|
+
if (gestureMode.value === MODE_PAN) {
|
|
951
|
+
const boundX = panBound(fit.width, scale.value, W);
|
|
952
|
+
const boundY = panBound(fit.height, scale.value, H);
|
|
953
|
+
tx.value = rubberBandClamp(startX.value + translationX, -boundX, boundX, W);
|
|
954
|
+
ty.value = rubberBandClamp(startY.value + translationY, -boundY, boundY, H);
|
|
955
|
+
} else if (gestureMode.value === MODE_PAGE) {
|
|
956
|
+
pagerX.value = rubberBandClamp(
|
|
957
|
+
pagerStart.value + sign * translationX,
|
|
958
|
+
-(count - 1) * pageWidth,
|
|
959
|
+
0,
|
|
960
|
+
W
|
|
961
|
+
);
|
|
962
|
+
} else if (gestureMode.value === MODE_DISMISS) {
|
|
963
|
+
dragX.value = translationX;
|
|
964
|
+
dragY.value = translationY;
|
|
965
|
+
shrink.value = dragScale(translationY, H);
|
|
966
|
+
fade.value = dragFade(translationY, H);
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
|
|
883
970
|
const pan = Gesture.Pan()
|
|
884
971
|
.maxPointers(1)
|
|
885
972
|
.minDistance(8)
|
|
@@ -897,39 +984,22 @@ function ViewerOverlay({
|
|
|
897
984
|
startY.value = ty.value;
|
|
898
985
|
return;
|
|
899
986
|
}
|
|
900
|
-
|
|
901
|
-
gestureMode.value = MODE_PAGE;
|
|
902
|
-
cancelAnimation(pagerX);
|
|
903
|
-
pagerStart.value = pagerX.value;
|
|
904
|
-
return;
|
|
905
|
-
}
|
|
906
|
-
gestureMode.value = MODE_DISMISS;
|
|
907
|
-
chrome.value = withTiming(0, { duration: 120 });
|
|
908
|
-
if (haptics) runOnJS(selectionTick)();
|
|
987
|
+
decide(event.translationX, event.translationY);
|
|
909
988
|
})
|
|
910
989
|
.onUpdate((event) => {
|
|
911
990
|
'worklet';
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
tx.value = rubberBandClamp(startX.value + event.translationX, -boundX, boundX, W);
|
|
916
|
-
ty.value = rubberBandClamp(startY.value + event.translationY, -boundY, boundY, H);
|
|
917
|
-
} else if (gestureMode.value === MODE_PAGE) {
|
|
918
|
-
pagerX.value = rubberBandClamp(
|
|
919
|
-
pagerStart.value + event.translationX,
|
|
920
|
-
-(count - 1) * pageWidth,
|
|
921
|
-
0,
|
|
922
|
-
W
|
|
923
|
-
);
|
|
924
|
-
} else if (gestureMode.value === MODE_DISMISS) {
|
|
925
|
-
dragX.value = event.translationX;
|
|
926
|
-
dragY.value = event.translationY;
|
|
927
|
-
shrink.value = dragScale(event.translationY, H);
|
|
928
|
-
fade.value = dragFade(event.translationY, H);
|
|
929
|
-
}
|
|
991
|
+
// Activated without a translation: the first update that has moved decides.
|
|
992
|
+
resolve(event.translationX, event.translationY);
|
|
993
|
+
follow(event.translationX, event.translationY);
|
|
930
994
|
})
|
|
931
995
|
.onEnd((event, success) => {
|
|
932
996
|
'worklet';
|
|
997
|
+
// A quick flick can end before any update has moved, so the end event
|
|
998
|
+
// may be the first to: decide on it and apply it before acting.
|
|
999
|
+
if (gestureMode.value === MODE_UNDECIDED) {
|
|
1000
|
+
resolve(event.translationX, event.translationY);
|
|
1001
|
+
follow(event.translationX, event.translationY);
|
|
1002
|
+
}
|
|
933
1003
|
const current = gestureMode.value;
|
|
934
1004
|
gestureMode.value = MODE_NONE;
|
|
935
1005
|
if (current === MODE_PAN) {
|
|
@@ -946,19 +1016,19 @@ function ViewerOverlay({
|
|
|
946
1016
|
ty.value = withDecay({ velocity: event.velocityY, clamp: [-boundY, boundY] });
|
|
947
1017
|
}
|
|
948
1018
|
} else if (current === MODE_PAGE) {
|
|
949
|
-
const
|
|
950
|
-
pagerX.value
|
|
951
|
-
|
|
952
|
-
velocity: event.velocityX,
|
|
953
|
-
});
|
|
1019
|
+
const velocity = sign * event.velocityX;
|
|
1020
|
+
const target = snapPage(pagerX.value, velocity, activePage.value, count, pageWidth);
|
|
1021
|
+
pagerX.value = withSpring(-target * pageWidth, { ...SETTLE_SPRING, velocity });
|
|
954
1022
|
if (target !== activePage.value) {
|
|
955
1023
|
activePage.value = target;
|
|
956
1024
|
runOnJS(onIndexChange)(target);
|
|
957
1025
|
}
|
|
958
1026
|
} else if (current === MODE_DISMISS) {
|
|
959
1027
|
if (success && shouldDismiss(event.translationY, event.velocityY)) {
|
|
960
|
-
|
|
961
|
-
|
|
1028
|
+
// Closing now, before the measure: no other gesture starts, and the
|
|
1029
|
+
// `open` effect leaves the flight home to `closeFromGesture`.
|
|
1030
|
+
phase.value = PHASE_CLOSING;
|
|
1031
|
+
runOnJS(closeFromGesture)(event.velocityX, event.velocityY);
|
|
962
1032
|
return;
|
|
963
1033
|
}
|
|
964
1034
|
dragX.value = withSpring(0, SETTLE_SPRING);
|
|
@@ -1007,8 +1077,8 @@ function ViewerOverlay({
|
|
|
1007
1077
|
if (!success || phase.value !== PHASE_OPEN) return;
|
|
1008
1078
|
const onImage = hitsRect(event.x, event.y, fit, scale.value, tx.value, ty.value);
|
|
1009
1079
|
if (!onImage) {
|
|
1010
|
-
|
|
1011
|
-
runOnJS(
|
|
1080
|
+
phase.value = PHASE_CLOSING;
|
|
1081
|
+
runOnJS(closeFromGesture)(0, 0);
|
|
1012
1082
|
return;
|
|
1013
1083
|
}
|
|
1014
1084
|
chromeOn.value = !chromeOn.value;
|
|
@@ -1048,7 +1118,8 @@ function ViewerOverlay({
|
|
|
1048
1118
|
scale,
|
|
1049
1119
|
settleZoom,
|
|
1050
1120
|
shrink,
|
|
1051
|
-
|
|
1121
|
+
closeFromGesture,
|
|
1122
|
+
sign,
|
|
1052
1123
|
startScale,
|
|
1053
1124
|
startX,
|
|
1054
1125
|
startY,
|
|
@@ -1056,7 +1127,9 @@ function ViewerOverlay({
|
|
|
1056
1127
|
ty,
|
|
1057
1128
|
]);
|
|
1058
1129
|
|
|
1059
|
-
const pagerStyle = useAnimatedStyle(() => ({
|
|
1130
|
+
const pagerStyle = useAnimatedStyle(() => ({
|
|
1131
|
+
transform: [{ translateX: sign * pagerX.value }],
|
|
1132
|
+
}));
|
|
1060
1133
|
|
|
1061
1134
|
const chromeStyle = useAnimatedStyle(() => ({
|
|
1062
1135
|
opacity: chrome.value * clamp(t.value, 0, 1) * fade.value,
|
|
@@ -1115,13 +1188,19 @@ function ViewerOverlay({
|
|
|
1115
1188
|
]}
|
|
1116
1189
|
onAccessibilityAction={onAccessibilityAction}
|
|
1117
1190
|
>
|
|
1118
|
-
|
|
1191
|
+
{/* Laid out left to right whatever the app's direction: the pages and
|
|
1192
|
+
the flight are placed in measured screen pixels, which a right-to-left
|
|
1193
|
+
layout would mirror. `sign` does the mirroring the gallery wants. */}
|
|
1194
|
+
<Animated.View
|
|
1195
|
+
pointerEvents="none"
|
|
1196
|
+
style={[StyleSheet.absoluteFill, PHYSICAL, pagerStyle]}
|
|
1197
|
+
>
|
|
1119
1198
|
{visiblePages.map(({ entry, at }) => (
|
|
1120
1199
|
<ViewerPage
|
|
1121
1200
|
key={entry.id}
|
|
1122
1201
|
item={entry}
|
|
1123
1202
|
at={at}
|
|
1124
|
-
left={at * pageWidth}
|
|
1203
|
+
left={sign * at * pageWidth}
|
|
1125
1204
|
viewport={{ width: W, height: H }}
|
|
1126
1205
|
box={box}
|
|
1127
1206
|
cornerRadius={cornerRadius}
|
|
@@ -804,7 +804,7 @@ const FILL = { flexGrow: 1, flexShrink: 1, flexBasis: 'auto' } as const;
|
|
|
804
804
|
/** The window the strip moves behind, one panel wide. */
|
|
805
805
|
const PAGER_VIEWPORT = { ...FILL, overflow: 'hidden' } as const;
|
|
806
806
|
|
|
807
|
-
function TabsIndicator() {
|
|
807
|
+
function TabsIndicator({ className }: { className?: string }) {
|
|
808
808
|
const { value, layouts, variant, animationDisabled } = useTabs('Tabs.List');
|
|
809
809
|
const x = useSharedValue(0);
|
|
810
810
|
const width = useSharedValue(0);
|
|
@@ -836,11 +836,20 @@ function TabsIndicator() {
|
|
|
836
836
|
width: width.value,
|
|
837
837
|
}));
|
|
838
838
|
|
|
839
|
-
return <Animated.View style={style} className={indicator()} />;
|
|
839
|
+
return <Animated.View style={style} className={cn(indicator(), className)} />;
|
|
840
840
|
}
|
|
841
841
|
|
|
842
842
|
export interface TabsListProps extends ViewProps {
|
|
843
843
|
className?: string;
|
|
844
|
+
/**
|
|
845
|
+
* Classes for the indicator that slides to the selected tab: the chip in
|
|
846
|
+
* `segmented` and `pill`, the rule in `underline`. Use it to change the
|
|
847
|
+
* indicator's colour, height or radius, for example `bg-primary`.
|
|
848
|
+
*
|
|
849
|
+
* `expanding` has no indicator, so this does nothing there. Style the open
|
|
850
|
+
* tab with `activeClassName` on `Tabs.Trigger` instead.
|
|
851
|
+
*/
|
|
852
|
+
indicatorClassName?: string;
|
|
844
853
|
/**
|
|
845
854
|
* Lay the triggers out at their natural widths inside a horizontal scroller
|
|
846
855
|
* instead of splitting the row between them. For more tabs than fit — which
|
|
@@ -862,7 +871,13 @@ function scrollTarget(layout: TabLayout | undefined): number | null {
|
|
|
862
871
|
return Math.max(layout.x - 24, 0);
|
|
863
872
|
}
|
|
864
873
|
|
|
865
|
-
function TabsList({
|
|
874
|
+
function TabsList({
|
|
875
|
+
className,
|
|
876
|
+
indicatorClassName,
|
|
877
|
+
scrollable = false,
|
|
878
|
+
children,
|
|
879
|
+
...props
|
|
880
|
+
}: TabsListProps) {
|
|
866
881
|
const { variant, value, layouts } = useTabs('Tabs.List');
|
|
867
882
|
const { list } = tabsVariants({ variant });
|
|
868
883
|
const scroller = useRef<ScrollView>(null);
|
|
@@ -903,7 +918,7 @@ function TabsList({ className, scrollable = false, children, ...props }: TabsLis
|
|
|
903
918
|
<View {...props} accessibilityRole="tablist" className={cn(list(), className)}>
|
|
904
919
|
{/* Nothing to slide: in `expanding` every tab draws its own pill, and the
|
|
905
920
|
open one is the shape that moves. */}
|
|
906
|
-
{variant === 'expanding' ? null : <TabsIndicator />}
|
|
921
|
+
{variant === 'expanding' ? null : <TabsIndicator className={indicatorClassName} />}
|
|
907
922
|
{textChildren(children)}
|
|
908
923
|
</View>
|
|
909
924
|
);
|
|
@@ -934,6 +949,19 @@ function TabsList({ className, scrollable = false, children, ...props }: TabsLis
|
|
|
934
949
|
|
|
935
950
|
export interface TabsTriggerProps {
|
|
936
951
|
className?: string;
|
|
952
|
+
/**
|
|
953
|
+
* Classes added to the trigger while it is selected. In `expanding`, where
|
|
954
|
+
* the open tab draws its own pill, this is how the pill is recoloured.
|
|
955
|
+
*/
|
|
956
|
+
activeClassName?: string;
|
|
957
|
+
/** Classes for the label in every state, for example its inactive colour. */
|
|
958
|
+
labelClassName?: string;
|
|
959
|
+
/**
|
|
960
|
+
* Classes for the label while the tab is selected. Set it with
|
|
961
|
+
* `indicatorClassName` on `Tabs.List` so the text stays readable on the new
|
|
962
|
+
* indicator colour.
|
|
963
|
+
*/
|
|
964
|
+
activeLabelClassName?: string;
|
|
937
965
|
value: string;
|
|
938
966
|
/**
|
|
939
967
|
* Rendered before the label. Required by `variant="expanding"`, where it is
|
|
@@ -949,6 +977,9 @@ export interface TabsTriggerProps {
|
|
|
949
977
|
|
|
950
978
|
function TabsTrigger({
|
|
951
979
|
className,
|
|
980
|
+
activeClassName,
|
|
981
|
+
labelClassName,
|
|
982
|
+
activeLabelClassName,
|
|
952
983
|
value,
|
|
953
984
|
icon,
|
|
954
985
|
badge,
|
|
@@ -983,6 +1014,10 @@ function TabsTrigger({
|
|
|
983
1014
|
[registerLayout, value]
|
|
984
1015
|
);
|
|
985
1016
|
|
|
1017
|
+
// Last, so a caller's `text-*` or `bg-*` replaces the variant's own.
|
|
1018
|
+
const label = cn(slots.label(), labelClassName, active && activeLabelClassName);
|
|
1019
|
+
const trigger = cn(slots.trigger(), className, active && activeClassName);
|
|
1020
|
+
|
|
986
1021
|
if (context.variant === 'expanding') {
|
|
987
1022
|
return (
|
|
988
1023
|
<ExpandingTrigger
|
|
@@ -991,8 +1026,8 @@ function TabsTrigger({
|
|
|
991
1026
|
icon={icon}
|
|
992
1027
|
badge={badge}
|
|
993
1028
|
still={context.animationDisabled}
|
|
994
|
-
labelClassName={
|
|
995
|
-
className={
|
|
1029
|
+
labelClassName={label}
|
|
1030
|
+
className={trigger}
|
|
996
1031
|
onLayout={handleLayout}
|
|
997
1032
|
onPress={() => context.setValue(value)}
|
|
998
1033
|
>
|
|
@@ -1009,11 +1044,16 @@ function TabsTrigger({
|
|
|
1009
1044
|
onPress={() => context.setValue(value)}
|
|
1010
1045
|
onLayout={handleLayout}
|
|
1011
1046
|
hitSlop={TRIGGER_HIT_SLOP[context.size]}
|
|
1012
|
-
className={cn(
|
|
1047
|
+
className={cn(
|
|
1048
|
+
slots.trigger(),
|
|
1049
|
+
(icon || badge) && 'flex-row gap-1.5',
|
|
1050
|
+
className,
|
|
1051
|
+
active && activeClassName
|
|
1052
|
+
)}
|
|
1013
1053
|
>
|
|
1014
1054
|
{icon}
|
|
1015
1055
|
{textChildren(children, (text) => (
|
|
1016
|
-
<Text size="sm" weight="medium" className={
|
|
1056
|
+
<Text size="sm" weight="medium" className={label}>
|
|
1017
1057
|
{text}
|
|
1018
1058
|
</Text>
|
|
1019
1059
|
))}
|
package/src/icons/index.tsx
CHANGED
|
@@ -68,6 +68,10 @@ import HgBookmark01Icon from '@hugeicons/core-free-icons/Bookmark01Icon';
|
|
|
68
68
|
import HgBubbleChatIcon from '@hugeicons/core-free-icons/BubbleChatIcon';
|
|
69
69
|
import HgCalendar03Icon from '@hugeicons/core-free-icons/Calendar03Icon';
|
|
70
70
|
import HgCamera01Icon from '@hugeicons/core-free-icons/Camera01Icon';
|
|
71
|
+
import HgCameraRotated01Icon from '@hugeicons/core-free-icons/CameraRotated01Icon';
|
|
72
|
+
import HgFlashIcon from '@hugeicons/core-free-icons/FlashIcon';
|
|
73
|
+
import HgFlashOffIcon from '@hugeicons/core-free-icons/FlashOffIcon';
|
|
74
|
+
import HgTimer02Icon from '@hugeicons/core-free-icons/Timer02Icon';
|
|
71
75
|
import HgCancel01Icon from '@hugeicons/core-free-icons/Cancel01Icon';
|
|
72
76
|
import HgCheckListIcon from '@hugeicons/core-free-icons/CheckListIcon';
|
|
73
77
|
import HgCheckmarkCircle01Icon from '@hugeicons/core-free-icons/CheckmarkCircle01Icon';
|
|
@@ -360,6 +364,10 @@ export const ImageIcon = icon(HgImage01Icon, { size: 16, color: '#737373' });
|
|
|
360
364
|
export const PaperclipIcon = icon(HgAttachment01Icon, { size: 16, color: '#737373' });
|
|
361
365
|
export const CameraIcon = icon(HgCamera01Icon, { size: 16, color: '#737373' });
|
|
362
366
|
export const VideoIcon = icon(HgVideo01Icon, { size: 16, color: '#737373' });
|
|
367
|
+
export const CameraSwitchIcon = icon(HgCameraRotated01Icon, { size: 16, color: '#737373' });
|
|
368
|
+
export const FlashIcon = icon(HgFlashIcon, { size: 16, color: '#737373' });
|
|
369
|
+
export const FlashOffIcon = icon(HgFlashOffIcon, { size: 16, color: '#737373' });
|
|
370
|
+
export const TimerIcon = icon(HgTimer02Icon, { size: 16, color: '#737373' });
|
|
363
371
|
export const UploadIcon = icon(HgCloudUploadIcon, { size: 16, color: '#737373' });
|
|
364
372
|
export const MicIcon = icon(HgMic01Icon, { size: 16, color: '#737373' });
|
|
365
373
|
export const AudioLinesIcon = icon(HgAudioWave01Icon, { size: 16, color: '#737373' });
|
package/src/index.ts
CHANGED
|
@@ -91,6 +91,38 @@ export {
|
|
|
91
91
|
type AvatarCropperSource,
|
|
92
92
|
type PickAvatarImageOptions,
|
|
93
93
|
} from './components/avatar-cropper';
|
|
94
|
+
export {
|
|
95
|
+
Camera,
|
|
96
|
+
hasCamera,
|
|
97
|
+
useCamera,
|
|
98
|
+
type CameraProps,
|
|
99
|
+
type CameraPreviewProps,
|
|
100
|
+
type CameraHeaderProps,
|
|
101
|
+
type CameraFooterProps,
|
|
102
|
+
type CameraControlsProps,
|
|
103
|
+
type CameraButtonProps,
|
|
104
|
+
type CameraFlashProps,
|
|
105
|
+
type CameraTimerProps,
|
|
106
|
+
type CameraDurationProps,
|
|
107
|
+
type CameraZoomProps,
|
|
108
|
+
type CameraModesProps,
|
|
109
|
+
type CameraLibraryProps,
|
|
110
|
+
type CameraFlipProps,
|
|
111
|
+
type CameraShutterProps,
|
|
112
|
+
type CameraHandle,
|
|
113
|
+
type CameraState,
|
|
114
|
+
type CameraCapture,
|
|
115
|
+
type CameraPhoto,
|
|
116
|
+
type CameraVideo,
|
|
117
|
+
type CameraPictureOptions,
|
|
118
|
+
type CameraViewOptions,
|
|
119
|
+
type CameraViewHandle,
|
|
120
|
+
type CameraZoomStop,
|
|
121
|
+
type CameraFacing,
|
|
122
|
+
type CameraFlashMode,
|
|
123
|
+
type CameraMode,
|
|
124
|
+
type CameraTimerDelay,
|
|
125
|
+
} from './components/camera';
|
|
94
126
|
export {
|
|
95
127
|
Attachment,
|
|
96
128
|
type AttachmentProps,
|
|
@@ -1577,7 +1609,10 @@ export {
|
|
|
1577
1609
|
BoldIcon,
|
|
1578
1610
|
CalendarIcon,
|
|
1579
1611
|
CameraIcon,
|
|
1612
|
+
CameraSwitchIcon,
|
|
1580
1613
|
CardIcon,
|
|
1614
|
+
FlashIcon,
|
|
1615
|
+
FlashOffIcon,
|
|
1581
1616
|
HeadsetIcon,
|
|
1582
1617
|
LifebuoyIcon,
|
|
1583
1618
|
HelpCircleIcon,
|
|
@@ -1647,6 +1682,7 @@ export {
|
|
|
1647
1682
|
SparklesIcon,
|
|
1648
1683
|
StarIcon,
|
|
1649
1684
|
SunIcon,
|
|
1685
|
+
TimerIcon,
|
|
1650
1686
|
TrashIcon,
|
|
1651
1687
|
UnlockIcon,
|
|
1652
1688
|
UploadIcon,
|