@papernote/ui 1.10.6 → 1.10.8
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/components/SwipeableListItem.d.ts +51 -32
- package/dist/components/SwipeableListItem.d.ts.map +1 -1
- package/dist/index.d.ts +51 -32
- package/dist/index.esm.js +321 -182
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +321 -182
- package/dist/index.js.map +1 -1
- package/dist/styles.css +135 -0
- package/package.json +1 -1
- package/src/components/SwipeableListItem.stories.tsx +383 -294
- package/src/components/SwipeableListItem.tsx +367 -198
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { LucideIcon } from 'lucide-react';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Single action configuration for swipe gestures
|
|
5
5
|
*/
|
|
6
6
|
export interface SwipeListAction {
|
|
7
|
+
/** Unique identifier for the action */
|
|
8
|
+
id: string;
|
|
7
9
|
/** Background color variant or custom Tailwind class */
|
|
8
|
-
color: 'destructive' | 'warning' | 'success' | 'primary' | string;
|
|
10
|
+
color: 'destructive' | 'warning' | 'success' | 'primary' | 'neutral' | string;
|
|
9
11
|
/** Lucide icon to display */
|
|
10
12
|
icon: LucideIcon;
|
|
11
|
-
/** Label
|
|
13
|
+
/** Label shown below icon */
|
|
12
14
|
label: string;
|
|
15
|
+
/** Click handler (can be async) */
|
|
16
|
+
onClick: () => void | Promise<void>;
|
|
13
17
|
}
|
|
14
18
|
/**
|
|
15
19
|
* SwipeableListItem component props
|
|
@@ -17,50 +21,65 @@ export interface SwipeListAction {
|
|
|
17
21
|
export interface SwipeableListItemProps {
|
|
18
22
|
/** List item content */
|
|
19
23
|
children: React.ReactNode;
|
|
20
|
-
/**
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
|
|
24
|
+
/** Actions shown when swiping left (appear on right side) */
|
|
25
|
+
leftActions?: SwipeListAction[];
|
|
26
|
+
/** Actions shown when swiping right (appear on left side) */
|
|
27
|
+
rightActions?: SwipeListAction[];
|
|
28
|
+
/** Width per action button in pixels (default: 72) */
|
|
29
|
+
actionWidth?: number;
|
|
30
|
+
/** Enable full swipe to trigger first action (default: false) */
|
|
31
|
+
fullSwipe?: boolean;
|
|
32
|
+
/** Full swipe threshold as percentage of container width (default: 0.5) */
|
|
33
|
+
fullSwipeThreshold?: number;
|
|
30
34
|
/** Disable swipe interactions */
|
|
31
35
|
disabled?: boolean;
|
|
32
36
|
/** Additional class name */
|
|
33
37
|
className?: string;
|
|
38
|
+
/** Callback when swipe state changes */
|
|
39
|
+
onSwipeChange?: (direction: 'left' | 'right' | null) => void;
|
|
34
40
|
}
|
|
35
41
|
/**
|
|
36
|
-
* SwipeableListItem - List item with swipe-to-action
|
|
42
|
+
* SwipeableListItem - List item with swipe-to-reveal action buttons
|
|
37
43
|
*
|
|
38
|
-
*
|
|
39
|
-
* -
|
|
40
|
-
* -
|
|
41
|
-
* - Arrow keys
|
|
44
|
+
* Features:
|
|
45
|
+
* - Multiple actions per side (like email apps)
|
|
46
|
+
* - Full swipe to trigger primary action
|
|
47
|
+
* - Keyboard accessibility (Arrow keys + Tab + Enter)
|
|
42
48
|
* - Async callback support with loading state
|
|
49
|
+
* - Haptic feedback on mobile
|
|
50
|
+
* - Smooth animations and visual polish
|
|
43
51
|
*
|
|
44
|
-
* @example
|
|
52
|
+
* @example Single action per side
|
|
45
53
|
* ```tsx
|
|
46
54
|
* <SwipeableListItem
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
* color: '
|
|
52
|
-
*
|
|
53
|
-
* }}
|
|
54
|
-
* leftAction={{
|
|
55
|
-
* icon: X,
|
|
56
|
-
* color: 'destructive',
|
|
57
|
-
* label: 'Dismiss'
|
|
58
|
-
* }}
|
|
55
|
+
* rightActions={[
|
|
56
|
+
* { id: 'approve', icon: Check, color: 'success', label: 'Approve', onClick: handleApprove }
|
|
57
|
+
* ]}
|
|
58
|
+
* leftActions={[
|
|
59
|
+
* { id: 'delete', icon: Trash, color: 'destructive', label: 'Delete', onClick: handleDelete }
|
|
60
|
+
* ]}
|
|
59
61
|
* >
|
|
60
62
|
* <div className="p-4">List item content</div>
|
|
61
63
|
* </SwipeableListItem>
|
|
62
64
|
* ```
|
|
65
|
+
*
|
|
66
|
+
* @example Multiple actions (email-style)
|
|
67
|
+
* ```tsx
|
|
68
|
+
* <SwipeableListItem
|
|
69
|
+
* leftActions={[
|
|
70
|
+
* { id: 'delete', icon: Trash, color: 'destructive', label: 'Delete', onClick: handleDelete },
|
|
71
|
+
* { id: 'archive', icon: Archive, color: 'warning', label: 'Archive', onClick: handleArchive },
|
|
72
|
+
* ]}
|
|
73
|
+
* rightActions={[
|
|
74
|
+
* { id: 'read', icon: Mail, color: 'primary', label: 'Read', onClick: handleRead },
|
|
75
|
+
* { id: 'star', icon: Star, color: 'warning', label: 'Star', onClick: handleStar },
|
|
76
|
+
* ]}
|
|
77
|
+
* fullSwipe
|
|
78
|
+
* >
|
|
79
|
+
* <EmailListItem />
|
|
80
|
+
* </SwipeableListItem>
|
|
81
|
+
* ```
|
|
63
82
|
*/
|
|
64
|
-
export declare function SwipeableListItem({ children,
|
|
83
|
+
export declare function SwipeableListItem({ children, leftActions, rightActions, actionWidth, fullSwipe, fullSwipeThreshold, disabled, className, onSwipeChange, }: SwipeableListItemProps): import("react/jsx-runtime").JSX.Element;
|
|
65
84
|
export default SwipeableListItem;
|
|
66
85
|
//# sourceMappingURL=SwipeableListItem.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SwipeableListItem.d.ts","sourceRoot":"","sources":["../../src/components/SwipeableListItem.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAExE,OAAO,KAAK,EAAE,UA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EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;CAC9D;AAcD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,QAAQ,EACR,WAAgB,EAChB,YAAiB,EACjB,WAAgB,EAChB,SAAiB,EACjB,kBAAwB,EACxB,QAAgB,EAChB,SAAc,EACd,aAAa,GACd,EAAE,sBAAsB,2CAgexB;AAED,eAAe,iBAAiB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3006,15 +3006,19 @@ interface SwipeableCardProps {
|
|
|
3006
3006
|
declare function SwipeableCard({ children, onSwipeRight, onSwipeLeft, rightAction, leftAction, swipeThreshold, hapticFeedback, disabled, onSwipeStart, onSwipeEnd, className, }: SwipeableCardProps): react_jsx_runtime.JSX.Element;
|
|
3007
3007
|
|
|
3008
3008
|
/**
|
|
3009
|
-
*
|
|
3009
|
+
* Single action configuration for swipe gestures
|
|
3010
3010
|
*/
|
|
3011
3011
|
interface SwipeListAction {
|
|
3012
|
+
/** Unique identifier for the action */
|
|
3013
|
+
id: string;
|
|
3012
3014
|
/** Background color variant or custom Tailwind class */
|
|
3013
|
-
color: 'destructive' | 'warning' | 'success' | 'primary' | string;
|
|
3015
|
+
color: 'destructive' | 'warning' | 'success' | 'primary' | 'neutral' | string;
|
|
3014
3016
|
/** Lucide icon to display */
|
|
3015
3017
|
icon: LucideIcon;
|
|
3016
|
-
/** Label
|
|
3018
|
+
/** Label shown below icon */
|
|
3017
3019
|
label: string;
|
|
3020
|
+
/** Click handler (can be async) */
|
|
3021
|
+
onClick: () => void | Promise<void>;
|
|
3018
3022
|
}
|
|
3019
3023
|
/**
|
|
3020
3024
|
* SwipeableListItem component props
|
|
@@ -3022,51 +3026,66 @@ interface SwipeListAction {
|
|
|
3022
3026
|
interface SwipeableListItemProps {
|
|
3023
3027
|
/** List item content */
|
|
3024
3028
|
children: React__default.ReactNode;
|
|
3025
|
-
/**
|
|
3026
|
-
|
|
3027
|
-
/**
|
|
3028
|
-
|
|
3029
|
-
/**
|
|
3030
|
-
|
|
3031
|
-
/**
|
|
3032
|
-
|
|
3033
|
-
/**
|
|
3034
|
-
|
|
3029
|
+
/** Actions shown when swiping left (appear on right side) */
|
|
3030
|
+
leftActions?: SwipeListAction[];
|
|
3031
|
+
/** Actions shown when swiping right (appear on left side) */
|
|
3032
|
+
rightActions?: SwipeListAction[];
|
|
3033
|
+
/** Width per action button in pixels (default: 72) */
|
|
3034
|
+
actionWidth?: number;
|
|
3035
|
+
/** Enable full swipe to trigger first action (default: false) */
|
|
3036
|
+
fullSwipe?: boolean;
|
|
3037
|
+
/** Full swipe threshold as percentage of container width (default: 0.5) */
|
|
3038
|
+
fullSwipeThreshold?: number;
|
|
3035
3039
|
/** Disable swipe interactions */
|
|
3036
3040
|
disabled?: boolean;
|
|
3037
3041
|
/** Additional class name */
|
|
3038
3042
|
className?: string;
|
|
3043
|
+
/** Callback when swipe state changes */
|
|
3044
|
+
onSwipeChange?: (direction: 'left' | 'right' | null) => void;
|
|
3039
3045
|
}
|
|
3040
3046
|
/**
|
|
3041
|
-
* SwipeableListItem - List item with swipe-to-action
|
|
3047
|
+
* SwipeableListItem - List item with swipe-to-reveal action buttons
|
|
3042
3048
|
*
|
|
3043
|
-
*
|
|
3044
|
-
* -
|
|
3045
|
-
* -
|
|
3046
|
-
* - Arrow keys
|
|
3049
|
+
* Features:
|
|
3050
|
+
* - Multiple actions per side (like email apps)
|
|
3051
|
+
* - Full swipe to trigger primary action
|
|
3052
|
+
* - Keyboard accessibility (Arrow keys + Tab + Enter)
|
|
3047
3053
|
* - Async callback support with loading state
|
|
3054
|
+
* - Haptic feedback on mobile
|
|
3055
|
+
* - Smooth animations and visual polish
|
|
3048
3056
|
*
|
|
3049
|
-
* @example
|
|
3057
|
+
* @example Single action per side
|
|
3050
3058
|
* ```tsx
|
|
3051
3059
|
* <SwipeableListItem
|
|
3052
|
-
*
|
|
3053
|
-
*
|
|
3054
|
-
*
|
|
3055
|
-
*
|
|
3056
|
-
* color: '
|
|
3057
|
-
*
|
|
3058
|
-
* }}
|
|
3059
|
-
* leftAction={{
|
|
3060
|
-
* icon: X,
|
|
3061
|
-
* color: 'destructive',
|
|
3062
|
-
* label: 'Dismiss'
|
|
3063
|
-
* }}
|
|
3060
|
+
* rightActions={[
|
|
3061
|
+
* { id: 'approve', icon: Check, color: 'success', label: 'Approve', onClick: handleApprove }
|
|
3062
|
+
* ]}
|
|
3063
|
+
* leftActions={[
|
|
3064
|
+
* { id: 'delete', icon: Trash, color: 'destructive', label: 'Delete', onClick: handleDelete }
|
|
3065
|
+
* ]}
|
|
3064
3066
|
* >
|
|
3065
3067
|
* <div className="p-4">List item content</div>
|
|
3066
3068
|
* </SwipeableListItem>
|
|
3067
3069
|
* ```
|
|
3070
|
+
*
|
|
3071
|
+
* @example Multiple actions (email-style)
|
|
3072
|
+
* ```tsx
|
|
3073
|
+
* <SwipeableListItem
|
|
3074
|
+
* leftActions={[
|
|
3075
|
+
* { id: 'delete', icon: Trash, color: 'destructive', label: 'Delete', onClick: handleDelete },
|
|
3076
|
+
* { id: 'archive', icon: Archive, color: 'warning', label: 'Archive', onClick: handleArchive },
|
|
3077
|
+
* ]}
|
|
3078
|
+
* rightActions={[
|
|
3079
|
+
* { id: 'read', icon: Mail, color: 'primary', label: 'Read', onClick: handleRead },
|
|
3080
|
+
* { id: 'star', icon: Star, color: 'warning', label: 'Star', onClick: handleStar },
|
|
3081
|
+
* ]}
|
|
3082
|
+
* fullSwipe
|
|
3083
|
+
* >
|
|
3084
|
+
* <EmailListItem />
|
|
3085
|
+
* </SwipeableListItem>
|
|
3086
|
+
* ```
|
|
3068
3087
|
*/
|
|
3069
|
-
declare function SwipeableListItem({ children,
|
|
3088
|
+
declare function SwipeableListItem({ children, leftActions, rightActions, actionWidth, fullSwipe, fullSwipeThreshold, disabled, className, onSwipeChange, }: SwipeableListItemProps): react_jsx_runtime.JSX.Element;
|
|
3070
3089
|
|
|
3071
3090
|
interface NotificationBannerAction {
|
|
3072
3091
|
/** Button label */
|