cleanplate 0.3.9 → 0.3.11
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/dist/components/form-controls/Select.d.ts +11 -0
- package/dist/components/form-controls/Select.d.ts.map +1 -1
- package/dist/components/page-header/PageHeader.d.ts.map +1 -1
- package/dist/components/pagination/Pagination.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.css +1 -1
- package/dist/index.es.js +4 -4
- package/dist/index.js +4 -4
- package/docs/FormControls.md +6 -2
- package/docs/PageHeader.md +10 -7
- package/package.json +1 -1
package/docs/FormControls.md
CHANGED
|
@@ -8,7 +8,7 @@ FormControls is a set of form primitives exported as a namespace: `FormControls.
|
|
|
8
8
|
| --- | --- | --- |
|
|
9
9
|
| Input | Single-line text | placeholder, value, onChange(e), type |
|
|
10
10
|
| TextArea | Multi-line text | placeholder, value, onChange(e) |
|
|
11
|
-
| Select | Floating UI combobox: desktop portalled list; **≤768px** bottom sheet; sync or async options, search, groups, multi chips + cap | `mode` / `isMulti`, `options`, `onSearch`, `groups`, `maxSelect`, `triggerMaxItems`, `name`, `placeholder`, `error` |
|
|
11
|
+
| Select | Floating UI combobox: desktop portalled list; **≤768px** bottom sheet; sync or async options, search, groups, multi chips + cap | `mode` / `isMulti`, `options`, `onSearch`, `searchable`, `groups`, `maxSelect`, `triggerMaxItems`, `panelMinWidth`, `name`, `placeholder`, `error` |
|
|
12
12
|
| Date | Calendar date picker (`date-fns` + Floating UI); **Cancel** / **OK** staging; desktop **popover** (~**400px** max width, viewport-capped); **≤768px** **bottom sheet** + backdrop; **month** / **year** subviews with back + titled headers; trigger **`calendar_month`** icon | `value`/`defaultValue` (`Date \| null`), `onChange`, `minDate`/`maxDate`/`disabledDates`/`disabledDaysOfWeek`, `locale`, `weekStartsOn`, `dateFormat`, `clearable`, `readOnly`, `name` (hidden **yyyy-MM-dd**), `popoverPlacement`, `onOpen`/`onClose` |
|
|
13
13
|
| Checkbox | Checkbox group (array-based, multi-select) | name, label, options, value (CheckboxValue[]), defaultValue, onChange(values, e), orientation, variant |
|
|
14
14
|
| Radio | Radio group (array-based) | name, label, options, value, defaultValue, onChange(value, e), orientation, variant |
|
|
@@ -59,6 +59,8 @@ interface SelectProps {
|
|
|
59
59
|
onSearch?: (query: string) => Promise<Option[]>;
|
|
60
60
|
/** Debounce for `onSearch` only (ms). @default 300 */
|
|
61
61
|
searchDebounce?: number;
|
|
62
|
+
/** When false, hides the panel search field. @default true */
|
|
63
|
+
searchable?: boolean;
|
|
62
64
|
/** Panel search field placeholder. @default "Search" */
|
|
63
65
|
searchPlaceholder?: string;
|
|
64
66
|
/** When search text matches nothing, optional “add” callback receives trimmed string. */
|
|
@@ -74,6 +76,8 @@ interface SelectProps {
|
|
|
74
76
|
triggerClassName?: string;
|
|
75
77
|
triggerActiveClassName?: string;
|
|
76
78
|
contentsClassName?: string;
|
|
79
|
+
/** Desktop only: min width of the options panel (px or CSS length). @default trigger width only */
|
|
80
|
+
panelMinWidth?: number | string;
|
|
77
81
|
dataTestId?: string;
|
|
78
82
|
/** Selection mode. @default 'single'. Prefer over legacy `isMulti`. */
|
|
79
83
|
mode?: "single" | "multi";
|
|
@@ -371,7 +375,7 @@ Pagination uses `FormControls.Select` for rows-per-page. Pills uses `FormControl
|
|
|
371
375
|
- **Input (`prefix` / `suffix`):** Inline leading/trailing text affix for currency (`$`), country code (`+91`), unit (`kg`, `%`), TLD (`.com`), etc. Soft-capped at 4 characters so the layout stays predictable; longer strings are truncated. When set, the field's outer wrapper takes over the visible border / padding / focus ring so the affixes read as part of the same input. Affixes are linked to the input via `aria-describedby`, so screen readers announce e.g. "Amount, dollars, $500" when the visible affix is `$`. For symbols/abbreviations that don't read well, pass `prefixA11yLabel` / `suffixA11yLabel` (e.g. `prefix="$"`, `prefixA11yLabel="dollars"`). Ignored when `type="search"` (search already uses both edges) — for any other `type`, including `number`, affixes work as expected.
|
|
372
376
|
- **Input (validation / constraints):** `maxLength` is passed straight to the native attribute (works for any `type`). `min` / `max` are passed to the native attribute (HTML5 form-validation hints) and, for `type="number"` only, also clamped on `blur` — the user can finish typing freely and the value snaps to the bound when they leave the field.
|
|
373
377
|
- **Input (`autoComplete` / `onBlur`):** `autoComplete` maps to the native attribute (`"email"`, `"current-password"`, `"off"`, …). `onBlur` runs after any internal numeric clamp so consumers see the final value.
|
|
374
|
-
- **Select:** Built on **Floating UI** — desktop uses a **portalled** panel with flip/shift to stay in the viewport; **≤768px** uses a **bottom sheet** (`role="dialog"`, `aria-modal`, `aria-labelledby` to the field label when the label exists). **Option** shape supports `group`, `icon`, `avatar`, `meta`, `disabled`. **`mode`** (`'single' | 'multi'`) replaces **`isMulti`** (still supported, deprecated). Single mode: **`onChange(Option | null)`** — `null` when cleared. Multi mode: **`onChange(Option[])`** — use **`[]`** for clear. **`name` + hidden `<input>`:** native form submit posts the selected **`value`**(s); **multi** joins with **commas** — avoid comma characters inside `value` if you rely on `FormData`, or parse manually. **`options={null}` + `onSearch`:** async loading; show loading/empty/error states in the panel. **`groups`:** sticky headings for shared `Option.group`. **`maxSelect`:** multi only; **`triggerMaxItems`:** chip overflow **`+N`**. **`aria-controls`** on the combobox trigger and panel search point at the listbox **only while open**. **`aria-invalid`** reflects **`error`** on trigger, search field, and listbox. Validation message uses **`role="alert"`** (via shared field error pattern).
|
|
378
|
+
- **Select:** Built on **Floating UI** — desktop uses a **portalled** panel with flip/shift to stay in the viewport; panel **width** matches the trigger, with optional **`panelMinWidth`** when options need more horizontal space; **`searchable={false}`** hides the panel search field (full static list, or async `onSearch("")` on open); **≤768px** uses a **bottom sheet** (`role="dialog"`, `aria-modal`, `aria-labelledby` to the field label when the label exists). **Option** shape supports `group`, `icon`, `avatar`, `meta`, `disabled`. **`mode`** (`'single' | 'multi'`) replaces **`isMulti`** (still supported, deprecated). Single mode: **`onChange(Option | null)`** — `null` when cleared. Multi mode: **`onChange(Option[])`** — use **`[]`** for clear. **`name` + hidden `<input>`:** native form submit posts the selected **`value`**(s); **multi** joins with **commas** — avoid comma characters inside `value` if you rely on `FormData`, or parse manually. **`options={null}` + `onSearch`:** async loading; show loading/empty/error states in the panel. **`groups`:** sticky headings for shared `Option.group`. **`maxSelect`:** multi only; **`triggerMaxItems`:** chip overflow **`+N`**. **`aria-controls`** on the combobox trigger and panel search point at the listbox **only while open**. **`aria-invalid`** reflects **`error`** on trigger, search field, and listbox. Validation message uses **`role="alert"`** (via shared field error pattern).
|
|
375
379
|
- **Date:** **`Date | null`** with **`onChange`**. Opens a **`role="dialog"`** calendar: **staging** applies on day tap; **Cancel** reverts to the last committed value; **OK** commits (and clears staging). **Desktop:** portalled Floating UI panel with flip/shift, fixed **max width ~400px** (capped by viewport). **≤768px:** bottom sheet fixed to the lower viewport + dimmed backdrop, `aria-modal`, body scroll lock while open (same breakpoint idea as Select). **Header:** month cluster + year cluster (44px arrow hits); tapping month/year opens **scrollable subviews** with **back (`arrow_back`)** and headings **“Select a month of {yyyy}”** / **“Select a year for {MMMM}”** (locale-aware via `locale`). **Trigger:** **`calendar_month`** trailing icon (not Select chevrons); optional **clear** when `clearable`. **`readOnly`** and **`isDisabled`** block interaction. Constraints: **`minDate`/`maxDate`** (inclusive), **`disabledDates`**, **`disabledDaysOfWeek`**. **`dateFormat`** + **`locale`** control the field string; grid labels follow **`locale`** and **`weekStartsOn`**. **`name`:** hidden input posts **`yyyy-MM-dd`** for the **committed** value only. **`onOpen`/`onClose`** fire when the panel opens/closes. **`popoverPlacement`** adjusts desktop anchor (default `bottom-start`). **`error`** / **`isRequired`** use the shared field error pattern (`aria-invalid`, message under the field).
|
|
376
380
|
- **Radio:** Group-first API — pass `options: RadioOption[]`. Renders `<fieldset>` + `<legend>` with a single `value` and `onChange(value, e)`. `isRequired` puts `*` on the legend and adds `required`/`aria-required` to the first enabled option (HTML5 only requires one input in the group to carry it). Custom ring/dot follows the native `:checked` state so uncontrolled groups stay visually correct. Pass `variant="card"` for tile-style options (ring in top-right, optional `icon` on the left, primary-brand border + tint when selected).
|
|
377
381
|
- **Checkbox:** Group-first API — pass `options: CheckboxOption[]`. Renders `<fieldset>` + `<legend>` with a `value: CheckboxValue[]` and `onChange(values, e)`. `isRequired` puts `*` on the legend and sets `aria-required` on the group; native HTML5 doesn't enforce "at least one" for checkbox groups, so add custom validation at the form layer. Custom box/tick follows the native `:checked` state. Pass `variant="card"` for tile-style options (box in top-right, optional `icon` on the left, primary-brand border + tint when checked). For a single checkbox, pass a one-element `options` array — `value=[]` is unchecked, `value=[opt.value]` is checked.
|
package/docs/PageHeader.md
CHANGED
|
@@ -90,12 +90,14 @@ import { PageHeader, Button } from "cleanplate";
|
|
|
90
90
|
### Custom title (ReactNode)
|
|
91
91
|
|
|
92
92
|
```jsx
|
|
93
|
+
import { PageHeader, Button, Container, Icon } from "cleanplate";
|
|
94
|
+
|
|
93
95
|
<PageHeader
|
|
94
96
|
title={
|
|
95
|
-
<
|
|
96
|
-
<
|
|
97
|
-
Custom title
|
|
98
|
-
</
|
|
97
|
+
<Container display="flex" align="center" gap="2" padding="0" margin="m-0">
|
|
98
|
+
<Icon name="assignment" size="medium" />
|
|
99
|
+
Custom title with icon
|
|
100
|
+
</Container>
|
|
99
101
|
}
|
|
100
102
|
subtitle="Optional subtitle"
|
|
101
103
|
primaryCta={<Button>Action</Button>}
|
|
@@ -121,14 +123,15 @@ import { PageHeader, Button } from "cleanplate";
|
|
|
121
123
|
## Behavior Notes
|
|
122
124
|
|
|
123
125
|
- **Layout:** Root is a `<header>`. Flex row: left (title + subtitle), right (CTA + more trigger). Right column uses margin-left: auto for right alignment.
|
|
124
|
-
- **Title / subtitle:**
|
|
125
|
-
- **More menu:** When moreMenuItems is set, renders a Dropdown with an icon Button (more_vert) and
|
|
126
|
-
- **Accessibility:** More trigger has aria-expanded and aria-
|
|
126
|
+
- **Title / subtitle:** Always rendered with Typography (`h4` / `p`); strings and custom ReactNode children share the same heading styles and semantics.
|
|
127
|
+
- **More menu:** When moreMenuItems is set, renders a Dropdown with an icon Button (more_vert) and MenuList; each item onClick runs and the dropdown closes. When moreMenuContent is set, that content is shown in the dropdown. Use one or the other.
|
|
128
|
+
- **Accessibility:** More trigger has aria-expanded, aria-haspopup, and aria-label; menu items use MenuList semantics.
|
|
127
129
|
|
|
128
130
|
## Related Components / Links
|
|
129
131
|
|
|
130
132
|
- Button (typically for primaryCta)
|
|
131
133
|
- Typography (used internally for string title and subtitle)
|
|
132
134
|
- Dropdown (used internally for the more menu)
|
|
135
|
+
- MenuList (used internally for moreMenuItems)
|
|
133
136
|
- Icon (more_vert trigger)
|
|
134
137
|
- Container (wrap PageHeader and page content)
|