@xsolla/xui-primitives-core 0.212.0 → 0.213.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/index.d.mts CHANGED
@@ -170,10 +170,23 @@ interface SpinnerProps {
170
170
  "aria-describedby"?: string;
171
171
  testID?: string;
172
172
  }
173
+ /**
174
+ * Size of an icon glyph — the single definition shared by every icon package.
175
+ *
176
+ * A `number` is pixels. A `string` is a raw CSS length, which is what lets an
177
+ * icon fill a box owned by its parent: `size="100%"` is the reason this type
178
+ * is not just `number`.
179
+ *
180
+ * Only numbers and percentage strings survive on React Native, which has no
181
+ * layout engine for `calc()` or font-relative units. Use `resolveIconSize`
182
+ * (web) and `resolveNativeIconSize` (native) rather than interpolating a
183
+ * `size` into styles by hand — see FEP-895.
184
+ */
185
+ type IconSize = number | string;
173
186
  interface IconProps {
174
187
  name?: string;
175
188
  color?: string;
176
- size?: number | string;
189
+ size?: IconSize;
177
190
  children?: React.ReactNode;
178
191
  testID?: string;
179
192
  /** Test ID for testing frameworks (web) */
@@ -259,4 +272,30 @@ interface LinearGradientProps {
259
272
  testID?: string;
260
273
  }
261
274
 
262
- export type { BoxProps, DividerProps, IconProps, InputPrimitiveProps, LinearGradientProps, SpinnerProps, TestIDProps, TextAreaPrimitiveProps, TextProps };
275
+ /**
276
+ * An `IconSize` narrowed to what React Native's layout accepts. Assignable to
277
+ * both `DimensionValue` (`View` styles) and `NumberProp` (react-native-svg).
278
+ */
279
+ type NativeIconSize = number | `${number}%`;
280
+ /**
281
+ * Resolve an `IconSize` to a CSS length for the web renderers.
282
+ *
283
+ * Numbers become pixels; strings pass through untouched, so any valid CSS
284
+ * length (`"100%"`, `"1em"`, `"calc(100% - 2px)"`) reaches the stylesheet as
285
+ * authored. Interpolating `size` directly into a `px` template is the bug this
286
+ * exists to prevent — it turns `"100%"` into `100%px`, which the browser drops.
287
+ */
288
+ declare function resolveIconSize(size: IconSize): string;
289
+ /**
290
+ * Resolve an `IconSize` for the React Native renderers.
291
+ *
292
+ * Numbers (density-independent pixels) and percentage strings pass through.
293
+ * Anything else — `calc()`, `em`, `rem`, `vw` — has no meaning to React
294
+ * Native's layout, so it falls back to `fallback` and warns once instead of
295
+ * silently rendering at the wrong size.
296
+ */
297
+ declare function resolveNativeIconSize(size: IconSize, fallback: number): NativeIconSize;
298
+ /** Reset the warn-once cache. Test-only. */
299
+ declare function resetNativeIconSizeWarnings(): void;
300
+
301
+ export { type BoxProps, type DividerProps, type IconProps, type IconSize, type InputPrimitiveProps, type LinearGradientProps, type NativeIconSize, type SpinnerProps, type TestIDProps, type TextAreaPrimitiveProps, type TextProps, resetNativeIconSizeWarnings, resolveIconSize, resolveNativeIconSize };
package/index.d.ts CHANGED
@@ -170,10 +170,23 @@ interface SpinnerProps {
170
170
  "aria-describedby"?: string;
171
171
  testID?: string;
172
172
  }
173
+ /**
174
+ * Size of an icon glyph — the single definition shared by every icon package.
175
+ *
176
+ * A `number` is pixels. A `string` is a raw CSS length, which is what lets an
177
+ * icon fill a box owned by its parent: `size="100%"` is the reason this type
178
+ * is not just `number`.
179
+ *
180
+ * Only numbers and percentage strings survive on React Native, which has no
181
+ * layout engine for `calc()` or font-relative units. Use `resolveIconSize`
182
+ * (web) and `resolveNativeIconSize` (native) rather than interpolating a
183
+ * `size` into styles by hand — see FEP-895.
184
+ */
185
+ type IconSize = number | string;
173
186
  interface IconProps {
174
187
  name?: string;
175
188
  color?: string;
176
- size?: number | string;
189
+ size?: IconSize;
177
190
  children?: React.ReactNode;
178
191
  testID?: string;
179
192
  /** Test ID for testing frameworks (web) */
@@ -259,4 +272,30 @@ interface LinearGradientProps {
259
272
  testID?: string;
260
273
  }
261
274
 
262
- export type { BoxProps, DividerProps, IconProps, InputPrimitiveProps, LinearGradientProps, SpinnerProps, TestIDProps, TextAreaPrimitiveProps, TextProps };
275
+ /**
276
+ * An `IconSize` narrowed to what React Native's layout accepts. Assignable to
277
+ * both `DimensionValue` (`View` styles) and `NumberProp` (react-native-svg).
278
+ */
279
+ type NativeIconSize = number | `${number}%`;
280
+ /**
281
+ * Resolve an `IconSize` to a CSS length for the web renderers.
282
+ *
283
+ * Numbers become pixels; strings pass through untouched, so any valid CSS
284
+ * length (`"100%"`, `"1em"`, `"calc(100% - 2px)"`) reaches the stylesheet as
285
+ * authored. Interpolating `size` directly into a `px` template is the bug this
286
+ * exists to prevent — it turns `"100%"` into `100%px`, which the browser drops.
287
+ */
288
+ declare function resolveIconSize(size: IconSize): string;
289
+ /**
290
+ * Resolve an `IconSize` for the React Native renderers.
291
+ *
292
+ * Numbers (density-independent pixels) and percentage strings pass through.
293
+ * Anything else — `calc()`, `em`, `rem`, `vw` — has no meaning to React
294
+ * Native's layout, so it falls back to `fallback` and warns once instead of
295
+ * silently rendering at the wrong size.
296
+ */
297
+ declare function resolveNativeIconSize(size: IconSize, fallback: number): NativeIconSize;
298
+ /** Reset the warn-once cache. Test-only. */
299
+ declare function resetNativeIconSizeWarnings(): void;
300
+
301
+ export { type BoxProps, type DividerProps, type IconProps, type IconSize, type InputPrimitiveProps, type LinearGradientProps, type NativeIconSize, type SpinnerProps, type TestIDProps, type TextAreaPrimitiveProps, type TextProps, resetNativeIconSizeWarnings, resolveIconSize, resolveNativeIconSize };
package/index.js CHANGED
@@ -3,6 +3,10 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
6
10
  var __copyProps = (to, from, except, desc) => {
7
11
  if (from && typeof from === "object" || typeof from === "function") {
8
12
  for (let key of __getOwnPropNames(from))
@@ -15,5 +19,42 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
15
19
 
16
20
  // src/index.ts
17
21
  var index_exports = {};
22
+ __export(index_exports, {
23
+ resetNativeIconSizeWarnings: () => resetNativeIconSizeWarnings,
24
+ resolveIconSize: () => resolveIconSize,
25
+ resolveNativeIconSize: () => resolveNativeIconSize
26
+ });
18
27
  module.exports = __toCommonJS(index_exports);
28
+
29
+ // src/iconSize.ts
30
+ var PERCENTAGE = /^\d+(?:\.\d+)?%$/;
31
+ function resolveIconSize(size) {
32
+ return typeof size === "number" ? `${size}px` : size.trim();
33
+ }
34
+ function resolveNativeIconSize(size, fallback) {
35
+ if (typeof size === "number") return size;
36
+ const trimmed = size.trim();
37
+ if (PERCENTAGE.test(trimmed)) return trimmed;
38
+ warnUnsupportedNativeSize(trimmed, fallback);
39
+ return fallback;
40
+ }
41
+ var warned = /* @__PURE__ */ new Set();
42
+ function resetNativeIconSizeWarnings() {
43
+ warned.clear();
44
+ }
45
+ function warnUnsupportedNativeSize(size, fallback) {
46
+ if (warned.has(size)) return;
47
+ warned.add(size);
48
+ if (typeof console !== "undefined" && console.warn) {
49
+ console.warn(
50
+ `Icon: size="${size}" is not supported on React Native \u2014 only numbers and percentage strings (e.g. "100%") are. Falling back to ${fallback}. To size an icon by its container, use size="100%".`
51
+ );
52
+ }
53
+ }
54
+ // Annotate the CommonJS export names for ESM import in node:
55
+ 0 && (module.exports = {
56
+ resetNativeIconSizeWarnings,
57
+ resolveIconSize,
58
+ resolveNativeIconSize
59
+ });
19
60
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from \"./types\";\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/iconSize.ts"],"sourcesContent":["export * from \"./types\";\nexport * from \"./iconSize\";\n","import type { IconSize } from \"./types\";\n\n/**\n * A bare, non-negative percentage length — the only string form React Native\n * understands. Deliberately rejects signs, whitespace-separated junk and\n * anything calc-like.\n */\nconst PERCENTAGE = /^\\d+(?:\\.\\d+)?%$/;\n\n/**\n * An `IconSize` narrowed to what React Native's layout accepts. Assignable to\n * both `DimensionValue` (`View` styles) and `NumberProp` (react-native-svg).\n */\nexport type NativeIconSize = number | `${number}%`;\n\n/**\n * Resolve an `IconSize` to a CSS length for the web renderers.\n *\n * Numbers become pixels; strings pass through untouched, so any valid CSS\n * length (`\"100%\"`, `\"1em\"`, `\"calc(100% - 2px)\"`) reaches the stylesheet as\n * authored. Interpolating `size` directly into a `px` template is the bug this\n * exists to prevent — it turns `\"100%\"` into `100%px`, which the browser drops.\n */\nexport function resolveIconSize(size: IconSize): string {\n return typeof size === \"number\" ? `${size}px` : size.trim();\n}\n\n/**\n * Resolve an `IconSize` for the React Native renderers.\n *\n * Numbers (density-independent pixels) and percentage strings pass through.\n * Anything else — `calc()`, `em`, `rem`, `vw` — has no meaning to React\n * Native's layout, so it falls back to `fallback` and warns once instead of\n * silently rendering at the wrong size.\n */\nexport function resolveNativeIconSize(\n size: IconSize,\n fallback: number\n): NativeIconSize {\n if (typeof size === \"number\") return size;\n\n const trimmed = size.trim();\n if (PERCENTAGE.test(trimmed)) return trimmed as `${number}%`;\n\n warnUnsupportedNativeSize(trimmed, fallback);\n return fallback;\n}\n\nconst warned = new Set<string>();\n\n/** Reset the warn-once cache. Test-only. */\nexport function resetNativeIconSizeWarnings(): void {\n warned.clear();\n}\n\nfunction warnUnsupportedNativeSize(size: string, fallback: number): void {\n if (warned.has(size)) return;\n warned.add(size);\n\n if (typeof console !== \"undefined\" && console.warn) {\n console.warn(\n `Icon: size=\"${size}\" is not supported on React Native — only numbers ` +\n `and percentage strings (e.g. \"100%\") are. Falling back to ${fallback}. ` +\n `To size an icon by its container, use size=\"100%\".`\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACOA,IAAM,aAAa;AAgBZ,SAAS,gBAAgB,MAAwB;AACtD,SAAO,OAAO,SAAS,WAAW,GAAG,IAAI,OAAO,KAAK,KAAK;AAC5D;AAUO,SAAS,sBACd,MACA,UACgB;AAChB,MAAI,OAAO,SAAS,SAAU,QAAO;AAErC,QAAM,UAAU,KAAK,KAAK;AAC1B,MAAI,WAAW,KAAK,OAAO,EAAG,QAAO;AAErC,4BAA0B,SAAS,QAAQ;AAC3C,SAAO;AACT;AAEA,IAAM,SAAS,oBAAI,IAAY;AAGxB,SAAS,8BAAoC;AAClD,SAAO,MAAM;AACf;AAEA,SAAS,0BAA0B,MAAc,UAAwB;AACvE,MAAI,OAAO,IAAI,IAAI,EAAG;AACtB,SAAO,IAAI,IAAI;AAEf,MAAI,OAAO,YAAY,eAAe,QAAQ,MAAM;AAClD,YAAQ;AAAA,MACN,eAAe,IAAI,oHAC4C,QAAQ;AAAA,IAEzE;AAAA,EACF;AACF;","names":[]}
package/index.mjs CHANGED
@@ -1 +1,31 @@
1
+ // src/iconSize.ts
2
+ var PERCENTAGE = /^\d+(?:\.\d+)?%$/;
3
+ function resolveIconSize(size) {
4
+ return typeof size === "number" ? `${size}px` : size.trim();
5
+ }
6
+ function resolveNativeIconSize(size, fallback) {
7
+ if (typeof size === "number") return size;
8
+ const trimmed = size.trim();
9
+ if (PERCENTAGE.test(trimmed)) return trimmed;
10
+ warnUnsupportedNativeSize(trimmed, fallback);
11
+ return fallback;
12
+ }
13
+ var warned = /* @__PURE__ */ new Set();
14
+ function resetNativeIconSizeWarnings() {
15
+ warned.clear();
16
+ }
17
+ function warnUnsupportedNativeSize(size, fallback) {
18
+ if (warned.has(size)) return;
19
+ warned.add(size);
20
+ if (typeof console !== "undefined" && console.warn) {
21
+ console.warn(
22
+ `Icon: size="${size}" is not supported on React Native \u2014 only numbers and percentage strings (e.g. "100%") are. Falling back to ${fallback}. To size an icon by its container, use size="100%".`
23
+ );
24
+ }
25
+ }
26
+ export {
27
+ resetNativeIconSizeWarnings,
28
+ resolveIconSize,
29
+ resolveNativeIconSize
30
+ };
1
31
  //# sourceMappingURL=index.mjs.map
package/index.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/iconSize.ts"],"sourcesContent":["import type { IconSize } from \"./types\";\n\n/**\n * A bare, non-negative percentage length — the only string form React Native\n * understands. Deliberately rejects signs, whitespace-separated junk and\n * anything calc-like.\n */\nconst PERCENTAGE = /^\\d+(?:\\.\\d+)?%$/;\n\n/**\n * An `IconSize` narrowed to what React Native's layout accepts. Assignable to\n * both `DimensionValue` (`View` styles) and `NumberProp` (react-native-svg).\n */\nexport type NativeIconSize = number | `${number}%`;\n\n/**\n * Resolve an `IconSize` to a CSS length for the web renderers.\n *\n * Numbers become pixels; strings pass through untouched, so any valid CSS\n * length (`\"100%\"`, `\"1em\"`, `\"calc(100% - 2px)\"`) reaches the stylesheet as\n * authored. Interpolating `size` directly into a `px` template is the bug this\n * exists to prevent — it turns `\"100%\"` into `100%px`, which the browser drops.\n */\nexport function resolveIconSize(size: IconSize): string {\n return typeof size === \"number\" ? `${size}px` : size.trim();\n}\n\n/**\n * Resolve an `IconSize` for the React Native renderers.\n *\n * Numbers (density-independent pixels) and percentage strings pass through.\n * Anything else — `calc()`, `em`, `rem`, `vw` — has no meaning to React\n * Native's layout, so it falls back to `fallback` and warns once instead of\n * silently rendering at the wrong size.\n */\nexport function resolveNativeIconSize(\n size: IconSize,\n fallback: number\n): NativeIconSize {\n if (typeof size === \"number\") return size;\n\n const trimmed = size.trim();\n if (PERCENTAGE.test(trimmed)) return trimmed as `${number}%`;\n\n warnUnsupportedNativeSize(trimmed, fallback);\n return fallback;\n}\n\nconst warned = new Set<string>();\n\n/** Reset the warn-once cache. Test-only. */\nexport function resetNativeIconSizeWarnings(): void {\n warned.clear();\n}\n\nfunction warnUnsupportedNativeSize(size: string, fallback: number): void {\n if (warned.has(size)) return;\n warned.add(size);\n\n if (typeof console !== \"undefined\" && console.warn) {\n console.warn(\n `Icon: size=\"${size}\" is not supported on React Native — only numbers ` +\n `and percentage strings (e.g. \"100%\") are. Falling back to ${fallback}. ` +\n `To size an icon by its container, use size=\"100%\".`\n );\n }\n}\n"],"mappings":";AAOA,IAAM,aAAa;AAgBZ,SAAS,gBAAgB,MAAwB;AACtD,SAAO,OAAO,SAAS,WAAW,GAAG,IAAI,OAAO,KAAK,KAAK;AAC5D;AAUO,SAAS,sBACd,MACA,UACgB;AAChB,MAAI,OAAO,SAAS,SAAU,QAAO;AAErC,QAAM,UAAU,KAAK,KAAK;AAC1B,MAAI,WAAW,KAAK,OAAO,EAAG,QAAO;AAErC,4BAA0B,SAAS,QAAQ;AAC3C,SAAO;AACT;AAEA,IAAM,SAAS,oBAAI,IAAY;AAGxB,SAAS,8BAAoC;AAClD,SAAO,MAAM;AACf;AAEA,SAAS,0BAA0B,MAAc,UAAwB;AACvE,MAAI,OAAO,IAAI,IAAI,EAAG;AACtB,SAAO,IAAI,IAAI;AAEf,MAAI,OAAO,YAAY,eAAe,QAAQ,MAAM;AAClD,YAAQ;AAAA,MACN,eAAe,IAAI,oHAC4C,QAAQ;AAAA,IAEzE;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@xsolla/xui-primitives-core",
3
- "version": "0.212.0",
3
+ "version": "0.213.1",
4
4
  "description": "Core type definitions for XUI primitives",
5
5
  "main": "./index.js",
6
6
  "module": "./index.mjs",
7
7
  "types": "./index.d.ts",
8
8
  "scripts": {
9
- "build": "tsup"
9
+ "build": "tsup",
10
+ "test": "vitest",
11
+ "test:run": "vitest run",
12
+ "test:coverage": "vitest run --coverage"
10
13
  },
11
14
  "devDependencies": {
12
15
  "@vitest/coverage-v8": "^4.0.18",