@embeddable.com/remarkable-ui 2.0.43 → 2.0.45

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
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  styles
3
- } from "./chunk-54RMM3OQ.js";
3
+ } from "./chunk-TZ3EDAGU.js";
4
4
 
5
5
  // src/components/charts/bars/BarChart.tsx
6
6
  import { useRef } from "react";
@@ -1861,7 +1861,7 @@ var TableBodyCellWithCopy = ({
1861
1861
  value,
1862
1862
  align = "left",
1863
1863
  children,
1864
- style
1864
+ style: style2
1865
1865
  }) => {
1866
1866
  const [isPressedCopy, setIsPressedCopy] = useState5(false);
1867
1867
  const handleCopy = () => {
@@ -1874,7 +1874,7 @@ var TableBodyCellWithCopy = ({
1874
1874
  "td",
1875
1875
  {
1876
1876
  title: value,
1877
- style: { textAlign: align, ...style },
1877
+ style: { textAlign: align, ...style2 },
1878
1878
  onMouseLeave: () => setIsPressedCopy(false),
1879
1879
  children: [
1880
1880
  /* @__PURE__ */ jsx12(
@@ -1923,7 +1923,7 @@ var TablePagination = ({
1923
1923
  if (totalPages && page >= totalPages) {
1924
1924
  onPageChange(0);
1925
1925
  }
1926
- }, [totalPages, page]);
1926
+ }, [totalPages, page, onPageChange]);
1927
1927
  return /* @__PURE__ */ jsx13("div", { className: styles10.tablePagination, "aria-label": "Table pagination controls", children: /* @__PURE__ */ jsxs7("div", { className: styles10.tablePaginationCentral, children: [
1928
1928
  /* @__PURE__ */ jsxs7("div", { className: styles10.tablePaginationCentralButtons, children: [
1929
1929
  /* @__PURE__ */ jsx13(
@@ -2182,8 +2182,9 @@ var DateRangePickerChevron = ({
2182
2182
  const rotation = orientation === "left" ? void 0 : "rotate(180deg)";
2183
2183
  const isSmallChevron = size === SMALL_SIZE;
2184
2184
  return /* @__PURE__ */ jsx16(
2185
- "button",
2185
+ "span",
2186
2186
  {
2187
+ "data-testid": "date-range-picker-chevron",
2187
2188
  className: clsx9(styles12.chevron, isSmallChevron && styles12.small),
2188
2189
  style: {
2189
2190
  transform: rotation
@@ -2300,7 +2301,7 @@ import { forwardRef as forwardRef3 } from "react";
2300
2301
  // src/components/shared/GhostButton/GhostButton.tsx
2301
2302
  import React3 from "react";
2302
2303
  import clsx11 from "clsx";
2303
- import styles14 from "./GhostButton.module-JZ7YOOU5.module.css";
2304
+ import styles14 from "./GhostButton.module-33OGL7WW.module.css";
2304
2305
  import { jsx as jsx20, jsxs as jsxs12 } from "react/jsx-runtime";
2305
2306
  var GhostButton = React3.forwardRef(
2306
2307
  ({ startIcon: StartIcon, endIcon: EndIcon, children, className, ...props }, ref) => {
@@ -2565,7 +2566,7 @@ import { forwardRef as forwardRef5 } from "react";
2565
2566
 
2566
2567
  // src/components/editors/inputs/shared/InputField/InputField.tsx
2567
2568
  import { IconX as IconX2 } from "@tabler/icons-react";
2568
- import styles20 from "./InputField.module-LDLOMDBK.module.css";
2569
+ import styles20 from "./InputField.module-DWUIQOWJ.module.css";
2569
2570
  import clsx16 from "clsx";
2570
2571
  import { forwardRef as forwardRef4 } from "react";
2571
2572
  import { jsx as jsx26, jsxs as jsxs16 } from "react/jsx-runtime";
@@ -2693,7 +2694,7 @@ import { Fragment as Fragment6, useEffect as useEffect8, useMemo as useMemo5, us
2693
2694
 
2694
2695
  // src/components/editors/selects/shared/SelectFieldContent/SelectFieldOptions/SelectFieldOption/SelectFieldOption.tsx
2695
2696
  import * as DropdownMenu2 from "@radix-ui/react-dropdown-menu";
2696
- import styles21 from "./SelectFieldOption.module-SH3TOVNB.module.css";
2697
+ import styles21 from "./SelectFieldOption.module-ZXJXUZWN.module.css";
2697
2698
  import clsx17 from "clsx";
2698
2699
  import { jsx as jsx29, jsxs as jsxs18 } from "react/jsx-runtime";
2699
2700
  var SelectListOption = ({
@@ -2786,6 +2787,7 @@ var MultiSelectField = ({
2786
2787
  label,
2787
2788
  required,
2788
2789
  disabled,
2790
+ disableApplyButton,
2789
2791
  isClearable,
2790
2792
  isLoading,
2791
2793
  isSearchable,
@@ -2796,6 +2798,7 @@ var MultiSelectField = ({
2796
2798
  values = [],
2797
2799
  avoidCollisions,
2798
2800
  onChange,
2801
+ onPendingChange,
2799
2802
  onSearch,
2800
2803
  error = false,
2801
2804
  errorMessage
@@ -2808,6 +2811,7 @@ var MultiSelectField = ({
2808
2811
  useSelectSearchFocus(isOpen, searchFieldRef);
2809
2812
  useEffect8(() => {
2810
2813
  setPreValues(values);
2814
+ onPendingChange?.(values);
2811
2815
  }, [JSON.stringify(values)]);
2812
2816
  useEffect8(() => {
2813
2817
  if (isLoading) {
@@ -2833,9 +2837,13 @@ var MultiSelectField = ({
2833
2837
  e.preventDefault();
2834
2838
  if (!newValue) return;
2835
2839
  if (preValues.includes(newValue)) {
2836
- setPreValues(preValues.filter((v) => v !== newValue));
2840
+ const next = preValues.filter((v) => v !== newValue);
2841
+ setPreValues(next);
2842
+ onPendingChange?.(next);
2837
2843
  } else {
2838
- setPreValues([...preValues, newValue]);
2844
+ const next = [...preValues, newValue];
2845
+ setPreValues(next);
2846
+ onPendingChange?.(next);
2839
2847
  }
2840
2848
  };
2841
2849
  const handleSearch = (newSearch) => {
@@ -2851,6 +2859,7 @@ var MultiSelectField = ({
2851
2859
  const handleClearAll = () => {
2852
2860
  setSearchValue("");
2853
2861
  onSearch?.("");
2862
+ onPendingChange?.([]);
2854
2863
  onChange([]);
2855
2864
  };
2856
2865
  const hasError = error || !!errorMessage;
@@ -2919,7 +2928,7 @@ var MultiSelectField = ({
2919
2928
  Button,
2920
2929
  {
2921
2930
  className: styles23.submitButton,
2922
- disabled: isSubmitDisabled || isLoading,
2931
+ disabled: isSubmitDisabled || isLoading || disableApplyButton,
2923
2932
  variant: "primary",
2924
2933
  size: "medium",
2925
2934
  onClick: () => handleSave(preValues),
@@ -3252,61 +3261,227 @@ var CardFeedback = ({
3252
3261
  ] });
3253
3262
  };
3254
3263
 
3255
- // src/components/shared/Overlay/Overlay.tsx
3264
+ // src/components/shared/GhostButtonIcon/GhostButtonIcon.tsx
3265
+ import React5 from "react";
3256
3266
  import clsx22 from "clsx";
3257
- import styles29 from "./Overlay.module-FCW64VWM.module.css";
3267
+ import style from "./GhostButtonIcon.module-6J6DJCE6.module.css";
3258
3268
  import { jsx as jsx38 } from "react/jsx-runtime";
3269
+ var GhostButtonIcon = React5.forwardRef(
3270
+ ({ icon: Icon, className, ...props }, ref) => {
3271
+ return /* @__PURE__ */ jsx38("button", { ref, className: clsx22(style.ghostButtonIcon, className), ...props, children: /* @__PURE__ */ jsx38(Icon, {}) });
3272
+ }
3273
+ );
3274
+ GhostButtonIcon.displayName = "GhostButtonIcon";
3275
+
3276
+ // src/components/shared/Overlay/Overlay.tsx
3277
+ import clsx23 from "clsx";
3278
+ import styles29 from "./Overlay.module-FCW64VWM.module.css";
3279
+ import { jsx as jsx39 } from "react/jsx-runtime";
3259
3280
  var Overlay = ({ className, children }) => {
3260
- return /* @__PURE__ */ jsx38("div", { className: clsx22(styles29.overlay, className), children });
3281
+ return /* @__PURE__ */ jsx39("div", { className: clsx23(styles29.overlay, className), children });
3261
3282
  };
3262
3283
 
3263
3284
  // src/components/shared/Skeleton/Skeleton.tsx
3264
3285
  import styles30 from "./Skeleton.module-ZN5S5VRF.module.css";
3265
- import { jsx as jsx39 } from "react/jsx-runtime";
3286
+ import { jsx as jsx40 } from "react/jsx-runtime";
3266
3287
  var Skeleton = () => {
3267
- return /* @__PURE__ */ jsx39("div", { className: styles30.skeleton });
3288
+ return /* @__PURE__ */ jsx40("div", { className: styles30.skeleton });
3268
3289
  };
3269
3290
 
3270
3291
  // src/components/shared/Typography/Typography.tsx
3271
3292
  import styles31 from "./Typography.module-SW6CT55P.module.css";
3272
- import clsx23 from "clsx";
3273
- import { jsx as jsx40 } from "react/jsx-runtime";
3293
+ import clsx24 from "clsx";
3294
+ import { jsx as jsx41 } from "react/jsx-runtime";
3274
3295
  function Typography({
3275
3296
  children,
3276
3297
  as: Component = "p",
3277
3298
  className,
3278
- style,
3299
+ style: style2,
3279
3300
  title
3280
3301
  }) {
3281
- return /* @__PURE__ */ jsx40(Component, { title, className: clsx23(styles31.typography, className), style, children });
3302
+ return /* @__PURE__ */ jsx41(Component, { title, className: clsx24(styles31.typography, className), style: style2, children });
3282
3303
  }
3283
3304
 
3284
3305
  // src/components/shared/Divider/Divider.tsx
3285
- import clsx24 from "clsx";
3306
+ import clsx25 from "clsx";
3286
3307
  import styles32 from "./Divider.module-2BOWHKT3.module.css";
3287
- import { jsx as jsx41 } from "react/jsx-runtime";
3308
+ import { jsx as jsx42 } from "react/jsx-runtime";
3288
3309
  var getStyle2 = (color, thickness, vertical) => {
3289
- const style = {};
3290
- if (color) style.backgroundColor = color;
3310
+ const style2 = {};
3311
+ if (color) style2.backgroundColor = color;
3291
3312
  if (thickness) {
3292
3313
  if (vertical) {
3293
- style.width = thickness;
3314
+ style2.width = thickness;
3294
3315
  } else {
3295
- style.height = thickness;
3316
+ style2.height = thickness;
3296
3317
  }
3297
3318
  }
3298
- return style;
3319
+ return style2;
3299
3320
  };
3300
3321
  var Divider = ({ color, thickness, vertical, className }) => {
3301
- return /* @__PURE__ */ jsx41(
3322
+ return /* @__PURE__ */ jsx42(
3302
3323
  "div",
3303
3324
  {
3304
- className: clsx24(styles32.divider, vertical && styles32.vertical, className),
3325
+ className: clsx25(styles32.divider, vertical && styles32.vertical, className),
3305
3326
  style: getStyle2(color, thickness, vertical)
3306
3327
  }
3307
3328
  );
3308
3329
  };
3309
3330
 
3331
+ // src/components/shared/Markdown/Markdown.tsx
3332
+ import { useMemo as useMemo7 } from "react";
3333
+ import ReactMarkdown from "react-markdown";
3334
+ import remarkGfm from "remark-gfm";
3335
+ import styles33 from "./Markdown.module-AIJ2C4S2.module.css";
3336
+ import { jsx as jsx43 } from "react/jsx-runtime";
3337
+ var normalizeEscapedNewlines = (input) => input?.replaceAll(String.raw`\n`, "\n");
3338
+ var Markdown = ({ content }) => {
3339
+ const resolvedContent = useMemo7(() => {
3340
+ return normalizeEscapedNewlines(content);
3341
+ }, [content]);
3342
+ return /* @__PURE__ */ jsx43("div", { className: styles33.markdown, children: /* @__PURE__ */ jsx43(ReactMarkdown, { remarkPlugins: [remarkGfm], children: resolvedContent }) });
3343
+ };
3344
+
3345
+ // src/components/shared/MarkdownEditor/MarkdownEditor.tsx
3346
+ import {
3347
+ IconBold,
3348
+ IconCode,
3349
+ IconEye,
3350
+ IconH1,
3351
+ IconItalic,
3352
+ IconLink,
3353
+ IconList,
3354
+ IconPencil,
3355
+ IconStrikethrough
3356
+ } from "@tabler/icons-react";
3357
+ import { useRef as useRef12, useState as useState10 } from "react";
3358
+ import styles34 from "./MarkdownEditor.module-2R7P4ZIL.module.css";
3359
+
3360
+ // src/components/shared/MarkdownEditor/MarkdownEditor.utils.ts
3361
+ var MAX_HISTORY = 100;
3362
+ var applyWrap = (value, start, end, syntax) => value.slice(0, start) + syntax + value.slice(start, end) + syntax + value.slice(end);
3363
+ var applyLinePrefix = (value, start, prefix) => {
3364
+ const lineStart = value.lastIndexOf("\n", start - 1) + 1;
3365
+ return value.slice(0, lineStart) + prefix + value.slice(lineStart);
3366
+ };
3367
+
3368
+ // src/components/shared/MarkdownEditor/MarkdownEditor.tsx
3369
+ import { jsx as jsx44, jsxs as jsxs25 } from "react/jsx-runtime";
3370
+ var MarkdownEditor = ({
3371
+ value: valueProp,
3372
+ onChange,
3373
+ placeholder
3374
+ }) => {
3375
+ const value = valueProp ?? "";
3376
+ const textareaRef = useRef12(null);
3377
+ const [history, setHistory] = useState10({ entries: [value], index: 0 });
3378
+ const [isPreview, setIsPreview] = useState10(false);
3379
+ const handleChange = (newValue) => {
3380
+ setHistory((prev) => {
3381
+ const entries = [...prev.entries.slice(0, prev.index + 1), newValue];
3382
+ const capped = entries.length > MAX_HISTORY ? entries.slice(-MAX_HISTORY) : entries;
3383
+ return { entries: capped, index: capped.length - 1 };
3384
+ });
3385
+ onChange?.(newValue);
3386
+ };
3387
+ const applyEdit = (edit) => {
3388
+ const textarea = textareaRef.current;
3389
+ if (!textarea) return;
3390
+ const { selectionStart: start, selectionEnd: end } = textarea;
3391
+ const result = edit(value, start, end);
3392
+ handleChange(result.value);
3393
+ requestAnimationFrame(() => {
3394
+ textarea.focus();
3395
+ textarea.setSelectionRange(...result.cursor);
3396
+ });
3397
+ };
3398
+ const handleWrap = (syntax) => applyEdit((text, start, end) => ({
3399
+ value: applyWrap(text, start, end, syntax),
3400
+ cursor: [start + syntax.length, end + syntax.length]
3401
+ }));
3402
+ const handlePrefix = (prefix) => applyEdit((text, start) => ({
3403
+ value: applyLinePrefix(text, start, prefix),
3404
+ cursor: [start + prefix.length, start + prefix.length]
3405
+ }));
3406
+ const handleLink = () => applyEdit((text, start, end) => ({
3407
+ value: text.slice(0, start) + `[${text.slice(start, end)}]()` + text.slice(end),
3408
+ cursor: [end + 3, end + 3]
3409
+ // cursor inside the ()
3410
+ }));
3411
+ const navigate = (delta) => {
3412
+ const newIndex = history.index + delta;
3413
+ if (newIndex < 0 || newIndex >= history.entries.length) return;
3414
+ const entry = history.entries[newIndex];
3415
+ if (entry === void 0) return;
3416
+ setHistory((prev) => ({ ...prev, index: newIndex }));
3417
+ onChange?.(entry);
3418
+ };
3419
+ const handleKeyDown = (e) => {
3420
+ if (!e.ctrlKey && !e.metaKey) return;
3421
+ const key = `${e.shiftKey ? "shift+" : ""}${e.key.toLowerCase()}`;
3422
+ const actions = {
3423
+ z: () => navigate(-1),
3424
+ "shift+z": () => navigate(1),
3425
+ y: () => navigate(1),
3426
+ b: () => handleWrap("**"),
3427
+ i: () => handleWrap("*"),
3428
+ k: handleLink,
3429
+ "`": () => handleWrap("`"),
3430
+ "shift+x": () => handleWrap("~~")
3431
+ };
3432
+ const action = actions[key];
3433
+ if (action) {
3434
+ e.preventDefault();
3435
+ action();
3436
+ }
3437
+ };
3438
+ const toolbarButtons = [
3439
+ { icon: IconBold, label: "Bold", onClick: () => handleWrap("**") },
3440
+ { icon: IconItalic, label: "Italic", onClick: () => handleWrap("*") },
3441
+ { icon: IconStrikethrough, label: "Strikethrough", onClick: () => handleWrap("~~") },
3442
+ { icon: IconCode, label: "Code", onClick: () => handleWrap("`") },
3443
+ { icon: IconH1, label: "Heading", onClick: () => handlePrefix("# ") },
3444
+ { icon: IconList, label: "Bullet list", onClick: () => handlePrefix("- ") },
3445
+ { icon: IconLink, label: "Link", onClick: handleLink }
3446
+ ];
3447
+ return /* @__PURE__ */ jsxs25("div", { className: styles34.container, children: [
3448
+ /* @__PURE__ */ jsxs25("div", { className: styles34.toolbar, children: [
3449
+ toolbarButtons.map(({ icon, label, onClick }) => /* @__PURE__ */ jsx44(
3450
+ GhostButtonIcon,
3451
+ {
3452
+ icon,
3453
+ "aria-label": label,
3454
+ disabled: isPreview,
3455
+ onMouseDown: (e) => e.preventDefault(),
3456
+ onClick
3457
+ },
3458
+ label
3459
+ )),
3460
+ /* @__PURE__ */ jsx44("div", { className: styles34.toolbarSpacer }),
3461
+ /* @__PURE__ */ jsx44(
3462
+ GhostButtonIcon,
3463
+ {
3464
+ icon: isPreview ? IconPencil : IconEye,
3465
+ "aria-label": isPreview ? "Edit" : "Preview",
3466
+ onMouseDown: (e) => e.preventDefault(),
3467
+ onClick: () => setIsPreview((prev) => !prev)
3468
+ }
3469
+ )
3470
+ ] }),
3471
+ isPreview ? /* @__PURE__ */ jsx44("div", { className: styles34.preview, children: /* @__PURE__ */ jsx44(Markdown, { content: value }) }) : /* @__PURE__ */ jsx44(
3472
+ "textarea",
3473
+ {
3474
+ ref: textareaRef,
3475
+ className: styles34.markdownEditor,
3476
+ value,
3477
+ onChange: (e) => handleChange(e.target.value),
3478
+ onKeyDown: handleKeyDown,
3479
+ placeholder
3480
+ }
3481
+ )
3482
+ ] });
3483
+ };
3484
+
3310
3485
  // src/utils/object.utils.ts
3311
3486
  var shallowEqual = (object1, object2) => {
3312
3487
  const keys1 = Object.keys(object1 ?? {});
@@ -3338,9 +3513,12 @@ export {
3338
3513
  FieldFeedback,
3339
3514
  FieldHeader,
3340
3515
  GhostButton,
3516
+ GhostButtonIcon,
3341
3517
  HeatMap,
3342
3518
  KpiChart,
3343
3519
  LineChart,
3520
+ Markdown,
3521
+ MarkdownEditor,
3344
3522
  MultiSelectField,
3345
3523
  NumberField,
3346
3524
  Overlay,