@atlaskit/datetime-picker 18.2.4 → 18.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/datetime-picker
2
2
 
3
+ ## 18.3.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 18.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [`fa627e0fd7b58`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/fa627e0fd7b58) -
14
+ This is behind a flag `platform-dst-dp-parse-date-format`.
15
+
16
+ Parse typed dates with `dateFormat` via `date-fns` when set, so displayed labels re-parse without
17
+ a custom `parseInputValue`. This will not affect existing instances that already have a
18
+ `parseInputValue` and will honor provided `dateFormat` props for all entry methods, improving user
19
+ experience.
20
+
3
21
  ## 18.2.4
4
22
 
5
23
  ### Patch Changes
@@ -44,7 +44,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
44
44
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
45
45
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
46
46
  var packageName = "@atlaskit/datetime-picker";
47
- var packageVersion = "18.2.3";
47
+ var packageVersion = "18.3.0";
48
48
  var styles = {
49
49
  pickerContainerStyle: "_kqswh2mm",
50
50
  dropdownIndicatorStyles: "_1ul91k8s _1tke1k8s _1e0c1txw _4cvr1h6o _1bah1h6o",
@@ -33,7 +33,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
33
33
  // for typing `process`
34
34
  // oxlint-disable-next-line @atlassian/no-restricted-imports
35
35
  var packageName = "@atlaskit/datetime-picker";
36
- var packageVersion = "18.2.3";
36
+ var packageVersion = "18.3.0";
37
37
  var analyticsAttributes = {
38
38
  componentName: 'dateTimePicker',
39
39
  packageName: packageName,
@@ -30,7 +30,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
30
30
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
31
31
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // oxlint-disable-next-line @atlassian/no-restricted-imports
32
32
  var packageName = "@atlaskit/datetime-picker";
33
- var packageVersion = "18.2.3";
33
+ var packageVersion = "18.3.0";
34
34
  var defaultTimeFormat = 'h:mma';
35
35
  var menuStyles = {
36
36
  /* Need to remove default absolute positioning as that causes issues with position fixed */
@@ -4,7 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.parseDate = void 0;
7
+ var _dateFns = require("date-fns");
8
+ var _fg = require("@atlaskit/platform-feature-flags/fg");
7
9
  var _defaultDateFormat = require("./default-date-format");
10
+ var _parseTokens = require("./parse-tokens");
8
11
  /**
9
12
  * Everything in this file is to smooth out the migration of the new date picker
10
13
  * (https://product-fabric.atlassian.net/browse/DSP-20682). When that ticket is
@@ -22,12 +25,17 @@ var _defaultDateFormat = require("./default-date-format");
22
25
  * If component _only_ has injected variables, it is fully internal and was
23
26
  * broken out to be it's own function.
24
27
  */
28
+ // oxlint-disable-next-line @atlassian/no-restricted-imports
25
29
 
26
30
  /**
27
- * There are two props that can change how the date is parsed.
31
+ * There are props that can change how the date is parsed.
28
32
  * The priority of props used is:
29
33
  * 1. `parseInputValue`
30
- * 2. `locale`
34
+ * 2. `dateFormat` (when `platform-dst-dp-parse-date-format` is on)
35
+ * 3. `locale`
36
+ *
37
+ * `dateFormat` only wins when the input actually parses against it, otherwise
38
+ * `locale` parsing is used.
31
39
  */
32
40
  var parseDate = exports.parseDate = function parseDate(date, di) {
33
41
  var parseInputValue = di.parseInputValue,
@@ -36,5 +44,14 @@ var parseDate = exports.parseDate = function parseDate(date, di) {
36
44
  if (parseInputValue) {
37
45
  return parseInputValue(date, dateFormat || _defaultDateFormat.defaultDateFormat);
38
46
  }
47
+ if (dateFormat && (0, _fg.fg)('platform-dst-dp-parse-date-format')) {
48
+ // new Date(0) to make reference date deterministic
49
+ var parsed = (0, _dateFns.parse)(date, (0, _parseTokens.convertTokens)(dateFormat), new Date(0));
50
+ // `dateFormat` is a display format, so typed input does not always match
51
+ // it. Locale parsing stays as the fallback so those entries still work.
52
+ if ((0, _dateFns.isValid)(parsed)) {
53
+ return parsed;
54
+ }
55
+ }
39
56
  return l10n.parseDate(date);
40
57
  };
@@ -31,7 +31,7 @@ import { MenuTopLayer } from '../internal/menu-top-layer';
31
31
  import { parseDate } from '../internal/parse-date';
32
32
  import { makeSingleValue } from '../internal/single-value';
33
33
  const packageName = "@atlaskit/datetime-picker";
34
- const packageVersion = "18.2.3";
34
+ const packageVersion = "18.3.0";
35
35
  const styles = {
36
36
  pickerContainerStyle: "_kqswh2mm",
37
37
  dropdownIndicatorStyles: "_1ul91k8s _1tke1k8s _1e0c1txw _4cvr1h6o _1bah1h6o",
@@ -20,7 +20,7 @@ import { convertTokens } from '../internal/parse-tokens';
20
20
  import DatePicker from './date-picker';
21
21
  import TimePicker from './time-picker';
22
22
  const packageName = "@atlaskit/datetime-picker";
23
- const packageVersion = "18.2.3";
23
+ const packageVersion = "18.3.0";
24
24
  const analyticsAttributes = {
25
25
  componentName: 'dateTimePicker',
26
26
  packageName,
@@ -17,7 +17,7 @@ import { convertTokens } from '../internal/parse-tokens';
17
17
  import { placeholderDatetime } from '../internal/placeholder-date-time';
18
18
  import { makeSingleValue } from '../internal/single-value';
19
19
  const packageName = "@atlaskit/datetime-picker";
20
- const packageVersion = "18.2.3";
20
+ const packageVersion = "18.3.0";
21
21
  const defaultTimeFormat = 'h:mma';
22
22
  const menuStyles = {
23
23
  /* Need to remove default absolute positioning as that causes issues with position fixed */
@@ -15,14 +15,21 @@
15
15
  * If component _only_ has injected variables, it is fully internal and was
16
16
  * broken out to be it's own function.
17
17
  */
18
-
18
+ // oxlint-disable-next-line @atlassian/no-restricted-imports
19
+ import { isValid, parse } from 'date-fns';
20
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
19
21
  import { defaultDateFormat } from './default-date-format';
22
+ import { convertTokens } from './parse-tokens';
20
23
 
21
24
  /**
22
- * There are two props that can change how the date is parsed.
25
+ * There are props that can change how the date is parsed.
23
26
  * The priority of props used is:
24
27
  * 1. `parseInputValue`
25
- * 2. `locale`
28
+ * 2. `dateFormat` (when `platform-dst-dp-parse-date-format` is on)
29
+ * 3. `locale`
30
+ *
31
+ * `dateFormat` only wins when the input actually parses against it, otherwise
32
+ * `locale` parsing is used.
26
33
  */
27
34
  export const parseDate = (date, di) => {
28
35
  const {
@@ -33,5 +40,14 @@ export const parseDate = (date, di) => {
33
40
  if (parseInputValue) {
34
41
  return parseInputValue(date, dateFormat || defaultDateFormat);
35
42
  }
43
+ if (dateFormat && fg('platform-dst-dp-parse-date-format')) {
44
+ // new Date(0) to make reference date deterministic
45
+ const parsed = parse(date, convertTokens(dateFormat), new Date(0));
46
+ // `dateFormat` is a display format, so typed input does not always match
47
+ // it. Locale parsing stays as the fallback so those entries still work.
48
+ if (isValid(parsed)) {
49
+ return parsed;
50
+ }
51
+ }
36
52
  return l10n.parseDate(date);
37
53
  };
@@ -37,7 +37,7 @@ import { MenuTopLayer } from '../internal/menu-top-layer';
37
37
  import { parseDate } from '../internal/parse-date';
38
38
  import { makeSingleValue } from '../internal/single-value';
39
39
  var packageName = "@atlaskit/datetime-picker";
40
- var packageVersion = "18.2.3";
40
+ var packageVersion = "18.3.0";
41
41
  var styles = {
42
42
  pickerContainerStyle: "_kqswh2mm",
43
43
  dropdownIndicatorStyles: "_1ul91k8s _1tke1k8s _1e0c1txw _4cvr1h6o _1bah1h6o",
@@ -27,7 +27,7 @@ import { convertTokens } from '../internal/parse-tokens';
27
27
  import DatePicker from './date-picker';
28
28
  import TimePicker from './time-picker';
29
29
  var packageName = "@atlaskit/datetime-picker";
30
- var packageVersion = "18.2.3";
30
+ var packageVersion = "18.3.0";
31
31
  var analyticsAttributes = {
32
32
  componentName: 'dateTimePicker',
33
33
  packageName: packageName,
@@ -23,7 +23,7 @@ import { convertTokens } from '../internal/parse-tokens';
23
23
  import { placeholderDatetime } from '../internal/placeholder-date-time';
24
24
  import { makeSingleValue } from '../internal/single-value';
25
25
  var packageName = "@atlaskit/datetime-picker";
26
- var packageVersion = "18.2.3";
26
+ var packageVersion = "18.3.0";
27
27
  var defaultTimeFormat = 'h:mma';
28
28
  var menuStyles = {
29
29
  /* Need to remove default absolute positioning as that causes issues with position fixed */
@@ -15,14 +15,21 @@
15
15
  * If component _only_ has injected variables, it is fully internal and was
16
16
  * broken out to be it's own function.
17
17
  */
18
-
18
+ // oxlint-disable-next-line @atlassian/no-restricted-imports
19
+ import { isValid, parse } from 'date-fns';
20
+ import { fg } from '@atlaskit/platform-feature-flags/fg';
19
21
  import { defaultDateFormat } from './default-date-format';
22
+ import { convertTokens } from './parse-tokens';
20
23
 
21
24
  /**
22
- * There are two props that can change how the date is parsed.
25
+ * There are props that can change how the date is parsed.
23
26
  * The priority of props used is:
24
27
  * 1. `parseInputValue`
25
- * 2. `locale`
28
+ * 2. `dateFormat` (when `platform-dst-dp-parse-date-format` is on)
29
+ * 3. `locale`
30
+ *
31
+ * `dateFormat` only wins when the input actually parses against it, otherwise
32
+ * `locale` parsing is used.
26
33
  */
27
34
  export var parseDate = function parseDate(date, di) {
28
35
  var parseInputValue = di.parseInputValue,
@@ -31,5 +38,14 @@ export var parseDate = function parseDate(date, di) {
31
38
  if (parseInputValue) {
32
39
  return parseInputValue(date, dateFormat || defaultDateFormat);
33
40
  }
41
+ if (dateFormat && fg('platform-dst-dp-parse-date-format')) {
42
+ // new Date(0) to make reference date deterministic
43
+ var parsed = parse(date, convertTokens(dateFormat), new Date(0));
44
+ // `dateFormat` is a display format, so typed input does not always match
45
+ // it. Locale parsing stays as the fallback so those entries still work.
46
+ if (isValid(parsed)) {
47
+ return parsed;
48
+ }
49
+ }
34
50
  return l10n.parseDate(date);
35
51
  };
@@ -1,26 +1,13 @@
1
- /**
2
- * Everything in this file is to smooth out the migration of the new date picker
3
- * (https://product-fabric.atlassian.net/browse/DSP-20682). When that ticket is
4
- * complete, all of these functions will ilkely be merged back into the date
5
- * picker. Please do not pre-optimize and put these back into the date picker
6
- * unless you are working on the DTP Refresh and you have a good reason to do
7
- * so, thank you!
8
- *
9
- * All variables within the `di` objects are dependency injections. They should
10
- * be read from within the component at the end of the day. But because we are
11
- * extracting them, we have to inject them in every place manually. When we
12
- * re-introduce them to the components, we can likely remove the `di` variables
13
- * and instead use internal variables.
14
- *
15
- * If component _only_ has injected variables, it is fully internal and was
16
- * broken out to be it's own function.
17
- */
18
1
  import { type LocalizationProvider } from '@atlaskit/locale';
19
2
  /**
20
- * There are two props that can change how the date is parsed.
3
+ * There are props that can change how the date is parsed.
21
4
  * The priority of props used is:
22
5
  * 1. `parseInputValue`
23
- * 2. `locale`
6
+ * 2. `dateFormat` (when `platform-dst-dp-parse-date-format` is on)
7
+ * 3. `locale`
8
+ *
9
+ * `dateFormat` only wins when the input actually parses against it, otherwise
10
+ * `locale` parsing is used.
24
11
  */
25
12
  export declare const parseDate: (date: string, di: {
26
13
  parseInputValue: ((date: string, dateFormat: string) => Date) | undefined;
@@ -184,16 +184,18 @@ export interface DatePickerBaseProps extends WithAnalyticsEventsProps, PickerSel
184
184
  openCalendarLabel?: string;
185
185
  /**
186
186
  * A function for parsing input characters and transforming them into a Date object.
187
- * By default parses the date string based off the locale. Note that this does
188
- * not affect how the resulting value is displayed in the input. Use the
189
- * `dateFormat` or `formatDisplayLabel` prop to handle how the value is
190
- * displayed.
187
+ * Overrides the default parser. By default, when `dateFormat` is set the input is
188
+ * parsed with that format via date-fns; otherwise the date string is parsed based
189
+ * off the locale. Note that this does not affect how the resulting value is
190
+ * displayed in the input. Use the `dateFormat` or `formatDisplayLabel` prop to
191
+ * handle how the value is displayed.
191
192
  */
192
193
  parseInputValue?: (date: string, dateFormat: string) => Date;
193
194
  /**
194
195
  * A function for formatting the date displayed in the input. By default composes together [`date-fns`'s parse method](https://date-fns.org/v1.29.0/docs/parse) and [`date-fns`'s format method](https://date-fns.org/v1.29.0/docs/format) to return a correctly formatted date string.
195
196
  *
196
- * Note that this does not affect how the input is parsed. This must be done using the `parseInputValue` prop.
197
+ * Note that this does not affect how the input is parsed. Use `dateFormat` for
198
+ * default parsing of the display format, or `parseInputValue` for a custom parser.
197
199
  */
198
200
  formatDisplayLabel?: (value: string, dateFormat: string) => string;
199
201
  /**
@@ -233,9 +235,10 @@ export interface DatePickerBaseProps extends WithAnalyticsEventsProps, PickerSel
233
235
  hideIcon?: boolean;
234
236
  /**
235
237
  * Format the date with a string that is accepted by [date-fns's format
236
- * function](https://date-fns.org/v1.29.0/docs/format). **This does not affect
237
- * how the input is parsed.** This must be done using the `parseInputValue`
238
- * prop.
238
+ * function](https://date-fns.org/v1.29.0/docs/format). When set, the default
239
+ * parser also uses this format (via date-fns) so displayed labels re-parse.
240
+ * Without `dateFormat`, parsing falls back to the locale. A custom
241
+ * `parseInputValue` overrides this default.
239
242
  *
240
243
  * Note that though we are using `date-fns` version 2, we use [the tokens from
241
244
  * `date-fns` version 1](https://date-fns.org/v1.30.1/docs/format) under the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/datetime-picker",
3
- "version": "18.2.4",
3
+ "version": "18.3.1",
4
4
  "description": "A date time picker allows the user to select an associated date and time.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -40,14 +40,14 @@
40
40
  "@atlaskit/layering": "^5.0.0",
41
41
  "@atlaskit/locale": "^5.0.0",
42
42
  "@atlaskit/platform-feature-flags": "^2.1.0",
43
- "@atlaskit/popper": "^9.0.0",
43
+ "@atlaskit/popper": "^9.1.0",
44
44
  "@atlaskit/primitives": "^22.2.0",
45
45
  "@atlaskit/react-compiler-gating": "^0.2.0",
46
46
  "@atlaskit/select": "^22.6.0",
47
- "@atlaskit/tokens": "^16.4.0",
48
- "@atlaskit/top-layer": "^3.1.0",
47
+ "@atlaskit/tokens": "^16.7.0",
48
+ "@atlaskit/top-layer": "^4.0.0",
49
49
  "@babel/runtime": "^7.0.0",
50
- "@compiled/react": "^1.0.0",
50
+ "@compiled/react": "^1.0.2",
51
51
  "date-fns": "^2.17.0"
52
52
  },
53
53
  "peerDependencies": {
@@ -57,10 +57,10 @@
57
57
  "@af/accessibility-testing": "workspace:^",
58
58
  "@af/integration-testing": "workspace:^",
59
59
  "@af/visual-regression": "workspace:^",
60
- "@atlaskit/code": "^18.2.0",
60
+ "@atlaskit/code": "^19.0.0",
61
61
  "@atlaskit/codemod-utils": "^5.0.0",
62
- "@atlaskit/docs": "^12.1.0",
63
- "@atlaskit/form": "^16.1.0",
62
+ "@atlaskit/docs": "^12.2.0",
63
+ "@atlaskit/form": "^17.0.0",
64
64
  "@atlaskit/heading": "^7.0.0",
65
65
  "@atlaskit/link": "^5.0.0",
66
66
  "@atlaskit/modal-dialog": "^16.3.0",
@@ -69,6 +69,7 @@
69
69
  "@atlaskit/section-message": "^10.0.0",
70
70
  "@atlaskit/textfield": "^10.0.0",
71
71
  "@atlaskit/toggle": "^17.1.0",
72
+ "@atlassian/feature-flags-test-utils": "^1.2.0",
72
73
  "@atlassian/ssr-tests": "workspace:^",
73
74
  "@atlassian/structured-docs-types": "workspace:^",
74
75
  "@testing-library/react": "^16.3.0",
@@ -81,35 +82,15 @@
81
82
  "react-dom": "^18.2.0",
82
83
  "react-lorem-component": "^0.13.0"
83
84
  },
84
- "techstack": {
85
- "@atlassian/frontend": {
86
- "import-structure": "atlassian-conventions"
87
- },
88
- "@repo/internal": {
89
- "dom-events": "use-bind-event-listener",
90
- "design-system": "v1",
91
- "styling": [
92
- "compiled",
93
- "static"
94
- ],
95
- "ui-components": [
96
- "primitives",
97
- "lite-mode"
98
- ],
99
- "analytics": "analytics-next",
100
- "design-tokens": [
101
- "color",
102
- "spacing"
103
- ],
104
- "deprecation": "no-deprecated-imports"
105
- }
106
- },
107
85
  "platform-feature-flags": {
108
86
  "platform-dst-top-layer": {
109
87
  "type": "boolean"
110
88
  },
111
89
  "platform-dst-shape-theme-default": {
112
90
  "type": "boolean"
91
+ },
92
+ "platform-dst-dp-parse-date-format": {
93
+ "type": "boolean"
113
94
  }
114
95
  },
115
96
  "homepage": "https://atlassian.design/components/datetime-picker/"