@norges-domstoler/dds-components 0.0.0-dev-20240223113502 → 0.0.0-dev-20240223152935
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/index.d.mts +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +74 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +98 -118
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -752,11 +752,11 @@ declare const isKeyboardEvent: (e: Event | KeyboardEvent$1<Element>) => e is Key
|
|
|
752
752
|
* }
|
|
753
753
|
* ```
|
|
754
754
|
* @param size antall elementer i gruppen.
|
|
755
|
-
* @param
|
|
755
|
+
* @param active om fokus skal kontrolleres av hooken. Når status blir inaktiv vil fokusrekkefølge nullstilles.
|
|
756
756
|
* @param direction retning elementene blas i.
|
|
757
757
|
* @returns hook par: indeksen til fokuserte elemenentet og funksjonen som håndterer fokus.
|
|
758
758
|
*/
|
|
759
|
-
declare function useRoveFocus(size?: number,
|
|
759
|
+
declare function useRoveFocus(size?: number, active?: boolean, direction?: Direction$1): [number, Dispatch<SetStateAction<number>>];
|
|
760
760
|
|
|
761
761
|
declare enum ScreenSize {
|
|
762
762
|
XSmall = 0,
|
|
@@ -1973,6 +1973,8 @@ type FileUploaderProps = {
|
|
|
1973
1973
|
onChange: (newFiles: FileList) => void;
|
|
1974
1974
|
/**Bredde for filopplasteren. */
|
|
1975
1975
|
width?: Property.Width<string>;
|
|
1976
|
+
/**Om drag-and-drop zone skal vises. */
|
|
1977
|
+
withDragAndDrop?: boolean;
|
|
1976
1978
|
} & Partial<FileUploaderHookProps>;
|
|
1977
1979
|
declare const FileUploader: {
|
|
1978
1980
|
(props: FileUploaderProps): react_jsx_runtime.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -752,11 +752,11 @@ declare const isKeyboardEvent: (e: Event | KeyboardEvent$1<Element>) => e is Key
|
|
|
752
752
|
* }
|
|
753
753
|
* ```
|
|
754
754
|
* @param size antall elementer i gruppen.
|
|
755
|
-
* @param
|
|
755
|
+
* @param active om fokus skal kontrolleres av hooken. Når status blir inaktiv vil fokusrekkefølge nullstilles.
|
|
756
756
|
* @param direction retning elementene blas i.
|
|
757
757
|
* @returns hook par: indeksen til fokuserte elemenentet og funksjonen som håndterer fokus.
|
|
758
758
|
*/
|
|
759
|
-
declare function useRoveFocus(size?: number,
|
|
759
|
+
declare function useRoveFocus(size?: number, active?: boolean, direction?: Direction$1): [number, Dispatch<SetStateAction<number>>];
|
|
760
760
|
|
|
761
761
|
declare enum ScreenSize {
|
|
762
762
|
XSmall = 0,
|
|
@@ -1973,6 +1973,8 @@ type FileUploaderProps = {
|
|
|
1973
1973
|
onChange: (newFiles: FileList) => void;
|
|
1974
1974
|
/**Bredde for filopplasteren. */
|
|
1975
1975
|
width?: Property.Width<string>;
|
|
1976
|
+
/**Om drag-and-drop zone skal vises. */
|
|
1977
|
+
withDragAndDrop?: boolean;
|
|
1976
1978
|
} & Partial<FileUploaderHookProps>;
|
|
1977
1979
|
declare const FileUploader: {
|
|
1978
1980
|
(props: FileUploaderProps): react_jsx_runtime.JSX.Element;
|
package/dist/index.js
CHANGED
|
@@ -3073,7 +3073,7 @@ function useReturnFocusOnBlur(active, onBlur, triggerElement) {
|
|
|
3073
3073
|
// src/hooks/useRoveFocus.tsx
|
|
3074
3074
|
var import_react10 = require("react");
|
|
3075
3075
|
var isKeyboardEvent = (e) => e.key !== void 0;
|
|
3076
|
-
function useRoveFocus(size2,
|
|
3076
|
+
function useRoveFocus(size2, active, direction = "column") {
|
|
3077
3077
|
const [currentFocusIndex, setCurrentFocusIndex] = (0, import_react10.useState)(-1);
|
|
3078
3078
|
const nextKey = direction === "row" ? "ArrowRight" : "ArrowDown";
|
|
3079
3079
|
const previousKey = direction === "row" ? "ArrowLeft" : "ArrowUp";
|
|
@@ -3081,31 +3081,30 @@ function useRoveFocus(size2, reset, direction = "column") {
|
|
|
3081
3081
|
(e) => {
|
|
3082
3082
|
if (!size2 || !isKeyboardEvent(e))
|
|
3083
3083
|
return;
|
|
3084
|
-
if (reset)
|
|
3085
|
-
setCurrentFocusIndex(-1);
|
|
3086
3084
|
if (e.key === nextKey) {
|
|
3087
3085
|
e.preventDefault();
|
|
3088
|
-
setCurrentFocusIndex(
|
|
3089
|
-
currentFocusIndex === size2 - 1 ? 0 : currentFocusIndex + 1
|
|
3090
|
-
);
|
|
3086
|
+
setCurrentFocusIndex((prev) => prev === size2 - 1 ? 0 : prev + 1);
|
|
3091
3087
|
} else if (e.key === previousKey) {
|
|
3092
3088
|
e.preventDefault();
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
}
|
|
3098
|
-
setCurrentFocusIndex(size2 - 1);
|
|
3089
|
+
setCurrentFocusIndex((prev) => {
|
|
3090
|
+
if (prev === -1 || prev === 0)
|
|
3091
|
+
return size2 - 1;
|
|
3092
|
+
return prev - 1;
|
|
3093
|
+
});
|
|
3099
3094
|
}
|
|
3100
3095
|
},
|
|
3101
|
-
[size2,
|
|
3096
|
+
[size2, setCurrentFocusIndex]
|
|
3102
3097
|
);
|
|
3103
3098
|
(0, import_react10.useEffect)(() => {
|
|
3099
|
+
if (!active) {
|
|
3100
|
+
setCurrentFocusIndex(-1);
|
|
3101
|
+
return;
|
|
3102
|
+
}
|
|
3104
3103
|
document.addEventListener("keydown", handleKeyDown, false);
|
|
3105
3104
|
return () => {
|
|
3106
3105
|
document.removeEventListener("keydown", handleKeyDown, false);
|
|
3107
3106
|
};
|
|
3108
|
-
}, [handleKeyDown]);
|
|
3107
|
+
}, [handleKeyDown, active]);
|
|
3109
3108
|
return [currentFocusIndex, setCurrentFocusIndex];
|
|
3110
3109
|
}
|
|
3111
3110
|
|
|
@@ -4387,18 +4386,7 @@ var IconWrapper = import_styled_components17.default.span`
|
|
|
4387
4386
|
var isAnchorProps2 = (props) => props.href !== void 0;
|
|
4388
4387
|
var isButtonProps = (props) => props.href === void 0 && props.onClick !== void 0;
|
|
4389
4388
|
var OverflowMenuItem = (0, import_react21.forwardRef)((props, ref) => {
|
|
4390
|
-
const {
|
|
4391
|
-
title: title3,
|
|
4392
|
-
icon: icon12,
|
|
4393
|
-
focus,
|
|
4394
|
-
setFocus,
|
|
4395
|
-
index,
|
|
4396
|
-
id,
|
|
4397
|
-
className,
|
|
4398
|
-
htmlProps = {},
|
|
4399
|
-
...rest
|
|
4400
|
-
} = props;
|
|
4401
|
-
const { onKeyDown } = htmlProps;
|
|
4389
|
+
const { title: title3, icon: icon12, focus, id, className, htmlProps = {}, ...rest } = props;
|
|
4402
4390
|
let href;
|
|
4403
4391
|
let onClick;
|
|
4404
4392
|
if (isAnchorProps2(props)) {
|
|
@@ -4414,23 +4402,8 @@ var OverflowMenuItem = (0, import_react21.forwardRef)((props, ref) => {
|
|
|
4414
4402
|
(_a = itemRef.current) == null ? void 0 : _a.focus();
|
|
4415
4403
|
}
|
|
4416
4404
|
}, [focus]);
|
|
4417
|
-
const handleSelect = (0, import_react21.useCallback)(() => {
|
|
4418
|
-
if (setFocus && index) {
|
|
4419
|
-
setFocus(index);
|
|
4420
|
-
}
|
|
4421
|
-
}, [index, setFocus]);
|
|
4422
|
-
const handleOnClick = (e) => {
|
|
4423
|
-
handleSelect();
|
|
4424
|
-
onClick && onClick(e);
|
|
4425
|
-
};
|
|
4426
|
-
const handleOnKeyDown = (e) => {
|
|
4427
|
-
handleSelect();
|
|
4428
|
-
onKeyDown && onKeyDown(e);
|
|
4429
|
-
};
|
|
4430
4405
|
const linkProps = {
|
|
4431
4406
|
href,
|
|
4432
|
-
onClick: handleOnClick,
|
|
4433
|
-
onKeyDown: handleOnKeyDown,
|
|
4434
4407
|
role: "menuitem",
|
|
4435
4408
|
tabIndex: focus ? 0 : -1
|
|
4436
4409
|
};
|
|
@@ -4890,13 +4863,12 @@ var OverflowMenu = (0, import_react25.forwardRef)(
|
|
|
4890
4863
|
hasNavItems && interactiveItems.push(...navItems);
|
|
4891
4864
|
hasContextItems && interactiveItems.push(...items);
|
|
4892
4865
|
const hasInteractiveItems = interactiveItems.length > 0;
|
|
4893
|
-
const [focus
|
|
4866
|
+
const [focus] = useRoveFocus(interactiveItems == null ? void 0 : interactiveItems.length, isOpen);
|
|
4894
4867
|
const interactiveItemsList = hasInteractiveItems ? interactiveItems.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime177.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime177.jsx)(
|
|
4895
4868
|
OverflowMenuItem,
|
|
4896
4869
|
{
|
|
4897
4870
|
index,
|
|
4898
4871
|
focus: focus === index && isOpen,
|
|
4899
|
-
setFocus,
|
|
4900
4872
|
icon: hasInteractiveUser && index === 0 ? PersonIcon : void 0,
|
|
4901
4873
|
...item,
|
|
4902
4874
|
onClick: (e) => {
|
|
@@ -8089,6 +8061,9 @@ var rootTokens = {
|
|
|
8089
8061
|
backgroundColor: colors20.DdsColorInteractiveLightest
|
|
8090
8062
|
}
|
|
8091
8063
|
};
|
|
8064
|
+
var noZoneContainerTokens = {
|
|
8065
|
+
padding: [spacing20.SizesDdsSpacingX05, 0].join(" ")
|
|
8066
|
+
};
|
|
8092
8067
|
var fileTokens = {
|
|
8093
8068
|
marginTop: spacing20.SizesDdsSpacingX05,
|
|
8094
8069
|
paddingLeftRight: spacing20.SizesDdsSpacingX05,
|
|
@@ -8493,6 +8468,9 @@ var Root = import_styled_components56.default.div`
|
|
|
8493
8468
|
gap: ${rootTokens.gap};
|
|
8494
8469
|
background-color: ${({ $isDragActive }) => $isDragActive ? rootTokens.dragActive.backgroundColor : rootTokens.backgroundColor};
|
|
8495
8470
|
`;
|
|
8471
|
+
var NoZoneContainer = import_styled_components56.default.div`
|
|
8472
|
+
padding: ${noZoneContainerTokens.padding};
|
|
8473
|
+
`;
|
|
8496
8474
|
var FileUploaderInput = import_styled_components56.default.input``;
|
|
8497
8475
|
var FileListElement = import_styled_components56.default.ul`
|
|
8498
8476
|
margin: 0;
|
|
@@ -8505,6 +8483,7 @@ var FileUploader = (props) => {
|
|
|
8505
8483
|
label: label3,
|
|
8506
8484
|
tip,
|
|
8507
8485
|
required = false,
|
|
8486
|
+
withDragAndDrop = true,
|
|
8508
8487
|
initialFiles,
|
|
8509
8488
|
value,
|
|
8510
8489
|
accept,
|
|
@@ -8552,10 +8531,30 @@ var FileUploader = (props) => {
|
|
|
8552
8531
|
id: derivativeIdGenerator(uniqueId, `error-${index}`),
|
|
8553
8532
|
message: e
|
|
8554
8533
|
}));
|
|
8534
|
+
const button3 = /* @__PURE__ */ (0, import_jsx_runtime219.jsx)(
|
|
8535
|
+
Button,
|
|
8536
|
+
{
|
|
8537
|
+
...getButtonProps(),
|
|
8538
|
+
id: uniqueId,
|
|
8539
|
+
size: "medium",
|
|
8540
|
+
type: "button",
|
|
8541
|
+
appearance: "filled",
|
|
8542
|
+
purpose: "secondary",
|
|
8543
|
+
icon: UploadIcon,
|
|
8544
|
+
htmlProps: {
|
|
8545
|
+
"aria-invalid": hasRootErrors ? true : void 0,
|
|
8546
|
+
"aria-describedby": spaceSeparatedIdListGenerator([
|
|
8547
|
+
hasTip ? tipId : void 0,
|
|
8548
|
+
...rootErrorsList.map((e) => e.id)
|
|
8549
|
+
])
|
|
8550
|
+
},
|
|
8551
|
+
children: "Velg fil"
|
|
8552
|
+
}
|
|
8553
|
+
);
|
|
8555
8554
|
return /* @__PURE__ */ (0, import_jsx_runtime219.jsxs)(Wrapper3, { width, children: [
|
|
8556
8555
|
hasLabel && /* @__PURE__ */ (0, import_jsx_runtime219.jsx)(Label, { showRequiredStyling: showRequiredMarker, htmlFor: uniqueId, children: label3 }),
|
|
8557
8556
|
hasTip && /* @__PURE__ */ (0, import_jsx_runtime219.jsx)(InputMessage, { id: tipId, message: tip, messageType: "tip" }),
|
|
8558
|
-
/* @__PURE__ */ (0, import_jsx_runtime219.jsxs)(
|
|
8557
|
+
withDragAndDrop ? /* @__PURE__ */ (0, import_jsx_runtime219.jsxs)(
|
|
8559
8558
|
Root,
|
|
8560
8559
|
{
|
|
8561
8560
|
...getRootProps(),
|
|
@@ -8566,29 +8565,13 @@ var FileUploader = (props) => {
|
|
|
8566
8565
|
"Dra og slipp filer her eller",
|
|
8567
8566
|
" ",
|
|
8568
8567
|
/* @__PURE__ */ (0, import_jsx_runtime219.jsx)(VisuallyHidden, { as: "span", children: "velg fil med p\xE5f\xF8lgende knapp" }),
|
|
8569
|
-
|
|
8570
|
-
Button,
|
|
8571
|
-
{
|
|
8572
|
-
...getButtonProps(),
|
|
8573
|
-
id: uniqueId,
|
|
8574
|
-
size: "medium",
|
|
8575
|
-
type: "button",
|
|
8576
|
-
appearance: "filled",
|
|
8577
|
-
purpose: "secondary",
|
|
8578
|
-
icon: UploadIcon,
|
|
8579
|
-
htmlProps: {
|
|
8580
|
-
"aria-invalid": hasRootErrors ? true : void 0,
|
|
8581
|
-
"aria-describedby": spaceSeparatedIdListGenerator([
|
|
8582
|
-
hasTip ? tipId : void 0,
|
|
8583
|
-
...rootErrorsList.map((e) => e.id)
|
|
8584
|
-
])
|
|
8585
|
-
},
|
|
8586
|
-
children: "Velg fil"
|
|
8587
|
-
}
|
|
8588
|
-
)
|
|
8568
|
+
button3
|
|
8589
8569
|
]
|
|
8590
8570
|
}
|
|
8591
|
-
),
|
|
8571
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime219.jsxs)(NoZoneContainer, { children: [
|
|
8572
|
+
/* @__PURE__ */ (0, import_jsx_runtime219.jsx)(FileUploaderInput, { ...getInputProps() }),
|
|
8573
|
+
button3
|
|
8574
|
+
] }),
|
|
8592
8575
|
/* @__PURE__ */ (0, import_jsx_runtime219.jsx)(ErrorList, { errors: rootErrorsList }),
|
|
8593
8576
|
/* @__PURE__ */ (0, import_jsx_runtime219.jsx)(FileListElement, { children: fileListElements })
|
|
8594
8577
|
] });
|
|
@@ -11607,7 +11590,7 @@ var SearchSuggestions = (0, import_react85.forwardRef)((props, ref) => {
|
|
|
11607
11590
|
searchId,
|
|
11608
11591
|
"suggestions-header"
|
|
11609
11592
|
);
|
|
11610
|
-
const [focus
|
|
11593
|
+
const [focus] = useRoveFocus(suggestions == null ? void 0 : suggestions.length, showSuggestions);
|
|
11611
11594
|
const suggestionsToRender = maxSuggestions ? suggestions == null ? void 0 : suggestions.slice(maxSuggestions) : suggestions;
|
|
11612
11595
|
const renderedSuggestions = /* @__PURE__ */ (0, import_jsx_runtime244.jsx)(SuggestionsList, { role: "listbox", "aria-labelledby": suggestionsHeaderId, children: suggestionsToRender.map((suggestion, index) => {
|
|
11613
11596
|
return /* @__PURE__ */ (0, import_jsx_runtime244.jsx)("li", { role: "option", children: /* @__PURE__ */ (0, import_jsx_runtime244.jsx)(
|
|
@@ -11615,7 +11598,6 @@ var SearchSuggestions = (0, import_react85.forwardRef)((props, ref) => {
|
|
|
11615
11598
|
{
|
|
11616
11599
|
index,
|
|
11617
11600
|
focus: focus === index && showSuggestions,
|
|
11618
|
-
setFocus,
|
|
11619
11601
|
"aria-label": `s\xF8k p\xE5 ${suggestion}`,
|
|
11620
11602
|
onClick: onSuggestionClick,
|
|
11621
11603
|
title: suggestion,
|
|
@@ -13520,19 +13502,13 @@ var Tab = (0, import_react110.forwardRef)((props, ref) => {
|
|
|
13520
13502
|
useSetTabWidth(index, width);
|
|
13521
13503
|
const itemRef = (0, import_react110.useRef)(null);
|
|
13522
13504
|
const combinedRef = useCombinedRef(ref, itemRef);
|
|
13523
|
-
const {
|
|
13505
|
+
const { tabContentDirection } = useTabsContext();
|
|
13524
13506
|
(0, import_react110.useEffect)(() => {
|
|
13525
13507
|
var _a;
|
|
13526
13508
|
if (focus) {
|
|
13527
13509
|
(_a = itemRef.current) == null ? void 0 : _a.focus();
|
|
13528
|
-
setHasTabFocus(true);
|
|
13529
13510
|
}
|
|
13530
13511
|
}, [focus]);
|
|
13531
|
-
useOnKeyDown("Tab", () => {
|
|
13532
|
-
var _a;
|
|
13533
|
-
setHasTabFocus(false);
|
|
13534
|
-
(_a = tabPanelsRef == null ? void 0 : tabPanelsRef.current) == null ? void 0 : _a.focus();
|
|
13535
|
-
});
|
|
13536
13512
|
const handleSelect = (0, import_react110.useCallback)(() => {
|
|
13537
13513
|
if (setFocus && index) {
|
|
13538
13514
|
setFocus(index);
|
|
@@ -13606,12 +13582,11 @@ var TabList = (0, import_react111.forwardRef)(
|
|
|
13606
13582
|
handleTabChange,
|
|
13607
13583
|
tabListRef,
|
|
13608
13584
|
hasTabFocus,
|
|
13609
|
-
tabPanelsRef,
|
|
13610
13585
|
setHasTabFocus
|
|
13611
13586
|
} = useTabsContext();
|
|
13612
13587
|
const uniqueId = id != null ? id : `${tabsId}-tablist`;
|
|
13613
13588
|
const childrenArray = import_react111.Children.toArray(children).length;
|
|
13614
|
-
const [focus, setFocus] = useRoveFocus(childrenArray,
|
|
13589
|
+
const [focus, setFocus] = useRoveFocus(childrenArray, hasTabFocus, "row");
|
|
13615
13590
|
const combinedRef = useCombinedRef(ref, tabListRef);
|
|
13616
13591
|
const tabListChildren = import_react111.Children.map(children, (child, index) => {
|
|
13617
13592
|
return (0, import_react111.isValidElement)(child) && (0, import_react111.cloneElement)(child, {
|
|
@@ -13625,28 +13600,34 @@ var TabList = (0, import_react111.forwardRef)(
|
|
|
13625
13600
|
});
|
|
13626
13601
|
});
|
|
13627
13602
|
const [widths, setWidths] = (0, import_react111.useState)([]);
|
|
13628
|
-
useOnKeyDown("Tab", () => {
|
|
13629
|
-
var _a;
|
|
13630
|
-
setHasTabFocus(false);
|
|
13631
|
-
(_a = tabPanelsRef == null ? void 0 : tabPanelsRef.current) == null ? void 0 : _a.focus();
|
|
13632
|
-
});
|
|
13633
|
-
useOnClickOutside((tabListRef == null ? void 0 : tabListRef.current) || null, () => {
|
|
13634
|
-
setHasTabFocus(false);
|
|
13635
|
-
});
|
|
13636
13603
|
const handleOnFocus = (event) => {
|
|
13637
13604
|
setHasTabFocus(true);
|
|
13638
13605
|
onFocus && onFocus(event);
|
|
13639
13606
|
};
|
|
13640
|
-
const
|
|
13641
|
-
|
|
13642
|
-
|
|
13643
|
-
|
|
13644
|
-
|
|
13645
|
-
|
|
13646
|
-
|
|
13647
|
-
|
|
13607
|
+
const handleOnBlur = (event) => {
|
|
13608
|
+
var _a;
|
|
13609
|
+
if ((tabListRef == null ? void 0 : tabListRef.current) === event.relatedTarget) {
|
|
13610
|
+
setFocus(-1);
|
|
13611
|
+
}
|
|
13612
|
+
if (!((_a = tabListRef == null ? void 0 : tabListRef.current) == null ? void 0 : _a.contains(event.relatedTarget))) {
|
|
13613
|
+
setHasTabFocus(false);
|
|
13614
|
+
}
|
|
13648
13615
|
};
|
|
13649
|
-
return /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(TabWidthContextProvider, { onChangeWidths: setWidths, children: /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(
|
|
13616
|
+
return /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(TabWidthContextProvider, { onChangeWidths: setWidths, children: /* @__PURE__ */ (0, import_jsx_runtime266.jsx)(
|
|
13617
|
+
TabRow,
|
|
13618
|
+
{
|
|
13619
|
+
...rest,
|
|
13620
|
+
ref: combinedRef,
|
|
13621
|
+
role: "tablist",
|
|
13622
|
+
"aria-label": "Bruk venste og h\xF8yre piltast for \xE5 bla",
|
|
13623
|
+
id: uniqueId,
|
|
13624
|
+
tabIndex: 0,
|
|
13625
|
+
onFocus: handleOnFocus,
|
|
13626
|
+
onBlur: handleOnBlur,
|
|
13627
|
+
$gridTemplateColumns: widths.join(" "),
|
|
13628
|
+
children: tabListChildren
|
|
13629
|
+
}
|
|
13630
|
+
) });
|
|
13650
13631
|
}
|
|
13651
13632
|
);
|
|
13652
13633
|
TabList.displayName = "TabList";
|