@sustaina/shared-ui 1.20.0 → 1.21.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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +47 -29
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +47 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
@@ -4396,9 +4396,6 @@ var DataTable = ({
|
|
|
4396
4396
|
columnResizeMode: columnResizing?.enabled ? columnResizing?.resizeMode ?? "onChange" : "onChange"
|
|
4397
4397
|
})
|
|
4398
4398
|
});
|
|
4399
|
-
if (isDefined(tableRef) && !isDefined(tableRef?.current)) {
|
|
4400
|
-
tableRef.current = table;
|
|
4401
|
-
}
|
|
4402
4399
|
const tableContainerRef = React4.useRef(null);
|
|
4403
4400
|
const isTableEmpty = table.getCoreRowModel().rows.length === 0;
|
|
4404
4401
|
const isTableEmptyAfterFiltering = table.getRowModel().rows.length === 0;
|
|
@@ -4476,6 +4473,13 @@ var DataTable = ({
|
|
|
4476
4473
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
4477
4474
|
[scrollFetch?.enabled, scrollFetch?.isFetchingMore, scrollFetch?.hasMore, scrollFetch?.fetchMore]
|
|
4478
4475
|
);
|
|
4476
|
+
React4.useEffect(() => {
|
|
4477
|
+
if (!tableRef) return;
|
|
4478
|
+
tableRef.current = table;
|
|
4479
|
+
return () => {
|
|
4480
|
+
tableRef.current = null;
|
|
4481
|
+
};
|
|
4482
|
+
}, [tableRef, table]);
|
|
4479
4483
|
React4.useEffect(() => {
|
|
4480
4484
|
fetchMoreOnScrollReached(tableContainerRef.current);
|
|
4481
4485
|
}, [fetchMoreOnScrollReached]);
|
|
@@ -5129,7 +5133,8 @@ function DialogAlert({
|
|
|
5129
5133
|
}, [onCancel, onOpenChange]);
|
|
5130
5134
|
const handleConfirm = React4.useCallback(() => {
|
|
5131
5135
|
onConfirm?.();
|
|
5132
|
-
|
|
5136
|
+
onOpenChange(false);
|
|
5137
|
+
}, [onConfirm, onOpenChange]);
|
|
5133
5138
|
return /* @__PURE__ */ jsxRuntime.jsx(Dialog2, { open, onOpenChange: persistent ? () => {
|
|
5134
5139
|
} : onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent2, { className: "max-w-md", showCloseButton: !persistent, children: [
|
|
5135
5140
|
/* @__PURE__ */ jsxRuntime.jsxs(DialogHeader2, { children: [
|
|
@@ -5391,6 +5396,26 @@ var getDialogAlertControls = () => ({
|
|
|
5391
5396
|
closeDialogAlert,
|
|
5392
5397
|
openErrorDialogAlert
|
|
5393
5398
|
});
|
|
5399
|
+
function LoadingOverlay({
|
|
5400
|
+
className,
|
|
5401
|
+
fullscreen = true,
|
|
5402
|
+
spinnerClassName,
|
|
5403
|
+
...props
|
|
5404
|
+
}) {
|
|
5405
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
5406
|
+
"div",
|
|
5407
|
+
{
|
|
5408
|
+
"data-slot": "loading-overlay",
|
|
5409
|
+
className: cn(
|
|
5410
|
+
fullscreen ? "fixed z-100" : "absolute z-10",
|
|
5411
|
+
"inset-0 flex items-center justify-center transition-opacity duration-300",
|
|
5412
|
+
className
|
|
5413
|
+
),
|
|
5414
|
+
...props,
|
|
5415
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, { className: cn("size-50", spinnerClassName) })
|
|
5416
|
+
}
|
|
5417
|
+
);
|
|
5418
|
+
}
|
|
5394
5419
|
|
|
5395
5420
|
// src/components/formulaEditor/constants/formulaOperation.ts
|
|
5396
5421
|
var defaultOperators = [
|
|
@@ -6189,6 +6214,7 @@ var buildDocFromRaw = (raw, prefixMap, configLookup) => {
|
|
|
6189
6214
|
var FormulaEditor = ({
|
|
6190
6215
|
value,
|
|
6191
6216
|
disabled,
|
|
6217
|
+
loading = false,
|
|
6192
6218
|
className,
|
|
6193
6219
|
editorClassName,
|
|
6194
6220
|
errorMessage,
|
|
@@ -6223,6 +6249,7 @@ var FormulaEditor = ({
|
|
|
6223
6249
|
const allowedOperators = React4.useMemo(() => operators.map((operator) => operator.value), [operators]);
|
|
6224
6250
|
const displayError = errorMessage ?? fieldState?.error?.message;
|
|
6225
6251
|
const hasError = Boolean(displayError);
|
|
6252
|
+
const isInteractionDisabled = Boolean(disabled || loading);
|
|
6226
6253
|
const convertValueToContent = React4.useCallback(
|
|
6227
6254
|
(input) => {
|
|
6228
6255
|
if (!input) return "";
|
|
@@ -6265,16 +6292,17 @@ var FormulaEditor = ({
|
|
|
6265
6292
|
hasError ? "border border-destructive" : "border focus-visible:border-ring",
|
|
6266
6293
|
"w-full rounded-lg bg-white px-4 py-3",
|
|
6267
6294
|
"overflow-y-auto whitespace-pre-wrap wrap-break-word focus:outline-none",
|
|
6268
|
-
|
|
6295
|
+
isInteractionDisabled && "pointer-events-none opacity-60",
|
|
6269
6296
|
editorClassName
|
|
6270
|
-
)
|
|
6297
|
+
),
|
|
6298
|
+
...loading ? { "aria-busy": "true" } : {}
|
|
6271
6299
|
}
|
|
6272
6300
|
}
|
|
6273
6301
|
});
|
|
6274
6302
|
React4.useEffect(() => {
|
|
6275
6303
|
if (!editor) return;
|
|
6276
|
-
editor.setEditable(!
|
|
6277
|
-
}, [
|
|
6304
|
+
editor.setEditable(!isInteractionDisabled);
|
|
6305
|
+
}, [editor, isInteractionDisabled]);
|
|
6278
6306
|
React4.useEffect(() => {
|
|
6279
6307
|
if (!editor || resolvedContent === void 0) return;
|
|
6280
6308
|
if (ignorePropValueRef.current && typeof value === "string" && value === lastEmittedValueRef.current) {
|
|
@@ -6306,6 +6334,7 @@ var FormulaEditor = ({
|
|
|
6306
6334
|
onBlur: field?.onBlur,
|
|
6307
6335
|
tabIndex: 0,
|
|
6308
6336
|
className: "relative",
|
|
6337
|
+
"aria-busy": loading,
|
|
6309
6338
|
onFocus: () => {
|
|
6310
6339
|
if (editor && !editor.isFocused) {
|
|
6311
6340
|
editor.chain().focus().run();
|
|
@@ -6313,6 +6342,14 @@ var FormulaEditor = ({
|
|
|
6313
6342
|
},
|
|
6314
6343
|
children: [
|
|
6315
6344
|
/* @__PURE__ */ jsxRuntime.jsx(react.EditorContent, { editor }),
|
|
6345
|
+
loading && /* @__PURE__ */ jsxRuntime.jsx(
|
|
6346
|
+
LoadingOverlay,
|
|
6347
|
+
{
|
|
6348
|
+
fullscreen: false,
|
|
6349
|
+
className: "rounded-lg bg-white/80 backdrop-blur-sm",
|
|
6350
|
+
spinnerClassName: "size-6 text-sus-blue-3"
|
|
6351
|
+
}
|
|
6352
|
+
),
|
|
6316
6353
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
6317
6354
|
Button,
|
|
6318
6355
|
{
|
|
@@ -6320,6 +6357,7 @@ var FormulaEditor = ({
|
|
|
6320
6357
|
variant: "ghost",
|
|
6321
6358
|
size: "icon",
|
|
6322
6359
|
className: "absolute bottom-2 right-4 h-6 w-6 rounded-full bg-white shadow",
|
|
6360
|
+
disabled: isInteractionDisabled,
|
|
6323
6361
|
onClick: () => setIsExpanded((prev) => !prev),
|
|
6324
6362
|
children: isExpanded ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Minimize2, { className: "h-4 w-4" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Maximize2, { className: "h-4 w-4" })
|
|
6325
6363
|
}
|
|
@@ -6334,7 +6372,7 @@ var FormulaEditor = ({
|
|
|
6334
6372
|
type: "button",
|
|
6335
6373
|
onClick: () => insertOperator(operator.value),
|
|
6336
6374
|
className: "min-w-10 rounded-sm px-3 bg-sus-blue-3",
|
|
6337
|
-
disabled,
|
|
6375
|
+
disabled: isInteractionDisabled,
|
|
6338
6376
|
children: operator.label
|
|
6339
6377
|
},
|
|
6340
6378
|
operator.value
|
|
@@ -6740,26 +6778,6 @@ var useGridSettingsStore = zustand.create(
|
|
|
6740
6778
|
})
|
|
6741
6779
|
);
|
|
6742
6780
|
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
6781
|
var DEVICE_SIZES = [320, 420, 640, 768, 1024, 1280, 1536, 1920];
|
|
6764
6782
|
var IMAGE_SIZES = [16, 32, 48, 64, 96, 128, 256, 384];
|
|
6765
6783
|
var defaultLoader = ({ src }) => src;
|