@navikt/ds-react 7.1.2 → 7.2.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/cjs/form/combobox/FilteredOptions/FilteredOptions.js +3 -1
- package/cjs/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/cjs/form/combobox/Input/Input.context.js +1 -1
- package/cjs/form/combobox/Input/Input.context.js.map +1 -1
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js +2 -1
- package/cjs/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
- package/cjs/form/combobox/customOptionsContext.js +2 -2
- package/cjs/form/combobox/customOptionsContext.js.map +1 -1
- package/cjs/form/file-upload/index.d.ts +4 -4
- package/cjs/form/file-upload/index.js +5 -5
- package/cjs/form/file-upload/index.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +2 -2
- package/cjs/index.js.map +1 -1
- package/cjs/list/List.js +7 -2
- package/cjs/list/List.js.map +1 -1
- package/cjs/list/types.d.ts +1 -1
- package/cjs/modal/Modal.js +2 -2
- package/cjs/modal/Modal.js.map +1 -1
- package/cjs/overlays/dismissablelayer/DismissableLayer.js +2 -0
- package/cjs/overlays/dismissablelayer/DismissableLayer.js.map +1 -1
- package/cjs/progress-bar/ProgressBar.js +6 -2
- package/cjs/progress-bar/ProgressBar.js.map +1 -1
- package/cjs/table/AnimateHeight.js +12 -14
- package/cjs/table/AnimateHeight.js.map +1 -1
- package/cjs/util/TextareaAutoSize.js +1 -0
- package/cjs/util/TextareaAutoSize.js.map +1 -1
- package/cjs/util/create-context.js +3 -3
- package/cjs/util/create-context.js.map +1 -1
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js +3 -1
- package/esm/form/combobox/FilteredOptions/FilteredOptions.js.map +1 -1
- package/esm/form/combobox/Input/Input.context.js +1 -1
- package/esm/form/combobox/Input/Input.context.js.map +1 -1
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js +2 -1
- package/esm/form/combobox/SelectedOptions/selectedOptionsContext.js.map +1 -1
- package/esm/form/combobox/customOptionsContext.js +2 -2
- package/esm/form/combobox/customOptionsContext.js.map +1 -1
- package/esm/form/file-upload/index.d.ts +4 -4
- package/esm/form/file-upload/index.js +4 -4
- package/esm/form/file-upload/index.js.map +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/list/List.js +7 -2
- package/esm/list/List.js.map +1 -1
- package/esm/list/types.d.ts +1 -1
- package/esm/modal/Modal.js +2 -2
- package/esm/modal/Modal.js.map +1 -1
- package/esm/overlays/dismissablelayer/DismissableLayer.js +2 -0
- package/esm/overlays/dismissablelayer/DismissableLayer.js.map +1 -1
- package/esm/progress-bar/ProgressBar.js +6 -2
- package/esm/progress-bar/ProgressBar.js.map +1 -1
- package/esm/table/AnimateHeight.js +12 -14
- package/esm/table/AnimateHeight.js.map +1 -1
- package/esm/util/TextareaAutoSize.js +1 -0
- package/esm/util/TextareaAutoSize.js.map +1 -1
- package/esm/util/create-context.js +3 -3
- package/esm/util/create-context.js.map +1 -1
- package/package.json +5 -5
- package/src/form/combobox/FilteredOptions/FilteredOptions.tsx +1 -0
- package/src/form/combobox/Input/Input.context.tsx +1 -1
- package/src/form/combobox/SelectedOptions/selectedOptionsContext.tsx +2 -1
- package/src/form/combobox/customOptionsContext.tsx +2 -2
- package/src/form/file-upload/index.ts +4 -4
- package/src/index.ts +1 -1
- package/src/list/List.tsx +12 -6
- package/src/list/types.ts +1 -1
- package/src/modal/Modal.tsx +2 -2
- package/src/overlays/dismissablelayer/DismissableLayer.tsx +3 -0
- package/src/progress-bar/ProgressBar.tsx +2 -0
- package/src/table/AnimateHeight.tsx +15 -16
- package/src/util/TextareaAutoSize.tsx +1 -0
- package/src/util/create-context.tsx +3 -2
package/src/list/types.ts
CHANGED
|
@@ -22,7 +22,7 @@ export interface ListProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
22
22
|
* Changes margin-block on list and font size on items.
|
|
23
23
|
* @default "medium"
|
|
24
24
|
*/
|
|
25
|
-
size?: "medium" | "
|
|
25
|
+
size?: "small" | "medium" | "large";
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface ListItemProps extends React.HTMLAttributes<HTMLLIElement> {
|
package/src/modal/Modal.tsx
CHANGED
|
@@ -127,7 +127,7 @@ export const Modal = forwardRef<HTMLDialogElement, ModalProps>(
|
|
|
127
127
|
// We have to use JS because it doesn't work to set it with a prop (React bug?)
|
|
128
128
|
// Currently doesn't seem to work in Chrome. See also Tooltip.tsx
|
|
129
129
|
if (modalRef.current && portalNode) modalRef.current.autofocus = true;
|
|
130
|
-
}, [
|
|
130
|
+
}, [portalNode]);
|
|
131
131
|
|
|
132
132
|
useEffect(() => {
|
|
133
133
|
// We need to have this in a useEffect so that the content renders before the modal is displayed,
|
|
@@ -140,7 +140,7 @@ export const Modal = forwardRef<HTMLDialogElement, ModalProps>(
|
|
|
140
140
|
modalRef.current.close();
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
}, [
|
|
143
|
+
}, [portalNode, open]);
|
|
144
144
|
|
|
145
145
|
useBodyScrollLock(modalRef, portalNode, isNested);
|
|
146
146
|
|
|
@@ -337,6 +337,8 @@ const DismissableLayerNode = forwardRef<HTMLDivElement, DismissableLayerProps>(
|
|
|
337
337
|
* If `disableOutsidePointerEvents` is true,
|
|
338
338
|
* we want to disable pointer events on the body when the first layer is opened.
|
|
339
339
|
*/
|
|
340
|
+
|
|
341
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: Every time the descendants change, we want to update the body pointer events since we might have added or removed a layer.
|
|
340
342
|
useEffect(() => {
|
|
341
343
|
if (!node || !enabled || !disableOutsidePointerEvents) return;
|
|
342
344
|
|
|
@@ -362,6 +364,7 @@ const DismissableLayerNode = forwardRef<HTMLDivElement, DismissableLayerProps>(
|
|
|
362
364
|
/**
|
|
363
365
|
* To make sure pointerEvents are enabled for all parents and siblings when the layer is removed from the DOM
|
|
364
366
|
*/
|
|
367
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: We explicitly want to run this on unmount, including every time the node updates to make sure we don't lock the application behind pointer-events: none.
|
|
365
368
|
useEffect(() => {
|
|
366
369
|
return () => descendants.values().forEach((x) => x.forceUpdate());
|
|
367
370
|
}, [descendants, node]);
|
|
@@ -107,6 +107,7 @@ export const ProgressBar = forwardRef<HTMLDivElement, ProgressBarProps>(
|
|
|
107
107
|
}, [simulated?.seconds]);
|
|
108
108
|
|
|
109
109
|
return (
|
|
110
|
+
/* biome-ignore lint/a11y/useFocusableInteractive: Progressbar is not interactive. */
|
|
110
111
|
<div
|
|
111
112
|
ref={ref}
|
|
112
113
|
className={cl(
|
|
@@ -121,6 +122,7 @@ export const ProgressBar = forwardRef<HTMLDivElement, ProgressBarProps>(
|
|
|
121
122
|
? `Fremdrift kan ikke beregnes, antatt tid er: ${simulated?.seconds} sekunder`
|
|
122
123
|
: `${Math.round(value)} av ${Math.round(valueMax)}`
|
|
123
124
|
}
|
|
125
|
+
// biome-ignore lint/a11y/useAriaPropsForRole: We found that adding valueMin was not needed
|
|
124
126
|
role="progressbar"
|
|
125
127
|
aria-labelledby={ariaLabelledBy}
|
|
126
128
|
aria-label={ariaLabel}
|
|
@@ -74,37 +74,36 @@ const AnimateHeight: React.FC<AnimateHeightProps> = ({
|
|
|
74
74
|
const animationClassesTimeoutID = useRef<Timeout>();
|
|
75
75
|
const timeoutID = useRef<Timeout>();
|
|
76
76
|
|
|
77
|
-
const
|
|
77
|
+
const initialHeight = useRef<Height>(height);
|
|
78
|
+
const initialOverflow = useRef<Overflow>("visible");
|
|
78
79
|
|
|
79
|
-
|
|
80
|
-
let initOverflow: Overflow = "visible";
|
|
80
|
+
const duration = prefersReducedMotion ? 0 : userDuration;
|
|
81
81
|
|
|
82
|
-
if (typeof
|
|
82
|
+
if (typeof initialHeight.current === "number") {
|
|
83
83
|
// Reset negative height to 0
|
|
84
84
|
if (typeof height !== "string") {
|
|
85
|
-
|
|
85
|
+
initialHeight.current = height < 0 ? 0 : height;
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
} else if (isPercentage(
|
|
87
|
+
initialOverflow.current = "hidden";
|
|
88
|
+
} else if (isPercentage(initialHeight.current)) {
|
|
89
89
|
// If value is string "0%" make sure we convert it to number 0
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
initialHeight.current = height === "0%" ? 0 : height;
|
|
91
|
+
initialOverflow.current = "hidden";
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
const [currentHeight, setCurrentHeight] = useState<Height>(
|
|
95
|
-
|
|
94
|
+
const [currentHeight, setCurrentHeight] = useState<Height>(
|
|
95
|
+
initialHeight.current,
|
|
96
|
+
);
|
|
97
|
+
const [overflow, setOverflow] = useState<Overflow>(initialOverflow.current);
|
|
96
98
|
const [useTransitions, setUseTransitions] = useState<boolean>(false);
|
|
97
99
|
|
|
98
|
-
// ------------------ Did mount
|
|
99
100
|
useEffect(() => {
|
|
100
101
|
// Hide content if height is 0 (to prevent tabbing into it)
|
|
101
|
-
hideContent(contentElement.current,
|
|
102
|
-
|
|
103
|
-
// This should be explicitly run only on mount
|
|
104
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
102
|
+
hideContent(contentElement.current, initialHeight.current);
|
|
105
103
|
}, []);
|
|
106
104
|
|
|
107
105
|
// ------------------ Height update
|
|
106
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: This should be explicitly run only on height change
|
|
108
107
|
useEffect(() => {
|
|
109
108
|
if (height !== prevHeight.current && contentElement.current) {
|
|
110
109
|
showContent(contentElement.current, prevHeight.current);
|
|
@@ -205,6 +205,7 @@ const TextareaAutosize = forwardRef<HTMLTextAreaElement, TextareaAutosizeProps>(
|
|
|
205
205
|
syncHeight();
|
|
206
206
|
});
|
|
207
207
|
|
|
208
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: Since value is an external prop, we want to reset the renders on every time it changes, even when it is undefined or empty.
|
|
208
209
|
useEffect(() => {
|
|
209
210
|
renders.current = 0;
|
|
210
211
|
}, [value]);
|
|
@@ -43,8 +43,9 @@ export function createContext<T>(options: CreateContextOptions<T> = {}) {
|
|
|
43
43
|
const Provider = forwardRef<unknown, ProviderProps<T>>(
|
|
44
44
|
({ children, ...context }, ref) => {
|
|
45
45
|
// Only re-memoize when prop values change
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
|
|
47
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: Object.values(context) includes all dependencies.
|
|
48
|
+
const value = React.useMemo(() => context, Object.values(context)) as T; // eslint-disable-line react-hooks/exhaustive-deps
|
|
48
49
|
|
|
49
50
|
return (
|
|
50
51
|
<Context.Provider value={ref ? { ...value, ref } : value}>
|