@dbcdk/react-components 0.0.8 → 0.0.10
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/README.md +167 -0
- package/dist/components/__stories__/_data/tabs.d.ts +9 -0
- package/dist/components/__stories__/_data/tabs.js +31 -0
- package/dist/components/accordion/Accordion.d.ts +27 -0
- package/dist/components/accordion/Accordion.js +66 -0
- package/dist/components/accordion/Accordion.module.css +87 -0
- package/dist/components/button/Button.module.css +1 -0
- package/dist/components/circle/Circle.d.ts +4 -1
- package/dist/components/circle/Circle.js +2 -2
- package/dist/components/circle/Circle.module.css +54 -2
- package/dist/components/code-block/CodeBlock.module.css +1 -1
- package/dist/components/datetime-picker/DateTimePicker.d.ts +4 -7
- package/dist/components/datetime-picker/DateTimePicker.js +117 -64
- package/dist/components/datetime-picker/dateTimeHelpers.d.ts +14 -2
- package/dist/components/datetime-picker/dateTimeHelpers.js +32 -17
- package/dist/components/forms/checkbox/Checkbox.d.ts +2 -8
- package/dist/components/forms/checkbox/Checkbox.js +3 -5
- package/dist/components/forms/input/Input.d.ts +1 -0
- package/dist/components/forms/input/Input.js +2 -4
- package/dist/components/forms/input/Input.module.css +9 -11
- package/dist/components/forms/input-container/InputContainer.d.ts +2 -1
- package/dist/components/forms/input-container/InputContainer.js +3 -3
- package/dist/components/forms/input-container/InputContainer.module.css +65 -0
- package/dist/components/forms/radio-buttons/RadioButton.d.ts +36 -0
- package/dist/components/forms/radio-buttons/RadioButton.js +26 -0
- package/dist/components/forms/radio-buttons/RadioButtonGroup.d.ts +25 -0
- package/dist/components/forms/radio-buttons/RadioButtonGroup.js +19 -0
- package/dist/components/forms/radio-buttons/RadioButtons.module.css +117 -0
- package/dist/components/forms/select/Select.d.ts +1 -1
- package/dist/components/forms/select/Select.js +3 -3
- package/dist/components/forms/text-area/Textarea.js +3 -3
- package/dist/components/forms/text-area/Textarea.module.css +8 -1
- package/dist/components/headline/Headline.d.ts +2 -7
- package/dist/components/headline/Headline.js +5 -2
- package/dist/components/headline/Headline.module.css +61 -2
- package/dist/components/hyperlink/Hyperlink.d.ts +1 -0
- package/dist/components/hyperlink/Hyperlink.js +5 -1
- package/dist/components/icon/Icon.module.css +1 -0
- package/dist/components/interval-select/IntervalSelect.js +1 -1
- package/dist/components/nav-bar/NavBar.d.ts +24 -6
- package/dist/components/overlay/modal/provider/ModalProvider.d.ts +2 -2
- package/dist/components/overlay/modal/provider/ModalProvider.js +24 -25
- package/dist/components/overlay/side-panel/SidePanel.d.ts +12 -4
- package/dist/components/overlay/side-panel/SidePanel.js +60 -4
- package/dist/components/overlay/side-panel/SidePanel.module.css +151 -28
- package/dist/components/overlay/side-panel/useSidePanel.d.ts +1 -1
- package/dist/components/overlay/side-panel/useSidePanel.js +2 -2
- package/dist/components/page-layout/PageLayout.js +0 -2
- package/dist/components/popover/Popover.js +33 -14
- package/dist/components/popover/Popover.module.css +0 -4
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.d.ts +5 -5
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.js +16 -8
- package/dist/components/sidebar/components/expandable-sidebar-item/ExpandableSidebarItem.module.css +0 -3
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.d.ts +3 -1
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.js +4 -3
- package/dist/components/sidebar/components/sidebar-container/SidebarContainer.module.css +109 -79
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.js +16 -3
- package/dist/components/sidebar/components/sidebar-items/SidebarItems.module.css +20 -0
- package/dist/components/sidebar/providers/SidebarProvider.js +25 -46
- package/dist/components/skeleton-loader/SkeletonLoader.d.ts +1 -1
- package/dist/components/skeleton-loader/SkeletonLoader.js +15 -12
- package/dist/components/state-page/StatePage.d.ts +9 -0
- package/dist/components/state-page/StatePage.js +20 -0
- package/dist/components/state-page/StatePage.module.css +9 -0
- package/dist/components/state-page/empty.d.ts +2 -0
- package/dist/components/state-page/empty.js +2 -0
- package/dist/components/state-page/error.d.ts +2 -0
- package/dist/components/state-page/error.js +2 -0
- package/dist/components/state-page/notFound.d.ts +2 -0
- package/dist/components/state-page/notFound.js +2 -0
- package/dist/components/sticky-footer-layout/StickyFooterLayout.d.ts +19 -0
- package/dist/components/sticky-footer-layout/StickyFooterLayout.js +27 -0
- package/dist/components/table/Table.js +4 -4
- package/dist/components/table/Table.module.css +168 -60
- package/dist/components/table/components/empty-state/EmptyState.d.ts +1 -1
- package/dist/components/table/components/empty-state/EmptyState.js +6 -7
- package/dist/components/toast/Toast.js +5 -1
- package/dist/components/toast/Toast.module.css +40 -15
- package/dist/components/toast/provider/ToastProvider.js +1 -0
- package/dist/hooks/useTimeDuration.js +9 -3
- package/dist/hooks/useViewportFill.js +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -1
- package/dist/src/styles/styles.css +22 -3
- package/dist/styles/styles.css +22 -3
- package/dist/styles/themes/dbc/dark.css +1 -1
- package/dist/styles/themes/dbc/light.css +2 -1
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# DBC React Components
|
|
2
|
+
|
|
3
|
+
Reusable React components for DBC projects.
|
|
4
|
+
|
|
5
|
+
This library provides a shared, themeable component system used across DBC’s internal (and selected external) applications. It is designed to promote consistency, speed up development, and improve overall quality and accessibility.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Purpose of the library
|
|
10
|
+
|
|
11
|
+
The goals of this component library are:
|
|
12
|
+
|
|
13
|
+
- **Consistency**
|
|
14
|
+
Provide a unified look and feel across DBC’s digital products, especially internal tools.
|
|
15
|
+
|
|
16
|
+
- **Development speed**
|
|
17
|
+
Reduce development and maintenance time by reusing well-tested components instead of rebuilding UI from scratch.
|
|
18
|
+
|
|
19
|
+
- **Quality & accessibility**
|
|
20
|
+
Components are reviewed and built according to best practices, with accessibility and robustness in mind, ensuring a strong baseline quality.
|
|
21
|
+
|
|
22
|
+
- **Reduced third-party dependency**
|
|
23
|
+
Increase digital independence by building and sharing our own components across the organisation, reducing reliance on external NPM packages.
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## Getting started
|
|
28
|
+
|
|
29
|
+
### 1) Install the package
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm install @dbcdk/react-components
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### 2) Import global styles
|
|
38
|
+
|
|
39
|
+
> **Important:** The component library requires global styles to be imported once in your application.
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import '@dbcdk/react-components/styles.css'
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
### 3) Add the theme `<link>` in your root layout (Next.js example)
|
|
48
|
+
|
|
49
|
+
The library uses theme CSS files that are dynamically loaded via a `<link>` tag in `<head>`.
|
|
50
|
+
You **must** use the exported `LINK_ID` so the `useTheme()` hook can update the active theme at runtime.
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import { ReactNode } from 'react'
|
|
54
|
+
import { cookies } from 'next/headers'
|
|
55
|
+
|
|
56
|
+
import { LINK_ID } from '@dbcdk/react-components'
|
|
57
|
+
import '@dbcdk/react-components/styles.css'
|
|
58
|
+
|
|
59
|
+
export default async function RootLayout({ children }: Readonly<{ children: ReactNode }>) {
|
|
60
|
+
const cookieStore = await cookies()
|
|
61
|
+
const themeId = cookieStore.get('dbc_theme')?.value || 'light'
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<html lang="da">
|
|
65
|
+
<head>
|
|
66
|
+
<link id={LINK_ID} rel="stylesheet" href={`/themes/${themeId}.css`} />
|
|
67
|
+
</head>
|
|
68
|
+
<body>{children}</body>
|
|
69
|
+
</html>
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
> Theme files are expected to be served from `/themes/<theme>.css`.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
### 4) Switching theme in your application
|
|
79
|
+
|
|
80
|
+
Example using `useTheme()`:
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
'use client'
|
|
84
|
+
|
|
85
|
+
import { AppHeader, Button, useTheme } from '@dbcdk/react-components'
|
|
86
|
+
import { Moon, Sun } from 'lucide-react'
|
|
87
|
+
|
|
88
|
+
export default function Header() {
|
|
89
|
+
const { theme, switchTheme } = useTheme()
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<AppHeader>
|
|
93
|
+
<Button variant="outlined" onClick={() => switchTheme(theme === 'light' ? 'dark' : 'light')}>
|
|
94
|
+
{theme === 'light' ? <Moon /> : <Sun />}
|
|
95
|
+
</Button>
|
|
96
|
+
</AppHeader>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The hook updates the `<link>` tag automatically and persists the selected theme.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Using Storybook
|
|
106
|
+
|
|
107
|
+
Storybook is the primary documentation and exploration tool for this library.
|
|
108
|
+
|
|
109
|
+
### Local Storybook
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
npm run storybook
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Storybook runs on `http://localhost:6006`.
|
|
116
|
+
|
|
117
|
+
### In Storybook you can:
|
|
118
|
+
|
|
119
|
+
1. Browse components in the left-hand navigation
|
|
120
|
+
2. Open a story to see variants and states
|
|
121
|
+
3. Adjust props via **Controls**
|
|
122
|
+
4. Read guidelines and usage notes in the **Docs** tab
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Themes
|
|
127
|
+
|
|
128
|
+
Use the 🎨 **theme selector** in the Storybook toolbar to switch between available themes (e.g. light and dark).
|
|
129
|
+
|
|
130
|
+
All components are styled using CSS variables defined in the theme files.
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Accessibility (a11y)
|
|
135
|
+
|
|
136
|
+
Accessibility is a first-class concern in this library.
|
|
137
|
+
|
|
138
|
+
We aim to ensure that components:
|
|
139
|
+
|
|
140
|
+
- Are usable with keyboard navigation
|
|
141
|
+
- Have visible and consistent focus states
|
|
142
|
+
- Work with screen readers
|
|
143
|
+
- Follow common ARIA and semantic HTML best practices
|
|
144
|
+
|
|
145
|
+
Storybook includes the a11y addon to help identify issues during development.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Contributing
|
|
150
|
+
|
|
151
|
+
See [`CONTRIBUTING.md`](./CONTRIBUTING.md) for detailed guidelines on:
|
|
152
|
+
|
|
153
|
+
- Folder structure
|
|
154
|
+
- Styling and theming rules
|
|
155
|
+
- Storybook requirements
|
|
156
|
+
- TypeScript conventions
|
|
157
|
+
- Versioning and changesets
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## License
|
|
162
|
+
|
|
163
|
+
ISC
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { TabItem } from '../../../components/tabs/Tabs';
|
|
3
|
+
export declare const tabItems: TabItem[];
|
|
4
|
+
export declare const tabArgs: {
|
|
5
|
+
tabs: TabItem[];
|
|
6
|
+
variant: 'filled' | 'outlined';
|
|
7
|
+
header: string;
|
|
8
|
+
addition: ReactNode;
|
|
9
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Hourglass, Undo2 } from 'lucide-react';
|
|
3
|
+
import { Button } from '../../../components/button/Button';
|
|
4
|
+
import { Icon } from '../../../components/icon/Icon';
|
|
5
|
+
import { SampleTable } from './table';
|
|
6
|
+
export const tabItems = [
|
|
7
|
+
{
|
|
8
|
+
header: 'Afvist af anmelder',
|
|
9
|
+
id: 1,
|
|
10
|
+
headerIcon: _jsx(Icon, { severity: "error" }),
|
|
11
|
+
content: _jsx(SampleTable, {}),
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
header: 'Afventer godkendelse',
|
|
15
|
+
id: 2,
|
|
16
|
+
headerIcon: _jsx(Hourglass, {}),
|
|
17
|
+
content: _jsx(SampleTable, {}),
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
header: 'Retur til redigering',
|
|
21
|
+
id: 3,
|
|
22
|
+
headerIcon: _jsx(Undo2, {}),
|
|
23
|
+
content: _jsx(SampleTable, {}),
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
export const tabArgs = {
|
|
27
|
+
tabs: tabItems,
|
|
28
|
+
variant: 'filled',
|
|
29
|
+
header: 'Sagsoversigt',
|
|
30
|
+
addition: _jsx(Button, { children: "Se historik" }),
|
|
31
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReactNode, JSX } from 'react';
|
|
2
|
+
import { Severity } from '../../constants/severity.types';
|
|
3
|
+
export interface AccordionItem {
|
|
4
|
+
header: string;
|
|
5
|
+
headerIcon?: ReactNode;
|
|
6
|
+
severity?: Severity;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
type Size = 'sm' | 'md' | 'lg';
|
|
11
|
+
type Mode = 'single' | 'multiple';
|
|
12
|
+
export interface AccordionProps {
|
|
13
|
+
items: AccordionItem[];
|
|
14
|
+
mode?: Mode;
|
|
15
|
+
size?: Size;
|
|
16
|
+
/** Uncontrolled defaults */
|
|
17
|
+
defaultOpenIndex?: number | null;
|
|
18
|
+
defaultOpenIndexes?: number[];
|
|
19
|
+
/** Controlled state */
|
|
20
|
+
openIndex?: number | null;
|
|
21
|
+
openIndexes?: number[];
|
|
22
|
+
/** Change callbacks */
|
|
23
|
+
onOpenIndexChange?: (index: number | null) => void;
|
|
24
|
+
onOpenIndexesChange?: (indexes: number[]) => void;
|
|
25
|
+
}
|
|
26
|
+
export declare function Accordion({ items, mode, size, defaultOpenIndex, defaultOpenIndexes, openIndex, openIndexes, onOpenIndexChange, onOpenIndexesChange, }: AccordionProps): JSX.Element;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId, useMemo, useState } from 'react';
|
|
4
|
+
import styles from './Accordion.module.css';
|
|
5
|
+
import { Headline } from '../headline/Headline';
|
|
6
|
+
function uniqSorted(nums) {
|
|
7
|
+
return Array.from(new Set(nums)).sort((a, b) => a - b);
|
|
8
|
+
}
|
|
9
|
+
export function Accordion({ items, mode = 'single', size = 'md', defaultOpenIndex = null, defaultOpenIndexes = [], openIndex, openIndexes, onOpenIndexChange, onOpenIndexesChange, }) {
|
|
10
|
+
const uid = useId();
|
|
11
|
+
const isControlledSingle = mode === 'single' && openIndex !== undefined;
|
|
12
|
+
const isControlledMultiple = mode === 'multiple' && openIndexes !== undefined;
|
|
13
|
+
const [internalOpenIndex, setInternalOpenIndex] = useState(mode === 'single' ? defaultOpenIndex : null);
|
|
14
|
+
const [internalOpenIndexes, setInternalOpenIndexes] = useState(mode === 'multiple' ? uniqSorted(defaultOpenIndexes) : []);
|
|
15
|
+
const currentOpenIndex = mode === 'single' ? (isControlledSingle ? openIndex : internalOpenIndex) : null;
|
|
16
|
+
const currentOpenIndexes = useMemo(() => mode === 'multiple'
|
|
17
|
+
? isControlledMultiple
|
|
18
|
+
? uniqSorted(openIndexes)
|
|
19
|
+
: internalOpenIndexes
|
|
20
|
+
: [], [mode, isControlledMultiple, openIndexes, internalOpenIndexes]);
|
|
21
|
+
const openSet = useMemo(() => new Set(mode === 'single'
|
|
22
|
+
? currentOpenIndex !== null
|
|
23
|
+
? [currentOpenIndex]
|
|
24
|
+
: []
|
|
25
|
+
: currentOpenIndexes), [mode, currentOpenIndex, currentOpenIndexes]);
|
|
26
|
+
function setSingle(next) {
|
|
27
|
+
if (isControlledSingle)
|
|
28
|
+
onOpenIndexChange === null || onOpenIndexChange === void 0 ? void 0 : onOpenIndexChange(next);
|
|
29
|
+
else {
|
|
30
|
+
setInternalOpenIndex(next);
|
|
31
|
+
onOpenIndexChange === null || onOpenIndexChange === void 0 ? void 0 : onOpenIndexChange(next);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function setMultiple(next) {
|
|
35
|
+
const normalized = uniqSorted(next);
|
|
36
|
+
if (isControlledMultiple)
|
|
37
|
+
onOpenIndexesChange === null || onOpenIndexesChange === void 0 ? void 0 : onOpenIndexesChange(normalized);
|
|
38
|
+
else {
|
|
39
|
+
setInternalOpenIndexes(normalized);
|
|
40
|
+
onOpenIndexesChange === null || onOpenIndexesChange === void 0 ? void 0 : onOpenIndexesChange(normalized);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function toggle(index) {
|
|
44
|
+
const item = items[index];
|
|
45
|
+
if (!item || item.disabled)
|
|
46
|
+
return;
|
|
47
|
+
if (mode === 'single') {
|
|
48
|
+
const isOpen = openSet.has(index);
|
|
49
|
+
setSingle(isOpen ? null : index);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
// multiple
|
|
53
|
+
const isOpen = openSet.has(index);
|
|
54
|
+
if (isOpen)
|
|
55
|
+
setMultiple(currentOpenIndexes.filter(i => i !== index));
|
|
56
|
+
else
|
|
57
|
+
setMultiple([...currentOpenIndexes, index]);
|
|
58
|
+
}
|
|
59
|
+
return (_jsx("div", { className: `${styles.container} ${styles[size]}`, children: items.map((item, i) => {
|
|
60
|
+
const isOpen = openSet.has(i);
|
|
61
|
+
const isDisabled = !!item.disabled;
|
|
62
|
+
const buttonId = `${uid}-acc-btn-${i}`;
|
|
63
|
+
const panelId = `${uid}-acc-panel-${i}`;
|
|
64
|
+
return (_jsxs("section", { className: `${styles.item} ${isOpen ? styles.open : ''} ${isDisabled ? styles.disabled : ''}`, children: [_jsxs("button", { type: "button", id: buttonId, className: styles.trigger, "aria-expanded": isOpen, "aria-controls": panelId, onClick: () => toggle(i), disabled: isDisabled, children: [_jsx("span", { className: styles.title, children: _jsx(Headline, { disableMargin: true, size: 4, weight: 500, severity: item.severity, allowWrap: isOpen, children: item.header }) }), _jsx("span", { className: styles.chevron, "aria-hidden": "true", children: _jsx("svg", { viewBox: "0 0 20 20", focusable: "false", children: _jsx("path", { d: "M5.5 7.5L10 12l4.5-4.5", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })] }), _jsx("div", { id: panelId, role: "region", "aria-labelledby": buttonId, className: styles.panel, "data-open": isOpen ? 'true' : 'false', children: _jsx("div", { className: styles.content, children: item.children }) })] }, i));
|
|
65
|
+
}) }));
|
|
66
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
border-radius: var(--border-radius-default);
|
|
3
|
+
background-color: var(--color-bg-surface);
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
gap: var(--spacing-xxs);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.trigger {
|
|
12
|
+
all: unset;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
width: 100%;
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
gap: var(--spacing-sm);
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
user-select: none;
|
|
21
|
+
padding: var(--spacing-xs) var(--spacing-md);
|
|
22
|
+
background: var(--color-bg-contextual);
|
|
23
|
+
|
|
24
|
+
/* IMPORTANT: allow flex children to actually shrink */
|
|
25
|
+
min-width: 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.trigger:focus-visible {
|
|
29
|
+
outline: none;
|
|
30
|
+
box-shadow: var(--focus-ring);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.disabled .trigger {
|
|
34
|
+
cursor: not-allowed;
|
|
35
|
+
color: var(--color-disabled-fg);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.title {
|
|
39
|
+
/* IMPORTANT: this is the shrinking area that contains Headline */
|
|
40
|
+
display: flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
min-width: 0;
|
|
43
|
+
flex: 1 1 auto;
|
|
44
|
+
|
|
45
|
+
/* ensures any overflow is clipped so ellipsis can show */
|
|
46
|
+
overflow: hidden;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.chevron {
|
|
50
|
+
width: var(--icon-size-md);
|
|
51
|
+
height: var(--icon-size-md);
|
|
52
|
+
flex: 0 0 auto;
|
|
53
|
+
transition: transform var(--transition-normal) var(--ease-standard);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.open .chevron {
|
|
57
|
+
transform: rotate(180deg);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/* Collapsible panel using max-height */
|
|
61
|
+
.panel {
|
|
62
|
+
overflow: hidden;
|
|
63
|
+
max-height: 0;
|
|
64
|
+
transition: max-height var(--transition-slow) var(--ease-decelerate);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.panel[data-open='true'] {
|
|
68
|
+
max-height: 999px;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.content {
|
|
72
|
+
padding: var(--spacing-md) 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Sizes */
|
|
76
|
+
.sm .trigger,
|
|
77
|
+
.sm .content {
|
|
78
|
+
padding: var(--spacing-sm) var(--spacing-md);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.md .trigger {
|
|
82
|
+
padding: var(--spacing-sm) var(--spacing-md);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.lg .trigger {
|
|
86
|
+
padding: var(--spacing-md) var(--spacing-md);
|
|
87
|
+
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import type { ReactNode, JSX } from 'react';
|
|
2
2
|
import { Severity } from '../../constants/severity.types';
|
|
3
|
+
type CircleSize = 'xs' | 'sm' | 'md' | 'lg';
|
|
3
4
|
interface CircleProps {
|
|
4
5
|
severity: Severity;
|
|
5
6
|
children?: ReactNode;
|
|
6
7
|
glow?: boolean;
|
|
8
|
+
pulse?: boolean;
|
|
9
|
+
size?: CircleSize;
|
|
7
10
|
}
|
|
8
|
-
export declare function Circle({ severity, children, glow }: CircleProps): JSX.Element;
|
|
11
|
+
export declare function Circle({ severity, children, glow, pulse, size }: CircleProps): JSX.Element;
|
|
9
12
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import styles from './Circle.module.css';
|
|
3
|
-
export function Circle({ severity, children, glow }) {
|
|
4
|
-
return (_jsxs("span", { className: styles.container, children: [_jsx("span", { "data-glow": glow, className: `${styles.circle} ${styles[severity]}` }), children
|
|
3
|
+
export function Circle({ severity, children, glow, pulse, size = 'sm' }) {
|
|
4
|
+
return (_jsxs("span", { className: styles.container, children: [_jsx("span", { "data-glow": glow, "data-pulse": pulse, "data-size": size, className: `${styles.circle} ${styles[severity]}` }), children] }));
|
|
5
5
|
}
|
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
.circle {
|
|
13
|
+
position: relative;
|
|
13
14
|
display: inline-block;
|
|
14
|
-
inline-size: var(--component-size-
|
|
15
|
-
block-size: var(--component-size-
|
|
15
|
+
inline-size: var(--component-size-sm);
|
|
16
|
+
block-size: var(--component-size-sm);
|
|
16
17
|
border-radius: var(--border-radius-round);
|
|
17
18
|
flex-shrink: 0;
|
|
18
19
|
|
|
@@ -60,3 +61,54 @@
|
|
|
60
61
|
.info[data-glow='true'] {
|
|
61
62
|
box-shadow: 0 0 0 2px var(--color-status-info-bg);
|
|
62
63
|
}
|
|
64
|
+
|
|
65
|
+
.circle[data-size='xs'] {
|
|
66
|
+
inline-size: var(--component-size-xxs);
|
|
67
|
+
block-size: var(--component-size-xxs);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.circle[data-size='sm'] {
|
|
71
|
+
inline-size: 14px;
|
|
72
|
+
block-size: 14px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.circle[data-size='md'] {
|
|
76
|
+
inline-size: 18px;
|
|
77
|
+
block-size: 18px;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.circle[data-size='lg'] {
|
|
81
|
+
inline-size: 22px;
|
|
82
|
+
block-size: 22px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.circle[data-pulse='true']::after {
|
|
86
|
+
content: '';
|
|
87
|
+
position: absolute;
|
|
88
|
+
inset: 0;
|
|
89
|
+
border-radius: inherit;
|
|
90
|
+
background-color: inherit;
|
|
91
|
+
animation: circle-pulse 1.6s ease-out infinite;
|
|
92
|
+
pointer-events: none;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@keyframes circle-pulse {
|
|
96
|
+
0% {
|
|
97
|
+
transform: scale(1);
|
|
98
|
+
opacity: 0.6;
|
|
99
|
+
}
|
|
100
|
+
60% {
|
|
101
|
+
transform: scale(2);
|
|
102
|
+
opacity: 0;
|
|
103
|
+
}
|
|
104
|
+
100% {
|
|
105
|
+
transform: scale(2);
|
|
106
|
+
opacity: 0;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@media (prefers-reduced-motion: reduce) {
|
|
111
|
+
.circle[data-pulse='true']::after {
|
|
112
|
+
animation: none;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Input } from '../../components/forms/input/Input';
|
|
3
|
+
import { type UtcIsoString } from './dateTimeHelpers';
|
|
3
4
|
type Mode = 'single' | 'range';
|
|
4
5
|
type WeekStart = 0 | 1;
|
|
5
|
-
export type DateValue =
|
|
6
|
-
start:
|
|
7
|
-
end:
|
|
6
|
+
export type DateValue = UtcIsoString | null | {
|
|
7
|
+
start: UtcIsoString | null;
|
|
8
|
+
end: UtcIsoString | null;
|
|
8
9
|
};
|
|
9
10
|
type InputProps = React.ComponentProps<typeof Input>;
|
|
10
11
|
export interface DateTimePickerProps {
|
|
@@ -24,10 +25,6 @@ export interface DateTimePickerProps {
|
|
|
24
25
|
end: Date;
|
|
25
26
|
};
|
|
26
27
|
}[];
|
|
27
|
-
/**
|
|
28
|
-
* Forwarded to the internal <Input />.
|
|
29
|
-
* DateTimePicker controls: value, onInput/onBlur/onKeyDown, icon, onClear.
|
|
30
|
-
*/
|
|
31
28
|
inputProps?: Omit<InputProps, 'value' | 'onInput' | 'onBlur' | 'icon' | 'onClear' | 'type'>;
|
|
32
29
|
formatDate?: (d: Date, opts: {
|
|
33
30
|
locale: string;
|