@synerise/ds-sidebar 1.1.45 → 1.1.47

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/CLAUDE.md +118 -0
  3. package/package.json +9 -8
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.1.47](https://github.com/Synerise/synerise-design/compare/@synerise/ds-sidebar@1.1.46...@synerise/ds-sidebar@1.1.47) (2026-07-23)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-sidebar
9
+
10
+ ## [1.1.46](https://github.com/Synerise/synerise-design/compare/@synerise/ds-sidebar@1.1.45...@synerise/ds-sidebar@1.1.46) (2026-07-16)
11
+
12
+ **Note:** Version bump only for package @synerise/ds-sidebar
13
+
6
14
  ## [1.1.45](https://github.com/Synerise/synerise-design/compare/@synerise/ds-sidebar@1.1.44...@synerise/ds-sidebar@1.1.45) (2026-07-09)
7
15
 
8
16
  **Note:** Version bump only for package @synerise/ds-sidebar
package/CLAUDE.md ADDED
@@ -0,0 +1,118 @@
1
+ # Sidebar (`@synerise/ds-sidebar`)
2
+
3
+ > A collapsible accordion sidebar built on a DS-native, antd-free `Collapse` (in `src/Collapse/`), with optional drag-and-drop panel reordering via `@synerise/ds-sortable`. Also exports `SidebarWithButton` — a helper component with a title and a dropdown-menu button.
4
+
5
+ ## Package structure
6
+
7
+ ```
8
+ src/
9
+ Sidebar.tsx — main component; conditional sortable/non-sortable modes
10
+ Sidebar.types.ts — SidebarProps, PanelProps, SidebarContextType, Order
11
+ Sidebar.styles.ts — StyledCollapse, StyledPanel, SidebarHandle, DragOverlay, etc.
12
+ Sidebar.context.tsx — SidebarContext { isSortable }
13
+ Collapse/
14
+ Collapse.tsx — DS-native accordion (manages active panels by `id`, clones children)
15
+ CollapsePanel.tsx — one item; renders the ant-collapse-* / ds-sidebar-* DOM
16
+ Collapse.types.ts — CollapseProps, CollapsePanelProps
17
+ Panel/
18
+ Panel.tsx — compound child; renders DraggablePanel or PanelContent
19
+ DraggablePanel/
20
+ DraggablePanel.tsx — useSortable wrapper around PanelContent
21
+ DragOverlayPanel/
22
+ DragOverlayPanel.tsx — visual copy of panel rendered during drag
23
+ PanelContent/
24
+ PanelContent.tsx — DS CollapsePanel wrapper with optional drag handle
25
+ SidebarWithButton/
26
+ SidebarWithButton.tsx — sidebar variant with title + dropdown button
27
+ SidebarWithButton.types.ts
28
+ SidebarWithButton.styles.ts
29
+ __specs__/Sidebar.spec.tsx — Vitest tests
30
+ index.ts — public exports
31
+ ```
32
+
33
+ ## Public exports
34
+
35
+ ### `Sidebar` (default export)
36
+
37
+ | Prop | Type | Default | Description |
38
+ |------|------|---------|-------------|
39
+ | `children` | `ReactNode` | — | **Required.** `<Sidebar.Panel>` elements |
40
+ | `order` | `string[]` | `[]` | Panel IDs in display order; also enables sortable mode when combined with `onChangeOrder` |
41
+ | `onChangeOrder` | `(order: string \| string[]) => void` | — | Called after drag reorder; **must be set alongside `order` to enable drag mode** |
42
+ | `defaultActiveKey` | `string[]` | — | Initially open panel IDs |
43
+ | `activeKey` | `string \| string[]` | — | Controlled open panels |
44
+ | `onChange` | `(keys: string \| string[]) => void` | — | Called when panels open/close |
45
+ | `getPopupContainer` | `(node: HTMLDivElement) => HTMLElement` | — | Portal target for the `DragOverlay`; useful when sidebar is inside a scrollable container |
46
+ | `className` | `string` | — | Added to the Collapse root |
47
+
48
+ Any other DS `CollapseProps` (`activeKey`, `defaultActiveKey`, `onChange`, `accordion`, `expandIcon`, `expandIconPosition`) are spread through.
49
+
50
+ **Drag mode is active when** `Array.isArray(order) && order.length > 0 && !!onChangeOrder`. The `is-drag-drop` CSS class is applied to the collapse when active.
51
+
52
+ ### `Sidebar.Panel` (compound component)
53
+
54
+ Accessed as `Sidebar.Panel` or imported as `Panel`. Renders as `DraggablePanel` in sortable mode and `PanelContent` otherwise.
55
+
56
+ | Prop | Type | Description |
57
+ |------|------|-------------|
58
+ | `id` | `string` | **Required.** Unique panel ID (used for ordering and collapse key) |
59
+ | `header` | `ReactNode` | **Required.** Panel header content |
60
+ | `children` | `ReactNode` | Panel body content |
61
+ | `forceRender` | `boolean` | Render body even when collapsed |
62
+ | `isActive` | `boolean` | Internal: whether panel is expanded |
63
+ | `draggable` | `boolean` | Internal: set by `DraggablePanel` |
64
+ | `dragHandleProps` | `HTMLAttributes<HTMLDivElement>` | Internal: set by `DraggablePanel` |
65
+
66
+ ### `SidebarWithButton`
67
+
68
+ A non-collapsible sidebar header variant with a title label and a ghost button that opens a dropdown menu.
69
+
70
+ | Prop | Type | Default | Description |
71
+ |------|------|---------|-------------|
72
+ | `dataSource` | `MenuItemProps[]` | — | **Required.** Menu items in the dropdown |
73
+ | `buttonLabel` | `string` | — | Button text |
74
+ | `title` | `string` | — | Title text on the left |
75
+
76
+ ## Usage patterns
77
+
78
+ ```tsx
79
+ import Sidebar from '@synerise/ds-sidebar';
80
+
81
+ // Non-sortable
82
+ <Sidebar defaultActiveKey={['overview']}>
83
+ <Sidebar.Panel id="overview" header="Overview">content</Sidebar.Panel>
84
+ <Sidebar.Panel id="settings" header="Settings">content</Sidebar.Panel>
85
+ </Sidebar>
86
+
87
+ // Sortable (drag-and-drop)
88
+ <Sidebar
89
+ order={panelOrder}
90
+ onChangeOrder={setPanelOrder}
91
+ defaultActiveKey={['overview']}
92
+ >
93
+ <Sidebar.Panel id="overview" header="Overview">content</Sidebar.Panel>
94
+ <Sidebar.Panel id="settings" header="Settings">content</Sidebar.Panel>
95
+ </Sidebar>
96
+ ```
97
+
98
+ ## Context / Provider
99
+
100
+ `SidebarContext` is created in `Sidebar.context.tsx` and provides `{ isSortable: boolean }` to `Panel` children. `Panel` checks this context to decide whether to render a `DraggablePanel` or a plain `PanelContent`. No external Provider is needed.
101
+
102
+ ## Styling
103
+
104
+ `StyledCollapse` in `Sidebar.styles.ts` styles the DS accordion DOM via its `.ant-collapse-*` class hooks (retained for ui-tests / interim external CSS; `ds-sidebar-*` emitted alongside). Header padding is `18px 24px`. Content padding is `16px 24px`. Background is `blue-050`. The drag handle (`SidebarHandle`) is `cursor: grabbing` and positioned absolutely on the left of the header.
105
+
106
+ ## Key dependencies
107
+
108
+ - DS-native `Collapse` / `CollapsePanel` (`src/Collapse/`) — the accordion engine (no antd)
109
+ - `@synerise/ds-sortable` — `SortableContainer`, `DragOverlay`, `useSortable`, `CSS`
110
+ - `@synerise/ds-icon` — expand icons (`AngleDownS`, `AngleUpS`) and drag handle (`DragHandleM`)
111
+ - `@synerise/ds-dropdown`, `@synerise/ds-menu`, `@synerise/ds-button` — used by `SidebarWithButton`
112
+
113
+ ## Implementation notes
114
+
115
+ - **Collapse keys panels the way antd did** (`child.key ?? index`): the DS `Collapse` matches `activeKey`/`defaultActiveKey`/`onChange` against each panel's React `key`, falling back to the child index when a panel has no key. The panel helpers (`createSidebarPanels`, and real consumers) set `key={id}`, so id-based `activeKey`/`defaultActiveKey` work as before; panels written without a key (e.g. the `WithBlock` story, `defaultActiveKey="0"`) match by index — exactly as under antd. `Collapse` strips the `.$` prefix that `Children.toArray` (the sortable path) adds and treats positional `.N` keys as "no key", so the old `prefixKeys` juggling is unnecessary and `activeKey`/`defaultActiveKey`/`onChange` still speak plain ids in both modes.
116
+ - **`DragOverlayPanel`** is rendered either inside `getPopupContainer` target (via `createPortal`) or inline if no container is provided.
117
+ - **`onChangeOrder` must be truthy** to enable sorting — passing an empty array as `order` without `onChangeOrder` does not enable drag mode.
118
+ - **Uses Vitest** for testing.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-sidebar",
3
- "version": "1.1.45",
3
+ "version": "1.1.47",
4
4
  "description": "Sidebar UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -17,6 +17,7 @@
17
17
  "files": [
18
18
  "/dist",
19
19
  "CHANGELOG.md",
20
+ "CLAUDE.md",
20
21
  "README.md",
21
22
  "package.json",
22
23
  "LICENSE.md"
@@ -41,12 +42,12 @@
41
42
  ],
42
43
  "types": "dist/index.d.ts",
43
44
  "dependencies": {
44
- "@synerise/ds-button": "^1.5.33",
45
- "@synerise/ds-dropdown": "^1.3.18",
46
- "@synerise/ds-icon": "^1.18.4",
47
- "@synerise/ds-menu": "^1.4.30",
48
- "@synerise/ds-sortable": "^1.3.20",
49
- "@synerise/ds-utils": "^1.10.1",
45
+ "@synerise/ds-button": "^1.5.35",
46
+ "@synerise/ds-dropdown": "^1.3.20",
47
+ "@synerise/ds-icon": "^1.18.5",
48
+ "@synerise/ds-menu": "^1.4.32",
49
+ "@synerise/ds-sortable": "^1.3.21",
50
+ "@synerise/ds-utils": "^1.10.2",
50
51
  "classnames": "^2.5.1"
51
52
  },
52
53
  "peerDependencies": {
@@ -55,5 +56,5 @@
55
56
  "styled-components": "^5.3.3",
56
57
  "vitest": "4"
57
58
  },
58
- "gitHead": "5c90008871be36fb52553a2ed3a633acf5db5b3b"
59
+ "gitHead": "d0a43cc43d8528a36f105aceea52ab470edb71d9"
59
60
  }