@cognite/aura 0.3.0 → 0.3.2
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/DESIGN.md +2243 -729
- package/README.md +133 -11
- package/dist/components/index.d.ts +3 -2
- package/dist/components/index.js +183 -176
- package/dist/components/ui/core/action-toolbar/action-toolbar.js +4 -4
- package/dist/components/ui/core/alert/alert.js +3 -3
- package/dist/components/ui/core/banner/banner.js +6 -6
- package/dist/components/ui/core/button/button.js +4 -4
- package/dist/components/ui/core/checkbox/checkbox.js +8 -8
- package/dist/components/ui/core/code-block/code-block.js +6 -6
- package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.d.ts +15 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/date-picker.js +73 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/index.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/types.d.ts +17 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/date-picker/use-date-picker.js +52 -0
- package/dist/components/ui/core/date-time-pickers/date-range-picker/date-range-picker.js +64 -75
- package/dist/components/ui/core/date-time-pickers/date-range-picker/types.d.ts +1 -2
- package/dist/components/ui/core/date-time-pickers/date-range-picker/use-date-range-picker.js +51 -64
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/date-time-range-picker.js +146 -161
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/types.d.ts +1 -2
- package/dist/components/ui/core/date-time-pickers/date-time-range-picker/use-date-time-range-picker.js +124 -137
- package/dist/components/ui/core/date-time-pickers/index.d.ts +4 -0
- package/dist/components/ui/core/date-time-pickers/index.js +10 -0
- package/dist/components/ui/core/date-time-pickers/shared/calendar/calendar.js +8 -8
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.d.ts +1 -1
- package/dist/components/ui/core/date-time-pickers/shared/date-time-input/date-time-input.js +1 -1
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.d.ts +0 -2
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-popover-state.js +18 -34
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.d.ts +23 -0
- package/dist/components/ui/core/date-time-pickers/shared/hooks/use-single-date-state.js +32 -0
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/index.d.ts +2 -0
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.d.ts +19 -0
- package/dist/components/ui/core/date-time-pickers/shared/time-picker-panel/time-picker-panel.js +41 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/index.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.d.ts +16 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/time-picker.js +100 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/types.d.ts +23 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.d.ts +3 -0
- package/dist/components/ui/core/date-time-pickers/time-picker/use-time-picker.js +64 -0
- package/dist/components/ui/core/date-time-pickers/utils/calendar-utils.js +3 -3
- package/dist/components/ui/core/date-time-pickers/utils/time-utils.js +1 -1
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.d.ts +17 -15
- package/dist/components/ui/core/dropdown-menu/dropdown-menu.js +83 -85
- package/dist/components/ui/core/hover-card/hover-card.js +3 -3
- package/dist/components/ui/core/input/input.js +1 -1
- package/dist/components/ui/core/message/message.js +387 -101
- package/dist/components/ui/core/pagination/pagination.js +9 -7
- package/dist/components/ui/core/prompt-input/prompt-input.js +16 -16
- package/dist/components/ui/core/radio-group/radio-group.js +7 -7
- package/dist/components/ui/core/reasoning/reasoning.js +1 -1
- package/dist/components/ui/core/segmented-control/segmented-control.js +3 -3
- package/dist/components/ui/core/select/select.d.ts +2 -1
- package/dist/components/ui/core/select/select.js +134 -110
- package/dist/components/ui/core/shimmer/shimmer.d.ts +3 -1
- package/dist/components/ui/core/shimmer/shimmer.js +89 -49
- package/dist/components/ui/core/tabs/tabs.js +3 -3
- package/dist/components/ui/core/textarea/textarea.js +1 -1
- package/dist/components/ui/core/toggle/toggle.d.ts +15 -0
- package/dist/components/ui/core/toggle/toggle.js +74 -0
- package/dist/components/ui/core/tool/tool.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/lib/portal-container-context.js +3 -3
- package/dist/lib/use-controllable-state.js +17 -17
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.js +7 -7
- package/dist/styles.css +1 -1
- package/dist/styles.source.css +3 -0
- package/package.json +200 -18
- package/dist/index.js +0 -308
package/README.md
CHANGED
|
@@ -2,6 +2,109 @@
|
|
|
2
2
|
|
|
3
3
|
Aura exports Cognite's UI components, styles, utilities, and ESLint guidance for preserving the design system in downstream apps.
|
|
4
4
|
|
|
5
|
+
## Using Aura in Fusion
|
|
6
|
+
|
|
7
|
+
[`DESIGN.md`](./DESIGN.md) describes visual identity, critical interaction rules, and UX guidance for feedback, disclosure, errors, layout, and accessibility. This section covers *how to use the package* in the Fusion monorepo and host shell.
|
|
8
|
+
|
|
9
|
+
### Package imports
|
|
10
|
+
|
|
11
|
+
Aura ships two flavours of component import. Both resolve through the package's `exports` map — never reach into `src/`.
|
|
12
|
+
|
|
13
|
+
**Per-component subpath (preferred for app code)** keeps bundles small by only pulling in what each module actually needs:
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { Button } from '@cognite/aura/components/button';
|
|
17
|
+
import { Card } from '@cognite/aura/components/card';
|
|
18
|
+
import { DatePicker } from '@cognite/aura/components/date-time-pickers';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Aggregate barrel** is convenient for stories, prototypes, and code that already pulls in many components. The barrel is side-effect-free (`*.css` aside) and tree-shakes well in modern bundlers, so prefer whichever style reads better at the call site:
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { Button, Card } from '@cognite/aura/components';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Stylesheets and tokens are imported the same way regardless of which component-import style you use:
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
import '@cognite/aura/colors.css';
|
|
31
|
+
import '@cognite/aura/styles.css';
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Canonical token sources in this repo: `src/colors.css` and `src/styles.source.css`. In consuming apps, import from the published package paths above — not from `src/` next to your app code.
|
|
35
|
+
|
|
36
|
+
Do not import Aura through relative paths from another project, such as `../../../libs/aura/src/components`. Fusion resolves Aura through its package exports, so use `@cognite/aura/components` (or a per-component subpath), `@cognite/aura/colors.css`, and `@cognite/aura/styles.css`.
|
|
37
|
+
|
|
38
|
+
#### Adding a new component
|
|
39
|
+
|
|
40
|
+
Every Aura component must support **both** import styles. When you add a new component:
|
|
41
|
+
|
|
42
|
+
1. Place its source under `src/components/ui/core/<name>/<name>.tsx`, matching the kebab-case directory used by existing components.
|
|
43
|
+
2. Re-export it from the aggregate barrel in `src/components/index.ts` so `@cognite/aura/components` keeps working.
|
|
44
|
+
3. Register a per-component subpath export in `libs/aura/package.json` (alphabetical order):
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
"./components/<name>": {
|
|
48
|
+
"@fusion/source": "./src/components/ui/core/<name>/<name>.tsx",
|
|
49
|
+
"import": "./dist/components/ui/core/<name>/<name>.js",
|
|
50
|
+
"types": "./dist/components/ui/core/<name>/<name>.d.ts"
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Composite components that ship as a folder (such as `date-time-pickers`) point at the folder's `index.ts` instead.
|
|
55
|
+
|
|
56
|
+
The Vite build derives library entries directly from `package.json` (`entriesFromPackageJson: true`), so once both entry points are wired the dist output and types appear automatically. The two surfaces must stay in sync — consumers should be able to choose either style without missing exports.
|
|
57
|
+
|
|
58
|
+
Aura uses Tailwind v4 package CSS entry points. Consuming Fusion apps should not add a `tailwind.config.js` just to wire Aura tokens or content paths; import `@cognite/aura/styles.css` and let Aura's exported CSS carry the theme and source directives. `styles.css` is the public stylesheet entry point for product consumers; in published external packages it resolves to the built Tailwind CSS output produced by Aura's build.
|
|
59
|
+
|
|
60
|
+
When another Fusion library exposes Aura-styled components, give that library the same self-sourcing setup instead of pushing scan rules into every consumer:
|
|
61
|
+
|
|
62
|
+
- Export a package stylesheet, for example `@cognite/example-ui/styles.css`.
|
|
63
|
+
- In that stylesheet, import `@cognite/aura/styles.source.css` and source the library itself. `styles.source.css` is for package stylesheets that compose Aura's Tailwind theme/source directives before adding their own `@source` rules:
|
|
64
|
+
|
|
65
|
+
```css
|
|
66
|
+
@import '@cognite/aura/styles.source.css';
|
|
67
|
+
@source './';
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
- If the target app already relies on `!important` style precedence, for example through styled-components overrides or existing Cogs components, add Tailwind's import modifier so Aura utilities can match that setup when necessary:
|
|
71
|
+
|
|
72
|
+
```css
|
|
73
|
+
@import '@cognite/aura/styles.source.css' important;
|
|
74
|
+
@source './';
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
- If the library builds or previews that stylesheet directly, include `@tailwindcss/vite` in its Vite and Storybook setup.
|
|
78
|
+
- Consumers should import the library stylesheet, not Aura internals. For example, an app using `@cognite/atlas-ai-react-ui` should import `@cognite/atlas-ai-react-ui/styles.css`, which can pull in Aura internally.
|
|
79
|
+
- Do not add cross-project `@source "../../../libs/..."` directives or `tailwind.config.js` `content` entries for other Fusion libraries. In Tailwind v4 these app-level content arrays do not replace package-owned `@source` directives.
|
|
80
|
+
|
|
81
|
+
Prefer **CVA** variants and component APIs over overriding primitive styles. Prop names, `size` values, and subcomponents are defined in:
|
|
82
|
+
|
|
83
|
+
- [Aura Storybook](https://storybook-aura-23638.fusion-preview.preview.cogniteapp.com)
|
|
84
|
+
- [Aura design system docs](https://docs.cognite.com/aura-design-system/get-started)
|
|
85
|
+
- TypeScript types from `@cognite/aura/components`
|
|
86
|
+
|
|
87
|
+
### Fusion shell integration
|
|
88
|
+
|
|
89
|
+
The Fusion host shell owns global chrome that Aura does not ship: **Topbar**, **Sonner** toasts, **AlertDialog**, **Sheet** / **Drawer**, **Tabs**, **SegmentedControl**, and some patterns like **EmptyState**. These **must** still follow Aura tokens, [Interaction states](./DESIGN.md#interaction-states), and [Heuristics](./DESIGN.md#heuristics).
|
|
90
|
+
|
|
91
|
+
| Concern | Fusion convention |
|
|
92
|
+
| ------- | ----------------- |
|
|
93
|
+
| Primary navigation | One **Topbar**; avoid duplicating global nav in content |
|
|
94
|
+
| View switching | Shell **Tabs** / **SegmentedControl** when the product uses that pattern |
|
|
95
|
+
| Toasts | **Sonner**, bottom-right, ~4s auto-dismiss, themed with Aura tokens |
|
|
96
|
+
| Confirm destructive work | Shell **AlertDialog** or Aura **Dialog** with explicit copy |
|
|
97
|
+
| Narrow viewports | Prefer shell **Drawer** / **Dialog** over compressed multi-column chrome |
|
|
98
|
+
|
|
99
|
+
For local sub-app development against the live shell, use import map overrides — see the Fusion [subapp manual testing guide](../../.cursor/rules/subapp-manual-testing.mdc).
|
|
100
|
+
|
|
101
|
+
### Serve and test locally
|
|
102
|
+
|
|
103
|
+
```sh
|
|
104
|
+
pnpm nx serve aura # Storybook
|
|
105
|
+
pnpm nx run aura:design-md-lint
|
|
106
|
+
```
|
|
107
|
+
|
|
5
108
|
## Optional peer dependencies
|
|
6
109
|
|
|
7
110
|
Some Aura entry points require optional peer dependencies that consumers must install themselves:
|
|
@@ -35,30 +138,49 @@ Some Aura entry points require optional peer dependencies that consumers must in
|
|
|
35
138
|
</ChartContainer>
|
|
36
139
|
```
|
|
37
140
|
|
|
38
|
-
##
|
|
141
|
+
## Versioning
|
|
39
142
|
|
|
40
|
-
|
|
143
|
+
### Before releasing
|
|
41
144
|
|
|
42
|
-
|
|
145
|
+
Ensure all documentation is up to date before bumping the version:
|
|
43
146
|
|
|
44
|
-
|
|
147
|
+
- [`CHANGELOG.md`](./CHANGELOG.md) — summarise all consumer-facing changes since the last release.
|
|
148
|
+
- [`DESIGN.md`](./DESIGN.md) — reflect any new or updated components, tokens, or visual behaviour.
|
|
149
|
+
- Any agent skills in `.cursor/skills/` or `.claude/skills/` that reference Aura components or APIs.
|
|
45
150
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
151
|
+
### Release process
|
|
152
|
+
|
|
153
|
+
1. Create a release branch off the latest `master`.
|
|
154
|
+
2. Bump the version in `libs/aura/package.json` and prepend a new section to `CHANGELOG.md`.
|
|
155
|
+
3. Commit with `release(aura): <version>` and open a PR into `master`.
|
|
156
|
+
4. Once merged, CI publishes the package to the registry automatically.
|
|
157
|
+
|
|
158
|
+
### After publishing
|
|
49
159
|
|
|
50
|
-
|
|
160
|
+
Consumers can adopt the new version by updating their `package.json` manually, or by letting Renovate/Dependabot open a bump PR in their repo automatically. [The Custom Apps repo](https://github.com/cognitedata/dune) has this configured and is the primary critical consumer.
|
|
161
|
+
|
|
162
|
+
## DESIGN.md
|
|
163
|
+
|
|
164
|
+
[`DESIGN.md`](./DESIGN.md) describes Aura's visual identity in the [Google design.md](https://github.com/google-labs-code/design.md) format — YAML design tokens in front matter plus markdown rationale for coding agents.
|
|
165
|
+
|
|
166
|
+
Validate structure, token references, and section order with [`@google/design.md`](https://www.npmjs.com/package/@google/design.md):
|
|
167
|
+
|
|
168
|
+
**Recommended (from the Fusion workspace root):**
|
|
51
169
|
|
|
52
170
|
```sh
|
|
53
|
-
pnpm
|
|
171
|
+
pnpm nx run aura:design-md-lint
|
|
54
172
|
```
|
|
55
173
|
|
|
56
|
-
|
|
174
|
+
**Direct CLI (from `libs/aura`):**
|
|
57
175
|
|
|
58
176
|
```sh
|
|
59
|
-
|
|
177
|
+
npx --yes @google/design.md lint ./DESIGN.md
|
|
60
178
|
```
|
|
61
179
|
|
|
180
|
+
Exit code `0` means the file passed (no errors). Warnings surface issues such as orphaned tokens or out-of-order sections.
|
|
181
|
+
|
|
182
|
+
Published installs ship this spec at the package root; resolve it as `@cognite/aura/DESIGN.md` (for example with `import.meta.resolve` or your bundler's raw import).
|
|
183
|
+
|
|
62
184
|
## ESLint
|
|
63
185
|
|
|
64
186
|
Aura ships an ESLint plugin at `@cognite/aura/eslint`.
|
|
@@ -31,6 +31,7 @@ export { Kbd, KbdGroup } from './ui/core/kbd/kbd';
|
|
|
31
31
|
export { Progress } from './ui/core/progress/progress';
|
|
32
32
|
export { Textarea } from './ui/core/textarea/textarea';
|
|
33
33
|
export { Tabs, TabsLabel, TabsList, TabsPanel, TabsTrigger, tabsListVariants, tabsTriggerVariants, } from './ui/core/tabs/tabs';
|
|
34
|
+
export { Toggle, toggleVariants } from './ui/core/toggle/toggle';
|
|
34
35
|
export { InputGroup, InputGroupAddon, InputGroupButton, InputGroupText, InputGroupInput, InputGroupTextarea, } from './ui/core/input-group/input-group';
|
|
35
36
|
export { Alert, AlertTitle, AlertDescription, AlertActions, AlertButton, AlertClose, } from './ui/core/alert/alert';
|
|
36
37
|
export { EmptyState, EmptyStateIcon, EmptyStateTitle, EmptyStateDescription, EmptyStateActions, } from './ui/core/empty-state/empty-state';
|
|
@@ -46,7 +47,7 @@ export { Search } from './ui/core/search/search';
|
|
|
46
47
|
export { Popover, PopoverClose, PopoverContent, PopoverDescription, PopoverHeader, PopoverHeaderContent, PopoverSlot, PopoverTitle, PopoverTrigger, } from './ui/core/popover/popover';
|
|
47
48
|
export { Pagination, PaginationContent, PaginationEllipsis, PaginationFirst, PaginationItem, PaginationLast, PaginationLink, PaginationNext, PaginationPrevious, PaginationResultsPerPage, PaginationResultsPerPageLabel, PaginationSelectTrigger, PaginationStatus, PaginationTeleport, } from './ui/core/pagination/pagination';
|
|
48
49
|
export { Sources, SourcesTitle, Source } from './ui/core/sources/sources';
|
|
49
|
-
export { DateRangePicker, DateTimeRangePicker, } from './ui/core/date-time-pickers';
|
|
50
|
-
export type { DateRangePickerProps, DateTimeRangePickerProps, ShortcutItem, TimeFormat, } from './ui/core/date-time-pickers';
|
|
50
|
+
export { DatePicker, DateRangePicker, DateTimeRangePicker, TimePicker, } from './ui/core/date-time-pickers';
|
|
51
|
+
export type { DatePickerProps, DateRangePickerProps, DateTimeRangePickerProps, ShortcutItem, TimeFormat, TimePickerProps, } from './ui/core/date-time-pickers';
|
|
51
52
|
export { PortalContainerContext } from '../lib/portal-container-context';
|
|
52
53
|
export type { ComponentMeta, ComponentStatusType } from '../lib/types';
|