uikit-react-public 0.45.5 → 0.47.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/components/DropZone/DropZone.d.ts +21 -0
- package/dist/components/DropZone/DropZone.stories.d.ts +52 -0
- package/dist/components/DropZone/__tests__/DropZone.test.d.ts +1 -0
- package/dist/components/DropZone/index.d.ts +2 -0
- package/dist/components/Skeleton/Skeleton.d.ts +35 -0
- package/dist/components/Skeleton/Skeleton.stories.d.ts +27 -0
- package/dist/components/Skeleton/SkeletonAvatar.d.ts +7 -0
- package/dist/components/Skeleton/SkeletonInput.d.ts +4 -0
- package/dist/components/Skeleton/SkeletonTableRow.d.ts +9 -0
- package/dist/components/Skeleton/SkeletonText.d.ts +4 -0
- package/dist/components/Skeleton/__tests__/Skeleton.test.d.ts +1 -0
- package/dist/components/Skeleton/index.d.ts +6 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/hooks/__tests__/useDraggable.test.d.ts +1 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/useDraggable.d.ts +31 -0
- package/dist/hooks/useDropZone.d.ts +57 -0
- package/dist/index.js +7229 -6665
- package/lib/components/DropZone/DropZone.mdx +72 -0
- package/lib/components/DropZone/DropZone.stories.tsx +139 -0
- package/lib/components/DropZone/DropZone.tsx +213 -0
- package/lib/components/DropZone/__tests__/DropZone.test.tsx +378 -0
- package/lib/components/DropZone/__tests__/__snapshots__/DropZone.test.tsx.snap +46 -0
- package/lib/components/DropZone/index.ts +2 -0
- package/lib/components/Skeleton/Skeleton.mdx +34 -0
- package/lib/components/Skeleton/Skeleton.stories.tsx +77 -0
- package/lib/components/Skeleton/Skeleton.tsx +158 -0
- package/lib/components/Skeleton/SkeletonAvatar.tsx +20 -0
- package/lib/components/Skeleton/SkeletonInput.tsx +13 -0
- package/lib/components/Skeleton/SkeletonTableRow.tsx +44 -0
- package/lib/components/Skeleton/SkeletonText.tsx +13 -0
- package/lib/components/Skeleton/__tests__/Skeleton.test.tsx +86 -0
- package/lib/components/Skeleton/index.ts +6 -0
- package/lib/components/index.ts +13 -0
- package/lib/hooks/__tests__/useDraggable.test.tsx +184 -0
- package/lib/hooks/index.ts +19 -0
- package/lib/hooks/useDraggable.ts +243 -0
- package/lib/hooks/useDropZone.ts +418 -0
- package/package.json +1 -1
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
|
+
import { DropZoneDrop, DropZoneRejection, UseDropZoneOptions } from '../../hooks/useDropZone';
|
|
3
|
+
import { MarginProps } from '../common/marginsStyle';
|
|
4
|
+
export declare const NAME = "ucl-uikit-drop-zone";
|
|
5
|
+
export interface DropZoneRenderProps<TData = unknown> {
|
|
6
|
+
activeTypes: string[];
|
|
7
|
+
isDragAccept: boolean;
|
|
8
|
+
isDragActive: boolean;
|
|
9
|
+
isDragReject: boolean;
|
|
10
|
+
lastDrop: DropZoneDrop<TData> | null;
|
|
11
|
+
lastRejection: DropZoneRejection<TData> | null;
|
|
12
|
+
}
|
|
13
|
+
export interface DropZoneBaseProps<TData = unknown> extends Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'onDrop'>, UseDropZoneOptions<TData> {
|
|
14
|
+
children?: ReactNode | ((props: DropZoneRenderProps<TData>) => ReactNode);
|
|
15
|
+
ref?: Ref<HTMLDivElement>;
|
|
16
|
+
testId?: string;
|
|
17
|
+
}
|
|
18
|
+
export type DropZoneProps<TData = unknown> = DropZoneBaseProps<TData> & MarginProps;
|
|
19
|
+
declare const DropZone: <TData = unknown>({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, acceptedTypes, canDrop, children, className, disabled, dropEffect, keyboardDrop, onDrop, onReject, parseData, ref, role, testId, ...props }: DropZoneProps<TData>) => import("react").JSX.Element;
|
|
20
|
+
declare const MemoizedDropZone: typeof DropZone;
|
|
21
|
+
export default MemoizedDropZone;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: <TData = unknown>({ "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, acceptedTypes, canDrop, children, className, disabled, dropEffect, keyboardDrop, onDrop, onReject, parseData, ref, role, testId, ...props }: import('./DropZone').DropZoneProps<TData>) => import("react").JSX.Element;
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: string;
|
|
7
|
+
};
|
|
8
|
+
argTypes: {
|
|
9
|
+
acceptedTypes: {
|
|
10
|
+
control: {
|
|
11
|
+
type: "object";
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
disabled: {
|
|
15
|
+
control: {
|
|
16
|
+
type: "boolean";
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
dropEffect: {
|
|
20
|
+
options: string[];
|
|
21
|
+
control: {
|
|
22
|
+
type: "select";
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
testId: {
|
|
26
|
+
control: {
|
|
27
|
+
type: "text";
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
className: {
|
|
31
|
+
control: false;
|
|
32
|
+
};
|
|
33
|
+
children: {
|
|
34
|
+
control: false;
|
|
35
|
+
};
|
|
36
|
+
onDrop: {
|
|
37
|
+
action: string;
|
|
38
|
+
};
|
|
39
|
+
onReject: {
|
|
40
|
+
action: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
args: {
|
|
44
|
+
acceptedTypes: string;
|
|
45
|
+
};
|
|
46
|
+
tags: string[];
|
|
47
|
+
};
|
|
48
|
+
export default meta;
|
|
49
|
+
type Story = StoryObj<typeof meta>;
|
|
50
|
+
export declare const Default: Story;
|
|
51
|
+
export declare const WithTableCell: Story;
|
|
52
|
+
export declare const Disabled: Story;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { HTMLAttributes, Ref } from 'react';
|
|
2
|
+
import { ThemeType } from '../../theme';
|
|
3
|
+
import { MarginProps } from '../common/marginsStyle';
|
|
4
|
+
import { default as SkeletonAvatar } from './SkeletonAvatar';
|
|
5
|
+
import { default as SkeletonInput } from './SkeletonInput';
|
|
6
|
+
import { default as SkeletonTableRow } from './SkeletonTableRow';
|
|
7
|
+
import { default as SkeletonText } from './SkeletonText';
|
|
8
|
+
export declare const NAME = "ucl-uikit-skeleton";
|
|
9
|
+
export type SkeletonVariant = 'text' | 'circle' | 'rect';
|
|
10
|
+
export interface SkeletonBaseProps extends HTMLAttributes<HTMLDivElement> {
|
|
11
|
+
/** Placeholder shape. @default 'text' */
|
|
12
|
+
variant?: SkeletonVariant;
|
|
13
|
+
/** Overrides the bar width. Numbers are treated as pixels. */
|
|
14
|
+
width?: number | string;
|
|
15
|
+
/** Overrides the bar height. Numbers are treated as pixels. */
|
|
16
|
+
height?: number | string;
|
|
17
|
+
/** Number of bars to render. @default 1 */
|
|
18
|
+
count?: number;
|
|
19
|
+
/** Optional border-radius token. Ignored for the `circle` variant. */
|
|
20
|
+
radius?: keyof ThemeType['radius'];
|
|
21
|
+
testId?: string;
|
|
22
|
+
ref?: Ref<HTMLDivElement>;
|
|
23
|
+
}
|
|
24
|
+
export type SkeletonProps = SkeletonBaseProps & MarginProps;
|
|
25
|
+
export declare const getSkeletonShimmerBackground: (theme: ThemeType) => string;
|
|
26
|
+
declare const Skeleton: ({ variant, width, height, count, radius, testId, className, ref, ...props }: SkeletonProps) => import("react").JSX.Element;
|
|
27
|
+
export interface SkeletonSubcomponents {
|
|
28
|
+
Text: typeof SkeletonText;
|
|
29
|
+
Avatar: typeof SkeletonAvatar;
|
|
30
|
+
Input: typeof SkeletonInput;
|
|
31
|
+
TableRow: typeof SkeletonTableRow;
|
|
32
|
+
}
|
|
33
|
+
declare const SkeletonWithSubcomponents: typeof Skeleton & SkeletonSubcomponents;
|
|
34
|
+
export { Skeleton };
|
|
35
|
+
export default SkeletonWithSubcomponents;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: (({ variant, width, height, count, radius, testId, className, ref, ...props }: import('./Skeleton').SkeletonProps) => import("react").JSX.Element) & import('./Skeleton').SkeletonSubcomponents;
|
|
5
|
+
parameters: {
|
|
6
|
+
layout: string;
|
|
7
|
+
};
|
|
8
|
+
args: {
|
|
9
|
+
variant: "text";
|
|
10
|
+
};
|
|
11
|
+
argTypes: {
|
|
12
|
+
variant: {
|
|
13
|
+
options: string[];
|
|
14
|
+
control: {
|
|
15
|
+
type: "radio";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
export default meta;
|
|
21
|
+
type Story = StoryObj<typeof meta>;
|
|
22
|
+
export declare const Default: Story;
|
|
23
|
+
export declare const Circle: Story;
|
|
24
|
+
export declare const Landscape: Story;
|
|
25
|
+
export declare const Portrait: Story;
|
|
26
|
+
export declare const TextLines: Story;
|
|
27
|
+
export declare const FigmaExamples: Story;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SkeletonProps } from './Skeleton';
|
|
2
|
+
export interface SkeletonAvatarProps extends Omit<SkeletonProps, 'variant' | 'width' | 'height' | 'count'> {
|
|
3
|
+
/** Matches the `Avatar` size options. @default 72 */
|
|
4
|
+
size?: 32 | 48 | 56 | 72 | 80;
|
|
5
|
+
}
|
|
6
|
+
declare const SkeletonAvatar: ({ size, ...props }: SkeletonAvatarProps) => import("react").JSX.Element;
|
|
7
|
+
export default SkeletonAvatar;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { HTMLAttributes } from 'react';
|
|
2
|
+
export declare const NAME = "ucl-uikit-skeleton__table-row";
|
|
3
|
+
export interface SkeletonTableRowProps extends HTMLAttributes<HTMLTableRowElement> {
|
|
4
|
+
/** Number of cells to render. @default 4 */
|
|
5
|
+
columns?: number;
|
|
6
|
+
testId?: string;
|
|
7
|
+
}
|
|
8
|
+
declare const SkeletonTableRow: ({ columns, testId, className, ...props }: SkeletonTableRowProps) => import("react").JSX.Element;
|
|
9
|
+
export default SkeletonTableRow;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default } from './Skeleton';
|
|
2
|
+
export type { SkeletonProps, SkeletonVariant } from './Skeleton';
|
|
3
|
+
export type { SkeletonAvatarProps } from './SkeletonAvatar';
|
|
4
|
+
export type { SkeletonInputProps } from './SkeletonInput';
|
|
5
|
+
export type { SkeletonTableRowProps } from './SkeletonTableRow';
|
|
6
|
+
export type { SkeletonTextProps } from './SkeletonText';
|
|
@@ -31,6 +31,8 @@ export { default as Spinner } from './Spinner';
|
|
|
31
31
|
export type { SpinnerProps } from './Spinner';
|
|
32
32
|
export { default as ProgressBar } from './ProgressBar';
|
|
33
33
|
export type { ProgressBarProps, ProgressBarSize, ProgressBarVariant, } from './ProgressBar';
|
|
34
|
+
export { default as Skeleton } from './Skeleton';
|
|
35
|
+
export type { SkeletonProps, SkeletonVariant, SkeletonTextProps, SkeletonAvatarProps, SkeletonInputProps, SkeletonTableRowProps, } from './Skeleton';
|
|
34
36
|
export { default as Textarea } from './Textarea';
|
|
35
37
|
export type { TextareaProps } from './Textarea';
|
|
36
38
|
export { default as Heading } from './Heading';
|
|
@@ -121,6 +123,8 @@ export type { NativeDatepickerProps } from './NativeDatepicker';
|
|
|
121
123
|
export { default as Calendar } from './Calendar';
|
|
122
124
|
export type { CalendarProps, CalendarStatuses } from './Calendar';
|
|
123
125
|
export { default as WeekPicker } from './WeekPicker';
|
|
126
|
+
export { default as DropZone } from './DropZone';
|
|
127
|
+
export type { DropZoneProps, DropZoneRenderProps } from './DropZone';
|
|
124
128
|
export { default as FileInput } from './FileInput';
|
|
125
129
|
export type { FileInputProps } from './FileInput';
|
|
126
130
|
export { default as Timepicker } from './Timepicker';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export { useFocusTrap } from './useFocusTrap';
|
|
2
|
+
export { default as useDraggable } from './useDraggable';
|
|
3
|
+
export type { DraggableProps, UseDraggableOptions, UseDraggableReturn, } from './useDraggable';
|
|
4
|
+
export { default as useDropZone, UIKIT_DND_DATA_TYPE } from './useDropZone';
|
|
5
|
+
export type { DragData, DropZoneAcceptedTypes, DropZoneDrop, DropZoneEvent, DropZoneRejection, DropZoneRejectionReason, DropZoneRootProps, KeyboardDragData, UseDropZoneOptions, UseDropZoneReturn, } from './useDropZone';
|
|
2
6
|
export { default as useMediaQuery } from './useMediaQuery';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DragEvent, HTMLAttributes, Ref, RefCallback } from 'react';
|
|
2
|
+
import { DragData } from './useDropZone';
|
|
3
|
+
export interface UseDraggableOptions<TData = unknown> {
|
|
4
|
+
data: TData;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
dragImage?: Element;
|
|
7
|
+
dragImageOffset?: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
};
|
|
11
|
+
effectAllowed?: DataTransfer['effectAllowed'];
|
|
12
|
+
keyboardDrag?: boolean;
|
|
13
|
+
onDragEnd?: (event: DragEvent<HTMLElement>) => void;
|
|
14
|
+
onKeyboardDragCancel?: (dragData: DragData<TData>) => void;
|
|
15
|
+
onDragStart?: (dragData: DragData<TData>, event: DragEvent<HTMLElement>) => void;
|
|
16
|
+
onKeyboardDragStart?: (dragData: DragData<TData>) => void;
|
|
17
|
+
serializeData?: (data: TData) => string;
|
|
18
|
+
type: string;
|
|
19
|
+
}
|
|
20
|
+
export interface DraggableProps<TElement extends HTMLElement> extends HTMLAttributes<TElement> {
|
|
21
|
+
draggable: boolean;
|
|
22
|
+
ref: RefCallback<TElement>;
|
|
23
|
+
}
|
|
24
|
+
export interface UseDraggableReturn {
|
|
25
|
+
getDragProps: <TElement extends HTMLElement = HTMLElement>(props?: HTMLAttributes<TElement> & {
|
|
26
|
+
ref?: Ref<TElement>;
|
|
27
|
+
}) => DraggableProps<TElement>;
|
|
28
|
+
isDragging: boolean;
|
|
29
|
+
}
|
|
30
|
+
declare const useDraggable: <TData = unknown>({ data, disabled, dragImage, dragImageOffset, effectAllowed, keyboardDrag, onDragEnd, onKeyboardDragCancel, onDragStart, onKeyboardDragStart, serializeData, type, }: UseDraggableOptions<TData>) => UseDraggableReturn;
|
|
31
|
+
export default useDraggable;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { DragEvent, HTMLAttributes, KeyboardEvent, Ref, RefCallback } from 'react';
|
|
2
|
+
export declare const UIKIT_DND_DATA_TYPE = "application/x-ucl-uikit-dnd";
|
|
3
|
+
export type DropZoneAcceptedTypes = string | readonly string[];
|
|
4
|
+
export type DropZoneRejectionReason = 'invalid-type' | 'cannot-drop';
|
|
5
|
+
export interface DragData<TData = unknown> {
|
|
6
|
+
data: TData;
|
|
7
|
+
rawData?: string;
|
|
8
|
+
type: string;
|
|
9
|
+
}
|
|
10
|
+
export interface KeyboardDragData<TData = unknown> extends DragData<TData> {
|
|
11
|
+
id: string;
|
|
12
|
+
rawData: string;
|
|
13
|
+
}
|
|
14
|
+
export interface DropZoneDrop<TData = unknown> extends DragData<TData> {
|
|
15
|
+
dataTransfer: DataTransfer | null;
|
|
16
|
+
files: File[];
|
|
17
|
+
rawData: string;
|
|
18
|
+
}
|
|
19
|
+
export interface DropZoneRejection<TData = unknown> {
|
|
20
|
+
drop: DropZoneDrop<TData> | null;
|
|
21
|
+
reason: DropZoneRejectionReason;
|
|
22
|
+
}
|
|
23
|
+
export interface UseDropZoneOptions<TData = unknown> {
|
|
24
|
+
acceptedTypes?: DropZoneAcceptedTypes;
|
|
25
|
+
canDrop?: (drop: DropZoneDrop<TData>) => boolean;
|
|
26
|
+
disabled?: boolean;
|
|
27
|
+
dropEffect?: DataTransfer['dropEffect'];
|
|
28
|
+
keyboardDrop?: boolean;
|
|
29
|
+
onDrop?: (drop: DropZoneDrop<TData>, event: DropZoneEvent) => void;
|
|
30
|
+
onReject?: (rejection: DropZoneRejection<TData>, event: DropZoneEvent) => void;
|
|
31
|
+
parseData?: (rawData: string, type: string) => TData;
|
|
32
|
+
}
|
|
33
|
+
export type DropZoneEvent = DragEvent<HTMLElement> | KeyboardEvent<HTMLElement>;
|
|
34
|
+
export interface DropZoneRootProps<TElement extends HTMLElement> extends HTMLAttributes<TElement> {
|
|
35
|
+
ref: RefCallback<TElement>;
|
|
36
|
+
'aria-disabled'?: boolean;
|
|
37
|
+
'data-drag-active': boolean;
|
|
38
|
+
'data-drag-accept': boolean;
|
|
39
|
+
'data-drag-reject': boolean;
|
|
40
|
+
}
|
|
41
|
+
export interface UseDropZoneReturn<TData = unknown> {
|
|
42
|
+
activeTypes: string[];
|
|
43
|
+
getRootProps: <TElement extends HTMLElement = HTMLDivElement>(props?: HTMLAttributes<TElement> & {
|
|
44
|
+
ref?: Ref<TElement>;
|
|
45
|
+
}) => DropZoneRootProps<TElement>;
|
|
46
|
+
isDragAccept: boolean;
|
|
47
|
+
isDragActive: boolean;
|
|
48
|
+
isDragReject: boolean;
|
|
49
|
+
lastDrop: DropZoneDrop<TData> | null;
|
|
50
|
+
lastRejection: DropZoneRejection<TData> | null;
|
|
51
|
+
}
|
|
52
|
+
export declare const getActiveKeyboardDrag: () => KeyboardDragData<unknown> | null;
|
|
53
|
+
export declare const setActiveKeyboardDrag: (dragData: KeyboardDragData<unknown>) => void;
|
|
54
|
+
export declare const clearActiveKeyboardDrag: () => void;
|
|
55
|
+
export declare const subscribeToKeyboardDrag: (listener: () => void) => () => void;
|
|
56
|
+
declare const useDropZone: <TData = unknown>({ acceptedTypes, canDrop, disabled, dropEffect, keyboardDrop, onDrop: onDropCallback, onReject, parseData, }?: UseDropZoneOptions<TData>) => UseDropZoneReturn<TData>;
|
|
57
|
+
export default useDropZone;
|