@selfhelp/shared 1.14.20 → 1.14.24
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 +109 -0
- package/dist/{common-DMm4kymA.d.mts → common-qaDIAYS3.d.mts} +5 -4
- package/dist/{common-DMm4kymA.d.ts → common-qaDIAYS3.d.ts} +5 -4
- package/dist/index.d.mts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +99 -175
- package/dist/index.mjs +99 -172
- package/dist/plugin-sdk/index.d.mts +2 -2
- package/dist/plugin-sdk/index.d.ts +2 -2
- package/dist/plugin-sdk/index.js +90 -91
- package/dist/plugin-sdk/index.mjs +90 -91
- package/dist/registry/index.d.mts +3 -3
- package/dist/registry/index.d.ts +3 -3
- package/dist/registry/index.js +90 -90
- package/dist/registry/index.mjs +90 -90
- package/dist/{styles.registry-B8IaEULk.d.ts → styles.registry-4W0LzmZB.d.mts} +194 -365
- package/dist/{styles.registry-DhkxrV2-.d.mts → styles.registry-D6xMm5VR.d.ts} +194 -365
- package/dist/theme/index.d.mts +42 -91
- package/dist/theme/index.d.ts +42 -91
- package/dist/theme/index.js +9 -85
- package/dist/theme/index.mjs +9 -82
- package/dist/theme/tailwind.d.mts +2 -2
- package/dist/theme/tailwind.d.ts +2 -2
- package/package.json +1 -1
- package/src/plugin-sdk/define.ts +0 -1
- package/src/registry/__tests__/platform.test.ts +0 -4
- package/src/registry/__tests__/registry.test.ts +0 -2
- package/src/registry/styles.registry.ts +90 -96
- package/src/theme/__tests__/mantineVariant.test.ts +2 -2
- package/src/theme/__tests__/semantic.test.ts +34 -71
- package/src/theme/mantineVariant.ts +3 -3
- package/src/theme/semantic.ts +45 -185
- package/src/theme/tailwind.ts +2 -2
- package/src/theme/tokens.ts +3 -3
- package/src/types/__tests__/mobile-adapters.test.ts +1 -1
- package/src/types/mantine/common.ts +4 -3
- 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 -9
- 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,
|
|
1
|
+
import { m as TMantineSize, b as TSharedSize, T as TMantineColor, p as TMantineVariant, k as TSharedRadius } from '../common-qaDIAYS3.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:
|
|
@@ -29,8 +29,8 @@ declare const CONTAINER_SIZE_PX: Record<TMantineSize, number>;
|
|
|
29
29
|
/**
|
|
30
30
|
* Mantine palette base colors (color-6 from each scale). Each renderer
|
|
31
31
|
* maps these to its own theme tokens. For HeroUI Native we feed these
|
|
32
|
-
* into the theme builder so `
|
|
33
|
-
* same Mantine-blue look on mobile.
|
|
32
|
+
* into the theme builder so the portable `color: 'blue'` field resolves
|
|
33
|
+
* to the same Mantine-blue look on mobile.
|
|
34
34
|
*/
|
|
35
35
|
declare const COLOR_PALETTE: Record<TCanonicalColor, string>;
|
|
36
36
|
/**
|
|
@@ -62,8 +62,9 @@ declare function colorToHex(name: string | undefined, shade?: number): string |
|
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Shared semantic style mapper — the single source of truth that turns
|
|
65
|
-
* renderer-agnostic CMS values (
|
|
66
|
-
* props. Renderers consume this module instead of duplicating
|
|
65
|
+
* renderer-agnostic CMS values (the unprefixed portable fields) into concrete
|
|
66
|
+
* per-platform props. Renderers consume this module instead of duplicating
|
|
67
|
+
* mapping logic.
|
|
67
68
|
*
|
|
68
69
|
* - Web -> Mantine (`toMantineSemanticProps`)
|
|
69
70
|
* - Mobile -> HeroUI Native (`toHeroUiSemanticProps`)
|
|
@@ -71,18 +72,19 @@ declare function colorToHex(name: string | undefined, shade?: number): string |
|
|
|
71
72
|
*
|
|
72
73
|
* Design rules (mobile rendering plan, section 8.2):
|
|
73
74
|
* - NO value clamping. The shared scales are the true common denominator
|
|
74
|
-
* (`
|
|
75
|
+
* (`size` = sm|md|lg, `radius` = none|sm|md|lg|full), so every
|
|
75
76
|
* value maps 1:1 to each platform. The backend enforces the same domain
|
|
76
77
|
* (migration `Version20260618195450`).
|
|
77
78
|
* - NO implicit cross-platform fallback. These functions take already-resolved
|
|
78
|
-
*
|
|
79
|
-
* component default is applied by each platform renderer,
|
|
79
|
+
* portable props; the precedence `web_*`/`mobile_*` override -> portable
|
|
80
|
+
* (unprefixed) -> component default is applied by each platform renderer,
|
|
81
|
+
* never here.
|
|
80
82
|
* - Exhaustive enum handling (every switch covers the full domain).
|
|
81
83
|
*
|
|
82
|
-
* Platform-specific props stay separate from these
|
|
84
|
+
* Platform-specific props stay separate from these portable values:
|
|
83
85
|
* - `web_*` Mantine-only fields
|
|
84
86
|
* - `mobile_*` HeroUI/native-only fields
|
|
85
|
-
* -
|
|
87
|
+
* - portable the unprefixed semantic fields mapped here
|
|
86
88
|
*/
|
|
87
89
|
|
|
88
90
|
/** Cross-platform size: the true common denominator (HeroUI Native has no xs/xl). */
|
|
@@ -90,16 +92,13 @@ type TSemanticSize = TSharedSize;
|
|
|
90
92
|
type TSemanticSpacing = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
91
93
|
/** Cross-platform radius. `full` = pill; `none` = square. */
|
|
92
94
|
type TSemanticRadius = TSharedRadius;
|
|
93
|
-
type TSemanticIntent = 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'neutral';
|
|
94
95
|
type TSemanticState = 'disabled' | 'loading' | 'invalid' | 'required';
|
|
95
96
|
/**
|
|
96
|
-
* Cross-platform colour + variant authored in the CMS (`
|
|
97
|
-
* `
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* live catalog); the mapper maps them onto HeroUI Native for mobile, while the
|
|
102
|
-
* web renderer feeds them straight into Mantine.
|
|
97
|
+
* Cross-platform colour + variant authored in the CMS (`color` /
|
|
98
|
+
* `variant`), stored as Mantine palette / variant *values* kept verbatim by the
|
|
99
|
+
* catalog. They are the canonical cross-platform appearance fields; the mapper
|
|
100
|
+
* maps them onto HeroUI Native for mobile, while the web renderer feeds them
|
|
101
|
+
* straight into Mantine.
|
|
103
102
|
*/
|
|
104
103
|
type TSemanticColor = TMantineColor;
|
|
105
104
|
type TSemanticVariant = TMantineVariant;
|
|
@@ -114,28 +113,22 @@ interface ISharedStyleProps {
|
|
|
114
113
|
size?: TSemanticSize;
|
|
115
114
|
spacing?: TSemanticSpacing;
|
|
116
115
|
radius?: TSemanticRadius;
|
|
117
|
-
/** Mantine palette colour authored via `
|
|
116
|
+
/** Mantine palette colour authored via `color` (cross-platform). */
|
|
118
117
|
color?: TSemanticColor;
|
|
119
|
-
/** Mantine variant authored via `
|
|
118
|
+
/** Mantine variant authored via `variant` (cross-platform). */
|
|
120
119
|
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
|
-
*/
|
|
126
|
-
intent?: TSemanticIntent;
|
|
127
120
|
/** Active boolean states. Stored as a small set so multiple can apply. */
|
|
128
121
|
states?: readonly TSemanticState[];
|
|
129
122
|
/** Layout: stretch the control to the full width of its container. */
|
|
130
123
|
fullWidth?: boolean;
|
|
131
124
|
}
|
|
132
|
-
type TMantineMappedColor = 'blue' | 'gray' | 'green' | 'yellow' | 'red';
|
|
133
|
-
type TMantineMappedVariant = 'filled' | 'light' | 'outline' | 'default';
|
|
134
125
|
interface IMantineResolvedStyle {
|
|
135
126
|
/** Mantine accepts sm|md|lg 1:1 (a subset of its xs..xl scale). */
|
|
136
127
|
size?: TSemanticSize;
|
|
137
|
-
color
|
|
138
|
-
|
|
128
|
+
/** Mantine palette colour, read verbatim from the `color` field. */
|
|
129
|
+
color?: TSemanticColor;
|
|
130
|
+
/** Mantine variant, read verbatim from the `variant` field. */
|
|
131
|
+
variant?: TSemanticVariant;
|
|
139
132
|
/** Mantine `radius` accepts a token or a number; pill => FULL_RADIUS_PX. */
|
|
140
133
|
radius?: TSemanticSize | number;
|
|
141
134
|
/** Margin/padding spacing token (xs..xl); `none` => undefined. */
|
|
@@ -154,9 +147,9 @@ type THeroUiButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'outline' | '
|
|
|
154
147
|
type THeroUiColor = 'accent' | 'default' | 'success' | 'warning' | 'danger';
|
|
155
148
|
interface IHeroUiResolvedStyle {
|
|
156
149
|
size?: THeroUiSize;
|
|
157
|
-
/**
|
|
150
|
+
/** Button variant derived from the Mantine `variant`/`color`. */
|
|
158
151
|
buttonVariant?: THeroUiButtonVariant;
|
|
159
|
-
/**
|
|
152
|
+
/** Semantic color derived from the Mantine `color` (Chip/Tag/etc). */
|
|
160
153
|
color?: THeroUiColor;
|
|
161
154
|
/** Resolved radius in px (pill => FULL_RADIUS_PX, none => 0). */
|
|
162
155
|
radiusPx?: number;
|
|
@@ -191,48 +184,7 @@ declare function mapRadiusToMantine(radius: TSemanticRadius | undefined): TSeman
|
|
|
191
184
|
/** Resolve a semantic spacing token to px (none => 0). */
|
|
192
185
|
declare function mapSpacingToPx(spacing: TSemanticSpacing | undefined): number | undefined;
|
|
193
186
|
/**
|
|
194
|
-
* Map a
|
|
195
|
-
* primary -> blue / filled
|
|
196
|
-
* secondary -> gray / light
|
|
197
|
-
* success -> green / filled
|
|
198
|
-
* warning -> yellow / filled
|
|
199
|
-
* danger -> red / filled
|
|
200
|
-
* neutral -> gray / default
|
|
201
|
-
*/
|
|
202
|
-
declare function mapIntentToMantine(intent: TSemanticIntent | undefined): {
|
|
203
|
-
color: TMantineMappedColor;
|
|
204
|
-
variant: TMantineMappedVariant;
|
|
205
|
-
} | undefined;
|
|
206
|
-
/**
|
|
207
|
-
* Map a semantic intent to a HeroUI Native **Button** variant.
|
|
208
|
-
*
|
|
209
|
-
* HeroUI buttons have no dedicated success/warning variant. Rather than
|
|
210
|
-
* silently collapse them, the dedicated status surfaces use
|
|
211
|
-
* {@link mapIntentToHeroUiColor}; the Button variant maps success/warning to
|
|
212
|
-
* `primary` because that is the closest *prominent* action affordance, and the
|
|
213
|
-
* status color is carried separately. This is an explicit semantic choice, not
|
|
214
|
-
* a clamp that hides an unsupported size/scale value.
|
|
215
|
-
* primary -> primary
|
|
216
|
-
* secondary -> secondary
|
|
217
|
-
* success -> primary (status color carried by mapIntentToHeroUiColor)
|
|
218
|
-
* warning -> primary (status color carried by mapIntentToHeroUiColor)
|
|
219
|
-
* danger -> danger
|
|
220
|
-
* neutral -> secondary
|
|
221
|
-
*/
|
|
222
|
-
declare function mapIntentToHeroUiButtonVariant(intent: TSemanticIntent | undefined): THeroUiButtonVariant | undefined;
|
|
223
|
-
/**
|
|
224
|
-
* Map a semantic intent to a HeroUI Native semantic color (Chip/Tag/
|
|
225
|
-
* status surfaces, which DO support success/warning).
|
|
226
|
-
* primary -> accent
|
|
227
|
-
* secondary -> default
|
|
228
|
-
* success -> success
|
|
229
|
-
* warning -> warning
|
|
230
|
-
* danger -> danger
|
|
231
|
-
* neutral -> default
|
|
232
|
-
*/
|
|
233
|
-
declare function mapIntentToHeroUiColor(intent: TSemanticIntent | undefined): THeroUiColor | undefined;
|
|
234
|
-
/**
|
|
235
|
-
* Map a Mantine palette colour (`shared_color`) onto a HeroUI Native semantic
|
|
187
|
+
* Map a Mantine palette colour (`color`) onto a HeroUI Native semantic
|
|
236
188
|
* colour (Chip / Tag / status surfaces). The Mantine palette is broad; it
|
|
237
189
|
* collapses onto HeroUI's five semantic colours by hue family:
|
|
238
190
|
* red/pink -> danger
|
|
@@ -243,14 +195,14 @@ declare function mapIntentToHeroUiColor(intent: TSemanticIntent | undefined): TH
|
|
|
243
195
|
*/
|
|
244
196
|
declare function mapMantineColorToHeroUiColor(color: TSemanticColor | undefined): THeroUiColor | undefined;
|
|
245
197
|
/**
|
|
246
|
-
* Map a Mantine palette colour (`
|
|
247
|
-
* variant when no explicit `
|
|
198
|
+
* Map a Mantine palette colour (`color`) onto a HeroUI Native **Button**
|
|
199
|
+
* variant when no explicit `variant` is authored. HeroUI buttons encode
|
|
248
200
|
* colour in the variant, so the destructive hue becomes `danger`, neutral hues
|
|
249
201
|
* become `secondary`, and everything else stays the prominent `primary`.
|
|
250
202
|
*/
|
|
251
203
|
declare function mapMantineColorToHeroUiButtonVariant(color: TSemanticColor | undefined): THeroUiButtonVariant | undefined;
|
|
252
204
|
/**
|
|
253
|
-
* Map a Mantine variant (`
|
|
205
|
+
* Map a Mantine variant (`variant`) onto the HeroUI Native Button
|
|
254
206
|
* vocabulary:
|
|
255
207
|
* filled / gradient -> primary
|
|
256
208
|
* light / white / default -> secondary
|
|
@@ -259,14 +211,14 @@ declare function mapMantineColorToHeroUiButtonVariant(color: TSemanticColor | un
|
|
|
259
211
|
*/
|
|
260
212
|
declare function mapMantineVariantToHeroUiButtonVariant(variant: TSemanticVariant | undefined): THeroUiButtonVariant | undefined;
|
|
261
213
|
/**
|
|
262
|
-
* Map the accordion variant token (`
|
|
214
|
+
* Map the accordion variant token (`accordion_variant`: Mantine
|
|
263
215
|
* default/contained/filled/separated) onto the HeroUI Native Accordion `variant`
|
|
264
216
|
* vocabulary. HeroUI Native only has `default` (plain list) and `surface`
|
|
265
217
|
* (grouped container), so every "boxed" Mantine variant collapses to `surface`.
|
|
266
218
|
*/
|
|
267
219
|
declare function mapAccordionVariantToHeroUiVariant(variant: string | undefined): 'default' | 'surface';
|
|
268
220
|
/**
|
|
269
|
-
* Map the chip variant token (`
|
|
221
|
+
* Map the chip variant token (`chip_variant`: Mantine
|
|
270
222
|
* filled/outline/light) onto the HeroUI Native Chip `variant` vocabulary
|
|
271
223
|
* (`primary`/`secondary`/`tertiary`/`soft`):
|
|
272
224
|
* - filled -> primary (solid accent fill)
|
|
@@ -277,8 +229,8 @@ declare function mapChipVariantToHeroUiVariant(variant: string | undefined): 'pr
|
|
|
277
229
|
/** A React Native-safe dimension: a px number, a percentage string, or "auto". */
|
|
278
230
|
type TReactNativeDimension = number | `${number}%` | 'auto';
|
|
279
231
|
/**
|
|
280
|
-
* Parse a CMS dimension string (`shared_width`/`shared_height`/`
|
|
281
|
-
* `
|
|
232
|
+
* Parse a CMS dimension string (`shared_width`/`shared_height`/`mih`/`miw`/
|
|
233
|
+
* `mah`/`maw`) into a React Native-safe value. Web (Mantine) accepts the raw
|
|
282
234
|
* string verbatim ("320px", "100%", "auto"); React Native does NOT accept a
|
|
283
235
|
* unit suffix, so a px value must become a unitless number:
|
|
284
236
|
* "320px" | "320" | 320 -> 320 (number)
|
|
@@ -309,7 +261,7 @@ interface IReactNativeGridColumn {
|
|
|
309
261
|
*/
|
|
310
262
|
declare function gridSpanToReactNativeColumn(span: string | number | undefined | null, cols?: number): IReactNativeGridColumn;
|
|
311
263
|
/**
|
|
312
|
-
* Map a `
|
|
264
|
+
* Map a `divider_variant` (solid/dashed/dotted) onto a React Native
|
|
313
265
|
* `borderStyle`. The vocabularies are identical, so this validates the domain
|
|
314
266
|
* and falls back to 'solid'.
|
|
315
267
|
*/
|
|
@@ -330,10 +282,9 @@ declare function toMantineSemanticProps(props: ISharedStyleProps): IMantineResol
|
|
|
330
282
|
*
|
|
331
283
|
* Appearance precedence (mirrors the web renderer, which reads the same CMS
|
|
332
284
|
* fields straight into Mantine):
|
|
333
|
-
* 1. `
|
|
334
|
-
* 2. else `
|
|
335
|
-
*
|
|
336
|
-
* The semantic `color` is resolved from `shared_color` first, then `intent`.
|
|
285
|
+
* 1. `variant` (Mantine variant) mapped onto the HeroUI button vocab;
|
|
286
|
+
* 2. else `color` (Mantine palette) mapped onto a button variant.
|
|
287
|
+
* The semantic `color` is resolved from `color`.
|
|
337
288
|
*/
|
|
338
289
|
declare function toHeroUiSemanticProps(props: ISharedStyleProps): IHeroUiResolvedStyle;
|
|
339
290
|
/**
|
|
@@ -363,10 +314,10 @@ declare const resolveSharedStyleForMobile: typeof toHeroUiSemanticProps;
|
|
|
363
314
|
* SCOPE — this is NOT the semantic mapper (`semantic.ts`). The two have
|
|
364
315
|
* different input domains and both live here so there is exactly one home
|
|
365
316
|
* for style mapping:
|
|
366
|
-
* - `semantic.ts` maps renderer-agnostic
|
|
367
|
-
* (`
|
|
317
|
+
* - `semantic.ts` maps renderer-agnostic unprefixed portable fields
|
|
318
|
+
* (`color` / `variant` / `size` / `radius` / `spacing`) per platform.
|
|
368
319
|
* - `mantineVariant.ts` resolves a Mantine palette `color` + `variant` value
|
|
369
|
-
* pair (e.g. the
|
|
320
|
+
* pair (e.g. the portable `color` + `variant`)
|
|
370
321
|
* into concrete RGB. Its only runtime
|
|
371
322
|
* consumer today is the mobile **Expo Web preview**
|
|
372
323
|
* fallback (where `heroui-native` cannot render and the
|
|
@@ -394,4 +345,4 @@ interface IResolvedVariant {
|
|
|
394
345
|
}
|
|
395
346
|
declare function resolveMantineVariant(variant: string | undefined, color: string | undefined): IResolvedVariant;
|
|
396
347
|
|
|
397
|
-
export { COLOR_PALETTE, COLOR_SCALES, CONTAINER_SIZE_PX, FONT_SIZE_PX, FULL_RADIUS_PX, type IHeroUiResolvedStyle, type IMantineResolvedStyle, type IReactNativeGridColumn, 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
|
|
348
|
+
export { COLOR_PALETTE, COLOR_SCALES, CONTAINER_SIZE_PX, FONT_SIZE_PX, FULL_RADIUS_PX, type IHeroUiResolvedStyle, type IMantineResolvedStyle, type IReactNativeGridColumn, 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 TReactNativeDimension, type TSemanticColor, type TSemanticRadius, type TSemanticSize, type TSemanticSpacing, type TSemanticState, type TSemanticVariant, colorToHex, gridSpanToReactNativeColumn, mapAccordionVariantToHeroUiVariant, mapChipVariantToHeroUiVariant, mapDividerVariantToReactNative, mapMantineColorToHeroUiButtonVariant, mapMantineColorToHeroUiColor, mapMantineVariantToHeroUiButtonVariant, mapRadiusToMantine, mapRadiusToPx, mapSizeToHeroUi, mapSizeToMantine, mapSpacingToPx, parseDimensionToReactNative, parseDimensionToWeb, radiusToPx, resolveMantineVariant, resolveSharedStyle, resolveSharedStyleForMobile, resolveSharedStyleForWeb, resolveSharedStyleProps, sizeToFontPx, spacingToPx, toHeroUiSemanticProps, toMantineSemanticProps, toReactNativeSemanticStyle };
|
package/dist/theme/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { m as TMantineSize, b as TSharedSize,
|
|
1
|
+
import { m as TMantineSize, b as TSharedSize, T as TMantineColor, p as TMantineVariant, k as TSharedRadius } from '../common-qaDIAYS3.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:
|
|
@@ -29,8 +29,8 @@ declare const CONTAINER_SIZE_PX: Record<TMantineSize, number>;
|
|
|
29
29
|
/**
|
|
30
30
|
* Mantine palette base colors (color-6 from each scale). Each renderer
|
|
31
31
|
* maps these to its own theme tokens. For HeroUI Native we feed these
|
|
32
|
-
* into the theme builder so `
|
|
33
|
-
* same Mantine-blue look on mobile.
|
|
32
|
+
* into the theme builder so the portable `color: 'blue'` field resolves
|
|
33
|
+
* to the same Mantine-blue look on mobile.
|
|
34
34
|
*/
|
|
35
35
|
declare const COLOR_PALETTE: Record<TCanonicalColor, string>;
|
|
36
36
|
/**
|
|
@@ -62,8 +62,9 @@ declare function colorToHex(name: string | undefined, shade?: number): string |
|
|
|
62
62
|
|
|
63
63
|
/**
|
|
64
64
|
* Shared semantic style mapper — the single source of truth that turns
|
|
65
|
-
* renderer-agnostic CMS values (
|
|
66
|
-
* props. Renderers consume this module instead of duplicating
|
|
65
|
+
* renderer-agnostic CMS values (the unprefixed portable fields) into concrete
|
|
66
|
+
* per-platform props. Renderers consume this module instead of duplicating
|
|
67
|
+
* mapping logic.
|
|
67
68
|
*
|
|
68
69
|
* - Web -> Mantine (`toMantineSemanticProps`)
|
|
69
70
|
* - Mobile -> HeroUI Native (`toHeroUiSemanticProps`)
|
|
@@ -71,18 +72,19 @@ declare function colorToHex(name: string | undefined, shade?: number): string |
|
|
|
71
72
|
*
|
|
72
73
|
* Design rules (mobile rendering plan, section 8.2):
|
|
73
74
|
* - NO value clamping. The shared scales are the true common denominator
|
|
74
|
-
* (`
|
|
75
|
+
* (`size` = sm|md|lg, `radius` = none|sm|md|lg|full), so every
|
|
75
76
|
* value maps 1:1 to each platform. The backend enforces the same domain
|
|
76
77
|
* (migration `Version20260618195450`).
|
|
77
78
|
* - NO implicit cross-platform fallback. These functions take already-resolved
|
|
78
|
-
*
|
|
79
|
-
* component default is applied by each platform renderer,
|
|
79
|
+
* portable props; the precedence `web_*`/`mobile_*` override -> portable
|
|
80
|
+
* (unprefixed) -> component default is applied by each platform renderer,
|
|
81
|
+
* never here.
|
|
80
82
|
* - Exhaustive enum handling (every switch covers the full domain).
|
|
81
83
|
*
|
|
82
|
-
* Platform-specific props stay separate from these
|
|
84
|
+
* Platform-specific props stay separate from these portable values:
|
|
83
85
|
* - `web_*` Mantine-only fields
|
|
84
86
|
* - `mobile_*` HeroUI/native-only fields
|
|
85
|
-
* -
|
|
87
|
+
* - portable the unprefixed semantic fields mapped here
|
|
86
88
|
*/
|
|
87
89
|
|
|
88
90
|
/** Cross-platform size: the true common denominator (HeroUI Native has no xs/xl). */
|
|
@@ -90,16 +92,13 @@ type TSemanticSize = TSharedSize;
|
|
|
90
92
|
type TSemanticSpacing = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
91
93
|
/** Cross-platform radius. `full` = pill; `none` = square. */
|
|
92
94
|
type TSemanticRadius = TSharedRadius;
|
|
93
|
-
type TSemanticIntent = 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'neutral';
|
|
94
95
|
type TSemanticState = 'disabled' | 'loading' | 'invalid' | 'required';
|
|
95
96
|
/**
|
|
96
|
-
* Cross-platform colour + variant authored in the CMS (`
|
|
97
|
-
* `
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
* live catalog); the mapper maps them onto HeroUI Native for mobile, while the
|
|
102
|
-
* web renderer feeds them straight into Mantine.
|
|
97
|
+
* Cross-platform colour + variant authored in the CMS (`color` /
|
|
98
|
+
* `variant`), stored as Mantine palette / variant *values* kept verbatim by the
|
|
99
|
+
* catalog. They are the canonical cross-platform appearance fields; the mapper
|
|
100
|
+
* maps them onto HeroUI Native for mobile, while the web renderer feeds them
|
|
101
|
+
* straight into Mantine.
|
|
103
102
|
*/
|
|
104
103
|
type TSemanticColor = TMantineColor;
|
|
105
104
|
type TSemanticVariant = TMantineVariant;
|
|
@@ -114,28 +113,22 @@ interface ISharedStyleProps {
|
|
|
114
113
|
size?: TSemanticSize;
|
|
115
114
|
spacing?: TSemanticSpacing;
|
|
116
115
|
radius?: TSemanticRadius;
|
|
117
|
-
/** Mantine palette colour authored via `
|
|
116
|
+
/** Mantine palette colour authored via `color` (cross-platform). */
|
|
118
117
|
color?: TSemanticColor;
|
|
119
|
-
/** Mantine variant authored via `
|
|
118
|
+
/** Mantine variant authored via `variant` (cross-platform). */
|
|
120
119
|
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
|
-
*/
|
|
126
|
-
intent?: TSemanticIntent;
|
|
127
120
|
/** Active boolean states. Stored as a small set so multiple can apply. */
|
|
128
121
|
states?: readonly TSemanticState[];
|
|
129
122
|
/** Layout: stretch the control to the full width of its container. */
|
|
130
123
|
fullWidth?: boolean;
|
|
131
124
|
}
|
|
132
|
-
type TMantineMappedColor = 'blue' | 'gray' | 'green' | 'yellow' | 'red';
|
|
133
|
-
type TMantineMappedVariant = 'filled' | 'light' | 'outline' | 'default';
|
|
134
125
|
interface IMantineResolvedStyle {
|
|
135
126
|
/** Mantine accepts sm|md|lg 1:1 (a subset of its xs..xl scale). */
|
|
136
127
|
size?: TSemanticSize;
|
|
137
|
-
color
|
|
138
|
-
|
|
128
|
+
/** Mantine palette colour, read verbatim from the `color` field. */
|
|
129
|
+
color?: TSemanticColor;
|
|
130
|
+
/** Mantine variant, read verbatim from the `variant` field. */
|
|
131
|
+
variant?: TSemanticVariant;
|
|
139
132
|
/** Mantine `radius` accepts a token or a number; pill => FULL_RADIUS_PX. */
|
|
140
133
|
radius?: TSemanticSize | number;
|
|
141
134
|
/** Margin/padding spacing token (xs..xl); `none` => undefined. */
|
|
@@ -154,9 +147,9 @@ type THeroUiButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'outline' | '
|
|
|
154
147
|
type THeroUiColor = 'accent' | 'default' | 'success' | 'warning' | 'danger';
|
|
155
148
|
interface IHeroUiResolvedStyle {
|
|
156
149
|
size?: THeroUiSize;
|
|
157
|
-
/**
|
|
150
|
+
/** Button variant derived from the Mantine `variant`/`color`. */
|
|
158
151
|
buttonVariant?: THeroUiButtonVariant;
|
|
159
|
-
/**
|
|
152
|
+
/** Semantic color derived from the Mantine `color` (Chip/Tag/etc). */
|
|
160
153
|
color?: THeroUiColor;
|
|
161
154
|
/** Resolved radius in px (pill => FULL_RADIUS_PX, none => 0). */
|
|
162
155
|
radiusPx?: number;
|
|
@@ -191,48 +184,7 @@ declare function mapRadiusToMantine(radius: TSemanticRadius | undefined): TSeman
|
|
|
191
184
|
/** Resolve a semantic spacing token to px (none => 0). */
|
|
192
185
|
declare function mapSpacingToPx(spacing: TSemanticSpacing | undefined): number | undefined;
|
|
193
186
|
/**
|
|
194
|
-
* Map a
|
|
195
|
-
* primary -> blue / filled
|
|
196
|
-
* secondary -> gray / light
|
|
197
|
-
* success -> green / filled
|
|
198
|
-
* warning -> yellow / filled
|
|
199
|
-
* danger -> red / filled
|
|
200
|
-
* neutral -> gray / default
|
|
201
|
-
*/
|
|
202
|
-
declare function mapIntentToMantine(intent: TSemanticIntent | undefined): {
|
|
203
|
-
color: TMantineMappedColor;
|
|
204
|
-
variant: TMantineMappedVariant;
|
|
205
|
-
} | undefined;
|
|
206
|
-
/**
|
|
207
|
-
* Map a semantic intent to a HeroUI Native **Button** variant.
|
|
208
|
-
*
|
|
209
|
-
* HeroUI buttons have no dedicated success/warning variant. Rather than
|
|
210
|
-
* silently collapse them, the dedicated status surfaces use
|
|
211
|
-
* {@link mapIntentToHeroUiColor}; the Button variant maps success/warning to
|
|
212
|
-
* `primary` because that is the closest *prominent* action affordance, and the
|
|
213
|
-
* status color is carried separately. This is an explicit semantic choice, not
|
|
214
|
-
* a clamp that hides an unsupported size/scale value.
|
|
215
|
-
* primary -> primary
|
|
216
|
-
* secondary -> secondary
|
|
217
|
-
* success -> primary (status color carried by mapIntentToHeroUiColor)
|
|
218
|
-
* warning -> primary (status color carried by mapIntentToHeroUiColor)
|
|
219
|
-
* danger -> danger
|
|
220
|
-
* neutral -> secondary
|
|
221
|
-
*/
|
|
222
|
-
declare function mapIntentToHeroUiButtonVariant(intent: TSemanticIntent | undefined): THeroUiButtonVariant | undefined;
|
|
223
|
-
/**
|
|
224
|
-
* Map a semantic intent to a HeroUI Native semantic color (Chip/Tag/
|
|
225
|
-
* status surfaces, which DO support success/warning).
|
|
226
|
-
* primary -> accent
|
|
227
|
-
* secondary -> default
|
|
228
|
-
* success -> success
|
|
229
|
-
* warning -> warning
|
|
230
|
-
* danger -> danger
|
|
231
|
-
* neutral -> default
|
|
232
|
-
*/
|
|
233
|
-
declare function mapIntentToHeroUiColor(intent: TSemanticIntent | undefined): THeroUiColor | undefined;
|
|
234
|
-
/**
|
|
235
|
-
* Map a Mantine palette colour (`shared_color`) onto a HeroUI Native semantic
|
|
187
|
+
* Map a Mantine palette colour (`color`) onto a HeroUI Native semantic
|
|
236
188
|
* colour (Chip / Tag / status surfaces). The Mantine palette is broad; it
|
|
237
189
|
* collapses onto HeroUI's five semantic colours by hue family:
|
|
238
190
|
* red/pink -> danger
|
|
@@ -243,14 +195,14 @@ declare function mapIntentToHeroUiColor(intent: TSemanticIntent | undefined): TH
|
|
|
243
195
|
*/
|
|
244
196
|
declare function mapMantineColorToHeroUiColor(color: TSemanticColor | undefined): THeroUiColor | undefined;
|
|
245
197
|
/**
|
|
246
|
-
* Map a Mantine palette colour (`
|
|
247
|
-
* variant when no explicit `
|
|
198
|
+
* Map a Mantine palette colour (`color`) onto a HeroUI Native **Button**
|
|
199
|
+
* variant when no explicit `variant` is authored. HeroUI buttons encode
|
|
248
200
|
* colour in the variant, so the destructive hue becomes `danger`, neutral hues
|
|
249
201
|
* become `secondary`, and everything else stays the prominent `primary`.
|
|
250
202
|
*/
|
|
251
203
|
declare function mapMantineColorToHeroUiButtonVariant(color: TSemanticColor | undefined): THeroUiButtonVariant | undefined;
|
|
252
204
|
/**
|
|
253
|
-
* Map a Mantine variant (`
|
|
205
|
+
* Map a Mantine variant (`variant`) onto the HeroUI Native Button
|
|
254
206
|
* vocabulary:
|
|
255
207
|
* filled / gradient -> primary
|
|
256
208
|
* light / white / default -> secondary
|
|
@@ -259,14 +211,14 @@ declare function mapMantineColorToHeroUiButtonVariant(color: TSemanticColor | un
|
|
|
259
211
|
*/
|
|
260
212
|
declare function mapMantineVariantToHeroUiButtonVariant(variant: TSemanticVariant | undefined): THeroUiButtonVariant | undefined;
|
|
261
213
|
/**
|
|
262
|
-
* Map the accordion variant token (`
|
|
214
|
+
* Map the accordion variant token (`accordion_variant`: Mantine
|
|
263
215
|
* default/contained/filled/separated) onto the HeroUI Native Accordion `variant`
|
|
264
216
|
* vocabulary. HeroUI Native only has `default` (plain list) and `surface`
|
|
265
217
|
* (grouped container), so every "boxed" Mantine variant collapses to `surface`.
|
|
266
218
|
*/
|
|
267
219
|
declare function mapAccordionVariantToHeroUiVariant(variant: string | undefined): 'default' | 'surface';
|
|
268
220
|
/**
|
|
269
|
-
* Map the chip variant token (`
|
|
221
|
+
* Map the chip variant token (`chip_variant`: Mantine
|
|
270
222
|
* filled/outline/light) onto the HeroUI Native Chip `variant` vocabulary
|
|
271
223
|
* (`primary`/`secondary`/`tertiary`/`soft`):
|
|
272
224
|
* - filled -> primary (solid accent fill)
|
|
@@ -277,8 +229,8 @@ declare function mapChipVariantToHeroUiVariant(variant: string | undefined): 'pr
|
|
|
277
229
|
/** A React Native-safe dimension: a px number, a percentage string, or "auto". */
|
|
278
230
|
type TReactNativeDimension = number | `${number}%` | 'auto';
|
|
279
231
|
/**
|
|
280
|
-
* Parse a CMS dimension string (`shared_width`/`shared_height`/`
|
|
281
|
-
* `
|
|
232
|
+
* Parse a CMS dimension string (`shared_width`/`shared_height`/`mih`/`miw`/
|
|
233
|
+
* `mah`/`maw`) into a React Native-safe value. Web (Mantine) accepts the raw
|
|
282
234
|
* string verbatim ("320px", "100%", "auto"); React Native does NOT accept a
|
|
283
235
|
* unit suffix, so a px value must become a unitless number:
|
|
284
236
|
* "320px" | "320" | 320 -> 320 (number)
|
|
@@ -309,7 +261,7 @@ interface IReactNativeGridColumn {
|
|
|
309
261
|
*/
|
|
310
262
|
declare function gridSpanToReactNativeColumn(span: string | number | undefined | null, cols?: number): IReactNativeGridColumn;
|
|
311
263
|
/**
|
|
312
|
-
* Map a `
|
|
264
|
+
* Map a `divider_variant` (solid/dashed/dotted) onto a React Native
|
|
313
265
|
* `borderStyle`. The vocabularies are identical, so this validates the domain
|
|
314
266
|
* and falls back to 'solid'.
|
|
315
267
|
*/
|
|
@@ -330,10 +282,9 @@ declare function toMantineSemanticProps(props: ISharedStyleProps): IMantineResol
|
|
|
330
282
|
*
|
|
331
283
|
* Appearance precedence (mirrors the web renderer, which reads the same CMS
|
|
332
284
|
* fields straight into Mantine):
|
|
333
|
-
* 1. `
|
|
334
|
-
* 2. else `
|
|
335
|
-
*
|
|
336
|
-
* The semantic `color` is resolved from `shared_color` first, then `intent`.
|
|
285
|
+
* 1. `variant` (Mantine variant) mapped onto the HeroUI button vocab;
|
|
286
|
+
* 2. else `color` (Mantine palette) mapped onto a button variant.
|
|
287
|
+
* The semantic `color` is resolved from `color`.
|
|
337
288
|
*/
|
|
338
289
|
declare function toHeroUiSemanticProps(props: ISharedStyleProps): IHeroUiResolvedStyle;
|
|
339
290
|
/**
|
|
@@ -363,10 +314,10 @@ declare const resolveSharedStyleForMobile: typeof toHeroUiSemanticProps;
|
|
|
363
314
|
* SCOPE — this is NOT the semantic mapper (`semantic.ts`). The two have
|
|
364
315
|
* different input domains and both live here so there is exactly one home
|
|
365
316
|
* for style mapping:
|
|
366
|
-
* - `semantic.ts` maps renderer-agnostic
|
|
367
|
-
* (`
|
|
317
|
+
* - `semantic.ts` maps renderer-agnostic unprefixed portable fields
|
|
318
|
+
* (`color` / `variant` / `size` / `radius` / `spacing`) per platform.
|
|
368
319
|
* - `mantineVariant.ts` resolves a Mantine palette `color` + `variant` value
|
|
369
|
-
* pair (e.g. the
|
|
320
|
+
* pair (e.g. the portable `color` + `variant`)
|
|
370
321
|
* into concrete RGB. Its only runtime
|
|
371
322
|
* consumer today is the mobile **Expo Web preview**
|
|
372
323
|
* fallback (where `heroui-native` cannot render and the
|
|
@@ -394,4 +345,4 @@ interface IResolvedVariant {
|
|
|
394
345
|
}
|
|
395
346
|
declare function resolveMantineVariant(variant: string | undefined, color: string | undefined): IResolvedVariant;
|
|
396
347
|
|
|
397
|
-
export { COLOR_PALETTE, COLOR_SCALES, CONTAINER_SIZE_PX, FONT_SIZE_PX, FULL_RADIUS_PX, type IHeroUiResolvedStyle, type IMantineResolvedStyle, type IReactNativeGridColumn, 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
|
|
348
|
+
export { COLOR_PALETTE, COLOR_SCALES, CONTAINER_SIZE_PX, FONT_SIZE_PX, FULL_RADIUS_PX, type IHeroUiResolvedStyle, type IMantineResolvedStyle, type IReactNativeGridColumn, 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 TReactNativeDimension, type TSemanticColor, type TSemanticRadius, type TSemanticSize, type TSemanticSpacing, type TSemanticState, type TSemanticVariant, colorToHex, gridSpanToReactNativeColumn, mapAccordionVariantToHeroUiVariant, mapChipVariantToHeroUiVariant, mapDividerVariantToReactNative, mapMantineColorToHeroUiButtonVariant, mapMantineColorToHeroUiColor, mapMantineVariantToHeroUiButtonVariant, mapRadiusToMantine, mapRadiusToPx, mapSizeToHeroUi, mapSizeToMantine, mapSpacingToPx, parseDimensionToReactNative, parseDimensionToWeb, radiusToPx, resolveMantineVariant, resolveSharedStyle, resolveSharedStyleForMobile, resolveSharedStyleForWeb, resolveSharedStyleProps, sizeToFontPx, spacingToPx, toHeroUiSemanticProps, toMantineSemanticProps, toReactNativeSemanticStyle };
|