@tonycodes-ui/mortar 0.20.0 → 0.22.0

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/cli/data.mjs CHANGED
@@ -40,6 +40,11 @@ export const GUIDES = {
40
40
  summary:
41
41
  "Transactional email from @tonycodes-ui/mortar/email: emailTheme, the Email components, the templates (verify email, magic link, password reset, invite, receipt, notification) and renderEmail.",
42
42
  },
43
+ native: {
44
+ file: "docs/native.md",
45
+ summary:
46
+ "Mortar for SwiftUI (iPhone, iPad, Mac) and Jetpack Compose (Android): install, MortarTheme and brands, the native components and their web equivalents, the generated tokens and snapshot tests.",
47
+ },
43
48
  "migrating-0.6": {
44
49
  file: "docs/migrating-to-0.6.md",
45
50
  summary: "Every prop and markup change from 0.5 to 0.6.",
package/cli/mcp.mjs CHANGED
@@ -30,7 +30,7 @@ class RpcError extends Error {
30
30
  }
31
31
 
32
32
  const INSTRUCTIONS =
33
- "Mortar is an MIT React 19 + Tailwind 4 UI kit (@tonycodes-ui/mortar). Before writing UI, search_components (or list_kits) to find what to reuse, then get_build_packet for the components or the brief and compose from it: start from the purpose shell (AppShell, MarketingHeader, DocsShell, AuthLayout), use named imports and the exact props in each contract, theme through ThemeProvider and tokens, never copy components or override .m-* classes. For transactional emails, use @tonycodes-ui/mortar/email (get_guide email), never the app components. Run audit_app on the application when done and fix its findings. Missing shared patterns are contributed to the kit by GitHub pull request (get_guide contributing).";
33
+ "Mortar is an MIT React 19 + Tailwind 4 UI kit (@tonycodes-ui/mortar). Before writing UI, search_components (or list_kits) to find what to reuse, then get_build_packet for the components or the brief and compose from it: start from the purpose shell (AppShell, MarketingHeader, DocsShell, AuthLayout), use named imports and the exact props in each contract, theme through ThemeProvider and tokens, never copy components or override .m-* classes. For transactional emails, use @tonycodes-ui/mortar/email (get_guide email), never the app components. For iOS, iPadOS and Android apps, use the SwiftUI package and Compose library (get_guide native); each component's contract names its native equivalent. Run audit_app on the application when done and fix its findings. Missing shared patterns are contributed to the kit by GitHub pull request (get_guide contributing).";
34
34
 
35
35
  /**
36
36
  * Handle one parsed JSON-RPC message. Returns the response object, or
package/cli/packet.mjs CHANGED
@@ -14,6 +14,36 @@ export const THEME_SETUP = `import { ThemeProvider } from "@tonycodes-ui/mortar"
14
14
  const importLine = (data, names) =>
15
15
  `import { ${[...new Set(names)].sort().join(", ")} } from "${data.packageName}";`;
16
16
 
17
+ // The native libraries (docs/native.md): a Swift package and an Android
18
+ // library, built from the same tokens.
19
+ export const NATIVE = {
20
+ swiftui: {
21
+ package: "https://github.com/tonycodes/mortar",
22
+ import: "import Mortar",
23
+ theme: ".mortarTheme(.neutral)",
24
+ },
25
+ compose: {
26
+ package: "codes.tony:mortar",
27
+ import: "import codes.tony.mortar.*",
28
+ theme: "MortarTheme(brand = MortarBrand.Neutral) { … }",
29
+ },
30
+ };
31
+
32
+ /** A component's SwiftUI and Compose equivalents, from its manifest. */
33
+ const nativeDetail = (platforms) =>
34
+ Object.fromEntries(
35
+ Object.entries(platforms).map(([platform, name]) => [
36
+ platform,
37
+ {
38
+ name,
39
+ import:
40
+ platform === "compose"
41
+ ? `import codes.tony.mortar.${name}`
42
+ : NATIVE.swiftui.import,
43
+ },
44
+ ]),
45
+ );
46
+
17
47
  /** The full contract of one component, as get_component returns it. */
18
48
  export function componentDetail(data, c, { example = true } = {}) {
19
49
  const p = data.placement(c);
@@ -46,6 +76,7 @@ export function componentDetail(data, c, { example = true } = {}) {
46
76
  avoid: c.contract.avoid,
47
77
  accessibility: c.contract.accessibility,
48
78
  capabilities: c.capabilities,
79
+ ...(c.platforms ? { native: nativeDetail(c.platforms) } : {}),
49
80
  dependencies: (c.contract.dependencies ?? [])
50
81
  .map((id) => data.byId(id)?.export ?? id)
51
82
  .sort(),
@@ -137,6 +168,11 @@ const PURPOSES = [
137
168
  const EMAIL_WORDS =
138
169
  /\b(?:(?:transactional|verification|verify|welcome|invite|invitation|receipt|order confirmation|confirmation|password reset|reset|magic[\s-]link|sign[\s-]in|notification|digest|billing)\s+e-?mails?|e-?mail\s+templates?)\b/i;
139
170
 
171
+ // A brief for an iOS, iPadOS or Android app. The native libraries mirror a
172
+ // core set of components, so the packet lists them.
173
+ const NATIVE_WORDS =
174
+ /\b(?:ios|ipados|iphone|ipad|android|swift(?:ui)?|jetpack compose|kotlin|(?:native|mobile)\s+apps?)\b/i;
175
+
140
176
  /** Pick components for a free-text brief, with the reason for each. */
141
177
  export function chooseForBrief(data, brief) {
142
178
  const purposes = PURPOSES.filter((p) => p.words.test(brief));
@@ -214,6 +250,8 @@ export function buildPacket(data, { components: names = [], brief } = {}) {
214
250
  guides.push("auth-flows");
215
251
  const emails = !!brief && EMAIL_WORDS.test(brief);
216
252
  if (emails) guides.push("email");
253
+ const native = !!brief && NATIVE_WORDS.test(brief);
254
+ if (native) guides.push("native");
217
255
  return {
218
256
  package: data.packageName,
219
257
  version: data.version,
@@ -273,6 +311,19 @@ export function buildPacket(data, { components: names = [], brief } = {}) {
273
311
  },
274
312
  }
275
313
  : {}),
314
+ ...(native
315
+ ? {
316
+ native: {
317
+ swiftui: NATIVE.swiftui,
318
+ compose: NATIVE.compose,
319
+ components: data.components
320
+ .filter((c) => c.platforms)
321
+ .map((c) => ({ web: c.export, ...c.platforms })),
322
+ notes:
323
+ "The native libraries mirror these core components with the same props in each platform's idiom, themed from the same tokens. Everything else is web only: build it from the platform's own controls styled with MortarTokens, or contribute it (get_guide native).",
324
+ },
325
+ }
326
+ : {}),
276
327
  guides,
277
328
  next: [
278
329
  "Compose with named imports from the package; keep product names, data, routes and actions in props and slots.",