@selfhelp/shared 1.14.20 → 1.14.23
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 +72 -0
- package/dist/{common-DMm4kymA.d.mts → common-udJ0O8qC.d.mts} +1 -1
- package/dist/{common-DMm4kymA.d.ts → common-udJ0O8qC.d.ts} +1 -1
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +6 -6
- package/dist/index.mjs +6 -6
- package/dist/plugin-sdk/index.d.mts +2 -2
- package/dist/plugin-sdk/index.d.ts +2 -2
- package/dist/plugin-sdk/index.js +1 -1
- package/dist/plugin-sdk/index.mjs +1 -1
- package/dist/registry/index.d.mts +3 -3
- package/dist/registry/index.d.ts +3 -3
- package/dist/registry/index.js +1 -1
- package/dist/registry/index.mjs +1 -1
- package/dist/{styles.registry-B8IaEULk.d.ts → styles.registry-CZZwODJY.d.mts} +194 -178
- package/dist/{styles.registry-DhkxrV2-.d.mts → styles.registry-DQKcvIBZ.d.ts} +194 -178
- package/dist/theme/index.d.mts +20 -20
- package/dist/theme/index.d.ts +20 -20
- package/dist/theme/index.js +5 -5
- package/dist/theme/index.mjs +5 -5
- package/dist/theme/tailwind.d.mts +2 -2
- package/dist/theme/tailwind.d.ts +2 -2
- package/package.json +1 -1
- package/src/registry/styles.registry.ts +1 -1
- package/src/theme/__tests__/semantic.test.ts +19 -19
- package/src/theme/mantineVariant.ts +1 -1
- package/src/theme/semantic.ts +24 -24
- package/src/theme/tailwind.ts +2 -2
- package/src/theme/tokens.ts +1 -1
- package/src/types/__tests__/mobile-adapters.test.ts +1 -1
- package/src/types/mantine/common.ts +1 -1
- package/src/types/mobile-adapters.ts +4 -4
- package/src/types/styles/auth.ts +10 -10
- package/src/types/styles/base.ts +2 -2
- package/src/types/styles/composite.ts +7 -7
- package/src/types/styles/error.ts +9 -9
- package/src/types/styles/forms.ts +74 -58
- package/src/types/styles/interactive.ts +34 -32
- package/src/types/styles/layout.ts +42 -42
- package/src/types/styles/media.ts +6 -6
- package/src/types/styles/typography.ts +13 -13
- package/src/utils/spacing.ts +1 -1
package/dist/theme/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { m as TMantineSize, b as TSharedSize, k as TSharedRadius, T as TMantineColor, p as TMantineVariant } from '../common-
|
|
1
|
+
import { m as TMantineSize, b as TSharedSize, k as TSharedRadius, T as TMantineColor, p as TMantineVariant } from '../common-udJ0O8qC.mjs';
|
|
2
2
|
export { sharedTailwindExtend, sharedTailwindPreset } from './tailwind.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Mantine semantic token tables. Both the web Mantine theme and the
|
|
6
|
-
* mobile HeroUI Native theme extend these so a `
|
|
6
|
+
* mobile HeroUI Native theme extend these so a `size: 'md'` on a
|
|
7
7
|
* section renders identical sizing regardless of platform.
|
|
8
8
|
*
|
|
9
9
|
* Pixel values come straight from Mantine v9 defaults:
|
|
@@ -71,7 +71,7 @@ declare function colorToHex(name: string | undefined, shade?: number): string |
|
|
|
71
71
|
*
|
|
72
72
|
* Design rules (mobile rendering plan, section 8.2):
|
|
73
73
|
* - NO value clamping. The shared scales are the true common denominator
|
|
74
|
-
* (`
|
|
74
|
+
* (`size` = sm|md|lg, `radius` = none|sm|md|lg|full), so every
|
|
75
75
|
* value maps 1:1 to each platform. The backend enforces the same domain
|
|
76
76
|
* (migration `Version20260618195450`).
|
|
77
77
|
* - NO implicit cross-platform fallback. These functions take already-resolved
|
|
@@ -93,8 +93,8 @@ type TSemanticRadius = TSharedRadius;
|
|
|
93
93
|
type TSemanticIntent = 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'neutral';
|
|
94
94
|
type TSemanticState = 'disabled' | 'loading' | 'invalid' | 'required';
|
|
95
95
|
/**
|
|
96
|
-
* Cross-platform colour + variant authored in the CMS (`
|
|
97
|
-
* `
|
|
96
|
+
* Cross-platform colour + variant authored in the CMS (`color` /
|
|
97
|
+
* `variant`). These are stored as Mantine palette / variant *values* —
|
|
98
98
|
* the catalog keeps them verbatim (migration `Version20260618143216` renamed the
|
|
99
99
|
* legacy `mantine_*` fields to `shared_*` without touching the values). They are
|
|
100
100
|
* the REAL cross-platform appearance fields (there is no `shared_intent` in the
|
|
@@ -114,9 +114,9 @@ interface ISharedStyleProps {
|
|
|
114
114
|
size?: TSemanticSize;
|
|
115
115
|
spacing?: TSemanticSpacing;
|
|
116
116
|
radius?: TSemanticRadius;
|
|
117
|
-
/** Mantine palette colour authored via `
|
|
117
|
+
/** Mantine palette colour authored via `color` (cross-platform). */
|
|
118
118
|
color?: TSemanticColor;
|
|
119
|
-
/** Mantine variant authored via `
|
|
119
|
+
/** Mantine variant authored via `variant` (cross-platform). */
|
|
120
120
|
variant?: TSemanticVariant;
|
|
121
121
|
/**
|
|
122
122
|
* Legacy semantic intent. Kept for back-compat; `shared_intent` is NOT in the
|
|
@@ -232,7 +232,7 @@ declare function mapIntentToHeroUiButtonVariant(intent: TSemanticIntent | undefi
|
|
|
232
232
|
*/
|
|
233
233
|
declare function mapIntentToHeroUiColor(intent: TSemanticIntent | undefined): THeroUiColor | undefined;
|
|
234
234
|
/**
|
|
235
|
-
* Map a Mantine palette colour (`
|
|
235
|
+
* Map a Mantine palette colour (`color`) onto a HeroUI Native semantic
|
|
236
236
|
* colour (Chip / Tag / status surfaces). The Mantine palette is broad; it
|
|
237
237
|
* collapses onto HeroUI's five semantic colours by hue family:
|
|
238
238
|
* red/pink -> danger
|
|
@@ -243,14 +243,14 @@ declare function mapIntentToHeroUiColor(intent: TSemanticIntent | undefined): TH
|
|
|
243
243
|
*/
|
|
244
244
|
declare function mapMantineColorToHeroUiColor(color: TSemanticColor | undefined): THeroUiColor | undefined;
|
|
245
245
|
/**
|
|
246
|
-
* Map a Mantine palette colour (`
|
|
247
|
-
* variant when no explicit `
|
|
246
|
+
* Map a Mantine palette colour (`color`) onto a HeroUI Native **Button**
|
|
247
|
+
* variant when no explicit `variant` is authored. HeroUI buttons encode
|
|
248
248
|
* colour in the variant, so the destructive hue becomes `danger`, neutral hues
|
|
249
249
|
* become `secondary`, and everything else stays the prominent `primary`.
|
|
250
250
|
*/
|
|
251
251
|
declare function mapMantineColorToHeroUiButtonVariant(color: TSemanticColor | undefined): THeroUiButtonVariant | undefined;
|
|
252
252
|
/**
|
|
253
|
-
* Map a Mantine variant (`
|
|
253
|
+
* Map a Mantine variant (`variant`) onto the HeroUI Native Button
|
|
254
254
|
* vocabulary:
|
|
255
255
|
* filled / gradient -> primary
|
|
256
256
|
* light / white / default -> secondary
|
|
@@ -259,14 +259,14 @@ declare function mapMantineColorToHeroUiButtonVariant(color: TSemanticColor | un
|
|
|
259
259
|
*/
|
|
260
260
|
declare function mapMantineVariantToHeroUiButtonVariant(variant: TSemanticVariant | undefined): THeroUiButtonVariant | undefined;
|
|
261
261
|
/**
|
|
262
|
-
* Map the accordion variant token (`
|
|
262
|
+
* Map the accordion variant token (`accordion_variant`: Mantine
|
|
263
263
|
* default/contained/filled/separated) onto the HeroUI Native Accordion `variant`
|
|
264
264
|
* vocabulary. HeroUI Native only has `default` (plain list) and `surface`
|
|
265
265
|
* (grouped container), so every "boxed" Mantine variant collapses to `surface`.
|
|
266
266
|
*/
|
|
267
267
|
declare function mapAccordionVariantToHeroUiVariant(variant: string | undefined): 'default' | 'surface';
|
|
268
268
|
/**
|
|
269
|
-
* Map the chip variant token (`
|
|
269
|
+
* Map the chip variant token (`chip_variant`: Mantine
|
|
270
270
|
* filled/outline/light) onto the HeroUI Native Chip `variant` vocabulary
|
|
271
271
|
* (`primary`/`secondary`/`tertiary`/`soft`):
|
|
272
272
|
* - filled -> primary (solid accent fill)
|
|
@@ -277,8 +277,8 @@ declare function mapChipVariantToHeroUiVariant(variant: string | undefined): 'pr
|
|
|
277
277
|
/** A React Native-safe dimension: a px number, a percentage string, or "auto". */
|
|
278
278
|
type TReactNativeDimension = number | `${number}%` | 'auto';
|
|
279
279
|
/**
|
|
280
|
-
* Parse a CMS dimension string (`shared_width`/`shared_height`/`
|
|
281
|
-
* `
|
|
280
|
+
* Parse a CMS dimension string (`shared_width`/`shared_height`/`mih`/`miw`/
|
|
281
|
+
* `mah`/`maw`) into a React Native-safe value. Web (Mantine) accepts the raw
|
|
282
282
|
* string verbatim ("320px", "100%", "auto"); React Native does NOT accept a
|
|
283
283
|
* unit suffix, so a px value must become a unitless number:
|
|
284
284
|
* "320px" | "320" | 320 -> 320 (number)
|
|
@@ -309,7 +309,7 @@ interface IReactNativeGridColumn {
|
|
|
309
309
|
*/
|
|
310
310
|
declare function gridSpanToReactNativeColumn(span: string | number | undefined | null, cols?: number): IReactNativeGridColumn;
|
|
311
311
|
/**
|
|
312
|
-
* Map a `
|
|
312
|
+
* Map a `divider_variant` (solid/dashed/dotted) onto a React Native
|
|
313
313
|
* `borderStyle`. The vocabularies are identical, so this validates the domain
|
|
314
314
|
* and falls back to 'solid'.
|
|
315
315
|
*/
|
|
@@ -330,10 +330,10 @@ declare function toMantineSemanticProps(props: ISharedStyleProps): IMantineResol
|
|
|
330
330
|
*
|
|
331
331
|
* Appearance precedence (mirrors the web renderer, which reads the same CMS
|
|
332
332
|
* fields straight into Mantine):
|
|
333
|
-
* 1. `
|
|
334
|
-
* 2. else `
|
|
333
|
+
* 1. `variant` (Mantine variant) mapped onto the HeroUI button vocab;
|
|
334
|
+
* 2. else `color` (Mantine palette) mapped onto a button variant;
|
|
335
335
|
* 3. else the legacy `intent` mapping (back-compat fallback).
|
|
336
|
-
* The semantic `color` is resolved from `
|
|
336
|
+
* The semantic `color` is resolved from `color` first, then `intent`.
|
|
337
337
|
*/
|
|
338
338
|
declare function toHeroUiSemanticProps(props: ISharedStyleProps): IHeroUiResolvedStyle;
|
|
339
339
|
/**
|
|
@@ -366,7 +366,7 @@ declare const resolveSharedStyleForMobile: typeof toHeroUiSemanticProps;
|
|
|
366
366
|
* - `semantic.ts` maps renderer-agnostic shared fields
|
|
367
367
|
* (`intent` / `size` / `radius` / `spacing`) per platform.
|
|
368
368
|
* - `mantineVariant.ts` resolves a Mantine palette `color` + `variant` value
|
|
369
|
-
* pair (e.g. the semantic `
|
|
369
|
+
* pair (e.g. the semantic `color` + `web_variant`)
|
|
370
370
|
* into concrete RGB. Its only runtime
|
|
371
371
|
* consumer today is the mobile **Expo Web preview**
|
|
372
372
|
* fallback (where `heroui-native` cannot render and the
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { m as TMantineSize, b as TSharedSize, k as TSharedRadius, T as TMantineColor, p as TMantineVariant } from '../common-
|
|
1
|
+
import { m as TMantineSize, b as TSharedSize, k as TSharedRadius, T as TMantineColor, p as TMantineVariant } from '../common-udJ0O8qC.js';
|
|
2
2
|
export { sharedTailwindExtend, sharedTailwindPreset } from './tailwind.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Mantine semantic token tables. Both the web Mantine theme and the
|
|
6
|
-
* mobile HeroUI Native theme extend these so a `
|
|
6
|
+
* mobile HeroUI Native theme extend these so a `size: 'md'` on a
|
|
7
7
|
* section renders identical sizing regardless of platform.
|
|
8
8
|
*
|
|
9
9
|
* Pixel values come straight from Mantine v9 defaults:
|
|
@@ -71,7 +71,7 @@ declare function colorToHex(name: string | undefined, shade?: number): string |
|
|
|
71
71
|
*
|
|
72
72
|
* Design rules (mobile rendering plan, section 8.2):
|
|
73
73
|
* - NO value clamping. The shared scales are the true common denominator
|
|
74
|
-
* (`
|
|
74
|
+
* (`size` = sm|md|lg, `radius` = none|sm|md|lg|full), so every
|
|
75
75
|
* value maps 1:1 to each platform. The backend enforces the same domain
|
|
76
76
|
* (migration `Version20260618195450`).
|
|
77
77
|
* - NO implicit cross-platform fallback. These functions take already-resolved
|
|
@@ -93,8 +93,8 @@ type TSemanticRadius = TSharedRadius;
|
|
|
93
93
|
type TSemanticIntent = 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'neutral';
|
|
94
94
|
type TSemanticState = 'disabled' | 'loading' | 'invalid' | 'required';
|
|
95
95
|
/**
|
|
96
|
-
* Cross-platform colour + variant authored in the CMS (`
|
|
97
|
-
* `
|
|
96
|
+
* Cross-platform colour + variant authored in the CMS (`color` /
|
|
97
|
+
* `variant`). These are stored as Mantine palette / variant *values* —
|
|
98
98
|
* the catalog keeps them verbatim (migration `Version20260618143216` renamed the
|
|
99
99
|
* legacy `mantine_*` fields to `shared_*` without touching the values). They are
|
|
100
100
|
* the REAL cross-platform appearance fields (there is no `shared_intent` in the
|
|
@@ -114,9 +114,9 @@ interface ISharedStyleProps {
|
|
|
114
114
|
size?: TSemanticSize;
|
|
115
115
|
spacing?: TSemanticSpacing;
|
|
116
116
|
radius?: TSemanticRadius;
|
|
117
|
-
/** Mantine palette colour authored via `
|
|
117
|
+
/** Mantine palette colour authored via `color` (cross-platform). */
|
|
118
118
|
color?: TSemanticColor;
|
|
119
|
-
/** Mantine variant authored via `
|
|
119
|
+
/** Mantine variant authored via `variant` (cross-platform). */
|
|
120
120
|
variant?: TSemanticVariant;
|
|
121
121
|
/**
|
|
122
122
|
* Legacy semantic intent. Kept for back-compat; `shared_intent` is NOT in the
|
|
@@ -232,7 +232,7 @@ declare function mapIntentToHeroUiButtonVariant(intent: TSemanticIntent | undefi
|
|
|
232
232
|
*/
|
|
233
233
|
declare function mapIntentToHeroUiColor(intent: TSemanticIntent | undefined): THeroUiColor | undefined;
|
|
234
234
|
/**
|
|
235
|
-
* Map a Mantine palette colour (`
|
|
235
|
+
* Map a Mantine palette colour (`color`) onto a HeroUI Native semantic
|
|
236
236
|
* colour (Chip / Tag / status surfaces). The Mantine palette is broad; it
|
|
237
237
|
* collapses onto HeroUI's five semantic colours by hue family:
|
|
238
238
|
* red/pink -> danger
|
|
@@ -243,14 +243,14 @@ declare function mapIntentToHeroUiColor(intent: TSemanticIntent | undefined): TH
|
|
|
243
243
|
*/
|
|
244
244
|
declare function mapMantineColorToHeroUiColor(color: TSemanticColor | undefined): THeroUiColor | undefined;
|
|
245
245
|
/**
|
|
246
|
-
* Map a Mantine palette colour (`
|
|
247
|
-
* variant when no explicit `
|
|
246
|
+
* Map a Mantine palette colour (`color`) onto a HeroUI Native **Button**
|
|
247
|
+
* variant when no explicit `variant` is authored. HeroUI buttons encode
|
|
248
248
|
* colour in the variant, so the destructive hue becomes `danger`, neutral hues
|
|
249
249
|
* become `secondary`, and everything else stays the prominent `primary`.
|
|
250
250
|
*/
|
|
251
251
|
declare function mapMantineColorToHeroUiButtonVariant(color: TSemanticColor | undefined): THeroUiButtonVariant | undefined;
|
|
252
252
|
/**
|
|
253
|
-
* Map a Mantine variant (`
|
|
253
|
+
* Map a Mantine variant (`variant`) onto the HeroUI Native Button
|
|
254
254
|
* vocabulary:
|
|
255
255
|
* filled / gradient -> primary
|
|
256
256
|
* light / white / default -> secondary
|
|
@@ -259,14 +259,14 @@ declare function mapMantineColorToHeroUiButtonVariant(color: TSemanticColor | un
|
|
|
259
259
|
*/
|
|
260
260
|
declare function mapMantineVariantToHeroUiButtonVariant(variant: TSemanticVariant | undefined): THeroUiButtonVariant | undefined;
|
|
261
261
|
/**
|
|
262
|
-
* Map the accordion variant token (`
|
|
262
|
+
* Map the accordion variant token (`accordion_variant`: Mantine
|
|
263
263
|
* default/contained/filled/separated) onto the HeroUI Native Accordion `variant`
|
|
264
264
|
* vocabulary. HeroUI Native only has `default` (plain list) and `surface`
|
|
265
265
|
* (grouped container), so every "boxed" Mantine variant collapses to `surface`.
|
|
266
266
|
*/
|
|
267
267
|
declare function mapAccordionVariantToHeroUiVariant(variant: string | undefined): 'default' | 'surface';
|
|
268
268
|
/**
|
|
269
|
-
* Map the chip variant token (`
|
|
269
|
+
* Map the chip variant token (`chip_variant`: Mantine
|
|
270
270
|
* filled/outline/light) onto the HeroUI Native Chip `variant` vocabulary
|
|
271
271
|
* (`primary`/`secondary`/`tertiary`/`soft`):
|
|
272
272
|
* - filled -> primary (solid accent fill)
|
|
@@ -277,8 +277,8 @@ declare function mapChipVariantToHeroUiVariant(variant: string | undefined): 'pr
|
|
|
277
277
|
/** A React Native-safe dimension: a px number, a percentage string, or "auto". */
|
|
278
278
|
type TReactNativeDimension = number | `${number}%` | 'auto';
|
|
279
279
|
/**
|
|
280
|
-
* Parse a CMS dimension string (`shared_width`/`shared_height`/`
|
|
281
|
-
* `
|
|
280
|
+
* Parse a CMS dimension string (`shared_width`/`shared_height`/`mih`/`miw`/
|
|
281
|
+
* `mah`/`maw`) into a React Native-safe value. Web (Mantine) accepts the raw
|
|
282
282
|
* string verbatim ("320px", "100%", "auto"); React Native does NOT accept a
|
|
283
283
|
* unit suffix, so a px value must become a unitless number:
|
|
284
284
|
* "320px" | "320" | 320 -> 320 (number)
|
|
@@ -309,7 +309,7 @@ interface IReactNativeGridColumn {
|
|
|
309
309
|
*/
|
|
310
310
|
declare function gridSpanToReactNativeColumn(span: string | number | undefined | null, cols?: number): IReactNativeGridColumn;
|
|
311
311
|
/**
|
|
312
|
-
* Map a `
|
|
312
|
+
* Map a `divider_variant` (solid/dashed/dotted) onto a React Native
|
|
313
313
|
* `borderStyle`. The vocabularies are identical, so this validates the domain
|
|
314
314
|
* and falls back to 'solid'.
|
|
315
315
|
*/
|
|
@@ -330,10 +330,10 @@ declare function toMantineSemanticProps(props: ISharedStyleProps): IMantineResol
|
|
|
330
330
|
*
|
|
331
331
|
* Appearance precedence (mirrors the web renderer, which reads the same CMS
|
|
332
332
|
* fields straight into Mantine):
|
|
333
|
-
* 1. `
|
|
334
|
-
* 2. else `
|
|
333
|
+
* 1. `variant` (Mantine variant) mapped onto the HeroUI button vocab;
|
|
334
|
+
* 2. else `color` (Mantine palette) mapped onto a button variant;
|
|
335
335
|
* 3. else the legacy `intent` mapping (back-compat fallback).
|
|
336
|
-
* The semantic `color` is resolved from `
|
|
336
|
+
* The semantic `color` is resolved from `color` first, then `intent`.
|
|
337
337
|
*/
|
|
338
338
|
declare function toHeroUiSemanticProps(props: ISharedStyleProps): IHeroUiResolvedStyle;
|
|
339
339
|
/**
|
|
@@ -366,7 +366,7 @@ declare const resolveSharedStyleForMobile: typeof toHeroUiSemanticProps;
|
|
|
366
366
|
* - `semantic.ts` maps renderer-agnostic shared fields
|
|
367
367
|
* (`intent` / `size` / `radius` / `spacing`) per platform.
|
|
368
368
|
* - `mantineVariant.ts` resolves a Mantine palette `color` + `variant` value
|
|
369
|
-
* pair (e.g. the semantic `
|
|
369
|
+
* pair (e.g. the semantic `color` + `web_variant`)
|
|
370
370
|
* into concrete RGB. Its only runtime
|
|
371
371
|
* consumer today is the mobile **Expo Web preview**
|
|
372
372
|
* fallback (where `heroui-native` cannot render and the
|
package/dist/theme/index.js
CHANGED
|
@@ -465,19 +465,19 @@ function readBool(value) {
|
|
|
465
465
|
}
|
|
466
466
|
function resolveSharedStyleProps(fields) {
|
|
467
467
|
const resolved = {};
|
|
468
|
-
const size = readString(fields.
|
|
468
|
+
const size = readString(fields.size);
|
|
469
469
|
if (size !== void 0 && SEMANTIC_SIZES.includes(size)) {
|
|
470
470
|
resolved.size = size;
|
|
471
471
|
}
|
|
472
|
-
const radius = readString(fields.
|
|
472
|
+
const radius = readString(fields.radius);
|
|
473
473
|
if (radius !== void 0 && SEMANTIC_RADII.includes(radius)) {
|
|
474
474
|
resolved.radius = radius;
|
|
475
475
|
}
|
|
476
|
-
const color = readString(fields.
|
|
476
|
+
const color = readString(fields.color);
|
|
477
477
|
if (color !== void 0) {
|
|
478
478
|
resolved.color = color;
|
|
479
479
|
}
|
|
480
|
-
const variant = readString(fields.
|
|
480
|
+
const variant = readString(fields.variant);
|
|
481
481
|
if (variant !== void 0) {
|
|
482
482
|
resolved.variant = variant;
|
|
483
483
|
}
|
|
@@ -485,7 +485,7 @@ function resolveSharedStyleProps(fields) {
|
|
|
485
485
|
if (intent !== void 0 && SEMANTIC_INTENTS.includes(intent)) {
|
|
486
486
|
resolved.intent = intent;
|
|
487
487
|
}
|
|
488
|
-
const fullWidth = readBool(fields.
|
|
488
|
+
const fullWidth = readBool(fields.full_width);
|
|
489
489
|
if (fullWidth !== void 0) {
|
|
490
490
|
resolved.fullWidth = fullWidth;
|
|
491
491
|
}
|
package/dist/theme/index.mjs
CHANGED
|
@@ -400,19 +400,19 @@ function readBool(value) {
|
|
|
400
400
|
}
|
|
401
401
|
function resolveSharedStyleProps(fields) {
|
|
402
402
|
const resolved = {};
|
|
403
|
-
const size = readString(fields.
|
|
403
|
+
const size = readString(fields.size);
|
|
404
404
|
if (size !== void 0 && SEMANTIC_SIZES.includes(size)) {
|
|
405
405
|
resolved.size = size;
|
|
406
406
|
}
|
|
407
|
-
const radius = readString(fields.
|
|
407
|
+
const radius = readString(fields.radius);
|
|
408
408
|
if (radius !== void 0 && SEMANTIC_RADII.includes(radius)) {
|
|
409
409
|
resolved.radius = radius;
|
|
410
410
|
}
|
|
411
|
-
const color = readString(fields.
|
|
411
|
+
const color = readString(fields.color);
|
|
412
412
|
if (color !== void 0) {
|
|
413
413
|
resolved.color = color;
|
|
414
414
|
}
|
|
415
|
-
const variant = readString(fields.
|
|
415
|
+
const variant = readString(fields.variant);
|
|
416
416
|
if (variant !== void 0) {
|
|
417
417
|
resolved.variant = variant;
|
|
418
418
|
}
|
|
@@ -420,7 +420,7 @@ function resolveSharedStyleProps(fields) {
|
|
|
420
420
|
if (intent !== void 0 && SEMANTIC_INTENTS.includes(intent)) {
|
|
421
421
|
resolved.intent = intent;
|
|
422
422
|
}
|
|
423
|
-
const fullWidth = readBool(fields.
|
|
423
|
+
const fullWidth = readBool(fields.full_width);
|
|
424
424
|
if (fullWidth !== void 0) {
|
|
425
425
|
resolved.fullWidth = fullWidth;
|
|
426
426
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared Tailwind preset extended by both the web frontend (Tailwind v4)
|
|
3
3
|
* and the mobile app (Uniwind v4 inside HeroUI Native). Anchors the same
|
|
4
|
-
* scale values that drive `
|
|
5
|
-
* `
|
|
4
|
+
* scale values that drive `size`, `radius`,
|
|
5
|
+
* `spacing`, and the color palette so a class like `p-md` or
|
|
6
6
|
* `text-blue-6` resolves identically on web and mobile.
|
|
7
7
|
*/
|
|
8
8
|
/**
|
package/dist/theme/tailwind.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared Tailwind preset extended by both the web frontend (Tailwind v4)
|
|
3
3
|
* and the mobile app (Uniwind v4 inside HeroUI Native). Anchors the same
|
|
4
|
-
* scale values that drive `
|
|
5
|
-
* `
|
|
4
|
+
* scale values that drive `size`, `radius`,
|
|
5
|
+
* `spacing`, and the color palette so a class like `p-md` or
|
|
6
6
|
* `text-blue-6` resolves identically on web and mobile.
|
|
7
7
|
*/
|
|
8
8
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@selfhelp/shared",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.23",
|
|
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",
|
|
@@ -191,7 +191,7 @@ export const BASE_STYLE_REGISTRY = {
|
|
|
191
191
|
input: { description: 'Plain HTML input', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
192
192
|
'text-input': { description: 'Mantine TextInput', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
193
193
|
textarea: { description: 'Mantine Textarea', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
194
|
-
'rich-text-editor': { description: 'Tiptap editor on web;
|
|
194
|
+
'rich-text-editor': { description: 'Tiptap editor on web; native inline-format toolbar editor on mobile', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
195
195
|
select: { description: 'HTML select / Mantine Select', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
196
196
|
radio: { description: 'Mantine Radio / RadioGroup', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
197
197
|
checkbox: { description: 'Mantine Checkbox', category: 'forms', frontendOnly: true, canHaveChildren: false },
|
|
@@ -119,10 +119,10 @@ describe('semantic style mapper', () => {
|
|
|
119
119
|
it('reads valid shared_* values', () => {
|
|
120
120
|
expect(
|
|
121
121
|
resolveSharedStyleProps({
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
size: 'lg',
|
|
123
|
+
radius: 'full',
|
|
124
124
|
shared_intent: 'danger',
|
|
125
|
-
|
|
125
|
+
full_width: '1',
|
|
126
126
|
}),
|
|
127
127
|
).toEqual({ size: 'lg', radius: 'full', intent: 'danger', fullWidth: true });
|
|
128
128
|
});
|
|
@@ -131,8 +131,8 @@ describe('semantic style mapper', () => {
|
|
|
131
131
|
// Stale Mantine values (xs/xl) are NOT mapped; the renderer falls
|
|
132
132
|
// through to its component default rather than silently clamping.
|
|
133
133
|
const resolved = resolveSharedStyleProps({
|
|
134
|
-
|
|
135
|
-
|
|
134
|
+
size: 'xl',
|
|
135
|
+
radius: 'xs',
|
|
136
136
|
shared_intent: 'bogus',
|
|
137
137
|
});
|
|
138
138
|
expect(resolved.size).toBeUndefined();
|
|
@@ -140,26 +140,26 @@ describe('semantic style mapper', () => {
|
|
|
140
140
|
expect(resolved.intent).toBeUndefined();
|
|
141
141
|
});
|
|
142
142
|
|
|
143
|
-
it('coerces
|
|
144
|
-
expect(resolveSharedStyleProps({
|
|
145
|
-
expect(resolveSharedStyleProps({
|
|
143
|
+
it('coerces full_width booleans', () => {
|
|
144
|
+
expect(resolveSharedStyleProps({ full_width: '0' }).fullWidth).toBe(false);
|
|
145
|
+
expect(resolveSharedStyleProps({ full_width: true }).fullWidth).toBe(true);
|
|
146
146
|
expect(resolveSharedStyleProps({}).fullWidth).toBeUndefined();
|
|
147
147
|
});
|
|
148
148
|
|
|
149
|
-
it('reads
|
|
150
|
-
const resolved = resolveSharedStyleProps({
|
|
149
|
+
it('reads color and variant (the REAL cross-platform fields)', () => {
|
|
150
|
+
const resolved = resolveSharedStyleProps({ color: 'red', variant: 'light' });
|
|
151
151
|
expect(resolved.color).toBe('red');
|
|
152
152
|
expect(resolved.variant).toBe('light');
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
-
it('treats an empty
|
|
156
|
-
const resolved = resolveSharedStyleProps({
|
|
155
|
+
it('treats an empty color / variant as absent', () => {
|
|
156
|
+
const resolved = resolveSharedStyleProps({ color: '', variant: '' });
|
|
157
157
|
expect(resolved.color).toBeUndefined();
|
|
158
158
|
expect(resolved.variant).toBeUndefined();
|
|
159
159
|
});
|
|
160
160
|
});
|
|
161
161
|
|
|
162
|
-
describe('Mantine colour/variant -> HeroUI Native (real
|
|
162
|
+
describe('Mantine colour/variant -> HeroUI Native (real color/variant)', () => {
|
|
163
163
|
it('maps a Mantine palette colour to a HeroUI semantic colour', () => {
|
|
164
164
|
expect(mapMantineColorToHeroUiColor('red')).toBe('danger');
|
|
165
165
|
expect(mapMantineColorToHeroUiColor('green')).toBe('success');
|
|
@@ -199,7 +199,7 @@ describe('semantic style mapper', () => {
|
|
|
199
199
|
expect(mapMantineColorToHeroUiButtonVariant('blue')).toBe('primary');
|
|
200
200
|
});
|
|
201
201
|
|
|
202
|
-
it('toHeroUiSemanticProps prefers
|
|
202
|
+
it('toHeroUiSemanticProps prefers variant, then color, then intent', () => {
|
|
203
203
|
expect(
|
|
204
204
|
toHeroUiSemanticProps({ variant: 'outline', color: 'red', intent: 'primary' }).buttonVariant,
|
|
205
205
|
).toBe('outline');
|
|
@@ -213,12 +213,12 @@ describe('semantic style mapper', () => {
|
|
|
213
213
|
});
|
|
214
214
|
});
|
|
215
215
|
|
|
216
|
-
it('resolves a real CMS button section (
|
|
216
|
+
it('resolves a real CMS button section (color + variant + size)', () => {
|
|
217
217
|
const props = resolveSharedStyleProps({
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
218
|
+
color: 'red',
|
|
219
|
+
variant: 'filled',
|
|
220
|
+
size: 'lg',
|
|
221
|
+
radius: 'md',
|
|
222
222
|
});
|
|
223
223
|
expect(toHeroUiSemanticProps(props)).toMatchObject({
|
|
224
224
|
size: 'lg',
|
|
@@ -16,7 +16,7 @@ SPDX-License-Identifier: MPL-2.0
|
|
|
16
16
|
* - `semantic.ts` maps renderer-agnostic shared fields
|
|
17
17
|
* (`intent` / `size` / `radius` / `spacing`) per platform.
|
|
18
18
|
* - `mantineVariant.ts` resolves a Mantine palette `color` + `variant` value
|
|
19
|
-
* pair (e.g. the semantic `
|
|
19
|
+
* pair (e.g. the semantic `color` + `web_variant`)
|
|
20
20
|
* into concrete RGB. Its only runtime
|
|
21
21
|
* consumer today is the mobile **Expo Web preview**
|
|
22
22
|
* fallback (where `heroui-native` cannot render and the
|
package/src/theme/semantic.ts
CHANGED
|
@@ -13,7 +13,7 @@ SPDX-License-Identifier: MPL-2.0
|
|
|
13
13
|
*
|
|
14
14
|
* Design rules (mobile rendering plan, section 8.2):
|
|
15
15
|
* - NO value clamping. The shared scales are the true common denominator
|
|
16
|
-
* (`
|
|
16
|
+
* (`size` = sm|md|lg, `radius` = none|sm|md|lg|full), so every
|
|
17
17
|
* value maps 1:1 to each platform. The backend enforces the same domain
|
|
18
18
|
* (migration `Version20260618195450`).
|
|
19
19
|
* - NO implicit cross-platform fallback. These functions take already-resolved
|
|
@@ -47,8 +47,8 @@ export type TSemanticIntent =
|
|
|
47
47
|
export type TSemanticState = 'disabled' | 'loading' | 'invalid' | 'required';
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
|
-
* Cross-platform colour + variant authored in the CMS (`
|
|
51
|
-
* `
|
|
50
|
+
* Cross-platform colour + variant authored in the CMS (`color` /
|
|
51
|
+
* `variant`). These are stored as Mantine palette / variant *values* —
|
|
52
52
|
* the catalog keeps them verbatim (migration `Version20260618143216` renamed the
|
|
53
53
|
* legacy `mantine_*` fields to `shared_*` without touching the values). They are
|
|
54
54
|
* the REAL cross-platform appearance fields (there is no `shared_intent` in the
|
|
@@ -81,9 +81,9 @@ export interface ISharedStyleProps {
|
|
|
81
81
|
size?: TSemanticSize;
|
|
82
82
|
spacing?: TSemanticSpacing;
|
|
83
83
|
radius?: TSemanticRadius;
|
|
84
|
-
/** Mantine palette colour authored via `
|
|
84
|
+
/** Mantine palette colour authored via `color` (cross-platform). */
|
|
85
85
|
color?: TSemanticColor;
|
|
86
|
-
/** Mantine variant authored via `
|
|
86
|
+
/** Mantine variant authored via `variant` (cross-platform). */
|
|
87
87
|
variant?: TSemanticVariant;
|
|
88
88
|
/**
|
|
89
89
|
* Legacy semantic intent. Kept for back-compat; `shared_intent` is NOT in the
|
|
@@ -349,7 +349,7 @@ export function mapIntentToHeroUiColor(
|
|
|
349
349
|
// ===== color / variant (the REAL cross-platform appearance fields) =====
|
|
350
350
|
|
|
351
351
|
/**
|
|
352
|
-
* Map a Mantine palette colour (`
|
|
352
|
+
* Map a Mantine palette colour (`color`) onto a HeroUI Native semantic
|
|
353
353
|
* colour (Chip / Tag / status surfaces). The Mantine palette is broad; it
|
|
354
354
|
* collapses onto HeroUI's five semantic colours by hue family:
|
|
355
355
|
* red/pink -> danger
|
|
@@ -382,8 +382,8 @@ export function mapMantineColorToHeroUiColor(
|
|
|
382
382
|
}
|
|
383
383
|
|
|
384
384
|
/**
|
|
385
|
-
* Map a Mantine palette colour (`
|
|
386
|
-
* variant when no explicit `
|
|
385
|
+
* Map a Mantine palette colour (`color`) onto a HeroUI Native **Button**
|
|
386
|
+
* variant when no explicit `variant` is authored. HeroUI buttons encode
|
|
387
387
|
* colour in the variant, so the destructive hue becomes `danger`, neutral hues
|
|
388
388
|
* become `secondary`, and everything else stays the prominent `primary`.
|
|
389
389
|
*/
|
|
@@ -404,7 +404,7 @@ export function mapMantineColorToHeroUiButtonVariant(
|
|
|
404
404
|
}
|
|
405
405
|
|
|
406
406
|
/**
|
|
407
|
-
* Map a Mantine variant (`
|
|
407
|
+
* Map a Mantine variant (`variant`) onto the HeroUI Native Button
|
|
408
408
|
* vocabulary:
|
|
409
409
|
* filled / gradient -> primary
|
|
410
410
|
* light / white / default -> secondary
|
|
@@ -434,7 +434,7 @@ export function mapMantineVariantToHeroUiButtonVariant(
|
|
|
434
434
|
}
|
|
435
435
|
|
|
436
436
|
/**
|
|
437
|
-
* Map the accordion variant token (`
|
|
437
|
+
* Map the accordion variant token (`accordion_variant`: Mantine
|
|
438
438
|
* default/contained/filled/separated) onto the HeroUI Native Accordion `variant`
|
|
439
439
|
* vocabulary. HeroUI Native only has `default` (plain list) and `surface`
|
|
440
440
|
* (grouped container), so every "boxed" Mantine variant collapses to `surface`.
|
|
@@ -454,7 +454,7 @@ export function mapAccordionVariantToHeroUiVariant(
|
|
|
454
454
|
}
|
|
455
455
|
|
|
456
456
|
/**
|
|
457
|
-
* Map the chip variant token (`
|
|
457
|
+
* Map the chip variant token (`chip_variant`: Mantine
|
|
458
458
|
* filled/outline/light) onto the HeroUI Native Chip `variant` vocabulary
|
|
459
459
|
* (`primary`/`secondary`/`tertiary`/`soft`):
|
|
460
460
|
* - filled -> primary (solid accent fill)
|
|
@@ -475,14 +475,14 @@ export function mapChipVariantToHeroUiVariant(
|
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
477
|
|
|
478
|
-
// ===== layout dimensions (shared_width / shared_height / grid span / divider) =====
|
|
478
|
+
// ===== layout dimensions (shared_width / shared_height / mih/miw/mah/maw / grid span / divider) =====
|
|
479
479
|
|
|
480
480
|
/** A React Native-safe dimension: a px number, a percentage string, or "auto". */
|
|
481
481
|
export type TReactNativeDimension = number | `${number}%` | 'auto';
|
|
482
482
|
|
|
483
483
|
/**
|
|
484
|
-
* Parse a CMS dimension string (`shared_width`/`shared_height`/`
|
|
485
|
-
* `
|
|
484
|
+
* Parse a CMS dimension string (`shared_width`/`shared_height`/`mih`/`miw`/
|
|
485
|
+
* `mah`/`maw`) into a React Native-safe value. Web (Mantine) accepts the raw
|
|
486
486
|
* string verbatim ("320px", "100%", "auto"); React Native does NOT accept a
|
|
487
487
|
* unit suffix, so a px value must become a unitless number:
|
|
488
488
|
* "320px" | "320" | 320 -> 320 (number)
|
|
@@ -552,7 +552,7 @@ export function gridSpanToReactNativeColumn(
|
|
|
552
552
|
}
|
|
553
553
|
|
|
554
554
|
/**
|
|
555
|
-
* Map a `
|
|
555
|
+
* Map a `divider_variant` (solid/dashed/dotted) onto a React Native
|
|
556
556
|
* `borderStyle`. The vocabularies are identical, so this validates the domain
|
|
557
557
|
* and falls back to 'solid'.
|
|
558
558
|
*/
|
|
@@ -601,26 +601,26 @@ function readBool(value: unknown): boolean | undefined {
|
|
|
601
601
|
export function resolveSharedStyleProps(fields: Record<string, unknown>): ISharedStyleProps {
|
|
602
602
|
const resolved: ISharedStyleProps = {};
|
|
603
603
|
|
|
604
|
-
const size = readString(fields.
|
|
604
|
+
const size = readString(fields.size);
|
|
605
605
|
if (size !== undefined && (SEMANTIC_SIZES as readonly string[]).includes(size)) {
|
|
606
606
|
resolved.size = size as TSemanticSize;
|
|
607
607
|
}
|
|
608
608
|
|
|
609
|
-
const radius = readString(fields.
|
|
609
|
+
const radius = readString(fields.radius);
|
|
610
610
|
if (radius !== undefined && (SEMANTIC_RADII as readonly string[]).includes(radius)) {
|
|
611
611
|
resolved.radius = radius as TSemanticRadius;
|
|
612
612
|
}
|
|
613
613
|
|
|
614
|
-
// `
|
|
614
|
+
// `color` / `variant` are the REAL cross-platform appearance
|
|
615
615
|
// fields (Mantine palette/variant values stored verbatim). Read them
|
|
616
616
|
// open-domain — the palette is intentionally broad and platform mappers
|
|
617
617
|
// collapse it; an unknown value simply falls through to a renderer default.
|
|
618
|
-
const color = readString(fields.
|
|
618
|
+
const color = readString(fields.color);
|
|
619
619
|
if (color !== undefined) {
|
|
620
620
|
resolved.color = color;
|
|
621
621
|
}
|
|
622
622
|
|
|
623
|
-
const variant = readString(fields.
|
|
623
|
+
const variant = readString(fields.variant);
|
|
624
624
|
if (variant !== undefined) {
|
|
625
625
|
resolved.variant = variant as TSemanticVariant;
|
|
626
626
|
}
|
|
@@ -632,7 +632,7 @@ export function resolveSharedStyleProps(fields: Record<string, unknown>): IShare
|
|
|
632
632
|
resolved.intent = intent as TSemanticIntent;
|
|
633
633
|
}
|
|
634
634
|
|
|
635
|
-
const fullWidth = readBool(fields.
|
|
635
|
+
const fullWidth = readBool(fields.full_width);
|
|
636
636
|
if (fullWidth !== undefined) {
|
|
637
637
|
resolved.fullWidth = fullWidth;
|
|
638
638
|
}
|
|
@@ -665,10 +665,10 @@ export function toMantineSemanticProps(props: ISharedStyleProps): IMantineResolv
|
|
|
665
665
|
*
|
|
666
666
|
* Appearance precedence (mirrors the web renderer, which reads the same CMS
|
|
667
667
|
* fields straight into Mantine):
|
|
668
|
-
* 1. `
|
|
669
|
-
* 2. else `
|
|
668
|
+
* 1. `variant` (Mantine variant) mapped onto the HeroUI button vocab;
|
|
669
|
+
* 2. else `color` (Mantine palette) mapped onto a button variant;
|
|
670
670
|
* 3. else the legacy `intent` mapping (back-compat fallback).
|
|
671
|
-
* The semantic `color` is resolved from `
|
|
671
|
+
* The semantic `color` is resolved from `color` first, then `intent`.
|
|
672
672
|
*/
|
|
673
673
|
export function toHeroUiSemanticProps(props: ISharedStyleProps): IHeroUiResolvedStyle {
|
|
674
674
|
const buttonVariant =
|
package/src/theme/tailwind.ts
CHANGED
|
@@ -5,8 +5,8 @@ SPDX-License-Identifier: MPL-2.0
|
|
|
5
5
|
/**
|
|
6
6
|
* Shared Tailwind preset extended by both the web frontend (Tailwind v4)
|
|
7
7
|
* and the mobile app (Uniwind v4 inside HeroUI Native). Anchors the same
|
|
8
|
-
* scale values that drive `
|
|
9
|
-
* `
|
|
8
|
+
* scale values that drive `size`, `radius`,
|
|
9
|
+
* `spacing`, and the color palette so a class like `p-md` or
|
|
10
10
|
* `text-blue-6` resolves identically on web and mobile.
|
|
11
11
|
*/
|
|
12
12
|
|
package/src/theme/tokens.ts
CHANGED
|
@@ -4,7 +4,7 @@ SPDX-License-Identifier: MPL-2.0
|
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
6
|
* Mantine semantic token tables. Both the web Mantine theme and the
|
|
7
|
-
* mobile HeroUI Native theme extend these so a `
|
|
7
|
+
* mobile HeroUI Native theme extend these so a `size: 'md'` on a
|
|
8
8
|
* section renders identical sizing regardless of platform.
|
|
9
9
|
*
|
|
10
10
|
* Pixel values come straight from Mantine v9 defaults:
|