@alixpartners/ui-components 2.5.1 → 2.5.2

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.
@@ -8,6 +8,7 @@ type RadioGroupProps = {
8
8
  ariaLabel?: string;
9
9
  disabled?: boolean;
10
10
  children?: ReactNode;
11
+ orientation?: 'vertical' | 'horizontal';
11
12
  } & DataAttributes & InteractiveEventHandlers;
12
13
  /**
13
14
  * RadioGroup is used to group related radio options together, allowing users to select one option from a set of mutually exclusive choices.
@@ -18,7 +19,8 @@ type RadioGroupProps = {
18
19
  * @param {string} [props.ariaLabel] - Accessibility label for screen readers to describe the radio group
19
20
  * @param {boolean} [props.disabled] - Whether the radio group is disabled (defaults to false)
20
21
  * @param {ReactNode} [props.children] - Radio options to be rendered within the group
22
+ * @param {'vertical' | 'horizontal'} [props.orientation='vertical'] - Layout direction of the radio buttons
21
23
  * @returns {JSX.Element} The rendered RadioGroup component
22
24
  */
23
- export default function RadioGroup({ value, ariaLabel, onChange, disabled, children, className, ...props }: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
25
+ export default function RadioGroup({ value, ariaLabel, onChange, disabled, children, className, orientation, ...props }: RadioGroupProps): import("react/jsx-runtime").JSX.Element;
24
26
  export {};
@@ -1,25 +1,27 @@
1
- import { jsx as _ } from "react/jsx-runtime";
1
+ import { jsx as n } from "react/jsx-runtime";
2
2
  import { c as p } from "../../clsx-OuTLNxxd.js";
3
3
  import { useState as f } from "react";
4
- import { R as n } from "../../index-CpsmI33B.js";
5
- import '../../assets/RadioGroup.css';const R = "RadioGroup-module__root___ewZw-", b = "RadioGroup-module__disabled___n-nfI", s = {
6
- root: R,
7
- disabled: b
4
+ import { R } from "../../index-CpsmI33B.js";
5
+ import '../../assets/RadioGroup.css';const z = "RadioGroup-module__root___ewZw-", b = "RadioGroup-module__horizontal___QsBvv", h = "RadioGroup-module__disabled___n-nfI", t = {
6
+ root: z,
7
+ horizontal: b,
8
+ disabled: h
8
9
  };
9
- function S({
10
- value: a,
11
- ariaLabel: l,
10
+ function w({
11
+ value: r,
12
+ ariaLabel: s,
12
13
  onChange: o,
13
14
  disabled: e = !1,
14
- children: r,
15
- className: d,
15
+ children: d,
16
+ className: i,
17
+ orientation: l = "vertical",
16
18
  ...u
17
19
  }) {
18
- const [i, c] = f(a), m = (t) => {
19
- c(t), o == null || o(t);
20
+ const [_, c] = f(r), m = (a) => {
21
+ c(a), o == null || o(a);
20
22
  };
21
- return /* @__PURE__ */ _(n, { className: p(s.root, e && s.disabled, d), value: i, "aria-label": l, onValueChange: m, disabled: e, loop: !0, ...u, children: r });
23
+ return /* @__PURE__ */ n(R, { className: p(t.root, e && t.disabled, l === "horizontal" && t.horizontal, i), value: _, "aria-label": s, onValueChange: m, disabled: e, orientation: l, loop: !0, ...u, children: d });
22
24
  }
23
25
  export {
24
- S as default
26
+ w as default
25
27
  };
@@ -68,6 +68,14 @@ r("RadioGroup", () => {
68
68
  i(/* @__PURE__ */ o(d, { disabled: !1, children: /* @__PURE__ */ o(t, { label: "Option 1", value: "option1" }) }));
69
69
  const e = a.getByRole("radiogroup");
70
70
  n(e.className).not.toContain("disabled");
71
+ }), l("should apply horizontal class when orientation is horizontal", () => {
72
+ i(/* @__PURE__ */ o(d, { orientation: "horizontal", children: /* @__PURE__ */ o(t, { label: "Option 1", value: "option1" }) }));
73
+ const e = a.getByTestId("radio-group");
74
+ n(e.className).toContain("horizontal");
75
+ }), l("should not apply horizontal class by default", () => {
76
+ i(/* @__PURE__ */ o(d, { children: /* @__PURE__ */ o(t, { label: "Option 1", value: "option1" }) }));
77
+ const e = a.getByTestId("radio-group");
78
+ n(e.className).not.toContain("horizontal");
71
79
  });
72
80
  }), r("Empty String Values", () => {
73
81
  l("should handle empty string values", () => {
@@ -0,0 +1,26 @@
1
+ import { RichTextBlockType, RichTextDocumentModel } from './RichTextEditor.model';
2
+ type ToolbarLayout = 'inline' | 'stacked';
3
+ type FormatOption = {
4
+ label: string;
5
+ value: RichTextBlockType;
6
+ };
7
+ type RichTextEditorProps = {
8
+ className?: string;
9
+ label?: string;
10
+ required?: boolean;
11
+ value?: string;
12
+ placeholder?: string;
13
+ disabled?: boolean;
14
+ toolbarLayout?: ToolbarLayout;
15
+ showToolbar?: boolean;
16
+ showWordCount?: boolean;
17
+ maxWords?: number;
18
+ resizable?: boolean;
19
+ rows?: number;
20
+ tooltipEnabled?: boolean;
21
+ formatOptions?: FormatOption[];
22
+ onChange?: (value: string) => void;
23
+ onModelChange?: (model: RichTextDocumentModel) => void;
24
+ };
25
+ export default function RichTextEditor({ className, label, required, value, placeholder, disabled, toolbarLayout, showToolbar, showWordCount, maxWords, resizable, rows, tooltipEnabled, formatOptions, onChange, onModelChange, }: RichTextEditorProps): import("react/jsx-runtime").JSX.Element;
26
+ export {};
@@ -0,0 +1,10 @@
1
+ import "react/jsx-runtime";
2
+ import "../../clsx-OuTLNxxd.js";
3
+ import "react";
4
+ import "../Icon/Icon.js";
5
+ import "../Tooltip/Tooltip.js";
6
+ import { R as f } from "../../RichTextEditor-CHGQT1Qj.js";
7
+ import "../../index-DZ4Gof57.js";
8
+ export {
9
+ f as default
10
+ };
@@ -0,0 +1,12 @@
1
+ export type RichTextBlockType = 'paragraph' | 'heading1' | 'heading2' | 'heading3' | 'heading4' | 'preformatted' | 'unordered-list' | 'ordered-list';
2
+ export type RichTextBlockNode = {
3
+ type: RichTextBlockType;
4
+ html: string;
5
+ align?: 'left' | 'center' | 'right' | 'justify';
6
+ };
7
+ export type RichTextDocumentModel = {
8
+ blocks: RichTextBlockNode[];
9
+ };
10
+ export declare function createModelFromHtml(html: string): RichTextDocumentModel;
11
+ export declare function renderModelToHtml(model: RichTextDocumentModel): string;
12
+ export declare function getWordCountFromModel(model: RichTextDocumentModel): number;
@@ -0,0 +1,91 @@
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { d, i as r, r as a, g as t, s as e, f as i, w as y, v as b } from "../../vi.bdSIJ99Y-017e_Pkz.js";
3
+ import { s as c, R as n } from "../../RichTextEditor-CHGQT1Qj.js";
4
+ d("RichTextEditor", () => {
5
+ d("Rendering", () => {
6
+ r("renders label and required marker", () => {
7
+ a(/* @__PURE__ */ o(n, { label: "Body", required: !0 })), t(e.getByTestId("rte-label")).toHaveTextContent("Body"), t(e.getByTestId("rte-required")).toHaveTextContent("*");
8
+ }), r("does not render label when omitted", () => {
9
+ a(/* @__PURE__ */ o(n, {})), t(e.queryByTestId("rte-label")).not.toBeInTheDocument();
10
+ }), r("shows toolbar by default", () => {
11
+ a(/* @__PURE__ */ o(n, { label: "Body" })), t(e.getByTestId("rte-toolbar")).toBeInTheDocument();
12
+ }), r("hides toolbar when showToolbar is false", () => {
13
+ a(/* @__PURE__ */ o(n, { label: "Body", showToolbar: !1 })), t(e.queryByTestId("rte-toolbar")).not.toBeInTheDocument();
14
+ }), r("hides word count when showWordCount is false", () => {
15
+ a(/* @__PURE__ */ o(n, { label: "Body", showWordCount: !1 })), t(e.queryByTestId("rte-word-count")).not.toBeInTheDocument();
16
+ }), r("places word counter inside the same frame as the editor", () => {
17
+ a(/* @__PURE__ */ o(n, { label: "Body" }));
18
+ const s = e.getByTestId("rte-editor"), l = e.getByTestId("rte-word-count");
19
+ t(l.parentElement).toBe(s.parentElement);
20
+ }), r("applies stacked toolbar class when toolbarLayout is stacked", () => {
21
+ a(/* @__PURE__ */ o(n, { label: "Body", toolbarLayout: "stacked" }));
22
+ const s = e.getByTestId("rte-toolbar");
23
+ t(s.className).toContain(c.toolbarStacked);
24
+ }), r("renders two toolbar rows when stacked", () => {
25
+ a(/* @__PURE__ */ o(n, { label: "Body", toolbarLayout: "stacked" }));
26
+ const l = e.getByTestId("rte-toolbar").querySelectorAll(`.${c.toolbarRow}`);
27
+ t(l.length).toBe(2);
28
+ }), r("renders one toolbar row when inline", () => {
29
+ a(/* @__PURE__ */ o(n, { label: "Body", toolbarLayout: "inline" }));
30
+ const l = e.getByTestId("rte-toolbar").querySelectorAll(`.${c.toolbarRow}`);
31
+ t(l.length).toBe(1);
32
+ });
33
+ }), d("Toolbar actions", () => {
34
+ r("does not render justify or numbered list actions", () => {
35
+ a(/* @__PURE__ */ o(n, { label: "Body" })), t(e.queryByTestId("rte-action-align-justify")).not.toBeInTheDocument(), t(e.queryByTestId("rte-action-numbered")).not.toBeInTheDocument();
36
+ }), r("renders bold, align, list, and link actions", () => {
37
+ a(/* @__PURE__ */ o(n, { label: "Body" })), t(e.getByTestId("rte-action-bold")).toBeInTheDocument(), t(e.getByTestId("rte-action-align-left")).toBeInTheDocument(), t(e.getByTestId("rte-action-bulleted")).toBeInTheDocument(), t(e.getByTestId("rte-action-insert-link")).toBeInTheDocument();
38
+ });
39
+ }), d("Format dropdown", () => {
40
+ r("opens format menu and shows default format options", async () => {
41
+ a(/* @__PURE__ */ o(n, { label: "Body" })), i.click(e.getByTestId("rte-format-select")), await y(() => {
42
+ t(e.getByTestId("rte-format-menu")).toBeInTheDocument();
43
+ }), t(e.getByTestId("rte-format-option-paragraph")).toBeInTheDocument(), t(e.getByTestId("rte-format-option-heading1")).toBeInTheDocument();
44
+ }), r("uses custom format option labels", async () => {
45
+ a(/* @__PURE__ */ o(n, { label: "Body", formatOptions: [{
46
+ label: "Custom block",
47
+ value: "paragraph"
48
+ }] })), i.click(e.getByTestId("rte-format-select")), await y(() => {
49
+ t(e.getByTestId("rte-format-menu")).toBeInTheDocument();
50
+ }), t(e.getByTestId("rte-format-option-paragraph")).toHaveTextContent("Custom block");
51
+ });
52
+ }), d("Word count", () => {
53
+ r("shows word count and updates it", () => {
54
+ a(/* @__PURE__ */ o(n, { label: "Body", value: "<p>Hello world</p>", maxWords: 8 })), t(e.getByTestId("rte-word-count")).toHaveTextContent("2/8");
55
+ const s = e.getByTestId("rte-editor");
56
+ i.input(s, {
57
+ target: {
58
+ innerHTML: "<p>Hello world again now</p>"
59
+ }
60
+ }), t(e.getByTestId("rte-word-count")).toHaveTextContent("4/8");
61
+ });
62
+ }), d("Callbacks and editor props", () => {
63
+ r("fires onChange with rendered html", () => {
64
+ const s = b.fn();
65
+ a(/* @__PURE__ */ o(n, { label: "Body", onChange: s }));
66
+ const l = e.getByTestId("rte-editor");
67
+ i.input(l, {
68
+ target: {
69
+ innerHTML: "<p>Test value</p>"
70
+ }
71
+ }), t(s).toHaveBeenCalled(), t(s.mock.calls[0][0]).toContain("<p>Test value</p>");
72
+ }), r("fires onModelChange when content changes", () => {
73
+ const s = b.fn();
74
+ a(/* @__PURE__ */ o(n, { label: "Body", onModelChange: s }));
75
+ const l = e.getByTestId("rte-editor");
76
+ i.input(l, {
77
+ target: {
78
+ innerHTML: "<p>Model test</p>"
79
+ }
80
+ }), t(s).toHaveBeenCalled(), t(s.mock.calls[0][0]).toMatchObject({
81
+ blocks: t.any(Array)
82
+ });
83
+ }), r("sets resize none when resizable is false", () => {
84
+ a(/* @__PURE__ */ o(n, { label: "Body", resizable: !1 })), t(e.getByTestId("rte-editor")).toHaveStyle({
85
+ resize: "none"
86
+ });
87
+ }), r("sets contentEditable false when disabled", () => {
88
+ a(/* @__PURE__ */ o(n, { label: "Body", disabled: !0 })), t(e.getByTestId("rte-editor")).toHaveAttribute("contenteditable", "false");
89
+ });
90
+ });
91
+ });
package/dist/main.d.ts CHANGED
@@ -12,6 +12,7 @@ export { default as Dropdown, type DropdownOption } from './components/Dropdown/
12
12
  export { default as FilePicker, useFilePickerContext, type FilePickerContextValue, } from './components/FilePicker/FilePicker.tsx';
13
13
  export { default as Search } from './components/Search/Search.tsx';
14
14
  export { default as Datepicker } from './components/Datepicker/Datepicker';
15
+ export { default as RichTextEditor } from './components/RichTextEditor/RichTextEditor';
15
16
  export { default as Toast } from './components/Toast/Toast.tsx';
16
17
  export { default as ToastProvider } from './components/ToastProvider/ToastProvider.tsx';
17
18
  export { useToast } from './components/ToastProvider/useToast.ts';
package/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
- import { default as e } from "./components/Button/Button.js";
2
- import { default as t } from "./components/Checkbox/Checkbox.js";
1
+ import { default as r } from "./components/Button/Button.js";
2
+ import { default as e } from "./components/Checkbox/Checkbox.js";
3
3
  import { default as s } from "./components/Icon/Icon.js";
4
4
  import { default as l } from "./components/Input/Input.js";
5
5
  import { default as u } from "./components/Radio/Radio.js";
@@ -7,60 +7,62 @@ import { default as m } from "./components/RadioGroup/RadioGroup.js";
7
7
  import { default as n } from "./components/Textarea/Textarea.js";
8
8
  import { default as c } from "./components/Toggle/Toggle.js";
9
9
  import { default as D } from "./components/Banner/Banner.js";
10
- import { default as k } from "./components/Ghost/Ghost.js";
11
- import { default as h } from "./components/Dropdown/Dropdown.js";
12
- import { default as C, useFilePickerContext as F } from "./components/FilePicker/FilePicker.js";
13
- import { default as P } from "./components/Search/Search.js";
14
- import { default as G } from "./components/Datepicker/Datepicker.js";
15
- import { default as R } from "./components/Toast/Toast.js";
16
- import { T as w } from "./ToastProvider-D5LImZ-Q.js";
17
- import { u as L } from "./useToast-Cz5MGKnw.js";
18
- import { default as q } from "./components/Creatable/Creatable.js";
19
- import { default as z } from "./components/SplitButton/SplitButton.js";
20
- import { default as H } from "./components/DragAndDrop/DragAndDrop.js";
21
- import { c as K, d as M } from "./DragAndDrop.utils-D3xTV9EK.js";
22
- import { default as Q } from "./components/Tab/Tab.js";
23
- import { default as W } from "./components/TabNavigation/TabNavigation.js";
24
- import { default as Y } from "./components/Dialog/Dialog.js";
25
- import { default as _ } from "./components/TagsFields/TagsFields.js";
26
- import { default as oo } from "./components/NavBar/NavBar.js";
10
+ import { default as h } from "./components/Ghost/Ghost.js";
11
+ import { default as B } from "./components/Dropdown/Dropdown.js";
12
+ import { default as v, useFilePickerContext as C } from "./components/FilePicker/FilePicker.js";
13
+ import { default as I } from "./components/Search/Search.js";
14
+ import { default as S } from "./components/Datepicker/Datepicker.js";
15
+ import { R as N } from "./RichTextEditor-CHGQT1Qj.js";
16
+ import { default as w } from "./components/Toast/Toast.js";
17
+ import { T as E } from "./ToastProvider-D5LImZ-Q.js";
18
+ import { u as j } from "./useToast-Cz5MGKnw.js";
19
+ import { default as y } from "./components/Creatable/Creatable.js";
20
+ import { default as H } from "./components/SplitButton/SplitButton.js";
21
+ import { default as K } from "./components/DragAndDrop/DragAndDrop.js";
22
+ import { c as O, d as Q } from "./DragAndDrop.utils-D3xTV9EK.js";
23
+ import { default as W } from "./components/Tab/Tab.js";
24
+ import { default as Y } from "./components/TabNavigation/TabNavigation.js";
25
+ import { default as _ } from "./components/Dialog/Dialog.js";
26
+ import { default as oo } from "./components/TagsFields/TagsFields.js";
27
+ import { default as ro } from "./components/NavBar/NavBar.js";
27
28
  import { default as eo } from "./components/Tag/Tag.js";
28
- import { default as to } from "./components/Tooltip/Tooltip.js";
29
- import { default as so } from "./components/Spinner/Spinner.js";
30
- import { default as lo } from "./components/Illustration/Illustration.js";
31
- import { a as xo } from "./ap-logos-CwA4O8B7.js";
29
+ import { default as so } from "./components/Tooltip/Tooltip.js";
30
+ import { default as lo } from "./components/Spinner/Spinner.js";
31
+ import { default as xo } from "./components/Illustration/Illustration.js";
32
+ import { a as io } from "./ap-logos-CwA4O8B7.js";
32
33
  import './assets/main.css';export {
33
34
  D as Banner,
34
- e as Button,
35
- t as Checkbox,
36
- q as Creatable,
37
- G as Datepicker,
38
- Y as Dialog,
39
- H as DragAndDrop,
40
- h as Dropdown,
41
- C as FilePicker,
42
- k as Ghost,
35
+ r as Button,
36
+ e as Checkbox,
37
+ y as Creatable,
38
+ S as Datepicker,
39
+ _ as Dialog,
40
+ K as DragAndDrop,
41
+ B as Dropdown,
42
+ v as FilePicker,
43
+ h as Ghost,
43
44
  s as Icon,
44
- lo as Illustration,
45
+ xo as Illustration,
45
46
  l as Input,
46
- oo as NavBar,
47
+ ro as NavBar,
47
48
  u as Radio,
48
49
  m as RadioGroup,
49
- P as Search,
50
- so as Spinner,
51
- z as SplitButton,
52
- Q as Tab,
53
- W as TabNavigation,
50
+ N as RichTextEditor,
51
+ I as Search,
52
+ lo as Spinner,
53
+ H as SplitButton,
54
+ W as Tab,
55
+ Y as TabNavigation,
54
56
  eo as Tag,
55
- _ as TagsFields,
57
+ oo as TagsFields,
56
58
  n as Textarea,
57
- R as Toast,
58
- w as ToastProvider,
59
+ w as Toast,
60
+ E as ToastProvider,
59
61
  c as Toggle,
60
- to as Tooltip,
61
- xo as apLogos,
62
- K as composeValidators,
63
- M as defaultValidator,
64
- F as useFilePickerContext,
65
- L as useToast
62
+ so as Tooltip,
63
+ io as apLogos,
64
+ O as composeValidators,
65
+ Q as defaultValidator,
66
+ C as useFilePickerContext,
67
+ j as useToast
66
68
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alixpartners/ui-components",
3
- "version": "2.5.1",
3
+ "version": "2.5.2",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"