sit-onyx 1.2.0-dev-20251016092305 → 1.2.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.
@@ -2,9 +2,11 @@ import { Nullable } from '../../types/index.js';
2
2
  import { OnyxInputProps } from '../OnyxInput/types.js';
3
3
  export type OnyxDatePickerProps = Omit<OnyxInputProps, "type" | "modelValue" | "autocapitalize" | "maxlength" | "minlength" | "pattern" | "withCounter" | "placeholder" | "autocomplete"> & {
4
4
  /**
5
- * Current date value. Supports all data types that are parsable by `new Date()`.
5
+ * A date string compliant with [ISO8601](https://en.wikipedia.org/wiki/ISO_8601).
6
+ * @example "date.toISOString()"
7
+ * @example "2011-10-31"
6
8
  */
7
- modelValue?: Nullable<DateValue>;
9
+ modelValue?: Nullable<string>;
8
10
  /**
9
11
  * Whether the user should be able to select only date or date + time.
10
12
  */
@@ -5274,8 +5274,22 @@ const useRequired = (props, requiredMarker) => ({
5274
5274
  "onyx-optional-marker": !props.required
5275
5275
  }))
5276
5276
  });
5277
- const isValidDate = (date) => {
5278
- return date instanceof Date && !isNaN(date);
5277
+ const isValidDate = (date) => date instanceof Date && !isNaN(date.getTime());
5278
+ const dateToISOString = (date, type) => {
5279
+ if (!isValidDate(date)) {
5280
+ return void 0;
5281
+ }
5282
+ const dateString = date.toISOString();
5283
+ if (type === "datetime-utc") {
5284
+ return dateString;
5285
+ }
5286
+ const dateOnlyString = dateString.split("T")[0];
5287
+ if (type === "date") {
5288
+ return dateOnlyString;
5289
+ }
5290
+ const hours = date.getHours().toString().padStart(2, "0");
5291
+ const minutes = date.getMinutes().toString().padStart(2, "0");
5292
+ return `${dateOnlyString}T${hours}:${minutes}`;
5279
5293
  };
5280
5294
  const getValidityStateProperties = () => Object.entries(Object.getOwnPropertyDescriptors(ValidityState.prototype)).filter(([_, value]) => value.enumerable).map(([key]) => key);
5281
5295
  const transformValidityStateToObject = (validityState) => {
@@ -9104,12 +9118,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
9104
9118
  const getNormalizedDate = computed(() => {
9105
9119
  return (value2) => {
9106
9120
  const date = value2 != void 0 && value2 != null ? new Date(value2) : void 0;
9107
- if (!isValidDate(date)) return;
9108
- const dateString = date.toISOString().split("T")[0];
9109
- if (props.type === "date") return dateString;
9110
- const hours = date.getHours().toString().padStart(2, "0");
9111
- const minutes = date.getMinutes().toString().padStart(2, "0");
9112
- return `${dateString}T${hours}:${minutes}`;
9121
+ return dateToISOString(date, props.type);
9113
9122
  };
9114
9123
  });
9115
9124
  const modelValue = useVModel({
@@ -9121,12 +9130,11 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
9121
9130
  get: () => getNormalizedDate.value(modelValue.value),
9122
9131
  set: (value2) => {
9123
9132
  const newDate = new Date(value2 ?? "");
9124
- modelValue.value = isValidDate(newDate) ? newDate.toISOString() : void 0;
9133
+ modelValue.value = dateToISOString(newDate, props.type === "date" ? "date" : "datetime-utc");
9125
9134
  }
9126
9135
  });
9127
- const input2 = useTemplateRef("inputRef");
9128
- useAutofocus(input2, props);
9129
- const __returned__ = { props, emit, rootAttrs, restAttrs, vCustomValidity, errorMessages, successMessages, messages, densityClass, disabled, showError, skeleton, errorClass, formElementProps, getNormalizedDate, modelValue, value, input: input2, OnyxFormElement, OnyxLoadingIndicator, OnyxSkeleton };
9136
+ useAutofocus(useTemplateRef("inputRef"), props);
9137
+ const __returned__ = { props, emit, rootAttrs, restAttrs, vCustomValidity, errorMessages, successMessages, messages, densityClass, disabled, showError, skeleton, errorClass, formElementProps, getNormalizedDate, modelValue, value, OnyxFormElement, OnyxLoadingIndicator, OnyxSkeleton };
9130
9138
  Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
9131
9139
  return __returned__;
9132
9140
  }