@sustaina/shared-ui 1.20.0 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -555,6 +555,7 @@ type FormulaTokenConfig<TItem extends FormulaTokenSuggestion = FormulaTokenSugge
555
555
  type FormulaEditorProps = {
556
556
  value?: string;
557
557
  disabled?: boolean;
558
+ loading?: boolean;
558
559
  className?: string;
559
560
  editorClassName?: string;
560
561
  errorMessage?: ReactNode;
package/dist/index.d.ts CHANGED
@@ -555,6 +555,7 @@ type FormulaTokenConfig<TItem extends FormulaTokenSuggestion = FormulaTokenSugge
555
555
  type FormulaEditorProps = {
556
556
  value?: string;
557
557
  disabled?: boolean;
558
+ loading?: boolean;
558
559
  className?: string;
559
560
  editorClassName?: string;
560
561
  errorMessage?: ReactNode;
package/dist/index.js CHANGED
@@ -5129,7 +5129,8 @@ function DialogAlert({
5129
5129
  }, [onCancel, onOpenChange]);
5130
5130
  const handleConfirm = React4.useCallback(() => {
5131
5131
  onConfirm?.();
5132
- }, [onConfirm]);
5132
+ onOpenChange(false);
5133
+ }, [onConfirm, onOpenChange]);
5133
5134
  return /* @__PURE__ */ jsxRuntime.jsx(Dialog2, { open, onOpenChange: persistent ? () => {
5134
5135
  } : onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent2, { className: "max-w-md", showCloseButton: !persistent, children: [
5135
5136
  /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader2, { children: [
@@ -5391,6 +5392,26 @@ var getDialogAlertControls = () => ({
5391
5392
  closeDialogAlert,
5392
5393
  openErrorDialogAlert
5393
5394
  });
5395
+ function LoadingOverlay({
5396
+ className,
5397
+ fullscreen = true,
5398
+ spinnerClassName,
5399
+ ...props
5400
+ }) {
5401
+ return /* @__PURE__ */ jsxRuntime.jsx(
5402
+ "div",
5403
+ {
5404
+ "data-slot": "loading-overlay",
5405
+ className: cn(
5406
+ fullscreen ? "fixed z-100" : "absolute z-10",
5407
+ "inset-0 flex items-center justify-center transition-opacity duration-300",
5408
+ className
5409
+ ),
5410
+ ...props,
5411
+ children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { className: cn("size-50", spinnerClassName) })
5412
+ }
5413
+ );
5414
+ }
5394
5415
 
5395
5416
  // src/components/formulaEditor/constants/formulaOperation.ts
5396
5417
  var defaultOperators = [
@@ -6189,6 +6210,7 @@ var buildDocFromRaw = (raw, prefixMap, configLookup) => {
6189
6210
  var FormulaEditor = ({
6190
6211
  value,
6191
6212
  disabled,
6213
+ loading = false,
6192
6214
  className,
6193
6215
  editorClassName,
6194
6216
  errorMessage,
@@ -6223,6 +6245,7 @@ var FormulaEditor = ({
6223
6245
  const allowedOperators = React4.useMemo(() => operators.map((operator) => operator.value), [operators]);
6224
6246
  const displayError = errorMessage ?? fieldState?.error?.message;
6225
6247
  const hasError = Boolean(displayError);
6248
+ const isInteractionDisabled = Boolean(disabled || loading);
6226
6249
  const convertValueToContent = React4.useCallback(
6227
6250
  (input) => {
6228
6251
  if (!input) return "";
@@ -6265,16 +6288,17 @@ var FormulaEditor = ({
6265
6288
  hasError ? "border border-destructive" : "border focus-visible:border-ring",
6266
6289
  "w-full rounded-lg bg-white px-4 py-3",
6267
6290
  "overflow-y-auto whitespace-pre-wrap wrap-break-word focus:outline-none",
6268
- disabled && "pointer-events-none opacity-60",
6291
+ isInteractionDisabled && "pointer-events-none opacity-60",
6269
6292
  editorClassName
6270
- )
6293
+ ),
6294
+ ...loading ? { "aria-busy": "true" } : {}
6271
6295
  }
6272
6296
  }
6273
6297
  });
6274
6298
  React4.useEffect(() => {
6275
6299
  if (!editor) return;
6276
- editor.setEditable(!disabled);
6277
- }, [disabled, editor]);
6300
+ editor.setEditable(!isInteractionDisabled);
6301
+ }, [editor, isInteractionDisabled]);
6278
6302
  React4.useEffect(() => {
6279
6303
  if (!editor || resolvedContent === void 0) return;
6280
6304
  if (ignorePropValueRef.current && typeof value === "string" && value === lastEmittedValueRef.current) {
@@ -6306,6 +6330,7 @@ var FormulaEditor = ({
6306
6330
  onBlur: field?.onBlur,
6307
6331
  tabIndex: 0,
6308
6332
  className: "relative",
6333
+ "aria-busy": loading,
6309
6334
  onFocus: () => {
6310
6335
  if (editor && !editor.isFocused) {
6311
6336
  editor.chain().focus().run();
@@ -6313,6 +6338,14 @@ var FormulaEditor = ({
6313
6338
  },
6314
6339
  children: [
6315
6340
  /* @__PURE__ */ jsxRuntime.jsx(react.EditorContent, { editor }),
6341
+ loading && /* @__PURE__ */ jsxRuntime.jsx(
6342
+ LoadingOverlay,
6343
+ {
6344
+ fullscreen: false,
6345
+ className: "rounded-lg bg-white/80 backdrop-blur-sm",
6346
+ spinnerClassName: "size-6 text-sus-blue-3"
6347
+ }
6348
+ ),
6316
6349
  /* @__PURE__ */ jsxRuntime.jsx(
6317
6350
  Button,
6318
6351
  {
@@ -6320,6 +6353,7 @@ var FormulaEditor = ({
6320
6353
  variant: "ghost",
6321
6354
  size: "icon",
6322
6355
  className: "absolute bottom-2 right-4 h-6 w-6 rounded-full bg-white shadow",
6356
+ disabled: isInteractionDisabled,
6323
6357
  onClick: () => setIsExpanded((prev) => !prev),
6324
6358
  children: isExpanded ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minimize2, { className: "h-4 w-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Maximize2, { className: "h-4 w-4" })
6325
6359
  }
@@ -6334,7 +6368,7 @@ var FormulaEditor = ({
6334
6368
  type: "button",
6335
6369
  onClick: () => insertOperator(operator.value),
6336
6370
  className: "min-w-10 rounded-sm px-3 bg-sus-blue-3",
6337
- disabled,
6371
+ disabled: isInteractionDisabled,
6338
6372
  children: operator.label
6339
6373
  },
6340
6374
  operator.value
@@ -6740,26 +6774,6 @@ var useGridSettingsStore = zustand.create(
6740
6774
  })
6741
6775
  );
6742
6776
  var useGridSettingsStore_default = useGridSettingsStore;
6743
- function LoadingOverlay({
6744
- className,
6745
- fullscreen = true,
6746
- spinnerClassName,
6747
- ...props
6748
- }) {
6749
- return /* @__PURE__ */ jsxRuntime.jsx(
6750
- "div",
6751
- {
6752
- "data-slot": "loading-overlay",
6753
- className: cn(
6754
- fullscreen ? "fixed z-100" : "absolute z-10",
6755
- "inset-0 flex items-center justify-center transition-opacity duration-300",
6756
- className
6757
- ),
6758
- ...props,
6759
- children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { className: cn("size-50", spinnerClassName) })
6760
- }
6761
- );
6762
- }
6763
6777
  var DEVICE_SIZES = [320, 420, 640, 768, 1024, 1280, 1536, 1920];
6764
6778
  var IMAGE_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];
6765
6779
  var defaultLoader = ({ src }) => src;