@alixpartners/ui-components 2.5.3 → 2.5.6
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/README.md +97 -97
- package/dist/CorusHeader.module-xOp6ZX_M.js +35 -0
- package/dist/RichTextEditor-cvtLFe4t.js +443 -0
- package/dist/ap-logos-2dYMA1l5.js +4 -0
- package/dist/assets/CorusHeader.css +1 -0
- package/dist/assets/Input.css +1 -1
- package/dist/assets/RichTextEditor.css +1 -1
- package/dist/assets/SplitButton.css +1 -1
- package/dist/assets/ap-icons-types.d.ts +1 -1
- package/dist/assets/ap-icons.d.ts +1 -1
- package/dist/assets/ap-logos-types.d.ts +1 -1
- package/dist/assets/ap-logos.d.ts +1 -1
- package/dist/assets/main.css +1 -1
- package/dist/components/Checkbox/Checkbox.js +3 -3
- package/dist/components/CorusHeader/CorusHeader.d.ts +3 -0
- package/dist/components/CorusHeader/CorusHeader.js +66 -0
- package/dist/components/CorusHeader/CorusHeader.types.d.ts +58 -0
- package/dist/components/CorusHeader/DropdownItemContent.d.ts +6 -0
- package/dist/components/CorusHeader/DropdownItemContent.js +17 -0
- package/dist/components/CorusHeader/DropdownMenu.d.ts +6 -0
- package/dist/components/CorusHeader/DropdownMenu.js +26 -0
- package/dist/components/CorusHeader/MegaMenuContent.d.ts +6 -0
- package/dist/components/CorusHeader/MegaMenuContent.js +29 -0
- package/dist/components/CorusHeader/UserProfileIcon.d.ts +3 -0
- package/dist/components/CorusHeader/UserProfileIcon.js +9 -0
- package/dist/components/Creatable/Creatable.js +1 -1
- package/dist/components/Datepicker/Datepicker.js +1 -1
- package/dist/components/Dialog/Dialog.js +5 -5
- package/dist/components/Dropdown/Dropdown.js +1 -1
- package/dist/components/Icons/IconsGallery.js +1 -1
- package/dist/components/Logo/Logo.d.ts +1 -1
- package/dist/components/Logo/Logo.js +12 -6
- package/dist/components/Logos/LogosGallery.js +1 -1
- package/dist/components/NavBar/NavBar.js +50 -352
- package/dist/components/Radio/Radio.js +1 -1
- package/dist/components/RadioGroup/RadioGroup.js +1 -1
- package/dist/components/RichTextEditor/RichTextEditor.d.ts +3 -3
- package/dist/components/RichTextEditor/RichTextEditor.js +2 -2
- package/dist/components/RichTextEditor/RichTextEditor.model.d.ts +1 -1
- package/dist/components/RichTextEditor/RichTextEditor.test.js +76 -59
- package/dist/components/SplitButton/SplitButton.js +3 -3
- package/dist/components/TagsFields/TagsFields.js +1 -1
- package/dist/components/Toggle/Toggle.js +2 -2
- package/dist/components/Tooltip/Tooltip.js +50 -50
- package/dist/{index-7CBv-Jx6.js → index-C2s_VtSb.js} +3 -3
- package/dist/{index-DEphED6n.js → index-C8H9A55g.js} +2 -2
- package/dist/{index-DZ4Gof57.js → index-CCFDXH-J.js} +6 -6
- package/dist/{index-CpsmI33B.js → index-CCnm5-ML.js} +4 -4
- package/dist/{index-Chv2KjIL.js → index-CFqDEbIR.js} +2 -2
- package/dist/{index-BymOxiM6.js → index-CfIcUHKK.js} +1 -1
- package/dist/{index-D34Qo5Qx.js → index-ChQc_Cm6.js} +3 -3
- package/dist/{index-DrR82jOT.js → index-CmGGeUr0.js} +2 -2
- package/dist/index-D_L0ncPJ.js +312 -0
- package/dist/{index-DgdVwltD.js → index-Ii4UOx3H.js} +7 -7
- package/dist/index-Nyh2Wa71.js +27 -0
- package/dist/{index-DM51yNMI.js → index-z_kiwVc3.js} +5 -5
- package/dist/main.d.ts +1 -0
- package/dist/main.js +24 -22
- package/dist/web.config +8 -8
- package/package.json +94 -88
- package/dist/RichTextEditor-CfINW9Xs.js +0 -412
- package/dist/ap-logos-CwA4O8B7.js +0 -4
- package/dist/index-CxAtPSMM.js +0 -27
package/README.md
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
# AlixPartners UI Component Library
|
|
2
|
-
|
|
3
|
-
A modern, reusable component library built with **[ReactJS](https://react.dev/)**.
|
|
4
|
-
|
|
5
|
-
Version **2.0** has been **rebuilt from the ground up** to align with the latest **AlixPartners Design System** and deliver improved developer experience, accessibility, and performance.
|
|
6
|
-
|
|
7
|
-
## ✨ What’s New in 2.0
|
|
8
|
-
|
|
9
|
-
- Completely redesigned architecture with modern build tooling ([Vite](https://vitejs.dev/))
|
|
10
|
-
- Updated design tokens and styles aligned with AlixPartners Design System
|
|
11
|
-
- Improved accessibility (a11y) and semantic HTML usage
|
|
12
|
-
- Streamlined props API for cleaner integration
|
|
13
|
-
- Enhanced Storybook documentation
|
|
14
|
-
- Faster build & development workflows
|
|
15
|
-
|
|
16
|
-
### Version Support
|
|
17
|
-
|
|
18
|
-
- v2.x — Active development (BETA)
|
|
19
|
-
- v1.x — Maintained for legacy projects (no new features, critical fixes only)
|
|
20
|
-
|
|
21
|
-
---
|
|
22
|
-
|
|
23
|
-
## 🚀 Installation
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
npm install @alixpartners/ui-components
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## 🔧 Usage
|
|
30
|
-
|
|
31
|
-
```tsx
|
|
32
|
-
import { YourComponent } from '@alixpartners/ui-components'
|
|
33
|
-
|
|
34
|
-
function App() {
|
|
35
|
-
return <YourComponent />
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## 🧱 Components
|
|
40
|
-
|
|
41
|
-
Explore all available components and documentation in Storybook.
|
|
42
|
-
|
|
43
|
-
To run it locally:
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
npm run storybook
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
|
-
## 📦 Build
|
|
52
|
-
|
|
53
|
-
To bundle the library for publishing:
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
npm run build
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
The output will be in the `dist/` directory.
|
|
60
|
-
|
|
61
|
-
### Usage in projects while developing
|
|
62
|
-
|
|
63
|
-
When working on the library and testing it in another project:
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
# In the component library root:
|
|
67
|
-
npm link
|
|
68
|
-
|
|
69
|
-
# In the consuming project's root:
|
|
70
|
-
npm link alix-partners-react-components-test
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
Then import components using the `alix-partners-react-components-test` import.
|
|
74
|
-
|
|
75
|
-
## 🧪 Testing
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
npm run test
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
#### 🧪 Test Coverage
|
|
82
|
-
|
|
83
|
-
```bash
|
|
84
|
-
npm run coverage
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
## 📚 Publish
|
|
88
|
-
|
|
89
|
-
To publish to npm:
|
|
90
|
-
|
|
91
|
-
1. Bump the version in `package.json`
|
|
92
|
-
2. Create a pull request in Azure DevOps to the `main` branch
|
|
93
|
-
3. This will automatically publish the library to `npm` once approved
|
|
94
|
-
|
|
95
|
-
## 🤝 Contributing
|
|
96
|
-
|
|
97
|
-
The **AlixPartners UI Component Library** is a collaborative, community-driven project where contributions from all team members are encouraged and valued. If you’d like to add new components or improve existing ones, please see the CONTRIBUTING.md file.
|
|
1
|
+
# AlixPartners UI Component Library
|
|
2
|
+
|
|
3
|
+
A modern, reusable component library built with **[ReactJS](https://react.dev/)**.
|
|
4
|
+
|
|
5
|
+
Version **2.0** has been **rebuilt from the ground up** to align with the latest **AlixPartners Design System** and deliver improved developer experience, accessibility, and performance.
|
|
6
|
+
|
|
7
|
+
## ✨ What’s New in 2.0
|
|
8
|
+
|
|
9
|
+
- Completely redesigned architecture with modern build tooling ([Vite](https://vitejs.dev/))
|
|
10
|
+
- Updated design tokens and styles aligned with AlixPartners Design System
|
|
11
|
+
- Improved accessibility (a11y) and semantic HTML usage
|
|
12
|
+
- Streamlined props API for cleaner integration
|
|
13
|
+
- Enhanced Storybook documentation
|
|
14
|
+
- Faster build & development workflows
|
|
15
|
+
|
|
16
|
+
### Version Support
|
|
17
|
+
|
|
18
|
+
- v2.x — Active development (BETA)
|
|
19
|
+
- v1.x — Maintained for legacy projects (no new features, critical fixes only)
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## 🚀 Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install @alixpartners/ui-components
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 🔧 Usage
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { YourComponent } from '@alixpartners/ui-components'
|
|
33
|
+
|
|
34
|
+
function App() {
|
|
35
|
+
return <YourComponent />
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 🧱 Components
|
|
40
|
+
|
|
41
|
+
Explore all available components and documentation in Storybook.
|
|
42
|
+
|
|
43
|
+
To run it locally:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
npm run storybook
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## 📦 Build
|
|
52
|
+
|
|
53
|
+
To bundle the library for publishing:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm run build
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The output will be in the `dist/` directory.
|
|
60
|
+
|
|
61
|
+
### Usage in projects while developing
|
|
62
|
+
|
|
63
|
+
When working on the library and testing it in another project:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# In the component library root:
|
|
67
|
+
npm link
|
|
68
|
+
|
|
69
|
+
# In the consuming project's root:
|
|
70
|
+
npm link alix-partners-react-components-test
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Then import components using the `alix-partners-react-components-test` import.
|
|
74
|
+
|
|
75
|
+
## 🧪 Testing
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
npm run test
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### 🧪 Test Coverage
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npm run coverage
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 📚 Publish
|
|
88
|
+
|
|
89
|
+
To publish to npm:
|
|
90
|
+
|
|
91
|
+
1. Bump the version in `package.json`
|
|
92
|
+
2. Create a pull request in Azure DevOps to the `main` branch
|
|
93
|
+
3. This will automatically publish the library to `npm` once approved
|
|
94
|
+
|
|
95
|
+
## 🤝 Contributing
|
|
96
|
+
|
|
97
|
+
The **AlixPartners UI Component Library** is a collaborative, community-driven project where contributions from all team members are encouraged and valued. If you’d like to add new components or improve existing ones, please see the CONTRIBUTING.md file.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import './assets/CorusHeader.css';const e = {
|
|
2
|
+
"navbar-wrapper": "CorusHeader-module__navbar-wrapper___1KxAb",
|
|
3
|
+
"navbar-container": "CorusHeader-module__navbar-container___E75C0",
|
|
4
|
+
"navbar-logo-container": "CorusHeader-module__navbar-logo-container___va-bi",
|
|
5
|
+
"navbar-logo-link": "CorusHeader-module__navbar-logo-link___c96t1",
|
|
6
|
+
"navbar-project-name": "CorusHeader-module__navbar-project-name___TmX-b",
|
|
7
|
+
"navbar-module-name": "CorusHeader-module__navbar-module-name___GKW5y",
|
|
8
|
+
"navbar-menu": "CorusHeader-module__navbar-menu___t4hvB",
|
|
9
|
+
"navbar-menu-list": "CorusHeader-module__navbar-menu-list___avqIc",
|
|
10
|
+
"navbar-menu-list-item": "CorusHeader-module__navbar-menu-list-item___EvvFr",
|
|
11
|
+
"navbar-menu-list-item-trigger-container": "CorusHeader-module__navbar-menu-list-item-trigger-container___nYo0n",
|
|
12
|
+
"navbar-menu-list-item-action": "CorusHeader-module__navbar-menu-list-item-action___Fd2Kz",
|
|
13
|
+
"navbar-menu-list-item-arrow": "CorusHeader-module__navbar-menu-list-item-arrow___-peqY",
|
|
14
|
+
"navbar-action-button": "CorusHeader-module__navbar-action-button___Db8zx",
|
|
15
|
+
"navbar-menu-additional": "CorusHeader-module__navbar-menu-additional___00q5q",
|
|
16
|
+
"navbar-menu-additional-trigger": "CorusHeader-module__navbar-menu-additional-trigger___HZmWR",
|
|
17
|
+
"navbar-settings-icon": "CorusHeader-module__navbar-settings-icon___TeGCJ",
|
|
18
|
+
"navbar-profile-icon": "CorusHeader-module__navbar-profile-icon___I2WA2",
|
|
19
|
+
"mega-menu-content": "CorusHeader-module__mega-menu-content___W-xjj",
|
|
20
|
+
"mega-menu-column-wrapper": "CorusHeader-module__mega-menu-column-wrapper___1ZgWq",
|
|
21
|
+
"mega-menu-divider": "CorusHeader-module__mega-menu-divider___6nYcz",
|
|
22
|
+
"mega-menu-column": "CorusHeader-module__mega-menu-column___yHh9s",
|
|
23
|
+
"mega-menu-items": "CorusHeader-module__mega-menu-items___hJQSC",
|
|
24
|
+
"mega-menu-heading": "CorusHeader-module__mega-menu-heading___aPj3a",
|
|
25
|
+
"mega-menu-item": "CorusHeader-module__mega-menu-item___WxCN-",
|
|
26
|
+
"mega-menu-item-label": "CorusHeader-module__mega-menu-item-label___TyZiu",
|
|
27
|
+
"mega-menu-item-description": "CorusHeader-module__mega-menu-item-description___e3-s2",
|
|
28
|
+
"dropdown-item-row": "CorusHeader-module__dropdown-item-row___pBKtB",
|
|
29
|
+
"dropdown-item-icon": "CorusHeader-module__dropdown-item-icon___cPSQk",
|
|
30
|
+
"dropdown-item-content": "CorusHeader-module__dropdown-item-content___z4wRj",
|
|
31
|
+
"mega-menu-footer": "CorusHeader-module__mega-menu-footer___sBd8B"
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
e as s
|
|
35
|
+
};
|
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
import { jsxs as c, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { c as b } from "./clsx-OuTLNxxd.js";
|
|
3
|
+
import { useMemo as Ee, useId as ze, useRef as M, useState as u, useEffect as H } from "react";
|
|
4
|
+
import qe from "./components/Dialog/Dialog.js";
|
|
5
|
+
import U from "./components/Icon/Icon.js";
|
|
6
|
+
import ve from "./components/Input/Input.js";
|
|
7
|
+
import G from "./components/Tooltip/Tooltip.js";
|
|
8
|
+
import { R as $e, T as We, P as Ke, C as Ve } from "./index-CCFDXH-J.js";
|
|
9
|
+
import './assets/RichTextEditor.css';const Je = "RichTextEditor-module__container___AplP0", Ze = "RichTextEditor-module__label___vjzs-", Ge = "RichTextEditor-module__required___7duke", Ye = "RichTextEditor-module__frame___7OSyf", Xe = "RichTextEditor-module__frameFocused___GtJ2x", Qe = "RichTextEditor-module__frameDisabled___LubtU", et = "RichTextEditor-module__frameError___sPTiY", tt = "RichTextEditor-module__errorMessage___4VdKj", nt = "RichTextEditor-module__helpers___cpuz6", ot = "RichTextEditor-module__helperText___rFoU0", rt = "RichTextEditor-module__helpLink___7gYcv", it = "RichTextEditor-module__containerDisabled___6h9dd", at = "RichTextEditor-module__containerFullWidth___pOoeL", lt = "RichTextEditor-module__toolbarContent___YXKHD", ct = "RichTextEditor-module__toolbarPanel___OVGHO", st = "RichTextEditor-module__toolbarRow___f0xJR", dt = "RichTextEditor-module__editorBody___f8jPI", ut = "RichTextEditor-module__toolbar___m9-M-", mt = "RichTextEditor-module__toolbarStacked___6rB10", ht = "RichTextEditor-module__actions___ZAK9J", ft = "RichTextEditor-module__toolButton___IT2Kg", _t = "RichTextEditor-module__toolButtonActive___-HvZQ", pt = "RichTextEditor-module__toolIcon___Wndhd", gt = "RichTextEditor-module__formatControl___w4WcA", Tt = "RichTextEditor-module__toolbarLinkSlot___Gu-9l", bt = "RichTextEditor-module__selectTrigger___frv3x", xt = "RichTextEditor-module__selectIconBox___SYdTE", Rt = "RichTextEditor-module__selectTriggerOpen___tk2Pb", Et = "RichTextEditor-module__selectTriggerLabel___FkEv0", vt = "RichTextEditor-module__selectIcon___aJWUk", kt = "RichTextEditor-module__formatMenu___y-uBL", Mt = "RichTextEditor-module__formatMenuOptions___zcdlo", yt = "RichTextEditor-module__formatMenuOption___3ppTs", Ct = "RichTextEditor-module__formatMenuOptionSelected___bq9J9", Lt = "RichTextEditor-module__formatMenuOptionParagraph___4BLds", Ot = "RichTextEditor-module__formatMenuOptionHeading1___H1cKX", Nt = "RichTextEditor-module__formatMenuOptionHeading2___JdixR", Ht = "RichTextEditor-module__formatMenuOptionHeading3___NcwLr", wt = "RichTextEditor-module__formatMenuOptionHeading4___4mLbG", Bt = "RichTextEditor-module__formatMenuOptionPreformatted___cB0Ix", St = "RichTextEditor-module__editor___M32R7", Dt = "RichTextEditor-module__characterCount___gmUzj", It = "RichTextEditor-module__characterCountExceeded___vjIpc", Ft = "RichTextEditor-module__linkDialogForm___vOLO1", t = {
|
|
10
|
+
container: Je,
|
|
11
|
+
label: Ze,
|
|
12
|
+
required: Ge,
|
|
13
|
+
frame: Ye,
|
|
14
|
+
frameFocused: Xe,
|
|
15
|
+
frameDisabled: Qe,
|
|
16
|
+
frameError: et,
|
|
17
|
+
errorMessage: tt,
|
|
18
|
+
helpers: nt,
|
|
19
|
+
helperText: ot,
|
|
20
|
+
helpLink: rt,
|
|
21
|
+
containerDisabled: it,
|
|
22
|
+
containerFullWidth: at,
|
|
23
|
+
toolbarContent: lt,
|
|
24
|
+
toolbarPanel: ct,
|
|
25
|
+
toolbarRow: st,
|
|
26
|
+
editorBody: dt,
|
|
27
|
+
toolbar: ut,
|
|
28
|
+
toolbarStacked: mt,
|
|
29
|
+
actions: ht,
|
|
30
|
+
toolButton: ft,
|
|
31
|
+
toolButtonActive: _t,
|
|
32
|
+
toolIcon: pt,
|
|
33
|
+
formatControl: gt,
|
|
34
|
+
toolbarLinkSlot: Tt,
|
|
35
|
+
selectTrigger: bt,
|
|
36
|
+
selectIconBox: xt,
|
|
37
|
+
selectTriggerOpen: Rt,
|
|
38
|
+
selectTriggerLabel: Et,
|
|
39
|
+
selectIcon: vt,
|
|
40
|
+
formatMenu: kt,
|
|
41
|
+
formatMenuOptions: Mt,
|
|
42
|
+
formatMenuOption: yt,
|
|
43
|
+
formatMenuOptionSelected: Ct,
|
|
44
|
+
formatMenuOptionParagraph: Lt,
|
|
45
|
+
formatMenuOptionHeading1: Ot,
|
|
46
|
+
formatMenuOptionHeading2: Nt,
|
|
47
|
+
formatMenuOptionHeading3: Ht,
|
|
48
|
+
formatMenuOptionHeading4: wt,
|
|
49
|
+
formatMenuOptionPreformatted: Bt,
|
|
50
|
+
editor: St,
|
|
51
|
+
characterCount: Dt,
|
|
52
|
+
characterCountExceeded: It,
|
|
53
|
+
linkDialogForm: Ft
|
|
54
|
+
}, At = {
|
|
55
|
+
paragraph: "p",
|
|
56
|
+
heading1: "h1",
|
|
57
|
+
heading2: "h2",
|
|
58
|
+
heading3: "h3",
|
|
59
|
+
heading4: "h4",
|
|
60
|
+
preformatted: "pre",
|
|
61
|
+
"unordered-list": "ul",
|
|
62
|
+
"ordered-list": "ol"
|
|
63
|
+
};
|
|
64
|
+
function Me(r) {
|
|
65
|
+
return r.trim().length > 0 ? r : "<br>";
|
|
66
|
+
}
|
|
67
|
+
function Pt(r) {
|
|
68
|
+
switch (r.toLowerCase()) {
|
|
69
|
+
case "h1":
|
|
70
|
+
return "heading1";
|
|
71
|
+
case "h2":
|
|
72
|
+
return "heading2";
|
|
73
|
+
case "h3":
|
|
74
|
+
return "heading3";
|
|
75
|
+
case "h4":
|
|
76
|
+
return "heading4";
|
|
77
|
+
case "pre":
|
|
78
|
+
return "preformatted";
|
|
79
|
+
case "ul":
|
|
80
|
+
return "unordered-list";
|
|
81
|
+
case "ol":
|
|
82
|
+
return "ordered-list";
|
|
83
|
+
case "p":
|
|
84
|
+
default:
|
|
85
|
+
return "paragraph";
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function Y(r) {
|
|
89
|
+
if (!r.trim())
|
|
90
|
+
return {
|
|
91
|
+
blocks: [{
|
|
92
|
+
type: "paragraph",
|
|
93
|
+
html: "<br>"
|
|
94
|
+
}]
|
|
95
|
+
};
|
|
96
|
+
const f = new DOMParser().parseFromString(r, "text/html"), p = Array.from(f.body.childNodes), x = [];
|
|
97
|
+
return p.forEach((a) => {
|
|
98
|
+
var E;
|
|
99
|
+
if (a.nodeType === Node.TEXT_NODE) {
|
|
100
|
+
const y = (E = a.textContent) == null ? void 0 : E.trim();
|
|
101
|
+
y && x.push({
|
|
102
|
+
type: "paragraph",
|
|
103
|
+
html: y
|
|
104
|
+
});
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (a.nodeType !== Node.ELEMENT_NODE)
|
|
108
|
+
return;
|
|
109
|
+
const m = a, R = m.style.textAlign;
|
|
110
|
+
x.push({
|
|
111
|
+
type: Pt(m.tagName),
|
|
112
|
+
html: Me(m.innerHTML),
|
|
113
|
+
align: R || void 0
|
|
114
|
+
});
|
|
115
|
+
}), {
|
|
116
|
+
blocks: x.length > 0 ? x : [{
|
|
117
|
+
type: "paragraph",
|
|
118
|
+
html: "<br>"
|
|
119
|
+
}]
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function ke(r) {
|
|
123
|
+
return r.blocks.length ? r.blocks.map((s) => {
|
|
124
|
+
const f = At[s.type], p = s.align ? ` style="text-align:${s.align}"` : "";
|
|
125
|
+
return `<${f}${p}>${Me(s.html)}</${f}>`;
|
|
126
|
+
}).join("") : "<p><br></p>";
|
|
127
|
+
}
|
|
128
|
+
function Ut(r) {
|
|
129
|
+
return r.blocks.map((f) => f.html.replace(/<[^>]+>/g, "")).join("").length;
|
|
130
|
+
}
|
|
131
|
+
const jt = ["bold", "italic", "underline", "align-left", "align-center", "align-right", "bulleted", "link", "format"], zt = [{
|
|
132
|
+
label: "Paragraph",
|
|
133
|
+
value: "paragraph"
|
|
134
|
+
}, {
|
|
135
|
+
label: "Heading 1",
|
|
136
|
+
value: "heading1"
|
|
137
|
+
}, {
|
|
138
|
+
label: "Heading 2",
|
|
139
|
+
value: "heading2"
|
|
140
|
+
}, {
|
|
141
|
+
label: "Heading 3",
|
|
142
|
+
value: "heading3"
|
|
143
|
+
}, {
|
|
144
|
+
label: "Heading 4",
|
|
145
|
+
value: "heading4"
|
|
146
|
+
}, {
|
|
147
|
+
label: "Preformatted",
|
|
148
|
+
value: "preformatted"
|
|
149
|
+
}], qt = {
|
|
150
|
+
paragraph: "P",
|
|
151
|
+
heading1: "H1",
|
|
152
|
+
heading2: "H2",
|
|
153
|
+
heading3: "H3",
|
|
154
|
+
heading4: "H4",
|
|
155
|
+
preformatted: "PRE",
|
|
156
|
+
"unordered-list": "UL",
|
|
157
|
+
"ordered-list": "OL"
|
|
158
|
+
};
|
|
159
|
+
function X() {
|
|
160
|
+
return "<p><br></p>";
|
|
161
|
+
}
|
|
162
|
+
function $t(r) {
|
|
163
|
+
return r.trim().length > 0 ? r : X();
|
|
164
|
+
}
|
|
165
|
+
function Wt() {
|
|
166
|
+
const r = document.queryCommandValue("formatBlock");
|
|
167
|
+
switch (String(r || "").replace(/[<>]/g, "").toUpperCase()) {
|
|
168
|
+
case "H1":
|
|
169
|
+
return "heading1";
|
|
170
|
+
case "H2":
|
|
171
|
+
return "heading2";
|
|
172
|
+
case "H3":
|
|
173
|
+
return "heading3";
|
|
174
|
+
case "H4":
|
|
175
|
+
return "heading4";
|
|
176
|
+
case "PRE":
|
|
177
|
+
return "preformatted";
|
|
178
|
+
default:
|
|
179
|
+
return "paragraph";
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function Kt(r) {
|
|
183
|
+
switch (r) {
|
|
184
|
+
case "heading1":
|
|
185
|
+
return t.formatMenuOptionHeading1;
|
|
186
|
+
case "heading2":
|
|
187
|
+
return t.formatMenuOptionHeading2;
|
|
188
|
+
case "heading3":
|
|
189
|
+
return t.formatMenuOptionHeading3;
|
|
190
|
+
case "heading4":
|
|
191
|
+
return t.formatMenuOptionHeading4;
|
|
192
|
+
case "preformatted":
|
|
193
|
+
return t.formatMenuOptionPreformatted;
|
|
194
|
+
default:
|
|
195
|
+
return t.formatMenuOptionParagraph;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
function tn({
|
|
199
|
+
className: r,
|
|
200
|
+
label: s,
|
|
201
|
+
required: f = !1,
|
|
202
|
+
value: p,
|
|
203
|
+
placeholder: x = "Content",
|
|
204
|
+
disabled: a = !1,
|
|
205
|
+
errorMessage: m,
|
|
206
|
+
helpText: R,
|
|
207
|
+
helpLink: E,
|
|
208
|
+
helpLinkText: y,
|
|
209
|
+
toolbarLayout: j = "inline",
|
|
210
|
+
showToolbar: z = !0,
|
|
211
|
+
showCharacterCount: ye = !0,
|
|
212
|
+
maxCharacters: g,
|
|
213
|
+
resizable: Ce = !0,
|
|
214
|
+
rows: Le = 8,
|
|
215
|
+
fullWidth: q = !1,
|
|
216
|
+
tooltipEnabled: w = !0,
|
|
217
|
+
formatOptions: Q = zt,
|
|
218
|
+
toolbarOptions: ee = jt,
|
|
219
|
+
onChange: $,
|
|
220
|
+
onModelChange: W
|
|
221
|
+
}) {
|
|
222
|
+
const Oe = Ee(() => new Set(ee), [ee]), C = (e) => Oe.has(e), te = ze(), d = M(null), ne = M(null), oe = M(null), L = M(null), B = M(!1), [Ne, re] = u(!1), [S, ie] = u(!1), [He, we] = u(0), [ae, le] = u(null), [Be, ce] = u(!1), [se, de] = u(""), [ue, me] = u(""), [he, O] = u(""), [D, fe] = u(() => Y(p || X())), [_e, Se] = u("paragraph"), [T, De] = u({
|
|
223
|
+
bold: !1,
|
|
224
|
+
italic: !1,
|
|
225
|
+
underline: !1,
|
|
226
|
+
justifyLeft: !1,
|
|
227
|
+
justifyCenter: !1,
|
|
228
|
+
justifyRight: !1,
|
|
229
|
+
insertUnorderedList: !1
|
|
230
|
+
}), N = Ee(() => Ut(D), [D]), pe = M(N);
|
|
231
|
+
pe.current = N;
|
|
232
|
+
const K = () => {
|
|
233
|
+
if (!d.current) return;
|
|
234
|
+
const e = Y(d.current.innerHTML);
|
|
235
|
+
fe(e), W == null || W(e), $ == null || $(ke(e));
|
|
236
|
+
}, I = () => {
|
|
237
|
+
Se(Wt()), De({
|
|
238
|
+
bold: document.queryCommandState("bold"),
|
|
239
|
+
italic: document.queryCommandState("italic"),
|
|
240
|
+
underline: document.queryCommandState("underline"),
|
|
241
|
+
justifyLeft: document.queryCommandState("justifyLeft"),
|
|
242
|
+
justifyCenter: document.queryCommandState("justifyCenter"),
|
|
243
|
+
justifyRight: document.queryCommandState("justifyRight"),
|
|
244
|
+
insertUnorderedList: document.queryCommandState("insertUnorderedList")
|
|
245
|
+
});
|
|
246
|
+
}, V = () => {
|
|
247
|
+
var e;
|
|
248
|
+
a || (e = d.current) == null || e.focus();
|
|
249
|
+
}, ge = (e, n) => {
|
|
250
|
+
a || (V(), document.execCommand(e, !1, n), K(), I());
|
|
251
|
+
}, Ie = (e) => {
|
|
252
|
+
ge("formatBlock", qt[e]);
|
|
253
|
+
}, Te = () => {
|
|
254
|
+
var l, k;
|
|
255
|
+
if (a) return;
|
|
256
|
+
V();
|
|
257
|
+
const e = window.getSelection();
|
|
258
|
+
let n = "", i = "";
|
|
259
|
+
if (e && e.rangeCount > 0) {
|
|
260
|
+
const h = e.getRangeAt(0);
|
|
261
|
+
L.current = h.cloneRange(), n = e.toString();
|
|
262
|
+
const _ = ((l = h.startContainer.parentElement) == null ? void 0 : l.closest("a")) ?? ((k = h.endContainer.parentElement) == null ? void 0 : k.closest("a"));
|
|
263
|
+
_ instanceof HTMLAnchorElement && (n = _.textContent ?? n, i = _.getAttribute("href") ?? "");
|
|
264
|
+
} else
|
|
265
|
+
L.current = null;
|
|
266
|
+
de(n), me(i), O(""), ce(!0);
|
|
267
|
+
}, J = () => {
|
|
268
|
+
if (B.current) {
|
|
269
|
+
B.current = !1;
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
ce(!1), O(""), L.current = null;
|
|
273
|
+
}, Fe = (e) => {
|
|
274
|
+
me(e), he && O("");
|
|
275
|
+
}, Ae = (e) => {
|
|
276
|
+
const n = /^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
|
|
277
|
+
try {
|
|
278
|
+
const i = /^https?:\/\//i.test(e), l = new URL(i ? e : `https://${e}`);
|
|
279
|
+
return l.protocol !== "http:" && l.protocol !== "https:" ? !1 : n.test(l.hostname);
|
|
280
|
+
} catch {
|
|
281
|
+
return !1;
|
|
282
|
+
}
|
|
283
|
+
}, Pe = (e) => /^https?:\/\//i.test(e) ? e : `https://${/^www\./i.test(e) ? e : `www.${e}`}`, Ue = () => {
|
|
284
|
+
const e = ue.trim();
|
|
285
|
+
if (!e) {
|
|
286
|
+
O("This field is required"), B.current = !0;
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
if (!Ae(e)) {
|
|
290
|
+
O("Invalid link"), B.current = !0;
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
const n = Pe(e), i = se.trim() || e, l = (_) => _.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), k = `<a href="${l(n)}" target="_blank" rel="noopener noreferrer">${l(i)}</a>`;
|
|
294
|
+
V();
|
|
295
|
+
const h = window.getSelection();
|
|
296
|
+
h && L.current && (h.removeAllRanges(), h.addRange(L.current)), document.execCommand("insertHTML", !1, k), K(), I(), J();
|
|
297
|
+
}, je = (e) => {
|
|
298
|
+
if (!e.ctrlKey && !e.metaKey) return;
|
|
299
|
+
const n = e.target, i = n == null ? void 0 : n.closest("a");
|
|
300
|
+
i instanceof HTMLAnchorElement && i.href && (e.preventDefault(), window.open(i.href, "_blank", "noopener,noreferrer"));
|
|
301
|
+
};
|
|
302
|
+
H(() => {
|
|
303
|
+
const e = $t(p || X()), n = Y(e);
|
|
304
|
+
fe(n), d.current && d.current.innerHTML !== e && (d.current.innerHTML = e);
|
|
305
|
+
}, [p]), H(() => {
|
|
306
|
+
d.current && (d.current.innerHTML.trim() || (d.current.innerHTML = ke(D)));
|
|
307
|
+
}, [D]), H(() => {
|
|
308
|
+
const e = d.current;
|
|
309
|
+
if (!e || !g) return;
|
|
310
|
+
const n = (i) => {
|
|
311
|
+
var _;
|
|
312
|
+
if (!i.inputType.startsWith("insert")) return;
|
|
313
|
+
const l = window.getSelection(), k = l && !l.isCollapsed ? l.toString().length : 0, h = i.data ? i.data.length : ((_ = i.dataTransfer) == null ? void 0 : _.getData("text").length) ?? 0;
|
|
314
|
+
pe.current - k + h > g && i.preventDefault();
|
|
315
|
+
};
|
|
316
|
+
return e.addEventListener("beforeinput", n), () => e.removeEventListener("beforeinput", n);
|
|
317
|
+
}, [g]), H(() => {
|
|
318
|
+
var n;
|
|
319
|
+
const e = (n = ne.current) == null ? void 0 : n.getBoundingClientRect().width;
|
|
320
|
+
e && we(e);
|
|
321
|
+
}, [S]), H(() => {
|
|
322
|
+
if (!z || q) {
|
|
323
|
+
le(null);
|
|
324
|
+
return;
|
|
325
|
+
}
|
|
326
|
+
const e = oe.current;
|
|
327
|
+
if (!e) return;
|
|
328
|
+
const n = () => {
|
|
329
|
+
const l = e.getBoundingClientRect().width;
|
|
330
|
+
l > 0 && le(l);
|
|
331
|
+
};
|
|
332
|
+
n();
|
|
333
|
+
const i = new ResizeObserver(() => {
|
|
334
|
+
n();
|
|
335
|
+
});
|
|
336
|
+
return i.observe(e), window.addEventListener("resize", n), () => {
|
|
337
|
+
i.disconnect(), window.removeEventListener("resize", n);
|
|
338
|
+
};
|
|
339
|
+
}, [z, j, a, w, q]);
|
|
340
|
+
const v = (e) => /* @__PURE__ */ o(G, { content: e.tooltip, size: "sm", theme: "dark", tipSide: "top", tipAlignment: "center", disabled: !w, children: /* @__PURE__ */ o("button", { type: "button", className: b(t.toolButton, e.active && t.toolButtonActive), onMouseDown: (n) => n.preventDefault(), onClick: () => ge(e.command, e.value), "aria-label": e.tooltip, disabled: a, children: /* @__PURE__ */ o(U, { icon: e.icon, className: t.toolIcon }) }) }, e.id), Z = [{
|
|
341
|
+
id: "bold",
|
|
342
|
+
icon: "ap-icon-bold",
|
|
343
|
+
command: "bold",
|
|
344
|
+
tooltip: "Bold (CTRL + B)",
|
|
345
|
+
active: T.bold
|
|
346
|
+
}, {
|
|
347
|
+
id: "italic",
|
|
348
|
+
icon: "ap-icon-italic",
|
|
349
|
+
command: "italic",
|
|
350
|
+
tooltip: "Italic (CTRL + I)",
|
|
351
|
+
active: T.italic
|
|
352
|
+
}, {
|
|
353
|
+
id: "underline",
|
|
354
|
+
icon: "ap-icon-underline",
|
|
355
|
+
command: "underline",
|
|
356
|
+
tooltip: "Underline (CTRL + U)",
|
|
357
|
+
active: T.underline
|
|
358
|
+
}, {
|
|
359
|
+
id: "align-left",
|
|
360
|
+
icon: "ap-icon-align-left",
|
|
361
|
+
command: "justifyLeft",
|
|
362
|
+
tooltip: "Align left",
|
|
363
|
+
active: T.justifyLeft
|
|
364
|
+
}, {
|
|
365
|
+
id: "align-center",
|
|
366
|
+
icon: "ap-icon-align-center",
|
|
367
|
+
command: "justifyCenter",
|
|
368
|
+
tooltip: "Align center",
|
|
369
|
+
active: T.justifyCenter
|
|
370
|
+
}, {
|
|
371
|
+
id: "align-right",
|
|
372
|
+
icon: "ap-icon-align-right",
|
|
373
|
+
command: "justifyRight",
|
|
374
|
+
tooltip: "Align right",
|
|
375
|
+
active: T.justifyRight
|
|
376
|
+
}, {
|
|
377
|
+
id: "bulleted",
|
|
378
|
+
icon: "ap-icon-list",
|
|
379
|
+
command: "insertUnorderedList",
|
|
380
|
+
tooltip: "Bulleted list",
|
|
381
|
+
active: T.insertUnorderedList
|
|
382
|
+
}], F = Z.filter((e) => ["bold", "italic", "underline"].includes(e.id) && C(e.id)), A = Z.filter((e) => ["align-left", "align-center", "align-right"].includes(e.id) && C(e.id)), P = Z.filter((e) => ["bulleted"].includes(e.id) && C(e.id)), be = C("link"), xe = C("format"), Re = () => {
|
|
383
|
+
var e;
|
|
384
|
+
return /* @__PURE__ */ o("div", { className: t.formatControl, children: /* @__PURE__ */ c($e, { open: S, onOpenChange: ie, children: [
|
|
385
|
+
/* @__PURE__ */ c(We, { ref: ne, disabled: a, className: b(t.selectTrigger, S && t.selectTriggerOpen), children: [
|
|
386
|
+
/* @__PURE__ */ o("span", { className: t.selectTriggerLabel, children: ((e = Q.find((n) => n.value === _e)) == null ? void 0 : e.label) || "Paragraph" }),
|
|
387
|
+
/* @__PURE__ */ o("span", { className: t.selectIconBox, children: /* @__PURE__ */ o(U, { icon: S ? "ap-icon-expand-less" : "ap-icon-expand-more", className: t.selectIcon }) })
|
|
388
|
+
] }),
|
|
389
|
+
/* @__PURE__ */ o(Ke, { children: /* @__PURE__ */ o(Ve, { align: "end", side: "bottom", sideOffset: 6, collisionPadding: 8, className: t.formatMenu, style: {
|
|
390
|
+
minWidth: He || 180,
|
|
391
|
+
zIndex: 9999
|
|
392
|
+
}, children: /* @__PURE__ */ o("div", { className: t.formatMenuOptions, children: Q.map((n) => /* @__PURE__ */ o("button", { type: "button", className: b(t.formatMenuOption, Kt(n.value), n.value === _e && t.formatMenuOptionSelected), onMouseDown: (i) => i.preventDefault(), onClick: () => {
|
|
393
|
+
Ie(n.value), ie(!1);
|
|
394
|
+
}, children: n.label }, n.value)) }) }) })
|
|
395
|
+
] }) });
|
|
396
|
+
};
|
|
397
|
+
return /* @__PURE__ */ c("div", { className: b(t.container, a && t.containerDisabled, q && t.containerFullWidth, r), children: [
|
|
398
|
+
s && /* @__PURE__ */ c("label", { className: t.label, htmlFor: te, children: [
|
|
399
|
+
s,
|
|
400
|
+
f && /* @__PURE__ */ o("span", { className: t.required, children: "*" })
|
|
401
|
+
] }),
|
|
402
|
+
/* @__PURE__ */ c("div", { className: b(t.frame, Ne && t.frameFocused, a && t.frameDisabled, m && t.frameError), style: {
|
|
403
|
+
width: ae ? `${ae}px` : void 0
|
|
404
|
+
}, children: [
|
|
405
|
+
z && /* @__PURE__ */ o("div", { className: b(t.toolbar, j === "stacked" && t.toolbarStacked), children: /* @__PURE__ */ o("div", { ref: oe, className: t.toolbarContent, children: j === "stacked" ? /* @__PURE__ */ c("div", { className: t.toolbarPanel, children: [
|
|
406
|
+
/* @__PURE__ */ c("div", { className: t.toolbarRow, children: [
|
|
407
|
+
F.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: F.map(v) }),
|
|
408
|
+
A.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: A.map(v) })
|
|
409
|
+
] }),
|
|
410
|
+
/* @__PURE__ */ c("div", { className: t.toolbarRow, children: [
|
|
411
|
+
P.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: P.map(v) }),
|
|
412
|
+
be && /* @__PURE__ */ o("div", { className: t.toolbarLinkSlot, children: /* @__PURE__ */ o(G, { content: "Insert link", size: "sm", theme: "dark", tipSide: "top", tipAlignment: "center", disabled: !w, children: /* @__PURE__ */ o("button", { type: "button", className: t.toolButton, onMouseDown: (e) => e.preventDefault(), onClick: Te, "aria-label": "Insert link", disabled: a, children: /* @__PURE__ */ o(U, { icon: "ap-icon-link", className: t.toolIcon }) }) }) }),
|
|
413
|
+
xe && Re()
|
|
414
|
+
] })
|
|
415
|
+
] }) : /* @__PURE__ */ o("div", { className: t.toolbarPanel, children: /* @__PURE__ */ c("div", { className: t.toolbarRow, children: [
|
|
416
|
+
F.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: F.map(v) }),
|
|
417
|
+
A.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: A.map(v) }),
|
|
418
|
+
P.length > 0 && /* @__PURE__ */ o("div", { className: t.actions, children: P.map(v) }),
|
|
419
|
+
be && /* @__PURE__ */ o("div", { className: t.toolbarLinkSlot, children: /* @__PURE__ */ o(G, { content: "Insert link", size: "sm", theme: "dark", tipSide: "top", tipAlignment: "center", disabled: !w, children: /* @__PURE__ */ o("button", { type: "button", className: t.toolButton, onMouseDown: (e) => e.preventDefault(), onClick: Te, "aria-label": "Insert link", disabled: a, children: /* @__PURE__ */ o(U, { icon: "ap-icon-link", className: t.toolIcon }) }) }) }),
|
|
420
|
+
xe && Re()
|
|
421
|
+
] }) }) }) }),
|
|
422
|
+
/* @__PURE__ */ c("div", { className: t.editorBody, style: {
|
|
423
|
+
minHeight: `${Le * 20}px`,
|
|
424
|
+
resize: Ce && !a ? "vertical" : "none"
|
|
425
|
+
}, children: [
|
|
426
|
+
/* @__PURE__ */ o("div", { id: te, ref: d, className: t.editor, contentEditable: !a, suppressContentEditableWarning: !0, role: "textbox", "aria-multiline": "true", "aria-label": s || "Rich text editor", "data-placeholder": x, onInput: K, onFocus: () => re(!0), onBlur: () => re(!1), onKeyUp: I, onMouseUp: I, onClick: je }),
|
|
427
|
+
ye && /* @__PURE__ */ o("div", { className: b(t.characterCount, g && N > g && t.characterCountExceeded), children: g ? `${N}/${g}` : N })
|
|
428
|
+
] })
|
|
429
|
+
] }),
|
|
430
|
+
(m || R || E) && /* @__PURE__ */ c("div", { className: t.helpers, children: [
|
|
431
|
+
m ? /* @__PURE__ */ o("span", { title: m, className: t.errorMessage, children: m }) : R && /* @__PURE__ */ o("span", { title: R, className: t.helperText, children: R }),
|
|
432
|
+
E && y && /* @__PURE__ */ o("a", { href: E, className: t.helpLink, target: "_blank", rel: "noopener noreferrer", children: y })
|
|
433
|
+
] }),
|
|
434
|
+
/* @__PURE__ */ o(qe, { isOpen: Be, onClose: J, title: "Attach link", cancelButtonText: "Cancel", cancelButtonType: "primary", cancelButtonVariant: "cancel", confirmButtonText: "Attach", confirmButtonType: "primary", onCancel: J, onConfirm: Ue, description: /* @__PURE__ */ c("div", { className: t.linkDialogForm, children: [
|
|
435
|
+
/* @__PURE__ */ o(ve, { type: "text", label: "Displayed text", value: se, onChange: de, autofocus: !0 }),
|
|
436
|
+
/* @__PURE__ */ o(ve, { type: "text", label: "Link", value: ue, placeholder: "https://example.com/", required: !0, errorMessage: he || void 0, onChange: Fe })
|
|
437
|
+
] }) })
|
|
438
|
+
] });
|
|
439
|
+
}
|
|
440
|
+
export {
|
|
441
|
+
tn as R,
|
|
442
|
+
t as s
|
|
443
|
+
};
|