@selfhelp/shared 1.14.23 → 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 +37 -0
- package/dist/{common-udJ0O8qC.d.mts → common-qaDIAYS3.d.mts} +5 -4
- package/dist/{common-udJ0O8qC.d.ts → common-qaDIAYS3.d.ts} +5 -4
- package/dist/index.d.mts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +94 -170
- package/dist/index.mjs +94 -167
- 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-CZZwODJY.d.mts → styles.registry-4W0LzmZB.d.mts} +2 -189
- package/dist/{styles.registry-DQKcvIBZ.d.ts → styles.registry-D6xMm5VR.d.ts} +2 -189
- package/dist/theme/index.d.mts +27 -76
- package/dist/theme/index.d.ts +27 -76
- package/dist/theme/index.js +4 -80
- package/dist/theme/index.mjs +4 -77
- 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 +16 -53
- package/src/theme/mantineVariant.ts +3 -3
- package/src/theme/semantic.ts +24 -164
- package/src/theme/tokens.ts +2 -2
- package/src/types/mantine/common.ts +4 -3
- package/src/types/styles/base.ts +1 -1
- package/src/types/styles/composite.ts +0 -2
package/dist/theme/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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
|
/**
|
|
@@ -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`)
|
|
@@ -75,14 +76,15 @@ declare function colorToHex(name: string | undefined, shade?: number): string |
|
|
|
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
97
|
* Cross-platform colour + variant authored in the CMS (`color` /
|
|
97
|
-
* `variant`)
|
|
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.
|
|
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;
|
|
@@ -118,24 +117,18 @@ interface ISharedStyleProps {
|
|
|
118
117
|
color?: TSemanticColor;
|
|
119
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;
|
|
@@ -190,47 +183,6 @@ declare function mapRadiusToPx(radius: TSemanticRadius | undefined): number | un
|
|
|
190
183
|
declare function mapRadiusToMantine(radius: TSemanticRadius | undefined): TSemanticSize | number | undefined;
|
|
191
184
|
/** Resolve a semantic spacing token to px (none => 0). */
|
|
192
185
|
declare function mapSpacingToPx(spacing: TSemanticSpacing | undefined): number | undefined;
|
|
193
|
-
/**
|
|
194
|
-
* Map a semantic intent to a Mantine `{ color, variant }` pair.
|
|
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
186
|
/**
|
|
235
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
|
|
@@ -331,9 +283,8 @@ declare function toMantineSemanticProps(props: ISharedStyleProps): IMantineResol
|
|
|
331
283
|
* Appearance precedence (mirrors the web renderer, which reads the same CMS
|
|
332
284
|
* fields straight into Mantine):
|
|
333
285
|
* 1. `variant` (Mantine variant) mapped onto the HeroUI button vocab;
|
|
334
|
-
* 2. else `color` (Mantine palette) mapped onto a button variant
|
|
335
|
-
*
|
|
336
|
-
* The semantic `color` is resolved from `color` first, then `intent`.
|
|
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,4 +1,4 @@
|
|
|
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
|
/**
|
|
@@ -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`)
|
|
@@ -75,14 +76,15 @@ declare function colorToHex(name: string | undefined, shade?: number): string |
|
|
|
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
97
|
* Cross-platform colour + variant authored in the CMS (`color` /
|
|
97
|
-
* `variant`)
|
|
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.
|
|
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;
|
|
@@ -118,24 +117,18 @@ interface ISharedStyleProps {
|
|
|
118
117
|
color?: TSemanticColor;
|
|
119
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;
|
|
@@ -190,47 +183,6 @@ declare function mapRadiusToPx(radius: TSemanticRadius | undefined): number | un
|
|
|
190
183
|
declare function mapRadiusToMantine(radius: TSemanticRadius | undefined): TSemanticSize | number | undefined;
|
|
191
184
|
/** Resolve a semantic spacing token to px (none => 0). */
|
|
192
185
|
declare function mapSpacingToPx(spacing: TSemanticSpacing | undefined): number | undefined;
|
|
193
|
-
/**
|
|
194
|
-
* Map a semantic intent to a Mantine `{ color, variant }` pair.
|
|
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
186
|
/**
|
|
235
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
|
|
@@ -331,9 +283,8 @@ declare function toMantineSemanticProps(props: ISharedStyleProps): IMantineResol
|
|
|
331
283
|
* Appearance precedence (mirrors the web renderer, which reads the same CMS
|
|
332
284
|
* fields straight into Mantine):
|
|
333
285
|
* 1. `variant` (Mantine variant) mapped onto the HeroUI button vocab;
|
|
334
|
-
* 2. else `color` (Mantine palette) mapped onto a button variant
|
|
335
|
-
*
|
|
336
|
-
* The semantic `color` is resolved from `color` first, then `intent`.
|
|
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.js
CHANGED
|
@@ -34,9 +34,6 @@ __export(theme_exports, {
|
|
|
34
34
|
mapAccordionVariantToHeroUiVariant: () => mapAccordionVariantToHeroUiVariant,
|
|
35
35
|
mapChipVariantToHeroUiVariant: () => mapChipVariantToHeroUiVariant,
|
|
36
36
|
mapDividerVariantToReactNative: () => mapDividerVariantToReactNative,
|
|
37
|
-
mapIntentToHeroUiButtonVariant: () => mapIntentToHeroUiButtonVariant,
|
|
38
|
-
mapIntentToHeroUiColor: () => mapIntentToHeroUiColor,
|
|
39
|
-
mapIntentToMantine: () => mapIntentToMantine,
|
|
40
37
|
mapMantineColorToHeroUiButtonVariant: () => mapMantineColorToHeroUiButtonVariant,
|
|
41
38
|
mapMantineColorToHeroUiColor: () => mapMantineColorToHeroUiColor,
|
|
42
39
|
mapMantineVariantToHeroUiButtonVariant: () => mapMantineVariantToHeroUiButtonVariant,
|
|
@@ -214,14 +211,6 @@ var sharedTailwindPreset = {
|
|
|
214
211
|
var FULL_RADIUS_PX = 9999;
|
|
215
212
|
var SEMANTIC_SIZES = ["sm", "md", "lg"];
|
|
216
213
|
var SEMANTIC_RADII = ["none", "sm", "md", "lg", "full"];
|
|
217
|
-
var SEMANTIC_INTENTS = [
|
|
218
|
-
"primary",
|
|
219
|
-
"secondary",
|
|
220
|
-
"success",
|
|
221
|
-
"warning",
|
|
222
|
-
"danger",
|
|
223
|
-
"neutral"
|
|
224
|
-
];
|
|
225
214
|
function mapSizeToMantine(size) {
|
|
226
215
|
return size;
|
|
227
216
|
}
|
|
@@ -277,63 +266,6 @@ function mapSpacingToPx(spacing2) {
|
|
|
277
266
|
if (spacing2 === "none") return 0;
|
|
278
267
|
return SPACING_PX[spacing2];
|
|
279
268
|
}
|
|
280
|
-
function mapIntentToMantine(intent) {
|
|
281
|
-
if (!intent) return void 0;
|
|
282
|
-
switch (intent) {
|
|
283
|
-
case "primary":
|
|
284
|
-
return { color: "blue", variant: "filled" };
|
|
285
|
-
case "secondary":
|
|
286
|
-
return { color: "gray", variant: "light" };
|
|
287
|
-
case "success":
|
|
288
|
-
return { color: "green", variant: "filled" };
|
|
289
|
-
case "warning":
|
|
290
|
-
return { color: "yellow", variant: "filled" };
|
|
291
|
-
case "danger":
|
|
292
|
-
return { color: "red", variant: "filled" };
|
|
293
|
-
case "neutral":
|
|
294
|
-
return { color: "gray", variant: "default" };
|
|
295
|
-
default:
|
|
296
|
-
return void 0;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
function mapIntentToHeroUiButtonVariant(intent) {
|
|
300
|
-
if (!intent) return void 0;
|
|
301
|
-
switch (intent) {
|
|
302
|
-
case "primary":
|
|
303
|
-
return "primary";
|
|
304
|
-
case "secondary":
|
|
305
|
-
return "secondary";
|
|
306
|
-
case "success":
|
|
307
|
-
return "primary";
|
|
308
|
-
case "warning":
|
|
309
|
-
return "primary";
|
|
310
|
-
case "danger":
|
|
311
|
-
return "danger";
|
|
312
|
-
case "neutral":
|
|
313
|
-
return "secondary";
|
|
314
|
-
default:
|
|
315
|
-
return void 0;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
function mapIntentToHeroUiColor(intent) {
|
|
319
|
-
if (!intent) return void 0;
|
|
320
|
-
switch (intent) {
|
|
321
|
-
case "primary":
|
|
322
|
-
return "accent";
|
|
323
|
-
case "secondary":
|
|
324
|
-
return "default";
|
|
325
|
-
case "success":
|
|
326
|
-
return "success";
|
|
327
|
-
case "warning":
|
|
328
|
-
return "warning";
|
|
329
|
-
case "danger":
|
|
330
|
-
return "danger";
|
|
331
|
-
case "neutral":
|
|
332
|
-
return "default";
|
|
333
|
-
default:
|
|
334
|
-
return void 0;
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
269
|
function mapMantineColorToHeroUiColor(color) {
|
|
338
270
|
if (!color) return void 0;
|
|
339
271
|
switch (color) {
|
|
@@ -481,10 +413,6 @@ function resolveSharedStyleProps(fields) {
|
|
|
481
413
|
if (variant !== void 0) {
|
|
482
414
|
resolved.variant = variant;
|
|
483
415
|
}
|
|
484
|
-
const intent = readString(fields.shared_intent);
|
|
485
|
-
if (intent !== void 0 && SEMANTIC_INTENTS.includes(intent)) {
|
|
486
|
-
resolved.intent = intent;
|
|
487
|
-
}
|
|
488
416
|
const fullWidth = readBool(fields.full_width);
|
|
489
417
|
if (fullWidth !== void 0) {
|
|
490
418
|
resolved.fullWidth = fullWidth;
|
|
@@ -492,12 +420,11 @@ function resolveSharedStyleProps(fields) {
|
|
|
492
420
|
return resolved;
|
|
493
421
|
}
|
|
494
422
|
function toMantineSemanticProps(props) {
|
|
495
|
-
const intent = mapIntentToMantine(props.intent);
|
|
496
423
|
const spacing2 = props.spacing && props.spacing !== "none" ? props.spacing : void 0;
|
|
497
424
|
return {
|
|
498
425
|
size: mapSizeToMantine(props.size),
|
|
499
|
-
color:
|
|
500
|
-
variant:
|
|
426
|
+
color: props.color,
|
|
427
|
+
variant: props.variant,
|
|
501
428
|
radius: mapRadiusToMantine(props.radius),
|
|
502
429
|
spacing: spacing2,
|
|
503
430
|
disabled: hasState(props.states, "disabled") || void 0,
|
|
@@ -508,8 +435,8 @@ function toMantineSemanticProps(props) {
|
|
|
508
435
|
};
|
|
509
436
|
}
|
|
510
437
|
function toHeroUiSemanticProps(props) {
|
|
511
|
-
const buttonVariant = mapMantineVariantToHeroUiButtonVariant(props.variant) ?? mapMantineColorToHeroUiButtonVariant(props.color)
|
|
512
|
-
const color = mapMantineColorToHeroUiColor(props.color)
|
|
438
|
+
const buttonVariant = mapMantineVariantToHeroUiButtonVariant(props.variant) ?? mapMantineColorToHeroUiButtonVariant(props.color);
|
|
439
|
+
const color = mapMantineColorToHeroUiColor(props.color);
|
|
513
440
|
return {
|
|
514
441
|
size: mapSizeToHeroUi(props.size),
|
|
515
442
|
buttonVariant,
|
|
@@ -651,9 +578,6 @@ function resolveMantineVariant(variant, color) {
|
|
|
651
578
|
mapAccordionVariantToHeroUiVariant,
|
|
652
579
|
mapChipVariantToHeroUiVariant,
|
|
653
580
|
mapDividerVariantToReactNative,
|
|
654
|
-
mapIntentToHeroUiButtonVariant,
|
|
655
|
-
mapIntentToHeroUiColor,
|
|
656
|
-
mapIntentToMantine,
|
|
657
581
|
mapMantineColorToHeroUiButtonVariant,
|
|
658
582
|
mapMantineColorToHeroUiColor,
|
|
659
583
|
mapMantineVariantToHeroUiButtonVariant,
|
package/dist/theme/index.mjs
CHANGED
|
@@ -149,14 +149,6 @@ var sharedTailwindPreset = {
|
|
|
149
149
|
var FULL_RADIUS_PX = 9999;
|
|
150
150
|
var SEMANTIC_SIZES = ["sm", "md", "lg"];
|
|
151
151
|
var SEMANTIC_RADII = ["none", "sm", "md", "lg", "full"];
|
|
152
|
-
var SEMANTIC_INTENTS = [
|
|
153
|
-
"primary",
|
|
154
|
-
"secondary",
|
|
155
|
-
"success",
|
|
156
|
-
"warning",
|
|
157
|
-
"danger",
|
|
158
|
-
"neutral"
|
|
159
|
-
];
|
|
160
152
|
function mapSizeToMantine(size) {
|
|
161
153
|
return size;
|
|
162
154
|
}
|
|
@@ -212,63 +204,6 @@ function mapSpacingToPx(spacing2) {
|
|
|
212
204
|
if (spacing2 === "none") return 0;
|
|
213
205
|
return SPACING_PX[spacing2];
|
|
214
206
|
}
|
|
215
|
-
function mapIntentToMantine(intent) {
|
|
216
|
-
if (!intent) return void 0;
|
|
217
|
-
switch (intent) {
|
|
218
|
-
case "primary":
|
|
219
|
-
return { color: "blue", variant: "filled" };
|
|
220
|
-
case "secondary":
|
|
221
|
-
return { color: "gray", variant: "light" };
|
|
222
|
-
case "success":
|
|
223
|
-
return { color: "green", variant: "filled" };
|
|
224
|
-
case "warning":
|
|
225
|
-
return { color: "yellow", variant: "filled" };
|
|
226
|
-
case "danger":
|
|
227
|
-
return { color: "red", variant: "filled" };
|
|
228
|
-
case "neutral":
|
|
229
|
-
return { color: "gray", variant: "default" };
|
|
230
|
-
default:
|
|
231
|
-
return void 0;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
function mapIntentToHeroUiButtonVariant(intent) {
|
|
235
|
-
if (!intent) return void 0;
|
|
236
|
-
switch (intent) {
|
|
237
|
-
case "primary":
|
|
238
|
-
return "primary";
|
|
239
|
-
case "secondary":
|
|
240
|
-
return "secondary";
|
|
241
|
-
case "success":
|
|
242
|
-
return "primary";
|
|
243
|
-
case "warning":
|
|
244
|
-
return "primary";
|
|
245
|
-
case "danger":
|
|
246
|
-
return "danger";
|
|
247
|
-
case "neutral":
|
|
248
|
-
return "secondary";
|
|
249
|
-
default:
|
|
250
|
-
return void 0;
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
function mapIntentToHeroUiColor(intent) {
|
|
254
|
-
if (!intent) return void 0;
|
|
255
|
-
switch (intent) {
|
|
256
|
-
case "primary":
|
|
257
|
-
return "accent";
|
|
258
|
-
case "secondary":
|
|
259
|
-
return "default";
|
|
260
|
-
case "success":
|
|
261
|
-
return "success";
|
|
262
|
-
case "warning":
|
|
263
|
-
return "warning";
|
|
264
|
-
case "danger":
|
|
265
|
-
return "danger";
|
|
266
|
-
case "neutral":
|
|
267
|
-
return "default";
|
|
268
|
-
default:
|
|
269
|
-
return void 0;
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
207
|
function mapMantineColorToHeroUiColor(color) {
|
|
273
208
|
if (!color) return void 0;
|
|
274
209
|
switch (color) {
|
|
@@ -416,10 +351,6 @@ function resolveSharedStyleProps(fields) {
|
|
|
416
351
|
if (variant !== void 0) {
|
|
417
352
|
resolved.variant = variant;
|
|
418
353
|
}
|
|
419
|
-
const intent = readString(fields.shared_intent);
|
|
420
|
-
if (intent !== void 0 && SEMANTIC_INTENTS.includes(intent)) {
|
|
421
|
-
resolved.intent = intent;
|
|
422
|
-
}
|
|
423
354
|
const fullWidth = readBool(fields.full_width);
|
|
424
355
|
if (fullWidth !== void 0) {
|
|
425
356
|
resolved.fullWidth = fullWidth;
|
|
@@ -427,12 +358,11 @@ function resolveSharedStyleProps(fields) {
|
|
|
427
358
|
return resolved;
|
|
428
359
|
}
|
|
429
360
|
function toMantineSemanticProps(props) {
|
|
430
|
-
const intent = mapIntentToMantine(props.intent);
|
|
431
361
|
const spacing2 = props.spacing && props.spacing !== "none" ? props.spacing : void 0;
|
|
432
362
|
return {
|
|
433
363
|
size: mapSizeToMantine(props.size),
|
|
434
|
-
color:
|
|
435
|
-
variant:
|
|
364
|
+
color: props.color,
|
|
365
|
+
variant: props.variant,
|
|
436
366
|
radius: mapRadiusToMantine(props.radius),
|
|
437
367
|
spacing: spacing2,
|
|
438
368
|
disabled: hasState(props.states, "disabled") || void 0,
|
|
@@ -443,8 +373,8 @@ function toMantineSemanticProps(props) {
|
|
|
443
373
|
};
|
|
444
374
|
}
|
|
445
375
|
function toHeroUiSemanticProps(props) {
|
|
446
|
-
const buttonVariant = mapMantineVariantToHeroUiButtonVariant(props.variant) ?? mapMantineColorToHeroUiButtonVariant(props.color)
|
|
447
|
-
const color = mapMantineColorToHeroUiColor(props.color)
|
|
376
|
+
const buttonVariant = mapMantineVariantToHeroUiButtonVariant(props.variant) ?? mapMantineColorToHeroUiButtonVariant(props.color);
|
|
377
|
+
const color = mapMantineColorToHeroUiColor(props.color);
|
|
448
378
|
return {
|
|
449
379
|
size: mapSizeToHeroUi(props.size),
|
|
450
380
|
buttonVariant,
|
|
@@ -585,9 +515,6 @@ export {
|
|
|
585
515
|
mapAccordionVariantToHeroUiVariant,
|
|
586
516
|
mapChipVariantToHeroUiVariant,
|
|
587
517
|
mapDividerVariantToReactNative,
|
|
588
|
-
mapIntentToHeroUiButtonVariant,
|
|
589
|
-
mapIntentToHeroUiColor,
|
|
590
|
-
mapIntentToMantine,
|
|
591
518
|
mapMantineColorToHeroUiButtonVariant,
|
|
592
519
|
mapMantineColorToHeroUiColor,
|
|
593
520
|
mapMantineVariantToHeroUiButtonVariant,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@selfhelp/shared",
|
|
3
|
-
"version": "1.14.
|
|
3
|
+
"version": "1.14.24",
|
|
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",
|
package/src/plugin-sdk/define.ts
CHANGED