Skip to content

Commit e2545f9

Browse files
authored
docs: create CLAUDE.md files (#8227)
- root md file: For developers working on this repo. - packages md files: For consumers - bundled in. _In this PR the `files` field in the package.json of the packages is also cleanup up. `LICENSE` is added by lerna, the reference there was pointing to a non existing file._
1 parent 88f50fa commit e2545f9

15 files changed

Lines changed: 1725 additions & 10 deletions

File tree

CLAUDE.md

Lines changed: 401 additions & 0 deletions
Large diffs are not rendered by default.

docs/knowledge-base/ServerSideRendering.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default function AppOrRootLayout() {
5151
#### Icon and Feature Imports in Server Components
5252

5353
Some UI5 Web Component features rely on the registration of a component during runtime on the client.
54-
The most common of these are icon imports (e.g. `import '@ui5/webcomponents-icons/dist/add.js';`), feature imports (e.g. `import '@ui5/webcomponents/dist/features/FormSupport.js';` and asset imports (e.g. `import '@ui5/webcomponents-react/dist/Assets.js';`).
54+
The most common of these are icon imports (e.g. `import '@ui5/webcomponents-icons/dist/add.js';`) and asset imports (e.g. `import '@ui5/webcomponents-react/dist/Assets.js';`).
5555

5656
In order to fulfill their purpose in your application, you must ensure that these imports are only used in client components (the file or a parent component must contain the `'use client';` directive).
5757
If they are imported into server components, these imports will do nothing and you'll notice that some features or icons are not available in your application.

packages/ai/CLAUDE.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# @ui5/webcomponents-ai-react
2+
3+
React wrappers for `@ui5/webcomponents-ai` - AI-focused UI5 Web Components.
4+
5+
> **Experimental:** This package is under active development. APIs may change.
6+
>
7+
> **Horizon themes only** - not compatible with other SAP themes.
8+
9+
## Documentation
10+
11+
For component APIs, props, and usage examples, see the official UI5 Web Components AI documentation:
12+
13+
**https://sap.github.io/ui5-webcomponents/components/ai/**
14+
15+
## Installation
16+
17+
```bash
18+
npm install @ui5/webcomponents-ai-react @ui5/webcomponents-ai
19+
```
20+
21+
## Available Components
22+
23+
| Component | Description |
24+
| ------------- | ---------------------------------- |
25+
| `Button` | Multi-state AI action button |
26+
| `ButtonState` | State definition for Button |
27+
| `PromptInput` | Input for AI prompts |
28+
| `Input` | Input with AI Writing Assistant |
29+
| `TextArea` | TextArea with AI Writing Assistant |
30+
31+
## Import Pattern
32+
33+
```tsx
34+
import { Button } from '@ui5/webcomponents-ai-react/Button';
35+
import { ButtonState } from '@ui5/webcomponents-ai-react/ButtonState';
36+
import { PromptInput } from '@ui5/webcomponents-ai-react/PromptInput';
37+
import { Input } from '@ui5/webcomponents-ai-react/Input';
38+
import { TextArea } from '@ui5/webcomponents-ai-react/TextArea';
39+
```
40+
41+
## Event Handling
42+
43+
Event data is in `e.detail`. For fully controlled components, call `e.preventDefault()` in `onInput` to prevent internal state updates.
44+
45+
**Cancelable events:** `Input.onInput`, `Input.onButtonClick`, `TextArea.onInput`

packages/ai/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@
6262
"files": [
6363
"dist",
6464
"CHANGELOG.md",
65-
"NOTICE.txt"
65+
"CLAUDE.md"
6666
]
6767
}

packages/base/CLAUDE.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# @ui5/webcomponents-react-base
2+
3+
Core utilities, hooks, and infrastructure for UI5 Web Components React wrappers. This package is primarily used internally by `@ui5/webcomponents-react` but exports useful hooks and utilities for consumers.
4+
5+
## Import Pattern
6+
7+
Subpath imports are recommended for clarity:
8+
9+
```tsx
10+
// ✅ Recommended - subpath imports
11+
import { useI18nBundle, useViewportRange } from '@ui5/webcomponents-react-base/hooks';
12+
import * as Device from '@ui5/webcomponents-react-base/Device';
13+
import { ThemingParameters } from '@ui5/webcomponents-react-base/ThemingParameters';
14+
15+
// Also works - root import
16+
import { useI18nBundle, useViewportRange } from '@ui5/webcomponents-react-base';
17+
```
18+
19+
## Public API
20+
21+
### Hooks (`@ui5/webcomponents-react-base/hooks`)
22+
23+
#### `useI18nBundle(bundleName: string)`
24+
25+
Access internationalization bundles for translated text.
26+
27+
```tsx
28+
import { useI18nBundle } from '@ui5/webcomponents-react-base/hooks';
29+
30+
function MyComponent() {
31+
const i18n = useI18nBundle('@ui5/webcomponents-react');
32+
const label = i18n.getText('BUTTON_LABEL');
33+
// With placeholders: i18n.getText('ITEMS_SELECTED', 5, 20) -> "5 of 20 items selected"
34+
35+
return <span>{label}</span>;
36+
}
37+
```
38+
39+
#### `useViewportRange()`
40+
41+
Get current viewport size range for responsive layouts.
42+
43+
```tsx
44+
import { useViewportRange } from '@ui5/webcomponents-react-base/hooks';
45+
46+
function ResponsiveComponent() {
47+
const range = useViewportRange();
48+
// Returns: 'Phone' | 'Tablet' | 'Desktop' | 'LargeDesktop'
49+
50+
return range === 'Phone' ? <MobileView /> : <DesktopView />;
51+
}
52+
```
53+
54+
### Device Utilities (`@ui5/webcomponents-react-base/Device`)
55+
56+
Re-exports from `@ui5/webcomponents-base/dist/Device.js` plus additional resize/orientation handlers.
57+
58+
```tsx
59+
import * as Device from '@ui5/webcomponents-react-base/Device';
60+
61+
// From @ui5/webcomponents-base - check capabilities
62+
Device.supportsTouch();
63+
64+
// Resize handling
65+
Device.attachResizeHandler((windowSize) => {
66+
console.log(windowSize.width, windowSize.height);
67+
});
68+
Device.detachResizeHandler(handler);
69+
70+
// Orientation handling
71+
Device.getOrientation(); // { landscape: boolean, portrait: boolean }
72+
Device.attachOrientationChangeHandler((orientation) => {
73+
console.log(orientation.landscape, orientation.portrait);
74+
});
75+
Device.detachOrientationChangeHandler(handler);
76+
77+
// Media range queries
78+
Device.getCurrentRange(); // Current viewport range
79+
Device.attachMediaHandler(handler);
80+
Device.detachMediaHandler(handler);
81+
```
82+
83+
### ThemingParameters (`@ui5/webcomponents-react-base/ThemingParameters`)
84+
85+
TypeScript-friendly mappings for SAP theming CSS variables. Useful for **inline styles** or **CSS-in-JS** solutions.
86+
87+
```tsx
88+
import { ThemingParameters } from '@ui5/webcomponents-react-base/ThemingParameters';
89+
90+
// CSS-in-JS / inline styles
91+
const style = {
92+
backgroundColor: ThemingParameters.sapBackgroundColor, // 'var(--sapBackgroundColor)'
93+
color: ThemingParameters.sapTextColor, // 'var(--sapTextColor)'
94+
borderRadius: ThemingParameters.sapElement_BorderCornerRadius,
95+
fontFamily: ThemingParameters.sapFontFamily,
96+
};
97+
98+
// Semantic colors
99+
ThemingParameters.sapPositiveColor; // success/positive
100+
ThemingParameters.sapNegativeColor; // error/negative
101+
ThemingParameters.sapCriticalColor; // warning
102+
ThemingParameters.sapInformativeColor; // info
103+
```
104+
105+
**For standard CSS files**, use the CSS variables directly (e.g., `var(--sapBackgroundColor)`).
106+
107+
See the full list of available CSS variables: https://experience.sap.com/fiori-design-web/theming-base-content/
108+
109+
### Types (`@ui5/webcomponents-react-base/types`)
110+
111+
```tsx
112+
import type { UI5WCSlotsNode } from '@ui5/webcomponents-react-base/types';
113+
114+
// UI5WCSlotsNode - Type for slot content (ReactNode | ReactNode[])
115+
```
116+
117+
## Internal APIs
118+
119+
The following exports exist for sharing between packages of this library. **They are not intended for consumer use** and may change without notice:
120+
121+
- `./internal/hooks` - Internal hooks (`useSyncRef`, `useStylesheet`, `useIsRTL`, `useCurrentTheme`, `useIsomorphicLayoutEffect`)
122+
- `./internal/utils` - Internal utilities (`debounce`, `throttle`, `enrichEventWithDetails`)
123+
- `./internal/types` - Internal types (`CommonProps`, `Ui5CustomEvent`, `Ui5DomRef`)
124+
- `./withWebComponent` - HOC for wrapping web components

packages/base/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@
105105
"files": [
106106
"dist",
107107
"CHANGELOG.md",
108-
"LICENSE",
109-
"NOTICE.txt",
108+
"CLAUDE.md",
110109
"README.md"
111110
]
112111
}

0 commit comments

Comments
 (0)