@sinequa/galactik 0.0.0-stage → 2.1.0
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 +155 -2
- package/fesm2022/sinequa-galactik.mjs +23902 -0
- package/fesm2022/sinequa-galactik.mjs.map +1 -0
- package/package.json +28 -3
- package/types/sinequa-galactik.d.ts +7818 -0
package/README.md
CHANGED
|
@@ -1,3 +1,156 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @sinequa/galactik
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Angular UI primitives built on top of [`@angular/aria`](https://www.npmjs.com/package/@angular/aria), [`@floating-ui/dom`](https://floating-ui.com/) and [`class-variance-authority`](https://cva.style/), designed to be composed and themed with Tailwind CSS.
|
|
4
|
+
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- Angular `^22.0.0`
|
|
8
|
+
- `@angular/aria` `^22.0.0`
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @sinequa/galactik
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Contributing
|
|
17
|
+
|
|
18
|
+
`CONTRIBUTING.md` is the contract for working inside this library: project layout, file and
|
|
19
|
+
naming conventions, how components are written, the tokens-only styling rule, accessibility,
|
|
20
|
+
the public API, documentation, tests, and the checklists for adding a component or migrating
|
|
21
|
+
one from `@sinequa/ui`.
|
|
22
|
+
|
|
23
|
+
## Exports
|
|
24
|
+
|
|
25
|
+
Public API surface (see `public-api.ts`):
|
|
26
|
+
|
|
27
|
+
- **Menu** — `MenuComponent`, `MenuContentComponent`, `MenuItemComponent`, `SubMenuComponent`, `MenuTriggerDirective`
|
|
28
|
+
- **Tabs** — `TabsComponent`, `TabListComponent`, `TabComponent`, `TabPanelComponent`
|
|
29
|
+
- **Popover** — `DropdownDirective` (alias of `PopoverDirective`, kept for backward compatibility)
|
|
30
|
+
- **Utils** — `cn` helper for merging Tailwind class names
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
### Menu
|
|
35
|
+
|
|
36
|
+
`Menu` exposes the `itemSelected` output — it emits the `value` of the chosen `<MenuItem>` (keyboard or mouse). Items that open a submenu never emit.
|
|
37
|
+
|
|
38
|
+
> **Note** — always declare the template ref with the `exportAs` form (`#menu="menu"`). Without it, Angular types the reference as the host `HTMLElement` instead of the `MenuComponent` instance, which makes `[menuTrigger]="menu"` fail type-checking and prevents accessing the component's API.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { Component } from "@angular/core";
|
|
42
|
+
import { MenuComponent, MenuContentComponent, MenuItemComponent, MenuTriggerDirective } from "@sinequa/galactik";
|
|
43
|
+
|
|
44
|
+
@Component({
|
|
45
|
+
selector: "app-menu-example",
|
|
46
|
+
imports: [MenuComponent, MenuContentComponent, MenuItemComponent, MenuTriggerDirective],
|
|
47
|
+
template: `
|
|
48
|
+
<button [menuTrigger]="menu">Open</button>
|
|
49
|
+
<Menu #menu="menu" (itemSelected)="onSelect($event)">
|
|
50
|
+
<MenuContent>
|
|
51
|
+
<MenuItem value="edit">Edit</MenuItem>
|
|
52
|
+
<MenuItem value="delete">Delete</MenuItem>
|
|
53
|
+
</MenuContent>
|
|
54
|
+
</Menu>
|
|
55
|
+
`,
|
|
56
|
+
})
|
|
57
|
+
export class MenuExampleComponent {
|
|
58
|
+
onSelect(value: string) {
|
|
59
|
+
console.log("Selected item:", value);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
#### Submenus
|
|
65
|
+
|
|
66
|
+
Nest a `<SubMenu>` inside a `<MenuItem>` and wire them together with `[submenu]`:
|
|
67
|
+
|
|
68
|
+
```ts
|
|
69
|
+
import { Component } from "@angular/core";
|
|
70
|
+
import { MenuComponent, MenuContentComponent, MenuItemComponent, MenuTriggerDirective, SubMenuComponent } from "@sinequa/galactik";
|
|
71
|
+
|
|
72
|
+
@Component({
|
|
73
|
+
selector: "app-submenu-example",
|
|
74
|
+
imports: [MenuComponent, MenuContentComponent, MenuItemComponent, MenuTriggerDirective, SubMenuComponent],
|
|
75
|
+
template: `
|
|
76
|
+
<button [menuTrigger]="menu">Open</button>
|
|
77
|
+
<Menu #menu="menu" (itemSelected)="onSelect($event)">
|
|
78
|
+
<MenuContent>
|
|
79
|
+
<MenuItem value="copy">Copy</MenuItem>
|
|
80
|
+
<MenuItem value="more" [submenu]="moreSub">More…</MenuItem>
|
|
81
|
+
|
|
82
|
+
<SubMenu #moreSub="ngMenu">
|
|
83
|
+
<MenuItem value="rename">Rename</MenuItem>
|
|
84
|
+
<MenuItem value="delete">Delete</MenuItem>
|
|
85
|
+
</SubMenu>
|
|
86
|
+
</MenuContent>
|
|
87
|
+
</Menu>
|
|
88
|
+
`,
|
|
89
|
+
})
|
|
90
|
+
export class SubmenuExampleComponent {
|
|
91
|
+
onSelect(value: string) {
|
|
92
|
+
console.log("Selected item:", value);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
> **Note** — the ref must be `#moreSub="ngMenu"`, **not** `="submenu"`. The `[submenu]` input on `<MenuItem>` expects the underlying `Menu` directive instance from `@angular/aria` (exported as `ngMenu`), which `<SubMenu>` applies via `hostDirectives`. Exporting `="submenu"` would give you the wrapper component instead, and `[submenu]="moreSub"` would fail type-checking.
|
|
98
|
+
|
|
99
|
+
### Tabs
|
|
100
|
+
|
|
101
|
+
`TabList` re-exposes the `selectedTabChange` output from `@angular/aria` — it emits the `value` of the currently selected tab.
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
import { Component } from "@angular/core";
|
|
105
|
+
import { TabsComponent, TabListComponent, TabComponent, TabPanelComponent } from "@sinequa/galactik";
|
|
106
|
+
|
|
107
|
+
@Component({
|
|
108
|
+
selector: "app-tabs-example",
|
|
109
|
+
imports: [TabsComponent, TabListComponent, TabComponent, TabPanelComponent],
|
|
110
|
+
template: `
|
|
111
|
+
<Tabs>
|
|
112
|
+
<TabList (selectedTabChange)="onTabChange($event)">
|
|
113
|
+
<Tab value="overview">Overview</Tab>
|
|
114
|
+
<Tab value="details">Details</Tab>
|
|
115
|
+
</TabList>
|
|
116
|
+
<TabPanel value="overview">Overview content</TabPanel>
|
|
117
|
+
<TabPanel value="details">Details content</TabPanel>
|
|
118
|
+
</Tabs>
|
|
119
|
+
`,
|
|
120
|
+
})
|
|
121
|
+
export class TabsExampleComponent {
|
|
122
|
+
onTabChange(value: string) {
|
|
123
|
+
console.log("Selected tab:", value);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Popover / Dropdown
|
|
129
|
+
|
|
130
|
+
The `[popover]` and `[dropdown]` selectors are provided by the same directive. Use `[dropdown]` when you want the floating panel to close on click (it's the default for the dropdown alias).
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
import { Component } from "@angular/core";
|
|
134
|
+
import { DropdownDirective } from "@sinequa/galactik";
|
|
135
|
+
|
|
136
|
+
@Component({
|
|
137
|
+
selector: "app-popover-example",
|
|
138
|
+
imports: [DropdownDirective],
|
|
139
|
+
template: `
|
|
140
|
+
<button popovertarget="my-dropdown">Open</button>
|
|
141
|
+
<div dropdown id="my-dropdown" placement="bottom-start">
|
|
142
|
+
Dropdown content
|
|
143
|
+
</div>
|
|
144
|
+
`,
|
|
145
|
+
})
|
|
146
|
+
export class PopoverExampleComponent {}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Development
|
|
150
|
+
|
|
151
|
+
This library is part of the `atomic-angular` workspace and is built with the Angular CLI:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
ng build galactik
|
|
155
|
+
ng test galactik
|
|
156
|
+
```
|