@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/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 handleChange = useCallback16((value) => onChange(value ? `${value}:00` : void 0), [onChange]);
4311
- return /* @__PURE__ */ jsx58(BaseInputTemplate2, { type: "time", ...props, onChange: handleChange });
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