@true-engineering/true-react-common-ui-kit 4.0.0-alpha66 → 4.0.0-alpha68
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/Notification/Notification.d.ts +3 -3
- package/dist/components/Selector/Selector.styles.d.ts +1 -7
- package/dist/hooks/use-resize-ref.d.ts +3 -3
- package/dist/true-react-common-ui-kit.js +71 -159
- package/dist/true-react-common-ui-kit.js.map +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs +1 -1
- package/dist/true-react-common-ui-kit.umd.cjs.map +1 -1
- package/package.json +1 -1
- package/src/components/Notification/Notification.stories.tsx +3 -1
- package/src/components/Notification/Notification.tsx +9 -17
- package/src/components/Selector/Selector.stories.tsx +4 -0
- package/src/components/Selector/Selector.styles.ts +31 -133
- package/src/components/Selector/Selector.tsx +35 -48
- package/src/hooks/use-resize-ref.ts +5 -5
|
@@ -7,11 +7,11 @@ export interface INotificationProps extends ICommonProps<INotificationStyles> {
|
|
|
7
7
|
type: INotificationType;
|
|
8
8
|
/** @default true */
|
|
9
9
|
isFullWidth?: boolean;
|
|
10
|
-
text?:
|
|
11
|
-
title?:
|
|
10
|
+
text?: ReactNode;
|
|
11
|
+
title?: ReactNode;
|
|
12
12
|
/** @default 's' */
|
|
13
13
|
size?: 's' | 'm' | 'l';
|
|
14
|
-
icon?: IIcon;
|
|
14
|
+
icon?: IIcon | null;
|
|
15
15
|
children?: ReactNode;
|
|
16
16
|
}
|
|
17
17
|
export declare const Notification: FC<INotificationProps>;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import { CSSProperties } from 'react';
|
|
2
1
|
import { ITweakStyles } from '../../theme';
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const getSelectorLineStyle: (activeElementData?: {
|
|
5
|
-
clientWidth: number;
|
|
6
|
-
offsetLeft: number;
|
|
7
|
-
}) => CSSProperties | undefined;
|
|
8
|
-
export declare const useStyles: import('../../theme').IUseStyles<"option" | "s" | "line" | "invalid" | "root" | "active" | "disabled" | "m" | "l" | "iconFromRight" | "required" | "optionWrapper" | "optionIcon" | "optionText" | "selector" | "autoWidth">;
|
|
2
|
+
export declare const useStyles: import('../../theme').IUseStyles<"option" | "s" | "invalid" | "active" | "disabled" | "m" | "l" | "iconFromRight" | "required" | "selector" | "autoWidth" | "optionIcon" | "optionText">;
|
|
9
3
|
export type ISelectorStyles = ITweakStyles<typeof useStyles>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { RefCallback } from 'react';
|
|
2
|
-
export interface IResizeRefOptions {
|
|
2
|
+
export interface IResizeRefOptions<T extends Element> {
|
|
3
3
|
/** @default false */
|
|
4
4
|
isDisabled?: boolean;
|
|
5
5
|
onChange?: (entry: ResizeObserverEntry) => void;
|
|
6
|
-
onTargetChange?: (target:
|
|
6
|
+
onTargetChange?: (target: T) => void;
|
|
7
7
|
}
|
|
8
|
-
export declare const useResizeRef: (options: IResizeRefOptions) => RefCallback<
|
|
8
|
+
export declare const useResizeRef: <T extends Element>(options: IResizeRefOptions<T>) => RefCallback<T>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createContext, useContext, useMemo, useRef, useEffect, memo, useLayoutEffect, useCallback, useState, Fragment as Fragment$1, forwardRef, PureComponent, createRef, createElement } from "react";
|
|
2
2
|
import { createUseStyles } from "react-jss";
|
|
3
|
-
import { isObject, isString, isNotEmpty, isArrayNotEmpty, mergeStyles, isStringEmpty, isStringNotEmpty, mergeRefs, isFunction, isEmpty, addDataAttributes as addDataAttributes$1, stopPropagation, applyAction, isReactNodeNotEmpty, addClickHandler, getTestId, getSelectKeyHandler, addDataTestId, getArray, isArrayLikeNotEmpty, doNothing, createFilter, merge, getTransition, indexMap, isNumberInteger,
|
|
3
|
+
import { isObject, isString, isNotEmpty, isArrayNotEmpty, mergeStyles, isStringEmpty, isStringNotEmpty, mergeRefs, isFunction, isEmpty, addDataAttributes as addDataAttributes$1, stopPropagation, applyAction, isReactNodeNotEmpty, addClickHandler, getTestId, getSelectKeyHandler, addDataTestId, getArray, isArrayLikeNotEmpty, doNothing, createFilter, merge, getTransition, indexMap, isNumberInteger, isArrayEmpty } from "@true-engineering/true-react-platform-helpers";
|
|
4
4
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
5
|
import { CSSTransition } from "react-transition-group";
|
|
6
6
|
import clsx from "clsx";
|
|
@@ -10333,14 +10333,12 @@ const Notification = ({
|
|
|
10333
10333
|
testId,
|
|
10334
10334
|
size: size2 = "s",
|
|
10335
10335
|
data,
|
|
10336
|
-
icon,
|
|
10336
|
+
icon = type !== "custom" ? `status-${type}` : void 0,
|
|
10337
10337
|
tweakStyles
|
|
10338
10338
|
}) => {
|
|
10339
10339
|
const classes = useStyles$b({ theme: tweakStyles });
|
|
10340
|
-
const hasText =
|
|
10341
|
-
const hasTitle =
|
|
10342
|
-
const isDefaultType = type !== "custom";
|
|
10343
|
-
const hasIcon = isReactNodeNotEmpty(icon) || isDefaultType;
|
|
10340
|
+
const hasText = isReactNodeNotEmpty(text);
|
|
10341
|
+
const hasTitle = isReactNodeNotEmpty(title);
|
|
10344
10342
|
return /* @__PURE__ */ jsxs(
|
|
10345
10343
|
"div",
|
|
10346
10344
|
{
|
|
@@ -10351,7 +10349,7 @@ const Notification = ({
|
|
|
10351
10349
|
}),
|
|
10352
10350
|
...addDataAttributes$1(data, testId),
|
|
10353
10351
|
children: [
|
|
10354
|
-
|
|
10352
|
+
isNotEmpty(icon) && /* @__PURE__ */ jsx("div", { className: classes.icon, children: renderIcon(icon) }),
|
|
10355
10353
|
/* @__PURE__ */ jsxs("div", { className: classes.body, children: [
|
|
10356
10354
|
hasTitle && /* @__PURE__ */ jsx("span", { className: classes.title, ...addDataTestId(testId, "title"), children: title }),
|
|
10357
10355
|
hasText && /* @__PURE__ */ jsx("span", { className: classes.text, ...addDataTestId(testId, "text"), children: text }),
|
|
@@ -10835,131 +10833,49 @@ function RadioButton({
|
|
|
10835
10833
|
}
|
|
10836
10834
|
);
|
|
10837
10835
|
}
|
|
10838
|
-
const SELECTOR_TOTAL_GAP = 4;
|
|
10839
|
-
const SELECTOR_BORDER_WIDTH = 1;
|
|
10840
|
-
const SELECTOR_GAP = SELECTOR_TOTAL_GAP - SELECTOR_BORDER_WIDTH;
|
|
10841
|
-
const getSelectorLineStyle = (activeElementData) => isNotEmpty(activeElementData) ? {
|
|
10842
|
-
width: activeElementData.clientWidth - SELECTOR_GAP * 2,
|
|
10843
|
-
transform: `translateX(${activeElementData.offsetLeft}px)`
|
|
10844
|
-
} : void 0;
|
|
10845
10836
|
const useStyles$7 = createThemedStyles("Selector", {
|
|
10846
|
-
|
|
10847
|
-
display: "
|
|
10848
|
-
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
|
|
10852
|
-
|
|
10853
|
-
"&::before": {
|
|
10854
|
-
top: "50%",
|
|
10855
|
-
left: -12,
|
|
10856
|
-
width: 6,
|
|
10857
|
-
height: 6,
|
|
10837
|
+
selector: {
|
|
10838
|
+
display: "grid",
|
|
10839
|
+
gridAutoFlow: "column",
|
|
10840
|
+
gridAutoColumns: "auto",
|
|
10841
|
+
boxSizing: "border-box",
|
|
10842
|
+
position: "relative",
|
|
10843
|
+
"&:has($active)::before": {
|
|
10858
10844
|
content: '""',
|
|
10859
10845
|
position: "absolute",
|
|
10860
|
-
|
|
10861
|
-
|
|
10862
|
-
|
|
10846
|
+
transition: animations.defaultTransition,
|
|
10847
|
+
transitionProperty: "left, width",
|
|
10848
|
+
width: "var(--active-element-width)",
|
|
10849
|
+
height: "var(--active-element-height)",
|
|
10850
|
+
top: "var(--active-element-top)",
|
|
10851
|
+
left: "var(--active-element-left)"
|
|
10863
10852
|
}
|
|
10864
10853
|
},
|
|
10865
|
-
|
|
10866
|
-
|
|
10867
|
-
height: "100%"
|
|
10854
|
+
autoWidth: {
|
|
10855
|
+
gridAutoColumns: "1fr"
|
|
10868
10856
|
},
|
|
10857
|
+
required: {},
|
|
10858
|
+
invalid: {},
|
|
10869
10859
|
option: {
|
|
10860
|
+
appearance: "none",
|
|
10861
|
+
background: "none",
|
|
10862
|
+
border: "none",
|
|
10870
10863
|
display: "flex",
|
|
10871
10864
|
alignItems: "center",
|
|
10872
10865
|
justifyContent: "center",
|
|
10873
|
-
|
|
10874
|
-
|
|
10875
|
-
padding: 0,
|
|
10876
|
-
border: "none",
|
|
10877
|
-
cursor: "pointer",
|
|
10878
|
-
width: "100%"
|
|
10879
|
-
},
|
|
10880
|
-
active: {
|
|
10881
|
-
cursor: "default"
|
|
10882
|
-
},
|
|
10883
|
-
disabled: {
|
|
10884
|
-
cursor: "default",
|
|
10885
|
-
"& $optionText": {
|
|
10886
|
-
color: colors.FONT_LABEL
|
|
10887
|
-
}
|
|
10888
|
-
},
|
|
10889
|
-
optionIcon: {
|
|
10890
|
-
width: 20,
|
|
10891
|
-
height: 20
|
|
10892
|
-
},
|
|
10893
|
-
optionText: {},
|
|
10894
|
-
iconFromRight: {
|
|
10895
|
-
"& $option": {
|
|
10866
|
+
zIndex: 1,
|
|
10867
|
+
"$iconFromRight &": {
|
|
10896
10868
|
flexDirection: "row-reverse"
|
|
10897
10869
|
}
|
|
10898
10870
|
},
|
|
10871
|
+
active: {},
|
|
10872
|
+
disabled: {},
|
|
10873
|
+
optionIcon: {},
|
|
10874
|
+
optionText: {},
|
|
10875
|
+
iconFromRight: {},
|
|
10899
10876
|
s: {},
|
|
10900
10877
|
m: {},
|
|
10901
|
-
l: {}
|
|
10902
|
-
line: {},
|
|
10903
|
-
selector: {
|
|
10904
|
-
display: "grid",
|
|
10905
|
-
gridAutoFlow: "column",
|
|
10906
|
-
gridAutoColumns: "1fr",
|
|
10907
|
-
borderRadius: dimensions.BORDER_RADIUS_SMALL,
|
|
10908
|
-
backgroundColor: colors.BORDER_LIGHT,
|
|
10909
|
-
width: "fit-content",
|
|
10910
|
-
position: "relative",
|
|
10911
|
-
border: ["solid", SELECTOR_BORDER_WIDTH, "transparent"],
|
|
10912
|
-
"& $line": {
|
|
10913
|
-
content: '""',
|
|
10914
|
-
position: "absolute",
|
|
10915
|
-
left: SELECTOR_GAP,
|
|
10916
|
-
height: `calc(100% - ${SELECTOR_GAP * 2}px)`,
|
|
10917
|
-
backgroundColor: colors.CLASSIC_WHITE,
|
|
10918
|
-
borderRadius: dimensions.BORDER_RADIUS_SMALL,
|
|
10919
|
-
transition: animations.defaultTransition,
|
|
10920
|
-
transitionProperty: "transform, width"
|
|
10921
|
-
},
|
|
10922
|
-
"&$invalid": {
|
|
10923
|
-
borderColor: colors.RED_WARNING
|
|
10924
|
-
},
|
|
10925
|
-
"& $option": {
|
|
10926
|
-
gap: 6,
|
|
10927
|
-
position: "relative",
|
|
10928
|
-
zIndex: 1,
|
|
10929
|
-
height: "100%",
|
|
10930
|
-
color: colors.FONT_MEDIUM,
|
|
10931
|
-
fontSize: 16,
|
|
10932
|
-
transition: animations.defaultTransition,
|
|
10933
|
-
transitionProperty: "color",
|
|
10934
|
-
background: "none",
|
|
10935
|
-
"&$s": {
|
|
10936
|
-
padding: [4, 8],
|
|
10937
|
-
fontSize: 10,
|
|
10938
|
-
lineHeight: "14px"
|
|
10939
|
-
},
|
|
10940
|
-
"&$m": {
|
|
10941
|
-
padding: [14, 18]
|
|
10942
|
-
},
|
|
10943
|
-
"&$l": {
|
|
10944
|
-
padding: [16, 24]
|
|
10945
|
-
},
|
|
10946
|
-
"&:hover, &:focus": {
|
|
10947
|
-
color: colors.FONT_MAIN
|
|
10948
|
-
},
|
|
10949
|
-
"&$active": {
|
|
10950
|
-
color: colors.FONT_MAIN
|
|
10951
|
-
}
|
|
10952
|
-
}
|
|
10953
|
-
},
|
|
10954
|
-
autoWidth: {
|
|
10955
|
-
"&$selector": {
|
|
10956
|
-
gridAutoColumns: "auto",
|
|
10957
|
-
"& $line": {
|
|
10958
|
-
width: "unset",
|
|
10959
|
-
transform: "unset"
|
|
10960
|
-
}
|
|
10961
|
-
}
|
|
10962
|
-
}
|
|
10878
|
+
l: {}
|
|
10963
10879
|
});
|
|
10964
10880
|
function Selector({
|
|
10965
10881
|
options,
|
|
@@ -10975,57 +10891,53 @@ function Selector({
|
|
|
10975
10891
|
tweakStyles,
|
|
10976
10892
|
onChange
|
|
10977
10893
|
}) {
|
|
10978
|
-
const classes = useStyles$7({
|
|
10979
|
-
const
|
|
10980
|
-
|
|
10981
|
-
|
|
10982
|
-
|
|
10983
|
-
|
|
10984
|
-
|
|
10985
|
-
useEffect(() => {
|
|
10986
|
-
const listEl = listRef.current;
|
|
10987
|
-
if (listEl === null) {
|
|
10988
|
-
return;
|
|
10894
|
+
const classes = useStyles$7({ tweakStyles });
|
|
10895
|
+
const updateVariables = (active) => {
|
|
10896
|
+
if (isNotEmpty(active?.parentElement)) {
|
|
10897
|
+
active.parentElement.style.setProperty("--active-element-width", `${active.clientWidth}px`);
|
|
10898
|
+
active.parentElement.style.setProperty("--active-element-height", `${active.clientHeight}px`);
|
|
10899
|
+
active.parentElement.style.setProperty("--active-element-left", `${active.offsetLeft}px`);
|
|
10900
|
+
active.parentElement.style.setProperty("--active-element-top", `${active.offsetTop}px`);
|
|
10989
10901
|
}
|
|
10990
|
-
|
|
10991
|
-
|
|
10992
|
-
|
|
10993
|
-
|
|
10902
|
+
};
|
|
10903
|
+
const resizeRef = useResizeRef({
|
|
10904
|
+
onTargetChange: (target) => updateVariables(target.querySelector(`.${classes.active}`))
|
|
10905
|
+
});
|
|
10906
|
+
return /* @__PURE__ */ jsx(
|
|
10994
10907
|
"div",
|
|
10995
10908
|
{
|
|
10996
|
-
|
|
10909
|
+
ref: resizeRef,
|
|
10910
|
+
className: clsx(classes.selector, classes[size2], {
|
|
10997
10911
|
[classes.iconFromRight]: iconPosition === "right",
|
|
10998
10912
|
[classes.invalid]: isInvalid,
|
|
10999
10913
|
[classes.required]: isRequired,
|
|
11000
10914
|
[classes.autoWidth]: hasSameOptionsWidth
|
|
11001
10915
|
}),
|
|
11002
|
-
ref: listRef,
|
|
11003
10916
|
...addDataAttributes$1(data, testId),
|
|
11004
|
-
children:
|
|
11005
|
-
|
|
11006
|
-
|
|
11007
|
-
|
|
11008
|
-
|
|
11009
|
-
|
|
11010
|
-
|
|
11011
|
-
|
|
11012
|
-
|
|
11013
|
-
|
|
11014
|
-
|
|
11015
|
-
|
|
11016
|
-
|
|
11017
|
-
|
|
11018
|
-
|
|
11019
|
-
|
|
11020
|
-
|
|
11021
|
-
children:
|
|
11022
|
-
|
|
11023
|
-
|
|
11024
|
-
|
|
11025
|
-
|
|
11026
|
-
|
|
11027
|
-
|
|
11028
|
-
]
|
|
10917
|
+
children: options.map((option) => {
|
|
10918
|
+
const optionId = String(option.value);
|
|
10919
|
+
const isDisabledOption = option.isDisabled || isDisabled;
|
|
10920
|
+
const isActiveOption = option.value === value;
|
|
10921
|
+
return /* @__PURE__ */ jsxs(
|
|
10922
|
+
"button",
|
|
10923
|
+
{
|
|
10924
|
+
ref: isActiveOption ? updateVariables : void 0,
|
|
10925
|
+
type: "button",
|
|
10926
|
+
className: clsx(classes.option, {
|
|
10927
|
+
[classes.active]: isActiveOption,
|
|
10928
|
+
[classes.disabled]: isDisabledOption
|
|
10929
|
+
}),
|
|
10930
|
+
disabled: isDisabledOption,
|
|
10931
|
+
onClick: !isDisabledOption ? () => onChange(option.value) : void 0,
|
|
10932
|
+
...addDataTestId(testId, optionId),
|
|
10933
|
+
children: [
|
|
10934
|
+
isReactNodeNotEmpty(option.icon) && /* @__PURE__ */ jsx("div", { className: classes.optionIcon, children: renderIcon(option.icon) }),
|
|
10935
|
+
/* @__PURE__ */ jsx("div", { className: classes.optionText, children: option.label })
|
|
10936
|
+
]
|
|
10937
|
+
},
|
|
10938
|
+
optionId
|
|
10939
|
+
);
|
|
10940
|
+
})
|
|
11029
10941
|
}
|
|
11030
10942
|
);
|
|
11031
10943
|
}
|