@eschoolbase/client-ui 0.2.1 → 0.3.1

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.
@@ -0,0 +1,3 @@
1
+ import type { TextareaProps } from './Textarea.types';
2
+ /** `Textarea type="rich"`: a contenteditable editor with a small formatting toolbar. The value is sanitized HTML. */
3
+ export declare function RichTextControl({ id, required, disabled, error, 'aria-describedby': ariaDescribedBy, 'aria-label': ariaLabel, rows, resize, readOnly, className, name, placeholder, value, defaultValue, onValueChange, }: Omit<TextareaProps, 'label' | 'helperText' | 'type'>): import("react").JSX.Element;
@@ -1,3 +1,6 @@
1
1
  import type { TextareaProps } from './Textarea.types';
2
- /** Multi-line text input with the same label, helper and error handling as `Input`. */
2
+ /**
3
+ * Multi-line text input with the same label, helper and error handling as `Input`.
4
+ * Use `type="rich"` for a formatting editor that works with HTML.
5
+ */
3
6
  export declare const Textarea: import("react").ForwardRefExoticComponent<TextareaProps & import("react").RefAttributes<HTMLTextAreaElement>>;
@@ -1,5 +1,6 @@
1
1
  import type { ReactNode, TextareaHTMLAttributes } from 'react';
2
2
  export type TextareaResize = 'none' | 'vertical' | 'horizontal' | 'both';
3
+ export type TextareaKind = 'text' | 'rich';
3
4
  export interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElement> {
4
5
  label?: ReactNode;
5
6
  helperText?: ReactNode;
@@ -9,4 +10,12 @@ export interface TextareaProps extends TextareaHTMLAttributes<HTMLTextAreaElemen
9
10
  rows?: number;
10
11
  /** Which directions the user can resize. Defaults to `vertical`. */
11
12
  resize?: TextareaResize;
13
+ /**
14
+ * `text` (default) is a plain textarea. `rich` is a formatting editor (bold, italic, underline, lists,
15
+ * links): `value` / `defaultValue` are HTML strings (sanitized), changes arrive through `onValueChange`
16
+ * as HTML, and `name` submits the HTML in a hidden input. `ref` and `onChange` are not used for `rich`.
17
+ */
18
+ type?: TextareaKind;
19
+ /** `type="rich"` only: called with the sanitized HTML (an empty string when the editor is empty). */
20
+ onValueChange?: (html: string) => void;
12
21
  }
@@ -1,2 +1,2 @@
1
1
  export { Textarea } from './Textarea';
2
- export type { TextareaProps, TextareaResize } from './Textarea.types';
2
+ export type { TextareaKind, TextareaProps, TextareaResize } from './Textarea.types';
@@ -0,0 +1,4 @@
1
+ /** Reduces HTML to a small allowlist of formatting tags, with no attributes except safe links. */
2
+ export declare function sanitizeHtml(html: string): string;
3
+ /** True when the HTML has no text and no list structure worth keeping. */
4
+ export declare function isEmptyHtml(html: string): boolean;