@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/core.umd.js
CHANGED
|
@@ -3838,10 +3838,23 @@
|
|
|
3838
3838
|
return /* @__PURE__ */ jsxRuntime.jsx(BaseInputTemplate2, { ...props });
|
|
3839
3839
|
}
|
|
3840
3840
|
function TimeWidget(props) {
|
|
3841
|
-
const { onChange, options, registry } = props;
|
|
3841
|
+
const { onChange, options, registry, schema, value } = props;
|
|
3842
3842
|
const BaseInputTemplate2 = utils.getTemplate("BaseInputTemplate", registry, options);
|
|
3843
|
-
const
|
|
3844
|
-
|
|
3843
|
+
const hasSecondPrecision = typeof schema.multipleOf === "number" && Number.isFinite(schema.multipleOf) && schema.multipleOf < 60;
|
|
3844
|
+
const handleChange = react.useCallback(
|
|
3845
|
+
(newValue) => {
|
|
3846
|
+
if (!newValue) {
|
|
3847
|
+
onChange(void 0);
|
|
3848
|
+
} else if (hasSecondPrecision) {
|
|
3849
|
+
onChange(newValue);
|
|
3850
|
+
} else {
|
|
3851
|
+
onChange(`${newValue}:00`);
|
|
3852
|
+
}
|
|
3853
|
+
},
|
|
3854
|
+
[hasSecondPrecision, onChange]
|
|
3855
|
+
);
|
|
3856
|
+
const displayValue = typeof value === "string" && !hasSecondPrecision && /^\d{2}:\d{2}:00$/.test(value) ? value.slice(0, -3) : value;
|
|
3857
|
+
return /* @__PURE__ */ jsxRuntime.jsx(BaseInputTemplate2, { type: "time", ...props, value: displayValue, onChange: handleChange });
|
|
3845
3858
|
}
|
|
3846
3859
|
function UpDownWidget(props) {
|
|
3847
3860
|
const { options, registry } = props;
|
package/dist/index.cjs
CHANGED
|
@@ -4183,10 +4183,23 @@ var import_react27 = require("react");
|
|
|
4183
4183
|
var import_utils48 = require("@rjsf/utils");
|
|
4184
4184
|
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
4185
4185
|
function TimeWidget(props) {
|
|
4186
|
-
const { onChange, options, registry } = props;
|
|
4186
|
+
const { onChange, options, registry, schema, value } = props;
|
|
4187
4187
|
const BaseInputTemplate2 = (0, import_utils48.getTemplate)("BaseInputTemplate", registry, options);
|
|
4188
|
-
const
|
|
4189
|
-
|
|
4188
|
+
const hasSecondPrecision = typeof schema.multipleOf === "number" && Number.isFinite(schema.multipleOf) && schema.multipleOf < 60;
|
|
4189
|
+
const handleChange = (0, import_react27.useCallback)(
|
|
4190
|
+
(newValue) => {
|
|
4191
|
+
if (!newValue) {
|
|
4192
|
+
onChange(void 0);
|
|
4193
|
+
} else if (hasSecondPrecision) {
|
|
4194
|
+
onChange(newValue);
|
|
4195
|
+
} else {
|
|
4196
|
+
onChange(`${newValue}:00`);
|
|
4197
|
+
}
|
|
4198
|
+
},
|
|
4199
|
+
[hasSecondPrecision, onChange]
|
|
4200
|
+
);
|
|
4201
|
+
const displayValue = typeof value === "string" && !hasSecondPrecision && /^\d{2}:\d{2}:00$/.test(value) ? value.slice(0, -3) : value;
|
|
4202
|
+
return /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(BaseInputTemplate2, { type: "time", ...props, value: displayValue, onChange: handleChange });
|
|
4190
4203
|
}
|
|
4191
4204
|
|
|
4192
4205
|
// src/components/widgets/UpDownWidget.tsx
|