@dbcdk/react-components 0.0.78 → 0.0.79

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.
@@ -13,6 +13,7 @@ type ModalContextValue = {
13
13
  openModal: (config: ModalConfig) => void;
14
14
  closeModal: () => void;
15
15
  confirm: (config: ConfirmModalConfig) => Promise<boolean>;
16
+ markAsLoading: (loading?: boolean) => void;
16
17
  };
17
18
  type ModalProviderProps = {
18
19
  children: ReactNode;
@@ -8,7 +8,11 @@ export function ModalProvider({ children }) {
8
8
  const [isOpen, setIsOpen] = useState(false);
9
9
  const [config, setConfig] = useState(null);
10
10
  const [mounted, setMounted] = useState(false);
11
- useEffect(() => setMounted(true), []);
11
+ useEffect(() => {
12
+ setMounted(true); // eslint-disable-line react-hooks/set-state-in-effect -- intentional: SSR portal guard, runs once after hydration
13
+ }, []);
14
+ const [isLoading, setIsLoading] = useState(false);
15
+ const markAsLoading = useCallback((loading = true) => setIsLoading(loading), []);
12
16
  const pendingResolverRef = useRef(null);
13
17
  const resolvePending = useCallback((value) => {
14
18
  if (pendingResolverRef.current) {
@@ -18,6 +22,7 @@ export function ModalProvider({ children }) {
18
22
  }, []);
19
23
  const closeModal = useCallback(() => {
20
24
  setIsOpen(false);
25
+ setIsLoading(false);
21
26
  }, []);
22
27
  const openModal = useCallback((newConfig) => {
23
28
  resolvePending(false);
@@ -54,8 +59,8 @@ export function ModalProvider({ children }) {
54
59
  setIsOpen(true);
55
60
  });
56
61
  }, [resolvePending]);
57
- const modalNode = (_jsxs(ModalContext.Provider, { value: { openModal, closeModal, confirm }, children: [children, mounted &&
58
- createPortal(_jsx(Modal, { ...(config !== null && config !== void 0 ? config : {}), isOpen: isOpen, onRequestClose: handleRequestClose, children: config === null || config === void 0 ? void 0 : config.children }), document.body)] }));
62
+ const modalNode = (_jsxs(ModalContext.Provider, { value: { openModal, closeModal, confirm, markAsLoading }, children: [children, mounted &&
63
+ createPortal(_jsx(Modal, { ...(config !== null && config !== void 0 ? config : {}), isOpen: isOpen, isLoading: isLoading, onRequestClose: handleRequestClose, children: config === null || config === void 0 ? void 0 : config.children }), document.body)] }));
59
64
  return modalNode;
60
65
  }
61
66
  export function useModal() {
@@ -1,11 +1,12 @@
1
1
  import type { ReactNode, JSX } from 'react';
2
2
  interface PanelProps {
3
- header: string;
3
+ header: ReactNode;
4
4
  headerIcon?: ReactNode;
5
+ headerAddition?: ReactNode;
5
6
  severity?: Severity;
6
7
  children: ReactNode;
7
8
  size?: 'sm' | 'md' | 'lg';
8
9
  }
9
10
  import { Severity } from '../../constants/severity.types';
10
- export declare function Panel({ header, headerIcon, children, severity, size }: PanelProps): JSX.Element;
11
+ export declare function Panel({ header, headerIcon, headerAddition, children, severity, size, }: PanelProps): JSX.Element;
11
12
  export {};
@@ -2,6 +2,6 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import styles from './Panel.module.css';
4
4
  import { Headline } from '../headline/Headline';
5
- export function Panel({ header, headerIcon, children, severity, size }) {
6
- return (_jsxs("section", { className: `${styles.container} ${size ? styles[size] : ''}`, children: [_jsx("div", { className: styles.header, children: _jsx(Headline, { disableMargin: true, size: 3, icon: headerIcon, severity: severity, children: header }) }), _jsx("div", { className: styles.content, children: children })] }));
5
+ export function Panel({ header, headerIcon, headerAddition, children, severity, size, }) {
6
+ return (_jsxs("section", { className: `${styles.container} ${size ? styles[size] : ''}`, children: [_jsx("div", { className: styles.header, children: _jsx(Headline, { disableMargin: true, size: size === 'sm' ? 4 : 3, icon: headerIcon, addition: headerAddition, severity: severity, children: header }) }), _jsx("div", { className: styles.content, children: children })] }));
7
7
  }
@@ -1,6 +1,6 @@
1
1
  .container {
2
- border: var(--border-width-thin) solid var(--color-border-default);
3
- border-radius: var(--border-radius-default);
2
+ border: var(--border-width-thin) solid var(--color-border-subtle);
3
+ border-radius: var(--border-radius-md);
4
4
  background-color: var(--color-bg-surface);
5
5
  box-sizing: border-box;
6
6
  display: flex;
@@ -8,7 +8,8 @@
8
8
  }
9
9
 
10
10
  .header {
11
- border-bottom: var(--border-width-thin) solid var(--color-border-default);
11
+ border-radius: var(--border-radius-md) var(--border-radius-md) 0 0;
12
+ border-bottom: var(--border-width-thin) solid var(--color-border-subtle);
12
13
  }
13
14
 
14
15
  .content {
@@ -17,11 +18,12 @@
17
18
 
18
19
  .header {
19
20
  padding: var(--spacing-sm) var(--spacing-md);
21
+ background-color: var(--table-header-bg);
20
22
  }
21
23
 
22
24
  .container.sm {
23
25
  .header,
24
26
  .content {
25
- padding: var(--spacing-sm) var(--spacing-md);
27
+ padding: var(--spacing-xs) var(--spacing-md);
26
28
  }
27
29
  }
@@ -47,7 +47,7 @@
47
47
  }
48
48
 
49
49
  .container:not(.active):hover {
50
- background-color: var(--color-bg-contextual);
50
+ background-color: var(--color-bg-toolbar-hover);
51
51
 
52
52
  color: var(--color-fg-default);
53
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dbcdk/react-components",
3
- "version": "0.0.78",
3
+ "version": "0.0.79",
4
4
  "description": "Reusable React components for DBC projects",
5
5
  "license": "ISC",
6
6
  "author": "",