@lingui/macro 3.13.0 → 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
  * ```
@@ -159,13 +159,6 @@ declare module "@lingui/macro" {
159
159
  choices: Record<string, string> & BasicType
160
160
  ): string
161
161
 
162
- /**
163
- * Defines multiple messages for extraction
164
- */
165
- export function defineMessages<M extends Record<string, MessageDescriptor>>(
166
- messages: M
167
- ): M
168
-
169
162
  /**
170
163
  * Define a message for later use
171
164
  *
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
  * ```
@@ -148,15 +148,6 @@ export function selectOrdinal(
148
148
  */
149
149
  export function select(value: string, choices: ChoiceOptions): string
150
150
 
151
- /**
152
- * Defines multiple messages for extraction
153
- *
154
- * @see {@link defineMessage} for more details
155
- */
156
- export function defineMessages<M extends Record<string, MessageDescriptor>>(
157
- messages: M
158
- ): M
159
-
160
151
  /**
161
152
  * Define a message for later use
162
153
  *
@@ -181,6 +172,7 @@ export type TransProps = {
181
172
  comment?: string
182
173
  values?: Record<string, unknown>
183
174
  context?: string
175
+ children?: React.ReactNode
184
176
  component?: React.ComponentType<TransRenderProps>
185
177
  render?: (props: TransRenderProps) => ReactElement<any, any> | null
186
178
  }
package/index.js CHANGED
@@ -147,7 +147,6 @@ function alreadyVisited(path) {
147
147
 
148
148
  function getMacroType(tagName) {
149
149
  switch (tagName) {
150
- case "defineMessages":
151
150
  case "defineMessage":
152
151
  case "arg":
153
152
  case "t":
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.0",
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,10 +30,12 @@
30
30
  ],
31
31
  "dependencies": {
32
32
  "@babel/runtime": "^7.11.2",
33
- "@lingui/conf": "^3.13.0",
33
+ "@lingui/conf": "^3.13.3",
34
34
  "ramda": "^0.27.1"
35
35
  },
36
36
  "peerDependencies": {
37
+ "@lingui/core": "^3.13.0",
38
+ "@lingui/react": "^3.13.0",
37
39
  "babel-plugin-macros": "2 || 3"
38
40
  }
39
41
  }