payload 1.6.5 → 1.6.6

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.
@@ -1,25 +1,67 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
27
  };
5
28
  Object.defineProperty(exports, "__esModule", { value: true });
6
29
  const react_1 = __importDefault(require("react"));
7
- const react_datepicker_1 = __importDefault(require("react-datepicker"));
30
+ const react_datepicker_1 = __importStar(require("react-datepicker"));
31
+ const Locales = __importStar(require("date-fns/locale"));
32
+ const Locale_1 = require("../../utilities/Locale");
8
33
  const Calendar_1 = __importDefault(require("../../icons/Calendar"));
9
34
  const X_1 = __importDefault(require("../../icons/X"));
10
35
  require("react-datepicker/dist/react-datepicker.css");
11
36
  require("./index.scss");
12
37
  const baseClass = 'date-time-picker';
38
+ const formattedLocales = {
39
+ en: 'enUS',
40
+ my: 'enUS',
41
+ ua: 'uk',
42
+ zh: 'zhCN',
43
+ };
13
44
  const DateTime = (props) => {
14
- const { value, onChange, displayFormat, pickerAppearance = 'dayAndTime', minDate, maxDate, monthsToShow = 1, minTime, maxTime, timeIntervals = 30, timeFormat = 'h:mm aa', readOnly, placeholder: placeholderText, } = props;
45
+ const { value, onChange, displayFormat, pickerAppearance, minDate, maxDate, monthsToShow = 1, minTime, maxTime, timeIntervals = 30, timeFormat = 'h:mm aa', readOnly, placeholder: placeholderText, } = props;
46
+ let currentLocale = (0, Locale_1.useLocale)();
47
+ currentLocale = formattedLocales[currentLocale] || currentLocale;
48
+ try {
49
+ const locale = Locales[currentLocale];
50
+ (0, react_datepicker_1.registerLocale)(currentLocale, locale);
51
+ }
52
+ catch (e) {
53
+ console.warn(`Could not find DatePicker locale for ${currentLocale}`);
54
+ }
15
55
  let dateTimeFormat = displayFormat;
16
- if (dateTimeFormat === undefined) {
56
+ if (dateTimeFormat === undefined && pickerAppearance) {
17
57
  if (pickerAppearance === 'dayAndTime')
18
58
  dateTimeFormat = 'MMM d, yyy h:mm a';
19
59
  else if (pickerAppearance === 'timeOnly')
20
60
  dateTimeFormat = 'h:mm a';
61
+ else if (pickerAppearance === 'dayOnly')
62
+ dateTimeFormat = 'dd';
21
63
  else if (pickerAppearance === 'monthOnly')
22
- dateTimeFormat = 'MM/yyyy';
64
+ dateTimeFormat = 'MMMM';
23
65
  else
24
66
  dateTimeFormat = 'MMM d, yyy';
25
67
  }
@@ -51,11 +93,12 @@ const DateTime = (props) => {
51
93
  react_1.default.createElement(X_1.default, null))),
52
94
  react_1.default.createElement(Calendar_1.default, null)),
53
95
  react_1.default.createElement("div", { className: `${baseClass}__input-wrapper` },
54
- react_1.default.createElement(react_datepicker_1.default, { ...dateTimePickerProps, onChange: (val) => onChange(val), popperModifiers: {
55
- preventOverflow: {
96
+ react_1.default.createElement(react_datepicker_1.default, { ...dateTimePickerProps, onChange: (val) => onChange(val), locale: currentLocale || 'en-US', popperModifiers: [
97
+ {
98
+ name: 'preventOverflow',
56
99
  enabled: true,
57
100
  },
58
- } }))));
101
+ ] }))));
59
102
  };
60
103
  exports.default = DateTime;
61
104
  //# sourceMappingURL=DatePicker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../../../src/admin/components/elements/DatePicker/DatePicker.tsx"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAC1B,wEAA0C;AAC1C,oEAAgD;AAChD,sDAAkC;AAGlC,sDAAoD;AACpD,wBAAsB;AAEtB,MAAM,SAAS,GAAG,kBAAkB,CAAC;AAErC,MAAM,QAAQ,GAAoB,CAAC,KAAK,EAAE,EAAE;IAC1C,MAAM,EACJ,KAAK,EACL,QAAQ,EACR,aAAa,EACb,gBAAgB,GAAG,YAAY,EAC/B,OAAO,EACP,OAAO,EACP,YAAY,GAAG,CAAC,EAChB,OAAO,EACP,OAAO,EACP,aAAa,GAAG,EAAE,EAClB,UAAU,GAAG,SAAS,EACtB,QAAQ,EACR,WAAW,EAAE,eAAe,GAC7B,GAAG,KAAK,CAAC;IAEV,IAAI,cAAc,GAAG,aAAa,CAAC;IAEnC,IAAI,cAAc,KAAK,SAAS,EAAE;QAChC,IAAI,gBAAgB,KAAK,YAAY;YAAE,cAAc,GAAG,mBAAmB,CAAC;aACvE,IAAI,gBAAgB,KAAK,UAAU;YAAE,cAAc,GAAG,QAAQ,CAAC;aAC/D,IAAI,gBAAgB,KAAK,WAAW;YAAE,cAAc,GAAG,SAAS,CAAC;;YACjE,cAAc,GAAG,YAAY,CAAC;KACpC;IAED,MAAM,mBAAmB,GAAG;QAC1B,OAAO;QACP,OAAO;QACP,UAAU,EAAE,cAAc;QAC1B,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC;QACtC,cAAc,EAAE,gBAAgB,KAAK,YAAY,IAAI,gBAAgB,KAAK,UAAU;QACpF,OAAO;QACP,OAAO;QACP,aAAa;QACb,UAAU;QACV,eAAe;QACf,QAAQ,EAAE,QAAQ;QAClB,QAAQ;QACR,eAAe,EAAE,KAAK;QACtB,QAAQ,EAAE,KAAK,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC;QAClC,cAAc,EAAE,KAAK;QACrB,mBAAmB,EAAE,gBAAgB,KAAK,WAAW;KACtD,CAAC;IAEF,MAAM,OAAO,GAAG;QACd,SAAS;QACT,GAAG,SAAS,iBAAiB,gBAAgB,EAAE;KAChD,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAE5B,OAAO,CACL,uCAAK,SAAS,EAAE,OAAO;QACrB,uCAAK,SAAS,EAAE,GAAG,SAAS,aAAa;YACtC,mBAAmB,CAAC,QAAQ,IAAI,CAC/B,0CACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,GAAG,SAAS,gBAAgB,EACvC,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAE7B,8BAAC,WAAK,OAAG,CACF,CACV;YACD,8BAAC,kBAAY,OAAG,CACZ;QACN,uCAAK,SAAS,EAAE,GAAG,SAAS,iBAAiB;YAC3C,8BAAC,0BAAU,OACL,mBAAmB,EACvB,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAW,CAAC,EACxC,eAAe,EAAE;oBACf,eAAe,EAAE;wBACf,OAAO,EAAE,IAAI;qBACd;iBACF,GACD,CACE,CACF,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../../../src/admin/components/elements/DatePicker/DatePicker.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,qEAA8D;AAC9D,yDAA2C;AAC3C,mDAAmD;AACnD,oEAAgD;AAChD,sDAAkC;AAGlC,sDAAoD;AACpD,wBAA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16 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.populate = void 0;
4
4
  const populate = async ({ id, collection, data, key, overrideAccess, depth, currentDepth, req, showHiddenFields, }) => {
5
5
  const dataRef = data;
6
- const doc = await req.payload.findByID({
7
- req,
8
- collection: collection.config.slug,
6
+ const doc = await req.payloadDataLoader.load(JSON.stringify([
7
+ collection.config.slug,
9
8
  id,
10
- currentDepth: currentDepth + 1,
11
- overrideAccess: typeof overrideAccess === 'undefined' ? false : overrideAccess,
12
- disableErrors: true,
13
9
  depth,
10
+ currentDepth + 1,
11
+ req.locale,
12
+ req.fallbackLocale,
13
+ typeof overrideAccess === 'undefined' ? false : overrideAccess,
14
14
  showHiddenFields,
15
- });
15
+ ]));
16
16
  if (doc) {
17
17
  dataRef[key] = doc;
18
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"populate.js","sourceRoot":"","sources":["../../../src/fields/richText/populate.ts"],"names":[],"mappings":";;;AAgBO,MAAM,QAAQ,GAAG,KAAK,EAAE,EAC7B,EAAE,EACF,UAAU,EACV,IAAI,EACJ,GAAG,EACH,cAAc,EACd,KAAK,EACL,YAAY,EACZ,GAAG,EACH,gBAAgB,GAKjB,EAAiB,EAAE;IAClB,MAAM,OAAO,GAAG,IAA+B,CAAC;IAEhD,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC;QACrC,GAAG;QACH,UAAU,EAAE,UAAU,CAAC,MAAM,CAAC,IAAI;QAClC,EAAE;QACF,YAAY,EAAE,YAAY,GAAG,CAAC;QAC9B,cAAc,EAAE,OAAO,cAAc,KAAK,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc;QAC9E,aAAa,EAAE,IAAI;QACnB,KAAK;QACL,gBAAgB;KACjB,CAAC,CAAC;IAEH,IAAI,GAAG,EAAE;QACP,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;KACpB;SAAM;QACL,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;KACrB;AACH,CAAC,CAAC;AAjCW,QAAA,QAAQ,YAiCnB"}
1
+ {"version":3,"file":"populate.js","sourceRoot":"","sources":["../../../src/fields/richText/populate.ts"],"names":[],"mappings":";;;AAgBO,MAAM,QAAQ,GAAG,KAAK,EAAE,EAC7B,EAAE,EACF,UAAU,EACV,IAAI,EACJ,GAAG,EACH,cAAc,EACd,KAAK,EACL,YAAY,EACZ,GAAG,EACH,gBAAgB,GAKjB,EAAiB,EAAE;IAClB,MAAM,OAAO,GAAG,IAA+B,CAAC;IAEhD,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;QAC1D,UAAU,CAAC,MAAM,CAAC,IAAI;QACtB,EAAE;QACF,KAAK;QACL,YAAY,GAAG,CAAC;QAChB,GAAG,CAAC,MAAM;QACV,GAAG,CAAC,cAAc;QAClB,OAAO,cAAc,KAAK,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc;QAC9D,gBAAgB;KACjB,CAAC,CAAC,CAAC;IAEJ,IAAI,GAAG,EAAE;QACP,OAAO,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC;KACpB;SAAM;QACL,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;KACrB;AACH,CAAC,CAAC;AAjCW,QAAA,QAAQ,YAiCnB"}
@@ -77,15 +77,31 @@ export interface Post {
77
77
 
78
78
  ```
79
79
 
80
+ In order for Payload to properly infer these types when using local operations, you'll need to alias the following in your tsconfig.json file:
81
+
82
+ ```json
83
+ {
84
+ "compilerOptions": {
85
+ // ...
86
+ "paths": {
87
+ "payload/generated-types": [
88
+ "./src/payload-types.ts", // Ensure this matches the path to your typescript outputFile
89
+ ],
90
+ }
91
+ },
92
+ // ...
93
+ }
94
+ ```
95
+
80
96
  #### Customizing the output path of your generated types
81
97
 
82
98
  You can specify where you want your types to be generated by adding a property to your Payload config:
83
99
 
84
- ```
100
+ ```ts
85
101
  {
86
102
  // the remainder of your config
87
103
  typescript: {
88
- outputFile: path.resolve(__dirname, './generated-types.ts'),
104
+ outputFile: path.resolve(__dirname, './payload-types.ts'),
89
105
  },
90
106
  }
91
107
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "payload",
3
- "version": "1.6.5",
3
+ "version": "1.6.6",
4
4
  "description": "Node, React and MongoDB Headless CMS and Application Framework",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -161,7 +161,7 @@
161
161
  "react": "^18.2.0",
162
162
  "react-animate-height": "^2.1.2",
163
163
  "react-beautiful-dnd": "^13.1.1",
164
- "react-datepicker": "^3.8.0",
164
+ "react-datepicker": "^4.10.0",
165
165
  "react-diff-viewer": "^3.1.1",
166
166
  "react-dom": "^18.2.0",
167
167
  "react-helmet": "^6.1.0",
@@ -244,7 +244,7 @@
244
244
  "@types/qs-middleware": "^1.0.1",
245
245
  "@types/react": "^18.0.26",
246
246
  "@types/react-beautiful-dnd": "^13.1.3",
247
- "@types/react-datepicker": "^3.1.8",
247
+ "@types/react-datepicker": "^4.8.0",
248
248
  "@types/react-dom": "^18.0.10",
249
249
  "@types/react-helmet": "^6.1.6",
250
250
  "@types/react-router-dom": "^5.3.3",