cleanplate 0.3.21 → 0.3.22

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).
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cleanplate",
3
- "version": "0.3.21",
3
+ "version": "0.3.22",
4
4
  "description": "CleanPlate - A Headless React UI Framework",
5
5
  "files": [
6
6
  "dist",