@linzjs/lui 21.0.1 → 21.1.1

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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [21.1.1](https://github.com/linz/lui/compare/v21.1.0...v21.1.1) (2023-10-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * strip out those pesky clip-paths with duplicate ids when generating svgs ([#1024](https://github.com/linz/lui/issues/1024)) ([dbee9cc](https://github.com/linz/lui/commit/dbee9cca5c6422f5587aab712151401e8863b95d))
7
+
8
+ # [21.1.0](https://github.com/linz/lui/compare/v21.0.1...v21.1.0) (2023-10-05)
9
+
10
+
11
+ ### Features
12
+
13
+ * **Splitter:** add splitter from Memorials ([#1020](https://github.com/linz/lui/issues/1020)) ([4cf1430](https://github.com/linz/lui/commit/4cf1430945de48d9f858f2c89a6c331e8fc7b092))
14
+
1
15
  ## [21.0.1](https://github.com/linz/lui/compare/v21.0.0...v21.0.1) (2023-10-04)
2
16
 
3
17
 
@@ -390,14 +390,9 @@ iconMap['ic_basemap_off'] = (
390
390
 
391
391
  iconMap['ic_blackwhite_greyscale'] = (
392
392
  <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
393
- <g clipPath="url(#a)">
393
+ <g>
394
394
  <path d="M12 22c5.52 0 10-4.48 10-10S17.52 2 12 2 2 6.48 2 12s4.48 10 10 10Zm1-17.93c3.94.49 7 3.85 7 7.93s-3.05 7.44-7 7.93V4.07Z" />
395
395
  </g>
396
- <defs>
397
- <clipPath id="a">
398
- <path d="M0 0h24v24H0z" />
399
- </clipPath>
400
- </defs>
401
396
  </svg>
402
397
  );
403
398
 
@@ -421,14 +416,9 @@ iconMap['ic_cancel_clear'] = (
421
416
 
422
417
  iconMap['ic_cancel_outline'] = (
423
418
  <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
424
- <g clipPath="url(#a)">
419
+ <g>
425
420
  <path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2Zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8Zm3.59-13L12 10.59 8.41 7 7 8.41 10.59 12 7 15.59 8.41 17 12 13.41 15.59 17 17 15.59 13.41 12 17 8.41 15.59 7Z" />
426
421
  </g>
427
- <defs>
428
- <clipPath id="a">
429
- <path d="M0 0h24v24H0z" />
430
- </clipPath>
431
- </defs>
432
422
  </svg>
433
423
  );
434
424
 
@@ -567,14 +557,9 @@ iconMap['ic_dealings'] = (
567
557
 
568
558
  iconMap['ic_delete_forever'] = (
569
559
  <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
570
- <g clipPath="url(#a)">
560
+ <g>
571
561
  <path d="M14.12 10.47 12 12.59l-2.13-2.12-1.41 1.41L10.59 14l-2.12 2.12 1.41 1.41L12 15.41l2.12 2.12 1.41-1.41L13.41 14l2.12-2.12-1.41-1.41ZM15.5 4l-1-1h-5l-1 1H5v2h14V4h-3.5ZM6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12ZM8 9h8v10H8V9Z" />
572
562
  </g>
573
- <defs>
574
- <clipPath id="a">
575
- <path d="M0 0h24v24H0z" />
576
- </clipPath>
577
- </defs>
578
563
  </svg>
579
564
  );
580
565
 
@@ -920,14 +905,9 @@ iconMap['ic_lock'] = (
920
905
 
921
906
  iconMap['ic_lock_alt'] = (
922
907
  <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
923
- <g clipPath="url(#a)">
908
+ <g>
924
909
  <path d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2ZM9 6c0-1.66 1.34-3 3-3s3 1.34 3 3v2H9V6Zm9 14H6V10h12v10Zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2Z" />
925
910
  </g>
926
- <defs>
927
- <clipPath id="a">
928
- <path d="M0 0h24v24H0z" />
929
- </clipPath>
930
- </defs>
931
911
  </svg>
932
912
  );
933
913
 
@@ -1031,14 +1011,9 @@ iconMap['ic_notice_of_change'] = (
1031
1011
 
1032
1012
  iconMap['ic_notifications'] = (
1033
1013
  <svg viewBox="0 0 24 24">
1034
- <g clipPath="url(#a)">
1014
+ <g>
1035
1015
  <path d="M12 22c1.1 0 2-.9 2-2h-4c0 1.1.9 2 2 2Zm6-6v-5c0-3.07-1.63-5.64-4.5-6.32V4c0-.83-.67-1.5-1.5-1.5s-1.5.67-1.5 1.5v.68C7.64 5.36 6 7.92 6 11v5l-2 2v1h16v-1l-2-2Zm-2 1H8v-6c0-2.48 1.51-4.5 4-4.5s4 2.02 4 4.5v6Z" />
1036
1016
  </g>
1037
- <defs>
1038
- <clipPath id="a">
1039
- <path d="M0 0h24v24H0z" />
1040
- </clipPath>
1041
- </defs>
1042
1017
  </svg>
1043
1018
  );
1044
1019
 
@@ -1064,15 +1039,10 @@ iconMap['ic_order_history'] = (
1064
1039
 
1065
1040
  iconMap['ic_package'] = (
1066
1041
  <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
1067
- <g clipPath="url(#a)">
1042
+ <g>
1068
1043
  <path d="M20 2H4c-1 0-2 .9-2 2v3.01c0 .72.43 1.34 1 1.69V20c0 1.1 1.1 2 2 2h14c.9 0 2-.9 2-2V8.7c.57-.35 1-.97 1-1.69V4c0-1.1-1-2-2-2Zm-1 18H5V9h14v11Zm1-13H4V4h16v3Z" />
1069
1044
  <path d="M15 12H9v2h6v-2Z" />
1070
1045
  </g>
1071
- <defs>
1072
- <clipPath id="a">
1073
- <path d="M0 0h24v24H0z" />
1074
- </clipPath>
1075
- </defs>
1076
1046
  </svg>
1077
1047
  );
1078
1048
 
@@ -1148,14 +1118,9 @@ iconMap['ic_placeholder'] = (
1148
1118
 
1149
1119
  iconMap['ic_plus_one'] = (
1150
1120
  <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
1151
- <g clipPath="url(#a)">
1121
+ <g>
1152
1122
  <path d="M10 8H8v4H4v2h4v4h2v-4h4v-2h-4V8Zm4.5-1.92V7.9l2.5-.5V18h2V5l-4.5 1.08Z" />
1153
1123
  </g>
1154
- <defs>
1155
- <clipPath id="a">
1156
- <path d="M0 0h24v24H0z" />
1157
- </clipPath>
1158
- </defs>
1159
1124
  </svg>
1160
1125
  );
1161
1126
 
@@ -1220,14 +1185,9 @@ iconMap['ic_refresh'] = (
1220
1185
 
1221
1186
  iconMap['ic_regenerate'] = (
1222
1187
  <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
1223
- <g clipPath="url(#a)">
1188
+ <g>
1224
1189
  <path d="M12 6v1.79c0 .45.54.67.85.35l2.79-2.79c.2-.2.2-.51 0-.71l-2.79-2.79a.5.5 0 0 0-.85.36V4c-4.42 0-8 3.58-8 8 0 1.04.2 2.04.57 2.95.27.67 1.13.85 1.64.34.27-.27.38-.68.23-1.04C6.15 13.56 6 12.79 6 12c0-3.31 2.69-6 6-6Zm5.79 2.71c-.27.27-.38.69-.23 1.04.28.7.44 1.46.44 2.25 0 3.31-2.69 6-6 6v-1.79c0-.45-.54-.67-.85-.35l-2.79 2.79c-.2.2-.2.51 0 .71l2.79 2.79a.5.5 0 0 0 .85-.35V20c4.42 0 8-3.58 8-8 0-1.04-.2-2.04-.57-2.95-.27-.67-1.13-.85-1.64-.34Z" />
1225
1190
  </g>
1226
- <defs>
1227
- <clipPath id="a">
1228
- <path d="M0 0h24v24H0z" />
1229
- </clipPath>
1230
- </defs>
1231
1191
  </svg>
1232
1192
  );
1233
1193
 
@@ -1263,15 +1223,10 @@ iconMap['ic_requisitions'] = (
1263
1223
 
1264
1224
  iconMap['ic_restore'] = (
1265
1225
  <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
1266
- <g clipPath="url(#a)">
1226
+ <g>
1267
1227
  <path d="M14 2H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6Zm4 18H6V4h7.17L18 8.83V20Z" />
1268
1228
  <path d="m16.72 9.4-1.17 1.17a4.477 4.477 0 0 0-3.77-2.07c-2.48 0-4.5 2.02-4.5 4.5s2.02 4.5 4.5 4.5a4.51 4.51 0 0 0 4.12-2.7h-1.55a3.14 3.14 0 0 1-2.58 1.35 3.15 3.15 0 1 1 0-6.3c1.21 0 2.27.7 2.79 1.71L13.12 13h3.6V9.4Z" />
1269
1229
  </g>
1270
- <defs>
1271
- <clipPath id="a">
1272
- <path d="M0 0h24v24H0z" />
1273
- </clipPath>
1274
- </defs>
1275
1230
  </svg>
1276
1231
  );
1277
1232
 
@@ -1443,14 +1398,9 @@ iconMap['ic_unlink'] = (
1443
1398
 
1444
1399
  iconMap['ic_unlock'] = (
1445
1400
  <svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
1446
- <g clipPath="url(#a)">
1401
+ <g>
1447
1402
  <path d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6h2c0-1.66 1.34-3 3-3s3 1.34 3 3v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2Zm0 12H6V10h12v10Zm-6-3c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2Z" />
1448
1403
  </g>
1449
- <defs>
1450
- <clipPath id="a">
1451
- <path d="M0 0h24v24H0z" />
1452
- </clipPath>
1453
- </defs>
1454
1404
  </svg>
1455
1405
  );
1456
1406
 
@@ -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,7 @@
1
+ import { RefObject } from 'react';
2
+ declare type Side = 'primary' | 'secondary';
3
+ export declare const ControlIcon: ({ parent, side, }: {
4
+ side: Side;
5
+ parent: RefObject<HTMLButtonElement>;
6
+ }) => JSX.Element | null;
7
+ 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,4 @@
1
+ /// <reference types="react" />
2
+ declare type ForwardedRef<T> = ((instance: T | null) => void) | React.MutableRefObject<T | null> | null;
3
+ export declare const useForkRef: <T>(forwardedRef: ForwardedRef<T>) => import("react").RefObject<T>;
4
+ export {};
@@ -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
+ };
@@ -0,0 +1,5 @@
1
+ import { RefObject } from 'react';
2
+ export declare const useSplitterRef: () => {
3
+ ref: RefObject<HTMLDivElement>;
4
+ setRatio: (val: number) => void;
5
+ };
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';