@konstructio/ui 0.1.4 → 0.1.6
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/Avatar/hooks/use-gravatar-url.js +21 -16
- package/dist/components/Badge/Badge.js +13 -13
- package/dist/components/Button/Button.js +20 -19
- package/dist/components/Button/Button.variants.js +5 -2
- package/dist/components/Checkbox/Checkbox.variants.js +1 -2
- package/dist/components/Datepicker/components/DatePickerContent/DatePickerContent.js +7 -7
- package/dist/components/Sheet/Sheet.js +308 -123
- package/dist/components/Sheet/components/SheetStep/SheetStep.js +94 -0
- package/dist/components/Sheet/components/index.js +4 -0
- package/dist/components/Sheet/utils/index.js +34 -7
- package/dist/lib/components/Button/Button.types.d.ts +2 -0
- package/dist/lib/components/Button/Button.variants.d.ts +1 -0
- package/dist/lib/components/Sheet/Sheet.d.ts +10 -4
- package/dist/lib/components/Sheet/Sheet.types.d.ts +12 -0
- package/dist/lib/components/Sheet/components/SheetStep/SheetStep.d.ts +8 -0
- package/dist/lib/components/Sheet/components/SheetStep/SheetStep.types.d.ts +32 -0
- package/dist/lib/components/Sheet/components/index.d.ts +2 -0
- package/dist/lib/components/Sheet/utils/index.d.ts +17 -2
- package/dist/package.json +3 -3
- package/dist/styles.css +1 -1
- package/package.json +3 -3
|
@@ -9,11 +9,17 @@ import { Props } from './Sheet.types';
|
|
|
9
9
|
*
|
|
10
10
|
* Multi-step sheets pass a `step`: when it changes the content slides across
|
|
11
11
|
* (forward for a higher step, back for a lower one) and the panel height
|
|
12
|
-
* animates to the new content.
|
|
12
|
+
* animates to the new content. With `onBack`, swiping the content towards the
|
|
13
|
+
* right on a later step goes back the way the iOS back gesture does: the
|
|
14
|
+
* previous step follows the finger in from the left while the panel grows or
|
|
15
|
+
* shrinks to its height, and the swipe commits or springs back on release.
|
|
13
16
|
*
|
|
14
|
-
* On touch screens the panel
|
|
15
|
-
*
|
|
16
|
-
* quick flick, and springs back otherwise.
|
|
17
|
+
* On touch screens the panel follows a finger on its grab handle or header.
|
|
18
|
+
* Towards the edge it docks to it closes past a quarter of its height or on a
|
|
19
|
+
* quick flick, and springs back otherwise. An `expandable` sheet grows with
|
|
20
|
+
* the finger when pulled away from that edge and, once released, springs the
|
|
21
|
+
* rest of the way to the full viewport (or back to its natural height); from
|
|
22
|
+
* there a pull towards the edge shrinks it again, and a long one closes it.
|
|
17
23
|
*
|
|
18
24
|
* @example
|
|
19
25
|
* ```tsx
|
|
@@ -16,6 +16,12 @@ export type Props = PropsWithChildren<{
|
|
|
16
16
|
isOpen: boolean;
|
|
17
17
|
/** Called when the sheet asks to close: scrim tap, Escape, or `closeOnSelect` */
|
|
18
18
|
onClose: () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Goes back one step. On a step above the first the header (chevron and
|
|
21
|
+
* title) becomes the back control in place of `leading`, and swiping the
|
|
22
|
+
* content towards the right goes back too.
|
|
23
|
+
*/
|
|
24
|
+
onBack?: () => void;
|
|
19
25
|
/** Heading of the sheet; also its accessible name */
|
|
20
26
|
title: ReactNode;
|
|
21
27
|
/** Keep the title for assistive technology only */
|
|
@@ -24,6 +30,12 @@ export type Props = PropsWithChildren<{
|
|
|
24
30
|
leading?: ReactNode;
|
|
25
31
|
/** Screen edge the sheet docks to (default: 'bottom') */
|
|
26
32
|
position?: SheetPosition;
|
|
33
|
+
/**
|
|
34
|
+
* Let a swipe away from the docked edge grow the panel to the full viewport.
|
|
35
|
+
* A swipe back towards the edge restores its natural height first and only
|
|
36
|
+
* a further swipe closes it.
|
|
37
|
+
*/
|
|
38
|
+
expandable?: boolean;
|
|
27
39
|
/**
|
|
28
40
|
* Index of the step the content shows. Changing it slides the content across
|
|
29
41
|
* (forward for a higher index, back for a lower one) and animates the panel
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Props } from './SheetStep.types';
|
|
3
|
+
/**
|
|
4
|
+
* One step of a sheet's content. It owns its horizontal offset so a step that
|
|
5
|
+
* was swiped away keeps that offset while it unmounts and the next step mounts
|
|
6
|
+
* in place.
|
|
7
|
+
*/
|
|
8
|
+
export declare const SheetStep: FC<Props>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { PanInfo } from 'motion/react';
|
|
2
|
+
import { PropsWithChildren } from 'react';
|
|
3
|
+
export type BackOutcome = 'back' | 'stay';
|
|
4
|
+
/**
|
|
5
|
+
* What AnimatePresence hands an exiting step: the direction of travel and
|
|
6
|
+
* whether the step has already been moved out by a gesture.
|
|
7
|
+
*/
|
|
8
|
+
export type StepExitCustom = {
|
|
9
|
+
direction: number;
|
|
10
|
+
instant: boolean;
|
|
11
|
+
};
|
|
12
|
+
export type Props = PropsWithChildren<{
|
|
13
|
+
step: number;
|
|
14
|
+
direction: number;
|
|
15
|
+
/** Slide the content across on mount and unmount */
|
|
16
|
+
animated: boolean;
|
|
17
|
+
/** The content follows a swipe towards the right and reports its progress */
|
|
18
|
+
canSwipeBack: boolean;
|
|
19
|
+
/** Whether the pan that just started is a horizontal one on swipeable content */
|
|
20
|
+
isArmed: (info: PanInfo) => boolean;
|
|
21
|
+
onBackStart: () => void;
|
|
22
|
+
onBackMove: (offset: number) => void;
|
|
23
|
+
onBackEnd: (info: PanInfo) => BackOutcome;
|
|
24
|
+
/** Reports the step's own height once it is laid out */
|
|
25
|
+
onMount: (height: number) => void;
|
|
26
|
+
/** Bumped to slide the content out as if swiped, e.g. from the back button */
|
|
27
|
+
commitSignal: number;
|
|
28
|
+
/** The content has finished sliding out after a completed swipe */
|
|
29
|
+
onBackCommit: () => void;
|
|
30
|
+
/** The content has settled back in place after an abandoned swipe */
|
|
31
|
+
onBackCancel: () => void;
|
|
32
|
+
}>;
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
import { SheetPosition } from '../Sheet.types';
|
|
2
2
|
export declare const DISMISS_DISTANCE_RATIO = 0.25;
|
|
3
3
|
export declare const DISMISS_VELOCITY = 500;
|
|
4
|
-
type
|
|
4
|
+
type Gesture = {
|
|
5
5
|
offset: number;
|
|
6
6
|
velocity: number;
|
|
7
7
|
panelHeight: number;
|
|
8
8
|
position: SheetPosition;
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
type SheetGesture = Gesture & {
|
|
11
|
+
expandable: boolean;
|
|
12
|
+
isExpanded: boolean;
|
|
13
|
+
/** Height the panel had before it expanded; the collapse target */
|
|
14
|
+
restHeight?: number;
|
|
15
|
+
};
|
|
16
|
+
export type SheetGestureOutcome = 'dismiss' | 'expand' | 'collapse' | 'rest';
|
|
17
|
+
export declare function shouldDismissSheet(gesture: Gesture): boolean;
|
|
18
|
+
export declare function shouldExpandSheet(gesture: Gesture): boolean;
|
|
19
|
+
type BackGesture = {
|
|
20
|
+
offset: number;
|
|
21
|
+
velocity: number;
|
|
22
|
+
panelWidth: number;
|
|
23
|
+
};
|
|
24
|
+
export declare function shouldSwipeBack({ offset, velocity, panelWidth, }: BackGesture): boolean;
|
|
25
|
+
export declare function resolveSheetGesture({ expandable, isExpanded, restHeight, ...gesture }: SheetGesture): SheetGestureOutcome;
|
|
11
26
|
export {};
|
package/dist/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@konstructio/ui",
|
|
3
3
|
"description": "A set of reusable and customizable React components built for konstruct.io",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.5",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"google-libphonenumber": "^3.2.48",
|
|
103
103
|
"i18n-iso-countries": "^7.14.0",
|
|
104
104
|
"js-cookie": "^3.0.8",
|
|
105
|
-
"lucide-react": "^1.
|
|
105
|
+
"lucide-react": "^1.68.0",
|
|
106
106
|
"react-chartjs-2": "^5.3.1",
|
|
107
107
|
"react-day-picker": "^10.0.2",
|
|
108
108
|
"react-feather": "^2.0.10",
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
"jest-axe": "^11.0.0",
|
|
177
177
|
"jsdom": "^30.1.3",
|
|
178
178
|
"lodash": "^4.18.1",
|
|
179
|
-
"motion": "^14.9.
|
|
179
|
+
"motion": "^14.9.1",
|
|
180
180
|
"postcss": "^8.5.32",
|
|
181
181
|
"prettier": "^3.9.10",
|
|
182
182
|
"rimraf": "^6.1.4",
|