@hzblj/kara-router 0.1.0 → 0.2.1
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 +24 -0
- package/lib/module/tabs/tabs.js +28 -26
- package/lib/module/tabs/tabs.js.map +1 -1
- package/lib/typescript/tabs/tabs.types.d.ts +2 -1
- package/package.json +4 -6
- package/src/tabs/tabs.tsx +21 -17
- package/src/tabs/tabs.types.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# @hzblj/kara-router
|
|
2
2
|
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`be5be81`](https://github.com/hzblj/kara-ui/commit/be5be81a3764dfbd199c3c3cf90deadc6e53d268) Thanks [@hzblj](https://github.com/hzblj)! - Installable again: 0.2.0 was published with `workspace:^` ranges between the kara packages, which no package manager outside this repository resolves. The packages now go out through Yarn, which writes the real version ranges.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`be5be81`](https://github.com/hzblj/kara-ui/commit/be5be81a3764dfbd199c3c3cf90deadc6e53d268)]:
|
|
10
|
+
- @hzblj/kara-components@0.2.1
|
|
11
|
+
- @hzblj/kara-native@0.2.1
|
|
12
|
+
- @hzblj/kara-theme@0.2.1
|
|
13
|
+
|
|
14
|
+
## 0.2.0
|
|
15
|
+
|
|
16
|
+
### Minor Changes
|
|
17
|
+
|
|
18
|
+
- [`c30bef6`](https://github.com/hzblj/kara-ui/commit/c30bef6be2639deb6d385ad209d1a2799b5b656f) Thanks [@hzblj](https://github.com/hzblj)! - Icons are now fully native and the app's own: `plugins: [['@hzblj/kara-ui', {icons: {source: './assets/icons'}}]]` turns every SVG in the folder into an iOS asset-catalog template image and an Android vector drawable at prebuild (`x.ios.svg` / `x.android.svg` for per-platform glyphs), and writes `kara-icons.d.ts` so `name` only accepts icons that exist; `npx kara-icons` does the same for CI. `Icon` draws them in a host, the new `RnIcon` anywhere, and `Tabs` passes them as `xcasset` / `drawable`. The built-in SF Symbol / Material icon names and the `@expo/vector-icons` peer dependency are gone.
|
|
19
|
+
|
|
20
|
+
### Patch Changes
|
|
21
|
+
|
|
22
|
+
- Updated dependencies [[`c30bef6`](https://github.com/hzblj/kara-ui/commit/c30bef6be2639deb6d385ad209d1a2799b5b656f), [`c30bef6`](https://github.com/hzblj/kara-ui/commit/c30bef6be2639deb6d385ad209d1a2799b5b656f)]:
|
|
23
|
+
- @hzblj/kara-components@0.2.0
|
|
24
|
+
- @hzblj/kara-native@0.2.0
|
|
25
|
+
- @hzblj/kara-theme@0.2.0
|
|
26
|
+
|
|
3
27
|
## 0.1.0
|
|
4
28
|
|
|
5
29
|
### Minor Changes
|
package/lib/module/tabs/tabs.js
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { MATERIAL_ICONS, SF_SYMBOLS } from '@hzblj/kara-components';
|
|
3
|
+
import { iconResourceName } from '@hzblj/kara-native';
|
|
5
4
|
import { NativeTabs } from 'expo-router/unstable-native-tabs';
|
|
6
5
|
import { Children, isValidElement } from 'react';
|
|
7
6
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
7
|
const {
|
|
9
8
|
Icon,
|
|
10
|
-
Label
|
|
11
|
-
VectorIcon
|
|
9
|
+
Label
|
|
12
10
|
} = NativeTabs.Trigger;
|
|
13
|
-
const sfSymbol = name => SF_SYMBOLS[name];
|
|
14
|
-
const materialIcon = name => /*#__PURE__*/_jsx(VectorIcon, {
|
|
15
|
-
family: MaterialIcons,
|
|
16
|
-
name: MATERIAL_ICONS[name]
|
|
17
|
-
});
|
|
18
11
|
|
|
19
12
|
/**
|
|
20
13
|
* Declares one tab and renders nothing itself — `Tabs` reads these props and emits the trigger.
|
|
@@ -22,6 +15,11 @@ const materialIcon = name => /*#__PURE__*/_jsx(VectorIcon, {
|
|
|
22
15
|
* merely *renders* a trigger is invisible to it and the tab bar comes up empty.
|
|
23
16
|
*/
|
|
24
17
|
const TabsScreen = () => null;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The tab's icon, natively on both sides: the app icon's image set in the iOS asset catalog, its vector drawable on
|
|
21
|
+
* Android — one name, the one the config plugin gave both. No icon font, no bitmap rendered in JavaScript.
|
|
22
|
+
*/
|
|
25
23
|
const renderTrigger = ({
|
|
26
24
|
hidden,
|
|
27
25
|
icon,
|
|
@@ -29,23 +27,27 @@ const renderTrigger = ({
|
|
|
29
27
|
selectedIcon,
|
|
30
28
|
testID,
|
|
31
29
|
title
|
|
32
|
-
}) =>
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
},
|
|
30
|
+
}) => {
|
|
31
|
+
const asset = iconResourceName(icon);
|
|
32
|
+
const selected = selectedIcon ? iconResourceName(selectedIcon) : undefined;
|
|
33
|
+
return /*#__PURE__*/_jsxs(NativeTabs.Trigger, {
|
|
34
|
+
hidden: hidden,
|
|
35
|
+
name: name,
|
|
36
|
+
testID: testID,
|
|
37
|
+
children: [/*#__PURE__*/_jsx(Icon, {
|
|
38
|
+
drawable: selected ? {
|
|
39
|
+
default: asset,
|
|
40
|
+
selected
|
|
41
|
+
} : asset,
|
|
42
|
+
xcasset: selected ? {
|
|
43
|
+
default: asset,
|
|
44
|
+
selected
|
|
45
|
+
} : asset
|
|
46
|
+
}), /*#__PURE__*/_jsx(Label, {
|
|
47
|
+
children: title
|
|
48
|
+
})]
|
|
49
|
+
}, name);
|
|
50
|
+
};
|
|
49
51
|
const TabsRoot = ({
|
|
50
52
|
children,
|
|
51
53
|
minimizeBehavior = 'never'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["iconResourceName","NativeTabs","Children","isValidElement","jsx","_jsx","jsxs","_jsxs","Icon","Label","Trigger","TabsScreen","renderTrigger","hidden","icon","name","selectedIcon","testID","title","asset","selected","undefined","children","drawable","default","xcasset","TabsRoot","minimizeBehavior","map","child","type","props","Tabs","Object","assign","Screen"],"sourceRoot":"../../../src","sources":["tabs/tabs.tsx"],"mappings":";;AAAA,SAAQA,gBAAgB,QAAO,oBAAoB;AACnD,SAAQC,UAAU,QAAO,kCAAkC;AAC3D,SAAQC,QAAQ,EAAEC,cAAc,QAAO,OAAO;AAAA,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAI9C,MAAM;EAACC,IAAI;EAAEC;AAAK,CAAC,GAAGR,UAAU,CAACS,OAAO;;AAExC;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAmC,GAAGA,CAAA,KAAM,IAAI;;AAEtD;AACA;AACA;AACA;AACA,MAAMC,aAAa,GAAGA,CAAC;EAACC,MAAM;EAAEC,IAAI;EAAEC,IAAI;EAAEC,YAAY;EAAEC,MAAM;EAAEC;AAAsB,CAAC,KAAK;EAC5F,MAAMC,KAAK,GAAGnB,gBAAgB,CAACc,IAAI,CAAC;EACpC,MAAMM,QAAQ,GAAGJ,YAAY,GAAGhB,gBAAgB,CAACgB,YAAY,CAAC,GAAGK,SAAS;EAE1E,oBACEd,KAAA,CAACN,UAAU,CAACS,OAAO;IAACG,MAAM,EAAEA,MAAO;IAAYE,IAAI,EAAEA,IAAK;IAACE,MAAM,EAAEA,MAAO;IAAAK,QAAA,gBACxEjB,IAAA,CAACG,IAAI;MACHe,QAAQ,EAAEH,QAAQ,GAAG;QAACI,OAAO,EAAEL,KAAK;QAAEC;MAAQ,CAAC,GAAGD,KAAM;MACxDM,OAAO,EAAEL,QAAQ,GAAG;QAACI,OAAO,EAAEL,KAAK;QAAEC;MAAQ,CAAC,GAAGD;IAAM,CACxD,CAAC,eACFd,IAAA,CAACI,KAAK;MAAAa,QAAA,EAAEJ;IAAK,CAAQ,CAAC;EAAA,GALiBH,IAMrB,CAAC;AAEzB,CAAC;AAED,MAAMW,QAAQ,GAAGA,CAAC;EAACJ,QAAQ;EAAEK,gBAAgB,GAAG;AAAkB,CAAC,kBACjEtB,IAAA,CAACJ,UAAU;EAAC0B,gBAAgB,EAAEA,gBAAiB;EAAAL,QAAA,EAC5CpB,QAAQ,CAAC0B,GAAG,CAACN,QAAQ,EAAEO,KAAK,IAC3B,aAAA1B,cAAc,CAAkB0B,KAAK,CAAC,IAAIA,KAAK,CAACC,IAAI,KAAKnB,UAAU,GAAGC,aAAa,CAACiB,KAAK,CAACE,KAAK,CAAC,GAAGF,KACrG;AAAC,CACS,CACb;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMG,IAAmB,GAAGC,MAAM,CAACC,MAAM,CAACR,QAAQ,EAAE;EAACS,MAAM,EAAExB;AAAU,CAAC,CAAC","ignoreList":[]}
|
|
@@ -7,9 +7,10 @@ export type TabsScreenProps = {
|
|
|
7
7
|
* at runtime remounts the navigator, so pass a build constant.
|
|
8
8
|
*/
|
|
9
9
|
hidden?: boolean;
|
|
10
|
+
/** One of the app's icons — the asset-catalog image on iOS, the vector drawable on Android. */
|
|
10
11
|
icon: IconName;
|
|
11
12
|
name: string;
|
|
12
|
-
/** Swapped in while the tab is active — the filled
|
|
13
|
+
/** Swapped in while the tab is active — the filled counterpart of `icon`, say. */
|
|
13
14
|
selectedIcon?: IconName;
|
|
14
15
|
testID?: string;
|
|
15
16
|
title: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hzblj/kara-router",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Expo Router pieces of @hzblj/kara-ui: native tabs and a navigation theme mapped from the active kara theme.",
|
|
5
5
|
"author": "Jan Blazej",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,19 +59,17 @@
|
|
|
59
59
|
]
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@hzblj/kara-components": "^0.1
|
|
63
|
-
"@hzblj/kara-
|
|
64
|
-
"
|
|
62
|
+
"@hzblj/kara-components": "^0.2.1",
|
|
63
|
+
"@hzblj/kara-native": "^0.2.1",
|
|
64
|
+
"@hzblj/kara-theme": "^0.2.1"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@expo/vector-icons": "*",
|
|
68
67
|
"expo-router": "*",
|
|
69
68
|
"react": "*",
|
|
70
69
|
"react-native": "*"
|
|
71
70
|
},
|
|
72
71
|
"devDependencies": {
|
|
73
72
|
"@expo/ui": "~57.0.18",
|
|
74
|
-
"@expo/vector-icons": "^15.1.1",
|
|
75
73
|
"@storybook/react-native": "^10.6.0",
|
|
76
74
|
"@types/react": "~19.2.18",
|
|
77
75
|
"expo": "~57.0.22",
|
package/src/tabs/tabs.tsx
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {type IconName, MATERIAL_ICONS, SF_SYMBOLS} from '@hzblj/kara-components'
|
|
1
|
+
import {iconResourceName} from '@hzblj/kara-native'
|
|
3
2
|
import {NativeTabs} from 'expo-router/unstable-native-tabs'
|
|
4
3
|
import {Children, isValidElement} from 'react'
|
|
5
|
-
import type {SFSymbol} from 'sf-symbols-typescript'
|
|
6
|
-
import type {TabsComponent, TabsProps, TabsScreenProps} from './tabs.types'
|
|
7
|
-
|
|
8
|
-
const {Icon, Label, VectorIcon} = NativeTabs.Trigger
|
|
9
4
|
|
|
10
|
-
|
|
5
|
+
import type {TabsComponent, TabsProps, TabsScreenProps} from './tabs.types'
|
|
11
6
|
|
|
12
|
-
const
|
|
7
|
+
const {Icon, Label} = NativeTabs.Trigger
|
|
13
8
|
|
|
14
9
|
/**
|
|
15
10
|
* Declares one tab and renders nothing itself — `Tabs` reads these props and emits the trigger.
|
|
@@ -18,15 +13,24 @@ const materialIcon = (name: IconName) => <VectorIcon family={MaterialIcons} name
|
|
|
18
13
|
*/
|
|
19
14
|
const TabsScreen: TabsComponent['Screen'] = () => null
|
|
20
15
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
/**
|
|
17
|
+
* The tab's icon, natively on both sides: the app icon's image set in the iOS asset catalog, its vector drawable on
|
|
18
|
+
* Android — one name, the one the config plugin gave both. No icon font, no bitmap rendered in JavaScript.
|
|
19
|
+
*/
|
|
20
|
+
const renderTrigger = ({hidden, icon, name, selectedIcon, testID, title}: TabsScreenProps) => {
|
|
21
|
+
const asset = iconResourceName(icon)
|
|
22
|
+
const selected = selectedIcon ? iconResourceName(selectedIcon) : undefined
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<NativeTabs.Trigger hidden={hidden} key={name} name={name} testID={testID}>
|
|
26
|
+
<Icon
|
|
27
|
+
drawable={selected ? {default: asset, selected} : asset}
|
|
28
|
+
xcasset={selected ? {default: asset, selected} : asset}
|
|
29
|
+
/>
|
|
30
|
+
<Label>{title}</Label>
|
|
31
|
+
</NativeTabs.Trigger>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
30
34
|
|
|
31
35
|
const TabsRoot = ({children, minimizeBehavior = 'never'}: TabsProps) => (
|
|
32
36
|
<NativeTabs minimizeBehavior={minimizeBehavior}>
|
package/src/tabs/tabs.types.ts
CHANGED
|
@@ -8,9 +8,10 @@ export type TabsScreenProps = {
|
|
|
8
8
|
* at runtime remounts the navigator, so pass a build constant.
|
|
9
9
|
*/
|
|
10
10
|
hidden?: boolean
|
|
11
|
+
/** One of the app's icons — the asset-catalog image on iOS, the vector drawable on Android. */
|
|
11
12
|
icon: IconName
|
|
12
13
|
name: string
|
|
13
|
-
/** Swapped in while the tab is active — the filled
|
|
14
|
+
/** Swapped in while the tab is active — the filled counterpart of `icon`, say. */
|
|
14
15
|
selectedIcon?: IconName
|
|
15
16
|
testID?: string
|
|
16
17
|
title: string
|