@sybilion/uilib 1.4.9 → 1.4.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/dist/agent-glossary/content-prompt.generated.ts +27 -0
- package/dist/agent-glossary/content.generated.ts +27 -0
- package/dist/agent-glossary/content.index.md +4 -0
- package/dist/agent-glossary/content.md +27 -0
- package/dist/agent-glossary/content.prompt.md +27 -0
- package/dist/agent-glossary/workspace.generated.ts +2 -2
- package/dist/agent-glossary/workspace.index.md +2 -2
- package/dist/agent-glossary/workspace.md +2 -2
- package/dist/esm/components/ui/AnalysesSelector/AnalysesSelector.js +2 -2
- package/dist/esm/components/ui/Button/Button.styl.js +1 -1
- package/dist/esm/components/ui/ButtonGroup/ButtonGroup.js +9 -0
- package/dist/esm/components/ui/ButtonGroup/ButtonGroup.styl.js +7 -0
- package/dist/esm/components/ui/Chart/Chart.js +3 -3
- package/dist/esm/components/ui/Chat/ChatPrompt/ChatPrompt.styl.js +1 -1
- package/dist/esm/components/ui/Chat/ChatPrompt/ChatPromptComposer.js +1 -1
- package/dist/esm/components/ui/Chat/ChatSheet/ChatSheet.js +13 -0
- package/dist/esm/components/ui/Chat/ChatSheet/useChatPanelChromeModel.js +10 -7
- package/dist/esm/components/ui/Chip/Chip.js +3 -4
- package/dist/esm/components/ui/Chip/Chip.styl.js +2 -2
- package/dist/esm/components/ui/FileChip/FileChip.js +1 -1
- package/dist/esm/components/ui/Page/pageScrollRestoration.js +22 -0
- package/dist/esm/components/ui/Page/usePageScrollRestoration.js +73 -0
- package/dist/esm/components/ui/Renamer/Renamer.js +1 -1
- package/dist/esm/components/ui/Renamer/Renamer.styl.js +1 -1
- package/dist/esm/components/ui/Sidebar/Sidebar.js +91 -73
- package/dist/esm/components/widgets/DriverCard/DriverCard.js +7 -7
- package/dist/esm/components/widgets/DriverCard/DriverPerformanceChart.js +3 -3
- package/dist/esm/components/widgets/DriverMap/DriverIcon/DriverIcon.js +2 -2
- package/dist/esm/components/widgets/DriverMap/DriverIcon/DriverIcon.styl.js +1 -1
- package/dist/esm/components/widgets/DriversComparisonChart/DriversComparisonChart.js +1 -0
- package/dist/esm/components/widgets/PerformanceChart/PerformanceTable.js +1 -0
- package/dist/esm/components/widgets/SybilionAppHeader/SybilionAppHeader.styl.js +1 -1
- package/dist/esm/index.js +4 -2
- package/dist/esm/types/src/components/ui/ButtonGroup/ButtonGroup.d.ts +3 -0
- package/dist/esm/types/src/components/ui/ButtonGroup/ButtonGroup.types.d.ts +3 -0
- package/dist/esm/types/src/components/ui/ButtonGroup/index.d.ts +2 -0
- package/dist/esm/types/src/components/ui/Chip/Chip.d.ts +1 -1
- package/dist/esm/types/src/components/ui/Chip/Chip.types.d.ts +4 -2
- package/dist/esm/types/src/components/ui/Page/index.d.ts +2 -0
- package/dist/esm/types/src/components/ui/Page/pageScrollRestoration.d.ts +2 -0
- package/dist/esm/types/src/components/ui/Page/usePageScrollRestoration.d.ts +2 -0
- package/dist/esm/types/src/components/ui/Sidebar/Sidebar.d.ts +13 -6
- package/dist/esm/types/src/docs/pages/ButtonGroupPage.d.ts +1 -0
- package/dist/esm/types/src/index.d.ts +1 -1
- package/package.json +1 -1
- package/src/components/ui/AnalysesSelector/AnalysesSelector.tsx +3 -3
- package/src/components/ui/AnalysisLineIcon/AGENT.md +1 -1
- package/src/components/ui/Avatar/AGENT.md +1 -1
- package/src/components/ui/Button/Button.styl +11 -5
- package/src/components/ui/ButtonGroup/AGENT.md +29 -0
- package/src/components/ui/ButtonGroup/ButtonGroup.styl +21 -0
- package/src/components/ui/{Badge/Badge.styl.d.ts → ButtonGroup/ButtonGroup.styl.d.ts} +0 -6
- package/src/components/ui/ButtonGroup/ButtonGroup.tsx +17 -0
- package/src/components/ui/ButtonGroup/ButtonGroup.types.ts +3 -0
- package/src/components/ui/ButtonGroup/index.ts +2 -0
- package/src/components/ui/Chat/ChatPrompt/ChatPrompt.styl +2 -0
- package/src/components/ui/Chat/ChatPrompt/ChatPromptComposer.tsx +1 -0
- package/src/components/ui/Chat/ChatSheet/ChatSheet.tsx +15 -0
- package/src/components/ui/Chat/ChatSheet/useChatPanelChromeModel.tsx +21 -9
- package/src/components/ui/Chip/AGENT.md +4 -3
- package/src/components/ui/Chip/Chip.styl +17 -0
- package/src/components/ui/Chip/Chip.styl.d.ts +2 -0
- package/src/components/ui/Chip/Chip.tsx +10 -6
- package/src/components/ui/Chip/Chip.types.ts +5 -2
- package/src/components/ui/FileChip/FileChip.tsx +1 -1
- package/src/components/ui/Page/index.ts +2 -0
- package/src/components/ui/Page/pageScrollRestoration.ts +22 -0
- package/src/components/ui/Page/usePageScrollRestoration.ts +90 -0
- package/src/components/ui/Renamer/Renamer.styl +1 -1
- package/src/components/ui/Renamer/Renamer.tsx +1 -0
- package/src/components/ui/Sidebar/Sidebar.tsx +158 -99
- package/src/components/widgets/DriverCard/DriverCard.tsx +12 -10
- package/src/components/widgets/DriverMap/DriverIcon/DriverIcon.styl +1 -0
- package/src/components/widgets/DriverMap/DriverIcon/DriverIcon.tsx +3 -3
- package/src/components/widgets/SybilionAppHeader/SybilionAppHeader.styl +2 -2
- package/src/docs/pages/ButtonGroupPage.tsx +45 -0
- package/src/docs/pages/ChipPage.tsx +37 -0
- package/src/docs/pages/VimeoEmbedPage.tsx +4 -5
- package/src/docs/registry.ts +6 -12
- package/src/index.ts +1 -1
- package/dist/esm/components/ui/Badge/Badge.js +0 -11
- package/dist/esm/components/ui/Badge/Badge.styl.js +0 -7
- package/dist/esm/types/src/components/ui/Badge/Badge.d.ts +0 -3
- package/dist/esm/types/src/components/ui/Badge/Badge.types.d.ts +0 -6
- package/dist/esm/types/src/components/ui/Badge/index.d.ts +0 -2
- package/dist/esm/types/src/docs/pages/BadgePage.d.ts +0 -1
- package/dist/esm/types/src/docs/pages/TogglePage.d.ts +0 -1
- package/src/components/ui/Badge/AGENT.md +0 -16
- package/src/components/ui/Badge/Badge.styl +0 -95
- package/src/components/ui/Badge/Badge.tsx +0 -31
- package/src/components/ui/Badge/Badge.types.ts +0 -7
- package/src/components/ui/Badge/index.ts +0 -2
- package/src/docs/pages/BadgePage.tsx +0 -30
- package/src/docs/pages/TogglePage.tsx +0 -27
|
@@ -12,7 +12,6 @@ export * from './components/ui/AnalysesSelector';
|
|
|
12
12
|
export * from './components/ui/AnalysisLineIcon';
|
|
13
13
|
export * from './components/ui/AppHeader';
|
|
14
14
|
export * from './components/ui/Avatar';
|
|
15
|
-
export * from './components/ui/Badge';
|
|
16
15
|
export * from './components/ui/Banner';
|
|
17
16
|
export * from './components/ui/Chip';
|
|
18
17
|
export * from './components/ui/Kicker';
|
|
@@ -20,6 +19,7 @@ export * from './components/ui/PullQuote';
|
|
|
20
19
|
export * from './components/ui/SignalCard';
|
|
21
20
|
export * from './components/ui/Breadcrumb';
|
|
22
21
|
export * from './components/ui/Button';
|
|
22
|
+
export * from './components/ui/ButtonGroup';
|
|
23
23
|
export * from './components/ui/Card';
|
|
24
24
|
export * from './components/ui/Chart';
|
|
25
25
|
export * from './components/ui/ChartAreaInteractive';
|
package/package.json
CHANGED
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
} from 'react';
|
|
9
9
|
|
|
10
10
|
import { AnalysisLineIcon } from '#uilib/components/ui/AnalysisLineIcon';
|
|
11
|
-
import { Badge } from '#uilib/components/ui/Badge';
|
|
12
11
|
import { Button } from '#uilib/components/ui/Button';
|
|
12
|
+
import { Chip } from '#uilib/components/ui/Chip';
|
|
13
13
|
import { LabelWithId } from '#uilib/components/ui/LabelWithId';
|
|
14
14
|
import {
|
|
15
15
|
Select,
|
|
@@ -55,9 +55,9 @@ function renderItemContent(item: AnalysesSelectorItem) {
|
|
|
55
55
|
|
|
56
56
|
if (failed) {
|
|
57
57
|
return (
|
|
58
|
-
<
|
|
58
|
+
<Chip variant="negative" squared className={S.itemBadge}>
|
|
59
59
|
failed
|
|
60
|
-
</
|
|
60
|
+
</Chip>
|
|
61
61
|
);
|
|
62
62
|
}
|
|
63
63
|
|
|
@@ -8,4 +8,4 @@ AnalysisLineIcon renders a small solid or dashed line marker in a given colour.
|
|
|
8
8
|
## When not to use
|
|
9
9
|
|
|
10
10
|
- As a generic decorative icon; it only conveys meaning next to a chart.
|
|
11
|
-
- To indicate status or severity; use
|
|
11
|
+
- To indicate status or severity; use Chip instead.
|
|
@@ -8,7 +8,7 @@ Avatar displays a user or entity image with an automatic fallback to initials wh
|
|
|
8
8
|
## When not to use
|
|
9
9
|
|
|
10
10
|
- For arbitrary illustrative imagery; use a plain image instead.
|
|
11
|
-
- To convey status on its own; pair it with a
|
|
11
|
+
- To convey status on its own; pair it with a Chip or status indicator.
|
|
12
12
|
|
|
13
13
|
## Do
|
|
14
14
|
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
transition all var(--dur-base) var(--ease-standard)
|
|
17
17
|
border 0
|
|
18
18
|
|
|
19
|
+
&:active
|
|
20
|
+
opacity 0.8
|
|
21
|
+
|
|
19
22
|
&:disabled
|
|
20
23
|
pointer-events none
|
|
21
24
|
opacity 0.5
|
|
@@ -43,6 +46,9 @@
|
|
|
43
46
|
&:hover
|
|
44
47
|
background-color var(--sb-gray-800)
|
|
45
48
|
|
|
49
|
+
:global(.dark) &
|
|
50
|
+
background-color var(--sb-gray-600)
|
|
51
|
+
|
|
46
52
|
.destructive
|
|
47
53
|
background-color var(--destructive-900)
|
|
48
54
|
color white
|
|
@@ -51,7 +57,7 @@
|
|
|
51
57
|
background-color var(--destructive-600)
|
|
52
58
|
|
|
53
59
|
&:focus-visible
|
|
54
|
-
ring 3px var(--destructive-200)
|
|
60
|
+
ring 3px var(--destructive-200)
|
|
55
61
|
|
|
56
62
|
:global(.dark) &
|
|
57
63
|
ring 3px var(--destructive-400)
|
|
@@ -80,11 +86,11 @@
|
|
|
80
86
|
|
|
81
87
|
.ghost
|
|
82
88
|
&:hover
|
|
83
|
-
background-color var(--
|
|
84
|
-
color var(--
|
|
89
|
+
background-color var(--sb-gray-100)
|
|
90
|
+
color var(--foreground)
|
|
85
91
|
|
|
86
|
-
|
|
87
|
-
|
|
92
|
+
:global(.dark) &
|
|
93
|
+
background-color var(--sb-gray-900)
|
|
88
94
|
|
|
89
95
|
.link
|
|
90
96
|
color var(--primary)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
profiles: [workspace, content]
|
|
3
|
+
summary: Layout wrapper that molds adjacent Button children into one segmented control.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
ButtonGroup is a layout wrapper for two or more adjacent buttons. It removes gaps and inner corner radii so outline and secondary actions read as a single segmented control while each button keeps its own click handler.
|
|
7
|
+
|
|
8
|
+
## When to use
|
|
9
|
+
|
|
10
|
+
- To present a small set of related actions side by side, such as pagination or view toggles implemented with Button.
|
|
11
|
+
- To group outline buttons that share a border, such as filter presets or export format choices.
|
|
12
|
+
- When each segment needs its own label and handler but should look like one control.
|
|
13
|
+
|
|
14
|
+
## When not to use
|
|
15
|
+
|
|
16
|
+
- For mutually exclusive selection state; use ToggleGroup or Tabs instead.
|
|
17
|
+
- For a single action; use Button alone.
|
|
18
|
+
- When buttons are not direct children of the wrapper.
|
|
19
|
+
|
|
20
|
+
## Do
|
|
21
|
+
|
|
22
|
+
- Place Button elements as direct children of ButtonGroup.
|
|
23
|
+
- Use the outline variant when adjacent borders should read as one shared edge.
|
|
24
|
+
- Keep segment labels short so the group stays compact.
|
|
25
|
+
|
|
26
|
+
## Don't
|
|
27
|
+
|
|
28
|
+
- Nest ButtonGroup inside Button or wrap non-button elements expecting grouped styling.
|
|
29
|
+
- Use ButtonGroup for navigation between pages; use links or Tabs instead.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.root
|
|
2
|
+
display inline-flex
|
|
3
|
+
align-items stretch
|
|
4
|
+
width fit-content
|
|
5
|
+
|
|
6
|
+
> button
|
|
7
|
+
&:not(:first-child)
|
|
8
|
+
margin-left -1px
|
|
9
|
+
border-top-left-radius 0
|
|
10
|
+
border-bottom-left-radius 0
|
|
11
|
+
|
|
12
|
+
&:not(:last-child)
|
|
13
|
+
border-top-right-radius 0
|
|
14
|
+
border-bottom-right-radius 0
|
|
15
|
+
|
|
16
|
+
&:hover,
|
|
17
|
+
&:focus-visible
|
|
18
|
+
z-index 1
|
|
19
|
+
|
|
20
|
+
&:disabled
|
|
21
|
+
z-index 0
|
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
// Please do not change this file!
|
|
3
3
|
interface CssExports {
|
|
4
4
|
'root': string;
|
|
5
|
-
'squared': string;
|
|
6
|
-
'variant-default': string;
|
|
7
|
-
'variant-green': string;
|
|
8
|
-
'variant-outline': string;
|
|
9
|
-
'variant-red': string;
|
|
10
|
-
'variant-yellow': string;
|
|
11
5
|
}
|
|
12
6
|
export const cssExports: CssExports;
|
|
13
7
|
export default cssExports;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
|
|
3
|
+
import S from './ButtonGroup.styl';
|
|
4
|
+
import type { ButtonGroupProps } from './ButtonGroup.types';
|
|
5
|
+
|
|
6
|
+
function ButtonGroup({ className, ...props }: ButtonGroupProps) {
|
|
7
|
+
return (
|
|
8
|
+
<div
|
|
9
|
+
data-slot="button-group"
|
|
10
|
+
className={cn(S.root, className)}
|
|
11
|
+
role="group"
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { ButtonGroup };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
1
2
|
import { createPortal } from 'react-dom';
|
|
2
3
|
|
|
3
4
|
import { Button } from '../../Button';
|
|
@@ -85,6 +86,19 @@ export function ChatSheet({
|
|
|
85
86
|
};
|
|
86
87
|
}
|
|
87
88
|
|
|
89
|
+
const [chromePortalReady, setChromePortalReady] = useState(false);
|
|
90
|
+
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (!model.isOpen) {
|
|
93
|
+
setChromePortalReady(false);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const frameId = requestAnimationFrame(() => {
|
|
97
|
+
setChromePortalReady(true);
|
|
98
|
+
});
|
|
99
|
+
return () => cancelAnimationFrame(frameId);
|
|
100
|
+
}, [model.isOpen]);
|
|
101
|
+
|
|
88
102
|
if (inline) {
|
|
89
103
|
return <ChatChrome {...model.chromeProps} />;
|
|
90
104
|
}
|
|
@@ -101,6 +115,7 @@ export function ChatSheet({
|
|
|
101
115
|
</Button>
|
|
102
116
|
)}
|
|
103
117
|
{model.isOpen &&
|
|
118
|
+
chromePortalReady &&
|
|
104
119
|
model.chatPanelContainer &&
|
|
105
120
|
createPortal(
|
|
106
121
|
<ChatChrome {...model.chromeProps} />,
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
startTransition,
|
|
3
|
+
useCallback,
|
|
4
|
+
useEffect,
|
|
5
|
+
useMemo,
|
|
6
|
+
useRef,
|
|
7
|
+
useState,
|
|
8
|
+
} from 'react';
|
|
2
9
|
|
|
3
10
|
import {
|
|
4
11
|
ChatPreset,
|
|
@@ -47,7 +54,8 @@ import { ScrollRef } from '@homecode/ui';
|
|
|
47
54
|
|
|
48
55
|
import {
|
|
49
56
|
DISMISS_CHAT_FOR_LAYOUT_EVENT,
|
|
50
|
-
|
|
57
|
+
useSidebarActions,
|
|
58
|
+
useSidebarState,
|
|
51
59
|
} from '../../Sidebar/Sidebar';
|
|
52
60
|
import { Chat } from '../Chat';
|
|
53
61
|
import type { ChatChromeProps } from '../ChatChrome';
|
|
@@ -177,14 +185,16 @@ export function useChatPanelChromeModel({
|
|
|
177
185
|
const {
|
|
178
186
|
chatPanelContainer,
|
|
179
187
|
isOpen: sidebarNavOpen,
|
|
180
|
-
setOpen: setSidebarNavOpen,
|
|
181
188
|
sidebarWidthPx,
|
|
182
189
|
chatWidthPx,
|
|
190
|
+
chatPanelOpen: shellChatPanelOpen,
|
|
191
|
+
} = useSidebarState();
|
|
192
|
+
const {
|
|
193
|
+
setOpen: setSidebarNavOpen,
|
|
183
194
|
setChatWidthPx,
|
|
184
195
|
getShellWidth,
|
|
185
|
-
chatPanelOpen: shellChatPanelOpen,
|
|
186
196
|
setChatPanelOpen,
|
|
187
|
-
} =
|
|
197
|
+
} = useSidebarActions();
|
|
188
198
|
const [localUiBusy, setLocalUiBusy] = useState(false);
|
|
189
199
|
const [outboundLoadingLabel, setOutboundLoadingLabel] = useState<
|
|
190
200
|
string | undefined
|
|
@@ -344,10 +354,12 @@ export function useChatPanelChromeModel({
|
|
|
344
354
|
layoutDismissedRef.current = false;
|
|
345
355
|
openedShellChatRef.current = true;
|
|
346
356
|
setChatPanelOpen(true);
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
357
|
+
startTransition(() => {
|
|
358
|
+
setIsOpen(true);
|
|
359
|
+
if (!searchParams.has(CHAT_QUERY_PARAM)) {
|
|
360
|
+
addSearchParams({ [CHAT_QUERY_PARAM]: CHAT_OPEN_VALUE });
|
|
361
|
+
}
|
|
362
|
+
});
|
|
351
363
|
return;
|
|
352
364
|
}
|
|
353
365
|
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
Chips are compact
|
|
1
|
+
Chips are compact capsules for filters, status labels, version tags, and quantitative delta indicators. Use the default pill shape for filters and live status; pass `squared` for compact label badges in lists, tables, and cards.
|
|
2
2
|
|
|
3
3
|
## When to use
|
|
4
4
|
|
|
5
5
|
- To present a row of filter options, with the active variant marking the current selection.
|
|
6
6
|
- To flag live status, version tags, or deadlines with the neutral, accent, and filled variants.
|
|
7
|
+
- To label or categorise content in lists, tables, and cards with `squared` and neutral, line, yellow, positive, or negative variants.
|
|
7
8
|
- To show a quantitative delta or impact direction with the positive or negative variant, optionally with a trend arrow.
|
|
8
9
|
|
|
9
10
|
## When not to use
|
|
10
11
|
|
|
11
|
-
- For general-purpose labels without status or delta semantics; use Badge instead.
|
|
12
12
|
- For file attachments; use FileChip.
|
|
13
|
-
- As decoration; the
|
|
13
|
+
- As decoration; the positive and negative variants are reserved for quantitative signals and status meaning.
|
|
14
14
|
|
|
15
15
|
## Do
|
|
16
16
|
|
|
17
17
|
- Keep chip labels short and in sentence case.
|
|
18
18
|
- Pair the positive and negative variants with a trend arrow or delta value so the direction reads at a glance.
|
|
19
|
+
- Use colour variants consistently so a given colour always carries the same meaning across the product.
|
|
@@ -14,6 +14,14 @@
|
|
|
14
14
|
letter-spacing var(--tracking-body)
|
|
15
15
|
transition background-color var(--dur-base) var(--ease-standard), color var(--dur-base) var(--ease-standard), border-color var(--dur-base) var(--ease-standard)
|
|
16
16
|
|
|
17
|
+
&.squared
|
|
18
|
+
border-radius var(--p-1)
|
|
19
|
+
|
|
20
|
+
& > svg
|
|
21
|
+
width 0.75rem
|
|
22
|
+
height 0.75rem
|
|
23
|
+
pointer-events none
|
|
24
|
+
|
|
17
25
|
.dot
|
|
18
26
|
width 6px
|
|
19
27
|
height 6px
|
|
@@ -76,3 +84,12 @@
|
|
|
76
84
|
&.variant-negative
|
|
77
85
|
background var(--status-negative-bg)
|
|
78
86
|
color var(--status-negative)
|
|
87
|
+
|
|
88
|
+
// Yellow variant — caution / pending status
|
|
89
|
+
&.variant-yellow
|
|
90
|
+
background-color var(--sb-yellow-50)
|
|
91
|
+
color var(--sb-yellow-600)
|
|
92
|
+
|
|
93
|
+
:global(.dark) &
|
|
94
|
+
background-color var(--sb-yellow-900)
|
|
95
|
+
color var(--sb-yellow-400)
|
|
@@ -4,6 +4,7 @@ interface CssExports {
|
|
|
4
4
|
'arrow': string;
|
|
5
5
|
'dot': string;
|
|
6
6
|
'root': string;
|
|
7
|
+
'squared': string;
|
|
7
8
|
'variant-accent': string;
|
|
8
9
|
'variant-active': string;
|
|
9
10
|
'variant-filled': string;
|
|
@@ -11,6 +12,7 @@ interface CssExports {
|
|
|
11
12
|
'variant-negative': string;
|
|
12
13
|
'variant-neutral': string;
|
|
13
14
|
'variant-positive': string;
|
|
15
|
+
'variant-yellow': string;
|
|
14
16
|
}
|
|
15
17
|
export const cssExports: CssExports;
|
|
16
18
|
export default cssExports;
|
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
import cn from 'classnames';
|
|
2
|
-
|
|
3
1
|
import { TrendingDown, TrendingUp } from 'lucide-react';
|
|
4
2
|
|
|
5
|
-
import S from './Chip.styl';
|
|
6
3
|
import { ChipProps } from './Chip.types';
|
|
4
|
+
import S from './Chip.styl';
|
|
5
|
+
import cn from 'classnames';
|
|
7
6
|
|
|
8
7
|
function Chip({
|
|
9
8
|
className,
|
|
10
9
|
variant = 'neutral',
|
|
11
10
|
dot,
|
|
12
11
|
trend,
|
|
12
|
+
squared = false,
|
|
13
13
|
children,
|
|
14
14
|
...props
|
|
15
15
|
}: ChipProps) {
|
|
16
|
-
const showDot = dot ?? variant === 'neutral';
|
|
17
16
|
const TrendIcon =
|
|
18
17
|
trend === 'up' ? TrendingUp : trend === 'down' ? TrendingDown : null;
|
|
19
18
|
|
|
20
19
|
return (
|
|
21
20
|
<span
|
|
22
21
|
data-slot="chip"
|
|
23
|
-
className={cn(
|
|
22
|
+
className={cn(
|
|
23
|
+
S.root,
|
|
24
|
+
S[`variant-${variant}`],
|
|
25
|
+
squared && S.squared,
|
|
26
|
+
className,
|
|
27
|
+
)}
|
|
24
28
|
{...props}
|
|
25
29
|
>
|
|
26
|
-
{
|
|
30
|
+
{dot && <span className={S.dot} aria-hidden="true" />}
|
|
27
31
|
{TrendIcon && (
|
|
28
32
|
<TrendIcon className={S.arrow} strokeWidth={1.5} aria-hidden="true" />
|
|
29
33
|
)}
|
|
@@ -7,7 +7,8 @@ export type ChipVariant =
|
|
|
7
7
|
| 'filled'
|
|
8
8
|
| 'accent'
|
|
9
9
|
| 'positive'
|
|
10
|
-
| 'negative'
|
|
10
|
+
| 'negative'
|
|
11
|
+
| 'yellow';
|
|
11
12
|
|
|
12
13
|
export type ChipTrend = 'up' | 'down';
|
|
13
14
|
|
|
@@ -15,9 +16,11 @@ export interface ChipProps extends ComponentProps<'span'> {
|
|
|
15
16
|
variant?: ChipVariant;
|
|
16
17
|
/**
|
|
17
18
|
* Show the 6px status dot. Defaults to true for the neutral variant
|
|
18
|
-
* and false for all others.
|
|
19
|
+
* (when not squared) and false for all others.
|
|
19
20
|
*/
|
|
20
21
|
dot?: boolean;
|
|
21
22
|
/** Render a Lucide trend arrow before the label. */
|
|
22
23
|
trend?: ChipTrend;
|
|
24
|
+
/** Use compact squared corners instead of the default pill shape. */
|
|
25
|
+
squared?: boolean;
|
|
23
26
|
}
|
|
@@ -10,6 +10,8 @@ export { PageHeader } from './PageHeader/PageHeader';
|
|
|
10
10
|
export { PageEmptyCanvas } from './PageEmptyCanvas/PageEmptyCanvas';
|
|
11
11
|
export { PageContent, PageContentSection } from './PageContent/PageContent';
|
|
12
12
|
export { PageScroll } from './PageScroll/PageScroll';
|
|
13
|
+
export { usePageScrollRestoration } from './usePageScrollRestoration';
|
|
14
|
+
export { readSavedScrollTop } from './pageScrollRestoration';
|
|
13
15
|
export { PageXScroll } from './PageXScroll/PageXScroll';
|
|
14
16
|
export { Breadcrumbs } from './Breadcrumbs/Breadcrumbs';
|
|
15
17
|
export { PageFooter } from './PageFooter/PageFooter';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isBrowser } from '#uilib/tools/env';
|
|
2
|
+
|
|
3
|
+
export function readSavedScrollTop(key: string): number | null {
|
|
4
|
+
if (!isBrowser) return null;
|
|
5
|
+
|
|
6
|
+
const raw = sessionStorage.getItem(key);
|
|
7
|
+
if (raw == null) return null;
|
|
8
|
+
|
|
9
|
+
const top = Number(raw);
|
|
10
|
+
return Number.isFinite(top) && top > 0 ? top : null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function saveScrollTop(key: string, top: number): void {
|
|
14
|
+
if (!isBrowser) return;
|
|
15
|
+
|
|
16
|
+
if (top <= 0) {
|
|
17
|
+
sessionStorage.removeItem(key);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
sessionStorage.setItem(key, String(top));
|
|
22
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { useCallback, useContext, useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import debounce from '#uilib/tools/debounce';
|
|
4
|
+
|
|
5
|
+
import { PageContext } from './pageContext';
|
|
6
|
+
import { readSavedScrollTop, saveScrollTop } from './pageScrollRestoration';
|
|
7
|
+
|
|
8
|
+
const SCROLL_SAVE_MS = 150;
|
|
9
|
+
|
|
10
|
+
/** Session scroll restoration for a PageScroll ancestor (via PageContext). */
|
|
11
|
+
export function usePageScrollRestoration(scrollRestorationKey: string) {
|
|
12
|
+
const { getPageScrollElement } = useContext(PageContext);
|
|
13
|
+
const debouncedSaveRef = useRef<ReturnType<typeof debounce> | null>(null);
|
|
14
|
+
const latestScrollTopRef = useRef(0);
|
|
15
|
+
const pendingRestoreTopRef = useRef<number | null>(null);
|
|
16
|
+
|
|
17
|
+
const tryRestoreScroll = useCallback(() => {
|
|
18
|
+
const el = getPageScrollElement();
|
|
19
|
+
const top = pendingRestoreTopRef.current;
|
|
20
|
+
if (!el || top == null) return false;
|
|
21
|
+
|
|
22
|
+
const maxTop = Math.max(0, el.scrollHeight - el.clientHeight);
|
|
23
|
+
const targetTop = Math.min(top, maxTop);
|
|
24
|
+
el.scrollTo({ top: targetTop, behavior: 'auto' });
|
|
25
|
+
|
|
26
|
+
const applied = el.scrollTop >= targetTop - 1 || maxTop <= 0;
|
|
27
|
+
if (applied && maxTop > 0) {
|
|
28
|
+
pendingRestoreTopRef.current = null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return applied;
|
|
32
|
+
}, [getPageScrollElement]);
|
|
33
|
+
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
debouncedSaveRef.current?.cancel();
|
|
36
|
+
debouncedSaveRef.current = debounce(
|
|
37
|
+
(key: string, top: number) => {
|
|
38
|
+
saveScrollTop(key, top);
|
|
39
|
+
},
|
|
40
|
+
SCROLL_SAVE_MS,
|
|
41
|
+
{ leading: false },
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return () => {
|
|
45
|
+
debouncedSaveRef.current?.cancel();
|
|
46
|
+
};
|
|
47
|
+
}, []);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
const el = getPageScrollElement();
|
|
51
|
+
if (!el) return;
|
|
52
|
+
|
|
53
|
+
const ro = new ResizeObserver(() => {
|
|
54
|
+
if (pendingRestoreTopRef.current != null) {
|
|
55
|
+
tryRestoreScroll();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
ro.observe(el);
|
|
59
|
+
|
|
60
|
+
return () => ro.disconnect();
|
|
61
|
+
}, [getPageScrollElement, tryRestoreScroll]);
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
const el = getPageScrollElement();
|
|
65
|
+
if (!el) return;
|
|
66
|
+
|
|
67
|
+
latestScrollTopRef.current = el.scrollTop;
|
|
68
|
+
|
|
69
|
+
const savedTop = readSavedScrollTop(scrollRestorationKey);
|
|
70
|
+
if (savedTop != null) {
|
|
71
|
+
pendingRestoreTopRef.current = savedTop;
|
|
72
|
+
tryRestoreScroll();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const handleScroll = () => {
|
|
76
|
+
latestScrollTopRef.current = el.scrollTop;
|
|
77
|
+
debouncedSaveRef.current?.(scrollRestorationKey, el.scrollTop);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
el.addEventListener('scroll', handleScroll, { passive: true });
|
|
81
|
+
|
|
82
|
+
return () => {
|
|
83
|
+
el.removeEventListener('scroll', handleScroll);
|
|
84
|
+
debouncedSaveRef.current?.cancel();
|
|
85
|
+
const storedTop = readSavedScrollTop(scrollRestorationKey) ?? 0;
|
|
86
|
+
const top = Math.max(latestScrollTopRef.current, storedTop);
|
|
87
|
+
saveScrollTop(scrollRestorationKey, top);
|
|
88
|
+
};
|
|
89
|
+
}, [getPageScrollElement, scrollRestorationKey, tryRestoreScroll]);
|
|
90
|
+
}
|