@equinor/eds-core-react 2.4.0 → 2.4.1-beta.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/build/index.css +370 -29
- package/build/index.min.css +1 -1
- package/dist/eds-core-react.cjs +24 -4
- package/dist/esm/components/Autocomplete/MultipleInput.js +19 -5
- package/dist/esm/components/Autocomplete/useAutocomplete.js +6 -0
- package/dist/esm/components/InputWrapper/InputWrapper.js +1 -1
- package/dist/esm/components/Textarea/Textarea.js +1 -1
- package/dist/esm-next/components/next/Banner/Banner.js +88 -0
- package/dist/esm-next/components/next/Button/Button.js +1 -2
- package/dist/esm-next/components/next/Input/Input.js +1 -1
- package/dist/esm-next/components/next/Link/Link.js +36 -0
- package/dist/esm-next/components/next/Search/Search.js +118 -0
- package/dist/esm-next/components/next/Slot/Slot.js +47 -0
- package/dist/esm-next/components/next/TextArea/TextArea.js +131 -0
- package/dist/esm-next/components/next/TextField/TextField.js +0 -1
- package/dist/esm-next/components/next/Tooltip/Tooltip.js +84 -0
- package/dist/esm-next/index.next.js +6 -0
- package/dist/index.next.cjs +474 -8
- package/dist/types/components/Autocomplete/Autocomplete.d.ts +5 -0
- package/dist/types/components/Autocomplete/AutocompleteContext.d.ts +6 -2
- package/dist/types/components/Autocomplete/useAutocomplete.d.ts +4 -2
- package/dist/types/components/next/Banner/Banner.d.ts +23 -0
- package/dist/types/components/next/Banner/Banner.figma.d.ts +1 -0
- package/dist/types/components/next/Banner/Banner.types.d.ts +33 -0
- package/dist/types/components/next/Banner/index.d.ts +2 -0
- package/dist/types/components/next/Button/Button.types.d.ts +1 -2
- package/dist/types/components/next/Input/Input.types.d.ts +4 -1
- package/dist/types/components/next/Link/Link.d.ts +4 -0
- package/dist/types/components/next/Link/Link.figma.d.ts +1 -0
- package/dist/types/components/next/Link/Link.types.d.ts +13 -0
- package/dist/types/components/next/Link/index.d.ts +2 -0
- package/dist/types/components/next/Search/Search.d.ts +9 -0
- package/dist/types/components/next/Search/Search.figma.d.ts +1 -0
- package/dist/types/components/next/Search/Search.types.d.ts +16 -0
- package/dist/types/components/next/Search/index.d.ts +2 -0
- package/dist/types/components/next/Slot/Slot.d.ts +3 -0
- package/dist/types/components/next/Slot/Slot.types.d.ts +4 -0
- package/dist/types/components/next/Slot/index.d.ts +2 -0
- package/dist/types/components/next/TextArea/TextArea.d.ts +11 -0
- package/dist/types/components/next/TextArea/TextArea.figma.d.ts +1 -0
- package/dist/types/components/next/TextArea/TextArea.types.d.ts +21 -0
- package/dist/types/components/next/TextArea/index.d.ts +2 -0
- package/dist/types/components/next/Tooltip/Tooltip.d.ts +7 -0
- package/dist/types/components/next/Tooltip/Tooltip.figma.d.ts +1 -0
- package/dist/types/components/next/Tooltip/Tooltip.types.d.ts +17 -0
- package/dist/types/components/next/Tooltip/index.d.ts +2 -0
- package/dist/types/components/next/index.d.ts +12 -0
- package/package.json +39 -32
package/dist/index.next.cjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var react = require('react');
|
|
4
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
5
4
|
var edsIcons = require('@equinor/eds-icons');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var edsUtils = require('@equinor/eds-utils');
|
|
6
7
|
var reactDom = require('react-dom');
|
|
7
8
|
var styled = require('styled-components');
|
|
8
|
-
var edsUtils = require('@equinor/eds-utils');
|
|
9
9
|
var edsTokens = require('@equinor/eds-tokens');
|
|
10
10
|
var react$1 = require('@floating-ui/react');
|
|
11
11
|
|
|
@@ -78,8 +78,7 @@ TypographyNext.displayName = 'TypographyNext';
|
|
|
78
78
|
|
|
79
79
|
const SIZE_MAPPING = {
|
|
80
80
|
small: 'sm',
|
|
81
|
-
default: 'md'
|
|
82
|
-
large: 'lg'
|
|
81
|
+
default: 'md'
|
|
83
82
|
};
|
|
84
83
|
const sizeToTypography = SIZE_MAPPING;
|
|
85
84
|
const sizeToSelectableSpace = SIZE_MAPPING;
|
|
@@ -609,7 +608,7 @@ const Input = /*#__PURE__*/react.forwardRef(function Input({
|
|
|
609
608
|
})]
|
|
610
609
|
}), /*#__PURE__*/jsxRuntime.jsx(Component, {
|
|
611
610
|
ref: ref,
|
|
612
|
-
type: type,
|
|
611
|
+
type: Component === 'textarea' ? undefined : type,
|
|
613
612
|
disabled: disabled,
|
|
614
613
|
readOnly: readOnly,
|
|
615
614
|
className: ['eds-input', className].filter(Boolean).join(' '),
|
|
@@ -709,7 +708,7 @@ const TooltipArrow = styled__default.default.svg.withConfig({
|
|
|
709
708
|
displayName: "Tooltip__TooltipArrow",
|
|
710
709
|
componentId: "sc-m2im2p-2"
|
|
711
710
|
})(["width:", ";height:", ";position:absolute;fill:", ";"], tooltip.entities.arrow.width, tooltip.entities.arrow.height, tooltip.background);
|
|
712
|
-
const Tooltip = /*#__PURE__*/react.forwardRef(function Tooltip({
|
|
711
|
+
const Tooltip$1 = /*#__PURE__*/react.forwardRef(function Tooltip({
|
|
713
712
|
title,
|
|
714
713
|
placement = 'bottom',
|
|
715
714
|
children,
|
|
@@ -856,14 +855,13 @@ const TextField = /*#__PURE__*/react.forwardRef(function TextField({
|
|
|
856
855
|
} = useFieldIds(providedId);
|
|
857
856
|
return /*#__PURE__*/jsxRuntime.jsxs(Field, {
|
|
858
857
|
disabled: disabled,
|
|
859
|
-
className: "eds-text-field",
|
|
860
858
|
children: [label && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
861
859
|
className: "eds-text-field__header",
|
|
862
860
|
children: [/*#__PURE__*/jsxRuntime.jsx(Field.Label, {
|
|
863
861
|
htmlFor: inputId,
|
|
864
862
|
indicator: indicator,
|
|
865
863
|
children: label
|
|
866
|
-
}), labelInfo && /*#__PURE__*/jsxRuntime.jsx(Tooltip, {
|
|
864
|
+
}), labelInfo && /*#__PURE__*/jsxRuntime.jsx(Tooltip$1, {
|
|
867
865
|
title: labelInfo,
|
|
868
866
|
placement: "top",
|
|
869
867
|
children: /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
@@ -901,12 +899,480 @@ const TextField = /*#__PURE__*/react.forwardRef(function TextField({
|
|
|
901
899
|
});
|
|
902
900
|
});
|
|
903
901
|
|
|
902
|
+
const TextArea = /*#__PURE__*/react.forwardRef(function TextArea({
|
|
903
|
+
label,
|
|
904
|
+
labelInfo,
|
|
905
|
+
indicator,
|
|
906
|
+
description,
|
|
907
|
+
helperMessage,
|
|
908
|
+
id: providedId,
|
|
909
|
+
invalid,
|
|
910
|
+
disabled,
|
|
911
|
+
maxRows,
|
|
912
|
+
showCharacterCount,
|
|
913
|
+
...textareaProps
|
|
914
|
+
}, ref) {
|
|
915
|
+
const {
|
|
916
|
+
inputId,
|
|
917
|
+
descriptionId,
|
|
918
|
+
helperMessageId,
|
|
919
|
+
getDescribedBy
|
|
920
|
+
} = useFieldIds(providedId);
|
|
921
|
+
const [charCount, setCharCount] = react.useState(() => String(textareaProps.value ?? textareaProps.defaultValue ?? '').length);
|
|
922
|
+
react.useEffect(() => {
|
|
923
|
+
if (textareaProps.value !== undefined) {
|
|
924
|
+
setCharCount(String(textareaProps.value).length);
|
|
925
|
+
}
|
|
926
|
+
}, [textareaProps.value]);
|
|
927
|
+
const {
|
|
928
|
+
maxLength,
|
|
929
|
+
onChange: onChangeProp,
|
|
930
|
+
...restTextareaProps
|
|
931
|
+
} = textareaProps;
|
|
932
|
+
const handleChange = e => {
|
|
933
|
+
setCharCount(e.target.value.length);
|
|
934
|
+
onChangeProp?.(e);
|
|
935
|
+
};
|
|
936
|
+
const internalRef = react.useRef(null);
|
|
937
|
+
const [maxPixelHeight, setMaxPixelHeight] = react.useState(undefined);
|
|
938
|
+
|
|
939
|
+
// Auto-grow is always on. When maxRows is set, compute a pixel cap after
|
|
940
|
+
// mount using the element's actual rendered line-height and padding
|
|
941
|
+
// (density-aware). Until the cap is computed (or if maxRows is not set),
|
|
942
|
+
// pass Infinity so the textarea grows without bound.
|
|
943
|
+
const autoResizeHeight = maxRows !== undefined && maxPixelHeight !== undefined ? maxPixelHeight : Infinity;
|
|
944
|
+
const autoResizeRef = edsUtils.useAutoResize(autoResizeHeight);
|
|
945
|
+
react.useEffect(() => {
|
|
946
|
+
if (!maxRows || !internalRef.current) return;
|
|
947
|
+
const el = internalRef.current;
|
|
948
|
+
const updateMaxHeight = () => {
|
|
949
|
+
const style = window.getComputedStyle(el);
|
|
950
|
+
const lineHeight = parseFloat(style.lineHeight);
|
|
951
|
+
const paddingBlockStart = parseFloat(style.paddingBlockStart);
|
|
952
|
+
const paddingBlockEnd = parseFloat(style.paddingBlockEnd);
|
|
953
|
+
setMaxPixelHeight(lineHeight * maxRows + paddingBlockStart + paddingBlockEnd);
|
|
954
|
+
};
|
|
955
|
+
const observer = new ResizeObserver(updateMaxHeight);
|
|
956
|
+
observer.observe(el);
|
|
957
|
+
updateMaxHeight();
|
|
958
|
+
return () => observer.disconnect();
|
|
959
|
+
}, [maxRows]);
|
|
960
|
+
const combinedRef = react.useMemo(() => edsUtils.mergeRefs(ref, autoResizeRef, internalRef), [ref, autoResizeRef, internalRef]);
|
|
961
|
+
const showHelperRow = helperMessage || showCharacterCount;
|
|
962
|
+
return /*#__PURE__*/jsxRuntime.jsxs(Field, {
|
|
963
|
+
className: "eds-text-area",
|
|
964
|
+
disabled: disabled,
|
|
965
|
+
children: [label && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
966
|
+
className: "label-row",
|
|
967
|
+
children: [/*#__PURE__*/jsxRuntime.jsx(Field.Label, {
|
|
968
|
+
htmlFor: inputId,
|
|
969
|
+
indicator: indicator,
|
|
970
|
+
children: label
|
|
971
|
+
}), labelInfo && /*#__PURE__*/jsxRuntime.jsx(Tooltip$1, {
|
|
972
|
+
title: labelInfo,
|
|
973
|
+
placement: "top",
|
|
974
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
975
|
+
variant: "ghost",
|
|
976
|
+
icon: true,
|
|
977
|
+
round: true,
|
|
978
|
+
size: "small",
|
|
979
|
+
tone: "neutral",
|
|
980
|
+
"aria-label": "More information",
|
|
981
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Icon, {
|
|
982
|
+
data: edsIcons.info_circle,
|
|
983
|
+
size: "xs"
|
|
984
|
+
})
|
|
985
|
+
})
|
|
986
|
+
})]
|
|
987
|
+
}), description && /*#__PURE__*/jsxRuntime.jsx(Field.Description, {
|
|
988
|
+
id: descriptionId,
|
|
989
|
+
children: description
|
|
990
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
991
|
+
ref: combinedRef,
|
|
992
|
+
as: "textarea",
|
|
993
|
+
id: inputId,
|
|
994
|
+
disabled: disabled,
|
|
995
|
+
invalid: invalid,
|
|
996
|
+
maxLength: maxLength,
|
|
997
|
+
onChange: handleChange,
|
|
998
|
+
"aria-describedby": getDescribedBy({
|
|
999
|
+
hasDescription: !!description,
|
|
1000
|
+
hasHelperMessage: !!helperMessage
|
|
1001
|
+
}),
|
|
1002
|
+
...restTextareaProps
|
|
1003
|
+
}), showHelperRow && /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1004
|
+
className: "helper-row",
|
|
1005
|
+
children: [helperMessage && /*#__PURE__*/jsxRuntime.jsx(Field.HelperMessage, {
|
|
1006
|
+
id: helperMessageId,
|
|
1007
|
+
role: invalid ? 'alert' : undefined,
|
|
1008
|
+
children: helperMessage
|
|
1009
|
+
}), showCharacterCount && /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1010
|
+
className: "char-count",
|
|
1011
|
+
"data-font-family": "ui",
|
|
1012
|
+
"data-font-size": "xs",
|
|
1013
|
+
"aria-live": maxLength !== undefined && charCount >= maxLength * 0.8 ? 'polite' : 'off',
|
|
1014
|
+
children: maxLength !== undefined ? `${charCount} / ${maxLength}` : charCount
|
|
1015
|
+
})]
|
|
1016
|
+
})]
|
|
1017
|
+
});
|
|
1018
|
+
});
|
|
1019
|
+
TextArea.displayName = 'TextArea';
|
|
1020
|
+
|
|
1021
|
+
const Search = /*#__PURE__*/react.forwardRef(function Search({
|
|
1022
|
+
label,
|
|
1023
|
+
description,
|
|
1024
|
+
helperMessage,
|
|
1025
|
+
id: providedId,
|
|
1026
|
+
invalid,
|
|
1027
|
+
disabled,
|
|
1028
|
+
readOnly,
|
|
1029
|
+
value,
|
|
1030
|
+
defaultValue,
|
|
1031
|
+
onChange,
|
|
1032
|
+
onClear,
|
|
1033
|
+
clearLabel = 'Clear search',
|
|
1034
|
+
...inputProps
|
|
1035
|
+
}, forwardedRef) {
|
|
1036
|
+
const {
|
|
1037
|
+
inputId,
|
|
1038
|
+
labelId,
|
|
1039
|
+
descriptionId,
|
|
1040
|
+
helperMessageId,
|
|
1041
|
+
getDescribedBy
|
|
1042
|
+
} = useFieldIds(providedId);
|
|
1043
|
+
const isControlled = value !== undefined;
|
|
1044
|
+
const [internalHasValue, setInternalHasValue] = react.useState(() => Boolean(defaultValue));
|
|
1045
|
+
const hasValue = isControlled ? Boolean(value) : internalHasValue;
|
|
1046
|
+
const inputRef = react.useRef(null);
|
|
1047
|
+
const mergedRef = react.useCallback(node => {
|
|
1048
|
+
inputRef.current = node;
|
|
1049
|
+
if (typeof forwardedRef === 'function') {
|
|
1050
|
+
forwardedRef(node);
|
|
1051
|
+
} else if (forwardedRef) {
|
|
1052
|
+
forwardedRef.current = node;
|
|
1053
|
+
}
|
|
1054
|
+
}, [forwardedRef]);
|
|
1055
|
+
const handleChange = e => {
|
|
1056
|
+
if (!isControlled) {
|
|
1057
|
+
setInternalHasValue(Boolean(e.target.value));
|
|
1058
|
+
}
|
|
1059
|
+
onChange?.(e);
|
|
1060
|
+
};
|
|
1061
|
+
const handleClear = () => {
|
|
1062
|
+
if (!isControlled && inputRef.current) {
|
|
1063
|
+
// Direct DOM mutation: bypasses React's synthetic onChange, which is
|
|
1064
|
+
// intentional — onClear is the designated callback for clear actions.
|
|
1065
|
+
inputRef.current.value = '';
|
|
1066
|
+
setInternalHasValue(false);
|
|
1067
|
+
}
|
|
1068
|
+
onClear?.();
|
|
1069
|
+
inputRef.current?.focus();
|
|
1070
|
+
};
|
|
1071
|
+
const showClear = hasValue && !disabled && !readOnly;
|
|
1072
|
+
// Accent only in interactive states — grey in error, readonly, disabled
|
|
1073
|
+
const iconTone = disabled || readOnly || invalid ? 'neutral' : 'accent';
|
|
1074
|
+
return /*#__PURE__*/jsxRuntime.jsx("search", {
|
|
1075
|
+
className: "eds-search",
|
|
1076
|
+
"aria-labelledby": label ? labelId : undefined,
|
|
1077
|
+
children: /*#__PURE__*/jsxRuntime.jsxs(Field, {
|
|
1078
|
+
disabled: disabled,
|
|
1079
|
+
children: [label && /*#__PURE__*/jsxRuntime.jsx(Field.Label, {
|
|
1080
|
+
id: labelId,
|
|
1081
|
+
htmlFor: inputId,
|
|
1082
|
+
children: label
|
|
1083
|
+
}), description && /*#__PURE__*/jsxRuntime.jsx(Field.Description, {
|
|
1084
|
+
id: descriptionId,
|
|
1085
|
+
children: description
|
|
1086
|
+
}), /*#__PURE__*/jsxRuntime.jsx(Input, {
|
|
1087
|
+
ref: mergedRef,
|
|
1088
|
+
id: inputId,
|
|
1089
|
+
type: "search",
|
|
1090
|
+
disabled: disabled,
|
|
1091
|
+
readOnly: readOnly,
|
|
1092
|
+
invalid: invalid,
|
|
1093
|
+
value: value,
|
|
1094
|
+
defaultValue: defaultValue,
|
|
1095
|
+
onChange: handleChange,
|
|
1096
|
+
"aria-describedby": getDescribedBy({
|
|
1097
|
+
hasDescription: !!description,
|
|
1098
|
+
hasHelperMessage: !!helperMessage
|
|
1099
|
+
}),
|
|
1100
|
+
hideErrorIcon: true,
|
|
1101
|
+
startAdornment: /*#__PURE__*/jsxRuntime.jsx(Icon, {
|
|
1102
|
+
data: edsIcons.search,
|
|
1103
|
+
className: "search-icon",
|
|
1104
|
+
"data-color-appearance": iconTone
|
|
1105
|
+
}),
|
|
1106
|
+
endAdornment: showClear ? /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
1107
|
+
variant: "ghost",
|
|
1108
|
+
icon: true,
|
|
1109
|
+
round: true,
|
|
1110
|
+
size: "small",
|
|
1111
|
+
tone: invalid ? 'neutral' : 'accent',
|
|
1112
|
+
onClick: handleClear,
|
|
1113
|
+
"aria-label": clearLabel,
|
|
1114
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Icon, {
|
|
1115
|
+
data: edsIcons.close
|
|
1116
|
+
})
|
|
1117
|
+
}) : undefined,
|
|
1118
|
+
...inputProps
|
|
1119
|
+
}), helperMessage && /*#__PURE__*/jsxRuntime.jsx(Field.HelperMessage, {
|
|
1120
|
+
id: helperMessageId,
|
|
1121
|
+
role: invalid ? 'alert' : undefined,
|
|
1122
|
+
children: helperMessage
|
|
1123
|
+
})]
|
|
1124
|
+
})
|
|
1125
|
+
});
|
|
1126
|
+
});
|
|
1127
|
+
Search.displayName = 'Search';
|
|
1128
|
+
|
|
1129
|
+
function mergeClassNames(...classNames) {
|
|
1130
|
+
return classNames.filter(Boolean).join(' ');
|
|
1131
|
+
}
|
|
1132
|
+
function mergeProps(slotProps, childProps) {
|
|
1133
|
+
const merged = {
|
|
1134
|
+
...childProps
|
|
1135
|
+
};
|
|
1136
|
+
for (const key of Object.keys(slotProps)) {
|
|
1137
|
+
const slotValue = slotProps[key];
|
|
1138
|
+
const childValue = childProps[key];
|
|
1139
|
+
if (key === 'className') {
|
|
1140
|
+
merged[key] = mergeClassNames(slotValue, childValue);
|
|
1141
|
+
} else if (key === 'style') {
|
|
1142
|
+
merged[key] = {
|
|
1143
|
+
...slotValue,
|
|
1144
|
+
...childValue
|
|
1145
|
+
};
|
|
1146
|
+
} else if (typeof slotValue === 'function' && typeof childValue === 'function') {
|
|
1147
|
+
merged[key] = (...args) => {
|
|
1148
|
+
childValue(...args);
|
|
1149
|
+
slotValue(...args);
|
|
1150
|
+
};
|
|
1151
|
+
} else if (slotValue !== undefined) {
|
|
1152
|
+
merged[key] = slotValue;
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
return merged;
|
|
1156
|
+
}
|
|
1157
|
+
const Slot = /*#__PURE__*/react.forwardRef(function Slot({
|
|
1158
|
+
children,
|
|
1159
|
+
...slotProps
|
|
1160
|
+
}, ref) {
|
|
1161
|
+
if (! /*#__PURE__*/react.isValidElement(children)) {
|
|
1162
|
+
return null;
|
|
1163
|
+
}
|
|
1164
|
+
const child = children;
|
|
1165
|
+
const merged = mergeProps(slotProps, child.props);
|
|
1166
|
+
return /*#__PURE__*/react.cloneElement(child, {
|
|
1167
|
+
...merged,
|
|
1168
|
+
ref
|
|
1169
|
+
});
|
|
1170
|
+
});
|
|
1171
|
+
Slot.displayName = 'Slot';
|
|
1172
|
+
|
|
1173
|
+
const Link = /*#__PURE__*/react.forwardRef(function Link({
|
|
1174
|
+
variant = 'inline',
|
|
1175
|
+
asChild,
|
|
1176
|
+
className,
|
|
1177
|
+
children,
|
|
1178
|
+
...rest
|
|
1179
|
+
}, ref) {
|
|
1180
|
+
const classes = ['eds-link', className].filter(Boolean).join(' ');
|
|
1181
|
+
const sharedProps = {
|
|
1182
|
+
ref,
|
|
1183
|
+
className: classes,
|
|
1184
|
+
'data-variant': variant,
|
|
1185
|
+
'data-color-appearance': 'info',
|
|
1186
|
+
'data-font-family': variant === 'standalone' ? 'ui' : undefined,
|
|
1187
|
+
'data-font-size': variant === 'standalone' ? 'md' : undefined,
|
|
1188
|
+
'data-line-height': variant === 'standalone' ? 'squished' : undefined,
|
|
1189
|
+
...rest
|
|
1190
|
+
};
|
|
1191
|
+
if (asChild) {
|
|
1192
|
+
return /*#__PURE__*/jsxRuntime.jsx(Slot, {
|
|
1193
|
+
...sharedProps,
|
|
1194
|
+
children: children
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
return /*#__PURE__*/jsxRuntime.jsx("a", {
|
|
1198
|
+
...sharedProps,
|
|
1199
|
+
children: children
|
|
1200
|
+
});
|
|
1201
|
+
});
|
|
1202
|
+
Link.displayName = 'Link';
|
|
1203
|
+
|
|
1204
|
+
const Tooltip = /*#__PURE__*/react.forwardRef(function Tooltip({
|
|
1205
|
+
title,
|
|
1206
|
+
placement = 'top',
|
|
1207
|
+
disabled,
|
|
1208
|
+
children,
|
|
1209
|
+
className,
|
|
1210
|
+
onMouseEnter: onMouseEnterProp,
|
|
1211
|
+
onMouseLeave: onMouseLeaveProp,
|
|
1212
|
+
...rest
|
|
1213
|
+
}, ref) {
|
|
1214
|
+
const uid = react.useId();
|
|
1215
|
+
const tooltipId = `eds-tooltip-${uid.replace(/:/g, '')}`;
|
|
1216
|
+
const anchorName = `--${tooltipId}`;
|
|
1217
|
+
const tooltipRef = react.useRef(null);
|
|
1218
|
+
const hideTimer = react.useRef(null);
|
|
1219
|
+
const active = Boolean(title) && !disabled;
|
|
1220
|
+
const show = () => {
|
|
1221
|
+
if (hideTimer.current) clearTimeout(hideTimer.current);
|
|
1222
|
+
if (!tooltipRef.current?.matches(':popover-open')) {
|
|
1223
|
+
tooltipRef.current?.showPopover();
|
|
1224
|
+
}
|
|
1225
|
+
};
|
|
1226
|
+
|
|
1227
|
+
// Short delay so mouse can travel from trigger to tooltip (WCAG 1.4.13 — hoverable)
|
|
1228
|
+
const hide = () => {
|
|
1229
|
+
hideTimer.current = setTimeout(() => {
|
|
1230
|
+
if (tooltipRef.current?.matches(':popover-open')) {
|
|
1231
|
+
tooltipRef.current.hidePopover();
|
|
1232
|
+
}
|
|
1233
|
+
}, 100);
|
|
1234
|
+
};
|
|
1235
|
+
|
|
1236
|
+
// Merge forwarded ref with internal ref
|
|
1237
|
+
const setRef = node => {
|
|
1238
|
+
tooltipRef.current = node;
|
|
1239
|
+
if (typeof ref === 'function') ref(node);else if (ref) ref.current = node;
|
|
1240
|
+
};
|
|
1241
|
+
if (!active) return children;
|
|
1242
|
+
return /*#__PURE__*/jsxRuntime.jsxs("span", {
|
|
1243
|
+
className: "eds-tooltip-anchor",
|
|
1244
|
+
style: {
|
|
1245
|
+
'--tooltip-anchor-name': anchorName
|
|
1246
|
+
},
|
|
1247
|
+
onMouseEnter: show,
|
|
1248
|
+
onMouseLeave: hide,
|
|
1249
|
+
onFocus: show,
|
|
1250
|
+
onBlur: hide,
|
|
1251
|
+
children: [/*#__PURE__*/react.cloneElement(children, {
|
|
1252
|
+
'aria-describedby': tooltipId
|
|
1253
|
+
}), /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1254
|
+
ref: setRef,
|
|
1255
|
+
id: tooltipId,
|
|
1256
|
+
role: "tooltip"
|
|
1257
|
+
// hint: top-layer + Escape/light-dismiss. Safari falls back to manual (no Escape).
|
|
1258
|
+
,
|
|
1259
|
+
popover: "hint",
|
|
1260
|
+
className: ['eds-tooltip', className].filter(Boolean).join(' '),
|
|
1261
|
+
"data-placement": placement,
|
|
1262
|
+
"data-space-proportions": "squished",
|
|
1263
|
+
...rest,
|
|
1264
|
+
onMouseEnter: e => {
|
|
1265
|
+
if (hideTimer.current) clearTimeout(hideTimer.current);
|
|
1266
|
+
onMouseEnterProp?.(e);
|
|
1267
|
+
},
|
|
1268
|
+
onMouseLeave: e => {
|
|
1269
|
+
hide();
|
|
1270
|
+
onMouseLeaveProp?.(e);
|
|
1271
|
+
},
|
|
1272
|
+
children: /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1273
|
+
className: "label",
|
|
1274
|
+
"data-font-family": "ui",
|
|
1275
|
+
"data-font-size": "sm",
|
|
1276
|
+
"data-baseline": "center",
|
|
1277
|
+
children: title
|
|
1278
|
+
})
|
|
1279
|
+
})]
|
|
1280
|
+
});
|
|
1281
|
+
});
|
|
1282
|
+
Tooltip.displayName = 'Tooltip';
|
|
1283
|
+
|
|
1284
|
+
const BannerIcon = /*#__PURE__*/react.forwardRef(function BannerIcon({
|
|
1285
|
+
className,
|
|
1286
|
+
children,
|
|
1287
|
+
...rest
|
|
1288
|
+
}, ref) {
|
|
1289
|
+
return /*#__PURE__*/jsxRuntime.jsx("span", {
|
|
1290
|
+
ref: ref,
|
|
1291
|
+
className: ['eds-banner__icon', className].filter(Boolean).join(' '),
|
|
1292
|
+
...rest,
|
|
1293
|
+
children: children
|
|
1294
|
+
});
|
|
1295
|
+
});
|
|
1296
|
+
const BannerMessage = /*#__PURE__*/react.forwardRef(function BannerMessage({
|
|
1297
|
+
className,
|
|
1298
|
+
children,
|
|
1299
|
+
...rest
|
|
1300
|
+
}, ref) {
|
|
1301
|
+
return /*#__PURE__*/jsxRuntime.jsx(TypographyNext, {
|
|
1302
|
+
ref: ref,
|
|
1303
|
+
as: "p",
|
|
1304
|
+
family: "ui",
|
|
1305
|
+
size: "md",
|
|
1306
|
+
baseline: "center",
|
|
1307
|
+
lineHeight: "default",
|
|
1308
|
+
tracking: "normal",
|
|
1309
|
+
className: ['eds-banner__message', className].filter(Boolean).join(' '),
|
|
1310
|
+
...rest,
|
|
1311
|
+
children: children
|
|
1312
|
+
});
|
|
1313
|
+
});
|
|
1314
|
+
const BannerActions = /*#__PURE__*/react.forwardRef(function BannerActions({
|
|
1315
|
+
placement = 'left',
|
|
1316
|
+
className,
|
|
1317
|
+
children,
|
|
1318
|
+
...rest
|
|
1319
|
+
}, ref) {
|
|
1320
|
+
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
1321
|
+
ref: ref,
|
|
1322
|
+
className: ['eds-banner__actions', className].filter(Boolean).join(' '),
|
|
1323
|
+
"data-placement": placement,
|
|
1324
|
+
...rest,
|
|
1325
|
+
children: children
|
|
1326
|
+
});
|
|
1327
|
+
});
|
|
1328
|
+
const BannerComponent = /*#__PURE__*/react.forwardRef(function Banner({
|
|
1329
|
+
tone = 'info',
|
|
1330
|
+
role = 'status',
|
|
1331
|
+
onDismiss,
|
|
1332
|
+
className,
|
|
1333
|
+
children,
|
|
1334
|
+
...rest
|
|
1335
|
+
}, ref) {
|
|
1336
|
+
return /*#__PURE__*/jsxRuntime.jsxs("div", {
|
|
1337
|
+
ref: ref,
|
|
1338
|
+
className: ['eds-banner', className].filter(Boolean).join(' '),
|
|
1339
|
+
"data-color-appearance": tone,
|
|
1340
|
+
role: role,
|
|
1341
|
+
...rest,
|
|
1342
|
+
children: [children, onDismiss && /*#__PURE__*/jsxRuntime.jsx(Button, {
|
|
1343
|
+
variant: "ghost",
|
|
1344
|
+
icon: true,
|
|
1345
|
+
size: "small",
|
|
1346
|
+
className: "eds-banner__dismiss",
|
|
1347
|
+
"aria-label": "Dismiss",
|
|
1348
|
+
onClick: onDismiss,
|
|
1349
|
+
children: /*#__PURE__*/jsxRuntime.jsx(Icon, {
|
|
1350
|
+
data: edsIcons.close
|
|
1351
|
+
})
|
|
1352
|
+
})]
|
|
1353
|
+
});
|
|
1354
|
+
});
|
|
1355
|
+
BannerIcon.displayName = 'Banner.Icon';
|
|
1356
|
+
BannerMessage.displayName = 'Banner.Message';
|
|
1357
|
+
BannerActions.displayName = 'Banner.Actions';
|
|
1358
|
+
BannerComponent.displayName = 'Banner';
|
|
1359
|
+
const Banner = BannerComponent;
|
|
1360
|
+
Banner.Icon = BannerIcon;
|
|
1361
|
+
Banner.Message = BannerMessage;
|
|
1362
|
+
Banner.Actions = BannerActions;
|
|
1363
|
+
|
|
1364
|
+
exports.Banner = Banner;
|
|
904
1365
|
exports.Button = Button;
|
|
905
1366
|
exports.Checkbox = Checkbox;
|
|
906
1367
|
exports.Field = Field;
|
|
907
1368
|
exports.Icon = Icon;
|
|
908
1369
|
exports.Input = Input;
|
|
1370
|
+
exports.Link = Link;
|
|
909
1371
|
exports.Radio = Radio;
|
|
1372
|
+
exports.Search = Search;
|
|
1373
|
+
exports.Slot = Slot;
|
|
910
1374
|
exports.Switch = Switch;
|
|
1375
|
+
exports.TextArea = TextArea;
|
|
911
1376
|
exports.TextField = TextField;
|
|
1377
|
+
exports.Tooltip = Tooltip;
|
|
912
1378
|
exports.useFieldIds = useFieldIds;
|
|
@@ -67,6 +67,11 @@ export type AutocompleteProps<T = string> = {
|
|
|
67
67
|
* @default 'summary'
|
|
68
68
|
*/
|
|
69
69
|
selectionDisplay?: 'chips' | 'summary';
|
|
70
|
+
/** Amount of values to list in chips (only relevant if selectionDisplay = 'chips')
|
|
71
|
+
* When left blank, all values will be shown as chips
|
|
72
|
+
* @default undefined
|
|
73
|
+
*/
|
|
74
|
+
chipCount?: number;
|
|
70
75
|
/** Callback for the selected item change
|
|
71
76
|
* changes.selectedItems gives the selected items
|
|
72
77
|
*/
|
|
@@ -39,6 +39,7 @@ export declare const AutocompleteContext: import("react").Context<{
|
|
|
39
39
|
onInputChange: (text: string) => void;
|
|
40
40
|
selectedOptions: unknown[];
|
|
41
41
|
selectionDisplay: "summary" | "chips";
|
|
42
|
+
chipCount: number;
|
|
42
43
|
itemToKey: (item: unknown) => unknown;
|
|
43
44
|
itemCompare: (value: unknown, compare: unknown) => boolean;
|
|
44
45
|
allowSelectAll: boolean;
|
|
@@ -73,6 +74,7 @@ export declare const AutocompleteContext: import("react").Context<{
|
|
|
73
74
|
hideClearButton?: boolean;
|
|
74
75
|
selectedOptions?: unknown[];
|
|
75
76
|
selectionDisplay?: "chips" | "summary";
|
|
77
|
+
chipCount?: number;
|
|
76
78
|
onOptionsChange?: (changes: import("./Autocomplete").AutocompleteChanges<unknown>) => void;
|
|
77
79
|
onInputChange?: (text: string) => void;
|
|
78
80
|
onAddNewOption?: (text: string) => void;
|
|
@@ -94,7 +96,7 @@ export declare const AutocompleteContext: import("react").Context<{
|
|
|
94
96
|
optionLabel?: (option: unknown) => string;
|
|
95
97
|
} & {
|
|
96
98
|
ref?: React.Ref<HTMLInputElement>;
|
|
97
|
-
}, "disabled" | "className" | "style" | "meta" | "label" | "ref" | "multiple" | "variant" | "placeholder" | "readOnly" | "options" | "helperText" | "helperIcon" | "loading" | "optionDisabled" | "totalOptions" | "initialSelectedOptions" | "noOptionsText" | "hideClearButton" | "selectedOptions" | "selectionDisplay" | "onOptionsChange" | "onInputChange" | "onAddNewOption" | "allowSelectAll" | "optionComponent" | "optionsFilter" | "autoWidth" | "clearSearchOnChange" | "multiline" | "dropdownHeight" | "itemToKey" | "itemCompare" | "
|
|
99
|
+
}, "disabled" | "className" | "id" | "style" | "meta" | "label" | "ref" | "multiple" | "variant" | "placeholder" | "readOnly" | "options" | "onClear" | "helperText" | "helperIcon" | "loading" | "optionDisabled" | "totalOptions" | "initialSelectedOptions" | "noOptionsText" | "hideClearButton" | "selectedOptions" | "selectionDisplay" | "chipCount" | "onOptionsChange" | "onInputChange" | "onAddNewOption" | "allowSelectAll" | "optionComponent" | "optionsFilter" | "autoWidth" | "clearSearchOnChange" | "multiline" | "dropdownHeight" | "itemToKey" | "itemCompare" | "optionLabel">;
|
|
98
100
|
highlightedIndex: number;
|
|
99
101
|
selectedItem: unknown;
|
|
100
102
|
isOpen: boolean;
|
|
@@ -153,6 +155,7 @@ export declare const useAutocompleteContext: () => {
|
|
|
153
155
|
onInputChange: (text: string) => void;
|
|
154
156
|
selectedOptions: unknown[];
|
|
155
157
|
selectionDisplay: "summary" | "chips";
|
|
158
|
+
chipCount: number;
|
|
156
159
|
itemToKey: (item: unknown) => unknown;
|
|
157
160
|
itemCompare: (value: unknown, compare: unknown) => boolean;
|
|
158
161
|
allowSelectAll: boolean;
|
|
@@ -187,6 +190,7 @@ export declare const useAutocompleteContext: () => {
|
|
|
187
190
|
hideClearButton?: boolean;
|
|
188
191
|
selectedOptions?: unknown[];
|
|
189
192
|
selectionDisplay?: "chips" | "summary";
|
|
193
|
+
chipCount?: number;
|
|
190
194
|
onOptionsChange?: (changes: import("./Autocomplete").AutocompleteChanges<unknown>) => void;
|
|
191
195
|
onInputChange?: (text: string) => void;
|
|
192
196
|
onAddNewOption?: (text: string) => void;
|
|
@@ -208,7 +212,7 @@ export declare const useAutocompleteContext: () => {
|
|
|
208
212
|
optionLabel?: (option: unknown) => string;
|
|
209
213
|
} & {
|
|
210
214
|
ref?: React.Ref<HTMLInputElement>;
|
|
211
|
-
}, "disabled" | "className" | "style" | "meta" | "label" | "ref" | "multiple" | "variant" | "placeholder" | "readOnly" | "options" | "helperText" | "helperIcon" | "loading" | "optionDisabled" | "totalOptions" | "initialSelectedOptions" | "noOptionsText" | "hideClearButton" | "selectedOptions" | "selectionDisplay" | "onOptionsChange" | "onInputChange" | "onAddNewOption" | "allowSelectAll" | "optionComponent" | "optionsFilter" | "autoWidth" | "clearSearchOnChange" | "multiline" | "dropdownHeight" | "itemToKey" | "itemCompare" | "
|
|
215
|
+
}, "disabled" | "className" | "id" | "style" | "meta" | "label" | "ref" | "multiple" | "variant" | "placeholder" | "readOnly" | "options" | "onClear" | "helperText" | "helperIcon" | "loading" | "optionDisabled" | "totalOptions" | "initialSelectedOptions" | "noOptionsText" | "hideClearButton" | "selectedOptions" | "selectionDisplay" | "chipCount" | "onOptionsChange" | "onInputChange" | "onAddNewOption" | "allowSelectAll" | "optionComponent" | "optionsFilter" | "autoWidth" | "clearSearchOnChange" | "multiline" | "dropdownHeight" | "itemToKey" | "itemCompare" | "optionLabel">;
|
|
212
216
|
highlightedIndex: number;
|
|
213
217
|
selectedItem: unknown;
|
|
214
218
|
isOpen: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DOMAttributes } from 'react';
|
|
2
2
|
import { AutocompleteProps } from './Autocomplete';
|
|
3
3
|
import { AutocompleteToken } from './Autocomplete.tokens';
|
|
4
|
-
export declare const useAutocomplete: <T>({ options, totalOptions, label, meta, className, style, disabled, readOnly, loading, hideClearButton, onOptionsChange, onAddNewOption, onInputChange, selectedOptions: _selectedOptions, selectionDisplay, multiple, itemToKey: _itemToKey, itemCompare: _itemCompare, allowSelectAll, initialSelectedOptions: _initialSelectedOptions, optionDisabled, optionsFilter, autoWidth, placeholder, optionLabel, clearSearchOnChange, multiline, dropdownHeight, optionComponent, helperText, helperIcon, noOptionsText, variant, onClear, ref, ...other }: AutocompleteProps<T> & {
|
|
4
|
+
export declare const useAutocomplete: <T>({ options, totalOptions, label, meta, className, style, disabled, readOnly, loading, hideClearButton, onOptionsChange, onAddNewOption, onInputChange, selectedOptions: _selectedOptions, selectionDisplay, chipCount, multiple, itemToKey: _itemToKey, itemCompare: _itemCompare, allowSelectAll, initialSelectedOptions: _initialSelectedOptions, optionDisabled, optionsFilter, autoWidth, placeholder, optionLabel, clearSearchOnChange, multiline, dropdownHeight, optionComponent, helperText, helperIcon, noOptionsText, variant, onClear, ref, id, ...other }: AutocompleteProps<T> & {
|
|
5
5
|
ref?: React.Ref<HTMLInputElement>;
|
|
6
6
|
}) => {
|
|
7
7
|
getDropdownProps: <Options>(options?: import("downshift").UseMultipleSelectionGetDropdownPropsOptions & Options, extraOptions?: import("downshift").GetPropsCommonOptions) => Omit<import("downshift").Overwrite<import("downshift").UseMultipleSelectionGetDropdownReturnValue, Options>, "preventKeyAction">;
|
|
@@ -44,6 +44,7 @@ export declare const useAutocomplete: <T>({ options, totalOptions, label, meta,
|
|
|
44
44
|
onInputChange: (text: string) => void;
|
|
45
45
|
selectedOptions: T[];
|
|
46
46
|
selectionDisplay: "summary" | "chips";
|
|
47
|
+
chipCount: number;
|
|
47
48
|
itemToKey: (item: T) => unknown;
|
|
48
49
|
itemCompare: (value: T, compare: T) => boolean;
|
|
49
50
|
allowSelectAll: boolean;
|
|
@@ -78,6 +79,7 @@ export declare const useAutocomplete: <T>({ options, totalOptions, label, meta,
|
|
|
78
79
|
hideClearButton?: boolean;
|
|
79
80
|
selectedOptions?: T[];
|
|
80
81
|
selectionDisplay?: "chips" | "summary";
|
|
82
|
+
chipCount?: number;
|
|
81
83
|
onOptionsChange?: (changes: import("./Autocomplete").AutocompleteChanges<T>) => void;
|
|
82
84
|
onInputChange?: (text: string) => void;
|
|
83
85
|
onAddNewOption?: (text: string) => void;
|
|
@@ -103,7 +105,7 @@ export declare const useAutocomplete: <T>({ options, totalOptions, label, meta,
|
|
|
103
105
|
optionLabel?: (option: T) => string;
|
|
104
106
|
}) & {
|
|
105
107
|
ref?: React.Ref<HTMLInputElement>;
|
|
106
|
-
}, "disabled" | "className" | "style" | "meta" | "label" | "ref" | "multiple" | "variant" | "placeholder" | "readOnly" | "options" | "helperText" | "helperIcon" | "loading" | "optionDisabled" | "totalOptions" | "initialSelectedOptions" | "noOptionsText" | "hideClearButton" | "selectedOptions" | "selectionDisplay" | "onOptionsChange" | "onInputChange" | "onAddNewOption" | "allowSelectAll" | "optionComponent" | "optionsFilter" | "autoWidth" | "clearSearchOnChange" | "multiline" | "dropdownHeight" | "itemToKey" | "itemCompare" | "
|
|
108
|
+
}, "disabled" | "className" | "id" | "style" | "meta" | "label" | "ref" | "multiple" | "variant" | "placeholder" | "readOnly" | "options" | "onClear" | "helperText" | "helperIcon" | "loading" | "optionDisabled" | "totalOptions" | "initialSelectedOptions" | "noOptionsText" | "hideClearButton" | "selectedOptions" | "selectionDisplay" | "chipCount" | "onOptionsChange" | "onInputChange" | "onAddNewOption" | "allowSelectAll" | "optionComponent" | "optionsFilter" | "autoWidth" | "clearSearchOnChange" | "multiline" | "dropdownHeight" | "itemToKey" | "itemCompare" | "optionLabel">;
|
|
107
109
|
highlightedIndex: number;
|
|
108
110
|
selectedItem: T;
|
|
109
111
|
isOpen: boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
declare const BannerIcon: import("react").ForwardRefExoticComponent<{
|
|
2
|
+
children: import("react").ReactNode;
|
|
3
|
+
} & import("react").HTMLAttributes<HTMLSpanElement> & import("react").RefAttributes<HTMLSpanElement>>;
|
|
4
|
+
declare const BannerMessage: import("react").ForwardRefExoticComponent<{
|
|
5
|
+
children: import("react").ReactNode;
|
|
6
|
+
} & import("react").HTMLAttributes<HTMLParagraphElement> & import("react").RefAttributes<HTMLParagraphElement>>;
|
|
7
|
+
declare const BannerActions: import("react").ForwardRefExoticComponent<{
|
|
8
|
+
placement?: import("./Banner.types").BannerActionsPlacement;
|
|
9
|
+
children: import("react").ReactNode;
|
|
10
|
+
} & import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
|
|
11
|
+
declare const BannerComponent: import("react").ForwardRefExoticComponent<{
|
|
12
|
+
tone?: import("./Banner.types").BannerTone;
|
|
13
|
+
role?: import("react").HTMLAttributes<HTMLDivElement>["role"];
|
|
14
|
+
onDismiss?: () => void;
|
|
15
|
+
children: import("react").ReactNode;
|
|
16
|
+
} & import("react").HTMLAttributes<HTMLDivElement> & import("react").RefAttributes<HTMLDivElement>>;
|
|
17
|
+
type CompoundBanner = typeof BannerComponent & {
|
|
18
|
+
Icon: typeof BannerIcon;
|
|
19
|
+
Message: typeof BannerMessage;
|
|
20
|
+
Actions: typeof BannerActions;
|
|
21
|
+
};
|
|
22
|
+
export declare const Banner: CompoundBanner;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|