@uniformdev/design-system 19.25.0 → 19.26.0
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/esm/index.js +279 -236
- package/dist/index.d.ts +5 -2
- package/dist/index.js +244 -191
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -20450,13 +20450,16 @@ type DetailsProps = React$1.HTMLAttributes<HTMLDetailsElement> & {
|
|
|
20450
20450
|
/** sets the summary inner components */
|
|
20451
20451
|
summary: React$1.ReactNode;
|
|
20452
20452
|
children: React$1.ReactNode;
|
|
20453
|
-
|
|
20453
|
+
isOpen?: boolean | undefined;
|
|
20454
|
+
onChange?: (isOpen: boolean) => void;
|
|
20455
|
+
/** sets whether the details should be open by default.
|
|
20456
|
+
* Undefined value means that the details will be controlled by the user.
|
|
20454
20457
|
* @default false
|
|
20455
20458
|
*/
|
|
20456
20459
|
isOpenByDefault?: boolean;
|
|
20457
20460
|
};
|
|
20458
20461
|
/** @example <Details summary="summary text">child content here</Details>*/
|
|
20459
|
-
declare const Details: ({ summary, children, isOpenByDefault, ...props }: DetailsProps) => _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
20462
|
+
declare const Details: ({ summary, children, isOpenByDefault, isOpen, onChange, ...props }: DetailsProps) => _emotion_react_types_jsx_namespace.EmotionJSX.Element;
|
|
20460
20463
|
|
|
20461
20464
|
interface DrawerItem {
|
|
20462
20465
|
/** An ID for the drawer. It should be unique in the stack where it's rendered */
|
package/dist/index.js
CHANGED
|
@@ -12713,43 +12713,48 @@ var summaryIconVisiblyHidden = import_react46.css`
|
|
|
12713
12713
|
|
|
12714
12714
|
// src/components/Details/Details.tsx
|
|
12715
12715
|
var import_jsx_runtime37 = require("@emotion/react/jsx-runtime");
|
|
12716
|
-
var Details = ({
|
|
12716
|
+
var Details = ({
|
|
12717
|
+
summary: summary2,
|
|
12718
|
+
children,
|
|
12719
|
+
isOpenByDefault = false,
|
|
12720
|
+
isOpen,
|
|
12721
|
+
onChange,
|
|
12722
|
+
...props
|
|
12723
|
+
}) => {
|
|
12717
12724
|
const detailsRef = React9.useRef(null);
|
|
12718
|
-
const [
|
|
12719
|
-
React9.
|
|
12720
|
-
|
|
12721
|
-
|
|
12722
|
-
|
|
12725
|
+
const [internalOpen, setInternalOpen] = React9.useState(isOpenByDefault);
|
|
12726
|
+
const memoizedIsOpen = React9.useMemo(() => {
|
|
12727
|
+
return isOpen !== void 0 ? isOpen : internalOpen;
|
|
12728
|
+
}, [internalOpen, isOpen]);
|
|
12729
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
12730
|
+
"details",
|
|
12731
|
+
{
|
|
12732
|
+
"data-testid": "details",
|
|
12733
|
+
onToggle: (e) => {
|
|
12734
|
+
setInternalOpen(e.currentTarget.open);
|
|
12735
|
+
onChange == null ? void 0 : onChange(e.currentTarget.open);
|
|
12736
|
+
},
|
|
12737
|
+
css: details,
|
|
12738
|
+
open: memoizedIsOpen,
|
|
12739
|
+
ref: detailsRef,
|
|
12740
|
+
...props,
|
|
12741
|
+
children: [
|
|
12742
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("summary", { "data-testid": "summary", css: summary, children: [
|
|
12743
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
12744
|
+
Icon,
|
|
12745
|
+
{
|
|
12746
|
+
css: [!children ? summaryIconVisiblyHidden : void 0, summaryIcon],
|
|
12747
|
+
icon: "chevron-down",
|
|
12748
|
+
iconColor: "currentColor",
|
|
12749
|
+
size: "1.25rem"
|
|
12750
|
+
}
|
|
12751
|
+
),
|
|
12752
|
+
summary2
|
|
12753
|
+
] }),
|
|
12754
|
+
memoizedIsOpen ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { "data-testid": "details-content", css: detailsContent, children }) : null
|
|
12755
|
+
]
|
|
12723
12756
|
}
|
|
12724
|
-
|
|
12725
|
-
var _a2;
|
|
12726
|
-
const toggle = Boolean((_a2 = detailsRef == null ? void 0 : detailsRef.current) == null ? void 0 : _a2.open);
|
|
12727
|
-
setOpen(toggle);
|
|
12728
|
-
};
|
|
12729
|
-
(_a = detailsRef.current) == null ? void 0 : _a.addEventListener("toggle", toggleEvent);
|
|
12730
|
-
() => {
|
|
12731
|
-
var _a2;
|
|
12732
|
-
return (_a2 = detailsRef.current) == null ? void 0 : _a2.removeEventListener("toggle", toggleEvent);
|
|
12733
|
-
};
|
|
12734
|
-
}, [detailsRef]);
|
|
12735
|
-
React9.useEffect(() => {
|
|
12736
|
-
setOpen(isOpenByDefault);
|
|
12737
|
-
}, [isOpenByDefault]);
|
|
12738
|
-
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("details", { "data-testid": "details", css: details, open, ref: detailsRef, ...props, children: [
|
|
12739
|
-
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("summary", { "data-testid": "summary", css: summary, children: [
|
|
12740
|
-
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
12741
|
-
Icon,
|
|
12742
|
-
{
|
|
12743
|
-
css: [!children ? summaryIconVisiblyHidden : void 0, summaryIcon],
|
|
12744
|
-
icon: "chevron-down",
|
|
12745
|
-
iconColor: "currentColor",
|
|
12746
|
-
size: "1.25rem"
|
|
12747
|
-
}
|
|
12748
|
-
),
|
|
12749
|
-
summary2
|
|
12750
|
-
] }),
|
|
12751
|
-
open ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { "data-testid": "details-content", css: detailsContent, children }) : null
|
|
12752
|
-
] });
|
|
12757
|
+
);
|
|
12753
12758
|
};
|
|
12754
12759
|
|
|
12755
12760
|
// src/components/Drawer/Drawer.tsx
|
|
@@ -16534,6 +16539,26 @@ function removeLinkNode(node) {
|
|
|
16534
16539
|
}
|
|
16535
16540
|
node.remove();
|
|
16536
16541
|
}
|
|
16542
|
+
function removeLinkNodeFromSelection() {
|
|
16543
|
+
const selection = (0, import_lexical2.$getSelection)();
|
|
16544
|
+
if (!(0, import_lexical2.$isRangeSelection)(selection)) {
|
|
16545
|
+
return;
|
|
16546
|
+
}
|
|
16547
|
+
const nodes = selection.extract();
|
|
16548
|
+
const linkNodesFound = /* @__PURE__ */ new Set();
|
|
16549
|
+
for (const node of nodes) {
|
|
16550
|
+
if ((0, import_lexical2.$isElementNode)(node) && !node.isInline()) {
|
|
16551
|
+
continue;
|
|
16552
|
+
}
|
|
16553
|
+
const linkNodeAncestor = getLinkAncestor(node);
|
|
16554
|
+
if (linkNodeAncestor) {
|
|
16555
|
+
linkNodesFound.add(linkNodeAncestor);
|
|
16556
|
+
}
|
|
16557
|
+
}
|
|
16558
|
+
for (const node of linkNodesFound) {
|
|
16559
|
+
removeLinkNode(node);
|
|
16560
|
+
}
|
|
16561
|
+
}
|
|
16537
16562
|
function upsertLinkNode(props) {
|
|
16538
16563
|
var _a, _b, _c, _d, _e;
|
|
16539
16564
|
const selection = (0, import_lexical2.$getSelection)();
|
|
@@ -16591,6 +16616,7 @@ function upsertLinkNode(props) {
|
|
|
16591
16616
|
}
|
|
16592
16617
|
}
|
|
16593
16618
|
}
|
|
16619
|
+
var REMOVE_LINK_NODE_COMMAND = (0, import_lexical2.createCommand)("REMOVE_LINK_NODE_COMMAND");
|
|
16594
16620
|
var UPSERT_LINK_NODE_COMMAND = (0, import_lexical2.createCommand)("UPSERT_LINK_NODE_COMMAND");
|
|
16595
16621
|
var OPEN_LINK_NODE_MODAL_COMMAND = (0, import_lexical2.createCommand)(
|
|
16596
16622
|
"OPEN_LINK_NODE_MODAL_COMMAND"
|
|
@@ -16635,6 +16661,14 @@ function LinkNodePlugin({ onConnectLink }) {
|
|
|
16635
16661
|
},
|
|
16636
16662
|
import_lexical2.COMMAND_PRIORITY_EDITOR
|
|
16637
16663
|
),
|
|
16664
|
+
editor.registerCommand(
|
|
16665
|
+
REMOVE_LINK_NODE_COMMAND,
|
|
16666
|
+
() => {
|
|
16667
|
+
removeLinkNodeFromSelection();
|
|
16668
|
+
return true;
|
|
16669
|
+
},
|
|
16670
|
+
import_lexical2.COMMAND_PRIORITY_EDITOR
|
|
16671
|
+
),
|
|
16638
16672
|
editor.registerCommand(
|
|
16639
16673
|
OPEN_LINK_NODE_MODAL_COMMAND,
|
|
16640
16674
|
() => {
|
|
@@ -16839,7 +16873,6 @@ var import_react99 = require("@emotion/react");
|
|
|
16839
16873
|
var import_code = require("@lexical/code");
|
|
16840
16874
|
var import_list2 = require("@lexical/list");
|
|
16841
16875
|
var import_LexicalComposerContext3 = require("@lexical/react/LexicalComposerContext");
|
|
16842
|
-
var import_LexicalDecoratorBlockNode = require("@lexical/react/LexicalDecoratorBlockNode");
|
|
16843
16876
|
var import_rich_text = require("@lexical/rich-text");
|
|
16844
16877
|
var import_selection2 = require("@lexical/selection");
|
|
16845
16878
|
var import_utils5 = require("@lexical/utils");
|
|
@@ -16899,40 +16932,35 @@ var toolbarChevron = import_react99.css`
|
|
|
16899
16932
|
var ToolbarIcon = ({ icon }) => {
|
|
16900
16933
|
return /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Icon, { icon, css: toolbarIcon, size: "1rem" });
|
|
16901
16934
|
};
|
|
16935
|
+
var FORMATS_WITH_ICON = /* @__PURE__ */ new Map([
|
|
16936
|
+
["bold", "format-bold"],
|
|
16937
|
+
["italic", "format-italic"],
|
|
16938
|
+
["underline", "format-underline"],
|
|
16939
|
+
["strikethrough", "format-strike"],
|
|
16940
|
+
["code", "format-code"],
|
|
16941
|
+
["superscript", "format-superscript"],
|
|
16942
|
+
["subscript", "format-subscript"]
|
|
16943
|
+
]);
|
|
16944
|
+
var HEADING_ELEMENTS = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
16945
|
+
var TEXTUAL_ELEMENTS = HEADING_ELEMENTS;
|
|
16902
16946
|
var RichTextToolbar = ({ config }) => {
|
|
16903
16947
|
const [editor] = (0, import_LexicalComposerContext3.useLexicalComposerContext)();
|
|
16904
|
-
const
|
|
16905
|
-
|
|
16906
|
-
|
|
16907
|
-
|
|
16908
|
-
|
|
16909
|
-
|
|
16910
|
-
|
|
16911
|
-
|
|
16912
|
-
|
|
16913
|
-
|
|
16914
|
-
|
|
16915
|
-
|
|
16916
|
-
|
|
16917
|
-
|
|
16918
|
-
|
|
16919
|
-
|
|
16920
|
-
["strikethrough", "format-strike"],
|
|
16921
|
-
["code", "format-code"],
|
|
16922
|
-
["superscript", "format-superscript"],
|
|
16923
|
-
["subscript", "format-subscript"]
|
|
16924
|
-
]);
|
|
16925
|
-
const enabledBuiltInFormatsWithIcon = enabledBuiltInFormats.filter(
|
|
16926
|
-
(format) => formatsWithIcon.has(format.type)
|
|
16927
|
-
);
|
|
16928
|
-
const enabledBuiltInFormatsWithoutIcon = enabledBuiltInFormats.filter(
|
|
16929
|
-
(format) => !formatsWithIcon.has(format.type)
|
|
16930
|
-
);
|
|
16931
|
-
const [activeFormats, setActiveFormats] = (0, import_react100.useState)([]);
|
|
16932
|
-
const [activeElement, setActiveElement] = (0, import_react100.useState)("paragraph");
|
|
16933
|
-
const enabledTextualElements = enabledBuiltInElements.filter(
|
|
16934
|
-
(element) => ["h1", "h2", "h3", "h4", "h5", "h6"].includes(element.type)
|
|
16935
|
-
);
|
|
16948
|
+
const {
|
|
16949
|
+
activeElement,
|
|
16950
|
+
setActiveElement,
|
|
16951
|
+
activeFormats,
|
|
16952
|
+
setActiveFormats,
|
|
16953
|
+
visibleFormatsWithIcon,
|
|
16954
|
+
visibleFormatsWithoutIcon,
|
|
16955
|
+
visibleTextualElements,
|
|
16956
|
+
isLink,
|
|
16957
|
+
setIsLink,
|
|
16958
|
+
linkElementVisible,
|
|
16959
|
+
visibleLists,
|
|
16960
|
+
codeElementVisible,
|
|
16961
|
+
quoteElementVisible,
|
|
16962
|
+
visibleElementsWithIcons
|
|
16963
|
+
} = useRichTextToolbarState({ config });
|
|
16936
16964
|
const onSelectElement = (type) => {
|
|
16937
16965
|
if (activeElement === type) {
|
|
16938
16966
|
return;
|
|
@@ -16942,7 +16970,7 @@ var RichTextToolbar = ({ config }) => {
|
|
|
16942
16970
|
if (!(0, import_lexical4.$isRangeSelection)(selection)) {
|
|
16943
16971
|
return;
|
|
16944
16972
|
}
|
|
16945
|
-
if (
|
|
16973
|
+
if (HEADING_ELEMENTS.includes(type)) {
|
|
16946
16974
|
(0, import_selection2.$setBlocksType)(selection, () => (0, import_rich_text.$createHeadingNode)(type));
|
|
16947
16975
|
} else if (type === "paragraph") {
|
|
16948
16976
|
(0, import_selection2.$setBlocksType)(selection, () => (0, import_lexical4.$createParagraphNode)());
|
|
@@ -16953,28 +16981,13 @@ var RichTextToolbar = ({ config }) => {
|
|
|
16953
16981
|
}
|
|
16954
16982
|
});
|
|
16955
16983
|
};
|
|
16956
|
-
const [isLink, setIsLink] = (0, import_react100.useState)(false);
|
|
16957
|
-
const linkElementEnabled = (0, import_react100.useMemo)(() => {
|
|
16958
|
-
return enabledBuiltInElements.some((element) => element.type === "link");
|
|
16959
|
-
}, [enabledBuiltInElements]);
|
|
16960
|
-
const enabledLists = (0, import_react100.useMemo)(() => {
|
|
16961
|
-
return new Set(
|
|
16962
|
-
enabledBuiltInElements.filter((element) => ["orderedList", "unorderedList"].includes(element.type)).map((element) => element.type)
|
|
16963
|
-
);
|
|
16964
|
-
}, [enabledBuiltInElements]);
|
|
16965
|
-
const quoteElementEnabled = (0, import_react100.useMemo)(() => {
|
|
16966
|
-
return enabledBuiltInElements.some((element) => element.type === "quote");
|
|
16967
|
-
}, [enabledBuiltInElements]);
|
|
16968
|
-
const codeElementEnabled = (0, import_react100.useMemo)(() => {
|
|
16969
|
-
return enabledBuiltInElements.some((element) => element.type === "code");
|
|
16970
|
-
}, [enabledBuiltInElements]);
|
|
16971
16984
|
const updateToolbar = (0, import_react100.useCallback)(() => {
|
|
16972
16985
|
const selection = (0, import_lexical4.$getSelection)();
|
|
16973
16986
|
if (!(0, import_lexical4.$isRangeSelection)(selection)) {
|
|
16974
16987
|
return;
|
|
16975
16988
|
}
|
|
16976
16989
|
const newActiveFormats = [];
|
|
16977
|
-
for (const format of
|
|
16990
|
+
for (const format of richTextBuiltInFormats) {
|
|
16978
16991
|
if (selection.hasFormat(format.type)) {
|
|
16979
16992
|
newActiveFormats.push(format.type);
|
|
16980
16993
|
}
|
|
@@ -17006,7 +17019,7 @@ var RichTextToolbar = ({ config }) => {
|
|
|
17006
17019
|
} else {
|
|
17007
17020
|
setIsLink(false);
|
|
17008
17021
|
}
|
|
17009
|
-
}, [editor,
|
|
17022
|
+
}, [editor, setActiveElement, setActiveFormats, setIsLink]);
|
|
17010
17023
|
(0, import_react100.useEffect)(() => {
|
|
17011
17024
|
return editor.registerCommand(
|
|
17012
17025
|
import_lexical4.SELECTION_CHANGE_COMMAND,
|
|
@@ -17026,103 +17039,56 @@ var RichTextToolbar = ({ config }) => {
|
|
|
17026
17039
|
});
|
|
17027
17040
|
});
|
|
17028
17041
|
}, [editor, updateToolbar]);
|
|
17029
|
-
const clearFormatting2 = (0, import_react100.useCallback)(() => {
|
|
17030
|
-
editor.update(() => {
|
|
17031
|
-
const selection = (0, import_lexical4.$getSelection)();
|
|
17032
|
-
if ((0, import_lexical4.$isRangeSelection)(selection)) {
|
|
17033
|
-
const anchor = selection.anchor;
|
|
17034
|
-
const focus = selection.focus;
|
|
17035
|
-
const nodes = selection.getNodes();
|
|
17036
|
-
if (anchor.key === focus.key && anchor.offset === focus.offset) {
|
|
17037
|
-
return;
|
|
17038
|
-
}
|
|
17039
|
-
nodes.forEach((node, idx) => {
|
|
17040
|
-
if ((0, import_lexical4.$isTextNode)(node)) {
|
|
17041
|
-
if (idx === 0 && anchor.offset !== 0) {
|
|
17042
|
-
node = node.splitText(anchor.offset)[1] || node;
|
|
17043
|
-
}
|
|
17044
|
-
if (idx === nodes.length - 1) {
|
|
17045
|
-
node = node.splitText(focus.offset)[0] || node;
|
|
17046
|
-
}
|
|
17047
|
-
if (node.__style !== "") {
|
|
17048
|
-
node.setStyle("");
|
|
17049
|
-
}
|
|
17050
|
-
if (node.__format !== 0) {
|
|
17051
|
-
node.setFormat(0);
|
|
17052
|
-
(0, import_utils5.$getNearestBlockElementAncestorOrThrow)(node).setFormat("");
|
|
17053
|
-
}
|
|
17054
|
-
} else if ((0, import_rich_text.$isHeadingNode)(node) || (0, import_rich_text.$isQuoteNode)(node)) {
|
|
17055
|
-
node.replace((0, import_lexical4.$createParagraphNode)(), true);
|
|
17056
|
-
} else if ((0, import_LexicalDecoratorBlockNode.$isDecoratorBlockNode)(node)) {
|
|
17057
|
-
node.setFormat("");
|
|
17058
|
-
}
|
|
17059
|
-
});
|
|
17060
|
-
}
|
|
17061
|
-
updateToolbar();
|
|
17062
|
-
});
|
|
17063
|
-
}, [editor, updateToolbar]);
|
|
17064
|
-
const elementsThatShouldBeVisibleInDropdown = (0, import_react100.useMemo)(() => {
|
|
17065
|
-
if (activeElement === "paragraph") {
|
|
17066
|
-
return enabledTextualElements;
|
|
17067
|
-
}
|
|
17068
|
-
if (enabledBuiltInElements.some((element) => element.type === activeElement)) {
|
|
17069
|
-
return enabledTextualElements;
|
|
17070
|
-
}
|
|
17071
|
-
return [
|
|
17072
|
-
...enabledTextualElements,
|
|
17073
|
-
{
|
|
17074
|
-
label: getLabelForElement(activeElement),
|
|
17075
|
-
type: activeElement
|
|
17076
|
-
}
|
|
17077
|
-
];
|
|
17078
|
-
}, [enabledBuiltInElements, enabledTextualElements, activeElement]);
|
|
17079
17042
|
return /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { css: toolbar, children: [
|
|
17080
|
-
|
|
17043
|
+
/* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(
|
|
17081
17044
|
Menu,
|
|
17082
17045
|
{
|
|
17083
17046
|
menuLabel: "Elements",
|
|
17084
|
-
menuTrigger: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("button", { css: toolbarButton, title: "Text
|
|
17085
|
-
|
|
17047
|
+
menuTrigger: /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("button", { css: toolbarButton, title: "Text styles", children: [
|
|
17048
|
+
visibleTextualElements.some((element) => element.type === activeElement) ? getLabelForElement(activeElement) : getLabelForElement("paragraph"),
|
|
17086
17049
|
" ",
|
|
17087
17050
|
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Icon, { icon: "chevron-down", css: [toolbarIcon, toolbarChevron], size: "1rem" })
|
|
17088
17051
|
] }),
|
|
17089
17052
|
placement: "bottom-start",
|
|
17090
17053
|
children: [
|
|
17091
|
-
|
|
17092
|
-
|
|
17093
|
-
|
|
17094
|
-
|
|
17095
|
-
...elementsThatShouldBeVisibleInDropdown
|
|
17096
|
-
].map((element) => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
17097
|
-
MenuItem,
|
|
17098
|
-
{
|
|
17099
|
-
onClick: () => {
|
|
17100
|
-
onSelectElement(element.type);
|
|
17054
|
+
[
|
|
17055
|
+
{
|
|
17056
|
+
label: "Normal",
|
|
17057
|
+
type: "paragraph"
|
|
17101
17058
|
},
|
|
17102
|
-
|
|
17103
|
-
|
|
17104
|
-
|
|
17105
|
-
|
|
17059
|
+
...visibleTextualElements
|
|
17060
|
+
].map((element) => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
17061
|
+
MenuItem,
|
|
17062
|
+
{
|
|
17063
|
+
onClick: () => {
|
|
17064
|
+
onSelectElement(element.type);
|
|
17065
|
+
},
|
|
17066
|
+
children: element.label
|
|
17067
|
+
},
|
|
17068
|
+
element.type
|
|
17069
|
+
)),
|
|
17070
|
+
visibleTextualElements.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(MenuItem, { disabled: true, children: "Alternative text styles are not available" }) : null
|
|
17071
|
+
]
|
|
17106
17072
|
}
|
|
17107
|
-
)
|
|
17108
|
-
|
|
17109
|
-
|
|
17073
|
+
),
|
|
17074
|
+
visibleFormatsWithIcon.length > 0 || visibleFormatsWithoutIcon.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { css: toolbarGroup, children: [
|
|
17075
|
+
visibleFormatsWithIcon.map((format) => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Tooltip, { title: format.label, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
17110
17076
|
"button",
|
|
17111
17077
|
{
|
|
17112
17078
|
onClick: () => {
|
|
17113
17079
|
editor.dispatchCommand(import_lexical4.FORMAT_TEXT_COMMAND, format.type);
|
|
17114
17080
|
},
|
|
17115
17081
|
css: [toolbarButton, activeFormats.includes(format.type) ? toolbarButtonActive : null],
|
|
17116
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ToolbarIcon, { icon:
|
|
17082
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ToolbarIcon, { icon: FORMATS_WITH_ICON.get(format.type) })
|
|
17117
17083
|
}
|
|
17118
17084
|
) }, format.type)),
|
|
17119
|
-
|
|
17085
|
+
visibleFormatsWithoutIcon.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
17120
17086
|
Menu,
|
|
17121
17087
|
{
|
|
17122
|
-
menuLabel: "
|
|
17123
|
-
menuTrigger: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("button", { css: toolbarButton, title: "
|
|
17088
|
+
menuLabel: "Alternative text styles",
|
|
17089
|
+
menuTrigger: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)("button", { css: toolbarButton, title: "Alternative text styles", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Icon, { icon: "more-alt", css: toolbarIcon }) }),
|
|
17124
17090
|
placement: "bottom-start",
|
|
17125
|
-
children:
|
|
17091
|
+
children: visibleFormatsWithoutIcon.map((format) => /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
17126
17092
|
MenuItem,
|
|
17127
17093
|
{
|
|
17128
17094
|
onClick: () => {
|
|
@@ -17135,19 +17101,19 @@ var RichTextToolbar = ({ config }) => {
|
|
|
17135
17101
|
}
|
|
17136
17102
|
) : null
|
|
17137
17103
|
] }) : null,
|
|
17138
|
-
|
|
17139
|
-
|
|
17104
|
+
visibleElementsWithIcons.size > 0 ? /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)("div", { css: toolbarGroup, children: [
|
|
17105
|
+
linkElementVisible ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Tooltip, { title: "Link", placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
17140
17106
|
"button",
|
|
17141
17107
|
{
|
|
17142
17108
|
onClick: () => {
|
|
17143
|
-
editor.dispatchCommand(OPEN_LINK_NODE_MODAL_COMMAND, {});
|
|
17109
|
+
isLink ? editor.dispatchCommand(REMOVE_LINK_NODE_COMMAND, {}) : editor.dispatchCommand(OPEN_LINK_NODE_MODAL_COMMAND, {});
|
|
17144
17110
|
},
|
|
17145
17111
|
css: [toolbarButton, isLink ? toolbarButtonActive : null],
|
|
17146
17112
|
children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ToolbarIcon, { icon: "link" })
|
|
17147
17113
|
}
|
|
17148
17114
|
) }) : null,
|
|
17149
|
-
|
|
17150
|
-
|
|
17115
|
+
visibleLists.size > 0 ? /* @__PURE__ */ (0, import_jsx_runtime91.jsxs)(import_jsx_runtime91.Fragment, { children: [
|
|
17116
|
+
visibleLists.has("unorderedList") ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Tooltip, { title: "Bullet List", placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
17151
17117
|
"button",
|
|
17152
17118
|
{
|
|
17153
17119
|
onClick: () => {
|
|
@@ -17157,7 +17123,7 @@ var RichTextToolbar = ({ config }) => {
|
|
|
17157
17123
|
children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ToolbarIcon, { icon: "layout-list" })
|
|
17158
17124
|
}
|
|
17159
17125
|
) }) : null,
|
|
17160
|
-
|
|
17126
|
+
visibleLists.has("orderedList") ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Tooltip, { title: "Ordered List", placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
17161
17127
|
"button",
|
|
17162
17128
|
{
|
|
17163
17129
|
onClick: () => {
|
|
@@ -17168,7 +17134,7 @@ var RichTextToolbar = ({ config }) => {
|
|
|
17168
17134
|
}
|
|
17169
17135
|
) }) : null
|
|
17170
17136
|
] }) : null,
|
|
17171
|
-
|
|
17137
|
+
quoteElementVisible ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Tooltip, { title: "Blockquote", placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
17172
17138
|
"button",
|
|
17173
17139
|
{
|
|
17174
17140
|
onClick: () => {
|
|
@@ -17178,7 +17144,7 @@ var RichTextToolbar = ({ config }) => {
|
|
|
17178
17144
|
children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ToolbarIcon, { icon: "quote" })
|
|
17179
17145
|
}
|
|
17180
17146
|
) }) : null,
|
|
17181
|
-
|
|
17147
|
+
codeElementVisible ? /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Tooltip, { title: "Code Block", placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
17182
17148
|
"button",
|
|
17183
17149
|
{
|
|
17184
17150
|
onClick: () => {
|
|
@@ -17188,31 +17154,118 @@ var RichTextToolbar = ({ config }) => {
|
|
|
17188
17154
|
children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ToolbarIcon, { icon: "code-slash" })
|
|
17189
17155
|
}
|
|
17190
17156
|
) }) : null
|
|
17191
|
-
] }) : null
|
|
17192
|
-
/* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
17193
|
-
"div",
|
|
17194
|
-
{
|
|
17195
|
-
css: [
|
|
17196
|
-
toolbarGroup,
|
|
17197
|
-
{
|
|
17198
|
-
marginLeft: "auto"
|
|
17199
|
-
}
|
|
17200
|
-
],
|
|
17201
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(Tooltip, { title: "Clear formatting", placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(
|
|
17202
|
-
"button",
|
|
17203
|
-
{
|
|
17204
|
-
onClick: () => {
|
|
17205
|
-
clearFormatting2();
|
|
17206
|
-
},
|
|
17207
|
-
css: [toolbarButton],
|
|
17208
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime91.jsx)(ToolbarIcon, { icon: "clear-formatting" })
|
|
17209
|
-
}
|
|
17210
|
-
) })
|
|
17211
|
-
}
|
|
17212
|
-
)
|
|
17157
|
+
] }) : null
|
|
17213
17158
|
] });
|
|
17214
17159
|
};
|
|
17215
17160
|
var RichTextToolbar_default = RichTextToolbar;
|
|
17161
|
+
var useRichTextToolbarState = ({ config }) => {
|
|
17162
|
+
var _a;
|
|
17163
|
+
const enabledBuiltInFormats = (0, import_react100.useMemo)(() => {
|
|
17164
|
+
return richTextBuiltInFormats.filter((format) => {
|
|
17165
|
+
var _a2, _b;
|
|
17166
|
+
return (_b = (_a2 = config == null ? void 0 : config.formatting) == null ? void 0 : _a2.builtIn) == null ? void 0 : _b.includes(format.type);
|
|
17167
|
+
});
|
|
17168
|
+
}, [config]);
|
|
17169
|
+
const enabledBuiltInElements = (0, import_react100.useMemo)(() => {
|
|
17170
|
+
return richTextBuiltInElements.filter((element) => {
|
|
17171
|
+
var _a2, _b;
|
|
17172
|
+
return (_b = (_a2 = config == null ? void 0 : config.elements) == null ? void 0 : _a2.builtIn) == null ? void 0 : _b.includes(element.type);
|
|
17173
|
+
});
|
|
17174
|
+
}, [config]);
|
|
17175
|
+
const enabledBuiltInFormatsWithIcon = (0, import_react100.useMemo)(() => {
|
|
17176
|
+
return enabledBuiltInFormats.filter((format) => FORMATS_WITH_ICON.has(format.type));
|
|
17177
|
+
}, [enabledBuiltInFormats]);
|
|
17178
|
+
const enabledBuiltInFormatsWithoutIcon = enabledBuiltInFormats.filter(
|
|
17179
|
+
(format) => !FORMATS_WITH_ICON.has(format.type)
|
|
17180
|
+
);
|
|
17181
|
+
const [activeFormats, setActiveFormats] = (0, import_react100.useState)([]);
|
|
17182
|
+
const visibleFormatsWithIcon = (0, import_react100.useMemo)(() => {
|
|
17183
|
+
const visibleFormats = /* @__PURE__ */ new Set();
|
|
17184
|
+
activeFormats.filter((type) => FORMATS_WITH_ICON.has(type)).forEach((type) => {
|
|
17185
|
+
visibleFormats.add(type);
|
|
17186
|
+
});
|
|
17187
|
+
enabledBuiltInFormatsWithIcon.forEach((format) => {
|
|
17188
|
+
visibleFormats.add(format.type);
|
|
17189
|
+
});
|
|
17190
|
+
return richTextBuiltInFormats.filter((format) => visibleFormats.has(format.type));
|
|
17191
|
+
}, [activeFormats, enabledBuiltInFormatsWithIcon]);
|
|
17192
|
+
const visibleFormatsWithoutIcon = (0, import_react100.useMemo)(() => {
|
|
17193
|
+
const visibleFormats = /* @__PURE__ */ new Set();
|
|
17194
|
+
activeFormats.filter((type) => !FORMATS_WITH_ICON.has(type)).forEach((type) => {
|
|
17195
|
+
visibleFormats.add(type);
|
|
17196
|
+
});
|
|
17197
|
+
enabledBuiltInFormatsWithoutIcon.forEach((format) => {
|
|
17198
|
+
visibleFormats.add(format.type);
|
|
17199
|
+
});
|
|
17200
|
+
return richTextBuiltInFormats.filter((format) => visibleFormats.has(format.type));
|
|
17201
|
+
}, [activeFormats, enabledBuiltInFormatsWithoutIcon]);
|
|
17202
|
+
const [activeElement, setActiveElement] = (0, import_react100.useState)("paragraph");
|
|
17203
|
+
const enabledTextualElements = enabledBuiltInElements.filter(
|
|
17204
|
+
(element) => TEXTUAL_ELEMENTS.includes(element.type)
|
|
17205
|
+
);
|
|
17206
|
+
const visibleTextualElements = (0, import_react100.useMemo)(() => {
|
|
17207
|
+
if (!TEXTUAL_ELEMENTS.includes(activeElement)) {
|
|
17208
|
+
return enabledTextualElements;
|
|
17209
|
+
}
|
|
17210
|
+
return richTextBuiltInElements.filter(
|
|
17211
|
+
(element) => {
|
|
17212
|
+
var _a2, _b;
|
|
17213
|
+
return TEXTUAL_ELEMENTS.includes(element.type) && (((_b = (_a2 = config == null ? void 0 : config.elements) == null ? void 0 : _a2.builtIn) == null ? void 0 : _b.includes(element.type)) || element.type === activeElement);
|
|
17214
|
+
}
|
|
17215
|
+
);
|
|
17216
|
+
}, [activeElement, (_a = config == null ? void 0 : config.elements) == null ? void 0 : _a.builtIn, enabledTextualElements]);
|
|
17217
|
+
const [isLink, setIsLink] = (0, import_react100.useState)(false);
|
|
17218
|
+
const linkElementVisible = (0, import_react100.useMemo)(() => {
|
|
17219
|
+
return enabledBuiltInElements.some((element) => element.type === "link") || isLink;
|
|
17220
|
+
}, [isLink, enabledBuiltInElements]);
|
|
17221
|
+
const visibleLists = (0, import_react100.useMemo)(() => {
|
|
17222
|
+
return new Set(
|
|
17223
|
+
["orderedList", "unorderedList"].filter(
|
|
17224
|
+
(type) => enabledBuiltInElements.some((element) => element.type === type) || activeElement === type
|
|
17225
|
+
)
|
|
17226
|
+
);
|
|
17227
|
+
}, [activeElement, enabledBuiltInElements]);
|
|
17228
|
+
const quoteElementVisible = (0, import_react100.useMemo)(() => {
|
|
17229
|
+
return enabledBuiltInElements.some((element) => element.type === "quote") || activeElement === "quote";
|
|
17230
|
+
}, [activeElement, enabledBuiltInElements]);
|
|
17231
|
+
const codeElementVisible = (0, import_react100.useMemo)(() => {
|
|
17232
|
+
return enabledBuiltInElements.some((element) => element.type === "code") || activeElement === "code";
|
|
17233
|
+
}, [activeElement, enabledBuiltInElements]);
|
|
17234
|
+
const visibleElementsWithIcons = (0, import_react100.useMemo)(() => {
|
|
17235
|
+
const visibleElements = /* @__PURE__ */ new Set();
|
|
17236
|
+
if (linkElementVisible) {
|
|
17237
|
+
visibleElements.add("link");
|
|
17238
|
+
}
|
|
17239
|
+
if (visibleLists.size > 0) {
|
|
17240
|
+
visibleLists.forEach((type) => {
|
|
17241
|
+
visibleElements.add(type);
|
|
17242
|
+
});
|
|
17243
|
+
}
|
|
17244
|
+
if (quoteElementVisible) {
|
|
17245
|
+
visibleElements.add("quote");
|
|
17246
|
+
}
|
|
17247
|
+
if (codeElementVisible) {
|
|
17248
|
+
visibleElements.add("code");
|
|
17249
|
+
}
|
|
17250
|
+
return visibleElements;
|
|
17251
|
+
}, [codeElementVisible, linkElementVisible, quoteElementVisible, visibleLists]);
|
|
17252
|
+
return {
|
|
17253
|
+
activeFormats,
|
|
17254
|
+
setActiveFormats,
|
|
17255
|
+
activeElement,
|
|
17256
|
+
setActiveElement,
|
|
17257
|
+
visibleFormatsWithIcon,
|
|
17258
|
+
visibleFormatsWithoutIcon,
|
|
17259
|
+
visibleTextualElements,
|
|
17260
|
+
isLink,
|
|
17261
|
+
setIsLink,
|
|
17262
|
+
linkElementVisible,
|
|
17263
|
+
visibleLists,
|
|
17264
|
+
quoteElementVisible,
|
|
17265
|
+
codeElementVisible,
|
|
17266
|
+
visibleElementsWithIcons
|
|
17267
|
+
};
|
|
17268
|
+
};
|
|
17216
17269
|
|
|
17217
17270
|
// src/components/ParameterInputs/ParameterRichText.tsx
|
|
17218
17271
|
var import_jsx_runtime92 = require("@emotion/react/jsx-runtime");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniformdev/design-system",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.26.0",
|
|
4
4
|
"description": "Uniform design system components",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"@storybook/client-api": "6.5.16",
|
|
24
24
|
"@storybook/react": "6.5.16",
|
|
25
25
|
"@types/react": "18.2.7",
|
|
26
|
-
"@uniformdev/canvas": "^19.
|
|
27
|
-
"@uniformdev/richtext": "^19.
|
|
26
|
+
"@uniformdev/canvas": "^19.26.0",
|
|
27
|
+
"@uniformdev/richtext": "^19.26.0",
|
|
28
28
|
"autoprefixer": "10.4.14",
|
|
29
29
|
"hygen": "6.2.11",
|
|
30
30
|
"postcss": "8.4.24",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "860f4f8ae7161b5fb0b7a670bdfd1566fce45bee"
|
|
71
71
|
}
|