@sustaina/shared-ui 1.61.0 → 1.62.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 +76 -111
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -111
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4514,7 +4514,10 @@ var FieldSelect = ({ row, fieldOptions, onChangeField }) => /* @__PURE__ */ jsxR
|
|
|
4514
4514
|
children: /* @__PURE__ */ jsxRuntime.jsx(SelectValue, { placeholder: "Select field" })
|
|
4515
4515
|
}
|
|
4516
4516
|
),
|
|
4517
|
-
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { className: "w-full min-w-[unset]", children: fieldOptions.map((f) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: f.value, children: f.
|
|
4517
|
+
/* @__PURE__ */ jsxRuntime.jsx(SelectContent, { className: "w-full min-w-[unset]", children: fieldOptions.map((f) => /* @__PURE__ */ jsxRuntime.jsx(SelectItem, { value: f.value, children: f.decorator ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center", children: [
|
|
4518
|
+
f.decorator,
|
|
4519
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(f.labelStyle), children: f.label })
|
|
4520
|
+
] }) : f.label }, f.value)) })
|
|
4518
4521
|
] }) });
|
|
4519
4522
|
|
|
4520
4523
|
// src/components/advanceSearch/types.ts
|
|
@@ -5694,7 +5697,7 @@ function MonthCal({
|
|
|
5694
5697
|
setMenuYear(year);
|
|
5695
5698
|
}
|
|
5696
5699
|
}
|
|
5697
|
-
}, [selectedMonthDate
|
|
5700
|
+
}, [selectedMonthDate]);
|
|
5698
5701
|
React__namespace.useEffect(() => {
|
|
5699
5702
|
if (typeof minYear === "number" && menuYear < minYear) {
|
|
5700
5703
|
setMenuYear(minYear);
|
|
@@ -7418,6 +7421,13 @@ var ConditionDropdownInput = ({ row, control, fieldSchema, onClear }) => {
|
|
|
7418
7421
|
showClear: hasValue,
|
|
7419
7422
|
showSearch: true,
|
|
7420
7423
|
virtual: false,
|
|
7424
|
+
labelRender: (option) => {
|
|
7425
|
+
const opt = option;
|
|
7426
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center", children: [
|
|
7427
|
+
opt.decorator,
|
|
7428
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(opt.labelStyle), children: opt.label })
|
|
7429
|
+
] });
|
|
7430
|
+
},
|
|
7421
7431
|
onSelect: (val) => field.onChange(val),
|
|
7422
7432
|
onClear: handleClear
|
|
7423
7433
|
}
|
|
@@ -17168,60 +17178,11 @@ var Input2 = React__namespace.forwardRef(
|
|
|
17168
17178
|
}
|
|
17169
17179
|
);
|
|
17170
17180
|
Input2.displayName = "Input";
|
|
17171
|
-
function useFillDecimalOnBlur({
|
|
17172
|
-
enabled,
|
|
17173
|
-
decimalScale,
|
|
17174
|
-
value,
|
|
17175
|
-
defaultValue
|
|
17176
|
-
}) {
|
|
17177
|
-
const blurScale = enabled ? decimalScale ?? 2 : void 0;
|
|
17178
|
-
const isUserEditingRef = React__namespace.useRef(false);
|
|
17179
|
-
const [formattedValue, setFormattedValue] = React__namespace.useState(() => {
|
|
17180
|
-
if (!enabled) return void 0;
|
|
17181
|
-
const scale = decimalScale ?? 2;
|
|
17182
|
-
const initial = parseToNumber(value) ?? parseToNumber(defaultValue);
|
|
17183
|
-
if (initial !== void 0) return truncateToFixed(initial, scale);
|
|
17184
|
-
return void 0;
|
|
17185
|
-
});
|
|
17186
|
-
React__namespace.useEffect(() => {
|
|
17187
|
-
if (!enabled) return;
|
|
17188
|
-
const parsed = parseToNumber(value);
|
|
17189
|
-
if (parsed !== void 0) {
|
|
17190
|
-
if (blurScale !== void 0 && !isUserEditingRef.current) {
|
|
17191
|
-
setFormattedValue(truncateToFixed(parsed, blurScale));
|
|
17192
|
-
}
|
|
17193
|
-
} else if (value === null || value === "") {
|
|
17194
|
-
setFormattedValue(void 0);
|
|
17195
|
-
}
|
|
17196
|
-
}, [value, enabled, blurScale]);
|
|
17197
|
-
const onEdit = React__namespace.useCallback(
|
|
17198
|
-
(values, sourceInfo) => {
|
|
17199
|
-
if (!enabled || sourceInfo.source !== "event") return;
|
|
17200
|
-
isUserEditingRef.current = true;
|
|
17201
|
-
setFormattedValue(values.value || void 0);
|
|
17202
|
-
},
|
|
17203
|
-
[enabled]
|
|
17204
|
-
);
|
|
17205
|
-
const onBlur = React__namespace.useCallback(
|
|
17206
|
-
(truncatedStr) => {
|
|
17207
|
-
isUserEditingRef.current = false;
|
|
17208
|
-
if (!enabled || blurScale === void 0) return;
|
|
17209
|
-
setFormattedValue(truncatedStr);
|
|
17210
|
-
},
|
|
17211
|
-
[enabled, blurScale]
|
|
17212
|
-
);
|
|
17213
|
-
const resetEditing = React__namespace.useCallback(() => {
|
|
17214
|
-
isUserEditingRef.current = false;
|
|
17215
|
-
}, []);
|
|
17216
|
-
return { formattedValue, blurScale, onEdit, onBlur, resetEditing, setFormattedValue };
|
|
17217
|
-
}
|
|
17218
17181
|
function useStepper({ value, step, min, max, disabled, onStep }) {
|
|
17219
|
-
const [changed, setChanged] = React__namespace.useState(false);
|
|
17220
17182
|
const changeValue = React__namespace.useCallback(
|
|
17221
17183
|
(delta) => {
|
|
17222
17184
|
const current = value ?? 0;
|
|
17223
17185
|
const clamped = clamp(current + delta, min, max);
|
|
17224
|
-
setChanged(true);
|
|
17225
17186
|
onStep(clamped);
|
|
17226
17187
|
},
|
|
17227
17188
|
[value, max, min, onStep]
|
|
@@ -17230,7 +17191,7 @@ function useStepper({ value, step, min, max, disabled, onStep }) {
|
|
|
17230
17191
|
const decrement = React__namespace.useCallback(() => changeValue(-step), [changeValue, step]);
|
|
17231
17192
|
const isIncrementDisabled = disabled || max !== void 0 && (value ?? 0) >= max;
|
|
17232
17193
|
const isDecrementDisabled = disabled || min !== void 0 && (value ?? 0) <= min;
|
|
17233
|
-
return {
|
|
17194
|
+
return { increment, decrement, isIncrementDisabled, isDecrementDisabled };
|
|
17234
17195
|
}
|
|
17235
17196
|
var InputNumber = ({
|
|
17236
17197
|
customInputProps,
|
|
@@ -17254,26 +17215,37 @@ var InputNumber = ({
|
|
|
17254
17215
|
...props
|
|
17255
17216
|
}) => {
|
|
17256
17217
|
const blurFormatEnabled = fillDecimalOnBlur || truncateDecimalOnBlur;
|
|
17257
|
-
const
|
|
17218
|
+
const blurScale = blurFormatEnabled ? decimalScaleProp ?? 2 : void 0;
|
|
17219
|
+
const [displayOverride, setDisplayOverride] = React__namespace.useState(() => {
|
|
17220
|
+
if (!blurFormatEnabled) return void 0;
|
|
17221
|
+
const scale = decimalScaleProp ?? 2;
|
|
17222
|
+
const initial = parseToNumber(value) ?? parseToNumber(defaultValue);
|
|
17223
|
+
if (initial !== void 0) return truncateToFixed(initial, scale);
|
|
17224
|
+
return void 0;
|
|
17225
|
+
});
|
|
17226
|
+
const [numericValue, setNumericValue] = React__namespace.useState(
|
|
17258
17227
|
() => parseToNumber(value) ?? parseToNumber(defaultValue)
|
|
17259
17228
|
);
|
|
17260
|
-
const
|
|
17261
|
-
const
|
|
17262
|
-
const
|
|
17263
|
-
|
|
17264
|
-
|
|
17265
|
-
if (
|
|
17266
|
-
|
|
17267
|
-
|
|
17268
|
-
|
|
17269
|
-
|
|
17270
|
-
|
|
17271
|
-
|
|
17272
|
-
|
|
17273
|
-
|
|
17274
|
-
|
|
17275
|
-
|
|
17276
|
-
|
|
17229
|
+
const isEditingRef = React__namespace.useRef(false);
|
|
17230
|
+
const rawRef = React__namespace.useRef("");
|
|
17231
|
+
const prevValueRef = React__namespace.useRef(value);
|
|
17232
|
+
if (value !== prevValueRef.current) {
|
|
17233
|
+
prevValueRef.current = value;
|
|
17234
|
+
if (value === "" || value === null) {
|
|
17235
|
+
if (displayOverride !== void 0) setDisplayOverride(void 0);
|
|
17236
|
+
if (numericValue !== void 0) setNumericValue(void 0);
|
|
17237
|
+
isEditingRef.current = false;
|
|
17238
|
+
} else if (!isEditingRef.current) {
|
|
17239
|
+
const num = parseToNumber(value);
|
|
17240
|
+
if (num !== numericValue) setNumericValue(num);
|
|
17241
|
+
if (blurFormatEnabled && num !== void 0) {
|
|
17242
|
+
const formatted = truncateToFixed(num, blurScale);
|
|
17243
|
+
if (formatted !== displayOverride) setDisplayOverride(formatted);
|
|
17244
|
+
} else {
|
|
17245
|
+
if (displayOverride !== void 0) setDisplayOverride(void 0);
|
|
17246
|
+
}
|
|
17247
|
+
}
|
|
17248
|
+
}
|
|
17277
17249
|
const isAllowed = React__namespace.useMemo(() => {
|
|
17278
17250
|
if (maxIntegerDigits === void 0 && !isAllowedProp) return void 0;
|
|
17279
17251
|
return (values) => {
|
|
@@ -17286,80 +17258,73 @@ var InputNumber = ({
|
|
|
17286
17258
|
return isAllowedProp ? isAllowedProp(values) : true;
|
|
17287
17259
|
};
|
|
17288
17260
|
}, [maxIntegerDigits, isAllowedProp]);
|
|
17289
|
-
const notifyChange = React__namespace.useCallback(
|
|
17290
|
-
(newValue, event) => {
|
|
17291
|
-
internalValueRef.current = newValue;
|
|
17292
|
-
setInternalValue(newValue);
|
|
17293
|
-
onStepChange?.(newValue);
|
|
17294
|
-
onValueChange?.(
|
|
17295
|
-
{ floatValue: newValue, formattedValue: String(newValue), value: String(newValue) },
|
|
17296
|
-
createSourceInfo(event)
|
|
17297
|
-
);
|
|
17298
|
-
},
|
|
17299
|
-
[onStepChange, onValueChange]
|
|
17300
|
-
);
|
|
17301
17261
|
const stepper = useStepper({
|
|
17302
|
-
value:
|
|
17262
|
+
value: numericValue,
|
|
17303
17263
|
step,
|
|
17304
17264
|
min,
|
|
17305
17265
|
max,
|
|
17306
17266
|
disabled,
|
|
17307
17267
|
onStep: React__namespace.useCallback(
|
|
17308
17268
|
(clamped) => {
|
|
17309
|
-
|
|
17310
|
-
|
|
17311
|
-
|
|
17312
|
-
|
|
17313
|
-
|
|
17269
|
+
setNumericValue(clamped);
|
|
17270
|
+
const formatted = blurScale !== void 0 ? truncateToFixed(clamped, blurScale) : String(clamped);
|
|
17271
|
+
setDisplayOverride(formatted);
|
|
17272
|
+
rawRef.current = String(clamped);
|
|
17273
|
+
onStepChange?.(clamped);
|
|
17274
|
+
onValueChange?.(
|
|
17275
|
+
{ floatValue: clamped, formattedValue: formatted, value: String(clamped) },
|
|
17276
|
+
createSourceInfo()
|
|
17277
|
+
);
|
|
17314
17278
|
},
|
|
17315
|
-
[
|
|
17279
|
+
[blurScale, onStepChange, onValueChange]
|
|
17316
17280
|
)
|
|
17317
17281
|
});
|
|
17318
17282
|
const handleValueChange = React__namespace.useCallback(
|
|
17319
17283
|
(values, sourceInfo) => {
|
|
17320
|
-
internalValueRef.current = values.floatValue;
|
|
17321
|
-
rawValueRef.current = values.value;
|
|
17322
|
-
setInternalValue(values.floatValue);
|
|
17323
17284
|
if (sourceInfo.source === "event") {
|
|
17324
|
-
|
|
17285
|
+
isEditingRef.current = true;
|
|
17286
|
+
setDisplayOverride(values.value);
|
|
17325
17287
|
}
|
|
17288
|
+
setNumericValue(values.floatValue);
|
|
17289
|
+
rawRef.current = values.value;
|
|
17326
17290
|
onValueChange?.(values, sourceInfo);
|
|
17327
17291
|
if (values.floatValue !== void 0) onStepChange?.(values.floatValue);
|
|
17328
|
-
autoFormat.onEdit(values, sourceInfo);
|
|
17329
17292
|
},
|
|
17330
|
-
[onValueChange, onStepChange
|
|
17293
|
+
[onValueChange, onStepChange]
|
|
17331
17294
|
);
|
|
17332
17295
|
const handleBlur = React__namespace.useCallback(
|
|
17333
17296
|
(event) => {
|
|
17297
|
+
isEditingRef.current = false;
|
|
17334
17298
|
onBlur?.(event);
|
|
17335
|
-
const
|
|
17336
|
-
if (
|
|
17337
|
-
|
|
17299
|
+
const currentNumeric = numericValue;
|
|
17300
|
+
if (currentNumeric === void 0) {
|
|
17301
|
+
setDisplayOverride("");
|
|
17338
17302
|
return;
|
|
17339
17303
|
}
|
|
17340
|
-
const clamped = clamp(
|
|
17341
|
-
const wasClamped = clamped !==
|
|
17304
|
+
const clamped = clamp(currentNumeric, min, max);
|
|
17305
|
+
const wasClamped = clamped !== currentNumeric;
|
|
17342
17306
|
if (wasClamped) {
|
|
17343
|
-
|
|
17344
|
-
|
|
17345
|
-
rawValueRef.current = String(clamped);
|
|
17346
|
-
setInternalValue(clamped);
|
|
17307
|
+
setNumericValue(clamped);
|
|
17308
|
+
rawRef.current = String(clamped);
|
|
17347
17309
|
onValueChange?.(
|
|
17348
17310
|
{ floatValue: clamped, formattedValue: String(clamped), value: String(clamped) },
|
|
17349
17311
|
createSourceInfo()
|
|
17350
17312
|
);
|
|
17351
17313
|
onStepChange?.(clamped);
|
|
17352
17314
|
}
|
|
17353
|
-
if (blurFormatEnabled &&
|
|
17354
|
-
const rawStr = wasClamped ? String(clamped) :
|
|
17355
|
-
|
|
17315
|
+
if (blurFormatEnabled && blurScale !== void 0) {
|
|
17316
|
+
const rawStr = wasClamped ? String(clamped) : rawRef.current || String(clamped);
|
|
17317
|
+
setDisplayOverride(truncateStringToFixed(rawStr, blurScale));
|
|
17318
|
+
} else if (wasClamped) {
|
|
17319
|
+
setDisplayOverride(String(clamped));
|
|
17356
17320
|
} else {
|
|
17357
|
-
|
|
17321
|
+
setDisplayOverride(void 0);
|
|
17358
17322
|
}
|
|
17359
17323
|
},
|
|
17360
|
-
[onBlur, blurFormatEnabled,
|
|
17324
|
+
[onBlur, blurFormatEnabled, blurScale, numericValue, min, max, onValueChange, onStepChange]
|
|
17361
17325
|
);
|
|
17362
|
-
const
|
|
17326
|
+
const isValueExplicitlyEmpty = value === "" || value === null;
|
|
17327
|
+
const effectiveValue = isValueExplicitlyEmpty ? "" : displayOverride !== void 0 ? displayOverride : value;
|
|
17363
17328
|
const buttonClass = cn(
|
|
17364
17329
|
"flex items-center justify-center h-3 w-5 transition-colors outline-none",
|
|
17365
17330
|
"text-neutral-400 hover:text-neutral-600 active:text-neutral-900",
|
|
@@ -17375,7 +17340,7 @@ var InputNumber = ({
|
|
|
17375
17340
|
onBlur: handleBlur,
|
|
17376
17341
|
...isAllowed && { isAllowed },
|
|
17377
17342
|
...truncateDecimalOnBlur ? {} : fillDecimalOnBlur ? { decimalScale: decimalScaleProp } : { decimalScale: decimalScaleProp, fixedDecimalScale: fixedDecimalScaleProp },
|
|
17378
|
-
...
|
|
17343
|
+
...displayOverride !== void 0 && { valueIsNumericString: true },
|
|
17379
17344
|
...props,
|
|
17380
17345
|
disabled,
|
|
17381
17346
|
invalid,
|