@rjsf/utils 5.15.1 → 5.16.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 CHANGED
@@ -77,6 +77,7 @@ __export(src_exports, {
77
77
  examplesId: () => examplesId,
78
78
  findSchemaDefinition: () => findSchemaDefinition,
79
79
  getClosestMatchingOption: () => getClosestMatchingOption,
80
+ getDateElementProps: () => getDateElementProps,
80
81
  getDefaultFormState: () => getDefaultFormState,
81
82
  getDiscriminatorFieldFromSchema: () => getDiscriminatorFieldFromSchema,
82
83
  getDisplayLabel: () => getDisplayLabel,
@@ -2048,6 +2049,34 @@ var ErrorSchemaBuilder = class {
2048
2049
  }
2049
2050
  };
2050
2051
 
2052
+ // src/getDateElementProps.ts
2053
+ function getDateElementProps(date, time, yearRange = [1900, (/* @__PURE__ */ new Date()).getFullYear() + 2], format = "YMD") {
2054
+ const { day, month, year, hour, minute, second } = date;
2055
+ const dayObj = { type: "day", range: [1, 31], value: day };
2056
+ const monthObj = { type: "month", range: [1, 12], value: month };
2057
+ const yearObj = { type: "year", range: yearRange, value: year };
2058
+ const dateElementProp = [];
2059
+ switch (format) {
2060
+ case "MDY":
2061
+ dateElementProp.push(monthObj, dayObj, yearObj);
2062
+ break;
2063
+ case "DMY":
2064
+ dateElementProp.push(dayObj, monthObj, yearObj);
2065
+ break;
2066
+ case "YMD":
2067
+ default:
2068
+ dateElementProp.push(yearObj, monthObj, dayObj);
2069
+ }
2070
+ if (time) {
2071
+ dateElementProp.push(
2072
+ { type: "hour", range: [0, 23], value: hour },
2073
+ { type: "minute", range: [0, 59], value: minute },
2074
+ { type: "second", range: [0, 59], value: second }
2075
+ );
2076
+ }
2077
+ return dateElementProp;
2078
+ }
2079
+
2051
2080
  // src/rangeSpec.ts
2052
2081
  function rangeSpec(schema) {
2053
2082
  const spec = {};