@luscii-healthtech/web-ui 54.6.1 → 54.7.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.
- package/dist/index.development.js +34 -11
- package/dist/index.development.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/components/Card/Card.d.ts +11 -0
- package/dist/src/components/TextEditor/TextEditor.d.ts +16 -0
- package/dist/src/components/TextEditor/mentionSuggestion.d.ts +5 -1
- package/dist/src/generated/components/Card/Card.d.ts +11 -0
- package/dist/src/generated/components/TextEditor/TextEditor.d.ts +16 -0
- package/dist/src/generated/components/TextEditor/mentionSuggestion.d.ts +5 -1
- package/dist/stories/Card.stories.d.ts +6 -0
- package/dist/stories/TextEditor.stories.d.ts +13 -4
- package/dist/web-ui-tailwind.css +13 -0
- package/dist/web-ui.esm.js +1 -1
- package/dist/web-ui.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -3064,13 +3064,17 @@ const TopBar = (props) => {
|
|
|
3064
3064
|
TopBar.Actions = Actions$1;
|
|
3065
3065
|
|
|
3066
3066
|
function Card(props) {
|
|
3067
|
-
const { actions: __, as: Element = "div", children, border, className, elevation, elevationOnHover, padding = true, title: _, borderRadius = "m", highlighted = false } = props, rest = __rest(props, ["actions", "as", "children", "border", "className", "elevation", "elevationOnHover", "padding", "title", "borderRadius", "highlighted"]);
|
|
3067
|
+
const { actions: __, as: Element = "div", children, border, className, elevation, elevationOnHover, padding = true, title: _, borderRadius = "m", highlighted = false, selected = false } = props, rest = __rest(props, ["actions", "as", "children", "border", "className", "elevation", "elevationOnHover", "padding", "title", "borderRadius", "highlighted", "selected"]);
|
|
3068
3068
|
const hasHoverEffect = !(elevation === elevationOnHover || elevationOnHover === void 0);
|
|
3069
3069
|
const hoverShadowClassName = createShadowClassName(elevationOnHover, {
|
|
3070
3070
|
modifier: "hover",
|
|
3071
3071
|
transition: true
|
|
3072
3072
|
});
|
|
3073
|
-
const outerClasses = classNames__default.default("ui:transition-colors ui:duration-300", className, hoverShadowClassName, "ui:transition-shadow ui:duration-300"
|
|
3073
|
+
const outerClasses = classNames__default.default("ui:transition-colors ui:duration-300", className, hoverShadowClassName, "ui:transition-shadow ui:duration-300", {
|
|
3074
|
+
// Selected state: brand-primary ring hugging the card's rounded corners,
|
|
3075
|
+
// matching the selected treatment of `LabeledRadioCard`.
|
|
3076
|
+
"ui:ring-2 ui:ring-border-brand-primary-default ui:focus-visible:ring-offset-2": selected
|
|
3077
|
+
});
|
|
3074
3078
|
const innerClasses = classNames__default.default("ui:rounded-inherit ui:border ui:border-transparent ui:transition[border-color] ui:duration-300 ui:motion-reduce:duration-[0ms]! ui:overflow-hidden", "ui:relative", "ui:before:contain-strict ui:before:transition[transform, opacity] ui:before:delay-50 ui:before:duration-150 ui:before:motion-reduce:duration-[0ms]!", "ui:before:origin-left ui:before:absolute ui:before:left-0 ui:before:content-[''] ui:before:inset-y-0 ui:before:ease-in-out", {
|
|
3075
3079
|
"ui:border-slate-300": border || highlighted,
|
|
3076
3080
|
"ui:hover:border-slate-400": hasHoverEffect,
|
|
@@ -5296,7 +5300,7 @@ const MentionList = React.forwardRef(({ items, command }, ref) => {
|
|
|
5296
5300
|
MentionList.displayName = "MentionList";
|
|
5297
5301
|
|
|
5298
5302
|
const MAX_RESULTS = 8;
|
|
5299
|
-
const createMentionSuggestion = (getTags) => ({
|
|
5303
|
+
const createMentionSuggestion = (getTags, getPopupContainer = () => null) => ({
|
|
5300
5304
|
items: ({ query }) => {
|
|
5301
5305
|
const normalizedQuery = query.toLowerCase();
|
|
5302
5306
|
return getTags().filter((tag) => tag.label.toLowerCase().includes(normalizedQuery)).slice(0, MAX_RESULTS);
|
|
@@ -5304,7 +5308,10 @@ const createMentionSuggestion = (getTags) => ({
|
|
|
5304
5308
|
render: () => {
|
|
5305
5309
|
let component = null;
|
|
5306
5310
|
let popup = null;
|
|
5311
|
+
let latestClientRect = null;
|
|
5312
|
+
let mountTarget = document.body;
|
|
5307
5313
|
const reposition = (clientRect) => {
|
|
5314
|
+
latestClientRect = clientRect;
|
|
5308
5315
|
if (!popup || !clientRect) {
|
|
5309
5316
|
return;
|
|
5310
5317
|
}
|
|
@@ -5312,11 +5319,14 @@ const createMentionSuggestion = (getTags) => ({
|
|
|
5312
5319
|
if (!rect) {
|
|
5313
5320
|
return;
|
|
5314
5321
|
}
|
|
5315
|
-
|
|
5316
|
-
popup.style.
|
|
5322
|
+
const originRect = mountTarget.getBoundingClientRect();
|
|
5323
|
+
popup.style.top = `${rect.bottom - originRect.top + 4}px`;
|
|
5324
|
+
popup.style.left = `${rect.left - originRect.left}px`;
|
|
5317
5325
|
};
|
|
5326
|
+
const handleViewportChange = () => reposition(latestClientRect);
|
|
5318
5327
|
return {
|
|
5319
5328
|
onStart: (props) => {
|
|
5329
|
+
var _a, _b;
|
|
5320
5330
|
component = new react.ReactRenderer(MentionList, {
|
|
5321
5331
|
props,
|
|
5322
5332
|
editor: props.editor
|
|
@@ -5324,12 +5334,15 @@ const createMentionSuggestion = (getTags) => ({
|
|
|
5324
5334
|
if (!props.clientRect) {
|
|
5325
5335
|
return;
|
|
5326
5336
|
}
|
|
5337
|
+
mountTarget = (_b = (_a = getPopupContainer()) !== null && _a !== void 0 ? _a : props.editor.view.dom.closest("dialog")) !== null && _b !== void 0 ? _b : document.body;
|
|
5327
5338
|
popup = document.createElement("div");
|
|
5328
|
-
popup.style.position = "
|
|
5339
|
+
popup.style.position = "absolute";
|
|
5329
5340
|
popup.style.zIndex = "1000";
|
|
5330
5341
|
popup.appendChild(component.element);
|
|
5331
|
-
|
|
5342
|
+
mountTarget.appendChild(popup);
|
|
5332
5343
|
reposition(props.clientRect);
|
|
5344
|
+
window.addEventListener("scroll", handleViewportChange, true);
|
|
5345
|
+
window.addEventListener("resize", handleViewportChange);
|
|
5333
5346
|
},
|
|
5334
5347
|
onUpdate: (props) => {
|
|
5335
5348
|
component === null || component === void 0 ? void 0 : component.updateProps(props);
|
|
@@ -5340,6 +5353,9 @@ const createMentionSuggestion = (getTags) => ({
|
|
|
5340
5353
|
return (_b = (_a = component === null || component === void 0 ? void 0 : component.ref) === null || _a === void 0 ? void 0 : _a.onKeyDown(props)) !== null && _b !== void 0 ? _b : false;
|
|
5341
5354
|
},
|
|
5342
5355
|
onExit: () => {
|
|
5356
|
+
window.removeEventListener("scroll", handleViewportChange, true);
|
|
5357
|
+
window.removeEventListener("resize", handleViewportChange);
|
|
5358
|
+
latestClientRect = null;
|
|
5343
5359
|
popup === null || popup === void 0 ? void 0 : popup.remove();
|
|
5344
5360
|
popup = null;
|
|
5345
5361
|
component === null || component === void 0 ? void 0 : component.destroy();
|
|
@@ -5356,8 +5372,13 @@ const MentionView = ({ node }) => {
|
|
|
5356
5372
|
const char = (_b = node.attrs.mentionSuggestionChar) !== null && _b !== void 0 ? _b : "@";
|
|
5357
5373
|
const display = `${char}${label}`;
|
|
5358
5374
|
const tooltipText = id && id !== label ? id : null;
|
|
5359
|
-
const
|
|
5360
|
-
|
|
5375
|
+
const [dialogContainer, setDialogContainer] = React.useState(null);
|
|
5376
|
+
const pillRef = React.useCallback((el) => {
|
|
5377
|
+
var _a2;
|
|
5378
|
+
setDialogContainer((_a2 = el === null || el === void 0 ? void 0 : el.closest("dialog")) !== null && _a2 !== void 0 ? _a2 : null);
|
|
5379
|
+
}, []);
|
|
5380
|
+
const pill = jsxRuntime.jsx("span", { ref: pillRef, className: "web-ui-mention", children: display });
|
|
5381
|
+
return jsxRuntime.jsx(react.NodeViewWrapper, { as: "span", children: tooltipText ? jsxRuntime.jsx(Tooltip$1.Provider, { children: jsxRuntime.jsxs(Tooltip.Root, { children: [jsxRuntime.jsx(Tooltip.Trigger, { asChild: true, children: pill }), jsxRuntime.jsx(Tooltip.Content, { container: dialogContainer !== null && dialogContainer !== void 0 ? dialogContainer : void 0, children: jsxRuntime.jsx(Tooltip.Text, { children: tooltipText }) })] }) }) : pill });
|
|
5361
5382
|
};
|
|
5362
5383
|
|
|
5363
5384
|
const TEXT_EDITOR_TRANSLATIONS = {
|
|
@@ -5472,12 +5493,13 @@ const TextEditor = (_a) => {
|
|
|
5472
5493
|
["bold", "italic", "underline", "strike"],
|
|
5473
5494
|
[{ list: "ordered" }, { list: "bullet" }],
|
|
5474
5495
|
["link"]
|
|
5475
|
-
], placeholder, tags, onValueChange } = _a, attrs = __rest(_a, ["defaultValue", "formats", "toolbar", "placeholder", "tags", "onValueChange"]);
|
|
5496
|
+
], placeholder, tags, popupContainer, onValueChange } = _a, attrs = __rest(_a, ["defaultValue", "formats", "toolbar", "placeholder", "tags", "popupContainer", "onValueChange"]);
|
|
5476
5497
|
const rawId = React.useId();
|
|
5477
5498
|
const toolbarId = `toolbar-${rawId.replace(/:/g, "")}`;
|
|
5478
5499
|
const defaultValueRef = React.useRef(sanitize(defaultValue !== null && defaultValue !== void 0 ? defaultValue : ""));
|
|
5479
5500
|
const onTextChangeRef = React.useRef(onValueChange);
|
|
5480
5501
|
const tagsRef = React.useRef(tags !== null && tags !== void 0 ? tags : []);
|
|
5502
|
+
const popupContainerRef = React.useRef(popupContainer);
|
|
5481
5503
|
const mentionsEnabled = tags !== void 0;
|
|
5482
5504
|
const [linkTooltip, setLinkTooltip] = React.useState(null);
|
|
5483
5505
|
const [hasTextSelected, setHasTextSelected] = React.useState(false);
|
|
@@ -5486,6 +5508,7 @@ const TextEditor = (_a) => {
|
|
|
5486
5508
|
React.useLayoutEffect(() => {
|
|
5487
5509
|
onTextChangeRef.current = onValueChange;
|
|
5488
5510
|
tagsRef.current = tags !== null && tags !== void 0 ? tags : [];
|
|
5511
|
+
popupContainerRef.current = popupContainer;
|
|
5489
5512
|
});
|
|
5490
5513
|
const editor = react.useEditor({
|
|
5491
5514
|
extensions: [
|
|
@@ -5516,7 +5539,7 @@ const TextEditor = (_a) => {
|
|
|
5516
5539
|
...mentionsEnabled ? [
|
|
5517
5540
|
MentionWithTooltip.configure({
|
|
5518
5541
|
HTMLAttributes: { class: "web-ui-mention" },
|
|
5519
|
-
suggestion: createMentionSuggestion(() => tagsRef.current)
|
|
5542
|
+
suggestion: createMentionSuggestion(() => tagsRef.current, () => popupContainerRef.current)
|
|
5520
5543
|
})
|
|
5521
5544
|
] : []
|
|
5522
5545
|
],
|