@lingui/macro 3.13.2 → 3.13.3

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/global.d.ts CHANGED
@@ -119,9 +119,9 @@ declare module "@lingui/macro" {
119
119
  * ```
120
120
  * import { selectOrdinal } from "@lingui/macro";
121
121
  * const message = selectOrdinal(count, {
122
- * one: "1st",
123
- * two: "2nd",
124
- * few: "3rd",
122
+ * one: "#st",
123
+ * two: "#nd",
124
+ * few: "#rd",
125
125
  * other: "#th",
126
126
  * });
127
127
  * ```
package/index.d.ts CHANGED
@@ -111,9 +111,9 @@ export function plural(value: number | string, options: ChoiceOptions): string
111
111
  * ```
112
112
  * import { selectOrdinal } from "@lingui/macro";
113
113
  * const message = selectOrdinal(count, {
114
- * one: "1st",
115
- * two: "2nd",
116
- * few: "3rd",
114
+ * one: "#st",
115
+ * two: "#nd",
116
+ * few: "#rd",
117
117
  * other: "#th",
118
118
  * });
119
119
  * ```
@@ -172,6 +172,7 @@ export type TransProps = {
172
172
  comment?: string
173
173
  values?: Record<string, unknown>
174
174
  context?: string
175
+ children?: React.ReactNode
175
176
  component?: React.ComponentType<TransRenderProps>
176
177
  render?: (props: TransRenderProps) => ReactElement<any, any> | null
177
178
  }
package/macroJsx.js CHANGED
@@ -66,6 +66,13 @@ var MacroJSX = /*#__PURE__*/function () {
66
66
  (0, _defineProperty2.default)(this, "types", void 0);
67
67
  (0, _defineProperty2.default)(this, "expressionIndex", void 0);
68
68
  (0, _defineProperty2.default)(this, "elementIndex", void 0);
69
+ (0, _defineProperty2.default)(this, "safeJsxAttribute", function (name, value) {
70
+ // Quoted JSX attributes use XML-style escapes instead of JavaScript-style escapes.
71
+ // This means that <Trans id="Say \"hi\"!" /> is invalid, but <Trans id={"Say \"hi\"!"} /> is valid.
72
+ // We could consider removing this condition and always wrap in a jsxExpressionContainer.
73
+ var attributeValue = value.includes('"') ? _this.types.jsxExpressionContainer(_this.types.stringLiteral(value)) : _this.types.stringLiteral(value);
74
+ return _this.types.jsxAttribute(_this.types.jsxIdentifier(name), attributeValue);
75
+ });
69
76
  (0, _defineProperty2.default)(this, "replacePath", function (path) {
70
77
  var tokens = _this.tokenizeNode(path.node);
71
78
 
@@ -93,11 +100,11 @@ var MacroJSX = /*#__PURE__*/function () {
93
100
 
94
101
  if (process.env.NODE_ENV !== "production") {
95
102
  if (message) {
96
- attributes.push(_this.types.jsxAttribute(_this.types.jsxIdentifier(_constants.MESSAGE), _this.types.stringLiteral(message)));
103
+ attributes.push(_this.safeJsxAttribute(_constants.MESSAGE, message));
97
104
  }
98
105
  }
99
106
  } else {
100
- attributes.push(_this.types.jsxAttribute(_this.types.jsxIdentifier(_constants.ID), _this.types.stringLiteral(message)));
107
+ attributes.push(_this.safeJsxAttribute(_constants.ID, message));
101
108
  }
102
109
 
103
110
  if (process.env.NODE_ENV !== "production") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingui/macro",
3
- "version": "3.13.2",
3
+ "version": "3.13.3",
4
4
  "description": "Macro for generating messages in ICU MessageFormat syntax",
5
5
  "main": "index.js",
6
6
  "author": {
@@ -30,7 +30,7 @@
30
30
  ],
31
31
  "dependencies": {
32
32
  "@babel/runtime": "^7.11.2",
33
- "@lingui/conf": "^3.13.2",
33
+ "@lingui/conf": "^3.13.3",
34
34
  "ramda": "^0.27.1"
35
35
  },
36
36
  "peerDependencies": {