@norges-domstoler/dds-components 0.0.0-dev-20250523090258 → 0.0.0-dev-20250523114007
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 +6 -3
- package/dist/index.d.ts +6 -3
- package/dist/index.js +23 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -77
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ComponentPropsWithRef, HTMLAttributes, Ref, ElementType, ComponentPropsWithoutRef, CSSProperties, ReactNode, ComponentProps, PropsWithChildren, AnchorHTMLAttributes, LabelHTMLAttributes, RefCallback, RefObject, KeyboardEvent as KeyboardEvent$1, Dispatch, SetStateAction, SVGAttributes, JSX, ButtonHTMLAttributes, AriaRole, InputHTMLAttributes, ForwardedRef, ForwardRefExoticComponent, ChangeEvent, MouseEvent as MouseEvent$1, ReactElement } from 'react';
|
|
3
|
+
import { ComponentPropsWithRef, HTMLAttributes, Ref, ElementType, ComponentPropsWithoutRef, CSSProperties, ReactNode, ComponentProps, PropsWithChildren, AnchorHTMLAttributes, LabelHTMLAttributes, RefCallback, RefObject, KeyboardEvent as KeyboardEvent$1, Dispatch, SetStateAction, SVGAttributes, JSX, ButtonHTMLAttributes, AriaRole, InputHTMLAttributes, MouseEventHandler, ForwardedRef, ForwardRefExoticComponent, ChangeEvent, MouseEvent as MouseEvent$1, ReactElement } from 'react';
|
|
4
4
|
import * as CSS from 'csstype';
|
|
5
5
|
import { Property, StandardProperties } from 'csstype';
|
|
6
6
|
import { Strategy, UseFloatingReturn, Placement as Placement$1 } from '@floating-ui/react-dom';
|
|
@@ -2259,7 +2259,10 @@ type OverflowMenuListItemBaseProps<T extends 'span' | 'button' | 'a'> = {
|
|
|
2259
2259
|
*/
|
|
2260
2260
|
purpose?: 'default' | 'danger';
|
|
2261
2261
|
} & ComponentPropsWithRef<T>;
|
|
2262
|
-
type OverflowMenuButtonProps = OverflowMenuListItemBaseProps<'button'> & Pick<ButtonProps, 'loading' | 'loadingTooltip'
|
|
2262
|
+
type OverflowMenuButtonProps = OverflowMenuListItemBaseProps<'button'> & Pick<ButtonProps, 'loading' | 'loadingTooltip'> & {
|
|
2263
|
+
/**Asynkron `onClick` event; håndterer loading status, slik at menyen ikke lukker seg under loading. */
|
|
2264
|
+
onClickAsync?: MouseEventHandler<HTMLButtonElement>;
|
|
2265
|
+
};
|
|
2263
2266
|
type OverflowMenuLinkProps = OverflowMenuListItemBaseProps<'a'>;
|
|
2264
2267
|
type OverflowMenuSpanProps = OverflowMenuListItemBaseProps<'span'>;
|
|
2265
2268
|
type OverflowMenuProps = Omit<BaseComponentPropsWithChildren<HTMLDivElement, {
|
|
@@ -2274,7 +2277,7 @@ type OverflowMenuProps = Omit<BaseComponentPropsWithChildren<HTMLDivElement, {
|
|
|
2274
2277
|
}>, 'id'>;
|
|
2275
2278
|
|
|
2276
2279
|
declare const OverflowMenuButton: {
|
|
2277
|
-
({ id, icon, children, className, onClick, purpose, loading, loadingTooltip, "aria-disabled": ariaDisabled, ref, ...rest }: OverflowMenuButtonProps): react_jsx_runtime.JSX.Element;
|
|
2280
|
+
({ id, icon, children, className, onClick, onClickAsync, purpose, loading, loadingTooltip, "aria-disabled": ariaDisabled, ref, ...rest }: OverflowMenuButtonProps): react_jsx_runtime.JSX.Element;
|
|
2278
2281
|
displayName: string;
|
|
2279
2282
|
};
|
|
2280
2283
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import { ComponentPropsWithRef, HTMLAttributes, Ref, ElementType, ComponentPropsWithoutRef, CSSProperties, ReactNode, ComponentProps, PropsWithChildren, AnchorHTMLAttributes, LabelHTMLAttributes, RefCallback, RefObject, KeyboardEvent as KeyboardEvent$1, Dispatch, SetStateAction, SVGAttributes, JSX, ButtonHTMLAttributes, AriaRole, InputHTMLAttributes, ForwardedRef, ForwardRefExoticComponent, ChangeEvent, MouseEvent as MouseEvent$1, ReactElement } from 'react';
|
|
3
|
+
import { ComponentPropsWithRef, HTMLAttributes, Ref, ElementType, ComponentPropsWithoutRef, CSSProperties, ReactNode, ComponentProps, PropsWithChildren, AnchorHTMLAttributes, LabelHTMLAttributes, RefCallback, RefObject, KeyboardEvent as KeyboardEvent$1, Dispatch, SetStateAction, SVGAttributes, JSX, ButtonHTMLAttributes, AriaRole, InputHTMLAttributes, MouseEventHandler, ForwardedRef, ForwardRefExoticComponent, ChangeEvent, MouseEvent as MouseEvent$1, ReactElement } from 'react';
|
|
4
4
|
import * as CSS from 'csstype';
|
|
5
5
|
import { Property, StandardProperties } from 'csstype';
|
|
6
6
|
import { Strategy, UseFloatingReturn, Placement as Placement$1 } from '@floating-ui/react-dom';
|
|
@@ -2259,7 +2259,10 @@ type OverflowMenuListItemBaseProps<T extends 'span' | 'button' | 'a'> = {
|
|
|
2259
2259
|
*/
|
|
2260
2260
|
purpose?: 'default' | 'danger';
|
|
2261
2261
|
} & ComponentPropsWithRef<T>;
|
|
2262
|
-
type OverflowMenuButtonProps = OverflowMenuListItemBaseProps<'button'> & Pick<ButtonProps, 'loading' | 'loadingTooltip'
|
|
2262
|
+
type OverflowMenuButtonProps = OverflowMenuListItemBaseProps<'button'> & Pick<ButtonProps, 'loading' | 'loadingTooltip'> & {
|
|
2263
|
+
/**Asynkron `onClick` event; håndterer loading status, slik at menyen ikke lukker seg under loading. */
|
|
2264
|
+
onClickAsync?: MouseEventHandler<HTMLButtonElement>;
|
|
2265
|
+
};
|
|
2263
2266
|
type OverflowMenuLinkProps = OverflowMenuListItemBaseProps<'a'>;
|
|
2264
2267
|
type OverflowMenuSpanProps = OverflowMenuListItemBaseProps<'span'>;
|
|
2265
2268
|
type OverflowMenuProps = Omit<BaseComponentPropsWithChildren<HTMLDivElement, {
|
|
@@ -2274,7 +2277,7 @@ type OverflowMenuProps = Omit<BaseComponentPropsWithChildren<HTMLDivElement, {
|
|
|
2274
2277
|
}>, 'id'>;
|
|
2275
2278
|
|
|
2276
2279
|
declare const OverflowMenuButton: {
|
|
2277
|
-
({ id, icon, children, className, onClick, purpose, loading, loadingTooltip, "aria-disabled": ariaDisabled, ref, ...rest }: OverflowMenuButtonProps): react_jsx_runtime.JSX.Element;
|
|
2280
|
+
({ id, icon, children, className, onClick, onClickAsync, purpose, loading, loadingTooltip, "aria-disabled": ariaDisabled, ref, ...rest }: OverflowMenuButtonProps): react_jsx_runtime.JSX.Element;
|
|
2278
2281
|
displayName: string;
|
|
2279
2282
|
};
|
|
2280
2283
|
|
package/dist/index.js
CHANGED
|
@@ -4197,6 +4197,7 @@ var OverflowMenuButton = ({
|
|
|
4197
4197
|
children,
|
|
4198
4198
|
className,
|
|
4199
4199
|
onClick,
|
|
4200
|
+
onClickAsync,
|
|
4200
4201
|
purpose = "default",
|
|
4201
4202
|
loading,
|
|
4202
4203
|
loadingTooltip,
|
|
@@ -4207,10 +4208,27 @@ var OverflowMenuButton = ({
|
|
|
4207
4208
|
const itemRef = (0, import_react19.useRef)(null);
|
|
4208
4209
|
const combinedRef = useCombinedRef(ref, itemRef);
|
|
4209
4210
|
const { onClose, registerItem, unregisterItem, focusedRef } = useOverflowMenuContext();
|
|
4211
|
+
const [internalLoading, setInternalLoading] = (0, import_react19.useState)(false);
|
|
4212
|
+
const isLoading = loading || internalLoading;
|
|
4210
4213
|
(0, import_react19.useEffect)(() => {
|
|
4211
4214
|
registerItem(itemRef);
|
|
4212
4215
|
return () => unregisterItem(itemRef);
|
|
4213
4216
|
}, []);
|
|
4217
|
+
const handleClick = async (e) => {
|
|
4218
|
+
if (isLoading) return;
|
|
4219
|
+
if (onClickAsync) {
|
|
4220
|
+
setInternalLoading(true);
|
|
4221
|
+
try {
|
|
4222
|
+
await onClickAsync(e);
|
|
4223
|
+
} finally {
|
|
4224
|
+
setInternalLoading(false);
|
|
4225
|
+
onClose == null ? void 0 : onClose();
|
|
4226
|
+
}
|
|
4227
|
+
} else {
|
|
4228
|
+
onClick == null ? void 0 : onClick(e);
|
|
4229
|
+
onClose == null ? void 0 : onClose();
|
|
4230
|
+
}
|
|
4231
|
+
};
|
|
4214
4232
|
return /* @__PURE__ */ (0, import_jsx_runtime194.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime194.jsxs)(
|
|
4215
4233
|
"button",
|
|
4216
4234
|
{
|
|
@@ -4226,15 +4244,12 @@ var OverflowMenuButton = ({
|
|
|
4226
4244
|
focus_default["focusable--inset"],
|
|
4227
4245
|
loading && OverflowMenu_default["button-loading"]
|
|
4228
4246
|
),
|
|
4229
|
-
onClick:
|
|
4230
|
-
|
|
4231
|
-
onClose == null ? void 0 : onClose();
|
|
4232
|
-
},
|
|
4233
|
-
"aria-disabled": loading ? true : ariaDisabled ? ariaDisabled : void 0,
|
|
4247
|
+
onClick: (e) => handleClick(e),
|
|
4248
|
+
"aria-disabled": isLoading ? true : ariaDisabled ? ariaDisabled : void 0,
|
|
4234
4249
|
...rest,
|
|
4235
4250
|
tabIndex: focusedRef === itemRef ? 0 : -1,
|
|
4236
4251
|
children: [
|
|
4237
|
-
|
|
4252
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime194.jsx)("span", { className: cn(utilStyles_default["center-absolute"]), children: /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(
|
|
4238
4253
|
Spinner,
|
|
4239
4254
|
{
|
|
4240
4255
|
size: "var(--dds-icon-size-medium)",
|
|
@@ -4244,12 +4259,12 @@ var OverflowMenuButton = ({
|
|
|
4244
4259
|
icon && /* @__PURE__ */ (0, import_jsx_runtime194.jsx)(
|
|
4245
4260
|
Icon,
|
|
4246
4261
|
{
|
|
4247
|
-
className: cn(
|
|
4262
|
+
className: cn(isLoading && invisible),
|
|
4248
4263
|
iconSize: "inherit",
|
|
4249
4264
|
icon
|
|
4250
4265
|
}
|
|
4251
4266
|
),
|
|
4252
|
-
/* @__PURE__ */ (0, import_jsx_runtime194.jsx)("span", { className: cn(
|
|
4267
|
+
/* @__PURE__ */ (0, import_jsx_runtime194.jsx)("span", { className: cn(isLoading && invisible), children })
|
|
4253
4268
|
]
|
|
4254
4269
|
}
|
|
4255
4270
|
) });
|