@selfhelp/shared 1.14.12 → 1.14.13

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/CHANGELOG.md CHANGED
@@ -9,6 +9,30 @@ All notable changes to `@selfhelp/shared` will be documented in this file.
9
9
 
10
10
  This project follows semantic versioning.
11
11
 
12
+ ## v1.14.13
13
+
14
+ `css_mobile` Tailwind-class lockstep fix. The web CMS class dropdown
15
+ (`generate-css-classes.js`) offers the **standard Tailwind numeric color scale**
16
+ (`bg-blue-500`, `text-gray-800`, `border-red-500`, …), but Tailwind v4's default
17
+ palette is authored in `oklch()`, which React Native cannot parse — so the mobile
18
+ allow-list only ever accepted the hex-backed Mantine scale (`bg-blue-6`) and
19
+ silently dropped every dropdown color class on mobile. Authors saw colored
20
+ backgrounds on web and nothing on mobile.
21
+
22
+ ### Fixed (`cms-classes`)
23
+
24
+ - **Standard Tailwind color scale → Mantine hex scale remap** in
25
+ `src/cms-classes/remap.ts`: `bg-/text-/border-{name}-{50..950}` is now rewritten
26
+ onto the RN-safe Mantine scale (`…-{0..9}`) instead of being dropped. Tailwind-only
27
+ names (`slate`, `purple`, `sky`, `emerald`, `amber`, …) alias to their nearest
28
+ Mantine palette. This is a deliberate, documented web→mobile remap (shade is the
29
+ closest visual match).
30
+ - **`text-white` / `text-black`** are now allow-listed (plain colors, RN-safe).
31
+ - The web dropdown's interactive-state classes (`hover:*`, `focus:ring-*`,
32
+ `focus:outline-none`) are remapped to drop cleanly on mobile instead of warning.
33
+
34
+ Patch bump (additive remap/allow-list; no contract change).
35
+
12
36
  ## v1.14.12
13
37
 
14
38
  Layout cross-platform pass — the 13 layout styles (`container`, `box`, `flex`,
package/dist/index.js CHANGED
@@ -1135,7 +1135,7 @@ var CLASS_PATTERNS = [
1135
1135
  { prefix: "max-w-", values: [...SIZE_VALUES, "full", "fit", "screen", "none"] },
1136
1136
  { prefix: "max-h-", values: [...SIZE_VALUES, "full", "screen", "none"] },
1137
1137
  // typography
1138
- { prefix: "text-", values: [...SIZE_VALUES, "left", "center", "right", "justify", ...COLOR_SCALE_VALUES] },
1138
+ { prefix: "text-", values: [...SIZE_VALUES, "left", "center", "right", "justify", "white", "black", ...COLOR_SCALE_VALUES] },
1139
1139
  { prefix: "font-", values: ["thin", "light", "normal", "medium", "semibold", "bold", "extrabold", "black"] },
1140
1140
  { prefix: "leading-", values: ["none", "tight", "snug", "normal", "relaxed", "loose"] },
1141
1141
  { prefix: "tracking-", values: ["tighter", "tight", "normal", "wide", "wider", "widest"] },
@@ -1206,10 +1206,78 @@ var LITERAL_CLASSES = /* @__PURE__ */ new Set([
1206
1206
  ]);
1207
1207
 
1208
1208
  // src/cms-classes/remap.ts
1209
+ var TW_SCALE_TO_MANTINE = {
1210
+ "50": "0",
1211
+ "100": "1",
1212
+ "200": "2",
1213
+ "300": "3",
1214
+ "400": "4",
1215
+ "500": "6",
1216
+ "600": "7",
1217
+ "700": "8",
1218
+ "800": "9",
1219
+ "900": "9",
1220
+ "950": "9"
1221
+ };
1222
+ var TW_NAME_TO_MANTINE = {
1223
+ slate: "gray",
1224
+ gray: "gray",
1225
+ zinc: "gray",
1226
+ neutral: "gray",
1227
+ stone: "gray",
1228
+ red: "red",
1229
+ rose: "pink",
1230
+ pink: "pink",
1231
+ fuchsia: "grape",
1232
+ purple: "grape",
1233
+ grape: "grape",
1234
+ violet: "violet",
1235
+ indigo: "indigo",
1236
+ blue: "blue",
1237
+ sky: "cyan",
1238
+ cyan: "cyan",
1239
+ teal: "teal",
1240
+ emerald: "green",
1241
+ green: "green",
1242
+ lime: "lime",
1243
+ yellow: "yellow",
1244
+ amber: "orange",
1245
+ orange: "orange"
1246
+ };
1247
+ var COLOR_PREFIXES = ["bg-", "text-", "border-"];
1248
+ function buildColorScaleRemaps() {
1249
+ const out = [];
1250
+ for (const prefix of COLOR_PREFIXES) {
1251
+ for (const [twName, mantineName] of Object.entries(TW_NAME_TO_MANTINE)) {
1252
+ for (const [twScale, idx] of Object.entries(TW_SCALE_TO_MANTINE)) {
1253
+ out.push({
1254
+ from: `${prefix}${twName}-${twScale}`,
1255
+ to: `${prefix}${mantineName}-${idx}`,
1256
+ reason: "tailwind oklch scale \u2192 mantine hex scale (RN-safe)"
1257
+ });
1258
+ }
1259
+ }
1260
+ }
1261
+ return out;
1262
+ }
1263
+ var INTERACTIVE_DROP = [
1264
+ "hover:bg-gray-100",
1265
+ "hover:bg-blue-600",
1266
+ "hover:bg-green-600",
1267
+ "hover:bg-red-600",
1268
+ "hover:text-blue-600",
1269
+ "hover:text-green-600",
1270
+ "hover:text-red-600",
1271
+ "hover:shadow-md",
1272
+ "hover:shadow-lg",
1273
+ "hover:underline",
1274
+ "focus:outline-none",
1275
+ "focus:ring-2",
1276
+ "focus:ring-blue-500",
1277
+ "focus:ring-offset-2"
1278
+ ].map((from) => ({ from, to: null, reason: "interactive state not applicable on mobile" }));
1209
1279
  var CLASS_REMAP = [
1210
- // hover/focus on mobile only fires for keyboard nav; safe to drop.
1211
- { from: "hover:bg-gray-100", to: null, reason: "hover not applicable on mobile" },
1212
- { from: "hover:underline", to: null, reason: "hover not applicable on mobile" },
1280
+ ...INTERACTIVE_DROP,
1213
1281
  // cursor classes are no-ops on RN.
1214
1282
  { from: "cursor-pointer", to: null, reason: "no cursor on RN" },
1215
1283
  { from: "cursor-default", to: null, reason: "no cursor on RN" },
@@ -1218,7 +1286,9 @@ var CLASS_REMAP = [
1218
1286
  { from: "select-text", to: null, reason: "unsupported on RN" },
1219
1287
  // legacy aliases
1220
1288
  { from: "mantine-fw", to: "w-full" },
1221
- { from: "mantine-h-full", to: "h-full" }
1289
+ { from: "mantine-h-full", to: "h-full" },
1290
+ // standard Tailwind color scale → Mantine hex scale (RN-safe)
1291
+ ...buildColorScaleRemaps()
1222
1292
  ];
1223
1293
  var REMAP_MAP = new Map(CLASS_REMAP.map((r) => [r.from, r]));
1224
1294
  function findRemap(className) {
package/dist/index.mjs CHANGED
@@ -1015,7 +1015,7 @@ var CLASS_PATTERNS = [
1015
1015
  { prefix: "max-w-", values: [...SIZE_VALUES, "full", "fit", "screen", "none"] },
1016
1016
  { prefix: "max-h-", values: [...SIZE_VALUES, "full", "screen", "none"] },
1017
1017
  // typography
1018
- { prefix: "text-", values: [...SIZE_VALUES, "left", "center", "right", "justify", ...COLOR_SCALE_VALUES] },
1018
+ { prefix: "text-", values: [...SIZE_VALUES, "left", "center", "right", "justify", "white", "black", ...COLOR_SCALE_VALUES] },
1019
1019
  { prefix: "font-", values: ["thin", "light", "normal", "medium", "semibold", "bold", "extrabold", "black"] },
1020
1020
  { prefix: "leading-", values: ["none", "tight", "snug", "normal", "relaxed", "loose"] },
1021
1021
  { prefix: "tracking-", values: ["tighter", "tight", "normal", "wide", "wider", "widest"] },
@@ -1086,10 +1086,78 @@ var LITERAL_CLASSES = /* @__PURE__ */ new Set([
1086
1086
  ]);
1087
1087
 
1088
1088
  // src/cms-classes/remap.ts
1089
+ var TW_SCALE_TO_MANTINE = {
1090
+ "50": "0",
1091
+ "100": "1",
1092
+ "200": "2",
1093
+ "300": "3",
1094
+ "400": "4",
1095
+ "500": "6",
1096
+ "600": "7",
1097
+ "700": "8",
1098
+ "800": "9",
1099
+ "900": "9",
1100
+ "950": "9"
1101
+ };
1102
+ var TW_NAME_TO_MANTINE = {
1103
+ slate: "gray",
1104
+ gray: "gray",
1105
+ zinc: "gray",
1106
+ neutral: "gray",
1107
+ stone: "gray",
1108
+ red: "red",
1109
+ rose: "pink",
1110
+ pink: "pink",
1111
+ fuchsia: "grape",
1112
+ purple: "grape",
1113
+ grape: "grape",
1114
+ violet: "violet",
1115
+ indigo: "indigo",
1116
+ blue: "blue",
1117
+ sky: "cyan",
1118
+ cyan: "cyan",
1119
+ teal: "teal",
1120
+ emerald: "green",
1121
+ green: "green",
1122
+ lime: "lime",
1123
+ yellow: "yellow",
1124
+ amber: "orange",
1125
+ orange: "orange"
1126
+ };
1127
+ var COLOR_PREFIXES = ["bg-", "text-", "border-"];
1128
+ function buildColorScaleRemaps() {
1129
+ const out = [];
1130
+ for (const prefix of COLOR_PREFIXES) {
1131
+ for (const [twName, mantineName] of Object.entries(TW_NAME_TO_MANTINE)) {
1132
+ for (const [twScale, idx] of Object.entries(TW_SCALE_TO_MANTINE)) {
1133
+ out.push({
1134
+ from: `${prefix}${twName}-${twScale}`,
1135
+ to: `${prefix}${mantineName}-${idx}`,
1136
+ reason: "tailwind oklch scale \u2192 mantine hex scale (RN-safe)"
1137
+ });
1138
+ }
1139
+ }
1140
+ }
1141
+ return out;
1142
+ }
1143
+ var INTERACTIVE_DROP = [
1144
+ "hover:bg-gray-100",
1145
+ "hover:bg-blue-600",
1146
+ "hover:bg-green-600",
1147
+ "hover:bg-red-600",
1148
+ "hover:text-blue-600",
1149
+ "hover:text-green-600",
1150
+ "hover:text-red-600",
1151
+ "hover:shadow-md",
1152
+ "hover:shadow-lg",
1153
+ "hover:underline",
1154
+ "focus:outline-none",
1155
+ "focus:ring-2",
1156
+ "focus:ring-blue-500",
1157
+ "focus:ring-offset-2"
1158
+ ].map((from) => ({ from, to: null, reason: "interactive state not applicable on mobile" }));
1089
1159
  var CLASS_REMAP = [
1090
- // hover/focus on mobile only fires for keyboard nav; safe to drop.
1091
- { from: "hover:bg-gray-100", to: null, reason: "hover not applicable on mobile" },
1092
- { from: "hover:underline", to: null, reason: "hover not applicable on mobile" },
1160
+ ...INTERACTIVE_DROP,
1093
1161
  // cursor classes are no-ops on RN.
1094
1162
  { from: "cursor-pointer", to: null, reason: "no cursor on RN" },
1095
1163
  { from: "cursor-default", to: null, reason: "no cursor on RN" },
@@ -1098,7 +1166,9 @@ var CLASS_REMAP = [
1098
1166
  { from: "select-text", to: null, reason: "unsupported on RN" },
1099
1167
  // legacy aliases
1100
1168
  { from: "mantine-fw", to: "w-full" },
1101
- { from: "mantine-h-full", to: "h-full" }
1169
+ { from: "mantine-h-full", to: "h-full" },
1170
+ // standard Tailwind color scale → Mantine hex scale (RN-safe)
1171
+ ...buildColorScaleRemaps()
1102
1172
  ];
1103
1173
  var REMAP_MAP = new Map(CLASS_REMAP.map((r) => [r.from, r]));
1104
1174
  function findRemap(className) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@selfhelp/shared",
3
- "version": "1.14.12",
3
+ "version": "1.14.13",
4
4
  "description": "Shared TypeScript package for SelfHelp web frontend and mobile app: style registry, types, API contracts, Mantine theme tokens, condition + interpolation engines, CMS class allow-list.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,6 +34,24 @@ describe('classifyClass (css_mobile classifier)', () => {
34
34
  expect(classifyClass('grid-cols-7').kind).toBe('drop');
35
35
  expect(classifyClass('').kind).toBe('drop');
36
36
  });
37
+
38
+ it('remaps the web dropdown standard Tailwind color scale onto the Mantine hex scale (RN-safe)', () => {
39
+ // Tailwind v4 default palette is oklch and crashes RN, so the standard
40
+ // scale the dropdown offers is rewritten onto the hex-backed Mantine scale.
41
+ expect(classifyClass('bg-blue-500')).toMatchObject({ kind: 'remap', from: 'bg-blue-500', to: 'bg-blue-6' });
42
+ expect(classifyClass('bg-green-600')).toMatchObject({ kind: 'remap', to: 'bg-green-7' });
43
+ expect(classifyClass('bg-gray-800')).toMatchObject({ kind: 'remap', to: 'bg-gray-9' });
44
+ expect(classifyClass('text-indigo-700')).toMatchObject({ kind: 'remap', to: 'text-indigo-8' });
45
+ expect(classifyClass('border-red-500')).toMatchObject({ kind: 'remap', to: 'border-red-6' });
46
+ // Tailwind-only names alias to the nearest Mantine palette.
47
+ expect(classifyClass('bg-purple-500')).toMatchObject({ kind: 'remap', to: 'bg-grape-6' });
48
+ expect(classifyClass('bg-slate-700')).toMatchObject({ kind: 'remap', to: 'bg-gray-8' });
49
+ });
50
+
51
+ it('allows text-white / text-black (plain colors, RN-safe)', () => {
52
+ expect(classifyClass('text-white').kind).toBe('allow');
53
+ expect(classifyClass('text-black').kind).toBe('allow');
54
+ });
37
55
  });
38
56
 
39
57
  describe('classifyClassString', () => {
@@ -85,7 +85,7 @@ export const CLASS_PATTERNS: readonly IClassPattern[] = [
85
85
  { prefix: 'max-w-', values: [...SIZE_VALUES, 'full', 'fit', 'screen', 'none'] },
86
86
  { prefix: 'max-h-', values: [...SIZE_VALUES, 'full', 'screen', 'none'] },
87
87
  // typography
88
- { prefix: 'text-', values: [...SIZE_VALUES, 'left', 'center', 'right', 'justify', ...COLOR_SCALE_VALUES] },
88
+ { prefix: 'text-', values: [...SIZE_VALUES, 'left', 'center', 'right', 'justify', 'white', 'black', ...COLOR_SCALE_VALUES] },
89
89
  { prefix: 'font-', values: ['thin', 'light', 'normal', 'medium', 'semibold', 'bold', 'extrabold', 'black'] },
90
90
  { prefix: 'leading-', values: ['none', 'tight', 'snug', 'normal', 'relaxed', 'loose'] },
91
91
  { prefix: 'tracking-', values: ['tighter', 'tight', 'normal', 'wide', 'wider', 'widest'] },
@@ -22,10 +22,100 @@ export interface IClassRemap {
22
22
  reason?: string;
23
23
  }
24
24
 
25
+ /**
26
+ * Standard Tailwind numeric color scale (`50..950`) → Mantine hex-backed
27
+ * scale index (`0..9`). The web dropdown (`generate-css-classes.js`) offers
28
+ * the standard Tailwind scale, but Tailwind v4's default palette is authored
29
+ * in `oklch()`, which React Native cannot parse — only the Mantine palettes
30
+ * carried by the shared preset (`theme/tailwind.ts`, indices `0..9`) resolve
31
+ * to RN-safe hex. So we rewrite the dropdown's standard scale onto the Mantine
32
+ * scale instead of dropping it. The shade is the closest visual match; this is
33
+ * a deliberate, documented web→mobile remap.
34
+ */
35
+ const TW_SCALE_TO_MANTINE: Readonly<Record<string, string>> = {
36
+ '50': '0',
37
+ '100': '1',
38
+ '200': '2',
39
+ '300': '3',
40
+ '400': '4',
41
+ '500': '6',
42
+ '600': '7',
43
+ '700': '8',
44
+ '800': '9',
45
+ '900': '9',
46
+ '950': '9',
47
+ };
48
+
49
+ /**
50
+ * Tailwind color name → Mantine palette name. Only Mantine palettes have an
51
+ * RN-safe hex scale in the shared preset; Tailwind-only names (`slate`,
52
+ * `purple`, `sky`, …) are aliased to their nearest Mantine palette.
53
+ */
54
+ const TW_NAME_TO_MANTINE: Readonly<Record<string, string>> = {
55
+ slate: 'gray',
56
+ gray: 'gray',
57
+ zinc: 'gray',
58
+ neutral: 'gray',
59
+ stone: 'gray',
60
+ red: 'red',
61
+ rose: 'pink',
62
+ pink: 'pink',
63
+ fuchsia: 'grape',
64
+ purple: 'grape',
65
+ grape: 'grape',
66
+ violet: 'violet',
67
+ indigo: 'indigo',
68
+ blue: 'blue',
69
+ sky: 'cyan',
70
+ cyan: 'cyan',
71
+ teal: 'teal',
72
+ emerald: 'green',
73
+ green: 'green',
74
+ lime: 'lime',
75
+ yellow: 'yellow',
76
+ amber: 'orange',
77
+ orange: 'orange',
78
+ };
79
+
80
+ const COLOR_PREFIXES = ['bg-', 'text-', 'border-'] as const;
81
+
82
+ /** Build the `{prefix}{twName}-{twScale}` → `{prefix}{mantineName}-{idx}` remaps. */
83
+ function buildColorScaleRemaps(): IClassRemap[] {
84
+ const out: IClassRemap[] = [];
85
+ for (const prefix of COLOR_PREFIXES) {
86
+ for (const [twName, mantineName] of Object.entries(TW_NAME_TO_MANTINE)) {
87
+ for (const [twScale, idx] of Object.entries(TW_SCALE_TO_MANTINE)) {
88
+ out.push({
89
+ from: `${prefix}${twName}-${twScale}`,
90
+ to: `${prefix}${mantineName}-${idx}`,
91
+ reason: 'tailwind oklch scale → mantine hex scale (RN-safe)',
92
+ });
93
+ }
94
+ }
95
+ }
96
+ return out;
97
+ }
98
+
99
+ /** Interactive-state classes the web dropdown offers but RN can't honour. */
100
+ const INTERACTIVE_DROP = [
101
+ 'hover:bg-gray-100',
102
+ 'hover:bg-blue-600',
103
+ 'hover:bg-green-600',
104
+ 'hover:bg-red-600',
105
+ 'hover:text-blue-600',
106
+ 'hover:text-green-600',
107
+ 'hover:text-red-600',
108
+ 'hover:shadow-md',
109
+ 'hover:shadow-lg',
110
+ 'hover:underline',
111
+ 'focus:outline-none',
112
+ 'focus:ring-2',
113
+ 'focus:ring-blue-500',
114
+ 'focus:ring-offset-2',
115
+ ].map((from): IClassRemap => ({ from, to: null, reason: 'interactive state not applicable on mobile' }));
116
+
25
117
  export const CLASS_REMAP: readonly IClassRemap[] = [
26
- // hover/focus on mobile only fires for keyboard nav; safe to drop.
27
- { from: 'hover:bg-gray-100', to: null, reason: 'hover not applicable on mobile' },
28
- { from: 'hover:underline', to: null, reason: 'hover not applicable on mobile' },
118
+ ...INTERACTIVE_DROP,
29
119
  // cursor classes are no-ops on RN.
30
120
  { from: 'cursor-pointer', to: null, reason: 'no cursor on RN' },
31
121
  { from: 'cursor-default', to: null, reason: 'no cursor on RN' },
@@ -35,6 +125,8 @@ export const CLASS_REMAP: readonly IClassRemap[] = [
35
125
  // legacy aliases
36
126
  { from: 'mantine-fw', to: 'w-full' },
37
127
  { from: 'mantine-h-full', to: 'h-full' },
128
+ // standard Tailwind color scale → Mantine hex scale (RN-safe)
129
+ ...buildColorScaleRemaps(),
38
130
  ];
39
131
 
40
132
  const REMAP_MAP = new Map<string, IClassRemap>(CLASS_REMAP.map((r) => [r.from, r]));