@pega/custom-dx-components 0.23.30 → 0.23.31

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.
Files changed (45) hide show
  1. package/package.json +1 -1
  2. package/src/tasks/create/templates/Constellation/Field/Date/DateFormatter.js.mustache +0 -1
  3. package/src/tasks/create/templates/Constellation/Field/Date/FormattedText.jsx.mustache +0 -1
  4. package/src/tasks/create/templates/Constellation/Field/Date/date.js.mustache +0 -2
  5. package/src/tasks/create/templates/Constellation/Field/DateTime/date-time.js.mustache +0 -1
  6. package/src/tasks/create/templates/Constellation/Field/DateTime/date-utils.js.mustache +0 -1
  7. package/src/tasks/create/templates/Constellation/Field/DateTime/date.js.mustache +0 -1
  8. package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/date.js.mustache +0 -1
  9. package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/embed-utils.js.mustache +0 -1
  10. package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/repeat-utils.js.mustache +0 -1
  11. package/src/tasks/create/templates/Constellation/Field/Picklist-Autocomplete/textformat-utils.jsx.mustache +0 -1
  12. package/src/tasks/create/templates/Constellation/Field/Picklist-RadioButtons/textformat-utils.jsx.mustache +0 -1
  13. package/src/tasks/create/templates/Constellation/Field/Text-URL/text-url.jsx.mustache +0 -1
  14. package/src/tasks/create/templates/Constellation/Field/TimeofDay/time-of-day.js.mustache +0 -1
  15. package/src/tasks/create/templates/Constellation/Template/PAGE/utils.js.mustache +0 -1
  16. package/src/tasks/init/template/.eslintrc.json +10 -1
  17. package/src/tasks/init/template/package.json.mustache +1 -1
  18. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyAutocomplete/date.js +0 -1
  19. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyAutocomplete/embed-utils.js +22 -12
  20. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyAutocomplete/repeat-utils.js +0 -1
  21. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyAutocomplete/textformat-utils.jsx +0 -1
  22. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/DateFormatter.js +0 -1
  23. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/FormattedText.jsx +0 -1
  24. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDate/date.js +0 -2
  25. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/date-time.js +0 -1
  26. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/date-utils.js +41 -48
  27. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyDateTime/date.js +54 -68
  28. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyPage/utils.js +12 -10
  29. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyRadioButtons/textformat-utils.jsx +0 -1
  30. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyTimeOfDay/time-of-day.js +41 -48
  31. package/tests/assets/components/createAll/Constellation/Pega_DXIL_MyURL/text-url.jsx +0 -1
  32. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyAutocomplete/date.js +0 -1
  33. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyAutocomplete/embed-utils.js +22 -12
  34. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyAutocomplete/repeat-utils.js +0 -1
  35. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyAutocomplete/textformat-utils.jsx +0 -1
  36. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/DateFormatter.js +0 -1
  37. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/FormattedText.jsx +0 -1
  38. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDate/date.js +0 -2
  39. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/date-time.js +0 -1
  40. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/date-utils.js +41 -48
  41. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyDateTime/date.js +54 -68
  42. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyPage/utils.js +12 -10
  43. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyRadioButtons/textformat-utils.jsx +0 -1
  44. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyTimeOfDay/time-of-day.js +41 -48
  45. package/tests/assets/components/createAll/Launchpad/Pega_DXIL_MyURL/text-url.jsx +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pega/custom-dx-components",
3
- "version": "0.23.30",
3
+ "version": "0.23.31",
4
4
  "description": "Utility for building custom UI components",
5
5
  "bin": "./bin/index.js",
6
6
  "scripts": {
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import dayjs from 'dayjs';
3
2
  import relativeTime from 'dayjs/plugin/relativeTime.js';
4
3
  import localizedFormat from 'dayjs/plugin/localizedFormat.js';
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import { FieldValueList } from '@pega/cosmos-react-core';
3
2
  import PropTypes from 'prop-types';
4
3
 
@@ -1,6 +1,4 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  /* eslint-disable no-undef */
3
- /* eslint-disable prefer-regex-literals */
4
2
  import dayjs from 'dayjs';
5
3
  import DateFormatter from './DateFormatter.js';
6
4
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import dayjs from "dayjs";
3
2
  import relativeTime from 'dayjs/plugin/relativeTime.js';
4
3
  import localizedFormat from 'dayjs/plugin/localizedFormat.js';
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import dayjs from "dayjs";
3
2
  import relativeTime from 'dayjs/plugin/relativeTime.js';
4
3
  import localizedFormat from 'dayjs/plugin/localizedFormat.js';
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import dayjs from 'dayjs';
3
2
  import relativeTime from 'dayjs/plugin/relativeTime.js';
4
3
  import localizedFormat from 'dayjs/plugin/localizedFormat.js';
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import dayjs from 'dayjs';
3
2
  import relativeTime from 'dayjs/plugin/relativeTime.js';
4
3
  import localizedFormat from 'dayjs/plugin/localizedFormat.js';
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import { isEmbeddedField, isPageListInPath, PAGE, PAGELIST, buildAggOrCalcId } from './repeat-utils.js';
3
2
 
4
3
  export const AT_FILTEREDLIST = '@FILTERED_LIST';
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  /* eslint-disable sonarjs/no-collapsible-if */
3
2
  /* eslint-disable default-param-last */
4
3
  /* eslint-disable func-names */
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import { EmailDisplay, PhoneDisplay, URLDisplay, Image, Button, Lightbox } from '@pega/cosmos-react-core';
3
2
  import { useRef, useState } from 'react';
4
3
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import { EmailDisplay, PhoneDisplay, URLDisplay, Image, Button, Lightbox } from '@pega/cosmos-react-core';
3
2
  import { useRef, useState } from 'react';
4
3
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import { useState, useRef, React} from "react";
3
2
  import { EmailDisplay, PhoneDisplay, URLDisplay, Image, Button, Lightbox } from '@pega/cosmos-react-core';
4
3
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import dayjs from "dayjs";
3
2
  import relativeTime from 'dayjs/plugin/relativeTime.js';
4
3
  import localizedFormat from 'dayjs/plugin/localizedFormat.js';
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import { createUID } from '@pega/cosmos-react-core';
3
2
 
4
3
  // import { LazyMap as LazyComponentMap } from '../../components_map';
@@ -19,7 +19,14 @@
19
19
  "version": "detect"
20
20
  }
21
21
  },
22
- "ignorePatterns": ["node_modules", "packages/*/lib", "!.storybook", ".storybook/public"],
22
+ "ignorePatterns": [
23
+ "node_modules",
24
+ "packages/*/lib",
25
+ "!.storybook",
26
+ ".storybook/public",
27
+ "**/demo.stories.jsx",
28
+ "/**/mock.stories.js"
29
+ ],
23
30
  "rules": {
24
31
  // Prettier recommends running separately from a linter.
25
32
  // https://prettier.io/docs/en/integrating-with-linters.html#notes
@@ -85,6 +92,7 @@
85
92
  "no-irregular-whitespace": "off",
86
93
  "no-empty": "off",
87
94
  "no-new-object": "off",
95
+ "import/no-relative-packages": "off",
88
96
 
89
97
  "import/no-mutable-exports": "error",
90
98
  "sonarjs/max-switch-cases": "error",
@@ -131,6 +139,7 @@
131
139
  "operator-assignment": "error",
132
140
  "prefer-template": "error",
133
141
  "vars-on-top": "error",
142
+ "prefer-regex-literals": "off",
134
143
 
135
144
  "no-use-before-define": "off", // doc for @typescript-eslint/no-use-before-define says to turn off the base implementation
136
145
  "@typescript-eslint/no-use-before-define": "error"
@@ -69,7 +69,7 @@
69
69
  },
70
70
  "devDependencies": {
71
71
  "@pega/configs": "^0.6.0",
72
- "@pega/custom-dx-components": "0.23.30",
72
+ "@pega/custom-dx-components": "0.23.31",
73
73
  "@pega/pcore-pconnect-typedefs": "2.0.0",
74
74
  "@storybook/addon-actions": "^7.6.7",
75
75
  "@storybook/addon-essentials": "^7.6.7",
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import dayjs from 'dayjs';
3
2
  import relativeTime from 'dayjs/plugin/relativeTime.js';
4
3
  import localizedFormat from 'dayjs/plugin/localizedFormat.js';
@@ -1,5 +1,10 @@
1
- /* eslint-disable import/no-relative-packages */
2
- import { isEmbeddedField, isPageListInPath, PAGE, PAGELIST, buildAggOrCalcId } from './repeat-utils.js';
1
+ import {
2
+ isEmbeddedField,
3
+ isPageListInPath,
4
+ PAGE,
5
+ PAGELIST,
6
+ buildAggOrCalcId
7
+ } from './repeat-utils.js';
3
8
 
4
9
  export const AT_FILTEREDLIST = '@FILTERED_LIST';
5
10
  export const AT_PROPERTY = '@P';
@@ -53,7 +58,7 @@ export function getEmbeddedFieldName(propertyName, classID) {
53
58
  * @param {Array} metaFields Fields metadata Array. Contains metadata of all the fields.
54
59
  */
55
60
  export function updateMetaEmbeddedFieldID(metaFields) {
56
- return metaFields.forEach((metaField) => {
61
+ return metaFields.forEach(metaField => {
57
62
  if (metaField.fieldID?.startsWith(PAGE) || metaField.fieldID?.startsWith(PAGELIST)) {
58
63
  metaField.fieldID = getFieldNameFromEmbeddedFieldName(metaField.fieldID);
59
64
  }
@@ -70,7 +75,7 @@ export function updateMetaEmbeddedFieldID(metaFields) {
70
75
  */
71
76
  export function getConfigEmbeddedFieldsMeta(configFields, classID) {
72
77
  const configEmbeddedFieldsMeta = [];
73
- configFields.forEach((field) => {
78
+ configFields.forEach(field => {
74
79
  let value = field;
75
80
  if (isEmbeddedField(value)) {
76
81
  // conversion Page.PageList[].property => Page.PageList.property
@@ -94,8 +99,8 @@ export function getConfigEmbeddedFieldsMeta(configFields, classID) {
94
99
  */
95
100
  export function mergeConfigEmbeddedFieldsMeta(configEmbeddedFieldsMeta, metaFields) {
96
101
  const mergedMetaFields = [...metaFields];
97
- configEmbeddedFieldsMeta.forEach((configFieldMeta) => {
98
- const fieldMeta = metaFields.find((metaField) => metaField.fieldID === configFieldMeta.fieldID);
102
+ configEmbeddedFieldsMeta.forEach(configFieldMeta => {
103
+ const fieldMeta = metaFields.find(metaField => metaField.fieldID === configFieldMeta.fieldID);
99
104
  if (!fieldMeta) mergedMetaFields.push(configFieldMeta);
100
105
  });
101
106
  return mergedMetaFields;
@@ -153,7 +158,7 @@ export function preparePropertyValue(value) {
153
158
  // FIXME #EmbeddedPropertyPatch
154
159
  // TODO: Remove this utility when we have nested response for queryable pageList and supports scalarList component
155
160
  export function updatePageListFieldsConfig(configFields) {
156
- return configFields.forEach((item) => {
161
+ return configFields.forEach(item => {
157
162
  if (item.type === 'ScalarList') {
158
163
  if (!item.config.originalValue) {
159
164
  item.config.originalValue = item.config.value;
@@ -167,7 +172,7 @@ export function updatePageListFieldsConfig(configFields) {
167
172
  * Update the renderer type for the properties of type Page.
168
173
  */
169
174
  export function updatePageFieldsConfig(configFields, parentClassID) {
170
- return configFields.forEach((item) => {
175
+ return configFields.forEach(item => {
171
176
  const {
172
177
  type,
173
178
  config: { value }
@@ -257,7 +262,7 @@ export function preparePropertyMaps(fields, classID, context) {
257
262
  export function getPageListFields(fields) {
258
263
  const parentPaths = new Set();
259
264
  const pageListFields = [];
260
- fields.forEach((field) => {
265
+ fields.forEach(field => {
261
266
  const { name } = field;
262
267
  if (isPageListProperty(name)) {
263
268
  const parentPath = name.substring(0, name.lastIndexOf(':'));
@@ -270,7 +275,12 @@ export function getPageListFields(fields) {
270
275
  return pageListFields;
271
276
  }
272
277
 
273
- export function mergePageListFieldAggregation(pageListName, select, existingAggregations, existingAggregationsName) {
278
+ export function mergePageListFieldAggregation(
279
+ pageListName,
280
+ select,
281
+ existingAggregations,
282
+ existingAggregationsName
283
+ ) {
274
284
  // Build a dummy genericAggregationId to check if any type of aggregation for that pagelist is included in existing aggregations.
275
285
  const genericAggregationId = buildAggOrCalcId(pageListName, '');
276
286
  if (existingAggregationsName.includes(genericAggregationId)) {
@@ -285,7 +295,7 @@ export function mergePageListFieldsAggregation(fields, select, existingAggregati
285
295
  const parentPaths = new Set();
286
296
  const existingAggregationsName = Object.keys(existingAggregations).toString();
287
297
  const pageListFields = [];
288
- fields.forEach((field) => {
298
+ fields.forEach(field => {
289
299
  const { name } = field;
290
300
  if (isPageListProperty(name)) {
291
301
  const parentPath = name.substring(0, name.lastIndexOf(':'));
@@ -307,5 +317,5 @@ export function mergePageListFieldsAggregation(fields, select, existingAggregati
307
317
  * @returns {object | undefined} value of first pageListProperty found
308
318
  */
309
319
  export function hasPageListProperty(fieldDefs) {
310
- return fieldDefs?.find((field) => isPageListProperty(field.name));
320
+ return fieldDefs?.find(field => isPageListProperty(field.name));
311
321
  }
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  /* eslint-disable sonarjs/no-collapsible-if */
3
2
  /* eslint-disable default-param-last */
4
3
  /* eslint-disable func-names */
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import { EmailDisplay, PhoneDisplay, URLDisplay, Image, Button, Lightbox } from '@pega/cosmos-react-core';
3
2
  import { useRef, useState } from 'react';
4
3
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import dayjs from 'dayjs';
3
2
  import relativeTime from 'dayjs/plugin/relativeTime.js';
4
3
  import localizedFormat from 'dayjs/plugin/localizedFormat.js';
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import { FieldValueList } from '@pega/cosmos-react-core';
3
2
  import PropTypes from 'prop-types';
4
3
 
@@ -1,6 +1,4 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  /* eslint-disable no-undef */
3
- /* eslint-disable prefer-regex-literals */
4
2
  import dayjs from 'dayjs';
5
3
  import DateFormatter from './DateFormatter.js';
6
4
 
@@ -1,4 +1,3 @@
1
- /* eslint-disable import/no-relative-packages */
2
1
  import dayjs from "dayjs";
3
2
  import relativeTime from 'dayjs/plugin/relativeTime.js';
4
3
  import localizedFormat from 'dayjs/plugin/localizedFormat.js';
@@ -1,5 +1,4 @@
1
- /* eslint-disable import/no-relative-packages */
2
- import dayjs from "dayjs";
1
+ import dayjs from 'dayjs';
3
2
  import relativeTime from 'dayjs/plugin/relativeTime.js';
4
3
  import localizedFormat from 'dayjs/plugin/localizedFormat.js';
5
4
  import utc from 'dayjs/plugin/utc.js';
@@ -17,11 +16,11 @@ dayjs.extend(timezone);
17
16
  * @param {string} text datetime
18
17
  * @returns {object} datetime as a dayjs object
19
18
  */
20
- export const getDayJSObject = (text) => {
19
+ export const getDayJSObject = text => {
21
20
  const momObj = dayjs(text);
22
21
  if (momObj.isValid()) return momObj;
23
22
  const timeStamp = text;
24
- const isDateTime = timeStamp.indexOf("GMT") !== -1;
23
+ const isDateTime = timeStamp.indexOf('GMT') !== -1;
25
24
  const year = parseInt(timeStamp.substr(0, 4), 10);
26
25
  const month = parseInt(timeStamp.substr(4, 2), 10) - 1;
27
26
  const day = parseInt(timeStamp.substr(6, 2), 10);
@@ -47,7 +46,7 @@ export const getDayJSObject = (text) => {
47
46
  }
48
47
 
49
48
  mom = dayjs(
50
- mom.toLocaleString("en-US", {
49
+ mom.toLocaleString('en-US', {
51
50
  timeZone: CurrentTz
52
51
  })
53
52
  );
@@ -61,8 +60,8 @@ export const getDayJSObject = (text) => {
61
60
  * @param {string} time datetime
62
61
  * @returns {object} relative time from now
63
62
  */
64
- export const getRelativeTime = (time) => {
65
- let relativetime = "";
63
+ export const getRelativeTime = time => {
64
+ let relativetime = '';
66
65
  if (dayjs(time).isUTC()) {
67
66
  relativetime = dayjs(time).fromNow();
68
67
  } else {
@@ -78,7 +77,7 @@ export const getRelativeTime = (time) => {
78
77
  * @param {string} value from which Year needs to be taken out
79
78
  * @returns {number} year for the date passed
80
79
  */
81
- export const getFullYear = (value) =>
80
+ export const getFullYear = value =>
82
81
  value ? new Date(value).getFullYear() : new Date().getFullYear();
83
82
 
84
83
  /**
@@ -128,8 +127,8 @@ export const getMinDate = (previousYears, currentYear, yearFromValue) => {
128
127
  *
129
128
  * @returns {number} clockFormat
130
129
  */
131
- export const parseClockFormat = (clockFormat) =>
132
- typeof clockFormat === "string" ? parseInt(clockFormat, 10) : clockFormat;
130
+ export const parseClockFormat = clockFormat =>
131
+ typeof clockFormat === 'string' ? parseInt(clockFormat, 10) : clockFormat;
133
132
 
134
133
  /**
135
134
  * Return datetime value string off to seconds
@@ -141,9 +140,9 @@ export const parseClockFormat = (clockFormat) =>
141
140
  */
142
141
  export const correctDateTimeToSeconds = (datetime, withSeconds) => {
143
142
  if (withSeconds) {
144
- return `${datetime.substring(0, datetime.indexOf("Z"))}.000Z`;
143
+ return `${datetime.substring(0, datetime.indexOf('Z'))}.000Z`;
145
144
  }
146
- return `${datetime.substring(0, datetime.lastIndexOf(":"))}:00.000Z`;
145
+ return `${datetime.substring(0, datetime.lastIndexOf(':'))}:00.000Z`;
147
146
  };
148
147
 
149
148
  /**
@@ -156,12 +155,9 @@ export const correctDateTimeToSeconds = (datetime, withSeconds) => {
156
155
  */
157
156
  export const timeCorrectedToSeconds = (datetime, withSeconds) => {
158
157
  if (withSeconds) {
159
- return datetime.substring(datetime.indexOf("T") + 1, datetime.indexOf("."));
158
+ return datetime.substring(datetime.indexOf('T') + 1, datetime.indexOf('.'));
160
159
  }
161
- return `${datetime.substring(
162
- datetime.indexOf("T") + 1,
163
- datetime.lastIndexOf(":")
164
- )}:00`;
160
+ return `${datetime.substring(datetime.indexOf('T') + 1, datetime.lastIndexOf(':'))}:00`;
165
161
  };
166
162
 
167
163
  /**
@@ -184,14 +180,13 @@ export const datetimeFireChangeBlurEvents = (
184
180
  propName,
185
181
  pConn
186
182
  ) => {
187
-
188
183
  // TODO - clean up, we should not rely on timestamp from cosmos to check InComplete validation
189
184
  // above triggerFieldChange should have validated this
190
185
  if (errorState) {
191
186
  pConn.getValidationApi().validate(errorState);
192
187
  }
193
188
  // BUG-640834 In errorState presist old values avoiding store update & re-render.
194
- else{
189
+ else {
195
190
  if (formattedValue !== actualValue) {
196
191
  actions.updateFieldValue(propName, formattedValue);
197
192
  }
@@ -212,27 +207,27 @@ export const getDateFormat = (locale, options) => {
212
207
  .formatToParts()
213
208
  .map(({ type, value }) => {
214
209
  switch (type) {
215
- case "day":
216
- return "DD";
217
- case "month":
218
- return "MM";
219
- case "year":
220
- return "YYYY";
221
- case "hour":
222
- return "hh";
223
- case "minute":
224
- return "mm";
225
- case "second":
226
- return "ss";
227
- case "dayPeriod":
228
- return "A";
229
- case "literal":
210
+ case 'day':
211
+ return 'DD';
212
+ case 'month':
213
+ return 'MM';
214
+ case 'year':
215
+ return 'YYYY';
216
+ case 'hour':
217
+ return 'hh';
218
+ case 'minute':
219
+ return 'mm';
220
+ case 'second':
221
+ return 'ss';
222
+ case 'dayPeriod':
223
+ return 'A';
224
+ case 'literal':
230
225
  return value;
231
226
  default:
232
- return "";
227
+ return '';
233
228
  }
234
229
  })
235
- .join("");
230
+ .join('');
236
231
  };
237
232
 
238
233
  /**
@@ -242,15 +237,13 @@ export const getDateFormat = (locale, options) => {
242
237
  * @returns {boolean} True or False for the locale
243
238
  * Example : getDateFormat("pl-PL") returns false
244
239
  */
245
- export const is12HClockFormat = (locale) => {
240
+ export const is12HClockFormat = locale => {
246
241
  const meridiem = new Intl.DateTimeFormat(locale, {
247
- hour: "numeric"
242
+ hour: 'numeric'
248
243
  })
249
244
  .formatToParts()
250
- .find(({ type }) => type === "dayPeriod");
251
- return !!(meridiem === null || meridiem === undefined
252
- ? undefined
253
- : meridiem.value);
245
+ .find(({ type }) => type === 'dayPeriod');
246
+ return !!(meridiem === null || meridiem === undefined ? undefined : meridiem.value);
254
247
  };
255
248
 
256
249
  /**
@@ -263,9 +256,9 @@ export const is12HClockFormat = (locale) => {
263
256
  */
264
257
  export const getTimeOptions = (withSeconds, is12h = false) => {
265
258
  return {
266
- hour: "numeric",
267
- minute: "numeric",
268
- ...(withSeconds && { second: "numeric" }),
259
+ hour: 'numeric',
260
+ minute: 'numeric',
261
+ ...(withSeconds && { second: 'numeric' }),
269
262
  hour12: is12h
270
263
  };
271
264
  };
@@ -280,9 +273,9 @@ export const getTimeOptions = (withSeconds, is12h = false) => {
280
273
  */
281
274
  export const getDateTimeOptions = (withSeconds, is12h = false) => {
282
275
  return {
283
- year: "numeric",
284
- month: "numeric",
285
- day: "numeric",
276
+ year: 'numeric',
277
+ month: 'numeric',
278
+ day: 'numeric',
286
279
  ...getTimeOptions(withSeconds, is12h)
287
280
  };
288
281
  };