@trackunit/react-form-components 0.1.77 → 0.1.78

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/index.cjs.js CHANGED
@@ -7,7 +7,7 @@ var usehooksTs = require('usehooks-ts');
7
7
  var cssClassVarianceUtilities = require('@trackunit/css-class-variance-utilities');
8
8
  var React = require('react');
9
9
  var sharedUtils = require('@trackunit/shared-utils');
10
- var dateFns = require('date-fns');
10
+ var polyfill = require('@js-temporal/polyfill');
11
11
  var parsePhoneNumberFromString = require('libphonenumber-js');
12
12
  var reactHookForm = require('react-hook-form');
13
13
  var ReactSelect = require('react-select');
@@ -737,7 +737,13 @@ ColorField.displayName = "ColorField";
737
737
  * NOTE: If shown with a label, please use the `DateField` component instead.
738
738
  */
739
739
  const DateInput = React.forwardRef(({ min, max, defaultValue, value, ...rest }, ref) => {
740
- const formatDateToInputString = (date) => date instanceof Date ? dateFns.format(date, "yyyy-MM-dd") : date;
740
+ const formatDateToInputString = (date) => date instanceof Date
741
+ ? polyfill.Temporal.PlainDateTime.from({
742
+ year: date.getFullYear(),
743
+ month: date.getMonth() + 1,
744
+ day: date.getDate(),
745
+ }).toPlainDate().toString()
746
+ : date;
741
747
  // Chrome and Firefox need their default icon to have datepicker functionality.
742
748
  const showIcon = !/Chrome/.test(navigator.userAgent) && !/Firefox/.test(navigator.userAgent);
743
749
  return (jsxRuntime.jsx(BaseInput, { defaultValue: formatDateToInputString(defaultValue), max: formatDateToInputString(max), min: formatDateToInputString(min), ref: ref, suffix: showIcon ? jsxRuntime.jsx(reactComponents.Icon, { dataTestId: "calendar", name: "Calendar", size: "medium", type: "solid" }) : null, type: "date", value: formatDateToInputString(value), ...rest }));
package/index.esm.js CHANGED
@@ -6,7 +6,7 @@ import { cvaMerge } from '@trackunit/css-class-variance-utilities';
6
6
  import * as React from 'react';
7
7
  import React__default, { isValidElement, forwardRef, useMemo, useState, useCallback, useRef, cloneElement, useEffect, useImperativeHandle } from 'react';
8
8
  import { uuidv4, nonNullable } from '@trackunit/shared-utils';
9
- import { format } from 'date-fns';
9
+ import { Temporal } from '@js-temporal/polyfill';
10
10
  import parsePhoneNumberFromString, { isSupportedCountry, getCountries, getCountryCallingCode, AsYouType, parseIncompletePhoneNumber, isValidPhoneNumber } from 'libphonenumber-js';
11
11
  import { Controller } from 'react-hook-form';
12
12
  import ReactSelect, { components } from 'react-select';
@@ -718,7 +718,13 @@ ColorField.displayName = "ColorField";
718
718
  * NOTE: If shown with a label, please use the `DateField` component instead.
719
719
  */
720
720
  const DateInput = forwardRef(({ min, max, defaultValue, value, ...rest }, ref) => {
721
- const formatDateToInputString = (date) => date instanceof Date ? format(date, "yyyy-MM-dd") : date;
721
+ const formatDateToInputString = (date) => date instanceof Date
722
+ ? Temporal.PlainDateTime.from({
723
+ year: date.getFullYear(),
724
+ month: date.getMonth() + 1,
725
+ day: date.getDate(),
726
+ }).toPlainDate().toString()
727
+ : date;
722
728
  // Chrome and Firefox need their default icon to have datepicker functionality.
723
729
  const showIcon = !/Chrome/.test(navigator.userAgent) && !/Firefox/.test(navigator.userAgent);
724
730
  return (jsx(BaseInput, { defaultValue: formatDateToInputString(defaultValue), max: formatDateToInputString(max), min: formatDateToInputString(min), ref: ref, suffix: showIcon ? jsx(Icon, { dataTestId: "calendar", name: "Calendar", size: "medium", type: "solid" }) : null, type: "date", value: formatDateToInputString(value), ...rest }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-form-components",
3
- "version": "0.1.77",
3
+ "version": "0.1.78",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -11,8 +11,8 @@
11
11
  "@trackunit/ui-icons": "*",
12
12
  "react": "18.3.1",
13
13
  "usehooks-ts": "^3.1.0",
14
- "date-fns": "^2.30.0",
15
14
  "react-select": "^5.8.0",
15
+ "@js-temporal/polyfill": "^0.4.4",
16
16
  "libphonenumber-js": "1.10.36",
17
17
  "@trackunit/shared-utils": "*",
18
18
  "@testing-library/react": "15.0.6",