@uniformdev/design-system 19.185.1-alpha.8 → 19.186.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.js CHANGED
@@ -19567,7 +19567,8 @@ var KeyValueInput = ({
19567
19567
  onChange: (itemValue) => handleUpdateOptionRow(index, itemValue),
19568
19568
  onDelete: () => handleDeleteOptionRow(index),
19569
19569
  onFocusChange: handleFocusChange,
19570
- "data-testid": "key-value-input-item"
19570
+ "data-testid": "key-value-input-item",
19571
+ onEnter: handleAddOptionRow
19571
19572
  },
19572
19573
  isDragging ? id : index
19573
19574
  )) })
@@ -19602,7 +19603,8 @@ var KeyValueInputItem = ({
19602
19603
  error,
19603
19604
  onFocusChange,
19604
19605
  disabledDelete = false,
19605
- disabledDnd = false
19606
+ disabledDnd = false,
19607
+ onEnter
19606
19608
  }) => {
19607
19609
  const { attributes, listeners, setNodeRef, transform, transition, setActivatorNodeRef, isSorting } = (0, import_sortable.useSortable)({
19608
19610
  id,
@@ -19612,6 +19614,11 @@ var KeyValueInputItem = ({
19612
19614
  transform: import_utilities.CSS.Transform.toString(transform),
19613
19615
  transition
19614
19616
  };
19617
+ const handleEnter = (e) => {
19618
+ if (e.key === "Enter") {
19619
+ onEnter();
19620
+ }
19621
+ };
19615
19622
  return /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { css: rowWrapper, ref: setNodeRef, style, children: [
19616
19623
  /* @__PURE__ */ (0, import_jsx_runtime92.jsx)(DragHandle, { disableDnd: disabledDnd, ref: setActivatorNodeRef, ...attributes, ...listeners }),
19617
19624
  /* @__PURE__ */ (0, import_jsx_runtime92.jsxs)("div", { css: SelectKeyValueRowStyles, "data-testid": "key-value-input-item", children: [
@@ -19631,6 +19638,7 @@ var KeyValueInputItem = ({
19631
19638
  },
19632
19639
  onBlur: () => onFocusChange == null ? void 0 : onFocusChange(false),
19633
19640
  onFocus: () => onFocusChange == null ? void 0 : onFocusChange(true),
19641
+ onKeyDown: handleEnter,
19634
19642
  value: value.key,
19635
19643
  errorMessage: isSorting ? void 0 : error == null ? void 0 : error.key,
19636
19644
  "data-testid": "key"
@@ -19642,12 +19650,15 @@ var KeyValueInputItem = ({
19642
19650
  label: valueLabel,
19643
19651
  showLabel: false,
19644
19652
  disabled: disabled2,
19645
- onChange: (e) => onChange == null ? void 0 : onChange({
19646
- key: value.key,
19647
- value: e.currentTarget.value
19648
- }),
19653
+ onChange: (e) => {
19654
+ onChange == null ? void 0 : onChange({
19655
+ key: value.key,
19656
+ value: e.currentTarget.value
19657
+ });
19658
+ },
19649
19659
  onBlur: () => onFocusChange == null ? void 0 : onFocusChange(false),
19650
19660
  onFocus: () => onFocusChange == null ? void 0 : onFocusChange(true),
19661
+ onKeyDown: handleEnter,
19651
19662
  value: value.value,
19652
19663
  errorMessage: isSorting ? void 0 : error == null ? void 0 : error.value,
19653
19664
  "data-testid": "value"
@@ -21828,8 +21839,8 @@ var import_react141 = require("react");
21828
21839
  // src/components/ParameterInputs/ParameterLabel.tsx
21829
21840
  init_emotion_jsx_shim();
21830
21841
  var import_jsx_runtime121 = require("@emotion/react/jsx-runtime");
21831
- var ParameterLabel = ({ id, asSpan, children, ...props }) => {
21832
- return !asSpan ? /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("label", { ...props, htmlFor: id, css: labelText2, children }) : /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("span", { "aria-labelledby": id, css: labelText2, children });
21842
+ var ParameterLabel = ({ id, asSpan, children, testId, ...props }) => {
21843
+ return !asSpan ? /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("label", { ...props, htmlFor: id, css: labelText2, "data-testid": testId, children }) : /* @__PURE__ */ (0, import_jsx_runtime121.jsx)("span", { "aria-labelledby": id, css: labelText2, children });
21833
21844
  };
21834
21845
 
21835
21846
  // src/components/ParameterInputs/ParameterMenuButton.tsx
@@ -21956,7 +21967,7 @@ var ParameterShell = ({
21956
21967
  label,
21957
21968
  labelTrailingIcon != null ? labelTrailingIcon : null
21958
21969
  ] }),
21959
- !title2 ? null : /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(ParameterLabel, { id, asSpan: true, children: [
21970
+ !title2 ? null : /* @__PURE__ */ (0, import_jsx_runtime123.jsxs)(ParameterLabel, { id, asSpan: true, testId: "parameter-label", children: [
21960
21971
  labelLeadingIcon != null ? labelLeadingIcon : null,
21961
21972
  title2,
21962
21973
  labelTrailingIcon != null ? labelTrailingIcon : null
@@ -22281,7 +22292,7 @@ var ParameterNameAndPublicIdInput = ({
22281
22292
 
22282
22293
  // src/components/ParameterInputs/ParameterRichText.tsx
22283
22294
  init_emotion_jsx_shim();
22284
- var import_react157 = require("@emotion/react");
22295
+ var import_react156 = require("@emotion/react");
22285
22296
  var import_list3 = require("@lexical/list");
22286
22297
  var import_markdown = require("@lexical/markdown");
22287
22298
  var import_LexicalComposer = require("@lexical/react/LexicalComposer");
@@ -22347,10 +22358,6 @@ var richTextBuiltInElements = [
22347
22358
  label: "Table",
22348
22359
  type: "table"
22349
22360
  },
22350
- {
22351
- label: "Asset",
22352
- type: "asset"
22353
- },
22354
22361
  {
22355
22362
  label: "Dynamic Token",
22356
22363
  type: "variable"
@@ -22398,7 +22405,7 @@ var getLabelForElement = (type) => {
22398
22405
  // src/components/ParameterInputs/ParameterRichText.tsx
22399
22406
  var import_fast_equals2 = require("fast-equals");
22400
22407
  var import_lexical9 = require("lexical");
22401
- var import_react158 = require("react");
22408
+ var import_react157 = require("react");
22402
22409
 
22403
22410
  // src/components/ParameterInputs/rich-text/CustomCodeNode.ts
22404
22411
  init_emotion_jsx_shim();
@@ -23337,792 +23344,372 @@ function ListIndentPlugin({ maxDepth }) {
23337
23344
  return null;
23338
23345
  }
23339
23346
 
23340
- // src/components/ParameterInputs/rich-text/TableActionMenuPlugin.tsx
23347
+ // src/components/ParameterInputs/rich-text/RichTextToolbar.tsx
23341
23348
  init_emotion_jsx_shim();
23342
23349
  var import_react149 = require("@emotion/react");
23350
+ var import_code2 = require("@lexical/code");
23351
+ var import_list2 = require("@lexical/list");
23343
23352
  var import_LexicalComposerContext4 = require("@lexical/react/LexicalComposerContext");
23344
- var import_useLexicalEditable = require("@lexical/react/useLexicalEditable");
23353
+ var import_rich_text = require("@lexical/rich-text");
23354
+ var import_selection2 = require("@lexical/selection");
23345
23355
  var import_table = require("@lexical/table");
23356
+ var import_utils10 = require("@lexical/utils");
23346
23357
  var import_lexical5 = require("lexical");
23347
23358
  var import_react150 = require("react");
23348
23359
  var import_jsx_runtime130 = require("@emotion/react/jsx-runtime");
23349
- function computeSelectionCount(selection) {
23350
- const selectionShape = selection.getShape();
23351
- return {
23352
- columns: selectionShape.toX - selectionShape.fromX + 1,
23353
- rows: selectionShape.toY - selectionShape.fromY + 1
23354
- };
23355
- }
23356
- var tableActionMenuTrigger = import_react149.css`
23357
- position: absolute;
23358
- transform: translate(calc(-100% - 1px), 1px);
23360
+ var toolbar = import_react149.css`
23361
+ ${scrollbarStyles}
23362
+ background: var(--gray-50);
23363
+ border-radius: var(--rounded-base);
23364
+ display: flex;
23365
+ /* We add 1px because we use a 1px wide separator */
23366
+ gap: calc(var(--spacing-sm) + 1px);
23367
+ margin: 0 0 calc(var(--spacing-sm) + var(--spacing-xs)) 0;
23368
+ overflow: auto;
23369
+ padding: var(--spacing-sm);
23370
+ position: sticky;
23371
+ top: calc(var(--spacing-sm) * -2);
23372
+ z-index: 10;
23359
23373
  `;
23360
- var TableActionMenuTrigger = (0, import_react150.forwardRef)((props, ref) => {
23361
- const { tableCellEl, positioningAnchorEl, ...rest } = props;
23362
- const [coordinates, setCoordinates] = (0, import_react150.useState)({ x: 0, y: 0 });
23363
- (0, import_react150.useLayoutEffect)(() => {
23364
- const rect = tableCellEl.getBoundingClientRect();
23365
- const parentRect = positioningAnchorEl.getBoundingClientRect();
23366
- const relativeX = rect.right - parentRect.left + positioningAnchorEl.scrollLeft;
23367
- const relativeY = rect.top - parentRect.top + positioningAnchorEl.scrollTop;
23368
- setCoordinates({ x: relativeX, y: relativeY });
23369
- }, [tableCellEl, positioningAnchorEl]);
23370
- return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
23371
- IconButton,
23372
- {
23373
- ref,
23374
- css: [
23375
- tableActionMenuTrigger,
23376
- {
23377
- top: coordinates.y,
23378
- left: coordinates.x
23379
- }
23380
- ],
23381
- size: "xs",
23382
- buttonType: "unimportant",
23383
- ...rest,
23384
- children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Icon, { icon: "chevron-down", size: "1rem", iconColor: "currentColor" })
23385
- }
23386
- );
23387
- });
23388
- TableActionMenuTrigger.displayName = "TableActionMenuTrigger";
23389
- function TableActionMenu({
23390
- tableCellNode: _tableCellNode,
23391
- menuPortalEl,
23392
- tableCellEl,
23393
- positioningAnchorEl
23394
- }) {
23374
+ var toolbarGroup = import_react149.css`
23375
+ display: flex;
23376
+ flex-shrink: 0;
23377
+ gap: var(--spacing-xs);
23378
+ position: relative;
23379
+
23380
+ &:not(:first-child)::before {
23381
+ background-color: var(--gray-300);
23382
+ content: '';
23383
+ display: block;
23384
+ height: 24px;
23385
+ left: calc(var(--spacing-xs) * -1);
23386
+ position: absolute;
23387
+ top: 4px;
23388
+ width: 1px;
23389
+ }
23390
+ `;
23391
+ var richTextToolbarButton = import_react149.css`
23392
+ align-items: center;
23393
+ appearance: none;
23394
+ border: 0;
23395
+ border-radius: var(--rounded-sm);
23396
+ box-shadow: none;
23397
+ color: var(--gray-900);
23398
+ display: flex;
23399
+ flex-shrink: 0;
23400
+ height: 32px;
23401
+ justify-content: center;
23402
+ min-width: 32px;
23403
+ padding: 0 var(--spacing-sm);
23404
+ `;
23405
+ var richTextToolbarButtonActive = import_react149.css`
23406
+ background: var(--gray-200);
23407
+ `;
23408
+ var textStyleButton = import_react149.css`
23409
+ justify-content: space-between;
23410
+ min-width: 7rem;
23411
+ `;
23412
+ var toolbarIcon = import_react149.css`
23413
+ color: inherit;
23414
+ `;
23415
+ var toolbarChevron = import_react149.css`
23416
+ margin-left: var(--spacing-xs);
23417
+ `;
23418
+ var RichTextToolbarIcon = ({ icon }) => {
23419
+ return /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Icon, { icon, css: toolbarIcon, size: "1rem" });
23420
+ };
23421
+ var FORMATS_WITH_ICON = /* @__PURE__ */ new Map([
23422
+ ["bold", "format-bold"],
23423
+ ["italic", "format-italic"],
23424
+ ["underline", "format-underline"],
23425
+ ["strikethrough", "format-strike"],
23426
+ ["code", "format-code"],
23427
+ ["superscript", "format-superscript"],
23428
+ ["subscript", "format-subscript"]
23429
+ ]);
23430
+ var HEADING_ELEMENTS = ["h1", "h2", "h3", "h4", "h5", "h6"];
23431
+ var TEXTUAL_ELEMENTS = HEADING_ELEMENTS;
23432
+ var RichTextToolbar = ({ config, customControls, onInsertTable }) => {
23395
23433
  const [editor] = (0, import_LexicalComposerContext4.useLexicalComposerContext)();
23396
- const [tableCellNode, updateTableCellNode] = (0, import_react150.useState)(_tableCellNode);
23397
- const [selectionCounts, updateSelectionCounts] = (0, import_react150.useState)({
23398
- columns: 1,
23399
- rows: 1
23400
- });
23401
- const [menuTriggerKey, setMenuTriggerKey] = (0, import_react150.useState)(0);
23402
- const incrementMenuTriggerKey = () => {
23403
- setMenuTriggerKey((key) => key += 1);
23404
- };
23405
- (0, import_react150.useEffect)(() => {
23406
- return editor.registerMutationListener(
23407
- import_table.TableCellNode,
23408
- (nodeMutations) => {
23409
- const nodeUpdated = nodeMutations.get(tableCellNode.getKey()) === "updated";
23410
- if (nodeUpdated) {
23411
- editor.getEditorState().read(() => {
23412
- updateTableCellNode(tableCellNode.getLatest());
23413
- });
23414
- }
23415
- },
23416
- { skipInitialization: true }
23417
- );
23418
- }, [editor, tableCellNode]);
23419
- (0, import_react150.useEffect)(() => {
23420
- editor.getEditorState().read(() => {
23421
- const selection = (0, import_lexical5.$getSelection)();
23422
- if ((0, import_table.$isTableSelection)(selection)) {
23423
- updateSelectionCounts(computeSelectionCount(selection));
23424
- }
23425
- });
23426
- }, [editor]);
23427
- const clearTableSelection = (0, import_react150.useCallback)(() => {
23428
- editor.update(() => {
23429
- if (tableCellNode.isAttached()) {
23430
- const tableNode = (0, import_table.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
23431
- const tableElement2 = editor.getElementByKey(
23432
- tableNode.getKey()
23433
- );
23434
- if (!tableElement2) {
23435
- throw new Error("Expected to find tableElement in DOM");
23436
- }
23437
- const tableSelection = (0, import_table.getTableObserverFromTableElement)(tableElement2);
23438
- if (tableSelection !== null) {
23439
- tableSelection.clearHighlight();
23440
- }
23441
- tableNode.markDirty();
23442
- updateTableCellNode(tableCellNode.getLatest());
23443
- }
23444
- const rootNode = (0, import_lexical5.$getRoot)();
23445
- rootNode.selectStart();
23446
- });
23447
- }, [editor, tableCellNode]);
23448
- const insertTableRowAtSelection = (0, import_react150.useCallback)(
23449
- (shouldInsertAfter) => {
23450
- editor.update(() => {
23451
- (0, import_table.$insertTableRow__EXPERIMENTAL)(shouldInsertAfter);
23452
- });
23453
- incrementMenuTriggerKey();
23454
- },
23455
- [editor]
23456
- );
23457
- const insertTableColumnAtSelection = (0, import_react150.useCallback)(
23458
- (shouldInsertAfter) => {
23434
+ const {
23435
+ activeElement,
23436
+ setActiveElement,
23437
+ activeFormats,
23438
+ setActiveFormats,
23439
+ visibleFormatsWithIcon,
23440
+ visibleFormatsWithoutIcon,
23441
+ visibleTextualElements,
23442
+ isLink,
23443
+ setIsLink,
23444
+ linkElementVisible,
23445
+ visibleLists,
23446
+ codeElementVisible,
23447
+ quoteElementVisible,
23448
+ visibleElementsWithIcons,
23449
+ visibleInsertElementsWithIcons,
23450
+ tableElementVisible
23451
+ } = useRichTextToolbarState({ config });
23452
+ const onSelectElement = (type) => {
23453
+ if (activeElement === type) {
23454
+ return;
23455
+ }
23456
+ editor.focus(() => {
23459
23457
  editor.update(() => {
23460
- for (let i = 0; i < selectionCounts.columns; i++) {
23461
- (0, import_table.$insertTableColumn__EXPERIMENTAL)(shouldInsertAfter);
23458
+ const selection = (0, import_lexical5.$getSelection)();
23459
+ if (HEADING_ELEMENTS.includes(type)) {
23460
+ (0, import_selection2.$setBlocksType)(selection, () => (0, import_rich_text.$createHeadingNode)(type));
23461
+ } else if (type === "paragraph") {
23462
+ (0, import_selection2.$setBlocksType)(selection, () => (0, import_lexical5.$createParagraphNode)());
23463
+ } else if (type === "quote") {
23464
+ (0, import_selection2.$setBlocksType)(selection, () => (0, import_rich_text.$createQuoteNode)());
23465
+ } else if (type === "code") {
23466
+ (0, import_selection2.$setBlocksType)(selection, () => (0, import_code2.$createCodeNode)());
23467
+ } else if (type === "table" && onInsertTable) {
23468
+ onInsertTable().then((dimensions) => {
23469
+ if (!dimensions) {
23470
+ return;
23471
+ }
23472
+ const { rows, columns } = dimensions;
23473
+ editor.focus(() => {
23474
+ editor.update(() => {
23475
+ (0, import_lexical5.$insertNodes)([(0, import_table.$createTableNodeWithDimensions)(rows, columns, false)]);
23476
+ });
23477
+ });
23478
+ });
23462
23479
  }
23463
23480
  });
23464
- incrementMenuTriggerKey();
23465
- },
23466
- [editor, selectionCounts.columns]
23467
- );
23468
- const deleteTableRowAtSelection = (0, import_react150.useCallback)(() => {
23469
- editor.update(() => {
23470
- (0, import_table.$deleteTableRow__EXPERIMENTAL)();
23471
- });
23472
- incrementMenuTriggerKey();
23473
- }, [editor]);
23474
- const deleteTableAtSelection = (0, import_react150.useCallback)(() => {
23475
- editor.update(() => {
23476
- const tableNode = (0, import_table.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
23477
- tableNode.remove();
23478
- clearTableSelection();
23479
23481
  });
23480
- }, [editor, tableCellNode, clearTableSelection]);
23481
- const deleteTableColumnAtSelection = (0, import_react150.useCallback)(() => {
23482
- editor.update(() => {
23483
- (0, import_table.$deleteTableColumn__EXPERIMENTAL)();
23484
- });
23485
- incrementMenuTriggerKey();
23486
- }, [editor]);
23487
- const toggleTableRowIsHeader = (0, import_react150.useCallback)(() => {
23488
- editor.update(() => {
23489
- const tableNode = (0, import_table.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
23490
- const tableRowIndex = (0, import_table.$getTableRowIndexFromTableCellNode)(tableCellNode);
23491
- const tableRows = tableNode.getChildren();
23492
- if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {
23493
- throw new Error("Expected table cell to be inside of table row.");
23494
- }
23495
- const tableRow2 = tableRows[tableRowIndex];
23496
- if (!(0, import_table.$isTableRowNode)(tableRow2)) {
23497
- throw new Error("Expected table row");
23482
+ };
23483
+ const updateToolbar = (0, import_react150.useCallback)(() => {
23484
+ const selection = (0, import_lexical5.$getSelection)();
23485
+ if (!(0, import_lexical5.$isRangeSelection)(selection)) {
23486
+ return;
23487
+ }
23488
+ const newActiveFormats = [];
23489
+ for (const format of richTextBuiltInFormats) {
23490
+ if (selection.hasFormat(format.type)) {
23491
+ newActiveFormats.push(format.type);
23498
23492
  }
23499
- tableRow2.getChildren().forEach((tableCell) => {
23500
- if (!(0, import_table.$isTableCellNode)(tableCell)) {
23501
- throw new Error("Expected table cell");
23502
- }
23503
- tableCell.toggleHeaderStyle(import_table.TableCellHeaderStates.ROW);
23504
- });
23505
- clearTableSelection();
23493
+ }
23494
+ setActiveFormats(newActiveFormats);
23495
+ const anchorNode = selection.anchor.getNode();
23496
+ let element = anchorNode.getKey() === "root" ? anchorNode : (0, import_utils10.$findMatchingParent)(anchorNode, (e) => {
23497
+ const parent = e.getParent();
23498
+ return parent !== null && (0, import_lexical5.$isRootOrShadowRoot)(parent);
23506
23499
  });
23507
- }, [editor, tableCellNode, clearTableSelection]);
23508
- const toggleTableColumnIsHeader = (0, import_react150.useCallback)(() => {
23509
- editor.update(() => {
23510
- const tableNode = (0, import_table.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
23511
- const tableColumnIndex = (0, import_table.$getTableColumnIndexFromTableCellNode)(tableCellNode);
23512
- const tableRows = tableNode.getChildren();
23513
- const maxRowsLength = Math.max(...tableRows.map((row) => row.getChildren().length));
23514
- if (tableColumnIndex >= maxRowsLength || tableColumnIndex < 0) {
23515
- throw new Error("Expected table cell to be inside of table row.");
23516
- }
23517
- for (let r = 0; r < tableRows.length; r++) {
23518
- const tableRow2 = tableRows[r];
23519
- if (!(0, import_table.$isTableRowNode)(tableRow2)) {
23520
- throw new Error("Expected table row");
23521
- }
23522
- const tableCells = tableRow2.getChildren();
23523
- if (tableColumnIndex >= tableCells.length) {
23524
- continue;
23525
- }
23526
- const tableCell = tableCells[tableColumnIndex];
23527
- if (!(0, import_table.$isTableCellNode)(tableCell)) {
23528
- throw new Error("Expected table cell");
23529
- }
23530
- tableCell.toggleHeaderStyle(import_table.TableCellHeaderStates.COLUMN);
23500
+ if (element === null) {
23501
+ element = anchorNode.getTopLevelElementOrThrow();
23502
+ }
23503
+ const elementKey = element.getKey();
23504
+ const elementDOM = editor.getElementByKey(elementKey);
23505
+ if (elementDOM !== null) {
23506
+ if ((0, import_list2.$isListNode)(element)) {
23507
+ const parentList = (0, import_utils10.$getNearestNodeOfType)(anchorNode, import_list2.ListNode);
23508
+ const type = parentList ? parentList.getListType() : element.getListType();
23509
+ setActiveElement(type === "bullet" ? "unorderedList" : "orderedList");
23510
+ } else {
23511
+ const type = (0, import_rich_text.$isHeadingNode)(element) ? element.getTag() : element.getType();
23512
+ setActiveElement(type);
23531
23513
  }
23532
- clearTableSelection();
23533
- });
23534
- }, [editor, tableCellNode, clearTableSelection]);
23535
- const menuItemCss = (0, import_react149.css)({
23536
- fontSize: "var(--fs-sm)"
23537
- });
23538
- return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
23539
- Menu,
23540
- {
23541
- menuTrigger: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
23542
- TableActionMenuTrigger,
23543
- {
23544
- tableCellEl,
23545
- positioningAnchorEl
23546
- },
23547
- menuTriggerKey
23548
- ),
23549
- portalElement: menuPortalEl,
23550
- maxMenuHeight: "300px",
23551
- children: [
23552
- /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
23553
- MenuItem,
23554
- {
23555
- onClick: () => {
23556
- insertTableRowAtSelection(false);
23557
- },
23558
- css: menuItemCss,
23559
- children: [
23560
- "Insert ",
23561
- selectionCounts.rows === 1 ? "row" : `${selectionCounts.rows} rows`,
23562
- " above"
23563
- ]
23564
- }
23565
- ),
23566
- /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(MenuItem, { onClick: () => insertTableRowAtSelection(true), css: menuItemCss, children: [
23567
- "Insert ",
23568
- selectionCounts.rows === 1 ? "row" : `${selectionCounts.rows} rows`,
23569
- " below"
23570
- ] }),
23571
- /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(MenuItemSeparator, {}),
23572
- /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(MenuItem, { onClick: () => insertTableColumnAtSelection(false), css: menuItemCss, children: [
23573
- "Insert ",
23574
- selectionCounts.columns === 1 ? "column" : `${selectionCounts.columns} columns`,
23575
- " left"
23576
- ] }),
23577
- /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(MenuItem, { onClick: () => insertTableColumnAtSelection(true), css: menuItemCss, children: [
23578
- "Insert ",
23579
- selectionCounts.columns === 1 ? "column" : `${selectionCounts.columns} columns`,
23580
- " right"
23581
- ] }),
23582
- /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(MenuItemSeparator, {}),
23583
- /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(MenuItem, { onClick: () => deleteTableColumnAtSelection(), css: menuItemCss, children: "Delete column" }),
23584
- /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(MenuItem, { onClick: () => deleteTableRowAtSelection(), css: menuItemCss, children: "Delete row" }),
23585
- /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(MenuItem, { onClick: () => deleteTableAtSelection(), css: menuItemCss, children: "Delete table" }),
23586
- /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(MenuItemSeparator, {}),
23587
- /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(MenuItem, { onClick: () => toggleTableRowIsHeader(), css: menuItemCss, children: [
23588
- (tableCellNode.__headerState & import_table.TableCellHeaderStates.ROW) === import_table.TableCellHeaderStates.ROW ? "Remove" : "Add",
23589
- " ",
23590
- "row header"
23591
- ] }),
23592
- /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(MenuItem, { onClick: () => toggleTableColumnIsHeader(), css: menuItemCss, children: [
23593
- (tableCellNode.__headerState & import_table.TableCellHeaderStates.COLUMN) === import_table.TableCellHeaderStates.COLUMN ? "Remove" : "Add",
23594
- " ",
23595
- "column header"
23596
- ] })
23597
- ]
23598
23514
  }
23599
- );
23600
- }
23601
- function TableCellActionMenuContainer({
23602
- menuPortalEl,
23603
- positioningAnchorEl
23604
- }) {
23605
- const [editor] = (0, import_LexicalComposerContext4.useLexicalComposerContext)();
23606
- const [tableCellNode, setTableMenuCellNode] = (0, import_react150.useState)(null);
23607
- const [tableCellNodeEl, _setTableMenuCellNodeEl] = (0, import_react150.useState)(null);
23608
- const [tableCellMenuPortalEl, setTableMenuCellMenuPortalEl] = (0, import_react150.useState)(null);
23609
- (0, import_react150.useEffect)(() => {
23610
- const newPortalEl = document.createElement("div");
23611
- setTableMenuCellMenuPortalEl(newPortalEl);
23612
- menuPortalEl.appendChild(newPortalEl);
23613
- return () => {
23614
- newPortalEl.remove();
23615
- };
23616
- }, [menuPortalEl]);
23617
- const setTableMenuCellNodeElem = (0, import_react150.useCallback)((elem) => {
23618
- if (elem) {
23619
- _setTableMenuCellNodeEl(elem);
23515
+ const node = getSelectedNode(selection);
23516
+ if (getLinkAncestor(node) !== null) {
23517
+ setIsLink(true);
23620
23518
  } else {
23621
- _setTableMenuCellNodeEl(null);
23622
- }
23623
- }, []);
23624
- const $moveMenu = (0, import_react150.useCallback)(() => {
23625
- const selection = (0, import_lexical5.$getSelection)();
23626
- const nativeSelection = window.getSelection();
23627
- const activeElement = document.activeElement;
23628
- if (selection == null) {
23629
- setTableMenuCellNode(null);
23630
- return;
23631
- }
23632
- const rootElement = editor.getRootElement();
23633
- if ((0, import_lexical5.$isRangeSelection)(selection) && rootElement !== null && nativeSelection !== null && rootElement.contains(nativeSelection.anchorNode)) {
23634
- const tableCellNodeFromSelection = (0, import_table.$getTableCellNodeFromLexicalNode)(selection.anchor.getNode());
23635
- if (tableCellNodeFromSelection == null) {
23636
- setTableMenuCellNode(null);
23637
- setTableMenuCellNodeElem(null);
23638
- return;
23639
- }
23640
- const tableCellParentNodeDOM = editor.getElementByKey(tableCellNodeFromSelection.getKey());
23641
- if (tableCellParentNodeDOM == null) {
23642
- setTableMenuCellNode(null);
23643
- setTableMenuCellNodeElem(null);
23644
- return;
23645
- }
23646
- setTableMenuCellNode(tableCellNodeFromSelection);
23647
- setTableMenuCellNodeElem(tableCellParentNodeDOM);
23648
- } else if (!activeElement) {
23649
- setTableMenuCellNode(null);
23650
- setTableMenuCellNodeElem(null);
23519
+ setIsLink(false);
23651
23520
  }
23652
- }, [editor, setTableMenuCellNodeElem]);
23521
+ }, [editor, setActiveElement, setActiveFormats, setIsLink]);
23653
23522
  (0, import_react150.useEffect)(() => {
23654
- return editor.registerUpdateListener(() => {
23655
- editor.getEditorState().read(() => {
23656
- $moveMenu();
23523
+ return editor.registerCommand(
23524
+ import_lexical5.SELECTION_CHANGE_COMMAND,
23525
+ (_payload) => {
23526
+ updateToolbar();
23527
+ return false;
23528
+ },
23529
+ import_lexical5.COMMAND_PRIORITY_CRITICAL
23530
+ );
23531
+ }, [editor, updateToolbar]);
23532
+ (0, import_react150.useEffect)(() => {
23533
+ return editor.registerUpdateListener(({ editorState }) => {
23534
+ requestAnimationFrame(() => {
23535
+ editorState.read(() => {
23536
+ updateToolbar();
23537
+ });
23657
23538
  });
23658
23539
  });
23659
- });
23660
- return tableCellNode != null && tableCellNodeEl != null && tableCellMenuPortalEl != null && /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
23661
- TableActionMenu,
23662
- {
23663
- tableCellNode,
23664
- menuPortalEl: tableCellMenuPortalEl,
23665
- tableCellEl: tableCellNodeEl,
23666
- positioningAnchorEl
23667
- },
23668
- tableCellNode.getKey()
23669
- );
23670
- }
23671
- function TableActionMenuPlugin({
23672
- positioningAnchorEl,
23673
- menuPortalEl
23674
- }) {
23675
- const isEditable = (0, import_useLexicalEditable.useLexicalEditable)();
23676
- return isEditable ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(TableCellActionMenuContainer, { menuPortalEl, positioningAnchorEl }) : null;
23677
- }
23678
-
23679
- // src/components/ParameterInputs/rich-text/TableCellResizerPlugin.tsx
23680
- init_emotion_jsx_shim();
23681
- var import_react151 = require("@emotion/react");
23682
- var import_LexicalComposerContext5 = require("@lexical/react/LexicalComposerContext");
23683
- var import_useLexicalEditable2 = require("@lexical/react/useLexicalEditable");
23684
- var import_table2 = require("@lexical/table");
23685
- var import_utils10 = require("@lexical/utils");
23686
- var import_lexical6 = require("lexical");
23687
- var import_react152 = require("react");
23688
- var import_react_dom3 = require("react-dom");
23689
- var import_jsx_runtime131 = require("@emotion/react/jsx-runtime");
23690
- var MIN_ROW_HEIGHT = 33;
23691
- var MIN_COLUMN_WIDTH = 50;
23692
- var tableResizer = import_react151.css`
23693
- position: absolute;
23694
- z-index: var(--z-10);
23695
- `;
23696
- var fixedGetDOMCellFromTarget = (node) => {
23697
- let currentNode = node;
23698
- while (currentNode != null) {
23699
- const nodeName = currentNode.nodeName;
23700
- if (nodeName === "TD" || nodeName === "TH") {
23701
- const cell2 = currentNode._cell;
23702
- if (cell2 === void 0) {
23703
- return {
23704
- elem: currentNode
23705
- };
23540
+ }, [editor, updateToolbar]);
23541
+ return /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("div", { css: toolbar, children: [
23542
+ /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
23543
+ Menu,
23544
+ {
23545
+ menuTrigger: /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("button", { css: [richTextToolbarButton, textStyleButton], title: "Text styles", children: [
23546
+ visibleTextualElements.some((element) => element.type === activeElement) ? getLabelForElement(activeElement) : getLabelForElement("paragraph"),
23547
+ " ",
23548
+ /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Icon, { icon: "chevron-down", css: [toolbarIcon, toolbarChevron], size: "1rem" })
23549
+ ] }),
23550
+ placement: "bottom-start",
23551
+ children: [
23552
+ [
23553
+ {
23554
+ label: "Normal",
23555
+ type: "paragraph"
23556
+ },
23557
+ ...visibleTextualElements
23558
+ ].map((element) => /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
23559
+ MenuItem,
23560
+ {
23561
+ onClick: () => {
23562
+ onSelectElement(element.type);
23563
+ },
23564
+ children: element.label
23565
+ },
23566
+ element.type
23567
+ )),
23568
+ visibleTextualElements.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(MenuItem, { disabled: true, children: "Alternative text styles are not available" }) : null
23569
+ ]
23706
23570
  }
23707
- return cell2;
23708
- }
23709
- currentNode = currentNode.parentNode;
23710
- }
23711
- return null;
23712
- };
23713
- function TableCellResizer({ editor, positioningAnchorEl }) {
23714
- const targetRef = (0, import_react152.useRef)(null);
23715
- const resizerRef = (0, import_react152.useRef)(null);
23716
- const tableRectRef = (0, import_react152.useRef)(null);
23717
- const mouseStartPosRef = (0, import_react152.useRef)(null);
23718
- const [mouseCurrentPos, updateMouseCurrentPos] = (0, import_react152.useState)(null);
23719
- const [activeCell, updateActiveCell] = (0, import_react152.useState)(null);
23720
- const [isMouseDown, updateIsMouseDown] = (0, import_react152.useState)(false);
23721
- const [draggingDirection, updateDraggingDirection] = (0, import_react152.useState)(null);
23722
- const resetState = (0, import_react152.useCallback)(() => {
23723
- updateActiveCell(null);
23724
- targetRef.current = null;
23725
- updateDraggingDirection(null);
23726
- mouseStartPosRef.current = null;
23727
- tableRectRef.current = null;
23728
- }, []);
23729
- const isMouseDownOnEvent = (event) => {
23730
- return (event.buttons & 1) === 1;
23731
- };
23732
- (0, import_react152.useEffect)(() => {
23733
- const onMouseMove = (event) => {
23734
- setTimeout(() => {
23735
- const target = event.target;
23736
- if (draggingDirection) {
23737
- updateMouseCurrentPos({
23738
- x: event.clientX,
23739
- y: event.clientY
23740
- });
23741
- return;
23742
- }
23743
- updateIsMouseDown(isMouseDownOnEvent(event));
23744
- if (resizerRef.current && resizerRef.current.contains(target)) {
23745
- return;
23571
+ ),
23572
+ visibleFormatsWithIcon.length > 0 || visibleFormatsWithoutIcon.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("div", { css: toolbarGroup, children: [
23573
+ visibleFormatsWithIcon.map((format) => /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Tooltip, { title: format.label, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
23574
+ "button",
23575
+ {
23576
+ onClick: () => {
23577
+ editor.dispatchCommand(import_lexical5.FORMAT_TEXT_COMMAND, format.type);
23578
+ },
23579
+ css: [
23580
+ richTextToolbarButton,
23581
+ activeFormats.includes(format.type) ? richTextToolbarButtonActive : null
23582
+ ],
23583
+ children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(RichTextToolbarIcon, { icon: FORMATS_WITH_ICON.get(format.type) })
23746
23584
  }
23747
- if (targetRef.current !== target) {
23748
- targetRef.current = target;
23749
- const cell2 = fixedGetDOMCellFromTarget(target);
23750
- if (cell2 && activeCell !== cell2) {
23751
- editor.update(() => {
23752
- const tableCellNode = (0, import_lexical6.$getNearestNodeFromDOMNode)(cell2.elem);
23753
- if (!tableCellNode) {
23754
- throw new Error("TableCellResizer: Table cell node not found.");
23755
- }
23756
- const tableNode = (0, import_table2.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
23757
- const tableElement2 = editor.getElementByKey(tableNode.getKey());
23758
- if (!tableElement2) {
23759
- throw new Error("TableCellResizer: Table element not found.");
23760
- }
23761
- targetRef.current = target;
23762
- tableRectRef.current = tableElement2.getBoundingClientRect();
23763
- updateActiveCell(cell2);
23764
- });
23765
- } else if (cell2 == null) {
23766
- resetState();
23767
- }
23585
+ ) }, format.type)),
23586
+ visibleFormatsWithoutIcon.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
23587
+ Menu,
23588
+ {
23589
+ menuLabel: "Alternative text styles",
23590
+ menuTrigger: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("button", { css: richTextToolbarButton, title: "Alternative text styles", children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Icon, { icon: "more-alt", css: toolbarIcon }) }),
23591
+ placement: "bottom-start",
23592
+ children: visibleFormatsWithoutIcon.map((format) => /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
23593
+ MenuItem,
23594
+ {
23595
+ onClick: () => {
23596
+ editor.dispatchCommand(import_lexical5.FORMAT_TEXT_COMMAND, format.type);
23597
+ },
23598
+ children: format.label
23599
+ },
23600
+ format.type
23601
+ ))
23768
23602
  }
23769
- }, 0);
23770
- };
23771
- const onMouseDown = () => {
23772
- setTimeout(() => {
23773
- updateIsMouseDown(true);
23774
- }, 0);
23775
- };
23776
- const onMouseUp = () => {
23777
- setTimeout(() => {
23778
- updateIsMouseDown(false);
23779
- }, 0);
23780
- };
23781
- const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {
23782
- rootElement == null ? void 0 : rootElement.addEventListener("mousemove", onMouseMove);
23783
- rootElement == null ? void 0 : rootElement.addEventListener("mousedown", onMouseDown);
23784
- rootElement == null ? void 0 : rootElement.addEventListener("mouseup", onMouseUp);
23785
- prevRootElement == null ? void 0 : prevRootElement.removeEventListener("mousemove", onMouseMove);
23786
- prevRootElement == null ? void 0 : prevRootElement.removeEventListener("mousedown", onMouseDown);
23787
- prevRootElement == null ? void 0 : prevRootElement.removeEventListener("mouseup", onMouseUp);
23788
- });
23789
- return () => {
23790
- removeRootListener();
23791
- };
23792
- }, [activeCell, draggingDirection, editor, resetState]);
23793
- const isHeightChanging = (direction) => {
23794
- if (direction === "bottom") {
23795
- return true;
23796
- }
23797
- return false;
23798
- };
23799
- const updateRowHeight = (0, import_react152.useCallback)(
23800
- (heightChange) => {
23801
- if (!activeCell) {
23802
- throw new Error("TableCellResizer: Expected active cell.");
23803
- }
23804
- editor.update(
23805
- () => {
23806
- const tableCellNode = (0, import_lexical6.$getNearestNodeFromDOMNode)(activeCell.elem);
23807
- if (!(0, import_table2.$isTableCellNode)(tableCellNode)) {
23808
- throw new Error("TableCellResizer: Table cell node not found.");
23809
- }
23810
- const tableNode = (0, import_table2.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
23811
- const tableRowIndex = (0, import_table2.$getTableRowIndexFromTableCellNode)(tableCellNode);
23812
- const tableRows = tableNode.getChildren();
23813
- if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {
23814
- throw new Error("Expected table cell to be inside of table row.");
23815
- }
23816
- const tableRow2 = tableRows[tableRowIndex];
23817
- if (!(0, import_table2.$isTableRowNode)(tableRow2)) {
23818
- throw new Error("Expected table row");
23819
- }
23820
- let height = tableRow2.getHeight();
23821
- if (height === void 0) {
23822
- const rowCells = tableRow2.getChildren();
23823
- height = Math.min(...rowCells.map((cell2) => {
23824
- var _a;
23825
- return (_a = getCellNodeHeight(cell2, editor)) != null ? _a : Infinity;
23826
- }));
23827
- }
23828
- const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT);
23829
- tableRow2.setHeight(newHeight);
23830
- },
23831
- { tag: "skip-scroll-into-view" }
23832
- );
23833
- },
23834
- [activeCell, editor]
23835
- );
23836
- const getCellNodeWidth = (cell2, activeEditor) => {
23837
- const width = cell2.getWidth();
23838
- if (width !== void 0) {
23839
- return width;
23840
- }
23841
- const domCellNode = activeEditor.getElementByKey(cell2.getKey());
23842
- if (domCellNode == null) {
23843
- return void 0;
23844
- }
23845
- const computedStyle = getComputedStyle(domCellNode);
23846
- return domCellNode.clientWidth - parseFloat(computedStyle.paddingLeft) - parseFloat(computedStyle.paddingRight);
23847
- };
23848
- const getCellNodeHeight = (cell2, activeEditor) => {
23849
- const domCellNode = activeEditor.getElementByKey(cell2.getKey());
23850
- return domCellNode == null ? void 0 : domCellNode.clientHeight;
23851
- };
23852
- const getCellColumnIndex = (tableCellNode, tableMap) => {
23853
- for (let row = 0; row < tableMap.length; row++) {
23854
- for (let column = 0; column < tableMap[row].length; column++) {
23855
- if (tableMap[row][column].cell === tableCellNode) {
23856
- return column;
23603
+ ) : null
23604
+ ] }) : null,
23605
+ visibleElementsWithIcons.size > 0 || customControls ? /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("div", { css: toolbarGroup, children: [
23606
+ linkElementVisible ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Tooltip, { title: "Link", placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
23607
+ "button",
23608
+ {
23609
+ onClick: () => {
23610
+ isLink ? editor.dispatchCommand(REMOVE_LINK_NODE_COMMAND, {}) : editor.dispatchCommand(OPEN_LINK_NODE_MODAL_COMMAND, {});
23611
+ },
23612
+ css: [richTextToolbarButton, isLink ? richTextToolbarButtonActive : null],
23613
+ children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(RichTextToolbarIcon, { icon: "link" })
23857
23614
  }
23858
- }
23859
- }
23860
- };
23861
- const updateColumnWidth = (0, import_react152.useCallback)(
23862
- (widthChange) => {
23863
- if (!activeCell) {
23864
- throw new Error("TableCellResizer: Expected active cell.");
23865
- }
23866
- editor.update(
23867
- () => {
23868
- const tableCellNode = (0, import_lexical6.$getNearestNodeFromDOMNode)(activeCell.elem);
23869
- if (!(0, import_table2.$isTableCellNode)(tableCellNode)) {
23870
- throw new Error("TableCellResizer: Table cell node not found.");
23615
+ ) }) : null,
23616
+ visibleLists.size > 0 ? /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(import_jsx_runtime130.Fragment, { children: [
23617
+ visibleLists.has("unorderedList") ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Tooltip, { title: "Bullet List", placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
23618
+ "button",
23619
+ {
23620
+ onClick: () => {
23621
+ activeElement === "unorderedList" ? editor.dispatchCommand(import_list2.REMOVE_LIST_COMMAND, void 0) : editor.dispatchCommand(import_list2.INSERT_UNORDERED_LIST_COMMAND, void 0);
23622
+ },
23623
+ css: [
23624
+ richTextToolbarButton,
23625
+ activeElement === "unorderedList" ? richTextToolbarButtonActive : null
23626
+ ],
23627
+ children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(RichTextToolbarIcon, { icon: "layout-list" })
23871
23628
  }
23872
- const tableNode = (0, import_table2.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
23873
- const [tableMap] = (0, import_table2.$computeTableMapSkipCellCheck)(tableNode, null, null);
23874
- const columnIndex = getCellColumnIndex(tableCellNode, tableMap);
23875
- if (columnIndex === void 0) {
23876
- throw new Error("TableCellResizer: Table column not found.");
23629
+ ) }) : null,
23630
+ visibleLists.has("orderedList") ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Tooltip, { title: "Ordered List", placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
23631
+ "button",
23632
+ {
23633
+ onClick: () => {
23634
+ activeElement === "orderedList" ? editor.dispatchCommand(import_list2.REMOVE_LIST_COMMAND, void 0) : editor.dispatchCommand(import_list2.INSERT_ORDERED_LIST_COMMAND, void 0);
23635
+ },
23636
+ css: [
23637
+ richTextToolbarButton,
23638
+ activeElement === "orderedList" ? richTextToolbarButtonActive : null
23639
+ ],
23640
+ children: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(RichTextToolbarIcon, { icon: "layout-list-numbered" })
23877
23641
  }
23878
- for (let row = 0; row < tableMap.length; row++) {
23879
- const cell2 = tableMap[row][columnIndex];
23880
- if (cell2.startRow === row && (columnIndex === tableMap[row].length - 1 || tableMap[row][columnIndex].cell !== tableMap[row][columnIndex + 1].cell)) {
23881
- const width = getCellNodeWidth(cell2.cell, editor);
23882
- if (width === void 0) {
23883
- continue;
23884
- }
23885
- const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH);
23886
- cell2.cell.setWidth(newWidth);
23642
+ ) }) : null
23643
+ ] }) : null,
23644
+ customControls ? customControls : null
23645
+ ] }) : null,
23646
+ visibleInsertElementsWithIcons.size > 0 ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)("div", { css: toolbarGroup, children: /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)(
23647
+ Menu,
23648
+ {
23649
+ menuTrigger: /* @__PURE__ */ (0, import_jsx_runtime130.jsxs)("button", { css: richTextToolbarButton, title: "Insert block element", children: [
23650
+ "Insert",
23651
+ /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Icon, { icon: "chevron-down", css: [toolbarIcon, toolbarChevron], size: "1rem" })
23652
+ ] }),
23653
+ placement: "bottom-start",
23654
+ children: [
23655
+ quoteElementVisible ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
23656
+ MenuItem,
23657
+ {
23658
+ onClick: () => {
23659
+ onSelectElement("quote");
23660
+ },
23661
+ icon: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Icon, { icon: "quote", iconColor: "currentColor" }),
23662
+ children: "Quote"
23887
23663
  }
23888
- }
23889
- },
23890
- { tag: "skip-scroll-into-view" }
23891
- );
23892
- },
23893
- [activeCell, editor]
23894
- );
23895
- const mouseUpHandler = (0, import_react152.useCallback)(
23896
- (direction) => {
23897
- const handler = (event) => {
23898
- event.preventDefault();
23899
- event.stopPropagation();
23900
- if (!activeCell) {
23901
- throw new Error("TableCellResizer: Expected active cell.");
23902
- }
23903
- if (mouseStartPosRef.current) {
23904
- const { x, y } = mouseStartPosRef.current;
23905
- if (activeCell === null) {
23906
- return;
23907
- }
23908
- const zoom = (0, import_utils10.calculateZoomLevel)(event.target);
23909
- if (isHeightChanging(direction)) {
23910
- const heightChange = (event.clientY - y) / zoom;
23911
- updateRowHeight(heightChange);
23912
- } else {
23913
- const widthChange = (event.clientX - x) / zoom;
23914
- updateColumnWidth(widthChange);
23915
- }
23916
- resetState();
23917
- document.removeEventListener("mouseup", handler);
23918
- }
23919
- };
23920
- return handler;
23921
- },
23922
- [activeCell, resetState, updateColumnWidth, updateRowHeight]
23923
- );
23924
- const toggleResize = (0, import_react152.useCallback)(
23925
- (direction) => (event) => {
23926
- event.preventDefault();
23927
- event.stopPropagation();
23928
- if (!activeCell) {
23929
- throw new Error("TableCellResizer: Expected active cell.");
23664
+ ) : null,
23665
+ codeElementVisible ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
23666
+ MenuItem,
23667
+ {
23668
+ onClick: () => {
23669
+ onSelectElement("code");
23670
+ },
23671
+ icon: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Icon, { icon: "code-slash", iconColor: "currentColor" }),
23672
+ children: "Code"
23673
+ }
23674
+ ) : null,
23675
+ tableElementVisible && onInsertTable !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(
23676
+ MenuItem,
23677
+ {
23678
+ onClick: () => {
23679
+ onSelectElement("table");
23680
+ },
23681
+ icon: /* @__PURE__ */ (0, import_jsx_runtime130.jsx)(Icon, { icon: "view-grid", iconColor: "currentColor" }),
23682
+ children: "Table"
23683
+ }
23684
+ ) : null
23685
+ ]
23930
23686
  }
23931
- mouseStartPosRef.current = {
23932
- x: event.clientX,
23933
- y: event.clientY
23934
- };
23935
- updateMouseCurrentPos(mouseStartPosRef.current);
23936
- updateDraggingDirection(direction);
23937
- document.addEventListener("mouseup", mouseUpHandler(direction));
23938
- },
23939
- [activeCell, mouseUpHandler]
23687
+ ) }) : null
23688
+ ] });
23689
+ };
23690
+ var RichTextToolbar_default = RichTextToolbar;
23691
+ var useRichTextToolbarState = ({ config }) => {
23692
+ var _a;
23693
+ const enabledBuiltInFormats = (0, import_react150.useMemo)(() => {
23694
+ return richTextBuiltInFormats.filter((format) => {
23695
+ var _a2, _b;
23696
+ return (_b = (_a2 = config == null ? void 0 : config.formatting) == null ? void 0 : _a2.builtIn) == null ? void 0 : _b.includes(format.type);
23697
+ });
23698
+ }, [config]);
23699
+ const enabledBuiltInElements = (0, import_react150.useMemo)(() => {
23700
+ return richTextBuiltInElements.filter((element) => {
23701
+ var _a2, _b;
23702
+ return (_b = (_a2 = config == null ? void 0 : config.elements) == null ? void 0 : _a2.builtIn) == null ? void 0 : _b.includes(element.type);
23703
+ });
23704
+ }, [config]);
23705
+ const enabledBuiltInFormatsWithIcon = (0, import_react150.useMemo)(() => {
23706
+ return enabledBuiltInFormats.filter((format) => FORMATS_WITH_ICON.has(format.type));
23707
+ }, [enabledBuiltInFormats]);
23708
+ const enabledBuiltInFormatsWithoutIcon = enabledBuiltInFormats.filter(
23709
+ (format) => !FORMATS_WITH_ICON.has(format.type)
23940
23710
  );
23941
- const getResizers = (0, import_react152.useCallback)(() => {
23942
- if (activeCell) {
23943
- const { height, width, top, left } = activeCell.elem.getBoundingClientRect();
23944
- const parentRect = positioningAnchorEl.getBoundingClientRect();
23945
- const zoom = (0, import_utils10.calculateZoomLevel)(activeCell.elem);
23946
- const zoneWidth = 10;
23947
- const styles = {
23948
- bottom: {
23949
- backgroundColor: "none",
23950
- cursor: "row-resize",
23951
- height: `${zoneWidth}px`,
23952
- left: `${left - parentRect.left}px`,
23953
- top: `${top - parentRect.top + positioningAnchorEl.scrollTop + height - zoneWidth / 2}px`,
23954
- width: `${width}px`
23955
- },
23956
- right: {
23957
- backgroundColor: "none",
23958
- cursor: "col-resize",
23959
- height: `${height}px`,
23960
- left: `${left - parentRect.left + width - zoneWidth / 2}px`,
23961
- top: `${top - parentRect.top + positioningAnchorEl.scrollTop}px`,
23962
- width: `${zoneWidth}px`
23963
- }
23964
- };
23965
- const tableRect = tableRectRef.current;
23966
- if (draggingDirection && mouseCurrentPos && tableRect) {
23967
- if (isHeightChanging(draggingDirection)) {
23968
- styles[draggingDirection].left = `${tableRect.left - parentRect.left}px`;
23969
- styles[draggingDirection].top = `${(mouseCurrentPos.y - parentRect.top + positioningAnchorEl.scrollTop) / zoom}px`;
23970
- styles[draggingDirection].height = "3px";
23971
- styles[draggingDirection].width = `${tableRect.width}px`;
23972
- } else {
23973
- styles[draggingDirection].top = `${tableRect.top - parentRect.top + positioningAnchorEl.scrollTop}px`;
23974
- styles[draggingDirection].left = `${(mouseCurrentPos.x - parentRect.left) / zoom}px`;
23975
- styles[draggingDirection].width = "3px";
23976
- styles[draggingDirection].height = `${tableRect.height}px`;
23977
- }
23978
- styles[draggingDirection].backgroundColor = "#adf";
23979
- }
23980
- return styles;
23981
- }
23982
- return {
23983
- bottom: null,
23984
- left: null,
23985
- right: null,
23986
- top: null
23987
- };
23988
- }, [activeCell, draggingDirection, mouseCurrentPos, positioningAnchorEl]);
23989
- const resizerStyles = getResizers();
23990
- return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)("div", { ref: resizerRef, children: activeCell != null && !isMouseDown && /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(import_jsx_runtime131.Fragment, { children: [
23991
- /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
23992
- "div",
23993
- {
23994
- css: tableResizer,
23995
- style: resizerStyles.right || void 0,
23996
- onMouseDown: toggleResize("right")
23997
- }
23998
- ),
23999
- /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
24000
- "div",
24001
- {
24002
- css: tableResizer,
24003
- style: resizerStyles.bottom || void 0,
24004
- onMouseDown: toggleResize("bottom")
24005
- }
24006
- )
24007
- ] }) });
24008
- }
24009
- function TableCellResizerPlugin({ positioningAnchorEl }) {
24010
- const [editor] = (0, import_LexicalComposerContext5.useLexicalComposerContext)();
24011
- const isEditable = (0, import_useLexicalEditable2.useLexicalEditable)();
24012
- return (0, import_react152.useMemo)(
24013
- () => isEditable ? (0, import_react_dom3.createPortal)(
24014
- /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TableCellResizer, { editor, positioningAnchorEl }),
24015
- positioningAnchorEl
24016
- ) : null,
24017
- [editor, isEditable, positioningAnchorEl]
24018
- );
24019
- }
24020
-
24021
- // src/components/ParameterInputs/rich-text/TableSelectionPlugin.tsx
24022
- init_emotion_jsx_shim();
24023
- var import_LexicalComposerContext6 = require("@lexical/react/LexicalComposerContext");
24024
- var import_table3 = require("@lexical/table");
24025
- var import_lexical7 = require("lexical");
24026
- var import_react153 = require("react");
24027
- var TableSelectionPlugin = () => {
24028
- const [editor] = (0, import_LexicalComposerContext6.useLexicalComposerContext)();
24029
- const [closestTableCellNode, setClosestTableCellNode] = (0, import_react153.useState)(null);
24030
- (0, import_react153.useEffect)(() => {
24031
- return editor.registerCommand(
24032
- import_lexical7.SELECTION_CHANGE_COMMAND,
24033
- () => {
24034
- editor.read(() => {
24035
- const selection = (0, import_lexical7.$getSelection)();
24036
- if (!(0, import_lexical7.$isRangeSelection)(selection) || !selection.isCollapsed()) {
24037
- setClosestTableCellNode(null);
24038
- return false;
24039
- }
24040
- const tableCellNode = (0, import_table3.$findCellNode)(selection.anchor.getNode());
24041
- if (tableCellNode === null) {
24042
- setClosestTableCellNode(null);
24043
- return false;
24044
- }
24045
- setClosestTableCellNode(tableCellNode);
24046
- });
24047
- return false;
24048
- },
24049
- import_lexical7.COMMAND_PRIORITY_NORMAL
24050
- );
24051
- }, [editor]);
24052
- (0, import_react153.useEffect)(() => {
24053
- const onControlA = (event) => {
24054
- if (event.key === "a" && (event.ctrlKey || event.metaKey)) {
24055
- if (!closestTableCellNode) {
24056
- return;
24057
- }
24058
- event.preventDefault();
24059
- editor.update(() => {
24060
- const selection = closestTableCellNode.select(0, closestTableCellNode.getChildrenSize());
24061
- (0, import_lexical7.$setSelection)(selection);
24062
- });
24063
- }
24064
- };
24065
- return editor.registerRootListener((rootElement, prevRootElement) => {
24066
- rootElement == null ? void 0 : rootElement.addEventListener("keydown", onControlA);
24067
- prevRootElement == null ? void 0 : prevRootElement.removeEventListener("keydown", onControlA);
24068
- });
24069
- }, [editor, closestTableCellNode]);
24070
- return null;
24071
- };
24072
- var TableSelectionPlugin_default = TableSelectionPlugin;
24073
-
24074
- // src/components/ParameterInputs/rich-text/toolbar/RichTextToolbar.tsx
24075
- init_emotion_jsx_shim();
24076
- var import_react155 = require("@emotion/react");
24077
- var import_code2 = require("@lexical/code");
24078
- var import_list2 = require("@lexical/list");
24079
- var import_LexicalComposerContext7 = require("@lexical/react/LexicalComposerContext");
24080
- var import_rich_text = require("@lexical/rich-text");
24081
- var import_selection2 = require("@lexical/selection");
24082
- var import_table4 = require("@lexical/table");
24083
- var import_utils11 = require("@lexical/utils");
24084
- var import_lexical8 = require("lexical");
24085
- var import_react156 = require("react");
24086
-
24087
- // src/components/ParameterInputs/rich-text/toolbar/constants.ts
24088
- init_emotion_jsx_shim();
24089
- var FORMATS_WITH_ICON = /* @__PURE__ */ new Map([
24090
- ["bold", "format-bold"],
24091
- ["italic", "format-italic"],
24092
- ["underline", "format-underline"],
24093
- ["strikethrough", "format-strike"],
24094
- ["code", "format-code"],
24095
- ["superscript", "format-superscript"],
24096
- ["subscript", "format-subscript"]
24097
- ]);
24098
- var HEADING_ELEMENTS = ["h1", "h2", "h3", "h4", "h5", "h6"];
24099
- var TEXTUAL_ELEMENTS = HEADING_ELEMENTS;
24100
-
24101
- // src/components/ParameterInputs/rich-text/toolbar/useRichTextToolbarState.ts
24102
- init_emotion_jsx_shim();
24103
- var import_react154 = require("react");
24104
- var useRichTextToolbarState = ({ config }) => {
24105
- var _a;
24106
- const enabledBuiltInFormats = (0, import_react154.useMemo)(() => {
24107
- return richTextBuiltInFormats.filter((format) => {
24108
- var _a2, _b;
24109
- return (_b = (_a2 = config == null ? void 0 : config.formatting) == null ? void 0 : _a2.builtIn) == null ? void 0 : _b.includes(format.type);
24110
- });
24111
- }, [config]);
24112
- const enabledBuiltInElements = (0, import_react154.useMemo)(() => {
24113
- return richTextBuiltInElements.filter((element) => {
24114
- var _a2, _b;
24115
- return (_b = (_a2 = config == null ? void 0 : config.elements) == null ? void 0 : _a2.builtIn) == null ? void 0 : _b.includes(element.type);
24116
- });
24117
- }, [config]);
24118
- const enabledBuiltInFormatsWithIcon = (0, import_react154.useMemo)(() => {
24119
- return enabledBuiltInFormats.filter((format) => FORMATS_WITH_ICON.has(format.type));
24120
- }, [enabledBuiltInFormats]);
24121
- const enabledBuiltInFormatsWithoutIcon = enabledBuiltInFormats.filter(
24122
- (format) => !FORMATS_WITH_ICON.has(format.type)
24123
- );
24124
- const [activeFormats, setActiveFormats] = (0, import_react154.useState)([]);
24125
- const visibleFormatsWithIcon = (0, import_react154.useMemo)(() => {
23711
+ const [activeFormats, setActiveFormats] = (0, import_react150.useState)([]);
23712
+ const visibleFormatsWithIcon = (0, import_react150.useMemo)(() => {
24126
23713
  const visibleFormats = /* @__PURE__ */ new Set();
24127
23714
  activeFormats.filter((type) => FORMATS_WITH_ICON.has(type)).forEach((type) => {
24128
23715
  visibleFormats.add(type);
@@ -24132,7 +23719,7 @@ var useRichTextToolbarState = ({ config }) => {
24132
23719
  });
24133
23720
  return richTextBuiltInFormats.filter((format) => visibleFormats.has(format.type));
24134
23721
  }, [activeFormats, enabledBuiltInFormatsWithIcon]);
24135
- const visibleFormatsWithoutIcon = (0, import_react154.useMemo)(() => {
23722
+ const visibleFormatsWithoutIcon = (0, import_react150.useMemo)(() => {
24136
23723
  const visibleFormats = /* @__PURE__ */ new Set();
24137
23724
  activeFormats.filter((type) => !FORMATS_WITH_ICON.has(type)).forEach((type) => {
24138
23725
  visibleFormats.add(type);
@@ -24142,11 +23729,11 @@ var useRichTextToolbarState = ({ config }) => {
24142
23729
  });
24143
23730
  return richTextBuiltInFormats.filter((format) => visibleFormats.has(format.type));
24144
23731
  }, [activeFormats, enabledBuiltInFormatsWithoutIcon]);
24145
- const [activeElement, setActiveElement] = (0, import_react154.useState)("paragraph");
23732
+ const [activeElement, setActiveElement] = (0, import_react150.useState)("paragraph");
24146
23733
  const enabledTextualElements = enabledBuiltInElements.filter(
24147
23734
  (element) => TEXTUAL_ELEMENTS.includes(element.type)
24148
23735
  );
24149
- const visibleTextualElements = (0, import_react154.useMemo)(() => {
23736
+ const visibleTextualElements = (0, import_react150.useMemo)(() => {
24150
23737
  if (!TEXTUAL_ELEMENTS.includes(activeElement)) {
24151
23738
  return enabledTextualElements;
24152
23739
  }
@@ -24157,30 +23744,27 @@ var useRichTextToolbarState = ({ config }) => {
24157
23744
  }
24158
23745
  );
24159
23746
  }, [activeElement, (_a = config == null ? void 0 : config.elements) == null ? void 0 : _a.builtIn, enabledTextualElements]);
24160
- const [isLink, setIsLink] = (0, import_react154.useState)(false);
24161
- const linkElementVisible = (0, import_react154.useMemo)(() => {
23747
+ const [isLink, setIsLink] = (0, import_react150.useState)(false);
23748
+ const linkElementVisible = (0, import_react150.useMemo)(() => {
24162
23749
  return enabledBuiltInElements.some((element) => element.type === "link") || isLink;
24163
23750
  }, [isLink, enabledBuiltInElements]);
24164
- const visibleLists = (0, import_react154.useMemo)(() => {
23751
+ const visibleLists = (0, import_react150.useMemo)(() => {
24165
23752
  return new Set(
24166
23753
  ["orderedList", "unorderedList"].filter(
24167
23754
  (type) => enabledBuiltInElements.some((element) => element.type === type) || activeElement === type
24168
23755
  )
24169
23756
  );
24170
23757
  }, [activeElement, enabledBuiltInElements]);
24171
- const quoteElementVisible = (0, import_react154.useMemo)(() => {
23758
+ const quoteElementVisible = (0, import_react150.useMemo)(() => {
24172
23759
  return enabledBuiltInElements.some((element) => element.type === "quote") || activeElement === "quote";
24173
23760
  }, [activeElement, enabledBuiltInElements]);
24174
- const codeElementVisible = (0, import_react154.useMemo)(() => {
23761
+ const codeElementVisible = (0, import_react150.useMemo)(() => {
24175
23762
  return enabledBuiltInElements.some((element) => element.type === "code") || activeElement === "code";
24176
23763
  }, [activeElement, enabledBuiltInElements]);
24177
- const tableElementVisible = (0, import_react154.useMemo)(() => {
23764
+ const tableElementVisible = (0, import_react150.useMemo)(() => {
24178
23765
  return enabledBuiltInElements.some((element) => element.type === "table") || activeElement === "table";
24179
23766
  }, [activeElement, enabledBuiltInElements]);
24180
- const assetElementVisible = (0, import_react154.useMemo)(() => {
24181
- return enabledBuiltInElements.some((element) => element.type === "asset") || activeElement === "asset";
24182
- }, [activeElement, enabledBuiltInElements]);
24183
- const visibleElementsWithIcons = (0, import_react154.useMemo)(() => {
23767
+ const visibleElementsWithIcons = (0, import_react150.useMemo)(() => {
24184
23768
  const visibleElements = /* @__PURE__ */ new Set();
24185
23769
  if (linkElementVisible) {
24186
23770
  visibleElements.add("link");
@@ -24192,7 +23776,7 @@ var useRichTextToolbarState = ({ config }) => {
24192
23776
  }
24193
23777
  return visibleElements;
24194
23778
  }, [linkElementVisible, visibleLists]);
24195
- const visibleInsertElementsWithIcons = (0, import_react154.useMemo)(() => {
23779
+ const visibleInsertElementsWithIcons = (0, import_react150.useMemo)(() => {
24196
23780
  const visibleElements = /* @__PURE__ */ new Set();
24197
23781
  if (quoteElementVisible) {
24198
23782
  visibleElements.add("quote");
@@ -24203,11 +23787,8 @@ var useRichTextToolbarState = ({ config }) => {
24203
23787
  if (tableElementVisible) {
24204
23788
  visibleElements.add("table");
24205
23789
  }
24206
- if (assetElementVisible) {
24207
- visibleElements.add("asset");
24208
- }
24209
23790
  return visibleElements;
24210
- }, [codeElementVisible, quoteElementVisible, tableElementVisible, assetElementVisible]);
23791
+ }, [codeElementVisible, quoteElementVisible, tableElementVisible]);
24211
23792
  return {
24212
23793
  activeFormats,
24213
23794
  setActiveFormats,
@@ -24223,347 +23804,744 @@ var useRichTextToolbarState = ({ config }) => {
24223
23804
  quoteElementVisible,
24224
23805
  codeElementVisible,
24225
23806
  tableElementVisible,
24226
- assetElementVisible,
24227
23807
  visibleElementsWithIcons,
24228
23808
  visibleInsertElementsWithIcons
24229
23809
  };
24230
23810
  };
24231
23811
 
24232
- // src/components/ParameterInputs/rich-text/toolbar/RichTextToolbar.tsx
24233
- var import_jsx_runtime132 = require("@emotion/react/jsx-runtime");
24234
- var toolbar = import_react155.css`
24235
- ${scrollbarStyles}
24236
- background: var(--gray-50);
24237
- border-radius: var(--rounded-base);
24238
- display: flex;
24239
- /* We add 1px because we use a 1px wide separator */
24240
- gap: calc(var(--spacing-sm) + 1px);
24241
- margin: 0 0 calc(var(--spacing-sm) + var(--spacing-xs)) 0;
24242
- overflow: auto;
24243
- padding: var(--spacing-sm);
24244
- position: sticky;
24245
- top: calc(var(--spacing-sm) * -2);
24246
- z-index: 10;
24247
- `;
24248
- var toolbarGroup = import_react155.css`
24249
- display: flex;
24250
- flex-shrink: 0;
24251
- gap: var(--spacing-xs);
24252
- position: relative;
24253
-
24254
- &:not(:first-child)::before {
24255
- background-color: var(--gray-300);
24256
- content: '';
24257
- display: block;
24258
- height: 24px;
24259
- left: calc(var(--spacing-xs) * -1);
24260
- position: absolute;
24261
- top: 4px;
24262
- width: 1px;
24263
- }
24264
- `;
24265
- var richTextToolbarButton = import_react155.css`
24266
- align-items: center;
24267
- appearance: none;
24268
- border: 0;
24269
- border-radius: var(--rounded-sm);
24270
- box-shadow: none;
24271
- color: var(--gray-900);
24272
- display: flex;
24273
- flex-shrink: 0;
24274
- height: 32px;
24275
- justify-content: center;
24276
- min-width: 32px;
24277
- padding: 0 var(--spacing-sm);
24278
- `;
24279
- var richTextToolbarButtonActive = import_react155.css`
24280
- background: var(--gray-200);
24281
- `;
24282
- var textStyleButton = import_react155.css`
24283
- justify-content: space-between;
24284
- min-width: 7rem;
24285
- `;
24286
- var toolbarIcon = import_react155.css`
24287
- color: inherit;
24288
- `;
24289
- var toolbarChevron = import_react155.css`
24290
- margin-left: var(--spacing-xs);
23812
+ // src/components/ParameterInputs/rich-text/TableActionMenuPlugin.tsx
23813
+ init_emotion_jsx_shim();
23814
+ var import_react151 = require("@emotion/react");
23815
+ var import_LexicalComposerContext5 = require("@lexical/react/LexicalComposerContext");
23816
+ var import_useLexicalEditable = require("@lexical/react/useLexicalEditable");
23817
+ var import_table2 = require("@lexical/table");
23818
+ var import_lexical6 = require("lexical");
23819
+ var import_react152 = require("react");
23820
+ var import_jsx_runtime131 = require("@emotion/react/jsx-runtime");
23821
+ function computeSelectionCount(selection) {
23822
+ const selectionShape = selection.getShape();
23823
+ return {
23824
+ columns: selectionShape.toX - selectionShape.fromX + 1,
23825
+ rows: selectionShape.toY - selectionShape.fromY + 1
23826
+ };
23827
+ }
23828
+ var tableActionMenuTrigger = import_react151.css`
23829
+ position: absolute;
23830
+ transform: translate(calc(-100% - 1px), 1px);
24291
23831
  `;
24292
- var RichTextToolbarIcon = ({ icon }) => {
24293
- return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Icon, { icon, css: toolbarIcon, size: "1rem" });
24294
- };
24295
- var RichTextToolbar = ({ config, customControls, onInsertTable, onInsertAsset }) => {
24296
- const [editor] = (0, import_LexicalComposerContext7.useLexicalComposerContext)();
24297
- const {
24298
- activeElement,
24299
- setActiveElement,
24300
- activeFormats,
24301
- setActiveFormats,
24302
- visibleFormatsWithIcon,
24303
- visibleFormatsWithoutIcon,
24304
- visibleTextualElements,
24305
- isLink,
24306
- setIsLink,
24307
- linkElementVisible,
24308
- visibleLists,
24309
- codeElementVisible,
24310
- quoteElementVisible,
24311
- visibleElementsWithIcons,
24312
- visibleInsertElementsWithIcons,
24313
- tableElementVisible,
24314
- assetElementVisible
24315
- } = useRichTextToolbarState({ config });
24316
- const onSelectElement = (type) => {
24317
- if (activeElement === type) {
24318
- return;
24319
- }
24320
- editor.focus(() => {
24321
- editor.update(() => {
24322
- const selection = (0, import_lexical8.$getSelection)();
24323
- if (HEADING_ELEMENTS.includes(type)) {
24324
- (0, import_selection2.$setBlocksType)(selection, () => (0, import_rich_text.$createHeadingNode)(type));
24325
- } else if (type === "paragraph") {
24326
- (0, import_selection2.$setBlocksType)(selection, () => (0, import_lexical8.$createParagraphNode)());
24327
- } else if (type === "quote") {
24328
- (0, import_selection2.$setBlocksType)(selection, () => (0, import_rich_text.$createQuoteNode)());
24329
- } else if (type === "code") {
24330
- (0, import_selection2.$setBlocksType)(selection, () => (0, import_code2.$createCodeNode)());
24331
- } else if (type === "table" && onInsertTable) {
24332
- onInsertTable().then((dimensions) => {
24333
- if (!dimensions) {
24334
- return;
24335
- }
24336
- const { rows, columns } = dimensions;
24337
- editor.focus(() => {
24338
- editor.update(() => {
24339
- (0, import_lexical8.$insertNodes)([(0, import_table4.$createTableNodeWithDimensions)(rows, columns, false)]);
24340
- });
24341
- });
23832
+ var TableActionMenuTrigger = (0, import_react152.forwardRef)((props, ref) => {
23833
+ const { tableCellEl, positioningAnchorEl, ...rest } = props;
23834
+ const [coordinates, setCoordinates] = (0, import_react152.useState)({ x: 0, y: 0 });
23835
+ (0, import_react152.useLayoutEffect)(() => {
23836
+ const rect = tableCellEl.getBoundingClientRect();
23837
+ const parentRect = positioningAnchorEl.getBoundingClientRect();
23838
+ const relativeX = rect.right - parentRect.left + positioningAnchorEl.scrollLeft;
23839
+ const relativeY = rect.top - parentRect.top + positioningAnchorEl.scrollTop;
23840
+ setCoordinates({ x: relativeX, y: relativeY });
23841
+ }, [tableCellEl, positioningAnchorEl]);
23842
+ return /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
23843
+ IconButton,
23844
+ {
23845
+ ref,
23846
+ css: [
23847
+ tableActionMenuTrigger,
23848
+ {
23849
+ top: coordinates.y,
23850
+ left: coordinates.x
23851
+ }
23852
+ ],
23853
+ size: "xs",
23854
+ buttonType: "unimportant",
23855
+ ...rest,
23856
+ children: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(Icon, { icon: "chevron-down", size: "1rem", iconColor: "currentColor" })
23857
+ }
23858
+ );
23859
+ });
23860
+ TableActionMenuTrigger.displayName = "TableActionMenuTrigger";
23861
+ function TableActionMenu({
23862
+ tableCellNode: _tableCellNode,
23863
+ menuPortalEl,
23864
+ tableCellEl,
23865
+ positioningAnchorEl
23866
+ }) {
23867
+ const [editor] = (0, import_LexicalComposerContext5.useLexicalComposerContext)();
23868
+ const [tableCellNode, updateTableCellNode] = (0, import_react152.useState)(_tableCellNode);
23869
+ const [selectionCounts, updateSelectionCounts] = (0, import_react152.useState)({
23870
+ columns: 1,
23871
+ rows: 1
23872
+ });
23873
+ const [menuTriggerKey, setMenuTriggerKey] = (0, import_react152.useState)(0);
23874
+ const incrementMenuTriggerKey = () => {
23875
+ setMenuTriggerKey((key) => key += 1);
23876
+ };
23877
+ (0, import_react152.useEffect)(() => {
23878
+ return editor.registerMutationListener(
23879
+ import_table2.TableCellNode,
23880
+ (nodeMutations) => {
23881
+ const nodeUpdated = nodeMutations.get(tableCellNode.getKey()) === "updated";
23882
+ if (nodeUpdated) {
23883
+ editor.getEditorState().read(() => {
23884
+ updateTableCellNode(tableCellNode.getLatest());
24342
23885
  });
24343
- } else if (type === "asset" && onInsertAsset) {
24344
- onInsertAsset();
23886
+ }
23887
+ },
23888
+ { skipInitialization: true }
23889
+ );
23890
+ }, [editor, tableCellNode]);
23891
+ (0, import_react152.useEffect)(() => {
23892
+ editor.getEditorState().read(() => {
23893
+ const selection = (0, import_lexical6.$getSelection)();
23894
+ if ((0, import_table2.$isTableSelection)(selection)) {
23895
+ updateSelectionCounts(computeSelectionCount(selection));
23896
+ }
23897
+ });
23898
+ }, [editor]);
23899
+ const clearTableSelection = (0, import_react152.useCallback)(() => {
23900
+ editor.update(() => {
23901
+ if (tableCellNode.isAttached()) {
23902
+ const tableNode = (0, import_table2.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
23903
+ const tableElement2 = editor.getElementByKey(
23904
+ tableNode.getKey()
23905
+ );
23906
+ if (!tableElement2) {
23907
+ throw new Error("Expected to find tableElement in DOM");
23908
+ }
23909
+ const tableSelection = (0, import_table2.getTableObserverFromTableElement)(tableElement2);
23910
+ if (tableSelection !== null) {
23911
+ tableSelection.clearHighlight();
23912
+ }
23913
+ tableNode.markDirty();
23914
+ updateTableCellNode(tableCellNode.getLatest());
23915
+ }
23916
+ const rootNode = (0, import_lexical6.$getRoot)();
23917
+ rootNode.selectStart();
23918
+ });
23919
+ }, [editor, tableCellNode]);
23920
+ const insertTableRowAtSelection = (0, import_react152.useCallback)(
23921
+ (shouldInsertAfter) => {
23922
+ editor.update(() => {
23923
+ (0, import_table2.$insertTableRow__EXPERIMENTAL)(shouldInsertAfter);
23924
+ });
23925
+ incrementMenuTriggerKey();
23926
+ },
23927
+ [editor]
23928
+ );
23929
+ const insertTableColumnAtSelection = (0, import_react152.useCallback)(
23930
+ (shouldInsertAfter) => {
23931
+ editor.update(() => {
23932
+ for (let i = 0; i < selectionCounts.columns; i++) {
23933
+ (0, import_table2.$insertTableColumn__EXPERIMENTAL)(shouldInsertAfter);
24345
23934
  }
24346
23935
  });
23936
+ incrementMenuTriggerKey();
23937
+ },
23938
+ [editor, selectionCounts.columns]
23939
+ );
23940
+ const deleteTableRowAtSelection = (0, import_react152.useCallback)(() => {
23941
+ editor.update(() => {
23942
+ (0, import_table2.$deleteTableRow__EXPERIMENTAL)();
24347
23943
  });
24348
- };
24349
- const updateToolbar = (0, import_react156.useCallback)(() => {
24350
- const selection = (0, import_lexical8.$getSelection)();
24351
- if (!(0, import_lexical8.$isRangeSelection)(selection)) {
23944
+ incrementMenuTriggerKey();
23945
+ }, [editor]);
23946
+ const deleteTableAtSelection = (0, import_react152.useCallback)(() => {
23947
+ editor.update(() => {
23948
+ const tableNode = (0, import_table2.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
23949
+ tableNode.remove();
23950
+ clearTableSelection();
23951
+ });
23952
+ }, [editor, tableCellNode, clearTableSelection]);
23953
+ const deleteTableColumnAtSelection = (0, import_react152.useCallback)(() => {
23954
+ editor.update(() => {
23955
+ (0, import_table2.$deleteTableColumn__EXPERIMENTAL)();
23956
+ });
23957
+ incrementMenuTriggerKey();
23958
+ }, [editor]);
23959
+ const toggleTableRowIsHeader = (0, import_react152.useCallback)(() => {
23960
+ editor.update(() => {
23961
+ const tableNode = (0, import_table2.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
23962
+ const tableRowIndex = (0, import_table2.$getTableRowIndexFromTableCellNode)(tableCellNode);
23963
+ const tableRows = tableNode.getChildren();
23964
+ if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {
23965
+ throw new Error("Expected table cell to be inside of table row.");
23966
+ }
23967
+ const tableRow2 = tableRows[tableRowIndex];
23968
+ if (!(0, import_table2.$isTableRowNode)(tableRow2)) {
23969
+ throw new Error("Expected table row");
23970
+ }
23971
+ tableRow2.getChildren().forEach((tableCell) => {
23972
+ if (!(0, import_table2.$isTableCellNode)(tableCell)) {
23973
+ throw new Error("Expected table cell");
23974
+ }
23975
+ tableCell.toggleHeaderStyle(import_table2.TableCellHeaderStates.ROW);
23976
+ });
23977
+ clearTableSelection();
23978
+ });
23979
+ }, [editor, tableCellNode, clearTableSelection]);
23980
+ const toggleTableColumnIsHeader = (0, import_react152.useCallback)(() => {
23981
+ editor.update(() => {
23982
+ const tableNode = (0, import_table2.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
23983
+ const tableColumnIndex = (0, import_table2.$getTableColumnIndexFromTableCellNode)(tableCellNode);
23984
+ const tableRows = tableNode.getChildren();
23985
+ const maxRowsLength = Math.max(...tableRows.map((row) => row.getChildren().length));
23986
+ if (tableColumnIndex >= maxRowsLength || tableColumnIndex < 0) {
23987
+ throw new Error("Expected table cell to be inside of table row.");
23988
+ }
23989
+ for (let r = 0; r < tableRows.length; r++) {
23990
+ const tableRow2 = tableRows[r];
23991
+ if (!(0, import_table2.$isTableRowNode)(tableRow2)) {
23992
+ throw new Error("Expected table row");
23993
+ }
23994
+ const tableCells = tableRow2.getChildren();
23995
+ if (tableColumnIndex >= tableCells.length) {
23996
+ continue;
23997
+ }
23998
+ const tableCell = tableCells[tableColumnIndex];
23999
+ if (!(0, import_table2.$isTableCellNode)(tableCell)) {
24000
+ throw new Error("Expected table cell");
24001
+ }
24002
+ tableCell.toggleHeaderStyle(import_table2.TableCellHeaderStates.COLUMN);
24003
+ }
24004
+ clearTableSelection();
24005
+ });
24006
+ }, [editor, tableCellNode, clearTableSelection]);
24007
+ const menuItemCss = (0, import_react151.css)({
24008
+ fontSize: "var(--fs-sm)"
24009
+ });
24010
+ return /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(
24011
+ Menu,
24012
+ {
24013
+ menuTrigger: /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
24014
+ TableActionMenuTrigger,
24015
+ {
24016
+ tableCellEl,
24017
+ positioningAnchorEl
24018
+ },
24019
+ menuTriggerKey
24020
+ ),
24021
+ portalElement: menuPortalEl,
24022
+ maxMenuHeight: "300px",
24023
+ children: [
24024
+ /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(
24025
+ MenuItem,
24026
+ {
24027
+ onClick: () => {
24028
+ insertTableRowAtSelection(false);
24029
+ },
24030
+ css: menuItemCss,
24031
+ children: [
24032
+ "Insert ",
24033
+ selectionCounts.rows === 1 ? "row" : `${selectionCounts.rows} rows`,
24034
+ " above"
24035
+ ]
24036
+ }
24037
+ ),
24038
+ /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(MenuItem, { onClick: () => insertTableRowAtSelection(true), css: menuItemCss, children: [
24039
+ "Insert ",
24040
+ selectionCounts.rows === 1 ? "row" : `${selectionCounts.rows} rows`,
24041
+ " below"
24042
+ ] }),
24043
+ /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(MenuItemSeparator, {}),
24044
+ /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(MenuItem, { onClick: () => insertTableColumnAtSelection(false), css: menuItemCss, children: [
24045
+ "Insert ",
24046
+ selectionCounts.columns === 1 ? "column" : `${selectionCounts.columns} columns`,
24047
+ " left"
24048
+ ] }),
24049
+ /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(MenuItem, { onClick: () => insertTableColumnAtSelection(true), css: menuItemCss, children: [
24050
+ "Insert ",
24051
+ selectionCounts.columns === 1 ? "column" : `${selectionCounts.columns} columns`,
24052
+ " right"
24053
+ ] }),
24054
+ /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(MenuItemSeparator, {}),
24055
+ /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(MenuItem, { onClick: () => deleteTableColumnAtSelection(), css: menuItemCss, children: "Delete column" }),
24056
+ /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(MenuItem, { onClick: () => deleteTableRowAtSelection(), css: menuItemCss, children: "Delete row" }),
24057
+ /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(MenuItem, { onClick: () => deleteTableAtSelection(), css: menuItemCss, children: "Delete table" }),
24058
+ /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(MenuItemSeparator, {}),
24059
+ /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(MenuItem, { onClick: () => toggleTableRowIsHeader(), css: menuItemCss, children: [
24060
+ (tableCellNode.__headerState & import_table2.TableCellHeaderStates.ROW) === import_table2.TableCellHeaderStates.ROW ? "Remove" : "Add",
24061
+ " ",
24062
+ "row header"
24063
+ ] }),
24064
+ /* @__PURE__ */ (0, import_jsx_runtime131.jsxs)(MenuItem, { onClick: () => toggleTableColumnIsHeader(), css: menuItemCss, children: [
24065
+ (tableCellNode.__headerState & import_table2.TableCellHeaderStates.COLUMN) === import_table2.TableCellHeaderStates.COLUMN ? "Remove" : "Add",
24066
+ " ",
24067
+ "column header"
24068
+ ] })
24069
+ ]
24070
+ }
24071
+ );
24072
+ }
24073
+ function TableCellActionMenuContainer({
24074
+ menuPortalEl,
24075
+ positioningAnchorEl
24076
+ }) {
24077
+ const [editor] = (0, import_LexicalComposerContext5.useLexicalComposerContext)();
24078
+ const [tableCellNode, setTableMenuCellNode] = (0, import_react152.useState)(null);
24079
+ const [tableCellNodeEl, _setTableMenuCellNodeEl] = (0, import_react152.useState)(null);
24080
+ const [tableCellMenuPortalEl, setTableMenuCellMenuPortalEl] = (0, import_react152.useState)(null);
24081
+ (0, import_react152.useEffect)(() => {
24082
+ const newPortalEl = document.createElement("div");
24083
+ setTableMenuCellMenuPortalEl(newPortalEl);
24084
+ menuPortalEl.appendChild(newPortalEl);
24085
+ return () => {
24086
+ newPortalEl.remove();
24087
+ };
24088
+ }, [menuPortalEl]);
24089
+ const setTableMenuCellNodeElem = (0, import_react152.useCallback)((elem) => {
24090
+ if (elem) {
24091
+ _setTableMenuCellNodeEl(elem);
24092
+ } else {
24093
+ _setTableMenuCellNodeEl(null);
24094
+ }
24095
+ }, []);
24096
+ const $moveMenu = (0, import_react152.useCallback)(() => {
24097
+ const selection = (0, import_lexical6.$getSelection)();
24098
+ const nativeSelection = window.getSelection();
24099
+ const activeElement = document.activeElement;
24100
+ if (selection == null) {
24101
+ setTableMenuCellNode(null);
24352
24102
  return;
24353
24103
  }
24354
- const newActiveFormats = [];
24355
- for (const format of richTextBuiltInFormats) {
24356
- if (selection.hasFormat(format.type)) {
24357
- newActiveFormats.push(format.type);
24104
+ const rootElement = editor.getRootElement();
24105
+ if ((0, import_lexical6.$isRangeSelection)(selection) && rootElement !== null && nativeSelection !== null && rootElement.contains(nativeSelection.anchorNode)) {
24106
+ const tableCellNodeFromSelection = (0, import_table2.$getTableCellNodeFromLexicalNode)(selection.anchor.getNode());
24107
+ if (tableCellNodeFromSelection == null) {
24108
+ setTableMenuCellNode(null);
24109
+ setTableMenuCellNodeElem(null);
24110
+ return;
24111
+ }
24112
+ const tableCellParentNodeDOM = editor.getElementByKey(tableCellNodeFromSelection.getKey());
24113
+ if (tableCellParentNodeDOM == null) {
24114
+ setTableMenuCellNode(null);
24115
+ setTableMenuCellNodeElem(null);
24116
+ return;
24117
+ }
24118
+ setTableMenuCellNode(tableCellNodeFromSelection);
24119
+ setTableMenuCellNodeElem(tableCellParentNodeDOM);
24120
+ } else if (!activeElement) {
24121
+ setTableMenuCellNode(null);
24122
+ setTableMenuCellNodeElem(null);
24123
+ }
24124
+ }, [editor, setTableMenuCellNodeElem]);
24125
+ (0, import_react152.useEffect)(() => {
24126
+ return editor.registerUpdateListener(() => {
24127
+ editor.getEditorState().read(() => {
24128
+ $moveMenu();
24129
+ });
24130
+ });
24131
+ });
24132
+ return tableCellNode != null && tableCellNodeEl != null && tableCellMenuPortalEl != null && /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(
24133
+ TableActionMenu,
24134
+ {
24135
+ tableCellNode,
24136
+ menuPortalEl: tableCellMenuPortalEl,
24137
+ tableCellEl: tableCellNodeEl,
24138
+ positioningAnchorEl
24139
+ },
24140
+ tableCellNode.getKey()
24141
+ );
24142
+ }
24143
+ function TableActionMenuPlugin({
24144
+ positioningAnchorEl,
24145
+ menuPortalEl
24146
+ }) {
24147
+ const isEditable = (0, import_useLexicalEditable.useLexicalEditable)();
24148
+ return isEditable ? /* @__PURE__ */ (0, import_jsx_runtime131.jsx)(TableCellActionMenuContainer, { menuPortalEl, positioningAnchorEl }) : null;
24149
+ }
24150
+
24151
+ // src/components/ParameterInputs/rich-text/TableCellResizerPlugin.tsx
24152
+ init_emotion_jsx_shim();
24153
+ var import_react153 = require("@emotion/react");
24154
+ var import_LexicalComposerContext6 = require("@lexical/react/LexicalComposerContext");
24155
+ var import_useLexicalEditable2 = require("@lexical/react/useLexicalEditable");
24156
+ var import_table3 = require("@lexical/table");
24157
+ var import_utils12 = require("@lexical/utils");
24158
+ var import_lexical7 = require("lexical");
24159
+ var import_react154 = require("react");
24160
+ var import_react_dom3 = require("react-dom");
24161
+ var import_jsx_runtime132 = require("@emotion/react/jsx-runtime");
24162
+ var MIN_ROW_HEIGHT = 33;
24163
+ var MIN_COLUMN_WIDTH = 50;
24164
+ var tableResizer = import_react153.css`
24165
+ position: absolute;
24166
+ z-index: var(--z-10);
24167
+ `;
24168
+ var fixedGetDOMCellFromTarget = (node) => {
24169
+ let currentNode = node;
24170
+ while (currentNode != null) {
24171
+ const nodeName = currentNode.nodeName;
24172
+ if (nodeName === "TD" || nodeName === "TH") {
24173
+ const cell2 = currentNode._cell;
24174
+ if (cell2 === void 0) {
24175
+ return {
24176
+ elem: currentNode
24177
+ };
24178
+ }
24179
+ return cell2;
24180
+ }
24181
+ currentNode = currentNode.parentNode;
24182
+ }
24183
+ return null;
24184
+ };
24185
+ function TableCellResizer({ editor, positioningAnchorEl }) {
24186
+ const targetRef = (0, import_react154.useRef)(null);
24187
+ const resizerRef = (0, import_react154.useRef)(null);
24188
+ const tableRectRef = (0, import_react154.useRef)(null);
24189
+ const mouseStartPosRef = (0, import_react154.useRef)(null);
24190
+ const [mouseCurrentPos, updateMouseCurrentPos] = (0, import_react154.useState)(null);
24191
+ const [activeCell, updateActiveCell] = (0, import_react154.useState)(null);
24192
+ const [isMouseDown, updateIsMouseDown] = (0, import_react154.useState)(false);
24193
+ const [draggingDirection, updateDraggingDirection] = (0, import_react154.useState)(null);
24194
+ const resetState = (0, import_react154.useCallback)(() => {
24195
+ updateActiveCell(null);
24196
+ targetRef.current = null;
24197
+ updateDraggingDirection(null);
24198
+ mouseStartPosRef.current = null;
24199
+ tableRectRef.current = null;
24200
+ }, []);
24201
+ const isMouseDownOnEvent = (event) => {
24202
+ return (event.buttons & 1) === 1;
24203
+ };
24204
+ (0, import_react154.useEffect)(() => {
24205
+ const onMouseMove = (event) => {
24206
+ setTimeout(() => {
24207
+ const target = event.target;
24208
+ if (draggingDirection) {
24209
+ updateMouseCurrentPos({
24210
+ x: event.clientX,
24211
+ y: event.clientY
24212
+ });
24213
+ return;
24214
+ }
24215
+ updateIsMouseDown(isMouseDownOnEvent(event));
24216
+ if (resizerRef.current && resizerRef.current.contains(target)) {
24217
+ return;
24218
+ }
24219
+ if (targetRef.current !== target) {
24220
+ targetRef.current = target;
24221
+ const cell2 = fixedGetDOMCellFromTarget(target);
24222
+ if (cell2 && activeCell !== cell2) {
24223
+ editor.update(() => {
24224
+ const tableCellNode = (0, import_lexical7.$getNearestNodeFromDOMNode)(cell2.elem);
24225
+ if (!tableCellNode) {
24226
+ throw new Error("TableCellResizer: Table cell node not found.");
24227
+ }
24228
+ const tableNode = (0, import_table3.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
24229
+ const tableElement2 = editor.getElementByKey(tableNode.getKey());
24230
+ if (!tableElement2) {
24231
+ throw new Error("TableCellResizer: Table element not found.");
24232
+ }
24233
+ targetRef.current = target;
24234
+ tableRectRef.current = tableElement2.getBoundingClientRect();
24235
+ updateActiveCell(cell2);
24236
+ });
24237
+ } else if (cell2 == null) {
24238
+ resetState();
24239
+ }
24240
+ }
24241
+ }, 0);
24242
+ };
24243
+ const onMouseDown = () => {
24244
+ setTimeout(() => {
24245
+ updateIsMouseDown(true);
24246
+ }, 0);
24247
+ };
24248
+ const onMouseUp = () => {
24249
+ setTimeout(() => {
24250
+ updateIsMouseDown(false);
24251
+ }, 0);
24252
+ };
24253
+ const removeRootListener = editor.registerRootListener((rootElement, prevRootElement) => {
24254
+ rootElement == null ? void 0 : rootElement.addEventListener("mousemove", onMouseMove);
24255
+ rootElement == null ? void 0 : rootElement.addEventListener("mousedown", onMouseDown);
24256
+ rootElement == null ? void 0 : rootElement.addEventListener("mouseup", onMouseUp);
24257
+ prevRootElement == null ? void 0 : prevRootElement.removeEventListener("mousemove", onMouseMove);
24258
+ prevRootElement == null ? void 0 : prevRootElement.removeEventListener("mousedown", onMouseDown);
24259
+ prevRootElement == null ? void 0 : prevRootElement.removeEventListener("mouseup", onMouseUp);
24260
+ });
24261
+ return () => {
24262
+ removeRootListener();
24263
+ };
24264
+ }, [activeCell, draggingDirection, editor, resetState]);
24265
+ const isHeightChanging = (direction) => {
24266
+ if (direction === "bottom") {
24267
+ return true;
24268
+ }
24269
+ return false;
24270
+ };
24271
+ const updateRowHeight = (0, import_react154.useCallback)(
24272
+ (heightChange) => {
24273
+ if (!activeCell) {
24274
+ throw new Error("TableCellResizer: Expected active cell.");
24275
+ }
24276
+ editor.update(
24277
+ () => {
24278
+ const tableCellNode = (0, import_lexical7.$getNearestNodeFromDOMNode)(activeCell.elem);
24279
+ if (!(0, import_table3.$isTableCellNode)(tableCellNode)) {
24280
+ throw new Error("TableCellResizer: Table cell node not found.");
24281
+ }
24282
+ const tableNode = (0, import_table3.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
24283
+ const tableRowIndex = (0, import_table3.$getTableRowIndexFromTableCellNode)(tableCellNode);
24284
+ const tableRows = tableNode.getChildren();
24285
+ if (tableRowIndex >= tableRows.length || tableRowIndex < 0) {
24286
+ throw new Error("Expected table cell to be inside of table row.");
24287
+ }
24288
+ const tableRow2 = tableRows[tableRowIndex];
24289
+ if (!(0, import_table3.$isTableRowNode)(tableRow2)) {
24290
+ throw new Error("Expected table row");
24291
+ }
24292
+ let height = tableRow2.getHeight();
24293
+ if (height === void 0) {
24294
+ const rowCells = tableRow2.getChildren();
24295
+ height = Math.min(...rowCells.map((cell2) => {
24296
+ var _a;
24297
+ return (_a = getCellNodeHeight(cell2, editor)) != null ? _a : Infinity;
24298
+ }));
24299
+ }
24300
+ const newHeight = Math.max(height + heightChange, MIN_ROW_HEIGHT);
24301
+ tableRow2.setHeight(newHeight);
24302
+ },
24303
+ { tag: "skip-scroll-into-view" }
24304
+ );
24305
+ },
24306
+ [activeCell, editor]
24307
+ );
24308
+ const getCellNodeWidth = (cell2, activeEditor) => {
24309
+ const width = cell2.getWidth();
24310
+ if (width !== void 0) {
24311
+ return width;
24312
+ }
24313
+ const domCellNode = activeEditor.getElementByKey(cell2.getKey());
24314
+ if (domCellNode == null) {
24315
+ return void 0;
24316
+ }
24317
+ const computedStyle = getComputedStyle(domCellNode);
24318
+ return domCellNode.clientWidth - parseFloat(computedStyle.paddingLeft) - parseFloat(computedStyle.paddingRight);
24319
+ };
24320
+ const getCellNodeHeight = (cell2, activeEditor) => {
24321
+ const domCellNode = activeEditor.getElementByKey(cell2.getKey());
24322
+ return domCellNode == null ? void 0 : domCellNode.clientHeight;
24323
+ };
24324
+ const getCellColumnIndex = (tableCellNode, tableMap) => {
24325
+ for (let row = 0; row < tableMap.length; row++) {
24326
+ for (let column = 0; column < tableMap[row].length; column++) {
24327
+ if (tableMap[row][column].cell === tableCellNode) {
24328
+ return column;
24329
+ }
24330
+ }
24331
+ }
24332
+ };
24333
+ const updateColumnWidth = (0, import_react154.useCallback)(
24334
+ (widthChange) => {
24335
+ if (!activeCell) {
24336
+ throw new Error("TableCellResizer: Expected active cell.");
24337
+ }
24338
+ editor.update(
24339
+ () => {
24340
+ const tableCellNode = (0, import_lexical7.$getNearestNodeFromDOMNode)(activeCell.elem);
24341
+ if (!(0, import_table3.$isTableCellNode)(tableCellNode)) {
24342
+ throw new Error("TableCellResizer: Table cell node not found.");
24343
+ }
24344
+ const tableNode = (0, import_table3.$getTableNodeFromLexicalNodeOrThrow)(tableCellNode);
24345
+ const [tableMap] = (0, import_table3.$computeTableMapSkipCellCheck)(tableNode, null, null);
24346
+ const columnIndex = getCellColumnIndex(tableCellNode, tableMap);
24347
+ if (columnIndex === void 0) {
24348
+ throw new Error("TableCellResizer: Table column not found.");
24349
+ }
24350
+ for (let row = 0; row < tableMap.length; row++) {
24351
+ const cell2 = tableMap[row][columnIndex];
24352
+ if (cell2.startRow === row && (columnIndex === tableMap[row].length - 1 || tableMap[row][columnIndex].cell !== tableMap[row][columnIndex + 1].cell)) {
24353
+ const width = getCellNodeWidth(cell2.cell, editor);
24354
+ if (width === void 0) {
24355
+ continue;
24356
+ }
24357
+ const newWidth = Math.max(width + widthChange, MIN_COLUMN_WIDTH);
24358
+ cell2.cell.setWidth(newWidth);
24359
+ }
24360
+ }
24361
+ },
24362
+ { tag: "skip-scroll-into-view" }
24363
+ );
24364
+ },
24365
+ [activeCell, editor]
24366
+ );
24367
+ const mouseUpHandler = (0, import_react154.useCallback)(
24368
+ (direction) => {
24369
+ const handler = (event) => {
24370
+ event.preventDefault();
24371
+ event.stopPropagation();
24372
+ if (!activeCell) {
24373
+ throw new Error("TableCellResizer: Expected active cell.");
24374
+ }
24375
+ if (mouseStartPosRef.current) {
24376
+ const { x, y } = mouseStartPosRef.current;
24377
+ if (activeCell === null) {
24378
+ return;
24379
+ }
24380
+ const zoom = (0, import_utils12.calculateZoomLevel)(event.target);
24381
+ if (isHeightChanging(direction)) {
24382
+ const heightChange = (event.clientY - y) / zoom;
24383
+ updateRowHeight(heightChange);
24384
+ } else {
24385
+ const widthChange = (event.clientX - x) / zoom;
24386
+ updateColumnWidth(widthChange);
24387
+ }
24388
+ resetState();
24389
+ document.removeEventListener("mouseup", handler);
24390
+ }
24391
+ };
24392
+ return handler;
24393
+ },
24394
+ [activeCell, resetState, updateColumnWidth, updateRowHeight]
24395
+ );
24396
+ const toggleResize = (0, import_react154.useCallback)(
24397
+ (direction) => (event) => {
24398
+ event.preventDefault();
24399
+ event.stopPropagation();
24400
+ if (!activeCell) {
24401
+ throw new Error("TableCellResizer: Expected active cell.");
24402
+ }
24403
+ mouseStartPosRef.current = {
24404
+ x: event.clientX,
24405
+ y: event.clientY
24406
+ };
24407
+ updateMouseCurrentPos(mouseStartPosRef.current);
24408
+ updateDraggingDirection(direction);
24409
+ document.addEventListener("mouseup", mouseUpHandler(direction));
24410
+ },
24411
+ [activeCell, mouseUpHandler]
24412
+ );
24413
+ const getResizers = (0, import_react154.useCallback)(() => {
24414
+ if (activeCell) {
24415
+ const { height, width, top, left } = activeCell.elem.getBoundingClientRect();
24416
+ const parentRect = positioningAnchorEl.getBoundingClientRect();
24417
+ const zoom = (0, import_utils12.calculateZoomLevel)(activeCell.elem);
24418
+ const zoneWidth = 10;
24419
+ const styles = {
24420
+ bottom: {
24421
+ backgroundColor: "none",
24422
+ cursor: "row-resize",
24423
+ height: `${zoneWidth}px`,
24424
+ left: `${left - parentRect.left}px`,
24425
+ top: `${top - parentRect.top + positioningAnchorEl.scrollTop + height - zoneWidth / 2}px`,
24426
+ width: `${width}px`
24427
+ },
24428
+ right: {
24429
+ backgroundColor: "none",
24430
+ cursor: "col-resize",
24431
+ height: `${height}px`,
24432
+ left: `${left - parentRect.left + width - zoneWidth / 2}px`,
24433
+ top: `${top - parentRect.top + positioningAnchorEl.scrollTop}px`,
24434
+ width: `${zoneWidth}px`
24435
+ }
24436
+ };
24437
+ const tableRect = tableRectRef.current;
24438
+ if (draggingDirection && mouseCurrentPos && tableRect) {
24439
+ if (isHeightChanging(draggingDirection)) {
24440
+ styles[draggingDirection].left = `${tableRect.left - parentRect.left}px`;
24441
+ styles[draggingDirection].top = `${(mouseCurrentPos.y - parentRect.top + positioningAnchorEl.scrollTop) / zoom}px`;
24442
+ styles[draggingDirection].height = "3px";
24443
+ styles[draggingDirection].width = `${tableRect.width}px`;
24444
+ } else {
24445
+ styles[draggingDirection].top = `${tableRect.top - parentRect.top + positioningAnchorEl.scrollTop}px`;
24446
+ styles[draggingDirection].left = `${(mouseCurrentPos.x - parentRect.left) / zoom}px`;
24447
+ styles[draggingDirection].width = "3px";
24448
+ styles[draggingDirection].height = `${tableRect.height}px`;
24449
+ }
24450
+ styles[draggingDirection].backgroundColor = "#adf";
24358
24451
  }
24452
+ return styles;
24359
24453
  }
24360
- setActiveFormats(newActiveFormats);
24361
- const anchorNode = selection.anchor.getNode();
24362
- let element = anchorNode.getKey() === "root" ? anchorNode : (0, import_utils11.$findMatchingParent)(anchorNode, (e) => {
24363
- const parent = e.getParent();
24364
- return parent !== null && (0, import_lexical8.$isRootOrShadowRoot)(parent);
24365
- });
24366
- if (element === null) {
24367
- element = anchorNode.getTopLevelElementOrThrow();
24368
- }
24369
- const elementKey = element.getKey();
24370
- const elementDOM = editor.getElementByKey(elementKey);
24371
- if (elementDOM !== null) {
24372
- if ((0, import_list2.$isListNode)(element)) {
24373
- const parentList = (0, import_utils11.$getNearestNodeOfType)(anchorNode, import_list2.ListNode);
24374
- const type = parentList ? parentList.getListType() : element.getListType();
24375
- setActiveElement(type === "bullet" ? "unorderedList" : "orderedList");
24376
- } else {
24377
- const type = (0, import_rich_text.$isHeadingNode)(element) ? element.getTag() : element.getType();
24378
- setActiveElement(type);
24454
+ return {
24455
+ bottom: null,
24456
+ left: null,
24457
+ right: null,
24458
+ top: null
24459
+ };
24460
+ }, [activeCell, draggingDirection, mouseCurrentPos, positioningAnchorEl]);
24461
+ const resizerStyles = getResizers();
24462
+ return /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { ref: resizerRef, children: activeCell != null && !isMouseDown && /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(import_jsx_runtime132.Fragment, { children: [
24463
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
24464
+ "div",
24465
+ {
24466
+ css: tableResizer,
24467
+ style: resizerStyles.right || void 0,
24468
+ onMouseDown: toggleResize("right")
24379
24469
  }
24380
- }
24381
- const node = getSelectedNode(selection);
24382
- if (getLinkAncestor(node) !== null) {
24383
- setIsLink(true);
24384
- } else {
24385
- setIsLink(false);
24386
- }
24387
- }, [editor, setActiveElement, setActiveFormats, setIsLink]);
24388
- (0, import_react156.useEffect)(() => {
24470
+ ),
24471
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
24472
+ "div",
24473
+ {
24474
+ css: tableResizer,
24475
+ style: resizerStyles.bottom || void 0,
24476
+ onMouseDown: toggleResize("bottom")
24477
+ }
24478
+ )
24479
+ ] }) });
24480
+ }
24481
+ function TableCellResizerPlugin({ positioningAnchorEl }) {
24482
+ const [editor] = (0, import_LexicalComposerContext6.useLexicalComposerContext)();
24483
+ const isEditable = (0, import_useLexicalEditable2.useLexicalEditable)();
24484
+ return (0, import_react154.useMemo)(
24485
+ () => isEditable ? (0, import_react_dom3.createPortal)(
24486
+ /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(TableCellResizer, { editor, positioningAnchorEl }),
24487
+ positioningAnchorEl
24488
+ ) : null,
24489
+ [editor, isEditable, positioningAnchorEl]
24490
+ );
24491
+ }
24492
+
24493
+ // src/components/ParameterInputs/rich-text/TableSelectionPlugin.tsx
24494
+ init_emotion_jsx_shim();
24495
+ var import_LexicalComposerContext7 = require("@lexical/react/LexicalComposerContext");
24496
+ var import_table4 = require("@lexical/table");
24497
+ var import_lexical8 = require("lexical");
24498
+ var import_react155 = require("react");
24499
+ var TableSelectionPlugin = () => {
24500
+ const [editor] = (0, import_LexicalComposerContext7.useLexicalComposerContext)();
24501
+ const [closestTableCellNode, setClosestTableCellNode] = (0, import_react155.useState)(null);
24502
+ (0, import_react155.useEffect)(() => {
24389
24503
  return editor.registerCommand(
24390
24504
  import_lexical8.SELECTION_CHANGE_COMMAND,
24391
- (_payload) => {
24392
- updateToolbar();
24505
+ () => {
24506
+ editor.read(() => {
24507
+ const selection = (0, import_lexical8.$getSelection)();
24508
+ if (!(0, import_lexical8.$isRangeSelection)(selection) || !selection.isCollapsed()) {
24509
+ setClosestTableCellNode(null);
24510
+ return false;
24511
+ }
24512
+ const tableCellNode = (0, import_table4.$findCellNode)(selection.anchor.getNode());
24513
+ if (tableCellNode === null) {
24514
+ setClosestTableCellNode(null);
24515
+ return false;
24516
+ }
24517
+ setClosestTableCellNode(tableCellNode);
24518
+ });
24393
24519
  return false;
24394
24520
  },
24395
- import_lexical8.COMMAND_PRIORITY_CRITICAL
24521
+ import_lexical8.COMMAND_PRIORITY_NORMAL
24396
24522
  );
24397
- }, [editor, updateToolbar]);
24398
- (0, import_react156.useEffect)(() => {
24399
- return editor.registerUpdateListener(({ editorState }) => {
24400
- requestAnimationFrame(() => {
24401
- editorState.read(() => {
24402
- updateToolbar();
24403
- });
24404
- });
24405
- });
24406
- }, [editor, updateToolbar]);
24407
- return /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("div", { css: toolbar, children: [
24408
- /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(
24409
- Menu,
24410
- {
24411
- menuTrigger: /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("button", { css: [richTextToolbarButton, textStyleButton], title: "Text styles", children: [
24412
- visibleTextualElements.some((element) => element.type === activeElement) ? getLabelForElement(activeElement) : getLabelForElement("paragraph"),
24413
- " ",
24414
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Icon, { icon: "chevron-down", css: [toolbarIcon, toolbarChevron], size: "1rem" })
24415
- ] }),
24416
- placement: "bottom-start",
24417
- children: [
24418
- [
24419
- {
24420
- label: "Normal",
24421
- type: "paragraph"
24422
- },
24423
- ...visibleTextualElements
24424
- ].map((element) => /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
24425
- MenuItem,
24426
- {
24427
- onClick: () => {
24428
- onSelectElement(element.type);
24429
- },
24430
- children: element.label
24431
- },
24432
- element.type
24433
- )),
24434
- visibleTextualElements.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(MenuItem, { disabled: true, children: "Alternative text styles are not available" }) : null
24435
- ]
24436
- }
24437
- ),
24438
- visibleFormatsWithIcon.length > 0 || visibleFormatsWithoutIcon.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("div", { css: toolbarGroup, children: [
24439
- visibleFormatsWithIcon.map((format) => /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Tooltip, { title: format.label, placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
24440
- "button",
24441
- {
24442
- onClick: () => {
24443
- editor.dispatchCommand(import_lexical8.FORMAT_TEXT_COMMAND, format.type);
24444
- },
24445
- css: [
24446
- richTextToolbarButton,
24447
- activeFormats.includes(format.type) ? richTextToolbarButtonActive : null
24448
- ],
24449
- children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(RichTextToolbarIcon, { icon: FORMATS_WITH_ICON.get(format.type) })
24450
- }
24451
- ) }, format.type)),
24452
- visibleFormatsWithoutIcon.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
24453
- Menu,
24454
- {
24455
- menuLabel: "Alternative text styles",
24456
- menuTrigger: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("button", { css: richTextToolbarButton, title: "Alternative text styles", children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Icon, { icon: "more-alt", css: toolbarIcon }) }),
24457
- placement: "bottom-start",
24458
- children: visibleFormatsWithoutIcon.map((format) => /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
24459
- MenuItem,
24460
- {
24461
- onClick: () => {
24462
- editor.dispatchCommand(import_lexical8.FORMAT_TEXT_COMMAND, format.type);
24463
- },
24464
- children: format.label
24465
- },
24466
- format.type
24467
- ))
24468
- }
24469
- ) : null
24470
- ] }) : null,
24471
- visibleElementsWithIcons.size > 0 || customControls ? /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("div", { css: toolbarGroup, children: [
24472
- linkElementVisible ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Tooltip, { title: "Link", placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
24473
- "button",
24474
- {
24475
- onClick: () => {
24476
- isLink ? editor.dispatchCommand(REMOVE_LINK_NODE_COMMAND, {}) : editor.dispatchCommand(OPEN_LINK_NODE_MODAL_COMMAND, {});
24477
- },
24478
- css: [richTextToolbarButton, isLink ? richTextToolbarButtonActive : null],
24479
- children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(RichTextToolbarIcon, { icon: "link" })
24523
+ }, [editor]);
24524
+ (0, import_react155.useEffect)(() => {
24525
+ const onControlA = (event) => {
24526
+ if (event.key === "a" && (event.ctrlKey || event.metaKey)) {
24527
+ if (!closestTableCellNode) {
24528
+ return;
24480
24529
  }
24481
- ) }) : null,
24482
- visibleLists.size > 0 ? /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(import_jsx_runtime132.Fragment, { children: [
24483
- visibleLists.has("unorderedList") ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Tooltip, { title: "Bullet List", placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
24484
- "button",
24485
- {
24486
- onClick: () => {
24487
- activeElement === "unorderedList" ? editor.dispatchCommand(import_list2.REMOVE_LIST_COMMAND, void 0) : editor.dispatchCommand(import_list2.INSERT_UNORDERED_LIST_COMMAND, void 0);
24488
- },
24489
- css: [
24490
- richTextToolbarButton,
24491
- activeElement === "unorderedList" ? richTextToolbarButtonActive : null
24492
- ],
24493
- children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(RichTextToolbarIcon, { icon: "layout-list" })
24494
- }
24495
- ) }) : null,
24496
- visibleLists.has("orderedList") ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Tooltip, { title: "Ordered List", placement: "top", children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
24497
- "button",
24498
- {
24499
- onClick: () => {
24500
- activeElement === "orderedList" ? editor.dispatchCommand(import_list2.REMOVE_LIST_COMMAND, void 0) : editor.dispatchCommand(import_list2.INSERT_ORDERED_LIST_COMMAND, void 0);
24501
- },
24502
- css: [
24503
- richTextToolbarButton,
24504
- activeElement === "orderedList" ? richTextToolbarButtonActive : null
24505
- ],
24506
- children: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(RichTextToolbarIcon, { icon: "layout-list-numbered" })
24507
- }
24508
- ) }) : null
24509
- ] }) : null,
24510
- customControls ? customControls : null
24511
- ] }) : null,
24512
- visibleInsertElementsWithIcons.size > 0 ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)("div", { css: toolbarGroup, children: /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)(
24513
- Menu,
24514
- {
24515
- menuTrigger: /* @__PURE__ */ (0, import_jsx_runtime132.jsxs)("button", { css: richTextToolbarButton, title: "Insert block element", children: [
24516
- "Insert",
24517
- /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Icon, { icon: "chevron-down", css: [toolbarIcon, toolbarChevron], size: "1rem" })
24518
- ] }),
24519
- placement: "bottom-start",
24520
- children: [
24521
- quoteElementVisible ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
24522
- MenuItem,
24523
- {
24524
- onClick: () => {
24525
- onSelectElement("quote");
24526
- },
24527
- icon: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Icon, { icon: "quote", iconColor: "currentColor" }),
24528
- children: "Quote"
24529
- }
24530
- ) : null,
24531
- codeElementVisible ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
24532
- MenuItem,
24533
- {
24534
- onClick: () => {
24535
- onSelectElement("code");
24536
- },
24537
- icon: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Icon, { icon: "code-slash", iconColor: "currentColor" }),
24538
- children: "Code"
24539
- }
24540
- ) : null,
24541
- tableElementVisible && onInsertTable !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
24542
- MenuItem,
24543
- {
24544
- onClick: () => {
24545
- onSelectElement("table");
24546
- },
24547
- icon: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Icon, { icon: "view-grid", iconColor: "currentColor" }),
24548
- children: "Table"
24549
- }
24550
- ) : null,
24551
- assetElementVisible && onInsertAsset !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(
24552
- MenuItem,
24553
- {
24554
- onClick: () => {
24555
- onSelectElement("asset");
24556
- },
24557
- icon: /* @__PURE__ */ (0, import_jsx_runtime132.jsx)(Icon, { icon: "image", iconColor: "currentColor" }),
24558
- children: "Asset"
24559
- }
24560
- ) : null
24561
- ]
24530
+ event.preventDefault();
24531
+ editor.update(() => {
24532
+ const selection = closestTableCellNode.select(0, closestTableCellNode.getChildrenSize());
24533
+ (0, import_lexical8.$setSelection)(selection);
24534
+ });
24562
24535
  }
24563
- ) }) : null
24564
- ] });
24536
+ };
24537
+ return editor.registerRootListener((rootElement, prevRootElement) => {
24538
+ rootElement == null ? void 0 : rootElement.addEventListener("keydown", onControlA);
24539
+ prevRootElement == null ? void 0 : prevRootElement.removeEventListener("keydown", onControlA);
24540
+ });
24541
+ }, [editor, closestTableCellNode]);
24542
+ return null;
24565
24543
  };
24566
- var RichTextToolbar_default = RichTextToolbar;
24544
+ var TableSelectionPlugin_default = TableSelectionPlugin;
24567
24545
 
24568
24546
  // src/components/ParameterInputs/ParameterRichText.tsx
24569
24547
  var import_jsx_runtime133 = require("@emotion/react/jsx-runtime");
@@ -24592,7 +24570,6 @@ var ParameterRichText = ({
24592
24570
  variables,
24593
24571
  customControls,
24594
24572
  onInsertTable,
24595
- onInsertAsset,
24596
24573
  minimalInteractivity
24597
24574
  }) => {
24598
24575
  return /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)(
@@ -24626,7 +24603,6 @@ var ParameterRichText = ({
24626
24603
  variables,
24627
24604
  customControls,
24628
24605
  onInsertTable,
24629
- onInsertAsset,
24630
24606
  minimalInteractivity,
24631
24607
  children
24632
24608
  }
@@ -24636,7 +24612,7 @@ var ParameterRichText = ({
24636
24612
  }
24637
24613
  );
24638
24614
  };
24639
- var editorContainerWrapper = import_react157.css`
24615
+ var editorContainerWrapper = import_react156.css`
24640
24616
  position: relative;
24641
24617
 
24642
24618
  &::before {
@@ -24652,12 +24628,12 @@ var editorContainerWrapper = import_react157.css`
24652
24628
  z-index: 2;
24653
24629
  }
24654
24630
  `;
24655
- var editorWrapper = import_react157.css`
24631
+ var editorWrapper = import_react156.css`
24656
24632
  display: flex;
24657
24633
  flex-flow: column;
24658
24634
  flex-grow: 1;
24659
24635
  `;
24660
- var editorContainer = import_react157.css`
24636
+ var editorContainer = import_react156.css`
24661
24637
  ${scrollbarStyles}
24662
24638
  background: var(--white);
24663
24639
  border-radius: var(--rounded-sm);
@@ -24689,7 +24665,7 @@ var editorContainer = import_react157.css`
24689
24665
  max-height: unset;
24690
24666
  }
24691
24667
  `;
24692
- var editorContainerOverflowWrapper = import_react157.css`
24668
+ var editorContainerOverflowWrapper = import_react156.css`
24693
24669
  overflow: hidden;
24694
24670
  pointer-events: none;
24695
24671
 
@@ -24697,7 +24673,7 @@ var editorContainerOverflowWrapper = import_react157.css`
24697
24673
  pointer-events: auto;
24698
24674
  }
24699
24675
  `;
24700
- var editorPlaceholder = import_react157.css`
24676
+ var editorPlaceholder = import_react156.css`
24701
24677
  color: var(--gray-500);
24702
24678
  font-style: italic;
24703
24679
  /* 1px is added to make sure caret is clearly visible when field is focused
@@ -24708,9 +24684,8 @@ var editorPlaceholder = import_react157.css`
24708
24684
  top: var(--spacing-sm);
24709
24685
  user-select: none;
24710
24686
  `;
24711
- var editorInput = import_react157.css`
24687
+ var editorInput = import_react156.css`
24712
24688
  min-height: 100%;
24713
- flex-grow: 1;
24714
24689
 
24715
24690
  &:focus,
24716
24691
  &:focus-within {
@@ -24733,7 +24708,6 @@ var ParameterRichTextInner = ({
24733
24708
  variables,
24734
24709
  customControls,
24735
24710
  onInsertTable,
24736
- onInsertAsset,
24737
24711
  minimalInteractivity
24738
24712
  }) => {
24739
24713
  const lexicalConfig = {
@@ -24806,7 +24780,6 @@ var ParameterRichTextInner = ({
24806
24780
  variables,
24807
24781
  customControls,
24808
24782
  onInsertTable,
24809
- onInsertAsset,
24810
24783
  minimalInteractivity,
24811
24784
  children
24812
24785
  }
@@ -24835,16 +24808,15 @@ var RichText = ({
24835
24808
  variables,
24836
24809
  customControls,
24837
24810
  onInsertTable,
24838
- onInsertAsset,
24839
24811
  minimalInteractivity
24840
24812
  }) => {
24841
24813
  const [editor] = (0, import_LexicalComposerContext8.useLexicalComposerContext)();
24842
- (0, import_react158.useEffect)(() => {
24814
+ (0, import_react157.useEffect)(() => {
24843
24815
  if (onRichTextInit) {
24844
24816
  onRichTextInit(editor);
24845
24817
  }
24846
24818
  }, [editor, onRichTextInit]);
24847
- (0, import_react158.useEffect)(() => {
24819
+ (0, import_react157.useEffect)(() => {
24848
24820
  const removeUpdateListener = editor.registerUpdateListener(({ editorState, prevEditorState, tags }) => {
24849
24821
  requestAnimationFrame(() => {
24850
24822
  if (!(0, import_fast_equals2.deepEqual)(editorState.toJSON(), prevEditorState.toJSON())) {
@@ -24856,31 +24828,23 @@ var RichText = ({
24856
24828
  removeUpdateListener();
24857
24829
  };
24858
24830
  }, [editor, onChange]);
24859
- (0, import_react158.useEffect)(() => {
24831
+ (0, import_react157.useEffect)(() => {
24860
24832
  editor.setEditable(!readOnly);
24861
24833
  }, [editor, readOnly]);
24862
- const [editorContainerRef, setEditorContainerRef] = (0, import_react158.useState)(null);
24834
+ const [editorContainerRef, setEditorContainerRef] = (0, import_react157.useState)(null);
24863
24835
  const onEditorContainerRef = (_editorContainerRef) => {
24864
24836
  if (_editorContainerRef !== null) {
24865
24837
  setEditorContainerRef(_editorContainerRef);
24866
24838
  }
24867
24839
  };
24868
- const [portalContainerRef, setPortalContainerRef] = (0, import_react158.useState)(null);
24840
+ const [portalContainerRef, setPortalContainerRef] = (0, import_react157.useState)(null);
24869
24841
  const onPortalContainerRef = (_portalContainerRef) => {
24870
24842
  if (_portalContainerRef !== null) {
24871
24843
  setPortalContainerRef(_portalContainerRef);
24872
24844
  }
24873
24845
  };
24874
24846
  return /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)(import_jsx_runtime133.Fragment, { children: [
24875
- readOnly || minimalInteractivity ? null : /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(
24876
- RichTextToolbar_default,
24877
- {
24878
- config,
24879
- customControls,
24880
- onInsertTable,
24881
- onInsertAsset
24882
- }
24883
- ),
24847
+ readOnly || minimalInteractivity ? null : /* @__PURE__ */ (0, import_jsx_runtime133.jsx)(RichTextToolbar_default, { config, customControls, onInsertTable }),
24884
24848
  /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)("div", { css: editorContainerWrapper, ref: onPortalContainerRef, children: [
24885
24849
  /* @__PURE__ */ (0, import_jsx_runtime133.jsxs)(
24886
24850
  "div",
@@ -24934,15 +24898,15 @@ var RichText = ({
24934
24898
 
24935
24899
  // src/components/ParameterInputs/ParameterSelect.tsx
24936
24900
  init_emotion_jsx_shim();
24937
- var import_react159 = require("react");
24901
+ var import_react158 = require("react");
24938
24902
  var import_jsx_runtime134 = require("@emotion/react/jsx-runtime");
24939
- var ParameterSelect = (0, import_react159.forwardRef)(
24903
+ var ParameterSelect = (0, import_react158.forwardRef)(
24940
24904
  ({ defaultOption, options, ...props }, ref) => {
24941
24905
  const { shellProps, innerProps } = extractParameterProps(props);
24942
24906
  return /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(ParameterShell, { ...shellProps, children: /* @__PURE__ */ (0, import_jsx_runtime134.jsx)(ParameterSelectInner, { options, defaultOption, ...innerProps, ref }) });
24943
24907
  }
24944
24908
  );
24945
- var ParameterSelectInner = (0, import_react159.forwardRef)(
24909
+ var ParameterSelectInner = (0, import_react158.forwardRef)(
24946
24910
  ({ defaultOption, options, ...props }, ref) => {
24947
24911
  const { id, label, hiddenLabel } = useParameterShell();
24948
24912
  return /* @__PURE__ */ (0, import_jsx_runtime134.jsxs)(
@@ -24967,13 +24931,13 @@ var ParameterSelectInner = (0, import_react159.forwardRef)(
24967
24931
 
24968
24932
  // src/components/ParameterInputs/ParameterTextarea.tsx
24969
24933
  init_emotion_jsx_shim();
24970
- var import_react160 = require("react");
24934
+ var import_react159 = require("react");
24971
24935
  var import_jsx_runtime135 = require("@emotion/react/jsx-runtime");
24972
- var ParameterTextarea = (0, import_react160.forwardRef)((props, ref) => {
24936
+ var ParameterTextarea = (0, import_react159.forwardRef)((props, ref) => {
24973
24937
  const { shellProps, innerProps } = extractParameterProps(props);
24974
24938
  return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(ParameterShell, { "data-testid": "parameter-textarea", ...shellProps, children: /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(ParameterTextareaInner, { ref, ...innerProps }) });
24975
24939
  });
24976
- var ParameterTextareaInner = (0, import_react160.forwardRef)(({ ...props }, ref) => {
24940
+ var ParameterTextareaInner = (0, import_react159.forwardRef)(({ ...props }, ref) => {
24977
24941
  const { id, label, hiddenLabel } = useParameterShell();
24978
24942
  return /* @__PURE__ */ (0, import_jsx_runtime135.jsx)(
24979
24943
  "textarea",
@@ -24989,13 +24953,13 @@ var ParameterTextareaInner = (0, import_react160.forwardRef)(({ ...props }, ref)
24989
24953
 
24990
24954
  // src/components/ParameterInputs/ParameterToggle.tsx
24991
24955
  init_emotion_jsx_shim();
24992
- var import_react161 = require("react");
24956
+ var import_react160 = require("react");
24993
24957
  var import_jsx_runtime136 = require("@emotion/react/jsx-runtime");
24994
- var ParameterToggle = (0, import_react161.forwardRef)((props, ref) => {
24958
+ var ParameterToggle = (0, import_react160.forwardRef)((props, ref) => {
24995
24959
  const { shellProps, innerProps } = extractParameterProps(props);
24996
24960
  return /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(ParameterShell, { ...shellProps, children: /* @__PURE__ */ (0, import_jsx_runtime136.jsx)(ParameterToggleInner, { ref, ...innerProps }) });
24997
24961
  });
24998
- var ParameterToggleInner = (0, import_react161.forwardRef)(
24962
+ var ParameterToggleInner = (0, import_react160.forwardRef)(
24999
24963
  ({ children, ...props }, ref) => {
25000
24964
  const { id, label } = useParameterShell();
25001
24965
  return /* @__PURE__ */ (0, import_jsx_runtime136.jsxs)("label", { css: inputToggleLabel2, children: [
@@ -25011,8 +24975,8 @@ init_emotion_jsx_shim();
25011
24975
 
25012
24976
  // src/components/ProgressBar/ProgressBar.styles.ts
25013
24977
  init_emotion_jsx_shim();
25014
- var import_react162 = require("@emotion/react");
25015
- var container3 = import_react162.css`
24978
+ var import_react161 = require("@emotion/react");
24979
+ var container3 = import_react161.css`
25016
24980
  background: var(--gray-50);
25017
24981
  margin-block: var(--spacing-sm);
25018
24982
  position: relative;
@@ -25022,17 +24986,17 @@ var container3 = import_react162.css`
25022
24986
  border: solid 1px var(--gray-300);
25023
24987
  `;
25024
24988
  var themeMap = {
25025
- primary: import_react162.css`
24989
+ primary: import_react161.css`
25026
24990
  --progress-color: var(--accent-light);
25027
24991
  `,
25028
- secondary: import_react162.css`
24992
+ secondary: import_react161.css`
25029
24993
  --progress-color: var(--accent-alt-light);
25030
24994
  `,
25031
- destructive: import_react162.css`
24995
+ destructive: import_react161.css`
25032
24996
  --progress-color: var(--brand-secondary-5);
25033
24997
  `
25034
24998
  };
25035
- var slidingBackgroundPosition = import_react162.keyframes`
24999
+ var slidingBackgroundPosition = import_react161.keyframes`
25036
25000
  from {
25037
25001
  background-position: 0 0;
25038
25002
  }
@@ -25040,10 +25004,10 @@ var slidingBackgroundPosition = import_react162.keyframes`
25040
25004
  background-position: 64px 0;
25041
25005
  }
25042
25006
  `;
25043
- var determinate = import_react162.css`
25007
+ var determinate = import_react161.css`
25044
25008
  background-color: var(--progress-color);
25045
25009
  `;
25046
- var indeterminate = import_react162.css`
25010
+ var indeterminate = import_react161.css`
25047
25011
  background-image: linear-gradient(
25048
25012
  45deg,
25049
25013
  var(--progress-color) 25%,
@@ -25057,7 +25021,7 @@ var indeterminate = import_react162.css`
25057
25021
  background-size: 64px 64px;
25058
25022
  animation: ${slidingBackgroundPosition} 1s linear infinite;
25059
25023
  `;
25060
- var bar = import_react162.css`
25024
+ var bar = import_react161.css`
25061
25025
  position: absolute;
25062
25026
  inset: 0;
25063
25027
  transition: transform var(--duration-fast) var(--timing-ease-out);
@@ -25106,22 +25070,22 @@ function ProgressBar({
25106
25070
 
25107
25071
  // src/components/ProgressList/ProgressList.tsx
25108
25072
  init_emotion_jsx_shim();
25109
- var import_react164 = require("@emotion/react");
25073
+ var import_react163 = require("@emotion/react");
25110
25074
  var import_CgCheckO3 = require("@react-icons/all-files/cg/CgCheckO");
25111
25075
  var import_CgRadioCheck2 = require("@react-icons/all-files/cg/CgRadioCheck");
25112
25076
  var import_CgRecord2 = require("@react-icons/all-files/cg/CgRecord");
25113
- var import_react165 = require("react");
25077
+ var import_react164 = require("react");
25114
25078
 
25115
25079
  // src/components/ProgressList/styles/ProgressList.styles.ts
25116
25080
  init_emotion_jsx_shim();
25117
- var import_react163 = require("@emotion/react");
25118
- var progressListStyles = import_react163.css`
25081
+ var import_react162 = require("@emotion/react");
25082
+ var progressListStyles = import_react162.css`
25119
25083
  display: flex;
25120
25084
  flex-direction: column;
25121
25085
  gap: var(--spacing-sm);
25122
25086
  list-style-type: none;
25123
25087
  `;
25124
- var progressListItemStyles = import_react163.css`
25088
+ var progressListItemStyles = import_react162.css`
25125
25089
  display: flex;
25126
25090
  gap: var(--spacing-base);
25127
25091
  align-items: center;
@@ -25130,7 +25094,7 @@ var progressListItemStyles = import_react163.css`
25130
25094
  // src/components/ProgressList/ProgressList.tsx
25131
25095
  var import_jsx_runtime138 = require("@emotion/react/jsx-runtime");
25132
25096
  var ProgressList = ({ inProgressId, items, autoEllipsis, ...htmlProps }) => {
25133
- const itemsWithStatus = (0, import_react165.useMemo)(() => {
25097
+ const itemsWithStatus = (0, import_react164.useMemo)(() => {
25134
25098
  const indexOfInProgressItem = items.findIndex(({ id }) => id === inProgressId);
25135
25099
  return items.map((item, index) => {
25136
25100
  let status = "queued";
@@ -25163,7 +25127,7 @@ var ProgressListItem = ({
25163
25127
  errorLevel = "danger",
25164
25128
  autoEllipsis = false
25165
25129
  }) => {
25166
- const icon = (0, import_react165.useMemo)(() => {
25130
+ const icon = (0, import_react164.useMemo)(() => {
25167
25131
  if (error) {
25168
25132
  return warningIcon;
25169
25133
  }
@@ -25174,14 +25138,14 @@ var ProgressListItem = ({
25174
25138
  };
25175
25139
  return iconPerStatus[status];
25176
25140
  }, [status, error]);
25177
- const statusStyles = (0, import_react165.useMemo)(() => {
25141
+ const statusStyles = (0, import_react164.useMemo)(() => {
25178
25142
  if (error) {
25179
- return errorLevel === "caution" ? import_react164.css`
25143
+ return errorLevel === "caution" ? import_react163.css`
25180
25144
  color: rgb(161, 98, 7);
25181
25145
  & svg {
25182
25146
  color: rgb(250, 204, 21);
25183
25147
  }
25184
- ` : import_react164.css`
25148
+ ` : import_react163.css`
25185
25149
  color: rgb(185, 28, 28);
25186
25150
  & svg {
25187
25151
  color: var(--brand-primary-2);
@@ -25189,13 +25153,13 @@ var ProgressListItem = ({
25189
25153
  `;
25190
25154
  }
25191
25155
  const colorPerStatus = {
25192
- completed: import_react164.css`
25156
+ completed: import_react163.css`
25193
25157
  opacity: 0.75;
25194
25158
  `,
25195
- inProgress: import_react164.css`
25159
+ inProgress: import_react163.css`
25196
25160
  -webkit-text-stroke-width: thin;
25197
25161
  `,
25198
- queued: import_react164.css`
25162
+ queued: import_react163.css`
25199
25163
  opacity: 0.5;
25200
25164
  `
25201
25165
  };
@@ -25212,17 +25176,17 @@ var ProgressListItem = ({
25212
25176
 
25213
25177
  // src/components/SegmentedControl/SegmentedControl.tsx
25214
25178
  init_emotion_jsx_shim();
25215
- var import_react167 = require("@emotion/react");
25179
+ var import_react166 = require("@emotion/react");
25216
25180
  var import_CgCheck6 = require("@react-icons/all-files/cg/CgCheck");
25217
- var import_react168 = require("react");
25181
+ var import_react167 = require("react");
25218
25182
 
25219
25183
  // src/components/SegmentedControl/SegmentedControl.styles.ts
25220
25184
  init_emotion_jsx_shim();
25221
- var import_react166 = require("@emotion/react");
25222
- var segmentedControlRootStyles = import_react166.css`
25185
+ var import_react165 = require("@emotion/react");
25186
+ var segmentedControlRootStyles = import_react165.css`
25223
25187
  position: relative;
25224
25188
  `;
25225
- var segmentedControlScrollIndicatorsStyles = import_react166.css`
25189
+ var segmentedControlScrollIndicatorsStyles = import_react165.css`
25226
25190
  position: absolute;
25227
25191
  inset: 0;
25228
25192
  z-index: 1;
@@ -25250,17 +25214,17 @@ var segmentedControlScrollIndicatorsStyles = import_react166.css`
25250
25214
  background: linear-gradient(to left, var(--background-color) 10%, transparent);
25251
25215
  }
25252
25216
  `;
25253
- var segmentedControlScrollIndicatorStartVisibleStyles = import_react166.css`
25217
+ var segmentedControlScrollIndicatorStartVisibleStyles = import_react165.css`
25254
25218
  &::before {
25255
25219
  opacity: 1;
25256
25220
  }
25257
25221
  `;
25258
- var segmentedControlScrollIndicatorEndVisibleStyles = import_react166.css`
25222
+ var segmentedControlScrollIndicatorEndVisibleStyles = import_react165.css`
25259
25223
  &::after {
25260
25224
  opacity: 1;
25261
25225
  }
25262
25226
  `;
25263
- var segmentedControlWrapperStyles = import_react166.css`
25227
+ var segmentedControlWrapperStyles = import_react165.css`
25264
25228
  overflow-y: auto;
25265
25229
  scroll-behavior: smooth;
25266
25230
  scrollbar-width: none;
@@ -25269,7 +25233,7 @@ var segmentedControlWrapperStyles = import_react166.css`
25269
25233
  height: 0px;
25270
25234
  }
25271
25235
  `;
25272
- var segmentedControlStyles = import_react166.css`
25236
+ var segmentedControlStyles = import_react165.css`
25273
25237
  --segmented-control-rounded-value: var(--rounded-base);
25274
25238
  --segmented-control-border-width: 1px;
25275
25239
  --segmented-control-selected-color: var(--brand-secondary-3);
@@ -25288,14 +25252,14 @@ var segmentedControlStyles = import_react166.css`
25288
25252
  border-radius: calc(var(--segmented-control-rounded-value) + var(--segmented-control-border-width));
25289
25253
  font-size: var(--fs-xs);
25290
25254
  `;
25291
- var segmentedControlVerticalStyles = import_react166.css`
25255
+ var segmentedControlVerticalStyles = import_react165.css`
25292
25256
  flex-direction: column;
25293
25257
  --segmented-control-first-border-radius: var(--segmented-control-rounded-value)
25294
25258
  var(--segmented-control-rounded-value) 0 0;
25295
25259
  --segmented-control-last-border-radius: 0 0 var(--segmented-control-rounded-value)
25296
25260
  var(--segmented-control-rounded-value);
25297
25261
  `;
25298
- var segmentedControlItemStyles = import_react166.css`
25262
+ var segmentedControlItemStyles = import_react165.css`
25299
25263
  &:first-of-type label {
25300
25264
  border-radius: var(--segmented-control-first-border-radius);
25301
25265
  }
@@ -25303,10 +25267,10 @@ var segmentedControlItemStyles = import_react166.css`
25303
25267
  border-radius: var(--segmented-control-last-border-radius);
25304
25268
  }
25305
25269
  `;
25306
- var segmentedControlInputStyles = import_react166.css`
25270
+ var segmentedControlInputStyles = import_react165.css`
25307
25271
  ${accessibleHidden}
25308
25272
  `;
25309
- var segmentedControlLabelStyles = (checked, disabled2) => import_react166.css`
25273
+ var segmentedControlLabelStyles = (checked, disabled2) => import_react165.css`
25310
25274
  position: relative;
25311
25275
  display: flex;
25312
25276
  align-items: center;
@@ -25373,20 +25337,20 @@ var segmentedControlLabelStyles = (checked, disabled2) => import_react166.css`
25373
25337
  `}
25374
25338
  }
25375
25339
  `;
25376
- var segmentedControlLabelIconOnlyStyles = import_react166.css`
25340
+ var segmentedControlLabelIconOnlyStyles = import_react165.css`
25377
25341
  padding-inline: 0.5em;
25378
25342
  `;
25379
- var segmentedControlLabelCheckStyles = import_react166.css`
25343
+ var segmentedControlLabelCheckStyles = import_react165.css`
25380
25344
  opacity: 0.5;
25381
25345
  `;
25382
- var segmentedControlLabelContentStyles = import_react166.css`
25346
+ var segmentedControlLabelContentStyles = import_react165.css`
25383
25347
  display: flex;
25384
25348
  align-items: center;
25385
25349
  justify-content: center;
25386
25350
  gap: var(--spacing-sm);
25387
25351
  height: 100%;
25388
25352
  `;
25389
- var segmentedControlLabelTextStyles = import_react166.css`
25353
+ var segmentedControlLabelTextStyles = import_react165.css`
25390
25354
  white-space: nowrap;
25391
25355
  `;
25392
25356
 
@@ -25406,10 +25370,10 @@ var SegmentedControl = ({
25406
25370
  currentBackgroundColor = "white",
25407
25371
  ...props
25408
25372
  }) => {
25409
- const wrapperRef = (0, import_react168.useRef)(null);
25410
- const [isOverflowStartShadowVisible, setIsOverflowStartShadowVisible] = (0, import_react168.useState)(false);
25411
- const [isOverflowEndShadowVisible, setIsOverflowEndShadowVisible] = (0, import_react168.useState)(false);
25412
- const onOptionChange = (0, import_react168.useCallback)(
25373
+ const wrapperRef = (0, import_react167.useRef)(null);
25374
+ const [isOverflowStartShadowVisible, setIsOverflowStartShadowVisible] = (0, import_react167.useState)(false);
25375
+ const [isOverflowEndShadowVisible, setIsOverflowEndShadowVisible] = (0, import_react167.useState)(false);
25376
+ const onOptionChange = (0, import_react167.useCallback)(
25413
25377
  (event) => {
25414
25378
  if (event.target.checked) {
25415
25379
  onChange == null ? void 0 : onChange(options[parseInt(event.target.value)].value);
@@ -25417,19 +25381,19 @@ var SegmentedControl = ({
25417
25381
  },
25418
25382
  [options, onChange]
25419
25383
  );
25420
- const sizeStyles = (0, import_react168.useMemo)(() => {
25384
+ const sizeStyles = (0, import_react167.useMemo)(() => {
25421
25385
  const map = {
25422
- sm: (0, import_react167.css)({ height: "calc(24px - 2px)", fontSize: "var(--fs-xs)" }),
25423
- md: (0, import_react167.css)({ height: "calc(32px - 2px)", fontSize: "var(--fs-sm)" }),
25424
- lg: (0, import_react167.css)({ height: "calc(40px - 2px)", fontSize: "var(--fs-base)" }),
25425
- xl: (0, import_react167.css)({ height: "calc(48px - 2px)", fontSize: "var(--fs-base)" })
25386
+ sm: (0, import_react166.css)({ height: "calc(24px - 2px)", fontSize: "var(--fs-xs)" }),
25387
+ md: (0, import_react166.css)({ height: "calc(32px - 2px)", fontSize: "var(--fs-sm)" }),
25388
+ lg: (0, import_react166.css)({ height: "calc(40px - 2px)", fontSize: "var(--fs-base)" }),
25389
+ xl: (0, import_react166.css)({ height: "calc(48px - 2px)", fontSize: "var(--fs-base)" })
25426
25390
  };
25427
25391
  return map[size];
25428
25392
  }, [size]);
25429
- const isIconOnly = (0, import_react168.useMemo)(() => {
25393
+ const isIconOnly = (0, import_react167.useMemo)(() => {
25430
25394
  return options.every((option) => option && option.icon && !option.label);
25431
25395
  }, [options]);
25432
- (0, import_react168.useEffect)(() => {
25396
+ (0, import_react167.useEffect)(() => {
25433
25397
  const wrapperElement = wrapperRef.current;
25434
25398
  const onScroll = () => {
25435
25399
  if (!wrapperElement) {
@@ -25524,12 +25488,12 @@ init_emotion_jsx_shim();
25524
25488
 
25525
25489
  // src/components/Skeleton/Skeleton.styles.ts
25526
25490
  init_emotion_jsx_shim();
25527
- var import_react169 = require("@emotion/react");
25528
- var lightFadingOut = import_react169.keyframes`
25491
+ var import_react168 = require("@emotion/react");
25492
+ var lightFadingOut = import_react168.keyframes`
25529
25493
  from { opacity: 0.1; }
25530
25494
  to { opacity: 0.025; }
25531
25495
  `;
25532
- var skeletonStyles = import_react169.css`
25496
+ var skeletonStyles = import_react168.css`
25533
25497
  animation: ${lightFadingOut} 1s ease-out infinite alternate;
25534
25498
  background-color: var(--gray-900);
25535
25499
  `;
@@ -25564,12 +25528,12 @@ var Skeleton = ({
25564
25528
 
25565
25529
  // src/components/Switch/Switch.tsx
25566
25530
  init_emotion_jsx_shim();
25567
- var import_react171 = require("react");
25531
+ var import_react170 = require("react");
25568
25532
 
25569
25533
  // src/components/Switch/Switch.styles.ts
25570
25534
  init_emotion_jsx_shim();
25571
- var import_react170 = require("@emotion/react");
25572
- var SwitchInputContainer = import_react170.css`
25535
+ var import_react169 = require("@emotion/react");
25536
+ var SwitchInputContainer = import_react169.css`
25573
25537
  cursor: pointer;
25574
25538
  display: inline-block;
25575
25539
  position: relative;
@@ -25578,7 +25542,7 @@ var SwitchInputContainer = import_react170.css`
25578
25542
  vertical-align: middle;
25579
25543
  user-select: none;
25580
25544
  `;
25581
- var SwitchInput = (size) => import_react170.css`
25545
+ var SwitchInput = (size) => import_react169.css`
25582
25546
  appearance: none;
25583
25547
  border-radius: var(--rounded-full);
25584
25548
  background-color: var(--white);
@@ -25618,7 +25582,7 @@ var SwitchInput = (size) => import_react170.css`
25618
25582
  cursor: not-allowed;
25619
25583
  }
25620
25584
  `;
25621
- var SwitchInputDisabled = import_react170.css`
25585
+ var SwitchInputDisabled = import_react169.css`
25622
25586
  opacity: var(--opacity-50);
25623
25587
  cursor: not-allowed;
25624
25588
 
@@ -25626,7 +25590,7 @@ var SwitchInputDisabled = import_react170.css`
25626
25590
  cursor: not-allowed;
25627
25591
  }
25628
25592
  `;
25629
- var SwitchInputLabel = (size) => import_react170.css`
25593
+ var SwitchInputLabel = (size) => import_react169.css`
25630
25594
  align-items: center;
25631
25595
  color: var(--typography-base);
25632
25596
  display: inline-flex;
@@ -25648,7 +25612,7 @@ var SwitchInputLabel = (size) => import_react170.css`
25648
25612
  top: 0;
25649
25613
  }
25650
25614
  `;
25651
- var SwitchText = (size) => import_react170.css`
25615
+ var SwitchText = (size) => import_react169.css`
25652
25616
  color: var(--gray-500);
25653
25617
  font-size: var(--fs-sm);
25654
25618
  padding-inline: ${size === "sm" ? "var(--spacing-xl)" : "var(--spacing-2xl)"} 0;
@@ -25656,7 +25620,7 @@ var SwitchText = (size) => import_react170.css`
25656
25620
 
25657
25621
  // src/components/Switch/Switch.tsx
25658
25622
  var import_jsx_runtime141 = require("@emotion/react/jsx-runtime");
25659
- var Switch = (0, import_react171.forwardRef)(
25623
+ var Switch = (0, import_react170.forwardRef)(
25660
25624
  ({ label, infoText, toggleText, children, switchSize = "base", ...inputProps }, ref) => {
25661
25625
  let additionalText = infoText;
25662
25626
  if (infoText && toggleText) {
@@ -25685,8 +25649,8 @@ var React24 = __toESM(require("react"));
25685
25649
 
25686
25650
  // src/components/Table/Table.styles.ts
25687
25651
  init_emotion_jsx_shim();
25688
- var import_react172 = require("@emotion/react");
25689
- var table = ({ cellPadding = "var(--spacing-sm) var(--spacing-md)" }) => import_react172.css`
25652
+ var import_react171 = require("@emotion/react");
25653
+ var table = ({ cellPadding = "var(--spacing-sm) var(--spacing-md)" }) => import_react171.css`
25690
25654
  border-bottom: 1px solid var(--gray-400);
25691
25655
  border-collapse: collapse;
25692
25656
  min-width: 100%;
@@ -25706,14 +25670,14 @@ var table = ({ cellPadding = "var(--spacing-sm) var(--spacing-md)" }) => import_
25706
25670
  background-color: var(--gray-50);
25707
25671
  }
25708
25672
  `;
25709
- var tableHead = import_react172.css`
25673
+ var tableHead = import_react171.css`
25710
25674
  color: var(--typography-base);
25711
25675
  text-align: left;
25712
25676
  `;
25713
- var tableRow = import_react172.css`
25677
+ var tableRow = import_react171.css`
25714
25678
  border-bottom: 1px solid var(--gray-100);
25715
25679
  `;
25716
- var tableCellHead = import_react172.css`
25680
+ var tableCellHead = import_react171.css`
25717
25681
  font-size: var(--fs-sm);
25718
25682
  text-transform: uppercase;
25719
25683
  font-weight: var(--fw-bold);
@@ -25759,13 +25723,13 @@ var TableCellData = React24.forwardRef(
25759
25723
 
25760
25724
  // src/components/Tabs/Tabs.tsx
25761
25725
  init_emotion_jsx_shim();
25762
- var import_react174 = require("@ariakit/react");
25763
- var import_react175 = require("react");
25726
+ var import_react173 = require("@ariakit/react");
25727
+ var import_react174 = require("react");
25764
25728
 
25765
25729
  // src/components/Tabs/Tabs.styles.ts
25766
25730
  init_emotion_jsx_shim();
25767
- var import_react173 = require("@emotion/react");
25768
- var tabButtonStyles = import_react173.css`
25731
+ var import_react172 = require("@emotion/react");
25732
+ var tabButtonStyles = import_react172.css`
25769
25733
  align-items: center;
25770
25734
  border: 0;
25771
25735
  height: 2.5rem;
@@ -25782,7 +25746,7 @@ var tabButtonStyles = import_react173.css`
25782
25746
  box-shadow: inset 0 -2px 0 var(--brand-secondary-3);
25783
25747
  }
25784
25748
  `;
25785
- var tabButtonGroupStyles = import_react173.css`
25749
+ var tabButtonGroupStyles = import_react172.css`
25786
25750
  display: flex;
25787
25751
  gap: var(--spacing-base);
25788
25752
  border-bottom: 1px solid var(--gray-300);
@@ -25791,7 +25755,7 @@ var tabButtonGroupStyles = import_react173.css`
25791
25755
  // src/components/Tabs/Tabs.tsx
25792
25756
  var import_jsx_runtime143 = require("@emotion/react/jsx-runtime");
25793
25757
  var useCurrentTab = () => {
25794
- const context = (0, import_react174.useTabStore)();
25758
+ const context = (0, import_react173.useTabStore)();
25795
25759
  if (!context) {
25796
25760
  throw new Error("This component can only be used inside <Tabs>");
25797
25761
  }
@@ -25805,12 +25769,12 @@ var Tabs = ({
25805
25769
  manual,
25806
25770
  ...props
25807
25771
  }) => {
25808
- const selected = (0, import_react175.useMemo)(() => {
25772
+ const selected = (0, import_react174.useMemo)(() => {
25809
25773
  if (selectedId) return selectedId;
25810
25774
  return useHashForState && typeof window !== "undefined" && window.location.hash ? window.location.hash.substring(1) : void 0;
25811
25775
  }, [selectedId, useHashForState]);
25812
- const tab = (0, import_react174.useTabStore)({ ...props, selectOnMove: !manual, selectedId: selected });
25813
- const onTabSelect = (0, import_react175.useCallback)(
25776
+ const tab = (0, import_react173.useTabStore)({ ...props, selectOnMove: !manual, selectedId: selected });
25777
+ const onTabSelect = (0, import_react174.useCallback)(
25814
25778
  (value) => {
25815
25779
  const selectedValueWithoutNull = value != null ? value : void 0;
25816
25780
  onSelectedIdChange == null ? void 0 : onSelectedIdChange(selectedValueWithoutNull);
@@ -25821,28 +25785,28 @@ var Tabs = ({
25821
25785
  },
25822
25786
  [onSelectedIdChange, useHashForState]
25823
25787
  );
25824
- (0, import_react175.useEffect)(() => {
25788
+ (0, import_react174.useEffect)(() => {
25825
25789
  if (selected && selected !== tab.getState().activeId) {
25826
25790
  tab.setSelectedId(selected);
25827
25791
  }
25828
25792
  }, [selected, tab]);
25829
- return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_react174.TabProvider, { store: tab, setSelectedId: onTabSelect, children });
25793
+ return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_react173.TabProvider, { store: tab, setSelectedId: onTabSelect, children });
25830
25794
  };
25831
25795
  var TabButtonGroup = ({ children, ...props }) => {
25832
- return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_react174.TabList, { ...props, css: tabButtonGroupStyles, children });
25796
+ return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_react173.TabList, { ...props, css: tabButtonGroupStyles, children });
25833
25797
  };
25834
25798
  var TabButton = ({
25835
25799
  children,
25836
25800
  id,
25837
25801
  ...props
25838
25802
  }) => {
25839
- return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_react174.Tab, { type: "button", id, ...props, css: tabButtonStyles, children });
25803
+ return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_react173.Tab, { type: "button", id, ...props, css: tabButtonStyles, children });
25840
25804
  };
25841
25805
  var TabContent = ({
25842
25806
  children,
25843
25807
  ...props
25844
25808
  }) => {
25845
- return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_react174.TabPanel, { ...props, children });
25809
+ return /* @__PURE__ */ (0, import_jsx_runtime143.jsx)(import_react173.TabPanel, { ...props, children });
25846
25810
  };
25847
25811
 
25848
25812
  // src/components/Validation/StatusBullet.tsx
@@ -25850,8 +25814,8 @@ init_emotion_jsx_shim();
25850
25814
 
25851
25815
  // src/components/Validation/StatusBullet.styles.ts
25852
25816
  init_emotion_jsx_shim();
25853
- var import_react176 = require("@emotion/react");
25854
- var StatusBulletContainer = import_react176.css`
25817
+ var import_react175 = require("@emotion/react");
25818
+ var StatusBulletContainer = import_react175.css`
25855
25819
  align-items: center;
25856
25820
  align-self: center;
25857
25821
  color: var(--gray-500);
@@ -25868,33 +25832,33 @@ var StatusBulletContainer = import_react176.css`
25868
25832
  display: block;
25869
25833
  }
25870
25834
  `;
25871
- var StatusBulletBase = import_react176.css`
25835
+ var StatusBulletBase = import_react175.css`
25872
25836
  font-size: var(--fs-sm);
25873
25837
  &:before {
25874
25838
  width: var(--fs-xs);
25875
25839
  height: var(--fs-xs);
25876
25840
  }
25877
25841
  `;
25878
- var StatusBulletSmall = import_react176.css`
25842
+ var StatusBulletSmall = import_react175.css`
25879
25843
  font-size: var(--fs-xs);
25880
25844
  &:before {
25881
25845
  width: var(--fs-xxs);
25882
25846
  height: var(--fs-xxs);
25883
25847
  }
25884
25848
  `;
25885
- var StatusDraft = import_react176.css`
25849
+ var StatusDraft = import_react175.css`
25886
25850
  &:before {
25887
25851
  background: var(--white);
25888
25852
  box-shadow: inset 0 0 0 0.125rem var(--accent-dark);
25889
25853
  }
25890
25854
  `;
25891
- var StatusModified = import_react176.css`
25855
+ var StatusModified = import_react175.css`
25892
25856
  &:before {
25893
25857
  background: linear-gradient(to right, var(--white) 50%, var(--accent-dark) 50% 100%);
25894
25858
  box-shadow: inset 0 0 0 0.125rem var(--accent-dark);
25895
25859
  }
25896
25860
  `;
25897
- var StatusError = import_react176.css`
25861
+ var StatusError = import_react175.css`
25898
25862
  color: var(--error);
25899
25863
  &:before {
25900
25864
  /* TODO: replace this with an svg icon */
@@ -25907,22 +25871,22 @@ var StatusError = import_react176.css`
25907
25871
  );
25908
25872
  }
25909
25873
  `;
25910
- var StatusPublished = import_react176.css`
25874
+ var StatusPublished = import_react175.css`
25911
25875
  &:before {
25912
25876
  background: var(--accent-dark);
25913
25877
  }
25914
25878
  `;
25915
- var StatusOrphan = import_react176.css`
25879
+ var StatusOrphan = import_react175.css`
25916
25880
  &:before {
25917
25881
  background: var(--brand-secondary-5);
25918
25882
  }
25919
25883
  `;
25920
- var StatusUnknown = import_react176.css`
25884
+ var StatusUnknown = import_react175.css`
25921
25885
  &:before {
25922
25886
  background: var(--gray-800);
25923
25887
  }
25924
25888
  `;
25925
- var StatusDeleted = import_react176.css`
25889
+ var StatusDeleted = import_react175.css`
25926
25890
  &:before {
25927
25891
  background: var(--error);
25928
25892
  }