@linzjs/lui 21.0.1 → 21.1.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 +7 -0
- package/dist/components/LuiResizableLayout/LuiResizableLayout.d.ts +3 -0
- package/dist/components/Splitter/Control/Control.d.ts +9 -0
- package/dist/components/Splitter/Control/ControlIcon.d.ts +7 -0
- package/dist/components/Splitter/Separator/Separator.d.ts +10 -0
- package/dist/components/Splitter/Splitter.d.ts +30 -0
- package/dist/components/Splitter/helpers/clampSeparator.d.ts +10 -0
- package/dist/components/Splitter/helpers/getKeyDownDeltaMove.d.ts +7 -0
- package/dist/components/Splitter/helpers/getSeparatorAttributes.d.ts +25 -0
- package/dist/components/Splitter/helpers/getSeparatorPosition.d.ts +7 -0
- package/dist/components/Splitter/helpers/useForkRef.d.ts +4 -0
- package/dist/components/Splitter/helpers/useMoveSeparator.d.ts +11 -0
- package/dist/components/Splitter/helpers/useShowSeparator.d.ts +7 -0
- package/dist/components/Splitter/helpers/useValueSeparator.d.ts +16 -0
- package/dist/components/Splitter/useSplitterRef.d.ts +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +556 -36
- package/dist/index.js.map +1 -1
- package/dist/lui.esm.js +555 -37
- package/dist/lui.esm.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [21.1.0](https://github.com/linz/lui/compare/v21.0.1...v21.1.0) (2023-10-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **Splitter:** add splitter from Memorials ([#1020](https://github.com/linz/lui/issues/1020)) ([4cf1430](https://github.com/linz/lui/commit/4cf1430945de48d9f858f2c89a6c331e8fc7b092))
|
|
7
|
+
|
|
1
8
|
## [21.0.1](https://github.com/linz/lui/compare/v21.0.0...v21.0.1) (2023-10-04)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -6,6 +6,9 @@ export declare enum SplitPanelState {
|
|
|
6
6
|
CLOSED_LEFT = 1,
|
|
7
7
|
CLOSED_RIGHT = 2
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* @deprecated replaced by Splitter
|
|
11
|
+
*/
|
|
9
12
|
export declare const LuiResizableLayout: React.FC<{
|
|
10
13
|
givenLeftRef?: RefObject<HTMLDivElement>;
|
|
11
14
|
givenRightRef?: RefObject<HTMLDivElement>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React, { ComponentPropsWithRef } from 'react';
|
|
2
|
+
import { LuiButton } from '../../LuiButton/LuiButton';
|
|
3
|
+
import './Control.scss';
|
|
4
|
+
declare type ButtonProps = Partial<ComponentPropsWithRef<typeof LuiButton>>;
|
|
5
|
+
declare type Props = {
|
|
6
|
+
side: 'primary' | 'secondary';
|
|
7
|
+
} & ButtonProps;
|
|
8
|
+
export declare const Control: React.ForwardRefExoticComponent<Pick<Props, "href" | "openInNewTab" | "level" | "type" | "size" | "disabled" | "style" | "onClick" | "name" | "title" | "data-testid" | "className" | "buttonProps" | "children" | "key" | "side"> & React.RefAttributes<HTMLButtonElement>>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import './Separator.scss';
|
|
2
|
+
import React, { ComponentProps } from 'react';
|
|
3
|
+
import { Splitter } from '../Splitter';
|
|
4
|
+
declare type Parts = NonNullable<ComponentProps<typeof Splitter>['parts']>['controls'];
|
|
5
|
+
export declare const Separator: React.ForwardRefExoticComponent<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.HTMLAttributes<HTMLDivElement> | "key"> & {
|
|
6
|
+
parts?: Parts;
|
|
7
|
+
ratio?: number | undefined;
|
|
8
|
+
onResized?: ((val: number) => void) | undefined;
|
|
9
|
+
} & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { ComponentPropsWithRef } from 'react';
|
|
2
|
+
import './Splitter.scss';
|
|
3
|
+
import { LuiButton } from '../LuiButton/LuiButton';
|
|
4
|
+
declare type ButtonProps = Omit<ComponentPropsWithRef<typeof LuiButton>, 'children'> & {
|
|
5
|
+
children?: React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Container that appends a separator when the children count equals 2.
|
|
9
|
+
* It looks at HTML nodes, not React components
|
|
10
|
+
*/
|
|
11
|
+
export declare const Splitter: React.ForwardRefExoticComponent<{
|
|
12
|
+
ratio?: number | undefined;
|
|
13
|
+
min?: number | undefined;
|
|
14
|
+
max?: number | undefined;
|
|
15
|
+
onResized?: ((ratio: number) => void) | undefined;
|
|
16
|
+
orientation?: "horizontal" | "vertical" | undefined;
|
|
17
|
+
parts?: {
|
|
18
|
+
separator?: (Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
|
|
19
|
+
ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
|
|
20
|
+
}) | undefined;
|
|
21
|
+
controls?: {
|
|
22
|
+
container?: (Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "key" | keyof React.HTMLAttributes<HTMLSpanElement>> & {
|
|
23
|
+
ref?: ((instance: HTMLSpanElement | null) => void) | React.RefObject<HTMLSpanElement> | null | undefined;
|
|
24
|
+
}) | undefined;
|
|
25
|
+
primary?: ButtonProps | undefined;
|
|
26
|
+
secondary?: ButtonProps | undefined;
|
|
27
|
+
} | undefined;
|
|
28
|
+
} | undefined;
|
|
29
|
+
} & React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Delimits the separator position value between 0 to 100 by default.
|
|
3
|
+
* It will prioritize supplied min and max delimiters as long as they are within the 0-100 range.
|
|
4
|
+
* @param props Expects a separator value and optional min and max delimiters
|
|
5
|
+
*/
|
|
6
|
+
export declare const clampSeparator: (props: {
|
|
7
|
+
min?: number | undefined;
|
|
8
|
+
value: number;
|
|
9
|
+
max?: number | undefined;
|
|
10
|
+
}) => number;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare type Event = Pick<React.KeyboardEvent<HTMLDivElement>, 'currentTarget' | 'key' | 'ctrlKey' | 'shiftKey' | 'metaKey' | 'altKey'>;
|
|
3
|
+
/**
|
|
4
|
+
* Gets the delta % the separator should move based on key down.
|
|
5
|
+
*/
|
|
6
|
+
export declare const getKeyDownDeltaMove: (e: Event, valueNow: number) => number;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
declare type Props = {
|
|
3
|
+
child: Element | null | undefined;
|
|
4
|
+
separator?: never;
|
|
5
|
+
ref?: never;
|
|
6
|
+
} | {
|
|
7
|
+
child?: never;
|
|
8
|
+
separator: Element | null | undefined;
|
|
9
|
+
ref?: never;
|
|
10
|
+
} | {
|
|
11
|
+
child?: never;
|
|
12
|
+
separator?: never;
|
|
13
|
+
ref?: RefObject<HTMLElement> | null | undefined;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Given a ref/element if finds the Separator and returns the most useful attributes
|
|
17
|
+
*/
|
|
18
|
+
export declare const getSeparatorAttributes: (props: Props) => {
|
|
19
|
+
valueNow: number;
|
|
20
|
+
valueMin: number;
|
|
21
|
+
valueMax: number;
|
|
22
|
+
orientation: "horizontal" | "vertical" | undefined;
|
|
23
|
+
thickness: number;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a value from 0 to 100 that represents the separator position from left to right.
|
|
4
|
+
* @param separatorRef Separator ref
|
|
5
|
+
* @param drag Represents mouse/touch horizontal/vertical coordinate when the user is resizing.
|
|
6
|
+
*/
|
|
7
|
+
export declare const getSeparatorPosition: (separatorRef: RefObject<HTMLDivElement>, drag: number) => number;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* It captures window events to report a new position.
|
|
4
|
+
* Provides necessary handlers for separator.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useMoveSeparator: (separator: RefObject<HTMLDivElement>, resize: (val: number) => void) => {
|
|
7
|
+
onMouseDown: () => void;
|
|
8
|
+
onTouchStart: () => void;
|
|
9
|
+
onTouchEnd: () => void;
|
|
10
|
+
onBlur: () => void;
|
|
11
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if the splitter container has 3 child nodes, including the separator.
|
|
4
|
+
* The consumer must render 2 element nodes (not components), to be able to split.
|
|
5
|
+
* @param separatorRef Separator ref
|
|
6
|
+
*/
|
|
7
|
+
export declare const useShowSeparator: (separatorRef: RefObject<HTMLDivElement>) => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Ensures valueNow is set to a valid value within its allowed boundaries.
|
|
4
|
+
* If boundaries and/or initialRatio are not specified, they will be defaulted.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useValueSeparator: ({ separator, ratio, onResized, boundaries: { min, max }, }: {
|
|
7
|
+
ratio?: number | undefined;
|
|
8
|
+
onResized?: ((newVal: number) => void) | undefined;
|
|
9
|
+
separator: RefObject<HTMLDivElement>;
|
|
10
|
+
boundaries: {
|
|
11
|
+
min: number;
|
|
12
|
+
max: number;
|
|
13
|
+
};
|
|
14
|
+
}) => {
|
|
15
|
+
setValueNow: (val?: number) => void;
|
|
16
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -65,3 +65,5 @@ export { ToolbarItem, ToolbarItemProps, ToolbarItemSeparator, } from './componen
|
|
|
65
65
|
export { Breakpoint, breakpoints, breakpointQuery, useMediaQuery, } from './components/common/UseMediaQuery';
|
|
66
66
|
export { useEscapeFunction, usePageClickFunction, } from './components/common/Hooks';
|
|
67
67
|
export { LuiCounter } from './components/LuiCounter/LuiCounter';
|
|
68
|
+
export { Splitter } from './components/Splitter/Splitter';
|
|
69
|
+
export { useSplitterRef } from './components/Splitter/useSplitterRef';
|