@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.mjs
CHANGED
|
@@ -4471,7 +4471,10 @@ var FieldSelect = ({ row, fieldOptions, onChangeField }) => /* @__PURE__ */ jsx(
|
|
|
4471
4471
|
children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select field" })
|
|
4472
4472
|
}
|
|
4473
4473
|
),
|
|
4474
|
-
/* @__PURE__ */ jsx(SelectContent, { className: "w-full min-w-[unset]", children: fieldOptions.map((f) => /* @__PURE__ */ jsx(SelectItem, { value: f.value, children: f.
|
|
4474
|
+
/* @__PURE__ */ jsx(SelectContent, { className: "w-full min-w-[unset]", children: fieldOptions.map((f) => /* @__PURE__ */ jsx(SelectItem, { value: f.value, children: f.decorator ? /* @__PURE__ */ jsxs("span", { className: "flex items-center", children: [
|
|
4475
|
+
f.decorator,
|
|
4476
|
+
/* @__PURE__ */ jsx("span", { className: cn(f.labelStyle), children: f.label })
|
|
4477
|
+
] }) : f.label }, f.value)) })
|
|
4475
4478
|
] }) });
|
|
4476
4479
|
|
|
4477
4480
|
// src/components/advanceSearch/types.ts
|
|
@@ -5651,7 +5654,7 @@ function MonthCal({
|
|
|
5651
5654
|
setMenuYear(year);
|
|
5652
5655
|
}
|
|
5653
5656
|
}
|
|
5654
|
-
}, [selectedMonthDate
|
|
5657
|
+
}, [selectedMonthDate]);
|
|
5655
5658
|
React.useEffect(() => {
|
|
5656
5659
|
if (typeof minYear === "number" && menuYear < minYear) {
|
|
5657
5660
|
setMenuYear(minYear);
|
|
@@ -7375,6 +7378,13 @@ var ConditionDropdownInput = ({ row, control, fieldSchema, onClear }) => {
|
|
|
7375
7378
|
showClear: hasValue,
|
|
7376
7379
|
showSearch: true,
|
|
7377
7380
|
virtual: false,
|
|
7381
|
+
labelRender: (option) => {
|
|
7382
|
+
const opt = option;
|
|
7383
|
+
return /* @__PURE__ */ jsxs("span", { className: "flex items-center", children: [
|
|
7384
|
+
opt.decorator,
|
|
7385
|
+
/* @__PURE__ */ jsx("span", { className: cn(opt.labelStyle), children: opt.label })
|
|
7386
|
+
] });
|
|
7387
|
+
},
|
|
7378
7388
|
onSelect: (val) => field.onChange(val),
|
|
7379
7389
|
onClear: handleClear
|
|
7380
7390
|
}
|
|
@@ -17125,60 +17135,11 @@ var Input2 = React.forwardRef(
|
|
|
17125
17135
|
}
|
|
17126
17136
|
);
|
|
17127
17137
|
Input2.displayName = "Input";
|
|
17128
|
-
function useFillDecimalOnBlur({
|
|
17129
|
-
enabled,
|
|
17130
|
-
decimalScale,
|
|
17131
|
-
value,
|
|
17132
|
-
defaultValue
|
|
17133
|
-
}) {
|
|
17134
|
-
const blurScale = enabled ? decimalScale ?? 2 : void 0;
|
|
17135
|
-
const isUserEditingRef = React.useRef(false);
|
|
17136
|
-
const [formattedValue, setFormattedValue] = React.useState(() => {
|
|
17137
|
-
if (!enabled) return void 0;
|
|
17138
|
-
const scale = decimalScale ?? 2;
|
|
17139
|
-
const initial = parseToNumber(value) ?? parseToNumber(defaultValue);
|
|
17140
|
-
if (initial !== void 0) return truncateToFixed(initial, scale);
|
|
17141
|
-
return void 0;
|
|
17142
|
-
});
|
|
17143
|
-
React.useEffect(() => {
|
|
17144
|
-
if (!enabled) return;
|
|
17145
|
-
const parsed = parseToNumber(value);
|
|
17146
|
-
if (parsed !== void 0) {
|
|
17147
|
-
if (blurScale !== void 0 && !isUserEditingRef.current) {
|
|
17148
|
-
setFormattedValue(truncateToFixed(parsed, blurScale));
|
|
17149
|
-
}
|
|
17150
|
-
} else if (value === null || value === "") {
|
|
17151
|
-
setFormattedValue(void 0);
|
|
17152
|
-
}
|
|
17153
|
-
}, [value, enabled, blurScale]);
|
|
17154
|
-
const onEdit = React.useCallback(
|
|
17155
|
-
(values, sourceInfo) => {
|
|
17156
|
-
if (!enabled || sourceInfo.source !== "event") return;
|
|
17157
|
-
isUserEditingRef.current = true;
|
|
17158
|
-
setFormattedValue(values.value || void 0);
|
|
17159
|
-
},
|
|
17160
|
-
[enabled]
|
|
17161
|
-
);
|
|
17162
|
-
const onBlur = React.useCallback(
|
|
17163
|
-
(truncatedStr) => {
|
|
17164
|
-
isUserEditingRef.current = false;
|
|
17165
|
-
if (!enabled || blurScale === void 0) return;
|
|
17166
|
-
setFormattedValue(truncatedStr);
|
|
17167
|
-
},
|
|
17168
|
-
[enabled, blurScale]
|
|
17169
|
-
);
|
|
17170
|
-
const resetEditing = React.useCallback(() => {
|
|
17171
|
-
isUserEditingRef.current = false;
|
|
17172
|
-
}, []);
|
|
17173
|
-
return { formattedValue, blurScale, onEdit, onBlur, resetEditing, setFormattedValue };
|
|
17174
|
-
}
|
|
17175
17138
|
function useStepper({ value, step, min, max, disabled, onStep }) {
|
|
17176
|
-
const [changed, setChanged] = React.useState(false);
|
|
17177
17139
|
const changeValue = React.useCallback(
|
|
17178
17140
|
(delta) => {
|
|
17179
17141
|
const current = value ?? 0;
|
|
17180
17142
|
const clamped = clamp(current + delta, min, max);
|
|
17181
|
-
setChanged(true);
|
|
17182
17143
|
onStep(clamped);
|
|
17183
17144
|
},
|
|
17184
17145
|
[value, max, min, onStep]
|
|
@@ -17187,7 +17148,7 @@ function useStepper({ value, step, min, max, disabled, onStep }) {
|
|
|
17187
17148
|
const decrement = React.useCallback(() => changeValue(-step), [changeValue, step]);
|
|
17188
17149
|
const isIncrementDisabled = disabled || max !== void 0 && (value ?? 0) >= max;
|
|
17189
17150
|
const isDecrementDisabled = disabled || min !== void 0 && (value ?? 0) <= min;
|
|
17190
|
-
return {
|
|
17151
|
+
return { increment, decrement, isIncrementDisabled, isDecrementDisabled };
|
|
17191
17152
|
}
|
|
17192
17153
|
var InputNumber = ({
|
|
17193
17154
|
customInputProps,
|
|
@@ -17211,26 +17172,37 @@ var InputNumber = ({
|
|
|
17211
17172
|
...props
|
|
17212
17173
|
}) => {
|
|
17213
17174
|
const blurFormatEnabled = fillDecimalOnBlur || truncateDecimalOnBlur;
|
|
17214
|
-
const
|
|
17175
|
+
const blurScale = blurFormatEnabled ? decimalScaleProp ?? 2 : void 0;
|
|
17176
|
+
const [displayOverride, setDisplayOverride] = React.useState(() => {
|
|
17177
|
+
if (!blurFormatEnabled) return void 0;
|
|
17178
|
+
const scale = decimalScaleProp ?? 2;
|
|
17179
|
+
const initial = parseToNumber(value) ?? parseToNumber(defaultValue);
|
|
17180
|
+
if (initial !== void 0) return truncateToFixed(initial, scale);
|
|
17181
|
+
return void 0;
|
|
17182
|
+
});
|
|
17183
|
+
const [numericValue, setNumericValue] = React.useState(
|
|
17215
17184
|
() => parseToNumber(value) ?? parseToNumber(defaultValue)
|
|
17216
17185
|
);
|
|
17217
|
-
const
|
|
17218
|
-
const
|
|
17219
|
-
const
|
|
17220
|
-
|
|
17221
|
-
|
|
17222
|
-
if (
|
|
17223
|
-
|
|
17224
|
-
|
|
17225
|
-
|
|
17226
|
-
|
|
17227
|
-
|
|
17228
|
-
|
|
17229
|
-
|
|
17230
|
-
|
|
17231
|
-
|
|
17232
|
-
|
|
17233
|
-
|
|
17186
|
+
const isEditingRef = React.useRef(false);
|
|
17187
|
+
const rawRef = React.useRef("");
|
|
17188
|
+
const prevValueRef = React.useRef(value);
|
|
17189
|
+
if (value !== prevValueRef.current) {
|
|
17190
|
+
prevValueRef.current = value;
|
|
17191
|
+
if (value === "" || value === null) {
|
|
17192
|
+
if (displayOverride !== void 0) setDisplayOverride(void 0);
|
|
17193
|
+
if (numericValue !== void 0) setNumericValue(void 0);
|
|
17194
|
+
isEditingRef.current = false;
|
|
17195
|
+
} else if (!isEditingRef.current) {
|
|
17196
|
+
const num = parseToNumber(value);
|
|
17197
|
+
if (num !== numericValue) setNumericValue(num);
|
|
17198
|
+
if (blurFormatEnabled && num !== void 0) {
|
|
17199
|
+
const formatted = truncateToFixed(num, blurScale);
|
|
17200
|
+
if (formatted !== displayOverride) setDisplayOverride(formatted);
|
|
17201
|
+
} else {
|
|
17202
|
+
if (displayOverride !== void 0) setDisplayOverride(void 0);
|
|
17203
|
+
}
|
|
17204
|
+
}
|
|
17205
|
+
}
|
|
17234
17206
|
const isAllowed = React.useMemo(() => {
|
|
17235
17207
|
if (maxIntegerDigits === void 0 && !isAllowedProp) return void 0;
|
|
17236
17208
|
return (values) => {
|
|
@@ -17243,80 +17215,73 @@ var InputNumber = ({
|
|
|
17243
17215
|
return isAllowedProp ? isAllowedProp(values) : true;
|
|
17244
17216
|
};
|
|
17245
17217
|
}, [maxIntegerDigits, isAllowedProp]);
|
|
17246
|
-
const notifyChange = React.useCallback(
|
|
17247
|
-
(newValue, event) => {
|
|
17248
|
-
internalValueRef.current = newValue;
|
|
17249
|
-
setInternalValue(newValue);
|
|
17250
|
-
onStepChange?.(newValue);
|
|
17251
|
-
onValueChange?.(
|
|
17252
|
-
{ floatValue: newValue, formattedValue: String(newValue), value: String(newValue) },
|
|
17253
|
-
createSourceInfo(event)
|
|
17254
|
-
);
|
|
17255
|
-
},
|
|
17256
|
-
[onStepChange, onValueChange]
|
|
17257
|
-
);
|
|
17258
17218
|
const stepper = useStepper({
|
|
17259
|
-
value:
|
|
17219
|
+
value: numericValue,
|
|
17260
17220
|
step,
|
|
17261
17221
|
min,
|
|
17262
17222
|
max,
|
|
17263
17223
|
disabled,
|
|
17264
17224
|
onStep: React.useCallback(
|
|
17265
17225
|
(clamped) => {
|
|
17266
|
-
|
|
17267
|
-
|
|
17268
|
-
|
|
17269
|
-
|
|
17270
|
-
|
|
17226
|
+
setNumericValue(clamped);
|
|
17227
|
+
const formatted = blurScale !== void 0 ? truncateToFixed(clamped, blurScale) : String(clamped);
|
|
17228
|
+
setDisplayOverride(formatted);
|
|
17229
|
+
rawRef.current = String(clamped);
|
|
17230
|
+
onStepChange?.(clamped);
|
|
17231
|
+
onValueChange?.(
|
|
17232
|
+
{ floatValue: clamped, formattedValue: formatted, value: String(clamped) },
|
|
17233
|
+
createSourceInfo()
|
|
17234
|
+
);
|
|
17271
17235
|
},
|
|
17272
|
-
[
|
|
17236
|
+
[blurScale, onStepChange, onValueChange]
|
|
17273
17237
|
)
|
|
17274
17238
|
});
|
|
17275
17239
|
const handleValueChange = React.useCallback(
|
|
17276
17240
|
(values, sourceInfo) => {
|
|
17277
|
-
internalValueRef.current = values.floatValue;
|
|
17278
|
-
rawValueRef.current = values.value;
|
|
17279
|
-
setInternalValue(values.floatValue);
|
|
17280
17241
|
if (sourceInfo.source === "event") {
|
|
17281
|
-
|
|
17242
|
+
isEditingRef.current = true;
|
|
17243
|
+
setDisplayOverride(values.value);
|
|
17282
17244
|
}
|
|
17245
|
+
setNumericValue(values.floatValue);
|
|
17246
|
+
rawRef.current = values.value;
|
|
17283
17247
|
onValueChange?.(values, sourceInfo);
|
|
17284
17248
|
if (values.floatValue !== void 0) onStepChange?.(values.floatValue);
|
|
17285
|
-
autoFormat.onEdit(values, sourceInfo);
|
|
17286
17249
|
},
|
|
17287
|
-
[onValueChange, onStepChange
|
|
17250
|
+
[onValueChange, onStepChange]
|
|
17288
17251
|
);
|
|
17289
17252
|
const handleBlur = React.useCallback(
|
|
17290
17253
|
(event) => {
|
|
17254
|
+
isEditingRef.current = false;
|
|
17291
17255
|
onBlur?.(event);
|
|
17292
|
-
const
|
|
17293
|
-
if (
|
|
17294
|
-
|
|
17256
|
+
const currentNumeric = numericValue;
|
|
17257
|
+
if (currentNumeric === void 0) {
|
|
17258
|
+
setDisplayOverride("");
|
|
17295
17259
|
return;
|
|
17296
17260
|
}
|
|
17297
|
-
const clamped = clamp(
|
|
17298
|
-
const wasClamped = clamped !==
|
|
17261
|
+
const clamped = clamp(currentNumeric, min, max);
|
|
17262
|
+
const wasClamped = clamped !== currentNumeric;
|
|
17299
17263
|
if (wasClamped) {
|
|
17300
|
-
|
|
17301
|
-
|
|
17302
|
-
rawValueRef.current = String(clamped);
|
|
17303
|
-
setInternalValue(clamped);
|
|
17264
|
+
setNumericValue(clamped);
|
|
17265
|
+
rawRef.current = String(clamped);
|
|
17304
17266
|
onValueChange?.(
|
|
17305
17267
|
{ floatValue: clamped, formattedValue: String(clamped), value: String(clamped) },
|
|
17306
17268
|
createSourceInfo()
|
|
17307
17269
|
);
|
|
17308
17270
|
onStepChange?.(clamped);
|
|
17309
17271
|
}
|
|
17310
|
-
if (blurFormatEnabled &&
|
|
17311
|
-
const rawStr = wasClamped ? String(clamped) :
|
|
17312
|
-
|
|
17272
|
+
if (blurFormatEnabled && blurScale !== void 0) {
|
|
17273
|
+
const rawStr = wasClamped ? String(clamped) : rawRef.current || String(clamped);
|
|
17274
|
+
setDisplayOverride(truncateStringToFixed(rawStr, blurScale));
|
|
17275
|
+
} else if (wasClamped) {
|
|
17276
|
+
setDisplayOverride(String(clamped));
|
|
17313
17277
|
} else {
|
|
17314
|
-
|
|
17278
|
+
setDisplayOverride(void 0);
|
|
17315
17279
|
}
|
|
17316
17280
|
},
|
|
17317
|
-
[onBlur, blurFormatEnabled,
|
|
17281
|
+
[onBlur, blurFormatEnabled, blurScale, numericValue, min, max, onValueChange, onStepChange]
|
|
17318
17282
|
);
|
|
17319
|
-
const
|
|
17283
|
+
const isValueExplicitlyEmpty = value === "" || value === null;
|
|
17284
|
+
const effectiveValue = isValueExplicitlyEmpty ? "" : displayOverride !== void 0 ? displayOverride : value;
|
|
17320
17285
|
const buttonClass = cn(
|
|
17321
17286
|
"flex items-center justify-center h-3 w-5 transition-colors outline-none",
|
|
17322
17287
|
"text-neutral-400 hover:text-neutral-600 active:text-neutral-900",
|
|
@@ -17332,7 +17297,7 @@ var InputNumber = ({
|
|
|
17332
17297
|
onBlur: handleBlur,
|
|
17333
17298
|
...isAllowed && { isAllowed },
|
|
17334
17299
|
...truncateDecimalOnBlur ? {} : fillDecimalOnBlur ? { decimalScale: decimalScaleProp } : { decimalScale: decimalScaleProp, fixedDecimalScale: fixedDecimalScaleProp },
|
|
17335
|
-
...
|
|
17300
|
+
...displayOverride !== void 0 && { valueIsNumericString: true },
|
|
17336
17301
|
...props,
|
|
17337
17302
|
disabled,
|
|
17338
17303
|
invalid,
|