@dimasbaguspm/versaur 0.0.60 → 0.0.61

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.
@@ -2,7 +2,7 @@ import { j as r } from "./jsx-runtime-C5mzlN2N.js";
2
2
  import g, { useState as y, useEffect as v, createContext as V, useContext as T, forwardRef as p, useRef as S, useId as k, useMemo as _, cloneElement as $ } from "react";
3
3
  import { c as h, a as u } from "./index-BDtz_hQY.js";
4
4
  import { XIcon as R } from "lucide-react";
5
- import { n as D, l as H, H as G, t as U } from "./image-rectangle-CCvXv24a.js";
5
+ import { p as D, l as H, H as G, v as U } from "./image-rectangle-CLLXF8w_.js";
6
6
  import "./snackbar-CTq4MLir.js";
7
7
  import X from "react-dom";
8
8
  function q() {
@@ -2,7 +2,7 @@ import { j as s } from "./jsx-runtime-C5mzlN2N.js";
2
2
  import * as j from "react";
3
3
  import { forwardRef as l, createContext as S, useContext as C, useState as w } from "react";
4
4
  import { c as n, a as d } from "./index-BDtz_hQY.js";
5
- import { n as x, I as N } from "./image-rectangle-CCvXv24a.js";
5
+ import { p as x, I as N } from "./image-rectangle-CLLXF8w_.js";
6
6
  import "./snackbar-CTq4MLir.js";
7
7
  import { L as V } from "./skeleton-BRwIW26B.js";
8
8
  import { ChevronDown as z, ChevronRight as B, ChevronLeft as H } from "lucide-react";
@@ -1,2 +1,2 @@
1
1
  export { TextAreaInput } from './textarea-input';
2
- export type { TextAreaInputProps } from './types';
2
+ export type { TextAreaInputProps, FormatType, FormatState } from './types';
@@ -0,0 +1,53 @@
1
+ import { default as React } from 'react';
2
+ import { FormatType } from './types';
3
+ import { IconProps } from '../../primitive/icon';
4
+ /**
5
+ * Props for the TextAreaInputToolbarButton component
6
+ */
7
+ export interface TextAreaInputToolbarButtonProps {
8
+ /**
9
+ * The format type this button applies
10
+ */
11
+ format: FormatType;
12
+ /**
13
+ * Whether this format is currently active
14
+ */
15
+ isActive: boolean;
16
+ /**
17
+ * Icon component to render
18
+ */
19
+ icon: IconProps['as'];
20
+ /**
21
+ * Accessible label for the button
22
+ */
23
+ label: string;
24
+ /**
25
+ * Whether the button is disabled
26
+ */
27
+ disabled?: boolean;
28
+ /**
29
+ * Click handler
30
+ */
31
+ onClick: (format: FormatType) => void;
32
+ }
33
+ /**
34
+ * Individual toolbar button for formatting actions
35
+ */
36
+ export declare const TextAreaInputToolbarButton: React.ForwardRefExoticComponent<TextAreaInputToolbarButtonProps & React.RefAttributes<HTMLButtonElement>>;
37
+ /**
38
+ * Props for the TextAreaInputToolbar component
39
+ */
40
+ export interface TextAreaInputToolbarProps {
41
+ /**
42
+ * Child toolbar buttons
43
+ */
44
+ children: React.ReactNode;
45
+ /**
46
+ * Additional CSS classes
47
+ */
48
+ className?: string;
49
+ }
50
+ /**
51
+ * Container for formatting toolbar buttons
52
+ */
53
+ export declare const TextAreaInputToolbar: React.ForwardRefExoticComponent<TextAreaInputToolbarProps & React.RefAttributes<HTMLDivElement>>;
@@ -5,6 +5,7 @@ import { TextAreaInputProps } from './types';
5
5
  *
6
6
  * Uses contentEditable div for robust multi-line text input with better control
7
7
  * Provides error states, disabled, and readOnly support
8
+ * Supports rich text formatting with an optional toolbar
8
9
  * Follows browser standards and accessibility best practices
9
10
  */
10
11
  export declare const TextAreaInput: React.ForwardRefExoticComponent<TextAreaInputProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,4 +1,23 @@
1
1
  import { HTMLAttributes, ReactNode } from 'react';
2
+ /**
3
+ * Available formatting options for rich text editing
4
+ */
5
+ export type FormatType = 'bold' | 'italic' | 'underline' | 'strikethrough' | 'h1' | 'h2' | 'h3' | 'orderedList' | 'unorderedList' | 'link';
6
+ /**
7
+ * State of active formats in the current selection
8
+ */
9
+ export interface FormatState {
10
+ bold: boolean;
11
+ italic: boolean;
12
+ underline: boolean;
13
+ strikethrough: boolean;
14
+ h1: boolean;
15
+ h2: boolean;
16
+ h3: boolean;
17
+ orderedList: boolean;
18
+ unorderedList: boolean;
19
+ link: boolean;
20
+ }
2
21
  /**
3
22
  * Props for the TextAreaInput component
4
23
  */
@@ -52,4 +71,13 @@ export interface TextAreaInputProps extends Omit<HTMLAttributes<HTMLDivElement>,
52
71
  * Whether the textarea is required
53
72
  */
54
73
  required?: boolean;
74
+ /**
75
+ * Whether to show the formatting toolbar
76
+ * @default false
77
+ */
78
+ showToolbar?: boolean;
79
+ /**
80
+ * Allowed formatting options (if not specified, all are allowed)
81
+ */
82
+ allowedFormats?: FormatType[];
55
83
  }
@@ -0,0 +1,21 @@
1
+ import { FormatType } from './types';
2
+ /**
3
+ * Custom hook for managing rich text formatting in TextAreaInput
4
+ *
5
+ * Handles toolbar state, format application, and selection tracking
6
+ */
7
+ export declare const useTextAreaFormatting: (enabled: boolean, contentRef: React.RefObject<HTMLDivElement | null>) => {
8
+ formatState: {
9
+ bold: boolean;
10
+ italic: boolean;
11
+ underline: boolean;
12
+ strikethrough: boolean;
13
+ h1: boolean;
14
+ h2: boolean;
15
+ h3: boolean;
16
+ orderedList: boolean;
17
+ unorderedList: boolean;
18
+ link: boolean;
19
+ };
20
+ handleFormatClick: (format: FormatType) => void;
21
+ };
@@ -0,0 +1,10 @@
1
+ import { default as React } from 'react';
2
+ import { FormattedTextProps } from './types';
3
+ /**
4
+ * FormattedText component for Versaur UI
5
+ *
6
+ * Displays rich HTML content with consistent formatting styles
7
+ * Matches the styling used in TextAreaInput with toolbar formatting
8
+ * Should be used with sanitized HTML content to prevent XSS attacks
9
+ */
10
+ export declare const FormattedText: React.ForwardRefExoticComponent<FormattedTextProps & React.RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,3 @@
1
+ export { FormattedText } from './formatted-text';
2
+ export { formattedContentStyles } from './helpers';
3
+ export type { FormattedTextProps } from './types';
@@ -0,0 +1,19 @@
1
+ import { HTMLAttributes } from 'react';
2
+ /**
3
+ * Props for the FormattedText component
4
+ */
5
+ export interface FormattedTextProps extends HTMLAttributes<HTMLDivElement> {
6
+ /**
7
+ * The HTML content to display (should be sanitized if from user input)
8
+ */
9
+ content: string;
10
+ /**
11
+ * Whether to allow the content to be scrollable
12
+ * @default false
13
+ */
14
+ scrollable?: boolean;
15
+ /**
16
+ * Maximum height for scrollable content (in rem units)
17
+ */
18
+ maxHeight?: number;
19
+ }
@@ -14,6 +14,7 @@ export * from './button-menu-icon';
14
14
  export * from './button-icon';
15
15
  export * from './card';
16
16
  export * from './filter-chip';
17
+ export * from './formatted-text';
17
18
  export * from './heading';
18
19
  export * from './hr';
19
20
  export * from './icon';
@@ -59,6 +59,8 @@ const symbolToSubpath = {
59
59
  "ButtonMenuIcon": "primitive",
60
60
  "Card": "primitive",
61
61
  "FilterChip": "primitive",
62
+ "FormattedText": "primitive",
63
+ "formattedContentStyles": "primitive",
62
64
  "Heading": "primitive",
63
65
  "Hr": "primitive",
64
66
  "Icon": "primitive",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimasbaguspm/versaur",
3
- "version": "0.0.60",
3
+ "version": "0.0.61",
4
4
  "description": "React UI library with Tailwind CSS",
5
5
  "author": "Dimas Bagus Prayogo Mukti<dimas.bagus.pm@gmail.com>",
6
6
  "license": "MIT",