@rjsf/utils 5.15.0 → 5.16.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.js +29 -0
- package/dist/index.js.map +3 -3
- package/dist/utils.esm.js +29 -0
- package/dist/utils.esm.js.map +3 -3
- package/dist/utils.umd.js +29 -0
- package/lib/getDateElementProps.d.ts +19 -0
- package/lib/getDateElementProps.js +31 -0
- package/lib/getDateElementProps.js.map +1 -0
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +19 -19
- package/src/getDateElementProps.ts +56 -0
- package/src/index.ts +3 -0
package/dist/utils.esm.js
CHANGED
|
@@ -1914,6 +1914,34 @@ var ErrorSchemaBuilder = class {
|
|
|
1914
1914
|
}
|
|
1915
1915
|
};
|
|
1916
1916
|
|
|
1917
|
+
// src/getDateElementProps.ts
|
|
1918
|
+
function getDateElementProps(date, time, yearRange = [1900, (/* @__PURE__ */ new Date()).getFullYear() + 2], format = "YMD") {
|
|
1919
|
+
const { day, month, year, hour, minute, second } = date;
|
|
1920
|
+
const dayObj = { type: "day", range: [1, 31], value: day };
|
|
1921
|
+
const monthObj = { type: "month", range: [1, 12], value: month };
|
|
1922
|
+
const yearObj = { type: "year", range: yearRange, value: year };
|
|
1923
|
+
const dateElementProp = [];
|
|
1924
|
+
switch (format) {
|
|
1925
|
+
case "MDY":
|
|
1926
|
+
dateElementProp.push(monthObj, dayObj, yearObj);
|
|
1927
|
+
break;
|
|
1928
|
+
case "DMY":
|
|
1929
|
+
dateElementProp.push(dayObj, monthObj, yearObj);
|
|
1930
|
+
break;
|
|
1931
|
+
case "YMD":
|
|
1932
|
+
default:
|
|
1933
|
+
dateElementProp.push(yearObj, monthObj, dayObj);
|
|
1934
|
+
}
|
|
1935
|
+
if (time) {
|
|
1936
|
+
dateElementProp.push(
|
|
1937
|
+
{ type: "hour", range: [0, 23], value: hour },
|
|
1938
|
+
{ type: "minute", range: [0, 59], value: minute },
|
|
1939
|
+
{ type: "second", range: [0, 59], value: second }
|
|
1940
|
+
);
|
|
1941
|
+
}
|
|
1942
|
+
return dateElementProp;
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1917
1945
|
// src/rangeSpec.ts
|
|
1918
1946
|
function rangeSpec(schema) {
|
|
1919
1947
|
const spec = {};
|
|
@@ -2613,6 +2641,7 @@ export {
|
|
|
2613
2641
|
examplesId,
|
|
2614
2642
|
findSchemaDefinition,
|
|
2615
2643
|
getClosestMatchingOption,
|
|
2644
|
+
getDateElementProps,
|
|
2616
2645
|
getDefaultFormState,
|
|
2617
2646
|
getDiscriminatorFieldFromSchema,
|
|
2618
2647
|
getDisplayLabel,
|