@forthtilliath/react-native-kit 0.2.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/LICENSE +21 -0
- package/README.md +88 -0
- package/dist/ChangelogNotes.d.ts +22 -0
- package/dist/ChangelogNotes.d.ts.map +1 -0
- package/dist/ChangelogNotes.js +40 -0
- package/package.json +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Forthtilliath
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# @forthtilliath/react-native-kit
|
|
2
|
+
|
|
3
|
+
Small, dependency-free-of-app-theme React Native UI components, distributed one file per component so consumers only pull in what they use.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @forthtilliath/react-native-kit react react-native
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or, from within this monorepo, as a workspace dependency:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@forthtilliath/react-native-kit": "workspace:*"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`react` and `react-native` are peer dependencies — install them in the consuming app if not already present.
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Each component is its own module — import the file you need directly:
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { ChangelogNotes } from "@forthtilliath/react-native-kit/ChangelogNotes";
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### `<ChangelogNotes notes={...} styles={...} />`
|
|
32
|
+
|
|
33
|
+
Renders GitHub-style release notes — as produced by `@forthtilliath/expo-release-updates`'s `parseChangelogNotes` — as headings, bulleted items, and bold-aware text, instead of showing the raw Markdown syntax in a plain `Text`.
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
<ChangelogNotes notes={release.notes} />
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
It understands the small subset of Markdown GitHub release notes actually use:
|
|
40
|
+
|
|
41
|
+
| `notes` input | Rendered as |
|
|
42
|
+
| ----------------------------------------- | --------------------------------------------------------------------------- |
|
|
43
|
+
| `### Added` | a heading `Text` — `"Added"` |
|
|
44
|
+
| `- Export history to CSV.` | a row (`View`) with a `•` bullet `Text` and an item `Text` |
|
|
45
|
+
| `**Auto-backup**: saves every 5 minutes.` | a plain `Text`, with the bold segment split into its own bold-styled `Text` |
|
|
46
|
+
|
|
47
|
+
A full example, mixing all three:
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
<ChangelogNotes
|
|
51
|
+
notes={`### Added\n- **Auto-backup**: saves every 5 minutes.\n- Export history to CSV.\n\nSee the full changelog for details.`}
|
|
52
|
+
/>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The component ships with neutral default styles and no opinion on your app's theme. Override any subset via the `styles` prop to match your colors/dark mode:
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
<ChangelogNotes
|
|
59
|
+
notes={release.notes}
|
|
60
|
+
styles={{
|
|
61
|
+
heading: { color: colors.text, fontWeight: "700" },
|
|
62
|
+
itemRow: { gap: 8 },
|
|
63
|
+
bullet: { color: colors.primary },
|
|
64
|
+
itemText: { color: colors.textMuted },
|
|
65
|
+
text: { color: colors.textMuted },
|
|
66
|
+
bold: { color: colors.text, fontWeight: "700" },
|
|
67
|
+
}}
|
|
68
|
+
/>
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Every field of `styles` is optional — pass only the ones you want to override; the rest fall back to the defaults (`ChangelogNotesStyles` in `ChangelogNotes.tsx`).
|
|
72
|
+
|
|
73
|
+
## Scripts
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pnpm run dev # tsc --watch -> dist/
|
|
77
|
+
pnpm run build # tsc -> dist/
|
|
78
|
+
pnpm run check-types # tsc --noEmit
|
|
79
|
+
pnpm run lint # eslint
|
|
80
|
+
pnpm run test # vitest run
|
|
81
|
+
pnpm run test:watch # vitest
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Built to `dist/` (see the `exports` field in `package.json`), so run `pnpm run build` (or `dev`) after source changes for consumers to see them.
|
|
85
|
+
|
|
86
|
+
### Testing note
|
|
87
|
+
|
|
88
|
+
`react-native`'s package entry uses Flow syntax that `@babel/parser`'s flow plugin can't parse (`as Cast` casts aren't supported there), so Vitest can never load the real package directly. Tests alias `react-native` to a minimal stub (`src/__mocks__/react-native.tsx`) instead — see that file for details.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { StyleProp, TextStyle, ViewStyle } from "react-native";
|
|
2
|
+
export interface ChangelogNotesStyles {
|
|
3
|
+
heading?: StyleProp<TextStyle>;
|
|
4
|
+
itemRow?: StyleProp<ViewStyle>;
|
|
5
|
+
bullet?: StyleProp<TextStyle>;
|
|
6
|
+
itemText?: StyleProp<TextStyle>;
|
|
7
|
+
text?: StyleProp<TextStyle>;
|
|
8
|
+
bold?: StyleProp<TextStyle>;
|
|
9
|
+
}
|
|
10
|
+
export interface ChangelogNotesProps {
|
|
11
|
+
/** Raw release notes, e.g. straight from a GitHub release body. */
|
|
12
|
+
notes: string;
|
|
13
|
+
/** Override any of the default styles to match your app's theme. */
|
|
14
|
+
styles?: ChangelogNotesStyles;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Renders GitHub-style release notes (parsed by `parseChangelogNotes`) as
|
|
18
|
+
* headings, bulleted items and bold-aware text, instead of showing the raw
|
|
19
|
+
* Markdown syntax in a plain `<Text>`.
|
|
20
|
+
*/
|
|
21
|
+
export declare function ChangelogNotes({ notes, styles }: ChangelogNotesProps): import("react").JSX.Element;
|
|
22
|
+
//# sourceMappingURL=ChangelogNotes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChangelogNotes.d.ts","sourceRoot":"","sources":["../src/ChangelogNotes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAMpE,MAAM,WAAW,oBAAoB;IACnC,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5B,IAAI,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,mBAAmB;IAClC,mEAAmE;IACnE,KAAK,EAAE,MAAM,CAAC;IACd,oEAAoE;IACpE,MAAM,CAAC,EAAE,oBAAoB,CAAC;CAC/B;AA0BD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,mBAAmB,+BAoCpE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Text, View } from "react-native";
|
|
3
|
+
import { parseChangelogNotes } from "@forthtilliath/expo-release-updates/parseChangelogNotes";
|
|
4
|
+
// Reasonable, neutral defaults so the component works with zero
|
|
5
|
+
// configuration — most consumers will still want to pass `styles` to match
|
|
6
|
+
// their own theme (colors, dark mode, ...), which this package has no
|
|
7
|
+
// opinion on.
|
|
8
|
+
const defaultStyles = {
|
|
9
|
+
heading: { fontSize: 13, fontWeight: "700", color: "#111827", marginTop: 8 },
|
|
10
|
+
itemRow: { flexDirection: "row", gap: 6, marginTop: 4 },
|
|
11
|
+
bullet: { fontSize: 13, color: "#6b7280" },
|
|
12
|
+
itemText: { flex: 1, fontSize: 13, color: "#6b7280" },
|
|
13
|
+
text: { fontSize: 13, color: "#6b7280" },
|
|
14
|
+
bold: { fontWeight: "700", color: "#111827" },
|
|
15
|
+
};
|
|
16
|
+
function renderSegments(segments, boldStyle) {
|
|
17
|
+
return segments.map((segment) => (_jsx(Text, { style: segment.bold ? boldStyle : undefined, children: segment.text }, segment.text)));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Renders GitHub-style release notes (parsed by `parseChangelogNotes`) as
|
|
21
|
+
* headings, bulleted items and bold-aware text, instead of showing the raw
|
|
22
|
+
* Markdown syntax in a plain `<Text>`.
|
|
23
|
+
*/
|
|
24
|
+
export function ChangelogNotes({ notes, styles }) {
|
|
25
|
+
const merged = { ...defaultStyles, ...styles };
|
|
26
|
+
const blocks = parseChangelogNotes(notes);
|
|
27
|
+
return (_jsx(_Fragment, { children: blocks.map((block, index) => {
|
|
28
|
+
// Blocks have no stable identity of their own (plain parsed lines),
|
|
29
|
+
// so the index is the only reasonable key — the list is never
|
|
30
|
+
// reordered or filtered after the initial parse.
|
|
31
|
+
const key = `${block.type}-${String(index)}`;
|
|
32
|
+
if (block.type === "heading") {
|
|
33
|
+
return (_jsx(Text, { style: merged.heading, children: block.text }, key));
|
|
34
|
+
}
|
|
35
|
+
if (block.type === "item") {
|
|
36
|
+
return (_jsxs(View, { style: merged.itemRow, children: [_jsx(Text, { style: merged.bullet, children: "\u2022" }), _jsx(Text, { style: merged.itemText, children: renderSegments(block.segments, merged.bold) })] }, key));
|
|
37
|
+
}
|
|
38
|
+
return (_jsx(Text, { style: merged.text, children: renderSegments(block.segments, merged.bold) }, key));
|
|
39
|
+
}) }));
|
|
40
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@forthtilliath/react-native-kit",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/Forthtilliath/turborepo.git",
|
|
12
|
+
"directory": "packages/react-native-kit"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/Forthtilliath/turborepo/tree/main/packages/react-native-kit#readme",
|
|
15
|
+
"bugs": "https://github.com/Forthtilliath/turborepo/issues",
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
19
|
+
"exports": {
|
|
20
|
+
"./*": "./dist/*.js"
|
|
21
|
+
},
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@forthtilliath/expo-release-updates": "0.2.0"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react": ">=19",
|
|
27
|
+
"react-native": ">=0.81"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/react": "^19.2.17",
|
|
31
|
+
"@types/react-test-renderer": "^19.1.0",
|
|
32
|
+
"eslint": "10.7.0",
|
|
33
|
+
"react": "^19.2.7",
|
|
34
|
+
"react-native": "0.86.0",
|
|
35
|
+
"react-test-renderer": "19.2.3",
|
|
36
|
+
"typescript": "^5.9.3",
|
|
37
|
+
"vitest": "^4.1.10",
|
|
38
|
+
"@forthtilliath/eslint-config": "0.0.0",
|
|
39
|
+
"@forthtilliath/typescript-config": "0.0.0"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"lint": "eslint . --max-warnings 0",
|
|
43
|
+
"check-types": "tsc --noEmit",
|
|
44
|
+
"clean": "rm -rf dist",
|
|
45
|
+
"dev": "tsc --watch -p tsconfig.build.json",
|
|
46
|
+
"build": "pnpm run clean && tsc -p tsconfig.build.json",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"test:watch": "vitest"
|
|
49
|
+
}
|
|
50
|
+
}
|