@selfhelp/shared 1.14.4 → 1.14.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,4 +1,4 @@
1
- import { l as TMantineSize, a as TSharedSize, j as TSharedRadius } from '../common-CJSHQL1E.mjs';
1
+ import { l as TMantineSize, b as TSharedSize, j as TSharedRadius, T as TMantineColor, o as TMantineVariant } from '../common-DVC0R_AX.mjs';
2
2
  export { sharedTailwindExtend, sharedTailwindPreset } from './tailwind.mjs';
3
3
 
4
4
  /**
@@ -92,6 +92,17 @@ type TSemanticSpacing = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
92
92
  type TSemanticRadius = TSharedRadius;
93
93
  type TSemanticIntent = 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'neutral';
94
94
  type TSemanticState = 'disabled' | 'loading' | 'invalid' | 'required';
95
+ /**
96
+ * Cross-platform colour + variant authored in the CMS (`shared_color` /
97
+ * `shared_variant`). These are stored as Mantine palette / variant *values* —
98
+ * the catalog keeps them verbatim (migration `Version20260618143216` renamed the
99
+ * legacy `mantine_*` fields to `shared_*` without touching the values). They are
100
+ * the REAL cross-platform appearance fields (there is no `shared_intent` in the
101
+ * live catalog); the mapper maps them onto HeroUI Native for mobile, while the
102
+ * web renderer feeds them straight into Mantine.
103
+ */
104
+ type TSemanticColor = TMantineColor;
105
+ type TSemanticVariant = TMantineVariant;
95
106
  /** Pixel value used for a fully-rounded ("pill") radius on both platforms. */
96
107
  declare const FULL_RADIUS_PX = 9999;
97
108
  /**
@@ -103,6 +114,15 @@ interface ISharedStyleProps {
103
114
  size?: TSemanticSize;
104
115
  spacing?: TSemanticSpacing;
105
116
  radius?: TSemanticRadius;
117
+ /** Mantine palette colour authored via `shared_color` (cross-platform). */
118
+ color?: TSemanticColor;
119
+ /** Mantine variant authored via `shared_variant` (cross-platform). */
120
+ variant?: TSemanticVariant;
121
+ /**
122
+ * Legacy semantic intent. Kept for back-compat; `shared_intent` is NOT in the
123
+ * live catalog, so real CMS sections drive appearance through `color` /
124
+ * `variant` above. Used as the final fallback in the platform resolvers.
125
+ */
106
126
  intent?: TSemanticIntent;
107
127
  /** Active boolean states. Stored as a small set so multiple can apply. */
108
128
  states?: readonly TSemanticState[];
@@ -211,6 +231,33 @@ declare function mapIntentToHeroUiButtonVariant(intent: TSemanticIntent | undefi
211
231
  * neutral -> default
212
232
  */
213
233
  declare function mapIntentToHeroUiColor(intent: TSemanticIntent | undefined): THeroUiColor | undefined;
234
+ /**
235
+ * Map a Mantine palette colour (`shared_color`) onto a HeroUI Native semantic
236
+ * colour (Chip / Tag / status surfaces). The Mantine palette is broad; it
237
+ * collapses onto HeroUI's five semantic colours by hue family:
238
+ * red/pink -> danger
239
+ * green/teal/lime -> success
240
+ * yellow/orange -> warning
241
+ * gray/dark -> default
242
+ * blue/cyan/indigo/… -> accent (the brand/primary hue)
243
+ */
244
+ declare function mapMantineColorToHeroUiColor(color: TSemanticColor | undefined): THeroUiColor | undefined;
245
+ /**
246
+ * Map a Mantine palette colour (`shared_color`) onto a HeroUI Native **Button**
247
+ * variant when no explicit `shared_variant` is authored. HeroUI buttons encode
248
+ * colour in the variant, so the destructive hue becomes `danger`, neutral hues
249
+ * become `secondary`, and everything else stays the prominent `primary`.
250
+ */
251
+ declare function mapMantineColorToHeroUiButtonVariant(color: TSemanticColor | undefined): THeroUiButtonVariant | undefined;
252
+ /**
253
+ * Map a Mantine variant (`shared_variant`) onto the HeroUI Native Button
254
+ * vocabulary:
255
+ * filled / gradient -> primary
256
+ * light / white / default -> secondary
257
+ * outline -> outline
258
+ * subtle / transparent -> ghost
259
+ */
260
+ declare function mapMantineVariantToHeroUiButtonVariant(variant: TSemanticVariant | undefined): THeroUiButtonVariant | undefined;
214
261
  /**
215
262
  * Read the `shared_*` CMS fields of a section into {@link ISharedStyleProps}.
216
263
  *
@@ -222,7 +269,16 @@ declare function mapIntentToHeroUiColor(intent: TSemanticIntent | undefined): TH
222
269
  declare function resolveSharedStyleProps(fields: Record<string, unknown>): ISharedStyleProps;
223
270
  /** Resolve shared props into Mantine (web) props. */
224
271
  declare function toMantineSemanticProps(props: ISharedStyleProps): IMantineResolvedStyle;
225
- /** Resolve shared props into HeroUI Native (mobile) props. */
272
+ /**
273
+ * Resolve shared props into HeroUI Native (mobile) props.
274
+ *
275
+ * Appearance precedence (mirrors the web renderer, which reads the same CMS
276
+ * fields straight into Mantine):
277
+ * 1. `shared_variant` (Mantine variant) mapped onto the HeroUI button vocab;
278
+ * 2. else `shared_color` (Mantine palette) mapped onto a button variant;
279
+ * 3. else the legacy `intent` mapping (back-compat fallback).
280
+ * The semantic `color` is resolved from `shared_color` first, then `intent`.
281
+ */
226
282
  declare function toHeroUiSemanticProps(props: ISharedStyleProps): IHeroUiResolvedStyle;
227
283
  /**
228
284
  * Resolve shared props into a plain React Native style object (for styles with
@@ -282,4 +338,4 @@ interface IResolvedVariant {
282
338
  }
283
339
  declare function resolveMantineVariant(variant: string | undefined, color: string | undefined): IResolvedVariant;
284
340
 
285
- export { COLOR_PALETTE, COLOR_SCALES, CONTAINER_SIZE_PX, FONT_SIZE_PX, FULL_RADIUS_PX, type IHeroUiResolvedStyle, type IMantineResolvedStyle, type IReactNativeResolvedStyle, type IReactNativeThemeScales, type IResolvedVariant, type ISharedStyleProps, type ISpacingResolved, LINE_HEIGHT, RADIUS_PX, SPACING_PX, SPACING_TO_TAILWIND, type TCanonicalColor, type TCanonicalRadius, type TCanonicalSpacing, type THeroUiButtonVariant, type THeroUiColor, type THeroUiSize, type TMantineMappedColor, type TMantineMappedVariant, type TSemanticIntent, type TSemanticRadius, type TSemanticSize, type TSemanticSpacing, type TSemanticState, colorToHex, mapIntentToHeroUiButtonVariant, mapIntentToHeroUiColor, mapIntentToMantine, mapRadiusToMantine, mapRadiusToPx, mapSizeToHeroUi, mapSizeToMantine, mapSpacingToPx, radiusToPx, resolveMantineVariant, resolveSharedStyle, resolveSharedStyleForMobile, resolveSharedStyleForWeb, resolveSharedStyleProps, sizeToFontPx, spacingToPx, toHeroUiSemanticProps, toMantineSemanticProps, toReactNativeSemanticStyle };
341
+ export { COLOR_PALETTE, COLOR_SCALES, CONTAINER_SIZE_PX, FONT_SIZE_PX, FULL_RADIUS_PX, type IHeroUiResolvedStyle, type IMantineResolvedStyle, type IReactNativeResolvedStyle, type IReactNativeThemeScales, type IResolvedVariant, type ISharedStyleProps, type ISpacingResolved, LINE_HEIGHT, RADIUS_PX, SPACING_PX, SPACING_TO_TAILWIND, type TCanonicalColor, type TCanonicalRadius, type TCanonicalSpacing, type THeroUiButtonVariant, type THeroUiColor, type THeroUiSize, type TMantineMappedColor, type TMantineMappedVariant, type TSemanticColor, type TSemanticIntent, type TSemanticRadius, type TSemanticSize, type TSemanticSpacing, type TSemanticState, type TSemanticVariant, colorToHex, mapIntentToHeroUiButtonVariant, mapIntentToHeroUiColor, mapIntentToMantine, mapMantineColorToHeroUiButtonVariant, mapMantineColorToHeroUiColor, mapMantineVariantToHeroUiButtonVariant, mapRadiusToMantine, mapRadiusToPx, mapSizeToHeroUi, mapSizeToMantine, mapSpacingToPx, radiusToPx, resolveMantineVariant, resolveSharedStyle, resolveSharedStyleForMobile, resolveSharedStyleForWeb, resolveSharedStyleProps, sizeToFontPx, spacingToPx, toHeroUiSemanticProps, toMantineSemanticProps, toReactNativeSemanticStyle };
@@ -1,4 +1,4 @@
1
- import { l as TMantineSize, a as TSharedSize, j as TSharedRadius } from '../common-CJSHQL1E.js';
1
+ import { l as TMantineSize, b as TSharedSize, j as TSharedRadius, T as TMantineColor, o as TMantineVariant } from '../common-DVC0R_AX.js';
2
2
  export { sharedTailwindExtend, sharedTailwindPreset } from './tailwind.js';
3
3
 
4
4
  /**
@@ -92,6 +92,17 @@ type TSemanticSpacing = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
92
92
  type TSemanticRadius = TSharedRadius;
93
93
  type TSemanticIntent = 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'neutral';
94
94
  type TSemanticState = 'disabled' | 'loading' | 'invalid' | 'required';
95
+ /**
96
+ * Cross-platform colour + variant authored in the CMS (`shared_color` /
97
+ * `shared_variant`). These are stored as Mantine palette / variant *values* —
98
+ * the catalog keeps them verbatim (migration `Version20260618143216` renamed the
99
+ * legacy `mantine_*` fields to `shared_*` without touching the values). They are
100
+ * the REAL cross-platform appearance fields (there is no `shared_intent` in the
101
+ * live catalog); the mapper maps them onto HeroUI Native for mobile, while the
102
+ * web renderer feeds them straight into Mantine.
103
+ */
104
+ type TSemanticColor = TMantineColor;
105
+ type TSemanticVariant = TMantineVariant;
95
106
  /** Pixel value used for a fully-rounded ("pill") radius on both platforms. */
96
107
  declare const FULL_RADIUS_PX = 9999;
97
108
  /**
@@ -103,6 +114,15 @@ interface ISharedStyleProps {
103
114
  size?: TSemanticSize;
104
115
  spacing?: TSemanticSpacing;
105
116
  radius?: TSemanticRadius;
117
+ /** Mantine palette colour authored via `shared_color` (cross-platform). */
118
+ color?: TSemanticColor;
119
+ /** Mantine variant authored via `shared_variant` (cross-platform). */
120
+ variant?: TSemanticVariant;
121
+ /**
122
+ * Legacy semantic intent. Kept for back-compat; `shared_intent` is NOT in the
123
+ * live catalog, so real CMS sections drive appearance through `color` /
124
+ * `variant` above. Used as the final fallback in the platform resolvers.
125
+ */
106
126
  intent?: TSemanticIntent;
107
127
  /** Active boolean states. Stored as a small set so multiple can apply. */
108
128
  states?: readonly TSemanticState[];
@@ -211,6 +231,33 @@ declare function mapIntentToHeroUiButtonVariant(intent: TSemanticIntent | undefi
211
231
  * neutral -> default
212
232
  */
213
233
  declare function mapIntentToHeroUiColor(intent: TSemanticIntent | undefined): THeroUiColor | undefined;
234
+ /**
235
+ * Map a Mantine palette colour (`shared_color`) onto a HeroUI Native semantic
236
+ * colour (Chip / Tag / status surfaces). The Mantine palette is broad; it
237
+ * collapses onto HeroUI's five semantic colours by hue family:
238
+ * red/pink -> danger
239
+ * green/teal/lime -> success
240
+ * yellow/orange -> warning
241
+ * gray/dark -> default
242
+ * blue/cyan/indigo/… -> accent (the brand/primary hue)
243
+ */
244
+ declare function mapMantineColorToHeroUiColor(color: TSemanticColor | undefined): THeroUiColor | undefined;
245
+ /**
246
+ * Map a Mantine palette colour (`shared_color`) onto a HeroUI Native **Button**
247
+ * variant when no explicit `shared_variant` is authored. HeroUI buttons encode
248
+ * colour in the variant, so the destructive hue becomes `danger`, neutral hues
249
+ * become `secondary`, and everything else stays the prominent `primary`.
250
+ */
251
+ declare function mapMantineColorToHeroUiButtonVariant(color: TSemanticColor | undefined): THeroUiButtonVariant | undefined;
252
+ /**
253
+ * Map a Mantine variant (`shared_variant`) onto the HeroUI Native Button
254
+ * vocabulary:
255
+ * filled / gradient -> primary
256
+ * light / white / default -> secondary
257
+ * outline -> outline
258
+ * subtle / transparent -> ghost
259
+ */
260
+ declare function mapMantineVariantToHeroUiButtonVariant(variant: TSemanticVariant | undefined): THeroUiButtonVariant | undefined;
214
261
  /**
215
262
  * Read the `shared_*` CMS fields of a section into {@link ISharedStyleProps}.
216
263
  *
@@ -222,7 +269,16 @@ declare function mapIntentToHeroUiColor(intent: TSemanticIntent | undefined): TH
222
269
  declare function resolveSharedStyleProps(fields: Record<string, unknown>): ISharedStyleProps;
223
270
  /** Resolve shared props into Mantine (web) props. */
224
271
  declare function toMantineSemanticProps(props: ISharedStyleProps): IMantineResolvedStyle;
225
- /** Resolve shared props into HeroUI Native (mobile) props. */
272
+ /**
273
+ * Resolve shared props into HeroUI Native (mobile) props.
274
+ *
275
+ * Appearance precedence (mirrors the web renderer, which reads the same CMS
276
+ * fields straight into Mantine):
277
+ * 1. `shared_variant` (Mantine variant) mapped onto the HeroUI button vocab;
278
+ * 2. else `shared_color` (Mantine palette) mapped onto a button variant;
279
+ * 3. else the legacy `intent` mapping (back-compat fallback).
280
+ * The semantic `color` is resolved from `shared_color` first, then `intent`.
281
+ */
226
282
  declare function toHeroUiSemanticProps(props: ISharedStyleProps): IHeroUiResolvedStyle;
227
283
  /**
228
284
  * Resolve shared props into a plain React Native style object (for styles with
@@ -282,4 +338,4 @@ interface IResolvedVariant {
282
338
  }
283
339
  declare function resolveMantineVariant(variant: string | undefined, color: string | undefined): IResolvedVariant;
284
340
 
285
- export { COLOR_PALETTE, COLOR_SCALES, CONTAINER_SIZE_PX, FONT_SIZE_PX, FULL_RADIUS_PX, type IHeroUiResolvedStyle, type IMantineResolvedStyle, type IReactNativeResolvedStyle, type IReactNativeThemeScales, type IResolvedVariant, type ISharedStyleProps, type ISpacingResolved, LINE_HEIGHT, RADIUS_PX, SPACING_PX, SPACING_TO_TAILWIND, type TCanonicalColor, type TCanonicalRadius, type TCanonicalSpacing, type THeroUiButtonVariant, type THeroUiColor, type THeroUiSize, type TMantineMappedColor, type TMantineMappedVariant, type TSemanticIntent, type TSemanticRadius, type TSemanticSize, type TSemanticSpacing, type TSemanticState, colorToHex, mapIntentToHeroUiButtonVariant, mapIntentToHeroUiColor, mapIntentToMantine, mapRadiusToMantine, mapRadiusToPx, mapSizeToHeroUi, mapSizeToMantine, mapSpacingToPx, radiusToPx, resolveMantineVariant, resolveSharedStyle, resolveSharedStyleForMobile, resolveSharedStyleForWeb, resolveSharedStyleProps, sizeToFontPx, spacingToPx, toHeroUiSemanticProps, toMantineSemanticProps, toReactNativeSemanticStyle };
341
+ export { COLOR_PALETTE, COLOR_SCALES, CONTAINER_SIZE_PX, FONT_SIZE_PX, FULL_RADIUS_PX, type IHeroUiResolvedStyle, type IMantineResolvedStyle, type IReactNativeResolvedStyle, type IReactNativeThemeScales, type IResolvedVariant, type ISharedStyleProps, type ISpacingResolved, LINE_HEIGHT, RADIUS_PX, SPACING_PX, SPACING_TO_TAILWIND, type TCanonicalColor, type TCanonicalRadius, type TCanonicalSpacing, type THeroUiButtonVariant, type THeroUiColor, type THeroUiSize, type TMantineMappedColor, type TMantineMappedVariant, type TSemanticColor, type TSemanticIntent, type TSemanticRadius, type TSemanticSize, type TSemanticSpacing, type TSemanticState, type TSemanticVariant, colorToHex, mapIntentToHeroUiButtonVariant, mapIntentToHeroUiColor, mapIntentToMantine, mapMantineColorToHeroUiButtonVariant, mapMantineColorToHeroUiColor, mapMantineVariantToHeroUiButtonVariant, mapRadiusToMantine, mapRadiusToPx, mapSizeToHeroUi, mapSizeToMantine, mapSpacingToPx, radiusToPx, resolveMantineVariant, resolveSharedStyle, resolveSharedStyleForMobile, resolveSharedStyleForWeb, resolveSharedStyleProps, sizeToFontPx, spacingToPx, toHeroUiSemanticProps, toMantineSemanticProps, toReactNativeSemanticStyle };
@@ -33,6 +33,9 @@ __export(theme_exports, {
33
33
  mapIntentToHeroUiButtonVariant: () => mapIntentToHeroUiButtonVariant,
34
34
  mapIntentToHeroUiColor: () => mapIntentToHeroUiColor,
35
35
  mapIntentToMantine: () => mapIntentToMantine,
36
+ mapMantineColorToHeroUiButtonVariant: () => mapMantineColorToHeroUiButtonVariant,
37
+ mapMantineColorToHeroUiColor: () => mapMantineColorToHeroUiColor,
38
+ mapMantineVariantToHeroUiButtonVariant: () => mapMantineVariantToHeroUiButtonVariant,
36
39
  mapRadiusToMantine: () => mapRadiusToMantine,
37
40
  mapRadiusToPx: () => mapRadiusToPx,
38
41
  mapSizeToHeroUi: () => mapSizeToHeroUi,
@@ -325,6 +328,58 @@ function mapIntentToHeroUiColor(intent) {
325
328
  return void 0;
326
329
  }
327
330
  }
331
+ function mapMantineColorToHeroUiColor(color) {
332
+ if (!color) return void 0;
333
+ switch (color) {
334
+ case "red":
335
+ case "pink":
336
+ return "danger";
337
+ case "green":
338
+ case "teal":
339
+ case "lime":
340
+ return "success";
341
+ case "yellow":
342
+ case "orange":
343
+ return "warning";
344
+ case "gray":
345
+ case "dark":
346
+ return "default";
347
+ default:
348
+ return "accent";
349
+ }
350
+ }
351
+ function mapMantineColorToHeroUiButtonVariant(color) {
352
+ if (!color) return void 0;
353
+ switch (color) {
354
+ case "red":
355
+ case "pink":
356
+ return "danger";
357
+ case "gray":
358
+ case "dark":
359
+ return "secondary";
360
+ default:
361
+ return "primary";
362
+ }
363
+ }
364
+ function mapMantineVariantToHeroUiButtonVariant(variant) {
365
+ if (!variant) return void 0;
366
+ switch (variant) {
367
+ case "filled":
368
+ case "gradient":
369
+ return "primary";
370
+ case "light":
371
+ case "white":
372
+ case "default":
373
+ return "secondary";
374
+ case "outline":
375
+ return "outline";
376
+ case "subtle":
377
+ case "transparent":
378
+ return "ghost";
379
+ default:
380
+ return void 0;
381
+ }
382
+ }
328
383
  function hasState(states, state) {
329
384
  return !!states && states.includes(state);
330
385
  }
@@ -348,6 +403,14 @@ function resolveSharedStyleProps(fields) {
348
403
  if (radius !== void 0 && SEMANTIC_RADII.includes(radius)) {
349
404
  resolved.radius = radius;
350
405
  }
406
+ const color = readString(fields.shared_color);
407
+ if (color !== void 0) {
408
+ resolved.color = color;
409
+ }
410
+ const variant = readString(fields.shared_variant);
411
+ if (variant !== void 0) {
412
+ resolved.variant = variant;
413
+ }
351
414
  const intent = readString(fields.shared_intent);
352
415
  if (intent !== void 0 && SEMANTIC_INTENTS.includes(intent)) {
353
416
  resolved.intent = intent;
@@ -375,10 +438,12 @@ function toMantineSemanticProps(props) {
375
438
  };
376
439
  }
377
440
  function toHeroUiSemanticProps(props) {
441
+ const buttonVariant = mapMantineVariantToHeroUiButtonVariant(props.variant) ?? mapMantineColorToHeroUiButtonVariant(props.color) ?? mapIntentToHeroUiButtonVariant(props.intent);
442
+ const color = mapMantineColorToHeroUiColor(props.color) ?? mapIntentToHeroUiColor(props.intent);
378
443
  return {
379
444
  size: mapSizeToHeroUi(props.size),
380
- buttonVariant: mapIntentToHeroUiButtonVariant(props.intent),
381
- color: mapIntentToHeroUiColor(props.intent),
445
+ buttonVariant,
446
+ color,
382
447
  radiusPx: mapRadiusToPx(props.radius),
383
448
  spacingPx: mapSpacingToPx(props.spacing),
384
449
  isDisabled: hasState(props.states, "disabled") || void 0,
@@ -515,6 +580,9 @@ function resolveMantineVariant(variant, color) {
515
580
  mapIntentToHeroUiButtonVariant,
516
581
  mapIntentToHeroUiColor,
517
582
  mapIntentToMantine,
583
+ mapMantineColorToHeroUiButtonVariant,
584
+ mapMantineColorToHeroUiColor,
585
+ mapMantineVariantToHeroUiButtonVariant,
518
586
  mapRadiusToMantine,
519
587
  mapRadiusToPx,
520
588
  mapSizeToHeroUi,
@@ -269,6 +269,58 @@ function mapIntentToHeroUiColor(intent) {
269
269
  return void 0;
270
270
  }
271
271
  }
272
+ function mapMantineColorToHeroUiColor(color) {
273
+ if (!color) return void 0;
274
+ switch (color) {
275
+ case "red":
276
+ case "pink":
277
+ return "danger";
278
+ case "green":
279
+ case "teal":
280
+ case "lime":
281
+ return "success";
282
+ case "yellow":
283
+ case "orange":
284
+ return "warning";
285
+ case "gray":
286
+ case "dark":
287
+ return "default";
288
+ default:
289
+ return "accent";
290
+ }
291
+ }
292
+ function mapMantineColorToHeroUiButtonVariant(color) {
293
+ if (!color) return void 0;
294
+ switch (color) {
295
+ case "red":
296
+ case "pink":
297
+ return "danger";
298
+ case "gray":
299
+ case "dark":
300
+ return "secondary";
301
+ default:
302
+ return "primary";
303
+ }
304
+ }
305
+ function mapMantineVariantToHeroUiButtonVariant(variant) {
306
+ if (!variant) return void 0;
307
+ switch (variant) {
308
+ case "filled":
309
+ case "gradient":
310
+ return "primary";
311
+ case "light":
312
+ case "white":
313
+ case "default":
314
+ return "secondary";
315
+ case "outline":
316
+ return "outline";
317
+ case "subtle":
318
+ case "transparent":
319
+ return "ghost";
320
+ default:
321
+ return void 0;
322
+ }
323
+ }
272
324
  function hasState(states, state) {
273
325
  return !!states && states.includes(state);
274
326
  }
@@ -292,6 +344,14 @@ function resolveSharedStyleProps(fields) {
292
344
  if (radius !== void 0 && SEMANTIC_RADII.includes(radius)) {
293
345
  resolved.radius = radius;
294
346
  }
347
+ const color = readString(fields.shared_color);
348
+ if (color !== void 0) {
349
+ resolved.color = color;
350
+ }
351
+ const variant = readString(fields.shared_variant);
352
+ if (variant !== void 0) {
353
+ resolved.variant = variant;
354
+ }
295
355
  const intent = readString(fields.shared_intent);
296
356
  if (intent !== void 0 && SEMANTIC_INTENTS.includes(intent)) {
297
357
  resolved.intent = intent;
@@ -319,10 +379,12 @@ function toMantineSemanticProps(props) {
319
379
  };
320
380
  }
321
381
  function toHeroUiSemanticProps(props) {
382
+ const buttonVariant = mapMantineVariantToHeroUiButtonVariant(props.variant) ?? mapMantineColorToHeroUiButtonVariant(props.color) ?? mapIntentToHeroUiButtonVariant(props.intent);
383
+ const color = mapMantineColorToHeroUiColor(props.color) ?? mapIntentToHeroUiColor(props.intent);
322
384
  return {
323
385
  size: mapSizeToHeroUi(props.size),
324
- buttonVariant: mapIntentToHeroUiButtonVariant(props.intent),
325
- color: mapIntentToHeroUiColor(props.intent),
386
+ buttonVariant,
387
+ color,
326
388
  radiusPx: mapRadiusToPx(props.radius),
327
389
  spacingPx: mapSpacingToPx(props.spacing),
328
390
  isDisabled: hasState(props.states, "disabled") || void 0,
@@ -458,6 +520,9 @@ export {
458
520
  mapIntentToHeroUiButtonVariant,
459
521
  mapIntentToHeroUiColor,
460
522
  mapIntentToMantine,
523
+ mapMantineColorToHeroUiButtonVariant,
524
+ mapMantineColorToHeroUiColor,
525
+ mapMantineVariantToHeroUiButtonVariant,
461
526
  mapRadiusToMantine,
462
527
  mapRadiusToPx,
463
528
  mapSizeToHeroUi,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@selfhelp/shared",
3
- "version": "1.14.4",
3
+ "version": "1.14.6",
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",
@@ -8,6 +8,9 @@ import {
8
8
  mapIntentToHeroUiButtonVariant,
9
9
  mapIntentToHeroUiColor,
10
10
  mapIntentToMantine,
11
+ mapMantineColorToHeroUiButtonVariant,
12
+ mapMantineColorToHeroUiColor,
13
+ mapMantineVariantToHeroUiButtonVariant,
11
14
  mapRadiusToMantine,
12
15
  mapRadiusToPx,
13
16
  mapSizeToHeroUi,
@@ -136,6 +139,73 @@ describe('semantic style mapper', () => {
136
139
  expect(resolveSharedStyleProps({ shared_full_width: true }).fullWidth).toBe(true);
137
140
  expect(resolveSharedStyleProps({}).fullWidth).toBeUndefined();
138
141
  });
142
+
143
+ it('reads shared_color and shared_variant (the REAL cross-platform fields)', () => {
144
+ const resolved = resolveSharedStyleProps({ shared_color: 'red', shared_variant: 'light' });
145
+ expect(resolved.color).toBe('red');
146
+ expect(resolved.variant).toBe('light');
147
+ });
148
+
149
+ it('treats an empty shared_color / shared_variant as absent', () => {
150
+ const resolved = resolveSharedStyleProps({ shared_color: '', shared_variant: '' });
151
+ expect(resolved.color).toBeUndefined();
152
+ expect(resolved.variant).toBeUndefined();
153
+ });
154
+ });
155
+
156
+ describe('Mantine colour/variant -> HeroUI Native (real shared_color/shared_variant)', () => {
157
+ it('maps a Mantine palette colour to a HeroUI semantic colour', () => {
158
+ expect(mapMantineColorToHeroUiColor('red')).toBe('danger');
159
+ expect(mapMantineColorToHeroUiColor('green')).toBe('success');
160
+ expect(mapMantineColorToHeroUiColor('yellow')).toBe('warning');
161
+ expect(mapMantineColorToHeroUiColor('gray')).toBe('default');
162
+ expect(mapMantineColorToHeroUiColor('blue')).toBe('accent');
163
+ expect(mapMantineColorToHeroUiColor('grape')).toBe('accent');
164
+ expect(mapMantineColorToHeroUiColor(undefined)).toBeUndefined();
165
+ });
166
+
167
+ it('maps a Mantine variant to a HeroUI button variant', () => {
168
+ expect(mapMantineVariantToHeroUiButtonVariant('filled')).toBe('primary');
169
+ expect(mapMantineVariantToHeroUiButtonVariant('light')).toBe('secondary');
170
+ expect(mapMantineVariantToHeroUiButtonVariant('outline')).toBe('outline');
171
+ expect(mapMantineVariantToHeroUiButtonVariant('subtle')).toBe('ghost');
172
+ expect(mapMantineVariantToHeroUiButtonVariant('transparent')).toBe('ghost');
173
+ });
174
+
175
+ it('derives a button variant from the colour when no variant is set', () => {
176
+ expect(mapMantineColorToHeroUiButtonVariant('red')).toBe('danger');
177
+ expect(mapMantineColorToHeroUiButtonVariant('gray')).toBe('secondary');
178
+ expect(mapMantineColorToHeroUiButtonVariant('blue')).toBe('primary');
179
+ });
180
+
181
+ it('toHeroUiSemanticProps prefers shared_variant, then shared_color, then intent', () => {
182
+ expect(
183
+ toHeroUiSemanticProps({ variant: 'outline', color: 'red', intent: 'primary' }).buttonVariant,
184
+ ).toBe('outline');
185
+ expect(toHeroUiSemanticProps({ color: 'red' })).toMatchObject({
186
+ buttonVariant: 'danger',
187
+ color: 'danger',
188
+ });
189
+ expect(toHeroUiSemanticProps({ intent: 'success' })).toMatchObject({
190
+ buttonVariant: 'primary',
191
+ color: 'success',
192
+ });
193
+ });
194
+
195
+ it('resolves a real CMS button section (shared_color + shared_variant + shared_size)', () => {
196
+ const props = resolveSharedStyleProps({
197
+ shared_color: 'red',
198
+ shared_variant: 'filled',
199
+ shared_size: 'lg',
200
+ shared_radius: 'md',
201
+ });
202
+ expect(toHeroUiSemanticProps(props)).toMatchObject({
203
+ size: 'lg',
204
+ buttonVariant: 'primary', // filled -> primary
205
+ color: 'danger', // red -> danger
206
+ radiusPx: RADIUS_PX.md,
207
+ });
208
+ });
139
209
  });
140
210
 
141
211
  describe('platform resolvers', () => {