cleanplate 0.3.21 → 0.3.23

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.
@@ -1 +1 @@
1
- {"version":3,"file":"table-arg-types.d.ts","sourceRoot":"","sources":["../../../src/stories/table/table-arg-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAejD,wFAAwF;AACxF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,MAAM,CAWtD,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,QAE/B,CAAC"}
1
+ {"version":3,"file":"table-arg-types.d.ts","sourceRoot":"","sources":["../../../src/stories/table/table-arg-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAgBjD,wFAAwF;AACxF,eAAO,MAAM,yBAAyB,EAAE,QAAQ,CAAC,MAAM,CAWtD,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,QAE/B,CAAC"}
package/docs/Avatar.md CHANGED
@@ -7,6 +7,7 @@ Purpose: Displays user initials, an image, or a Material icon in a consistent ci
7
7
  | Prop | Type | Required | Default | Description |
8
8
  | --- | --- | --- | --- | --- |
9
9
  | name | string | no | "" | Display name; used for initials and `title` when no image/icon. Also used for image `alt`. |
10
+ | codeText | string | no | "" | Optional code-like text override for non-image/non-icon mode. Keeps only alphanumeric chars, then renders the last 4 characters (uppercased). |
10
11
  | image | string | no | "" | Image URL; when set, shows image instead of initials or icon. |
11
12
  | icon | MaterialIconName | no | — | Material icon name; when set (and no image), shows icon instead of initials. |
12
13
  | size | "small" \| "medium" | no | "medium" | Size of the avatar. |
@@ -36,6 +37,7 @@ type AvatarMargin = string | SpacingOption[];
36
37
  ```typescript
37
38
  interface AvatarProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "style"> {
38
39
  name?: string;
40
+ codeText?: string;
39
41
  image?: string;
40
42
  icon?: MaterialIconName; // from "../icon/material-icon-names"
41
43
  size?: AvatarSize;
@@ -60,6 +62,20 @@ export const Example = () => (
60
62
  );
61
63
  ```
62
64
 
65
+ ### Code text (up to 4 chars)
66
+
67
+ ```jsx
68
+ import { Avatar } from "cleanplate";
69
+
70
+ export const Example = () => (
71
+ <>
72
+ <Avatar codeText="B101" size="medium" />
73
+ <Avatar codeText="F2" size="small" />
74
+ <Avatar codeText="order-AB#12-99" size="medium" />
75
+ </>
76
+ );
77
+ ```
78
+
63
79
  ### Icon
64
80
 
65
81
  ```jsx
@@ -143,8 +159,10 @@ export const Example = () => (
143
159
 
144
160
  ## Behavior Notes
145
161
 
146
- - **Display priority:** If `image` is set, the image is shown. Else if `icon` is set, the Material icon is shown. Otherwise initials from `name` are shown.
162
+ - **Display priority:** If `image` is set, the image is shown. Else if `icon` is set, the Material icon is shown. Else if `codeText` resolves to a valid value, that text is shown. Otherwise initials from `name` are shown.
163
+ - **Code text sanitization:** `codeText` removes special characters, keeps only `[a-zA-Z0-9]`, then renders the **last 4** characters in uppercase. Examples: `"B101"` -> `"B101"`, `"F2"` -> `"F2"`, `"AB#12-99"` -> `"1299"`.
147
164
  - **Initials:** Derived from the first letter of each word in `name` (up to 2 characters), e.g. "John Doe" → "JD".
165
+ - **Text fitting:** Avatar text auto-scales for 3-4 characters so code labels remain readable in both sizes.
148
166
  - **Backgrounds (CSS only):** **Initials** use `var(--primary-brand)` on the root. **Icon** mode uses `var(--primary-brand)` for the circle. **Image** mode uses `var(--white)` behind the photo so transparent PNGs do not show a hole. To change colors, add a **`className`** and target the root in your stylesheet.
149
167
  - **Spacing:** `margin` accepts the **spacing suffix**; the component adds the `m-` prefix via `getSpacingClass`. Use suffix form (e.g. `"0"`, `"2"`, `"b-3"`) when passing values explicitly.
150
168
  - **Root element:** A `div`; supports `ref` and other attributes except **`style`** (omitted from the public type so layout stays class-based).
@@ -0,0 +1,179 @@
1
+ # FeedbackState Component
2
+
3
+ Purpose: Unified empty and error **region** for cards, panels, tables, and main content areas — when a section has no data or failed to load. Use `Alert` for short inline banners and `Toast` for transient messages. **Margin** uses the **framework-wide spacing suffix rule** (same for all components); see `llms.txt`.
4
+
5
+ **Illustrations:** CleanPlate does not host artwork. Pass your own image URL (`png`, `jpg`, `svg`) or a custom `ReactNode`, or use the `icon` prop with a Material icon name when no image is needed.
6
+
7
+ ## Props / Inputs
8
+
9
+ | Prop | Type | Required | Default | Description |
10
+ | --- | --- | --- | --- | --- |
11
+ | variant | `"empty" \| "error"` | yes | — | Drives default ARIA role and error tone |
12
+ | title | string | yes | — | Primary headline |
13
+ | titleTag | `"h1"` … `"h6" \| "p"` | no | `"h2"` | Semantic element for the title |
14
+ | description | string \| ReactNode | no | — | Supporting copy |
15
+ | illustration | string \| ReactNode | no | — | Image URL or custom media node |
16
+ | illustrationAlt | string | no | `""` | `alt` for URL images; empty = decorative |
17
+ | icon | MaterialIconName | no | — | Material icon when `illustration` is omitted |
18
+ | size | `"small" \| "medium" \| "large"` | no | `"medium"` | Overall scale (spacing, media box, icon size) |
19
+ | primaryAction | ActionConfig | no | — | Solid primary button |
20
+ | secondaryAction | ActionConfig | no | — | Ghost secondary button |
21
+ | onRetry | `() => void` | no | — | Shorthand primary “Try again” when `primaryAction` is absent |
22
+ | retryLabel | string | no | `"Try again"` | Label when `onRetry` is used |
23
+ | errorCode | string \| number | no | — | Visual error code (not the sole indicator) |
24
+ | errorDetails | string | no | — | Technical detail in a `<details>` disclosure |
25
+ | role | `"alert" \| "status" \| "none"` | no | `status` (empty) / `alert` (error) | Root ARIA role |
26
+ | margin | string \| SpacingOption[] | no | `"0"` | Spacing **suffix**; component adds `m-` prefix |
27
+ | className | string | no | `""` | Extra class on root for consumer CSS overrides |
28
+ | dataTestId | string | no | — | `data-testid` on root |
29
+
30
+ ### ActionConfig
31
+
32
+ ```typescript
33
+ type ActionConfig = {
34
+ label: string;
35
+ onClick: () => void;
36
+ };
37
+ ```
38
+
39
+ Actions use `Button` only — there is no `href`. Use `onClick` for navigation (e.g. router).
40
+
41
+ ## Types
42
+
43
+ ### FeedbackStateVariant
44
+ ```typescript
45
+ type FeedbackStateVariant = "empty" | "error";
46
+ ```
47
+
48
+ ### FeedbackStateSize
49
+ ```typescript
50
+ type FeedbackStateSize = "small" | "medium" | "large";
51
+ ```
52
+
53
+ ### FeedbackStateTitleTag
54
+ ```typescript
55
+ type FeedbackStateTitleTag = "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p";
56
+ ```
57
+
58
+ ### FeedbackStateRole
59
+ ```typescript
60
+ type FeedbackStateRole = "alert" | "status" | "none";
61
+ ```
62
+
63
+ ### FeedbackStateProps
64
+ ```typescript
65
+ interface FeedbackStateProps {
66
+ variant: FeedbackStateVariant;
67
+ title: string;
68
+ titleTag?: FeedbackStateTitleTag;
69
+ description?: string | React.ReactNode;
70
+ illustration?: string | React.ReactNode;
71
+ illustrationAlt?: string;
72
+ icon?: MaterialIconName;
73
+ size?: FeedbackStateSize;
74
+ primaryAction?: ActionConfig;
75
+ secondaryAction?: ActionConfig;
76
+ onRetry?: () => void;
77
+ retryLabel?: string;
78
+ errorCode?: string | number;
79
+ errorDetails?: string;
80
+ role?: FeedbackStateRole;
81
+ margin?: string | SpacingOption[];
82
+ className?: string;
83
+ dataTestId?: string;
84
+ }
85
+ ```
86
+
87
+ ## Usage Examples
88
+
89
+ ### Empty state with icon
90
+
91
+ ```jsx
92
+ import { FeedbackState } from "cleanplate";
93
+
94
+ export const ProjectsEmpty = ({ onCreate }) => (
95
+ <FeedbackState
96
+ variant="empty"
97
+ title="No projects yet"
98
+ description="Create your first project to get started."
99
+ icon="folder_open"
100
+ primaryAction={{ label: "New project", onClick: onCreate }}
101
+ />
102
+ );
103
+ ```
104
+
105
+ ### Empty state with module illustration
106
+
107
+ ```jsx
108
+ <FeedbackState
109
+ variant="empty"
110
+ title="No search results"
111
+ description="Try adjusting your filters."
112
+ illustration="/assets/modules/search-empty.png"
113
+ illustrationAlt=""
114
+ primaryAction={{ label: "Clear filters", onClick: clearFilters }}
115
+ />
116
+ ```
117
+
118
+ ### Error with retry
119
+
120
+ ```jsx
121
+ <FeedbackState
122
+ variant="error"
123
+ title="Could not load projects"
124
+ description="Check your connection and try again."
125
+ icon="cloud_off"
126
+ errorCode={503}
127
+ onRetry={refetch}
128
+ />
129
+ ```
130
+
131
+ ### Error with technical details
132
+
133
+ ```jsx
134
+ <FeedbackState
135
+ variant="error"
136
+ title="Request failed"
137
+ errorDetails={error.message}
138
+ dataTestId="projects-error"
139
+ />
140
+ ```
141
+
142
+ ### Custom styles via className
143
+
144
+ ```jsx
145
+ <FeedbackState
146
+ variant="empty"
147
+ title="No items"
148
+ className="my-module-empty"
149
+ icon="inbox"
150
+ />
151
+ ```
152
+
153
+ ```css
154
+ .my-module-empty.cp-feedback-state {
155
+ min-height: 280px;
156
+ }
157
+ ```
158
+
159
+ ## Behavior Notes
160
+
161
+ - **Media precedence:** `illustration` → `icon` → no media. If both `illustration` and `icon` are set, illustration wins.
162
+ - **Action precedence:** `primaryAction` overrides `onRetry`.
163
+ - **Layout:** Stacked only (media above text, centered actions).
164
+ - **Accessibility:** Root `aria-labelledby` points at the title; decorative media uses `aria-hidden` when `illustrationAlt` is empty and a title is present.
165
+ - **Motion:** Subtle mount fade; disabled when `prefers-reduced-motion: reduce`.
166
+
167
+ ### Stable slot classes (for CSS overrides)
168
+
169
+ - `cp-feedback-state` — root
170
+ - `cp-feedback-state__media`, `cp-feedback-state__media-img`
171
+ - `cp-feedback-state__content`, `cp-feedback-state__title`, `cp-feedback-state__description`
172
+ - `cp-feedback-state__error-code`, `cp-feedback-state__actions`, `cp-feedback-state__details`
173
+
174
+ ## Related Components / Links
175
+
176
+ - Alert (inline feedback)
177
+ - Toast (transient messages)
178
+ - Button, Icon, Typography (composed internally)
179
+ - Container (wrap for layout in stories and apps)
package/docs/Header.md CHANGED
@@ -136,7 +136,9 @@ Prefer **`Dropdown`** with **`Avatar`** as **`trigger`** and **`content`** that
136
136
  - **headerLeft / headerCenter / headerRight:** When provided, replace the default logo, MenuList, or right slot.
137
137
  - **AppShell:** If you pass **`header`** as **`HeaderProps`** to **`AppShell`**, configure **`headerRight`** the same way as a standalone **`Header`** (recommended account dropdown structure does not change).
138
138
  - **showCenterMenu:** When `false`, the center column is empty on desktop (unless `headerCenter` is set). `menuItems` is still used for the mobile overlay.
139
- - **Mobile:** Below 1024px, center nav hides; hamburger shows. Click opens slide-in menu (Animated fade-in-left).
139
+ - **Mobile:** Below 1024px, center nav hides; hamburger shows. Click opens a Floating UI drawer with backdrop fade and left slide animation.
140
+ - **Backdrop + close:** Clicking the backdrop closes the drawer; close button and menu item clicks also close it.
141
+ - **Scroll lock:** While the mobile drawer is open, background page scroll is locked.
140
142
  - **onMenuItemClick:** Called with the clicked item; mobile menu closes on click.
141
143
  - **Margin:** Uses the suffix API (e.g. `"0"` → m-0).
142
144
 
@@ -146,4 +148,4 @@ Prefer **`Dropdown`** with **`Avatar`** as **`trigger`** and **`content`** that
146
148
  - Dropdown, Avatar (account menu in **headerRight**; see `docs/Dropdown.md`)
147
149
  - AppShell (passes **`header`** as Header props; same **headerRight** recommendations apply)
148
150
  - Button, Icon (mobile menu trigger and close)
149
- - Animated (mobile menu slide-in)
151
+ - Floating UI overlay/dialog primitives (mobile menu drawer)
@@ -10,6 +10,7 @@ Purpose: Combines fixed media (`Avatar`: icon, image, or initials) with a dense
10
10
  | mediaIcon | `MaterialIconName` \| string | no | "" | Material Symbol name passed to `Avatar`. |
11
11
  | mediaImage | string | no | "" | Image URL for `Avatar`. |
12
12
  | mediaAvatar | string | no | "" | Display name used for initials when image/icon are not shown. |
13
+ | mediaAvatarCodeText | string | no | "" | Optional avatar code override. Passed to `Avatar.codeText` (alphanumeric only, last 4 chars). |
13
14
  | subtitle | `React.ReactNode` | no | — | Optional middle line (e.g. subject). Omit for two-line layouts. |
14
15
  | description | `React.ReactNode` | no | — | Optional preview/snippet line(s); muted, multi-line ellipsis via `--cp-media-object-desc-lines`. |
15
16
  | descriptionLineClamp | number | no | 2 | Max lines for `description` before truncation. |
@@ -40,6 +41,7 @@ interface MediaObjectProps extends React.HTMLAttributes<HTMLDivElement> {
40
41
  mediaIcon?: MaterialIconName | string;
41
42
  mediaImage?: string;
42
43
  mediaAvatar?: string;
44
+ mediaAvatarCodeText?: string;
43
45
  title: string;
44
46
  subtitle?: React.ReactNode;
45
47
  description?: React.ReactNode;
@@ -184,6 +186,7 @@ import { MediaObject, Typography } from "cleanplate";
184
186
  - **Trailing rail**: If `meta` and/or `action` is passed, the body adds a second grid column: `meta` always occupies **column 2, row 1** aligned with `title`; `action` occupies **column 2, last text row**, aligned toward the snippet row. When **only one** logical text row remains and **both** `meta` and `action` exist, both stack in one compact trailing cell (`gap` 2px).
185
187
  - **`descriptionLineClamp`** sets the CSS custom property `--cp-media-object-desc-lines` on the snippet wrapper so consumers can clamp 1–N lines preview text.
186
188
  - **Media slot**: Implemented with `Avatar` (`name={mediaAvatar}`, `image`, `icon`). Combination rules when multiple props are set match `Avatar` (see `docs/Avatar.md`); typical usage passes one dominant source (photo URL vs icon vs name for initials).
189
+ - **Code avatars**: Use `mediaAvatarCodeText` for code-like values (e.g. `B101`, `F2`). Avatar sanitizes to alphanumeric and renders the last 4 chars.
187
190
  - **`meta` primitives**: Strings and numbers render with component meta typography (muted `--text-muted`); pass React nodes when you control color/weight entirely.
188
191
  - **`title`** is always a string rendered as emphasized primary text (`--text-default`).
189
192
  - **`subtitle`** and **`description`** accept `React.ReactNode`; empty string / falsy hides the slot.
package/docs/Table.md CHANGED
@@ -74,13 +74,14 @@ interface TableMobileColumns
74
74
  extends Omit<
75
75
  MediaObjectProps,
76
76
  | "title" | "subtitle" | "description" | "meta" | "action"
77
- | "mediaAvatar" | "mediaIcon" | "mediaImage" | "onClick"
77
+ | "mediaAvatar" | "mediaAvatarCodeText" | "mediaIcon" | "mediaImage" | "onClick"
78
78
  > {
79
79
  title: TableMobileColumnKey; // required row key
80
80
  subtitle?: TableMobileColumnField;
81
81
  description?: TableMobileColumnField;
82
82
  meta?: TableMobileColumnField;
83
83
  mediaAvatar?: TableMobileColumnKey;
84
+ mediaAvatarCodeText?: TableMobileColumnField<string>; // static code, row key, or resolver
84
85
  mediaIcon?: TableMobileColumnField<string>; // static icon, row key, or resolver
85
86
  mediaImage?: TableMobileColumnField<string>; // static URL, row key, or resolver
86
87
  action?: (row: TableRow) => React.ReactNode;
@@ -180,6 +181,7 @@ const columns = [
180
181
  description: "email",
181
182
  meta: "status",
182
183
  mediaAvatar: "name",
184
+ mediaAvatarCodeText: "employeeCode",
183
185
  descriptionLineClamp: 2,
184
186
  action: (row) => <Badge label={String(row.status)} variant="success" />,
185
187
  }}
@@ -200,7 +202,7 @@ const columns = [
200
202
 
201
203
  - **Required:** `columns` and `data` are required. Each column must have `id` and `title`; row keys should match `id` for default cell display.
202
204
  - **Pagination:** Built-in Pagination is shown when `totalItems` > 0 and `hidePagination` is false. Pass `onPageChange` and optionally `onRowsPerPageChange`; keep `currentPage` and `rowsPerPage` in parent state.
203
- - **Mobile:** When viewport width < 768px and `mobileColumns` is set, each row renders as a `MediaObject`. Map row keys to `title`, `subtitle`, `description`, `meta`, and media fields, or use resolvers / `action` for custom per-row UI. Static MediaObject props (`descriptionLineClamp`, `margin`, `padding`, etc.) pass through unchanged.
205
+ - **Mobile:** When viewport width < 768px and `mobileColumns` is set, each row renders as a `MediaObject`. Map row keys to `title`, `subtitle`, `description`, `meta`, and media fields (`mediaAvatar`, `mediaAvatarCodeText`, `mediaIcon`, `mediaImage`), or use resolvers / `action` for custom per-row UI. Static MediaObject props (`descriptionLineClamp`, `margin`, `padding`, etc.) pass through unchanged.
204
206
  - **customRender:** Receives `(rowData, column)` and returns a React node; use for badges, buttons, or any custom cell content.
205
207
  - **Spacing:** `margin` uses the suffix API; the component adds the `m-` prefix via `getSpacingClass`.
206
208
 
package/llms.txt CHANGED
@@ -101,6 +101,13 @@ All component documentation is located in the `docs/` folder. The following docu
101
101
  - Types: AlertProps, AlertSize, AlertVariant, AlertMargin, SpacingOption
102
102
  - Related Components: Typography, Container, Button, Icon (used internally)
103
103
 
104
+ ### FeedbackState Component
105
+ - File: `docs/FeedbackState.md`
106
+ - Purpose: Unified empty and error region for cards, panels, tables, and content areas. Consumer-supplied illustration URL (png/jpg/svg) or Material `icon`; optional primary/secondary actions (`onClick` only).
107
+ - Key Features: variant empty|error, sizes small|medium|large, stacked layout, errorCode/errorDetails, onRetry shorthand, className overrides, dataTestId, margin suffix API
108
+ - Types: FeedbackStateProps, FeedbackStateVariant, FeedbackStateSize, FeedbackStateTitleTag, FeedbackStateRole, ActionConfig, FeedbackStateMargin, SpacingOption
109
+ - Related Components: Typography, Button, Icon (used internally); Alert (inline); Toast (transient)
110
+
104
111
  ### Spinner Component
105
112
  - File: `docs/Spinner.md`
106
113
  - Purpose: Loading indicator that shows a rotating Material icon. Use for progress or activity states.
@@ -259,6 +266,7 @@ All documentation files follow a consistent format:
259
266
  | Container | `docs/Container.md` | Layout, spacing, and flex structure |
260
267
  | Dropdown | `docs/Dropdown.md` | Menus and floating panels |
261
268
  | Alert | `docs/Alert.md` | Inline feedback and notices |
269
+ | FeedbackState | `docs/FeedbackState.md` | Empty/error content regions |
262
270
  | Spinner | `docs/Spinner.md` | Loading and activity indicator |
263
271
  | Stepper | `docs/Stepper.md` | Wizard / checkout **step progress** (not numeric +/−; that is **FormControls.Stepper** in FormControls) |
264
272
  | BreadCrumb | `docs/BreadCrumb.md` | Navigation trail and page hierarchy |
@@ -296,5 +304,5 @@ npm install cleanplate
296
304
  ## Usage
297
305
 
298
306
  ```jsx
299
- import { Button, Typography, Icon, MediaObject, Avatar, Container, Dropdown, Alert, Spinner, Stepper, BreadCrumb, Accordion, ConfirmDialog, Modal, Pagination, Table, Badge, Pills, Animated, FormControls, Toast, MenuList, Header, PageHeader, BottomSheet, Footer, AppShell } from "cleanplate";
307
+ import { Button, Typography, Icon, MediaObject, Avatar, Container, Dropdown, Alert, FeedbackState, Spinner, Stepper, BreadCrumb, Accordion, ConfirmDialog, Modal, Pagination, Table, Badge, Pills, Animated, FormControls, Toast, MenuList, Header, PageHeader, BottomSheet, Footer, AppShell } from "cleanplate";
300
308
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cleanplate",
3
- "version": "0.3.21",
3
+ "version": "0.3.23",
4
4
  "description": "CleanPlate - A Headless React UI Framework",
5
5
  "files": [
6
6
  "dist",