@rjsf/core 6.7.1 → 6.8.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/core.umd.js +16 -3
- package/dist/index.cjs +16 -3
- package/dist/index.cjs.map +2 -2
- package/dist/index.esm.js +16 -3
- package/dist/index.esm.js.map +2 -2
- package/lib/components/widgets/TimeWidget.d.ts.map +1 -1
- package/lib/components/widgets/TimeWidget.js +15 -3
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/components/widgets/TimeWidget.tsx +18 -3
package/dist/index.esm.js
CHANGED
|
@@ -4305,10 +4305,23 @@ import { useCallback as useCallback16 } from "react";
|
|
|
4305
4305
|
import { getTemplate as getTemplate26 } from "@rjsf/utils";
|
|
4306
4306
|
import { jsx as jsx58 } from "react/jsx-runtime";
|
|
4307
4307
|
function TimeWidget(props) {
|
|
4308
|
-
const { onChange, options, registry } = props;
|
|
4308
|
+
const { onChange, options, registry, schema, value } = props;
|
|
4309
4309
|
const BaseInputTemplate2 = getTemplate26("BaseInputTemplate", registry, options);
|
|
4310
|
-
const
|
|
4311
|
-
|
|
4310
|
+
const hasSecondPrecision = typeof schema.multipleOf === "number" && Number.isFinite(schema.multipleOf) && schema.multipleOf < 60;
|
|
4311
|
+
const handleChange = useCallback16(
|
|
4312
|
+
(newValue) => {
|
|
4313
|
+
if (!newValue) {
|
|
4314
|
+
onChange(void 0);
|
|
4315
|
+
} else if (hasSecondPrecision) {
|
|
4316
|
+
onChange(newValue);
|
|
4317
|
+
} else {
|
|
4318
|
+
onChange(`${newValue}:00`);
|
|
4319
|
+
}
|
|
4320
|
+
},
|
|
4321
|
+
[hasSecondPrecision, onChange]
|
|
4322
|
+
);
|
|
4323
|
+
const displayValue = typeof value === "string" && !hasSecondPrecision && /^\d{2}:\d{2}:00$/.test(value) ? value.slice(0, -3) : value;
|
|
4324
|
+
return /* @__PURE__ */ jsx58(BaseInputTemplate2, { type: "time", ...props, value: displayValue, onChange: handleChange });
|
|
4312
4325
|
}
|
|
4313
4326
|
|
|
4314
4327
|
// src/components/widgets/UpDownWidget.tsx
|